summaryrefslogtreecommitdiff
path: root/package/omxplayer/patches/patch-Makefile_include
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@uclibc-ng.org>2016-07-05 19:55:04 +0200
committerWaldemar Brodkorb <wbx@uclibc-ng.org>2016-07-05 19:55:21 +0200
commitad91f62a75c2f0e58f57dbe25d702ac6da9b239c (patch)
treeb60a3d50f0412c88d9d874eb6303fbad8570048f /package/omxplayer/patches/patch-Makefile_include
parentf1fbc971e786acdb48e030c97344299f3ace9eb9 (diff)
allow to cross-compile x86_64 kernel on Darwin
Diffstat (limited to 'package/omxplayer/patches/patch-Makefile_include')
0 files changed, 0 insertions, 0 deletions
v1.0.13&id2=93b4dc9ccfb0c6e1872397b53e97fba9e799a7ad'>Makefile.in712
-rw-r--r--Makerules288
-rw-r--r--README75
-rw-r--r--Rules.mak705
-rw-r--r--TODO179
-rw-r--r--docs/Glibc_vs_uClibc_Differences.txt2
-rw-r--r--docs/PORTING3
-rw-r--r--docs/crt.txt80
-rw-r--r--docs/defines.txt83
-rw-r--r--docs/man/arc4random.3110
-rw-r--r--docs/probe_math_exception.c64
-rw-r--r--docs/pthreads_hacking.txt748
-rw-r--r--docs/sigaction.txt249
-rw-r--r--docs/wchar_and_locale.txt113
-rw-r--r--extra/Configs/Config.alpha4
-rw-r--r--extra/Configs/Config.arc46
-rw-r--r--extra/Configs/Config.arm138
-rw-r--r--extra/Configs/Config.avr324
-rw-r--r--extra/Configs/Config.bfin5
-rw-r--r--extra/Configs/Config.c6x29
-rw-r--r--extra/Configs/Config.cris10
-rw-r--r--extra/Configs/Config.e123
-rw-r--r--extra/Configs/Config.frv4
-rw-r--r--extra/Configs/Config.h83007
-rw-r--r--extra/Configs/Config.hppa4
-rw-r--r--extra/Configs/Config.i38679
-rw-r--r--extra/Configs/Config.i96019
-rw-r--r--extra/Configs/Config.ia644
-rw-r--r--extra/Configs/Config.in1082
-rw-r--r--extra/Configs/Config.in.arch59
-rw-r--r--extra/Configs/Config.lm32 (renamed from extra/Configs/Config.v850)13
-rw-r--r--extra/Configs/Config.m68k5
-rw-r--r--extra/Configs/Config.metag32
-rw-r--r--extra/Configs/Config.microblaze11
-rw-r--r--extra/Configs/Config.mips45
-rw-r--r--extra/Configs/Config.nios23
-rw-r--r--extra/Configs/Config.nios26
-rw-r--r--extra/Configs/Config.or1k35
-rw-r--r--extra/Configs/Config.powerpc4
-rw-r--r--extra/Configs/Config.sh9
-rw-r--r--extra/Configs/Config.sh6435
-rw-r--r--extra/Configs/Config.sparc14
-rw-r--r--extra/Configs/Config.vax24
-rw-r--r--extra/Configs/Config.x86_645
-rw-r--r--extra/Configs/Config.xtensa8
-rw-r--r--extra/Configs/defconfigs/alpha/defconfig (renamed from extra/Configs/defconfigs/alpha)0
-rw-r--r--extra/Configs/defconfigs/arc/arcv2_defconfig39
-rw-r--r--extra/Configs/defconfigs/arc/defconfig38
-rw-r--r--extra/Configs/defconfigs/arc/tb10x_defconfig38
-rw-r--r--extra/Configs/defconfigs/arm/defconfig (renamed from extra/Configs/defconfigs/arm)0
-rw-r--r--extra/Configs/defconfigs/avr32/defconfig (renamed from extra/Configs/defconfigs/avr32)0
-rw-r--r--extra/Configs/defconfigs/bfin/defconfig (renamed from extra/Configs/defconfigs/bfin)0
-rw-r--r--extra/Configs/defconfigs/cris/defconfig (renamed from extra/Configs/defconfigs/cris)0
-rw-r--r--extra/Configs/defconfigs/e11
-rw-r--r--extra/Configs/defconfigs/frv/defconfig (renamed from extra/Configs/defconfigs/frv)0
-rw-r--r--extra/Configs/defconfigs/h8300/defconfig (renamed from extra/Configs/defconfigs/h8300)0
-rw-r--r--extra/Configs/defconfigs/hppa/defconfig (renamed from extra/Configs/defconfigs/hppa)0
-rw-r--r--extra/Configs/defconfigs/i386/defconfig (renamed from extra/Configs/defconfigs/i386)0
-rw-r--r--extra/Configs/defconfigs/i9601
-rw-r--r--extra/Configs/defconfigs/ia64/defconfig (renamed from extra/Configs/defconfigs/ia64)0
-rw-r--r--extra/Configs/defconfigs/lm321
-rw-r--r--extra/Configs/defconfigs/m68k/defconfig (renamed from extra/Configs/defconfigs/m68k)0
-rw-r--r--extra/Configs/defconfigs/metag/defconfig1
-rw-r--r--extra/Configs/defconfigs/microblaze/defconfig (renamed from extra/Configs/defconfigs/microblaze)0
-rw-r--r--extra/Configs/defconfigs/mips/defconfig (renamed from extra/Configs/defconfigs/mips)0
-rw-r--r--extra/Configs/defconfigs/nios1
-rw-r--r--extra/Configs/defconfigs/nios2/defconfig (renamed from extra/Configs/defconfigs/nios2)0
-rw-r--r--extra/Configs/defconfigs/or1k/defconfig242
-rw-r--r--extra/Configs/defconfigs/powerpc/defconfig (renamed from extra/Configs/defconfigs/powerpc)0
-rw-r--r--extra/Configs/defconfigs/sh/defconfig (renamed from extra/Configs/defconfigs/sh)0
-rw-r--r--extra/Configs/defconfigs/sh641
-rw-r--r--extra/Configs/defconfigs/sparc/defconfig (renamed from extra/Configs/defconfigs/sparc)0
-rw-r--r--extra/Configs/defconfigs/v8501
-rw-r--r--extra/Configs/defconfigs/vax1
-rw-r--r--extra/Configs/defconfigs/x86_64/defconfig (renamed from extra/Configs/defconfigs/x86_64)0
-rw-r--r--extra/config/.gitignore7
-rw-r--r--extra/config/Makefile91
-rw-r--r--extra/config/Makefile.kconfig293
-rw-r--r--extra/config/README.uClibc3
-rwxr-xr-xextra/config/check.sh2
-rw-r--r--extra/config/conf.c510
-rw-r--r--extra/config/confdata.c871
-rw-r--r--extra/config/expr.c92
-rw-r--r--extra/config/expr.h122
-rw-r--r--extra/config/gconf.c218
-rw-r--r--extra/config/gconf.glade33
-rw-r--r--extra/config/kconfig-language.txt62
-rw-r--r--extra/config/kconfig-to-uclibc.patch.gzbin5989 -> 0 bytes-rw-r--r--extra/config/kconfig-to-uclibc.tar.gzbin0 -> 4285 bytes-rw-r--r--extra/config/kconfig_load.c35
-rw-r--r--extra/config/kxgettext.c24
-rw-r--r--extra/config/list.h131
-rw-r--r--extra/config/lkc.h84
-rw-r--r--extra/config/lkc_proto.h16
-rw-r--r--[-rwxr-xr-x]extra/config/lxdialog/check-lxdialog.sh15
-rw-r--r--extra/config/lxdialog/checklist.c21
-rw-r--r--extra/config/lxdialog/dialog.h31
-rw-r--r--extra/config/lxdialog/inputbox.c135
-rw-r--r--extra/config/lxdialog/menubox.c53
-rw-r--r--extra/config/lxdialog/textbox.c183
-rw-r--r--extra/config/lxdialog/util.c94
-rw-r--r--extra/config/lxdialog/yesno.c8
-rw-r--r--extra/config/mconf.c535
-rw-r--r--extra/config/menu.c325
-rwxr-xr-xextra/config/merge_config.sh150
-rw-r--r--extra/config/nconf.c1557
-rw-r--r--extra/config/nconf.gui.c656
-rw-r--r--extra/config/nconf.h96
-rw-r--r--extra/config/qconf.cc337
-rw-r--r--extra/config/qconf.h95
-rw-r--r--extra/config/streamline_config.pl640
-rw-r--r--extra/config/symbol.c636
-rw-r--r--extra/config/util.c70
-rw-r--r--extra/config/zconf.gperf3
-rw-r--r--extra/config/zconf.hash.c_shipped271
-rw-r--r--extra/config/zconf.l61
-rw-r--r--extra/config/zconf.lex.c_shipped (renamed from extra/config/lex.zconf.c_shipped)126
-rw-r--r--extra/config/zconf.tab.c_shipped1000
-rw-r--r--extra/config/zconf.y107
-rw-r--r--extra/locale/.gitignore26
-rw-r--r--extra/locale/Makefile6
-rw-r--r--extra/locale/Makefile.in189
-rw-r--r--extra/locale/gen_collate.c236
-rw-r--r--extra/locale/gen_ldc.c9
-rw-r--r--extra/locale/gen_locale.c227
-rw-r--r--extra/locale/gen_mmap.c2
-rw-r--r--extra/locale/gen_wc8bit.c327
-rw-r--r--extra/locale/gen_wctype.c913
-rw-r--r--extra/locale/lmmtolso.c6
-rw-r--r--extra/locale/locale_mmap.h52
-rw-r--r--extra/locale/programs/locale.c52
-rw-r--r--extra/scripts/.gitignore1
-rwxr-xr-xextra/scripts/MAKEALL146
-rwxr-xr-xextra/scripts/conf-header.sh2
-rwxr-xr-xextra/scripts/cppcheck.sh56
-rw-r--r--extra/scripts/gen-as-const.awk33
-rwxr-xr-xextra/scripts/gen_bits_syscall_h.sh56
-rwxr-xr-xextra/scripts/getent4
-rwxr-xr-xextra/scripts/install_headers.sh53
-rwxr-xr-xextra/scripts/install_kernel_headers.sh74
-rw-r--r--extra/scripts/none.lds13
-rwxr-xr-xextra/scripts/randconfig.sh26
-rwxr-xr-xextra/scripts/relative_path.sh5
-rwxr-xr-xextra/scripts/relinfo.pl5
-rw-r--r--extra/scripts/unifdef.c1159
-rw-r--r--extra/scripts/unifdef.h57
-rw-r--r--extra/scripts/unifdef.test67
-rw-r--r--extra/scripts/version.h2
-rw-r--r--include/.gitignore50
-rw-r--r--include/a.out.h6
-rw-r--r--include/alloca.h40
-rw-r--r--include/ar.h5
-rw-r--r--include/argp.h566
-rw-r--r--include/arpa/inet.h37
-rw-r--r--include/arpa/nameser.h19
-rw-r--r--include/arpa/nameser_compat.h4
-rw-r--r--include/assert.h16
-rw-r--r--include/atomic.h628
-rw-r--r--include/byteswap.h5
-rw-r--r--include/cancel.h101
-rw-r--r--include/complex.h28
-rw-r--r--include/cpio.h5
-rw-r--r--include/crypt.h6
-rw-r--r--include/ctype.h308
-rw-r--r--include/dirent.h132
-rw-r--r--include/dlfcn.h40
-rw-r--r--include/elf.h402
-rw-r--r--include/endian.h54
-rw-r--r--include/err.h21
-rw-r--r--include/errno.h32
-rw-r--r--include/error.h5
-rw-r--r--include/execinfo.h43
-rw-r--r--include/fcntl.h133
-rw-r--r--include/features.h203
-rw-r--r--include/fenv.h11
-rw-r--r--include/fnmatch.h16
-rw-r--r--include/fts.h131
-rw-r--r--include/ftw.h51
-rw-r--r--include/getopt.h2
-rw-r--r--include/glob.h44
-rw-r--r--include/gnu-versions.h9
-rw-r--r--include/grp.h33
-rw-r--r--include/iconv.h11
-rw-r--r--include/ieee754.h13
-rw-r--r--include/ifaddrs.h7
-rw-r--r--include/internal/parse_config.h57
-rw-r--r--include/internal/utmp.h92
-rw-r--r--include/inttypes.h161
-rw-r--r--include/langinfo.h58
-rw-r--r--include/libc-internal.h67
-rw-r--r--include/libc-symbols.h355
-rw-r--r--include/libgen.h5
-rw-r--r--include/libintl.h57
-rw-r--r--include/limits.h28
-rw-r--r--include/link.h33
-rw-r--r--include/locale.h29
-rw-r--r--include/malloc.h20
-rw-r--r--include/math.h130
-rw-r--r--include/memory.h5
-rw-r--r--include/mntent.h16
-rw-r--r--include/mqueue.h5
-rw-r--r--include/net/ethernet.h15
-rw-r--r--include/net/if.h10
-rw-r--r--include/net/if_arp.h17
-rw-r--r--include/net/if_packet.h5
-rw-r--r--include/net/if_shaper.h5
-rw-r--r--include/net/if_slip.h5
-rw-r--r--include/net/route.h9
-rw-r--r--include/netax25/ax25.h5
-rw-r--r--include/netdb.h206
-rw-r--r--include/neteconet/ec.h5
-rw-r--r--include/netinet/ether.h26
-rw-r--r--include/netinet/icmp6.h21
-rw-r--r--include/netinet/if_ether.h5
-rw-r--r--include/netinet/if_fddi.h5
-rw-r--r--include/netinet/if_tr.h5
-rw-r--r--include/netinet/igmp.h5
-rw-r--r--include/netinet/in.h152
-rw-r--r--include/netinet/in_systm.h5
-rw-r--r--include/netinet/ip.h85
-rw-r--r--include/netinet/ip6.h13
-rw-r--r--include/netinet/ip_icmp.h5
-rw-r--r--include/netinet/protocols.h62
-rw-r--r--include/netinet/tcp.h10
-rw-r--r--include/netinet/udp.h17
-rw-r--r--include/netipx/ipx.h5
-rw-r--r--include/netpacket/packet.h5
-rw-r--r--include/nl_types.h15
-rw-r--r--include/obstack.h324
-rw-r--r--include/paths.h2
-rw-r--r--include/printf.h27
-rw-r--r--include/protocols/timed.h5
-rw-r--r--include/pty.h6
-rw-r--r--include/pwd.h16
-rw-r--r--include/regex.h155
-rw-r--r--include/regexp.h35
-rw-r--r--include/resolv.h159
-rw-r--r--include/rpc/auth.h33
-rw-r--r--include/rpc/auth_des.h17
-rw-r--r--include/rpc/auth_unix.h1
-rw-r--r--include/rpc/clnt.h40
-rw-r--r--include/rpc/netdb.h9
-rw-r--r--include/rpc/pmap_clnt.h23
-rw-r--r--include/rpc/pmap_prot.h2
-rw-r--r--include/rpc/pmap_rmt.h3
-rw-r--r--include/rpc/rpc.h20
-rw-r--r--include/rpc/rpc_msg.h24
-rw-r--r--include/rpc/svc.h16
-rw-r--r--include/rpc/svc_auth.h1
-rw-r--r--include/rpc/types.h13
-rw-r--r--include/rpc/xdr.h48
-rw-r--r--include/sched.h67
-rw-r--r--include/scsi/scsi.h5
-rw-r--r--include/scsi/scsi_ioctl.h5
-rw-r--r--include/scsi/sg.h5
-rw-r--r--include/search.h28
-rw-r--r--include/setjmp.h58
-rw-r--r--include/sgtty.h13
-rw-r--r--include/shadow.h19
-rw-r--r--include/signal.h210
-rw-r--r--include/spawn.h295
-rw-r--r--include/stdint.h22
-rw-r--r--include/stdio.h266
-rw-r--r--include/stdio_ext.h6
-rw-r--r--include/stdlib.h305
-rw-r--r--include/string.h214
-rw-r--r--include/strings.h48
-rw-r--r--include/sys/cdefs.h47
-rw-r--r--include/sys/dir.h5
-rw-r--r--include/sys/file.h7
-rw-r--r--include/sys/fsuid.h5
-rw-r--r--include/sys/ioctl.h6
-rw-r--r--include/sys/ipc.h7
-rw-r--r--include/sys/kd.h5
-rw-r--r--include/sys/kdaemon.h5
-rw-r--r--include/sys/klog.h5
-rw-r--r--include/sys/mman.h30
-rw-r--r--include/sys/mount.h67
-rw-r--r--include/sys/msg.h17
-rw-r--r--include/sys/mtio.h5
-rw-r--r--include/sys/param.h23
-rw-r--r--include/sys/personality.h5
-rw-r--r--include/sys/poll.h12
-rw-r--r--include/sys/queue.h842
-rw-r--r--include/sys/quota.h96
-rw-r--r--include/sys/reboot.h5
-rw-r--r--include/sys/resource.h15
-rw-r--r--include/sys/select.h9
-rw-r--r--include/sys/sem.h7
-rw-r--r--include/sys/sendfile.h6
-rw-r--r--include/sys/shm.h12
-rw-r--r--include/sys/socket.h58
-rw-r--r--include/sys/stat.h87
-rw-r--r--include/sys/statfs.h16
-rw-r--r--include/sys/statvfs.h21
-rw-r--r--include/sys/swap.h9
-rw-r--r--include/sys/syscall.h16
-rw-r--r--include/sys/sysctl.h5
-rw-r--r--include/sys/sysinfo.h14
-rw-r--r--include/sys/syslog.h7
-rw-r--r--include/sys/sysmacros.h34
-rw-r--r--include/sys/time.h36
-rw-r--r--include/sys/timeb.h5
-rw-r--r--include/sys/times.h6
-rw-r--r--include/sys/timex.h19
-rw-r--r--include/sys/ttydefaults.h6
-rw-r--r--include/sys/types.h11
-rw-r--r--include/sys/uio.h9
-rw-r--r--include/sys/un.h5
-rw-r--r--include/sys/ustat.h5
-rw-r--r--include/sys/utsname.h29
-rw-r--r--include/sys/wait.h67
-rw-r--r--include/sys/xattr.h31
-rw-r--r--include/tar.h5
-rw-r--r--include/termios.h15
-rw-r--r--include/tgmath.h329
-rw-r--r--include/time.h92
-rw-r--r--include/tls.h19
-rw-r--r--include/ttyent.h7
-rw-r--r--include/ucontext.h37
-rw-r--r--include/ulimit.h5
-rw-r--r--include/unistd.h362
-rw-r--r--include/utime.h10
-rw-r--r--include/utmp.h31
-rw-r--r--include/utmpx.h126
-rw-r--r--include/values.h7
-rw-r--r--include/wchar-stub.h13
-rw-r--r--include/wchar.h225
-rw-r--r--include/wctype.h30
-rw-r--r--include/wordexp.h8
-rw-r--r--include/xlocale.h36
-rw-r--r--ldso/include/dl-defs.h49
-rw-r--r--ldso/include/dl-elf.h118
-rw-r--r--ldso/include/dl-hash.h102
-rw-r--r--ldso/include/dl-string.h95
-rw-r--r--ldso/include/dl-syscall.h211
-rw-r--r--ldso/include/dlfcn.h4
-rw-r--r--ldso/include/inline-hashtab.h265
-rw-r--r--ldso/include/ldso.h77
-rw-r--r--ldso/include/ldsodefs.h154
-rw-r--r--ldso/include/tlsdeschtab.h121
-rw-r--r--ldso/ldso/Makefile.in54
-rw-r--r--ldso/ldso/arc/dl-debug.h83
-rw-r--r--ldso/ldso/arc/dl-startup.h91
-rw-r--r--ldso/ldso/arc/dl-syscalls.h7
-rw-r--r--ldso/ldso/arc/dl-sysdep.h175
-rw-r--r--ldso/ldso/arc/elfinterp.c311
-rw-r--r--ldso/ldso/arc/resolve.S57
-rw-r--r--ldso/ldso/arm/aeabi_read_tp.S62
-rw-r--r--ldso/ldso/arm/dl-debug.h6
-rw-r--r--ldso/ldso/arm/dl-startup.h22
-rw-r--r--ldso/ldso/arm/dl-syscalls.h6
-rw-r--r--ldso/ldso/arm/dl-sysdep.h34
-rw-r--r--ldso/ldso/arm/elfinterp.c110
-rw-r--r--ldso/ldso/arm/resolve.S23
-rw-r--r--ldso/ldso/arm/thumb_atomics.S78
-rw-r--r--ldso/ldso/avr32/dl-debug.h2
-rw-r--r--ldso/ldso/avr32/dl-startup.h16
-rw-r--r--ldso/ldso/avr32/dl-syscalls.h7
-rw-r--r--ldso/ldso/avr32/dl-sysdep.h27
-rw-r--r--ldso/ldso/avr32/elfinterp.c55
-rw-r--r--ldso/ldso/bfin/dl-debug.h22
-rw-r--r--ldso/ldso/bfin/dl-inlines.h694
-rw-r--r--ldso/ldso/bfin/dl-startup.h107
-rw-r--r--ldso/ldso/bfin/dl-syscalls.h185
-rw-r--r--ldso/ldso/bfin/dl-sysdep.h171
-rw-r--r--ldso/ldso/bfin/elfinterp.c62
-rw-r--r--ldso/ldso/bfin/resolve.S5
-rw-r--r--ldso/ldso/c6x/dl-debug.h49
-rw-r--r--ldso/ldso/c6x/dl-inlines.h120
-rw-r--r--ldso/ldso/c6x/dl-startup.h189
-rw-r--r--ldso/ldso/c6x/dl-syscalls.h1
-rw-r--r--ldso/ldso/c6x/dl-sysdep.h230
-rw-r--r--ldso/ldso/c6x/elfinterp.c304
-rw-r--r--ldso/ldso/c6x/resolve.S68
-rw-r--r--ldso/ldso/cris/dl-debug.h2
-rw-r--r--ldso/ldso/cris/dl-startup.h8
-rw-r--r--ldso/ldso/cris/dl-syscalls.h7
-rw-r--r--ldso/ldso/cris/dl-sysdep.h14
-rw-r--r--ldso/ldso/cris/elfinterp.c66
-rw-r--r--ldso/ldso/dl-debug.c51
-rw-r--r--ldso/ldso/dl-elf.c775
-rw-r--r--ldso/ldso/dl-hash.c204
-rw-r--r--ldso/ldso/dl-startup.c182
-rw-r--r--ldso/ldso/dl-symbols.c21
-rw-r--r--ldso/ldso/dl-tls.c1056
-rw-r--r--ldso/ldso/fdpic/dl-inlines.h228
-rw-r--r--ldso/ldso/fdpic/dl-sysdep.h136
-rw-r--r--ldso/ldso/frv/dl-debug.h2
-rw-r--r--ldso/ldso/frv/dl-inlines.h457
-rw-r--r--ldso/ldso/frv/dl-startup.h35
-rw-r--r--ldso/ldso/frv/dl-syscalls.h176
-rw-r--r--ldso/ldso/frv/dl-sysdep.h122
-rw-r--r--ldso/ldso/frv/elfinterp.c113
-rw-r--r--ldso/ldso/h8300/dl-sysdep.h1
-rw-r--r--ldso/ldso/i386/dl-debug.h2
-rw-r--r--ldso/ldso/i386/dl-startup.h5
-rw-r--r--ldso/ldso/i386/dl-syscalls.h7
-rw-r--r--ldso/ldso/i386/dl-sysdep.h40
-rw-r--r--ldso/ldso/i386/elfinterp.c84
-rw-r--r--ldso/ldso/ldso.c968
-rw-r--r--ldso/ldso/m68k/dl-debug.h2
-rw-r--r--ldso/ldso/m68k/dl-startup.h20
-rw-r--r--ldso/ldso/m68k/dl-syscalls.h7
-rw-r--r--ldso/ldso/m68k/dl-sysdep.h34
-rw-r--r--ldso/ldso/m68k/elfinterp.c47
-rw-r--r--ldso/ldso/m68k/resolve.S5
-rw-r--r--ldso/ldso/metag/dl-debug.h33
-rw-r--r--ldso/ldso/metag/dl-inlines.h39
-rw-r--r--ldso/ldso/metag/dl-startup.h68
-rw-r--r--ldso/ldso/metag/dl-syscalls.h6
-rw-r--r--ldso/ldso/metag/dl-sysdep.h121
-rw-r--r--ldso/ldso/metag/elfinterp.c318
-rw-r--r--ldso/ldso/metag/metag_load_tp.S20
-rw-r--r--ldso/ldso/metag/resolve.S51
-rw-r--r--ldso/ldso/microblaze/dl-debug.h54
-rw-r--r--ldso/ldso/microblaze/dl-startup.h102
-rw-r--r--ldso/ldso/microblaze/dl-syscalls.h1
-rw-r--r--ldso/ldso/microblaze/dl-sysdep.h84
-rw-r--r--ldso/ldso/microblaze/elfinterp.c330
-rw-r--r--ldso/ldso/microblaze/resolve.S51
-rw-r--r--ldso/ldso/mips/README4
-rw-r--r--ldso/ldso/mips/dl-debug.h15
-rw-r--r--ldso/ldso/mips/dl-startup.h8
-rw-r--r--ldso/ldso/mips/dl-syscalls.h7
-rw-r--r--ldso/ldso/mips/dl-sysdep.h68
-rw-r--r--ldso/ldso/mips/elfinterp.c178
-rw-r--r--ldso/ldso/mips/resolve.S51
-rw-r--r--ldso/ldso/or1k/dl-debug.h (renamed from libc/string/sh64/strlen.S)64
-rw-r--r--ldso/ldso/or1k/dl-startup.h106
-rw-r--r--ldso/ldso/or1k/dl-syscalls.h1
-rw-r--r--ldso/ldso/or1k/dl-sysdep.h105
-rw-r--r--ldso/ldso/or1k/elfinterp.c333
-rw-r--r--ldso/ldso/or1k/resolve.S54
-rw-r--r--ldso/ldso/powerpc/dl-debug.h2
-rw-r--r--ldso/ldso/powerpc/dl-startup.h7
-rw-r--r--ldso/ldso/powerpc/dl-syscalls.h7
-rw-r--r--ldso/ldso/powerpc/dl-sysdep.h15
-rw-r--r--ldso/ldso/powerpc/elfinterp.c132
-rw-r--r--ldso/ldso/powerpc/resolve.S14
-rw-r--r--ldso/ldso/sh/dl-debug.h4
-rw-r--r--ldso/ldso/sh/dl-startup.h15
-rw-r--r--ldso/ldso/sh/dl-syscalls.h11
-rw-r--r--ldso/ldso/sh/dl-sysdep.h19
-rw-r--r--ldso/ldso/sh/elfinterp.c108
-rw-r--r--ldso/ldso/sh64/dl-debug.h79
-rw-r--r--ldso/ldso/sh64/dl-startup.h117
-rw-r--r--ldso/ldso/sh64/dl-syscalls.h25
-rw-r--r--ldso/ldso/sh64/dl-sysdep.h169
-rw-r--r--ldso/ldso/sh64/elfinterp.c346
-rw-r--r--ldso/ldso/sh64/resolve.S95
-rw-r--r--ldso/ldso/sparc/dl-debug.h2
-rw-r--r--ldso/ldso/sparc/dl-startup.h3
-rw-r--r--ldso/ldso/sparc/dl-syscalls.h7
-rw-r--r--ldso/ldso/sparc/dl-sysdep.h29
-rw-r--r--ldso/ldso/sparc/elfinterp.c116
-rw-r--r--ldso/ldso/x86_64/dl-debug.h2
-rw-r--r--ldso/ldso/x86_64/dl-startup.h6
-rw-r--r--ldso/ldso/x86_64/dl-syscalls.h7
-rw-r--r--ldso/ldso/x86_64/dl-sysdep.h18
-rw-r--r--ldso/ldso/x86_64/elfinterp.c81
-rw-r--r--ldso/ldso/xtensa/dl-debug.h79
-rw-r--r--ldso/ldso/xtensa/dl-startup.h34
-rw-r--r--ldso/ldso/xtensa/dl-syscalls.h8
-rw-r--r--ldso/ldso/xtensa/dl-sysdep.h52
-rw-r--r--ldso/ldso/xtensa/dl-tlsdesc.S103
-rw-r--r--ldso/ldso/xtensa/elfinterp.c142
-rw-r--r--ldso/ldso/xtensa/resolve.S48
-rw-r--r--ldso/libdl/Makefile.in23
-rw-r--r--ldso/libdl/libdl.c579
-rw-r--r--ldso/man/dlopen.35
-rw-r--r--libc/.gitignore1
-rw-r--r--libc/Makefile.in31
-rw-r--r--libc/inet/Makefile.in81
-rw-r--r--libc/inet/_res_state.c8
-rw-r--r--libc/inet/accept4.c (renamed from libc/inet/resolveaddress.c)4
-rw-r--r--libc/inet/addr.c35
-rw-r--r--libc/inet/closenameservers.c2
-rw-r--r--libc/inet/decodea.c2
-rw-r--r--libc/inet/decoded.c2
-rw-r--r--libc/inet/decodeh.c2
-rw-r--r--libc/inet/decodep.c2
-rw-r--r--libc/inet/decodeq.c2
-rw-r--r--libc/inet/dnslookup.c2
-rw-r--r--libc/inet/encodea.c2
-rw-r--r--libc/inet/encoded.c2
-rw-r--r--libc/inet/encodeh.c2
-rw-r--r--libc/inet/encodep.c2
-rw-r--r--libc/inet/encodeq.c2
-rw-r--r--libc/inet/ether_addr.c64
-rw-r--r--libc/inet/formquery.c2
-rw-r--r--libc/inet/gai_strerror.c10
-rw-r--r--libc/inet/get_hosts_byaddr_r.c2
-rw-r--r--libc/inet/get_hosts_byname_r.c2
-rw-r--r--libc/inet/getaddrinfo.c1532
-rw-r--r--libc/inet/gethostbyaddr.c2
-rw-r--r--libc/inet/gethostbyaddr_r.c2
-rw-r--r--libc/inet/gethostbyname.c2
-rw-r--r--libc/inet/gethostbyname2.c2
-rw-r--r--libc/inet/gethostbyname2_r.c2
-rw-r--r--libc/inet/gethostbyname_r.c2
-rw-r--r--libc/inet/gethostent.c2
-rw-r--r--libc/inet/gethostent_r.c (renamed from libc/inet/resolvename.c)4
-rw-r--r--libc/inet/getnameinfo.c2
-rw-r--r--libc/inet/getnet.c208
-rw-r--r--libc/inet/getnetbyad.c40
-rw-r--r--libc/inet/getnetbynm.c49
-rw-r--r--libc/inet/getnetent.c148
-rw-r--r--libc/inet/getproto.c355
-rw-r--r--libc/inet/getservice.c361
-rw-r--r--libc/inet/herror.c19
-rw-r--r--libc/inet/hostid.c96
-rw-r--r--libc/inet/if_index.c43
-rw-r--r--libc/inet/ifaddrs.c75
-rw-r--r--libc/inet/in6_addr.c8
-rw-r--r--libc/inet/inet_addr.c2
-rw-r--r--libc/inet/inet_makeaddr.c2
-rw-r--r--libc/inet/inet_net.c9
-rw-r--r--libc/inet/lengthd.c2
-rw-r--r--libc/inet/lengthq.c2
-rw-r--r--libc/inet/netlinkaccess.h39
-rw-r--r--libc/inet/ns_name.c2
-rw-r--r--libc/inet/ns_netint.c8
-rw-r--r--libc/inet/ns_parse.c8
-rw-r--r--libc/inet/ntohl.c62
-rw-r--r--libc/inet/ntop.c103
-rw-r--r--libc/inet/opennameservers.c2
-rw-r--r--libc/inet/opensock.c31
-rw-r--r--libc/inet/read_etc_hosts_r.c2
-rw-r--r--libc/inet/res_comp.c2
-rw-r--r--libc/inet/res_data.c8
-rw-r--r--libc/inet/res_init.c2
-rw-r--r--libc/inet/res_query.c2
-rw-r--r--libc/inet/resolv.c4838
-rw-r--r--libc/inet/rpc/Makefile.in39
-rw-r--r--libc/inet/rpc/auth_none.c66
-rw-r--r--libc/inet/rpc/auth_unix.c39
-rw-r--r--libc/inet/rpc/authunix_prot.c6
-rw-r--r--libc/inet/rpc/bindresvport.c7
-rw-r--r--libc/inet/rpc/clnt_generic.c15
-rw-r--r--libc/inet/rpc/clnt_perror.c97
-rw-r--r--libc/inet/rpc/clnt_raw.c22
-rw-r--r--libc/inet/rpc/clnt_simple.c9
-rw-r--r--libc/inet/rpc/clnt_tcp.c68
-rw-r--r--libc/inet/rpc/clnt_udp.c73
-rw-r--r--libc/inet/rpc/clnt_unix.c68
-rw-r--r--libc/inet/rpc/create_xid.c17
-rw-r--r--libc/inet/rpc/errqueue.h5
-rw-r--r--libc/inet/rpc/get_myaddress.c6
-rw-r--r--libc/inet/rpc/getrpcent.c19
-rw-r--r--libc/inet/rpc/getrpcport.c6
-rw-r--r--libc/inet/rpc/pm_getmaps.c9
-rw-r--r--libc/inet/rpc/pm_getport.c28
-rw-r--r--libc/inet/rpc/pmap_clnt.c16
-rw-r--r--libc/inet/rpc/pmap_prot.c6
-rw-r--r--libc/inet/rpc/pmap_prot2.c8
-rw-r--r--libc/inet/rpc/pmap_rmt.c64
-rw-r--r--libc/inet/rpc/rcmd.c143
-rw-r--r--libc/inet/rpc/rexec.c95
-rw-r--r--libc/inet/rpc/rpc_cmsg.c10
-rw-r--r--libc/inet/rpc/rpc_dtablesize.c6
-rw-r--r--libc/inet/rpc/rpc_private.h8
-rw-r--r--libc/inet/rpc/rpc_prot.c16
-rw-r--r--libc/inet/rpc/rpc_thread.c10
-rw-r--r--libc/inet/rpc/rtime.c12
-rw-r--r--libc/inet/rpc/ruserpass.c33
-rw-r--r--libc/inet/rpc/sa_len.c13
-rw-r--r--libc/inet/rpc/svc.c27
-rw-r--r--libc/inet/rpc/svc_auth.c5
-rw-r--r--libc/inet/rpc/svc_authux.c7
-rw-r--r--libc/inet/rpc/svc_raw.c11
-rw-r--r--libc/inet/rpc/svc_run.c10
-rw-r--r--libc/inet/rpc/svc_simple.c36
-rw-r--r--libc/inet/rpc/svc_tcp.c51
-rw-r--r--libc/inet/rpc/svc_udp.c91
-rw-r--r--libc/inet/rpc/svc_unix.c52
-rw-r--r--libc/inet/rpc/xdr.c70
-rw-r--r--libc/inet/rpc/xdr_array.c31
-rw-r--r--libc/inet/rpc/xdr_float.c183
-rw-r--r--libc/inet/rpc/xdr_intXX_t.c11
-rw-r--r--libc/inet/rpc/xdr_mem.c10
-rw-r--r--libc/inet/rpc/xdr_rec.c135
-rw-r--r--libc/inet/rpc/xdr_reference.c30
-rw-r--r--libc/inet/rpc/xdr_stdio.c18
-rw-r--r--libc/inet/socketcalls.c352
-rw-r--r--libc/misc/Makefile.in3
-rw-r--r--libc/misc/assert/Makefile.in16
-rw-r--r--libc/misc/assert/__assert.c15
-rw-r--r--libc/misc/ctype/Makefile.in34
-rw-r--r--libc/misc/ctype/ctype.c90
-rw-r--r--libc/misc/dirent/Makefile.in24
-rw-r--r--libc/misc/dirent/alphasort.c11
-rw-r--r--libc/misc/dirent/alphasort64.c13
-rw-r--r--libc/misc/dirent/closedir.c5
-rw-r--r--libc/misc/dirent/dirfd.c1
-rw-r--r--libc/misc/dirent/dirstream.h21
-rw-r--r--libc/misc/dirent/opendir.c98
-rw-r--r--libc/misc/dirent/readdir.c29
-rw-r--r--libc/misc/dirent/readdir64.c53
-rw-r--r--libc/misc/dirent/readdir64_r.c64
-rw-r--r--libc/misc/dirent/readdir_r.c29
-rw-r--r--libc/misc/dirent/rewinddir.c1
-rw-r--r--libc/misc/dirent/scandir.c59
-rw-r--r--libc/misc/dirent/scandir64.c111
-rw-r--r--libc/misc/dirent/seekdir.c1
-rw-r--r--libc/misc/dirent/versionsort.c17
-rw-r--r--libc/misc/dirent/versionsort64.c18
-rw-r--r--libc/misc/elf/Makefile12
-rw-r--r--libc/misc/elf/Makefile.in22
-rw-r--r--libc/misc/elf/dl-core.c20
-rw-r--r--libc/misc/elf/dl-iterate-phdr.c81
-rw-r--r--libc/misc/elf/dl-support.c75
-rw-r--r--libc/misc/error/Makefile.in24
-rw-r--r--libc/misc/error/err.c44
-rw-r--r--libc/misc/error/error.c24
-rw-r--r--libc/misc/file/Makefile.in20
-rw-r--r--libc/misc/file/isfdtype.c40
-rw-r--r--libc/misc/file/issetugid.c10
-rw-r--r--libc/misc/file/lockf.c12
-rw-r--r--libc/misc/file/lockf64.c9
-rw-r--r--libc/misc/fnmatch/Makefile.in20
-rw-r--r--libc/misc/fnmatch/fnmatch.c62
-rw-r--r--libc/misc/fnmatch/fnmatch_loop.c9
-rw-r--r--libc/misc/fnmatch/fnmatch_old.c7
-rw-r--r--libc/misc/fts/Makefile14
-rw-r--r--libc/misc/fts/Makefile.in23
-rw-r--r--libc/misc/fts/fts.c1114
-rw-r--r--libc/misc/ftw/Makefile.in22
-rw-r--r--libc/misc/ftw/ftw.c48
-rw-r--r--libc/misc/ftw/ftw64.c5
-rw-r--r--libc/misc/glob/Makefile.in28
-rw-r--r--libc/misc/glob/glob-susv3.c27
-rw-r--r--libc/misc/glob/glob.c31
-rw-r--r--libc/misc/gnu/Makefile.in17
-rw-r--r--libc/misc/gnu/obprintf.c29
-rw-r--r--libc/misc/gnu/obstack.c413
-rw-r--r--libc/misc/internals/Makefile.in20
-rw-r--r--libc/misc/internals/__errno_location.c15
-rw-r--r--libc/misc/internals/__h_errno_location.c12
-rw-r--r--libc/misc/internals/__uClibc_main.c330
-rw-r--r--libc/misc/internals/errno.c23
-rw-r--r--libc/misc/internals/h_errno.c14
-rw-r--r--libc/misc/internals/internal_errno.h18
-rw-r--r--libc/misc/internals/parse_config.c278
-rw-r--r--libc/misc/internals/tempname.c58
-rw-r--r--libc/misc/internals/tempname.h4
-rw-r--r--libc/misc/locale/Makefile.in25
-rw-r--r--libc/misc/locale/locale.c177
-rw-r--r--libc/misc/mntent/Makefile.in16
-rw-r--r--libc/misc/mntent/mntent.c17
-rw-r--r--libc/misc/pthread/Makefile.in13
-rw-r--r--libc/misc/pthread/tsd.c18
-rw-r--r--libc/misc/pthread/weaks.c44
-rw-r--r--libc/misc/regex/Makefile.in21
-rw-r--r--libc/misc/regex/_regex.h45
-rw-r--r--libc/misc/regex/regcomp.c298
-rw-r--r--libc/misc/regex/regex.c143
-rw-r--r--libc/misc/regex/regex_internal.c70
-rw-r--r--libc/misc/regex/regex_internal.h127
-rw-r--r--libc/misc/regex/regex_old.c251
-rw-r--r--libc/misc/regex/regexec.c217
-rw-r--r--libc/misc/search/Makefile.in24
-rw-r--r--libc/misc/search/_hsearch_r.c20
-rw-r--r--libc/misc/search/_lsearch.c4
-rw-r--r--libc/misc/search/_tsearch.c18
-rw-r--r--libc/misc/search/hsearch.c8
-rw-r--r--libc/misc/search/insremque.c23
-rw-r--r--libc/misc/statfs/Makefile.in25
-rw-r--r--libc/misc/statfs/fstatfs64.c28
-rw-r--r--libc/misc/statfs/fstatvfs.c15
-rw-r--r--libc/misc/statfs/fstatvfs64.c17
-rw-r--r--libc/misc/statfs/internal_statvfs.c125
-rw-r--r--libc/misc/statfs/statfs64.c27
-rw-r--r--libc/misc/statfs/statvfs.c14
-rw-r--r--libc/misc/statfs/statvfs64.c17
-rw-r--r--libc/misc/syslog/Makefile.in16
-rw-r--r--libc/misc/syslog/syslog.c185
-rw-r--r--libc/misc/sysvipc/Makefile.in22
-rw-r--r--libc/misc/sysvipc/__syscall_ipc.c2
-rw-r--r--libc/misc/sysvipc/ftok.c14
-rw-r--r--libc/misc/sysvipc/ipc.h10
-rw-r--r--libc/misc/sysvipc/msgq.c55
-rw-r--r--libc/misc/sysvipc/sem.c19
-rw-r--r--libc/misc/sysvipc/shm.c16
-rw-r--r--libc/misc/time/Makefile.in39
-rw-r--r--libc/misc/time/adjtime.c1
-rw-r--r--libc/misc/time/ftime.c12
-rw-r--r--libc/misc/time/time.c554
-rw-r--r--libc/misc/ttyent/Makefile.in16
-rw-r--r--libc/misc/ttyent/getttyent.c23
-rw-r--r--libc/misc/utmp/Makefile.in17
-rw-r--r--libc/misc/utmp/utent.c315
-rw-r--r--libc/misc/utmp/wtent.c58
-rw-r--r--libc/misc/wchar/Makefile.in20
-rw-r--r--libc/misc/wchar/wchar.c356
-rw-r--r--libc/misc/wctype/Makefile.in24
-rw-r--r--libc/misc/wctype/_wctype.c523
-rw-r--r--libc/misc/wordexp/Makefile.in16
-rw-r--r--libc/misc/wordexp/wordexp.c127
-rw-r--r--libc/pwd_grp/Makefile.in27
-rw-r--r--libc/pwd_grp/__getgrouplist_internal.c8
-rw-r--r--libc/pwd_grp/fgetgrent.c12
-rw-r--r--libc/pwd_grp/fgetpwent.c12
-rw-r--r--libc/pwd_grp/fgetspent.c6
-rw-r--r--libc/pwd_grp/getgrent.c5
-rw-r--r--libc/pwd_grp/getgrgid.c6
-rw-r--r--libc/pwd_grp/getgrgid_r.c7
-rw-r--r--libc/pwd_grp/getgrnam.c6
-rw-r--r--libc/pwd_grp/getgrnam_r.c7
-rw-r--r--libc/pwd_grp/getgrouplist.c8
-rw-r--r--libc/pwd_grp/getpwent.c5
-rw-r--r--libc/pwd_grp/getpwnam.c7
-rw-r--r--libc/pwd_grp/getpwnam_r.c7
-rw-r--r--libc/pwd_grp/getpwuid.c6
-rw-r--r--libc/pwd_grp/getpwuid_r.c7
-rw-r--r--libc/pwd_grp/getspent.c5
-rw-r--r--libc/pwd_grp/getspnam.c6
-rw-r--r--libc/pwd_grp/getspnam_r.c7
-rw-r--r--libc/pwd_grp/lckpwdf.c99
-rw-r--r--libc/pwd_grp/pwd_grp.c422
-rw-r--r--libc/pwd_grp/pwd_grp_internal.c56
-rw-r--r--libc/pwd_grp/sgetspent.c6
-rw-r--r--libc/signal/Makefile.in40
-rw-r--r--libc/signal/allocrtsig.c15
-rw-r--r--libc/signal/killpg.c7
-rw-r--r--libc/signal/raise.c13
-rw-r--r--libc/signal/sigaction.c77
-rw-r--r--libc/signal/sigaddset.c14
-rw-r--r--libc/signal/sigandset.c5
-rw-r--r--libc/signal/sigblock.c22
-rw-r--r--libc/signal/sigdelset.c14
-rw-r--r--libc/signal/sigempty.c20
-rw-r--r--libc/signal/sigfillset.c23
-rw-r--r--libc/signal/siggetmask.c10
-rw-r--r--libc/signal/sighold.c13
-rw-r--r--libc/signal/sigignore.c14
-rw-r--r--libc/signal/sigintr.c22
-rw-r--r--libc/signal/sigisempty.c5
-rw-r--r--libc/signal/sigismem.c10
-rw-r--r--libc/signal/sigjmp.c12
-rw-r--r--libc/signal/signal.c26
-rw-r--r--libc/signal/sigorset.c5
-rw-r--r--libc/signal/sigpause.c54
-rw-r--r--libc/signal/sigrelse.c13
-rw-r--r--libc/signal/sigset-cvt-mask.h32
-rw-r--r--libc/signal/sigset.c54
-rw-r--r--libc/signal/sigsetmask.c23
-rw-r--r--libc/signal/sigsetops.c11
-rw-r--r--libc/signal/sigwait.c71
-rw-r--r--libc/signal/sysv_signal.c15
-rw-r--r--libc/stdio/Makefile.in81
-rw-r--r--libc/stdio/_READ.c4
-rw-r--r--libc/stdio/_WRITE.c57
-rw-r--r--libc/stdio/__fpending.c7
-rw-r--r--libc/stdio/__fsetlocking.c1
-rw-r--r--libc/stdio/_cs_funcs.c51
-rw-r--r--libc/stdio/_flushlbf.c1
-rw-r--r--libc/stdio/_fopen.c38
-rw-r--r--libc/stdio/_fpmaxtostr.c57
-rw-r--r--libc/stdio/_fpmaxtostr.h49
-rw-r--r--libc/stdio/_fwrite.c3
-rw-r--r--libc/stdio/_load_inttype.c3
-rw-r--r--libc/stdio/_rfill.c2
-rw-r--r--libc/stdio/_scanf.c237
-rw-r--r--libc/stdio/_stdio.c65
-rw-r--r--libc/stdio/_stdio.h121
-rw-r--r--libc/stdio/_store_inttype.c1
-rw-r--r--libc/stdio/_trans2w.c1
-rw-r--r--libc/stdio/_uintmaxtostr.c48
-rw-r--r--libc/stdio/_vfprintf.c511
-rw-r--r--libc/stdio/_wfwrite.c6
-rw-r--r--libc/stdio/asprintf.c2
-rw-r--r--libc/stdio/ctermid.c1
-rw-r--r--libc/stdio/dprintf.c1
-rw-r--r--libc/stdio/fclose.c5
-rw-r--r--libc/stdio/fcloseall.c1
-rw-r--r--libc/stdio/fdopen.c9
-rw-r--r--libc/stdio/fflush.c11
-rw-r--r--libc/stdio/fgetc.c10
-rw-r--r--libc/stdio/fgets.c4
-rw-r--r--libc/stdio/fgetwc.c12
-rw-r--r--libc/stdio/fgetws.c2
-rw-r--r--libc/stdio/fileno.c3
-rw-r--r--libc/stdio/fmemopen.c2
-rw-r--r--libc/stdio/fopen.c5
-rw-r--r--libc/stdio/fopencookie.c30
-rw-r--r--libc/stdio/fprintf.c2
-rw-r--r--libc/stdio/fputc.c13
-rw-r--r--libc/stdio/fputs.c5
-rw-r--r--libc/stdio/fputwc.c3
-rw-r--r--libc/stdio/fputws.c4
-rw-r--r--libc/stdio/fread.c7
-rw-r--r--libc/stdio/freopen.c1
-rw-r--r--libc/stdio/fseeko.c7
-rw-r--r--libc/stdio/ftello.c7
-rw-r--r--libc/stdio/fwprintf.c1
-rw-r--r--libc/stdio/fwrite.c3
-rw-r--r--libc/stdio/getchar.c2
-rw-r--r--libc/stdio/getdelim.c2
-rw-r--r--libc/stdio/getline.c2
-rw-r--r--libc/stdio/gets.c3
-rw-r--r--libc/stdio/getw.c1
-rw-r--r--libc/stdio/getwchar.c2
-rw-r--r--libc/stdio/old_vfprintf.c27
-rw-r--r--libc/stdio/open_memstream.c10
-rw-r--r--libc/stdio/perror.c3
-rw-r--r--libc/stdio/popen.c30
-rw-r--r--libc/stdio/printf.c2
-rw-r--r--libc/stdio/putchar.c1
-rw-r--r--libc/stdio/puts.c2
-rw-r--r--libc/stdio/putw.c1
-rw-r--r--libc/stdio/putwchar.c8
-rw-r--r--libc/stdio/remove.c7
-rw-r--r--libc/stdio/rewind.c2
-rw-r--r--libc/stdio/setbuf.c1
-rw-r--r--libc/stdio/setbuffer.c1
-rw-r--r--libc/stdio/setlinebuf.c1
-rw-r--r--libc/stdio/setvbuf.c1
-rw-r--r--libc/stdio/snprintf.c2
-rw-r--r--libc/stdio/sprintf.c2
-rw-r--r--libc/stdio/swprintf.c1
-rw-r--r--libc/stdio/tempnam.c7
-rw-r--r--libc/stdio/tmpfile.c12
-rw-r--r--libc/stdio/tmpnam.c11
-rw-r--r--libc/stdio/tmpnam_r.c5
-rw-r--r--libc/stdio/ungetc.c1
-rw-r--r--libc/stdio/ungetwc.c1
-rw-r--r--libc/stdio/vasprintf.c11
-rw-r--r--libc/stdio/vdprintf.c20
-rw-r--r--libc/stdio/vprintf.c1
-rw-r--r--libc/stdio/vsnprintf.c57
-rw-r--r--libc/stdio/vsprintf.c1
-rw-r--r--libc/stdio/vswprintf.c21
-rw-r--r--libc/stdio/vwprintf.c1
-rw-r--r--libc/stdio/wprintf.c1
-rw-r--r--libc/stdlib/Makefile.in108
-rw-r--r--libc/stdlib/__uc_malloc.c7
-rw-r--r--libc/stdlib/_atexit.c76
-rw-r--r--libc/stdlib/_strtod.c48
-rw-r--r--libc/stdlib/a64l.c5
-rw-r--r--libc/stdlib/abort.c35
-rw-r--r--libc/stdlib/arc4random.c219
-rw-r--r--libc/stdlib/bsd_getpt.c9
-rw-r--r--libc/stdlib/canonicalize.c19
-rw-r--r--libc/stdlib/drand48-iter.c9
-rw-r--r--libc/stdlib/drand48.c10
-rw-r--r--libc/stdlib/drand48_r.c6
-rw-r--r--libc/stdlib/erand48.c10
-rw-r--r--libc/stdlib/erand48_r.c9
-rw-r--r--libc/stdlib/gcvt.c1
-rw-r--r--libc/stdlib/getenv.c5
-rw-r--r--libc/stdlib/getpt.c42
-rw-r--r--libc/stdlib/grantpt.c31
-rw-r--r--libc/stdlib/jrand48.c10
-rw-r--r--libc/stdlib/jrand48_r.c9
-rw-r--r--libc/stdlib/l64a.c23
-rw-r--r--libc/stdlib/lcong48.c29
-rw-r--r--libc/stdlib/ldiv.c5
-rw-r--r--libc/stdlib/lldiv.c5
-rw-r--r--libc/stdlib/lrand48.c10
-rw-r--r--libc/stdlib/lrand48_r.c7
-rw-r--r--libc/stdlib/malloc-simple/Makefile.in20
-rw-r--r--libc/stdlib/malloc-simple/alloc.c27
-rw-r--r--libc/stdlib/malloc-standard/Makefile.in18
-rw-r--r--libc/stdlib/malloc-standard/calloc.c1
-rw-r--r--libc/stdlib/malloc-standard/free.c7
-rw-r--r--libc/stdlib/malloc-standard/mallinfo.c11
-rw-r--r--libc/stdlib/malloc-standard/malloc.c7
-rw-r--r--libc/stdlib/malloc-standard/malloc.h37
-rw-r--r--libc/stdlib/malloc-standard/memalign.c4
-rw-r--r--libc/stdlib/malloc-standard/realloc.c4
-rw-r--r--libc/stdlib/malloc/Makefile.in18
-rw-r--r--libc/stdlib/malloc/calloc.c5
-rw-r--r--libc/stdlib/malloc/free.c40
-rw-r--r--libc/stdlib/malloc/heap.h86
-rw-r--r--libc/stdlib/malloc/heap_alloc.c8
-rw-r--r--libc/stdlib/malloc/heap_alloc_at.c8
-rw-r--r--libc/stdlib/malloc/heap_debug.c15
-rw-r--r--libc/stdlib/malloc/heap_free.c8
-rw-r--r--libc/stdlib/malloc/malloc.c46
-rw-r--r--libc/stdlib/malloc/malloc.h73
-rw-r--r--libc/stdlib/malloc/malloc_debug.c4
-rw-r--r--libc/stdlib/malloc/memalign.c7
-rw-r--r--libc/stdlib/malloc/realloc.c20
-rw-r--r--libc/stdlib/mkdtemp.c6
-rw-r--r--libc/stdlib/mkostemp.c32
-rw-r--r--libc/stdlib/mkostemp64.c32
-rw-r--r--libc/stdlib/mkostemps.c36
-rw-r--r--libc/stdlib/mkostemps64.c34
-rw-r--r--libc/stdlib/mkstemp.c6
-rw-r--r--libc/stdlib/mkstemp64.c6
-rw-r--r--libc/stdlib/mkstemps.c33
-rw-r--r--libc/stdlib/mkstemps64.c33
-rw-r--r--libc/stdlib/mktemp.c7
-rw-r--r--libc/stdlib/mrand48.c10
-rw-r--r--libc/stdlib/mrand48_r.c6
-rw-r--r--libc/stdlib/nrand48.c10
-rw-r--r--libc/stdlib/nrand48_r.c9
-rw-r--r--libc/stdlib/posix_memalign.c5
-rw-r--r--libc/stdlib/ptsname.c13
-rw-r--r--libc/stdlib/pty-private.h3
-rw-r--r--libc/stdlib/qsort_r.c7
-rw-r--r--libc/stdlib/rand.c6
-rw-r--r--libc/stdlib/rand_r.c5
-rw-r--r--libc/stdlib/random.c16
-rw-r--r--libc/stdlib/random_r.c12
-rw-r--r--libc/stdlib/realpath.c28
-rw-r--r--libc/stdlib/rpmatch.c7
-rw-r--r--libc/stdlib/seed48.c10
-rw-r--r--libc/stdlib/seed48_r.c7
-rw-r--r--libc/stdlib/setenv.c243
-rw-r--r--libc/stdlib/srand48.c10
-rw-r--r--libc/stdlib/srand48_r.c6
-rw-r--r--libc/stdlib/stdlib.c222
-rw-r--r--libc/stdlib/system.c255
-rw-r--r--libc/stdlib/unix_grantpt.c25
-rw-r--r--libc/stdlib/unlockpt.c4
-rw-r--r--libc/stdlib/valloc.c4
-rw-r--r--libc/string/Makefile.in15
-rw-r--r--libc/string/__glibc_strerror_r.c9
-rw-r--r--libc/string/__xpg_basename.c5
-rw-r--r--libc/string/__xpg_strerror_r.c12
-rw-r--r--libc/string/_collate.c36
-rwxr-xr-xlibc/string/arc/Makefile13
-rw-r--r--libc/string/arc/arcv2/memcpy.S236
-rw-r--r--libc/string/arc/arcv2/memset.S115
-rw-r--r--libc/string/arc/arcv2/strcmp.S83
-rw-r--r--libc/string/arc/memcmp.S157
-rw-r--r--libc/string/arc/memcpy.S71
-rw-r--r--libc/string/arc/memset.S51
-rw-r--r--libc/string/arc/strchr.S138
-rw-r--r--libc/string/arc/strcmp.S102
-rw-r--r--libc/string/arc/strcpy.S71
-rw-r--r--libc/string/arc/strlen.S84
-rw-r--r--libc/string/arm/_memcpy.S24
-rw-r--r--libc/string/arm/memcmp.S13
-rw-r--r--libc/string/arm/memset.S19
-rw-r--r--libc/string/arm/strcmp.S7
-rw-r--r--libc/string/arm/strlen.S13
-rw-r--r--libc/string/arm/strncmp.S101
-rw-r--r--libc/string/avr32/Makefile3
-rw-r--r--libc/string/basename.c4
-rw-r--r--libc/string/bcopy.c24
-rw-r--r--libc/string/bfin/memchr.S4
-rw-r--r--libc/string/bfin/strcmp.S80
-rw-r--r--libc/string/bzero.c16
-rw-r--r--libc/string/cris/memcopy.h3
-rw-r--r--libc/string/cris/memcpy.c380
-rw-r--r--libc/string/cris/memmove.c6
-rw-r--r--libc/string/cris/memset.c435
-rw-r--r--libc/string/cris/strcpy.c1
-rw-r--r--libc/string/cris/strncpy.c2
-rw-r--r--libc/string/dirname.c3
-rw-r--r--libc/string/ffs.c12
-rw-r--r--libc/string/ffsll.c35
-rw-r--r--libc/string/frv/memcpy.S4
-rw-r--r--libc/string/frv/memset.S6
-rw-r--r--libc/string/generic/bp-checks.h129
-rw-r--r--libc/string/generic/memchr.c9
-rw-r--r--libc/string/generic/memcmp.c23
-rw-r--r--libc/string/generic/memcopy.h8
-rw-r--r--libc/string/generic/memcpy.c7
-rw-r--r--libc/string/generic/memmem.c8
-rw-r--r--libc/string/generic/memmove.c7
-rw-r--r--libc/string/generic/mempcpy.c4
-rw-r--r--libc/string/generic/memrchr.c7
-rw-r--r--libc/string/generic/memset.c6
-rw-r--r--libc/string/generic/pagecopy.h9
-rw-r--r--libc/string/generic/rawmemchr.c7
-rw-r--r--libc/string/generic/strcat.c6
-rw-r--r--libc/string/generic/strchr.c7
-rw-r--r--libc/string/generic/strchrnul.c7
-rw-r--r--libc/string/generic/strcmp.c7
-rw-r--r--libc/string/generic/strcpy.c33
-rw-r--r--libc/string/generic/strcspn.c7
-rw-r--r--libc/string/generic/strlen.c7
-rw-r--r--libc/string/generic/strncat.c6
-rw-r--r--libc/string/generic/strncmp.c6
-rw-r--r--libc/string/generic/strncpy.c6
-rw-r--r--libc/string/generic/strnlen.c11
-rw-r--r--libc/string/generic/strrchr.c7
-rw-r--r--libc/string/generic/strsep.c8
-rw-r--r--libc/string/generic/strspn.c6
-rw-r--r--libc/string/generic/strstr.c6
-rw-r--r--libc/string/generic/strtok_r.c24
-rw-r--r--libc/string/i386/memchr.c52
-rw-r--r--libc/string/i386/memcpy.c31
-rw-r--r--libc/string/i386/memmove.c52
-rw-r--r--libc/string/i386/memset.c66
-rw-r--r--libc/string/i386/rawmemchr.c24
-rw-r--r--libc/string/i386/strcat.c1
-rw-r--r--libc/string/i386/strchr.c32
-rw-r--r--libc/string/i386/strchrnul.c47
-rw-r--r--libc/string/i386/strcmp.c2
-rw-r--r--libc/string/i386/strcpy.c2
-rw-r--r--libc/string/i386/string.h338
-rw-r--r--libc/string/i386/strlen.c20
-rw-r--r--libc/string/i386/strncat.c73
-rw-r--r--libc/string/i386/strncmp.c41
-rw-r--r--libc/string/i386/strncpy.c55
-rw-r--r--libc/string/i386/strnlen.c51
-rw-r--r--libc/string/i386/strrchr.c30
-rw-r--r--libc/string/ia64/bcopy.S2
-rw-r--r--libc/string/ia64/bzero.S143
-rw-r--r--libc/string/ia64/memccpy.S109
-rw-r--r--libc/string/ia64/memchr.S47
-rw-r--r--libc/string/ia64/memcmp.S101
-rw-r--r--libc/string/ia64/memcpy.S167
-rw-r--r--libc/string/ia64/memmove.S177
-rw-r--r--libc/string/ia64/memset.S185
-rw-r--r--libc/string/ia64/softpipe.h5
-rw-r--r--libc/string/ia64/strchr.S39
-rw-r--r--libc/string/ia64/strcmp.S9
-rw-r--r--libc/string/ia64/strcpy.S73
-rw-r--r--libc/string/ia64/strlen.S25
-rw-r--r--libc/string/ia64/strncmp.S17
-rw-r--r--libc/string/ia64/strncpy.S97
-rw-r--r--libc/string/ia64/sysdep.h168
-rw-r--r--libc/string/memchr.c14
-rw-r--r--libc/string/memcmp.c1
-rw-r--r--libc/string/memcpy.c9
-rw-r--r--libc/string/memmem.c2
-rw-r--r--libc/string/memmove.c22
-rw-r--r--libc/string/mempcpy.c9
-rw-r--r--libc/string/memrchr.c16
-rw-r--r--libc/string/memset.c13
-rw-r--r--libc/string/metag/Makefile13
-rw-r--r--libc/string/metag/memchr.S156
-rw-r--r--libc/string/metag/memcpy.S189
-rw-r--r--libc/string/metag/memmove.S350
-rw-r--r--libc/string/metag/memset.S90
-rw-r--r--libc/string/metag/strchr.S167
-rw-r--r--libc/string/metag/strcmp.S65
-rw-r--r--libc/string/metag/strcpy.S94
-rw-r--r--libc/string/microblaze/Makefile (renamed from libc/string/sh64/Makefile)4
-rw-r--r--libc/string/microblaze/memcpy.S334
-rw-r--r--libc/string/microblaze/memmove.S356
-rw-r--r--libc/string/mips/memcpy.S1055
-rw-r--r--libc/string/mips/memset.S520
-rw-r--r--libc/string/mips/sysdep.h45
-rw-r--r--libc/string/powerpc/memcpy.c28
-rw-r--r--libc/string/powerpc/memmove.c2
-rw-r--r--libc/string/powerpc/memset.c1
-rw-r--r--libc/string/psignal.c2
-rw-r--r--libc/string/rawmemchr.c1
-rw-r--r--libc/string/sh/memchr.S30
-rw-r--r--libc/string/sh/sh4/memcpy.S242
-rw-r--r--libc/string/sh/sh4/memmove.c121
-rw-r--r--libc/string/sh/sh4/memset.S152
-rw-r--r--libc/string/sh/sh4/strcpy.S28
-rw-r--r--libc/string/sh/sh4/strncpy.S43
-rw-r--r--libc/string/sh/strlen.S75
-rw-r--r--libc/string/sh64/memcpy.S205
-rw-r--r--libc/string/sh64/memset.S96
-rw-r--r--libc/string/sh64/strcpy.S102
-rw-r--r--libc/string/sparc/sparc32/memchr.S7
-rw-r--r--libc/string/sparc/sparc32/memcpy.S5
-rw-r--r--libc/string/sparc/sparc32/memset.S5
-rw-r--r--libc/string/sparc/sparc32/stpcpy.S5
-rw-r--r--libc/string/sparc/sparc32/strcat.S5
-rw-r--r--libc/string/sparc/sparc32/strchr.S5
-rw-r--r--libc/string/sparc/sparc32/strcmp.S5
-rw-r--r--libc/string/sparc/sparc32/strcpy.S5
-rw-r--r--libc/string/sparc/sparc32/strlen.S5
-rw-r--r--libc/string/sparc/sparc64/memchr.S261
-rw-r--r--libc/string/sparc/sparc64/memcpy.S923
-rw-r--r--libc/string/sparc/sparc64/memset.S317
-rw-r--r--libc/string/sparc/sparc64/sparcv9b/memcpy.S612
-rw-r--r--libc/string/sparc/sparc64/stpcpy.S271
-rw-r--r--libc/string/sparc/sparc64/strcat.S339
-rw-r--r--libc/string/sparc/sparc64/strchr.S486
-rw-r--r--libc/string/sparc/sparc64/strcmp.S279
-rw-r--r--libc/string/sparc/sparc64/strcpy.S245
-rw-r--r--libc/string/sparc/sparc64/strlen.S173
-rw-r--r--libc/string/stpcpy.c8
-rw-r--r--libc/string/stpncpy.c13
-rw-r--r--libc/string/strcasecmp.c18
-rw-r--r--libc/string/strcasestr.c7
-rw-r--r--libc/string/strcat.c2
-rw-r--r--libc/string/strchr.c9
-rw-r--r--libc/string/strchrnul.c6
-rw-r--r--libc/string/strcmp.c3
-rw-r--r--libc/string/strcpy.c13
-rw-r--r--libc/string/strcspn.c1
-rw-r--r--libc/string/strdup.c4
-rw-r--r--libc/string/strerror.c2
-rw-r--r--libc/string/strlcpy.c16
-rw-r--r--libc/string/strlen.c2
-rw-r--r--libc/string/strncasecmp.c18
-rw-r--r--libc/string/strncat.c5
-rw-r--r--libc/string/strncmp.c1
-rw-r--r--libc/string/strncpy.c8
-rw-r--r--libc/string/strndup.c3
-rw-r--r--libc/string/strnlen.c13
-rw-r--r--libc/string/strpbrk.c2
-rw-r--r--libc/string/strrchr.c1
-rw-r--r--libc/string/strsep.c3
-rw-r--r--libc/string/strsignal.c38
-rw-r--r--libc/string/strspn.c2
-rw-r--r--libc/string/strstr.c3
-rw-r--r--libc/string/strtok.c1
-rw-r--r--libc/string/strtok_r.c5
-rw-r--r--libc/string/strverscmp.c106
-rw-r--r--libc/string/sys_errlist.c2
-rw-r--r--libc/string/x86_64/bzero.S1
-rw-r--r--libc/string/x86_64/memcpy.S7
-rw-r--r--libc/string/x86_64/mempcpy.S1
-rw-r--r--libc/string/x86_64/memset.S9
-rw-r--r--libc/string/x86_64/strcat.S5
-rw-r--r--libc/string/x86_64/strchr.S5
-rw-r--r--libc/string/x86_64/strcmp.S5
-rw-r--r--libc/string/x86_64/strcpy.S5
-rw-r--r--libc/string/x86_64/strcspn.S5
-rw-r--r--libc/string/x86_64/strlen.S5
-rw-r--r--libc/string/x86_64/strspn.S5
-rw-r--r--libc/string/xtensa/memcpy.S45
-rw-r--r--libc/string/xtensa/memset.S23
-rw-r--r--libc/string/xtensa/strcmp.S180
-rw-r--r--libc/string/xtensa/strcpy.S91
-rw-r--r--libc/string/xtensa/strlen.S71
-rw-r--r--libc/string/xtensa/strncpy.S165
-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/mman.h103
-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/nios/bits/endian.h)7
-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/m68k/bits/mman.h)30
-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.c27
-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/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/sys/ucontext.h76
-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/e1/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/v850/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/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/v850/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/e1/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/vax/sys/ucontext.h)86
-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/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/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/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/endian.h9
-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/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/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
-rw-r--r--libc/termios/Makefile.in10
-rw-r--r--libc/termios/cfmakeraw.c5
-rw-r--r--libc/termios/cfsetspeed.c7
-rw-r--r--libc/termios/isatty.c7
-rw-r--r--libc/termios/kernel_termios.h5
-rw-r--r--libc/termios/speed.c7
-rw-r--r--libc/termios/tcdrain.c25
-rw-r--r--libc/termios/tcflow.c6
-rw-r--r--libc/termios/tcflush.c6
-rw-r--r--libc/termios/tcgetattr.c10
-rw-r--r--libc/termios/tcgetpgrp.c7
-rw-r--r--libc/termios/tcgetsid.c8
-rw-r--r--libc/termios/tcsendbrk.c6
-rw-r--r--libc/termios/tcsetattr.c8
-rw-r--r--libc/termios/tcsetpgrp.c6
-rw-r--r--libc/termios/ttyname.c9
-rw-r--r--libc/unistd/Makefile.in50
-rw-r--r--libc/unistd/confstr.c26
-rw-r--r--libc/unistd/daemon.c109
-rw-r--r--libc/unistd/exec.c58
-rw-r--r--libc/unistd/execvpe.c7
-rw-r--r--libc/unistd/fpathconf.c10
-rw-r--r--libc/unistd/getlogin.c4
-rw-r--r--libc/unistd/getopt-susv3.c12
-rw-r--r--libc/unistd/getopt.c54
-rw-r--r--libc/unistd/getopt_int.h5
-rw-r--r--libc/unistd/getopt_long-simple.c1
-rw-r--r--libc/unistd/getpass.c70
-rw-r--r--libc/unistd/getsubopt-susv3.c3
-rw-r--r--libc/unistd/getsubopt.c8
-rw-r--r--libc/unistd/pathconf.c8
-rw-r--r--libc/unistd/sleep.c159
-rw-r--r--libc/unistd/sysconf.c146
-rw-r--r--libc/unistd/ualarm.c1
-rw-r--r--libc/unistd/usershell.c184
-rw-r--r--libc/unistd/usleep.c16
-rw-r--r--libcrypt/Makefile.in34
-rw-r--r--libcrypt/crypt.c29
-rw-r--r--libcrypt/crypt_stub.c1
-rw-r--r--libcrypt/des.c43
-rw-r--r--libcrypt/libcrypt.h5
-rw-r--r--libcrypt/md5.c19
-rw-r--r--libcrypt/sha256-crypt.c325
-rw-r--r--libcrypt/sha256.c293
-rw-r--r--libcrypt/sha256.h57
-rw-r--r--libcrypt/sha512-crypt.c338
-rw-r--r--libcrypt/sha512.c325
-rw-r--r--libcrypt/sha512.h57
-rw-r--r--libintl/Makefile.in20
-rw-r--r--libm/Makefile.in279
-rw-r--r--libm/README1
-rw-r--r--libm/carg.c9
-rw-r--r--libm/cexp.c63
-rw-r--r--libm/e_acos.c19
-rw-r--r--libm/e_acosh.c22
-rw-r--r--libm/e_asin.c22
-rw-r--r--libm/e_atan2.c22
-rw-r--r--libm/e_atanh.c25
-rw-r--r--libm/e_cosh.c22
-rw-r--r--libm/e_exp.c20
-rw-r--r--libm/e_exp10.c33
-rw-r--r--libm/e_fmod.c19
-rw-r--r--libm/e_gamma_r.c33
-rw-r--r--libm/e_hypot.c25
-rw-r--r--libm/e_j0.c130
-rw-r--r--libm/e_j1.c134
-rw-r--r--libm/e_jn.c36
-rw-r--r--libm/e_lgamma_r.c98
-rw-r--r--libm/e_log.c23
-rw-r--r--libm/e_log10.c25
-rw-r--r--libm/e_log2.c119
-rw-r--r--libm/e_pow.c95
-rw-r--r--libm/e_rem_pio2.c26
-rw-r--r--libm/e_remainder.c23
-rw-r--r--libm/e_scalb.c44
-rw-r--r--libm/e_sinh.c22
-rw-r--r--libm/e_sqrt.c25
-rw-r--r--libm/float_wrappers.c403
-rw-r--r--libm/fp_private.h90
-rw-r--r--libm/fpmacros.c303
-rw-r--r--libm/i386/fclrexcpt.c5
-rw-r--r--libm/i386/fedisblxcpt.c5
-rw-r--r--libm/i386/feenablxcpt.c5
-rw-r--r--libm/i386/fegetenv.c5
-rw-r--r--libm/i386/fegetexcept.c5
-rw-r--r--libm/i386/fegetround.c5
-rw-r--r--libm/i386/feholdexcpt.c5
-rw-r--r--libm/i386/fesetenv.c5
-rw-r--r--libm/i386/fesetround.c5
-rw-r--r--libm/i386/feupdateenv.c5
-rw-r--r--libm/i386/fgetexcptflg.c5
-rw-r--r--libm/i386/fraiseexcpt.c5
-rw-r--r--libm/i386/fsetexcptflg.c5
-rw-r--r--libm/i386/ftestexcept.c5
-rw-r--r--libm/k_cos.c16
-rw-r--r--libm/k_rem_pio2.c27
-rw-r--r--libm/k_sin.c16
-rw-r--r--libm/k_standard.c789
-rw-r--r--libm/k_tan.c18
-rw-r--r--libm/ldouble_wrappers.c453
-rw-r--r--libm/math_private.h87
-rw-r--r--libm/metag/Makefile.arch23
-rw-r--r--libm/metag/fclrexcpt.c44
-rw-r--r--libm/metag/fedisblxcpt.c40
-rw-r--r--libm/metag/feenablxcpt.c (renamed from libc/signal/sigsetops.h)33
-rw-r--r--libm/metag/fegetenv.c36
-rw-r--r--libm/metag/fegetexcept.c31
-rw-r--r--libm/metag/fegetround.c30
-rw-r--r--libm/metag/feholdexcpt.c41
-rw-r--r--libm/metag/fesetenv.c60
-rw-r--r--libm/metag/fesetround.c41
-rw-r--r--libm/metag/feupdateenv.c45
-rw-r--r--libm/metag/fgetexcptflg.c34
-rw-r--r--libm/metag/fraiseexcpt.c92
-rw-r--r--libm/metag/fsetexcptflg.c44
-rw-r--r--libm/metag/ftestexcept.c32
-rw-r--r--libm/metag/internal.h7
-rw-r--r--libm/nan.c7
-rw-r--r--libm/powerpc/classic/Makefile.arch4
-rw-r--r--libm/powerpc/classic/s_ceil.c113
-rw-r--r--libm/powerpc/classic/s_copysign.c59
-rw-r--r--libm/powerpc/classic/s_floor.c113
-rw-r--r--libm/powerpc/classic/s_frexp.c65
-rw-r--r--libm/powerpc/classic/s_ldexp.c49
-rw-r--r--libm/powerpc/classic/s_logb.c107
-rw-r--r--libm/powerpc/classic/s_modf.c344
-rw-r--r--libm/powerpc/classic/s_nearbyint.c38
-rw-r--r--libm/powerpc/classic/s_rint.c159
-rw-r--r--libm/powerpc/classic/s_round.c115
-rw-r--r--libm/powerpc/classic/s_trunc.c89
-rw-r--r--libm/powerpc/classic/w_scalb.c94
-rw-r--r--libm/powerpc/e500/Makefile.arch2
-rw-r--r--libm/powerpc/e500/fpu/Makefile.arch2
-rw-r--r--libm/powerpc/e500/fpu/fclrexcpt.c5
-rw-r--r--libm/powerpc/e500/fpu/fe_nomask.c5
-rw-r--r--libm/powerpc/e500/fpu/fedisblxcpt.c5
-rw-r--r--libm/powerpc/e500/fpu/feenablxcpt.c5
-rw-r--r--libm/powerpc/e500/fpu/fegetenv.c5
-rw-r--r--libm/powerpc/e500/fpu/fegetexcept.c5
-rw-r--r--libm/powerpc/e500/fpu/fegetround.c5
-rw-r--r--libm/powerpc/e500/fpu/feholdexcpt.c5
-rw-r--r--libm/powerpc/e500/fpu/fenv_const.c5
-rw-r--r--libm/powerpc/e500/fpu/fenv_libc.h5
-rw-r--r--libm/powerpc/e500/fpu/fesetenv.c5
-rw-r--r--libm/powerpc/e500/fpu/fesetround.c5
-rw-r--r--libm/powerpc/e500/fpu/feupdateenv.c5
-rw-r--r--libm/powerpc/e500/fpu/fgetexcptflg.c5
-rw-r--r--libm/powerpc/e500/fpu/fraiseexcpt.c5
-rw-r--r--libm/powerpc/e500/fpu/fsetexcptflg.c5
-rw-r--r--libm/powerpc/e500/fpu/ftestexcept.c5
-rw-r--r--libm/powerpc/e500/spe-raise.c5
-rw-r--r--libm/s_asinh.c20
-rw-r--r--libm/s_atan.c33
-rw-r--r--libm/s_cbrt.c21
-rw-r--r--libm/s_ceil.c42
-rw-r--r--libm/s_copysign.c13
-rw-r--r--libm/s_cos.c13
-rw-r--r--libm/s_erf.c28
-rw-r--r--libm/s_expm1.c17
-rw-r--r--libm/s_fabs.c16
-rw-r--r--libm/s_fdim.c27
-rw-r--r--libm/s_finite.c28
-rw-r--r--libm/s_finitef.c33
-rw-r--r--libm/s_floor.c42
-rw-r--r--libm/s_fma.c27
-rw-r--r--libm/s_fmax.c19
-rw-r--r--libm/s_fmin.c19
-rw-r--r--libm/s_fpclassify.c41
-rw-r--r--libm/s_fpclassifyf.c39
-rw-r--r--libm/s_frexp.c17
-rw-r--r--libm/s_ilogb.c60
-rw-r--r--libm/s_isinf.c23
-rw-r--r--libm/s_isinff.c23
-rw-r--r--libm/s_isnan.c (renamed from libm/e_gamma.c)30
-rw-r--r--libm/s_isnanf.c (renamed from libm/s_matherr.c)33
-rw-r--r--libm/s_ldexp.c36
-rw-r--r--libm/s_lib_version.c5
-rw-r--r--libm/s_llrint.c33
-rw-r--r--libm/s_llround.c33
-rw-r--r--libm/s_log1p.c21
-rw-r--r--libm/s_logb.c15
-rw-r--r--libm/s_lrint.c34
-rw-r--r--libm/s_lround.c33
-rw-r--r--libm/s_modf.c46
-rw-r--r--libm/s_nextafter.c17
-rw-r--r--libm/s_nextafterf.c96
-rw-r--r--libm/s_remquo.c31
-rw-r--r--libm/s_rint.c78
-rw-r--r--libm/s_round.c30
-rw-r--r--libm/s_scalbn.c89
-rw-r--r--libm/s_signbit.c34
-rw-r--r--libm/s_signbitf.c34
-rw-r--r--libm/s_signgam.c2
-rw-r--r--libm/s_significand.c15
-rw-r--r--libm/s_sin.c13
-rw-r--r--libm/s_tan.c13
-rw-r--r--libm/s_tanh.c20
-rw-r--r--libm/s_trunc.c24
-rw-r--r--libm/sh/sh4/Makefile.arch24
-rw-r--r--libm/sh/sh4/feholdexcpt.c29
-rw-r--r--libm/sh/sh4/fesetenv.c26
-rw-r--r--libm/sh/sh4/s_lrintf.S52
-rw-r--r--libm/sh/sh4/s_lroundf.S39
-rw-r--r--libm/sincos.c48
-rw-r--r--libm/w_acos.c44
-rw-r--r--libm/w_acosh.c44
-rw-r--r--libm/w_asin.c46
-rw-r--r--libm/w_atan2.c43
-rw-r--r--libm/w_atanh.c48
-rw-r--r--libm/w_cabs.c19
-rw-r--r--libm/w_cosh.c44
-rw-r--r--libm/w_drem.c15
-rw-r--r--libm/w_exp.c55
-rw-r--r--libm/w_exp2.c (renamed from libm/e_lgamma.c)24
-rw-r--r--libm/w_fmod.c44
-rw-r--r--libm/w_gamma.c49
-rw-r--r--libm/w_gamma_r.c47
-rw-r--r--libm/w_hypot.c44
-rw-r--r--libm/w_j0.c69
-rw-r--r--libm/w_j1.c70
-rw-r--r--libm/w_jn.c92
-rw-r--r--libm/w_lgamma.c51
-rw-r--r--libm/w_lgamma_r.c46
-rw-r--r--libm/w_log.c44
-rw-r--r--libm/w_log10.c47
-rw-r--r--libm/w_pow.c62
-rw-r--r--libm/w_remainder.c44
-rw-r--r--libm/w_scalb.c60
-rw-r--r--libm/w_sinh.c44
-rw-r--r--libm/w_sqrt.c44
-rw-r--r--libnsl/Makefile.in19
-rw-r--r--libnsl/nsl.c2
-rw-r--r--libpthread/Makefile.in4
-rw-r--r--libpthread/linuxthreads.old/Makefile.in68
-rw-r--r--libpthread/linuxthreads.old/attr.c6
-rw-r--r--libpthread/linuxthreads.old/cancel.c14
-rw-r--r--libpthread/linuxthreads.old/condvar.c10
-rw-r--r--libpthread/linuxthreads.old/errno.c2
-rw-r--r--libpthread/linuxthreads.old/events.c3
-rw-r--r--libpthread/linuxthreads.old/forward.c24
-rw-r--r--libpthread/linuxthreads.old/internals.h145
-rw-r--r--libpthread/linuxthreads.old/join.c146
-rw-r--r--libpthread/linuxthreads.old/libc_pthread_init.c17
-rw-r--r--libpthread/linuxthreads.old/locale.c4
-rw-r--r--libpthread/linuxthreads.old/lockfile.c5
-rw-r--r--libpthread/linuxthreads.old/manager.c71
-rw-r--r--libpthread/linuxthreads.old/oldsemaphore.c241
-rw-r--r--libpthread/linuxthreads.old/pt-machine.c3
-rw-r--r--libpthread/linuxthreads.old/ptfork.c61
-rw-r--r--libpthread/linuxthreads.old/pthread.c93
-rw-r--r--libpthread/linuxthreads.old/ptlongjmp.c14
-rw-r--r--libpthread/linuxthreads.old/rwlock.c3
-rw-r--r--libpthread/linuxthreads.old/semaphore.c32
-rw-r--r--libpthread/linuxthreads.old/semaphore.h15
-rw-r--r--libpthread/linuxthreads.old/signals.c9
-rw-r--r--libpthread/linuxthreads.old/specific.c2
-rw-r--r--libpthread/linuxthreads.old/spinlock.c5
-rw-r--r--libpthread/linuxthreads.old/sysdeps/alpha/pt-machine.h3
-rw-r--r--libpthread/linuxthreads.old/sysdeps/arc/pt-machine.h42
-rw-r--r--libpthread/linuxthreads.old/sysdeps/arm/pt-machine.h65
-rw-r--r--libpthread/linuxthreads.old/sysdeps/avr32/pt-machine.h2
-rw-r--r--libpthread/linuxthreads.old/sysdeps/bfin/pt-machine.h3
-rw-r--r--libpthread/linuxthreads.old/sysdeps/c6x/pt-machine.h63
-rw-r--r--libpthread/linuxthreads.old/sysdeps/cris/pt-machine.h3
-rw-r--r--libpthread/linuxthreads.old/sysdeps/frv/pt-machine.h3
-rw-r--r--libpthread/linuxthreads.old/sysdeps/h8300/pt-machine.h3
-rw-r--r--libpthread/linuxthreads.old/sysdeps/hppa/pspinlock.c (renamed from libpthread/linuxthreads/sysdeps/sparc/sparc32/pspinlock.c)48
-rw-r--r--libpthread/linuxthreads.old/sysdeps/hppa/pt-machine.h59
-rw-r--r--libpthread/linuxthreads.old/sysdeps/i386/pt-machine.h5
-rw-r--r--libpthread/linuxthreads.old/sysdeps/i386/tls.h5
-rw-r--r--libpthread/linuxthreads.old/sysdeps/i386/useldt.h3
-rw-r--r--libpthread/linuxthreads.old/sysdeps/ia64/pt-machine.h5
-rw-r--r--libpthread/linuxthreads.old/sysdeps/ia64/tls.h5
-rw-r--r--libpthread/linuxthreads.old/sysdeps/m68k/pt-machine.h5
-rw-r--r--libpthread/linuxthreads.old/sysdeps/microblaze/pt-machine.h106
-rw-r--r--libpthread/linuxthreads.old/sysdeps/microblaze/sigcontextinfo.h (renamed from libc/sysdeps/linux/v850/bits/sigcontextinfo.h)2
-rw-r--r--libpthread/linuxthreads.old/sysdeps/mips/pt-machine.h3
-rw-r--r--libpthread/linuxthreads.old/sysdeps/nios/pt-machine.h68
-rw-r--r--libpthread/linuxthreads.old/sysdeps/nios2/pt-machine.h3
-rw-r--r--libpthread/linuxthreads.old/sysdeps/or1k/pt-machine.h (renamed from libpthread/linuxthreads.old/sysdeps/sh64/pt-machine.h)42
-rw-r--r--libpthread/linuxthreads.old/sysdeps/powerpc/pt-machine.h3
-rw-r--r--libpthread/linuxthreads.old/sysdeps/pthread/bits/libc-lock.h53
-rw-r--r--libpthread/linuxthreads.old/sysdeps/pthread/bits/libc-tsd.h14
-rw-r--r--libpthread/linuxthreads.old/sysdeps/pthread/bits/pthreadtypes.h3
-rw-r--r--libpthread/linuxthreads.old/sysdeps/pthread/not-cancel.h113
-rw-r--r--libpthread/linuxthreads.old/sysdeps/pthread/pthread-functions.h21
-rw-r--r--libpthread/linuxthreads.old/sysdeps/pthread/pthread.h122
-rw-r--r--libpthread/linuxthreads.old/sysdeps/pthread/tls.h5
-rw-r--r--libpthread/linuxthreads.old/sysdeps/sh/pt-machine.h5
-rw-r--r--libpthread/linuxthreads.old/sysdeps/sh/tls.h5
-rw-r--r--libpthread/linuxthreads.old/sysdeps/sh64/Makefile.arch30
-rw-r--r--libpthread/linuxthreads.old/sysdeps/sh64/pt-machine.c47
-rw-r--r--libpthread/linuxthreads.old/sysdeps/sparc/pt-machine.h86
-rw-r--r--libpthread/linuxthreads.old/sysdeps/sparc/sparc32/pt-machine.h83
-rw-r--r--libpthread/linuxthreads.old/sysdeps/sparc/sparc64/pt-machine.h105
-rw-r--r--libpthread/linuxthreads.old/sysdeps/sparc/tcb-offsets.h1
-rw-r--r--libpthread/linuxthreads.old/sysdeps/v850/pt-machine.h52
-rw-r--r--libpthread/linuxthreads.old/sysdeps/x86_64/pt-machine.h8
-rw-r--r--libpthread/linuxthreads.old/sysdeps/x86_64/tls.h5
-rw-r--r--libpthread/linuxthreads.old/sysdeps/xtensa/pt-machine.h47
-rw-r--r--libpthread/linuxthreads.old/wrapsyscall.c89
-rw-r--r--libpthread/linuxthreads.old_db/Makefile.in28
-rw-r--r--libpthread/linuxthreads.old_db/proc_service.h5
-rw-r--r--libpthread/linuxthreads.old_db/td_init.c5
-rw-r--r--libpthread/linuxthreads.old_db/td_log.c5
-rw-r--r--libpthread/linuxthreads.old_db/td_symbol_list.c17
-rw-r--r--libpthread/linuxthreads.old_db/td_ta_clear_event.c9
-rw-r--r--libpthread/linuxthreads.old_db/td_ta_delete.c7
-rw-r--r--libpthread/linuxthreads.old_db/td_ta_enable_stats.c5
-rw-r--r--libpthread/linuxthreads.old_db/td_ta_event_addr.c5
-rw-r--r--libpthread/linuxthreads.old_db/td_ta_event_getmsg.c5
-rw-r--r--libpthread/linuxthreads.old_db/td_ta_get_nthreads.c5
-rw-r--r--libpthread/linuxthreads.old_db/td_ta_get_ph.c5
-rw-r--r--libpthread/linuxthreads.old_db/td_ta_get_stats.c5
-rw-r--r--libpthread/linuxthreads.old_db/td_ta_map_id2thr.c5
-rw-r--r--libpthread/linuxthreads.old_db/td_ta_map_lwp2thr.c5
-rw-r--r--libpthread/linuxthreads.old_db/td_ta_new.c5
-rw-r--r--libpthread/linuxthreads.old_db/td_ta_reset_stats.c5
-rw-r--r--libpthread/linuxthreads.old_db/td_ta_set_event.c9
-rw-r--r--libpthread/linuxthreads.old_db/td_ta_setconcurrency.c5
-rw-r--r--libpthread/linuxthreads.old_db/td_ta_thr_iter.c5
-rw-r--r--libpthread/linuxthreads.old_db/td_ta_tsd_iter.c5
-rw-r--r--libpthread/linuxthreads.old_db/td_thr_clear_event.c9
-rw-r--r--libpthread/linuxthreads.old_db/td_thr_dbresume.c5
-rw-r--r--libpthread/linuxthreads.old_db/td_thr_dbsuspend.c5
-rw-r--r--libpthread/linuxthreads.old_db/td_thr_event_enable.c9
-rw-r--r--libpthread/linuxthreads.old_db/td_thr_event_getmsg.c5
-rw-r--r--libpthread/linuxthreads.old_db/td_thr_get_info.c5
-rw-r--r--libpthread/linuxthreads.old_db/td_thr_getfpregs.c5
-rw-r--r--libpthread/linuxthreads.old_db/td_thr_getgregs.c5
-rw-r--r--libpthread/linuxthreads.old_db/td_thr_getxregs.c5
-rw-r--r--libpthread/linuxthreads.old_db/td_thr_getxregsize.c5
-rw-r--r--libpthread/linuxthreads.old_db/td_thr_set_event.c9
-rw-r--r--libpthread/linuxthreads.old_db/td_thr_setfpregs.c5
-rw-r--r--libpthread/linuxthreads.old_db/td_thr_setgregs.c5
-rw-r--r--libpthread/linuxthreads.old_db/td_thr_setprio.c5
-rw-r--r--libpthread/linuxthreads.old_db/td_thr_setsigpending.c5
-rw-r--r--libpthread/linuxthreads.old_db/td_thr_setxregs.c5
-rw-r--r--libpthread/linuxthreads.old_db/td_thr_sigsetmask.c5
-rw-r--r--libpthread/linuxthreads.old_db/td_thr_tls_get_addr.c7
-rw-r--r--libpthread/linuxthreads.old_db/td_thr_tsd.c5
-rw-r--r--libpthread/linuxthreads.old_db/td_thr_validate.c5
-rw-r--r--libpthread/linuxthreads.old_db/thread_db.h5
-rw-r--r--libpthread/linuxthreads.old_db/thread_dbP.h2
-rw-r--r--libpthread/linuxthreads/.cvsignore3
-rw-r--r--libpthread/linuxthreads/Makefile.in62
-rw-r--r--libpthread/linuxthreads/alloca_cutoff.c5
-rw-r--r--libpthread/linuxthreads/attr.c13
-rw-r--r--libpthread/linuxthreads/barrier.c5
-rw-r--r--libpthread/linuxthreads/cancel.c3
-rw-r--r--libpthread/linuxthreads/descr.h10
-rw-r--r--libpthread/linuxthreads/errno.c2
-rw-r--r--libpthread/linuxthreads/events.c5
-rw-r--r--libpthread/linuxthreads/forward.c8
-rw-r--r--libpthread/linuxthreads/internals.h35
-rw-r--r--libpthread/linuxthreads/libc-cancellation.c8
-rw-r--r--libpthread/linuxthreads/libc_pthread_init.c21
-rw-r--r--libpthread/linuxthreads/lockfile.c5
-rw-r--r--libpthread/linuxthreads/manager.c81
-rw-r--r--libpthread/linuxthreads/pt-machine.c5
-rw-r--r--libpthread/linuxthreads/ptcleanup.c6
-rw-r--r--libpthread/linuxthreads/ptclock_gettime.c6
-rw-r--r--libpthread/linuxthreads/ptclock_settime.c6
-rw-r--r--libpthread/linuxthreads/ptfork.c2
-rw-r--r--libpthread/linuxthreads/pthread.c168
-rw-r--r--libpthread/linuxthreads/pthread_atfork.c5
-rw-r--r--libpthread/linuxthreads/pthread_setegid.c5
-rw-r--r--libpthread/linuxthreads/pthread_seteuid.c5
-rw-r--r--libpthread/linuxthreads/pthread_setgid.c5
-rw-r--r--libpthread/linuxthreads/pthread_setregid.c5
-rw-r--r--libpthread/linuxthreads/pthread_setresgid.c5
-rw-r--r--libpthread/linuxthreads/pthread_setresuid.c5
-rw-r--r--libpthread/linuxthreads/pthread_setreuid.c5
-rw-r--r--libpthread/linuxthreads/pthread_setuid.c5
-rw-r--r--libpthread/linuxthreads/restart.h2
-rw-r--r--libpthread/linuxthreads/rwlock.c5
-rw-r--r--libpthread/linuxthreads/semaphore.c1
-rw-r--r--libpthread/linuxthreads/semaphore.h13
-rw-r--r--libpthread/linuxthreads/signals.c10
-rw-r--r--libpthread/linuxthreads/specific.c12
-rw-r--r--libpthread/linuxthreads/spinlock.c14
-rw-r--r--libpthread/linuxthreads/spinlock.h6
-rw-r--r--libpthread/linuxthreads/sysdeps/alpha/elf/pt-initfini.c5
-rw-r--r--libpthread/linuxthreads/sysdeps/alpha/pspinlock.c5
-rw-r--r--libpthread/linuxthreads/sysdeps/alpha/pt-machine.h3
-rw-r--r--libpthread/linuxthreads/sysdeps/alpha/tls.h5
-rw-r--r--libpthread/linuxthreads/sysdeps/arm/pspinlock.c5
-rw-r--r--libpthread/linuxthreads/sysdeps/arm/pt-machine.h5
-rw-r--r--libpthread/linuxthreads/sysdeps/arm/sysdep-cancel.h8
-rw-r--r--libpthread/linuxthreads/sysdeps/arm/tls.h5
-rw-r--r--libpthread/linuxthreads/sysdeps/avr32/pt-machine.h6
-rw-r--r--libpthread/linuxthreads/sysdeps/cris/pspinlock.c5
-rw-r--r--libpthread/linuxthreads/sysdeps/cris/pt-machine.h5
-rw-r--r--libpthread/linuxthreads/sysdeps/hppa/pspinlock.c5
-rw-r--r--libpthread/linuxthreads/sysdeps/hppa/pt-machine.h5
-rw-r--r--libpthread/linuxthreads/sysdeps/i386/i686/pt-machine.h7
-rw-r--r--libpthread/linuxthreads/sysdeps/i386/pspinlock.c7
-rw-r--r--libpthread/linuxthreads/sysdeps/i386/pt-machine.h8
-rw-r--r--libpthread/linuxthreads/sysdeps/i386/tls.h7
-rw-r--r--libpthread/linuxthreads/sysdeps/i386/useldt.h5
-rw-r--r--libpthread/linuxthreads/sysdeps/ia64/pspinlock.c5
-rw-r--r--libpthread/linuxthreads/sysdeps/ia64/pt-machine.h5
-rw-r--r--libpthread/linuxthreads/sysdeps/ia64/tcb-offsets.sym2
-rw-r--r--libpthread/linuxthreads/sysdeps/ia64/tls.h5
-rw-r--r--libpthread/linuxthreads/sysdeps/m68k/pspinlock.c25
-rw-r--r--libpthread/linuxthreads/sysdeps/m68k/pt-machine.h14
-rw-r--r--libpthread/linuxthreads/sysdeps/mips/pspinlock.c7
-rw-r--r--libpthread/linuxthreads/sysdeps/mips/pt-machine.h3
-rw-r--r--libpthread/linuxthreads/sysdeps/mips/tls.h5
-rw-r--r--libpthread/linuxthreads/sysdeps/or1k/pt-machine.h55
-rw-r--r--libpthread/linuxthreads/sysdeps/powerpc/powerpc32/pspinlock.c5
-rw-r--r--libpthread/linuxthreads/sysdeps/powerpc/powerpc32/pt-machine.h3
-rw-r--r--libpthread/linuxthreads/sysdeps/powerpc/powerpc64/pspinlock.c5
-rw-r--r--libpthread/linuxthreads/sysdeps/powerpc/powerpc64/pt-machine.h3
-rw-r--r--libpthread/linuxthreads/sysdeps/powerpc/tcb-offsets.sym2
-rw-r--r--libpthread/linuxthreads/sysdeps/powerpc/tls.h5
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/.cvsignore2
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/bits/initspin.h5
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/bits/libc-lock.h11
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/bits/libc-tsd.h8
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/bits/pthreadtypes.h3
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/bits/typesizes.h5
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/errno-loc.c11
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/flockfile.c5
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/ftrylockfile.c5
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/funlockfile.c5
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/getcpuclockid.c7
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/herrno-loc.c11
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/kernel-features.h80
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/list.h5
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/malloc-machine.h5
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/not-cancel.h65
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/posix-timer.h5
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/pt-initfini.c3
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/pthread-functions.h9
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/pthread.h94
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/ptlongjmp.c7
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/res-state.c11
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/sigaction.c7
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/timer_create.c5
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/timer_delete.c5
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/timer_getoverr.c5
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/timer_gettime.c5
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/timer_routines.c5
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/timer_settime.c5
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/tst-timer.c5
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/uClibc-glue.h6
-rw-r--r--libpthread/linuxthreads/sysdeps/s390/pspinlock.c91
-rw-r--r--libpthread/linuxthreads/sysdeps/s390/s390-32/pt-machine.h120
-rw-r--r--libpthread/linuxthreads/sysdeps/s390/s390-64/pt-machine.h125
-rw-r--r--libpthread/linuxthreads/sysdeps/s390/tcb-offsets.sym4
-rw-r--r--libpthread/linuxthreads/sysdeps/s390/tls.h145
-rw-r--r--libpthread/linuxthreads/sysdeps/sh/pspinlock.c5
-rw-r--r--libpthread/linuxthreads/sysdeps/sh/pt-machine.h5
-rw-r--r--libpthread/linuxthreads/sysdeps/sh/tcb-offsets.sym2
-rw-r--r--libpthread/linuxthreads/sysdeps/sh/tls.h5
-rw-r--r--libpthread/linuxthreads/sysdeps/sparc/pspinlock.c95
-rw-r--r--libpthread/linuxthreads/sysdeps/sparc/pt-machine.h86
-rw-r--r--libpthread/linuxthreads/sysdeps/sparc/sparc32/pt-machine.h83
-rw-r--r--libpthread/linuxthreads/sysdeps/sparc/sparc32/sparcv9/pspinlock.c94
-rw-r--r--libpthread/linuxthreads/sysdeps/sparc/sparc64/pspinlock.c93
-rw-r--r--libpthread/linuxthreads/sysdeps/sparc/sparc64/pt-machine.h105
-rw-r--r--libpthread/linuxthreads/sysdeps/sparc/tls.h5
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/.cvsignore2
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/allocalim.h5
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/allocrtsig.c7
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/bits/local_lim.h5
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h5
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/pt-sigsuspend.S5
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h9
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/vfork.S9
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h129
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/arm/vfork.S77
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/execve.c60
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/fork.c5
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/fork.h5
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/bits/initspin.h5
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/malloc-machine.h5
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/pt-initfini.c3
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h13
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h15
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/i386/vfork.S11
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/bits/local_lim.h5
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/fork.h5
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/pt-initfini.c3
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/pt-sigsuspend.c5
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h5
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/vfork.S7
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/jmp-unwind.c6
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h13
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/m68k/vfork.S11
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h7
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h8
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/vfork.S6
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/mq_notify.c11
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h9
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S9
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h5
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S11
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/pt-sigsuspend.c7
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/raise.c6
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/register-atfork.c5
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/s390/bits/typesizes.h72
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-32/pt-initfini.c154
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h137
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-64/pt-initfini.c137
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-64/pt-sigsuspend.c1
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h116
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/pt-initfini.c3
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/smp.h3
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h13
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/vfork.S16
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/sigwait.c22
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/smp.h3
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/bits/local_lim.h5
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h5
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/fork.h20
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc64/pt-sigsuspend.c1
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S64
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h (renamed from libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h)6
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/vfork.S (renamed from libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S)9
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/unregister-atfork.c5
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h5
-rw-r--r--libpthread/linuxthreads/sysdeps/unix/sysv/linux/x86_64/vfork.S7
-rw-r--r--libpthread/linuxthreads/sysdeps/x86_64/pspinlock.c5
-rw-r--r--libpthread/linuxthreads/sysdeps/x86_64/pt-machine.h5
-rw-r--r--libpthread/linuxthreads/sysdeps/x86_64/tls.h5
-rw-r--r--libpthread/linuxthreads_db/.cvsignore5
-rw-r--r--libpthread/linuxthreads_db/Makefile.in28
-rw-r--r--libpthread/linuxthreads_db/Makefile.old5
-rw-r--r--libpthread/linuxthreads_db/proc_service.h5
-rw-r--r--libpthread/linuxthreads_db/td_init.c5
-rw-r--r--libpthread/linuxthreads_db/td_log.c5
-rw-r--r--libpthread/linuxthreads_db/td_symbol_list.c17
-rw-r--r--libpthread/linuxthreads_db/td_ta_clear_event.c9
-rw-r--r--libpthread/linuxthreads_db/td_ta_delete.c7
-rw-r--r--libpthread/linuxthreads_db/td_ta_enable_stats.c5
-rw-r--r--libpthread/linuxthreads_db/td_ta_event_addr.c5
-rw-r--r--libpthread/linuxthreads_db/td_ta_event_getmsg.c5
-rw-r--r--libpthread/linuxthreads_db/td_ta_get_nthreads.c5
-rw-r--r--libpthread/linuxthreads_db/td_ta_get_ph.c5
-rw-r--r--libpthread/linuxthreads_db/td_ta_get_stats.c5
-rw-r--r--libpthread/linuxthreads_db/td_ta_map_id2thr.c5
-rw-r--r--libpthread/linuxthreads_db/td_ta_map_lwp2thr.c5
-rw-r--r--libpthread/linuxthreads_db/td_ta_new.c5
-rw-r--r--libpthread/linuxthreads_db/td_ta_reset_stats.c5
-rw-r--r--libpthread/linuxthreads_db/td_ta_set_event.c9
-rw-r--r--libpthread/linuxthreads_db/td_ta_setconcurrency.c5
-rw-r--r--libpthread/linuxthreads_db/td_ta_thr_iter.c7
-rw-r--r--libpthread/linuxthreads_db/td_ta_tsd_iter.c5
-rw-r--r--libpthread/linuxthreads_db/td_thr_clear_event.c9
-rw-r--r--libpthread/linuxthreads_db/td_thr_dbresume.c5
-rw-r--r--libpthread/linuxthreads_db/td_thr_dbsuspend.c5
-rw-r--r--libpthread/linuxthreads_db/td_thr_event_enable.c9
-rw-r--r--libpthread/linuxthreads_db/td_thr_event_getmsg.c5
-rw-r--r--libpthread/linuxthreads_db/td_thr_get_info.c5
-rw-r--r--libpthread/linuxthreads_db/td_thr_getfpregs.c5
-rw-r--r--libpthread/linuxthreads_db/td_thr_getgregs.c5
-rw-r--r--libpthread/linuxthreads_db/td_thr_getxregs.c5
-rw-r--r--libpthread/linuxthreads_db/td_thr_getxregsize.c5
-rw-r--r--libpthread/linuxthreads_db/td_thr_set_event.c9
-rw-r--r--libpthread/linuxthreads_db/td_thr_setfpregs.c5
-rw-r--r--libpthread/linuxthreads_db/td_thr_setgregs.c5
-rw-r--r--libpthread/linuxthreads_db/td_thr_setprio.c5
-rw-r--r--libpthread/linuxthreads_db/td_thr_setsigpending.c5
-rw-r--r--libpthread/linuxthreads_db/td_thr_setxregs.c5
-rw-r--r--libpthread/linuxthreads_db/td_thr_sigsetmask.c5
-rw-r--r--libpthread/linuxthreads_db/td_thr_tls_get_addr.c7
-rw-r--r--libpthread/linuxthreads_db/td_thr_tlsbase.c11
-rw-r--r--libpthread/linuxthreads_db/td_thr_tsd.c5
-rw-r--r--libpthread/linuxthreads_db/td_thr_validate.c5
-rw-r--r--libpthread/linuxthreads_db/thread_db.h5
-rw-r--r--libpthread/nptl/.gitignore30
-rw-r--r--libpthread/nptl/ChangeLog11100
-rw-r--r--libpthread/nptl/DESIGN-barrier.txt44
-rw-r--r--libpthread/nptl/DESIGN-condvar.txt134
-rw-r--r--libpthread/nptl/DESIGN-rwlock.txt113
-rw-r--r--libpthread/nptl/DESIGN-sem.txt46
-rw-r--r--libpthread/nptl/Makefile13
-rw-r--r--libpthread/nptl/Makefile.in252
-rw-r--r--libpthread/nptl/README.NPTL307
-rw-r--r--libpthread/nptl/TODO31
-rw-r--r--libpthread/nptl/TODO-kernel20
-rw-r--r--libpthread/nptl/TODO-testing20
-rw-r--r--libpthread/nptl/alloca_cutoff.c35
-rw-r--r--libpthread/nptl/allocatestack.c1220
-rw-r--r--libpthread/nptl/banner.h1
-rw-r--r--libpthread/nptl/cancellation.c99
-rw-r--r--libpthread/nptl/cleanup.c48
-rw-r--r--libpthread/nptl/cleanup_compat.c54
-rw-r--r--libpthread/nptl/cleanup_defer.c91
-rw-r--r--libpthread/nptl/cleanup_defer_compat.c99
-rw-r--r--libpthread/nptl/cleanup_routine.c27
-rw-r--r--libpthread/nptl/descr.h376
-rw-r--r--libpthread/nptl/errno_location.c1
-rw-r--r--libpthread/nptl/events.c33
-rw-r--r--libpthread/nptl/forward.c169
-rw-r--r--libpthread/nptl/herrno.c34
-rw-r--r--libpthread/nptl/init.c431
-rw-r--r--libpthread/nptl/libc-cancellation.c24
-rw-r--r--libpthread/nptl/linux_fsinfo.h152
-rw-r--r--libpthread/nptl/pt-cleanup.c63
-rw-r--r--libpthread/nptl/pt-system.c35
-rw-r--r--libpthread/nptl/pthread-errnos.sym13
-rw-r--r--libpthread/nptl/pthreadP.h602
-rw-r--r--libpthread/nptl/pthread_atfork.c63
-rw-r--r--libpthread/nptl/pthread_attr_destroy.c40
-rw-r--r--libpthread/nptl/pthread_attr_getdetachstate.c39
-rw-r--r--libpthread/nptl/pthread_attr_getguardsize.c34
-rw-r--r--libpthread/nptl/pthread_attr_getinheritsched.c40
-rw-r--r--libpthread/nptl/pthread_attr_getschedparam.c40
-rw-r--r--libpthread/nptl/pthread_attr_getschedpolicy.c39
-rw-r--r--libpthread/nptl/pthread_attr_getscope.c40
-rw-r--r--libpthread/nptl/pthread_attr_getstack.c40
-rw-r--r--libpthread/nptl/pthread_attr_getstackaddr.c41
-rw-r--r--libpthread/nptl/pthread_attr_getstacksize.c39
-rw-r--r--libpthread/nptl/pthread_attr_init.c50
-rw-r--r--libpthread/nptl/pthread_attr_setdetachstate.c46
-rw-r--r--libpthread/nptl/pthread_attr_setguardsize.c37
-rw-r--r--libpthread/nptl/pthread_attr_setinheritsched.c47
-rw-r--r--libpthread/nptl/pthread_attr_setschedparam.c48
-rw-r--r--libpthread/nptl/pthread_attr_setschedpolicy.c47
-rw-r--r--libpthread/nptl/pthread_attr_setscope.c51
-rw-r--r--libpthread/nptl/pthread_attr_setstack.c55
-rw-r--r--libpthread/nptl/pthread_attr_setstackaddr.c43
-rw-r--r--libpthread/nptl/pthread_attr_setstacksize.c48
-rw-r--r--libpthread/nptl/pthread_barrierattr_destroy.c28
-rw-r--r--libpthread/nptl/pthread_barrierattr_getpshared.c30
-rw-r--r--libpthread/nptl/pthread_barrierattr_init.c28
-rw-r--r--libpthread/nptl/pthread_barrierattr_setpshared.c39
-rw-r--r--libpthread/nptl/pthread_cancel.c107
-rw-r--r--libpthread/nptl/pthread_clock_gettime.c67
-rw-r--r--libpthread/nptl/pthread_clock_settime.c54
-rw-r--r--libpthread/nptl/pthread_cond_destroy.c83
-rw-r--r--libpthread/nptl/pthread_cond_init.c46
-rw-r--r--libpthread/nptl/pthread_condattr_destroy.c29
-rw-r--r--libpthread/nptl/pthread_condattr_getclock.c30
-rw-r--r--libpthread/nptl/pthread_condattr_getpshared.c30
-rw-r--r--libpthread/nptl/pthread_condattr_init.c31
-rw-r--r--libpthread/nptl/pthread_condattr_setclock.c72
-rw-r--r--libpthread/nptl/pthread_condattr_setpshared.c36
-rw-r--r--libpthread/nptl/pthread_create.c584
-rw-r--r--libpthread/nptl/pthread_detach.c55
-rw-r--r--libpthread/nptl/pthread_equal.c28
-rw-r--r--libpthread/nptl/pthread_exit.c37
-rw-r--r--libpthread/nptl/pthread_getattr_np.c178
-rw-r--r--libpthread/nptl/pthread_getconcurrency.c26
-rw-r--r--libpthread/nptl/pthread_getschedparam.c75
-rw-r--r--libpthread/nptl/pthread_getspecific.c68
-rw-r--r--libpthread/nptl/pthread_join.c113
-rw-r--r--libpthread/nptl/pthread_key_create.c55
-rw-r--r--libpthread/nptl/pthread_key_delete.c41
-rw-r--r--libpthread/nptl/pthread_kill_other_threads.c31
-rw-r--r--libpthread/nptl/pthread_mutex_consistent.c36
-rw-r--r--libpthread/nptl/pthread_mutex_destroy.c38
-rw-r--r--libpthread/nptl/pthread_mutex_getprioceiling.c37
-rw-r--r--libpthread/nptl/pthread_mutex_init.c141
-rw-r--r--libpthread/nptl/pthread_mutex_lock.c499
-rw-r--r--libpthread/nptl/pthread_mutex_setprioceiling.c118
-rw-r--r--libpthread/nptl/pthread_mutex_timedlock.c489
-rw-r--r--libpthread/nptl/pthread_mutex_trylock.c381
-rw-r--r--libpthread/nptl/pthread_mutex_unlock.c293
-rw-r--r--libpthread/nptl/pthread_mutexattr_destroy.c27
-rw-r--r--libpthread/nptl/pthread_mutexattr_getprioceiling.c47
-rw-r--r--libpthread/nptl/pthread_mutexattr_getprotocol.c36
-rw-r--r--libpthread/nptl/pthread_mutexattr_getpshared.c35
-rw-r--r--libpthread/nptl/pthread_mutexattr_getrobust.c36
-rw-r--r--libpthread/nptl/pthread_mutexattr_gettype.c35
-rw-r--r--libpthread/nptl/pthread_mutexattr_init.c37
-rw-r--r--libpthread/nptl/pthread_mutexattr_setprioceiling.c46
-rw-r--r--libpthread/nptl/pthread_mutexattr_setprotocol.c40
-rw-r--r--libpthread/nptl/pthread_mutexattr_setpshared.c42
-rw-r--r--libpthread/nptl/pthread_mutexattr_setrobust.c43
-rw-r--r--libpthread/nptl/pthread_mutexattr_settype.c40
-rw-r--r--libpthread/nptl/pthread_rwlock_destroy.c28
-rw-r--r--libpthread/nptl/pthread_rwlock_init.c72
-rw-r--r--libpthread/nptl/pthread_rwlock_tryrdlock.c49
-rw-r--r--libpthread/nptl/pthread_rwlock_trywrlock.c42
-rw-r--r--libpthread/nptl/pthread_rwlockattr_destroy.c28
-rw-r--r--libpthread/nptl/pthread_rwlockattr_getkind_np.c30
-rw-r--r--libpthread/nptl/pthread_rwlockattr_getpshared.c30
-rw-r--r--libpthread/nptl/pthread_rwlockattr_init.c33
-rw-r--r--libpthread/nptl/pthread_rwlockattr_setkind_np.c40
-rw-r--r--libpthread/nptl/pthread_rwlockattr_setpshared.c39
-rw-r--r--libpthread/nptl/pthread_self.c29
-rw-r--r--libpthread/nptl/pthread_setcancelstate.c73
-rw-r--r--libpthread/nptl/pthread_setcanceltype.c76
-rw-r--r--libpthread/nptl/pthread_setconcurrency.c39
-rw-r--r--libpthread/nptl/pthread_setegid.c3
-rw-r--r--libpthread/nptl/pthread_seteuid.c3
-rw-r--r--libpthread/nptl/pthread_setgid.c3
-rw-r--r--libpthread/nptl/pthread_setregid.c3
-rw-r--r--libpthread/nptl/pthread_setresgid.c3
-rw-r--r--libpthread/nptl/pthread_setresuid.c3
-rw-r--r--libpthread/nptl/pthread_setreuid.c3
-rw-r--r--libpthread/nptl/pthread_setschedparam.c74
-rw-r--r--libpthread/nptl/pthread_setschedprio.c65
-rw-r--r--libpthread/nptl/pthread_setspecific.c96
-rw-r--r--libpthread/nptl/pthread_setuid.c3
-rw-r--r--libpthread/nptl/pthread_testcancel.c28
-rw-r--r--libpthread/nptl/pthread_timedjoin.c106
-rw-r--r--libpthread/nptl/pthread_tryjoin.c74
-rw-r--r--libpthread/nptl/res.c26
-rw-r--r--libpthread/nptl/sem_close.c80
-rw-r--r--libpthread/nptl/sem_destroy.c31
-rw-r--r--libpthread/nptl/sem_getvalue.c35
-rw-r--r--libpthread/nptl/sem_init.c54
-rw-r--r--libpthread/nptl/sem_open.c397
-rw-r--r--libpthread/nptl/sem_unlink.c66
-rw-r--r--libpthread/nptl/semaphore.h78
-rw-r--r--libpthread/nptl/semaphoreP.h57
-rw-r--r--libpthread/nptl/sysdeps/Makefile13
-rw-r--r--libpthread/nptl/sysdeps/Makefile.commonarch64
-rw-r--r--libpthread/nptl/sysdeps/Makefile.in29
-rw-r--r--libpthread/nptl/sysdeps/alpha/Makefile20
-rw-r--r--libpthread/nptl/sysdeps/alpha/dl-tls.h28
-rw-r--r--libpthread/nptl/sysdeps/alpha/elf/pt-initfini.c88
-rw-r--r--libpthread/nptl/sysdeps/alpha/jmpbuf-unwind.h27
-rw-r--r--libpthread/nptl/sysdeps/alpha/libc-tls.c36
-rw-r--r--libpthread/nptl/sysdeps/alpha/pthread_spin_lock.S44
-rw-r--r--libpthread/nptl/sysdeps/alpha/pthread_spin_trylock.S45
-rw-r--r--libpthread/nptl/sysdeps/alpha/pthreaddef.h37
-rw-r--r--libpthread/nptl/sysdeps/alpha/tcb-offsets.sym14
-rw-r--r--libpthread/nptl/sysdeps/alpha/tls.h126
-rw-r--r--libpthread/nptl/sysdeps/arc/Makefile.arch8
-rw-r--r--libpthread/nptl/sysdeps/arc/dl-tls.h28
-rw-r--r--libpthread/nptl/sysdeps/arc/jmpbuf-unwind.h32
-rw-r--r--libpthread/nptl/sysdeps/arc/libc-tls.c27
-rw-r--r--libpthread/nptl/sysdeps/arc/pthread_spin_lock.S21
-rw-r--r--libpthread/nptl/sysdeps/arc/pthread_spin_trylock.S31
-rw-r--r--libpthread/nptl/sysdeps/arc/pthreaddef.h (renamed from libc/sysdeps/linux/e1/sys/procfs.h)31
-rw-r--r--libpthread/nptl/sysdeps/arc/tcb-offsets.sym8
-rw-r--r--libpthread/nptl/sysdeps/arc/tls.h163
-rw-r--r--libpthread/nptl/sysdeps/arm/Makefile.arch10
-rw-r--r--libpthread/nptl/sysdeps/arm/aeabi_read_tp.S1
-rw-r--r--libpthread/nptl/sysdeps/arm/dl-tls.h28
-rw-r--r--libpthread/nptl/sysdeps/arm/jmpbuf-unwind.h32
-rw-r--r--libpthread/nptl/sysdeps/arm/libc-tls.c36
-rw-r--r--libpthread/nptl/sysdeps/arm/pthread_spin_lock.S30
-rw-r--r--libpthread/nptl/sysdeps/arm/pthread_spin_trylock.S33
-rw-r--r--libpthread/nptl/sysdeps/arm/pthreaddef.h38
-rw-r--r--libpthread/nptl/sysdeps/arm/tcb-offsets.sym11
-rw-r--r--libpthread/nptl/sysdeps/arm/thumb_atomics.S1
-rw-r--r--libpthread/nptl/sysdeps/arm/tls.h158
-rw-r--r--libpthread/nptl/sysdeps/generic/Makefile13
-rw-r--r--libpthread/nptl/sysdeps/generic/Makefile.in25
-rw-r--r--libpthread/nptl/sysdeps/generic/dl-tls.c900
-rw-r--r--libpthread/nptl/sysdeps/generic/dl-tls.h2
-rw-r--r--libpthread/nptl/sysdeps/generic/libc-tls.c266
-rw-r--r--libpthread/nptl/sysdeps/generic/lowlevellock.h83
-rw-r--r--libpthread/nptl/sysdeps/i386/Makefile26
-rw-r--r--libpthread/nptl/sysdeps/i386/Makefile.arch10
-rw-r--r--libpthread/nptl/sysdeps/i386/dl-tls.h61
-rw-r--r--libpthread/nptl/sysdeps/i386/i486/pthread_spin_trylock.S46
-rw-r--r--libpthread/nptl/sysdeps/i386/i586/pthread_spin_trylock.S19
-rw-r--r--libpthread/nptl/sysdeps/i386/i686/Makefile31
-rw-r--r--libpthread/nptl/sysdeps/i386/i686/pthread_spin_trylock.S20
-rw-r--r--libpthread/nptl/sysdeps/i386/i686/tls.h35
-rw-r--r--libpthread/nptl/sysdeps/i386/jmpbuf-unwind.h27
-rw-r--r--libpthread/nptl/sysdeps/i386/pthread_spin_init.c19
-rw-r--r--libpthread/nptl/sysdeps/i386/pthread_spin_lock.c48
-rw-r--r--libpthread/nptl/sysdeps/i386/pthread_spin_unlock.S31
-rw-r--r--libpthread/nptl/sysdeps/i386/pthreaddef.h47
-rw-r--r--libpthread/nptl/sysdeps/i386/tcb-offsets.sym17
-rw-r--r--libpthread/nptl/sysdeps/i386/tls.h479
-rw-r--r--libpthread/nptl/sysdeps/jmpbuf-unwind.h27
-rw-r--r--libpthread/nptl/sysdeps/metag/Makefile.arch10
-rw-r--r--libpthread/nptl/sysdeps/metag/dl-tls.h29
-rw-r--r--libpthread/nptl/sysdeps/metag/jmpbuf-unwind.h36
-rw-r--r--libpthread/nptl/sysdeps/metag/libc-tls.c33
-rw-r--r--libpthread/nptl/sysdeps/metag/metag_load_tp.S7
-rw-r--r--libpthread/nptl/sysdeps/metag/pthread_spin_init.c (renamed from libc/sysdeps/linux/e1/bits/wordsize.h)10
-rw-r--r--libpthread/nptl/sysdeps/metag/pthread_spin_lock.S20
-rw-r--r--libpthread/nptl/sysdeps/metag/pthread_spin_trylock.S24
-rw-r--r--libpthread/nptl/sysdeps/metag/pthread_spin_unlock.S16
-rw-r--r--libpthread/nptl/sysdeps/metag/pthreaddef.h40
-rw-r--r--libpthread/nptl/sysdeps/metag/tcb-offsets.sym15
-rw-r--r--libpthread/nptl/sysdeps/metag/tls.h163
-rw-r--r--libpthread/nptl/sysdeps/mips/Makefile13
-rw-r--r--libpthread/nptl/sysdeps/mips/Makefile.arch11
-rw-r--r--libpthread/nptl/sysdeps/mips/dl-tls.h45
-rw-r--r--libpthread/nptl/sysdeps/mips/jmpbuf-unwind.h26
-rw-r--r--libpthread/nptl/sysdeps/mips/libc-tls.c36
-rw-r--r--libpthread/nptl/sysdeps/mips/nptl-sysdep.S2
-rw-r--r--libpthread/nptl/sysdeps/mips/pthread_spin_lock.S37
-rw-r--r--libpthread/nptl/sysdeps/mips/pthread_spin_trylock.S42
-rw-r--r--libpthread/nptl/sysdeps/mips/pthreaddef.h38
-rw-r--r--libpthread/nptl/sysdeps/mips/regdef.h25
-rw-r--r--libpthread/nptl/sysdeps/mips/tcb-offsets.sym11
-rw-r--r--libpthread/nptl/sysdeps/mips/tls.h180
-rw-r--r--libpthread/nptl/sysdeps/powerpc/Makefile.arch7
-rw-r--r--libpthread/nptl/sysdeps/powerpc/dl-tls.h48
-rw-r--r--libpthread/nptl/sysdeps/powerpc/jmpbuf-unwind.h27
-rw-r--r--libpthread/nptl/sysdeps/powerpc/pthread_spin_lock.c43
-rw-r--r--libpthread/nptl/sysdeps/powerpc/pthread_spin_trylock.c41
-rw-r--r--libpthread/nptl/sysdeps/powerpc/pthreaddef.h40
-rw-r--r--libpthread/nptl/sysdeps/powerpc/tcb-offsets.sym20
-rw-r--r--libpthread/nptl/sysdeps/powerpc/tls.h215
-rw-r--r--libpthread/nptl/sysdeps/pthread/Makefile13
-rw-r--r--libpthread/nptl/sysdeps/pthread/Makefile.in106
-rw-r--r--libpthread/nptl/sysdeps/pthread/allocalim.h29
-rw-r--r--libpthread/nptl/sysdeps/pthread/bits/libc-lock.h583
-rw-r--r--libpthread/nptl/sysdeps/pthread/bits/libc-tsd.h68
-rw-r--r--libpthread/nptl/sysdeps/pthread/bits/sigthread.h0
-rw-r--r--libpthread/nptl/sysdeps/pthread/bits/stdio-lock.h110
-rw-r--r--libpthread/nptl/sysdeps/pthread/createthread.c256
-rw-r--r--libpthread/nptl/sysdeps/pthread/librt-cancellation.c24
-rw-r--r--libpthread/nptl/sysdeps/pthread/list.h102
-rw-r--r--libpthread/nptl/sysdeps/pthread/malloc-machine.h72
-rw-r--r--libpthread/nptl/sysdeps/pthread/posix-timer.h196
-rw-r--r--libpthread/nptl/sysdeps/pthread/pt-initfini.c128
-rw-r--r--libpthread/nptl/sysdeps/pthread/pt-longjmp.c30
-rw-r--r--libpthread/nptl/sysdeps/pthread/pt-sigaction.c39
-rw-r--r--libpthread/nptl/sysdeps/pthread/pthread-functions.h116
-rw-r--r--libpthread/nptl/sysdeps/pthread/pthread.h1138
-rw-r--r--libpthread/nptl/sysdeps/pthread/pthread_barrier_destroy.c43
-rw-r--r--libpthread/nptl/sysdeps/pthread/pthread_barrier_init.c70
-rw-r--r--libpthread/nptl/sysdeps/pthread/pthread_barrier_wait.c78
-rw-r--r--libpthread/nptl/sysdeps/pthread/pthread_cond_broadcast.c89
-rw-r--r--libpthread/nptl/sysdeps/pthread/pthread_cond_signal.c62
-rw-r--r--libpthread/nptl/sysdeps/pthread/pthread_cond_timedwait.c217
-rw-r--r--libpthread/nptl/sysdeps/pthread/pthread_cond_wait.c192
-rw-r--r--libpthread/nptl/sysdeps/pthread/pthread_once.c53
-rw-r--r--libpthread/nptl/sysdeps/pthread/pthread_rwlock_rdlock.c96
-rw-r--r--libpthread/nptl/sysdeps/pthread/pthread_rwlock_timedrdlock.c136
-rw-r--r--libpthread/nptl/sysdeps/pthread/pthread_rwlock_timedwrlock.c126
-rw-r--r--libpthread/nptl/sysdeps/pthread/pthread_rwlock_unlock.c59
-rw-r--r--libpthread/nptl/sysdeps/pthread/pthread_rwlock_wrlock.c88
-rw-r--r--libpthread/nptl/sysdeps/pthread/pthread_sigmask.c57
-rw-r--r--libpthread/nptl/sysdeps/pthread/pthread_spin_destroy.c28
-rw-r--r--libpthread/nptl/sysdeps/pthread/pthread_spin_init.c27
-rw-r--r--libpthread/nptl/sysdeps/pthread/pthread_spin_unlock.c29
-rw-r--r--libpthread/nptl/sysdeps/pthread/rt-unwind-resume.c1
-rw-r--r--libpthread/nptl/sysdeps/pthread/setxid.h62
-rw-r--r--libpthread/nptl/sysdeps/pthread/sigfillset.c20
-rw-r--r--libpthread/nptl/sysdeps/pthread/sigprocmask.c21
-rw-r--r--libpthread/nptl/sysdeps/pthread/tcb-offsets.h1
-rw-r--r--libpthread/nptl/sysdeps/pthread/timer_create.c169
-rw-r--r--libpthread/nptl/sysdeps/pthread/timer_delete.c69
-rw-r--r--libpthread/nptl/sysdeps/pthread/timer_getoverr.c44
-rw-r--r--libpthread/nptl/sysdeps/pthread/timer_gettime.c76
-rw-r--r--libpthread/nptl/sysdeps/pthread/timer_routines.c577
-rw-r--r--libpthread/nptl/sysdeps/pthread/timer_settime.c136
-rw-r--r--libpthread/nptl/sysdeps/pthread/tpp.c171
-rw-r--r--libpthread/nptl/sysdeps/pthread/uClibc-glue.h47
-rw-r--r--libpthread/nptl/sysdeps/pthread/unwind-forcedunwind.c155
-rw-r--r--libpthread/nptl/sysdeps/pthread/unwind-resume.c80
-rw-r--r--libpthread/nptl/sysdeps/pthread_spin_lock.c39
-rw-r--r--libpthread/nptl/sysdeps/pthread_spin_trylock.c28
-rw-r--r--libpthread/nptl/sysdeps/pthreaddef.h39
-rw-r--r--libpthread/nptl/sysdeps/sh/Makefile3
-rw-r--r--libpthread/nptl/sysdeps/sh/Makefile.arch10
-rw-r--r--libpthread/nptl/sysdeps/sh/dl-tls.h28
-rw-r--r--libpthread/nptl/sysdeps/sh/jmpbuf-unwind.h27
-rw-r--r--libpthread/nptl/sysdeps/sh/libc-tls.c31
-rw-r--r--libpthread/nptl/sysdeps/sh/pthread_spin_init.c19
-rw-r--r--libpthread/nptl/sysdeps/sh/pthread_spin_lock.c33
-rw-r--r--libpthread/nptl/sysdeps/sh/pthread_spin_trylock.S31
-rw-r--r--libpthread/nptl/sysdeps/sh/pthread_spin_unlock.S29
-rw-r--r--libpthread/nptl/sysdeps/sh/pthreaddef.h48
-rw-r--r--libpthread/nptl/sysdeps/sh/tcb-offsets.sym15
-rw-r--r--libpthread/nptl/sysdeps/sh/tls.h181
-rw-r--r--libpthread/nptl/sysdeps/sparc/Makefile3
-rw-r--r--libpthread/nptl/sysdeps/sparc/Makefile.arch8
-rw-r--r--libpthread/nptl/sysdeps/sparc/dl-tls.h28
-rw-r--r--libpthread/nptl/sysdeps/sparc/jmpbuf-unwind.h27
-rw-r--r--libpthread/nptl/sysdeps/sparc/pthread_spin_lock.c39
-rw-r--r--libpthread/nptl/sysdeps/sparc/pthread_spin_trylock.c28
-rw-r--r--libpthread/nptl/sysdeps/sparc/pthreaddef.h39
-rw-r--r--libpthread/nptl/sysdeps/sparc/tcb-offsets.sym7
-rw-r--r--libpthread/nptl/sysdeps/sparc/tls.h180
-rw-r--r--libpthread/nptl/sysdeps/unix/Makefile13
-rw-r--r--libpthread/nptl/sysdeps/unix/Makefile.in8
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/Makefile13
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/Makefile.in8
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/Makefile13
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/Makefile.commonarch169
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/__syscall_error.c18
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/accept.S12
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/alpha/Makefile2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/alpha/bits/local_lim.h99
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h167
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/alpha/bits/semaphore.h33
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/alpha/clone.S2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/alpha/createthread.c22
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/alpha/fork.c29
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/alpha/lowlevellock.h283
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/alpha/pthread_once.c96
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/alpha/sem_post.c5
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h176
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/alpha/timer_create.c1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/alpha/timer_delete.c1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/alpha/timer_getoverr.c1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/alpha/timer_gettime.c1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/alpha/timer_settime.c1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/alpha/vfork.S45
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arc/Makefile13
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arc/Makefile.arch15
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arc/bits/pthreadtypes.h181
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arc/bits/semaphore.h35
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arc/clone.S10
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arc/createthread.c25
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arc/fork.c30
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arc/libc-lowlevellock.c21
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arc/lowlevellock.c128
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arc/lowlevellock.h279
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arc/pt-__syscall_error.c7
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arc/pt-__syscall_rt_sigaction.c13
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arc/pt-gettimeofday.c11
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arc/pthread_once.c100
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arc/sysdep-cancel.h115
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arc/vfork.S11
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arm/Makefile13
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arm/Makefile.arch23
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arm/bits/pthreadtypes.h180
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arm/bits/semaphore.h34
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arm/clone.S3
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arm/createthread.c22
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arm/fork.c30
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arm/libc-lowlevellock.c20
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arm/lowlevellock.c136
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arm/lowlevellock.h281
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arm/pt-__syscall_error.c1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arm/pt-__syscall_rt_sigaction.c1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arm/pt-gettimeofday.c5
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arm/pthread_once.c99
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h253
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind-forcedunwind.c177
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind-resume.c116
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arm/vfork.S38
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/bits/local_lim.h99
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/bits/posix_opt.h203
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/close.S21
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/connect.S12
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/creat.S7
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/createthread.c23
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/exit-thread.S22
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/fork.c231
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/fork.h59
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/getpid.c69
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/Makefile13
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/Makefile.arch15
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h172
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/bits/semaphore.h35
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/clone.S2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/createthread.c48
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/fork.c30
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S464
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevelrobustlock.S233
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_barrier_wait.S186
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S238
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S215
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S698
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S594
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S194
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S244
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S237
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_unlock.S156
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S185
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_post.S139
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S328
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_trywait.S76
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_wait.S267
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/libc-lowlevellock.S1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/lowlevellock.S19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/lowlevelrobustlock.S19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_barrier_wait.S19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_cond_broadcast.S19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_cond_signal.S19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_cond_timedwait.S19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_cond_wait.S19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_rwlock_rdlock.S19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_rwlock_timedrdlock.S19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_rwlock_timedwrlock.S19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_rwlock_unlock.S19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_rwlock_wrlock.S19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/sem_post.S19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/sem_timedwait.S19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/sem_trywait.S19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/sem_wait.S19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/libc-lowlevellock.S1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/lowlevellock.S19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/lowlevelrobustlock.S19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_barrier_wait.S19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_cond_broadcast.S19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_cond_signal.S19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_cond_timedwait.S20
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_cond_wait.S19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_rwlock_rdlock.S19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_rwlock_timedrdlock.S19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_rwlock_timedwrlock.S19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_rwlock_unlock.S20
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_rwlock_wrlock.S19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/sem_post.S19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/sem_timedwait.S19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/sem_trywait.S19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/sem_wait.S19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/lowlevellock.h584
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/pt-__syscall_error.c1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/pthread_once.S196
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/pthread_spin_init.c1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/pthread_spin_unlock.S1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/smp.h55
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h154
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/vfork.S37
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/internaltypes.h161
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/jmp-unwind.c39
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/kernel-posix-timers.h1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/libc-lowlevellock.c20
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/libc_multiple_threads.c25
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/libc_pthread_init.c73
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/lowlevelbarrier.sym12
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/lowlevelcond.sym16
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/lowlevellock.c127
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c113
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.sym6
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/lowlevelrwlock.sym16
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/lseek.S7
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/metag/Makefile13
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/metag/Makefile.arch18
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/metag/bits/pthreadtypes.h181
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/metag/bits/semaphore.h35
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/metag/clone.S9
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/metag/createthread.c23
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/metag/fork.c31
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/metag/libc-lowlevellock.c21
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/metag/lowlevellock.c137
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/metag/lowlevellock.h279
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/metag/pt-__syscall_error.c7
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/metag/pt-__syscall_rt_sigaction.c7
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/metag/pt-gettimeofday.c11
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/metag/pthread_once.c100
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/metag/sysdep-cancel.h152
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/metag/vfork.S56
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/mips/Makefile13
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/mips/Makefile.arch17
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/mips/bits/pthreadtypes.h229
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/mips/bits/semaphore.h36
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/mips/clone.S2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/mips/createthread.c23
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/mips/fork.c1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/mips/lowlevellock.h294
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/mips/pt-__syscall_rt_sigaction.c1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/mips/pt-clone.S2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/mips/pthread_once.c92
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h187
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/mips/vfork.S42
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/mq_notify.c285
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/msync.S7
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/nanosleep.S9
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/not-cancel.h113
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/open.S21
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pause.S7
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/Makefile13
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/Makefile.arch18
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h220
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/bits/semaphore.h40
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/clone.S5
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/createthread.c24
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/fork.c1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h314
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S9
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h118
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S (renamed from libpthread/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-64/vfork.S)61
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S9
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h120
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_create.c1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_delete.c1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_getoverr.c1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_gettime.c1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_settime.c1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S (renamed from libpthread/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-32/vfork.S)67
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/pt-__syscall_error.c1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/pt-longjmp.c36
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_once.c100
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_spin_unlock.c28
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/sem_post.c45
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h5
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/vfork.S5
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pt-accept.S12
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pt-close.S9
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pt-connect.S12
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pt-fcntl.c1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pt-fork.c28
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pt-fsync.c2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pt-llseek.c3
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pt-lseek.S7
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pt-msgrcv.c2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pt-msgsnd.c2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pt-msync.S7
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pt-nanosleep.S9
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pt-open.S9
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pt-open64.c1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pt-pause.S7
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pt-pread_pwrite.c1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pt-raise.c51
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pt-read.S9
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pt-recv.S12
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pt-recvfrom.S12
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pt-recvmsg.S12
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pt-send.S12
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pt-sendmsg.S12
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pt-sendto.S12
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pt-sigwait.c2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pt-sleep.c2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pt-tcdrain.c1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pt-tempname.c1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pt-wait.c2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pt-waitpid.c1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pt-write.S9
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pthread-pi-defines.sym8
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pthread_attr_getaffinity.c54
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pthread_attr_setaffinity.c80
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pthread_getaffinity.c45
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pthread_getcpuclockid.c56
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pthread_kill.c77
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pthread_mutex_cond_lock.c14
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pthread_setaffinity.c91
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pthread_sigqueue.c82
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pthread_yield.c29
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/raise.c73
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/read.S19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/recv.S12
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/recvfrom.S12
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/recvmsg.S12
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/register-atfork.c148
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sem_post.c56
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sem_timedwait.c110
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sem_trywait.c42
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sem_wait.c82
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/send.S12
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sendmsg.S12
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sendto.S12
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sh/Makefile13
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sh/Makefile.arch19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h182
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sh/bits/semaphore.h35
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sh/clone.S2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sh/createthread.c23
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sh/fork.c29
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sh/libc-lowlevellock.S18
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevel-atomic.h80
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.S545
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h419
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevelrobustlock.S264
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sh/pt-initfini.c125
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_barrier_wait.S215
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_broadcast.S262
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_signal.S189
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S860
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S753
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_once.S262
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_rdlock.S254
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedrdlock.S313
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedwrlock.S297
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_unlock.S198
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_wrlock.S234
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sh/sem_post.S108
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sh/sem_timedwait.S357
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sh/sem_trywait.S88
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sh/sem_wait.S301
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sh/sh4/lowlevellock.h4
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sh/smp.h (renamed from libc/sysdeps/linux/vax/bits/wordsize.h)12
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h168
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sh/vfork.S70
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sigtimedwait.c87
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sigwait.c2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sigwaitinfo.c87
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sleep.c2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/smp.h (renamed from libc/misc/pthread/unlock.c)20
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sparc/Makefile13
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sparc/Makefile.arch19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sparc/bits/local_lim.h99
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sparc/bits/pthreadtypes.h220
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sparc/bits/semaphore.h40
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sparc/clone.S2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sparc/fork.c28
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sparc/internaltypes.h34
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sparc/libc-lowlevellock.c20
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sparc/lowlevellock.c135
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sparc/lowlevellock.h296
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sparc/pt-__syscall_error.c1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sparc/pthread_barrier_destroy.c44
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sparc/pthread_barrier_init.c54
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sparc/pthread_barrier_wait.c93
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sparc/pthread_once.c94
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sparc/sem_init.c54
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sparc/sem_post.c52
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sparc/sem_timedwait.c147
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sparc/sem_trywait.c51
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sparc/sem_wait.c124
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h (renamed from libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h)104
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sparc/vfork.S48
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/structsem.sym12
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/timer_create.c242
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/timer_delete.c114
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/timer_getoverr.c80
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/timer_gettime.c82
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/timer_routines.c203
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/timer_settime.c87
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/unregister-atfork.c122
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/unwindbuf.sym7
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/waitpid.S23
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/write.S19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/Makefile13
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/Makefile.arch22
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h224
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/bits/semaphore.h40
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S115
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/clone.S3
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/compat-timer.h45
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/fork.c30
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/libc-cancellation.S21
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/libc-lowlevellock.S19
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/librt-cancellation.S21
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S462
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h597
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S305
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pt-__syscall_error.c1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S160
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S177
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S160
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S795
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S486
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S189
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S179
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S275
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S267
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S130
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S167
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_setaffinity.c14
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_spin_init.c1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_spin_unlock.S1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S88
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S378
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/sem_trywait.S51
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S173
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h110
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/vfork.S42
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/Makefile.arch15
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/bits/pthreadtypes.h184
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/bits/semaphore.h35
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/clone.S3
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/createthread.c24
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/fork.c29
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/lowlevellock.c132
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/lowlevellock.h293
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/pt-initfini.c134
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/pthread_once.c89
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/sysdep-cancel.h172
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/vfork.S59
-rw-r--r--libpthread/nptl/sysdeps/x86_64/Makefile.arch10
-rw-r--r--libpthread/nptl/sysdeps/x86_64/dl-tls.h28
-rw-r--r--libpthread/nptl/sysdeps/x86_64/jmpbuf-unwind.h27
-rw-r--r--libpthread/nptl/sysdeps/x86_64/pthread_spin_init.c1
-rw-r--r--libpthread/nptl/sysdeps/x86_64/pthread_spin_lock.c1
-rw-r--r--libpthread/nptl/sysdeps/x86_64/pthread_spin_trylock.S39
-rw-r--r--libpthread/nptl/sysdeps/x86_64/pthread_spin_unlock.S30
-rw-r--r--libpthread/nptl/sysdeps/x86_64/pthreaddef.h42
-rw-r--r--libpthread/nptl/sysdeps/x86_64/tcb-offsets.sym28
-rw-r--r--libpthread/nptl/sysdeps/x86_64/tls.h437
-rw-r--r--libpthread/nptl/sysdeps/xtensa/Makefile.arch40
-rw-r--r--libpthread/nptl/sysdeps/xtensa/dl-tls.h58
-rw-r--r--libpthread/nptl/sysdeps/xtensa/jmpbuf-unwind.h32
-rw-r--r--libpthread/nptl/sysdeps/xtensa/libc-tls.c36
-rw-r--r--libpthread/nptl/sysdeps/xtensa/pthread_spin_lock.S33
-rw-r--r--libpthread/nptl/sysdeps/xtensa/pthread_spin_trylock.S35
-rw-r--r--libpthread/nptl/sysdeps/xtensa/pthreaddef.h (renamed from libc/sysdeps/linux/mips/readahead.c)46
-rw-r--r--libpthread/nptl/sysdeps/xtensa/tcb-offsets.sym7
-rw-r--r--libpthread/nptl/sysdeps/xtensa/tls.h159
-rw-r--r--libpthread/nptl/sysdeps/xtensa/tlsdesc.sym10
-rw-r--r--libpthread/nptl/unwind.c179
-rw-r--r--libpthread/nptl/vars.c42
-rw-r--r--libpthread/nptl/version.c44
-rw-r--r--libpthread/nptl/version.h1
-rw-r--r--libpthread/nptl_db/ChangeLog230
-rw-r--r--libpthread/nptl_db/Makefile13
-rw-r--r--libpthread/nptl_db/Makefile.in74
-rw-r--r--libpthread/nptl_db/db_info.c104
-rw-r--r--libpthread/nptl_db/fetch-value.c283
-rw-r--r--libpthread/nptl_db/proc_service.h86
-rw-r--r--libpthread/nptl_db/structs.def88
-rw-r--r--libpthread/nptl_db/td_init.c31
-rw-r--r--libpthread/nptl_db/td_log.c31
-rw-r--r--libpthread/nptl_db/td_symbol_list.c70
-rw-r--r--libpthread/nptl_db/td_ta_clear_event.c76
-rw-r--r--libpthread/nptl_db/td_ta_delete.c41
-rw-r--r--libpthread/nptl_db/td_ta_enable_stats.c34
-rw-r--r--libpthread/nptl_db/td_ta_event_addr.c60
-rw-r--r--libpthread/nptl_db/td_ta_event_getmsg.c104
-rw-r--r--libpthread/nptl_db/td_ta_get_nthreads.c41
-rw-r--r--libpthread/nptl_db/td_ta_get_ph.c35
-rw-r--r--libpthread/nptl_db/td_ta_get_stats.c34
-rw-r--r--libpthread/nptl_db/td_ta_map_id2thr.c37
-rw-r--r--libpthread/nptl_db/td_ta_map_lwp2thr.c208
-rw-r--r--libpthread/nptl_db/td_ta_new.c64
-rw-r--r--libpthread/nptl_db/td_ta_reset_stats.c34
-rw-r--r--libpthread/nptl_db/td_ta_set_event.c76
-rw-r--r--libpthread/nptl_db/td_ta_setconcurrency.c34
-rw-r--r--libpthread/nptl_db/td_ta_thr_iter.c150
-rw-r--r--libpthread/nptl_db/td_ta_tsd_iter.c80
-rw-r--r--libpthread/nptl_db/td_thr_clear_event.c74
-rw-r--r--libpthread/nptl_db/td_thr_dbresume.c29
-rw-r--r--libpthread/nptl_db/td_thr_dbsuspend.c29
-rw-r--r--libpthread/nptl_db/td_thr_event_enable.c49
-rw-r--r--libpthread/nptl_db/td_thr_event_getmsg.c118
-rw-r--r--libpthread/nptl_db/td_thr_get_info.c124
-rw-r--r--libpthread/nptl_db/td_thr_getfpregs.c57
-rw-r--r--libpthread/nptl_db/td_thr_getgregs.c57
-rw-r--r--libpthread/nptl_db/td_thr_getxregs.c29
-rw-r--r--libpthread/nptl_db/td_thr_getxregsize.c29
-rw-r--r--libpthread/nptl_db/td_thr_set_event.c74
-rw-r--r--libpthread/nptl_db/td_thr_setfpregs.c54
-rw-r--r--libpthread/nptl_db/td_thr_setgregs.c54
-rw-r--r--libpthread/nptl_db/td_thr_setprio.c29
-rw-r--r--libpthread/nptl_db/td_thr_setsigpending.c30
-rw-r--r--libpthread/nptl_db/td_thr_setxregs.c29
-rw-r--r--libpthread/nptl_db/td_thr_sigsetmask.c29
-rw-r--r--libpthread/nptl_db/td_thr_tls_get_addr.c42
-rw-r--r--libpthread/nptl_db/td_thr_tlsbase.c75
-rw-r--r--libpthread/nptl_db/td_thr_tsd.c95
-rw-r--r--libpthread/nptl_db/td_thr_validate.c84
-rw-r--r--libpthread/nptl_db/thread_db.h458
-rw-r--r--libpthread/nptl_db/thread_dbP.h260
-rw-r--r--libresolv/Makefile.in19
-rw-r--r--libresolv/resolv.c2
-rw-r--r--librt/Makefile.in63
-rw-r--r--librt/clock_getcpuclockid.c103
-rw-r--r--librt/clock_gettime.c299
-rw-r--r--librt/clock_nanosleep.c95
-rw-r--r--librt/dso_handle.c5
-rw-r--r--librt/kernel-posix-cpu-timers.h18
-rw-r--r--librt/kernel-posix-timers.h22
-rw-r--r--librt/mq_receive.c40
-rw-r--r--librt/mq_send.c40
-rw-r--r--librt/mq_timedreceive.S8
-rw-r--r--librt/mq_timedsend.S8
-rw-r--r--librt/rt_stubs.c40
-rw-r--r--librt/shm.c102
-rw-r--r--librt/spawn.c266
-rw-r--r--librt/spawn_faction_addclose.c51
-rw-r--r--librt/spawn_faction_adddup2.c52
-rw-r--r--librt/spawn_faction_addopen.c55
-rw-r--r--librt/spawn_faction_init.c42
-rw-r--r--librt/spawn_int.h35
-rw-r--r--librt/timer_create.c5
-rw-r--r--libuargp/Makefile14
-rw-r--r--libuargp/Makefile.in73
-rw-r--r--libuargp/argp-ba.c26
-rw-r--r--libuargp/argp-eexst.c32
-rw-r--r--libuargp/argp-fmtstream.c439
-rw-r--r--libuargp/argp-fmtstream.h314
-rw-r--r--libuargp/argp-fs-xinl.c44
-rw-r--r--libuargp/argp-help.c1882
-rw-r--r--libuargp/argp-parse.c949
-rw-r--r--libuargp/argp-pv.c25
-rw-r--r--libuargp/argp-pvh.c32
-rw-r--r--libuargp/argp-xinl.c35
-rw-r--r--libubacktrace/Makefile14
-rw-r--r--libubacktrace/Makefile.in84
-rw-r--r--libubacktrace/arm/Makefile.arch17
-rw-r--r--libubacktrace/arm/backtrace.c98
-rw-r--r--libubacktrace/backtrace.c89
-rw-r--r--libubacktrace/backtracesyms.c104
-rw-r--r--libubacktrace/backtracesymsfd.c115
-rw-r--r--libutil/Makefile.in27
-rw-r--r--libutil/forkpty.c8
-rw-r--r--libutil/login.c59
-rw-r--r--libutil/login_tty.c1
-rw-r--r--libutil/logout.c33
-rw-r--r--libutil/logwtmp.c36
-rw-r--r--libutil/openpty.c6
-rw-r--r--test/.gitignore334
-rw-r--r--test/Makefile34
-rw-r--r--test/README56
-rw-r--r--test/Rules.mak137
-rw-r--r--test/Test.mak85
-rw-r--r--test/argp/Makefile8
-rw-r--r--test/argp/Makefile.in12
-rw-r--r--test/argp/argp-ex1.c15
-rw-r--r--test/argp/argp-ex2.c45
-rw-r--r--test/argp/argp-ex3.c153
-rw-r--r--test/argp/argp-ex4.c167
-rw-r--r--test/argp/argp-test.c209
-rw-r--r--test/argp/bug-argp1.c26
-rw-r--r--test/argp/tst-argp1.c118
-rw-r--r--test/argp/tst-argp2.c101
-rw-r--r--test/args/Makefile11
-rw-r--r--test/args/Makefile.in9
-rw-r--r--test/assert/Makefile7
-rw-r--r--test/assert/Makefile.in6
-rw-r--r--test/build/Makefile4
-rwxr-xr-x[-rw-r--r--]test/build/check_config_options.sh0
-rw-r--r--test/crypt/Makefile8
-rw-r--r--test/crypt/Makefile.in15
-rw-r--r--test/crypt/crypt.c76
-rw-r--r--test/crypt/sha256c-test.c62
-rw-r--r--test/crypt/sha512c-test.c63
-rw-r--r--test/ctype/Makefile6
-rw-r--r--test/ctype/Makefile.in5
-rw-r--r--test/ctype/ctype.c2
-rw-r--r--test/dlopen/Makefile40
-rw-r--r--test/dlopen/Makefile.in82
-rw-r--r--test/dlopen/dltest.c2
-rw-r--r--test/dlopen/libA.c7
-rw-r--r--test/dlopen/libB.c7
-rw-r--r--test/dlopen/libC.c30
-rw-r--r--test/dlopen/libtest.c4
-rw-r--r--test/dlopen/nodelete.c205
-rw-r--r--test/dlopen/nodelmod1.c10
-rw-r--r--test/dlopen/nodelmod2.c10
-rw-r--r--test/dlopen/nodelmod3.c8
-rw-r--r--test/dlopen/nodelmod4.c10
-rw-r--r--test/dlopen/testscope.c29
-rw-r--r--test/dlopen/tst-origin.c37
-rw-r--r--test/inet/Makefile4
-rw-r--r--test/inet/Makefile.in21
-rw-r--r--test/inet/bug-if1.c5
-rw-r--r--test/inet/gethost.c40
-rw-r--r--test/inet/gethostid.c6
-rw-r--r--test/inet/getnetent.c17
-rw-r--r--test/inet/tst-ether_aton.c46
-rw-r--r--test/inet/tst-ifaddrs.c99
-rw-r--r--test/inet/tst-network.c5
-rw-r--r--test/inet/tst-res.c44
-rw-r--r--test/inet/tst-sock-nonblock.c53
-rw-r--r--test/librt/Makefile8
-rw-r--r--test/librt/Makefile.in8
-rw-r--r--test/librt/shmtest.c104
-rw-r--r--test/locale-mbwc/Makefile29
-rw-r--r--test/locale-mbwc/Makefile.in31
-rw-r--r--test/locale-mbwc/dat_iswctype.c2
-rw-r--r--test/locale-mbwc/tst2_mbrtowc.c21
-rw-r--r--test/locale-mbwc/tst_funcs.h24
-rw-r--r--test/locale/Makefile31
-rw-r--r--test/locale/Makefile.in31
-rw-r--r--test/locale/collate-test.c5
-rw-r--r--test/locale/dump-ctype.c5
-rw-r--r--test/locale/gen-unicode-ctype.c5
-rw-r--r--test/locale/tst-C-locale.c5
-rw-r--r--test/locale/tst-ctype.c5
-rw-r--r--test/locale/tst-digits.c5
-rw-r--r--test/locale/tst-fmon.c5
-rw-r--r--test/locale/tst-langinfo.c5
-rw-r--r--test/locale/tst-langinfo.input5
-rw-r--r--test/locale/tst-mbswcs1.c5
-rw-r--r--test/locale/tst-mbswcs2.c5
-rw-r--r--test/locale/tst-mbswcs3.c5
-rw-r--r--test/locale/tst-mbswcs4.c5
-rw-r--r--test/locale/tst-mbswcs5.c5
-rw-r--r--test/locale/tst-mbswcs6.c5
-rw-r--r--test/locale/tst-numeric.c5
-rw-r--r--test/locale/tst-rpmatch.c5
-rw-r--r--test/locale/tst-trans.c5
-rw-r--r--test/locale/tst-wctype.c5
-rw-r--r--test/locale/xfrm-test.c5
-rw-r--r--test/malloc/Makefile6
-rw-r--r--test/malloc/Makefile.in18
-rw-r--r--test/malloc/tst-asprintf.c27
-rw-r--r--test/malloc/tst-calloc.c23
-rw-r--r--test/malloc/tst-malloc.c5
-rw-r--r--test/malloc/tst-mcheck.c5
-rw-r--r--test/malloc/tst-obstack.c44
-rw-r--r--test/math/Makefile26
-rw-r--r--test/math/Makefile.in46
-rw-r--r--test/math/basic-test.c78
-rw-r--r--test/math/c99_test.c116
-rw-r--r--test/math/compile_test.c141
-rw-r--r--test/math/gamma.c73
-rwxr-xr-xtest/math/gen-libm-test.pl7
-rw-r--r--test/math/ilogb.c52
-rw-r--r--test/math/libm-test-ulps-arc144
-rw-r--r--test/math/libm-test-ulps-arm4989
-rw-r--r--test/math/libm-test-ulps-cris145
-rw-r--r--test/math/libm-test-ulps-generic5
-rw-r--r--test/math/libm-test-ulps-i3861261
-rw-r--r--test/math/libm-test-ulps-ia641146
-rw-r--r--test/math/libm-test-ulps-mips324966
-rw-r--r--test/math/libm-test-ulps-mips649633
-rw-r--r--test/math/libm-test-ulps-powerpc1336
-rw-r--r--test/math/libm-test-ulps-s3901332
-rw-r--r--test/math/libm-test-ulps-sh1094
-rw-r--r--test/math/libm-test-ulps-sparc1338
-rw-r--r--test/math/libm-test-ulps-x86_641308
-rw-r--r--test/math/libm-test-ulps-xtensa145
-rw-r--r--test/math/libm-test.inc82
-rw-r--r--test/math/rint.c34
-rw-r--r--test/math/signgam.c28
-rw-r--r--test/math/test-double.c5
-rw-r--r--test/math/test-float.c5
-rw-r--r--test/math/test-fpucw.c5
-rw-r--r--test/math/test-idouble.c5
-rw-r--r--test/math/test-ifloat.c5
-rw-r--r--test/math/test-ildoubl.c5
-rw-r--r--test/math/test-ldouble.c5
-rw-r--r--test/math/tst-definitions.c5
-rw-r--r--test/misc/Makefile14
-rw-r--r--test/misc/Makefile.in48
-rw-r--r--test/misc/bug-glob1.c4
-rw-r--r--test/misc/bug-glob2.c6
-rw-r--r--test/misc/fdopen.c2
-rw-r--r--test/misc/opendir-tst1.c8
-rw-r--r--test/misc/tst-fnmatch.c5
-rw-r--r--test/misc/tst-fnmatch.input5
-rw-r--r--test/misc/tst-gnuglob.c5
-rw-r--r--test/misc/tst-inotify.c65
-rw-r--r--test/misc/tst-mkostemps.c159
-rw-r--r--test/misc/tst-scandir.c23
-rw-r--r--test/misc/tst-statfs.c31
-rw-r--r--test/misc/tst-statvfs.c26
-rw-r--r--test/misc/tst-utmp.c67
-rw-r--r--test/misc/tst-utmpx.c2
-rw-r--r--test/mmap/Makefile4
-rw-r--r--test/mmap/mmap2.c7
-rw-r--r--test/nptl/Makefile8
-rw-r--r--test/nptl/Makefile.in220
-rw-r--r--test/nptl/eintr.c88
-rw-r--r--test/nptl/libatfork.c27
-rw-r--r--test/nptl/tst-align.c70
-rw-r--r--test/nptl/tst-align2.c86
-rw-r--r--test/nptl/tst-align3.c56
-rw-r--r--test/nptl/tst-atfork1.c120
-rw-r--r--test/nptl/tst-atfork2.c24
-rw-r--r--test/nptl/tst-attr1.c305
-rw-r--r--test/nptl/tst-attr2.c316
-rw-r--r--test/nptl/tst-attr3.c419
-rw-r--r--test/nptl/tst-barrier1.c70
-rw-r--r--test/nptl/tst-barrier2.c184
-rw-r--r--test/nptl/tst-barrier3.c153
-rw-r--r--test/nptl/tst-barrier4.c121
-rw-r--r--test/nptl/tst-basic1.c81
-rw-r--r--test/nptl/tst-basic2.c120
-rw-r--r--test/nptl/tst-basic3.c86
-rw-r--r--test/nptl/tst-basic4.c100
-rw-r--r--test/nptl/tst-basic5.c73
-rw-r--r--test/nptl/tst-basic6.c131
-rw-r--r--test/nptl/tst-basic7.c75
-rw-r--r--test/nptl/tst-cancel1.c162
-rw-r--r--test/nptl/tst-cancel10.c125
-rw-r--r--test/nptl/tst-cancel11.c122
-rw-r--r--test/nptl/tst-cancel12.c126
-rw-r--r--test/nptl/tst-cancel13.c128
-rw-r--r--test/nptl/tst-cancel14.c136
-rw-r--r--test/nptl/tst-cancel15.c141
-rw-r--r--test/nptl/tst-cancel16.c230
-rw-r--r--test/nptl/tst-cancel18.c173
-rw-r--r--test/nptl/tst-cancel19.c286
-rw-r--r--test/nptl/tst-cancel2.c99
-rw-r--r--test/nptl/tst-cancel20.c263
-rw-r--r--test/nptl/tst-cancel21.c293
-rw-r--r--test/nptl/tst-cancel22.c121
-rw-r--r--test/nptl/tst-cancel23.c1
-rw-r--r--test/nptl/tst-cancel25.c171
-rw-r--r--test/nptl/tst-cancel3.c97
-rw-r--r--test/nptl/tst-cancel4.c2393
-rw-r--r--test/nptl/tst-cancel5.c1
-rw-r--r--test/nptl/tst-cancel6.c78
-rw-r--r--test/nptl/tst-cancel7.c208
-rw-r--r--test/nptl/tst-cancel8.c142
-rw-r--r--test/nptl/tst-cancel9.c125
-rw-r--r--test/nptl/tst-cancelx10.c1
-rw-r--r--test/nptl/tst-cancelx11.c1
-rw-r--r--test/nptl/tst-cancelx12.c1
-rw-r--r--test/nptl/tst-cancelx13.c1
-rw-r--r--test/nptl/tst-cancelx14.c1
-rw-r--r--test/nptl/tst-cancelx15.c1
-rw-r--r--test/nptl/tst-cancelx16.c1
-rw-r--r--test/nptl/tst-cancelx18.c1
-rw-r--r--test/nptl/tst-cancelx2.c1
-rw-r--r--test/nptl/tst-cancelx20.c1
-rw-r--r--test/nptl/tst-cancelx21.c1
-rw-r--r--test/nptl/tst-cancelx3.c1
-rw-r--r--test/nptl/tst-cancelx4.c1
-rw-r--r--test/nptl/tst-cancelx6.c1
-rw-r--r--test/nptl/tst-cancelx7.c1
-rw-r--r--test/nptl/tst-cancelx8.c1
-rw-r--r--test/nptl/tst-cancelx9.c1
-rw-r--r--test/nptl/tst-cleanup0.c75
-rw-r--r--test/nptl/tst-cleanup1.c99
-rw-r--r--test/nptl/tst-cleanup2.c62
-rw-r--r--test/nptl/tst-cleanup3.c97
-rw-r--r--test/nptl/tst-cleanup4.c197
-rw-r--r--test/nptl/tst-cleanup4aux.c120
-rw-r--r--test/nptl/tst-cleanupx0.c1
-rw-r--r--test/nptl/tst-cleanupx1.c1
-rw-r--r--test/nptl/tst-cleanupx2.c1
-rw-r--r--test/nptl/tst-cleanupx3.c1
-rw-r--r--test/nptl/tst-cleanupx4.c1
-rw-r--r--test/nptl/tst-clock.c123
-rw-r--r--test/nptl/tst-clock1.c50
-rw-r--r--test/nptl/tst-clock2.c201
-rw-r--r--test/nptl/tst-clock_nanosleep.c57
-rw-r--r--test/nptl/tst-cond1.c93
-rw-r--r--test/nptl/tst-cond10.c172
-rw-r--r--test/nptl/tst-cond11.c190
-rw-r--r--test/nptl/tst-cond12.c195
-rw-r--r--test/nptl/tst-cond13.c2
-rw-r--r--test/nptl/tst-cond14.c117
-rw-r--r--test/nptl/tst-cond15.c159
-rw-r--r--test/nptl/tst-cond16.c104
-rw-r--r--test/nptl/tst-cond17.c2
-rw-r--r--test/nptl/tst-cond18.c116
-rw-r--r--test/nptl/tst-cond19.c75
-rw-r--r--test/nptl/tst-cond2.c162
-rw-r--r--test/nptl/tst-cond20.c169
-rw-r--r--test/nptl/tst-cond21.c3
-rw-r--r--test/nptl/tst-cond22.c160
-rw-r--r--test/nptl/tst-cond23.c183
-rw-r--r--test/nptl/tst-cond3.c112
-rw-r--r--test/nptl/tst-cond4.c263
-rw-r--r--test/nptl/tst-cond5.c105
-rw-r--r--test/nptl/tst-cond6.c233
-rw-r--r--test/nptl/tst-cond7.c167
-rw-r--r--test/nptl/tst-cond8.c276
-rw-r--r--test/nptl/tst-cond9.c149
-rw-r--r--test/nptl/tst-cpuclock1.c306
-rw-r--r--test/nptl/tst-cpuclock2.c331
-rw-r--r--test/nptl/tst-cputimer1.c68
-rw-r--r--test/nptl/tst-cputimer2.c83
-rw-r--r--test/nptl/tst-cputimer3.c130
-rw-r--r--test/nptl/tst-detach1.c55
-rw-r--r--test/nptl/tst-dlsym1.c66
-rw-r--r--test/nptl/tst-eintr1.c104
-rw-r--r--test/nptl/tst-eintr2.c117
-rw-r--r--test/nptl/tst-eintr3.c71
-rw-r--r--test/nptl/tst-eintr4.c55
-rw-r--r--test/nptl/tst-eintr5.c80
-rw-r--r--test/nptl/tst-exec2.c153
-rw-r--r--test/nptl/tst-exec3.c151
-rw-r--r--test/nptl/tst-exec4.c115
-rw-r--r--test/nptl/tst-exit1.c78
-rw-r--r--test/nptl/tst-exit2.c40
-rw-r--r--test/nptl/tst-exit3.c81
-rw-r--r--test/nptl/tst-fini1.c34
-rw-r--r--test/nptl/tst-fini1mod.c71
-rw-r--r--test/nptl/tst-flock1.c92
-rw-r--r--test/nptl/tst-flock2.c259
-rw-r--r--test/nptl/tst-fork1.c119
-rw-r--r--test/nptl/tst-fork2.c89
-rw-r--r--test/nptl/tst-fork3.c106
-rw-r--r--test/nptl/tst-fork4.c64
-rw-r--r--test/nptl/tst-getpid1.c122
-rw-r--r--test/nptl/tst-getpid2.c2
-rw-r--r--test/nptl/tst-getpid3.c114
-rw-r--r--test/nptl/tst-initializers1-c89.c1
-rw-r--r--test/nptl/tst-initializers1-c99.c1
-rw-r--r--test/nptl/tst-initializers1-gnu89.c1
-rw-r--r--test/nptl/tst-initializers1-gnu99.c1
-rw-r--r--test/nptl/tst-initializers1.c47
-rw-r--r--test/nptl/tst-join1.c82
-rw-r--r--test/nptl/tst-join2.c103
-rw-r--r--test/nptl/tst-join3.c122
-rw-r--r--test/nptl/tst-join4.c124
-rw-r--r--test/nptl/tst-join5.c142
-rw-r--r--test/nptl/tst-join6.c2
-rw-r--r--test/nptl/tst-key1.c88
-rw-r--r--test/nptl/tst-key2.c114
-rw-r--r--test/nptl/tst-key3.c155
-rw-r--r--test/nptl/tst-key4.c136
-rw-r--r--test/nptl/tst-kill1.c99
-rw-r--r--test/nptl/tst-kill2.c138
-rw-r--r--test/nptl/tst-kill3.c158
-rw-r--r--test/nptl/tst-kill4.c73
-rw-r--r--test/nptl/tst-kill5.c48
-rw-r--r--test/nptl/tst-kill6.c161
-rw-r--r--test/nptl/tst-mqueue.h83
-rw-r--r--test/nptl/tst-mqueue1.c416
-rw-r--r--test/nptl/tst-mqueue2.c476
-rw-r--r--test/nptl/tst-mqueue3.c243
-rw-r--r--test/nptl/tst-mqueue4.c287
-rw-r--r--test/nptl/tst-mqueue5.c1013
-rw-r--r--test/nptl/tst-mqueue6.c304
-rw-r--r--test/nptl/tst-mqueue7.c108
-rw-r--r--test/nptl/tst-mqueue8.c265
-rw-r--r--test/nptl/tst-mqueue9.c91
-rw-r--r--test/nptl/tst-mutex1.c56
-rw-r--r--test/nptl/tst-mutex2.c222
-rw-r--r--test/nptl/tst-mutex3.c224
-rw-r--r--test/nptl/tst-mutex4.c190
-rw-r--r--test/nptl/tst-mutex5.c185
-rw-r--r--test/nptl/tst-mutex5a.c2
-rw-r--r--test/nptl/tst-mutex6.c54
-rw-r--r--test/nptl/tst-mutex7.c120
-rw-r--r--test/nptl/tst-mutex7a.c2
-rw-r--r--test/nptl/tst-mutex8.c366
-rw-r--r--test/nptl/tst-mutex9.c190
-rw-r--r--test/nptl/tst-oddstacklimit.c1
-rw-r--r--test/nptl/tst-once1.c50
-rw-r--r--test/nptl/tst-once2.c103
-rw-r--r--test/nptl/tst-once3.c161
-rw-r--r--test/nptl/tst-once4.c201
-rw-r--r--test/nptl/tst-oncex3.c1
-rw-r--r--test/nptl/tst-oncex4.c1
-rw-r--r--test/nptl/tst-popen1.c59
-rw-r--r--test/nptl/tst-raise1.c61
-rw-r--r--test/nptl/tst-rwlock1.c116
-rw-r--r--test/nptl/tst-rwlock10.c20
-rw-r--r--test/nptl/tst-rwlock11.c20
-rw-r--r--test/nptl/tst-rwlock12.c207
-rw-r--r--test/nptl/tst-rwlock13.c70
-rw-r--r--test/nptl/tst-rwlock14.c168
-rw-r--r--test/nptl/tst-rwlock2.c142
-rw-r--r--test/nptl/tst-rwlock2a.c2
-rw-r--r--test/nptl/tst-rwlock3.c92
-rw-r--r--test/nptl/tst-rwlock4.c189
-rw-r--r--test/nptl/tst-rwlock5.c86
-rw-r--r--test/nptl/tst-rwlock6.c225
-rw-r--r--test/nptl/tst-rwlock7.c178
-rw-r--r--test/nptl/tst-rwlock8.c163
-rw-r--r--test/nptl/tst-rwlock9.c202
-rw-r--r--test/nptl/tst-sched1.c97
-rw-r--r--test/nptl/tst-sem1.c88
-rw-r--r--test/nptl/tst-sem10.c87
-rw-r--r--test/nptl/tst-sem11.c76
-rw-r--r--test/nptl/tst-sem12.c14
-rw-r--r--test/nptl/tst-sem2.c53
-rw-r--r--test/nptl/tst-sem3.c144
-rw-r--r--test/nptl/tst-sem4.c149
-rw-r--r--test/nptl/tst-sem5.c79
-rw-r--r--test/nptl/tst-sem6.c80
-rw-r--r--test/nptl/tst-sem7.c108
-rw-r--r--test/nptl/tst-sem8.c73
-rw-r--r--test/nptl/tst-sem9.c80
-rw-r--r--test/nptl/tst-signal1.c188
-rw-r--r--test/nptl/tst-signal2.c197
-rw-r--r--test/nptl/tst-signal3.c260
-rw-r--r--test/nptl/tst-signal4.c59
-rw-r--r--test/nptl/tst-signal5.c110
-rw-r--r--test/nptl/tst-signal6.c191
-rw-r--r--test/nptl/tst-signal7.c58
-rw-r--r--test/nptl/tst-spin1.c56
-rw-r--r--test/nptl/tst-spin2.c158
-rw-r--r--test/nptl/tst-spin3.c54
-rw-r--r--test/nptl/tst-stack-align.h34
-rw-r--r--test/nptl/tst-stack1.c145
-rw-r--r--test/nptl/tst-stack2.c79
-rw-r--r--test/nptl/tst-stdio1.c56
-rw-r--r--test/nptl/tst-stdio2.c81
-rw-r--r--test/nptl/tst-sysconf.c47
-rw-r--r--test/nptl/tst-timer2.c65
-rw-r--r--test/nptl/tst-timer3.c86
-rw-r--r--test/nptl/tst-timer4.c647
-rw-r--r--test/nptl/tst-timer5.c38
-rw-r--r--test/nptl/tst-tls1.c121
-rw-r--r--test/nptl/tst-tls2.c215
-rw-r--r--test/nptl/tst-tls3.c224
-rw-r--r--test/nptl/tst-tls3mod.c105
-rw-r--r--test/nptl/tst-tls4.c190
-rw-r--r--test/nptl/tst-tls4moda.c55
-rw-r--r--test/nptl/tst-tls4modb.c64
-rw-r--r--test/nptl/tst-tls5.c118
-rw-r--r--test/nptl/tst-tls5.h28
-rw-r--r--test/nptl/tst-tls5mod.c6
-rw-r--r--test/nptl/tst-tls5moda.c6
-rw-r--r--test/nptl/tst-tls5modb.c6
-rw-r--r--test/nptl/tst-tls5modc.c6
-rw-r--r--test/nptl/tst-tls5modd.c6
-rw-r--r--test/nptl/tst-tls5mode.c8
-rw-r--r--test/nptl/tst-tls5modf.c9
-rw-r--r--test/nptl/tst-tsd1.c117
-rw-r--r--test/nptl/tst-tsd2.c96
-rw-r--r--test/nptl/tst-tsd3.c128
-rw-r--r--test/nptl/tst-tsd4.c102
-rw-r--r--test/nptl/tst-tsd5.c80
-rw-r--r--test/nptl/tst-tsd6.c89
-rw-r--r--test/nptl/tst-typesizes.c95
-rw-r--r--test/nptl/tst-umask1.c136
-rw-r--r--test/nptl/tst-unload.c46
-rw-r--r--test/nptl/tst-vfork1.c149
-rw-r--r--test/nptl/tst-vfork1x.c149
-rw-r--r--test/nptl/tst-vfork2.c198
-rw-r--r--test/nptl/tst-vfork2x.c198
-rwxr-xr-xtest/plt/check-plt.sh38
-rw-r--r--test/pthread/Makefile8
-rw-r--r--test/pthread/Makefile.in8
-rw-r--r--test/pthread/cancellation-points.c10
-rw-r--r--test/pthread/ex6.c7
-rw-r--r--test/pthread/ex7.c7
-rw-r--r--test/pthread/tst-join2.c104
-rw-r--r--test/pthread/tst-join3.c123
-rw-r--r--test/pwd_grp/Makefile10
-rw-r--r--test/pwd_grp/Makefile.in8
-rw-r--r--test/pwd_grp/getgroups.c13
-rw-r--r--test/regex/Makefile17
-rw-r--r--test/regex/Makefile.in6
-rw-r--r--test/regex/testregex.c32
-rw-r--r--test/regex/testregexc.c1
-rw-r--r--test/regex/testregexf.c1
-rw-r--r--test/regex/testregexi.c1
-rw-r--r--test/regex/testregexl.c1
-rw-r--r--test/regex/testregexn.c1
-rw-r--r--test/regex/testregexp.c1
-rw-r--r--test/regex/testregexr.c1
-rw-r--r--test/regex/tst-regex2.c442
-rw-r--r--test/regex/tst-regex2.dat (renamed from test/regex/.regex.ChangeLog.14)0
-rw-r--r--test/regex/tst-regexloc.c20
-rw-r--r--test/rpc/Makefile12
-rw-r--r--test/rpc/Makefile.in11
-rw-r--r--test/rpc/getrpcent_r.c1
-rw-r--r--test/setjmp/Makefile4
-rw-r--r--test/setjmp/Makefile.in1
-rw-r--r--test/setjmp/bug269-setjmp.c5
-rw-r--r--test/setjmp/tst-setjmp.c5
-rw-r--r--test/signal/Makefile8
-rw-r--r--test/signal/Makefile.in10
-rw-r--r--test/signal/tst-raise.c5
-rw-r--r--test/signal/tst-signalfd.c63
-rw-r--r--test/signal/tst-sigsimple.c5
-rw-r--r--test/silly/Makefile7
-rw-r--r--test/silly/Makefile.in24
-rw-r--r--test/silly/hello.c2
-rw-r--r--test/silly/tst-atomic-long.c27
-rw-r--r--test/silly/tst-atomic.c573
-rw-r--r--test/stat/Makefile12
-rw-r--r--test/stat/Makefile.in13
-rw-r--r--test/stat/memcmp-stat.c2
-rw-r--r--test/stat/stat-loop256.c32
-rw-r--r--test/stdio/Makefile8
-rw-r--r--test/stdio/Makefile.in10
-rw-r--r--test/stdio/lseek_no_lfs.c22
-rw-r--r--test/stdio/scanf_m.c24
-rw-r--r--test/stdio/tst-fmemopen.c53
-rw-r--r--test/stdlib/Makefile9
-rw-r--r--test/stdlib/Makefile.in19
-rw-r--r--test/stdlib/qsort.c10
-rw-r--r--test/stdlib/test-canon.c8
-rw-r--r--test/stdlib/test-canon2.c86
-rw-r--r--test/stdlib/test-mkostemp-O_CLOEXEC.c45
-rw-r--r--test/stdlib/test-mkostemp-child.c22
-rw-r--r--test/stdlib/testarc4random.c10
-rw-r--r--test/stdlib/teststrtoq.c89
-rw-r--r--test/string/Makefile6
-rw-r--r--test/string/Makefile.in8
-rw-r--r--test/string/stratcliff.c5
-rw-r--r--test/string/test-ffs.c5
-rw-r--r--test/string/testcopy.c5
-rw-r--r--test/string/tester.c6
-rw-r--r--test/string/tst-bswap.c5
-rw-r--r--test/string/tst-inlcall.c5
-rw-r--r--test/termios/Makefile4
-rw-r--r--test/test-skeleton.c116
-rw-r--r--test/testsuite.h5
-rw-r--r--test/time/Makefile13
-rw-r--r--test/time/Makefile.in25
-rw-r--r--test/time/test_time.c5
-rw-r--r--test/time/tst-ctime.c44
-rw-r--r--test/time/tst-futimens1.c105
-rw-r--r--test/time/tst-strptime.c5
-rw-r--r--test/time/tst-timerfd.c71
-rw-r--r--test/time/tst-timezone.c5
-rw-r--r--test/time/tst_wcsftime.c70
-rw-r--r--test/tls/Makefile8
-rw-r--r--test/tls/Makefile.in150
-rw-r--r--test/tls/README8
-rw-r--r--test/tls/tls-macros-arm.h51
-rw-r--r--test/tls/tls-macros-mips.h64
-rw-r--r--test/tls/tls-macros-thumb.h57
-rw-r--r--test/tls/tls-macros.h1000
-rw-r--r--test/tls/tst-tls-at-ctor.c21
-rw-r--r--test/tls/tst-tls1-static.c1
-rw-r--r--test/tls/tst-tls1.c92
-rw-r--r--test/tls/tst-tls10.c40
-rw-r--r--test/tls/tst-tls10.h38
-rw-r--r--test/tls/tst-tls11.c27
-rw-r--r--test/tls/tst-tls12.c18
-rw-r--r--test/tls/tst-tls13.c30
-rw-r--r--test/tls/tst-tls14.c66
-rw-r--r--test/tls/tst-tls15.c33
-rw-r--r--test/tls/tst-tls16.c53
-rw-r--r--test/tls/tst-tls17.c29
-rw-r--r--test/tls/tst-tls18.c38
-rw-r--r--test/tls/tst-tls2-static.c1
-rw-r--r--test/tls/tst-tls2.c91
-rw-r--r--test/tls/tst-tls3.c76
-rw-r--r--test/tls/tst-tls4.c56
-rw-r--r--test/tls/tst-tls5.c72
-rw-r--r--test/tls/tst-tls6.c107
-rw-r--r--test/tls/tst-tls7.c78
-rw-r--r--test/tls/tst-tls8.c229
-rw-r--r--test/tls/tst-tls9-static.c1
-rw-r--r--test/tls/tst-tls9.c42
-rw-r--r--test/tls/tst-tlsmod-at-ctor.c25
-rw-r--r--test/tls/tst-tlsmod1.c68
-rw-r--r--test/tls/tst-tlsmod10.c1
-rw-r--r--test/tls/tst-tlsmod11.c6
-rw-r--r--test/tls/tst-tlsmod12.c14
-rw-r--r--test/tls/tst-tlsmod13.c14
-rw-r--r--test/tls/tst-tlsmod13a.c16
-rw-r--r--test/tls/tst-tlsmod14a.c41
-rw-r--r--test/tls/tst-tlsmod14b.c2
-rw-r--r--test/tls/tst-tlsmod15a.c6
-rw-r--r--test/tls/tst-tlsmod15b.c17
-rw-r--r--test/tls/tst-tlsmod16a.c7
-rw-r--r--test/tls/tst-tlsmod16b.c13
-rw-r--r--test/tls/tst-tlsmod17a.c23
-rw-r--r--test/tls/tst-tlsmod17b.c15
-rw-r--r--test/tls/tst-tlsmod18a.c21
-rw-r--r--test/tls/tst-tlsmod2.c38
-rw-r--r--test/tls/tst-tlsmod3.c41
-rw-r--r--test/tls/tst-tlsmod4.c38
-rw-r--r--test/tls/tst-tlsmod5.c7
-rw-r--r--test/tls/tst-tlsmod6.c7
-rw-r--r--test/tls/tst-tlsmod7.c103
-rw-r--r--test/tls/tst-tlsmod8.c72
-rw-r--r--test/tls/tst-tlsmod9.c101
-rw-r--r--test/uclibcng-testrunner.sh62
-rw-r--r--test/unistd/Makefile13
-rw-r--r--test/unistd/Makefile.in49
-rw-r--r--test/unistd/errno.c2
-rw-r--r--test/unistd/tst-fallocate.c166
-rw-r--r--test/unistd/tst-fallocate64.c2
-rwxr-xr-xtest/unistd/tst-getconf.sh240
-rw-r--r--test/unistd/tst-posix_fallocate.c127
-rw-r--r--test/unistd/tst-posix_fallocate64.c2
-rw-r--r--test/unistd/tst-preadwrite.c7
-rw-r--r--test/unistd/tst-preadwrite64.c5
-rw-r--r--test/unistd/tst-pselect.c51
-rw-r--r--test/unistd/tstgetopt.c6
-rw-r--r--utils/.gitignore12
-rw-r--r--utils/Makefile.in132
-rw-r--r--utils/bswap.h52
-rw-r--r--utils/chroot_realpath.c48
-rw-r--r--utils/getconf.c1335
-rw-r--r--utils/iconv.c271
-rw-r--r--utils/ldconfig.c130
-rw-r--r--utils/ldd.c206
-rw-r--r--utils/mmap-windows.c100
-rw-r--r--utils/porting.h97
-rw-r--r--utils/readelf.c363
-rw-r--r--utils/readsoname2.c14
4605 files changed, 246429 insertions, 69815 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000..3ded06ee8
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,37 @@
+#
+# Never ignore these
+#
+!.gitignore
+
+#
+# Generated files
+#
+*.os
+*.oS
+*.a
+*.i
+*.o
+*.depend
+lib/
+install_dir/
+.config*
+.*.dep
+/*.log
+cscope.*
+
+#
+# Debugging files
+#
+.gdb_history
+.gdbinit
+core
+*.c.[0-9][0-9][0-9]t.*
+
+#
+# Backups / patches
+#
+*~
+*.orig
+*.rej
+/*.patch
+/*.diff
diff --git a/Changelog b/Changelog
deleted file mode 100644
index 52fd3eda2..000000000
--- a/Changelog
+++ /dev/null
@@ -1,791 +0,0 @@
-0.9.27 12 January 2005
-
- This has been a long time in the making... Release highlights:
- o New stdio implementation
- o New optimized string functions
- o Major improvements to the shared lib loader
- o Shared libraries work properly on powerpc
- o Debugging works on mips
- o New architectures: frv, nios, nios2, bfin
- o Linux 2.6.x kernel support
- o Lots and lots of bug fixes
-
- This release is NOT binary compatible with uClibc 0.9.26 or any earlier
- release, so be prepared to recompile your software if you are still using
- an old version of uClibc.
-
- -Erik
-
-
-
-0.9.26 3 January 2004
-
- This simply adds a fix for a pthread bug that was noticed a few hours
- after the previous release. Otherwise identical to 0.9.25.
-
- This release remains binary compatible with uClibc 0.9.21-25 as long as
- you take care to avoid any configuraton changes that will break things.
- We _were_ planning to break binary compatibilty in this release, but
- decided to hold those changes so we could push out a bugfix release.
-
- We _will_ break binary compatibilty in the upcoming 0.9.27 release to
- implement a few things we have been postponing. That should hopefully be
- the last ABI change before we freeze the ABI for the upcoming 1.0.x
- stable uClibc series.
-
-Release highlights:
- o A trivial fix for a pthread bug
- o Nothing else
-
- -Erik
-
-
-
-0.9.25 3 January 2004
-
-See Changelog.full for the complete list of who did what.
-
-Note:
- This release remains binary compatible with uClibc 0.9.21-24 as long as
- you take care to avoid any configuraton changes that will break things.
- We _were_ planning to break binary compatibilty in this release, but
- decided to hold those changes so we could push out a bugfix release.
-
- We _will_ break binary compatibilty in the upcoming 0.9.26 release to
- implement a few things we have been postponing. That should hopefully be
- the last ABI change before we freeze the ABI for the upcoming 1.0.x
- stable uClibc series.
-
-Release highlights:
- o Fixed a ton of problems found using the LTP and NIST test suites.
- The few remaining test failures are obscure corner cases, such as
- a few functions that fail (correctly) with incorrect errno values.
- o Fixed a longstanding pthreads bug -- amoung other things, you no
- longer need to explicitly add -lpthread for perl to work.
- o Added some sh optimized string functions
- o Added sh64 shared library support
- o The default malloc implementation has been replaced, and will
- now actually free memory when told to do so.
- o Both popen() and exec*() now behave themselves per SuSv3
- o Better 2.6.x kernel header support
- o Added support for Position Independent Executables (PIE) on x86
- o Lots of other minor cleanups
-
- -Erik
-
-
-
-0.9.24 15 December 2003
-
-See Changelog.full for the complete list of who did what.
-
-Note:
- This release remains binary compatible with uClibc 0.9.21-23 as
- long as you take care to avoid any configuraton changes that will
- break things.
-
- We currently plan to break binary compatibilty in the upcoming 0.9.25 to
- implement a few things we have been postponing, which will hopefully be
- the last change....
-
-Release highlights:
- o Fixed several silly configuration problems
- o Added arm optimized string functions
- o Lots of minor cleanups
-
- -Erik
-
-
-
-
-
-0.9.23 13 November 2003
-
-See Changelog.full for the complete list of who did what.
-
-Note:
- This release is binary compatible with uClibc 0.9.21 and 0.9.22 as
- long as you take care to avoid any configuraton changes that will
- break things. Enabling or disabling things like soft-float,
- locale, wide wchar support, or changing cpu type are all good
- examples of things that will break binary compatibility.
-
-Release highlights:
- o Fixed several silly configuration problems that were
- present in the 0.9.22 release.
- o Fixed compilation problem with soft-float support on
- several architectures.
- o Lots of cleanup work on the powepc shared lib loader
- thanks to Joakim Tjernlund.
- o Updated the debian packaging for use in a standalone uClibc
- system, rather than being a subordinate library under a
- glibc based system.
-
- -Erik
-
-
-
-
-
-0.9.22 8 November 2003
-
-See Changelog.full for the complete list of who did what.
-
-Note:
- This release is binary compatible with the 0.9.21 release
- if you take care to avoid any configuraton changes that
- might break things for you (i.e. enabling or disabling things
- like soft-float, locale, wide wchar support, or changing cpu
- type are all good examples of binary incompatible config options).
-
-Release highlights:
- o Added e1, microblaze, and sh64 architectures.
- o Much improved soft-float support
- o Rewrote the passwd and group handing functions
- and implemented all SuSv3 required reentrant
- versions.
- o Reworked and updated the Config system. You now
- get to select your target architecture with the
- config system.
- o Fixed pthreads for mmuless m68k systems
- o Added some x86 optimized string functions.
- o Lots and lots of bugs fixed.
-
- -Erik
-
-
-
-
-
-0.9.21 9 September 2003
-
-See Changelog.full for the complete list of who did what.
-
-Note:
- This release is not binary compatible with earlier releases.
- Sorry about that. We have never promised to provide binary
- compatibility until we hit version 1.0, and even then, if
- you change your configuration.
-
-Release highlights:
- o uClibc now has full ANSI/ISO C99 locale support (except
- for wcsftime() and collating items in regex).
- o Added support for using pre-generated locale data, making
- it easy for mere mortals to use uClibc w/locale support.
- o Lots of new tuning options added to trade size
- for features, allowing for smaller static binaries.
- o The "dlopen()'ing libraries that depend on libraries"
- problem was fixed.
- o A new scanf implementation. Well tested, but
- brand new so watch for obscure bugs...
- o Reworked and updated the Config system, adding several
- nice new features which we now use.
- o Lots and lots of sundry bug fixes and cleanups.
-
- -Erik
-
-
-
-
-
-0.9.20 30 June 2003
-
-See Changelog.full for the complete list of who did what.
-
-Note:
- This release remains binary compatible with 0.9.18 and 0.9.19.
-
-
-Release highlights:
- o Some ldd, profiling, and gcc wrapper updates
- o Updated to support and compile with gcc 3.3
- o Several needed mips updates
- o Building under cygwin should now work...
- o Prevent non-PIC code getting into PIC libs
- o Added mmap64 support
- o mmu-less systems now get a 16k default thread stack size
- which is much more sane than the old 2 MB default...
- o Implemented syscall() for powerpc
- o Optionally struct tm extension support
- o Lots of other sundry little fixes and cleanups.
- o Prevent buffer overflows in the passwd and group functions.
-
- -Erik
-
-
-
-
-
-0.9.19 3 March 2003
-
-See Changelog.full for the complete list of who did what.
-
-Note:
- This release remains binary compatible with 0.9.18 (except
- for mips, but then mips was unusable in stock 0.9.18 anyways).
-
-
-Release highlights:
- Stefan Allius
- o Some Makefile and warning fixes
- David Airlie
- o Fixed gcc wrapper handling of ctor/dtor stuff when used in
- with and w/o the nostdinc and nostdlib options
- Erik Andersen
- o Fixed a number of system call kernel type/user type translation
- problems that scrambled a handful of system calls.
- o Fixup powerpc syscalls to eliminate warnings with gcc-3.2
- o Fixed several ioctl special cases for powerpc
- o Checked in forgotten mips kernel_types.h changes
- o Fixed mips shared library loader bug that caused segfaults
- o Major update to the pthreads library. Should improve performance.
- o Fixed uClibc's shared library loader so we can properly debug
- applications using pthreads (must use gdb 5.3 or newer which
- was compiled using uClibc).
- o Made uClibc's ldd act just the glibc provided one (i.e. relying
- on the shared lib loader to do the work) when it is possible to
- doi so, and only rummage about the ELF headers when we have no
- other choice (such as when using 'ldd' on cross compiled stuff).
- Miles Bader
- o header file updates for v850 architecture
- o Fixed v850 crt0.S __uClibc_main argument stack space
- Jeffrey Damick
- o Fixed res_init() so it properly reloads /etc/resolv.conf
- Vadim Lebedev
- o Fixed ARM setjmp when floating point was disabled
- David McCullough
- o Removed debug (-g) when building crti.o and crtn.o, as
- debug would mess up the build for SH4 and probably others.
- o Fixed SH setjmp when floating point was enabled
-
-
- -Erik
-
-
-
-
-
-0.9.18 12 February 2003
-
-See Changelog.full for the complete list of who did what.
-
-Note:
-
- Once again, this release is _NOT_ binary compatible with earlier
- releases. I _think this will be the last time (with the possible
- exception of some future changes to our locale support...)
-
-
-Release highlights:
- Stefan Allius
- o fixed a compile problem when large file support was disabled
- o fixed dlib_pic.o to compile with proper flags
- o fixed a shared lib loader compile warning
- o Made adding libgcc functions to uClibc optional
- Erik Andersen
- o Fixed scandir64 to not free the wrong pieces of memory
- which caused segfaults
- o Fixed mismatches between kernel and libc dirent structures
- o Fixed mismatches between the size of uClibc's struct dirent
- and struct dirent64 so that when _FILE_OFFSET_BITS=64 we
- do not lose part of the filename
- o Fixed getdents64.c so the build will not break when compiling
- vs a 2.0.x Linux kernel when UCLIBC_HAS_LFS is enabled
- o Create stub crti.o and crtn.o files when UCLIBC_CTOR_DTOR is disabled
- o Fixed licenses for a few files that erroneously were listed as GPL
- but were really LGPL after discussing with authors
- o sigaction for x86 had an extra and unwanted sigaction syscall
- o Fixed debugging of arm binaries by adding a .note.ABI-tag section
- Miles Bader
- o header file updates for v850 architecture
- o Fixed v850 clone syscall
- Christian Krause
- o Fixed pthread_cond_timedwait to properly uses rt singals
- when available
- Christophe Massiot
- o Added mips _flush_cache syscall
- David McCullough
- o Added m68k brk syscall
- Marshall M. Midden
- o Fixed pipe implementation for mips
-
-
- -Erik
-
-
-
-
-
-0.9.17 25 January 2003
-
-See Changelog.full for the complete list of who did what.
-
-Note:
-
- I have always reserved the right to make binary incompatible changes as
- needed prior to the "1.0" release. This release is a good example of
- that. A few bugs turned up that needed to be fixed and the only good way
- to fix them was to change some fundamental data structure sizes. So I did
- just that. As a result, this release is _NOT_ binary compatible with
- earlier releases -- you will need to recompile your applications.
-
-
-Release highlights:
- Stefan Allius
- o fixed a number of shared library loader bugs
- o setjmp, longjmp, clone, and vfork cleanups for the SH architecture
- o Don't build the config system with ncurses unless asked to
- Tobias Anderberg
- o cris architecture updates
- Erik Andersen
- o Changed 'struct stat' and 'struct stat64' so they use types that
- are consistant with use elsewhere in the library. Without this,
- subtle bugs would occur due to comparing signed and unsigned
- types (for example, GNU tar wouldn't work)
- o Fixed dlopen so it works with staticly linked apps
- o Fixed sigaction on arm architecture so sa_restorer works properly
- o Fixed sigaction on x86 architecture for (fixed debugging threads)
- o Fixed a wide char related segfault in the regular expression code
- o Powerpc pread and pwrite are now implemented correctly
- o Powerpc syscall mechanism re-implemented
- o Sparc architecture and syscall mechanism fixed up so things compile
- o usershell reimplemented
- o Fixed global destructors for staticly linked applications
- o Added dynamic atexit support (needed for full C++ ctor/dtor support)
- o The ldd utility now acts more like the GNU utility
- o Added a stub libnsl library to make stupid configure scripts bahave
- o Always build crt1.o as well as crt0.o to minimize the need to mess
- with the compiler
- o Rewrote powerpc crt0.S to properly handle ctors/dtors
- o Removed unimplemented and legacy stuff from our header files to
- make configure behave better
- o Made the lib loader also support libs in /usr/X11R6/lib by default
- o Config system updates
- o networking function updates
- o Large file support updates
- o Lots of other little bug fixes and cleanups
- Nick Fedchik
- o Support ether_aton
- Nathan Field
- o Fixed pthread_mutex_lock and pthread_mutex_unlock so they
- actually work as advertised on mips
- o Fixed several nasty pthread bugs fixing debugging
- Brett Hunt
- o Fixed potential segfaults during 'make menuconfig'
- Jay Kulpinski
- o Fixed a subtle problem in the DNS resolver that prevented
- uncompressed DNS lookup responses from working
- David McCullough
- o Fixed pclose error handling
- David Meggy
- o fixed the problem where arm binaries would crash on start
- that Erik stupidly caused right before the last release.
- Manuel Novoa III
- o Major locale support update!
- o Allow people to use pregenerated locale data instead of generating
- approx 40Mb of glibc locales to get the 300+ locales currently
- supported.
- o locale dependent collation support
- o Fixed locale support tools to work when cross-compiling
- o Added the *wprintf functions
- o Added the wcsto{inttype} functions
- o Added iconv() and a mini iconv utility
- o Added hsearch and hsearch_r
- o Fixed a silly bug allowing wprintf %s to work correctly.
- o Fixed fdopen when used with "a" (append).
- o Fixed stdio file position handing to be sure fell() always
- gives correct results
- Luc Van Oostenryck
- o Fixed a buffer overflow in getlogin_r
- Yoshinori Sato
- o Hitachi h8300 architecture update
- Ronald Wahl
- o Powerpc shared library relocation fixes
-
- -Erik
-
-
-
-0.9.16 8 November 2002
-
-See Changelog.full for the complete list of who did what.
-
-Release highlights:
- o CRIS architecture and shared library support from Tobias Anderberg
- o New uClibc configuration system
- o shared library global constructors and destructors initialization
- ordering fixed by Stefan Allius
- o More SuperH architecture fixes from Stefan Allius
- o uClibc now compiles with newer versions of gcc (i.e. RedHat 8.0)
- o uClibc no longer requires perl to compile
- o mips dlopen was fixed by Steven J. Hill
- o pty and tty handling fixes
- o Manuel Novoa added support for a new /etc/TZ file for globally
- setting the system timezone.
- o Manuel also fixed up a number of remaining wide char issues.
- o Lots of other little bug fixes and cleanups
-
- -Erik
-
-
-
-0.9.15 27 August 2002
-
-This is a minor bugfix release.
-
-See Changelog.full for the complete list of who did what.
-Release highlights:
- o Eliminated the HAS_LONG_LONG option. gcc always supports
- long long, and the option never excluded all long long anyways.
- o ctype.h no longer allows multiple argument evaluation in
- compliance with ANSI/ISO C99
- o Obscure printf fixes -- one involving %o and one involving %f.
- o Bugfixes for locking and reentrance in password/group functions
- o Directly use kernel types for most items, eliminating needless
- translation and fixing several bugs.
- o Directly use kernel struct stat -- no more translating
- o More superH (sh) architecture merging from Stefan Allius
- o Errno values and strerror are now correct on alpha, sparc, and mips
- o Fixed an obscure bug with fclose when custom streams are enabled.
- o Lots of other little bug fixes and cleanups
-
- -Erik
-
-
-
-0.9.14 12 August 2002
-
-This is a minor bugfix release.
-
-See Changelog.full for the complete list of who did what.
-Release highlights:
- o Fix a compile error when RPC and Pthread support
- were both enabled.
- o Eliminate duplicate define warnings in wstring.c.
- o Fix potentially broken preprocessor comparisons.
- o Erik was an idiot and broke thread locking in exit(),
- atexit() and friends. Fix that.
- o Fix the gcc wrapper to use crtbeginS.o and crtendS.o when
- compiling PIC code (crtbegin.o and crtend.o) otherwise.
-
- -Erik
-
-
-
-
-0.9.13 9 August 2002
-
-Security Fixes
- o There was an off-by-one buffer overflow in the group
- handling code, fix thanks to Joseph Chiu.
- o There was an integer overflow bug in calloc, per
- http://online.securityfocus.com/bid/5398
- o There was an integer overflow bug in the xdr_array
- RPC code, per http://online.securityfocus.com/bid/5356
-
-See Changelog.full for the complete list of who did what.
-Release highlights:
- o Add full shared library support for Hitachi SuperH (sh)
- thanks to Stefan Allius and Edie C. Dost
- o Lots of reentrance cleanups (we should now be fully
- reentrant when compiled with pthread support).
- o Miles Bader implemented a new mmap based malloc which is much
- smarter than the old "malloc-simple", and actually works, unlike
- the old "malloc". This is now the default for mmu-less systems
- and should greatly help reduce memory fragmentation and wastage.
- o Reworked syscall handling for i386 and ARM, smaller and cleaner.
- o Support for the syscall() function on i386 and ARM
- o The uClibc g++ wrapper now automagically adds the proper include
- search path and and libraries.
- o Lots of shared library loader updates
- o dlopen'd shred libraries not properly run destructors
- when ctor/dtor support is enabled
- o pread/pwrite/pread64/pwrite64 now all work as expected
- o Lots and lots of other bug fixes and cleanups.
-
- -Erik
-
-
-
-
-0.9.12 20 June 2002
-
-See Changelog.full for the complete list of who did what.
-Release highlights:
- o Add full shared library support for mips (big and little
- endian), thanks to a lot of hard work from Steven J. Hill
- o i960 architecture support, thanks to Martin Proulx
- o An initial alpha port (works, but needs some cleanup)
- o Fixes shared library support for powerpc
- o Fixes for mmu-less systems
- o Much improved thread locking and reentrance.
- o More gcc wrapper updates. XFree86 really does link
- this time around. It still didn't last time.
- o Libcrypt now passes conformance tests
- o Nearly complete locale supporti thanks to a lot
- of hard work by Manuel Novoa III. This stuff is
- _way_ smaller than glibc's
- o Completely new time handling functions also by Manuel
- o Lots of other bug fixes and cleanups.
-
- -Erik
-
-
-
-
-Erik Andersen:
-0.9.11 10 April 2002
-
-Release highlights:
- o Lots of bug fixes
- o Much better large file support
- o Several gcc wrapper bug fixes, so things like iproute2 and
- XFree86 should now link properly.
- o Fixes a stdio thread locking bug that could cause random
- deadlocks on s*printf calls when threading was enabled.
-
-Erik Andersen:
- o Added a generic implementation of truncate64.c and ftruncate64.c
- o Added missing creat64, glob64, mkstemp64, getrlimit64, setrlimit64
- o Removed internal erroneous use of __USE_FILE_OFFSET64
- o Made libpthread compile on sparc and powerpc
- o Made libpthread soname and symlinks match the other libraries.
- o Added finite() to the C89 math lib, since some math functions use it.
- o Added missing function pointer to error.c (some apps wanted it)
- o Fixed initfini build for arches where gcc tries to be sneaky
- o Fixed m68k/bits/setjmp.h which I has broken in the last release.
- o Fixed a buffer overflow in the dynamic library loader
- o Fixed a stdio thread locking bug that could cause random
- deadlocks on s*printf calls when threading was enabled.
- o Implemented sqrtf(), needed for libstdc++ on arm
-Miles Bader:
- o Make clean fixes to not blindly wipe all symlinks
- o Re-enabled clnt_perror()
- o Re-implemented swab()
-Dwayne Fontenot:
- o Many updates to the uClibc Working Application List
-Steven J. Hill:
- o Many updates to the mips dynamic loader. Not yet working but
- getting very close now.
- o Fixed locking bug in getttyent()
- o Support libpthread on mips
-Richard June:
- o Fixed several bugs in utmp code (pututline was only writing the
- first sizeof-a-pointer bytes to the utmpfile).
- o setutent() was only opening utmp readonly.
-m4@brecis.COM:
- o Fixed a silly typing problem with the getuid syscall.
-Manuel Novoa III:
- o Fixed stdio FILE read/write auto-transition bugs.
- o Better stdio errno handling
- o Changed setvbuf() to more closely match glibc's behavior
- o Fixed getpass() to not echo passwords to the console
- o Fixed locale ISblank flag.
- o Fixed an arg promotion handling bug in _do_one_spec for %c reported
- by Ilguiz Latypov.
-Kensuke Otake:
- o Implemented swab()
-Yoshinori Sato:
- o Fixed h8300 architecture support for pthreads and changes to
- the include files
-David Schleef:
- o Made powerpc assembly code PIC-compatible
- o Removed powerpc R_PPC_REL24 handling, since it was deceptively useless.
-John Traill:
- o Several types on powerpc, such as dev_t, are different than on other
- architectures. John spotted this, which fixed a _ton_ of problems since
- anything calling stat() was previously broken.
-Jim Treadway:
- o Eliminated use of alarm() from the DNS resolver by converting
- it to use select instead (much cleaner).
-
-
-
-
-
-
-
-
-0.9.10 21 March 2002
-
-Major new features:
- o pthreads support (derived from glibc 2.1.3's linuxthreads library)
- by Stefan Soucek and Erik Andersen
- o pthreads support for MMU-less systems, by Stefan Soucek
- o Complete rewrite of all stdio functions for standards compliance,
- small size, pthreads support, wide/narrow stream support, large
- file support, unbuffered support, etc, etc by Manuel Novoa III
- o gcc wrapper reworked by Erik Andersen. Now operated correctly in
- all known cases, and now wraps g++ as well for C++ support.
- o constructor/destructor support, for C++ by Erik Andersen.
- o Eliminated duplicate include/bits header files, by Erik Andersen.
- Now all common include/bits headers are grouped together.
-
-
-Erik Andersen:
- o Lots of changes and improvements to the shared library loader
- o Cleaned up a piles of bugs
- o Fixed a segfault when scandir was called on empty directories.
- o Several syscalls added: pread/pwrite
- o Makefile/build system cleanups
- o Sighandling fixes
- o pthreads support (with Stefan Soucek)
- o Added ldexp to the C89 math library, per POSIX
- o fclose() EINTR handling is now correct per IEEE Std 1003.1-2001
- o Support isblank()
- o Reworked libcrypt to avoid leaking private symbols into the namespace
- o Added strtof(), strtold(), updwtmp(), strptime()
- o Fix ldso build for older arm cross compilers
-Miles Bader:
- o atexit cleanups
- o fixed gcc wrapper handling of -M* options
- o Fixed truncate64/ftruncate64 to restrict them to 64-bit systems,
- since we can't be sure that the _syscall macros can cope with 64
- bit args on 32 bit arches.
- o Large File support on the v850
- o Fixed v850 headers after Erik messed them up
- o Eliminate include/features.h namespace pollution
-M. R. Brown:
- o Fixed pthread support for SH, and fixed SH vfork as well
- o Fixed SH headers after Erik messed them up
-Geoffrey Espin:
- o Mips architecture cleanups. Now works perfectly
- with busybox, vi, ash, etc...
- o Merged in the random number support (rand, srand, etc) from glibc.
-Thomas Fritzsche:
- o Fixes DNS resolver bug from 0.9.9
-Steven J. Hill:
- o Fixed build to support both mips and mipsel
- o Beginnings of a mips ldso port
-Andrew Ip:
- o Support for gnu error() functions
-David McCullough:
- o Coldfire platform updates: clone, setjmp
- o Fixed simple malloc to work on systems with an MMU
-Manuel Novoa III:
- o Rewrote all stdio functions for standards compliance, small size,
- pthreads support, wide/narrow stream support, large file support,
- unbuffered support, etc, etc, etc.
- o Rewrote the various string to int functions to be smaller, more
- standards compilant, and reduce dependance on libgcc.a.
-Yoshinori Sato:
- o ptrace for the Hitachi h8300 fix
-David Schleef:
- o Debian packaging updates
- o Check for proper 16-byte aliged stack pointer on powerpc
-Stefan Soucek:
- o pthreads support for MMU-less systems
- o pthreads support (with Erik Andersen)
-Brian Stafford:
- o Rewrote strcasecmp() per SUSv2.
-Bart Visscher:
- o Added missing IPV6 support and reentrant networking function
- additions so iptables now runs with IPV6 support.
-
-
-
-
-
-
-0.9.9 February 4, 2002
-
-Erik Andersen:
- o A bunch of doc updates. Major update to the working
- apps list.
- o Added a configurator script (extra/Configs/uClibc_config_fix.pl)
- which can simplify configuring uClibc.
- o Fixed setjmp/longjmp on x86,arm,powerpc,mips,and sparc.
- Hitting ^C in ash kills client apps now, not ash.
- o Reworked signal handling code so it now passes POSIX
- conformance tests.
- o Fixed sleep and usleep to work correctly when
- interrupted by signals.
- o Made getopt behave the same when staticly linking
- as when dynamicly linking. It was using different
- implementations depending on how apps were linked.
- o Added missing inttypes.h header file
- o Eliminate all C++ style comments from header files
- o Support statvfs and statfs
- o Support getmntent_r
- o Scandir and scandir64 were calling malloc without
- checking for ENOMEM
- o Fixed stpcpy function declaration
- o Many large file support improvements.
- o Fixed fcntl to work when DOLFS is enabled
- o Fixed termios code to do the Right Thing(tm)
- o Allow regex to be excluded at compile time
- o Implemented mempcpy
- o Build ldd and readelf for the target system and for the
- host system
- o Fix several cases where get-needed-libgcc-objects.sh
- could fail, breaking the shared uClibc library.
- o Include all shared library loader objects into a
- single C file, thereby reducing its size further.
- o Reworked the shared library linking process to be more
- flexible so that gcc and ld can more easily be built to
- target uClibc library.
- o Better error checking in the Makefiles. Be more pedantic
- about tar, chmod, etc to avoid system dependent failures.
- o We can now autodetect the target architecture
- o Hide references to wchar_t so GNU autoconf
- configure scripts won't get confused and try to
- enable wide char support.
- o Fixed stdio.h so apps can use varargs.h if they want to.
- o Added brk/sbrk support for ARM, powerpc, mips, and sparc
- and set them to default to the much faster brk using malloc
- o Added missing syscalls: get_kernel_syms, fcntl64,
- fdatasync, sched_setparam, sched_getparam,
- sched_setscheduler, sched_getscheduler,
- sched_get_priority_max, sched_get_priority_min,
- sched_rr_get_interval, sigaltstack, sendfile,
- pivot_root, sigsuspend, setfsuid, and setfsgid
- o Force DOPIC be true when HAVE_SHARED is true.
- o Fixed hstrerror()
- o Implemented gethostent(), sethostent(), and endhostent()
- o Added arch specific support so that sparc and mips actually
- compile and work
-Miles Bader:
- o Fixes for the v850 architecture: crt0, setjmp,
- arch autodetection, etc.
- o Fixed `make install' to not build ldso stuff on
- non-shared-library systems.
-Michael E Brown:
- o Allow the gcc wrapper to support setting DEVEL_PREFIX
- and BUILD_DIR at runtime (no more need to recompile).
-M. R. Brown and Erik Andersen:
- o Fixed the SH port so it now works. Tested and shown
- working on an SH4 Dreamcast system.
-Kim Heino:
- o Made 'make clean' remove generated bits/syscall.h
-David McCullough:
- o SH architecture updates. Added brk, sbrk,
- o Fixed simple malloc to work on systems with an MMU
- o Taught getutent to return NULL if utmp doesn't exist.
- o Added insque/remque support
- o Fixed DNS resolver version number so apps won't get
- confused and use the wrong API.
- o Added Config selectable shadow password support
-Yoshinori Sato
- o Contributed support for the Hitach H8/300H architecture
-Cédric Schieli:
- o Add support for inet_netof, inet_lnaof, inet_makeaddr
- and hstrerror.
-David Schleef:
- o Added libstrip, a nifty script to automagically
- strip unneeded content from the uClibc shared
- libraries.
-Martin Sieper
- o Added getw() and putw()
- o Added missing header files -- lastlog.h, sgtty.h,
- netipx/ipx.h, sys/perm.h
-Stefan Soucek:
- o Add rcmd support, i.e. rsh, rlogin, etc.
- o Fix rcmd to avoid alloca, which is dangerous
- on mmu-less systems
-spudmonkey@racsa.co.cr:
- o Eliminate a buffer overflow in the shared library loader
-Brian Stafford:
- o Enable support for Unix98 PTYs, and add option
- to disable old style PTYs.
-
-
diff --git a/DEDICATION.mjn3 b/DEDICATION.mjn3
deleted file mode 100644
index bc26bc845..000000000
--- a/DEDICATION.mjn3
+++ /dev/null
@@ -1,22 +0,0 @@
-
-All of my uClibc and busybox work is dedicated to Toni, my love who
-passed away on Feb. 12, 2003.
-
-I would ask that anyone benefiting from this work, especially those
-using it in commercial products, consider making a donation in her
-memory to our local non-profit hospice organization that did so much
-for us in her last few months.
-
- In memory of Toni W. Hagan
-
- Hospice of Acadiana, Inc.
- 2600 Johnston St., Suite 200
- Lafayette, LA 70503-3240
-
- Phone (337) 232-1234 or 1-800-738-2226
- Fax (337) 232-1297
-
- http://www.hospiceacadiana.com/
-
-
-Manuel Novoa III
diff --git a/INSTALL b/INSTALL
index 79cde848d..ae88aaf4b 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,21 +1,20 @@
SOFTWARE REQUIREMENTS
- Compiling uClibc requires Linux kernel header files. uClibc will
+ Compiling uClibc-ng requires Linux kernel header files. uClibc-ng will
be compiled to match the interfaces available in the provided
- version of the Linux kernel headers. Linux kernel version 2.0,
- version 2.2, version 2.4 and version 2.6 are known to work. Other
- kernel versions may work but haven't been tested. Its also helpful
- to have a working version of GNU binutils, and GNU gcc -- using
- excessively old versions of these packages can cause very strange
- errors that are difficult to find and fix.
+ version of the Linux kernel headers. Linux kernel version 3.x is
+ supported.
+ Its also helpful to have a working version of GNU binutils, and
+ GNU gcc -- using excessively old versions of these packages can
+ cause very strange errors that are difficult to find and fix.
-CONFIGURING uClibc:
+CONFIGURING uClibc-ng:
- - Users must have a valid configuration file to compile uClibc. Do not
+ - Users must have a valid configuration file to compile uClibc-ng. Do not
skip this step. New configuration options are added in each
release, and odd configuration options are sometimes removed.
- To configure uClibc, you can run:
+ To configure uClibc-ng, you can run:
make menuconfig
or
@@ -39,10 +38,10 @@ CONFIGURING uClibc:
"make allnoconfig" Set all values to "no" for all options.
-COMPILING uClibc:
+COMPILING uClibc-ng:
- - uClibc does not have proper dependancy checking (yet) so if you
- change your uClibc configuration, you must current rebuild the
+ - uClibc-ng does not have proper dependancy checking so if you
+ change your uClibc-ng configuration, you must current rebuild the
entire library, by first running
make clean
@@ -51,30 +50,32 @@ COMPILING uClibc:
make
- to compile uClibc. or if you are cross compiling, you would
+ to compile uClibc-ng. or if you are cross compiling, you would
instead run something like:
- make CROSS=arm-linux-
+ make CROSS_COMPILE=arm-linux-
-INSTALLING the uClibc development environment:
+INSTALLING the uClibc-ng development environment:
- As root, if necessary, run something like:
make PREFIX=<some path> install
- This will install the uClibc runtime and development system (i.e.
+ This will install the uClibc-ng runtime and development system (i.e.
all the header files, libraries, etc) into the directories defined
within your .config file.
-USING uClibc:
+USING uClibc-ng:
- - To compile programs with uClibc you will need a complete toolchain
- (i.e. binutils, gcc, and uClibc) that was built expressly for use
- with uClibc.
+ - To compile programs with uClibc-ng you will need a complete toolchain
+ (i.e. binutils, gcc and uClibc-ng) that was built expressly for use
+ with uClibc-ng.
- - Native and cross compiling toolchains, as well as makefiles for creating
- uClibc toolchains, are available from the uClibc website. You may want
- to check out "buildroot", which is available from the uClibc download area,
- which provides examples of how to build your own uClibc based system.
+ - You have following choices at the moment:
+ - Use OpenADK from http://www.openadk.org
+ - Use Buildroot from http://www.buildroot.org
+ - Use OpenWrt from http://www.openwrt.org
+ - Use Crosstool-NG from http://crosstool-ng.org
+ - Use your own build scripts or environment
diff --git a/MAINTAINERS b/MAINTAINERS
deleted file mode 100644
index 621c3b794..000000000
--- a/MAINTAINERS
+++ /dev/null
@@ -1,150 +0,0 @@
-Arch Maintainers List
-
-Note: For the hard of thinking, this list is meant to remain in alphabetical
-order. If you could add yourselves to it in alphabetical order that would be
-so much easier [Ed].
-
-P: Person
-E: Person's email address
-W: Web-page with status/info
-S: Status, one of the following:
-
- Supported: Someone is actually paid to look after this.
- Maintained: Someone actually looks after it.
- Patches: It has a maintainer but they don't have time to do
- much other than throw the odd patch in. See below ...
- Unmaintained: No current maintainer [but maybe you could take the
- role as you write your new code].
- Obsolete: Old code. Something tagged obsolete generally means
- it has been replaced by a better system and you
- should be using that.
-
-----------------------------------------------------------------------
-
-ALPHA
-S: Unmaintained
-
-
-ARM
-N: Erik Andersen
-E: andersen@codepoet.org
-W: http://www.arm.linux.org.uk/
-S: Maintained
-
-
-AVR32
-N: Hans-Christian Egtvedt
-E: hans-christian.egtvedt@atmel.com
-N: Haavard Skinnemoen
-E: haavard.skinnemoen@atmel.com
-W: http://avr32linux.org/
-S: Maintained
-
-
-BFIN
-N: Mike Frysinger
-E: vapier.adi@gmail.com
-W: http://blackfin.uclinux.org/
-S: Maintained
-
-
-CRIS
-P: Ricard Wanderlof
-M: ricard.wanderlof@axis.com
-W: http://developer.axis.com
-S: Maintained
-
-
-E1
-S: Unmaintained
-
-
-FRV
-S: Unmaintained
-
-
-H8300
-S: Unmaintained
-
-
-HPPA
-S: Unmaintained
-
-
-IA64
-S: Unmaintained
-
-
-I386
-N: Erik Andersen
-E: andersen@codepoet.org
-S: Maintained
-
-
-I960
-S: Unmaintained
-
-
-M68K
-S: Unmaintained
-
-
-MICROBLAZE
-S: Unmaintained
-
-
-MIPS
-N: Erik Andersen
-E: andersen@codepoet.org
-W: http://www.linux-mips.org
-S: Maintained
-
-
-NIOS and NIOS2
-S: Unmaintained
-
-
-POWERPC
-N: Joakim Tjernlund
-E: joakim.tjernlund@lumentis.se
-W: http://penguinppc.org/
-S: Maintained
-
-
-SH and SH64
-P: Paul Mundt
-E: lethal@linux-sh.org
-W: http://www.linux-sh.org
-S: Maintained
-
-
-SH4 (NPTL/TLS)
-P: Carmelo Amoroso
-E: carmelo.amoroso@st.com
-W: http://www.stlinux.com
-S: Supported
-
-
-SPARC
-S: Unmaintained
-
-VAX
-P: Jan-Benedict Glaw
-E: jbglaw@lug-owl.de (personal), linux-vax@pergamentum.com (mailing list)
-W: http://linux-vax.sourceforge.net/
-S: Maintained
-
-V850
-S: Unmaintained
-
-
-X86_64
-S: Unmaintained
-
-
-XTENSA
-P: Chris Zankel
-E: chris@zankel.net
-W: http://linux-xtensa.org/
-S: Maintained
-
diff --git a/Makefile b/Makefile
index 793ca7879..702430a6d 100644
--- a/Makefile
+++ b/Makefile
@@ -6,9 +6,14 @@
#
top_srcdir=./
-top_builddir=./
-#include $(top_builddir)Rules.mak
-#all: libs
-include Makefile.in
+top_builddir=$(if $(O),$(O),.)/
+export top_builddir
+
+# We do not need built-in implicit rules
+MAKEFLAGS += -r
+CONFIG_SHELL ?= /bin/sh
+export CONFIG_SHELL
+
+include $(top_srcdir)Makefile.in
include $(top_srcdir)Makerules
include $(top_srcdir)Makefile.help
diff --git a/Makefile.help b/Makefile.help
index 7ab771f4a..f6c762794 100644
--- a/Makefile.help
+++ b/Makefile.help
@@ -8,12 +8,16 @@
help:
@echo 'Cleaning:'
@echo ' clean - delete temporary object files'
- @echo ' realclean - delete temporary object file, including dependencies'
+ @echo ' realclean - delete temporary object files, including dependencies'
@echo ' distclean - delete all non-source files (including .config)'
@echo
@echo 'Build:'
@echo ' all - libraries and generated headers'
- @echo ' pregen - generated headers'
+ @echo ' pregen - generate headers'
+ @echo ' startfiles - build startfiles (crt)'
+ @echo ' utils - build target utilities'
+ @echo ' (ldd, ldconfig, locale, iconv)'
+ @echo ' hostutils - build host utilities (see utils)'
@echo
@echo 'Configuration:'
@echo ' allnoconfig - disable all symbols in .config'
@@ -23,16 +27,47 @@ help:
@echo ' menuconfig - interactive curses-based configurator'
@echo ' oldconfig - resolve any unresolved symbols in .config'
@echo ' silentoldconfig - resolve any unresolved symbols in .config, silently'
+ @echo ' savedefconfig - Save current config (minimal config)'
@echo ' randconfig - generate a random .config'
+ @$(if $(arch-defconfigs), \
+ @echo ''; \
+ echo 'Architecture specific configs ($(ARCH))'; \
+ $(foreach c, $(arch-defconfigs), \
+ printf " %-21s - Build for %s\\n" $(c) $(subst _defconfig,,$(c));) \
+ )
@echo
@echo 'Installation:'
@echo ' install - install both the runtime and the headers'
@echo ' install_runtime - install the libraries'
@echo ' install_dev - install all headers and static libs'
- @echo ' install_headers - install headers'
+ @echo ' install_startfiles - install startfiles (crt)'
+ @echo ' install_headers - install headers excluding generated ones'
+ @echo ' install_utils - install target utilities'
+ @echo ' install_hostutils - install host utilities'
@echo
@echo 'Development:'
@echo ' check - run testsuite'
@echo ' test_compile - compile testsuite binaries'
@echo ' release - create a distribution tarball'
@echo
+ @echo 'Environment variables:'
+ @echo ' O=<abspath> - Use <abspath> as object directory'
+ @echo ' V="" - Quiet build (default)'
+ @echo ' V=1 - Very verbose build (show full commands)'
+ @echo ' V=2 - Brief build (show defines, ld flags)'
+ @echo ' CROSS_COMPILE= - Override CROSS_COMPILER_PREFIX from .config'
+ @echo ' ARCH= - Use given arch for config targets'
+ @echo ' SHELL= - Shell to use for make'
+ @echo ' BUILD_CFLAGS= - extra CFLAGS for compiling host binaries'
+ @echo ' BUILD_LDFLAGS= - extra LDFLAGS for linking host binaries'
+ @echo ' CONFIG_SHELL= - Shell to use for menuconfig'
+ @echo
+ @echo ' PREFIX= - Prepended prefix'
+ @echo ' RUNTIME_PREFIX= - Prefix for the libdir containing shared objects'
+ @echo ' (usually "/")'
+ @echo ' DEVEL_PREFIX= - Prefix for the libdir containing static objects'
+ @echo ' and the include dir (usually "/usr")'
+ @echo ' MULTILIB_DIR= - Directory component for libraries (default "lib").'
+ @echo ' UCLIBC_EXTRA_CFLAGS - extra CFLAGS for compiling uClibc'
+ @echo ' UCLIBC_EXTRA_CPPFLAGS - extra CPPFLAGS for compiling uClibc'
+
diff --git a/Makefile.in b/Makefile.in
index d2590882f..f8f6a7f23 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,6 +1,6 @@
# Makefile for uClibc
#
-# Copyright (C) 2000-2005 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,23 +8,16 @@
#--------------------------------------------------------------
# You shouldn't need to mess with anything beyond this point...
#--------------------------------------------------------------
-clean_targets := clean realclean distclean \
- objclean-y headers_clean-y utils_clean
-noconfig_targets := menuconfig config oldconfig silentoldconfig randconfig \
- defconfig allyesconfig allnoconfig \
- release dist tags help
-
-include $(top_builddir)Rules.mak
+include $(top_srcdir)Rules.mak
sub_headers := headers
-#suspicious_dependency:=include/bits
-
ifeq ($(HAVE_DOT_CONFIG),y)
-all: pregen libs
+all: pregen libs startfiles
+libs: pregen
# In this section, we need .config
--include .config.cmd
+-include $(top_builddir).config.cmd
else # ifeq ($(HAVE_DOT_CONFIG),y)
@@ -36,6 +29,7 @@ headers:
endif # ifeq ($(HAVE_DOT_CONFIG),y)
+include $(top_srcdir)extra/locale/Makefile.in
include $(top_srcdir)ldso/Makefile.in
include $(top_srcdir)libcrypt/Makefile.in
include $(top_srcdir)libintl/Makefile.in
@@ -45,23 +39,39 @@ include $(top_srcdir)libresolv/Makefile.in
include $(top_srcdir)libutil/Makefile.in
include $(top_srcdir)libpthread/Makefile.in
include $(top_srcdir)librt/Makefile.in
-include $(top_srcdir)extra/locale/Makefile.in
+include $(top_srcdir)libuargp/Makefile.in
+include $(top_srcdir)libubacktrace/Makefile.in
# last included to catch all the objects added by others (locales/threads)
include $(top_srcdir)libc/Makefile.in
+conf := $(top_builddir)extra/config/conf
+mconf := $(top_builddir)extra/config/mconf
+nconf := $(top_builddir)extra/config/nconf
+
ifeq ($(HAVE_DOT_CONFIG),y)
# If the .config changes then we have to make sure that our includes are
# updated properly. This would normally work by saying that the headers
# have uClibc_config.h as prerequisite but since we _symlink_ the headers
# and do not (?) want to rely on 'make -L' we better update them right here,
# on spot to save us from alot of hazzle.
-include/bits/uClibc_config.h: extra/config/conf .config $(top_srcdir)extra/scripts/conf-header.sh | include/bits
+$(top_builddir)include/bits/uClibc_config.h: $(conf) $(KCONFIG_CONFIG) $(top_srcdir)extra/scripts/conf-header.sh | $(top_builddir)include/bits
@$(disp_gen)
- @#superfluous: $(Q)$(INSTALL) -d $(dir $@)
- $(Q)@$< -s $(top_srcdir)extra/Configs/Config.in
- $(Q)$(top_srcdir)extra/scripts/conf-header.sh .config > $@
+ $(Q)$< -s $(Kconfig)
+ $(Q)$(top_srcdir)extra/scripts/conf-header.sh $(KCONFIG_CONFIG) > $@.tmp
$(Q)$(MAKE) headers-y
+ $(Q)mv $@.tmp $@
+
+# The above doesn't work for threads, though. Just using check-symlinks for now.
+# XXX: FIXME: this is ugly
+MAKEFLAGS += -L
+
+$(top_builddir)include/config/linuxthreads/old.h $(top_builddir)include/config/linuxthreads/new.h:
+ @true
+
+$(top_builddir)include/generated/unifdef_config.h: $(top_builddir)include/bits/uClibc_config.h | $(top_builddir)include/generated
+ @$(disp_gen)
+ $(Q)$(SED) -e '1,3d' $^ > $@
# For the moment, we have to keep re-running this target
# because the fix includes scripts rely on pre-processers
@@ -74,28 +84,42 @@ else
export header_extra_args = -n
endif
HEADERS_BITS_COMMON := $(notdir $(wildcard $(top_srcdir)libc/sysdeps/linux/common/bits/*.h))
+ifneq ($(ARCH_HAS_DEPRECATED_SYSCALLS),y)
+HEADERS_BITS_COMMON_NO_LEGACY := $(notdir $(wildcard $(top_srcdir)libc/sysdeps/linux/common-generic/bits/*.h))
+HEADERS_BITS_COMMON := $(filter-out $(HEADERS_BITS_COMMON_NO_LEGACY),$(HEADERS_BITS_COMMON))
+ALL_HEADERS_BITS_COMMON_NO_LEGACY := $(addprefix $(top_builddir)include/bits/,$(HEADERS_BITS_COMMON_NO_LEGACY))
+endif
+
HEADERS_BITS_ARCH := $(notdir $(wildcard $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/bits/*.h))
HEADERS_BITS_SUBARCH :=
ifneq ($(TARGET_SUBARCH),)
HEADERS_BITS_SUBARCH := $(notdir $(wildcard $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/bits/$(TARGET_SUBARCH)/*.h))
endif
+ifneq ($(HEADERS_BITS_PTHREAD),)
+HEADERS_BITS_ARCH := $(filter-out $(HEADERS_BITS_PTHREAD),$(HEADERS_BITS_ARCH))
+HEADERS_BITS_SUBARCH:= $(filter-out $(HEADERS_BITS_PTHREAD),$(HEADERS_BITS_SUBARCH))
+endif
HEADERS_BITS_COMMON := $(filter-out $(HEADERS_BITS_ARCH) $(HEADERS_BITS_SUBARCH) $(HEADERS_BITS_PTHREAD),$(HEADERS_BITS_COMMON))
HEADERS_SYS_COMMON := $(notdir $(wildcard $(top_srcdir)libc/sysdeps/linux/common/sys/*.h))
HEADERS_SYS_ARCH := $(notdir $(wildcard $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/sys/*.h))
HEADERS_SYS_COMMON := $(filter-out $(HEADERS_SYS_ARCH),$(HEADERS_SYS_COMMON))
-ALL_HEADERS_COMMON := include/fpu_control.h include/dl-osinfo.h \
- include/hp-timing.h
-ALL_HEADERS_BITS_COMMON := $(addprefix include/bits/,$(HEADERS_BITS_COMMON))
-ALL_HEADERS_BITS_ARCH := $(addprefix include/bits/,$(HEADERS_BITS_ARCH))
+ALL_HEADERS_COMMON := $(top_builddir)include/fpu_control.h \
+ $(top_builddir)include/jmpbuf-offsets.h \
+ $(top_builddir)include/jmpbuf-unwind.h \
+ $(top_builddir)include/dl-osinfo.h \
+ $(top_builddir)include/hp-timing.h \
+ $(top_builddir)include/not-cancel.h
+ALL_HEADERS_BITS_COMMON := $(addprefix $(top_builddir)include/bits/,$(HEADERS_BITS_COMMON))
+ALL_HEADERS_BITS_ARCH := $(addprefix $(top_builddir)include/bits/,$(HEADERS_BITS_ARCH))
ifneq ($(TARGET_SUBARCH),)
-ALL_HEADERS_BITS_SUBARCH := $(addprefix include/bits/,$(HEADERS_BITS_SUBARCH))
+ALL_HEADERS_BITS_SUBARCH := $(addprefix $(top_builddir)include/bits/,$(HEADERS_BITS_SUBARCH))
else
ALL_HEADERS_BITS_SUBARCH :=
endif
-ALL_HEADERS_SYS_COMMON := $(addprefix include/sys/,$(HEADERS_SYS_COMMON))
-ALL_HEADERS_SYS_ARCH := $(addprefix include/sys/,$(HEADERS_SYS_ARCH))
+ALL_HEADERS_SYS_COMMON := $(addprefix $(top_builddir)include/sys/,$(HEADERS_SYS_COMMON))
+ALL_HEADERS_SYS_ARCH := $(addprefix $(top_builddir)include/sys/,$(HEADERS_SYS_ARCH))
target-headers-sysdep := \
$(ALL_HEADERS_COMMON) \
@@ -103,403 +127,435 @@ target-headers-sysdep := \
$(ALL_HEADERS_BITS_ARCH) \
$(ALL_HEADERS_BITS_SUBARCH) \
$(ALL_HEADERS_SYS_COMMON) \
- $(ALL_HEADERS_SYS_ARCH)
+ $(ALL_HEADERS_SYS_ARCH) \
+ $(ALL_HEADERS_BITS_PTHREAD)
-include/fpu_control.h:
+ifneq ($(ARCH_HAS_DEPRECATED_SYSCALLS),y)
+ target-headers-sysdep += $(ALL_HEADERS_BITS_COMMON_NO_LEGACY)
+endif
+
+$(top_builddir)include/fpu_control.h $(top_builddir)include/jmpbuf-offsets.h $(top_builddir)include/jmpbuf-unwind.h:
@$(disp_ln)
- $(Q)[ -r libc/sysdeps/linux/$(TARGET_ARCH)/$(@F) ] && \
- $(LN) -fs ../libc/sysdeps/linux/$(TARGET_ARCH)/$(@F) $@ || \
- $(LN) -fs ../libc/sysdeps/linux/common/$(@F) $@
+ $(Q)[ -r $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/$(@F) ] && \
+ $(LN) -fs $(call rel_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/$(@F) $@ || \
+ $(LN) -fs $(call rel_srcdir)libc/sysdeps/linux/common/$(@F) $@
-include/dl-osinfo.h include/hp-timing.h:
- $(do_ln) ../libc/sysdeps/linux/common/$(@F) $@
+$(top_builddir)include/dl-osinfo.h $(top_builddir)include/hp-timing.h $(top_builddir)include/not-cancel.h:
+ $(do_ln) $(call rel_srcdir)libc/sysdeps/linux/common/$(@F) $@
$(ALL_HEADERS_BITS_COMMON):
- $(do_ln) ../../libc/sysdeps/linux/common/bits/$(@F) $@
+ $(do_ln) $(call rel_srcdir)libc/sysdeps/linux/common/bits/$(@F) $@
$(ALL_HEADERS_BITS_ARCH):
- $(do_ln) ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits/$(@F) $@
+ $(do_ln) $(call rel_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/bits/$(@F) $@
+
+ifneq ($(ARCH_HAS_DEPRECATED_SYSCALLS),y)
+$(ALL_HEADERS_BITS_COMMON_NO_LEGACY):
+ $(do_ln) $(call rel_srcdir)libc/sysdeps/linux/common-generic/bits/$(@F) $@
+endif
ifneq ($(TARGET_SUBARCH),)
$(ALL_HEADERS_BITS_SUBARCH):
- $(do_ln) ../../../libc/sysdeps/linux/$(TARGET_ARCH)/bits/$(TARGET_SUBARCH)/$(@F) $@
+ $(do_ln) $(call rel_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/bits/$(TARGET_SUBARCH)/$(@F) $@
endif
ifneq ($(strip $(ALL_HEADERS_SYS_COMMON)),)
$(ALL_HEADERS_SYS_COMMON):
- $(do_ln) ../../libc/sysdeps/linux/common/sys/$(@F) $@
+ $(do_ln) $(call rel_srcdir)libc/sysdeps/linux/common/sys/$(@F) $@
endif
ifneq ($(strip $(ALL_HEADERS_SYS_ARCH)),)
$(ALL_HEADERS_SYS_ARCH):
- $(do_ln) ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys/$(@F) $@
+ $(do_ln) $(call rel_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/sys/$(@F) $@
endif
-$(target-headers-sysdep): | include/bits
+$(target-headers-sysdep) $(pregen-headers-y): | $(top_builddir)include/bits $(top_builddir)include/sys $(top_builddir)include/bits/sysnum.h
-sysdep_common_headers-clean:
- $(RM) $(ALL_HEADERS_COMMON)
-headers_clean-y += sysdep_common_headers-clean
+HEADERCLEAN_common:
+ $(do_rm) $(ALL_HEADERS_COMMON)
+headers_clean-y += HEADERCLEAN_common
+HEADERCLEAN_config:
+ $(do_rm) -r $(addprefix $(top_builddir)include/,config generated)
+menuconfig-clean-y: HEADERCLEAN_config
# The headers. Arch specific headers are specified via ARCH_HEADERS in
# libc/sysdeps/linux/$(TARGET_ARCH)/Makefile.arch which appends those via
# libc/sysdeps/linux/Makefile.commonarch to headers-y
headers-y += $(target-headers-sysdep)
-headers: include/bits/uClibc_config.h
-
-pregen: include/bits/sysnum.h headers
+headers: $(top_builddir)include/bits/uClibc_config.h | subdirs
$(Q)$(if $(UCLIBC_HAS_LOCALE),$(MAKE) -C extra/locale locale_headers)
-include/bits/sysnum.h: $(top_srcdir)extra/scripts/gen_bits_syscall_h.sh
- $(Q)$(INSTALL) -d $(@D)
+subdirs: $(addprefix $(top_builddir),$(subdirs))
+
+$(pregen-headers-y): $(headers_dep)
+pregen: headers $(pregen-headers-y) $(headers_dep)
+
+$(top_builddir)include/bits/sysnum.h: $(top_srcdir)extra/scripts/gen_bits_syscall_h.sh | $(top_builddir)include/bits
@$(disp_gen)
$(Q)set -e; \
- cd $(top_builddir); \
- tmp=`mktemp include/bits/sysnum.h.XXXXXX 2>/dev/null`; \
- [ -z "$$tmp" ] && tmp='include/bits/sysnum.h.new'; \
- KERNEL_HEADERS="${KERNEL_HEADERS}" top_builddir=. CC="$(CC) $(CPU_CFLAGS)" $(SHELL) extra/scripts/gen_bits_syscall_h.sh > $$tmp; \
- if cmp include/bits/sysnum.h $$tmp >/dev/null 2>&1; then \
- $(RM) $$tmp; \
- else \
- mv -f $$tmp include/bits/sysnum.h; \
+ KERNEL_HEADERS="${KERNEL_HEADERS}" CC="$(CC) $(CPU_CFLAGS)" $(SHELL) $< > $@.new; \
+ cmp -s $@ $@.new && $(RM) $@.new || mv -f $@.new $@
+ @# Ugly linux specific hack..
+ $(Q)if grep -q __NR_ $@; then true; else \
+ rm -f $@; \
+ echo "ERROR: Could not generate syscalls."; \
+ echo "Make sure that you have properly installed kernel headers."; \
+ echo "Your .config KERNEL_HEADERS=\"\" was set to:"; \
+ echo "${KERNEL_HEADERS}"; \
+ exit 1; \
fi
+.PHONY: $(LOCAL_INSTALL_PATH)
$(LOCAL_INSTALL_PATH):
- $(Q)$(MAKE) PREFIX=$(shell pwd)/ RUNTIME_PREFIX=./ \
- DEVEL_PREFIX=$(LOCAL_INSTALL_PATH)/usr/ \
- HOSTCC="$(HOSTCC)" \
- install_kernel_headers
- $(Q)$(MAKE) PREFIX=$(shell pwd)/ RUNTIME_PREFIX=./ \
- DEVEL_PREFIX=$(LOCAL_INSTALL_PATH)/usr/ \
+ $(Q)$(MAKE) PREFIX=$(LOCAL_INSTALL_PATH) \
+ RUNTIME_PREFIX=/ \
+ DEVEL_PREFIX=/usr/ \
HOSTCC="$(HOSTCC)" \
- install_dev
+ install
install: install_runtime install_dev
-RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB=$(shell $(top_srcdir)extra/scripts/relative_path.sh $(DEVEL_PREFIX)lib $(RUNTIME_PREFIX)lib)
+RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB=$(shell $(top_srcdir)extra/scripts/relative_path.sh $(DEVEL_PREFIX)$(MULTILIB_DIR) $(RUNTIME_PREFIX)$(MULTILIB_DIR))
+$(top_builddir)extra/scripts/unifdef: |$(top_builddir)extra/scripts
$(top_builddir)extra/scripts/unifdef: $(top_srcdir)extra/scripts/unifdef.c
$(hcompile.u)
-# Installs kernel header files (linux/*, asm/*, asm-generic/*).
-install_kernel_headers: headers
- top_builddir=$(top_builddir) \
- $(top_srcdir)extra/scripts/install_kernel_headers.sh include $(PREFIX)$(DEVEL_PREFIX)include
-
# Installs header files.
-install_headers: headers $(top_builddir)extra/scripts/unifdef
- $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)include
- top_builddir=$(top_builddir) \
- $(top_srcdir)extra/scripts/install_headers.sh include $(PREFIX)$(DEVEL_PREFIX)include
- printf '#ifndef _LIBC_INTERNAL_H\n#define _LIBC_INTERNAL_H 1\n#endif\n' > \
- $(PREFIX)$(DEVEL_PREFIX)include/libc-internal.h
- echo '/* Dont use _syscall#() macros; use the syscall() function */' > \
- $(PREFIX)$(DEVEL_PREFIX)include/bits/syscalls.h
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/dl-osinfo.h
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/_lfs_64.h
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/uClibc_uintmaxtostr.h
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/kernel_sigaction.h
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/kernel_stat.h
-ifneq ($(UCLIBC_HAS_FLOATS),y)
- # Remove floating point related headers since float support is disabled.
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/complex.h
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/fpu_control.h
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ieee754.h
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/math.h
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/tgmath.h
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/uClibc_fpmax.h
-endif
-ifneq ($(UCLIBC_HAS_FENV),y)
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/fenv.h \
- $(PREFIX)$(DEVEL_PREFIX)include/bits/fenv.h \
- $(PREFIX)$(DEVEL_PREFIX)include/bits/fenvinline.h
-endif
-ifneq ($(UCLIBC_HAS_WCHAR),y)
- # Remove wide char headers since wide char support is disabled.
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wctype.h
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wchar.h
-endif
-ifneq ($(UCLIBC_HAS_LOCALE),y)
- # Remove iconv header since locale support is disabled.
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/iconv.h
-endif
-ifneq ($(UCLIBC_HAS_GLIBC_CUSTOM_PRINTF),y)
- # Remove printf header since custom print specifier support is disabled.
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/printf.h
-endif
-ifneq ($(UCLIBC_HAS_XLOCALE),y)
- # Remove xlocale header since extended locale support is disabled.
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/xlocale.h
-endif
-ifneq ($(UCLIBC_HAS_GETTEXT_AWARENESS),y)
- # Remove libintl header since gettext support is disabled.
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/libintl.h
-endif
-ifneq ($(UCLIBC_HAS_REGEX),y)
- # Remove regex headers since regex support is disabled.
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/regex.h
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/regexp.h
-endif
-ifneq ($(UCLIBC_HAS_WORDEXP),y)
- # Remove wordexp header since wordexp support is disabled.
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wordexp.h
-endif
-ifneq ($(UCLIBC_HAS_FTW),y)
- # Remove ftw header since ftw support is disabled.
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ftw.h
-endif
-ifneq ($(UCLIBC_HAS_GLOB),y)
- # Remove glob header since glob support is disabled.
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/glob.h
-endif
-ifneq ($(UCLIBC_HAS_GNU_GETOPT),y)
-ifneq ($(UCLIBC_HAS_GETOPT_LONG),y)
- # Remove getopt header since gnu getopt support is disabled.
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/getopt.h
-endif
-endif
-ifneq ($(UCLIBC_HAS_SHADOW),y)
- # Remove shadow header since shadow password support is disabled.
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/shadow.h
-endif
-ifneq ($(PTHREADS_DEBUG_SUPPORT),y)
- # Remove thread_db header since thread debug support is disabled.
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/thread_db.h
-endif
-ifneq ($(UCLIBC_HAS_THREADS),y)
- # Remove pthread headers since thread support is disabled.
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/*thread*.h
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/semaphore.h
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/*thread*.h
-endif
-ifneq ($(HAVE_SHARED),y)
- # Remove dlfcn header if we don't have shared libraries.
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/dlfcn.h
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/dlfcn.h
-endif
-ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
- # Remove this as it is only used internally.
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/tls.h
-endif
-ifneq ($(UCLIBC_HAS_GNU_ERROR),y)
- # Remove error.h upon request
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/error.h
-endif
-ifneq ($(UCLIBC_HAS_BSD_ERR),y)
- # Remove err.h upon request
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/err.h
-endif
-ifneq ($(UCLIBC_SUSV3_LEGACY),y)
- # Remove timeb.h since the LEGACY ftime() was disabled upon request
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sys/timeb.h
-endif
-ifneq ($(UCLIBC_HAS_EPOLL),y)
- # Remove epoll.h since epoll_*() were disabled upon request
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sys/epoll.h
-endif
-ifneq ($(UCLIBC_HAS_XATTR),y)
- # Remove xattr.h since extended attributes were disabled upon request
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sys/xattr.h
-endif
-ifneq ($(UCLIBC_HAS_PTY),y)
- # Remove pty.h since PTY support was disabled upon request
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/pty.h
-endif
-ifneq ($(UCLIBC_LINUX_SPECIFIC),y)
- # Remove linux-specific headers as requested
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sys/inotify.h
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sys/perm.h
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sys/personality.h
-endif
-ifneq ($(UCLIBC_SV4_DEPRECATED),y)
- # Remove ustat.h since deprecated SV4 support was disabled upon request
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ustat.h
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sys/ustat.h
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/ustat.h
-endif
-ifeq ($(UCLIBC_HAS_REALTIME)$(UCLIBC_HAS_ADVANCED_REALTIME),)
- # Remove SUSv-realtime related message-queue headers upon request
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/mqueue.h
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sys/mqueue.h
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/mqueue.h
-endif
-ifneq ($(UCLIBC_HAS_REALTIME),y)
- # Remove SUSv-realtime related headers upon request
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sched.h
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sys/sched.h
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/sched.h
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/semaphore.h
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sys/semaphore.h
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/semaphore.h
-endif
-ifneq ($(UCLIBC_HAS_SOCKET),y)
- # Remove socket related headers upon request
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sys/socket.h
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/bits/socket.h
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/sys/socketvar.h
-endif
-ifneq ($(UCLIBC_HAS_CRYPT),y)
- # Remove crypt.h since libcrypt was disabled upon request
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/crypt.h
-endif
-ifneq ($(UCLIBC_SUPPORT_AI_ADDRCONFIG),y)
- # Remove ifaddrs.h since the corresponding functionality is disabled
- $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ifaddrs.h
+# a "y" here means the feature is enabled and so we should *not* rm it.
+# if the option expands to nothing though, we can punt the headers.
+HEADERS_RM- := \
+ config \
+ generated \
+ internal \
+ cancel.h \
+ dl-osinfo.h \
+ jmpbuf-offsets.h \
+ jmpbuf-unwind.h \
+ hp-timing.h \
+ not-cancel.h \
+ _lfs_64.h \
+ bits/uClibc_arch_features.h \
+ bits/kernel_sigaction.h \
+ bits/kernel_stat.h \
+ bits/kernel_types.h \
+ bits/libc-lock.h \
+ bits/stdio-lock.h \
+ bits/syscalls.h \
+ bits/syscalls-common.h \
+ bits/uClibc_fpmax.h \
+ bits/uClibc_mutex.h \
+ bits/uClibc_pthread.h \
+ bits/uClibc_uintmaxtostr.h \
+ bits/uClibc_uwchar.h \
+ bits/uClibc_va_copy.h \
+ bits/sigcontextinfo.h \
+ bits/stackinfo.h \
+ atomic.h \
+ bits/atomic.h \
+ tls.h \
+ rpc/des_crypt.h \
+ rpc/key_prot.h \
+ rpc/rpc_des.h
+ifeq ($(UCLIBC_STRICT_HEADERS),y)
+HEADERS_RM- += sgtty.h
+endif
+HEADERS_RM-$(HAVE_SHARED) += dlfcn.h bits/dlfcn.h
+HEADERS_RM-$(PTHREADS_DEBUG_SUPPORT) += thread_db.h
+HEADERS_RM-$(UCLIBC_HAS_ARGP) += argp.h
+HEADERS_RM-$(UCLIBC_HAS_BSD_ERR) += err.h
+HEADERS_RM-$(UCLIBC_HAS_CRYPT) += crypt.h
+HEADERS_RM-$(UCLIBC_HAS_EPOLL) += sys/epoll.h
+HEADERS_RM-$(UCLIBC_HAS_FENV) += fenv.h bits/fenv.h bits/fenvinline.h
+HEADERS_RM-$(UCLIBC_HAS_FLOATS) += complex.h fpu_control.h ieee754.h \
+ math.h \
+ tgmath.h \
+ bits/math*.h
+HEADERS_RM-$(findstring y,$(UCLIBC_HAS_FTW)$(UCLIBC_HAS_NFTW)) += ftw.h
+HEADERS_RM-$(UCLIBC_HAS_FTS) += fts.h
+HEADERS_RM-$(UCLIBC_HAS_GETTEXT_AWARENESS) += libintl.h
+HEADERS_RM-$(UCLIBC_HAS_GLIBC_CUSTOM_PRINTF) += printf.h
+HEADERS_RM-$(UCLIBC_HAS_GLOB) += glob.h
+HEADERS_RM-$(UCLIBC_HAS_GNU_ERROR) += error.h
+HEADERS_RM-$(UCLIBC_HAS_GETOPT_LONG) += getopt.h
+HEADERS_RM-$(UCLIBC_HAS_IPV6) += netinet/ip6.h netinet/icmp6.h
+HEADERS_RM-$(UCLIBC_HAS_BACKTRACE) += execinfo.h
+HEADERS_RM-$(UCLIBC_HAS_LOCALE) += iconv.h bits/uClibc_ctype.h
+HEADERS_RM-$(UCLIBC_HAS_PTY) += pty.h
+HEADERS_RM-$(UCLIBC_HAS_REALTIME) += mqueue.h bits/mqueue.h sched.h \
+ bits/sched.h \
+ semaphore.h
+HEADERS_RM-$(UCLIBC_HAS_REGEX) += regex.h regexp.h
+HEADERS_RM-$(UCLIBC_HAS_RPC) += rpc
+HEADERS_RM-$(UCLIBC_HAS_SHADOW) += shadow.h
+HEADERS_RM-$(UCLIBC_HAS_SOCKET) += sys/socket.h bits/socket.h sys/socketvar.h bits/socket_type.h
+HEADERS_RM-$(UCLIBC_HAS_SYSLOG) += syslog.h sys/syslog.h bits/syslog*.h
+HEADERS_RM-$(UCLIBC_HAS_THREADS) += *thread*.h semaphore.h \
+ bits/*thread*.h \
+ bits/initspin.h
+HEADERS_RM-$(UCLIBC_HAS_THREADS_NATIVE) += atomic.h bits/atomic.h
+HEADERS_RM-$(UCLIBC_HAS_OBSTACK) += obstack.h
+HEADERS_RM-$(UCLIBC_HAS_UTMP) += bits/utmp.h utmp.h
+HEADERS_RM-$(UCLIBC_HAS_UTMPX) += bits/utmpx.h utmpx.h
+HEADERS_RM-$(UCLIBC_HAS_WCHAR) += wchar.h wctype.h
+HEADERS_RM-$(UCLIBC_HAS_WORDEXP) += wordexp.h
+HEADERS_RM-$(UCLIBC_HAS_XATTR) += sys/xattr.h
+HEADERS_RM-$(UCLIBC_HAS_XLOCALE) += xlocale.h
+HEADERS_RM-$(UCLIBC_LINUX_SPECIFIC) += \
+ sys/cachectl.h \
+ bits/eventfd.h \
+ sys/eventfd.h \
+ sys/fsuid.h \
+ bits/inotify.h \
+ sys/inotify.h \
+ sys/kdaemon.h \
+ sys/perm.h \
+ sys/personality.h \
+ sys/prctl.h \
+ sys/random.h \
+ sys/reboot.h \
+ sys/sendfile.h \
+ bits/signalfd.h \
+ sys/signalfd.h \
+ bits/statfs.h \
+ sys/statfs.h \
+ sys/swap.h \
+ sys/sysctl.h \
+ sys/sysinfo.h \
+ bits/timerfd.h \
+ sys/timerfd.h \
+ sys/sysmips.h \
+ sys/vfs.h
+HEADERS_RM-$(UCLIBC_SUPPORT_AI_ADDRCONFIG) += ifaddrs.h
+HEADERS_RM-$(UCLIBC_SV4_DEPRECATED) += ustat.h sys/ustat.h bits/ustat.h
+HEADERS_RM-$(UCLIBC_SUSV3_LEGACY) += sys/timeb.h regexp.h
+HEADERS_RM-$(UCLIBC_SUSV4_LEGACY) += utime.h ucontext.h
+HEADERS_RM-$(UCLIBC_HAS_ADVANCED_REALTIME) += spawn.h
+
+ifneq ($(findstring install,$(MAKECMDGOALS)),)
+$(addprefix $(PREFIX)$(DEVEL_PREFIX),include $(MULTILIB_DIR)):
+ $(do_mkdir)
+# avoid warning about duplicate targets in rule or overrides
+ifneq ($(abspath $(RUNTIME_PREFIX)$(MULTILIB_DIR)),$(abspath $(DEVEL_PREFIX)$(MULTILIB_DIR)))
+$(PREFIX)$(RUNTIME_PREFIX)$(MULTILIB_DIR):
+ $(do_mkdir)
+endif
+endif
+
+
+install_headers: headers $(top_builddir)extra/scripts/unifdef $(top_builddir)include/generated/unifdef_config.h | $(PREFIX)$(DEVEL_PREFIX)include
+ @$(call disp_install,"include -> $(PREFIX)$(DEVEL_PREFIX)include")
+ $(Q)top_builddir=$(top_builddir) \
+ $(top_srcdir)extra/scripts/install_headers.sh \
+ include $(PREFIX)$(DEVEL_PREFIX)include
+ifneq ($(O),) # only run this step in O is set i.e. make O=/my/builddir/ ..
+ @$(call disp_install,"$(top_builddir)/include -> $(PREFIX)$(DEVEL_PREFIX)include")
+ $(Q)top_builddir=$(top_builddir) \
+ $(top_srcdir)extra/scripts/install_headers.sh \
+ $(top_builddir)/include $(PREFIX)$(DEVEL_PREFIX)include
+endif
+ $(Q)cd $(PREFIX)$(DEVEL_PREFIX)include && $(RM) -r $(HEADERS_RM-)
+ifeq ($(UCLIBC_HAS_WCHAR),)
+ $(Q)cd $(PREFIX)$(DEVEL_PREFIX)include && mv -f wchar-stub.h wchar.h
+else
+ $(Q)cd $(PREFIX)$(DEVEL_PREFIX)include && $(RM) -f wchar-stub.h
endif
+# Installs startfiles
+install_startfiles: startfiles | $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)
+ -$(INSTALL) -m 644 $(startfiles) $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/
+
# Installs development library links.
-install_dev: install_headers
- $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)lib
- -$(INSTALL) -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)lib/
+install_dev: install_headers install_runtime install_startfiles | $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)
+ -$(INSTALL) -m 644 $(top_builddir)lib/*.a $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/
ifeq ($(HAVE_SHARED),y)
- for i in `find lib/ -type l -name 'lib[a-zA-Z]*.so' | \
- sed -e 's/lib\///'` ; do \
- $(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)$$i.$(MAJOR_VERSION) \
- $(PREFIX)$(DEVEL_PREFIX)lib/$$i; \
+ for i in `cd $(top_builddir) && find lib/ -type l -name 'lib[a-zA-Z]*.so' | \
+ $(SED) -e 's/lib\///'` ; do \
+ $(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)$$i.$(ABI_VERSION) \
+ $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/$$i; \
done
- if [ -f $(top_builddir)lib/libc.so -a -f $(PREFIX)$(RUNTIME_PREFIX)lib/$(SHARED_MAJORNAME) ] ; then \
- $(RM) $(PREFIX)$(DEVEL_PREFIX)lib/libc.so; \
- sed -e 's:$(NONSHARED_LIBNAME):$(DEVEL_PREFIX)lib/$(NONSHARED_LIBNAME):' \
- -e 's:$(SHARED_MAJORNAME):$(RUNTIME_PREFIX)lib/$(SHARED_MAJORNAME):' \
- -e 's:$(UCLIBC_LDSO):$(RUNTIME_PREFIX)lib/$(UCLIBC_LDSO):' \
- $(top_builddir)lib/libc.so > $(PREFIX)$(DEVEL_PREFIX)lib/libc.so; \
+ifeq ($(HARDWIRED_ABSPATH),y)
+ if [ -f $(top_builddir)lib/libc.so -a -f $(PREFIX)$(RUNTIME_PREFIX)$(MULTILIB_DIR)/$(SHARED_LIBNAME) ] ; then \
+ $(RM) $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/libc.so; \
+ $(SED) -e 's:$(NONSHARED_LIBNAME):$(DEVEL_PREFIX)$(MULTILIB_DIR)/$(NONSHARED_LIBNAME):' \
+ -e 's:$(SHARED_LIBNAME):$(RUNTIME_PREFIX)$(MULTILIB_DIR)/$(SHARED_LIBNAME):' \
+ -e 's:$(UCLIBC_LDSO):$(RUNTIME_PREFIX)$(MULTILIB_DIR)/$(UCLIBC_LDSO):' \
+ $(top_builddir)lib/libc.so > $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/libc.so; \
+ $(SED) -i -e 's://:/:g' $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/libc.so; \
+ fi
+else
+ -$(INSTALL) -m 755 $(top_builddir)lib/libc.so $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/
+endif
+ echo "$(UBACKTRACE_ASNEEDED)" >> $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/libc.so
+ifeq ($(UCLIBC_HAS_ARGP),y)
+# Add the AS_NEEDED entry for libuargp.so
+ if [ -f $(top_builddir)lib/libc.so -a -f $(PREFIX)$(RUNTIME_PREFIX)$(MULTILIB_DIR)/$(SHARED_MAJORNAME) ] ; then \
+ echo "GROUP ( $(UARGP_ASNEEDED) )" >> $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/libc.so; \
fi
+endif
+
ifeq ($(UCLIBC_HAS_THREADS),y)
ifneq ($(LINUXTHREADS_OLD),y)
- if [ -f $(top_builddir)lib/libpthread.so -a -f $(PREFIX)$(RUNTIME_PREFIX)lib/libpthread.so.$(MAJOR_VERSION) ] ; then \
- $(RM) $(PREFIX)$(DEVEL_PREFIX)lib/libpthread.so; \
- cp $(top_srcdir)extra/scripts/format.lds $(PREFIX)$(DEVEL_PREFIX)lib/libpthread.so; \
- echo "GROUP ( $(RUNTIME_PREFIX)lib/libpthread.so.$(MAJOR_VERSION) $(DEVEL_PREFIX)lib/libpthread_nonshared.a )" \
- >> $(PREFIX)$(DEVEL_PREFIX)lib/libpthread.so; \
+ifeq ($(HARDWIRED_ABSPATH),y)
+ if [ -f $(top_builddir)lib/libpthread.so -a -f $(PREFIX)$(RUNTIME_PREFIX)$(MULTILIB_DIR)/libpthread.so.$(ABI_VERSION) ] ; then \
+ $(RM) $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/libpthread.so; \
+ cp $(top_srcdir)extra/scripts/format.lds $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/libpthread.so; \
+ echo "GROUP ( $(RUNTIME_PREFIX)$(MULTILIB_DIR)/libpthread.so.$(ABI_VERSION) $(DEVEL_PREFIX)$(MULTILIB_DIR)/libpthread_nonshared.a )" \
+ >> $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/libpthread.so; \
+ $(SED) -i -e 's://:/:g' $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/libpthread.so; \
fi
+else
+ -$(INSTALL) -m 755 $(top_builddir)lib/libpthread.so $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/
+endif
endif
endif
ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
$(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)libthread_db.so.1 \
- $(PREFIX)$(DEVEL_PREFIX)lib/libthread_db.so
+ $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/libthread_db.so
endif
ifeq ($(DOPIC),y)
# # If we build shared libraries then the static libs are PIC...
# # Make _pic.a symlinks to make mklibs.py and similar tools happy.
- if [ -d lib ] ; then \
- for i in `find lib/ -type f -name 'lib*.a' | sed -e 's/lib\///'` ; do \
- $(LN) -sf $$i $(PREFIX)$(DEVEL_PREFIX)lib/`echo $$i \
- | sed -e 's/\.a$$/_pic.a/'`; \
+ if [ -d $(top_builddir)lib ] ; then \
+ for i in `cd $(top_builddir) && find lib/ -type f -name 'lib*.a' | $(SED) -e 's/lib\///'` ; do \
+ $(LN) -sf $$i $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/`echo $$i \
+ | $(SED) -e 's/\.a$$/_pic.a/'`; \
done ; \
fi
endif
endif
ifeq ($(UCLIBC_FORMAT_SHARED_FLAT),y)
- for file in lib/lib*.gdb; do \
+ for file in $(top_builddir)lib/lib*.gdb; do \
if test -f $$file; then \
- $(INSTALL) -m 755 $$file $(PREFIX)$(DEVEL_PREFIX)lib; \
- $(INSTALL) -m 755 `echo $$file | sed 's/\.gdb$$//'` \
- $(PREFIX)$(DEVEL_PREFIX)lib; \
+ $(INSTALL) -m 755 $$file $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR); \
+ $(INSTALL) -m 755 `echo $$file | $(SED) 's/\.gdb$$//'` \
+ $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR); \
fi; \
done
endif
# Installs run-time libraries
-install_runtime:
+install_runtime: all | $(PREFIX)$(RUNTIME_PREFIX)$(MULTILIB_DIR)
ifeq ($(HAVE_SHARED),y)
- $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)lib
- $(INSTALL) -m 644 lib/lib*-$(VERSION).so \
- $(PREFIX)$(RUNTIME_PREFIX)lib
- cd lib && $(TAR) -cf - *.so.* | $(TAR) -xf - -C $(PREFIX)$(RUNTIME_PREFIX)lib
- @if [ -x lib/$(UCLIBC_LDSO_NAME)-$(VERSION).so ] ; then \
+ $(INSTALL) -m 755 $(top_builddir)lib/lib*-$(VERSION).so \
+ $(PREFIX)$(RUNTIME_PREFIX)$(MULTILIB_DIR)
+ (cd $(top_builddir)lib && $(TAR) --exclude=$(UCLIBC_LDSO_NAME).so.lds -cf - *.so.*) \
+ | $(TAR) -xf - -C $(PREFIX)$(RUNTIME_PREFIX)$(MULTILIB_DIR)
+ @if [ -x $(top_builddir)lib/$(UCLIBC_LDSO_NAME)-$(VERSION).so ] ; then \
set -e; \
$(SHELL_SET_X); \
- $(INSTALL) -m 755 lib/$(UCLIBC_LDSO_NAME)-$(VERSION).so \
- $(PREFIX)$(RUNTIME_PREFIX)lib; \
+ $(INSTALL) -m 755 $(top_builddir)lib/$(UCLIBC_LDSO_NAME)-$(VERSION).so \
+ $(PREFIX)$(RUNTIME_PREFIX)$(MULTILIB_DIR); \
fi
endif
-utils:
- $(Q)$(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils
+utils: | pregen
+ $(Q)$(MAKE) CROSS_COMPILE="$(CROSS_COMPILE)" CC="$(CC)" -C utils $@
# Installs helper applications, such as 'ldd' and 'ldconfig'
install_utils: utils
- $(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils utils_install
+ $(Q)$(MAKE) CROSS_COMPILE="$(CROSS_COMPILE)" CC="$(CC)" -C utils utils_install
endif # ifeq ($(HAVE_DOT_CONFIG),y)
-include/bits:
- @$(disp_mkdir)
- $(Q)$(INSTALL) -d $@
+hostutils: | pregen
+ $(Q)$(MAKE) CROSS_COMPILE="$(CROSS_COMPILE)" CC="$(CC)" HOSTCC="$(HOSTCC)" DOTHOST=.host -C utils $@
+
+install_hostutils: hostutils
+ $(Q)$(MAKE) CROSS_COMPILE="$(CROSS_COMPILE)" CC="$(CC)" HOSTCC="$(HOSTCC)" DOTHOST=.host -C utils utils_install
+
+$(addprefix $(top_builddir),include include/bits include/sys include/config include/generated lib extra/config/lxdialog extra/locale extra/scripts $(subdirs)):
+ $(do_mkdir)
# configuration
# ---------------------------------------------------------------------------
-extra/config/conf extra/config/mconf: $(suspicious_dependency)
- $(Q)$(MAKE) -C extra/config $(notdir $@)
-
-menuconfig: extra/config/mconf $(suspicious_dependency)
- $(Q)./extra/config/mconf extra/Configs/Config.in
-
-config: extra/config/conf $(suspicious_dependency)
- $(Q)./extra/config/conf extra/Configs/Config.in
-
-oldconfig: extra/config/conf $(suspicious_dependency)
- $(Q)./extra/config/conf -o extra/Configs/Config.in
-
-silentoldconfig: extra/config/conf $(suspicious_dependency)
- $(Q)./extra/config/conf -s extra/Configs/Config.in
-
-randconfig: extra/config/conf $(suspicious_dependency)
- $(Q)./extra/config/conf -r extra/Configs/Config.in
-
-allyesconfig: extra/config/conf $(suspicious_dependency)
- $(Q)./extra/config/conf -y extra/Configs/Config.in
- sed -i -e "s/^DODEBUG=.*/# DODEBUG is not set/" .config
- sed -i -e "s/^DOASSERTS=.*/# DOASSERTS is not set/" .config
- sed -i -e "s/^SUPPORT_LD_DEBUG_EARLY=.*/# SUPPORT_LD_DEBUG_EARLY is not set/" .config
- sed -i -e "s/^SUPPORT_LD_DEBUG=.*/# SUPPORT_LD_DEBUG is not set/" .config
- sed -i -e "s/^UCLIBC_MJN3_ONLY=.*/# UCLIBC_MJN3_ONLY is not set/" .config
- $(Q)./extra/config/conf -o extra/Configs/Config.in
-
-allnoconfig: extra/config/conf $(suspicious_dependency)
- $(Q)./extra/config/conf -n extra/Configs/Config.in
-
-defconfig: extra/config/conf $(suspicious_dependency)
- $(Q)./extra/config/conf -d extra/Configs/Config.in \
- -D extra/Configs/defconfigs/$(ARCH)
-
-clean:
- $(Q)$(RM) -r lib include/bits
- $(RM) ldso/*/*.a libpthread/*/*.a libc/*.a libcrypt/*.a libintl/*.a \
- libm/*.a libnsl/*.a libpthread/*.a libresolv/*.a librt/*.a \
- libutil/*.a lib/*.a \
- include/fpu_control.h include/dl-osinfo.h include/hp-timing.h
+$(conf) $(mconf) $(nconf): | $(top_builddir)include/config $(top_builddir)include/generated $(top_builddir)extra/config/lxdialog
+ $(Q)$(MAKE) -C extra/config $(@F)
+
+arch-defconfigs := $(notdir $(wildcard $(top_srcdir)extra/Configs/defconfigs/$(ARCH)/*_defconfig))
+
+menuconfig: $(mconf)
+ $(Q)$< $(Kconfig)
+config: $(conf)
+ $(Q)$< $(Kconfig)
+nconfig: $(nconf)
+ $(Q)$< $(Kconfig)
+
+oldaskconfig: $(conf)
+ $(Q)$< -a $(Kconfig)
+silentoldconfig: $(conf)
+ $(Q)$< -s $(Kconfig)
+oldconfig: $(conf)
+ $(Q)$< -o $(Kconfig)
+allnoconfig: $(conf)
+ $(Q)$< -n $(Kconfig)
+allyesconfig: $(conf)
+ $(Q)$< -y $(Kconfig)
+ $(SED) -i -e "s/^DODEBUG=.*/# DODEBUG is not set/" \
+ -e "s/^DOASSERTS=.*/# DOASSERTS is not set/" \
+ -e "s/^SUPPORT_LD_DEBUG_EARLY=.*/# SUPPORT_LD_DEBUG_EARLY is not set/" \
+ -e "s/^SUPPORT_LD_DEBUG=.*/# SUPPORT_LD_DEBUG is not set/" \
+ -e "s/^UCLIBC_MJN3_ONLY=.*/# UCLIBC_MJN3_ONLY is not set/" \
+ $(KCONFIG_CONFIG)
+ $(Q)$< -o $(Kconfig)
+alldefconfig: $(conf)
+ $(Q)$< -A $(Kconfig)
+randconfig: $(conf)
+ $(Q)$< -r $(Kconfig)
+
+cmd_defconfig = $(Q)$< -D extra/Configs/defconfigs/$(ARCH)/$@ $(Kconfig)
+defconfig: $(conf) ; $(cmd_defconfig)
+%_defconfig: $(conf) ; $(cmd_defconfig)
+
+savedefconfig: $(conf)
+ $(Q)$< -S defconfig $(Kconfig)
+listnewconfig: $(conf)
+ $(Q)$< -l $(Kconfig)
+olddefconfig: $(conf)
+ $(Q)$< -d $(Kconfig)
+
+menuconfig-clean-y:
+ $(Q)$(MAKE) -C extra/config CLEAN_extra/config
+
+# The find here should continue to work as long as we are only symlinking
+# headers in to include/. I don't see this changing to anything else, so
+# it should be fine.
+include_clean:
+ $(SECHO) " CLEAN include"
+ $(Q)$(RM) -r $(top_builddir)include/bits
+ $(Q)find $(top_builddir)include/ -type l -exec rm -f {} +
+
+clean: include_clean
+ $(Q)$(RM) -r $(top_builddir)lib
+ @$(MAKE) -C utils CLEAN_utils
+$(MAKE) -s -C test clean
- +$(MAKE) -C utils utils_clean
- @set -e; \
- for i in `(cd libc/sysdeps/linux/common/sys; ls *.h)` ; do \
- $(RM) include/sys/$$i; \
- done; \
- if [ -d libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
- for i in `(cd libc/sysdeps/linux/$(TARGET_ARCH)/sys; ls *.h)` ; do \
- $(RM) include/sys/$$i; \
- done; \
- fi
- @$(RM) include/linux include/asm*
- $(RM) $(top_builddir)extra/scripts/unifdef
- $(RM) -r $(LOCAL_INSTALL_PATH)
+ $(Q)$(RM) $(top_builddir)extra/scripts/unifdef
+ $(Q)$(RM) -r $(LOCAL_INSTALL_PATH)
-distclean: clean
+distclean: realclean
-find . \( -name core -o -name \*.orig -o -name \*~ -o -name .\*.dep \) -exec $(RM) {} \;
- $(RM) .config .config.old .config.cmd
- $(RM) extra/locale/*.tgz
- $(MAKE) -C extra/config distclean
+ $(RM) $(top_builddir).config $(top_builddir).config.old $(top_builddir).config.cmd
+ $(Q)$(RM) $(top_builddir)extra/locale/*.tgz
+ @$(MAKE) -C extra/config distclean
dist release:
- $(RM) -r ../uClibc-$(VERSION) ../uClibc-$(VERSION).tar.bz2
- svn -q export . ../uClibc-$(VERSION)
- $(TAR) cjf ../uClibc-$(VERSION).tar.bz2 -C .. uClibc-$(VERSION)
- du -b ../uClibc-$(VERSION).tar.bz2
+ $(RM) ../uClibc-$(VERSION).tar
+ git archive --format=tar --prefix=uClibc-$(VERSION)/ HEAD \
+ > ../uClibc-$(VERSION).tar
+ cat ../uClibc-$(VERSION).tar | bzip2 -c9 > ../uClibc-$(VERSION).tar.bz2
+ cat ../uClibc-$(VERSION).tar | xz -e -c8 > ../uClibc-$(VERSION).tar.xz
+ du -b ../uClibc-$(VERSION).tar.{bz2,xz}
test check: test_compile
- $(Q)$(MAKE) -C test
+ $(Q)$(MAKE) -C test \
+ $(if $(O),top_builddir=$(O)/)
test_compile: $(LOCAL_INSTALL_PATH)
- $(Q)$(MAKE) -C test compile
+ $(Q)$(MAKE) -C test compile \
+ $(if $(O),top_builddir=$(O)/)
+
+test_gen: $(LOCAL_INSTALL_PATH)
+ $(Q)$(MAKE) -C test gen \
+ $(if $(O),top_builddir=$(O)/)
diff --git a/Makerules b/Makerules
index 4ce235e36..d8cbfe435 100644
--- a/Makerules
+++ b/Makerules
@@ -6,10 +6,10 @@
PHONY := FORCE
-.PHONY: dummy $(PHONY) \
+.PHONY: dummy $(PHONY) subdirs \
all check test $(clean_targets) \
config dist menuconfig oldconfig release \
- subdirs utils help
+ utils help
# order is important, the stripping uses STRIP_FLAGS for lib-so, but not for lib-a
ifeq ($(HAVE_SHARED),y)
@@ -24,6 +24,31 @@ endif
libs: $(lib-a-y)
endif
objs: all_objs
+$(lib-so-y) $(lib-a-y): | $(top_builddir)lib
+
+# apply unconditional per-directory flags
+define add_IS_IN_lib
+ifneq ($(strip $(2)),)
+__add_IS_IN_lib := $(2)
+__add_IS_IN_lib += $(2:.o=.i) $(2:.os=.i) $(2:.oS=.i)
+__add_IS_IN_lib += $(2:.o=.s) $(2:.os=.s) $(2:.oS=.s)
+$$(__add_IS_IN_lib): CFLAGS-for-library-members:=$(CFLAGS-$(1)) -DIN_LIB=$(word 1,$(subst /, ,$(1)))
+endif
+endef
+$(eval $(call add_IS_IN_lib,rtld,$(ldso-y)))
+$(eval $(call add_IS_IN_lib,libc,$(libc-y) $(libc-static-y) $(libc-y:.o=.os) $(libc-shared-y) $(libc-nonshared-y)))
+$(eval $(call add_IS_IN_lib,libcrypt,$(libcrypt-a-y) $(libcrypt-so-y)))
+$(eval $(call add_IS_IN_lib,libdl,$(libdl-a-y) $(libdl-so-y)))
+$(eval $(call add_IS_IN_lib,libintl,$(libintl-a-y) $(libintl-so-y)))
+$(eval $(call add_IS_IN_lib,libm,$(libm-a-y) $(libm-so-y)))
+$(eval $(call add_IS_IN_lib,libnsl,$(libnsl-a-y) $(libnsl-so-y)))
+$(eval $(call add_IS_IN_lib,libpthread/$(PTNAME),$(libpthread-a-y) $(libpthread-so-y) $(libpthread-nonshared-y)))
+$(eval $(call add_IS_IN_lib,libpthread/$(PTNAME)_db,$(libthread_db-a-y) $(libthread_db-so-y)))
+$(eval $(call add_IS_IN_lib,libresolv,$(libresolv-a-y) $(libresolv-so-y)))
+$(eval $(call add_IS_IN_lib,librt,$(librt-a-y) $(librt-so-y)))
+$(eval $(call add_IS_IN_lib,libutil,$(libutil-a-y) $(libutil-so-y)))
+$(eval $(call add_IS_IN_lib,libubacktrace,$(libubacktrace-a-y) $(libubacktrace-so-y)))
+$(eval $(call add_IS_IN_lib,libuargp,$(libuargp-a-y) $(libuargp-so-y)))
shared_objs = $(libc-y:.o=.os) $(libc-shared-y) $(libc-nonshared-y) \
$(libcrypt-so-y) $(libdl-so-y) \
@@ -31,12 +56,12 @@ shared_objs = $(libc-y:.o=.os) $(libc-shared-y) $(libc-nonshared-y) \
$(libpthread-so-y) $(libpthread-nonshared-y) $(libthread_db-so-y) \
$(libresolv-so-y) $(librt-so-y) \
$(ldso-y) \
- $(libutil-so-y)
+ $(libutil-so-y) $(libubacktrace-so-y) $(libuargp-so-y)
ar_objs = $(libc-y) $(libc-static-y) $(libcrypt-a-y) \
$(libdl-a-y) $(libintl-a-y) $(libm-a-y) $(libnsl-a-y) \
$(libpthread-a-y) $(libthread_db-a-y) \
- $(libresolv-a-y) $(librt-a-y) $(libutil-a-y)
+ $(libresolv-a-y) $(librt-a-y) $(libutil-a-y) $(libubacktrace-a-y) $(libuargp-a-y)
ifeq ($(DOPIC),y)
ar_objs := $(ar_objs:.o=.os)
endif
@@ -49,11 +74,18 @@ all_objs: $(ar_objs)
endif
$(shared_objs) $(ar_objs): | $(sub_headers)
+define objects_with_syms
+ $(foreach o,$(2),$(if $(shell $(NM) $(1) $(o) | grep .),$(o)))
+endef
+
headers-y: $(headers-y)
@true
MAKEFLAGS += --no-print-directory
SHELL_SET_X := set +x
+define rel_srcdir
+ $(shell $(CONFIG_SHELL) $(top_srcdir)/extra/scripts/relative_path.sh $(@D) .)
+endef
ifneq ($(findstring s,$(MAKEFLAGS)),)
export MAKE_IS_SILENT := y
SECHO := -@false
@@ -63,16 +95,27 @@ else
export MAKE_IS_SILENT := n
SECHO := @echo
ifneq ($(V)$(VERBOSE),)
+ifeq ($(V),2)
+DISP := bri# brief, like pur but with defines
+Q := @
+else
SHELL_SET_X := set -x
DISP := ver
Q :=
+endif
else
DISP := pur
Q := @
endif
endif
-show_objs = $(subst ../,,$@)
+show_objs = $(subst $(top_builddir),,$(subst ../,,$@))
+define show_defs
+ $(filter -D%,$(1))
+endef
+define show_ldflags
+ $(subst $(comma), ,$(subst -Wl$(comma),,$(filter -Wl%,$(1))))
+endef
pur_disp_compile.c = echo " "CC $(show_objs)
pur_disp_compile.i = echo " "CPP $(show_objs)
@@ -80,15 +123,20 @@ pur_disp_compile.s = echo " "CC-S $(show_objs)
pur_disp_compile.u = echo " "CC $(show_objs)
pur_disp_compile.S = echo " "AS $(show_objs)
pur_disp_compile.m = $(pur_disp_compile.c)
+pur_disp_compile.mi= echo " "CPP-m $(show_objs)
pur_disp_compile-m = echo " "CC-m $(show_objs)
+pur_disp_hcompile.u= echo " "HOSTCC $(show_objs)
+pur_disp_hcompile.o= echo " "HOSTCC-o $(show_objs)
pur_disp_strip = echo " "STRIP $(STRIP_FLAGS) $@
pur_disp_t_strip = echo " "STRIP $(STRIP_FLAGS) $@
pur_disp_ar = echo " "AR $(ARFLAGS) $@
pur_disp_ld = echo " "LD $(1)
-pur_disp_ln = echo " "LN $@
-pur_disp_mkdir = echo " "MKDIR $@
-pur_disp_gen = echo " "GEN $@
-pur_disp_unifdef = echo " "UNIFDEF $@
+pur_disp_ln = echo " "LN $(show_objs)
+pur_disp_mkdir = echo " "MKDIR $(show_objs)
+pur_disp_gen = echo " "GEN $(show_objs)
+pur_disp_install = echo " "INSTALL $(1)
+pur_disp_unifdef = echo " "UNIFDEF $(show_objs)
+pur_disp_rm = echo " "CLEAN $(subst CLEAN_,,$(patsubst HEADERCLEAN_%,include \(%\),$@))
sil_disp_compile.c = true
sil_disp_compile.i = true
@@ -96,7 +144,10 @@ sil_disp_compile.s = true
sil_disp_compile.u = true
sil_disp_compile.S = true
sil_disp_compile.m = true
+sil_disp_compile.mi= true
sil_disp_compile-m = true
+sil_disp_hcompile.u= true
+sil_disp_hcompile.o= true
sil_disp_strip = true
sil_disp_t_strip = true
sil_disp_ar = true
@@ -104,23 +155,53 @@ sil_disp_ld = true
sil_disp_ln = true
sil_disp_mkdir = true
sil_disp_gen = true
+sil_disp_install = true
sil_disp_unifdef = true
-
-ver_disp_compile.c = echo $(cmd_compile.c)
-ver_disp_compile.i = echo $(cmd_compile.i)
-ver_disp_compile.s = echo $(cmd_compile.s)
-ver_disp_compile.u = echo $(cmd_compile.u)
-ver_disp_compile.S = echo $(cmd_compile.S)
-ver_disp_compile.m = echo $(cmd_compile.m)
-ver_disp_compile-m = echo $(cmd_compile-m)
-ver_disp_strip = echo $(cmd_strip)
-ver_disp_t_strip = echo $(cmd_t_strip)
-ver_disp_ar = echo $(cmd_ar)
+sil_disp_rm = true
+
+bri_disp_compile.c = $(pur_disp_compile.c) $(call show_defs,$(cmd_compile.c))
+bri_disp_compile.i = $(pur_disp_compile.i) $(call show_defs,$(cmd_compile.i))
+bri_disp_compile.s = $(pur_disp_compile.s) $(call show_defs,$(cmd_compile.s))
+bri_disp_compile.u = $(pur_disp_compile.u) $(call show_defs,$(cmd_compile.u))
+bri_disp_compile.S = $(pur_disp_compile.S) $(call show_defs,$(cmd_compile.S))
+bri_disp_compile.m = $(pur_disp_compile.m) $(call show_defs,$(cmd_compile.m))
+bri_disp_compile.mi = $(pur_disp_compile.mi) $(call show_defs,$(cmd_compile.mi))
+bri_disp_compile-m = $(pur_disp_compile-m) $(call show_defs,$(cmd_compile-m))
+bri_disp_hcompile.u = $(pur_disp_hcompile.u) $(call show_defs,$(cmd_hcompile.u))
+bri_disp_hcompile.o = $(pur_disp_hcompile.o) $(call show_defs,$(cmd_hcompile.o))
+bri_disp_strip = $(pur_disp_strip)
+bri_disp_t_strip = $(pur_disp_t_strip)
+bri_disp_ar = $(pur_disp_ar)
+bri_disp_ld = $(pur_disp_ld) $(call show_ldflags,$(cmd_ld))
+bri_disp_ln = $(pur_disp_ln)
+bri_disp_mkdir = $(pur_disp_mkdir)
+bri_disp_gen = $(pur_disp_gen)
+bri_disp_install = $(pur_disp_install)
+bri_disp_unifdef = $(pur_disp_unifdef)
+bri_disp_rm = $(pur_disp_rm)
+
+esc=$(subst ','\'',$(1))
+# ')
+ver_disp_compile.c = echo '$(call esc,$(cmd_compile.c))'
+ver_disp_compile.i = echo '$(call esc,$(cmd_compile.i))'
+ver_disp_compile.s = echo '$(call esc,$(cmd_compile.s))'
+ver_disp_compile.u = echo '$(call esc,$(cmd_compile.u))'
+ver_disp_compile.S = echo '$(call esc,$(cmd_compile.S))'
+ver_disp_compile.m = echo '$(call esc,$(cmd_compile.m))'
+ver_disp_compile.mi= echo '$(call esc,$(cmd_compile.mi))'
+ver_disp_compile-m = echo '$(call esc,$(cmd_compile-m))'
+ver_disp_hcompile.u= echo '$(call esc,$(cmd_hcompile.u))'
+ver_disp_hcompile.o= echo '$(call esc,$(cmd_hcompile.o))'
+ver_disp_strip = echo '$(call esc,$(cmd_strip))'
+ver_disp_t_strip = echo '$(call esc,$(cmd_t_strip))'
+ver_disp_ar = echo '$(call esc,$(cmd_ar))'
ver_disp_ld =
ver_disp_ln =
ver_disp_mkdir =
ver_disp_gen =
-ver_disp_unifdef = echo $(cmd_unifdef)
+ver_disp_install =
+ver_disp_unifdef = echo '$(call esc,$(cmd_unifdef))'
+ver_disp_rm =
disp_compile.c = $($(DISP)_disp_compile.c)
disp_compile.i = $($(DISP)_disp_compile.i)
@@ -128,7 +209,10 @@ disp_compile.s = $($(DISP)_disp_compile.s)
disp_compile.u = $($(DISP)_disp_compile.u)
disp_compile.S = $($(DISP)_disp_compile.S)
disp_compile.m = $($(DISP)_disp_compile.m)
+disp_compile.mi= $($(DISP)_disp_compile.mi)
disp_compile-m = $($(DISP)_disp_compile-m)
+disp_hcompile.u= $($(DISP)_disp_hcompile.u)
+disp_hcompile.o= $($(DISP)_disp_hcompile.o)
disp_strip = $($(DISP)_disp_strip)
disp_t_strip = $($(DISP)_disp_t_strip)
disp_ar = $($(DISP)_disp_ar)
@@ -136,7 +220,9 @@ disp_ld = $($(DISP)_disp_ld)
disp_ln = $($(DISP)_disp_ln)
disp_mkdir = $($(DISP)_disp_mkdir)
disp_gen = $($(DISP)_disp_gen)
+disp_install = $($(DISP)_disp_install)
disp_unifdef = $($(DISP)_disp_unifdef)
+disp_rm = $($(DISP)_disp_rm)
any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^)
@@ -162,59 +248,92 @@ maybe_exec = \
$(cmd_$(1)); \
echo 'cmd_$(call variablify,$@) := $(call dirify,$(cmd_$(call variablify,$1)))' >> $(dir $@).$(notdir $@).dep)
+# collect flags of domulti prereqs
+#collect_multi_flags = $(CFLAGS-$(notdir $(d))) $(CFLAGS-$(notdir $(patsubst %/,%,$(dir $(d)))))
+collect_multi_flags = $(CFLAGS-$(notdir $(patsubst %/,%,$(dir $(d)))))
+
+#sub_srcdir = $(word 1,$(filter-out lib extra locale libpthread,$(wordlist 1,2,$(subst /, ,$(subst $(top_srcdir),,$(dir $<))))))
CFLAGS_gen.dep = -MT $@ -MD -MP -MF $(dir $@).$(notdir $@).dep
-cmd_compile.c = $(CC) -c $< -o $@ $(CFLAGS) $(ARCH_CFLAGS) \
+cmd_compile.c = $(CC) -c $< -o $@ \
+ $(filter-out $(CFLAGS-OMIT-$(notdir $<)), \
+ $(CFLAGS) \
+ $(CFLAGS-for-library-members) \
$(CFLAGS-$(suffix $@)) \
- $(filter-out $(CFLAGS-OMIT-$(notdir $<)),$(CFLAGS-$(notdir $(<D)))) \
- $(CFLAGS-$(subst $(top_srcdir),,$(dir $<))) \
+ $(CFLAGS-y-$(subst $(top_srcdir),,$(<D))) \
$(CFLAGS-$(notdir $<)) \
$(CFLAGS-$(notdir $@)) \
+ ) \
$(CFLAGS_gen.dep)
-cmd_compile.i = $(cmd_compile.c:-c=-E -dD $(EXTRA_CPPFLAGS))
+cmd_compile.i = $(cmd_compile.c:-c=-E -dD) $(UCLIBC_EXTRA_CPPFLAGS)
cmd_compile.s = $(cmd_compile.c:-c=-S)
cmd_compile.u = $(CC) $^ $(DEPS-$(notdir $@)) -o $@ $(CFLAGS) $(CFLAGS-$(notdir $(^D))) $(CFLAGS-$(notdir $@)) $(CFLAGS_gen.dep)
-cmd_compile.S = $(filter-out -std=gnu99, $(cmd_compile.c)) -D__ASSEMBLER__ $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS-$(suffix $@)) $(ASFLAGS-$(notdir $<)) $(ASFLAGS-$(notdir $@))
+cmd_compile.S = $(filter-out -std=%, $(cmd_compile.c)) -D__ASSEMBLER__ $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS-$(suffix $@)) $(ASFLAGS-$(notdir $<)) $(ASFLAGS-$(notdir $@))
cmd_compile.m = $(cmd_compile.c) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@))
+cmd_compile.mi= $(cmd_compile.m:-c=-E -dD) $(UCLIBC_EXTRA_CPPFLAGS)
-cmd_compile-m = $(CC) $^ -c -o $@ $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(notdir $(@D))) $(CFLAGS-$(notdir $@))
+cmd_compile-m = $(CC) $^ -c -o $@ $(CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(notdir $(@D))) $(CFLAGS-$(notdir $@)) $(sort $(foreach d,$(^:$(top_srcdir)=),$(collect_multi_flags)))
cmd_strip = $(STRIPTOOL) $(STRIP_FLAGS) $^
cmd_t_strip = $(STRIPTOOL) $(STRIP_FLAGS) $@
-cmd_ar = $(AR) $(ARFLAGS) $@ $^
+cmd_ar = $(AR) $(ARFLAGS) $@ $(call objects_with_syms,,$^)
define do_ln
@$(disp_ln)
$(Q)$(LN) -fs
endef
+define do_mkdir
+ @$(disp_mkdir)
+ $(Q)$(INSTALL) -d $@
+endef
+
+define do_rm
+ @$(disp_rm)
+ $(Q)$(RM)
+endef
+
+define do_awk
+ @$(disp_gen)
+ $(Q)$(AWK) -f
+endef
+
+define do_sed
+ @$(disp_gen)
+ $(Q)$(SED)
+endef
+
compile.c = @$(call maybe_exec,compile.c)
compile.i = $(call maybe_exec,compile.i)
compile.s = $(call maybe_exec,compile.s)
compile.S = @$(call maybe_exec,compile.S)
compile.m = @$(call maybe_exec,compile.m)
-compile-m = @$(disp_compile-m) ; $(cmd_compile-m) ; $(cmd_t_strip)
+compile.mi= $(call maybe_exec,compile.mi)
+compile-m = @$(disp_compile-m) ; $(cmd_compile-m) && $(cmd_t_strip)
do_strip = @$(disp_strip) ; $(cmd_strip)
do_t_strip= @$(disp_t_strip) ; $(cmd_t_strip)
do_unifdef= @$(disp_unifdef) ; $(cmd_unifdef)
+hcompile.u= @$(disp_hcompile.u); $(cmd_hcompile.u)
+hcompile.o= @$(disp_hcompile.o); $(cmd_hcompile.o)
define do_ar
- $(do_strip)
@$(disp_ar) ; $(cmd_ar)
+ @$(do_t_strip)
endef
define compile.u
@$(disp_compile.u) ; $(cmd_compile.u)
@$(disp_t_strip)
endef
-hcompile.u = $(HOSTCC) $^ $(DEPS-$(notdir $@)) -o $@ $(BUILD_LDFLAGS) $(BUILD_LDFLAGS-$(notdir $(^D))) $(BUILD_LDFLAGS-$(notdir $@)) $(BUILD_CFLAGS) $(BUILD_CFLAGS-$(notdir $(^D))) $(BUILD_CFLAGS-$(notdir $@))
-hcompile.o = $(HOSTCC) $^ $(DEPS-$(notdir $@)) -c -o $@ $(BUILD_CFLAGS) $(BUILD_CFLAGS-$(notdir $(^D))) $(BUILD_CFLAGS-$(notdir $@))
+cmd_hcompile.u = $(HOSTCC) $(filter-out $(PHONY),$^) $(DEPS-$(notdir $@)) -o $@ $(BUILD_LDFLAGS) $(BUILD_LDFLAGS-$(notdir $(^D))) $(BUILD_LDFLAGS-$(notdir $@)) $(BUILD_CFLAGS) $(BUILD_CFLAGS-$(notdir $(^D))) $(BUILD_CFLAGS-$(notdir $@))
+cmd_hcompile.o = $(HOSTCC) $(filter-out $(PHONY),$<) $(DEPS-$(notdir $@)) -c -o $@ $(BUILD_CFLAGS) $(BUILD_CFLAGS-$(notdir $(^D))) $(BUILD_CFLAGS-$(notdir $@))
define link.so
- $(Q)$(INSTALL) -d $(dir $@)
$(Q)$(RM) $@ $@.$(2) $(dir $@)$(1)
@$(disp_ld)
- $(Q)$(CC) $(LDFLAGS-$(notdir $@)) -Wl,-soname=$(notdir $@).$(2) \
- $(NOSTDLIB_CFLAGS) -o $(dir $@)$(1) $(START_FILE-$(notdir $@)) \
+ $(Q)$(CC) $(LDFLAGS-$(notdir $@)) $(LDFLAGS-y-$(@F)) \
+ -Wl,-soname=$(notdir $@).$(2) \
+ $(CFLAG_-nostdlib) $(CFLAG_-nostartfiles) \
+ -o $(dir $@)$(1) $(START_FILE-$(notdir $@)) \
-Wl,--whole-archive $(firstword $^) -Wl,--no-whole-archive \
$(LIBS-$(notdir $@)) $(LIBGCC) $(END_FILE-$(notdir $@))
$(Q)$(LN) -sf $(1) $@.$(2)
@@ -237,10 +356,9 @@ LINK_FLAT_CRTS := $(top_builddir)lib/Scrt1.o $(top_builddir)lib/crti.o \
# This is so far only used for libc, for which we want to link the entire
# libgcc into the shared object.
define link-flat.so
- $(Q)$(INSTALL) -d $(dir $@)
$(Q)$(RM) $(1) $@
@$(disp_ld)
- $(Q)$(CC) $(LDFLAGS-$(notdir $@)) $(NOSTDLIB_CFLAGS) -o $(1) \
+ $(Q)$(CC) $(LDFLAGS-$(notdir $@)) $(CFLAG_-nostdlib) -o $(1) \
-Wl,-elf2flt -Wl,-shared-lib-id,$(2) $(top_builddir)lib/Scrt1.o \
$(top_builddir)/lib/crti.o -Wl,--whole-archive $(firstword $^) \
$(LIBGCC) -Wl,--no-whole-archive $(LIBS-$(notdir $@)) $(LIBGCC) \
@@ -248,12 +366,11 @@ define link-flat.so
endef
define linkm.so
- $(Q)$(INSTALL) -d $(dir $@)
$(Q)$(RM) $@ $@.$(2) $(dir $@)$(1)
$(do_strip)
@$(disp_ld)
$(Q)$(CC) $(LDFLAGS-$(notdir $@)) -Wl,-soname=$(notdir $@).$(2) \
- $(NOSTDLIB_CFLAGS) -o $(dir $@)$(1) $(START_FILE-$(notdir $@)) \
+ $(CFLAG_-nostdlib) -o $(dir $@)$(1) $(START_FILE-$(notdir $@)) \
$^ \
$(LIBS-$(notdir $@)) $(LIBGCC) $(END_FILE-$(notdir $@))
$(Q)$(LN) -sf $(1) $@.$(2)
@@ -263,36 +380,37 @@ endef
CFLAGS-.os+=$(PICFLAG)
CFLAGS-.oS+=$(PICFLAG) -DSHARED
-%.o: %.c FORCE ; $(compile.c)
-%.os: %.c FORCE ; $(compile.c)
-%.oS: %.c FORCE ; $(compile.c)
-%.o: %.S FORCE ; $(compile.S)
-%.os: %.S FORCE ; $(compile.S)
-%.oS: %.S FORCE ; $(compile.S)
-%.o: %.s FORCE ; $(compile.S)
-%.os: %.s FORCE ; $(compile.S)
-%.oS: %.s FORCE ; $(compile.S)
-%.i: %.c FORCE ; $(compile.i)
-%.i: %.S FORCE ; $(compile.i)
-%.s: %.c FORCE ; $(compile.s)
-%.s: %.S FORCE ; $(compile.s)
-
-$(top_builddir)lib/interp.c: | $(sub_headers)
- $(Q)$(INSTALL) -d $(dir $@)
- $(Q)echo "/* Force shared libraries to know about the correct library loader */" > $@
- $(Q)echo "#include <features.h>" >> $@
- $(Q)echo "const char __dl_ldso__[] __attribute__ ((section " \
- "(\".interp\"))) =\""$(SHARED_LIB_LOADER_PREFIX)/$(UCLIBC_LDSO)"\";" >> $@
-
-$(interp): $(top_builddir)lib/interp.c
+$(top_builddir)%.o: $(top_srcdir)%.c FORCE ; $(compile.c)
+$(top_builddir)%.os: $(top_srcdir)%.c FORCE | pregen; $(compile.c)
+$(top_builddir)%.oS: $(top_srcdir)%.c FORCE | pregen; $(compile.c)
+$(top_builddir)%.o: $(top_srcdir)%.S FORCE ; $(compile.S)
+$(top_builddir)%.os: $(top_srcdir)%.S FORCE | pregen; $(compile.S)
+$(top_builddir)%.oS: $(top_srcdir)%.S FORCE | pregen; $(compile.S)
+$(top_builddir)%.o: $(top_srcdir)%.s FORCE ; $(compile.S)
+$(top_builddir)%.os: $(top_srcdir)%.s FORCE ; $(compile.S)
+$(top_builddir)%.oS: $(top_srcdir)%.s FORCE | pregen; $(compile.S)
+$(top_builddir)%.i: $(top_srcdir)%.c FORCE | pregen; $(compile.i)
+$(top_builddir)%.i: $(top_srcdir)%.S FORCE | pregen; $(compile.i)
+$(top_builddir)%.s: $(top_srcdir)%.c FORCE | pregen; $(compile.s)
+$(top_builddir)%.s: $(top_srcdir)%.S FORCE | pregen; $(compile.s)
+$(top_builddir)%.dep:
+
+$(top_builddir)lib/interp.c: | $(top_builddir)lib
+ $(Q)echo "/* Force shared libraries to know about the correct library loader */" > $@.tmp
+ $(Q)echo "#include <features.h>" >> $@.tmp
+ $(Q)echo "const char __dl_ldso__[] attribute_hidden __attribute__ ((weak)) __attribute__ ((section " \
+ "(\".interp\"))) =\""$(RUNTIME_PREFIX)$(MULTILIB_DIR)/$(UCLIBC_LDSO)"\";" >> $@.tmp
+ $(Q)$(SED) -i -e 's://:/:g' $@.tmp
+ $(Q)mv $@.tmp $@
+
+$(interp): $(top_builddir)lib/interp.c | $(sub_headers)
$(compile.c)
$(Q)$(STRIPTOOL) -x -R .note -R .comment $@
$(ldso):
- @cd $(top_builddir); $(MAKE) lib/$(patsubst %.$(MAJOR_VERSION),%,$(notdir $@))
-
+ $(Q)cd $(top_builddir); $(MAKE) lib/$(patsubst %.$(ABI_VERSION),%,$(notdir $@))
$(libc):
- @cd $(top_builddir); $(MAKE) lib/$(patsubst %.$(MAJOR_VERSION),%,$(notdir $@))
+ $(Q)cd $(top_builddir); $(MAKE) lib/$(patsubst %.$(ABI_VERSION),%,$(notdir $@))
CRT := crt1
@@ -305,7 +423,6 @@ endif
ASFLAGS-$(CRT).o := -DL_$(CRT)
ASFLAGS-S$(CRT).o := $(PIEFLAG) -DL_S$(CRT)
$(CRTS): $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/$(CRT).S
- $(Q)$(INSTALL) -d $(dir $@)
$(compile.S)
$(Q)$(STRIPTOOL) -x -R .note -R .comment $@
@@ -314,72 +431,71 @@ CTOR_TARGETS=$(top_builddir)lib/crti.o $(top_builddir)lib/crtn.o
else
CTOR_TARGETS:=
endif
+ifeq ($(HAS_NO_THREADS)$(UCLIBC_HAS_THREADS_NATIVE),)
+$(lib-so-y): $(CTOR_TARGETS)
+endif
ifeq ($(UCLIBC_FORMAT_FDPIC_ELF),y)
CRTRELOC=$(top_builddir)lib/crtreloc.o
$(CRTRELOC): $(top_builddir)lib/%.o : $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/%.c
- $(Q)$(INSTALL) -d $(dir $@)
$(compile.c)
endif
ifneq ($(wildcard $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/initfini.c),)
CFLAGS-initfini.s := -S -g0 $(PICFLAG) -fno-inline-functions -finhibit-size-directive
-$(top_builddir)lib/initfini.s: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/initfini.c
+$(top_builddir)lib/initfini.s: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/initfini.c | $(top_builddir)lib
$(compile.c)
$(top_builddir)lib/defs.h: $(top_builddir)lib/initfini.s
- $(Q)sed -n -e '/@TESTS_BEGIN/,/@TESTS_END/p' $< | \
- gawk -f $(top_srcdir)extra/scripts/defs.awk > $@.tmp
+ $(do_sed) -n -e '/@TESTS_BEGIN/,/@TESTS_END/p' $< | \
+ $(AWK) -f $(top_srcdir)extra/scripts/defs.awk > $@.tmp
$(Q)mv $@.tmp $@
$(top_builddir)lib/crti.S: $(top_builddir)lib/initfini.s $(top_builddir)lib/defs.h
- $(Q)sed -n -e '1,/@HEADER_ENDS/p' \
+ $(do_sed) -n -e '1,/@HEADER_ENDS/p' \
-e '/@_.*_PROLOG_BEGINS/,/@_.*_PROLOG_ENDS/p' \
-e '/@TRAILER_BEGINS/,$$p' $< > $@
$(top_builddir)lib/crtn.S: $(top_builddir)lib/initfini.s
- $(Q)sed -n -e '1,/@HEADER_ENDS/p' \
+ $(do_sed) -n -e '1,/@HEADER_ENDS/p' \
-e '/@_.*_EPILOG_BEGINS/,/@_.*_EPILOG_ENDS/p' \
-e '/@TRAILER_BEGINS/,$$p' $< > $@
$(CTOR_TARGETS): $(top_builddir)lib/%.o : $(top_builddir)lib/%.S
- $(Q)$(INSTALL) -d $(dir $@)
$(compile.S) $(PICFLAG) $(SSP_DISABLE_FLAGS)
else
$(CTOR_TARGETS): $(top_builddir)lib/%.o : $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/%.S
- $(Q)$(INSTALL) -d $(dir $@)
$(compile.S) $(PICFLAG) $(SSP_DISABLE_FLAGS)
endif
-#ifeq ($(TARGET_ARCH),nios)
-#CRTS_COMPAT := $(top_builddir)lib/crt0.o
-#$(CRTS_COMPAT):
-# ln -fs crt1.o $(top_builddir)lib/crt0.o
-#else
CRTS_COMPAT :=
-#endif
-$(crt-y): $(CRTS) $(CTOR_TARGETS) $(CRTS_COMPAT) $(CRTRELOC)
-$(CRTS) $(CTOR_TARGETS) $(CRTS_COMPAT) $(CRTRELOC): | $(headers-y)
+startfiles = $(CRTS) $(CTOR_TARGETS) $(CRTS_COMPAT) $(CRTRELOC)
+startfiles: $(startfiles)
+$(CRTS) $(CTOR_TARGETS) $(CRTS_COMPAT) $(CRTRELOC): | headers
+$(CRTS) $(CTOR_TARGETS) $(CRTS_COMPAT) $(CRTRELOC) \
+ $(LINK_FLAT_CRTS) $(SHARED_START_FILES) $(SHARED_END_FILES): | $(top_builddir)lib
$(top_builddir)lib/$(NONSHARED_LIBNAME): $(libc-nonshared-y)
- $(Q)$(INSTALL) -d $(dir $@)
$(Q)$(RM) $@
$(do_ar)
$(top_builddir)lib/libpthread_nonshared.a: $(libpthread-nonshared-y)
- $(Q)$(INSTALL) -d $(dir $@)
$(Q)$(RM) $@
$(do_ar)
files.dep := $(libc-a-y) $(libc-so-y) $(libc-nonshared-y) \
$(libm-a-y) $(libm-so-y) \
$(libpthread-a-y) $(libpthread-so-y) $(libpthread-nonshared-y) \
- $(libthread_db-a-y) $(libthread_db-so-y) \
+ $(libthread_db-a-y) $(libthread_db-so-y) $(libpthread-generated-y) \
+ $(START_FILE-libpthread.so) $(END_FILE-libpthread.so) \
+ $(PTHREAD_INITFINI:.c=.s) \
$(librt-a-y) $(librt-so-y) $(libresolv-a-y) $(libresolv-so-y) \
$(libcrypt-a-y) $(libcrypt-so-y) $(libutil-a-y) $(libutil-so-y) \
- $(libnsl-a-y) $(libnsl-so-y) $(ldso-y) $(libdl-a-y) $(libdl-so-y)
+ $(libnsl-a-y) $(libnsl-so-y) $(ldso-y) $(libdl-a-y) $(libdl-so-y) \
+ $(libubacktrace-a-y) $(libubacktrace-so-y) $(libuargp-so-y) $(libuargp-a-y)
.depends.dep := \
+ $(patsubst %.s,%.s.dep,$(filter %.s,$(files.dep))) \
$(patsubst %.o,%.o.dep,$(filter %.o,$(files.dep))) \
$(patsubst %.os,%.os.dep,$(filter %.os,$(files.dep))) \
$(patsubst %.oS,%.oS.dep,$(filter %.oS,$(files.dep)))
@@ -391,7 +507,7 @@ files.dep := $(libc-a-y) $(libc-so-y) $(libc-nonshared-y) \
FORCE:
clean: objclean-y headers_clean-y
-realclean: clean
+realclean: clean menuconfig-clean-y
$(Q)$(RM) $(.depends.dep)
objclean-y: $(objclean-y)
diff --git a/README b/README
index f8467fb71..002b6f9e8 100644
--- a/README
+++ b/README
@@ -1,73 +1,48 @@
+ uClibc-ng - a small C Library for Linux
- uClibc - a Small C Library for Linux
- Erik Andersen <andersen@codepoet.org>
+uClibc-ng (aka µClibc-ng/pronounced yew-see-lib-see-next-generation) is a C
+library for developing embedded Linux systems. It is much smaller than the GNU
+C Library, but nearly all applications supported by glibc also work perfectly
+with uClibc-ng.
-uClibc (aka µClibc/pronounced yew-see-lib-see) is a C library for
-developing embedded Linux systems. It is much smaller than the
-GNU C Library, but nearly all applications supported by glibc
-also work perfectly with uClibc. Porting applications from glibc
-to uClibc typically involves just recompiling the source code.
-uClibc even supports shared libraries and threading. It currently
-runs on standard Linux and MMU-less (also known as µClinux)
-systems with support for alpha, ARM, cris, e1, h8300, i386, i960,
-m68k, microblaze, mips/mipsel, PowerPC, SH, SPARC, and v850
-processors.
+uClibc-ng is a spin-off of uClibc from http://www.uclibc.org
+from Erik Andersen and others.
+
+Porting applications from glibc to uClibc-ng typically involves just
+recompiling the source code. uClibc-ng even supports shared libraries and
+threading. It currently runs on standard Linux and MMU-less (also
+known as µClinux) systems with support for ARC, ARM, Blackfin, i386, M68K/Coldfire
+MIPS, MIPS64, PowerPC, SH, Sparc, X86_64 and XTENSA processors.
If you are building an embedded Linux system and you find that
glibc is eating up too much space, you should consider using
-uClibc. If you are building a huge fileserver with 12 Terabytes
+uClibc-ng. If you are building a huge fileserver with 12 Terabytes
of storage, then using glibc may make more sense. Unless, for
example, that 12 Terabytes will be Network Attached Storage and
you plan to burn Linux into the system's firmware...
-uClibc is maintained by Erik Andersen and is licensed under the
+uClibc-ng is maintained by Waldemar Brodkorb and is licensed under the
GNU LESSER GENERAL PUBLIC LICENSE. This license allows you to
make closed source commercial applications using an unmodified
-version of uClibc (Please consider sharing some of the money you
-make ;-). You do not need to give away all your source code just
-because you use uClibc and/or run on Linux. You should, however,
+version of uClibc-ng. You do not need to give away all your source code just
+because you use uClibc-ng and/or run on Linux. You should, however,
carefuly review the license and make certain you understand and
abide by it strictly.
-
For installation instructions, see the file INSTALL.
-uClibc strives to be standards compliant, which means that most
+uClibc-ng strives to be standards compliant, which means that most
documentation written for SuSv3, or for glibc also applies to
-uClibc functions. However, many GNU extensions are not supported
+uClibc-ng functions. However, many GNU extensions are not supported
because they have not been ported, or more importantly, would
-increase the size of uClibc disproportional to the added
-functionality. There is some discussion of these differences
-in the "docs" directory.
+increase the size of uClibc-ng disproportional to the added
+functionality.
-Additional information (recent releases, FAQ, mailing list, bugs,
-etc.) can be found at http://www.uclibc.org/.
+Additional information can be found at http://www.uclibc-ng.org/.
-uClibc may be freely modified and distributed under the terms of
+uClibc-ng may be freely modified and distributed under the terms of
the GNU Lesser General Public License, which can be found in the
-file COPYING.LIB.
-
-Please Note:
-
- There is an unwholesomely huge amount of code out there
- that depends on the presence of GNU libc header files.
- We have GNU libc compatible header files. So we have
- committed a horrible sin in uClibc. We _lie_ and claim
- to be GNU libc in order to force these applications to
- work as their developers intended. This is IMHO,
- pardonable, since these defines are not really intended
- to check for the presence of a particular library, but
- rather are used to define an _interface_. Some programs
- are especially chummy with glibc, and may need this
- behavior disabled by adding CFLAGS+=-D__FORCE_NOGLIBC
-
- If you want to make special exceptions in your code which are
- specifically for uClibc, you can make certain to include features.h,
- and then have your code check for uClibc as follows:
-
- #ifdef __UCLIBC__
- do_something_special();
- #endif
+file COPYING.
And most of all, be sure to have some fun! :-)
- -Erik
+ -Waldemar
diff --git a/Rules.mak b/Rules.mak
index 9512a7d96..fc53ad13a 100644
--- a/Rules.mak
+++ b/Rules.mak
@@ -1,12 +1,23 @@
# Rules.make 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.
#
+# make nano-doc
+# FOO = bar -- recursively expanded variable. Value is remebered verbatim.
+# If it contains references to other variables, these references
+# are expanded whenever this variable is _substituted_.
+# FOO := bar -- simply expanded variable. Right hand is expanded when
+# the variable is _defined_. Therefore faster than =.
+# FOO ?= bar -- set a value only if it is not already set
+# (behaves as =, not :=).
+# FOO += bar -- append; if FOO is not defined, acts like = (not :=).
+
+
# check for proper make version
-ifneq ($(findstring 3.7,$(MAKE_VERSION)),)
+ifneq ($(findstring x3.7,x$(MAKE_VERSION)),)
$(error Your make is too old $(MAKE_VERSION). Go get at least 3.80)
endif
@@ -16,98 +27,150 @@ endif
# file named ".config". Don't mess with this file unless
# you know what you are doing.
+clean_targets := clean realclean distclean \
+ objclean-y headers_clean-y CLEAN_utils
+noconfig_targets := menuconfig config nconfig \
+ oldaskconfig silentoldconfig oldconfig allnoconfig allyesconfig \
+ alldefconfig randconfig defconfig savedefconfig listnewconfig \
+ olddefconfig \
+ xconfig gconfig update-po-config mconf qconf gconf nconf conf \
+ release dist tags help
+
#-----------------------------------------------------------
# If you are running a cross compiler, you will want to set
-# 'CROSS' to something more interesting ... Target
+# 'CROSS_COMPILE' to something more interesting ... Target
# architecture is determined by asking the CC compiler what
# arch it compiles things for, so unless your compiler is
# broken, you should not need to specify TARGET_ARCH.
#
# Most people will set this stuff on the command line, i.e.
-# make CROSS=arm-linux-
+# make CROSS_COMPILE=arm-linux-
# will build uClibc for 'arm'.
+# CROSS is still supported for backward compatibily only
-ifndef CROSS
-CROSS=
-endif
-CC = $(CROSS)gcc
-AR = $(CROSS)ar
-LD = $(CROSS)ld
-NM = $(CROSS)nm
-STRIPTOOL = $(CROSS)strip
+CROSS_COMPILE ?= $(CROSS)
+
+CC = $(CROSS_COMPILE)gcc
+AR = $(CROSS_COMPILE)ar
+LD = $(CROSS_COMPILE)ld
+NM = $(CROSS_COMPILE)nm
+OBJDUMP = $(CROSS_COMPILE)objdump
+STRIPTOOL = $(CROSS_COMPILE)strip
INSTALL = install
LN = ln
RM = rm -f
TAR = tar
+SED = sed
+AWK = awk
STRIP_FLAGS ?= -x -R .note -R .comment
-UNIFDEF := $(top_builddir)extra/scripts/unifdef -UUCLIBC_INTERNAL
-
# Select the compiler needed to build binaries for your development system
HOSTCC = gcc
-BUILD_CFLAGS = -O2 -Wall
-export ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun.*/sparc/ -e s/sparc.*/sparc/ \
- -e s/arm.*/arm/ -e s/sa110/arm/ -e s/sh.*/sh/ \
- -e s/s390x/s390/ -e s/parisc.*/hppa/ \
- -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
- -e s/xtensa.*/xtensa/ )
-
+BUILD_CFLAGS = -Os
#---------------------------------------------------------
# Nothing beyond this point should ever be touched by mere
# mortals. Unless you hang out with the gods, you should
# probably leave all this stuff alone.
+# strip quotes
+qstrip = $(strip $(subst ",,$(1)))
+#"))
+
+# kconfig stuff
+KCONFIG_CONFIG ?= $(top_builddir).config
+KCONFIG_CONFIG := $(abspath $(KCONFIG_CONFIG))
+export KCONFIG_CONFIG
+KCONFIG_AUTOCONFIG := $(dir $(KCONFIG_CONFIG))include/config/auto.conf
+export KCONFIG_AUTOCONFIG
+KCONFIG_TRISTATE := $(dir $(KCONFIG_CONFIG))include/config/tristate.conf
+export KCONFIG_TRISTATE
+srctree := $(abspath $(top_srcdir))
+export srctree
+KCONFIG_AUTOHEADER := $(dir $(KCONFIG_CONFIG))include/generated/autoconf.h
+export KCONFIG_AUTOHEADER
+Kconfig := $(abspath $(top_srcdir)extra/Configs/Config.in)
+
# Pull in the user's uClibc configuration
-ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
--include $(top_builddir).config
+ifeq ($(filter $(noconfig_targets) clean CLEAN_%,$(MAKECMDGOALS)),)
+-include $(KCONFIG_CONFIG)
endif
+TARGET_ARCH:=$(call qstrip,$(TARGET_ARCH))
+ifeq ($(TARGET_ARCH),)
+ARCH ?= $(shell uname -m | $(SED) -e s/i.86/i386/ \
+ -e s/sun.*/sparc/ -e s/sparc.*/sparc/ \
+ -e s/arm.*/arm/ -e s/sa110/arm/ \
+ -e s/sh.*/sh/ \
+ -e s/s390x/s390/ -e s/parisc.*/hppa/ \
+ -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
+ -e s/xtensa.*/xtensa/ )
+else
+ARCH = $(TARGET_ARCH)
+endif
+export ARCH
+
# Make certain these contain a final "/", but no "//"s.
-TARGET_ARCH:=$(shell grep -s '^TARGET_ARCH' $(top_builddir)/.config | sed -e 's/^TARGET_ARCH=//' -e 's/"//g')
-TARGET_ARCH:=$(strip $(subst ",, $(strip $(TARGET_ARCH))))
-TARGET_SUBARCH:=$(shell grep -s '^TARGET_SUBARCH' $(top_builddir)/.config | sed -e 's/^TARGET_SUBARCH=//' -e 's/"//g')
-TARGET_SUBARCH:=$(strip $(subst ",, $(strip $(TARGET_SUBARCH))))
-RUNTIME_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(RUNTIME_PREFIX))))))
-DEVEL_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(DEVEL_PREFIX))))))
-KERNEL_HEADERS:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(KERNEL_HEADERS))))))
-export RUNTIME_PREFIX DEVEL_PREFIX KERNEL_HEADERS
+scrub_path = $(strip $(subst //,/, $(subst ,/, $(call qstrip,$(1)))))
+TARGET_SUBARCH := $(call qstrip,$(TARGET_SUBARCH))
+RUNTIME_PREFIX := $(call scrub_path,$(RUNTIME_PREFIX))
+DEVEL_PREFIX := $(call scrub_path,$(DEVEL_PREFIX))
+MULTILIB_DIR := $(call scrub_path,$(MULTILIB_DIR))
+KERNEL_HEADERS := $(call scrub_path,$(KERNEL_HEADERS))
+export RUNTIME_PREFIX DEVEL_PREFIX KERNEL_HEADERS MULTILIB_DIR
# Now config hard core
-MAJOR_VERSION := 0
-MINOR_VERSION := 9
-SUBLEVEL := 29
+MAJOR_VERSION := 1
+MINOR_VERSION := 0
+SUBLEVEL := 13
EXTRAVERSION :=
VERSION := $(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL)
+ABI_VERSION := $(MAJOR_VERSION)
ifneq ($(EXTRAVERSION),)
VERSION := $(VERSION)$(EXTRAVERSION)
endif
# Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
LC_ALL := C
-export MAJOR_VERSION MINOR_VERSION SUBLEVEL VERSION LC_ALL
+export MAJOR_VERSION MINOR_VERSION SUBLEVEL VERSION ABI_VERSION LC_ALL
LIBC := libc
-SHARED_MAJORNAME := $(LIBC).so.$(MAJOR_VERSION)
-ifneq ($(findstring $(TARGET_ARCH) , hppa64 ia64 mips64 powerpc64 s390x sparc64 x86_64 ),)
+SHARED_LIBNAME := $(LIBC).so.$(ABI_VERSION)
+UBACKTRACE_DSO := libubacktrace.so.$(ABI_VERSION)
+
+UCLIBC_LDSO_NAME := ld-uClibc
+ARCH_NATIVE_BIT := 32
+ifneq ($(findstring $(TARGET_ARCH) , hppa64 ia64 powerpc64 s390x sparc64 x86_64 ),)
UCLIBC_LDSO_NAME := ld64-uClibc
+ARCH_NATIVE_BIT := 64
else
-UCLIBC_LDSO_NAME := ld-uClibc
+ifeq ($(CONFIG_MIPS_N64_ABI),y)
+UCLIBC_LDSO_NAME := ld64-uClibc
+ARCH_NATIVE_BIT := 64
+endif
endif
-UCLIBC_LDSO := $(UCLIBC_LDSO_NAME).so.$(MAJOR_VERSION)
+
+UCLIBC_LDSO := $(UCLIBC_LDSO_NAME).so.$(ABI_VERSION)
NONSHARED_LIBNAME := uclibc_nonshared.a
-libc := $(top_builddir)lib/$(SHARED_MAJORNAME)
-libc.depend := $(top_builddir)lib/$(SHARED_MAJORNAME:.$(MAJOR_VERSION)=)
+libc := $(top_builddir)lib/$(SHARED_LIBNAME)
+libc.depend := $(top_builddir)lib/$(SHARED_LIBNAME:.$(ABI_VERSION)=)
+ifneq ($(ARCH_HAS_NO_SHARED),y)
+libdl.depend := $(top_builddir)lib/libdl.so
+endif
+ifneq ($(HAS_NO_THREADS),y)
+libpthread.depend := $(top_builddir)lib/libpthread.so
+endif
interp := $(top_builddir)lib/interp.os
ldso := $(top_builddir)lib/$(UCLIBC_LDSO)
-headers_dep := $(top_builddir)include/bits/sysnum.h
+headers_dep := $(top_builddir)include/bits/sysnum.h \
+ $(top_builddir)include/bits/uClibc_config.h
sub_headers := $(headers_dep)
#LIBS :=$(interp) -L$(top_builddir)lib -lc
-LIBS := $(interp) -L$(top_builddir)lib $(libc:.$(MAJOR_VERSION)=)
+LIBS := $(interp) -L$(top_builddir)lib $(libc:.$(ABI_VERSION)=)
# Make sure DESTDIR and PREFIX can be used to install
# PREFIX is a uClibcism while DESTDIR is a common GNUism
@@ -124,8 +187,8 @@ endif
comma:=,
space:= #
-ifndef CROSS
-CROSS=$(subst ",, $(strip $(CROSS_COMPILER_PREFIX)))
+ifeq ($(CROSS_COMPILE),)
+CROSS_COMPILE=$(call qstrip,$(CROSS_COMPILER_PREFIX))
endif
# A nifty macro to make testing gcc features easier
@@ -136,48 +199,155 @@ check_as=$(shell \
if $(CC) -Wa,$(1) -Wa,-Z -c -o /dev/null -xassembler /dev/null > /dev/null 2>&1; \
then echo "-Wa,$(1)"; fi)
check_ld=$(shell \
- if $(LD) $(1) -o /dev/null -b binary /dev/null > /dev/null 2>&1; \
+ if $(CC) $(LDFLAG-fuse-ld) $(CFLAG_-Wl--no-warn-mismatch) -Wl,$(1) $(CFLAG_-nostdlib) -o /dev/null -Wl,-b,binary /dev/null > /dev/null 2>&1; \
then echo "$(1)"; fi)
+# Use variable indirection here so that we can have variable
+# names with fun chars in them like equal signs
+define check-tool-var
+ifeq ($(filter $(clean_targets) CLEAN_%,$(MAKECMDGOALS)),)
+_v = $(2)_$(3)
+ifndef $$(_v)
+$$(_v) := $$(call $(1),$(subst %, ,$(3)))
+export $$(_v)
+endif
+endif
+endef
+
+# Usage: check-gcc-var,<flag>
+# Check the C compiler to see if it supports <flag>.
+# Export the variable CFLAG_<flag> if it does.
+define check-gcc-var
+$(call check-tool-var,check_gcc,CFLAG,$(1))
+endef
+# Usage: check-as-var,<flag>
+# Check the assembler to see if it supports <flag>. Export the
+# variable ASFLAG_<flag> if it does (for invoking the assembler),
+# as well CFLAG_-Wa<flag> (for invoking the compiler driver).
+define check-as-var
+$(call check-tool-var,check_as,ASFLAG,$(1))
+_v = CFLAG_-Wa$(1)
+export $$(_v) = $$(if $$(ASFLAG_$(1)),-Wa$$(comma)$$(ASFLAG_$(1)))
+endef
+# Usage: check-ld-var,<flag>
+# Check the linker to see if it supports <flag>. Export the
+# variable LDFLAG_<flag> if it does (for invoking the linker),
+# as well CFLAG_-Wl<flag> (for invoking the compiler driver).
+define check-ld-var
+$(call check-tool-var,check_ld,LDFLAG,$(1))
+_v = CFLAG_-Wl$(1)
+export $$(_v) = $$(if $$(LDFLAG_$(1)),-Wl$$(comma)$$(LDFLAG_$(1)))
+endef
+# Usage: cache-output-var,<variable>,<shell command>
+# Execute <shell command> and cache the output in <variable>.
+define cache-output-var
+ifndef $(1)
+$(1) := $$(shell $(2))
+export $(1)
+endif
+endef
+
+
ARFLAGS:=cr
+# Note: The check for -nostdlib has to be before all calls to check_ld
+$(eval $(call check-gcc-var,-nostdlib))
+$(eval $(call check-gcc-var,-nostartfiles))
+# deliberately not named CFLAG-fuse-ld since unchecked and from user
+LDFLAG-fuse-ld := $(filter -fuse-ld=%,$(call qstrip,$(UCLIBC_EXTRA_CFLAGS)))
+# failed to merge target specific data of file /dev/null
+# Could use -Wl,--script,$(top_srcdir)extra/scripts/none.lds as well.
+$(eval $(call check-ld-var,--no-warn-mismatch))
+
+$(eval $(call cache-output-var,GCC_VER,$(CC) -dumpversion))
+GCC_VER := $(subst ., ,$(GCC_VER))
+GCC_MAJOR_VER ?= $(word 1,$(GCC_VER))
+GCC_MINOR_VER ?= $(word 2,$(GCC_VER))
+
# Flags in OPTIMIZATION are used only for non-debug builds
+
OPTIMIZATION:=
+OPTIMIZATION-$(GCC_MAJOR_VER):=
+OPTIMIZATION-$(GCC_MAJOR_VER).$(GCC_MINOR_VER):=
+
# Use '-Os' optimization if available, else use -O2, allow Config to override
-OPTIMIZATION+=$(call check_gcc,-Os,-O2)
+$(eval $(call check-gcc-var,-Os))
+ifneq ($(CFLAG_-Os),)
+OPTIMIZATION += $(CFLAG_-Os)
+else
+$(eval $(call check-gcc-var,-O2))
+OPTIMIZATION += $(CFLAG_-O2)
+endif
# Use the gcc 3.4 -funit-at-a-time optimization when available
-OPTIMIZATION+=$(call check_gcc,-funit-at-a-time,)
+$(eval $(call check-gcc-var,-funit-at-a-time))
+OPTIMIZATION-3.4 += $(CFLAG_-funit-at-a-time)
+$(eval $(call check-gcc-var,-fstrict-aliasing))
+OPTIMIZATION += $(CFLAG_-fstrict-aliasing)
-GCC_MAJOR_VER?=$(shell $(CC) -dumpversion | cut -d . -f 1)
-#GCC_MINOR_VER?=$(shell $(CC) -dumpversion | cut -d . -f 2)
+# CPU_CFLAGS-y contain options which are not warnings,
+# not include or library paths, and not optimizations.
-ifeq ($(GCC_MAJOR_VER),4)
-# shrinks code, results are from 4.0.2
-# 0.36%
-OPTIMIZATION+=$(call check_gcc,-fno-tree-loop-optimize,)
-# 0.34%
-OPTIMIZATION+=$(call check_gcc,-fno-tree-dominator-opts,)
-# 0.1%
-OPTIMIZATION+=$(call check_gcc,-fno-strength-reduce,)
+# Why -funsigned-char: I hunted a bug related to incorrect
+# sign extension of 'char' type for 10 hours straight. Not fun.
+CPU_CFLAGS-y := -funsigned-char -fno-builtin
+
+$(eval $(call check-gcc-var,-fno-asm))
+CPU_CFLAGS-y += $(CFLAG_-fno-asm)
+$(eval $(call check-gcc-var,-fmerge-all-constants))
+CPU_CFLAGS-y += $(CFLAG_-fmerge-all-constants)
+
+ifeq ($(UCLIBC_HAS_SOFT_FLOAT),y)
+ifneq ($(TARGET_ARCH),bfin)
+ifneq ($(TARGET_ARCH),lm32)
+ifneq ($(TARGET_ARCH),nios2)
+ifneq ($(TARGET_ARCH),sh)
+ifneq ($(TARGET_ARCH),c6x)
+ifneq ($(TARGET_ARCH),h8300)
+CPU_CFLAGS-y += -msoft-float
+endif
+endif
+endif
+endif
+endif
endif
+endif
+
+$(eval $(call check-gcc-var,-std=gnu99))
+CPU_CFLAGS-y += $(CFLAG_-std=gnu99)
CPU_CFLAGS-$(UCLIBC_FORMAT_SHARED_FLAT) += -mid-shared-library
CPU_CFLAGS-$(UCLIBC_FORMAT_FLAT_SEP_DATA) += -msep-data
+CPU_LDFLAGS-$(ARCH_LITTLE_ENDIAN) += -Wl,-EL
+CPU_LDFLAGS-$(ARCH_BIG_ENDIAN) += -Wl,-EB
+
PICFLAG-y := -fPIC
PICFLAG-$(UCLIBC_FORMAT_FDPIC_ELF) := -mfdpic
+PICFLAG-$(UCLIBC_FORMAT_DSBT_ELF) := -mdsbt -fpic
PICFLAG := $(PICFLAG-y)
PIEFLAG_NAME:=-fPIE
+$(eval $(call check-gcc-var,-fdata-sections))
+$(eval $(call check-gcc-var,-ffunction-sections))
+
# Some nice CPU specific optimizations
ifeq ($(TARGET_ARCH),i386)
- OPTIMIZATION+=$(call check_gcc,-fomit-frame-pointer,)
+$(eval $(call check-gcc-var,-fomit-frame-pointer))
+ OPTIMIZATION += $(CFLAG_-fomit-frame-pointer)
+ifeq ($(CONFIG_386)$(CONFIG_486)$(CONFIG_586),y)
+ # TODO: Change this to a gcc version check. This bug
+ # should be fixed with at least gcc-4.3.
+ # Non-SSE capable processor.
# NB: this may make SSE insns segfault!
# -O1 -march=pentium3, -Os -msse etc are known to be affected.
- # TODO: conditionally bump to 4
- # (see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13685)
- OPTIMIZATION+=$(call check_gcc,-mpreferred-stack-boundary=4,)
+ # See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13685
+ # -m32 is needed if host is 64-bit
+ OPTIMIZATION+=$(call check_gcc,-m32 -mpreferred-stack-boundary=2,)
+else
+$(eval $(call check-gcc-var,-mpreferred-stack-boundary=4))
+ OPTIMIZATION += $(CFLAG_-mpreferred-stack-boundary=4)
+endif
# Choice of alignment (please document why!)
# -falign-labels: in-line labels
@@ -186,18 +356,6 @@ ifeq ($(TARGET_ARCH),i386)
# -falign-jumps: reachable only by a jump
# Generic: no alignment at all (smallest code)
GCC_FALIGN=$(call check_gcc,-falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1,-malign-jumps=1 -malign-loops=1)
-ifeq ($(CONFIG_K7),y)
- # Align functions to four bytes, use default for jumps and loops (why?)
- GCC_FALIGN=$(call check_gcc,-falign-functions=4 -falign-labels=1,-malign-functions=4)
-endif
-ifeq ($(CONFIG_CRUSOE),y)
- # Use compiler's default for functions, jumps and loops (why?)
- GCC_FALIGN=$(call check_gcc,-falign-functions=0 -falign-labels=1,-malign-functions=0)
-endif
-ifeq ($(CONFIG_CYRIXIII),y)
- # Use compiler's default for functions, jumps and loops (why?)
- GCC_FALIGN=$(call check_gcc,-falign-functions=0 -falign-labels=1,-malign-functions=0)
-endif
OPTIMIZATION+=$(GCC_FALIGN)
# Putting each function and data object into its own section
@@ -215,32 +373,13 @@ endif
# It specifies 4 byte align for .text even if not told to do so:
# Idx Name Size VMA LMA File off Algn
# 0 .text xxxxxxxx 00000000 00000000 xxxxxxxx 2**2 <===!
- CPU_CFLAGS-y += $(call check_gcc,-ffunction-sections -fdata-sections,)
-ifneq ($(call check_ld,--sort-common,),)
- CPU_LDFLAGS-y += -Wl,--sort-common
-endif
-ifneq ($(call check_ld,--sort-section alignment),)
- CPU_LDFLAGS-y += -Wl,--sort-section,alignment
-endif
+ CPU_CFLAGS-y += $(CFLAG_-ffunction-sections) $(CFLAG_-fdata-sections)
+ CPU_LDFLAGS-y += $(CFLAG_-Wl--sort-common)
+$(eval $(call check-ld-var,--sort-section=alignment))
+ CPU_LDFLAGS-y += $(CFLAG_-Wl--sort-section=alignment)
CPU_LDFLAGS-y+=-m32
CPU_CFLAGS-y+=-m32
- CPU_CFLAGS-$(CONFIG_386)+=-march=i386
- CPU_CFLAGS-$(CONFIG_486)+=-march=i486
- CPU_CFLAGS-$(CONFIG_ELAN)+=-march=i486
- CPU_CFLAGS-$(CONFIG_586)+=-march=i586
- CPU_CFLAGS-$(CONFIG_586MMX)+=$(call check_gcc,-march=pentium-mmx,-march=i586)
- CPU_CFLAGS-$(CONFIG_686)+=-march=i686
- CPU_CFLAGS-$(CONFIG_PENTIUMII)+=$(call check_gcc,-march=pentium2,-march=i686)
- CPU_CFLAGS-$(CONFIG_PENTIUMIII)+=$(call check_gcc,-march=pentium3,-march=i686)
- CPU_CFLAGS-$(CONFIG_PENTIUM4)+=$(call check_gcc,-march=pentium4,-march=i686)
- CPU_CFLAGS-$(CONFIG_K6)+=$(call check_gcc,-march=k6,-march=i586)
- CPU_CFLAGS-$(CONFIG_K7)+=$(call check_gcc,-march=athlon,-march=i686)
- CPU_CFLAGS-$(CONFIG_CRUSOE)+=-march=i686
- CPU_CFLAGS-$(CONFIG_WINCHIPC6)+=$(call check_gcc,-march=winchip-c6,-march=i586)
- CPU_CFLAGS-$(CONFIG_WINCHIP2)+=$(call check_gcc,-march=winchip2,-march=i586)
- CPU_CFLAGS-$(CONFIG_CYRIXIII)+=$(call check_gcc,-march=c3,-march=i486)
- CPU_CFLAGS-$(CONFIG_NEHEMIAH)+=$(call check_gcc,-march=c3-2,-march=i686)
endif
ifeq ($(TARGET_ARCH),sparc)
@@ -251,90 +390,44 @@ ifeq ($(TARGET_ARCH),sparc)
endif
ifeq ($(TARGET_ARCH),arm)
- OPTIMIZATION+=-fstrict-aliasing
- CPU_LDFLAGS-$(ARCH_LITTLE_ENDIAN)+=-Wl,-EL
- CPU_LDFLAGS-$(ARCH_BIG_ENDIAN)+=-Wl,-EB
CPU_CFLAGS-$(ARCH_LITTLE_ENDIAN)+=-mlittle-endian
CPU_CFLAGS-$(ARCH_BIG_ENDIAN)+=-mbig-endian
- CPU_CFLAGS-$(CONFIG_GENERIC_ARM)+=
- CPU_CFLAGS-$(CONFIG_ARM610)+=-mtune=arm610 -march=armv3
- CPU_CFLAGS-$(CONFIG_ARM710)+=-mtune=arm710 -march=armv3
- CPU_CFLAGS-$(CONFIG_ARM7TDMI)+=-mtune=arm7tdmi -march=armv4t
- CPU_CFLAGS-$(CONFIG_ARM720T)+=-mtune=arm7tdmi -march=armv4t
- CPU_CFLAGS-$(CONFIG_ARM920T)+=-mtune=arm9tdmi -march=armv4t
- CPU_CFLAGS-$(CONFIG_ARM922T)+=-mtune=arm9tdmi -march=armv4t
- CPU_CFLAGS-$(CONFIG_ARM926T)+=-mtune=arm9tdmi -march=armv5t
- CPU_CFLAGS-$(CONFIG_ARM10T)+=-mtune=arm10tdmi -march=armv5t
- CPU_CFLAGS-$(CONFIG_ARM1136JF_S)+=-mtune=arm1136jf-s -march=armv6
- CPU_CFLAGS-$(CONFIG_ARM1176JZ_S)+=-mtune=arm1176jz-s -march=armv6
- CPU_CFLAGS-$(CONFIG_ARM1176JZF_S)+=-mtune=arm1176jzf-s -march=armv6
- CPU_CFLAGS-$(CONFIG_ARM_SA110)+=-mtune=strongarm110 -march=armv4
- CPU_CFLAGS-$(CONFIG_ARM_SA1100)+=-mtune=strongarm1100 -march=armv4
- CPU_CFLAGS-$(CONFIG_ARM_XSCALE)+=$(call check_gcc,-mtune=xscale,-mtune=strongarm110)
- CPU_CFLAGS-$(CONFIG_ARM_XSCALE)+=-march=armv5te -Wa,-mcpu=xscale
- CPU_CFLAGS-$(CONFIG_ARM_IWMMXT)+=-march=iwmmxt -Wa,-mcpu=iwmmxt -mabi=iwmmxt
- CPU_CFLAGS-$(CONFIG_ARM_CORTEX_M3)+=-mcpu=cortex-m3 -mthumb
- CPU_CFLAGS-$(CONFIG_ARM_CORTEX_M1)+=-mcpu=cortex-m1 -mthumb
+ CPU_CFLAGS-$(COMPILE_IN_THUMB_MODE)+=-mthumb
+endif
+
+ifeq ($(TARGET_ARCH),metag)
+ SYMBOL_PREFIX=_
+ CPU_CFLAGS-$(CONFIG_META_1_2)+=
+ CPU_CFLAGS-$(CONFIG_META_2_1)+=-Wa,-mcpu=metac21
endif
ifeq ($(TARGET_ARCH),mips)
- CPU_LDFLAGS-$(ARCH_LITTLE_ENDIAN)+=-Wl,-EL
- CPU_LDFLAGS-$(ARCH_BIG_ENDIAN)+=-Wl,-EB
- CPU_CFLAGS-$(CONFIG_MIPS_ISA_1)+=-mips1
- CPU_CFLAGS-$(CONFIG_MIPS_ISA_2)+=-mips2 -mtune=mips2
- CPU_CFLAGS-$(CONFIG_MIPS_ISA_3)+=-mips3 -mtune=mips3
- CPU_CFLAGS-$(CONFIG_MIPS_ISA_4)+=-mips4 -mtune=mips4
- CPU_CFLAGS-$(CONFIG_MIPS_ISA_MIPS32)+=-mips32 -mtune=mips32
- CPU_CFLAGS-$(CONFIG_MIPS_ISA_MIPS64)+=-mips64 -mtune=mips32
- ifeq ($(strip $(ARCH_BIG_ENDIAN)),y)
- CPU_LDFLAGS-$(CONFIG_MIPS_N64_ABI)+=-Wl,-melf64btsmip
- CPU_LDFLAGS-$(CONFIG_MIPS_O32_ABI)+=-Wl,-melf32btsmip
- endif
- ifeq ($(strip $(ARCH_LITTLE_ENDIAN)),y)
- CPU_LDFLAGS-$(CONFIG_MIPS_N64_ABI)+=-Wl,-melf64ltsmip
- CPU_LDFLAGS-$(CONFIG_MIPS_O32_ABI)+=-Wl,-melf32ltsmip
- endif
+ OPTIMIZATION+=-mno-split-addresses
CPU_CFLAGS-$(CONFIG_MIPS_N64_ABI)+=-mabi=64
CPU_CFLAGS-$(CONFIG_MIPS_O32_ABI)+=-mabi=32
CPU_CFLAGS-$(CONFIG_MIPS_N32_ABI)+=-mabi=n32
-endif
-
-ifeq ($(TARGET_ARCH),nios)
- CPU_LDFLAGS-y+=-Wl,-m32
- CPU_CFLAGS-y+=-Wl,-m32
+ CPU_LDFLAGS-y += $(CPU_CFLAGS)
endif
ifeq ($(TARGET_ARCH),sh)
- OPTIMIZATION+=-fstrict-aliasing
- OPTIMIZATION+= $(call check_gcc,-mprefergot,)
- CPU_LDFLAGS-$(ARCH_LITTLE_ENDIAN)+=-Wl,-EL
- CPU_LDFLAGS-$(ARCH_BIG_ENDIAN)+=-Wl,-EB
+$(eval $(call check-gcc-var,-mprefergot))
+ OPTIMIZATION += $(CFLAG_-mprefergot)
CPU_CFLAGS-$(ARCH_LITTLE_ENDIAN)+=-ml
CPU_CFLAGS-$(ARCH_BIG_ENDIAN)+=-mb
CPU_CFLAGS-$(CONFIG_SH2)+=-m2
CPU_CFLAGS-$(CONFIG_SH3)+=-m3
-ifeq ($(UCLIBC_HAS_FLOATS),y)
+ifeq ($(UCLIBC_HAS_FPU),y)
CPU_CFLAGS-$(CONFIG_SH2A)+=-m2a
CPU_CFLAGS-$(CONFIG_SH4)+=-m4
+ CPU_CFLAGS-$(CONFIG_SH4A)+=-m4a
else
CPU_CFLAGS-$(CONFIG_SH2A)+=-m2a-nofpu
CPU_CFLAGS-$(CONFIG_SH4)+=-m4-nofpu
+ CPU_CFLAGS-$(CONFIG_SH4A)+=-m4a-nofpu
endif
endif
-ifeq ($(TARGET_ARCH),sh64)
- OPTIMIZATION+=-fstrict-aliasing
- CPU_LDFLAGS-$(ARCH_LITTLE_ENDIAN):=-Wl,-EL
- CPU_LDFLAGS-$(ARCH_BIG_ENDIAN):=-Wl,-EB
- CPU_CFLAGS-$(ARCH_LITTLE_ENDIAN):=-ml
- CPU_CFLAGS-$(ARCH_BIG_ENDIAN):=-mb
- CPU_CFLAGS-$(CONFIG_SH5)+=-m5-32media
-endif
-
ifeq ($(TARGET_ARCH),h8300)
- SYMBOL_PREFIX=_
- CPU_LDFLAGS-$(CONFIG_H8300H)+= -Wl,-ms8300h
- CPU_LDFLAGS-$(CONFIG_H8S) += -Wl,-ms8300s
CPU_CFLAGS-$(CONFIG_H8300H) += -mh -mint32
CPU_CFLAGS-$(CONFIG_H8S) += -ms -mint32
endif
@@ -362,7 +455,7 @@ ifeq ($(TARGET_ARCH),powerpc)
PIEFLAG_NAME:=-fpie
PPC_HAS_REL16:=$(shell echo -e "\t.text\n\taddis 11,30,_GLOBAL_OFFSET_TABLE_-.@ha" | $(CC) -c -x assembler -o /dev/null - 2> /dev/null && echo -n y || echo -n n)
CPU_CFLAGS-$(PPC_HAS_REL16)+= -DHAVE_ASM_PPC_REL16
- CPU_CFLAGS-$(CONFIG_E500) += "-D__NO_MATH_INLINES -D__NO_LONG_DOUBLE_MATH"
+ CPU_CFLAGS-$(CONFIG_E500) += "-D__NO_MATH_INLINES"
endif
@@ -380,14 +473,12 @@ endif
endif
ifeq ($(TARGET_ARCH),frv)
- CPU_LDFLAGS-$(CONFIG_FRV)+=-Wl,-melf32frvfd
# Using -pie causes the program to have an interpreter, which is
# forbidden, so we must make do with -shared. Unfortunately,
# -shared by itself would get us global function descriptors
# and calls through PLTs, dynamic resolution of symbols, etc,
# which would break as well, but -Bsymbolic comes to the rescue.
- export LDPIEFLAG:=-Wl,-shared -Wl,-Bsymbolic
- UCLIBC_LDSO=ld.so.1
+ CPU_LDFLAGS-y += -Wl,-melf32frvfd -Wl,-Bsymbolic
endif
ifeq ($(strip $(TARGET_ARCH)),avr32)
@@ -396,110 +487,150 @@ ifeq ($(strip $(TARGET_ARCH)),avr32)
CPU_LDFLAGS-$(CONFIG_LINKRELAX) += --relax
endif
-ifeq ($(TARGET_ARCH),i960)
- SYMBOL_PREFIX=_
+ifeq ($(TARGET_ARCH),c6x)
+ PIEFLAG:=
+ CPU_CFLAGS-$(CONFIG_TMS320C64X) += -march=c64x
+ CPU_CFLAGS-$(CONFIG_TMS320C64XPLUS) += -march=c64x+
+ CPU_CFLAGS-$(ARCH_LITTLE_ENDIAN)+=-mlittle-endian
+ CPU_CFLAGS-$(ARCH_BIG_ENDIAN)+=-mbig-endian
+ CPU_LDFLAGS-y += $(CPU_CFLAGS)
endif
-ifeq ($(TARGET_ARCH),microblaze)
- SYMBOL_PREFIX=_
+ifeq ($(TARGET_ARCH),arc)
+ CPU_CFLAGS-y += -mlock -mswape
+ CPU_CFLAGS-$(CONFIG_ARC_CPU_700) += -mA7
+ CPU_CFLAGS-$(CONFIG_ARC_CPU_HS) += -mcpu=archs
+ CPU_LDFLAGS-y += $(CPU_CFLAGS) -marclinux
endif
-ifeq ($(TARGET_ARCH),v850)
- SYMBOL_PREFIX=_
+$(eval $(call check-gcc-var,$(PIEFLAG_NAME)))
+PIEFLAG := $(CFLAG_$(PIEFLAG_NAME))
+ifeq ($(PIEFLAG),)
+PIEFLAG := $(PICFLAG)
endif
+# We need to keep track of both the CC PIE flag (above) as
+# well as the LD PIE flag (below) because we can't rely on
+# gcc passing -pie if we used -fPIE. We need to directly use -pie
+# instead of -Wl,-pie as gcc picks up the wrong startfile/endfile
+$(eval $(call cache-output-var,LDPIEFLAG,$(CC) -Wl$(comma)--help 2>/dev/null | grep -q -- -pie && echo "-pie"))
-# Keep the check_gcc from being needlessly executed
-ifndef PIEFLAG
-ifneq ($(UCLIBC_BUILD_PIE),y)
-export PIEFLAG:=
-else
-export PIEFLAG:=$(call check_gcc,$(PIEFLAG_NAME),$(PICFLAG))
+# Check for --as-needed support in linker
+ifndef LD_FLAG_ASNEEDED
+_LD_FLAG_ASNEEDED:=$(shell $(CC) -Wl,--help 2>/dev/null | grep -- --as-needed)
+ifneq ($(_LD_FLAG_ASNEEDED),)
+export LD_FLAG_ASNEEDED:=--as-needed
endif
endif
-# We need to keep track of both the CC PIE flag (above) as
-# well as the LD PIE flag (below) because we can't rely on
-# gcc passing -pie if we used -fPIE
-ifndef LDPIEFLAG
-ifneq ($(UCLIBC_BUILD_PIE),y)
-export LDPIEFLAG:=
-else
-export LDPIEFLAG:=$(shell $(LD) --help 2>/dev/null | grep -q -- -pie && echo "-Wl,-pie")
+ifndef LD_FLAG_NO_ASNEEDED
+ifdef LD_FLAG_ASNEEDED
+export LD_FLAG_NO_ASNEEDED:=--no-as-needed
endif
endif
-
-# Check for AS_NEEDED support in linker script (binutils>=2.16.1 has it)
-ifndef ASNEEDED
-export ASNEEDED:=$(shell $(LD) --help 2>/dev/null | grep -q -- --as-needed && echo "AS_NEEDED ( $(UCLIBC_LDSO) )" || echo "$(UCLIBC_LDSO)")
+ifndef CC_FLAG_ASNEEDED
+ifdef LD_FLAG_ASNEEDED
+export CC_FLAG_ASNEEDED:=-Wl,$(LD_FLAG_ASNEEDED)
endif
-
-# Add a bunch of extra pedantic annoyingly strict checks
-XWARNINGS=$(subst ",, $(strip $(WARNINGS))) -Wstrict-prototypes -fno-strict-aliasing
-ifeq ($(EXTRA_WARNINGS),y)
-XWARNINGS+=-Wnested-externs -Wshadow -Wmissing-noreturn -Wmissing-format-attribute -Wformat=2
-XWARNINGS+=-Wmissing-prototypes -Wmissing-declarations
-XWARNINGS+=-Wnonnull -Wundef
-# works only w/ gcc-3.4 and up, can't be checked for gcc-3.x w/ check_gcc()
-#XWARNINGS+=-Wdeclaration-after-statement
endif
-XARCH_CFLAGS=$(subst ",, $(strip $(ARCH_CFLAGS)))
-CPU_CFLAGS=$(subst ",, $(strip $(CPU_CFLAGS-y)))
-
-SSP_DISABLE_FLAGS ?= $(call check_gcc,-fno-stack-protector,)
-ifeq ($(UCLIBC_BUILD_SSP),y)
-SSP_CFLAGS := $(call check_gcc,-fno-stack-protector-all,)
-SSP_CFLAGS += $(call check_gcc,-fstack-protector,)
-SSP_ALL_CFLAGS ?= $(call check_gcc,-fstack-protector-all,)
-else
-SSP_CFLAGS := $(SSP_DISABLE_FLAGS)
+ifndef CC_FLAG_NO_ASNEEDED
+ifdef LD_FLAG_NO_ASNEEDED
+export CC_FLAG_NO_ASNEEDED:=-Wl,$(LD_FLAG_NO_ASNEEDED)
endif
+endif
+link.asneeded = $(if $(findstring yy,$(CC_FLAG_ASNEEDED)$(CC_FLAG_NO_ASNEEDED)),$(CC_FLAG_ASNEEDED) $(1) $(CC_FLAG_NO_ASNEEDED))
-NOSTDLIB_CFLAGS:=$(call check_gcc,-nostdlib,)
-# Some nice CFLAGS to work with
-CFLAGS := -include $(top_builddir)include/libc-symbols.h \
- $(XWARNINGS) $(CPU_CFLAGS) $(SSP_CFLAGS) \
- -fno-builtin -nostdinc -I$(top_builddir)include -I. \
- -I$(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)
+# Check for AS_NEEDED support in linker script (binutils>=2.16.1 has it)
+ifndef ASNEEDED
+export ASNEEDED:=$(shell $(CC) -Wl,--help 2>/dev/null | grep -q -- --as-needed && echo "AS_NEEDED ( $(UCLIBC_LDSO) )" || echo "$(UCLIBC_LDSO)")
-# Make sure that we can be built with non-C99 compilers, too.
-# Use __\1__ instead.
-CFLAGS += $(call check_gcc,-fno-asm,)
-ifneq ($(strip $(UCLIBC_EXTRA_CFLAGS)),"")
-CFLAGS += $(subst ",, $(UCLIBC_EXTRA_CFLAGS))
+# Only used in installed libc.so linker script
+ifeq ($(UCLIBC_HAS_BACKTRACE),y)
+ifeq ($(HARDWIRED_ABSPATH),y)
+UBACKTRACE_FULL_NAME := $(subst //,/,$(RUNTIME_PREFIX)$(MULTILIB_DIR)/$(UBACKTRACE_DSO))
+else
+UBACKTRACE_FULL_NAME := $(UBACKTRACE_DSO)
endif
-
-LDADD_LIBFLOAT=
-ifeq ($(UCLIBC_HAS_SOFT_FLOAT),y)
-# If -msoft-float isn't supported, we want an error anyway.
-# Hmm... might need to revisit this for arm since it has 2 different
-# soft float encodings.
-ifneq ($(TARGET_ARCH),nios)
-ifneq ($(TARGET_ARCH),nios2)
-ifneq ($(TARGET_ARCH),sh)
-CFLAGS += -msoft-float
+export UBACKTRACE_ASNEEDED:=$(shell $(CC) -Wl,--help 2>/dev/null | grep -q -- --as-needed && \
+ echo "GROUP ( AS_NEEDED ( $(UBACKTRACE_FULL_NAME) ) )" || \
+ echo "GROUP ( $(UBACKTRACE_FULL_NAME) )")
+else
+export UBACKTRACE_ASNEEDED:=""
endif
+ifeq ($(UCLIBC_HAS_ARGP),y)
+ifeq ($(HARDWIRED_ABSPATH),y)
+# Only used in installed libc.so linker script
+UARGP_FULL_NAME := $(subst //,/,$(RUNTIME_PREFIX)$(MULTILIB_DIR)/libuargp.so.$(MAJOR_VERSION))
+else
+UARGP_FULL_NAME := libuargp.so.$(MAJOR_VERSION)
endif
+export UARGP_ASNEEDED:=$(shell $(CC) -Wl,--help 2>/dev/null | grep -q -- --as-needed && \
+ echo "GROUP ( AS_NEEDED ( $(UARGP_FULL_NAME) ) )" || \
+ echo "GROUP ( $(UARGP_FULL_NAME) )")
+else
+export UARGP_ASNEEDED:=""
endif
-ifeq ($(TARGET_ARCH),arm)
-# No longer needed with current toolchains, but leave it here for now.
-# If anyone is actually still using gcc 2.95 (say), they can uncomment it.
-# LDADD_LIBFLOAT=-lfloat
endif
+
+# Add a bunch of extra pedantic annoyingly strict checks
+WARNING_FLAGS = -Wstrict-prototypes -Wstrict-aliasing
+ifeq ($(EXTRA_WARNINGS),y)
+WARNING_FLAGS += \
+ -Wformat=2 \
+ -Wmissing-noreturn \
+ -Wmissing-format-attribute \
+ -Wmissing-prototypes \
+ -Wmissing-declarations \
+ -Wnested-externs \
+ -Wnonnull \
+ -Wold-style-declaration \
+ -Wold-style-definition \
+ -Wshadow \
+ -Wundef
+# Works only w/ gcc-3.4 and up, can't be checked for gcc-3.x w/ check_gcc()
+#WARNING_FLAGS-gcc-4 += -Wdeclaration-after-statement
+endif
+WARNING_FLAGS += $(WARNING_FLAGS-gcc-$(GCC_MAJOR_VER))
+$(foreach w,$(WARNING_FLAGS),$(eval $(call check-gcc-var,$(w))))
+XWARNINGS = $(call qstrip,$(WARNINGS)) $(foreach w,$(WARNING_FLAGS),$(CFLAG_$(w)))
+
+CPU_CFLAGS=$(call qstrip,$(CPU_CFLAGS-y))
+
+# Save the tested flag in a single variable and force it to be
+# evaluated just once. Then use that computed value.
+$(eval $(call check-gcc-var,-fno-stack-protector))
+SSP_DISABLE_FLAGS ?= $(CFLAG_-fno-stack-protector)
+ifeq ($(UCLIBC_BUILD_SSP),y)
+$(eval $(call check-gcc-var,-fno-stack-protector-all))
+$(eval $(call check-gcc-var,-fstack-protector))
+$(eval $(call check-gcc-var,-fstack-protector-all))
+SSP_CFLAGS := $(CFLAG_-fno-stack-protector-all)
+SSP_CFLAGS += $(CFLAG_-fstack-protector)
+SSP_ALL_CFLAGS ?= $(CFLAG_-fstack-protector-all)
+else
+SSP_CFLAGS := $(SSP_DISABLE_FLAGS)
endif
-# Please let us see private headers' parts
-CFLAGS += -DUCLIBC_INTERNAL
+# Collect all CFLAGS components
+CFLAGS := $(XWARNINGS) $(CPU_CFLAGS) $(SSP_CFLAGS) \
+ -nostdinc -I$(top_builddir)include \
+ -I$(top_srcdir)include -include libc-symbols.h \
+ -I$(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH) \
+ -I$(top_srcdir)libc/sysdeps/linux \
+ -I$(top_srcdir)ldso/ldso/$(TARGET_ARCH) \
+ -I$(top_srcdir)ldso/include -I.
# We need this to be checked within libc-symbols.h
ifneq ($(HAVE_SHARED),y)
CFLAGS += -DSTATIC
endif
-CFLAGS += $(call check_gcc,-std=gnu99,)
-
-LDFLAGS_NOSTRIP:=$(CPU_LDFLAGS-y) -Wl,-shared \
- -Wl,--warn-common -Wl,--warn-once -Wl,-z,combreloc
+$(eval $(call check-ld-var,--warn-once))
+$(eval $(call check-ld-var,--sort-common))
+$(eval $(call check-ld-var,--discard-all))
+LDFLAGS_NOSTRIP:=$(LDFLAG-fuse-ld) $(CPU_LDFLAGS-y) -shared \
+ -Wl,--warn-common $(CFLAG_-Wl--warn-once) -Wl,-z,combreloc
# binutils-2.16.1 warns about ignored sections, 2.16.91.0.3 and newer are ok
-#LDFLAGS_NOSTRIP+=$(call check_ld,--gc-sections)
+#$(eval $(call check-ld-var,--gc-sections))
+#LDFLAGS_NOSTRIP += $(LDFLAG_--gc-sections)
ifeq ($(UCLIBC_BUILD_RELRO),y)
LDFLAGS_NOSTRIP+=-Wl,-z,relro
@@ -511,21 +642,28 @@ endif
ifeq ($(LDSO_GNU_HASH_SUPPORT),y)
# Be sure that binutils support it
-LDFLAGS_GNUHASH:=$(call check_ld,--hash-style=gnu)
-ifeq ($(LDFLAGS_GNUHASH),)
-$(error Your binutils don't support --hash-style option, while you want to use it)
+$(eval $(call check-ld-var,--hash-style=gnu))
+ifeq ($(LDFLAG_--hash-style=gnu),)
+ifneq ($(filter-out $(clean_targets) CLEAN_% install_headers headers-y,$(MAKECMDGOALS)),)
+$(error Your binutils do not support --hash-style option, while you want to use it)
+endif
else
-LDFLAGS_NOSTRIP += -Wl,$(LDFLAGS_GNUHASH)
+LDFLAGS_NOSTRIP += $(CFLAG_-Wl--hash-style=gnu)
endif
endif
-LDFLAGS:=$(LDFLAGS_NOSTRIP) -Wl,-z,defs
ifeq ($(DODEBUG),y)
-#CFLAGS += -g3
-CFLAGS += -O0 -g3
+CFLAGS += -O0 -g3 -DDEBUG
else
-CFLAGS += $(OPTIMIZATION) $(XARCH_CFLAGS)
+CFLAGS += $(OPTIMIZATION)
+CFLAGS += $(OPTIMIZATION-$(GCC_MAJOR_VER))
+CFLAGS += $(OPTIMIZATION-$(GCC_MAJOR_VER).$(GCC_MINOR_VER))
+$(eval $(call check-ld-var,-O2))
+LDFLAGS_NOSTRIP += $(CFLAG_-Wl-O2)
endif
+
+LDFLAGS:=$(LDFLAGS_NOSTRIP) -Wl,-z,defs
+
ifeq ($(DOSTRIP),y)
LDFLAGS += -Wl,-s
else
@@ -541,19 +679,28 @@ ifeq ($(DOMULTI),y)
ifeq ($(GCC_MAJOR_VER),3)
DOMULTI:=n
else
-CFLAGS+=$(call check_gcc,--combine,)
+$(eval $(call check-gcc-var,--combine))
+CFLAGS += $(CFLAG_--combine)
endif
else
DOMULTI:=n
endif
+ifneq ($(strip $(UCLIBC_EXTRA_CFLAGS)),"")
+CFLAGS += $(call qstrip,$(UCLIBC_EXTRA_CFLAGS))
+endif
ifneq ($(strip $(UCLIBC_EXTRA_LDFLAGS)),"")
-LDFLAGS += $(subst ",, $(UCLIBC_EXTRA_LDFLAGS))
+LDFLAGS += $(call qstrip,$(UCLIBC_EXTRA_LDFLAGS))
+endif
+
+ifeq ($(UCLIBC_HAS_STDIO_FUTEXES),y)
+CFLAGS += -D__USE_STDIO_FUTEXES__
endif
ifeq ($(UCLIBC_HAS_THREADS),y)
ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
PTNAME := nptl
+ CFLAGS += -DHAVE_FORCED_UNWIND -D_LIBC_REENTRANT
else
ifeq ($(LINUXTHREADS_OLD),y)
PTNAME := linuxthreads.old
@@ -561,18 +708,20 @@ else
PTNAME := linuxthreads
endif
endif
-PTDIR := $(top_builddir)libpthread/$(PTNAME)
+PTDIR := libpthread/$(PTNAME)
# set up system dependencies include dirs (NOTE: order matters!)
ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
-PTINC:= -I$(PTDIR) \
- -I$(PTDIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH) \
- -I$(PTDIR)/sysdeps/$(TARGET_ARCH) \
- -I$(PTDIR)/sysdeps/unix/sysv/linux \
- -I$(PTDIR)/sysdeps/pthread \
- -I$(PTDIR)/sysdeps/pthread/bits \
- -I$(PTDIR)/sysdeps/generic \
- -I$(top_srcdir)ldso/ldso/$(TARGET_ARCH) \
- -I$(top_srcdir)ldso/include
+PTINC:= -I$(top_builddir)$(PTDIR) \
+ -I$(top_srcdir)$(PTDIR) \
+ $(if $(TARGET_SUBARCH),-I$(top_srcdir)$(PTDIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH)/$(TARGET_SUBARCH)) \
+ -I$(top_srcdir)$(PTDIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH) \
+ -I$(top_builddir)$(PTDIR)/sysdeps/$(TARGET_ARCH) \
+ -I$(top_srcdir)$(PTDIR)/sysdeps/$(TARGET_ARCH) \
+ -I$(top_builddir)$(PTDIR)/sysdeps/unix/sysv/linux \
+ -I$(top_srcdir)$(PTDIR)/sysdeps/unix/sysv/linux \
+ -I$(top_srcdir)$(PTDIR)/sysdeps/pthread \
+ -I$(top_srcdir)$(PTDIR)/sysdeps/pthread/bits \
+ -I$(top_srcdir)$(PTDIR)/sysdeps/generic
#
# Test for TLS if NPTL support was selected.
#
@@ -592,23 +741,26 @@ gcc_tls_test_fail:
endif
else
PTINC := \
- -I$(PTDIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH) \
- -I$(PTDIR)/sysdeps/$(TARGET_ARCH) \
- -I$(PTDIR)/sysdeps/unix/sysv/linux \
- -I$(PTDIR)/sysdeps/pthread \
- -I$(PTDIR) \
- -I$(top_builddir)libpthread
+ -I$(top_srcdir)$(PTDIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH) \
+ -I$(top_srcdir)$(PTDIR)/sysdeps/$(TARGET_ARCH) \
+ -I$(top_srcdir)$(PTDIR)/sysdeps/unix/sysv/linux \
+ -I$(top_srcdir)$(PTDIR)/sysdeps/pthread \
+ -I$(top_srcdir)$(PTDIR) \
+ -I$(top_srcdir)libpthread
endif
CFLAGS+=$(PTINC)
else
PTNAME :=
PTINC :=
endif
-CFLAGS += -I$(KERNEL_HEADERS)
+CFLAGS += -I$(top_srcdir)libc/sysdeps/linux/common
#CFLAGS += -iwithprefix include-fixed -iwithprefix include
-CC_IPREFIX:=$(shell $(CC) --print-file-name=include)
-CFLAGS += -I$(dir $(CC_IPREFIX))/include-fixed -I$(CC_IPREFIX)
+$(eval $(call cache-output-var,CC_IPREFIX,$(CC) -print-file-name=include))
+CC_INC := -isystem $(dir $(CC_IPREFIX))include-fixed -isystem $(CC_IPREFIX)
+CFLAGS += $(CC_INC)
+
+CFLAGS += -I$(KERNEL_HEADERS)
ifneq ($(DOASSERTS),y)
CFLAGS+=-DNDEBUG
@@ -619,18 +771,21 @@ CFLAGS+=-D__UCLIBC_UNDERSCORES__
endif
# Keep the check_as from being needlessly executed
-ifndef ASFLAGS_NOEXEC
ifeq ($(UCLIBC_BUILD_NOEXECSTACK),y)
-export ASFLAGS_NOEXEC := $(call check_as,--noexecstack)
-else
-export ASFLAGS_NOEXEC :=
-endif
+$(eval $(call check-as-var,--noexecstack))
endif
-ASFLAGS = $(ASFLAGS_NOEXEC)
+ASFLAGS += $(ASFLAG_--noexecstack)
LIBGCC_CFLAGS ?= $(CFLAGS) $(CPU_CFLAGS-y)
-LIBGCC:=$(shell $(CC) $(LIBGCC_CFLAGS) -print-libgcc-file-name)
-LIBGCC_DIR:=$(dir $(LIBGCC))
+$(eval $(call cache-output-var,LIBGCC_A,$(CC) $(LIBGCC_CFLAGS) -print-libgcc-file-name))
+$(eval $(call cache-output-var,LIBGCC_EH,$(CC) $(LIBGCC_CFLAGS) -print-file-name=libgcc_eh.a))
+# with -O0 we (e.g. lockf) might end up with references to
+# _Unwind_Resume, so pull in gcc_eh in this case..
+# with a --disable-shared toolchain, libgcc_eh.a and libgcc.a are combined
+# in libgcc.a, so check if the printed file exist, before adding to the commandline
+LIBGCC_EH_FILE := $(shell if [ -f $(LIBGCC_EH) ]; then echo $(LIBGCC_EH); fi)
+LIBGCC_DIR := $(dir $(LIBGCC_A))
+LIBGCC := $(LIBGCC_A) $(if $(DODEBUG),$(LIBGCC_EH_FILE))
# moved from libpthread/linuxthreads
ifeq ($(UCLIBC_CTOR_DTOR),y)
@@ -638,4 +793,6 @@ SHARED_START_FILES:=$(top_builddir)lib/crti.o $(LIBGCC_DIR)crtbeginS.o
SHARED_END_FILES:=$(LIBGCC_DIR)crtendS.o $(top_builddir)lib/crtn.o
endif
-LOCAL_INSTALL_PATH := install_dir
+LOCAL_INSTALL_PATH := $(if $(O),$(O)/)install_dir
+
+PTHREAD_GENERATE_MANGLE ?= -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*\$$/\#define \1 \2/p"
diff --git a/TODO b/TODO
deleted file mode 100644
index fa5a9bbf5..000000000
--- a/TODO
+++ /dev/null
@@ -1,179 +0,0 @@
-TODO list for every uClibc release:
--------------------------------------------------
- *) Test cris, i386, mips, mipsel, sh, x86_64, arm, armeb, and powerpc
- with the latest LTP testsuite. Fix any regressions and post LTP
- testsuite results for each architecture on uclibc.org.
- *) Audit header files. Remove prototypes for all functions that
- are not supported -- especially needed for the libm headers.
- *) Audit header files. When options are disabled, also disable
- them in the include files as well by checking for the proper
- define from include/bits/uClibc_config.h (pulled in from features.h)
-
-
-
-General release feature sets:
--------------------------------------------------
-.29 will be mostly as-is
-.30 will be the NPTL merge
-.31 for the no-kernel-headers fix, etc, etc.
-
-
-
-TODO list for the uClibc 0.9.29 release:
--------------------------------------------------
- *) as many of the arch-specific issues as possible
- *) Remove N instances of libc_hidden_proto() from uClibc internals.
- Instead add internal only header(s) defining all hidden prototypes.
- This will avoid clutter and guarantee prototype consistancy.
- *) The __is*_l() functions were all removed, such that we now only export
- the is*_l() functions (no prefix). Before, we had the prefixed versions
- for use by libstdc++ and weak versions without prefixes exported because
- those functions belong to no std (unless you call glibc a std). This should
- be fixed. Similar problems likely were created elsewhere.
- *) misc stdio bugs:
- http://bugs.uclibc.org/view.php?id=420
- http://bugs.uclibc.org/view.php?id=539
- *) bug in getopt handling:
- http://bugs.uclibc.org/view.php?id=61
- http://www.uclibc.org/lists/uclibc/2006-January/013851.html
- *) Should integrate test subdir better ... need to propagate CPU
- CFLAGS/LDFLAGS to the build/link for target binaries so that when we have
- a multilib toolchain, the proper ABI is selected.
-
-
-TODO list for the uClibc 1.0.0 release:
--------------------------------------------------
- *) glob / fnmatch tests fail
- *) regex should pass AT&T conformance tests
- *) Finish hiding uClibc internal symbols from our exported namespace
- *) Add system for generating minimal system call asm wrappers that abuse
- the C ABI to minimize amount of register/stack manipulation
- *) Explicity add some sortof CONFIG_LINUX_2_2_ABI, CONFIG_LINUX_2_4_ABI
- and CONFIG_LINUX_2_6_ABI type options, rather than having the abi
- depend on the selected set of kernel headers. This will likely also
- require that we provide a set of kernel headers (probably a derivitive
- of Mazur's linux-libc-headers) that can supplies the 2.2, 2.4, and 2.6
- kernel abi.
- *) Documentation updates:
- *) Write a uClibc HOWTO document
- *) Update README document
- *) Update INSTALL document
- *) Update docs/Glibc_vs_uClibc_Differences.txt document
- and fully document all differences between the feature
- set of uClibc and glibc.
- *) Update docs/uClibc_vs_SuSv3.txt document
- *) Update docs/threads.txt document
- *) Write man pages for ldd and ldconfig utility binaries
- *) Implement some mechanism (perhaps encoded in the .so name,
- perhaps using an abi tag magically embedded into each object)
- for flagging config options that break the ABI. Options
- such as UCLIBC_HAS_SOFT_FLOAT, UCLIBC_HAS_THREADS, UCLIBC_HAS_LOCALE,
- and perhaps others (finalize list) produce a lib with a differing
- ABI. Make it so apps cannot use an ABI mis-matched uClibc.
- This is most easily done using symbol versioning...
- *) Implement the long double versions of math funcs
- using wrappers on top of the double versions (size / precision
- trade off where size clearly wins).
- *) Make all small objects (>~50 bytes) into either inlines or
- into a static library
- *) Cleanup / rewrite sysconf.c. It should get some information
- from ldso (such as HZ). Other stuff it currently just makes
- up, which is obviously wrong. Also bits/uClibc_clk_tck.h
- needs to be updated at the same time to get proper HZ values.
- *) poll emulation using select() for old 2.0.x uClinux kernels
- in libc/sysdeps/linux/common/poll.c fails some python self-tests.
- Of course, modern systems using the actuall poll() syscall work fine.
- *) Cleanup/scrub all the Makefile copyright junk
- *) Fix dlopen, for both static and dynamic cases, and make it
- fully comply with SuSv3
-
-
-TODO list for AFTER the uClibc 1.0.0 release:
--------------------------------------------------
- *) Add support for 64bit time (to deal withhttp://2038bug.com/):
- date -s 011903142038 sets epoch to roll over in a few seconds (2^31)
- *) Add support for Linux 2.6.x fast vsyscalls
- *) Enable pristine source tree builds
- *) Fix regex so it isn't so stinking big
- *) Fix glob so it isn't so stinking big
- *) run 'nm -D --size-sort -t d libuClibc-0.9.26.so' and work on the
- biggest things (i.e. stuff at the end of the list) to make
- them smaller.
- <more wishlist items here>
-
-
-Arch specific TODO:
--------------------------------------------------
- alpha:
- ldso is not implemented
- arm:
- update crt1 code again for nommu (http://bugs.uclibc.org/view.php?id=538)
- recruit jbowler and integrate thumb support
- frv:
- needs to be updated for the new ldso changes and unification of the
- uClibc_main funcs (__uClibc_start_main doesnt exist anymore)
- hppa:
- errno.c test segfaults causes segfault in clone.S (seems to be in glibc too)
- i386:
- add support for fast system calls
- ia64:
- ldso is not implemented
- m68k:
- ldso lazy relocation doesnt work
- sh64:
- ldso is reasonably broken, presently requiring additional
- coaxing/threatening.
- sparc:
- need a sigaction.c since common one doesnt work (signal tests)
- ldso needs to be updated since it's totally broken atm
- vax:
- pthread support, linktime warning support (implies GAS patches),
- general touchups, testing, ldso.
-
-
------------------------------------------------------------------------------
-Manuel's todo:
-
- 1) Little things that need fixing:
- ----------------------------------
- a) Fix bug in *printf: outdigit precison bug
- b) Check that gnu/bsd extension members tm_gmtoff and tm_zone in struct tm
- are respected where they should be.
- c) Implement the obstack printf funcs for glibc compat.
- d) Implement glibc 'a' flag for scanf string conversions.
- e) Allow use of the older non-table-based ctype functions when using
- stub locale support. (smaller)
- f) __drand48_iterate should be void
- g) alphasort vs. versionsort. The former seems to be SVID, the latter GNU
- i.e. reverse to what we currently do. The latter is unimplemented.
- h) ponder removal/configs to turn off: __xpg_*, bsd_signal, dysize,
- getw/putw, utimes,
-
- 2) Additional str{f|p}time issues.
- ----------------------------------
- a) Spacing issue wrt strptime.
- b) Support locale specific alternate digits. (data is in place)
- c) Support locale era in year designations. (data is in place)
- d) Deal with mb format string issues in strftime.
- e) Implement wcsftime.
-
- 3) Other locale issues (my implementation):
- -------------------------------------------
- a) Do a little more clean up of ctype and wctype.
- b) Rework of the locale data organization to make using locales reasonable
- when staticly linking. (mmap)
- c) Rewrite the locale data generation tools to process the text specifications
- rather than relying on glibc.
- d) Adapt regex lib to use my collation data and add the necessary collating
- item tables to support SUSv3 required features.
- e) transliteration of unsupported wchars in 8-bit locales (like glibc).
- f) Support ISO/IEC 14652 draft locale extensions (LC_PAPER, etc).
- g) Implement strfrom.
- h) Shift-state codeset locale support?
-
- 4) Misc:
- --------
- a) Port uClibc to other OSs (including elks), or even bare metal (libgloss).
- b) Write a space-efficient gettext substitute, to avoid storing large amounts
- of redundant data.
-
diff --git a/docs/Glibc_vs_uClibc_Differences.txt b/docs/Glibc_vs_uClibc_Differences.txt
index 4ed24639e..ffddbae5f 100644
--- a/docs/Glibc_vs_uClibc_Differences.txt
+++ b/docs/Glibc_vs_uClibc_Differences.txt
@@ -66,7 +66,7 @@ encrypt_r, since these are not required by SuSv3.
12) uClibc directly uses kernel types to define most opaque data types.
-13) uClibc directly uses the linux kernel's arch specific 'stuct stat'.
+13) uClibc directly uses the linux kernel's arch specific 'struct stat'.
14) uClibc's librt library currently lacks all aio routines, all clock
routines, and all shm routines (only the timer routines and the mq
diff --git a/docs/PORTING b/docs/PORTING
index cadb32311..2ffdeda28 100644
--- a/docs/PORTING
+++ b/docs/PORTING
@@ -130,9 +130,6 @@ TODO: nptl / linuxthreads / linuxthreads.old
====================
=== Misc Cruft ===
====================
-- utils/readelf.c - not really needed generally speaking, but might as well
- add your arch to the giant EM_* list (describe_elf_hdr)
-
- MAINTAINERS - presumably you're going to submit this code back to mainline
and since you're the only one who cares about this arch (right now), you
should add yourself to the toplevel MAINTAINERS file. do it.
diff --git a/docs/crt.txt b/docs/crt.txt
new file mode 100644
index 000000000..41a44dcb4
--- /dev/null
+++ b/docs/crt.txt
@@ -0,0 +1,80 @@
+Mini FAQ about the misc libc/gcc crt files.
+
+
+Some definitions:
+PIC - position independent code (-fPIC)
+PIE - position independent executable (-fPIE -pie)
+crt - C runtime
+
+
+
+crt0.o crt1.o etc...
+ Some systems use crt0.o, while some use crt1.o (and a few even use crt2.o
+ or higher). Most likely due to a transitionary phase that some targets
+ went through. The specific number is otherwise entirely arbitrary -- look
+ at the internal gcc port code to figure out what your target expects. All
+ that matters is that whatever gcc has encoded, your C library better use
+ the same name.
+
+ This object is expected to contain the _start symbol which takes care of
+ bootstrapping the initial execution of the program. What exactly that
+ entails is highly libc dependent and as such, the object is provided by
+ the C library and cannot be mixed with other ones.
+
+ On uClibc/glibc systems, this object initializes very early ABI requirements
+ (like the stack or frame pointer), setting up the argc/argv/env values, and
+ then passing pointers to the init/fini/main funcs to the internal libc main
+ which in turn does more general bootstrapping before finally calling the real
+ main function.
+
+ glibc ports call this file 'start.S' while uClibc ports call this crt0.S or
+ crt1.S (depending on what their gcc expects).
+
+crti.o
+ Defines the function prologs for the .init and .fini sections (with the _init
+ and _fini symbols respectively). This way they can be called directly. These
+ symbols also trigger the linker to generate DT_INIT/DT_FINI dynamic ELF tags.
+
+ These are to support the old style constructor/destructor system where all
+ .init/.fini sections get concatenated at link time. Not to be confused with
+ newer prioritized constructor/destructor .init_array/.fini_array sections and
+ DT_INIT_ARRAY/DT_FINI_ARRAY ELF tags.
+
+ glibc ports used to call this 'initfini.c', but now use 'crti.S'. uClibc
+ also uses 'crti.S'.
+
+crtn.o
+ Defines the function epilogs for the .init/.fini sections. See crti.o.
+
+ glibc ports used to call this 'initfini.c', but now use 'crtn.S'. uClibc
+ also uses 'crtn.S'.
+
+Scrt1.o
+ Used in place of crt1.o when generating PIEs.
+gcrt1.o
+ Used in place of crt1.o when generating code with profiling information.
+ Compile with -pg. Produces output suitable for the gprof util.
+Mcrt1.o
+ Like gcrt1.o, but is used with the prof utility. glibc installs this as
+ a dummy file as it's useless on linux systems.
+
+crtbegin.o
+ GCC uses this to find the start of the constructors.
+crtbeginS.o
+ Used in place of crtbegin.o when generating shared objects/PIEs.
+crtbeginT.o
+ Used in place of crtbegin.o when generating static executables.
+crtend.o
+ GCC uses this to find the start of the destructors.
+crtendS.o
+ Used in place of crtend.o when generating shared objects/PIEs.
+
+
+
+General linking order:
+crt1.o crti.o crtbegin.o [-L paths] [user objects] [gcc libs] [C libs] [gcc libs] crtend.o crtn.o
+
+
+
+More references:
+ http://gcc.gnu.org/onlinedocs/gccint/Initialization.html
diff --git a/docs/defines.txt b/docs/defines.txt
new file mode 100644
index 000000000..b23fac9c0
--- /dev/null
+++ b/docs/defines.txt
@@ -0,0 +1,83 @@
+Feeble attempt to document the horde of #defines we deal with.
+Editors, please make your descriptions short but informative.
+
+
+
+__BEGIN_DECLS, __END_DECLS
+ Defined to either empty or 'extern "C" {' and '}' if included by C++.
+
+__USE_GNU, __USE_BSD, __USE_XOPEN[2K], __USE_SVID, __USE_POSIX...
+ If defined, user program which included us requests compat additions
+ from relevant standard or Unix flavor. See features.h for full list.
+
+__USE_FILE_OFFSET64
+__USE_LARGEFILE[64]
+_LARGEFILE[64]_SOURCE
+_FILE_OFFSET_BITS
+ ???
+
+__THROW
+ Function annotation "I do not throw anything".
+__NTH(func(params))
+ Function annotation "I do not throw anything".
+ Needed for situatuons when it's unclear on what side of "func(params)"
+ the "throw()" or "attribute((nothrow))" should eventually appear.
+ Messy, eh?
+
+return_type __REDIRECT(name, (params), alias)
+ declare alias to "name(params)"
+return_type __REDIRECT_NTH(name, (params), alias)
+ declare alias to "name(params) __THROW"
+
+__BIG_ENDIAN 4321
+__LITTLE_ENDIAN 1234
+ Should be always as shown. __PDP_ENDIAN is historic, ignore?
+__BYTE_ORDER, __FLOAT_WORD_ORDER
+ Should be defined to __BIG_ENDIAN or __LITTLE_ENDIAN.
+ Usage: "#if __BYTE_ORDER == __LITTLE_ENDIAN ..."
+ __USE_BSD adds versions without leading "__" for above four defines.
+_BIG_ENDIAN, __BIG_ENDIAN__
+_LITTLE_ENDIAN, __LITTLE_ENDIAN__
+ Defined (to what?) by gcc for some architectures to indicate endianness.
+ Seems that the fact of defined-ness is an indicator, not the value.
+
+__USE_EXTERN_INLINES
+ If defined, headers will supply some function as inlines.
+ uclibc itself is built with this option off and provides
+ out-of-line version of every inlined function in case user program
+ calls it instead of using an inline.
+_EXTERN_INLINE
+ If not defined by user prior to #include, will be defined to
+ "extern inline" or equivalent. IOW, if user defines it prior
+ #include, it replaces "extern __inline" string in inline definitions
+ (those enabled by __USE_EXTERN_INLINES) with something else.
+ A few uclibc .c files use it to create non-inlined functions
+ by defining it to "".
+__extern_inline
+ Defined to "extern inline", modulo gcc/C standard deviations.
+ Can't be used by user to play tricks as with _EXTERN_INLINE.
+
+internal_function
+ Used to modify function's calling convention, if "standard" one
+ is suboptimal. Examples:
+ int func(params) internal_function;
+ int internal_function func(params) { body }
+
+_LIBC
+ Defined only at libc build time. It is physically deleted
+from the headers (using unifdef tool) in installed headers ("make install").
+
+__UCLIBC_XXX
+ uclibc-internal and uclibc-specific defines. In particular:
+__UCLIBC_HAS_XXX__, __UCLIBC_HAVE_XXX__
+ __UCLIBC_HAS_XXX__ are booleans (defined/undefined), defined in
+ uClibc_config.h and generated from uclibc .config file.
+ __UCLIBC_HAVE_XXX__ are booleans from bits/uClibc_arch_features.h
+ (there are more __UCLIBC_XXX defines there)
+
+__LDBL_COMPAT
+ Never defined, TODO: remove?
+
+__SSP_ALL__
+ All functions, even small ones, have stack smashing protection
+ prologue enabled.
diff --git a/docs/man/arc4random.3 b/docs/man/arc4random.3
new file mode 100644
index 000000000..933d2eb0c
--- /dev/null
+++ b/docs/man/arc4random.3
@@ -0,0 +1,110 @@
+.\" $OpenBSD: arc4random.3,v 1.19 2005/07/17 08:50:55 jaredy Exp $
+.\"
+.\" Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by Niels Provos.
+.\" 4. The name of the author may not be used to endorse or promote products
+.\" derived from this software without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+.\"
+.\" Manual page, using -mandoc macros
+.\"
+.Dd April 15, 1997
+.Dt ARC4RANDOM 3
+.Os
+.Sh NAME
+.Nm arc4random ,
+.Nm arc4random_stir ,
+.Nm arc4random_addrandom
+.Nd arc4 random number generator
+.Sh SYNOPSIS
+.Fd #include <stdlib.h>
+.Ft uint32_t
+.Fn arc4random "void"
+.Ft void
+.Fn arc4random_stir "void"
+.Ft void
+.Fn arc4random_addrandom "u_char *dat" "int datlen"
+.Sh DESCRIPTION
+The
+.Fn arc4random
+function provides a high quality 32-bit pseudo-random
+number very quickly.
+.Fn arc4random
+seeds itself on a regular basis from the kernel strong random number
+subsystem described in
+.Xr random 4 .
+On each call, an ARC4 generator is used to generate a new result.
+The
+.Fn arc4random
+function uses the ARC4 cipher key stream generator,
+which uses 8*8 8-bit S-Boxes.
+The S-Boxes can be in about (2**1700) states.
+.Pp
+.Fn arc4random
+fits into a middle ground not covered by other subsystems such as
+the strong, slow, and resource expensive random
+devices described in
+.Xr random 4
+versus the fast but poor quality interfaces described in
+.Xr rand 3 ,
+.Xr random 3 ,
+and
+.Xr drand48 3 .
+.Pp
+The
+.Fn arc4random_stir
+function reads data from a pseudo-random device, usually
+.Pa /dev/urandom,
+and uses it to permute the S-Boxes via
+.Fn arc4random_addrandom .
+.Pp
+There is no need to call
+.Fn arc4random_stir
+before using
+.Fn arc4random ,
+since
+.Fn arc4random
+automatically initializes itself.
+.Sh SEE ALSO
+.Xr rand 3 ,
+.Xr rand48 3 ,
+.Xr random 3
+.Sh HISTORY
+An algorithm called
+.Pa RC4
+was designed by RSA Data Security, Inc.
+It was considered a trade secret.
+Because it was a trade secret, it obviously could not be patented.
+A clone of this was posted anonymously to USENET and confirmed to
+be equivalent by several sources who had access to the original cipher.
+Because of the trade secret situation, RSA Data Security, Inc. can do
+nothing about the release of the ARC4 algorithm.
+Since
+.Pa RC4
+used to be a trade secret, the cipher is now referred to as
+.Pa ARC4 .
+.Pp
+These functions first appeared in
+.Ox 2.1 .
diff --git a/docs/probe_math_exception.c b/docs/probe_math_exception.c
new file mode 100644
index 000000000..dbc9020d4
--- /dev/null
+++ b/docs/probe_math_exception.c
@@ -0,0 +1,64 @@
+/* Small test program for probing how various math functions
+ * with specific operands set floating point exceptions
+ */
+
+#define _ISOC99_SOURCE 1
+#define _GNU_SOURCE 1
+
+#include <stdint.h>
+#include <math.h>
+#include <fenv.h>
+#include <stdio.h>
+
+int main(int argc, char **argv)
+{
+ float largest, small, t, inf_float;
+
+ largest = small = 1;
+ while (1) {
+ t = largest + small;
+ /* optimizations may make plain "t == largest" unreliable */
+ if (memcmp(&t, &largest, sizeof(float)) == 0)
+ break;
+ if (isfinite(t)) {
+ largest = t;
+ small *= 2;
+ continue;
+ }
+ small /= 2;
+ }
+ inf_float = largest + largest;
+ //printf("%.40g ", largest);
+ //printf("[%llx]\n", (long long) (*(uint32_t *)&largest));
+
+ feclearexcept(FE_ALL_EXCEPT);
+
+ //t = 1.0 / 0.0; // simple test: FE_DIVBYZERO
+ //t = nextafterf(largest, 1); // glibc 2.8: no math exceptions raised
+ //t = nextafterf(largest, largest); // glibc 2.8: no math exceptions raised
+ //t = nextafterf(largest, inf_float); // glibc 2.8: FE_INEXACT FE_OVERFLOW
+
+#define PREX(ex) do { if (fetestexcept(ex)) printf(#ex " "); } while(0)
+#ifdef FE_INEXACT
+ PREX(FE_INEXACT);
+#endif
+#ifdef FE_DIVBYZERO
+ PREX(FE_DIVBYZERO);
+#endif
+#ifdef FE_UNDERFLOW
+ PREX(FE_UNDERFLOW);
+#endif
+#ifdef FE_OVERFLOW
+ PREX(FE_OVERFLOW);
+#endif
+#ifdef FE_INVALID
+ PREX(FE_INVALID);
+#endif
+ if (fetestexcept(FE_ALL_EXCEPT))
+ printf("\n");
+ else
+ printf("no math exceptions raised\n");
+
+ printf("%.40g\n", t);
+ return 0;
+}
diff --git a/docs/pthreads_hacking.txt b/docs/pthreads_hacking.txt
new file mode 100644
index 000000000..6c23257d4
--- /dev/null
+++ b/docs/pthreads_hacking.txt
@@ -0,0 +1,748 @@
+# Run me as a shell script in uclibc lib/*
+
+
+# Dump the list of dynamic symbols from libpthread
+# and compare libpthread's exported symbols of uclibc with glibc
+# (adjust /lib64/libpthread-*.*.so as needed).
+# The resulting diff is suspiciously large.
+# We export a lot of stuff which glibc does not.
+
+readelf -sDW libpthread-*.*.so \
+| grep '^ *[0-9]' \
+| sed 's/^[0-9a-f: ]*[^ ]\( *[A-Z]\)/\1/' \
+| sed 's/ [0-9] / N /' | sed 's/ [0-9][0-9] / N /' | sed 's/ [0-9][0-9][0-9] / N /' \
+| sort -k5 | uniq \
+>uclibc.lst
+
+readelf -sDW /lib64/libpthread-*.*.so \
+| grep '^ *[0-9]' \
+| sed 's/^[0-9a-f: ]*[^ ]\( *[A-Z]\)/\1/' \
+| sed 's/ [0-9] / N /' | sed 's/ [0-9][0-9] / N /' | sed 's/ [0-9][0-9][0-9] / N /' \
+| sort -k5 | uniq \
+>glibc.lst
+diff -u uclibc.lst glibc.lst >ug.diff
+
+
+# Check which exported symbols from libpthread are never referenced
+# from other libraries. Generally, I'd expect a very few __functions
+# with two underscores to be exported and not used by e.g. libc-X.X.X.so,
+# as these names are supposed to be internal, i.e. external programs
+# usually don't call them. On my system, I got 141 such __functions.
+# Examples:
+# __flockfilelist - NOP function (why do we need it at all?)
+# __pthread_perform_cleanup - called only from within libpthread
+
+echo *-*.*.*.so | xargs -n1 | grep -v libpthread | xargs readelf -aW >full_dump.lst
+>uclibc_unrefd.lst
+>uclibc_refd.lst
+sed 's/^.* //g' uclibc.lst \
+| while read symbol; do
+ if grep -F -- "$symbol" full_dump.lst >/dev/null 2>&1; then
+ echo "$symbol" >>uclibc_refd.lst
+ else
+ echo "$symbol" >>uclibc_unrefd.lst
+ fi
+done
+
+exit
+
+
+In case you don't have a glibc system to try it,
+ug.diff from vda's system is below.
+
+--- uclibc.lst 2009-03-16 03:07:58.000000000 +0100
++++ glibc.lst 2009-03-16 03:07:58.000000000 +0100
+@@ -1,188 +1,173 @@
+- NOTYPE GLOBAL DEFAULT ABS __bss_start
+- FUNC GLOBAL DEFAULT N __compare_and_swap
++ OBJECT GLOBAL DEFAULT ABS GLIBC_2.2.5
++ OBJECT GLOBAL DEFAULT ABS GLIBC_2.2.6
++ OBJECT GLOBAL DEFAULT ABS GLIBC_2.3.2
++ OBJECT GLOBAL DEFAULT ABS GLIBC_2.3.3
++ OBJECT GLOBAL DEFAULT ABS GLIBC_2.3.4
++ OBJECT GLOBAL DEFAULT ABS GLIBC_2.4
++ OBJECT GLOBAL DEFAULT ABS GLIBC_PRIVATE
++ FUNC GLOBAL DEFAULT N _IO_flockfile
++ FUNC GLOBAL DEFAULT N _IO_ftrylockfile
++ FUNC GLOBAL DEFAULT N _IO_funlockfile
++ NOTYPE WEAK DEFAULT UND _Jv_RegisterClasses
++ FUNC GLOBAL DEFAULT UND __clone
++ FUNC WEAK DEFAULT N __close
++ FUNC WEAK DEFAULT N __connect
++ FUNC WEAK DEFAULT UND __cxa_finalize
++ FUNC GLOBAL DEFAULT UND __endmntent
+ FUNC GLOBAL DEFAULT N __errno_location
+- FUNC GLOBAL DEFAULT N __flockfilelist
+- FUNC GLOBAL DEFAULT N __fresetlockfiles
+- FUNC GLOBAL DEFAULT N __funlockfilelist
++ FUNC WEAK DEFAULT N __fcntl
++ FUNC GLOBAL DEFAULT N __fork
++ FUNC GLOBAL DEFAULT UND __fxstat64
++ FUNC GLOBAL DEFAULT UND __getdelim
++ FUNC GLOBAL DEFAULT UND __getmntent_r
++ FUNC GLOBAL DEFAULT UND __getpagesize
++ FUNC GLOBAL DEFAULT UND __gettimeofday
+ FUNC GLOBAL DEFAULT N __h_errno_location
+- FUNC GLOBAL DEFAULT N __linuxthreads_create_event
+- FUNC GLOBAL DEFAULT N __linuxthreads_death_event
+- OBJECT GLOBAL DEFAULT N __linuxthreads_initial_report_events
+- OBJECT GLOBAL DEFAULT N __linuxthreads_pthread_key_2ndlevel_size
+- OBJECT GLOBAL DEFAULT N __linuxthreads_pthread_keys_max
+- OBJECT GLOBAL DEFAULT N __linuxthreads_pthread_sizeof_descr
+- OBJECT GLOBAL DEFAULT N __linuxthreads_pthread_threads_max
+- FUNC GLOBAL DEFAULT N __linuxthreads_reap_event
+- OBJECT GLOBAL DEFAULT N __linuxthreads_version
+- FUNC GLOBAL DEFAULT N __pthread_alt_lock
+- FUNC GLOBAL DEFAULT N __pthread_alt_timedlock
+- FUNC GLOBAL DEFAULT N __pthread_alt_unlock
+- FUNC GLOBAL DEFAULT N __pthread_attr_destroy
+- FUNC GLOBAL DEFAULT N __pthread_attr_getdetachstate
+- FUNC GLOBAL DEFAULT N __pthread_attr_getguardsize
+- FUNC GLOBAL DEFAULT N __pthread_attr_getinheritsched
+- FUNC GLOBAL DEFAULT N __pthread_attr_getschedparam
+- FUNC GLOBAL DEFAULT N __pthread_attr_getschedpolicy
+- FUNC GLOBAL DEFAULT N __pthread_attr_getscope
+- FUNC GLOBAL DEFAULT N __pthread_attr_getstack
+- FUNC GLOBAL DEFAULT N __pthread_attr_getstacksize
+- FUNC GLOBAL DEFAULT N __pthread_attr_init
+- FUNC GLOBAL DEFAULT N __pthread_attr_setdetachstate
+- FUNC GLOBAL DEFAULT N __pthread_attr_setguardsize
+- FUNC GLOBAL DEFAULT N __pthread_attr_setinheritsched
+- FUNC GLOBAL DEFAULT N __pthread_attr_setschedparam
+- FUNC GLOBAL DEFAULT N __pthread_attr_setschedpolicy
+- FUNC GLOBAL DEFAULT N __pthread_attr_setscope
+- FUNC GLOBAL DEFAULT N __pthread_attr_setstack
+- FUNC GLOBAL DEFAULT N __pthread_attr_setstacksize
+- FUNC GLOBAL DEFAULT N __pthread_barrierattr_getpshared
+- FUNC GLOBAL DEFAULT N __pthread_compare_and_swap
+- FUNC GLOBAL DEFAULT N __pthread_cond_broadcast
+- FUNC GLOBAL DEFAULT N __pthread_cond_destroy
+- FUNC GLOBAL DEFAULT N __pthread_cond_init
+- FUNC GLOBAL DEFAULT N __pthread_cond_signal
+- FUNC GLOBAL DEFAULT N __pthread_cond_timedwait
+- FUNC GLOBAL DEFAULT N __pthread_cond_wait
+- FUNC GLOBAL DEFAULT N __pthread_condattr_destroy
+- FUNC GLOBAL DEFAULT N __pthread_condattr_init
+- FUNC GLOBAL DEFAULT N __pthread_create
+- FUNC GLOBAL DEFAULT N __pthread_destroy_specifics
+- FUNC GLOBAL DEFAULT N __pthread_do_exit
+- FUNC GLOBAL DEFAULT N __pthread_equal
+- FUNC GLOBAL DEFAULT N __pthread_exit
+- OBJECT GLOBAL DEFAULT N __pthread_exit_code
+- OBJECT GLOBAL DEFAULT N __pthread_exit_requested
+- FUNC GLOBAL DEFAULT N __pthread_find_self
+- OBJECT GLOBAL DEFAULT N __pthread_functions
+- FUNC GLOBAL DEFAULT N __pthread_getconcurrency
+- FUNC GLOBAL DEFAULT N __pthread_getschedparam
+- FUNC WEAK DEFAULT N __pthread_getspecific
+- OBJECT GLOBAL DEFAULT N __pthread_handles
+- OBJECT GLOBAL DEFAULT N __pthread_handles_num
+- OBJECT GLOBAL DEFAULT N __pthread_has_cas
+- FUNC GLOBAL DEFAULT N __pthread_init_max_stacksize
+- OBJECT GLOBAL DEFAULT N __pthread_initial_thread
+- OBJECT GLOBAL DEFAULT N __pthread_initial_thread_bos
+- FUNC GLOBAL DEFAULT N __pthread_initialize
+- FUNC GLOBAL DEFAULT N __pthread_initialize_manager
++ FUNC GLOBAL DEFAULT N __libc_allocate_rtsig
++ FUNC GLOBAL DEFAULT UND __libc_allocate_rtsig_private
++ FUNC GLOBAL DEFAULT N __libc_current_sigrtmax
++ FUNC GLOBAL DEFAULT UND __libc_current_sigrtmax_private
++ FUNC GLOBAL DEFAULT N __libc_current_sigrtmin
++ FUNC GLOBAL DEFAULT UND __libc_current_sigrtmin_private
++ FUNC GLOBAL DEFAULT UND __libc_dl_error_tsd
++ FUNC GLOBAL DEFAULT UND __libc_dlopen_mode
++ FUNC GLOBAL DEFAULT UND __libc_dlsym
++ FUNC GLOBAL DEFAULT UND __libc_fatal
++ FUNC GLOBAL DEFAULT UND __libc_fork
++ FUNC GLOBAL DEFAULT UND __libc_longjmp
++ FUNC GLOBAL DEFAULT UND __libc_pthread_init
++ OBJECT GLOBAL DEFAULT UND __libc_stack_end
++ FUNC GLOBAL DEFAULT UND __libc_system
++ FUNC GLOBAL DEFAULT UND __libc_thread_freeres
++ FUNC WEAK DEFAULT N __lseek
++ FUNC WEAK DEFAULT N __nanosleep
++ FUNC WEAK DEFAULT N __open
++ FUNC WEAK DEFAULT N __open64
++ FUNC WEAK DEFAULT N __pread64
++ FUNC GLOBAL DEFAULT N __pthread_cleanup_routine
++ FUNC GLOBAL DEFAULT N __pthread_clock_gettime
++ FUNC GLOBAL DEFAULT N __pthread_clock_settime
++ FUNC GLOBAL DEFAULT N __pthread_getspecific
+ FUNC GLOBAL DEFAULT N __pthread_initialize_minimal
+- FUNC GLOBAL DEFAULT N __pthread_internal_tsd_address
+- FUNC GLOBAL DEFAULT N __pthread_internal_tsd_get
+- FUNC GLOBAL DEFAULT N __pthread_internal_tsd_set
+- FUNC WEAK DEFAULT N __pthread_key_create
+- FUNC GLOBAL DEFAULT N __pthread_kill_other_threads_np
+- OBJECT GLOBAL DEFAULT N __pthread_last_event
+- FUNC GLOBAL DEFAULT N __pthread_lock
+- OBJECT GLOBAL DEFAULT N __pthread_main_thread
+- FUNC GLOBAL DEFAULT N __pthread_manager
+- FUNC GLOBAL DEFAULT N __pthread_manager_adjust_prio
+- FUNC GLOBAL DEFAULT N __pthread_manager_event
+- OBJECT GLOBAL DEFAULT N __pthread_manager_reader
+- OBJECT GLOBAL DEFAULT N __pthread_manager_request
+- FUNC GLOBAL DEFAULT N __pthread_manager_sighandler
+- OBJECT GLOBAL DEFAULT N __pthread_manager_thread
+- OBJECT GLOBAL DEFAULT N __pthread_manager_thread_bos
+- OBJECT GLOBAL DEFAULT N __pthread_manager_thread_tos
+- OBJECT GLOBAL DEFAULT N __pthread_max_stacksize
+- FUNC WEAK DEFAULT N __pthread_mutex_destroy
+- FUNC WEAK DEFAULT N __pthread_mutex_init
+- FUNC WEAK DEFAULT N __pthread_mutex_lock
+- FUNC GLOBAL DEFAULT N __pthread_mutex_timedlock
+- FUNC WEAK DEFAULT N __pthread_mutex_trylock
+- FUNC WEAK DEFAULT N __pthread_mutex_unlock
+- FUNC WEAK DEFAULT N __pthread_mutexattr_destroy
+- FUNC GLOBAL DEFAULT N __pthread_mutexattr_getkind_np
+- FUNC GLOBAL DEFAULT N __pthread_mutexattr_getpshared
+- FUNC GLOBAL DEFAULT N __pthread_mutexattr_gettype
+- FUNC WEAK DEFAULT N __pthread_mutexattr_init
+- FUNC GLOBAL DEFAULT N __pthread_mutexattr_setkind_np
+- FUNC GLOBAL DEFAULT N __pthread_mutexattr_setpshared
+- FUNC WEAK DEFAULT N __pthread_mutexattr_settype
+- OBJECT GLOBAL DEFAULT N __pthread_nonstandard_stacks
+- FUNC GLOBAL DEFAULT N __pthread_null_sighandler
+- OBJECT GLOBAL DEFAULT N __pthread_offsetof_descr
+- OBJECT GLOBAL DEFAULT N __pthread_offsetof_pid
+- FUNC WEAK DEFAULT N __pthread_once
+- FUNC GLOBAL DEFAULT N __pthread_once_fork_child
+- FUNC GLOBAL DEFAULT N __pthread_once_fork_parent
+- FUNC GLOBAL DEFAULT N __pthread_once_fork_prepare
+- FUNC GLOBAL DEFAULT N __pthread_perform_cleanup
+- FUNC GLOBAL DEFAULT N __pthread_raise
+- FUNC GLOBAL DEFAULT N __pthread_reset_main_thread
+- FUNC GLOBAL DEFAULT N __pthread_restart_new
+- FUNC WEAK DEFAULT N __pthread_rwlock_destroy
+- FUNC WEAK DEFAULT N __pthread_rwlock_init
+- FUNC WEAK DEFAULT N __pthread_rwlock_rdlock
+- FUNC GLOBAL DEFAULT N __pthread_rwlock_timedrdlock
+- FUNC GLOBAL DEFAULT N __pthread_rwlock_timedwrlock
+- FUNC WEAK DEFAULT N __pthread_rwlock_tryrdlock
+- FUNC WEAK DEFAULT N __pthread_rwlock_trywrlock
+- FUNC WEAK DEFAULT N __pthread_rwlock_unlock
+- FUNC WEAK DEFAULT N __pthread_rwlock_wrlock
+- FUNC GLOBAL DEFAULT N __pthread_rwlockattr_destroy
+- FUNC GLOBAL DEFAULT N __pthread_self
+- FUNC GLOBAL DEFAULT N __pthread_setcancelstate
+- FUNC GLOBAL DEFAULT N __pthread_setcanceltype
+- FUNC GLOBAL DEFAULT N __pthread_setconcurrency
+- FUNC GLOBAL DEFAULT N __pthread_setschedparam
+- FUNC WEAK DEFAULT N __pthread_setspecific
+- OBJECT GLOBAL DEFAULT N __pthread_sig_cancel
+- OBJECT GLOBAL DEFAULT N __pthread_sig_debug
+- OBJECT GLOBAL DEFAULT N __pthread_sig_restart
+- FUNC GLOBAL DEFAULT N __pthread_sigaction
+- FUNC GLOBAL DEFAULT N __pthread_sighandler
+- FUNC GLOBAL DEFAULT N __pthread_sighandler_rt
+- FUNC GLOBAL DEFAULT N __pthread_sigwait
+- OBJECT GLOBAL DEFAULT N __pthread_sizeof_handle
+- OBJECT GLOBAL DEFAULT N __pthread_smp_kernel
+- FUNC GLOBAL DEFAULT N __pthread_spin_destroy
+- FUNC GLOBAL DEFAULT N __pthread_spin_init
+- FUNC GLOBAL DEFAULT N __pthread_spin_lock
+- FUNC GLOBAL DEFAULT N __pthread_spin_trylock
+- FUNC GLOBAL DEFAULT N __pthread_spin_unlock
+- FUNC GLOBAL DEFAULT N __pthread_thread_self
+- OBJECT GLOBAL DEFAULT N __pthread_threads_debug
+- OBJECT GLOBAL DEFAULT N __pthread_threads_events
+- OBJECT GLOBAL DEFAULT N __pthread_threads_max
+- FUNC GLOBAL DEFAULT N __pthread_timedsuspend_new
+- FUNC GLOBAL DEFAULT N __pthread_unlock
+- FUNC GLOBAL DEFAULT N __pthread_wait_for_restart_signal
+- FUNC GLOBAL DEFAULT N __register_atfork
++ FUNC GLOBAL DEFAULT N __pthread_key_create
++ FUNC GLOBAL DEFAULT N __pthread_mutex_destroy
++ FUNC GLOBAL DEFAULT N __pthread_mutex_init
++ FUNC GLOBAL DEFAULT N __pthread_mutex_lock
++ FUNC GLOBAL DEFAULT N __pthread_mutex_trylock
++ FUNC GLOBAL DEFAULT N __pthread_mutex_unlock
++ FUNC GLOBAL DEFAULT N __pthread_mutexattr_destroy
++ FUNC GLOBAL DEFAULT N __pthread_mutexattr_init
++ FUNC GLOBAL DEFAULT N __pthread_mutexattr_settype
++ FUNC GLOBAL DEFAULT N __pthread_once
++ FUNC GLOBAL DEFAULT N __pthread_register_cancel
++ FUNC GLOBAL DEFAULT N __pthread_register_cancel_defer
++ FUNC GLOBAL DEFAULT N __pthread_rwlock_destroy
++ FUNC GLOBAL DEFAULT N __pthread_rwlock_init
++ FUNC GLOBAL DEFAULT N __pthread_rwlock_rdlock
++ FUNC GLOBAL DEFAULT N __pthread_rwlock_tryrdlock
++ FUNC GLOBAL DEFAULT N __pthread_rwlock_trywrlock
++ FUNC GLOBAL DEFAULT N __pthread_rwlock_unlock
++ FUNC GLOBAL DEFAULT N __pthread_rwlock_wrlock
++ FUNC GLOBAL DEFAULT N __pthread_setspecific
++ FUNC GLOBAL DEFAULT N __pthread_unregister_cancel
++ FUNC GLOBAL DEFAULT N __pthread_unregister_cancel_restore
++ FUNC GLOBAL DEFAULT N __pthread_unwind
++ FUNC GLOBAL DEFAULT N __pthread_unwind_next
++ FUNC WEAK DEFAULT N __pwrite64
++ FUNC WEAK DEFAULT N __read
++ FUNC GLOBAL DEFAULT UND __register_atfork
++ FUNC GLOBAL DEFAULT N __res_state
++ TLS GLOBAL DEFAULT UND __resp
++ FUNC GLOBAL DEFAULT UND __sched_getparam
++ FUNC GLOBAL DEFAULT UND __sched_getscheduler
++ FUNC GLOBAL DEFAULT UND __sched_setscheduler
++ FUNC WEAK DEFAULT N __send
++ FUNC GLOBAL DEFAULT UND __setmntent
+ FUNC GLOBAL DEFAULT N __sigaction
+- OBJECT GLOBAL DEFAULT N __sighandler
+- NOTYPE GLOBAL DEFAULT ABS _edata
+- NOTYPE GLOBAL DEFAULT ABS _end
+- FUNC GLOBAL DEFAULT N _fini
+- FUNC GLOBAL DEFAULT N _init
++ FUNC GLOBAL DEFAULT UND __statfs
++ FUNC GLOBAL DEFAULT UND __sysconf
++ FUNC GLOBAL DEFAULT UND __tls_get_addr
++ OBJECT GLOBAL DEFAULT UND __vdso_clock_gettime
++ FUNC GLOBAL DEFAULT N __vfork
++ FUNC WEAK DEFAULT N __wait
++ FUNC WEAK DEFAULT N __write
++ FUNC GLOBAL DEFAULT UND _dl_allocate_tls
++ FUNC GLOBAL DEFAULT UND _dl_allocate_tls_init
++ FUNC GLOBAL DEFAULT UND _dl_deallocate_tls
++ FUNC GLOBAL DEFAULT UND _dl_get_tls_static_info
++ FUNC GLOBAL DEFAULT UND _dl_make_stack_executable
++ FUNC GLOBAL DEFAULT UND _exit
+ FUNC GLOBAL DEFAULT N _pthread_cleanup_pop
+ FUNC GLOBAL DEFAULT N _pthread_cleanup_pop_restore
+ FUNC GLOBAL DEFAULT N _pthread_cleanup_push
+ FUNC GLOBAL DEFAULT N _pthread_cleanup_push_defer
+- FUNC GLOBAL DEFAULT N compare_and_swap_is_available
+- FUNC GLOBAL DEFAULT N get_eflags
++ OBJECT GLOBAL DEFAULT UND _rtld_global
++ FUNC GLOBAL DEFAULT UND _setjmp
++ FUNC GLOBAL DEFAULT UND abort
++ FUNC WEAK DEFAULT N accept
++ FUNC GLOBAL DEFAULT UND calloc
++ FUNC WEAK DEFAULT N close
++ FUNC WEAK DEFAULT N connect
++ TLS GLOBAL DEFAULT UND errno
++ FUNC GLOBAL DEFAULT UND exit
++ FUNC GLOBAL DEFAULT UND fclose
++ FUNC WEAK DEFAULT N fcntl
++ FUNC WEAK DEFAULT N flockfile
++ FUNC GLOBAL DEFAULT UND fopen
++ FUNC GLOBAL DEFAULT N fork
++ FUNC GLOBAL DEFAULT UND free
++ FUNC WEAK DEFAULT N fsync
++ FUNC WEAK DEFAULT N ftrylockfile
++ FUNC WEAK DEFAULT N funlockfile
++ FUNC GLOBAL DEFAULT UND getrlimit
++ TLS GLOBAL DEFAULT UND h_errno
++ FUNC GLOBAL DEFAULT UND link
+ FUNC GLOBAL DEFAULT N longjmp
++ FUNC WEAK DEFAULT N lseek
++ FUNC WEAK DEFAULT N lseek64
++ FUNC GLOBAL DEFAULT UND malloc
++ FUNC GLOBAL DEFAULT UND memcpy
++ FUNC GLOBAL DEFAULT UND mempcpy
++ FUNC GLOBAL DEFAULT UND memset
++ FUNC GLOBAL DEFAULT UND mktemp
++ FUNC GLOBAL DEFAULT UND mmap
++ FUNC GLOBAL DEFAULT UND mprotect
++ FUNC WEAK DEFAULT N msync
++ FUNC GLOBAL DEFAULT UND munmap
++ FUNC WEAK DEFAULT N nanosleep
++ FUNC WEAK DEFAULT N open
++ FUNC WEAK DEFAULT N open64
++ FUNC WEAK DEFAULT N pause
++ FUNC WEAK DEFAULT N pread
++ FUNC WEAK DEFAULT N pread64
++ FUNC GLOBAL DEFAULT N pthread_atfork
+ FUNC GLOBAL DEFAULT N pthread_attr_destroy
++ FUNC GLOBAL DEFAULT N pthread_attr_getaffinity_np
+ FUNC GLOBAL DEFAULT N pthread_attr_getdetachstate
+- FUNC WEAK DEFAULT N pthread_attr_getguardsize
++ FUNC GLOBAL DEFAULT N pthread_attr_getguardsize
+ FUNC GLOBAL DEFAULT N pthread_attr_getinheritsched
+ FUNC GLOBAL DEFAULT N pthread_attr_getschedparam
+ FUNC GLOBAL DEFAULT N pthread_attr_getschedpolicy
+ FUNC GLOBAL DEFAULT N pthread_attr_getscope
+- FUNC WEAK DEFAULT N pthread_attr_getstack
+- FUNC WEAK DEFAULT N pthread_attr_getstacksize
++ FUNC GLOBAL DEFAULT N pthread_attr_getstack
++ FUNC GLOBAL DEFAULT N pthread_attr_getstackaddr
++ FUNC GLOBAL DEFAULT N pthread_attr_getstacksize
+ FUNC GLOBAL DEFAULT N pthread_attr_init
++ FUNC GLOBAL DEFAULT N pthread_attr_setaffinity_np
+ FUNC GLOBAL DEFAULT N pthread_attr_setdetachstate
+- FUNC WEAK DEFAULT N pthread_attr_setguardsize
++ FUNC GLOBAL DEFAULT N pthread_attr_setguardsize
+ FUNC GLOBAL DEFAULT N pthread_attr_setinheritsched
+ FUNC GLOBAL DEFAULT N pthread_attr_setschedparam
+ FUNC GLOBAL DEFAULT N pthread_attr_setschedpolicy
+ FUNC GLOBAL DEFAULT N pthread_attr_setscope
+- FUNC WEAK DEFAULT N pthread_attr_setstack
+- FUNC WEAK DEFAULT N pthread_attr_setstacksize
++ FUNC GLOBAL DEFAULT N pthread_attr_setstack
++ FUNC GLOBAL DEFAULT N pthread_attr_setstackaddr
++ FUNC GLOBAL DEFAULT N pthread_attr_setstacksize
+ FUNC GLOBAL DEFAULT N pthread_barrier_destroy
+ FUNC GLOBAL DEFAULT N pthread_barrier_init
+ FUNC GLOBAL DEFAULT N pthread_barrier_wait
+ FUNC GLOBAL DEFAULT N pthread_barrierattr_destroy
++ FUNC GLOBAL DEFAULT N pthread_barrierattr_getpshared
+ FUNC GLOBAL DEFAULT N pthread_barrierattr_init
+ FUNC GLOBAL DEFAULT N pthread_barrierattr_setpshared
+ FUNC GLOBAL DEFAULT N pthread_cancel
+@@ -193,36 +178,49 @@
+ FUNC GLOBAL DEFAULT N pthread_cond_timedwait
+ FUNC GLOBAL DEFAULT N pthread_cond_wait
+ FUNC GLOBAL DEFAULT N pthread_condattr_destroy
++ FUNC GLOBAL DEFAULT N pthread_condattr_getclock
+ FUNC GLOBAL DEFAULT N pthread_condattr_getpshared
+ FUNC GLOBAL DEFAULT N pthread_condattr_init
++ FUNC GLOBAL DEFAULT N pthread_condattr_setclock
+ FUNC GLOBAL DEFAULT N pthread_condattr_setpshared
+ FUNC GLOBAL DEFAULT N pthread_create
+ FUNC GLOBAL DEFAULT N pthread_detach
+ FUNC GLOBAL DEFAULT N pthread_equal
+ FUNC GLOBAL DEFAULT N pthread_exit
++ FUNC GLOBAL DEFAULT N pthread_getaffinity_np
+ FUNC GLOBAL DEFAULT N pthread_getattr_np
+- FUNC WEAK DEFAULT N pthread_getconcurrency
++ FUNC GLOBAL DEFAULT N pthread_getconcurrency
++ FUNC GLOBAL DEFAULT N pthread_getcpuclockid
+ FUNC GLOBAL DEFAULT N pthread_getschedparam
+ FUNC GLOBAL DEFAULT N pthread_getspecific
+ FUNC GLOBAL DEFAULT N pthread_join
+ FUNC GLOBAL DEFAULT N pthread_key_create
+ FUNC GLOBAL DEFAULT N pthread_key_delete
+ FUNC GLOBAL DEFAULT N pthread_kill
+- FUNC WEAK DEFAULT N pthread_kill_other_threads_np
++ FUNC GLOBAL DEFAULT N pthread_kill_other_threads_np
++ FUNC GLOBAL DEFAULT N pthread_mutex_consistent_np
+ FUNC GLOBAL DEFAULT N pthread_mutex_destroy
++ FUNC GLOBAL DEFAULT N pthread_mutex_getprioceiling
+ FUNC GLOBAL DEFAULT N pthread_mutex_init
+ FUNC GLOBAL DEFAULT N pthread_mutex_lock
++ FUNC GLOBAL DEFAULT N pthread_mutex_setprioceiling
+ FUNC GLOBAL DEFAULT N pthread_mutex_timedlock
+ FUNC GLOBAL DEFAULT N pthread_mutex_trylock
+ FUNC GLOBAL DEFAULT N pthread_mutex_unlock
+ FUNC GLOBAL DEFAULT N pthread_mutexattr_destroy
+ FUNC WEAK DEFAULT N pthread_mutexattr_getkind_np
+- FUNC WEAK DEFAULT N pthread_mutexattr_getpshared
+- FUNC WEAK DEFAULT N pthread_mutexattr_gettype
++ FUNC GLOBAL DEFAULT N pthread_mutexattr_getprioceiling
++ FUNC GLOBAL DEFAULT N pthread_mutexattr_getprotocol
++ FUNC GLOBAL DEFAULT N pthread_mutexattr_getpshared
++ FUNC GLOBAL DEFAULT N pthread_mutexattr_getrobust_np
++ FUNC GLOBAL DEFAULT N pthread_mutexattr_gettype
+ FUNC GLOBAL DEFAULT N pthread_mutexattr_init
+ FUNC WEAK DEFAULT N pthread_mutexattr_setkind_np
+- FUNC WEAK DEFAULT N pthread_mutexattr_setpshared
+- FUNC WEAK DEFAULT N pthread_mutexattr_settype
++ FUNC GLOBAL DEFAULT N pthread_mutexattr_setprioceiling
++ FUNC GLOBAL DEFAULT N pthread_mutexattr_setprotocol
++ FUNC GLOBAL DEFAULT N pthread_mutexattr_setpshared
++ FUNC GLOBAL DEFAULT N pthread_mutexattr_setrobust_np
++ FUNC GLOBAL DEFAULT N pthread_mutexattr_settype
+ FUNC GLOBAL DEFAULT N pthread_once
+ FUNC GLOBAL DEFAULT N pthread_rwlock_destroy
+ FUNC GLOBAL DEFAULT N pthread_rwlock_init
+@@ -240,27 +238,35 @@
+ FUNC GLOBAL DEFAULT N pthread_rwlockattr_setkind_np
+ FUNC GLOBAL DEFAULT N pthread_rwlockattr_setpshared
+ FUNC GLOBAL DEFAULT N pthread_self
++ FUNC GLOBAL DEFAULT N pthread_setaffinity_np
+ FUNC GLOBAL DEFAULT N pthread_setcancelstate
+ FUNC GLOBAL DEFAULT N pthread_setcanceltype
+- FUNC WEAK DEFAULT N pthread_setconcurrency
+- FUNC GLOBAL DEFAULT N pthread_setegid_np
+- FUNC GLOBAL DEFAULT N pthread_seteuid_np
+- FUNC GLOBAL DEFAULT N pthread_setgid_np
+- FUNC GLOBAL DEFAULT N pthread_setregid_np
+- FUNC GLOBAL DEFAULT N pthread_setresgid_np
+- FUNC GLOBAL DEFAULT N pthread_setresuid_np
+- FUNC GLOBAL DEFAULT N pthread_setreuid_np
++ FUNC GLOBAL DEFAULT N pthread_setconcurrency
+ FUNC GLOBAL DEFAULT N pthread_setschedparam
++ FUNC GLOBAL DEFAULT N pthread_setschedprio
+ FUNC GLOBAL DEFAULT N pthread_setspecific
+- FUNC GLOBAL DEFAULT N pthread_setuid_np
+ FUNC GLOBAL DEFAULT N pthread_sigmask
+- FUNC WEAK DEFAULT N pthread_spin_destroy
+- FUNC WEAK DEFAULT N pthread_spin_init
+- FUNC WEAK DEFAULT N pthread_spin_lock
+- FUNC WEAK DEFAULT N pthread_spin_trylock
+- FUNC WEAK DEFAULT N pthread_spin_unlock
++ FUNC GLOBAL DEFAULT N pthread_spin_destroy
++ FUNC GLOBAL DEFAULT N pthread_spin_init
++ FUNC GLOBAL DEFAULT N pthread_spin_lock
++ FUNC GLOBAL DEFAULT N pthread_spin_trylock
++ FUNC GLOBAL DEFAULT N pthread_spin_unlock
+ FUNC GLOBAL DEFAULT N pthread_testcancel
++ FUNC GLOBAL DEFAULT N pthread_timedjoin_np
++ FUNC GLOBAL DEFAULT N pthread_tryjoin_np
++ FUNC GLOBAL DEFAULT N pthread_yield
++ FUNC WEAK DEFAULT N pwrite
++ FUNC WEAK DEFAULT N pwrite64
+ FUNC GLOBAL DEFAULT N raise
++ FUNC WEAK DEFAULT N read
++ FUNC GLOBAL DEFAULT UND realloc
++ FUNC WEAK DEFAULT N recv
++ FUNC WEAK DEFAULT N recvfrom
++ FUNC WEAK DEFAULT N recvmsg
++ FUNC GLOBAL DEFAULT UND sched_get_priority_max
++ FUNC GLOBAL DEFAULT UND sched_get_priority_min
++ FUNC GLOBAL DEFAULT UND sched_setparam
++ FUNC GLOBAL DEFAULT UND sched_yield
+ FUNC GLOBAL DEFAULT N sem_close
+ FUNC GLOBAL DEFAULT N sem_destroy
+ FUNC GLOBAL DEFAULT N sem_getvalue
+@@ -271,8 +277,23 @@
+ FUNC GLOBAL DEFAULT N sem_trywait
+ FUNC GLOBAL DEFAULT N sem_unlink
+ FUNC GLOBAL DEFAULT N sem_wait
+- FUNC GLOBAL DEFAULT N set_eflags
+- FUNC GLOBAL DEFAULT N sigaction
+- FUNC GLOBAL DEFAULT N siglongjmp
+- FUNC GLOBAL DEFAULT N sigwait
+- FUNC GLOBAL DEFAULT N testandset
++ FUNC WEAK DEFAULT N send
++ FUNC WEAK DEFAULT N sendmsg
++ FUNC WEAK DEFAULT N sendto
++ FUNC WEAK DEFAULT N sigaction
++ FUNC WEAK DEFAULT N siglongjmp
++ FUNC WEAK DEFAULT N sigwait
++ FUNC GLOBAL DEFAULT UND sscanf
++ FUNC GLOBAL DEFAULT UND strcmp
++ FUNC GLOBAL DEFAULT UND strlen
++ FUNC GLOBAL DEFAULT N system
++ FUNC WEAK DEFAULT N tcdrain
++ FUNC GLOBAL DEFAULT UND tdelete
++ FUNC GLOBAL DEFAULT UND tfind
++ FUNC GLOBAL DEFAULT UND tsearch
++ FUNC GLOBAL DEFAULT UND twalk
++ FUNC GLOBAL DEFAULT UND unlink
++ FUNC WEAK DEFAULT N vfork
++ FUNC WEAK DEFAULT N wait
++ FUNC WEAK DEFAULT N waitpid
++ FUNC WEAK DEFAULT N write
+
+
+And uclibc_unrefd.lst is:
+
+__compare_and_swap
+__flockfilelist
+__fresetlockfiles
+__funlockfilelist
+__linuxthreads_create_event
+__linuxthreads_death_event
+__linuxthreads_initial_report_events
+__linuxthreads_pthread_key_2ndlevel_size
+__linuxthreads_pthread_keys_max
+__linuxthreads_pthread_sizeof_descr
+__linuxthreads_pthread_threads_max
+__linuxthreads_reap_event
+__linuxthreads_version
+__pthread_alt_lock
+__pthread_alt_timedlock
+__pthread_alt_unlock
+__pthread_attr_destroy
+__pthread_attr_getdetachstate
+__pthread_attr_getguardsize
+__pthread_attr_getinheritsched
+__pthread_attr_getschedparam
+__pthread_attr_getschedpolicy
+__pthread_attr_getscope
+__pthread_attr_getstack
+__pthread_attr_getstacksize
+__pthread_attr_init
+__pthread_attr_setdetachstate
+__pthread_attr_setguardsize
+__pthread_attr_setinheritsched
+__pthread_attr_setschedparam
+__pthread_attr_setschedpolicy
+__pthread_attr_setscope
+__pthread_attr_setstack
+__pthread_attr_setstacksize
+__pthread_barrierattr_getpshared
+__pthread_compare_and_swap
+__pthread_cond_broadcast
+__pthread_cond_destroy
+__pthread_cond_init
+__pthread_cond_signal
+__pthread_cond_timedwait
+__pthread_cond_wait
+__pthread_condattr_destroy
+__pthread_condattr_init
+__pthread_create
+__pthread_destroy_specifics
+__pthread_do_exit
+__pthread_equal
+__pthread_exit_code
+__pthread_exit_requested
+__pthread_find_self
+__pthread_functions
+__pthread_getconcurrency
+__pthread_getschedparam
+__pthread_getspecific
+__pthread_handles
+__pthread_handles_num
+__pthread_has_cas
+__pthread_init_max_stacksize
+__pthread_initial_thread
+__pthread_initial_thread_bos
+__pthread_initialize_manager
+__pthread_internal_tsd_address
+__pthread_internal_tsd_get
+__pthread_internal_tsd_set
+__pthread_key_create
+__pthread_kill_other_threads_np
+__pthread_last_event
+__pthread_lock
+__pthread_main_thread
+__pthread_manager
+__pthread_manager_adjust_prio
+__pthread_manager_event
+__pthread_manager_reader
+__pthread_manager_request
+__pthread_manager_sighandler
+__pthread_manager_thread
+__pthread_manager_thread_bos
+__pthread_manager_thread_tos
+__pthread_max_stacksize
+__pthread_mutex_destroy
+__pthread_mutex_timedlock
+__pthread_mutexattr_destroy
+__pthread_mutexattr_getkind_np
+__pthread_mutexattr_getpshared
+__pthread_mutexattr_gettype
+__pthread_mutexattr_init
+__pthread_mutexattr_setkind_np
+__pthread_mutexattr_setpshared
+__pthread_mutexattr_settype
+__pthread_nonstandard_stacks
+__pthread_null_sighandler
+__pthread_offsetof_descr
+__pthread_offsetof_pid
+__pthread_once_fork_child
+__pthread_once_fork_parent
+__pthread_once_fork_prepare
+__pthread_perform_cleanup
+__pthread_raise
+__pthread_reset_main_thread
+__pthread_restart_new
+__pthread_rwlock_destroy
+__pthread_rwlock_init
+__pthread_rwlock_rdlock
+__pthread_rwlock_timedrdlock
+__pthread_rwlock_timedwrlock
+__pthread_rwlock_tryrdlock
+__pthread_rwlock_trywrlock
+__pthread_rwlock_unlock
+__pthread_rwlock_wrlock
+__pthread_rwlockattr_destroy
+__pthread_self
+__pthread_setcancelstate
+__pthread_setcanceltype
+__pthread_setconcurrency
+__pthread_setschedparam
+__pthread_setspecific
+__pthread_sig_cancel
+__pthread_sig_debug
+__pthread_sig_restart
+__pthread_sigaction
+__pthread_sighandler
+__pthread_sighandler_rt
+__pthread_sigwait
+__pthread_sizeof_handle
+__pthread_smp_kernel
+__pthread_spin_destroy
+__pthread_spin_init
+__pthread_spin_lock
+__pthread_spin_trylock
+__pthread_spin_unlock
+__pthread_thread_self
+__pthread_threads_debug
+__pthread_threads_events
+__pthread_threads_max
+__pthread_timedsuspend_new
+__pthread_unlock
+__pthread_wait_for_restart_signal
+__register_atfork
+__sigaction
+__sighandler
+compare_and_swap_is_available
+get_eflags
+pthread_attr_getguardsize
+pthread_attr_getstack
+pthread_attr_getstacksize
+pthread_attr_setguardsize
+pthread_attr_setstack
+pthread_attr_setstacksize
+pthread_barrier_destroy
+pthread_barrier_init
+pthread_barrier_wait
+pthread_barrierattr_destroy
+pthread_barrierattr_init
+pthread_barrierattr_setpshared
+pthread_cancel
+pthread_condattr_getpshared
+pthread_condattr_setpshared
+pthread_create
+pthread_detach
+pthread_getattr_np
+pthread_getconcurrency
+pthread_getspecific
+pthread_join
+pthread_key_create
+pthread_key_delete
+pthread_kill
+pthread_kill_other_threads_np
+pthread_mutex_timedlock
+pthread_mutexattr_destroy
+pthread_mutexattr_getkind_np
+pthread_mutexattr_getpshared
+pthread_mutexattr_gettype
+pthread_mutexattr_init
+pthread_mutexattr_setkind_np
+pthread_mutexattr_setpshared
+pthread_mutexattr_settype
+pthread_rwlock_destroy
+pthread_rwlock_init
+pthread_rwlock_rdlock
+pthread_rwlock_timedrdlock
+pthread_rwlock_timedwrlock
+pthread_rwlock_tryrdlock
+pthread_rwlock_trywrlock
+pthread_rwlock_unlock
+pthread_rwlock_wrlock
+pthread_rwlockattr_destroy
+pthread_rwlockattr_getkind_np
+pthread_rwlockattr_getpshared
+pthread_rwlockattr_init
+pthread_rwlockattr_setkind_np
+pthread_rwlockattr_setpshared
+pthread_setconcurrency
+pthread_setegid_np
+pthread_seteuid_np
+pthread_setgid_np
+pthread_setregid_np
+pthread_setresgid_np
+pthread_setresuid_np
+pthread_setreuid_np
+pthread_setspecific
+pthread_setuid_np
+pthread_sigmask
+pthread_spin_destroy
+pthread_spin_init
+pthread_spin_lock
+pthread_spin_trylock
+pthread_spin_unlock
+pthread_testcancel
+sem_close
+sem_destroy
+sem_getvalue
+sem_init
+sem_open
+sem_post
+sem_timedwait
+sem_trywait
+sem_unlink
+sem_wait
+set_eflags
+testandset
diff --git a/docs/sigaction.txt b/docs/sigaction.txt
new file mode 100644
index 000000000..667eeba41
--- /dev/null
+++ b/docs/sigaction.txt
@@ -0,0 +1,249 @@
+ All what you never wanted to know about sigaction(),
+ struct sigaction, and sigset_t.
+
+
+Before vda started messing with sigset_t, struct sigaction
+and sigaction() functions, things looked this way:
+
+
+ Structures
+
+MIPS:
+
+Ignoring bogus "#if defined(__mips__) ..." block in
+libc/sysdeps/linux/common/bits/kernel_sigaction.h
+and using
+libc/sysdeps/linux/mips/bits/kernel_sigaction.h
+as an authoritative source:
+
+HAVE_SA_RESTORER is #defined
+struct old_kernel_sigaction {
+ unsigned sa_flags;
+ sighandler_t k_sa_handler;
+ unsigned long sa_mask;
+ unsigned pad0[3]; /* reserved, keep size constant */
+ /* Abi says here follows reserved int[2] */
+ void (*sa_restorer)(void);
+#if (_MIPS_SZPTR < 64)
+ /* For 32 bit code we have to pad struct sigaction to get
+ * constant size for the ABI */
+ int pad1[1]; /* reserved */
+#endif
+};
+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 */
+};
+struct sigaction {
+ unsigned sa_flags;
+ sighandler_t sa_handler;
+ 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];
+#endif
+};
+
+IA64:
+
+Has no old_sigaction. What a relief.
+
+struct kernel_sigaction {
+ sighandler_t k_sa_handler;
+ unsigned long sa_flags;
+ sigset_t sa_mask;
+};
+struct sigaction {
+ sighandler_t sa_handler;
+ unsigned long sa_flags;
+ sigset_t sa_mask;
+};
+
+Alpha:
+
+struct old_kernel_sigaction {
+ sighandler_t k_sa_handler;
+ unsigned long sa_mask;
+ unsigned sa_flags;
+};
+struct kernel_sigaction {
+ sighandler_t k_sa_handler;
+ unsigned sa_flags;
+ sigset_t sa_mask;
+};
+struct sigaction {
+ sighandler_t sa_handler;
+ sigset_t sa_mask;
+ unsigned sa_flags;
+};
+
+HPPA:
+
+struct kernel_sigaction {
+ sighandler_t k_sa_handler;
+ unsigned long sa_flags;
+ sigset_t sa_mask;
+};
+struct sigaction {
+ sighandler_t sa_handler;
+ unsigned long sa_flags;
+ sigset_t sa_mask;
+};
+
+The rest, kernel side:
+
+HAVE_SA_RESTORER #defined
+struct old_kernel_sigaction {
+ sighandler_t k_sa_handler;
+ unsigned long sa_mask;
+ unsigned long sa_flags;
+ void (*sa_restorer)(void);
+};
+struct kernel_sigaction {
+ sighandler_t k_sa_handler;
+ unsigned long sa_flags;
+ void (*sa_restorer)(void);
+ sigset_t sa_mask;
+};
+
+On userspace side, Sparc has special struct sigaction:
+
+struct sigaction {
+ sighandler_t sa_handler;
+ sigset_t sa_mask;
+ unsigned long sa_flags;
+ void (*sa_restorer)(void); /* Not used by Linux/Sparc */
+};
+
+And finally the rest has:
+
+struct sigaction {
+ sighandler_t sa_handler;
+ sigset_t sa_mask;
+ int sa_flags;
+ void (*sa_restorer)(void);
+};
+
+Userspace sigset_t was uniformly defined as vector of longs
+big enough to hold 1024 (!) bits - carried over from glibc.
+Since the only arch whose struct kernel_sigaction contains sa_mask
+not as a last member is MIPS, MIPS has special kernel_sigset_t,
+which is an array of longs long enough for 128 bits.
+Other arches still used userspace sigset_t in struct kernel_sigaction,
+but it did not really matter because overlong kernel_sigaction
+does not hurt in sigaction() [explained below].
+On kernel side, all arches define _NSIG to 65 (meaning
+there are 64 signals, 1..64) except MIPS, which define it to 129.
+
+
+ Functions
+
+sigaction() [libc function] usually has two kernel_sigaction's
+on stack and copy (userspace) struct sigaction members into
+first one, executes syscall, then pulls out the result from
+second one. This accomodates differences in layouts of structs.
+
+The only typically present quirk is what to do with sa_restorer.
+
+ libc/sysdeps/linux/arm/sigaction.c
+
+if HAVE_SA_RESTORER and (sa_flags & SA_RESTORER) is not set,
+sets sa_restorer to
+(flags & SA_SIGINFO) ? __default_rt_sa_restorer : __default_sa_restorer,
+and sets SA_RESTORER,
+otherwise passes it as-is. Which is kinda strange, because AFAICS
+HAVE_SA_RESTORER is *not* defined for ARM.
+
+ libc/sysdeps/linux/i386/sigaction.c
+
+Forcibly sets SA_RESTORER and sa_restorer:
+kact.sa_flags = act->sa_flags | SA_RESTORER;
+kact.sa_restorer = ((act->sa_flags & SA_SIGINFO) ? &restore_rt : &restore);
+
+ libc/sysdeps/linux/x86_64/sigaction.c
+
+Forcibly sets SA_RESTORER and sa_restorer:
+kact.sa_flags = act->sa_flags | SA_RESTORER;
+kact.sa_restorer = &restore_rt;
+
+ libc/sysdeps/linux/mips/sigaction.c
+
+# ifdef HAVE_SA_RESTORER
+# if _MIPS_SIM == _ABIO32
+ kact.sa_restorer = act->sa_restorer;
+# else
+ kact.sa_restorer = &restore_rt;
+# endif
+# endif
+No confusion here, HAVE_SA_RESTORER is #defined for MIPS
+
+ libc/sysdeps/linux/avr32/sigaction.c
+
+if (kact.sa_flags & SA_RESTORER) {
+ kact.sa_restorer = act->sa_restorer;
+} else {
+ kact.sa_restorer = __default_rt_sa_restorer;
+ kact.sa_flags |= SA_RESTORER;
+}
+Does not check HAVE_SA_RESTORER, but avr32 falls
+in "completely ordinary" category on both kernel and
+userspace sides, and those have it defined.
+
+ libc/sysdeps/linux/xtensa/sigaction.c
+
+if (kact.sa_flags & SA_RESTORER) {
+ kact.sa_restorer = act->sa_restorer;
+} else {
+ kact.sa_restorer = __default_sa_restorer;
+ kact.sa_flags |= SA_RESTORER;
+}
+Thus, similar to avr32.
+
+ libc/signal/sigaction.c (i.e. the all other arches)
+
+# ifdef HAVE_SA_RESTORER
+ kact.sa_restorer = act->sa_restorer;
+# endif
+Plain translation, just sa_restorer copy is protected
+by HAVE_SA_RESTORER #define check. Looks like here
+HAVE_SA_RESTORER will be undef'ed only for IA64,
+Alpha an HPPA.
+
+
+ Proposed overhaul past 0.9.30
+
+Since we can define libc-side structures at will:
+make sigset_t and struct sigaction identical on kernel side and libc side
+within each arch. If arches do not need special handling of sa_restorer,
+then sigaction() can directly use passed struct sigaction as-is.
+Otherwise, a copy is still needed, although sigaction() might have
+just one struct kernel_sigaction on stack and use it both for passing
+data to kernel and for receiving it back. Might save a few bytes.
+
+To this effect:
+
+* Make sigset_t size match kernel side on all arches.
+ This is easy since all arches have 64 signals and only MIPS has 128.
+
+* Modify libc/sysdeps/linux/$ARCH/bits/sigaction.h
+ so that its struct sigaction matches kernel's. If sa_restorer
+ field is present in libc but is missing in kernel_sigaction,
+ add it at the bottom in order to not mess up kernel_sigaction layout.
+
+* Modify libc/sysdeps/linux/$ARCH/sigaction.c
+ to implement the logic above. In "common" pseudo-arch
+ (libc/signal/sigaction.c file),
+ we would not even need to do any copying, as described above.
+
+* Document discovered arch quirks while debugging this mess.
+
+* struct old_kernel_sigaction can't be disposed of in a similar way,
+ we need to have userspace struct sigaction unchanged regardless
+ whether we use "old" or "new" kernel sigaction() syscall.
+ It's moot anyway because "old" one is long unused, it's from
+ pre-2.2 kernels.
diff --git a/docs/wchar_and_locale.txt b/docs/wchar_and_locale.txt
new file mode 100644
index 000000000..976c9aaad
--- /dev/null
+++ b/docs/wchar_and_locale.txt
@@ -0,0 +1,113 @@
+ User-configurable
+
+UCLIBC_HAS_CTYPE_TABLES
+ Make toupper etc work thru translation tables
+ and isalhum etc thru lookup tables. Help says:
+ "While the non-table versions are often smaller when building
+ statically linked apps, they work only in stub locale mode."
+
+ "stub locale mode" is when !UCLIBC_HAS_LOCALE I presume,
+ when we are permanently in POSIX/C locale.
+
+UCLIBC_HAS_CTYPE_SIGNED
+ Handle sign-extended chars. I.e. if you want
+ toupper((char)0xa0) => toupper(0xffffffa0) => still works correctly,
+ as if toupper(0xa0) was called.
+
+UCLIBC_HAS_CTYPE_UNSAFE/CHECKED/ENFORCED
+ Do not check ctype function argument's range/check it and return
+ error/check it and abort(). Help says:
+ NOTE: This only affects the 'ctype' _functions_. It does not affect
+ the macro implementations. [so what happens to macros?]
+ [examples?]
+
+UCLIBC_HAS_WCHAR
+ Wide character support. I assume all those wchar_t types and functions
+
+UCLIBC_HAS_LOCALE/XLOCALE
+ Support locale / extended locale
+
+UCLIBC_PREGENERATED_LOCALE_DATA
+ Not recommended
+
+
+ uclibc internal machinery
+
+__LOCALE_C_ONLY
+ #defined if !UCLIBC_HAS_LOCALE
+
+__NO_CTYPE
+ #defined only by some .c files. Prevents ctype macros to be #defined
+ (those w/o underscores. __ctype() macros will still be defined).
+ Looks like user is expected to never mess with defining it.
+
+__UCLIBC_DO_XLOCALE
+ #defined only by some .c files. Looks like user is expected to never
+ mess with defining it.
+
+__XL_NPP(N) - "add _l suffix if locale support is on"
+ #defined to N ## _l if __UCLIBC_HAS_XLOCALE__ && __UCLIBC_DO_XLOCALE,
+ else #defined to just N.
+
+__CTYPE_HAS_8_BIT_LOCALES
+__CTYPE_HAS_UTF_8_LOCALES
+ Depends on contents of extra/locale/LOCALES data file. Looks like
+ both will be set if UCLIBC_HAS_LOCALE and extra/locale/LOCALES
+ is not edited.
+
+__WCHAR_ENABLED
+ locale_mmap.h defines it unconditionally, extra/locale/gen_ldc.c
+ defines it too with a warning, and _then_ includes locale_mmap.h.
+ Makefile seems to prevent the warning in gen_ldc.c:
+ ifeq ($(UCLIBC_HAS_WCHAR),y)
+ BUILD_CFLAGS-gen_wc8bit += -DDO_WIDE_CHAR=1
+ BUILD_CFLAGS-gen_ldc += -D__WCHAR_ENABLED=1
+ endif
+ A mess. Why they can't just use __UCLIBC_HAS_WCHAR__?
+
+__WCHAR_REPLACEMENT_CHAR
+ Never defined (dead code???)
+
+
+
+ Actual ctype macros are a bloody mess!
+
+__C_isspace(c), __C_tolower(c) et al
+ Defined in bits/uClibc_ctype.h. Non-locale-aware, unsafe
+ wrt multiple-evaluation, macros. Return unsigned int.
+
+__isspace(c), __tolower(c) et al
+ Defined in bits/uClibc_ctype.h. Non-locale-aware,
+ but safe wrt multiple-evaluation, macros. Return int.
+
+__isdigit_char, __isdigit_int
+ Visible only to uclibc code. ((unsigned char/int)((c) - '0') <= 9).
+
+_tolower(c), _toupper(c)
+ Even more unsafe versions (they just do | 0x20 or ^ 0x20). Sheesh.
+ They are mandated by POSIX so we must have them defined,
+ but I removed all uses in uclibc code. Half of them were buggy.
+
+isspace(c), tolower(c) et al
+ Declared as int isXXXX(int c) in bits/uClibc_ctype.h. Then,
+ if not C++ compile, defined as macros to __usXXXX(c)
+
+bits/uClibc_ctype.h is included by ctype.h only if !__UCLIBC_HAS_CTYPE_TABLES__.
+
+Otherwise, ctype.h declares int isXXXX(int c) functions,
+then defines macros for isXXXX(c), __isXXX(c), toXXXX(c).
+Surprisingly, there are no __toXXXX(c), but if __USE_EXTERN_INLINES,
+there are inlines (yes, not macros!) for toXXXX(c) functions,
+so those may have both inlines and macros!).
+It also defines "unsafe" _toXXXX macros.
+
+All in all, __isXXXX(c) and __toXXXXX(c) seem to be useless,
+they are full equivalents to non-underscored versions.
+Remove?
+
+Macro-ization of isXXX(c) for __UCLIBC_HAS_XLOCALE__ case is problematic:
+it is done by indexing: __UCLIBC_CTYPE_B[c], and in __UCLIBC_HAS_XLOCALE__
+case __UCLIBC_CTYPE_B is doing a __ctype_b_loc() call! We do not save
+function call! Thus, why not have dedicated optimized functions
+for each isXXXX() instead? Looking deeper, __ctype_b_loc() may have
+another lever of function calls inside! What a mess...
diff --git a/extra/Configs/Config.alpha b/extra/Configs/Config.alpha
index fd2d7a8e5..212df6a82 100644
--- a/extra/Configs/Config.alpha
+++ b/extra/Configs/Config.alpha
@@ -13,7 +13,5 @@ config FORCE_OPTIONS_FOR_ARCH
select ARCH_LITTLE_ENDIAN
select ARCH_HAS_MMU
select ARCH_HAS_NO_LDSO
+ select ARCH_HAS_DEPRECATED_SYSCALLS
select UCLIBC_HAS_LFS
-
-config ARCH_CFLAGS
- string
diff --git a/extra/Configs/Config.arc b/extra/Configs/Config.arc
new file mode 100644
index 000000000..0c0bc71ce
--- /dev/null
+++ b/extra/Configs/Config.arc
@@ -0,0 +1,46 @@
+#
+# For a description of the syntax of this configuration file,
+# see extra/config/Kconfig-language.txt
+#
+config TARGET_ARCH
+ default "arc"
+
+config FORCE_OPTIONS_FOR_ARCH
+ bool
+ default y
+ select ARCH_ANY_ENDIAN
+
+choice
+ prompt "Target Processor Type"
+ default CONFIG_ARC_CPU_700
+
+config CONFIG_ARC_CPU_700
+ bool "ARC700"
+ select ARCH_HAS_MMU
+ help
+ ARCompact ISA based ARC CPU
+
+config CONFIG_ARC_CPU_HS
+ bool "ARC-HS"
+ select ARCH_HAS_MMU
+ help
+ Next Generation ARCv2 ISA based Processors
+
+endchoice
+
+choice
+ prompt "MMU Page Size"
+ default CONFIG_ARC_PAGE_SIZE_8K
+
+config CONFIG_ARC_PAGE_SIZE_8K
+ bool "8KB"
+ help
+ Choose between 4k, 8k (default) or 16k
+
+config CONFIG_ARC_PAGE_SIZE_16K
+ bool "16KB"
+
+config CONFIG_ARC_PAGE_SIZE_4K
+ bool "4KB"
+
+endchoice
diff --git a/extra/Configs/Config.arm b/extra/Configs/Config.arm
index 26e1f3da4..00cf98281 100644
--- a/extra/Configs/Config.arm
+++ b/extra/Configs/Config.arm
@@ -11,126 +11,38 @@ config FORCE_OPTIONS_FOR_ARCH
bool
default y
select ARCH_ANY_ENDIAN
+ select ARCH_HAS_UCONTEXT
+ select ARCH_HAS_DEPRECATED_SYSCALLS
-config ARCH_CFLAGS
- string
-
-choice
- prompt "Target ABI"
- default CONFIG_ARM_OABI
+config CONFIG_ARM_EABI
+ bool "Build for EABI"
help
- If you choose "EABI" here, functions and constants required by the
- ARM EABI will be built into the library. You should choose "EABI"
+ If you say 'y' here, functions and constants required by the
+ ARM EABI will be built into the library. You should say 'y'
if your compiler uses the ARM EABI, in which case you will also
- need a kernel supporting the EABI system call interface, or "OABI"
- for a compiler using the old Linux ABI.
-
-config CONFIG_ARM_OABI
- bool "OABI"
+ need a kernel supporting the EABI system call interface.
-config CONFIG_ARM_EABI
- bool "EABI"
+ If you say 'n' here, then the library will be built for the
+ old Linux ABI.
-endchoice
+config COMPILE_IN_THUMB_MODE
+ bool "Build using Thumb mode"
+ select USE_BX
+ select USE_LDREXSTREX
+ help
+ Say 'y' here to force building uClibc in thumb mode.
+ Say 'n' to use your compiler's default mode.
config USE_BX
bool "Use BX in function return"
- default y
- depends on !CONFIG_GENERIC_ARM && !CONFIG_ARM610 && !CONFIG_ARM710
help
- Use BX instruction for THUMB aware architectures.
-
-choice
- prompt "Target Processor Type"
- default CONFIG_GENERIC_ARM
+ Say 'y' to use BX to return from functions on your thumb-aware
+ processor. Say 'y' if you need to use interworking. Say 'n' if not.
+ It is safe to say 'y' even if you're not doing interworking.
+
+config USE_LDREXSTREX
+ bool "Use load-store exclusive ASM ops (not supported in SmartFusion)"
+ depends on COMPILE_IN_THUMB_MODE
+ default n
help
- This is the processor type of your CPU. This information is used for
- optimizing purposes. To build a library that will run on all ARMCPU
- types (albeit not optimally fast), you can specify "Generic Arm" here.
- If you pick anything other than "Generic Arm", there is no guarantee
- that uClibc will even run on anything other than the selected processor
- type.
-
- Here are the settings recommended for greatest speed:
- - "Generic Arm" select this if your compiler is already setup to
- optimize things properly, or if you want to run on pretty much
- everything, or you just don't much care.
- - For anything else, pick the ARM core type that best matches the
- cpu you will be using on your device.
-
- If you don't know what to do, choose "Generic Arm".
-
-config CONFIG_GENERIC_ARM
- bool "Generic Arm"
-
-config CONFIG_ARM610
- bool "Arm 610"
- select ARCH_HAS_MMU
-
-config CONFIG_ARM710
- bool "Arm 710"
- select ARCH_HAS_MMU
-
-config CONFIG_ARM7TDMI
- bool "Arm 7TDMI"
- select ARCH_HAS_NO_MMU
-
-config CONFIG_ARM720T
- bool "Arm 720T"
- select ARCH_HAS_MMU
-
-config CONFIG_ARM920T
- bool "Arm 920T"
- select ARCH_HAS_MMU
-
-config CONFIG_ARM922T
- bool "Arm 922T"
- select ARCH_HAS_MMU
-
-config CONFIG_ARM926T
- bool "Arm 926T"
- select ARCH_HAS_MMU
-
-config CONFIG_ARM10T
- bool "Arm 10T"
- select ARCH_HAS_MMU
-
-config CONFIG_ARM1136JF_S
- bool "Arm 1136JF-S"
- select ARCH_HAS_MMU
-
-config CONFIG_ARM1176JZ_S
- bool "Arm 1176JZ-S"
- select ARCH_HAS_MMU
-
-config CONFIG_ARM1176JZF_S
- bool "Arm 1176JZF-S"
- select ARCH_HAS_MMU
-
-config CONFIG_ARM_CORTEX_M3
- bool "Arm Cortex-M3"
- select ARCH_HAS_NO_MMU
- select USE_BX
-
-config CONFIG_ARM_CORTEX_M1
- bool "Arm Cortex-M1"
- select ARCH_HAS_NO_MMU
- select USE_BX
-
-config CONFIG_ARM_SA110
- bool "Intel StrongArm SA-110"
- select ARCH_HAS_MMU
-
-config CONFIG_ARM_SA1100
- bool "Intel StrongArm SA-1100"
- select ARCH_HAS_MMU
-
-config CONFIG_ARM_XSCALE
- bool "Intel Xscale"
- select ARCH_HAS_MMU
-
-config CONFIG_ARM_IWMMXT
- bool "Intel Xscale With WMMX PXA27x"
- select ARCH_HAS_MMU
-
-endchoice
+ Say 'y' to use LDREX/STREX ASM ops.
diff --git a/extra/Configs/Config.avr32 b/extra/Configs/Config.avr32
index 8d70e6e99..5fcd6f216 100644
--- a/extra/Configs/Config.avr32
+++ b/extra/Configs/Config.avr32
@@ -11,11 +11,9 @@ config FORCE_OPTIONS_FOR_ARCH
bool
default y
select ARCH_BIG_ENDIAN
+ select ARCH_HAS_DEPRECATED_SYSCALLS
select FORCE_SHAREABLE_TEXT_SEGMENTS
-config ARCH_CFLAGS
- string
-
choice
prompt "Target CPU Type"
default CONFIG_AVR32_AP7
diff --git a/extra/Configs/Config.bfin b/extra/Configs/Config.bfin
index d5a9eae80..c3ed1716c 100644
--- a/extra/Configs/Config.bfin
+++ b/extra/Configs/Config.bfin
@@ -12,7 +12,4 @@ config FORCE_OPTIONS_FOR_ARCH
default y
select ARCH_LITTLE_ENDIAN
select ARCH_HAS_NO_MMU
- select UCLIBC_HAS_LFS
-
-config ARCH_CFLAGS
- string
+ select ARCH_HAS_DEPRECATED_SYSCALLS
diff --git a/extra/Configs/Config.c6x b/extra/Configs/Config.c6x
new file mode 100644
index 000000000..96adfb398
--- /dev/null
+++ b/extra/Configs/Config.c6x
@@ -0,0 +1,29 @@
+#
+# For a description of the syntax of this configuration file,
+# see extra/config/Kconfig-language.txt
+#
+
+config TARGET_ARCH
+ default "c6x"
+
+config FORCE_OPTIONS_FOR_ARCH
+ bool
+ default y
+ select ARCH_ANY_ENDIAN
+ select ARCH_HAS_NO_MMU
+
+choice
+ prompt "Target Processor Type"
+ default CONFIG_GENERIC_C6X
+
+config CONFIG_GENERIC_C6X
+ bool "Generic C6X DSP"
+
+config CONFIG_TMS320C64X
+ bool "TMS320C64X"
+
+config CONFIG_TMS320C64XPLUS
+ bool "TMS320C64X+"
+
+endchoice
+
diff --git a/extra/Configs/Config.cris b/extra/Configs/Config.cris
index 18c75fb58..c49817f65 100644
--- a/extra/Configs/Config.cris
+++ b/extra/Configs/Config.cris
@@ -11,18 +11,16 @@ config FORCE_OPTIONS_FOR_ARCH
bool
default y
select ARCH_LITTLE_ENDIAN
-
-config ARCH_CFLAGS
- string
+ select ARCH_HAS_DEPRECATED_SYSCALLS
choice
prompt "Target Architecture Type"
default CONFIG_CRIS
help
- This is the architecture type of your CPU. This information is used for
- optimizing purposes.
+ This is the architecture type of your CPU. This information
+ is used for optimizing purposes.
- These are the possible settings:
+ Possible settings:
- CRIS Generic support for Axis' CRIS architecture.
- CRISv32 Support for Axis' CRISv32 architecture.
diff --git a/extra/Configs/Config.e1 b/extra/Configs/Config.e1
deleted file mode 100644
index 144d9d34d..000000000
--- a/extra/Configs/Config.e1
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# For a description of the syntax of this configuration file,
-# see extra/config/Kconfig-language.txt
-#
-
-config TARGET_ARCH
- string
- default "e1"
-
-config FORCE_OPTIONS_FOR_ARCH
- bool
- default y
- select ARCH_BIG_ENDIAN
- select ARCH_HAS_NO_MMU
- select ARCH_HAS_NO_SHARED
-
-config ARCH_E1
- bool
- default y
-
-config ARCH_CFLAGS
- string
- default "-mgnu-param"
diff --git a/extra/Configs/Config.frv b/extra/Configs/Config.frv
index 63bbfed72..d7eeaf90e 100644
--- a/extra/Configs/Config.frv
+++ b/extra/Configs/Config.frv
@@ -13,6 +13,4 @@ config FORCE_OPTIONS_FOR_ARCH
select ARCH_BIG_ENDIAN
select UCLIBC_HAS_FPU
select ARCH_HAS_NO_MMU
-
-config ARCH_CFLAGS
- string
+ select ARCH_HAS_DEPRECATED_SYSCALLS
diff --git a/extra/Configs/Config.h8300 b/extra/Configs/Config.h8300
index 262a0d245..0c5486cdc 100644
--- a/extra/Configs/Config.h8300
+++ b/extra/Configs/Config.h8300
@@ -10,8 +10,10 @@ config TARGET_ARCH
config FORCE_OPTIONS_FOR_ARCH
bool
default y
- select ARCH_ANY_ENDIAN
+ select ARCH_BIG_ENDIAN
select ARCH_HAS_NO_MMU
+ select ARCH_HAS_NO_LDSO
+ select HAVE_NO_PIC
choice
prompt "Target Processor"
@@ -26,6 +28,3 @@ config CONFIG_H8S
bool "H8S (edosk2674)"
endchoice
-
-config ARCH_CFLAGS
- string
diff --git a/extra/Configs/Config.hppa b/extra/Configs/Config.hppa
index 1c264a800..938e2e35b 100644
--- a/extra/Configs/Config.hppa
+++ b/extra/Configs/Config.hppa
@@ -15,6 +15,4 @@ config FORCE_OPTIONS_FOR_ARCH
select HAS_NO_THREADS
select ARCH_HAS_NO_LDSO
select HAVE_NO_SSP
-
-config ARCH_CFLAGS
- string
+ select ARCH_HAS_DEPRECATED_SYSCALLS
diff --git a/extra/Configs/Config.i386 b/extra/Configs/Config.i386
index 850ab8ea8..c928ac1a2 100644
--- a/extra/Configs/Config.i386
+++ b/extra/Configs/Config.i386
@@ -12,44 +12,17 @@ config FORCE_OPTIONS_FOR_ARCH
default y
select ARCH_LITTLE_ENDIAN
select ARCH_HAS_MMU
+ select ARCH_HAS_UCONTEXT
+ select ARCH_HAS_DEPRECATED_SYSCALLS
choice
prompt "Target x86 Processor Family"
- default CONFIG_GENERIC_386
+ default CONFIG_686
help
This is the processor type of your CPU. This information is used for
- optimizing purposes. To build a library that will run on all x86 CPU
- types (albeit not optimally fast), you can specify "386" here. If
- you pick anything other than "386", there is no guarantee that uClibc
- will even run on anything other than the selected processor type.
-
- Here are the settings recommended for greatest speed:
- - "Generic 386" select this if your compiler is already setup to
- optimize things properly.
- - "386" for the AMD/Cyrix/Intel 386DX/DXL/SL/SLC/SX, Cyrix/TI
- 486DLC/DLC2, UMC 486SX-S and NexGen Nx586. Only "386" kernels
- will run on a 386 class machine.
- - "486" for the AMD/Cyrix/IBM/Intel 486DX/DX2/DX4 or
- SL/SLC/SLC2/SLC3/SX/SX2 and UMC U5D or U5S.
- - "586" for Intel Pentium and other generic Pentium CPUs
- - "Pentium-MMX" for the Intel Pentium MMX.
- - "Pentium-Pro" for the Intel Pentium Pro/Celeron/Pentium II.
- - "Pentium-III" for the Intel Pentium III
- and Celerons based on the Coppermine core.
- - "Pentium-4" for the Intel Pentium 4.
- - "K6" for the AMD K6, K6-II and K6-III (aka K6-3D).
- - "Athlon" for the AMD K7 family (Athlon/Duron/Thunderbird).
- - "Elan" for the AMD Elan.
- - "Crusoe" for the Transmeta Crusoe series.
- - "Winchip-C6" for original IDT Winchip.
- - "Winchip-2/Winchip-2A/Winchip-3" for IDT Winchip CPUs
- - "CyrixIII/VIA C3" for VIA Cyrix III or VIA C3.
- - "VIA C3-2 Nehemiah" model 9 and above.
-
- If you don't know what to do, choose "386".
-
-config CONFIG_GENERIC_386
- bool "Generic 386"
+ selecting different handcoded optimization functions. Nowadays, most
+ people have an i686 CPU. If you don't, you most likely know what this
+ means and can pick the right one for your processor.
config CONFIG_386
bool "386"
@@ -58,45 +31,9 @@ config CONFIG_486
bool "486"
config CONFIG_586
- bool "Pentium/586/K5/5x86/6x86/6x86MX"
-
-config CONFIG_586MMX
- bool "Pentium-MMX"
+ bool "586"
config CONFIG_686
- bool "Pentium-Pro"
-
-config CONFIG_PENTIUMII
- bool "Celeron/Pentium-II"
-
-config CONFIG_PENTIUMIII
- bool "Pentium-III/Celeron(Coppermine)/Pentium-III Xeon"
-
-config CONFIG_PENTIUM4
- bool "Pentium-4/Celeron(P4-based)/Xeon"
-
-config CONFIG_K6
- bool "K6/K6-II/K6-III"
-
-config CONFIG_K7
- bool "Athlon/Duron/K7"
-
-config CONFIG_ELAN
- bool "Elan"
-
-config CONFIG_CRUSOE
- bool "Crusoe"
-
-config CONFIG_WINCHIPC6
- bool "Winchip-C6"
-
-config CONFIG_WINCHIP2
- bool "Winchip-2/Winchip-2A/Winchip-3"
-
-config CONFIG_CYRIXIII
- bool "CyrixIII/VIA-C3"
-
-config CONFIG_NEHEMIAH
- bool "VIA C3-2 (Nehemiah)"
+ bool "686"
endchoice
diff --git a/extra/Configs/Config.i960 b/extra/Configs/Config.i960
deleted file mode 100644
index cb325c7ea..000000000
--- a/extra/Configs/Config.i960
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# For a description of the syntax of this configuration file,
-# see extra/config/Kconfig-language.txt
-#
-
-config TARGET_ARCH
- string
- default "i960"
-
-config FORCE_OPTIONS_FOR_ARCH
- bool
- default y
- select ARCH_LITTLE_ENDIAN
- select ARCH_HAS_NO_MMU
- select HAS_NO_THREADS
-
-config ARCH_CFLAGS
- string
- default "-mh -mint32 -fsigned-char"
diff --git a/extra/Configs/Config.ia64 b/extra/Configs/Config.ia64
index dc13319b3..983b3ee54 100644
--- a/extra/Configs/Config.ia64
+++ b/extra/Configs/Config.ia64
@@ -13,6 +13,4 @@ config FORCE_OPTIONS_FOR_ARCH
select ARCH_LITTLE_ENDIAN
select ARCH_HAS_MMU
select ARCH_HAS_NO_LDSO
-
-config ARCH_CFLAGS
- string
+ select ARCH_HAS_DEPRECATED_SYSCALLS
diff --git a/extra/Configs/Config.in b/extra/Configs/Config.in
index 4aca400b5..3afc2912d 100644
--- a/extra/Configs/Config.in
+++ b/extra/Configs/Config.in
@@ -3,16 +3,50 @@
# see extra/config/Kconfig-language.txt
#
-mainmenu "uClibc C Library Configuration"
+mainmenu "uClibc-ng $VERSION C Library Configuration"
+
+config DESIRED_TARGET_ARCH
+ string
+ option env="ARCH"
+
+config VERSION
+ string
+ option env="VERSION"
choice
prompt "Target Architecture"
- help
- Stuff
+ default TARGET_alpha if DESIRED_TARGET_ARCH = "alpha"
+ default TARGET_arc if DESIRED_TARGET_ARCH = "arc"
+ default TARGET_arm if DESIRED_TARGET_ARCH = "arm"
+ default TARGET_avr32 if DESIRED_TARGET_ARCH = "avr32"
+ default TARGET_bfin if DESIRED_TARGET_ARCH = "bfin"
+ default TARGET_cris if DESIRED_TARGET_ARCH = "cris"
+ default TARGET_frv if DESIRED_TARGET_ARCH = "frv"
+ default TARGET_h8300 if DESIRED_TARGET_ARCH = "h8300"
+ default TARGET_hppa if DESIRED_TARGET_ARCH = "hppa"
+ default TARGET_i386 if DESIRED_TARGET_ARCH = "i386"
+ default TARGET_ia64 if DESIRED_TARGET_ARCH = "ia64"
+ default TARGET_lm32 if DESIRED_TARGET_ARCH = "lm32"
+ default TARGET_m68k if DESIRED_TARGET_ARCH = "m68k"
+ default TARGET_metag if DESIRED_TARGET_ARCH = "metag"
+ default TARGET_microblaze if DESIRED_TARGET_ARCH = "microblaze"
+ default TARGET_mips if DESIRED_TARGET_ARCH = "mips"
+ default TARGET_nios2 if DESIRED_TARGET_ARCH = "nios2"
+ default TARGET_or1k if DESIRED_TARGET_ARCH = "or1k"
+ default TARGET_powerpc if DESIRED_TARGET_ARCH = "powerpc"
+ default TARGET_sh if DESIRED_TARGET_ARCH = "sh"
+ default TARGET_sparc if DESIRED_TARGET_ARCH = "sparc"
+ default TARGET_x86_64 if DESIRED_TARGET_ARCH = "x86_64"
+ default TARGET_xtensa if DESIRED_TARGET_ARCH = "xtensa"
+ help
+ The architecture of your target.
config TARGET_alpha
bool "alpha"
+config TARGET_arc
+ bool "arc"
+
config TARGET_arm
bool "arm"
@@ -22,17 +56,19 @@ config TARGET_avr32
config TARGET_bfin
bool "bfin"
+# someone could sync this tree:
+# http://linux-c6x.org/git/?p=uClibc.git;a=summary
+config TARGET_c6x
+ bool "c6x"
+
config TARGET_cris
bool "cris"
-config TARGET_e1
- bool "e1 (BROKEN)"
-
-config TARGET_frv
- bool "frv (BROKEN)"
+#config TARGET_frv
+# bool "frv (BROKEN)"
config TARGET_h8300
- bool "h8300 (BROKEN)"
+ bool "h8300"
config TARGET_hppa
bool "hppa"
@@ -40,45 +76,39 @@ config TARGET_hppa
config TARGET_i386
bool "i386"
-config TARGET_i960
- bool "i960 (BROKEN)"
-
config TARGET_ia64
bool "ia64"
+config TARGET_lm32
+ bool "lm32"
+
config TARGET_m68k
bool "m68k"
+config TARGET_metag
+ bool "metag"
+
config TARGET_microblaze
- bool "microblaze (BROKEN)"
+ bool "microblaze"
config TARGET_mips
bool "mips"
-config TARGET_nios
- bool "nios"
-
config TARGET_nios2
bool "nios2"
+config TARGET_or1k
+ bool "or1k"
+
config TARGET_powerpc
bool "powerpc"
config TARGET_sh
bool "superh"
-config TARGET_sh64
- bool "sh64"
-
config TARGET_sparc
bool "sparc"
-config TARGET_v850
- bool "v850 (BROKEN)"
-
-config TARGET_vax
- bool "vax"
-
config TARGET_x86_64
bool "x86_64"
@@ -110,10 +140,6 @@ if TARGET_cris
source "extra/Configs/Config.cris"
endif
-if TARGET_e1
-source "extra/Configs/Config.e1"
-endif
-
if TARGET_frv
source "extra/Configs/Config.frv"
endif
@@ -130,20 +156,20 @@ if TARGET_i386
source "extra/Configs/Config.i386"
endif
-if TARGET_i960
-source "extra/Configs/Config.i960"
-endif
-
if TARGET_ia64
source "extra/Configs/Config.ia64"
endif
+if TARGET_lm32
+source "extra/Configs/Config.lm32"
+endif
+
if TARGET_m68k
source "extra/Configs/Config.m68k"
endif
-if TARGET_nios
-source "extra/Configs/Config.nios"
+if TARGET_metag
+source "extra/Configs/Config.metag"
endif
if TARGET_nios2
@@ -158,6 +184,10 @@ if TARGET_mips
source "extra/Configs/Config.mips"
endif
+if TARGET_or1k
+source "extra/Configs/Config.or1k"
+endif
+
if TARGET_powerpc
source "extra/Configs/Config.powerpc"
endif
@@ -166,22 +196,10 @@ if TARGET_sh
source "extra/Configs/Config.sh"
endif
-if TARGET_sh64
-source "extra/Configs/Config.sh64"
-endif
-
if TARGET_sparc
source "extra/Configs/Config.sparc"
endif
-if TARGET_v850
-source "extra/Configs/Config.v850"
-endif
-
-if TARGET_vax
-source "extra/Configs/Config.vax"
-endif
-
if TARGET_x86_64
source "extra/Configs/Config.x86_64"
endif
@@ -190,11 +208,25 @@ if TARGET_xtensa
source "extra/Configs/Config.xtensa"
endif
+if TARGET_c6x
+source "extra/Configs/Config.c6x"
+endif
+
+if TARGET_arc
+source "extra/Configs/Config.arc"
+endif
+
config TARGET_SUBARCH
string
default "e500" if CONFIG_E500
default "classic" if CONFIG_CLASSIC
default "sh4" if CONFIG_SH4
+ default "sh4" if CONFIG_SH4A
+ default "" if CONFIG_386
+ default "i486" if CONFIG_486
+ default "i586" if CONFIG_586
+ default "i686" if CONFIG_686
+ default "arcv2" if CONFIG_ARC_CPU_HS
default ""
source "extra/Configs/Config.in.arch"
@@ -205,7 +237,6 @@ menu "General Library Settings"
config HAVE_NO_PIC
bool
- default n
config DOPIC
bool "Generate only Position Independent Code (PIC)"
@@ -217,15 +248,16 @@ config DOPIC
config ARCH_HAS_NO_SHARED
bool
- default n
config ARCH_HAS_NO_LDSO
bool
select ARCH_HAS_NO_SHARED
- default n
+
+config ARCH_HAS_UCONTEXT
+ bool
config HAVE_SHARED
- bool "Enable support for shared libraries"
+ bool "Enable shared libraries"
depends on !ARCH_HAS_NO_SHARED
default y
help
@@ -236,28 +268,29 @@ config HAVE_SHARED
config FORCE_SHAREABLE_TEXT_SEGMENTS
bool "Only load shared libraries which can share their text segment"
depends on HAVE_SHARED
- default n
+ select DOPIC
help
If you answer Y here, the uClibc native shared library loader will
- only load shared libraries, which do not need to modify any non-writable
- segments. These libraries haven't set the DT_TEXTREL tag in the dynamic
- section (==> objdump). All your libraries must be compiled with
- -fPIC or -fpic, and all assembler function must be written as position
- independent code (PIC).
+ only load shared libraries, which do not need to modify any
+ non-writable segments. These libraries haven't set the DT_TEXTREL
+ tag in the dynamic section (==> objdump).
+ All your libraries must be compiled with -fPIC or -fpic, and all
+ assembler function must be written as position independent code (PIC).
Enabling this option will make uClibc's shared library loader a
- little bit smaller and guarantee that no memory will be wasted by badly
- coded shared libraries.
+ little bit smaller and guarantee that no memory will be wasted by
+ badly coded shared libraries.
config LDSO_LDD_SUPPORT
bool "Native 'ldd' support"
depends on HAVE_SHARED
default y
help
- Enable this to enable all the code needed to support traditional ldd,
+ Enable all the code needed to support traditional ldd,
which executes the shared library loader to resolve all dependencies
and then provide a list of shared libraries that are required for an
- application to function. Disabling this option will makes uClibc's
- shared library loader a little bit smaller. Most people will answer Y.
+ application to function. Disabling this option will make uClibc's
+ shared library loader a little bit smaller.
+ Most people will answer Y.
config LDSO_CACHE_SUPPORT
bool "Enable library loader cache (ld.so.conf)"
@@ -269,10 +302,21 @@ config LDSO_CACHE_SUPPORT
After updating this file, it is necessary to run 'ldconfig' to update
the /etc/ld.so.cache shared library loader cache file.
+config LDSO_PRELOAD_ENV_SUPPORT
+ bool "Enable library loader LD_PRELOAD environment"
+ depends on HAVE_SHARED
+ default y
+ help
+ Enable this to make use of LD_PRELOAD environment variable.
+ A whitespace-separated list of additional, user-specified, ELF shared
+ libraries to be loaded before all others. This can be used to
+ selectively override functions in other shared libraries. For
+ set-user-ID/set-group-ID ELF binaries, only libraries in the standard
+ search directories that are also set-user-ID will be loaded.
+
config LDSO_PRELOAD_FILE_SUPPORT
bool "Enable library loader preload file (ld.so.preload)"
depends on HAVE_SHARED
- default n
help
Enable this to make use of /etc/ld.so.preload. This file contains a
whitespace separated list of shared libraries to be loaded before
@@ -295,6 +339,32 @@ config LDSO_BASE_FILENAME
WARNING: Changing the default prefix could cause problems with
binutils' ld !
+config LDSO_STANDALONE_SUPPORT
+ bool "Dynamic linker stand-alone mode support"
+ depends on HAVE_SHARED
+ help
+ The dynamic linker can be run either indirectly through running some
+ dynamically linked program or library (in which case no command line
+ options to the dynamic linker can be passed and, in the ELF case, the
+ dynamic linker which is stored in the .interp section of the program
+ is executed) or directly by running:
+
+ /lib/ld-uClibc.so.* [OPTIONS] [PROGRAM [ARGUMENTS]]
+
+ Stand-alone execution is a prerequisite for adding prelink
+ capabilities to uClibc dynamic linker, as well useful for testing an
+ updated version of the dynamic linker without breaking the system.
+
+config LDSO_PRELINK_SUPPORT
+ bool "Dynamic linker prelink support"
+ depends on HAVE_SHARED
+ select LDSO_STANDALONE_SUPPORT
+ help
+ The dynamic linker can be used in stand-alone mode by the prelink tool
+ for prelinking ELF shared libraries and binaries to speed up startup
+ time. It also is able to load and handle prelinked libraries and
+ binaries at runtime.
+
config UCLIBC_STATIC_LDCONFIG
bool "Link ldconfig statically"
depends on HAVE_SHARED
@@ -303,14 +373,14 @@ config UCLIBC_STATIC_LDCONFIG
Enable this option to statically link the ldconfig binary.
Making ldconfig static can be beneficial if you have a library
- problem and need to use ldconfig to recover. Sometimes, it is
+ problem and need to use ldconfig to recover. Sometimes it is
preferable to instead keep the size of the system down, in which
case you should disable this option.
config LDSO_RUNPATH
bool "Enable ELF RUNPATH tag support"
depends on HAVE_SHARED
- default y
+ default y if LDSO_CACHE_SUPPORT
help
ELF's may have dynamic RPATH/RUNPATH tags. These tags list paths
which extend the library search paths. They are really only useful
@@ -320,8 +390,60 @@ config LDSO_RUNPATH
Usage of RUNPATH tags is not too common, so disabling this feature
should be safe for most people.
+config LDSO_RUNPATH_OF_EXECUTABLE
+ bool "Use executables RUNPATH/RPATH when searching for libraries."
+ depends on LDSO_RUNPATH
+ default n
+ help
+ Use the executables RUNPATH/RPATH to find to find libraries even
+ though this behavour is not standard. Setting this option causes
+ the uclibc dynamic linker behavour to match the glibc dynamic linker.
+
+config LDSO_SAFE_RUNPATH
+ bool "Allow only RUNPATH beginning with /"
+ depends on LDSO_RUNPATH
+ default y
+ help
+ Allow only absolute path in RPATH/RUNPATH.
+
+config LDSO_SEARCH_INTERP_PATH
+ bool "Add ldso path to lib search path"
+ depends on HAVE_SHARED
+ default y
+ help
+ The ldso is told where it is being executed from and can use that
+ path to find related core libraries. This is useful by default,
+ but can be annoying in a mixed development environment.
+
+ i.e. if the ldso is run from /foo/boo/ldso.so, it will start its
+ library search with /foo/boo/
+
+ If unsure, simply say Y here.
+
+config LDSO_LD_LIBRARY_PATH
+ bool "Add LD_LIBRARY_PATH to lib search path"
+ depends on HAVE_SHARED
+ default y
+ help
+ On hardened system it could be useful to disable the use of
+ LD_LIBRARY_PATH environment variable (a colon-separated list of
+ directories in which to search for ELF libraries at execution-time).
+
+ If unsure, simply say Y here.
+
+config LDSO_NO_CLEANUP
+ bool "Disable automatic unloading of dynamically loaded shared objects"
+ depends on HAVE_SHARED
+ help
+ If you need complete allocation traces when debugging memory leaks
+ using Valgrind in a process that dynamically loads shared objects,
+ then answer Y here. Unlike glibc, uClibc unloads all dynamically
+ loaded shared objects when a process exits, which prevents Valgrind
+ from correctly resolving the symbols from the unloaded shared objects.
+ Unless you know you need this, you should answer N.
+
config UCLIBC_CTOR_DTOR
- bool "Support global constructors and destructors"
+ bool
default y
help
If you wish to build uClibc with support for global constructor
@@ -340,39 +462,112 @@ config UCLIBC_CTOR_DTOR
config LDSO_GNU_HASH_SUPPORT
bool "Enable GNU hash style support"
depends on HAVE_SHARED
- default n
help
Newest binutils support a new hash style named GNU-hash. The dynamic
linker will use the new GNU-hash section (.gnu.hash) for symbol lookup
if present into the ELF binaries, otherwise it will use the old SysV
- hash style (.hash). This ensures that it is completely backward compatible.
+ hash style (.hash). This ensures that it is completely backward
+ compatible.
Further, being the hash table implementation self-contained into each
executable and shared libraries, objects with mixed hash style can
peacefully coexist in the same process.
If you want to use this new feature, answer Y
-config HAS_NO_THREADS
- bool
- default n
-
-config UCLIBC_HAS_THREADS
- bool "POSIX Threading support"
- depends on !HAS_NO_THREADS
- default y
- # linuxthreads and linuxthreads.old need nanosleep()
- select UCLIBC_HAS_REALTIME
+choice
+ prompt "Thread support"
+ #default UCLIBC_HAS_THREADS_NATIVE if (TARGET_alpha || TARGET_arm || TARGET_i386 || TARGET_mips || TARGET_powerpc || TARGET_sh || TARGET_sh64)
+ default HAS_NO_THREADS
help
If you want to compile uClibc with pthread support, then answer Y.
This will increase the size of uClibc by adding a bunch of locking
to critical data structures, and adding extra code to ensure that
functions are properly reentrant.
- If your applications require pthreads, answer Y.
+config HAS_NO_THREADS
+ bool "none"
+ help
+ Disable thread support.
+
+config LINUXTHREADS_OLD
+ bool "older (stable) version of linuxthreads"
+ # linuxthreads and linuxthreads.old need nanosleep()
+ select UCLIBC_HAS_REALTIME
+ depends on !TARGET_arc && \
+ !TARGET_arm && \
+ !TARGET_i386 && \
+ !TARGET_metag && \
+ !TARGET_mips && \
+ !TARGET_powerpc && \
+ !TARGET_sparc && \
+ !TARGET_x86_64 && \
+ !TARGET_xtensa || \
+ !ARCH_USE_MMU
+ help
+ There are two versions of linuxthreads. The older (stable) version
+ has been in uClibc for quite a long time but hasn't seen too many
+ updates other than bugfixes.
+
+
+config LINUXTHREADS_NEW
+ bool "slightly newer version of linuxthreads"
+ depends on ARCH_HAS_DEPRECATED_SYSCALLS
+ depends on !TARGET_arc && \
+ !TARGET_arm && \
+ !TARGET_i386 && \
+ !TARGET_metag && \
+ !TARGET_mips && \
+ !TARGET_powerpc && \
+ !TARGET_sh && \
+ !TARGET_sparc && \
+ !TARGET_x86_64 && \
+ !TARGET_xtensa || \
+ !ARCH_USE_MMU
+ help
+ The new version has not been tested much, and lacks ports for arches
+ which glibc does not support (like bfin/frv/etc...), but is based on
+ the latest code from glibc, so it may be the only choice for the
+ newer ports (like alpha/amd64/64bit arches and hppa).
+
+config UCLIBC_HAS_THREADS_NATIVE
+ bool "Native POSIX Threading (NPTL)"
+ select UCLIBC_HAS_TLS
+ select UCLIBC_HAS_STDIO_FUTEXES
+ select UCLIBC_HAS_REALTIME
+ # i386 has no lowlevellock support (yet) as opposed to i486 onward
+ depends on !CONFIG_386 && \
+ !TARGET_alpha && \
+ !TARGET_avr32 && \
+ !TARGET_bfin && \
+ !TARGET_c6x && \
+ !TARGET_cris && \
+ !TARGET_h8300 && \
+ !TARGET_hppa && \
+ !TARGET_ia64 && \
+ !TARGET_m68k && \
+ !TARGET_microblaze && \
+ !TARGET_nios2 && \
+ !TARGET_or1k && \
+ ARCH_USE_MMU
+ help
+ If you want to compile uClibc with NPTL support, then answer Y.
+
+endchoice
+
+config UCLIBC_HAS_THREADS
+ def_bool y if !HAS_NO_THREADS
+
+config UCLIBC_HAS_TLS
+ bool "Thread-Local Storage"
+ depends on UCLIBC_HAS_THREADS_NATIVE
+ help
+ If you want to enable TLS support then answer Y.
+ This is fast an efficient way to store per-thread local data
+ which is not on stack. It needs __thread support enabled in
+ gcc.
config PTHREADS_DEBUG_SUPPORT
bool "Build pthreads debugging support"
- default n
depends on UCLIBC_HAS_THREADS
help
Say Y here if you wish to be able to debug applications that use
@@ -387,19 +582,6 @@ config PTHREADS_DEBUG_SUPPORT
If you are doing development and want to debug applications using
uClibc's pthread library, answer Y. Otherwise, answer N.
-config LINUXTHREADS_OLD
- bool "Use the older (stable) version of linuxthreads"
- default y
- depends on UCLIBC_HAS_THREADS
- help
- There are two versions of linuxthreads. The older (stable) version
- has been in uClibc for quite a long time but hasn't seen too many
- updates other than bugfixes.
-
- The new version has not been tested much, and lacks ports for arches
- which glibc does not support (like bfin/frv/etc...), but is based on
- the latest code from glibc, so it may be the only choice for the
- newer ports (like alpha/amd64/64bit arches and hppa).
config UCLIBC_HAS_SYSLOG
bool "Syslog support"
@@ -423,20 +605,34 @@ choice
prompt "Malloc Implementation"
default MALLOC if ! ARCH_USE_MMU
default MALLOC_STANDARD if ARCH_USE_MMU
+
+config MALLOC
+ bool "malloc"
help
- "malloc" use mmap for all allocations and so works very well on MMU-less
- systems that do not support the brk() system call. It is pretty smart
- about reusing already allocated memory, and minimizing memory wastage.
+ "malloc" use mmap for all allocations and so works very well on
+ MMU-less systems that do not support the brk() system call. It is
+ pretty smart about reusing already allocated memory, and minimizing
+ memory wastage.
This is the default for uClinux MMU-less systems.
- "malloc-simple" was written from scratch for uClibc, and is the
- simplest possible (and therefore smallest) malloc implementation.
- This uses only the mmap() system call to allocation memory, and does
- not use the brk() system call at all, making it a fine choice for
- MMU-less systems with very limited memory. It is rather dumb, and
- certainly isn't the fastest. But it is 100% standards compliant,
- thread safe, and very small.
+config MALLOC_SIMPLE
+ bool "malloc-simple"
+ help
+ "malloc-simple" is trivially simple and slow as molasses. It
+ was written from scratch for uClibc, and is the simplest possible
+ (and therefore smallest) malloc implementation.
+
+ This uses only the mmap() system call to allocate and free memory,
+ and does not use the brk() system call at all, making it a fine
+ choice for MMU-less systems with very limited memory. It's 100%
+ standards compliant, thread safe, very small, and releases freed
+ memory back to the OS immediately rather than keeping it in the
+ process's heap for reallocation. It is also VERY SLOW.
+config MALLOC_STANDARD
+ bool "malloc-standard"
+ depends on ARCH_USE_MMU
+ help
"malloc-standard" is derived from the public domain dlmalloc
implementation by Doug Lea. It is quite fast, and is pretty smart
about reusing already allocated memory, and minimizing memory
@@ -446,21 +642,10 @@ choice
If unsure, answer "malloc-standard".
-config MALLOC
- bool "malloc"
-
-config MALLOC_SIMPLE
- bool "malloc-simple"
-
-config MALLOC_STANDARD
- bool "malloc-standard"
- depends on ARCH_USE_MMU
-
endchoice
config MALLOC_GLIBC_COMPAT
bool "Malloc returns live pointer for malloc(0)"
- default n
help
The behavior of malloc(0) is listed as implementation-defined by
SuSv3. Glibc returns a valid pointer to something, while uClibc
@@ -476,6 +661,15 @@ config MALLOC_GLIBC_COMPAT
does not detect glibc style returning-a-valid-pointer-for-malloc(0)
behavior). Most people can safely answer N.
+config UCLIBC_HAS_OBSTACK
+ bool "Obstack Support (gnu extension)"
+ help
+ When this option is enabled, uClibc will provide support for obstacks.
+ An obstack is a structure in which memory can be dynamically allocated
+ as a 'stack of objects'. Many programs need this GNU extention and
+ you should say Y if you are using any. Otherwise, say N to save some
+ space.
+
config UCLIBC_DYNAMIC_ATEXIT
bool "Dynamic atexit() Support"
default y
@@ -493,45 +687,116 @@ config UCLIBC_DYNAMIC_ATEXIT
config COMPAT_ATEXIT
bool "Old (visible) atexit Support"
- default n
help
- Enable this option if you want to update from 0.9.28 to svn/0.9.29, else
- you will be missing atexit() until you rebuild all apps.
+ Enable this option if you want to update from 0.9.28 to git/0.9.29,
+ else you will be missing atexit() until you rebuild all apps.
+
+config UCLIBC_HAS_UTMPX
+ bool "utmpx based support for tracking login/logouts to/from the system"
+ help
+ Answer y to enable support for accessing user accounting database.
+ It can be used to track all login/logout to the system.
+
+config UCLIBC_HAS_UTMP
+ bool "utmp support (XPG2 compat, SVr4 compat)"
+ depends on UCLIBC_HAS_UTMPX
+ help
+ Answer y to enable legacy SVID support for accessing
+ user accounting database:
+ getutent(), getutid(), getutline(), pututline(),
+ setutent(), endutent(), utmpname() in utmp.h
+ It can be used to track all login/logout to the system.
+
+ If unsure, answer N and use corresponding POSIX functions
+ from utmpx.h
+
+config UCLIBC_SUSV2_LEGACY
+ bool "Enable SuSv2 LEGACY functions"
+ help
+ Enable this option if you want to have SuSv2 LEGACY functions
+ Currently applies to:
+
+ valloc
+
+ WARNING! ABI incompatibility.
config UCLIBC_SUSV3_LEGACY
bool "Enable SuSv3 LEGACY functions"
- default n
+ #vfork,
+ # h_errno
+ # gethostbyaddr
+ # gethostbyname
help
Enable this option if you want to have SuSv3 LEGACY functions
in the library, else they are replaced by SuSv3 proposed macros.
- Currently applies to bcopy/bzero/bcmp/index/rindex/ftime.
+ Currently applies to:
+
+ bcmp, bcopy, bzero, index, rindex, ftime,
+ bsd_signal, (ecvt), (fcvt), gcvt, (getcontext),
+ (getwd), (makecontext),
+ mktemp, (pthread_attr_getstackaddr), (pthread_attr_setstackaddr),
+ scalb, (setcontext), (swapcontext), ualarm, usleep,
+ wcswcs.
+
WARNING! ABI incompatibility.
+config UCLIBC_HAS_CONTEXT_FUNCS
+ bool "Use obsolescent context control functions"
+ depends on UCLIBC_SUSV3_LEGACY && ARCH_HAS_UCONTEXT
+ help
+ Add into library the SuSv3 obsolescent functions used for context
+ control. The setcontext family allows the implementation in C of
+ advanced control flow patterns such as iterators, fibers, and
+ coroutines. They may be viewed as an advanced version of
+ setjmp/longjmp; whereas the latter allows only a single non-local jump
+ up the stack, setcontext allows the creation of multiple cooperative
+ threads of control, each with its own stack.
+ These functions are: setcontext, getcontext, makecontext, swapcontext.
+
config UCLIBC_SUSV3_LEGACY_MACROS
bool "Enable SuSv3 LEGACY macros"
- default n
help
Enable this option if you want to have SuSv3 LEGACY macros.
Currently applies to bcopy/bzero/bcmp/index/rindex et al.
WARNING! ABI incompatibility.
+config UCLIBC_SUSV4_LEGACY
+ bool "Enable SuSv4 LEGACY or obsolescent functions"
+ help
+ Enable this option if you want to have SuSv4 LEGACY functions
+ and macros in the library.
+ Currently applies to:
+
+ - XSI functions:
+ _longjmp, _setjmp, _tolower, _toupper, ftw, getitimer,
+ gettimeofday, isascii, pthread_getconcurrency,
+ pthread_setconcurrency, setitimer, setpgrp, sighold,
+ sigignore, sigpause, sigrelse, sigset, siginterrupt,
+ tempnam, toascii, ulimit.
+
+ - Base functions:
+ asctime, asctime_r, ctime, ctime_r, gets, rand_r,
+ tmpnam, utime.
+
+ WARNING! ABI incompatibility.
+
+config UCLIBC_STRICT_HEADERS
+ bool "Hide structures and constants for unsupported features"
+ help
+ Hide structures and constants in headers that should not be used,
+ because the respective feature is disabled.
+
+ WARNING! enabling this option requires to patch many faulty apps,
+ since they make (wrongly) use of these structures/constants,
+ although the feature was disabled.
+
config UCLIBC_HAS_STUBS
bool "Provide stubs for unavailable functionality"
- default n
help
With this option uClibc provides non-functional stubs for
functions which are impossible to implement on the target
architecture. Otherwise, such functions are simply omitted.
- As of 2008-07, this option makes uClibc provide fork() stub
- on NOMMU targets. It always sets errno to ENOSYS and returns -1.
-
- This may be useful if you port a lot of software and cannot
- audit all of it and replace or disable fork() usage.
- With this option, a program which uses fork() will build
- successfully. Of course, it may be useless if fork()
- is essential for its operation.
-
config UCLIBC_HAS_SHADOW
bool "Shadow Password Support"
default y
@@ -541,7 +806,6 @@ config UCLIBC_HAS_SHADOW
config UCLIBC_HAS_PROGRAM_INVOCATION_NAME
bool "Support for program_invocation_name"
- default n
help
Support for the GNU-specific program_invocation_name and
program_invocation_short_name strings. Some GNU packages
@@ -556,7 +820,6 @@ config UCLIBC_HAS_PROGRAM_INVOCATION_NAME
config UCLIBC_HAS___PROGNAME
bool "Support for __progname"
default y
- depends on UCLIBC_HAS_PROGRAM_INVOCATION_NAME
help
Some packages (like openssh) like to peek into internal libc
symbols to make their output a bit more user friendly.
@@ -602,7 +865,6 @@ config UNIX98PTY_ONLY
if UNIX98PTY_ONLY
config UCLIBC_HAS_GETPT
bool "Support getpt() (glibc-compat)"
- default n
depends on UCLIBC_HAS_PTY
help
Some packages may need getpt().
@@ -619,6 +881,30 @@ config UCLIBC_HAS_GETPT
def_bool y
endif
+config UCLIBC_HAS_LIBUTIL
+ bool "Provide libutil library and functions"
+ depends on UCLIBC_HAS_PTY
+ help
+ Provide a libutil library.
+ This non-standard conforming library provides the following
+ utility functions:
+
+ forkpty(): combines openpty(), fork(2), and login_tty() to
+ create a new process operating in a pseudo-terminal.
+ login(): write utmp and wtmp entries
+ login_tty(): prepares for a login on the tty fd by creating a
+ new session, making fd the controlling terminal for
+ the calling process, setting fd to be the standard
+ input, output, and error streams of the current
+ process, and closing fd.
+ logout(): write utmp and wtmp entries
+ logwtmp(): constructs a utmp structure and calls updwtmp() to
+ append the structure to the utmp file.
+ openpty(): finds an available pseudo-terminal and returns
+ file descriptors for the master and slave
+
+ This library adds about 3k-4k to your system.
+
config UCLIBC_HAS_TM_EXTENSIONS
bool "Support 'struct tm' timezone extension fields"
default y
@@ -658,7 +944,7 @@ config UCLIBC_HAS_TZ_FILE
file consists of a single line (newline required) of text describing
the timezone in the format specified for the TZ environment variable.
- Simply doing 'echo CST6CDT > /etc/TZ' is enough to create a valid file.
+ Doing 'echo CST6CDT > /etc/TZ' is enough to create a valid file.
See
http://www.opengroup.org/onlinepubs/007904975/basedefs/xbd_chap08.html
for details on valid settings of 'TZ'.
@@ -671,10 +957,10 @@ config UCLIBC_HAS_TZ_FILE_READ_MANY
default y
help
Answer Y to enable repeated reading of the '/etc/TZ' file even after
- a valid value has been read. This incurs the overhead of an open/read/close
- for each tzset() call (explicit or implied). However, setting this
- will allows applications to update their timezone information if the contents
- of the file change.
+ a valid value has been read. This incurs the overhead of an
+ open/read/close for each tzset() call (explicit or implied). However,
+ setting this will allow applications to update their timezone
+ information if the contents of the file change.
Most people will answer Y.
@@ -687,6 +973,17 @@ config UCLIBC_TZ_FILE_PATH
Most people will use the default of '/etc/TZ'.
+config UCLIBC_FALLBACK_TO_ETC_LOCALTIME
+ bool "Use /etc/localtime as a fallback"
+ depends on UCLIBC_HAS_TZ_FILE
+ default y
+ help
+ Answer Y to try to use /etc/localtime file.
+ On glibc systems this file (if it is in TZif2 format)
+ contains timezone string at the end.
+
+ Most people will answer Y.
+
endmenu
menu "Advanced Library Settings"
@@ -713,22 +1010,41 @@ config UCLIBC_GRP_BUFFER_SIZE
comment "Support various families of functions"
-config UCLIBC_LINUX_MODULE_24
- bool "Linux kernel module functions"
+config UCLIBC_LINUX_MODULE_26
+ bool "Linux kernel module functions (2.6)"
default y
help
- init_module, create_module, query_module, delete_module
- are used in linux (allegedly prior to 2.6) for loadable
- kernel modules.
+ delete_module, init_module
+ are used in linux for loadable kernel modules.
Say N if you do not use kernel modules.
+config UCLIBC_LINUX_MODULE_24
+ bool "Linux kernel module functions (<2.6)"
+ depends on !TARGET_bfin && !TARGET_c6x
+ help
+ create_module, query_module
+ are used in linux (prior to 2.6) for loadable kernel modules.
+
+ Say N if you do not use kernel modules, or you only support
+ Linux 2.6+.
+
config UCLIBC_LINUX_SPECIFIC
bool "Linux specific functions"
default y
help
- fstatfs(), inotify_*(), ioperm(), iopl(), madvise(), modify_ldt(),
- personality(), ppoll(), setresuid()
+ accept4(), bdflush(),
+ capget(), capset(), eventfd(), fallocate(),
+ fstatfs(), getrandom(), inotify_*(), ioperm(), iopl(),
+ madvise(), modify_ldt(), pipe2(), personality(),
+ prctl()/arch_prctl(), pivot_root(), modify_ldt(),
+ ppoll(), readahead(), reboot(), remap_file_pages(),
+ sched_getaffinity(), sched_setaffinity(), sendfile(),
+ setfsgid(), setfsuid(), setresgid(), setresuid(),
+ splice(), vmsplice(), tee(), signalfd(), statfs(),
+ swapoff(), swapon(), sync_file_range(), syncfs(),
+ _sysctl(), sysinfo(), timerfd_*(), vhangup(), umount(),
+ umount2()
config UCLIBC_HAS_GNU_ERROR
bool "Support GNU extensions for error-reporting"
@@ -761,9 +1077,8 @@ config UCLIBC_HAS_BSD_ERR
config UCLIBC_HAS_OBSOLETE_BSD_SIGNAL
bool "BSD obsolete signal functions"
- default n
help
- These functions are provided as a compatibility interface for
+ These functions are provided as a compatibility interface for
programs that make use of the historical System V signal API.
This API is obsolete:
new applications should use the POSIX signal API (sigaction(2),
@@ -776,7 +1091,6 @@ config UCLIBC_HAS_OBSOLETE_BSD_SIGNAL
config UCLIBC_HAS_OBSOLETE_SYSV_SIGNAL
bool "SYSV obsolete signal functions"
- default n
help
Use of sysv_signal() should be avoided; use sigaction(2) instead.
@@ -784,7 +1098,6 @@ config UCLIBC_HAS_OBSOLETE_SYSV_SIGNAL
config UCLIBC_NTP_LEGACY
bool "ntp_*() aliases"
- default n
help
Provide legacy aliases for ntp functions:
ntp_adjtime(), ntp_gettime()
@@ -793,7 +1106,6 @@ config UCLIBC_NTP_LEGACY
config UCLIBC_SV4_DEPRECATED
bool "Enable SVr4 deprecated functions"
- default n
help
These functions are DEPRECATED in System V release 4.
Say N unless you desparately need one of the functions below:
@@ -803,8 +1115,6 @@ config UCLIBC_SV4_DEPRECATED
config UCLIBC_HAS_REALTIME
bool "Realtime-related family of SUSv functions"
default y
- # glitch in mq_{send,receive} currently forces this on
- select UCLIBC_HAS_ADVANCED_REALTIME
help
These functions are part of the Timers option and need not
be available on all implementations.
@@ -945,6 +1255,20 @@ config UCLIBC_HAS_CRYPT_IMPL
help
libcrypt contains crypt(), setkey() and encrypt()
+config UCLIBC_HAS_SHA256_CRYPT_IMPL
+ bool "libcrypt SHA256 support"
+ depends on UCLIBC_HAS_CRYPT_IMPL
+ help
+ This adds support for SHA256 password hashing via the crypt() function.
+ Say N here if you do not need SHA256 crypt support.
+
+config UCLIBC_HAS_SHA512_CRYPT_IMPL
+ bool "libcrypt SHA512 support"
+ depends on UCLIBC_HAS_CRYPT_IMPL
+ help
+ This adds support for SHA512 password hashing via the crypt() function.
+ Say N here if you do not need SHA512 crypt support.
+
config UCLIBC_HAS_CRYPT_STUB
bool "libcrypt stubs"
default y
@@ -985,7 +1309,6 @@ config UCLIBC_HAS_IPV4
config UCLIBC_HAS_IPV6
bool "IP version 6 support"
- default n
select UCLIBC_HAS_SOCKET
help
If you want to include support for the next version of the Internet
@@ -995,12 +1318,14 @@ config UCLIBC_HAS_IPV6
config UCLIBC_HAS_RPC
bool "Remote Procedure Call (RPC) support"
- default n
+ # RPC+socket-ipvX doesn't currently work.
+ depends on UCLIBC_HAS_IPV4 || UCLIBC_HAS_IPV6
help
If you want to include RPC support, enable this. RPC is rarely used
- for anything except for the NFS filesystem. Unless you plan to use NFS,
- you can probably leave this set to N and save some space. If you need
- to use NFS then you should answer Y.
+ for anything except for the NFS filesystem. Unless you plan to use
+ NFS, you can probably leave this set to N and save some space.
+
+ If you need to use NFS then you should answer Y.
config UCLIBC_HAS_FULL_RPC
bool "Full RPC support"
@@ -1023,7 +1348,6 @@ config UCLIBC_HAS_REENTRANT_RPC
config UCLIBC_USE_NETLINK
bool "Use netlink to query interfaces"
- default n
depends on UCLIBC_HAS_SOCKET
help
In newer versions of Linux (2.4.17+), support was added for querying
@@ -1038,7 +1362,6 @@ config UCLIBC_USE_NETLINK
config UCLIBC_SUPPORT_AI_ADDRCONFIG
bool "Support the AI_ADDRCONFIG flag"
depends on UCLIBC_USE_NETLINK
- default n
help
The implementation of AI_ADDRCONFIG is aligned with the glibc
implementation using netlink to query interfaces to find both
@@ -1049,13 +1372,55 @@ config UCLIBC_SUPPORT_AI_ADDRCONFIG
config UCLIBC_HAS_BSD_RES_CLOSE
bool "Support res_close() (bsd-compat)"
- default n
help
Answer Y if you desperately want to support BSD compatibility in
the network code.
Most people will say N.
+config UCLIBC_HAS_COMPAT_RES_STATE
+ bool "Use compatible but bloated _res"
+ default y
+ help
+ Answer Y if you build network utilities and they muck with resolver
+ internals a lot (_res global structure). uclibc does not use most
+ of _res.XXX fields, and with this option OFF they won't even exist.
+ Which will make e.g. dig build fail.
+ Answering N saves around 400 bytes in bss.
+
+config UCLIBC_HAS_EXTRA_COMPAT_RES_STATE
+ bool "Use extra compatible but extra bloated _res"
+ help
+ Answer Y if selecting UCLIBC_HAS_COMPAT_RES_STATE is not enough.
+ As far as I can say, this should never be needed.
+
+config UCLIBC_HAS_RESOLVER_SUPPORT
+ bool "DNS resolver functions"
+ select UCLIBC_HAS_COMPAT_RES_STATE
+ depends on UCLIBC_HAS_IPV4 || UCLIBC_HAS_IPV6
+ help
+ Provide implementations for DNS resolver functions.
+ In particular, the following functions will be added to the
+ library:
+
+ ns_skiprr, ns_initparse, ns_parserr, ns_msg_getflag,
+ res_mkquery, res_init, res_ninit, res_close, res_nclose
+ res_query, res_search, res_querydomain,
+ dn_expand, dn_comp,
+ ns_name_uncompress, ns_name_ntop, ns_name_pton, ns_name_unpack,
+ ns_name_pack, ns_name_compress, ns_name_skip, dn_skipname,
+ ns_get16, ns_get32, ns_put16, ns_put32
+
+config UCLIBC_HAS_LIBRESOLV_STUB
+ bool "Provide libresolv stub"
+ help
+ Provide a dummy resolv library.
+
+config UCLIBC_HAS_LIBNSL_STUB
+ bool "Provide libnsl stub"
+ help
+ Provide a dummy nsl library.
+
endif
@@ -1086,6 +1451,13 @@ config UCLIBC_HAS_STRING_ARCH_OPT
These are small and fast, the only reason _not_ to say Y here is
for debugging purposes.
+config UCLIBC_HAS_STDIO_FUTEXES
+ bool "Use futexes for multithreaded I/O locking"
+ depends on UCLIBC_HAS_THREADS_NATIVE
+ help
+ If you want to compile uClibc to use futexes for low-level
+ I/O locking, answer Y. Otherwise, answer N.
+
config UCLIBC_HAS_CTYPE_TABLES
bool "Use Table Versions Of 'ctype.h' Functions."
default y
@@ -1114,7 +1486,8 @@ choice
depends on UCLIBC_HAS_CTYPE_TABLES
default UCLIBC_HAS_CTYPE_UNSAFE
help
- Please select the invalid arg behavior you want for the 'ctype' functions.
+ Please select the invalid arg behavior you want for the 'ctype'
+ functions.
The 'ctype' functions are now implemented using table lookups, with
the arg being the index. This can result in incorrect memory accesses
@@ -1137,7 +1510,6 @@ endchoice
config UCLIBC_HAS_WCHAR
bool "Wide Character Support"
- default n
help
Answer Y to enable wide character support. This will make uClibc
much larger. It is also currently required for locale support.
@@ -1148,7 +1520,6 @@ config UCLIBC_HAS_LOCALE
bool "Locale Support"
select UCLIBC_HAS_WCHAR
select UCLIBC_HAS_CTYPE_TABLES
- default n
help
uClibc now has full ANSI/ISO C99 locale support (except for
wcsftime() and collating items in regex). Be aware that enabling
@@ -1165,43 +1536,49 @@ config UCLIBC_HAS_LOCALE
Answer Y to enable locale support. Most people will answer N.
-config UCLIBC_PREGENERATED_LOCALE_DATA
- bool "Use Pre-generated Locale Data"
+choice
+
+prompt "Locale data"
+ depends on UCLIBC_HAS_LOCALE
+ default UCLIBC_BUILD_ALL_LOCALE
+
+config UCLIBC_BUILD_ALL_LOCALE
+ bool "All locales"
depends on UCLIBC_HAS_LOCALE
- default n
help
- If you are selective and only want locale data for a few particular
- locales, or you enjoy pain, or you are a rabid do-it-yourself sort of
- person, you can turn this option off and manually walk through the
- mostly undocumented procedure needed to generate your own locale
- data.
+ This builds all the locales that are available on your
+ host-box.
- Mere mortals will answer Y and use the default set of pregenerated
- locale data, which supports 169 UTF-8 locales, and 144 locales for
- other codesets (for the complete list see extra/locale/LOCALES).
+config UCLIBC_BUILD_MINIMAL_LOCALE
+ bool "Only selected locales"
+ depends on UCLIBC_HAS_LOCALE
+ help
+ If you do not need all locales that are available on your
+ host-box, then set this to 'Y'.
-config UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA
- bool "Automagically Download the Pre-generated Locale Data (if necessary)"
- depends on UCLIBC_PREGENERATED_LOCALE_DATA
- default n
+endchoice
+
+config UCLIBC_BUILD_MINIMAL_LOCALES
+ string "locales to use"
+ depends on UCLIBC_BUILD_MINIMAL_LOCALE
+ default "en_US"
help
- If you would like the build process to use 'wget' to automatically
- download the pregenerated locale data, enable this option. Otherwise
- you will need to obtain the locale data yourself from:
- http://www.uclibc.org/downloads/uClibc-locale-030818.tgz
- and place the uClibc-locale-030818.tgz tarball in the extra/locale/
- directory.
+ Space separated list of locales to use.
- Go ahead and make life easy for yourself... Answer Y.
+ E.g.:
+ en_US en_GB de_AT
+ default:
+ en_US
config UCLIBC_HAS_XLOCALE
bool "Extended Locale Support (experimental/incomplete)"
depends on UCLIBC_HAS_LOCALE
- default n
help
Answer Y to enable extended locale support similar to that provided
- by glibc. This is primarily intended to support libstd++ functionality.
- However, it also allows thread-specific locale selection via uselocale().
+ by glibc. This is primarily intended to support libstd++
+ functionality.
+ However, it also allows thread-specific locale selection via
+ uselocale().
Most people will answer N.
@@ -1209,7 +1586,6 @@ config UCLIBC_HAS_HEXADECIMAL_FLOATS
bool "Support hexadecimal float notation"
depends on UCLIBC_HAS_CTYPE_TABLES
depends on UCLIBC_HAS_FLOATS
- default n
help
Answer Y to enable support for hexadecimal float notation in the
(wchar and) char string to floating point conversion functions, as
@@ -1222,11 +1598,11 @@ config UCLIBC_HAS_GLIBC_DIGIT_GROUPING
bool "Support glibc's \"'\" flag for allowing locale-specific digit grouping"
depends on UCLIBC_HAS_LOCALE
depends on UCLIBC_HAS_FLOATS
- default n
help
- Answer Y to enable support for glibc's \"'\" flag for allowing locale-specific
- digit grouping in base 10 integer conversions and appropriate floating point
- conversions in the *printf() and *scanf() functions.
+ Answer Y to enable support for glibc's \"'\" flag for allowing
+ locale-specific digit grouping in base 10 integer conversions and
+ appropriate floating point conversions in the *printf() and *scanf()
+ functions.
Most people will answer N.
@@ -1235,23 +1611,24 @@ config UCLIBC_HAS_SCANF_LENIENT_DIGIT_GROUPING
depends on UCLIBC_HAS_GLIBC_DIGIT_GROUPING
default y
help
- Answer Y to make digit grouping optional when the \"'\" flag is specified.
+ Answer Y to make digit grouping optional when the \"'\" flag is
+ specified.
This is the standard glibc behavior. If the initial string of digits
- exceeds the maximum group number, the input will be treated as a normal
- non-grouped number.
+ exceeds the maximum group number, the input will be treated as a
+ normal non-grouped number.
Most people will answer N.
config UCLIBC_HAS_GLIBC_CUSTOM_PRINTF
bool "Support glibc's register_printf_function() (glibc-compat)"
depends on !USE_OLD_VFPRINTF
- default n
help
Answer Y to support glibc's register_printf_function() to allow an
application to add its own printf conversion specifiers.
+ parse_printf_format() is also enabled.
- NOTE: This implementation limits the number or registered specifiers to 10.
- NOTE: This implementation requires new conversion specifiers to be ASCII
+ NOTE: Limits the number or registered specifiers to 10.
+ NOTE: Requires new conversion specifiers to be ASCII
characters (0-0x7f). This is to avoid problems with processing
format strings in locales with different multibyte conversions.
@@ -1260,11 +1637,11 @@ config UCLIBC_HAS_GLIBC_CUSTOM_PRINTF
config USE_OLD_VFPRINTF
bool "Use the old vfprintf implementation"
depends on !UCLIBC_HAS_WCHAR
- default n
help
- Set to true to use the old vfprintf instead of the new. This is roughly
- C89 compliant with some extensions, and is much smaller. However, it does
- not support wide chars, positional args, or glibc custom printf specifiers.
+ Set to true to use the old vfprintf instead of the new. This is
+ roughly C89 compliant with some extensions, and is much smaller.
+ However, it does not support wide chars, positional args, or glibc
+ custom printf specifiers.
Most people will answer N.
@@ -1273,28 +1650,17 @@ config UCLIBC_PRINTF_SCANF_POSITIONAL_ARGS
depends on !USE_OLD_VFPRINTF
default 9
help
- Set the maximum number of positional args supported by the printf/scanf
- functions. The Single Unix Specification Version 3 requires a minimum
- value of 9. Setting this to a value lower than 9 will disable positional
- arg support and cause the NL_ARGMAX macro in limits.h to be #undef'd.
- WARNING! The workspace to support positional args is currently allocated
- on the stack. You probably don't want to set this to too high a value.
-
- Most people will answer 9.
-
-
-config UCLIBC_HAS_SCANF_GLIBC_A_FLAG
- bool "Support glibc's 'a' flag for scanf string conversions (not implemented)"
- default n
- help
- NOTE!!! Currently Not Implemented!!! Just A Place Holder!! NOTE!!!
- NOTE!!! Conflicts with an ANSI/ISO C99 scanf flag!! NOTE!!!
+ Set the maximum number of positional args supported by the
+ printf/scanf functions. The Single Unix Specification Version 3
+ requires a minimum value of 9. Setting this to a value lower than
+ 9 will disable positional arg support and cause the NL_ARGMAX macro
+ in limits.h to be #undef'd.
- Answer Y to enable support for glibc's 'a' flag for the scanf string
- conversions '%s', '%[', '%ls', '%l[', and '%S'. This is used to
- auto-allocate sufficient memory to hold the data retrieved.
+ WARNING! The workspace to support positional args is currently
+ allocated on the stack. You probably don't want to set
+ this to too high a value.
- Most people will answer N.
+ Most people will answer 9.
choice
prompt "Stdio buffer size"
@@ -1363,11 +1729,11 @@ endchoice
config UCLIBC_HAS_STDIO_SHUTDOWN_ON_ABORT
bool "Attempt to shutdown stdio subsystem when abort() is called."
- default n
help
- ANSI/ISO C99 requires abort() to be asyn-signal-safe. So there was a behavioral
- change made in SUSv3. Previously, abort() was required to have the affect of
- fclose() on all open streams. The wording has been changed to "may" from "shall".
+ ANSI/ISO C99 requires abort() to be asyn-signal-safe. So there was
+ a behavioral change made in SUSv3. Previously, abort() was required
+ to have the affect of fclose() on all open streams. The wording has
+ been changed to "may" from "shall".
Most people will answer N.
@@ -1394,22 +1760,23 @@ config UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION
default y
help
Answer Y to enable the stdio subsystem to automaticly transition
- between reading and writing. This relaxes the ANSI/ISO C99 requirement:
-
- When a file is opened with update mode ('+' as the second or third character
- in the list of mode argument values), both input and output may be performed
- on the associated stream. However, output shall not be directly followed by
- input without an intervening call to the fflush function or to a file
- positioning function (fseek, fsetpos, or rewind), and input shall not be
- directly followed by output without an intervening call to a file positioning
- function, unless the input operation encounters end­of­file.
+ between reading and writing. This relaxes the ANSI/ISO C99
+ requirement:
+
+ When a file is opened with update mode ('+' as the second or third
+ character in the list of mode argument values), both input and output
+ may be performed on the associated stream. However, output shall not
+ be directly followed by input without an intervening call to the
+ fflush function or to a file positioning function (fseek, fsetpos,
+ or rewind), and input shall not be directly followed by output without
+ an intervening call to a file positioning function, unless the input
+ operation encounters end­of­file.
Most people will answer Y.
config UCLIBC_HAS_FOPEN_LARGEFILE_MODE
bool "Support an fopen() 'F' flag for large file mode (uClibc-specific)"
depends on UCLIBC_HAS_LFS
- default n
help
Answer Y to enable a uClibc-specific extension to allow passing an
additional 'F' flag in the mode string for fopen() to specify that
@@ -1419,7 +1786,6 @@ config UCLIBC_HAS_FOPEN_LARGEFILE_MODE
config UCLIBC_HAS_FOPEN_EXCLUSIVE_MODE
bool "Support an fopen() 'x' flag for exclusive mode (glibc-compat)"
- default n
help
Answer Y to support a glibc extension to allow passing
additional 'x' flag in the mode string for fopen() to specify that
@@ -1427,9 +1793,17 @@ config UCLIBC_HAS_FOPEN_EXCLUSIVE_MODE
Most people will answer N.
+config UCLIBC_HAS_FOPEN_CLOSEEXEC_MODE
+ bool "Support an fopen() 'e' flag for close-on-exec mode (glibc-compat)"
+ help
+ Answer Y to support a glibc extension to allow passing
+ additional 'e' flag in the mode string for fopen() to specify that
+ the file should be open()ed with the O_CLOEXEC flag set.
+
+ Most people will answer N.
+
config UCLIBC_HAS_GLIBC_CUSTOM_STREAMS
bool "Support fmemopen(), open_memstream(), and fopencookie() (glibc-compat)"
- default n
help
Answer Y to support the glibc 'custom stream' extension functions
fmemopen(), open_memstream(), and fopencookie().
@@ -1440,11 +1814,11 @@ config UCLIBC_HAS_GLIBC_CUSTOM_STREAMS
config UCLIBC_HAS_PRINTF_M_SPEC
bool "Support the '%m' specifier in printf format strings (glibc-compat)"
- default n
help
Answer Y to support a glibc extension to interpret '%m' in printf
format strings as an instruction to output the error message string
- (as generated by strerror) corresponding to the current value of 'errno'.
+ (as generated by strerror) corresponding to the current value of
+ 'errno'.
Most people will answer N.
@@ -1461,14 +1835,14 @@ config UCLIBC_HAS_ERRNO_MESSAGES
config UCLIBC_HAS_SYS_ERRLIST
bool "Support sys_errlist[] (obsolete-compat)"
depends on UCLIBC_HAS_ERRNO_MESSAGES
- default n
help
Answer Y if you want to support the obsolete sys_errlist[].
This adds about 0.5k to the library, except for the mips
arch where it adds over 4K.
WARNING! In the future, support for sys_errlist[] may be unavailable
- in at least some configurations. In fact, it may be removed altogether.
+ in at least some configurations. In fact, it may be removed
+ altogether.
Most people will answer N.
@@ -1487,19 +1861,18 @@ config UCLIBC_HAS_SIGNUM_MESSAGES
config UCLIBC_HAS_SYS_SIGLIST
bool "Support sys_siglist[] (bsd-compat)"
depends on UCLIBC_HAS_SIGNUM_MESSAGES
- default n
help
Answer Y if you want to support sys_siglist[].
WARNING! In the future, support for sys_siglist[] may be unavailable
- in at least some configurations. In fact, it may be removed altogether.
+ in at least some configurations. In fact, it may be removed
+ altogether.
Most people will answer N.
config UCLIBC_HAS_GETTEXT_AWARENESS
bool "Include gettext awareness"
depends on UCLIBC_HAS_LOCALE && UCLIBC_MJN3_ONLY
- default n
help
NOTE!!! Not yet integrated with strerror and strsignal. NOTE!!!
@@ -1517,27 +1890,44 @@ config UCLIBC_HAS_GNU_GETOPT
help
Answer Y if you want to include full gnu getopt() instead of a
(much smaller) SUSv3 compatible getopt().
+ Note that getopt_long, getopt_long_only as well as getsubopt
+ are implemented on top of this choice.
Most people will answer Y.
config UCLIBC_HAS_GETOPT_LONG
- bool "Support getopt_long/getopt_long_only"
- depends on !UCLIBC_HAS_GNU_GETOPT
+ bool "Support getopt_long/getopt_long_only (glibc-compat)"
default y
help
- Answer Y if you want to include getopt_long[_only() used by many
- apps, even busybox.
+ Answer Y if you want to include getopt_long[_only()] used by many
+ apps.
Most people will answer Y.
config UCLIBC_HAS_GNU_GETSUBOPT
- bool "Support glibc getsubopt"
+ bool "Support getsubopt"
default y
help
- Answer Y if you want to include glibc getsubopt() instead of a
- smaller SUSv3 compatible getsubopt().
+ Answer Y if you want to include getsubopt().
Most people will answer Y.
+
+config UCLIBC_HAS_ARGP
+ bool "Support argp (as standalone shared object)"
+ default n
+ help
+ Argp is an interface for parsing unix-style argument vectors. Unlike
+ the common getopt interface, it provides many advanced features in
+ addition to parsing options, such as automatic output in response to
+ `--help' and `--version' options.
+ A library can export an argp option parser, which programs can easily
+ use in conjunction with their own option parser.
+ A new shared object "libuargp" is created. The "libc.so" linker script
+ contains the AS_NEEDED entry for getting the libuargp linked automatically.
+ Argp support is needed by elfutils libdw.
+
+ Most people can safely answer N.
+
endmenu
@@ -1591,7 +1981,6 @@ config UCLIBC_HAS_FNMATCH_OLD
config UCLIBC_HAS_WORDEXP
bool "Support the wordexp() interface"
depends on UCLIBC_HAS_GLOB
- default n
help
The SuSv3 wordexp() interface performs word expansions per the Shell
and Utilities volume of IEEE Std 1003.1-2001, Section 2.6. It is
@@ -1601,15 +1990,36 @@ config UCLIBC_HAS_WORDEXP
This interface is rarely used, and very large. Unless you have a
pressing need for wordexp(), you should probably answer N.
+config UCLIBC_HAS_NFTW
+ bool "Support the nftw() interface"
+ help
+ The SuSv3 nftw() interface is used to recursively descend
+ directory paths while repeatedly calling a function.
+
+ This interface is rarely used, and adds around 4.5k. Unless you have
+ a pressing need for nftw(), you should probably answer N.
+
config UCLIBC_HAS_FTW
- bool "Support the ftw() and nftw() interfaces"
- default n
+ bool "Support the ftw() interface (SUSv4-obsolete)"
+ depends on UCLIBC_SUSV4_LEGACY
help
- The SuSv3 ftw() and nftw() interfaces are used to recursively descend
+ The SuSv3 ftw() interface is used to recursively descend
directory paths while repeatedly calling a function.
This interface is rarely used, and adds around 4.5k. Unless you have
- a pressing need for ftw() or nftw(), you should probably answer N.
+ a pressing need for ftw(), you should probably answer N.
+
+config UCLIBC_HAS_FTS
+ bool "Support the fts() interface (bsd-compat)"
+ help
+ The fts functions are provided for traversing UNIX file hierarchies.
+
+ This interface is currently used by the elfutils and adds
+ around 7.5k.
+ You should port your application to use the POSIX nftw()
+ interface.
+
+ Unless you need to build/use elfutils, you should prolly answer N.
config UCLIBC_HAS_GLOB
bool "Support the glob() interface"
@@ -1626,14 +2036,13 @@ config UCLIBC_HAS_GLOB
config UCLIBC_HAS_GNU_GLOB
bool "Support gnu glob() interface"
depends on UCLIBC_HAS_GLOB
- default n
help
- The gnu glob interface is somewhat larger (weighing in at about 4,2k) than
- it's SuSv3 counterpart (and is out of date). It is an old copy from glibc and
- does not support all the GNU specific options.
+ The gnu glob interface is somewhat larger (weighing in at about 4,2k)
+ than it's SuSv3 counterpart (and is out of date). It is an old copy
+ from glibc and does not support all the GNU specific options.
- Answer Y if you want to include full gnu glob() instead of the smaller SUSv3
- compatible glob().
+ Answer Y if you want to include full gnu glob() instead of the smaller
+ SUSv3 compatible glob().
Most people will answer N.
@@ -1644,23 +2053,6 @@ endmenu
menu "Library Installation Options"
-config SHARED_LIB_LOADER_PREFIX
- string "Shared library loader path"
- depends on HAVE_SHARED
- default "$(RUNTIME_PREFIX)lib"
- help
- When using shared libraries, this path is the location where the
- shared library will be invoked. This value will be compiled into
- every binary compiled with uClibc.
-
- For a typical target system this should be set to "/lib", such that
- 'make install' will install /lib/ld-uClibc.so.0.
-
- BIG FAT WARNING:
- If you do not have a shared library loader with the correct name
- sitting in the directory this points to, your binaries will not
- run.
-
config RUNTIME_PREFIX
string "uClibc runtime library directory"
default "/usr/$(TARGET_ARCH)-linux-uclibc/"
@@ -1695,6 +2087,39 @@ config DEVEL_PREFIX
For a typical target system this should be set to "/usr", such that
'make install' will install /usr/include/<header files>.
+config MULTILIB_DIR
+ string "library path component"
+ default "lib"
+ help
+ Path component where libraries reside.
+
+ For a typical target system this should be set to "lib", such that
+ 'make install' will install libraries to "/lib" and "/usr/lib"
+ respectively
+ DEVEL_PREFIX/MULTILIB_DIR
+ RUNTIME_PREFIX/MULTILIB_DIR
+
+ Other settings may include "lib32" or "lib64".
+
+config HARDWIRED_ABSPATH
+ bool "Hardwire absolute paths into linker scripts"
+ default y
+ help
+ This prepends absolute paths to the libraries mentioned in linker
+ scripts such as libc.so.
+
+ This is a build time optimization. It has no impact on dynamic
+ linking at runtime, which doesn't use linker scripts.
+
+ You must disable this to use uClibc with old non-sysroot toolchains,
+ such as the prebuilt binary cross compilers at:
+ http://uclibc.org/downloads/binaries
+
+ The amount of time saved by this optimization is actually too small to
+ measure. The linker just had to search the library path to find the
+ linker script, so the dentries are cache hot if it has to search the
+ same path again. But it's what glibc does, so we do it too.
+
endmenu
@@ -1705,18 +2130,20 @@ config UCLIBC_BUILD_PIE
depends on HAVE_SHARED
depends on TARGET_arm || TARGET_frv || TARGET_i386 || TARGET_mips || TARGET_powerpc
select FORCE_SHAREABLE_TEXT_SEGMENTS
- default n
help
- If you answer Y here, ldd and iconv are built as ET_DYN/PIE executables.
+ If you answer Y here, ldd and iconv are built as ET_DYN/PIE
+ executables.
+
It requires gcc-3.4 and binutils-2.15 (for arm 2.16) or later.
More about ET_DYN/PIE binaries on <http://pax.grsecurity.net/> .
- WARNING: This option also enables FORCE_SHAREABLE_TEXT_SEGMENTS, so all
- libraries have to be built with -fPIC or -fpic, and all assembler
- functions must be written as position independent code (PIC).
+
+ WARNING: This option also enables FORCE_SHAREABLE_TEXT_SEGMENTS, so
+ all libraries have to be built with -fPIC or -fpic, and all
+ assembler functions must be written as position independent
+ code (PIC).
config UCLIBC_HAS_ARC4RANDOM
bool "Include the arc4random() function"
- default n
help
Answer Y to support the OpenBSD-like arc4random() function. This
function picks a random number between 0 and N, and will always return
@@ -1727,14 +2154,22 @@ config UCLIBC_HAS_ARC4RANDOM
Most people will answer N.
+config ARC4RANDOM_USES_NODEV
+ bool "Do not use /dev/urandom with arc4random()"
+ depends on UCLIBC_HAS_ARC4RANDOM
+ help
+ Answer Y to use gettimeofday(2) and getpid(2) exclusively for
+ arc4random(). This is not a bad idea for a diskless system, but
+ it uses a lot of syscalls to stir each array element.
+
+ Most people will answer N.
+
config HAVE_NO_SSP
bool
- default n
config UCLIBC_HAS_SSP
bool "Support for GCC stack smashing protector"
depends on !HAVE_NO_SSP
- default n
help
Add code to support GCC's -fstack-protector[-all] option to uClibc.
This requires GCC 4.1 or newer. GCC does not have to provide libssp,
@@ -1755,7 +2190,6 @@ config UCLIBC_HAS_SSP
config UCLIBC_HAS_SSP_COMPAT
bool "Support for gcc-3.x propolice smashing stack protector"
depends on UCLIBC_HAS_SSP
- default n
help
Add gcc-3.x propolice smashing stack protector to the library.
@@ -1772,7 +2206,6 @@ config UCLIBC_HAS_SSP_COMPAT
config SSP_QUICK_CANARY
bool "Use simple guard values without accessing /dev/urandom"
depends on UCLIBC_HAS_SSP
- default n
help
Use gettimeofday(2) to define the __guard without accessing
/dev/urandom.
@@ -1783,8 +2216,8 @@ config SSP_QUICK_CANARY
choice
prompt "Propolice protection blocking signal"
depends on UCLIBC_HAS_SSP
- default PROPOLICE_BLOCK_ABRT if ! DODEBUG
- default PROPOLICE_BLOCK_SEGV if DODEBUG
+ depends on DODEBUG
+ default PROPOLICE_BLOCK_SEGV
help
"abort" use SIGABRT to block offending programs.
This is the default implementation.
@@ -1805,7 +2238,6 @@ endchoice
config UCLIBC_BUILD_SSP
bool "Build uClibc with -fstack-protector"
depends on UCLIBC_HAS_SSP
- default n
help
Build all uClibc libraries and executables with -fstack-protector,
adding extra stack overflow checking to most uClibc functions.
@@ -1835,7 +2267,6 @@ config UCLIBC_BUILD_RELRO
config UCLIBC_BUILD_NOW
bool "Build uClibc with linker option -z NOW"
depends on HAVE_SHARED
- default n
help
Build all libraries and executables with "ld -z now".
@@ -1874,7 +2305,7 @@ config UCLIBC_BUILD_NOEXECSTACK
endmenu
-menu "uClibc development/debugging options"
+menu "Development/debugging options"
config CROSS_COMPILER_PREFIX
string "Cross-compiling toolchain prefix"
@@ -1885,14 +2316,13 @@ config CROSS_COMPILER_PREFIX
then enter 'arm-linux-uclibc-' here.
config UCLIBC_EXTRA_CFLAGS
- string "Enter any extra CFLAGS to use to build uClibc"
+ string "Extra CFLAGS"
default ""
help
Add any additional CFLAGS to be used to build uClibc.
config DODEBUG
- bool "Build uClibc with debugging symbols"
- default n
+ bool "Enable debugging symbols"
select EXTRA_WARNINGS
help
Say Y here if you wish to compile uClibc with debugging symbols.
@@ -1906,7 +2336,6 @@ config DODEBUG
config DODEBUG_PT
bool "Build pthread with debugging output"
depends on UCLIBC_HAS_THREADS && LINUXTHREADS_OLD
- default n
help
Enable debug output in libpthread. This is only useful when doing
development in libpthread itself.
@@ -1924,8 +2353,7 @@ config DOSTRIP
Most people will answer Y.
config DOASSERTS
- bool "Build uClibc with run-time assertion testing"
- default n
+ bool "Build with run-time assertion testing"
help
Say Y here to include runtime assertion tests.
This enables runtime assertion testing in some code, which can
@@ -1935,7 +2363,6 @@ config DOASSERTS
config SUPPORT_LD_DEBUG
bool "Build the shared library loader with debugging support"
depends on HAVE_SHARED
- default n
help
Answer Y here to enable all the extra code needed to debug the uClibc
native shared library loader. The level of debugging noise that is
@@ -1948,9 +2375,11 @@ config SUPPORT_LD_DEBUG
detail provide more information for some options
move display copy processing
symbols display symbol table processing
- reloc display relocation processing; detail shows the relocation patch
+ reloc display relocation processing; detail shows the
+ relocation patch
nofixups never fixes up jump relocations
- bindings displays the resolve processing (function calls); detail shows the relocation patch
+ bindings displays the resolve processing (function calls);
+ detail shows the relocation patch
all Enable everything!
The additional environment variable:
@@ -1969,7 +2398,6 @@ config SUPPORT_LD_DEBUG
config SUPPORT_LD_DEBUG_EARLY
bool "Build the shared library loader with early debugging support"
depends on HAVE_SHARED
- default n
help
Answer Y here to if you find the uClibc shared library loader is
crashing or otherwise not working very early on. This is typical
@@ -1983,37 +2411,55 @@ config SUPPORT_LD_DEBUG_EARLY
config UCLIBC_MALLOC_DEBUGGING
bool "Build malloc with debugging support"
depends on MALLOC || MALLOC_STANDARD
- default n
+ select DOASSERTS
help
Answer Y here to compile extra debugging support code into malloc.
Malloc debugging output may then be enabled at runtime using the
MALLOC_DEBUG environment variable.
- The value of MALLOC_DEBUG should be an integer, which is interpreted as
- a bitmask with the following bits:
+ The value of MALLOC_DEBUG should be an integer, which is interpreted
+ as a bitmask with the following bits:
1 - do extra consistency checking
- 2 - output messages for malloc/free calls and OS allocation calls
+ 2 - output messages for malloc/free calls and OS
+ allocation calls
4 - output messages for the `MMB' layer
- 8 - output messages for internal malloc heap manipulation calls
+ 8 - output messages for internal malloc heap manipulation
+ calls
Because this increases the size of malloc appreciably (due to strings
etc), you should say N unless you need to debug a malloc problem.
+config UCLIBC_HAS_BACKTRACE
+ bool "Add support for application self-debugging"
+ depends on HAVE_SHARED
+ help
+ Answer Y here to compile support for application self-debugging, by adding
+ a new shared object "libubacktrace.so" that provides the following new
+ functions:
+ backtrace, backtrace_symbols, backtrace_symbols_fd
+
+ The backtrace functionality is currently supported on SH platform, and it
+ based on dwarf2 informations to properly work, so any application that
+ want to use backtrace needs to be built with -fexceptions flag.
+
+ The symbol names may be unavailable without the use of special linker
+ options. For systems using the GNU linker, it is necessary to use the
+ -rdynamic linker option too. Note that names of "static" functions are not
+ exposed, and won't be available in the backtrace.
+
config WARNINGS
string "Compiler Warnings"
default "-Wall"
help
- Set this to the set of gcc warnings you wish to see while compiling.
+ Set this to the set of compiler warnings you wish to see while compiling.
config EXTRA_WARNINGS
bool "Enable extra annoying warnings"
- default n
help
If you wish to build with extra warnings enabled, say Y here.
config DOMULTI
bool "Compile all sources at once into an object"
- default n
help
Set this to compile all sources at once into an object (IMA).
This mode of compilation uses alot of memory but may produce
@@ -2024,12 +2470,4 @@ config DOMULTI
If unsure, keep the default of N.
-config UCLIBC_MJN3_ONLY
- bool "Manuel's hidden warnings"
- default n
- help
- Answer Y here to see all Manuel's personal notes, warnings, and todos.
-
- Most people will answer N.
-
endmenu
diff --git a/extra/Configs/Config.in.arch b/extra/Configs/Config.in.arch
index 2a912a109..92f45d969 100644
--- a/extra/Configs/Config.in.arch
+++ b/extra/Configs/Config.in.arch
@@ -10,23 +10,25 @@
if !ARCH_USE_MMU
choice
prompt "Target File Format"
-config UCLIBC_FORMAT_ELF
- bool "ELF"
- depends on ARCH_USE_MMU
config UCLIBC_FORMAT_FDPIC_ELF
bool "FDPIC ELF"
- depends on !ARCH_USE_MMU
+ depends on !ARCH_USE_MMU && (TARGET_bfin || TARGET_frv)
+ select DOPIC
+config UCLIBC_FORMAT_DSBT_ELF
+ bool "DBST ELF"
+ depends on !ARCH_USE_MMU && TARGET_c6x
+ select DOPIC
config UCLIBC_FORMAT_FLAT
bool "STATIC FLAT"
- depends on !ARCH_USE_MMU
+ depends on !ARCH_USE_MMU && !TARGET_frv
select ARCH_HAS_NO_LDSO
config UCLIBC_FORMAT_FLAT_SEP_DATA
bool "STATIC FLAT (sep-data)"
- depends on !ARCH_USE_MMU
+ depends on !ARCH_USE_MMU && !TARGET_frv
select ARCH_HAS_NO_LDSO
config UCLIBC_FORMAT_SHARED_FLAT
bool "SHARED FLAT"
- depends on !ARCH_USE_MMU
+ depends on !ARCH_USE_MMU && !TARGET_frv
select ARCH_HAS_NO_LDSO
help
Pick this one if you are using uClinux and wish to build
@@ -37,6 +39,14 @@ if ARCH_USE_MMU
comment "Using ELF file format"
endif
+config ARCH_HAS_DEPRECATED_SYSCALLS
+ bool
+ help
+ New architectures do not support deprecated system calls. However,
+ these system calls are needed to build linuxthreads (old and new) so
+ this symbol controls whether there is support for these threading libraries
+ or not.
+
config UCLIBC_SHARED_FLAT_ID
int "Shared library ID"
default 1
@@ -128,7 +138,6 @@ config UCLIBC_HAS_FLOATS
config UCLIBC_HAS_FPU
bool "Target CPU has a floating point unit (FPU)"
- depends on UCLIBC_HAS_FLOATS
default y
help
If your target CPU does not have a Floating Point Unit (FPU) or a
@@ -148,7 +157,6 @@ config UCLIBC_HAS_SOFT_FLOAT
config DO_C99_MATH
bool "Enable full C99 math library support"
depends on UCLIBC_HAS_FLOATS
- default n
help
If you want the uClibc math library to contain the full set C99
math library features, then answer Y. If you leave this set to
@@ -159,18 +167,40 @@ config DO_C99_MATH
If your applications require the newer C99 math library functions,
then answer Y.
+config DO_XSI_MATH
+ bool "Enable XSI math extensions to the ISO C standard (bessel)"
+ depends on UCLIBC_HAS_FLOATS
+ help
+ X/Open System Interfaces extensions to ISO C math functions
+ (differential equation functions):
+
+ j0, j1, jn - Bessel functions of the first kind
+ y0, y1, yn - Bessel functions of the second kind
+
config UCLIBC_HAS_FENV
bool "Enable C99 Floating-point environment"
depends on UCLIBC_HAS_FLOATS
- default n
help
If you want the uClibc math library to contain the C99 floating
point environment, rounding and exception handling functions then
say Y here.
+ NOTE: Supported architectures currently include:
+ i386
+
+config UCLIBC_HAS_LONG_DOUBLE_MATH
+ bool "Enable long double support"
+ depends on DO_C99_MATH
+ depends on TARGET_aarch64 || TARGET_alpha || TARGET_i386 || TARGET_ia64 || TARGET_m68k || TARGET_powerpc || TARGET_s390 || TARGET_sparc || TARGET_tile || TARGET_x86_64
+ default y
+ help
+ If you want the uClibc math library to contain the full set of C99
+ long double math library features, then answer Y. Don't enable it
+ for sparc w/ 32bit ABI.
+
config KERNEL_HEADERS
string "Linux kernel header location"
- default "/usr/include"
+ default ""
help
The kernel source you use to compile with should be the same
as the Linux kernel you run your apps on. uClibc doesn't even
@@ -181,12 +211,9 @@ config KERNEL_HEADERS
but then run on Linux 2.0.x, lchown will be compiled into uClibc,
but won't work at all. You have been warned.
-config UCLIBC_UCLINUX_BROKEN_MUNMAP
- bool
- depends on !ARCH_USE_MMU
- default y
+ If you don't set this, we'll assume the toolchain can find them.
-config EXCLUDE_BRK
+config UCLIBC_UCLINUX_BROKEN_MUNMAP
bool
depends on !ARCH_USE_MMU
default y
diff --git a/extra/Configs/Config.v850 b/extra/Configs/Config.lm32
index a668bba7c..807726702 100644
--- a/extra/Configs/Config.v850
+++ b/extra/Configs/Config.lm32
@@ -5,18 +5,13 @@
config TARGET_ARCH
string
- default "v850"
+ default "lm32"
config FORCE_OPTIONS_FOR_ARCH
bool
default y
- select ARCH_LITTLE_ENDIAN
+ select ARCH_BIG_ENDIAN
select ARCH_HAS_NO_MMU
+ select ARCH_HAS_NO_LDSO
select HAVE_NO_PIC
-
-config ARCH_CFLAGS
- string
-
-config CROSS
- string
- default "v850e-elf-"
+ select ARCH_HAS_DEPRECATED_SYSCALLS
diff --git a/extra/Configs/Config.m68k b/extra/Configs/Config.m68k
index f86ca35b4..5888067bc 100644
--- a/extra/Configs/Config.m68k
+++ b/extra/Configs/Config.m68k
@@ -11,7 +11,4 @@ config FORCE_OPTIONS_FOR_ARCH
bool
default y
select ARCH_BIG_ENDIAN
-
-config ARCH_CFLAGS
- string
- default "-Wa,--bitwise-or"
+ select ARCH_HAS_DEPRECATED_SYSCALLS
diff --git a/extra/Configs/Config.metag b/extra/Configs/Config.metag
new file mode 100644
index 000000000..e55822281
--- /dev/null
+++ b/extra/Configs/Config.metag
@@ -0,0 +1,32 @@
+#
+# For a description of the syntax of this configuration file,
+# see extra/config/Kconfig-language.txt
+#
+# Copyright (C) 2013, Imagination Technologies Ltd.
+#
+# Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+#
+
+config TARGET_ARCH
+ default "metag"
+
+config FORCE_OPTIONS_FOR_ARCH
+ bool
+ default y
+ select ARCH_LITTLE_ENDIAN
+ select ARCH_HAS_MMU
+
+choice
+ prompt "Target Processor Type"
+ default CONFIG_META_2_1
+ help
+ This is the processor type of your CPU. This information is used for
+ optimizing purposes.
+
+config CONFIG_META_1_2
+ bool "Meta 1.2"
+
+config CONFIG_META_2_1
+ bool "Meta 2.1"
+
+endchoice
diff --git a/extra/Configs/Config.microblaze b/extra/Configs/Config.microblaze
index a89914ef1..60d10d6ef 100644
--- a/extra/Configs/Config.microblaze
+++ b/extra/Configs/Config.microblaze
@@ -10,12 +10,5 @@ config TARGET_ARCH
config FORCE_OPTIONS_FOR_ARCH
bool
default y
- select ARCH_BIG_ENDIAN
- select ARCH_HAS_NO_MMU
-
-config ARCH_CFLAGS
- string
-
-config CROSS
- string
- default "mb-"
+ select ARCH_ANY_ENDIAN
+ select ARCH_HAS_DEPRECATED_SYSCALLS
diff --git a/extra/Configs/Config.mips b/extra/Configs/Config.mips
index 442209884..e0b62dd67 100644
--- a/extra/Configs/Config.mips
+++ b/extra/Configs/Config.mips
@@ -11,10 +11,8 @@ config FORCE_OPTIONS_FOR_ARCH
bool
default y
select ARCH_ANY_ENDIAN
-
-config ARCH_CFLAGS
- string
- default "-mno-split-addresses"
+ select ARCH_HAS_UCONTEXT
+ select ARCH_HAS_DEPRECATED_SYSCALLS
choice
prompt "Target ABI"
@@ -33,42 +31,3 @@ config CONFIG_MIPS_N64_ABI
bool "N64 ABI"
endchoice
-
-choice
- prompt "Target Processor Architecture"
- default CONFIG_MIPS_ISA_1 if CONFIG_MIPS_O32_ABI
- default CONFIG_MIPS_ISA_3 if CONFIG_MIPS_N32_ABI
- default CONFIG_MIPS_ISA_3 if CONFIG_MIPS_N64_ABI
- help
- This selects the instruction set architecture of your MIPS CPU. This
- information is used for optimizing purposes. To build a library that
- will run on any MIPS CPU, you can specify "Generic (MIPS I)" here.
- If you pick anything other than "Generic (MIPS I)," there is no
- guarantee that uClibc will even run on anything other than the
- selected processor type.
-
- You should probably select the MIPS ISA that best matches the
- CPU you will be using on your device. uClibc will be tuned
- for that architecture.
-
- If you don't know what to do, choose "Generic (MIPS I)"
-
-config CONFIG_MIPS_ISA_1
- bool "Generic (MIPS I)"
-
-config CONFIG_MIPS_ISA_2
- bool "MIPS II"
-
-config CONFIG_MIPS_ISA_3
- bool "MIPS III"
-
-config CONFIG_MIPS_ISA_4
- bool "MIPS IV"
-
-config CONFIG_MIPS_ISA_MIPS32
- bool "MIPS32"
-
-config CONFIG_MIPS_ISA_MIPS64
- bool "MIPS64"
-
-endchoice
diff --git a/extra/Configs/Config.nios b/extra/Configs/Config.nios
deleted file mode 100644
index f1dbd6c42..000000000
--- a/extra/Configs/Config.nios
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# For a description of the syntax of this configuration file,
-# see extra/config/Kconfig-language.txt
-#
-
-config TARGET_ARCH
- string
- default "nios"
-
-config FORCE_OPTIONS_FOR_ARCH
- bool
- default y
- select ARCH_LITTLE_ENDIAN
- select ARCH_HAS_NO_MMU
- select ARCH_HAS_NO_LDSO
- select HAVE_NO_PIC
-
-config ARCH_CFLAGS
- string
- default "-funaligned-struct-hack"
-
-config CROSS
- string
diff --git a/extra/Configs/Config.nios2 b/extra/Configs/Config.nios2
index 1f945556b..2310a46c0 100644
--- a/extra/Configs/Config.nios2
+++ b/extra/Configs/Config.nios2
@@ -14,9 +14,3 @@ config FORCE_OPTIONS_FOR_ARCH
select ARCH_HAS_NO_MMU
select ARCH_HAS_NO_LDSO
select HAVE_NO_PIC
-
-config ARCH_CFLAGS
- string
-
-config CROSS
- string
diff --git a/extra/Configs/Config.or1k b/extra/Configs/Config.or1k
new file mode 100644
index 000000000..45e6f0a57
--- /dev/null
+++ b/extra/Configs/Config.or1k
@@ -0,0 +1,35 @@
+#
+# For a description of the syntax of this configuration file,
+# see extra/config/Kconfig-language.txt
+#
+
+config TARGET_ARCH
+ default "or1k"
+
+config ARCH_CFLAGS
+ string
+
+config ARCH_LDFLAGS
+ string
+
+config LIBGCC_CFLAGS
+ string
+
+choice
+ prompt "Target Architecture Type"
+ default CONFIG_OR1K
+ help
+ This is the architecture type of your CPU. This information is used for
+ optimizing purposes.
+
+ These are the possible settings:
+ - or1k Generic support for OpenCores OpenRISC/or1k architecture.
+
+config CONFIG_OR1K
+ select ARCH_HAS_MMU
+ select UCLIBC_HAS_FPU
+ select ARCH_BIG_ENDIAN
+ select HAS_NO_THREADS
+ bool "or1k"
+
+endchoice
diff --git a/extra/Configs/Config.powerpc b/extra/Configs/Config.powerpc
index 8ba267cf1..7698022ae 100644
--- a/extra/Configs/Config.powerpc
+++ b/extra/Configs/Config.powerpc
@@ -12,9 +12,7 @@ config FORCE_OPTIONS_FOR_ARCH
default y
select ARCH_BIG_ENDIAN
select ARCH_HAS_MMU
-
-config ARCH_CFLAGS
- string
+ select ARCH_HAS_DEPRECATED_SYSCALLS
choice
prompt "Target Processor Type"
diff --git a/extra/Configs/Config.sh b/extra/Configs/Config.sh
index 8538bcc65..1367b1c4f 100644
--- a/extra/Configs/Config.sh
+++ b/extra/Configs/Config.sh
@@ -11,9 +11,7 @@ config FORCE_OPTIONS_FOR_ARCH
bool
default y
select ARCH_ANY_ENDIAN
-
-config ARCH_CFLAGS
- string
+ select ARCH_HAS_DEPRECATED_SYSCALLS
choice
prompt "Target Processor Type"
@@ -29,6 +27,7 @@ choice
- "SH2" SuperH SH-2
- "SH3" SuperH SH-3
- "SH4" SuperH SH-4
+ - "SH4A" SuperH SH-4a
config CONFIG_SH2A
select ARCH_HAS_NO_MMU
@@ -44,9 +43,11 @@ config CONFIG_SH3
bool "SH3"
config CONFIG_SH4
- select FORCE_SHAREABLE_TEXT_SEGMENTS
bool "SH4"
+config CONFIG_SH4A
+ bool "SH4A"
+
endchoice
config ARCH_HAS_BWD_MEMCPY
diff --git a/extra/Configs/Config.sh64 b/extra/Configs/Config.sh64
deleted file mode 100644
index 54d738e36..000000000
--- a/extra/Configs/Config.sh64
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# For a description of the syntax of this configuration file,
-# see extra/config/Kconfig-language.txt
-#
-
-config TARGET_ARCH
- string
- default "sh64"
-
-config FORCE_OPTIONS_FOR_ARCH
- bool
- default y
- select ARCH_ANY_ENDIAN
-
-config ARCH_CFLAGS
- string
-
-choice
- prompt "Target Processor Type"
- default CONFIG_SH5
- help
- This is the processor type of your CPU. This information is used for
- optimizing purposes, as well as to determine if your CPU has an MMU,
- an FPU, etc. If you pick the wrong CPU type, there is no guarantee
- that uClibc will work at all....
-
- Here are the available choices:
- - "SH5" SuperH SH-5 101, 103
-
-config CONFIG_SH5
- select ARCH_HAS_MMU
- select UCLIBC_HAS_LFS
- bool "SH5"
-
-endchoice
diff --git a/extra/Configs/Config.sparc b/extra/Configs/Config.sparc
index 3b19f9d14..47c8ac289 100644
--- a/extra/Configs/Config.sparc
+++ b/extra/Configs/Config.sparc
@@ -11,9 +11,7 @@ config FORCE_OPTIONS_FOR_ARCH
bool
default y
select ARCH_BIG_ENDIAN
-
-config ARCH_CFLAGS
- string
+ select ARCH_HAS_DEPRECATED_SYSCALLS
choice
prompt "Target Processor Type"
@@ -22,20 +20,10 @@ choice
This is the processor type of your CPU. This information is used for
optimizing purposes. Building for a v8 SPARC is pretty safe nowadays.
- Warning: shared library support requires v8 or better, so building for
- SPARC v7 will give you only static support.
-
config CONFIG_SPARC_V7
- select ARCH_HAS_NO_SHARED
bool "SPARC v7"
config CONFIG_SPARC_V8
bool "SPARC v8"
-config CONFIG_SPARC_V9
- bool "SPARC v9"
-
-config CONFIG_SPARC_V9B
- bool "SPARC v9b"
-
endchoice
diff --git a/extra/Configs/Config.vax b/extra/Configs/Config.vax
deleted file mode 100644
index 4192e28c2..000000000
--- a/extra/Configs/Config.vax
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# For a description of the syntax of this configuration file,
-# see extra/config/Kconfig-language.txt
-#
-
-config TARGET_ARCH
- string
- default "vax"
-
-config FORCE_OPTIONS_FOR_ARCH
- bool
- default y
- select ARCH_LITTLE_ENDIAN
- select ARCH_HAS_NO_LDSO
-
-config ARCH_CFLAGS
- string
-
-config ARCH_LDFLAGS
- string
-
-config CROSS
- string
- default "vax-linux-uclibc-"
diff --git a/extra/Configs/Config.x86_64 b/extra/Configs/Config.x86_64
index 7ae357f61..317a5007f 100644
--- a/extra/Configs/Config.x86_64
+++ b/extra/Configs/Config.x86_64
@@ -12,6 +12,5 @@ config FORCE_OPTIONS_FOR_ARCH
default y
select ARCH_LITTLE_ENDIAN
select ARCH_HAS_MMU
-
-config ARCH_CFLAGS
- string
+ select ARCH_HAS_UCONTEXT
+ select ARCH_HAS_DEPRECATED_SYSCALLS
diff --git a/extra/Configs/Config.xtensa b/extra/Configs/Config.xtensa
index 75132471a..3ee8817ba 100644
--- a/extra/Configs/Config.xtensa
+++ b/extra/Configs/Config.xtensa
@@ -7,6 +7,8 @@ config TARGET_ARCH
string
default "xtensa"
-config ARCH_CFLAGS
- string
-
+config FORCE_OPTIONS_FOR_ARCH
+ bool
+ default y
+ select ARCH_HAS_DEPRECATED_SYSCALLS
+ select ARCH_ANY_ENDIAN
diff --git a/extra/Configs/defconfigs/alpha b/extra/Configs/defconfigs/alpha/defconfig
index 05243d7bb..05243d7bb 100644
--- a/extra/Configs/defconfigs/alpha
+++ b/extra/Configs/defconfigs/alpha/defconfig
diff --git a/extra/Configs/defconfigs/arc/arcv2_defconfig b/extra/Configs/defconfigs/arc/arcv2_defconfig
new file mode 100644
index 000000000..2d1235817
--- /dev/null
+++ b/extra/Configs/defconfigs/arc/arcv2_defconfig
@@ -0,0 +1,39 @@
+CONFIG_ARC_CPU_HS=y
+ARCH_WANTS_LITTLE_ENDIAN=y
+# UCLIBC_HAS_FPU is not set
+DO_C99_MATH=y
+KERNEL_HEADERS="%KERNEL_HEADERS%"
+# DOPIC is not set
+# LDSO_CACHE_SUPPORT is not set
+LDSO_RUNPATH=y
+# LDSO_SAFE_RUNPATH is not set
+UCLIBC_HAS_THREADS_NATIVE=y
+PTHREADS_DEBUG_SUPPORT=y
+UCLIBC_HAS_UTMPX=y
+UCLIBC_HAS_UTMP=y
+UCLIBC_SUSV2_LEGACY=y
+UCLIBC_SUSV3_LEGACY=y
+UCLIBC_SUSV4_LEGACY=y
+UCLIBC_HAS_PROGRAM_INVOCATION_NAME=y
+UCLIBC_HAS_LIBUTIL=y
+UCLIBC_HAS_OBSOLETE_BSD_SIGNAL=y
+UCLIBC_SV4_DEPRECATED=y
+UCLIBC_HAS_IPV6=y
+UCLIBC_HAS_RPC=y
+UCLIBC_HAS_FULL_RPC=y
+UCLIBC_USE_NETLINK=y
+UCLIBC_SUPPORT_AI_ADDRCONFIG=y
+UCLIBC_HAS_RESOLVER_SUPPORT=y
+UCLIBC_HAS_LIBRESOLV_STUB=y
+UCLIBC_HAS_LIBNSL_STUB=y
+UCLIBC_HAS_LOCALE=y
+UCLIBC_HAS_GLIBC_CUSTOM_STREAMS=y
+UCLIBC_HAS_NFTW=y
+UCLIBC_HAS_FTW=y
+UCLIBC_HAS_GNU_GLOB=y
+RUNTIME_PREFIX="%RUNTIME_PREFIX%"
+DEVEL_PREFIX="%DEVEL_PREFIX%"
+CROSS_COMPILER_PREFIX="arc-linux-uclibc-"
+# DOSTRIP is not set
+SUPPORT_LD_DEBUG=y
+UCLIBC_HAS_BACKTRACE=y
diff --git a/extra/Configs/defconfigs/arc/defconfig b/extra/Configs/defconfigs/arc/defconfig
new file mode 100644
index 000000000..f582eb5a9
--- /dev/null
+++ b/extra/Configs/defconfigs/arc/defconfig
@@ -0,0 +1,38 @@
+ARCH_WANTS_LITTLE_ENDIAN=y
+# UCLIBC_HAS_FPU is not set
+DO_C99_MATH=y
+KERNEL_HEADERS="%KERNEL_HEADERS%"
+# DOPIC is not set
+# LDSO_CACHE_SUPPORT is not set
+LDSO_RUNPATH=y
+# LDSO_SAFE_RUNPATH is not set
+UCLIBC_HAS_THREADS_NATIVE=y
+PTHREADS_DEBUG_SUPPORT=y
+UCLIBC_HAS_UTMPX=y
+UCLIBC_HAS_UTMP=y
+UCLIBC_SUSV2_LEGACY=y
+UCLIBC_SUSV3_LEGACY=y
+UCLIBC_SUSV4_LEGACY=y
+UCLIBC_HAS_PROGRAM_INVOCATION_NAME=y
+UCLIBC_HAS_LIBUTIL=y
+UCLIBC_HAS_OBSOLETE_BSD_SIGNAL=y
+UCLIBC_SV4_DEPRECATED=y
+UCLIBC_HAS_IPV6=y
+UCLIBC_HAS_RPC=y
+UCLIBC_HAS_FULL_RPC=y
+UCLIBC_USE_NETLINK=y
+UCLIBC_SUPPORT_AI_ADDRCONFIG=y
+UCLIBC_HAS_RESOLVER_SUPPORT=y
+UCLIBC_HAS_LIBRESOLV_STUB=y
+UCLIBC_HAS_LIBNSL_STUB=y
+UCLIBC_HAS_LOCALE=y
+UCLIBC_HAS_GLIBC_CUSTOM_STREAMS=y
+UCLIBC_HAS_NFTW=y
+UCLIBC_HAS_FTW=y
+UCLIBC_HAS_GNU_GLOB=y
+RUNTIME_PREFIX="%RUNTIME_PREFIX%"
+DEVEL_PREFIX="%DEVEL_PREFIX%"
+CROSS_COMPILER_PREFIX="arc-linux-uclibc-"
+# DOSTRIP is not set
+SUPPORT_LD_DEBUG=y
+UCLIBC_HAS_BACKTRACE=y
diff --git a/extra/Configs/defconfigs/arc/tb10x_defconfig b/extra/Configs/defconfigs/arc/tb10x_defconfig
new file mode 100644
index 000000000..405a4eac7
--- /dev/null
+++ b/extra/Configs/defconfigs/arc/tb10x_defconfig
@@ -0,0 +1,38 @@
+ARCH_WANTS_LITTLE_ENDIAN=y
+# UCLIBC_HAS_FPU is not set
+DO_C99_MATH=y
+KERNEL_HEADERS="%KERNEL_HEADERS%"
+# DOPIC is not set
+# LDSO_CACHE_SUPPORT is not set
+LDSO_RUNPATH=y
+# LDSO_SAFE_RUNPATH is not set
+LINUXTHREADS_OLD=y
+PTHREADS_DEBUG_SUPPORT=y
+MALLOC_GLIBC_COMPAT=y
+UCLIBC_SUSV3_LEGACY=y
+UCLIBC_SUSV4_LEGACY=y
+UCLIBC_HAS_GETPT=y
+UCLIBC_HAS_LIBUTIL=y
+UCLIBC_HAS_OBSOLETE_BSD_SIGNAL=y
+UCLIBC_SV4_DEPRECATED=y
+UCLIBC_HAS_IPV6=y
+UCLIBC_HAS_RPC=y
+UCLIBC_HAS_FULL_RPC=y
+UCLIBC_HAS_REENTRANT_RPC=y
+UCLIBC_HAS_RESOLVER_SUPPORT=y
+UCLIBC_HAS_LIBRESOLV_STUB=y
+UCLIBC_HAS_LIBNSL_STUB=y
+UCLIBC_HAS_CTYPE_CHECKED=y
+UCLIBC_HAS_LOCALE=y
+UCLIBC_HAS_FOPEN_EXCLUSIVE_MODE=y
+UCLIBC_HAS_FOPEN_CLOSEEXEC_MODE=y
+UCLIBC_HAS_GLIBC_CUSTOM_STREAMS=y
+UCLIBC_HAS_PRINTF_M_SPEC=y
+UCLIBC_HAS_NFTW=y
+UCLIBC_HAS_FTW=y
+UCLIBC_HAS_GNU_GLOB=y
+RUNTIME_PREFIX="%RUNTIME_PREFIX%"
+DEVEL_PREFIX="%DEVEL_PREFIX%"
+CROSS_COMPILER_PREFIX="arc-linux-uclibc-"
+# DOSTRIP is not set
+SUPPORT_LD_DEBUG=y
diff --git a/extra/Configs/defconfigs/arm b/extra/Configs/defconfigs/arm/defconfig
index aa6789032..aa6789032 100644
--- a/extra/Configs/defconfigs/arm
+++ b/extra/Configs/defconfigs/arm/defconfig
diff --git a/extra/Configs/defconfigs/avr32 b/extra/Configs/defconfigs/avr32/defconfig
index 0b890a291..0b890a291 100644
--- a/extra/Configs/defconfigs/avr32
+++ b/extra/Configs/defconfigs/avr32/defconfig
diff --git a/extra/Configs/defconfigs/bfin b/extra/Configs/defconfigs/bfin/defconfig
index fb5c5ebe0..fb5c5ebe0 100644
--- a/extra/Configs/defconfigs/bfin
+++ b/extra/Configs/defconfigs/bfin/defconfig
diff --git a/extra/Configs/defconfigs/cris b/extra/Configs/defconfigs/cris/defconfig
index 4e9818083..4e9818083 100644
--- a/extra/Configs/defconfigs/cris
+++ b/extra/Configs/defconfigs/cris/defconfig
diff --git a/extra/Configs/defconfigs/e1 b/extra/Configs/defconfigs/e1
deleted file mode 100644
index e204c8778..000000000
--- a/extra/Configs/defconfigs/e1
+++ /dev/null
@@ -1 +0,0 @@
-TARGET_e1=y
diff --git a/extra/Configs/defconfigs/frv b/extra/Configs/defconfigs/frv/defconfig
index 8230316b6..8230316b6 100644
--- a/extra/Configs/defconfigs/frv
+++ b/extra/Configs/defconfigs/frv/defconfig
diff --git a/extra/Configs/defconfigs/h8300 b/extra/Configs/defconfigs/h8300/defconfig
index 66c4a33b3..66c4a33b3 100644
--- a/extra/Configs/defconfigs/h8300
+++ b/extra/Configs/defconfigs/h8300/defconfig
diff --git a/extra/Configs/defconfigs/hppa b/extra/Configs/defconfigs/hppa/defconfig
index 6358dbd1b..6358dbd1b 100644
--- a/extra/Configs/defconfigs/hppa
+++ b/extra/Configs/defconfigs/hppa/defconfig
diff --git a/extra/Configs/defconfigs/i386 b/extra/Configs/defconfigs/i386/defconfig
index 7c3517808..7c3517808 100644
--- a/extra/Configs/defconfigs/i386
+++ b/extra/Configs/defconfigs/i386/defconfig
diff --git a/extra/Configs/defconfigs/i960 b/extra/Configs/defconfigs/i960
deleted file mode 100644
index 5abe6dc8b..000000000
--- a/extra/Configs/defconfigs/i960
+++ /dev/null
@@ -1 +0,0 @@
-TARGET_i960=y
diff --git a/extra/Configs/defconfigs/ia64 b/extra/Configs/defconfigs/ia64/defconfig
index 7f26470a1..7f26470a1 100644
--- a/extra/Configs/defconfigs/ia64
+++ b/extra/Configs/defconfigs/ia64/defconfig
diff --git a/extra/Configs/defconfigs/lm32 b/extra/Configs/defconfigs/lm32
new file mode 100644
index 000000000..63fb19d79
--- /dev/null
+++ b/extra/Configs/defconfigs/lm32
@@ -0,0 +1 @@
+TARGET_lm32=y
diff --git a/extra/Configs/defconfigs/m68k b/extra/Configs/defconfigs/m68k/defconfig
index da874a89c..da874a89c 100644
--- a/extra/Configs/defconfigs/m68k
+++ b/extra/Configs/defconfigs/m68k/defconfig
diff --git a/extra/Configs/defconfigs/metag/defconfig b/extra/Configs/defconfigs/metag/defconfig
new file mode 100644
index 000000000..a6f57df72
--- /dev/null
+++ b/extra/Configs/defconfigs/metag/defconfig
@@ -0,0 +1 @@
+TARGET_metag=y
diff --git a/extra/Configs/defconfigs/microblaze b/extra/Configs/defconfigs/microblaze/defconfig
index 44012004a..44012004a 100644
--- a/extra/Configs/defconfigs/microblaze
+++ b/extra/Configs/defconfigs/microblaze/defconfig
diff --git a/extra/Configs/defconfigs/mips b/extra/Configs/defconfigs/mips/defconfig
index 0114a9bd1..0114a9bd1 100644
--- a/extra/Configs/defconfigs/mips
+++ b/extra/Configs/defconfigs/mips/defconfig
diff --git a/extra/Configs/defconfigs/nios b/extra/Configs/defconfigs/nios
deleted file mode 100644
index 2a110b893..000000000
--- a/extra/Configs/defconfigs/nios
+++ /dev/null
@@ -1 +0,0 @@
-TARGET_nios=y
diff --git a/extra/Configs/defconfigs/nios2 b/extra/Configs/defconfigs/nios2/defconfig
index 870bd538a..870bd538a 100644
--- a/extra/Configs/defconfigs/nios2
+++ b/extra/Configs/defconfigs/nios2/defconfig
diff --git a/extra/Configs/defconfigs/or1k/defconfig b/extra/Configs/defconfigs/or1k/defconfig
new file mode 100644
index 000000000..e0e08ce11
--- /dev/null
+++ b/extra/Configs/defconfigs/or1k/defconfig
@@ -0,0 +1,242 @@
+#
+# Automatically generated make config: don't edit
+# Version: 0.9.34-git
+# Wed Oct 10 16:27:15 2012
+#
+# TARGET_alpha is not set
+# TARGET_arm is not set
+# TARGET_avr32 is not set
+# TARGET_bfin is not set
+# TARGET_c6x is not set
+# TARGET_cris is not set
+# TARGET_e1 is not set
+# TARGET_frv is not set
+# TARGET_h8300 is not set
+# TARGET_hppa is not set
+# TARGET_i386 is not set
+# TARGET_ia64 is not set
+# TARGET_m68k is not set
+# TARGET_microblaze is not set
+# TARGET_mips is not set
+# TARGET_nios is not set
+# TARGET_nios2 is not set
+TARGET_or1k=y
+# TARGET_powerpc is not set
+# TARGET_sh is not set
+# TARGET_sh64 is not set
+# TARGET_sparc is not set
+# TARGET_x86_64 is not set
+# TARGET_xtensa is not set
+
+#
+# Target Architecture Features and Options
+#
+TARGET_ARCH="or1k"
+CONFIG_OR1K=y
+TARGET_SUBARCH=""
+
+#
+# Using ELF file format
+#
+ARCH_BIG_ENDIAN=y
+
+#
+# Using Big Endian
+#
+ARCH_HAS_MMU=y
+ARCH_USE_MMU=y
+UCLIBC_HAS_FLOATS=y
+UCLIBC_HAS_FPU=y
+DO_C99_MATH=y
+# DO_XSI_MATH is not set
+# UCLIBC_HAS_FENV is not set
+KERNEL_HEADERS="${SYSROOT}/usr/include"
+HAVE_DOT_CONFIG=y
+
+#
+# General Library Settings
+#
+DOPIC=y
+HAVE_SHARED=y
+# FORCE_SHAREABLE_TEXT_SEGMENTS is not set
+LDSO_LDD_SUPPORT=y
+LDSO_CACHE_SUPPORT=y
+LDSO_PRELOAD_ENV_SUPPORT=y
+# LDSO_PRELOAD_FILE_SUPPORT is not set
+LDSO_BASE_FILENAME="ld.so"
+# LDSO_STANDALONE_SUPPORT is not set
+# LDSO_PRELINK_SUPPORT is not set
+UCLIBC_STATIC_LDCONFIG=y
+LDSO_RUNPATH=y
+LDSO_SEARCH_INTERP_PATH=y
+LDSO_LD_LIBRARY_PATH=y
+# LDSO_NO_CLEANUP is not set
+UCLIBC_CTOR_DTOR=y
+# LDSO_GNU_HASH_SUPPORT is not set
+# HAS_NO_THREADS is not set
+LINUXTHREADS_OLD=y
+# LINUXTHREADS_NEW is not set
+# UCLIBC_HAS_THREADS_NATIVE is not set
+UCLIBC_HAS_THREADS=y
+# PTHREADS_DEBUG_SUPPORT is not set
+UCLIBC_HAS_SYSLOG=y
+UCLIBC_HAS_LFS=y
+# MALLOC is not set
+# MALLOC_SIMPLE is not set
+MALLOC_STANDARD=y
+# MALLOC_GLIBC_COMPAT is not set
+# UCLIBC_DYNAMIC_ATEXIT is not set
+COMPAT_ATEXIT=y
+UCLIBC_SUSV3_LEGACY=y
+# UCLIBC_SUSV3_LEGACY_MACROS is not set
+UCLIBC_SUSV4_LEGACY=y
+# UCLIBC_STRICT_HEADERS is not set
+# UCLIBC_HAS_STUBS is not set
+UCLIBC_HAS_SHADOW=y
+UCLIBC_HAS_PROGRAM_INVOCATION_NAME=y
+UCLIBC_HAS___PROGNAME=y
+UCLIBC_HAS_PTY=y
+ASSUME_DEVPTS=y
+UNIX98PTY_ONLY=y
+# UCLIBC_HAS_GETPT is not set
+# UCLIBC_HAS_LIBUTIL is not set
+UCLIBC_HAS_TM_EXTENSIONS=y
+UCLIBC_HAS_TZ_CACHING=y
+UCLIBC_HAS_TZ_FILE=y
+UCLIBC_HAS_TZ_FILE_READ_MANY=y
+UCLIBC_TZ_FILE_PATH="/etc/TZ"
+UCLIBC_FALLBACK_TO_ETC_LOCALTIME=y
+
+#
+# Advanced Library Settings
+#
+UCLIBC_PWD_BUFFER_SIZE=256
+UCLIBC_GRP_BUFFER_SIZE=256
+
+#
+# Support various families of functions
+#
+UCLIBC_LINUX_MODULE_26=y
+UCLIBC_LINUX_MODULE_24=y
+UCLIBC_LINUX_SPECIFIC=y
+UCLIBC_HAS_GNU_ERROR=y
+UCLIBC_BSD_SPECIFIC=y
+UCLIBC_HAS_BSD_ERR=y
+# UCLIBC_HAS_OBSOLETE_BSD_SIGNAL is not set
+# UCLIBC_HAS_OBSOLETE_SYSV_SIGNAL is not set
+# UCLIBC_NTP_LEGACY is not set
+# UCLIBC_SV4_DEPRECATED is not set
+UCLIBC_HAS_REALTIME=y
+UCLIBC_HAS_ADVANCED_REALTIME=y
+UCLIBC_HAS_EPOLL=y
+UCLIBC_HAS_XATTR=y
+UCLIBC_HAS_PROFILING=y
+UCLIBC_HAS_CRYPT_IMPL=y
+# UCLIBC_HAS_SHA256_CRYPT_IMPL is not set
+# UCLIBC_HAS_SHA512_CRYPT_IMPL is not set
+UCLIBC_HAS_CRYPT=y
+UCLIBC_HAS_NETWORK_SUPPORT=y
+UCLIBC_HAS_SOCKET=y
+UCLIBC_HAS_IPV4=y
+UCLIBC_HAS_IPV6=y
+UCLIBC_HAS_RPC=y
+UCLIBC_HAS_FULL_RPC=y
+UCLIBC_HAS_REENTRANT_RPC=y
+# UCLIBC_USE_NETLINK is not set
+# UCLIBC_HAS_BSD_RES_CLOSE is not set
+UCLIBC_HAS_COMPAT_RES_STATE=y
+# UCLIBC_HAS_EXTRA_COMPAT_RES_STATE is not set
+# UCLIBC_HAS_RESOLVER_SUPPORT is not set
+# UCLIBC_HAS_LIBRESOLV_STUB is not set
+# UCLIBC_HAS_LIBNSL_STUB is not set
+
+#
+# String and Stdio Support
+#
+UCLIBC_HAS_STRING_GENERIC_OPT=y
+UCLIBC_HAS_STRING_ARCH_OPT=y
+UCLIBC_HAS_CTYPE_TABLES=y
+UCLIBC_HAS_CTYPE_SIGNED=y
+UCLIBC_HAS_CTYPE_UNSAFE=y
+# UCLIBC_HAS_CTYPE_CHECKED is not set
+# UCLIBC_HAS_CTYPE_ENFORCED is not set
+UCLIBC_HAS_WCHAR=y
+# UCLIBC_HAS_LOCALE is not set
+# UCLIBC_HAS_HEXADECIMAL_FLOATS is not set
+# UCLIBC_HAS_GLIBC_CUSTOM_PRINTF is not set
+UCLIBC_PRINTF_SCANF_POSITIONAL_ARGS=9
+# UCLIBC_HAS_STDIO_BUFSIZ_NONE is not set
+# UCLIBC_HAS_STDIO_BUFSIZ_256 is not set
+# UCLIBC_HAS_STDIO_BUFSIZ_512 is not set
+# UCLIBC_HAS_STDIO_BUFSIZ_1024 is not set
+# UCLIBC_HAS_STDIO_BUFSIZ_2048 is not set
+UCLIBC_HAS_STDIO_BUFSIZ_4096=y
+# UCLIBC_HAS_STDIO_BUFSIZ_8192 is not set
+UCLIBC_HAS_STDIO_BUILTIN_BUFFER_NONE=y
+# UCLIBC_HAS_STDIO_BUILTIN_BUFFER_4 is not set
+# UCLIBC_HAS_STDIO_BUILTIN_BUFFER_8 is not set
+# UCLIBC_HAS_STDIO_SHUTDOWN_ON_ABORT is not set
+UCLIBC_HAS_STDIO_GETC_MACRO=y
+UCLIBC_HAS_STDIO_PUTC_MACRO=y
+UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION=y
+# UCLIBC_HAS_FOPEN_LARGEFILE_MODE is not set
+# UCLIBC_HAS_FOPEN_EXCLUSIVE_MODE is not set
+# UCLIBC_HAS_FOPEN_CLOSEEXEC_MODE is not set
+# UCLIBC_HAS_GLIBC_CUSTOM_STREAMS is not set
+# UCLIBC_HAS_PRINTF_M_SPEC is not set
+UCLIBC_HAS_ERRNO_MESSAGES=y
+# UCLIBC_HAS_SYS_ERRLIST is not set
+UCLIBC_HAS_SIGNUM_MESSAGES=y
+# UCLIBC_HAS_SYS_SIGLIST is not set
+UCLIBC_HAS_GNU_GETOPT=y
+UCLIBC_HAS_GNU_GETSUBOPT=y
+
+#
+# Big and Tall
+#
+UCLIBC_HAS_REGEX=y
+UCLIBC_HAS_REGEX_OLD=y
+UCLIBC_HAS_FNMATCH=y
+UCLIBC_HAS_FNMATCH_OLD=y
+# UCLIBC_HAS_WORDEXP is not set
+# UCLIBC_HAS_NFTW is not set
+# UCLIBC_HAS_FTW is not set
+# UCLIBC_HAS_FTS is not set
+UCLIBC_HAS_GLOB=y
+# UCLIBC_HAS_GNU_GLOB is not set
+# UCLIBC_HAS_UTMPX is not set
+
+#
+# Library Installation Options
+#
+RUNTIME_PREFIX="/"
+DEVEL_PREFIX="/usr"
+MULTILIB_DIR="lib"
+HARDWIRED_ABSPATH=y
+
+#
+# Security options
+#
+# UCLIBC_HAS_ARC4RANDOM is not set
+# UCLIBC_HAS_SSP is not set
+UCLIBC_BUILD_RELRO=y
+# UCLIBC_BUILD_NOW is not set
+UCLIBC_BUILD_NOEXECSTACK=y
+
+#
+# Development/debugging options
+#
+CROSS_COMPILER_PREFIX="or1k-linux-uclibc-"
+UCLIBC_EXTRA_CFLAGS=""
+# DODEBUG is not set
+# DODEBUG_PT is not set
+# DOSTRIP is not set
+# DOASSERTS is not set
+# SUPPORT_LD_DEBUG is not set
+# SUPPORT_LD_DEBUG_EARLY is not set
+# UCLIBC_MALLOC_DEBUGGING is not set
+# UCLIBC_HAS_BACKTRACE is not set
+WARNINGS="-Wall"
+# EXTRA_WARNINGS is not set
+# DOMULTI is not set
+# UCLIBC_MJN3_ONLY is not set
diff --git a/extra/Configs/defconfigs/powerpc b/extra/Configs/defconfigs/powerpc/defconfig
index 38688970e..38688970e 100644
--- a/extra/Configs/defconfigs/powerpc
+++ b/extra/Configs/defconfigs/powerpc/defconfig
diff --git a/extra/Configs/defconfigs/sh b/extra/Configs/defconfigs/sh/defconfig
index 650d280e0..650d280e0 100644
--- a/extra/Configs/defconfigs/sh
+++ b/extra/Configs/defconfigs/sh/defconfig
diff --git a/extra/Configs/defconfigs/sh64 b/extra/Configs/defconfigs/sh64
deleted file mode 100644
index 4f23a5402..000000000
--- a/extra/Configs/defconfigs/sh64
+++ /dev/null
@@ -1 +0,0 @@
-TARGET_sh64=y
diff --git a/extra/Configs/defconfigs/sparc b/extra/Configs/defconfigs/sparc/defconfig
index c2c74cbab..c2c74cbab 100644
--- a/extra/Configs/defconfigs/sparc
+++ b/extra/Configs/defconfigs/sparc/defconfig
diff --git a/extra/Configs/defconfigs/v850 b/extra/Configs/defconfigs/v850
deleted file mode 100644
index 046d5d4fd..000000000
--- a/extra/Configs/defconfigs/v850
+++ /dev/null
@@ -1 +0,0 @@
-TARGET_v850=y
diff --git a/extra/Configs/defconfigs/vax b/extra/Configs/defconfigs/vax
deleted file mode 100644
index 77a464e29..000000000
--- a/extra/Configs/defconfigs/vax
+++ /dev/null
@@ -1 +0,0 @@
-TARGET_vax=y
diff --git a/extra/Configs/defconfigs/x86_64 b/extra/Configs/defconfigs/x86_64/defconfig
index e03a36aa2..e03a36aa2 100644
--- a/extra/Configs/defconfigs/x86_64
+++ b/extra/Configs/defconfigs/x86_64/defconfig
diff --git a/extra/config/.gitignore b/extra/config/.gitignore
index b49584c93..be603c4fe 100644
--- a/extra/config/.gitignore
+++ b/extra/config/.gitignore
@@ -2,18 +2,21 @@
# Generated files
#
config*
-lex.*.c
+*.lex.c
*.tab.c
*.tab.h
zconf.hash.c
*.moc
-lkc_defs.h
+gconf.glade.h
+*.pot
+*.mo
#
# configuration programs
#
conf
mconf
+nconf
qconf
gconf
kxgettext
diff --git a/extra/config/Makefile b/extra/config/Makefile
index 45ec1f47e..c306a7eb1 100644
--- a/extra/config/Makefile
+++ b/extra/config/Makefile
@@ -1,43 +1,82 @@
-obj := .
-src := .
-top_srcdir=../../
-top_builddir=../../
-srctree := .
-include $(top_builddir)Rules.mak
+top_srcdir ?= ../../
-include Makefile.kconfig
+ifdef O
+top_builddir ?= ../../
+else
+top_builddir = ../../
+endif
+
+include $(top_srcdir)Rules.mak
+include $(top_srcdir)Makerules
+
+# ugh
+top_srcdir:=$(shell cd $(top_srcdir) && pwd)/
+
+src := extra/config
+obj := $(top_builddir)$(src)
+
+generated := $(patsubst %_shipped,%,$(wildcard *_shipped))
+generated := $(addprefix $(obj)/,$(generated:.c=.o))
+
+include $(top_srcdir)extra/config/Makefile.kconfig
+HOST_EXTRACFLAGS += -DCONFIG_='""'
+
+# do not create temporary object in the readonly srctree
+$(obj)/dochecklxdialog: CONFIG_SHELL:=cd $(obj) && $(CONFIG_SHELL)
+HOSTCFLAGS_zconf.lex.o := -I$(top_srcdir)$(src)
+HOSTCFLAGS_zconf.tab.o := -I$(top_srcdir)$(src)
+conf-objs := $(addprefix $(obj)/,$(conf-objs))
+mconf-objs := $(addprefix $(obj)/,$(mconf-objs))
+nconf-objs := $(addprefix $(obj)/,$(nconf-objs))
+kxgettext-objs := $(addprefix $(obj)/,$(kxgettext-objs))
ifeq ($(findstring mconf,$(MAKECMDGOALS)),mconf)
hostprogs-y += mconf
endif
-
--include .depend
-.depend: $(wildcard *.h *.c)
- $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) -MM *.c > .depend 2>/dev/null || :
+ifeq ($(findstring nconf,$(MAKECMDGOALS)),nconf)
+hostprogs-y += nconf
+endif
__hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
-host-csingle := $(foreach m,$(__hostprogs),$(if $($(m)-objs),,$(m)))
+host-csingle:= $(foreach m,$(__hostprogs),$(if $($(m)-objs),,$(m)))
host-cmulti := $(foreach m,$(__hostprogs),\
$(if $($(m)-cxxobjs),,$(if $($(m)-objs),$(m))))
host-cobjs := $(sort $(foreach m,$(__hostprogs),$($(m)-objs)))
-$(host-csingle): %: %.c
- $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCFLAGS_$@) $< $(HOST_LOADLIBES) -o $@
+conf mconf nconf kxgettext: %: $(obj)/%
+$(obj)/conf $(obj)/mconf $(obj)/nconf $(obj)/kxgettext: BUILD_LDFLAGS=$(HOSTLOADLIBES_$(@F))
+$(obj)/conf: $(conf-objs)
+ $(hcompile.u)
+$(obj)/mconf: $(mconf-objs)
+ $(hcompile.u)
+$(obj)/nconf: $(nconf-objs)
+ $(hcompile.u)
+$(obj)/kxgettext: $(kxgettext-objs)
+ $(hcompile.u)
+
+$(host-csingle) $(host-cmulti) $(host-cobjs): BUILD_CFLAGS+=$(HOST_EXTRACFLAGS) \
+ $(HOSTCFLAGS) $(HOSTCFLAGS_$(@F))
-$(host-cmulti): %: $(host-cobjs) $(host-cshlib)
- $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCFLAGS_$@) $($@-objs) $(HOST_LOADLIBES) -o $@
+host-cobjs.nogen := $(filter-out $(generated),$(host-cobjs))
+host-cobjs.generated := $(filter $(generated),$(host-cobjs))
-$(host-cobjs): %.o: %.c
- $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCFLAGS_$@) -c $< -o $@
+$(host-cobjs.nogen): $(obj)/%.o: $(top_srcdir)$(src)/%.c
+ $(hcompile.o)
+$(host-cobjs.generated): $(obj)/%.o: $(obj)/%.c
+ $(hcompile.o)
-$(obj)/%:: $(src)/%_shipped
+# we use the pre-generated always
+$(obj)/%:: $(top_srcdir)$(src)/%_shipped
+ @$(disp_gen)
$(Q)cat $< > $@
-clean:
- $(Q)rm -f $(clean-files) conf
-distclean: clean
- $(Q)rm -f $(lxdialog) $(conf-objs) $(mconf-objs) $(kxgettext-objs) \
- $(hostprogs-y) $(qconf-cxxobjs) $(qconf-objs) $(gconf-objs) .depend
+CLEAN_extra/config menuconfig_clean:
+ $(do_rm) $(clean-files) $(lxdialog) conf $(wildcard *.o)
+distclean: CLEAN_extra/config
+ $(Q)$(RM) -r $(lxdialog) $(conf-objs) $(mconf-objs) $(nconf-objs) \
+ $(kxgettext-objs) \
+ $(hostprogs-y) $(qconf-cxxobjs) $(qconf-objs) $(gconf-objs) \
+ .depend \
+ $(top_builddir)include/config $(top_builddir)include/generated
-FORCE:
-.PHONY: FORCE clean distclean
+.PHONY: clean distclean $(PHONY)
diff --git a/extra/config/Makefile.kconfig b/extra/config/Makefile.kconfig
index 32e8c5a22..844bc9da0 100644
--- a/extra/config/Makefile.kconfig
+++ b/extra/config/Makefile.kconfig
@@ -2,9 +2,17 @@
# Kernel configuration targets
# These targets are used from top-level makefile
-PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config
+PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config \
+ localmodconfig localyesconfig
-Kconfig := arch/$(SRCARCH)/Kconfig
+ifdef KBUILD_KCONFIG
+Kconfig := $(KBUILD_KCONFIG)
+else
+Kconfig := Kconfig
+endif
+
+# We need this, in case the user has it in its environment
+unexport CONFIG_
xconfig: $(obj)/qconf
$< $(Kconfig)
@@ -16,91 +24,121 @@ menuconfig: $(obj)/mconf
$< $(Kconfig)
config: $(obj)/conf
+ $< --oldaskconfig $(Kconfig)
+
+nconfig: $(obj)/nconf
$< $(Kconfig)
oldconfig: $(obj)/conf
- $< -o $(Kconfig)
+ $< --$@ $(Kconfig)
silentoldconfig: $(obj)/conf
- $< -s $(Kconfig)
+ $(Q)mkdir -p include/generated
+ $< --$@ $(Kconfig)
+
+localyesconfig localmodconfig: $(obj)/streamline_config.pl $(obj)/conf
+ $(Q)mkdir -p include/generated
+ $(Q)perl $< --$@ $(srctree) $(Kconfig) > .tmp.config
+ $(Q)if [ -f .config ]; then \
+ cmp -s .tmp.config .config || \
+ (mv -f .config .config.old.1; \
+ mv -f .tmp.config .config; \
+ $(obj)/conf --silentoldconfig $(Kconfig); \
+ mv -f .config.old.1 .config.old) \
+ else \
+ mv -f .tmp.config .config; \
+ $(obj)/conf --silentoldconfig $(Kconfig); \
+ fi
+ $(Q)rm -f .tmp.config
# Create new linux.pot file
# Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files
-# The symlink is used to repair a deficiency in arch/um
update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h
- $(Q)echo " GEN config"
- $(Q)xgettext --default-domain=linux \
- --add-comments --keyword=_ --keyword=N_ \
- --from-code=UTF-8 \
- --files-from=scripts/kconfig/POTFILES.in \
+ $(Q)echo " GEN config.pot"
+ $(Q)xgettext --default-domain=linux \
+ --add-comments --keyword=_ --keyword=N_ \
+ --from-code=UTF-8 \
+ --files-from=$(srctree)/scripts/kconfig/POTFILES.in \
+ --directory=$(srctree) --directory=$(objtree) \
--output $(obj)/config.pot
$(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot
- $(Q)ln -fs Kconfig.i386 arch/um/Kconfig.arch
- $(Q)(for i in `ls arch/`; \
+ $(Q)(for i in `ls $(srctree)/arch/*/Kconfig \
+ $(srctree)/arch/*/um/Kconfig`; \
do \
- echo " GEN $$i"; \
- $(obj)/kxgettext arch/$$i/Kconfig \
+ echo " GEN $$i"; \
+ $(obj)/kxgettext $$i \
>> $(obj)/config.pot; \
done )
+ $(Q)echo " GEN linux.pot"
$(Q)msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \
--output $(obj)/linux.pot
- $(Q)rm -f arch/um/Kconfig.arch
$(Q)rm -f $(obj)/config.pot
-PHONY += randconfig allyesconfig allnoconfig allmodconfig defconfig
+PHONY += allnoconfig allyesconfig allmodconfig alldefconfig randconfig
+
+allnoconfig allyesconfig allmodconfig alldefconfig randconfig: $(obj)/conf
+ $< --$@ $(Kconfig)
-randconfig: $(obj)/conf
- $< -r $(Kconfig)
+PHONY += listnewconfig olddefconfig oldnoconfig savedefconfig defconfig
-allyesconfig: $(obj)/conf
- $< -y $(Kconfig)
+listnewconfig olddefconfig: $(obj)/conf
+ $< --$@ $(Kconfig)
-allnoconfig: $(obj)/conf
- $< -n $(Kconfig)
+# oldnoconfig is an alias of olddefconfig, because people already are dependent
+# on its behavior(sets new symbols to their default value but not 'n') with the
+# counter-intuitive name.
+oldnoconfig: $(obj)/conf
+ $< --olddefconfig $(Kconfig)
-allmodconfig: $(obj)/conf
- $< -m $(Kconfig)
+savedefconfig: $(obj)/conf
+ $< --$@=defconfig $(Kconfig)
defconfig: $(obj)/conf
ifeq ($(KBUILD_DEFCONFIG),)
- $< -d $(Kconfig)
+ $< --defconfig $(Kconfig)
else
@echo "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
- $(Q)$< -D arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
+ $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
endif
%_defconfig: $(obj)/conf
- $(Q)$< -D arch/$(SRCARCH)/configs/$@ $(Kconfig)
+ $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
# Help text used by make help
help:
@echo ' config - Update current config utilising a line-oriented program'
+ @echo ' nconfig - Update current config utilising a ncurses menu based program'
@echo ' menuconfig - Update current config utilising a menu based program'
@echo ' xconfig - Update current config utilising a QT based front-end'
@echo ' gconfig - Update current config utilising a GTK based front-end'
@echo ' oldconfig - Update current config utilising a provided .config as base'
- @echo ' silentoldconfig - Same as oldconfig, but quietly'
- @echo ' randconfig - New config with random answer to all options'
- @echo ' defconfig - New config with default answer to all options'
- @echo ' allmodconfig - New config selecting modules when possible'
- @echo ' allyesconfig - New config where all options are accepted with yes'
+ @echo ' localmodconfig - Update current config disabling modules not loaded'
+ @echo ' localyesconfig - Update current config converting local mods to core'
+ @echo ' silentoldconfig - Same as oldconfig, but quietly, additionally update deps'
+ @echo ' defconfig - New config with default from ARCH supplied defconfig'
+ @echo ' savedefconfig - Save current config as ./defconfig (minimal config)'
@echo ' allnoconfig - New config where all options are answered with no'
+ @echo ' allyesconfig - New config where all options are accepted with yes'
+ @echo ' allmodconfig - New config selecting modules when possible'
+ @echo ' alldefconfig - New config with all symbols set to default'
+ @echo ' randconfig - New config with random answer to all options'
+ @echo ' listnewconfig - List new options'
+ @echo ' olddefconfig - Same as silentoldconfig but sets new symbols to their default value'
# lxdialog stuff
check-lxdialog := $(srctree)/$(src)/lxdialog/check-lxdialog.sh
# Use recursively expanded variables so we do not call gcc unless
# we really need to do so. (Do not call gcc as part of make mrproper)
-HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags)
-HOST_LOADLIBES = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
-
-HOST_EXTRACFLAGS += -DLOCALE
-
+HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) \
+ -DLOCALE
# ===========================================================================
# Shared Makefile for the various kconfig executables:
# conf: Used for defconfig, oldconfig and related targets
-# mconf: Used for the mconfig target.
+# nconf: Used for the nconfig target.
+# Utilizes ncurses
+# mconf: Used for the menuconfig target
# Utilizes the lxdialog package
# qconf: Used for the xconfig target
# Based on QT which needs to be installed to compile it
@@ -112,15 +150,27 @@ lxdialog := lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o
lxdialog += lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o
conf-objs := conf.o zconf.tab.o
-mconf-objs := mconf.o zconf.tab.o $(lxdialog)
+mconf-objs := mconf.o zconf.tab.o $(lxdialog)
+nconf-objs := nconf.o zconf.tab.o nconf.gui.o
kxgettext-objs := kxgettext.o zconf.tab.o
+qconf-cxxobjs := qconf.o
+qconf-objs := zconf.tab.o
+gconf-objs := gconf.o zconf.tab.o
+
+hostprogs-y := conf
-hostprogs-y := conf qconf gconf kxgettext
+ifeq ($(MAKECMDGOALS),nconfig)
+ hostprogs-y += nconf
+endif
ifeq ($(MAKECMDGOALS),menuconfig)
hostprogs-y += mconf
endif
+ifeq ($(MAKECMDGOALS),update-po-config)
+ hostprogs-y += kxgettext
+endif
+
ifeq ($(MAKECMDGOALS),xconfig)
qconf-target := 1
endif
@@ -130,24 +180,23 @@ endif
ifeq ($(qconf-target),1)
-qconf-cxxobjs := qconf.o
-qconf-objs := kconfig_load.o zconf.tab.o
+ hostprogs-y += qconf
endif
ifeq ($(gconf-target),1)
-gconf-objs := gconf.o kconfig_load.o zconf.tab.o
+ hostprogs-y += gconf
endif
-clean-files := lkc_defs.h qconf.moc .tmp_qtcheck \
- .tmp_gtkcheck zconf.tab.c lex.zconf.c zconf.hash.c gconf.glade.h
-clean-files += mconf qconf gconf
+clean-files := qconf.moc .tmp_qtcheck .tmp_gtkcheck
+clean-files += zconf.tab.c zconf.lex.c zconf.hash.c gconf.glade.h
+clean-files += mconf qconf gconf nconf
clean-files += config.pot linux.pot
# Check that we have the required ncurses stuff installed for lxdialog (menuconfig)
PHONY += $(obj)/dochecklxdialog
$(addprefix $(obj)/,$(lxdialog)): $(obj)/dochecklxdialog
$(obj)/dochecklxdialog:
- $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOST_LOADLIBES)
+ $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTLOADLIBES_mconf)
always := dochecklxdialog
@@ -155,16 +204,24 @@ always := dochecklxdialog
HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS))
# generated files seem to need this to find local include files
-HOSTCFLAGS_lex.zconf.o := -I$(src)
+HOSTCFLAGS_zconf.lex.o := -I$(src)
HOSTCFLAGS_zconf.tab.o := -I$(src)
-HOSTLOADLIBES_qconf = $(KC_QT_LIBS) -ldl
-HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS) -D LKC_DIRECT_LINK
+LEX_PREFIX_zconf := zconf
+YACC_PREFIX_zconf := zconf
+
+HOSTLOADLIBES_qconf = $(KC_QT_LIBS)
+HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS)
HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0`
HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \
- -D LKC_DIRECT_LINK
+ -Wno-missing-prototypes
+
+HOSTLOADLIBES_mconf = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
+HOSTLOADLIBES_nconf = $(shell \
+ pkg-config --libs menu panel ncurses 2>/dev/null \
+ || echo "-lmenu -lpanel -lncurses" )
$(obj)/qconf.o: $(obj)/.tmp_qtcheck
ifeq ($(qconf-target),1)
@@ -174,40 +231,48 @@ $(obj)/.tmp_qtcheck: $(src)/Makefile
# QT needs some extra effort...
$(obj)/.tmp_qtcheck:
@set -e; echo " CHECK qt"; dir=""; pkg=""; \
- pkg-config --exists qt 2> /dev/null && pkg=qt; \
- pkg-config --exists qt-mt 2> /dev/null && pkg=qt-mt; \
- if [ -n "$$pkg" ]; then \
- cflags="\$$(shell pkg-config $$pkg --cflags)"; \
- libs="\$$(shell pkg-config $$pkg --libs)"; \
- moc="\$$(shell pkg-config $$pkg --variable=prefix)/bin/moc"; \
- dir="$$(pkg-config $$pkg --variable=prefix)"; \
+ if ! pkg-config --exists QtCore 2> /dev/null; then \
+ echo "* Unable to find the QT4 tool qmake. Trying to use QT3"; \
+ pkg-config --exists qt 2> /dev/null && pkg=qt; \
+ pkg-config --exists qt-mt 2> /dev/null && pkg=qt-mt; \
+ if [ -n "$$pkg" ]; then \
+ cflags="\$$(shell pkg-config $$pkg --cflags)"; \
+ libs="\$$(shell pkg-config $$pkg --libs)"; \
+ moc="\$$(shell pkg-config $$pkg --variable=prefix)/bin/moc"; \
+ dir="$$(pkg-config $$pkg --variable=prefix)"; \
+ else \
+ for d in $$QTDIR /usr/share/qt* /usr/lib/qt*; do \
+ if [ -f $$d/include/qconfig.h ]; then dir=$$d; break; fi; \
+ done; \
+ if [ -z "$$dir" ]; then \
+ echo >&2 "*"; \
+ echo >&2 "* Unable to find any QT installation. Please make sure that"; \
+ echo >&2 "* the QT4 or QT3 development package is correctly installed and"; \
+ echo >&2 "* either qmake can be found or install pkg-config or set"; \
+ echo >&2 "* the QTDIR environment variable to the correct location."; \
+ echo >&2 "*"; \
+ false; \
+ fi; \
+ libpath=$$dir/lib; lib=qt; osdir=""; \
+ $(HOSTCXX) -print-multi-os-directory > /dev/null 2>&1 && \
+ osdir=x$$($(HOSTCXX) -print-multi-os-directory); \
+ test -d $$libpath/$$osdir && libpath=$$libpath/$$osdir; \
+ test -f $$libpath/libqt-mt.so && lib=qt-mt; \
+ cflags="-I$$dir/include"; \
+ libs="-L$$libpath -Wl,-rpath,$$libpath -l$$lib"; \
+ moc="$$dir/bin/moc"; \
+ fi; \
+ if [ ! -x $$dir/bin/moc -a -x /usr/bin/moc ]; then \
+ echo "*"; \
+ echo "* Unable to find $$dir/bin/moc, using /usr/bin/moc instead."; \
+ echo "*"; \
+ moc="/usr/bin/moc"; \
+ fi; \
else \
- for d in $$QTDIR /usr/share/qt* /usr/lib/qt*; do \
- if [ -f $$d/include/qconfig.h ]; then dir=$$d; break; fi; \
- done; \
- if [ -z "$$dir" ]; then \
- echo "*"; \
- echo "* Unable to find the QT3 installation. Please make sure that"; \
- echo "* the QT3 development package is correctly installed and"; \
- echo "* either install pkg-config or set the QTDIR environment"; \
- echo "* variable to the correct location."; \
- echo "*"; \
- false; \
- fi; \
- libpath=$$dir/lib; lib=qt; osdir=""; \
- $(HOSTCXX) -print-multi-os-directory > /dev/null 2>&1 && \
- osdir=x$$($(HOSTCXX) -print-multi-os-directory); \
- test -d $$libpath/$$osdir && libpath=$$libpath/$$osdir; \
- test -f $$libpath/libqt-mt.so && lib=qt-mt; \
- cflags="-I$$dir/include"; \
- libs="-L$$libpath -Wl,-rpath,$$libpath -l$$lib"; \
- moc="$$dir/bin/moc"; \
- fi; \
- if [ ! -x $$dir/bin/moc -a -x /usr/bin/moc ]; then \
- echo "*"; \
- echo "* Unable to find $$dir/bin/moc, using /usr/bin/moc instead."; \
- echo "*"; \
- moc="/usr/bin/moc"; \
+ cflags="\$$(shell pkg-config QtCore QtGui Qt3Support --cflags)"; \
+ libs="\$$(shell pkg-config QtCore QtGui Qt3Support --libs)"; \
+ moc="\$$(shell pkg-config QtCore --variable=moc_location)"; \
+ [ -n "$$moc" ] || moc="\$$(shell pkg-config QtCore --variable=prefix)/bin/moc"; \
fi; \
echo "KC_QT_CFLAGS=$$cflags" > $@; \
echo "KC_QT_LIBS=$$libs" >> $@; \
@@ -225,61 +290,33 @@ $(obj)/.tmp_gtkcheck:
if `pkg-config --atleast-version=2.0.0 gtk+-2.0`; then \
touch $@; \
else \
- echo "*"; \
- echo "* GTK+ is present but version >= 2.0.0 is required."; \
- echo "*"; \
+ echo >&2 "*"; \
+ echo >&2 "* GTK+ is present but version >= 2.0.0 is required."; \
+ echo >&2 "*"; \
false; \
fi \
else \
- echo "*"; \
- echo "* Unable to find the GTK+ installation. Please make sure that"; \
- echo "* the GTK+ 2.0 development package is correctly installed..."; \
- echo "* You need gtk+-2.0, glib-2.0 and libglade-2.0."; \
- echo "*"; \
+ echo >&2 "*"; \
+ echo >&2 "* Unable to find the GTK+ installation. Please make sure that"; \
+ echo >&2 "* the GTK+ 2.0 development package is correctly installed..."; \
+ echo >&2 "* You need gtk+-2.0, glib-2.0 and libglade-2.0."; \
+ echo >&2 "*"; \
false; \
fi
endif
-$(obj)/zconf.tab.o: $(obj)/lex.zconf.c $(obj)/zconf.hash.c
-
-$(obj)/kconfig_load.o: $(obj)/lkc_defs.h
+$(obj)/zconf.tab.o: $(obj)/zconf.lex.c $(obj)/zconf.hash.c
-$(obj)/qconf.o: $(obj)/qconf.moc $(obj)/lkc_defs.h
+$(obj)/qconf.o: $(obj)/qconf.moc
-$(obj)/gconf.o: $(obj)/lkc_defs.h
+quiet_cmd_moc = MOC $@
+ cmd_moc = $(KC_QT_MOC) -i $< -o $@
-$(obj)/%.moc: $(src)/%.h
- $(KC_QT_MOC) -i $< -o $@
-
-$(obj)/lkc_defs.h: $(src)/lkc_proto.h
- sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/'
+$(obj)/%.moc: $(src)/%.h $(obj)/.tmp_qtcheck
+ $(call cmd,moc)
# Extract gconf menu items for I18N support
$(obj)/gconf.glade.h: $(obj)/gconf.glade
- intltool-extract --type=gettext/glade $(obj)/gconf.glade
-
-###
-# The following requires flex/bison/gperf
-# By default we use the _shipped versions, uncomment the following line if
-# you are modifying the flex/bison src.
-# LKC_GENPARSER := 1
-
-ifdef LKC_GENPARSER
-
-$(obj)/zconf.tab.c: $(src)/zconf.y
-$(obj)/lex.zconf.c: $(src)/zconf.l
-$(obj)/zconf.hash.c: $(src)/zconf.gperf
+ $(Q)intltool-extract --type=gettext/glade --srcdir=$(srctree) \
+ $(obj)/gconf.glade
-%.tab.c: %.y
- bison -l -b $* -p $(notdir $*) $<
- cp $@ $@_shipped
-
-lex.%.c: %.l
- flex -L -P$(notdir $*) -o$@ $<
- cp $@ $@_shipped
-
-%.hash.c: %.gperf
- gperf < $< > $@
- cp $@ $@_shipped
-
-endif
diff --git a/extra/config/README.uClibc b/extra/config/README.uClibc
index fa1a0018f..0dcba9c7c 100644
--- a/extra/config/README.uClibc
+++ b/extra/config/README.uClibc
@@ -5,8 +5,9 @@ To update:
cd extra/config.new
cp /usr/src/linux/Documentation/kbuild/kconfig-language.txt .
mv Makefile Makefile.kconfig
- patch -p1 < ../config/kconfig-to-uclibc.patch
+ tar -O -xzf ../config/kconfig-to-uclibc.tar.gz | patch -p3
cp ../config/README.uClibc .
+ cp ../config/Makefile .
cd ..
rm -rf config
mv config.new config
diff --git a/extra/config/check.sh b/extra/config/check.sh
index fa59cbf9d..854d9c7c6 100755
--- a/extra/config/check.sh
+++ b/extra/config/check.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# Needed for systems without gettext
-$* -xc -o /dev/null - > /dev/null 2>&1 << EOF
+$* -x c -o /dev/null - > /dev/null 2>&1 << EOF
#include <libintl.h>
int main()
{
diff --git a/extra/config/conf.c b/extra/config/conf.c
index 6735bfe76..34bb4f587 100644
--- a/extra/config/conf.c
+++ b/extra/config/conf.c
@@ -5,45 +5,53 @@
#include <locale.h>
#include <ctype.h>
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <sys/stat.h>
+#include <sys/time.h>
+#include <errno.h>
-#define LKC_DIRECT_LINK
#include "lkc.h"
static void conf(struct menu *menu);
static void check_conf(struct menu *menu);
-
-enum {
- ask_all,
- ask_new,
- ask_silent,
- set_default,
- set_yes,
- set_mod,
- set_no,
- set_random
-} input_mode = ask_all;
-char *defconfig_file;
+static void xfgets(char *str, int size, FILE *in);
+
+enum input_mode {
+ oldaskconfig,
+ silentoldconfig,
+ oldconfig,
+ allnoconfig,
+ allyesconfig,
+ allmodconfig,
+ alldefconfig,
+ randconfig,
+ defconfig,
+ savedefconfig,
+ listnewconfig,
+ olddefconfig,
+} input_mode = oldaskconfig;
static int indent = 1;
+static int tty_stdio;
static int valid_stdin = 1;
+static int sync_kconfig;
static int conf_cnt;
-static char line[128];
+static char line[PATH_MAX];
static struct menu *rootEntry;
-static char nohelp_text[] = N_("Sorry, no help available for this option yet.\n");
-
-static const char *get_help(struct menu *menu)
+static void print_help(struct menu *menu)
{
- if (menu_has_help(menu))
- return _(menu_get_help(menu));
- else
- return nohelp_text;
+ struct gstr help = str_new();
+
+ menu_get_ext_help(menu, &help);
+
+ printf("\n%s\n", str_get(&help));
+ str_free(&help);
}
static void strip(char *str)
@@ -65,7 +73,7 @@ static void strip(char *str)
static void check_stdin(void)
{
- if (!valid_stdin && input_mode == ask_silent) {
+ if (!valid_stdin) {
printf(_("aborted!\n\n"));
printf(_("Console input/output is redirected. "));
printf(_("Run 'make oldconfig' to update configuration.\n\n"));
@@ -76,7 +84,6 @@ static void check_stdin(void)
static int conf_askvalue(struct symbol *sym, const char *def)
{
enum symbol_type type = sym_get_type(sym);
- tristate val;
if (!sym_has_value(sym))
printf(_("(NEW) "));
@@ -92,28 +99,19 @@ static int conf_askvalue(struct symbol *sym, const char *def)
}
switch (input_mode) {
- case set_no:
- case set_mod:
- case set_yes:
- case set_random:
- if (sym_has_value(sym)) {
- printf("%s\n", def);
- return 0;
- }
- break;
- case ask_new:
- case ask_silent:
+ case oldconfig:
+ case silentoldconfig:
if (sym_has_value(sym)) {
printf("%s\n", def);
return 0;
}
check_stdin();
- case ask_all:
+ /* fall through */
+ case oldaskconfig:
fflush(stdout);
- fgets(line, 128, stdin);
- return 1;
- case set_default:
- printf("%s\n", def);
+ xfgets(line, sizeof(line), stdin);
+ if (!tty_stdio)
+ printf("\n");
return 1;
default:
break;
@@ -128,57 +126,11 @@ static int conf_askvalue(struct symbol *sym, const char *def)
default:
;
}
- switch (input_mode) {
- case set_yes:
- if (sym_tristate_within_range(sym, yes)) {
- line[0] = 'y';
- line[1] = '\n';
- line[2] = 0;
- break;
- }
- case set_mod:
- if (type == S_TRISTATE) {
- if (sym_tristate_within_range(sym, mod)) {
- line[0] = 'm';
- line[1] = '\n';
- line[2] = 0;
- break;
- }
- } else {
- if (sym_tristate_within_range(sym, yes)) {
- line[0] = 'y';
- line[1] = '\n';
- line[2] = 0;
- break;
- }
- }
- case set_no:
- if (sym_tristate_within_range(sym, no)) {
- line[0] = 'n';
- line[1] = '\n';
- line[2] = 0;
- break;
- }
- case set_random:
- do {
- val = (tristate)(rand() % 3);
- } while (!sym_tristate_within_range(sym, val));
- switch (val) {
- case no: line[0] = 'n'; break;
- case mod: line[0] = 'm'; break;
- case yes: line[0] = 'y'; break;
- }
- line[1] = '\n';
- line[2] = 0;
- break;
- default:
- break;
- }
printf("%s", line);
return 1;
}
-int conf_string(struct menu *menu)
+static int conf_string(struct menu *menu)
{
struct symbol *sym = menu->sym;
const char *def;
@@ -197,10 +149,11 @@ int conf_string(struct menu *menu)
case '?':
/* print help */
if (line[1] == '\n') {
- printf("\n%s\n", get_help(menu));
+ print_help(menu);
def = NULL;
break;
}
+ /* fall through */
default:
line[strlen(line)-1] = 0;
def = line;
@@ -213,14 +166,12 @@ int conf_string(struct menu *menu)
static int conf_sym(struct menu *menu)
{
struct symbol *sym = menu->sym;
- int type;
tristate oldval, newval;
while (1) {
printf("%*s%s ", indent - 1, "", _(menu->prompt->text));
if (sym->name)
printf("(%s) ", sym->name);
- type = sym_get_type(sym);
putchar('[');
oldval = sym_get_tristate_value(sym);
switch (oldval) {
@@ -277,7 +228,7 @@ static int conf_sym(struct menu *menu)
if (sym_set_tristate_value(sym, newval))
return 0;
help:
- printf("\n%s\n", get_help(menu));
+ print_help(menu);
}
}
@@ -285,11 +236,9 @@ static int conf_choice(struct menu *menu)
{
struct symbol *sym, *def_sym;
struct menu *child;
- int type;
bool is_new;
sym = menu->sym;
- type = sym_get_type(sym);
is_new = !sym_has_value(sym);
if (sym_is_changable(sym)) {
conf_sym(menu);
@@ -351,20 +300,21 @@ static int conf_choice(struct menu *menu)
printf("?");
printf("]: ");
switch (input_mode) {
- case ask_new:
- case ask_silent:
+ case oldconfig:
+ case silentoldconfig:
if (!is_new) {
cnt = def;
printf("%d\n", cnt);
break;
}
check_stdin();
- case ask_all:
+ /* fall through */
+ case oldaskconfig:
fflush(stdout);
- fgets(line, 128, stdin);
+ xfgets(line, sizeof(line), stdin);
strip(line);
if (line[0] == '?') {
- printf("\n%s\n", get_help(menu));
+ print_help(menu);
continue;
}
if (!line[0])
@@ -374,15 +324,7 @@ static int conf_choice(struct menu *menu)
else
continue;
break;
- case set_random:
- if (is_new)
- def = (rand() % cnt) + 1;
- case set_default:
- case set_yes:
- case set_mod:
- case set_no:
- cnt = def;
- printf("%d\n", cnt);
+ default:
break;
}
@@ -395,8 +337,8 @@ static int conf_choice(struct menu *menu)
}
if (!child)
continue;
- if (line[strlen(line) - 1] == '?') {
- printf("\n%s\n", get_help(child));
+ if (line[0] && line[strlen(line) - 1] == '?') {
+ print_help(child);
continue;
}
sym_set_choice_value(sym, child->sym);
@@ -425,10 +367,14 @@ static void conf(struct menu *menu)
switch (prop->type) {
case P_MENU:
- if (input_mode == ask_silent && rootEntry != menu) {
+ if ((input_mode == silentoldconfig ||
+ input_mode == listnewconfig ||
+ input_mode == olddefconfig) &&
+ rootEntry != menu) {
check_conf(menu);
return;
}
+ /* fall through */
case P_COMMENT:
prompt = menu_get_prompt(menu);
if (prompt)
@@ -483,10 +429,16 @@ static void check_conf(struct menu *menu)
if (sym && !sym_has_value(sym)) {
if (sym_is_changable(sym) ||
(sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) {
- if (!conf_cnt++)
- printf(_("*\n* Restart config...\n*\n"));
- rootEntry = menu_get_parent_menu(menu);
- conf(rootEntry);
+ if (input_mode == listnewconfig) {
+ if (sym->name && !sym_is_choice_value(sym)) {
+ printf("%s%s\n", CONFIG_, sym->name);
+ }
+ } else if (input_mode != olddefconfig) {
+ if (!conf_cnt++)
+ printf(_("*\n* Restart config...\n*\n"));
+ rootEntry = menu_get_parent_menu(menu);
+ conf(rootEntry);
+ }
}
}
@@ -494,63 +446,170 @@ static void check_conf(struct menu *menu)
check_conf(child);
}
+#if 00 // || !defined __UCLIBC__ || \
+ defined __UCLIBC_HAS_GETOPT_LONG__
+static struct option long_opts[] = {
+ {"oldaskconfig", no_argument, NULL, oldaskconfig},
+ {"oldconfig", no_argument, NULL, oldconfig},
+ {"silentoldconfig", no_argument, NULL, silentoldconfig},
+ {"defconfig", optional_argument, NULL, defconfig},
+ {"savedefconfig", required_argument, NULL, savedefconfig},
+ {"allnoconfig", no_argument, NULL, allnoconfig},
+ {"allyesconfig", no_argument, NULL, allyesconfig},
+ {"allmodconfig", no_argument, NULL, allmodconfig},
+ {"alldefconfig", no_argument, NULL, alldefconfig},
+ {"randconfig", no_argument, NULL, randconfig},
+ {"listnewconfig", no_argument, NULL, listnewconfig},
+ {"olddefconfig", no_argument, NULL, olddefconfig},
+ /*
+ * oldnoconfig is an alias of olddefconfig, because people already
+ * are dependent on its behavior(sets new symbols to their default
+ * value but not 'n') with the counter-intuitive name.
+ */
+ {"oldnoconfig", no_argument, NULL, olddefconfig},
+ {NULL, 0, NULL, 0}
+};
+
+static void conf_usage(const char *progname)
+{
+
+ printf("Usage: %s [option] <kconfig-file>\n", progname);
+ printf("[option] is _one_ of the following:\n");
+ printf(" --listnewconfig List new options\n");
+ printf(" --oldaskconfig Start a new configuration using a line-oriented program\n");
+ printf(" --oldconfig Update a configuration using a provided .config as base\n");
+ printf(" --silentoldconfig Same as oldconfig, but quietly, additionally update deps\n");
+ printf(" --olddefconfig Same as silentoldconfig but sets new symbols to their default value\n");
+ printf(" --oldnoconfig An alias of olddefconfig\n");
+ printf(" --defconfig <file> New config with default defined in <file>\n");
+ printf(" --savedefconfig <file> Save the minimal current configuration to <file>\n");
+ printf(" --allnoconfig New config where all options are answered with no\n");
+ printf(" --allyesconfig New config where all options are answered with yes\n");
+ printf(" --allmodconfig New config where all options are answered with mod\n");
+ printf(" --alldefconfig New config with all symbols set to default\n");
+ printf(" --randconfig New config with random answer to all options\n");
+}
+#else
+static void conf_usage(const char *progname)
+{
+
+ printf("Usage: %s [option] <kconfig-file>\n", progname);
+ printf("[option] is _one_ of the following:\n");
+ printf(" -a, --oldaskconfig Start a new configuration using a line-oriented program\n");
+ printf(" -s, --silentoldconfig Same as oldconfig, but quietly, additionally update deps\n");
+ printf(" -o, --oldconfig Update a configuration using a provided .config as base\n");
+ printf(" -n, --allnoconfig New config where all options are answered with no\n");
+ printf(" -y, --allyesconfig New config where all options are answered with yes\n");
+ printf(" -m, --allmodconfig New config where all options are answered with mod\n");
+ printf(" -A, --alldefconfig New config with all symbols set to default\n");
+ printf(" -r, --randconfig New config with random answer to all options\n");
+ printf(" -D, --defconfig <file> New config with default defined in <file>\n");
+ printf(" -S, --savedefconfig <file> Save the minimal current configuration to <file>\n");
+ printf(" -l, --listnewconfig List new options\n");
+ printf(" -d, --olddefconfig Same as silentoldconfig but sets new symbols to their default value\n");
+ printf(" --oldnoconfig An alias of olddefconfig\n");
+
+}
+#endif
+
int main(int ac, char **av)
{
+ const char *progname = av[0];
int opt;
- const char *name;
+ const char *name, *defconfig_file = NULL /* gcc uninit */;
struct stat tmpstat;
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- while ((opt = getopt(ac, av, "osdD:nmyrh")) != -1) {
+ tty_stdio = isatty(0) && isatty(1) && isatty(2);
+
+#if 00// !defined __UCLIBC__ || \
+ defined __UCLIBC_HAS_GETOPT_LONG__
+ while ((opt = getopt_long(ac, av, "", long_opts, NULL)) != -1)
+#else
+ char *gch = "asonymArDSld";
+ while ((opt = getopt(ac, av, "asonymArD:S:ldh")) != -1)
+#endif
+ {
+ char *x = memchr(gch, opt, strlen(gch));
+ if (x == NULL)
+ opt = '?';
+ else
+ opt = x - gch;
+ input_mode = (enum input_mode)opt;
switch (opt) {
- case 'o':
- input_mode = ask_new;
- break;
- case 's':
- input_mode = ask_silent;
- valid_stdin = isatty(0) && isatty(1) && isatty(2);
- break;
- case 'd':
- input_mode = set_default;
+ case silentoldconfig:
+ sync_kconfig = 1;
break;
- case 'D':
- input_mode = set_default;
+ case defconfig:
+ case savedefconfig:
defconfig_file = optarg;
break;
- case 'n':
- input_mode = set_no;
- break;
- case 'm':
- input_mode = set_mod;
- break;
- case 'y':
- input_mode = set_yes;
- break;
- case 'r':
- input_mode = set_random;
- srand(time(NULL));
+ case randconfig:
+ {
+ struct timeval now;
+ unsigned int seed;
+ char *seed_env;
+
+ /*
+ * Use microseconds derived seed,
+ * compensate for systems where it may be zero
+ */
+ gettimeofday(&now, NULL);
+ seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1));
+
+ seed_env = getenv("KCONFIG_SEED");
+ if( seed_env && *seed_env ) {
+ char *endp;
+ int tmp = (int)strtol(seed_env, &endp, 0);
+ if (*endp == '\0') {
+ seed = tmp;
+ }
+ }
+ fprintf( stderr, "KCONFIG_SEED=0x%X\n", seed );
+ srand(seed);
break;
- case 'h':
- printf(_("See README for usage info\n"));
- exit(0);
+ }
+ case oldaskconfig:
+ case oldconfig:
+ case allnoconfig:
+ case allyesconfig:
+ case allmodconfig:
+ case alldefconfig:
+ case listnewconfig:
+ case olddefconfig:
break;
- default:
- fprintf(stderr, _("See README for usage info\n"));
+ case '?':
+ conf_usage(progname);
exit(1);
+ break;
}
}
if (ac == optind) {
printf(_("%s: Kconfig file missing\n"), av[0]);
+ conf_usage(progname);
exit(1);
}
name = av[optind];
conf_parse(name);
//zconfdump(stdout);
+ if (sync_kconfig) {
+ name = conf_get_configname();
+ if (stat(name, &tmpstat)) {
+ fprintf(stderr, _("***\n"
+ "*** Configuration file \"%s\" not found!\n"
+ "***\n"
+ "*** Please run some configurator (e.g. \"make oldconfig\" or\n"
+ "*** \"make menuconfig\" or \"make xconfig\").\n"
+ "***\n"), name);
+ exit(1);
+ }
+ }
+
switch (input_mode) {
- case set_default:
+ case defconfig:
if (!defconfig_file)
defconfig_file = conf_get_default_confname();
if (conf_read(defconfig_file)) {
@@ -560,75 +619,136 @@ int main(int ac, char **av)
exit(1);
}
break;
- case ask_silent:
- if (stat(".config", &tmpstat)) {
- printf(_("***\n"
- "*** You have not yet configured!\n"
- "*** (missing .config file)\n"
- "***\n"
- "*** Please run some configurator (e.g. \"make oldconfig\" or\n"
- "*** \"make menuconfig\" or \"make xconfig\").\n"
- "***\n"));
- exit(1);
- }
- case ask_all:
- case ask_new:
+ case savedefconfig:
+ case silentoldconfig:
+ case oldaskconfig:
+ case oldconfig:
+ case listnewconfig:
+ case olddefconfig:
conf_read(NULL);
break;
- case set_no:
- case set_mod:
- case set_yes:
- case set_random:
+ case allnoconfig:
+ case allyesconfig:
+ case allmodconfig:
+ case alldefconfig:
+ case randconfig:
name = getenv("KCONFIG_ALLCONFIG");
- if (name && !stat(name, &tmpstat)) {
- conf_read_simple(name, S_DEF_USER);
+ if (!name)
+ break;
+ if ((strcmp(name, "") != 0) && (strcmp(name, "1") != 0)) {
+ if (conf_read_simple(name, S_DEF_USER)) {
+ fprintf(stderr,
+ _("*** Can't read seed configuration \"%s\"!\n"),
+ name);
+ exit(1);
+ }
break;
}
switch (input_mode) {
- case set_no: name = "allno.config"; break;
- case set_mod: name = "allmod.config"; break;
- case set_yes: name = "allyes.config"; break;
- case set_random: name = "allrandom.config"; break;
+ case allnoconfig: name = "allno.config"; break;
+ case allyesconfig: name = "allyes.config"; break;
+ case allmodconfig: name = "allmod.config"; break;
+ case alldefconfig: name = "alldef.config"; break;
+ case randconfig: name = "allrandom.config"; break;
default: break;
}
- if (!stat(name, &tmpstat))
- conf_read_simple(name, S_DEF_USER);
- else if (!stat("all.config", &tmpstat))
- conf_read_simple("all.config", S_DEF_USER);
+ if (conf_read_simple(name, S_DEF_USER) &&
+ conf_read_simple("all.config", S_DEF_USER)) {
+ fprintf(stderr,
+ _("*** KCONFIG_ALLCONFIG set, but no \"%s\" or \"all.config\" file found\n"),
+ name);
+ exit(1);
+ }
break;
default:
break;
}
- if (input_mode != ask_silent) {
+ if (sync_kconfig) {
+ if (conf_get_changed()) {
+ name = getenv("KCONFIG_NOSILENTUPDATE");
+ if (name && *name) {
+ fprintf(stderr,
+ _("\n*** The configuration requires explicit update.\n\n"));
+ return 1;
+ }
+ }
+ valid_stdin = tty_stdio;
+ }
+
+ switch (input_mode) {
+ case allnoconfig:
+ conf_set_all_new_symbols(def_no);
+ break;
+ case allyesconfig:
+ conf_set_all_new_symbols(def_yes);
+ break;
+ case allmodconfig:
+ conf_set_all_new_symbols(def_mod);
+ break;
+ case alldefconfig:
+ conf_set_all_new_symbols(def_default);
+ break;
+ case randconfig:
+ /* Really nothing to do in this loop */
+ while (conf_set_all_new_symbols(def_random)) ;
+ break;
+ case defconfig:
+ conf_set_all_new_symbols(def_default);
+ break;
+ case savedefconfig:
+ break;
+ case oldaskconfig:
rootEntry = &rootmenu;
conf(&rootmenu);
- if (input_mode == ask_all) {
- input_mode = ask_silent;
- valid_stdin = 1;
+ input_mode = silentoldconfig;
+ /* fall through */
+ case oldconfig:
+ case listnewconfig:
+ case olddefconfig:
+ case silentoldconfig:
+ /* Update until a loop caused no more changes */
+ do {
+ conf_cnt = 0;
+ check_conf(&rootmenu);
+ } while (conf_cnt &&
+ (input_mode != listnewconfig &&
+ input_mode != olddefconfig));
+ break;
+ }
+
+ if (sync_kconfig) {
+ /* silentoldconfig is used during the build so we shall update autoconf.
+ * All other commands are only used to generate a config.
+ */
+ if (conf_get_changed() && conf_write(NULL)) {
+ fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n"));
+ exit(1);
}
- } else if (conf_get_changed()) {
- name = getenv("KCONFIG_NOSILENTUPDATE");
- if (name && *name) {
- fprintf(stderr, _("\n*** configuration requires explicit update.\n\n"));
+ if (conf_write_autoconf()) {
+ fprintf(stderr, _("\n*** Error during update of the configuration.\n\n"));
return 1;
}
- } else
- goto skip_check;
-
- do {
- conf_cnt = 0;
- check_conf(&rootmenu);
- } while (conf_cnt);
- if (conf_write(NULL)) {
- fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n"));
- return 1;
- }
-skip_check:
- if (/*input_mode == ask_silent &&*/ conf_write_autoconf()) {
- fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n"));
- return 1;
+ } else if (input_mode == savedefconfig) {
+ if (conf_write_defconfig(defconfig_file)) {
+ fprintf(stderr, _("n*** Error while saving defconfig to: %s\n\n"),
+ defconfig_file);
+ return 1;
+ }
+ } else if (input_mode != listnewconfig) {
+ if (conf_write(NULL)) {
+ fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n"));
+ exit(1);
+ }
}
-
return 0;
}
+
+/*
+ * Helper function to facilitate fgets() by Jean Sacren.
+ */
+void xfgets(char *str, int size, FILE *in)
+{
+ if (fgets(str, size, in) == NULL)
+ fprintf(stderr, "\nError in reading or end of file.\n");
+}
diff --git a/extra/config/confdata.c b/extra/config/confdata.c
index 59a2fec78..94c63c0e8 100644
--- a/extra/config/confdata.c
+++ b/extra/config/confdata.c
@@ -5,23 +5,27 @@
#include <sys/stat.h>
#include <ctype.h>
+#include <errno.h>
#include <fcntl.h>
+#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
-#define LKC_DIRECT_LINK
#include "lkc.h"
static void conf_warning(const char *fmt, ...)
__attribute__ ((format (printf, 1, 2)));
+static void conf_message(const char *fmt, ...)
+ __attribute__ ((format (printf, 1, 2)));
+
static const char *conf_filename;
static int conf_lineno, conf_warnings, conf_unsaved;
-const char conf_defname[] = "extra/Configs/defconfigs/$ARCH";
+const char conf_defname[] = "arch/$ARCH/defconfig";
static void conf_warning(const char *fmt, ...)
{
@@ -34,6 +38,29 @@ static void conf_warning(const char *fmt, ...)
conf_warnings++;
}
+static void conf_default_message_callback(const char *fmt, va_list ap)
+{
+ printf("#\n# ");
+ vprintf(fmt, ap);
+ printf("\n#\n");
+}
+
+static void (*conf_message_callback) (const char *fmt, va_list ap) =
+ conf_default_message_callback;
+void conf_set_message_callback(void (*fn) (const char *fmt, va_list ap))
+{
+ conf_message_callback = fn;
+}
+
+static void conf_message(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ if (conf_message_callback)
+ conf_message_callback(fmt, ap);
+}
+
const char *conf_get_configname(void)
{
char *name = getenv("KCONFIG_CONFIG");
@@ -41,6 +68,13 @@ const char *conf_get_configname(void)
return name ? name : ".config";
}
+const char *conf_get_autoconfig_name(void)
+{
+ char *name = getenv("KCONFIG_AUTOCONFIG");
+
+ return name ? name : "include/config/auto.conf";
+}
+
static char *conf_expand_value(const char *in)
{
struct symbol *sym;
@@ -94,6 +128,7 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
sym->flags |= def_flags;
break;
}
+ /* fall through */
case S_BOOLEAN:
if (p[0] == 'y') {
sym->def[def].tri = yes;
@@ -106,7 +141,7 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
break;
}
conf_warning("symbol value '%s' invalid for %s", p, sym->name);
- break;
+ return 1;
case S_OTHER:
if (*p != '"') {
for (p2 = p; *p2 && !isspace(*p2); p2++)
@@ -114,6 +149,7 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
sym->type = S_STRING;
goto done;
}
+ /* fall through */
case S_STRING:
if (*p++ != '"')
break;
@@ -128,6 +164,7 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
conf_warning("invalid string found");
return 1;
}
+ /* fall through */
case S_INT:
case S_HEX:
done:
@@ -145,10 +182,66 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
return 0;
}
+#define LINE_GROWTH 16
+static int add_byte(int c, char **lineptr, size_t slen, size_t *n)
+{
+ char *nline;
+ size_t new_size = slen + 1;
+ if (new_size > *n) {
+ new_size += LINE_GROWTH - 1;
+ new_size *= 2;
+ nline = realloc(*lineptr, new_size);
+ if (!nline)
+ return -1;
+
+ *lineptr = nline;
+ *n = new_size;
+ }
+
+ (*lineptr)[slen] = c;
+
+ return 0;
+}
+
+static ssize_t compat_getline(char **lineptr, size_t *n, FILE *stream)
+{
+ char *line = *lineptr;
+ size_t slen = 0;
+
+ for (;;) {
+ int c = getc(stream);
+
+ switch (c) {
+ case '\n':
+ if (add_byte(c, &line, slen, n) < 0)
+ goto e_out;
+ slen++;
+ /* fall through */
+ case EOF:
+ if (add_byte('\0', &line, slen, n) < 0)
+ goto e_out;
+ *lineptr = line;
+ if (slen == 0)
+ return -1;
+ return slen;
+ default:
+ if (add_byte(c, &line, slen, n) < 0)
+ goto e_out;
+ slen++;
+ }
+ }
+
+e_out:
+ line[slen-1] = '\0';
+ *lineptr = line;
+ return -1;
+}
+
int conf_read_simple(const char *name, int def)
{
FILE *in = NULL;
- char line[1024];
+ char *line = NULL;
+ size_t line_asize = 0;
char *p, *p2;
struct symbol *sym;
int i, def_flags;
@@ -163,8 +256,11 @@ int conf_read_simple(const char *name, int def)
if (in)
goto load;
sym_add_change_count(1);
- if (!sym_defconfig_list)
+ if (!sym_defconfig_list) {
+ if (modules_sym)
+ sym_calc_value(modules_sym);
return 1;
+ }
for_all_defaults(sym_defconfig_list, prop) {
if (expr_calc_value(prop->visible.expr) == no ||
@@ -173,9 +269,8 @@ int conf_read_simple(const char *name, int def)
name = conf_expand_value(prop->expr->left.sym->name);
in = zconf_fopen(name);
if (in) {
- printf(_("#\n"
- "# using defaults found in %s\n"
- "#\n"), name);
+ conf_message(_("using defaults found in %s"),
+ name);
goto load;
}
}
@@ -201,33 +296,33 @@ load:
case S_STRING:
if (sym->def[def].val)
free(sym->def[def].val);
+ /* fall through */
default:
sym->def[def].val = NULL;
sym->def[def].tri = no;
}
}
- while (fgets(line, sizeof(line), in)) {
+ while (compat_getline(&line, &line_asize, in) != -1) {
conf_lineno++;
sym = NULL;
- switch (line[0]) {
- case '#':
- if (line[1]!=' ')
+ if (line[0] == '#') {
+ if (memcmp(line + 2, CONFIG_, strlen(CONFIG_)))
continue;
- p = strchr(line + 2, ' ');
+ p = strchr(line + 2 + strlen(CONFIG_), ' ');
if (!p)
continue;
*p++ = 0;
if (strncmp(p, "is not set", 10))
continue;
if (def == S_DEF_USER) {
- sym = sym_find(line + 2);
+ sym = sym_find(line + 2 + strlen(CONFIG_));
if (!sym) {
- conf_warning("trying to assign nonexistent symbol %s", line + 2);
- break;
+ sym_add_change_count(1);
+ goto setsym;
}
} else {
- sym = sym_lookup(line + 2, 0);
+ sym = sym_lookup(line + 2 + strlen(CONFIG_), 0);
if (sym->type == S_UNKNOWN)
sym->type = S_BOOLEAN;
}
@@ -243,9 +338,8 @@ load:
default:
;
}
- break;
- case 'A' ... 'Z':
- p = strchr(line, '=');
+ } else if (memcmp(line, CONFIG_, strlen(CONFIG_)) == 0) {
+ p = strchr(line + strlen(CONFIG_), '=');
if (!p)
continue;
*p++ = 0;
@@ -256,13 +350,13 @@ load:
*p2 = 0;
}
if (def == S_DEF_USER) {
- sym = sym_find(line);
+ sym = sym_find(line + strlen(CONFIG_));
if (!sym) {
- conf_warning("trying to assign nonexistent symbol %s", line);
- break;
+ sym_add_change_count(1);
+ goto setsym;
}
} else {
- sym = sym_lookup(line, 0);
+ sym = sym_lookup(line + strlen(CONFIG_), 0);
if (sym->type == S_UNKNOWN)
sym->type = S_OTHER;
}
@@ -271,14 +365,12 @@ load:
}
if (conf_set_sym_val(sym, def, def_flags, p))
continue;
- break;
- case '\r':
- case '\n':
- break;
- default:
- conf_warning("unexpected data");
+ } else {
+ if (line[0] != '\r' && line[0] != '\n')
+ conf_warning("unexpected data");
continue;
}
+setsym:
if (sym && sym_is_choice_value(sym)) {
struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym));
switch (sym->def[def].tri) {
@@ -299,6 +391,7 @@ load:
cs->def[def].tri = EXPR_OR(cs->def[def].tri, sym->def[def].tri);
}
}
+ free(line);
fclose(in);
if (modules_sym)
@@ -308,10 +401,8 @@ load:
int conf_read(const char *name)
{
- struct symbol *sym, *choice_sym;
- struct property *prop;
- struct expr *e;
- int i, flags;
+ struct symbol *sym;
+ int i;
sym_set_change_count(0);
@@ -321,7 +412,7 @@ int conf_read(const char *name)
for_all_symbols(i, sym) {
sym_calc_value(sym);
if (sym_is_choice(sym) || (sym->flags & SYMBOL_AUTO))
- goto sym_ok;
+ continue;
if (sym_has_value(sym) && (sym->flags & SYMBOL_WRITE)) {
/* check that calculated value agrees with saved value */
switch (sym->type) {
@@ -330,29 +421,18 @@ int conf_read(const char *name)
if (sym->def[S_DEF_USER].tri != sym_get_tristate_value(sym))
break;
if (!sym_is_choice(sym))
- goto sym_ok;
+ continue;
+ /* fall through */
default:
if (!strcmp(sym->curr.val, sym->def[S_DEF_USER].val))
- goto sym_ok;
+ continue;
break;
}
} else if (!sym_has_value(sym) && !(sym->flags & SYMBOL_WRITE))
/* no previous value and not saved */
- goto sym_ok;
+ continue;
conf_unsaved++;
/* maybe print value in verbose mode... */
- sym_ok:
- if (!sym_is_choice(sym))
- continue;
- /* The choice symbol only has a set value (and thus is not new)
- * if all its visible childs have values.
- */
- prop = sym_get_choice_prop(sym);
- flags = sym->flags;
- expr_list_for_each_sym(prop->expr, e, choice_sym)
- if (choice_sym->visible != no)
- flags &= choice_sym->flags;
- sym->flags &= flags | ~SYMBOL_DEF_USER;
}
for_all_symbols(i, sym) {
@@ -385,41 +465,300 @@ int conf_read(const char *name)
return 0;
}
+/*
+ * Kconfig configuration printer
+ *
+ * This printer is used when generating the resulting configuration after
+ * kconfig invocation and `defconfig' files. Unset symbol might be omitted by
+ * passing a non-NULL argument to the printer.
+ *
+ */
+static void
+kconfig_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
+{
+
+ switch (sym->type) {
+ case S_BOOLEAN:
+ case S_TRISTATE:
+ if (*value == 'n') {
+ bool skip_unset = (arg != NULL);
+
+ if (!skip_unset)
+ fprintf(fp, "# %s%s is not set\n",
+ CONFIG_, sym->name);
+ return;
+ }
+ break;
+ default:
+ break;
+ }
+
+ fprintf(fp, "%s%s=%s\n", CONFIG_, sym->name, value);
+}
+
+static void
+kconfig_print_comment(FILE *fp, const char *value, void *arg)
+{
+ const char *p = value;
+ size_t l;
+
+ for (;;) {
+ l = strcspn(p, "\n");
+ fprintf(fp, "#");
+ if (l) {
+ fprintf(fp, " ");
+ xfwrite(p, l, 1, fp);
+ p += l;
+ }
+ fprintf(fp, "\n");
+ if (*p++ == '\0')
+ break;
+ }
+}
+
+static struct conf_printer kconfig_printer_cb =
+{
+ .print_symbol = kconfig_print_symbol,
+ .print_comment = kconfig_print_comment,
+};
+
+/*
+ * Header printer
+ *
+ * This printer is used when generating the `include/generated/autoconf.h' file.
+ */
+static void
+header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
+{
+
+ switch (sym->type) {
+ case S_BOOLEAN:
+ case S_TRISTATE: {
+ const char *suffix = "";
+
+ switch (*value) {
+ case 'n':
+ break;
+ case 'm':
+ suffix = "_MODULE";
+ /* fall through */
+ default:
+ fprintf(fp, "#define %s%s%s 1\n",
+ CONFIG_, sym->name, suffix);
+ }
+ break;
+ }
+ case S_HEX: {
+ const char *prefix = "";
+
+ if (value[0] != '0' || (value[1] != 'x' && value[1] != 'X'))
+ prefix = "0x";
+ fprintf(fp, "#define %s%s %s%s\n",
+ CONFIG_, sym->name, prefix, value);
+ break;
+ }
+ case S_STRING:
+ case S_INT:
+ fprintf(fp, "#define %s%s %s\n",
+ CONFIG_, sym->name, value);
+ break;
+ default:
+ break;
+ }
+
+}
+
+static void
+header_print_comment(FILE *fp, const char *value, void *arg)
+{
+ const char *p = value;
+ size_t l;
+
+ fprintf(fp, "/*\n");
+ for (;;) {
+ l = strcspn(p, "\n");
+ fprintf(fp, " *");
+ if (l) {
+ fprintf(fp, " ");
+ xfwrite(p, l, 1, fp);
+ p += l;
+ }
+ fprintf(fp, "\n");
+ if (*p++ == '\0')
+ break;
+ }
+ fprintf(fp, " */\n");
+}
+
+static struct conf_printer header_printer_cb =
+{
+ .print_symbol = header_print_symbol,
+ .print_comment = header_print_comment,
+};
+
+/*
+ * Tristate printer
+ *
+ * This printer is used when generating the `include/config/tristate.conf' file.
+ */
+static void
+tristate_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
+{
+
+ if (sym->type == S_TRISTATE && *value != 'n')
+ fprintf(fp, "%s%s=%c\n", CONFIG_, sym->name, (char)toupper(*value));
+}
+
+static struct conf_printer tristate_printer_cb =
+{
+ .print_symbol = tristate_print_symbol,
+ .print_comment = kconfig_print_comment,
+};
+
+static void conf_write_symbol(FILE *fp, struct symbol *sym,
+ struct conf_printer *printer, void *printer_arg)
+{
+ const char *str;
+
+ switch (sym->type) {
+ case S_OTHER:
+ case S_UNKNOWN:
+ break;
+ case S_STRING:
+ str = sym_get_string_value(sym);
+ str = sym_escape_string_value(str);
+ printer->print_symbol(fp, sym, str, printer_arg);
+ free((void *)str);
+ break;
+ default:
+ str = sym_get_string_value(sym);
+ printer->print_symbol(fp, sym, str, printer_arg);
+ }
+}
+
+static void
+conf_write_heading(FILE *fp, struct conf_printer *printer, void *printer_arg)
+{
+ char buf[256];
+
+ snprintf(buf, sizeof(buf),
+ "\n"
+ "Automatically generated file; DO NOT EDIT.\n"
+ "%s\n",
+ rootmenu.prompt->text);
+
+ printer->print_comment(fp, buf, printer_arg);
+}
+
+/*
+ * Write out a minimal config.
+ * All values that has default values are skipped as this is redundant.
+ */
+int conf_write_defconfig(const char *filename)
+{
+ struct symbol *sym;
+ struct menu *menu;
+ FILE *out;
+
+ out = fopen(filename, "w");
+ if (!out)
+ return 1;
+
+ sym_clear_all_valid();
+
+ /* Traverse all menus to find all relevant symbols */
+ menu = rootmenu.list;
+
+ while (menu != NULL)
+ {
+ sym = menu->sym;
+ if (sym == NULL) {
+ if (!menu_is_visible(menu))
+ goto next_menu;
+ } else if (!sym_is_choice(sym)) {
+ sym_calc_value(sym);
+ if (!(sym->flags & SYMBOL_WRITE))
+ goto next_menu;
+ sym->flags &= ~SYMBOL_WRITE;
+ /* If we cannot change the symbol - skip */
+ if (!sym_is_changable(sym))
+ goto next_menu;
+ /* If symbol equals to default value - skip */
+ if (strcmp(sym_get_string_value(sym), sym_get_string_default(sym)) == 0)
+ goto next_menu;
+
+ /*
+ * If symbol is a choice value and equals to the
+ * default for a choice - skip.
+ * But only if value is bool and equal to "y" and
+ * choice is not "optional".
+ * (If choice is "optional" then all values can be "n")
+ */
+ if (sym_is_choice_value(sym)) {
+ struct symbol *cs;
+ struct symbol *ds;
+
+ cs = prop_get_symbol(sym_get_choice_prop(sym));
+ ds = sym_choice_default(cs);
+ if (!sym_is_optional(cs) && sym == ds) {
+ if ((sym->type == S_BOOLEAN) &&
+ sym_get_tristate_value(sym) == yes)
+ goto next_menu;
+ }
+ }
+ conf_write_symbol(out, sym, &kconfig_printer_cb, NULL);
+ }
+next_menu:
+ if (menu->list != NULL) {
+ menu = menu->list;
+ }
+ else if (menu->next != NULL) {
+ menu = menu->next;
+ } else {
+ while ((menu = menu->parent)) {
+ if (menu->next != NULL) {
+ menu = menu->next;
+ break;
+ }
+ }
+ }
+ }
+ fclose(out);
+ return 0;
+}
+
int conf_write(const char *name)
{
FILE *out;
struct symbol *sym;
struct menu *menu;
const char *basename;
- char dirname[128], tmpname[128], newname[128];
- int type, l;
const char *str;
- time_t now;
- int use_timestamp = 1;
- char *env;
+ char tmpname[PATH_MAX+1], newname[PATH_MAX+1];
+ char *env, *dirname = NULL;
- dirname[0] = 0;
if (name && name[0]) {
struct stat st;
char *slash;
if (!stat(name, &st) && S_ISDIR(st.st_mode)) {
- strcpy(dirname, name);
+ dirname = strndup(name, strlen(name) + 1);
strcat(dirname, "/");
basename = conf_get_configname();
} else if ((slash = strrchr(name, '/'))) {
int size = slash - name + 1;
- memcpy(dirname, name, size);
- dirname[size] = 0;
+ dirname = strndup(name, size);
if (slash[1])
basename = slash + 1;
else
basename = conf_get_configname();
} else
basename = name;
- } else
- basename = conf_get_configname();
-
+ } else {
+ dirname = strdup(conf_get_configname());
+ basename = strdup(base_name(dirname));
+ dirname = dir_name(dirname);
+ }
sprintf(newname, "%s%s", dirname, basename);
env = getenv("KCONFIG_OVERWRITECONFIG");
if (!env || !*env) {
@@ -429,22 +768,11 @@ int conf_write(const char *name)
*tmpname = 0;
out = fopen(newname, "w");
}
+ free(dirname);
if (!out)
return 1;
- sym = sym_lookup("VERSION", 0);
- sym_calc_value(sym);
- time(&now);
- env = getenv("KCONFIG_NOTIMESTAMP");
- if (env && *env)
- use_timestamp = 0;
-
- fprintf(out, _("#\n"
- "# Automatically generated make config: don't edit\n"
- "%s%s"
- "#\n"),
- use_timestamp ? "# " : "",
- use_timestamp ? ctime(&now) : "");
+ conf_write_heading(out, &kconfig_printer_cb, NULL);
if (!conf_get_changed())
sym_clear_all_valid();
@@ -465,56 +793,11 @@ int conf_write(const char *name)
if (!(sym->flags & SYMBOL_WRITE))
goto next;
sym->flags &= ~SYMBOL_WRITE;
- type = sym->type;
- if (type == S_TRISTATE) {
- sym_calc_value(modules_sym);
- if (modules_sym->curr.tri == no)
- type = S_BOOLEAN;
- }
- switch (type) {
- case S_BOOLEAN:
- case S_TRISTATE:
- switch (sym_get_tristate_value(sym)) {
- case no:
- fprintf(out, "# %s is not set\n", sym->name);
- break;
- case mod:
- fprintf(out, "%s=m\n", sym->name);
- break;
- case yes:
- fprintf(out, "%s=y\n", sym->name);
- break;
- }
- break;
- case S_STRING:
- str = sym_get_string_value(sym);
- fprintf(out, "%s=\"", sym->name);
- while (1) {
- l = strcspn(str, "\"\\");
- if (l) {
- fwrite(str, l, 1, out);
- str += l;
- }
- if (!*str)
- break;
- fprintf(out, "\\%c", *str++);
- }
- fputs("\"\n", out);
- break;
- case S_HEX:
- str = sym_get_string_value(sym);
- if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) {
- fprintf(out, "%s=%s\n", sym->name, str);
- break;
- }
- case S_INT:
- str = sym_get_string_value(sym);
- fprintf(out, "%s=%s\n", sym->name, str);
- break;
- }
+
+ conf_write_symbol(out, sym, &kconfig_printer_cb, NULL);
}
- next:
+next:
if (menu->list) {
menu = menu->list;
continue;
@@ -531,36 +814,40 @@ int conf_write(const char *name)
fclose(out);
if (*tmpname) {
- strcat(dirname, basename);
+ dirname = malloc(strlen(basename) + 4 + 1);
+ strcpy(dirname, basename);
strcat(dirname, ".old");
rename(newname, dirname);
+ free(dirname);
if (rename(tmpname, newname))
return 1;
}
- printf(_("#\n"
- "# configuration written to %s\n"
- "#\n"), newname);
+ conf_message(_("configuration written to %s"), newname);
sym_set_change_count(0);
return 0;
}
-int conf_split_config(void)
+static int conf_split_config(void)
{
- char *name, path[128];
+ const char *name;
+ char path[PATH_MAX+1], opwd[PATH_MAX+1];
char *s, *d, c;
struct symbol *sym;
struct stat sb;
int res, i, fd;
- name = getenv("KCONFIG_AUTOCONFIG");
- if (!name)
- name = "include/config/auto.conf";
+ if (getcwd(opwd, sizeof(opwd)) == NULL)
+ return 1;
+ name = conf_get_autoconfig_name();
conf_read_simple(name, S_DEF_AUTO);
- if (chdir("include/config"))
+ strcpy(path, name);
+ dir_name(path);
+
+ if (chdir(path))
return 1;
res = 0;
@@ -654,7 +941,7 @@ int conf_split_config(void)
close(fd);
}
out:
- if (chdir("../.."))
+ if (chdir(opwd))
return 1;
return res;
@@ -663,117 +950,82 @@ out:
int conf_write_autoconf(void)
{
struct symbol *sym;
- const char *str;
- char *name;
- FILE *out, *out_h;
- time_t now;
- int i, l;
-
- return 0;
+ const char *name;
+ char cfg_fname[PATH_MAX+1], tristate_fname[PATH_MAX+1],
+ cfgh_fname[PATH_MAX+1];
+ char *dirname;
+ FILE *out, *tristate, *out_h;
+ int i;
sym_clear_all_valid();
- file_write_dep("include/config/auto.conf.cmd");
+ sprintf(cfg_fname, "%s.cmd", conf_get_autoconfig_name());
+ file_write_dep(cfg_fname);
if (conf_split_config())
return 1;
- out = fopen(".tmpconfig", "w");
+ dirname = dir_name(strdup(conf_get_configname()));
+ sprintf(cfg_fname, "%s.tmpconfig", dirname);
+ sprintf(tristate_fname, "%s.tmpconfig_tristate", dirname);
+ sprintf(cfgh_fname, "%s.tmpconfig.h", dirname);
+ free(dirname);
+
+ out = fopen(cfg_fname, "w");
if (!out)
return 1;
- out_h = fopen(".tmpconfig.h", "w");
+ tristate = fopen(tristate_fname, "w");
+ if (!tristate) {
+ fclose(out);
+ return 1;
+ }
+
+ out_h = fopen(cfgh_fname, "w");
if (!out_h) {
fclose(out);
+ fclose(tristate);
return 1;
}
- sym = sym_lookup("VERSION", 0);
- sym_calc_value(sym);
- time(&now);
- fprintf(out, "#\n"
- "# Automatically generated make config: don't edit\n"
- "# %s"
- "#\n",
- ctime(&now));
- fprintf(out_h, "/*\n"
- " * Automatically generated C config: don't edit\n"
- " * %s"
- " */\n",
- ctime(&now));
+ conf_write_heading(out, &kconfig_printer_cb, NULL);
+
+ conf_write_heading(tristate, &tristate_printer_cb, NULL);
+
+ conf_write_heading(out_h, &header_printer_cb, NULL);
for_all_symbols(i, sym) {
sym_calc_value(sym);
if (!(sym->flags & SYMBOL_WRITE) || !sym->name)
continue;
- switch (sym->type) {
- case S_BOOLEAN:
- case S_TRISTATE:
- switch (sym_get_tristate_value(sym)) {
- case no:
- break;
- case mod:
- fprintf(out, "%s=m\n", sym->name);
- fprintf(out_h, "#define %s_MODULE 1\n", sym->name);
- break;
- case yes:
- fprintf(out, "%s=y\n", sym->name);
- fprintf(out_h, "#define %s 1\n", sym->name);
- break;
- }
- break;
- case S_STRING:
- str = sym_get_string_value(sym);
- fprintf(out, "%s=\"", sym->name);
- fprintf(out_h, "#define %s \"", sym->name);
- while (1) {
- l = strcspn(str, "\"\\");
- if (l) {
- fwrite(str, l, 1, out);
- fwrite(str, l, 1, out_h);
- str += l;
- }
- if (!*str)
- break;
- fprintf(out, "\\%c", *str);
- fprintf(out_h, "\\%c", *str);
- str++;
- }
- fputs("\"\n", out);
- fputs("\"\n", out_h);
- break;
- case S_HEX:
- str = sym_get_string_value(sym);
- if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) {
- fprintf(out, "%s=%s\n", sym->name, str);
- fprintf(out_h, "#define %s 0x%s\n", sym->name, str);
- break;
- }
- case S_INT:
- str = sym_get_string_value(sym);
- fprintf(out, "%s=%s\n", sym->name, str);
- fprintf(out_h, "#define %s %s\n", sym->name, str);
- break;
- default:
- break;
- }
+
+ /* write symbol to auto.conf, tristate and header files */
+ conf_write_symbol(out, sym, &kconfig_printer_cb, (void *)1);
+
+ conf_write_symbol(tristate, sym, &tristate_printer_cb, (void *)1);
+
+ conf_write_symbol(out_h, sym, &header_printer_cb, NULL);
}
fclose(out);
+ fclose(tristate);
fclose(out_h);
name = getenv("KCONFIG_AUTOHEADER");
if (!name)
- name = "include/linux/autoconf.h";
- if (rename(".tmpconfig.h", name))
+ name = "include/generated/autoconf.h";
+ if (rename(cfgh_fname, name))
return 1;
- name = getenv("KCONFIG_AUTOCONFIG");
+ name = getenv("KCONFIG_TRISTATE");
if (!name)
- name = "include/config/auto.conf";
+ name = "include/config/tristate.conf";
+ if (rename(tristate_fname, name))
+ return 1;
+ name = conf_get_autoconfig_name();
/*
* This must be the last step, kbuild has a dependency on auto.conf
* and this marks the successful completion of the previous steps.
*/
- if (rename(".tmpconfig", name))
+ if (rename(cfg_fname, name))
return 1;
return 0;
@@ -805,3 +1057,196 @@ void conf_set_changed_callback(void (*fn)(void))
{
conf_changed_callback = fn;
}
+
+static bool randomize_choice_values(struct symbol *csym)
+{
+ struct property *prop;
+ struct symbol *sym;
+ struct expr *e;
+ int cnt, def;
+
+ /*
+ * If choice is mod then we may have more items selected
+ * and if no then no-one.
+ * In both cases stop.
+ */
+ if (csym->curr.tri != yes)
+ return false;
+
+ prop = sym_get_choice_prop(csym);
+
+ /* count entries in choice block */
+ cnt = 0;
+ expr_list_for_each_sym(prop->expr, e, sym)
+ cnt++;
+
+ /*
+ * find a random value and set it to yes,
+ * set the rest to no so we have only one set
+ */
+ def = (rand() % cnt);
+
+ cnt = 0;
+ expr_list_for_each_sym(prop->expr, e, sym) {
+ if (def == cnt++) {
+ sym->def[S_DEF_USER].tri = yes;
+ csym->def[S_DEF_USER].val = sym;
+ }
+ else {
+ sym->def[S_DEF_USER].tri = no;
+ }
+ sym->flags |= SYMBOL_DEF_USER;
+ /* clear VALID to get value calculated */
+ sym->flags &= ~SYMBOL_VALID;
+ }
+ csym->flags |= SYMBOL_DEF_USER;
+ /* clear VALID to get value calculated */
+ csym->flags &= ~(SYMBOL_VALID);
+
+ return true;
+}
+
+void set_all_choice_values(struct symbol *csym)
+{
+ struct property *prop;
+ struct symbol *sym;
+ struct expr *e;
+
+ prop = sym_get_choice_prop(csym);
+
+ /*
+ * Set all non-assinged choice values to no
+ */
+ expr_list_for_each_sym(prop->expr, e, sym) {
+ if (!sym_has_value(sym))
+ sym->def[S_DEF_USER].tri = no;
+ }
+ csym->flags |= SYMBOL_DEF_USER;
+ /* clear VALID to get value calculated */
+ csym->flags &= ~(SYMBOL_VALID | SYMBOL_NEED_SET_CHOICE_VALUES);
+}
+
+bool conf_set_all_new_symbols(enum conf_def_mode mode)
+{
+ struct symbol *sym, *csym;
+ int i, cnt, pby, pty, ptm; /* pby: probability of boolean = y
+ * pty: probability of tristate = y
+ * ptm: probability of tristate = m
+ */
+
+ pby = 50; pty = ptm = 33; /* can't go as the default in switch-case
+ * below, otherwise gcc whines about
+ * -Wmaybe-uninitialized */
+ if (mode == def_random) {
+ int n, p[3];
+ char *env = getenv("KCONFIG_PROBABILITY");
+ n = 0;
+ while( env && *env ) {
+ char *endp;
+ int tmp = strtol( env, &endp, 10 );
+ if( tmp >= 0 && tmp <= 100 ) {
+ p[n++] = tmp;
+ } else {
+ errno = ERANGE;
+ perror( "KCONFIG_PROBABILITY" );
+ exit( 1 );
+ }
+ env = (*endp == ':') ? endp+1 : endp;
+ if( n >=3 ) {
+ break;
+ }
+ }
+ switch( n ) {
+ case 1:
+ pby = p[0]; ptm = pby/2; pty = pby-ptm;
+ break;
+ case 2:
+ pty = p[0]; ptm = p[1]; pby = pty + ptm;
+ break;
+ case 3:
+ pby = p[0]; pty = p[1]; ptm = p[2];
+ break;
+ }
+
+ if( pty+ptm > 100 ) {
+ errno = ERANGE;
+ perror( "KCONFIG_PROBABILITY" );
+ exit( 1 );
+ }
+ }
+ bool has_changed = false;
+
+ for_all_symbols(i, sym) {
+ if (sym_has_value(sym) || (sym->flags & SYMBOL_VALID))
+ continue;
+ switch (sym_get_type(sym)) {
+ case S_BOOLEAN:
+ case S_TRISTATE:
+ has_changed = true;
+ switch (mode) {
+ case def_yes:
+ sym->def[S_DEF_USER].tri = yes;
+ break;
+ case def_mod:
+ sym->def[S_DEF_USER].tri = mod;
+ break;
+ case def_no:
+ sym->def[S_DEF_USER].tri = no;
+ break;
+ case def_random:
+ sym->def[S_DEF_USER].tri = no;
+ cnt = rand() % 100;
+ if (sym->type == S_TRISTATE) {
+ if (cnt < pty)
+ sym->def[S_DEF_USER].tri = yes;
+ else if (cnt < (pty+ptm))
+ sym->def[S_DEF_USER].tri = mod;
+ } else if (cnt < pby)
+ sym->def[S_DEF_USER].tri = yes;
+ break;
+ default:
+ continue;
+ }
+ if (!(sym_is_choice(sym) && mode == def_random))
+ sym->flags |= SYMBOL_DEF_USER;
+ break;
+ default:
+ break;
+ }
+
+ }
+
+ sym_clear_all_valid();
+
+ /*
+ * We have different type of choice blocks.
+ * If curr.tri equals to mod then we can select several
+ * choice symbols in one block.
+ * In this case we do nothing.
+ * If curr.tri equals yes then only one symbol can be
+ * selected in a choice block and we set it to yes,
+ * and the rest to no.
+ */
+ if (mode != def_random) {
+ for_all_symbols(i, csym) {
+ if ((sym_is_choice(csym) && !sym_has_value(csym)) ||
+ sym_is_choice_value(csym))
+ csym->flags |= SYMBOL_NEED_SET_CHOICE_VALUES;
+ }
+ }
+
+ for_all_symbols(i, csym) {
+ if (sym_has_value(csym) || !sym_is_choice(csym))
+ continue;
+
+ sym_calc_value(csym);
+ if (mode == def_random)
+ has_changed = randomize_choice_values(csym);
+ else {
+ set_all_choice_values(csym);
+ has_changed = true;
+ }
+ }
+
+ return has_changed;
+}
diff --git a/extra/config/expr.c b/extra/config/expr.c
index 579ece4fa..d6626521f 100644
--- a/extra/config/expr.c
+++ b/extra/config/expr.c
@@ -7,15 +7,13 @@
#include <stdlib.h>
#include <string.h>
-#define LKC_DIRECT_LINK
#include "lkc.h"
#define DEBUG_EXPR 0
struct expr *expr_alloc_symbol(struct symbol *sym)
{
- struct expr *e = malloc(sizeof(*e));
- memset(e, 0, sizeof(*e));
+ struct expr *e = xcalloc(1, sizeof(*e));
e->type = E_SYMBOL;
e->left.sym = sym;
return e;
@@ -23,8 +21,7 @@ struct expr *expr_alloc_symbol(struct symbol *sym)
struct expr *expr_alloc_one(enum expr_type type, struct expr *ce)
{
- struct expr *e = malloc(sizeof(*e));
- memset(e, 0, sizeof(*e));
+ struct expr *e = xcalloc(1, sizeof(*e));
e->type = type;
e->left.expr = ce;
return e;
@@ -32,8 +29,7 @@ struct expr *expr_alloc_one(enum expr_type type, struct expr *ce)
struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2)
{
- struct expr *e = malloc(sizeof(*e));
- memset(e, 0, sizeof(*e));
+ struct expr *e = xcalloc(1, sizeof(*e));
e->type = type;
e->left.expr = e1;
e->right.expr = e2;
@@ -42,8 +38,7 @@ struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e
struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2)
{
- struct expr *e = malloc(sizeof(*e));
- memset(e, 0, sizeof(*e));
+ struct expr *e = xcalloc(1, sizeof(*e));
e->type = type;
e->left.sym = s1;
e->right.sym = s2;
@@ -64,14 +59,14 @@ struct expr *expr_alloc_or(struct expr *e1, struct expr *e2)
return e2 ? expr_alloc_two(E_OR, e1, e2) : e1;
}
-struct expr *expr_copy(struct expr *org)
+struct expr *expr_copy(const struct expr *org)
{
struct expr *e;
if (!org)
return NULL;
- e = malloc(sizeof(*org));
+ e = xmalloc(sizeof(*org));
memcpy(e, org, sizeof(*org));
switch (org->type) {
case E_SYMBOL:
@@ -348,7 +343,7 @@ struct expr *expr_trans_bool(struct expr *e)
/*
* e1 || e2 -> ?
*/
-struct expr *expr_join_or(struct expr *e1, struct expr *e2)
+static struct expr *expr_join_or(struct expr *e1, struct expr *e2)
{
struct expr *tmp;
struct symbol *sym1, *sym2;
@@ -412,7 +407,7 @@ struct expr *expr_join_or(struct expr *e1, struct expr *e2)
return NULL;
}
-struct expr *expr_join_and(struct expr *e1, struct expr *e2)
+static struct expr *expr_join_and(struct expr *e1, struct expr *e2)
{
struct expr *tmp;
struct symbol *sym1, *sym2;
@@ -1013,6 +1008,48 @@ int expr_compare_type(enum expr_type t1, enum expr_type t2)
#endif
}
+static inline struct expr *
+expr_get_leftmost_symbol(const struct expr *e)
+{
+
+ if (e == NULL)
+ return NULL;
+
+ while (e->type != E_SYMBOL)
+ e = e->left.expr;
+
+ return expr_copy(e);
+}
+
+/*
+ * Given expression `e1' and `e2', returns the leaf of the longest
+ * sub-expression of `e1' not containing 'e2.
+ */
+struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2)
+{
+ struct expr *ret;
+
+ switch (e1->type) {
+ case E_OR:
+ return expr_alloc_and(
+ expr_simplify_unmet_dep(e1->left.expr, e2),
+ expr_simplify_unmet_dep(e1->right.expr, e2));
+ case E_AND: {
+ struct expr *e;
+ e = expr_alloc_and(expr_copy(e1), expr_copy(e2));
+ e = expr_eliminate_dups(e);
+ ret = (!expr_eq(e, e1)) ? e1 : NULL;
+ expr_free(e);
+ break;
+ }
+ default:
+ ret = e1;
+ break;
+ }
+
+ return expr_get_leftmost_symbol(ret);
+}
+
void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken)
{
if (!e) {
@@ -1087,7 +1124,7 @@ void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *
static void expr_print_file_helper(void *data, struct symbol *sym, const char *str)
{
- fwrite(str, strlen(str), 1, data);
+ xfwrite(str, strlen(str), 1, data);
}
void expr_fprint(struct expr *e, FILE *out)
@@ -1097,7 +1134,32 @@ void expr_fprint(struct expr *e, FILE *out)
static void expr_print_gstr_helper(void *data, struct symbol *sym, const char *str)
{
- str_append((struct gstr*)data, str);
+ struct gstr *gs = (struct gstr*)data;
+ const char *sym_str = NULL;
+
+ if (sym)
+ sym_str = sym_get_string_value(sym);
+
+ if (gs->max_width) {
+ unsigned extra_length = strlen(str);
+ const char *last_cr = strrchr(gs->s, '\n');
+ unsigned last_line_length;
+
+ if (sym_str)
+ extra_length += 4 + strlen(sym_str);
+
+ if (!last_cr)
+ last_cr = gs->s;
+
+ last_line_length = strlen(gs->s) - (last_cr - gs->s);
+
+ if ((last_line_length + extra_length) > gs->max_width)
+ str_append(gs, "\\\n");
+ }
+
+ str_append(gs, str);
+ if (sym && sym->type != S_UNKNOWN)
+ str_printf(gs, " [=%s]", sym_str);
}
void expr_gstr_print(struct expr *e, struct gstr *gs)
diff --git a/extra/config/expr.h b/extra/config/expr.h
index 9d60dd330..df198a5f4 100644
--- a/extra/config/expr.h
+++ b/extra/config/expr.h
@@ -10,7 +10,9 @@
extern "C" {
#endif
+#include <assert.h>
#include <stdio.h>
+#include "list.h"
#ifndef __cplusplus
#include <stdbool.h>
#endif
@@ -18,14 +20,10 @@ extern "C" {
struct file {
struct file *next;
struct file *parent;
- char *name;
+ const char *name;
int lineno;
- int flags;
};
-#define FILE_BUSY 0x0001
-#define FILE_SCANNED 0x0002
-
typedef enum tristate {
no, mod, yes
} tristate;
@@ -65,9 +63,13 @@ enum symbol_type {
S_UNKNOWN, S_BOOLEAN, S_TRISTATE, S_INT, S_HEX, S_STRING, S_OTHER
};
+/* enum values are used as index to symbol.def[] */
enum {
S_DEF_USER, /* main user value */
- S_DEF_AUTO,
+ S_DEF_AUTO, /* values read from auto.conf */
+ S_DEF_DEF3, /* Reserved for UI usage */
+ S_DEF_DEF4, /* Reserved for UI usage */
+ S_DEF_COUNT
};
struct symbol {
@@ -75,51 +77,77 @@ struct symbol {
char *name;
enum symbol_type type;
struct symbol_value curr;
- struct symbol_value def[4];
+ struct symbol_value def[S_DEF_COUNT];
tristate visible;
int flags;
struct property *prop;
+ struct expr_value dir_dep;
struct expr_value rev_dep;
};
-#define for_all_symbols(i, sym) for (i = 0; i < 257; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER)
-
-#define SYMBOL_CONST 0x0001
-#define SYMBOL_CHECK 0x0008
-#define SYMBOL_CHOICE 0x0010
-#define SYMBOL_CHOICEVAL 0x0020
-#define SYMBOL_VALID 0x0080
-#define SYMBOL_OPTIONAL 0x0100
-#define SYMBOL_WRITE 0x0200
-#define SYMBOL_CHANGED 0x0400
-#define SYMBOL_AUTO 0x1000
-#define SYMBOL_CHECKED 0x2000
-#define SYMBOL_WARNED 0x8000
-#define SYMBOL_DEF 0x10000
-#define SYMBOL_DEF_USER 0x10000
-#define SYMBOL_DEF_AUTO 0x20000
-#define SYMBOL_DEF3 0x40000
-#define SYMBOL_DEF4 0x80000
+#define for_all_symbols(i, sym) for (i = 0; i < SYMBOL_HASHSIZE; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER)
+
+#define SYMBOL_CONST 0x0001 /* symbol is const */
+#define SYMBOL_CHECK 0x0008 /* used during dependency checking */
+#define SYMBOL_CHOICE 0x0010 /* start of a choice block (null name) */
+#define SYMBOL_CHOICEVAL 0x0020 /* used as a value in a choice block */
+#define SYMBOL_VALID 0x0080 /* set when symbol.curr is calculated */
+#define SYMBOL_OPTIONAL 0x0100 /* choice is optional - values can be 'n' */
+#define SYMBOL_WRITE 0x0200 /* ? */
+#define SYMBOL_CHANGED 0x0400 /* ? */
+#define SYMBOL_AUTO 0x1000 /* value from environment variable */
+#define SYMBOL_CHECKED 0x2000 /* used during dependency checking */
+#define SYMBOL_WARNED 0x8000 /* warning has been issued */
+
+/* Set when symbol.def[] is used */
+#define SYMBOL_DEF 0x10000 /* First bit of SYMBOL_DEF */
+#define SYMBOL_DEF_USER 0x10000 /* symbol.def[S_DEF_USER] is valid */
+#define SYMBOL_DEF_AUTO 0x20000 /* symbol.def[S_DEF_AUTO] is valid */
+#define SYMBOL_DEF3 0x40000 /* symbol.def[S_DEF_3] is valid */
+#define SYMBOL_DEF4 0x80000 /* symbol.def[S_DEF_4] is valid */
+
+/* choice values need to be set before calculating this symbol value */
+#define SYMBOL_NEED_SET_CHOICE_VALUES 0x100000
#define SYMBOL_MAXLENGTH 256
-#define SYMBOL_HASHSIZE 257
-#define SYMBOL_HASHMASK 0xff
-
+#define SYMBOL_HASHSIZE 9973
+
+/* A property represent the config options that can be associated
+ * with a config "symbol".
+ * Sample:
+ * config FOO
+ * default y
+ * prompt "foo prompt"
+ * select BAR
+ * config BAZ
+ * int "BAZ Value"
+ * range 1..255
+ */
enum prop_type {
- P_UNKNOWN, P_PROMPT, P_COMMENT, P_MENU, P_DEFAULT, P_CHOICE,
- P_SELECT, P_RANGE, P_ENV
+ P_UNKNOWN,
+ P_PROMPT, /* prompt "foo prompt" or "BAZ Value" */
+ P_COMMENT, /* text associated with a comment */
+ P_MENU, /* prompt associated with a menuconfig option */
+ P_DEFAULT, /* default y */
+ P_CHOICE, /* choice value */
+ P_SELECT, /* select BAR */
+ P_RANGE, /* range 7..100 (for a symbol) */
+ P_ENV, /* value from environment variable */
+ P_SYMBOL, /* where a symbol is defined */
};
struct property {
- struct property *next;
- struct symbol *sym;
- enum prop_type type;
- const char *text;
+ struct property *next; /* next property - null if last */
+ struct symbol *sym; /* the symbol for which the property is associated */
+ enum prop_type type; /* type of property */
+ const char *text; /* the prompt value - P_PROMPT, P_MENU, P_COMMENT */
struct expr_value visible;
- struct expr *expr;
- struct menu *menu;
- struct file *file;
- int lineno;
+ struct expr *expr; /* the optional conditional part of the property */
+ struct menu *menu; /* the menu the property are associated with
+ * valid for: P_SELECT, P_RANGE, P_CHOICE,
+ * P_PROMPT, P_DEFAULT, P_MENU, P_COMMENT */
+ struct file *file; /* what file was this property defined */
+ int lineno; /* what lineno was this property defined */
};
#define for_all_properties(sym, st, tok) \
@@ -137,6 +165,7 @@ struct menu {
struct menu *list;
struct symbol *sym;
struct property *prompt;
+ struct expr *visibility;
struct expr *dep;
unsigned int flags;
char *help;
@@ -148,7 +177,14 @@ struct menu {
#define MENU_CHANGED 0x0001
#define MENU_ROOT 0x0002
-#ifndef SWIG
+struct jump_key {
+ struct list_head entries;
+ size_t offset;
+ struct menu *target;
+ int index;
+};
+
+#define JUMP_NB 9
extern struct file *file_list;
extern struct file *current_file;
@@ -164,7 +200,7 @@ struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e
struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2);
struct expr *expr_alloc_and(struct expr *e1, struct expr *e2);
struct expr *expr_alloc_or(struct expr *e1, struct expr *e2);
-struct expr *expr_copy(struct expr *org);
+struct expr *expr_copy(const struct expr *org);
void expr_free(struct expr *e);
int expr_eq(struct expr *e1, struct expr *e2);
void expr_eliminate_eq(struct expr **ep1, struct expr **ep2);
@@ -179,21 +215,21 @@ struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2);
struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2);
void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2);
struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym);
+struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2);
void expr_fprint(struct expr *e, FILE *out);
struct gstr; /* forward */
void expr_gstr_print(struct expr *e, struct gstr *gs);
-static __inline__ int expr_is_yes(struct expr *e)
+static inline int expr_is_yes(struct expr *e)
{
return !e || (e->type == E_SYMBOL && e->left.sym == &symbol_yes);
}
-static __inline__ int expr_is_no(struct expr *e)
+static inline int expr_is_no(struct expr *e)
{
return e && (e->type == E_SYMBOL && e->left.sym == &symbol_no);
}
-#endif
#ifdef __cplusplus
}
diff --git a/extra/config/gconf.c b/extra/config/gconf.c
index 540a0ff98..f2bee70e2 100644
--- a/extra/config/gconf.c
+++ b/extra/config/gconf.c
@@ -10,6 +10,7 @@
# include <config.h>
#endif
+#include <stdlib.h>
#include "lkc.h"
#include "images.c"
@@ -22,7 +23,6 @@
#include <string.h>
#include <unistd.h>
#include <time.h>
-#include <stdlib.h>
//#define DEBUG
@@ -30,13 +30,16 @@ enum {
SINGLE_VIEW, SPLIT_VIEW, FULL_VIEW
};
+enum {
+ OPT_NORMAL, OPT_ALL, OPT_PROMPT
+};
+
static gint view_mode = FULL_VIEW;
static gboolean show_name = TRUE;
static gboolean show_range = TRUE;
static gboolean show_value = TRUE;
-static gboolean show_all = FALSE;
-static gboolean show_debug = FALSE;
static gboolean resizeable = FALSE;
+static int opt_mode = OPT_NORMAL;
GtkWidget *main_wnd = NULL;
GtkWidget *tree1_w = NULL; // left frame
@@ -76,36 +79,7 @@ static void conf_changed(void);
/* Helping/Debugging Functions */
-
-const char *dbg_print_stype(int val)
-{
- static char buf[256];
-
- bzero(buf, 256);
-
- if (val == S_UNKNOWN)
- strcpy(buf, "unknown");
- if (val == S_BOOLEAN)
- strcpy(buf, "boolean");
- if (val == S_TRISTATE)
- strcpy(buf, "tristate");
- if (val == S_INT)
- strcpy(buf, "int");
- if (val == S_HEX)
- strcpy(buf, "hex");
- if (val == S_STRING)
- strcpy(buf, "string");
- if (val == S_OTHER)
- strcpy(buf, "other");
-
-#ifdef DEBUG
- printf("%s", buf);
-#endif
-
- return buf;
-}
-
-const char *dbg_print_flags(int val)
+const char *dbg_sym_flags(int val)
{
static char buf[256];
@@ -131,40 +105,10 @@ const char *dbg_print_flags(int val)
strcat(buf, "auto/");
buf[strlen(buf) - 1] = '\0';
-#ifdef DEBUG
- printf("%s", buf);
-#endif
return buf;
}
-const char *dbg_print_ptype(int val)
-{
- static char buf[256];
-
- bzero(buf, 256);
-
- if (val == P_UNKNOWN)
- strcpy(buf, "unknown");
- if (val == P_PROMPT)
- strcpy(buf, "prompt");
- if (val == P_COMMENT)
- strcpy(buf, "comment");
- if (val == P_MENU)
- strcpy(buf, "menu");
- if (val == P_DEFAULT)
- strcpy(buf, "default");
- if (val == P_CHOICE)
- strcpy(buf, "choice");
-
-#ifdef DEBUG
- printf("%s", buf);
-#endif
-
- return buf;
-}
-
-
void replace_button_icon(GladeXML * xml, GdkDrawable * window,
GtkStyle * style, gchar * btn_name, gchar ** xpm)
{
@@ -189,7 +133,6 @@ void init_main_window(const gchar * glade_file)
GladeXML *xml;
GtkWidget *widget;
GtkTextBuffer *txtbuf;
- char title[256];
GtkStyle *style;
xml = glade_xml_new(glade_file, "window1", NULL);
@@ -266,9 +209,7 @@ void init_main_window(const gchar * glade_file)
/*"style", PANGO_STYLE_OBLIQUE, */
NULL);
- sprintf(title, _("uClibc v%s Configuration"),
- getenv("VERSION"));
- gtk_window_set_title(GTK_WINDOW(main_wnd), title);
+ gtk_window_set_title(GTK_WINDOW(main_wnd), rootmenu.prompt->text);
gtk_widget_show(main_wnd);
}
@@ -312,7 +253,7 @@ void init_left_tree(void)
gtk_tree_view_set_model(view, model1);
gtk_tree_view_set_headers_visible(view, TRUE);
- gtk_tree_view_set_rules_hint(view, FALSE);
+ gtk_tree_view_set_rules_hint(view, TRUE);
column = gtk_tree_view_column_new();
gtk_tree_view_append_column(view, column);
@@ -344,8 +285,6 @@ void init_left_tree(void)
static void renderer_edited(GtkCellRendererText * cell,
const gchar * path_string,
const gchar * new_text, gpointer user_data);
-static void renderer_toggled(GtkCellRendererToggle * cellrenderertoggle,
- gchar * arg1, gpointer user_data);
void init_right_tree(void)
{
@@ -357,7 +296,7 @@ void init_right_tree(void)
gtk_tree_view_set_model(view, model2);
gtk_tree_view_set_headers_visible(view, TRUE);
- gtk_tree_view_set_rules_hint(view, FALSE);
+ gtk_tree_view_set_rules_hint(view, TRUE);
column = gtk_tree_view_column_new();
gtk_tree_view_append_column(view, column);
@@ -379,8 +318,6 @@ void init_right_tree(void)
"inconsistent", COL_BTNINC,
"visible", COL_BTNVIS,
"radio", COL_BTNRAD, NULL);
- /*g_signal_connect(G_OBJECT(renderer), "toggled",
- G_CALLBACK(renderer_toggled), NULL); */
renderer = gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
renderer, FALSE);
@@ -456,19 +393,9 @@ static void text_insert_help(struct menu *menu)
GtkTextBuffer *buffer;
GtkTextIter start, end;
const char *prompt = _(menu_get_prompt(menu));
- gchar *name;
- const char *help;
-
- help = menu_get_help(menu);
-
- /* Gettextize if the help text not empty */
- if ((help != 0) && (help[0] != 0))
- help = _(help);
+ struct gstr help = str_new();
- if (menu->sym && menu->sym->name)
- name = g_strdup_printf(menu->sym->name);
- else
- name = g_strdup("");
+ menu_get_ext_help(menu, &help);
buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w));
gtk_text_buffer_get_bounds(buffer, &start, &end);
@@ -478,14 +405,11 @@ static void text_insert_help(struct menu *menu)
gtk_text_buffer_get_end_iter(buffer, &end);
gtk_text_buffer_insert_with_tags(buffer, &end, prompt, -1, tag1,
NULL);
- gtk_text_buffer_insert_at_cursor(buffer, " ", 1);
- gtk_text_buffer_get_end_iter(buffer, &end);
- gtk_text_buffer_insert_with_tags(buffer, &end, name, -1, tag1,
- NULL);
gtk_text_buffer_insert_at_cursor(buffer, "\n\n", 2);
gtk_text_buffer_get_end_iter(buffer, &end);
- gtk_text_buffer_insert_with_tags(buffer, &end, help, -1, tag2,
+ gtk_text_buffer_insert_with_tags(buffer, &end, str_get(&help), -1, tag2,
NULL);
+ str_free(&help);
}
@@ -710,20 +634,29 @@ void on_show_data1_activate(GtkMenuItem * menuitem, gpointer user_data)
void
-on_show_all_options1_activate(GtkMenuItem * menuitem, gpointer user_data)
+on_set_option_mode1_activate(GtkMenuItem *menuitem, gpointer user_data)
{
- show_all = GTK_CHECK_MENU_ITEM(menuitem)->active;
+ opt_mode = OPT_NORMAL;
+ gtk_tree_store_clear(tree2);
+ display_tree(&rootmenu); /* instead of update_tree to speed-up */
+}
+
+void
+on_set_option_mode2_activate(GtkMenuItem *menuitem, gpointer user_data)
+{
+ opt_mode = OPT_ALL;
gtk_tree_store_clear(tree2);
- display_tree(&rootmenu); // instead of update_tree to speed-up
+ display_tree(&rootmenu); /* instead of update_tree to speed-up */
}
void
-on_show_debug_info1_activate(GtkMenuItem * menuitem, gpointer user_data)
+on_set_option_mode3_activate(GtkMenuItem *menuitem, gpointer user_data)
{
- show_debug = GTK_CHECK_MENU_ITEM(menuitem)->active;
- update_tree(&rootmenu, NULL);
+ opt_mode = OPT_PROMPT;
+ gtk_tree_store_clear(tree2);
+ display_tree(&rootmenu); /* instead of update_tree to speed-up */
}
@@ -732,7 +665,6 @@ void on_introduction1_activate(GtkMenuItem * menuitem, gpointer user_data)
GtkWidget *dialog;
const gchar *intro_text = _(
"Welcome to gkc, the GTK+ graphical configuration tool\n"
- "for uClibc.\n"
"For each option, a blank box indicates the feature is disabled, a\n"
"check indicates it is enabled, and a dot indicates that it is to\n"
"be compiled as a module. Clicking on the box will cycle through the three states.\n"
@@ -751,7 +683,7 @@ void on_introduction1_activate(GtkMenuItem * menuitem, gpointer user_data)
dialog = gtk_message_dialog_new(GTK_WINDOW(main_wnd),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
- GTK_BUTTONS_CLOSE, intro_text);
+ GTK_BUTTONS_CLOSE, "%s", intro_text);
g_signal_connect_swapped(GTK_OBJECT(dialog), "response",
G_CALLBACK(gtk_widget_destroy),
GTK_OBJECT(dialog));
@@ -769,7 +701,7 @@ void on_about1_activate(GtkMenuItem * menuitem, gpointer user_data)
dialog = gtk_message_dialog_new(GTK_WINDOW(main_wnd),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
- GTK_BUTTONS_CLOSE, about_text);
+ GTK_BUTTONS_CLOSE, "%s", about_text);
g_signal_connect_swapped(GTK_OBJECT(dialog), "response",
G_CALLBACK(gtk_widget_destroy),
GTK_OBJECT(dialog));
@@ -788,7 +720,7 @@ void on_license1_activate(GtkMenuItem * menuitem, gpointer user_data)
dialog = gtk_message_dialog_new(GTK_WINDOW(main_wnd),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
- GTK_BUTTONS_CLOSE, license_text);
+ GTK_BUTTONS_CLOSE, "%s", license_text);
g_signal_connect_swapped(GTK_OBJECT(dialog), "response",
G_CALLBACK(gtk_widget_destroy),
GTK_OBJECT(dialog));
@@ -820,7 +752,6 @@ void on_load_clicked(GtkButton * button, gpointer user_data)
void on_single_clicked(GtkButton * button, gpointer user_data)
{
view_mode = SINGLE_VIEW;
- gtk_paned_set_position(GTK_PANED(hpaned), 0);
gtk_widget_hide(tree1_w);
current = &rootmenu;
display_tree_part();
@@ -846,7 +777,6 @@ void on_split_clicked(GtkButton * button, gpointer user_data)
void on_full_clicked(GtkButton * button, gpointer user_data)
{
view_mode = FULL_VIEW;
- gtk_paned_set_position(GTK_PANED(hpaned), 0);
gtk_widget_hide(tree1_w);
if (tree2)
gtk_tree_store_clear(tree2);
@@ -900,7 +830,7 @@ static void renderer_edited(GtkCellRendererText * cell,
static void change_sym_value(struct menu *menu, gint col)
{
struct symbol *sym = menu->sym;
- tristate oldval, newval;
+ tristate newval;
if (!sym)
return;
@@ -917,7 +847,6 @@ static void change_sym_value(struct menu *menu, gint col)
switch (sym_get_type(sym)) {
case S_BOOLEAN:
case S_TRISTATE:
- oldval = sym_get_tristate_value(sym);
if (!sym_tristate_within_range(sym, newval))
newval = yes;
sym_set_tristate_value(sym, newval);
@@ -954,35 +883,6 @@ static void toggle_sym_value(struct menu *menu)
display_tree_part(); //fixme: keep exp/coll
}
-static void renderer_toggled(GtkCellRendererToggle * cell,
- gchar * path_string, gpointer user_data)
-{
- GtkTreePath *path, *sel_path = NULL;
- GtkTreeIter iter, sel_iter;
- GtkTreeSelection *sel;
- struct menu *menu;
-
- path = gtk_tree_path_new_from_string(path_string);
- if (!gtk_tree_model_get_iter(model2, &iter, path))
- return;
-
- sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree2_w));
- if (gtk_tree_selection_get_selected(sel, NULL, &sel_iter))
- sel_path = gtk_tree_model_get_path(model2, &sel_iter);
- if (!sel_path)
- goto out1;
- if (gtk_tree_path_compare(path, sel_path))
- goto out2;
-
- gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1);
- toggle_sym_value(menu);
-
- out2:
- gtk_tree_path_free(sel_path);
- out1:
- gtk_tree_path_free(path);
-}
-
static gint column2index(GtkTreeViewColumn * column)
{
gint i;
@@ -1174,9 +1074,12 @@ static gchar **fill_row(struct menu *menu)
row[COL_OPTION] =
g_strdup_printf("%s %s", _(menu_get_prompt(menu)),
- sym && sym_has_value(sym) ? "(NEW)" : "");
+ sym && !sym_has_value(sym) ? "(NEW)" : "");
- if (show_all && !menu_is_visible(menu))
+ if (opt_mode == OPT_ALL && !menu_is_visible(menu))
+ row[COL_COLOR] = g_strdup("DarkGray");
+ else if (opt_mode == OPT_PROMPT &&
+ menu_has_prompt(menu) && !menu_is_visible(menu))
row[COL_COLOR] = g_strdup("DarkGray");
else
row[COL_COLOR] = g_strdup("Black");
@@ -1235,6 +1138,7 @@ static gchar **fill_row(struct menu *menu)
row[COL_BTNVIS] = GINT_TO_POINTER(TRUE);
if (sym_is_choice(sym))
break;
+ /* fall through */
case S_TRISTATE:
val = sym_get_tristate_value(sym);
switch (val) {
@@ -1373,7 +1277,6 @@ static void update_tree(struct menu *src, GtkTreeIter * dst)
gboolean valid;
GtkTreeIter *sibling;
struct symbol *sym;
- struct property *prop;
struct menu *menu1, *menu2;
if (src == &rootmenu)
@@ -1382,7 +1285,6 @@ static void update_tree(struct menu *src, GtkTreeIter * dst)
valid = gtk_tree_model_iter_children(model2, child2, dst);
for (child1 = src->list; child1; child1 = child1->next) {
- prop = child1->prompt;
sym = child1->sym;
reparse:
@@ -1399,16 +1301,20 @@ static void update_tree(struct menu *src, GtkTreeIter * dst)
menu2 ? menu_get_prompt(menu2) : "nil");
#endif
- if (!menu_is_visible(child1) && !show_all) { // remove node
+ if ((opt_mode == OPT_NORMAL && !menu_is_visible(child1)) ||
+ (opt_mode == OPT_PROMPT && !menu_has_prompt(child1)) ||
+ (opt_mode == OPT_ALL && !menu_get_prompt(child1))) {
+
+ /* remove node */
if (gtktree_iter_find_node(dst, menu1) != NULL) {
memcpy(&tmp, child2, sizeof(GtkTreeIter));
valid = gtk_tree_model_iter_next(model2,
child2);
gtk_tree_store_remove(tree2, &tmp);
if (!valid)
- return; // next parent
+ return; /* next parent */
else
- goto reparse; // next child
+ goto reparse; /* next child */
} else
continue;
}
@@ -1477,17 +1383,19 @@ static void display_tree(struct menu *menu)
&& (tree == tree2))
continue;
- if (menu_is_visible(child) || show_all)
+ if ((opt_mode == OPT_NORMAL && menu_is_visible(child)) ||
+ (opt_mode == OPT_PROMPT && menu_has_prompt(child)) ||
+ (opt_mode == OPT_ALL && menu_get_prompt(child)))
place_node(child, fill_row(child));
#ifdef DEBUG
printf("%*c%s: ", indent, ' ', menu_get_prompt(child));
printf("%s", child->flags & MENU_ROOT ? "rootmenu | " : "");
- dbg_print_ptype(ptype);
+ printf("%s", prop_get_type_name(ptype));
printf(" | ");
if (sym) {
- dbg_print_stype(sym->type);
+ printf("%s", sym_type_name(sym->type));
printf(" | ");
- dbg_print_flags(sym->flags);
+ printf("%s", dbg_sym_flags(sym->flags));
printf("\n");
} else
printf("\n");
@@ -1499,6 +1407,12 @@ static void display_tree(struct menu *menu)
if (((menu != &rootmenu) && !(menu->flags & MENU_ROOT))
|| (view_mode == FULL_VIEW)
|| (view_mode == SPLIT_VIEW))*/
+
+ /* Change paned position if the view is not in 'split mode' */
+ if (view_mode == SINGLE_VIEW || view_mode == FULL_VIEW) {
+ gtk_paned_set_position(GTK_PANED(hpaned), 0);
+ }
+
if (((view_mode == SINGLE_VIEW) && (menu->flags & MENU_ROOT))
|| (view_mode == FULL_VIEW)
|| (view_mode == SPLIT_VIEW)) {
@@ -1557,10 +1471,6 @@ int main(int ac, char *av[])
char *env;
gchar *glade_file;
-#ifndef LKC_DIRECT_LINK
- kconfig_load();
-#endif
-
bindtextdomain(PACKAGE, LOCALEDIR);
bind_textdomain_codeset(PACKAGE, "UTF-8");
textdomain(PACKAGE);
@@ -1582,12 +1492,6 @@ int main(int ac, char *av[])
else
glade_file = g_strconcat(g_get_current_dir(), "/", av[0], ".glade", NULL);
- /* Load the interface and connect signals */
- init_main_window(glade_file);
- init_tree_model();
- init_left_tree();
- init_right_tree();
-
/* Conf stuffs */
if (ac > 1 && av[1][0] == '-') {
switch (av[1][1]) {
@@ -1607,6 +1511,12 @@ int main(int ac, char *av[])
fixup_rootmenu(&rootmenu);
conf_read(NULL);
+ /* Load the interface and connect signals */
+ init_main_window(glade_file);
+ init_tree_model();
+ init_left_tree();
+ init_right_tree();
+
switch (view_mode) {
case SINGLE_VIEW:
display_tree_part();
diff --git a/extra/config/gconf.glade b/extra/config/gconf.glade
index 2e2e2f9db..d449d3251 100644
--- a/extra/config/gconf.glade
+++ b/extra/config/gconf.glade
@@ -1,11 +1,10 @@
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
-<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
<glade-interface>
<widget class="GtkWindow" id="window1">
<property name="visible">True</property>
- <property name="title" translatable="yes">Gtk uClibc Configurator</property>
+ <property name="title" translatable="yes">Gtk uCLibc Configurator</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
@@ -190,26 +189,40 @@
</child>
<child>
- <widget class="GtkCheckMenuItem" id="show_all_options1">
+ <widget class="GtkRadioMenuItem" id="set_option_mode1">
+ <property name="visible">True</property>
+ <property name="tooltip" translatable="yes">Show normal options</property>
+ <property name="label" translatable="yes">Show normal options</property>
+ <property name="use_underline">True</property>
+ <property name="active">True</property>
+ <signal name="activate" handler="on_set_option_mode1_activate"/>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkRadioMenuItem" id="set_option_mode2">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Show all options</property>
<property name="label" translatable="yes">Show all _options</property>
<property name="use_underline">True</property>
<property name="active">False</property>
- <signal name="activate" handler="on_show_all_options1_activate"/>
+ <property name="group">set_option_mode1</property>
+ <signal name="activate" handler="on_set_option_mode2_activate"/>
</widget>
</child>
<child>
- <widget class="GtkCheckMenuItem" id="show_debug_info1">
+ <widget class="GtkRadioMenuItem" id="set_option_mode3">
<property name="visible">True</property>
- <property name="tooltip" translatable="yes">Show masked options</property>
- <property name="label" translatable="yes">Show _debug info</property>
+ <property name="tooltip" translatable="yes">Show all options with prompts</property>
+ <property name="label" translatable="yes">Show all prompt options</property>
<property name="use_underline">True</property>
<property name="active">False</property>
- <signal name="activate" handler="on_show_debug_info1_activate"/>
+ <property name="group">set_option_mode1</property>
+ <signal name="activate" handler="on_set_option_mode3_activate"/>
</widget>
</child>
+
</widget>
</child>
</widget>
@@ -547,7 +560,7 @@
<property name="headers_visible">True</property>
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
- <property name="enable_search">True</property>
+ <property name="enable_search">False</property>
<signal name="cursor_changed" handler="on_treeview2_cursor_changed" last_modification_time="Sun, 12 Jan 2003 15:58:22 GMT"/>
<signal name="button_press_event" handler="on_treeview1_button_press_event" last_modification_time="Sun, 12 Jan 2003 16:03:52 GMT"/>
<signal name="key_press_event" handler="on_treeview2_key_press_event" last_modification_time="Sun, 12 Jan 2003 16:11:44 GMT"/>
@@ -582,7 +595,7 @@
<property name="headers_visible">True</property>
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
- <property name="enable_search">True</property>
+ <property name="enable_search">False</property>
<signal name="cursor_changed" handler="on_treeview2_cursor_changed" last_modification_time="Sun, 12 Jan 2003 15:57:55 GMT"/>
<signal name="button_press_event" handler="on_treeview2_button_press_event" last_modification_time="Sun, 12 Jan 2003 15:57:58 GMT"/>
<signal name="key_press_event" handler="on_treeview2_key_press_event" last_modification_time="Sun, 12 Jan 2003 15:58:01 GMT"/>
diff --git a/extra/config/kconfig-language.txt b/extra/config/kconfig-language.txt
index 649cb8799..c858f8419 100644
--- a/extra/config/kconfig-language.txt
+++ b/extra/config/kconfig-language.txt
@@ -104,14 +104,21 @@ applicable everywhere (see syntax).
Reverse dependencies can only be used with boolean or tristate
symbols.
Note:
- select is evil.... select will by brute force set a symbol
- equal to 'y' without visiting the dependencies. So abusing
- select you are able to select a symbol FOO even if FOO depends
- on BAR that is not set. In general use select only for
- non-visible symbols (no prompts anywhere) and for symbols with
- no dependencies. That will limit the usefulness but on the
- other hand avoid the illegal configurations all over. kconfig
- should one day warn about such things.
+ select should be used with care. select will force
+ a symbol to a value without visiting the dependencies.
+ By abusing select you are able to select a symbol FOO even
+ if FOO depends on BAR that is not set.
+ In general use select only for non-visible symbols
+ (no prompts anywhere) and for symbols with no dependencies.
+ That will limit the usefulness but on the other hand avoid
+ the illegal configurations all over.
+
+- limiting menu display: "visible if" <expr>
+ This attribute is only applicable to menu blocks, if the condition is
+ false, the menu block is not displayed to the user (the symbols
+ contained there can still be selected by other symbols, though). It is
+ similar to a conditional "prompt" attribute for individual menu
+ entries. Default value of "visible" is true.
- numerical ranges: "range" <symbol> <symbol> ["if" <expr>]
This allows to limit the range of possible input values for int
@@ -180,7 +187,7 @@ Expressions are listed in decreasing order of precedence.
(7) Returns the result of max(/expr/, /expr/).
An expression can have a value of 'n', 'm' or 'y' (or 0, 1, 2
-respectively for calculations). A menu entry becomes visible when it's
+respectively for calculations). A menu entry becomes visible when its
expression evaluates to 'm' or 'y'.
There are two types of symbols: constant and non-constant symbols.
@@ -267,7 +274,7 @@ separate list of options.
choices:
- "choice"
+ "choice" [symbol]
<choice options>
<choice block>
"endchoice"
@@ -281,6 +288,10 @@ single driver can be compiled/loaded into the kernel, but all drivers
can be compiled as modules.
A choice accepts another option "optional", which allows to set the
choice to 'n' and no entry needs to be selected.
+If no [symbol] is associated with a choice, then you can not have multiple
+definitions of that choice. If a [symbol] is associated to the choice,
+then you may define the same choice (ie. with the same entries) in another
+place.
comment:
@@ -299,7 +310,8 @@ menu:
"endmenu"
This defines a menu block, see "Menu structure" above for more
-information. The only possible options are dependencies.
+information. The only possible options are dependencies and "visible"
+attributes.
if:
@@ -321,7 +333,8 @@ mainmenu:
"mainmenu" <prompt>
This sets the config program's title bar if the config program chooses
-to use it.
+to use it. It should be placed at the top of the configuration, before any
+other statement.
Kconfig hints
@@ -375,28 +388,3 @@ config FOO
depends on BAR && m
limits FOO to module (=m) or disabled (=n).
-
-
-Build limited by a third config symbol which may be =y or =m
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-A common idiom that we see (and sometimes have problems with) is this:
-
-When option C in B (module or subsystem) uses interfaces from A (module
-or subsystem), and both A and B are tristate (could be =y or =m if they
-were independent of each other, but they aren't), then we need to limit
-C such that it cannot be built statically if A is built as a loadable
-module. (C already depends on B, so there is no dependency issue to
-take care of here.)
-
-If A is linked statically into the kernel image, C can be built
-statically or as loadable module(s). However, if A is built as loadable
-module(s), then C must be restricted to loadable module(s) also. This
-can be expressed in kconfig language as:
-
-config C
- depends on A = y || A = B
-
-or for real examples, use this command in a kernel tree:
-
-$ find . -name Kconfig\* | xargs grep -ns "depends on.*=.*||.*=" | grep -v orig
-
diff --git a/extra/config/kconfig-to-uclibc.patch.gz b/extra/config/kconfig-to-uclibc.patch.gz
deleted file mode 100644
index df28093ba..000000000
--- a/extra/config/kconfig-to-uclibc.patch.gz
+++ /dev/null
Binary files differ
diff --git a/extra/config/kconfig-to-uclibc.tar.gz b/extra/config/kconfig-to-uclibc.tar.gz
new file mode 100644
index 000000000..bd018cc4c
--- /dev/null
+++ b/extra/config/kconfig-to-uclibc.tar.gz
Binary files differ
diff --git a/extra/config/kconfig_load.c b/extra/config/kconfig_load.c
deleted file mode 100644
index dbdcaad82..000000000
--- a/extra/config/kconfig_load.c
+++ /dev/null
@@ -1,35 +0,0 @@
-#include <dlfcn.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "lkc.h"
-
-#define P(name,type,arg) type (*name ## _p) arg
-#include "lkc_proto.h"
-#undef P
-
-void kconfig_load(void)
-{
- void *handle;
- char *error;
-
- handle = dlopen("./libkconfig.so", RTLD_LAZY);
- if (!handle) {
- handle = dlopen("./scripts/kconfig/libkconfig.so", RTLD_LAZY);
- if (!handle) {
- fprintf(stderr, "%s\n", dlerror());
- exit(1);
- }
- }
-
-#define P(name,type,arg) \
-{ \
- name ## _p = dlsym(handle, #name); \
- if ((error = dlerror())) { \
- fprintf(stderr, "%s\n", error); \
- exit(1); \
- } \
-}
-#include "lkc_proto.h"
-#undef P
-}
diff --git a/extra/config/kxgettext.c b/extra/config/kxgettext.c
index 6eb72a7f2..2858738b2 100644
--- a/extra/config/kxgettext.c
+++ b/extra/config/kxgettext.c
@@ -7,7 +7,6 @@
#include <stdlib.h>
#include <string.h>
-#define LKC_DIRECT_LINK
#include "lkc.h"
static char *escape(const char* text, char *bf, int len)
@@ -43,6 +42,10 @@ static char *escape(const char* text, char *bf, int len)
++text;
goto next;
}
+ else if (*text == '\\') {
+ *bfp++ = '\\';
+ len--;
+ }
*bfp++ = *text++;
next:
--len;
@@ -59,11 +62,11 @@ next:
struct file_line {
struct file_line *next;
- char* file;
- int lineno;
+ const char *file;
+ int lineno;
};
-static struct file_line *file_line__new(char *file, int lineno)
+static struct file_line *file_line__new(const char *file, int lineno)
{
struct file_line *self = malloc(sizeof(*self));
@@ -86,7 +89,8 @@ struct message {
static struct message *message__list;
-static struct message *message__new(const char *msg, char *option, char *file, int lineno)
+static struct message *message__new(const char *msg, char *option,
+ const char *file, int lineno)
{
struct message *self = malloc(sizeof(*self));
@@ -126,7 +130,8 @@ static struct message *mesage__find(const char *msg)
return m;
}
-static int message__add_file_line(struct message *self, char *file, int lineno)
+static int message__add_file_line(struct message *self, const char *file,
+ int lineno)
{
int rc = -1;
struct file_line *fl = file_line__new(file, lineno);
@@ -141,7 +146,8 @@ out:
return rc;
}
-static int message__add(const char *msg, char *option, char *file, int lineno)
+static int message__add(const char *msg, char *option, const char *file,
+ int lineno)
{
int rc = 0;
char bf[16384];
@@ -162,7 +168,7 @@ static int message__add(const char *msg, char *option, char *file, int lineno)
return rc;
}
-void menu_build_message_list(struct menu *menu)
+static void menu_build_message_list(struct menu *menu)
{
struct menu *child;
@@ -207,7 +213,7 @@ static void message__print_gettext_msgid_msgstr(struct message *self)
"msgstr \"\"\n", self->msg);
}
-void menu__xgettext(void)
+static void menu__xgettext(void)
{
struct message *m = message__list;
diff --git a/extra/config/list.h b/extra/config/list.h
new file mode 100644
index 000000000..685d80e1b
--- /dev/null
+++ b/extra/config/list.h
@@ -0,0 +1,131 @@
+#ifndef LIST_H
+#define LIST_H
+
+/*
+ * Copied from include/linux/...
+ */
+
+#undef offsetof
+#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+
+/**
+ * container_of - cast a member of a structure out to the containing structure
+ * @ptr: the pointer to the member.
+ * @type: the type of the container struct this is embedded in.
+ * @member: the name of the member within the struct.
+ *
+ */
+#define container_of(ptr, type, member) ({ \
+ const typeof( ((type *)0)->member ) *__mptr = (ptr); \
+ (type *)( (char *)__mptr - offsetof(type,member) );})
+
+
+struct list_head {
+ struct list_head *next, *prev;
+};
+
+
+#define LIST_HEAD_INIT(name) { &(name), &(name) }
+
+#define LIST_HEAD(name) \
+ struct list_head name = LIST_HEAD_INIT(name)
+
+/**
+ * list_entry - get the struct for this entry
+ * @ptr: the &struct list_head pointer.
+ * @type: the type of the struct this is embedded in.
+ * @member: the name of the list_struct within the struct.
+ */
+#define list_entry(ptr, type, member) \
+ container_of(ptr, type, member)
+
+/**
+ * list_for_each_entry - iterate over list of given type
+ * @pos: the type * to use as a loop cursor.
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ */
+#define list_for_each_entry(pos, head, member) \
+ for (pos = list_entry((head)->next, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = list_entry(pos->member.next, typeof(*pos), member))
+
+/**
+ * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
+ * @pos: the type * to use as a loop cursor.
+ * @n: another type * to use as temporary storage
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ */
+#define list_for_each_entry_safe(pos, n, head, member) \
+ for (pos = list_entry((head)->next, typeof(*pos), member), \
+ n = list_entry(pos->member.next, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = n, n = list_entry(n->member.next, typeof(*n), member))
+
+/**
+ * list_empty - tests whether a list is empty
+ * @head: the list to test.
+ */
+static inline int list_empty(const struct list_head *head)
+{
+ return head->next == head;
+}
+
+/*
+ * Insert a new entry between two known consecutive entries.
+ *
+ * This is only for internal list manipulation where we know
+ * the prev/next entries already!
+ */
+static inline void __list_add(struct list_head *_new,
+ struct list_head *prev,
+ struct list_head *next)
+{
+ next->prev = _new;
+ _new->next = next;
+ _new->prev = prev;
+ prev->next = _new;
+}
+
+/**
+ * list_add_tail - add a new entry
+ * @new: new entry to be added
+ * @head: list head to add it before
+ *
+ * Insert a new entry before the specified head.
+ * This is useful for implementing queues.
+ */
+static inline void list_add_tail(struct list_head *_new, struct list_head *head)
+{
+ __list_add(_new, head->prev, head);
+}
+
+/*
+ * Delete a list entry by making the prev/next entries
+ * point to each other.
+ *
+ * This is only for internal list manipulation where we know
+ * the prev/next entries already!
+ */
+static inline void __list_del(struct list_head *prev, struct list_head *next)
+{
+ next->prev = prev;
+ prev->next = next;
+}
+
+#define LIST_POISON1 ((void *) 0x00100100)
+#define LIST_POISON2 ((void *) 0x00200200)
+/**
+ * list_del - deletes entry from list.
+ * @entry: the element to delete from the list.
+ * Note: list_empty() on entry does not return true after this, the entry is
+ * in an undefined state.
+ */
+static inline void list_del(struct list_head *entry)
+{
+ __list_del(entry->prev, entry->next);
+ entry->next = (struct list_head*)LIST_POISON1;
+ entry->prev = (struct list_head*)LIST_POISON2;
+}
+#endif
diff --git a/extra/config/lkc.h b/extra/config/lkc.h
index c55c2fbd7..22d356146 100644
--- a/extra/config/lkc.h
+++ b/extra/config/lkc.h
@@ -11,37 +11,53 @@
#ifndef KBUILD_NO_NLS
# include <libintl.h>
#else
-# define gettext(Msgid) ((const char *) (Msgid))
-# define textdomain(Domainname) ((const char *) (Domainname))
-# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname))
+static inline const char *gettext(const char *txt) { return txt; }
+static inline void textdomain(const char *domainname) {}
+static inline void bindtextdomain(const char *name, const char *dir) {}
+static inline char *bind_textdomain_codeset(const char *dn, char *c) { return c; }
#endif
#ifdef __cplusplus
extern "C" {
#endif
-#ifdef LKC_DIRECT_LINK
#define P(name,type,arg) extern type name arg
-#else
-#include "lkc_defs.h"
-#define P(name,type,arg) extern type (*name ## _p) arg
-#endif
#include "lkc_proto.h"
#undef P
#define SRCTREE "srctree"
+#ifndef PACKAGE
#define PACKAGE "linux"
+#endif
+
#define LOCALEDIR "/usr/share/locale"
#define _(text) gettext(text)
#define N_(text) (text)
+#ifndef CONFIG_
+#define CONFIG_ "CONFIG_"
+#endif
+static inline const char *CONFIG_prefix(void)
+{
+ return getenv( "CONFIG_" ) ?: CONFIG_;
+}
+#undef CONFIG_
+#define CONFIG_ CONFIG_prefix()
#define TF_COMMAND 0x0001
#define TF_PARAM 0x0002
#define TF_OPTION 0x0004
+enum conf_def_mode {
+ def_default,
+ def_yes,
+ def_mod,
+ def_no,
+ def_random
+};
+
#define T_OPT_MODULES 1
#define T_OPT_DEFCONFIG_LIST 2
#define T_OPT_ENV 3
@@ -53,34 +69,49 @@ struct kconf_id {
enum symbol_type stype;
};
+extern int zconfdebug;
+
int zconfparse(void);
void zconfdump(FILE *out);
-
-extern int zconfdebug;
void zconf_starthelp(void);
FILE *zconf_fopen(const char *name);
void zconf_initscan(const char *name);
void zconf_nextfile(const char *name);
int zconf_lineno(void);
-char *zconf_curname(void);
+const char *zconf_curname(void);
/* confdata.c */
const char *conf_get_configname(void);
+const char *conf_get_autoconfig_name(void);
char *conf_get_default_confname(void);
void sym_set_change_count(int count);
void sym_add_change_count(int count);
+bool conf_set_all_new_symbols(enum conf_def_mode mode);
+void set_all_choice_values(struct symbol *csym);
-/* kconfig_load.c */
-void kconfig_load(void);
+struct conf_printer {
+ void (*print_symbol)(FILE *, struct symbol *, const char *, void *);
+ void (*print_comment)(FILE *, const char *, void *);
+};
+
+/* confdata.c and expr.c */
+static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out)
+{
+ assert(len != 0);
+
+ if (fwrite(str, len, count, out) != count)
+ fprintf(stderr, "Error in writing or end of file.\n");
+}
/* menu.c */
-void menu_init(void);
+void _menu_init(void);
void menu_warn(struct menu *menu, const char *fmt, ...);
struct menu *menu_add_menu(void);
void menu_end_menu(void);
void menu_add_entry(struct symbol *sym);
void menu_end_entry(void);
void menu_add_dep(struct expr *dep);
+void menu_add_visibility(struct expr *dep);
struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep);
struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep);
void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep);
@@ -92,10 +123,19 @@ void menu_set_type(int type);
/* util.c */
struct file *file_lookup(const char *name);
int file_write_dep(const char *name);
+void *xmalloc(size_t size);
+void *xcalloc(size_t nmemb, size_t size);
+char *dir_name(char *path);
+char *base_name(char *path);
struct gstr {
size_t len;
char *s;
+ /*
+ * when max_width is not zero long lines in string s (if any) get
+ * wrapped not to exceed the max_width value
+ */
+ int max_width;
};
struct gstr str_new(void);
struct gstr str_assign(const char *s);
@@ -111,43 +151,45 @@ void sym_init(void);
void sym_clear_all_valid(void);
void sym_set_all_changed(void);
void sym_set_changed(struct symbol *sym);
+struct symbol *sym_choice_default(struct symbol *sym);
+const char *sym_get_string_default(struct symbol *sym);
struct symbol *sym_check_deps(struct symbol *sym);
struct property *prop_alloc(enum prop_type type, struct symbol *sym);
struct symbol *prop_get_symbol(struct property *prop);
struct property *sym_get_env_prop(struct symbol *sym);
-static __inline__ tristate sym_get_tristate_value(struct symbol *sym)
+static inline tristate sym_get_tristate_value(struct symbol *sym)
{
return sym->curr.tri;
}
-static __inline__ struct symbol *sym_get_choice_value(struct symbol *sym)
+static inline struct symbol *sym_get_choice_value(struct symbol *sym)
{
return (struct symbol *)sym->curr.val;
}
-static __inline__ bool sym_set_choice_value(struct symbol *ch, struct symbol *chval)
+static inline bool sym_set_choice_value(struct symbol *ch, struct symbol *chval)
{
return sym_set_tristate_value(chval, yes);
}
-static __inline__ bool sym_is_choice(struct symbol *sym)
+static inline bool sym_is_choice(struct symbol *sym)
{
return sym->flags & SYMBOL_CHOICE ? true : false;
}
-static __inline__ bool sym_is_choice_value(struct symbol *sym)
+static inline bool sym_is_choice_value(struct symbol *sym)
{
return sym->flags & SYMBOL_CHOICEVAL ? true : false;
}
-static __inline__ bool sym_is_optional(struct symbol *sym)
+static inline bool sym_is_optional(struct symbol *sym)
{
return sym->flags & SYMBOL_OPTIONAL ? true : false;
}
-static __inline__ bool sym_has_value(struct symbol *sym)
+static inline bool sym_has_value(struct symbol *sym)
{
return sym->flags & SYMBOL_DEF_USER ? true : false;
}
diff --git a/extra/config/lkc_proto.h b/extra/config/lkc_proto.h
index 4d09f6dde..ecdb9659b 100644
--- a/extra/config/lkc_proto.h
+++ b/extra/config/lkc_proto.h
@@ -1,28 +1,40 @@
+#include <stdarg.h>
/* confdata.c */
P(conf_parse,void,(const char *name));
P(conf_read,int,(const char *name));
P(conf_read_simple,int,(const char *name, int));
+P(conf_write_defconfig,int,(const char *name));
P(conf_write,int,(const char *name));
P(conf_write_autoconf,int,(void));
P(conf_get_changed,bool,(void));
P(conf_set_changed_callback, void,(void (*fn)(void)));
+P(conf_set_message_callback, void,(void (*fn)(const char *fmt, va_list ap)));
/* menu.c */
P(rootmenu,struct menu,);
-P(menu_is_visible,bool,(struct menu *menu));
+P(menu_is_empty, bool, (struct menu *menu));
+P(menu_is_visible, bool, (struct menu *menu));
+P(menu_has_prompt, bool, (struct menu *menu));
P(menu_get_prompt,const char *,(struct menu *menu));
P(menu_get_root_menu,struct menu *,(struct menu *menu));
P(menu_get_parent_menu,struct menu *,(struct menu *menu));
P(menu_has_help,bool,(struct menu *menu));
P(menu_get_help,const char *,(struct menu *menu));
+P(get_symbol_str, void, (struct gstr *r, struct symbol *sym, struct list_head
+ *head));
+P(get_relations_str, struct gstr, (struct symbol **sym_arr, struct list_head
+ *head));
+P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help));
/* symbol.c */
P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]);
-P(sym_lookup,struct symbol *,(const char *name, int isconst));
+P(sym_lookup,struct symbol *,(const char *name, int flags));
P(sym_find,struct symbol *,(const char *name));
+P(sym_expand_string_value,const char *,(const char *in));
+P(sym_escape_string_value, const char *,(const char *in));
P(sym_re_search,struct symbol **,(const char *pattern));
P(sym_type_name,const char *,(enum symbol_type type));
P(sym_calc_value,void,(struct symbol *sym));
diff --git a/extra/config/lxdialog/check-lxdialog.sh b/extra/config/lxdialog/check-lxdialog.sh
index 5552154cb..9d2a4c585 100755..100644
--- a/extra/config/lxdialog/check-lxdialog.sh
+++ b/extra/config/lxdialog/check-lxdialog.sh
@@ -4,7 +4,9 @@
# What library to link
ldflags()
{
- for ext in so a dylib ; do
+ pkg-config --libs ncursesw 2>/dev/null && exit
+ pkg-config --libs ncurses 2>/dev/null && exit
+ for ext in so a dll.a dylib ; do
for lib in ncursesw ncurses curses ; do
$cc -print-file-name=lib${lib}.${ext} | grep -q /
if [ $? -eq 0 ]; then
@@ -19,10 +21,13 @@ ldflags()
# Where is ncurses.h?
ccflags()
{
- if [ -f /usr/include/ncurses/ncurses.h ]; then
+ if [ -f /usr/include/ncursesw/curses.h ]; then
+ echo '-I/usr/include/ncursesw -DCURSES_LOC="<curses.h>"'
+ echo ' -DNCURSES_WIDECHAR=1'
+ elif [ -f /usr/include/ncurses/ncurses.h ]; then
echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
elif [ -f /usr/include/ncurses/curses.h ]; then
- echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"'
+ echo '-I/usr/include/ncurses -DCURSES_LOC="<curses.h>"'
elif [ -f /usr/include/ncurses.h ]; then
echo '-DCURSES_LOC="<ncurses.h>"'
else
@@ -36,7 +41,7 @@ trap "rm -f $tmp" 0 1 2 3 15
# Check if we can link to ncurses
check() {
- $cc -xc - -o $tmp 2>/dev/null <<'EOF'
+ $cc -x c - -o $tmp 2>/dev/null <<'EOF'
#include CURSES_LOC
main() {}
EOF
@@ -52,7 +57,7 @@ EOF
}
usage() {
- printf "Usage: $0 [-check compiler options|-header|-library]\n"
+ printf "Usage: $0 [-check compiler options|-ccflags|-ldflags compiler options]\n"
}
if [ $# -eq 0 ]; then
diff --git a/extra/config/lxdialog/checklist.c b/extra/config/lxdialog/checklist.c
index b2a878c93..3b15c08ec 100644
--- a/extra/config/lxdialog/checklist.c
+++ b/extra/config/lxdialog/checklist.c
@@ -31,6 +31,10 @@ static int list_width, check_x, item_x;
static void print_item(WINDOW * win, int choice, int selected)
{
int i;
+ char *list_item = malloc(list_width + 1);
+
+ strncpy(list_item, item_str(), list_width - item_x);
+ list_item[list_width - item_x] = '\0';
/* Clear 'residue' of last item */
wattrset(win, dlg.menubox.atr);
@@ -41,16 +45,18 @@ static void print_item(WINDOW * win, int choice, int selected)
wmove(win, choice, check_x);
wattrset(win, selected ? dlg.check_selected.atr
: dlg.check.atr);
- wprintw(win, "(%c)", item_is_tag('X') ? 'X' : ' ');
+ if (!item_is_tag(':'))
+ wprintw(win, "(%c)", item_is_tag('X') ? 'X' : ' ');
wattrset(win, selected ? dlg.tag_selected.atr : dlg.tag.atr);
- mvwaddch(win, choice, item_x, item_str()[0]);
+ mvwaddch(win, choice, item_x, list_item[0]);
wattrset(win, selected ? dlg.item_selected.atr : dlg.item.atr);
- waddstr(win, (char *)item_str() + 1);
+ waddstr(win, list_item + 1);
if (selected) {
wmove(win, choice, check_x + 1);
wrefresh(win);
}
+ free(list_item);
}
/*
@@ -126,16 +132,16 @@ int dialog_checklist(const char *title, const char *prompt, int height,
}
do_resize:
- if (getmaxy(stdscr) < (height + 6))
+ if (getmaxy(stdscr) < (height + CHECKLIST_HEIGTH_MIN))
return -ERRDISPLAYTOOSMALL;
- if (getmaxx(stdscr) < (width + 6))
+ if (getmaxx(stdscr) < (width + CHECKLIST_WIDTH_MIN))
return -ERRDISPLAYTOOSMALL;
max_choice = MIN(list_height, item_count());
/* center dialog box on screen */
- x = (COLS - width) / 2;
- y = (LINES - height) / 2;
+ x = (getmaxx(stdscr) - width) / 2;
+ y = (getmaxy(stdscr) - height) / 2;
draw_shadow(stdscr, y, x, height, width);
@@ -174,6 +180,7 @@ do_resize:
check_x = 0;
item_foreach()
check_x = MAX(check_x, strlen(item_str()) + 4);
+ check_x = MIN(check_x, list_width);
check_x = (list_width - check_x) / 2;
item_x = check_x + 4;
diff --git a/extra/config/lxdialog/dialog.h b/extra/config/lxdialog/dialog.h
index b5211fce0..b4343d384 100644
--- a/extra/config/lxdialog/dialog.h
+++ b/extra/config/lxdialog/dialog.h
@@ -106,8 +106,14 @@ struct dialog_color {
int hl; /* highlight this item */
};
+struct subtitle_list {
+ struct subtitle_list *next;
+ const char *text;
+};
+
struct dialog_info {
const char *backtitle;
+ struct subtitle_list *subtitles;
struct dialog_color screen;
struct dialog_color shadow;
struct dialog_color dialog;
@@ -144,6 +150,7 @@ struct dialog_info {
*/
extern struct dialog_info dlg;
extern char dialog_input_result[];
+extern int saved_x, saved_y; /* Needed in signal handler in mconf.c */
/*
* Function prototypes
@@ -193,8 +200,23 @@ int item_is_tag(char tag);
int on_key_esc(WINDOW *win);
int on_key_resize(void);
+/* minimum (re)size values */
+#define CHECKLIST_HEIGTH_MIN 6 /* For dialog_checklist() */
+#define CHECKLIST_WIDTH_MIN 6
+#define INPUTBOX_HEIGTH_MIN 2 /* For dialog_inputbox() */
+#define INPUTBOX_WIDTH_MIN 2
+#define MENUBOX_HEIGTH_MIN 15 /* For dialog_menu() */
+#define MENUBOX_WIDTH_MIN 65
+#define TEXTBOX_HEIGTH_MIN 8 /* For dialog_textbox() */
+#define TEXTBOX_WIDTH_MIN 8
+#define YESNO_HEIGTH_MIN 4 /* For dialog_yesno() */
+#define YESNO_WIDTH_MIN 4
+#define WINDOW_HEIGTH_MIN 19 /* For init_dialog() */
+#define WINDOW_WIDTH_MIN 80
+
int init_dialog(const char *backtitle);
void set_dialog_backtitle(const char *backtitle);
+void set_dialog_subtitles(struct subtitle_list *subtitles);
void end_dialog(int x, int y);
void attr_clear(WINDOW * win, int height, int width, chtype attr);
void dialog_clear(void);
@@ -209,12 +231,17 @@ int first_alpha(const char *string, const char *exempt);
int dialog_yesno(const char *title, const char *prompt, int height, int width);
int dialog_msgbox(const char *title, const char *prompt, int height,
int width, int pause);
-int dialog_textbox(const char *title, const char *file, int height, int width);
+
+
+typedef void (*update_text_fn)(char *buf, size_t start, size_t end, void
+ *_data);
+int dialog_textbox(const char *title, char *tbuf, int initial_height,
+ int initial_width, int *keys, int *_vscroll, int *_hscroll,
+ update_text_fn update_text, void *data);
int dialog_menu(const char *title, const char *prompt,
const void *selected, int *s_scroll);
int dialog_checklist(const char *title, const char *prompt, int height,
int width, int list_height);
-extern char dialog_input_result[];
int dialog_inputbox(const char *title, const char *prompt, int height,
int width, const char *init);
diff --git a/extra/config/lxdialog/inputbox.c b/extra/config/lxdialog/inputbox.c
index 4946bd02b..447a58219 100644
--- a/extra/config/lxdialog/inputbox.c
+++ b/extra/config/lxdialog/inputbox.c
@@ -45,7 +45,8 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
const char *init)
{
int i, x, y, box_y, box_x, box_width;
- int input_x = 0, scroll = 0, key = 0, button = -1;
+ int input_x = 0, key = 0, button = -1;
+ int show_x, len, pos;
char *instr = dialog_input_result;
WINDOW *dialog;
@@ -55,14 +56,14 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
strcpy(instr, init);
do_resize:
- if (getmaxy(stdscr) <= (height - 2))
+ if (getmaxy(stdscr) <= (height - INPUTBOX_HEIGTH_MIN))
return -ERRDISPLAYTOOSMALL;
- if (getmaxx(stdscr) <= (width - 2))
+ if (getmaxx(stdscr) <= (width - INPUTBOX_WIDTH_MIN))
return -ERRDISPLAYTOOSMALL;
/* center dialog box on screen */
- x = (COLS - width) / 2;
- y = (LINES - height) / 2;
+ x = (getmaxx(stdscr) - width) / 2;
+ y = (getmaxy(stdscr) - height) / 2;
draw_shadow(stdscr, y, x, height, width);
@@ -89,7 +90,7 @@ do_resize:
box_y = y + 2;
box_x = (width - box_width) / 2;
draw_box(dialog, y + 1, box_x - 1, 3, box_width + 2,
- dlg.border.atr, dlg.dialog.atr);
+ dlg.dialog.atr, dlg.border.atr);
print_buttons(dialog, height, width, 0);
@@ -97,14 +98,17 @@ do_resize:
wmove(dialog, box_y, box_x);
wattrset(dialog, dlg.inputbox.atr);
- input_x = strlen(instr);
+ len = strlen(instr);
+ pos = len;
- if (input_x >= box_width) {
- scroll = input_x - box_width + 1;
+ if (len >= box_width) {
+ show_x = len - box_width + 1;
input_x = box_width - 1;
for (i = 0; i < box_width - 1; i++)
- waddch(dialog, instr[scroll + i]);
+ waddch(dialog, instr[show_x + i]);
} else {
+ show_x = 0;
+ input_x = len;
waddstr(dialog, instr);
}
@@ -121,45 +125,104 @@ do_resize:
case KEY_UP:
case KEY_DOWN:
break;
- case KEY_LEFT:
- continue;
- case KEY_RIGHT:
- continue;
case KEY_BACKSPACE:
case 127:
- if (input_x || scroll) {
+ if (pos) {
wattrset(dialog, dlg.inputbox.atr);
- if (!input_x) {
- scroll = scroll < box_width - 1 ? 0 : scroll - (box_width - 1);
- wmove(dialog, box_y, box_x);
- for (i = 0; i < box_width; i++)
- waddch(dialog,
- instr[scroll + input_x + i] ?
- instr[scroll + input_x + i] : ' ');
- input_x = strlen(instr) - scroll;
+ if (input_x == 0) {
+ show_x--;
} else
input_x--;
- instr[scroll + input_x] = '\0';
- mvwaddch(dialog, box_y, input_x + box_x, ' ');
+
+ if (pos < len) {
+ for (i = pos - 1; i < len; i++) {
+ instr[i] = instr[i+1];
+ }
+ }
+
+ pos--;
+ len--;
+ instr[len] = '\0';
+ wmove(dialog, box_y, box_x);
+ for (i = 0; i < box_width; i++) {
+ if (!instr[show_x + i]) {
+ waddch(dialog, ' ');
+ break;
+ }
+ waddch(dialog, instr[show_x + i]);
+ }
wmove(dialog, box_y, input_x + box_x);
wrefresh(dialog);
}
continue;
+ case KEY_LEFT:
+ if (pos > 0) {
+ if (input_x > 0) {
+ wmove(dialog, box_y, --input_x + box_x);
+ } else if (input_x == 0) {
+ show_x--;
+ wmove(dialog, box_y, box_x);
+ for (i = 0; i < box_width; i++) {
+ if (!instr[show_x + i]) {
+ waddch(dialog, ' ');
+ break;
+ }
+ waddch(dialog, instr[show_x + i]);
+ }
+ wmove(dialog, box_y, box_x);
+ }
+ pos--;
+ }
+ continue;
+ case KEY_RIGHT:
+ if (pos < len) {
+ if (input_x < box_width - 1) {
+ wmove(dialog, box_y, ++input_x + box_x);
+ } else if (input_x == box_width - 1) {
+ show_x++;
+ wmove(dialog, box_y, box_x);
+ for (i = 0; i < box_width; i++) {
+ if (!instr[show_x + i]) {
+ waddch(dialog, ' ');
+ break;
+ }
+ waddch(dialog, instr[show_x + i]);
+ }
+ wmove(dialog, box_y, input_x + box_x);
+ }
+ pos++;
+ }
+ continue;
default:
if (key < 0x100 && isprint(key)) {
- if (scroll + input_x < MAX_LEN) {
+ if (len < MAX_LEN) {
wattrset(dialog, dlg.inputbox.atr);
- instr[scroll + input_x] = key;
- instr[scroll + input_x + 1] = '\0';
+ if (pos < len) {
+ for (i = len; i > pos; i--)
+ instr[i] = instr[i-1];
+ instr[pos] = key;
+ } else {
+ instr[len] = key;
+ }
+ pos++;
+ len++;
+ instr[len] = '\0';
+
if (input_x == box_width - 1) {
- scroll++;
- wmove(dialog, box_y, box_x);
- for (i = 0; i < box_width - 1; i++)
- waddch(dialog, instr [scroll + i]);
+ show_x++;
} else {
- wmove(dialog, box_y, input_x++ + box_x);
- waddch(dialog, key);
+ input_x++;
+ }
+
+ wmove(dialog, box_y, box_x);
+ for (i = 0; i < box_width; i++) {
+ if (!instr[show_x + i]) {
+ waddch(dialog, ' ');
+ break;
+ }
+ waddch(dialog, instr[show_x + i]);
}
+ wmove(dialog, box_y, input_x + box_x);
wrefresh(dialog);
} else
flash(); /* Alarm user about overflow */
@@ -180,7 +243,7 @@ do_resize:
case KEY_LEFT:
switch (button) {
case -1:
- button = 1; /* Indicates "Cancel" button is selected */
+ button = 1; /* Indicates "Help" button is selected */
print_buttons(dialog, height, width, 1);
break;
case 0:
@@ -204,7 +267,7 @@ do_resize:
print_buttons(dialog, height, width, 0);
break;
case 0:
- button = 1; /* Indicates "Cancel" button is selected */
+ button = 1; /* Indicates "Help" button is selected */
print_buttons(dialog, height, width, 1);
break;
case 1:
diff --git a/extra/config/lxdialog/menubox.c b/extra/config/lxdialog/menubox.c
index c689fc03b..c93de0b2f 100644
--- a/extra/config/lxdialog/menubox.c
+++ b/extra/config/lxdialog/menubox.c
@@ -154,12 +154,14 @@ static void print_arrows(WINDOW * win, int item_no, int scroll, int y, int x,
*/
static void print_buttons(WINDOW * win, int height, int width, int selected)
{
- int x = width / 2 - 16;
+ int x = width / 2 - 28;
int y = height - 2;
print_button(win, gettext("Select"), y, x, selected == 0);
print_button(win, gettext(" Exit "), y, x + 12, selected == 1);
print_button(win, gettext(" Help "), y, x + 24, selected == 2);
+ print_button(win, gettext(" Save "), y, x + 36, selected == 3);
+ print_button(win, gettext(" Load "), y, x + 48, selected == 4);
wmove(win, y, x + 1 + 12 * selected);
wrefresh(win);
@@ -191,7 +193,7 @@ int dialog_menu(const char *title, const char *prompt,
do_resize:
height = getmaxy(stdscr);
width = getmaxx(stdscr);
- if (height < 15 || width < 65)
+ if (height < MENUBOX_HEIGTH_MIN || width < MENUBOX_WIDTH_MIN)
return -ERRDISPLAYTOOSMALL;
height -= 4;
@@ -201,8 +203,8 @@ do_resize:
max_choice = MIN(menu_height, item_count());
/* center dialog box on screen */
- x = (COLS - width) / 2;
- y = (LINES - height) / 2;
+ x = (getmaxx(stdscr) - width) / 2;
+ y = (getmaxy(stdscr) - height) / 2;
draw_shadow(stdscr, y, x, height, width);
@@ -301,10 +303,11 @@ do_resize:
}
}
- if (i < max_choice ||
- key == KEY_UP || key == KEY_DOWN ||
- key == '-' || key == '+' ||
- key == KEY_PPAGE || key == KEY_NPAGE) {
+ if (item_count() != 0 &&
+ (i < max_choice ||
+ key == KEY_UP || key == KEY_DOWN ||
+ key == '-' || key == '+' ||
+ key == KEY_PPAGE || key == KEY_NPAGE)) {
/* Remove highligt of current item */
print_item(scroll + choice, choice, FALSE);
@@ -372,7 +375,7 @@ do_resize:
case TAB:
case KEY_RIGHT:
button = ((key == KEY_LEFT ? --button : ++button) < 0)
- ? 2 : (button > 2 ? 0 : button);
+ ? 4 : (button > 4 ? 0 : button);
print_buttons(dialog, height, width, button);
wrefresh(menu);
@@ -383,6 +386,10 @@ do_resize:
case 'n':
case 'm':
case '/':
+ case 'h':
+ case '?':
+ case 'z':
+ case '\n':
/* save scroll info */
*s_scroll = scroll;
delwin(menu);
@@ -390,30 +397,26 @@ do_resize:
item_set(scroll + choice);
item_set_selected(1);
switch (key) {
+ case 'h':
+ case '?':
+ return 2;
case 's':
- return 3;
case 'y':
- return 3;
+ return 5;
case 'n':
- return 4;
+ return 6;
case 'm':
- return 5;
+ return 7;
case ' ':
- return 6;
+ return 8;
case '/':
- return 7;
+ return 9;
+ case 'z':
+ return 10;
+ case '\n':
+ return button;
}
return 0;
- case 'h':
- case '?':
- button = 2;
- case '\n':
- *s_scroll = scroll;
- delwin(menu);
- delwin(dialog);
- item_set(scroll + choice);
- item_set_selected(1);
- return button;
case 'e':
case 'x':
key = KEY_ESC;
diff --git a/extra/config/lxdialog/textbox.c b/extra/config/lxdialog/textbox.c
index c704712d0..1773319b9 100644
--- a/extra/config/lxdialog/textbox.c
+++ b/extra/config/lxdialog/textbox.c
@@ -22,23 +22,25 @@
#include "dialog.h"
static void back_lines(int n);
-static void print_page(WINDOW * win, int height, int width);
-static void print_line(WINDOW * win, int row, int width);
+static void print_page(WINDOW *win, int height, int width, update_text_fn
+ update_text, void *data);
+static void print_line(WINDOW *win, int row, int width);
static char *get_line(void);
static void print_position(WINDOW * win);
static int hscroll;
static int begin_reached, end_reached, page_length;
-static const char *buf;
-static const char *page;
+static char *buf;
+static char *page;
/*
* refresh window content
*/
static void refresh_text_box(WINDOW *dialog, WINDOW *box, int boxh, int boxw,
- int cur_y, int cur_x)
+ int cur_y, int cur_x, update_text_fn update_text,
+ void *data)
{
- print_page(box, boxh, boxw);
+ print_page(box, boxh, boxw, update_text, data);
print_position(dialog);
wmove(dialog, cur_y, cur_x); /* Restore cursor position */
wrefresh(dialog);
@@ -47,14 +49,18 @@ static void refresh_text_box(WINDOW *dialog, WINDOW *box, int boxh, int boxw,
/*
* Display text from a file in a dialog box.
+ *
+ * keys is a null-terminated array
+ * update_text() may not add or remove any '\n' or '\0' in tbuf
*/
-int dialog_textbox(const char *title, const char *tbuf,
- int initial_height, int initial_width)
+int dialog_textbox(const char *title, char *tbuf, int initial_height,
+ int initial_width, int *keys, int *_vscroll, int *_hscroll,
+ update_text_fn update_text, void *data)
{
int i, x, y, cur_x, cur_y, key = 0;
int height, width, boxh, boxw;
- int passed_end;
WINDOW *dialog, *box;
+ bool done = false;
begin_reached = 1;
end_reached = 0;
@@ -63,9 +69,18 @@ int dialog_textbox(const char *title, const char *tbuf,
buf = tbuf;
page = buf; /* page is pointer to start of page to be displayed */
+ if (_vscroll && *_vscroll) {
+ begin_reached = 0;
+
+ for (i = 0; i < *_vscroll; i++)
+ get_line();
+ }
+ if (_hscroll)
+ hscroll = *_hscroll;
+
do_resize:
getmaxyx(stdscr, height, width);
- if (height < 8 || width < 8)
+ if (height < TEXTBOX_HEIGTH_MIN || width < TEXTBOX_WIDTH_MIN)
return -ERRDISPLAYTOOSMALL;
if (initial_height != 0)
height = initial_height;
@@ -83,8 +98,8 @@ do_resize:
width = 0;
/* center dialog box on screen */
- x = (COLS - width) / 2;
- y = (LINES - height) / 2;
+ x = (getmaxx(stdscr) - width) / 2;
+ y = (getmaxy(stdscr) - height) / 2;
draw_shadow(stdscr, y, x, height, width);
@@ -120,25 +135,28 @@ do_resize:
/* Print first page of text */
attr_clear(box, boxh, boxw, dlg.dialog.atr);
- refresh_text_box(dialog, box, boxh, boxw, cur_y, cur_x);
+ refresh_text_box(dialog, box, boxh, boxw, cur_y, cur_x, update_text,
+ data);
- while ((key != KEY_ESC) && (key != '\n')) {
+ while (!done) {
key = wgetch(dialog);
switch (key) {
case 'E': /* Exit */
case 'e':
case 'X':
case 'x':
- delwin(box);
- delwin(dialog);
- return 0;
+ case 'q':
+ case '\n':
+ done = true;
+ break;
case 'g': /* First page */
case KEY_HOME:
if (!begin_reached) {
begin_reached = 1;
page = buf;
refresh_text_box(dialog, box, boxh, boxw,
- cur_y, cur_x);
+ cur_y, cur_x, update_text,
+ data);
}
break;
case 'G': /* Last page */
@@ -148,78 +166,48 @@ do_resize:
/* point to last char in buf */
page = buf + strlen(buf);
back_lines(boxh);
- refresh_text_box(dialog, box, boxh, boxw,
- cur_y, cur_x);
+ refresh_text_box(dialog, box, boxh, boxw, cur_y,
+ cur_x, update_text, data);
break;
case 'K': /* Previous line */
case 'k':
case KEY_UP:
- if (!begin_reached) {
- back_lines(page_length + 1);
-
- /* We don't call print_page() here but use
- * scrolling to ensure faster screen update.
- * However, 'end_reached' and 'page_length'
- * should still be updated, and 'page' should
- * point to start of next page. This is done
- * by calling get_line() in the following
- * 'for' loop. */
- scrollok(box, TRUE);
- wscrl(box, -1); /* Scroll box region down one line */
- scrollok(box, FALSE);
- page_length = 0;
- passed_end = 0;
- for (i = 0; i < boxh; i++) {
- if (!i) {
- /* print first line of page */
- print_line(box, 0, boxw);
- wnoutrefresh(box);
- } else
- /* Called to update 'end_reached' and 'page' */
- get_line();
- if (!passed_end)
- page_length++;
- if (end_reached && !passed_end)
- passed_end = 1;
- }
+ if (begin_reached)
+ break;
- print_position(dialog);
- wmove(dialog, cur_y, cur_x); /* Restore cursor position */
- wrefresh(dialog);
- }
+ back_lines(page_length + 1);
+ refresh_text_box(dialog, box, boxh, boxw, cur_y,
+ cur_x, update_text, data);
break;
case 'B': /* Previous page */
case 'b':
+ case 'u':
case KEY_PPAGE:
if (begin_reached)
break;
back_lines(page_length + boxh);
- refresh_text_box(dialog, box, boxh, boxw,
- cur_y, cur_x);
+ refresh_text_box(dialog, box, boxh, boxw, cur_y,
+ cur_x, update_text, data);
break;
case 'J': /* Next line */
case 'j':
case KEY_DOWN:
- if (!end_reached) {
- begin_reached = 0;
- scrollok(box, TRUE);
- scroll(box); /* Scroll box region up one line */
- scrollok(box, FALSE);
- print_line(box, boxh - 1, boxw);
- wnoutrefresh(box);
- print_position(dialog);
- wmove(dialog, cur_y, cur_x); /* Restore cursor position */
- wrefresh(dialog);
- }
+ if (end_reached)
+ break;
+
+ back_lines(page_length - 1);
+ refresh_text_box(dialog, box, boxh, boxw, cur_y,
+ cur_x, update_text, data);
break;
case KEY_NPAGE: /* Next page */
case ' ':
+ case 'd':
if (end_reached)
break;
begin_reached = 0;
- refresh_text_box(dialog, box, boxh, boxw,
- cur_y, cur_x);
+ refresh_text_box(dialog, box, boxh, boxw, cur_y,
+ cur_x, update_text, data);
break;
case '0': /* Beginning of line */
case 'H': /* Scroll left */
@@ -234,8 +222,8 @@ do_resize:
hscroll--;
/* Reprint current page to scroll horizontally */
back_lines(page_length);
- refresh_text_box(dialog, box, boxh, boxw,
- cur_y, cur_x);
+ refresh_text_box(dialog, box, boxh, boxw, cur_y,
+ cur_x, update_text, data);
break;
case 'L': /* Scroll right */
case 'l':
@@ -245,11 +233,12 @@ do_resize:
hscroll++;
/* Reprint current page to scroll horizontally */
back_lines(page_length);
- refresh_text_box(dialog, box, boxh, boxw,
- cur_y, cur_x);
+ refresh_text_box(dialog, box, boxh, boxw, cur_y,
+ cur_x, update_text, data);
break;
case KEY_ESC:
- key = on_key_esc(dialog);
+ if (on_key_esc(dialog) == KEY_ESC)
+ done = true;
break;
case KEY_RESIZE:
back_lines(height);
@@ -257,11 +246,31 @@ do_resize:
delwin(dialog);
on_key_resize();
goto do_resize;
+ default:
+ for (i = 0; keys[i]; i++) {
+ if (key == keys[i]) {
+ done = true;
+ break;
+ }
+ }
}
}
delwin(box);
delwin(dialog);
- return key; /* ESC pressed */
+ if (_vscroll) {
+ const char *s;
+
+ s = buf;
+ *_vscroll = 0;
+ back_lines(page_length);
+ while (s < page && (s = strchr(s, '\n'))) {
+ (*_vscroll)++;
+ s++;
+ }
+ }
+ if (_hscroll)
+ *_hscroll = hscroll;
+ return key;
}
/*
@@ -298,12 +307,23 @@ static void back_lines(int n)
}
/*
- * Print a new page of text. Called by dialog_textbox().
+ * Print a new page of text.
*/
-static void print_page(WINDOW * win, int height, int width)
+static void print_page(WINDOW *win, int height, int width, update_text_fn
+ update_text, void *data)
{
int i, passed_end = 0;
+ if (update_text) {
+ char *end;
+
+ for (i = 0; i < height; i++)
+ get_line();
+ end = page;
+ back_lines(height);
+ update_text(buf, page - buf, end - buf, data);
+ }
+
page_length = 0;
for (i = 0; i < height; i++) {
print_line(win, i, width);
@@ -316,11 +336,10 @@ static void print_page(WINDOW * win, int height, int width)
}
/*
- * Print a new line of text. Called by dialog_textbox() and print_page().
+ * Print a new line of text.
*/
static void print_line(WINDOW * win, int row, int width)
{
- int y, x;
char *line;
line = get_line();
@@ -329,10 +348,10 @@ static void print_line(WINDOW * win, int row, int width)
waddch(win, ' ');
waddnstr(win, line, MIN(strlen(line), width - 2));
- getyx(win, y, x);
/* Clear 'residue' of previous line */
#if OLD_NCURSES
{
+ int x = getcurx(win);
int i;
for (i = 0; i < width - x; i++)
waddch(win, ' ');
@@ -355,10 +374,8 @@ static char *get_line(void)
end_reached = 0;
while (*page != '\n') {
if (*page == '\0') {
- if (!end_reached) {
- end_reached = 1;
- break;
- }
+ end_reached = 1;
+ break;
} else if (i < MAX_LEN)
line[i++] = *(page++);
else {
@@ -371,7 +388,7 @@ static char *get_line(void)
if (i <= MAX_LEN)
line[i] = '\0';
if (!end_reached)
- page++; /* move pass '\n' */
+ page++; /* move past '\n' */
return line;
}
diff --git a/extra/config/lxdialog/util.c b/extra/config/lxdialog/util.c
index 86d95cca4..58a8289dd 100644
--- a/extra/config/lxdialog/util.c
+++ b/extra/config/lxdialog/util.c
@@ -19,8 +19,13 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#include <stdarg.h>
+
#include "dialog.h"
+/* Needed in signal handler in mconf.c */
+int saved_x, saved_y;
+
struct dialog_info dlg;
static void set_mono_theme(void)
@@ -249,15 +254,56 @@ void attr_clear(WINDOW * win, int height, int width, chtype attr)
void dialog_clear(void)
{
- attr_clear(stdscr, LINES, COLS, dlg.screen.atr);
+ int lines, columns;
+
+ lines = getmaxy(stdscr);
+ columns = getmaxx(stdscr);
+
+ attr_clear(stdscr, lines, columns, dlg.screen.atr);
/* Display background title if it exists ... - SLH */
if (dlg.backtitle != NULL) {
- int i;
+ int i, len = 0, skip = 0;
+ struct subtitle_list *pos;
wattrset(stdscr, dlg.screen.atr);
mvwaddstr(stdscr, 0, 1, (char *)dlg.backtitle);
+
+ for (pos = dlg.subtitles; pos != NULL; pos = pos->next) {
+ /* 3 is for the arrow and spaces */
+ len += strlen(pos->text) + 3;
+ }
+
wmove(stdscr, 1, 1);
- for (i = 1; i < COLS - 1; i++)
+ if (len > columns - 2) {
+ const char *ellipsis = "[...] ";
+ waddstr(stdscr, ellipsis);
+ skip = len - (columns - 2 - strlen(ellipsis));
+ }
+
+ for (pos = dlg.subtitles; pos != NULL; pos = pos->next) {
+ if (skip == 0)
+ waddch(stdscr, ACS_RARROW);
+ else
+ skip--;
+
+ if (skip == 0)
+ waddch(stdscr, ' ');
+ else
+ skip--;
+
+ if (skip < strlen(pos->text)) {
+ waddstr(stdscr, pos->text + skip);
+ skip = 0;
+ } else
+ skip -= strlen(pos->text);
+
+ if (skip == 0)
+ waddch(stdscr, ' ');
+ else
+ skip--;
+ }
+
+ for (i = len + 1; i < columns - 1; i++)
waddch(stdscr, ACS_HLINE);
}
wnoutrefresh(stdscr);
@@ -271,8 +317,12 @@ int init_dialog(const char *backtitle)
int height, width;
initscr(); /* Init curses */
+
+ /* Get current cursor position for signal handler in mconf.c */
+ getyx(stdscr, saved_y, saved_x);
+
getmaxyx(stdscr, height, width);
- if (height < 19 || width < 80) {
+ if (height < WINDOW_HEIGTH_MIN || width < WINDOW_WIDTH_MIN) {
endwin();
return -ERRDISPLAYTOOSMALL;
}
@@ -293,6 +343,11 @@ void set_dialog_backtitle(const char *backtitle)
dlg.backtitle = backtitle;
}
+void set_dialog_subtitles(struct subtitle_list *subtitles)
+{
+ dlg.subtitles = subtitles;
+}
+
/*
* End using dialog functions.
*/
@@ -321,27 +376,19 @@ void print_title(WINDOW *dialog, const char *title, int width)
/*
* Print a string of text in a window, automatically wrap around to the
* next line if the string is too long to fit on one line. Newline
- * characters '\n' are replaced by spaces. We start on a new line
+ * characters '\n' are propperly processed. We start on a new line
* if there is no room for at least 4 nonblanks following a double-space.
*/
void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)
{
int newl, cur_x, cur_y;
- int i, prompt_len, room, wlen;
- char tempstr[MAX_LEN + 1], *word, *sp, *sp2;
+ int prompt_len, room, wlen;
+ char tempstr[MAX_LEN + 1], *word, *sp, *sp2, *newline_separator = 0;
strcpy(tempstr, prompt);
prompt_len = strlen(tempstr);
- /*
- * Remove newlines
- */
- for (i = 0; i < prompt_len; i++) {
- if (tempstr[i] == '\n')
- tempstr[i] = ' ';
- }
-
if (prompt_len <= width - x * 2) { /* If prompt is short */
wmove(win, y, (width - prompt_len) / 2);
waddstr(win, tempstr);
@@ -351,7 +398,10 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)
newl = 1;
word = tempstr;
while (word && *word) {
- sp = strchr(word, ' ');
+ sp = strpbrk(word, "\n ");
+ if (sp && *sp == '\n')
+ newline_separator = sp;
+
if (sp)
*sp++ = 0;
@@ -363,7 +413,7 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)
if (wlen > room ||
(newl && wlen < 4 && sp
&& wlen + 1 + strlen(sp) > room
- && (!(sp2 = strchr(sp, ' '))
+ && (!(sp2 = strpbrk(sp, "\n "))
|| wlen + 1 + (sp2 - sp) > room))) {
cur_y++;
cur_x = x;
@@ -371,7 +421,15 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)
wmove(win, cur_y, cur_x);
waddstr(win, word);
getyx(win, cur_y, cur_x);
- cur_x++;
+
+ /* Move to the next line if the word separator was a newline */
+ if (newline_separator) {
+ cur_y++;
+ cur_x = x;
+ newline_separator = 0;
+ } else
+ cur_x++;
+
if (sp && *sp == ' ') {
cur_x++; /* double space */
while (*++sp == ' ') ;
diff --git a/extra/config/lxdialog/yesno.c b/extra/config/lxdialog/yesno.c
index 4e6e8090c..676fb2f82 100644
--- a/extra/config/lxdialog/yesno.c
+++ b/extra/config/lxdialog/yesno.c
@@ -45,14 +45,14 @@ int dialog_yesno(const char *title, const char *prompt, int height, int width)
WINDOW *dialog;
do_resize:
- if (getmaxy(stdscr) < (height + 4))
+ if (getmaxy(stdscr) < (height + YESNO_HEIGTH_MIN))
return -ERRDISPLAYTOOSMALL;
- if (getmaxx(stdscr) < (width + 4))
+ if (getmaxx(stdscr) < (width + YESNO_WIDTH_MIN))
return -ERRDISPLAYTOOSMALL;
/* center dialog box on screen */
- x = (COLS - width) / 2;
- y = (LINES - height) / 2;
+ x = (getmaxx(stdscr) - width) / 2;
+ y = (getmaxy(stdscr) - height) / 2;
draw_shadow(stdscr, y, x, height, width);
diff --git a/extra/config/mconf.c b/extra/config/mconf.c
index 3effa5b5b..fcf6478ec 100644
--- a/extra/config/mconf.c
+++ b/extra/config/mconf.c
@@ -15,20 +15,19 @@
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
+#include <signal.h>
#include <unistd.h>
#include <locale.h>
-#define LKC_DIRECT_LINK
#include "lkc.h"
#include "lxdialog/dialog.h"
static const char mconf_readme[] = N_(
"Overview\n"
"--------\n"
-"Some features may be built directly into uClibc. Some features\n"
-"may be completely removed altogether. There are also certain\n"
-"parameters which are not really features, but must be\n"
-"entered in as decimal or hexadecimal numbers or possibly text.\n"
+"This interface let you select features and parameters for the build.\n"
+"Features can either be built-in, modularized, or ignored. Parameters\n"
+"must be entered in as decimal or hexadecimal numbers or text.\n"
"\n"
"Menu items beginning with following braces represent features that\n"
" [ ] can be built in or removed\n"
@@ -49,7 +48,7 @@ static const char mconf_readme[] = N_(
"----------\n"
"o Use the Up/Down arrow keys (cursor keys) to highlight the item\n"
" you wish to change or submenu wish to select and press <Enter>.\n"
-" Submenus are designated by \"--->\".\n"
+" Submenus are designated by \"--->\", empty ones by \"----\".\n"
"\n"
" Shortcut: Press the option's highlighted letter (hotkey).\n"
" Pressing a hotkey more than once will sequence\n"
@@ -66,13 +65,15 @@ static const char mconf_readme[] = N_(
" there is a delayed response which you may find annoying.\n"
"\n"
" Also, the <TAB> and cursor keys will cycle between <Select>,\n"
-" <Exit> and <Help>\n"
+" <Exit> and <Help>.\n"
"\n"
"o To get help with an item, use the cursor keys to highlight <Help>\n"
-" and Press <ENTER>.\n"
+" and press <ENTER>.\n"
"\n"
" Shortcut: Press <H> or <?>.\n"
"\n"
+"o To toggle the display of hidden options, press <Z>.\n"
+"\n"
"\n"
"Radiolists (Choice lists)\n"
"-----------\n"
@@ -104,10 +105,10 @@ static const char mconf_readme[] = N_(
"Text Box (Help Window)\n"
"--------\n"
"o Use the cursor keys to scroll up/down/left/right. The VI editor\n"
-" keys h,j,k,l function here as do <SPACE BAR> and <B> for those\n"
-" who are familiar with less and lynx.\n"
+" keys h,j,k,l function here as do <u>, <d>, <SPACE BAR> and <B> for \n"
+" those who are familiar with less and lynx.\n"
"\n"
-"o Press <E>, <X>, <Enter> or <Esc><Esc> to exit.\n"
+"o Press <E>, <X>, <q>, <Enter> or <Esc><Esc> to exit.\n"
"\n"
"\n"
"Alternate Configuration Files\n"
@@ -147,9 +148,9 @@ static const char mconf_readme[] = N_(
"\n"
"Optional personality available\n"
"------------------------------\n"
-"If you prefer to have all of the options listed in a single\n"
-"menu, rather than the default multimenu hierarchy, run the menuconfig\n"
-"with MENUCONFIG_MODE environment variable set to single_menu. Example:\n"
+"If you prefer to have all of the options listed in a single menu, rather\n"
+"than the default multimenu hierarchy, run the menuconfig with\n"
+"MENUCONFIG_MODE environment variable set to single_menu. Example:\n"
"\n"
"make MENUCONFIG_MODE=single_menu menuconfig\n"
"\n"
@@ -175,11 +176,11 @@ static const char mconf_readme[] = N_(
"\n"),
menu_instructions[] = N_(
"Arrow keys navigate the menu. "
- "<Enter> selects submenus --->. "
+ "<Enter> selects submenus ---> (or empty submenus ----). "
"Highlighted letters are hotkeys. "
- "Pressing <Y> selectes a feature, while <N> will exclude a feature. "
+ "Pressing <Y> includes, <N> excludes, <M> modularizes features. "
"Press <Esc><Esc> to exit, <?> for Help, </> for Search. "
- "Legend: [*] feature is selected [ ] feature is excluded"),
+ "Legend: [*] built-in [ ] excluded <M> module < > module capable"),
radiolist_instructions[] = N_(
"Use the arrow keys to navigate this window or "
"press the hotkey of the item you wish to select "
@@ -198,8 +199,6 @@ inputbox_instructions_string[] = N_(
setmod_text[] = N_(
"This feature depends on another which has been configured as a module.\n"
"As a result, this feature will be built as a module."),
-nohelp_text[] = N_(
- "There is no help available for this option.\n"),
load_config_text[] = N_(
"Enter the name of the configuration file you wish to load. "
"Accept the name shown to restore the configuration you "
@@ -210,18 +209,18 @@ load_config_help[] = N_(
"configurations available on a single machine.\n"
"\n"
"If you have saved a previous configuration in a file other than the\n"
- "default, entering the name of the file here will allow you\n"
- "to modify that configuration.\n"
+ "default one, entering its name here will allow you to modify that\n"
+ "configuration.\n"
"\n"
"If you are uncertain, then you have probably never used alternate\n"
- "configuration files. You should therefor leave this blank to abort.\n"),
+ "configuration files. You should therefore leave this blank to abort.\n"),
save_config_text[] = N_(
"Enter a filename to which this configuration should be saved "
"as an alternate. Leave blank to abort."),
save_config_help[] = N_(
"\n"
- "For various reasons, one may wish to keep different\n"
- "configurations available on a single machine.\n"
+ "For various reasons, one may wish to keep different configurations\n"
+ "available on a single machine.\n"
"\n"
"Entering a file name here will allow you to later retrieve, modify\n"
"and use the current configuration as an alternate to whatever\n"
@@ -231,32 +230,39 @@ save_config_help[] = N_(
"leave this blank.\n"),
search_help[] = N_(
"\n"
- "Search for CONFIG_ symbols and display their relations.\n"
+ "Search for symbols and display their relations.\n"
"Regular expressions are allowed.\n"
"Example: search for \"^FOO\"\n"
"Result:\n"
"-----------------------------------------------------------------\n"
"Symbol: FOO [=m]\n"
+ "Type : tristate\n"
"Prompt: Foo bus is used to drive the bar HW\n"
- "Defined at drivers/pci/Kconfig:47\n"
- "Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n"
- "Location:\n"
- " -> Bus options (PCI, PCMCIA, EISA, MCA, ISA)\n"
- " -> PCI support (PCI [=y])\n"
- " -> PCI access mode (<choice> [=y])\n"
- "Selects: LIBCRC32\n"
- "Selected by: BAR\n"
+ " Defined at drivers/pci/Kconfig:47\n"
+ " Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n"
+ " Location:\n"
+ " -> Bus options (PCI, PCMCIA, EISA, ISA)\n"
+ " -> PCI support (PCI [=y])\n"
+ "(1) -> PCI access mode (<choice> [=y])\n"
+ " Selects: LIBCRC32\n"
+ " Selected by: BAR\n"
"-----------------------------------------------------------------\n"
+ "o The line 'Type:' shows the type of the configuration option for\n"
+ " this symbol (boolean, tristate, string, ...)\n"
"o The line 'Prompt:' shows the text used in the menu structure for\n"
- " this CONFIG_ symbol\n"
+ " this symbol\n"
"o The 'Defined at' line tell at what file / line number the symbol\n"
" is defined\n"
"o The 'Depends on:' line tell what symbols needs to be defined for\n"
" this symbol to be visible in the menu (selectable)\n"
"o The 'Location:' lines tell where in the menu structure this symbol\n"
" is located\n"
- " A location followed by a [=y] indicate that this is a selectable\n"
- " menu item - and current value is displayed inside brackets.\n"
+ " A location followed by a [=y] indicates that this is a\n"
+ " selectable menu item - and the current value is displayed inside\n"
+ " brackets.\n"
+ " Press the key in the (#) prefix to jump directly to that\n"
+ " location. You will be returned to the current search results\n"
+ " after exiting this new menu.\n"
"o The 'Selects:' line tell what symbol will be automatically\n"
" selected if this symbol is selected (y or m)\n"
"o The 'Selected by' line tell what symbol has selected this symbol\n"
@@ -264,131 +270,144 @@ search_help[] = N_(
"Only relevant lines are shown.\n"
"\n\n"
"Search examples:\n"
- "Examples: USB => find all CONFIG_ symbols containing USB\n"
- " ^USB => find all CONFIG_ symbols starting with USB\n"
- " USB$ => find all CONFIG_ symbols ending with USB\n"
+ "Examples: USB => find all symbols containing USB\n"
+ " ^USB => find all symbols starting with USB\n"
+ " USB$ => find all symbols ending with USB\n"
"\n");
static int indent;
static struct menu *current_menu;
static int child_count;
static int single_menu_mode;
+static int show_all_options;
+static int save_and_exit;
-static void conf(struct menu *menu);
+static void conf(struct menu *menu, struct menu *active_menu);
static void conf_choice(struct menu *menu);
static void conf_string(struct menu *menu);
static void conf_load(void);
static void conf_save(void);
+static int show_textbox_ext(const char *title, char *text, int r, int c,
+ int *keys, int *vscroll, int *hscroll,
+ update_text_fn update_text, void *data);
static void show_textbox(const char *title, const char *text, int r, int c);
static void show_helptext(const char *title, const char *text);
static void show_help(struct menu *menu);
-static void get_prompt_str(struct gstr *r, struct property *prop)
+static char filename[PATH_MAX+1];
+static void set_config_filename(const char *config_filename)
{
- int i, j;
- struct menu *submenu[8], *menu;
-
- str_printf(r, _("Prompt: %s\n"), _(prop->text));
- str_printf(r, _(" Defined at %s:%d\n"), prop->menu->file->name,
- prop->menu->lineno);
- if (!expr_is_yes(prop->visible.expr)) {
- str_append(r, _(" Depends on: "));
- expr_gstr_print(prop->visible.expr, r);
- str_append(r, "\n");
+ static char menu_backtitle[PATH_MAX+128];
+ int size;
+
+ size = snprintf(menu_backtitle, sizeof(menu_backtitle),
+ "%s - %s", config_filename, rootmenu.prompt->text);
+ if (size >= sizeof(menu_backtitle))
+ menu_backtitle[sizeof(menu_backtitle)-1] = '\0';
+ set_dialog_backtitle(menu_backtitle);
+
+ size = snprintf(filename, sizeof(filename), "%s", config_filename);
+ if (size >= sizeof(filename))
+ filename[sizeof(filename)-1] = '\0';
+}
+
+struct subtitle_part {
+ struct list_head entries;
+ const char *text;
+};
+static LIST_HEAD(trail);
+
+static struct subtitle_list *subtitles;
+static void set_subtitle(void)
+{
+ struct subtitle_part *sp;
+ struct subtitle_list *pos, *tmp;
+
+ for (pos = subtitles; pos != NULL; pos = tmp) {
+ tmp = pos->next;
+ free(pos);
}
- menu = prop->menu->parent;
- for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent)
- submenu[i++] = menu;
- if (i > 0) {
- str_printf(r, _(" Location:\n"));
- for (j = 4; --i >= 0; j += 2) {
- menu = submenu[i];
- str_printf(r, "%*c-> %s", j, ' ', _(menu_get_prompt(menu)));
- if (menu->sym) {
- str_printf(r, " (%s [=%s])", menu->sym->name ?
- menu->sym->name : _("<choice>"),
- sym_get_string_value(menu->sym));
+
+ subtitles = NULL;
+ list_for_each_entry(sp, &trail, entries) {
+ if (sp->text) {
+ if (pos) {
+ pos->next = xcalloc(sizeof(*pos), 1);
+ pos = pos->next;
+ } else {
+ subtitles = pos = xcalloc(sizeof(*pos), 1);
}
- str_append(r, "\n");
+ pos->text = sp->text;
}
}
+
+ set_dialog_subtitles(subtitles);
}
-static void get_symbol_str(struct gstr *r, struct symbol *sym)
+static void reset_subtitle(void)
{
- bool hit;
- struct property *prop;
+ struct subtitle_list *pos, *tmp;
- if (sym && sym->name)
- str_printf(r, "Symbol: %s [=%s]\n", sym->name,
- sym_get_string_value(sym));
- for_all_prompts(sym, prop)
- get_prompt_str(r, prop);
- hit = false;
- for_all_properties(sym, prop, P_SELECT) {
- if (!hit) {
- str_append(r, " Selects: ");
- hit = true;
- } else
- str_printf(r, " && ");
- expr_gstr_print(prop->expr, r);
+ for (pos = subtitles; pos != NULL; pos = tmp) {
+ tmp = pos->next;
+ free(pos);
}
- if (hit)
- str_append(r, "\n");
- if (sym->rev_dep.expr) {
- str_append(r, _(" Selected by: "));
- expr_gstr_print(sym->rev_dep.expr, r);
- str_append(r, "\n");
- }
- str_append(r, "\n\n");
+ subtitles = NULL;
+ set_dialog_subtitles(subtitles);
}
-static struct gstr get_relations_str(struct symbol **sym_arr)
+struct search_data {
+ struct list_head *head;
+ struct menu **targets;
+ int *keys;
+};
+
+static void update_text(char *buf, size_t start, size_t end, void *_data)
{
- struct symbol *sym;
- struct gstr res = str_new();
- int i;
+ struct search_data *data = _data;
+ struct jump_key *pos;
+ int k = 0;
- for (i = 0; sym_arr && (sym = sym_arr[i]); i++)
- get_symbol_str(&res, sym);
- if (!i)
- str_append(&res, _("No matches found.\n"));
- return res;
-}
+ list_for_each_entry(pos, data->head, entries) {
+ if (pos->offset >= start && pos->offset < end) {
+ char header[4];
-static char filename[PATH_MAX+1];
-static void set_config_filename(const char *config_filename)
-{
- static char menu_backtitle[PATH_MAX+128];
- int size;
- struct symbol *sym;
+ if (k < JUMP_NB) {
+ int key = '0' + (pos->index % JUMP_NB) + 1;
- sym = sym_lookup("VERSION", 0);
- sym_calc_value(sym);
- size = snprintf(menu_backtitle, sizeof(menu_backtitle),
- _("%s - uClibc v%s Configuration"),
- config_filename, sym_get_string_value(sym));
- if (size >= sizeof(menu_backtitle))
- menu_backtitle[sizeof(menu_backtitle)-1] = '\0';
- set_dialog_backtitle(menu_backtitle);
+ sprintf(header, "(%c)", key);
+ data->keys[k] = key;
+ data->targets[k] = pos->target;
+ k++;
+ } else {
+ sprintf(header, " ");
+ }
- size = snprintf(filename, sizeof(filename), "%s", config_filename);
- if (size >= sizeof(filename))
- filename[sizeof(filename)-1] = '\0';
+ memcpy(buf + pos->offset, header, sizeof(header) - 1);
+ }
+ }
+ data->keys[k] = 0;
}
-
static void search_conf(void)
{
struct symbol **sym_arr;
struct gstr res;
+ struct gstr title;
char *dialog_input;
- int dres;
+ int dres, vscroll = 0, hscroll = 0;
+ bool again;
+ struct gstr sttext;
+ struct subtitle_part stpart;
+
+ title = str_new();
+ str_printf( &title, _("Enter %s (sub)string or regexp to search for "
+ "(with or without \"%s\")"), CONFIG_, CONFIG_);
+
again:
dialog_clear();
dres = dialog_inputbox(_("Search Configuration Parameter"),
- _("Enter CONFIG_ (sub)string to search for "
- "(with or without \"CONFIG\")"),
+ str_get(&title),
10, 75, "");
switch (dres) {
case 0:
@@ -397,19 +416,52 @@ again:
show_helptext(_("Search Configuration"), search_help);
goto again;
default:
+ str_free(&title);
return;
}
- /* strip CONFIG_ if necessary */
+ /* strip the prefix if necessary */
dialog_input = dialog_input_result;
- if (strncasecmp(dialog_input_result, "CONFIG_", 7) == 0)
- dialog_input += 7;
+ if (strncasecmp(dialog_input_result, CONFIG_, strlen(CONFIG_)) == 0)
+ dialog_input += strlen(CONFIG_);
+
+ sttext = str_new();
+ str_printf(&sttext, "Search (%s)", dialog_input_result);
+ stpart.text = str_get(&sttext);
+ list_add_tail(&stpart.entries, &trail);
sym_arr = sym_re_search(dialog_input);
- res = get_relations_str(sym_arr);
+ do {
+ LIST_HEAD(head);
+ struct menu *targets[JUMP_NB];
+ int keys[JUMP_NB + 1], i;
+ struct search_data data = {
+ .head = &head,
+ .targets = targets,
+ .keys = keys,
+ };
+ struct jump_key *pos, *tmp;
+
+ res = get_relations_str(sym_arr, &head);
+ set_subtitle();
+ dres = show_textbox_ext(_("Search Results"), (char *)
+ str_get(&res), 0, 0, keys, &vscroll,
+ &hscroll, &update_text, (void *)
+ &data);
+ again = false;
+ for (i = 0; i < JUMP_NB && keys[i]; i++)
+ if (dres == keys[i]) {
+ conf(targets[i]->parent, targets[i]);
+ again = true;
+ }
+ str_free(&res);
+ list_for_each_entry_safe(pos, tmp, &head, entries)
+ free(pos);
+ } while (again);
free(sym_arr);
- show_textbox(_("Search Results"), str_get(&res), 0, 0);
- str_free(&res);
+ str_free(&title);
+ list_del(trail.prev);
+ str_free(&sttext);
}
static void build_conf(struct menu *menu)
@@ -420,8 +472,16 @@ static void build_conf(struct menu *menu)
int type, tmp, doint = 2;
tristate val;
char ch;
+ bool visible;
- if (!menu_is_visible(menu))
+ /*
+ * note: menu_is_visible() has side effect that it will
+ * recalc the value of the symbol.
+ */
+ visible = menu_is_visible(menu);
+ if (show_all_options && !menu_has_prompt(menu))
+ return;
+ else if (!show_all_options && !visible)
return;
sym = menu->sym;
@@ -438,8 +498,9 @@ static void build_conf(struct menu *menu)
menu->data ? "-->" : "++>",
indent + 1, ' ', prompt);
} else
- item_make(" %*c%s --->", indent + 1, ' ', prompt);
-
+ item_make(" %*c%s %s",
+ indent + 1, ' ', prompt,
+ menu_is_empty(menu) ? "----" : "--->");
item_set_tag('m');
item_set_data(menu);
if (single_menu_mode && menu->data)
@@ -570,7 +631,7 @@ static void build_conf(struct menu *menu)
(sym_has_value(sym) || !sym_is_changable(sym)) ?
"" : _(" (NEW)"));
if (menu->prompt->type == P_MENU) {
- item_add_str(" --->");
+ item_add_str(" %s", menu_is_empty(menu) ? "----" : "--->");
return;
}
}
@@ -582,40 +643,40 @@ conf_childs:
indent -= doint;
}
-static void conf(struct menu *menu)
+static void conf(struct menu *menu, struct menu *active_menu)
{
struct menu *submenu;
const char *prompt = menu_get_prompt(menu);
+ struct subtitle_part stpart;
struct symbol *sym;
- struct menu *active_menu = NULL;
int res;
int s_scroll = 0;
+ if (menu != &rootmenu)
+ stpart.text = menu_get_prompt(menu);
+ else
+ stpart.text = NULL;
+ list_add_tail(&stpart.entries, &trail);
+
while (1) {
item_reset();
current_menu = menu;
build_conf(menu);
if (!child_count)
break;
- if (menu == &rootmenu) {
- item_make("--- ");
- item_set_tag(':');
- item_make(_(" Load an Alternate Configuration File"));
- item_set_tag('L');
- item_make(_(" Save an Alternate Configuration File"));
- item_set_tag('S');
- }
+ set_subtitle();
dialog_clear();
res = dialog_menu(prompt ? _(prompt) : _("Main Menu"),
_(menu_instructions),
active_menu, &s_scroll);
if (res == 1 || res == KEY_ESC || res == -ERRDISPLAYTOOSMALL)
break;
- if (!item_activate_selected())
- continue;
- if (!item_tag())
- continue;
-
+ if (item_count() != 0) {
+ if (!item_activate_selected())
+ continue;
+ if (!item_tag())
+ continue;
+ }
submenu = item_data();
active_menu = item_data();
if (submenu)
@@ -630,32 +691,36 @@ static void conf(struct menu *menu)
if (single_menu_mode)
submenu->data = (void *) (long) !submenu->data;
else
- conf(submenu);
+ conf(submenu, NULL);
break;
case 't':
if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)
conf_choice(submenu);
else if (submenu->prompt->type == P_MENU)
- conf(submenu);
+ conf(submenu, NULL);
break;
case 's':
conf_string(submenu);
break;
- case 'L':
- conf_load();
- break;
- case 'S':
- conf_save();
- break;
}
break;
case 2:
if (sym)
show_help(submenu);
- else
+ else {
+ reset_subtitle();
show_helptext(_("README"), _(mconf_readme));
+ }
break;
case 3:
+ reset_subtitle();
+ conf_save();
+ break;
+ case 4:
+ reset_subtitle();
+ conf_load();
+ break;
+ case 5:
if (item_is_tag('t')) {
if (sym_set_tristate_value(sym, yes))
break;
@@ -663,31 +728,45 @@ static void conf(struct menu *menu)
show_textbox(NULL, setmod_text, 6, 74);
}
break;
- case 4:
+ case 6:
if (item_is_tag('t'))
sym_set_tristate_value(sym, no);
break;
- case 5:
+ case 7:
if (item_is_tag('t'))
sym_set_tristate_value(sym, mod);
break;
- case 6:
+ case 8:
if (item_is_tag('t'))
sym_toggle_tristate_value(sym);
else if (item_is_tag('m'))
- conf(submenu);
+ conf(submenu, NULL);
break;
- case 7:
+ case 9:
search_conf();
break;
+ case 10:
+ show_all_options = !show_all_options;
+ break;
}
}
+
+ list_del(trail.prev);
}
-static void show_textbox(const char *title, const char *text, int r, int c)
+static int show_textbox_ext(const char *title, char *text, int r, int c, int
+ *keys, int *vscroll, int *hscroll, update_text_fn
+ update_text, void *data)
{
dialog_clear();
- dialog_textbox(title, text, r, c);
+ return dialog_textbox(title, text, r, c, keys, vscroll, hscroll,
+ update_text, data);
+}
+
+static void show_textbox(const char *title, const char *text, int r, int c)
+{
+ show_textbox_ext(title, (char *) text, r, c, (int []) {0}, NULL, NULL,
+ NULL, NULL);
}
static void show_helptext(const char *title, const char *text)
@@ -695,22 +774,24 @@ static void show_helptext(const char *title, const char *text)
show_textbox(title, text, 0, 0);
}
+static void conf_message_callback(const char *fmt, va_list ap)
+{
+ char buf[PATH_MAX+1];
+
+ vsnprintf(buf, sizeof(buf), fmt, ap);
+ if (save_and_exit)
+ printf("%s", buf);
+ else
+ show_textbox(NULL, buf, 6, 60);
+}
+
static void show_help(struct menu *menu)
{
struct gstr help = str_new();
- struct symbol *sym = menu->sym;
-
- if (menu_has_help(menu))
- {
- if (sym->name) {
- str_printf(&help, "%s:\n\n", sym->name);
- str_append(&help, _(menu_get_help(menu)));
- str_append(&help, "\n");
- }
- } else {
- str_append(&help, nohelp_text);
- }
- get_symbol_str(&help, sym);
+
+ help.max_width = getmaxx(stdscr) - 10;
+ menu_get_ext_help(menu, &help);
+
show_helptext(_(menu_get_prompt(menu)), str_get(&help));
str_free(&help);
}
@@ -731,7 +812,12 @@ static void conf_choice(struct menu *menu)
for (child = menu->list; child; child = child->next) {
if (!menu_is_visible(child))
continue;
- item_make("%s", _(menu_get_prompt(child)));
+ if (child->sym)
+ item_make("%s", _(menu_get_prompt(child)));
+ else {
+ item_make("*** %s ***", _(menu_get_prompt(child)));
+ item_set_tag(':');
+ }
item_set_data(child);
if (child->sym == active)
item_set_selected(1);
@@ -741,12 +827,17 @@ static void conf_choice(struct menu *menu)
dialog_clear();
res = dialog_checklist(prompt ? _(prompt) : _("Main Menu"),
_(radiolist_instructions),
- 15, 70, 6);
+ MENUBOX_HEIGTH_MIN,
+ MENUBOX_WIDTH_MIN,
+ CHECKLIST_HEIGTH_MIN);
selected = item_activate_selected();
switch (res) {
case 0:
if (selected) {
child = item_data();
+ if (!child->sym)
+ break;
+
sym_set_tristate_value(child->sym, yes);
}
return;
@@ -772,7 +863,7 @@ static void conf_string(struct menu *menu)
while (1) {
int res;
- char *heading;
+ const char *heading;
switch (sym_get_type(menu->sym)) {
case S_INT:
@@ -860,9 +951,58 @@ static void conf_save(void)
}
}
+static int handle_exit(void)
+{
+ int res;
+
+ save_and_exit = 1;
+ reset_subtitle();
+ dialog_clear();
+ if (conf_get_changed())
+ res = dialog_yesno(NULL,
+ _("Do you wish to save your new configuration?\n"
+ "(Press <ESC><ESC> to continue configuration.)"),
+ 6, 60);
+ else
+ res = -1;
+
+ end_dialog(saved_x, saved_y);
+
+ switch (res) {
+ case 0:
+ if (conf_write(filename)) {
+ fprintf(stderr, _("\n\n"
+ "Error while writing of the configuration.\n"
+ "Your configuration changes were NOT saved."
+ "\n\n"));
+ return 1;
+ }
+ /* fall through */
+ case -1:
+ printf(_("\n\n"
+ "*** End of the configuration.\n"
+ "*** Execute 'make' to start the build or try 'make help'."
+ "\n\n"));
+ res = 0;
+ break;
+ default:
+ fprintf(stderr, _("\n\n"
+ "Your configuration changes were NOT saved."
+ "\n\n"));
+ if (res != KEY_ESC)
+ res = 0;
+ }
+
+ return res;
+}
+
+static void sig_handler(int signo)
+{
+ exit(handle_exit());
+}
+
int main(int ac, char **av)
{
- int saved_x, saved_y;
char *mode;
int res;
@@ -870,6 +1010,8 @@ int main(int ac, char **av)
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
+ signal(SIGINT, sig_handler);
+
conf_parse(av[1]);
conf_read(NULL);
@@ -879,7 +1021,6 @@ int main(int ac, char **av)
single_menu_mode = 1;
}
- getyx(stdscr, saved_y, saved_x);
if (init_dialog(NULL)) {
fprintf(stderr, N_("Your display is too small to run Menuconfig!\n"));
fprintf(stderr, N_("It must be at least 19 lines by 80 columns.\n"));
@@ -887,40 +1028,12 @@ int main(int ac, char **av)
}
set_config_filename(conf_get_configname());
+ conf_set_message_callback(conf_message_callback);
do {
- conf(&rootmenu);
- dialog_clear();
- if (conf_get_changed())
- res = dialog_yesno(NULL,
- _("Do you wish to save your "
- "new configuration?\n"
- "<ESC><ESC> to continue."),
- 6, 60);
- else
- res = -1;
+ conf(&rootmenu, NULL);
+ res = handle_exit();
} while (res == KEY_ESC);
- end_dialog(saved_x, saved_y);
- switch (res) {
- case 0:
- if (conf_write(filename)) {
- fprintf(stderr, _("\n\n"
- "Error during writing of the configuration.\n"
- "Your configuration changes were NOT saved."
- "\n\n"));
- return 1;
- }
- case -1:
- printf(_("\n\n"
- "*** End of configuration.\n"
- "*** Execute 'make' to build or try 'make help'."
- "\n\n"));
- break;
- default:
- fprintf(stderr, _("\n\n"
- "Your configuration changes were NOT saved."
- "\n\n"));
- }
-
- return conf_write_autoconf();
+ return res;
}
+
diff --git a/extra/config/menu.c b/extra/config/menu.c
index 606ceb9e7..7e233a6ca 100644
--- a/extra/config/menu.c
+++ b/extra/config/menu.c
@@ -3,12 +3,15 @@
* Released under the terms of the GNU GPL v2.0.
*/
+#include <ctype.h>
+#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
-#define LKC_DIRECT_LINK
#include "lkc.h"
+static const char nohelp_text[] = "There is no help available for this option.";
+
struct menu rootmenu;
static struct menu **last_entry_ptr;
@@ -35,7 +38,7 @@ static void prop_warn(struct property *prop, const char *fmt, ...)
va_end(ap);
}
-void menu_init(void)
+void _menu_init(void)
{
current_entry = current_menu = &rootmenu;
last_entry_ptr = &rootmenu.list;
@@ -45,7 +48,7 @@ void menu_add_entry(struct symbol *sym)
{
struct menu *menu;
- menu = malloc(sizeof(*menu));
+ menu = xmalloc(sizeof(*menu));
memset(menu, 0, sizeof(*menu));
menu->sym = sym;
menu->parent = current_menu;
@@ -55,6 +58,8 @@ void menu_add_entry(struct symbol *sym)
*last_entry_ptr = menu;
last_entry_ptr = &menu->next;
current_entry = menu;
+ if (sym)
+ menu_add_symbol(P_SYMBOL, sym, NULL);
}
void menu_end_entry(void)
@@ -74,7 +79,7 @@ void menu_end_menu(void)
current_menu = current_menu->parent;
}
-struct expr *menu_check_dep(struct expr *e)
+static struct expr *menu_check_dep(struct expr *e)
{
if (!e)
return e;
@@ -133,8 +138,35 @@ struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *e
while (isspace(*prompt))
prompt++;
}
- if (current_entry->prompt)
+ if (current_entry->prompt && current_entry != &rootmenu)
prop_warn(prop, "prompt redefined");
+
+ /* Apply all upper menus' visibilities to actual prompts. */
+ if(type == P_PROMPT) {
+ struct menu *menu = current_entry;
+
+ while ((menu = menu->parent) != NULL) {
+ struct expr *dup_expr;
+
+ if (!menu->visibility)
+ continue;
+ /*
+ * Do not add a reference to the
+ * menu's visibility expression but
+ * use a copy of it. Otherwise the
+ * expression reduction functions
+ * will modify expressions that have
+ * multiple references which can
+ * cause unwanted side effects.
+ */
+ dup_expr = expr_copy(menu->visibility);
+
+ prop->visible.expr
+ = expr_alloc_and(prop->visible.expr,
+ dup_expr);
+ }
+ }
+
current_entry->prompt = prop;
}
prop->text = prompt;
@@ -147,6 +179,12 @@ struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr
return menu_add_prop(type, prompt, NULL, dep);
}
+void menu_add_visibility(struct expr *expr)
+{
+ current_entry->visibility = expr_alloc_and(current_entry->visibility,
+ expr);
+}
+
void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep)
{
menu_add_prop(type, NULL, expr, dep);
@@ -178,13 +216,13 @@ void menu_add_option(int token, char *arg)
}
}
-static int menu_range_valid_sym(struct symbol *sym, struct symbol *sym2)
+static int menu_validate_number(struct symbol *sym, struct symbol *sym2)
{
return sym2->type == S_INT || sym2->type == S_HEX ||
(sym2->type == S_UNKNOWN && sym_string_valid(sym, sym2->name));
}
-void sym_check_prop(struct symbol *sym)
+static void sym_check_prop(struct symbol *sym)
{
struct property *prop;
struct symbol *sym2;
@@ -194,8 +232,17 @@ void sym_check_prop(struct symbol *sym)
if ((sym->type == S_STRING || sym->type == S_INT || sym->type == S_HEX) &&
prop->expr->type != E_SYMBOL)
prop_warn(prop,
- "default for config symbol '%'"
+ "default for config symbol '%s'"
" must be a single symbol", sym->name);
+ if (prop->expr->type != E_SYMBOL)
+ break;
+ sym2 = prop_get_symbol(prop);
+ if (sym->type == S_HEX || sym->type == S_INT) {
+ if (!menu_validate_number(sym, sym2))
+ prop_warn(prop,
+ "'%s': number is invalid",
+ sym->name);
+ }
break;
case P_SELECT:
sym2 = prop_get_symbol(prop);
@@ -215,8 +262,8 @@ void sym_check_prop(struct symbol *sym)
if (sym->type != S_INT && sym->type != S_HEX)
prop_warn(prop, "range is only allowed "
"for int or hex symbols");
- if (!menu_range_valid_sym(sym, prop->expr->left.sym) ||
- !menu_range_valid_sym(sym, prop->expr->right.sym))
+ if (!menu_validate_number(sym, prop->expr->left.sym) ||
+ !menu_validate_number(sym, prop->expr->right.sym))
prop_warn(prop, "range is invalid");
break;
default:
@@ -235,18 +282,22 @@ void menu_finalize(struct menu *parent)
sym = parent->sym;
if (parent->list) {
if (sym && sym_is_choice(sym)) {
- /* find the first choice value and find out choice type */
- for (menu = parent->list; menu; menu = menu->next) {
- if (menu->sym) {
- current_entry = parent;
- if (sym->type == S_UNKNOWN)
+ if (sym->type == S_UNKNOWN) {
+ /* find the first choice value to find out choice type */
+ current_entry = parent;
+ for (menu = parent->list; menu; menu = menu->next) {
+ if (menu->sym && menu->sym->type != S_UNKNOWN) {
menu_set_type(menu->sym->type);
- current_entry = menu;
- if (menu->sym->type == S_UNKNOWN)
- menu_set_type(sym->type);
- break;
+ break;
+ }
}
}
+ /* set the type of the remaining choice values */
+ for (menu = parent->list; menu; menu = menu->next) {
+ current_entry = menu;
+ if (menu->sym && menu->sym->type == S_UNKNOWN)
+ menu_set_type(sym->type);
+ }
parentdep = expr_alloc_symbol(sym);
} else if (parent->prompt)
parentdep = parent->prompt->visible.expr;
@@ -311,52 +362,40 @@ void menu_finalize(struct menu *parent)
parent->next = last_menu->next;
last_menu->next = NULL;
}
+
+ sym->dir_dep.expr = expr_alloc_or(sym->dir_dep.expr, parent->dep);
}
for (menu = parent->list; menu; menu = menu->next) {
- if (sym && sym_is_choice(sym) && menu->sym) {
+ if (sym && sym_is_choice(sym) &&
+ menu->sym && !sym_is_choice_value(menu->sym)) {
+ current_entry = menu;
menu->sym->flags |= SYMBOL_CHOICEVAL;
if (!menu->prompt)
menu_warn(menu, "choice value must have a prompt");
for (prop = menu->sym->prop; prop; prop = prop->next) {
- if (prop->type == P_PROMPT && prop->menu != menu) {
- prop_warn(prop, "choice values "
- "currently only support a "
- "single prompt");
- }
if (prop->type == P_DEFAULT)
prop_warn(prop, "defaults for choice "
- "values not supported");
+ "values not supported");
+ if (prop->menu == menu)
+ continue;
+ if (prop->type == P_PROMPT &&
+ prop->menu->parent->sym != sym)
+ prop_warn(prop, "choice value used outside its choice group");
}
- current_entry = menu;
- if (menu->sym->type == S_UNKNOWN)
- menu_set_type(sym->type);
/* Non-tristate choice values of tristate choices must
* depend on the choice being set to Y. The choice
* values' dependencies were propagated to their
* properties above, so the change here must be re-
- * propagated. */
+ * propagated.
+ */
if (sym->type == S_TRISTATE && menu->sym->type != S_TRISTATE) {
basedep = expr_alloc_comp(E_EQUAL, sym, &symbol_yes);
- basedep = expr_alloc_and(basedep, menu->dep);
- basedep = expr_eliminate_dups(basedep);
- menu->dep = basedep;
+ menu->dep = expr_alloc_and(basedep, menu->dep);
for (prop = menu->sym->prop; prop; prop = prop->next) {
if (prop->menu != menu)
continue;
- dep = expr_alloc_and(expr_copy(basedep),
- prop->visible.expr);
- dep = expr_eliminate_dups(dep);
- dep = expr_trans_bool(dep);
- prop->visible.expr = dep;
- if (prop->type == P_SELECT) {
- struct symbol *es = prop_get_symbol(prop);
- dep2 = expr_alloc_symbol(menu->sym);
- dep = expr_alloc_and(dep2,
- expr_copy(dep));
- dep = expr_alloc_or(es->rev_dep.expr, dep);
- dep = expr_eliminate_dups(dep);
- es->rev_dep.expr = dep;
- }
+ prop->visible.expr = expr_alloc_and(expr_copy(basedep),
+ prop->visible.expr);
}
}
menu_add_symbol(P_CHOICE, sym, NULL);
@@ -397,6 +436,29 @@ void menu_finalize(struct menu *parent)
}
}
+bool menu_has_prompt(struct menu *menu)
+{
+ if (!menu->prompt)
+ return false;
+ return true;
+}
+
+/*
+ * Determine if a menu is empty.
+ * A menu is considered empty if it contains no or only
+ * invisible entries.
+ */
+bool menu_is_empty(struct menu *menu)
+{
+ struct menu *child;
+
+ for (child = menu->list; child; child = child->next) {
+ if (menu_is_visible(child))
+ return(false);
+ }
+ return(true);
+}
+
bool menu_is_visible(struct menu *menu)
{
struct menu *child;
@@ -405,6 +467,12 @@ bool menu_is_visible(struct menu *menu)
if (!menu->prompt)
return false;
+
+ if (menu->visibility) {
+ if (expr_calc_value(menu->visibility) == no)
+ return no;
+ }
+
sym = menu->sym;
if (sym) {
sym_calc_value(sym);
@@ -414,12 +482,18 @@ bool menu_is_visible(struct menu *menu)
if (visible != no)
return true;
+
if (!sym || sym_get_tristate_value(menu->sym) == no)
return false;
- for (child = menu->list; child; child = child->next)
- if (menu_is_visible(child))
+ for (child = menu->list; child; child = child->next) {
+ if (menu_is_visible(child)) {
+ if (sym)
+ sym->flags |= SYMBOL_DEF_USER;
return true;
+ }
+ }
+
return false;
}
@@ -461,3 +535,156 @@ const char *menu_get_help(struct menu *menu)
else
return "";
}
+
+static void get_prompt_str(struct gstr *r, struct property *prop,
+ struct list_head *head)
+{
+ int i, j;
+ struct menu *submenu[8], *menu, *location = NULL;
+ struct jump_key *jump;
+
+ str_printf(r, _("Prompt: %s\n"), _(prop->text));
+ menu = prop->menu->parent;
+ for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) {
+ bool accessible = menu_is_visible(menu);
+
+ submenu[i++] = menu;
+ if (location == NULL && accessible)
+ location = menu;
+ }
+ if (head && location) {
+ jump = xmalloc(sizeof(struct jump_key));
+
+ if (menu_is_visible(prop->menu)) {
+ /*
+ * There is not enough room to put the hint at the
+ * beginning of the "Prompt" line. Put the hint on the
+ * last "Location" line even when it would belong on
+ * the former.
+ */
+ jump->target = prop->menu;
+ } else
+ jump->target = location;
+
+ if (list_empty(head))
+ jump->index = 0;
+ else
+ jump->index = list_entry(head->prev, struct jump_key,
+ entries)->index + 1;
+
+ list_add_tail(&jump->entries, head);
+ }
+
+ if (i > 0) {
+ str_printf(r, _(" Location:\n"));
+ for (j = 4; --i >= 0; j += 2) {
+ menu = submenu[i];
+ if (head && location && menu == location)
+ jump->offset = r->len - 1;
+ str_printf(r, "%*c-> %s", j, ' ',
+ _(menu_get_prompt(menu)));
+ if (menu->sym) {
+ str_printf(r, " (%s [=%s])", menu->sym->name ?
+ menu->sym->name : _("<choice>"),
+ sym_get_string_value(menu->sym));
+ }
+ str_append(r, "\n");
+ }
+ }
+}
+
+/*
+ * get peoperty of type P_SYMBOL
+ */
+static struct property *get_symbol_prop(struct symbol *sym)
+{
+ struct property *prop = NULL;
+
+ for_all_properties(sym, prop, P_SYMBOL)
+ break;
+ return prop;
+}
+
+/*
+ * head is optional and may be NULL
+ */
+void get_symbol_str(struct gstr *r, struct symbol *sym,
+ struct list_head *head)
+{
+ bool hit;
+ struct property *prop;
+
+ if (sym && sym->name) {
+ str_printf(r, "Symbol: %s [=%s]\n", sym->name,
+ sym_get_string_value(sym));
+ str_printf(r, "Type : %s\n", sym_type_name(sym->type));
+ if (sym->type == S_INT || sym->type == S_HEX) {
+ prop = sym_get_range_prop(sym);
+ if (prop) {
+ str_printf(r, "Range : ");
+ expr_gstr_print(prop->expr, r);
+ str_append(r, "\n");
+ }
+ }
+ }
+ for_all_prompts(sym, prop)
+ get_prompt_str(r, prop, head);
+
+ prop = get_symbol_prop(sym);
+ if (prop) {
+ str_printf(r, _(" Defined at %s:%d\n"), prop->menu->file->name,
+ prop->menu->lineno);
+ if (!expr_is_yes(prop->visible.expr)) {
+ str_append(r, _(" Depends on: "));
+ expr_gstr_print(prop->visible.expr, r);
+ str_append(r, "\n");
+ }
+ }
+
+ hit = false;
+ for_all_properties(sym, prop, P_SELECT) {
+ if (!hit) {
+ str_append(r, " Selects: ");
+ hit = true;
+ } else
+ str_printf(r, " && ");
+ expr_gstr_print(prop->expr, r);
+ }
+ if (hit)
+ str_append(r, "\n");
+ if (sym->rev_dep.expr) {
+ str_append(r, _(" Selected by: "));
+ expr_gstr_print(sym->rev_dep.expr, r);
+ str_append(r, "\n");
+ }
+ str_append(r, "\n\n");
+}
+
+struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head)
+{
+ struct symbol *sym;
+ struct gstr res = str_new();
+ int i;
+
+ for (i = 0; sym_arr && (sym = sym_arr[i]); i++)
+ get_symbol_str(&res, sym, head);
+ if (!i)
+ str_append(&res, _("No matches found.\n"));
+ return res;
+}
+
+
+void menu_get_ext_help(struct menu *menu, struct gstr *help)
+{
+ struct symbol *sym = menu->sym;
+ const char *help_text = nohelp_text;
+
+ if (menu_has_help(menu)) {
+ if (sym->name)
+ str_printf(help, "%s%s:\n\n", CONFIG_, sym->name);
+ help_text = menu_get_help(menu);
+ }
+ str_printf(help, "%s\n", _(help_text));
+ if (sym)
+ get_symbol_str(help, sym, NULL);
+}
diff --git a/extra/config/merge_config.sh b/extra/config/merge_config.sh
new file mode 100755
index 000000000..81b0c61bb
--- /dev/null
+++ b/extra/config/merge_config.sh
@@ -0,0 +1,150 @@
+#!/bin/sh
+# merge_config.sh - Takes a list of config fragment values, and merges
+# them one by one. Provides warnings on overridden values, and specified
+# values that did not make it to the resulting .config file (due to missed
+# dependencies or config symbol removal).
+#
+# Portions reused from kconf_check and generate_cfg:
+# http://git.yoctoproject.org/cgit/cgit.cgi/yocto-kernel-tools/tree/tools/kconf_check
+# http://git.yoctoproject.org/cgit/cgit.cgi/yocto-kernel-tools/tree/tools/generate_cfg
+#
+# Copyright (c) 2009-2010 Wind River Systems, Inc.
+# Copyright 2011 Linaro
+#
+# 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.
+#
+# 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.
+
+clean_up() {
+ rm -f $TMP_FILE
+ exit
+}
+trap clean_up HUP INT TERM
+
+usage() {
+ echo "Usage: $0 [OPTIONS] [CONFIG [...]]"
+ echo " -h display this help text"
+ echo " -m only merge the fragments, do not execute the make command"
+ echo " -n use allnoconfig instead of alldefconfig"
+ echo " -r list redundant entries when merging fragments"
+ echo " -O dir to put generated output files"
+}
+
+MAKE=true
+ALLTARGET=alldefconfig
+WARNREDUN=false
+OUTPUT=.
+
+while true; do
+ case $1 in
+ "-n")
+ ALLTARGET=allnoconfig
+ shift
+ continue
+ ;;
+ "-m")
+ MAKE=false
+ shift
+ continue
+ ;;
+ "-h")
+ usage
+ exit
+ ;;
+ "-r")
+ WARNREDUN=true
+ shift
+ continue
+ ;;
+ "-O")
+ if [ -d $2 ];then
+ OUTPUT=$(echo $2 | sed 's/\/*$//')
+ else
+ echo "output directory $2 does not exist" 1>&2
+ exit 1
+ fi
+ shift 2
+ continue
+ ;;
+ *)
+ break
+ ;;
+ esac
+done
+
+INITFILE=$1
+shift;
+
+MERGE_LIST=$*
+SED_CONFIG_EXP="s/^\(# \)\{0,1\}\(CONFIG_[a-zA-Z0-9_]*\)[= ].*/\2/p"
+TMP_FILE=$(mktemp ./.tmp.config.XXXXXXXXXX)
+
+echo "Using $INITFILE as base"
+cat $INITFILE > $TMP_FILE
+
+# Merge files, printing warnings on overrided values
+for MERGE_FILE in $MERGE_LIST ; do
+ echo "Merging $MERGE_FILE"
+ CFG_LIST=$(sed -n "$SED_CONFIG_EXP" $MERGE_FILE)
+
+ for CFG in $CFG_LIST ; do
+ grep -q -w $CFG $TMP_FILE
+ if [ $? -eq 0 ] ; then
+ PREV_VAL=$(grep -w $CFG $TMP_FILE)
+ NEW_VAL=$(grep -w $CFG $MERGE_FILE)
+ if [ "x$PREV_VAL" != "x$NEW_VAL" ] ; then
+ echo Value of $CFG is redefined by fragment $MERGE_FILE:
+ echo Previous value: $PREV_VAL
+ echo New value: $NEW_VAL
+ echo
+ elif [ "$WARNREDUN" = "true" ]; then
+ echo Value of $CFG is redundant by fragment $MERGE_FILE:
+ fi
+ sed -i "/$CFG[ =]/d" $TMP_FILE
+ fi
+ done
+ cat $MERGE_FILE >> $TMP_FILE
+done
+
+if [ "$MAKE" = "false" ]; then
+ cp $TMP_FILE $OUTPUT/.config
+ echo "#"
+ echo "# merged configuration written to $OUTPUT/.config (needs make)"
+ echo "#"
+ clean_up
+ exit
+fi
+
+# If we have an output dir, setup the O= argument, otherwise leave
+# it blank, since O=. will create an unnecessary ./source softlink
+OUTPUT_ARG=""
+if [ "$OUTPUT" != "." ] ; then
+ OUTPUT_ARG="O=$OUTPUT"
+fi
+
+
+# Use the merged file as the starting point for:
+# alldefconfig: Fills in any missing symbols with Kconfig default
+# allnoconfig: Fills in any missing symbols with # CONFIG_* is not set
+make KCONFIG_ALLCONFIG=$TMP_FILE $OUTPUT_ARG $ALLTARGET
+
+
+# Check all specified config values took (might have missed-dependency issues)
+for CFG in $(sed -n "$SED_CONFIG_EXP" $TMP_FILE); do
+
+ REQUESTED_VAL=$(grep -w -e "$CFG" $TMP_FILE)
+ ACTUAL_VAL=$(grep -w -e "$CFG" $OUTPUT/.config)
+ if [ "x$REQUESTED_VAL" != "x$ACTUAL_VAL" ] ; then
+ echo "Value requested for $CFG not in final .config"
+ echo "Requested value: $REQUESTED_VAL"
+ echo "Actual value: $ACTUAL_VAL"
+ echo ""
+ fi
+done
+
+clean_up
diff --git a/extra/config/nconf.c b/extra/config/nconf.c
new file mode 100644
index 000000000..4e416cfcb
--- /dev/null
+++ b/extra/config/nconf.c
@@ -0,0 +1,1557 @@
+/*
+ * Copyright (C) 2008 Nir Tzachar <nir.tzachar@gmail.com?
+ * Released under the terms of the GNU GPL v2.0.
+ *
+ * Derived from menuconfig.
+ *
+ */
+#define _GNU_SOURCE
+#include <string.h>
+#include <stdlib.h>
+
+#include "lkc.h"
+#include "nconf.h"
+#include <ctype.h>
+
+static const char nconf_global_help[] = N_(
+"Help windows\n"
+"------------\n"
+"o Global help: Unless in a data entry window, pressing <F1> will give \n"
+" you the global help window, which you are just reading.\n"
+"\n"
+"o A short version of the global help is available by pressing <F3>.\n"
+"\n"
+"o Local help: To get help related to the current menu entry, use any\n"
+" of <?> <h>, or if in a data entry window then press <F1>.\n"
+"\n"
+"\n"
+"Menu entries\n"
+"------------\n"
+"This interface lets you select features and parameters for the \n"
+"build. Features can either be built-in, modularized, or removed.\n"
+"Parameters must be entered as text or decimal or hexadecimal numbers.\n"
+"\n"
+"Menu entries beginning with following braces represent features that\n"
+" [ ] can be built in or removed\n"
+" < > can be built in, modularized or removed\n"
+" { } can be built in or modularized, are selected by another feature\n"
+" - - are selected by another feature\n"
+" XXX cannot be selected. Symbol Info <F2> tells you why.\n"
+"*, M or whitespace inside braces means to build in, build as a module\n"
+"or to exclude the feature respectively.\n"
+"\n"
+"To change any of these features, highlight it with the movement keys\n"
+"listed below and press <y> to build it in, <m> to make it a module or\n"
+"<n> to remove it. You may press the <Space> key to cycle through the\n"
+"available options.\n"
+"\n"
+"A trailing \"--->\" designates a submenu, a trailing \"----\" an\n"
+"empty submenu.\n"
+"\n"
+"Menu navigation keys\n"
+"----------------------------------------------------------------------\n"
+"Linewise up <Up>\n"
+"Linewise down <Down>\n"
+"Pagewise up <Page Up>\n"
+"Pagewise down <Page Down>\n"
+"First entry <Home>\n"
+"Last entry <End>\n"
+"Enter a submenu <Right> <Enter>\n"
+"Go back to parent menu <Left> <Esc> <F5>\n"
+"Close a help window <Enter> <Esc> <F5>\n"
+"Close entry window, apply <Enter>\n"
+"Close entry window, forget <Esc> <F5>\n"
+"Start incremental, case-insensitive search for STRING in menu entries,\n"
+" no regex support, STRING is displayed in upper left corner\n"
+" </>STRING\n"
+" Remove last character <Backspace>\n"
+" Jump to next hit <Down>\n"
+" Jump to previous hit <Up>\n"
+"Exit menu search mode </> <Esc>\n"
+"Search for configuration variables with or without leading CONFIG_\n"
+" <F8>RegExpr<Enter>\n"
+"Verbose search help <F8><F1>\n"
+"----------------------------------------------------------------------\n"
+"\n"
+"Unless in a data entry window, key <1> may be used instead of <F1>,\n"
+"<2> instead of <F2>, etc.\n"
+"\n"
+"\n"
+"Radiolist (Choice list)\n"
+"-----------------------\n"
+"Use the movement keys listed above to select the option you wish to set\n"
+"and press <Space>.\n"
+"\n"
+"\n"
+"Data entry\n"
+"----------\n"
+"Enter the requested information and press <Enter>. Hexadecimal values\n"
+"may be entered without the \"0x\" prefix.\n"
+"\n"
+"\n"
+"Text Box (Help Window)\n"
+"----------------------\n"
+"Use movement keys as listed in table above.\n"
+"\n"
+"Press any of <Enter> <Esc> <q> <F5> <F9> to exit.\n"
+"\n"
+"\n"
+"Alternate configuration files\n"
+"-----------------------------\n"
+"nconfig supports switching between different configurations.\n"
+"Press <F6> to save your current configuration. Press <F7> and enter\n"
+"a file name to load a previously saved configuration.\n"
+"\n"
+"\n"
+"Terminal configuration\n"
+"----------------------\n"
+"If you use nconfig in a xterm window, make sure your TERM environment\n"
+"variable specifies a terminal configuration which supports at least\n"
+"16 colors. Otherwise nconfig will look rather bad.\n"
+"\n"
+"If the \"stty size\" command reports the current terminalsize correctly,\n"
+"nconfig will adapt to sizes larger than the traditional 80x25 \"standard\"\n"
+"and display longer menus properly.\n"
+"\n"
+"\n"
+"Single menu mode\n"
+"----------------\n"
+"If you prefer to have all of the menu entries listed in a single menu,\n"
+"rather than the default multimenu hierarchy, run nconfig with\n"
+"NCONFIG_MODE environment variable set to single_menu. Example:\n"
+"\n"
+"make NCONFIG_MODE=single_menu nconfig\n"
+"\n"
+"<Enter> will then unfold the appropriate category, or fold it if it\n"
+"is already unfolded. Folded menu entries will be designated by a\n"
+"leading \"++>\" and unfolded entries by a leading \"-->\".\n"
+"\n"
+"Note that this mode can eventually be a little more CPU expensive than\n"
+"the default mode, especially with a larger number of unfolded submenus.\n"
+"\n"),
+menu_no_f_instructions[] = N_(
+"Legend: [*] built-in [ ] excluded <M> module < > module capable.\n"
+"Submenus are designated by a trailing \"--->\", empty ones by \"----\".\n"
+"\n"
+"Use the following keys to navigate the menus:\n"
+"Move up or down with <Up> and <Down>.\n"
+"Enter a submenu with <Enter> or <Right>.\n"
+"Exit a submenu to its parent menu with <Esc> or <Left>.\n"
+"Pressing <y> includes, <n> excludes, <m> modularizes features.\n"
+"Pressing <Space> cycles through the available options.\n"
+"To search for menu entries press </>.\n"
+"<Esc> always leaves the current window.\n"
+"\n"
+"You do not have function keys support.\n"
+"Press <1> instead of <F1>, <2> instead of <F2>, etc.\n"
+"For verbose global help use key <1>.\n"
+"For help related to the current menu entry press <?> or <h>.\n"),
+menu_instructions[] = N_(
+"Legend: [*] built-in [ ] excluded <M> module < > module capable.\n"
+"Submenus are designated by a trailing \"--->\", empty ones by \"----\".\n"
+"\n"
+"Use the following keys to navigate the menus:\n"
+"Move up or down with <Up> or <Down>.\n"
+"Enter a submenu with <Enter> or <Right>.\n"
+"Exit a submenu to its parent menu with <Esc> or <Left>.\n"
+"Pressing <y> includes, <n> excludes, <m> modularizes features.\n"
+"Pressing <Space> cycles through the available options.\n"
+"To search for menu entries press </>.\n"
+"<Esc> always leaves the current window.\n"
+"\n"
+"Pressing <1> may be used instead of <F1>, <2> instead of <F2>, etc.\n"
+"For verbose global help press <F1>.\n"
+"For help related to the current menu entry press <?> or <h>.\n"),
+radiolist_instructions[] = N_(
+"Press <Up>, <Down>, <Home> or <End> to navigate a radiolist, select\n"
+"with <Space>.\n"
+"For help related to the current entry press <?> or <h>.\n"
+"For global help press <F1>.\n"),
+inputbox_instructions_int[] = N_(
+"Please enter a decimal value.\n"
+"Fractions will not be accepted.\n"
+"Press <Enter> to apply, <Esc> to cancel."),
+inputbox_instructions_hex[] = N_(
+"Please enter a hexadecimal value.\n"
+"Press <Enter> to apply, <Esc> to cancel."),
+inputbox_instructions_string[] = N_(
+"Please enter a string value.\n"
+"Press <Enter> to apply, <Esc> to cancel."),
+setmod_text[] = N_(
+"This feature depends on another feature which has been configured as a\n"
+"module. As a result, the current feature will be built as a module too."),
+load_config_text[] = N_(
+"Enter the name of the configuration file you wish to load.\n"
+"Accept the name shown to restore the configuration you last\n"
+"retrieved. Leave empty to abort."),
+load_config_help[] = N_(
+"For various reasons, one may wish to keep several different\n"
+"configurations available on a single machine.\n"
+"\n"
+"If you have saved a previous configuration in a file other than the\n"
+"default one, entering its name here will allow you to load and modify\n"
+"that configuration.\n"
+"\n"
+"Leave empty to abort.\n"),
+save_config_text[] = N_(
+"Enter a filename to which this configuration should be saved\n"
+"as an alternate. Leave empty to abort."),
+save_config_help[] = N_(
+"For various reasons, one may wish to keep several different\n"
+"configurations available on a single machine.\n"
+"\n"
+"Entering a file name here will allow you to later retrieve, modify\n"
+"and use the current configuration as an alternate to whatever\n"
+"configuration options you have selected at that time.\n"
+"\n"
+"Leave empty to abort.\n"),
+search_help[] = N_(
+"Search for symbols (configuration variable names CONFIG_*) and display\n"
+"their relations. Regular expressions are supported.\n"
+"Example: Search for \"^FOO\".\n"
+"Result:\n"
+"-----------------------------------------------------------------\n"
+"Symbol: FOO [ = m]\n"
+"Prompt: Foo bus is used to drive the bar HW\n"
+"Defined at drivers/pci/Kconfig:47\n"
+"Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n"
+"Location:\n"
+" -> Bus options (PCI, PCMCIA, EISA, ISA)\n"
+" -> PCI support (PCI [ = y])\n"
+" -> PCI access mode (<choice> [ = y])\n"
+"Selects: LIBCRC32\n"
+"Selected by: BAR\n"
+"-----------------------------------------------------------------\n"
+"o The line 'Prompt:' shows the text displayed for this symbol in\n"
+" the menu hierarchy.\n"
+"o The 'Defined at' line tells at what file / line number the symbol is\n"
+" defined.\n"
+"o The 'Depends on:' line lists symbols that need to be defined for\n"
+" this symbol to be visible and selectable in the menu.\n"
+"o The 'Location:' lines tell, where in the menu structure this symbol\n"
+" is located. A location followed by a [ = y] indicates that this is\n"
+" a selectable menu item, and the current value is displayed inside\n"
+" brackets.\n"
+"o The 'Selects:' line tells, what symbol will be automatically selected\n"
+" if this symbol is selected (y or m).\n"
+"o The 'Selected by' line tells what symbol has selected this symbol.\n"
+"\n"
+"Only relevant lines are shown.\n"
+"\n\n"
+"Search examples:\n"
+"USB => find all symbols containing USB\n"
+"^USB => find all symbols starting with USB\n"
+"USB$ => find all symbols ending with USB\n"
+"\n");
+
+struct mitem {
+ char str[256];
+ char tag;
+ void *usrptr;
+ int is_visible;
+};
+
+#define MAX_MENU_ITEMS 4096
+static int show_all_items;
+static int indent;
+static struct menu *current_menu;
+static int child_count;
+static int single_menu_mode;
+/* the window in which all information appears */
+static WINDOW *main_window;
+/* the largest size of the menu window */
+static int mwin_max_lines;
+static int mwin_max_cols;
+/* the window in which we show option buttons */
+static MENU *curses_menu;
+static ITEM *curses_menu_items[MAX_MENU_ITEMS];
+static struct mitem k_menu_items[MAX_MENU_ITEMS];
+static int items_num;
+static int global_exit;
+/* the currently selected button */
+const char *current_instructions = menu_instructions;
+
+static char *dialog_input_result;
+static int dialog_input_result_len;
+
+static void conf(struct menu *menu);
+static void conf_choice(struct menu *menu);
+static void conf_string(struct menu *menu);
+static void conf_load(void);
+static void conf_save(void);
+static void show_help(struct menu *menu);
+static int do_exit(void);
+static void setup_windows(void);
+static void search_conf(void);
+
+typedef void (*function_key_handler_t)(int *key, struct menu *menu);
+static void handle_f1(int *key, struct menu *current_item);
+static void handle_f2(int *key, struct menu *current_item);
+static void handle_f3(int *key, struct menu *current_item);
+static void handle_f4(int *key, struct menu *current_item);
+static void handle_f5(int *key, struct menu *current_item);
+static void handle_f6(int *key, struct menu *current_item);
+static void handle_f7(int *key, struct menu *current_item);
+static void handle_f8(int *key, struct menu *current_item);
+static void handle_f9(int *key, struct menu *current_item);
+
+struct function_keys {
+ const char *key_str;
+ const char *func;
+ function_key key;
+ function_key_handler_t handler;
+};
+
+static const int function_keys_num = 9;
+struct function_keys function_keys[] = {
+ {
+ .key_str = "F1",
+ .func = "Help",
+ .key = F_HELP,
+ .handler = handle_f1,
+ },
+ {
+ .key_str = "F2",
+ .func = "SymInfo",
+ .key = F_SYMBOL,
+ .handler = handle_f2,
+ },
+ {
+ .key_str = "F3",
+ .func = "Help 2",
+ .key = F_INSTS,
+ .handler = handle_f3,
+ },
+ {
+ .key_str = "F4",
+ .func = "ShowAll",
+ .key = F_CONF,
+ .handler = handle_f4,
+ },
+ {
+ .key_str = "F5",
+ .func = "Back",
+ .key = F_BACK,
+ .handler = handle_f5,
+ },
+ {
+ .key_str = "F6",
+ .func = "Save",
+ .key = F_SAVE,
+ .handler = handle_f6,
+ },
+ {
+ .key_str = "F7",
+ .func = "Load",
+ .key = F_LOAD,
+ .handler = handle_f7,
+ },
+ {
+ .key_str = "F8",
+ .func = "SymSearch",
+ .key = F_SEARCH,
+ .handler = handle_f8,
+ },
+ {
+ .key_str = "F9",
+ .func = "Exit",
+ .key = F_EXIT,
+ .handler = handle_f9,
+ },
+};
+
+static void print_function_line(void)
+{
+ int i;
+ int offset = 1;
+ const int skip = 1;
+ int lines = getmaxy(stdscr);
+
+ for (i = 0; i < function_keys_num; i++) {
+ (void) wattrset(main_window, attributes[FUNCTION_HIGHLIGHT]);
+ mvwprintw(main_window, lines-3, offset,
+ "%s",
+ function_keys[i].key_str);
+ (void) wattrset(main_window, attributes[FUNCTION_TEXT]);
+ offset += strlen(function_keys[i].key_str);
+ mvwprintw(main_window, lines-3,
+ offset, "%s",
+ function_keys[i].func);
+ offset += strlen(function_keys[i].func) + skip;
+ }
+ (void) wattrset(main_window, attributes[NORMAL]);
+}
+
+/* help */
+static void handle_f1(int *key, struct menu *current_item)
+{
+ show_scroll_win(main_window,
+ _("Global help"), _(nconf_global_help));
+ return;
+}
+
+/* symbole help */
+static void handle_f2(int *key, struct menu *current_item)
+{
+ show_help(current_item);
+ return;
+}
+
+/* instructions */
+static void handle_f3(int *key, struct menu *current_item)
+{
+ show_scroll_win(main_window,
+ _("Short help"),
+ _(current_instructions));
+ return;
+}
+
+/* config */
+static void handle_f4(int *key, struct menu *current_item)
+{
+ int res = btn_dialog(main_window,
+ _("Show all symbols?"),
+ 2,
+ " <Show All> ",
+ "<Don't show all>");
+ if (res == 0)
+ show_all_items = 1;
+ else if (res == 1)
+ show_all_items = 0;
+
+ return;
+}
+
+/* back */
+static void handle_f5(int *key, struct menu *current_item)
+{
+ *key = KEY_LEFT;
+ return;
+}
+
+/* save */
+static void handle_f6(int *key, struct menu *current_item)
+{
+ conf_save();
+ return;
+}
+
+/* load */
+static void handle_f7(int *key, struct menu *current_item)
+{
+ conf_load();
+ return;
+}
+
+/* search */
+static void handle_f8(int *key, struct menu *current_item)
+{
+ search_conf();
+ return;
+}
+
+/* exit */
+static void handle_f9(int *key, struct menu *current_item)
+{
+ do_exit();
+ return;
+}
+
+/* return != 0 to indicate the key was handles */
+static int process_special_keys(int *key, struct menu *menu)
+{
+ int i;
+
+ if (*key == KEY_RESIZE) {
+ setup_windows();
+ return 1;
+ }
+
+ for (i = 0; i < function_keys_num; i++) {
+ if (*key == KEY_F(function_keys[i].key) ||
+ *key == '0' + function_keys[i].key){
+ function_keys[i].handler(key, menu);
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+static void clean_items(void)
+{
+ int i;
+ for (i = 0; curses_menu_items[i]; i++)
+ free_item(curses_menu_items[i]);
+ bzero(curses_menu_items, sizeof(curses_menu_items));
+ bzero(k_menu_items, sizeof(k_menu_items));
+ items_num = 0;
+}
+
+typedef enum {MATCH_TINKER_PATTERN_UP, MATCH_TINKER_PATTERN_DOWN,
+ FIND_NEXT_MATCH_DOWN, FIND_NEXT_MATCH_UP} match_f;
+
+/* return the index of the matched item, or -1 if no such item exists */
+static int get_mext_match(const char *match_str, match_f flag)
+{
+ int match_start = item_index(current_item(curses_menu));
+ int index;
+
+ if (flag == FIND_NEXT_MATCH_DOWN)
+ ++match_start;
+ else if (flag == FIND_NEXT_MATCH_UP)
+ --match_start;
+
+ index = match_start;
+ index = (index + items_num) % items_num;
+ while (true) {
+ char *str = k_menu_items[index].str;
+ if (strcasestr(str, match_str) != 0)
+ return index;
+ if (flag == FIND_NEXT_MATCH_UP ||
+ flag == MATCH_TINKER_PATTERN_UP)
+ --index;
+ else
+ ++index;
+ index = (index + items_num) % items_num;
+ if (index == match_start)
+ return -1;
+ }
+}
+
+/* Make a new item. */
+static void item_make(struct menu *menu, char tag, const char *fmt, ...)
+{
+ va_list ap;
+
+ if (items_num > MAX_MENU_ITEMS-1)
+ return;
+
+ bzero(&k_menu_items[items_num], sizeof(k_menu_items[0]));
+ k_menu_items[items_num].tag = tag;
+ k_menu_items[items_num].usrptr = menu;
+ if (menu != NULL)
+ k_menu_items[items_num].is_visible =
+ menu_is_visible(menu);
+ else
+ k_menu_items[items_num].is_visible = 1;
+
+ va_start(ap, fmt);
+ vsnprintf(k_menu_items[items_num].str,
+ sizeof(k_menu_items[items_num].str),
+ fmt, ap);
+ va_end(ap);
+
+ if (!k_menu_items[items_num].is_visible)
+ memcpy(k_menu_items[items_num].str, "XXX", 3);
+
+ curses_menu_items[items_num] = new_item(
+ k_menu_items[items_num].str,
+ k_menu_items[items_num].str);
+ set_item_userptr(curses_menu_items[items_num],
+ &k_menu_items[items_num]);
+ /*
+ if (!k_menu_items[items_num].is_visible)
+ item_opts_off(curses_menu_items[items_num], O_SELECTABLE);
+ */
+
+ items_num++;
+ curses_menu_items[items_num] = NULL;
+}
+
+/* very hackish. adds a string to the last item added */
+static void item_add_str(const char *fmt, ...)
+{
+ va_list ap;
+ int index = items_num-1;
+ char new_str[256];
+ char tmp_str[256];
+
+ if (index < 0)
+ return;
+
+ va_start(ap, fmt);
+ vsnprintf(new_str, sizeof(new_str), fmt, ap);
+ va_end(ap);
+ snprintf(tmp_str, sizeof(tmp_str), "%s%s",
+ k_menu_items[index].str, new_str);
+ strncpy(k_menu_items[index].str,
+ tmp_str,
+ sizeof(k_menu_items[index].str));
+
+ free_item(curses_menu_items[index]);
+ curses_menu_items[index] = new_item(
+ k_menu_items[index].str,
+ k_menu_items[index].str);
+ set_item_userptr(curses_menu_items[index],
+ &k_menu_items[index]);
+}
+
+/* get the tag of the currently selected item */
+static char item_tag(void)
+{
+ ITEM *cur;
+ struct mitem *mcur;
+
+ cur = current_item(curses_menu);
+ if (cur == NULL)
+ return 0;
+ mcur = (struct mitem *) item_userptr(cur);
+ return mcur->tag;
+}
+
+static int curses_item_index(void)
+{
+ return item_index(current_item(curses_menu));
+}
+
+static void *item_data(void)
+{
+ ITEM *cur;
+ struct mitem *mcur;
+
+ cur = current_item(curses_menu);
+ if (!cur)
+ return NULL;
+ mcur = (struct mitem *) item_userptr(cur);
+ return mcur->usrptr;
+
+}
+
+static int item_is_tag(char tag)
+{
+ return item_tag() == tag;
+}
+
+static char filename[PATH_MAX+1];
+static char menu_backtitle[PATH_MAX+128];
+static const char *set_config_filename(const char *config_filename)
+{
+ int size;
+
+ size = snprintf(menu_backtitle, sizeof(menu_backtitle),
+ "%s - %s", config_filename, rootmenu.prompt->text);
+ if (size >= sizeof(menu_backtitle))
+ menu_backtitle[sizeof(menu_backtitle)-1] = '\0';
+
+ size = snprintf(filename, sizeof(filename), "%s", config_filename);
+ if (size >= sizeof(filename))
+ filename[sizeof(filename)-1] = '\0';
+ return menu_backtitle;
+}
+
+/* return = 0 means we are successful.
+ * -1 means go on doing what you were doing
+ */
+static int do_exit(void)
+{
+ int res;
+ if (!conf_get_changed()) {
+ global_exit = 1;
+ return 0;
+ }
+ res = btn_dialog(main_window,
+ _("Do you wish to save your new configuration?\n"
+ "<ESC> to cancel and resume nconfig."),
+ 2,
+ " <save> ",
+ "<don't save>");
+ if (res == KEY_EXIT) {
+ global_exit = 0;
+ return -1;
+ }
+
+ /* if we got here, the user really wants to exit */
+ switch (res) {
+ case 0:
+ res = conf_write(filename);
+ if (res)
+ btn_dialog(
+ main_window,
+ _("Error during writing of configuration.\n"
+ "Your configuration changes were NOT saved."),
+ 1,
+ "<OK>");
+ break;
+ default:
+ btn_dialog(
+ main_window,
+ _("Your configuration changes were NOT saved."),
+ 1,
+ "<OK>");
+ break;
+ }
+ global_exit = 1;
+ return 0;
+}
+
+
+static void search_conf(void)
+{
+ struct symbol **sym_arr;
+ struct gstr res;
+ struct gstr title;
+ char *dialog_input;
+ int dres;
+
+ title = str_new();
+ str_printf( &title, _("Enter %s (sub)string or regexp to search for "
+ "(with or without \"%s\")"), CONFIG_, CONFIG_);
+
+again:
+ dres = dialog_inputbox(main_window,
+ _("Search Configuration Parameter"),
+ str_get(&title),
+ "", &dialog_input_result, &dialog_input_result_len);
+ switch (dres) {
+ case 0:
+ break;
+ case 1:
+ show_scroll_win(main_window,
+ _("Search Configuration"), search_help);
+ goto again;
+ default:
+ str_free(&title);
+ return;
+ }
+
+ /* strip the prefix if necessary */
+ dialog_input = dialog_input_result;
+ if (strncasecmp(dialog_input_result, CONFIG_, strlen(CONFIG_)) == 0)
+ dialog_input += strlen(CONFIG_);
+
+ sym_arr = sym_re_search(dialog_input);
+ res = get_relations_str(sym_arr, NULL);
+ free(sym_arr);
+ show_scroll_win(main_window,
+ _("Search Results"), str_get(&res));
+ str_free(&res);
+ str_free(&title);
+}
+
+
+static void build_conf(struct menu *menu)
+{
+ struct symbol *sym;
+ struct property *prop;
+ struct menu *child;
+ int type, tmp, doint = 2;
+ tristate val;
+ char ch;
+
+ if (!menu || (!show_all_items && !menu_is_visible(menu)))
+ return;
+
+ sym = menu->sym;
+ prop = menu->prompt;
+ if (!sym) {
+ if (prop && menu != current_menu) {
+ const char *prompt = menu_get_prompt(menu);
+ enum prop_type ptype;
+ ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;
+ switch (ptype) {
+ case P_MENU:
+ child_count++;
+ prompt = _(prompt);
+ if (single_menu_mode) {
+ item_make(menu, 'm',
+ "%s%*c%s",
+ menu->data ? "-->" : "++>",
+ indent + 1, ' ', prompt);
+ } else
+ item_make(menu, 'm',
+ " %*c%s %s",
+ indent + 1, ' ', prompt,
+ menu_is_empty(menu) ? "----" : "--->");
+
+ if (single_menu_mode && menu->data)
+ goto conf_childs;
+ return;
+ case P_COMMENT:
+ if (prompt) {
+ child_count++;
+ item_make(menu, ':',
+ " %*c*** %s ***",
+ indent + 1, ' ',
+ _(prompt));
+ }
+ break;
+ default:
+ if (prompt) {
+ child_count++;
+ item_make(menu, ':', "---%*c%s",
+ indent + 1, ' ',
+ _(prompt));
+ }
+ }
+ } else
+ doint = 0;
+ goto conf_childs;
+ }
+
+ type = sym_get_type(sym);
+ if (sym_is_choice(sym)) {
+ struct symbol *def_sym = sym_get_choice_value(sym);
+ struct menu *def_menu = NULL;
+
+ child_count++;
+ for (child = menu->list; child; child = child->next) {
+ if (menu_is_visible(child) && child->sym == def_sym)
+ def_menu = child;
+ }
+
+ val = sym_get_tristate_value(sym);
+ if (sym_is_changable(sym)) {
+ switch (type) {
+ case S_BOOLEAN:
+ item_make(menu, 't', "[%c]",
+ val == no ? ' ' : '*');
+ break;
+ case S_TRISTATE:
+ switch (val) {
+ case yes:
+ ch = '*';
+ break;
+ case mod:
+ ch = 'M';
+ break;
+ default:
+ ch = ' ';
+ break;
+ }
+ item_make(menu, 't', "<%c>", ch);
+ break;
+ }
+ } else {
+ item_make(menu, def_menu ? 't' : ':', " ");
+ }
+
+ item_add_str("%*c%s", indent + 1,
+ ' ', _(menu_get_prompt(menu)));
+ if (val == yes) {
+ if (def_menu) {
+ item_add_str(" (%s)",
+ _(menu_get_prompt(def_menu)));
+ item_add_str(" --->");
+ if (def_menu->list) {
+ indent += 2;
+ build_conf(def_menu);
+ indent -= 2;
+ }
+ }
+ return;
+ }
+ } else {
+ if (menu == current_menu) {
+ item_make(menu, ':',
+ "---%*c%s", indent + 1,
+ ' ', _(menu_get_prompt(menu)));
+ goto conf_childs;
+ }
+ child_count++;
+ val = sym_get_tristate_value(sym);
+ if (sym_is_choice_value(sym) && val == yes) {
+ item_make(menu, ':', " ");
+ } else {
+ switch (type) {
+ case S_BOOLEAN:
+ if (sym_is_changable(sym))
+ item_make(menu, 't', "[%c]",
+ val == no ? ' ' : '*');
+ else
+ item_make(menu, 't', "-%c-",
+ val == no ? ' ' : '*');
+ break;
+ case S_TRISTATE:
+ switch (val) {
+ case yes:
+ ch = '*';
+ break;
+ case mod:
+ ch = 'M';
+ break;
+ default:
+ ch = ' ';
+ break;
+ }
+ if (sym_is_changable(sym)) {
+ if (sym->rev_dep.tri == mod)
+ item_make(menu,
+ 't', "{%c}", ch);
+ else
+ item_make(menu,
+ 't', "<%c>", ch);
+ } else
+ item_make(menu, 't', "-%c-", ch);
+ break;
+ default:
+ tmp = 2 + strlen(sym_get_string_value(sym));
+ item_make(menu, 's', " (%s)",
+ sym_get_string_value(sym));
+ tmp = indent - tmp + 4;
+ if (tmp < 0)
+ tmp = 0;
+ item_add_str("%*c%s%s", tmp, ' ',
+ _(menu_get_prompt(menu)),
+ (sym_has_value(sym) ||
+ !sym_is_changable(sym)) ? "" :
+ _(" (NEW)"));
+ goto conf_childs;
+ }
+ }
+ item_add_str("%*c%s%s", indent + 1, ' ',
+ _(menu_get_prompt(menu)),
+ (sym_has_value(sym) || !sym_is_changable(sym)) ?
+ "" : _(" (NEW)"));
+ if (menu->prompt && menu->prompt->type == P_MENU) {
+ item_add_str(" %s", menu_is_empty(menu) ? "----" : "--->");
+ return;
+ }
+ }
+
+conf_childs:
+ indent += doint;
+ for (child = menu->list; child; child = child->next)
+ build_conf(child);
+ indent -= doint;
+}
+
+static void reset_menu(void)
+{
+ unpost_menu(curses_menu);
+ clean_items();
+}
+
+/* adjust the menu to show this item.
+ * prefer not to scroll the menu if possible*/
+static void center_item(int selected_index, int *last_top_row)
+{
+ int toprow;
+
+ set_top_row(curses_menu, *last_top_row);
+ toprow = top_row(curses_menu);
+ if (selected_index < toprow ||
+ selected_index >= toprow+mwin_max_lines) {
+ toprow = max(selected_index-mwin_max_lines/2, 0);
+ if (toprow >= item_count(curses_menu)-mwin_max_lines)
+ toprow = item_count(curses_menu)-mwin_max_lines;
+ set_top_row(curses_menu, toprow);
+ }
+ set_current_item(curses_menu,
+ curses_menu_items[selected_index]);
+ *last_top_row = toprow;
+ post_menu(curses_menu);
+ refresh_all_windows(main_window);
+}
+
+/* this function assumes reset_menu has been called before */
+static void show_menu(const char *prompt, const char *instructions,
+ int selected_index, int *last_top_row)
+{
+ int maxx, maxy;
+ WINDOW *menu_window;
+
+ current_instructions = instructions;
+
+ clear();
+ (void) wattrset(main_window, attributes[NORMAL]);
+ print_in_middle(stdscr, 1, 0, getmaxx(stdscr),
+ menu_backtitle,
+ attributes[MAIN_HEADING]);
+
+ (void) wattrset(main_window, attributes[MAIN_MENU_BOX]);
+ box(main_window, 0, 0);
+ (void) wattrset(main_window, attributes[MAIN_MENU_HEADING]);
+ mvwprintw(main_window, 0, 3, " %s ", prompt);
+ (void) wattrset(main_window, attributes[NORMAL]);
+
+ set_menu_items(curses_menu, curses_menu_items);
+
+ /* position the menu at the middle of the screen */
+ scale_menu(curses_menu, &maxy, &maxx);
+ maxx = min(maxx, mwin_max_cols-2);
+ maxy = mwin_max_lines;
+ menu_window = derwin(main_window,
+ maxy,
+ maxx,
+ 2,
+ (mwin_max_cols-maxx)/2);
+ keypad(menu_window, TRUE);
+ set_menu_win(curses_menu, menu_window);
+ set_menu_sub(curses_menu, menu_window);
+
+ /* must reassert this after changing items, otherwise returns to a
+ * default of 16
+ */
+ set_menu_format(curses_menu, maxy, 1);
+ center_item(selected_index, last_top_row);
+ set_menu_format(curses_menu, maxy, 1);
+
+ print_function_line();
+
+ /* Post the menu */
+ post_menu(curses_menu);
+ refresh_all_windows(main_window);
+}
+
+static void adj_match_dir(match_f *match_direction)
+{
+ if (*match_direction == FIND_NEXT_MATCH_DOWN)
+ *match_direction =
+ MATCH_TINKER_PATTERN_DOWN;
+ else if (*match_direction == FIND_NEXT_MATCH_UP)
+ *match_direction =
+ MATCH_TINKER_PATTERN_UP;
+ /* else, do no change.. */
+}
+
+struct match_state
+{
+ int in_search;
+ match_f match_direction;
+ char pattern[256];
+};
+
+/* Return 0 means I have handled the key. In such a case, ans should hold the
+ * item to center, or -1 otherwise.
+ * Else return -1 .
+ */
+static int do_match(int key, struct match_state *state, int *ans)
+{
+ char c = (char) key;
+ int terminate_search = 0;
+ *ans = -1;
+ if (key == '/' || (state->in_search && key == 27)) {
+ move(0, 0);
+ refresh();
+ clrtoeol();
+ state->in_search = 1-state->in_search;
+ bzero(state->pattern, sizeof(state->pattern));
+ state->match_direction = MATCH_TINKER_PATTERN_DOWN;
+ return 0;
+ } else if (!state->in_search)
+ return 1;
+
+ if (isalnum(c) || isgraph(c) || c == ' ') {
+ state->pattern[strlen(state->pattern)] = c;
+ state->pattern[strlen(state->pattern)] = '\0';
+ adj_match_dir(&state->match_direction);
+ *ans = get_mext_match(state->pattern,
+ state->match_direction);
+ } else if (key == KEY_DOWN) {
+ state->match_direction = FIND_NEXT_MATCH_DOWN;
+ *ans = get_mext_match(state->pattern,
+ state->match_direction);
+ } else if (key == KEY_UP) {
+ state->match_direction = FIND_NEXT_MATCH_UP;
+ *ans = get_mext_match(state->pattern,
+ state->match_direction);
+ } else if (key == KEY_BACKSPACE || key == 127) {
+ state->pattern[strlen(state->pattern)-1] = '\0';
+ adj_match_dir(&state->match_direction);
+ } else
+ terminate_search = 1;
+
+ if (terminate_search) {
+ state->in_search = 0;
+ bzero(state->pattern, sizeof(state->pattern));
+ move(0, 0);
+ refresh();
+ clrtoeol();
+ return -1;
+ }
+ return 0;
+}
+
+static void conf(struct menu *menu)
+{
+ struct menu *submenu = 0;
+ const char *prompt = menu_get_prompt(menu);
+ struct symbol *sym;
+ int res;
+ int current_index = 0;
+ int last_top_row = 0;
+ struct match_state match_state = {
+ .in_search = 0,
+ .match_direction = MATCH_TINKER_PATTERN_DOWN,
+ .pattern = "",
+ };
+
+ while (!global_exit) {
+ reset_menu();
+ current_menu = menu;
+ build_conf(menu);
+ if (!child_count)
+ break;
+
+ show_menu(prompt ? _(prompt) : _("Main Menu"),
+ _(menu_instructions),
+ current_index, &last_top_row);
+ keypad((menu_win(curses_menu)), TRUE);
+ while (!global_exit) {
+ if (match_state.in_search) {
+ mvprintw(0, 0,
+ "searching: %s", match_state.pattern);
+ clrtoeol();
+ }
+ refresh_all_windows(main_window);
+ res = wgetch(menu_win(curses_menu));
+ if (!res)
+ break;
+ if (do_match(res, &match_state, &current_index) == 0) {
+ if (current_index != -1)
+ center_item(current_index,
+ &last_top_row);
+ continue;
+ }
+ if (process_special_keys(&res,
+ (struct menu *) item_data()))
+ break;
+ switch (res) {
+ case KEY_DOWN:
+ menu_driver(curses_menu, REQ_DOWN_ITEM);
+ break;
+ case KEY_UP:
+ menu_driver(curses_menu, REQ_UP_ITEM);
+ break;
+ case KEY_NPAGE:
+ menu_driver(curses_menu, REQ_SCR_DPAGE);
+ break;
+ case KEY_PPAGE:
+ menu_driver(curses_menu, REQ_SCR_UPAGE);
+ break;
+ case KEY_HOME:
+ menu_driver(curses_menu, REQ_FIRST_ITEM);
+ break;
+ case KEY_END:
+ menu_driver(curses_menu, REQ_LAST_ITEM);
+ break;
+ case 'h':
+ case '?':
+ show_help((struct menu *) item_data());
+ break;
+ }
+ if (res == 10 || res == 27 ||
+ res == 32 || res == 'n' || res == 'y' ||
+ res == KEY_LEFT || res == KEY_RIGHT ||
+ res == 'm')
+ break;
+ refresh_all_windows(main_window);
+ }
+
+ refresh_all_windows(main_window);
+ /* if ESC or left*/
+ if (res == 27 || (menu != &rootmenu && res == KEY_LEFT))
+ break;
+
+ /* remember location in the menu */
+ last_top_row = top_row(curses_menu);
+ current_index = curses_item_index();
+
+ if (!item_tag())
+ continue;
+
+ submenu = (struct menu *) item_data();
+ if (!submenu || !menu_is_visible(submenu))
+ continue;
+ sym = submenu->sym;
+
+ switch (res) {
+ case ' ':
+ if (item_is_tag('t'))
+ sym_toggle_tristate_value(sym);
+ else if (item_is_tag('m'))
+ conf(submenu);
+ break;
+ case KEY_RIGHT:
+ case 10: /* ENTER WAS PRESSED */
+ switch (item_tag()) {
+ case 'm':
+ if (single_menu_mode)
+ submenu->data =
+ (void *) (long) !submenu->data;
+ else
+ conf(submenu);
+ break;
+ case 't':
+ if (sym_is_choice(sym) &&
+ sym_get_tristate_value(sym) == yes)
+ conf_choice(submenu);
+ else if (submenu->prompt &&
+ submenu->prompt->type == P_MENU)
+ conf(submenu);
+ else if (res == 10)
+ sym_toggle_tristate_value(sym);
+ break;
+ case 's':
+ conf_string(submenu);
+ break;
+ }
+ break;
+ case 'y':
+ if (item_is_tag('t')) {
+ if (sym_set_tristate_value(sym, yes))
+ break;
+ if (sym_set_tristate_value(sym, mod))
+ btn_dialog(main_window, setmod_text, 0);
+ }
+ break;
+ case 'n':
+ if (item_is_tag('t'))
+ sym_set_tristate_value(sym, no);
+ break;
+ case 'm':
+ if (item_is_tag('t'))
+ sym_set_tristate_value(sym, mod);
+ break;
+ }
+ }
+}
+
+static void conf_message_callback(const char *fmt, va_list ap)
+{
+ char buf[1024];
+
+ vsnprintf(buf, sizeof(buf), fmt, ap);
+ btn_dialog(main_window, buf, 1, "<OK>");
+}
+
+static void show_help(struct menu *menu)
+{
+ struct gstr help;
+
+ if (!menu)
+ return;
+
+ help = str_new();
+ menu_get_ext_help(menu, &help);
+ show_scroll_win(main_window, _(menu_get_prompt(menu)), str_get(&help));
+ str_free(&help);
+}
+
+static void conf_choice(struct menu *menu)
+{
+ const char *prompt = _(menu_get_prompt(menu));
+ struct menu *child = 0;
+ struct symbol *active;
+ int selected_index = 0;
+ int last_top_row = 0;
+ int res, i = 0;
+ struct match_state match_state = {
+ .in_search = 0,
+ .match_direction = MATCH_TINKER_PATTERN_DOWN,
+ .pattern = "",
+ };
+
+ active = sym_get_choice_value(menu->sym);
+ /* this is mostly duplicated from the conf() function. */
+ while (!global_exit) {
+ reset_menu();
+
+ for (i = 0, child = menu->list; child; child = child->next) {
+ if (!show_all_items && !menu_is_visible(child))
+ continue;
+
+ if (child->sym == sym_get_choice_value(menu->sym))
+ item_make(child, ':', "<X> %s",
+ _(menu_get_prompt(child)));
+ else if (child->sym)
+ item_make(child, ':', " %s",
+ _(menu_get_prompt(child)));
+ else
+ item_make(child, ':', "*** %s ***",
+ _(menu_get_prompt(child)));
+
+ if (child->sym == active){
+ last_top_row = top_row(curses_menu);
+ selected_index = i;
+ }
+ i++;
+ }
+ show_menu(prompt ? _(prompt) : _("Choice Menu"),
+ _(radiolist_instructions),
+ selected_index,
+ &last_top_row);
+ while (!global_exit) {
+ if (match_state.in_search) {
+ mvprintw(0, 0, "searching: %s",
+ match_state.pattern);
+ clrtoeol();
+ }
+ refresh_all_windows(main_window);
+ res = wgetch(menu_win(curses_menu));
+ if (!res)
+ break;
+ if (do_match(res, &match_state, &selected_index) == 0) {
+ if (selected_index != -1)
+ center_item(selected_index,
+ &last_top_row);
+ continue;
+ }
+ if (process_special_keys(
+ &res,
+ (struct menu *) item_data()))
+ break;
+ switch (res) {
+ case KEY_DOWN:
+ menu_driver(curses_menu, REQ_DOWN_ITEM);
+ break;
+ case KEY_UP:
+ menu_driver(curses_menu, REQ_UP_ITEM);
+ break;
+ case KEY_NPAGE:
+ menu_driver(curses_menu, REQ_SCR_DPAGE);
+ break;
+ case KEY_PPAGE:
+ menu_driver(curses_menu, REQ_SCR_UPAGE);
+ break;
+ case KEY_HOME:
+ menu_driver(curses_menu, REQ_FIRST_ITEM);
+ break;
+ case KEY_END:
+ menu_driver(curses_menu, REQ_LAST_ITEM);
+ break;
+ case 'h':
+ case '?':
+ show_help((struct menu *) item_data());
+ break;
+ }
+ if (res == 10 || res == 27 || res == ' ' ||
+ res == KEY_LEFT){
+ break;
+ }
+ refresh_all_windows(main_window);
+ }
+ /* if ESC or left */
+ if (res == 27 || res == KEY_LEFT)
+ break;
+
+ child = item_data();
+ if (!child || !menu_is_visible(child) || !child->sym)
+ continue;
+ switch (res) {
+ case ' ':
+ case 10:
+ case KEY_RIGHT:
+ sym_set_tristate_value(child->sym, yes);
+ return;
+ case 'h':
+ case '?':
+ show_help(child);
+ active = child->sym;
+ break;
+ case KEY_EXIT:
+ return;
+ }
+ }
+}
+
+static void conf_string(struct menu *menu)
+{
+ const char *prompt = menu_get_prompt(menu);
+
+ while (1) {
+ int res;
+ const char *heading;
+
+ switch (sym_get_type(menu->sym)) {
+ case S_INT:
+ heading = _(inputbox_instructions_int);
+ break;
+ case S_HEX:
+ heading = _(inputbox_instructions_hex);
+ break;
+ case S_STRING:
+ heading = _(inputbox_instructions_string);
+ break;
+ default:
+ heading = _("Internal nconf error!");
+ }
+ res = dialog_inputbox(main_window,
+ prompt ? _(prompt) : _("Main Menu"),
+ heading,
+ sym_get_string_value(menu->sym),
+ &dialog_input_result,
+ &dialog_input_result_len);
+ switch (res) {
+ case 0:
+ if (sym_set_string_value(menu->sym,
+ dialog_input_result))
+ return;
+ btn_dialog(main_window,
+ _("You have made an invalid entry."), 0);
+ break;
+ case 1:
+ show_help(menu);
+ break;
+ case KEY_EXIT:
+ return;
+ }
+ }
+}
+
+static void conf_load(void)
+{
+ while (1) {
+ int res;
+ res = dialog_inputbox(main_window,
+ NULL, load_config_text,
+ filename,
+ &dialog_input_result,
+ &dialog_input_result_len);
+ switch (res) {
+ case 0:
+ if (!dialog_input_result[0])
+ return;
+ if (!conf_read(dialog_input_result)) {
+ set_config_filename(dialog_input_result);
+ sym_set_change_count(1);
+ return;
+ }
+ btn_dialog(main_window, _("File does not exist!"), 0);
+ break;
+ case 1:
+ show_scroll_win(main_window,
+ _("Load Alternate Configuration"),
+ load_config_help);
+ break;
+ case KEY_EXIT:
+ return;
+ }
+ }
+}
+
+static void conf_save(void)
+{
+ while (1) {
+ int res;
+ res = dialog_inputbox(main_window,
+ NULL, save_config_text,
+ filename,
+ &dialog_input_result,
+ &dialog_input_result_len);
+ switch (res) {
+ case 0:
+ if (!dialog_input_result[0])
+ return;
+ res = conf_write(dialog_input_result);
+ if (!res) {
+ set_config_filename(dialog_input_result);
+ return;
+ }
+ btn_dialog(main_window, _("Can't create file! "
+ "Probably a nonexistent directory."),
+ 1, "<OK>");
+ break;
+ case 1:
+ show_scroll_win(main_window,
+ _("Save Alternate Configuration"),
+ save_config_help);
+ break;
+ case KEY_EXIT:
+ return;
+ }
+ }
+}
+
+void setup_windows(void)
+{
+ int lines, columns;
+
+ getmaxyx(stdscr, lines, columns);
+
+ if (main_window != NULL)
+ delwin(main_window);
+
+ /* set up the menu and menu window */
+ main_window = newwin(lines-2, columns-2, 2, 1);
+ keypad(main_window, TRUE);
+ mwin_max_lines = lines-7;
+ mwin_max_cols = columns-6;
+
+ /* panels order is from bottom to top */
+ new_panel(main_window);
+}
+
+int main(int ac, char **av)
+{
+ int lines, columns;
+ char *mode;
+
+ setlocale(LC_ALL, "");
+ bindtextdomain(PACKAGE, LOCALEDIR);
+ textdomain(PACKAGE);
+
+ conf_parse(av[1]);
+ conf_read(NULL);
+
+ mode = getenv("NCONFIG_MODE");
+ if (mode) {
+ if (!strcasecmp(mode, "single_menu"))
+ single_menu_mode = 1;
+ }
+
+ /* Initialize curses */
+ initscr();
+ /* set color theme */
+ set_colors();
+
+ cbreak();
+ noecho();
+ keypad(stdscr, TRUE);
+ curs_set(0);
+
+ getmaxyx(stdscr, lines, columns);
+ if (columns < 75 || lines < 20) {
+ endwin();
+ printf("Your terminal should have at "
+ "least 20 lines and 75 columns\n");
+ return 1;
+ }
+
+ notimeout(stdscr, FALSE);
+#if NCURSES_REENTRANT
+ set_escdelay(1);
+#else
+ ESCDELAY = 1;
+#endif
+
+ /* set btns menu */
+ curses_menu = new_menu(curses_menu_items);
+ menu_opts_off(curses_menu, O_SHOWDESC);
+ menu_opts_on(curses_menu, O_SHOWMATCH);
+ menu_opts_on(curses_menu, O_ONEVALUE);
+ menu_opts_on(curses_menu, O_NONCYCLIC);
+ menu_opts_on(curses_menu, O_IGNORECASE);
+ set_menu_mark(curses_menu, " ");
+ set_menu_fore(curses_menu, attributes[MAIN_MENU_FORE]);
+ set_menu_back(curses_menu, attributes[MAIN_MENU_BACK]);
+ set_menu_grey(curses_menu, attributes[MAIN_MENU_GREY]);
+
+ set_config_filename(conf_get_configname());
+ setup_windows();
+
+ /* check for KEY_FUNC(1) */
+ if (has_key(KEY_F(1)) == FALSE) {
+ show_scroll_win(main_window,
+ _("Instructions"),
+ _(menu_no_f_instructions));
+ }
+
+ conf_set_message_callback(conf_message_callback);
+ /* do the work */
+ while (!global_exit) {
+ conf(&rootmenu);
+ if (!global_exit && do_exit() == 0)
+ break;
+ }
+ /* ok, we are done */
+ unpost_menu(curses_menu);
+ free_menu(curses_menu);
+ delwin(main_window);
+ clear();
+ refresh();
+ endwin();
+ return 0;
+}
+
diff --git a/extra/config/nconf.gui.c b/extra/config/nconf.gui.c
new file mode 100644
index 000000000..8275f0e55
--- /dev/null
+++ b/extra/config/nconf.gui.c
@@ -0,0 +1,656 @@
+/*
+ * Copyright (C) 2008 Nir Tzachar <nir.tzachar@gmail.com?
+ * Released under the terms of the GNU GPL v2.0.
+ *
+ * Derived from menuconfig.
+ *
+ */
+#include "nconf.h"
+
+/* a list of all the different widgets we use */
+attributes_t attributes[ATTR_MAX+1] = {0};
+
+/* available colors:
+ COLOR_BLACK 0
+ COLOR_RED 1
+ COLOR_GREEN 2
+ COLOR_YELLOW 3
+ COLOR_BLUE 4
+ COLOR_MAGENTA 5
+ COLOR_CYAN 6
+ COLOR_WHITE 7
+ */
+static void set_normal_colors(void)
+{
+ init_pair(NORMAL, -1, -1);
+ init_pair(MAIN_HEADING, COLOR_MAGENTA, -1);
+
+ /* FORE is for the selected item */
+ init_pair(MAIN_MENU_FORE, -1, -1);
+ /* BACK for all the rest */
+ init_pair(MAIN_MENU_BACK, -1, -1);
+ init_pair(MAIN_MENU_GREY, -1, -1);
+ init_pair(MAIN_MENU_HEADING, COLOR_GREEN, -1);
+ init_pair(MAIN_MENU_BOX, COLOR_YELLOW, -1);
+
+ init_pair(SCROLLWIN_TEXT, -1, -1);
+ init_pair(SCROLLWIN_HEADING, COLOR_GREEN, -1);
+ init_pair(SCROLLWIN_BOX, COLOR_YELLOW, -1);
+
+ init_pair(DIALOG_TEXT, -1, -1);
+ init_pair(DIALOG_BOX, COLOR_YELLOW, -1);
+ init_pair(DIALOG_MENU_BACK, COLOR_YELLOW, -1);
+ init_pair(DIALOG_MENU_FORE, COLOR_RED, -1);
+
+ init_pair(INPUT_BOX, COLOR_YELLOW, -1);
+ init_pair(INPUT_HEADING, COLOR_GREEN, -1);
+ init_pair(INPUT_TEXT, -1, -1);
+ init_pair(INPUT_FIELD, -1, -1);
+
+ init_pair(FUNCTION_HIGHLIGHT, -1, -1);
+ init_pair(FUNCTION_TEXT, COLOR_YELLOW, -1);
+}
+
+/* available attributes:
+ A_NORMAL Normal display (no highlight)
+ A_STANDOUT Best highlighting mode of the terminal.
+ A_UNDERLINE Underlining
+ A_REVERSE Reverse video
+ A_BLINK Blinking
+ A_DIM Half bright
+ A_BOLD Extra bright or bold
+ A_PROTECT Protected mode
+ A_INVIS Invisible or blank mode
+ A_ALTCHARSET Alternate character set
+ A_CHARTEXT Bit-mask to extract a character
+ COLOR_PAIR(n) Color-pair number n
+ */
+static void normal_color_theme(void)
+{
+ /* automatically add color... */
+#define mkattr(name, attr) do { \
+attributes[name] = attr | COLOR_PAIR(name); } while (0)
+ mkattr(NORMAL, NORMAL);
+ mkattr(MAIN_HEADING, A_BOLD | A_UNDERLINE);
+
+ mkattr(MAIN_MENU_FORE, A_REVERSE);
+ mkattr(MAIN_MENU_BACK, A_NORMAL);
+ mkattr(MAIN_MENU_GREY, A_NORMAL);
+ mkattr(MAIN_MENU_HEADING, A_BOLD);
+ mkattr(MAIN_MENU_BOX, A_NORMAL);
+
+ mkattr(SCROLLWIN_TEXT, A_NORMAL);
+ mkattr(SCROLLWIN_HEADING, A_BOLD);
+ mkattr(SCROLLWIN_BOX, A_BOLD);
+
+ mkattr(DIALOG_TEXT, A_BOLD);
+ mkattr(DIALOG_BOX, A_BOLD);
+ mkattr(DIALOG_MENU_FORE, A_STANDOUT);
+ mkattr(DIALOG_MENU_BACK, A_NORMAL);
+
+ mkattr(INPUT_BOX, A_NORMAL);
+ mkattr(INPUT_HEADING, A_BOLD);
+ mkattr(INPUT_TEXT, A_NORMAL);
+ mkattr(INPUT_FIELD, A_UNDERLINE);
+
+ mkattr(FUNCTION_HIGHLIGHT, A_BOLD);
+ mkattr(FUNCTION_TEXT, A_REVERSE);
+}
+
+static void no_colors_theme(void)
+{
+ /* automatically add highlight, no color */
+#define mkattrn(name, attr) { attributes[name] = attr; }
+
+ mkattrn(NORMAL, NORMAL);
+ mkattrn(MAIN_HEADING, A_BOLD | A_UNDERLINE);
+
+ mkattrn(MAIN_MENU_FORE, A_STANDOUT);
+ mkattrn(MAIN_MENU_BACK, A_NORMAL);
+ mkattrn(MAIN_MENU_GREY, A_NORMAL);
+ mkattrn(MAIN_MENU_HEADING, A_BOLD);
+ mkattrn(MAIN_MENU_BOX, A_NORMAL);
+
+ mkattrn(SCROLLWIN_TEXT, A_NORMAL);
+ mkattrn(SCROLLWIN_HEADING, A_BOLD);
+ mkattrn(SCROLLWIN_BOX, A_BOLD);
+
+ mkattrn(DIALOG_TEXT, A_NORMAL);
+ mkattrn(DIALOG_BOX, A_BOLD);
+ mkattrn(DIALOG_MENU_FORE, A_STANDOUT);
+ mkattrn(DIALOG_MENU_BACK, A_NORMAL);
+
+ mkattrn(INPUT_BOX, A_BOLD);
+ mkattrn(INPUT_HEADING, A_BOLD);
+ mkattrn(INPUT_TEXT, A_NORMAL);
+ mkattrn(INPUT_FIELD, A_UNDERLINE);
+
+ mkattrn(FUNCTION_HIGHLIGHT, A_BOLD);
+ mkattrn(FUNCTION_TEXT, A_REVERSE);
+}
+
+void set_colors()
+{
+ start_color();
+ use_default_colors();
+ set_normal_colors();
+ if (has_colors()) {
+ normal_color_theme();
+ } else {
+ /* give defaults */
+ no_colors_theme();
+ }
+}
+
+
+/* this changes the windows attributes !!! */
+void print_in_middle(WINDOW *win,
+ int starty,
+ int startx,
+ int width,
+ const char *string,
+ chtype color)
+{ int length, x, y;
+ float temp;
+
+
+ if (win == NULL)
+ win = stdscr;
+ getyx(win, y, x);
+ if (startx != 0)
+ x = startx;
+ if (starty != 0)
+ y = starty;
+ if (width == 0)
+ width = 80;
+
+ length = strlen(string);
+ temp = (width - length) / 2;
+ x = startx + (int)temp;
+ (void) wattrset(win, color);
+ mvwprintw(win, y, x, "%s", string);
+ refresh();
+}
+
+int get_line_no(const char *text)
+{
+ int i;
+ int total = 1;
+
+ if (!text)
+ return 0;
+
+ for (i = 0; text[i] != '\0'; i++)
+ if (text[i] == '\n')
+ total++;
+ return total;
+}
+
+const char *get_line(const char *text, int line_no)
+{
+ int i;
+ int lines = 0;
+
+ if (!text)
+ return 0;
+
+ for (i = 0; text[i] != '\0' && lines < line_no; i++)
+ if (text[i] == '\n')
+ lines++;
+ return text+i;
+}
+
+int get_line_length(const char *line)
+{
+ int res = 0;
+ while (*line != '\0' && *line != '\n') {
+ line++;
+ res++;
+ }
+ return res;
+}
+
+/* print all lines to the window. */
+void fill_window(WINDOW *win, const char *text)
+{
+ int x, y;
+ int total_lines = get_line_no(text);
+ int i;
+
+ getmaxyx(win, y, x);
+ /* do not go over end of line */
+ total_lines = min(total_lines, y);
+ for (i = 0; i < total_lines; i++) {
+ char tmp[x+10];
+ const char *line = get_line(text, i);
+ int len = get_line_length(line);
+ strncpy(tmp, line, min(len, x));
+ tmp[len] = '\0';
+ mvwprintw(win, i, 0, "%s", tmp);
+ }
+}
+
+/* get the message, and buttons.
+ * each button must be a char*
+ * return the selected button
+ *
+ * this dialog is used for 2 different things:
+ * 1) show a text box, no buttons.
+ * 2) show a dialog, with horizontal buttons
+ */
+int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...)
+{
+ va_list ap;
+ char *btn;
+ int btns_width = 0;
+ int msg_lines = 0;
+ int msg_width = 0;
+ int total_width;
+ int win_rows = 0;
+ WINDOW *win;
+ WINDOW *msg_win;
+ WINDOW *menu_win;
+ MENU *menu;
+ ITEM *btns[btn_num+1];
+ int i, x, y;
+ int res = -1;
+
+
+ va_start(ap, btn_num);
+ for (i = 0; i < btn_num; i++) {
+ btn = va_arg(ap, char *);
+ btns[i] = new_item(btn, "");
+ btns_width += strlen(btn)+1;
+ }
+ va_end(ap);
+ btns[btn_num] = NULL;
+
+ /* find the widest line of msg: */
+ msg_lines = get_line_no(msg);
+ for (i = 0; i < msg_lines; i++) {
+ const char *line = get_line(msg, i);
+ int len = get_line_length(line);
+ if (msg_width < len)
+ msg_width = len;
+ }
+
+ total_width = max(msg_width, btns_width);
+ /* place dialog in middle of screen */
+ y = (getmaxy(stdscr)-(msg_lines+4))/2;
+ x = (getmaxx(stdscr)-(total_width+4))/2;
+
+
+ /* create the windows */
+ if (btn_num > 0)
+ win_rows = msg_lines+4;
+ else
+ win_rows = msg_lines+2;
+
+ win = newwin(win_rows, total_width+4, y, x);
+ keypad(win, TRUE);
+ menu_win = derwin(win, 1, btns_width, win_rows-2,
+ 1+(total_width+2-btns_width)/2);
+ menu = new_menu(btns);
+ msg_win = derwin(win, win_rows-2, msg_width, 1,
+ 1+(total_width+2-msg_width)/2);
+
+ set_menu_fore(menu, attributes[DIALOG_MENU_FORE]);
+ set_menu_back(menu, attributes[DIALOG_MENU_BACK]);
+
+ (void) wattrset(win, attributes[DIALOG_BOX]);
+ box(win, 0, 0);
+
+ /* print message */
+ (void) wattrset(msg_win, attributes[DIALOG_TEXT]);
+ fill_window(msg_win, msg);
+
+ set_menu_win(menu, win);
+ set_menu_sub(menu, menu_win);
+ set_menu_format(menu, 1, btn_num);
+ menu_opts_off(menu, O_SHOWDESC);
+ menu_opts_off(menu, O_SHOWMATCH);
+ menu_opts_on(menu, O_ONEVALUE);
+ menu_opts_on(menu, O_NONCYCLIC);
+ set_menu_mark(menu, "");
+ post_menu(menu);
+
+
+ touchwin(win);
+ refresh_all_windows(main_window);
+ while ((res = wgetch(win))) {
+ switch (res) {
+ case KEY_LEFT:
+ menu_driver(menu, REQ_LEFT_ITEM);
+ break;
+ case KEY_RIGHT:
+ menu_driver(menu, REQ_RIGHT_ITEM);
+ break;
+ case 10: /* ENTER */
+ case 27: /* ESCAPE */
+ case ' ':
+ case KEY_F(F_BACK):
+ case KEY_F(F_EXIT):
+ break;
+ }
+ touchwin(win);
+ refresh_all_windows(main_window);
+
+ if (res == 10 || res == ' ') {
+ res = item_index(current_item(menu));
+ break;
+ } else if (res == 27 || res == KEY_F(F_BACK) ||
+ res == KEY_F(F_EXIT)) {
+ res = KEY_EXIT;
+ break;
+ }
+ }
+
+ unpost_menu(menu);
+ free_menu(menu);
+ for (i = 0; i < btn_num; i++)
+ free_item(btns[i]);
+
+ delwin(win);
+ return res;
+}
+
+int dialog_inputbox(WINDOW *main_window,
+ const char *title, const char *prompt,
+ const char *init, char **resultp, int *result_len)
+{
+ int prompt_lines = 0;
+ int prompt_width = 0;
+ WINDOW *win;
+ WINDOW *prompt_win;
+ WINDOW *form_win;
+ PANEL *panel;
+ int i, x, y;
+ int res = -1;
+ int cursor_position = strlen(init);
+ int cursor_form_win;
+ char *result = *resultp;
+
+ if (strlen(init)+1 > *result_len) {
+ *result_len = strlen(init)+1;
+ *resultp = result = realloc(result, *result_len);
+ }
+
+ /* find the widest line of msg: */
+ prompt_lines = get_line_no(prompt);
+ for (i = 0; i < prompt_lines; i++) {
+ const char *line = get_line(prompt, i);
+ int len = get_line_length(line);
+ prompt_width = max(prompt_width, len);
+ }
+
+ if (title)
+ prompt_width = max(prompt_width, strlen(title));
+
+ /* place dialog in middle of screen */
+ y = (getmaxy(stdscr)-(prompt_lines+4))/2;
+ x = (getmaxx(stdscr)-(prompt_width+4))/2;
+
+ strncpy(result, init, *result_len);
+
+ /* create the windows */
+ win = newwin(prompt_lines+6, prompt_width+7, y, x);
+ prompt_win = derwin(win, prompt_lines+1, prompt_width, 2, 2);
+ form_win = derwin(win, 1, prompt_width, prompt_lines+3, 2);
+ keypad(form_win, TRUE);
+
+ (void) wattrset(form_win, attributes[INPUT_FIELD]);
+
+ (void) wattrset(win, attributes[INPUT_BOX]);
+ box(win, 0, 0);
+ (void) wattrset(win, attributes[INPUT_HEADING]);
+ if (title)
+ mvwprintw(win, 0, 3, "%s", title);
+
+ /* print message */
+ (void) wattrset(prompt_win, attributes[INPUT_TEXT]);
+ fill_window(prompt_win, prompt);
+
+ mvwprintw(form_win, 0, 0, "%*s", prompt_width, " ");
+ cursor_form_win = min(cursor_position, prompt_width-1);
+ mvwprintw(form_win, 0, 0, "%s",
+ result + cursor_position-cursor_form_win);
+
+ /* create panels */
+ panel = new_panel(win);
+
+ /* show the cursor */
+ curs_set(1);
+
+ touchwin(win);
+ refresh_all_windows(main_window);
+ while ((res = wgetch(form_win))) {
+ int len = strlen(result);
+ switch (res) {
+ case 10: /* ENTER */
+ case 27: /* ESCAPE */
+ case KEY_F(F_HELP):
+ case KEY_F(F_EXIT):
+ case KEY_F(F_BACK):
+ break;
+ case 127:
+ case KEY_BACKSPACE:
+ if (cursor_position > 0) {
+ memmove(&result[cursor_position-1],
+ &result[cursor_position],
+ len-cursor_position+1);
+ cursor_position--;
+ cursor_form_win--;
+ len--;
+ }
+ break;
+ case KEY_DC:
+ if (cursor_position >= 0 && cursor_position < len) {
+ memmove(&result[cursor_position],
+ &result[cursor_position+1],
+ len-cursor_position+1);
+ len--;
+ }
+ break;
+ case KEY_UP:
+ case KEY_RIGHT:
+ if (cursor_position < len) {
+ cursor_position++;
+ cursor_form_win++;
+ }
+ break;
+ case KEY_DOWN:
+ case KEY_LEFT:
+ if (cursor_position > 0) {
+ cursor_position--;
+ cursor_form_win--;
+ }
+ break;
+ case KEY_HOME:
+ cursor_position = 0;
+ cursor_form_win = 0;
+ break;
+ case KEY_END:
+ cursor_position = len;
+ cursor_form_win = min(cursor_position, prompt_width-1);
+ break;
+ default:
+ if ((isgraph(res) || isspace(res))) {
+ /* one for new char, one for '\0' */
+ if (len+2 > *result_len) {
+ *result_len = len+2;
+ *resultp = result = realloc(result,
+ *result_len);
+ }
+ /* insert the char at the proper position */
+ memmove(&result[cursor_position+1],
+ &result[cursor_position],
+ len-cursor_position+1);
+ result[cursor_position] = res;
+ cursor_position++;
+ cursor_form_win++;
+ len++;
+ } else {
+ mvprintw(0, 0, "unknown key: %d\n", res);
+ }
+ break;
+ }
+ if (cursor_form_win < 0)
+ cursor_form_win = 0;
+ else if (cursor_form_win > prompt_width-1)
+ cursor_form_win = prompt_width-1;
+
+ wmove(form_win, 0, 0);
+ wclrtoeol(form_win);
+ mvwprintw(form_win, 0, 0, "%*s", prompt_width, " ");
+ mvwprintw(form_win, 0, 0, "%s",
+ result + cursor_position-cursor_form_win);
+ wmove(form_win, 0, cursor_form_win);
+ touchwin(win);
+ refresh_all_windows(main_window);
+
+ if (res == 10) {
+ res = 0;
+ break;
+ } else if (res == 27 || res == KEY_F(F_BACK) ||
+ res == KEY_F(F_EXIT)) {
+ res = KEY_EXIT;
+ break;
+ } else if (res == KEY_F(F_HELP)) {
+ res = 1;
+ break;
+ }
+ }
+
+ /* hide the cursor */
+ curs_set(0);
+ del_panel(panel);
+ delwin(prompt_win);
+ delwin(form_win);
+ delwin(win);
+ return res;
+}
+
+/* refresh all windows in the correct order */
+void refresh_all_windows(WINDOW *main_window)
+{
+ update_panels();
+ touchwin(main_window);
+ refresh();
+}
+
+/* layman's scrollable window... */
+void show_scroll_win(WINDOW *main_window,
+ const char *title,
+ const char *text)
+{
+ int res;
+ int total_lines = get_line_no(text);
+ int x, y, lines, columns;
+ int start_x = 0, start_y = 0;
+ int text_lines = 0, text_cols = 0;
+ int total_cols = 0;
+ int win_cols = 0;
+ int win_lines = 0;
+ int i = 0;
+ WINDOW *win;
+ WINDOW *pad;
+ PANEL *panel;
+
+ getmaxyx(stdscr, lines, columns);
+
+ /* find the widest line of msg: */
+ total_lines = get_line_no(text);
+ for (i = 0; i < total_lines; i++) {
+ const char *line = get_line(text, i);
+ int len = get_line_length(line);
+ total_cols = max(total_cols, len+2);
+ }
+
+ /* create the pad */
+ pad = newpad(total_lines+10, total_cols+10);
+ (void) wattrset(pad, attributes[SCROLLWIN_TEXT]);
+ fill_window(pad, text);
+
+ win_lines = min(total_lines+4, lines-2);
+ win_cols = min(total_cols+2, columns-2);
+ text_lines = max(win_lines-4, 0);
+ text_cols = max(win_cols-2, 0);
+
+ /* place window in middle of screen */
+ y = (lines-win_lines)/2;
+ x = (columns-win_cols)/2;
+
+ win = newwin(win_lines, win_cols, y, x);
+ keypad(win, TRUE);
+ /* show the help in the help window, and show the help panel */
+ (void) wattrset(win, attributes[SCROLLWIN_BOX]);
+ box(win, 0, 0);
+ (void) wattrset(win, attributes[SCROLLWIN_HEADING]);
+ mvwprintw(win, 0, 3, " %s ", title);
+ panel = new_panel(win);
+
+ /* handle scrolling */
+ do {
+
+ copywin(pad, win, start_y, start_x, 2, 2, text_lines,
+ text_cols, 0);
+ print_in_middle(win,
+ text_lines+2,
+ 0,
+ text_cols,
+ "<OK>",
+ attributes[DIALOG_MENU_FORE]);
+ wrefresh(win);
+
+ res = wgetch(win);
+ switch (res) {
+ case KEY_NPAGE:
+ case ' ':
+ case 'd':
+ start_y += text_lines-2;
+ break;
+ case KEY_PPAGE:
+ case 'u':
+ start_y -= text_lines+2;
+ break;
+ case KEY_HOME:
+ start_y = 0;
+ break;
+ case KEY_END:
+ start_y = total_lines-text_lines;
+ break;
+ case KEY_DOWN:
+ case 'j':
+ start_y++;
+ break;
+ case KEY_UP:
+ case 'k':
+ start_y--;
+ break;
+ case KEY_LEFT:
+ case 'h':
+ start_x--;
+ break;
+ case KEY_RIGHT:
+ case 'l':
+ start_x++;
+ break;
+ }
+ if (res == 10 || res == 27 || res == 'q' ||
+ res == KEY_F(F_HELP) || res == KEY_F(F_BACK) ||
+ res == KEY_F(F_EXIT))
+ break;
+ if (start_y < 0)
+ start_y = 0;
+ if (start_y >= total_lines-text_lines)
+ start_y = total_lines-text_lines;
+ if (start_x < 0)
+ start_x = 0;
+ if (start_x >= total_cols-text_cols)
+ start_x = total_cols-text_cols;
+ } while (res);
+
+ del_panel(panel);
+ delwin(win);
+ refresh_all_windows(main_window);
+}
diff --git a/extra/config/nconf.h b/extra/config/nconf.h
new file mode 100644
index 000000000..0d5261705
--- /dev/null
+++ b/extra/config/nconf.h
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2008 Nir Tzachar <nir.tzachar@gmail.com?
+ * Released under the terms of the GNU GPL v2.0.
+ *
+ * Derived from menuconfig.
+ *
+ */
+
+#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <locale.h>
+#include <curses.h>
+#include <menu.h>
+#include <panel.h>
+#include <form.h>
+
+#include <stdio.h>
+#include <time.h>
+#include <sys/time.h>
+
+#include "ncurses.h"
+
+#define max(a, b) ({\
+ typeof(a) _a = a;\
+ typeof(b) _b = b;\
+ _a > _b ? _a : _b; })
+
+#define min(a, b) ({\
+ typeof(a) _a = a;\
+ typeof(b) _b = b;\
+ _a < _b ? _a : _b; })
+
+typedef enum {
+ NORMAL = 1,
+ MAIN_HEADING,
+ MAIN_MENU_BOX,
+ MAIN_MENU_FORE,
+ MAIN_MENU_BACK,
+ MAIN_MENU_GREY,
+ MAIN_MENU_HEADING,
+ SCROLLWIN_TEXT,
+ SCROLLWIN_HEADING,
+ SCROLLWIN_BOX,
+ DIALOG_TEXT,
+ DIALOG_MENU_FORE,
+ DIALOG_MENU_BACK,
+ DIALOG_BOX,
+ INPUT_BOX,
+ INPUT_HEADING,
+ INPUT_TEXT,
+ INPUT_FIELD,
+ FUNCTION_TEXT,
+ FUNCTION_HIGHLIGHT,
+ ATTR_MAX
+} attributes_t;
+extern attributes_t attributes[];
+
+typedef enum {
+ F_HELP = 1,
+ F_SYMBOL = 2,
+ F_INSTS = 3,
+ F_CONF = 4,
+ F_BACK = 5,
+ F_SAVE = 6,
+ F_LOAD = 7,
+ F_SEARCH = 8,
+ F_EXIT = 9,
+} function_key;
+
+void set_colors(void);
+
+/* this changes the windows attributes !!! */
+void print_in_middle(WINDOW *win,
+ int starty,
+ int startx,
+ int width,
+ const char *string,
+ chtype color);
+int get_line_length(const char *line);
+int get_line_no(const char *text);
+const char *get_line(const char *text, int line_no);
+void fill_window(WINDOW *win, const char *text);
+int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...);
+int dialog_inputbox(WINDOW *main_window,
+ const char *title, const char *prompt,
+ const char *init, char **resultp, int *result_len);
+void refresh_all_windows(WINDOW *main_window);
+void show_scroll_win(WINDOW *main_window,
+ const char *title,
+ const char *text);
diff --git a/extra/config/qconf.cc b/extra/config/qconf.cc
index ec3b5bb1e..8db89b8b0 100644
--- a/extra/config/qconf.cc
+++ b/extra/config/qconf.cc
@@ -3,24 +3,43 @@
* Released under the terms of the GNU GPL v2.0.
*/
-#include <qapplication.h>
+#include <qglobal.h>
+
+#if QT_VERSION < 0x040000
+#include <stddef.h>
#include <qmainwindow.h>
+#include <qvbox.h>
+#include <qvaluelist.h>
+#include <qtextbrowser.h>
+#include <qaction.h>
+#include <qheader.h>
+#include <qfiledialog.h>
+#include <qdragobject.h>
+#include <qpopupmenu.h>
+#else
+#include <q3mainwindow.h>
+#include <q3vbox.h>
+#include <q3valuelist.h>
+#include <q3textbrowser.h>
+#include <q3action.h>
+#include <q3header.h>
+#include <q3filedialog.h>
+#include <q3dragobject.h>
+#include <q3popupmenu.h>
+#endif
+
+#include <qapplication.h>
+#include <qdesktopwidget.h>
#include <qtoolbar.h>
#include <qlayout.h>
-#include <qvbox.h>
#include <qsplitter.h>
-#include <qlistview.h>
-#include <qtextbrowser.h>
#include <qlineedit.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <qmenubar.h>
#include <qmessagebox.h>
-#include <qaction.h>
-#include <qheader.h>
-#include <qfiledialog.h>
-#include <qdragobject.h>
#include <qregexp.h>
+#include <qevent.h>
#include <stdlib.h>
@@ -38,7 +57,7 @@
static QApplication *configApp;
static ConfigSettings *configSettings;
-QAction *ConfigMainWindow::saveAction;
+Q3Action *ConfigMainWindow::saveAction;
static inline QString qgettext(const char* str)
{
@@ -53,15 +72,14 @@ static inline QString qgettext(const QString& str)
/**
* Reads a list of integer values from the application settings.
*/
-QValueList<int> ConfigSettings::readSizes(const QString& key, bool *ok)
+Q3ValueList<int> ConfigSettings::readSizes(const QString& key, bool *ok)
{
- QValueList<int> result;
+ Q3ValueList<int> result;
QStringList entryList = readListEntry(key, ok);
- if (ok) {
- QStringList::Iterator it;
- for (it = entryList.begin(); it != entryList.end(); ++it)
- result.push_back((*it).toInt());
- }
+ QStringList::Iterator it;
+
+ for (it = entryList.begin(); it != entryList.end(); ++it)
+ result.push_back((*it).toInt());
return result;
}
@@ -69,10 +87,10 @@ QValueList<int> ConfigSettings::readSizes(const QString& key, bool *ok)
/**
* Writes a list of integer values to the application settings.
*/
-bool ConfigSettings::writeSizes(const QString& key, const QValueList<int>& value)
+bool ConfigSettings::writeSizes(const QString& key, const Q3ValueList<int>& value)
{
QStringList stringList;
- QValueList<int>::ConstIterator it;
+ Q3ValueList<int>::ConstIterator it;
for (it = value.begin(); it != value.end(); ++it)
stringList.push_back(QString::number(*it));
@@ -80,7 +98,6 @@ bool ConfigSettings::writeSizes(const QString& key, const QValueList<int>& value
}
-#if QT_VERSION >= 300
/*
* set the new data
* TODO check the value
@@ -91,7 +108,6 @@ void ConfigItem::okRename(int col)
sym_set_string_value(menu->sym, text(dataColIdx).latin1());
listView()->updateList(this);
}
-#endif
/*
* update the displayed of a menu entry
@@ -148,7 +164,7 @@ void ConfigItem::updateMenu(void)
case S_TRISTATE:
char ch;
- if (!sym_is_changable(sym) && !list->showAll) {
+ if (!sym_is_changable(sym) && list->optMode == normalOpt) {
setPixmap(promptColIdx, 0);
setText(noColIdx, QString::null);
setText(modColIdx, QString::null);
@@ -195,11 +211,9 @@ void ConfigItem::updateMenu(void)
data = sym_get_string_value(sym);
-#if QT_VERSION >= 300
int i = list->mapIdx(dataColIdx);
if (i >= 0)
setRenameEnabled(i, TRUE);
-#endif
setText(dataColIdx, data);
if (type == S_STRING)
prompt = QString("%1: %2").arg(prompt).arg(data);
@@ -297,10 +311,10 @@ void ConfigLineEdit::show(ConfigItem* i)
void ConfigLineEdit::keyPressEvent(QKeyEvent* e)
{
switch (e->key()) {
- case Key_Escape:
+ case Qt::Key_Escape:
break;
- case Key_Return:
- case Key_Enter:
+ case Qt::Key_Return:
+ case Qt::Key_Enter:
sym_set_string_value(item->menu->sym, text().latin1());
parent()->updateList(item);
break;
@@ -319,7 +333,7 @@ ConfigList::ConfigList(ConfigView* p, const char *name)
symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no),
choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no),
menuPix(xpm_menu), menuInvPix(xpm_menu_inv), menuBackPix(xpm_menuback), voidPix(xpm_void),
- showAll(false), showName(false), showRange(false), showData(false),
+ showName(false), showRange(false), showData(false), optMode(normalOpt),
rootEntry(0), headerPopup(0)
{
int i;
@@ -336,10 +350,10 @@ ConfigList::ConfigList(ConfigView* p, const char *name)
if (name) {
configSettings->beginGroup(name);
- showAll = configSettings->readBoolEntry("/showAll", false);
showName = configSettings->readBoolEntry("/showName", false);
showRange = configSettings->readBoolEntry("/showRange", false);
showData = configSettings->readBoolEntry("/showData", false);
+ optMode = (enum optionMode)configSettings->readNumEntry("/optionMode", false);
configSettings->endGroup();
connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings()));
}
@@ -351,6 +365,17 @@ ConfigList::ConfigList(ConfigView* p, const char *name)
reinit();
}
+bool ConfigList::menuSkip(struct menu *menu)
+{
+ if (optMode == normalOpt && menu_is_visible(menu))
+ return false;
+ if (optMode == promptOpt && menu_has_prompt(menu))
+ return false;
+ if (optMode == allOpt)
+ return false;
+ return true;
+}
+
void ConfigList::reinit(void)
{
removeColumn(dataColIdx);
@@ -379,7 +404,7 @@ void ConfigList::saveSettings(void)
configSettings->writeEntry("/showName", showName);
configSettings->writeEntry("/showRange", showRange);
configSettings->writeEntry("/showData", showData);
- configSettings->writeEntry("/showAll", showAll);
+ configSettings->writeEntry("/optionMode", (int)optMode);
configSettings->endGroup();
}
}
@@ -421,7 +446,7 @@ void ConfigList::updateList(ConfigItem* item)
if (!rootEntry) {
if (mode != listMode)
goto update;
- QListViewItemIterator it(this);
+ Q3ListViewItemIterator it(this);
ConfigItem* item;
for (; it.current(); ++it) {
@@ -516,11 +541,9 @@ void ConfigList::changeValue(ConfigItem* item)
case S_INT:
case S_HEX:
case S_STRING:
-#if QT_VERSION >= 300
if (colMap[dataColIdx] >= 0)
item->startRename(colMap[dataColIdx]);
else
-#endif
parent()->lineEdit->show(item);
break;
}
@@ -552,7 +575,7 @@ void ConfigList::setParentMenu(void)
return;
setRootMenu(menu_get_parent_menu(rootEntry->parent));
- QListViewItemIterator it(this);
+ Q3ListViewItemIterator it(this);
for (; (item = (ConfigItem*)it.current()); it++) {
if (item->menu == oldroot) {
setCurrentItem(item);
@@ -605,7 +628,7 @@ void ConfigList::updateMenuList(P* parent, struct menu* menu)
}
visible = menu_is_visible(child);
- if (showAll || visible) {
+ if (!menuSkip(child)) {
if (!child->sym && !child->list && !child->prompt)
continue;
if (!item || item->menu != child)
@@ -634,12 +657,12 @@ void ConfigList::updateMenuList(P* parent, struct menu* menu)
void ConfigList::keyPressEvent(QKeyEvent* ev)
{
- QListViewItem* i = currentItem();
+ Q3ListViewItem* i = currentItem();
ConfigItem* item;
struct menu *menu;
enum prop_type type;
- if (ev->key() == Key_Escape && mode != fullMode && mode != listMode) {
+ if (ev->key() == Qt::Key_Escape && mode != fullMode && mode != listMode) {
emit parentSelected();
ev->accept();
return;
@@ -652,8 +675,8 @@ void ConfigList::keyPressEvent(QKeyEvent* ev)
item = (ConfigItem*)i;
switch (ev->key()) {
- case Key_Return:
- case Key_Enter:
+ case Qt::Key_Return:
+ case Qt::Key_Enter:
if (item->goParent) {
emit parentSelected();
break;
@@ -667,16 +690,16 @@ void ConfigList::keyPressEvent(QKeyEvent* ev)
emit menuSelected(menu);
break;
}
- case Key_Space:
+ case Qt::Key_Space:
changeValue(item);
break;
- case Key_N:
+ case Qt::Key_N:
setValue(item, no);
break;
- case Key_M:
+ case Qt::Key_M:
setValue(item, mod);
break;
- case Key_Y:
+ case Qt::Key_Y:
setValue(item, yes);
break;
default:
@@ -800,10 +823,10 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
{
if (e->y() <= header()->geometry().bottom()) {
if (!headerPopup) {
- QAction *action;
+ Q3Action *action;
- headerPopup = new QPopupMenu(this);
- action = new QAction(NULL, _("Show Name"), 0, this);
+ headerPopup = new Q3PopupMenu(this);
+ action = new Q3Action(NULL, _("Show Name"), 0, this);
action->setToggleAction(TRUE);
connect(action, SIGNAL(toggled(bool)),
parent(), SLOT(setShowName(bool)));
@@ -811,7 +834,7 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
action, SLOT(setOn(bool)));
action->setOn(showName);
action->addTo(headerPopup);
- action = new QAction(NULL, _("Show Range"), 0, this);
+ action = new Q3Action(NULL, _("Show Range"), 0, this);
action->setToggleAction(TRUE);
connect(action, SIGNAL(toggled(bool)),
parent(), SLOT(setShowRange(bool)));
@@ -819,7 +842,7 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
action, SLOT(setOn(bool)));
action->setOn(showRange);
action->addTo(headerPopup);
- action = new QAction(NULL, _("Show Data"), 0, this);
+ action = new Q3Action(NULL, _("Show Data"), 0, this);
action->setToggleAction(TRUE);
connect(action, SIGNAL(toggled(bool)),
parent(), SLOT(setShowData(bool)));
@@ -834,7 +857,10 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
e->ignore();
}
-ConfigView* ConfigView::viewList;
+ConfigView*ConfigView::viewList;
+QAction *ConfigView::showNormalAction;
+QAction *ConfigView::showAllAction;
+QAction *ConfigView::showPromptAction;
ConfigView::ConfigView(QWidget* parent, const char *name)
: Parent(parent, name)
@@ -859,13 +885,16 @@ ConfigView::~ConfigView(void)
}
}
-void ConfigView::setShowAll(bool b)
+void ConfigView::setOptionMode(QAction *act)
{
- if (list->showAll != b) {
- list->showAll = b;
- list->updateListAll();
- emit showAllChanged(b);
- }
+ if (act == showNormalAction)
+ list->optMode = normalOpt;
+ else if (act == showAllAction)
+ list->optMode = allOpt;
+ else
+ list->optMode = promptOpt;
+
+ list->updateListAll();
}
void ConfigView::setShowName(bool b)
@@ -897,7 +926,7 @@ void ConfigView::setShowData(bool b)
void ConfigList::setAllOpen(bool open)
{
- QListViewItemIterator it(this);
+ Q3ListViewItemIterator it(this);
for (; it.current(); it++)
it.current()->setOpen(open);
@@ -920,7 +949,7 @@ void ConfigView::updateListAll(void)
}
ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name)
- : Parent(parent, name), menu(0), sym(0)
+ : Parent(parent, name), sym(0), _menu(0)
{
if (name) {
configSettings->beginGroup(name);
@@ -943,7 +972,7 @@ void ConfigInfoView::setShowDebug(bool b)
{
if (_showDebug != b) {
_showDebug = b;
- if (menu)
+ if (_menu)
menuInfo();
else if (sym)
symbolInfo();
@@ -953,44 +982,16 @@ void ConfigInfoView::setShowDebug(bool b)
void ConfigInfoView::setInfo(struct menu *m)
{
- if (menu == m)
+ if (_menu == m)
return;
- menu = m;
+ _menu = m;
sym = NULL;
- if (!menu)
+ if (!_menu)
clear();
else
menuInfo();
}
-void ConfigInfoView::setSource(const QString& name)
-{
- const char *p = name.latin1();
-
- menu = NULL;
- sym = NULL;
-
- switch (p[0]) {
- case 'm':
- struct menu *m;
-
- if (sscanf(p, "m%p", &m) == 1 && menu != m) {
- menu = m;
- menuInfo();
- emit menuSelected(menu);
- }
- break;
- case 's':
- struct symbol *s;
-
- if (sscanf(p, "s%p", &s) == 1 && sym != s) {
- sym = s;
- symbolInfo();
- }
- break;
- }
-}
-
void ConfigInfoView::symbolInfo(void)
{
QString str;
@@ -1012,11 +1013,11 @@ void ConfigInfoView::menuInfo(void)
struct symbol* sym;
QString head, debug, help;
- sym = menu->sym;
+ sym = _menu->sym;
if (sym) {
- if (menu->prompt) {
+ if (_menu->prompt) {
head += "<big><b>";
- head += print_filter(_(menu->prompt->text));
+ head += print_filter(_(_menu->prompt->text));
head += "</b></big>";
if (sym->name) {
head += " (";
@@ -1041,26 +1042,24 @@ void ConfigInfoView::menuInfo(void)
if (showDebug())
debug = debug_info(sym);
- help = menu_get_help(menu);
- /* Gettextize if the help text not empty */
- if (help.isEmpty())
- help = print_filter(menu_get_help(menu));
- else
- help = print_filter(_(menu_get_help(menu)));
- } else if (menu->prompt) {
+ struct gstr help_gstr = str_new();
+ menu_get_ext_help(_menu, &help_gstr);
+ help = print_filter(str_get(&help_gstr));
+ str_free(&help_gstr);
+ } else if (_menu->prompt) {
head += "<big><b>";
- head += print_filter(_(menu->prompt->text));
+ head += print_filter(_(_menu->prompt->text));
head += "</b></big><br><br>";
if (showDebug()) {
- if (menu->prompt->visible.expr) {
+ if (_menu->prompt->visible.expr) {
debug += "&nbsp;&nbsp;dep: ";
- expr_print(menu->prompt->visible.expr, expr_print_help, &debug, E_NONE);
+ expr_print(_menu->prompt->visible.expr, expr_print_help, &debug, E_NONE);
debug += "<br><br>";
}
}
}
if (showDebug())
- debug += QString().sprintf("defined at %s:%d<br><br>", menu->file->name, menu->lineno);
+ debug += QString().sprintf("defined at %s:%d<br><br>", _menu->file->name, _menu->lineno);
setText(head + debug + help);
}
@@ -1163,10 +1162,10 @@ void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char
*text += str2;
}
-QPopupMenu* ConfigInfoView::createPopupMenu(const QPoint& pos)
+Q3PopupMenu* ConfigInfoView::createPopupMenu(const QPoint& pos)
{
- QPopupMenu* popup = Parent::createPopupMenu(pos);
- QAction* action = new QAction(NULL, _("Show Debug Info"), 0, popup);
+ Q3PopupMenu* popup = Parent::createPopupMenu(pos);
+ Q3Action* action = new Q3Action(NULL, _("Show Debug Info"), 0, popup);
action->setToggleAction(TRUE);
connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool)));
connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setOn(bool)));
@@ -1199,7 +1198,7 @@ ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow* parent, const char *nam
layout1->addLayout(layout2);
split = new QSplitter(this);
- split->setOrientation(QSplitter::Vertical);
+ split->setOrientation(Qt::Vertical);
list = new ConfigView(split, name);
list->list->mode = listMode;
info = new ConfigInfoView(split, name);
@@ -1223,7 +1222,7 @@ ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow* parent, const char *nam
y = configSettings->readNumEntry("/window y", 0, &ok);
if (ok)
move(x, y);
- QValueList<int> sizes = configSettings->readSizes("/split", &ok);
+ Q3ValueList<int> sizes = configSettings->readSizes("/split", &ok);
if (ok)
split->setSizes(sizes);
configSettings->endGroup();
@@ -1275,9 +1274,15 @@ ConfigMainWindow::ConfigMainWindow(void)
int x, y, width, height;
char title[256];
- QWidget *d = configApp->desktop();
- snprintf(title, sizeof(title), _("uClibc v%s Configuration"),
- getenv("VERSION"));
+ QDesktopWidget *d = configApp->desktop();
+ snprintf(title, sizeof(title), "%s%s",
+ rootmenu.prompt->text,
+#if QT_VERSION < 0x040000
+ " (Qt3)"
+#else
+ ""
+#endif
+ );
setCaption(title);
width = configSettings->readNumEntry("/window width", d->width() - 64);
@@ -1290,14 +1295,14 @@ ConfigMainWindow::ConfigMainWindow(void)
move(x, y);
split1 = new QSplitter(this);
- split1->setOrientation(QSplitter::Horizontal);
+ split1->setOrientation(Qt::Horizontal);
setCentralWidget(split1);
menuView = new ConfigView(split1, "menu");
menuList = menuView->list;
split2 = new QSplitter(split1);
- split2->setOrientation(QSplitter::Vertical);
+ split2->setOrientation(Qt::Vertical);
// create config tree
configView = new ConfigView(split2, "config");
@@ -1310,60 +1315,79 @@ ConfigMainWindow::ConfigMainWindow(void)
configList->setFocus();
menu = menuBar();
- toolBar = new QToolBar("Tools", this);
+ toolBar = new Q3ToolBar("Tools", this);
- backAction = new QAction("Back", QPixmap(xpm_back), _("Back"), 0, this);
+ backAction = new Q3Action("Back", QPixmap(xpm_back), _("Back"), 0, this);
connect(backAction, SIGNAL(activated()), SLOT(goBack()));
backAction->setEnabled(FALSE);
- QAction *quitAction = new QAction("Quit", _("&Quit"), CTRL+Key_Q, this);
+ Q3Action *quitAction = new Q3Action("Quit", _("&Quit"), Qt::CTRL + Qt::Key_Q, this);
connect(quitAction, SIGNAL(activated()), SLOT(close()));
- QAction *loadAction = new QAction("Load", QPixmap(xpm_load), _("&Load"), CTRL+Key_L, this);
+ Q3Action *loadAction = new Q3Action("Load", QPixmap(xpm_load), _("&Load"), Qt::CTRL + Qt::Key_L, this);
connect(loadAction, SIGNAL(activated()), SLOT(loadConfig()));
- saveAction = new QAction("Save", QPixmap(xpm_save), _("&Save"), CTRL+Key_S, this);
+ saveAction = new Q3Action("Save", QPixmap(xpm_save), _("&Save"), Qt::CTRL + Qt::Key_S, this);
connect(saveAction, SIGNAL(activated()), SLOT(saveConfig()));
conf_set_changed_callback(conf_changed);
// Set saveAction's initial state
conf_changed();
- QAction *saveAsAction = new QAction("Save As...", _("Save &As..."), 0, this);
+ Q3Action *saveAsAction = new Q3Action("Save As...", _("Save &As..."), 0, this);
connect(saveAsAction, SIGNAL(activated()), SLOT(saveConfigAs()));
- QAction *searchAction = new QAction("Find", _("&Find"), CTRL+Key_F, this);
+ Q3Action *searchAction = new Q3Action("Find", _("&Find"), Qt::CTRL + Qt::Key_F, this);
connect(searchAction, SIGNAL(activated()), SLOT(searchConfig()));
- QAction *singleViewAction = new QAction("Single View", QPixmap(xpm_single_view), _("Single View"), 0, this);
+ Q3Action *singleViewAction = new Q3Action("Single View", QPixmap(xpm_single_view), _("Single View"), 0, this);
connect(singleViewAction, SIGNAL(activated()), SLOT(showSingleView()));
- QAction *splitViewAction = new QAction("Split View", QPixmap(xpm_split_view), _("Split View"), 0, this);
+ Q3Action *splitViewAction = new Q3Action("Split View", QPixmap(xpm_split_view), _("Split View"), 0, this);
connect(splitViewAction, SIGNAL(activated()), SLOT(showSplitView()));
- QAction *fullViewAction = new QAction("Full View", QPixmap(xpm_tree_view), _("Full View"), 0, this);
+ Q3Action *fullViewAction = new Q3Action("Full View", QPixmap(xpm_tree_view), _("Full View"), 0, this);
connect(fullViewAction, SIGNAL(activated()), SLOT(showFullView()));
- QAction *showNameAction = new QAction(NULL, _("Show Name"), 0, this);
+ Q3Action *showNameAction = new Q3Action(NULL, _("Show Name"), 0, this);
showNameAction->setToggleAction(TRUE);
connect(showNameAction, SIGNAL(toggled(bool)), configView, SLOT(setShowName(bool)));
connect(configView, SIGNAL(showNameChanged(bool)), showNameAction, SLOT(setOn(bool)));
showNameAction->setOn(configView->showName());
- QAction *showRangeAction = new QAction(NULL, _("Show Range"), 0, this);
+ Q3Action *showRangeAction = new Q3Action(NULL, _("Show Range"), 0, this);
showRangeAction->setToggleAction(TRUE);
connect(showRangeAction, SIGNAL(toggled(bool)), configView, SLOT(setShowRange(bool)));
connect(configView, SIGNAL(showRangeChanged(bool)), showRangeAction, SLOT(setOn(bool)));
showRangeAction->setOn(configList->showRange);
- QAction *showDataAction = new QAction(NULL, _("Show Data"), 0, this);
+ Q3Action *showDataAction = new Q3Action(NULL, _("Show Data"), 0, this);
showDataAction->setToggleAction(TRUE);
connect(showDataAction, SIGNAL(toggled(bool)), configView, SLOT(setShowData(bool)));
connect(configView, SIGNAL(showDataChanged(bool)), showDataAction, SLOT(setOn(bool)));
showDataAction->setOn(configList->showData);
- QAction *showAllAction = new QAction(NULL, _("Show All Options"), 0, this);
- showAllAction->setToggleAction(TRUE);
- connect(showAllAction, SIGNAL(toggled(bool)), configView, SLOT(setShowAll(bool)));
- connect(showAllAction, SIGNAL(toggled(bool)), menuView, SLOT(setShowAll(bool)));
- showAllAction->setOn(configList->showAll);
- QAction *showDebugAction = new QAction(NULL, _("Show Debug Info"), 0, this);
+
+ QActionGroup *optGroup = new QActionGroup(this);
+ optGroup->setExclusive(TRUE);
+ connect(optGroup, SIGNAL(selected(QAction *)), configView,
+ SLOT(setOptionMode(QAction *)));
+ connect(optGroup, SIGNAL(selected(QAction *)), menuView,
+ SLOT(setOptionMode(QAction *)));
+
+#if QT_VERSION >= 0x040000
+ configView->showNormalAction = new QAction(_("Show Normal Options"), optGroup);
+ configView->showAllAction = new QAction(_("Show All Options"), optGroup);
+ configView->showPromptAction = new QAction(_("Show Prompt Options"), optGroup);
+#else
+ configView->showNormalAction = new QAction(_("Show Normal Options"), 0, optGroup);
+ configView->showAllAction = new QAction(_("Show All Options"), 0, optGroup);
+ configView->showPromptAction = new QAction(_("Show Prompt Options"), 0, optGroup);
+#endif
+ configView->showNormalAction->setToggleAction(TRUE);
+ configView->showNormalAction->setOn(configList->optMode == normalOpt);
+ configView->showAllAction->setToggleAction(TRUE);
+ configView->showAllAction->setOn(configList->optMode == allOpt);
+ configView->showPromptAction->setToggleAction(TRUE);
+ configView->showPromptAction->setOn(configList->optMode == promptOpt);
+
+ Q3Action *showDebugAction = new Q3Action(NULL, _("Show Debug Info"), 0, this);
showDebugAction->setToggleAction(TRUE);
connect(showDebugAction, SIGNAL(toggled(bool)), helpText, SLOT(setShowDebug(bool)));
connect(helpText, SIGNAL(showDebugChanged(bool)), showDebugAction, SLOT(setOn(bool)));
showDebugAction->setOn(helpText->showDebug());
- QAction *showIntroAction = new QAction(NULL, _("Introduction"), 0, this);
+ Q3Action *showIntroAction = new Q3Action(NULL, _("Introduction"), 0, this);
connect(showIntroAction, SIGNAL(activated()), SLOT(showIntro()));
- QAction *showAboutAction = new QAction(NULL, _("About"), 0, this);
+ Q3Action *showAboutAction = new Q3Action(NULL, _("About"), 0, this);
connect(showAboutAction, SIGNAL(activated()), SLOT(showAbout()));
// init tool bar
@@ -1377,7 +1401,7 @@ ConfigMainWindow::ConfigMainWindow(void)
fullViewAction->addTo(toolBar);
// create config menu
- QPopupMenu* config = new QPopupMenu(this);
+ Q3PopupMenu* config = new Q3PopupMenu(this);
menu->insertItem(_("&File"), config);
loadAction->addTo(config);
saveAction->addTo(config);
@@ -1386,22 +1410,22 @@ ConfigMainWindow::ConfigMainWindow(void)
quitAction->addTo(config);
// create edit menu
- QPopupMenu* editMenu = new QPopupMenu(this);
+ Q3PopupMenu* editMenu = new Q3PopupMenu(this);
menu->insertItem(_("&Edit"), editMenu);
searchAction->addTo(editMenu);
// create options menu
- QPopupMenu* optionMenu = new QPopupMenu(this);
+ Q3PopupMenu* optionMenu = new Q3PopupMenu(this);
menu->insertItem(_("&Option"), optionMenu);
showNameAction->addTo(optionMenu);
showRangeAction->addTo(optionMenu);
showDataAction->addTo(optionMenu);
optionMenu->insertSeparator();
- showAllAction->addTo(optionMenu);
- showDebugAction->addTo(optionMenu);
+ optGroup->addTo(optionMenu);
+ optionMenu->insertSeparator();
// create help menu
- QPopupMenu* helpMenu = new QPopupMenu(this);
+ Q3PopupMenu* helpMenu = new Q3PopupMenu(this);
menu->insertSeparator();
menu->insertItem(_("&Help"), helpMenu);
showIntroAction->addTo(helpMenu);
@@ -1436,7 +1460,7 @@ ConfigMainWindow::ConfigMainWindow(void)
showSplitView();
// UI setup done, restore splitter positions
- QValueList<int> sizes = configSettings->readSizes("/split1", &ok);
+ Q3ValueList<int> sizes = configSettings->readSizes("/split1", &ok);
if (ok)
split1->setSizes(sizes);
@@ -1447,7 +1471,7 @@ ConfigMainWindow::ConfigMainWindow(void)
void ConfigMainWindow::loadConfig(void)
{
- QString s = QFileDialog::getOpenFileName(".config", NULL, this);
+ QString s = Q3FileDialog::getOpenFileName(conf_get_configname(), NULL, this);
if (s.isNull())
return;
if (conf_read(QFile::encodeName(s)))
@@ -1455,19 +1479,21 @@ void ConfigMainWindow::loadConfig(void)
ConfigView::updateListAll();
}
-void ConfigMainWindow::saveConfig(void)
+bool ConfigMainWindow::saveConfig(void)
{
- if (conf_write(NULL))
+ if (conf_write(NULL)) {
QMessageBox::information(this, "qconf", _("Unable to save configuration!"));
+ return false;
+ }
+ return true;
}
void ConfigMainWindow::saveConfigAs(void)
{
- QString s = QFileDialog::getSaveFileName(".config", NULL, this);
+ QString s = Q3FileDialog::getSaveFileName(conf_get_configname(), NULL, this);
if (s.isNull())
return;
- if (conf_write(QFile::encodeName(s)))
- QMessageBox::information(this, "qconf", _("Unable to save configuration!"));
+ saveConfig();
}
void ConfigMainWindow::searchConfig(void)
@@ -1492,7 +1518,7 @@ void ConfigMainWindow::setMenuLink(struct menu *menu)
ConfigList* list = NULL;
ConfigItem* item;
- if (!menu_is_visible(menu) && !configView->showAll())
+ if (configList->menuSkip(menu))
return;
switch (configList->mode) {
@@ -1524,6 +1550,8 @@ void ConfigMainWindow::setMenuLink(struct menu *menu)
case fullMode:
list = configList;
break;
+ default:
+ break;
}
if (list) {
@@ -1618,7 +1646,11 @@ void ConfigMainWindow::closeEvent(QCloseEvent* e)
mb.setButtonText(QMessageBox::Cancel, _("Cancel Exit"));
switch (mb.exec()) {
case QMessageBox::Yes:
- conf_write(NULL);
+ if (saveConfig())
+ e->accept();
+ else
+ e->ignore();
+ break;
case QMessageBox::No:
e->accept();
break;
@@ -1630,7 +1662,7 @@ void ConfigMainWindow::closeEvent(QCloseEvent* e)
void ConfigMainWindow::showIntro(void)
{
- static const QString str = _("Welcome to the qconf graphical configuration tool for uClibc.\n\n"
+ static const QString str = _("Welcome to the qconf graphical configuration tool.\n\n"
"For each option, a blank box indicates the feature is disabled, a check\n"
"indicates it is enabled, and a dot indicates that it is to be compiled\n"
"as a module. Clicking on the box will cycle through the three states.\n\n"
@@ -1673,6 +1705,9 @@ void ConfigMainWindow::saveSettings(void)
case fullMode :
entry = "full";
break;
+
+ default:
+ break;
}
configSettings->writeEntry("/listMode", entry);
@@ -1718,10 +1753,6 @@ int main(int ac, char** av)
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
-#ifndef LKC_DIRECT_LINK
- kconfig_load();
-#endif
-
progname = av[0];
configApp = new QApplication(ac, av);
if (ac > 1 && av[1][0] == '-') {
diff --git a/extra/config/qconf.h b/extra/config/qconf.h
index b3b5657b6..3715b3e72 100644
--- a/extra/config/qconf.h
+++ b/extra/config/qconf.h
@@ -3,26 +3,25 @@
* Released under the terms of the GNU GPL v2.0.
*/
+#if QT_VERSION < 0x040000
#include <qlistview.h>
-#if QT_VERSION >= 300
-#include <qsettings.h>
#else
-class QSettings {
-public:
- void beginGroup(const QString& group) { }
- void endGroup(void) { }
- bool readBoolEntry(const QString& key, bool def = FALSE, bool* ok = 0) const
- { if (ok) *ok = FALSE; return def; }
- int readNumEntry(const QString& key, int def = 0, bool* ok = 0) const
- { if (ok) *ok = FALSE; return def; }
- QString readEntry(const QString& key, const QString& def = QString::null, bool* ok = 0) const
- { if (ok) *ok = FALSE; return def; }
- QStringList readListEntry(const QString& key, bool* ok = 0) const
- { if (ok) *ok = FALSE; return QStringList(); }
- template <class t>
- bool writeEntry(const QString& key, t value)
- { return TRUE; }
-};
+#include <q3listview.h>
+#endif
+#include <qsettings.h>
+
+#if QT_VERSION < 0x040000
+#define Q3ValueList QValueList
+#define Q3PopupMenu QPopupMenu
+#define Q3ListView QListView
+#define Q3ListViewItem QListViewItem
+#define Q3VBox QVBox
+#define Q3TextBrowser QTextBrowser
+#define Q3MainWindow QMainWindow
+#define Q3Action QAction
+#define Q3ToolBar QToolBar
+#define Q3ListViewItemIterator QListViewItemIterator
+#define Q3FileDialog QFileDialog
#endif
class ConfigView;
@@ -31,11 +30,10 @@ class ConfigItem;
class ConfigLineEdit;
class ConfigMainWindow;
-
class ConfigSettings : public QSettings {
public:
- QValueList<int> readSizes(const QString& key, bool *ok);
- bool writeSizes(const QString& key, const QValueList<int>& value);
+ Q3ValueList<int> readSizes(const QString& key, bool *ok);
+ bool writeSizes(const QString& key, const Q3ValueList<int>& value);
};
enum colIdx {
@@ -44,10 +42,13 @@ enum colIdx {
enum listMode {
singleMode, menuMode, symbolMode, fullMode, listMode
};
+enum optionMode {
+ normalOpt = 0, allOpt, promptOpt
+};
-class ConfigList : public QListView {
+class ConfigList : public Q3ListView {
Q_OBJECT
- typedef class QListView Parent;
+ typedef class Q3ListView Parent;
public:
ConfigList(ConfigView* p, const char *name = 0);
void reinit(void);
@@ -115,6 +116,8 @@ public:
void setAllOpen(bool open);
void setParentMenu(void);
+ bool menuSkip(struct menu *);
+
template <class P>
void updateMenuList(P*, struct menu*);
@@ -124,22 +127,23 @@ public:
QPixmap choiceYesPix, choiceNoPix;
QPixmap menuPix, menuInvPix, menuBackPix, voidPix;
- bool showAll, showName, showRange, showData;
+ bool showName, showRange, showData;
enum listMode mode;
+ enum optionMode optMode;
struct menu *rootEntry;
QColorGroup disabledColorGroup;
QColorGroup inactivedColorGroup;
- QPopupMenu* headerPopup;
+ Q3PopupMenu* headerPopup;
private:
int colMap[colNr];
int colRevMap[colNr];
};
-class ConfigItem : public QListViewItem {
- typedef class QListViewItem Parent;
+class ConfigItem : public Q3ListViewItem {
+ typedef class Q3ListViewItem Parent;
public:
- ConfigItem(QListView *parent, ConfigItem *after, struct menu *m, bool v)
+ ConfigItem(Q3ListView *parent, ConfigItem *after, struct menu *m, bool v)
: Parent(parent, after), menu(m), visible(v), goParent(false)
{
init();
@@ -149,16 +153,14 @@ public:
{
init();
}
- ConfigItem(QListView *parent, ConfigItem *after, bool v)
+ ConfigItem(Q3ListView *parent, ConfigItem *after, bool v)
: Parent(parent, after), menu(0), visible(v), goParent(true)
{
init();
}
~ConfigItem(void);
void init(void);
-#if QT_VERSION >= 300
void okRename(int col);
-#endif
void updateMenu(void);
void testUpdateMenu(bool v);
ConfigList* listView() const
@@ -213,26 +215,24 @@ public:
ConfigItem *item;
};
-class ConfigView : public QVBox {
+class ConfigView : public Q3VBox {
Q_OBJECT
- typedef class QVBox Parent;
+ typedef class Q3VBox Parent;
public:
ConfigView(QWidget* parent, const char *name = 0);
~ConfigView(void);
static void updateList(ConfigItem* item);
static void updateListAll(void);
- bool showAll(void) const { return list->showAll; }
bool showName(void) const { return list->showName; }
bool showRange(void) const { return list->showRange; }
bool showData(void) const { return list->showData; }
public slots:
- void setShowAll(bool);
void setShowName(bool);
void setShowRange(bool);
void setShowData(bool);
+ void setOptionMode(QAction *);
signals:
- void showAllChanged(bool);
void showNameChanged(bool);
void showRangeChanged(bool);
void showDataChanged(bool);
@@ -242,11 +242,15 @@ public:
static ConfigView* viewList;
ConfigView* nextView;
+
+ static QAction *showNormalAction;
+ static QAction *showAllAction;
+ static QAction *showPromptAction;
};
-class ConfigInfoView : public QTextBrowser {
+class ConfigInfoView : public Q3TextBrowser {
Q_OBJECT
- typedef class QTextBrowser Parent;
+ typedef class Q3TextBrowser Parent;
public:
ConfigInfoView(QWidget* parent, const char *name = 0);
bool showDebug(void) const { return _showDebug; }
@@ -254,7 +258,6 @@ public:
public slots:
void setInfo(struct menu *menu);
void saveSettings(void);
- void setSource(const QString& name);
void setShowDebug(bool);
signals:
@@ -267,11 +270,11 @@ protected:
QString debug_info(struct symbol *sym);
static QString print_filter(const QString &str);
static void expr_print_help(void *data, struct symbol *sym, const char *str);
- QPopupMenu* createPopupMenu(const QPoint& pos);
+ Q3PopupMenu* createPopupMenu(const QPoint& pos);
void contentsContextMenuEvent(QContextMenuEvent *e);
struct symbol *sym;
- struct menu *menu;
+ struct menu *_menu;
bool _showDebug;
};
@@ -295,10 +298,10 @@ protected:
struct symbol **result;
};
-class ConfigMainWindow : public QMainWindow {
+class ConfigMainWindow : public Q3MainWindow {
Q_OBJECT
- static QAction *saveAction;
+ static Q3Action *saveAction;
static void conf_changed(void);
public:
ConfigMainWindow(void);
@@ -308,7 +311,7 @@ public slots:
void listFocusChanged(void);
void goBack(void);
void loadConfig(void);
- void saveConfig(void);
+ bool saveConfig(void);
void saveConfigAs(void);
void searchConfig(void);
void showSingleView(void);
@@ -327,8 +330,8 @@ protected:
ConfigView *configView;
ConfigList *configList;
ConfigInfoView *helpText;
- QToolBar *toolBar;
- QAction *backAction;
+ Q3ToolBar *toolBar;
+ Q3Action *backAction;
QSplitter* split1;
QSplitter* split2;
};
diff --git a/extra/config/streamline_config.pl b/extra/config/streamline_config.pl
new file mode 100644
index 000000000..4606cdfb8
--- /dev/null
+++ b/extra/config/streamline_config.pl
@@ -0,0 +1,640 @@
+#!/usr/bin/perl -w
+#
+# Copyright 2005-2009 - Steven Rostedt
+# Licensed under the terms of the GNU GPL License version 2
+#
+# It's simple enough to figure out how this works.
+# If not, then you can ask me at stripconfig@goodmis.org
+#
+# What it does?
+#
+# If you have installed a Linux kernel from a distribution
+# that turns on way too many modules than you need, and
+# you only want the modules you use, then this program
+# is perfect for you.
+#
+# It gives you the ability to turn off all the modules that are
+# not loaded on your system.
+#
+# Howto:
+#
+# 1. Boot up the kernel that you want to stream line the config on.
+# 2. Change directory to the directory holding the source of the
+# kernel that you just booted.
+# 3. Copy the configuraton file to this directory as .config
+# 4. Have all your devices that you need modules for connected and
+# operational (make sure that their corresponding modules are loaded)
+# 5. Run this script redirecting the output to some other file
+# like config_strip.
+# 6. Back up your old config (if you want too).
+# 7. copy the config_strip file to .config
+# 8. Run "make oldconfig"
+#
+# Now your kernel is ready to be built with only the modules that
+# are loaded.
+#
+# Here's what I did with my Debian distribution.
+#
+# cd /usr/src/linux-2.6.10
+# cp /boot/config-2.6.10-1-686-smp .config
+# ~/bin/streamline_config > config_strip
+# mv .config config_sav
+# mv config_strip .config
+# make oldconfig
+#
+use strict;
+use Getopt::Long;
+
+# set the environment variable LOCALMODCONFIG_DEBUG to get
+# debug output.
+my $debugprint = 0;
+$debugprint = 1 if (defined($ENV{LOCALMODCONFIG_DEBUG}));
+
+sub dprint {
+ return if (!$debugprint);
+ print STDERR @_;
+}
+
+my $config = ".config";
+
+my $uname = `uname -r`;
+chomp $uname;
+
+my @searchconfigs = (
+ {
+ "file" => ".config",
+ "exec" => "cat",
+ },
+ {
+ "file" => "/proc/config.gz",
+ "exec" => "zcat",
+ },
+ {
+ "file" => "/boot/config-$uname",
+ "exec" => "cat",
+ },
+ {
+ "file" => "/boot/vmlinuz-$uname",
+ "exec" => "scripts/extract-ikconfig",
+ "test" => "scripts/extract-ikconfig",
+ },
+ {
+ "file" => "vmlinux",
+ "exec" => "scripts/extract-ikconfig",
+ "test" => "scripts/extract-ikconfig",
+ },
+ {
+ "file" => "/lib/modules/$uname/kernel/kernel/configs.ko",
+ "exec" => "scripts/extract-ikconfig",
+ "test" => "scripts/extract-ikconfig",
+ },
+ {
+ "file" => "kernel/configs.ko",
+ "exec" => "scripts/extract-ikconfig",
+ "test" => "scripts/extract-ikconfig",
+ },
+ {
+ "file" => "kernel/configs.o",
+ "exec" => "scripts/extract-ikconfig",
+ "test" => "scripts/extract-ikconfig",
+ },
+);
+
+sub read_config {
+ foreach my $conf (@searchconfigs) {
+ my $file = $conf->{"file"};
+
+ next if ( ! -f "$file");
+
+ if (defined($conf->{"test"})) {
+ `$conf->{"test"} $conf->{"file"} 2>/dev/null`;
+ next if ($?);
+ }
+
+ my $exec = $conf->{"exec"};
+
+ print STDERR "using config: '$file'\n";
+
+ open(my $infile, '-|', "$exec $file") || die "Failed to run $exec $file";
+ my @x = <$infile>;
+ close $infile;
+ return @x;
+ }
+ die "No config file found";
+}
+
+my @config_file = read_config;
+
+# Parse options
+my $localmodconfig = 0;
+my $localyesconfig = 0;
+
+GetOptions("localmodconfig" => \$localmodconfig,
+ "localyesconfig" => \$localyesconfig);
+
+# Get the build source and top level Kconfig file (passed in)
+my $ksource = ($ARGV[0] ? $ARGV[0] : '.');
+my $kconfig = $ARGV[1];
+my $lsmod_file = $ENV{'LSMOD'};
+
+my @makefiles = `find $ksource -name Makefile 2>/dev/null`;
+chomp @makefiles;
+
+my %depends;
+my %selects;
+my %prompts;
+my %objects;
+my $var;
+my $iflevel = 0;
+my @ifdeps;
+
+# prevent recursion
+my %read_kconfigs;
+
+sub read_kconfig {
+ my ($kconfig) = @_;
+
+ my $state = "NONE";
+ my $config;
+
+ my $cont = 0;
+ my $line;
+
+ my $source = "$ksource/$kconfig";
+ my $last_source = "";
+
+ # Check for any environment variables used
+ while ($source =~ /\$(\w+)/ && $last_source ne $source) {
+ my $env = $1;
+ $last_source = $source;
+ $source =~ s/\$$env/$ENV{$env}/;
+ }
+
+ open(my $kinfile, '<', $source) || die "Can't open $kconfig";
+ while (<$kinfile>) {
+ chomp;
+
+ # Make sure that lines ending with \ continue
+ if ($cont) {
+ $_ = $line . " " . $_;
+ }
+
+ if (s/\\$//) {
+ $cont = 1;
+ $line = $_;
+ next;
+ }
+
+ $cont = 0;
+
+ # collect any Kconfig sources
+ if (/^source\s*"(.*)"/) {
+ my $kconfig = $1;
+ # prevent reading twice.
+ if (!defined($read_kconfigs{$kconfig})) {
+ $read_kconfigs{$kconfig} = 1;
+ read_kconfig($kconfig);
+ }
+ next;
+ }
+
+ # configs found
+ if (/^\s*(menu)?config\s+(\S+)\s*$/) {
+ $state = "NEW";
+ $config = $2;
+
+ # Add depends for 'if' nesting
+ for (my $i = 0; $i < $iflevel; $i++) {
+ if ($i) {
+ $depends{$config} .= " " . $ifdeps[$i];
+ } else {
+ $depends{$config} = $ifdeps[$i];
+ }
+ $state = "DEP";
+ }
+
+ # collect the depends for the config
+ } elsif ($state eq "NEW" && /^\s*depends\s+on\s+(.*)$/) {
+ $state = "DEP";
+ $depends{$config} = $1;
+ } elsif ($state eq "DEP" && /^\s*depends\s+on\s+(.*)$/) {
+ $depends{$config} .= " " . $1;
+
+ # Get the configs that select this config
+ } elsif ($state ne "NONE" && /^\s*select\s+(\S+)/) {
+ my $conf = $1;
+ if (defined($selects{$conf})) {
+ $selects{$conf} .= " " . $config;
+ } else {
+ $selects{$conf} = $config;
+ }
+
+ # configs without prompts must be selected
+ } elsif ($state ne "NONE" && /^\s*tristate\s\S/) {
+ # note if the config has a prompt
+ $prompts{$config} = 1;
+
+ # Check for if statements
+ } elsif (/^if\s+(.*\S)\s*$/) {
+ my $deps = $1;
+ # remove beginning and ending non text
+ $deps =~ s/^[^a-zA-Z0-9_]*//;
+ $deps =~ s/[^a-zA-Z0-9_]*$//;
+
+ my @deps = split /[^a-zA-Z0-9_]+/, $deps;
+
+ $ifdeps[$iflevel++] = join ':', @deps;
+
+ } elsif (/^endif/) {
+
+ $iflevel-- if ($iflevel);
+
+ # stop on "help"
+ } elsif (/^\s*help\s*$/) {
+ $state = "NONE";
+ }
+ }
+ close($kinfile);
+}
+
+if ($kconfig) {
+ read_kconfig($kconfig);
+}
+
+# Makefiles can use variables to define their dependencies
+sub convert_vars {
+ my ($line, %vars) = @_;
+
+ my $process = "";
+
+ while ($line =~ s/^(.*?)(\$\((.*?)\))//) {
+ my $start = $1;
+ my $variable = $2;
+ my $var = $3;
+
+ if (defined($vars{$var})) {
+ $process .= $start . $vars{$var};
+ } else {
+ $process .= $start . $variable;
+ }
+ }
+
+ $process .= $line;
+
+ return $process;
+}
+
+# Read all Makefiles to map the configs to the objects
+foreach my $makefile (@makefiles) {
+
+ my $line = "";
+ my %make_vars;
+
+ open(my $infile, '<', $makefile) || die "Can't open $makefile";
+ while (<$infile>) {
+ # if this line ends with a backslash, continue
+ chomp;
+ if (/^(.*)\\$/) {
+ $line .= $1;
+ next;
+ }
+
+ $line .= $_;
+ $_ = $line;
+ $line = "";
+
+ my $objs;
+
+ # Convert variables in a line (could define configs)
+ $_ = convert_vars($_, %make_vars);
+
+ # collect objects after obj-$(CONFIG_FOO_BAR)
+ if (/obj-\$\((CONFIG_[^\)]*)\)\s*[+:]?=\s*(.*)/) {
+ $var = $1;
+ $objs = $2;
+
+ # check if variables are set
+ } elsif (/^\s*(\S+)\s*[:]?=\s*(.*\S)/) {
+ $make_vars{$1} = $2;
+ }
+ if (defined($objs)) {
+ foreach my $obj (split /\s+/,$objs) {
+ $obj =~ s/-/_/g;
+ if ($obj =~ /(.*)\.o$/) {
+ # Objects may be enabled by more than one config.
+ # Store configs in an array.
+ my @arr;
+
+ if (defined($objects{$1})) {
+ @arr = @{$objects{$1}};
+ }
+
+ $arr[$#arr+1] = $var;
+
+ # The objects have a hash mapping to a reference
+ # of an array of configs.
+ $objects{$1} = \@arr;
+ }
+ }
+ }
+ }
+ close($infile);
+}
+
+my %modules;
+my $linfile;
+
+if (defined($lsmod_file)) {
+ if ( ! -f $lsmod_file) {
+ if ( -f $ENV{'objtree'}."/".$lsmod_file) {
+ $lsmod_file = $ENV{'objtree'}."/".$lsmod_file;
+ } else {
+ die "$lsmod_file not found";
+ }
+ }
+
+ my $otype = ( -x $lsmod_file) ? '-|' : '<';
+ open($linfile, $otype, $lsmod_file);
+
+} else {
+
+ # see what modules are loaded on this system
+ my $lsmod;
+
+ foreach my $dir ( ("/sbin", "/bin", "/usr/sbin", "/usr/bin") ) {
+ if ( -x "$dir/lsmod" ) {
+ $lsmod = "$dir/lsmod";
+ last;
+ }
+}
+ if (!defined($lsmod)) {
+ # try just the path
+ $lsmod = "lsmod";
+ }
+
+ open($linfile, '-|', $lsmod) || die "Can not call lsmod with $lsmod";
+}
+
+while (<$linfile>) {
+ next if (/^Module/); # Skip the first line.
+ if (/^(\S+)/) {
+ $modules{$1} = 1;
+ }
+}
+close ($linfile);
+
+# add to the configs hash all configs that are needed to enable
+# a loaded module. This is a direct obj-${CONFIG_FOO} += bar.o
+# where we know we need bar.o so we add FOO to the list.
+my %configs;
+foreach my $module (keys(%modules)) {
+ if (defined($objects{$module})) {
+ my @arr = @{$objects{$module}};
+ foreach my $conf (@arr) {
+ $configs{$conf} = $module;
+ dprint "$conf added by direct ($module)\n";
+ if ($debugprint) {
+ my $c=$conf;
+ $c =~ s/^CONFIG_//;
+ if (defined($depends{$c})) {
+ dprint " deps = $depends{$c}\n";
+ } else {
+ dprint " no deps\n";
+ }
+ }
+ }
+ } else {
+ # Most likely, someone has a custom (binary?) module loaded.
+ print STDERR "$module config not found!!\n";
+ }
+}
+
+# Read the current config, and see what is enabled. We want to
+# ignore configs that we would not enable anyway.
+
+my %orig_configs;
+my $valid = "A-Za-z_0-9";
+
+foreach my $line (@config_file) {
+ $_ = $line;
+
+ if (/(CONFIG_[$valid]*)=(m|y)/) {
+ $orig_configs{$1} = $2;
+ }
+}
+
+my $repeat = 1;
+
+my $depconfig;
+
+#
+# Note, we do not care about operands (like: &&, ||, !) we want to add any
+# config that is in the depend list of another config. This script does
+# not enable configs that are not already enabled. If we come across a
+# config A that depends on !B, we can still add B to the list of depends
+# to keep on. If A was on in the original config, B would not have been
+# and B would not be turned on by this script.
+#
+sub parse_config_depends
+{
+ my ($p) = @_;
+
+ while ($p =~ /[$valid]/) {
+
+ if ($p =~ /^[^$valid]*([$valid]+)/) {
+ my $conf = "CONFIG_" . $1;
+
+ $p =~ s/^[^$valid]*[$valid]+//;
+
+ # We only need to process if the depend config is a module
+ if (!defined($orig_configs{$conf}) || !$orig_configs{conf} eq "m") {
+ next;
+ }
+
+ if (!defined($configs{$conf})) {
+ # We must make sure that this config has its
+ # dependencies met.
+ $repeat = 1; # do again
+ dprint "$conf selected by depend $depconfig\n";
+ $configs{$conf} = 1;
+ }
+ } else {
+ die "this should never happen";
+ }
+ }
+}
+
+# Select is treated a bit differently than depends. We call this
+# when a config has no prompt and requires another config to be
+# selected. We use to just select all configs that selected this
+# config, but found that that can balloon into enabling hundreds
+# of configs that we do not care about.
+#
+# The idea is we look at all the configs that select it. If one
+# is already in our list of configs to enable, then there's nothing
+# else to do. If there isn't, we pick the first config that was
+# enabled in the orignal config and use that.
+sub parse_config_selects
+{
+ my ($config, $p) = @_;
+
+ my $next_config;
+
+ while ($p =~ /[$valid]/) {
+
+ if ($p =~ /^[^$valid]*([$valid]+)/) {
+ my $conf = "CONFIG_" . $1;
+
+ $p =~ s/^[^$valid]*[$valid]+//;
+
+ # Make sure that this config exists in the current .config file
+ if (!defined($orig_configs{$conf})) {
+ dprint "$conf not set for $config select\n";
+ next;
+ }
+
+ # Check if something other than a module selects this config
+ if (defined($orig_configs{$conf}) && $orig_configs{$conf} ne "m") {
+ dprint "$conf (non module) selects config, we are good\n";
+ # we are good with this
+ return;
+ }
+ if (defined($configs{$conf})) {
+ dprint "$conf selects $config so we are good\n";
+ # A set config selects this config, we are good
+ return;
+ }
+ # Set this config to be selected
+ if (!defined($next_config)) {
+ $next_config = $conf;
+ }
+ } else {
+ die "this should never happen";
+ }
+ }
+
+ # If no possible config selected this, then something happened.
+ if (!defined($next_config)) {
+ print STDERR "WARNING: $config is required, but nothing in the\n";
+ print STDERR " current config selects it.\n";
+ return;
+ }
+
+ # If we are here, then we found no config that is set and
+ # selects this config. Repeat.
+ $repeat = 1;
+ # Make this config need to be selected
+ $configs{$next_config} = 1;
+ dprint "$next_config selected by select $config\n";
+}
+
+my %process_selects;
+
+# loop through all configs, select their dependencies.
+sub loop_depend {
+ $repeat = 1;
+
+ while ($repeat) {
+ $repeat = 0;
+
+ forloop:
+ foreach my $config (keys %configs) {
+
+ # If this config is not a module, we do not need to process it
+ if (defined($orig_configs{$config}) && $orig_configs{$config} ne "m") {
+ next forloop;
+ }
+
+ $config =~ s/^CONFIG_//;
+ $depconfig = $config;
+
+ if (defined($depends{$config})) {
+ # This config has dependencies. Make sure they are also included
+ parse_config_depends $depends{$config};
+ }
+
+ # If the config has no prompt, then we need to check if a config
+ # that is enabled selected it. Or if we need to enable one.
+ if (!defined($prompts{$config}) && defined($selects{$config})) {
+ $process_selects{$config} = 1;
+ }
+ }
+ }
+}
+
+sub loop_select {
+
+ foreach my $config (keys %process_selects) {
+ $config =~ s/^CONFIG_//;
+
+ dprint "Process select $config\n";
+
+ # config has no prompt and must be selected.
+ parse_config_selects $config, $selects{$config};
+ }
+}
+
+while ($repeat) {
+ # Get the first set of configs and their dependencies.
+ loop_depend;
+
+ $repeat = 0;
+
+ # Now we need to see if we have to check selects;
+ loop_select;
+}
+
+my %setconfigs;
+
+# Finally, read the .config file and turn off any module enabled that
+# we could not find a reason to keep enabled.
+foreach my $line (@config_file) {
+ $_ = $line;
+
+ if (/CONFIG_IKCONFIG/) {
+ if (/# CONFIG_IKCONFIG is not set/) {
+ # enable IKCONFIG at least as a module
+ print "CONFIG_IKCONFIG=m\n";
+ # don't ask about PROC
+ print "# CONFIG_IKCONFIG_PROC is not set\n";
+ } else {
+ print;
+ }
+ next;
+ }
+
+ if (/^(CONFIG.*)=(m|y)/) {
+ if (defined($configs{$1})) {
+ if ($localyesconfig) {
+ $setconfigs{$1} = 'y';
+ print "$1=y\n";
+ next;
+ } else {
+ $setconfigs{$1} = $2;
+ }
+ } elsif ($2 eq "m") {
+ print "# $1 is not set\n";
+ next;
+ }
+ }
+ print;
+}
+
+# Integrity check, make sure all modules that we want enabled do
+# indeed have their configs set.
+loop:
+foreach my $module (keys(%modules)) {
+ if (defined($objects{$module})) {
+ my @arr = @{$objects{$module}};
+ foreach my $conf (@arr) {
+ if (defined($setconfigs{$conf})) {
+ next loop;
+ }
+ }
+ print STDERR "module $module did not have configs";
+ foreach my $conf (@arr) {
+ print STDERR " " , $conf;
+ }
+ print STDERR "\n";
+ }
+}
diff --git a/extra/config/symbol.c b/extra/config/symbol.c
index f8cd319f8..d550300ec 100644
--- a/extra/config/symbol.c
+++ b/extra/config/symbol.c
@@ -7,8 +7,8 @@
#include <stdlib.h>
#include <string.h>
#include <regex.h>
+#include <sys/utsname.h>
-#define LKC_DIRECT_LINK
#include "lkc.h"
struct symbol symbol_yes = {
@@ -35,30 +35,29 @@ tristate modules_val;
struct expr *sym_env_list;
-void sym_add_default(struct symbol *sym, const char *def)
+static void sym_add_default(struct symbol *sym, const char *def)
{
struct property *prop = prop_alloc(P_DEFAULT, sym);
- prop->expr = expr_alloc_symbol(sym_lookup(def, 1));
+ prop->expr = expr_alloc_symbol(sym_lookup(def, SYMBOL_CONST));
}
void sym_init(void)
{
struct symbol *sym;
- char *p;
+ struct utsname uts;
static bool inited = false;
if (inited)
return;
inited = true;
- p = getenv("VERSION");
- if (p) {
- sym = sym_lookup("VERSION", 0);
- sym->type = S_STRING;
- sym->flags |= SYMBOL_AUTO;
- sym_add_default(sym, p);
- }
+ uname(&uts);
+
+ sym = sym_lookup("UNAME_RELEASE", 0);
+ sym->type = S_STRING;
+ sym->flags |= SYMBOL_AUTO;
+ sym_add_default(sym, uts.release);
}
enum symbol_type sym_get_type(struct symbol *sym)
@@ -125,7 +124,7 @@ struct property *sym_get_default_prop(struct symbol *sym)
return NULL;
}
-struct property *sym_get_range_prop(struct symbol *sym)
+static struct property *sym_get_range_prop(struct symbol *sym)
{
struct property *prop;
@@ -137,7 +136,7 @@ struct property *sym_get_range_prop(struct symbol *sym)
return NULL;
}
-static int sym_get_range_val(struct symbol *sym, int base)
+static long sym_get_range_val(struct symbol *sym, int base)
{
sym_calc_value(sym);
switch (sym->type) {
@@ -156,7 +155,7 @@ static int sym_get_range_val(struct symbol *sym, int base)
static void sym_validate_range(struct symbol *sym)
{
struct property *prop;
- int base, val, val2;
+ long base, val, val2;
char str[64];
switch (sym->type) {
@@ -180,9 +179,9 @@ static void sym_validate_range(struct symbol *sym)
return;
}
if (sym->type == S_INT)
- sprintf(str, "%d", val2);
+ sprintf(str, "%ld", val2);
else
- sprintf(str, "0x%x", val2);
+ sprintf(str, "0x%lx", val2);
sym->curr.val = strdup(str);
}
@@ -205,6 +204,16 @@ static void sym_calc_visibility(struct symbol *sym)
}
if (sym_is_choice_value(sym))
return;
+ /* defaulting to "yes" if no explicit "depends on" are given */
+ tri = yes;
+ if (sym->dir_dep.expr)
+ tri = expr_calc_value(sym->dir_dep.expr);
+ if (tri == mod)
+ tri = yes;
+ if (sym->dir_dep.tri != tri) {
+ sym->dir_dep.tri = tri;
+ sym_set_changed(sym);
+ }
tri = no;
if (sym->rev_dep.expr)
tri = expr_calc_value(sym->rev_dep.expr);
@@ -216,42 +225,68 @@ static void sym_calc_visibility(struct symbol *sym)
}
}
-static struct symbol *sym_calc_choice(struct symbol *sym)
+/*
+ * Find the default symbol for a choice.
+ * First try the default values for the choice symbol
+ * Next locate the first visible choice value
+ * Return NULL if none was found
+ */
+struct symbol *sym_choice_default(struct symbol *sym)
{
struct symbol *def_sym;
struct property *prop;
struct expr *e;
- /* is the user choice visible? */
- def_sym = sym->def[S_DEF_USER].val;
- if (def_sym) {
- sym_calc_visibility(def_sym);
- if (def_sym->visible != no)
- return def_sym;
- }
-
/* any of the defaults visible? */
for_all_defaults(sym, prop) {
prop->visible.tri = expr_calc_value(prop->visible.expr);
if (prop->visible.tri == no)
continue;
def_sym = prop_get_symbol(prop);
- sym_calc_visibility(def_sym);
if (def_sym->visible != no)
return def_sym;
}
/* just get the first visible value */
prop = sym_get_choice_prop(sym);
+ expr_list_for_each_sym(prop->expr, e, def_sym)
+ if (def_sym->visible != no)
+ return def_sym;
+
+ /* failed to locate any defaults */
+ return NULL;
+}
+
+static struct symbol *sym_calc_choice(struct symbol *sym)
+{
+ struct symbol *def_sym;
+ struct property *prop;
+ struct expr *e;
+ int flags;
+
+ /* first calculate all choice values' visibilities */
+ flags = sym->flags;
+ prop = sym_get_choice_prop(sym);
expr_list_for_each_sym(prop->expr, e, def_sym) {
sym_calc_visibility(def_sym);
if (def_sym->visible != no)
- return def_sym;
+ flags &= def_sym->flags;
}
- /* no choice? reset tristate value */
- sym->curr.tri = no;
- return NULL;
+ sym->flags &= flags | ~SYMBOL_DEF_USER;
+
+ /* is the user choice visible? */
+ def_sym = sym->def[S_DEF_USER].val;
+ if (def_sym && def_sym->visible != no)
+ return def_sym;
+
+ def_sym = sym_choice_default(sym);
+
+ if (def_sym == NULL)
+ /* no choice? reset tristate value */
+ sym->curr.tri = no;
+
+ return def_sym;
}
void sym_calc_value(struct symbol *sym)
@@ -265,6 +300,14 @@ void sym_calc_value(struct symbol *sym)
if (sym->flags & SYMBOL_VALID)
return;
+
+ if (sym_is_choice_value(sym) &&
+ sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES) {
+ sym->flags &= ~SYMBOL_NEED_SET_CHOICE_VALUES;
+ prop = sym_get_choice_prop(sym);
+ sym_calc_value(prop_get_symbol(prop));
+ }
+
sym->flags |= SYMBOL_VALID;
oldval = sym->curr;
@@ -321,6 +364,18 @@ void sym_calc_value(struct symbol *sym)
}
}
calc_newval:
+ if (sym->dir_dep.tri == no && sym->rev_dep.tri != no) {
+ struct expr *e;
+ e = expr_simplify_unmet_dep(sym->rev_dep.expr,
+ sym->dir_dep.expr);
+ fprintf(stderr, "warning: (");
+ expr_fprint(e, stderr);
+ fprintf(stderr, ") selects %s which has unmet direct dependencies (",
+ sym->name);
+ expr_fprint(sym->dir_dep.expr, stderr);
+ fprintf(stderr, ")\n");
+ expr_free(e);
+ }
newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri);
}
if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN)
@@ -350,9 +405,6 @@ void sym_calc_value(struct symbol *sym)
;
}
- if (sym->flags & SYMBOL_AUTO)
- sym->flags &= ~SYMBOL_WRITE;
-
sym->curr = newval;
if (sym_is_choice(sym) && newval.tri == yes)
sym->curr.val = sym_calc_choice(sym);
@@ -368,15 +420,22 @@ void sym_calc_value(struct symbol *sym)
if (sym_is_choice(sym)) {
struct symbol *choice_sym;
- int flags = sym->flags & (SYMBOL_CHANGED | SYMBOL_WRITE);
prop = sym_get_choice_prop(sym);
expr_list_for_each_sym(prop->expr, e, choice_sym) {
- choice_sym->flags |= flags;
- if (flags & SYMBOL_CHANGED)
+ if ((sym->flags & SYMBOL_WRITE) &&
+ choice_sym->visible != no)
+ choice_sym->flags |= SYMBOL_WRITE;
+ if (sym->flags & SYMBOL_CHANGED)
sym_set_changed(choice_sym);
}
}
+
+ if (sym->flags & SYMBOL_AUTO)
+ sym->flags &= ~SYMBOL_WRITE;
+
+ if (sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES)
+ set_all_choice_values(sym);
}
void sym_clear_all_valid(void)
@@ -535,7 +594,7 @@ bool sym_string_valid(struct symbol *sym, const char *str)
bool sym_string_within_range(struct symbol *sym, const char *str)
{
struct property *prop;
- int val;
+ long val;
switch (sym->type) {
case S_STRING:
@@ -608,11 +667,11 @@ bool sym_set_string_value(struct symbol *sym, const char *newval)
size = strlen(newval) + 1;
if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) {
size += 2;
- sym->def[S_DEF_USER].val = val = malloc(size);
+ sym->def[S_DEF_USER].val = val = xmalloc(size);
*val++ = '0';
*val++ = 'x';
} else if (!oldval || strcmp(oldval, newval))
- sym->def[S_DEF_USER].val = val = malloc(size);
+ sym->def[S_DEF_USER].val = val = xmalloc(size);
else
return true;
@@ -623,6 +682,80 @@ bool sym_set_string_value(struct symbol *sym, const char *newval)
return true;
}
+/*
+ * Find the default value associated to a symbol.
+ * For tristate symbol handle the modules=n case
+ * in which case "m" becomes "y".
+ * If the symbol does not have any default then fallback
+ * to the fixed default values.
+ */
+const char *sym_get_string_default(struct symbol *sym)
+{
+ struct property *prop;
+ struct symbol *ds;
+ const char *str;
+ tristate val;
+
+ sym_calc_visibility(sym);
+ sym_calc_value(modules_sym);
+ val = symbol_no.curr.tri;
+ str = symbol_empty.curr.val;
+
+ /* If symbol has a default value look it up */
+ prop = sym_get_default_prop(sym);
+ if (prop != NULL) {
+ switch (sym->type) {
+ case S_BOOLEAN:
+ case S_TRISTATE:
+ /* The visibility may limit the value from yes => mod */
+ val = EXPR_AND(expr_calc_value(prop->expr), prop->visible.tri);
+ break;
+ default:
+ /*
+ * The following fails to handle the situation
+ * where a default value is further limited by
+ * the valid range.
+ */
+ ds = prop_get_symbol(prop);
+ if (ds != NULL) {
+ sym_calc_value(ds);
+ str = (const char *)ds->curr.val;
+ }
+ }
+ }
+
+ /* Handle select statements */
+ val = EXPR_OR(val, sym->rev_dep.tri);
+
+ /* transpose mod to yes if modules are not enabled */
+ if (val == mod)
+ if (!sym_is_choice_value(sym) && modules_sym->curr.tri == no)
+ val = yes;
+
+ /* transpose mod to yes if type is bool */
+ if (sym->type == S_BOOLEAN && val == mod)
+ val = yes;
+
+ switch (sym->type) {
+ case S_BOOLEAN:
+ case S_TRISTATE:
+ switch (val) {
+ case no: return "n";
+ case mod: return "m";
+ case yes: return "y";
+ }
+ case S_INT:
+ case S_HEX:
+ return str;
+ case S_STRING:
+ return str;
+ case S_OTHER:
+ case S_UNKNOWN:
+ break;
+ }
+ return "";
+}
+
const char *sym_get_string_value(struct symbol *sym)
{
tristate val;
@@ -635,7 +768,8 @@ const char *sym_get_string_value(struct symbol *sym)
case no:
return "n";
case mod:
- return "m";
+ sym_calc_value(modules_sym);
+ return (modules_sym->curr.tri == no) ? "n" : "m";
case yes:
return "y";
}
@@ -651,12 +785,20 @@ bool sym_is_changable(struct symbol *sym)
return sym->visible > sym->rev_dep.tri;
}
-struct symbol *sym_lookup(const char *name, int isconst)
+static unsigned strhash(const char *s)
+{
+ /* fnv32 hash */
+ unsigned hash = 2166136261U;
+ for (; *s; s++)
+ hash = (hash ^ *s) * 0x01000193;
+ return hash;
+}
+
+struct symbol *sym_lookup(const char *name, int flags)
{
struct symbol *symbol;
- const char *ptr;
char *new_name;
- int hash = 0;
+ int hash;
if (name) {
if (name[0] && !name[1]) {
@@ -666,29 +808,26 @@ struct symbol *sym_lookup(const char *name, int isconst)
case 'n': return &symbol_no;
}
}
- for (ptr = name; *ptr; ptr++)
- hash += *ptr;
- hash &= 0xff;
+ hash = strhash(name) % SYMBOL_HASHSIZE;
for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) {
- if (!strcmp(symbol->name, name)) {
- if ((isconst && symbol->flags & SYMBOL_CONST) ||
- (!isconst && !(symbol->flags & SYMBOL_CONST)))
- return symbol;
- }
+ if (symbol->name &&
+ !strcmp(symbol->name, name) &&
+ (flags ? symbol->flags & flags
+ : !(symbol->flags & (SYMBOL_CONST|SYMBOL_CHOICE))))
+ return symbol;
}
new_name = strdup(name);
} else {
new_name = NULL;
- hash = 256;
+ hash = 0;
}
- symbol = malloc(sizeof(*symbol));
+ symbol = xmalloc(sizeof(*symbol));
memset(symbol, 0, sizeof(*symbol));
symbol->name = new_name;
symbol->type = S_UNKNOWN;
- if (isconst)
- symbol->flags |= SYMBOL_CONST;
+ symbol->flags |= flags;
symbol->next = symbol_hash[hash];
symbol_hash[hash] = symbol;
@@ -699,7 +838,6 @@ struct symbol *sym_lookup(const char *name, int isconst)
struct symbol *sym_find(const char *name)
{
struct symbol *symbol = NULL;
- const char *ptr;
int hash = 0;
if (!name)
@@ -712,12 +850,11 @@ struct symbol *sym_find(const char *name)
case 'n': return &symbol_no;
}
}
- for (ptr = name; *ptr; ptr++)
- hash += *ptr;
- hash &= 0xff;
+ hash = strhash(name) % SYMBOL_HASHSIZE;
for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) {
- if (!strcmp(symbol->name, name) &&
+ if (symbol->name &&
+ !strcmp(symbol->name, name) &&
!(symbol->flags & SYMBOL_CONST))
break;
}
@@ -725,44 +862,301 @@ struct symbol *sym_find(const char *name)
return symbol;
}
+/*
+ * Expand symbol's names embedded in the string given in argument. Symbols'
+ * name to be expanded shall be prefixed by a '$'. Unknown symbol expands to
+ * the empty string.
+ */
+const char *sym_expand_string_value(const char *in)
+{
+ const char *src;
+ char *res;
+ size_t reslen;
+
+ reslen = strlen(in) + 1;
+ res = xmalloc(reslen);
+ res[0] = '\0';
+
+ while ((src = strchr(in, '$'))) {
+ char *p, name[SYMBOL_MAXLENGTH];
+ const char *symval = "";
+ struct symbol *sym;
+ size_t newlen;
+
+ strncat(res, in, src - in);
+ src++;
+
+ p = name;
+ while (isalnum(*src) || *src == '_')
+ *p++ = *src++;
+ *p = '\0';
+
+ sym = sym_find(name);
+ if (sym != NULL) {
+ sym_calc_value(sym);
+ symval = sym_get_string_value(sym);
+ }
+
+ newlen = strlen(res) + strlen(symval) + strlen(src) + 1;
+ if (newlen > reslen) {
+ reslen = newlen;
+ res = realloc(res, reslen);
+ }
+
+ strcat(res, symval);
+ in = src;
+ }
+ strcat(res, in);
+
+ return res;
+}
+
+const char *sym_escape_string_value(const char *in)
+{
+ const char *p;
+ size_t reslen;
+ char *res;
+ size_t l;
+
+ reslen = strlen(in) + strlen("\"\"") + 1;
+
+ p = in;
+ for (;;) {
+ l = strcspn(p, "\"\\");
+ p += l;
+
+ if (p[0] == '\0')
+ break;
+
+ reslen++;
+ p++;
+ }
+
+ res = xmalloc(reslen);
+ res[0] = '\0';
+
+ strcat(res, "\"");
+
+ p = in;
+ for (;;) {
+ l = strcspn(p, "\"\\");
+ strncat(res, p, l);
+ p += l;
+
+ if (p[0] == '\0')
+ break;
+
+ strcat(res, "\\");
+ strncat(res, p++, 1);
+ }
+
+ strcat(res, "\"");
+ return res;
+}
+
+struct sym_match {
+ struct symbol *sym;
+ off_t so, eo;
+};
+
+/* Compare matched symbols as thus:
+ * - first, symbols that match exactly
+ * - then, alphabetical sort
+ */
+static int sym_rel_comp( const void *sym1, const void *sym2 )
+{
+ struct sym_match *s1 = *(struct sym_match **)sym1;
+ struct sym_match *s2 = *(struct sym_match **)sym2;
+ int l1, l2;
+
+ /* Exact match:
+ * - if matched length on symbol s1 is the length of that symbol,
+ * then this symbol should come first;
+ * - if matched length on symbol s2 is the length of that symbol,
+ * then this symbol should come first.
+ * Note: since the search can be a regexp, both symbols may match
+ * exactly; if this is the case, we can't decide which comes first,
+ * and we fallback to sorting alphabetically.
+ */
+ l1 = s1->eo - s1->so;
+ l2 = s2->eo - s2->so;
+ if (l1 == strlen(s1->sym->name) && l2 != strlen(s2->sym->name))
+ return -1;
+ if (l1 != strlen(s1->sym->name) && l2 == strlen(s2->sym->name))
+ return 1;
+
+ /* As a fallback, sort symbols alphabetically */
+ return strcmp(s1->sym->name, s2->sym->name);
+}
+
struct symbol **sym_re_search(const char *pattern)
{
struct symbol *sym, **sym_arr = NULL;
+ struct sym_match **sym_match_arr = NULL;
int i, cnt, size;
regex_t re;
+ regmatch_t match[1];
cnt = size = 0;
/* Skip if empty */
if (strlen(pattern) == 0)
return NULL;
- if (regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB|REG_ICASE))
+ if (regcomp(&re, pattern, REG_EXTENDED|REG_ICASE))
return NULL;
for_all_symbols(i, sym) {
+ struct sym_match *tmp_sym_match;
if (sym->flags & SYMBOL_CONST || !sym->name)
continue;
- if (regexec(&re, sym->name, 0, NULL, 0))
+ if (regexec(&re, sym->name, 1, match, 0))
continue;
if (cnt + 1 >= size) {
- void *tmp = sym_arr;
+ void *tmp;
size += 16;
- sym_arr = realloc(sym_arr, size * sizeof(struct symbol *));
- if (!sym_arr) {
- free(tmp);
- return NULL;
+ tmp = realloc(sym_match_arr, size * sizeof(struct sym_match *));
+ if (!tmp) {
+ goto sym_re_search_free;
}
+ sym_match_arr = tmp;
}
- sym_arr[cnt++] = sym;
+ sym_calc_value(sym);
+ tmp_sym_match = (struct sym_match*)malloc(sizeof(struct sym_match));
+ if (!tmp_sym_match)
+ goto sym_re_search_free;
+ tmp_sym_match->sym = sym;
+ /* As regexec return 0, we know we have a match, so
+ * we can use match[0].rm_[se]o without further checks
+ */
+ tmp_sym_match->so = match[0].rm_so;
+ tmp_sym_match->eo = match[0].rm_eo;
+ sym_match_arr[cnt++] = tmp_sym_match;
}
- if (sym_arr)
+ if (sym_match_arr) {
+ qsort(sym_match_arr, cnt, sizeof(struct sym_match*), sym_rel_comp);
+ sym_arr = malloc((cnt+1) * sizeof(struct symbol));
+ if (!sym_arr)
+ goto sym_re_search_free;
+ for (i = 0; i < cnt; i++)
+ sym_arr[i] = sym_match_arr[i]->sym;
sym_arr[cnt] = NULL;
+ }
+sym_re_search_free:
+ if (sym_match_arr) {
+ for (i = 0; i < cnt; i++)
+ free(sym_match_arr[i]);
+ free(sym_match_arr);
+ }
regfree(&re);
return sym_arr;
}
+/*
+ * When we check for recursive dependencies we use a stack to save
+ * current state so we can print out relevant info to user.
+ * The entries are located on the call stack so no need to free memory.
+ * Note inser() remove() must always match to properly clear the stack.
+ */
+static struct dep_stack {
+ struct dep_stack *prev, *next;
+ struct symbol *sym;
+ struct property *prop;
+ struct expr *expr;
+} *check_top;
-struct symbol *sym_check_deps(struct symbol *sym);
+static void dep_stack_insert(struct dep_stack *stack, struct symbol *sym)
+{
+ memset(stack, 0, sizeof(*stack));
+ if (check_top)
+ check_top->next = stack;
+ stack->prev = check_top;
+ stack->sym = sym;
+ check_top = stack;
+}
+
+static void dep_stack_remove(void)
+{
+ check_top = check_top->prev;
+ if (check_top)
+ check_top->next = NULL;
+}
+
+/*
+ * Called when we have detected a recursive dependency.
+ * check_top point to the top of the stact so we use
+ * the ->prev pointer to locate the bottom of the stack.
+ */
+static void sym_check_print_recursive(struct symbol *last_sym)
+{
+ struct dep_stack *stack;
+ struct symbol *sym, *next_sym;
+ struct menu *menu = NULL;
+ struct property *prop;
+ struct dep_stack cv_stack;
+
+ if (sym_is_choice_value(last_sym)) {
+ dep_stack_insert(&cv_stack, last_sym);
+ last_sym = prop_get_symbol(sym_get_choice_prop(last_sym));
+ }
+
+ for (stack = check_top; stack != NULL; stack = stack->prev)
+ if (stack->sym == last_sym)
+ break;
+ if (!stack) {
+ fprintf(stderr, "unexpected recursive dependency error\n");
+ return;
+ }
+
+ for (; stack; stack = stack->next) {
+ sym = stack->sym;
+ next_sym = stack->next ? stack->next->sym : last_sym;
+ prop = stack->prop;
+ if (prop == NULL)
+ prop = stack->sym->prop;
+
+ /* for choice values find the menu entry (used below) */
+ if (sym_is_choice(sym) || sym_is_choice_value(sym)) {
+ for (prop = sym->prop; prop; prop = prop->next) {
+ menu = prop->menu;
+ if (prop->menu)
+ break;
+ }
+ }
+ if (stack->sym == last_sym)
+ fprintf(stderr, "%s:%d:error: recursive dependency detected!\n",
+ prop->file->name, prop->lineno);
+ if (stack->expr) {
+ fprintf(stderr, "%s:%d:\tsymbol %s %s value contains %s\n",
+ prop->file->name, prop->lineno,
+ sym->name ? sym->name : "<choice>",
+ prop_get_type_name(prop->type),
+ next_sym->name ? next_sym->name : "<choice>");
+ } else if (stack->prop) {
+ fprintf(stderr, "%s:%d:\tsymbol %s depends on %s\n",
+ prop->file->name, prop->lineno,
+ sym->name ? sym->name : "<choice>",
+ next_sym->name ? next_sym->name : "<choice>");
+ } else if (sym_is_choice(sym)) {
+ fprintf(stderr, "%s:%d:\tchoice %s contains symbol %s\n",
+ menu->file->name, menu->lineno,
+ sym->name ? sym->name : "<choice>",
+ next_sym->name ? next_sym->name : "<choice>");
+ } else if (sym_is_choice_value(sym)) {
+ fprintf(stderr, "%s:%d:\tsymbol %s is part of choice %s\n",
+ menu->file->name, menu->lineno,
+ sym->name ? sym->name : "<choice>",
+ next_sym->name ? next_sym->name : "<choice>");
+ } else {
+ fprintf(stderr, "%s:%d:\tsymbol %s is selected by %s\n",
+ prop->file->name, prop->lineno,
+ sym->name ? sym->name : "<choice>",
+ next_sym->name ? next_sym->name : "<choice>");
+ }
+ }
+
+ if (check_top == &cv_stack)
+ dep_stack_remove();
+}
static struct symbol *sym_check_expr_deps(struct expr *e)
{
@@ -795,20 +1189,14 @@ static struct symbol *sym_check_expr_deps(struct expr *e)
}
/* return NULL when dependencies are OK */
-struct symbol *sym_check_deps(struct symbol *sym)
+static struct symbol *sym_check_sym_deps(struct symbol *sym)
{
struct symbol *sym2;
struct property *prop;
+ struct dep_stack stack;
- if (sym->flags & SYMBOL_CHECK) {
- fprintf(stderr, "%s:%d:error: found recursive dependency: %s",
- sym->prop->file->name, sym->prop->lineno, sym->name);
- return sym;
- }
- if (sym->flags & SYMBOL_CHECKED)
- return NULL;
+ dep_stack_insert(&stack, sym);
- sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED);
sym2 = sym_check_expr_deps(sym->rev_dep.expr);
if (sym2)
goto out;
@@ -816,19 +1204,93 @@ struct symbol *sym_check_deps(struct symbol *sym)
for (prop = sym->prop; prop; prop = prop->next) {
if (prop->type == P_CHOICE || prop->type == P_SELECT)
continue;
+ stack.prop = prop;
sym2 = sym_check_expr_deps(prop->visible.expr);
if (sym2)
- goto out;
+ break;
if (prop->type != P_DEFAULT || sym_is_choice(sym))
continue;
+ stack.expr = prop->expr;
sym2 = sym_check_expr_deps(prop->expr);
if (sym2)
- goto out;
+ break;
+ stack.expr = NULL;
}
+
out:
+ dep_stack_remove();
+
+ return sym2;
+}
+
+static struct symbol *sym_check_choice_deps(struct symbol *choice)
+{
+ struct symbol *sym, *sym2;
+ struct property *prop;
+ struct expr *e;
+ struct dep_stack stack;
+
+ dep_stack_insert(&stack, choice);
+
+ prop = sym_get_choice_prop(choice);
+ expr_list_for_each_sym(prop->expr, e, sym)
+ sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED);
+
+ choice->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED);
+ sym2 = sym_check_sym_deps(choice);
+ choice->flags &= ~SYMBOL_CHECK;
if (sym2)
- fprintf(stderr, " -> %s%s", sym->name, sym2 == sym? "\n": "");
- sym->flags &= ~SYMBOL_CHECK;
+ goto out;
+
+ expr_list_for_each_sym(prop->expr, e, sym) {
+ sym2 = sym_check_sym_deps(sym);
+ if (sym2)
+ break;
+ }
+out:
+ expr_list_for_each_sym(prop->expr, e, sym)
+ sym->flags &= ~SYMBOL_CHECK;
+
+ if (sym2 && sym_is_choice_value(sym2) &&
+ prop_get_symbol(sym_get_choice_prop(sym2)) == choice)
+ sym2 = choice;
+
+ dep_stack_remove();
+
+ return sym2;
+}
+
+struct symbol *sym_check_deps(struct symbol *sym)
+{
+ struct symbol *sym2;
+ struct property *prop;
+
+ if (sym->flags & SYMBOL_CHECK) {
+ sym_check_print_recursive(sym);
+ return sym;
+ }
+ if (sym->flags & SYMBOL_CHECKED)
+ return NULL;
+
+ if (sym_is_choice_value(sym)) {
+ struct dep_stack stack;
+
+ /* for choice groups start the check with main choice symbol */
+ dep_stack_insert(&stack, sym);
+ prop = sym_get_choice_prop(sym);
+ sym2 = sym_check_deps(prop_get_symbol(prop));
+ dep_stack_remove();
+ } else if (sym_is_choice(sym)) {
+ sym2 = sym_check_choice_deps(sym);
+ } else {
+ sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED);
+ sym2 = sym_check_sym_deps(sym);
+ sym->flags &= ~SYMBOL_CHECK;
+ }
+
+ if (sym2 && sym2 == sym)
+ sym2 = NULL;
+
return sym2;
}
@@ -837,7 +1299,7 @@ struct property *prop_alloc(enum prop_type type, struct symbol *sym)
struct property *prop;
struct property **propp;
- prop = malloc(sizeof(*prop));
+ prop = xmalloc(sizeof(*prop));
memset(prop, 0, sizeof(*prop));
prop->type = type;
prop->sym = sym;
@@ -881,13 +1343,15 @@ const char *prop_get_type_name(enum prop_type type)
return "select";
case P_RANGE:
return "range";
+ case P_SYMBOL:
+ return "symbol";
case P_UNKNOWN:
break;
}
return "unknown";
}
-void prop_add_env(const char *env)
+static void prop_add_env(const char *env)
{
struct symbol *sym, *sym2;
struct property *prop;
@@ -904,7 +1368,7 @@ void prop_add_env(const char *env)
}
prop = prop_alloc(P_ENV, sym);
- prop->expr = expr_alloc_symbol(sym_lookup(env, 1));
+ prop->expr = expr_alloc_symbol(sym_lookup(env, SYMBOL_CONST));
sym_env_list = expr_alloc_one(E_LIST, sym_env_list);
sym_env_list->right.sym = sym;
diff --git a/extra/config/util.c b/extra/config/util.c
index f8e73c039..f1374e6de 100644
--- a/extra/config/util.c
+++ b/extra/config/util.c
@@ -5,6 +5,8 @@
* Released under the terms of the GNU GPL v2.0.
*/
+#include <stdarg.h>
+#include <stdlib.h>
#include <string.h>
#include "lkc.h"
@@ -12,15 +14,18 @@
struct file *file_lookup(const char *name)
{
struct file *file;
+ const char *file_name = sym_expand_string_value(name);
for (file = file_list; file; file = file->next) {
- if (!strcmp(name, file->name))
+ if (!strcmp(name, file->name)) {
+ free((void *)file_name);
return file;
+ }
}
- file = malloc(sizeof(*file));
+ file = xmalloc(sizeof(*file));
memset(file, 0, sizeof(*file));
- file->name = strdup(name);
+ file->name = file_name;
file->next = file_list;
file_list = file;
return file;
@@ -32,11 +37,15 @@ int file_write_dep(const char *name)
struct symbol *sym, *env_sym;
struct expr *e;
struct file *file;
+ char tmpf[PATH_MAX+1];
FILE *out;
if (!name)
name = ".kconfig.d";
- out = fopen("..config.tmp", "w");
+ strcpy(tmpf, name);
+ dir_name(tmpf);
+ strcat(tmpf, "..config.tmp");
+ out = fopen(tmpf, "w");
if (!out)
return 1;
fprintf(out, "deps_config := \\\n");
@@ -46,8 +55,8 @@ int file_write_dep(const char *name)
else
fprintf(out, "\t%s\n", file->name);
}
- fprintf(out, "\ninclude/config/auto.conf: \\\n"
- "\t$(deps_config)\n\n");
+ fprintf(out, "\n%s: \\\n"
+ "\t$(deps_config)\n\n", conf_get_autoconfig_name());
expr_list_for_each_sym(sym_env_list, e, sym) {
struct property *prop;
@@ -61,23 +70,24 @@ int file_write_dep(const char *name)
if (!value)
value = "";
fprintf(out, "ifneq \"$(%s)\" \"%s\"\n", env_sym->name, value);
- fprintf(out, "include/config/auto.conf: FORCE\n");
+ fprintf(out, "%s: FORCE\n", conf_get_autoconfig_name());
fprintf(out, "endif\n");
}
fprintf(out, "\n$(deps_config): ;\n");
fclose(out);
- rename("..config.tmp", name);
+ rename(tmpf, name);
return 0;
}
-/* Allocate initial growable sting */
+/* Allocate initial growable string */
struct gstr str_new(void)
{
struct gstr gs;
- gs.s = malloc(sizeof(char) * 64);
- gs.len = 16;
+ gs.s = xmalloc(sizeof(char) * 64);
+ gs.len = 64;
+ gs.max_width = 0;
strcpy(gs.s, "\0");
return gs;
}
@@ -88,6 +98,7 @@ struct gstr str_assign(const char *s)
struct gstr gs;
gs.s = strdup(s);
gs.len = strlen(s) + 1;
+ gs.max_width = 0;
return gs;
}
@@ -131,3 +142,40 @@ const char *str_get(struct gstr *gs)
return gs->s;
}
+void *xmalloc(size_t size)
+{
+ void *p = malloc(size);
+ if (p)
+ return p;
+ fprintf(stderr, "Out of memory.\n");
+ exit(1);
+}
+
+void *xcalloc(size_t nmemb, size_t size)
+{
+ void *p = calloc(nmemb, size);
+ if (p)
+ return p;
+ fprintf(stderr, "Out of memory.\n");
+ exit(1);
+}
+
+/* basename, dirname - parse pathname components */
+char *dir_name(char *path)
+{
+ char *slash = strrchr(path, '/');
+ int size = 0;
+ if (slash)
+ size = slash - path + 1;
+ path[size] = 0;
+ return path;
+}
+char *base_name(char *path)
+{
+ char *slash = strrchr(path, '/');
+ if (slash)
+ path += slash - path + 1;
+ return path;
+
+}
+
diff --git a/extra/config/zconf.gperf b/extra/config/zconf.gperf
index 25ef5d01c..f14ab4115 100644
--- a/extra/config/zconf.gperf
+++ b/extra/config/zconf.gperf
@@ -9,6 +9,8 @@
struct kconf_id;
+static const struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len);
+
%%
mainmenu, T_MAINMENU, TF_COMMAND
menu, T_MENU, TF_COMMAND
@@ -36,6 +38,7 @@ hex, T_TYPE, TF_COMMAND, S_HEX
string, T_TYPE, TF_COMMAND, S_STRING
select, T_SELECT, TF_COMMAND
range, T_RANGE, TF_COMMAND
+visible, T_VISIBLE, TF_COMMAND
option, T_OPTION, TF_COMMAND
on, T_ON, TF_PARAM
modules, T_OPT_MODULES, TF_OPTION
diff --git a/extra/config/zconf.hash.c_shipped b/extra/config/zconf.hash.c_shipped
index 5c73d5133..40df0005d 100644
--- a/extra/config/zconf.hash.c_shipped
+++ b/extra/config/zconf.hash.c_shipped
@@ -1,6 +1,5 @@
-/* ANSI-C code produced by gperf version 3.0.3 */
-/* Command-line: gperf */
-/* Computed positions: -k'1,3' */
+/* ANSI-C code produced by gperf version 3.0.4 */
+/* Command-line: gperf -t --output-file scripts/kconfig/zconf.hash.c_shipped -a -C -E -g -k '1,3,$' -p -t scripts/kconfig/zconf.gperf */
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
&& ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
@@ -29,8 +28,11 @@
#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
#endif
+#line 10 "scripts/kconfig/zconf.gperf"
struct kconf_id;
-/* maximum key range = 47, duplicates = 0 */
+
+static const struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len);
+/* maximum key range = 71, duplicates = 0 */
#ifdef __GNUC__
__inline
@@ -42,34 +44,34 @@ inline
static unsigned int
kconf_id_hash (register const char *str, register unsigned int len)
{
- static unsigned char asso_values[] =
+ static const unsigned char asso_values[] =
{
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 11, 5,
- 0, 0, 5, 49, 5, 20, 49, 49, 5, 20,
- 5, 0, 30, 49, 0, 15, 0, 10, 0, 49,
- 25, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 25, 25,
+ 0, 0, 0, 5, 0, 0, 73, 73, 5, 0,
+ 10, 5, 45, 73, 20, 20, 0, 15, 15, 73,
+ 20, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73
};
register int hval = len;
@@ -83,137 +85,183 @@ kconf_id_hash (register const char *str, register unsigned int len)
hval += asso_values[(unsigned char)str[0]];
break;
}
- return hval;
+ return hval + asso_values[(unsigned char)str[len - 1]];
}
struct kconf_id_strings_t
{
- char kconf_id_strings_str2[sizeof("on")];
- char kconf_id_strings_str3[sizeof("env")];
+ char kconf_id_strings_str2[sizeof("if")];
+ char kconf_id_strings_str3[sizeof("int")];
char kconf_id_strings_str5[sizeof("endif")];
- char kconf_id_strings_str6[sizeof("option")];
- char kconf_id_strings_str7[sizeof("endmenu")];
- char kconf_id_strings_str8[sizeof("optional")];
+ char kconf_id_strings_str7[sizeof("default")];
+ char kconf_id_strings_str8[sizeof("tristate")];
char kconf_id_strings_str9[sizeof("endchoice")];
- char kconf_id_strings_str10[sizeof("range")];
- char kconf_id_strings_str11[sizeof("choice")];
- char kconf_id_strings_str12[sizeof("default")];
+ char kconf_id_strings_str12[sizeof("def_tristate")];
char kconf_id_strings_str13[sizeof("def_bool")];
- char kconf_id_strings_str14[sizeof("help")];
- char kconf_id_strings_str15[sizeof("bool")];
- char kconf_id_strings_str16[sizeof("config")];
- char kconf_id_strings_str17[sizeof("def_tristate")];
- char kconf_id_strings_str18[sizeof("boolean")];
- char kconf_id_strings_str19[sizeof("defconfig_list")];
- char kconf_id_strings_str21[sizeof("string")];
- char kconf_id_strings_str22[sizeof("if")];
- char kconf_id_strings_str23[sizeof("int")];
- char kconf_id_strings_str26[sizeof("select")];
+ char kconf_id_strings_str14[sizeof("defconfig_list")];
+ char kconf_id_strings_str17[sizeof("on")];
+ char kconf_id_strings_str18[sizeof("optional")];
+ char kconf_id_strings_str21[sizeof("option")];
+ char kconf_id_strings_str22[sizeof("endmenu")];
+ char kconf_id_strings_str23[sizeof("mainmenu")];
+ char kconf_id_strings_str25[sizeof("menuconfig")];
char kconf_id_strings_str27[sizeof("modules")];
- char kconf_id_strings_str28[sizeof("tristate")];
char kconf_id_strings_str29[sizeof("menu")];
- char kconf_id_strings_str31[sizeof("source")];
+ char kconf_id_strings_str31[sizeof("select")];
char kconf_id_strings_str32[sizeof("comment")];
- char kconf_id_strings_str33[sizeof("hex")];
- char kconf_id_strings_str35[sizeof("menuconfig")];
- char kconf_id_strings_str36[sizeof("prompt")];
- char kconf_id_strings_str37[sizeof("depends")];
- char kconf_id_strings_str48[sizeof("mainmenu")];
+ char kconf_id_strings_str33[sizeof("env")];
+ char kconf_id_strings_str35[sizeof("range")];
+ char kconf_id_strings_str36[sizeof("choice")];
+ char kconf_id_strings_str39[sizeof("bool")];
+ char kconf_id_strings_str41[sizeof("source")];
+ char kconf_id_strings_str42[sizeof("visible")];
+ char kconf_id_strings_str43[sizeof("hex")];
+ char kconf_id_strings_str46[sizeof("config")];
+ char kconf_id_strings_str47[sizeof("boolean")];
+ char kconf_id_strings_str51[sizeof("string")];
+ char kconf_id_strings_str54[sizeof("help")];
+ char kconf_id_strings_str56[sizeof("prompt")];
+ char kconf_id_strings_str72[sizeof("depends")];
};
-static struct kconf_id_strings_t kconf_id_strings_contents =
+static const struct kconf_id_strings_t kconf_id_strings_contents =
{
- "on",
- "env",
+ "if",
+ "int",
"endif",
+ "default",
+ "tristate",
+ "endchoice",
+ "def_tristate",
+ "def_bool",
+ "defconfig_list",
+ "on",
+ "optional",
"option",
"endmenu",
- "optional",
- "endchoice",
+ "mainmenu",
+ "menuconfig",
+ "modules",
+ "menu",
+ "select",
+ "comment",
+ "env",
"range",
"choice",
- "default",
- "def_bool",
- "help",
"bool",
+ "source",
+ "visible",
+ "hex",
"config",
- "def_tristate",
"boolean",
- "defconfig_list",
"string",
- "if",
- "int",
- "select",
- "modules",
- "tristate",
- "menu",
- "source",
- "comment",
- "hex",
- "menuconfig",
+ "help",
"prompt",
- "depends",
- "mainmenu"
+ "depends"
};
#define kconf_id_strings ((const char *) &kconf_id_strings_contents)
#ifdef __GNUC__
__inline
-#ifdef __GNUC_STDC_INLINE__
+#if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__
__attribute__ ((__gnu_inline__))
#endif
#endif
-struct kconf_id *
+const struct kconf_id *
kconf_id_lookup (register const char *str, register unsigned int len)
{
enum
{
- TOTAL_KEYWORDS = 31,
+ TOTAL_KEYWORDS = 32,
MIN_WORD_LENGTH = 2,
MAX_WORD_LENGTH = 14,
MIN_HASH_VALUE = 2,
- MAX_HASH_VALUE = 48
+ MAX_HASH_VALUE = 72
};
- static struct kconf_id wordlist[] =
+ static const struct kconf_id wordlist[] =
{
{-1}, {-1},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str2, T_ON, TF_PARAM},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str3, T_OPT_ENV, TF_OPTION},
+#line 25 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str2, T_IF, TF_COMMAND|TF_PARAM},
+#line 36 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str3, T_TYPE, TF_COMMAND, S_INT},
{-1},
+#line 26 "scripts/kconfig/zconf.gperf"
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str5, T_ENDIF, TF_COMMAND},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str6, T_OPTION, TF_COMMAND},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str7, T_ENDMENU, TF_COMMAND},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str8, T_OPTIONAL, TF_COMMAND},
+ {-1},
+#line 29 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str7, T_DEFAULT, TF_COMMAND, S_UNKNOWN},
+#line 31 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str8, T_TYPE, TF_COMMAND, S_TRISTATE},
+#line 20 "scripts/kconfig/zconf.gperf"
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str9, T_ENDCHOICE, TF_COMMAND},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str10, T_RANGE, TF_COMMAND},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str11, T_CHOICE, TF_COMMAND},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str12, T_DEFAULT, TF_COMMAND, S_UNKNOWN},
+ {-1}, {-1},
+#line 32 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str12, T_DEFAULT, TF_COMMAND, S_TRISTATE},
+#line 35 "scripts/kconfig/zconf.gperf"
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str13, T_DEFAULT, TF_COMMAND, S_BOOLEAN},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str14, T_HELP, TF_COMMAND},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str15, T_TYPE, TF_COMMAND, S_BOOLEAN},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str16, T_CONFIG, TF_COMMAND},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str17, T_DEFAULT, TF_COMMAND, S_TRISTATE},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str18, T_TYPE, TF_COMMAND, S_BOOLEAN},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str19, T_OPT_DEFCONFIG_LIST,TF_OPTION},
- {-1},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str21, T_TYPE, TF_COMMAND, S_STRING},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str22, T_IF, TF_COMMAND|TF_PARAM},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str23, T_TYPE, TF_COMMAND, S_INT},
+#line 45 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str14, T_OPT_DEFCONFIG_LIST,TF_OPTION},
+ {-1}, {-1},
+#line 43 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str17, T_ON, TF_PARAM},
+#line 28 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str18, T_OPTIONAL, TF_COMMAND},
{-1}, {-1},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str26, T_SELECT, TF_COMMAND},
+#line 42 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str21, T_OPTION, TF_COMMAND},
+#line 17 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str22, T_ENDMENU, TF_COMMAND},
+#line 15 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str23, T_MAINMENU, TF_COMMAND},
+ {-1},
+#line 23 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str25, T_MENUCONFIG, TF_COMMAND},
+ {-1},
+#line 44 "scripts/kconfig/zconf.gperf"
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str27, T_OPT_MODULES, TF_OPTION},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str28, T_TYPE, TF_COMMAND, S_TRISTATE},
+ {-1},
+#line 16 "scripts/kconfig/zconf.gperf"
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str29, T_MENU, TF_COMMAND},
{-1},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str31, T_SOURCE, TF_COMMAND},
+#line 39 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str31, T_SELECT, TF_COMMAND},
+#line 21 "scripts/kconfig/zconf.gperf"
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str32, T_COMMENT, TF_COMMAND},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str33, T_TYPE, TF_COMMAND, S_HEX},
+#line 46 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str33, T_OPT_ENV, TF_OPTION},
{-1},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str35, T_MENUCONFIG, TF_COMMAND},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str36, T_PROMPT, TF_COMMAND},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str37, T_DEPENDS, TF_COMMAND},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+#line 40 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str35, T_RANGE, TF_COMMAND},
+#line 19 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str36, T_CHOICE, TF_COMMAND},
+ {-1}, {-1},
+#line 33 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str39, T_TYPE, TF_COMMAND, S_BOOLEAN},
+ {-1},
+#line 18 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str41, T_SOURCE, TF_COMMAND},
+#line 41 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str42, T_VISIBLE, TF_COMMAND},
+#line 37 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str43, T_TYPE, TF_COMMAND, S_HEX},
+ {-1}, {-1},
+#line 22 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str46, T_CONFIG, TF_COMMAND},
+#line 34 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str47, T_TYPE, TF_COMMAND, S_BOOLEAN},
+ {-1}, {-1}, {-1},
+#line 38 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str51, T_TYPE, TF_COMMAND, S_STRING},
+ {-1}, {-1},
+#line 24 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str54, T_HELP, TF_COMMAND},
{-1},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str48, T_MAINMENU, TF_COMMAND}
+#line 30 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str56, T_PROMPT, TF_COMMAND},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+#line 27 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str72, T_DEPENDS, TF_COMMAND}
};
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
@@ -234,4 +282,5 @@ kconf_id_lookup (register const char *str, register unsigned int len)
}
return 0;
}
+#line 47 "scripts/kconfig/zconf.gperf"
diff --git a/extra/config/zconf.l b/extra/config/zconf.l
index 4cea5c85c..6555a4754 100644
--- a/extra/config/zconf.l
+++ b/extra/config/zconf.l
@@ -1,5 +1,6 @@
-%option backup nostdinit noyywrap never-interactive full ecs
-%option 8bit backup nodefault perf-report perf-report
+%option nostdinit noyywrap never-interactive full ecs
+%option 8bit nodefault perf-report perf-report
+%option noinput
%x COMMAND HELP STRING PARAM
%{
/*
@@ -13,7 +14,6 @@
#include <string.h>
#include <unistd.h>
-#define LKC_DIRECT_LINK
#include "lkc.h"
#define START_STRSIZE 16
@@ -38,15 +38,15 @@ static int last_ts, first_ts;
static void zconf_endhelp(void);
static void zconf_endfile(void);
-void new_string(void)
+static void new_string(void)
{
- text = malloc(START_STRSIZE);
+ text = xmalloc(START_STRSIZE);
text_asize = START_STRSIZE;
text_size = 0;
*text = 0;
}
-void append_string(const char *str, int size)
+static void append_string(const char *str, int size)
{
int new_size = text_size + size + 1;
if (new_size > text_asize) {
@@ -60,9 +60,9 @@ void append_string(const char *str, int size)
text[text_size] = 0;
}
-void alloc_string(const char *str, int size)
+static void alloc_string(const char *str, int size)
{
- text = malloc(size + 1);
+ text = xmalloc(size + 1);
memcpy(text, str, size);
text[size] = 0;
}
@@ -95,7 +95,7 @@ n [A-Za-z0-9_]
<COMMAND>{
{n}+ {
- struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
+ const struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
BEGIN(PARAM);
current_pos.file = current_file;
current_pos.lineno = current_file->lineno;
@@ -131,7 +131,7 @@ n [A-Za-z0-9_]
\n BEGIN(INITIAL); current_file->lineno++; return T_EOL;
--- /* ignore */
({n}|[-/.])+ {
- struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
+ const struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
if (id && id->flags & TF_PARAM) {
zconflval.id = id;
return id->token;
@@ -288,39 +288,50 @@ void zconf_initscan(const char *name)
exit(1);
}
- current_buf = malloc(sizeof(*current_buf));
+ current_buf = xmalloc(sizeof(*current_buf));
memset(current_buf, 0, sizeof(*current_buf));
current_file = file_lookup(name);
current_file->lineno = 1;
- current_file->flags = FILE_BUSY;
}
void zconf_nextfile(const char *name)
{
+ struct file *iter;
struct file *file = file_lookup(name);
- struct buffer *buf = malloc(sizeof(*buf));
+ struct buffer *buf = xmalloc(sizeof(*buf));
memset(buf, 0, sizeof(*buf));
current_buf->state = YY_CURRENT_BUFFER;
- yyin = zconf_fopen(name);
+ yyin = zconf_fopen(file->name);
if (!yyin) {
- printf("%s:%d: can't open file \"%s\"\n", zconf_curname(), zconf_lineno(), name);
+ printf("%s:%d: can't open file \"%s\"\n",
+ zconf_curname(), zconf_lineno(), file->name);
exit(1);
}
yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
buf->parent = current_buf;
current_buf = buf;
- if (file->flags & FILE_BUSY) {
- printf("recursive scan (%s)?\n", name);
- exit(1);
- }
- if (file->flags & FILE_SCANNED) {
- printf("file %s already scanned?\n", name);
- exit(1);
+ for (iter = current_file->parent; iter; iter = iter->parent ) {
+ if (!strcmp(current_file->name,iter->name) ) {
+ printf("%s:%d: recursive inclusion detected. "
+ "Inclusion path:\n current file : '%s'\n",
+ zconf_curname(), zconf_lineno(),
+ zconf_curname());
+ iter = current_file->parent;
+ while (iter && \
+ strcmp(iter->name,current_file->name)) {
+ printf(" included from: '%s:%d'\n",
+ iter->name, iter->lineno-1);
+ iter = iter->parent;
+ }
+ if (iter)
+ printf(" included from: '%s:%d'\n",
+ iter->name, iter->lineno+1);
+ exit(1);
+ }
}
- file->flags |= FILE_BUSY;
file->lineno = 1;
file->parent = current_file;
current_file = file;
@@ -330,8 +341,6 @@ static void zconf_endfile(void)
{
struct buffer *parent;
- current_file->flags |= FILE_SCANNED;
- current_file->flags &= ~FILE_BUSY;
current_file = current_file->parent;
parent = current_buf->parent;
@@ -349,7 +358,7 @@ int zconf_lineno(void)
return current_pos.lineno;
}
-char *zconf_curname(void)
+const char *zconf_curname(void)
{
return current_pos.file ? current_pos.file->name : "<none>";
}
diff --git a/extra/config/lex.zconf.c_shipped b/extra/config/zconf.lex.c_shipped
index 6a1ea6f9e..a0521aa59 100644
--- a/extra/config/lex.zconf.c_shipped
+++ b/extra/config/zconf.lex.c_shipped
@@ -1,5 +1,5 @@
-#line 3 "scripts/kconfig/lex.zconf.c"
+#line 3 "scripts/kconfig/zconf.lex.c_shipped"
#define YY_INT_ALIGNED short int
@@ -27,7 +27,7 @@
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 33
+#define YY_FLEX_SUBMINOR_VERSION 35
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
@@ -49,10 +49,10 @@
/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
-#if __STDC_VERSION__ >= 199901L
+#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
- * if you want the limit (max/min) macros for int types.
+ * if you want the limit (max/min) macros for int types.
*/
#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS 1
@@ -112,11 +112,12 @@ typedef unsigned int flex_uint32_t;
#else /* ! __cplusplus */
-#if __STDC__
+/* C99 requires __STDC__ to be defined as 1. */
+#if defined (__STDC__)
#define YY_USE_CONST
-#endif /* __STDC__ */
+#endif /* defined (__STDC__) */
#endif /* ! __cplusplus */
#ifdef YY_USE_CONST
@@ -196,14 +197,9 @@ extern FILE *zconfin, *zconfout;
#define unput(c) yyunput( c, (yytext_ptr) )
-/* The following is because we cannot portably get our hands on size_t
- * (without autoconf's help, which isn't available because we want
- * flex-generated scanners to compile on their own).
- */
-
#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
-typedef unsigned int yy_size_t;
+typedef size_t yy_size_t;
#endif
#ifndef YY_STRUCT_YY_BUFFER_STATE
@@ -767,6 +763,7 @@ int zconf_flex_debug = 0;
#define YY_MORE_ADJ 0
#define YY_RESTORE_YY_MORE_OFFSET
char *zconftext;
+#define YY_NO_INPUT 1
/*
* Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
@@ -779,7 +776,6 @@ char *zconftext;
#include <string.h>
#include <unistd.h>
-#define LKC_DIRECT_LINK
#include "lkc.h"
#define START_STRSIZE 16
@@ -804,15 +800,15 @@ static int last_ts, first_ts;
static void zconf_endhelp(void);
static void zconf_endfile(void);
-void new_string(void)
+static void new_string(void)
{
- text = malloc(START_STRSIZE);
+ text = xmalloc(START_STRSIZE);
text_asize = START_STRSIZE;
text_size = 0;
*text = 0;
}
-void append_string(const char *str, int size)
+static void append_string(const char *str, int size)
{
int new_size = text_size + size + 1;
if (new_size > text_asize) {
@@ -826,9 +822,9 @@ void append_string(const char *str, int size)
text[text_size] = 0;
}
-void alloc_string(const char *str, int size)
+static void alloc_string(const char *str, int size)
{
- text = malloc(size + 1);
+ text = xmalloc(size + 1);
memcpy(text, str, size);
text[size] = 0;
}
@@ -853,6 +849,35 @@ void alloc_string(const char *str, int size)
static int yy_init_globals (void );
+/* Accessor methods to globals.
+ These are made visible to non-reentrant scanners for convenience. */
+
+int zconflex_destroy (void );
+
+int zconfget_debug (void );
+
+void zconfset_debug (int debug_flag );
+
+YY_EXTRA_TYPE zconfget_extra (void );
+
+void zconfset_extra (YY_EXTRA_TYPE user_defined );
+
+FILE *zconfget_in (void );
+
+void zconfset_in (FILE * in_str );
+
+FILE *zconfget_out (void );
+
+void zconfset_out (FILE * out_str );
+
+int zconfget_leng (void );
+
+char *zconfget_text (void );
+
+int zconfget_lineno (void );
+
+void zconfset_lineno (int line_number );
+
/* Macros after this point can all be overridden by user definitions in
* section 1.
*/
@@ -895,7 +920,7 @@ static int input (void );
/* This used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite().
*/
-#define ECHO (void) fwrite( zconftext, zconfleng, 1, zconfout )
+#define ECHO do { if (fwrite( zconftext, zconfleng, 1, zconfout )) {} } while (0)
#endif
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
@@ -1060,7 +1085,7 @@ YY_RULE_SETUP
case 6:
YY_RULE_SETUP
{
- struct kconf_id *id = kconf_id_lookup(zconftext, zconfleng);
+ const struct kconf_id *id = kconf_id_lookup(zconftext, zconfleng);
BEGIN(PARAM);
current_pos.file = current_file;
current_pos.lineno = current_file->lineno;
@@ -1135,7 +1160,7 @@ YY_RULE_SETUP
case 19:
YY_RULE_SETUP
{
- struct kconf_id *id = kconf_id_lookup(zconftext, zconfleng);
+ const struct kconf_id *id = kconf_id_lookup(zconftext, zconfleng);
if (id && id->flags & TF_PARAM) {
zconflval.id = id;
return id->token;
@@ -1535,7 +1560,7 @@ static int yy_get_next_buffer (void)
/* Read in more data. */
YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
- (yy_n_chars), num_to_read );
+ (yy_n_chars), (size_t) num_to_read );
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
}
@@ -1559,6 +1584,14 @@ static int yy_get_next_buffer (void)
else
ret_val = EOB_ACT_CONTINUE_SCAN;
+ if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
+ /* Extend the array by 50%, plus the number we really need. */
+ yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) zconfrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
+ if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
+ }
+
(yy_n_chars) += number_to_move;
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
@@ -1945,7 +1978,9 @@ static void zconfensure_buffer_stack (void)
(yy_buffer_stack) = (struct yy_buffer_state**)zconfalloc
(num_to_alloc * sizeof(struct yy_buffer_state*)
);
-
+ if ( ! (yy_buffer_stack) )
+ YY_FATAL_ERROR( "out of dynamic memory in zconfensure_buffer_stack()" );
+
memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
(yy_buffer_stack_max) = num_to_alloc;
@@ -1963,6 +1998,8 @@ static void zconfensure_buffer_stack (void)
((yy_buffer_stack),
num_to_alloc * sizeof(struct yy_buffer_state*)
);
+ if ( ! (yy_buffer_stack) )
+ YY_FATAL_ERROR( "out of dynamic memory in zconfensure_buffer_stack()" );
/* zero only the new slots.*/
memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
@@ -2007,7 +2044,7 @@ YY_BUFFER_STATE zconf_scan_buffer (char * base, yy_size_t size )
/** Setup the input buffer state to scan a string. The next call to zconflex() will
* scan from a @e copy of @a str.
- * @param str a NUL-terminated string to scan
+ * @param yystr a NUL-terminated string to scan
*
* @return the newly allocated buffer state object.
* @note If you want to scan bytes that may contain NUL values, then use
@@ -2306,39 +2343,50 @@ void zconf_initscan(const char *name)
exit(1);
}
- current_buf = malloc(sizeof(*current_buf));
+ current_buf = xmalloc(sizeof(*current_buf));
memset(current_buf, 0, sizeof(*current_buf));
current_file = file_lookup(name);
current_file->lineno = 1;
- current_file->flags = FILE_BUSY;
}
void zconf_nextfile(const char *name)
{
+ struct file *iter;
struct file *file = file_lookup(name);
- struct buffer *buf = malloc(sizeof(*buf));
+ struct buffer *buf = xmalloc(sizeof(*buf));
memset(buf, 0, sizeof(*buf));
current_buf->state = YY_CURRENT_BUFFER;
- zconfin = zconf_fopen(name);
+ zconfin = zconf_fopen(file->name);
if (!zconfin) {
- printf("%s:%d: can't open file \"%s\"\n", zconf_curname(), zconf_lineno(), name);
+ printf("%s:%d: can't open file \"%s\"\n",
+ zconf_curname(), zconf_lineno(), file->name);
exit(1);
}
zconf_switch_to_buffer(zconf_create_buffer(zconfin,YY_BUF_SIZE));
buf->parent = current_buf;
current_buf = buf;
- if (file->flags & FILE_BUSY) {
- printf("recursive scan (%s)?\n", name);
- exit(1);
- }
- if (file->flags & FILE_SCANNED) {
- printf("file %s already scanned?\n", name);
- exit(1);
+ for (iter = current_file->parent; iter; iter = iter->parent ) {
+ if (!strcmp(current_file->name,iter->name) ) {
+ printf("%s:%d: recursive inclusion detected. "
+ "Inclusion path:\n current file : '%s'\n",
+ zconf_curname(), zconf_lineno(),
+ zconf_curname());
+ iter = current_file->parent;
+ while (iter && \
+ strcmp(iter->name,current_file->name)) {
+ printf(" included from: '%s:%d'\n",
+ iter->name, iter->lineno-1);
+ iter = iter->parent;
+ }
+ if (iter)
+ printf(" included from: '%s:%d'\n",
+ iter->name, iter->lineno+1);
+ exit(1);
+ }
}
- file->flags |= FILE_BUSY;
file->lineno = 1;
file->parent = current_file;
current_file = file;
@@ -2348,8 +2396,6 @@ static void zconf_endfile(void)
{
struct buffer *parent;
- current_file->flags |= FILE_SCANNED;
- current_file->flags &= ~FILE_BUSY;
current_file = current_file->parent;
parent = current_buf->parent;
@@ -2367,7 +2413,7 @@ int zconf_lineno(void)
return current_pos.lineno;
}
-char *zconf_curname(void)
+const char *zconf_curname(void)
{
return current_pos.file ? current_pos.file->name : "<none>";
}
diff --git a/extra/config/zconf.tab.c_shipped b/extra/config/zconf.tab.c_shipped
index eb4982948..208f20087 100644
--- a/extra/config/zconf.tab.c_shipped
+++ b/extra/config/zconf.tab.c_shipped
@@ -1,24 +1,22 @@
-/* A Bison parser, made by GNU Bison 2.3. */
+/* A Bison parser, made by GNU Bison 2.4.3. */
/* Skeleton implementation for Bison's Yacc-like parsers in C
-
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
- Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
+
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+ 2009, 2010 Free Software Foundation, Inc.
+
+ 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, or (at your option)
- any later version.
-
+ the Free Software Foundation, either version 3 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., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
@@ -29,7 +27,7 @@
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
-
+
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
@@ -47,7 +45,7 @@
#define YYBISON 1
/* Bison version. */
-#define YYBISON_VERSION "2.3"
+#define YYBISON_VERSION "2.4.3"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
@@ -55,94 +53,23 @@
/* Pure parsers. */
#define YYPURE 0
+/* Push parsers. */
+#define YYPUSH 0
+
+/* Pull parsers. */
+#define YYPULL 1
+
/* Using locations. */
#define YYLSP_NEEDED 0
/* Substitute the variable and function names. */
-#define yyparse zconfparse
-#define yylex zconflex
-#define yyerror zconferror
-#define yylval zconflval
-#define yychar zconfchar
-#define yydebug zconfdebug
-#define yynerrs zconfnerrs
-
-
-/* Tokens. */
-#ifndef YYTOKENTYPE
-# define YYTOKENTYPE
- /* Put the tokens into the symbol table, so that GDB and other debuggers
- know about them. */
- enum yytokentype {
- T_MAINMENU = 258,
- T_MENU = 259,
- T_ENDMENU = 260,
- T_SOURCE = 261,
- T_CHOICE = 262,
- T_ENDCHOICE = 263,
- T_COMMENT = 264,
- T_CONFIG = 265,
- T_MENUCONFIG = 266,
- T_HELP = 267,
- T_HELPTEXT = 268,
- T_IF = 269,
- T_ENDIF = 270,
- T_DEPENDS = 271,
- T_OPTIONAL = 272,
- T_PROMPT = 273,
- T_TYPE = 274,
- T_DEFAULT = 275,
- T_SELECT = 276,
- T_RANGE = 277,
- T_OPTION = 278,
- T_ON = 279,
- T_WORD = 280,
- T_WORD_QUOTE = 281,
- T_UNEQUAL = 282,
- T_CLOSE_PAREN = 283,
- T_OPEN_PAREN = 284,
- T_EOL = 285,
- T_OR = 286,
- T_AND = 287,
- T_EQUAL = 288,
- T_NOT = 289
- };
-#endif
-/* Tokens. */
-#define T_MAINMENU 258
-#define T_MENU 259
-#define T_ENDMENU 260
-#define T_SOURCE 261
-#define T_CHOICE 262
-#define T_ENDCHOICE 263
-#define T_COMMENT 264
-#define T_CONFIG 265
-#define T_MENUCONFIG 266
-#define T_HELP 267
-#define T_HELPTEXT 268
-#define T_IF 269
-#define T_ENDIF 270
-#define T_DEPENDS 271
-#define T_OPTIONAL 272
-#define T_PROMPT 273
-#define T_TYPE 274
-#define T_DEFAULT 275
-#define T_SELECT 276
-#define T_RANGE 277
-#define T_OPTION 278
-#define T_ON 279
-#define T_WORD 280
-#define T_WORD_QUOTE 281
-#define T_UNEQUAL 282
-#define T_CLOSE_PAREN 283
-#define T_OPEN_PAREN 284
-#define T_EOL 285
-#define T_OR 286
-#define T_AND 287
-#define T_EQUAL 288
-#define T_NOT 289
-
-
+#define yyparse zconfparse
+#define yylex zconflex
+#define yyerror zconferror
+#define yylval zconflval
+#define yychar zconfchar
+#define yydebug zconfdebug
+#define yynerrs zconfnerrs
/* Copy the first part of user declarations. */
@@ -160,11 +87,8 @@
#include <string.h>
#include <stdbool.h>
-#define LKC_DIRECT_LINK
#include "lkc.h"
-#include "zconf.hash.c"
-
#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt)
#define PRINTD 0x0001
@@ -176,21 +100,18 @@ extern int zconflex(void);
static void zconfprint(const char *err, ...);
static void zconf_error(const char *err, ...);
static void zconferror(const char *err);
-static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken);
+static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken);
-struct symbol *symbol_hash[257];
+struct symbol *symbol_hash[SYMBOL_HASHSIZE];
static struct menu *current_menu, *current_entry;
-#define YYDEBUG 0
-#if YYDEBUG
-#define YYERROR_VERBOSE
-#endif
+
/* Enabling traces. */
#ifndef YYDEBUG
-# define YYDEBUG 0
+# define YYDEBUG 1
#endif
/* Enabling verbose error messages. */
@@ -206,31 +127,78 @@ static struct menu *current_menu, *current_entry;
# define YYTOKEN_TABLE 0
#endif
+
+/* Tokens. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum yytokentype {
+ T_MAINMENU = 258,
+ T_MENU = 259,
+ T_ENDMENU = 260,
+ T_SOURCE = 261,
+ T_CHOICE = 262,
+ T_ENDCHOICE = 263,
+ T_COMMENT = 264,
+ T_CONFIG = 265,
+ T_MENUCONFIG = 266,
+ T_HELP = 267,
+ T_HELPTEXT = 268,
+ T_IF = 269,
+ T_ENDIF = 270,
+ T_DEPENDS = 271,
+ T_OPTIONAL = 272,
+ T_PROMPT = 273,
+ T_TYPE = 274,
+ T_DEFAULT = 275,
+ T_SELECT = 276,
+ T_RANGE = 277,
+ T_VISIBLE = 278,
+ T_OPTION = 279,
+ T_ON = 280,
+ T_WORD = 281,
+ T_WORD_QUOTE = 282,
+ T_UNEQUAL = 283,
+ T_CLOSE_PAREN = 284,
+ T_OPEN_PAREN = 285,
+ T_EOL = 286,
+ T_OR = 287,
+ T_AND = 288,
+ T_EQUAL = 289,
+ T_NOT = 290
+ };
+#endif
+
+
+
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
-
{
+
+
char *string;
struct file *file;
struct symbol *symbol;
struct expr *expr;
struct menu *menu;
- struct kconf_id *id;
-}
-/* Line 187 of yacc.c. */
+ const struct kconf_id *id;
+
+
- YYSTYPE;
+} YYSTYPE;
+# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
-# define YYSTYPE_IS_TRIVIAL 1
#endif
-
/* Copy the second part of user declarations. */
-/* Line 216 of yacc.c. */
+/* Include zconf.hash.c here so it can see the token constants. */
+#include "zconf.hash.c"
+
#ifdef short
@@ -281,7 +249,7 @@ typedef short int yytype_int16;
#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
#ifndef YY_
-# if YYENABLE_NLS
+# if defined YYENABLE_NLS && YYENABLE_NLS
# if ENABLE_NLS
# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
# define YY_(msgid) dgettext ("bison-runtime", msgid)
@@ -306,14 +274,14 @@ typedef short int yytype_int16;
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static int
-YYID (int i)
+YYID (int yyi)
#else
static int
-YYID (i)
- int i;
+YYID (yyi)
+ int yyi;
#endif
{
- return i;
+ return yyi;
}
#endif
@@ -394,9 +362,9 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */
/* A type that is properly aligned for any stack member. */
union yyalloc
{
- yytype_int16 yyss;
- YYSTYPE yyvs;
- };
+ yytype_int16 yyss_alloc;
+ YYSTYPE yyvs_alloc;
+};
/* The size of the maximum gap between one aligned stack and the next. */
# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
@@ -430,12 +398,12 @@ union yyalloc
elements in the stack, and YYPTR gives the new location of the
stack. Advance YYPTR to a properly aligned location for the next
stack. */
-# define YYSTACK_RELOCATE(Stack) \
+# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
do \
{ \
YYSIZE_T yynewbytes; \
- YYCOPY (&yyptr->Stack, Stack, yysize); \
- Stack = &yyptr->Stack; \
+ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
+ Stack = &yyptr->Stack_alloc; \
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
yyptr += yynewbytes / sizeof (*yyptr); \
} \
@@ -444,22 +412,22 @@ union yyalloc
#endif
/* YYFINAL -- State number of the termination state. */
-#define YYFINAL 3
+#define YYFINAL 11
/* YYLAST -- Last index in YYTABLE. */
-#define YYLAST 258
+#define YYLAST 290
/* YYNTOKENS -- Number of terminals. */
-#define YYNTOKENS 35
+#define YYNTOKENS 36
/* YYNNTS -- Number of nonterminals. */
-#define YYNNTS 45
+#define YYNNTS 50
/* YYNRULES -- Number of rules. */
-#define YYNRULES 108
+#define YYNRULES 118
/* YYNRULES -- Number of states. */
-#define YYNSTATES 178
+#define YYNSTATES 191
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
#define YYUNDEFTOK 2
-#define YYMAXUTOK 289
+#define YYMAXUTOK 290
#define YYTRANSLATE(YYX) \
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
@@ -495,7 +463,8 @@ static const yytype_uint8 yytranslate[] =
2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, 28, 29, 30, 31, 32, 33, 34
+ 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
+ 35
};
#if YYDEBUG
@@ -503,70 +472,75 @@ static const yytype_uint8 yytranslate[] =
YYRHS. */
static const yytype_uint16 yyprhs[] =
{
- 0, 0, 3, 5, 6, 9, 12, 15, 20, 23,
- 28, 33, 37, 39, 41, 43, 45, 47, 49, 51,
- 53, 55, 57, 59, 61, 63, 67, 70, 74, 77,
- 81, 84, 85, 88, 91, 94, 97, 100, 103, 107,
- 112, 117, 122, 128, 132, 133, 137, 138, 141, 144,
- 147, 149, 153, 154, 157, 160, 163, 166, 169, 174,
- 178, 181, 186, 187, 190, 194, 196, 200, 201, 204,
- 207, 210, 214, 217, 219, 223, 224, 227, 230, 233,
- 237, 241, 244, 247, 250, 251, 254, 257, 260, 265,
- 266, 269, 271, 273, 276, 279, 282, 284, 287, 288,
- 291, 293, 297, 301, 305, 308, 312, 316, 318
+ 0, 0, 3, 6, 8, 11, 13, 14, 17, 20,
+ 23, 26, 31, 36, 40, 42, 44, 46, 48, 50,
+ 52, 54, 56, 58, 60, 62, 64, 66, 68, 72,
+ 75, 79, 82, 86, 89, 90, 93, 96, 99, 102,
+ 105, 108, 112, 117, 122, 127, 133, 137, 138, 142,
+ 143, 146, 150, 153, 155, 159, 160, 163, 166, 169,
+ 172, 175, 180, 184, 187, 192, 193, 196, 200, 202,
+ 206, 207, 210, 213, 216, 220, 224, 228, 230, 234,
+ 235, 238, 241, 244, 248, 252, 255, 258, 261, 262,
+ 265, 268, 271, 276, 277, 280, 283, 286, 287, 290,
+ 292, 294, 297, 300, 303, 305, 308, 309, 312, 314,
+ 318, 322, 326, 329, 333, 337, 339, 341, 342
};
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
static const yytype_int8 yyrhs[] =
{
- 36, 0, -1, 37, -1, -1, 37, 39, -1, 37,
- 53, -1, 37, 64, -1, 37, 3, 74, 76, -1,
- 37, 75, -1, 37, 25, 1, 30, -1, 37, 38,
- 1, 30, -1, 37, 1, 30, -1, 16, -1, 18,
- -1, 19, -1, 21, -1, 17, -1, 22, -1, 20,
- -1, 30, -1, 59, -1, 68, -1, 42, -1, 44,
- -1, 66, -1, 25, 1, 30, -1, 1, 30, -1,
- 10, 25, 30, -1, 41, 45, -1, 11, 25, 30,
- -1, 43, 45, -1, -1, 45, 46, -1, 45, 47,
- -1, 45, 72, -1, 45, 70, -1, 45, 40, -1,
- 45, 30, -1, 19, 73, 30, -1, 18, 74, 77,
- 30, -1, 20, 78, 77, 30, -1, 21, 25, 77,
- 30, -1, 22, 79, 79, 77, 30, -1, 23, 48,
- 30, -1, -1, 48, 25, 49, -1, -1, 33, 74,
- -1, 7, 30, -1, 50, 54, -1, 75, -1, 51,
- 56, 52, -1, -1, 54, 55, -1, 54, 72, -1,
- 54, 70, -1, 54, 30, -1, 54, 40, -1, 18,
- 74, 77, 30, -1, 19, 73, 30, -1, 17, 30,
- -1, 20, 25, 77, 30, -1, -1, 56, 39, -1,
- 14, 78, 76, -1, 75, -1, 57, 60, 58, -1,
- -1, 60, 39, -1, 60, 64, -1, 60, 53, -1,
- 4, 74, 30, -1, 61, 71, -1, 75, -1, 62,
- 65, 63, -1, -1, 65, 39, -1, 65, 64, -1,
- 65, 53, -1, 6, 74, 30, -1, 9, 74, 30,
- -1, 67, 71, -1, 12, 30, -1, 69, 13, -1,
- -1, 71, 72, -1, 71, 30, -1, 71, 40, -1,
- 16, 24, 78, 30, -1, -1, 74, 77, -1, 25,
- -1, 26, -1, 5, 30, -1, 8, 30, -1, 15,
- 30, -1, 30, -1, 76, 30, -1, -1, 14, 78,
- -1, 79, -1, 79, 33, 79, -1, 79, 27, 79,
- -1, 29, 78, 28, -1, 34, 78, -1, 78, 31,
- 78, -1, 78, 32, 78, -1, 25, -1, 26, -1
+ 37, 0, -1, 81, 38, -1, 38, -1, 63, 39,
+ -1, 39, -1, -1, 39, 41, -1, 39, 55, -1,
+ 39, 67, -1, 39, 80, -1, 39, 26, 1, 31,
+ -1, 39, 40, 1, 31, -1, 39, 1, 31, -1,
+ 16, -1, 18, -1, 19, -1, 21, -1, 17, -1,
+ 22, -1, 20, -1, 23, -1, 31, -1, 61, -1,
+ 71, -1, 44, -1, 46, -1, 69, -1, 26, 1,
+ 31, -1, 1, 31, -1, 10, 26, 31, -1, 43,
+ 47, -1, 11, 26, 31, -1, 45, 47, -1, -1,
+ 47, 48, -1, 47, 49, -1, 47, 75, -1, 47,
+ 73, -1, 47, 42, -1, 47, 31, -1, 19, 78,
+ 31, -1, 18, 79, 82, 31, -1, 20, 83, 82,
+ 31, -1, 21, 26, 82, 31, -1, 22, 84, 84,
+ 82, 31, -1, 24, 50, 31, -1, -1, 50, 26,
+ 51, -1, -1, 34, 79, -1, 7, 85, 31, -1,
+ 52, 56, -1, 80, -1, 53, 58, 54, -1, -1,
+ 56, 57, -1, 56, 75, -1, 56, 73, -1, 56,
+ 31, -1, 56, 42, -1, 18, 79, 82, 31, -1,
+ 19, 78, 31, -1, 17, 31, -1, 20, 26, 82,
+ 31, -1, -1, 58, 41, -1, 14, 83, 81, -1,
+ 80, -1, 59, 62, 60, -1, -1, 62, 41, -1,
+ 62, 67, -1, 62, 55, -1, 3, 79, 81, -1,
+ 4, 79, 31, -1, 64, 76, 74, -1, 80, -1,
+ 65, 68, 66, -1, -1, 68, 41, -1, 68, 67,
+ -1, 68, 55, -1, 6, 79, 31, -1, 9, 79,
+ 31, -1, 70, 74, -1, 12, 31, -1, 72, 13,
+ -1, -1, 74, 75, -1, 74, 31, -1, 74, 42,
+ -1, 16, 25, 83, 31, -1, -1, 76, 77, -1,
+ 76, 31, -1, 23, 82, -1, -1, 79, 82, -1,
+ 26, -1, 27, -1, 5, 31, -1, 8, 31, -1,
+ 15, 31, -1, 31, -1, 81, 31, -1, -1, 14,
+ 83, -1, 84, -1, 84, 34, 84, -1, 84, 28,
+ 84, -1, 30, 83, 29, -1, 35, 83, -1, 83,
+ 32, 83, -1, 83, 33, 83, -1, 26, -1, 27,
+ -1, -1, 26, -1
};
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] =
{
- 0, 104, 104, 106, 108, 109, 110, 111, 112, 113,
- 114, 118, 122, 122, 122, 122, 122, 122, 122, 126,
- 127, 128, 129, 130, 131, 135, 136, 142, 150, 156,
- 164, 174, 176, 177, 178, 179, 180, 181, 184, 192,
- 198, 208, 214, 220, 223, 225, 236, 237, 242, 251,
- 256, 264, 267, 269, 270, 271, 272, 273, 276, 282,
- 293, 299, 309, 311, 316, 324, 332, 335, 337, 338,
- 339, 344, 351, 356, 364, 367, 369, 370, 371, 374,
- 382, 389, 396, 402, 409, 411, 412, 413, 416, 424,
- 426, 431, 432, 435, 436, 437, 441, 442, 445, 446,
- 449, 450, 451, 452, 453, 454, 455, 458, 459
+ 0, 104, 104, 104, 106, 106, 108, 110, 111, 112,
+ 113, 114, 115, 119, 123, 123, 123, 123, 123, 123,
+ 123, 123, 127, 128, 129, 130, 131, 132, 136, 137,
+ 143, 151, 157, 165, 175, 177, 178, 179, 180, 181,
+ 182, 185, 193, 199, 209, 215, 221, 224, 226, 237,
+ 238, 243, 252, 257, 265, 268, 270, 271, 272, 273,
+ 274, 277, 283, 294, 300, 310, 312, 317, 325, 333,
+ 336, 338, 339, 340, 345, 352, 359, 364, 372, 375,
+ 377, 378, 379, 382, 390, 397, 404, 410, 417, 419,
+ 420, 421, 424, 432, 434, 435, 438, 445, 447, 452,
+ 453, 456, 457, 458, 462, 463, 466, 467, 470, 471,
+ 472, 473, 474, 475, 476, 479, 480, 483, 484
};
#endif
@@ -579,18 +553,19 @@ static const char *const yytname[] =
"T_SOURCE", "T_CHOICE", "T_ENDCHOICE", "T_COMMENT", "T_CONFIG",
"T_MENUCONFIG", "T_HELP", "T_HELPTEXT", "T_IF", "T_ENDIF", "T_DEPENDS",
"T_OPTIONAL", "T_PROMPT", "T_TYPE", "T_DEFAULT", "T_SELECT", "T_RANGE",
- "T_OPTION", "T_ON", "T_WORD", "T_WORD_QUOTE", "T_UNEQUAL",
+ "T_VISIBLE", "T_OPTION", "T_ON", "T_WORD", "T_WORD_QUOTE", "T_UNEQUAL",
"T_CLOSE_PAREN", "T_OPEN_PAREN", "T_EOL", "T_OR", "T_AND", "T_EQUAL",
- "T_NOT", "$accept", "input", "stmt_list", "option_name", "common_stmt",
- "option_error", "config_entry_start", "config_stmt",
+ "T_NOT", "$accept", "input", "start", "stmt_list", "option_name",
+ "common_stmt", "option_error", "config_entry_start", "config_stmt",
"menuconfig_entry_start", "menuconfig_stmt", "config_option_list",
"config_option", "symbol_option", "symbol_option_list",
"symbol_option_arg", "choice", "choice_entry", "choice_end",
"choice_stmt", "choice_option_list", "choice_option", "choice_block",
- "if_entry", "if_end", "if_stmt", "if_block", "menu", "menu_entry",
- "menu_end", "menu_stmt", "menu_block", "source_stmt", "comment",
- "comment_stmt", "help_start", "help", "depends_list", "depends",
- "prompt_stmt_opt", "prompt", "end", "nl", "if_expr", "expr", "symbol", 0
+ "if_entry", "if_end", "if_stmt", "if_block", "mainmenu_stmt", "menu",
+ "menu_entry", "menu_end", "menu_stmt", "menu_block", "source_stmt",
+ "comment", "comment_stmt", "help_start", "help", "depends_list",
+ "depends", "visibility_list", "visible", "prompt_stmt_opt", "prompt",
+ "end", "nl", "if_expr", "expr", "symbol", "word_opt", 0
};
#endif
@@ -602,40 +577,42 @@ static const yytype_uint16 yytoknum[] =
0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
- 285, 286, 287, 288, 289
+ 285, 286, 287, 288, 289, 290
};
# endif
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
static const yytype_uint8 yyr1[] =
{
- 0, 35, 36, 37, 37, 37, 37, 37, 37, 37,
- 37, 37, 38, 38, 38, 38, 38, 38, 38, 39,
- 39, 39, 39, 39, 39, 40, 40, 41, 42, 43,
- 44, 45, 45, 45, 45, 45, 45, 45, 46, 46,
- 46, 46, 46, 47, 48, 48, 49, 49, 50, 51,
- 52, 53, 54, 54, 54, 54, 54, 54, 55, 55,
- 55, 55, 56, 56, 57, 58, 59, 60, 60, 60,
- 60, 61, 62, 63, 64, 65, 65, 65, 65, 66,
- 67, 68, 69, 70, 71, 71, 71, 71, 72, 73,
- 73, 74, 74, 75, 75, 75, 76, 76, 77, 77,
- 78, 78, 78, 78, 78, 78, 78, 79, 79
+ 0, 36, 37, 37, 38, 38, 39, 39, 39, 39,
+ 39, 39, 39, 39, 40, 40, 40, 40, 40, 40,
+ 40, 40, 41, 41, 41, 41, 41, 41, 42, 42,
+ 43, 44, 45, 46, 47, 47, 47, 47, 47, 47,
+ 47, 48, 48, 48, 48, 48, 49, 50, 50, 51,
+ 51, 52, 53, 54, 55, 56, 56, 56, 56, 56,
+ 56, 57, 57, 57, 57, 58, 58, 59, 60, 61,
+ 62, 62, 62, 62, 63, 64, 65, 66, 67, 68,
+ 68, 68, 68, 69, 70, 71, 72, 73, 74, 74,
+ 74, 74, 75, 76, 76, 76, 77, 78, 78, 79,
+ 79, 80, 80, 80, 81, 81, 82, 82, 83, 83,
+ 83, 83, 83, 83, 83, 84, 84, 85, 85
};
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
static const yytype_uint8 yyr2[] =
{
- 0, 2, 1, 0, 2, 2, 2, 4, 2, 4,
- 4, 3, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 3, 2, 3, 2, 3,
- 2, 0, 2, 2, 2, 2, 2, 2, 3, 4,
- 4, 4, 5, 3, 0, 3, 0, 2, 2, 2,
- 1, 3, 0, 2, 2, 2, 2, 2, 4, 3,
- 2, 4, 0, 2, 3, 1, 3, 0, 2, 2,
- 2, 3, 2, 1, 3, 0, 2, 2, 2, 3,
- 3, 2, 2, 2, 0, 2, 2, 2, 4, 0,
- 2, 1, 1, 2, 2, 2, 1, 2, 0, 2,
- 1, 3, 3, 3, 2, 3, 3, 1, 1
+ 0, 2, 2, 1, 2, 1, 0, 2, 2, 2,
+ 2, 4, 4, 3, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 3, 2,
+ 3, 2, 3, 2, 0, 2, 2, 2, 2, 2,
+ 2, 3, 4, 4, 4, 5, 3, 0, 3, 0,
+ 2, 3, 2, 1, 3, 0, 2, 2, 2, 2,
+ 2, 4, 3, 2, 4, 0, 2, 3, 1, 3,
+ 0, 2, 2, 2, 3, 3, 3, 1, 3, 0,
+ 2, 2, 2, 3, 3, 2, 2, 2, 0, 2,
+ 2, 2, 4, 0, 2, 2, 2, 0, 2, 1,
+ 1, 2, 2, 2, 1, 2, 0, 2, 1, 3,
+ 3, 3, 2, 3, 3, 1, 1, 0, 1
};
/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
@@ -643,158 +620,172 @@ static const yytype_uint8 yyr2[] =
means the default is an error. */
static const yytype_uint8 yydefact[] =
{
- 3, 0, 0, 1, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 12, 16, 13, 14,
- 18, 15, 17, 0, 19, 0, 4, 31, 22, 31,
- 23, 52, 62, 5, 67, 20, 84, 75, 6, 24,
- 84, 21, 8, 11, 91, 92, 0, 0, 93, 0,
- 48, 94, 0, 0, 0, 107, 108, 0, 0, 0,
- 100, 95, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 96, 7, 71, 79, 80, 27, 29, 0,
- 104, 0, 0, 64, 0, 0, 9, 10, 0, 0,
- 0, 0, 89, 0, 0, 0, 44, 0, 37, 36,
- 32, 33, 0, 35, 34, 0, 0, 89, 0, 56,
- 57, 53, 55, 54, 63, 51, 50, 68, 70, 66,
- 69, 65, 86, 87, 85, 76, 78, 74, 77, 73,
- 97, 103, 105, 106, 102, 101, 26, 82, 0, 98,
- 0, 98, 98, 98, 0, 0, 0, 83, 60, 98,
- 0, 98, 0, 0, 0, 38, 90, 0, 0, 98,
- 46, 43, 25, 0, 59, 0, 88, 99, 39, 40,
- 41, 0, 0, 45, 58, 61, 42, 47
+ 6, 0, 104, 0, 3, 0, 6, 6, 99, 100,
+ 0, 1, 0, 0, 0, 0, 117, 0, 0, 0,
+ 0, 0, 0, 14, 18, 15, 16, 20, 17, 19,
+ 21, 0, 22, 0, 7, 34, 25, 34, 26, 55,
+ 65, 8, 70, 23, 93, 79, 9, 27, 88, 24,
+ 10, 0, 105, 2, 74, 13, 0, 101, 0, 118,
+ 0, 102, 0, 0, 0, 115, 116, 0, 0, 0,
+ 108, 103, 0, 0, 0, 0, 0, 0, 0, 88,
+ 0, 0, 75, 83, 51, 84, 30, 32, 0, 112,
+ 0, 0, 67, 0, 0, 11, 12, 0, 0, 0,
+ 0, 97, 0, 0, 0, 47, 0, 40, 39, 35,
+ 36, 0, 38, 37, 0, 0, 97, 0, 59, 60,
+ 56, 58, 57, 66, 54, 53, 71, 73, 69, 72,
+ 68, 106, 95, 0, 94, 80, 82, 78, 81, 77,
+ 90, 91, 89, 111, 113, 114, 110, 109, 29, 86,
+ 0, 106, 0, 106, 106, 106, 0, 0, 0, 87,
+ 63, 106, 0, 106, 0, 96, 0, 0, 41, 98,
+ 0, 0, 106, 49, 46, 28, 0, 62, 0, 107,
+ 92, 42, 43, 44, 0, 0, 48, 61, 64, 45,
+ 50
};
/* YYDEFGOTO[NTERM-NUM]. */
static const yytype_int16 yydefgoto[] =
{
- -1, 1, 2, 25, 26, 99, 27, 28, 29, 30,
- 64, 100, 101, 145, 173, 31, 32, 115, 33, 66,
- 111, 67, 34, 119, 35, 68, 36, 37, 127, 38,
- 70, 39, 40, 41, 102, 103, 69, 104, 140, 141,
- 42, 73, 154, 59, 60
+ -1, 3, 4, 5, 33, 34, 108, 35, 36, 37,
+ 38, 74, 109, 110, 157, 186, 39, 40, 124, 41,
+ 76, 120, 77, 42, 128, 43, 78, 6, 44, 45,
+ 137, 46, 80, 47, 48, 49, 111, 112, 81, 113,
+ 79, 134, 152, 153, 50, 7, 165, 69, 70, 60
};
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM. */
-#define YYPACT_NINF -78
+#define YYPACT_NINF -90
static const yytype_int16 yypact[] =
{
- -78, 33, 130, -78, -28, 73, 73, 7, 73, 36,
- 41, 73, 26, 52, -4, 58, -78, -78, -78, -78,
- -78, -78, -78, 90, -78, 94, -78, -78, -78, -78,
- -78, -78, -78, -78, -78, -78, -78, -78, -78, -78,
- -78, -78, -78, -78, -78, -78, 74, 85, -78, 96,
- -78, -78, 131, 134, 147, -78, -78, -4, -4, 193,
- -10, -78, 162, 164, 38, 102, 64, 148, 5, 192,
- 5, 165, -78, 174, -78, -78, -78, -78, -78, 65,
- -78, -4, -4, 174, 103, 103, -78, -78, 175, 185,
- 197, 73, 73, -4, 194, 103, -78, 231, -78, -78,
- -78, -78, 220, -78, -78, 204, 73, 73, 210, -78,
- -78, -78, -78, -78, -78, -78, -78, -78, -78, -78,
- -78, -78, -78, -78, -78, -78, -78, -78, -78, -78,
- -78, -78, 205, -78, -78, -78, -78, -78, -4, 222,
- 208, 222, 195, 222, 103, 2, 209, -78, -78, 222,
- 211, 222, 199, -4, 212, -78, -78, 213, 214, 222,
- 207, -78, -78, 215, -78, 216, -78, 111, -78, -78,
- -78, 217, 73, -78, -78, -78, -78, -78
+ 4, 42, -90, 96, -90, 111, -90, 15, -90, -90,
+ 75, -90, 82, 42, 104, 42, 110, 107, 42, 115,
+ 125, -4, 121, -90, -90, -90, -90, -90, -90, -90,
+ -90, 162, -90, 163, -90, -90, -90, -90, -90, -90,
+ -90, -90, -90, -90, -90, -90, -90, -90, -90, -90,
+ -90, 139, -90, -90, 138, -90, 142, -90, 143, -90,
+ 152, -90, 164, 167, 168, -90, -90, -4, -4, 77,
+ -18, -90, 177, 185, 33, 71, 195, 247, 236, -2,
+ 236, 171, -90, -90, -90, -90, -90, -90, 41, -90,
+ -4, -4, 138, 97, 97, -90, -90, 186, 187, 194,
+ 42, 42, -4, 196, 97, -90, 219, -90, -90, -90,
+ -90, 210, -90, -90, 204, 42, 42, 199, -90, -90,
+ -90, -90, -90, -90, -90, -90, -90, -90, -90, -90,
+ -90, 222, -90, 223, -90, -90, -90, -90, -90, -90,
+ -90, -90, -90, -90, 215, -90, -90, -90, -90, -90,
+ -4, 222, 228, 222, -5, 222, 97, 35, 229, -90,
+ -90, 222, 232, 222, -4, -90, 135, 233, -90, -90,
+ 234, 235, 222, 240, -90, -90, 237, -90, 239, -13,
+ -90, -90, -90, -90, 244, 42, -90, -90, -90, -90,
+ -90
};
/* YYPGOTO[NTERM-NUM]. */
static const yytype_int16 yypgoto[] =
{
- -78, -78, -78, -78, 121, -35, -78, -78, -78, -78,
- 219, -78, -78, -78, -78, -78, -78, -78, -44, -78,
- -78, -78, -78, -78, -78, -78, -78, -78, -78, -6,
- -78, -78, -78, -78, -78, 183, 218, 21, 143, -5,
- 146, 196, 69, -53, -77
+ -90, -90, 269, 271, -90, 23, -70, -90, -90, -90,
+ -90, 243, -90, -90, -90, -90, -90, -90, -90, -48,
+ -90, -90, -90, -90, -90, -90, -90, -90, -90, -90,
+ -90, -20, -90, -90, -90, -90, -90, 206, 205, -68,
+ -90, -90, 169, -1, 27, -7, 118, -66, -89, -90
};
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
positive, shift that token. If negative, reduce the rule which
number is the opposite. If zero, do what YYDEFACT says.
If YYTABLE_NINF, syntax error. */
-#define YYTABLE_NINF -82
+#define YYTABLE_NINF -86
static const yytype_int16 yytable[] =
{
- 46, 47, 43, 49, 79, 80, 52, 134, 135, 6,
- 7, 8, 9, 10, 11, 12, 13, 84, 144, 14,
- 15, 55, 56, 85, 118, 57, 126, 160, 132, 133,
- 58, 110, 161, 3, 123, 24, 123, 48, -28, 88,
- 142, -28, -28, -28, -28, -28, -28, -28, -28, -28,
- 89, 53, -28, -28, 90, -28, 91, 92, 93, 94,
- 95, 96, 120, 97, 128, 88, 50, 159, 98, -49,
- -49, 51, -49, -49, -49, -49, 89, 54, -49, -49,
- 90, 105, 106, 107, 108, 152, 139, 113, 61, 97,
- 124, 62, 124, 131, 109, 63, 81, 82, 44, 45,
- 167, 149, -30, 88, 72, -30, -30, -30, -30, -30,
- -30, -30, -30, -30, 89, 74, -30, -30, 90, -30,
- 91, 92, 93, 94, 95, 96, 75, 97, 55, 56,
- -2, 4, 98, 5, 6, 7, 8, 9, 10, 11,
- 12, 13, 81, 82, 14, 15, 16, 17, 18, 19,
- 20, 21, 22, 7, 8, 23, 10, 11, 12, 13,
- 24, 76, 14, 15, 77, -81, 88, 177, -81, -81,
- -81, -81, -81, -81, -81, -81, -81, 78, 24, -81,
- -81, 90, -81, -81, -81, -81, -81, -81, 114, 117,
- 97, 125, 86, 88, 87, 122, -72, -72, -72, -72,
- -72, -72, -72, -72, 130, 136, -72, -72, 90, 153,
- 156, 157, 158, 116, 121, 137, 129, 97, 163, 143,
- 165, 138, 122, 72, 81, 82, 81, 82, 171, 166,
- 81, 82, 146, 147, 148, 151, 153, 82, 155, 162,
- 172, 164, 168, 169, 170, 174, 175, 176, 65, 112,
- 150, 0, 0, 0, 0, 83, 0, 0, 71
+ 10, 88, 89, 54, 146, 147, 119, 1, 122, 164,
+ 93, 141, 56, 142, 58, 156, 94, 62, 1, 90,
+ 91, 131, 65, 66, 144, 145, 67, 90, 91, 132,
+ 127, 68, 136, -31, 97, 2, 154, -31, -31, -31,
+ -31, -31, -31, -31, -31, 98, 52, -31, -31, 99,
+ -31, 100, 101, 102, 103, 104, -31, 105, 129, 106,
+ 138, 173, 92, 141, 107, 142, 174, 172, 8, 9,
+ 143, -33, 97, 90, 91, -33, -33, -33, -33, -33,
+ -33, -33, -33, 98, 166, -33, -33, 99, -33, 100,
+ 101, 102, 103, 104, -33, 105, 11, 106, 179, 151,
+ 123, 126, 107, 135, 125, 130, 2, 139, 2, 90,
+ 91, -5, 12, 55, 161, 13, 14, 15, 16, 17,
+ 18, 19, 20, 65, 66, 21, 22, 23, 24, 25,
+ 26, 27, 28, 29, 30, 57, 59, 31, 61, -4,
+ 12, 63, 32, 13, 14, 15, 16, 17, 18, 19,
+ 20, 64, 71, 21, 22, 23, 24, 25, 26, 27,
+ 28, 29, 30, 72, 73, 31, 180, 90, 91, 52,
+ 32, -85, 97, 82, 83, -85, -85, -85, -85, -85,
+ -85, -85, -85, 84, 190, -85, -85, 99, -85, -85,
+ -85, -85, -85, -85, -85, 85, 97, 106, 86, 87,
+ -52, -52, 140, -52, -52, -52, -52, 98, 95, -52,
+ -52, 99, 114, 115, 116, 117, 96, 148, 149, 150,
+ 158, 106, 155, 159, 97, 163, 118, -76, -76, -76,
+ -76, -76, -76, -76, -76, 160, 164, -76, -76, 99,
+ 13, 14, 15, 16, 17, 18, 19, 20, 91, 106,
+ 21, 22, 14, 15, 140, 17, 18, 19, 20, 168,
+ 175, 21, 22, 177, 181, 182, 183, 32, 187, 167,
+ 188, 169, 170, 171, 185, 189, 53, 51, 32, 176,
+ 75, 178, 121, 0, 133, 162, 0, 0, 0, 0,
+ 184
};
static const yytype_int16 yycheck[] =
{
- 5, 6, 30, 8, 57, 58, 11, 84, 85, 4,
- 5, 6, 7, 8, 9, 10, 11, 27, 95, 14,
- 15, 25, 26, 33, 68, 29, 70, 25, 81, 82,
- 34, 66, 30, 0, 69, 30, 71, 30, 0, 1,
- 93, 3, 4, 5, 6, 7, 8, 9, 10, 11,
- 12, 25, 14, 15, 16, 17, 18, 19, 20, 21,
- 22, 23, 68, 25, 70, 1, 30, 144, 30, 5,
- 6, 30, 8, 9, 10, 11, 12, 25, 14, 15,
- 16, 17, 18, 19, 20, 138, 91, 66, 30, 25,
- 69, 1, 71, 28, 30, 1, 31, 32, 25, 26,
- 153, 106, 0, 1, 30, 3, 4, 5, 6, 7,
- 8, 9, 10, 11, 12, 30, 14, 15, 16, 17,
- 18, 19, 20, 21, 22, 23, 30, 25, 25, 26,
- 0, 1, 30, 3, 4, 5, 6, 7, 8, 9,
- 10, 11, 31, 32, 14, 15, 16, 17, 18, 19,
- 20, 21, 22, 5, 6, 25, 8, 9, 10, 11,
- 30, 30, 14, 15, 30, 0, 1, 172, 3, 4,
- 5, 6, 7, 8, 9, 10, 11, 30, 30, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 67, 68,
- 25, 70, 30, 1, 30, 30, 4, 5, 6, 7,
- 8, 9, 10, 11, 30, 30, 14, 15, 16, 14,
- 141, 142, 143, 67, 68, 30, 70, 25, 149, 25,
- 151, 24, 30, 30, 31, 32, 31, 32, 159, 30,
- 31, 32, 1, 13, 30, 25, 14, 32, 30, 30,
- 33, 30, 30, 30, 30, 30, 30, 30, 29, 66,
- 107, -1, -1, -1, -1, 59, -1, -1, 40
+ 1, 67, 68, 10, 93, 94, 76, 3, 76, 14,
+ 28, 81, 13, 81, 15, 104, 34, 18, 3, 32,
+ 33, 23, 26, 27, 90, 91, 30, 32, 33, 31,
+ 78, 35, 80, 0, 1, 31, 102, 4, 5, 6,
+ 7, 8, 9, 10, 11, 12, 31, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 23, 24, 78, 26,
+ 80, 26, 69, 133, 31, 133, 31, 156, 26, 27,
+ 29, 0, 1, 32, 33, 4, 5, 6, 7, 8,
+ 9, 10, 11, 12, 150, 14, 15, 16, 17, 18,
+ 19, 20, 21, 22, 23, 24, 0, 26, 164, 100,
+ 77, 78, 31, 80, 77, 78, 31, 80, 31, 32,
+ 33, 0, 1, 31, 115, 4, 5, 6, 7, 8,
+ 9, 10, 11, 26, 27, 14, 15, 16, 17, 18,
+ 19, 20, 21, 22, 23, 31, 26, 26, 31, 0,
+ 1, 26, 31, 4, 5, 6, 7, 8, 9, 10,
+ 11, 26, 31, 14, 15, 16, 17, 18, 19, 20,
+ 21, 22, 23, 1, 1, 26, 31, 32, 33, 31,
+ 31, 0, 1, 31, 31, 4, 5, 6, 7, 8,
+ 9, 10, 11, 31, 185, 14, 15, 16, 17, 18,
+ 19, 20, 21, 22, 23, 31, 1, 26, 31, 31,
+ 5, 6, 31, 8, 9, 10, 11, 12, 31, 14,
+ 15, 16, 17, 18, 19, 20, 31, 31, 31, 25,
+ 1, 26, 26, 13, 1, 26, 31, 4, 5, 6,
+ 7, 8, 9, 10, 11, 31, 14, 14, 15, 16,
+ 4, 5, 6, 7, 8, 9, 10, 11, 33, 26,
+ 14, 15, 5, 6, 31, 8, 9, 10, 11, 31,
+ 31, 14, 15, 31, 31, 31, 31, 31, 31, 151,
+ 31, 153, 154, 155, 34, 31, 7, 6, 31, 161,
+ 37, 163, 76, -1, 79, 116, -1, -1, -1, -1,
+ 172
};
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
symbol of state STATE-NUM. */
static const yytype_uint8 yystos[] =
{
- 0, 36, 37, 0, 1, 3, 4, 5, 6, 7,
- 8, 9, 10, 11, 14, 15, 16, 17, 18, 19,
- 20, 21, 22, 25, 30, 38, 39, 41, 42, 43,
- 44, 50, 51, 53, 57, 59, 61, 62, 64, 66,
- 67, 68, 75, 30, 25, 26, 74, 74, 30, 74,
- 30, 30, 74, 25, 25, 25, 26, 29, 34, 78,
- 79, 30, 1, 1, 45, 45, 54, 56, 60, 71,
- 65, 71, 30, 76, 30, 30, 30, 30, 30, 78,
- 78, 31, 32, 76, 27, 33, 30, 30, 1, 12,
- 16, 18, 19, 20, 21, 22, 23, 25, 30, 40,
- 46, 47, 69, 70, 72, 17, 18, 19, 20, 30,
- 40, 55, 70, 72, 39, 52, 75, 39, 53, 58,
- 64, 75, 30, 40, 72, 39, 53, 63, 64, 75,
- 30, 28, 78, 78, 79, 79, 30, 30, 24, 74,
- 73, 74, 78, 25, 79, 48, 1, 13, 30, 74,
- 73, 25, 78, 14, 77, 30, 77, 77, 77, 79,
- 25, 30, 30, 77, 30, 77, 30, 78, 30, 30,
- 30, 77, 33, 49, 30, 30, 30, 74
+ 0, 3, 31, 37, 38, 39, 63, 81, 26, 27,
+ 79, 0, 1, 4, 5, 6, 7, 8, 9, 10,
+ 11, 14, 15, 16, 17, 18, 19, 20, 21, 22,
+ 23, 26, 31, 40, 41, 43, 44, 45, 46, 52,
+ 53, 55, 59, 61, 64, 65, 67, 69, 70, 71,
+ 80, 39, 31, 38, 81, 31, 79, 31, 79, 26,
+ 85, 31, 79, 26, 26, 26, 27, 30, 35, 83,
+ 84, 31, 1, 1, 47, 47, 56, 58, 62, 76,
+ 68, 74, 31, 31, 31, 31, 31, 31, 83, 83,
+ 32, 33, 81, 28, 34, 31, 31, 1, 12, 16,
+ 18, 19, 20, 21, 22, 24, 26, 31, 42, 48,
+ 49, 72, 73, 75, 17, 18, 19, 20, 31, 42,
+ 57, 73, 75, 41, 54, 80, 41, 55, 60, 67,
+ 80, 23, 31, 74, 77, 41, 55, 66, 67, 80,
+ 31, 42, 75, 29, 83, 83, 84, 84, 31, 31,
+ 25, 79, 78, 79, 83, 26, 84, 50, 1, 13,
+ 31, 79, 78, 26, 14, 82, 83, 82, 31, 82,
+ 82, 82, 84, 26, 31, 31, 82, 31, 82, 83,
+ 31, 31, 31, 31, 82, 34, 51, 31, 31, 31,
+ 79
};
#define yyerrok (yyerrstatus = 0)
@@ -809,9 +800,18 @@ static const yytype_uint8 yystos[] =
/* Like YYERROR except do call yyerror. This remains here temporarily
to ease the transition to the new meaning of YYERROR, for GCC.
- Once GCC version 2 has supplanted version 1, this can go. */
+ Once GCC version 2 has supplanted version 1, this can go. However,
+ YYFAIL appears to be in use. Nevertheless, it is formally deprecated
+ in Bison 2.4.2's NEWS entry, where a plan to phase it out is
+ discussed. */
#define YYFAIL goto yyerrlab
+#if defined YYFAIL
+ /* This is here to suppress warnings from the GCC cpp's
+ -Wunused-macros. Normally we don't worry about that warning, but
+ some users do, and we want to make it easy for users to remove
+ YYFAIL uses, which will produce warnings from Bison 2.5. */
+#endif
#define YYRECOVERING() (!!yyerrstatus)
@@ -868,7 +868,7 @@ while (YYID (0))
we won't break user code: when these are the locations we know. */
#ifndef YY_LOCATION_PRINT
-# if YYLTYPE_IS_TRIVIAL
+# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
# define YY_LOCATION_PRINT(File, Loc) \
fprintf (File, "%d.%d-%d.%d", \
(Loc).first_line, (Loc).first_column, \
@@ -979,17 +979,20 @@ yy_symbol_print (yyoutput, yytype, yyvaluep)
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static void
-yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
+yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
#else
static void
-yy_stack_print (bottom, top)
- yytype_int16 *bottom;
- yytype_int16 *top;
+yy_stack_print (yybottom, yytop)
+ yytype_int16 *yybottom;
+ yytype_int16 *yytop;
#endif
{
YYFPRINTF (stderr, "Stack now");
- for (; bottom <= top; ++bottom)
- YYFPRINTF (stderr, " %d", *bottom);
+ for (; yybottom <= yytop; yybottom++)
+ {
+ int yybot = *yybottom;
+ YYFPRINTF (stderr, " %d", yybot);
+ }
YYFPRINTF (stderr, "\n");
}
@@ -1023,11 +1026,11 @@ yy_reduce_print (yyvsp, yyrule)
/* The symbols being reduced. */
for (yyi = 0; yyi < yynrhs; yyi++)
{
- fprintf (stderr, " $%d = ", yyi + 1);
+ YYFPRINTF (stderr, " $%d = ", yyi + 1);
yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
&(yyvsp[(yyi + 1) - (yynrhs)])
);
- fprintf (stderr, "\n");
+ YYFPRINTF (stderr, "\n");
}
}
@@ -1275,6 +1278,7 @@ yysyntax_error (char *yyresult, int yystate, int yychar)
}
}
#endif /* YYERROR_VERBOSE */
+
/*-----------------------------------------------.
| Release the memory associated to this symbol. |
@@ -1301,7 +1305,7 @@ yydestruct (yymsg, yytype, yyvaluep)
switch (yytype)
{
- case 51: /* "choice_entry" */
+ case 53: /* "choice_entry" */
{
fprintf(stderr, "%s:%d: missing end statement for this entry\n",
@@ -1311,7 +1315,7 @@ yydestruct (yymsg, yytype, yyvaluep)
};
break;
- case 57: /* "if_entry" */
+ case 59: /* "if_entry" */
{
fprintf(stderr, "%s:%d: missing end statement for this entry\n",
@@ -1321,7 +1325,7 @@ yydestruct (yymsg, yytype, yyvaluep)
};
break;
- case 62: /* "menu_entry" */
+ case 65: /* "menu_entry" */
{
fprintf(stderr, "%s:%d: missing end statement for this entry\n",
@@ -1336,10 +1340,8 @@ yydestruct (yymsg, yytype, yyvaluep)
break;
}
}
-
/* Prevent warnings from -Wmissing-prototypes. */
-
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int yyparse (void *YYPARSE_PARAM);
@@ -1355,11 +1357,10 @@ int yyparse ();
#endif /* ! YYPARSE_PARAM */
-
-/* The look-ahead symbol. */
+/* The lookahead symbol. */
int yychar;
-/* The semantic value of the look-ahead symbol. */
+/* The semantic value of the lookahead symbol. */
YYSTYPE yylval;
/* Number of syntax errors so far. */
@@ -1367,9 +1368,9 @@ int yynerrs;
-/*----------.
-| yyparse. |
-`----------*/
+/*-------------------------.
+| yyparse or yypush_parse. |
+`-------------------------*/
#ifdef YYPARSE_PARAM
#if (defined __STDC__ || defined __C99__FUNC__ \
@@ -1393,66 +1394,68 @@ yyparse ()
#endif
#endif
{
-
- int yystate;
- int yyn;
- int yyresult;
- /* Number of tokens to shift before error messages enabled. */
- int yyerrstatus;
- /* Look-ahead token as an internal (translated) token number. */
- int yytoken = 0;
-#if YYERROR_VERBOSE
- /* Buffer for error messages, and its allocated size. */
- char yymsgbuf[128];
- char *yymsg = yymsgbuf;
- YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
-#endif
-
- /* Three stacks and their tools:
- `yyss': related to states,
- `yyvs': related to semantic values,
- `yyls': related to locations.
- Refer to the stacks thru separate pointers, to allow yyoverflow
- to reallocate them elsewhere. */
- /* The state stack. */
- yytype_int16 yyssa[YYINITDEPTH];
- yytype_int16 *yyss = yyssa;
- yytype_int16 *yyssp;
+ int yystate;
+ /* Number of tokens to shift before error messages enabled. */
+ int yyerrstatus;
- /* The semantic value stack. */
- YYSTYPE yyvsa[YYINITDEPTH];
- YYSTYPE *yyvs = yyvsa;
- YYSTYPE *yyvsp;
+ /* The stacks and their tools:
+ `yyss': related to states.
+ `yyvs': related to semantic values.
+ Refer to the stacks thru separate pointers, to allow yyoverflow
+ to reallocate them elsewhere. */
+ /* The state stack. */
+ yytype_int16 yyssa[YYINITDEPTH];
+ yytype_int16 *yyss;
+ yytype_int16 *yyssp;
-#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
+ /* The semantic value stack. */
+ YYSTYPE yyvsa[YYINITDEPTH];
+ YYSTYPE *yyvs;
+ YYSTYPE *yyvsp;
- YYSIZE_T yystacksize = YYINITDEPTH;
+ YYSIZE_T yystacksize;
+ int yyn;
+ int yyresult;
+ /* Lookahead token as an internal (translated) token number. */
+ int yytoken;
/* The variables used to return semantic value and location from the
action routines. */
YYSTYPE yyval;
+#if YYERROR_VERBOSE
+ /* Buffer for error messages, and its allocated size. */
+ char yymsgbuf[128];
+ char *yymsg = yymsgbuf;
+ YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
+#endif
+
+#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
/* The number of symbols on the RHS of the reduced rule.
Keep to zero when no symbol should be popped. */
int yylen = 0;
+ yytoken = 0;
+ yyss = yyssa;
+ yyvs = yyvsa;
+ yystacksize = YYINITDEPTH;
+
YYDPRINTF ((stderr, "Starting parse\n"));
yystate = 0;
yyerrstatus = 0;
yynerrs = 0;
- yychar = YYEMPTY; /* Cause a token to be read. */
+ yychar = YYEMPTY; /* Cause a token to be read. */
/* Initialize stack pointers.
Waste one element of value and location stack
so that they stay on the same level as the state stack.
The wasted elements are never initialized. */
-
yyssp = yyss;
yyvsp = yyvs;
@@ -1482,7 +1485,6 @@ yyparse ()
YYSTYPE *yyvs1 = yyvs;
yytype_int16 *yyss1 = yyss;
-
/* Each stack pointer address is followed by the size of the
data in use in that stack, in bytes. This used to be a
conditional around just the two extra args, but that might
@@ -1490,7 +1492,6 @@ yyparse ()
yyoverflow (YY_("memory exhausted"),
&yyss1, yysize * sizeof (*yyssp),
&yyvs1, yysize * sizeof (*yyvsp),
-
&yystacksize);
yyss = yyss1;
@@ -1513,9 +1514,8 @@ yyparse ()
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
if (! yyptr)
goto yyexhaustedlab;
- YYSTACK_RELOCATE (yyss);
- YYSTACK_RELOCATE (yyvs);
-
+ YYSTACK_RELOCATE (yyss_alloc, yyss);
+ YYSTACK_RELOCATE (yyvs_alloc, yyvs);
# undef YYSTACK_RELOCATE
if (yyss1 != yyssa)
YYSTACK_FREE (yyss1);
@@ -1526,7 +1526,6 @@ yyparse ()
yyssp = yyss + yysize - 1;
yyvsp = yyvs + yysize - 1;
-
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
(unsigned long int) yystacksize));
@@ -1536,6 +1535,9 @@ yyparse ()
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
+ if (yystate == YYFINAL)
+ YYACCEPT;
+
goto yybackup;
/*-----------.
@@ -1544,16 +1546,16 @@ yyparse ()
yybackup:
/* Do appropriate processing given the current state. Read a
- look-ahead token if we need one and don't already have one. */
+ lookahead token if we need one and don't already have one. */
- /* First try to decide what to do without reference to look-ahead token. */
+ /* First try to decide what to do without reference to lookahead token. */
yyn = yypact[yystate];
if (yyn == YYPACT_NINF)
goto yydefault;
- /* Not known => get a look-ahead token if don't already have one. */
+ /* Not known => get a lookahead token if don't already have one. */
- /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
+ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
if (yychar == YYEMPTY)
{
YYDPRINTF ((stderr, "Reading a token: "));
@@ -1585,20 +1587,16 @@ yybackup:
goto yyreduce;
}
- if (yyn == YYFINAL)
- YYACCEPT;
-
/* Count tokens shifted since error; after three, turn off error
status. */
if (yyerrstatus)
yyerrstatus--;
- /* Shift the look-ahead token. */
+ /* Shift the lookahead token. */
YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
- /* Discard the shifted token unless it is eof. */
- if (yychar != YYEOF)
- yychar = YYEMPTY;
+ /* Discard the shifted token. */
+ yychar = YYEMPTY;
yystate = yyn;
*++yyvsp = yylval;
@@ -1637,39 +1635,39 @@ yyreduce:
YY_REDUCE_PRINT (yyn);
switch (yyn)
{
- case 8:
+ case 10:
{ zconf_error("unexpected end statement"); ;}
break;
- case 9:
+ case 11:
{ zconf_error("unknown statement \"%s\"", (yyvsp[(2) - (4)].string)); ;}
break;
- case 10:
+ case 12:
{
zconf_error("unexpected option \"%s\"", kconf_id_strings + (yyvsp[(2) - (4)].id)->name);
;}
break;
- case 11:
+ case 13:
{ zconf_error("invalid statement"); ;}
break;
- case 25:
+ case 28:
{ zconf_error("unknown option \"%s\"", (yyvsp[(1) - (3)].string)); ;}
break;
- case 26:
+ case 29:
{ zconf_error("invalid option"); ;}
break;
- case 27:
+ case 30:
{
struct symbol *sym = sym_lookup((yyvsp[(2) - (3)].string), 0);
@@ -1679,7 +1677,7 @@ yyreduce:
;}
break;
- case 28:
+ case 31:
{
menu_end_entry();
@@ -1687,7 +1685,7 @@ yyreduce:
;}
break;
- case 29:
+ case 32:
{
struct symbol *sym = sym_lookup((yyvsp[(2) - (3)].string), 0);
@@ -1697,7 +1695,7 @@ yyreduce:
;}
break;
- case 30:
+ case 33:
{
if (current_entry->prompt)
@@ -1709,7 +1707,7 @@ yyreduce:
;}
break;
- case 38:
+ case 41:
{
menu_set_type((yyvsp[(1) - (3)].id)->stype);
@@ -1719,7 +1717,7 @@ yyreduce:
;}
break;
- case 39:
+ case 42:
{
menu_add_prompt(P_PROMPT, (yyvsp[(2) - (4)].string), (yyvsp[(3) - (4)].expr));
@@ -1727,7 +1725,7 @@ yyreduce:
;}
break;
- case 40:
+ case 43:
{
menu_add_expr(P_DEFAULT, (yyvsp[(2) - (4)].expr), (yyvsp[(3) - (4)].expr));
@@ -1739,7 +1737,7 @@ yyreduce:
;}
break;
- case 41:
+ case 44:
{
menu_add_symbol(P_SELECT, sym_lookup((yyvsp[(2) - (4)].string), 0), (yyvsp[(3) - (4)].expr));
@@ -1747,7 +1745,7 @@ yyreduce:
;}
break;
- case 42:
+ case 45:
{
menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,(yyvsp[(2) - (5)].symbol), (yyvsp[(3) - (5)].symbol)), (yyvsp[(4) - (5)].expr));
@@ -1755,10 +1753,10 @@ yyreduce:
;}
break;
- case 45:
+ case 48:
{
- struct kconf_id *id = kconf_id_lookup((yyvsp[(2) - (3)].string), strlen((yyvsp[(2) - (3)].string)));
+ const struct kconf_id *id = kconf_id_lookup((yyvsp[(2) - (3)].string), strlen((yyvsp[(2) - (3)].string)));
if (id && id->flags & TF_OPTION)
menu_add_option(id->token, (yyvsp[(3) - (3)].string));
else
@@ -1767,35 +1765,35 @@ yyreduce:
;}
break;
- case 46:
+ case 49:
{ (yyval.string) = NULL; ;}
break;
- case 47:
+ case 50:
{ (yyval.string) = (yyvsp[(2) - (2)].string); ;}
break;
- case 48:
+ case 51:
{
- struct symbol *sym = sym_lookup(NULL, 0);
- sym->flags |= SYMBOL_CHOICE;
+ struct symbol *sym = sym_lookup((yyvsp[(2) - (3)].string), SYMBOL_CHOICE);
+ sym->flags |= SYMBOL_AUTO;
menu_add_entry(sym);
menu_add_expr(P_CHOICE, NULL, NULL);
printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno());
;}
break;
- case 49:
+ case 52:
{
(yyval.menu) = menu_add_menu();
;}
break;
- case 50:
+ case 53:
{
if (zconf_endtoken((yyvsp[(1) - (1)].id), T_CHOICE, T_ENDCHOICE)) {
@@ -1805,7 +1803,7 @@ yyreduce:
;}
break;
- case 58:
+ case 61:
{
menu_add_prompt(P_PROMPT, (yyvsp[(2) - (4)].string), (yyvsp[(3) - (4)].expr));
@@ -1813,7 +1811,7 @@ yyreduce:
;}
break;
- case 59:
+ case 62:
{
if ((yyvsp[(1) - (3)].id)->stype == S_BOOLEAN || (yyvsp[(1) - (3)].id)->stype == S_TRISTATE) {
@@ -1826,7 +1824,7 @@ yyreduce:
;}
break;
- case 60:
+ case 63:
{
current_entry->sym->flags |= SYMBOL_OPTIONAL;
@@ -1834,7 +1832,7 @@ yyreduce:
;}
break;
- case 61:
+ case 64:
{
if ((yyvsp[(1) - (4)].id)->stype == S_UNKNOWN) {
@@ -1846,7 +1844,7 @@ yyreduce:
;}
break;
- case 64:
+ case 67:
{
printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno());
@@ -1856,7 +1854,7 @@ yyreduce:
;}
break;
- case 65:
+ case 68:
{
if (zconf_endtoken((yyvsp[(1) - (1)].id), T_IF, T_ENDIF)) {
@@ -1866,7 +1864,14 @@ yyreduce:
;}
break;
- case 71:
+ case 74:
+
+ {
+ menu_add_prompt(P_MENU, (yyvsp[(2) - (3)].string), NULL);
+;}
+ break;
+
+ case 75:
{
menu_add_entry(NULL);
@@ -1875,14 +1880,14 @@ yyreduce:
;}
break;
- case 72:
+ case 76:
{
(yyval.menu) = menu_add_menu();
;}
break;
- case 73:
+ case 77:
{
if (zconf_endtoken((yyvsp[(1) - (1)].id), T_MENU, T_ENDMENU)) {
@@ -1892,7 +1897,7 @@ yyreduce:
;}
break;
- case 79:
+ case 83:
{
printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), (yyvsp[(2) - (3)].string));
@@ -1900,7 +1905,7 @@ yyreduce:
;}
break;
- case 80:
+ case 84:
{
menu_add_entry(NULL);
@@ -1909,14 +1914,14 @@ yyreduce:
;}
break;
- case 81:
+ case 85:
{
menu_end_entry();
;}
break;
- case 82:
+ case 86:
{
printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno());
@@ -1924,14 +1929,14 @@ yyreduce:
;}
break;
- case 83:
+ case 87:
{
current_entry->help = (yyvsp[(2) - (2)].string);
;}
break;
- case 88:
+ case 92:
{
menu_add_dep((yyvsp[(3) - (4)].expr));
@@ -1939,85 +1944,96 @@ yyreduce:
;}
break;
- case 90:
+ case 96:
+
+ {
+ menu_add_visibility((yyvsp[(2) - (2)].expr));
+;}
+ break;
+
+ case 98:
{
menu_add_prompt(P_PROMPT, (yyvsp[(1) - (2)].string), (yyvsp[(2) - (2)].expr));
;}
break;
- case 93:
+ case 101:
{ (yyval.id) = (yyvsp[(1) - (2)].id); ;}
break;
- case 94:
+ case 102:
{ (yyval.id) = (yyvsp[(1) - (2)].id); ;}
break;
- case 95:
+ case 103:
{ (yyval.id) = (yyvsp[(1) - (2)].id); ;}
break;
- case 98:
+ case 106:
{ (yyval.expr) = NULL; ;}
break;
- case 99:
+ case 107:
{ (yyval.expr) = (yyvsp[(2) - (2)].expr); ;}
break;
- case 100:
+ case 108:
{ (yyval.expr) = expr_alloc_symbol((yyvsp[(1) - (1)].symbol)); ;}
break;
- case 101:
+ case 109:
{ (yyval.expr) = expr_alloc_comp(E_EQUAL, (yyvsp[(1) - (3)].symbol), (yyvsp[(3) - (3)].symbol)); ;}
break;
- case 102:
+ case 110:
{ (yyval.expr) = expr_alloc_comp(E_UNEQUAL, (yyvsp[(1) - (3)].symbol), (yyvsp[(3) - (3)].symbol)); ;}
break;
- case 103:
+ case 111:
{ (yyval.expr) = (yyvsp[(2) - (3)].expr); ;}
break;
- case 104:
+ case 112:
{ (yyval.expr) = expr_alloc_one(E_NOT, (yyvsp[(2) - (2)].expr)); ;}
break;
- case 105:
+ case 113:
{ (yyval.expr) = expr_alloc_two(E_OR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;}
break;
- case 106:
+ case 114:
{ (yyval.expr) = expr_alloc_two(E_AND, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;}
break;
- case 107:
+ case 115:
{ (yyval.symbol) = sym_lookup((yyvsp[(1) - (1)].string), 0); free((yyvsp[(1) - (1)].string)); ;}
break;
- case 108:
+ case 116:
- { (yyval.symbol) = sym_lookup((yyvsp[(1) - (1)].string), 1); free((yyvsp[(1) - (1)].string)); ;}
+ { (yyval.symbol) = sym_lookup((yyvsp[(1) - (1)].string), SYMBOL_CONST); free((yyvsp[(1) - (1)].string)); ;}
+ break;
+
+ case 117:
+
+ { (yyval.string) = NULL; ;}
break;
-/* Line 1267 of yacc.c. */
default: break;
}
@@ -2029,7 +2045,6 @@ yyreduce:
*++yyvsp = yyval;
-
/* Now `shift' the result of the reduction. Determine what state
that goes to, based on the state we popped back to and the rule
number reduced by. */
@@ -2094,7 +2109,7 @@ yyerrlab:
if (yyerrstatus == 3)
{
- /* If just tried and failed to reuse look-ahead token after an
+ /* If just tried and failed to reuse lookahead token after an
error, discard it. */
if (yychar <= YYEOF)
@@ -2111,7 +2126,7 @@ yyerrlab:
}
}
- /* Else will try to reuse look-ahead token after shifting the error
+ /* Else will try to reuse lookahead token after shifting the error
token. */
goto yyerrlab1;
@@ -2168,9 +2183,6 @@ yyerrlab1:
YY_STACK_PRINT (yyss, yyssp);
}
- if (yyn == YYFINAL)
- YYACCEPT;
-
*++yyvsp = yylval;
@@ -2195,7 +2207,7 @@ yyabortlab:
yyresult = 1;
goto yyreturn;
-#ifndef yyoverflow
+#if !defined(yyoverflow) || YYERROR_VERBOSE
/*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here. |
`-------------------------------------------------*/
@@ -2206,7 +2218,7 @@ yyexhaustedlab:
#endif
yyreturn:
- if (yychar != YYEOF && yychar != YYEMPTY)
+ if (yychar != YYEMPTY)
yydestruct ("Cleanup: discarding lookahead",
yytoken, &yylval);
/* Do not reclaim the symbols of the rule which action triggered
@@ -2243,16 +2255,14 @@ void conf_parse(const char *name)
zconf_initscan(name);
sym_init();
- menu_init();
+ _menu_init();
modules_sym = sym_lookup(NULL, 0);
modules_sym->type = S_BOOLEAN;
modules_sym->flags |= SYMBOL_AUTO;
rootmenu.prompt = menu_add_prompt(P_MENU, "uClibc Configuration", NULL);
-#if YYDEBUG
if (getenv("ZCONF_DEBUG"))
zconfdebug = 1;
-#endif
zconfparse();
if (zconfnerrs)
exit(1);
@@ -2262,6 +2272,10 @@ void conf_parse(const char *name)
prop = prop_alloc(P_DEFAULT, modules_sym);
prop->expr = expr_alloc_symbol(sym_lookup("MODULES", 0));
}
+
+ rootmenu.prompt->text = _(rootmenu.prompt->text);
+ rootmenu.prompt->text = sym_expand_string_value(rootmenu.prompt->text);
+
menu_finalize(&rootmenu);
for_all_symbols(i, sym) {
if (sym_check_deps(sym))
@@ -2272,7 +2286,7 @@ void conf_parse(const char *name)
sym_set_change_count(1);
}
-const char *zconf_tokenname(int token)
+static const char *zconf_tokenname(int token)
{
switch (token) {
case T_MENU: return "menu";
@@ -2282,11 +2296,12 @@ const char *zconf_tokenname(int token)
case T_IF: return "if";
case T_ENDIF: return "endif";
case T_DEPENDS: return "depends";
+ case T_VISIBLE: return "visible";
}
return "<token>";
}
-static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken)
+static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken)
{
if (id->token != endtoken) {
zconf_error("unexpected '%s' within %s block",
@@ -2331,12 +2346,10 @@ static void zconf_error(const char *err, ...)
static void zconferror(const char *err)
{
-#if YYDEBUG
fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err);
-#endif
}
-void print_quoted_string(FILE *out, const char *str)
+static void print_quoted_string(FILE *out, const char *str)
{
const char *p;
int len;
@@ -2353,15 +2366,15 @@ void print_quoted_string(FILE *out, const char *str)
putc('"', out);
}
-void print_symbol(FILE *out, struct menu *menu)
+static void print_symbol(FILE *out, struct menu *menu)
{
struct symbol *sym = menu->sym;
struct property *prop;
if (sym_is_choice(sym))
- fprintf(out, "choice\n");
+ fprintf(out, "\nchoice\n");
else
- fprintf(out, "config %s\n", sym->name);
+ fprintf(out, "\nconfig %s\n", sym->name);
switch (sym->type) {
case S_BOOLEAN:
fputs(" boolean\n", out);
@@ -2407,6 +2420,21 @@ void print_symbol(FILE *out, struct menu *menu)
case P_CHOICE:
fputs(" #choice value\n", out);
break;
+ case P_SELECT:
+ fputs( " select ", out);
+ expr_fprint(prop->expr, out);
+ fputc('\n', out);
+ break;
+ case P_RANGE:
+ fputs( " range ", out);
+ expr_fprint(prop->expr, out);
+ fputc('\n', out);
+ break;
+ case P_MENU:
+ fputs( " menu ", out);
+ print_quoted_string(out, prop->text);
+ fputc('\n', out);
+ break;
default:
fprintf(out, " unknown prop %d!\n", prop->type);
break;
@@ -2418,7 +2446,6 @@ void print_symbol(FILE *out, struct menu *menu)
menu->help[len] = 0;
fprintf(out, " help\n%s\n", menu->help);
}
- fputc('\n', out);
}
void zconfdump(FILE *out)
@@ -2451,7 +2478,6 @@ void zconfdump(FILE *out)
expr_fprint(prop->visible.expr, out);
fputc('\n', out);
}
- fputs("\n", out);
}
if (menu->list)
@@ -2469,7 +2495,7 @@ void zconfdump(FILE *out)
}
}
-#include "lex.zconf.c"
+#include "zconf.lex.c"
#include "util.c"
#include "confdata.c"
#include "expr.c"
diff --git a/extra/config/zconf.y b/extra/config/zconf.y
index 4c6a8e3a3..2cfcfbadc 100644
--- a/extra/config/zconf.y
+++ b/extra/config/zconf.y
@@ -11,11 +11,8 @@
#include <string.h>
#include <stdbool.h>
-#define LKC_DIRECT_LINK
#include "lkc.h"
-#include "zconf.hash.c"
-
#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt)
#define PRINTD 0x0001
@@ -27,18 +24,14 @@ extern int zconflex(void);
static void zconfprint(const char *err, ...);
static void zconf_error(const char *err, ...);
static void zconferror(const char *err);
-static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken);
+static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken);
-struct symbol *symbol_hash[257];
+struct symbol *symbol_hash[SYMBOL_HASHSIZE];
static struct menu *current_menu, *current_entry;
-#define YYDEBUG 0
-#if YYDEBUG
-#define YYERROR_VERBOSE
-#endif
%}
-%expect 26
+%expect 30
%union
{
@@ -47,7 +40,7 @@ static struct menu *current_menu, *current_entry;
struct symbol *symbol;
struct expr *expr;
struct menu *menu;
- struct kconf_id *id;
+ const struct kconf_id *id;
}
%token <id>T_MAINMENU
@@ -70,6 +63,7 @@ static struct menu *current_menu, *current_entry;
%token <id>T_DEFAULT
%token <id>T_SELECT
%token <id>T_RANGE
+%token <id>T_VISIBLE
%token <id>T_OPTION
%token <id>T_ON
%token <string> T_WORD
@@ -91,7 +85,7 @@ static struct menu *current_menu, *current_entry;
%type <id> end
%type <id> option_name
%type <menu> if_entry menu_entry choice_entry
-%type <string> symbol_option_arg
+%type <string> symbol_option_arg word_opt
%destructor {
fprintf(stderr, "%s:%d: missing end statement for this entry\n",
@@ -100,15 +94,21 @@ static struct menu *current_menu, *current_entry;
menu_end_menu();
} if_entry menu_entry choice_entry
+%{
+/* Include zconf.hash.c here so it can see the token constants. */
+#include "zconf.hash.c"
+%}
+
%%
-input: stmt_list;
+input: nl start | start;
+
+start: mainmenu_stmt stmt_list | stmt_list;
stmt_list:
/* empty */
| stmt_list common_stmt
| stmt_list choice_stmt
| stmt_list menu_stmt
- | stmt_list T_MAINMENU prompt nl
| stmt_list end { zconf_error("unexpected end statement"); }
| stmt_list T_WORD error T_EOL { zconf_error("unknown statement \"%s\"", $2); }
| stmt_list option_name error T_EOL
@@ -119,7 +119,7 @@ stmt_list:
;
option_name:
- T_DEPENDS | T_PROMPT | T_TYPE | T_SELECT | T_OPTIONAL | T_RANGE | T_DEFAULT
+ T_DEPENDS | T_PROMPT | T_TYPE | T_SELECT | T_OPTIONAL | T_RANGE | T_DEFAULT | T_VISIBLE
;
common_stmt:
@@ -224,7 +224,7 @@ symbol_option_list:
/* empty */
| symbol_option_list T_WORD symbol_option_arg
{
- struct kconf_id *id = kconf_id_lookup($2, strlen($2));
+ const struct kconf_id *id = kconf_id_lookup($2, strlen($2));
if (id && id->flags & TF_OPTION)
menu_add_option(id->token, $3);
else
@@ -239,10 +239,10 @@ symbol_option_arg:
/* choice entry */
-choice: T_CHOICE T_EOL
+choice: T_CHOICE word_opt T_EOL
{
- struct symbol *sym = sym_lookup(NULL, 0);
- sym->flags |= SYMBOL_CHOICE;
+ struct symbol *sym = sym_lookup($2, SYMBOL_CHOICE);
+ sym->flags |= SYMBOL_AUTO;
menu_add_entry(sym);
menu_add_expr(P_CHOICE, NULL, NULL);
printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno());
@@ -339,6 +339,13 @@ if_block:
| if_block choice_stmt
;
+/* mainmenu entry */
+
+mainmenu_stmt: T_MAINMENU prompt nl
+{
+ menu_add_prompt(P_MENU, $2, NULL);
+};
+
/* menu entry */
menu: T_MENU prompt T_EOL
@@ -348,7 +355,7 @@ menu: T_MENU prompt T_EOL
printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno());
};
-menu_entry: menu depends_list
+menu_entry: menu visibility_list depends_list
{
$$ = menu_add_menu();
};
@@ -419,6 +426,19 @@ depends: T_DEPENDS T_ON expr T_EOL
printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno());
};
+/* visibility option */
+
+visibility_list:
+ /* empty */
+ | visibility_list visible
+ | visibility_list T_EOL
+;
+
+visible: T_VISIBLE if_expr
+{
+ menu_add_visibility($2);
+};
+
/* prompt statement */
prompt_stmt_opt:
@@ -456,9 +476,12 @@ expr: symbol { $$ = expr_alloc_symbol($1); }
;
symbol: T_WORD { $$ = sym_lookup($1, 0); free($1); }
- | T_WORD_QUOTE { $$ = sym_lookup($1, 1); free($1); }
+ | T_WORD_QUOTE { $$ = sym_lookup($1, SYMBOL_CONST); free($1); }
;
+word_opt: /* empty */ { $$ = NULL; }
+ | T_WORD
+
%%
void conf_parse(const char *name)
@@ -469,16 +492,14 @@ void conf_parse(const char *name)
zconf_initscan(name);
sym_init();
- menu_init();
+ _menu_init();
modules_sym = sym_lookup(NULL, 0);
modules_sym->type = S_BOOLEAN;
modules_sym->flags |= SYMBOL_AUTO;
rootmenu.prompt = menu_add_prompt(P_MENU, "uClibc Configuration", NULL);
-#if YYDEBUG
if (getenv("ZCONF_DEBUG"))
zconfdebug = 1;
-#endif
zconfparse();
if (zconfnerrs)
exit(1);
@@ -488,6 +509,10 @@ void conf_parse(const char *name)
prop = prop_alloc(P_DEFAULT, modules_sym);
prop->expr = expr_alloc_symbol(sym_lookup("MODULES", 0));
}
+
+ rootmenu.prompt->text = _(rootmenu.prompt->text);
+ rootmenu.prompt->text = sym_expand_string_value(rootmenu.prompt->text);
+
menu_finalize(&rootmenu);
for_all_symbols(i, sym) {
if (sym_check_deps(sym))
@@ -498,7 +523,7 @@ void conf_parse(const char *name)
sym_set_change_count(1);
}
-const char *zconf_tokenname(int token)
+static const char *zconf_tokenname(int token)
{
switch (token) {
case T_MENU: return "menu";
@@ -508,11 +533,12 @@ const char *zconf_tokenname(int token)
case T_IF: return "if";
case T_ENDIF: return "endif";
case T_DEPENDS: return "depends";
+ case T_VISIBLE: return "visible";
}
return "<token>";
}
-static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken)
+static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken)
{
if (id->token != endtoken) {
zconf_error("unexpected '%s' within %s block",
@@ -557,12 +583,10 @@ static void zconf_error(const char *err, ...)
static void zconferror(const char *err)
{
-#if YYDEBUG
fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err);
-#endif
}
-void print_quoted_string(FILE *out, const char *str)
+static void print_quoted_string(FILE *out, const char *str)
{
const char *p;
int len;
@@ -579,15 +603,15 @@ void print_quoted_string(FILE *out, const char *str)
putc('"', out);
}
-void print_symbol(FILE *out, struct menu *menu)
+static void print_symbol(FILE *out, struct menu *menu)
{
struct symbol *sym = menu->sym;
struct property *prop;
if (sym_is_choice(sym))
- fprintf(out, "choice\n");
+ fprintf(out, "\nchoice\n");
else
- fprintf(out, "config %s\n", sym->name);
+ fprintf(out, "\nconfig %s\n", sym->name);
switch (sym->type) {
case S_BOOLEAN:
fputs(" boolean\n", out);
@@ -633,6 +657,21 @@ void print_symbol(FILE *out, struct menu *menu)
case P_CHOICE:
fputs(" #choice value\n", out);
break;
+ case P_SELECT:
+ fputs( " select ", out);
+ expr_fprint(prop->expr, out);
+ fputc('\n', out);
+ break;
+ case P_RANGE:
+ fputs( " range ", out);
+ expr_fprint(prop->expr, out);
+ fputc('\n', out);
+ break;
+ case P_MENU:
+ fputs( " menu ", out);
+ print_quoted_string(out, prop->text);
+ fputc('\n', out);
+ break;
default:
fprintf(out, " unknown prop %d!\n", prop->type);
break;
@@ -644,7 +683,6 @@ void print_symbol(FILE *out, struct menu *menu)
menu->help[len] = 0;
fprintf(out, " help\n%s\n", menu->help);
}
- fputc('\n', out);
}
void zconfdump(FILE *out)
@@ -677,7 +715,6 @@ void zconfdump(FILE *out)
expr_fprint(prop->visible.expr, out);
fputc('\n', out);
}
- fputs("\n", out);
}
if (menu->list)
@@ -695,7 +732,7 @@ void zconfdump(FILE *out)
}
}
-#include "lex.zconf.c"
+#include "zconf.lex.c"
#include "util.c"
#include "confdata.c"
#include "expr.c"
diff --git a/extra/locale/.gitignore b/extra/locale/.gitignore
new file mode 100644
index 000000000..3ea196522
--- /dev/null
+++ b/extra/locale/.gitignore
@@ -0,0 +1,26 @@
+#
+# Never ignore these
+#
+!.gitignore
+
+#
+# Generated files
+#
+/c8tables.h
+/codesets.txt
+/locale_collate.h
+/locale_data.c
+/locale_tables.h
+/locales.txt
+/lt_defines.h
+/uClibc_locale_data.h
+/wctables.h
+#
+# generators
+#
+/gen_collate
+/gen_ldc
+/gen_locale
+/gen_wc8bit
+/gen_wctype
+
diff --git a/extra/locale/Makefile b/extra/locale/Makefile
index 11f362a5e..ff229e20c 100644
--- a/extra/locale/Makefile
+++ b/extra/locale/Makefile
@@ -4,10 +4,10 @@
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-
top_srcdir=../../
-top_builddir=../../
+top_builddir=$(if $(O),$(O),../../)/
+
all: objs
-include $(top_builddir)Rules.mak
+include $(top_srcdir)Rules.mak
include Makefile.in
include $(top_srcdir)Makerules
diff --git a/extra/locale/Makefile.in b/extra/locale/Makefile.in
index 52de0f26e..117993fd0 100644
--- a/extra/locale/Makefile.in
+++ b/extra/locale/Makefile.in
@@ -1,55 +1,72 @@
# 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.
#
+locale_DIR := $(top_srcdir)extra/locale
+locale_OUT := $(top_builddir)extra/locale
+
# command used to download source code
WGET := wget --passive-ftp
-LOCALE_DATA_FILENAME := uClibc-locale-030818.tgz
+LOCALE_DATA_FILENAME := uClibc-locale-20081111-$(ARCH_NATIVE_BIT)-$(if $(ARCH_LITTLE_ENDIAN),el,eb).tgz
BUILD_CFLAGS-locale-common := \
-D__UCLIBC_GEN_LOCALE \
- -DUCLIBC_CTYPE_HEADER='"$(top_builddir)include/bits/uClibc_ctype.h"'
+ -I$(top_builddir)
BUILD_CFLAGS-gen_wc8bit := $(BUILD_CFLAGS-locale-common) -DCTYPE_PACKED=1
-
BUILD_CFLAGS-gen_wctype := $(BUILD_CFLAGS-locale-common)
-
-BUILD_CFLAGS-gen_ldc :=
+BUILD_CFLAGS-gen_ldc := -I$(locale_OUT)
ifeq ($(UCLIBC_HAS_WCHAR),y)
BUILD_CFLAGS-gen_wc8bit += -DDO_WIDE_CHAR=1
BUILD_CFLAGS-gen_ldc += -D__WCHAR_ENABLED=1
endif
+BUILD_CFLAGS-gen_locale := -D_GNU_SOURCE -I$(locale_OUT)
+BUILD_CFLAGS-gen_collate := -D_GNU_SOURCE
-BUILD_CFLAGS-gen_locale := -D_GNU_SOURCE
+locale_headers-$(UCLIBC_HAS_LOCALE) := $(top_builddir)include/bits/uClibc_locale_data.h
-DEPH-locale := $(top_builddir)include/bits/sysnum.h
-DEPH-gen_locale := c8tables.h
-DEPH-gen_ldc := c8tables.h wctables.h locale_tables.h locale_collate.h
+headers_dep += $(locale_headers-y)
-locale_DIR := $(top_srcdir)extra/locale
-locale_OUT := $(top_builddir)extra/locale
+DEPH-locale := $(top_builddir)include/bits/uClibc_config.h
+DEPH-gen_collate := $(DEPH-locale)
+DEPH-gen_ldc := $(addprefix $(locale_OUT)/,c8tables.h wctables.h locale_tables.h locale_collate.h) $(DEPH-locale)
+DEPH-gen_locale := $(addprefix $(locale_OUT)/,c8tables.h) $(DEPH-locale)
+DEPH-gen_wc8bit := $(top_builddir)include/bits/uClibc_ctype.h $(DEPH-locale)
+DEPH-gen_wctype := $(top_builddir)include/bits/uClibc_ctype.h $(DEPH-locale)
-#locale_HOBJ := gen_collate gen_ldc gen_locale gen_wc8bit gen_wctype
-locale_HOBJ := gen_collate gen_wc8bit gen_wctype
-locale_HOBJ := $(patsubst %,$(locale_OUT)/%,$(locale_HOBJ))
+locale_HOBJ := gen_collate gen_ldc gen_locale gen_wc8bit gen_wctype
+locale_HOBJ := $(addprefix $(locale_OUT)/,$(locale_HOBJ))
+$(locale_HOBJ): | $(locale_OUT)
locale_SRC := $(locale_OUT)/locale_data.c
locale_OBJ := $(locale_OUT)/locale_data.o
CFLAGS-locale_data.c := -D__WCHAR_ENABLED -I$(locale_OUT) -I$(locale_DIR)
-# produces a loop
-#headers-$(UCLIBC_HAS_LOCALE) += locale_headers
-
libc-$(UCLIBC_HAS_LOCALE) += $(locale_OBJ)
-
libc-nomulti-$(UCLIBC_HAS_LOCALE) += $(locale_OBJ)
-locale_headers: $(top_builddir)include/bits/uClibc_locale_data.h
+$(locale_OUT)%.o: $(locale_OUT)%.c FORCE ; $(compile.c)
+$(locale_OUT)%.os: $(locale_OUT)%.c FORCE ; $(compile.c)
+$(locale_OUT)%.oS: $(locale_OUT)%.c FORCE ; $(compile.c)
+$(locale_OUT)%.o: $(locale_OUT)%.S FORCE ; $(compile.S)
+$(locale_OUT)%.os: $(locale_OUT)%.S FORCE ; $(compile.S)
+$(locale_OUT)%.oS: $(locale_OUT)%.S FORCE ; $(compile.S)
+$(locale_OUT)%.o: $(locale_OUT)%.s FORCE ; $(compile.S)
+$(locale_OUT)%.os: $(locale_OUT)%.s FORCE ; $(compile.S)
+$(locale_OUT)%.oS: $(locale_OUT)%.s FORCE ; $(compile.S)
+$(locale_OUT)%.i: $(locale_OUT)%.c FORCE ; $(compile.i)
+$(locale_OUT)%.i: $(locale_OUT)%.S FORCE ; $(compile.i)
+$(locale_OUT)%.s: $(locale_OUT)%.c FORCE ; $(compile.s)
+$(locale_OUT)%.s: $(locale_OUT)%.S FORCE ; $(compile.s)
+$(locale_OUT)%.dep:
+
+
+locale_headers: $(locale_headers-y)
# make sure that the host system has locales (this check is ok for uClibc/glibc)
# we do not know though which locales were really enabled for libc at build time
@@ -61,12 +78,12 @@ $(locale_OUT)/codesets.txt:
echo " "; \
echo "You do not have a codesets.txt file. Please create this "; \
echo "file in the $(locale_OUT) directory by running something like: "; \
- echo -e " find $(locale_DIR)/charmaps -name \"*.pairs\" > \\"; \
- echo -e " $@"; \
+ echo " find $(CURDIR)/$(locale_DIR)/charmaps -name \"*.pairs\" > \\"; \
+ echo " $@"; \
echo "and then edit that file to disable/enable the codesets you wish to support. "; \
echo " "; \
false; \
- fi;
+ fi
$(locale_OUT)/locales.txt:
@if [ ! -f $@ ] ; then \
@@ -81,99 +98,115 @@ $(locale_OUT)/locales.txt:
echo "to support. "; \
echo " "; \
false; \
- fi;
+ fi
else
$(locale_OUT)/codesets.txt:
+ @$(disp_gen)
ifeq ($(UCLIBC_BUILD_MINIMAL_LOCALE),y)
- echo "$(locale_DIR)/charmaps/ASCII.pairs" > $@ ; \
- echo "$(locale_DIR)/charmaps/ISO-8859-1.pairs" >> $@
+ $(Q)echo "$(CURDIR)/$(locale_DIR)/charmaps/ASCII.pairs" > $@
+ $(Q)echo "$(CURDIR)/$(locale_DIR)/charmaps/ISO-8859-1.pairs" >> $@
else
- find $(locale_DIR)/charmaps -name '*.pairs' | sort > $@
+ $(Q)set -e; \
+ find $(CURDIR)/$(locale_DIR)/charmaps/ -name '*.pairs' | \
+ sort > $@.new; \
+ [ -s $@.new ]; \
+ cmp -s $@ $@.new && $(RM) $@.new || mv -f $@.new $@
endif
# the lines beginning w/ '#-' are mandatory
# at least one conversion is needed (euro/cyrillic)
$(locale_OUT)/locales.txt: $(locale_DIR)/LOCALES
+ @$(disp_gen)
ifeq ($(UCLIBC_BUILD_MINIMAL_LOCALE),y)
- echo "@euro e" > $@ ; \
- echo "#-" >> $@ ; \
- echo "UTF-8 yes" >> $@ ; \
- echo "8-BIT yes" >> $@ ; \
- echo "#-" >> $@ ; \
- echo "en_US.UTF-8 UTF-8" >> $@ ; \
- echo "en_US ISO-8859-1" >> $@
+ $(Q)echo "@euro e" > $@
+ $(Q)echo "#-" >> $@
+ $(Q)echo "UTF-8 yes" >> $@
+ $(Q)echo "8-BIT yes" >> $@
+ $(Q)echo "#-" >> $@
+ $(Q)for locale in $(call qstrip,$(UCLIBC_BUILD_MINIMAL_LOCALES)); do \
+ echo "$$locale.UTF-8 UTF-8"; \
+ echo "$$locale ISO-8859-1"; \
+ done >> $@
else
- cp $< $@
+ $(Q)cat $< > $@
endif
endif
-$(locale_HOBJ): $(locale_OUT)/% : $(locale_DIR)/%.c | $(DEPH-locale)
+$(locale_DIR)/gen_collate.c: $(DEPH-gen_collate)
+$(locale_OUT)/gen_collate : $(locale_DIR)/gen_collate.c
$(hcompile.u)
-
-$(locale_OUT)/gen_locale : $(locale_DIR)/gen_locale.c | $(DEPH-locale) $(patsubst %,$(locale_OUT)/%,$(DEPH-gen_locale))
+$(locale_DIR)/gen_ldc.c: $(DEPH-gen_ldc)
+$(locale_OUT)/gen_ldc : $(locale_DIR)/gen_ldc.c
$(hcompile.u)
-
-$(locale_OUT)/gen_ldc : $(locale_DIR)/gen_ldc.c | $(DEPH-locale) $(patsubst %,$(locale_OUT)/%,$(DEPH-gen_ldc))
+$(locale_DIR)/gen_locale.c: $(DEPH-gen_locale)
+$(locale_OUT)/gen_locale : $(locale_DIR)/gen_locale.c
+ $(hcompile.u)
+$(locale_DIR)/gen_wc8bit.c: $(DEPH-gen_wc8bit)
+$(locale_OUT)/gen_wc8bit : $(locale_DIR)/gen_wc8bit.c
+ $(hcompile.u)
+$(locale_DIR)/gen_wctype.c: $(DEPH-gen_wctype)
+$(locale_OUT)/gen_wctype : $(locale_DIR)/gen_wctype.c
$(hcompile.u)
+ifneq ($(V),)
+ifeq ($(V),1)
+FLAG-locale-verbose := -v -v
+endif
+ifeq ($(V),2)
+FLAG-locale-verbose := -v
+endif
+endif
+
# code needs to be modified to support top_builddir in almost all apps that write directly to a file
# grep fopen *.c
$(locale_OUT)/c8tables.h: $(locale_OUT)/gen_wc8bit $(locale_OUT)/codesets.txt
- $< `cat $(word 2,$^)`
+ @$(disp_gen)
+ $(Q)$< `cat $(word 2,$^)` > $@
# Warning! Beware tr_TR toupper/tolower exceptions!
$(locale_OUT)/wctables.h: $(locale_OUT)/gen_wctype
- $< en_US
+ @$(disp_gen)
+ $(Q)for locale in $(call qstrip,$(UCLIBC_BUILD_MINIMAL_LOCALES)) en_US en_GB; do \
+ $< $(FLAG-locale-verbose) $$locale > $@ || \
+ $< $(FLAG-locale-verbose) $$locale.UTF-8 > $@ || \
+ $< $(FLAG-locale-verbose) $$locale.iso8859-1 > $@ && break; \
+ done
$(locale_OUT)/locale_tables.h: $(locale_OUT)/gen_locale $(locale_OUT)/locales.txt
- $< $(word 2,$^)
+ @$(disp_gen)
+ $(Q)$< $(FLAG-locale-verbose) -o $@ $(word 2,$^)
$(locale_OUT)/lt_defines.h: $(locale_OUT)/locale_tables.h $(locale_OUT)/locale_collate.h
- grep "^#define" $< > $@
- grep "^#define __lc" $(word 2,$^) >> $@
+ @$(disp_gen)
+ $(Q)grep "^#define" $< > $@
+ $(Q)grep "^#define __lc" $(word 2,$^) >> $@
$(locale_OUT)/locale_collate.h: $(locale_OUT)/gen_collate $(locale_OUT)/locale_tables.h
- grep COL_IDX_ $(word 2,$^) | sed -e "s/^.*COL_IDX_\([^, ]*\).*$$/\1/" | \
- sort | uniq | xargs $<
-
-$(locale_OUT)/$(LOCALE_DATA_FILENAME):
-ifeq ($(UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA),y)
- ( cd $(dir $@); $(WGET) http://www.uclibc.org/downloads/$(notdir $@) )
-endif
-
-ifeq ($(UCLIBC_PREGENERATED_LOCALE_DATA),y)
+ @$(disp_gen)
+ $(Q)grep COL_IDX_ $(word 2,$^) | \
+ $(SED) -e "s/^.*COL_IDX_\([^, ]*\).*$$/\1/" | sort | uniq | \
+ xargs $< $(locale_DIR)/collation $(FLAG-locale-verbose) -o $@
-$(locale_SRC): $(locale_OUT)/$(LOCALE_DATA_FILENAME)
- zcat $< | tar -xv -C $(dir $@) -f -
- touch $@
- # we use the one in locale_DIR
- #$(RM) $(locale_OUT)/locale_mmap.h
-
-# for arch specific versions we have to at least overwrite lt_defines.h/locale_data.c/uClibc_locale_data.h
-
-$(locale_OUT)/uClibc_locale_data.h: $(locale_SRC)
-
-else
-
-$(locale_SRC): $(locale_OUT)/gen_ldc
- $<
+$(locale_SRC): $(locale_OUT)/gen_ldc $(locale_OUT)/lt_defines.h
+ @$(disp_gen)
+ $(Q)$< $@
$(locale_OUT)/uClibc_locale_data.h: $(locale_OUT)/lt_defines.h $(locale_OUT)/c8tables.h $(locale_OUT)/wctables.h $(locale_DIR)/locale_mmap.h | $(locale_SRC)
- grep -v "define __LC" $< > $@
- cat $(wordlist 2,4,$^) >> $@
-
-endif
+ @$(disp_gen)
+ $(Q)grep -v "define __LC" $< > $@
+ $(Q)cat $(wordlist 2,4,$^) >> $@
$(top_builddir)include/bits/uClibc_locale_data.h: $(locale_OUT)/uClibc_locale_data.h | $(top_builddir)include/bits/uClibc_config.h
- cat $< | awk 'BEGIN{i=1}{ if ( /WANT_/ ) i = /endif/ ; else if (i) print $0 }' > $@
+ @$(disp_gen)
+ $(Q)$(AWK) 'BEGIN{i=1}{if (/WANT_/) i=/endif/;else if (i) print $0}' \
+ $< > $@
-objclean-y += locale_clean
+objclean-y += CLEAN_extra/locale
# lmmtolso.c/gen_mmap.c/tst-*.c not used
-locale_clean:
- $(RM) $(locale_HOBJ) $(locale_SRC) $(locale_OUT)/{*.{o,os,txt},gen_locale,gen_ldc}
- $(RM) $(locale_OUT)/{uClibc_locale_data,lt_defines,c8tables,wctables,locale_tables,locale_collate}.h
- $(RM) $(locale_OUT)/{lmmtolso,gen_mmap,locale.mmap}
+CLEAN_extra/locale:
+ $(do_rm) $(locale_HOBJ) $(locale_SRC) $(addprefix $(locale_OUT)/*., o os txt) \
+ $(addprefix $(locale_OUT)/,$(addsuffix .h,uClibc_locale_data lt_defines c8tables wctables locale_tables locale_collate) lmmtolso gen_mmap locale.mmap)
diff --git a/extra/locale/gen_collate.c b/extra/locale/gen_collate.c
index 77dc5ff9e..15582c1ba 100644
--- a/extra/locale/gen_collate.c
+++ b/extra/locale/gen_collate.c
@@ -1,3 +1,12 @@
+/*
+ * Usage:
+ * gen_collate <INPUTDIR> [-o OUTPUTFILE] LOCALE ...
+ *
+ * Generate collation data from locales LOCALE.
+ * Reads all LOCALE from INPUTDIR and writes collation data to OUTPUTFILE.
+ *
+ * The output file defaults to "locales_collate.h".
+ */
/* TODO:
*
* add UNDEFINED at end if not specified
@@ -24,6 +33,7 @@
#include <limits.h>
#include <ctype.h>
#include <assert.h>
+#include <errno.h>
#include <search.h>
typedef struct {
@@ -253,6 +263,14 @@ static void *root_sym = NULL;
static size_t num_sym = 0;
static size_t mem_sym = 0;
+static const char *inputdir;
+static size_t inputdir_len;
+static unsigned verbose = 0;
+enum {
+ VINFO = (1<<0),
+ VDETAIL = (1<<1),
+};
+
static void error_msg(const char *fmt, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
static void *xmalloc(size_t n);
static char *xsymdup(const char *s); /* only allocate once... store in a tree */
@@ -294,6 +312,18 @@ enum {
DT_RANGE = 0x10,
};
+static int verbose_msg(const unsigned lvl, const char *fmt, ...)
+{
+ va_list arg;
+ int ret = 0;
+
+ if (verbose & lvl) {
+ va_start(arg, fmt);
+ ret = vfprintf(stderr, fmt, arg);
+ va_end(arg);
+ }
+ return ret;
+}
static section_t *new_section(const char *name)
{
section_t *p;
@@ -310,7 +340,7 @@ static section_t *new_section(const char *name)
++anonsection;
}
#warning devel code
-/* fprintf(stderr, "section %s\n", name); */
+/* verbose_msg(VDETAIL, "section %s\n", name); */
p->name = xsymdup(name);
p->itm_list = NULL;
p->num_items = 0;
@@ -328,7 +358,7 @@ static section_t *new_section(const char *name)
p->rules[3] |= R_POSITION;
cur_rule[3] |= R_POSITION;
}
-/* fprintf(stderr, "new section %s -- cur_num_weights = %d\n", p->name, cur_num_weights); */
+/* verbose_msg(VDETAIL, "new section %s -- cur_num_weights = %d\n", p->name, cur_num_weights); */
return p;
}
@@ -379,7 +409,7 @@ static void do_unrecognized(void)
#if 1
error_msg("warning: unrecognized: %s", pos);
#else
-/* fprintf(stderr, "warning: unrecognized initial keyword \"%s\"\n", pos); */
+/* verbose_msg(VDETAIL, "warning: unrecognized initial keyword \"%s\"\n", pos); */
fprintf(stderr, "warning: unrecognized: %s", pos);
if (end_of_token) {
fprintf(stderr, "%c%s", end_of_token, pos_e+1);
@@ -587,10 +617,10 @@ static void add_superset_weight(char *t)
lli = new_ll_item(DT_REORDER, cur_section);
lli->prev = lli->next = lli;
insque(lli, comm_prev_ptr);
-/* fprintf(stderr, " subsection -----------------------\n"); */
+/* verbose_msg(VDETAIL, " subsection -----------------------\n"); */
}
-/* fprintf(stderr, " %s %s\n", t, ((weighted_item_t *)(comm_cur_ptr->data))->symbol); */
+/* verbose_msg(VDETAIL, " %s %s\n", t, ((weighted_item_t *)(comm_cur_ptr->data))->symbol); */
wi = add_weight(t);
lli = new_ll_item(DT_WEIGHTED, wi);
mark_reordered(wi->symbol);
@@ -745,7 +775,7 @@ static void processfile(void)
}
if (cur_base == cur_col) {
- fprintf(stderr, "Base: %15s", cur_col->name);
+ verbose_msg(VDETAIL, "Base: %15s", cur_col->name);
} else {
#if 1
if (!cur_col->undefined_idx) {
@@ -794,20 +824,21 @@ static void processfile(void)
}
#endif
- fprintf(stderr, " Der: %15s", cur_col->name);
+ verbose_msg(VDETAIL, " Der: %15s", cur_col->name);
}
{
+#if 0
ll_item_t *p = cur_col->section_list;
-
- fprintf(stderr, "%6u weights", tnumnodes(cur_col->root_wi_index));
+#endif
+ verbose_msg(VDETAIL, "%6u weights", tnumnodes(cur_col->root_wi_index));
if (cur_base) {
- fprintf(stderr, " %6u der %6u reor %6u starter - %u new stubs",
+ verbose_msg(VDETAIL, " %6u der %6u reor %6u starter - %u new stubs",
tnumnodes(cur_base->root_derived_wi),
tnumnodes(cur_base->root_wi_index_reordered),
tnumnodes(cur_base->root_starter_char),
ll_count(cur_col->section_list, DT_REORDER));
}
- fprintf(stderr, "\n");
+ verbose_msg(VDETAIL, "\n");
#if 0
while (p) {
@@ -826,7 +857,7 @@ static void processfile(void)
if ((*((section_t *)(p->data))->name != 'a')
|| (((section_t *)(p->data))->num_items > 0)
) {
- fprintf(stderr,
+ verbose_msg(VDETAIL,
/* "\t%-15s %zu\n", */
"\t%-15s %6u\n",
((section_t *)(p->data))->name,
@@ -1089,18 +1120,35 @@ int main(int argc, char **argv)
ll_item_t *lli;
int i;
int total;
+ char *output_file = "locale_collate.h";
+ unsigned verbosity = 0;
- if (argc < 2) {
+ if (argc < 3) {
return EXIT_FAILURE;
}
-
+ --argc;
+ inputdir = strdup(*++argv);
+ inputdir_len = strlen(inputdir);
init_locale_list();
while (--argc) {
- p = (const deps_t *) bsearch(*++argv, deps, sizeof(deps)/sizeof(deps[0]), sizeof(deps[0]), dep_cmp);
+ ++argv;
+ if (!strcmp(*argv, "-o")) {
+ --argc;
+ if (*++argv == NULL) {
+ printf("-o <outfile> requires an argument\n");
+ return EXIT_FAILURE;
+ }
+ output_file = strdup(*argv);
+ continue;
+ } else if (!strcmp(*argv, "-v")) {
+ verbosity++;
+ continue;
+ }
+ p = (const deps_t *) bsearch(*argv, deps, sizeof(deps)/sizeof(deps[0]), sizeof(deps[0]), dep_cmp);
if (!p) {
if (!strcmp("C", *argv)) {
- printf("ignoring C locale\n");
+ printf("ignoring %s locale\n", *argv);
continue;
} else {
printf("%s not found\n", *argv);
@@ -1125,10 +1173,10 @@ int main(int argc, char **argv)
total = 0;
for (i=0 ; i < BASE_MAX ; i++) {
-/* printf("der_count[%2d] = %3d\n", i, der_count[i]); */
+/* printf("der_count[%2d] = %3d\n", i, der_count[i]); */
total += der_count[i];
}
-/* printf("total = %d\n", total); */
+/* printf("total = %d\n", total); */
new_args[new_arg_count++] = "dummyprogramname";
for (i=0 ; i < BASE_MAX ; i++) {
@@ -1143,11 +1191,16 @@ int main(int argc, char **argv)
} while (lli != locale_list[i]);
new_args[new_arg_count++] = "-f";
}
+ for (i=0; i < verbosity; i++)
+ new_args[new_arg_count++] = "-v";
-/* for (i=0 ; i < new_arg_count ; i++) { */
-/* printf("%3d: %s\n", i, new_args[i]); */
-/* } */
-
+ new_args[new_arg_count++] = "-o";
+ new_args[new_arg_count++] = output_file;
+/*
+ for (i=0 ; i < new_arg_count ; i++) {
+ printf("%3d: %s\n", i, new_args[i]);
+ }
+*/
return old_main(new_arg_count, (char **) new_args);
}
@@ -1158,6 +1211,7 @@ static int old_main(int argc, char **argv)
{
int next_is_base = 0;
int next_is_subset = 0;
+ char *output_file = NULL;
superset = 0;
@@ -1185,6 +1239,11 @@ static int old_main(int argc, char **argv)
next_is_subset = 0;
next_is_base = 2;
superset = 0;
+ } else if (((*argv)[1] == 'o') && !(*argv)[2]) { /* output file */
+ --argc;
+ output_file = *++argv;
+ } else if (((*argv)[1] == 'v') && !(*argv)[2]) { /* verbose */
+ ++verbose;
} else {
error_msg("unrecognized option %s", *argv);
}
@@ -1198,7 +1257,7 @@ static int old_main(int argc, char **argv)
cur_derived = cur_col;
}
pushfile(*argv);
-/* fprintf(stderr, "processing file %s\n", *argv); */
+/* verbose_msg(VDETAIL, "processing file %s\n", *argv); */
processfile(); /* this does a popfile */
/* twalk(cur_col->root_colitem, print_colnode); */
@@ -1212,17 +1271,17 @@ static int old_main(int argc, char **argv)
}
}
- fprintf(stderr, "success!\n");
- fprintf(stderr,
+ verbose_msg(VINFO, "success!\n");
+ verbose_msg(VINFO,
/* "num_sym=%zu mem_sym=%zu unique_weights=%zu\n", */
"num_sym=%u mem_sym=%u unique_weights=%u\n",
num_sym, mem_sym, unique_weights);
/* twalk(root_weight, print_weight_node); */
- fprintf(stderr, "num base locales = %d num derived locales = %d\n",
+ verbose_msg(VINFO, "num base locales = %d num derived locales = %d\n",
base_locale_len, der_locale_len);
- fprintf(stderr,
+ verbose_msg(VINFO,
"override_len = %d multistart_len = %d weightstr_len = %d\n"
"wcs2colidt_len = %d index2weight_len = %d index2ruleidx_len = %d\n"
"ruletable_len = %d\n"
@@ -1250,10 +1309,10 @@ static int old_main(int argc, char **argv)
#endif
{
- FILE *fp = fopen("locale_collate.h", "w");
+ FILE *fp = fopen(output_file, "w");
if (!fp) {
- error_msg("couldn't open output file!");
+ error_msg("cannot open output file '%s'!", output_file);
}
dump_collate(fp);
if (ferror(fp) || fclose(fp)) {
@@ -1282,20 +1341,23 @@ static void error_msg(const char *fmt, ...)
static void pushfile(char *filename)
{
- static char fbuf[PATH_MAX];
-
- snprintf(fbuf, PATH_MAX, "collation/%s", filename);
+ char *inputfile;
+ size_t inputfile_len;
if (fno >= MAX_FNO) {
error_msg("file stack size exceeded");
}
- if (!(fstack[++fno] = fopen(fbuf, "r"))) {
+ inputfile_len = inputdir_len + strlen(filename) + 2;
+ inputfile = xmalloc(inputfile_len);
+ memset(inputfile, 0, inputfile_len);
+ sprintf(inputfile, "%s/%s", inputdir, filename);
+ if (!(fstack[++fno] = fopen(inputfile, "r"))) {
--fno; /* oops */
- error_msg("cannot open file %s", fbuf);
+ error_msg("cannot open file %s: %s", inputfile, strerror(errno));
}
- fname[fno] = xsymdup(filename);
+ fname[fno] = xsymdup(inputfile);
lineno[fno] = 0;
}
@@ -1452,11 +1514,11 @@ static void do_copy(void)
*e = 0;
++s;
if (cur_base && !strcmp(cur_base->name,s)) {
-/* fprintf(stderr, "skipping copy of base file %s\n", s); */
+/* verbose_msg(VDETAIL, "skipping copy of base file %s\n", s); */
#warning need to update last in order and position or check
return;
}
-/* fprintf(stderr, "full copy of %s\n", s); */
+/* verbose_msg(VDETAIL, "full copy of %s\n", s); */
pushfile(s);
return;
}
@@ -1541,7 +1603,7 @@ static ll_item_t *find_section_list_item(const char *name, col_locale_t *loc)
while (p) {
#warning devel code
/* if (!((p->data_type == DT_SECTION) || (p->data_type == DT_REORDER))) { */
-/* fprintf(stderr, "fsli = %d\n", p->data_type); */
+/* verbose_msg(VDETAIL, "fsli = %d\n", p->data_type); */
/* } */
assert((p->data_type == DT_SECTION) || (p->data_type == DT_REORDER));
if (!strcmp(name, ((section_t *)(p->data))->name)) {
@@ -1685,11 +1747,11 @@ static void add_colitem(char *item, char *def)
#warning devel code
if (superset) {
if (tfind(p, &cur_base->root_colitem, colitem_cmp)) {
-/* fprintf(stderr, "skipping superset duplicate collating item \"%s\"\n", p->string); */
+/* verbose_msg(VDETAIL, "skipping superset duplicate collating item \"%s\"\n", p->string); */
del_colitem(p);
return;
/* } else { */
-/* fprintf(stderr, "superset: new collating item \"%s\" = %s\n", p->string, p->element); */
+/* verbose_msg(VDETAIL, "superset: new collating item \"%s\" = %s\n", p->string, p->element); */
}
}
@@ -1850,7 +1912,7 @@ static void do_order_start(void)
cur_section = sect;
-/* fprintf(stderr, "setting cur_num_weights to %d for %s\n", sect->num_rules, sect->name); */
+/* verbose_msg(VDETAIL, "setting cur_num_weights to %d for %s\n", sect->num_rules, sect->name); */
cur_num_weights = sect->num_rules;
memcpy(cur_rule, sect->rules, MAX_COLLATION_WEIGHTS);
}
@@ -1923,7 +1985,7 @@ static void do_reorder_after(void)
insque(l1, l2);
l3 = find_ll_last(cur_col->section_list);
- fprintf(stderr, "reorder_after %p %p %p %s\n", l1, l2, l3, cur_section->name);
+ verbose_msg(VDETAIL, "reorder_after %p %p %p %s\n", l1, l2, l3, cur_section->name);
}
#else
insque(new_ll_item(DT_REORDER, cur_section), find_ll_last(cur_col->section_list));
@@ -1935,7 +1997,7 @@ static void do_reorder_after(void)
#warning devel code
-/* fprintf(stderr, "reorder -- %s %d\n", ((weighted_item_t *)(lli->data))->symbol, w->num_weights); */
+/* verbose_msg(VDETAIL, "reorder -- %s %d\n", ((weighted_item_t *)(lli->data))->symbol, w->num_weights); */
#warning hack to get around hu_HU reorder-after problem
/* if (!w->num_weights) { */
@@ -1945,7 +2007,7 @@ static void do_reorder_after(void)
/* memcpy(cur_rule, w->rule, MAX_COLLATION_WEIGHTS); */
/* } */
-/* fprintf(stderr, "reorder_after succeeded for %s\n", t); */
+/* verbose_msg(VDETAIL, "reorder_after succeeded for %s\n", t); */
}
static void do_reorder_end(void)
@@ -1986,9 +2048,9 @@ static void do_reorder_sections_after(void)
lli = cur_base->section_list;
do {
-/* fprintf(stderr, "hmm -- |%s|%d|\n", ((section_t *)(lli->data))->name, lli->data_type); */
+/* verbose_msg(VDETAIL, "hmm -- |%s|%d|\n", ((section_t *)(lli->data))->name, lli->data_type); */
if (lli->data_type & DT_SECTION) {
-/* fprintf(stderr, "checking |%s|%s|\n", ((section_t *)(lli->data))->name, t); */
+/* verbose_msg(VDETAIL, "checking |%s|%s|\n", ((section_t *)(lli->data))->name, t); */
if (!strcmp(((section_t *)(lli->data))->name, t)) {
reorder_section_ptr = lli;
return;
@@ -2025,7 +2087,7 @@ static ll_item_t *new_ll_item(int data_type, void *data)
static int sym_cmp(const void *n1, const void *n2)
{
-/* fprintf(stderr, "sym_cmp: |%s| |%s|\n", (const char *)n1, (const char *)n2); */
+/* verbose_msg(VDETAIL, "sym_cmp: |%s| |%s|\n", (const char *)n1, (const char *)n2); */
return strcmp((const char *) n1, (const char *) n2);
}
@@ -2039,9 +2101,9 @@ static char *xsymdup(const char *s)
}
++num_sym;
mem_sym += strlen(s) + 1;
-/* fprintf(stderr, "xsymdup: alloc |%s| %p |%s| %p\n", *(char **)p, p, s, s); */
+/* verbose_msg(VDETAIL, "xsymdup: alloc |%s| %p |%s| %p\n", *(char **)p, p, s, s); */
/* } else { */
-/* fprintf(stderr, "xsymdup: found |%s| %p\n", *(char **)p, p); */
+/* verbose_msg(VDETAIL, "xsymdup: found |%s| %p\n", *(char **)p, p); */
}
return *(char **) p;
}
@@ -2079,7 +2141,7 @@ static weight_t *register_weight(weight_t *w)
}
++unique_weights;
/* } else { */
-/* fprintf(stderr, "rw: found\n"); */
+/* verbose_msg(VDETAIL, "rw: found\n"); */
}
return *(weight_t **)p;
}
@@ -2200,7 +2262,7 @@ static void add_final_col_index(const char *s)
ci.element = NULL; /* don't care */
v = tfind(&ci, &cur_base->root_colitem, colitem_cmp);
if (!v) {
- fprintf(stderr, "%s NOT DEFINED!!!\n", s);
+ verbose_msg(VDETAIL, "%s NOT DEFINED!!!\n", s);
} else {
p = *((colitem_t **) v);
if (p->element != NULL) {
@@ -2347,11 +2409,11 @@ static ll_item_t *init_comm_ptr(void)
#warning devel code
/* { */
/* ll_item_t *p = comm_cur_ptr; */
-/* fprintf(stderr, "init_comm_ptr\n"); */
+/* verbose_msg(VDETAIL, "init_comm_ptr\n"); */
/* while (p != comm_cur_ptr) { */
/* if (p->data_type & DT_WEIGHTED) { */
-/* fprintf(stderr, "%s", ((weighted_item_t *)p)->symbol); */
+/* verbose_msg(VDETAIL, "%s", ((weighted_item_t *)p)->symbol); */
/* } */
/* p = p->next; */
/* } */
@@ -2359,7 +2421,7 @@ static ll_item_t *init_comm_ptr(void)
assert(comm_cur_ptr);
-/* fprintf(stderr, "init_comm_ptr -- %s %p %p %p %d\n", */
+/* verbose_msg(VDETAIL, "init_comm_ptr -- %s %p %p %p %d\n", */
/* ((weighted_item_t *)(comm_cur_ptr->data))->symbol, */
/* comm_cur_ptr, comm_cur_ptr->prev, comm_cur_ptr->next, */
/* ll_len(comm_cur_ptr)); */
@@ -2625,7 +2687,7 @@ static void finalize_base(void)
for (s = cur_base->section_list ; s ; s = s->next) {
#if 1
if (s->data_type & DT_REORDER) { /* a reordered section */
- fprintf(stderr, "pass1: reordered section %s - xxx\n", ((section_t *)(s->data))->name);
+ verbose_msg(VDETAIL, "pass1: reordered section %s - xxx\n", ((section_t *)(s->data))->name);
lli = ((section_t *)(s->data))->itm_list;
r = 0;
if (lli) {
@@ -2635,7 +2697,7 @@ static void finalize_base(void)
if (r > mr) {
mr = r;
}
- fprintf(stderr, "pass1: reordered section %s - %d\n", ((section_t *)(s->data))->name, r);
+ verbose_msg(VDETAIL, "pass1: reordered section %s - %d\n", ((section_t *)(s->data))->name, r);
continue;
}
#endif
@@ -2652,11 +2714,11 @@ static void finalize_base(void)
lli->idx = i;
assert(!rli);
rli = lli;
- fprintf(stderr, "range pre = %d after = ", i);
+ verbose_msg(VDETAIL, "range pre = %d after = ", i);
i += ((range_item_t *)(lli->data))->length + 1;
#warning check ko_kR and 9
/* ++i; */
- fprintf(stderr, "%d\n", i);
+ verbose_msg(VDETAIL, "%d\n", i);
if (!index2weight_len_inc) { /* ko_KR hack */
final_index += ((range_item_t *)(lli->data))->length + 1;
}
@@ -2726,7 +2788,7 @@ static void finalize_base(void)
/* cur_base->name, lli->idx, final_index_val(w->symbol), w->symbol); */
} else {
-/* fprintf(stderr, "section: %s %d %d\n", ((section_t *)(s->data))->name, */
+/* verbose_msg(VDETAIL, "section: %s %d %d\n", ((section_t *)(s->data))->name, */
/* s->data_type, lli->data_type); */
/* assert(!(s->data_type & DT_REORDER)); */
/* assert(lli->data_type & DT_REORDER); */
@@ -2772,7 +2834,7 @@ static void finalize_base(void)
mr = mi;
for (cli = cur_base->derived_list ; cli ; cli = cli->next) {
cl = (col_locale_t *)(cli->data);
-/* fprintf(stderr, "pass3: %d %s\n", cli->data_type, cl->name); */
+/* verbose_msg(VDETAIL, "pass3: %d %s\n", cli->data_type, cl->name); */
/* fprintf(stdout, "pass3: %d %s\n", cli->data_type, cl->name); */
@@ -2790,7 +2852,7 @@ static void finalize_base(void)
do {
assert(!(lli->data_type & DT_RANGE));
if (lli->data_type & DT_WEIGHTED) {
-/* fprintf(stderr, " %d %d %s\n", lli->data_type, lli->idx, ((weighted_item_t *)(lli->data))->symbol); */
+/* verbose_msg(VDETAIL, " %d %d %s\n", lli->data_type, lli->idx, ((weighted_item_t *)(lli->data))->symbol); */
add_final_col_index(((weighted_item_t *)(lli->data))->symbol);
if (s->data_type & DT_REORDER) {
continue;
@@ -2850,10 +2912,10 @@ static void finalize_base(void)
++wcs2index_count;
if ((tfind(buf, &cur_base->root_starter_char, sym_cmp)) != NULL) {
wcs2index[i] = ++starter_index;
-/* fprintf(stderr, "wcs2index[ %#06x ] = %d (starter)\n", i, wcs2index[i]); */
+/* verbose_msg(VDETAIL, "wcs2index[ %#06x ] = %d (starter)\n", i, wcs2index[i]); */
} else {
wcs2index[i] = (int)(p->data);
-/* fprintf(stderr, "wcs2index[ %#06x ] = %d\n", i, wcs2index[i]); */
+/* verbose_msg(VDETAIL, "wcs2index[ %#06x ] = %d\n", i, wcs2index[i]); */
}
} else {
if ((tfind(buf, &cur_base->root_starter_char, sym_cmp)) != NULL) {
@@ -2898,7 +2960,7 @@ static void finalize_base(void)
smallest = newopt(wcs2index, RANGE, n, &table);
assert(t == smallest);
wcs2colidt_len += smallest;
-/* fprintf(stderr, "smallest = %d wcs2colidt_len = %d\n", smallest, wcs2colidt_len); */
+/* verbose_msg(VDETAIL, "smallest = %d wcs2colidt_len = %d\n", smallest, wcs2colidt_len); */
#if 0
{
@@ -2919,15 +2981,15 @@ static void finalize_base(void)
u >>= __LOCALE_DATA_WCctype_II_SHIFT;
i0 = tbl->ii[u];
- fprintf(stderr, "i0 = %d\n", i0);
+ verbose_msg(VDETAIL, "i0 = %d\n", i0);
i0 <<= __LOCALE_DATA_WCctype_II_SHIFT;
i1 = tbl->ii[__LOCALE_DATA_WCctype_II_LEN + i0 + n];
/* i1 = tbl->ti[i0 + n]; */
- fprintf(stderr, "i1 = %d\n", i1);
+ verbose_msg(VDETAIL, "i1 = %d\n", i1);
i1 <<= __LOCALE_DATA_WCctype_TI_SHIFT;
/* return *(uint16_t *)(&(tbl->ii[__LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + i1 + sc])); */
- fprintf(stderr, "i2 = %d\n", __LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + i1 + sc);
- fprintf(stderr, "val = %d\n", tbl->ii[__LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + i1 + sc]);
+ verbose_msg(VDETAIL, "i2 = %d\n", __LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + i1 + sc);
+ verbose_msg(VDETAIL, "val = %d\n", tbl->ii[__LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + i1 + sc]);
/* return tbl->ut[i1 + sc]; */
@@ -2944,7 +3006,7 @@ static void finalize_base(void)
base_locale_array[base_locale_len].max_col_index = final_index;
base_locale_array[base_locale_len].max_weight = max_weight;
- fprintf(stderr, "%s: %6u invariant %6u varying %6u derived %6u total %6u max weight %6u wcs2\n",
+ verbose_msg(VDETAIL, "%s: %6u invariant %6u varying %6u derived %6u total %6u max weight %6u wcs2\n",
cur_base->name, num_invariant, num_varying,
tnumnodes(cur_base->root_derived_wi), final_index, max_weight,
wcs2index_count);
@@ -2960,7 +3022,7 @@ static void finalize_base(void)
for (s = cur_base->section_list ; s ; s = s->next) {
#if 1
if (s->data_type & DT_REORDER) {
- fprintf(stderr, "1: skipping reordered section %s\n", ((section_t *)(s->data))->name);
+ verbose_msg(VDETAIL, "1: skipping reordered section %s\n", ((section_t *)(s->data))->name);
continue;
}
#endif
@@ -2988,7 +3050,7 @@ static void finalize_base(void)
for (s = cur_base->section_list ; s ; s = s->next) {
#if 1
if (s->data_type & DT_REORDER) {
- fprintf(stderr, "2: skipping reordered section %s\n", ((section_t *)(s->data))->name);
+ verbose_msg(VDETAIL, "2: skipping reordered section %s\n", ((section_t *)(s->data))->name);
continue;
}
#endif
@@ -3015,7 +3077,7 @@ static void finalize_base(void)
do_starter_lists(cur_base);
-/* fprintf(stderr,"updated final_index = %d\n", final_index); */
+/* verbose_msg(VDETAIL,"updated final_index = %d\n", final_index); */
if (rli) {
base_locale_array[base_locale_len].range_low
@@ -3042,8 +3104,8 @@ static void finalize_base(void)
&& isupper(cur_base->name[4])
) {
- fprintf(stderr, "adding special derived for %s\n", cur_base->name);
-/* fprintf(stderr,"updated final_index = %d\n", final_index); */
+ verbose_msg(VDETAIL, "adding special derived for %s\n", cur_base->name);
+/* verbose_msg(VDETAIL,"updated final_index = %d\n", final_index); */
assert(der_locale_len+1 < DER_LOCALE_LEN);
@@ -3080,7 +3142,7 @@ static void finalize_base(void)
++der_locale_len;
} else {
- fprintf(stderr, "NOT adding special derived for %s\n", cur_base->name);
+ verbose_msg(VDETAIL, "NOT adding special derived for %s\n", cur_base->name);
}
/* now all the derived... */
@@ -3102,7 +3164,7 @@ static void finalize_base(void)
}
/* we do this in two passes... first all sequences, then all single reorders */
for (s = cl->section_list ; s ; s = s->next) {
-/* fprintf(stderr, "doing section %s\n", ((section_t *)(s->data))->name); */
+/* verbose_msg(VDETAIL, "doing section %s\n", ((section_t *)(s->data))->name); */
h = lli = ((section_t *)(s->data))->itm_list;
if (!lli) {
/* fprintf(stdout, "EMPTY ITEM LIST IN SECTION %s\n", ((section_t *)(s->data))->name ); */
@@ -3195,7 +3257,7 @@ static void finalize_base(void)
++base_locale_len;
/* if (tnumnodes(cur_base->root_starter_char)) { */
-/* fprintf(stderr, "starter nodes\n"); */
+/* verbose_msg(VDETAIL, "starter nodes\n"); */
/* twalk(cur_base->root_starter_char, print_starter_node); */
/* } */
}
@@ -3287,7 +3349,7 @@ static void process_starter_node(const void *ptr, VISIT order, int level)
if (++u16_starter < base_locale_array[base_locale_len].num_starters) {
u16_buf[u16_starter] = u16_buf_len;
}
-/* fprintf(stderr, "ucode - %d %d\n", u16_buf[u16_starter-1], u16_buf_len); */
+/* verbose_msg(VDETAIL, "ucode - %d %d\n", u16_buf[u16_starter-1], u16_buf_len); */
} else {
x.string = w->symbol;
x.element = NULL;
@@ -3299,7 +3361,7 @@ static void process_starter_node(const void *ptr, VISIT order, int level)
assert(u16_buf[u16_buf_len-1]);
assert(*s == '"');
n = is_ucode(++s);
-/* fprintf(stderr, "s is |%s| with len %d (%d)\n", s, strlen(s), n); */
+/* verbose_msg(VDETAIL, "s is |%s| with len %d (%d)\n", s, strlen(s), n); */
assert(n);
s += n;
while (*s != '"') {
@@ -3307,7 +3369,7 @@ static void process_starter_node(const void *ptr, VISIT order, int level)
assert(n);
strncpy(buf, s, n+1);
buf[n] = 0;
-/* fprintf(stderr, "buf is |%s| with len %d (%d)\n", buf, strlen(buf), n); */
+/* verbose_msg(VDETAIL, "buf is |%s| with len %d (%d)\n", buf, strlen(buf), n); */
u16_buf[u16_buf_len++] = final_index_val(buf);
assert(u16_buf[u16_buf_len-1]);
s += n;
@@ -3331,7 +3393,7 @@ static void complete_starter_node(const void *ptr, VISIT order, int level)
p = xmalloc(sizeof(weighted_item_t));
p->symbol = w.symbol;
p->weight = NULL;
-/* fprintf(stderr, "complete_starter_node: %s\n", *(const char **) ptr); */
+/* verbose_msg(VDETAIL, "complete_starter_node: %s\n", *(const char **) ptr); */
if (!tsearch(p, p_cl_root_starter_all, starter_all_cmp)) {
error_msg("OUT OF MEMORY");
}
@@ -3377,7 +3439,7 @@ static void do_starter_lists(col_locale_t *cl)
x.element = NULL;
p = tfind(&x, &cur_base->root_colitem, colitem_cmp);
if (!p) {
-/* fprintf(stderr, "Whoa... processing starters for %s and couldn't find %s\n", */
+/* verbose_msg(VDETAIL, "Whoa... processing starters for %s and couldn't find %s\n", */
/* cl->name, w->symbol); */
continue;
}
@@ -3426,13 +3488,13 @@ static void do_starter_lists(col_locale_t *cl)
u16_starter = 0;
u16_buf[0] = u16_buf_len = base_locale_array[base_locale_len].num_starters;
twalk(cl->root_starter_all, process_starter_node);
-/* fprintf(stderr, "s=%d n=%d\n", u16_starter, base_locale_array[base_locale_len].num_starters); */
+/* verbose_msg(VDETAIL, "s=%d n=%d\n", u16_starter, base_locale_array[base_locale_len].num_starters); */
assert(u16_starter == base_locale_array[base_locale_len].num_starters);
#if 0
{ int i;
for (i=0 ; i < u16_buf_len ; i++) {
- fprintf(stderr, "starter %2d: %d - %#06x\n", i, u16_buf[i], u16_buf[i]);
+ verbose_msg(VDETAIL, "starter %2d: %d - %#06x\n", i, u16_buf[i], u16_buf[i]);
}}
#endif
@@ -3451,7 +3513,7 @@ static void do_starter_lists(col_locale_t *cl)
der_locale_array[der_locale_len].multistart_offset = multistart_len;
}
multistart_len += u16_buf_len;
-/* fprintf(stderr, "%s: multistart_len = %d u16_buf_len = %d\n", cl->name, multistart_len, u16_buf_len); */
+/* verbose_msg(VDETAIL, "%s: multistart_len = %d u16_buf_len = %d\n", cl->name, multistart_len, u16_buf_len); */
} else if (!(u16_buf_len > multistart_len)) {
assert(mm);
if (cl == cur_base) {
@@ -3459,7 +3521,7 @@ static void do_starter_lists(col_locale_t *cl)
} else {
der_locale_array[der_locale_len].multistart_offset = ((uint16_t *)(mm)) - multistart_buffer;
}
-/* fprintf(stderr, "%s: memmem found a match with u16_buf_len = %d\n", cl->name, u16_buf_len); */
+/* verbose_msg(VDETAIL, "%s: memmem found a match with u16_buf_len = %d\n", cl->name, u16_buf_len); */
}
} else {
assert(!base_locale_array[base_locale_len].num_starters);
@@ -3931,5 +3993,5 @@ static void dump_collate(FILE *fp)
fprintf(fp,"}; /* %8lu */\n", collate_pos);
- fprintf(fp,"#define __lc_collate_data_LEN %d\n\n", collate_pos);
+ fprintf(fp,"#define __lc_collate_data_LEN %lu\n\n", collate_pos);
}
diff --git a/extra/locale/gen_ldc.c b/extra/locale/gen_ldc.c
index 2a121610e..2cedbddaf 100644
--- a/extra/locale/gen_ldc.c
+++ b/extra/locale/gen_ldc.c
@@ -148,8 +148,9 @@ void out_size_t(FILE *f, const size_t *p, size_t n, char *comment)
}
-int main(void)
+int main(int argc, char **argv)
{
+ char *output_file = "locale_data.c";
FILE *lso; /* static object */
int i;
#ifdef __LOCALE_DATA_MAGIC_SIZE
@@ -158,8 +159,10 @@ int main(void)
memset(magic, 0, __LOCALE_DATA_MAGIC_SIZE);
#endif /* __LOCALE_DATA_MAGIC_SIZE */
- if (!(lso = fopen("locale_data.c", "w"))) {
- printf("can't open locale_data.c!\n");
+ if (argc == 2)
+ output_file = argv[1];
+ if (!(lso = fopen(output_file, "w"))) {
+ printf("cannot open output file '%s'!\n", output_file);
return EXIT_FAILURE;
}
diff --git a/extra/locale/gen_locale.c b/extra/locale/gen_locale.c
index 31df4156e..5e8936082 100644
--- a/extra/locale/gen_locale.c
+++ b/extra/locale/gen_locale.c
@@ -4,6 +4,7 @@
#include <ctype.h>
#include <limits.h>
#include <assert.h>
+#include <stdarg.h>
#include <locale.h>
#include <langinfo.h>
#include <nl_types.h>
@@ -15,7 +16,7 @@
#define __LOCALE_DATA_CATEGORIES 6
/* must agree with ordering of gen_mmap! */
-static const unsigned char *lc_names[] = {
+static const char *lc_names[] = {
"LC_CTYPE",
"LC_NUMERIC",
"LC_MONETARY",
@@ -89,6 +90,41 @@ static int default_8bit;
static int total_size;
static int null_count;
+static unsigned verbose = 0;
+enum {
+ VINFO = (1<<0),
+ VDETAIL = (1<<1),
+};
+static int verbose_msg(const unsigned lvl, const char *fmt, ...)
+{
+ va_list arg;
+ int ret = 0;
+
+ if (verbose & lvl) {
+ va_start(arg, fmt);
+ ret = vfprintf(stderr, fmt, arg);
+ va_end(arg);
+ }
+ return ret;
+}
+
+static void error_msg(const char *fmt, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
+static void error_msg(const char *fmt, ...)
+{
+ va_list arg;
+
+ fprintf(stderr, "Error: ");
+/* if (fno >= 0) {
+ fprintf(stderr, "file %s (%d): ", fname[fno], lineno[fno]);
+ } */
+ va_start(arg, fmt);
+ vfprintf(stderr, fmt, arg);
+ va_end(arg);
+ fprintf(stderr, "\n");
+
+ exit(EXIT_FAILURE);
+}
+
static void do_locale_names(void)
{
/* "C" locale name is handled specially by the setlocale code. */
@@ -96,8 +132,7 @@ static void do_locale_names(void)
int i;
if (num_locales <= 1) {
-/* printf("error - only C locale?\n"); */
-/* exit(EXIT_FAILURE); */
+/* error_msg("only C locale?"); */
fprintf(ofp, "static const unsigned char __locales[%d];\n", (3 + __LOCALE_DATA_CATEGORIES));
fprintf(ofp, "static const unsigned char __locale_names5[5];\n");
} else {
@@ -131,8 +166,7 @@ static void do_locale_names(void)
} else if (!strcmp(locales[i].glibc_name, "C")) {
fprintf(ofp, "COL_IDX_C , ");
} else {
- printf("don't know how to handle COL_IDX_ for %s\n", locales[i].glibc_name);
- exit(EXIT_FAILURE);
+ error_msg("don't know how to handle COL_IDX_ for %s", locales[i].glibc_name);
}
#else
fprintf(ofp, "%#4x, ", 0); /* place holder for lc_collate */
@@ -196,8 +230,7 @@ static void do_locale_names(void)
}
}
if (pos[__LOCALE_DATA_CATEGORIES-1] > 255) {
- printf("error - lc_names is too big (%d)\n", pos[__LOCALE_DATA_CATEGORIES-1]);
- exit(EXIT_FAILURE);
+ error_msg("lc_names is too big (%d)", pos[__LOCALE_DATA_CATEGORIES-1]);
}
fprintf(ofp, "#define __LC_ALL\t\t%d\n\n", i);
@@ -218,7 +251,7 @@ static void do_locale_names(void)
fprintf(ofp, ";\n\n");
}
- printf("locale data = %d name data = %d for %d uniq\n",
+ verbose_msg(VDETAIL,"locale data = %d name data = %d for %d uniq\n",
num_locales * (3 + __LOCALE_DATA_CATEGORIES), uniq * 5, uniq);
total_size += num_locales * (3 + __LOCALE_DATA_CATEGORIES) + uniq * 5;
@@ -236,8 +269,7 @@ static void read_at_mappings(void)
if (!(p = strtok(line_buf, " \t\n")) || (*p == '#')) {
if (!fgets(line_buf, sizeof(line_buf), fp)) {
if (ferror(fp)) {
- printf("error reading file\n");
- exit(EXIT_FAILURE);
+ error_msg("reading file");
}
return; /* EOF */
}
@@ -248,17 +280,14 @@ static void read_at_mappings(void)
}
if (*p == '@') {
if (p[1] == 0) {
- printf("error: missing @modifier name\n");
- exit(EXIT_FAILURE);
+ error_msg("missing @modifier name");
}
m = p; /* save the modifier name */
if (!(p = strtok(NULL, " \t\n")) || p[1] || (((unsigned char) *p) > 0x7f)) {
- printf("error: missing or illegal @modifier mapping char\n");
- exit(EXIT_FAILURE);
+ error_msg("missing or illegal @modifier mapping char");
}
if (at_mappings[(int)((unsigned char) *p)]) {
- printf("error: reused @modifier mapping char\n");
- exit(EXIT_FAILURE);
+ error_msg("reused @modifier mapping char");
}
at_mappings[(int)((unsigned char) *p)] = 1;
at_mapto[mc] = *p;
@@ -267,10 +296,10 @@ static void read_at_mappings(void)
strcpy(++at_strings_end, m+1);
at_strings_end += (unsigned char) at_strings_end[-1];
- printf("@mapping: \"%s\" to '%c'\n", m, *p);
+ verbose_msg(VDETAIL,"@mapping: \"%s\" to '%c'\n", m, *p);
if (((p = strtok(NULL, " \t\n")) != NULL) && (*p != '#')) {
- printf("ignoring trailing text: %s...\n", p);
+ fprintf(stderr,"ignoring trailing text: %s...\n", p);
}
*line_buf = 0;
continue;
@@ -283,12 +312,12 @@ static void read_at_mappings(void)
p = at_strings;
if (!*p) {
- printf("no @ strings\n");
+ verbose_msg(VDETAIL,"no @ strings\n");
return;
}
do {
- printf("%s\n", p+1);
+ verbose_msg(VDETAIL,"%s\n", p+1);
p += 1 + (unsigned char) *p;
} while (*p);
}
@@ -303,8 +332,7 @@ static void read_enable_disable(void)
if (!(p = strtok(line_buf, " =\t\n")) || (*p == '#')) {
if (!fgets(line_buf, sizeof(line_buf), fp)) {
if (ferror(fp)) {
- printf("error reading file\n");
- exit(EXIT_FAILURE);
+ error_msg("reading file");
}
return; /* EOF */
}
@@ -316,25 +344,23 @@ static void read_enable_disable(void)
if (!strcmp(p, "UTF-8")) {
if (!(p = strtok(NULL, " =\t\n"))
|| ((toupper(*p) != 'Y') && (toupper(*p) != 'N'))) {
- printf("error: missing or illegal UTF-8 setting\n");
- exit(EXIT_FAILURE);
+ error_msg("missing or illegal UTF-8 setting");
}
default_utf8 = (toupper(*p) == 'Y');
- printf("UTF-8 locales are %sabled\n", "dis\0en"+ (default_utf8 << 2));
+ verbose_msg(VINFO,"UTF-8 locales are %sabled\n", "dis\0en"+ (default_utf8 << 2));
} else if (!strcmp(p, "8-BIT")) {
if (!(p = strtok(NULL, " =\t\n"))
|| ((toupper(*p) != 'Y') && (toupper(*p) != 'N'))) {
- printf("error: missing or illegal 8-BIT setting\n");
- exit(EXIT_FAILURE);
+ error_msg("missing or illegal 8-BIT setting");
}
default_8bit = (toupper(*p) == 'Y');
- printf("8-BIT locales are %sabled\n", "dis\0en" + (default_8bit << 2));
+ verbose_msg(VINFO,"8-BIT locales are %sabled\n", "dis\0en" + (default_8bit << 2));
} else {
break;
}
if (((p = strtok(NULL, " \t\n")) != NULL) && (*p != '#')) {
- printf("ignoring trailing text: %s...\n", p);
+ fprintf(stderr,"ignoring trailing text: %s...\n", p);
}
*line_buf = 0;
continue;
@@ -354,13 +380,12 @@ static int find_codeset_num(const char *cs)
if (strcmp(cs, "UTF-8") != 0) {
++r;
while (*s && strcmp(__LOCALE_DATA_CODESET_LIST+ ((unsigned char) *s), cs)) {
-/* printf("tried %s\n", __LOCALE_DATA_CODESET_LIST + ((unsigned char) *s)); */
+/* verbose_msg(VDETAIL,"tried %s\n", __LOCALE_DATA_CODESET_LIST + ((unsigned char) *s)); */
++r;
++s;
}
if (!*s) {
- printf("error: unsupported codeset %s\n", cs);
- exit(EXIT_FAILURE);
+ error_msg("unsupported codeset %s", cs);
}
}
return r;
@@ -375,8 +400,7 @@ static int find_codeset_num(const char *cs)
/* 7-bit is 1, UTF-8 is 2, 8-bits are > 2 */
if (strcmp(cs, "UTF-8") != 0) {
- printf("error: unsupported codeset %s\n", cs);
- exit(EXIT_FAILURE);
+ error_msg("unsupported codeset %s", cs);
}
return r;
}
@@ -396,8 +420,7 @@ static int find_at_string_num(const char *as)
p += 1 + (unsigned char) *p;
}
- printf("error: unmapped @string %s\n", as);
- exit(EXIT_FAILURE);
+ error_msg("error: unmapped @string %s", as);
}
static void read_locale_list(void)
@@ -429,8 +452,7 @@ static void read_locale_list(void)
if (!(p = strtok(line_buf, " \t\n")) || (*p == '#')) {
if (!fgets(line_buf, sizeof(line_buf), fp)) {
if (ferror(fp)) {
- printf("error reading file\n");
- exit(EXIT_FAILURE);
+ error_msg("reading file");
}
return; /* EOF */
}
@@ -448,7 +470,7 @@ static void read_locale_list(void)
s += 1 + ((unsigned char) *s);
}
if (i < num_locales) {
- printf("ignoring dulplicate locale name: %s", p);
+ fprintf(stderr,"ignoring duplicate locale name: %s", p);
*line_buf = 0;
continue;
}
@@ -460,24 +482,23 @@ static void read_locale_list(void)
ln = p; /* save locale name */
if (!(p = strtok(NULL, " \t\n"))) {
- printf("error: missing codeset for locale %s\n", ln);
- exit(EXIT_FAILURE);
+ error_msg("missing codeset for locale %s", ln);
}
cs = p;
i = find_codeset_num(p);
if ((i == 2) && !default_utf8) {
- printf("ignoring UTF-8 locale %s\n", ln);
+ fprintf(stderr,"ignoring UTF-8 locale %s\n", ln);
*line_buf = 0;
continue;
} else if ((i > 2) && !default_8bit) {
- printf("ignoring 8-bit codeset locale %s\n", ln);
+ fprintf(stderr,"ignoring 8-bit codeset locale %s\n", ln);
*line_buf = 0;
continue;
}
locales[num_locales].cs = (char)((unsigned char) i);
if (((p = strtok(NULL, " \t\n")) != NULL) && (*p != '#')) {
- printf("ignoring trailing text: %s...\n", p);
+ verbose_msg(VINFO,"ignoring trailing text: %s...\n", p);
}
/* Now go back to locale string for .codeset and @modifier */
@@ -492,19 +513,18 @@ static void read_locale_list(void)
ls = ln;
if ((strlen(ls) != 5) || (ls[2] != '_')) {
- printf("error: illegal locale name %s\n", ls);
- exit(EXIT_FAILURE);
+ error_msg("illegal locale name %s", ls);
}
i = 0; /* value for unspecified codeset */
if (ds) {
i = find_codeset_num(ds);
if ((i == 2) && !default_utf8) {
- printf("ignoring UTF-8 locale %s\n", ln);
+ fprintf(stderr,"ignoring UTF-8 locale %s\n", ln);
*line_buf = 0;
continue;
} else if ((i > 2) && !default_8bit) {
- printf("ignoring 8-bit codeset locale %s\n", ln);
+ fprintf(stderr,"ignoring 8-bit codeset locale %s\n", ln);
*line_buf = 0;
continue;
}
@@ -516,7 +536,7 @@ static void read_locale_list(void)
ls[2] = at_mapto[i];
}
memcpy(locales[num_locales].name, ls, 5);
-/* printf("locale: %5.5s %2d %2d %s\n", */
+/* verbose_msg(VDETAIL,"locale: %5.5s %2d %2d %s\n", */
/* locales[num_locales].name, */
/* locales[num_locales].cs, */
/* locales[num_locales].dot_cs, */
@@ -554,10 +574,24 @@ static int le_cmp(const void *a, const void *b)
int main(int argc, char **argv)
{
- if ((argc != 2) || (!(fp = fopen(*++argv, "r")))) {
- printf("error: missing filename or file!\n");
- return EXIT_FAILURE;
+ char *output_file = NULL;
+
+ while (--argc) {
+ ++argv;
+ if (!strcmp(*argv, "-o")) {
+ --argc;
+ output_file = strdup(*++argv);
+ } else if (!strcmp(*argv, "-v")) {
+ verbose++;
+ } else if (!(fp = fopen(*argv, "r"))) {
+no_inputfile:
+ error_msg("missing filename or file!");
+ }
}
+ if (fp == NULL)
+ goto no_inputfile;
+ if (output_file == NULL)
+ output_file = strdup("locale_tables.h");
at_strings_end = at_strings;
@@ -572,7 +606,7 @@ int main(int argc, char **argv)
#if 0
for (i=0 ; i < num_locales ; i++) {
- printf("locale: %5.5s %2d %2d %s\n",
+ verbose_msg(VDETAIL,"locale: %5.5s %2d %2d %s\n",
locales[i].name,
locales[i].cs,
locales[i].dot_cs,
@@ -580,10 +614,10 @@ int main(int argc, char **argv)
);
}
#endif
-
- if (!(ofp = fopen("locale_tables.h", "w"))) {
- printf("error: can not open locale_tables.h for writing!\n");
- return EXIT_FAILURE;
+ if (argc == 3)
+ output_file = *++argv;
+ if (output_file == NULL || !(ofp = fopen(output_file, "w"))) {
+ error_msg("cannot open output file '%s'!", output_file);
}
do_lc_time();
@@ -596,8 +630,8 @@ int main(int argc, char **argv)
fclose(ofp);
- printf("total data size = %d\n", total_size);
- printf("null count = %d\n", null_count);
+ verbose_msg(VINFO, "total data size = %d\n", total_size);
+ verbose_msg(VDETAIL, "null count = %d\n", null_count);
return EXIT_SUCCESS;
}
@@ -622,12 +656,10 @@ static int addblock(const char *s, size_t n) /* l includes nul terminator */
}
}
if (uniq >= sizeof(idx)) {
- printf("too many uniq strings!\n");
- exit(EXIT_FAILURE);
+ error_msg("too many uniq strings!");
}
if (last + n >= buf + sizeof(buf)) {
- printf("need to increase size of buf!\n");
- exit(EXIT_FAILURE);
+ error_msg("need to increase size of buf!");
}
idx[uniq] = last;
@@ -653,13 +685,11 @@ static int addstring(const char *s)
}
}
if (uniq >= sizeof(idx)) {
- printf("too many uniq strings!\n");
- exit(EXIT_FAILURE);
+ error_msg("too many uniq strings!");
}
l = strlen(s) + 1;
if (last + l >= buf + sizeof(buf)) {
- printf("need to increase size of buf!\n");
- exit(EXIT_FAILURE);
+ error_msg("need to increase size of buf!");
}
idx[uniq] = last;
@@ -670,9 +700,9 @@ static int addstring(const char *s)
}
#define DO_LC_COMMON(CATEGORY) \
- printf("buf-size=%d uniq=%d rows=%d\n", \
+ verbose_msg(VDETAIL, "buf-size=%d uniq=%d rows=%d\n", \
(int)(last - buf), uniq, lc_##CATEGORY##_uniq); \
- printf("total = %d + %d * %d + %d = %d\n", \
+ verbose_msg(VDETAIL, "total = %d + %d * %d + %d = %d\n", \
num_locales, lc_##CATEGORY##_uniq, NUM_NL_##CATEGORY, (int)(last - buf), \
i = num_locales + lc_##CATEGORY##_uniq*NUM_NL_##CATEGORY + (int)(last - buf)); \
total_size += i; \
@@ -701,8 +731,7 @@ static int addstring(const char *s)
#define DL_LC_LOOPTAIL(CATEGORY) \
if (k > NUM_NL_##CATEGORY) { \
- printf("error -- lc_" #CATEGORY " nl_item count > %d!\n", NUM_NL_##CATEGORY); \
- exit(EXIT_FAILURE); \
+ error_msg("lc_" #CATEGORY " nl_item count > %d!", NUM_NL_##CATEGORY); \
} \
{ \
int r; \
@@ -715,8 +744,7 @@ static int addstring(const char *s)
if (r == lc_##CATEGORY##_uniq) { /* new locale row */ \
++lc_##CATEGORY##_uniq; \
if (lc_##CATEGORY##_uniq > 255) { \
- printf("too many unique lc_" #CATEGORY " rows!\n"); \
- exit(EXIT_FAILURE); \
+ error_msg("too many unique lc_" #CATEGORY " rows!"); \
} \
} \
locales[i].lc_##CATEGORY##_row = r; \
@@ -781,8 +809,7 @@ static void dump_table16(const char *name, const int *tbl, int len)
fprintf(ofp, "\n\t");
}
if (tbl[i] != (uint16_t) tbl[i]) {
- printf("error - falls outside uint16 range!\n");
- exit(EXIT_FAILURE);
+ error_msg("falls outside uint16 range!");
}
fprintf(ofp, "%#6x, ", tbl[i]);
}
@@ -823,7 +850,7 @@ static void lc_time_S(int X, int k)
len = p - s;
}
j = addblock(s, len);
-/* if (len > 1) fprintf(stderr, "alt_digit: called addblock with len %zd\n", len); */
+/* if (len > 1) verbose_msg(VDETAIL, "alt_digit: called addblock with len %zd\n", len); */
} else if (X == ERA) {
if (!s) {
s = nulbuf;
@@ -837,7 +864,7 @@ static void lc_time_S(int X, int k)
}
++p;
j = addblock(s, p - s);
-/* if (p-s > 1) fprintf(stderr, "era: called addblock with len %d\n", p-s); */
+/* if (p-s > 1) verbose_msg(VDETAIL, "era: called addblock with len %d\n", p-s); */
} else {
j = addstring(s);
}
@@ -848,8 +875,7 @@ static void lc_time_S(int X, int k)
}
if (m == lc_time_count[k]) { /* new for this nl_item */
if (m > 255) {
- printf("too many nl_item %d entries in lc_time\n", k);
- exit(EXIT_FAILURE);
+ error_msg("too many nl_item %d entries in lc_time", k);
}
lc_time_item[k][m] = j;
++lc_time_count[k];
@@ -870,7 +896,7 @@ static void do_lc_time(void)
k = 0;
if (!setlocale(LC_ALL, locales[i].glibc_name)) {
- printf("setlocale(LC_ALL,%s) failed!\n",
+ verbose_msg(VDETAIL, "setlocale(LC_ALL,%s) failed!\n",
locales[i].glibc_name);
}
@@ -973,8 +999,7 @@ static void lc_numeric_S(int X, int k)
++e;
}
if ((e - s) > sizeof(buf)) {
- printf("grouping specifier too long\n");
- exit(EXIT_FAILURE);
+ error_msg("grouping specifier too long");
}
strncpy(buf, s, (e-s));
e = buf + (e-s);
@@ -1000,13 +1025,12 @@ static void lc_numeric_S(int X, int k)
}
if (m == lc_numeric_count[k]) { /* new for this nl_item */
if (m > 255) {
- printf("too many nl_item %d entries in lc_numeric\n", k);
- exit(EXIT_FAILURE);
+ error_msg("too many nl_item %d entries in lc_numeric", k);
}
lc_numeric_item[k][m] = j;
++lc_numeric_count[k];
}
-/* printf("\\x%02x", m); */
+/* verbose_msg(VDETAIL, "\\x%02x", m); */
lc_numeric_uniq_X[lc_numeric_uniq][k] = m;
}
@@ -1023,7 +1047,7 @@ static void do_lc_numeric(void)
k = 0;
if (!setlocale(LC_ALL, locales[i].glibc_name)) {
- printf("setlocale(LC_ALL,%s) failed!\n",
+ verbose_msg(VDETAIL,"setlocale(LC_ALL,%s) failed!\n",
locales[i].glibc_name);
}
@@ -1048,7 +1072,7 @@ static int lc_monetary_uniq;
#define DO_NL_S(X) lc_monetary_S(X, k++)
-/* #define DO_NL_C(X) printf("%#02x", (int)(unsigned char)(*nl_langinfo(X))); */
+/* #define DO_NL_C(X) verbose_msg(VDETAIL,"%#02x", (int)(unsigned char)(*nl_langinfo(X))); */
#define DO_NL_C(X) lc_monetary_C(X, k++)
static void lc_monetary_C(int X, int k)
@@ -1068,13 +1092,12 @@ static void lc_monetary_C(int X, int k)
}
if (m == lc_monetary_count[k]) { /* new for this nl_item */
if (m > 255) {
- printf("too many nl_item %d entries in lc_monetary\n", k);
- exit(EXIT_FAILURE);
+ error_msg("too many nl_item %d entries in lc_monetary", k);
}
lc_monetary_item[k][m] = j;
++lc_monetary_count[k];
}
-/* printf("\\x%02x", m); */
+/* verbose_msg(VDETAIL,"\\x%02x", m); */
lc_monetary_uniq_X[lc_monetary_uniq][k] = m;
}
@@ -1104,8 +1127,7 @@ static void lc_monetary_S(int X, int k)
++e;
}
if ((e - s) > sizeof(buf)) {
- printf("mon_grouping specifier too long\n");
- exit(EXIT_FAILURE);
+ error_msg("mon_grouping specifier too long");
}
strncpy(buf, s, (e-s));
e = buf + (e-s);
@@ -1131,13 +1153,12 @@ static void lc_monetary_S(int X, int k)
}
if (m == lc_monetary_count[k]) { /* new for this nl_item */
if (m > 255) {
- printf("too many nl_item %d entries in lc_monetary\n", k);
- exit(EXIT_FAILURE);
+ error_msg("too many nl_item %d entries in lc_monetary", k);
}
lc_monetary_item[k][m] = j;
++lc_monetary_count[k];
}
-/* printf("\\x%02x", m); */
+/* verbose_msg(VDETAIL,"\\x%02x", m); */
lc_monetary_uniq_X[lc_monetary_uniq][k] = m;
}
@@ -1154,7 +1175,7 @@ static void do_lc_monetary(void)
k = 0;
if (!setlocale(LC_ALL, locales[i].glibc_name)) {
- printf("setlocale(LC_ALL,%s) failed!\n",
+ verbose_msg(VDETAIL,"setlocale(LC_ALL,%s) failed!\n",
locales[i].glibc_name);
}
@@ -1213,13 +1234,12 @@ static void lc_messages_S(int X, int k)
}
if (m == lc_messages_count[k]) { /* new for this nl_item */
if (m > 255) {
- printf("too many nl_item %d entries in lc_messages\n", k);
- exit(EXIT_FAILURE);
+ error_msg("too many nl_item %d entries in lc_messages", k);
}
lc_messages_item[k][m] = j;
++lc_messages_count[k];
}
-/* printf("\\x%02x", m); */
+/* verbose_msg(VDETAIL, "\\x%02x", m); */
lc_messages_uniq_X[lc_messages_uniq][k] = m;
}
@@ -1236,7 +1256,7 @@ static void do_lc_messages(void)
k = 0;
if (!setlocale(LC_ALL, locales[i].glibc_name)) {
- printf("setlocale(LC_ALL,%s) failed!\n",
+ verbose_msg(VDETAIL, "setlocale(LC_ALL,%s) failed!\n",
locales[i].glibc_name);
}
@@ -1273,13 +1293,12 @@ static void lc_ctype_S(int X, int k)
}
if (m == lc_ctype_count[k]) { /* new for this nl_item */
if (m > 255) {
- printf("too many nl_item %d entries in lc_ctype\n", k);
- exit(EXIT_FAILURE);
+ error_msg("too many nl_item %d entries in lc_ctype", k);
}
lc_ctype_item[k][m] = j;
++lc_ctype_count[k];
}
-/* printf("\\x%02x", m); */
+/* verbose_msg(VDETAIL, "\\x%02x", m); */
lc_ctype_uniq_X[lc_ctype_uniq][k] = m;
}
@@ -1296,7 +1315,7 @@ static void do_lc_ctype(void)
k = 0;
if (!setlocale(LC_ALL, locales[i].glibc_name)) {
- printf("setlocale(LC_ALL,%s) failed!\n",
+ verbose_msg(VDETAIL, "setlocale(LC_ALL,%s) failed!\n",
locales[i].glibc_name);
}
diff --git a/extra/locale/gen_mmap.c b/extra/locale/gen_mmap.c
index f9bce022c..1cf0bb9e6 100644
--- a/extra/locale/gen_mmap.c
+++ b/extra/locale/gen_mmap.c
@@ -127,7 +127,7 @@ int main(void)
unsigned char *p;
if (!(fp = fopen("locale.mmap", "w"))) {
- printf("error - can't open locale.mmap for writing!");
+ printf("cannot open locale.mmap for writing!");
return EXIT_FAILURE;
}
diff --git a/extra/locale/gen_wc8bit.c b/extra/locale/gen_wc8bit.c
index c6db41231..e16b283a2 100644
--- a/extra/locale/gen_wc8bit.c
+++ b/extra/locale/gen_wc8bit.c
@@ -18,8 +18,10 @@
#ifndef _WCTYPE_H
#define _WCTYPE_H
#endif
-#include UCLIBC_CTYPE_HEADER
+#include "include/bits/uClibc_ctype.h"
+/* TODO: maybe support -v like gen_wctype.c */
+#define verbose_msg(msg...) if (verbose) fprintf(stderr, msg)
/* #define CTYPE_PACKED */
#define UPLOW_IDX_SHIFT 3
@@ -80,7 +82,6 @@ typedef struct {
int main(int argc, char **argv)
{
FILE *fp;
- FILE *out;
charset_data csd[30];
unsigned long max_wchar;
unsigned char *p;
@@ -98,85 +99,107 @@ int main(int argc, char **argv)
int total_size = 0;
if (!setlocale(LC_CTYPE, "en_US.UTF-8")) {
- printf("setlocale(LC_CTYPE,\"en_US.UTF-8\") failed!\n");
- return EXIT_FAILURE;
- }
+ /* Silly foreigners disabling en_US locales */
+ FILE *fp = popen("locale -a", "r");
+ if (!fp)
+ goto locale_failure;
+
+ while (!feof(fp)) {
+ char buf[256];
+ size_t len;
+
+ if (fgets(buf, sizeof(buf) - 10, fp) == NULL)
+ goto locale_failure;
+
+ len = strlen(buf);
+ if (len > 0 && buf[len - 1] == '\n')
+ buf[--len] = '\0';
+ if (len < 5 || strcasecmp(&buf[len-5], ".UTF8") != 0)
+ strcat(buf, ".UTF8");
+ if (setlocale(LC_CTYPE, buf))
+ goto locale_success;
+ }
- if (!(out = fopen("c8tables.h","w"))) {
- printf("error: couldn't open file \"c8tables.h\"\n");
+ locale_failure:
+ printf("could not find a UTF8 locale ... please enable en_US.UTF-8\n");
return EXIT_FAILURE;
+ locale_success:
+ pclose(fp);
}
#if 0
if (argc == 1) {
/* User requested 8-bit codesets, but didn't list any... */
/* Allow to build, just so this feature can be left on in config. */
- fprintf(out, "#ifdef __CTYPE_HAS_8_BIT_LOCALES\n");
- fprintf(out, "#warning ignoring 8 bit codesets request"
+ printf("#ifdef __CTYPE_HAS_8_BIT_LOCALES\n");
+ printf("#warning ignoring 8 bit codesets request"
" as no codesets specified.\n");
- fprintf(out, "#endif\n");
- fprintf(out, "#undef __CTYPE_HAS_8_BIT_LOCALES\n\n");
+ printf("#endif\n");
+ printf("#undef __CTYPE_HAS_8_BIT_LOCALES\n\n");
- fprintf(out, "#define __LOCALE_DATA_NUM_CODESETS\t\t0\n");
- fprintf(out, "#define __LOCALE_DATA_CODESET_LIST\t\t\"\"\n");
- fclose(out);
+ printf("#define __LOCALE_DATA_NUM_CODESETS\t\t0\n");
+ printf("#define __LOCALE_DATA_CODESET_LIST\t\t\"\"\n");
return EXIT_SUCCESS;
}
-/* fprintf(out, "#define __CTYPE_HAS_8_BIT_LOCALES\t1\n\n"); */
- fprintf(out, "#ifdef __CTYPE_HAS_8_BIT_LOCALES\n\n");
+/* printf("#define __CTYPE_HAS_8_BIT_LOCALES\t1\n\n"); */
+ printf("#ifdef __CTYPE_HAS_8_BIT_LOCALES\n\n");
#endif
if (argc == 1) {
- fprintf(out, "#undef __CTYPE_HAS_8_BIT_LOCALES\n\n");
+ printf("#undef __CTYPE_HAS_8_BIT_LOCALES\n\n");
- fprintf(out, "#define __LOCALE_DATA_NUM_CODESETS\t\t0\n");
- fprintf(out, "#define __LOCALE_DATA_CODESET_LIST\t\t\"\"\n");
+ printf("#define __LOCALE_DATA_NUM_CODESETS\t\t0\n");
+ printf("#define __LOCALE_DATA_CODESET_LIST\t\t\"\"\n");
} else {
- fprintf(out, "#define __CTYPE_HAS_8_BIT_LOCALES\t\t1\n\n");
+ printf("#define __CTYPE_HAS_8_BIT_LOCALES\t\t1\n\n");
}
- fprintf(out, "#define __LOCALE_DATA_Cctype_IDX_SHIFT\t%d\n", CTYPE_IDX_SHIFT);
- fprintf(out, "#define __LOCALE_DATA_Cctype_IDX_LEN\t\t%d\n", CTYPE_IDX_LEN);
+ printf("#define __LOCALE_DATA_Cctype_IDX_SHIFT\t%d\n", CTYPE_IDX_SHIFT);
+ printf("#define __LOCALE_DATA_Cctype_IDX_LEN\t\t%d\n", CTYPE_IDX_LEN);
#ifdef CTYPE_PACKED
- fprintf(out, "#define __LOCALE_DATA_Cctype_ROW_LEN\t\t%d\n", CTYPE_ROW_LEN >> 1);
- fprintf(out, "#define __LOCALE_DATA_Cctype_PACKED\t\t1\n");
+ printf("#define __LOCALE_DATA_Cctype_ROW_LEN\t\t%d\n", CTYPE_ROW_LEN >> 1);
+ printf("#define __LOCALE_DATA_Cctype_PACKED\t\t1\n");
#else
- fprintf(out, "#define __LOCALE_DATA_Cctype_ROW_LEN\t\t%d\n", CTYPE_ROW_LEN);
- fprintf(out, "#undef __LOCALE_DATA_Cctype_PACKED\n");
+ printf("#define __LOCALE_DATA_Cctype_ROW_LEN\t\t%d\n", CTYPE_ROW_LEN);
+ printf("#undef __LOCALE_DATA_Cctype_PACKED\n");
#endif
- fprintf(out, "\n#define __LOCALE_DATA_Cuplow_IDX_SHIFT\t%d\n", UPLOW_IDX_SHIFT);
- fprintf(out, "#define __LOCALE_DATA_Cuplow_IDX_LEN\t\t%d\n", UPLOW_IDX_LEN);
- fprintf(out, "#define __LOCALE_DATA_Cuplow_ROW_LEN\t\t%d\n", UPLOW_ROW_LEN);
+ printf("\n#define __LOCALE_DATA_Cuplow_IDX_SHIFT\t%d\n", UPLOW_IDX_SHIFT);
+ printf("#define __LOCALE_DATA_Cuplow_IDX_LEN\t\t%d\n", UPLOW_IDX_LEN);
+ printf("#define __LOCALE_DATA_Cuplow_ROW_LEN\t\t%d\n", UPLOW_ROW_LEN);
#ifdef DO_WIDE_CHAR
- fprintf(out, "\n#define __LOCALE_DATA_Cc2wc_IDX_LEN\t\t%d\n", C2WC_IDX_LEN);
- fprintf(out, "#define __LOCALE_DATA_Cc2wc_IDX_SHIFT\t\t%d\n", C2WC_IDX_SHIFT);
- fprintf(out, "#define __LOCALE_DATA_Cc2wc_ROW_LEN\t\t%d\n", C2WC_ROW_LEN);
+ printf("\n#define __LOCALE_DATA_Cc2wc_IDX_LEN\t\t%d\n", C2WC_IDX_LEN);
+ printf("#define __LOCALE_DATA_Cc2wc_IDX_SHIFT\t\t%d\n", C2WC_IDX_SHIFT);
+ printf("#define __LOCALE_DATA_Cc2wc_ROW_LEN\t\t%d\n", C2WC_ROW_LEN);
#endif
- fprintf(out, "\ntypedef struct {\n");
- fprintf(out, "\tunsigned char idx8ctype[%d];\n", CTYPE_IDX_LEN);
- fprintf(out, "\tunsigned char idx8uplow[%d];\n", UPLOW_IDX_LEN);
+ printf("\ntypedef struct {\n");
+ printf("\tunsigned char idx8ctype[%d];\n", CTYPE_IDX_LEN);
+ printf("\tunsigned char idx8uplow[%d];\n", UPLOW_IDX_LEN);
#ifdef DO_WIDE_CHAR
- fprintf(out, "\tunsigned char idx8c2wc[%d];\n", C2WC_IDX_LEN);
- fprintf(out, "\tunsigned char idx8wc2c[%d];\n", II_LEN);
+ printf("\tunsigned char idx8c2wc[%d];\n", C2WC_IDX_LEN);
+ printf("\tunsigned char idx8wc2c[%d];\n", II_LEN);
#endif
- fprintf(out, "} __codeset_8_bit_t;\n\n");
+#ifndef __metag__
+ printf("} __codeset_8_bit_t;\n\n");
+#else
+ printf("} __attribute__((__packed__)) __codeset_8_bit_t;\n\n");
+#endif /* __metag__ */
- fprintf(out, "#ifdef WANT_DATA\n\n");
- fprintf(out, "static const __codeset_8_bit_t codeset_8_bit[%d] = {\n", argc-1);
+ printf("#ifdef WANT_DATA\n\n");
+ printf("static const __codeset_8_bit_t codeset_8_bit[%d] = {\n", argc-1);
max_wchar = 0x7f;
numsets = 0;
codeset_index[0] = 0;
while (--argc) {
if (!(fp = fopen(*++argv,"r"))) {
- printf("error: couldn't open file \"%s\"\n", *argv);
+ fprintf(stderr, "cannot open file \"%s\"\n", *argv);
return EXIT_FAILURE;
}
- printf("processing %s... ", *argv);
+ fprintf(stderr, "processing %s... ", *argv);
{
char *s0;
@@ -202,12 +225,12 @@ int main(int argc, char **argv)
/* } */
if (numsets >= sizeof(codeset_index)) {
- printf("error - too many codesets!\n");
+ fprintf(stderr, "error - too many codesets!\n");
return EXIT_FAILURE;
}
if (codeset_list_end + n + 1 + numsets + 1 + 1 >= 256) {
- printf("error - codeset list to big!\n");
+ fprintf(stderr, "error - codeset list to big!\n");
return EXIT_FAILURE;
}
@@ -216,11 +239,11 @@ int main(int argc, char **argv)
codeset_list_end += (n+1);
codeset_list[codeset_list_end - 1] = 0;
- fprintf(out, "\t{ /* %.*s */", n, s0);
+ printf("\t{ /* %.*s */", n, s0);
}
- memset(&csd[numsets],sizeof(charset_data),0);
- memset(xi, sizeof(xi), 0);
+ memset(&csd[numsets], 0, sizeof(charset_data));
+ memset(xi, 0, sizeof(xi));
{
unsigned long c, wc;
int lines;
@@ -228,7 +251,7 @@ int main(int argc, char **argv)
while (fgets(buf,sizeof(buf),fp)) {
if ((2 != sscanf(buf, "{ %lx , %lx", &c, &wc))
|| (c >= 256) || (wc > MAX_WCHAR)) {
- printf("error: scanf failure! \"%s\"\n", buf);
+ fprintf(stderr, "error: scanf failure! \"%s\"\n", buf);
return EXIT_FAILURE;
}
@@ -236,7 +259,7 @@ int main(int argc, char **argv)
if (c <= 0x7f) { /* check the 7bit entries but don't store */
if (c != wc) {
- printf("error: c != wc in %s\n", buf);
+ fprintf(stderr, "error: c != wc in %s\n", buf);
return EXIT_FAILURE;
}
csd[numsets].c2w[c] = wc;
@@ -253,7 +276,7 @@ int main(int argc, char **argv)
}
++lines;
}
- printf("%d lines ", lines);
+ fprintf(stderr, "%d lines ", lines);
for (i = 0 ; i <= MAX_WCHAR ; i += (1 << TT_SHIFT)) {
p = &csd[numsets].w2c[i];
@@ -281,17 +304,17 @@ int main(int argc, char **argv)
++ti_num;
}
csd[numsets].ii[i >> TI_SHIFT] = j;
-/* printf("%d ", i >> TI_SHIFT); */
+/* fprintf(stderr, "%d ", i >> TI_SHIFT); */
}
#if 1
- fprintf(out, "\n\t\t/* idx8ctype data */\n\t\t{");
+ printf("\n\t\t/* idx8ctype data */\n\t\t{");
for (i = 128 ; i < 256 ; i++) {
wchar_t c;
unsigned int d;
/* if (!(i & 0x7)) { */
-/* fprintf(out, "\n"); */
+/* printf("\n"); */
/* } */
c = csd[numsets].c2w[i];
@@ -348,7 +371,7 @@ int main(int argc, char **argv)
}
if (j == n_ctype_rows) { /* new entry */
if (++n_ctype_rows > 256) {
- printf("error -- to many ctype rows!\n");
+ fprintf(stderr, "error -- to many ctype rows!\n");
return EXIT_FAILURE;
}
memcpy(p, row, CTYPE_ROW_LEN);
@@ -357,23 +380,23 @@ int main(int argc, char **argv)
if (!((i >> CTYPE_IDX_SHIFT) & 0x7)
&& (i != (127 + CTYPE_ROW_LEN))
) {
- fprintf(out, "\n\t\t ");
+ printf("\n\t\t ");
}
- fprintf(out, " %#4x,", j);
+ printf(" %#4x,", j);
}
#else
- fprintf(out, " %#4x,", d);
+ printf(" %#4x,", d);
#endif
}
#endif
- fprintf(out, " }");
+ printf(" }");
#if 1
- fprintf(out, ",\n\t\t/* idx8uplow data */\n\t\t{");
+ printf(",\n\t\t/* idx8uplow data */\n\t\t{");
for (i = 128 ; i < 256 ; i++) {
wchar_t c, u, l;
/* if (!(i & 0x7)) { */
-/* fprintf(out, "\n"); */
+/* printf("\n"); */
/* } */
c = csd[numsets].c2w[i];
if ((c != 0) || 1) {
@@ -391,7 +414,7 @@ int main(int argc, char **argv)
/* if ((((u-i) < CHAR_MIN) || ((u-i) > CHAR_MAX)) */
/* || (((i-l) < CHAR_MIN) || ((i-l) > CHAR_MAX)) */
/* ) { */
-/* printf("error - uplow diff out of range! %d %ld %ld\n", */
+/* fprintf(stderr, "error - uplow diff out of range! %d %ld %ld\n", */
/* i, u, l); */
/* return EXIT_FAILURE; */
/* } */
@@ -407,7 +430,7 @@ int main(int argc, char **argv)
}
if (j == n_uplow_rows) { /* new entry */
if (++n_uplow_rows > 256) {
- printf("error -- to many uplow rows!\n");
+ fprintf(stderr, "error -- to many uplow rows!\n");
return EXIT_FAILURE;
}
memcpy(p, row, UPLOW_ROW_LEN);
@@ -416,21 +439,21 @@ int main(int argc, char **argv)
if (!((i >> UPLOW_IDX_SHIFT) & 0x7)
&& (i != (127 + UPLOW_ROW_LEN))
) {
- fprintf(out, "\n\t\t ");
+ printf("\n\t\t ");
}
- fprintf(out, " %#4x,", j);
+ printf(" %#4x,", j);
}
#elif 0
if (!(i & 0x7) && i) {
- fprintf(out, "\n");
+ printf("\n");
}
- fprintf(out, " %4ld,", (l==i) ? (u-i) : (i-l));
-/* fprintf(out, " %4ld,", (l==i) ? u : l); */
+ printf(" %4ld,", (l==i) ? (u-i) : (i-l));
+/* printf(" %4ld,", (l==i) ? u : l); */
#else
if ((u != i) || (l != i)) {
#if 0
- fprintf(out, " %#08lx, %#08lx, %#08lx, %#08lx, %#08lx, %#08lx, \n",
+ printf(" %#08lx, %#08lx, %#08lx, %#08lx, %#08lx, %#08lx, \n",
(unsigned long) i,
(unsigned long) c,
(unsigned long) l,
@@ -439,7 +462,7 @@ int main(int argc, char **argv)
(unsigned long) towupper(c));
#else
- fprintf(out, " %#08lx, %8ld, %d, %8ld, %d, %#08lx\n",
+ printf(" %#08lx, %8ld, %d, %8ld, %d, %#08lx\n",
(unsigned long) i,
(long) (l - i),
iswupper(c),
@@ -451,15 +474,15 @@ int main(int argc, char **argv)
#endif
}
}
- fprintf(out, " }");
+ printf(" }");
#endif
#ifndef DO_WIDE_CHAR
- fprintf(out,"\n");
+ printf("\n");
#else /* DO_WIDE_CHAR */
#if 1
- fprintf(out, ",\n\t\t/* idx8c2wc data */\n\t\t{");
+ printf(",\n\t\t/* idx8c2wc data */\n\t\t{");
for (i = 128 ; i < 256 ; i++) {
#if 1
wrow[i & (C2WC_ROW_LEN-1)] = csd[numsets].c2w[i];
@@ -473,7 +496,7 @@ int main(int argc, char **argv)
}
if (j == n_c2wc_rows) { /* new entry */
if (++n_c2wc_rows > 256) {
- printf("error -- to many c2wc rows!\n");
+ fprintf(stderr, "error -- to many c2wc rows!\n");
return EXIT_FAILURE;
}
memcpy(p, (char *) wrow, 2*C2WC_ROW_LEN);
@@ -482,107 +505,107 @@ int main(int argc, char **argv)
if (!((i >> C2WC_IDX_SHIFT) & 0x7)
&& (i != (127 + C2WC_ROW_LEN))
) {
- fprintf(out, "\n\t\t ");
+ printf("\n\t\t ");
}
- fprintf(out, " %#4x,", j);
+ printf(" %#4x,", j);
}
#else
if (!(i & 0x7) && i) {
- fprintf(out, "\n");
+ printf("\n");
}
- fprintf(out, " %#6lx,", csd[numsets].c2w[i]);
+ printf(" %#6lx,", csd[numsets].c2w[i]);
#endif
}
- fprintf(out, " },\n");
+ printf(" },\n");
#endif
#if 1
-/* fprintf(out, "\nII_LEN = %d\n", II_LEN); */
- fprintf(out, "\t\t/* idx8wc2c data */\n\t\t{");
+/* fprintf(stderr, "\nII_LEN = %d\n", II_LEN); */
+ printf("\t\t/* idx8wc2c data */\n\t\t{");
for (i = 0 ; i < II_LEN ; i++) {
if (!(i & 0x7) && i) {
- fprintf(out, "\n\t\t ");
+ printf("\n\t\t ");
}
- fprintf(out, " %#4x,", csd[numsets].ii[i]);
+ printf(" %#4x,", csd[numsets].ii[i]);
}
- fprintf(out, " }\n");
+ printf(" }\n");
#endif
#endif /* DO_WIDE_CHAR */
- fprintf(out, "\t},\n");
+ printf("\t},\n");
}
++numsets;
- printf("done\n");
+ fprintf(stderr, "done\n");
}
- fprintf(out, "};\n");
- fprintf(out, "\n#endif /* WANT_DATA */\n");
+ printf("};\n");
+ printf("\n#endif /* WANT_DATA */\n");
#ifdef DO_WIDE_CHAR
- fprintf(out, "\n");
- fprintf(out, "#define __LOCALE_DATA_Cwc2c_DOMAIN_MAX\t%#x\n", RANGE);
- fprintf(out, "#define __LOCALE_DATA_Cwc2c_TI_SHIFT\t\t%d\n", TI_SHIFT);
- fprintf(out, "#define __LOCALE_DATA_Cwc2c_TT_SHIFT\t\t%d\n", TT_SHIFT);
- fprintf(out, "#define __LOCALE_DATA_Cwc2c_II_LEN\t\t%d\n", II_LEN);
- fprintf(out, "#define __LOCALE_DATA_Cwc2c_TI_LEN\t\t%d\n", ti_num << TI_SHIFT);
- fprintf(out, "#define __LOCALE_DATA_Cwc2c_TT_LEN\t\t%d\n", tt_num << TT_SHIFT);
- fprintf(out, "\n");
-
- fprintf(out, "\n#define __LOCALE_DATA_Cwc2c_TBL_LEN\t\t%d\n",
+ printf("\n");
+ printf("#define __LOCALE_DATA_Cwc2c_DOMAIN_MAX\t%#x\n", RANGE);
+ printf("#define __LOCALE_DATA_Cwc2c_TI_SHIFT\t\t%d\n", TI_SHIFT);
+ printf("#define __LOCALE_DATA_Cwc2c_TT_SHIFT\t\t%d\n", TT_SHIFT);
+ printf("#define __LOCALE_DATA_Cwc2c_II_LEN\t\t%d\n", II_LEN);
+ printf("#define __LOCALE_DATA_Cwc2c_TI_LEN\t\t%d\n", ti_num << TI_SHIFT);
+ printf("#define __LOCALE_DATA_Cwc2c_TT_LEN\t\t%d\n", tt_num << TT_SHIFT);
+ printf("\n");
+
+ printf("\n#define __LOCALE_DATA_Cwc2c_TBL_LEN\t\t%d\n",
(ti_num << TI_SHIFT) + (tt_num << TT_SHIFT));
- fprintf(out, "#ifdef WANT_DATA\n\n");
- fprintf(out, "static const unsigned char __LOCALE_DATA_Cwc2c_data[%d] = {\n",
+ printf("#ifdef WANT_DATA\n\n");
+ printf("static const unsigned char __LOCALE_DATA_Cwc2c_data[%d] = {\n",
(ti_num << TI_SHIFT) + (tt_num << TT_SHIFT));
- fprintf(out, "\t/* ti_table */\n\t");
+ printf("\t/* ti_table */\n\t");
for (i=0 ; i < ti_num << TI_SHIFT ; i++) {
if (!(i & 7) && i) {
- fprintf(out, "\n\t");
+ printf("\n\t");
}
- fprintf(out, " %#4x,", ti[i]);
+ printf(" %#4x,", ti[i]);
}
- fprintf(out, "\n");
- fprintf(out, "\t/* tt_table */\n\t");
+ printf("\n");
+ printf("\t/* tt_table */\n\t");
for (i=0 ; i < tt_num << TT_SHIFT ; i++) {
if (!(i & 7) && i) {
- fprintf(out, "\n\t");
+ printf("\n\t");
}
- fprintf(out, " %#4x,", tt[i]);
+ printf(" %#4x,", tt[i]);
}
- fprintf(out, "\n};\n");
+ printf("\n};\n");
- fprintf(out, "\n#endif /* WANT_DATA */\n");
+ printf("\n#endif /* WANT_DATA */\n");
#endif /* DO_WIDE_CHAR */
- fprintf(out, "\n#define __LOCALE_DATA_Cuplow_TBL_LEN\t\t%d\n",
+ printf("\n#define __LOCALE_DATA_Cuplow_TBL_LEN\t\t%d\n",
n_uplow_rows * UPLOW_ROW_LEN);
- fprintf(out, "\n#ifdef WANT_DATA\n\n");
+ printf("\n#ifdef WANT_DATA\n\n");
- fprintf(out, "\nstatic const unsigned char __LOCALE_DATA_Cuplow_data[%d] = {\n",
+ printf("\nstatic const unsigned char __LOCALE_DATA_Cuplow_data[%d] = {\n",
n_uplow_rows * UPLOW_ROW_LEN);
p = uplow_tbl;
for (j=0 ; j < n_uplow_rows ; j++) {
- fprintf(out, "\t");
+ printf("\t");
for (i=0 ; i < UPLOW_ROW_LEN ; i++) {
- fprintf(out, " %#4x,", (unsigned int)((unsigned char) p[i]));
+ printf(" %#4x,", (unsigned int)((unsigned char) p[i]));
}
- fprintf(out, "\n");
+ printf("\n");
p += UPLOW_ROW_LEN;
}
- fprintf(out, "};\n");
+ printf("};\n");
- fprintf(out, "\n#endif /* WANT_DATA */\n");
- fprintf(out, "\n#define __LOCALE_DATA_Cctype_TBL_LEN\t\t%d\n",
+ printf("\n#endif /* WANT_DATA */\n");
+ printf("\n#define __LOCALE_DATA_Cctype_TBL_LEN\t\t%d\n",
#ifdef CTYPE_PACKED
n_ctype_rows * CTYPE_ROW_LEN / 2
#else
n_ctype_rows * CTYPE_ROW_LEN
#endif
);
- fprintf(out, "\n#ifdef WANT_DATA\n\n");
+ printf("\n#ifdef WANT_DATA\n\n");
- fprintf(out, "\nstatic const unsigned char __LOCALE_DATA_Cctype_data[%d] = {\n",
+ printf("\nstatic const unsigned char __LOCALE_DATA_Cctype_data[%d] = {\n",
#ifdef CTYPE_PACKED
n_ctype_rows * CTYPE_ROW_LEN / 2
#else
@@ -591,59 +614,59 @@ int main(int argc, char **argv)
);
p = ctype_tbl;
for (j=0 ; j < n_ctype_rows ; j++) {
- fprintf(out, "\t");
+ printf("\t");
for (i=0 ; i < CTYPE_ROW_LEN ; i++) {
#ifdef CTYPE_PACKED
- fprintf(out, " %#4x,", (unsigned int)(p[i] + (p[i+1] << 4)));
+ printf(" %#4x,", (unsigned int)(p[i] + (p[i+1] << 4)));
++i;
#else
- fprintf(out, " %#4x,", (unsigned int)p[i]);
+ printf(" %#4x,", (unsigned int)p[i]);
#endif
}
- fprintf(out, "\n");
+ printf("\n");
p += CTYPE_ROW_LEN;
}
- fprintf(out, "};\n");
+ printf("};\n");
- fprintf(out, "\n#endif /* WANT_DATA */\n");
+ printf("\n#endif /* WANT_DATA */\n");
#ifdef DO_WIDE_CHAR
- fprintf(out, "\n#define __LOCALE_DATA_Cc2wc_TBL_LEN\t\t%d\n",
+ printf("\n#define __LOCALE_DATA_Cc2wc_TBL_LEN\t\t%d\n",
n_c2wc_rows * C2WC_ROW_LEN);
- fprintf(out, "\n#ifdef WANT_DATA\n\n");
+ printf("\n#ifdef WANT_DATA\n\n");
- fprintf(out, "\nstatic const unsigned short __LOCALE_DATA_Cc2wc_data[%d] = {\n",
+ printf("\nstatic const unsigned short __LOCALE_DATA_Cc2wc_data[%d] = {\n",
n_c2wc_rows * C2WC_ROW_LEN);
p = (unsigned char *) c2wc_tbl;
for (j=0 ; j < n_c2wc_rows ; j++) {
- fprintf(out, "\t");
+ printf("\t");
for (i=0 ; i < C2WC_ROW_LEN ; i++) {
- fprintf(out, " %#6x,", (unsigned int)(((unsigned short *)p)[i]));
+ printf(" %#6x,", (unsigned int)(((unsigned short *)p)[i]));
}
- fprintf(out, "\n");
+ printf("\n");
p += 2*C2WC_ROW_LEN;
}
- fprintf(out, "};\n");
- fprintf(out, "\n#endif /* WANT_DATA */\n");
+ printf("};\n");
+ printf("\n#endif /* WANT_DATA */\n");
#endif /* DO_WIDE_CHAR */
- fprintf(out, "\n\n");
+ printf("\n\n");
- fprintf(out, "#define __LOCALE_DATA_NUM_CODESETS\t\t%d\n", numsets);
- fprintf(out, "#define __LOCALE_DATA_CODESET_LIST \\\n\t\"");
+ printf("#define __LOCALE_DATA_NUM_CODESETS\t\t%d\n", numsets);
+ printf("#define __LOCALE_DATA_CODESET_LIST \\\n\t\"");
for (i=0 ; i < numsets ; i++) {
- fprintf(out, "\\x%02x", numsets + 1 + (unsigned char) codeset_index[i]);
+ printf("\\x%02x", numsets + 1 + (unsigned char) codeset_index[i]);
if (((i & 7) == 7) && (i + 1 < numsets)) {
- fprintf(out, "\" \\\n\t\"");
+ printf("\" \\\n\t\"");
}
}
- fprintf(out, "\" \\\n\t\"\\0\"");
+ printf("\" \\\n\t\"\\0\"");
for (i=0 ; i < numsets ; i++) {
- fprintf(out, " \\\n\t\"%s\\0\"",
+ printf(" \\\n\t\"%s\\0\"",
codeset_list + ((unsigned char)codeset_index[i]));
}
- fprintf(out, "\n\n");
+ printf("\n\n");
for (i=0 ; i < numsets ; i++) {
char buf[30];
char *z;
@@ -653,24 +676,22 @@ int main(int argc, char **argv)
*z = '_';
}
}
- fprintf(out, "#define __CTYPE_HAS_CODESET_%s\n", buf);
+ printf("#define __CTYPE_HAS_CODESET_%s\n", buf);
}
#ifdef DO_WIDE_CHAR
- fprintf(out, "#define __CTYPE_HAS_CODESET_UTF_8\n");
+ printf("#define __CTYPE_HAS_CODESET_UTF_8\n");
#endif /* DO_WIDE_CHAR */
#if 0
- fprintf(out, "\n#endif /* __CTYPE_HAS_8_BIT_LOCALES */\n\n");
+ printf("\n#endif /* __CTYPE_HAS_8_BIT_LOCALES */\n\n");
#endif
- fclose(out);
-
total_size = 0;
#ifdef DO_WIDE_CHAR
- printf("tt_num = %d ti_num = %d\n", tt_num, ti_num);
- printf("max_wchar = %#lx\n", max_wchar);
+ fprintf(stderr, "tt_num = %d ti_num = %d\n", tt_num, ti_num);
+ fprintf(stderr, "max_wchar = %#lx\n", max_wchar);
- printf("size is %d * %d + %d * %d + %d * %d = %d\n",
+ fprintf(stderr, "size is %d * %d + %d * %d + %d * %d = %d\n",
tt_num, 1 << TT_SHIFT, ti_num, 1 << TI_SHIFT,
((MAX_WCHAR >> (TT_SHIFT + TI_SHIFT)) + 1), numsets,
j = tt_num * (1 << TT_SHIFT) + ti_num * (1 << TI_SHIFT)
@@ -684,26 +705,26 @@ int main(int argc, char **argv)
i = 1;
#endif
- printf("ctype - CTYPE_IDX_SHIFT = %d -- %d * %d + %d * %d = %d\n",
+ fprintf(stderr, "ctype - CTYPE_IDX_SHIFT = %d -- %d * %d + %d * %d = %d\n",
CTYPE_IDX_SHIFT, numsets, CTYPE_IDX_LEN, n_ctype_rows, CTYPE_ROW_LEN / i,
j = numsets * CTYPE_IDX_LEN + n_ctype_rows * CTYPE_ROW_LEN / i);
total_size += j;
- printf("uplow - UPLOW_IDX_SHIFT = %d -- %d * %d + %d * %d = %d\n",
+ fprintf(stderr, "uplow - UPLOW_IDX_SHIFT = %d -- %d * %d + %d * %d = %d\n",
UPLOW_IDX_SHIFT, numsets, UPLOW_IDX_LEN, n_uplow_rows, UPLOW_ROW_LEN,
j = numsets * UPLOW_IDX_LEN + n_uplow_rows * UPLOW_ROW_LEN);
total_size += j;
#ifdef DO_WIDE_CHAR
- printf("c2wc - C2WC_IDX_SHIFT = %d -- %d * %d + 2 * %d * %d = %d\n",
+ fprintf(stderr, "c2wc - C2WC_IDX_SHIFT = %d -- %d * %d + 2 * %d * %d = %d\n",
C2WC_IDX_SHIFT, numsets, C2WC_IDX_LEN, n_c2wc_rows, C2WC_ROW_LEN,
j = numsets * C2WC_IDX_LEN + 2 * n_c2wc_rows * C2WC_ROW_LEN);
total_size += j;
#endif /* DO_WIDE_CHAR */
- printf("total size = %d\n", total_size);
+ fprintf(stderr, "total size = %d\n", total_size);
/* for (i=0 ; i < numsets ; i++) { */
/* printf("codeset_index[i] = %d codeset_list[ci[i]] = \"%s\"\n", */
diff --git a/extra/locale/gen_wctype.c b/extra/locale/gen_wctype.c
index 085ec51b1..d5b5c5c28 100644
--- a/extra/locale/gen_wctype.c
+++ b/extra/locale/gen_wctype.c
@@ -14,13 +14,7 @@
#include <wchar.h>
#include <ctype.h>
-#ifndef _CTYPE_H
-#define _CTYPE_H
-#endif
-#ifndef _WCTYPE_H
-#define _WCTYPE_H
-#endif
-#include UCLIBC_CTYPE_HEADER
+#include "include/bits/uClibc_charclass.h"
/* 0x9 : space blank */
/* 0xa : space */
@@ -62,7 +56,6 @@
/* typecount[15] = 0 empty_slot */
-
/* Set to #if 0 to restrict wchars to 16 bits. */
#if 1
#define RANGE 0x2ffffUL
@@ -72,74 +65,22 @@
#define RANGE 0xffffUL /* Restrict for 16-bit wchar_t... */
#endif
-#if 0
-/* Classification codes. */
-
-static const char *typename[] = {
- "C_unclassified",
- "C_alpha_nonupper_nonlower",
- "C_alpha_lower",
- "C_alpha_upper_lower",
- "C_alpha_upper",
- "C_digit",
- "C_punct",
- "C_graph",
- "C_print_space_nonblank",
- "C_print_space_blank",
- "C_space_nonblank_noncntrl",
- "C_space_blank_noncntrl",
- "C_cntrl_space_nonblank",
- "C_cntrl_space_blank",
- "C_cntrl_nonspace",
- "empty_slot"
-};
-#endif
-
-#if 0
-/* 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
-
-#define __CTYPE_isxdigit(D,X) \
- (__CTYPE_isdigit(D) || (((unsigned int)(((X)|0x20) - 'a')) <= 5))
-
-#define mywalnum(x) __CTYPE_isalnum(d)
-#define mywalpha(x) __CTYPE_isalpha(d)
-#define mywblank(x) __CTYPE_isblank(d)
-#define mywcntrl(x) __CTYPE_iscntrl(d)
-#define mywdigit(x) __CTYPE_isdigit(d)
-#define mywgraph(x) __CTYPE_isgraph(d)
-#define mywlower(x) __CTYPE_islower(d)
-#define mywprint(x) __CTYPE_isprint(d)
-#define mywpunct(x) __CTYPE_ispunct(d)
-#define mywspace(x) __CTYPE_isspace(d)
-#define mywupper(x) __CTYPE_isupper(d)
-#define mywxdigit(x) __CTYPE_isxdigit(d,x)
+/* Some macros that test for various (w)ctype classes when passed one of the
+ * designator values enumerated above. */
+#define mywalnum(D,C) ((unsigned)(D - 1) <= (__CTYPE_digit - 1))
+#define mywalpha(D,C) ((unsigned)(D - 1) <= (__CTYPE_alpha_upper - 1))
+#define mywblank(D,C) ((unsigned)(D - __CTYPE_print_space_nonblank) <= 5 && (D & 1))
+#define mywcntrl(D,C) ((unsigned)(D - __CTYPE_cntrl_space_nonblank) <= 2)
+#define mywdigit(D,C) (D == __CTYPE_digit)
+#define mywgraph(D,C) ((unsigned)(D - 1) <= (__CTYPE_graph - 1))
+#define mywlower(D,C) ((unsigned)(D - __CTYPE_alpha_lower) <= 1)
+#define mywprint(D,C) ((unsigned)(D - 1) <= (__CTYPE_print_space_blank - 1))
+#define mywpunct(D,C) (D == __CTYPE_punct)
+#define mywspace(D,C) ((unsigned)(D - __CTYPE_print_space_nonblank) <= 5)
+#define mywupper(D,C) ((unsigned)(D - __CTYPE_alpha_upper_lower) <= 1)
+/* #define mywxdigit(D,C) -- isxdigit is untestable this way.
+ * But that's ok as isxdigit() (and isdigit() too) are locale-invariant. */
+#define mywxdigit(D,C) (mywdigit(D,C) || (unsigned)(((C) | 0x20) - 'a') <= 5)
typedef struct {
short l;
@@ -159,48 +100,50 @@ typedef struct {
unsigned char *ut;
} table_data;
+static unsigned verbose;
+#define verbose_msg(msg...) if (verbose) fprintf(stderr, msg)
-void output_table(FILE *fp, const char *name, table_data *tbl)
+void output_table(const char *name, table_data *tbl)
{
size_t i;
- fprintf(fp, "#define __LOCALE_DATA_WC%s_II_LEN %7u\n", name, tbl->ii_len);
- fprintf(fp, "#define __LOCALE_DATA_WC%s_TI_LEN %7u\n", name, tbl->ti_len);
- fprintf(fp, "#define __LOCALE_DATA_WC%s_UT_LEN %7u\n", name, tbl->ut_len);
+ printf("#define __LOCALE_DATA_WC%s_II_LEN %7u\n", name, tbl->ii_len);
+ printf("#define __LOCALE_DATA_WC%s_TI_LEN %7u\n", name, tbl->ti_len);
+ printf("#define __LOCALE_DATA_WC%s_UT_LEN %7u\n", name, tbl->ut_len);
- fprintf(fp, "#define __LOCALE_DATA_WC%s_II_SHIFT %7u\n", name, tbl->ii_shift);
- fprintf(fp, "#define __LOCALE_DATA_WC%s_TI_SHIFT %7u\n", name, tbl->ti_shift);
+ printf("#define __LOCALE_DATA_WC%s_II_SHIFT %7u\n", name, tbl->ii_shift);
+ printf("#define __LOCALE_DATA_WC%s_TI_SHIFT %7u\n", name, tbl->ti_shift);
- fprintf(fp, "\n#ifdef WANT_WC%s_data\n", name);
+ printf("\n#ifdef WANT_WC%s_data\n", name);
i = tbl->ii_len + tbl->ti_len + tbl->ut_len;
- fprintf(fp, "\nstatic const unsigned char __LOCALE_DATA_WC%s_data[%zu] = {", name, i);
- for (i=0 ; i < tbl->ii_len ; i++) {
+ printf("\nstatic const unsigned char __LOCALE_DATA_WC%s_data[%zu] = {", name, i);
+ for (i = 0; i < tbl->ii_len; i++) {
if (i % 12 == 0) {
- fprintf(fp, "\n");
+ printf("\n");
}
- fprintf(fp, " %#04x,", tbl->ii[i]);
+ printf(" %#04x,", tbl->ii[i]);
}
- for (i=0 ; i < tbl->ti_len ; i++) {
+ for (i = 0; i < tbl->ti_len; i++) {
if (i % 12 == 0) {
- fprintf(fp, "\n");
+ printf("\n");
}
- fprintf(fp, " %#04x,", tbl->ti[i]);
+ printf(" %#04x,", tbl->ti[i]);
}
- for (i=0 ; i < tbl->ut_len ; i++) {
+ for (i = 0; i < tbl->ut_len; i++) {
if (i % 12 == 0) {
- fprintf(fp, "\n");
+ printf("\n");
}
- fprintf(fp, " %#04x,", tbl->ut[i]);
+ printf(" %#04x,", tbl->ut[i]);
}
- fprintf(fp, "\n};\n\n");
+ printf("\n};\n\n");
- fprintf(fp, "#endif /* WANT_WC%s_data */\n\n", name);
+ printf("#endif /* WANT_WC%s_data */\n\n", name);
}
static void dump_table_data(table_data *tbl)
{
- printf("ii_shift = %d ti_shift = %d\n"
+ verbose_msg("ii_shift = %d ti_shift = %d\n"
"ii_len = %d ti_len = %d ut_len = %d\n"
"total = %d\n",
tbl->ii_shift, tbl->ti_shift,
@@ -231,10 +174,11 @@ int main(int argc, char **argv)
uldiff_entry uldiff[MAXTO];
table_data cttable;
table_data ultable;
+#if 0
table_data combtable;
table_data widthtable;
long int last_comb = 0;
-
+#endif
unsigned char wct[(RANGE/2)+1]; /* wctype table (nibble per wchar) */
unsigned char ult[RANGE+1]; /* upper/lower table */
unsigned char combt[(RANGE/4)+1]; /* combining */
@@ -249,7 +193,7 @@ int main(int argc, char **argv)
#define INIT_TYPENAME(X) typename[__CTYPE_##X] = "C_" #X
- for (i=0 ; i < 16 ; i++) {
+ for (i = 0; i < 16; i++) {
typename[i] = empty_slot;
}
@@ -269,342 +213,348 @@ int main(int argc, char **argv)
INIT_TYPENAME(cntrl_space_blank);
INIT_TYPENAME(cntrl_nonspace);
+ memset(&cttable, 0, sizeof(table_data));
+ memset(&ultable, 0, sizeof(table_data));
+#if 0
+ memset(combtable, 0, sizeof(table_data));
+ memset(widthtable, 0, sizeof(table_data));
+#endif
setvbuf(stdout, NULL, _IONBF, 0);
while (--argc) {
- if (!setlocale(LC_CTYPE, *++argv)) {
- printf("setlocale(LC_CTYPE,%s) failed! Skipping this locale...\n", *argv);
+ ++argv;
+ if (!strcmp(*argv, "-v")) {
+ ++verbose;
continue;
}
-
+ /* setlocale might be just a stub */
+ /* if (!setlocale(LC_CTYPE, *argv)) {
+ verbose_msg("setlocale(LC_CTYPE,%s) failed! Skipping this locale...\n", *argv);
+ continue;
+ }
+ */
if (!(totitle = wctrans("totitle"))) {
- printf("no totitle transformation.\n");
+ verbose_msg("no totitle transformation.\n");
}
if (!(is_comb = wctype("combining"))) {
- printf("no combining wctype.\n");
+ verbose_msg("no combining wctype.\n");
}
if (!(is_comb3 = wctype("combining_level3"))) {
- printf("no combining_level3 wctype.\n");
+ verbose_msg("no combining_level3 wctype.\n");
}
if (!built) {
- built = 1;
- ul_count = 1;
- uldiff[0].u = uldiff[0].l = 0;
+ built = 1;
+ ul_count = 1;
+ uldiff[0].u = uldiff[0].l = 0;
- memset(wct, 0, sizeof(wct));
- memset(combt, 0, sizeof(combt));
- memset(widtht, 0, sizeof(widtht));
+ memset(wct, 0, sizeof(wct));
+ memset(combt, 0, sizeof(combt));
+ memset(widtht, 0, sizeof(widtht));
- for (i = 0 ; i < 16 ; i++) {
- typecount[i] = 0;
- }
+ for (i = 0; i < 16; i++) {
+ typecount[i] = 0;
+ }
- for (c=0 ; c <= RANGE ; c++) {
- if (iswdigit(c)) {
- d = __CTYPE_digit;
- } else if (iswalpha(c)) {
- d = __CTYPE_alpha_nonupper_nonlower;
- if (iswlower(c)) {
- d = __CTYPE_alpha_lower;
- if (iswupper(c)) {
- d = __CTYPE_alpha_upper_lower;
+ for (c = 0; c <= RANGE; c++) {
+ if (iswdigit(c)) {
+ d = __CTYPE_digit;
+ } else if (iswalpha(c)) {
+ d = __CTYPE_alpha_nonupper_nonlower;
+ if (iswlower(c)) {
+ d = __CTYPE_alpha_lower;
+ if (iswupper(c)) {
+ d = __CTYPE_alpha_upper_lower;
+ }
+ } else if (iswupper(c)) {
+ d = __CTYPE_alpha_upper;
}
- } else if (iswupper(c)) {
- d = __CTYPE_alpha_upper;
- }
- } else if (iswpunct(c)) {
- d = __CTYPE_punct;
- } else if (iswgraph(c)) {
- d = __CTYPE_graph;
- } else if (iswprint(c)) {
- d = __CTYPE_print_space_nonblank;
- if (iswblank(c)) {
- d = __CTYPE_print_space_blank;
- }
- } else if (iswspace(c) && !iswcntrl(c)) {
- d = __CTYPE_space_nonblank_noncntrl;
- if (iswblank(c)) {
- d = __CTYPE_space_blank_noncntrl;
- }
- } else if (iswcntrl(c)) {
- d = __CTYPE_cntrl_nonspace;
- if (iswspace(c)) {
- d = __CTYPE_cntrl_space_nonblank;
+ } else if (iswpunct(c)) {
+ d = __CTYPE_punct;
+ } else if (iswgraph(c)) {
+ d = __CTYPE_graph;
+ } else if (iswprint(c)) {
+ d = __CTYPE_print_space_nonblank;
+ if (iswblank(c)) {
+ d = __CTYPE_print_space_blank;
+ }
+ } else if (iswspace(c) && !iswcntrl(c)) {
+ d = __CTYPE_space_nonblank_noncntrl;
if (iswblank(c)) {
- d = __CTYPE_cntrl_space_blank;
+ d = __CTYPE_space_blank_noncntrl;
+ }
+ } else if (iswcntrl(c)) {
+ d = __CTYPE_cntrl_nonspace;
+ if (iswspace(c)) {
+ d = __CTYPE_cntrl_space_nonblank;
+ if (iswblank(c)) {
+ d = __CTYPE_cntrl_space_blank;
+ }
}
+ } else {
+ d = __CTYPE_unclassified;
}
- } else {
- d = __CTYPE_unclassified;
- }
-
- ++typecount[d];
+ ++typecount[d];
#if 0
- if (iswspace(c)) {
- if (iswblank(c)) {
- printf("%#8x : space blank\n", c);
- } else {
- printf("%#8x : space\n", c);
+ if (iswspace(c)) {
+ if (iswblank(c)) {
+ verbose_msg("%#8x : space blank\n", c);
+ } else {
+ verbose_msg("%#8x : space\n", c);
+ }
}
- }
#endif
-
#if 0
- if (c < 256) {
- unsigned int glibc;
-
- glibc = 0;
- if (isalnum(c)) ++glibc; glibc <<= 1;
- if (isalpha(c)) ++glibc; glibc <<= 1;
- if (isblank(c)) ++glibc; glibc <<= 1;
- if (iscntrl(c)) ++glibc; glibc <<= 1;
- if (isdigit(c)) ++glibc; glibc <<= 1;
- if (isgraph(c)) ++glibc; glibc <<= 1;
- if (islower(c)) ++glibc; glibc <<= 1;
- if (isprint(c)) ++glibc; glibc <<= 1;
- if (ispunct(c)) ++glibc; glibc <<= 1;
- if (isspace(c)) ++glibc; glibc <<= 1;
- if (isupper(c)) ++glibc; glibc <<= 1;
- if (isxdigit(c)) ++glibc;
- printf("%#8x : ctype %#4x\n", c, glibc);
- }
+ if (c < 256) {
+ unsigned int curr_stdclib;
+
+ curr_stdclib = 0;
+ if (isalnum(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (isalpha(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (isblank(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iscntrl(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (isdigit(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (isgraph(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (islower(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (isprint(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (ispunct(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (isspace(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (isupper(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (isxdigit(c)) ++curr_stdclib;
+ verbose_msg("%#8x : ctype %#4x\n", c, curr_stdclib);
+ }
#endif
-
#if 1
- /* Paranoid checking... */
- {
- unsigned int glibc;
- unsigned int mine;
-
- glibc = 0;
- if (iswalnum(c)) ++glibc; glibc <<= 1;
- if (iswalpha(c)) ++glibc; glibc <<= 1;
- if (iswblank(c)) ++glibc; glibc <<= 1;
- if (iswcntrl(c)) ++glibc; glibc <<= 1;
- if (iswdigit(c)) ++glibc; glibc <<= 1;
- if (iswgraph(c)) ++glibc; glibc <<= 1;
- if (iswlower(c)) ++glibc; glibc <<= 1;
- if (iswprint(c)) ++glibc; glibc <<= 1;
- if (iswpunct(c)) ++glibc; glibc <<= 1;
- if (iswspace(c)) ++glibc; glibc <<= 1;
- if (iswupper(c)) ++glibc; glibc <<= 1;
- if (iswxdigit(c)) ++glibc;
-
- mine = 0;
- if (mywalnum(c)) ++mine; mine <<= 1;
- if (mywalpha(c)) ++mine; mine <<= 1;
- if (mywblank(c)) ++mine; mine <<= 1;
- if (mywcntrl(c)) ++mine; mine <<= 1;
- if (mywdigit(c)) ++mine; mine <<= 1;
- if (mywgraph(c)) ++mine; mine <<= 1;
- if (mywlower(c)) ++mine; mine <<= 1;
- if (mywprint(c)) ++mine; mine <<= 1;
- if (mywpunct(c)) ++mine; mine <<= 1;
- if (mywspace(c)) ++mine; mine <<= 1;
- if (mywupper(c)) ++mine; mine <<= 1;
- if (mywxdigit(c)) ++mine;
-
- if (glibc != mine) {
- printf("%#8x : glibc %#4x != %#4x mine %u\n", c, glibc, mine, d);
- return EXIT_FAILURE;
- }
-
+ /* Paranoid checking... */
+ {
+ unsigned int curr_stdclib;
+ unsigned int mine;
+
+ curr_stdclib = 0;
+ if (iswalnum(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswalpha(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswblank(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswcntrl(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswdigit(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswgraph(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswlower(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswprint(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswpunct(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswspace(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswupper(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswxdigit(c)) ++curr_stdclib;
+
+ mine = 0;
+ if (mywalnum(d,c)) ++mine; mine <<= 1;
+ if (mywalpha(d,c)) ++mine; mine <<= 1;
+ if (mywblank(d,c)) ++mine; mine <<= 1;
+ if (mywcntrl(d,c)) ++mine; mine <<= 1;
+ if (mywdigit(d,c)) ++mine; mine <<= 1;
+ if (mywgraph(d,c)) ++mine; mine <<= 1;
+ if (mywlower(d,c)) ++mine; mine <<= 1;
+ if (mywprint(d,c)) ++mine; mine <<= 1;
+ if (mywpunct(d,c)) ++mine; mine <<= 1;
+ if (mywspace(d,c)) ++mine; mine <<= 1;
+ if (mywupper(d,c)) ++mine; mine <<= 1;
+ if (mywxdigit(d,c)) ++mine;
+
+ if (curr_stdclib != mine) {
+ verbose_msg("%#8x : curr_stdclib %#4x != %#4x mine %u\n", c, curr_stdclib, mine, d);
+ return EXIT_FAILURE;
+ }
#if 0
- if (iswctype(c,is_comb) || iswctype(c,is_comb3)) {
-/* if (!iswpunct(c)) { */
- printf("%#8x : %d %d %#4x\n",
- c, iswctype(c,is_comb),iswctype(c,is_comb3), glibc);
-/* } */
- }
+ if (iswctype(c,is_comb) || iswctype(c,is_comb3)) {
+/* if (!iswpunct(c)) { */
+ verbose_msg("%#8x : %d %d %#4x\n",
+ c, iswctype(c,is_comb),iswctype(c,is_comb3), curr_stdclib);
+/* } */
+ }
#endif
#if 0
- if (iswctype(c,is_comb) || iswctype(c,is_comb3)) {
- if (!last_comb) {
- printf("%#8x - ", c);
- last_comb = c;
- } else if (last_comb + 1 < c) {
- printf("%#8x\n%#8x - ", last_comb, c);
- last_comb = c;
- } else {
- last_comb = c;
+ if (iswctype(c,is_comb) || iswctype(c,is_comb3)) {
+ if (!last_comb) {
+ verbose_msg("%#8x - ", c);
+ last_comb = c;
+ } else if (last_comb + 1 < c) {
+ verbose_msg("%#8x\n%#8x - ", last_comb, c);
+ last_comb = c;
+ } else {
+ last_comb = c;
+ }
}
- }
#endif
- }
+ }
#endif
- combt[c/4] |= ((((!!iswctype(c,is_comb)) << 1) | !!iswctype(c,is_comb3))
+ combt[c/4] |= ((((!!iswctype(c,is_comb)) << 1) | !!iswctype(c,is_comb3))
<< ((c & 3) << 1));
-/* comb3t[c/8] |= ((!!iswctype(c,is_comb3)) << (c & 7)); */
+/* comb3t[c/8] |= ((!!iswctype(c,is_comb3)) << (c & 7)); */
-/* widtht[c/4] |= (wcwidth(c) << ((c & 3) << 1)); */
+/* widtht[c/4] |= (wcwidth(c) << ((c & 3) << 1)); */
- if (c & 1) { /* Use the high nibble for odd numbered wchars. */
- d <<= 4;
- }
- wct[c/2] |= d;
-
- l = (long)(int) towlower(c) - c;
- u = (long)(int) towupper(c) - c;
- ult[c] = 0;
- if (l || u) {
- if ((l != (short)l) || (u != (short)u)) {
- printf("range assumption error! %x %ld %ld\n", c, l, u);
- return EXIT_FAILURE;
+ if (c & 1) { /* Use the high nibble for odd numbered wchars. */
+ d <<= 4;
}
- for (i=0 ; i < ul_count ; i++) {
- if ((l == uldiff[i].l) && (u == uldiff[i].u)) {
- goto found;
+ wct[c/2] |= d;
+
+ l = (long)(int) towlower(c) - c;
+ u = (long)(int) towupper(c) - c;
+ ult[c] = 0;
+ if (l || u) {
+ if ((l != (short)l) || (u != (short)u)) {
+ verbose_msg("range assumption error! %x %ld %ld\n", c, l, u);
+ return EXIT_FAILURE;
}
+ for (i = 0; i < ul_count; i++) {
+ if ((l == uldiff[i].l) && (u == uldiff[i].u)) {
+ goto found;
+ }
+ }
+ uldiff[ul_count].l = l;
+ uldiff[ul_count].u = u;
+ ++ul_count;
+ if (ul_count > MAXTO) {
+ verbose_msg("too many touppers/tolowers!\n");
+ return EXIT_FAILURE;
+ }
+ found:
+ ult[c] = i;
}
- uldiff[ul_count].l = l;
- uldiff[ul_count].u = u;
- ++ul_count;
- if (ul_count > MAXTO) {
- printf("too many touppers/tolowers!\n");
- return EXIT_FAILURE;
- }
- found:
- ult[c] = i;
}
- }
-
- for (i = 0 ; i < 16 ; i++) {
- printf("typecount[%2d] = %8ld %s\n", i, typecount[i], typename[i]);
- }
- printf("optimizing is* table..\n");
- n = -1;
- smallest = SIZE_MAX;
- cttable.ii = NULL;
- for (i=0 ; i < 14 ; i++) {
- t = newopt(wct, (RANGE/2)+1, i, &cttable);
- if (smallest >= t) {
- n = i;
- smallest = t;
-/* } else { */
-/* break; */
+ for (i = 0; i < 16; i++) {
+ verbose_msg("typecount[%2d] = %8ld %s\n", i, typecount[i], typename[i]);
}
- }
- printf("smallest = %zu\n", smallest);
- if (!(cttable.ii = malloc(smallest))) {
- printf("couldn't allocate space!\n");
- return EXIT_FAILURE;
- }
- smallest = SIZE_MAX;
- newopt(wct, (RANGE/2)+1, n, &cttable);
- ++cttable.ti_shift; /* correct for nibble mode */
-
-
- printf("optimizing u/l-to table..\n");
- smallest = SIZE_MAX;
- ultable.ii = NULL;
- for (i=0 ; i < 14 ; i++) {
- t = newopt(ult, RANGE+1, i, &ultable);
- if (smallest >= t) {
- n = i;
- smallest = t;
-/* } else { */
-/* break; */
+ verbose_msg("optimizing is* table..\n");
+ n = -1;
+ smallest = SIZE_MAX;
+ cttable.ii = NULL;
+ for (i = 0; i < 14; i++) {
+ t = newopt(wct, (RANGE/2)+1, i, &cttable);
+ if (smallest >= t) {
+ n = i;
+ smallest = t;
+/* } else { */
+/* break; */
+ }
}
- }
- printf("%zu (smallest) + %zu (u/l diffs) = %zu\n",
- smallest, 4 * ul_count, smallest + 4 * ul_count);
- printf("smallest = %zu\n", smallest);
- if (!(ultable.ii = malloc(smallest))) {
- printf("couldn't allocate space!\n");
- return EXIT_FAILURE;
- }
- smallest = SIZE_MAX;
- newopt(ult, RANGE+1, n, &ultable);
-
-
+ verbose_msg("smallest = %zu\n", smallest);
+ if (!(cttable.ii = malloc(smallest))) {
+ verbose_msg("couldn't allocate space!\n");
+ return EXIT_FAILURE;
+ }
+ smallest = SIZE_MAX;
+ newopt(wct, (RANGE/2)+1, n, &cttable);
+ ++cttable.ti_shift; /* correct for nibble mode */
+
+ verbose_msg("optimizing u/l-to table..\n");
+ smallest = SIZE_MAX;
+ ultable.ii = NULL;
+ for (i = 0; i < 14; i++) {
+ t = newopt(ult, RANGE+1, i, &ultable);
+ if (smallest >= t) {
+ n = i;
+ smallest = t;
+/* } else { */
+/* break; */
+ }
+ }
+ verbose_msg("%lu (smallest) + %lu (u/l diffs) = %lu\n",
+ (unsigned long) smallest,
+ (unsigned long) (4 * ul_count),
+ (unsigned long) (smallest + 4 * ul_count)
+ );
+ verbose_msg("smallest = %zu\n", smallest);
+ if (!(ultable.ii = malloc(smallest))) {
+ verbose_msg("couldn't allocate space!\n");
+ return EXIT_FAILURE;
+ }
+ smallest = SIZE_MAX;
+ newopt(ult, RANGE+1, n, &ultable);
#if 0
- printf("optimizing comb table..\n");
- smallest = SIZE_MAX;
- combtable.ii = NULL;
- for (i=0 ; i < 14 ; i++) {
- t = newopt(combt, sizeof(combt), i, &combtable);
- if (smallest >= t) {
- n = i;
- smallest = t;
-/* } else { */
-/* break; */
+ verbose_msg("optimizing comb table..\n");
+ smallest = SIZE_MAX;
+ combtable.ii = NULL;
+ for (i = 0; i < 14; i++) {
+ t = newopt(combt, sizeof(combt), i, &combtable);
+ if (smallest >= t) {
+ n = i;
+ smallest = t;
+/* } else { */
+/* break; */
+ }
}
- }
- printf("smallest = %zu\n", smallest);
- if (!(combtable.ii = malloc(smallest))) {
- printf("couldn't allocate space!\n");
- return EXIT_FAILURE;
- }
- smallest = SIZE_MAX;
- newopt(combt, sizeof(combt), n, &combtable);
- combtable.ti_shift += 4; /* correct for 4 entries per */
+ verbose_msg("smallest = %zu\n", smallest);
+ if (!(combtable.ii = malloc(smallest))) {
+ verbose_msg("couldn't allocate space!\n");
+ return EXIT_FAILURE;
+ }
+ smallest = SIZE_MAX;
+ newopt(combt, sizeof(combt), n, &combtable);
+ combtable.ti_shift += 4; /* correct for 4 entries per */
#endif
-
-
#if 0
- printf("optimizing width table..\n");
- smallest = SIZE_MAX;
- widthtable.ii = NULL;
- for (i=0 ; i < 14 ; i++) {
- t = newopt(widtht, sizeof(widtht), i, &widthtable);
- if (smallest >= t) {
- n = i;
- smallest = t;
-/* } else { */
-/* break; */
+ verbose_msg("optimizing width table..\n");
+ smallest = SIZE_MAX;
+ widthtable.ii = NULL;
+ for (i = 0; i < 14; i++) {
+ t = newopt(widtht, sizeof(widtht), i, &widthtable);
+ if (smallest >= t) {
+ n = i;
+ smallest = t;
+/* } else { */
+/* break; */
+ }
}
- }
- printf("smallest = %zu\n", smallest);
- if (!(widthtable.ii = malloc(smallest))) {
- printf("couldn't allocate space!\n");
- return EXIT_FAILURE;
- }
- smallest = SIZE_MAX;
- newopt(widtht, sizeof(widtht), n, &widthtable);
- widthtable.ti_shift += 4; /* correct for 4 entries per */
+ verbose_msg("smallest = %zu\n", smallest);
+ if (!(widthtable.ii = malloc(smallest))) {
+ verbose_msg("couldn't allocate space!\n");
+ return EXIT_FAILURE;
+ }
+ smallest = SIZE_MAX;
+ newopt(widtht, sizeof(widtht), n, &widthtable);
+ widthtable.ti_shift += 4; /* correct for 4 entries per */
#endif
-
#if 0
- printf("optimizing comb3 table..\n");
- smallest = SIZE_MAX;
- comb3table.ii = NULL;
- for (i=0 ; i < 14 ; i++) {
- t = newopt(comb3t, sizeof(comb3t), i, &comb3table);
- if (smallest >= t) {
- n = i;
- smallest = t;
-/* } else { */
-/* break; */
+ verbose_msg("optimizing comb3 table..\n");
+ smallest = SIZE_MAX;
+ comb3table.ii = NULL;
+ for (i = 0; i < 14; i++) {
+ t = newopt(comb3t, sizeof(comb3t), i, &comb3table);
+ if (smallest >= t) {
+ n = i;
+ smallest = t;
+/* } else { */
+/* break; */
+ }
}
- }
- printf("smallest = %zu\n", smallest);
- if (!(comb3table.ii = malloc(smallest))) {
- printf("couldn't allocate space!\n");
- return EXIT_FAILURE;
- }
- smallest = SIZE_MAX;
- newopt(comb3t, sizeof(comb3t), n, &comb3table);
- comb3table.ti_shift += 8; /* correct for 4 entries per */
+ verbose_msg("smallest = %zu\n", smallest);
+ if (!(comb3table.ii = malloc(smallest))) {
+ verbose_msg("couldn't allocate space!\n");
+ return EXIT_FAILURE;
+ }
+ smallest = SIZE_MAX;
+ newopt(comb3t, sizeof(comb3t), n, &comb3table);
+ comb3table.ti_shift += 8; /* correct for 4 entries per */
#endif
- dump_table_data(&cttable);
- dump_table_data(&ultable);
- dump_table_data(&combtable);
+ dump_table_data(&cttable);
+ dump_table_data(&ultable);
+#if 0
+ dump_table_data(&combtable);
+#endif
}
- printf("verifying for %s...\n", *argv);
+ verbose_msg("verifying for %s...\n", *argv);
#if RANGE == 0xffffU
- for (c=0 ; c <= 0xffffUL ; c++)
+ for (c = 0; c <= 0xffffUL; c++)
#else
- for (c=0 ; c <= 0x10ffffUL ; c++)
+ for (c = 0; c <= 0x10ffffUL; c++)
#endif
- {
- unsigned int glibc;
+ {
+ unsigned int curr_stdclib;
unsigned int mine;
unsigned int upper, lower;
@@ -619,25 +569,24 @@ int main(int argc, char **argv)
}
#endif
#endif
-
- glibc = 0;
- if (iswalnum(c)) ++glibc; glibc <<= 1;
- if (iswalpha(c)) ++glibc; glibc <<= 1;
- if (iswblank(c)) ++glibc; glibc <<= 1;
- if (iswcntrl(c)) ++glibc; glibc <<= 1;
- if (iswdigit(c)) ++glibc; glibc <<= 1;
- if (iswgraph(c)) ++glibc; glibc <<= 1;
- if (iswlower(c)) ++glibc; glibc <<= 1;
- if (iswprint(c)) ++glibc; glibc <<= 1;
- if (iswpunct(c)) ++glibc; glibc <<= 1;
- if (iswspace(c)) ++glibc; glibc <<= 1;
- if (iswupper(c)) ++glibc; glibc <<= 1;
- if (iswxdigit(c)) ++glibc;
+ curr_stdclib = 0;
+ if (iswalnum(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswalpha(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswblank(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswcntrl(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswdigit(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswgraph(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswlower(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswprint(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswpunct(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswspace(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswupper(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswxdigit(c)) ++curr_stdclib;
{
unsigned int u;
- int n, sc;
- int i0, i1;
+ int n = 0, sc = 0; /* = 0 for verbose_msg only */
+ int i0 = 0, i1 = 0;
u = c;
if (u <= RANGE) {
@@ -649,16 +598,16 @@ int main(int argc, char **argv)
i0 = cttable.ii[u];
i0 <<= cttable.ii_shift;
i1 = cttable.ti[i0 + n];
- i1 <<= (cttable.ti_shift-1);
+ i1 <<= (cttable.ti_shift - 1);
d = cttable.ut[i1 + (sc >> 1)];
if (sc & 1) {
d >>= 4;
}
d &= 0x0f;
- } else if ((((unsigned int)(c - 0xe0020UL)) <= 0x5f) || (c == 0xe0001UL)){
+ } else if (((unsigned)(c - 0xe0020UL) <= 0x5f) || (c == 0xe0001UL)) {
d = __CTYPE_punct;
- } else if (((unsigned int)(c - 0xf0000UL)) < 0x20000UL) {
+ } else if ((unsigned)(c - 0xf0000UL) < 0x20000UL) {
if ((c & 0xffffU) <= 0xfffdU) {
d = __CTYPE_punct;
} else {
@@ -668,26 +617,27 @@ int main(int argc, char **argv)
d = __CTYPE_unclassified;
}
- mine = 0;
- if (mywalnum(c)) ++mine; mine <<= 1;
- if (mywalpha(c)) ++mine; mine <<= 1;
- if (mywblank(c)) ++mine; mine <<= 1;
- if (mywcntrl(c)) ++mine; mine <<= 1;
- if (mywdigit(c)) ++mine; mine <<= 1;
- if (mywgraph(c)) ++mine; mine <<= 1;
- if (mywlower(c)) ++mine; mine <<= 1;
- if (mywprint(c)) ++mine; mine <<= 1;
- if (mywpunct(c)) ++mine; mine <<= 1;
- if (mywspace(c)) ++mine; mine <<= 1;
- if (mywupper(c)) ++mine; mine <<= 1;
- if (mywxdigit(c)) ++mine;
-
- if (glibc != mine) {
- printf("%#8x : glibc %#4x != %#4x mine %d\n", c, glibc, mine, d);
- if (c < 0x30000UL) {
- printf("sc=%#x u=%#x n=%#x i0=%#x i1=%#x\n", sc, u, n, i0, i1);
+ mine = 0;
+ if (mywalnum(d,c)) ++mine; mine <<= 1;
+ if (mywalpha(d,c)) ++mine; mine <<= 1;
+ if (mywblank(d,c)) ++mine; mine <<= 1;
+ if (mywcntrl(d,c)) ++mine; mine <<= 1;
+ if (mywdigit(d,c)) ++mine; mine <<= 1;
+ if (mywgraph(d,c)) ++mine; mine <<= 1;
+ if (mywlower(d,c)) ++mine; mine <<= 1;
+ if (mywprint(d,c)) ++mine; mine <<= 1;
+ if (mywpunct(d,c)) ++mine; mine <<= 1;
+ if (mywspace(d,c)) ++mine; mine <<= 1;
+ if (mywupper(d,c)) ++mine; mine <<= 1;
+ if (mywxdigit(d,c)) ++mine;
+
+ if (curr_stdclib != mine) {
+ verbose_msg("%#8x : curr_stdclib %#4x != %#4x mine %d\n", c, curr_stdclib, mine, d);
+ if (c < 0x30000UL) {
+ verbose_msg("sc=%#x u=%#x n=%#x i0=%#x i1=%#x\n", sc, u, n, i0, i1);
+ }
}
- }
+
upper = lower = u = c;
if (u <= RANGE) {
sc = u & ((1 << ultable.ti_shift) - 1);
@@ -705,64 +655,52 @@ int main(int argc, char **argv)
lower = c + uldiff[i0].l;
}
- if (towupper(c) != upper) {
- printf("%#8x : towupper glibc %#4x != %#4x mine\n",
- c, towupper(c), upper);
- }
+ if (towupper(c) != upper) {
+ verbose_msg("%#8x : towupper curr_stdclib %#4x != %#4x mine\n",
+ c, towupper(c), upper);
+ }
- if (towlower(c) != lower) {
- printf("%#8x : towlower glibc %#4x != %#4x mine i0 = %d\n",
- c, towlower(c), lower, i0);
- }
+ if (towlower(c) != lower) {
+ verbose_msg("%#8x : towlower curr_stdclib %#4x != %#4x mine i0 = %d\n",
+ c, towlower(c), lower, i0);
+ }
- if (totitle && ((tt = towctrans(c, totitle)) != upper)) {
- printf("%#8x : totitle glibc %#4lx != %#4x mine i0 = %d\n",
- c, tt, upper, i0);
- }
+ if (totitle && ((tt = towctrans(c, totitle)) != upper)) {
+ verbose_msg("%#8x : totitle curr_stdclib %#4lx != %#4x mine i0 = %d\n",
+ c, tt, upper, i0);
+ }
}
-
- if ((c & 0xfff) == 0xfff) printf(".");
+ if ((c & 0xfff) == 0xfff) verbose_msg(".");
}
- printf("done\n");
+ verbose_msg("done\n");
}
- if (1) {
- FILE *fp;
-
- if (!(fp = fopen("wctables.h", "w"))) {
- printf("couldn't open wctables.h!\n");
- return EXIT_FAILURE;
- }
-
- fprintf(fp, "#define __LOCALE_DATA_WC_TABLE_DOMAIN_MAX %#8lx\n\n",
+ if (built) {
+ printf("#define __LOCALE_DATA_WC_TABLE_DOMAIN_MAX %#8lx\n\n",
(unsigned long) RANGE);
- output_table(fp, "ctype", &cttable);
- output_table(fp, "uplow", &ultable);
-
+ output_table("ctype", &cttable);
+ output_table("uplow", &ultable);
#warning fix the upper bound on the upper/lower tables... save 200 bytes or so
- fprintf(fp, "#define __LOCALE_DATA_WCuplow_diffs %7u\n", ul_count);
- fprintf(fp, "\n#ifdef WANT_WCuplow_diff_data\n\n");
- fprintf(fp, "\nstatic const short __LOCALE_DATA_WCuplow_diff_data[%zu] = {",
+ printf("#define __LOCALE_DATA_WCuplow_diffs %7u\n", ul_count);
+ printf("\n#ifdef WANT_WCuplow_diff_data\n\n");
+ printf("\nstatic const short __LOCALE_DATA_WCuplow_diff_data[%zu] = {",
2 * (size_t) ul_count);
- for (i=0 ; i < ul_count ; i++) {
+ for (i = 0; i < ul_count; i++) {
if (i % 4 == 0) {
- fprintf(fp, "\n");
+ printf("\n");
}
- fprintf(fp, " %6d, %6d,", uldiff[i].u, uldiff[i].l);
+ printf(" %6d, %6d,", uldiff[i].u, uldiff[i].l);
}
- fprintf(fp, "\n};\n\n");
- fprintf(fp, "#endif /* WANT_WCuplow_diff_data */\n\n");
-
-
-/* output_table(fp, "comb", &combtable); */
-/* output_table(fp, "width", &widthtable); */
+ printf("\n};\n\n");
+ printf("#endif /* WANT_WCuplow_diff_data */\n\n");
- fclose(fp);
+/* output_table("comb", &combtable); */
+/* output_table("width", &widthtable); */
}
- return EXIT_SUCCESS;
+ return !built;
}
size_t newopt(unsigned char *ut, size_t usize, int shift, table_data *tbl)
@@ -786,7 +724,7 @@ size_t newopt(unsigned char *ut, size_t usize, int shift, table_data *tbl)
numblocks = usize >> shift;
/* init table index */
- for (i=j=0 ; i < numblocks ; i++) {
+ for (i=j = 0; i < numblocks; i++) {
ti[i] = ut + j;
j += blocksize;
}
@@ -797,7 +735,7 @@ size_t newopt(unsigned char *ut, size_t usize, int shift, table_data *tbl)
uniq = 1;
uit[(ti[0]-ut)/blocksize] = 0;
- for (i=1 ; i < numblocks ; i++) {
+ for (i=1; i < numblocks; i++) {
if (memcmp(ti[i-1], ti[i], blocksize) < 0) {
if (++uniq > 255) {
break;
@@ -806,7 +744,7 @@ size_t newopt(unsigned char *ut, size_t usize, int shift, table_data *tbl)
}
#if 1
else if (memcmp(ti[i-1], ti[i], blocksize) > 0) {
- printf("bad sort %i!\n", i);
+ verbose_msg("bad sort %li!\n", (long) i);
abort();
}
#endif
@@ -815,37 +753,37 @@ size_t newopt(unsigned char *ut, size_t usize, int shift, table_data *tbl)
smallest = SIZE_MAX;
shift2 = -1;
- if (uniq <= 255) {
- smallest = numblocks + uniq * blocksize;
- if (!recurse) {
- ++recurse;
- for (j=1 ; j < 14 ; j++) {
- if ((numblocks >> j) < 2) break;
- if (tbl) {
- ii_save = tbl->ii;
- tbl->ii = NULL;
- }
- if ((t = newopt(uit, numblocks, j, tbl)) < SIZE_MAX) {
- t += uniq * blocksize;
- }
- if (tbl) {
- tbl->ii = ii_save;
- }
- if (smallest >= t) {
- shift2 = j;
- smallest = t;
- if (!tbl->ii) {
- printf("ishift %zu tshift %zu size %zu\n",
- shift2, shift, t);
- }
-/* } else { */
-/* break; */
+
+ if (uniq > 255)
+ return SIZE_MAX;
+
+ smallest = numblocks + uniq * blocksize;
+ if (!recurse) {
+ ++recurse;
+ for (j=1; j < 14; j++) {
+ if ((numblocks >> j) < 2) break;
+ if (tbl) {
+ ii_save = tbl->ii;
+ tbl->ii = NULL;
+ }
+ if ((t = newopt(uit, numblocks, j, tbl)) < SIZE_MAX) {
+ t += uniq * blocksize;
+ }
+ if (tbl) {
+ tbl->ii = ii_save;
+ }
+ if (smallest >= t) {
+ shift2 = j;
+ smallest = t;
+ if (!tbl->ii) {
+ verbose_msg("ishift %u tshift %u size %lu\n",
+ shift2, shift, (unsigned long) t);
}
+/* } else { */
+/* break; */
}
- --recurse;
}
- } else {
- return SIZE_MAX;
+ --recurse;
}
if (tbl->ii) {
@@ -855,22 +793,23 @@ size_t newopt(unsigned char *ut, size_t usize, int shift, table_data *tbl)
memcpy(tbl->ii, uit, numblocks);
tbl->ti = tbl->ii + tbl->ii_len;
tbl->ti_len = uniq * blocksize;
- for (i=0 ; i < uniq ; i++) {
+ for (i = 0; i < uniq; i++) {
memcpy(tbl->ti + i * blocksize, ti[uniqblock[i]], blocksize);
}
} else {
++recurse;
- printf("setting ishift %zu tshift %zu\n",
+ verbose_msg("setting ishift %u tshift %u\n",
shift2, shift);
newopt(uit, numblocks, shift2, tbl);
--recurse;
tbl->ti_shift = shift;
tbl->ut_len = uniq * blocksize;
tbl->ut = tbl->ti + tbl->ti_len;
- for (i=0 ; i < uniq ; i++) {
+ for (i = 0; i < uniq; i++) {
memcpy(tbl->ut + i * blocksize, ti[uniqblock[i]], blocksize);
}
}
}
return smallest;
}
+/* vi: set sw=4 ts=4: */
diff --git a/extra/locale/lmmtolso.c b/extra/locale/lmmtolso.c
index a1876a7dc..2437a8f69 100644
--- a/extra/locale/lmmtolso.c
+++ b/extra/locale/lmmtolso.c
@@ -14,18 +14,18 @@ int main(void)
size_t i;
if (!(lmm = fopen("locale.mmap", "r"))) {
- printf("can't open locale.mmap!\n");
+ printf("cannot open locale.mmap!\n");
return EXIT_FAILURE;
}
if (fstat(fileno(lmm), &fd_stat)) {
- printf("can't stat locale.mmap!\n");
+ printf("cannot stat locale.mmap!\n");
fclose(lmm);
return EXIT_FAILURE;
}
if (!(lso = fopen("locale_data.c", "w"))) {
- printf("can't open locale_data.c!\n");
+ printf("cannot open locale_data.c!\n");
fclose(lmm);
return EXIT_FAILURE;
}
diff --git a/extra/locale/locale_mmap.h b/extra/locale/locale_mmap.h
index 1b748239b..5b0df9074 100644
--- a/extra/locale/locale_mmap.h
+++ b/extra/locale/locale_mmap.h
@@ -8,34 +8,34 @@
/* TODO - fix */
#ifdef __WCHAR_ENABLED
-#define __LOCALE_DATA_WCctype_TBL_LEN (__LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + __LOCALE_DATA_WCctype_UT_LEN)
-#define __LOCALE_DATA_WCuplow_TBL_LEN (__LOCALE_DATA_WCuplow_II_LEN + __LOCALE_DATA_WCuplow_TI_LEN + __LOCALE_DATA_WCuplow_UT_LEN)
+#define __LOCALE_DATA_WCctype_TBL_LEN (__LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + __LOCALE_DATA_WCctype_UT_LEN)
+#define __LOCALE_DATA_WCuplow_TBL_LEN (__LOCALE_DATA_WCuplow_II_LEN + __LOCALE_DATA_WCuplow_TI_LEN + __LOCALE_DATA_WCuplow_UT_LEN)
#define __LOCALE_DATA_WCuplow_diff_TBL_LEN (2 * __LOCALE_DATA_WCuplow_diffs)
/* #define WCcomb_TBL_LEN (WCcomb_II_LEN + WCcomb_TI_LEN + WCcomb_UT_LEN) */
#endif
#undef __PASTE2
-#define __PASTE2(A,B) A ## B
+#define __PASTE2(A,B) A ## B
#undef __PASTE3
-#define __PASTE3(A,B,C) A ## B ## C
+#define __PASTE3(A,B,C) A ## B ## C
#define __LOCALE_DATA_COMMON_MMAP(X) \
- unsigned char __PASTE3(lc_,X,_data)[__PASTE3(__lc_,X,_data_LEN)];
+ unsigned char __PASTE3(lc_,X,_data)[__PASTE3(__lc_,X,_data_LEN)];
#define __LOCALE_DATA_COMMON_MMIDX(X) \
- unsigned char __PASTE3(lc_,X,_rows)[__PASTE3(__lc_,X,_rows_LEN)]; \
- uint16_t __PASTE3(lc_,X,_item_offsets)[__PASTE3(__lc_,X,_item_offsets_LEN)]; \
- uint16_t __PASTE3(lc_,X,_item_idx)[__PASTE3(__lc_,X,_item_idx_LEN)]; \
+ unsigned char __PASTE3(lc_,X,_rows)[__PASTE3(__lc_,X,_rows_LEN)]; \
+ uint16_t __PASTE3(lc_,X,_item_offsets)[__PASTE3(__lc_,X,_item_offsets_LEN)]; \
+ uint16_t __PASTE3(lc_,X,_item_idx)[__PASTE3(__lc_,X,_item_idx_LEN)]; \
typedef struct {
#ifdef __LOCALE_DATA_MAGIC_SIZE
unsigned char magic[__LOCALE_DATA_MAGIC_SIZE];
-#endif /* __LOCALE_DATA_MAGIC_SIZE */
+#endif
#ifdef __CTYPE_HAS_8_BIT_LOCALES
const unsigned char tbl8ctype[__LOCALE_DATA_Cctype_TBL_LEN];
- const unsigned char tbl8uplow[__LOCALE_DATA_Cuplow_TBL_LEN];
+ const unsigned char tbl8uplow[__LOCALE_DATA_Cuplow_TBL_LEN];
#ifdef __WCHAR_ENABLED
const uint16_t tbl8c2wc[__LOCALE_DATA_Cc2wc_TBL_LEN]; /* char > 0x7f to wide char */
const unsigned char tbl8wc2c[__LOCALE_DATA_Cwc2c_TBL_LEN];
@@ -48,31 +48,31 @@ typedef struct {
const int16_t tblwuplow_diff[__LOCALE_DATA_WCuplow_diff_TBL_LEN];
/* const unsigned char tblwcomb[WCcomb_TBL_LEN]; */
/* width?? */
-#endif /* __WCHAR_ENABLED */
+#endif
- __LOCALE_DATA_COMMON_MMAP(ctype);
- __LOCALE_DATA_COMMON_MMAP(numeric);
- __LOCALE_DATA_COMMON_MMAP(monetary);
- __LOCALE_DATA_COMMON_MMAP(time);
+ __LOCALE_DATA_COMMON_MMAP(ctype)
+ __LOCALE_DATA_COMMON_MMAP(numeric)
+ __LOCALE_DATA_COMMON_MMAP(monetary)
+ __LOCALE_DATA_COMMON_MMAP(time)
/* collate is different */
- __LOCALE_DATA_COMMON_MMAP(messages);
+ __LOCALE_DATA_COMMON_MMAP(messages)
#ifdef __CTYPE_HAS_8_BIT_LOCALES
const __codeset_8_bit_t codeset_8_bit[__LOCALE_DATA_NUM_CODESETS];
-#endif /* __CTYPE_HAS_8_BIT_LOCALES */
+#endif
- __LOCALE_DATA_COMMON_MMIDX(ctype);
- __LOCALE_DATA_COMMON_MMIDX(numeric);
- __LOCALE_DATA_COMMON_MMIDX(monetary);
- __LOCALE_DATA_COMMON_MMIDX(time);
+ __LOCALE_DATA_COMMON_MMIDX(ctype)
+ __LOCALE_DATA_COMMON_MMIDX(numeric)
+ __LOCALE_DATA_COMMON_MMIDX(monetary)
+ __LOCALE_DATA_COMMON_MMIDX(time)
/* collate is different */
- __LOCALE_DATA_COMMON_MMIDX(messages);
+ __LOCALE_DATA_COMMON_MMIDX(messages)
const uint16_t collate_data[__lc_collate_data_LEN];
unsigned char lc_common_item_offsets_LEN[__LOCALE_DATA_CATEGORIES];
- size_t lc_common_tbl_offsets[__LOCALE_DATA_CATEGORIES * 4];
+ size_t lc_common_tbl_offsets[__LOCALE_DATA_CATEGORIES * 4];
/* offsets from start of locale_mmap_t */
/* rows, item_offsets, item_idx, data */
@@ -80,14 +80,12 @@ typedef struct {
unsigned char locales[__LOCALE_DATA_NUM_LOCALES * __LOCALE_DATA_WIDTH_LOCALES];
unsigned char locale_names5[5*__LOCALE_DATA_NUM_LOCALE_NAMES];
unsigned char locale_at_modifiers[__LOCALE_DATA_AT_MODIFIERS_LENGTH];
-#endif /* __LOCALE_DATA_NUM_LOCALES */
+#endif
unsigned char lc_names[__lc_names_LEN];
#ifdef __CTYPE_HAS_8_BIT_LOCALES
unsigned char codeset_list[sizeof(__LOCALE_DATA_CODESET_LIST)]; /* TODO - fix */
-#endif /* __CTYPE_HAS_8_BIT_LOCALES */
-
-
+#endif
} __locale_mmap_t;
extern const __locale_mmap_t *__locale_mmap;
diff --git a/extra/locale/programs/locale.c b/extra/locale/programs/locale.c
index c8b76bd65..c9fd1f3c2 100644
--- a/extra/locale/programs/locale.c
+++ b/extra/locale/programs/locale.c
@@ -1,3 +1,4 @@
+/* vi: set sw=4 ts=4: */
/*
*
* Copyright (c) 2008 STMicroelectronics Ltd
@@ -9,12 +10,14 @@
*
*/
-
+#include <string.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <langinfo.h>
+#include <unistd.h>
+#ifdef __UCLIBC_HAS_GETOPT_LONG__
#include <getopt.h>
+#endif
typedef struct {
unsigned char idx_name;
@@ -28,7 +31,7 @@ typedef struct {
unsigned char lc_messages_row;
} locale_entry;
-/* Need to include this before locale.h and xlocale.h! */
+/* Need to include this before locale.h! */
#include <bits/uClibc_locale.h>
#undef CODESET_LIST
@@ -39,7 +42,7 @@ typedef struct {
#define LOCALE_AT_MODIFIERS (__locale_mmap->locale_at_modifiers)
#define CATEGORY_NAMES (__locale_mmap->lc_names)
-#define GET_CODESET_NAME(N) (CODESET_LIST + *(CODESET_LIST + N - 3))
+#define GET_CODESET_NAME(N) (const char *)(CODESET_LIST + *(CODESET_LIST + N - 3))
#define GET_LOCALE_ENTRY(R) (locale_entry *)(LOCALES + (__LOCALE_DATA_WIDTH_LOCALES * R))
#define GET_CATEGORY_NAME(X) (CATEGORY_NAMES + *(CATEGORY_NAMES + X))
#define GET_LOCALE_NAME(I) (const char *)(LOCALE_NAMES + 5 * (I - 1))
@@ -129,28 +132,47 @@ static void usage(const char *name)
const char *s;
s = basename(name);
+#ifdef __UCLIBC_HAS_GETOPT_LONG__
fprintf(stderr,
- "Usage: %s [-ck] [--category-name] [--keyword-name] [--help] NAME\n"
- "or: %s [OPTION...] [-a|-m] [--all-locales] [--charmaps] \n", s,
- s);
+ "Usage: %s [-a | -m] [FORMAT] name...\n\n"
+ "\t-a, --all-locales\tWrite names of all available locales\n"
+ "\t-m, --charmaps\tWrite names of available charmaps\n"
+ "\nFORMAT:\n"
+ "\t-c, --category-name\tWrite names of selected categories\n"
+ "\t-k, --keyword-name\tWrite names of selected keywords\n"
+ , s);
+#else
+ fprintf(stderr,
+ "Usage: %s [-a | -m] [FORMAT] name...\n\n"
+ "\t-a\tWrite names of all available locales\n"
+ "\t-m\tWrite names of available charmaps\n"
+ "\nFORMAT:\n"
+ "\t-c\tWrite names of selected categories\n"
+ "\t-k\tWrite names of selected keywords\n"
+ , s);
+#endif
}
static int argp_parse(int argc, char *argv[]);
static int argp_parse(int argc, char *argv[])
{
+ int c;
+ char *progname;
+#ifdef __UCLIBC_HAS_GETOPT_LONG__
static const struct option long_options[] = {
{"all-locales", no_argument, NULL, 'a'},
{"charmaps", no_argument, NULL, 'm'},
{"category-name", no_argument, NULL, 'c'},
{"keyword-name", no_argument, NULL, 'k'},
{"help", no_argument, NULL, 'h'},
- {NULL, 0, NULL, 0}
- };
- int c;
- char *progname;
-
+ {NULL, 0, NULL, 0}};
+#endif
progname = *argv;
+#ifdef __UCLIBC_HAS_GETOPT_LONG__
while ((c = getopt_long(argc, argv, "amckh", long_options, NULL)) >= 0)
+#else
+ while ((c = getopt(argc, argv, "amckh")) >= 0)
+#endif
switch (c) {
case 'a':
do_all = 1;
@@ -215,8 +237,10 @@ static void find_locale_string(locale_entry * loc_rec, char *loc)
if (loc[2] == '_') {
sprintf(loc, "%5.5s%c%s\0", loc, (dotcs != 0) ? '.' : ' ',
- (cs ==
- 1) ? ascii : ((cs == 2) ? utf8 : GET_CODESET_NAME(cs)));
+ (cs == 1) ? ascii
+ : ((cs == 2) ?
+ utf8
+: GET_CODESET_NAME(cs)));
} else {
at = loc[2];
loc[2] = '_';
diff --git a/extra/scripts/.gitignore b/extra/scripts/.gitignore
new file mode 100644
index 000000000..d13eda94e
--- /dev/null
+++ b/extra/scripts/.gitignore
@@ -0,0 +1 @@
+unifdef
diff --git a/extra/scripts/MAKEALL b/extra/scripts/MAKEALL
new file mode 100755
index 000000000..f46d3bd66
--- /dev/null
+++ b/extra/scripts/MAKEALL
@@ -0,0 +1,146 @@
+#!/bin/sh
+#
+# helper script to quick build testing with cross-compilers
+#
+
+: ${MAKE:=make}
+
+: ${BUILD_NCPUS:=$(getconf _NPROCESSORS_ONLN)}
+if [ "$BUILD_NCPUS" -gt 1 ] ; then
+ JOBS=-j$((BUILD_NCPUS + 1))
+else
+ JOBS=""
+fi
+MAKE="${MAKE} ${JOBS}"
+
+: ${CROSS_COMPILE:=${CROSS_COMPILER_PREFIX}}
+
+setconfig()
+{
+ local opt=$1
+ shift
+ case $1 in
+ [yn]) ;;
+ [0-9]*) ;;
+ *) set -- '"'$*'"'
+ esac
+ sed -i \
+ -e "/${opt}=/s:=.*:=$*:" \
+ .config
+ echo " ## setconfig ${opt} $*"
+}
+
+get_arches()
+{
+ case $1 in
+ hppa) echo hppa hppa2.0 hppa1.1 hppa1.0;;
+ i386) echo i386 i486 i586 i686;;
+ sh) echo sh4 sh2 sh3 sh1 sh;;
+ sparc) echo sparc sparc64;;
+ *) echo $1;;
+ esac
+}
+
+find_compiler()
+{
+ local t a v o l
+ for a in $(get_arches $1) ; do
+ for l in uclibc gnu gnueabi "" ; do
+ for v in unknown pc gentoo "" ; do
+ for o in linux uclinux "" ; do
+ t="${a}${v:+-${v}}${o:+-${o}}${l:+-${l}}"
+ if ${t}-gcc --help > /dev/null 2>&1 ; then
+ echo ${t}-
+ return 0
+ fi
+ done
+ done
+ done
+ done
+}
+
+do_make()
+{
+ echo " ## ${MAKE} -s $*"
+ ${MAKE} -s "$@"
+}
+
+mark_arch()
+{
+ local r=$1 a=$2
+ eval $r=\"\$$r $a\"
+}
+
+if [ -z "$*" ] ; then
+ set -- $(awk \
+ '$0 ~ /^config TARGET_/ { sub("TARGET_",""); print $NF }' \
+ extra/Configs/Config.in | grep -v SUBARCH)
+fi
+pass=""
+fail=""
+skip=""
+for a in "$@" ; do
+ if [ -z "${CROSS_COMPILE}" ] ; then
+ CROSS_COMPILE=$(find_compiler ${a})
+ fi
+
+ if [ -z "${CROSS_COMPILE}" ] ; then
+ mark_arch skip $a
+ echo " ### SKIP: ${a}: could not find compiler"
+ continue
+ fi
+
+ rm -f ${a}.log ${a}.fail
+ (
+ set -e
+
+ echo " ### Building target ${a} (${CROSS_COMPILE})"
+
+ do_make distclean
+ do_make ARCH=$a defconfig
+ do_make oldconfig
+
+ setconfig CROSS_COMPILER_PREFIX ${CROSS_COMPILE}
+
+ header_path=${KERNEL_HEADERS:-$(echo '#include <linux/version.h>' | ${CROSS_COMPILE}cpp 2>/dev/null | grep -o '[^"]*linux/version.h')} || :
+ if [ -z "${header_path}" ] ; then
+ for p in /usr/${CROSS_COMPILE%-}/usr/include ; do
+ if [ -e ${p}/linux/version.h ] ; then
+ header_path=${p}
+ break
+ fi
+ done
+ if [ -z "${header_path}" ] ; then
+ echo " ## unable to locate KERNEL_HEADERS"
+ fi
+ fi
+ setconfig KERNEL_HEADERS ${header_path%/linux/version.h}
+
+ if do_make ; then
+ echo " ## PASS"
+ else
+ echo " ## FAIL"
+ touch ${a}.fail
+ fi
+ ) 2>&1 | tee ${a}.log
+
+ if [ -e ${a}.fail ] ; then
+ rm -f ${a}.fail
+ mark_arch fail $a
+ else
+ mark_arch pass $a
+ fi
+
+ unset CROSS_COMPILE
+done
+
+if [ -n "${skip}" ] ; then
+ printf '\nSKIPPED: %s\n' "${skip}"
+fi
+if [ -n "${fail}" ] ; then
+ printf '\nPASSED: %s\nFAILED: %s\n\n' "${pass}" "${fail}"
+ exit 1
+else
+ printf '\nAll arches passed!\n\n'
+ exit 0
+fi
diff --git a/extra/scripts/conf-header.sh b/extra/scripts/conf-header.sh
index 90dfa999a..8044f8c06 100755
--- a/extra/scripts/conf-header.sh
+++ b/extra/scripts/conf-header.sh
@@ -8,7 +8,7 @@ if [ -z "$1" ] ; then
fi
cat <<EOF
-#if !defined __FEATURES_H && !defined __need_uClibc_config_h
+#if !defined _FEATURES_H && !defined __need_uClibc_config_h
# error Never include <bits/uClibc_config.h> directly; use <features.h> instead
#endif
diff --git a/extra/scripts/cppcheck.sh b/extra/scripts/cppcheck.sh
new file mode 100755
index 000000000..127c5096d
--- /dev/null
+++ b/extra/scripts/cppcheck.sh
@@ -0,0 +1,56 @@
+#! /bin/sh
+
+# usage:
+#
+# make \
+# REAL_CC=gcc-mine \
+# CC=extra/scripts/cppcheck.sh \
+# CPPCHECK_FLAGS="--enable=style,performance,portability,information,missingInclude --max-configs=256 -j $(($(getconf _NPROCESSORS_ONLN)-1))" \
+# CPPCHECK_LIMIT="yes"
+
+# CPPCHECK_FLAGS are optional and are not set per default.
+# CPPCHECK_LIMIT limits cppcheck to the -D and -U that would be passed to CC.
+# Setting CPPCHECK_LIMIT greatly improves the check-time but obviously
+# just checks a small subset of the defines found in a file.
+
+: ${REAL_CC:=gcc}
+${REAL_CC} $@
+args=""
+limits=""
+next_arg=0
+next_limit=0
+
+for i in $@
+do
+ if [ $next_arg -eq 1 ] ; then
+ next_arg=0
+ case "/$i" in
+ /-*) exit 0 ;;
+ esac
+ [ "x$args" = "x" ] && args="$i" || args="$args $i"
+ continue
+ fi
+ if [ $next_limit -eq 1 ] ; then
+ next_limit=0
+ [ "x$limits" = "x" ] && limits="$i" || limits="$limits $i"
+ continue
+ fi
+ case "/$i" in
+ /-c) next_arg=1 ;;
+ /-isystem)
+ next_arg=1;
+ [ "x$args" = "x" ] && args="-I" || args="$args -I" ;;
+ /-I)
+ next_arg=1;
+ [ "x$args" = "x" ] && args="$i" || args="$args $i" ;;
+ /-I*) [ "x$args" = "x" ] && args="$i" || args="$args $i" ;;
+ /-D|/-U)
+ next_limit=1;
+ [ "x$limit" = "x" ] && limit="$i" || limit="$limit $i" ;;
+ /-D*) [ "x$limits" = "x" ] && limits="$i" || limits="$limits $i" ;;
+ /-s|/-S|/-dump*|/--print*|/-print*) exit 0 ;;
+ *) ;;
+ esac
+done
+[ -z "${CPPCHECK_LIMIT}" ] && limits=""
+[ -z "${args}" ] || exec cppcheck ${CPPCHECK_FLAGS} ${args} ${limits}
diff --git a/extra/scripts/gen-as-const.awk b/extra/scripts/gen-as-const.awk
new file mode 100644
index 000000000..013bd6e85
--- /dev/null
+++ b/extra/scripts/gen-as-const.awk
@@ -0,0 +1,33 @@
+# Script used in producing headers of assembly constants from C expressions.
+# The input to this script looks like:
+# #cpp-directive ...
+# NAME1
+# NAME2 expression ...
+# The output of this script is C code to be run through gcc -S and then
+# massaged to extract the integer constant values of the given C expressions.
+# A line giving just a name implies an expression consisting of just that name.
+
+BEGIN { started = 0 }
+
+# cpp directives go straight through.
+/^#/ { print; next }
+
+NF >= 1 && !started {
+ printf "void dummy(void);\n";
+ print "void dummy(void) {";
+ started = 1;
+}
+
+# Separator.
+$1 == "--" { next }
+
+NF == 1 { sub(/^.*$/, "& &"); }
+
+NF > 1 {
+ name = $1;
+ sub(/^[^ ]+[ ]+/, "");
+ printf "__asm__ (\"@@@name@@@%s@@@value@@@%%0@@@end@@@\" : : \"i\" ((long) %s));\n",
+ name, $0;
+}
+
+END { if (started) print "}" }
diff --git a/extra/scripts/gen_bits_syscall_h.sh b/extra/scripts/gen_bits_syscall_h.sh
index c0b4c25f5..bfd06b832 100755
--- a/extra/scripts/gen_bits_syscall_h.sh
+++ b/extra/scripts/gen_bits_syscall_h.sh
@@ -8,39 +8,53 @@
# June 27, 2001 Manuel Novoa III
#
-# This script expects top_builddir and CC (as used in the Makefiles) to be set
-# in the environment, and outputs the appropriate
-# $top_builddir/include/bits/sysnum.h # corresponding to
-# $top_builddir/include/asm/unistd.h to stdout.
+# This script expects CC (as used in the Makefiles) to be set
+# in the environment, and outputs the appropriate bits/sysnum.h #
+# corresponding to asm/unistd.h to stdout.
#
# Warning!!! This does _no_ error checking!!!
-INCLUDE_OPTS="-nostdinc -I${KERNEL_HEADERS}"
+if [ "${KERNEL_HEADERS:-/}" != "/" ] ; then
+ INCLUDE_OPTS="-nostdinc -I${KERNEL_HEADERS}"
+else
+ # Let the toolchain use its configure paths.
+ INCLUDE_OPTS=
+fi
case $CC in
*icc*) CC_SYSNUM_ARGS="-dM" ;;
+*clang*) CC_SYSNUM_ARGS="-dM" ;;
*) CC_SYSNUM_ARGS="-dN" ;;
esac
( echo "#include <asm/unistd.h>";
echo "#include <asm/unistd.h>" |
$CC -E $CC_SYSNUM_ARGS $INCLUDE_OPTS - |
- sed -ne 's/^[ ]*#define[ ]*__NR_\([A-Za-z0-9_]*\).*/UCLIBC_\1 __NR_\1/gp' \
- -e 's/^[ ]*#undef[ ]*__NR_\([A-Za-z0-9_]*\).*/UNDEFUCLIBC_\1 __NR_\1/gp' # needed to strip out any kernel-internal defines
+ sed -n -r \
+ -e 's/^[ ]*#define[ ]*(__ARM_NR_|__NR_)([A-Za-z0-9_]*).*/UCLIBC\1\2 \1\2/gp' \
+ -e 's/^[ ]*#undef[ ]*(__ARM_NR_|__NR_)([A-Za-z0-9_]*).*/UNDEFUCLIBC\1\2 \1\2/gp' # needed to strip out any kernel-internal defines
) |
$CC -E $INCLUDE_OPTS - |
-( echo "/* WARNING!!! AUTO-GENERATED FILE!!! DO NOT EDIT!!! */" ;
- echo ;
- echo "#ifndef _BITS_SYSNUM_H" ;
- echo "#define _BITS_SYSNUM_H" ;
- echo ;
- echo "#ifndef _SYSCALL_H" ;
- echo "# error \"Never use <bits/sysnum.h> directly; include <sys/syscall.h> instead.\"" ;
- echo "#endif" ; echo ;
- sed -ne 's/^UCLIBC_\([A-Za-z0-9_]*\) *\(.*\)/#undef __NR_\1\
-#define __NR_\1 \2\
-#define SYS_\1 __NR_\1/gp' \
- -e 's/^UNDEFUCLIBC_\([A-Za-z0-9_]*\).*/#undef __NR_\1/gp'
- echo ;
- echo "#endif" ;
+(
+ cat <<-EOF
+/* WARNING!!! AUTO-GENERATED FILE!!! DO NOT EDIT!!! */
+/* See $0 for more information. */
+
+#ifndef _BITS_SYSNUM_H
+#define _BITS_SYSNUM_H
+
+#ifndef _SYSCALL_H
+# error "Never use <bits/sysnum.h> directly; include <sys/syscall.h> instead."
+#endif
+
+EOF
+ sed -n -r -e 's/^UCLIBC(__ARM_NR_|__NR_)([A-Za-z0-9_]*) *(.*)/#undef \1\2\
+#define \1\2 \3\
+#define SYS_\2 \1\2/gp' \
+ -e 's/^UNDEFUCLIBC(__ARM_NR_|__NR_)([A-Za-z0-9_]*).*/#undef \1\2\
+#undef SYS_\2/gp'
+ cat <<-EOF
+
+#endif
+EOF
)
diff --git a/extra/scripts/getent b/extra/scripts/getent
index 30d515b7e..5c482a071 100755
--- a/extra/scripts/getent
+++ b/extra/scripts/getent
@@ -1,5 +1,4 @@
#!/bin/sh
-# $Header: /var/cvs/uClibc/extra/scripts/getent,v 1.2 2005/02/02 14:18:01 solar Exp $
#
# Closely (not perfectly) emulate the behavior of glibc's getent utility
#
@@ -9,7 +8,8 @@
# case-insensitive matches not supported (ethers; others?)
# may return false-positives (hosts,protocols,rpc,services,ethers)
-export PATH="${PATH}:/bin:/usr/bin"
+[ -z "$PATH" ] && PATH="/bin:/usr/bin" || PATH="${PATH}:/bin:/usr/bin"
+export PATH
file="/etc/$1"
case $1 in
diff --git a/extra/scripts/install_headers.sh b/extra/scripts/install_headers.sh
index 6d73ad2c6..8c8d715ef 100755
--- a/extra/scripts/install_headers.sh
+++ b/extra/scripts/install_headers.sh
@@ -4,6 +4,10 @@
# $2 = dst dir
# $top_builddir = well you guessed it
+srcdir=${1:-include}
+dstdir=${2:-`. ./.config 2>/dev/null && echo ${DEVEL_PREFIX}/include`}
+: ${top_builddir:=.}
+
die_if_not_dir()
{
for dir in "$@"; do
@@ -19,40 +23,55 @@ umask 022
# Sanity tests
-die_if_not_dir "$1"
-mkdir -p "$2" 2>/dev/null
-die_if_not_dir "$2"
+die_if_not_dir "${srcdir}"
+mkdir -p "${dstdir}" 2>/dev/null
+die_if_not_dir "${dstdir}"
die_if_not_dir "$top_builddir"
if ! test -x "$top_builddir/extra/scripts/unifdef"; then
echo "Error: need '$top_builddir/extra/scripts/unifdef' executable"
exit 1
fi
-
# Sanitize and copy uclibc headers
(
-# We must cd, or else we'll prepend "$1" to filenames!
-cd "$1" || exit 1
-find ! -name '.' -a ! -path '*/.*'
+# We must cd, or else we will prepend "${srcdir}" to filenames!
+cd "${srcdir}" || exit 1
+find . ! -name '.' -a ! -path '*/.*' | sed -e 's/^\.\///' -e '/^config\//d' \
+ -e '/^config$/d'
) | \
(
IFS=''
while read -r filename; do
- filename="${filename#./}"
- if test -d "$1/$filename"; then
- mkdir -p "$2/$filename" 2>/dev/null
- else
- # NB: unifdef exits with 1 if output is not
- # exactly the same as input. That's ok.
- # Do not abort the script if unifdef "fails"!
- "$top_builddir/extra/scripts/unifdef" -UUCLIBC_INTERNAL "$1/$filename" \
- | grep -v '^libc_hidden_proto[ ]*([a-zA-Z0-9_]*)$' >"$2/$filename"
+ if test -d "${srcdir}/$filename"; then
+ mkdir -p "${dstdir}/$filename" 2>/dev/null
+ continue
fi
+ if test x"${filename##libc-*.h}" = x""; then
+ # Do not install libc-XXXX.h files
+ continue
+ fi
+ # Do not abort the script if unifdef "fails"!
+ # NB2: careful with sed command arguments, they contain tab character
+ "$top_builddir/extra/scripts/unifdef" \
+ -B \
+ -t \
+ -x 2 \
+ -f "$top_builddir/include/generated/unifdef_config.h" \
+ -U_LIBC \
+ -U__UCLIBC_GEN_LOCALE \
+ -U__NO_CTYPE \
+ "${srcdir}/$filename" \
+ | sed -e '/^rtld_hidden_proto[ ]*([a-zA-Z0-9_]*)$/d' \
+ | sed -e '/^lib\(c\|m\|resolv\|dl\|intl\|rt\|nsl\|util\|crypt\|pthread\)_hidden_proto[ ]*([a-zA-Z0-9_]*)$/d' \
+ > "${dstdir}/$filename"
done
)
# Fix mode/owner bits
-cd "$2" || exit 1
+cd "${dstdir}" || exit 1
chmod -R u=rwX,go=rX . >/dev/null 2>&1
chown -R `id | sed 's/^uid=\([0-9]*\).*gid=\([0-9]*\).*$/\1:\2/'` . >/dev/null 2>&1
+
+# ignore errors on unrelated files
+exit 0
diff --git a/extra/scripts/install_kernel_headers.sh b/extra/scripts/install_kernel_headers.sh
deleted file mode 100755
index 7e86eb850..000000000
--- a/extra/scripts/install_kernel_headers.sh
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/bin/sh
-# Parameters:
-# $1 = source dir
-# $2 = dst dir
-# $top_builddir = well you guessed it
-
-die_if_not_dir()
-{
- for dir in "$@"; do
- test -d "$dir" && continue
- echo "Error: '$dir' is not a directory"
- exit 1
- done
-}
-
-
-# Ensure that created dirs/files have 755/644 perms
-umask 022
-
-
-# Sanity tests
-die_if_not_dir "$1"
-mkdir -p "$2" 2>/dev/null
-die_if_not_dir "$2"
-die_if_not_dir "$top_builddir"
-
-
-# Just copy (no sanitization) some kernel headers.
-eval `grep ^KERNEL_HEADERS "$top_builddir/.config"`
-if ! test "$KERNEL_HEADERS" \
-|| ! test -d "$KERNEL_HEADERS/asm" \
-|| ! test -d "$KERNEL_HEADERS/asm-generic" \
-|| ! test -d "$KERNEL_HEADERS/linux" \
-; then
- echo "Error: '$KERNEL_HEADERS' is not a directory containing kernel headers."
- echo "Check KERNEL_HEADERS= in your .config file."
- exit 1
-fi
-# Do the copying only if src and dst dirs are not the same.
-# Be thorough: do not settle just for textual compare,
-# and guard against "pwd" being handled as shell builtin.
-# Double quoting looks weird, but it works (even bbox ash too).
-if test "`(cd "$KERNEL_HEADERS"; env pwd)`" != "`(cd "$2"; env pwd)`"; then
- # NB: source or target files and directories may be symlinks,
- # and for all we know, good reasons.
- # We must work correctly in these cases. This includes "do not replace
- # target symlink with real directory" rule. So, no rm -rf here please.
- mkdir -p "$2/asm" 2>/dev/null
- mkdir -p "$2/linux" 2>/dev/null
- # Exists, but is not a dir? That's bad, bail out
- die_if_not_dir "$2/asm" "$2/linux"
- # cp -HL creates regular destination files even if sources are symlinks.
- # This is intended.
- # (NB: you need busybox 1.11.x for this. earlier ones are slightly buggy)
- cp -RHL "$KERNEL_HEADERS/asm"/* "$2/asm" || exit 1
- cp -RHL "$KERNEL_HEADERS/linux"/* "$2/linux" || exit 1
- # Linux 2.4 doesn't have it
- if test -d "$KERNEL_HEADERS/asm-generic"; then
- mkdir -p "$2/asm-generic" 2>/dev/null
- die_if_not_dir "$2/asm-generic"
- cp -RHL "$KERNEL_HEADERS/asm-generic"/* "$2/asm-generic" || exit 1
- fi
- if ! test -f "$2/linux/version.h"; then
- echo "Warning: '$KERNEL_HEADERS/linux/version.h' is not found"
- echo "in kernel headers directory specified in .config."
- echo "Some programs won't like that. Consider fixing it by hand."
- fi
-fi
-
-
-# Fix mode/owner bits
-cd "$2" || exit 1
-chmod -R u=rwX,go=rX . >/dev/null 2>&1
-chown -R `id | sed 's/^uid=\([0-9]*\).*gid=\([0-9]*\).*$/\1:\2/'` . >/dev/null 2>&1
diff --git a/extra/scripts/none.lds b/extra/scripts/none.lds
new file mode 100644
index 000000000..d6bd05afc
--- /dev/null
+++ b/extra/scripts/none.lds
@@ -0,0 +1,13 @@
+/* GNU ld script
+ * Used by the build system to probe flags.
+ * Discards all output to avoid error
+ * "failed to merge target specific data of file %B". */
+TARGET(binary)
+INPUT(/dev/null)
+/* We could as well omit the whole SECTIONS block.
+ * This redundancy is just for clarity. */
+SECTIONS
+{
+ /DISCARD/ : { *(*) }
+}
+
diff --git a/extra/scripts/randconfig.sh b/extra/scripts/randconfig.sh
index d0be318c8..d83731b6e 100755
--- a/extra/scripts/randconfig.sh
+++ b/extra/scripts/randconfig.sh
@@ -1,19 +1,34 @@
#!/bin/sh
+# build random configurations
+# Usage:
+# ARCH=i386 nohup ./extra/scripts/randconfig.sh & sleep 1800 && touch STOP
+#
+# The above builds random i386 configs and automatically stops after 30 minutes
+
+test "x$AWK" = "x" && AWK=awk
test "x$ARCH" = "x" && ARCH=`uname -m`
KCONFIG_ALLCONFIG=.config.allconfig
(echo TARGET_$ARCH=y
- echo '# UCLIBC_PREGENERATED_LOCALE_DATA is not set'
- echo '# UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA is not set'
+ echo '# DOMULTI is not set'
) > $KCONFIG_ALLCONFIG
export KCONFIG_ALLCONFIG
+if test "x$NCPU" = "x"
+then
+ test -r /proc/cpuinfo && \
+ eval `$AWK 'BEGIN{NCPU=0}
+/processor/{let NCPU++}
+END{if (NCPU<1) {NCPU=1}; print("NCPU="NCPU);}' /proc/cpuinfo` || \
+ NCPU=1
+fi
+MAKELEVEL="-j$NCPU"
i=0
while test ! -f STOP
do
- make $* randconfig > /dev/null
- make $* silentoldconfig > /dev/null
- if (make $*) 2>&1 >& mk.log
+ ARCH=$ARCH make $* randconfig > /dev/null
+ ARCH=$ARCH make $* silentoldconfig > /dev/null
+ if (make $MAKELEVEL $*) 2>&1 >& mk.log
then
:
else
@@ -24,3 +39,4 @@ do
fi
make distclean > /dev/null || true
done
+rm -f STOP
diff --git a/extra/scripts/relative_path.sh b/extra/scripts/relative_path.sh
index c859646a4..4dddefac1 100755
--- a/extra/scripts/relative_path.sh
+++ b/extra/scripts/relative_path.sh
@@ -33,7 +33,10 @@ case $from in
;;
esac
-prefix=`echo $from///$target | sed 's,\(\(/[^/]*\)*\).*///\1.*,\1,'`
+# Without trailing slash, from=/usr/lib and target=/uclibc/lib
+# mistakenly concludes that prefix=/u
+#prefix=`echo $from///$target | sed 's,\(\(/[^/]*\)*\).*///\1.*,\1,'`
+prefix=`echo $from///$target | sed 's,\(\(/[^/]*\)*/\).*///\1.*,\1,'`
dots=`echo $prefix | sed s,.,.,g`
from=`echo $from | sed "s,^$dots,,"`
target=`echo $target | sed "s,^$dots,,"`
diff --git a/extra/scripts/relinfo.pl b/extra/scripts/relinfo.pl
index ec4a5df13..cb990b36f 100755
--- a/extra/scripts/relinfo.pl
+++ b/extra/scripts/relinfo.pl
@@ -1,5 +1,5 @@
#! /usr/bin/perl
-eval "exec /usr/bin/perl -S $0 $*"
+eval "exec /usr/bin/env perl -w -S $0 $@"
if 0;
# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Red Hat, Inc.
# Written by Ulrich Drepper <drepper@redhat.com>, 2000.
@@ -14,8 +14,7 @@ eval "exec /usr/bin/perl -S $0 $*"
# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
for ($cnt = 0; $cnt <= $#ARGV; ++$cnt) {
$relent = 0;
diff --git a/extra/scripts/unifdef.c b/extra/scripts/unifdef.c
index 552025e72..0f059205f 100644
--- a/extra/scripts/unifdef.c
+++ b/extra/scripts/unifdef.c
@@ -1,13 +1,5 @@
/*
- * Copyright (c) 2002 - 2005 Tony Finch <dot@dotat.at>. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by Dave Yost.
- * It was rewritten to support ANSI C by Tony Finch. The original version of
- * unifdef carried the following copyright notice. None of its code remains
- * in this version (though some of the names remain).
- *
- * Copyright (c) 1985, 1993
- * The Regents of the University of California. All rights reserved.
+ * Copyright (c) 2002 - 2014 Tony Finch <dot@dotat.at>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -31,27 +23,15 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-
-#ifndef lint
-#if 0
-static const char copyright[] =
-"@(#) Copyright (c) 1985, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif
-#ifdef __IDSTRING
-__IDSTRING(Berkeley, "@(#)unifdef.c 8.1 (Berkeley) 6/6/93");
-__IDSTRING(NetBSD, "$NetBSD: unifdef.c,v 1.8 2000/07/03 02:51:36 matt Exp $");
-__IDSTRING(dotat, "$dotat: things/unifdef.c,v 1.171 2005/03/08 12:38:48 fanf2 Exp $");
-#endif
-#endif /* not lint */
-#ifdef __FBSDID
-__FBSDID("$FreeBSD: /repoman/r/ncvs/src/usr.bin/unifdef/unifdef.c,v 1.20 2005/05/21 09:55:09 ru Exp $");
-#endif
-
/*
* unifdef - remove ifdef'ed lines
*
+ * This code was derived from software contributed to Berkeley by Dave Yost.
+ * It was rewritten to support ANSI C by Tony Finch. The original version
+ * of unifdef carried the 4-clause BSD copyright licence. None of its code
+ * remains in this version (though some of the names remain) so it now
+ * carries a more liberal licence.
+ *
* Wishlist:
* provide an option which will append the name of the
* appropriate symbol after #else's and #endif's
@@ -59,20 +39,17 @@ __FBSDID("$FreeBSD: /repoman/r/ncvs/src/usr.bin/unifdef/unifdef.c,v 1.20 2005/05
* #else's and #endif's to see that they match their
* corresponding #ifdef or #ifndef
*
- * The first two items above require better buffer handling, which would
- * also make it possible to handle all "dodgy" directives correctly.
+ * These require better buffer handling, which would also make
+ * it possible to handle all "dodgy" directives correctly.
*/
-#include <ctype.h>
-#include <err.h>
-#include <stdarg.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
+#include "unifdef.h"
-size_t strlcpy(char *dst, const char *src, size_t siz);
+static const char copyright[] =
+ #include "version.h"
+ "@(#) $Author: Tony Finch (dot@dotat.at) $\n"
+ "@(#) $URL: http://dotat.at/prog/unifdef $\n"
+;
/* types of input lines: */
typedef enum {
@@ -90,6 +67,7 @@ typedef enum {
LT_DODGY_LAST = LT_DODGY + LT_ENDIF,
LT_PLAIN, /* ordinary line */
LT_EOF, /* end of file */
+ LT_ERROR, /* unevaluable #if */
LT_COUNT
} Linetype;
@@ -100,9 +78,12 @@ static char const * const linetype_name[] = {
"DODGY IF", "DODGY TRUE", "DODGY FALSE",
"DODGY ELIF", "DODGY ELTRUE", "DODGY ELFALSE",
"DODGY ELSE", "DODGY ENDIF",
- "PLAIN", "EOF"
+ "PLAIN", "EOF", "ERROR"
};
+#define linetype_if2elif(lt) ((Linetype)(lt - LT_IF + LT_ELIF))
+#define linetype_2dodgy(lt) ((Linetype)(lt + LT_DODGY))
+
/* state of #if processing */
typedef enum {
IS_OUTSIDE,
@@ -156,7 +137,7 @@ static char const * const linestate_name[] = {
*/
#define MAXDEPTH 64 /* maximum #if nesting */
#define MAXLINE 4096 /* maximum length of line */
-#define MAXSYMS 4096 /* maximum number of symbols */
+#define MAXSYMS 16384 /* maximum number of symbols */
/*
* Sometimes when editing a keyword the replacement text is longer, so
@@ -168,13 +149,17 @@ static char const * const linestate_name[] = {
* Globals.
*/
+static bool compblank; /* -B: compress blank lines */
+static bool lnblank; /* -b: blank deleted lines */
static bool complement; /* -c: do the complement */
static bool debugging; /* -d: debugging reports */
+static bool inplace; /* -m: modify in place */
static bool iocccok; /* -e: fewer IOCCC errors */
+static bool strictlogic; /* -K: keep ambiguous #ifs */
static bool killconsts; /* -k: eval constant #ifs */
-static bool lnblank; /* -l: blank deleted lines */
static bool lnnum; /* -n: add #line directives */
static bool symlist; /* -s: output symbol list */
+static bool symdepth; /* -S: output symbol depth */
static bool text; /* -t: this is a text file */
static const char *symname[MAXSYMS]; /* symbol name */
@@ -185,10 +170,28 @@ static int nsyms; /* number of symbols */
static FILE *input; /* input file pointer */
static const char *filename; /* input file name */
static int linenum; /* current line number */
+static const char *linefile; /* file name for #line */
+static FILE *output; /* output file pointer */
+static const char *ofilename; /* output file name */
+static const char *backext; /* backup extension */
+static char *tempname; /* avoid splatting input */
static char tline[MAXLINE+EDITSLOP];/* input buffer plus space */
static char *keyword; /* used for editing #elif's */
+/*
+ * When processing a file, the output's newline style will match the
+ * input's, and unifdef correctly handles CRLF or LF endings whatever
+ * the platform's native style. The stdio streams are opened in binary
+ * mode to accommodate platforms whose native newline style is CRLF.
+ * When the output isn't a processed input file (when it is error /
+ * debug / diagnostic messages) then unifdef uses native line endings.
+ */
+
+static const char *newline; /* input file format */
+static const char newline_unix[] = "\n";
+static const char newline_crlf[] = "\r\n";
+
static Comment_state incomment; /* comment parser state */
static Line_state linestate; /* #if line parser state */
static Ifstate ifstate[MAXDEPTH]; /* #if processor state */
@@ -196,31 +199,53 @@ static bool ignoring[MAXDEPTH]; /* ignore comments state */
static int stifline[MAXDEPTH]; /* start of current #if */
static int depth; /* current #if nesting */
static int delcount; /* count of deleted lines */
-static bool keepthis; /* don't delete constant #if */
+static unsigned blankcount; /* count of blank lines */
+static unsigned blankmax; /* maximum recent blankcount */
+static bool constexpr; /* constant #if expression */
+static bool zerosyms; /* to format symdepth output */
+static bool firstsym; /* ditto */
+static int exitmode; /* exit status mode */
static int exitstat; /* program exit status */
+static bool altered; /* was this file modified? */
-static void addsym(bool, bool, char *);
+static void addsym1(bool, bool, char *);
+static void addsym2(bool, const char *, const char *);
+static char *astrcat(const char *, const char *);
+static void cleantemp(void);
+static void closeio(void);
static void debug(const char *, ...);
+static void debugsym(const char *, int);
+static bool defundef(void);
+static void defundefile(const char *);
static void done(void);
static void error(const char *);
-static int findsym(const char *);
+static int findsym(const char **);
static void flushline(bool);
-static Linetype getline(void);
+static void hashline(void);
+static void help(void);
static Linetype ifeval(const char **);
static void ignoreoff(void);
static void ignoreon(void);
+static void indirectsym(void);
static void keywordedit(const char *);
+static const char *matchsym(const char *, const char *);
static void nest(void);
+static Linetype parseline(void);
static void process(void);
+static void processinout(const char *, const char *);
+static const char *skipargs(const char *);
static const char *skipcomment(const char *);
+static const char *skiphash(void);
+static const char *skipline(const char *);
static const char *skipsym(const char *);
static void state(Ifstate);
-static int strlcmp(const char *, const char *, size_t);
static void unnest(void);
static void usage(void);
+static void version(void);
+static const char *xstrdup(const char *, const char *);
-#define endsym(c) (!isalpha((unsigned char)c) && !isdigit((unsigned char)c) && c != '_')
+#define endsym(c) (!isalnum((unsigned char)c) && c != '_')
/*
* The main program.
@@ -230,7 +255,7 @@ main(int argc, char *argv[])
{
int opt;
- while ((opt = getopt(argc, argv, "i:D:U:I:cdeklnst")) != -1)
+ while ((opt = getopt(argc, argv, "i:D:U:f:I:M:o:x:bBcdehKklmnsStV")) != -1)
switch (opt) {
case 'i': /* treat stuff controlled by these symbols as text */
/*
@@ -240,20 +265,26 @@ main(int argc, char *argv[])
*/
opt = *optarg++;
if (opt == 'D')
- addsym(true, true, optarg);
+ addsym1(true, true, optarg);
else if (opt == 'U')
- addsym(true, false, optarg);
+ addsym1(true, false, optarg);
else
usage();
break;
case 'D': /* define a symbol */
- addsym(false, true, optarg);
+ addsym1(false, true, optarg);
break;
case 'U': /* undef a symbol */
- addsym(false, false, optarg);
+ addsym1(false, false, optarg);
+ break;
+ case 'I': /* no-op for compatibility with cpp */
break;
- case 'I':
- /* no-op for compatibility with cpp */
+ case 'b': /* blank deleted lines instead of omitting them */
+ case 'l': /* backwards compatibility */
+ lnblank = true;
+ break;
+ case 'B': /* compress blank lines around removed section */
+ compblank = true;
break;
case 'c': /* treat -D as -U and vice versa */
complement = true;
@@ -264,49 +295,214 @@ main(int argc, char *argv[])
case 'e': /* fewer errors from dodgy lines */
iocccok = true;
break;
+ case 'f': /* definitions file */
+ defundefile(optarg);
+ break;
+ case 'h':
+ help();
+ break;
+ case 'K': /* keep ambiguous #ifs */
+ strictlogic = true;
+ break;
case 'k': /* process constant #ifs */
killconsts = true;
break;
- case 'l': /* blank deleted lines instead of omitting them */
- lnblank = true;
+ case 'm': /* modify in place */
+ inplace = true;
+ break;
+ case 'M': /* modify in place and keep backup */
+ inplace = true;
+ backext = optarg;
break;
case 'n': /* add #line directive after deleted lines */
lnnum = true;
break;
+ case 'o': /* output to a file */
+ ofilename = optarg;
+ break;
case 's': /* only output list of symbols that control #ifs */
symlist = true;
break;
+ case 'S': /* list symbols with their nesting depth */
+ symlist = symdepth = true;
+ break;
case 't': /* don't parse C comments */
text = true;
break;
+ case 'V':
+ version();
+ break;
+ case 'x':
+ exitmode = atoi(optarg);
+ if(exitmode < 0 || exitmode > 2)
+ usage();
+ break;
default:
usage();
}
argc -= optind;
argv += optind;
- if (argc > 1) {
- errx(2, "can only do one file");
- } else if (argc == 1 && strcmp(*argv, "-") != 0) {
- filename = *argv;
- input = fopen(filename, "r");
- if (input == NULL)
- err(2, "can't open %s", filename);
- } else {
+ if (compblank && lnblank)
+ errx(2, "-B and -b are mutually exclusive");
+ if (symlist && (ofilename != NULL || inplace || argc > 1))
+ errx(2, "-s only works with one input file");
+ if (argc > 1 && ofilename != NULL)
+ errx(2, "-o cannot be used with multiple input files");
+ if (argc > 1 && !inplace)
+ errx(2, "multiple input files require -m or -M");
+ if (argc == 0)
+ argc = 1;
+ if (argc == 1 && !inplace && ofilename == NULL)
+ ofilename = "-";
+ indirectsym();
+
+ atexit(cleantemp);
+ if (ofilename != NULL)
+ processinout(*argv, ofilename);
+ else while (argc-- > 0) {
+ processinout(*argv, *argv);
+ argv++;
+ }
+ switch(exitmode) {
+ case(0): exit(exitstat);
+ case(1): exit(!exitstat);
+ case(2): exit(0);
+ default: abort(); /* bug */
+ }
+}
+
+/*
+ * File logistics.
+ */
+static void
+processinout(const char *ifn, const char *ofn)
+{
+ struct stat st;
+
+ if (ifn == NULL || strcmp(ifn, "-") == 0) {
filename = "[stdin]";
- input = stdin;
+ linefile = NULL;
+ input = fbinmode(stdin);
+ } else {
+ filename = ifn;
+ linefile = ifn;
+ input = fopen(ifn, "rb");
+ if (input == NULL)
+ err(2, "can't open %s", ifn);
+ }
+ if (strcmp(ofn, "-") == 0) {
+ output = fbinmode(stdout);
+ process();
+ return;
}
+ if (stat(ofn, &st) < 0) {
+ output = fopen(ofn, "wb");
+ if (output == NULL)
+ err(2, "can't create %s", ofn);
+ process();
+ return;
+ }
+
+ tempname = astrcat(ofn, ".XXXXXX");
+ output = mktempmode(tempname, st.st_mode);
+ if (output == NULL)
+ err(2, "can't create %s", tempname);
+
process();
- abort(); /* bug */
+
+ if (backext != NULL) {
+ char *backname = astrcat(ofn, backext);
+ if (rename(ofn, backname) < 0)
+ err(2, "can't rename \"%s\" to \"%s\"", ofn, backname);
+ free(backname);
+ }
+ /* leave file unmodified if unifdef made no changes */
+ if (!altered && backext == NULL) {
+ if (remove(tempname) < 0)
+ warn("can't remove \"%s\"", tempname);
+ } else if (replace(tempname, ofn) < 0)
+ err(2, "can't rename \"%s\" to \"%s\"", tempname, ofn);
+ free(tempname);
+ tempname = NULL;
+}
+
+/*
+ * For cleaning up if there is an error.
+ */
+static void
+cleantemp(void)
+{
+ if (tempname != NULL)
+ remove(tempname);
+}
+
+/*
+ * Self-identification functions.
+ */
+
+static void
+version(void)
+{
+ const char *c = copyright;
+ for (;;) {
+ while (*++c != '$')
+ if (*c == '\0')
+ exit(0);
+ while (*++c != '$')
+ putc(*c, stderr);
+ putc('\n', stderr);
+ }
+}
+
+static void
+synopsis(FILE *fp)
+{
+ fprintf(fp,
+ "usage: unifdef [-bBcdehKkmnsStV] [-x{012}] [-Mext] [-opath] \\\n"
+ " [-[i]Dsym[=val]] [-[i]Usym] [-fpath] ... [file] ...\n");
}
static void
usage(void)
{
- fprintf(stderr, "usage: unifdef [-cdeklnst] [-Ipath]"
- " [-Dsym[=val]] [-Usym] [-iDsym[=val]] [-iUsym] ... [file]\n");
+ synopsis(stderr);
exit(2);
}
+static void
+help(void)
+{
+ synopsis(stdout);
+ printf(
+ " -Dsym=val define preprocessor symbol with given value\n"
+ " -Dsym define preprocessor symbol with value 1\n"
+ " -Usym preprocessor symbol is undefined\n"
+ " -iDsym=val \\ ignore C strings and comments\n"
+ " -iDsym ) in sections controlled by these\n"
+ " -iUsym / preprocessor symbols\n"
+ " -fpath file containing #define and #undef directives\n"
+ " -b blank lines instead of deleting them\n"
+ " -B compress blank lines around deleted section\n"
+ " -c complement (invert) keep vs. delete\n"
+ " -d debugging mode\n"
+ " -e ignore multiline preprocessor directives\n"
+ " -h print help\n"
+ " -Ipath extra include file path (ignored)\n"
+ " -K disable && and || short-circuiting\n"
+ " -k process constant #if expressions\n"
+ " -Mext modify in place and keep backups\n"
+ " -m modify input files in place\n"
+ " -n add #line directives to output\n"
+ " -opath output file name\n"
+ " -S list #if control symbols with nesting\n"
+ " -s list #if control symbols\n"
+ " -t ignore C strings and comments\n"
+ " -V print version\n"
+ " -x{012} exit status mode\n"
+ );
+ exit(0);
+}
+
/*
* A state transition function alters the global #if processing state
* in a particular way. The table below is indexed by the current
@@ -320,7 +516,8 @@ usage(void)
* When we have processed a group that starts off with a known-false
* #if/#elif sequence (which has therefore been deleted) followed by a
* #elif that we don't understand and therefore must keep, we edit the
- * latter into a #if to keep the nesting correct.
+ * latter into a #if to keep the nesting correct. We use memcpy() to
+ * overwrite the 4 byte token "elif" with "if " without a '\0' byte.
*
* When we find a true #elif in a group, the following block will
* always be kept and the rest of the sequence after the next #elif or
@@ -373,69 +570,62 @@ static void Oelif (void) { if (!iocccok) Eioccc(); Pelif(); }
static void Idrop (void) { Fdrop(); ignoreon(); }
static void Itrue (void) { Ftrue(); ignoreon(); }
static void Ifalse(void) { Ffalse(); ignoreon(); }
-/* edit this line */
-static void Mpass (void) { strncpy(keyword, "if ", 4); Pelif(); }
-static void Mtrue (void) { keywordedit("else\n"); state(IS_TRUE_MIDDLE); }
-static void Melif (void) { keywordedit("endif\n"); state(IS_FALSE_TRAILER); }
-static void Melse (void) { keywordedit("endif\n"); state(IS_FALSE_ELSE); }
+/* modify this line */
+static void Mpass (void) { memcpy(keyword, "if ", 4); Pelif(); }
+static void Mtrue (void) { keywordedit("else"); state(IS_TRUE_MIDDLE); }
+static void Melif (void) { keywordedit("endif"); state(IS_FALSE_TRAILER); }
+static void Melse (void) { keywordedit("endif"); state(IS_FALSE_ELSE); }
static state_fn * const trans_table[IS_COUNT][LT_COUNT] = {
/* IS_OUTSIDE */
{ Itrue, Ifalse,Fpass, Ftrue, Ffalse,Eelif, Eelif, Eelif, Eelse, Eendif,
Oiffy, Oiffy, Fpass, Oif, Oif, Eelif, Eelif, Eelif, Eelse, Eendif,
- print, done },
+ print, done, abort },
/* IS_FALSE_PREFIX */
{ Idrop, Idrop, Fdrop, Fdrop, Fdrop, Mpass, Strue, Sfalse,Selse, Dendif,
Idrop, Idrop, Fdrop, Fdrop, Fdrop, Mpass, Eioccc,Eioccc,Eioccc,Eioccc,
- drop, Eeof },
+ drop, Eeof, abort },
/* IS_TRUE_PREFIX */
{ Itrue, Ifalse,Fpass, Ftrue, Ffalse,Dfalse,Dfalse,Dfalse,Delse, Dendif,
Oiffy, Oiffy, Fpass, Oif, Oif, Eioccc,Eioccc,Eioccc,Eioccc,Eioccc,
- print, Eeof },
+ print, Eeof, abort },
/* IS_PASS_MIDDLE */
{ Itrue, Ifalse,Fpass, Ftrue, Ffalse,Pelif, Mtrue, Delif, Pelse, Pendif,
Oiffy, Oiffy, Fpass, Oif, Oif, Pelif, Oelif, Oelif, Pelse, Pendif,
- print, Eeof },
+ print, Eeof, abort },
/* IS_FALSE_MIDDLE */
{ Idrop, Idrop, Fdrop, Fdrop, Fdrop, Pelif, Mtrue, Delif, Pelse, Pendif,
Idrop, Idrop, Fdrop, Fdrop, Fdrop, Eioccc,Eioccc,Eioccc,Eioccc,Eioccc,
- drop, Eeof },
+ drop, Eeof, abort },
/* IS_TRUE_MIDDLE */
{ Itrue, Ifalse,Fpass, Ftrue, Ffalse,Melif, Melif, Melif, Melse, Pendif,
Oiffy, Oiffy, Fpass, Oif, Oif, Eioccc,Eioccc,Eioccc,Eioccc,Pendif,
- print, Eeof },
+ print, Eeof, abort },
/* IS_PASS_ELSE */
{ Itrue, Ifalse,Fpass, Ftrue, Ffalse,Eelif, Eelif, Eelif, Eelse, Pendif,
Oiffy, Oiffy, Fpass, Oif, Oif, Eelif, Eelif, Eelif, Eelse, Pendif,
- print, Eeof },
+ print, Eeof, abort },
/* IS_FALSE_ELSE */
{ Idrop, Idrop, Fdrop, Fdrop, Fdrop, Eelif, Eelif, Eelif, Eelse, Dendif,
Idrop, Idrop, Fdrop, Fdrop, Fdrop, Eelif, Eelif, Eelif, Eelse, Eioccc,
- drop, Eeof },
+ drop, Eeof, abort },
/* IS_TRUE_ELSE */
{ Itrue, Ifalse,Fpass, Ftrue, Ffalse,Eelif, Eelif, Eelif, Eelse, Dendif,
Oiffy, Oiffy, Fpass, Oif, Oif, Eelif, Eelif, Eelif, Eelse, Eioccc,
- print, Eeof },
+ print, Eeof, abort },
/* IS_FALSE_TRAILER */
{ Idrop, Idrop, Fdrop, Fdrop, Fdrop, Dfalse,Dfalse,Dfalse,Delse, Dendif,
Idrop, Idrop, Fdrop, Fdrop, Fdrop, Dfalse,Dfalse,Dfalse,Delse, Eioccc,
- drop, Eeof }
+ drop, Eeof, abort }
/*TRUEI FALSEI IF TRUE FALSE ELIF ELTRUE ELFALSE ELSE ENDIF
TRUEI FALSEI IF TRUE FALSE ELIF ELTRUE ELFALSE ELSE ENDIF (DODGY)
- PLAIN EOF */
+ PLAIN EOF ERROR */
};
/*
* State machine utility functions
*/
static void
-done(void)
-{
- if (incomment)
- error("EOF in comment");
- exit(exitstat);
-}
-static void
ignoreoff(void)
{
if (depth == 0)
@@ -450,22 +640,19 @@ ignoreon(void)
static void
keywordedit(const char *replacement)
{
- size_t size = tline + sizeof(tline) - keyword;
- char *dst = keyword;
- const char *src = replacement;
- if (size != 0) {
- while ((--size != 0) && (*src != '\0'))
- *dst++ = *src++;
- *dst = '\0';
- }
+ snprintf(keyword, tline + sizeof(tline) - keyword,
+ "%s%s", replacement, newline);
+ altered = true;
print();
}
static void
nest(void)
{
- depth += 1;
- if (depth >= MAXDEPTH)
+ if (depth > MAXDEPTH-1)
+ abort(); /* bug */
+ if (depth == MAXDEPTH-1)
error("Too many levels of nesting");
+ depth += 1;
stifline[depth] = linenum;
}
static void
@@ -482,7 +669,20 @@ state(Ifstate is)
}
/*
+ * The last state transition function. When this is called,
+ * lineval == LT_EOF, so the process() loop will terminate.
+ */
+static void
+done(void)
+{
+ if (incomment)
+ error("EOF in comment");
+ closeio();
+}
+
+/*
* Write a line to the output or not, according to command line options.
+ * If writing fails, closeio() will print the error and exit.
*/
static void
flushline(bool keep)
@@ -490,16 +690,58 @@ flushline(bool keep)
if (symlist)
return;
if (keep ^ complement) {
- if (lnnum && delcount > 0)
- printf("#line %d\n", linenum);
- fputs(tline, stdout);
- delcount = 0;
+ bool blankline = tline[strspn(tline, " \t\r\n")] == '\0';
+ if (blankline && compblank && blankcount != blankmax) {
+ delcount += 1;
+ blankcount += 1;
+ } else {
+ if (lnnum && delcount > 0)
+ hashline();
+ if (fputs(tline, output) == EOF)
+ closeio();
+ delcount = 0;
+ blankmax = blankcount = blankline ? blankcount + 1 : 0;
+ }
} else {
- if (lnblank)
- putc('\n', stdout);
- exitstat = 1;
+ if (lnblank && fputs(newline, output) == EOF)
+ closeio();
+ altered = true;
delcount += 1;
+ blankcount = 0;
}
+ if (debugging && fflush(output) == EOF)
+ closeio();
+}
+
+/*
+ * Format of #line directives depends on whether we know the input filename.
+ */
+static void
+hashline(void)
+{
+ int e;
+
+ if (linefile == NULL)
+ e = fprintf(output, "#line %d%s", linenum, newline);
+ else
+ e = fprintf(output, "#line %d \"%s\"%s",
+ linenum, linefile, newline);
+ if (e < 0)
+ closeio();
+}
+
+/*
+ * Flush the output and handle errors.
+ */
+static void
+closeio(void)
+{
+ /* Tidy up after findsym(). */
+ if (symdepth && !zerosyms)
+ printf("\n");
+ if (output != NULL && (ferror(output) || fclose(output) == EOF))
+ err(2, "%s: can't write to output", filename);
+ fclose(input);
}
/*
@@ -508,16 +750,22 @@ flushline(bool keep)
static void
process(void)
{
- Linetype lineval;
-
- for (;;) {
- linenum++;
- lineval = getline();
+ Linetype lineval = LT_PLAIN;
+ /* When compressing blank lines, act as if the file
+ is preceded by a large number of blank lines. */
+ blankmax = blankcount = 1000;
+ zerosyms = true;
+ newline = NULL;
+ linenum = 0;
+ altered = false;
+ while (lineval != LT_EOF) {
+ lineval = parseline();
trans_table[ifstate[depth]][lineval]();
- debug("process %s -> %s depth %d",
- linetype_name[lineval],
+ debug("process line %d %s -> %s depth %d",
+ linenum, linetype_name[lineval],
ifstate_name[ifstate[depth]], depth);
}
+ exitstat |= altered;
}
/*
@@ -526,101 +774,131 @@ process(void)
* help from skipcomment().
*/
static Linetype
-getline(void)
+parseline(void)
{
const char *cp;
int cursym;
- int kwlen;
Linetype retval;
Comment_state wascomment;
- if (fgets(tline, MAXLINE, input) == NULL)
- return (LT_EOF);
- retval = LT_PLAIN;
wascomment = incomment;
- cp = skipcomment(tline);
- if (linestate == LS_START) {
- if (*cp == '#') {
- linestate = LS_HASH;
- cp = skipcomment(cp + 1);
- } else if (*cp != '\0')
- linestate = LS_DIRTY;
+ cp = skiphash();
+ if (cp == NULL)
+ return (LT_EOF);
+ if (newline == NULL) {
+ if (strrchr(tline, '\n') == strrchr(tline, '\r') + 1)
+ newline = newline_crlf;
+ else
+ newline = newline_unix;
}
- if (!incomment && linestate == LS_HASH) {
- keyword = tline + (cp - tline);
- cp = skipsym(cp);
- kwlen = cp - keyword;
- /* no way can we deal with a continuation inside a keyword */
- if (strncmp(cp, "\\\n", 2) == 0)
- Eioccc();
- if (strlcmp("ifdef", keyword, kwlen) == 0 ||
- strlcmp("ifndef", keyword, kwlen) == 0) {
- cp = skipcomment(cp);
- if ((cursym = findsym(cp)) < 0)
- retval = LT_IF;
- else {
- retval = (keyword[2] == 'n')
- ? LT_FALSE : LT_TRUE;
- if (value[cursym] == NULL)
- retval = (retval == LT_TRUE)
- ? LT_FALSE : LT_TRUE;
- if (ignore[cursym])
- retval = (retval == LT_TRUE)
- ? LT_TRUEI : LT_FALSEI;
- }
- cp = skipsym(cp);
- } else if (strlcmp("if", keyword, kwlen) == 0)
- retval = ifeval(&cp);
- else if (strlcmp("elif", keyword, kwlen) == 0)
- retval = ifeval(&cp) - LT_IF + LT_ELIF;
- else if (strlcmp("else", keyword, kwlen) == 0)
- retval = LT_ELSE;
- else if (strlcmp("endif", keyword, kwlen) == 0)
- retval = LT_ENDIF;
+ if (*cp == '\0') {
+ retval = LT_PLAIN;
+ goto done;
+ }
+ keyword = tline + (cp - tline);
+ if ((cp = matchsym("ifdef", keyword)) != NULL ||
+ (cp = matchsym("ifndef", keyword)) != NULL) {
+ cp = skipcomment(cp);
+ if ((cursym = findsym(&cp)) < 0)
+ retval = LT_IF;
else {
- linestate = LS_DIRTY;
- retval = LT_PLAIN;
+ retval = (keyword[2] == 'n')
+ ? LT_FALSE : LT_TRUE;
+ if (value[cursym] == NULL)
+ retval = (retval == LT_TRUE)
+ ? LT_FALSE : LT_TRUE;
+ if (ignore[cursym])
+ retval = (retval == LT_TRUE)
+ ? LT_TRUEI : LT_FALSEI;
}
- cp = skipcomment(cp);
- if (*cp != '\0') {
+ } else if ((cp = matchsym("if", keyword)) != NULL)
+ retval = ifeval(&cp);
+ else if ((cp = matchsym("elif", keyword)) != NULL)
+ retval = linetype_if2elif(ifeval(&cp));
+ else if ((cp = matchsym("else", keyword)) != NULL)
+ retval = LT_ELSE;
+ else if ((cp = matchsym("endif", keyword)) != NULL)
+ retval = LT_ENDIF;
+ else {
+ cp = skipsym(keyword);
+ /* no way can we deal with a continuation inside a keyword */
+ if (strncmp(cp, "\\\r\n", 3) == 0 ||
+ strncmp(cp, "\\\n", 2) == 0)
+ Eioccc();
+ cp = skipline(cp);
+ retval = LT_PLAIN;
+ goto done;
+ }
+ cp = skipcomment(cp);
+ if (*cp != '\0') {
+ cp = skipline(cp);
+ if (retval == LT_TRUE || retval == LT_FALSE ||
+ retval == LT_TRUEI || retval == LT_FALSEI)
+ retval = LT_IF;
+ if (retval == LT_ELTRUE || retval == LT_ELFALSE)
+ retval = LT_ELIF;
+ }
+ /* the following can happen if the last line of the file lacks a
+ newline or if there is too much whitespace in a directive */
+ if (linestate == LS_HASH) {
+ long len = cp - tline;
+ if (fgets(tline + len, MAXLINE - len, input) == NULL) {
+ if (ferror(input))
+ err(2, "can't read %s", filename);
+ /* append the missing newline at eof */
+ strcpy(tline + len, newline);
+ cp += strlen(newline);
+ linestate = LS_START;
+ } else {
linestate = LS_DIRTY;
- if (retval == LT_TRUE || retval == LT_FALSE ||
- retval == LT_TRUEI || retval == LT_FALSEI)
- retval = LT_IF;
- if (retval == LT_ELTRUE || retval == LT_ELFALSE)
- retval = LT_ELIF;
- }
- if (retval != LT_PLAIN && (wascomment || incomment)) {
- retval += LT_DODGY;
- if (incomment)
- linestate = LS_DIRTY;
}
- /* skipcomment should have changed the state */
- if (linestate == LS_HASH)
- abort(); /* bug */
}
- if (linestate == LS_DIRTY) {
- while (*cp != '\0')
- cp = skipcomment(cp + 1);
+ if (retval != LT_PLAIN && (wascomment || linestate != LS_START)) {
+ retval = linetype_2dodgy(retval);
+ linestate = LS_DIRTY;
}
- debug("parser %s comment %s line",
+done:
+ debug("parser line %d state %s comment %s line", linenum,
comment_name[incomment], linestate_name[linestate]);
return (retval);
}
/*
* These are the binary operators that are supported by the expression
- * evaluator. Note that if support for division is added then we also
- * need short-circuiting booleans because of divide-by-zero.
+ * evaluator.
*/
-static int op_lt(int a, int b) { return (a < b); }
-static int op_gt(int a, int b) { return (a > b); }
-static int op_le(int a, int b) { return (a <= b); }
-static int op_ge(int a, int b) { return (a >= b); }
-static int op_eq(int a, int b) { return (a == b); }
-static int op_ne(int a, int b) { return (a != b); }
-static int op_or(int a, int b) { return (a || b); }
-static int op_and(int a, int b) { return (a && b); }
+static Linetype op_strict(long *p, long v, Linetype at, Linetype bt) {
+ if(at == LT_IF || bt == LT_IF) return (LT_IF);
+ return (*p = v, v ? LT_TRUE : LT_FALSE);
+}
+static Linetype op_lt(long *p, Linetype at, long a, Linetype bt, long b) {
+ return op_strict(p, a < b, at, bt);
+}
+static Linetype op_gt(long *p, Linetype at, long a, Linetype bt, long b) {
+ return op_strict(p, a > b, at, bt);
+}
+static Linetype op_le(long *p, Linetype at, long a, Linetype bt, long b) {
+ return op_strict(p, a <= b, at, bt);
+}
+static Linetype op_ge(long *p, Linetype at, long a, Linetype bt, long b) {
+ return op_strict(p, a >= b, at, bt);
+}
+static Linetype op_eq(long *p, Linetype at, long a, Linetype bt, long b) {
+ return op_strict(p, a == b, at, bt);
+}
+static Linetype op_ne(long *p, Linetype at, long a, Linetype bt, long b) {
+ return op_strict(p, a != b, at, bt);
+}
+static Linetype op_or(long *p, Linetype at, long a, Linetype bt, long b) {
+ if (!strictlogic && (at == LT_TRUE || bt == LT_TRUE))
+ return (*p = 1, LT_TRUE);
+ return op_strict(p, a || b, at, bt);
+}
+static Linetype op_and(long *p, Linetype at, long a, Linetype bt, long b) {
+ if (!strictlogic && (at == LT_FALSE || bt == LT_FALSE))
+ return (*p = 0, LT_FALSE);
+ return op_strict(p, a && b, at, bt);
+}
/*
* An evaluation function takes three arguments, as follows: (1) a pointer to
@@ -629,12 +907,12 @@ static int op_and(int a, int b) { return (a && b); }
* value of the expression; and (3) a pointer to a char* that points to the
* expression to be evaluated and that is updated to the end of the expression
* when evaluation is complete. The function returns LT_FALSE if the value of
- * the expression is zero, LT_TRUE if it is non-zero, or LT_IF if the
- * expression could not be evaluated.
+ * the expression is zero, LT_TRUE if it is non-zero, LT_IF if the expression
+ * depends on an unknown symbol, or LT_ERROR if there is a parse failure.
*/
struct ops;
-typedef Linetype eval_fn(const struct ops *, int *, const char **);
+typedef Linetype eval_fn(const struct ops *, long *, const char **);
static eval_fn eval_table, eval_unary;
@@ -645,13 +923,15 @@ static eval_fn eval_table, eval_unary;
* element of the table. Innermost expressions have special non-table-driven
* handling.
*/
-static const struct ops {
+struct op {
+ const char *str;
+ Linetype (*fn)(long *, Linetype, long, Linetype, long);
+};
+struct ops {
eval_fn *inner;
- struct op {
- const char *str;
- int (*fn)(int, int);
- } op[5];
-} eval_ops[] = {
+ struct op op[5];
+};
+static const struct ops eval_ops[] = {
{ eval_table, { { "||", op_or } } },
{ eval_table, { { "&&", op_and } } },
{ eval_table, { { "==", op_eq },
@@ -662,90 +942,119 @@ static const struct ops {
{ ">", op_gt } } }
};
+/* Current operator precedence level */
+static long prec(const struct ops *ops)
+{
+ return (ops - eval_ops);
+}
+
/*
* Function for evaluating the innermost parts of expressions,
- * viz. !expr (expr) defined(symbol) symbol number
- * We reset the keepthis flag when we find a non-constant subexpression.
+ * viz. !expr (expr) number defined(symbol) symbol
+ * We reset the constexpr flag in the last two cases.
*/
static Linetype
-eval_unary(const struct ops *ops, int *valp, const char **cpp)
+eval_unary(const struct ops *ops, long *valp, const char **cpp)
{
const char *cp;
char *ep;
int sym;
+ bool defparen;
+ Linetype lt;
cp = skipcomment(*cpp);
if (*cp == '!') {
- debug("eval%d !", ops - eval_ops);
+ debug("eval%d !", prec(ops));
cp++;
- if (eval_unary(ops, valp, &cp) == LT_IF)
- return (LT_IF);
- *valp = !*valp;
+ lt = eval_unary(ops, valp, &cp);
+ if (lt == LT_ERROR)
+ return (LT_ERROR);
+ if (lt != LT_IF) {
+ *valp = !*valp;
+ lt = *valp ? LT_TRUE : LT_FALSE;
+ }
} else if (*cp == '(') {
cp++;
- debug("eval%d (", ops - eval_ops);
- if (eval_table(eval_ops, valp, &cp) == LT_IF)
- return (LT_IF);
+ debug("eval%d (", prec(ops));
+ lt = eval_table(eval_ops, valp, &cp);
+ if (lt == LT_ERROR)
+ return (LT_ERROR);
cp = skipcomment(cp);
if (*cp++ != ')')
- return (LT_IF);
+ return (LT_ERROR);
} else if (isdigit((unsigned char)*cp)) {
- debug("eval%d number", ops - eval_ops);
+ debug("eval%d number", prec(ops));
*valp = strtol(cp, &ep, 0);
- cp = skipsym(cp);
- } else if (strncmp(cp, "defined", 7) == 0 && endsym(cp[7])) {
+ if (ep == cp)
+ return (LT_ERROR);
+ lt = *valp ? LT_TRUE : LT_FALSE;
+ cp = ep;
+ } else if (matchsym("defined", cp) != NULL) {
cp = skipcomment(cp+7);
- debug("eval%d defined", ops - eval_ops);
- if (*cp++ != '(')
- return (LT_IF);
- cp = skipcomment(cp);
- sym = findsym(cp);
- if (sym < 0)
- return (LT_IF);
- *valp = (value[sym] != NULL);
- cp = skipsym(cp);
+ if (*cp == '(') {
+ cp = skipcomment(cp+1);
+ defparen = true;
+ } else {
+ defparen = false;
+ }
+ sym = findsym(&cp);
cp = skipcomment(cp);
- if (*cp++ != ')')
- return (LT_IF);
- keepthis = false;
+ if (defparen && *cp++ != ')') {
+ debug("eval%d defined missing ')'", prec(ops));
+ return (LT_ERROR);
+ }
+ if (sym < 0) {
+ debug("eval%d defined unknown", prec(ops));
+ lt = LT_IF;
+ } else {
+ debug("eval%d defined %s", prec(ops), symname[sym]);
+ *valp = (value[sym] != NULL);
+ lt = *valp ? LT_TRUE : LT_FALSE;
+ }
+ constexpr = false;
} else if (!endsym(*cp)) {
- debug("eval%d symbol", ops - eval_ops);
- sym = findsym(cp);
- if (sym < 0)
- return (LT_IF);
- if (value[sym] == NULL)
+ debug("eval%d symbol", prec(ops));
+ sym = findsym(&cp);
+ if (sym < 0) {
+ lt = LT_IF;
+ cp = skipargs(cp);
+ } else if (value[sym] == NULL) {
*valp = 0;
- else {
+ lt = LT_FALSE;
+ } else {
*valp = strtol(value[sym], &ep, 0);
if (*ep != '\0' || ep == value[sym])
- return (LT_IF);
+ return (LT_ERROR);
+ lt = *valp ? LT_TRUE : LT_FALSE;
+ cp = skipargs(cp);
}
- cp = skipsym(cp);
- keepthis = false;
+ constexpr = false;
} else {
- debug("eval%d bad expr", ops - eval_ops);
- return (LT_IF);
+ debug("eval%d bad expr", prec(ops));
+ return (LT_ERROR);
}
*cpp = cp;
- debug("eval%d = %d", ops - eval_ops, *valp);
- return (*valp ? LT_TRUE : LT_FALSE);
+ debug("eval%d = %d", prec(ops), *valp);
+ return (lt);
}
/*
* Table-driven evaluation of binary operators.
*/
static Linetype
-eval_table(const struct ops *ops, int *valp, const char **cpp)
+eval_table(const struct ops *ops, long *valp, const char **cpp)
{
const struct op *op;
const char *cp;
- int val;
+ long val;
+ Linetype lt, rt;
- debug("eval%d", ops - eval_ops);
+ debug("eval%d", prec(ops));
cp = *cpp;
- if (ops->inner(ops+1, valp, &cp) == LT_IF)
- return (LT_IF);
+ lt = ops->inner(ops+1, valp, &cp);
+ if (lt == LT_ERROR)
+ return (LT_ERROR);
for (;;) {
cp = skipcomment(cp);
for (op = ops->op; op->str != NULL; op++)
@@ -754,15 +1063,17 @@ eval_table(const struct ops *ops, int *valp, const char **cpp)
if (op->str == NULL)
break;
cp += strlen(op->str);
- debug("eval%d %s", ops - eval_ops, op->str);
- if (ops->inner(ops+1, &val, &cp) == LT_IF)
- return (LT_IF);
- *valp = op->fn(*valp, val);
+ debug("eval%d %s", prec(ops), op->str);
+ rt = ops->inner(ops+1, &val, &cp);
+ if (rt == LT_ERROR)
+ return (LT_ERROR);
+ lt = op->fn(valp, lt, *valp, rt, val);
}
*cpp = cp;
- debug("eval%d = %d", ops - eval_ops, *valp);
- return (*valp ? LT_TRUE : LT_FALSE);
+ debug("eval%d = %d", prec(ops), *valp);
+ debug("eval%d lt = %s", prec(ops), linetype_name[lt]);
+ return (lt);
}
/*
@@ -773,14 +1084,57 @@ eval_table(const struct ops *ops, int *valp, const char **cpp)
static Linetype
ifeval(const char **cpp)
{
- int ret;
- int val;
+ Linetype ret;
+ long val = 0;
debug("eval %s", *cpp);
- keepthis = killconsts ? false : true;
+ constexpr = killconsts ? false : true;
ret = eval_table(eval_ops, &val, cpp);
debug("eval = %d", val);
- return (keepthis ? LT_IF : ret);
+ return (constexpr ? LT_IF : ret == LT_ERROR ? LT_IF : ret);
+}
+
+/*
+ * Read a line and examine its initial part to determine if it is a
+ * preprocessor directive. Returns NULL on EOF, or a pointer to a
+ * preprocessor directive name, or a pointer to the zero byte at the
+ * end of the line.
+ */
+static const char *
+skiphash(void)
+{
+ const char *cp;
+
+ linenum++;
+ if (fgets(tline, MAXLINE, input) == NULL) {
+ if (ferror(input))
+ err(2, "can't read %s", filename);
+ else
+ return (NULL);
+ }
+ cp = skipcomment(tline);
+ if (linestate == LS_START && *cp == '#') {
+ linestate = LS_HASH;
+ return (skipcomment(cp + 1));
+ } else if (*cp == '\0') {
+ return (cp);
+ } else {
+ return (skipline(cp));
+ }
+}
+
+/*
+ * Mark a line dirty and consume the rest of it, keeping track of the
+ * lexical state.
+ */
+static const char *
+skipline(const char *cp)
+{
+ if (*cp != '\0')
+ linestate = LS_DIRTY;
+ while (*cp != '\0')
+ cp = skipcomment(cp + 1);
+ return (cp);
}
/*
@@ -801,11 +1155,16 @@ skipcomment(const char *cp)
}
while (*cp != '\0')
/* don't reset to LS_START after a line continuation */
- if (strncmp(cp, "\\\n", 2) == 0)
+ if (strncmp(cp, "\\\r\n", 3) == 0)
+ cp += 3;
+ else if (strncmp(cp, "\\\n", 2) == 0)
cp += 2;
else switch (incomment) {
case NO_COMMENT:
- if (strncmp(cp, "/\\\n", 3) == 0) {
+ if (strncmp(cp, "/\\\r\n", 4) == 0) {
+ incomment = STARTING_COMMENT;
+ cp += 4;
+ } else if (strncmp(cp, "/\\\n", 3) == 0) {
incomment = STARTING_COMMENT;
cp += 3;
} else if (strncmp(cp, "/*", 2) == 0) {
@@ -825,7 +1184,7 @@ skipcomment(const char *cp)
} else if (strncmp(cp, "\n", 1) == 0) {
linestate = LS_START;
cp += 1;
- } else if (strchr(" \t", *cp) != NULL) {
+ } else if (strchr(" \r\t", *cp) != NULL) {
cp += 1;
} else
return (cp);
@@ -857,7 +1216,10 @@ skipcomment(const char *cp)
cp += 1;
continue;
case C_COMMENT:
- if (strncmp(cp, "*\\\n", 3) == 0) {
+ if (strncmp(cp, "*\\\r\n", 4) == 0) {
+ incomment = FINISHING_COMMENT;
+ cp += 4;
+ } else if (strncmp(cp, "*\\\n", 3) == 0) {
incomment = FINISHING_COMMENT;
cp += 3;
} else if (strncmp(cp, "*/", 2) == 0) {
@@ -892,6 +1254,31 @@ skipcomment(const char *cp)
}
/*
+ * Skip macro arguments.
+ */
+static const char *
+skipargs(const char *cp)
+{
+ const char *ocp = cp;
+ int level = 0;
+ cp = skipcomment(cp);
+ if (*cp != '(')
+ return (cp);
+ do {
+ if (*cp == '(')
+ level++;
+ if (*cp == ')')
+ level--;
+ cp = skipcomment(cp+1);
+ } while (level != 0 && *cp != '\0');
+ if (level == 0)
+ return (cp);
+ else
+ /* Rewind and re-detect the syntax error later. */
+ return (ocp);
+}
+
+/*
* Skip over an identifier.
*/
static const char *
@@ -903,27 +1290,69 @@ skipsym(const char *cp)
}
/*
- * Look for the symbol in the symbol table. If is is found, we return
+ * Skip whitespace and take a copy of any following identifier.
+ */
+static const char *
+getsym(const char **cpp)
+{
+ const char *cp = *cpp, *sym;
+
+ cp = skipcomment(cp);
+ cp = skipsym(sym = cp);
+ if (cp == sym)
+ return NULL;
+ *cpp = cp;
+ return (xstrdup(sym, cp));
+}
+
+/*
+ * Check that s (a symbol) matches the start of t, and that the
+ * following character in t is not a symbol character. Returns a
+ * pointer to the following character in t if there is a match,
+ * otherwise NULL.
+ */
+static const char *
+matchsym(const char *s, const char *t)
+{
+ while (*s != '\0' && *t != '\0')
+ if (*s != *t)
+ return (NULL);
+ else
+ ++s, ++t;
+ if (*s == '\0' && endsym(*t))
+ return(t);
+ else
+ return(NULL);
+}
+
+/*
+ * Look for the symbol in the symbol table. If it is found, we return
* the symbol table index, else we return -1.
*/
static int
-findsym(const char *str)
+findsym(const char **strp)
{
- const char *cp;
+ const char *str;
int symind;
- cp = skipsym(str);
- if (cp == str)
- return (-1);
+ str = *strp;
+ *strp = skipsym(str);
if (symlist) {
- printf("%.*s\n", (int)(cp-str), str);
+ if (*strp == str)
+ return (-1);
+ if (symdepth && firstsym)
+ printf("%s%3d", zerosyms ? "" : "\n", depth);
+ firstsym = zerosyms = false;
+ printf("%s%.*s%s",
+ symdepth ? " " : "",
+ (int)(*strp-str), str,
+ symdepth ? "" : "\n");
/* we don't care about the value of the symbol */
return (0);
}
for (symind = 0; symind < nsyms; ++symind) {
- if (strlcmp(symname[symind], str, cp-str) == 0) {
- debug("findsym %s %s", symname[symind],
- value[symind] ? value[symind] : "");
+ if (matchsym(symname[symind], str) != NULL) {
+ debugsym("findsym", symind);
return (symind);
}
}
@@ -931,51 +1360,194 @@ findsym(const char *str)
}
/*
+ * Resolve indirect symbol values to their final definitions.
+ */
+static void
+indirectsym(void)
+{
+ const char *cp;
+ int changed, sym, ind;
+
+ do {
+ changed = 0;
+ for (sym = 0; sym < nsyms; ++sym) {
+ if (value[sym] == NULL)
+ continue;
+ cp = value[sym];
+ ind = findsym(&cp);
+ if (ind == -1 || ind == sym ||
+ *cp != '\0' ||
+ value[ind] == NULL ||
+ value[ind] == value[sym])
+ continue;
+ debugsym("indir...", sym);
+ value[sym] = value[ind];
+ debugsym("...ectsym", sym);
+ changed++;
+ }
+ } while (changed);
+}
+
+/*
+ * Add a symbol to the symbol table, specified with the format sym=val
+ */
+static void
+addsym1(bool ignorethis, bool definethis, char *symval)
+{
+ const char *sym, *val;
+
+ sym = symval;
+ val = skipsym(sym);
+ if (definethis && *val == '=') {
+ symval[val - sym] = '\0';
+ val = val + 1;
+ } else if (*val == '\0') {
+ val = definethis ? "1" : NULL;
+ } else {
+ usage();
+ }
+ addsym2(ignorethis, sym, val);
+}
+
+/*
* Add a symbol to the symbol table.
*/
static void
-addsym(bool ignorethis, bool definethis, char *sym)
+addsym2(bool ignorethis, const char *sym, const char *val)
{
+ const char *cp = sym;
int symind;
- char *val;
- symind = findsym(sym);
+ symind = findsym(&cp);
if (symind < 0) {
if (nsyms >= MAXSYMS)
errx(2, "too many symbols");
symind = nsyms++;
}
- symname[symind] = sym;
ignore[symind] = ignorethis;
- val = sym + (skipsym(sym) - sym);
- if (definethis) {
- if (*val == '=') {
- value[symind] = val+1;
- *val = '\0';
- } else if (*val == '\0')
- value[symind] = "";
- else
- usage();
+ symname[symind] = sym;
+ value[symind] = val;
+ debugsym("addsym", symind);
+}
+
+static void
+debugsym(const char *why, int symind)
+{
+ debug("%s %s%c%s", why, symname[symind],
+ value[symind] ? '=' : ' ',
+ value[symind] ? value[symind] : "undef");
+}
+
+/*
+ * Add symbols to the symbol table from a file containing
+ * #define and #undef preprocessor directives.
+ */
+static void
+defundefile(const char *fn)
+{
+ filename = fn;
+ input = fopen(fn, "rb");
+ if (input == NULL)
+ err(2, "can't open %s", fn);
+ linenum = 0;
+ while (defundef())
+ ;
+ if (ferror(input))
+ err(2, "can't read %s", filename);
+ else
+ fclose(input);
+ if (incomment)
+ error("EOF in comment");
+}
+
+/*
+ * Read and process one #define or #undef directive
+ */
+static bool
+defundef(void)
+{
+ const char *cp, *kw, *sym, *val, *end;
+
+ cp = skiphash();
+ if (cp == NULL)
+ return (false);
+ if (*cp == '\0')
+ goto done;
+ /* strip trailing whitespace, and do a fairly rough check to
+ avoid unsupported multi-line preprocessor directives */
+ end = cp + strlen(cp);
+ while (end > tline && strchr(" \t\n\r", end[-1]) != NULL)
+ --end;
+ if (end > tline && end[-1] == '\\')
+ Eioccc();
+
+ kw = cp;
+ if ((cp = matchsym("define", kw)) != NULL) {
+ sym = getsym(&cp);
+ if (sym == NULL)
+ error("missing macro name in #define");
+ if (*cp == '(') {
+ val = "1";
+ } else {
+ cp = skipcomment(cp);
+ val = (cp < end) ? xstrdup(cp, end) : "";
+ }
+ debug("#define");
+ addsym2(false, sym, val);
+ } else if ((cp = matchsym("undef", kw)) != NULL) {
+ sym = getsym(&cp);
+ if (sym == NULL)
+ error("missing macro name in #undef");
+ cp = skipcomment(cp);
+ debug("#undef");
+ addsym2(false, sym, NULL);
} else {
- if (*val != '\0')
- usage();
- value[symind] = NULL;
+ error("unrecognized preprocessor directive");
}
+ skipline(cp);
+done:
+ debug("parser line %d state %s comment %s line", linenum,
+ comment_name[incomment], linestate_name[linestate]);
+ return (true);
}
/*
- * Compare s with n characters of t.
- * The same as strncmp() except that it checks that s[n] == '\0'.
+ * Concatenate two strings into new memory, checking for failure.
*/
-static int
-strlcmp(const char *s, const char *t, size_t n)
+static char *
+astrcat(const char *s1, const char *s2)
{
- while (n-- && *t != '\0')
- if (*s != *t)
- return ((unsigned char)*s - (unsigned char)*t);
- else
- ++s, ++t;
- return ((unsigned char)*s);
+ char *s;
+ int len;
+ size_t size;
+
+ len = snprintf(NULL, 0, "%s%s", s1, s2);
+ if (len < 0)
+ err(2, "snprintf");
+ size = (size_t)len + 1;
+ s = (char *)malloc(size);
+ if (s == NULL)
+ err(2, "malloc");
+ snprintf(s, size, "%s%s", s1, s2);
+ return (s);
+}
+
+/*
+ * Duplicate a segment of a string, checking for failure.
+ */
+static const char *
+xstrdup(const char *start, const char *end)
+{
+ size_t n;
+ char *s;
+
+ if (end < start) abort(); /* bug */
+ n = (size_t)(end - start) + 1;
+ s = malloc(n);
+ if (s == NULL)
+ err(2, "malloc");
+ snprintf(s, n, "%s", start);
+ return (s);
}
/*
@@ -1001,5 +1573,6 @@ error(const char *msg)
else
warnx("%s: %d: %s (#if line %d depth %d)",
filename, linenum, msg, stifline[depth], depth);
+ closeio();
errx(2, "output may be truncated");
}
diff --git a/extra/scripts/unifdef.h b/extra/scripts/unifdef.h
new file mode 100644
index 000000000..276015c82
--- /dev/null
+++ b/extra/scripts/unifdef.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2012 - 2013 Tony Finch <dot@dotat.at>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/stat.h>
+
+#include <ctype.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+/* Avoid err.h since this are non-standard BSD extensions */
+#define vwarnx(fmt, args) ({ fprintf(stderr, "unifdef: "); vfprintf(stderr, fmt, args); fprintf(stderr, "\n"); })
+#define warnx(fmt, args...) fprintf(stderr, "unifdef: " fmt "\n", ## args)
+#define warn(fmt, args...) warnx(fmt ": %s", ## args, strerror(errno))
+#define errx(exit_code, fmt, args...) ({ warnx(fmt, ## args); exit(exit_code); })
+#define err(exit_code, fmt, args...) errx(exit_code, fmt ": %s", ## args, strerror(errno))
+
+/* portability stubs */
+
+#define fbinmode(fp) (fp)
+
+#define replace(old,new) rename(old,new)
+
+static FILE *
+mktempmode(char *tmp, int mode)
+{
+ int fd = mkstemp(tmp);
+ if (fd < 0) return (NULL);
+ fchmod(fd, mode & (S_IRWXU|S_IRWXG|S_IRWXO));
+ return (fdopen(fd, "wb"));
+}
diff --git a/extra/scripts/unifdef.test b/extra/scripts/unifdef.test
new file mode 100644
index 000000000..5ba4e48df
--- /dev/null
+++ b/extra/scripts/unifdef.test
@@ -0,0 +1,67 @@
+Run me through unifdef -UA
+*** Nothing should be visible here:
+#if defined A && defined B
+hello world
+#endif
+#if defined A && B
+hello world
+#endif
+#if defined A && 1
+hello world
+#endif
+#if defined A && (1 > 0)
+hello world
+#endif
+#if defined B && defined A
+hello world
+#endif
+#if B && defined A
+hello world
+#endif
+#if 1 && defined A
+hello world
+#endif
+#if (1 > 0) && defined A
+hello world
+#endif
+#if defined A && (defined FOO || defined BAR)
+hello world
+#endif
+#if (defined FOO || defined BAR) && defined A
+hello world
+#endif
+
+*** Everything should be visible here, but #if/#endif removed:
+#if defined B || !defined A
+hello world 1
+#endif
+#if !defined A || defined B
+hello world 2 (last)
+#endif
+
+*** This should be unchanged (#if/#endif not removed):
+#if defined A || defined B
+I am here 1
+#endif
+#if defined B || defined A
+I am here 2
+#endif
+I am here 3
+#if !defined FOO && !defined BAR \
+ && !defined BAZ
+# error "I am here 4"
+#endif
+I am here 5
+#if (!defined FOO \
+ && (defined BAR || defined BAZ \
+ || defined XYZ))
+I am here 6
+#endif
+I am here 7
+#if !defined FOO \
+ && defined BAR
+I am here 8
+#endif
+I am here 9 (last)
+
+*** End
diff --git a/extra/scripts/version.h b/extra/scripts/version.h
new file mode 100644
index 000000000..5636b1b81
--- /dev/null
+++ b/extra/scripts/version.h
@@ -0,0 +1,2 @@
+"@(#) $Version: unifdef-2.10.4.1542ea4 $\n"
+"@(#) $Date: 2014-01-07 22:32:21 +0000 $\n"
diff --git a/include/.gitignore b/include/.gitignore
new file mode 100644
index 000000000..8f86c4c80
--- /dev/null
+++ b/include/.gitignore
@@ -0,0 +1,50 @@
+#
+# Never ignore these
+#
+!.gitignore
+
+#
+# Generated files
+#
+/bits/
+/config/
+/generated/
+
+/bfin_fixed_code.h
+/bfin_l1layout.h
+/bfin_sram.h
+/dl-osinfo.h
+/fpu_control.h
+/hp-timing.h
+/jmpbuf-offsets.h
+/jmpbuf-unwind.h
+/not-cancel.h
+/pthread.h
+/semaphore.h
+/thread_db.h
+/sgidefs.h
+
+/sys/acct.h
+/sys/asm.h
+/sys/cachectl.h
+/sys/debugreg.h
+/sys/elf.h
+/sys/epoll.h
+/sys/eventfd.h
+/sys/fpregdef.h
+/sys/inotify.h
+/sys/io.h
+/sys/perm.h
+/sys/prctl.h
+/sys/procfs.h
+/sys/ptrace.h
+/sys/random.h
+/sys/reg.h
+/sys/regdef.h
+/sys/signalfd.h
+/sys/sysmips.h
+/sys/tas.h
+/sys/timerfd.h
+/sys/ucontext.h
+/sys/user.h
+/sys/vm86.h
diff --git a/include/a.out.h b/include/a.out.h
index d963de74c..50a9f0735 100644
--- a/include/a.out.h
+++ b/include/a.out.h
@@ -1,5 +1 @@
-#ifdef _LIBC
-# include_next <linux/a.out.h>
-#else
-# include <linux/a.out.h>
-#endif
+#define __NO_A_OUT_SUPPORT 1
diff --git a/include/alloca.h b/include/alloca.h
index b4fc31738..b3a1e4a6a 100644
--- a/include/alloca.h
+++ b/include/alloca.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 _ALLOCA_H
#define _ALLOCA_H 1
@@ -36,7 +35,40 @@ extern void *alloca (size_t __size) __THROW;
# define alloca(size) __builtin_alloca (size)
#endif /* GCC. */
-#define __MAX_ALLOCA_CUTOFF 65536
+#ifdef _LIBC
+# define __MAX_ALLOCA_CUTOFF 65536
+
+# include <bits/stackinfo.h>
+# ifdef _STACK_GROWS_DOWN
+# define extend_alloca(buf, len, newlen) \
+ (__typeof (buf)) ({ size_t __newlen = (newlen); \
+ char *__newbuf = alloca (__newlen); \
+ if (__newbuf + __newlen == (char *) buf) \
+ len += __newlen; \
+ else \
+ len = __newlen; \
+ __newbuf; })
+# elif defined _STACK_GROWS_UP
+# define extend_alloca(buf, len, newlen) \
+ (__typeof (buf)) ({ size_t __newlen = (newlen); \
+ char *__newbuf = alloca (__newlen); \
+ char *__buf = (buf); \
+ if (__buf + __newlen == __newbuf) \
+ { \
+ len += __newlen; \
+ __newbuf = __buf; \
+ } \
+ else \
+ len = __newlen; \
+ __newbuf; })
+# else
+# error unknown stack
+# define extend_alloca(buf, len, newlen) \
+ alloca (((len) = (newlen)))
+# endif
+
+extern int __libc_alloca_cutoff (size_t size);
+#endif
__END_DECLS
diff --git a/include/ar.h b/include/ar.h
index 5d157eca9..30c3fc6a9 100644
--- a/include/ar.h
+++ b/include/ar.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 _AR_H
#define _AR_H 1
diff --git a/include/argp.h b/include/argp.h
new file mode 100644
index 000000000..9d5372890
--- /dev/null
+++ b/include/argp.h
@@ -0,0 +1,566 @@
+/* Hierarchial argument parsing, layered over getopt.
+ Copyright (C) 1995-1999, 2003, 2004, 2005, 2006, 2007, 2009
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Miles Bader <miles at gnu.ai.mit.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.
+
+ Modified for uClibc by: Salvatore Cro <salvatore.cro at st.com>
+*/
+
+#ifndef _ARGP_H
+#define _ARGP_H
+
+#include <stdio.h>
+#include <ctype.h>
+#include <limits.h>
+
+#define __need_error_t
+#include <errno.h>
+
+#ifndef __const
+# define __const const
+#endif
+
+#ifndef __THROW
+# define __THROW
+#endif
+#ifndef __NTH
+# define __NTH(fct) fct __THROW
+#endif
+
+#ifndef __attribute__
+/* This feature is available in gcc versions 2.5 and later. */
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || defined(__STRICT_ANSI__)
+# define __attribute__(Spec) /* empty */
+# endif
+/* The __-protected variants of `format' and `printf' attributes
+ are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) || defined(__STRICT_ANSI__)
+# define __format__ format
+# define __printf__ printf
+# endif
+#endif
+
+/* GCC 2.95 and later have "__restrict"; C99 compilers have
+ "restrict", and "configure" may have defined "restrict". */
+#ifndef __restrict
+# if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__))
+# if defined restrict || 199901L <= __STDC_VERSION__
+# define __restrict restrict
+# else
+# define __restrict
+# endif
+# endif
+#endif
+
+#ifndef __error_t_defined
+typedef int error_t;
+# define __error_t_defined
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* A description of a particular option. A pointer to an array of
+ these is passed in the OPTIONS field of an argp structure. Each option
+ entry can correspond to one long option and/or one short option; more
+ names for the same option can be added by following an entry in an option
+ array with options having the OPTION_ALIAS flag set. */
+struct argp_option
+{
+ /* The long option name. For more than one name for the same option, you
+ can use following options with the OPTION_ALIAS flag set. */
+ __const char *name;
+
+ /* What key is returned for this option. If > 0 and printable, then it's
+ also accepted as a short option. */
+ int key;
+
+ /* If non-NULL, this is the name of the argument associated with this
+ option, which is required unless the OPTION_ARG_OPTIONAL flag is set. */
+ __const char *arg;
+
+ /* OPTION_ flags. */
+ int flags;
+
+ /* The doc string for this option. If both NAME and KEY are 0, This string
+ will be printed outdented from the normal option column, making it
+ useful as a group header (it will be the first thing printed in its
+ group); in this usage, it's conventional to end the string with a `:'. */
+ __const char *doc;
+
+ /* The group this option is in. In a long help message, options are sorted
+ alphabetically within each group, and the groups presented in the order
+ 0, 1, 2, ..., n, -m, ..., -2, -1. Every entry in an options array with
+ if this field 0 will inherit the group number of the previous entry, or
+ zero if it's the first one, unless its a group header (NAME and KEY both
+ 0), in which case, the previous entry + 1 is the default. Automagic
+ options such as --help are put into group -1. */
+ int group;
+};
+
+/* The argument associated with this option is optional. */
+#define OPTION_ARG_OPTIONAL 0x1
+
+/* This option isn't displayed in any help messages. */
+#define OPTION_HIDDEN 0x2
+
+/* This option is an alias for the closest previous non-alias option. This
+ means that it will be displayed in the same help entry, and will inherit
+ fields other than NAME and KEY from the aliased option. */
+#define OPTION_ALIAS 0x4
+
+/* This option isn't actually an option (and so should be ignored by the
+ actual option parser), but rather an arbitrary piece of documentation that
+ should be displayed in much the same manner as the options. If this flag
+ is set, then the option NAME field is displayed unmodified (e.g., no `--'
+ prefix is added) at the left-margin (where a *short* option would normally
+ be displayed), and the documentation string in the normal place. For
+ purposes of sorting, any leading whitespace and punctuation is ignored,
+ except that if the first non-whitespace character is not `-', this entry
+ is displayed after all options (and OPTION_DOC entries with a leading `-')
+ in the same group. */
+#define OPTION_DOC 0x8
+
+/* This option shouldn't be included in `long' usage messages (but is still
+ included in help messages). This is mainly intended for options that are
+ completely documented in an argp's ARGS_DOC field, in which case including
+ the option in the generic usage list would be redundant. For instance,
+ if ARGS_DOC is "FOO BAR\n-x BLAH", and the `-x' option's purpose is to
+ distinguish these two cases, -x should probably be marked
+ OPTION_NO_USAGE. */
+#define OPTION_NO_USAGE 0x10
+
+struct argp; /* fwd declare this type */
+struct argp_state; /* " */
+struct argp_child; /* " */
+
+/* The type of a pointer to an argp parsing function. */
+typedef error_t (*argp_parser_t) (int __key, char *__arg,
+ struct argp_state *__state);
+
+/* What to return for unrecognized keys. For special ARGP_KEY_ keys, such
+ returns will simply be ignored. For user keys, this error will be turned
+ into EINVAL (if the call to argp_parse is such that errors are propagated
+ back to the user instead of exiting); returning EINVAL itself would result
+ in an immediate stop to parsing in *all* cases. */
+#define ARGP_ERR_UNKNOWN E2BIG /* Hurd should never need E2BIG. XXX */
+
+/* Special values for the KEY argument to an argument parsing function.
+ ARGP_ERR_UNKNOWN should be returned if they aren't understood.
+
+ The sequence of keys to a parsing function is either (where each
+ uppercased word should be prefixed by `ARGP_KEY_' and opt is a user key):
+
+ INIT opt... NO_ARGS END SUCCESS -- No non-option arguments at all
+ or INIT (opt | ARG)... END SUCCESS -- All non-option args parsed
+ or INIT (opt | ARG)... SUCCESS -- Some non-option arg unrecognized
+
+ The third case is where every parser returned ARGP_KEY_UNKNOWN for an
+ argument, in which case parsing stops at that argument (returning the
+ unparsed arguments to the caller of argp_parse if requested, or stopping
+ with an error message if not).
+
+ If an error occurs (either detected by argp, or because the parsing
+ function returned an error value), then the parser is called with
+ ARGP_KEY_ERROR, and no further calls are made. */
+
+/* This is not an option at all, but rather a command line argument. If a
+ parser receiving this key returns success, the fact is recorded, and the
+ ARGP_KEY_NO_ARGS case won't be used. HOWEVER, if while processing the
+ argument, a parser function decrements the NEXT field of the state it's
+ passed, the option won't be considered processed; this is to allow you to
+ actually modify the argument (perhaps into an option), and have it
+ processed again. */
+#define ARGP_KEY_ARG 0
+/* There are remaining arguments not parsed by any parser, which may be found
+ starting at (STATE->argv + STATE->next). If success is returned, but
+ STATE->next left untouched, it's assumed that all arguments were consume,
+ otherwise, the parser should adjust STATE->next to reflect any arguments
+ consumed. */
+#define ARGP_KEY_ARGS 0x1000006
+/* There are no more command line arguments at all. */
+#define ARGP_KEY_END 0x1000001
+/* Because it's common to want to do some special processing if there aren't
+ any non-option args, user parsers are called with this key if they didn't
+ successfully process any non-option arguments. Called just before
+ ARGP_KEY_END (where more general validity checks on previously parsed
+ arguments can take place). */
+#define ARGP_KEY_NO_ARGS 0x1000002
+/* Passed in before any parsing is done. Afterwards, the values of each
+ element of the CHILD_INPUT field, if any, in the state structure is
+ copied to each child's state to be the initial value of the INPUT field. */
+#define ARGP_KEY_INIT 0x1000003
+/* Use after all other keys, including SUCCESS & END. */
+#define ARGP_KEY_FINI 0x1000007
+/* Passed in when parsing has successfully been completed (even if there are
+ still arguments remaining). */
+#define ARGP_KEY_SUCCESS 0x1000004
+/* Passed in if an error occurs. */
+#define ARGP_KEY_ERROR 0x1000005
+
+/* An argp structure contains a set of options declarations, a function to
+ deal with parsing one, documentation string, a possible vector of child
+ argp's, and perhaps a function to filter help output. When actually
+ parsing options, getopt is called with the union of all the argp
+ structures chained together through their CHILD pointers, with conflicts
+ being resolved in favor of the first occurrence in the chain. */
+struct argp
+{
+ /* An array of argp_option structures, terminated by an entry with both
+ NAME and KEY having a value of 0. */
+ __const struct argp_option *options;
+
+ /* What to do with an option from this structure. KEY is the key
+ associated with the option, and ARG is any associated argument (NULL if
+ none was supplied). If KEY isn't understood, ARGP_ERR_UNKNOWN should be
+ returned. If a non-zero, non-ARGP_ERR_UNKNOWN value is returned, then
+ parsing is stopped immediately, and that value is returned from
+ argp_parse(). For special (non-user-supplied) values of KEY, see the
+ ARGP_KEY_ definitions below. */
+ argp_parser_t parser;
+
+ /* A string describing what other arguments are wanted by this program. It
+ is only used by argp_usage to print the `Usage:' message. If it
+ contains newlines, the strings separated by them are considered
+ alternative usage patterns, and printed on separate lines (lines after
+ the first are prefix by ` or: ' instead of `Usage:'). */
+ __const char *args_doc;
+
+ /* If non-NULL, a string containing extra text to be printed before and
+ after the options in a long help message (separated by a vertical tab
+ `\v' character). */
+ __const char *doc;
+
+ /* A vector of argp_children structures, terminated by a member with a 0
+ argp field, pointing to child argps should be parsed with this one. Any
+ conflicts are resolved in favor of this argp, or early argps in the
+ CHILDREN list. This field is useful if you use libraries that supply
+ their own argp structure, which you want to use in conjunction with your
+ own. */
+ __const struct argp_child *children;
+
+ /* If non-zero, this should be a function to filter the output of help
+ messages. KEY is either a key from an option, in which case TEXT is
+ that option's help text, or a special key from the ARGP_KEY_HELP_
+ defines, below, describing which other help text TEXT is. The function
+ should return either TEXT, if it should be used as-is, a replacement
+ string, which should be malloced, and will be freed by argp, or NULL,
+ meaning `print nothing'. The value for TEXT is *after* any translation
+ has been done, so if any of the replacement text also needs translation,
+ that should be done by the filter function. INPUT is either the input
+ supplied to argp_parse, or NULL, if argp_help was called directly. */
+ char *(*help_filter) (int __key, __const char *__text, void *__input);
+
+ /* If non-zero the strings used in the argp library are translated using
+ the domain described by this string. Otherwise the currently installed
+ default domain is used. */
+ const char *argp_domain;
+};
+
+/* Possible KEY arguments to a help filter function. */
+#define ARGP_KEY_HELP_PRE_DOC 0x2000001 /* Help text preceeding options. */
+#define ARGP_KEY_HELP_POST_DOC 0x2000002 /* Help text following options. */
+#define ARGP_KEY_HELP_HEADER 0x2000003 /* Option header string. */
+#define ARGP_KEY_HELP_EXTRA 0x2000004 /* After all other documentation;
+ TEXT is NULL for this key. */
+/* Explanatory note emitted when duplicate option arguments have been
+ suppressed. */
+#define ARGP_KEY_HELP_DUP_ARGS_NOTE 0x2000005
+#define ARGP_KEY_HELP_ARGS_DOC 0x2000006 /* Argument doc string. */
+
+/* When an argp has a non-zero CHILDREN field, it should point to a vector of
+ argp_child structures, each of which describes a subsidiary argp. */
+struct argp_child
+{
+ /* The child parser. */
+ __const struct argp *argp;
+
+ /* Flags for this child. */
+ int flags;
+
+ /* If non-zero, an optional header to be printed in help output before the
+ child options. As a side-effect, a non-zero value forces the child
+ options to be grouped together; to achieve this effect without actually
+ printing a header string, use a value of "". */
+ __const char *header;
+
+ /* Where to group the child options relative to the other (`consolidated')
+ options in the parent argp; the values are the same as the GROUP field
+ in argp_option structs, but all child-groupings follow parent options at
+ a particular group level. If both this field and HEADER are zero, then
+ they aren't grouped at all, but rather merged with the parent options
+ (merging the child's grouping levels with the parents). */
+ int group;
+};
+
+/* Parsing state. This is provided to parsing functions called by argp,
+ which may examine and, as noted, modify fields. */
+struct argp_state
+{
+ /* The top level ARGP being parsed. */
+ __const struct argp *root_argp;
+
+ /* The argument vector being parsed. May be modified. */
+ int argc;
+ char **argv;
+
+ /* The index in ARGV of the next arg that to be parsed. May be modified. */
+ int next;
+
+ /* The flags supplied to argp_parse. May be modified. */
+ unsigned flags;
+
+ /* While calling a parsing function with a key of ARGP_KEY_ARG, this is the
+ number of the current arg, starting at zero, and incremented after each
+ such call returns. At all other times, this is the number of such
+ arguments that have been processed. */
+ unsigned arg_num;
+
+ /* If non-zero, the index in ARGV of the first argument following a special
+ `--' argument (which prevents anything following being interpreted as an
+ option). Only set once argument parsing has proceeded past this point. */
+ int quoted;
+
+ /* An arbitrary pointer passed in from the user. */
+ void *input;
+ /* Values to pass to child parsers. This vector will be the same length as
+ the number of children for the current parser. */
+ void **child_inputs;
+
+ /* For the parser's use. Initialized to 0. */
+ void *hook;
+
+ /* The name used when printing messages. This is initialized to ARGV[0],
+ or PROGRAM_INVOCATION_NAME if that is unavailable. */
+ char *name;
+
+ /* Streams used when argp prints something. */
+ FILE *err_stream; /* For errors; initialized to stderr. */
+ FILE *out_stream; /* For information; initialized to stdout. */
+
+ void *pstate; /* Private, for use by argp. */
+};
+
+/* Flags for argp_parse (note that the defaults are those that are
+ convenient for program command line parsing): */
+
+/* Don't ignore the first element of ARGV. Normally (and always unless
+ ARGP_NO_ERRS is set) the first element of the argument vector is
+ skipped for option parsing purposes, as it corresponds to the program name
+ in a command line. */
+#define ARGP_PARSE_ARGV0 0x01
+
+/* Don't print error messages for unknown options to stderr; unless this flag
+ is set, ARGP_PARSE_ARGV0 is ignored, as ARGV[0] is used as the program
+ name in the error messages. This flag implies ARGP_NO_EXIT (on the
+ assumption that silent exiting upon errors is bad behaviour). */
+#define ARGP_NO_ERRS 0x02
+
+/* Don't parse any non-option args. Normally non-option args are parsed by
+ calling the parse functions with a key of ARGP_KEY_ARG, and the actual arg
+ as the value. Since it's impossible to know which parse function wants to
+ handle it, each one is called in turn, until one returns 0 or an error
+ other than ARGP_ERR_UNKNOWN; if an argument is handled by no one, the
+ argp_parse returns prematurely (but with a return value of 0). If all
+ args have been parsed without error, all parsing functions are called one
+ last time with a key of ARGP_KEY_END. This flag needn't normally be set,
+ as the normal behavior is to stop parsing as soon as some argument can't
+ be handled. */
+#define ARGP_NO_ARGS 0x04
+
+/* Parse options and arguments in the same order they occur on the command
+ line -- normally they're rearranged so that all options come first. */
+#define ARGP_IN_ORDER 0x08
+
+/* Don't provide the standard long option --help, which causes usage and
+ option help information to be output to stdout, and exit (0) called. */
+#define ARGP_NO_HELP 0x10
+
+/* Don't exit on errors (they may still result in error messages). */
+#define ARGP_NO_EXIT 0x20
+
+/* Use the gnu getopt `long-only' rules for parsing arguments. */
+#define ARGP_LONG_ONLY 0x40
+
+/* Turns off any message-printing/exiting options. */
+#define ARGP_SILENT (ARGP_NO_EXIT | ARGP_NO_ERRS | ARGP_NO_HELP)
+
+/* Parse the options strings in ARGC & ARGV according to the options in ARGP.
+ FLAGS is one of the ARGP_ flags above. If ARG_INDEX is non-NULL, the
+ index in ARGV of the first unparsed option is returned in it. If an
+ unknown option is present, ARGP_ERR_UNKNOWN is returned; if some parser
+ routine returned a non-zero value, it is returned; otherwise 0 is
+ returned. This function may also call exit unless the ARGP_NO_HELP flag
+ is set. INPUT is a pointer to a value to be passed in to the parser. */
+extern error_t argp_parse (__const struct argp *__restrict __argp,
+ int __argc, char **__restrict __argv,
+ unsigned __flags, int *__restrict __arg_index,
+ void *__restrict __input);
+
+/* Global variables. */
+
+/* If defined or set by the user program to a non-zero value, then a default
+ option --version is added (unless the ARGP_NO_HELP flag is used), which
+ will print this string followed by a newline and exit (unless the
+ ARGP_NO_EXIT flag is used). Overridden by ARGP_PROGRAM_VERSION_HOOK. */
+extern __const char *argp_program_version;
+
+/* If defined or set by the user program to a non-zero value, then a default
+ option --version is added (unless the ARGP_NO_HELP flag is used), which
+ calls this function with a stream to print the version to and a pointer to
+ the current parsing state, and then exits (unless the ARGP_NO_EXIT flag is
+ used). This variable takes precedent over ARGP_PROGRAM_VERSION. */
+extern void (*argp_program_version_hook) (FILE *__restrict __stream,
+ struct argp_state *__restrict
+ __state);
+
+/* If defined or set by the user program, it should point to string that is
+ the bug-reporting address for the program. It will be printed by
+ argp_help if the ARGP_HELP_BUG_ADDR flag is set (as it is by various
+ standard help messages), embedded in a sentence that says something like
+ `Report bugs to ADDR.'. */
+extern __const char *argp_program_bug_address;
+
+/* The exit status that argp will use when exiting due to a parsing error.
+ If not defined or set by the user program, this defaults to EX_USAGE from
+ <sysexits.h>. */
+extern error_t argp_err_exit_status;
+
+/* Flags for argp_help. */
+#define ARGP_HELP_USAGE 0x01 /* a Usage: message. */
+#define ARGP_HELP_SHORT_USAGE 0x02 /* " but don't actually print options. */
+#define ARGP_HELP_SEE 0x04 /* a `Try ... for more help' message. */
+#define ARGP_HELP_LONG 0x08 /* a long help message. */
+#define ARGP_HELP_PRE_DOC 0x10 /* doc string preceding long help. */
+#define ARGP_HELP_POST_DOC 0x20 /* doc string following long help. */
+#define ARGP_HELP_DOC (ARGP_HELP_PRE_DOC | ARGP_HELP_POST_DOC)
+#define ARGP_HELP_BUG_ADDR 0x40 /* bug report address */
+#define ARGP_HELP_LONG_ONLY 0x80 /* modify output appropriately to
+ reflect ARGP_LONG_ONLY mode. */
+
+/* These ARGP_HELP flags are only understood by argp_state_help. */
+#define ARGP_HELP_EXIT_ERR 0x100 /* Call exit(1) instead of returning. */
+#define ARGP_HELP_EXIT_OK 0x200 /* Call exit(0) instead of returning. */
+
+/* The standard thing to do after a program command line parsing error, if an
+ error message has already been printed. */
+#define ARGP_HELP_STD_ERR \
+ (ARGP_HELP_SEE | ARGP_HELP_EXIT_ERR)
+/* The standard thing to do after a program command line parsing error, if no
+ more specific error message has been printed. */
+#define ARGP_HELP_STD_USAGE \
+ (ARGP_HELP_SHORT_USAGE | ARGP_HELP_SEE | ARGP_HELP_EXIT_ERR)
+/* The standard thing to do in response to a --help option. */
+#define ARGP_HELP_STD_HELP \
+ (ARGP_HELP_SHORT_USAGE | ARGP_HELP_LONG | ARGP_HELP_EXIT_OK \
+ | ARGP_HELP_DOC | ARGP_HELP_BUG_ADDR)
+
+/* Output a usage message for ARGP to STREAM. FLAGS are from the set
+ ARGP_HELP_*. */
+extern void argp_help (__const struct argp *__restrict __argp,
+ FILE *__restrict __stream,
+ unsigned __flags, char *__restrict __name);
+
+/* The following routines are intended to be called from within an argp
+ parsing routine (thus taking an argp_state structure as the first
+ argument). They may or may not print an error message and exit, depending
+ on the flags in STATE -- in any case, the caller should be prepared for
+ them *not* to exit, and should return an appropiate error after calling
+ them. [argp_usage & argp_error should probably be called argp_state_...,
+ but they're used often enough that they should be short] */
+
+/* Output, if appropriate, a usage message for STATE to STREAM. FLAGS are
+ from the set ARGP_HELP_*. */
+extern void argp_state_help (__const struct argp_state *__restrict __state,
+ FILE *__restrict __stream,
+ unsigned int __flags);
+/* Possibly output the standard usage message for ARGP to stderr and exit. */
+extern void argp_usage (__const struct argp_state *__state);
+
+/* If appropriate, print the printf string FMT and following args, preceded
+ by the program name and `:', to stderr, and followed by a `Try ... --help'
+ message, then exit (1). */
+extern void argp_error (__const struct argp_state *__restrict __state,
+ __const char *__restrict __fmt, ...)
+ __attribute__ ((__format__ (__printf__, 2, 3)));
+/* Similar to the standard gnu error-reporting function error(), but will
+ respect the ARGP_NO_EXIT and ARGP_NO_ERRS flags in STATE, and will print
+ to STATE->err_stream. This is useful for argument parsing code that is
+ shared between program startup (when exiting is desired) and runtime
+ option parsing (when typically an error code is returned instead). The
+ difference between this function and argp_error is that the latter is for
+ *parsing errors*, and the former is for other problems that occur during
+ parsing but don't reflect a (syntactic) problem with the input. */
+extern void argp_failure (__const struct argp_state *__restrict __state,
+ int __status, int __errnum,
+ __const char *__restrict __fmt, ...)
+ __attribute__ ((__format__ (__printf__, 4, 5)));
+/* Returns true if the option OPT is a valid short option. */
+extern int _option_is_short (__const struct argp_option *__opt) __THROW;
+extern int __option_is_short (__const struct argp_option *__opt) __THROW;
+
+/* Returns true if the option OPT is in fact the last (unused) entry in an
+ options array. */
+extern int _option_is_end (__const struct argp_option *__opt) __THROW;
+extern int __option_is_end (__const struct argp_option *__opt) __THROW;
+
+/* Return the input field for ARGP in the parser corresponding to STATE; used
+ by the help routines. */
+/* We think this should not be exported */
+extern void *__argp_input (__const struct argp *__restrict __argp,
+ __const struct argp_state *__restrict __state)
+ __THROW;
+
+#ifdef __USE_EXTERN_INLINES
+
+# ifndef ARGP_EI
+# define ARGP_EI __extern_inline
+# endif
+
+ARGP_EI void
+argp_usage (__const struct argp_state *__state)
+{
+ argp_state_help (__state, stderr, ARGP_HELP_STD_USAGE);
+}
+
+ARGP_EI int
+__NTH (__option_is_short (__const struct argp_option *__opt))
+{
+ if (__opt->flags & OPTION_DOC)
+ return 0;
+ else
+ {
+ int __key = __opt->key;
+ return __key > 0 && __key <= UCHAR_MAX && isprint (__key);
+ }
+}
+
+ARGP_EI int
+__NTH (__option_is_end (__const struct argp_option *__opt))
+{
+ return !__opt->key && !__opt->name && !__opt->doc && !__opt->group;
+}
+#endif /* Use extern inlines. */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* argp.h */
diff --git a/include/arpa/inet.h b/include/arpa/inet.h
index 02233d4e7..4a90cf2cf 100644
--- a/include/arpa/inet.h
+++ b/include/arpa/inet.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 1999, 2000, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1999, 2000, 2001, 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
@@ -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 _ARPA_INET_H
#define _ARPA_INET_H 1
@@ -32,7 +31,8 @@ __BEGIN_DECLS
/* Convert Internet host address from numbers-and-dots notation in CP
into binary data in network byte order. */
-extern in_addr_t inet_addr (__const char *__cp) __THROW;
+extern in_addr_t inet_addr (const char *__cp) __THROW;
+libc_hidden_proto(inet_addr)
/* Return the local host address part of the Internet address in IN. */
extern in_addr_t inet_lnaof (struct in_addr __in) __THROW;
@@ -41,40 +41,50 @@ extern in_addr_t inet_lnaof (struct in_addr __in) __THROW;
network number NET with the local address HOST. */
extern struct in_addr inet_makeaddr (in_addr_t __net, in_addr_t __host)
__THROW;
+libc_hidden_proto(inet_makeaddr)
/* Return network number part of the Internet address IN. */
extern in_addr_t inet_netof (struct in_addr __in) __THROW;
+libc_hidden_proto(inet_netof)
/* Extract the network number in network byte order from the address
in numbers-and-dots natation starting at CP. */
-extern in_addr_t inet_network (__const char *__cp) __THROW;
+extern in_addr_t inet_network (const char *__cp) __THROW;
+libc_hidden_proto(inet_network)
/* Convert Internet number in IN to ASCII representation. The return value
is a pointer to an internal array containing the string. */
extern char *inet_ntoa (struct in_addr __in) __THROW;
+libc_hidden_proto(inet_ntoa)
+#ifdef __UCLIBC__
/* Recursion-safe flavor */
extern char *inet_ntoa_r (struct in_addr __in, char *__buf) __THROW;
+#endif
/* Convert from presentation format of an Internet number in buffer
starting at CP to the binary network format and store result for
interface type AF in buffer starting at BUF. */
-extern int inet_pton (int __af, __const char *__restrict __cp,
+extern int inet_pton (int __af, const char *__restrict __cp,
void *__restrict __buf) __THROW;
+libc_hidden_proto(inet_pton)
/* Convert a Internet address in binary network format for interface
type AF in buffer starting at CP to presentation form and place
result in buffer of length LEN astarting at BUF. */
-extern __const char *inet_ntop (int __af, __const void *__restrict __cp,
+extern const char *inet_ntop (int __af, const void *__restrict __cp,
char *__restrict __buf, socklen_t __len)
__THROW;
+libc_hidden_proto(inet_ntop)
/* The following functions are not part of XNS 5.2. */
#ifdef __USE_MISC
/* Convert Internet host address from numbers-and-dots notation in CP
into binary data and store the result in the structure INP. */
-extern int inet_aton (__const char *__cp, struct in_addr *__inp) __THROW;
+extern int inet_aton (const char *__cp, struct in_addr *__inp) __THROW;
+libc_hidden_proto(inet_aton)
+#if 0
/* Format a network number NET into presentation format and place result
in buffer starting at BUF with length of LEN bytes. */
extern char *inet_neta (in_addr_t __net, char *__buf, size_t __len) __THROW;
@@ -82,26 +92,27 @@ extern char *inet_neta (in_addr_t __net, char *__buf, size_t __len) __THROW;
/* Convert network number for interface type AF in buffer starting at
CP to presentation format. The result will specifiy BITS bits of
the number. */
-extern char *inet_net_ntop (int __af, __const void *__cp, int __bits,
+extern char *inet_net_ntop (int __af, const void *__cp, int __bits,
char *__buf, size_t __len) __THROW;
/* Convert network number for interface type AF from presentation in
buffer starting at CP to network format and store result int
buffer starting at BUF of size LEN. */
-extern int inet_net_pton (int __af, __const char *__cp,
+extern int inet_net_pton (int __af, const char *__cp,
void *__buf, size_t __len) __THROW;
/* Convert ASCII representation in hexadecimal form of the Internet
address to binary form and place result in buffer of length LEN
starting at BUF. */
-extern unsigned int inet_nsap_addr (__const char *__cp,
+extern unsigned int inet_nsap_addr (const char *__cp,
unsigned char *__buf, int __len) __THROW;
/* Convert internet address in binary form in LEN bytes starting at CP
a presentation form and place result in BUF. */
-extern char *inet_nsap_ntoa (int __len, __const unsigned char *__cp,
+extern char *inet_nsap_ntoa (int __len, const unsigned char *__cp,
char *__buf) __THROW;
#endif
+#endif
__END_DECLS
diff --git a/include/arpa/nameser.h b/include/arpa/nameser.h
index 496c8dbe8..17c68f595 100644
--- a/include/arpa/nameser.h
+++ b/include/arpa/nameser.h
@@ -118,15 +118,7 @@ typedef struct __ns_msg {
const u_char *_ptr;
} ns_msg;
-/* Private data structure - do not use from outside library. */
-struct _ns_flagdata { int mask, shift; };
-extern struct _ns_flagdata _ns_flagdata[];
-
/* Accessor macros - this is part of the public interface. */
-#define ns_msg_getflag(handle, flag) ( \
- ((handle)._flags & _ns_flagdata[flag].mask) \
- >> _ns_flagdata[flag].shift \
- )
#define ns_msg_id(handle) ((handle)._id + 0)
#define ns_msg_base(handle) ((handle)._msg + 0)
#define ns_msg_end(handle) ((handle)._eom + 0)
@@ -287,7 +279,7 @@ typedef enum __ns_type {
ns_t_naptr = 35, /* Naming Authority PoinTeR */
ns_t_kx = 36, /* Key Exchange */
ns_t_cert = 37, /* Certification record */
- ns_t_a6 = 38, /* IPv6 address (deprecates AAAA) */
+ ns_t_a6 = 38, /* IPv6 address (deprecated, use ns_t_aaaa) */
ns_t_dname = 39, /* Non-terminal DNAME (for IPv6) */
ns_t_sink = 40, /* Kitchen sink (experimentatl) */
ns_t_opt = 41, /* EDNS0 option (meta-RR) */
@@ -499,6 +491,7 @@ typedef enum __ns_cert_types {
#define ns_samename __ns_samename
__BEGIN_DECLS
+int ns_msg_getflag (ns_msg, int) __THROW;
u_int ns_get16 (const u_char *) __THROW;
u_long ns_get32 (const u_char *) __THROW;
void ns_put16 (u_int, u_char *) __THROW;
@@ -506,6 +499,7 @@ void ns_put32 (u_long, u_char *) __THROW;
int ns_initparse (const u_char *, int, ns_msg *) __THROW;
int ns_skiprr (const u_char *, const u_char *, ns_sect, int)
__THROW;
+libc_hidden_proto(ns_skiprr)
int ns_parserr (ns_msg *, ns_sect, int, ns_rr *) __THROW;
int ns_sprintrr (const ns_msg *, const ns_rr *,
const char *, const char *, char *, size_t)
@@ -519,16 +513,23 @@ int ns_parse_ttl (const char *, u_long *) __THROW;
u_int32_t ns_datetosecs (const char *cp, int *errp) __THROW;
int ns_name_ntol (const u_char *, u_char *, size_t) __THROW;
int ns_name_ntop (const u_char *, char *, size_t) __THROW;
+libc_hidden_proto(ns_name_ntop)
int ns_name_pton (const char *, u_char *, size_t) __THROW;
+libc_hidden_proto(ns_name_pton)
int ns_name_unpack (const u_char *, const u_char *,
const u_char *, u_char *, size_t) __THROW;
+libc_hidden_proto(ns_name_unpack)
int ns_name_pack (const u_char *, u_char *, int,
const u_char **, const u_char **) __THROW;
+libc_hidden_proto(ns_name_pack)
int ns_name_uncompress (const u_char *, const u_char *,
const u_char *, char *, size_t) __THROW;
+libc_hidden_proto(ns_name_uncompress)
int ns_name_compress (const char *, u_char *, size_t,
const u_char **, const u_char **) __THROW;
+libc_hidden_proto(ns_name_compress)
int ns_name_skip (const u_char **, const u_char *) __THROW;
+libc_hidden_proto(ns_name_skip)
void ns_name_rollback (const u_char *, const u_char **,
const u_char **) __THROW;
int ns_sign (u_char *, int *, int, int, void *,
diff --git a/include/arpa/nameser_compat.h b/include/arpa/nameser_compat.h
index e3ef864cd..7fe46a16d 100644
--- a/include/arpa/nameser_compat.h
+++ b/include/arpa/nameser_compat.h
@@ -47,7 +47,7 @@
typedef struct {
unsigned id :16; /* query identification number */
-#if BYTE_ORDER == BIG_ENDIAN
+#if __BYTE_ORDER == __BIG_ENDIAN
/* fields in third byte */
unsigned qr: 1; /* response flag */
unsigned opcode: 4; /* purpose of message */
@@ -61,7 +61,7 @@ typedef struct {
unsigned cd: 1; /* checking disabled by resolver */
unsigned rcode :4; /* response code */
#endif
-#if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN
+#if __BYTE_ORDER == __LITTLE_ENDIAN || __BYTE_ORDER == __PDP_ENDIAN
/* fields in third byte */
unsigned rd :1; /* recursion desired */
unsigned tc :1; /* truncated message */
diff --git a/include/assert.h b/include/assert.h
index 9b9d1b796..ee8e85fa2 100644
--- a/include/assert.h
+++ b/include/assert.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 Standard: 7.2 Diagnostics <assert.h>
@@ -51,14 +50,15 @@
__BEGIN_DECLS
/* This prints an "Assertion failed" message and aborts. */
-extern void __assert __P((const char *, const char *, int, const char *));
+extern void __assert(const char *, const char *, unsigned int, const char *)
+ __THROW __attribute__ ((__noreturn__));
+libc_hidden_proto(__assert)
__END_DECLS
# define assert(expr) \
- (__ASSERT_VOID_CAST ((expr) ? 0 : \
- (__assert (__STRING(expr), __FILE__, __LINE__, \
- __ASSERT_FUNCTION), 0)))
+ (__ASSERT_VOID_CAST ((expr) ? 0 : \
+ (__assert (__STRING(expr), __FILE__, __LINE__, __ASSERT_FUNCTION), 0)))
/* Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__'
which contains the name of the function currently being defined.
@@ -71,7 +71,7 @@ __END_DECLS
# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
# define __ASSERT_FUNCTION __func__
# else
-# define __ASSERT_FUNCTION ((__const char *) 0)
+# define __ASSERT_FUNCTION ((const char *) 0)
# endif
# endif
diff --git a/include/atomic.h b/include/atomic.h
index aff41202e..3680d8714 100644
--- a/include/atomic.h
+++ b/include/atomic.h
@@ -1,5 +1,5 @@
/* Internal macros for atomic operations for GNU C Library.
- Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -14,13 +14,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/>. */
#ifndef _ATOMIC_H
#define _ATOMIC_H 1
+/* This header defines three types of macros:
+
+ - atomic arithmetic and logic operation on memory. They all
+ have the prefix "atomic_".
+
+ - conditionally atomic operations of the same kinds. These
+ always behave identical but can be faster when atomicity
+ is not really needed since only one thread has access to
+ the memory location. In that case the code is slower in
+ the multi-thread case. The interfaces have the prefix
+ "catomic_".
+
+ - support functions like barriers. They also have the prefix
+ "atomic_".
+
+ Architectures must provide a few lowlevel macros (the compare
+ and exchange definitions). All others are optional. They
+ should only be provided if the architecture has specific
+ support for the operation.
+
+ As <atomic.h> macros are usually heavily nested and often use local
+ variables to make sure side-effects are evaluated properly, use for
+ macro local variables a per-macro unique prefix. This file uses
+ __atgN_ prefix where N is different in each macro. */
+
#include <stdlib.h>
#include <bits/atomic.h>
@@ -30,33 +54,33 @@
and following args. */
#define __atomic_val_bysize(pre, post, mem, ...) \
({ \
- __typeof (*mem) __result; \
+ __typeof (*mem) __atg1_result; \
if (sizeof (*mem) == 1) \
- __result = pre##_8_##post (mem, __VA_ARGS__); \
+ __atg1_result = pre##_8_##post (mem, __VA_ARGS__); \
else if (sizeof (*mem) == 2) \
- __result = pre##_16_##post (mem, __VA_ARGS__); \
+ __atg1_result = pre##_16_##post (mem, __VA_ARGS__); \
else if (sizeof (*mem) == 4) \
- __result = pre##_32_##post (mem, __VA_ARGS__); \
+ __atg1_result = pre##_32_##post (mem, __VA_ARGS__); \
else if (sizeof (*mem) == 8) \
- __result = pre##_64_##post (mem, __VA_ARGS__); \
+ __atg1_result = pre##_64_##post (mem, __VA_ARGS__); \
else \
abort (); \
- __result; \
+ __atg1_result; \
})
#define __atomic_bool_bysize(pre, post, mem, ...) \
({ \
- int __result; \
+ int __atg2_result; \
if (sizeof (*mem) == 1) \
- __result = pre##_8_##post (mem, __VA_ARGS__); \
+ __atg2_result = pre##_8_##post (mem, __VA_ARGS__); \
else if (sizeof (*mem) == 2) \
- __result = pre##_16_##post (mem, __VA_ARGS__); \
+ __atg2_result = pre##_16_##post (mem, __VA_ARGS__); \
else if (sizeof (*mem) == 4) \
- __result = pre##_32_##post (mem, __VA_ARGS__); \
+ __atg2_result = pre##_32_##post (mem, __VA_ARGS__); \
else if (sizeof (*mem) == 8) \
- __result = pre##_64_##post (mem, __VA_ARGS__); \
+ __atg2_result = pre##_64_##post (mem, __VA_ARGS__); \
else \
abort (); \
- __result; \
+ __atg2_result; \
})
@@ -70,6 +94,29 @@
#endif
+#ifndef catomic_compare_and_exchange_val_acq
+# ifdef __arch_c_compare_and_exchange_val_32_acq
+# define catomic_compare_and_exchange_val_acq(mem, newval, oldval) \
+ __atomic_val_bysize (__arch_c_compare_and_exchange_val,acq, \
+ mem, newval, oldval)
+# else
+# define catomic_compare_and_exchange_val_acq(mem, newval, oldval) \
+ atomic_compare_and_exchange_val_acq (mem, newval, oldval)
+# endif
+#endif
+
+
+#ifndef catomic_compare_and_exchange_val_rel
+# ifndef atomic_compare_and_exchange_val_rel
+# define catomic_compare_and_exchange_val_rel(mem, newval, oldval) \
+ catomic_compare_and_exchange_val_acq (mem, newval, oldval)
+# else
+# define catomic_compare_and_exchange_val_rel(mem, newval, oldval) \
+ atomic_compare_and_exchange_val_rel (mem, newval, oldval)
+# endif
+#endif
+
+
#ifndef atomic_compare_and_exchange_val_rel
# define atomic_compare_and_exchange_val_rel(mem, newval, oldval) \
atomic_compare_and_exchange_val_acq (mem, newval, oldval)
@@ -83,17 +130,46 @@
# define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \
__atomic_bool_bysize (__arch_compare_and_exchange_bool,acq, \
mem, newval, oldval)
-# else
-# define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \
+# else
+# define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \
({ /* Cannot use __oldval here, because macros later in this file might \
call this macro with __oldval argument. */ \
- __typeof (oldval) __old = (oldval); \
- atomic_compare_and_exchange_val_acq (mem, newval, __old) != __old; \
+ __typeof (oldval) __atg3_old = (oldval); \
+ atomic_compare_and_exchange_val_acq (mem, newval, __atg3_old) \
+ != __atg3_old; \
})
# endif
#endif
+#ifndef catomic_compare_and_exchange_bool_acq
+# ifdef __arch_c_compare_and_exchange_bool_32_acq
+# define catomic_compare_and_exchange_bool_acq(mem, newval, oldval) \
+ __atomic_bool_bysize (__arch_c_compare_and_exchange_bool,acq, \
+ mem, newval, oldval)
+# else
+# define catomic_compare_and_exchange_bool_acq(mem, newval, oldval) \
+ ({ /* Cannot use __oldval here, because macros later in this file might \
+ call this macro with __oldval argument. */ \
+ __typeof (oldval) __atg4_old = (oldval); \
+ catomic_compare_and_exchange_val_acq (mem, newval, __atg4_old) \
+ != __atg4_old; \
+ })
+# endif
+#endif
+
+
+#ifndef catomic_compare_and_exchange_bool_rel
+# ifndef atomic_compare_and_exchange_bool_rel
+# define catomic_compare_and_exchange_bool_rel(mem, newval, oldval) \
+ catomic_compare_and_exchange_bool_acq (mem, newval, oldval)
+# else
+# define catomic_compare_and_exchange_bool_rel(mem, newval, oldval) \
+ atomic_compare_and_exchange_bool_rel (mem, newval, oldval)
+# endif
+#endif
+
+
#ifndef atomic_compare_and_exchange_bool_rel
# define atomic_compare_and_exchange_bool_rel(mem, newval, oldval) \
atomic_compare_and_exchange_bool_acq (mem, newval, oldval)
@@ -103,18 +179,17 @@
/* Store NEWVALUE in *MEM and return the old value. */
#ifndef atomic_exchange_acq
# define atomic_exchange_acq(mem, newvalue) \
- ({ __typeof (*(mem)) __oldval; \
- __typeof (mem) __memp = (mem); \
- __typeof (*(mem)) __value = (newvalue); \
+ ({ __typeof (*(mem)) __atg5_oldval; \
+ __typeof (mem) __atg5_memp = (mem); \
+ __typeof (*(mem)) __atg5_value = (newvalue); \
\
do \
- __oldval = (*__memp); \
- while (__builtin_expect (atomic_compare_and_exchange_bool_acq (__memp, \
- __value, \
- __oldval),\
- 0)); \
+ __atg5_oldval = *__atg5_memp; \
+ while (__builtin_expect \
+ (atomic_compare_and_exchange_bool_acq (__atg5_memp, __atg5_value, \
+ __atg5_oldval), 0)); \
\
- __oldval; })
+ __atg5_oldval; })
#endif
#ifndef atomic_exchange_rel
@@ -123,21 +198,106 @@
/* Add VALUE to *MEM and return the old value of *MEM. */
+#ifndef atomic_exchange_and_add_acq
+# ifdef atomic_exchange_and_add
+# define atomic_exchange_and_add_acq(mem, value) \
+ atomic_exchange_and_add (mem, value)
+# else
+# define atomic_exchange_and_add_acq(mem, value) \
+ ({ __typeof (*(mem)) __atg6_oldval; \
+ __typeof (mem) __atg6_memp = (mem); \
+ __typeof (*(mem)) __atg6_value = (value); \
+ \
+ do \
+ __atg6_oldval = *__atg6_memp; \
+ while (__builtin_expect \
+ (atomic_compare_and_exchange_bool_acq (__atg6_memp, \
+ __atg6_oldval \
+ + __atg6_value, \
+ __atg6_oldval), 0)); \
+ \
+ __atg6_oldval; })
+# endif
+#endif
+
+#ifndef atomic_exchange_and_add_rel
+# define atomic_exchange_and_add_rel(mem, value) \
+ atomic_exchange_and_add_acq(mem, value)
+#endif
+
#ifndef atomic_exchange_and_add
# define atomic_exchange_and_add(mem, value) \
- ({ __typeof (*(mem)) __oldval; \
- __typeof (mem) __memp = (mem); \
- __typeof (*(mem)) __value = (value); \
+ atomic_exchange_and_add_acq(mem, value)
+#endif
+
+#ifndef catomic_exchange_and_add
+# define catomic_exchange_and_add(mem, value) \
+ ({ __typeof (*(mem)) __atg7_oldv; \
+ __typeof (mem) __atg7_memp = (mem); \
+ __typeof (*(mem)) __atg7_value = (value); \
\
do \
- __oldval = (*__memp); \
- while (__builtin_expect (atomic_compare_and_exchange_bool_acq (__memp, \
- __oldval \
- + __value,\
- __oldval),\
- 0)); \
+ __atg7_oldv = *__atg7_memp; \
+ while (__builtin_expect \
+ (catomic_compare_and_exchange_bool_acq (__atg7_memp, \
+ __atg7_oldv \
+ + __atg7_value, \
+ __atg7_oldv), 0)); \
\
- __oldval; })
+ __atg7_oldv; })
+#endif
+
+
+#ifndef atomic_max
+# define atomic_max(mem, value) \
+ do { \
+ __typeof (*(mem)) __atg8_oldval; \
+ __typeof (mem) __atg8_memp = (mem); \
+ __typeof (*(mem)) __atg8_value = (value); \
+ do { \
+ __atg8_oldval = *__atg8_memp; \
+ if (__atg8_oldval >= __atg8_value) \
+ break; \
+ } while (__builtin_expect \
+ (atomic_compare_and_exchange_bool_acq (__atg8_memp, __atg8_value,\
+ __atg8_oldval), 0)); \
+ } while (0)
+#endif
+
+
+#ifndef catomic_max
+# define catomic_max(mem, value) \
+ do { \
+ __typeof (*(mem)) __atg9_oldv; \
+ __typeof (mem) __atg9_memp = (mem); \
+ __typeof (*(mem)) __atg9_value = (value); \
+ do { \
+ __atg9_oldv = *__atg9_memp; \
+ if (__atg9_oldv >= __atg9_value) \
+ break; \
+ } while (__builtin_expect \
+ (catomic_compare_and_exchange_bool_acq (__atg9_memp, \
+ __atg9_value, \
+ __atg9_oldv), 0)); \
+ } while (0)
+#endif
+
+
+#ifndef atomic_min
+# define atomic_min(mem, value) \
+ do { \
+ __typeof (*(mem)) __atg10_oldval; \
+ __typeof (mem) __atg10_memp = (mem); \
+ __typeof (*(mem)) __atg10_value = (value); \
+ do { \
+ __atg10_oldval = *__atg10_memp; \
+ if (__atg10_oldval <= __atg10_value) \
+ break; \
+ } while (__builtin_expect \
+ (atomic_compare_and_exchange_bool_acq (__atg10_memp, \
+ __atg10_value, \
+ __atg10_oldval), 0)); \
+ } while (0)
#endif
@@ -146,16 +306,32 @@
#endif
+#ifndef catomic_add
+# define catomic_add(mem, value) \
+ (void) catomic_exchange_and_add ((mem), (value))
+#endif
+
+
#ifndef atomic_increment
# define atomic_increment(mem) atomic_add ((mem), 1)
#endif
+#ifndef catomic_increment
+# define catomic_increment(mem) catomic_add ((mem), 1)
+#endif
+
+
#ifndef atomic_increment_val
# define atomic_increment_val(mem) (atomic_exchange_and_add ((mem), 1) + 1)
#endif
+#ifndef catomic_increment_val
+# define catomic_increment_val(mem) (catomic_exchange_and_add ((mem), 1) + 1)
+#endif
+
+
/* Add one to *MEM and return true iff it's now zero. */
#ifndef atomic_increment_and_test
# define atomic_increment_and_test(mem) \
@@ -168,11 +344,21 @@
#endif
+#ifndef catomic_decrement
+# define catomic_decrement(mem) catomic_add ((mem), -1)
+#endif
+
+
#ifndef atomic_decrement_val
# define atomic_decrement_val(mem) (atomic_exchange_and_add ((mem), -1) - 1)
#endif
+#ifndef catomic_decrement_val
+# define catomic_decrement_val(mem) (catomic_exchange_and_add ((mem), -1) - 1)
+#endif
+
+
/* Subtract 1 from *MEM and return true iff it's now zero. */
#ifndef atomic_decrement_and_test
# define atomic_decrement_and_test(mem) \
@@ -183,35 +369,34 @@
/* Decrement *MEM if it is > 0, and return the old value. */
#ifndef atomic_decrement_if_positive
# define atomic_decrement_if_positive(mem) \
- ({ __typeof (*(mem)) __oldval; \
- __typeof (mem) __memp = (mem); \
+ ({ __typeof (*(mem)) __atg11_oldval; \
+ __typeof (mem) __atg11_memp = (mem); \
\
do \
{ \
- __oldval = *__memp; \
- if (__builtin_expect (__oldval <= 0, 0)) \
+ __atg11_oldval = *__atg11_memp; \
+ if (__builtin_expect (__atg11_oldval <= 0, 0)) \
break; \
} \
- while (__builtin_expect (atomic_compare_and_exchange_bool_acq (__memp, \
- __oldval \
- - 1, \
- __oldval),\
- 0));\
- __oldval; })
+ while (__builtin_expect \
+ (atomic_compare_and_exchange_bool_acq (__atg11_memp, \
+ __atg11_oldval - 1, \
+ __atg11_oldval), 0)); \
+ __atg11_oldval; })
#endif
#ifndef atomic_add_negative
# define atomic_add_negative(mem, value) \
- ({ __typeof (value) __aan_value = (value); \
- atomic_exchange_and_add (mem, __aan_value) < -__aan_value; })
+ ({ __typeof (value) __atg12_value = (value); \
+ atomic_exchange_and_add (mem, __atg12_value) < -__atg12_value; })
#endif
#ifndef atomic_add_zero
# define atomic_add_zero(mem, value) \
- ({ __typeof (value) __aaz_value = (value); \
- atomic_exchange_and_add (mem, __aaz_value) == -__aaz_value; })
+ ({ __typeof (value) __atg13_value = (value); \
+ atomic_exchange_and_add (mem, __atg13_value) == -__atg13_value; })
#endif
@@ -223,21 +408,119 @@
#ifndef atomic_bit_test_set
# define atomic_bit_test_set(mem, bit) \
- ({ __typeof (*(mem)) __oldval; \
- __typeof (mem) __memp = (mem); \
- __typeof (*(mem)) __mask = ((__typeof (*(mem))) 1 << (bit)); \
+ ({ __typeof (*(mem)) __atg14_old; \
+ __typeof (mem) __atg14_memp = (mem); \
+ __typeof (*(mem)) __atg14_mask = ((__typeof (*(mem))) 1 << (bit)); \
\
do \
- __oldval = (*__memp); \
- while (__builtin_expect (atomic_compare_and_exchange_bool_acq (__memp, \
- __oldval \
- | __mask, \
- __oldval),\
- 0)); \
+ __atg14_old = (*__atg14_memp); \
+ while (__builtin_expect \
+ (atomic_compare_and_exchange_bool_acq (__atg14_memp, \
+ __atg14_old | __atg14_mask,\
+ __atg14_old), 0)); \
+ \
+ __atg14_old & __atg14_mask; })
+#endif
+
+/* Atomically *mem &= mask. */
+#ifndef atomic_and
+# define atomic_and(mem, mask) \
+ do { \
+ __typeof (*(mem)) __atg15_old; \
+ __typeof (mem) __atg15_memp = (mem); \
+ __typeof (*(mem)) __atg15_mask = (mask); \
+ \
+ do \
+ __atg15_old = (*__atg15_memp); \
+ while (__builtin_expect \
+ (atomic_compare_and_exchange_bool_acq (__atg15_memp, \
+ __atg15_old & __atg15_mask, \
+ __atg15_old), 0)); \
+ } while (0)
+#endif
+
+#ifndef catomic_and
+# define catomic_and(mem, mask) \
+ do { \
+ __typeof (*(mem)) __atg20_old; \
+ __typeof (mem) __atg20_memp = (mem); \
+ __typeof (*(mem)) __atg20_mask = (mask); \
+ \
+ do \
+ __atg20_old = (*__atg20_memp); \
+ while (__builtin_expect \
+ (catomic_compare_and_exchange_bool_acq (__atg20_memp, \
+ __atg20_old & __atg20_mask,\
+ __atg20_old), 0)); \
+ } while (0)
+#endif
+
+/* Atomically *mem &= mask and return the old value of *mem. */
+#ifndef atomic_and_val
+# define atomic_and_val(mem, mask) \
+ ({ __typeof (*(mem)) __atg16_old; \
+ __typeof (mem) __atg16_memp = (mem); \
+ __typeof (*(mem)) __atg16_mask = (mask); \
+ \
+ do \
+ __atg16_old = (*__atg16_memp); \
+ while (__builtin_expect \
+ (atomic_compare_and_exchange_bool_acq (__atg16_memp, \
+ __atg16_old & __atg16_mask,\
+ __atg16_old), 0)); \
+ \
+ __atg16_old; })
+#endif
+
+/* Atomically *mem |= mask and return the old value of *mem. */
+#ifndef atomic_or
+# define atomic_or(mem, mask) \
+ do { \
+ __typeof (*(mem)) __atg17_old; \
+ __typeof (mem) __atg17_memp = (mem); \
+ __typeof (*(mem)) __atg17_mask = (mask); \
\
- __oldval & __mask; })
+ do \
+ __atg17_old = (*__atg17_memp); \
+ while (__builtin_expect \
+ (atomic_compare_and_exchange_bool_acq (__atg17_memp, \
+ __atg17_old | __atg17_mask, \
+ __atg17_old), 0)); \
+ } while (0)
#endif
+#ifndef catomic_or
+# define catomic_or(mem, mask) \
+ do { \
+ __typeof (*(mem)) __atg18_old; \
+ __typeof (mem) __atg18_memp = (mem); \
+ __typeof (*(mem)) __atg18_mask = (mask); \
+ \
+ do \
+ __atg18_old = (*__atg18_memp); \
+ while (__builtin_expect \
+ (catomic_compare_and_exchange_bool_acq (__atg18_memp, \
+ __atg18_old | __atg18_mask,\
+ __atg18_old), 0)); \
+ } while (0)
+#endif
+
+/* Atomically *mem |= mask and return the old value of *mem. */
+#ifndef atomic_or_val
+# define atomic_or_val(mem, mask) \
+ ({ __typeof (*(mem)) __atg19_old; \
+ __typeof (mem) __atg19_memp = (mem); \
+ __typeof (*(mem)) __atg19_mask = (mask); \
+ \
+ do \
+ __atg19_old = (*__atg19_memp); \
+ while (__builtin_expect \
+ (atomic_compare_and_exchange_bool_acq (__atg19_memp, \
+ __atg19_old | __atg19_mask,\
+ __atg19_old), 0)); \
+ \
+ __atg19_old; })
+#endif
#ifndef atomic_full_barrier
# define atomic_full_barrier() __asm__ ("" ::: "memory")
@@ -254,6 +537,225 @@
#endif
+#ifndef atomic_forced_read
+# define atomic_forced_read(x) \
+ ({ __typeof (x) __x; __asm__ ("" : "=r" (__x) : "0" (x)); __x; })
+#endif
+
+/* This is equal to 1 iff the architecture supports 64b atomic operations. */
+#define __HAVE_64B_ATOMICS 0 /* TODO: not yet used - Add these to arch bits! */
+#ifndef __HAVE_64B_ATOMICS
+#error Unable to determine if 64-bit atomics are present.
+#endif
+
+/* The following functions are a subset of the atomic operations provided by
+ C11. Usually, a function named atomic_OP_MO(args) is equivalent to C11's
+ atomic_OP_explicit(args, memory_order_MO); exceptions noted below. */
+
+/* Each arch can request to use compiler built-ins for C11 atomics. If it
+ does, all atomics will be based on these. */
+#if 0 /* not yet used USE_ATOMIC_COMPILER_BUILTINS */
+
+/* We require 32b atomic operations; some archs also support 64b atomic
+ operations. */
+void __atomic_link_error (void);
+# if __HAVE_64B_ATOMICS == 1
+# define __atomic_check_size(mem) \
+ if ((sizeof (*mem) != 4) && (sizeof (*mem) != 8)) \
+ __atomic_link_error ();
+# else
+# define __atomic_check_size(mem) \
+ if (sizeof (*mem) != 4) \
+ __atomic_link_error ();
+# endif
+
+# define atomic_thread_fence_acquire() \
+ __atomic_thread_fence (__ATOMIC_ACQUIRE)
+# define atomic_thread_fence_release() \
+ __atomic_thread_fence (__ATOMIC_RELEASE)
+# define atomic_thread_fence_seq_cst() \
+ __atomic_thread_fence (__ATOMIC_SEQ_CST)
+
+# define atomic_load_relaxed(mem) \
+ ({ __atomic_check_size((mem)); __atomic_load_n ((mem), __ATOMIC_RELAXED); })
+# define atomic_load_acquire(mem) \
+ ({ __atomic_check_size((mem)); __atomic_load_n ((mem), __ATOMIC_ACQUIRE); })
+
+# define atomic_store_relaxed(mem, val) \
+ do { \
+ __atomic_check_size((mem)); \
+ __atomic_store_n ((mem), (val), __ATOMIC_RELAXED); \
+ } while (0)
+# define atomic_store_release(mem, val) \
+ do { \
+ __atomic_check_size((mem)); \
+ __atomic_store_n ((mem), (val), __ATOMIC_RELEASE); \
+ } while (0)
+
+/* On failure, this CAS has memory_order_relaxed semantics. */
+# define atomic_compare_exchange_weak_relaxed(mem, expected, desired) \
+ ({ __atomic_check_size((mem)); \
+ __atomic_compare_exchange_n ((mem), (expected), (desired), 1, \
+ __ATOMIC_RELAXED, __ATOMIC_RELAXED); })
+# define atomic_compare_exchange_weak_acquire(mem, expected, desired) \
+ ({ __atomic_check_size((mem)); \
+ __atomic_compare_exchange_n ((mem), (expected), (desired), 1, \
+ __ATOMIC_ACQUIRE, __ATOMIC_RELAXED); })
+# define atomic_compare_exchange_weak_release(mem, expected, desired) \
+ ({ __atomic_check_size((mem)); \
+ __atomic_compare_exchange_n ((mem), (expected), (desired), 1, \
+ __ATOMIC_RELEASE, __ATOMIC_RELAXED); })
+
+# define atomic_exchange_acquire(mem, desired) \
+ ({ __atomic_check_size((mem)); \
+ __atomic_exchange_n ((mem), (desired), __ATOMIC_ACQUIRE); })
+# define atomic_exchange_release(mem, desired) \
+ ({ __atomic_check_size((mem)); \
+ __atomic_exchange_n ((mem), (desired), __ATOMIC_RELEASE); })
+
+# define atomic_fetch_add_relaxed(mem, operand) \
+ ({ __atomic_check_size((mem)); \
+ __atomic_fetch_add ((mem), (operand), __ATOMIC_RELAXED); })
+# define atomic_fetch_add_acquire(mem, operand) \
+ ({ __atomic_check_size((mem)); \
+ __atomic_fetch_add ((mem), (operand), __ATOMIC_ACQUIRE); })
+# define atomic_fetch_add_release(mem, operand) \
+ ({ __atomic_check_size((mem)); \
+ __atomic_fetch_add ((mem), (operand), __ATOMIC_RELEASE); })
+# define atomic_fetch_add_acq_rel(mem, operand) \
+ ({ __atomic_check_size((mem)); \
+ __atomic_fetch_add ((mem), (operand), __ATOMIC_ACQ_REL); })
+
+# define atomic_fetch_and_acquire(mem, operand) \
+ ({ __atomic_check_size((mem)); \
+ __atomic_fetch_and ((mem), (operand), __ATOMIC_ACQUIRE); })
+
+# define atomic_fetch_or_relaxed(mem, operand) \
+ ({ __atomic_check_size((mem)); \
+ __atomic_fetch_or ((mem), (operand), __ATOMIC_RELAXED); })
+# define atomic_fetch_or_acquire(mem, operand) \
+ ({ __atomic_check_size((mem)); \
+ __atomic_fetch_or ((mem), (operand), __ATOMIC_ACQUIRE); })
+
+#else /* !USE_ATOMIC_COMPILER_BUILTINS */
+
+/* By default, we assume that read, write, and full barriers are equivalent
+ to acquire, release, and seq_cst barriers. Archs for which this does not
+ hold have to provide custom definitions of the fences. */
+# ifndef atomic_thread_fence_acquire
+# define atomic_thread_fence_acquire() atomic_read_barrier ()
+# endif
+# ifndef atomic_thread_fence_release
+# define atomic_thread_fence_release() atomic_write_barrier ()
+# endif
+# ifndef atomic_thread_fence_seq_cst
+# define atomic_thread_fence_seq_cst() atomic_full_barrier ()
+# endif
+
+# ifndef atomic_load_relaxed
+# define atomic_load_relaxed(mem) \
+ ({ __typeof (*(mem)) __atg100_val; \
+ __asm__ ("" : "=r" (__atg100_val) : "0" (*(mem))); \
+ __atg100_val; })
+# endif
+# ifndef atomic_load_acquire
+# define atomic_load_acquire(mem) \
+ ({ __typeof (*(mem)) __atg101_val = atomic_load_relaxed (mem); \
+ atomic_thread_fence_acquire (); \
+ __atg101_val; })
+# endif
+
+# ifndef atomic_store_relaxed
+/* XXX Use inline asm here? */
+# define atomic_store_relaxed(mem, val) do { *(mem) = (val); } while (0)
+# endif
+# ifndef atomic_store_release
+# define atomic_store_release(mem, val) \
+ do { \
+ atomic_thread_fence_release (); \
+ atomic_store_relaxed ((mem), (val)); \
+ } while (0)
+# endif
+
+/* On failure, this CAS has memory_order_relaxed semantics. */
+/* XXX This potentially has one branch more than necessary, but archs
+ currently do not define a CAS that returns both the previous value and
+ the success flag. */
+# ifndef atomic_compare_exchange_weak_acquire
+# define atomic_compare_exchange_weak_acquire(mem, expected, desired) \
+ ({ __typeof (*(expected)) __atg102_expected = *(expected); \
+ *(expected) = \
+ atomic_compare_and_exchange_val_acq ((mem), (desired), *(expected)); \
+ *(expected) == __atg102_expected; })
+# endif
+# ifndef atomic_compare_exchange_weak_relaxed
+/* XXX Fall back to CAS with acquire MO because archs do not define a weaker
+ CAS. */
+# define atomic_compare_exchange_weak_relaxed(mem, expected, desired) \
+ atomic_compare_exchange_weak_acquire ((mem), (expected), (desired))
+# endif
+# ifndef atomic_compare_exchange_weak_release
+# define atomic_compare_exchange_weak_release(mem, expected, desired) \
+ ({ __typeof (*(expected)) __atg103_expected = *(expected); \
+ *(expected) = \
+ atomic_compare_and_exchange_val_rel ((mem), (desired), *(expected)); \
+ *(expected) == __atg103_expected; })
+# endif
+
+# ifndef atomic_exchange_acquire
+# define atomic_exchange_acquire(mem, val) \
+ atomic_exchange_acq ((mem), (val))
+# endif
+# ifndef atomic_exchange_release
+# define atomic_exchange_release(mem, val) \
+ atomic_exchange_rel ((mem), (val))
+# endif
+
+# ifndef atomic_fetch_add_acquire
+# define atomic_fetch_add_acquire(mem, operand) \
+ atomic_exchange_and_add_acq ((mem), (operand))
+# endif
+# ifndef atomic_fetch_add_relaxed
+/* XXX Fall back to acquire MO because the MO semantics of
+ atomic_exchange_and_add are not documented; the generic version falls back
+ to atomic_exchange_and_add_acq if atomic_exchange_and_add is not defined,
+ and vice versa. */
+# define atomic_fetch_add_relaxed(mem, operand) \
+ atomic_fetch_add_acquire ((mem), (operand))
+# endif
+# ifndef atomic_fetch_add_release
+# define atomic_fetch_add_release(mem, operand) \
+ atomic_exchange_and_add_rel ((mem), (operand))
+# endif
+# ifndef atomic_fetch_add_acq_rel
+# define atomic_fetch_add_acq_rel(mem, operand) \
+ ({ atomic_thread_fence_release (); \
+ atomic_exchange_and_add_acq ((mem), (operand)); })
+# endif
+
+/* XXX The default for atomic_and_val has acquire semantics, but this is not
+ documented. */
+# ifndef atomic_fetch_and_acquire
+# define atomic_fetch_and_acquire(mem, operand) \
+ atomic_and_val ((mem), (operand))
+# endif
+
+/* XXX The default for atomic_or_val has acquire semantics, but this is not
+ documented. */
+# ifndef atomic_fetch_or_acquire
+# define atomic_fetch_or_acquire(mem, operand) \
+ atomic_or_val ((mem), (operand))
+# endif
+/* XXX Fall back to acquire MO because archs do not define a weaker
+ atomic_or_val. */
+# ifndef atomic_fetch_or_relaxed
+# define atomic_fetch_or_relaxed(mem, operand) \
+ atomic_fetch_or_acquire ((mem), (operand))
+# endif
+
+#endif /* !USE_ATOMIC_COMPILER_BUILTINS */
+
+
#ifndef atomic_delay
# define atomic_delay() do { /* nothing */ } while (0)
#endif
diff --git a/include/byteswap.h b/include/byteswap.h
index b61d4dda8..18ca95d37 100644
--- a/include/byteswap.h
+++ b/include/byteswap.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 _BYTESWAP_H
#define _BYTESWAP_H 1
diff --git a/include/cancel.h b/include/cancel.h
new file mode 100644
index 000000000..ac6f6b64d
--- /dev/null
+++ b/include/cancel.h
@@ -0,0 +1,101 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Copyright (C) 2000-2011 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#ifndef _CANCEL_H
+#define _CANCEL_H
+
+/*
+ * Usage of this header:
+ * 1. define a static or hidden function __NC(NAME) - expands to __NAME_nocancel
+ * 2. if it is hidden, add the prototype to the appropiate header where NAME has
+ * it's prototype (guarded by _LIBC)
+ * 3. add a CANCELLABLE_SYSCALL(...) line at the end, this will create the function
+ * NAME (as weak) with enabled cancellation for NPTL (and later for new LT), for
+ * LT_OLD it will also create a strong_alias to __libc_NAME to be used in libpthread
+ * 4. if you need libc_hidden_(weak|def) line, use instead lt_libc_hidden, this will
+ * take care of the correct type, weak or strong depending on the THREADS type
+ * 5. If the implementation can't be done using CANCELLABLE_SYSCALL (like for fcntl)
+ * you need to manually add lt_strong_alias() line too, to optionally create the
+ * __libc_NAME alias
+ * 6. if functions are needed to implement __NC(NAME), that themselves are cancellable,
+ * decide how the cancellation should be solved, two variants are possible:
+ * a. use the other function as __NC(FUNC), this way you access the non-cancellable
+ * variant and provide by CANCELLABLE_SYSCALL(...) the dedicated cancellation for NAME.
+ * be aware, that for this case __NC(FUNC) has to be hidden (not static)
+ * b. use the other function with it's name (FUNC) and add LIBC_CANCEL_HANDLED(); at
+ * the end of file with a comment telling us which function took care of the cancellation
+ * Note: LIBC_CANCEL_HANDLED() is noop on uClibc, glibc uses it only for tests, we use
+ * it only for "documentation".
+ *
+ * For now the use of this file is limited to libc, will expand later to support libpthread
+ * and librt as well.
+ */
+
+#include <features.h>
+
+#ifndef NOT_IN_libc
+
+#define __NC(name) _NC(name)
+#define _NC(name) __##name##_nocancel
+
+#define __NC_OLD(name) _NC_OLD(name)
+#define _NC_OLD(name) __libc_##name
+
+#define __NC_PROTO(name) extern __typeof(name) __NC(name) attribute_hidden;
+#define __NC_OLD_PROTO(name) extern __typeof(name) __NC_OLD(name);
+
+#if defined __UCLIBC_HAS_THREADS__ && !defined __LINUXTHREADS_OLD__
+# define __NEW_THREADS 1
+#else
+# define SINGLE_THREAD_P 1
+#endif
+
+#ifdef __NEW_THREADS
+# include <sysdep-cancel.h>
+
+# define CANCELLABLE_SYSCALL(res_type, name, param_list, params) \
+res_type weak_function name param_list \
+{ \
+ if (SINGLE_THREAD_P) \
+ return __NC(name) params; \
+ int oldtype = LIBC_CANCEL_ASYNC(); \
+ res_type result = __NC(name) params; \
+ LIBC_CANCEL_RESET(oldtype); \
+ return result; \
+}
+
+# define lt_strong_alias(name)
+# define lt_libc_hidden(name) libc_hidden_def(name)
+
+#elif defined __LINUXTHREADS_OLD__
+
+# define CANCELLABLE_SYSCALL(res_type, name, param_list, params) \
+weak_alias(__NC(name),name) \
+lt_strong_alias(name)
+
+# define lt_strong_alias(name) \
+__NC_OLD_PROTO(name) \
+strong_alias(name,__NC_OLD(name))
+# define lt_libc_hidden(name) libc_hidden_weak(name)
+
+#else
+
+# define CANCELLABLE_SYSCALL(res_type, name, param_list, params) \
+strong_alias(__NC(name),name)
+
+# define lt_strong_alias(name)
+# define lt_libc_hidden(name) libc_hidden_def(name)
+
+#endif
+
+/* disable it, useless, glibc uses it only for tests */
+# undef LIBC_CANCEL_HANDLED
+# define LIBC_CANCEL_HANDLED()
+
+#endif /* NOT_IN_libc */
+
+#endif
diff --git a/include/complex.h b/include/complex.h
index f005a9391..ed7e502b7 100644
--- a/include/complex.h
+++ b/include/complex.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1998, 1999, 2000, 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/>. */
/*
* ISO C99: 7.3 Complex arithmetic <complex.h>
@@ -54,15 +53,15 @@ __BEGIN_DECLS
so we can easily declare each function as both `name' and `__name',
and can declare the float versions `namef' and `__namef'. */
-#define __MATHCALL(function, args) \
- __MATHDECL (_Mdouble_complex_,function, args)
+#define __MATHCALL(function, args) \
+ __MATHDECL(_Mdouble_complex_,function, args)
#define __MATHDECL(type, function, args) \
- __MATHDECL_1(type, function, args); \
- __MATHDECL_1(type, __CONCAT(__,function), args)
+ __MATHDECL_1(type, function, args); \
+ __MATHDECL_1(type, __CONCAT(__,function), args)
#define __MATHDECL_1(type, function, args) \
- extern type __MATH_PRECNAME(function) args __THROW
+ extern type __MATH_PRECNAME(function) args __THROW
-#define _Mdouble_ double
+#define _Mdouble_ double
#define __MATH_PRECNAME(name) name
#include <bits/cmathcalls.h>
#undef _Mdouble_
@@ -72,7 +71,7 @@ __BEGIN_DECLS
#ifndef _Mfloat_
# define _Mfloat_ float
#endif
-#define _Mdouble_ _Mfloat_
+#define _Mdouble_ _Mfloat_
#ifdef __STDC__
# define __MATH_PRECNAME(name) name##f
#else
@@ -80,15 +79,17 @@ __BEGIN_DECLS
#endif
#include <bits/cmathcalls.h>
#undef _Mdouble_
+#undef _Mfloat_
#undef __MATH_PRECNAME
/* And the long double versions. It is non-critical to define them
here unconditionally since `long double' is required in ISO C99. */
-#if __STDC__ - 0 || __GNUC__ - 0 && !defined __NO_LONG_DOUBLE_MATH
+#if (__STDC__ - 0 || __GNUC__ - 0) \
+ && defined __UCLIBC_HAS_LONG_DOUBLE_MATH__
# ifndef _Mlong_double_
# define _Mlong_double_ long double
# endif
-# define _Mdouble_ _Mlong_double_
+# define _Mdouble_ _Mlong_double_
# ifdef __STDC__
# define __MATH_PRECNAME(name) name##l
# else
@@ -97,6 +98,7 @@ __BEGIN_DECLS
# include <bits/cmathcalls.h>
#endif
#undef _Mdouble_
+#undef _Mlong_double_
#undef __MATH_PRECNAME
#undef __MATHDECL_1
#undef __MATHDECL
diff --git a/include/cpio.h b/include/cpio.h
index fae32752a..00be7650e 100644
--- a/include/cpio.h
+++ b/include/cpio.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 _CPIO_H
#define _CPIO_H 1
diff --git a/include/crypt.h b/include/crypt.h
index f62a03056..825e7eb57 100644
--- a/include/crypt.h
+++ b/include/crypt.h
@@ -12,10 +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; see the file COPYING.LIB. If
+ * not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _CRYPT_H
diff --git a/include/ctype.h b/include/ctype.h
index 184b47b51..ecd5e7308 100644
--- a/include/ctype.h
+++ b/include/ctype.h
@@ -1,5 +1,5 @@
/* Copyright (C) 1991,92,93,95,96,97,98,99,2001,02
- Free Software Foundation, Inc.
+ 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/>. */
/*
* ISO C99 Standard 7.4: Character handling <ctype.h>
@@ -27,7 +26,77 @@
#include <features.h>
#include <bits/types.h>
-#ifdef __UCLIBC_HAS_CTYPE_TABLES__
+__BEGIN_DECLS
+__BEGIN_NAMESPACE_STD
+
+/* The following names are all functions:
+ int isCHARACTERISTIC(int c);
+ which return nonzero iff C has CHARACTERISTIC.
+ For the meaning of the characteristic names, see the `enum' above. */
+extern int isalnum(int __c) __THROW;
+libc_hidden_proto(isalnum)
+extern int isalpha(int __c) __THROW;
+libc_hidden_proto(isalpha)
+extern int iscntrl(int __c) __THROW;
+libc_hidden_proto(iscntrl)
+extern int isdigit(int __c) __THROW;
+libc_hidden_proto(isdigit)
+extern int islower(int __c) __THROW;
+libc_hidden_proto(islower)
+extern int isgraph(int __c) __THROW;
+libc_hidden_proto(isgraph)
+extern int isprint(int __c) __THROW;
+libc_hidden_proto(isprint)
+extern int ispunct(int __c) __THROW;
+libc_hidden_proto(ispunct)
+extern int isspace(int __c) __THROW;
+libc_hidden_proto(isspace)
+extern int isupper(int __c) __THROW;
+libc_hidden_proto(isupper)
+extern int isxdigit(int __c) __THROW;
+libc_hidden_proto(isxdigit)
+
+
+/* Return the lowercase version of C. */
+extern int tolower(int __c) __THROW;
+libc_hidden_proto(tolower)
+
+/* Return the uppercase version of C. */
+extern int toupper(int __c) __THROW;
+libc_hidden_proto(toupper)
+
+#if (defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN) && \
+ defined __UCLIBC_SUSV4_LEGACY__
+/* Return nonzero iff C is in the ASCII set
+ (i.e., is no more than 7 bits wide). */
+extern int isascii(int __c) __THROW;
+libc_hidden_proto(isascii)
+/* Return the part of C that is in the ASCII set
+ (i.e., the low-order 7 bits of C). */
+extern int toascii(int __c) __THROW;
+#endif
+
+__END_NAMESPACE_STD
+
+
+/* ISO C99 introduced one new function. */
+#ifdef __USE_ISOC99
+__BEGIN_NAMESPACE_C99
+
+extern int isblank(int __c) __THROW;
+libc_hidden_proto(isblank)
+
+__END_NAMESPACE_C99
+#endif
+__END_DECLS
+
+#ifndef __UCLIBC_HAS_CTYPE_TABLES__
+
+/* "Stub locale": we are permanently in C/POSIX locale.
+ * Using simple(r) ctype.h machinery in this header instead: */
+#include <bits/uClibc_ctype.h>
+
+#else
__BEGIN_DECLS
@@ -36,6 +105,7 @@ __BEGIN_DECLS
If there get to be more than 16 distinct characteristics,
__ctype_mask_t will need to be adjusted. */
+/* libstdc++ from gcc toolchain needs this macro. */
# define _ISbit(bit) (1 << (bit))
enum
@@ -57,15 +127,14 @@ enum
#error _ISbit already defined!
#endif /* ! _ISbit */
+/* __ctype_XXX_t types and __UCLIBC_CTYPE_x_TBL_OFFSET constants */
#include <bits/uClibc_touplow.h>
#ifdef __UCLIBC_HAS_CTYPE_SIGNED__
# define __UCLIBC_CTYPE_IN_TO_DOMAIN(c) (((unsigned int)((c) + 128)) < 384)
-
-#else /* __UCLIBC_HAS_CTYPE_SIGNED__ */
+#else
# define __UCLIBC_CTYPE_IN_TO_DOMAIN(c) (((unsigned int)(c)) < 256)
-
-#endif /* __UCLIBC_HAS_CTYPE_SIGNED__ */
+#endif
/* In the thread-specific locale model (see `uselocale' in <locale.h>)
we cannot use global variables for these as was done in the past.
@@ -101,18 +170,20 @@ enum
/* Pointers to the default C-locale data. */
extern const __ctype_mask_t *__C_ctype_b;
+libc_hidden_proto(__C_ctype_b)
extern const __ctype_touplow_t *__C_ctype_toupper;
+libc_hidden_proto(__C_ctype_toupper)
extern const __ctype_touplow_t *__C_ctype_tolower;
+libc_hidden_proto(__C_ctype_tolower)
#ifdef __UCLIBC_HAS_XLOCALE__
-extern __const __ctype_mask_t **__ctype_b_loc (void)
- __attribute__ ((__const));
-extern __const __ctype_touplow_t **__ctype_tolower_loc (void)
- __attribute__ ((__const));
-extern __const __ctype_touplow_t **__ctype_toupper_loc (void)
- __attribute__ ((__const));
-
+const __ctype_mask_t **__ctype_b_loc(void) __attribute__ ((const));
+libc_hidden_proto(__ctype_b_loc)
+const __ctype_touplow_t **__ctype_tolower_loc(void) __attribute__ ((const));
+libc_hidden_proto(__ctype_tolower_loc)
+const __ctype_touplow_t **__ctype_toupper_loc(void) __attribute__ ((const));
+libc_hidden_proto(__ctype_toupper_loc)
#define __UCLIBC_CTYPE_B (*__ctype_b_loc())
#define __UCLIBC_CTYPE_TOLOWER (*__ctype_tolower_loc())
#define __UCLIBC_CTYPE_TOUPPER (*__ctype_toupper_loc())
@@ -121,107 +192,60 @@ extern __const __ctype_touplow_t **__ctype_toupper_loc (void)
/* Pointers to the current global locale data in use. */
extern const __ctype_mask_t *__ctype_b;
+libc_hidden_proto(__ctype_b)
extern const __ctype_touplow_t *__ctype_toupper;
+libc_hidden_proto(__ctype_toupper)
extern const __ctype_touplow_t *__ctype_tolower;
-
+libc_hidden_proto(__ctype_tolower)
#define __UCLIBC_CTYPE_B (__ctype_b)
#define __UCLIBC_CTYPE_TOLOWER (__ctype_tolower)
#define __UCLIBC_CTYPE_TOUPPER (__ctype_toupper)
#endif /* __UCLIBC_HAS_XLOCALE__ */
-#define __isctype(c, type) \
- ((__UCLIBC_CTYPE_B)[(int) (c)] & (__ctype_mask_t) type)
-
+#ifdef __UCLIBC_SUSV4_LEGACY__
#define __isascii(c) (((c) & ~0x7f) == 0) /* If C is a 7 bit value. */
#define __toascii(c) ((c) & 0x7f) /* Mask off high bits. */
+#endif
-#if defined _LIBC && (defined IS_IN_libc || defined NOT_IN_libc)
-/* isdigit() is really locale-invariant, so provide some small fast macros.
- * These are uClibc-specific. */
+#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
-#define __exctype(name) extern int name (int) __THROW
-
-__BEGIN_NAMESPACE_STD
-
-/* The following names are all functions:
- int isCHARACTERISTIC(int c);
- which return nonzero iff C has CHARACTERISTIC.
- For the meaning of the characteristic names, see the `enum' above. */
-__exctype (isalnum);
-__exctype (isalpha);
-__exctype (iscntrl);
-__exctype (isdigit);
-__exctype (islower);
-__exctype (isgraph);
-__exctype (isprint);
-__exctype (ispunct);
-__exctype (isspace);
-__exctype (isupper);
-__exctype (isxdigit);
-
-
-/* Return the lowercase version of C. */
-extern int tolower (int __c) __THROW;
-
-/* Return the uppercase version of C. */
-extern int toupper (int __c) __THROW;
-
-__END_NAMESPACE_STD
-
-
-/* ISO C99 introduced one new function. */
-#ifdef __USE_ISOC99
-__BEGIN_NAMESPACE_C99
-
-__exctype (isblank);
-
-__END_NAMESPACE_C99
-#endif
-
#ifdef __USE_GNU
/* Test C for a set of character classes according to MASK. */
-extern int isctype (int __c, int __mask) __THROW;
+extern int isctype(int __c, int __mask) __THROW;
#endif
-#if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN
-
-/* Return nonzero iff C is in the ASCII set
- (i.e., is no more than 7 bits wide). */
-extern int isascii (int __c) __THROW;
-
-/* Return the part of C that is in the ASCII set
- (i.e., the low-order 7 bits of C). */
-extern int toascii (int __c) __THROW;
-
+#if (defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN) \
+ && defined __UCLIBC_SUSV4_LEGACY__
/* These are the same as `toupper' and `tolower' except that they do not
check the argument for being in the range of a `char'. */
-__exctype (_toupper);
-__exctype (_tolower);
+extern int _toupper(int __c) __THROW;
+extern int _tolower(int __c) __THROW;
#endif /* Use SVID or use misc. */
/* This code is needed for the optimized mapping functions. */
-#define __tobody(c, f, a, args) \
- (__extension__ \
- ({ int __res; \
- if (sizeof (c) > 1) \
- { \
- if (__builtin_constant_p (c)) \
- { \
- int __c = (c); \
- __res = __UCLIBC_CTYPE_IN_TO_DOMAIN(__c) ? (a)[__c] : __c; \
- } \
- else \
- __res = f args; \
- } \
- else \
- __res = (a)[(int) (c)]; \
- __res; }))
-
-#if !defined __NO_CTYPE && !defined __cplusplus
+#define __tobody(c, f, table, args) \
+(__extension__ ({ \
+ int __res; \
+ if (sizeof(c) > 1) { \
+ if (__builtin_constant_p(c)) { \
+ int __c = (c); \
+ __res = __UCLIBC_CTYPE_IN_TO_DOMAIN(__c) ? (table)[__c] : __c; \
+ } else \
+ __res = f args; \
+ } else \
+ __res = (table)[(int) (c)]; \
+ __res; \
+}))
+
+#define __isctype(c, type) ((__UCLIBC_CTYPE_B)[(int)(c)] & (__ctype_mask_t)type)
+/* Do not combine in one #if - unifdef tool is not that clever */
+#ifndef __NO_CTYPE
+#ifndef __cplusplus
# define isalnum(c) __isctype((c), _ISalnum)
# define isalpha(c) __isctype((c), _ISalpha)
# define iscntrl(c) __isctype((c), _IScntrl)
@@ -233,7 +257,6 @@ __exctype (_tolower);
# define isspace(c) __isctype((c), _ISspace)
# define isupper(c) __isctype((c), _ISupper)
# define isxdigit(c) __isctype((c), _ISxdigit)
-
# ifdef __USE_ISOC99
# define isblank(c) __isctype((c), _ISblank)
# endif
@@ -244,7 +267,6 @@ __NTH (tolower (int __c))
{
return __UCLIBC_CTYPE_IN_TO_DOMAIN(__c) ? (__UCLIBC_CTYPE_TOLOWER)[__c] : __c;
}
-
__extern_inline int
__NTH (toupper (int __c))
{
@@ -253,22 +275,23 @@ __NTH (toupper (int __c))
# endif
# if __GNUC__ >= 2 && defined __OPTIMIZE__ && !defined __cplusplus
-# define tolower(c) __tobody (c, tolower, __UCLIBC_CTYPE_TOLOWER, (c))
-# define toupper(c) __tobody (c, toupper, __UCLIBC_CTYPE_TOUPPER, (c))
+# define tolower(c) __tobody(c, tolower, __UCLIBC_CTYPE_TOLOWER, (c))
+# define toupper(c) __tobody(c, toupper, __UCLIBC_CTYPE_TOUPPER, (c))
# endif /* Optimizing gcc */
-# if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN
+# if (defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN) \
+ && defined __UCLIBC_SUSV4_LEGACY__
# define isascii(c) __isascii (c)
# define toascii(c) __toascii (c)
-
# define _tolower(c) ((int) (__UCLIBC_CTYPE_TOLOWER)[(int) (c)])
# define _toupper(c) ((int) (__UCLIBC_CTYPE_TOUPPER)[(int) (c)])
# endif
-#endif /* Not __NO_CTYPE. */
+#endif /* not __cplusplus */
+#endif /* not __NO_CTYPE */
-#if defined(__USE_GNU) && defined(__UCLIBC_HAS_XLOCALE__)
+#if defined __USE_GNU && defined __UCLIBC_HAS_XLOCALE__
/* The concept of one static locale per category is not very well
thought out. Many applications will need to process its data using
information from several different locales. Another application is
@@ -286,49 +309,54 @@ __NTH (toupper (int __c))
/* These definitions are similar to the ones above but all functions
take as an argument a handle for the locale which shall be used. */
-# define __isctype_l(c, type, locale) \
- ((locale)->__ctype_b[(int) (c)] & (__ctype_mask_t) type)
-
-# define __exctype_l(name) \
- extern int name (int, __locale_t) __THROW
-
-/* The following names are all functions:
- int isCHARACTERISTIC(int c, locale_t *locale);
- which return nonzero iff C has CHARACTERISTIC.
- For the meaning of the characteristic names, see the `enum' above. */
-__exctype_l (isalnum_l);
-__exctype_l (isalpha_l);
-__exctype_l (iscntrl_l);
-__exctype_l (isdigit_l);
-__exctype_l (islower_l);
-__exctype_l (isgraph_l);
-__exctype_l (isprint_l);
-__exctype_l (ispunct_l);
-__exctype_l (isspace_l);
-__exctype_l (isupper_l);
-__exctype_l (isxdigit_l);
-
-__exctype_l (isblank_l);
+extern int isalnum_l(int, __locale_t) __THROW;
+libc_hidden_proto(isalnum_l)
+extern int isalpha_l(int, __locale_t) __THROW;
+libc_hidden_proto(isalpha_l)
+extern int iscntrl_l(int, __locale_t) __THROW;
+libc_hidden_proto(iscntrl_l)
+extern int isdigit_l(int, __locale_t) __THROW;
+libc_hidden_proto(isdigit_l)
+extern int islower_l(int, __locale_t) __THROW;
+libc_hidden_proto(islower_l)
+extern int isgraph_l(int, __locale_t) __THROW;
+libc_hidden_proto(isgraph_l)
+extern int isprint_l(int, __locale_t) __THROW;
+libc_hidden_proto(isprint_l)
+extern int ispunct_l(int, __locale_t) __THROW;
+libc_hidden_proto(ispunct_l)
+extern int isspace_l(int, __locale_t) __THROW;
+libc_hidden_proto(isspace_l)
+extern int isupper_l(int, __locale_t) __THROW;
+libc_hidden_proto(isupper_l)
+extern int isxdigit_l(int, __locale_t) __THROW;
+libc_hidden_proto(isxdigit_l)
+extern int isblank_l(int, __locale_t) __THROW;
+libc_hidden_proto(isblank_l)
+
+# if (defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN) \
+ && defined __UCLIBC_SUSV4_LEGACY__
+/* Return nonzero iff C is in the ASCII set
+ (i.e., is no more than 7 bits wide). */
+extern int isascii_l (int __c) __THROW;
+libc_hidden_proto(isascii_l)
+# endif
/* Return the lowercase version of C in locale L. */
-extern int __tolower_l (int __c, __locale_t __l) __THROW;
extern int tolower_l (int __c, __locale_t __l) __THROW;
+libc_hidden_proto(tolower_l)
/* Return the uppercase version of C. */
-extern int __toupper_l (int __c, __locale_t __l) __THROW;
extern int toupper_l (int __c, __locale_t __l) __THROW;
# if __GNUC__ >= 2 && defined __OPTIMIZE__ && !defined __cplusplus
-# define __tolower_l(c, locale) \
- __tobody (c, __tolower_l, (locale)->__ctype_tolower, (c, locale))
-# define __toupper_l(c, locale) \
- __tobody (c, __toupper_l, (locale)->__ctype_toupper, (c, locale))
-# define tolower_l(c, locale) __tolower_l ((c), (locale))
-# define toupper_l(c, locale) __toupper_l ((c), (locale))
+# define tolower_l(c, locale) __tobody(c, tolower_l, (locale)->__ctype_tolower, (c, locale))
+# define toupper_l(c, locale) __tobody(c, toupper_l, (locale)->__ctype_toupper, (c, locale))
# endif /* Optimizing gcc */
+# define __isctype_l(c, type, locale) ((locale)->__ctype_b[(int) (c)] & (__ctype_mask_t) type)
# ifndef __NO_CTYPE
# define __isalnum_l(c,l) __isctype_l((c), _ISalnum, (l))
# define __isalpha_l(c,l) __isctype_l((c), _ISalpha, (l))
@@ -341,10 +369,10 @@ extern int toupper_l (int __c, __locale_t __l) __THROW;
# define __isspace_l(c,l) __isctype_l((c), _ISspace, (l))
# define __isupper_l(c,l) __isctype_l((c), _ISupper, (l))
# define __isxdigit_l(c,l) __isctype_l((c), _ISxdigit, (l))
-
# define __isblank_l(c,l) __isctype_l((c), _ISblank, (l))
-# if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN
+# if (defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN) \
+ && defined __UCLIBC_SUSV4_LEGACY__
# define __isascii_l(c,l) ((l), __isascii (c))
# define __toascii_l(c,l) ((l), __toascii (c))
# endif
@@ -360,10 +388,10 @@ extern int toupper_l (int __c, __locale_t __l) __THROW;
# define isspace_l(c,l) __isspace_l ((c), (l))
# define isupper_l(c,l) __isupper_l ((c), (l))
# define isxdigit_l(c,l) __isxdigit_l ((c), (l))
-
# define isblank_l(c,l) __isblank_l ((c), (l))
-# if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN
+# if (defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN) \
+ && defined __UCLIBC_SUSV4_LEGACY__
# define isascii_l(c,l) __isascii_l ((c), (l))
# define toascii_l(c,l) __toascii_l ((c), (l))
# endif
@@ -374,10 +402,12 @@ extern int toupper_l (int __c, __locale_t __l) __THROW;
__END_DECLS
-#else /* __UCLIBC_HAS_CTYPE_TABLES__ */
-
-#include <bits/uClibc_ctype.h>
+#endif /* __UCLIBC_HAS_CTYPE_TABLES__ */
+#if defined _LIBC && !defined __UCLIBC_SUSV4_LEGACY__
+/* We define {__,}isascii for internal use only */
+# define __isascii(c) (((c) & ~0x7f) == 0)
+# define isascii(c) __isascii (c)
#endif
#endif /* ctype.h */
diff --git a/include/dirent.h b/include/dirent.h
index 565a94dee..00aa0773e 100644
--- a/include/dirent.h
+++ b/include/dirent.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2000, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2000,2003-2005,2009,2010 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -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: 5.1.2 Directory Operations <dirent.h>
@@ -132,7 +131,16 @@ typedef struct __dirstream DIR;
This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern DIR *opendir (__const char *__name) __nonnull ((1));
+extern DIR *opendir (const char *__name) __nonnull ((1));
+libc_hidden_proto(opendir)
+
+#ifdef __USE_XOPEN2K8
+/* Same as opendir, but open the stream on the file descriptor FD.
+
+ This function is a possible cancellation point and therefore not
+ marked with __THROW. */
+extern DIR *fdopendir (int __fd);
+#endif
/* Close the directory stream DIRP.
Return 0 if successful, -1 if not.
@@ -140,6 +148,7 @@ extern DIR *opendir (__const char *__name) __nonnull ((1));
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern int closedir (DIR *__dirp) __nonnull ((1));
+libc_hidden_proto(closedir)
/* Read a directory entry from DIRP. Return a pointer to a `struct
dirent' describing the entry, or NULL for EOF or error. The
@@ -153,6 +162,7 @@ extern int closedir (DIR *__dirp) __nonnull ((1));
marked with __THROW. */
#ifndef __USE_FILE_OFFSET64
extern struct dirent *readdir (DIR *__dirp) __nonnull ((1));
+libc_hidden_proto(readdir)
#else
# ifdef __REDIRECT
extern struct dirent *__REDIRECT (readdir, (DIR *__dirp), readdir64)
@@ -164,6 +174,7 @@ extern struct dirent *__REDIRECT (readdir, (DIR *__dirp), readdir64)
#ifdef __USE_LARGEFILE64
extern struct dirent64 *readdir64 (DIR *__dirp) __nonnull ((1));
+libc_hidden_proto(readdir64)
#endif
#if defined __USE_POSIX || defined __USE_MISC
@@ -177,6 +188,7 @@ extern int readdir_r (DIR *__restrict __dirp,
struct dirent *__restrict __entry,
struct dirent **__restrict __result)
__nonnull ((1, 2, 3));
+libc_hidden_proto(readdir_r)
# else
# ifdef __REDIRECT
extern int __REDIRECT (readdir_r,
@@ -194,6 +206,7 @@ extern int readdir64_r (DIR *__restrict __dirp,
struct dirent64 *__restrict __entry,
struct dirent64 **__restrict __result)
__nonnull ((1, 2, 3));
+libc_hidden_proto(readdir64_r)
# endif
#endif /* POSIX or misc */
@@ -210,24 +223,27 @@ extern void seekdir (DIR *__dirp, long int __pos) __THROW __nonnull ((1));
extern long int telldir (DIR *__dirp) __THROW __nonnull ((1));
#endif
-#if defined __USE_BSD || defined __USE_MISC
+#if defined __USE_BSD || defined __USE_MISC || defined __USE_XOPEN2K8
/* Return the file descriptor used by DIRP. */
extern int dirfd (DIR *__dirp) __THROW __nonnull ((1));
+libc_hidden_proto(dirfd)
# if 0 /* defined __OPTIMIZE__ && defined _DIR_dirfd */
# define dirfd(dirp) _DIR_dirfd (dirp)
# endif
-# ifndef MAXNAMLEN
+# if defined __USE_BSD || defined __USE_MISC
+# ifndef MAXNAMLEN
/* Get the definitions of the POSIX.1 limits. */
# include <bits/posix1_lim.h>
/* `MAXNAMLEN' is the BSD name for what POSIX calls `NAME_MAX'. */
-# ifdef NAME_MAX
-# define MAXNAMLEN NAME_MAX
-# else
-# define MAXNAMLEN 255
+# ifdef NAME_MAX
+# define MAXNAMLEN NAME_MAX
+# else
+# define MAXNAMLEN 255
+# endif
# endif
# endif
@@ -239,18 +255,20 @@ extern int dirfd (DIR *__dirp) __THROW __nonnull ((1));
sorted using qsort with CMP, and collected in a malloc'd array in
*NAMELIST. Returns the number of entries selected, or -1 on error. */
# ifndef __USE_FILE_OFFSET64
-extern int scandir (__const char *__restrict __dir,
+extern int scandir (const char *__restrict __dir,
struct dirent ***__restrict __namelist,
- int (*__selector) (__const struct dirent *),
- int (*__cmp) (__const void *, __const void *))
+ int (*__selector) (const struct dirent *),
+ int (*__cmp) (const struct dirent **,
+ const struct dirent **))
__nonnull ((1, 2));
# else
# ifdef __REDIRECT
extern int __REDIRECT (scandir,
- (__const char *__restrict __dir,
+ (const char *__restrict __dir,
struct dirent ***__restrict __namelist,
- int (*__selector) (__const struct dirent *),
- int (*__cmp) (__const void *, __const void *)),
+ int (*__selector) (const struct dirent *),
+ int (*__cmp) (const struct dirent **,
+ const struct dirent **)),
scandir64) __nonnull ((1, 2));
# else
# define scandir scandir64
@@ -260,21 +278,24 @@ extern int __REDIRECT (scandir,
# if defined __USE_GNU && defined __USE_LARGEFILE64
/* This function is like `scandir' but it uses the 64bit dirent structure.
Please note that the CMP function must now work with struct dirent64 **. */
-extern int scandir64 (__const char *__restrict __dir,
+extern int scandir64 (const char *__restrict __dir,
struct dirent64 ***__restrict __namelist,
- int (*__selector) (__const struct dirent64 *),
- int (*__cmp) (__const void *, __const void *))
+ int (*__selector) (const struct dirent64 *),
+ int (*__cmp) (const struct dirent64 **,
+ const struct dirent64 **))
__nonnull ((1, 2));
# endif
/* Function to compare two `struct dirent's alphabetically. */
# ifndef __USE_FILE_OFFSET64
-extern int alphasort (__const void *__e1, __const void *__e2)
+extern int alphasort (const struct dirent **__e1,
+ const struct dirent **__e2)
__THROW __attribute_pure__ __nonnull ((1, 2));
# else
# ifdef __REDIRECT
-extern int __REDIRECT (alphasort,
- (__const void *__e1, __const void *__e2),
+extern int __REDIRECT_NTH (alphasort,
+ (const struct dirent **__e1,
+ const struct dirent **__e2),
alphasort64) __attribute_pure__ __nonnull ((1, 2));
# else
# define alphasort alphasort64
@@ -282,12 +303,75 @@ extern int __REDIRECT (alphasort,
# endif
# if defined __USE_GNU && defined __USE_LARGEFILE64
-extern int alphasort64 (__const void *__e1, __const void *__e2)
+extern int alphasort64 (const struct dirent64 **__e1,
+ const struct dirent64 **__e2)
__THROW __attribute_pure__ __nonnull ((1, 2));
# endif
+#endif /* Use BSD or misc or XPG7. */
+
+
+#if 0 /* defined __USE_BSD || defined __USE_MISC */
+/* Read directory entries from FD into BUF, reading at most NBYTES.
+ Reading starts at offset *BASEP, and *BASEP is updated with the new
+ position after reading. Returns the number of bytes read; zero when at
+ end of directory; or -1 for errors. */
+# ifndef __USE_FILE_OFFSET64
+extern __ssize_t getdirentries (int __fd, char *__restrict __buf,
+ size_t __nbytes,
+ __off_t *__restrict __basep)
+ __THROW __nonnull ((2, 4));
+# else
+# ifdef __REDIRECT
+extern __ssize_t __REDIRECT_NTH (getdirentries,
+ (int __fd, char *__restrict __buf,
+ size_t __nbytes,
+ __off64_t *__restrict __basep),
+ getdirentries64) __nonnull ((2, 4));
+# else
+# define getdirentries getdirentries64
+# endif
+# endif
+# ifdef __USE_LARGEFILE64
+extern __ssize_t getdirentries64 (int __fd, char *__restrict __buf,
+ size_t __nbytes,
+ __off64_t *__restrict __basep)
+ __THROW __nonnull ((2, 4));
+# endif
#endif /* Use BSD or misc. */
+#ifdef __USE_GNU
+/* Function to compare two `struct dirent's by name & version. */
+# ifndef __USE_FILE_OFFSET64
+extern int versionsort (const struct dirent **__e1,
+ const struct dirent **__e2)
+ __THROW __attribute_pure__ __nonnull ((1, 2));
+# else
+# ifdef __REDIRECT
+extern int __REDIRECT_NTH (versionsort,
+ (const struct dirent **__e1,
+ const struct dirent **__e2),
+ versionsort64)
+ __attribute_pure__ __nonnull ((1, 2));
+# else
+# define versionsort versionsort64
+# endif
+# endif
+
+# ifdef __USE_LARGEFILE64
+extern int versionsort64 (const struct dirent64 **__e1,
+ const struct dirent64 **__e2)
+ __THROW __attribute_pure__ __nonnull ((1, 2));
+# endif
+#endif /* Use GNU. */
+
__END_DECLS
+#ifdef _LIBC
+extern __ssize_t __getdents(int fd, char *buf, size_t count) attribute_hidden;
+# ifdef __UCLIBC_HAS_LFS__
+extern __ssize_t __getdents64 (int fd, char *buf, size_t count) attribute_hidden;
+# endif
+#endif
+
#endif /* dirent.h */
diff --git a/include/dlfcn.h b/include/dlfcn.h
index 2348e436d..74825aaf0 100644
--- a/include/dlfcn.h
+++ b/include/dlfcn.h
@@ -1,6 +1,5 @@
/* User functions for run-time dynamic loading.
- Copyright (C) 1995-1999,2000,2001,2003,2004,2006
- Free Software Foundation, Inc.
+ Copyright (C) 1995-2001,2003,2004,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
@@ -14,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
#define _DLFCN_H 1
@@ -28,6 +26,9 @@
/* Collect various system dependent definitions and declarations. */
#include <bits/dlfcn.h>
+/* Internally used flag. */
+#define __RTLD_SECURE 0x04000000 /* Apply additional security checks. */
+
#ifdef __USE_GNU
/* If the first argument of `dlsym' or `dlvsym' is set to RTLD_NEXT
@@ -52,30 +53,31 @@ typedef long int Lmid_t;
# endif
#endif
+
__BEGIN_DECLS
/* Open the shared object FILE and map it in; return a handle that can be
passed to `dlsym' to get symbol values from it. */
-extern void *dlopen (__const char *__file, int __mode) __THROW;
+extern void *dlopen (const char *__file, int __mode) __THROWNL;
/* Unmap and close a shared object opened by `dlopen'.
The handle cannot be used again after calling `dlclose'. */
-extern int dlclose (void *__handle) __THROW __nonnull ((1));
+extern int dlclose (void *__handle) __THROWNL __nonnull ((1));
/* Find the run-time address in the shared object HANDLE refers to
of the symbol called NAME. */
extern void *dlsym (void *__restrict __handle,
- __const char *__restrict __name) __THROW __nonnull ((2));
+ const char *__restrict __name) __THROW __nonnull ((2));
#if 0 /*def __USE_GNU*/
/* Like `dlopen', but request object to be allocated in a new namespace. */
-extern void *dlmopen (Lmid_t __nsid, __const char *__file, int __mode) __THROW;
+extern void *dlmopen (Lmid_t __nsid, const char *__file, int __mode) __THROWNL;
/* Find the run-time address in the shared object HANDLE refers to
of the symbol called NAME with VERSION. */
extern void *dlvsym (void *__restrict __handle,
- __const char *__restrict __name,
- __const char *__restrict __version)
+ const char *__restrict __name,
+ const char *__restrict __version)
__THROW __nonnull ((2, 3));
#endif
@@ -90,20 +92,20 @@ extern char *dlerror (void) __THROW;
`dladdr'. */
typedef struct
{
- __const char *dli_fname; /* File name of defining object. */
+ const char *dli_fname; /* File name of defining object. */
void *dli_fbase; /* Load address of that object. */
- __const char *dli_sname; /* Name of nearest symbol. */
+ const char *dli_sname; /* Name of nearest symbol. */
void *dli_saddr; /* Exact value of nearest symbol. */
} Dl_info;
/* Fill in *INFO with the following information about ADDRESS.
Returns 0 iff no shared object's segments contain that address. */
-extern int dladdr (__const void *__address, Dl_info *__info)
+extern int dladdr (const void *__address, Dl_info *__info)
__THROW __nonnull ((2));
#if 0 /* not supported by uClibc */
/* Same as `dladdr', but additionally sets *EXTRA_INFO according to FLAGS. */
-extern int dladdr1 (__const void *__address, Dl_info *__info,
+extern int dladdr1 (const void *__address, Dl_info *__info,
void **__extra_info, int __flags) __THROW __nonnull ((2));
/* These are the possible values for the FLAGS argument to `dladdr1'.
@@ -166,7 +168,7 @@ enum
segment, or if the calling thread has not allocated a block for it. */
RTLD_DI_TLS_DATA = 10,
- RTLD_DI_MAX = 10,
+ RTLD_DI_MAX = 10
};
@@ -186,12 +188,6 @@ typedef struct
unsigned int dls_cnt; /* Number of elements in `dls_serpath'. */
Dl_serpath dls_serpath[1]; /* Actually longer, dls_cnt elements. */
} Dl_serinfo;
-
-#else
-
-/* Get information about the shared objects currently loaded */
-extern int dlinfo (void);
-
#endif
#endif /* __USE_GNU */
diff --git a/include/elf.h b/include/elf.h
index 4c6d09012..5f47905f1 100644
--- a/include/elf.h
+++ b/include/elf.h
@@ -13,20 +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/>. */
#ifndef _ELF_H
#define _ELF_H 1
-#include <features.h>
-
-__BEGIN_DECLS
+/* Avoid features.h here for portability. This stuff matches sys/cdefs.h. */
+#ifdef __cplusplus
+extern "C" {
+#endif
/* Standard ELF types. */
#include <stdint.h>
+#include <endian.h>
/* Type for a 16-bit quantity. */
typedef uint16_t Elf32_Half;
@@ -120,6 +121,11 @@ typedef struct
/* Conglomeration of the identification bytes, for easy testing as a word. */
#define ELFMAG "\177ELF"
#define SELFMAG 4
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+# define ELFMAG_U32 ((uint32_t)(ELFMAG0 + 0x100 * (ELFMAG1 + (0x100 * (ELFMAG2 + 0x100 * ELFMAG3)))))
+#elif __BYTE_ORDER == __BIG_ENDIAN
+# define ELFMAG_U32 ((uint32_t)((((ELFMAG0 * 0x100) + ELFMAG1) * 0x100 + ELFMAG2) * 0x100 + ELFMAG3))
+#endif
#define EI_CLASS 4 /* File class byte index */
#define ELFCLASSNONE 0 /* Invalid class */
@@ -141,8 +147,8 @@ typedef struct
#define ELFOSABI_SYSV 0 /* Alias. */
#define ELFOSABI_HPUX 1 /* HP-UX */
#define ELFOSABI_NETBSD 2 /* NetBSD. */
-#define ELFOSABI_LINUX 3 /* Linux. */
-#define ELFOSABI_HURD 4 /* GNU/Hurd */
+#define ELFOSABI_GNU 3 /* Object uses GNU ELF extensions. */
+#define ELFOSABI_LINUX ELFOSABI_GNU /* Compatibility alias. */
#define ELFOSABI_SOLARIS 6 /* Sun Solaris. */
#define ELFOSABI_AIX 7 /* IBM AIX. */
#define ELFOSABI_IRIX 8 /* SGI Irix. */
@@ -251,8 +257,8 @@ typedef struct
#define EM_MN10300 89 /* Matsushita MN10300 */
#define EM_MN10200 90 /* Matsushita MN10200 */
#define EM_PJ 91 /* picoJava */
-#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */
-#define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */
+#define EM_OR1K 92 /* OpenRISC 32-bit embedded processor */
+#define EM_ARCOMPACT 93 /* ARCompact ISA based Cores: ARC 700 */
#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */
#define EM_IP2K 101 /* Ubicom IP2022 micro controller */
#define EM_CR 103 /* National Semiconductor CompactRISC */
@@ -260,7 +266,13 @@ typedef struct
#define EM_BLACKFIN 106 /* Analog Devices Blackfin */
#define EM_ALTERA_NIOS2 113 /* Altera Nios II soft-core processor */
#define EM_CRX 114 /* National Semiconductor CRX */
-#define EM_NUM 95
+#define EM_TI_C6000 140
+#define EM_METAG 174 /* Imagination Technologies Meta */
+#define EM_MICROBLAZE 189 /* Xilinx Microblaze */
+#define EM_ARCV2 195 /* ARCv2 Cores */
+
+/* NEXT FREE NUMBER: Increment this after adding your official arch number */
+#define EM_NUM 196
/* If it is necessary to assign new unofficial EM_* values, please pick large
random numbers (0x8523, 0xa7f2, etc.) to minimize the chances of collision
@@ -274,19 +286,9 @@ typedef struct
unofficial e_machine number should eventually ask registry@caldera.com for
an officially blessed number to be added to the list above. */
-/* picoJava */
-#define EM_PJ_OLD 99
-
/* Cygnus PowerPC ELF backend. Written in the absence of an ABI. */
#define EM_CYGNUS_POWERPC 0x9025
-/* Old version of Sparc v9, from before the ABI; this should be
- removed shortly. */
-#define EM_OLD_SPARCV9 11
-
-/* Old version of PowerPC, this should be removed shortly. */
-#define EM_PPC_OLD 17
-
/* (Deprecated) Temporary number for the OpenRISC processor. */
#define EM_OR32 0x8472
@@ -360,6 +362,11 @@ typedef struct
/* V850 backend magic number. Written in the absense of an ABI. */
#define EM_CYGNUS_V850 0x9080
+/* Xilinx Microblaze (unofficial). Note that there is now an official microblaze
+ * magic number, but all the toolchains currently in existence use the old number
+ */
+#define EM_MICROBLAZE_OLD 0xbaab
+
/* Legal values for e_version (version). */
#define EV_NONE 0 /* Invalid ELF version */
@@ -546,6 +553,7 @@ typedef struct
#define STB_WEAK 2 /* Weak symbol */
#define STB_NUM 3 /* Number of defined types. */
#define STB_LOOS 10 /* Start of OS-specific */
+#define STB_GNU_UNIQUE 10 /* Unique symbol. */
#define STB_HIOS 12 /* End of OS-specific */
#define STB_LOPROC 13 /* Start of processor-specific */
#define STB_HIPROC 15 /* End of processor-specific */
@@ -561,6 +569,7 @@ typedef struct
#define STT_TLS 6 /* Symbol is thread-local data object*/
#define STT_NUM 7 /* Number of defined types. */
#define STT_LOOS 10 /* Start of OS-specific */
+#define STT_GNU_IFUNC 10 /* Symbol is indirect code object */
#define STT_HIOS 12 /* End of OS-specific */
#define STT_LOPROC 13 /* Start of processor-specific */
#define STT_HIPROC 15 /* End of processor-specific */
@@ -1259,26 +1268,26 @@ typedef struct
#define R_386_NUM 38
/* Blackfin specific definitions. */
-#define R_BFIN_unused0 0x00
-#define R_BFIN_pcrel5m2 0x01
-#define R_BFIN_unused1 0x02
-#define R_BFIN_pcrel10 0x03
-#define R_BFIN_pcrel12_jump 0x04
-#define R_BFIN_rimm16 0x05
-#define R_BFIN_luimm16 0x06
-#define R_BFIN_huimm16 0x07
-#define R_BFIN_pcrel12_jump_s 0x08
-#define R_BFIN_pcrel24_jump_x 0x09
-#define R_BFIN_pcrel24 0x0a
-#define R_BFIN_unusedb 0x0b
-#define R_BFIN_unusedc 0x0c
-#define R_BFIN_pcrel24_jump_l 0x0d
-#define R_BFIN_pcrel24_call_x 0x0e
+#define R_BFIN_UNUSED0 0x00
+#define R_BFIN_PCREL5M2 0x01
+#define R_BFIN_UNUSED1 0x02
+#define R_BFIN_PCREL10 0x03
+#define R_BFIN_PCREL12_JUMP 0x04
+#define R_BFIN_RIMM16 0x05
+#define R_BFIN_LUIMM16 0x06
+#define R_BFIN_HUIMM16 0x07
+#define R_BFIN_PCREL12_JUMP_S 0x08
+#define R_BFIN_PCREL24_JUMP_X 0x09
+#define R_BFIN_PCREL24 0x0a
+#define R_BFIN_UNUSEDB 0x0b
+#define R_BFIN_UNUSEDC 0x0c
+#define R_BFIN_PCREL24_JUMP_L 0x0d
+#define R_BFIN_PCREL24_CALL_X 0x0e
#define R_BFIN_var_eq_symb 0x0f
-#define R_BFIN_byte_data 0x10
-#define R_BFIN_byte2_data 0x11
-#define R_BFIN_byte4_data 0x12
-#define R_BFIN_pcrel11 0x13
+#define R_BFIN_BYTE_DATA 0x10
+#define R_BFIN_BYTE2_DATA 0x11
+#define R_BFIN_BYTE4_DATA 0x12
+#define R_BFIN_PCREL11 0x13
#define R_BFIN_GOT17M4 0x14
#define R_BFIN_GOTHI 0x15
@@ -1544,6 +1553,7 @@ typedef struct
#define STO_MIPS_INTERNAL 0x1
#define STO_MIPS_HIDDEN 0x2
#define STO_MIPS_PROTECTED 0x3
+#define STO_MIPS_PLT 0x8
#define STO_MIPS_SC_ALIGN_UNUSED 0xff
/* MIPS specific values for `st_info'. */
@@ -1689,8 +1699,11 @@ typedef struct
#define R_MIPS_TLS_TPREL64 48 /* TP-relative offset, 64 bit */
#define R_MIPS_TLS_TPREL_HI16 49 /* TP-relative offset, high 16 bits */
#define R_MIPS_TLS_TPREL_LO16 50 /* TP-relative offset, low 16 bits */
+#define R_MIPS_GLOB_DAT 51
+#define R_MIPS_COPY 126
+#define R_MIPS_JUMP_SLOT 127
/* Keep this the last entry. */
-#define R_MIPS_NUM 51
+#define R_MIPS_NUM 128
/* Legal values for p_type field of Elf32_Phdr. */
@@ -1756,7 +1769,13 @@ typedef struct
#define DT_MIPS_COMPACT_SIZE 0x7000002f /* (O32)Size of compact rel section. */
#define DT_MIPS_GP_VALUE 0x70000030 /* GP value for aux GOTs. */
#define DT_MIPS_AUX_DYNAMIC 0x70000031 /* Address of aux .dynamic. */
-#define DT_MIPS_NUM 0x32
+/* The address of .got.plt in an executable using the new non-PIC ABI. */
+#define DT_MIPS_PLTGOT 0x70000032
+/* The base of the PLT in an executable using the new non-PIC ABI if that
+ PLT is writable. For a non-writable PLT, this is omitted or has a zero
+ value. */
+#define DT_MIPS_RWPLT 0x70000034
+#define DT_MIPS_NUM 0x35
/* Legal values for DT_MIPS_FLAGS Elf32_Dyn entry. */
@@ -2163,10 +2182,10 @@ typedef Elf32_Addr Elf32_Conflict;
#define R_PPC_DIAB_RELSDA_HA 185 /* like EMB_RELSDA, adjusted high 16 */
/* GNU relocs used in PIC code sequences. */
-#define R_PPC_REL16 249 /* word32 (sym-.) */
-#define R_PPC_REL16_LO 250 /* half16 (sym-.)@l */
-#define R_PPC_REL16_HI 251 /* half16 (sym-.)@h */
-#define R_PPC_REL16_HA 252 /* half16 (sym-.)@ha */
+#define R_PPC_REL16 249 /* word32 (sym+add-.) */
+#define R_PPC_REL16_LO 250 /* half16 (sym+add-.)@l */
+#define R_PPC_REL16_HI 251 /* half16 (sym+add-.)@h */
+#define R_PPC_REL16_HA 252 /* half16 (sym+add-.)@ha */
/* This is a phony reloc to handle any old fashioned TOC16 references
that may still be in object files. */
@@ -2331,6 +2350,11 @@ typedef Elf32_Addr Elf32_Conflict;
#define SHF_ARM_COMDEF 0x80000000 /* Section may be multiply defined
in the input to a link step */
+#define SHT_ARM_EXIDX (SHT_LOPROC + 1) /* ARM unwind section. */
+#define SHT_ARM_PREEMPTMAP (SHT_LOPROC + 2) /* Preemption details. */
+#define SHT_ARM_ATTRIBUTES (SHT_LOPROC + 3) /* ARM attributes section. */
+
+
/* ARM-specific program header flags */
#define PF_ARM_SB 0x10000000 /* Segment contains the location
addressed by the static base */
@@ -2357,6 +2381,9 @@ typedef Elf32_Addr Elf32_Conflict;
#define R_ARM_THM_SWI8 14
#define R_ARM_XPC25 15
#define R_ARM_THM_XPC22 16
+#define R_ARM_TLS_DTPMOD32 17
+#define R_ARM_TLS_DTPOFF32 18
+#define R_ARM_TLS_TPOFF32 19
#define R_ARM_COPY 20 /* Copy symbol at runtime */
#define R_ARM_GLOB_DAT 21 /* Create GOT entry */
#define R_ARM_JUMP_SLOT 22 /* Create PLT entry */
@@ -2375,6 +2402,14 @@ typedef Elf32_Addr Elf32_Conflict;
#define R_ARM_GNU_VTINHERIT 101
#define R_ARM_THM_PC11 102 /* thumb unconditional branch */
#define R_ARM_THM_PC9 103 /* thumb conditional branch */
+#define R_ARM_TLS_GD32 104
+#define R_ARM_TLS_LDM32 105
+#define R_ARM_TLS_LDO32 106
+#define R_ARM_TLS_IE32 107
+#define R_ARM_TLS_LE32 108
+#define R_ARM_TLS_LDO12 109
+#define R_ARM_TLS_LE12 110
+#define R_ARM_TLS_IE12GP 111
#define R_ARM_RXPC25 249
#define R_ARM_RSBREL32 250
#define R_ARM_THM_RPC22 251
@@ -2786,53 +2821,6 @@ typedef Elf32_Addr Elf32_Conflict;
#define R_M32R_GOTOFF_LO 64 /* Low 16 bit offset to GOT */
#define R_M32R_NUM 256 /* Keep this the last entry. */
-/* i960 Relocations */
-#define R_960_NONE 0
-#define R_960_12 1
-#define R_960_32 2
-#define R_960_IP24 3
-#define R_960_SUB 4
-#define R_960_OPTCALL 5
-#define R_960_OPTCALLX 6
-#define R_960_OPTCALLXA 7
-/* Keep this the last entry. */
-#define R_960_NUM 8
-
-
-/* v850 relocations. */
-#define R_V850_NONE 0
-#define R_V850_9_PCREL 1
-#define R_V850_22_PCREL 2
-#define R_V850_HI16_S 3
-#define R_V850_HI16 4
-#define R_V850_LO16 5
-#define R_V850_32 6
-#define R_V850_16 7
-#define R_V850_8 8
-#define R_V850_SDA_16_16_OFFSET 9 /* For ld.b, st.b, set1, clr1,
- not1, tst1, movea, movhi */
-#define R_V850_SDA_15_16_OFFSET 10 /* For ld.w, ld.h, ld.hu, st.w, st.h */
-#define R_V850_ZDA_16_16_OFFSET 11 /* For ld.b, st.b, set1, clr1,
- not1, tst1, movea, movhi */
-#define R_V850_ZDA_15_16_OFFSET 12 /* For ld.w, ld.h, ld.hu, st.w, st.h */
-#define R_V850_TDA_6_8_OFFSET 13 /* For sst.w, sld.w */
-#define R_V850_TDA_7_8_OFFSET 14 /* For sst.h, sld.h */
-#define R_V850_TDA_7_7_OFFSET 15 /* For sst.b, sld.b */
-#define R_V850_TDA_16_16_OFFSET 16 /* For set1, clr1, not1, tst1,
- movea, movhi */
-/* CYGNUS LOCAL v850e */
-#define R_V850_TDA_4_5_OFFSET 17 /* For sld.hu */
-#define R_V850_TDA_4_4_OFFSET 18 /* For sld.bu */
-#define R_V850_SDA_16_16_SPLIT_OFFSET 19 /* For ld.bu */
-#define R_V850_ZDA_16_16_SPLIT_OFFSET 20 /* For ld.bu */
-#define R_V850_CALLT_6_7_OFFSET 21 /* For callt */
-#define R_V850_CALLT_16_16_OFFSET 22 /* For callt */
-/* END CYGNUS LOCAL */
-#define R_V850_GNU_VTINHERIT 23
-#define R_V850_GNU_VTENTRY 24
-/* Keep this the last entry. */
-#define R_V850_NUM 25
-
/* Atmel AVR32 relocations. */
#define R_AVR32_NONE 0
#define R_AVR32_32 1
@@ -2958,18 +2946,18 @@ typedef Elf32_Addr Elf32_Conflict;
#define R_NIOS2_PCREL16 3
#define R_NIOS2_CALL26 4
#define R_NIOS2_IMM5 5
-#define R_NIOS2_CACHE_OPX 6
+#define R_NIOS2_CACHE_OPX 6
#define R_NIOS2_IMM6 7
#define R_NIOS2_IMM8 8
#define R_NIOS2_HI16 9
#define R_NIOS2_LO16 10
-#define R_NIOS2_HIADJ16 11
+#define R_NIOS2_HIADJ16 11
#define R_NIOS2_BFD_RELOC_32 12
#define R_NIOS2_BFD_RELOC_16 13
-#define R_NIOS2_BFD_RELOC_8 14
+#define R_NIOS2_BFD_RELOC_8 14
#define R_NIOS2_GPREL 15
-#define R_NIOS2_GNU_VTINHERIT 16
-#define R_NIOS2_GNU_VTENTRY 17
+#define R_NIOS2_GNU_VTINHERIT 16
+#define R_NIOS2_GNU_VTENTRY 17
#define R_NIOS2_UJMP 18
#define R_NIOS2_CJMP 19
#define R_NIOS2_CALLR 20
@@ -3032,9 +3020,221 @@ typedef Elf32_Addr Elf32_Conflict;
#define R_XTENSA_SLOT12_ALT 47
#define R_XTENSA_SLOT13_ALT 48
#define R_XTENSA_SLOT14_ALT 49
+#define R_XTENSA_TLSDESC_FN 50
+#define R_XTENSA_TLSDESC_ARG 51
+#define R_XTENSA_TLS_TPOFF 53
/* Keep this the last entry. */
-#define R_XTENSA_NUM 50
-
-__END_DECLS
+#define R_XTENSA_NUM 54
+
+/* C6X specific relocs */
+#define R_C6000_NONE 0
+#define R_C6000_ABS32 1
+#define R_C6000_ABS16 2
+#define R_C6000_ABS8 3
+#define R_C6000_PCR_S21 4
+#define R_C6000_PCR_S12 5
+#define R_C6000_PCR_S10 6
+#define R_C6000_PCR_S7 7
+#define R_C6000_ABS_S16 8
+#define R_C6000_ABS_L16 9
+#define R_C6000_ABS_H16 10
+#define R_C6000_SBR_U15_B 11
+#define R_C6000_SBR_U15_H 12
+#define R_C6000_SBR_U15_W 13
+#define R_C6000_SBR_S16 14
+#define R_C6000_SBR_L16_B 15
+#define R_C6000_SBR_L16_H 16
+#define R_C6000_SBR_L16_W 17
+#define R_C6000_SBR_H16_B 18
+#define R_C6000_SBR_H16_H 19
+#define R_C6000_SBR_H16_W 20
+#define R_C6000_SBR_GOT_U15_W 21
+#define R_C6000_SBR_GOT_L16_W 22
+#define R_C6000_SBR_GOT_H16_W 23
+#define R_C6000_DSBT_INDEX 24
+#define R_C6000_PREL31 25
+#define R_C6000_COPY 26
+#define R_C6000_JUMP_SLOT 27
+#define R_C6000_SBR_GOT32 28
+#define R_C6000_PCR_H16 29
+#define R_C6000_PCR_L16 30
+#define R_C6000_ALIGN 253
+#define R_C6000_FPHEAD 254
+#define R_C6000_NOCMP 255
+
+/* C6x specific values for the Dyn d_tag field. */
+#define DT_C6000_DSBT_BASE (DT_LOPROC + 0)
+#define DT_C6000_DSBT_SIZE (DT_LOPROC + 1)
+#define DT_C6000_PREEMPTMAP (DT_LOPROC + 2)
+#define DT_C6000_DSBT_INDEX (DT_LOPROC + 3)
+
+#define DT_C6000_NUM 4
+
+/* microblaze specific relocs */
+#define R_MICROBLAZE_NONE 0
+#define R_MICROBLAZE_32 1
+#define R_MICROBLAZE_32_PCREL 2
+#define R_MICROBLAZE_64_PCREL 3
+#define R_MICROBLAZE_32_PCREL_LO 4
+#define R_MICROBLAZE_64 5
+#define R_MICROBLAZE_32_LO 6
+#define R_MICROBLAZE_SRO32 7
+#define R_MICROBLAZE_SRW32 8
+#define R_MICROBLAZE_64_NONE 9
+#define R_MICROBLAZE_32_SYM_OP_SYM 10
+#define R_MICROBLAZE_GNU_VTINHERIT 11
+#define R_MICROBLAZE_GNU_VTENTRY 12
+#define R_MICROBLAZE_GOTPC_64 13 /* PC-relative GOT offset */
+#define R_MICROBLAZE_GOT_64 14 /* GOT entry offset */
+#define R_MICROBLAZE_PLT_64 15 /* PLT offset (PC-relative */
+#define R_MICROBLAZE_REL 16 /* adjust by program base */
+#define R_MICROBLAZE_JUMP_SLOT 17 /* create PLT entry */
+#define R_MICROBLAZE_GLOB_DAT 18 /* create GOT entry */
+#define R_MICROBLAZE_GOTOFF_64 19 /* offset relative to GOT */
+#define R_MICROBLAZE_GOTOFF_32 20 /* offset relative to GOT */
+#define R_MICROBLAZE_COPY 21 /* runtime copy */
+#define R_MICROBLAZE_NUM 22
+
+/* Meta relocations */
+#define R_METAG_HIADDR16 0
+#define R_METAG_LOADDR16 1
+#define R_METAG_ADDR32 2
+#define R_METAG_NONE 3
+#define R_METAG_RELBRANCH 4
+#define R_METAG_GETSETOFF 5
+
+/* Backward compatability */
+#define R_METAG_REG32OP1 6
+#define R_METAG_REG32OP2 7
+#define R_METAG_REG32OP3 8
+#define R_METAG_REG16OP1 9
+#define R_METAG_REG16OP2 10
+#define R_METAG_REG16OP3 11
+#define R_METAG_REG32OP4 12
+
+#define R_METAG_HIOG 13
+#define R_METAG_LOOG 14
+
+/* GNU */
+#define R_METAG_GNU_VTINHERIT 30
+#define R_METAG_GNU_VTENTRY 31
+
+/* PIC relocations */
+#define R_METAG_HI16_GOTOFF 32
+#define R_METAG_LO16_GOTOFF 33
+#define R_METAG_GETSET_GOTOFF 34
+#define R_METAG_GETSET_GOT 35
+#define R_METAG_HI16_GOTPC 36
+#define R_METAG_LO16_GOTPC 37
+#define R_METAG_HI16_PLT 38
+#define R_METAG_LO16_PLT 39
+#define R_METAG_RELBRANCH_PLT 40
+#define R_METAG_GOTOFF 41
+#define R_METAG_PLT 42
+#define R_METAG_COPY 43
+#define R_METAG_JMP_SLOT 44
+#define R_METAG_RELATIVE 45
+#define R_METAG_GLOB_DAT 46
+
+/* TLS relocations */
+#define R_METAG_TLS_TPOFF 56
+#define R_METAG_TLS_DTPMOD 57
+#define R_METAG_TLS_DTPOFF 58
+
+/* OpenRISC 1000 specific relocs */
+#define R_OR1K_NONE 0
+#define R_OR1K_32 1
+#define R_OR1K_16 2
+#define R_OR1K_8 3
+#define R_OR1K_LO_16_IN_INSN 4
+#define R_OR1K_HI_16_IN_INSN 5
+#define R_OR1K_INSN_REL_26 6
+#define R_OR1K_GNU_VTENTRY 7
+#define R_OR1K_GNU_VTINHERIT 8
+#define R_OR1K_32_PCREL 9
+#define R_OR1K_16_PCREL 10
+#define R_OR1K_8_PCREL 11
+#define R_OR1K_GOTPC_HI16 12
+#define R_OR1K_GOTPC_LO16 13
+#define R_OR1K_GOT16 14
+#define R_OR1K_PLT26 15
+#define R_OR1K_GOTOFF_HI16 16
+#define R_OR1K_GOTOFF_LO16 17
+#define R_OR1K_COPY 18
+#define R_OR1K_GLOB_DAT 19
+#define R_OR1K_JMP_SLOT 20
+#define R_OR1K_RELATIVE 21
+
+/* ARCompact specific relocs */
+#define R_ARC_NONE 0x0
+#define R_ARC_8 0x1
+#define R_ARC_16 0x2
+#define R_ARC_24 0x3
+#define R_ARC_32 0x4
+#define R_ARC_B26 0x5
+#define R_ARC_B22_PCREL 0x6
+#define R_ARC_H30 0x7
+#define R_ARC_N8 0x8
+#define R_ARC_N16 0x9
+#define R_ARC_N24 0xA
+#define R_ARC_N32 0xB
+#define R_ARC_SDA 0xC
+#define R_ARC_SECTOFF 0xD
+#define R_ARC_S21H_PCREL 0xE
+#define R_ARC_S21W_PCREL 0xF
+#define R_ARC_S25H_PCREL 0x10
+#define R_ARC_S25W_PCREL 0x11
+#define R_ARC_SDA32 0x12
+#define R_ARC_SDA_LDST 0x13
+#define R_ARC_SDA_LDST1 0x14
+#define R_ARC_SDA_LDST2 0x15
+#define R_ARC_SDA16_LD 0x16
+#define R_ARC_SDA16_LD1 0x17
+#define R_ARC_SDA16_LD2 0x18
+#define R_ARC_S13_PCREL 0x19
+#define R_ARC_W 0x1A
+#define R_ARC_32_ME 0x1B
+#define R_ARC_N32_ME 0x1C
+#define R_ARC_SECTOFF_ME 0x1D
+#define R_ARC_SDA32_ME 0x1E
+#define R_ARC_W_ME 0x1F
+#define R_ARC_H30_ME 0x20
+#define R_ARC_SECTOFF_U8 0x21
+#define R_ARC_SECTOFF_S9 0x22
+#define R_AC_SECTOFF_U8 0x23
+#define R_AC_SECTOFF_U8_1 0x24
+#define R_AC_SECTOFF_U8_2 0x25
+#define R_AC_SECTOFF_S9 0x26
+#define R_AC_SECTOFF_S9_1 0x27
+#define R_AC_SECTOFF_S9_2 0x28
+#define R_ARC_SECTOFF_ME_1 0x29
+#define R_ARC_SECTOFF_ME_2 0x2A
+#define R_ARC_SECTOFF_1 0x2B
+#define R_ARC_SECTOFF_2 0x2C
+#define R_ARC_PC32 0x32
+#define R_ARC_GOTPC32 0x33
+#define R_ARC_PLT32 0x34
+#define R_ARC_COPY 0x35
+#define R_ARC_GLOB_DAT 0x36
+#define R_ARC_JMP_SLOT 0x37
+#define R_ARC_RELATIVE 0x38
+#define R_ARC_GOTOFF 0x39
+#define R_ARC_GOTPC 0x3A
+#define R_ARC_GOT32 0x3B
+
+#define R_ARC_TLS_DTPMOD 0x42
+#define R_ARC_TLS_DTPOFF 0x43
+#define R_ARC_TLS_TPOFF 0x44
+#define R_ARC_TLS_GD_GOT 0x45
+#define R_ARC_TLS_GD_LD 0x46
+#define R_ARC_TLS_GD_CALL 0x47
+#define R_ARC_TLS_IE_GOT 0x48
+#define R_ARC_TLS_DTPOFF_S9 0x4a
+#define R_ARC_TLS_LE_S9 0x4a
+#define R_ARC_TLS_LE_32 0x4b
+
+#ifdef __cplusplus
+}
+#endif
#endif /* elf.h */
diff --git a/include/endian.h b/include/endian.h
index 2f7bce100..23a265485 100644
--- a/include/endian.h
+++ b/include/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/>. */
#ifndef _ENDIAN_H
#define _ENDIAN_H 1
@@ -55,4 +54,53 @@
# define __LONG_LONG_PAIR(HI, LO) HI, LO
#endif
+#ifdef _LIBC
+# ifndef __ASSEMBLER__
+# include <stdint.h>
+# define OFF_HI(offset) (offset >> 31)
+# define OFF_LO(offset) (offset)
+# define OFF64_HI(offset) (uint32_t)(offset >> 32)
+# define OFF64_LO(offset) (uint32_t)(offset & 0xffffffff)
+# define OFF_HI_LO(offset) __LONG_LONG_PAIR(OFF_HI(offset), OFF_LO(offset))
+# define OFF64_HI_LO(offset) __LONG_LONG_PAIR(OFF64_HI(offset), OFF64_LO(offset))
+# endif
+#endif
+
+#ifdef __USE_BSD
+/* Conversion interfaces. */
+# include <byteswap.h>
+
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+# define htobe16(x) __bswap_16 (x)
+# define htole16(x) (x)
+# define be16toh(x) __bswap_16 (x)
+# define le16toh(x) (x)
+
+# define htobe32(x) __bswap_32 (x)
+# define htole32(x) (x)
+# define be32toh(x) __bswap_32 (x)
+# define le32toh(x) (x)
+
+# define htobe64(x) __bswap_64 (x)
+# define htole64(x) (x)
+# define be64toh(x) __bswap_64 (x)
+# define le64toh(x) (x)
+# else
+# define htobe16(x) (x)
+# define htole16(x) __bswap_16 (x)
+# define be16toh(x) (x)
+# define le16toh(x) __bswap_16 (x)
+
+# define htobe32(x) (x)
+# define htole32(x) __bswap_32 (x)
+# define be32toh(x) (x)
+# define le32toh(x) __bswap_32 (x)
+
+# define htobe64(x) (x)
+# define htole64(x) __bswap_64 (x)
+# define be64toh(x) (x)
+# define le64toh(x) __bswap_64 (x)
+# endif
+#endif
+
#endif /* endian.h */
diff --git a/include/err.h b/include/err.h
index 7ff3553ab..25ff4e957 100644
--- a/include/err.h
+++ b/include/err.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 _ERR_H
#define _ERR_H 1
@@ -32,25 +31,25 @@ __BEGIN_DECLS
/* Print "program: ", FORMAT, ": ", the standard error string for errno,
and a newline, on stderr. */
-extern void warn (__const char *__format, ...)
+extern void warn (const char *__format, ...)
__attribute__ ((__format__ (__printf__, 1, 2)));
-extern void vwarn (__const char *__format, __gnuc_va_list)
+extern void vwarn (const char *__format, __gnuc_va_list)
__attribute__ ((__format__ (__printf__, 1, 0)));
/* Likewise, but without ": " and the standard error string. */
-extern void warnx (__const char *__format, ...)
+extern void warnx (const char *__format, ...)
__attribute__ ((__format__ (__printf__, 1, 2)));
-extern void vwarnx (__const char *__format, __gnuc_va_list)
+extern void vwarnx (const char *__format, __gnuc_va_list)
__attribute__ ((__format__ (__printf__, 1, 0)));
/* Likewise, and then exit with STATUS. */
-extern void err (int __status, __const char *__format, ...)
+extern void err (int __status, const char *__format, ...)
__attribute__ ((__noreturn__, __format__ (__printf__, 2, 3)));
-extern void verr (int __status, __const char *__format, __gnuc_va_list)
+extern void verr (int __status, const char *__format, __gnuc_va_list)
__attribute__ ((__noreturn__, __format__ (__printf__, 2, 0)));
-extern void errx (int __status, __const char *__format, ...)
+extern void errx (int __status, const char *__format, ...)
__attribute__ ((__noreturn__, __format__ (__printf__, 2, 3)));
-extern void verrx (int __status, __const char *, __gnuc_va_list)
+extern void verrx (int __status, const char *, __gnuc_va_list)
__attribute__ ((__noreturn__, __format__ (__printf__, 2, 0)));
__END_DECLS
diff --git a/include/errno.h b/include/errno.h
index b2315b90a..4e3a81689 100644
--- a/include/errno.h
+++ b/include/errno.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 Standard: 7.5 Errors <errno.h>
@@ -47,6 +46,11 @@ __BEGIN_DECLS
extern int errno;
#endif
+#ifdef _LIBC
+# ifdef __UCLIBC_HAS___PROGNAME__
+extern const char *__progname, *__progname_full;
+# endif
+#endif
#if defined __USE_GNU && defined __UCLIBC_HAS_PROGRAM_INVOCATION_NAME__
/* The full and simple forms of the name with which the program was
@@ -58,9 +62,27 @@ extern const char *program_invocation_name, *program_invocation_short_name;
__END_DECLS
-#if defined _LIBC && ( defined IS_IN_libc || defined NOT_IN_libc )
-#include <bits/uClibc_errno.h>
+#ifdef _LIBC
+#ifdef IS_IN_rtld
+# undef errno
+# define errno _dl_errno
+extern int _dl_errno; /* attribute_hidden */
+#elif defined __UCLIBC_HAS_TLS__
+# if !defined NOT_IN_libc || defined IS_IN_libpthread
+# undef errno
+# ifndef NOT_IN_libc
+# define errno __libc_errno
+# else
+# define errno errno /* For #ifndef errno tests. */
+# endif
+extern __thread int errno attribute_tls_model_ie;
+# endif
+#endif
+
+#ifndef __set_errno
+#define __set_errno(val) (errno = (val))
#endif
+#endif /* _LIBC */
#endif /* _ERRNO_H */
diff --git a/include/error.h b/include/error.h
index b553caeb9..867a36658 100644
--- a/include/error.h
+++ b/include/error.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 _ERROR_H
#define _ERROR_H 1
diff --git a/include/execinfo.h b/include/execinfo.h
new file mode 100644
index 000000000..503c84662
--- /dev/null
+++ b/include/execinfo.h
@@ -0,0 +1,43 @@
+/* Copyright (C) 1998, 1999, 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/>. */
+
+#ifndef _EXECINFO_H
+#define _EXECINFO_H 1
+
+#include <features.h>
+
+__BEGIN_DECLS
+
+/* Store up to SIZE return address of the current program state in
+ ARRAY and return the exact number of values stored. */
+extern int backtrace (void **__array, int __size) __nonnull ((1));
+
+
+/* Return names of functions from the backtrace list in ARRAY in a newly
+ malloc()ed memory block. */
+extern char **backtrace_symbols (void *const *__array, int __size)
+ __THROW __nonnull ((1));
+
+
+/* This function is similar to backtrace_symbols() but it writes the result
+ immediately to a file. */
+extern void backtrace_symbols_fd (void *const *__array, int __size, int __fd)
+ __THROW __nonnull ((1));
+
+__END_DECLS
+
+#endif /* execinfo.h */
diff --git a/include/fcntl.h b/include/fcntl.h
index adeabaebb..adcd7ef4b 100644
--- a/include/fcntl.h
+++ b/include/fcntl.h
@@ -1,5 +1,5 @@
-/* Copyright (C) 1991,1992,1994-2001,2003,2004,2005
- Free Software Foundation, Inc.
+/* Copyright (C) 1991,1992,1994-2001,2003,2004,2005,2006,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/>. */
/*
* POSIX Standard: 6.5 File Control Operations <fcntl.h>
@@ -56,13 +55,21 @@ __BEGIN_DECLS
# define SEEK_END 2 /* Seek from end of file. */
#endif /* XPG */
-#if 0 /*def __USE_GNU*/
+#ifdef __USE_ATFILE
# define AT_FDCWD -100 /* Special value used to indicate
- openat should use the current
- working directory. */
+ the *at functions should use the
+ current working directory. */
# define AT_SYMLINK_NOFOLLOW 0x100 /* Do not follow symbolic links. */
# define AT_REMOVEDIR 0x200 /* Remove directory instead of
unlinking file. */
+# define AT_SYMLINK_FOLLOW 0x400 /* Follow symbolic links. */
+# ifdef __USE_GNU
+# define AT_NO_AUTOMOUNT 0x800 /* Suppress terminal automount
+ traversal. */
+# define AT_EMPTY_PATH 0x1000 /* Allow empty relative pathname. */
+# endif
+# define AT_EACCESS 0x200 /* Test access permitted for
+ effective IDs, not real IDs. */
#endif
/* Do the file control operation described by CMD on FD.
@@ -70,8 +77,12 @@ __BEGIN_DECLS
This function is a cancellation point and therefore not marked with
__THROW. */
-#ifndef __USE_FILE_OFFSET64
+#if !defined(__USE_FILE_OFFSET64) || defined(__LP64__)
extern int fcntl (int __fd, int __cmd, ...);
+# ifdef _LIBC
+extern int __fcntl_nocancel(int, int, long) attribute_hidden;
+libc_hidden_proto(fcntl)
+# endif
#else
# ifdef __REDIRECT
extern int __REDIRECT (fcntl, (int __fd, int __cmd, ...), fcntl64);
@@ -79,8 +90,12 @@ extern int __REDIRECT (fcntl, (int __fd, int __cmd, ...), fcntl64);
# define fcntl fcntl64
# endif
#endif
-#ifdef __USE_LARGEFILE64
+#if defined(__USE_LARGEFILE64) && !defined(__LP64__)
extern int fcntl64 (int __fd, int __cmd, ...);
+# ifdef _LIBC
+extern int __fcntl64_nocancel(int, int, long) attribute_hidden;
+libc_hidden_proto(fcntl64)
+# endif
#endif
/* Open FILE and return a new file descriptor for it, or -1 on error.
@@ -90,42 +105,49 @@ extern int fcntl64 (int __fd, int __cmd, ...);
This function is a cancellation point and therefore not marked with
__THROW. */
#ifndef __USE_FILE_OFFSET64
-extern int open (__const char *__file, int __oflag, ...) __nonnull ((1));
+extern int open (const char *__file, int __oflag, ...) __nonnull ((1));
+libc_hidden_proto(open)
+# ifdef _LIBC
+extern int __open2_nocancel(const char *, int) __nonnull ((1)) attribute_hidden;
+extern int __open_nocancel(const char *, int, mode_t) __nonnull ((1)) attribute_hidden;
+# endif
#else
# ifdef __REDIRECT
-extern int __REDIRECT (open, (__const char *__file, int __oflag, ...), open64)
+extern int __REDIRECT (open, (const char *__file, int __oflag, ...), open64)
__nonnull ((1));
# else
# define open open64
# endif
#endif
#ifdef __USE_LARGEFILE64
-extern int open64 (__const char *__file, int __oflag, ...) __nonnull ((1));
+extern int open64 (const char *__file, int __oflag, ...) __nonnull ((1));
+libc_hidden_proto(open64)
#endif
-#if 0 /*def __USE_GNU*/
-/* Similar to OPEN but a relative path name is interpreted relative to
+#ifdef __USE_ATFILE
+/* Similar to `open' but a relative path name is interpreted relative to
the directory for which FD is a descriptor.
- NOTE: some other OPENAT implementation support additional functionality
+ NOTE: some other `openat' implementation support additional functionality
through this interface, especially using the O_XATTR flag. This is not
yet supported here.
This function is a cancellation point and therefore not marked with
__THROW. */
# ifndef __USE_FILE_OFFSET64
-extern int openat (int __fd, __const char *__file, int __oflag, ...)
+extern int openat (int __fd, const char *__file, int __oflag, ...)
__nonnull ((2));
+libc_hidden_proto(openat)
# else
# ifdef __REDIRECT
-extern int __REDIRECT (openat, (int __fd, __const char *__file, int __oflag,
+extern int __REDIRECT (openat, (int __fd, const char *__file, int __oflag,
...), openat64) __nonnull ((2));
# else
# define openat openat64
# endif
# endif
-extern int openat64 (int __fd, __const char *__file, int __oflag, ...)
+extern int openat64 (int __fd, const char *__file, int __oflag, ...)
__nonnull ((2));
#endif
@@ -135,17 +157,17 @@ extern int openat64 (int __fd, __const char *__file, int __oflag, ...)
This function is a cancellation point and therefore not marked with
__THROW. */
#ifndef __USE_FILE_OFFSET64
-extern int creat (__const char *__file, __mode_t __mode) __nonnull ((1));
+extern int creat (const char *__file, __mode_t __mode) __nonnull ((1));
#else
# ifdef __REDIRECT
-extern int __REDIRECT (creat, (__const char *__file, __mode_t __mode),
+extern int __REDIRECT (creat, (const char *__file, __mode_t __mode),
creat64) __nonnull ((1));
# else
# define creat creat64
# endif
#endif
#ifdef __USE_LARGEFILE64
-extern int creat64 (__const char *__file, __mode_t __mode) __nonnull ((1));
+extern int creat64 (const char *__file, __mode_t __mode) __nonnull ((1));
#endif
#if !defined F_LOCK && (defined __USE_MISC || (defined __USE_XOPEN_EXTENDED \
@@ -165,12 +187,13 @@ extern int creat64 (__const char *__file, __mode_t __mode) __nonnull ((1));
# ifndef __USE_FILE_OFFSET64
extern int lockf (int __fd, int __cmd, __off_t __len);
+libc_hidden_proto(lockf)
# else
-# ifdef __REDIRECT
+# ifdef __REDIRECT
extern int __REDIRECT (lockf, (int __fd, int __cmd, __off64_t __len), lockf64);
-# else
-# define lockf lockf64
-# endif
+# else
+# define lockf lockf64
+# endif
# endif
# ifdef __USE_LARGEFILE64
extern int lockf64 (int __fd, int __cmd, __off64_t __len);
@@ -184,13 +207,13 @@ extern int lockf64 (int __fd, int __cmd, __off64_t __len);
extern int posix_fadvise (int __fd, __off_t __offset, __off_t __len,
int __advise) __THROW;
# else
-# ifdef __REDIRECT_NTH
+# ifdef __REDIRECT_NTH
extern int __REDIRECT_NTH (posix_fadvise, (int __fd, __off64_t __offset,
- __off64_t __len, int __advise),
- posix_fadvise64);
-# else
-# define posix_fadvise posix_fadvise64
-# endif
+ __off64_t __len, int __advise),
+ posix_fadvise64);
+# else
+# define posix_fadvise posix_fadvise64
+# endif
# endif
# ifdef __USE_LARGEFILE64
extern int posix_fadvise64 (int __fd, __off64_t __offset, __off64_t __len,
@@ -199,30 +222,60 @@ extern int posix_fadvise64 (int __fd, __off64_t __offset, __off64_t __len,
#endif
-#if 0 // && defined __UCLIBC_HAS_ADVANCED_REALTIME__
-
-/* FIXME -- uClibc should probably implement these... */
+#if defined __UCLIBC_HAS_ADVANCED_REALTIME__
/* Reserve storage for the data of the file associated with FD.
- This function is a possible cancellation points and therefore not
+ This function is a possible cancellation point and therefore not
marked with __THROW. */
# ifndef __USE_FILE_OFFSET64
extern int posix_fallocate (int __fd, __off_t __offset, __off_t __len);
# else
-# ifdef __REDIRECT
+# ifdef __REDIRECT
extern int __REDIRECT (posix_fallocate, (int __fd, __off64_t __offset,
__off64_t __len),
posix_fallocate64);
-# else
-# define posix_fallocate posix_fallocate64
-# endif
+# else
+# define posix_fallocate posix_fallocate64
+# endif
# endif
# ifdef __USE_LARGEFILE64
extern int posix_fallocate64 (int __fd, __off64_t __offset, __off64_t __len);
# endif
#endif
+#if (defined __UCLIBC_LINUX_SPECIFIC__ && defined __USE_GNU) || defined _LIBC
+/* Reserve storage for the data of a file associated with FD. This function
+ is Linux-specific. For the portable version, use posix_fallocate().
+ Unlike the latter, fallocate can operate in different modes. The default
+ mode = 0 is equivalent to posix_fallocate().
+
+ Note: These declarations are used in posix_fallocate.c and
+ posix_fallocate64.c, so we expose them internally.
+ */
+
+/* Flags for fallocate's mode. */
+# define FALLOC_FL_KEEP_SIZE 1 /* Don't extend size of file
+ even if offset + len is
+ greater than file size. */
+# define FALLOC_FL_PUNCH_HOLE 2 /* Create a hole in the file. */
+
+# ifndef __USE_FILE_OFFSET64
+extern int fallocate (int __fd, int __mode, __off_t __offset, __off_t __len);
+# else
+# ifdef __REDIRECT
+extern int __REDIRECT (fallocate, (int __fd, int __mode, __off64_t __offset,
+ __off64_t __len),
+ fallocate64);
+# else
+# define fallocate fallocate64
+# endif
+# endif
+# ifdef __USE_LARGEFILE64
+extern int fallocate64 (int __fd, int __mode, __off64_t __offset, __off64_t __len);
+# endif
+#endif
+
__END_DECLS
#endif /* fcntl.h */
diff --git a/include/features.h b/include/features.h
index defdd04c6..dcf1348d8 100644
--- a/include/features.h
+++ b/include/features.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-1993,1995-2003,2004,2005 Free Software Foundation, Inc.
+/* Copyright (C) 1991-1993,1995-2006,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
@@ -12,34 +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/>. */
#ifndef _FEATURES_H
#define _FEATURES_H 1
-/* This macro indicates that the installed library is uClibc. Use
- * __UCLIBC_MAJOR__ and __UCLIBC_MINOR__ to test for the features in
- * specific releases. */
-#define __UCLIBC__ 1
-
-/* Load up the current set of uClibc supported features along
- * with the current uClibc major and minor version numbers.
- * For uClibc release 0.9.26, these numbers would be:
- * #define __UCLIBC_MAJOR__ 0
- * #define __UCLIBC_MINOR__ 9
- * #define __UCLIBC_SUBLEVEL__ 26
- */
-#define __need_uClibc_config_h
-#include <bits/uClibc_config.h>
-#undef __need_uClibc_config_h
-#include <bits/uClibc_arch_features.h>
-
-/* For uClibc, always optimize for size -- this should disable
- * a lot of expensive inlining... */
-#define __OPTIMIZE_SIZE__ 1
-
/* These are defined by the user (or the compiler)
to specify the desired environment:
@@ -50,9 +28,10 @@
if >=199309L, add IEEE Std 1003.1b-1993;
if >=199506L, add IEEE Std 1003.1c-1995;
if >=200112L, all of IEEE 1003.1-2004
+ if >=200809L, all of IEEE 1003.1-2008
_XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if
Single Unix conformance is wanted, to 600 for the
- upcoming sixth revision.
+ sixth revision, to 700 for the seventh revision.
_XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions.
_LARGEFILE_SOURCE Some more functions for correct standard I/O.
_LARGEFILE64_SOURCE Additional functionality from LFS for large files.
@@ -69,7 +48,7 @@
The `-ansi' switch to the GNU C compiler defines __STRICT_ANSI__.
If none of these are defined, the default is to have _SVID_SOURCE,
_BSD_SOURCE, and _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to
- 199506L. If more than one of these are defined, they accumulate.
+ 200112L. If more than one of these are defined, they accumulate.
For example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE
together give you ISO C, 1003.1, and 1003.2, but nothing else.
@@ -77,6 +56,7 @@
header files to decide what to declare or define:
__USE_ISOC99 Define ISO C99 things.
+ __USE_ISOC95 Define ISO C90 AMD1 (C95) things.
__USE_POSIX Define IEEE Std 1003.1 things.
__USE_POSIX2 Define IEEE Std 1003.2 things.
__USE_POSIX199309 Define IEEE Std 1003.1, and .1b things.
@@ -85,6 +65,7 @@
__USE_XOPEN_EXTENDED Define X/Open Unix things.
__USE_UNIX98 Define Single Unix V2 things.
__USE_XOPEN2K Define XPG6 things.
+ __USE_XOPEN2K8 Define XPG7 things.
__USE_LARGEFILE Define correct standard I/O things.
__USE_LARGEFILE64 Define LFS things with separate names.
__USE_FILE_OFFSET64 Define 64bit interface as default.
@@ -111,6 +92,7 @@
/* Undefine everything, so we get a clean slate. */
#undef __USE_ISOC99
+#undef __USE_ISOC95
#undef __USE_POSIX
#undef __USE_POSIX2
#undef __USE_POSIX199309
@@ -119,6 +101,7 @@
#undef __USE_XOPEN_EXTENDED
#undef __USE_UNIX98
#undef __USE_XOPEN2K
+#undef __USE_XOPEN2K8
#undef __USE_LARGEFILE
#undef __USE_LARGEFILE64
#undef __USE_FILE_OFFSET64
@@ -171,15 +154,13 @@
# undef _POSIX_SOURCE
# define _POSIX_SOURCE 1
# undef _POSIX_C_SOURCE
-# define _POSIX_C_SOURCE 199506L
+# define _POSIX_C_SOURCE 200809L
# undef _XOPEN_SOURCE
-# define _XOPEN_SOURCE 600
+# define _XOPEN_SOURCE 700
# undef _XOPEN_SOURCE_EXTENDED
# define _XOPEN_SOURCE_EXTENDED 1
-# ifdef __UCLIBC_HAS_LFS__
-# undef _LARGEFILE64_SOURCE
-# define _LARGEFILE64_SOURCE 1
-# endif /* __UCLIBC_HAS_LFS__ */
+# undef _LARGEFILE64_SOURCE
+# define _LARGEFILE64_SOURCE 1
# undef _BSD_SOURCE
# define _BSD_SOURCE 1
# undef _SVID_SOURCE
@@ -188,6 +169,60 @@
# define _ATFILE_SOURCE 1
#endif
+/* This macro indicates that the installed library is uClibc. Use
+ * __UCLIBC_MAJOR__ and __UCLIBC_MINOR__ to test for the features in
+ * specific releases. */
+#define __UCLIBC__ 1
+
+#ifdef __UCLIBC__
+/* Load up the current set of uClibc supported features along
+ * with the current uClibc major and minor version numbers.
+ * For uClibc release 0.9.26, these numbers would be:
+ * #define __UCLIBC_MAJOR__ 0
+ * #define __UCLIBC_MINOR__ 9
+ * #define __UCLIBC_SUBLEVEL__ 26
+ */
+# define __need_uClibc_config_h
+# include <bits/uClibc_config.h>
+# undef __need_uClibc_config_h
+
+/* For uClibc, always optimize for size -- this should disable
+ * a lot of expensive inlining...
+ * TODO: this is wrong! __OPTIMIZE_SIZE__ is an indicator of
+ * gcc -Os compile. We should not mess with compiler inlines.
+ * We should instead disable __USE_EXTERN_INLINES unconditionally,
+ * or maybe actually audit and test uclibc to work correctly
+ * with __USE_EXTERN_INLINES on.
+ */
+# define __OPTIMIZE_SIZE__ 1
+
+/* disable unsupported features */
+# undef __LDBL_COMPAT
+
+# ifndef __UCLIBC_HAS_FORTIFY__
+# undef _FORTIFY_SOURCE
+# endif
+
+# ifndef __UCLIBC_HAS_THREADS__
+# if defined _REENTRANT || defined _THREAD_SAFE
+# warning requested reentrant code, but thread support was disabled
+# undef _REENTRANT
+# undef _THREAD_SAFE
+# endif
+# endif
+
+# ifndef __UCLIBC_HAS_LFS__
+# undef _LARGEFILE64_SOURCE
+/* NOTE: This is probably incorrect on a 64-bit arch... */
+# if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64
+# error It appears you have defined _FILE_OFFSET_BITS=64. Unfortunately, \
+uClibc was built without large file support enabled.
+# endif
+# elif defined __BCC__
+# error BCC does not support LFS, please disable it
+# endif
+#endif /* __UCLIBC__ */
+
/* If nothing (other than _GNU_SOURCE) is defined,
define _BSD_SOURCE and _SVID_SOURCE. */
#if (!defined __STRICT_ANSI__ && !defined _ISOC99_SOURCE && \
@@ -207,6 +242,12 @@
# define __USE_ISOC99 1
#endif
+/* This is to enable the ISO C90 Amendment 1:1995 extension. */
+#if (defined _ISOC99_SOURCE || defined _ISOC9X_SOURCE \
+ || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199409L))
+# define __USE_ISOC95 1
+#endif
+
/* If none of the ANSI/POSIX macros are defined, use POSIX.1 and POSIX.2
(and IEEE Std 1003.1b-1993 unless _XOPEN_SOURCE is defined). */
#if ((!defined __STRICT_ANSI__ || (_XOPEN_SOURCE - 0) >= 500) && \
@@ -214,9 +255,14 @@
# define _POSIX_SOURCE 1
# if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 500
# define _POSIX_C_SOURCE 2
-# else
+# elif defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 600
# define _POSIX_C_SOURCE 199506L
+# elif defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 700
+# define _POSIX_C_SOURCE 200112L
+# else
+# define _POSIX_C_SOURCE 200809L
# endif
+# define __USE_POSIX_IMPLICITLY 1
#endif
#if defined _POSIX_SOURCE || _POSIX_C_SOURCE >= 1 || defined _XOPEN_SOURCE
@@ -237,6 +283,14 @@
#if (_POSIX_C_SOURCE - 0) >= 200112L
# define __USE_XOPEN2K 1
+# undef __USE_ISOC99
+# define __USE_ISOC99 1
+#endif
+
+#if (_POSIX_C_SOURCE - 0) >= 200809L
+# define __USE_XOPEN2K8 1
+# undef _ATFILE_SOURCE
+# define _ATFILE_SOURCE 1
#endif
#ifdef _XOPEN_SOURCE
@@ -247,6 +301,9 @@
# undef _LARGEFILE_SOURCE
# define _LARGEFILE_SOURCE 1
# if (_XOPEN_SOURCE - 0) >= 600
+# if (_XOPEN_SOURCE - 0) >= 700
+# define __USE_XOPEN2K8 1
+# endif
# define __USE_XOPEN2K 1
# undef __USE_ISOC99
# define __USE_ISOC99 1
@@ -294,8 +351,6 @@
# define __USE_REENTRANT 1
#endif
-/* uClibc does not support _FORTIFY_SOURCE */
-#undef _FORTIFY_SOURCE
#if defined _FORTIFY_SOURCE && _FORTIFY_SOURCE > 0 \
&& __GNUC_PREREQ (4, 1) && defined __OPTIMIZE__ && __OPTIMIZE__ > 0
# if _FORTIFY_SOURCE > 1
@@ -308,12 +363,14 @@
#endif
/* We do support the IEC 559 math functionality, real and complex. */
+#ifdef __UCLIBC_HAS_FLOATS__
#define __STDC_IEC_559__ 1
#define __STDC_IEC_559_COMPLEX__ 1
+#endif
#ifdef __UCLIBC_HAS_WCHAR__
/* wchar_t uses ISO 10646-1 (2nd ed., published 2000-09-15) / Unicode 3.1. */
-# define __STDC_ISO_10646__ 200009L
+#define __STDC_ISO_10646__ 200009L
#endif
/* There is an unwholesomely huge amount of code out there that depends on the
@@ -327,14 +384,16 @@
/* This macro indicates that the installed library is the GNU C Library.
For historic reasons the value now is 6 and this will stay from now
on. The use of this variable is deprecated. */
-# undef __GNU_LIBRARY__
-# define __GNU_LIBRARY__ 6
+/* uClibc WARNING: leave these aligned to the left, don't put a space after '#', else
+ * broken apps could fail the check. */
+#undef __GNU_LIBRARY__
+#define __GNU_LIBRARY__ 6
/* Major and minor version number of the GNU C library package. Use
these macros to test for features in specific releases. */
/* Don't do it, if you want to keep uClibc happy. */
-# define __GLIBC__ 2
-# define __GLIBC_MINOR__ 2
+#define __GLIBC__ 2
+#define __GLIBC_MINOR__ 2
#endif
#define __GLIBC_PREREQ(maj, min) \
@@ -360,66 +419,32 @@
__USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. */
# if defined __USE_FILE_OFFSET64 && !defined __REDIRECT
# define __USE_LARGEFILE 1
+# ifdef __UCLIBC_HAS_LFS__
# define __USE_LARGEFILE64 1
+# endif
# endif
#endif /* !ASSEMBLER */
-/* Decide whether we can define 'extern inline' functions in headers. */
+/* Decide whether we can, and are willing to define extern inline
+ * functions in headers, even if this results in a slightly bigger
+ * code for user programs built against uclibc.
+ * Enabled only in -O2 compiles, not -Os.
+ * uclibc itself is usually built without __USE_EXTERN_INLINES,
+ * remove "&& !defined __OPTIMIZE_SIZE__" part to do otherwise.
+ */
#if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__ \
- && (defined __extern_inline || defined __GNUC_GNU_INLINE__)
+ && (defined __extern_inline || defined __GNUC_GNU_INLINE__ || defined __GNUC_STDC_INLINE__)
# define __USE_EXTERN_INLINES 1
#endif
-
-/* Make sure users large file options agree with uClibc's configuration. */
-#ifndef __UCLIBC_HAS_LFS__
-
-/* If uClibc was built without large file support, output an error if
- * 64-bit file offsets were requested.
- * NOTE: This is probably incorrect on a 64-bit arch... */
-# ifdef __USE_FILE_OFFSET64
-# error It appears you have defined _FILE_OFFSET_BITS=64. Unfortunately, \
-uClibc was built without large file support enabled.
-# endif
-
-/* If uClibc was built without large file support and _LARGEFILE64_SOURCE
- * is defined, undefine it. */
-# ifdef _LARGEFILE64_SOURCE
-# undef _LARGEFILE64_SOURCE
-# undef __USE_LARGEFILE64
-# endif
-
-/* If we're actually building uClibc with large file support,
- * define __USE_LARGEFILE64 and __USE_LARGEFILE. */
-#elif defined _LIBC
-# undef _LARGEFILE_SOURCE
-# undef _LARGEFILE64_SOURCE
-# undef _FILE_OFFSET_BITS
-# undef __USE_LARGEFILE
-# undef __USE_LARGEFILE64
-# undef __USE_FILE_OFFSET64
-# define _LARGEFILE_SOURCE 1
-# define _LARGEFILE64_SOURCE 1
-# define __USE_LARGEFILE 1
-# define __USE_LARGEFILE64 1
-#endif
-
-/* uClibc does not support *at interfaces. */
-#undef _ATFILE_SOURCE
-#undef __USE_ATFILE
-
#ifdef _LIBC
+# ifdef __UCLIBC_HAS_LFS__
+# undef _FILE_OFFSET_BITS
+# undef __USE_FILE_OFFSET64
+# endif
# include <libc-internal.h>
#endif
-/* Some people like to build up uClibc with *-elf toolchains, so
- * a little grease here until we drop '#ifdef __linux__' checks
- * from our source code.
- */
-#ifndef __linux__
-# define __linux__ 1
-#endif
-
#endif /* features.h */
diff --git a/include/fenv.h b/include/fenv.h
index 8a06f024e..9ba384756 100644
--- a/include/fenv.h
+++ b/include/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/include/fnmatch.h b/include/fnmatch.h
index aefb007fb..d77e4b6b0 100644
--- a/include/fnmatch.h
+++ b/include/fnmatch.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 _FNMATCH_H
#define _FNMATCH_H 1
@@ -23,14 +22,6 @@
extern "C" {
#endif
-#ifndef const
-# if (defined __STDC__ && __STDC__) || defined __cplusplus
-# define __const const
-# else
-# define __const
-# endif
-#endif
-
/* We #undef these before defining them because some losing systems
(HP-UX A.08.07 for example) define these in <unistd.h>. */
#undef FNM_PATHNAME
@@ -62,8 +53,9 @@ extern "C" {
/* Match NAME against the filename pattern PATTERN,
returning zero if it matches, FNM_NOMATCH if not. */
-extern int fnmatch (__const char *__pattern, __const char *__name,
+extern int fnmatch (const char *__pattern, const char *__name,
int __flags);
+libc_hidden_proto(fnmatch)
#ifdef __cplusplus
}
diff --git a/include/fts.h b/include/fts.h
new file mode 100644
index 000000000..0a070ba8d
--- /dev/null
+++ b/include/fts.h
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)fts.h 8.3 (Berkeley) 8/14/94
+ */
+
+#ifndef _FTS_H
+#define _FTS_H 1
+
+#include <features.h>
+#include <sys/types.h>
+
+/* The fts interface is incompatible with the LFS interface which
+ transparently uses the 64-bit file access functions. */
+#ifdef __USE_FILE_OFFSET64
+# error "<fts.h> cannot be used with -D_FILE_OFFSET_BITS==64"
+#endif
+
+
+typedef struct {
+ struct _ftsent *fts_cur; /* current node */
+ struct _ftsent *fts_child; /* linked list of children */
+ struct _ftsent **fts_array; /* sort array */
+ dev_t fts_dev; /* starting device # */
+ char *fts_path; /* path for this descent */
+ int fts_rfd; /* fd for root */
+ int fts_pathlen; /* sizeof(path) */
+ int fts_nitems; /* elements in the sort array */
+ int (*fts_compar) (const void *, const void *); /* compare fn */
+
+#define FTS_COMFOLLOW 0x0001 /* follow command line symlinks */
+#define FTS_LOGICAL 0x0002 /* logical walk */
+#define FTS_NOCHDIR 0x0004 /* don't change directories */
+#define FTS_NOSTAT 0x0008 /* don't get stat info */
+#define FTS_PHYSICAL 0x0010 /* physical walk */
+#define FTS_SEEDOT 0x0020 /* return dot and dot-dot */
+#define FTS_XDEV 0x0040 /* don't cross devices */
+#define FTS_WHITEOUT 0x0080 /* return whiteout information */
+#define FTS_OPTIONMASK 0x00ff /* valid user option mask */
+
+#define FTS_NAMEONLY 0x0100 /* (private) child names only */
+#define FTS_STOP 0x0200 /* (private) unrecoverable error */
+ int fts_options; /* fts_open options, global flags */
+} FTS;
+
+typedef struct _ftsent {
+ struct _ftsent *fts_cycle; /* cycle node */
+ struct _ftsent *fts_parent; /* parent directory */
+ struct _ftsent *fts_link; /* next file in directory */
+ long fts_number; /* local numeric value */
+ void *fts_pointer; /* local address value */
+ char *fts_accpath; /* access path */
+ char *fts_path; /* root path */
+ int fts_errno; /* errno for this node */
+ int fts_symfd; /* fd for symlink */
+ u_short fts_pathlen; /* strlen(fts_path) */
+ u_short fts_namelen; /* strlen(fts_name) */
+
+ ino_t fts_ino; /* inode */
+ dev_t fts_dev; /* device */
+ nlink_t fts_nlink; /* link count */
+
+#define FTS_ROOTPARENTLEVEL -1
+#define FTS_ROOTLEVEL 0
+ short fts_level; /* depth (-1 to N) */
+
+#define FTS_D 1 /* preorder directory */
+#define FTS_DC 2 /* directory that causes cycles */
+#define FTS_DEFAULT 3 /* none of the above */
+#define FTS_DNR 4 /* unreadable directory */
+#define FTS_DOT 5 /* dot or dot-dot */
+#define FTS_DP 6 /* postorder directory */
+#define FTS_ERR 7 /* error; errno is set */
+#define FTS_F 8 /* regular file */
+#define FTS_INIT 9 /* initialized only */
+#define FTS_NS 10 /* stat(2) failed */
+#define FTS_NSOK 11 /* no stat(2) requested */
+#define FTS_SL 12 /* symbolic link */
+#define FTS_SLNONE 13 /* symbolic link without target */
+#define FTS_W 14 /* whiteout object */
+ u_short fts_info; /* user flags for FTSENT structure */
+
+#define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */
+#define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */
+ u_short fts_flags; /* private flags for FTSENT structure */
+
+#define FTS_AGAIN 1 /* read node again */
+#define FTS_FOLLOW 2 /* follow symbolic link */
+#define FTS_NOINSTR 3 /* no instructions */
+#define FTS_SKIP 4 /* discard node */
+ u_short fts_instr; /* fts_set() instructions */
+
+ struct stat *fts_statp; /* stat(2) information */
+ char fts_name[1]; /* file name */
+} FTSENT;
+
+__BEGIN_DECLS
+FTSENT *fts_children (FTS *, int);
+int fts_close (FTS *);
+FTS *fts_open (char * const *, int,
+ int (*)(const FTSENT **, const FTSENT **));
+FTSENT *fts_read (FTS *);
+int fts_set (FTS *, FTSENT *, int) __THROW;
+__END_DECLS
+
+#endif /* fts.h */
diff --git a/include/ftw.h b/include/ftw.h
index 4bdff88c6..528db404d 100644
--- a/include/ftw.h
+++ b/include/ftw.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/>. */
/*
* X/Open Portability Guide 4.2: ftw.h
@@ -112,55 +111,57 @@ struct FTW
/* Convenient types for callback functions. */
-typedef int (*__ftw_func_t) (__const char *__filename,
- __const struct stat *__status, int __flag);
+typedef int (*__ftw_func_t) (const char *__filename,
+ const struct stat *__status, int __flag);
#ifdef __USE_LARGEFILE64
-typedef int (*__ftw64_func_t) (__const char *__filename,
- __const struct stat64 *__status, int __flag);
+typedef int (*__ftw64_func_t) (const char *__filename,
+ const struct stat64 *__status, int __flag);
#endif
#ifdef __USE_XOPEN_EXTENDED
-typedef int (*__nftw_func_t) (__const char *__filename,
- __const struct stat *__status, int __flag,
+typedef int (*__nftw_func_t) (const char *__filename,
+ const struct stat *__status, int __flag,
struct FTW *__info);
# ifdef __USE_LARGEFILE64
-typedef int (*__nftw64_func_t) (__const char *__filename,
- __const struct stat64 *__status,
+typedef int (*__nftw64_func_t) (const char *__filename,
+ const struct stat64 *__status,
int __flag, struct FTW *__info);
# endif
#endif
+#ifdef __UCLIBC_HAS_FTW__
/* Call a function on every element in a directory tree.
This function is a possible cancellation point and therefore not
marked with __THROW. */
-#ifndef __USE_FILE_OFFSET64
-extern int ftw (__const char *__dir, __ftw_func_t __func, int __descriptors)
+# ifndef __USE_FILE_OFFSET64
+extern int ftw (const char *__dir, __ftw_func_t __func, int __descriptors)
__nonnull ((1, 2));
-#else
-# ifdef __REDIRECT
-extern int __REDIRECT (ftw, (__const char *__dir, __ftw_func_t __func,
- int __descriptors), ftw64) __nonnull ((1, 2));
# else
-# define ftw ftw64
+# ifdef __REDIRECT
+extern int __REDIRECT (ftw, (const char *__dir, __ftw_func_t __func,
+ int __descriptors), ftw64) __nonnull ((1, 2));
+# else
+# define ftw ftw64
+# endif
# endif
-#endif
-#ifdef __USE_LARGEFILE64
-extern int ftw64 (__const char *__dir, __ftw64_func_t __func,
+# ifdef __USE_LARGEFILE64
+extern int ftw64 (const char *__dir, __ftw64_func_t __func,
int __descriptors) __nonnull ((1, 2));
+# endif
#endif
-#ifdef __USE_XOPEN_EXTENDED
+#if defined __UCLIBC_HAS_NFTW__ && defined __USE_XOPEN_EXTENDED
/* Call a function on every element in a directory tree. FLAG allows
to specify the behaviour more detailed.
This function is a possible cancellation point and therefore not
marked with __THROW. */
# ifndef __USE_FILE_OFFSET64
-extern int nftw (__const char *__dir, __nftw_func_t __func, int __descriptors,
+extern int nftw (const char *__dir, __nftw_func_t __func, int __descriptors,
int __flag) __nonnull ((1, 2));
# else
# ifdef __REDIRECT
-extern int __REDIRECT (nftw, (__const char *__dir, __nftw_func_t __func,
+extern int __REDIRECT (nftw, (const char *__dir, __nftw_func_t __func,
int __descriptors, int __flag), nftw64)
__nonnull ((1, 2));
# else
@@ -168,7 +169,7 @@ extern int __REDIRECT (nftw, (__const char *__dir, __nftw_func_t __func,
# endif
# endif
# ifdef __USE_LARGEFILE64
-extern int nftw64 (__const char *__dir, __nftw64_func_t __func,
+extern int nftw64 (const char *__dir, __nftw64_func_t __func,
int __descriptors, int __flag) __nonnull ((1, 2));
# endif
#endif
diff --git a/include/getopt.h b/include/getopt.h
index a682f9ca8..de9da2686 100644
--- a/include/getopt.h
+++ b/include/getopt.h
@@ -1,4 +1,4 @@
-/* This file will not be installed if not using gnu getopt. */
+/* This file will not be installed if not using getopt_long. */
#include <bits/getopt.h>
diff --git a/include/glob.h b/include/glob.h
index 68ea2cb9c..6d712e56d 100644
--- a/include/glob.h
+++ b/include/glob.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 _GLOB_H
#define _GLOB_H 1
@@ -110,13 +109,13 @@ typedef struct
#else
void *(*gl_readdir) (void *);
#endif
- void *(*gl_opendir) (__const char *);
+ void *(*gl_opendir) (const char *);
#ifdef __USE_GNU
- int (*gl_lstat) (__const char *__restrict, struct stat *__restrict);
- int (*gl_stat) (__const char *__restrict, struct stat *__restrict);
+ int (*gl_lstat) (const char *__restrict, struct stat *__restrict);
+ int (*gl_stat) (const char *__restrict, struct stat *__restrict);
#else
- int (*gl_lstat) (__const char *__restrict, void *__restrict);
- int (*gl_stat) (__const char *__restrict, void *__restrict);
+ int (*gl_lstat) (const char *__restrict, void *__restrict);
+ int (*gl_stat) (const char *__restrict, void *__restrict);
#endif
#endif
#endif /* __UCLIBC_HAS_GNU_GLOB__ */
@@ -143,13 +142,13 @@ typedef struct
# else
void *(*gl_readdir) (void *);
# endif
- void *(*gl_opendir) (__const char *);
+ void *(*gl_opendir) (const char *);
# ifdef __USE_GNU
- int (*gl_lstat) (__const char *__restrict, struct stat64 *__restrict);
- int (*gl_stat) (__const char *__restrict, struct stat64 *__restrict);
+ int (*gl_lstat) (const char *__restrict, struct stat64 *__restrict);
+ int (*gl_stat) (const char *__restrict, struct stat64 *__restrict);
# else
- int (*gl_lstat) (__const char *__restrict, void *__restrict);
- int (*gl_stat) (__const char *__restrict, void *__restrict);
+ int (*gl_lstat) (const char *__restrict, void *__restrict);
+ int (*gl_stat) (const char *__restrict, void *__restrict);
# endif
#endif
#endif /* __UCLIBC_HAS_GNU_GLOB__ */
@@ -170,27 +169,31 @@ typedef struct
If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned.
Otherwise, `glob' returns zero. */
#if !defined __USE_FILE_OFFSET64 || __GNUC__ < 2
-extern int glob (__const char *__restrict __pattern, int __flags,
- int (*__errfunc) (__const char *, int),
+extern int glob (const char *__restrict __pattern, int __flags,
+ int (*__errfunc) (const char *, int),
glob_t *__restrict __pglob) __THROW;
+libc_hidden_proto(glob)
/* Free storage allocated in PGLOB by a previous `glob' call. */
extern void globfree (glob_t *__pglob) __THROW;
+libc_hidden_proto(globfree)
#else
-extern int __REDIRECT_NTH (glob, (__const char *__restrict __pattern,
+extern int __REDIRECT_NTH (glob, (const char *__restrict __pattern,
int __flags,
- int (*__errfunc) (__const char *, int),
+ int (*__errfunc) (const char *, int),
glob_t *__restrict __pglob), glob64);
extern void __REDIRECT_NTH (globfree, (glob_t *__pglob), globfree64);
#endif
#ifdef __USE_LARGEFILE64
-extern int glob64 (__const char *__restrict __pattern, int __flags,
- int (*__errfunc) (__const char *, int),
+extern int glob64 (const char *__restrict __pattern, int __flags,
+ int (*__errfunc) (const char *, int),
glob64_t *__restrict __pglob) __THROW;
+libc_hidden_proto(glob64)
extern void globfree64 (glob64_t *__pglob) __THROW;
+libc_hidden_proto(globfree64)
#endif
@@ -200,7 +203,8 @@ extern void globfree64 (glob64_t *__pglob) __THROW;
This function is not part of the interface specified by POSIX.2
but several programs want to use it. */
-extern int glob_pattern_p (__const char *__pattern, int __quote) __THROW;
+extern int glob_pattern_p (const char *__pattern, int __quote) __THROW;
+libc_hidden_proto(glob_pattern_p)
#endif
__END_DECLS
diff --git a/include/gnu-versions.h b/include/gnu-versions.h
index 59e617c4b..6678c9bc0 100644
--- a/include/gnu-versions.h
+++ b/include/gnu-versions.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 _GNU_VERSIONS_H
#define _GNU_VERSIONS_H 1
@@ -44,9 +43,13 @@
remember, if any of these versions change, the libc.so major version
number must change too (so avoid it)! */
+#ifdef __UCLIBC_HAS_OBSTACK__
#define _GNU_OBSTACK_INTERFACE_VERSION 1 /* vs malloc/obstack.c */
+#endif
#define _GNU_REGEX_INTERFACE_VERSION 1 /* vs posix/regex.c */
+#ifdef __UCLIBC_HAS_GNU_GLOB__
#define _GNU_GLOB_INTERFACE_VERSION 1 /* vs posix/glob.c */
+#endif
#define _GNU_GETOPT_INTERFACE_VERSION 2 /* vs posix/getopt.c and
posix/getopt1.c */
diff --git a/include/grp.h b/include/grp.h
index 6ad8be1dd..676100eb0 100644
--- a/include/grp.h
+++ b/include/grp.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: 9.2.1 Group Database Access <grp.h>
@@ -92,7 +91,7 @@ extern struct group *fgetgrent (FILE *__stream);
cancellation point. But due to similarity with an POSIX interface
or due to the implementation it is a cancellation point and
therefore not marked with __THROW. */
-extern int putgrent (__const struct group *__restrict __p,
+extern int putgrent (const struct group *__restrict __p,
FILE *__restrict __f);
#endif
@@ -106,7 +105,7 @@ extern struct group *getgrgid (__gid_t __gid);
This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern struct group *getgrnam (__const char *__name);
+extern struct group *getgrnam (const char *__name);
#if defined __USE_POSIX || defined __USE_MISC
@@ -133,6 +132,7 @@ extern struct group *getgrnam (__const char *__name);
extern int getgrent_r (struct group *__restrict __resultbuf,
char *__restrict __buffer, size_t __buflen,
struct group **__restrict __result);
+libc_hidden_proto(getgrent_r)
# endif
/* Search for an entry with a matching group ID.
@@ -142,15 +142,17 @@ extern int getgrent_r (struct group *__restrict __resultbuf,
extern int getgrgid_r (__gid_t __gid, struct group *__restrict __resultbuf,
char *__restrict __buffer, size_t __buflen,
struct group **__restrict __result);
+libc_hidden_proto(getgrgid_r)
/* Search for an entry with a matching group name.
This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern int getgrnam_r (__const char *__restrict __name,
+extern int getgrnam_r (const char *__restrict __name,
struct group *__restrict __resultbuf,
char *__restrict __buffer, size_t __buflen,
struct group **__restrict __result);
+libc_hidden_proto(getgrnam_r)
# ifdef __USE_SVID
/* Read a group entry from STREAM. This function is not standardized
@@ -164,32 +166,37 @@ extern int fgetgrent_r (FILE *__restrict __stream,
struct group *__restrict __resultbuf,
char *__restrict __buffer, size_t __buflen,
struct group **__restrict __result);
+libc_hidden_proto(fgetgrent_r)
# endif
#endif /* POSIX or reentrant */
-#ifdef __USE_BSD
+#if defined __USE_BSD || defined __USE_GNU
# define __need_size_t
# include <stddef.h>
-/* Set the group set for the current user to GROUPS (N of them). */
-extern int setgroups (size_t __n, __const __gid_t *__groups) __THROW;
-
-#if 0
/* Store at most *NGROUPS members of the group set for USER into
*GROUPS. Also include GROUP. The actual number of groups found is
returned in *NGROUPS. Return -1 if the if *NGROUPS is too small.
+ In all cases the actual number of groups is stored in *NGROUPS.
This function is not part of POSIX and therefore no official
cancellation point. But due to similarity with an POSIX interface
or due to the implementation it is a cancellation point and
therefore not marked with __THROW. */
-extern int getgrouplist (__const char *__user, __gid_t __group,
+extern int getgrouplist (const char *__user, __gid_t __group,
__gid_t *__groups, int *__ngroups);
+
#endif
+#if defined __USE_BSD
+
+/* Set the group set for the current user to GROUPS (N of them). */
+extern int setgroups (size_t __n, const __gid_t *__groups) __THROW;
+libc_hidden_proto(setgroups)
+
/* Initialize the group set for the current user
by reading the group database and using all groups
of which USER is a member. Also include GROUP.
@@ -198,7 +205,7 @@ extern int getgrouplist (__const char *__user, __gid_t __group,
cancellation point. But due to similarity with an POSIX interface
or due to the implementation it is a cancellation point and
therefore not marked with __THROW. */
-extern int initgroups (__const char *__user, __gid_t __group);
+extern int initgroups (const char *__user, __gid_t __group);
#endif /* Use BSD. */
diff --git a/include/iconv.h b/include/iconv.h
index 0a19c049d..5ab4c6cb9 100644
--- a/include/iconv.h
+++ b/include/iconv.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 _ICONV_H
#define _ICONV_H 1
@@ -37,9 +36,9 @@ typedef void *iconv_t;
/* Allocate descriptor for code conversion from codeset FROMCODE to
codeset TOCODE.
- This function is a possible cancellation points and therefore not
+ This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern iconv_t iconv_open (__const char *__tocode, __const char *__fromcode);
+extern iconv_t iconv_open (const char *__tocode, const char *__fromcode);
/* Convert at most *INBYTESLEFT bytes from *INBUF according to the
code conversion algorithm specified by CD and place up to
@@ -51,7 +50,7 @@ extern size_t iconv (iconv_t __cd, char **__restrict __inbuf,
/* Free resources allocated for descriptor CD for code conversion.
- This function is a possible cancellation points and therefore not
+ This function is a possible cancellation point and therefore not
marked with __THROW. */
extern int iconv_close (iconv_t __cd);
diff --git a/include/ieee754.h b/include/ieee754.h
index 7131e5de6..43c1a1a56 100644
--- a/include/ieee754.h
+++ b/include/ieee754.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 _IEEE754_H
@@ -80,7 +79,7 @@ union ieee754_double
unsigned int mantissa1:32;
#endif /* Big endian. */
#if __BYTE_ORDER == __LITTLE_ENDIAN
-# if __FLOAT_WORD_ORDER == BIG_ENDIAN
+# if __FLOAT_WORD_ORDER == __BIG_ENDIAN
unsigned int mantissa0:20;
unsigned int exponent:11;
unsigned int negative:1;
@@ -106,7 +105,7 @@ union ieee754_double
unsigned int mantissa0:19;
unsigned int mantissa1:32;
#else
-# if __FLOAT_WORD_ORDER == BIG_ENDIAN
+# if __FLOAT_WORD_ORDER == __BIG_ENDIAN
unsigned int mantissa0:19;
unsigned int quiet_nan:1;
unsigned int exponent:11;
@@ -142,7 +141,7 @@ union ieee854_long_double
unsigned int mantissa1:32;
#endif
#if __BYTE_ORDER == __LITTLE_ENDIAN
-# if __FLOAT_WORD_ORDER == BIG_ENDIAN
+# if __FLOAT_WORD_ORDER == __BIG_ENDIAN
unsigned int exponent:15;
unsigned int negative:1;
unsigned int empty:16;
@@ -171,7 +170,7 @@ union ieee854_long_double
unsigned int mantissa1:32;
#endif
#if __BYTE_ORDER == __LITTLE_ENDIAN
-# if __FLOAT_WORD_ORDER == BIG_ENDIAN
+# if __FLOAT_WORD_ORDER == __BIG_ENDIAN
unsigned int exponent:15;
unsigned int negative:1;
unsigned int empty:16;
diff --git a/include/ifaddrs.h b/include/ifaddrs.h
index ba6a1554b..0de7f5d9a 100644
--- a/include/ifaddrs.h
+++ b/include/ifaddrs.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 _IFADDRS_H
#define _IFADDRS_H 1
@@ -65,9 +64,11 @@ struct ifaddrs
The storage returned in *IFAP is allocated dynamically and can
only be properly freed by passing it to `freeifaddrs'. */
extern int getifaddrs (struct ifaddrs **__ifap) __THROW;
+libc_hidden_proto(getifaddrs)
/* Reclaim the storage allocated by a previous `getifaddrs' call. */
extern void freeifaddrs (struct ifaddrs *__ifa) __THROW;
+libc_hidden_proto(freeifaddrs)
__END_DECLS
diff --git a/include/internal/parse_config.h b/include/internal/parse_config.h
new file mode 100644
index 000000000..ebfb87e5f
--- /dev/null
+++ b/include/internal/parse_config.h
@@ -0,0 +1,57 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * config file parser helper
+ *
+ * Copyright (C) 2008 by Vladimir Dronnikov <dronnikov@gmail.com>
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Also for use in uClibc (http://uclibc.org/) licensed under LGPLv2.1 or later.
+ */
+#ifndef __INTERNAL_PARSE_CONFIG_H
+#define __INTERNAL_PARSE_CONFIG_H
+
+#include <stdio.h>
+#ifndef FAST_FUNC
+# define FAST_FUNC
+#endif
+
+/*
+ * Config file parser
+ */
+enum {
+ PARSE_COLLAPSE = 0x00010000, /* treat consecutive delimiters as one */
+ PARSE_TRIM = 0x00020000, /* trim leading and trailing delimiters */
+/* TODO: COLLAPSE and TRIM seem to always go in pair */
+ PARSE_GREEDY = 0x00040000, /* last token takes entire remainder of the line */
+ PARSE_MIN_DIE = 0x00100000, /* die if < min tokens found */
+ /* keep a copy of current line */
+ PARSE_KEEP_COPY = 0x00200000 * 0, /*ENABLE_FEATURE_CROND_D, */
+/* PARSE_ESCAPE = 0x00400000,*/ /* process escape sequences in tokens */
+ /* NORMAL is:
+ * remove leading and trailing delimiters and collapse
+ multiple delimiters into one
+ * warn and continue if less than mintokens delimiters found
+ * grab everything into last token
+ */
+ PARSE_NORMAL = PARSE_COLLAPSE | PARSE_TRIM | PARSE_GREEDY,
+};
+
+typedef struct parser_t {
+ FILE *fp; /* input file */
+ char *data; /* pointer to data */
+ size_t data_len; /* offset into data of begin of line */
+ char *line; /* pointer to beginning of line */
+ size_t line_len; /* length of line */
+ smalluint allocated;
+} parser_t;
+
+parser_t* config_open(const char *filename) FAST_FUNC attribute_hidden;
+libc_hidden_proto(config_open)
+int config_read(parser_t *parser, char ***tokens, unsigned flags, const char *delims) FAST_FUNC attribute_hidden;
+libc_hidden_proto(config_read)
+#define config_read(parser, tokens, max, min, str, flags) \
+ config_read(parser, tokens, ((flags) | (((min) & 0xFF) << 8) | ((max) & 0xFF)), str)
+void config_close(parser_t *parser) FAST_FUNC attribute_hidden;
+libc_hidden_proto(config_close)
+
+#endif /* __INTERNAL_PARSE_CONFIG_H */
diff --git a/include/internal/utmp.h b/include/internal/utmp.h
new file mode 100644
index 000000000..49f96b4d8
--- /dev/null
+++ b/include/internal/utmp.h
@@ -0,0 +1,92 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * internal helper for utmp and utmpx handling
+ *
+ * Copyright (C) 2015 by Bernhard Reutner-Fischer
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ */
+#ifndef __INTERNAL_UTMP_H
+#define __INTERNAL_UTMP_H
+
+#include <utmpx.h>
+#include <utmp.h>
+
+/* Note: _PATH_UTMPX == _PATH_UTMP */
+
+#if (defined __UCLIBC_HAS_UTMPX__ && defined __UCLIBC_HAS_UTMP__) \
+ || !defined __UCLIBC_HAS_UTMP__
+/* implement the X and alias the non-X */
+# define __set_unlocked __setutxent_unlocked
+# define set setutxent
+# define __get_unlocked __getutxent_unlocked
+# define get getutxent
+# define end endutxent
+# define __getid_unlocked __getutxid_unlocked
+# define getid getutxid
+# define getline getutxline
+# define putline pututxline
+# define name utmpxname
+# define updw updwtmpx
+# define UT utmpx
+# ifndef __DEFAULT_PATH_UTMP
+# define __DEFAULT_PATH_UTMP _PATH_UTMPX
+# endif
+# if defined __UCLIBC_HAS_UTMP__
+# define other(n,a) strong_alias_untyped(n,a)
+# else
+# define other(n,a) /* nothing */
+# endif
+#elif defined __UCLIBC_HAS_UTMP__
+# define __set_unlocked __setutent_unlocked
+# define set setutent
+# define __get_unlocked __getutent_unlocked
+# define get getutent
+# define end endutent
+# define __getid_unlocked __getutid_unlocked
+# define getid getutid
+# define getline getutline
+# define putline pututline
+# define name utmpname
+# define updw updwtmp
+# define UT utmp
+# ifndef __DEFAULT_PATH_UTMP
+# define __DEFAULT_PATH_UTMP _PATH_UTMP
+# endif
+# define other(n,a) /* nothing */
+#else
+#error You are supposed to either have UTMP or UTMPX or both here
+#endif
+
+/* not used in libc_hidden_proto(setutxent) */
+/* not used in libc_hidden_proto(endutxent) */
+/* not used in libc_hidden_proto(getutxent) */
+/* not used in libc_hidden_proto(getutxid) */
+/* not used in libc_hidden_proto(getutxline) */
+/* not used in libc_hidden_proto(pututxline) */
+/* not used in libc_hidden_proto(utmpxname) */
+/* not used in libc_hidden_proto(updwtmpx) */
+
+/* not used in libc_hidden_proto(setutent) */
+/* not used in libc_hidden_proto(endutent) */
+/* not used in libc_hidden_proto(getutent) */
+/* not used in libc_hidden_proto(getutid) */
+/* not used in libc_hidden_proto(getutline) */
+/* not used in libc_hidden_proto(pututline) */
+/* not used in libc_hidden_proto(utmpname) */
+/* not used in libc_hidden_proto(updwtmp) */
+
+#ifdef IS_IN_libutil
+# if (defined __UCLIBC_HAS_UTMPX__ && defined __UCLIBC_HAS_UTMP__) \
+ || !defined __UCLIBC_HAS_UTMP__
+ /* monkey-patch to use the POSIX interface */
+# define setutent setutxent
+# define getutline getutxline
+# define pututline pututxline
+# define endutent endutxent
+# define updwtmp updwtmpx
+# endif
+#endif /* IS_IN_libutil */
+
+#endif /* __INTERNAL_UTMP_H */
+
diff --git a/include/inttypes.h b/include/inttypes.h
index b1d4302a2..fa6339869 100644
--- a/include/inttypes.h
+++ b/include/inttypes.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1997-2001, 2004, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -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.8 Format conversion of integer types <inttypes.h>
@@ -70,8 +69,8 @@ typedef wchar_t __gwchar_t;
# define PRIdLEAST64 __PRI64_PREFIX "d"
# define PRIdFAST8 "d"
-# define PRIdFAST16 "d"
-# define PRIdFAST32 "d"
+# define PRIdFAST16 __PRIPTR_PREFIX "d"
+# define PRIdFAST32 __PRIPTR_PREFIX "d"
# define PRIdFAST64 __PRI64_PREFIX "d"
@@ -86,8 +85,8 @@ typedef wchar_t __gwchar_t;
# define PRIiLEAST64 __PRI64_PREFIX "i"
# define PRIiFAST8 "i"
-# define PRIiFAST16 "i"
-# define PRIiFAST32 "i"
+# define PRIiFAST16 __PRIPTR_PREFIX "i"
+# define PRIiFAST32 __PRIPTR_PREFIX "i"
# define PRIiFAST64 __PRI64_PREFIX "i"
/* Octal notation. */
@@ -102,8 +101,8 @@ typedef wchar_t __gwchar_t;
# define PRIoLEAST64 __PRI64_PREFIX "o"
# define PRIoFAST8 "o"
-# define PRIoFAST16 "o"
-# define PRIoFAST32 "o"
+# define PRIoFAST16 __PRIPTR_PREFIX "o"
+# define PRIoFAST32 __PRIPTR_PREFIX "o"
# define PRIoFAST64 __PRI64_PREFIX "o"
/* Unsigned integers. */
@@ -118,8 +117,8 @@ typedef wchar_t __gwchar_t;
# define PRIuLEAST64 __PRI64_PREFIX "u"
# define PRIuFAST8 "u"
-# define PRIuFAST16 "u"
-# define PRIuFAST32 "u"
+# define PRIuFAST16 __PRIPTR_PREFIX "u"
+# define PRIuFAST32 __PRIPTR_PREFIX "u"
# define PRIuFAST64 __PRI64_PREFIX "u"
/* lowercase hexadecimal notation. */
@@ -134,8 +133,8 @@ typedef wchar_t __gwchar_t;
# define PRIxLEAST64 __PRI64_PREFIX "x"
# define PRIxFAST8 "x"
-# define PRIxFAST16 "x"
-# define PRIxFAST32 "x"
+# define PRIxFAST16 __PRIPTR_PREFIX "x"
+# define PRIxFAST32 __PRIPTR_PREFIX "x"
# define PRIxFAST64 __PRI64_PREFIX "x"
/* UPPERCASE hexadecimal notation. */
@@ -150,8 +149,8 @@ typedef wchar_t __gwchar_t;
# define PRIXLEAST64 __PRI64_PREFIX "X"
# define PRIXFAST8 "X"
-# define PRIXFAST16 "X"
-# define PRIXFAST32 "X"
+# define PRIXFAST16 __PRIPTR_PREFIX "X"
+# define PRIXFAST32 __PRIPTR_PREFIX "X"
# define PRIXFAST64 __PRI64_PREFIX "X"
@@ -304,25 +303,145 @@ extern imaxdiv_t imaxdiv (intmax_t __numer, intmax_t __denom)
__THROW __attribute__ ((__const__));
/* Like `strtol' but convert to `intmax_t'. */
-extern intmax_t strtoimax (__const char *__restrict __nptr,
+extern intmax_t strtoimax (const char *__restrict __nptr,
char **__restrict __endptr, int __base) __THROW;
/* Like `strtoul' but convert to `uintmax_t'. */
-extern uintmax_t strtoumax (__const char *__restrict __nptr,
+extern uintmax_t strtoumax (const char *__restrict __nptr,
char ** __restrict __endptr, int __base) __THROW;
-#if defined __UCLIBC_HAS_WCHAR__ && __UCLIBC_HAS_WCHAR__
+#ifdef __UCLIBC_HAS_WCHAR__
/* Like `wcstol' but convert to `intmax_t'. */
-extern intmax_t wcstoimax (__const __gwchar_t *__restrict __nptr,
+extern intmax_t wcstoimax (const __gwchar_t *__restrict __nptr,
__gwchar_t **__restrict __endptr, int __base)
__THROW;
/* Like `wcstoul' but convert to `uintmax_t'. */
-extern uintmax_t wcstoumax (__const __gwchar_t *__restrict __nptr,
+extern uintmax_t wcstoumax (const __gwchar_t *__restrict __nptr,
__gwchar_t ** __restrict __endptr, int __base)
__THROW;
#endif
+#if 0 /*def __USE_EXTERN_INLINES*/
+
+# if __WORDSIZE == 64
+
+extern long int __strtol_internal (const char *__restrict __nptr,
+ char **__restrict __endptr,
+ int __base, int __group)
+ __THROW __nonnull ((1)) __wur;
+/* Like `strtol' but convert to `intmax_t'. */
+__extern_inline intmax_t
+__NTH (strtoimax (const char *__restrict nptr, char **__restrict endptr,
+ int base))
+{
+ return __strtol_internal (nptr, endptr, base, 0);
+}
+
+extern unsigned long int __strtoul_internal (const char *
+ __restrict __nptr,
+ char ** __restrict __endptr,
+ int __base, int __group)
+ __THROW __nonnull ((1)) __wur;
+/* Like `strtoul' but convert to `uintmax_t'. */
+__extern_inline uintmax_t
+__NTH (strtoumax (const char *__restrict nptr, char **__restrict endptr,
+ int base))
+{
+ return __strtoul_internal (nptr, endptr, base, 0);
+}
+
+extern long int __wcstol_internal (const __gwchar_t * __restrict __nptr,
+ __gwchar_t **__restrict __endptr,
+ int __base, int __group)
+ __THROW __nonnull ((1)) __wur;
+/* Like `wcstol' but convert to `intmax_t'. */
+__extern_inline intmax_t
+__NTH (wcstoimax (const __gwchar_t *__restrict nptr,
+ __gwchar_t **__restrict endptr, int base))
+{
+ return __wcstol_internal (nptr, endptr, base, 0);
+}
+
+extern unsigned long int __wcstoul_internal (const __gwchar_t *
+ __restrict __nptr,
+ __gwchar_t **
+ __restrict __endptr,
+ int __base, int __group)
+ __THROW __nonnull ((1)) __wur;
+/* Like `wcstoul' but convert to `uintmax_t'. */
+__extern_inline uintmax_t
+__NTH (wcstoumax (const __gwchar_t *__restrict nptr,
+ __gwchar_t **__restrict endptr, int base))
+{
+ return __wcstoul_internal (nptr, endptr, base, 0);
+}
+
+# else /* __WORDSIZE == 32 */
+
+__extension__
+extern long long int __strtoll_internal (const char *__restrict __nptr,
+ char **__restrict __endptr,
+ int __base, int __group)
+ __THROW __nonnull ((1)) __wur;
+/* Like `strtol' but convert to `intmax_t'. */
+__extern_inline intmax_t
+__NTH (strtoimax (const char *__restrict nptr, char **__restrict endptr,
+ int base))
+{
+ return __strtoll_internal (nptr, endptr, base, 0);
+}
+
+__extension__
+extern unsigned long long int __strtoull_internal (const char *
+ __restrict __nptr,
+ char **
+ __restrict __endptr,
+ int __base,
+ int __group)
+ __THROW __nonnull ((1)) __wur;
+/* Like `strtoul' but convert to `uintmax_t'. */
+__extern_inline uintmax_t
+__NTH (strtoumax (const char *__restrict nptr, char **__restrict endptr,
+ int base))
+{
+ return __strtoull_internal (nptr, endptr, base, 0);
+}
+
+__extension__
+extern long long int __wcstoll_internal (const __gwchar_t *
+ __restrict __nptr,
+ __gwchar_t **__restrict __endptr,
+ int __base, int __group)
+ __THROW __nonnull ((1)) __wur;
+/* Like `wcstol' but convert to `intmax_t'. */
+__extern_inline intmax_t
+__NTH (wcstoimax (const __gwchar_t *__restrict nptr,
+ __gwchar_t **__restrict endptr, int base))
+{
+ return __wcstoll_internal (nptr, endptr, base, 0);
+}
+
+
+__extension__
+extern unsigned long long int __wcstoull_internal (const __gwchar_t *
+ __restrict __nptr,
+ __gwchar_t **
+ __restrict __endptr,
+ int __base,
+ int __group)
+ __THROW __nonnull ((1)) __wur;
+/* Like `wcstoul' but convert to `uintmax_t'. */
+__extern_inline uintmax_t
+__NTH (wcstoumax (const __gwchar_t *__restrict nptr,
+ __gwchar_t **__restrict endptr, int base))
+{
+ return __wcstoull_internal (nptr, endptr, base, 0);
+}
+
+# endif /* __WORDSIZE == 32 */
+#endif /* Use extern inlines. */
+
__END_DECLS
#endif /* inttypes.h */
diff --git a/include/langinfo.h b/include/langinfo.h
index 12f008046..94a4d7e75 100644
--- a/include/langinfo.h
+++ b/include/langinfo.h
@@ -1,5 +1,5 @@
/* Access to locale-dependent parameters.
- Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1995-2002,2003,2004,2005,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 _LANGINFO_H
#define _LANGINFO_H 1
@@ -32,13 +31,20 @@ __BEGIN_DECLS
(LC_*) and an item index within the category. Some code may depend on
the item values within a category increasing monotonically with the
indices. */
+#if 0
+#define _NL_ITEM(category, index) (((category) << 16) | (index))
+
+/* Extract the category and item index from a constructed `nl_item' value. */
+#define _NL_ITEM_CATEGORY(item) ((int) (item) >> 16)
+#define _NL_ITEM_INDEX(item) ((int) (item) & 0xffff)
+#else
#define _NL_ITEM(category, index) \
(((category) << __NL_ITEM_CATEGORY_SHIFT) | (index))
/* Extract the category and item index from a constructed `nl_item' value. */
#define _NL_ITEM_CATEGORY(item) ((int) (item) >> __NL_ITEM_CATEGORY_SHIFT)
#define _NL_ITEM_INDEX(item) ((int) (item) & __NL_ITEM_INDEX_MASK)
-
+#endif
/* Enumeration of locale items that can be queried with `nl_langinfo'. */
enum
@@ -312,6 +318,9 @@ enum
_NL_CTYPE_INDIGITS8_WC,
_NL_CTYPE_INDIGITS9_WC,
_NL_CTYPE_OUTDIGIT0_MB,
+#else
+ _NL_CTYPE_OUTDIGIT0_MB = _NL_ITEM (__LC_CTYPE, 0),
+#endif
_NL_CTYPE_OUTDIGIT1_MB,
_NL_CTYPE_OUTDIGIT2_MB,
_NL_CTYPE_OUTDIGIT3_MB,
@@ -321,6 +330,7 @@ enum
_NL_CTYPE_OUTDIGIT7_MB,
_NL_CTYPE_OUTDIGIT8_MB,
_NL_CTYPE_OUTDIGIT9_MB,
+#if 0
_NL_CTYPE_OUTDIGIT0_WC,
_NL_CTYPE_OUTDIGIT1_WC,
_NL_CTYPE_OUTDIGIT2_WC,
@@ -340,6 +350,8 @@ enum
_NL_CTYPE_TRANSLIT_DEFAULT_MISSING,
_NL_CTYPE_TRANSLIT_IGNORE_LEN,
_NL_CTYPE_TRANSLIT_IGNORE,
+ _NL_CTYPE_MAP_TO_NONASCII,
+ _NL_CTYPE_NONASCII_CASE,
_NL_CTYPE_EXTRA_MAP_1,
_NL_CTYPE_EXTRA_MAP_2,
_NL_CTYPE_EXTRA_MAP_3,
@@ -354,17 +366,7 @@ enum
_NL_CTYPE_EXTRA_MAP_12,
_NL_CTYPE_EXTRA_MAP_13,
_NL_CTYPE_EXTRA_MAP_14,
-#else /* 0 */
- _NL_CTYPE_OUTDIGIT0_MB = _NL_ITEM (__LC_CTYPE, 0),
- _NL_CTYPE_OUTDIGIT1_MB,
- _NL_CTYPE_OUTDIGIT2_MB,
- _NL_CTYPE_OUTDIGIT3_MB,
- _NL_CTYPE_OUTDIGIT4_MB,
- _NL_CTYPE_OUTDIGIT5_MB,
- _NL_CTYPE_OUTDIGIT6_MB,
- _NL_CTYPE_OUTDIGIT7_MB,
- _NL_CTYPE_OUTDIGIT8_MB,
- _NL_CTYPE_OUTDIGIT9_MB,
+#else /* 0 */
_NL_CTYPE_CODESET_NAME, /* uClibc note: MUST BE LAST ENTRY!!! */
CODESET = _NL_CTYPE_CODESET_NAME,
#define CODESET CODESET
@@ -434,6 +436,10 @@ enum
#ifdef __USE_GNU
# define N_SIGN_POSN __N_SIGN_POSN
#endif
+#if 0 /* moved below for some reason on uClibc */
+ _NL_MONETARY_CRNCYSTR,
+#define CRNCYSTR _NL_MONETARY_CRNCYSTR
+#endif
__INT_P_CS_PRECEDES,
#ifdef __USE_GNU
# define INT_P_CS_PRECEDES __INT_P_CS_PRECEDES
@@ -458,10 +464,10 @@ enum
#ifdef __USE_GNU
# define INT_N_SIGN_POSN __INT_N_SIGN_POSN
#endif
-
+#if 1 /* moved here from above */
_NL_MONETARY_CRNCYSTR,
#define CRNCYSTR _NL_MONETARY_CRNCYSTR
-
+#endif
#if 0
_NL_MONETARY_DUO_INT_CURR_SYMBOL,
_NL_MONETARY_DUO_CURRENCY_SYMBOL,
@@ -591,10 +597,18 @@ enum
_NL_IDENTIFICATION_CODESET,
_NL_NUM_LC_IDENTIFICATION,
#endif
+
/* This marks the highest value used. */
_NL_NUM
};
+/* This macro produces an item you can pass to `nl_langinfo' or
+ `nl_langinfo_l' to get the name of the locale in use for CATEGORY. */
+#define _NL_LOCALE_NAME(category) _NL_ITEM ((category), -1)
+#ifdef __USE_GNU
+# define NL_LOCALE_NAME(category) _NL_LOCALE_NAME (category)
+#endif
+
/* Return the current locale's value for ITEM.
If ITEM is invalid, an empty string is returned.
@@ -603,10 +617,10 @@ enum
it is usually in read-only memory and cannot be modified. */
extern char *nl_langinfo (nl_item __item) __THROW;
+libc_hidden_proto(nl_langinfo)
-#ifdef __UCLIBC_HAS_XLOCALE__
-#ifdef __USE_GNU
+#if defined __USE_XOPEN2K && defined __UCLIBC_HAS_XLOCALE__
/* This interface is for the extended locale model. See <locale.h> for
more information. */
@@ -614,8 +628,8 @@ extern char *nl_langinfo (nl_item __item) __THROW;
# include <xlocale.h>
/* Just like nl_langinfo but get the information from the locale object L. */
-extern char *nl_langinfo_l (nl_item __item, __locale_t l);
-#endif
+extern char *nl_langinfo_l (nl_item __item, __locale_t __l);
+libc_hidden_proto(nl_langinfo_l)
#endif
__END_DECLS
diff --git a/include/libc-internal.h b/include/libc-internal.h
index 7b2566f74..87af07cc5 100644
--- a/include/libc-internal.h
+++ b/include/libc-internal.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 _LIBC_INTERNAL_H
#define _LIBC_INTERNAL_H 1
@@ -27,8 +26,11 @@
# define attribute_relro
#endif
-#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#ifdef __UCLIBC_HAS_TLS__
# define attribute_tls_model_ie __attribute__ ((tls_model ("initial-exec")))
+#else
+# define attribute_tls_model_ie
+# define __thread
#endif
/* Pull in things like __attribute_used__ */
@@ -44,10 +46,12 @@
# include <stddef.h>
/* sources are built w/ _GNU_SOURCE, this gets undefined */
-#ifdef __USE_GNU
-extern int __xpg_strerror_r (int __errnum, char *__buf, size_t __buflen);
-#else
+#if defined __USE_XOPEN2K && !defined __USE_GNU
extern char *__glibc_strerror_r (int __errnum, char *__buf, size_t __buflen);
+libc_hidden_proto(__glibc_strerror_r)
+#else
+extern int __xpg_strerror_r (int __errnum, char *__buf, size_t __buflen);
+libc_hidden_proto(__xpg_strerror_r)
#endif
/* #include <pthread.h> */
@@ -63,38 +67,27 @@ extern char *__glibc_strerror_r (int __errnum, char *__buf, size_t __buflen);
/* internal access to program name */
extern const char *__uclibc_progname attribute_hidden;
-# endif /* IS_IN_libc */
+# ifdef __UCLIBC_HAS_FORTIFY__
+extern void __chk_fail(void) attribute_noreturn;
+libc_hidden_proto(__chk_fail)
+# endif
-/* #include <alloca.h> */
-#include <bits/stackinfo.h>
-#if defined(_STACK_GROWS_DOWN)
-# define extend_alloca(buf, len, newlen) \
- (__typeof (buf)) ({ size_t __newlen = (newlen); \
- char *__newbuf = alloca (__newlen); \
- if (__newbuf + __newlen == (char *) buf) \
- len += __newlen; \
- else \
- len = __newlen; \
- __newbuf; })
-#elif defined(_STACK_GROWS_UP)
-# define extend_alloca(buf, len, newlen) \
- (__typeof (buf)) ({ size_t __newlen = (newlen); \
- char *__newbuf = alloca (__newlen); \
- char *__buf = (buf); \
- if (__buf + __newlen == __newbuf) \
- { \
- len += __newlen; \
- __newbuf = __buf; \
- } \
- else \
- len = __newlen; \
- __newbuf; })
-#else
-# warning unknown stack
-# define extend_alloca(buf, len, newlen) \
- alloca (((len) = (newlen)))
-#endif
+# ifdef __UCLIBC_HAS_SSP__
+extern void __stack_chk_fail(void) attribute_noreturn __cold;
+# endif
+
+# endif /* IS_IN_libc */
#endif /* __ASSEMBLER__ */
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+
+/* Some people like to build up uClibc with *-elf toolchains, so
+ * a little grease here until we drop '#ifdef __linux__' checks
+ * from our source code.
+ */
+#ifndef __linux__
+# define __linux__ 1
+#endif
+
#endif /* _LIBC_INTERNAL_H */
diff --git a/include/libc-symbols.h b/include/libc-symbols.h
index e491aff5f..fc129db5d 100644
--- a/include/libc-symbols.h
+++ b/include/libc-symbols.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 _LIBC_SYMBOLS_H
#define _LIBC_SYMBOLS_H 1
@@ -39,7 +38,6 @@
It should define for us the following symbols:
* HAVE_ASM_SET_DIRECTIVE if we have `.set B, A' instead of `A = B'.
- * ASM_GLOBAL_DIRECTIVE with `.globl' or `.global'.
* ASM_TYPE_DIRECTIVE_PREFIX with `@' or `#' or whatever for .type,
or leave it undefined if there is no .type directive.
* HAVE_ELF if using ELF, which supports weak symbols using `.weak'.
@@ -63,6 +61,21 @@
#ifndef unlikely
# define unlikely(x) __builtin_expect((!!(x)),0)
#endif
+#if defined __GNUC__ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
+# ifndef __cold
+# define __cold __attribute__ ((__cold__))
+# endif
+# ifndef __hot
+# define __hot __attribute__ ((__hot__))
+# endif
+#else
+# ifndef __cold
+# define __cold
+# endif
+# ifndef __hot
+# define __hot
+# endif
+#endif
#ifndef __LINUX_COMPILER_H
# define __LINUX_COMPILER_H
#endif
@@ -70,6 +83,12 @@
# define __cast__(_to)
#endif
+#if defined __GNUC__ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+# define attribute_optimize(x) __attribute__ ((optimize(x)))
+#else
+# define attribute_optimize(x)
+#endif
+
#define attribute_unused __attribute__ ((unused))
#if defined __GNUC__ || defined __ICC
@@ -78,22 +97,28 @@
# define attribute_noreturn
#endif
+#define libc_freeres_ptr(decl) \
+ __make_section_unallocated ("__libc_freeres_ptrs, \"aw\", %nobits") \
+ decl __attribute__ ((section ("__libc_freeres_ptrs" __sec_comment)))
+#define __libc_freeres_fn_section \
+ __attribute__ ((section ("__libc_freeres_fn")))
+
#ifndef NOT_IN_libc
# define IS_IN_libc 1
#endif
+/* Indirect stringification. Doing two levels allows
+ * the parameter to be a macro itself.
+ */
+#define __stringify_1(x...) #x
+#define __stringify(x) __stringify_1(x)
+
#ifdef __UCLIBC_HAVE_ASM_SET_DIRECTIVE__
# define HAVE_ASM_SET_DIRECTIVE
#else
# undef HAVE_ASM_SET_DIRECTIVE
#endif
-#ifdef __UCLIBC_ASM_GLOBAL_DIRECTIVE__
-# define ASM_GLOBAL_DIRECTIVE __UCLIBC_ASM_GLOBAL_DIRECTIVE__
-#else
-# define ASM_GLOBAL_DIRECTIVE .global
-#endif
-
#ifdef __UCLIBC_HAVE_ASM_WEAK_DIRECTIVE__
# define HAVE_ASM_WEAK_DIRECTIVE
#else
@@ -106,10 +131,10 @@
# undef HAVE_ASM_WEAKEXT_DIRECTIVE
#endif
-#ifdef __UCLIBC_HAVE_ASM_GLOBAL_DOT_NAME__
-# define HAVE_ASM_GLOBAL_DOT_NAME
+#ifdef __UCLIBC_HAVE_ASM_CFI_DIRECTIVES__
+# define HAVE_ASM_CFI_DIRECTIVES
#else
-# undef HAVE_ASM_GLOBAL_DOT_NAME
+# undef HAVE_ASM_CFI_DIRECTIVES
#endif
#if defined HAVE_ASM_WEAK_DIRECTIVE || defined HAVE_ASM_WEAKEXT_DIRECTIVE
@@ -131,17 +156,6 @@
# define ASM_LINE_SEP ;
#endif
-#ifdef HAVE_ASM_GLOBAL_DOT_NAME
-# ifndef C_SYMBOL_DOT_NAME
-# if defined __GNUC__ && defined __GNUC_MINOR__ \
- && (__GNUC__ << 16) + __GNUC_MINOR__ >= (3 << 16) + 1
-# define C_SYMBOL_DOT_NAME(name) .name
-# else
-# define C_SYMBOL_DOT_NAME(name) .##name
-# endif
-# endif
-#endif
-
#ifndef __ASSEMBLER__
/* GCC understands weak symbols and aliases; use its interface where
possible, instead of embedded assembly language. */
@@ -150,13 +164,19 @@
# define strong_alias(name, aliasname) _strong_alias(name, aliasname)
# define _strong_alias(name, aliasname) \
extern __typeof (name) aliasname __attribute__ ((alias (#name)));
+/* Same, but does not check for type match. Use sparingly.
+ Example: strong_alias(stat,stat64) may fail, this one works: */
+# define strong_alias_untyped(name, aliasname) \
+ _strong_alias_untyped(name, aliasname)
+# define _strong_alias_untyped(name, aliasname) \
+ extern __typeof (aliasname) aliasname __attribute__ ((alias (#name)));
+
+# ifdef HAVE_WEAK_SYMBOLS
/* This comes between the return type and function name in
a function definition to make that definition weak. */
-# define weak_function __attribute__ ((weak))
-# define weak_const_function __attribute__ ((weak, __const__))
-
-# ifdef HAVE_WEAK_SYMBOLS
+# define weak_function __attribute__ ((weak))
+# define weak_const_function __attribute__ ((weak, __const__))
/* Define ALIASNAME as a weak alias for NAME.
If weak aliases are not available, this defines a strong alias. */
@@ -170,6 +190,9 @@
# else
+# define weak_function /* empty */
+# define weak_const_function __attribute__ ((__const__))
+
# define weak_alias(name, aliasname) strong_alias(name, aliasname)
# define weak_extern(symbol) /* Nothing. */
@@ -178,81 +201,37 @@
#else /* __ASSEMBLER__ */
# ifdef HAVE_ASM_SET_DIRECTIVE
-# ifdef HAVE_ASM_GLOBAL_DOT_NAME
-# define strong_alias(original, alias) \
- ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
- .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original) ASM_LINE_SEP \
- ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
- .set C_SYMBOL_DOT_NAME (alias),C_SYMBOL_DOT_NAME (original)
-# define strong_data_alias(original, alias) \
- ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
- .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original)
-# else
-# define strong_alias(original, alias) \
- ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
- .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original)
-# define strong_data_alias(original, alias) strong_alias(original, alias)
-# endif
+# define strong_alias(original, alias) \
+ .globl C_SYMBOL_NAME(alias) ASM_LINE_SEP \
+ .set C_SYMBOL_NAME(alias),C_SYMBOL_NAME(original)
+# define strong_data_alias(original, alias) strong_alias(original, alias)
# else
-# ifdef HAVE_ASM_GLOBAL_DOT_NAME
-# define strong_alias(original, alias) \
- ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
- C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP \
- ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
- C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
-# define strong_data_alias(original, alias) \
- ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
- C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
-# else
-# define strong_alias(original, alias) \
- ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
- C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
-# define strong_data_alias(original, alias) strong_alias(original, alias)
-# endif
+# define strong_alias(original, alias) \
+ .globl C_SYMBOL_NAME(alias) ASM_LINE_SEP \
+ C_SYMBOL_NAME(alias) = C_SYMBOL_NAME(original)
+# define strong_data_alias(original, alias) strong_alias(original, alias)
# endif
-# ifdef HAVE_WEAK_SYMBOLS
-# ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
-# ifdef HAVE_ASM_GLOBAL_DOT_NAME
-# define weak_alias(original, alias) \
- .weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original) ASM_LINE_SEP \
- .weakext C_SYMBOL_DOT_NAME (alias), C_SYMBOL_DOT_NAME (original)
-# else
-# define weak_alias(original, alias) \
- .weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original)
-# endif
-# define weak_extern(symbol) \
- .weakext C_SYMBOL_NAME (symbol)
+# ifdef HAVE_WEAK_SYMBOLS
+# ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
+# define weak_alias(original, alias) \
+ .weakext C_SYMBOL_NAME(alias),C_SYMBOL_NAME(original)
+# define weak_extern(symbol) \
+ .weakext C_SYMBOL_NAME(symbol)
# else /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
# ifdef HAVE_ASM_SET_DIRECTIVE
-# ifdef HAVE_ASM_GLOBAL_DOT_NAME
-# define weak_alias(original, alias) \
- .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \
- .set C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original) ASM_LINE_SEP \
- .weak C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
- .set C_SYMBOL_DOT_NAME (alias), C_SYMBOL_DOT_NAME (original)
-# else
-# define weak_alias(original, alias) \
- .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \
- .set C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original)
-# endif
+# define weak_alias(original, alias) \
+ .weak C_SYMBOL_NAME(alias) ASM_LINE_SEP \
+ .set C_SYMBOL_NAME(alias),C_SYMBOL_NAME(original)
# else /* ! HAVE_ASM_SET_DIRECTIVE */
-# ifdef HAVE_ASM_GLOBAL_DOT_NAME
-# define weak_alias(original, alias) \
- .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \
- C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP \
- .weak C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
- C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
-# else
-# define weak_alias(original, alias) \
- .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \
- C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
-# endif
+# define weak_alias(original, alias) \
+ .weak C_SYMBOL_NAME(alias) ASM_LINE_SEP \
+ C_SYMBOL_NAME(alias) = C_SYMBOL_NAME(original)
# endif
-# define weak_extern(symbol) \
- .weak C_SYMBOL_NAME (symbol)
+# define weak_extern(symbol) \
+ .weak C_SYMBOL_NAME(symbol)
# endif /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */
@@ -264,6 +243,7 @@
#endif /* __ASSEMBLER__ */
+
/* On some platforms we can make internal function calls (i.e., calls of
functions not exported) a bit faster by using a different calling
convention. */
@@ -271,18 +251,21 @@
# define internal_function /* empty */
#endif
+
/* We want the .gnu.warning.SYMBOL section to be unallocated. */
#define __make_section_unallocated(section_string) \
__asm__ (".section " section_string "\n\t.previous");
+
/* Tacking on "\n#APP\n\t#" to the section name makes gcc put it's bogus
section attributes on what looks like a comment to the assembler. */
-#ifdef __sparc__ //HAVE_SECTION_QUOTES
+#ifdef __sparc__ /* HAVE_SECTION_QUOTES */
# define __sec_comment "\"\n#APP\n\t#\""
#else
# define __sec_comment "\n#APP\n\t#"
#endif
+
/* When a reference to SYMBOL is encountered, the linker will emit a
warning message MSG. */
#define link_warning(symbol, msg) \
@@ -296,8 +279,7 @@
#ifdef SHARED
# define INTUSE(name) name##_internal
# define INTDEF(name) strong_alias (name, name##_internal)
-# define INTVARDEF(name) \
- _INTVARDEF (name, name##_internal)
+# define INTVARDEF(name) _INTVARDEF (name, name##_internal)
# if defined HAVE_VISIBILITY_ATTRIBUTE
# define _INTVARDEF(name, aliasname) \
extern __typeof (name) aliasname __attribute__ ((alias (#name), \
@@ -316,65 +298,61 @@
# define INTVARDEF2(name, newname)
#endif
+
/* The following macros are used for PLT bypassing within libc.so
(and if needed other libraries similarly).
- First of all, you need to have the function prototyped somewhere,
- say in foo/foo.h:
-
- int foo (int __bar);
If calls to foo within libc.so should always go to foo defined in libc.so,
then in include/foo.h you add:
- libc_hidden_proto (foo)
+ int foo(int __bar);
+ libc_hidden_proto(foo)
line and after the foo function definition:
- int foo (int __bar)
- {
+ int foo(int __bar) {
return __bar;
}
- libc_hidden_def (foo)
+ libc_hidden_def(foo)
or
- int foo (int __bar)
- {
+ int foo(int __bar) {
return __bar;
}
- libc_hidden_weak (foo)
+ libc_hidden_weak(foo)
- Similarly for global data. If references to foo within libc.so should
- always go to foo defined in libc.so, then in include/foo.h you add:
+ Similarly for global data: if references to foo within libc.so
+ should always go to foo defined in libc.so, then in include/foo.h:
- libc_hidden_proto (foo)
+ extern int foo;
+ libc_hidden_proto(foo)
- line and after foo's definition:
+ and after foo's definition:
int foo = INITIAL_FOO_VALUE;
- libc_hidden_data_def (foo)
+ libc_hidden_data_def(foo)
or
int foo = INITIAL_FOO_VALUE;
- libc_hidden_data_weak (foo)
+ libc_hidden_data_weak(foo)
If foo is normally just an alias (strong or weak) to some other function,
you should use the normal strong_alias first, then add libc_hidden_def
or libc_hidden_weak:
- int baz (int __bar)
- {
+ int baz(int __bar) {
return __bar;
}
- strong_alias (baz, foo)
- libc_hidden_weak (foo)
+ strong_alias(baz, foo)
+ libc_hidden_weak(foo)
If the function should be internal to multiple objects, say ld.so and
libc.so, the best way is to use:
#if !defined NOT_IN_libc || defined IS_IN_rtld
- hidden_proto (foo)
+ hidden_proto(foo)
#endif
in include/foo.h and the normal macros at all function definitions
@@ -383,100 +361,95 @@
If versioned_symbol macro is used to define foo,
libc_hidden_ver macro should be used, as in:
- int __real_foo (int __bar)
- {
+ int __real_foo(int __bar) {
return __bar;
}
- versioned_symbol (libc, __real_foo, foo, GLIBC_2_1);
- libc_hidden_ver (__real_foo, foo) */
+ versioned_symbol(libc, __real_foo, foo, GLIBC_2_1);
+ libc_hidden_ver(__real_foo, foo)
+ */
/* uClibc specific (the above comment was copied from glibc):
- * a. when ppc64 will be supported, we need changes to support:
+ *
+ * when ppc64 will be supported, we need changes to support
* strong_data_alias (used by asm hidden_data_def)
- * b. libc_hidden_proto(foo) should be added after the header having foo's prototype
- * or after extern foo... to all source files that should use the internal version
- * of foo within libc, even to the file defining foo itself, libc_hidden_def does
- * not hide __GI_foo itself, although the name suggests it (hiding is done exclusively
- * by libc_hidden_proto). The reasoning to have it after the header w/ foo's prototype is
- * to get first the __REDIRECT from original header and then create the __GI_foo alias
- * c. no versioning support, hidden[_data]_ver are noop
- * d. hidden_def() in asm is _hidden_strong_alias (not strong_alias) */
-
-/* Arrange to hide uClibc internals */
-#if (defined __GNUC__ && \
- (defined __GNUC_MINOR__ && ( __GNUC__ >= 3 && __GNUC_MINOR__ >= 3 ) \
- || __GNUC__ >= 4)) || defined __ICC
+ *
+ * no versioning support, hidden[_data]_ver are noop
+ *
+ * hidden_def() in asm is _hidden_strong_alias (not strong_alias)
+ *
+ * libc_hidden_proto(foo) should be added after declaration
+ * in the header, or after extern foo... in all source files
+ * (this is discouraged).
+ * libc_hidden_def does not hide __GI_foo itself, although the name
+ * suggests it (hiding is done exclusively by libc_hidden_proto).
+
+FIXME! - ?
+ * The reasoning to have it after the header w/ foo's prototype is
+ * to get first the __REDIRECT from original header and then create
+ * the __GI_foo alias
+
+ * Hunt for references which still go through PLT (example for x86):
+ * build shared lib, then disassemble it and search for <xxx@plt>:
+ * $ objdump -drx libuClibc-*.so >disasm.txt
+ * $ grep -F '@plt>:' disasm.txt
+ *
+ * In uclibc, malloc/free and related functions should be called
+ * through PLT (making it possible to use alternative malloc),
+ * and possibly some __pthread_xxx functions can be called through PLT
+ * (why?). The rest should not use PLT.
+ */
+
+#if (defined __GNUC__ && defined __GNUC_MINOR__ \
+ && (( __GNUC__ >= 3 && __GNUC_MINOR__ >= 3) || __GNUC__ >= 4) \
+ ) || defined __ICC
# define attribute_hidden __attribute__ ((visibility ("hidden")))
+# define attribute_protected __attribute__ ((visibility ("protected")))
# define __hidden_proto_hiddenattr(attrs...) __attribute__ ((visibility ("hidden"), ##attrs))
#else
# define attribute_hidden
+# define attribute_protected
# define __hidden_proto_hiddenattr(attrs...)
#endif
#if /*!defined STATIC &&*/ !defined __BCC__
+
# ifndef __ASSEMBLER__
-# define hidden_proto(name, attrs...) __hidden_proto (name, __GI_##name, ##attrs)
+# define hidden_proto(name, attrs...) __hidden_proto(name, __GI_##name, ##attrs)
# define __hidden_proto(name, internal, attrs...) \
- extern __typeof (name) name __asm__ (__hidden_asmname (#internal)) \
- __hidden_proto_hiddenattr (attrs);
+ extern __typeof (name) name __asm__ (__hidden_asmname (#internal)) \
+ __hidden_proto_hiddenattr (attrs);
# define __hidden_asmname(name) __hidden_asmname1 (__USER_LABEL_PREFIX__, name)
# define __hidden_asmname1(prefix, name) __hidden_asmname2(prefix, name)
# define __hidden_asmname2(prefix, name) #prefix name
# define __hidden_ver1(local, internal, name) \
- extern __typeof (name) __EI_##name __asm__(__hidden_asmname (#internal)); \
- extern __typeof (name) __EI_##name __attribute__((alias (__hidden_asmname1 (,#local))))
+ extern __typeof (name) __EI_##name __asm__(__hidden_asmname (#internal)); \
+ extern __typeof (name) __EI_##name __attribute__((alias (__hidden_asmname1 (,#local))))
# define hidden_ver(local, name) __hidden_ver1(local, __GI_##name, name);
# define hidden_data_ver(local, name) hidden_ver(local, name)
# define hidden_def(name) __hidden_ver1(__GI_##name, name, name);
# define hidden_data_def(name) hidden_def(name)
-# define hidden_weak(name) \
+# define hidden_weak(name) \
__hidden_ver1(__GI_##name, name, name) __attribute__((weak));
# define hidden_data_weak(name) hidden_weak(name)
# else /* __ASSEMBLER__ */
-# ifdef HAVE_ASM_SET_DIRECTIVE
-# ifdef HAVE_ASM_GLOBAL_DOT_NAME
-# define _hidden_strong_alias(original, alias) \
- ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
- .hidden C_SYMBOL_NAME (alias) ASM_LINE_SEP \
- .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original) ASM_LINE_SEP \
- ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
- .hidden C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
- .set C_SYMBOL_DOT_NAME (alias),C_SYMBOL_DOT_NAME (original)
-# else
-# define _hidden_strong_alias(original, alias) \
- ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
- .hidden C_SYMBOL_NAME (alias) ASM_LINE_SEP \
- .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original)
-# endif
-# else
-# ifdef HAVE_ASM_GLOBAL_DOT_NAME
-# define _hidden_strong_alias(original, alias) \
- ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
- .hidden C_SYMBOL_NAME (alias) ASM_LINE_SEP \
- C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP \
- ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
- .hidden C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
- C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original)
-# else
-# define _hidden_strong_alias(original, alias) \
- ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \
- .hidden C_SYMBOL_NAME (alias) ASM_LINE_SEP \
- C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original)
-# endif
-# endif
-# ifdef HAVE_ASM_GLOBAL_DOT_NAME
-# define _hidden_weak_alias(original, alias) \
- .hidden C_SYMBOL_NAME (alias) ASM_LINE_SEP \
- .hidden C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \
- weak_alias(original, alias)
-# else
-# define _hidden_weak_alias(original, alias) \
- .hidden C_SYMBOL_NAME (alias) ASM_LINE_SEP \
- weak_alias(original, alias)
+# ifdef HAVE_ASM_SET_DIRECTIVE
+# define _hidden_strong_alias(original, alias) \
+ .globl C_SYMBOL_NAME(alias) ASM_LINE_SEP \
+ .hidden C_SYMBOL_NAME(alias) ASM_LINE_SEP \
+ .set C_SYMBOL_NAME(alias),C_SYMBOL_NAME(original)
+# else /* dont have .set directive */
+# define _hidden_strong_alias(original, alias) \
+ .globl C_SYMBOL_NAME(alias) ASM_LINE_SEP \
+ .hidden C_SYMBOL_NAME(alias) ASM_LINE_SEP \
+ C_SYMBOL_NAME(alias) = C_SYMBOL_NAME(original)
# endif
+# define _hidden_weak_alias(original, alias) \
+ .hidden C_SYMBOL_NAME(alias) ASM_LINE_SEP \
+ weak_alias(original, alias)
+
/* For assembly, we need to do the opposite of what we do in C:
in assembly gcc __REDIRECT stuff is not in place, so functions
are defined by its normal name and we need to create the
@@ -492,25 +465,25 @@
# define hidden_data_def(name) _hidden_strong_alias (name, __GI_##name)
# define hidden_data_weak(name) _hidden_weak_alias (name, __GI_##name)
# define hidden_data_ver(local, name) strong_data_alias (local, __GI_##name)
-# ifdef HAVE_ASM_GLOBAL_DOT_NAME
-# define HIDDEN_JUMPTARGET(name) .__GI_##name
-# else
-# define HIDDEN_JUMPTARGET(name) __GI_##name
-# endif
+# define HIDDEN_JUMPTARGET(name) __GI_##name
# endif /* __ASSEMBLER__ */
-#else /* SHARED */
+
+#else /* not SHARED */
+
# ifndef __ASSEMBLER__
# define hidden_proto(name, attrs...)
# else
# define HIDDEN_JUMPTARGET(name) name
-# endif /* Not __ASSEMBLER__ */
+# endif /* not __ASSEMBLER__ */
# define hidden_weak(name)
# define hidden_def(name)
# define hidden_ver(local, name)
# define hidden_data_weak(name)
# define hidden_data_def(name)
# define hidden_data_ver(local, name)
-#endif /* SHARED */
+
+#endif /* SHARED / not SHARED */
+
/* uClibc does not support versioning yet. */
#define versioned_symbol(lib, local, symbol, version) /* weak_alias(local, symbol) */
diff --git a/include/libgen.h b/include/libgen.h
index b25254357..0a40c43f0 100644
--- a/include/libgen.h
+++ b/include/libgen.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 _LIBGEN_H
#define _LIBGEN_H 1
diff --git a/include/libintl.h b/include/libintl.h
index ba57f1698..0cbf758ed 100644
--- a/include/libintl.h
+++ b/include/libintl.h
@@ -14,15 +14,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/>. */
#ifndef _LIBINTL_H
#define _LIBINTL_H 1
#include <features.h>
+#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
+
/* We define an additional symbol to signal that we use the GNU
implementation of gettext. */
#define __USE_GNU_GETTEXT 1
@@ -34,54 +35,49 @@
__BEGIN_DECLS
-#ifdef __UCLIBC_MJN3_ONLY__
-#warning "mjn3 FIXME: gettext has a prototype but isn't defined."
-#warning "mjn3 FIXME: __OPTIMIZE__ is never defined."
-#endif
-
/* Look up MSGID in the current default message catalog for the current
LC_MESSAGES locale. If not found, returns MSGID itself (the default
text). */
-extern char *gettext (__const char *__msgid)
+extern char *gettext (const char *__msgid)
__THROW __attribute_format_arg__ (1);
/* Look up MSGID in the DOMAINNAME message catalog for the current
LC_MESSAGES locale. */
-extern char *dgettext (__const char *__domainname, __const char *__msgid)
+extern char *dgettext (const char *__domainname, const char *__msgid)
__THROW __attribute_format_arg__ (2);
#if 0 /* uClibc: disabled */
-extern char *__dgettext (__const char *__domainname, __const char *__msgid)
+extern char *__dgettext (const char *__domainname, const char *__msgid)
__THROW __attribute_format_arg__ (2);
#endif
/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
locale. */
-extern char *dcgettext (__const char *__domainname,
- __const char *__msgid, int __category)
+extern char *dcgettext (const char *__domainname,
+ const char *__msgid, int __category)
__THROW __attribute_format_arg__ (2);
#if 0 /* uClibc: disabled */
-extern char *__dcgettext (__const char *__domainname,
- __const char *__msgid, int __category)
+extern char *__dcgettext (const char *__domainname,
+ const char *__msgid, int __category)
__THROW __attribute_format_arg__ (2);
#endif
/* Similar to `gettext' but select the plural form corresponding to the
number N. */
-extern char *ngettext (__const char *__msgid1, __const char *__msgid2,
+extern char *ngettext (const char *__msgid1, const char *__msgid2,
unsigned long int __n)
__THROW __attribute_format_arg__ (1) __attribute_format_arg__ (2);
/* Similar to `dgettext' but select the plural form corresponding to the
number N. */
-extern char *dngettext (__const char *__domainname, __const char *__msgid1,
- __const char *__msgid2, unsigned long int __n)
+extern char *dngettext (const char *__domainname, const char *__msgid1,
+ const char *__msgid2, unsigned long int __n)
__THROW __attribute_format_arg__ (2) __attribute_format_arg__ (3);
/* Similar to `dcgettext' but select the plural form corresponding to the
number N. */
-extern char *dcngettext (__const char *__domainname, __const char *__msgid1,
- __const char *__msgid2, unsigned long int __n,
+extern char *dcngettext (const char *__domainname, const char *__msgid1,
+ const char *__msgid2, unsigned long int __n,
int __category)
__THROW __attribute_format_arg__ (2) __attribute_format_arg__ (3);
@@ -89,17 +85,17 @@ extern char *dcngettext (__const char *__domainname, __const char *__msgid1,
/* Set the current default message catalog to DOMAINNAME.
If DOMAINNAME is null, return the current default.
If DOMAINNAME is "", reset to the default of "messages". */
-extern char *textdomain (__const char *__domainname) __THROW;
+extern char *textdomain (const char *__domainname) __THROW;
/* Specify that the DOMAINNAME message catalog will be found
in DIRNAME rather than in the system locale data base. */
-extern char *bindtextdomain (__const char *__domainname,
- __const char *__dirname) __THROW;
+extern char *bindtextdomain (const char *__domainname,
+ const char *__dirname) __THROW;
/* Specify the character encoding in which the messages from the
DOMAINNAME message catalog will be returned. */
-extern char *bind_textdomain_codeset (__const char *__domainname,
- __const char *__codeset) __THROW;
+extern char *bind_textdomain_codeset (const char *__domainname,
+ const char *__codeset) __THROW;
/* Optimized version of the function above. */
@@ -130,4 +126,15 @@ extern char *bind_textdomain_codeset (__const char *__domainname,
__END_DECLS
+#else
+
+#define gettext(msgid) ((const char *) (msgid))
+
+#endif /* __UCLIBC_HAS_GETTEXT_AWARENESS__ */
+
+#ifdef _LIBC
+# define _(x) gettext(x)
+# define N_(x) x
+#endif
+
#endif /* libintl.h */
diff --git a/include/limits.h b/include/limits.h
index 45cd6f253..c274dd492 100644
--- a/include/limits.h
+++ b/include/limits.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1991, 92, 96, 97, 98, 99, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1996, 1997, 1998, 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
@@ -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/>. */
/*
* ISO C99 Standard: 7.10/5.2.4.2.1 Sizes of integer types <limits.h>
@@ -122,20 +122,20 @@
#if defined __GNUC__ && !defined _GCC_LIMITS_H_
/* `_GCC_LIMITS_H_' is what GCC's file defines. */
# include_next <limits.h>
+#endif
/* The <limits.h> files in some gcc versions don't define LLONG_MIN,
LLONG_MAX, and ULLONG_MAX. Instead only the values gcc defined for
ages are available. */
-# ifdef __USE_ISOC99
-# ifndef LLONG_MIN
-# define LLONG_MIN LONG_LONG_MIN
-# endif
-# ifndef LLONG_MAX
-# define LLONG_MAX LONG_LONG_MAX
-# endif
-# ifndef ULLONG_MAX
-# define ULLONG_MAX ULONG_LONG_MAX
-# endif
+#if defined __USE_ISOC99 && defined __GNUC__
+# ifndef LLONG_MIN
+# define LLONG_MIN (-LLONG_MAX-1)
+# endif
+# ifndef LLONG_MAX
+# define LLONG_MAX __LONG_LONG_MAX__
+# endif
+# ifndef ULLONG_MAX
+# define ULLONG_MAX (LLONG_MAX * 2ULL + 1)
# endif
#endif
diff --git a/include/link.h b/include/link.h
index 6ce15df5f..711777bae 100644
--- a/include/link.h
+++ b/include/link.h
@@ -1,6 +1,6 @@
/* Data structure for communication from the run-time dynamic linker for
loaded ELF shared objects.
- Copyright (C) 1995-2001, 2004, 2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1995-2001, 2004, 2005, 2006, 2010 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -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 _LINK_H
#define _LINK_H 1
@@ -27,7 +26,7 @@
#include <dlfcn.h>
#endif
#include <sys/types.h>
-#if defined _LIBC && defined __UCLIBC_HAS_THREADS_NATIVE__
+#if defined _LIBC && defined __UCLIBC_HAS_TLS__
#include <tls.h>
#endif
@@ -80,9 +79,12 @@ extern struct r_debug _r_debug;
*/
extern ElfW(Dyn) _DYNAMIC[];
-#ifdef __FDPIC__
+#if defined(__FRV_FDPIC__) || defined(__BFIN_FDPIC__)
# include <bits/elf-fdpic.h>
#endif
+#ifdef __DSBT__
+# include <bits/elf-dsbt.h>
+#endif
/* Structure describing a loaded shared object. The `l_next' and `l_prev'
members form a chain of all the shared objects loaded at startup.
@@ -95,16 +97,20 @@ struct link_map
/* These first few members are part of the protocol with the debugger.
This is the same format used in SVR4. */
-#ifdef __FDPIC__
+#if defined(__FRV_FDPIC__) || defined(__BFIN_FDPIC__)
struct elf32_fdpic_loadaddr l_addr;
#else
+#ifdef __DSBT__
+ struct elf32_dsbt_loadaddr l_addr;
+#else
ElfW(Addr) l_addr; /* Base address shared object is loaded at. */
#endif
+#endif
char *l_name; /* Absolute file name object was found in. */
ElfW(Dyn) *l_ld; /* Dynamic section of the shared object. */
struct link_map *l_next, *l_prev; /* Chain of loaded objects. */
-
-#ifdef USE_TLS
+#ifdef _LIBC
+#if defined(USE_TLS) && USE_TLS
/* Thread-local storage related info. */
/* Start of the initialization image. */
@@ -126,6 +132,9 @@ struct link_map
size_t l_tls_modid;
/* Nonzero if _dl_init_static_tls should be called for this module */
unsigned int l_need_tls_init:1;
+ /* Address of TLS descriptor hash table. */
+ void *l_tlsdesc_table;
+#endif
#endif
};
@@ -175,11 +184,15 @@ enum
struct dl_phdr_info
{
-#ifdef __FDPIC__
+#if defined(__FRV_FDPIC__) || defined(__BFIN_FDPIC__)
struct elf32_fdpic_loadaddr dlpi_addr;
#else
+#ifdef __DSBT__
+ struct elf32_dsbt_loadaddr dlpi_addr;
+#else
ElfW(Addr) dlpi_addr;
#endif
+#endif
const char *dlpi_name;
const ElfW(Phdr) *dlpi_phdr;
ElfW(Half) dlpi_phnum;
diff --git a/include/locale.h b/include/locale.h
index c708d4435..3cd6f5ef3 100644
--- a/include/locale.h
+++ b/include/locale.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991,92,95-99,2000,01,02 Free Software Foundation, Inc.
+/* Copyright (C) 1991,1992,1995-2002,2007,2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -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 Standard: 7.11 Localization <locale.h>
@@ -39,6 +38,7 @@ __BEGIN_DECLS
#define LC_COLLATE __LC_COLLATE
#define LC_MONETARY __LC_MONETARY
#define LC_MESSAGES __LC_MESSAGES
+#define LC_ALL __LC_ALL
#if 0
#define LC_PAPER __LC_PAPER
#define LC_NAME __LC_NAME
@@ -47,9 +47,10 @@ __BEGIN_DECLS
#define LC_MEASUREMENT __LC_MEASUREMENT
#define LC_IDENTIFICATION __LC_IDENTIFICATION
#endif
-#define LC_ALL __LC_ALL
+__BEGIN_NAMESPACE_STD
+
/* Structure giving information about numeric and monetary notation. */
struct lconv
{
@@ -121,18 +122,17 @@ struct lconv
};
-__BEGIN_NAMESPACE_STD
-
/* Set and/or return the current locale. */
-extern char *setlocale (int __category, __const char *__locale) __THROW;
+extern char *setlocale (int __category, const char *__locale) __THROW;
/* Return the numeric/monetary information for the current locale. */
extern struct lconv *localeconv (void) __THROW;
+libc_hidden_proto(localeconv)
__END_NAMESPACE_STD
-#if defined(__USE_GNU) && defined(__UCLIBC_HAS_LOCALE__)
+#if defined __USE_XOPEN2K8 && defined __UCLIBC_HAS_XLOCALE__
/* The concept of one static locale per category is not very well
thought out. Many applications will need to process its data using
information from several different locales. Another application is
@@ -144,19 +144,16 @@ __END_NAMESPACE_STD
Attention: all these functions are *not* standardized in any form.
This is a proof-of-concept implementation. */
-#if defined(__UCLIBC_HAS_XLOCALE__)
/* Get locale datatype definition. */
# include <xlocale.h>
-#endif
-
-typedef __locale_t locale_t;
/* Return a reference to a data structure representing a set of locale
datasets. Unlike for the CATEGORY parameter for `setlocale' the
CATEGORY_MASK parameter here uses a single bit for each category,
made by OR'ing together LC_*_MASK bits above. */
-extern __locale_t newlocale (int __category_mask, __const char *__locale,
+extern __locale_t newlocale (int __category_mask, const char *__locale,
__locale_t __base) __THROW;
+libc_hidden_proto(newlocale)
/* These are the bits that can be set in the CATEGORY_MASK argument to
`newlocale'. In the GNU implementation, LC_FOO_MASK has the value
@@ -168,9 +165,6 @@ extern __locale_t newlocale (int __category_mask, __const char *__locale,
# define LC_COLLATE_MASK (1 << __LC_COLLATE)
# define LC_MONETARY_MASK (1 << __LC_MONETARY)
# define LC_MESSAGES_MASK (1 << __LC_MESSAGES)
-#ifdef L_newlocale
-#warning mask defines for extra locale categories
-#endif /* L_newlocale - uClibc note */
#ifdef LC_PAPER
# define LC_PAPER_MASK (1 << __LC_PAPER)
# define LC_NAME_MASK (1 << __LC_NAME)
@@ -215,6 +209,7 @@ extern void freelocale (__locale_t __dataset) __THROW;
for all threads and can also be installed any time, meaning
the thread uses the global settings controlled by `setlocale'. */
extern __locale_t uselocale (__locale_t __dataset) __THROW;
+libc_hidden_proto(uselocale)
/* This value can be passed to `uselocale' and may be returned by it.
Passing this value to any other function has undefined behavior. */
diff --git a/include/malloc.h b/include/malloc.h
index 12834a547..b16a1105a 100644
--- a/include/malloc.h
+++ b/include/malloc.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 _MALLOC_H
#define _MALLOC_H 1
@@ -124,12 +123,16 @@ extern void free __MALLOC_P ((__malloc_ptr_t __ptr));
/* Allocate SIZE bytes allocated to ALIGNMENT bytes. */
extern __malloc_ptr_t memalign __MALLOC_P ((size_t __alignment, size_t __size));
+libc_hidden_proto(memalign)
+#ifdef __UCLIBC_SUSV2_LEGACY__
/* Allocate SIZE bytes on a page boundary. */
extern __malloc_ptr_t valloc __MALLOC_P ((size_t __size)) __attribute_malloc__;
+#endif
#ifdef __MALLOC_STANDARD__
+# ifdef __USE_SVID
/* SVID2/XPG mallinfo structure */
struct mallinfo {
int arena; /* total space allocated from system */
@@ -146,15 +149,18 @@ struct mallinfo {
/* Returns a copy of the updated current mallinfo. */
extern struct mallinfo mallinfo __MALLOC_P ((void));
+libc_hidden_proto(mallinfo)
+# endif /* __USE_SVID */
+# ifdef __USE_GNU
/* Release all but __pad bytes of freed top-most memory back to the
system. Return 1 if successful, else 0. */
extern int malloc_trim(size_t pad);
+# endif /* __USE_GNU */
#include <stdio.h>
-/* Prints brief summary statistics to the specified file.
- * Writes to stderr if file is NULL. */
-extern void malloc_stats(FILE *file);
+/* Prints brief summary statistics on the stderr. */
+extern void malloc_stats(void);
/* SVID2/XPG mallopt options */
#ifndef M_MXFAST
@@ -189,7 +195,9 @@ extern int mallopt __MALLOC_P ((int __param, int __val));
* if it returns. If __uc_malloc_failed is NULL, uclibc will _exit(1).
* NB: do not use stdio in __uc_malloc_failed handler! */
extern void *__uc_malloc(size_t size);
+libc_hidden_proto(__uc_malloc)
extern void (*__uc_malloc_failed)(size_t size);
+libc_hidden_proto(__uc_malloc_failed)
#ifdef __cplusplus
} /* end of extern "C" */
diff --git a/include/math.h b/include/math.h
index 34c042dc5..25454764a 100644
--- a/include/math.h
+++ b/include/math.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/>. */
/*
* ISO C99 Standard: 7.12 Mathematics <math.h>
@@ -46,44 +45,79 @@ __BEGIN_DECLS
/* Get general and ISO C99 specific information. */
#include <bits/mathdef.h>
+
/* The file <bits/mathcalls.h> contains the prototypes for all the
actual math functions. These macros are used for those prototypes,
so we can easily declare each function as both `name' and `__name',
and can declare the float versions `namef' and `__namef'. */
-#define __MATHCALL(function,suffix, args) \
- __MATHDECL (_Mdouble_,function,suffix, args)
-#define __MATHDECL(type, function,suffix, args) \
- __MATHDECL_1(type, function,suffix, args); \
- __MATHDECL_1(type, __CONCAT(__,function),suffix, args)
-#define __MATHCALLX(function,suffix, args, attrib) \
- __MATHDECLX (_Mdouble_,function,suffix, args, attrib)
-#define __MATHDECLX(type, function,suffix, args, attrib) \
- __MATHDECL_1(type, function,suffix, args) __attribute__ (attrib); \
- __MATHDECL_1(type, __CONCAT(__,function),suffix, args) __attribute__ (attrib)
-#define __MATHDECL_1(type, function,suffix, args) \
- extern type __MATH_PRECNAME(function,suffix) args __THROW
-
-#define _Mdouble_ double
-#define __MATH_PRECNAME(name,r) __CONCAT(name,r)
-# define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_STD
-# define _Mdouble_END_NAMESPACE __END_NAMESPACE_STD
+#define __MATHDECL_1(type,function,suffix,args) \
+ extern type __MATH_PRECNAME(function,suffix) args __THROW
+
+#define __MATHDECL(type,function,suffix,args) \
+ __MATHDECL_1(type,function,suffix,args);
+
+#define __MATHCALL(function,suffix,args) \
+ __MATHDECL(_Mdouble_,function,suffix,args)
+
+#define __MATHDECLX(type,function,suffix,args,attrib) \
+ __MATHDECL_1(type,function,suffix,args) __attribute__ (attrib); \
+ __MATH_maybe_libm_hidden_proto(function)
+
+#define __MATHCALLX(function,suffix,args,attrib) \
+ __MATHDECLX(_Mdouble_,function,suffix,args,attrib)
+
+/* Decls which are also used internally in libm.
+ Only the main variant is used internally, no need to try to avoid relocs
+ for the {l,f} variants. */
+#define __MATHDECLI(type,function,suffix,args) \
+ __MATHDECL_1(type,function,suffix,args); \
+ __MATH_maybe_libm_hidden_proto(function)
+
+#define __MATHCALLI(function,suffix,args) \
+ __MATHDECLI(_Mdouble_,function,suffix,args)
+
+/* Private helpers for purely macro impls below.
+ Only make __foo{,f,l} visible but not (the macro-only) foo. */
+#if defined _LIBC
+# define __MATHDECL_PRIV(type,function,suffix,args,attrib) \
+ __MATHDECL_1(type,__CONCAT(__,function),suffix,args) __attribute__ (attrib); \
+ libm_hidden_proto(__MATH_PRECNAME(__##function,suffix))
+#else
+# define __MATHDECL_PRIV(type,function,suffix,args,attrib) \
+ __MATHDECL_1(type,__CONCAT(__,function),suffix,args) __attribute__ (attrib);
+#endif
+
+
+/* Include the file of declarations, declaring double versions */
+
+#if defined _LIBC
+# define __MATH_maybe_libm_hidden_proto(x) libm_hidden_proto(x)
+#else
+# define __MATH_maybe_libm_hidden_proto(x)
+#endif
+#define _Mdouble_ double
+#define __MATH_PRECNAME(name,r) __CONCAT(name,r)
+#define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_STD
+#define _Mdouble_END_NAMESPACE __END_NAMESPACE_STD
#include <bits/mathcalls.h>
#undef _Mdouble_
#undef _Mdouble_BEGIN_NAMESPACE
#undef _Mdouble_END_NAMESPACE
-#undef __MATH_PRECNAME
+#undef __MATH_PRECNAME
+#undef __MATH_maybe_libm_hidden_proto
-#if defined __USE_MISC || defined __USE_ISOC99
+#if defined __USE_MISC || defined __USE_ISOC99
/* Include the file of declarations again, this time using `float'
instead of `double' and appending f to each function name. */
+# define __MATH_maybe_libm_hidden_proto(x)
# ifndef _Mfloat_
# define _Mfloat_ float
# endif
-# define _Mdouble_ _Mfloat_
+# define _Mdouble_ _Mfloat_
# ifdef __STDC__
# define __MATH_PRECNAME(name,r) name##f##r
# else
@@ -95,24 +129,25 @@ __BEGIN_DECLS
# undef _Mdouble_
# undef _Mdouble_BEGIN_NAMESPACE
# undef _Mdouble_END_NAMESPACE
+# undef _Mfloat_
# undef __MATH_PRECNAME
+# undef __MATH_maybe_libm_hidden_proto
+
-# if (__STDC__ - 0 || __GNUC__ - 0) \
+# if (defined __STDC__ || defined __GNUC__) \
&& (!defined __NO_LONG_DOUBLE_MATH || defined __LDBL_COMPAT)
# ifdef __LDBL_COMPAT
# ifdef __USE_ISOC99
-extern float __nldbl_nexttowardf (float __x, long double __y)
- __THROW __attribute__ ((__const__));
+extern float __nldbl_nexttowardf (float __x, long double __y) __THROW
+ __attribute__ ((__const__));
# ifdef __REDIRECT_NTH
-extern float __REDIRECT_NTH (nexttowardf, (float __x, long double __y),
- __nldbl_nexttowardf)
- __attribute__ ((__const__));
-extern double __REDIRECT_NTH (nexttoward, (double __x, long double __y),
- nextafter) __attribute__ ((__const__));
-extern long double __REDIRECT_NTH (nexttowardl,
- (long double __x, long double __y),
- nextafter) __attribute__ ((__const__));
+extern float __REDIRECT_NTH (nexttowardf, (float __x, long double __y), __nldbl_nexttowardf)
+ __attribute__ ((__const__));
+extern double __REDIRECT_NTH (nexttoward, (double __x, long double __y), nextafter)
+ __attribute__ ((__const__));
+extern long double __REDIRECT_NTH (nexttowardl, (long double __x, long double __y), nextafter)
+ __attribute__ ((__const__));
# endif
# endif
@@ -120,17 +155,17 @@ extern long double __REDIRECT_NTH (nexttowardl,
instead of `double' and appending l to each function name. */
# undef __MATHDECL_1
-# define __MATHDECL_2(type, function,suffix, args, alias) \
- extern type __REDIRECT_NTH(__MATH_PRECNAME(function,suffix), \
- args, alias)
-# define __MATHDECL_1(type, function,suffix, args) \
- __MATHDECL_2(type, function,suffix, args, __CONCAT(function,suffix))
+# define __MATHDECL_2(type,function,suffix,args,alias) \
+ extern type __REDIRECT_NTH(__MATH_PRECNAME(function,suffix),args,alias)
+# define __MATHDECL_1(type,function,suffix,args) \
+ __MATHDECL_2(type,function,suffix,args,__CONCAT(function,suffix))
# endif
+# define __MATH_maybe_libm_hidden_proto(x)
# ifndef _Mlong_double_
# define _Mlong_double_ long double
# endif
-# define _Mdouble_ _Mlong_double_
+# define _Mdouble_ _Mlong_double_
# ifdef __STDC__
# define __MATH_PRECNAME(name,r) name##l##r
# else
@@ -140,9 +175,11 @@ extern long double __REDIRECT_NTH (nexttowardl,
# define _Mdouble_END_NAMESPACE __END_NAMESPACE_C99
# include <bits/mathcalls.h>
# undef _Mdouble_
-# undef _Mdouble_BEGIN_NAMESPACE
-# undef _Mdouble_END_NAMESPACE
+# undef _Mdouble_BEGIN_NAMESPACE
+# undef _Mdouble_END_NAMESPACE
+# undef _Mlong_double_
# undef __MATH_PRECNAME
+# undef __MATH_maybe_libm_hidden_proto
# endif /* __STDC__ || __GNUC__ */
@@ -159,7 +196,7 @@ extern int signgam;
/* ISO C99 defines some generic macros which work on any data type. */
-#ifdef __USE_ISOC99
+#if defined(__USE_ISOC99) || defined(__USE_BSD)
/* Get the architecture specific values describing the floating-point
evaluation. The following symbols will get defined:
@@ -279,6 +316,11 @@ enum
#endif /* Use ISO C99. */
+/* BSD compat */
+#define finite(x) __finite(x)
+#define finitef(x) __finitef(x)
+#define finitel(x) __finitel(x)
+
#ifdef __USE_MISC
/* Support for various different standard error handling behaviors. */
typedef enum
@@ -338,8 +380,10 @@ extern int matherr (struct exception *__exc);
#else /* !SVID */
# ifdef __USE_XOPEN
+# ifdef __UCLIBC_SUSV4_LEGACY__
/* X/Open wants another strange constant. */
# define MAXFLOAT 3.40282347e+38F
+# endif
# endif
#endif /* SVID */
diff --git a/include/memory.h b/include/memory.h
index 743fa6a95..176a0a92c 100644
--- a/include/memory.h
+++ b/include/memory.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/>. */
/*
* SVID
diff --git a/include/mntent.h b/include/mntent.h
index a82e9539a..f9f119db5 100644
--- a/include/mntent.h
+++ b/include/mntent.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 _MNTENT_H
#define _MNTENT_H 1
@@ -64,7 +63,8 @@ struct mntent
/* Prepare to begin reading and/or writing mount table entries from the
beginning of FILE. MODE is as for `fopen'. */
-extern FILE *setmntent (__const char *__file, __const char *__mode) __THROW;
+extern FILE *setmntent (const char *__file, const char *__mode) __THROW;
+libc_hidden_proto(setmntent)
/* Read one mount table entry from STREAM. Returns a pointer to storage
reused on the next call, or null for EOF or error (use feof/ferror to
@@ -77,20 +77,22 @@ extern struct mntent *getmntent_r (FILE *__restrict __stream,
struct mntent *__restrict __result,
char *__restrict __buffer,
int __bufsize) __THROW;
+libc_hidden_proto(getmntent_r)
#endif
/* Write the mount table entry described by MNT to STREAM.
Return zero on success, nonzero on failure. */
extern int addmntent (FILE *__restrict __stream,
- __const struct mntent *__restrict __mnt) __THROW;
+ const struct mntent *__restrict __mnt) __THROW;
/* Close a stream opened with `setmntent'. */
extern int endmntent (FILE *__stream) __THROW;
+libc_hidden_proto(endmntent)
/* Search MNT->mnt_opts for an option matching OPT.
Returns the address of the substring, or null if none found. */
-extern char *hasmntopt (__const struct mntent *__mnt,
- __const char *__opt) __THROW;
+extern char *hasmntopt (const struct mntent *__mnt,
+ const char *__opt) __THROW;
__END_DECLS
diff --git a/include/mqueue.h b/include/mqueue.h
index f75b50611..fbfd807b2 100644
--- a/include/mqueue.h
+++ b/include/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
#define _MQUEUE_H 1
diff --git a/include/net/ethernet.h b/include/net/ethernet.h
index 7ca8e8348..9698c70bb 100644
--- a/include/net/ethernet.h
+++ b/include/net/ethernet.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 1999, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1999, 2001, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -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/>. */
/* Based on the FreeBSD version of this file. Curiously, that file
lacks a copyright in the header. */
@@ -45,9 +44,17 @@ struct ether_header
/* Ethernet protocol ID's */
#define ETHERTYPE_PUP 0x0200 /* Xerox PUP */
+#define ETHERTYPE_SPRITE 0x0500 /* Sprite */
#define ETHERTYPE_IP 0x0800 /* IP */
#define ETHERTYPE_ARP 0x0806 /* Address resolution */
#define ETHERTYPE_REVARP 0x8035 /* Reverse ARP */
+#define ETHERTYPE_AT 0x809B /* AppleTalk protocol */
+#define ETHERTYPE_AARP 0x80F3 /* AppleTalk ARP */
+#define ETHERTYPE_VLAN 0x8100 /* IEEE 802.1Q VLAN tagging */
+#define ETHERTYPE_IPX 0x8137 /* IPX */
+#define ETHERTYPE_IPV6 0x86dd /* IP protocol version 6 */
+#define ETHERTYPE_LOOPBACK 0x9000 /* used to test interfaces */
+
#define ETHER_ADDR_LEN ETH_ALEN /* size of ethernet addr */
#define ETHER_TYPE_LEN 2 /* bytes in type field */
diff --git a/include/net/if.h b/include/net/if.h
index ebb3e9f30..67636e0fc 100644
--- a/include/net/if.h
+++ b/include/net/if.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 _NET_IF_H
#define _NET_IF_H 1
@@ -191,14 +190,17 @@ struct ifconf
__BEGIN_DECLS
/* Convert an interface name to an index, and vice versa. */
-extern unsigned int if_nametoindex (__const char *__ifname) __THROW;
+extern unsigned int if_nametoindex (const char *__ifname) __THROW;
+libc_hidden_proto(if_nametoindex)
extern char *if_indextoname (unsigned int __ifindex, char *__ifname) __THROW;
/* Return a list of all interfaces and their indices. */
extern struct if_nameindex *if_nameindex (void) __THROW;
+libc_hidden_proto(if_nameindex)
/* Free the data returned from if_nameindex. */
extern void if_freenameindex (struct if_nameindex *__ptr) __THROW;
+libc_hidden_proto(if_freenameindex)
__END_DECLS
diff --git a/include/net/if_arp.h b/include/net/if_arp.h
index 46f035bef..b2997efaa 100644
--- a/include/net/if_arp.h
+++ b/include/net/if_arp.h
@@ -1,5 +1,5 @@
/* Definitions for Address Resolution Protocol.
- Copyright (C) 1997, 1999, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1997,1999,2001,2006,2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -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/>. */
/* Based on the 4.4BSD and Linux version of this file. */
@@ -96,7 +95,7 @@ struct arphdr
#define ARPHRD_ADAPT 264
#define ARPHRD_ROSE 270
#define ARPHRD_X25 271 /* CCITT X.25. */
-#define ARPHDR_HWX25 272 /* Boards with X.25 in firmware. */
+#define ARPHRD_HWX25 272 /* Boards with X.25 in firmware. */
#define ARPHRD_PPP 512
#define ARPHRD_CISCO 513 /* Cisco HDLC. */
#define ARPHRD_HDLC ARPHRD_CISCO
@@ -126,6 +125,14 @@ struct arphdr
#define ARPHRD_FCFABRIC 787 /* Fibrechanel fabric. */
#define ARPHRD_IEEE802_TR 800 /* Magic type ident for TR. */
#define ARPHRD_IEEE80211 801 /* IEEE 802.11. */
+#define ARPHRD_IEEE80211_PRISM 802 /* IEEE 802.11 + Prism2 header. */
+#define ARPHRD_IEEE80211_RADIOTAP 803 /* IEEE 802.11 + radiotap header. */
+#define ARPHRD_IEEE802154 804 /* IEEE 802.15.4 header. */
+#define ARPHRD_IEEE802154_PHY 805 /* IEEE 802.15.4 PHY header. */
+
+#define ARPHRD_VOID 0xFFFF /* Void type, nothing is known. */
+#define ARPHRD_NONE 0xFFFE /* Zero header length. */
+
/* ARP ioctl request. */
struct arpreq
diff --git a/include/net/if_packet.h b/include/net/if_packet.h
index e5184e7f1..135f2b8a4 100644
--- a/include/net/if_packet.h
+++ b/include/net/if_packet.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 __IF_PACKET_H
#define __IF_PACKET_H
diff --git a/include/net/if_shaper.h b/include/net/if_shaper.h
index 7060af31e..84c9ddd24 100644
--- a/include/net/if_shaper.h
+++ b/include/net/if_shaper.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 _NET_IF_SHAPER_H
#define _NET_IF_SHAPER_H 1
diff --git a/include/net/if_slip.h b/include/net/if_slip.h
index 66bd7f30a..381131cba 100644
--- a/include/net/if_slip.h
+++ b/include/net/if_slip.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 _NET_IF_SLIP_H
#define _NET_IF_SLIP_H 1
diff --git a/include/net/route.h b/include/net/route.h
index da5c810c7..d1023bee3 100644
--- a/include/net/route.h
+++ b/include/net/route.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/>. */
/* Based on the 4.4BSD and Linux version of this file. */
@@ -55,6 +54,7 @@ struct rtentry
#define rt_mss rt_mtu
+#if defined __UCLIBC_HAS_IPV6__ || !defined __UCLIBC_STRICT_HEADERS__
struct in6_rtmsg
{
struct in6_addr rtmsg_dst;
@@ -68,6 +68,7 @@ struct in6_rtmsg
u_int32_t rtmsg_flags;
int rtmsg_ifindex;
};
+#endif
#define RTF_UP 0x0001 /* Route usable. */
@@ -129,6 +130,7 @@ struct in6_rtmsg
#define RT_CLASS_MAX 255
+#if defined __UCLIBC_HAS_IPV6__ || !defined __UCLIBC_STRICT_HEADERS__
#define RTMSG_ACK NLMSG_ACK
#define RTMSG_OVERRUN NLMSG_OVERRUN
@@ -141,5 +143,6 @@ struct in6_rtmsg
#define RTMSG_CONTROL 0x40
#define RTMSG_AR_FAILED 0x51 /* Address Resolution failed. */
+#endif
#endif /* net/route.h */
diff --git a/include/netax25/ax25.h b/include/netax25/ax25.h
index ce3c7abc9..a248dac1a 100644
--- a/include/netax25/ax25.h
+++ b/include/netax25/ax25.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 _NETAX25_AX25_H
#define _NETAX25_AX25_H 1
diff --git a/include/netdb.h b/include/netdb.h
index df90601ac..95abe95cb 100644
--- a/include/netdb.h
+++ b/include/netdb.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996-2002, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2002, 2003, 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/>. */
/* All data returned by the network data base library are supplied in
host order and returned in network order (suitable for use in
@@ -27,7 +26,7 @@
#include <netinet/in.h>
#include <stdint.h>
-#ifdef __USE_MISC
+#if defined __USE_MISC && defined __UCLIBC_HAS_RPC__
/* This is necessary to make this include file properly replace the
Sun version. */
# include <rpc/netdb.h>
@@ -54,24 +53,39 @@
__BEGIN_DECLS
/* Error status for non-reentrant lookup functions.
- We use a macro to access always the thread-specific `h_errno' variable.
- We always need the extern int here in case internal libc code undefines
- the macro because it needs access to the underlying storage. */
-extern int h_errno;
-#ifdef __UCLIBC_HAS_THREADS__
-# define h_errno (*__h_errno_location ())
-#endif
+ We use a macro to access always the thread-specific `h_errno' variable. */
+#define h_errno (*__h_errno_location ())
/* Function to get address of global `h_errno' variable. */
extern int *__h_errno_location (void) __THROW __attribute__ ((__const__));
+/* Macros for accessing h_errno from inside libc. */
#ifdef _LIBC
-# define __set_h_errno(x) (h_errno = (x))
-#endif
+# ifdef __UCLIBC_HAS_THREADS__
+# if defined __UCLIBC_HAS_TLS__ \
+ && (!defined NOT_IN_libc || defined IS_IN_libpthread)
+# undef h_errno
+# ifndef NOT_IN_libc
+# define h_errno __libc_h_errno
+# else
+# define h_errno h_errno /* For #ifndef h_errno tests. */
+# endif
+extern __thread int h_errno attribute_tls_model_ie;
+# define __set_h_errno(x) (h_errno = (x))
+# else
+static inline int __set_h_errno (int __err)
+{
+ return *__h_errno_location () = __err;
+}
+# endif /* __UCLIBC_HAS_TLS__ */
+# else
+# undef h_errno
+# define __set_h_errno(x) (h_errno = (x))
+extern int h_errno;
+# endif /* __UCLIBC_HAS_THREADS__ */
+#endif /* _LIBC */
/* Possible values left in `h_errno'. */
-#define NETDB_INTERNAL -1 /* See errno. */
-#define NETDB_SUCCESS 0 /* No problem. */
#define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found. */
#define TRY_AGAIN 2 /* Non-Authoritative Host not found,
or SERVERFAIL. */
@@ -79,7 +93,11 @@ extern int *__h_errno_location (void) __THROW __attribute__ ((__const__));
NOTIMP. */
#define NO_DATA 4 /* Valid name, no data record of requested
type. */
-#define NO_ADDRESS NO_DATA /* No address, look for MX record. */
+#if defined __USE_MISC || defined __USE_GNU
+# define NETDB_INTERNAL -1 /* See errno. */
+# define NETDB_SUCCESS 0 /* No problem. */
+# define NO_ADDRESS NO_DATA /* No address, look for MX record. */
+#endif
#ifdef __USE_XOPEN2K
/* Highest reserved Internet port number. */
@@ -91,13 +109,15 @@ extern int *__h_errno_location (void) __THROW __attribute__ ((__const__));
# define SCOPE_DELIMITER '%'
#endif
+#if defined __USE_MISC || defined __USE_GNU
/* Print error indicated by `h_errno' variable on standard error. STR
if non-null is printed before the error string. */
-extern void herror (__const char *__str) __THROW;
+extern void herror (const char *__str) __THROW;
+libc_hidden_proto(herror)
/* Return string associated with error ERR_NUM. */
-extern __const char *hstrerror (int __err_num) __THROW;
-
+extern const char *hstrerror (int __err_num) __THROW;
+#endif
/* Description of data base entry for a single host. */
@@ -108,7 +128,9 @@ struct hostent
int h_addrtype; /* Host address type. */
int h_length; /* Length of address. */
char **h_addr_list; /* List of addresses from name server. */
-#define h_addr h_addr_list[0] /* Address, for backward compatibility. */
+#if defined __USE_MISC || defined __USE_GNU
+# define h_addr h_addr_list[0] /* Address, for backward compatibility.*/
+#endif
};
/* Open host data base files and mark them as staying open even after
@@ -136,14 +158,16 @@ extern struct hostent *gethostent (void);
This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern struct hostent *gethostbyaddr (__const void *__addr, __socklen_t __len,
+extern struct hostent *gethostbyaddr (const void *__addr, __socklen_t __len,
int __type);
+libc_hidden_proto(gethostbyaddr)
/* Return entry from host data base for host with NAME.
This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern struct hostent *gethostbyname (__const char *__name);
+extern struct hostent *gethostbyname (const char *__name);
+libc_hidden_proto(gethostbyname)
#ifdef __USE_MISC
/* Return entry from host data base for host with NAME. AF must be
@@ -154,7 +178,8 @@ extern struct hostent *gethostbyname (__const char *__name);
cancellation point. But due to similarity with an POSIX interface
or due to the implementation it is a cancellation point and
therefore not marked with __THROW. */
-extern struct hostent *gethostbyname2 (__const char *__name, int __af);
+extern struct hostent *gethostbyname2 (const char *__name, int __af);
+libc_hidden_proto(gethostbyname2)
/* Reentrant versions of the functions above. The additional
arguments specify a buffer of BUFLEN starting at BUF. The last
@@ -170,25 +195,29 @@ extern int gethostent_r (struct hostent *__restrict __result_buf,
char *__restrict __buf, size_t __buflen,
struct hostent **__restrict __result,
int *__restrict __h_errnop);
+libc_hidden_proto(gethostent_r)
-extern int gethostbyaddr_r (__const void *__restrict __addr, __socklen_t __len,
+extern int gethostbyaddr_r (const void *__restrict __addr, __socklen_t __len,
int __type,
struct hostent *__restrict __result_buf,
char *__restrict __buf, size_t __buflen,
struct hostent **__restrict __result,
int *__restrict __h_errnop);
+libc_hidden_proto(gethostbyaddr_r)
-extern int gethostbyname_r (__const char *__restrict __name,
+extern int gethostbyname_r (const char *__restrict __name,
struct hostent *__restrict __result_buf,
char *__restrict __buf, size_t __buflen,
struct hostent **__restrict __result,
int *__restrict __h_errnop);
+libc_hidden_proto(gethostbyname_r)
-extern int gethostbyname2_r (__const char *__restrict __name, int __af,
+extern int gethostbyname2_r (const char *__restrict __name, int __af,
struct hostent *__restrict __result_buf,
char *__restrict __buf, size_t __buflen,
struct hostent **__restrict __result,
int *__restrict __h_errnop);
+libc_hidden_proto(gethostbyname2_r)
#endif /* misc */
@@ -198,12 +227,14 @@ extern int gethostbyname2_r (__const char *__restrict __name, int __af,
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern void setnetent (int __stay_open);
+libc_hidden_proto(setnetent)
/* Close network data base files and clear `stay open' flag.
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern void endnetent (void);
+libc_hidden_proto(endnetent)
/* Get next entry from network data base file. Open data base if
necessary.
@@ -223,10 +254,8 @@ extern struct netent *getnetbyaddr (uint32_t __net, int __type);
This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern struct netent *getnetbyname (__const char *__name);
+extern struct netent *getnetbyname (const char *__name);
-#if 0
-/* FIXME */
#ifdef __USE_MISC
/* Reentrant versions of the functions above. The additional
arguments specify a buffer of BUFLEN starting at BUF. The last
@@ -242,20 +271,22 @@ extern int getnetent_r (struct netent *__restrict __result_buf,
char *__restrict __buf, size_t __buflen,
struct netent **__restrict __result,
int *__restrict __h_errnop);
+libc_hidden_proto(getnetent_r)
extern int getnetbyaddr_r (uint32_t __net, int __type,
struct netent *__restrict __result_buf,
char *__restrict __buf, size_t __buflen,
struct netent **__restrict __result,
int *__restrict __h_errnop);
+libc_hidden_proto(getnetbyaddr_r)
-extern int getnetbyname_r (__const char *__restrict __name,
+extern int getnetbyname_r (const char *__restrict __name,
struct netent *__restrict __result_buf,
char *__restrict __buf, size_t __buflen,
struct netent **__restrict __result,
int *__restrict __h_errnop);
-#endif /* misc */
-#endif
+libc_hidden_proto(getnetbyname_r)
+#endif /* __USE_MISC */
/* Description of data base entry for a single service. */
@@ -273,12 +304,14 @@ struct servent
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern void setservent (int __stay_open);
+libc_hidden_proto(setservent)
/* Close service data base files and clear `stay open' flag.
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern void endservent (void);
+libc_hidden_proto(endservent)
/* Get next entry from service data base file. Open data base if
necessary.
@@ -292,15 +325,16 @@ extern struct servent *getservent (void);
This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern struct servent *getservbyname (__const char *__name,
- __const char *__proto);
+extern struct servent *getservbyname (const char *__name,
+ const char *__proto);
/* Return entry from service data base which matches port PORT and
protocol PROTO.
This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern struct servent *getservbyport (int __port, __const char *__proto);
+extern struct servent *getservbyport (int __port, const char *__proto);
+libc_hidden_proto(getservbyport)
#ifdef __USE_MISC
@@ -314,17 +348,20 @@ extern struct servent *getservbyport (int __port, __const char *__proto);
extern int getservent_r (struct servent *__restrict __result_buf,
char *__restrict __buf, size_t __buflen,
struct servent **__restrict __result);
+libc_hidden_proto(getservent_r)
-extern int getservbyname_r (__const char *__restrict __name,
- __const char *__restrict __proto,
+extern int getservbyname_r (const char *__restrict __name,
+ const char *__restrict __proto,
struct servent *__restrict __result_buf,
char *__restrict __buf, size_t __buflen,
struct servent **__restrict __result);
+libc_hidden_proto(getservbyname_r)
-extern int getservbyport_r (int __port, __const char *__restrict __proto,
+extern int getservbyport_r (int __port, const char *__restrict __proto,
struct servent *__restrict __result_buf,
char *__restrict __buf, size_t __buflen,
struct servent **__restrict __result);
+libc_hidden_proto(getservbyport_r)
#endif /* misc */
@@ -342,12 +379,14 @@ struct protoent
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern void setprotoent (int __stay_open);
+libc_hidden_proto(setprotoent)
/* Close protocol data base files and clear `stay open' flag.
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern void endprotoent (void);
+libc_hidden_proto(endprotoent)
/* Get next entry from protocol data base file. Open data base if
necessary.
@@ -360,7 +399,7 @@ extern struct protoent *getprotoent (void);
This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern struct protoent *getprotobyname (__const char *__name);
+extern struct protoent *getprotobyname (const char *__name);
/* Return entry from protocol data base which number is PROTO.
@@ -380,16 +419,19 @@ extern struct protoent *getprotobynumber (int __proto);
extern int getprotoent_r (struct protoent *__restrict __result_buf,
char *__restrict __buf, size_t __buflen,
struct protoent **__restrict __result);
+libc_hidden_proto(getprotoent_r)
-extern int getprotobyname_r (__const char *__restrict __name,
+extern int getprotobyname_r (const char *__restrict __name,
struct protoent *__restrict __result_buf,
char *__restrict __buf, size_t __buflen,
struct protoent **__restrict __result);
+libc_hidden_proto(getprotobyname_r)
extern int getprotobynumber_r (int __proto,
struct protoent *__restrict __result_buf,
char *__restrict __buf, size_t __buflen,
struct protoent **__restrict __result);
+libc_hidden_proto(getprotobynumber_r)
#ifdef __UCLIBC_HAS_NETGROUP__
@@ -399,7 +441,7 @@ extern int getprotobynumber_r (int __proto,
cancellation point. But due to similarity with an POSIX interface
or due to the implementation it is a cancellation point and
therefore not marked with __THROW. */
-extern int setnetgrent (__const char *__netgroup);
+extern int setnetgrent (const char *__netgroup);
/* Free all space allocated by previous `setnetgrent' call.
@@ -427,8 +469,8 @@ extern int getnetgrent (char **__restrict __hostp,
cancellation point. But due to similarity with an POSIX interface
or due to the implementation it is a cancellation point and
therefore not marked with __THROW. */
-extern int innetgr (__const char *__netgroup, __const char *__host,
- __const char *__user, __const char *domain);
+extern int innetgr (const char *__netgroup, const char *__host,
+ const char *__user, const char *__domain);
/* Reentrant version of `getnetgrent' where result is placed in BUFFER.
@@ -443,11 +485,12 @@ extern int getnetgrent_r (char **__restrict __hostp,
#endif /* UCLIBC_HAS_NETGROUP */
#endif /* misc */
-
+#ifdef __UCLIBC__
/* ruserpass - remote password check.
This function also exists in glibc but is undocumented */
extern int ruserpass(const char *host, const char **aname, const char **apass);
-
+libc_hidden_proto(ruserpass)
+#endif
#ifdef __USE_BSD
/* Call `rshd' at port RPORT on remote machine *AHOST to execute CMD.
@@ -462,9 +505,9 @@ extern int ruserpass(const char *host, const char **aname, const char **apass);
or due to the implementation it is a cancellation point and
therefore not marked with __THROW. */
extern int rcmd (char **__restrict __ahost, unsigned short int __rport,
- __const char *__restrict __locuser,
- __const char *__restrict __remuser,
- __const char *__restrict __cmd, int *__restrict __fd2p);
+ const char *__restrict __locuser,
+ const char *__restrict __remuser,
+ const char *__restrict __cmd, int *__restrict __fd2p);
#if 0
/* FIXME */
@@ -476,9 +519,9 @@ extern int rcmd (char **__restrict __ahost, unsigned short int __rport,
or due to the implementation it is a cancellation point and
therefore not marked with __THROW. */
extern int rcmd_af (char **__restrict __ahost, unsigned short int __rport,
- __const char *__restrict __locuser,
- __const char *__restrict __remuser,
- __const char *__restrict __cmd, int *__restrict __fd2p,
+ const char *__restrict __locuser,
+ const char *__restrict __remuser,
+ const char *__restrict __cmd, int *__restrict __fd2p,
sa_family_t __af);
#endif
@@ -493,9 +536,9 @@ extern int rcmd_af (char **__restrict __ahost, unsigned short int __rport,
or due to the implementation it is a cancellation point and
therefore not marked with __THROW. */
extern int rexec (char **__restrict __ahost, int __rport,
- __const char *__restrict __name,
- __const char *__restrict __pass,
- __const char *__restrict __cmd, int *__restrict __fd2p);
+ const char *__restrict __name,
+ const char *__restrict __pass,
+ const char *__restrict __cmd, int *__restrict __fd2p);
/* This is the equivalent function where the protocol can be selected
and which therefore can be used for IPv6.
@@ -505,10 +548,11 @@ extern int rexec (char **__restrict __ahost, int __rport,
or due to the implementation it is a cancellation point and
therefore not marked with __THROW. */
extern int rexec_af (char **__restrict __ahost, int __rport,
- __const char *__restrict __name,
- __const char *__restrict __pass,
- __const char *__restrict __cmd, int *__restrict __fd2p,
+ const char *__restrict __name,
+ const char *__restrict __pass,
+ const char *__restrict __cmd, int *__restrict __fd2p,
sa_family_t __af);
+libc_hidden_proto(rexec_af)
/* Check whether user REMUSER on system RHOST is allowed to login as LOCUSER.
If SUSER is not zero the user tries to become superuser. Return 0 if
@@ -518,8 +562,8 @@ extern int rexec_af (char **__restrict __ahost, int __rport,
cancellation point. But due to similarity with an POSIX interface
or due to the implementation it is a cancellation point and
therefore not marked with __THROW. */
-extern int ruserok (__const char *__rhost, int __suser,
- __const char *__remuser, __const char *__locuser);
+extern int ruserok (const char *__rhost, int __suser,
+ const char *__remuser, const char *__locuser);
#if 0
/* FIXME */
@@ -530,8 +574,8 @@ extern int ruserok (__const char *__rhost, int __suser,
cancellation point. But due to similarity with an POSIX interface
or due to the implementation it is a cancellation point and
therefore not marked with __THROW. */
-extern int ruserok_af (__const char *__rhost, int __suser,
- __const char *__remuser, __const char *__locuser,
+extern int ruserok_af (const char *__rhost, int __suser,
+ const char *__remuser, const char *__locuser,
sa_family_t __af);
#endif
@@ -544,6 +588,7 @@ extern int ruserok_af (__const char *__rhost, int __suser,
or due to the implementation it is a cancellation point and
therefore not marked with __THROW. */
extern int rresvport (int *__alport);
+libc_hidden_proto(rresvport)
#if 0
/* FIXME */
@@ -582,16 +627,6 @@ struct addrinfo
# define AI_ALL 0x0010 /* Return IPv4 mapped and IPv6 addresses. */
# define AI_ADDRCONFIG 0x0020 /* Use configuration of this host to choose
returned address type.. */
-# ifdef __USE_GNU
-# define AI_IDN 0x0040 /* IDN encode input (assuming it is encoded
- in the current locale's character set)
- before looking it up. */
-# define AI_CANONIDN 0x0080 /* Translate canonical name from IDN format. */
-# define AI_IDN_ALLOW_UNASSIGNED 0x0100 /* Don't reject unassigned Unicode
- code points. */
-# define AI_IDN_USE_STD3_ASCII_RULES 0x0200 /* Validate strings according to
- STD3 rules. */
-# endif
# define AI_NUMERICSERV 0x0400 /* Don't use name resolution. */
/* Error values for `getaddrinfo' function. */
@@ -599,32 +634,34 @@ struct addrinfo
# define EAI_NONAME -2 /* NAME or SERVICE is unknown. */
# define EAI_AGAIN -3 /* Temporary failure in name resolution. */
# define EAI_FAIL -4 /* Non-recoverable failure in name res. */
-# define EAI_NODATA -5 /* No address associated with NAME. */
# define EAI_FAMILY -6 /* `ai_family' not supported. */
# define EAI_SOCKTYPE -7 /* `ai_socktype' not supported. */
# define EAI_SERVICE -8 /* SERVICE not supported for `ai_socktype'. */
-# define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */
# define EAI_MEMORY -10 /* Memory allocation failure. */
# define EAI_SYSTEM -11 /* System error returned in `errno'. */
# define EAI_OVERFLOW -12 /* Argument buffer overflow. */
# ifdef __USE_GNU
+# define EAI_NODATA -5 /* No address associated with NAME. */
+# define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */
# define EAI_INPROGRESS -100 /* Processing request in progress. */
# define EAI_CANCELED -101 /* Request canceled. */
# define EAI_NOTCANCELED -102 /* Request not canceled. */
# define EAI_ALLDONE -103 /* All requests done. */
# define EAI_INTR -104 /* Interrupted by a signal. */
-# define EAI_IDN_ENCODE -105 /* IDN encoding failed. */
# endif
-# define NI_MAXHOST 1025
-# define NI_MAXSERV 32
+# ifdef __USE_MISC
+# define NI_MAXHOST 1025
+# define NI_MAXSERV 32
+# endif
# define NI_NUMERICHOST 1 /* Don't try to look up hostname. */
# define NI_NUMERICSERV 2 /* Don't convert port number to name. */
# define NI_NOFQDN 4 /* Only return nodename portion. */
# define NI_NAMEREQD 8 /* Don't return numeric addresses. */
# define NI_DGRAM 16 /* Look up UDP service rather than TCP. */
-# ifdef __USE_GNU
+#if 0 /* uClibc: not implemented */
+/* # ifdef __USE_GNU */
# define NI_IDN 32 /* Convert name from IDN format. */
# define NI_IDN_ALLOW_UNASSIGNED 64 /* Don't reject unassigned Unicode
code points. */
@@ -637,25 +674,28 @@ struct addrinfo
This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern int getaddrinfo (__const char *__restrict __name,
- __const char *__restrict __service,
- __const struct addrinfo *__restrict __req,
+extern int getaddrinfo (const char *__restrict __name,
+ const char *__restrict __service,
+ const struct addrinfo *__restrict __req,
struct addrinfo **__restrict __pai);
+libc_hidden_proto(getaddrinfo)
/* Free `addrinfo' structure AI including associated storage. */
extern void freeaddrinfo (struct addrinfo *__ai) __THROW;
+libc_hidden_proto(freeaddrinfo)
/* Convert error return from getaddrinfo() to a string. */
-extern __const char *gai_strerror (int __ecode) __THROW;
+extern const char *gai_strerror (int __ecode) __THROW;
/* Translate a socket address to a location and service name.
This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern int getnameinfo (__const struct sockaddr *__restrict __sa,
+extern int getnameinfo (const struct sockaddr *__restrict __sa,
socklen_t __salen, char *__restrict __host,
socklen_t __hostlen, char *__restrict __serv,
socklen_t __servlen, unsigned int __flags);
+libc_hidden_proto(getnameinfo)
#endif /* POSIX */
__END_DECLS
diff --git a/include/neteconet/ec.h b/include/neteconet/ec.h
index f21601ca0..63a75ccf7 100644
--- a/include/neteconet/ec.h
+++ b/include/neteconet/ec.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 _NETECONET_EC_H
#define _NETECONET_EC_H 1
diff --git a/include/netinet/ether.h b/include/netinet/ether.h
index a16255037..546282066 100644
--- a/include/netinet/ether.h
+++ b/include/netinet/ether.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 _NETINET_ETHER_H
#define _NETINET_ETHER_H 1
@@ -25,31 +24,38 @@
/* Get definition of `struct ether_addr'. */
#include <netinet/if_ether.h>
+#ifdef _LIBC
#define ETHER_FILE_NAME "/etc/ethers"
+#endif
__BEGIN_DECLS
+#if defined __UCLIBC_HAS_SOCKET__ || defined __UCLIBC_HAS_IPV4__ || \
+ defined __UCLIBC_HAS_IPV6__
/* Convert 48 bit Ethernet ADDRess to ASCII. */
-extern char *ether_ntoa (__const struct ether_addr *__addr) __THROW;
-extern char *ether_ntoa_r (__const struct ether_addr *__addr, char *__buf)
+extern char *ether_ntoa (const struct ether_addr *__addr) __THROW;
+extern char *ether_ntoa_r (const struct ether_addr *__addr, char *__buf)
__THROW;
+libc_hidden_proto(ether_ntoa_r)
/* Convert ASCII string S to 48 bit Ethernet address. */
-extern struct ether_addr *ether_aton (__const char *__asc) __THROW;
-extern struct ether_addr *ether_aton_r (__const char *__asc,
+extern struct ether_addr *ether_aton (const char *__asc) __THROW;
+extern struct ether_addr *ether_aton_r (const char *__asc,
struct ether_addr *__addr) __THROW;
+libc_hidden_proto(ether_aton_r)
/* Map 48 bit Ethernet number ADDR to HOSTNAME. */
-extern int ether_ntohost (char *__hostname, __const struct ether_addr *__addr)
+extern int ether_ntohost (char *__hostname, const struct ether_addr *__addr)
__THROW;
/* Map HOSTNAME to 48 bit Ethernet address. */
-extern int ether_hostton (__const char *__hostname, struct ether_addr *__addr)
+extern int ether_hostton (const char *__hostname, struct ether_addr *__addr)
__THROW;
/* Scan LINE and set ADDR and HOSTNAME. */
-extern int ether_line (__const char *__line, struct ether_addr *__addr,
+extern int ether_line (const char *__line, struct ether_addr *__addr,
char *__hostname) __THROW;
+#endif
__END_DECLS
diff --git a/include/netinet/icmp6.h b/include/netinet/icmp6.h
index 0cb1aa6a6..776f6bdda 100644
--- a/include/netinet/icmp6.h
+++ b/include/netinet/icmp6.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-1997,2000,2006 Free Software Foundation, Inc.
+/* Copyright (C) 1991-1997,2000,2006,2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -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 _NETINET_ICMP6_H
#define _NETINET_ICMP6_H 1
@@ -161,11 +160,11 @@ struct nd_neighbor_advert /* neighbor advertisement */
#define nd_na_code nd_na_hdr.icmp6_code
#define nd_na_cksum nd_na_hdr.icmp6_cksum
#define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
-#if BYTE_ORDER == BIG_ENDIAN
+#if __BYTE_ORDER == __BIG_ENDIAN
#define ND_NA_FLAG_ROUTER 0x80000000
#define ND_NA_FLAG_SOLICITED 0x40000000
#define ND_NA_FLAG_OVERRIDE 0x20000000
-#else /* BYTE_ORDER == LITTLE_ENDIAN */
+#else /* __BYTE_ORDER == __LITTLE_ENDIAN */
#define ND_NA_FLAG_ROUTER 0x00000080
#define ND_NA_FLAG_SOLICITED 0x00000040
#define ND_NA_FLAG_OVERRIDE 0x00000020
@@ -299,10 +298,10 @@ struct rr_pco_use /* use prefix part */
#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x20
#define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x10
-#if BYTE_ORDER == BIG_ENDIAN
+#if __BYTE_ORDER == __BIG_ENDIAN
# define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000
# define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000
-#elif BYTE_ORDER == LITTLE_ENDIAN
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
# define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80
# define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40
#endif
@@ -316,10 +315,10 @@ struct rr_result /* router renumbering result message */
struct in6_addr rrr_prefix;
};
-#if BYTE_ORDER == BIG_ENDIAN
+#if __BYTE_ORDER == __BIG_ENDIAN
# define ICMP6_RR_RESULT_FLAGS_OOB 0x0002
# define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001
-#elif BYTE_ORDER == LITTLE_ENDIAN
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
# define ICMP6_RR_RESULT_FLAGS_OOB 0x0200
# define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100
#endif
@@ -339,7 +338,7 @@ struct nd_opt_home_agent_info
uint8_t nd_opt_home_agent_info_type;
uint8_t nd_opt_home_agent_info_len;
uint16_t nd_opt_home_agent_info_reserved;
- int16_t nd_opt_home_agent_info_preference;
+ uint16_t nd_opt_home_agent_info_preference;
uint16_t nd_opt_home_agent_info_lifetime;
};
diff --git a/include/netinet/if_ether.h b/include/netinet/if_ether.h
index aadb59bea..feb43578e 100644
--- a/include/netinet/if_ether.h
+++ b/include/netinet/if_ether.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 __NETINET_IF_ETHER_H
diff --git a/include/netinet/if_fddi.h b/include/netinet/if_fddi.h
index 1a0ec927d..54372d5aa 100644
--- a/include/netinet/if_fddi.h
+++ b/include/netinet/if_fddi.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 _NETINET_IF_FDDI_H
#define _NETINET_IF_FDDI_H 1
diff --git a/include/netinet/if_tr.h b/include/netinet/if_tr.h
index 45c39115f..6c5ec9b2f 100644
--- a/include/netinet/if_tr.h
+++ b/include/netinet/if_tr.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 _NETINET_IF_TR_H
#define _NETINET_IF_TR_H 1
diff --git a/include/netinet/igmp.h b/include/netinet/igmp.h
index 67396baaa..e40fbabe5 100644
--- a/include/netinet/igmp.h
+++ b/include/netinet/igmp.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 _NETINET_IGMP_H
#define _NETINET_IGMP_H 1
diff --git a/include/netinet/in.h b/include/netinet/in.h
index 6bfc5e780..884d925c9 100644
--- a/include/netinet/in.h
+++ b/include/netinet/in.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2001, 2003, 2004, 2006, 2007
+/* Copyright (C) 1991-2001, 2003, 2004, 2006, 2007, 2008
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 _NETINET_IN_H
#define _NETINET_IN_H 1
@@ -53,6 +52,8 @@ enum
#define IPPROTO_IDP IPPROTO_IDP
IPPROTO_TP = 29, /* SO Transport Protocol Class 4. */
#define IPPROTO_TP IPPROTO_TP
+ IPPROTO_DCCP = 33, /* Datagram Congestion Control Protocol. */
+#define IPPROTO_DCCP IPPROTO_DCCP
IPPROTO_IPV6 = 41, /* IPv6 header. */
#define IPPROTO_IPV6 IPPROTO_IPV6
IPPROTO_ROUTING = 43, /* IPv6 routing header. */
@@ -83,6 +84,8 @@ enum
#define IPPROTO_COMP IPPROTO_COMP
IPPROTO_SCTP = 132, /* Stream Control Transmission Protocol. */
#define IPPROTO_SCTP IPPROTO_SCTP
+ IPPROTO_UDPLITE = 136, /* UDP-Lite protocol. */
+#define IPPROTO_UDPLITE IPPROTO_UDPLITE
IPPROTO_RAW = 255, /* Raw IP packets. */
#define IPPROTO_RAW IPPROTO_RAW
IPPROTO_MAX
@@ -190,33 +193,41 @@ struct in_addr
#define INADDR_MAX_LOCAL_GROUP ((in_addr_t) 0xe00000ff) /* 224.0.0.255 */
+#if defined __UCLIBC_HAS_IPV6__ || !defined __UCLIBC_STRICT_HEADERS__
/* IPv6 address */
struct in6_addr
{
union
{
- uint8_t u6_addr8[16];
- uint16_t u6_addr16[8];
- uint32_t u6_addr32[4];
- } in6_u;
-#define s6_addr in6_u.u6_addr8
-#define s6_addr16 in6_u.u6_addr16
-#define s6_addr32 in6_u.u6_addr32
+ uint8_t __u6_addr8[16];
+#if defined __USE_MISC || defined __USE_GNU
+ uint16_t __u6_addr16[8];
+ uint32_t __u6_addr32[4];
+#endif
+ } __in6_u;
+#define s6_addr __in6_u.__u6_addr8
+#if defined __USE_MISC || defined __USE_GNU
+# define s6_addr16 __in6_u.__u6_addr16
+# define s6_addr32 __in6_u.__u6_addr32
+#endif
};
-extern const struct in6_addr in6addr_any; /* :: */
-extern const struct in6_addr in6addr_loopback; /* ::1 */
#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
-#define INET_ADDRSTRLEN 16
#define INET6_ADDRSTRLEN 46
+#endif
-/* Get the definition of the macro to define the common sockaddr members. */
-#include <bits/socket.h>
+#ifdef __UCLIBC_HAS_IPV6__
+extern const struct in6_addr in6addr_any; /* :: */
+extern const struct in6_addr in6addr_loopback; /* ::1 */
+libc_hidden_proto(in6addr_loopback)
+#endif
+
+#define INET_ADDRSTRLEN 16
-#if 1 /* defined __UCLIBC_HAS_IPV4__ */
+#if 1 /*def __UCLIBC_HAS_IPV4__*/
/* Structure describing an Internet socket address. */
struct sockaddr_in
{
@@ -232,6 +243,7 @@ struct sockaddr_in
};
#endif
+#if defined __UCLIBC_HAS_IPV6__ || !defined __UCLIBC_STRICT_HEADERS__
/* Ditto, for IPv6. */
struct sockaddr_in6
{
@@ -241,8 +253,10 @@ struct sockaddr_in6
struct in6_addr sin6_addr; /* IPv6 address */
uint32_t sin6_scope_id; /* IPv6 scope-id */
};
+#endif
+#if defined __USE_MISC || defined __USE_GNU
/* IPv4 multicast request. */
struct ip_mreq
{
@@ -264,7 +278,10 @@ struct ip_mreq_source
/* IP address of interface. */
struct in_addr imr_sourceaddr;
};
+#endif
+
+#if defined __UCLIBC_HAS_IPV6__ || !defined __UCLIBC_STRICT_HEADERS__
/* Likewise, for IPv6. */
struct ipv6_mreq
{
@@ -274,8 +291,10 @@ struct ipv6_mreq
/* local interface */
unsigned int ipv6mr_interface;
};
+#endif
+#if defined __USE_MISC || defined __USE_GNU
/* Multicast group request. */
struct group_req
{
@@ -342,6 +361,7 @@ struct group_filter
- sizeof (struct sockaddr_storage) \
+ ((numsrc) \
* sizeof (struct sockaddr_storage)))
+#endif
/* Get system-specific definitions. */
@@ -355,12 +375,16 @@ struct group_filter
may have different representations but the values are always the same. */
extern uint32_t ntohl (uint32_t __netlong) __THROW __attribute__ ((__const__));
+libc_hidden_proto(ntohl)
extern uint16_t ntohs (uint16_t __netshort)
__THROW __attribute__ ((__const__));
+libc_hidden_proto(ntohs)
extern uint32_t htonl (uint32_t __hostlong)
__THROW __attribute__ ((__const__));
+libc_hidden_proto(htonl)
extern uint16_t htons (uint16_t __hostshort)
__THROW __attribute__ ((__const__));
+libc_hidden_proto(htons)
#include <endian.h>
@@ -388,73 +412,85 @@ extern uint16_t htons (uint16_t __hostshort)
# endif
#endif
+#if defined __UCLIBC_HAS_IPV6__ || !defined __UCLIBC_STRICT_HEADERS__
#define IN6_IS_ADDR_UNSPECIFIED(a) \
- (((__const uint32_t *) (a))[0] == 0 \
- && ((__const uint32_t *) (a))[1] == 0 \
- && ((__const uint32_t *) (a))[2] == 0 \
- && ((__const uint32_t *) (a))[3] == 0)
+ (((const uint32_t *) (a))[0] == 0 \
+ && ((const uint32_t *) (a))[1] == 0 \
+ && ((const uint32_t *) (a))[2] == 0 \
+ && ((const uint32_t *) (a))[3] == 0)
#define IN6_IS_ADDR_LOOPBACK(a) \
- (((__const uint32_t *) (a))[0] == 0 \
- && ((__const uint32_t *) (a))[1] == 0 \
- && ((__const uint32_t *) (a))[2] == 0 \
- && ((__const uint32_t *) (a))[3] == htonl (1))
+ (((const uint32_t *) (a))[0] == 0 \
+ && ((const uint32_t *) (a))[1] == 0 \
+ && ((const uint32_t *) (a))[2] == 0 \
+ && ((const uint32_t *) (a))[3] == htonl (1))
-#define IN6_IS_ADDR_MULTICAST(a) (((__const uint8_t *) (a))[0] == 0xff)
+#define IN6_IS_ADDR_MULTICAST(a) (((const uint8_t *) (a))[0] == 0xff)
#define IN6_IS_ADDR_LINKLOCAL(a) \
- ((((__const uint32_t *) (a))[0] & htonl (0xffc00000)) \
+ ((((const uint32_t *) (a))[0] & htonl (0xffc00000)) \
== htonl (0xfe800000))
#define IN6_IS_ADDR_SITELOCAL(a) \
- ((((__const uint32_t *) (a))[0] & htonl (0xffc00000)) \
+ ((((const uint32_t *) (a))[0] & htonl (0xffc00000)) \
== htonl (0xfec00000))
#define IN6_IS_ADDR_V4MAPPED(a) \
- ((((__const uint32_t *) (a))[0] == 0) \
- && (((__const uint32_t *) (a))[1] == 0) \
- && (((__const uint32_t *) (a))[2] == htonl (0xffff)))
+ ((((const uint32_t *) (a))[0] == 0) \
+ && (((const uint32_t *) (a))[1] == 0) \
+ && (((const uint32_t *) (a))[2] == htonl (0xffff)))
#define IN6_IS_ADDR_V4COMPAT(a) \
- ((((__const uint32_t *) (a))[0] == 0) \
- && (((__const uint32_t *) (a))[1] == 0) \
- && (((__const uint32_t *) (a))[2] == 0) \
- && (ntohl (((__const uint32_t *) (a))[3]) > 1))
+ ((((const uint32_t *) (a))[0] == 0) \
+ && (((const uint32_t *) (a))[1] == 0) \
+ && (((const uint32_t *) (a))[2] == 0) \
+ && (ntohl (((const uint32_t *) (a))[3]) > 1))
#define IN6_ARE_ADDR_EQUAL(a,b) \
- ((((__const uint32_t *) (a))[0] == ((__const uint32_t *) (b))[0]) \
- && (((__const uint32_t *) (a))[1] == ((__const uint32_t *) (b))[1]) \
- && (((__const uint32_t *) (a))[2] == ((__const uint32_t *) (b))[2]) \
- && (((__const uint32_t *) (a))[3] == ((__const uint32_t *) (b))[3]))
+ ((((const uint32_t *) (a))[0] == ((const uint32_t *) (b))[0]) \
+ && (((const uint32_t *) (a))[1] == ((const uint32_t *) (b))[1]) \
+ && (((const uint32_t *) (a))[2] == ((const uint32_t *) (b))[2]) \
+ && (((const uint32_t *) (a))[3] == ((const uint32_t *) (b))[3]))
+#endif
+#if defined __USE_MISC || defined __USE_GNU
/* Bind socket to a privileged IP port. */
extern int bindresvport (int __sockfd, struct sockaddr_in *__sock_in) __THROW;
+libc_hidden_proto(bindresvport)
+# if 0 /*def __UCLIBC_HAS_IPV6__*/
/* The IPv6 version of this function. */
extern int bindresvport6 (int __sockfd, struct sockaddr_in6 *__sock_in)
__THROW;
+# endif
+#endif
+#if defined __UCLIBC_HAS_IPV6__ || !defined __UCLIBC_STRICT_HEADERS__
#define IN6_IS_ADDR_MC_NODELOCAL(a) \
(IN6_IS_ADDR_MULTICAST(a) \
- && ((((__const uint8_t *) (a))[1] & 0xf) == 0x1))
+ && ((((const uint8_t *) (a))[1] & 0xf) == 0x1))
#define IN6_IS_ADDR_MC_LINKLOCAL(a) \
(IN6_IS_ADDR_MULTICAST(a) \
- && ((((__const uint8_t *) (a))[1] & 0xf) == 0x2))
+ && ((((const uint8_t *) (a))[1] & 0xf) == 0x2))
#define IN6_IS_ADDR_MC_SITELOCAL(a) \
(IN6_IS_ADDR_MULTICAST(a) \
- && ((((__const uint8_t *) (a))[1] & 0xf) == 0x5))
+ && ((((const uint8_t *) (a))[1] & 0xf) == 0x5))
#define IN6_IS_ADDR_MC_ORGLOCAL(a) \
(IN6_IS_ADDR_MULTICAST(a) \
- && ((((__const uint8_t *) (a))[1] & 0xf) == 0x8))
+ && ((((const uint8_t *) (a))[1] & 0xf) == 0x8))
#define IN6_IS_ADDR_MC_GLOBAL(a) \
(IN6_IS_ADDR_MULTICAST(a) \
- && ((((__const uint8_t *) (a))[1] & 0xf) == 0xe))
+ && ((((const uint8_t *) (a))[1] & 0xf) == 0xe))
+#endif
+
+#ifdef __USE_GNU
+# if defined __UCLIBC_HAS_IPV6__ || !defined __UCLIBC_STRICT_HEADERS__
/* IPv6 packet information. */
struct in6_pktinfo
{
@@ -470,22 +506,22 @@ struct ip6_mtuinfo
};
-#if 0 /*def __USE_GNU*/
+# if 0
/* Obsolete hop-by-hop and Destination Options Processing (RFC 2292). */
extern int inet6_option_space (int __nbytes)
__THROW __attribute_deprecated__;
extern int inet6_option_init (void *__bp, struct cmsghdr **__cmsgp,
int __type) __THROW __attribute_deprecated__;
extern int inet6_option_append (struct cmsghdr *__cmsg,
- __const uint8_t *__typep, int __multx,
+ const uint8_t *__typep, int __multx,
int __plusy) __THROW __attribute_deprecated__;
extern uint8_t *inet6_option_alloc (struct cmsghdr *__cmsg, int __datalen,
int __multx, int __plusy)
__THROW __attribute_deprecated__;
-extern int inet6_option_next (__const struct cmsghdr *__cmsg,
+extern int inet6_option_next (const struct cmsghdr *__cmsg,
uint8_t **__tptrp)
__THROW __attribute_deprecated__;
-extern int inet6_option_find (__const struct cmsghdr *__cmsg,
+extern int inet6_option_find (const struct cmsghdr *__cmsg,
uint8_t **__tptrp, int __type)
__THROW __attribute_deprecated__;
@@ -513,13 +549,16 @@ extern int inet6_opt_get_val (void *__databuf, int __offset, void *__val,
extern socklen_t inet6_rth_space (int __type, int __segments) __THROW;
extern void *inet6_rth_init (void *__bp, socklen_t __bp_len, int __type,
int __segments) __THROW;
-extern int inet6_rth_add (void *__bp, __const struct in6_addr *__addr) __THROW;
-extern int inet6_rth_reverse (__const void *__in, void *__out) __THROW;
-extern int inet6_rth_segments (__const void *__bp) __THROW;
-extern struct in6_addr *inet6_rth_getaddr (__const void *__bp, int __index)
+extern int inet6_rth_add (void *__bp, const struct in6_addr *__addr) __THROW;
+extern int inet6_rth_reverse (const void *__in, void *__out) __THROW;
+extern int inet6_rth_segments (const void *__bp) __THROW;
+extern struct in6_addr *inet6_rth_getaddr (const void *__bp, int __index)
__THROW;
+# endif
+# endif
+# if 0
/* Multicast source filter support. */
/* Get IPv4 source filter. */
@@ -532,23 +571,24 @@ extern int getipv4sourcefilter (int __s, struct in_addr __interface_addr,
extern int setipv4sourcefilter (int __s, struct in_addr __interface_addr,
struct in_addr __group, uint32_t __fmode,
uint32_t __numsrc,
- __const struct in_addr *__slist)
+ const struct in_addr *__slist)
__THROW;
/* Get source filter. */
extern int getsourcefilter (int __s, uint32_t __interface_addr,
- __const struct sockaddr *__group,
+ const struct sockaddr *__group,
socklen_t __grouplen, uint32_t *__fmode,
uint32_t *__numsrc,
struct sockaddr_storage *__slist) __THROW;
/* Set source filter. */
extern int setsourcefilter (int __s, uint32_t __interface_addr,
- __const struct sockaddr *__group,
+ const struct sockaddr *__group,
socklen_t __grouplen, uint32_t __fmode,
uint32_t __numsrc,
- __const struct sockaddr_storage *__slist) __THROW;
+ const struct sockaddr_storage *__slist) __THROW;
+# endif
#endif /* use GNU */
__END_DECLS
diff --git a/include/netinet/in_systm.h b/include/netinet/in_systm.h
index 51a08e176..d398d0c9e 100644
--- a/include/netinet/in_systm.h
+++ b/include/netinet/in_systm.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 _NETINET_IN_SYSTM_H
#define _NETINET_IN_SYSTM_H 1
diff --git a/include/netinet/ip.h b/include/netinet/ip.h
index fc9144052..3fe58b9ee 100644
--- a/include/netinet/ip.h
+++ b/include/netinet/ip.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1991,92,93,95,96,97,98,99,2000 Free Software Foundation, Inc.
+/* Copyright (C) 1991,92,93,95,96,97,98,99,2000,2009 Free Software
+ Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -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 __NETINET_IP_H
#define __NETINET_IP_H 1
@@ -153,7 +153,60 @@ struct ip_timestamp
#define IP_MAXPACKET 65535 /* maximum packet size */
/*
- * Definitions for IP type of service (ip_tos)
+ * Definitions for Explicit Congestion Notification (ECN)
+ *
+ * Taken from RFC-3168, Section 5.
+ */
+
+#define IPTOS_ECN_MASK 0x03
+#define IPTOS_ECN(x) ((x) & IPTOS_ECN_MASK)
+#define IPTOS_ECN_NOT_ECT 0x00
+#define IPTOS_ECN_ECT1 0x01
+#define IPTOS_ECN_ECT0 0x02
+#define IPTOS_ECN_CE 0x03
+
+/*
+ * Definitions for IP differentiated services code points (DSCP)
+ *
+ * Taken from RFC-2597, Section 6 and RFC-2598, Section 2.3.
+ */
+
+#define IPTOS_DSCP_MASK 0xfc
+#define IPTOS_DSCP(x) ((x) & IPTOS_DSCP_MASK)
+#define IPTOS_DSCP_AF11 0x28
+#define IPTOS_DSCP_AF12 0x30
+#define IPTOS_DSCP_AF13 0x38
+#define IPTOS_DSCP_AF21 0x48
+#define IPTOS_DSCP_AF22 0x50
+#define IPTOS_DSCP_AF23 0x58
+#define IPTOS_DSCP_AF31 0x68
+#define IPTOS_DSCP_AF32 0x70
+#define IPTOS_DSCP_AF33 0x78
+#define IPTOS_DSCP_AF41 0x88
+#define IPTOS_DSCP_AF42 0x90
+#define IPTOS_DSCP_AF43 0x98
+#define IPTOS_DSCP_EF 0xb8
+
+/*
+ * In RFC 2474, Section 4.2.2.1, the Class Selector Codepoints subsume
+ * the old ToS Precedence values.
+ */
+#define IPTOS_CLASS_MASK 0xe0
+#define IPTOS_CLASS(class) ((class) & IPTOS_CLASS_MASK)
+#define IPTOS_CLASS_CS0 0x00
+#define IPTOS_CLASS_CS1 0x20
+#define IPTOS_CLASS_CS2 0x40
+#define IPTOS_CLASS_CS3 0x60
+#define IPTOS_CLASS_CS4 0x80
+#define IPTOS_CLASS_CS5 0xa0
+#define IPTOS_CLASS_CS6 0xc0
+#define IPTOS_CLASS_CS7 0xe0
+
+#define IPTOS_CLASS_DEFAULT IPTOS_CLASS_CS0
+
+/*
+ * Definitions for IP type of service (ip_tos) [deprecated; use DSCP
+ * and CS definitions above instead.]
*/
#define IPTOS_TOS_MASK 0x1E
#define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK)
@@ -164,18 +217,18 @@ struct ip_timestamp
#define IPTOS_MINCOST IPTOS_LOWCOST
/*
- * Definitions for IP precedence (also in ip_tos) (hopefully unused)
+ * Definitions for IP precedence (also in ip_tos) [also deprecated.]
*/
-#define IPTOS_PREC_MASK 0xe0
-#define IPTOS_PREC(tos) ((tos) & IPTOS_PREC_MASK)
-#define IPTOS_PREC_NETCONTROL 0xe0
-#define IPTOS_PREC_INTERNETCONTROL 0xc0
-#define IPTOS_PREC_CRITIC_ECP 0xa0
-#define IPTOS_PREC_FLASHOVERRIDE 0x80
-#define IPTOS_PREC_FLASH 0x60
-#define IPTOS_PREC_IMMEDIATE 0x40
-#define IPTOS_PREC_PRIORITY 0x20
-#define IPTOS_PREC_ROUTINE 0x00
+#define IPTOS_PREC_MASK IPTOS_CLASS_MASK
+#define IPTOS_PREC(tos) IPTOS_CLASS(tos)
+#define IPTOS_PREC_NETCONTROL IPTOS_CLASS_CS7
+#define IPTOS_PREC_INTERNETCONTROL IPTOS_CLASS_CS6
+#define IPTOS_PREC_CRITIC_ECP IPTOS_CLASS_CS5
+#define IPTOS_PREC_FLASHOVERRIDE IPTOS_CLASS_CS4
+#define IPTOS_PREC_FLASH IPTOS_CLASS_CS3
+#define IPTOS_PREC_IMMEDIATE IPTOS_CLASS_CS2
+#define IPTOS_PREC_PRIORITY IPTOS_CLASS_CS1
+#define IPTOS_PREC_ROUTINE IPTOS_CLASS_CS0
/*
* Definitions for options.
diff --git a/include/netinet/ip6.h b/include/netinet/ip6.h
index bef2af2f5..b4f0f3799 100644
--- a/include/netinet/ip6.h
+++ b/include/netinet/ip6.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 _NETINET_IP6_H
#define _NETINET_IP6_H 1
@@ -102,11 +101,11 @@ struct ip6_frag
uint32_t ip6f_ident; /* identification */
};
-#if BYTE_ORDER == BIG_ENDIAN
+#if __BYTE_ORDER == __BIG_ENDIAN
# define IP6F_OFF_MASK 0xfff8 /* mask out offset from _offlg */
# define IP6F_RESERVED_MASK 0x0006 /* reserved bits in ip6f_offlg */
# define IP6F_MORE_FRAG 0x0001 /* more-fragments flag */
-#else /* BYTE_ORDER == LITTLE_ENDIAN */
+#else /* __BYTE_ORDER == __LITTLE_ENDIAN */
# define IP6F_OFF_MASK 0xf8ff /* mask out offset from _offlg */
# define IP6F_RESERVED_MASK 0x0600 /* reserved bits in ip6f_offlg */
# define IP6F_MORE_FRAG 0x0100 /* more-fragments flag */
@@ -176,11 +175,11 @@ struct ip6_opt_router
};
/* Router alert values (in network byte order) */
-#if BYTE_ORDER == BIG_ENDIAN
+#if __BYTE_ORDER == __BIG_ENDIAN
# define IP6_ALERT_MLD 0x0000
# define IP6_ALERT_RSVP 0x0001
# define IP6_ALERT_AN 0x0002
-#else /* BYTE_ORDER == LITTLE_ENDING */
+#else /* __BYTE_ORDER == __LITTLE_ENDING */
# define IP6_ALERT_MLD 0x0000
# define IP6_ALERT_RSVP 0x0100
# define IP6_ALERT_AN 0x0200
diff --git a/include/netinet/ip_icmp.h b/include/netinet/ip_icmp.h
index 2fc8e9c1c..79788f91c 100644
--- a/include/netinet/ip_icmp.h
+++ b/include/netinet/ip_icmp.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 __NETINET_IP_ICMP_H
#define __NETINET_IP_ICMP_H 1
diff --git a/include/netinet/protocols.h b/include/netinet/protocols.h
deleted file mode 100644
index 1a619c474..000000000
--- a/include/netinet/protocols.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* protocols.h */
-#ifndef _NETINET_PROTOCOLS_H
-#define _NETINET_PROTOCOLS_H
-
-#define IP_ICMP 1
-#define IP_IGMP 2
-#define IP_GGP 3
-#define IP_ST 5
-#define IP_TCP 6
-#define IP_UCL 7
-#define IP_EGP 8
-#define IP_IGP 9
-#define IP_BBN_RCC_MON 10
-#define IP_NVP_II 11
-#define IP_PUP 12
-#define IP_ARGUS 13
-#define IP_EMCON 14
-#define IP_XNET 15
-#define IP_CHAOS 16
-#define IP_UDP 17
-#define IP_MUX 18
-#define IP_DCN_MEAS 19
-#define IP_HMP 20
-#define IP_PRM 21
-#define IP_XNS_IDP 22
-#define IP_TRUNK1 23
-#define IP_TRUNK2 24
-#define IP_LEAF1 25
-#define IP_LEAF2 26
-#define IP_RDP 27
-#define IP_IRTP 28
-#define IP_ISO_TP4 29
-#define IP_NETBLT 30
-#define IP_MFE_NSP 31
-#define IP_MERIT_INP 32
-#define IP_SEP 33
-#define IP_3PC 34
-#define IP_CFTP 62
-#define SAT_EXPAK 64
-#define IP_RVD 66
-#define IP_IPPC 67
-#define IP_SAT_MON 69
-#define IP_VISA 70
-#define IP_IPCV 71
-#define IP_BR_SAT_MON 76
-#define IP_SUN_ND 77
-#define IP_WB_MON 78
-#define IP_WB_EXPAK 79
-#define IP_ISO_IP 80
-#define IP_VMTP 81
-#define IP_SECURE_VMTP 82
-#define IP_VINES 83
-#define IP_TTP 84
-#define NSFNET_IGP 85
-#define IP_DGP 86
-#define IP_TCF 87
-#define IP_IGRP 88
-#define IP_OSPFIGP 89
-#define IP_SPRITE_RPG 90
-#define IP_LARP 91
-
-#endif /* _NETINET_PROTOCOLS_H*/
diff --git a/include/netinet/tcp.h b/include/netinet/tcp.h
index 06e8414b5..04032bb68 100644
--- a/include/netinet/tcp.h
+++ b/include/netinet/tcp.h
@@ -51,6 +51,16 @@
#define TCP_QUICKACK 12 /* Bock/reenable quick ACKs. */
#define TCP_CONGESTION 13 /* Congestion control algorithm. */
#define TCP_MD5SIG 14 /* TCP MD5 Signature (RFC2385) */
+#define TCP_COOKIE_TRANSACTIONS 15 /* TCP Cookie Transactions */
+#define TCP_THIN_LINEAR_TIMEOUTS 16 /* Use linear timeouts for thin streams*/
+#define TCP_THIN_DUPACK 17 /* Fast retrans. after 1 dupack */
+#define TCP_USER_TIMEOUT 18 /* How long for loss retry before timeout */
+#define TCP_REPAIR 19 /* TCP sock is under repair right now */
+#define TCP_REPAIR_QUEUE 20 /* Set TCP queue to repair */
+#define TCP_QUEUE_SEQ 21 /* Set sequence number of repaired queue. */
+#define TCP_REPAIR_OPTIONS 22 /* Repair TCP connection options */
+#define TCP_FASTOPEN 23 /* Enable FastOpen on listeners */
+#define TCP_TIMESTAMP 24 /* TCP time stamp */
#ifdef __USE_MISC
# include <sys/types.h>
diff --git a/include/netinet/udp.h b/include/netinet/udp.h
index 45b69f749..7d4976885 100644
--- a/include/netinet/udp.h
+++ b/include/netinet/udp.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 92, 93, 95, 96, 97, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 1991-1993,1995-1997,2004,2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -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/>. */
/*
* Copyright (C) 1982, 1986 Regents of the University of California.
@@ -74,6 +73,16 @@ struct udphdr
};
#endif
+/* UDP socket options */
+#define UDP_CORK 1 /* Never send partially complete segments. */
+#define UDP_ENCAP 100 /* Set the socket to accept
+ encapsulated packets. */
+
+/* UDP encapsulation types */
+#define UDP_ENCAP_ESPINUDP_NON_IKE 1 /* draft-ietf-ipsec-nat-t-ike-00/01 */
+#define UDP_ENCAP_ESPINUDP 2 /* draft-ietf-ipsec-udp-encaps-06 */
+#define UDP_ENCAP_L2TPINUDP 3 /* rfc2661 */
+
#define SOL_UDP 17 /* sockopt level for UDP */
#endif /* netinet/udp.h */
diff --git a/include/netipx/ipx.h b/include/netipx/ipx.h
index 7eb42ef55..abe981fb8 100644
--- a/include/netipx/ipx.h
+++ b/include/netipx/ipx.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 __NETIPX_IPX_H
#define __NETIPX_IPX_H 1
diff --git a/include/netpacket/packet.h b/include/netpacket/packet.h
index 6c634282f..350a13b10 100644
--- a/include/netpacket/packet.h
+++ b/include/netpacket/packet.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 __NETPACKET_PACKET_H
#define __NETPACKET_PACKET_H 1
diff --git a/include/nl_types.h b/include/nl_types.h
index 74e762113..cb86cf0cd 100644
--- a/include/nl_types.h
+++ b/include/nl_types.h
@@ -12,20 +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/>. */
#ifndef _NL_TYPES_H
#define _NL_TYPES_H 1
#include <features.h>
+#ifndef __UCLIBC_STRICT_HEADERS__
/* The default message set used by the gencat program. */
#define NL_SETD 1
/* Value for FLAG parameter of `catgets' to say we want XPG4 compliance. */
#define NL_CAT_LOCALE 1
+#endif
__BEGIN_DECLS
@@ -34,25 +35,29 @@ __BEGIN_DECLS
#warning "mjn3 FIXME: None of these prototypes have implementations."
#endif
+#ifndef __UCLIBC_STRICT_HEADERS__
/* Message catalog descriptor type. */
typedef void *nl_catd;
+#endif
/* Type used by `nl_langinfo'. */
typedef int nl_item;
+#if 0
/* Open message catalog for later use, returning descriptor.
This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern nl_catd catopen (__const char *__cat_name, int __flag) __nonnull ((1));
+extern nl_catd catopen (const char *__cat_name, int __flag) __nonnull ((1));
/* Return translation with NUMBER in SET of CATALOG; if not found
return STRING. */
extern char *catgets (nl_catd __catalog, int __set, int __number,
- __const char *__string) __THROW __nonnull ((1));
+ const char *__string) __THROW __nonnull ((1));
/* Close message CATALOG. */
extern int catclose (nl_catd __catalog) __THROW __nonnull ((1));
+#endif
__END_DECLS
diff --git a/include/obstack.h b/include/obstack.h
index 244e580ad..8ef0b7a45 100644
--- a/include/obstack.h
+++ b/include/obstack.h
@@ -1,7 +1,7 @@
/* obstack.h - object stack macros
- Copyright (C) 1988,89,90,91,92,93,94,96,97,98,99 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 /gd/gnu/lib.
+ Copyright (C) 1988-1994,1996-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
@@ -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/>. */
/* Summary:
@@ -110,45 +109,36 @@ Summary:
extern "C" {
#endif
-/* We use subtraction of (char *) 0 instead of casting to int
- because on word-addressable machines a simple cast to int
- may ignore the byte-within-word field of the pointer. */
-
-#ifndef __PTR_TO_INT
-# define __PTR_TO_INT(P) ((P) - (char *) 0)
-#endif
-
-#ifndef __INT_TO_PTR
-# define __INT_TO_PTR(P) ((P) + (char *) 0)
-#endif
-
-/* We need the type of the resulting object. If __PTRDIFF_TYPE__ is
+/* We need the type of a pointer subtraction. If __PTRDIFF_TYPE__ is
defined, as with GNU C, use that; that way we don't pollute the
- namespace with <stddef.h>'s symbols. Otherwise, if <stddef.h> is
- available, include it and use ptrdiff_t. In traditional C, long is
- the best that we can do. */
+ namespace with <stddef.h>'s symbols. Otherwise, include <stddef.h>
+ and use ptrdiff_t. */
#ifdef __PTRDIFF_TYPE__
# define PTR_INT_TYPE __PTRDIFF_TYPE__
#else
-# ifdef HAVE_STDDEF_H
-# include <stddef.h>
-# define PTR_INT_TYPE ptrdiff_t
-# else
-# define PTR_INT_TYPE long
-# endif
+# include <stddef.h>
+# define PTR_INT_TYPE ptrdiff_t
#endif
-#if defined _LIBC || defined HAVE_STRING_H
-# include <string.h>
-# define _obstack_memcpy(To, From, N) memcpy ((To), (From), (N))
-#else
-# ifdef memcpy
-# define _obstack_memcpy(To, From, N) memcpy ((To), (From), (N))
-# else
-# define _obstack_memcpy(To, From, N) bcopy ((From), (To), (N))
-# endif
-#endif
+/* If B is the base of an object addressed by P, return the result of
+ aligning P to the next multiple of A + 1. B and P must be of type
+ char *. A + 1 must be a power of 2. */
+
+#define __BPTR_ALIGN(B, P, A) ((B) + (((P) - (B) + (A)) & ~(A)))
+
+/* Similiar to _BPTR_ALIGN (B, P, A), except optimize the common case
+ where pointers can be converted to integers, aligned as integers,
+ and converted back again. If PTR_INT_TYPE is narrower than a
+ pointer (e.g., the AS/400), play it safe and compute the alignment
+ relative to B. Otherwise, use the faster strategy of computing the
+ alignment relative to 0. */
+
+#define __PTR_ALIGN(B, P, A) \
+ __BPTR_ALIGN (sizeof (PTR_INT_TYPE) < sizeof (void *) ? (B) : (char *) 0, \
+ P, A)
+
+#include <string.h>
struct _obstack_chunk /* Lives at front of each chunk. */
{
@@ -164,20 +154,18 @@ struct obstack /* control current object in current chunk */
char *object_base; /* address of object we are building */
char *next_free; /* where to add next char to current object */
char *chunk_limit; /* address of char after current chunk */
- PTR_INT_TYPE temp; /* Temporary for some macros. */
+ union
+ {
+ PTR_INT_TYPE tempint;
+ void *tempptr;
+ } temp; /* Temporary for some macros. */
int alignment_mask; /* Mask of alignment for each object. */
-#if defined __STDC__ && __STDC__
/* These prototypes vary based on `use_extra_arg', and we use
casts to the prototypeless function type in all assignments,
but having prototypes here quiets -Wstrict-prototypes. */
struct _obstack_chunk *(*chunkfun) (void *, long);
void (*freefun) (void *, struct _obstack_chunk *);
void *extra_arg; /* first arg for chunk alloc/dealloc funcs */
-#else
- struct _obstack_chunk *(*chunkfun) (); /* User's fcn to allocate a chunk. */
- void (*freefun) (); /* User's function to free a chunk. */
- char *extra_arg; /* first arg for chunk alloc/dealloc funcs */
-#endif
unsigned use_extra_arg:1; /* chunk alloc/dealloc funcs take extra arg */
unsigned maybe_empty_object:1;/* There is a possibility that the current
chunk contains a zero-length object. This
@@ -190,77 +178,23 @@ struct obstack /* control current object in current chunk */
/* Declare the external functions we use; they are in obstack.c. */
-#if defined __STDC__ && __STDC__
extern void _obstack_newchunk (struct obstack *, int);
-extern void _obstack_free (struct obstack *, void *);
+libc_hidden_proto(_obstack_newchunk)
extern int _obstack_begin (struct obstack *, int, int,
void *(*) (long), void (*) (void *));
extern int _obstack_begin_1 (struct obstack *, int, int,
void *(*) (void *, long),
void (*) (void *, void *), void *);
extern int _obstack_memory_used (struct obstack *);
-#else
-extern void _obstack_newchunk ();
-extern void _obstack_free ();
-extern int _obstack_begin ();
-extern int _obstack_begin_1 ();
-extern int _obstack_memory_used ();
-#endif
-
-#if defined __STDC__ && __STDC__
-
-/* Do the function-declarations after the structs
- but before defining the macros. */
-
-void obstack_init (struct obstack *obstack);
-
-void * obstack_alloc (struct obstack *obstack, int size);
-
-void * obstack_copy (struct obstack *obstack, const void *address, int size);
-void * obstack_copy0 (struct obstack *obstack, const void *address, int size);
void obstack_free (struct obstack *obstack, void *block);
-void obstack_blank (struct obstack *obstack, int size);
-
-void obstack_grow (struct obstack *obstack, const void *data, int size);
-void obstack_grow0 (struct obstack *obstack, const void *data, int size);
-
-void obstack_1grow (struct obstack *obstack, int data_char);
-void obstack_ptr_grow (struct obstack *obstack, const void *data);
-void obstack_int_grow (struct obstack *obstack, int data);
-
-void * obstack_finish (struct obstack *obstack);
-
-int obstack_object_size (struct obstack *obstack);
-
-int obstack_room (struct obstack *obstack);
-void obstack_make_room (struct obstack *obstack, int size);
-void obstack_1grow_fast (struct obstack *obstack, int data_char);
-void obstack_ptr_grow_fast (struct obstack *obstack, const void *data);
-void obstack_int_grow_fast (struct obstack *obstack, int data);
-void obstack_blank_fast (struct obstack *obstack, int size);
-
-void * obstack_base (struct obstack *obstack);
-void * obstack_next_free (struct obstack *obstack);
-int obstack_alignment_mask (struct obstack *obstack);
-int obstack_chunk_size (struct obstack *obstack);
-int obstack_memory_used (struct obstack *obstack);
-
-#endif /* __STDC__ */
-
-/* Non-ANSI C cannot really support alternative functions for these macros,
- so we do not declare them. */
/* Error handler called when `obstack_chunk_alloc' failed to allocate
more memory. This can be set to a user defined function which
should either abort gracefully or use longjump - but shouldn't
return. The default action is to print a message and abort. */
-#if defined __STDC__ && __STDC__
extern void (*obstack_alloc_failed_handler) (void);
-#else
-extern void (*obstack_alloc_failed_handler) ();
-#endif
/* Exit value used when `print_and_abort' is used. */
extern int obstack_exit_failure;
@@ -269,7 +203,7 @@ extern int obstack_exit_failure;
Note that this might not be the final address of the object
because a new chunk might be needed to hold the final size. */
-#define obstack_base(h) ((h)->object_base)
+#define obstack_base(h) ((void *) (h)->object_base)
/* Size for allocating ordinary chunks. */
@@ -283,67 +217,34 @@ extern int obstack_exit_failure;
#define obstack_alignment_mask(h) ((h)->alignment_mask)
-/* To prevent prototype warnings provide complete argument list in
- standard C version. */
-#if defined __STDC__ && __STDC__
-
-# define obstack_init(h) \
+/* To prevent prototype warnings provide complete argument list. */
+#define obstack_init(h) \
_obstack_begin ((h), 0, 0, \
- (void *(*) (long)) obstack_chunk_alloc, \
+ (void *(*) (long)) obstack_chunk_alloc, \
(void (*) (void *)) obstack_chunk_free)
-# define obstack_begin(h, size) \
+#define obstack_begin(h, size) \
_obstack_begin ((h), (size), 0, \
- (void *(*) (long)) obstack_chunk_alloc, \
+ (void *(*) (long)) obstack_chunk_alloc, \
(void (*) (void *)) obstack_chunk_free)
-# define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \
+#define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \
_obstack_begin ((h), (size), (alignment), \
- (void *(*) (long)) (chunkfun), \
+ (void *(*) (long)) (chunkfun), \
(void (*) (void *)) (freefun))
-# define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \
+#define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \
_obstack_begin_1 ((h), (size), (alignment), \
(void *(*) (void *, long)) (chunkfun), \
(void (*) (void *, void *)) (freefun), (arg))
-# define obstack_chunkfun(h, newchunkfun) \
+#define obstack_chunkfun(h, newchunkfun) \
((h) -> chunkfun = (struct _obstack_chunk *(*)(void *, long)) (newchunkfun))
-# define obstack_freefun(h, newfreefun) \
+#define obstack_freefun(h, newfreefun) \
((h) -> freefun = (void (*)(void *, struct _obstack_chunk *)) (newfreefun))
-#else
-
-# define obstack_init(h) \
- _obstack_begin ((h), 0, 0, \
- (void *(*) ()) obstack_chunk_alloc, \
- (void (*) ()) obstack_chunk_free)
-
-# define obstack_begin(h, size) \
- _obstack_begin ((h), (size), 0, \
- (void *(*) ()) obstack_chunk_alloc, \
- (void (*) ()) obstack_chunk_free)
-
-# define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \
- _obstack_begin ((h), (size), (alignment), \
- (void *(*) ()) (chunkfun), \
- (void (*) ()) (freefun))
-
-# define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \
- _obstack_begin_1 ((h), (size), (alignment), \
- (void *(*) ()) (chunkfun), \
- (void (*) ()) (freefun), (arg))
-
-# define obstack_chunkfun(h, newchunkfun) \
- ((h) -> chunkfun = (struct _obstack_chunk *(*)()) (newchunkfun))
-
-# define obstack_freefun(h, newfreefun) \
- ((h) -> freefun = (void (*)()) (newfreefun))
-
-#endif
-
-#define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = achar)
+#define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = (achar))
#define obstack_blank_fast(h,n) ((h)->next_free += (n))
@@ -364,12 +265,12 @@ extern int obstack_exit_failure;
# define obstack_object_size(OBSTACK) \
__extension__ \
- ({ struct obstack *__o = (OBSTACK); \
+ ({ struct obstack const *__o = (OBSTACK); \
(unsigned) (__o->next_free - __o->object_base); })
# define obstack_room(OBSTACK) \
__extension__ \
- ({ struct obstack *__o = (OBSTACK); \
+ ({ struct obstack const *__o = (OBSTACK); \
(unsigned) (__o->chunk_limit - __o->next_free); })
# define obstack_make_room(OBSTACK,length) \
@@ -382,8 +283,11 @@ __extension__ \
# define obstack_empty_p(OBSTACK) \
__extension__ \
- ({ struct obstack *__o = (OBSTACK); \
- (__o->chunk->prev == 0 && __o->next_free - __o->chunk->contents == 0); })
+ ({ struct obstack const *__o = (OBSTACK); \
+ (__o->chunk->prev == 0 \
+ && __o->next_free == __PTR_ALIGN ((char *) __o->chunk, \
+ __o->chunk->contents, \
+ __o->alignment_mask)); })
# define obstack_grow(OBSTACK,where,length) \
__extension__ \
@@ -391,7 +295,7 @@ __extension__ \
int __len = (length); \
if (__o->next_free + __len > __o->chunk_limit) \
_obstack_newchunk (__o, __len); \
- _obstack_memcpy (__o->next_free, (where), __len); \
+ memcpy (__o->next_free, where, __len); \
__o->next_free += __len; \
(void) 0; })
@@ -401,7 +305,7 @@ __extension__ \
int __len = (length); \
if (__o->next_free + __len + 1 > __o->chunk_limit) \
_obstack_newchunk (__o, __len + 1); \
- _obstack_memcpy (__o->next_free, (where), __len); \
+ memcpy (__o->next_free, where, __len); \
__o->next_free += __len; \
*(__o->next_free)++ = 0; \
(void) 0; })
@@ -411,7 +315,7 @@ __extension__ \
({ struct obstack *__o = (OBSTACK); \
if (__o->next_free + 1 > __o->chunk_limit) \
_obstack_newchunk (__o, 1); \
- *(__o->next_free)++ = (datum); \
+ obstack_1grow_fast (__o, datum); \
(void) 0; })
/* These assume that the obstack alignment is good enough for pointers
@@ -423,22 +327,28 @@ __extension__ \
({ struct obstack *__o = (OBSTACK); \
if (__o->next_free + sizeof (void *) > __o->chunk_limit) \
_obstack_newchunk (__o, sizeof (void *)); \
- *((void **)__o->next_free)++ = (datum); \
- (void) 0; })
+ obstack_ptr_grow_fast (__o, datum); }) \
# define obstack_int_grow(OBSTACK,datum) \
__extension__ \
({ struct obstack *__o = (OBSTACK); \
if (__o->next_free + sizeof (int) > __o->chunk_limit) \
_obstack_newchunk (__o, sizeof (int)); \
- *((int *)__o->next_free)++ = (datum); \
- (void) 0; })
+ obstack_int_grow_fast (__o, datum); })
-# define obstack_ptr_grow_fast(h,aptr) \
- (*((void **) (h)->next_free)++ = (aptr))
+# define obstack_ptr_grow_fast(OBSTACK,aptr) \
+__extension__ \
+({ struct obstack *__o1 = (OBSTACK); \
+ *(const void **) __o1->next_free = (aptr); \
+ __o1->next_free += sizeof (const void *); \
+ (void) 0; })
-# define obstack_int_grow_fast(h,aint) \
- (*((int *) (h)->next_free)++ = (aint))
+# define obstack_int_grow_fast(OBSTACK,aint) \
+__extension__ \
+({ struct obstack *__o1 = (OBSTACK); \
+ *(int *) __o1->next_free = (aint); \
+ __o1->next_free += sizeof (int); \
+ (void) 0; })
# define obstack_blank(OBSTACK,length) \
__extension__ \
@@ -446,7 +356,7 @@ __extension__ \
int __len = (length); \
if (__o->chunk_limit - __o->next_free < __len) \
_obstack_newchunk (__o, __len); \
- __o->next_free += __len; \
+ obstack_blank_fast (__o, __len); \
(void) 0; })
# define obstack_alloc(OBSTACK,length) \
@@ -469,21 +379,20 @@ __extension__ \
/* The local variable is named __o1 to avoid a name conflict
when obstack_blank is called. */
-# define obstack_finish(OBSTACK) \
+# define obstack_finish(OBSTACK) \
__extension__ \
({ struct obstack *__o1 = (OBSTACK); \
- void *value; \
- value = (void *) __o1->object_base; \
- if (__o1->next_free == value) \
+ void *__value = (void *) __o1->object_base; \
+ if (__o1->next_free == __value) \
__o1->maybe_empty_object = 1; \
__o1->next_free \
- = __INT_TO_PTR ((__PTR_TO_INT (__o1->next_free)+__o1->alignment_mask)\
- & ~ (__o1->alignment_mask)); \
+ = __PTR_ALIGN (__o1->object_base, __o1->next_free, \
+ __o1->alignment_mask); \
if (__o1->next_free - (char *)__o1->chunk \
> __o1->chunk_limit - (char *)__o1->chunk) \
__o1->next_free = __o1->chunk_limit; \
__o1->object_base = __o1->next_free; \
- value; })
+ __value; })
# define obstack_free(OBSTACK, OBJ) \
__extension__ \
@@ -502,7 +411,10 @@ __extension__ \
(unsigned) ((h)->chunk_limit - (h)->next_free)
# define obstack_empty_p(h) \
- ((h)->chunk->prev == 0 && (h)->next_free - (h)->chunk->contents == 0)
+ ((h)->chunk->prev == 0 \
+ && (h)->next_free == __PTR_ALIGN ((char *) (h)->chunk, \
+ (h)->chunk->contents, \
+ (h)->alignment_mask))
/* Note that the call to _obstack_newchunk is enclosed in (..., 0)
so that we can avoid having void expressions
@@ -511,51 +423,51 @@ __extension__ \
but some compilers won't accept it. */
# define obstack_make_room(h,length) \
-( (h)->temp = (length), \
- (((h)->next_free + (h)->temp > (h)->chunk_limit) \
- ? (_obstack_newchunk ((h), (h)->temp), 0) : 0))
+( (h)->temp.tempint = (length), \
+ (((h)->next_free + (h)->temp.tempint > (h)->chunk_limit) \
+ ? (_obstack_newchunk ((h), (h)->temp.tempint), 0) : 0))
# define obstack_grow(h,where,length) \
-( (h)->temp = (length), \
- (((h)->next_free + (h)->temp > (h)->chunk_limit) \
- ? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \
- _obstack_memcpy ((h)->next_free, (where), (h)->temp), \
- (h)->next_free += (h)->temp)
+( (h)->temp.tempint = (length), \
+ (((h)->next_free + (h)->temp.tempint > (h)->chunk_limit) \
+ ? (_obstack_newchunk ((h), (h)->temp.tempint), 0) : 0), \
+ memcpy ((h)->next_free, where, (h)->temp.tempint), \
+ (h)->next_free += (h)->temp.tempint)
# define obstack_grow0(h,where,length) \
-( (h)->temp = (length), \
- (((h)->next_free + (h)->temp + 1 > (h)->chunk_limit) \
- ? (_obstack_newchunk ((h), (h)->temp + 1), 0) : 0), \
- _obstack_memcpy ((h)->next_free, (where), (h)->temp), \
- (h)->next_free += (h)->temp, \
+( (h)->temp.tempint = (length), \
+ (((h)->next_free + (h)->temp.tempint + 1 > (h)->chunk_limit) \
+ ? (_obstack_newchunk ((h), (h)->temp.tempint + 1), 0) : 0), \
+ memcpy ((h)->next_free, where, (h)->temp.tempint), \
+ (h)->next_free += (h)->temp.tempint, \
*((h)->next_free)++ = 0)
# define obstack_1grow(h,datum) \
( (((h)->next_free + 1 > (h)->chunk_limit) \
? (_obstack_newchunk ((h), 1), 0) : 0), \
- (*((h)->next_free)++ = (datum)))
+ obstack_1grow_fast (h, datum))
# define obstack_ptr_grow(h,datum) \
( (((h)->next_free + sizeof (char *) > (h)->chunk_limit) \
? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0), \
- (*((const char **) (((h)->next_free+=sizeof(char *))-sizeof(char *))) = (datum)))
+ obstack_ptr_grow_fast (h, datum))
# define obstack_int_grow(h,datum) \
( (((h)->next_free + sizeof (int) > (h)->chunk_limit) \
? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \
- (*((int *) (((h)->next_free+=sizeof(int))-sizeof(int))) = (datum)))
+ obstack_int_grow_fast (h, datum))
# define obstack_ptr_grow_fast(h,aptr) \
- (*((const char **) (h)->next_free)++ = (aptr))
+ (((const void **) ((h)->next_free += sizeof (void *)))[-1] = (aptr))
# define obstack_int_grow_fast(h,aint) \
- (*((int *) (h)->next_free)++ = (aint))
+ (((int *) ((h)->next_free += sizeof (int)))[-1] = (aint))
# define obstack_blank(h,length) \
-( (h)->temp = (length), \
- (((h)->chunk_limit - (h)->next_free < (h)->temp) \
- ? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \
- ((h)->next_free += (h)->temp))
+( (h)->temp.tempint = (length), \
+ (((h)->chunk_limit - (h)->next_free < (h)->temp.tempint) \
+ ? (_obstack_newchunk ((h), (h)->temp.tempint), 0) : 0), \
+ obstack_blank_fast (h, (h)->temp.tempint))
# define obstack_alloc(h,length) \
(obstack_blank ((h), (length)), obstack_finish ((h)))
@@ -566,35 +478,27 @@ __extension__ \
# define obstack_copy0(h,where,length) \
(obstack_grow0 ((h), (where), (length)), obstack_finish ((h)))
-# define obstack_finish(h) \
+# define obstack_finish(h) \
( ((h)->next_free == (h)->object_base \
? (((h)->maybe_empty_object = 1), 0) \
: 0), \
- (h)->temp = __PTR_TO_INT ((h)->object_base), \
+ (h)->temp.tempptr = (h)->object_base, \
(h)->next_free \
- = __INT_TO_PTR ((__PTR_TO_INT ((h)->next_free)+(h)->alignment_mask) \
- & ~ ((h)->alignment_mask)), \
+ = __PTR_ALIGN ((h)->object_base, (h)->next_free, \
+ (h)->alignment_mask), \
(((h)->next_free - (char *) (h)->chunk \
> (h)->chunk_limit - (char *) (h)->chunk) \
? ((h)->next_free = (h)->chunk_limit) : 0), \
(h)->object_base = (h)->next_free, \
- __INT_TO_PTR ((h)->temp))
+ (h)->temp.tempptr)
-# if defined __STDC__ && __STDC__
-# define obstack_free(h,obj) \
-( (h)->temp = (char *) (obj) - (char *) (h)->chunk, \
- (((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\
- ? (int) ((h)->next_free = (h)->object_base \
- = (h)->temp + (char *) (h)->chunk) \
- : (((obstack_free) ((h), (h)->temp + (char *) (h)->chunk), 0), 0)))
-# else
-# define obstack_free(h,obj) \
-( (h)->temp = (char *) (obj) - (char *) (h)->chunk, \
- (((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\
+# define obstack_free(h,obj) \
+( (h)->temp.tempint = (char *) (obj) - (char *) (h)->chunk, \
+ ((((h)->temp.tempint > 0 \
+ && (h)->temp.tempint < (h)->chunk_limit - (char *) (h)->chunk)) \
? (int) ((h)->next_free = (h)->object_base \
- = (h)->temp + (char *) (h)->chunk) \
- : (_obstack_free ((h), (h)->temp + (char *) (h)->chunk), 0)))
-# endif
+ = (h)->temp.tempint + (char *) (h)->chunk) \
+ : (((obstack_free) ((h), (h)->temp.tempint + (char *) (h)->chunk), 0), 0)))
#endif /* not __GNUC__ or not __STDC__ */
diff --git a/include/paths.h b/include/paths.h
index ae892c4cf..0b4035d22 100644
--- a/include/paths.h
+++ b/include/paths.h
@@ -44,6 +44,7 @@
#define _PATH_DEVDB "/var/run/dev.db"
#define _PATH_DEVNULL "/dev/null"
#define _PATH_DRUM "/dev/drum"
+#define _PATH_GSHADOW "/etc/gshadow"
#define _PATH_KLOG "/proc/kmsg"
#define _PATH_KMEM "/dev/kmem"
#define _PATH_LASTLOG "/var/log/lastlog"
@@ -64,7 +65,6 @@
#define _PATH_VI "/usr/bin/vi"
#define _PATH_WTMP "/var/log/wtmp"
-/* uClibc */
#ifdef _LIBC
#define _PATH_PASSWD "/etc/passwd"
#define _PATH_GROUP "/etc/group"
diff --git a/include/printf.h b/include/printf.h
index 72dffaab4..c6467a0ef 100644
--- a/include/printf.h
+++ b/include/printf.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/>. */
/* March 11, 2001 Manuel Novoa III
*
@@ -41,7 +40,7 @@ __BEGIN_DECLS
* need to support bitfields since that's what glibc made visible to users.
* So, we take
* advantage of how gcc lays out bitfields to create an appropriate
- * mapping. Inside uclibc (UCLIBC_INTERNAL is defined) we access the
+ * mapping. Inside uclibc (i.e. if _LIBC is defined) we access the
* bitfields using bitmasks in a single flag variable.
*
* WARNING -- This may very well fail if built with -fpack-struct!!!
@@ -61,7 +60,7 @@ struct printf_info {
int spec;
#endif
-#ifndef UCLIBC_INTERNAL
+#ifndef _LIBC
#if __BYTE_ORDER == __LITTLE_ENDIAN
unsigned int space:1; /* Space flag. */
@@ -95,7 +94,7 @@ struct printf_info {
#error unsupported byte order!
#endif
-#else /* UCLIBC_INTERNAL */
+#else /* _LIBC */
uint32_t _flags; /* non-gnu */
#define __PRINT_INFO_FLAG_space (1<<0)
@@ -121,7 +120,7 @@ struct printf_info {
#define PRINT_INFO_SET_extra(INFO_PTR,VAL) \
((INFO_PTR)->_flags |= (((INFO_PTR)->_flags & ~1) | ((VAL) & 1)))
-#endif /* UCLIBC_INTERNAL */
+#endif /* _LIBC */
#ifdef __UCLIBC_HAS_WCHAR__
wchar_t pad; /* Padding character. */
@@ -143,14 +142,14 @@ struct printf_info {
#ifdef __UCLIBC_HAS_GLIBC_CUSTOM_PRINTF__
typedef int (*printf_function) (FILE *__stream,
- __const struct printf_info *__info,
- __const void *__const *__args);
+ const struct printf_info *__info,
+ const void *const *__args);
/* Type of a printf specifier-arginfo function.
INFO gives information about the format specification.
N, ARGTYPES, and return value are as for parse_printf_format. */
-typedef int printf_arginfo_function (__const struct printf_info *__info,
+typedef int printf_arginfo_function (const struct printf_info *__info,
size_t __n, int *__argtypes);
@@ -174,7 +173,7 @@ extern int register_printf_function (int __spec, printf_function __func,
array it is passed with the types of the arguments it wants, and return
the number of arguments it wants. */
-extern size_t parse_printf_format (__const char *__restrict __fmt, size_t __n,
+extern size_t parse_printf_format (const char *__restrict __fmt, size_t __n,
int *__restrict __argtypes) __THROW;
@@ -222,11 +221,11 @@ enum { /* C type: */
the format specifier is a uppercase character powers of 1000 are
used. Otherwise powers of 1024. */
extern int printf_size (FILE *__restrict __fp,
- __const struct printf_info *__info,
- __const void *__const *__restrict __args) __THROW;
+ const struct printf_info *__info,
+ const void *const *__restrict __args) __THROW;
/* This is the appropriate argument information function for `printf_size'. */
-extern int printf_size_info (__const struct printf_info *__restrict
+extern int printf_size_info (const struct printf_info *__restrict
__info, size_t __n, int *__restrict __argtypes)
__THROW;
diff --git a/include/protocols/timed.h b/include/protocols/timed.h
index 4345bed47..f50061cc1 100644
--- a/include/protocols/timed.h
+++ b/include/protocols/timed.h
@@ -32,14 +32,17 @@
#ifndef _PROTOCOLS_TIMED_H
#define _PROTOCOLS_TIMED_H 1
+#include <features.h>
+#ifdef __UCLIBC_HAS_RPC__
#include <rpc/types.h>
+#endif
/*
* Time Synchronization Protocol
*/
#define TSPVERSION 1
-#define ANYADDR NULL
+#define ANYADDR NULL
struct tsp {
u_char tsp_type;
diff --git a/include/pty.h b/include/pty.h
index 2d4b5e270..f23a260ae 100644
--- a/include/pty.h
+++ b/include/pty.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 _PTY_H
#define _PTY_H 1
@@ -33,6 +32,7 @@ __BEGIN_DECLS
ends in AMASTER and ASLAVE. */
extern int openpty (int *__amaster, int *__aslave, char *__name,
struct termios *__termp, struct winsize *__winp) __THROW;
+libutil_hidden_proto(openpty)
/* Create child process and establish the slave pseudo terminal as the
child's controlling terminal. */
diff --git a/include/pwd.h b/include/pwd.h
index e87413304..72475a61d 100644
--- a/include/pwd.h
+++ b/include/pwd.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: 9.2.2 User Database Access <pwd.h>
@@ -100,7 +99,7 @@ extern struct passwd *fgetpwent (FILE *__stream);
cancellation point. But due to similarity with an POSIX interface
or due to the implementation it is a cancellation point and
therefore not marked with __THROW. */
-extern int putpwent (__const struct passwd *__restrict __p,
+extern int putpwent (const struct passwd *__restrict __p,
FILE *__restrict __f);
#endif
@@ -114,7 +113,8 @@ extern struct passwd *getpwuid (__uid_t __uid);
This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern struct passwd *getpwnam (__const char *__name);
+extern struct passwd *getpwnam (const char *__name);
+libc_hidden_proto(getpwnam)
#if defined __USE_POSIX || defined __USE_MISC
@@ -140,17 +140,20 @@ extern struct passwd *getpwnam (__const char *__name);
extern int getpwent_r (struct passwd *__restrict __resultbuf,
char *__restrict __buffer, size_t __buflen,
struct passwd **__restrict __result);
+libc_hidden_proto(getpwent_r)
# endif
extern int getpwuid_r (__uid_t __uid,
struct passwd *__restrict __resultbuf,
char *__restrict __buffer, size_t __buflen,
struct passwd **__restrict __result);
+libc_hidden_proto(getpwuid_r)
-extern int getpwnam_r (__const char *__restrict __name,
+extern int getpwnam_r (const char *__restrict __name,
struct passwd *__restrict __resultbuf,
char *__restrict __buffer, size_t __buflen,
struct passwd **__restrict __result);
+libc_hidden_proto(getpwnam_r)
# ifdef __USE_SVID
@@ -165,6 +168,7 @@ extern int fgetpwent_r (FILE *__restrict __stream,
struct passwd *__restrict __resultbuf,
char *__restrict __buffer, size_t __buflen,
struct passwd **__restrict __result);
+libc_hidden_proto(fgetpwent_r)
# endif
#endif /* POSIX or reentrant */
diff --git a/include/regex.h b/include/regex.h
index 5bd3088e5..94d893073 100644
--- a/include/regex.h
+++ b/include/regex.h
@@ -1,6 +1,6 @@
/* Definitions for data structures and routines for the regular
expression library.
- Copyright (C) 1985,1989-93,1995-98,2000,2001,2002,2003,2005
+ Copyright (C) 1985,1989-93,1995-98,2000,2001,2002,2003,2005,2006,2008
Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -15,28 +15,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 _REGEX_H
#define _REGEX_H 1
#include <sys/types.h>
-/* Allow the use in C++ code. */
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* POSIX says that <sys/types.h> must be included (by the caller) before
- <regex.h>. */
-
-#if !defined _POSIX_C_SOURCE && !defined _POSIX_SOURCE && defined VMS
-/* VMS doesn't have `size_t' in <sys/types.h>, even though POSIX says it
- should be there. */
-# include <stddef.h>
-#endif
+__BEGIN_DECLS
/* The following two types have to be signed and unsigned integer type
wide enough to hold a value of a pointer. For most ANSI compilers
@@ -52,20 +39,21 @@ typedef unsigned long int active_reg_t;
add or remove a bit, only one other definition need change. */
typedef unsigned long int reg_syntax_t;
+#ifdef __USE_GNU
/* If this bit is not set, then \ inside a bracket expression is literal.
If set, then such a \ quotes the following character. */
-#define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1)
+# define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1)
/* If this bit is not set, then + and ? are operators, and \+ and \? are
literals.
If set, then \+ and \? are operators and + and ? are literals. */
-#define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1)
+# define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1)
/* If this bit is set, then character classes are supported. They are:
[:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:],
[:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
If not set, then character classes are not supported. */
-#define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1)
+# define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1)
/* If this bit is set, then ^ and $ are always anchors (outside bracket
expressions, of course).
@@ -79,7 +67,7 @@ typedef unsigned long int reg_syntax_t;
POSIX draft 11.2 says that * etc. in leading positions is undefined.
We already implemented a previous draft which made those constructs
invalid, though, so we haven't changed the code back. */
-#define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1)
+# define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1)
/* If this bit is set, then special characters are always special
regardless of where they are in the pattern.
@@ -87,71 +75,71 @@ typedef unsigned long int reg_syntax_t;
some contexts; otherwise they are ordinary. Specifically,
* + ? and intervals are only special when not after the beginning,
open-group, or alternation operator. */
-#define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1)
+# define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1)
/* If this bit is set, then *, +, ?, and { cannot be first in an re or
immediately after an alternation or begin-group operator. */
-#define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1)
+# define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1)
/* If this bit is set, then . matches newline.
If not set, then it doesn't. */
-#define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1)
+# define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1)
/* If this bit is set, then . doesn't match NUL.
If not set, then it does. */
-#define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1)
+# define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1)
/* If this bit is set, nonmatching lists [^...] do not match newline.
If not set, they do. */
-#define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1)
+# define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1)
/* If this bit is set, either \{...\} or {...} defines an
interval, depending on RE_NO_BK_BRACES.
If not set, \{, \}, {, and } are literals. */
-#define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1)
+# define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1)
/* If this bit is set, +, ? and | aren't recognized as operators.
If not set, they are. */
-#define RE_LIMITED_OPS (RE_INTERVALS << 1)
+# define RE_LIMITED_OPS (RE_INTERVALS << 1)
/* If this bit is set, newline is an alternation operator.
If not set, newline is literal. */
-#define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1)
+# define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1)
/* If this bit is set, then `{...}' defines an interval, and \{ and \}
are literals.
If not set, then `\{...\}' defines an interval. */
-#define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1)
+# define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1)
/* If this bit is set, (...) defines a group, and \( and \) are literals.
If not set, \(...\) defines a group, and ( and ) are literals. */
-#define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1)
+# define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1)
/* If this bit is set, then \<digit> matches <digit>.
If not set, then \<digit> is a back-reference. */
-#define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1)
+# define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1)
/* If this bit is set, then | is an alternation operator, and \| is literal.
If not set, then \| is an alternation operator, and | is literal. */
-#define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1)
+# define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1)
/* If this bit is set, then an ending range point collating higher
than the starting range point, as in [z-a], is invalid.
If not set, then when ending range point collates higher than the
starting range point, the range is ignored. */
-#define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1)
+# define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1)
/* If this bit is set, then an unmatched ) is ordinary.
If not set, then an unmatched ) is invalid. */
-#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1)
+# define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1)
/* If this bit is set, succeed as soon as we match the whole pattern,
without further backtracking. */
-#define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1)
+# define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1)
/* If this bit is set, do not process the GNU regex operators.
If not set, then the GNU regex operators are recognized. */
-#define RE_NO_GNU_OPS (RE_NO_POSIX_BACKTRACKING << 1)
+# define RE_NO_GNU_OPS (RE_NO_POSIX_BACKTRACKING << 1)
/* If this bit is set, turn on internal regex debugging.
If not set, and debugging was on, turn it off.
@@ -159,29 +147,30 @@ typedef unsigned long int reg_syntax_t;
We define this bit always, so that all that's needed to turn on
debugging is to recompile regex.c; the calling code can always have
this bit set, and it won't affect anything in the normal case. */
-#define RE_DEBUG (RE_NO_GNU_OPS << 1)
+# define RE_DEBUG (RE_NO_GNU_OPS << 1)
/* If this bit is set, a syntactically invalid interval is treated as
a string of ordinary characters. For example, the ERE 'a{1' is
treated as 'a\{1'. */
-#define RE_INVALID_INTERVAL_ORD (RE_DEBUG << 1)
+# define RE_INVALID_INTERVAL_ORD (RE_DEBUG << 1)
/* If this bit is set, then ignore case when matching.
If not set, then case is significant. */
-#define RE_ICASE (RE_INVALID_INTERVAL_ORD << 1)
+# define RE_ICASE (RE_INVALID_INTERVAL_ORD << 1)
/* This bit is used internally like RE_CONTEXT_INDEP_ANCHORS but only
for ^, because it is difficult to scan the regex backwards to find
whether ^ should be special. */
-#define RE_CARET_ANCHORS_HERE (RE_ICASE << 1)
+# define RE_CARET_ANCHORS_HERE (RE_ICASE << 1)
/* If this bit is set, then \{ cannot be first in an bre or
immediately after an alternation or begin-group operator. */
-#define RE_CONTEXT_INVALID_DUP (RE_CARET_ANCHORS_HERE << 1)
+# define RE_CONTEXT_INVALID_DUP (RE_CARET_ANCHORS_HERE << 1)
/* If this bit is set, then no_sub will be set to 1 during
re_compile_pattern. */
-#define RE_NO_SUB (RE_CONTEXT_INVALID_DUP << 1)
+# define RE_NO_SUB (RE_CONTEXT_INVALID_DUP << 1)
+#endif
/* This global variable defines the particular regexp syntax to use (for
some interfaces). When a regexp is compiled, the syntax used is
@@ -189,6 +178,7 @@ typedef unsigned long int reg_syntax_t;
already-compiled regexps. */
extern reg_syntax_t re_syntax_options;
+#ifdef __USE_GNU
/* Define combinations of the above bits for the standard possibilities.
(The [[[ comments delimit what gets put into the Texinfo file, so
don't delete them!) */
@@ -263,11 +253,12 @@ extern reg_syntax_t re_syntax_options;
/* Maximum number of duplicates an interval can allow. Some systems
(erroneously) define this in other header files, but we want our
value, so remove any previous define. */
-#ifdef RE_DUP_MAX
-# undef RE_DUP_MAX
-#endif
+# ifdef RE_DUP_MAX
+# undef RE_DUP_MAX
+# endif
/* If sizeof(int) == 2, then ((1 << 15) - 1) overflows. */
-#define RE_DUP_MAX (0x7fff)
+# define RE_DUP_MAX (0x7fff)
+#endif
/* POSIX `cflags' bits (i.e., information for `regcomp'). */
@@ -311,7 +302,7 @@ extern reg_syntax_t re_syntax_options;
`re_error_msg' table in regex.c. */
typedef enum
{
-#ifdef _XOPEN_SOURCE
+#if defined _XOPEN_SOURCE || defined __USE_XOPEN2K
REG_ENOSYS = -1, /* This will never happen for this implementation. */
#endif
@@ -346,7 +337,16 @@ typedef enum
private to the regex routines. */
#ifndef RE_TRANSLATE_TYPE
-# define RE_TRANSLATE_TYPE unsigned char *
+# define __RE_TRANSLATE_TYPE unsigned char *
+# ifdef __USE_GNU
+# define RE_TRANSLATE_TYPE __RE_TRANSLATE_TYPE
+# endif
+#endif
+
+#ifdef __USE_GNU
+# define __REPB_PREFIX(name) name
+#else
+# define __REPB_PREFIX(name) __##name
#endif
struct re_pattern_buffer
@@ -354,27 +354,27 @@ struct re_pattern_buffer
/* Space that holds the compiled pattern. It is declared as
`unsigned char *' because its elements are sometimes used as
array indexes. */
- unsigned char *buffer;
+ unsigned char *__REPB_PREFIX(buffer);
/* Number of bytes to which `buffer' points. */
- unsigned long int allocated;
+ unsigned long int __REPB_PREFIX(allocated);
/* Number of bytes actually used in `buffer'. */
- unsigned long int used;
+ unsigned long int __REPB_PREFIX(used);
/* Syntax setting with which the pattern was compiled. */
- reg_syntax_t syntax;
+ reg_syntax_t __REPB_PREFIX(syntax);
/* Pointer to a fastmap, if any, otherwise zero. re_search uses the
fastmap, if there is one, to skip over impossible starting points
for matches. */
- char *fastmap;
+ char *__REPB_PREFIX(fastmap);
/* Either a translate table to apply to all characters before
comparing them, or zero for no translation. The translation is
applied to a pattern when it is compiled and to a string when it
is matched. */
- RE_TRANSLATE_TYPE translate;
+ __RE_TRANSLATE_TYPE __REPB_PREFIX(translate);
/* Number of subexpressions found by the compiler. */
size_t re_nsub;
@@ -383,34 +383,36 @@ struct re_pattern_buffer
Well, in truth it's used only in `re_search_2', to see whether or
not we should use the fastmap, so we don't set this absolutely
perfectly; see `re_compile_fastmap' (the `duplicate' case). */
- unsigned can_be_null : 1;
+ unsigned __REPB_PREFIX(can_be_null) : 1;
/* If REGS_UNALLOCATED, allocate space in the `regs' structure
for `max (RE_NREGS, re_nsub + 1)' groups.
If REGS_REALLOCATE, reallocate space if necessary.
If REGS_FIXED, use what's there. */
-#define REGS_UNALLOCATED 0
-#define REGS_REALLOCATE 1
-#define REGS_FIXED 2
- unsigned regs_allocated : 2;
+#ifdef __USE_GNU
+# define REGS_UNALLOCATED 0
+# define REGS_REALLOCATE 1
+# define REGS_FIXED 2
+#endif
+ unsigned __REPB_PREFIX(regs_allocated) : 2;
/* Set to zero when `regex_compile' compiles a pattern; set to one
by `re_compile_fastmap' if it updates the fastmap. */
- unsigned fastmap_accurate : 1;
+ unsigned __REPB_PREFIX(fastmap_accurate) : 1;
/* If set, `re_match_2' does not return information about
subexpressions. */
- unsigned no_sub : 1;
+ unsigned __REPB_PREFIX(no_sub) : 1;
/* If set, a beginning-of-line anchor doesn't match at the beginning
of the string. */
- unsigned not_bol : 1;
+ unsigned __REPB_PREFIX(not_bol) : 1;
/* Similarly for an end-of-line anchor. */
- unsigned not_eol : 1;
+ unsigned __REPB_PREFIX(not_eol) : 1;
/* If true, an anchor at a newline matches. */
- unsigned newline_anchor : 1;
+ unsigned __REPB_PREFIX(newline_anchor) : 1;
};
typedef struct re_pattern_buffer regex_t;
@@ -419,6 +421,7 @@ typedef struct re_pattern_buffer regex_t;
typedef int regoff_t;
+#ifdef __USE_GNU
/* This is the structure we store register match data in. See
regex.texinfo for a full description of what registers match. */
struct re_registers
@@ -432,8 +435,9 @@ struct re_registers
/* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer,
`re_match_2' returns information about at least this many registers
the first time a `regs' structure is passed. */
-#ifndef RE_NREGS
-# define RE_NREGS 30
+# ifndef RE_NREGS
+# define RE_NREGS 30
+# endif
#endif
@@ -448,7 +452,7 @@ typedef struct
/* Declarations for routines. */
-
+#ifdef __USE_GNU
/* Sets the current default syntax to SYNTAX, and return the old syntax.
You can also simply assign to the `re_syntax_options' variable. */
extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax);
@@ -464,6 +468,7 @@ extern const char *re_compile_pattern (const char *__pattern, size_t __length,
accelerate searches. Return 0 if successful and -2 if was an
internal error. */
extern int re_compile_fastmap (struct re_pattern_buffer *__buffer);
+libc_hidden_proto(re_compile_fastmap)
/* Search in the string STRING (with length LENGTH) for the pattern
@@ -474,6 +479,7 @@ extern int re_compile_fastmap (struct re_pattern_buffer *__buffer);
extern int re_search (struct re_pattern_buffer *__buffer, const char *__string,
int __length, int __start, int __range,
struct re_registers *__regs);
+libc_hidden_proto(re_search)
/* Like `re_search', but search in the concatenation of STRING1 and
@@ -482,6 +488,7 @@ extern int re_search_2 (struct re_pattern_buffer *__buffer,
const char *__string1, int __length1,
const char *__string2, int __length2, int __start,
int __range, struct re_registers *__regs, int __stop);
+libc_hidden_proto(re_search_2)
/* Like `re_search', but return how many characters in STRING the regexp
@@ -513,8 +520,9 @@ extern void re_set_registers (struct re_pattern_buffer *__buffer,
struct re_registers *__regs,
unsigned int __num_regs,
regoff_t *__starts, regoff_t *__ends);
+#endif /* Use GNU */
-#if defined _REGEX_RE_COMP || defined _LIBC
+#if defined _REGEX_RE_COMP || (defined _LIBC && defined __USE_BSD)
# ifndef _CRAY
/* 4.2 bsd compatibility. */
extern char *re_comp (const char *);
@@ -535,7 +543,8 @@ extern int re_exec (const char *);
#endif
/* gcc 3.1 and up support the [restrict] syntax. */
#ifndef __restrict_arr
-# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
+# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) \
+ && !defined __GNUG__
# define __restrict_arr __restrict
# else
# define __restrict_arr
@@ -551,15 +560,15 @@ extern int regexec (const regex_t *__restrict __preg,
const char *__restrict __string, size_t __nmatch,
regmatch_t __pmatch[__restrict_arr],
int __eflags);
+libc_hidden_proto(regexec)
extern size_t regerror (int __errcode, const regex_t *__restrict __preg,
char *__restrict __errbuf, size_t __errbuf_size);
extern void regfree (regex_t *__preg);
+libc_hidden_proto(regfree)
-#ifdef __cplusplus
-}
-#endif /* C++ */
+__END_DECLS
#endif /* regex.h */
diff --git a/include/regexp.h b/include/regexp.h
index b7b50b710..17879aed1 100644
--- a/include/regexp.h
+++ b/include/regexp.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1996, 1997, 1998, 1999, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998, 1999, 2004, 2008
+ Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@@ -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/>. */
#ifndef _REGEXP_H
#define _REGEXP_H 1
@@ -81,6 +81,7 @@
__BEGIN_DECLS
+#if 0
/* Interface variables. They contain the results of the successful
calls to `setp' and `advance'. */
extern char *loc1;
@@ -89,6 +90,7 @@ extern char *loc2;
/* The use of this variable in the `advance' function is not
supported. */
extern char *locs;
+#endif
#ifndef __DO_NOT_DEFINE_COMPILE
@@ -100,7 +102,7 @@ extern char *locs;
on the macros. */
char *
compile (char *__restrict instring, char *__restrict expbuf,
- __const char *__restrict endbuf, int eof)
+ const char *__restrict endbuf, int eof)
{
char *__input_buffer = NULL;
size_t __input_size = 0;
@@ -129,8 +131,9 @@ compile (char *__restrict instring, char *__restrict expbuf,
__expr_ptr = (regex_t *) expbuf;
/* The remaining space in the buffer can be used for the compiled
pattern. */
- __expr_ptr->buffer = expbuf + sizeof (regex_t);
- __expr_ptr->allocated = endbuf - (char *) __expr_ptr->buffer;
+ __expr_ptr->__REPB_PREFIX (buffer) = expbuf + sizeof (regex_t);
+ __expr_ptr->__REPB_PREFIX (allocated)
+ = endbuf - (char *) __expr_ptr->__REPB_PREFIX (buffer);
while ((__ch = (GETC ())) != eof)
{
@@ -162,7 +165,10 @@ compile (char *__restrict instring, char *__restrict expbuf,
}
__input_buffer[__current_size++] = __ch;
}
- __input_buffer[__current_size++] = '\0';
+ if (__current_size)
+ __input_buffer[__current_size++] = '\0';
+ else
+ __input_buffer = "";
/* Now compile the pattern. */
__error = regcomp (__expr_ptr, __input_buffer, REG_NEWLINE);
@@ -198,23 +204,26 @@ compile (char *__restrict instring, char *__restrict expbuf,
}
/* Everything is ok. */
- RETURN ((char *) (__expr_ptr->buffer + __expr_ptr->used));
+ RETURN ((char *) (__expr_ptr->__REPB_PREFIX (buffer)
+ + __expr_ptr->__REPB_PREFIX (used)));
}
#endif
+#if 0
/* Find the next match in STRING. The compiled regular expression is
found in the buffer starting at EXPBUF. `loc1' will return the
first character matched and `loc2' points to the next unmatched
character. */
-extern int step (__const char *__restrict __string,
- __const char *__restrict __expbuf) __THROW;
+extern int step (const char *__restrict __string,
+ const char *__restrict __expbuf) __THROW;
/* Match the beginning of STRING with the compiled regular expression
in EXPBUF. If the match is successful `loc2' will contain the
position of the first unmatched character. */
-extern int advance (__const char *__restrict __string,
- __const char *__restrict __expbuf) __THROW;
+extern int advance (const char *__restrict __string,
+ const char *__restrict __expbuf) __THROW;
+#endif
__END_DECLS
diff --git a/include/resolv.h b/include/resolv.h
index 3434f5d8c..9349be11f 100644
--- a/include/resolv.h
+++ b/include/resolv.h
@@ -98,56 +98,85 @@ typedef res_sendhookact (*res_send_rhook) (const struct sockaddr_in *ns,
# define RES_MAXNDOTS 15 /* should reflect bit field size */
# define RES_MAXRETRANS 30 /* only for resolv.conf/RES_OPTIONS */
# define RES_MAXRETRY 5 /* only for resolv.conf/RES_OPTIONS */
-# define RES_DFLRETRY 2 /* Default #/tries. */
+# define RES_DFLRETRY 3 /* Default #/tries. */
+/* (glibc uses RES_DFLRETRY of 2 but also does _res.retry = 4 sometimes (!) */
# define RES_MAXTIME 65535 /* Infinity, in milliseconds. */
+/* _res (an instance of this structure) uses 0.5kb in bss
+ * in "ordinary" libc's (glibc, xBSD). We want to be less wasteful.
+ * We (1) shuffle and shrink some integer fields,
+ * and (2) can switch off stuff we don't support.
+ * Everything inside __UCLIBC_HAS_COMPAT_RES_STATE__
+ * is not actually used by uclibc and can be configured off.
+ * However, this will prevent some programs from building.
+ * Really obscure stuff with no observed users in the wild is under
+ * __UCLIBC_HAS_EXTRA_COMPAT_RES_STATE__.
+ * I guess it's safe to set that to N.
+ */
struct __res_state {
- int retrans; /* retransmition time interval */
- int retry; /* number of times to retransmit */
- u_long options; /* option flags - see below. */
- int nscount; /* number of name servers */
- struct sockaddr_in
- nsaddr_list[MAXNS]; /* address of name server */
-# define nsaddr nsaddr_list[0] /* for backward compatibility */
- u_short id; /* current message id */
- char *dnsrch[MAXDNSRCH+1]; /* components of domain to search */
+ /*int retrans, retry; - moved, was here */
+ u_int32_t options; /* (was: ulong) option flags - see below. */
+ struct sockaddr_in nsaddr_list[MAXNS]; /* address of name server */
+#define nsaddr nsaddr_list[0] /* for backward compatibility */
+ char *dnsrch[MAXDNSRCH + 1]; /* components of domain to search */
+ /*char defdname[256]; - moved, was here */
+ u_int8_t nscount; /* (was: int) number of name servers */
+ u_int8_t ndots; /* (was: unsigned:4) threshold for initial abs. query */
+ u_int8_t retrans; /* (was: int) retransmission time interval */
+ u_int8_t retry; /* (was: int) number of times to retransmit */
+#ifdef __UCLIBC_HAS_COMPAT_RES_STATE__
+ /* googling for "_res.defdname" says it's still sometimes used.
+ * Pity. It's huge, I want to move it to EXTRA_COMPAT... */
char defdname[256]; /* default domain (deprecated) */
- u_long pfcode; /* RES_PRF_ flags - see below. */
- unsigned ndots:4; /* threshold for initial abs. query */
- unsigned nsort:4; /* number of elements in sort_list[] */
- char unused[3];
+ u_int8_t nsort; /* (was: unsigned:4) number of elements in sort_list[] */
+ u_int16_t pfcode; /* (was: ulong) RES_PRF_ flags. Used by dig. */
+ unsigned short id; /* current message id */
+ int res_h_errno; /* last one set for this context */
struct {
struct in_addr addr;
u_int32_t mask;
} sort_list[MAXRESOLVSORT];
- res_send_qhook qhook; /* query hook */
- res_send_rhook rhook; /* response hook */
- int res_h_errno; /* last one set for this context */
- int _vcsock; /* PRIVATE: for res_send VC i/o */
- u_int _flags; /* PRIVATE: see below */
+#endif
+
+ /* I assume that the intention is to store all
+ * DNS servers' addresses here, and duplicate in nsaddr_list[]
+ * those which have IPv4 address. In the case of IPv4 address
+ * _u._ext.nsaddrs[x] will point to some nsaddr_list[y],
+ * otherwise it will point into malloc'ed sockaddr_in6.
+ * nscount is the number of IPv4 addresses and _u._ext.nscount
+ * is the number of addresses of all kinds.
+ *
+ * If this differs from established usage and you need
+ * to change this, please describe how it is supposed to work.
+ */
union {
- char pad[52]; /* On an i386 this means 512b total. */
struct {
- u_int16_t nscount;
-#if 0
- u_int16_t nsmap[MAXNS];
-#else
- u_int16_t nstimes[MAXNS]; /* ms. */
+#ifdef __UCLIBC_HAS_IPV6__
+ struct sockaddr_in6 *nsaddrs[MAXNS];
#endif
+ u_int8_t nscount; /* (was: u_int16_t) */
+#ifdef __UCLIBC_HAS_COMPAT_RES_STATE__
+ /* rather obscure, and differs in BSD and glibc */
+ u_int16_t nstimes[MAXNS];
int nssocks[MAXNS];
u_int16_t nscount6;
u_int16_t nsinit;
- struct sockaddr_in6 *nsaddrs[MAXNS];
-#if 0
-#ifdef _LIBC
- unsigned long long int initstamp
- __attribute__((packed));
-#else
- unsigned int _initstamp[2];
-#endif
+ /* glibc also has: */
+ /*u_int16_t nsmap[MAXNS];*/
+ /*unsigned long long initstamp;*/
#endif
} _ext;
} _u;
+
+#ifdef __UCLIBC_HAS_EXTRA_COMPAT_RES_STATE__
+ /* Truly obscure stuff.
+ * Googling for "_res.XXX" for these members
+ * turned up basically empty */
+ res_send_qhook qhook; /* query hook */
+ res_send_rhook rhook; /* response hook */
+ int _vcsock; /* PRIVATE: for res_send VC i/o */
+ unsigned _flags; /* PRIVATE: see below */
+#endif
};
typedef struct __res_state *res_state;
@@ -196,6 +225,7 @@ struct res_sym {
/*
* Resolver options (keep these in synch with res_debug.c, please)
+ * (which of these do we really implement??)
*/
#define RES_INIT 0x00000001 /* address initialized */
#define RES_DEBUG 0x00000002 /* print debug messages */
@@ -247,53 +277,69 @@ struct res_sym {
/* 0x00008000 */
/* Things involving an internal (static) resolver context. */
-#if 0
__BEGIN_DECLS
extern struct __res_state *__res_state(void) __attribute__ ((__const__));
__END_DECLS
#define _res (*__res_state())
-#else
-extern struct __res_state _res;
-#endif
+#if 0
#define fp_nquery __fp_nquery
#define fp_query __fp_query
#define hostalias __hostalias
#define p_query __p_query
+#endif
#define res_close __res_close
#define res_init __res_init
+#if 0
#define res_isourserver __res_isourserver
+#endif
#define res_mkquery __res_mkquery
#define res_query __res_query
#define res_querydomain __res_querydomain
#define res_search __res_search
+#if 0
#define res_send __res_send
+#endif
__BEGIN_DECLS
+#if 0
void fp_nquery (const u_char *, int, FILE *) __THROW;
void fp_query (const u_char *, FILE *) __THROW;
const char * hostalias (const char *) __THROW;
void p_query (const u_char *) __THROW;
+#endif
#ifdef __UCLIBC_HAS_BSD_RES_CLOSE__
void res_close (void) __THROW;
#endif
int res_init (void) __THROW;
+libc_hidden_proto(res_init)
+#if 0
int res_isourserver (const struct sockaddr_in *) __THROW;
+#endif
int res_mkquery (int, const char *, int, int, const u_char *,
int, const u_char *, u_char *, int) __THROW;
int res_query (const char *, int, int, u_char *, int) __THROW;
+libc_hidden_proto(res_query)
int res_querydomain (const char *, const char *, int, int,
u_char *, int) __THROW;
+libc_hidden_proto(res_querydomain)
int res_search (const char *, int, int, u_char *, int) __THROW;
+#if 0
int res_send (const u_char *, int, u_char *, int) __THROW;
+#endif
__END_DECLS
+#if 0
#define b64_ntop __b64_ntop
#define b64_pton __b64_pton
-#define dn_comp __dn_comp
#define dn_count_labels __dn_count_labels
+#endif
+#define dn_comp __dn_comp
#define dn_expand __dn_expand
#define dn_skipname __dn_skipname
+#define res_ninit __res_ninit
+#define res_nclose __res_nclose
+#if 0
#define fp_resstat __fp_resstat
#define loc_aton __loc_aton
#define loc_ntoa __loc_ntoa
@@ -315,8 +361,6 @@ __END_DECLS
#define res_hostalias __res_hostalias
#define res_mailok __res_mailok
#define res_nameinquery __res_nameinquery
-#define res_nclose __res_nclose
-#define res_ninit __res_ninit
#define res_nmkquery __res_nmkquery
#define res_npquery __res_npquery
#define res_nquery __res_nquery
@@ -330,7 +374,9 @@ __END_DECLS
#define sym_ntop __sym_ntop
#define sym_ntos __sym_ntos
#define sym_ston __sym_ston
+#endif
__BEGIN_DECLS
+#if 0
int res_hnok (const char *) __THROW;
int res_ownok (const char *) __THROW;
int res_mailok (const char *) __THROW;
@@ -342,7 +388,6 @@ int b64_ntop (u_char const *, size_t, char *, size_t) __THROW;
int b64_pton (char const *, u_char *, size_t) __THROW;
int loc_aton (const char *ascii, u_char *binary) __THROW;
const char * loc_ntoa (const u_char *binary, char *ascii) __THROW;
-int dn_skipname (const u_char *, const u_char *) __THROW;
void putlong (u_int32_t, u_char *) __THROW;
void putshort (u_int16_t, u_char *) __THROW;
const char * p_class (int) __THROW;
@@ -358,10 +403,18 @@ const u_char * p_fqname (const u_char *, const u_char *, FILE *) __THROW;
const char * p_option (u_long option) __THROW;
char * p_secstodate (u_long) __THROW;
int dn_count_labels (const char *) __THROW;
+#endif
+int dn_skipname (const u_char *, const u_char *) __THROW;
+libc_hidden_proto(dn_skipname)
int dn_comp (const char *, u_char *, int, u_char **, u_char **)
__THROW;
+libc_hidden_proto(dn_comp)
int dn_expand (const u_char *, const u_char *, const u_char *,
char *, int) __THROW;
+libc_hidden_proto(dn_expand)
+int res_ninit (res_state) __THROW;
+void res_nclose (res_state) __THROW;
+#if 0
u_int res_randomid (void) __THROW;
int res_nameinquery (const char *, int, int,
const u_char *, const u_char *) __THROW;
@@ -369,7 +422,6 @@ int res_queriesmatch (const u_char *, const u_char *,
const u_char *, const u_char *) __THROW;
const char * p_section (int section, int opcode) __THROW;
/* Things involving a resolver context. */
-int res_ninit (res_state) __THROW;
int res_nisourserver (const res_state,
const struct sockaddr_in *) __THROW;
void fp_resstat (const res_state, FILE *) __THROW;
@@ -388,8 +440,27 @@ int res_nmkquery (res_state, int, const char *, int, int,
int) __THROW;
int res_nsend (res_state, const u_char *, int, u_char *, int)
__THROW;
-void res_nclose (res_state) __THROW;
-__END_DECLS
#endif
+__END_DECLS
+
+# if _LIBC
+# ifdef __UCLIBC_HAS_THREADS__
+# if defined __UCLIBC_HAS_TLS__ \
+ && (!defined NOT_IN_libc || defined IS_IN_libpthread)
+# undef _res
+# ifndef NOT_IN_libc
+# define __resp __libc_resp
+# endif
+# define _res (*__resp)
+extern __thread struct __res_state *__resp attribute_tls_model_ie;
+# endif
+# else
+# undef _res
+# define _res (*__resp)
+extern struct __res_state *__resp;
+# endif /* __UCLIBC_HAS_THREADS__ */
+# endif /* _LIBC */
+
+#endif /* _RESOLV_H_ */
#endif /* !_RESOLV_H_ */
diff --git a/include/rpc/auth.h b/include/rpc/auth.h
index 17eb59f70..70066fe52 100644
--- a/include/rpc/auth.h
+++ b/include/rpc/auth.h
@@ -41,17 +41,6 @@
#ifndef _RPC_AUTH_H
#define _RPC_AUTH_H 1
-#ifdef _LIBC
-/* Some adjustments to make the libc source from glibc
- * compile more easily with uClibc... */
-#ifndef __FORCE_GLIBC
-#define __FORCE_GLIBC
-#endif
-#ifndef _GNU_SOUCE
-#define _GNU_SOUCE
-#endif
-#define _(X) X
-#endif
#include <features.h>
#include <rpc/xdr.h>
@@ -107,13 +96,17 @@ struct AUTH {
struct opaque_auth ah_cred;
struct opaque_auth ah_verf;
union des_block ah_key;
+ /* not sure whether non-const-ness is a part of the spec... if it is,
+ * enclose "const" in #ifdef _LIBC / #endif
+ * to make it effective only for libc compile */
+ const
struct auth_ops {
void (*ah_nextverf) (AUTH *);
int (*ah_marshal) (AUTH *, XDR *); /* nextverf & serialize */
int (*ah_validate) (AUTH *, struct opaque_auth *);
/* validate verifier */
int (*ah_refresh) (AUTH *); /* refresh credentials */
- void (*ah_destroy) (AUTH *); /* destroy this structure */
+ void (*ah_destroy) (AUTH *); /* destroy this structure */
} *ah_ops;
caddr_t ah_private;
};
@@ -171,13 +164,18 @@ extern struct opaque_auth _null_auth;
*/
extern AUTH *authunix_create (char *__machname, __uid_t __uid, __gid_t __gid,
int __len, __gid_t *__aup_gids);
+libc_hidden_proto(authunix_create)
extern AUTH *authunix_create_default (void);
+libc_hidden_proto(authunix_create_default)
extern AUTH *authnone_create (void) __THROW;
+libc_hidden_proto(authnone_create)
+#if 0
extern AUTH *authdes_create (const char *__servername, u_int __window,
struct sockaddr *__syncaddr, des_block *__ckey)
__THROW;
extern AUTH *authdes_pk_create (const char *, netobj *, u_int,
struct sockaddr *, des_block *) __THROW;
+#endif
#define AUTH_NONE 0 /* no authentication */
@@ -189,16 +187,17 @@ extern AUTH *authdes_pk_create (const char *, netobj *, u_int,
#define AUTH_DH AUTH_DES /* Diffie-Hellman (this is DES) */
#define AUTH_KERB 4 /* kerberos style */
+#if 0
/*
* Netname manipulating functions
*
*/
extern int getnetname (char *) __THROW;
-extern int host2netname (char *, __const char *, __const char *) __THROW;
-extern int user2netname (char *, __const uid_t, __const char *) __THROW;
-extern int netname2user (__const char *, uid_t *, gid_t *, int *, gid_t *)
+extern int host2netname (char *, const char *, const char *) __THROW;
+extern int user2netname (char *, const uid_t, const char *) __THROW;
+extern int netname2user (const char *, uid_t *, gid_t *, int *, gid_t *)
__THROW;
-extern int netname2host (__const char *, char *, __const int) __THROW;
+extern int netname2host (const char *, char *, const int) __THROW;
/*
*
@@ -213,11 +212,13 @@ extern int key_gendes (des_block *);
extern int key_setsecret (char *);
extern int key_secretkey_is_set (void);
extern int key_get_conv (char *, des_block *);
+#endif
/*
* XDR an opaque authentication struct.
*/
extern bool_t xdr_opaque_auth (XDR *, struct opaque_auth *) __THROW;
+libc_hidden_proto(xdr_opaque_auth)
__END_DECLS
diff --git a/include/rpc/auth_des.h b/include/rpc/auth_des.h
index 12ada8404..bcd96e424 100644
--- a/include/rpc/auth_des.h
+++ b/include/rpc/auth_des.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 _RPC_AUTH_DES_H
#define _RPC_AUTH_DES_H 1
@@ -24,6 +23,7 @@
__BEGIN_DECLS
+#if 0
/* There are two kinds of "names": fullnames and nicknames */
enum authdes_namekind
{
@@ -47,6 +47,7 @@ struct authdes_cred
struct authdes_fullname adc_fullname;
uint32_t adc_nickname;
};
+#endif
/* A timeval replacement for !32bit platforms */
struct rpc_timeval
@@ -55,6 +56,7 @@ struct rpc_timeval
uint32_t tv_usec; /* Microseconds. */
};
+#if 0
/* A des authentication verifier */
struct authdes_verf
{
@@ -86,22 +88,23 @@ struct authdes_verf
#define adv_nickname adv_int_u
/* Map a des credential into a unix cred. */
-extern int authdes_getucred (__const struct authdes_cred * __adc,
+extern int authdes_getucred (const struct authdes_cred * __adc,
uid_t * __uid, gid_t * __gid,
short *__grouplen, gid_t * __groups) __THROW;
/* Get the public key for NAME and place it in KEY. NAME can only be
up to MAXNETNAMELEN bytes long and the destination buffer KEY should
have HEXKEYBYTES + 1 bytes long to fit all characters from the key. */
-extern int getpublickey (__const char *__name, char *__key) __THROW;
+extern int getpublickey (const char *__name, char *__key) __THROW;
/* Get the secret key for NAME and place it in KEY. PASSWD is used to
decrypt the encrypted key stored in the database. NAME can only be
up to MAXNETNAMELEN bytes long and the destination buffer KEY
should have HEXKEYBYTES + 1 bytes long to fit all characters from
the key. */
-extern int getsecretkey (__const char *__name, char *__key,
- __const char *__passwd) __THROW;
+extern int getsecretkey (const char *__name, char *__key,
+ const char *__passwd) __THROW;
+#endif
extern int rtime (struct sockaddr_in *__addrp, struct rpc_timeval *__timep,
struct rpc_timeval *__timeout) __THROW;
diff --git a/include/rpc/auth_unix.h b/include/rpc/auth_unix.h
index 424661d9c..713fcb437 100644
--- a/include/rpc/auth_unix.h
+++ b/include/rpc/auth_unix.h
@@ -74,6 +74,7 @@ struct authunix_parms
extern bool_t xdr_authunix_parms (XDR *__xdrs, struct authunix_parms *__p)
__THROW;
+libc_hidden_proto(xdr_authunix_parms)
/*
* If a response verifier has flavor AUTH_SHORT,
diff --git a/include/rpc/clnt.h b/include/rpc/clnt.h
index cf271c5c1..32da6b4e5 100644
--- a/include/rpc/clnt.h
+++ b/include/rpc/clnt.h
@@ -132,6 +132,10 @@ struct rpc_err {
typedef struct CLIENT CLIENT;
struct CLIENT {
AUTH *cl_auth; /* authenticator */
+ /* not sure whether non-const-ness is a part of the spec... if it is,
+ * enclose "const" in #ifdef _LIBC / #endif
+ * to make it effective only for libc compile */
+ const
struct clnt_ops {
enum clnt_stat (*cl_call) (CLIENT *, u_long, xdrproc_t, caddr_t, xdrproc_t,
caddr_t, struct timeval);
@@ -277,7 +281,7 @@ struct CLIENT {
* u_long prog;
* u_long vers;
*/
-extern CLIENT *clntraw_create (__const u_long __prog, __const u_long __vers)
+extern CLIENT *clntraw_create (const u_long __prog, const u_long __vers)
__THROW;
@@ -291,8 +295,8 @@ extern CLIENT *clntraw_create (__const u_long __prog, __const u_long __vers)
* u_ong vers; -- version number
* char *prot; -- protocol
*/
-extern CLIENT *clnt_create (__const char *__host, __const u_long __prog,
- __const u_long __vers, __const char *__prot)
+extern CLIENT *clnt_create (const char *__host, const u_long __prog,
+ const u_long __vers, const char *__prot)
__THROW;
@@ -310,6 +314,7 @@ extern CLIENT *clnt_create (__const char *__host, __const u_long __prog,
extern CLIENT *clnttcp_create (struct sockaddr_in *__raddr, u_long __prog,
u_long __version, int *__sockp, u_int __sendsz,
u_int __recvsz) __THROW;
+libc_hidden_proto(clnttcp_create)
/*
* UDP based rpc.
@@ -335,12 +340,12 @@ extern CLIENT *clnttcp_create (struct sockaddr_in *__raddr, u_long __prog,
extern CLIENT *clntudp_create (struct sockaddr_in *__raddr, u_long __program,
u_long __version, struct timeval __wait_resend,
int *__sockp) __THROW;
+libc_hidden_proto(clntudp_create)
extern CLIENT *clntudp_bufcreate (struct sockaddr_in *__raddr,
u_long __program, u_long __version,
struct timeval __wait_resend, int *__sockp,
u_int __sendsz, u_int __recvsz) __THROW;
-
-
+libc_hidden_proto(clntudp_bufcreate)
/*
@@ -357,19 +362,22 @@ extern CLIENT *clntudp_bufcreate (struct sockaddr_in *__raddr,
extern CLIENT *clntunix_create (struct sockaddr_un *__raddr, u_long __program,
u_long __version, int *__sockp,
u_int __sendsz, u_int __recvsz) __THROW;
+libc_hidden_proto(clntunix_create)
-extern int callrpc (__const char *__host, __const u_long __prognum,
- __const u_long __versnum, __const u_long __procnum,
- __const xdrproc_t __inproc, __const char *__in,
- __const xdrproc_t __outproc, char *__out) __THROW;
+extern int callrpc (const char *__host, const u_long __prognum,
+ const u_long __versnum, const u_long __procnum,
+ const xdrproc_t __inproc, const char *__in,
+ const xdrproc_t __outproc, char *__out) __THROW;
extern int _rpc_dtablesize (void) __THROW;
+libc_hidden_proto(_rpc_dtablesize)
/*
* Print why creation failed
*/
-extern void clnt_pcreateerror (__const char *__msg); /* stderr */
-extern char *clnt_spcreateerror(__const char *__msg) __THROW; /* string */
+extern void clnt_pcreateerror (const char *__msg); /* stderr */
+extern char *clnt_spcreateerror(const char *__msg) __THROW; /* string */
+libc_hidden_proto(clnt_spcreateerror)
/*
* Like clnt_perror(), but is more verbose in its output
@@ -379,10 +387,13 @@ extern void clnt_perrno (enum clnt_stat __num); /* stderr */
/*
* Print an English error message, given the client error code
*/
-extern void clnt_perror (CLIENT *__clnt, __const char *__msg);
+extern void clnt_perror (CLIENT *__clnt, const char *__msg);
/* stderr */
-extern char *clnt_sperror (CLIENT *__clnt, __const char *__msg) __THROW;
+libc_hidden_proto(clnt_perror)
+extern char *clnt_sperror (CLIENT *__clnt, const char *__msg) __THROW;
/* string */
+libc_hidden_proto(clnt_sperror)
+
/*
* If a creation fails, the following allows the user to figure out why.
@@ -400,11 +411,12 @@ extern struct rpc_createerr rpc_createerr;
* Copy error message to buffer.
*/
extern char *clnt_sperrno (enum clnt_stat __num) __THROW; /* string */
+libc_hidden_proto(clnt_sperrno)
/*
* get the port number on the host for the rpc program,version and proto
*/
-extern int getrpcport (__const char * __host, u_long __prognum,
+extern int getrpcport (const char * __host, u_long __prognum,
u_long __versnum, u_int proto) __THROW;
/*
diff --git a/include/rpc/netdb.h b/include/rpc/netdb.h
index 86717373c..764b8cf1a 100644
--- a/include/rpc/netdb.h
+++ b/include/rpc/netdb.h
@@ -51,13 +51,18 @@ struct rpcent
};
extern void setrpcent (int __stayopen) __THROW;
+libc_hidden_proto(setrpcent)
extern void endrpcent (void) __THROW;
-extern struct rpcent *getrpcbyname (__const char *__name) __THROW;
+libc_hidden_proto(endrpcent)
+extern struct rpcent *getrpcbyname (const char *__name) __THROW;
+libc_hidden_proto(getrpcbyname)
extern struct rpcent *getrpcbynumber (int __number) __THROW;
+libc_hidden_proto(getrpcbynumber)
extern struct rpcent *getrpcent (void) __THROW;
+libc_hidden_proto(getrpcent)
#if defined __USE_MISC && defined __UCLIBC_HAS_REENTRANT_RPC__
-extern int getrpcbyname_r (__const char *__name, struct rpcent *__result_buf,
+extern int getrpcbyname_r (const char *__name, struct rpcent *__result_buf,
char *__buffer, size_t __buflen,
struct rpcent **__result) __THROW;
diff --git a/include/rpc/pmap_clnt.h b/include/rpc/pmap_clnt.h
index 1b1c45291..936516af7 100644
--- a/include/rpc/pmap_clnt.h
+++ b/include/rpc/pmap_clnt.h
@@ -69,29 +69,32 @@ typedef bool_t (*resultproc_t) (caddr_t resp, struct sockaddr_in *raddr);
* address if the responder to the broadcast.
*/
-extern bool_t pmap_set (__const u_long __program, __const u_long __vers,
+extern bool_t pmap_set (const u_long __program, const u_long __vers,
int __protocol, u_short __port) __THROW;
-extern bool_t pmap_unset (__const u_long __program, __const u_long __vers)
+libc_hidden_proto(pmap_set)
+extern bool_t pmap_unset (const u_long __program, const u_long __vers)
__THROW;
+libc_hidden_proto(pmap_unset)
extern struct pmaplist *pmap_getmaps (struct sockaddr_in *__address) __THROW;
extern enum clnt_stat pmap_rmtcall (struct sockaddr_in *__addr,
- __const u_long __prog,
- __const u_long __vers,
- __const u_long __proc,
+ const u_long __prog,
+ const u_long __vers,
+ const u_long __proc,
xdrproc_t __xdrargs,
caddr_t __argsp, xdrproc_t __xdrres,
caddr_t __resp, struct timeval __tout,
u_long *__port_ptr) __THROW;
-extern enum clnt_stat clnt_broadcast (__const u_long __prog,
- __const u_long __vers,
- __const u_long __proc, xdrproc_t __xargs,
+extern enum clnt_stat clnt_broadcast (const u_long __prog,
+ const u_long __vers,
+ const u_long __proc, xdrproc_t __xargs,
caddr_t __argsp, xdrproc_t __xresults,
caddr_t __resultsp,
resultproc_t __eachresult) __THROW;
extern u_short pmap_getport (struct sockaddr_in *__address,
- __const u_long __program,
- __const u_long __version, u_int __protocol)
+ const u_long __program,
+ const u_long __version, u_int __protocol)
__THROW;
+libc_hidden_proto(pmap_getport)
__END_DECLS
diff --git a/include/rpc/pmap_prot.h b/include/rpc/pmap_prot.h
index cd64e36de..30b26709f 100644
--- a/include/rpc/pmap_prot.h
+++ b/include/rpc/pmap_prot.h
@@ -95,6 +95,7 @@ struct pmap {
};
extern bool_t xdr_pmap (XDR *__xdrs, struct pmap *__regs) __THROW;
+libc_hidden_proto(xdr_pmap)
struct pmaplist {
struct pmap pml_map;
@@ -102,6 +103,7 @@ struct pmaplist {
};
extern bool_t xdr_pmaplist (XDR *__xdrs, struct pmaplist **__rp) __THROW;
+libc_hidden_proto(xdr_pmaplist)
__END_DECLS
diff --git a/include/rpc/pmap_rmt.h b/include/rpc/pmap_rmt.h
index 7a38b5f5f..59b4f6587 100644
--- a/include/rpc/pmap_rmt.h
+++ b/include/rpc/pmap_rmt.h
@@ -53,6 +53,8 @@ struct rmtcallargs {
extern bool_t xdr_rmtcall_args (XDR *__xdrs, struct rmtcallargs *__crp)
__THROW;
+libc_hidden_proto(xdr_rmtcall_args)
+
struct rmtcallres {
u_long *port_ptr;
@@ -62,6 +64,7 @@ struct rmtcallres {
};
extern bool_t xdr_rmtcallres (XDR *__xdrs, struct rmtcallres *__crp) __THROW;
+libc_hidden_proto(xdr_rmtcallres)
__END_DECLS
diff --git a/include/rpc/rpc.h b/include/rpc/rpc.h
index 8194ffee3..df0542890 100644
--- a/include/rpc/rpc.h
+++ b/include/rpc/rpc.h
@@ -38,19 +38,6 @@
#ifndef _RPC_RPC_H
#define _RPC_RPC_H 1
-#ifdef _LIBC
-/* Some adjustments to make the libc source from glibc
- * compile more easily with uClibc... */
-#ifndef __FORCE_GLIBC
-#define __FORCE_GLIBC
-#endif
-#ifndef _GNU_SOUCE
-#define _GNU_SOUCE
-#endif
-#define _(X) X
-#include <features.h>
-#endif
-
#include <rpc/types.h> /* some typedefs */
#include <netinet/in.h>
@@ -84,10 +71,12 @@ __BEGIN_DECLS
/* Global variables, protected for multi-threaded applications. */
extern fd_set *__rpc_thread_svc_fdset (void) __attribute__ ((__const__));
+libc_hidden_proto(__rpc_thread_svc_fdset)
#define svc_fdset (*__rpc_thread_svc_fdset ())
extern struct rpc_createerr *__rpc_thread_createerr (void)
__attribute__ ((__const__));
+libc_hidden_proto(__rpc_thread_createerr)
#define get_rpc_createerr() (*__rpc_thread_createerr ())
/* The people who "engineered" RPC should bee punished for naming the
data structure and the variable the same. We cannot always define the
@@ -100,14 +89,13 @@ extern struct rpc_createerr *__rpc_thread_createerr (void)
extern struct pollfd **__rpc_thread_svc_pollfd (void)
__attribute__ ((__const__));
+libc_hidden_proto(__rpc_thread_svc_pollfd)
#define svc_pollfd (*__rpc_thread_svc_pollfd ())
extern int *__rpc_thread_svc_max_pollfd (void) __attribute__ ((__const__));
+libc_hidden_proto(__rpc_thread_svc_max_pollfd)
#define svc_max_pollfd (*__rpc_thread_svc_max_pollfd ())
-extern bool_t xdr_accepted_reply (XDR *xdrs, struct accepted_reply *ar);
-extern bool_t xdr_rejected_reply (XDR *xdrs, struct rejected_reply *rr);
-
__END_DECLS
#endif /* rpc/rpc.h */
diff --git a/include/rpc/rpc_msg.h b/include/rpc/rpc_msg.h
index 636d60ea9..1137dadd2 100644
--- a/include/rpc/rpc_msg.h
+++ b/include/rpc/rpc_msg.h
@@ -171,6 +171,7 @@ struct rpc_msg {
* struct rpc_msg *cmsg;
*/
extern bool_t xdr_callmsg (XDR *__xdrs, struct rpc_msg *__cmsg) __THROW;
+libc_hidden_proto(xdr_callmsg)
/*
* XDR routine to pre-serialize the static part of a rpc message.
@@ -179,6 +180,7 @@ extern bool_t xdr_callmsg (XDR *__xdrs, struct rpc_msg *__cmsg) __THROW;
* struct rpc_msg *cmsg;
*/
extern bool_t xdr_callhdr (XDR *__xdrs, struct rpc_msg *__cmsg) __THROW;
+libc_hidden_proto(xdr_callhdr)
/*
* XDR routine to handle a rpc reply.
@@ -187,6 +189,7 @@ extern bool_t xdr_callhdr (XDR *__xdrs, struct rpc_msg *__cmsg) __THROW;
* struct rpc_msg *rmsg;
*/
extern bool_t xdr_replymsg (XDR *__xdrs, struct rpc_msg *__rmsg) __THROW;
+libc_hidden_proto(xdr_replymsg)
/*
* Fills in the error part of a reply message.
@@ -196,6 +199,27 @@ extern bool_t xdr_replymsg (XDR *__xdrs, struct rpc_msg *__rmsg) __THROW;
*/
extern void _seterr_reply (struct rpc_msg *__msg, struct rpc_err *__error)
__THROW;
+libc_hidden_proto(_seterr_reply)
+
+#ifdef __UCLIBC__
+/*
+ * XDR routine to handle an accepted rpc reply.
+ * xdr_accepted_reply(xdrs, rej)
+ * XDR *xdrs;
+ * struct accepted_reply *rej;
+ */
+extern bool_t xdr_accepted_reply(XDR *__xdrs, struct accepted_reply *__ar);
+libc_hidden_proto(xdr_accepted_reply)
+
+/*
+ * XDR routine to handle a rejected rpc reply.
+ * xdr_rejected_reply(xdrs, rej)
+ * XDR *xdrs;
+ * struct rejected_reply *rej;
+ */
+extern bool_t xdr_rejected_reply(XDR *__xdrs, struct rejected_reply *__rr);
+libc_hidden_proto(xdr_rejected_reply)
+#endif
__END_DECLS
diff --git a/include/rpc/svc.h b/include/rpc/svc.h
index 3ffca50bd..689832548 100644
--- a/include/rpc/svc.h
+++ b/include/rpc/svc.h
@@ -173,6 +173,7 @@ typedef void (*__dispatch_fn_t) (struct svc_req*, SVCXPRT*);
extern bool_t svc_register (SVCXPRT *__xprt, rpcprog_t __prog,
rpcvers_t __vers, __dispatch_fn_t __dispatch,
rpcprot_t __protocol) __THROW;
+libc_hidden_proto(svc_register)
/*
* Service un-registration
@@ -182,6 +183,7 @@ extern bool_t svc_register (SVCXPRT *__xprt, rpcprog_t __prog,
* rpcvers_t vers;
*/
extern void svc_unregister (rpcprog_t __prog, rpcvers_t __vers) __THROW;
+libc_hidden_proto(svc_unregister)
/*
* Transport registration.
@@ -190,6 +192,7 @@ extern void svc_unregister (rpcprog_t __prog, rpcvers_t __vers) __THROW;
* SVCXPRT *xprt;
*/
extern void xprt_register (SVCXPRT *__xprt) __THROW;
+libc_hidden_proto(xprt_register)
/*
* Transport un-register
@@ -198,7 +201,7 @@ extern void xprt_register (SVCXPRT *__xprt) __THROW;
* SVCXPRT *xprt;
*/
extern void xprt_unregister (SVCXPRT *__xprt) __THROW;
-
+libc_hidden_proto(xprt_unregister)
/*
* When the service routine is called, it must first check to see if it
@@ -228,8 +231,10 @@ extern void xprt_unregister (SVCXPRT *__xprt) __THROW;
extern bool_t svc_sendreply (SVCXPRT *xprt, xdrproc_t __xdr_results,
caddr_t __xdr_location) __THROW;
+libc_hidden_proto(svc_sendreply)
extern void svcerr_decode (SVCXPRT *__xprt) __THROW;
+libc_hidden_proto(svcerr_decode)
extern void svcerr_weakauth (SVCXPRT *__xprt) __THROW;
@@ -237,10 +242,13 @@ extern void svcerr_noproc (SVCXPRT *__xprt) __THROW;
extern void svcerr_progvers (SVCXPRT *__xprt, rpcvers_t __low_vers,
rpcvers_t __high_vers) __THROW;
+libc_hidden_proto(svcerr_progvers)
extern void svcerr_auth (SVCXPRT *__xprt, enum auth_stat __why) __THROW;
+libc_hidden_proto(svcerr_auth)
extern void svcerr_noprog (SVCXPRT *__xprt) __THROW;
+libc_hidden_proto(svcerr_noprog)
extern void svcerr_systemerr (SVCXPRT *__xprt) __THROW;
@@ -270,9 +278,13 @@ extern fd_set svc_fdset;
* also see clnt.h for protocol numbers.
*/
extern void svc_getreq (int __rdfds) __THROW;
+libc_hidden_proto(svc_getreq)
extern void svc_getreq_common (const int __fd) __THROW;
+libc_hidden_proto(svc_getreq_common)
extern void svc_getreqset (fd_set *__readfds) __THROW;
+libc_hidden_proto(svc_getreqset)
extern void svc_getreq_poll (struct pollfd *, const int) __THROW;
+libc_hidden_proto(svc_getreq_poll)
extern void svc_exit (void) __THROW;
extern void svc_run (void) __THROW;
@@ -294,8 +306,10 @@ extern SVCXPRT *svcraw_create (void) __THROW;
* Udp based rpc.
*/
extern SVCXPRT *svcudp_create (int __sock) __THROW;
+libc_hidden_proto(svcudp_create)
extern SVCXPRT *svcudp_bufcreate (int __sock, u_int __sendsz, u_int __recvsz)
__THROW;
+libc_hidden_proto(svcudp_bufcreate)
/*
* Tcp based rpc.
diff --git a/include/rpc/svc_auth.h b/include/rpc/svc_auth.h
index 1c1a7156a..834e3c923 100644
--- a/include/rpc/svc_auth.h
+++ b/include/rpc/svc_auth.h
@@ -48,6 +48,7 @@ __BEGIN_DECLS
*/
extern enum auth_stat _authenticate (struct svc_req *__rqst,
struct rpc_msg *__msg) __THROW;
+libc_hidden_proto(_authenticate)
__END_DECLS
diff --git a/include/rpc/types.h b/include/rpc/types.h
index 469576e52..8eff8e718 100644
--- a/include/rpc/types.h
+++ b/include/rpc/types.h
@@ -33,19 +33,6 @@
#ifndef _RPC_TYPES_H
#define _RPC_TYPES_H 1
-#ifdef _LIBC
-/* Some adjustments to make the libc source from glibc
- * compile more easily with uClibc... */
-#ifndef __FORCE_GLIBC
-#define __FORCE_GLIBC
-#endif
-#ifndef _GNU_SOUCE
-#define _GNU_SOUCE
-#endif
-#define _(X) X
-#endif
-#include <features.h>
-
typedef int bool_t;
typedef int enum_t;
/* This needs to be changed to uint32_t in the future */
diff --git a/include/rpc/xdr.h b/include/rpc/xdr.h
index 25dd214ee..a424153b6 100644
--- a/include/rpc/xdr.h
+++ b/include/rpc/xdr.h
@@ -36,14 +36,6 @@
#ifndef _RPC_XDR_H
#define _RPC_XDR_H 1
-#ifdef _LIBC
-/* Some adjustments to make the libc source from glibc
- * compile more easily with uClibc... */
-# ifndef __FORCE_GLIBC
-# define __FORCE_GLIBC
-# endif
-# define _(X) X
-#endif
#include <features.h>
#include <sys/types.h>
#include <rpc/types.h>
@@ -120,17 +112,21 @@ typedef struct XDR XDR;
struct XDR
{
enum xdr_op x_op; /* operation; fast additional param */
+ /* not sure whether non-const-ness is a part of the spec... if it is,
+ * enclose "const" in #ifdef _LIBC / #endif
+ * to make it effective only for libc compile */
+ const
struct xdr_ops
{
bool_t (*x_getlong) (XDR *__xdrs, long *__lp);
/* get a long from underlying stream */
- bool_t (*x_putlong) (XDR *__xdrs, __const long *__lp);
+ bool_t (*x_putlong) (XDR *__xdrs, const long *__lp);
/* put a long to " */
bool_t (*x_getbytes) (XDR *__xdrs, caddr_t __addr, u_int __len);
/* get some bytes from " */
- bool_t (*x_putbytes) (XDR *__xdrs, __const char *__addr, u_int __len);
+ bool_t (*x_putbytes) (XDR *__xdrs, const char *__addr, u_int __len);
/* put some bytes to " */
- u_int (*x_getpostn) (__const XDR *__xdrs);
+ u_int (*x_getpostn) (const XDR *__xdrs);
/* returns bytes off from beginning */
bool_t (*x_setpostn) (XDR *__xdrs, u_int __pos);
/* lets you reposition the stream */
@@ -140,7 +136,7 @@ struct XDR
/* free privates of this xdr_stream */
bool_t (*x_getint32) (XDR *__xdrs, int32_t *__ip);
/* get a int from underlying stream */
- bool_t (*x_putint32) (XDR *__xdrs, __const int32_t *__ip);
+ bool_t (*x_putint32) (XDR *__xdrs, const int32_t *__ip);
/* put a int to " */
}
*x_ops;
@@ -293,14 +289,23 @@ struct xdr_discrim
* also, the XDR structure is always updated by some of these calls.
*/
extern bool_t xdr_void (void) __THROW;
+libc_hidden_proto(xdr_void)
extern bool_t xdr_short (XDR *__xdrs, short *__sp) __THROW;
+libc_hidden_proto(xdr_short)
extern bool_t xdr_u_short (XDR *__xdrs, u_short *__usp) __THROW;
+libc_hidden_proto(xdr_u_short)
extern bool_t xdr_int (XDR *__xdrs, int *__ip) __THROW;
+libc_hidden_proto(xdr_int)
extern bool_t xdr_u_int (XDR *__xdrs, u_int *__up) __THROW;
+libc_hidden_proto(xdr_u_int)
extern bool_t xdr_long (XDR *__xdrs, long *__lp) __THROW;
+libc_hidden_proto(xdr_long)
extern bool_t xdr_u_long (XDR *__xdrs, u_long *__ulp) __THROW;
+libc_hidden_proto(xdr_u_long)
extern bool_t xdr_hyper (XDR *__xdrs, quad_t *__llp) __THROW;
+libc_hidden_proto(xdr_hyper)
extern bool_t xdr_u_hyper (XDR *__xdrs, u_quad_t *__ullp) __THROW;
+libc_hidden_proto(xdr_u_hyper)
extern bool_t xdr_longlong_t (XDR *__xdrs, quad_t *__llp) __THROW;
extern bool_t xdr_u_longlong_t (XDR *__xdrs, u_quad_t *__ullp) __THROW;
extern bool_t xdr_int8_t (XDR *__xdrs, int8_t *__ip) __THROW;
@@ -311,18 +316,27 @@ extern bool_t xdr_int32_t (XDR *__xdrs, int32_t *__ip) __THROW;
extern bool_t xdr_uint32_t (XDR *__xdrs, uint32_t *__up) __THROW;
extern bool_t xdr_int64_t (XDR *__xdrs, int64_t *__ip) __THROW;
extern bool_t xdr_uint64_t (XDR *__xdrs, uint64_t *__up) __THROW;
+extern bool_t xdr_quad_t (XDR *__xdrs, quad_t *__ip) __THROW;
+extern bool_t xdr_u_quad_t (XDR *__xdrs, u_quad_t *__up) __THROW;
extern bool_t xdr_bool (XDR *__xdrs, bool_t *__bp) __THROW;
+libc_hidden_proto(xdr_bool)
extern bool_t xdr_enum (XDR *__xdrs, enum_t *__ep) __THROW;
+libc_hidden_proto(xdr_enum)
extern bool_t xdr_array (XDR * _xdrs, caddr_t *__addrp, u_int *__sizep,
u_int __maxsize, u_int __elsize, xdrproc_t __elproc)
__THROW;
+libc_hidden_proto(xdr_array)
extern bool_t xdr_bytes (XDR *__xdrs, char **__cpp, u_int *__sizep,
u_int __maxsize) __THROW;
+libc_hidden_proto(xdr_bytes)
extern bool_t xdr_opaque (XDR *__xdrs, caddr_t __cp, u_int __cnt) __THROW;
+libc_hidden_proto(xdr_opaque)
extern bool_t xdr_string (XDR *__xdrs, char **__cpp, u_int __maxsize) __THROW;
+libc_hidden_proto(xdr_string)
extern bool_t xdr_union (XDR *__xdrs, enum_t *__dscmp, char *__unp,
- __const struct xdr_discrim *__choices,
+ const struct xdr_discrim *__choices,
xdrproc_t dfault) __THROW;
+libc_hidden_proto(xdr_union)
extern bool_t xdr_char (XDR *__xdrs, char *__cp) __THROW;
extern bool_t xdr_u_char (XDR *__xdrs, u_char *__cp) __THROW;
extern bool_t xdr_vector (XDR *__xdrs, char *__basep, u_int __nelem,
@@ -331,6 +345,7 @@ extern bool_t xdr_float (XDR *__xdrs, float *__fp) __THROW;
extern bool_t xdr_double (XDR *__xdrs, double *__dp) __THROW;
extern bool_t xdr_reference (XDR *__xdrs, caddr_t *__xpp, u_int __size,
xdrproc_t __proc) __THROW;
+libc_hidden_proto(xdr_reference)
extern bool_t xdr_pointer (XDR *__xdrs, char **__objpp,
u_int __obj_size, xdrproc_t __xdr_obj) __THROW;
extern bool_t xdr_wrapstring (XDR *__xdrs, char **__cpp) __THROW;
@@ -355,8 +370,9 @@ extern bool_t xdr_netobj (XDR *__xdrs, struct netobj *__np) __THROW;
*/
/* XDR using memory buffers */
-extern void xdrmem_create (XDR *__xdrs, __const caddr_t __addr,
+extern void xdrmem_create (XDR *__xdrs, const caddr_t __addr,
u_int __size, enum xdr_op __xop) __THROW;
+libc_hidden_proto(xdrmem_create)
/* XDR using stdio library */
extern void xdrstdio_create (XDR *__xdrs, FILE *__file, enum xdr_op __xop)
@@ -367,15 +383,19 @@ extern void xdrrec_create (XDR *__xdrs, u_int __sendsize,
u_int __recvsize, caddr_t __tcp_handle,
int (*__readit) (char *, char *, int),
int (*__writeit) (char *, char *, int)) __THROW;
+libc_hidden_proto(xdrrec_create)
/* make end of xdr record */
extern bool_t xdrrec_endofrecord (XDR *__xdrs, bool_t __sendnow) __THROW;
+libc_hidden_proto(xdrrec_endofrecord)
/* move to beginning of next record */
extern bool_t xdrrec_skiprecord (XDR *__xdrs) __THROW;
+libc_hidden_proto(xdrrec_skiprecord)
/* true if no more input */
extern bool_t xdrrec_eof (XDR *__xdrs) __THROW;
+libc_hidden_proto(xdrrec_eof)
/* free memory buffers for xdr */
extern void xdr_free (xdrproc_t __proc, char *__objp) __THROW;
diff --git a/include/sched.h b/include/sched.h
index 7cfdbf1f9..f262a0be5 100644
--- a/include/sched.h
+++ b/include/sched.h
@@ -1,5 +1,5 @@
/* Definitions for POSIX 1003.1b-1993 (aka POSIX.4) scheduling interface.
- Copyright (C) 1996,1997,1999,2001-2003,2004 Free Software Foundation, Inc.
+ Copyright (C) 1996,1997,1999,2001-2004,2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -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 _SCHED_H
#define _SCHED_H 1
@@ -25,6 +24,9 @@
/* Get type definitions. */
#include <bits/types.h>
+#define __need_size_t
+#include <stddef.h>
+
#define __need_timespec
#include <time.h>
@@ -37,7 +39,7 @@
__BEGIN_DECLS
/* Set scheduling parameters for a process. */
-extern int sched_setparam (__pid_t __pid, __const struct sched_param *__param)
+extern int sched_setparam (__pid_t __pid, const struct sched_param *__param)
__THROW;
/* Retrieve scheduling parameters for a particular process. */
@@ -45,7 +47,7 @@ extern int sched_getparam (__pid_t __pid, struct sched_param *__param) __THROW;
/* Set scheduling algorithm and/or parameters for a process. */
extern int sched_setscheduler (__pid_t __pid, int __policy,
- __const struct sched_param *__param) __THROW;
+ const struct sched_param *__param) __THROW;
/* Retrieve scheduling algorithm for a particular purpose. */
extern int sched_getscheduler (__pid_t __pid) __THROW;
@@ -63,22 +65,61 @@ extern int sched_get_priority_min (int __algorithm) __THROW;
extern int sched_rr_get_interval (__pid_t __pid, struct timespec *__t) __THROW;
-#ifdef __USE_GNU
+#if defined __USE_GNU && defined __UCLIBC_LINUX_SPECIFIC__
/* Access macros for `cpu_set'. */
-#define CPU_SETSIZE __CPU_SETSIZE
-#define CPU_SET(cpu, cpusetp) __CPU_SET (cpu, cpusetp)
-#define CPU_CLR(cpu, cpusetp) __CPU_CLR (cpu, cpusetp)
-#define CPU_ISSET(cpu, cpusetp) __CPU_ISSET (cpu, cpusetp)
-#define CPU_ZERO(cpusetp) __CPU_ZERO (cpusetp)
+# define CPU_SETSIZE __CPU_SETSIZE
+# define CPU_SET(cpu, cpusetp) __CPU_SET_S (cpu, sizeof (cpu_set_t), cpusetp)
+# define CPU_CLR(cpu, cpusetp) __CPU_CLR_S (cpu, sizeof (cpu_set_t), cpusetp)
+# define CPU_ISSET(cpu, cpusetp) __CPU_ISSET_S (cpu, sizeof (cpu_set_t), \
+ cpusetp)
+# define CPU_ZERO(cpusetp) __CPU_ZERO_S (sizeof (cpu_set_t), cpusetp)
+# define CPU_COUNT(cpusetp) __CPU_COUNT_S (sizeof (cpu_set_t), cpusetp)
+
+# define CPU_SET_S(cpu, setsize, cpusetp) __CPU_SET_S (cpu, setsize, cpusetp)
+# define CPU_CLR_S(cpu, setsize, cpusetp) __CPU_CLR_S (cpu, setsize, cpusetp)
+# define CPU_ISSET_S(cpu, setsize, cpusetp) __CPU_ISSET_S (cpu, setsize, \
+ cpusetp)
+# define CPU_ZERO_S(setsize, cpusetp) __CPU_ZERO_S (setsize, cpusetp)
+# define CPU_COUNT_S(setsize, cpusetp) __CPU_COUNT_S (setsize, cpusetp)
+
+# define CPU_EQUAL(cpusetp1, cpusetp2) \
+ __CPU_EQUAL_S (sizeof (cpu_set_t), cpusetp1, cpusetp2)
+# define CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
+ __CPU_EQUAL_S (setsize, cpusetp1, cpusetp2)
+
+# define CPU_AND(destset, srcset1, srcset2) \
+ __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, &)
+# define CPU_OR(destset, srcset1, srcset2) \
+ __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, |)
+# define CPU_XOR(destset, srcset1, srcset2) \
+ __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, ^)
+# define CPU_AND_S(setsize, destset, srcset1, srcset2) \
+ __CPU_OP_S (setsize, destset, srcset1, srcset2, &)
+# define CPU_OR_S(setsize, destset, srcset1, srcset2) \
+ __CPU_OP_S (setsize, destset, srcset1, srcset2, |)
+# define CPU_XOR_S(setsize, destset, srcset1, srcset2) \
+ __CPU_OP_S (setsize, destset, srcset1, srcset2, ^)
+
+# define CPU_ALLOC_SIZE(count) __CPU_ALLOC_SIZE (count)
+# define CPU_ALLOC(count) __CPU_ALLOC (count)
+# define CPU_FREE(cpuset) __CPU_FREE (cpuset)
/* Set the CPU affinity for a task */
extern int sched_setaffinity (__pid_t __pid, size_t __cpusetsize,
- __const cpu_set_t *__cpuset) __THROW;
+ const cpu_set_t *__cpuset) __THROW;
/* Get the CPU affinity for a task */
extern int sched_getaffinity (__pid_t __pid, size_t __cpusetsize,
cpu_set_t *__cpuset) __THROW;
+
+# ifdef _LIBC
+extern int __clone (int (*__fn) (void *__arg), void *__child_stack,
+ int __flags, void *__arg, ...);
+extern int __clone2 (int (*__fn) (void *__arg), void *__child_stack_base,
+ size_t __child_stack_size, int __flags, void *__arg, ...);
+# endif
+
#endif
__END_DECLS
diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
index 49ab75806..20ca8de86 100644
--- a/include/scsi/scsi.h
+++ b/include/scsi/scsi.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 header file contains public constants and structures used by
diff --git a/include/scsi/scsi_ioctl.h b/include/scsi/scsi_ioctl.h
index ba8c84faf..14b45b34d 100644
--- a/include/scsi/scsi_ioctl.h
+++ b/include/scsi/scsi_ioctl.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 _SCSI_IOCTL_H
#define _SCSI_IOCTL_H
diff --git a/include/scsi/sg.h b/include/scsi/sg.h
index b0dc0ad7d..2aa593729 100644
--- a/include/scsi/sg.h
+++ b/include/scsi/sg.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/>. */
/*
History:
diff --git a/include/search.h b/include/search.h
index 2ffba697b..f93c788b4 100644
--- a/include/search.h
+++ b/include/search.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 _SEARCH_H
#define _SEARCH_H 1
@@ -52,7 +51,7 @@ extern void remque (void *__elem) __THROW;
/* For use with hsearch(3). */
#ifndef __COMPAR_FN_T
# define __COMPAR_FN_T
-typedef int (*__compar_fn_t) (__const void *, __const void *);
+typedef int (*__compar_fn_t) (const void *, const void *);
# ifdef __USE_GNU
typedef __compar_fn_t comparison_fn_t;
@@ -106,8 +105,11 @@ struct hsearch_data
same time. */
extern int hsearch_r (ENTRY __item, ACTION __action, ENTRY **__retval,
struct hsearch_data *__htab) __THROW;
+libc_hidden_proto(hsearch_r)
extern int hcreate_r (size_t __nel, struct hsearch_data *__htab) __THROW;
+libc_hidden_proto(hcreate_r)
extern void hdestroy_r (struct hsearch_data *__htab) __THROW;
+libc_hidden_proto(hdestroy_r)
#endif
@@ -127,28 +129,30 @@ VISIT;
/* Search for an entry matching the given KEY in the tree pointed to
by *ROOTP and insert a new element if not found. */
-extern void *tsearch (__const void *__key, void **__rootp,
+extern void *tsearch (const void *__key, void **__rootp,
__compar_fn_t __compar);
+libc_hidden_proto(tsearch)
/* Search for an entry matching the given KEY in the tree pointed to
by *ROOTP. If no matching entry is available return NULL. */
-extern void *tfind (__const void *__key, void *__const *__rootp,
+extern void *tfind (const void *__key, void *const *__rootp,
__compar_fn_t __compar);
+libc_hidden_proto(tfind)
/* Remove the element matching KEY from the tree pointed to by *ROOTP. */
-extern void *tdelete (__const void *__restrict __key,
+extern void *tdelete (const void *__restrict __key,
void **__restrict __rootp,
__compar_fn_t __compar);
#ifndef __ACTION_FN_T
# define __ACTION_FN_T
-typedef void (*__action_fn_t) (__const void *__nodep, VISIT __value,
+typedef void (*__action_fn_t) (const void *__nodep, VISIT __value,
int __level);
#endif
/* Walk through the whole tree and call the ACTION callback for every node
or leaf. */
-extern void twalk (__const void *__root, __action_fn_t __action);
+extern void twalk (const void *__root, __action_fn_t __action);
#ifdef __USE_GNU
/* Callback type for function to free a tree node. If the keys are atomic
@@ -157,17 +161,19 @@ typedef void (*__free_fn_t) (void *__nodep);
/* Destroy the whole tree, call FREEFCT for each node or leaf. */
extern void tdestroy (void *__root, __free_fn_t __freefct);
+libc_hidden_proto(tdestroy)
#endif
/* Perform linear search for KEY by comparing by COMPAR in an array
[BASE,BASE+NMEMB*SIZE). */
-extern void *lfind (__const void *__key, __const void *__base,
+extern void *lfind (const void *__key, const void *__base,
size_t *__nmemb, size_t __size, __compar_fn_t __compar);
+libc_hidden_proto(lfind)
/* Perform linear search for KEY by comparing by COMPAR function in
array [BASE,BASE+NMEMB*SIZE) and insert entry if not found. */
-extern void *lsearch (__const void *__key, void *__base,
+extern void *lsearch (const void *__key, void *__base,
size_t *__nmemb, size_t __size, __compar_fn_t __compar);
__END_DECLS
diff --git a/include/setjmp.h b/include/setjmp.h
index 99e3dc8cd..71c1d35cb 100644
--- a/include/setjmp.h
+++ b/include/setjmp.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-1999, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1991-1999,2001,2002,2007,2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -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 Standard: 7.13 Nonlocal jumps <setjmp.h>
@@ -30,8 +29,9 @@ __BEGIN_DECLS
#include <bits/setjmp.h> /* Get `__jmp_buf'. */
#include <bits/sigset.h> /* Get `__sigset_t'. */
+
/* Calling environment, plus possibly a saved signal mask. */
-typedef struct __jmp_buf_tag /* C++ doesn't like tagless structs. */
+struct __jmp_buf_tag
{
/* NOTE: The machine-dependent definitions of `__sigsetjmp'
assume that a `jmp_buf' begins with a `__jmp_buf' and that
@@ -40,23 +40,30 @@ typedef struct __jmp_buf_tag /* C++ doesn't like tagless structs. */
__jmp_buf __jmpbuf; /* Calling environment. */
int __mask_was_saved; /* Saved the signal mask? */
__sigset_t __saved_mask; /* Saved signal mask. */
- } jmp_buf[1];
+ };
+
+__BEGIN_NAMESPACE_STD
+
+typedef struct __jmp_buf_tag jmp_buf[1];
/* Store the calling environment in ENV, also saving the signal mask.
Return 0. */
-extern int setjmp (jmp_buf __env) __THROW;
+extern int setjmp (jmp_buf __env) __THROWNL;
-/* Store the calling environment in ENV, not saving the signal mask.
- Return 0. */
-extern int _setjmp (jmp_buf __env) __THROW;
+__END_NAMESPACE_STD
/* Store the calling environment in ENV, also saving the
signal mask if SAVEMASK is nonzero. Return 0.
This is the internal name for `sigsetjmp'. */
-extern int __sigsetjmp (jmp_buf __env, int __savemask) __THROW;
+extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask)
+ __THROWNL;
#ifndef __FAVOR_BSD
+/* Store the calling environment in ENV, not saving the signal mask.
+ Return 0. */
+extern int _setjmp (struct __jmp_buf_tag __env[1]) __THROWNL;
+
/* Do not save the signal mask. This is equivalent to the `_setjmp'
BSD function. */
# define setjmp(env) _setjmp (env)
@@ -68,16 +75,21 @@ extern int __sigsetjmp (jmp_buf __env, int __savemask) __THROW;
#endif /* Favor BSD. */
+__BEGIN_NAMESPACE_STD
+
/* Jump to the environment saved in ENV, making the
`setjmp' call there return VAL, or 1 if VAL is 0. */
-extern void longjmp (jmp_buf __env, int __val)
- __THROW __attribute__ ((__noreturn__));
+extern void longjmp (struct __jmp_buf_tag __env[1], int __val)
+ __THROWNL __attribute__ ((__noreturn__));
+
+__END_NAMESPACE_STD
+
#if defined __USE_BSD || defined __USE_XOPEN
/* Same. Usually `_longjmp' is used with `_setjmp', which does not save
the signal mask. But it is how ENV was saved that determines whether
`longjmp' restores the mask; `_longjmp' is just an alias. */
-extern void _longjmp (jmp_buf __env, int __val)
- __THROW __attribute__ ((__noreturn__));
+extern void _longjmp (struct __jmp_buf_tag __env[1], int __val)
+ __THROWNL __attribute__ ((__noreturn__));
#endif
@@ -85,7 +97,7 @@ extern void _longjmp (jmp_buf __env, int __val)
/* Use the same type for `jmp_buf' and `sigjmp_buf'.
The `__mask_was_saved' flag determines whether
or not `longjmp' will restore the signal mask. */
-typedef jmp_buf sigjmp_buf;
+typedef struct __jmp_buf_tag sigjmp_buf[1];
/* Store the calling environment in ENV, also saving the
signal mask if SAVEMASK is nonzero. Return 0. */
@@ -96,9 +108,21 @@ typedef jmp_buf sigjmp_buf;
Restore the signal mask if that sigsetjmp call saved it.
This is just an alias `longjmp'. */
extern void siglongjmp (sigjmp_buf __env, int __val)
- __THROW __attribute__ ((__noreturn__));
+ __THROWNL __attribute__ ((__noreturn__));
#endif /* Use POSIX. */
__END_DECLS
+#ifdef _LIBC
+extern void __longjmp(__jmp_buf __env, int __val) __THROWNL attribute_noreturn;
+libc_hidden_proto(__longjmp)
+extern __typeof(longjmp) __libc_longjmp __THROWNL attribute_noreturn;
+extern __typeof(siglongjmp) __libc_siglongjmp __THROWNL attribute_noreturn;
+extern void _longjmp_unwind(jmp_buf __env, int __val);
+libc_hidden_proto(_longjmp_unwind)
+extern int __sigjmp_save(sigjmp_buf __env, int __savemask) attribute_hidden;
+/* We use the normal longjmp for unwinding */
+# define __libc_unwind_longjmp(buf, val) __libc_longjmp(buf, val)
+#endif
+
#endif /* setjmp.h */
diff --git a/include/sgtty.h b/include/sgtty.h
index 5b2bc4184..d37b58548 100644
--- a/include/sgtty.h
+++ b/include/sgtty.h
@@ -12,28 +12,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 _SGTTY_H
#define _SGTTY_H 1
+#warning useless header on uClibc
+
#include <features.h>
#include <sys/ioctl.h>
+#ifndef __UCLIBC_STRICT_HEADERS__
/* On some systems this type is not defined by <bits/ioctl-types.h>;
in that case, the functions are just stubs that return ENOSYS. */
struct sgttyb;
+#endif
__BEGIN_DECLS
+#if 0
/* Fill in *PARAMS with terminal parameters associated with FD. */
extern int gtty (int __fd, struct sgttyb *__params) __THROW;
/* Set the terminal parameters associated with FD to *PARAMS. */
-extern int stty (int __fd, __const struct sgttyb *__params) __THROW;
+extern int stty (int __fd, const struct sgttyb *__params) __THROW;
+#endif
__END_DECLS
diff --git a/include/shadow.h b/include/shadow.h
index 778df52b9..97725102f 100644
--- a/include/shadow.h
+++ b/include/shadow.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/>. */
/* Declaration of types and functions for shadow password suite. */
@@ -84,7 +83,7 @@ extern struct spwd *getspent (void);
cancellation point. But due to similarity with an POSIX interface
or due to the implementation it is a cancellation point and
therefore not marked with __THROW. */
-extern struct spwd *getspnam (__const char *__name);
+extern struct spwd *getspnam (const char *__name);
/* Read shadow entry from STRING.
@@ -92,7 +91,7 @@ extern struct spwd *getspnam (__const char *__name);
cancellation point. But due to similarity with an POSIX interface
or due to the implementation it is a cancellation point and
therefore not marked with __THROW. */
-extern struct spwd *sgetspent (__const char *__string);
+extern struct spwd *sgetspent (const char *__string);
/* Read next shadow entry from STREAM.
@@ -108,7 +107,7 @@ extern struct spwd *fgetspent (FILE *__stream);
cancellation point. But due to similarity with an POSIX interface
or due to the implementation it is a cancellation point and
therefore not marked with __THROW. */
-extern int putspent (__const struct spwd *__p, FILE *__stream);
+extern int putspent (const struct spwd *__p, FILE *__stream);
#ifdef __USE_MISC
@@ -120,18 +119,22 @@ extern int putspent (__const struct spwd *__p, FILE *__stream);
therefore not marked with __THROW. */
extern int getspent_r (struct spwd *__result_buf, char *__buffer,
size_t __buflen, struct spwd **__result);
+libc_hidden_proto(getspent_r)
-extern int getspnam_r (__const char *__name, struct spwd *__result_buf,
+extern int getspnam_r (const char *__name, struct spwd *__result_buf,
char *__buffer, size_t __buflen,
struct spwd **__result);
+libc_hidden_proto(getspnam_r)
-extern int sgetspent_r (__const char *__string, struct spwd *__result_buf,
+extern int sgetspent_r (const char *__string, struct spwd *__result_buf,
char *__buffer, size_t __buflen,
struct spwd **__result);
+libc_hidden_proto(sgetspent_r)
extern int fgetspent_r (FILE *__stream, struct spwd *__result_buf,
char *__buffer, size_t __buflen,
struct spwd **__result);
+libc_hidden_proto(fgetspent_r)
#endif /* misc */
diff --git a/include/signal.h b/include/signal.h
index 610acdc70..38baaccfb 100644
--- a/include/signal.h
+++ b/include/signal.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 1991-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
@@ -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 Standard: 7.14 Signal handling <signal.h>
@@ -57,32 +56,69 @@ typedef __sigset_t sigset_t;
#include <bits/types.h>
#include <bits/signum.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
+/* Biggest signal number + 1 (including real-time signals). */
+#ifndef _NSIG /* if arch has not defined it in bits/signum.h... */
+# define _NSIG 65
+#endif
+#ifdef __USE_MISC
+# define NSIG _NSIG
+#endif
+/* Real-time signal range */
+#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. */
+#ifndef __SIGRTMIN /* if arch has not defined it in bits/signum.h... */
+# define __SIGRTMIN 32
+#endif
+#define __SIGRTMAX (_NSIG - 1)
+
+
#if defined __USE_XOPEN || defined __USE_XOPEN2K
# ifndef __pid_t_defined
typedef __pid_t pid_t;
# define __pid_t_defined
+# endif
#endif
#ifdef __USE_XOPEN
-# endif
# ifndef __uid_t_defined
typedef __uid_t uid_t;
# define __uid_t_defined
# endif
#endif /* Unix98 */
+#if defined __USE_POSIX199309 && defined __UCLIBC_HAS_REALTIME__
+/* We need `struct timespec' later on. */
+# define __need_timespec
+# include <time.h>
+#endif
+
+#if defined __USE_POSIX199309 || defined __USE_XOPEN_EXTENDED
+/* Get the `siginfo_t' type plus the needed symbols. */
+# include <bits/siginfo.h>
+#endif
+
/* Type of a signal handler. */
typedef void (*__sighandler_t) (int);
+
#if defined __UCLIBC_HAS_OBSOLETE_SYSV_SIGNAL__
/* The X/Open definition of `signal' specifies the SVID semantic. Use
the additional function `sysv_signal' when X/Open compatibility is
requested. */
extern __sighandler_t __sysv_signal (int __sig, __sighandler_t __handler)
__THROW;
-#ifdef __USE_GNU
+# ifdef __USE_GNU
extern __sighandler_t sysv_signal (int __sig, __sighandler_t __handler)
__THROW;
-#endif
+# endif
#endif /* __UCLIBC_HAS_OBSOLETE_SYSV_SIGNAL__ */
/* Set the handler for the signal SIG to HANDLER, returning the old
@@ -92,6 +128,7 @@ __BEGIN_NAMESPACE_STD
#if defined __USE_BSD || !defined __UCLIBC_HAS_OBSOLETE_SYSV_SIGNAL__
extern __sighandler_t signal (int __sig, __sighandler_t __handler)
__THROW;
+libc_hidden_proto(signal)
#else
/* Make sure the used `signal' implementation is the SVID version. */
# ifdef __REDIRECT_NTH
@@ -104,7 +141,7 @@ extern __sighandler_t __REDIRECT_NTH (signal,
#endif
__END_NAMESPACE_STD
-#ifdef __USE_XOPEN
+#if defined __USE_XOPEN && defined __UCLIBC_SUSV3_LEGACY__
/* The X/Open definition of `signal' conflicts with the BSD version.
So they defined another function `bsd_signal'. */
extern __sighandler_t bsd_signal (int __sig, __sighandler_t __handler)
@@ -116,33 +153,41 @@ extern __sighandler_t bsd_signal (int __sig, __sighandler_t __handler)
If PID is < -1, send SIG to all processes in process group - PID. */
#ifdef __USE_POSIX
extern int kill (__pid_t __pid, int __sig) __THROW;
-#endif /* Use POSIX. */
+libc_hidden_proto(kill)
+#endif
#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
/* Send SIG to all processes in process group PGRP.
If PGRP is zero, send SIG to all processes in
the current process's process group. */
extern int killpg (__pid_t __pgrp, int __sig) __THROW;
-#endif /* Use BSD || X/Open Unix. */
+#endif
__BEGIN_NAMESPACE_STD
/* Raise signal SIG, i.e., send SIG to yourself. */
extern int raise (int __sig) __THROW;
+libc_hidden_proto(raise)
__END_NAMESPACE_STD
-#ifdef __USE_SVID
+#if 0 /*def __USE_SVID*/
/* SVID names for the same things. */
extern __sighandler_t ssignal (int __sig, __sighandler_t __handler)
__THROW;
extern int gsignal (int __sig) __THROW;
#endif /* Use SVID. */
-#ifdef __USE_MISC
+/* glibc guards the next two wrong with __USE_XOPEN2K */
+#if defined __USE_MISC || defined __USE_XOPEN2K8
/* Print a message describing the meaning of the given signal number. */
-extern void psignal (int __sig, __const char *__s);
-#endif /* Use misc. */
+extern void psignal (int __sig, const char *__s);
+#endif /* Use misc or POSIX 2008. */
+#if 0 /*def __USE_XOPEN2K8*/
+/* Print a message describing the meaning of the given signal information. */
+extern void psiginfo (const siginfo_t *__pinfo, const char *__s);
+#endif /* POSIX 2008. */
+#ifdef __UCLIBC_SUSV4_LEGACY__
/* The `sigpause' function has two different interfaces. The original
BSD definition defines the argument as a mask of the signal, while
the more modern interface in X/Open defines it as the signal
@@ -151,22 +196,25 @@ extern void psignal (int __sig, __const char *__s);
This function is a cancellation point and therefore not marked with
__THROW. */
-extern int __sigpause (int __sig_or_mask, int __is_sig);
+/*extern int __sigpause (int __sig_or_mask, int __is_sig);*/
#ifdef __FAVOR_BSD
/* Set the mask of blocked signals to MASK,
wait for a signal to arrive, and then restore the mask. */
-extern int sigpause (int __mask) __THROW __attribute_deprecated__;
-# define sigpause(mask) __sigpause ((mask), 0)
+/*extern int sigpause (int __mask) __THROW __attribute_deprecated__;
+# define sigpause(mask) __sigpause ((mask), 0)*/
+/* uClibc note: BSD sigpause is available as __bsd_sigpause.
+ * It is intentionally not prototyped */
#else
# ifdef __USE_XOPEN
/* Remove a signal from the signal mask and suspend the process. */
-# define sigpause(sig) __sigpause ((sig), 1)
+extern int sigpause(int __sig);
+/*# define sigpause(sig) __sigpause ((sig), 1)*/
# endif
#endif
+#endif /* __UCLIBC_SUSV4_LEGACY__ */
-
-#ifdef __USE_BSD
+#if 0 /*def __USE_BSD*/
/* None of the following functions should be used anymore. They are here
only for compatibility. A single word (`int') is not guaranteed to be
enough to hold a complete signal mask and therefore these functions
@@ -186,10 +234,6 @@ extern int siggetmask (void) __THROW __attribute_deprecated__;
#endif /* Use BSD. */
-#ifdef __USE_MISC
-# define NSIG _NSIG
-#endif
-
#ifdef __USE_GNU
typedef __sighandler_t sighandler_t;
#endif
@@ -201,15 +245,6 @@ typedef __sighandler_t sig_t;
#ifdef __USE_POSIX
-# ifdef __USE_POSIX199309
-/* We need `struct timespec' later on. */
-# define __need_timespec
-# include <time.h>
-
-/* Get the `siginfo_t' type plus the needed symbols. */
-# include <bits/siginfo.h>
-# endif
-
/* Clear all signals from SET. */
extern int sigemptyset (sigset_t *__set) __THROW __nonnull ((1));
@@ -218,25 +253,27 @@ extern int sigfillset (sigset_t *__set) __THROW __nonnull ((1));
/* Add SIGNO to SET. */
extern int sigaddset (sigset_t *__set, int __signo) __THROW __nonnull ((1));
+libc_hidden_proto(sigaddset)
/* Remove SIGNO from SET. */
extern int sigdelset (sigset_t *__set, int __signo) __THROW __nonnull ((1));
+libc_hidden_proto(sigdelset)
/* Return 1 if SIGNO is in SET, 0 if not. */
-extern int sigismember (__const sigset_t *__set, int __signo)
+extern int sigismember (const sigset_t *__set, int __signo)
__THROW __nonnull ((1));
# ifdef __USE_GNU
/* Return non-empty value is SET is not empty. */
-extern int sigisemptyset (__const sigset_t *__set) __THROW __nonnull ((1));
+extern int sigisemptyset (const sigset_t *__set) __THROW __nonnull ((1));
/* Build new signal set by combining the two inputs set using logical AND. */
-extern int sigandset (sigset_t *__set, __const sigset_t *__left,
- __const sigset_t *__right) __THROW __nonnull ((1, 2, 3));
+extern int sigandset (sigset_t *__set, const sigset_t *__left,
+ const sigset_t *__right) __THROW __nonnull ((1, 2, 3));
/* Build new signal set by combining the two inputs set using logical OR. */
-extern int sigorset (sigset_t *__set, __const sigset_t *__left,
- __const sigset_t *__right) __THROW __nonnull ((1, 2, 3));
+extern int sigorset (sigset_t *__set, const sigset_t *__left,
+ const sigset_t *__right) __THROW __nonnull ((1, 2, 3));
# endif /* GNU */
/* Get the system-specific definitions of `struct sigaction'
@@ -244,19 +281,58 @@ extern int sigorset (sigset_t *__set, __const sigset_t *__left,
# include <bits/sigaction.h>
/* Get and/or change the set of blocked signals. */
-extern int sigprocmask (int __how, __const sigset_t *__restrict __set,
+extern int sigprocmask (int __how, const sigset_t *__restrict __set,
sigset_t *__restrict __oset) __THROW;
+libc_hidden_proto(sigprocmask)
/* Change the set of blocked signals to SET,
wait until a signal arrives, and restore the set of blocked signals.
This function is a cancellation point and therefore not marked with
__THROW. */
-extern int sigsuspend (__const sigset_t *__set) __nonnull ((1));
+extern int sigsuspend (const sigset_t *__set) __nonnull ((1));
+#ifdef _LIBC
+extern __typeof(sigsuspend) __sigsuspend_nocancel attribute_hidden;
+libc_hidden_proto(sigsuspend)
+#endif
/* Get and/or set the action for signal SIG. */
-extern int sigaction (int __sig, __const struct sigaction *__restrict __act,
+extern int sigaction (int __sig, const struct sigaction *__restrict __act,
struct sigaction *__restrict __oact) __THROW;
+#ifdef _LIBC
+# if 0 /* this is in headers */
+/* In uclibc, userspace struct sigaction is identical to
+ * "new" struct kernel_sigaction (one from the Linux 2.1.68 kernel).
+ * See sigaction.h
+ */
+struct old_kernel_sigaction;
+extern int __syscall_sigaction(int, const struct old_kernel_sigaction *,
+ struct old_kernel_sigaction *) attribute_hidden;
+# else /* this is how the function is built */
+extern __typeof(sigaction) __syscall_sigaction attribute_hidden;
+# endif
+# define __need_size_t
+# include <stddef.h>
+/* candidate for attribute_hidden, if NPTL would behave */
+extern int __syscall_rt_sigaction(int, const struct sigaction *,
+ struct sigaction *, size_t)
+# ifndef __UCLIBC_HAS_THREADS_NATIVE__
+ attribute_hidden
+# endif
+ ;
+extern __typeof(sigaction) __libc_sigaction;
+libc_hidden_proto(sigaction)
+
+# ifdef __mips__
+# define _KERNEL_NSIG_WORDS (_NSIG / _MIPS_SZLONG)
+typedef struct {
+ unsigned long sig[_KERNEL_NSIG_WORDS];
+} kernel_sigset_t;
+# define __SYSCALL_SIGSET_T_SIZE (sizeof(kernel_sigset_t))
+# else
+# define __SYSCALL_SIGSET_T_SIZE (_NSIG / 8)
+# endif
+#endif
/* Put in SET all signals that are blocked and waiting to be delivered. */
extern int sigpending (sigset_t *__set) __THROW __nonnull ((1));
@@ -266,7 +342,7 @@ extern int sigpending (sigset_t *__set) __THROW __nonnull ((1));
This function is a cancellation point and therefore not marked with
__THROW. */
-extern int sigwait (__const sigset_t *__restrict __set, int *__restrict __sig)
+extern int sigwait (const sigset_t *__restrict __set, int *__restrict __sig)
__nonnull ((1, 2));
# if defined __USE_POSIX199309 && defined __UCLIBC_HAS_REALTIME__
@@ -274,22 +350,29 @@ extern int sigwait (__const sigset_t *__restrict __set, int *__restrict __sig)
This function is a cancellation point and therefore not marked with
__THROW. */
-extern int sigwaitinfo (__const sigset_t *__restrict __set,
+extern int sigwaitinfo (const sigset_t *__restrict __set,
siginfo_t *__restrict __info) __nonnull ((1));
+#ifdef _LIBC
+extern __typeof(sigwaitinfo) __sigwaitinfo attribute_hidden;
+#endif
/* Select any of pending signals from SET and place information in INFO.
Wait the time specified by TIMEOUT if no signal is pending.
This function is a cancellation point and therefore not marked with
__THROW. */
-extern int sigtimedwait (__const sigset_t *__restrict __set,
+extern int sigtimedwait (const sigset_t *__restrict __set,
siginfo_t *__restrict __info,
- __const struct timespec *__restrict __timeout)
+ const struct timespec *__restrict __timeout)
__nonnull ((1));
+#ifdef _LIBC
+extern __typeof(sigtimedwait) __sigtimedwait_nocancel attribute_hidden;
+libc_hidden_proto(sigtimedwait)
+#endif
/* Send signal SIG to the process PID. Associate data in VAL with the
signal. */
-extern int sigqueue (__pid_t __pid, int __sig, __const union sigval __val)
+extern int sigqueue (__pid_t __pid, int __sig, const union sigval __val)
__THROW;
# endif /* Use POSIX 199306. */
@@ -297,13 +380,14 @@ extern int sigqueue (__pid_t __pid, int __sig, __const union sigval __val)
#ifdef __USE_BSD
-#ifdef __UCLIBC_HAS_SYS_SIGLIST__
+# ifdef __UCLIBC_HAS_SYS_SIGLIST__
/* Names of the signals. This variable exists only for compatibility.
Use `strsignal' instead (see <string.h>). */
-#define _sys_siglist sys_siglist
-extern __const char *__const sys_siglist[_NSIG];
-#endif /* __UCLIBC_HAS_SYS_SIGLIST__ */
+# define _sys_siglist sys_siglist
+extern const char *const sys_siglist[_NSIG];
+# endif
+#ifndef __UCLIBC_STRICT_HEADERS__
/* Structure passed to `sigvec'. */
struct sigvec
{
@@ -318,48 +402,60 @@ struct sigvec
# define SV_ONSTACK (1 << 0)/* Take the signal on the signal stack. */
# define SV_INTERRUPT (1 << 1)/* Do not restart system calls. */
# define SV_RESETHAND (1 << 2)/* Reset handler to SIG_DFL on receipt. */
+#endif
+#if 0
/* If VEC is non-NULL, set the handler for SIG to the `sv_handler' member
of VEC. The signals in `sv_mask' will be blocked while the handler runs.
If the SV_RESETHAND bit is set in `sv_flags', the handler for SIG will be
reset to SIG_DFL before `sv_handler' is entered. If OVEC is non-NULL,
it is filled in with the old information for SIG. */
-extern int sigvec (int __sig, __const struct sigvec *__vec,
+extern int sigvec (int __sig, const struct sigvec *__vec,
struct sigvec *__ovec) __THROW;
+#endif
/* Get machine-dependent `struct sigcontext' and signal subcodes. */
# include <bits/sigcontext.h>
+#if 0
/* Restore the state saved in SCP. */
extern int sigreturn (struct sigcontext *__scp) __THROW;
+#endif
#endif /* use BSD. */
#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
+# define __need_size_t
+# include <stddef.h>
+# ifdef __UCLIBC_SUSV4_LEGACY__
/* If INTERRUPT is nonzero, make signal SIG interrupt system calls
(causing them to fail with EINTR); if INTERRUPT is zero, make system
calls be restarted after signal SIG. */
extern int siginterrupt (int __sig, int __interrupt) __THROW;
+# endif
# include <bits/sigstack.h>
# ifdef __USE_XOPEN
/* This will define `ucontext_t' and `mcontext_t'. */
-# include <ucontext.h>
+/* SuSv4 obsoleted include/ucontext.h */
+# include <sys/ucontext.h>
# endif
+# if 0
/* Run signals handlers on the stack specified by SS (if not NULL).
If OSS is not NULL, it is filled in with the old signal stack status.
This interface is obsolete and on many platform not implemented. */
extern int sigstack (struct sigstack *__ss, struct sigstack *__oss)
__THROW __attribute_deprecated__;
+# endif
/* Alternate signal handler stack interface.
This interface should always be preferred over `sigstack'. */
-extern int sigaltstack (__const struct sigaltstack *__restrict __ss,
+extern int sigaltstack (const struct sigaltstack *__restrict __ss,
struct sigaltstack *__restrict __oss) __THROW;
#endif /* use BSD or X/Open Unix. */
@@ -385,7 +481,7 @@ extern __sighandler_t sigset (int __sig, __sighandler_t __disp) __THROW;
be defined here. */
# include <bits/pthreadtypes.h>
# include <bits/sigthread.h>
-#endif /* use Unix98 */
+#endif
/* The following functions are used internally in the C library and in
other code which need deep insights. */
@@ -395,6 +491,10 @@ extern int __libc_current_sigrtmin (void) __THROW;
/* Return number of available real-time signal with lowest priority. */
extern int __libc_current_sigrtmax (void) __THROW;
+#ifdef _LIBC
+extern sigset_t _sigintr attribute_hidden;
+# include <string.h>
+#endif
#endif /* signal.h */
__END_DECLS
diff --git a/include/spawn.h b/include/spawn.h
new file mode 100644
index 000000000..3de375b41
--- /dev/null
+++ b/include/spawn.h
@@ -0,0 +1,295 @@
+/* Definitions for POSIX spawn interface.
+ Copyright (C) 2000,2003,2004,2009,2011,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 _SPAWN_H
+#define _SPAWN_H 1
+
+#include <features.h>
+#include <sched.h>
+#define __need_sigset_t
+#include <signal.h>
+#include <sys/types.h>
+
+/* For the tiny inlines (errno/free/memset). */
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+
+
+/* Data structure to contain attributes for thread creation. */
+typedef struct
+{
+ short int __flags;
+ pid_t __pgrp;
+ sigset_t __sd;
+ sigset_t __ss;
+ struct sched_param __sp;
+ int __policy;
+ int __pad[16];
+} posix_spawnattr_t;
+
+
+/* Data structure to contain information about the actions to be
+ performed in the new process with respect to file descriptors. */
+typedef struct
+{
+ int __allocated;
+ int __used;
+ struct __spawn_action *__actions;
+ int __pad[16];
+} posix_spawn_file_actions_t;
+
+
+/* Flags to be set in the `posix_spawnattr_t'. */
+#define POSIX_SPAWN_RESETIDS 0x01
+#define POSIX_SPAWN_SETPGROUP 0x02
+#define POSIX_SPAWN_SETSIGDEF 0x04
+#define POSIX_SPAWN_SETSIGMASK 0x08
+#define POSIX_SPAWN_SETSCHEDPARAM 0x10
+#define POSIX_SPAWN_SETSCHEDULER 0x20
+#ifdef __USE_GNU
+# define POSIX_SPAWN_USEVFORK 0x40
+#endif
+
+__BEGIN_DECLS
+
+/* Spawn a new process executing PATH with the attributes describes in *ATTRP.
+ Before running the process perform the actions described in FILE-ACTIONS.
+
+ This function is a possible cancellation point and therefore not
+ marked with __THROW. */
+extern int posix_spawn (pid_t *__restrict __pid,
+ const char *__restrict __path,
+ const posix_spawn_file_actions_t *__restrict
+ __file_actions,
+ const posix_spawnattr_t *__restrict __attrp,
+ char *const __argv[__restrict_arr],
+ char *const __envp[__restrict_arr]);
+
+/* Similar to `posix_spawn' but search for FILE in the PATH.
+
+ This function is a possible cancellation point and therefore not
+ marked with __THROW. */
+extern int posix_spawnp (pid_t *__pid, const char *__file,
+ const posix_spawn_file_actions_t *__file_actions,
+ const posix_spawnattr_t *__attrp,
+ char *const __argv[], char *const __envp[]);
+
+
+/* Initialize data structure with attributes for `spawn' to default values. */
+static inline
+int posix_spawnattr_init (posix_spawnattr_t *__attr)
+{
+ memset (__attr, 0, sizeof (*__attr));
+ return 0;
+}
+
+/* Free resources associated with ATTR. */
+static inline
+int posix_spawnattr_destroy (posix_spawnattr_t *__attr)
+{
+ return 0;
+}
+
+/* Store signal mask for signals with default handling from ATTR in
+ SIGDEFAULT. */
+static inline
+int posix_spawnattr_getsigdefault (const posix_spawnattr_t *
+ __restrict __attr,
+ sigset_t *__restrict __sigdefault)
+{
+ memcpy (__sigdefault, &__attr->__sd, sizeof (sigset_t));
+ return 0;
+}
+
+/* Set signal mask for signals with default handling in ATTR to SIGDEFAULT. */
+static inline
+int posix_spawnattr_setsigdefault (posix_spawnattr_t *__restrict __attr,
+ const sigset_t *__restrict
+ __sigdefault)
+{
+ memcpy (&__attr->__sd, __sigdefault, sizeof (sigset_t));
+ return 0;
+}
+
+/* Store signal mask for the new process from ATTR in SIGMASK. */
+static inline
+int posix_spawnattr_getsigmask (const posix_spawnattr_t *__restrict
+ __attr,
+ sigset_t *__restrict __sigmask)
+{
+ memcpy (__sigmask, &__attr->__ss, sizeof (sigset_t));
+ return 0;
+}
+
+/* Set signal mask for the new process in ATTR to SIGMASK. */
+static inline
+int posix_spawnattr_setsigmask (posix_spawnattr_t *__restrict __attr,
+ const sigset_t *__restrict __sigmask)
+{
+ memcpy (&__attr->__ss, __sigmask, sizeof (sigset_t));
+ return 0;
+}
+
+/* Get flag word from the attribute structure. */
+static inline
+int posix_spawnattr_getflags (const posix_spawnattr_t *__restrict
+ __attr,
+ short int *__restrict __flags)
+{
+ *__flags = __attr->__flags;
+ return 0;
+}
+
+/* Store flags in the attribute structure. */
+static inline
+int posix_spawnattr_setflags (posix_spawnattr_t *_attr,
+ short int __flags)
+{
+#ifdef POSIX_SPAWN_USEVFORK
+# define __POSIX_SPAWN_USEVFORK POSIX_SPAWN_USEVFORK
+#else
+# define __POSIX_SPAWN_USEVFORK 0
+#endif
+#define __POSIX_SPAWN_MASK (POSIX_SPAWN_RESETIDS \
+ | POSIX_SPAWN_SETPGROUP \
+ | POSIX_SPAWN_SETSIGDEF \
+ | POSIX_SPAWN_SETSIGMASK \
+ | POSIX_SPAWN_SETSCHEDPARAM \
+ | POSIX_SPAWN_SETSCHEDULER \
+ | __POSIX_SPAWN_USEVFORK)
+
+ /* Check no invalid bits are set. */
+ if (__flags & ~__POSIX_SPAWN_MASK)
+ return EINVAL;
+
+ _attr->__flags = __flags;
+ return 0;
+#undef __POSIX_SPAWN_USEVFORK
+#undef __POSIX_SPAWN_MASK
+}
+
+/* Get process group ID from the attribute structure. */
+static inline
+int posix_spawnattr_getpgroup (const posix_spawnattr_t *__restrict
+ __attr, pid_t *__restrict __pgroup)
+{
+ *__pgroup = __attr->__pgrp;
+ return 0;
+}
+
+/* Store process group ID in the attribute structure. */
+static inline
+int posix_spawnattr_setpgroup (posix_spawnattr_t *__attr,
+ pid_t __pgroup)
+{
+ __attr->__pgrp = __pgroup;
+ return 0;
+}
+
+/* Get scheduling policy from the attribute structure. */
+static inline
+int posix_spawnattr_getschedpolicy (const posix_spawnattr_t *
+ __restrict __attr,
+ int *__restrict __schedpolicy)
+{
+ *__schedpolicy = __attr->__policy;
+ return 0;
+}
+
+/* Store scheduling policy in the attribute structure. */
+static inline
+int posix_spawnattr_setschedpolicy (posix_spawnattr_t *__attr,
+ int __schedpolicy)
+{
+ switch (__schedpolicy) {
+ case SCHED_OTHER:
+ case SCHED_FIFO:
+ case SCHED_RR:
+ break;
+ default:
+ return EINVAL;
+ }
+
+ __attr->__policy = __schedpolicy;
+ return 0;
+}
+
+/* Get scheduling parameters from the attribute structure. */
+static inline
+int posix_spawnattr_getschedparam (const posix_spawnattr_t *
+ __restrict __attr,
+ struct sched_param *__restrict
+ __schedparam)
+{
+ memcpy (__schedparam, &__attr->__sp, sizeof (__attr->__sp));
+ return 0;
+}
+
+/* Store scheduling parameters in the attribute structure. */
+static inline
+int posix_spawnattr_setschedparam (posix_spawnattr_t *__restrict __attr,
+ const struct sched_param *
+ __restrict __schedparam)
+{
+ __attr->__sp = *__schedparam;
+ return 0;
+}
+
+/* Initialize data structure for file attribute for `spawn' call. */
+static inline
+int posix_spawn_file_actions_init (posix_spawn_file_actions_t *
+ __file_actions)
+{
+ memset (__file_actions, 0, sizeof (*__file_actions));
+ return 0;
+}
+
+/* Free resources associated with FILE-ACTIONS. */
+static inline
+int posix_spawn_file_actions_destroy (posix_spawn_file_actions_t *
+ __file_actions)
+{
+ free (__file_actions->__actions);
+ return 0;
+}
+
+/* Add an action to FILE-ACTIONS which tells the implementation to call
+ `open' for the given file during the `spawn' call. */
+extern int posix_spawn_file_actions_addopen (posix_spawn_file_actions_t *
+ __restrict __file_actions,
+ int __fd,
+ const char *__restrict __path,
+ int __oflag, mode_t __mode)
+ __THROW;
+
+/* Add an action to FILE-ACTIONS which tells the implementation to call
+ `close' for the given file descriptor during the `spawn' call. */
+extern int posix_spawn_file_actions_addclose (posix_spawn_file_actions_t *
+ __file_actions, int __fd)
+ __THROW;
+
+/* Add an action to FILE-ACTIONS which tells the implementation to call
+ `dup2' for the given file descriptors during the `spawn' call. */
+extern int posix_spawn_file_actions_adddup2 (posix_spawn_file_actions_t *
+ __file_actions,
+ int __fd, int __newfd) __THROW;
+
+__END_DECLS
+
+#endif /* spawn.h */
diff --git a/include/stdint.h b/include/stdint.h
index 6d1ecbec4..9ca84453c 100644
--- a/include/stdint.h
+++ b/include/stdint.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1997,1998,1999,2000,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
@@ -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.18 Integer types <stdint.h>
@@ -238,7 +237,7 @@ typedef unsigned long long int uintmax_t;
# define UINTPTR_MAX (4294967295U)
# endif
-#if !defined(__H8300H__) && !defined(__H8300S__)
+
/* Minimum for largest signed integral type. */
# define INTMAX_MIN (-__INT64_C(9223372036854775807)-1)
/* Maximum for largest signed integral type. */
@@ -246,15 +245,6 @@ typedef unsigned long long int uintmax_t;
/* Maximum for largest unsigned integral type. */
# define UINTMAX_MAX (__UINT64_C(18446744073709551615))
-#else
-/* Minimum for largest signed integral type. */
-# define INTMAX_MIN (-LONG_LONG_MAX-1)
-/* Maximum for largest signed integral type. */
-# define INTMAX_MAX (LONG_LONG_MAX)
-
-/* Maximum for largest unsigned integral type. */
-# define UINTMAX_MAX (LONG_LONG_MAX<<1+1)
-#endif
/* Limits of other integer types. */
@@ -309,8 +299,8 @@ typedef unsigned long long int uintmax_t;
# endif
/* Unsigned. */
-# define UINT8_C(c) c ## U
-# define UINT16_C(c) c ## U
+# define UINT8_C(c) c
+# define UINT16_C(c) c
# define UINT32_C(c) c ## U
# if __WORDSIZE == 64
# define UINT64_C(c) c ## UL
diff --git a/include/stdio.h b/include/stdio.h
index c854ec333..9aae5abf4 100644
--- a/include/stdio.h
+++ b/include/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/>. */
/*
* ISO C99 Standard: 7.19 Input/output <stdio.h>
@@ -88,7 +87,7 @@ typedef __STDIO_fpos64_t fpos64_t;
#endif
/* The possibilities for the third argument to `setvbuf'. */
-#define _IOFBF __STDIO_IOFBF /* Fully buffered. */
+#define _IOFBF __STDIO_IOFBF /* Fully buffered. */
#define _IOLBF __STDIO_IOLBF /* Line buffered. */
#define _IONBF __STDIO_IONBF /* No buffering. */
@@ -114,7 +113,7 @@ typedef __STDIO_fpos64_t fpos64_t;
#if defined __USE_SVID || defined __USE_XOPEN
-/* Default path prefix for `tempnam' and `tmpnam'. */
+/* Default path prefix for `mkstemp'. */
# define P_tmpdir "/tmp"
#endif
@@ -122,7 +121,7 @@ typedef __STDIO_fpos64_t fpos64_t;
/* Get the values:
L_tmpnam How long an array of chars must be to be passed to `tmpnam'.
TMP_MAX The minimum number of unique filenames generated by tmpnam
- (and tempnam when it uses tmpnam's name space),
+ (and tempnam when it uses tmpnam's name space),
or tempnam (the two are separate).
L_ctermid How long an array to pass to `ctermid'.
L_cuserid How long an array to pass to `cuserid'.
@@ -142,16 +141,23 @@ extern FILE *stderr; /* Standard error output stream. */
__BEGIN_NAMESPACE_STD
/* Remove file FILENAME. */
-extern int remove (__const char *__filename) __THROW;
+extern int remove (const char *__filename) __THROW;
+libc_hidden_proto(remove)
/* Rename file OLD to NEW. */
-extern int rename (__const char *__old, __const char *__new) __THROW;
+extern int rename (const char *__old, const char *__new) __THROW;
__END_NAMESPACE_STD
+#ifdef __USE_ATFILE
+/* Rename file OLD relative to OLDFD to NEW relative to NEWFD. */
+extern int renameat (int __oldfd, const char *__old, int __newfd,
+ const char *__new) __THROW;
+libc_hidden_proto(renameat)
+#endif
__BEGIN_NAMESPACE_STD
/* Create a temporary file and open it read/write.
- This function is a possible cancellation points and therefore not
+ This function is a possible cancellation point and therefore not
marked with __THROW. */
#ifndef __USE_FILE_OFFSET64
extern FILE *tmpfile (void) __wur;
@@ -167,18 +173,20 @@ extern FILE *__REDIRECT (tmpfile, (void), tmpfile64) __wur;
extern FILE *tmpfile64 (void) __wur;
#endif
+#ifdef __UCLIBC_SUSV4_LEGACY__
/* Generate a temporary filename. */
extern char *tmpnam (char *__s) __THROW __wur;
+#endif
__END_NAMESPACE_STD
-#ifdef __USE_MISC
+#if defined __USE_MISC && defined __UCLIBC_SUSV4_LEGACY__
/* This is the reentrant variant of `tmpnam'. The only difference is
that it does not allow S to be NULL. */
extern char *tmpnam_r (char *__s) __THROW __wur;
#endif
-#if defined __USE_SVID || defined __USE_XOPEN
+#if (defined __USE_SVID || defined __USE_XOPEN) && defined __UCLIBC_SUSV4_LEGACY__
/* Generate a unique temporary filename using up to five characters of PFX
if it is not NULL. The directory to put this file in is searched for
as follows: First the environment variable "TMPDIR" is checked.
@@ -186,7 +194,7 @@ extern char *tmpnam_r (char *__s) __THROW __wur;
If not and if DIR is not NULL, that value is checked. If that fails,
P_tmpdir is tried and finally "/tmp". The storage for the filename
is allocated by `malloc'. */
-extern char *tempnam (__const char *__dir, __const char *__pfx)
+extern char *tempnam (const char *__dir, const char *__pfx)
__THROW __attribute_malloc__ __wur;
#endif
@@ -197,11 +205,13 @@ __BEGIN_NAMESPACE_STD
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern int fclose (FILE *__stream);
+libc_hidden_proto(fclose)
/* Flush STREAM, or all streams if STREAM is NULL.
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern int fflush (FILE *__stream);
+libc_hidden_proto(fflush)
__END_NAMESPACE_STD
#ifdef __USE_MISC
@@ -212,6 +222,7 @@ __END_NAMESPACE_STD
or due to the implementation it is a cancellation point and
therefore not marked with __THROW. */
extern int fflush_unlocked (FILE *__stream);
+libc_hidden_proto(fflush_unlocked)
#endif
#ifdef __USE_GNU
@@ -231,22 +242,23 @@ __BEGIN_NAMESPACE_STD
This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern FILE *fopen (__const char *__restrict __filename,
- __const char *__restrict __modes) __wur;
+extern FILE *fopen (const char *__restrict __filename,
+ const char *__restrict __modes) __wur;
+libc_hidden_proto(fopen)
/* Open a file, replacing an existing stream with it.
This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern FILE *freopen (__const char *__restrict __filename,
- __const char *__restrict __modes,
+extern FILE *freopen (const char *__restrict __filename,
+ const char *__restrict __modes,
FILE *__restrict __stream) __wur;
#else
# ifdef __REDIRECT
-extern FILE *__REDIRECT (fopen, (__const char *__restrict __filename,
- __const char *__restrict __modes), fopen64)
+extern FILE *__REDIRECT (fopen, (const char *__restrict __filename,
+ const char *__restrict __modes), fopen64)
__wur;
-extern FILE *__REDIRECT (freopen, (__const char *__restrict __filename,
- __const char *__restrict __modes,
+extern FILE *__REDIRECT (freopen, (const char *__restrict __filename,
+ const char *__restrict __modes,
FILE *__restrict __stream), freopen64)
__wur;
# else
@@ -256,35 +268,40 @@ extern FILE *__REDIRECT (freopen, (__const char *__restrict __filename,
#endif
__END_NAMESPACE_STD
#ifdef __USE_LARGEFILE64
-extern FILE *fopen64 (__const char *__restrict __filename,
- __const char *__restrict __modes) __wur;
-extern FILE *freopen64 (__const char *__restrict __filename,
- __const char *__restrict __modes,
+extern FILE *fopen64 (const char *__restrict __filename,
+ const char *__restrict __modes) __wur;
+libc_hidden_proto(fopen64)
+extern FILE *freopen64 (const char *__restrict __filename,
+ const char *__restrict __modes,
FILE *__restrict __stream) __wur;
#endif
#ifdef __USE_POSIX
/* Create a new stream that refers to an existing system file descriptor. */
-extern FILE *fdopen (int __fd, __const char *__modes) __THROW __wur;
+extern FILE *fdopen (int __fd, const char *__modes) __THROW __wur;
+libc_hidden_proto(fdopen)
#endif
-#ifdef __USE_GNU
#ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__
+#ifdef __USE_GNU
/* Create a new stream that refers to the given magic cookie,
and uses the given functions for input and output. */
extern FILE *fopencookie (void *__restrict __magic_cookie,
- __const char *__restrict __modes,
+ const char *__restrict __modes,
_IO_cookie_io_functions_t __io_funcs) __THROW __wur;
+libc_hidden_proto(fopencookie)
+#endif
+#ifdef __USE_XOPEN2K8
/* Create a new stream that refers to a memory buffer. */
-extern FILE *fmemopen (void *__s, size_t __len, __const char *__modes)
+extern FILE *fmemopen (void *__s, size_t __len, const char *__modes)
__THROW __wur;
/* Open a stream that writes into a malloc'd buffer that is expanded as
necessary. *BUFLOC and *SIZELOC are updated with the buffer's location
and the number of characters written on fflush or fclose. */
-extern FILE *open_memstream (char **__restrict __bufloc,
- size_t *__restrict __sizeloc) __THROW __wur;
+extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __THROW __wur;
+libc_hidden_proto(open_memstream)
#endif
#endif
@@ -298,6 +315,7 @@ extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __THROW;
else allocate an internal buffer N bytes long. */
extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
int __modes, size_t __n) __THROW;
+libc_hidden_proto(setvbuf)
__END_NAMESPACE_STD
#ifdef __USE_BSD
@@ -317,70 +335,81 @@ __BEGIN_NAMESPACE_STD
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern int fprintf (FILE *__restrict __stream,
- __const char *__restrict __format, ...);
+ const char *__restrict __format, ...);
+libc_hidden_proto(fprintf)
/* Write formatted output to stdout.
This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern int printf (__const char *__restrict __format, ...);
+extern int printf (const char *__restrict __format, ...);
+libc_hidden_proto(printf)
/* Write formatted output to S. */
extern int sprintf (char *__restrict __s,
- __const char *__restrict __format, ...) __THROW;
+ const char *__restrict __format, ...) __THROWNL
+ __attribute__ ((__format__ (__printf__, 2, 3)));
+libc_hidden_proto(sprintf)
/* Write formatted output to S from argument list ARG.
This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern int vfprintf (FILE *__restrict __s, __const char *__restrict __format,
+extern int vfprintf (FILE *__restrict __s, const char *__restrict __format,
__gnuc_va_list __arg);
+libc_hidden_proto(vfprintf)
/* Write formatted output to stdout from argument list ARG.
This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern int vprintf (__const char *__restrict __format, __gnuc_va_list __arg);
+extern int vprintf (const char *__restrict __format, __gnuc_va_list __arg);
/* Write formatted output to S from argument list ARG. */
-extern int vsprintf (char *__restrict __s, __const char *__restrict __format,
- __gnuc_va_list __arg) __THROW;
+extern int vsprintf (char *__restrict __s, const char *__restrict __format,
+ __gnuc_va_list __arg) __THROWNL
+ __attribute__ ((__format__ (__printf__, 2, 0)));
__END_NAMESPACE_STD
#if defined __USE_BSD || defined __USE_ISOC99 || defined __USE_UNIX98
__BEGIN_NAMESPACE_C99
/* Maximum chars of output to write in MAXLEN. */
extern int snprintf (char *__restrict __s, size_t __maxlen,
- __const char *__restrict __format, ...)
- __THROW __attribute__ ((__format__ (__printf__, 3, 4)));
+ const char *__restrict __format, ...)
+ __THROWNL __attribute__ ((__format__ (__printf__, 3, 4)));
+libc_hidden_proto(snprintf)
extern int vsnprintf (char *__restrict __s, size_t __maxlen,
- __const char *__restrict __format, __gnuc_va_list __arg)
- __THROW __attribute__ ((__format__ (__printf__, 3, 0)));
+ const char *__restrict __format, __gnuc_va_list __arg)
+ __THROWNL __attribute__ ((__format__ (__printf__, 3, 0)));
+libc_hidden_proto(vsnprintf)
__END_NAMESPACE_C99
#endif
#ifdef __USE_GNU
/* Write formatted output to a string dynamically allocated with `malloc'.
Store the address of the string in *PTR. */
-extern int vasprintf (char **__restrict __ptr, __const char *__restrict __f,
+extern int vasprintf (char **__restrict __ptr, const char *__restrict __f,
__gnuc_va_list __arg)
- __THROW __attribute__ ((__format__ (__printf__, 2, 0))) __wur;
+ __THROWNL __attribute__ ((__format__ (__printf__, 2, 0))) __wur;
+libc_hidden_proto(vasprintf)
#if 0 /* uClibc: disabled */
extern int __asprintf (char **__restrict __ptr,
- __const char *__restrict __fmt, ...)
- __THROW __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
+ const char *__restrict __fmt, ...)
+ __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
#endif
extern int asprintf (char **__restrict __ptr,
- __const char *__restrict __fmt, ...)
- __THROW __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
+ const char *__restrict __fmt, ...)
+ __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
+libc_hidden_proto(asprintf)
+#endif
+#ifdef __USE_XOPEN2K8
/* Write formatted output to a file descriptor.
- These functions are not part of POSIX and therefore no official
- cancellation point. But due to similarity with an POSIX interface
- or due to the implementation they are cancellation points and
- therefore not marked with __THROW. */
-extern int vdprintf (int __fd, __const char *__restrict __fmt,
+ This function is a possible cancellation point and therefore not
+ marked with __THROW. */
+extern int vdprintf (int __fd, const char *__restrict __fmt,
__gnuc_va_list __arg)
__attribute__ ((__format__ (__printf__, 2, 0)));
-extern int dprintf (int __fd, __const char *__restrict __fmt, ...)
+libc_hidden_proto(vdprintf)
+extern int dprintf (int __fd, const char *__restrict __fmt, ...)
__attribute__ ((__format__ (__printf__, 2, 3)));
#endif
@@ -391,15 +420,20 @@ __BEGIN_NAMESPACE_STD
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern int fscanf (FILE *__restrict __stream,
- __const char *__restrict __format, ...) __wur;
+ const char *__restrict __format, ...)
+ __attribute__ ((__format__ (__scanf__, 2, 3))) __wur;
+libc_hidden_proto(fscanf)
/* Read formatted input from stdin.
This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern int scanf (__const char *__restrict __format, ...) __wur;
+extern int scanf (const char *__restrict __format, ...)
+ __attribute__ ((__format__ (__scanf__, 1, 2))) __wur;
/* Read formatted input from S. */
-extern int sscanf (__const char *__restrict __s,
- __const char *__restrict __format, ...) __THROW;
+extern int sscanf (const char *__restrict __s,
+ const char *__restrict __format, ...)
+ __THROW __attribute__ ((__format__ (__scanf__, 2, 3)));
+libc_hidden_proto(sscanf)
__END_NAMESPACE_STD
#ifdef __USE_ISOC99
@@ -408,21 +442,23 @@ __BEGIN_NAMESPACE_C99
This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern int vfscanf (FILE *__restrict __s, __const char *__restrict __format,
+extern int vfscanf (FILE *__restrict __s, const char *__restrict __format,
__gnuc_va_list __arg)
__attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
+libc_hidden_proto(vfscanf)
/* Read formatted input from stdin into argument list ARG.
This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern int vscanf (__const char *__restrict __format, __gnuc_va_list __arg)
+extern int vscanf (const char *__restrict __format, __gnuc_va_list __arg)
__attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
/* Read formatted input from S into argument list ARG. */
-extern int vsscanf (__const char *__restrict __s,
- __const char *__restrict __format, __gnuc_va_list __arg)
+extern int vsscanf (const char *__restrict __s,
+ const char *__restrict __format, __gnuc_va_list __arg)
__THROW __attribute__ ((__format__ (__scanf__, 2, 0)));
+libc_hidden_proto(vsscanf)
__END_NAMESPACE_C99
#endif /* Use ISO C9x. */
@@ -433,6 +469,7 @@ __BEGIN_NAMESPACE_STD
These functions are possible cancellation points and therefore not
marked with __THROW. */
extern int fgetc (FILE *__stream);
+libc_hidden_proto(fgetc)
extern int getc (FILE *__stream);
/* Read a character from stdin.
@@ -452,10 +489,9 @@ __END_NAMESPACE_STD
These functions are possible cancellation points and therefore not
marked with __THROW. */
extern int getc_unlocked (FILE *__stream);
+libc_hidden_proto(getc_unlocked)
extern int getchar_unlocked (void);
-
-/* SUSv3 allows getc_unlocked to be a macro */
-#define getc_unlocked(_fp) __GETC_UNLOCKED(_fp)
+libc_hidden_proto(getchar_unlocked)
#endif /* Use POSIX or MISC. */
#ifdef __USE_MISC
@@ -466,6 +502,7 @@ extern int getchar_unlocked (void);
or due to the implementation it is a cancellation point and
therefore not marked with __THROW. */
extern int fgetc_unlocked (FILE *__stream);
+libc_hidden_proto(fgetc_unlocked)
#endif /* Use MISC. */
@@ -478,6 +515,7 @@ __BEGIN_NAMESPACE_STD
These functions is a possible cancellation point and therefore not
marked with __THROW. */
extern int fputc (int __c, FILE *__stream);
+libc_hidden_proto(fputc)
extern int putc (int __c, FILE *__stream);
/* Write a character to stdout.
@@ -508,9 +546,6 @@ extern int fputc_unlocked (int __c, FILE *__stream);
marked with __THROW. */
extern int putc_unlocked (int __c, FILE *__stream);
extern int putchar_unlocked (int __c);
-
-/* SUSv3 allows putc_unlocked to be a macro */
-#define putc_unlocked(_ch, _fp) __PUTC_UNLOCKED(_ch, _fp)
#endif /* Use POSIX or MISC. */
@@ -531,13 +566,23 @@ __BEGIN_NAMESPACE_STD
marked with __THROW. */
extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
__wur;
+libc_hidden_proto(fgets)
+#if !defined __USE_ISOC11 \
+ || (defined __cplusplus && __cplusplus <= 201103L)
/* Get a newline-terminated string from stdin, removing the newline.
DO NOT USE THIS FUNCTION!! There is no limit on how much it will read.
+ The function has been officially removed in ISO C11. This opportunity
+ is used to also remove it from the GNU feature list. It is now only
+ available when explicitly using an old ISO C, Unix, or POSIX standard.
+ GCC defines _GNU_SOURCE when building C++ code and the function is still
+ in C++11, so it is also available for C++.
+
This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern char *gets (char *__s) __wur;
+extern char *gets (char *__s) __wur __attribute_deprecated__;
+#endif
__END_NAMESPACE_STD
#ifdef __USE_GNU
@@ -549,10 +594,11 @@ __END_NAMESPACE_STD
therefore not marked with __THROW. */
extern char *fgets_unlocked (char *__restrict __s, int __n,
FILE *__restrict __stream) __wur;
+libc_hidden_proto(fgets_unlocked)
#endif
-#ifdef __USE_GNU
+#ifdef __USE_XOPEN2K8
/* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
(and null-terminate it). *LINEPTR is a pointer returned from malloc (or
NULL), pointing to *N characters of space. It is realloc'd as
@@ -571,6 +617,7 @@ extern __ssize_t __getdelim (char **__restrict __lineptr,
extern __ssize_t getdelim (char **__restrict __lineptr,
size_t *__restrict __n, int __delimiter,
FILE *__restrict __stream) __wur;
+libc_hidden_proto(getdelim)
/* Like `getdelim', but reads up to a newline.
@@ -581,42 +628,47 @@ extern __ssize_t getdelim (char **__restrict __lineptr,
extern __ssize_t getline (char **__restrict __lineptr,
size_t *__restrict __n,
FILE *__restrict __stream) __wur;
+libc_hidden_proto(getline)
#endif
__BEGIN_NAMESPACE_STD
/* Write a string to STREAM.
- This function is a possible cancellation points and therefore not
+ This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern int fputs (__const char *__restrict __s, FILE *__restrict __stream);
+extern int fputs (const char *__restrict __s, FILE *__restrict __stream);
+libc_hidden_proto(fputs)
/* Write a string, followed by a newline, to stdout.
- This function is a possible cancellation points and therefore not
+ This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern int puts (__const char *__s);
+extern int puts (const char *__s);
/* Push a character back onto the input buffer of STREAM.
- This function is a possible cancellation points and therefore not
+ This function is a possible cancellation point and therefore not
marked with __THROW. */
extern int ungetc (int __c, FILE *__stream);
+libc_hidden_proto(ungetc)
/* Read chunks of generic data from STREAM.
- This function is a possible cancellation points and therefore not
+ This function is a possible cancellation point and therefore not
marked with __THROW. */
extern size_t fread (void *__restrict __ptr, size_t __size,
size_t __n, FILE *__restrict __stream) __wur;
+libc_hidden_proto(fread)
/* Write chunks of generic data to STREAM.
- This function is a possible cancellation points and therefore not
+ This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern size_t fwrite (__const void *__restrict __ptr, size_t __size,
+extern size_t fwrite (const void *__restrict __ptr, size_t __size,
size_t __n, FILE *__restrict __s) __wur;
+libc_hidden_proto(fwrite)
__END_NAMESPACE_STD
#ifdef __USE_GNU
@@ -626,8 +678,9 @@ __END_NAMESPACE_STD
cancellation point. But due to similarity with an POSIX interface
or due to the implementation it is a cancellation point and
therefore not marked with __THROW. */
-extern int fputs_unlocked (__const char *__restrict __s,
+extern int fputs_unlocked (const char *__restrict __s,
FILE *__restrict __stream);
+libc_hidden_proto(fputs_unlocked)
#endif
#ifdef __USE_MISC
@@ -639,8 +692,10 @@ extern int fputs_unlocked (__const char *__restrict __s,
therefore not marked with __THROW. */
extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
size_t __n, FILE *__restrict __stream) __wur;
-extern size_t fwrite_unlocked (__const void *__restrict __ptr, size_t __size,
+libc_hidden_proto(fread_unlocked)
+extern size_t fwrite_unlocked (const void *__restrict __ptr, size_t __size,
size_t __n, FILE *__restrict __stream) __wur;
+libc_hidden_proto(fwrite_unlocked)
#endif
@@ -650,16 +705,19 @@ __BEGIN_NAMESPACE_STD
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern int fseek (FILE *__stream, long int __off, int __whence);
+libc_hidden_proto(fseek)
/* Return the current position of STREAM.
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern long int ftell (FILE *__stream) __wur;
+libc_hidden_proto(ftell)
/* Rewind to the beginning of STREAM.
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern void rewind (FILE *__stream);
+libc_hidden_proto(rewind)
__END_NAMESPACE_STD
/* The Single Unix Specification, Version 2, specifies an alternative,
@@ -703,13 +761,13 @@ extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos);
This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern int fsetpos (FILE *__stream, __const fpos_t *__pos);
+extern int fsetpos (FILE *__stream, const fpos_t *__pos);
#else
# ifdef __REDIRECT
extern int __REDIRECT (fgetpos, (FILE *__restrict __stream,
fpos_t *__restrict __pos), fgetpos64);
extern int __REDIRECT (fsetpos,
- (FILE *__stream, __const fpos_t *__pos), fsetpos64);
+ (FILE *__stream, const fpos_t *__pos), fsetpos64);
# else
# define fgetpos fgetpos64
# define fsetpos fsetpos64
@@ -719,9 +777,11 @@ __END_NAMESPACE_STD
#ifdef __USE_LARGEFILE64
extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence);
+libc_hidden_proto(fseeko64)
extern __off64_t ftello64 (FILE *__stream) __wur;
+libc_hidden_proto(ftello64)
extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos);
-extern int fsetpos64 (FILE *__stream, __const fpos64_t *__pos);
+extern int fsetpos64 (FILE *__stream, const fpos64_t *__pos);
#endif
__BEGIN_NAMESPACE_STD
@@ -746,7 +806,8 @@ __BEGIN_NAMESPACE_STD
This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern void perror (__const char *__s);
+extern void perror (const char *__s);
+libc_hidden_proto(perror)
__END_NAMESPACE_STD
#ifdef __UCLIBC_HAS_SYS_ERRLIST__
@@ -754,7 +815,7 @@ __END_NAMESPACE_STD
function provides all the needed functionality. */
#ifdef __USE_BSD
extern int sys_nerr;
-extern __const char *__const sys_errlist[];
+extern const char *const sys_errlist[];
#endif
#endif /* __UCLIBC_HAS_SYS_ERRLIST__ */
@@ -762,11 +823,13 @@ extern __const char *__const sys_errlist[];
#ifdef __USE_POSIX
/* Return the system file descriptor for STREAM. */
extern int fileno (FILE *__stream) __THROW __wur;
+libc_hidden_proto(fileno)
#endif /* Use POSIX. */
#ifdef __USE_MISC
/* Faster version when locking is not required. */
extern int fileno_unlocked (FILE *__stream) __THROW __wur;
+libc_hidden_proto(fileno_unlocked)
#endif
@@ -776,7 +839,7 @@ extern int fileno_unlocked (FILE *__stream) __THROW __wur;
This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern FILE *popen (__const char *__command, __const char *__modes) __wur;
+extern FILE *popen (const char *__command, const char *__modes) __wur;
/* Close a stream opened by popen and return the status of its child.
@@ -798,18 +861,19 @@ extern char *cuserid (char *__s);
#endif /* Use X/Open, but not issue 6. */
-#if 0 /* def __USE_GNU uClibc note: not supported */
+#if defined __USE_GNU && defined __UCLIBC_HAS_OBSTACK__
struct obstack; /* See <obstack.h>. */
/* Write formatted output to an obstack. */
extern int obstack_printf (struct obstack *__restrict __obstack,
- __const char *__restrict __format, ...)
- __THROW __attribute__ ((__format__ (__printf__, 2, 3)));
+ const char *__restrict __format, ...)
+ __THROWNL __attribute__ ((__format__ (__printf__, 2, 3)));
extern int obstack_vprintf (struct obstack *__restrict __obstack,
- __const char *__restrict __format,
+ const char *__restrict __format,
__gnuc_va_list __args)
- __THROW __attribute__ ((__format__ (__printf__, 2, 0)));
-#endif /* Use GNU. */
+ __THROWNL __attribute__ ((__format__ (__printf__, 2, 0)));
+libc_hidden_proto(obstack_vprintf)
+#endif /* USE_GNU && UCLIBC_HAS_OBSTACK. */
#if defined __USE_POSIX || defined __USE_MISC
@@ -831,27 +895,31 @@ extern void funlockfile (FILE *__stream) __THROW;
declared here which do not belong into this header. But we have to
follow. In GNU mode we don't do this nonsense. */
# define __need_getopt
+/* keep this on uClibc in bits/, we need it when GNU_GETOPT is disabled */
# include <bits/getopt.h>
#endif /* X/Open, but not issue 6 and not for GNU. */
/* If we are compiling with optimizing read this file. It contains
several optimizing inline functions and macros. */
+
+#ifdef __UCLIBC__
+
#define fgetc(_fp) __FGETC(_fp)
#define fputc(_ch, _fp) __FPUTC(_ch, _fp)
+#if defined __USE_POSIX || defined __USE_MISC
+/* SUSv3 allows getc_unlocked to be a macro */
+#define getc_unlocked(_fp) __GETC_UNLOCKED(_fp)
+/* SUSv3 allows putc_unlocked to be a macro */
+#define putc_unlocked(_ch, _fp) __PUTC_UNLOCKED(_ch, _fp)
+#endif
+
#ifdef __USE_MISC
#define fgetc_unlocked(_fp) __FGETC_UNLOCKED(_fp)
#define fputc_unlocked(_ch, _fp) __FPUTC_UNLOCKED(_ch, _fp)
#endif
-#ifndef __STDIO_GETC_MACRO
-#define __stdin stdin
-#endif
#define getchar() __GETC(__stdin)
-
-#ifndef __STDIO_PUTC_MACRO
-#define __stdout stdout
-#endif
#define putchar(_ch) __PUTC((_ch), __stdout)
#if defined __USE_POSIX || defined __USE_MISC
@@ -870,6 +938,8 @@ extern void funlockfile (FILE *__stream) __THROW;
#define ferror_unlocked(_fp) __FERROR_UNLOCKED(_fp)
#endif
+#endif
+
__END_DECLS
#endif /* <stdio.h> included. */
diff --git a/include/stdio_ext.h b/include/stdio_ext.h
index 23d12e092..c9443499d 100644
--- a/include/stdio_ext.h
+++ b/include/stdio_ext.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/>. */
/* This header contains the same definitions as the header of the same name
on Sun's Solaris OS. */
@@ -81,6 +80,7 @@ extern void _flushlbf (void);
/* Set locking status of stream FP to TYPE. */
extern int __fsetlocking (FILE *__fp, int __type) __THROW;
+libc_hidden_proto(__fsetlocking)
__END_DECLS
diff --git a/include/stdlib.h b/include/stdlib.h
index b87dfd921..ba8849ed0 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2003, 2004, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 1991-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
@@ -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 Standard: 7.20 General utilities <stdlib.h>
@@ -39,7 +38,7 @@ __BEGIN_DECLS
#ifndef __need_malloc_and_calloc
#define _STDLIB_H 1
-#if defined __USE_XOPEN && !defined _SYS_WAIT_H
+#if (defined __USE_XOPEN || defined __USE_XOPEN2K8) && !defined _SYS_WAIT_H
/* XPG requires a few symbols from <sys/wait.h> being defined. */
# include <bits/waitflags.h>
# include <bits/waitstatus.h>
@@ -50,15 +49,15 @@ __BEGIN_DECLS
as well as POSIX.1 use of `int' for the status word. */
# if defined __GNUC__ && !defined __cplusplus
-# define __WAIT_INT(status) \
- (__extension__ ({ union { __typeof(status) __in; int __i; } __u; \
- __u.__in = (status); __u.__i; }))
+# define __WAIT_INT(status) \
+ (__extension__ (((union { __typeof(status) __in; int __i; }) \
+ { .__in = (status) }).__i))
# else
# define __WAIT_INT(status) (*(int *) &(status))
# endif
/* This is the type of the argument to `wait'. The funky union
- causes redeclarations with ether `int *' or `union wait *' to be
+ causes redeclarations with either `int *' or `union wait *' to be
allowed without complaint. __WAIT_STATUS_DEFN is the type used in
the actual function definitions. */
@@ -84,14 +83,14 @@ typedef union
# endif /* Use BSD. */
/* Define the macros <sys/wait.h> also would define this way. */
-# define WEXITSTATUS(status) __WEXITSTATUS(__WAIT_INT(status))
-# define WTERMSIG(status) __WTERMSIG(__WAIT_INT(status))
-# define WSTOPSIG(status) __WSTOPSIG(__WAIT_INT(status))
-# define WIFEXITED(status) __WIFEXITED(__WAIT_INT(status))
-# define WIFSIGNALED(status) __WIFSIGNALED(__WAIT_INT(status))
-# define WIFSTOPPED(status) __WIFSTOPPED(__WAIT_INT(status))
-# if 0 /* def __WIFCONTINUED */
-# define WIFCONTINUED(status) __WIFCONTINUED(__WAIT_INT(status))
+# define WEXITSTATUS(status) __WEXITSTATUS (__WAIT_INT (status))
+# define WTERMSIG(status) __WTERMSIG (__WAIT_INT (status))
+# define WSTOPSIG(status) __WSTOPSIG (__WAIT_INT (status))
+# define WIFEXITED(status) __WIFEXITED (__WAIT_INT (status))
+# define WIFSIGNALED(status) __WIFSIGNALED (__WAIT_INT (status))
+# define WIFSTOPPED(status) __WIFSTOPPED (__WAIT_INT (status))
+# ifdef __WIFCONTINUED
+# define WIFCONTINUED(status) __WIFCONTINUED (__WAIT_INT (status))
# endif
#endif /* X/Open and <sys/wait.h> not included. */
@@ -141,31 +140,36 @@ __END_NAMESPACE_C99
#if 0
#define MB_CUR_MAX (__ctype_get_mb_cur_max ())
extern size_t __ctype_get_mb_cur_max (void) __THROW __wur;
-#endif
+#else
#ifdef __UCLIBC_HAS_WCHAR__
-#define MB_CUR_MAX (_stdlib_mb_cur_max ())
+# define MB_CUR_MAX (_stdlib_mb_cur_max ())
extern size_t _stdlib_mb_cur_max (void) __THROW __wur;
+libc_hidden_proto(_stdlib_mb_cur_max)
+#else
+# define MB_CUR_MAX 1
+#endif
#endif
__BEGIN_NAMESPACE_STD
#ifdef __UCLIBC_HAS_FLOATS__
/* Convert a string to a floating-point number. */
-extern double atof (__const char *__nptr)
+extern double atof (const char *__nptr)
__THROW __attribute_pure__ __nonnull ((1)) __wur;
#endif /* __UCLIBC_HAS_FLOATS__ */
/* Convert a string to an integer. */
-extern int atoi (__const char *__nptr)
+extern int atoi (const char *__nptr)
__THROW __attribute_pure__ __nonnull ((1)) __wur;
+libc_hidden_proto(atoi)
/* Convert a string to a long integer. */
-extern long int atol (__const char *__nptr)
+extern long int atol (const char *__nptr)
__THROW __attribute_pure__ __nonnull ((1)) __wur;
__END_NAMESPACE_STD
#if defined __USE_ISOC99 || defined __USE_MISC
__BEGIN_NAMESPACE_C99
/* Convert a string to a long long integer. */
-__extension__ extern long long int atoll (__const char *__nptr)
+__extension__ extern long long int atoll (const char *__nptr)
__THROW __attribute_pure__ __nonnull ((1)) __wur;
__END_NAMESPACE_C99
#endif
@@ -173,18 +177,19 @@ __END_NAMESPACE_C99
#ifdef __UCLIBC_HAS_FLOATS__
__BEGIN_NAMESPACE_STD
/* Convert a string to a floating-point number. */
-extern double strtod (__const char *__restrict __nptr,
+extern double strtod (const char *__restrict __nptr,
char **__restrict __endptr)
__THROW __nonnull ((1)) __wur;
+libc_hidden_proto(strtod)
__END_NAMESPACE_STD
#ifdef __USE_ISOC99
__BEGIN_NAMESPACE_C99
/* Likewise for `float' and `long double' sizes of floating-point numbers. */
-extern float strtof (__const char *__restrict __nptr,
+extern float strtof (const char *__restrict __nptr,
char **__restrict __endptr) __THROW __nonnull ((1)) __wur;
-extern long double strtold (__const char *__restrict __nptr,
+extern long double strtold (const char *__restrict __nptr,
char **__restrict __endptr)
__THROW __nonnull ((1)) __wur;
__END_NAMESPACE_C99
@@ -193,24 +198,28 @@ __END_NAMESPACE_C99
__BEGIN_NAMESPACE_STD
/* Convert a string to a long integer. */
-extern long int strtol (__const char *__restrict __nptr,
+extern long int strtol (const char *__restrict __nptr,
char **__restrict __endptr, int __base)
__THROW __nonnull ((1)) __wur;
+libc_hidden_proto(strtol)
/* Convert a string to an unsigned long integer. */
-extern unsigned long int strtoul (__const char *__restrict __nptr,
+extern unsigned long int strtoul (const char *__restrict __nptr,
char **__restrict __endptr, int __base)
__THROW __nonnull ((1)) __wur;
+libc_hidden_proto(strtoul)
__END_NAMESPACE_STD
#ifdef __USE_BSD
+#include <sys/types.h> /* for u_quad_t */
+
/* Convert a string to a quadword integer. */
__extension__
-extern long long int strtoq (__const char *__restrict __nptr,
+extern quad_t strtoq (const char *__restrict __nptr,
char **__restrict __endptr, int __base)
__THROW __nonnull ((1)) __wur;
/* Convert a string to an unsigned quadword integer. */
__extension__
-extern unsigned long long int strtouq (__const char *__restrict __nptr,
+extern u_quad_t strtouq (const char *__restrict __nptr,
char **__restrict __endptr, int __base)
__THROW __nonnull ((1)) __wur;
#endif /* GCC and use BSD. */
@@ -219,30 +228,30 @@ extern unsigned long long int strtouq (__const char *__restrict __nptr,
__BEGIN_NAMESPACE_C99
/* Convert a string to a quadword integer. */
__extension__
-extern long long int strtoll (__const char *__restrict __nptr,
+extern long long int strtoll (const char *__restrict __nptr,
char **__restrict __endptr, int __base)
__THROW __nonnull ((1)) __wur;
+libc_hidden_proto(strtoll)
/* Convert a string to an unsigned quadword integer. */
__extension__
-extern unsigned long long int strtoull (__const char *__restrict __nptr,
+extern unsigned long long int strtoull (const char *__restrict __nptr,
char **__restrict __endptr, int __base)
__THROW __nonnull ((1)) __wur;
__END_NAMESPACE_C99
#endif /* ISO C99 or GCC and use MISC. */
-#ifdef __UCLIBC_HAS_XLOCALE__
-#ifdef __USE_GNU
+#if defined __USE_GNU && defined __UCLIBC_HAS_XLOCALE__
/* The concept of one static locale per category is not very well
thought out. Many applications will need to process its data using
- information from several different locales. Another application is
+ information from several different locales. Another problem is
the implementation of the internationalization handling in the
- upcoming ISO C++ standard library. To support this another set of
- the functions using locale data exist which have an additional
+ ISO C++ standard library. To support this another set of
+ the functions using locale data exist which take an additional
argument.
- Attention: all these functions are *not* standardized in any form.
- This is a proof-of-concept implementation. */
+ Attention: even though several *_l interfaces are part of POSIX:2008,
+ these are not. */
/* Structure for reentrant locale using functions. This is an
(almost) opaque type for the user level programs. */
@@ -250,44 +259,44 @@ __END_NAMESPACE_C99
/* Special versions of the functions above which take the locale to
use as an additional parameter. */
-extern long int strtol_l (__const char *__restrict __nptr,
+extern long int strtol_l (const char *__restrict __nptr,
char **__restrict __endptr, int __base,
__locale_t __loc) __THROW __nonnull ((1, 4)) __wur;
+libc_hidden_proto(strtol_l)
-extern unsigned long int strtoul_l (__const char *__restrict __nptr,
+extern unsigned long int strtoul_l (const char *__restrict __nptr,
char **__restrict __endptr,
int __base, __locale_t __loc)
__THROW __nonnull ((1, 4)) __wur;
+libc_hidden_proto(strtoul_l)
__extension__
-extern long long int strtoll_l (__const char *__restrict __nptr,
+extern long long int strtoll_l (const char *__restrict __nptr,
char **__restrict __endptr, int __base,
__locale_t __loc)
__THROW __nonnull ((1, 4)) __wur;
__extension__
-extern unsigned long long int strtoull_l (__const char *__restrict __nptr,
+extern unsigned long long int strtoull_l (const char *__restrict __nptr,
char **__restrict __endptr,
int __base, __locale_t __loc)
__THROW __nonnull ((1, 4)) __wur;
#ifdef __UCLIBC_HAS_FLOATS__
-extern double strtod_l (__const char *__restrict __nptr,
+extern double strtod_l (const char *__restrict __nptr,
char **__restrict __endptr, __locale_t __loc)
__THROW __nonnull ((1, 3)) __wur;
-extern float strtof_l (__const char *__restrict __nptr,
+extern float strtof_l (const char *__restrict __nptr,
char **__restrict __endptr, __locale_t __loc)
__THROW __nonnull ((1, 3)) __wur;
-extern long double strtold_l (__const char *__restrict __nptr,
+extern long double strtold_l (const char *__restrict __nptr,
char **__restrict __endptr,
__locale_t __loc)
__THROW __nonnull ((1, 3)) __wur;
#endif /* __UCLIBC_HAS_FLOATS__ */
-
#endif /* GNU */
-#endif /* __UCLIBC_HAS_XLOCALE__ */
#if defined __USE_SVID || defined __USE_XOPEN_EXTENDED
@@ -297,7 +306,7 @@ extern long double strtold_l (__const char *__restrict __nptr,
extern char *l64a (long int __n) __THROW __wur;
/* Read a number from a string S in base 64 as above. */
-extern long int a64l (__const char *__s)
+extern long int a64l (const char *__s)
__THROW __attribute_pure__ __nonnull ((1)) __wur;
#endif /* Use SVID || extended X/Open. */
@@ -311,6 +320,7 @@ extern long int a64l (__const char *__s)
We provide both interfaces to the same random number generator. */
/* Return a random long integer between 0 and RAND_MAX inclusive. */
extern long int random (void) __THROW;
+libc_hidden_proto(random)
/* Seed the random number generator with the given number. */
extern void srandom (unsigned int __seed) __THROW;
@@ -337,26 +347,37 @@ struct random_data
int32_t *fptr; /* Front pointer. */
int32_t *rptr; /* Rear pointer. */
int32_t *state; /* Array of state values. */
+#if 0
int rand_type; /* Type of random number generator. */
int rand_deg; /* Degree of random number generator. */
int rand_sep; /* Distance between front and rear. */
+#else
+ /* random_r.c, TYPE_x, DEG_x, SEP_x - small enough for int8_t */
+ int8_t rand_type; /* Type of random number generator. */
+ int8_t rand_deg; /* Degree of random number generator. */
+ int8_t rand_sep; /* Distance between front and rear. */
+#endif
int32_t *end_ptr; /* Pointer behind state table. */
};
extern int random_r (struct random_data *__restrict __buf,
int32_t *__restrict __result) __THROW __nonnull ((1, 2));
+libc_hidden_proto(random_r)
extern int srandom_r (unsigned int __seed, struct random_data *__buf)
__THROW __nonnull ((2));
+libc_hidden_proto(srandom_r)
extern int initstate_r (unsigned int __seed, char *__restrict __statebuf,
size_t __statelen,
struct random_data *__restrict __buf)
__THROW __nonnull ((2, 4));
+libc_hidden_proto(initstate_r)
extern int setstate_r (char *__restrict __statebuf,
struct random_data *__restrict __buf)
__THROW __nonnull ((1, 2));
+libc_hidden_proto(setstate_r)
# endif /* Use misc. */
#endif /* Use SVID || extended X/Open || BSD. */
@@ -419,16 +440,19 @@ extern int drand48_r (struct drand48_data *__restrict __buffer,
extern int erand48_r (unsigned short int __xsubi[3],
struct drand48_data *__restrict __buffer,
double *__restrict __result) __THROW __nonnull ((1, 2));
+libc_hidden_proto(erand48_r)
#endif /* __UCLIBC_HAS_FLOATS__ */
/* Return non-negative, long integer in [0,2^31). */
extern int lrand48_r (struct drand48_data *__restrict __buffer,
long int *__restrict __result)
__THROW __nonnull ((1, 2));
+libc_hidden_proto(lrand48_r)
extern int nrand48_r (unsigned short int __xsubi[3],
struct drand48_data *__restrict __buffer,
long int *__restrict __result)
__THROW __nonnull ((1, 2));
+libc_hidden_proto(nrand48_r)
/* Return signed, long integers in [-2^31,2^31). */
extern int mrand48_r (struct drand48_data *__restrict __buffer,
@@ -438,13 +462,16 @@ extern int jrand48_r (unsigned short int __xsubi[3],
struct drand48_data *__restrict __buffer,
long int *__restrict __result)
__THROW __nonnull ((1, 2));
+libc_hidden_proto(jrand48_r)
/* Seed random number generator. */
extern int srand48_r (long int __seedval, struct drand48_data *__buffer)
__THROW __nonnull ((2));
+libc_hidden_proto(srand48_r)
extern int seed48_r (unsigned short int __seed16v[3],
struct drand48_data *__buffer) __THROW __nonnull ((1, 2));
+libc_hidden_proto(seed48_r)
extern int lcong48_r (unsigned short int __param[7],
struct drand48_data *__buffer)
@@ -459,9 +486,11 @@ extern int lcong48_r (unsigned short int __param[7],
__BEGIN_NAMESPACE_STD
/* Allocate SIZE bytes of memory. */
extern void *malloc (size_t __size) __THROW __attribute_malloc__ __wur;
+/* We want the malloc symbol overridable at runtime, do not hide it! */
/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */
extern void *calloc (size_t __nmemb, size_t __size)
__THROW __attribute_malloc__ __wur;
+/* We want the calloc symbol overridable at runtime, do not hide it! */
__END_NAMESPACE_STD
#endif
@@ -469,13 +498,18 @@ __END_NAMESPACE_STD
__BEGIN_NAMESPACE_STD
/* Re-allocate the previously allocated block
in PTR, making the new block SIZE bytes long. */
+/* __attribute_malloc__ is not used, because if realloc returns
+ the same pointer that was passed to it, aliasing needs to be allowed
+ between objects pointed by the old and new pointers. */
extern void *realloc (void *__ptr, size_t __size)
- __THROW __attribute_malloc__ __attribute_warn_unused_result__;
+ __THROW __wur;
+/* We want the realloc symbol overridable at runtime, do not hide it! */
/* Free a block allocated by `malloc', `realloc' or `calloc'. */
extern void free (void *__ptr) __THROW;
+/* We want the free symbol overridable at runtime, do not hide it! */
__END_NAMESPACE_STD
-#ifdef __USE_MISC
+#if 0 /*def __USE_MISC*/
/* Free a block. An alias for `free'. (Sun Unices). */
extern void cfree (void *__ptr) __THROW;
#endif /* Use misc. */
@@ -498,6 +532,7 @@ extern int posix_memalign (void **__memptr, size_t __alignment, size_t __size)
__BEGIN_NAMESPACE_STD
/* Abort execution and generate a core-dump. */
extern void abort (void) __THROW __attribute__ ((__noreturn__));
+libc_hidden_proto(abort)
/* Register a function to be called when `exit' is called. */
@@ -513,9 +548,10 @@ extern int on_exit (void (*__func) (int __status, void *__arg), void *__arg)
__BEGIN_NAMESPACE_STD
/* Call all functions registered with `atexit' and `on_exit',
- in the reverse of the order in which they were registered
+ in the reverse of the order in which they were registered,
perform stdio cleanup, and terminate program execution with STATUS. */
extern void exit (int __status) __THROW __attribute__ ((__noreturn__));
+libc_hidden_proto(exit)
__END_NAMESPACE_STD
#ifdef __USE_ISOC99
@@ -529,13 +565,16 @@ __END_NAMESPACE_C99
__BEGIN_NAMESPACE_STD
/* Return the value of envariable NAME, or NULL if it doesn't exist. */
-extern char *getenv (__const char *__name) __THROW __nonnull ((1)) __wur;
+extern char *getenv (const char *__name) __THROW __nonnull ((1)) __wur;
+libc_hidden_proto(getenv)
__END_NAMESPACE_STD
+#if 0
/* This function is similar to the above but returns NULL if the
programs is running with SUID or SGID enabled. */
-extern char *__secure_getenv (__const char *__name)
+extern char *__secure_getenv (const char *__name)
__THROW __nonnull ((1)) __wur;
+#endif
#if defined __USE_SVID || defined __USE_XOPEN
/* The SVID says this is in <stdio.h>, but this seems a better place. */
@@ -547,11 +586,13 @@ extern int putenv (char *__string) __THROW __nonnull ((1));
#if defined __USE_BSD || defined __USE_XOPEN2K
/* Set NAME to VALUE in the environment.
If REPLACE is nonzero, overwrite an existing value. */
-extern int setenv (__const char *__name, __const char *__value, int __replace)
+extern int setenv (const char *__name, const char *__value, int __replace)
__THROW __nonnull ((2));
+libc_hidden_proto(setenv)
/* Remove the variable NAME from the environment. */
-extern int unsetenv (__const char *__name) __THROW;
+extern int unsetenv (const char *__name) __THROW;
+libc_hidden_proto(unsetenv)
#endif
/* The following is used by uClibc in atexit.c and sysconf.c */
@@ -572,11 +613,13 @@ extern int clearenv (void) __THROW;
#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
+# if defined __UCLIBC_SUSV3_LEGACY__
/* Generate a unique temporary file name from TEMPLATE.
The last six characters of TEMPLATE must be "XXXXXX";
they are replaced with a string that makes the file name unique.
Returns TEMPLATE, or a null pointer if it cannot get a unique file name. */
extern char *mktemp (char *__template) __THROW __nonnull ((1)) __wur;
+# endif
/* Generate a unique temporary file name from TEMPLATE.
The last six characters of TEMPLATE must be "XXXXXX";
@@ -584,7 +627,7 @@ extern char *mktemp (char *__template) __THROW __nonnull ((1)) __wur;
Returns a file descriptor open on the file for reading and writing,
or -1 if it cannot create a uniquely-named file.
- This function is a possible cancellation points and therefore not
+ This function is a possible cancellation point and therefore not
marked with __THROW. */
# ifndef __USE_FILE_OFFSET64
extern int mkstemp (char *__template) __nonnull ((1)) __wur;
@@ -601,7 +644,36 @@ extern int mkstemp64 (char *__template) __nonnull ((1)) __wur;
# endif
#endif
-#ifdef __USE_BSD
+#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
+# if defined __UCLIBC_SUSV3_LEGACY__
+extern char *mktemps (char *__template, int __suffixlen) __THROW __nonnull ((1)) __wur;
+# endif
+
+/* The mkstemps() function is like mkstemp(), except that the string in
+ template contains a suffix of suffixlen characters. Thus, template is
+ of the form prefixXXXXXXsuffix, and the string XXXXXX is modified as
+ for mkstemp().
+ Returns a file descriptor open on the file for reading and writing,
+ or -1 if it cannot create a uniquely-named file.
+
+ This function is a possible cancellation point and therefore not
+ marked with __THROW. */
+# ifndef __USE_FILE_OFFSET64
+extern int mkstemps (char *__template, int __suffixlen) __nonnull ((1)) __wur;
+# else
+# ifdef __REDIRECT
+extern int __REDIRECT (mkstemps, (char *__template, int __suffixlen), mkstemps64)
+ __nonnull ((1)) __wur;
+# else
+# define mkstemps mkstemps64
+# endif
+# endif
+# ifdef __USE_LARGEFILE64
+extern int mkstemps64 (char *__template, int __suffixlen) __nonnull ((1)) __wur;
+# endif
+#endif
+
+#if defined __USE_BSD || defined __USE_XOPEN2K8
/* Create a unique temporary directory from TEMPLATE.
The last six characters of TEMPLATE must be "XXXXXX";
they are replaced with a string that makes the directory name unique.
@@ -610,51 +682,95 @@ extern int mkstemp64 (char *__template) __nonnull ((1)) __wur;
extern char *mkdtemp (char *__template) __THROW __nonnull ((1)) __wur;
#endif
+#ifdef __USE_GNU
+/* Generate a unique temporary file name from TEMPLATE similar to
+ mkstemp. But allow the caller to pass additional flags which are
+ used in the open call to create the file..
+
+ This function is a possible cancellation point and therefore not
+ marked with __THROW. */
+# ifndef __USE_FILE_OFFSET64
+extern int mkostemp (char *__template, int __flags) __nonnull ((1)) __wur;
+# else
+# ifdef __REDIRECT
+extern int __REDIRECT (mkostemp, (char *__template, int __flags), mkostemp64)
+ __nonnull ((1)) __wur;
+# else
+# define mkostemp mkostemp64
+# endif
+# endif
+# ifdef __USE_LARGEFILE64
+extern int mkostemp64 (char *__template, int __flags) __nonnull ((1)) __wur;
+# endif
+#endif
+
+#ifdef __USE_GNU
+/* Generate a unique temporary file name from TEMPLATE similar to
+ mkostemp. But allow the caller to pass additional file name suffix.
+
+ This function is a possible cancellation point and therefore not
+ marked with __THROW. */
+# ifndef __USE_FILE_OFFSET64
+extern int mkostemps (char *__template, int __suffixlen, int __flags) __nonnull ((1)) __wur;
+# else
+# ifdef __REDIRECT
+extern int __REDIRECT (mkostemps, (char *__template, int __suffixlen, int __flags), mkostemps64)
+ __nonnull ((1)) __wur;
+# else
+# define mkostemps mkostemps64
+# endif
+# endif
+# ifdef __USE_LARGEFILE64
+extern int mkostemps64 (char *__template, int __suffixlen, int __flags) __nonnull ((1)) __wur;
+# endif
+#endif
+
__BEGIN_NAMESPACE_STD
/* Execute the given line as a shell command.
This function is a cancellation point and therefore not marked with
__THROW. */
-extern int system (__const char *__command) __wur;
+extern int system (const char *__command) __wur;
__END_NAMESPACE_STD
-#if 0 /* def __USE_GNU */
+#ifdef __USE_GNU
/* Return a malloc'd string containing the canonical absolute name of the
- named file. The last file name component need not exist, and may be a
- symlink to a nonexistent file. */
-extern char *canonicalize_file_name (__const char *__name)
+ existing named file. */
+extern char *canonicalize_file_name (const char *__name)
__THROW __nonnull ((1)) __wur;
#endif
#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
-/* Return the canonical absolute name of file NAME. The last file name
- component need not exist, and may be a symlink to a nonexistent file.
- If RESOLVED is null, the result is malloc'd; otherwise, if the canonical
- name is PATH_MAX chars or more, returns null with `errno' set to
- ENAMETOOLONG; if the name fits in fewer than PATH_MAX chars, returns the
- name in RESOLVED. */
-/* we choose to handle __resolved==NULL as crash :) */
-extern char *realpath (__const char *__restrict __name,
- char *__restrict __resolved) __THROW __wur __nonnull((2));
+/* Return the canonical absolute name of file NAME. If RESOLVED is
+ null, the result is malloc'd; otherwise, if the canonical name is
+ PATH_MAX chars or more, returns null with `errno' set to
+ ENAMETOOLONG; if the name fits in fewer than PATH_MAX chars,
+ returns the name in RESOLVED. */
+extern char *realpath (const char *__restrict __name,
+ char *__restrict __resolved) __THROW __wur;
+libc_hidden_proto(realpath)
#endif
/* Shorthand for type of comparison functions. */
#ifndef __COMPAR_FN_T
# define __COMPAR_FN_T
-typedef int (*__compar_fn_t) (__const void *, __const void *);
+typedef int (*__compar_fn_t) (const void *, const void *);
# ifdef __USE_GNU
typedef __compar_fn_t comparison_fn_t;
# endif
#endif
+#ifdef __USE_GNU
+typedef int (*__compar_d_fn_t) (const void *, const void *, void *);
+#endif
__BEGIN_NAMESPACE_STD
/* Do a binary search for KEY in BASE, which consists of NMEMB elements
of SIZE bytes each, using COMPAR to perform the comparisons. */
-extern void *bsearch (__const void *__key, __const void *__base,
+extern void *bsearch (const void *__key, const void *__base,
size_t __nmemb, size_t __size, __compar_fn_t __compar)
__nonnull ((1, 2, 5)) __wur;
@@ -662,7 +778,13 @@ extern void *bsearch (__const void *__key, __const void *__base,
using COMPAR to perform the comparisons. */
extern void qsort (void *__base, size_t __nmemb, size_t __size,
__compar_fn_t __compar) __nonnull ((1, 4));
-
+libc_hidden_proto(qsort)
+#ifdef __USE_GNU
+extern void qsort_r (void *__base, size_t __nmemb, size_t __size,
+ __compar_d_fn_t __compar, void *__arg)
+ __nonnull ((1, 4));
+libc_hidden_proto(qsort_r)
+#endif
/* Return the absolute value of X. */
extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
@@ -694,12 +816,11 @@ __END_NAMESPACE_C99
#endif
-#if defined __USE_SVID || defined __USE_XOPEN_EXTENDED || defined __USE_BSD
+#if ( defined __USE_SVID || defined __USE_XOPEN_EXTENDED ) && defined __UCLIBC_HAS_FLOATS__
/* Convert floating point numbers to strings. The returned values are
valid only until another call to the same function. */
# ifdef __UCLIBC_SUSV3_LEGACY__
-
#if 0
/* Convert VALUE to a string with NDIGIT digits and return a pointer to
this. Set *DECPT with the position of the decimal character and *SIGN
@@ -721,6 +842,7 @@ extern char *gcvt (double __value, int __ndigit, char *__buf)
__THROW __nonnull ((3)) __wur;
# endif /* __UCLIBC_SUSV3_LEGACY__ */
+
# if 0 /*def __USE_MISC*/
/* Long double versions of above functions. */
extern char *qecvt (long double __value, int __ndigit,
@@ -753,15 +875,16 @@ extern int qfcvt_r (long double __value, int __ndigit,
# endif /* misc */
#endif /* use MISC || use X/Open Unix */
+
#ifdef __UCLIBC_HAS_WCHAR__
__BEGIN_NAMESPACE_STD
/* Return the length of the multibyte character
in S, which is no longer than N. */
-extern int mblen (__const char *__s, size_t __n) __THROW __wur;
+extern int mblen (const char *__s, size_t __n) __THROW __wur;
/* Return the length of the given multibyte character,
putting its `wchar_t' representation in *PWC. */
extern int mbtowc (wchar_t *__restrict __pwc,
- __const char *__restrict __s, size_t __n) __THROW __wur;
+ const char *__restrict __s, size_t __n) __THROW __wur;
/* Put the multibyte character represented
by WCHAR in S, returning its length. */
extern int wctomb (char *__s, wchar_t __wchar) __THROW __wur;
@@ -769,10 +892,10 @@ extern int wctomb (char *__s, wchar_t __wchar) __THROW __wur;
/* Convert a multibyte string to a wide char string. */
extern size_t mbstowcs (wchar_t *__restrict __pwcs,
- __const char *__restrict __s, size_t __n) __THROW;
+ const char *__restrict __s, size_t __n) __THROW;
/* Convert a wide char string to multibyte string. */
extern size_t wcstombs (char *__restrict __s,
- __const wchar_t *__restrict __pwcs, size_t __n)
+ const wchar_t *__restrict __pwcs, size_t __n)
__THROW;
__END_NAMESPACE_STD
#endif /* __UCLIBC_HAS_WCHAR__ */
@@ -783,7 +906,7 @@ __END_NAMESPACE_STD
or negative response expression as specified by the LC_MESSAGES category
in the program's current locale. Returns 1 if affirmative, 0 if
negative, and -1 if not matching. */
-extern int rpmatch (__const char *__response) __THROW __nonnull ((1)) __wur;
+extern int rpmatch (const char *__response) __THROW __nonnull ((1)) __wur;
#endif
@@ -795,7 +918,7 @@ extern int rpmatch (__const char *__response) __THROW __nonnull ((1)) __wur;
suboption. On exit *OPTIONP is set to the beginning of the next
token or at the terminating NUL character. */
extern int getsubopt (char **__restrict __optionp,
- char *__const *__restrict __tokens,
+ char *const *__restrict __tokens,
char **__restrict __valuep)
__THROW __nonnull ((1, 2, 3)) __wur;
#endif
@@ -804,7 +927,7 @@ extern int getsubopt (char **__restrict __optionp,
#ifdef __USE_XOPEN
# if defined __UCLIBC_HAS_CRYPT__
/* Setup DES tables according KEY. */
-extern void setkey (__const char *__key) __THROW __nonnull ((1));
+extern void setkey (const char *__key) __THROW __nonnull ((1));
# endif /* __UCLIBC_HAS_CRYPT__ */
#endif
@@ -814,12 +937,12 @@ extern void setkey (__const char *__key) __THROW __nonnull ((1));
#ifdef __USE_XOPEN2K
/* Return a master pseudo-terminal handle. */
extern int posix_openpt (int __oflag) __wur;
-libc_hidden_proto(posix_openpt)
#endif
#ifdef __USE_XOPEN
/* The next four functions all take a master pseudo-tty fd and
perform an operation on the associated slave: */
+
#ifdef __UCLIBC_HAS_PTY__
/* Chown the slave to the calling user. */
extern int grantpt (int __fd) __THROW;
@@ -842,6 +965,7 @@ extern char *ptsname (int __fd) __THROW __wur;
Return 0 on success, otherwise an error number. */
extern int ptsname_r (int __fd, char *__buf, size_t __buflen)
__THROW __nonnull ((2));
+libc_hidden_proto(ptsname_r)
# endif
# if defined __UCLIBC_HAS_GETPT__
/* Open a master pseudo terminal and return its file descriptor. */
@@ -858,12 +982,19 @@ extern int getloadavg (double __loadavg[], int __nelem)
#endif
#ifdef __UCLIBC_HAS_ARC4RANDOM__
-#include <stdint.h>
-extern uint32_t arc4random(void);
+# include <sys/types.h>
+extern u_int32_t arc4random(void);
extern void arc4random_stir(void);
extern void arc4random_addrandom(unsigned char *, int);
#endif
+#ifdef _LIBC
+extern int __drand48_iterate (unsigned short int xsubi[3], struct drand48_data *buffer) attribute_hidden;
+
+/* Global state for non-reentrant functions. */
+extern struct drand48_data __libc_drand48_data attribute_hidden;
+#endif
+
#endif /* don't just need malloc and calloc */
#undef __need_malloc_and_calloc
diff --git a/include/string.h b/include/string.h
index bbca20af3..8315203a4 100644
--- a/include/string.h
+++ b/include/string.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-1993, 1995-2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 1991-1993,1995-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
@@ -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 Standard: 7.21 String handling <string.h>
@@ -36,12 +35,12 @@ __BEGIN_DECLS
__BEGIN_NAMESPACE_STD
/* Copy N bytes of SRC to DEST. */
extern void *memcpy (void *__restrict __dest,
- __const void *__restrict __src, size_t __n)
+ const void *__restrict __src, size_t __n)
__THROW __nonnull ((1, 2));
libc_hidden_proto(memcpy)
/* Copy N bytes of SRC to DEST, guaranteeing
correct behavior for overlapping strings. */
-extern void *memmove (void *__dest, __const void *__src, size_t __n)
+extern void *memmove (void *__dest, const void *__src, size_t __n)
__THROW __nonnull ((1, 2));
libc_hidden_proto(memmove)
__END_NAMESPACE_STD
@@ -50,7 +49,7 @@ __END_NAMESPACE_STD
Return the position in DEST one byte past where C was copied,
or NULL if C was not found in the first N bytes of SRC. */
#if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN
-extern void *memccpy (void *__restrict __dest, __const void *__restrict __src,
+extern void *memccpy (void *__restrict __dest, const void *__restrict __src,
int __c, size_t __n)
__THROW __nonnull ((1, 2));
libc_hidden_proto(memccpy)
@@ -63,12 +62,12 @@ extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
libc_hidden_proto(memset)
/* Compare N bytes of S1 and S2. */
-extern int memcmp (__const void *__s1, __const void *__s2, size_t __n)
+extern int memcmp (const void *__s1, const void *__s2, size_t __n)
__THROW __attribute_pure__ __nonnull ((1, 2));
libc_hidden_proto(memcmp)
/* Search N bytes of S for C. */
-extern void *memchr (__const void *__s, int __c, size_t __n)
+extern void *memchr (const void *__s, int __c, size_t __n)
__THROW __attribute_pure__ __nonnull ((1));
libc_hidden_proto(memchr)
__END_NAMESPACE_STD
@@ -76,12 +75,12 @@ __END_NAMESPACE_STD
#ifdef __USE_GNU
/* Search in S for C. This is similar to `memchr' but there is no
length limit. */
-extern void *rawmemchr (__const void *__s, int __c)
+extern void *rawmemchr (const void *__s, int __c)
__THROW __attribute_pure__ __nonnull ((1));
libc_hidden_proto(rawmemchr)
/* Search N bytes of S for the final occurrence of C. */
-extern void *memrchr (__const void *__s, int __c, size_t __n)
+extern void *memrchr (const void *__s, int __c, size_t __n)
__THROW __attribute_pure__ __nonnull ((1));
libc_hidden_proto(memrchr)
#endif
@@ -89,63 +88,62 @@ libc_hidden_proto(memrchr)
__BEGIN_NAMESPACE_STD
/* Copy SRC to DEST. */
-extern char *strcpy (char *__restrict __dest, __const char *__restrict __src)
+extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
__THROW __nonnull ((1, 2));
libc_hidden_proto(strcpy)
/* Copy no more than N characters of SRC to DEST. */
extern char *strncpy (char *__restrict __dest,
- __const char *__restrict __src, size_t __n)
+ const char *__restrict __src, size_t __n)
__THROW __nonnull ((1, 2));
libc_hidden_proto(strncpy)
/* Append SRC onto DEST. */
-extern char *strcat (char *__restrict __dest, __const char *__restrict __src)
+extern char *strcat (char *__restrict __dest, const char *__restrict __src)
__THROW __nonnull ((1, 2));
libc_hidden_proto(strcat)
/* Append no more than N characters from SRC onto DEST. */
-extern char *strncat (char *__restrict __dest, __const char *__restrict __src,
+extern char *strncat (char *__restrict __dest, const char *__restrict __src,
size_t __n) __THROW __nonnull ((1, 2));
libc_hidden_proto(strncat)
/* Compare S1 and S2. */
-extern int strcmp (__const char *__s1, __const char *__s2)
+extern int strcmp (const char *__s1, const char *__s2)
__THROW __attribute_pure__ __nonnull ((1, 2));
libc_hidden_proto(strcmp)
/* Compare N characters of S1 and S2. */
-extern int strncmp (__const char *__s1, __const char *__s2, size_t __n)
+extern int strncmp (const char *__s1, const char *__s2, size_t __n)
__THROW __attribute_pure__ __nonnull ((1, 2));
libc_hidden_proto(strncmp)
/* Compare the collated forms of S1 and S2. */
-extern int strcoll (__const char *__s1, __const char *__s2)
+extern int strcoll (const char *__s1, const char *__s2)
__THROW __attribute_pure__ __nonnull ((1, 2));
libc_hidden_proto(strcoll)
/* Put a transformation of SRC into no more than N bytes of DEST. */
extern size_t strxfrm (char *__restrict __dest,
- __const char *__restrict __src, size_t __n)
+ const char *__restrict __src, size_t __n)
__THROW __nonnull ((2));
-libc_hidden_proto(strxfrm)
__END_NAMESPACE_STD
-#if defined __USE_GNU && defined __UCLIBC_HAS_XLOCALE__
+#if defined __USE_XOPEN2K8 && defined __UCLIBC_HAS_XLOCALE__
/* The following functions are equivalent to the both above but they
take the locale they use for the collation as an extra argument.
This is not standardsized but something like will come. */
# include <xlocale.h>
/* Compare the collated forms of S1 and S2 using rules from L. */
-extern int strcoll_l (__const char *__s1, __const char *__s2, __locale_t __l)
+extern int strcoll_l (const char *__s1, const char *__s2, __locale_t __l)
__THROW __attribute_pure__ __nonnull ((1, 2, 3));
libc_hidden_proto(strcoll_l)
/* Put a transformation of SRC into no more than N bytes of DEST. */
-extern size_t strxfrm_l (char *__dest, __const char *__src, size_t __n,
+extern size_t strxfrm_l (char *__dest, const char *__src, size_t __n,
__locale_t __l) __THROW __nonnull ((2, 4));
libc_hidden_proto(strxfrm_l)
#endif
#if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED
/* Duplicate S, returning an identical malloc'd string. */
-extern char *strdup (__const char *__s)
+extern char *strdup (const char *__s)
__THROW __attribute_malloc__ __nonnull ((1));
libc_hidden_proto(strdup)
#endif
@@ -153,8 +151,8 @@ libc_hidden_proto(strdup)
/* Return a malloc'd copy of at most N bytes of STRING. The
resultant string is terminated even if no null terminator
appears before STRING[N]. */
-#if defined __USE_GNU
-extern char *strndup (__const char *__string, size_t __n)
+#if defined __USE_XOPEN2K8
+extern char *strndup (const char *__string, size_t __n)
__THROW __attribute_malloc__ __nonnull ((1));
libc_hidden_proto(strndup)
#endif
@@ -164,7 +162,7 @@ libc_hidden_proto(strndup)
# define strdupa(s) \
(__extension__ \
({ \
- __const char *__old = (s); \
+ const char *__old = (s); \
size_t __len = strlen (__old) + 1; \
char *__new = (char *) __builtin_alloca (__len); \
(char *) memcpy (__new, __old, __len); \
@@ -174,7 +172,7 @@ libc_hidden_proto(strndup)
# define strndupa(s, n) \
(__extension__ \
({ \
- __const char *__old = (s); \
+ const char *__old = (s); \
size_t __len = strnlen (__old, (n)); \
char *__new = (char *) __builtin_alloca (__len + 1); \
__new[__len] = '\0'; \
@@ -184,11 +182,11 @@ libc_hidden_proto(strndup)
__BEGIN_NAMESPACE_STD
/* Find the first occurrence of C in S. */
-extern char *strchr (__const char *__s, int __c)
+extern char *strchr (const char *__s, int __c)
__THROW __attribute_pure__ __nonnull ((1));
libc_hidden_proto(strchr)
/* Find the last occurrence of C in S. */
-extern char *strrchr (__const char *__s, int __c)
+extern char *strrchr (const char *__s, int __c)
__THROW __attribute_pure__ __nonnull ((1));
libc_hidden_proto(strrchr)
__END_NAMESPACE_STD
@@ -196,7 +194,7 @@ __END_NAMESPACE_STD
#ifdef __USE_GNU
/* This function is similar to `strchr'. But it returns a pointer to
the closing NUL byte in case C is not found in S. */
-extern char *strchrnul (__const char *__s, int __c)
+extern char *strchrnul (const char *__s, int __c)
__THROW __attribute_pure__ __nonnull ((1));
libc_hidden_proto(strchrnul)
#endif
@@ -204,26 +202,26 @@ libc_hidden_proto(strchrnul)
__BEGIN_NAMESPACE_STD
/* Return the length of the initial segment of S which
consists entirely of characters not in REJECT. */
-extern size_t strcspn (__const char *__s, __const char *__reject)
+extern size_t strcspn (const char *__s, const char *__reject)
__THROW __attribute_pure__ __nonnull ((1, 2));
libc_hidden_proto(strcspn)
/* Return the length of the initial segment of S which
consists entirely of characters in ACCEPT. */
-extern size_t strspn (__const char *__s, __const char *__accept)
+extern size_t strspn (const char *__s, const char *__accept)
__THROW __attribute_pure__ __nonnull ((1, 2));
libc_hidden_proto(strspn)
/* Find the first occurrence in S of any character in ACCEPT. */
-extern char *strpbrk (__const char *__s, __const char *__accept)
+extern char *strpbrk (const char *__s, const char *__accept)
__THROW __attribute_pure__ __nonnull ((1, 2));
libc_hidden_proto(strpbrk)
/* Find the first occurrence of NEEDLE in HAYSTACK. */
-extern char *strstr (__const char *__haystack, __const char *__needle)
+extern char *strstr (const char *__haystack, const char *__needle)
__THROW __attribute_pure__ __nonnull ((1, 2));
libc_hidden_proto(strstr)
/* Divide S into tokens separated by characters in DELIM. */
-extern char *strtok (char *__restrict __s, __const char *__restrict __delim)
+extern char *strtok (char *__restrict __s, const char *__restrict __delim)
__THROW __nonnull ((2));
libc_hidden_proto(strtok)
__END_NAMESPACE_STD
@@ -232,12 +230,12 @@ __END_NAMESPACE_STD
passed between calls are stored in SAVE_PTR. */
#if 0 /* uClibc: disabled */
extern char *__strtok_r (char *__restrict __s,
- __const char *__restrict __delim,
+ const char *__restrict __delim,
char **__restrict __save_ptr)
__THROW __nonnull ((2, 3));
#endif
#if defined __USE_POSIX || defined __USE_MISC
-extern char *strtok_r (char *__restrict __s, __const char *__restrict __delim,
+extern char *strtok_r (char *__restrict __s, const char *__restrict __delim,
char **__restrict __save_ptr)
__THROW __nonnull ((2, 3));
libc_hidden_proto(strtok_r)
@@ -245,7 +243,7 @@ libc_hidden_proto(strtok_r)
#ifdef __USE_GNU
/* Similar to `strstr' but this function ignores the case of both strings. */
-extern char *strcasestr (__const char *__haystack, __const char *__needle)
+extern char *strcasestr (const char *__haystack, const char *__needle)
__THROW __attribute_pure__ __nonnull ((1, 2));
libc_hidden_proto(strcasestr)
#endif
@@ -254,20 +252,21 @@ libc_hidden_proto(strcasestr)
/* Find the first occurrence of NEEDLE in HAYSTACK.
NEEDLE is NEEDLELEN bytes long;
HAYSTACK is HAYSTACKLEN bytes long. */
-extern void *memmem (__const void *__haystack, size_t __haystacklen,
- __const void *__needle, size_t __needlelen)
+extern void *memmem (const void *__haystack, size_t __haystacklen,
+ const void *__needle, size_t __needlelen)
__THROW __attribute_pure__ __nonnull ((1, 3));
-libc_hidden_proto(memmem)
/* Copy N bytes of SRC to DEST, return pointer to bytes after the
last written byte. */
-#if 0 /* uClibc: disabled */
+#if __GNUC_PREREQ (3, 4)
+# define __mempcpy(dest, src, n) __builtin_mempcpy(dest, src, n)
+#else /* uClibc: disabled */
extern void *__mempcpy (void *__restrict __dest,
- __const void *__restrict __src, size_t __n)
+ const void *__restrict __src, size_t __n)
__THROW __nonnull ((1, 2));
#endif
extern void *mempcpy (void *__restrict __dest,
- __const void *__restrict __src, size_t __n)
+ const void *__restrict __src, size_t __n)
__THROW __nonnull ((1, 2));
libc_hidden_proto(mempcpy)
#endif
@@ -275,15 +274,15 @@ libc_hidden_proto(mempcpy)
__BEGIN_NAMESPACE_STD
/* Return the length of S. */
-extern size_t strlen (__const char *__s)
+extern size_t strlen (const char *__s)
__THROW __attribute_pure__ __nonnull ((1));
libc_hidden_proto(strlen)
__END_NAMESPACE_STD
-#ifdef __USE_GNU
+#ifdef __USE_XOPEN2K8
/* Find the length of STRING, but scan at most MAXLEN characters.
If no '\0' terminator is found in that many characters, return MAXLEN. */
-extern size_t strnlen (__const char *__string, size_t __maxlen)
+extern size_t strnlen (const char *__string, size_t __maxlen)
__THROW __attribute_pure__ __nonnull ((1));
libc_hidden_proto(strnlen)
#endif
@@ -307,6 +306,7 @@ __END_NAMESPACE_STD
ERRNUM. */
extern int __xpg_strerror_r (int __errnum, char *__buf, size_t __buflen)
__THROW __nonnull ((2));
+libc_hidden_proto(__xpg_strerror_r)
# ifdef __REDIRECT_NTH
extern int __REDIRECT_NTH (strerror_r,
(int __errnum, char *__buf, size_t __buflen),
@@ -319,6 +319,7 @@ extern int __REDIRECT_NTH (strerror_r,
used. */
extern char *__glibc_strerror_r (int __errnum, char *__buf, size_t __buflen)
__THROW __nonnull ((2));
+libc_hidden_proto(__glibc_strerror_r)
# ifdef __REDIRECT_NTH
extern char * __REDIRECT_NTH (strerror_r,
(int __errnum, char *__buf, size_t __buflen),
@@ -329,6 +330,12 @@ extern char * __REDIRECT_NTH (strerror_r,
# endif
#endif
+#if 0 /*defined __USE_XOPEN2K8 && defined __UCLIBC_HAS_XLOCALE__*/
+/* Translate error number to string according to the locale L. */
+extern char *strerror_l (int __errnum, __locale_t __l) __THROW;
+#endif
+
+
/* We define this function always since `bzero' is sometimes needed when
the namespace rules does not allow this. */
#if 0 /* uClibc: disabled */
@@ -338,35 +345,57 @@ extern void __bzero (void *__s, size_t __n) __THROW __nonnull ((1));
#ifdef __USE_BSD
# ifdef __UCLIBC_SUSV3_LEGACY__
/* Copy N bytes of SRC to DEST (like memmove, but args reversed). */
-extern void bcopy (__const void *__src, void *__dest, size_t __n)
+extern void bcopy (const void *__src, void *__dest, size_t __n)
__THROW __nonnull ((1, 2));
/* Set N bytes of S to 0. */
extern void bzero (void *__s, size_t __n) __THROW __nonnull ((1));
/* Compare N bytes of S1 and S2 (same as memcmp). */
-extern int bcmp (__const void *__s1, __const void *__s2, size_t __n)
+extern int bcmp (const void *__s1, const void *__s2, size_t __n)
__THROW __attribute_pure__ __nonnull ((1, 2));
/* Find the first occurrence of C in S (same as strchr). */
-extern char *index (__const char *__s, int __c)
+extern char *index (const char *__s, int __c)
__THROW __attribute_pure__ __nonnull ((1));
/* Find the last occurrence of C in S (same as strrchr). */
-extern char *rindex (__const char *__s, int __c)
+extern char *rindex (const char *__s, int __c)
__THROW __attribute_pure__ __nonnull ((1));
-# else
-# ifdef __UCLIBC_SUSV3_LEGACY_MACROS__
+# elif defined(__UCLIBC_SUSV3_LEGACY_MACROS__) && !defined(_STRINGS_H)
/* bcopy/bzero/bcmp/index/rindex are marked LEGACY in SuSv3.
* They are replaced as proposed by SuSv3. Don't sync this part
* with glibc and keep it in sync with strings.h. */
-# define bcopy(src,dest,n) (memmove((dest), (src), (n)), (void) 0)
-# define bzero(s,n) (memset((s), '\0', (n)), (void) 0)
-# define bcmp(s1,s2,n) memcmp((s1), (s2), (size_t)(n))
-# define index(s,c) strchr((s), (c))
-# define rindex(s,c) strrchr((s), (c))
-# endif
+/* Copy N bytes of SRC to DEST (like memmove, but args reversed). */
+static __inline__ void bcopy (__const void *__src, void *__dest, size_t __n)
+{
+ memmove(__dest, __src, __n);
+}
+
+/* Set N bytes of S to 0. */
+static __inline__ void bzero (void *__s, size_t __n)
+{
+ memset(__s, 0, __n);
+}
+
+/* Compare N bytes of S1 and S2 (same as memcmp). */
+static __inline__ int bcmp (__const void *__s1, __const void *__s2, size_t __n)
+{
+ return memcmp(__s1, __s2, __n);
+}
+
+/* Find the first occurrence of C in S (same as strchr). */
+static __inline__ char *index (__const char *__s, int __c)
+{
+ return strchr(__s, __c);
+}
+
+/* Find the last occurrence of C in S (same as strrchr). */
+static __inline__ char *rindex (__const char *__s, int __c)
+{
+ return strrchr(__s, __c);
+}
# endif
/* Return the position of the first bit set in I, or 0 if none are set.
@@ -376,7 +405,7 @@ libc_hidden_proto(ffs)
/* The following two functions are non-standard but necessary for non-32 bit
platforms. */
-#if 0 /*def __USE_GNU*/
+#ifdef __USE_GNU
extern int ffsl (long int __l) __THROW __attribute__ ((__const__));
# ifdef __GNUC__
__extension__ extern int ffsll (long long int __ll)
@@ -385,25 +414,25 @@ __extension__ extern int ffsll (long long int __ll)
# endif
/* Compare S1 and S2, ignoring case. */
-extern int strcasecmp (__const char *__s1, __const char *__s2)
+extern int strcasecmp (const char *__s1, const char *__s2)
__THROW __attribute_pure__ __nonnull ((1, 2));
libc_hidden_proto(strcasecmp)
/* Compare no more than N chars of S1 and S2, ignoring case. */
-extern int strncasecmp (__const char *__s1, __const char *__s2, size_t __n)
+extern int strncasecmp (const char *__s1, const char *__s2, size_t __n)
__THROW __attribute_pure__ __nonnull ((1, 2));
libc_hidden_proto(strncasecmp)
#endif /* Use BSD. */
-#if defined __USE_GNU && defined __UCLIBC_HAS_XLOCALE__
+#if defined __USE_XOPEN2K8 && defined __UCLIBC_HAS_XLOCALE__
/* Again versions of a few functions which use the given locale instead
of the global one. */
-extern int strcasecmp_l (__const char *__s1, __const char *__s2,
+extern int strcasecmp_l (const char *__s1, const char *__s2,
__locale_t __loc)
__THROW __attribute_pure__ __nonnull ((1, 2, 3));
libc_hidden_proto(strcasecmp_l)
-extern int strncasecmp_l (__const char *__s1, __const char *__s2,
+extern int strncasecmp_l (const char *__s1, const char *__s2,
size_t __n, __locale_t __loc)
__THROW __attribute_pure__ __nonnull ((1, 2, 4));
libc_hidden_proto(strncasecmp_l)
@@ -413,61 +442,59 @@ libc_hidden_proto(strncasecmp_l)
/* Return the next DELIM-delimited token from *STRINGP,
terminating it with a '\0', and update *STRINGP to point past it. */
extern char *strsep (char **__restrict __stringp,
- __const char *__restrict __delim)
+ const char *__restrict __delim)
__THROW __nonnull ((1, 2));
libc_hidden_proto(strsep)
#endif
-#ifdef __USE_GNU
-/* Compare S1 and S2 as strings holding name & indices/version numbers. */
-#if 0
-extern int strverscmp (__const char *__s1, __const char *__s2)
- __THROW __attribute_pure__ __nonnull ((1, 2));
-libc_hidden_proto(strverscmp)
-#endif
-
+#ifdef __USE_XOPEN2K8
/* Return a string describing the meaning of the signal number in SIG. */
extern char *strsignal (int __sig) __THROW;
libc_hidden_proto(strsignal)
/* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */
-#if 0 /* uClibc: disabled */
-extern char *__stpcpy (char *__restrict __dest, __const char *__restrict __src)
+# if 0 /* uClibc: disabled */
+extern char *__stpcpy (char *__restrict __dest, const char *__restrict __src)
__THROW __nonnull ((1, 2));
-#endif
-extern char *stpcpy (char *__restrict __dest, __const char *__restrict __src)
+# endif
+extern char *stpcpy (char *__restrict __dest, const char *__restrict __src)
__THROW __nonnull ((1, 2));
libc_hidden_proto(stpcpy)
/* Copy no more than N characters of SRC to DEST, returning the address of
the last character written into DEST. */
-#if 0 /* uClibc: disabled */
+# if 0 /* uClibc: disabled */
extern char *__stpncpy (char *__restrict __dest,
- __const char *__restrict __src, size_t __n)
+ const char *__restrict __src, size_t __n)
__THROW __nonnull ((1, 2));
-#endif
+# endif
extern char *stpncpy (char *__restrict __dest,
- __const char *__restrict __src, size_t __n)
+ const char *__restrict __src, size_t __n)
__THROW __nonnull ((1, 2));
-libc_hidden_proto(stpncpy)
+#endif
+
+#ifdef __USE_GNU
+/* Compare S1 and S2 as strings holding name & indices/version numbers. */
+extern int strverscmp (const char *__s1, const char *__s2)
+ __THROW __attribute_pure__ __nonnull ((1, 2));
+libc_hidden_proto(strverscmp)
-#if 0 /* uClibc does not support strfry or memfrob. */
+# if 0 /* uClibc does not support strfry or memfrob. */
/* Sautee STRING briskly. */
extern char *strfry (char *__string) __THROW __nonnull ((1));
/* Frobnicate N bytes of S. */
extern void *memfrob (void *__s, size_t __n) __THROW __nonnull ((1));
-#endif
+# endif
# ifndef basename
/* Return the file name within directory of FILENAME. We don't
declare the function if the `basename' macro is available (defined
in <libgen.h>) which makes the XPG version of this function
available. */
-extern char *basename (__const char *__filename) __THROW __nonnull ((1));
-libc_hidden_proto(basename)
+extern char *basename (const char *__filename) __THROW __nonnull ((1));
# endif
-#endif
+#endif /* __USE_GNU */
#ifdef __USE_BSD
@@ -482,4 +509,11 @@ libc_hidden_proto(strlcpy)
__END_DECLS
-#endif /* string.h */
+
+#if defined(_LIBC) && defined(__UCLIBC_HAS_STRING_ARCH_OPT__)
+# if defined __i386__
+# include <../libc/string/i386/string.h>
+# endif
+#endif
+
+#endif /* string.h */
diff --git a/include/strings.h b/include/strings.h
index 550f4ab9c..baf2a6389 100644
--- a/include/strings.h
+++ b/include/strings.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991,92,96,97,99,2000,2001 Free Software Foundation, Inc.
+/* Copyright (C) 1991,92,96,97,99,2000,2001,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 _STRINGS_H
#define _STRINGS_H 1
@@ -35,22 +34,22 @@ __BEGIN_DECLS
# ifdef __UCLIBC_SUSV3_LEGACY__
/* Copy N bytes of SRC to DEST (like memmove, but args reversed). */
-extern void bcopy (__const void *__src, void *__dest, size_t __n)
+extern void bcopy (const void *__src, void *__dest, size_t __n)
__THROW __nonnull ((1, 2));
/* Set N bytes of S to 0. */
extern void bzero (void *__s, size_t __n) __THROW __nonnull ((1));
/* Compare N bytes of S1 and S2 (same as memcmp). */
-extern int bcmp (__const void *__s1, __const void *__s2, size_t __n)
+extern int bcmp (const void *__s1, const void *__s2, size_t __n)
__THROW __attribute_pure__ __nonnull ((1, 2));
/* Find the first occurrence of C in S (same as strchr). */
-extern char *index (__const char *__s, int __c)
+extern char *index (const char *__s, int __c)
__THROW __attribute_pure__ __nonnull ((1));
/* Find the last occurrence of C in S (same as strrchr). */
-extern char *rindex (__const char *__s, int __c)
+extern char *rindex (const char *__s, int __c)
__THROW __attribute_pure__ __nonnull ((1));
# else
# ifdef __UCLIBC_SUSV3_LEGACY_MACROS__
@@ -69,10 +68,11 @@ extern char *rindex (__const char *__s, int __c)
/* Return the position of the first bit set in I, or 0 if none are set.
The least-significant bit is position 1, the most-significant 32. */
extern int ffs (int __i) __THROW __attribute__ ((__const__));
+libc_hidden_proto(ffs)
/* The following two functions are non-standard but necessary for non-32 bit
platforms. */
-#if 0 /*def __USE_GNU*/
+# ifdef __USE_GNU
extern int ffsl (long int __l) __THROW __attribute__ ((__const__));
# ifdef __GNUC__
__extension__ extern int ffsll (long long int __ll)
@@ -81,17 +81,39 @@ __extension__ extern int ffsll (long long int __ll)
# endif
/* Compare S1 and S2, ignoring case. */
-extern int strcasecmp (__const char *__s1, __const char *__s2)
+extern int strcasecmp (const char *__s1, const char *__s2)
__THROW __attribute_pure__ __nonnull ((1, 2));
+libc_hidden_proto(strcasecmp)
/* Compare no more than N chars of S1 and S2, ignoring case. */
-extern int strncasecmp (__const char *__s1, __const char *__s2, size_t __n)
+extern int strncasecmp (const char *__s1, const char *__s2, size_t __n)
__THROW __attribute_pure__ __nonnull ((1, 2));
-
+libc_hidden_proto(strncasecmp)
+
+#if defined __USE_XOPEN2K8 && defined __UCLIBC_HAS_XLOCALE__
+/* The following functions are equivalent to the both above but they
+ take the locale they use for the collation as an extra argument.
+ This is not standardsized but something like will come. */
+# include <xlocale.h>
+
+/* Again versions of a few functions which use the given locale instead
+ of the global one. */
+extern int strcasecmp_l (const char *__s1, const char *__s2,
+ __locale_t __loc)
+ __THROW __attribute_pure__ __nonnull ((1, 2, 3));
+libc_hidden_proto(strcasecmp_l)
+
+extern int strncasecmp_l (const char *__s1, const char *__s2,
+ size_t __n, __locale_t __loc)
+ __THROW __attribute_pure__ __nonnull ((1, 2, 4));
+libc_hidden_proto(strncasecmp_l)
+#endif
__END_DECLS
-#ifdef UCLIBC_INTERNAL
+#ifdef _LIBC
+/* comment is wrong and will face this, when HAS_GNU option will be added
+ * header is SuSv standard */
#error "<strings.h> should not be included from libc."
#endif
diff --git a/include/sys/cdefs.h b/include/sys/cdefs.h
index 588c1ebb2..f725ce98c 100644
--- a/include/sys/cdefs.h
+++ b/include/sys/cdefs.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_CDEFS_H
#define _SYS_CDEFS_H 1
@@ -38,20 +37,33 @@
#ifdef __GNUC__
+/* All functions, except those with callbacks or those that
+ synchronize memory, are leaf functions. */
+# if __GNUC_PREREQ (4, 6) && !defined _LIBC
+# define __LEAF , __leaf__
+# define __LEAF_ATTR __attribute__ ((__leaf__))
+# else
+# define __LEAF
+# define __LEAF_ATTR
+# endif
+
/* GCC can always grok prototypes. For C++ programs we add throw()
to help it optimize the function calls. But this works only with
gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions
as non-throwing using a function attribute since programs can use
the -fexceptions options for C code as well. */
# if !defined __cplusplus && __GNUC_PREREQ (3, 3)
-# define __THROW __attribute__ ((__nothrow__))
-# define __NTH(fct) __attribute__ ((__nothrow__)) fct
+# define __THROW __attribute__ ((__nothrow__ __LEAF))
+# define __THROWNL __attribute__ ((__nothrow__))
+# define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct
# else
# if defined __cplusplus && __GNUC_PREREQ (2,8)
# define __THROW throw ()
-# define __NTH(fct) fct throw ()
+# define __THROWNL throw ()
+# define __NTH(fct) __LEAF_ATTR fct throw ()
# else
# define __THROW
+# define __THROWNL
# define __NTH(fct) fct
# endif
# endif
@@ -61,12 +73,9 @@
# define __inline /* No inline functions. */
# define __THROW
+# define __THROWNL
# define __NTH(fct) fct
-# define __const const
-# define __signed signed
-# define __volatile volatile
-
#endif /* GCC. */
/* These two macros are not used in glibc anymore. They are kept here
@@ -120,14 +129,6 @@
#endif
-/* Support for bounded pointers. */
-#ifndef __BOUNDED_POINTERS__
-# define __bounded /* nothing */
-# define __unbounded /* nothing */
-# define __ptrvalue /* nothing */
-#endif
-
-
/* Fortify support. */
#define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)
#define __bos0(ptr) __builtin_object_size (ptr, 0)
@@ -178,9 +179,13 @@
# ifdef __cplusplus
# define __REDIRECT_NTH(name, proto, alias) \
name proto __THROW __asm__ (__ASMNAME (#alias))
+# define __REDIRECT_NTHNL(name, proto, alias) \
+ name proto __THROWNL __asm__ (__ASMNAME (#alias))
# else
# define __REDIRECT_NTH(name, proto, alias) \
name proto __asm__ (__ASMNAME (#alias)) __THROW
+# define __REDIRECT_NTHNL(name, proto, alias) \
+ name proto __asm__ (__ASMNAME (#alias)) __THROWNL
# endif
# define __ASMNAME(cname) __ASMNAME2 (__USER_LABEL_PREFIX__, cname)
# define __ASMNAME2(prefix, cname) __STRING (prefix) cname
@@ -226,6 +231,12 @@
# define __attribute_pure__ /* Ignore */
#endif
+#if __GNUC_PREREQ (2,96)
+# define __attribute_const__ __attribute__((__const__))
+#else
+# define __attribute_const__ /* unimplemented */
+#endif
+
/* At some point during the gcc 3.1 development the `used' attribute
for functions was introduced. We don't want to use it unconditionally
(although this would be possible) since it generates warnings. */
diff --git a/include/sys/dir.h b/include/sys/dir.h
index 2611d6cd9..5352f9029 100644
--- a/include/sys/dir.h
+++ b/include/sys/dir.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_DIR_H
#define _SYS_DIR_H 1
diff --git a/include/sys/file.h b/include/sys/file.h
index 93b36350a..42dfa44b5 100644
--- a/include/sys/file.h
+++ b/include/sys/file.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_FILE_H
#define _SYS_FILE_H 1
@@ -39,7 +38,7 @@ __BEGIN_DECLS
/* Operations for the `flock' call. */
#define LOCK_SH 1 /* Shared lock. */
-#define LOCK_EX 2 /* Exclusive lock. */
+#define LOCK_EX 2 /* Exclusive lock. */
#define LOCK_UN 8 /* Unlock. */
/* Can be OR'd in to one of the above. */
diff --git a/include/sys/fsuid.h b/include/sys/fsuid.h
index 4ecb19918..2fd512e74 100644
--- a/include/sys/fsuid.h
+++ b/include/sys/fsuid.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_FSUID_H
#define _SYS_FSUID_H 1
diff --git a/include/sys/ioctl.h b/include/sys/ioctl.h
index 6d8a0f40b..3ff134c8d 100644
--- a/include/sys/ioctl.h
+++ b/include/sys/ioctl.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
#define _SYS_IOCTL_H 1
@@ -40,6 +39,7 @@ __BEGIN_DECLS
One argument may follow; its presence and type depend on REQUEST.
Return value depends on REQUEST. Usually -1 indicates error. */
extern int ioctl (int __fd, unsigned long int __request, ...) __THROW;
+libc_hidden_proto(ioctl)
__END_DECLS
diff --git a/include/sys/ipc.h b/include/sys/ipc.h
index 42806db2b..02aab5255 100644
--- a/include/sys/ipc.h
+++ b/include/sys/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
#define _SYS_IPC_H 1
@@ -51,7 +50,7 @@ typedef __key_t key_t;
__BEGIN_DECLS
/* Generates key for System V style IPC. */
-extern key_t ftok (__const char *__pathname, int __proj_id) __THROW;
+extern key_t ftok (const char *__pathname, int __proj_id) __THROW;
__END_DECLS
diff --git a/include/sys/kd.h b/include/sys/kd.h
index d459c079e..44ab953bc 100644
--- a/include/sys/kd.h
+++ b/include/sys/kd.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_KD_H
#define _SYS_KD_H 1
diff --git a/include/sys/kdaemon.h b/include/sys/kdaemon.h
index 61491f93d..921e07274 100644
--- a/include/sys/kdaemon.h
+++ b/include/sys/kdaemon.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/>. */
/* Interfaces to control the various kernel daemons. */
diff --git a/include/sys/klog.h b/include/sys/klog.h
index 35f5fe40e..f5fef94b0 100644
--- a/include/sys/klog.h
+++ b/include/sys/klog.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_KLOG_H
diff --git a/include/sys/mman.h b/include/sys/mman.h
index 10471e683..71d553af4 100644
--- a/include/sys/mman.h
+++ b/include/sys/mman.h
@@ -1,5 +1,5 @@
/* Definitions for BSD-style memory management.
- Copyright (C) 1994-2000, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1994-2000, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -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
#define _SYS_MMAN_H 1
@@ -57,9 +56,10 @@ __BEGIN_DECLS
#ifndef __USE_FILE_OFFSET64
extern void *mmap (void *__addr, size_t __len, int __prot,
int __flags, int __fd, __off_t __offset) __THROW;
+libc_hidden_proto(mmap)
#else
-# ifdef __REDIRECT
-extern void * __REDIRECT (mmap,
+# ifdef __REDIRECT_NTH
+extern void * __REDIRECT_NTH (mmap,
(void *__addr, size_t __len, int __prot,
int __flags, int __fd, __off64_t __offset),
mmap64);
@@ -75,6 +75,7 @@ extern void *mmap64 (void *__addr, size_t __len, int __prot,
/* Deallocate any mapping for the region starting at ADDR and extending LEN
bytes. Returns 0 if successful, -1 for errors (and sets errno). */
extern int munmap (void *__addr, size_t __len) __THROW;
+libc_hidden_proto(munmap)
/* Change the memory protection of the region starting at ADDR and
extending LEN bytes to PROT. Returns 0 if successful, -1 for errors
@@ -98,7 +99,7 @@ static __inline__ int msync (void *__addr, size_t __len, int __flags) { return 0
#endif
-#if defined __USE_BSD && defined __UCLIBC_LINUX_SPECIFIC__
+#if defined __USE_BSD && (defined __UCLIBC_LINUX_SPECIFIC__ || defined __UCLIBC_HAS_THREADS_NATIVE__)
/* Advise the system about particular usage patterns the program follows
for the region starting at ADDR and extending LEN bytes. */
extern int madvise (void *__addr, size_t __len, int __advice) __THROW;
@@ -113,10 +114,10 @@ extern int posix_madvise (void *__addr, size_t __len, int __advice) __THROW;
/* Guarantee all whole pages mapped by the range [ADDR,ADDR+LEN) to
be memory resident. */
-extern int mlock (__const void *__addr, size_t __len) __THROW;
+extern int mlock (const void *__addr, size_t __len) __THROW;
/* Unlock whole pages previously mapped by the range [ADDR,ADDR+LEN). */
-extern int munlock (__const void *__addr, size_t __len) __THROW;
+extern int munlock (const void *__addr, size_t __len) __THROW;
/* Cause all currently mapped pages of the process to be memory resident
until unlocked by a call to the `munlockall', until the process exits,
@@ -131,8 +132,8 @@ extern int munlockall (void) __THROW;
/* On no-mmu systems, memory cannot be swapped out, so
* these functions will always succeed. */
-static __inline__ int mlock (__const void *__addr, size_t __len) { return 0; }
-static __inline__ int munlock (__const void *__addr, size_t __len) { return 0; }
+static __inline__ int mlock (const void *__addr, size_t __len) { return 0; }
+static __inline__ int munlock (const void *__addr, size_t __len) { return 0; }
static __inline__ int mlockall (int __flags) { return 0; }
static __inline__ int munlockall (void) { return 0; }
#endif
@@ -156,19 +157,22 @@ extern int mincore (void *__start, size_t __len, unsigned char *__vec)
resides after a successful call. */
extern void *mremap (void *__addr, size_t __old_len, size_t __new_len,
int __flags, ...) __THROW;
+libc_hidden_proto(mremap)
+#ifdef __UCLIBC_LINUX_SPECIFIC__
/* Remap arbitrary pages of a shared backing store within an existing
VMA. */
extern int remap_file_pages (void *__start, size_t __size, int __prot,
size_t __pgoff, int __flags) __THROW;
#endif
+#endif
/* Open shared memory segment. */
-extern int shm_open (__const char *__name, int __oflag, mode_t __mode);
+extern int shm_open (const char *__name, int __oflag, mode_t __mode);
/* Remove shared memory segment. */
-extern int shm_unlink (__const char *__name);
+extern int shm_unlink (const char *__name);
__END_DECLS
diff --git a/include/sys/mount.h b/include/sys/mount.h
index b30554987..c0e7b84f8 100644
--- a/include/sys/mount.h
+++ b/include/sys/mount.h
@@ -1,5 +1,5 @@
/* Header file for mounting/unmount Linux filesystems.
- Copyright (C) 1996,1997,1998,1999,2000,2004 Free Software Foundation, Inc.
+ Copyright (C) 1996-2000, 2004, 2010, 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/>. */
/* This is taken from /usr/include/linux/fs.h. */
@@ -47,23 +46,46 @@ enum
#define MS_REMOUNT MS_REMOUNT
MS_MANDLOCK = 64, /* Allow mandatory locks on an FS. */
#define MS_MANDLOCK MS_MANDLOCK
- S_WRITE = 128, /* Write on file/directory/symlink. */
-#define S_WRITE S_WRITE
- S_APPEND = 256, /* Append-only file. */
-#define S_APPEND S_APPEND
- S_IMMUTABLE = 512, /* Immutable file. */
-#define S_IMMUTABLE S_IMMUTABLE
+ MS_DIRSYNC = 128, /* Directory modifications are synchronous. */
+#define MS_DIRSYNC MS_DIRSYNC
MS_NOATIME = 1024, /* Do not update access times. */
#define MS_NOATIME MS_NOATIME
MS_NODIRATIME = 2048, /* Do not update directory access times. */
#define MS_NODIRATIME MS_NODIRATIME
MS_BIND = 4096, /* Bind directory at different place. */
#define MS_BIND MS_BIND
+ MS_MOVE = 8192,
+#define MS_MOVE MS_MOVE
+ MS_REC = 16384,
+#define MS_REC MS_REC
+ MS_SILENT = 32768,
+#define MS_SILENT MS_SILENT
+ MS_POSIXACL = 1 << 16, /* VFS does not apply the umask. */
+#define MS_POSIXACL MS_POSIXACL
+ MS_UNBINDABLE = 1 << 17, /* Change to unbindable. */
+#define MS_UNBINDABLE MS_UNBINDABLE
+ MS_PRIVATE = 1 << 18, /* Change to private. */
+#define MS_PRIVATE MS_PRIVATE
+ MS_SLAVE = 1 << 19, /* Change to slave. */
+#define MS_SLAVE MS_SLAVE
+ MS_SHARED = 1 << 20, /* Change to shared. */
+#define MS_SHARED MS_SHARED
+ MS_RELATIME = 1 << 21, /* Update atime relative to mtime/ctime. */
+#define MS_RELATIME MS_RELATIME
+ MS_KERNMOUNT = 1 << 22, /* This is a kern_mount call. */
+#define MS_KERNMOUNT MS_KERNMOUNT
+ MS_I_VERSION = 1 << 23, /* Update inode I_version field. */
+#define MS_I_VERSION MS_I_VERSION
+ MS_STRICTATIME = 1 << 24, /* Always perform atime updates. */
+#define MS_STRICTATIME MS_STRICTATIME
+ MS_ACTIVE = 1 << 30,
+#define MS_ACTIVE MS_ACTIVE
+ MS_NOUSER = 1 << 31
+#define MS_NOUSER MS_NOUSER
};
/* Flags that can be altered by MS_REMOUNT */
-#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_NOATIME \
- |MS_NODIRATIME)
+#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_I_VERSION)
/* Magic mount flag number. Has to be or-ed to the flag values. */
@@ -96,23 +118,32 @@ enum
/* Possible value for FLAGS parameter of `umount2'. */
enum
{
- MNT_FORCE = 1 /* Force unmounting. */
+ MNT_FORCE = 1, /* Force unmounting. */
#define MNT_FORCE MNT_FORCE
+ MNT_DETACH = 2, /* Just detach from the tree. */
+#define MNT_DETACH MNT_DETACH
+ MNT_EXPIRE = 4, /* Mark for expiry. */
+#define MNT_EXPIRE MNT_EXPIRE
+ UMOUNT_NOFOLLOW = 8 /* Don't follow symlink on umount. */
+#define UMOUNT_NOFOLLOW UMOUNT_NOFOLLOW
};
__BEGIN_DECLS
/* Mount a filesystem. */
-extern int mount (__const char *__special_file, __const char *__dir,
- __const char *__fstype, unsigned long int __rwflag,
- __const void *__data) __THROW;
+extern int mount (const char *__special_file, const char *__dir,
+ const char *__fstype, unsigned long int __rwflag,
+ const void *__data) __THROW;
/* Unmount a filesystem. */
-extern int umount (__const char *__special_file) __THROW;
+extern int umount (const char *__special_file) __THROW;
+#ifdef __UCLIBC_LINUX_SPECIFIC__
/* Unmount a filesystem. Force unmounting if FLAGS is set to MNT_FORCE. */
-extern int umount2 (__const char *__special_file, int __flags) __THROW;
+extern int umount2 (const char *__special_file, int __flags) __THROW;
+libc_hidden_proto(umount2)
+#endif
__END_DECLS
diff --git a/include/sys/msg.h b/include/sys/msg.h
index 1fd64b2ac..b27e972ae 100644
--- a/include/sys/msg.h
+++ b/include/sys/msg.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1995,1996,1997,1999,2000,2003 Free Software Foundation, Inc.
+/* Copyright (C) 1995-1997,1999,2000,2003,2006,2007
+ Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -12,15 +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/>. */
#ifndef _SYS_MSG_H
#define _SYS_MSG_H
#include <features.h>
+#define __need_size_t
+#include <stddef.h>
+
/* Get common definition of System V style IPC. */
#include <sys/ipc.h>
@@ -66,14 +69,14 @@ extern int msgget (key_t __key, int __msgflg) __THROW;
This function is a cancellation point and therefore not marked with
__THROW. */
-extern int msgrcv (int __msqid, void *__msgp, size_t __msgsz,
- long int __msgtyp, int __msgflg);
+extern ssize_t msgrcv (int __msqid, void *__msgp, size_t __msgsz,
+ long int __msgtyp, int __msgflg);
/* Send message to message queue.
This function is a cancellation point and therefore not marked with
__THROW. */
-extern int msgsnd (int __msqid, __const void *__msgp, size_t __msgsz,
+extern int msgsnd (int __msqid, const void *__msgp, size_t __msgsz,
int __msgflg);
__END_DECLS
diff --git a/include/sys/mtio.h b/include/sys/mtio.h
index 51fa550cd..60f3e51e7 100644
--- a/include/sys/mtio.h
+++ b/include/sys/mtio.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/>. */
/* Written by H. Bergman <hennus@cybercomm.nl>. */
diff --git a/include/sys/param.h b/include/sys/param.h
index 0b0424eb9..d329706c9 100644
--- a/include/sys/param.h
+++ b/include/sys/param.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995,1996,1997,2000,2001,2003 Free Software Foundation, Inc.
+/* Copyright (C) 1995-1997,2000,2001,2003,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,17 +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/>. */
#ifndef _SYS_PARAM_H
#define _SYS_PARAM_H 1
+#ifndef ARG_MAX
+# define __undef_ARG_MAX
+#endif
+
#include <limits.h>
#include <linux/limits.h>
#include <linux/param.h>
+/* The kernel headers defines ARG_MAX. The value is wrong, though. */
+#ifndef __undef_ARG_MAX
+# undef ARG_MAX
+# undef __undef_ARG_MAX
+#endif
+
/* BSD names for some <limits.h> values. */
#define NBBY CHAR_BIT
@@ -31,12 +40,12 @@
#endif
#define MAXSYMLINKS 20
#define CANBSIZ MAX_CANON
-#define NCARGS ARG_MAX
#define MAXPATHLEN PATH_MAX
-/* The following is not really correct but it is a value we used for a
+/* The following are not really correct but it is a value we used for a
long time and which seems to be usable. People should not use NOFILE
- anyway. */
+ and NCARGS anyway. */
#define NOFILE 256
+#define NCARGS 131072
#include <sys/types.h>
diff --git a/include/sys/personality.h b/include/sys/personality.h
index 154b1131a..ee1de6403 100644
--- a/include/sys/personality.h
+++ b/include/sys/personality.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/>. */
/* Taken verbatim from Linux 2.4 (include/linux/personality.h). */
diff --git a/include/sys/poll.h b/include/sys/poll.h
index a298dac15..029a9badd 100644
--- a/include/sys/poll.h
+++ b/include/sys/poll.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_POLL_H
#define _SYS_POLL_H 1
@@ -30,8 +29,6 @@
/* Get the timespec definition. */
# define __need_timespec
# include <time.h>
-/* get NULL definition. */
-# include <stddef.h>
#endif
@@ -58,6 +55,7 @@ __BEGIN_DECLS
This function is a cancellation point and therefore not marked with
__THROW. */
extern int poll (struct pollfd *__fds, nfds_t __nfds, int __timeout);
+libc_hidden_proto(poll)
#if defined __USE_GNU && defined __UCLIBC_LINUX_SPECIFIC__
/* Like poll, but before waiting the threads signal mask is replaced
@@ -67,8 +65,8 @@ extern int poll (struct pollfd *__fds, nfds_t __nfds, int __timeout);
This function is a cancellation point and therefore not marked with
__THROW. */
extern int ppoll (struct pollfd *__fds, nfds_t __nfds,
- __const struct timespec *__timeout,
- __const __sigset_t *__ss);
+ const struct timespec *__timeout,
+ const __sigset_t *__ss);
#endif
__END_DECLS
diff --git a/include/sys/queue.h b/include/sys/queue.h
index d62afcc84..daf4553d3 100644
--- a/include/sys/queue.h
+++ b/include/sys/queue.h
@@ -1,4 +1,4 @@
-/*-
+/*
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -10,7 +10,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -27,38 +27,24 @@
* SUCH DAMAGE.
*
* @(#)queue.h 8.5 (Berkeley) 8/20/94
- * $FreeBSD: src/sys/sys/queue.h,v 1.68 2006/10/24 11:20:29 ru Exp $
*/
-#ifndef _SYS_QUEUE_H_
+#ifndef _SYS_QUEUE_H_
#define _SYS_QUEUE_H_
-#include <sys/cdefs.h>
-
/*
- * This file defines four types of data structures: singly-linked lists,
- * singly-linked tail queues, lists and tail queues.
- *
- * A singly-linked list is headed by a single forward pointer. The elements
- * are singly linked for minimum space and pointer manipulation overhead at
- * the expense of O(n) removal for arbitrary elements. New elements can be
- * added to the list after an existing element or at the head of the list.
- * Elements being removed from the head of the list should use the explicit
- * macro for this purpose for optimum efficiency. A singly-linked list may
- * only be traversed in the forward direction. Singly-linked lists are ideal
- * for applications with large datasets and few or no removals or for
- * implementing a LIFO queue.
+ * This file defines five types of data structures: singly-linked lists,
+ * lists, simple queues, tail queues, and circular queues.
*
- * A singly-linked tail queue is headed by a pair of pointers, one to the
- * head of the list and the other to the tail of the list. The elements are
- * singly linked for minimum space and pointer manipulation overhead at the
- * expense of O(n) removal for arbitrary elements. New elements can be added
- * to the list after an existing element, at the head of the list, or at the
- * end of the list. Elements being removed from the head of the tail queue
- * should use the explicit macro for this purpose for optimum efficiency.
- * A singly-linked tail queue may only be traversed in the forward direction.
- * Singly-linked tail queues are ideal for applications with large datasets
- * and few or no removals or for implementing a FIFO queue.
+ * A singly-linked list is headed by a single forward pointer. The
+ * elements are singly linked for minimum space and pointer manipulation
+ * overhead at the expense of O(n) removal for arbitrary elements. New
+ * elements can be added to the list after an existing element or at the
+ * head of the list. Elements being removed from the head of the list
+ * should use the explicit macro for this purpose for optimum
+ * efficiency. A singly-linked list may only be traversed in the forward
+ * direction. Singly-linked lists are ideal for applications with large
+ * datasets and few or no removals or for implementing a LIFO queue.
*
* A list is headed by a single forward pointer (or an array of forward
* pointers for a hash table header). The elements are doubly linked
@@ -67,6 +53,13 @@
* or after an existing element or at the head of the list. A list
* may only be traversed in the forward direction.
*
+ * A simple queue is headed by a pair of pointers, one the head of the
+ * list and the other to the tail of the list. The elements are singly
+ * linked to save space, so elements can only be removed from the
+ * head of the list. New elements can be added to the list after
+ * an existing element, at the head of the list, or at the end of the
+ * list. A simple queue may only be traversed in the forward direction.
+ *
* A tail queue is headed by a pair of pointers, one to the head of the
* list and the other to the tail of the list. The elements are doubly
* linked so that an arbitrary element can be removed without a need to
@@ -74,67 +67,85 @@
* after an existing element, at the head of the list, or at the end of
* the list. A tail queue may be traversed in either direction.
*
- * For details on the use of these macros, see the queue(3) manual page.
- *
- *
- * SLIST LIST STAILQ TAILQ
- * _HEAD + + + +
- * _HEAD_INITIALIZER + + + +
- * _ENTRY + + + +
- * _INIT + + + +
- * _EMPTY + + + +
- * _FIRST + + + +
- * _NEXT + + + +
- * _PREV - - - +
- * _LAST - - + +
- * _FOREACH + + + +
- * _FOREACH_SAFE + + + +
- * _FOREACH_REVERSE - - - +
- * _FOREACH_REVERSE_SAFE - - - +
- * _INSERT_HEAD + + + +
- * _INSERT_BEFORE - + - +
- * _INSERT_AFTER + + + +
- * _INSERT_TAIL - - + +
- * _CONCAT - - + +
- * _REMOVE_HEAD + - + -
- * _REMOVE + + + +
+ * A circle queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or after
+ * an existing element, at the head of the list, or at the end of the list.
+ * A circle queue may be traversed in either direction, but has a more
+ * complex end of list detection.
*
+ * For details on the use of these macros, see the queue(3) manual page.
+ */
+
+/*
+ * List definitions.
+ */
+#define LIST_HEAD(name, type) \
+struct name { \
+ struct type *lh_first; /* first element */ \
+}
+
+#define LIST_HEAD_INITIALIZER(head) \
+ { NULL }
+
+#define LIST_ENTRY(type) \
+struct { \
+ struct type *le_next; /* next element */ \
+ struct type **le_prev; /* address of previous next element */ \
+}
+
+/*
+ * List functions.
+ */
+#define LIST_INIT(head) do { \
+ (head)->lh_first = NULL; \
+} while (/*CONSTCOND*/0)
+
+#define LIST_INSERT_AFTER(listelm, elm, field) do { \
+ if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \
+ (listelm)->field.le_next->field.le_prev = \
+ &(elm)->field.le_next; \
+ (listelm)->field.le_next = (elm); \
+ (elm)->field.le_prev = &(listelm)->field.le_next; \
+} while (/*CONSTCOND*/0)
+
+#define LIST_INSERT_BEFORE(listelm, elm, field) do { \
+ (elm)->field.le_prev = (listelm)->field.le_prev; \
+ (elm)->field.le_next = (listelm); \
+ *(listelm)->field.le_prev = (elm); \
+ (listelm)->field.le_prev = &(elm)->field.le_next; \
+} while (/*CONSTCOND*/0)
+
+#define LIST_INSERT_HEAD(head, elm, field) do { \
+ if (((elm)->field.le_next = (head)->lh_first) != NULL) \
+ (head)->lh_first->field.le_prev = &(elm)->field.le_next;\
+ (head)->lh_first = (elm); \
+ (elm)->field.le_prev = &(head)->lh_first; \
+} while (/*CONSTCOND*/0)
+
+#define LIST_REMOVE(elm, field) do { \
+ if ((elm)->field.le_next != NULL) \
+ (elm)->field.le_next->field.le_prev = \
+ (elm)->field.le_prev; \
+ *(elm)->field.le_prev = (elm)->field.le_next; \
+} while (/*CONSTCOND*/0)
+
+#define LIST_FOREACH(var, head, field) \
+ for ((var) = ((head)->lh_first); \
+ (var); \
+ (var) = ((var)->field.le_next))
+
+/*
+ * List access methods.
*/
-#ifdef QUEUE_MACRO_DEBUG
-/* Store the last 2 places the queue element or head was altered */
-struct qm_trace {
- char * lastfile;
- int lastline;
- char * prevfile;
- int prevline;
-};
-
-#define TRACEBUF struct qm_trace trace;
-#define TRASHIT(x) do {(x) = (void *)-1;} while (0)
-
-#define QMD_TRACE_HEAD(head) do { \
- (head)->trace.prevline = (head)->trace.lastline; \
- (head)->trace.prevfile = (head)->trace.lastfile; \
- (head)->trace.lastline = __LINE__; \
- (head)->trace.lastfile = __FILE__; \
-} while (0)
-
-#define QMD_TRACE_ELEM(elem) do { \
- (elem)->trace.prevline = (elem)->trace.lastline; \
- (elem)->trace.prevfile = (elem)->trace.lastfile; \
- (elem)->trace.lastline = __LINE__; \
- (elem)->trace.lastfile = __FILE__; \
-} while (0)
-
-#else
-#define QMD_TRACE_ELEM(elem)
-#define QMD_TRACE_HEAD(head)
-#define TRACEBUF
-#define TRASHIT(x)
-#endif /* QUEUE_MACRO_DEBUG */
+#define LIST_EMPTY(head) ((head)->lh_first == NULL)
+#define LIST_FIRST(head) ((head)->lh_first)
+#define LIST_NEXT(elm, field) ((elm)->field.le_next)
+
/*
- * Singly-linked List declarations.
+ * Singly-linked List definitions.
*/
#define SLIST_HEAD(name, type) \
struct name { \
@@ -152,66 +163,55 @@ struct { \
/*
* Singly-linked List functions.
*/
-#define SLIST_EMPTY(head) ((head)->slh_first == NULL)
-
-#define SLIST_FIRST(head) ((head)->slh_first)
-
-#define SLIST_FOREACH(var, head, field) \
- for ((var) = SLIST_FIRST((head)); \
- (var); \
- (var) = SLIST_NEXT((var), field))
-
-#define SLIST_FOREACH_SAFE(var, head, field, tvar) \
- for ((var) = SLIST_FIRST((head)); \
- (var) && ((tvar) = SLIST_NEXT((var), field), 1); \
- (var) = (tvar))
-
-#define SLIST_FOREACH_PREVPTR(var, varp, head, field) \
- for ((varp) = &SLIST_FIRST((head)); \
- ((var) = *(varp)) != NULL; \
- (varp) = &SLIST_NEXT((var), field))
-
#define SLIST_INIT(head) do { \
- SLIST_FIRST((head)) = NULL; \
-} while (0)
+ (head)->slh_first = NULL; \
+} while (/*CONSTCOND*/0)
#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
- SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field); \
- SLIST_NEXT((slistelm), field) = (elm); \
-} while (0)
+ (elm)->field.sle_next = (slistelm)->field.sle_next; \
+ (slistelm)->field.sle_next = (elm); \
+} while (/*CONSTCOND*/0)
#define SLIST_INSERT_HEAD(head, elm, field) do { \
- SLIST_NEXT((elm), field) = SLIST_FIRST((head)); \
- SLIST_FIRST((head)) = (elm); \
-} while (0)
+ (elm)->field.sle_next = (head)->slh_first; \
+ (head)->slh_first = (elm); \
+} while (/*CONSTCOND*/0)
-#define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
+#define SLIST_REMOVE_HEAD(head, field) do { \
+ (head)->slh_first = (head)->slh_first->field.sle_next; \
+} while (/*CONSTCOND*/0)
#define SLIST_REMOVE(head, elm, type, field) do { \
- if (SLIST_FIRST((head)) == (elm)) { \
+ if ((head)->slh_first == (elm)) { \
SLIST_REMOVE_HEAD((head), field); \
} \
else { \
- struct type *curelm = SLIST_FIRST((head)); \
- while (SLIST_NEXT(curelm, field) != (elm)) \
- curelm = SLIST_NEXT(curelm, field); \
- SLIST_NEXT(curelm, field) = \
- SLIST_NEXT(SLIST_NEXT(curelm, field), field); \
+ struct type *curelm = (head)->slh_first; \
+ while(curelm->field.sle_next != (elm)) \
+ curelm = curelm->field.sle_next; \
+ curelm->field.sle_next = \
+ curelm->field.sle_next->field.sle_next; \
} \
- TRASHIT((elm)->field.sle_next); \
-} while (0)
+} while (/*CONSTCOND*/0)
+
+#define SLIST_FOREACH(var, head, field) \
+ for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next)
+
+/*
+ * Singly-linked List access methods.
+ */
+#define SLIST_EMPTY(head) ((head)->slh_first == NULL)
+#define SLIST_FIRST(head) ((head)->slh_first)
+#define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
-#define SLIST_REMOVE_HEAD(head, field) do { \
- SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \
-} while (0)
/*
* Singly-linked Tail queue declarations.
*/
-#define STAILQ_HEAD(name, type) \
+#define STAILQ_HEAD(name, type) \
struct name { \
- struct type *stqh_first;/* first element */ \
- struct type **stqh_last;/* addr of last next element */ \
+ struct type *stqh_first; /* first element */ \
+ struct type **stqh_last; /* addr of last next element */ \
}
#define STAILQ_HEAD_INITIALIZER(head) \
@@ -225,394 +225,350 @@ struct { \
/*
* Singly-linked Tail queue functions.
*/
-#define STAILQ_CONCAT(head1, head2) do { \
- if (!STAILQ_EMPTY((head2))) { \
- *(head1)->stqh_last = (head2)->stqh_first; \
- (head1)->stqh_last = (head2)->stqh_last; \
- STAILQ_INIT((head2)); \
- } \
-} while (0)
-
-#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL)
-
-#define STAILQ_FIRST(head) ((head)->stqh_first)
-
-#define STAILQ_FOREACH(var, head, field) \
- for((var) = STAILQ_FIRST((head)); \
- (var); \
- (var) = STAILQ_NEXT((var), field))
-
-
-#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \
- for ((var) = STAILQ_FIRST((head)); \
- (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \
- (var) = (tvar))
-
#define STAILQ_INIT(head) do { \
- STAILQ_FIRST((head)) = NULL; \
- (head)->stqh_last = &STAILQ_FIRST((head)); \
-} while (0)
-
-#define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \
- if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\
- (head)->stqh_last = &STAILQ_NEXT((elm), field); \
- STAILQ_NEXT((tqelm), field) = (elm); \
-} while (0)
+ (head)->stqh_first = NULL; \
+ (head)->stqh_last = &(head)->stqh_first; \
+} while (/*CONSTCOND*/0)
#define STAILQ_INSERT_HEAD(head, elm, field) do { \
- if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \
- (head)->stqh_last = &STAILQ_NEXT((elm), field); \
- STAILQ_FIRST((head)) = (elm); \
-} while (0)
+ if (((elm)->field.stqe_next = (head)->stqh_first) == NULL) \
+ (head)->stqh_last = &(elm)->field.stqe_next; \
+ (head)->stqh_first = (elm); \
+} while (/*CONSTCOND*/0)
#define STAILQ_INSERT_TAIL(head, elm, field) do { \
- STAILQ_NEXT((elm), field) = NULL; \
+ (elm)->field.stqe_next = NULL; \
*(head)->stqh_last = (elm); \
- (head)->stqh_last = &STAILQ_NEXT((elm), field); \
-} while (0)
+ (head)->stqh_last = &(elm)->field.stqe_next; \
+} while (/*CONSTCOND*/0)
-#define STAILQ_LAST(head, type, field) \
- (STAILQ_EMPTY((head)) ? \
- NULL : \
- ((struct type *)(void *) \
- ((char *)((head)->stqh_last) - __offsetof(struct type, field))))
+#define STAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
+ if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL)\
+ (head)->stqh_last = &(elm)->field.stqe_next; \
+ (listelm)->field.stqe_next = (elm); \
+} while (/*CONSTCOND*/0)
-#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
+#define STAILQ_REMOVE_HEAD(head, field) do { \
+ if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) \
+ (head)->stqh_last = &(head)->stqh_first; \
+} while (/*CONSTCOND*/0)
#define STAILQ_REMOVE(head, elm, type, field) do { \
- if (STAILQ_FIRST((head)) == (elm)) { \
+ if ((head)->stqh_first == (elm)) { \
STAILQ_REMOVE_HEAD((head), field); \
+ } else { \
+ struct type *curelm = (head)->stqh_first; \
+ while (curelm->field.stqe_next != (elm)) \
+ curelm = curelm->field.stqe_next; \
+ if ((curelm->field.stqe_next = \
+ curelm->field.stqe_next->field.stqe_next) == NULL) \
+ (head)->stqh_last = &(curelm)->field.stqe_next; \
} \
- else { \
- struct type *curelm = STAILQ_FIRST((head)); \
- while (STAILQ_NEXT(curelm, field) != (elm)) \
- curelm = STAILQ_NEXT(curelm, field); \
- if ((STAILQ_NEXT(curelm, field) = \
- STAILQ_NEXT(STAILQ_NEXT(curelm, field), field)) == NULL)\
- (head)->stqh_last = &STAILQ_NEXT((curelm), field);\
+} while (/*CONSTCOND*/0)
+
+#define STAILQ_FOREACH(var, head, field) \
+ for ((var) = ((head)->stqh_first); \
+ (var); \
+ (var) = ((var)->field.stqe_next))
+
+#define STAILQ_CONCAT(head1, head2) do { \
+ if (!STAILQ_EMPTY((head2))) { \
+ *(head1)->stqh_last = (head2)->stqh_first; \
+ (head1)->stqh_last = (head2)->stqh_last; \
+ STAILQ_INIT((head2)); \
} \
- TRASHIT((elm)->field.stqe_next); \
-} while (0)
+} while (/*CONSTCOND*/0)
+
+/*
+ * Singly-linked Tail queue access methods.
+ */
+#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL)
+#define STAILQ_FIRST(head) ((head)->stqh_first)
+#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
-#define STAILQ_REMOVE_HEAD(head, field) do { \
- if ((STAILQ_FIRST((head)) = \
- STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \
- (head)->stqh_last = &STAILQ_FIRST((head)); \
-} while (0)
/*
- * List declarations.
+ * Simple queue definitions.
*/
-#define LIST_HEAD(name, type) \
+#define SIMPLEQ_HEAD(name, type) \
struct name { \
- struct type *lh_first; /* first element */ \
+ struct type *sqh_first; /* first element */ \
+ struct type **sqh_last; /* addr of last next element */ \
}
-#define LIST_HEAD_INITIALIZER(head) \
- { NULL }
+#define SIMPLEQ_HEAD_INITIALIZER(head) \
+ { NULL, &(head).sqh_first }
-#define LIST_ENTRY(type) \
+#define SIMPLEQ_ENTRY(type) \
struct { \
- struct type *le_next; /* next element */ \
- struct type **le_prev; /* address of previous next element */ \
+ struct type *sqe_next; /* next element */ \
}
/*
- * List functions.
+ * Simple queue functions.
*/
+#define SIMPLEQ_INIT(head) do { \
+ (head)->sqh_first = NULL; \
+ (head)->sqh_last = &(head)->sqh_first; \
+} while (/*CONSTCOND*/0)
+
+#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \
+ if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \
+ (head)->sqh_last = &(elm)->field.sqe_next; \
+ (head)->sqh_first = (elm); \
+} while (/*CONSTCOND*/0)
+
+#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \
+ (elm)->field.sqe_next = NULL; \
+ *(head)->sqh_last = (elm); \
+ (head)->sqh_last = &(elm)->field.sqe_next; \
+} while (/*CONSTCOND*/0)
+
+#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
+ if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\
+ (head)->sqh_last = &(elm)->field.sqe_next; \
+ (listelm)->field.sqe_next = (elm); \
+} while (/*CONSTCOND*/0)
+
+#define SIMPLEQ_REMOVE_HEAD(head, field) do { \
+ if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \
+ (head)->sqh_last = &(head)->sqh_first; \
+} while (/*CONSTCOND*/0)
+
+#define SIMPLEQ_REMOVE(head, elm, type, field) do { \
+ if ((head)->sqh_first == (elm)) { \
+ SIMPLEQ_REMOVE_HEAD((head), field); \
+ } else { \
+ struct type *curelm = (head)->sqh_first; \
+ while (curelm->field.sqe_next != (elm)) \
+ curelm = curelm->field.sqe_next; \
+ if ((curelm->field.sqe_next = \
+ curelm->field.sqe_next->field.sqe_next) == NULL) \
+ (head)->sqh_last = &(curelm)->field.sqe_next; \
+ } \
+} while (/*CONSTCOND*/0)
-#if (defined(_KERNEL) && defined(INVARIANTS))
-#define QMD_LIST_CHECK_HEAD(head, field) do { \
- if (LIST_FIRST((head)) != NULL && \
- LIST_FIRST((head))->field.le_prev != \
- &LIST_FIRST((head))) \
- panic("Bad list head %p first->prev != head", (head)); \
-} while (0)
-
-#define QMD_LIST_CHECK_NEXT(elm, field) do { \
- if (LIST_NEXT((elm), field) != NULL && \
- LIST_NEXT((elm), field)->field.le_prev != \
- &((elm)->field.le_next)) \
- panic("Bad link elm %p next->prev != elm", (elm)); \
-} while (0)
-
-#define QMD_LIST_CHECK_PREV(elm, field) do { \
- if (*(elm)->field.le_prev != (elm)) \
- panic("Bad link elm %p prev->next != elm", (elm)); \
-} while (0)
-#else
-#define QMD_LIST_CHECK_HEAD(head, field)
-#define QMD_LIST_CHECK_NEXT(elm, field)
-#define QMD_LIST_CHECK_PREV(elm, field)
-#endif /* (_KERNEL && INVARIANTS) */
-
-#define LIST_EMPTY(head) ((head)->lh_first == NULL)
-
-#define LIST_FIRST(head) ((head)->lh_first)
-
-#define LIST_FOREACH(var, head, field) \
- for ((var) = LIST_FIRST((head)); \
- (var); \
- (var) = LIST_NEXT((var), field))
-
-#define LIST_FOREACH_SAFE(var, head, field, tvar) \
- for ((var) = LIST_FIRST((head)); \
- (var) && ((tvar) = LIST_NEXT((var), field), 1); \
- (var) = (tvar))
-
-#define LIST_INIT(head) do { \
- LIST_FIRST((head)) = NULL; \
-} while (0)
-
-#define LIST_INSERT_AFTER(listelm, elm, field) do { \
- QMD_LIST_CHECK_NEXT(listelm, field); \
- if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\
- LIST_NEXT((listelm), field)->field.le_prev = \
- &LIST_NEXT((elm), field); \
- LIST_NEXT((listelm), field) = (elm); \
- (elm)->field.le_prev = &LIST_NEXT((listelm), field); \
-} while (0)
-
-#define LIST_INSERT_BEFORE(listelm, elm, field) do { \
- QMD_LIST_CHECK_PREV(listelm, field); \
- (elm)->field.le_prev = (listelm)->field.le_prev; \
- LIST_NEXT((elm), field) = (listelm); \
- *(listelm)->field.le_prev = (elm); \
- (listelm)->field.le_prev = &LIST_NEXT((elm), field); \
-} while (0)
-
-#define LIST_INSERT_HEAD(head, elm, field) do { \
- QMD_LIST_CHECK_HEAD((head), field); \
- if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \
- LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\
- LIST_FIRST((head)) = (elm); \
- (elm)->field.le_prev = &LIST_FIRST((head)); \
-} while (0)
+#define SIMPLEQ_FOREACH(var, head, field) \
+ for ((var) = ((head)->sqh_first); \
+ (var); \
+ (var) = ((var)->field.sqe_next))
-#define LIST_NEXT(elm, field) ((elm)->field.le_next)
+/*
+ * Simple queue access methods.
+ */
+#define SIMPLEQ_EMPTY(head) ((head)->sqh_first == NULL)
+#define SIMPLEQ_FIRST(head) ((head)->sqh_first)
+#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next)
-#define LIST_REMOVE(elm, field) do { \
- QMD_LIST_CHECK_NEXT(elm, field); \
- QMD_LIST_CHECK_PREV(elm, field); \
- if (LIST_NEXT((elm), field) != NULL) \
- LIST_NEXT((elm), field)->field.le_prev = \
- (elm)->field.le_prev; \
- *(elm)->field.le_prev = LIST_NEXT((elm), field); \
- TRASHIT((elm)->field.le_next); \
- TRASHIT((elm)->field.le_prev); \
-} while (0)
/*
- * Tail queue declarations.
+ * Tail queue definitions.
*/
-#define TAILQ_HEAD(name, type) \
+#define _TAILQ_HEAD(name, type, qual) \
struct name { \
- struct type *tqh_first; /* first element */ \
- struct type **tqh_last; /* addr of last next element */ \
- TRACEBUF \
+ qual type *tqh_first; /* first element */ \
+ qual type *qual *tqh_last; /* addr of last next element */ \
}
+#define TAILQ_HEAD(name, type) _TAILQ_HEAD(name, struct type,)
#define TAILQ_HEAD_INITIALIZER(head) \
{ NULL, &(head).tqh_first }
-#define TAILQ_ENTRY(type) \
+#define _TAILQ_ENTRY(type, qual) \
struct { \
- struct type *tqe_next; /* next element */ \
- struct type **tqe_prev; /* address of previous next element */ \
- TRACEBUF \
+ qual type *tqe_next; /* next element */ \
+ qual type *qual *tqe_prev; /* address of previous next element */\
}
+#define TAILQ_ENTRY(type) _TAILQ_ENTRY(struct type,)
/*
* Tail queue functions.
*/
-#if (defined(_KERNEL) && defined(INVARIANTS))
-#define QMD_TAILQ_CHECK_HEAD(head, field) do { \
- if (!TAILQ_EMPTY(head) && \
- TAILQ_FIRST((head))->field.tqe_prev != \
- &TAILQ_FIRST((head))) \
- panic("Bad tailq head %p first->prev != head", (head)); \
-} while (0)
-
-#define QMD_TAILQ_CHECK_TAIL(head, field) do { \
- if (*(head)->tqh_last != NULL) \
- panic("Bad tailq NEXT(%p->tqh_last) != NULL", (head)); \
-} while (0)
-
-#define QMD_TAILQ_CHECK_NEXT(elm, field) do { \
- if (TAILQ_NEXT((elm), field) != NULL && \
- TAILQ_NEXT((elm), field)->field.tqe_prev != \
- &((elm)->field.tqe_next)) \
- panic("Bad link elm %p next->prev != elm", (elm)); \
-} while (0)
-
-#define QMD_TAILQ_CHECK_PREV(elm, field) do { \
- if (*(elm)->field.tqe_prev != (elm)) \
- panic("Bad link elm %p prev->next != elm", (elm)); \
-} while (0)
-#else
-#define QMD_TAILQ_CHECK_HEAD(head, field)
-#define QMD_TAILQ_CHECK_TAIL(head, headname)
-#define QMD_TAILQ_CHECK_NEXT(elm, field)
-#define QMD_TAILQ_CHECK_PREV(elm, field)
-#endif /* (_KERNEL && INVARIANTS) */
-
-#define TAILQ_CONCAT(head1, head2, field) do { \
- if (!TAILQ_EMPTY(head2)) { \
- *(head1)->tqh_last = (head2)->tqh_first; \
- (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \
- (head1)->tqh_last = (head2)->tqh_last; \
- TAILQ_INIT((head2)); \
- QMD_TRACE_HEAD(head1); \
- QMD_TRACE_HEAD(head2); \
- } \
-} while (0)
-
-#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
-
-#define TAILQ_FIRST(head) ((head)->tqh_first)
-
-#define TAILQ_FOREACH(var, head, field) \
- for ((var) = TAILQ_FIRST((head)); \
- (var); \
- (var) = TAILQ_NEXT((var), field))
-
-#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
- for ((var) = TAILQ_FIRST((head)); \
- (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
- (var) = (tvar))
-
-#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
- for ((var) = TAILQ_LAST((head), headname); \
- (var); \
- (var) = TAILQ_PREV((var), headname, field))
-
-#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \
- for ((var) = TAILQ_LAST((head), headname); \
- (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \
- (var) = (tvar))
-
#define TAILQ_INIT(head) do { \
- TAILQ_FIRST((head)) = NULL; \
- (head)->tqh_last = &TAILQ_FIRST((head)); \
- QMD_TRACE_HEAD(head); \
-} while (0)
-
-#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
- QMD_TAILQ_CHECK_NEXT(listelm, field); \
- if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\
- TAILQ_NEXT((elm), field)->field.tqe_prev = \
- &TAILQ_NEXT((elm), field); \
- else { \
- (head)->tqh_last = &TAILQ_NEXT((elm), field); \
- QMD_TRACE_HEAD(head); \
- } \
- TAILQ_NEXT((listelm), field) = (elm); \
- (elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field); \
- QMD_TRACE_ELEM(&(elm)->field); \
- QMD_TRACE_ELEM(&listelm->field); \
-} while (0)
-
-#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
- QMD_TAILQ_CHECK_PREV(listelm, field); \
- (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
- TAILQ_NEXT((elm), field) = (listelm); \
- *(listelm)->field.tqe_prev = (elm); \
- (listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field); \
- QMD_TRACE_ELEM(&(elm)->field); \
- QMD_TRACE_ELEM(&listelm->field); \
-} while (0)
+ (head)->tqh_first = NULL; \
+ (head)->tqh_last = &(head)->tqh_first; \
+} while (/*CONSTCOND*/0)
#define TAILQ_INSERT_HEAD(head, elm, field) do { \
- QMD_TAILQ_CHECK_HEAD(head, field); \
- if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL) \
- TAILQ_FIRST((head))->field.tqe_prev = \
- &TAILQ_NEXT((elm), field); \
+ if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \
+ (head)->tqh_first->field.tqe_prev = \
+ &(elm)->field.tqe_next; \
else \
- (head)->tqh_last = &TAILQ_NEXT((elm), field); \
- TAILQ_FIRST((head)) = (elm); \
- (elm)->field.tqe_prev = &TAILQ_FIRST((head)); \
- QMD_TRACE_HEAD(head); \
- QMD_TRACE_ELEM(&(elm)->field); \
-} while (0)
+ (head)->tqh_last = &(elm)->field.tqe_next; \
+ (head)->tqh_first = (elm); \
+ (elm)->field.tqe_prev = &(head)->tqh_first; \
+} while (/*CONSTCOND*/0)
#define TAILQ_INSERT_TAIL(head, elm, field) do { \
- QMD_TAILQ_CHECK_TAIL(head, field); \
- TAILQ_NEXT((elm), field) = NULL; \
+ (elm)->field.tqe_next = NULL; \
(elm)->field.tqe_prev = (head)->tqh_last; \
*(head)->tqh_last = (elm); \
- (head)->tqh_last = &TAILQ_NEXT((elm), field); \
- QMD_TRACE_HEAD(head); \
- QMD_TRACE_ELEM(&(elm)->field); \
-} while (0)
+ (head)->tqh_last = &(elm)->field.tqe_next; \
+} while (/*CONSTCOND*/0)
-#define TAILQ_LAST(head, headname) \
- (*(((struct headname *)((head)->tqh_last))->tqh_last))
-
-#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
+#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
+ if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
+ (elm)->field.tqe_next->field.tqe_prev = \
+ &(elm)->field.tqe_next; \
+ else \
+ (head)->tqh_last = &(elm)->field.tqe_next; \
+ (listelm)->field.tqe_next = (elm); \
+ (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \
+} while (/*CONSTCOND*/0)
-#define TAILQ_PREV(elm, headname, field) \
- (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
+#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
+ (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
+ (elm)->field.tqe_next = (listelm); \
+ *(listelm)->field.tqe_prev = (elm); \
+ (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \
+} while (/*CONSTCOND*/0)
#define TAILQ_REMOVE(head, elm, field) do { \
- QMD_TAILQ_CHECK_NEXT(elm, field); \
- QMD_TAILQ_CHECK_PREV(elm, field); \
- if ((TAILQ_NEXT((elm), field)) != NULL) \
- TAILQ_NEXT((elm), field)->field.tqe_prev = \
+ if (((elm)->field.tqe_next) != NULL) \
+ (elm)->field.tqe_next->field.tqe_prev = \
(elm)->field.tqe_prev; \
- else { \
+ else \
(head)->tqh_last = (elm)->field.tqe_prev; \
- QMD_TRACE_HEAD(head); \
- } \
- *(elm)->field.tqe_prev = TAILQ_NEXT((elm), field); \
- TRASHIT((elm)->field.tqe_next); \
- TRASHIT((elm)->field.tqe_prev); \
- QMD_TRACE_ELEM(&(elm)->field); \
-} while (0)
+ *(elm)->field.tqe_prev = (elm)->field.tqe_next; \
+} while (/*CONSTCOND*/0)
+#define TAILQ_FOREACH(var, head, field) \
+ for ((var) = ((head)->tqh_first); \
+ (var); \
+ (var) = ((var)->field.tqe_next))
-#ifdef _KERNEL
+#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
+ for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \
+ (var); \
+ (var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last)))
+
+#define TAILQ_CONCAT(head1, head2, field) do { \
+ if (!TAILQ_EMPTY(head2)) { \
+ *(head1)->tqh_last = (head2)->tqh_first; \
+ (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \
+ (head1)->tqh_last = (head2)->tqh_last; \
+ TAILQ_INIT((head2)); \
+ } \
+} while (/*CONSTCOND*/0)
/*
- * XXX insque() and remque() are an old way of handling certain queues.
- * They bogusly assumes that all queue heads look alike.
+ * Tail queue access methods.
*/
+#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
+#define TAILQ_FIRST(head) ((head)->tqh_first)
+#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
-struct quehead {
- struct quehead *qh_link;
- struct quehead *qh_rlink;
-};
-
-#ifdef __CC_SUPPORTS___INLINE
+#define TAILQ_LAST(head, headname) \
+ (*(((struct headname *)((head)->tqh_last))->tqh_last))
+#define TAILQ_PREV(elm, headname, field) \
+ (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
-static __inline void
-insque(void *a, void *b)
-{
- struct quehead *element = (struct quehead *)a,
- *head = (struct quehead *)b;
- element->qh_link = head->qh_link;
- element->qh_rlink = head;
- head->qh_link = element;
- element->qh_link->qh_rlink = element;
+/*
+ * Circular queue definitions.
+ */
+#define CIRCLEQ_HEAD(name, type) \
+struct name { \
+ struct type *cqh_first; /* first element */ \
+ struct type *cqh_last; /* last element */ \
}
-static __inline void
-remque(void *a)
-{
- struct quehead *element = (struct quehead *)a;
+#define CIRCLEQ_HEAD_INITIALIZER(head) \
+ { (void *)&head, (void *)&head }
- element->qh_link->qh_rlink = element->qh_rlink;
- element->qh_rlink->qh_link = element->qh_link;
- element->qh_rlink = 0;
+#define CIRCLEQ_ENTRY(type) \
+struct { \
+ struct type *cqe_next; /* next element */ \
+ struct type *cqe_prev; /* previous element */ \
}
-#else /* !__CC_SUPPORTS___INLINE */
+/*
+ * Circular queue functions.
+ */
+#define CIRCLEQ_INIT(head) do { \
+ (head)->cqh_first = (void *)(head); \
+ (head)->cqh_last = (void *)(head); \
+} while (/*CONSTCOND*/0)
+
+#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
+ (elm)->field.cqe_next = (listelm)->field.cqe_next; \
+ (elm)->field.cqe_prev = (listelm); \
+ if ((listelm)->field.cqe_next == (void *)(head)) \
+ (head)->cqh_last = (elm); \
+ else \
+ (listelm)->field.cqe_next->field.cqe_prev = (elm); \
+ (listelm)->field.cqe_next = (elm); \
+} while (/*CONSTCOND*/0)
+
+#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \
+ (elm)->field.cqe_next = (listelm); \
+ (elm)->field.cqe_prev = (listelm)->field.cqe_prev; \
+ if ((listelm)->field.cqe_prev == (void *)(head)) \
+ (head)->cqh_first = (elm); \
+ else \
+ (listelm)->field.cqe_prev->field.cqe_next = (elm); \
+ (listelm)->field.cqe_prev = (elm); \
+} while (/*CONSTCOND*/0)
+
+#define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \
+ (elm)->field.cqe_next = (head)->cqh_first; \
+ (elm)->field.cqe_prev = (void *)(head); \
+ if ((head)->cqh_last == (void *)(head)) \
+ (head)->cqh_last = (elm); \
+ else \
+ (head)->cqh_first->field.cqe_prev = (elm); \
+ (head)->cqh_first = (elm); \
+} while (/*CONSTCOND*/0)
+
+#define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \
+ (elm)->field.cqe_next = (void *)(head); \
+ (elm)->field.cqe_prev = (head)->cqh_last; \
+ if ((head)->cqh_first == (void *)(head)) \
+ (head)->cqh_first = (elm); \
+ else \
+ (head)->cqh_last->field.cqe_next = (elm); \
+ (head)->cqh_last = (elm); \
+} while (/*CONSTCOND*/0)
-void insque(void *a, void *b);
-void remque(void *a);
+#define CIRCLEQ_REMOVE(head, elm, field) do { \
+ if ((elm)->field.cqe_next == (void *)(head)) \
+ (head)->cqh_last = (elm)->field.cqe_prev; \
+ else \
+ (elm)->field.cqe_next->field.cqe_prev = \
+ (elm)->field.cqe_prev; \
+ if ((elm)->field.cqe_prev == (void *)(head)) \
+ (head)->cqh_first = (elm)->field.cqe_next; \
+ else \
+ (elm)->field.cqe_prev->field.cqe_next = \
+ (elm)->field.cqe_next; \
+} while (/*CONSTCOND*/0)
-#endif /* __CC_SUPPORTS___INLINE */
+#define CIRCLEQ_FOREACH(var, head, field) \
+ for ((var) = ((head)->cqh_first); \
+ (var) != (const void *)(head); \
+ (var) = ((var)->field.cqe_next))
-#endif /* _KERNEL */
+#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \
+ for ((var) = ((head)->cqh_last); \
+ (var) != (const void *)(head); \
+ (var) = ((var)->field.cqe_prev))
-#endif /* !_SYS_QUEUE_H_ */
+/*
+ * Circular queue access methods.
+ */
+#define CIRCLEQ_EMPTY(head) ((head)->cqh_first == (void *)(head))
+#define CIRCLEQ_FIRST(head) ((head)->cqh_first)
+#define CIRCLEQ_LAST(head) ((head)->cqh_last)
+#define CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next)
+#define CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev)
+
+#define CIRCLEQ_LOOP_NEXT(head, elm, field) \
+ (((elm)->field.cqe_next == (void *)(head)) \
+ ? ((head)->cqh_first) \
+ : (elm->field.cqe_next))
+#define CIRCLEQ_LOOP_PREV(head, elm, field) \
+ (((elm)->field.cqe_prev == (void *)(head)) \
+ ? ((head)->cqh_last) \
+ : (elm->field.cqe_prev))
+
+#endif /* sys/queue.h */
diff --git a/include/sys/quota.h b/include/sys/quota.h
index a6afdbe44..088e6139e 100644
--- a/include/sys/quota.h
+++ b/include/sys/quota.h
@@ -30,8 +30,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * Version: $Id: quota.h,v 1.1 2002/01/03 04:00:09 andersen Exp $
*/
#ifndef _SYS_QUOTA_H
@@ -40,6 +38,19 @@
#include <features.h>
#include <sys/types.h>
+#ifdef __UCLIBC__
+# undef _LINUX_QUOTA_VERSION
+# define _LINUX_QUOTA_VERSION 1
+#endif
+
+/*
+ * Select between different incompatible quota versions.
+ * Default to the version used by Linux kernel version 2.4.22
+ * or later. */
+#ifndef _LINUX_QUOTA_VERSION
+# define _LINUX_QUOTA_VERSION 2
+#endif
+
/*
* Convert diskblocks to blocks and the other way around.
* currently only to fool the BSD source. :-)
@@ -94,21 +105,33 @@
#define SUBCMDSHIFT 8
#define QCMD(cmd, type) (((cmd) << SUBCMDSHIFT) | ((type) & SUBCMDMASK))
-#define Q_QUOTAON 0x0100 /* enable quotas */
-#define Q_QUOTAOFF 0x0200 /* disable quotas */
-#define Q_GETQUOTA 0x0300 /* get limits and usage */
-#define Q_SETQUOTA 0x0400 /* set limits and usage */
-#define Q_SETUSE 0x0500 /* set usage */
-#define Q_SYNC 0x0600 /* sync disk copy of a filesystems quotas */
-#define Q_SETQLIM 0x0700 /* set limits */
-#define Q_GETSTATS 0x0800 /* get collected stats */
-#define Q_RSQUASH 0x1000 /* set root_squash option */
+#if _LINUX_QUOTA_VERSION < 2
+# define Q_QUOTAON 0x0100 /* enable quotas */
+# define Q_QUOTAOFF 0x0200 /* disable quotas */
+# define Q_GETQUOTA 0x0300 /* get limits and usage */
+# define Q_SETQUOTA 0x0400 /* set limits and usage */
+# define Q_SETUSE 0x0500 /* set usage */
+# define Q_SYNC 0x0600 /* sync disk copy of a filesystems quotas */
+# define Q_SETQLIM 0x0700 /* set limits */
+# define Q_GETSTATS 0x0800 /* get collected stats */
+# define Q_RSQUASH 0x1000 /* set root_squash option */
+#else
+# define Q_SYNC 0x800001 /* sync disk copy of a filesystems quotas */
+# define Q_QUOTAON 0x800002 /* turn quotas on */
+# define Q_QUOTAOFF 0x800003 /* turn quotas off */
+# define Q_GETFMT 0x800004 /* get quota format used on given filesystem */
+# define Q_GETINFO 0x800005 /* get information about quota files */
+# define Q_SETINFO 0x800006 /* set information about quota files */
+# define Q_GETQUOTA 0x800007 /* get user quota structure */
+# define Q_SETQUOTA 0x800008 /* set user quota structure */
+#endif
/*
* The following structure defines the format of the disk quota file
* (as it appears on disk) - the file is an array of these structures
* indexed by user or group number.
*/
+#if _LINUX_QUOTA_VERSION < 2
struct dqblk
{
u_int32_t dqb_bhardlimit; /* absolute limit on disk blks alloc */
@@ -120,13 +143,45 @@ struct dqblk
time_t dqb_btime; /* time limit for excessive disk use */
time_t dqb_itime; /* time limit for excessive files */
};
+#else
+
+/* Flags that indicate which fields in dqblk structure are valid. */
+#define QIF_BLIMITS 1
+#define QIF_SPACE 2
+#define QIF_ILIMITS 4
+#define QIF_INODES 8
+#define QIF_BTIME 16
+#define QIF_ITIME 32
+#define QIF_LIMITS (QIF_BLIMITS | QIF_ILIMITS)
+#define QIF_USAGE (QIF_SPACE | QIF_INODES)
+#define QIF_TIMES (QIF_BTIME | QIF_ITIME)
+#define QIF_ALL (QIF_LIMITS | QIF_USAGE | QIF_TIMES)
+
+struct dqblk
+ {
+ u_int64_t dqb_bhardlimit; /* absolute limit on disk quota blocks alloc */
+ u_int64_t dqb_bsoftlimit; /* preferred limit on disk quota blocks */
+ u_int64_t dqb_curspace; /* current quota block count */
+ u_int64_t dqb_ihardlimit; /* maximum # allocated inodes */
+ u_int64_t dqb_isoftlimit; /* preferred inode limit */
+ u_int64_t dqb_curinodes; /* current # allocated inodes */
+ u_int64_t dqb_btime; /* time limit for excessive disk use */
+ u_int64_t dqb_itime; /* time limit for excessive files */
+ u_int32_t dqb_valid; /* bitmask of QIF_* constants */
+ };
+#endif
/*
* Shorthand notation.
*/
#define dq_bhardlimit dq_dqb.dqb_bhardlimit
#define dq_bsoftlimit dq_dqb.dqb_bsoftlimit
-#define dq_curblocks dq_dqb.dqb_curblocks
+#if _LINUX_QUOTA_VERSION < 2
+# define dq_curblocks dq_dqb.dqb_curblocks
+#else
+# define dq_curspace dq_dqb.dqb_curspace
+# define dq_valid dq_dqb.dqb_valid
+#endif
#define dq_ihardlimit dq_dqb.dqb_ihardlimit
#define dq_isoftlimit dq_dqb.dqb_isoftlimit
#define dq_curinodes dq_dqb.dqb_curinodes
@@ -135,6 +190,7 @@ struct dqblk
#define dqoff(UID) ((loff_t)((UID) * sizeof (struct dqblk)))
+#if _LINUX_QUOTA_VERSION < 2
struct dqstats
{
u_int32_t lookups;
@@ -147,6 +203,22 @@ struct dqstats
u_int32_t free_dquots;
u_int32_t syncs;
};
+#else
+
+/* Flags that indicate which fields in dqinfo structure are valid. */
+# define IIF_BGRACE 1
+# define IIF_IGRACE 2
+# define IIF_FLAGS 4
+# define IIF_ALL (IIF_BGRACE | IIF_IGRACE | IIF_FLAGS)
+
+struct dqinfo
+ {
+ u_int64_t dqi_bgrace;
+ u_int64_t dqi_igrace;
+ u_int32_t dqi_flags;
+ u_int32_t dqi_valid;
+ };
+#endif
__BEGIN_DECLS
diff --git a/include/sys/reboot.h b/include/sys/reboot.h
index 2a719c7a3..bc685aebb 100644
--- a/include/sys/reboot.h
+++ b/include/sys/reboot.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 should define RB_* macros to be used as flag
bits in the argument to the `reboot' system call. */
diff --git a/include/sys/resource.h b/include/sys/resource.h
index 391274137..17167ed99 100644
--- a/include/sys/resource.h
+++ b/include/sys/resource.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_RESOURCE_H
#define _SYS_RESOURCE_H 1
@@ -50,6 +49,7 @@ typedef int __priority_which_t;
#ifndef __USE_FILE_OFFSET64
extern int getrlimit (__rlimit_resource_t __resource,
struct rlimit *__rlimits) __THROW;
+libc_hidden_proto(getrlimit)
#else
# ifdef __REDIRECT_NTH
extern int __REDIRECT_NTH (getrlimit, (__rlimit_resource_t __resource,
@@ -68,11 +68,12 @@ extern int getrlimit64 (__rlimit_resource_t __resource,
Return 0 if successful, -1 if not (and sets errno). */
#ifndef __USE_FILE_OFFSET64
extern int setrlimit (__rlimit_resource_t __resource,
- __const struct rlimit *__rlimits) __THROW;
+ const struct rlimit *__rlimits) __THROW;
+libc_hidden_proto(setrlimit)
#else
# ifdef __REDIRECT_NTH
extern int __REDIRECT_NTH (setrlimit, (__rlimit_resource_t __resource,
- __const struct rlimit *__rlimits),
+ const struct rlimit *__rlimits),
setrlimit64);
# else
# define setrlimit setrlimit64
@@ -80,7 +81,7 @@ extern int __REDIRECT_NTH (setrlimit, (__rlimit_resource_t __resource,
#endif
#ifdef __USE_LARGEFILE64
extern int setrlimit64 (__rlimit_resource_t __resource,
- __const struct rlimit64 *__rlimits) __THROW;
+ const struct rlimit64 *__rlimits) __THROW;
#endif
/* Return resource usage information on process indicated by WHO
@@ -92,11 +93,13 @@ extern int getrusage (__rusage_who_t __who, struct rusage *__usage) __THROW;
(as specified by WHO) is used. A lower priority number means higher
priority. Priorities range from PRIO_MIN to PRIO_MAX (above). */
extern int getpriority (__priority_which_t __which, id_t __who) __THROW;
+libc_hidden_proto(getpriority)
/* Set the priority of all processes specified by WHICH and WHO (see above)
to PRIO. Returns 0 on success, -1 on errors. */
extern int setpriority (__priority_which_t __which, id_t __who, int __prio)
__THROW;
+libc_hidden_proto(setpriority)
__END_DECLS
diff --git a/include/sys/select.h b/include/sys/select.h
index 2a408433e..0c2192dbb 100644
--- a/include/sys/select.h
+++ b/include/sys/select.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/>. */
/* POSIX 1003.1g: 6.2 Select from File Descriptor Sets <sys/select.h> */
@@ -110,6 +109,10 @@ extern int select (int __nfds, fd_set *__restrict __readfds,
fd_set *__restrict __writefds,
fd_set *__restrict __exceptfds,
struct timeval *__restrict __timeout);
+#ifdef _LIBC
+extern __typeof(select) __select_nocancel attribute_hidden;
+libc_hidden_proto(select)
+#endif
#ifdef __USE_XOPEN2K
/* Same as above only that the TIMEOUT value is given with higher
diff --git a/include/sys/sem.h b/include/sys/sem.h
index 24a57fc32..84168d834 100644
--- a/include/sys/sem.h
+++ b/include/sys/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
#define _SYS_SEM_H 1
@@ -61,7 +60,7 @@ extern int semop (int __semid, struct sembuf *__sops, size_t __nsops) __THROW;
#ifdef __USE_GNU
/* Operate on semaphore with timeout. */
extern int semtimedop (int __semid, struct sembuf *__sops, size_t __nsops,
- __const struct timespec *__timeout) __THROW;
+ const struct timespec *__timeout) __THROW;
#endif
__END_DECLS
diff --git a/include/sys/sendfile.h b/include/sys/sendfile.h
index 4c1367b6b..dae074c05 100644
--- a/include/sys/sendfile.h
+++ b/include/sys/sendfile.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_SENDFILE_H
#define _SYS_SENDFILE_H 1
@@ -45,6 +44,7 @@ extern ssize_t __REDIRECT_NTH (sendfile,
#ifdef __USE_LARGEFILE64
extern ssize_t sendfile64 (int __out_fd, int __in_fd, __off64_t *__offset,
size_t __count) __THROW;
+libc_hidden_proto(sendfile64)
#endif
__END_DECLS
diff --git a/include/sys/shm.h b/include/sys/shm.h
index 8ec30b486..8f04adeb4 100644
--- a/include/sys/shm.h
+++ b/include/sys/shm.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995-1999, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1995-1999, 2000, 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -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
#define _SYS_SHM_H 1
@@ -41,6 +40,7 @@ typedef __pid_t pid_t;
# endif
#endif /* X/Open */
+
__BEGIN_DECLS
/* The following System V style IPC functions implement a shared memory
@@ -53,11 +53,11 @@ extern int shmctl (int __shmid, int __cmd, struct shmid_ds *__buf) __THROW;
extern int shmget (key_t __key, size_t __size, int __shmflg) __THROW;
/* Attach shared memory segment. */
-extern void *shmat (int __shmid, __const void *__shmaddr, int __shmflg)
+extern void *shmat (int __shmid, const void *__shmaddr, int __shmflg)
__THROW;
/* Detach shared memory segment. */
-extern int shmdt (__const void *__shmaddr) __THROW;
+extern int shmdt (const void *__shmaddr) __THROW;
__END_DECLS
diff --git a/include/sys/socket.h b/include/sys/socket.h
index 4ae1ea980..8642312aa 100644
--- a/include/sys/socket.h
+++ b/include/sys/socket.h
@@ -1,5 +1,6 @@
/* Declarations of socket constants, types, and functions.
- Copyright (C) 1991,92,1994-2001,2003 Free Software Foundation, Inc.
+ Copyright (C) 1991,92,1994-2001,2003,2005,2007,2008
+ Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -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/>. */
#ifndef _SYS_SOCKET_H
#define _SYS_SOCKET_H 1
@@ -27,6 +27,10 @@ __BEGIN_DECLS
#include <sys/uio.h>
#define __need_size_t
#include <stddef.h>
+#ifdef __USE_GNU
+/* Get the __sigset_t definition. */
+# include <bits/sigset.h>
+#endif
/* This operating system-specific header file defines the SOCK_*, PF_*,
@@ -64,7 +68,7 @@ enum
old-style declaration, too. */
#if defined __cplusplus || !__GNUC_PREREQ (2, 7) || !defined __USE_GNU
# define __SOCKADDR_ARG struct sockaddr *__restrict
-# define __CONST_SOCKADDR_ARG __const struct sockaddr *
+# define __CONST_SOCKADDR_ARG const struct sockaddr *
#else
/* Add more `struct sockaddr_AF' types here as necessary.
These are all the ones I found on NetBSD and Linux. */
@@ -87,7 +91,7 @@ enum
typedef union { __SOCKADDR_ALLTYPES
} __SOCKADDR_ARG __attribute__ ((__transparent_union__));
# undef __SOCKADDR_ONETYPE
-# define __SOCKADDR_ONETYPE(type) __const struct type *__restrict __##type##__;
+# define __SOCKADDR_ONETYPE(type) const struct type *__restrict __##type##__;
typedef union { __SOCKADDR_ALLTYPES
} __CONST_SOCKADDR_ARG __attribute__ ((__transparent_union__));
# undef __SOCKADDR_ONETYPE
@@ -98,6 +102,7 @@ typedef union { __SOCKADDR_ALLTYPES
protocol PROTOCOL. If PROTOCOL is zero, one is chosen automatically.
Returns a file descriptor for the new socket, or -1 for errors. */
extern int socket (int __domain, int __type, int __protocol) __THROW;
+libc_hidden_proto(socket)
/* Create two new sockets, of type TYPE in domain DOMAIN and using
protocol PROTOCOL, which are connected to each other, and put file
@@ -109,10 +114,12 @@ extern int socketpair (int __domain, int __type, int __protocol,
/* Give the socket FD the local address ADDR (which is LEN bytes long). */
extern int bind (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len)
__THROW;
+libc_hidden_proto(bind)
/* Put the local address of FD into *ADDR and its length in *LEN. */
extern int getsockname (int __fd, __SOCKADDR_ARG __addr,
socklen_t *__restrict __len) __THROW;
+libc_hidden_proto(getsockname)
/* Open a connection on socket FD to peer at ADDR (which LEN bytes long).
For connectionless socket types, just set the default address to send to
@@ -122,6 +129,7 @@ extern int getsockname (int __fd, __SOCKADDR_ARG __addr,
This function is a cancellation point and therefore not marked with
__THROW. */
extern int connect (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len);
+libc_hidden_proto(connect)
/* Put the address of the peer connected to socket FD into *ADDR
(which is *LEN bytes long), and its actual length into *LEN. */
@@ -133,7 +141,8 @@ extern int getpeername (int __fd, __SOCKADDR_ARG __addr,
This function is a cancellation point and therefore not marked with
__THROW. */
-extern ssize_t send (int __fd, __const void *__buf, size_t __n, int __flags);
+extern ssize_t send (int __fd, const void *__buf, size_t __n, int __flags);
+libc_hidden_proto(send)
/* Read N bytes into BUF from socket FD.
Returns the number read or -1 for errors.
@@ -141,15 +150,20 @@ extern ssize_t send (int __fd, __const void *__buf, size_t __n, int __flags);
This function is a cancellation point and therefore not marked with
__THROW. */
extern ssize_t recv (int __fd, void *__buf, size_t __n, int __flags);
+libc_hidden_proto(recv)
/* Send N bytes of BUF on socket FD to peer at address ADDR (which is
ADDR_LEN bytes long). Returns the number sent, or -1 for errors.
This function is a cancellation point and therefore not marked with
__THROW. */
-extern ssize_t sendto (int __fd, __const void *__buf, size_t __n,
+extern ssize_t sendto (int __fd, const void *__buf, size_t __n,
int __flags, __CONST_SOCKADDR_ARG __addr,
socklen_t __addr_len);
+#ifdef _LIBC
+extern __typeof(sendto) __sendto_nocancel attribute_hidden;
+libc_hidden_proto(sendto)
+#endif
/* Read N bytes into BUF through socket FD.
If ADDR is not NULL, fill in *ADDR_LEN bytes of it with tha address of
@@ -161,6 +175,10 @@ extern ssize_t sendto (int __fd, __const void *__buf, size_t __n,
extern ssize_t recvfrom (int __fd, void *__restrict __buf, size_t __n,
int __flags, __SOCKADDR_ARG __addr,
socklen_t *__restrict __addr_len);
+#ifdef _LIBC
+extern __typeof(recvfrom) __recvfrom_nocancel attribute_hidden;
+libc_hidden_proto(recvfrom)
+#endif
/* Send a message described MESSAGE on socket FD.
@@ -168,8 +186,9 @@ extern ssize_t recvfrom (int __fd, void *__restrict __buf, size_t __n,
This function is a cancellation point and therefore not marked with
__THROW. */
-extern ssize_t sendmsg (int __fd, __const struct msghdr *__message,
+extern ssize_t sendmsg (int __fd, const struct msghdr *__message,
int __flags);
+libc_hidden_proto(sendmsg)
/* Receive a message as described by MESSAGE from socket FD.
Returns the number of bytes read or -1 for errors.
@@ -177,6 +196,7 @@ extern ssize_t sendmsg (int __fd, __const struct msghdr *__message,
This function is a cancellation point and therefore not marked with
__THROW. */
extern ssize_t recvmsg (int __fd, struct msghdr *__message, int __flags);
+libc_hidden_proto(recvmsg)
/* Put the current value for socket FD's option OPTNAME at protocol level LEVEL
@@ -190,13 +210,15 @@ extern int getsockopt (int __fd, int __level, int __optname,
to *OPTVAL (which is OPTLEN bytes long).
Returns 0 on success, -1 for errors. */
extern int setsockopt (int __fd, int __level, int __optname,
- __const void *__optval, socklen_t __optlen) __THROW;
+ const void *__optval, socklen_t __optlen) __THROW;
+libc_hidden_proto(setsockopt)
/* Prepare to accept connections on socket FD.
N connection requests will be queued before further requests are refused.
Returns 0 on success, -1 for errors. */
extern int listen (int __fd, int __n) __THROW;
+libc_hidden_proto(listen)
/* Await a connection on socket FD.
When a connection arrives, open a new socket to communicate with it,
@@ -208,6 +230,16 @@ extern int listen (int __fd, int __n) __THROW;
__THROW. */
extern int accept (int __fd, __SOCKADDR_ARG __addr,
socklen_t *__restrict __addr_len);
+libc_hidden_proto(accept)
+
+#if defined __UCLIBC_LINUX_SPECIFIC__ && defined __USE_GNU
+/* Similar to 'accept' but takes an additional parameter to specify flags.
+
+ This function is a cancellation point and therefore not marked with
+ __THROW. */
+extern int accept4 (int __fd, __SOCKADDR_ARG __addr,
+ socklen_t *__restrict __addr_len, int __flags);
+#endif
/* Shut down all or part of the connection open on socket FD.
HOW determines what to shut down:
@@ -218,7 +250,7 @@ extern int accept (int __fd, __SOCKADDR_ARG __addr,
extern int shutdown (int __fd, int __how) __THROW;
-#ifdef __USE_XOPEN2K
+#if 0 /*def __USE_XOPEN2K*/
/* Determine wheter socket is at a out-of-band mark. */
extern int sockatmark (int __fd) __THROW;
#endif
@@ -233,4 +265,8 @@ extern int isfdtype (int __fd, int __fdtype) __THROW;
__END_DECLS
+#ifdef _LIBC
+extern int __socketcall(int, unsigned long *) attribute_hidden;
+#endif
+
#endif /* sys/socket.h */
diff --git a/include/sys/stat.h b/include/sys/stat.h
index 508239050..495a68cb1 100644
--- a/include/sys/stat.h
+++ b/include/sys/stat.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1991,1992,1995-2004,2005,2006 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1995-2004, 2005, 2006, 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
@@ -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/>. */
/*
* POSIX Standard: 5.6 File Characteristics <sys/stat.h>
@@ -27,11 +27,12 @@
#include <bits/types.h> /* For __mode_t and __dev_t. */
-#if defined __USE_XOPEN || defined __USE_MISC
+#if defined __USE_XOPEN || defined __USE_XOPEN2K || defined __USE_MISC \
+ || defined __USE_ATFILE
# if defined __USE_XOPEN || defined __USE_XOPEN2K
# define __need_time_t
# endif
-# ifdef __USE_MISC
+# if defined __USE_MISC || defined __USE_ATFILE
# define __need_timespec
# endif
# include <time.h> /* For time_t resp. timespec. */
@@ -204,15 +205,17 @@ __BEGIN_DECLS
#ifndef __USE_FILE_OFFSET64
/* Get file attributes for FILE and put them in BUF. */
-extern int stat (__const char *__restrict __file,
+extern int stat (const char *__restrict __file,
struct stat *__restrict __buf) __THROW __nonnull ((1, 2));
+libc_hidden_proto(stat)
/* Get file attributes for the file, device, pipe, or socket
that file descriptor FD is open on and put them in BUF. */
extern int fstat (int __fd, struct stat *__buf) __THROW __nonnull ((2));
+libc_hidden_proto(fstat)
#else
# ifdef __REDIRECT_NTH
-extern int __REDIRECT_NTH (stat, (__const char *__restrict __file,
+extern int __REDIRECT_NTH (stat, (const char *__restrict __file,
struct stat *__restrict __buf), stat64)
__nonnull ((1, 2));
extern int __REDIRECT_NTH (fstat, (int __fd, struct stat *__buf), fstat64)
@@ -223,9 +226,11 @@ extern int __REDIRECT_NTH (fstat, (int __fd, struct stat *__buf), fstat64)
# endif
#endif
#ifdef __USE_LARGEFILE64
-extern int stat64 (__const char *__restrict __file,
+extern int stat64 (const char *__restrict __file,
struct stat64 *__restrict __buf) __THROW __nonnull ((1, 2));
extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
+libc_hidden_proto(stat64)
+libc_hidden_proto(fstat64)
#endif
#ifdef __USE_ATFILE
@@ -233,12 +238,13 @@ extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
Relative path names are interpreted relative to FD unless FD is
AT_FDCWD. */
# ifndef __USE_FILE_OFFSET64
-extern int fstatat (int __fd, __const char *__restrict __file,
+extern int fstatat (int __fd, const char *__restrict __file,
struct stat *__restrict __buf, int __flag)
__THROW __nonnull ((2, 3));
+libc_hidden_proto(fstatat)
# else
# ifdef __REDIRECT_NTH
-extern int __REDIRECT_NTH (fstatat, (int __fd, __const char *__restrict __file,
+extern int __REDIRECT_NTH (fstatat, (int __fd, const char *__restrict __file,
struct stat *__restrict __buf,
int __flag),
fstatat64) __nonnull ((2, 3));
@@ -247,21 +253,25 @@ extern int __REDIRECT_NTH (fstatat, (int __fd, __const char *__restrict __file,
# endif
# endif
-extern int fstatat64 (int __fd, __const char *__restrict __file,
+# ifdef __USE_LARGEFILE64
+extern int fstatat64 (int __fd, const char *__restrict __file,
struct stat64 *__restrict __buf, int __flag)
__THROW __nonnull ((2, 3));
+libc_hidden_proto(fstatat64)
+# endif
#endif
-#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
+#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K
# ifndef __USE_FILE_OFFSET64
/* Get file attributes about FILE and put them in BUF.
If FILE is a symbolic link, do not follow it. */
-extern int lstat (__const char *__restrict __file,
+extern int lstat (const char *__restrict __file,
struct stat *__restrict __buf) __THROW __nonnull ((1, 2));
+libc_hidden_proto(lstat)
# else
# ifdef __REDIRECT_NTH
extern int __REDIRECT_NTH (lstat,
- (__const char *__restrict __file,
+ (const char *__restrict __file,
struct stat *__restrict __buf), lstat64)
__nonnull ((1, 2));
# else
@@ -269,22 +279,24 @@ extern int __REDIRECT_NTH (lstat,
# endif
# endif
# ifdef __USE_LARGEFILE64
-extern int lstat64 (__const char *__restrict __file,
+extern int lstat64 (const char *__restrict __file,
struct stat64 *__restrict __buf)
__THROW __nonnull ((1, 2));
+libc_hidden_proto(lstat64)
# endif
#endif
/* Set file access permissions for FILE to MODE.
If FILE is a symbolic link, this affects its target instead. */
-extern int chmod (__const char *__file, __mode_t __mode)
+extern int chmod (const char *__file, __mode_t __mode)
__THROW __nonnull ((1));
+libc_hidden_proto(chmod)
#if 0 /*def __USE_BSD*/
/* Set file access permissions for FILE to MODE.
If FILE is a symbolic link, this affects the link itself
rather than its target. */
-extern int lchmod (__const char *__file, __mode_t __mode)
+extern int lchmod (const char *__file, __mode_t __mode)
__THROW __nonnull ((1));
#endif
@@ -296,8 +308,10 @@ extern int fchmod (int __fd, __mode_t __mode) __THROW;
#ifdef __USE_ATFILE
/* Set file access permissions of FILE relative to
the directory FD is open on. */
-extern int fchmodat (int __fd, __const char *__file, __mode_t mode, int __flag)
+extern int fchmodat (int __fd, const char *__file, __mode_t __mode,
+ int __flag)
__THROW __nonnull ((2)) __wur;
+libc_hidden_proto(fchmodat)
#endif /* Use ATFILE. */
@@ -313,46 +327,65 @@ extern __mode_t getumask (void) __THROW;
#endif
/* Create a new directory named PATH, with permission bits MODE. */
-extern int mkdir (__const char *__path, __mode_t __mode)
+extern int mkdir (const char *__path, __mode_t __mode)
__THROW __nonnull ((1));
+libc_hidden_proto(mkdir)
#ifdef __USE_ATFILE
/* Like mkdir, create a new directory with permission bits MODE. But
interpret relative PATH names relative to the directory associated
with FD. */
-extern int mkdirat (int __fd, __const char *__path, __mode_t __mode)
+extern int mkdirat (int __fd, const char *__path, __mode_t __mode)
__THROW __nonnull ((2));
+libc_hidden_proto(mkdirat)
#endif
/* Create a device file named PATH, with permission and special bits MODE
and device number DEV (which can be constructed from major and minor
device numbers with the `makedev' macro above). */
#if defined __USE_MISC || defined __USE_BSD || defined __USE_XOPEN_EXTENDED
-extern int mknod (__const char *__path, __mode_t __mode, __dev_t __dev)
+extern int mknod (const char *__path, __mode_t __mode, __dev_t __dev)
__THROW __nonnull ((1));
-#endif
+libc_hidden_proto(mknod)
-#ifdef __USE_ATFILE
+# ifdef __USE_ATFILE
/* Like mknod, create a new device file with permission bits MODE and
device number DEV. But interpret relative PATH names relative to
the directory associated with FD. */
-extern int mknodat (int __fd, __const char *__path, __mode_t __mode,
+extern int mknodat (int __fd, const char *__path, __mode_t __mode,
__dev_t __dev) __THROW __nonnull ((2));
+libc_hidden_proto(mknodat)
+# endif
#endif
/* Create a new FIFO named PATH, with permission bits MODE. */
-extern int mkfifo (__const char *__path, __mode_t __mode)
+extern int mkfifo (const char *__path, __mode_t __mode)
__THROW __nonnull ((1));
#ifdef __USE_ATFILE
/* Like mkfifo, create a new FIFO with permission bits MODE. But
interpret relative PATH names relative to the directory associated
with FD. */
-extern int mkfifoat (int __fd, __const char *__path, __mode_t __mode)
+extern int mkfifoat (int __fd, const char *__path, __mode_t __mode)
__THROW __nonnull ((2));
#endif
+
+#ifdef __USE_ATFILE
+/* Set file access and modification times relative to directory file
+ descriptor. */
+extern int utimensat (int __fd, const char *__path,
+ const struct timespec __times[2],
+ int __flags)
+ __THROW __nonnull ((2));
+libc_hidden_proto(utimensat)
+#endif
+#ifdef __USE_XOPEN2K8
+/* Set file access and modification times of the file associated with FD. */
+extern int futimens (int __fd, const struct timespec __times[2]) __THROW;
+#endif
+
/* on uClibc we have unversioned struct stat and mknod.
* bits/stat.h is filled with wrong info, so we undo it here. */
#undef _STAT_VER
diff --git a/include/sys/statfs.h b/include/sys/statfs.h
index f4177d4c9..ab74b0bbd 100644
--- a/include/sys/statfs.h
+++ b/include/sys/statfs.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_STATFS_H
#define _SYS_STATFS_H 1
@@ -29,23 +28,24 @@ __BEGIN_DECLS
/* Return information about the filesystem on which FILE resides. */
#ifndef __USE_FILE_OFFSET64
-extern int statfs (__const char *__file, struct statfs *__buf)
+extern int statfs (const char *__file, struct statfs *__buf)
__THROW __nonnull ((1, 2));
+libc_hidden_proto(statfs)
#else
# ifdef __REDIRECT_NTH
extern int __REDIRECT_NTH (statfs,
- (__const char *__file, struct statfs *__buf),
+ (const char *__file, struct statfs *__buf),
statfs64) __nonnull ((1, 2));
# else
# define statfs statfs64
# endif
#endif
#ifdef __USE_LARGEFILE64
-extern int statfs64 (__const char *__file, struct statfs64 *__buf)
+extern int statfs64 (const char *__file, struct statfs64 *__buf)
__THROW __nonnull ((1, 2));
+libc_hidden_proto(statfs64)
#endif
-#if defined __UCLIBC_LINUX_SPECIFIC__
/* Return information about the filesystem containing the file FILDES
refers to. */
#ifndef __USE_FILE_OFFSET64
@@ -62,8 +62,8 @@ extern int __REDIRECT_NTH (fstatfs, (int __fildes, struct statfs *__buf),
#ifdef __USE_LARGEFILE64
extern int fstatfs64 (int __fildes, struct statfs64 *__buf)
__THROW __nonnull ((2));
+libc_hidden_proto(fstatfs64)
#endif
-#endif /* __UCLIBC_LINUX_SPECIFIC__ */
__END_DECLS
diff --git a/include/sys/statvfs.h b/include/sys/statvfs.h
index 685dd2619..e5e0c2362 100644
--- a/include/sys/statvfs.h
+++ b/include/sys/statvfs.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_STATVFS_H
#define _SYS_STATVFS_H 1
@@ -49,13 +48,14 @@ __BEGIN_DECLS
/* Return information about the filesystem on which FILE resides. */
#ifndef __USE_FILE_OFFSET64
-extern int statvfs (__const char *__restrict __file,
+extern int statvfs (const char *__restrict __file,
struct statvfs *__restrict __buf)
__THROW __nonnull ((1, 2));
+libc_hidden_proto(statvfs)
#else
-# ifdef __REDIRECT
-extern int __REDIRECT (statvfs,
- (__const char *__restrict __file,
+# ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (statvfs,
+ (const char *__restrict __file,
struct statvfs *__restrict __buf), statvfs64)
__nonnull ((1, 2));
# else
@@ -63,7 +63,7 @@ extern int __REDIRECT (statvfs,
# endif
#endif
#ifdef __USE_LARGEFILE64
-extern int statvfs64 (__const char *__restrict __file,
+extern int statvfs64 (const char *__restrict __file,
struct statvfs64 *__restrict __buf)
__THROW __nonnull ((1, 2));
#endif
@@ -73,9 +73,10 @@ extern int statvfs64 (__const char *__restrict __file,
#ifndef __USE_FILE_OFFSET64
extern int fstatvfs (int __fildes, struct statvfs *__buf)
__THROW __nonnull ((2));
+libc_hidden_proto(fstatvfs)
#else
-# ifdef __REDIRECT
-extern int __REDIRECT (fstatvfs, (int __fildes, struct statvfs *__buf),
+# ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (fstatvfs, (int __fildes, struct statvfs *__buf),
fstatvfs64) __nonnull ((2));
# else
# define fstatvfs fstatvfs64
diff --git a/include/sys/swap.h b/include/sys/swap.h
index b6e7bef5d..29faba616 100644
--- a/include/sys/swap.h
+++ b/include/sys/swap.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_SWAP_H
@@ -33,10 +32,10 @@ __BEGIN_DECLS
/* Make the block special device PATH available to the system for swapping.
This call is restricted to the super-user. */
-extern int swapon (__const char *__path, int __flags) __THROW;
+extern int swapon (const char *__path, int __flags) __THROW;
/* Stop using block special device PATH for swapping. */
-extern int swapoff (__const char *__path) __THROW;
+extern int swapoff (const char *__path) __THROW;
__END_DECLS
diff --git a/include/sys/syscall.h b/include/sys/syscall.h
index 4c8ede843..ec8a75cf1 100644
--- a/include/sys/syscall.h
+++ b/include/sys/syscall.h
@@ -12,26 +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/>. */
#ifndef _SYSCALL_H
#define _SYSCALL_H 1
+/* User application code should use syscall(). */
+
+#include <features.h>
+#include <bits/sysnum.h>
+#ifdef _LIBC
/* The _syscall#() macros are for uClibc internal use only.
- * User application code should use syscall() instead.
*
* The kernel provided _syscall[0-6] macros from asm/unistd.h are not suitable
* for use in uClibc as they lack PIC support etc, so for uClibc we use our own
* local _syscall# macros to be certain all such variations are handled
* properly.
*/
-
-#include <features.h>
-#include <bits/sysnum.h>
-#if defined _LIBC && (defined IS_IN_libc || defined NOT_IN_libc)
# include <bits/syscalls.h>
+# include <bits/syscalls-common.h>
#endif
#endif
diff --git a/include/sys/sysctl.h b/include/sys/sysctl.h
index 110efaa76..2c2d68819 100644
--- a/include/sys/sysctl.h
+++ b/include/sys/sysctl.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_SYSCTL_H
#define _SYS_SYSCTL_H 1
diff --git a/include/sys/sysinfo.h b/include/sys/sysinfo.h
index 9fd4fa829..00e363371 100644
--- a/include/sys/sysinfo.h
+++ b/include/sys/sysinfo.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_SYSINFO_H
#define _SYS_SYSINFO_H 1
@@ -24,6 +23,8 @@
#ifndef _LINUX_KERNEL_H
/* Include our own copy of struct sysinfo to avoid binary compatability
* problems with Linux 2.4, which changed things. Grumble, grumble. */
+#define _LINUX_SYSINFO_H
+
#define SI_LOAD_SHIFT 16
struct sysinfo {
long uptime; /* Seconds since boot */
@@ -48,19 +49,20 @@ __BEGIN_DECLS
/* Returns information on overall system statistics. */
extern int sysinfo (struct sysinfo *__info) __THROW;
-
/* Return number of configured processors. */
-extern int get_nprocs_conf (void) __THROW;
+#define get_nprocs_conf() (sysconf(_SC_NPROCESSORS_CONF))
/* Return number of available processors. */
-extern int get_nprocs (void) __THROW;
+#define get_nprocs() (sysconf(_SC_NPROCESSORS_ONLN))
+#if 0
/* Return number of physical pages of memory in the system. */
extern long int get_phys_pages (void) __THROW;
/* Return number of available physical pages of memory in the system. */
extern long int get_avphys_pages (void) __THROW;
+#endif
__END_DECLS
diff --git a/include/sys/syslog.h b/include/sys/syslog.h
index 3f5e6b297..8808d217c 100644
--- a/include/sys/syslog.h
+++ b/include/sys/syslog.h
@@ -184,7 +184,7 @@ extern void closelog (void);
This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern void openlog (__const char *__ident, int __option, int __facility);
+extern void openlog (const char *__ident, int __option, int __facility);
/* Set the log mask level. */
extern int setlogmask (int __mask) __THROW;
@@ -193,8 +193,9 @@ extern int setlogmask (int __mask) __THROW;
This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern void syslog (int __pri, __const char *__fmt, ...)
+extern void syslog (int __pri, const char *__fmt, ...)
__attribute__ ((__format__ (__printf__, 2, 3)));
+libc_hidden_proto(syslog)
#ifdef __USE_BSD
/* Generate a log message using FMT and using arguments pointed to by AP.
@@ -203,7 +204,7 @@ extern void syslog (int __pri, __const char *__fmt, ...)
cancellation point. But due to similarity with an POSIX interface
or due to the implementation it is a cancellation point and
therefore not marked with __THROW. */
-extern void vsyslog (int __pri, __const char *__fmt, __gnuc_va_list __ap)
+extern void vsyslog (int __pri, const char *__fmt, __gnuc_va_list __ap)
__attribute__ ((__format__ (__printf__, 2, 0)));
#endif
diff --git a/include/sys/sysmacros.h b/include/sys/sysmacros.h
index c5efca4f9..3addb7500 100644
--- a/include/sys/sysmacros.h
+++ b/include/sys/sysmacros.h
@@ -13,44 +13,47 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 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_SYSMACROS_H
#define _SYS_SYSMACROS_H 1
#include <features.h>
+__BEGIN_DECLS
+
/* If the compiler does not know long long it is out of luck. We are
not going to hack weird hacks to support the dev_t representation
they need. */
-#if 1 /*def __GLIBC_HAVE_LONG_LONG uClibc note: always enable */
+
__extension__
-static __inline unsigned int gnu_dev_major (unsigned long long int __dev)
- __THROW;
+extern unsigned int gnu_dev_major (unsigned long long int __dev)
+ __THROW __attribute__ ((__const__));
+libc_hidden_proto(gnu_dev_major)
__extension__
-static __inline unsigned int gnu_dev_minor (unsigned long long int __dev)
- __THROW;
+extern unsigned int gnu_dev_minor (unsigned long long int __dev)
+ __THROW __attribute__ ((__const__));
+libc_hidden_proto(gnu_dev_minor)
__extension__
-static __inline unsigned long long int gnu_dev_makedev (unsigned int __major,
+extern unsigned long long int gnu_dev_makedev (unsigned int __major,
unsigned int __minor)
- __THROW;
+ __THROW __attribute__ ((__const__));
-# if defined __GNUC__ && __GNUC__ >= 2
-__extension__ static __inline unsigned int
+# ifdef __USE_EXTERN_INLINES
+__extension__ __extern_inline __attribute__ ((__const__)) unsigned int
__NTH (gnu_dev_major (unsigned long long int __dev))
{
return ((__dev >> 8) & 0xfff) | ((unsigned int) (__dev >> 32) & ~0xfff);
}
-__extension__ static __inline unsigned int
+__extension__ __extern_inline __attribute__ ((__const__)) unsigned int
__NTH (gnu_dev_minor (unsigned long long int __dev))
{
return (__dev & 0xff) | ((unsigned int) (__dev >> 12) & ~0xff);
}
-__extension__ static __inline unsigned long long int
+__extension__ __extern_inline __attribute__ ((__const__)) unsigned long long int
__NTH (gnu_dev_makedev (unsigned int __major, unsigned int __minor))
{
return ((__minor & 0xff) | ((__major & 0xfff) << 8)
@@ -58,12 +61,11 @@ __NTH (gnu_dev_makedev (unsigned int __major, unsigned int __minor))
| (((unsigned long long int) (__major & ~0xfff)) << 32));
}
# endif
-
+__END_DECLS
/* Access the functions with their traditional names. */
# define major(dev) gnu_dev_major (dev)
# define minor(dev) gnu_dev_minor (dev)
# define makedev(maj, min) gnu_dev_makedev (maj, min)
-#endif
#endif /* sys/sysmacros.h */
diff --git a/include/sys/time.h b/include/sys/time.h
index 66fb9e021..3b7a106be 100644
--- a/include/sys/time.h
+++ b/include/sys/time.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1991-1994,1996-2002,2003,2005 Free Software Foundation, Inc.
+/* Copyright (C) 1991-1994,1996-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
@@ -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 _SYS_TIME_H
#define _SYS_TIME_H 1
@@ -71,19 +71,21 @@ typedef void *__restrict __timezone_ptr_t;
Use the functions and variables declared in <time.h> instead. */
extern int gettimeofday (struct timeval *__restrict __tv,
__timezone_ptr_t __tz) __THROW __nonnull ((1));
+libc_hidden_proto(gettimeofday)
#ifdef __USE_BSD
/* Set the current time of day and timezone information.
This call is restricted to the super-user. */
-extern int settimeofday (__const struct timeval *__tv,
- __const struct timezone *__tz)
+extern int settimeofday (const struct timeval *__tv,
+ const struct timezone *__tz)
__THROW __nonnull ((1));
+libc_hidden_proto(settimeofday)
/* Adjust the current time of day by the amount in DELTA.
If OLDDELTA is not NULL, it is filled in with the amount
of time adjustment remaining to be done from the last `adjtime' call.
This call is restricted to the super-user. */
-extern int adjtime (__const struct timeval *__delta,
+extern int adjtime (const struct timeval *__delta,
struct timeval *__olddelta) __THROW;
#endif
@@ -130,30 +132,34 @@ extern int getitimer (__itimer_which_t __which,
set *OLD to the old value of timer WHICH.
Returns 0 on success, -1 on errors. */
extern int setitimer (__itimer_which_t __which,
- __const struct itimerval *__restrict __new,
+ const struct itimerval *__restrict __new,
struct itimerval *__restrict __old) __THROW;
+libc_hidden_proto(setitimer)
/* Change the access time of FILE to TVP[0] and the modification time of
FILE to TVP[1]. If TVP is a null pointer, use the current time instead.
Returns 0 on success, -1 on errors. */
-extern int utimes (__const char *__file, __const struct timeval __tvp[2])
+extern int utimes (const char *__file, const struct timeval __tvp[2])
__THROW __nonnull ((1));
+libc_hidden_proto(utimes)
-#if 0 /*def __USE_BSD*/
+#ifdef __USE_BSD
/* Same as `utimes', but does not follow symbolic links. */
-extern int lutimes (__const char *__file, __const struct timeval __tvp[2])
+extern int lutimes (const char *__file, const struct timeval __tvp[2])
__THROW __nonnull ((1));
+#if 0
/* Same as `utimes', but takes an open file descriptor instead of a name. */
-extern int futimes (int __fd, __const struct timeval __tvp[2]) __THROW;
+extern int futimes (int __fd, const struct timeval __tvp[2]) __THROW;
+#endif
#endif
-#if 0 /*def __USE_GNU*/
+#ifdef __USE_GNU
/* Change the access time of FILE relative to FD to TVP[0] and the
modification time of FILE to TVP[1]. If TVP is a null pointer, use
the current time instead. Returns 0 on success, -1 on errors. */
-extern int futimesat (int __fd, __const char *__file,
- __const struct timeval __tvp[2]) __THROW;
+extern int futimesat (int __fd, const char *__file,
+ const struct timeval __tvp[2]) __THROW;
#endif
diff --git a/include/sys/timeb.h b/include/sys/timeb.h
index dbdbf45a8..d34e4c10e 100644
--- a/include/sys/timeb.h
+++ b/include/sys/timeb.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_TIMEB_H
#define _SYS_TIMEB_H 1
diff --git a/include/sys/times.h b/include/sys/times.h
index 6022f2f84..3936762bd 100644
--- a/include/sys/times.h
+++ b/include/sys/times.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: 4.5.2 Process Times <sys/times.h>
@@ -47,6 +46,7 @@ struct tms
Return the elapsed real time, or (clock_t) -1 for errors.
All times are in CLK_TCKths of a second. */
extern clock_t times (struct tms *__buffer) __THROW;
+libc_hidden_proto(times)
__END_DECLS
diff --git a/include/sys/timex.h b/include/sys/timex.h
index d2020a6d2..4cb81d208 100644
--- a/include/sys/timex.h
+++ b/include/sys/timex.h
@@ -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_TIMEX_H
#define _SYS_TIMEX_H 1
#include <features.h>
#include <sys/time.h>
+#include <time.h>
/* These definitions from linux/timex.h as of 2.2.0. */
@@ -67,8 +67,12 @@ struct timex
#define ADJ_ESTERROR 0x0008 /* estimated time error */
#define ADJ_STATUS 0x0010 /* clock status */
#define ADJ_TIMECONST 0x0020 /* pll time constant */
-#define ADJ_TICK 0x4000 /* tick value */
-#define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */
+#define ADJ_TAI 0x0080 /* set TAI offset */
+#define ADJ_MICRO 0x1000 /* select microsecond resolution */
+#define ADJ_NANO 0x2000 /* select nanosecond resolution */
+#define ADJ_TICK 0x4000 /* tick value */
+#define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */
+#define ADJ_OFFSET_SS_READ 0xa001 /* read-only adjtime */
/* xntp 3.4 compatibility names */
#define MOD_OFFSET ADJ_OFFSET
@@ -118,12 +122,15 @@ __BEGIN_DECLS
extern int __adjtimex (struct timex *__ntx) __THROW;
extern int adjtimex (struct timex *__ntx) __THROW;
+libc_hidden_proto(adjtimex)
#if defined __UCLIBC_NTP_LEGACY__
extern int ntp_gettime (struct ntptimeval *__ntv) __THROW;
extern int ntp_adjtime (struct timex *__tntx) __THROW;
#endif
-
+#if defined __UCLIBC_HAS_REALTIME__
+extern int clock_adjtime (clockid_t __clock_id, struct timex *__ntx) __THROW;
+#endif
__END_DECLS
#endif /* sys/timex.h */
diff --git a/include/sys/ttydefaults.h b/include/sys/ttydefaults.h
index 9be168b83..bb605a458 100644
--- a/include/sys/ttydefaults.h
+++ b/include/sys/ttydefaults.h
@@ -75,9 +75,9 @@
#define CSTART CTRL('q')
#define CSTOP CTRL('s')
#define CLNEXT CTRL('v')
-#define CDISCARD CTRL('o')
-#define CWERASE CTRL('w')
-#define CREPRINT CTRL('r')
+#define CDISCARD CTRL('o')
+#define CWERASE CTRL('w')
+#define CREPRINT CTRL('r')
#define CEOT CEOF
/* compat */
#define CBRK CEOL
diff --git a/include/sys/types.h b/include/sys/types.h
index 8c0b5dce3..2b45d0300 100644
--- a/include/sys/types.h
+++ b/include/sys/types.h
@@ -1,5 +1,5 @@
/* Copyright (C) 1991,1992,1994,1995,1996,1997,1998,1999,2000,2001,2002
- Free Software Foundation, Inc.
+ 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/>. */
/*
* POSIX Standard: 2.6 Primitive System Data Types <sys/types.h>
@@ -165,7 +164,7 @@ typedef short int int16_t;
typedef int int32_t;
# if __WORDSIZE == 64
typedef long int int64_t;
-# elif defined __GNUC__ || defined __ICC
+# elif defined __GNUC__ || defined __ICC || defined __TenDRA__
__extension__ typedef long long int int64_t;
# endif
# endif
@@ -176,7 +175,7 @@ typedef unsigned short int u_int16_t;
typedef unsigned int u_int32_t;
# if __WORDSIZE == 64
typedef unsigned long int u_int64_t;
-# elif defined __GNUC__ || defined __ICC
+# elif defined __GNUC__ || defined __ICC || defined __TenDRA__
__extension__ typedef unsigned long long int u_int64_t;
# endif
diff --git a/include/sys/uio.h b/include/sys/uio.h
index 1b203f71c..efc681e7b 100644
--- a/include/sys/uio.h
+++ b/include/sys/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/>. */
#ifndef _SYS_UIO_H
#define _SYS_UIO_H 1
@@ -37,7 +36,7 @@ __BEGIN_DECLS
This function is a cancellation point and therefore not marked with
__THROW. */
-extern ssize_t readv (int __fd, __const struct iovec *__iovec, int __count);
+extern ssize_t readv (int __fd, const struct iovec *__iovec, int __count);
/* Write data pointed by the buffers described by IOVEC, which
is a vector of COUNT `struct iovec's, to file descriptor FD.
@@ -47,7 +46,7 @@ extern ssize_t readv (int __fd, __const struct iovec *__iovec, int __count);
This function is a cancellation point and therefore not marked with
__THROW. */
-extern ssize_t writev (int __fd, __const struct iovec *__iovec, int __count);
+extern ssize_t writev (int __fd, const struct iovec *__iovec, int __count);
__END_DECLS
diff --git a/include/sys/un.h b/include/sys/un.h
index 1fa10e4fe..e49d552bd 100644
--- a/include/sys/un.h
+++ b/include/sys/un.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_UN_H
#define _SYS_UN_H 1
diff --git a/include/sys/ustat.h b/include/sys/ustat.h
index 7a9cdac0d..11f51b20a 100644
--- a/include/sys/ustat.h
+++ b/include/sys/ustat.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/>. */
/*
* This interface is obsolete. Use <sys/statfs.h> instead.
diff --git a/include/sys/utsname.h b/include/sys/utsname.h
index ca195cb4d..04ff55be7 100644
--- a/include/sys/utsname.h
+++ b/include/sys/utsname.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 92, 94, 96, 97, 99 Free Software Foundation, Inc.
+/* Copyright (C) 1991,92,94,96,97,99,2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -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: 4.4 System Identification <sys/utsname.h>
@@ -29,26 +28,38 @@ __BEGIN_DECLS
#include <bits/utsname.h>
+#ifndef _UTSNAME_SYSNAME_LENGTH
+# define _UTSNAME_SYSNAME_LENGTH _UTSNAME_LENGTH
+#endif
#ifndef _UTSNAME_NODENAME_LENGTH
# define _UTSNAME_NODENAME_LENGTH _UTSNAME_LENGTH
#endif
+#ifndef _UTSNAME_RELEASE_LENGTH
+# define _UTSNAME_RELEASE_LENGTH _UTSNAME_LENGTH
+#endif
+#ifndef _UTSNAME_VERSION_LENGTH
+# define _UTSNAME_VERSION_LENGTH _UTSNAME_LENGTH
+#endif
+#ifndef _UTSNAME_MACHINE_LENGTH
+# define _UTSNAME_MACHINE_LENGTH _UTSNAME_LENGTH
+#endif
/* Structure describing the system and machine. */
struct utsname
{
/* Name of the implementation of the operating system. */
- char sysname[_UTSNAME_LENGTH];
+ char sysname[_UTSNAME_SYSNAME_LENGTH];
/* Name of this node on the network. */
char nodename[_UTSNAME_NODENAME_LENGTH];
/* Current release level of this implementation. */
- char release[_UTSNAME_LENGTH];
+ char release[_UTSNAME_RELEASE_LENGTH];
/* Current version level of this release. */
- char version[_UTSNAME_LENGTH];
+ char version[_UTSNAME_VERSION_LENGTH];
/* Name of the hardware type the system is running on. */
- char machine[_UTSNAME_LENGTH];
+ char machine[_UTSNAME_MACHINE_LENGTH];
#if _UTSNAME_DOMAIN_LENGTH - 0
/* Name of the domain of this node on the network. */
@@ -61,12 +72,14 @@ struct utsname
};
#ifdef __USE_SVID
+/* Note that SVID assumes all members have the same size. */
# define SYS_NMLN _UTSNAME_LENGTH
#endif
/* Put information about the system in NAME. */
extern int uname (struct utsname *__name) __THROW;
+libc_hidden_proto(uname)
__END_DECLS
diff --git a/include/sys/wait.h b/include/sys/wait.h
index 81a54fc3d..f7a420b93 100644
--- a/include/sys/wait.h
+++ b/include/sys/wait.h
@@ -1,5 +1,5 @@
-/* Copyright (C) 1991-1994,1996-2001,2003,2004,2005
- Free Software Foundation, Inc.
+/* Copyright (C) 1991-1994,1996-2001,2003,2004,2005,2007,2009
+ Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -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/>. */
/*
* POSIX Standard: 3.2.1 Wait for Process Termination <sys/wait.h>
@@ -29,10 +28,9 @@
__BEGIN_DECLS
#include <signal.h>
-#include <sys/resource.h>
/* These macros could also be defined in <stdlib.h>. */
-#if !defined _STDLIB_H || !defined __USE_XOPEN
+#if !defined _STDLIB_H || (!defined __USE_XOPEN && !defined __USE_XOPEN2K8)
/* This will define the `W*' macros for the flag
bits to `waitpid', `wait3', and `wait4'. */
# include <bits/waitflags.h>
@@ -47,11 +45,11 @@ __BEGIN_DECLS
(__extension__ (((union { __typeof(status) __in; int __i; }) \
{ .__in = (status) }).__i))
# else
-# define __WAIT_INT(status) (*(__const int *) &(status))
+# define __WAIT_INT(status) (*(const int *) &(status))
# endif
/* This is the type of the argument to `wait'. The funky union
- causes redeclarations with ether `int *' or `union wait *' to be
+ causes redeclarations with either `int *' or `union wait *' to be
allowed without complaint. __WAIT_STATUS_DEFN is the type used in
the actual function definitions. */
@@ -79,26 +77,26 @@ typedef union
/* This will define all the `__W*' macros. */
# include <bits/waitstatus.h>
-# define WEXITSTATUS(status) __WEXITSTATUS(__WAIT_INT(status))
-# define WTERMSIG(status) __WTERMSIG(__WAIT_INT(status))
-# define WSTOPSIG(status) __WSTOPSIG(__WAIT_INT(status))
-# define WIFEXITED(status) __WIFEXITED(__WAIT_INT(status))
-# define WIFSIGNALED(status) __WIFSIGNALED(__WAIT_INT(status))
-# define WIFSTOPPED(status) __WIFSTOPPED(__WAIT_INT(status))
-# if 0 /*def __WIFCONTINUED*/
-# define WIFCONTINUED(status) __WIFCONTINUED(__WAIT_INT(status))
+# define WEXITSTATUS(status) __WEXITSTATUS (__WAIT_INT (status))
+# define WTERMSIG(status) __WTERMSIG (__WAIT_INT (status))
+# define WSTOPSIG(status) __WSTOPSIG (__WAIT_INT (status))
+# define WIFEXITED(status) __WIFEXITED (__WAIT_INT (status))
+# define WIFSIGNALED(status) __WIFSIGNALED (__WAIT_INT (status))
+# define WIFSTOPPED(status) __WIFSTOPPED (__WAIT_INT (status))
+# ifdef __WIFCONTINUED
+# define WIFCONTINUED(status) __WIFCONTINUED (__WAIT_INT (status))
# endif
#endif /* <stdlib.h> not included. */
#ifdef __USE_BSD
# define WCOREFLAG __WCOREFLAG
-# define WCOREDUMP(status) __WCOREDUMP(__WAIT_INT(status))
-# define W_EXITCODE(ret, sig) __W_EXITCODE(ret, sig)
-# define W_STOPCODE(sig) __W_STOPCODE(sig)
+# define WCOREDUMP(status) __WCOREDUMP (__WAIT_INT (status))
+# define W_EXITCODE(ret, sig) __W_EXITCODE (ret, sig)
+# define W_STOPCODE(sig) __W_STOPCODE (sig)
#endif
/* The following values are used by the `waitid' function. */
-#if defined __USE_SVID || defined __USE_XOPEN
+#if defined __USE_SVID || defined __USE_XOPEN || defined __USE_XOPEN2K8
typedef enum
{
P_ALL, /* Wait for any child. */
@@ -137,10 +135,20 @@ extern __pid_t wait (__WAIT_STATUS __stat_loc);
This function is a cancellation point and therefore not marked with
__THROW. */
extern __pid_t waitpid (__pid_t __pid, int *__stat_loc, int __options);
+#ifdef _LIBC
+extern __typeof(waitpid) __waitpid_nocancel attribute_hidden;
+libc_hidden_proto(waitpid)
+#endif
-#if defined __USE_SVID || defined __USE_XOPEN
+#if defined __USE_SVID || defined __USE_XOPEN || defined __USE_XOPEN2K8
+# ifndef __id_t_defined
+# include <bits/types.h>
+ typedef __id_t id_t;
+# define __id_t_defined
+# endif
# define __need_siginfo_t
# include <bits/siginfo.h>
+
/* Wait for a childing matching IDTYPE and ID to change the status and
place appropriate information in *INFOP.
If IDTYPE is P_PID, match any process whose process ID is ID.
@@ -157,29 +165,26 @@ extern int waitid (idtype_t __idtype, __id_t __id, siginfo_t *__infop,
#endif
#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
-/* This being here makes the prototypes valid whether or not
- we have already included <sys/resource.h> to define `struct rusage'. */
struct rusage;
-
/* 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 there. If the
WUNTRACED bit is set in OPTIONS, return status for stopped children;
otherwise don't. */
extern __pid_t wait3 (__WAIT_STATUS __stat_loc, int __options,
- struct rusage * __usage) __THROW;
+ struct rusage * __usage) __THROWNL;
#endif
#ifdef __USE_BSD
-/* This being here makes the prototypes valid whether or not
- we have already included <sys/resource.h> to define `struct rusage'. */
-struct rusage;
-
/* PID is like waitpid. Other args are like wait3. */
extern __pid_t wait4 (__pid_t __pid, __WAIT_STATUS __stat_loc, int __options,
- struct rusage *__usage) __THROW;
+ struct rusage *__usage) __THROWNL;
#endif /* Use BSD. */
+#ifdef _LIBC
+extern __pid_t __wait4_nocancel(__pid_t, __WAIT_STATUS, int, struct rusage *) attribute_hidden;
+#endif
+
__END_DECLS
diff --git a/include/sys/xattr.h b/include/sys/xattr.h
index 2737f90bd..f39642dcc 100644
--- a/include/sys/xattr.h
+++ b/include/sys/xattr.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_XATTR_H
#define _SYS_XATTR_H 1
@@ -37,48 +36,48 @@ enum
/* Set the attribute NAME of the file pointed to by PATH to VALUE (which
is SIZE bytes long). Return 0 on success, -1 for errors. */
-extern int setxattr (__const char *__path, __const char *__name,
- __const void *__value, size_t __size, int __flags)
+extern int setxattr (const char *__path, const char *__name,
+ const void *__value, size_t __size, int __flags)
__THROW;
/* Set the attribute NAME of the file pointed to by PATH to VALUE (which is
SIZE bytes long), not following symlinks for the last pathname component.
Return 0 on success, -1 for errors. */
-extern int lsetxattr (__const char *__path, __const char *__name,
- __const void *__value, size_t __size, int __flags)
+extern int lsetxattr (const char *__path, const char *__name,
+ const void *__value, size_t __size, int __flags)
__THROW;
/* Set the attribute NAME of the file descriptor FD to VALUE (which is SIZE
bytes long). Return 0 on success, -1 for errors. */
-extern int fsetxattr (int __fd, __const char *__name, __const void *__value,
+extern int fsetxattr (int __fd, const char *__name, const void *__value,
size_t __size, int __flags) __THROW;
/* Get the attribute NAME of the file pointed to by PATH to VALUE (which is
SIZE bytes long). Return 0 on success, -1 for errors. */
-extern ssize_t getxattr (__const char *__path, __const char *__name,
+extern ssize_t getxattr (const char *__path, const char *__name,
void *__value, size_t __size) __THROW;
/* Get the attribute NAME of the file pointed to by PATH to VALUE (which is
SIZE bytes long), not following symlinks for the last pathname component.
Return 0 on success, -1 for errors. */
-extern ssize_t lgetxattr (__const char *__path, __const char *__name,
+extern ssize_t lgetxattr (const char *__path, const char *__name,
void *__value, size_t __size) __THROW;
/* Get the attribute NAME of the file descriptor FD to VALUE (which is SIZE
bytes long). Return 0 on success, -1 for errors. */
-extern ssize_t fgetxattr (int __fd, __const char *__name, void *__value,
+extern ssize_t fgetxattr (int __fd, const char *__name, void *__value,
size_t __size) __THROW;
/* List attributes of the file pointed to by PATH into the user-supplied
buffer LIST (which is SIZE bytes big). Return 0 on success, -1 for
errors. */
-extern ssize_t listxattr (__const char *__path, char *__list, size_t __size)
+extern ssize_t listxattr (const char *__path, char *__list, size_t __size)
__THROW;
/* List attributes of the file pointed to by PATH into the user-supplied
buffer LIST (which is SIZE bytes big), not following symlinks for the
last pathname component. Return 0 on success, -1 for errors. */
-extern ssize_t llistxattr (__const char *__path, char *__list, size_t __size)
+extern ssize_t llistxattr (const char *__path, char *__list, size_t __size)
__THROW;
/* List attributes of the file descriptor FD into the user-supplied buffer
@@ -88,16 +87,16 @@ extern ssize_t flistxattr (int __fd, char *__list, size_t __size)
/* Remove the attribute NAME from the file pointed to by PATH. Return 0
on success, -1 for errors. */
-extern int removexattr (__const char *__path, __const char *__name) __THROW;
+extern int removexattr (const char *__path, const char *__name) __THROW;
/* Remove the attribute NAME from the file pointed to by PATH, not
following symlinks for the last pathname component. Return 0 on
success, -1 for errors. */
-extern int lremovexattr (__const char *__path, __const char *__name) __THROW;
+extern int lremovexattr (const char *__path, const char *__name) __THROW;
/* Remove the attribute NAME from the file descriptor FD. Return 0 on
success, -1 for errors. */
-extern int fremovexattr (int __fd, __const char *__name) __THROW;
+extern int fremovexattr (int __fd, const char *__name) __THROW;
__END_DECLS
diff --git a/include/tar.h b/include/tar.h
index ddfef755d..9732d67cb 100644
--- a/include/tar.h
+++ b/include/tar.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 _TAR_H
#define _TAR_H 1
diff --git a/include/termios.h b/include/termios.h
index 9698b1fbd..7f11fd28c 100644
--- a/include/termios.h
+++ b/include/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/>. */
/*
* POSIX Standard: 7.1-2 General Terminal Interface <termios.h>
@@ -46,16 +45,18 @@ __BEGIN_DECLS
#endif
/* Return the output baud rate stored in *TERMIOS_P. */
-extern speed_t cfgetospeed (__const struct termios *__termios_p) __THROW;
+extern speed_t cfgetospeed (const struct termios *__termios_p) __THROW;
/* Return the input baud rate stored in *TERMIOS_P. */
-extern speed_t cfgetispeed (__const struct termios *__termios_p) __THROW;
+extern speed_t cfgetispeed (const struct termios *__termios_p) __THROW;
/* Set the output baud rate stored in *TERMIOS_P to SPEED. */
extern int cfsetospeed (struct termios *__termios_p, speed_t __speed) __THROW;
+libc_hidden_proto(cfsetospeed)
/* Set the input baud rate stored in *TERMIOS_P to SPEED. */
extern int cfsetispeed (struct termios *__termios_p, speed_t __speed) __THROW;
+libc_hidden_proto(cfsetispeed)
#ifdef __USE_BSD
/* Set both the input and output baud rates in *TERMIOS_OP to SPEED. */
@@ -65,11 +66,13 @@ extern int cfsetspeed (struct termios *__termios_p, speed_t __speed) __THROW;
/* Put the state of FD into *TERMIOS_P. */
extern int tcgetattr (int __fd, struct termios *__termios_p) __THROW;
+libc_hidden_proto(tcgetattr)
/* Set the state of FD to *TERMIOS_P.
Values for OPTIONAL_ACTIONS (TCSA*) are in <bits/termios.h>. */
extern int tcsetattr (int __fd, int __optional_actions,
- __const struct termios *__termios_p) __THROW;
+ const struct termios *__termios_p) __THROW;
+libc_hidden_proto(tcsetattr)
#ifdef __USE_BSD
diff --git a/include/tgmath.h b/include/tgmath.h
index 5fb683fef..1dc3595ee 100644
--- a/include/tgmath.h
+++ b/include/tgmath.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1998, 1999, 2000, 2001, 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
@@ -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/>. */
/*
* ISO C99 Standard: 7.22 Type-generic math <tgmath.h>
@@ -47,174 +47,199 @@
/* 1 if 'type' is a floating type, 0 if 'type' is an integer type.
Allows for _Bool. Expands to an integer constant expression. */
-# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))
+# if __GNUC_PREREQ (3, 1)
+# define __floating_type(type) \
+ (__builtin_classify_type ((type) 0) == 8 \
+ || (__builtin_classify_type ((type) 0) == 9 \
+ && __builtin_classify_type (__real__ ((type) 0)) == 8))
+# else
+# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))
+# endif
/* The tgmath real type for T, where E is 0 if T is an integer type and
1 for a floating type. */
# define __tgmath_real_type_sub(T, E) \
- __typeof__(*(0 ? (__typeof__ (0 ? (double *) 0 : (void *) (E))) 0 \
- : (__typeof__ (0 ? (T *) 0 : (void *) (!(E)))) 0))
+ __typeof__ (*(0 ? (__typeof__ (0 ? (double *) 0 : (void *) (E))) 0 \
+ : (__typeof__ (0 ? (T *) 0 : (void *) (!(E)))) 0))
/* The tgmath real type of EXPR. */
# define __tgmath_real_type(expr) \
- __tgmath_real_type_sub(__typeof__(expr), __floating_type(__typeof__(expr)))
+ __tgmath_real_type_sub (__typeof__ ((__typeof__ (expr)) 0), \
+ __floating_type (__typeof__ (expr)))
/* We have two kinds of generic macros: to support functions which are
only defined on real valued parameters and those which are defined
for complex functions as well. */
# define __TGMATH_UNARY_REAL_ONLY(Val, Fct) \
- (__extension__ ({ __tgmath_real_type (Val) __tgmres; \
- if (sizeof (Val) == sizeof (double) \
- || __builtin_classify_type (Val) != 8) \
- __tgmres = Fct (Val); \
- else if (sizeof (Val) == sizeof (float)) \
- __tgmres = Fct##f (Val); \
- else \
- __tgmres = __tgml(Fct) (Val); \
- __tgmres; }))
+ (__extension__ ((sizeof (Val) == sizeof (double) \
+ || __builtin_classify_type (Val) != 8) \
+ ? (__tgmath_real_type (Val)) Fct (Val) \
+ : (sizeof (Val) == sizeof (float)) \
+ ? (__tgmath_real_type (Val)) Fct##f (Val) \
+ : (__tgmath_real_type (Val)) __tgml(Fct) (Val)))
+
+# define __TGMATH_UNARY_REAL_RET_ONLY(Val, RetType, Fct) \
+ (__extension__ ((sizeof (Val) == sizeof (double) \
+ || __builtin_classify_type (Val) != 8) \
+ ? (RetType) Fct (Val) \
+ : (sizeof (Val) == sizeof (float)) \
+ ? (RetType) Fct##f (Val) \
+ : (RetType) __tgml(Fct) (Val)))
# define __TGMATH_BINARY_FIRST_REAL_ONLY(Val1, Val2, Fct) \
- (__extension__ ({ __tgmath_real_type (Val1) __tgmres; \
- if (sizeof (Val1) == sizeof (double) \
- || __builtin_classify_type (Val1) != 8) \
- __tgmres = Fct (Val1, Val2); \
- else if (sizeof (Val1) == sizeof (float)) \
- __tgmres = Fct##f (Val1, Val2); \
- else \
- __tgmres = __tgml(Fct) (Val1, Val2); \
- __tgmres; }))
+ (__extension__ ((sizeof (Val1) == sizeof (double) \
+ || __builtin_classify_type (Val1) != 8) \
+ ? (__tgmath_real_type (Val1)) Fct (Val1, Val2) \
+ : (sizeof (Val1) == sizeof (float)) \
+ ? (__tgmath_real_type (Val1)) Fct##f (Val1, Val2) \
+ : (__tgmath_real_type (Val1)) __tgml(Fct) (Val1, Val2)))
# define __TGMATH_BINARY_REAL_ONLY(Val1, Val2, Fct) \
- (__extension__ ({ __tgmath_real_type ((Val1) + (Val2)) __tgmres; \
- if ((sizeof (Val1) > sizeof (double) \
- || sizeof (Val2) > sizeof (double)) \
- && __builtin_classify_type ((Val1) + (Val2)) == 8) \
- __tgmres = __tgml(Fct) (Val1, Val2); \
- else if (sizeof (Val1) == sizeof (double) \
- || sizeof (Val2) == sizeof (double) \
- || __builtin_classify_type (Val1) != 8 \
- || __builtin_classify_type (Val2) != 8) \
- __tgmres = Fct (Val1, Val2); \
- else \
- __tgmres = Fct##f (Val1, Val2); \
- __tgmres; }))
+ (__extension__ (((sizeof (Val1) > sizeof (double) \
+ || sizeof (Val2) > sizeof (double)) \
+ && __builtin_classify_type ((Val1) + (Val2)) == 8) \
+ ? (__typeof ((__tgmath_real_type (Val1)) 0 \
+ + (__tgmath_real_type (Val2)) 0)) \
+ __tgml(Fct) (Val1, Val2) \
+ : (sizeof (Val1) == sizeof (double) \
+ || sizeof (Val2) == sizeof (double) \
+ || __builtin_classify_type (Val1) != 8 \
+ || __builtin_classify_type (Val2) != 8) \
+ ? (__typeof ((__tgmath_real_type (Val1)) 0 \
+ + (__tgmath_real_type (Val2)) 0)) \
+ Fct (Val1, Val2) \
+ : (__typeof ((__tgmath_real_type (Val1)) 0 \
+ + (__tgmath_real_type (Val2)) 0)) \
+ Fct##f (Val1, Val2)))
# define __TGMATH_TERNARY_FIRST_SECOND_REAL_ONLY(Val1, Val2, Val3, Fct) \
- (__extension__ ({ __tgmath_real_type ((Val1) + (Val2)) __tgmres; \
- if ((sizeof (Val1) > sizeof (double) \
- || sizeof (Val2) > sizeof (double)) \
- && __builtin_classify_type ((Val1) + (Val2)) == 8) \
- __tgmres = __tgml(Fct) (Val1, Val2, Val3); \
- else if (sizeof (Val1) == sizeof (double) \
- || sizeof (Val2) == sizeof (double) \
- || __builtin_classify_type (Val1) != 8 \
- || __builtin_classify_type (Val2) != 8) \
- __tgmres = Fct (Val1, Val2, Val3); \
- else \
- __tgmres = Fct##f (Val1, Val2, Val3); \
- __tgmres; }))
+ (__extension__ (((sizeof (Val1) > sizeof (double) \
+ || sizeof (Val2) > sizeof (double)) \
+ && __builtin_classify_type ((Val1) + (Val2)) == 8) \
+ ? (__typeof ((__tgmath_real_type (Val1)) 0 \
+ + (__tgmath_real_type (Val2)) 0)) \
+ __tgml(Fct) (Val1, Val2, Val3) \
+ : (sizeof (Val1) == sizeof (double) \
+ || sizeof (Val2) == sizeof (double) \
+ || __builtin_classify_type (Val1) != 8 \
+ || __builtin_classify_type (Val2) != 8) \
+ ? (__typeof ((__tgmath_real_type (Val1)) 0 \
+ + (__tgmath_real_type (Val2)) 0)) \
+ Fct (Val1, Val2, Val3) \
+ : (__typeof ((__tgmath_real_type (Val1)) 0 \
+ + (__tgmath_real_type (Val2)) 0)) \
+ Fct##f (Val1, Val2, Val3)))
# define __TGMATH_TERNARY_REAL_ONLY(Val1, Val2, Val3, Fct) \
- (__extension__ ({ __tgmath_real_type ((Val1) + (Val2) + (Val3)) __tgmres;\
- if ((sizeof (Val1) > sizeof (double) \
- || sizeof (Val2) > sizeof (double) \
- || sizeof (Val3) > sizeof (double)) \
- && __builtin_classify_type ((Val1) + (Val2) \
- + (Val3)) == 8) \
- __tgmres = __tgml(Fct) (Val1, Val2, Val3); \
- else if (sizeof (Val1) == sizeof (double) \
- || sizeof (Val2) == sizeof (double) \
- || sizeof (Val3) == sizeof (double) \
- || __builtin_classify_type (Val1) != 8 \
- || __builtin_classify_type (Val2) != 8 \
- || __builtin_classify_type (Val3) != 8) \
- __tgmres = Fct (Val1, Val2, Val3); \
- else \
- __tgmres = Fct##f (Val1, Val2, Val3); \
- __tgmres; }))
+ (__extension__ (((sizeof (Val1) > sizeof (double) \
+ || sizeof (Val2) > sizeof (double) \
+ || sizeof (Val3) > sizeof (double)) \
+ && __builtin_classify_type ((Val1) + (Val2) + (Val3)) \
+ == 8) \
+ ? (__typeof ((__tgmath_real_type (Val1)) 0 \
+ + (__tgmath_real_type (Val2)) 0 \
+ + (__tgmath_real_type (Val3)) 0)) \
+ __tgml(Fct) (Val1, Val2, Val3) \
+ : (sizeof (Val1) == sizeof (double) \
+ || sizeof (Val2) == sizeof (double) \
+ || sizeof (Val3) == sizeof (double) \
+ || __builtin_classify_type (Val1) != 8 \
+ || __builtin_classify_type (Val2) != 8 \
+ || __builtin_classify_type (Val3) != 8) \
+ ? (__typeof ((__tgmath_real_type (Val1)) 0 \
+ + (__tgmath_real_type (Val2)) 0 \
+ + (__tgmath_real_type (Val3)) 0)) \
+ Fct (Val1, Val2, Val3) \
+ : (__typeof ((__tgmath_real_type (Val1)) 0 \
+ + (__tgmath_real_type (Val2)) 0 \
+ + (__tgmath_real_type (Val3)) 0)) \
+ Fct##f (Val1, Val2, Val3)))
/* XXX This definition has to be changed as soon as the compiler understands
the imaginary keyword. */
# define __TGMATH_UNARY_REAL_IMAG(Val, Fct, Cfct) \
- (__extension__ ({ __tgmath_real_type (Val) __tgmres; \
- if (sizeof (__real__ (Val)) > sizeof (double) \
- && __builtin_classify_type (__real__ (Val)) == 8) \
- { \
- if (sizeof (__real__ (Val)) == sizeof (Val)) \
- __tgmres = __tgml(Fct) (Val); \
- else \
- __tgmres = __tgml(Cfct) (Val); \
- } \
- else if (sizeof (__real__ (Val)) == sizeof (double) \
- || __builtin_classify_type (__real__ (Val)) \
- != 8) \
- { \
- if (sizeof (__real__ (Val)) == sizeof (Val)) \
- __tgmres = Fct (Val); \
- else \
- __tgmres = Cfct (Val); \
- } \
- else \
- { \
- if (sizeof (__real__ (Val)) == sizeof (Val)) \
- __tgmres = Fct##f (Val); \
- else \
- __tgmres = Cfct##f (Val); \
- } \
- __tgmres; }))
+ (__extension__ ((sizeof (__real__ (Val)) == sizeof (double) \
+ || __builtin_classify_type (__real__ (Val)) != 8) \
+ ? ((sizeof (__real__ (Val)) == sizeof (Val)) \
+ ? (__tgmath_real_type (Val)) Fct (Val) \
+ : (__tgmath_real_type (Val)) Cfct (Val)) \
+ : (sizeof (__real__ (Val)) == sizeof (float)) \
+ ? ((sizeof (__real__ (Val)) == sizeof (Val)) \
+ ? (__tgmath_real_type (Val)) Fct##f (Val) \
+ : (__tgmath_real_type (Val)) Cfct##f (Val)) \
+ : ((sizeof (__real__ (Val)) == sizeof (Val)) \
+ ? (__tgmath_real_type (Val)) __tgml(Fct) (Val) \
+ : (__tgmath_real_type (Val)) __tgml(Cfct) (Val))))
+
+# define __TGMATH_UNARY_IMAG(Val, Cfct) \
+ (__extension__ ((sizeof (__real__ (Val)) == sizeof (double) \
+ || __builtin_classify_type (__real__ (Val)) != 8) \
+ ? (__typeof__ ((__tgmath_real_type (Val)) 0 \
+ + _Complex_I)) Cfct (Val) \
+ : (sizeof (__real__ (Val)) == sizeof (float)) \
+ ? (__typeof__ ((__tgmath_real_type (Val)) 0 \
+ + _Complex_I)) Cfct##f (Val) \
+ : (__typeof__ ((__tgmath_real_type (Val)) 0 \
+ + _Complex_I)) __tgml(Cfct) (Val)))
/* XXX This definition has to be changed as soon as the compiler understands
the imaginary keyword. */
-# define __TGMATH_UNARY_IMAG_ONLY(Val, Fct) \
- (__extension__ ({ __tgmath_real_type (Val) __tgmres; \
- if (sizeof (Val) == sizeof (__complex__ double) \
- || __builtin_classify_type (__real__ (Val)) != 8) \
- __tgmres = Fct (Val); \
- else if (sizeof (Val) == sizeof (__complex__ float)) \
- __tgmres = Fct##f (Val); \
- else \
- __tgmres = __tgml(Fct) (Val); \
- __tgmres; }))
+# define __TGMATH_UNARY_REAL_IMAG_RET_REAL(Val, Fct, Cfct) \
+ (__extension__ ((sizeof (__real__ (Val)) == sizeof (double) \
+ || __builtin_classify_type (__real__ (Val)) != 8) \
+ ? ((sizeof (__real__ (Val)) == sizeof (Val)) \
+ ? (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\
+ Fct (Val) \
+ : (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\
+ Cfct (Val)) \
+ : (sizeof (__real__ (Val)) == sizeof (float)) \
+ ? ((sizeof (__real__ (Val)) == sizeof (Val)) \
+ ? (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\
+ Fct##f (Val) \
+ : (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\
+ Cfct##f (Val)) \
+ : ((sizeof (__real__ (Val)) == sizeof (Val)) \
+ ? (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\
+ __tgml(Fct) (Val) \
+ : (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\
+ __tgml(Cfct) (Val))))
/* XXX This definition has to be changed as soon as the compiler understands
the imaginary keyword. */
# define __TGMATH_BINARY_REAL_IMAG(Val1, Val2, Fct, Cfct) \
- (__extension__ ({ __tgmath_real_type ((Val1) + (Val2)) __tgmres; \
- if ((sizeof (__real__ (Val1)) > sizeof (double) \
- || sizeof (__real__ (Val2)) > sizeof (double)) \
- && __builtin_classify_type (__real__ (Val1) \
- + __real__ (Val2)) \
- == 8) \
- { \
- if (sizeof (__real__ (Val1)) == sizeof (Val1) \
- && sizeof (__real__ (Val2)) == sizeof (Val2)) \
- __tgmres = __tgml(Fct) (Val1, Val2); \
- else \
- __tgmres = __tgml(Cfct) (Val1, Val2); \
- } \
- else if (sizeof (__real__ (Val1)) == sizeof (double) \
- || sizeof (__real__ (Val2)) == sizeof(double) \
- || (__builtin_classify_type (__real__ (Val1)) \
- != 8) \
- || (__builtin_classify_type (__real__ (Val2)) \
- != 8)) \
- { \
- if (sizeof (__real__ (Val1)) == sizeof (Val1) \
- && sizeof (__real__ (Val2)) == sizeof (Val2)) \
- __tgmres = Fct (Val1, Val2); \
- else \
- __tgmres = Cfct (Val1, Val2); \
- } \
- else \
- { \
- if (sizeof (__real__ (Val1)) == sizeof (Val1) \
- && sizeof (__real__ (Val2)) == sizeof (Val2)) \
- __tgmres = Fct##f (Val1, Val2); \
- else \
- __tgmres = Cfct##f (Val1, Val2); \
- } \
- __tgmres; }))
+ (__extension__ (((sizeof (__real__ (Val1)) > sizeof (double) \
+ || sizeof (__real__ (Val2)) > sizeof (double)) \
+ && __builtin_classify_type (__real__ (Val1) \
+ + __real__ (Val2)) == 8) \
+ ? ((sizeof (__real__ (Val1)) == sizeof (Val1) \
+ && sizeof (__real__ (Val2)) == sizeof (Val2)) \
+ ? (__typeof ((__tgmath_real_type (Val1)) 0 \
+ + (__tgmath_real_type (Val2)) 0)) \
+ __tgml(Fct) (Val1, Val2) \
+ : (__typeof ((__tgmath_real_type (Val1)) 0 \
+ + (__tgmath_real_type (Val2)) 0)) \
+ __tgml(Cfct) (Val1, Val2)) \
+ : (sizeof (__real__ (Val1)) == sizeof (double) \
+ || sizeof (__real__ (Val2)) == sizeof (double) \
+ || __builtin_classify_type (__real__ (Val1)) != 8 \
+ || __builtin_classify_type (__real__ (Val2)) != 8) \
+ ? ((sizeof (__real__ (Val1)) == sizeof (Val1) \
+ && sizeof (__real__ (Val2)) == sizeof (Val2)) \
+ ? (__typeof ((__tgmath_real_type (Val1)) 0 \
+ + (__tgmath_real_type (Val2)) 0)) \
+ Fct (Val1, Val2) \
+ : (__typeof ((__tgmath_real_type (Val1)) 0 \
+ + (__tgmath_real_type (Val2)) 0)) \
+ Cfct (Val1, Val2)) \
+ : ((sizeof (__real__ (Val1)) == sizeof (Val1) \
+ && sizeof (__real__ (Val2)) == sizeof (Val2)) \
+ ? (__typeof ((__tgmath_real_type (Val1)) 0 \
+ + (__tgmath_real_type (Val2)) 0)) \
+ Fct##f (Val1, Val2) \
+ : (__typeof ((__tgmath_real_type (Val1)) 0 \
+ + (__tgmath_real_type (Val2)) 0)) \
+ Cfct##f (Val1, Val2))))
#else
# error "Unsupported compiler; you cannot use <tgmath.h>"
#endif
@@ -317,7 +342,7 @@
#define ceil(Val) __TGMATH_UNARY_REAL_ONLY (Val, ceil)
/* Absolute value of X. */
-#define fabs(Val) __TGMATH_UNARY_REAL_IMAG (Val, fabs, cabs)
+#define fabs(Val) __TGMATH_UNARY_REAL_IMAG_RET_REAL (Val, fabs, cabs)
/* Largest integer not greater than X. */
#define floor(Val) __TGMATH_UNARY_REAL_ONLY (Val, floor)
@@ -345,13 +370,13 @@
/* Round X to nearest integral value according to current rounding
direction. */
-#define lrint(Val) __TGMATH_UNARY_REAL_ONLY (Val, lrint)
-#define llrint(Val) __TGMATH_UNARY_REAL_ONLY (Val, llrint)
+#define lrint(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, long int, lrint)
+#define llrint(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, long long int, llrint)
/* Round X to nearest integral value, rounding halfway cases away from
zero. */
-#define lround(Val) __TGMATH_UNARY_REAL_ONLY (Val, lround)
-#define llround(Val) __TGMATH_UNARY_REAL_ONLY (Val, llround)
+#define lround(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, long int, lround)
+#define llround(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, long long int, llround)
/* Return X with its signed changed to Y's. */
@@ -376,6 +401,7 @@
/* Return the remainder of integer divison X / Y with infinite precision. */
#define remainder(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, remainder)
+#ifdef __UCLIBC_SUSV3_LEGACY__
/* Return X times (2 to the Nth power). */
#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
# define scalb(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, scalb)
@@ -387,9 +413,10 @@
/* Return X times (2 to the Nth power). */
#define scalbln(Val1, Val2) \
__TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, scalbln)
+#endif /* __UCLIBC_SUSV3_LEGACY__ */
/* Return the binary exponent of X, which must be nonzero. */
-#define ilogb(Val) __TGMATH_UNARY_REAL_ONLY (Val, ilogb)
+#define ilogb(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, int, ilogb)
/* Return positive difference between X and Y. */
@@ -410,21 +437,21 @@
/* Absolute value, conjugates, and projection. */
/* Argument value of Z. */
-#define carg(Val) __TGMATH_UNARY_IMAG_ONLY (Val, carg)
+#define carg(Val) __TGMATH_UNARY_REAL_IMAG_RET_REAL (Val, carg, carg)
/* Complex conjugate of Z. */
-#define conj(Val) __TGMATH_UNARY_IMAG_ONLY (Val, conj)
+#define conj(Val) __TGMATH_UNARY_IMAG (Val, conj)
/* Projection of Z onto the Riemann sphere. */
-#define cproj(Val) __TGMATH_UNARY_IMAG_ONLY (Val, cproj)
+#define cproj(Val) __TGMATH_UNARY_IMAG (Val, cproj)
/* Decomposing complex values. */
/* Imaginary part of Z. */
-#define cimag(Val) __TGMATH_UNARY_IMAG_ONLY (Val, cimag)
+#define cimag(Val) __TGMATH_UNARY_REAL_IMAG_RET_REAL (Val, cimag, cimag)
/* Real part of Z. */
-#define creal(Val) __TGMATH_UNARY_IMAG_ONLY (Val, creal)
+#define creal(Val) __TGMATH_UNARY_REAL_IMAG_RET_REAL (Val, creal, creal)
#endif /* tgmath.h */
diff --git a/include/time.h b/include/time.h
index f6863ed84..a1dfdea18 100644
--- a/include/time.h
+++ b/include/time.h
@@ -1,5 +1,4 @@
-/* Copyright (C) 1991-1999,2000,2001,2002,2003,2006
- Free Software Foundation, Inc.
+/* Copyright (C) 1991-2003,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/>. */
/*
* ISO C99 Standard: 7.23 Date and time <time.h>
@@ -146,10 +144,10 @@ struct tm
#ifdef __UCLIBC_HAS_TM_EXTENSIONS__
#ifdef __USE_BSD
long int tm_gmtoff; /* Seconds east of UTC. */
- __const char *tm_zone; /* Timezone abbreviation. */
+ const char *tm_zone; /* Timezone abbreviation. */
#else
long int __tm_gmtoff; /* Seconds east of UTC. */
- __const char *__tm_zone; /* Timezone abbreviation. */
+ const char *__tm_zone; /* Timezone abbreviation. */
#endif
#endif /* __UCLIBC_HAS_TM_EXTENSIONS__ */
};
@@ -187,6 +185,7 @@ extern clock_t clock (void) __THROW;
/* Return the current time and put it in *TIMER if TIMER is not NULL. */
extern time_t time (time_t *__timer) __THROW;
+libc_hidden_proto(time)
#ifdef __UCLIBC_HAS_FLOATS__
/* Return the difference between TIME1 and TIME0. */
@@ -194,6 +193,10 @@ extern double difftime (time_t __time1, time_t __time0)
__THROW __attribute__ ((__const__));
#endif /* __UCLIBC_HAS_FLOATS__ */
+#ifdef _LIBC
+# define CLOCK_IDFIELD_SIZE 3
+#endif
+
/* Return the `time_t' representation of TP and normalize TP. */
extern time_t mktime (struct tm *__tp) __THROW;
@@ -202,32 +205,36 @@ extern time_t mktime (struct tm *__tp) __THROW;
Write no more than MAXSIZE characters and return the number
of characters written, or 0 if it would exceed MAXSIZE. */
extern size_t strftime (char *__restrict __s, size_t __maxsize,
- __const char *__restrict __format,
- __const struct tm *__restrict __tp) __THROW;
+ const char *__restrict __format,
+ const struct tm *__restrict __tp) __THROW;
__END_NAMESPACE_STD
# ifdef __USE_XOPEN
/* Parse S according to FORMAT and store binary time information in TP.
The return value is a pointer to the first unparsed character in S. */
-extern char *strptime (__const char *__restrict __s,
- __const char *__restrict __fmt, struct tm *__tp)
+extern char *strptime (const char *__restrict __s,
+ const char *__restrict __fmt, struct tm *__tp)
__THROW;
# endif
#ifdef __UCLIBC_HAS_XLOCALE__
-# ifdef __USE_GNU
+# ifdef __USE_XOPEN2K8
/* Similar to the two functions above but take the information from
the provided locale and not the global locale. */
# include <xlocale.h>
extern size_t strftime_l (char *__restrict __s, size_t __maxsize,
- __const char *__restrict __format,
- __const struct tm *__restrict __tp,
+ const char *__restrict __format,
+ const struct tm *__restrict __tp,
__locale_t __loc) __THROW;
+libc_hidden_proto(strftime_l)
+# endif
-extern char *strptime_l (__const char *__restrict __s,
- __const char *__restrict __fmt, struct tm *__tp,
+# ifdef __USE_GNU
+extern char *strptime_l (const char *__restrict __s,
+ const char *__restrict __fmt, struct tm *__tp,
__locale_t __loc) __THROW;
+libc_hidden_proto(strptime_l)
# endif
#endif
@@ -235,32 +242,36 @@ extern char *strptime_l (__const char *__restrict __s,
__BEGIN_NAMESPACE_STD
/* Return the `struct tm' representation of *TIMER
in Universal Coordinated Time (aka Greenwich Mean Time). */
-extern struct tm *gmtime (__const time_t *__timer) __THROW;
+extern struct tm *gmtime (const time_t *__timer) __THROW;
/* Return the `struct tm' representation
of *TIMER in the local timezone. */
-extern struct tm *localtime (__const time_t *__timer) __THROW;
+extern struct tm *localtime (const time_t *__timer) __THROW;
+libc_hidden_proto(localtime)
__END_NAMESPACE_STD
# if defined __USE_POSIX || defined __USE_MISC
/* Return the `struct tm' representation of *TIMER in UTC,
using *TP to store the result. */
-extern struct tm *gmtime_r (__const time_t *__restrict __timer,
+extern struct tm *gmtime_r (const time_t *__restrict __timer,
struct tm *__restrict __tp) __THROW;
/* Return the `struct tm' representation of *TIMER in local time,
using *TP to store the result. */
-extern struct tm *localtime_r (__const time_t *__restrict __timer,
+extern struct tm *localtime_r (const time_t *__restrict __timer,
struct tm *__restrict __tp) __THROW;
+libc_hidden_proto(localtime_r)
# endif /* POSIX or misc */
__BEGIN_NAMESPACE_STD
/* Return a string of the form "Day Mon dd hh:mm:ss yyyy\n"
that is the representation of TP in this format. */
-extern char *asctime (__const struct tm *__tp) __THROW;
+extern char *asctime (const struct tm *__tp) __THROW;
+libc_hidden_proto(asctime)
/* Equivalent to `asctime (localtime (timer))'. */
-extern char *ctime (__const time_t *__timer) __THROW;
+extern char *ctime (const time_t *__timer) __THROW;
+libc_hidden_proto(ctime)
__END_NAMESPACE_STD
# if defined __USE_POSIX || defined __USE_MISC
@@ -268,11 +279,12 @@ __END_NAMESPACE_STD
/* Return in BUF a string of the form "Day Mon dd hh:mm:ss yyyy\n"
that is the representation of TP in this format. */
-extern char *asctime_r (__const struct tm *__restrict __tp,
+extern char *asctime_r (const struct tm *__restrict __tp,
char *__restrict __buf) __THROW;
+libc_hidden_proto(asctime_r)
/* Equivalent to `asctime_r (localtime_r (timer, *TMP*), buf)'. */
-extern char *ctime_r (__const time_t *__restrict __timer,
+extern char *ctime_r (const time_t *__restrict __timer,
char *__restrict __buf) __THROW;
# endif /* POSIX or misc */
@@ -293,6 +305,7 @@ extern char *tzname[2];
/* Set time conversion information from the TZ environment variable.
If TZ is not defined, a locale-dependent default is used. */
extern void tzset (void) __THROW;
+libc_hidden_proto(tzset)
# endif
# if defined __USE_SVID || defined __USE_XOPEN
@@ -303,7 +316,8 @@ extern long int timezone;
# ifdef __USE_SVID
/* Set the system time to *WHEN.
This call is restricted to the superuser. */
-extern int stime (__const time_t *__when) __THROW;
+extern int stime (const time_t *__when) __THROW;
+libc_hidden_proto(stime)
# endif
@@ -334,8 +348,9 @@ extern int dysize (int __year) __THROW __attribute__ ((__const__));
This function is a cancellation point and therefore not marked with
__THROW. */
-extern int nanosleep (__const struct timespec *__requested_time,
+extern int nanosleep (const struct timespec *__requested_time,
struct timespec *__remaining);
+libc_hidden_proto(nanosleep)
/* Get resolution of clock CLOCK_ID. */
@@ -346,24 +361,24 @@ libc_hidden_proto(clock_getres)
extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp) __THROW;
/* Set clock CLOCK_ID to value TP. */
-extern int clock_settime (clockid_t __clock_id, __const struct timespec *__tp)
+extern int clock_settime (clockid_t __clock_id, const struct timespec *__tp)
__THROW;
-#endif /* __UCLIBC_HAS_REALTIME__ */
-#ifdef __UCLIBC_MJN3_ONLY__
-#warning "mjn3 FIXME: a bunch of unimplemented function prototypes."
+# endif /* __UCLIBC_HAS_REALTIME__ */
+
# if defined __USE_XOPEN2K && defined __UCLIBC_HAS_ADVANCED_REALTIME__
+# ifdef __UCLIBC_HAS_THREADS_NATIVE__
/* High-resolution sleep with the specified clock.
This function is a cancellation point and therefore not marked with
__THROW. */
extern int clock_nanosleep (clockid_t __clock_id, int __flags,
- __const struct timespec *__req,
+ const struct timespec *__req,
struct timespec *__rem);
/* Return clock ID for CPU-time clock. */
extern int clock_getcpuclockid (pid_t __pid, clockid_t *__clock_id) __THROW;
+# endif /* __UCLIBC_HAS_THREADS_NATIVE__ */
# endif
-#endif /* __UCLIBC_MJN3_ONLY__ */
# if defined __UCLIBC_HAS_REALTIME__
/* Create new per-process timer using CLOCK_ID. */
@@ -376,7 +391,7 @@ extern int timer_delete (timer_t __timerid) __THROW;
/* Set timer TIMERID to VALUE, returning old value in OVLAUE. */
extern int timer_settime (timer_t __timerid, int __flags,
- __const struct itimerspec *__restrict __value,
+ const struct itimerspec *__restrict __value,
struct itimerspec *__restrict __ovalue) __THROW;
/* Get current value of timer TIMERID and store it in VLAUE. */
@@ -412,7 +427,7 @@ extern int getdate_err;
This function is a possible cancellation points and therefore not
marked with __THROW. */
-extern struct tm *getdate (__const char *__string);
+extern struct tm *getdate (const char *__string);
# endif
# ifdef __USE_GNU
@@ -426,20 +441,13 @@ extern struct tm *getdate (__const char *__string);
cancellation point. But due to similarity with an POSIX interface
or due to the implementation it is a cancellation point and
therefore not marked with __THROW. */
-extern int getdate_r (__const char *__restrict __string,
+extern int getdate_r (const char *__restrict __string,
struct tm *__restrict __resbufp);
# endif
#endif /* __UCLIBC_MJN3_ONLY__ */
__END_DECLS
-
-#ifdef UCLIBC_INTERNAL
-/* Experiment. Grep for 'libc_hidden_proto(time)' if need to revert */
-libc_hidden_proto(time)
-#endif
-
-
#endif /* <time.h> included. */
#endif /* <time.h> not already included. */
diff --git a/include/tls.h b/include/tls.h
new file mode 100644
index 000000000..f88af405b
--- /dev/null
+++ b/include/tls.h
@@ -0,0 +1,19 @@
+/* This file defines USE___THREAD to 1 or 0 to cut down on the #if mess. */
+
+#ifndef _include_tls_h
+#define _include_tls_h 1
+
+#include_next <tls.h>
+
+#if defined USE_TLS && USE_TLS && HAVE___THREAD \
+ && (!defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt)
+
+# define USE___THREAD 1
+
+#else
+
+# define USE___THREAD 0
+
+#endif
+
+#endif
diff --git a/include/ttyent.h b/include/ttyent.h
index 0b221bccf..63df44921 100644
--- a/include/ttyent.h
+++ b/include/ttyent.h
@@ -48,7 +48,7 @@ struct ttyent {
#define TTY_ON 0x01 /* enable logins (start ty_getty program) */
#define TTY_SECURE 0x02 /* allow uid of 0 to login */
int ty_status; /* status flags */
- char *ty_window; /* command to start up window manager */
+ char *ty_window; /* command to start up window manager */
char *ty_comment; /* comment field */
};
@@ -56,9 +56,12 @@ struct ttyent {
__BEGIN_DECLS
extern struct ttyent *getttyent (void) __THROW;
-extern struct ttyent *getttynam (__const char *__tty) __THROW;
+libc_hidden_proto(getttyent)
+extern struct ttyent *getttynam (const char *__tty) __THROW;
extern int setttyent (void) __THROW;
+libc_hidden_proto(setttyent)
extern int endttyent (void) __THROW;
+libc_hidden_proto(endttyent)
__END_DECLS
diff --git a/include/ucontext.h b/include/ucontext.h
index 5bd46454e..4ce114ef1 100644
--- a/include/ucontext.h
+++ b/include/ucontext.h
@@ -12,21 +12,46 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 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 System V ABI user-level context switching support functions
+ are marked obsolescent by SuSv3. */
#ifndef _UCONTEXT_H
#define _UCONTEXT_H 1
#include <features.h>
+#ifdef __UCLIBC_HAS_CONTEXT_FUNCS__
+
/* Get machine dependent definition of data structures. */
#include <sys/ucontext.h>
-/* The System V ABI user-level context switching support functions
- * are marked obsolescent by SuSv3, and are not implemented by
- * uClibc. This header is therefore empty. */
+__BEGIN_DECLS
+
+/* Get user context and store it in variable pointed to by UCP. */
+extern int getcontext (ucontext_t *__ucp) __THROWNL;
+
+/* Set user context from information of variable pointed to by UCP. */
+extern int setcontext (const ucontext_t *__ucp) __THROWNL;
+
+/* Save current context in context variable pointed to by OUCP and set
+ context from variable pointed to by UCP. */
+extern int swapcontext (ucontext_t *__restrict __oucp,
+ const ucontext_t *__restrict __ucp) __THROWNL;
+
+/* Manipulate user context UCP to continue with calling functions FUNC
+ and the ARGC-1 parameters following ARGC when the context is used
+ the next time in `setcontext' or `swapcontext'.
+
+ We cannot say anything about the parameters FUNC takes; `void'
+ is as good as any other choice. */
+extern void makecontext (ucontext_t *__ucp, void (*__func) (void),
+ int __argc, ...) __THROW;
+
+__END_DECLS
+#endif
#endif /* ucontext.h */
diff --git a/include/ulimit.h b/include/ulimit.h
index 93b5f3796..15134ed92 100644
--- a/include/ulimit.h
+++ b/include/ulimit.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 _ULIMIT_H
#define _ULIMIT_H 1
diff --git a/include/unistd.h b/include/unistd.h
index 164f28909..8e4daf687 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2002,2003,2004,2005,2006 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2006, 2007, 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
@@ -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.10 Symbolic Constants <unistd.h>
@@ -30,33 +29,67 @@ __BEGIN_DECLS
/* These may be used to determine what facilities are present at compile time.
Their values can be obtained at run time from `sysconf'. */
+#ifdef __USE_XOPEN2K8
+/* POSIX Standard approved as ISO/IEC 9945-1 as of September 2008. */
+# define _POSIX_VERSION 200809L
+#elif defined __USE_XOPEN2K
/* POSIX Standard approved as ISO/IEC 9945-1 as of December 2001. */
-#define _POSIX_VERSION 200112L
+# define _POSIX_VERSION 200112L
+#elif defined __USE_POSIX199506
+/* POSIX Standard approved as ISO/IEC 9945-1 as of June 1995. */
+# define _POSIX_VERSION 199506L
+#elif defined __USE_POSIX199309
+/* POSIX Standard approved as ISO/IEC 9945-1 as of September 1993. */
+# define _POSIX_VERSION 199309L
+#else
+/* POSIX Standard approved as ISO/IEC 9945-1 as of September 1990. */
+# define _POSIX_VERSION 199009L
+#endif
/* These are not #ifdef __USE_POSIX2 because they are
in the theoretically application-owned namespace. */
+#ifdef __USE_XOPEN2K8
+# define __POSIX2_THIS_VERSION 200809L
+/* The utilities on GNU systems also correspond to this version. */
+#elif defined __USE_XOPEN2K
+/* The utilities on GNU systems also correspond to this version. */
+# define __POSIX2_THIS_VERSION 200112L
+#elif defined __USE_POSIX199506
+/* The utilities on GNU systems also correspond to this version. */
+# define __POSIX2_THIS_VERSION 199506L
+#else
+/* The utilities on GNU systems also correspond to this version. */
+# define __POSIX2_THIS_VERSION 199209L
+#endif
+
/* The utilities on GNU systems also correspond to this version. */
-#define _POSIX2_VERSION 200112L
+#define _POSIX2_VERSION __POSIX2_THIS_VERSION
/* If defined, the implementation supports the
C Language Bindings Option. */
-#define _POSIX2_C_BIND 200112L
+#define _POSIX2_C_BIND __POSIX2_THIS_VERSION
/* If defined, the implementation supports the
C Language Development Utilities Option. */
-#define _POSIX2_C_DEV 200112L
+#define _POSIX2_C_DEV __POSIX2_THIS_VERSION
/* If defined, the implementation supports the
Software Development Utilities Option. */
-#define _POSIX2_SW_DEV 200112L
+#define _POSIX2_SW_DEV __POSIX2_THIS_VERSION
+#if 0 /* uClibc does not provide the utility */
/* If defined, the implementation supports the
creation of locales with the localedef utility. */
-#define _POSIX2_LOCALEDEF 200112L
+#define _POSIX2_LOCALEDEF __POSIX2_THIS_VERSION
+#endif
/* X/Open version number to which the library conforms. It is selectable. */
-#ifdef __USE_UNIX98
+#ifdef __USE_XOPEN2K8
+# define _XOPEN_VERSION 700
+#elif defined __USE_XOPEN2K
+# define _XOPEN_VERSION 600
+#elif defined __USE_UNIX98
# define _XOPEN_VERSION 500
#else
# define _XOPEN_VERSION 4
@@ -169,9 +202,11 @@ __BEGIN_DECLS
*/
#include <bits/posix_opt.h>
+/* keep it after posix_opt.h, it overwrites based on uClibc's config options */
+#include <bits/uClibc_posix_opt.h>
/* Get the environment definitions from Unix98. */
-#ifdef __USE_UNIX98
+#if defined __USE_UNIX98 || defined __USE_XOPEN2K
# include <bits/environments.h>
#endif
@@ -231,7 +266,7 @@ typedef __pid_t pid_t;
# endif
#endif /* X/Open */
-#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
+#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K
# ifndef __intptr_t_defined
typedef __intptr_t intptr_t;
# define __intptr_t_defined
@@ -253,16 +288,16 @@ typedef __socklen_t socklen_t;
#define F_OK 0 /* Test for existence. */
/* Test for access to NAME using the real UID and real GID. */
-extern int access (__const char *__name, int __type) __THROW __nonnull ((1));
+extern int access (const char *__name, int __type) __THROW __nonnull ((1));
-#if 0 /*def __USE_GNU*/
+#if defined __UCLIBC_LINUX_SPECIFIC__ && defined __USE_GNU
/* Test for access to NAME using the effective UID and GID
(as normal file operations use). */
-extern int euidaccess (__const char *__name, int __type)
+extern int euidaccess (const char *__name, int __type)
__THROW __nonnull ((1));
/* An alias for `euidaccess', used by some other systems. */
-extern int eaccess (__const char *__name, int __type)
+extern int eaccess (const char *__name, int __type)
__THROW __nonnull ((1));
#endif
@@ -270,8 +305,9 @@ extern int eaccess (__const char *__name, int __type)
/* Test for access to FILE relative to the directory FD is open on.
If AT_EACCESS is set in FLAG, then use effective IDs like `eaccess',
otherwise use real IDs like `access'. */
-extern int faccessat (int __fd, __const char *__file, int __type, int __flag)
+extern int faccessat (int __fd, const char *__file, int __type, int __flag)
__THROW __nonnull ((2)) __wur;
+libc_hidden_proto(faccessat)
#endif /* Use GNU. */
@@ -297,6 +333,10 @@ extern int faccessat (int __fd, __const char *__file, int __type, int __flag)
Return the new file position. */
#ifndef __USE_FILE_OFFSET64
extern __off_t lseek (int __fd, __off_t __offset, int __whence) __THROW;
+# ifdef _LIBC
+extern __typeof(lseek) __lseek_nocancel attribute_hidden;
+libc_hidden_proto(lseek)
+# endif
#else
# ifdef __REDIRECT_NTH
extern __off64_t __REDIRECT_NTH (lseek,
@@ -309,6 +349,10 @@ extern __off64_t __REDIRECT_NTH (lseek,
#ifdef __USE_LARGEFILE64
extern __off64_t lseek64 (int __fd, __off64_t __offset, int __whence)
__THROW;
+# ifdef _LIBC
+extern __typeof(lseek64) __lseek64_nocancel attribute_hidden;
+libc_hidden_proto(lseek64)
+# endif
#endif
/* Close the file descriptor FD.
@@ -316,6 +360,11 @@ extern __off64_t lseek64 (int __fd, __off64_t __offset, int __whence)
This function is a cancellation point and therefore not marked with
__THROW. */
extern int close (int __fd);
+#ifdef _LIBC
+extern __typeof(close) __close_nocancel attribute_hidden;
+extern void __close_nocancel_no_status(int) attribute_hidden;
+libc_hidden_proto(close)
+#endif
/* Read NBYTES into BUF from FD. Return the
number read, -1 for errors or 0 for EOF.
@@ -323,14 +372,22 @@ extern int close (int __fd);
This function is a cancellation point and therefore not marked with
__THROW. */
extern ssize_t read (int __fd, void *__buf, size_t __nbytes) __wur;
+#ifdef _LIBC
+extern __typeof(read) __read_nocancel attribute_hidden;
+libc_hidden_proto(read)
+#endif
/* Write N bytes of BUF to FD. Return the number written, or -1.
This function is a cancellation point and therefore not marked with
__THROW. */
-extern ssize_t write (int __fd, __const void *__buf, size_t __n) __wur;
+extern ssize_t write (int __fd, const void *__buf, size_t __n) __wur;
+#ifdef _LIBC
+extern __typeof(write) __write_nocancel attribute_hidden;
+libc_hidden_proto(write)
+#endif
-#ifdef __USE_UNIX98
+#if defined __USE_UNIX98 || defined __USE_XOPEN2K8
# ifndef __USE_FILE_OFFSET64
/* Read NBYTES into BUF from FD at the given position OFFSET without
changing the file pointer. Return the number read, -1 for errors
@@ -346,14 +403,14 @@ extern ssize_t pread (int __fd, void *__buf, size_t __nbytes,
This function is a cancellation point and therefore not marked with
__THROW. */
-extern ssize_t pwrite (int __fd, __const void *__buf, size_t __n,
+extern ssize_t pwrite (int __fd, const void *__buf, size_t __n,
__off_t __offset) __wur;
# else
# ifdef __REDIRECT
extern ssize_t __REDIRECT (pread, (int __fd, void *__buf, size_t __nbytes,
__off64_t __offset),
pread64) __wur;
-extern ssize_t __REDIRECT (pwrite, (int __fd, __const void *__buf,
+extern ssize_t __REDIRECT (pwrite, (int __fd, const void *__buf,
size_t __nbytes, __off64_t __offset),
pwrite64) __wur;
# else
@@ -370,7 +427,7 @@ extern ssize_t pread64 (int __fd, void *__buf, size_t __nbytes,
__off64_t __offset) __wur;
/* Write N bytes of BUF to FD at the given position OFFSET without
changing the file pointer. Return the number written, or -1. */
-extern ssize_t pwrite64 (int __fd, __const void *__buf, size_t __n,
+extern ssize_t pwrite64 (int __fd, const void *__buf, size_t __n,
__off64_t __offset) __wur;
# endif
#endif
@@ -380,6 +437,14 @@ extern ssize_t pwrite64 (int __fd, __const void *__buf, size_t __n,
bytes written on PIPEDES[1] can be read from PIPEDES[0].
Returns 0 if successful, -1 if not. */
extern int pipe (int __pipedes[2]) __THROW __wur;
+libc_hidden_proto(pipe)
+
+#if defined __UCLIBC_LINUX_SPECIFIC__ && defined __USE_GNU
+/* Same as pipe but apply flags passed in FLAGS to the new file
+ descriptors. */
+extern int pipe2 (int __pipedes[2], int __flags) __THROW __wur;
+libc_hidden_proto(pipe2)
+#endif
/* Schedule an alarm. In SECONDS seconds, the process will get a SIGALRM.
If SECONDS is zero, any currently scheduled alarm will be cancelled.
@@ -389,6 +454,7 @@ extern int pipe (int __pipedes[2]) __THROW __wur;
to 0 and check its value after calling `alarm', and this might tell you.
The signal may come late due to processor scheduling. */
extern unsigned int alarm (unsigned int __seconds) __THROW;
+libc_hidden_proto(alarm)
/* Make the process sleep for SECONDS seconds, or until a signal arrives
and is not ignored. The function returns the number of seconds less
@@ -401,8 +467,11 @@ extern unsigned int alarm (unsigned int __seconds) __THROW;
This function is a cancellation point and therefore not marked with
__THROW. */
extern unsigned int sleep (unsigned int __seconds);
+libc_hidden_proto(sleep)
-#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
+#if (defined __USE_BSD \
+ || (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \
+ ) && defined __UCLIBC_SUSV3_LEGACY__
/* Set an alarm to go off (generating a SIGALRM signal) in VALUE
microseconds. If INTERVAL is nonzero, when the alarm goes off, the
timer is reset to go off every INTERVAL microseconds thereafter.
@@ -428,17 +497,18 @@ extern int pause (void);
/* Change the owner and group of FILE. */
-extern int chown (__const char *__file, __uid_t __owner, __gid_t __group)
+extern int chown (const char *__file, __uid_t __owner, __gid_t __group)
__THROW __nonnull ((1)) __wur;
+libc_hidden_proto(chown)
-#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
+#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
/* Change the owner and group of the file that FD is open on. */
extern int fchown (int __fd, __uid_t __owner, __gid_t __group) __THROW __wur;
/* Change owner and group of FILE, if it is a symbolic
link the ownership of the symbolic link is changed. */
-extern int lchown (__const char *__file, __uid_t __owner, __gid_t __group)
+extern int lchown (const char *__file, __uid_t __owner, __gid_t __group)
__THROW __nonnull ((1)) __wur;
#endif /* Use BSD || X/Open Unix. */
@@ -446,17 +516,20 @@ extern int lchown (__const char *__file, __uid_t __owner, __gid_t __group)
#ifdef __USE_ATFILE
/* Change the owner and group of FILE relative to the directory FD is open
on. */
-extern int fchownat (int __fd, __const char *__file, __uid_t __owner,
+extern int fchownat (int __fd, const char *__file, __uid_t __owner,
__gid_t __group, int __flag)
__THROW __nonnull ((2)) __wur;
+libc_hidden_proto(fchownat)
#endif /* Use GNU. */
/* Change the process's working directory to PATH. */
-extern int chdir (__const char *__path) __THROW __nonnull ((1)) __wur;
+extern int chdir (const char *__path) __THROW __nonnull ((1)) __wur;
+libc_hidden_proto(chdir)
-#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
+#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
/* Change the process's working directory to the one FD is open on. */
extern int fchdir (int __fd) __THROW __wur;
+libc_hidden_proto(fchdir)
#endif
/* Get the pathname of the current working directory,
@@ -467,6 +540,7 @@ extern int fchdir (int __fd) __THROW __wur;
bytes long, unless SIZE == 0, in which case it is as
big as necessary. */
extern char *getcwd (char *__buf, size_t __size) __THROW __wur;
+libc_hidden_proto(getcwd)
#ifdef __USE_GNU
/* Return a malloc'd string containing the current directory name.
@@ -475,7 +549,7 @@ extern char *getcwd (char *__buf, size_t __size) __THROW __wur;
extern char *get_current_dir_name (void) __THROW;
#endif
-#if 0 /*defined __USE_BSD || defined __USE_XOPEN_EXTENDED*/
+#if 0 /*defined __USE_BSD || (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8)*/
/* Put the absolute pathname of the current working directory in BUF.
If successful, return BUF. If not, put an error message in
BUF and return NULL. BUF should be at least PATH_MAX bytes long. */
@@ -489,6 +563,14 @@ extern int dup (int __fd) __THROW __wur;
/* Duplicate FD to FD2, closing FD2 and making it open on the same file. */
extern int dup2 (int __fd, int __fd2) __THROW;
+libc_hidden_proto(dup2)
+
+#ifdef __USE_GNU
+/* Duplicate FD to FD2, closing FD2 and making it open on the same
+ file while setting flags according to FLAGS. */
+extern int dup3 (int __fd, int __fd2, int __flags) __THROW;
+libc_hidden_proto(dup3)
+#endif
/* NULL-terminated array of "NAME=VALUE" environment variables. */
extern char **__environ;
@@ -499,41 +581,56 @@ extern char **environ;
/* Replace the current process, executing PATH with arguments ARGV and
environment ENVP. ARGV and ENVP are terminated by NULL pointers. */
-extern int execve (__const char *__path, char *__const __argv[],
- char *__const __envp[]) __THROW __nonnull ((1));
+extern int execve (const char *__path, char *const __argv[],
+ char *const __envp[]) __THROW __nonnull ((1, 2));
+libc_hidden_proto(execve)
-#if 0 /*def __USE_GNU*/
+#if 0 /*def __USE_XOPEN2K8*/
/* Execute the file FD refers to, overlaying the running program image.
ARGV and ENVP are passed to the new program, as for `execve'. */
-extern int fexecve (int __fd, char *__const __argv[], char *__const __envp[])
- __THROW;
+extern int fexecve (int __fd, char *const __argv[], char *const __envp[])
+ __THROW __nonnull ((2));
#endif
/* Execute PATH with arguments ARGV and environment from `environ'. */
-extern int execv (__const char *__path, char *__const __argv[])
- __THROW __nonnull ((1));
+extern int execv (const char *__path, char *const __argv[])
+ __THROW __nonnull ((1, 2));
+libc_hidden_proto(execv)
/* Execute PATH with all arguments after PATH until a NULL pointer,
and the argument after that for environment. */
-extern int execle (__const char *__path, __const char *__arg, ...)
- __THROW __nonnull ((1));
+extern int execle (const char *__path, const char *__arg, ...)
+ __THROW __nonnull ((1, 2));
+libc_hidden_proto(execle)
/* Execute PATH with all arguments after PATH until
a NULL pointer and environment from `environ'. */
-extern int execl (__const char *__path, __const char *__arg, ...)
- __THROW __nonnull ((1));
+extern int execl (const char *__path, const char *__arg, ...)
+ __THROW __nonnull ((1, 2));
+libc_hidden_proto(execl)
/* Execute FILE, searching in the `PATH' environment variable if it contains
no slashes, with arguments ARGV and environment from `environ'. */
-extern int execvp (__const char *__file, char *__const __argv[])
- __THROW __nonnull ((1));
+extern int execvp (const char *__file, char *const __argv[])
+ __THROW __nonnull ((1, 2));
+libc_hidden_proto(execvp)
/* Execute FILE, searching in the `PATH' environment variable if
it contains no slashes, with all arguments after FILE until a
NULL pointer and environment from `environ'. */
-extern int execlp (__const char *__file, __const char *__arg, ...)
- __THROW __nonnull ((1));
+extern int execlp (const char *__file, const char *__arg, ...)
+ __THROW __nonnull ((1, 2));
+libc_hidden_proto(execlp)
+
+#ifdef __USE_GNU
+/* Execute FILE, searching in the `PATH' environment variable if it contains
+ no slashes, with arguments ARGV and environment from a pointer */
+extern int execvpe (const char *__file, char *const __argv[],
+ char *const __envp[])
+ __THROW __nonnull ((1, 2));
+libc_hidden_proto(execvpe)
+#endif
#if defined __USE_MISC || defined __USE_XOPEN
@@ -544,6 +641,7 @@ extern int nice (int __inc) __THROW __wur;
/* Terminate program execution with the low-order 8 bits of STATUS. */
extern void _exit (int __status) __attribute__ ((__noreturn__));
+libc_hidden_proto(_exit)
/* Get the `_PC_*' symbols for the NAME argument to `pathconf' and `fpathconf';
@@ -552,7 +650,7 @@ extern void _exit (int __status) __attribute__ ((__noreturn__));
#include <bits/confname.h>
/* Get file-specific configuration information about PATH. */
-extern long int pathconf (__const char *__path, int __name)
+extern long int pathconf (const char *__path, int __name)
__THROW __nonnull ((1));
/* Get file-specific configuration about descriptor FD. */
@@ -560,6 +658,7 @@ extern long int fpathconf (int __fd, int __name) __THROW;
/* Get the value of the system variable NAME. */
extern long int sysconf (int __name) __THROW;
+libc_hidden_proto(sysconf)
#ifdef __USE_POSIX2
/* Get the value of the string-valued system variable NAME. */
@@ -569,6 +668,7 @@ extern size_t confstr (int __name, char *__buf, size_t __len) __THROW;
/* Get the process ID of the calling process. */
extern __pid_t getpid (void) __THROW;
+libc_hidden_proto(getpid)
/* Get the process ID of the calling process's parent. */
extern __pid_t getppid (void) __THROW;
@@ -587,7 +687,7 @@ extern __pid_t __REDIRECT_NTH (getpgrp, (__pid_t __pid), __getpgid);
/* Get the process group ID of process PID. */
extern __pid_t __getpgid (__pid_t __pid) __THROW;
-#ifdef __USE_XOPEN_EXTENDED
+#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
extern __pid_t getpgid (__pid_t __pid) __THROW;
#endif
@@ -596,6 +696,7 @@ extern __pid_t getpgid (__pid_t __pid) __THROW;
If PID is zero, the current process's process group ID is set.
If PGID is zero, the process ID of the process is used. */
extern int setpgid (__pid_t __pid, __pid_t __pgid) __THROW;
+libc_hidden_proto(setpgid)
#if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED
/* Both System V and BSD have `setpgrp' functions, but with different
@@ -630,28 +731,35 @@ extern int __REDIRECT_NTH (setpgrp, (__pid_t __pid, __pid_t __pgrp), setpgid);
The process group IDs of the session and the calling process
are set to the process ID of the calling process, which is returned. */
extern __pid_t setsid (void) __THROW;
+libc_hidden_proto(setsid)
-#ifdef __USE_XOPEN_EXTENDED
+#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
/* Return the session ID of the given process. */
extern __pid_t getsid (__pid_t __pid) __THROW;
+libc_hidden_proto(getsid)
#endif
/* Get the real user ID of the calling process. */
extern __uid_t getuid (void) __THROW;
+libc_hidden_proto(getuid)
/* Get the effective user ID of the calling process. */
extern __uid_t geteuid (void) __THROW;
+libc_hidden_proto(geteuid)
/* Get the real group ID of the calling process. */
extern __gid_t getgid (void) __THROW;
+libc_hidden_proto(getgid)
/* Get the effective group ID of the calling process. */
extern __gid_t getegid (void) __THROW;
+libc_hidden_proto(getegid)
/* If SIZE is zero, return the number of supplementary groups
the calling process is in. Otherwise, fill in the group IDs
of its supplementary groups in LIST and return the number written. */
extern int getgroups (int __size, __gid_t __list[]) __THROW __wur;
+libc_hidden_proto(getgroups)
#if 0 /*def __USE_GNU*/
/* Return nonzero iff the calling process is in group GID. */
@@ -662,34 +770,37 @@ extern int group_member (__gid_t __gid) __THROW;
If the calling process is the super-user, set the real
and effective user IDs, and the saved set-user-ID to UID;
if not, the effective user ID is set to UID. */
-extern int setuid (__uid_t __uid) __THROW;
+extern int setuid (__uid_t __uid) __THROW __wur;
#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
/* Set the real user ID of the calling process to RUID,
and the effective user ID of the calling process to EUID. */
-extern int setreuid (__uid_t __ruid, __uid_t __euid) __THROW;
+extern int setreuid (__uid_t __ruid, __uid_t __euid) __THROW __wur;
+libc_hidden_proto(setreuid)
#endif
#if defined __USE_BSD || defined __USE_XOPEN2K
/* Set the effective user ID of the calling process to UID. */
-extern int seteuid (__uid_t __uid) __THROW;
-#endif /* Use BSD. */
+extern int seteuid (__uid_t __uid) __THROW __wur;
+libc_hidden_proto(seteuid)
+#endif
/* Set the group ID of the calling process to GID.
If the calling process is the super-user, set the real
and effective group IDs, and the saved set-group-ID to GID;
if not, the effective group ID is set to GID. */
-extern int setgid (__gid_t __gid) __THROW;
+extern int setgid (__gid_t __gid) __THROW __wur;
#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
/* Set the real group ID of the calling process to RGID,
and the effective group ID of the calling process to EGID. */
-extern int setregid (__gid_t __rgid, __gid_t __egid) __THROW;
+extern int setregid (__gid_t __rgid, __gid_t __egid) __THROW __wur;
+libc_hidden_proto(setregid)
#endif
#if defined __USE_BSD || defined __USE_XOPEN2K
/* Set the effective group ID of the calling process to GID. */
-extern int setegid (__gid_t __gid) __THROW;
+extern int setegid (__gid_t __gid) __THROW __wur;
#endif /* Use BSD. */
#ifdef __USE_GNU
@@ -707,13 +818,15 @@ extern int getresgid (__gid_t *__rgid, __gid_t *__egid, __gid_t *__sgid)
/* Set the real user ID, effective user ID, and saved-set user ID,
of the calling process to RUID, EUID, and SUID, respectively. */
extern int setresuid (__uid_t __ruid, __uid_t __euid, __uid_t __suid)
- __THROW;
+ __THROW __wur;
+libc_hidden_proto(setresuid)
#endif
/* Set the real group ID, effective group ID, and saved-set group ID,
of the calling process to RGID, EGID, and SGID, respectively. */
extern int setresgid (__gid_t __rgid, __gid_t __egid, __gid_t __sgid)
- __THROW;
+ __THROW __wur;
+libc_hidden_proto(setresgid)
#endif
@@ -721,7 +834,13 @@ extern int setresgid (__gid_t __rgid, __gid_t __egid, __gid_t __sgid)
/* Clone the calling process, creating an exact copy.
Return -1 for errors, 0 to the new process,
and the process ID of the new process to the old process. */
-extern __pid_t fork (void) __THROW;
+extern __pid_t fork (void) __THROWNL;
+# ifdef _LIBC
+# ifdef __UCLIBC_HAS_THREADS__
+extern __typeof(fork) __libc_fork;
+# endif
+libc_hidden_proto(fork)
+# endif
#endif
#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
@@ -730,8 +849,13 @@ extern __pid_t fork (void) __THROW;
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. */
extern __pid_t vfork (void) __THROW;
+libc_hidden_proto(vfork)
#endif /* Use BSD. */
+#if 0 /* psm: seems unused , exit-thread.S is not compiled */
+/* Special exit function which only terminates the current thread. */
+extern void __exit_thread (int val) __attribute__ ((__noreturn__));
+#endif
/* Return the pathname of the terminal FD is open on, or NULL on errors.
The returned storage is good only until the next call to this function. */
@@ -741,10 +865,12 @@ extern char *ttyname (int __fd) __THROW;
open on in BUF. Return 0 on success, otherwise an error number. */
extern int ttyname_r (int __fd, char *__buf, size_t __buflen)
__THROW __nonnull ((2)) __wur;
+libc_hidden_proto(ttyname_r)
/* Return 1 if FD is a valid descriptor associated
with a terminal, zero if not. */
extern int isatty (int __fd) __THROW;
+libc_hidden_proto(isatty)
#if 0 /*defined __USE_BSD \
|| (defined __USE_XOPEN_EXTENDED && !defined __USE_UNIX98)*/
@@ -755,56 +881,64 @@ extern int ttyslot (void) __THROW;
/* Make a link to FROM named TO. */
-extern int link (__const char *__from, __const char *__to)
+extern int link (const char *__from, const char *__to)
__THROW __nonnull ((1, 2)) __wur;
#ifdef __USE_ATFILE
/* Like link but relative paths in TO and FROM are interpreted relative
to FROMFD and TOFD respectively. */
-extern int linkat (int __fromfd, __const char *__from, int __tofd,
- __const char *__to, int __flags)
+extern int linkat (int __fromfd, const char *__from, int __tofd,
+ const char *__to, int __flags)
__THROW __nonnull ((2, 4)) __wur;
+libc_hidden_proto(linkat)
#endif
#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K
/* Make a symbolic link to FROM named TO. */
-extern int symlink (__const char *__from, __const char *__to)
+extern int symlink (const char *__from, const char *__to)
__THROW __nonnull ((1, 2)) __wur;
/* Read the contents of the symbolic link PATH into no more than
LEN bytes of BUF. The contents are not null-terminated.
Returns the number of characters read, or -1 for errors. */
-extern ssize_t readlink (__const char *__restrict __path,
+extern ssize_t readlink (const char *__restrict __path,
char *__restrict __buf, size_t __len)
__THROW __nonnull ((1, 2)) __wur;
-#endif /* Use BSD. */
+libc_hidden_proto(readlink)
+#endif /* Use POSIX.1-2001. */
#ifdef __USE_ATFILE
/* Like symlink but a relative path in TO is interpreted relative to TOFD. */
-extern int symlinkat (__const char *__from, int __tofd,
- __const char *__to) __THROW __nonnull ((1, 3)) __wur;
+extern int symlinkat (const char *__from, int __tofd,
+ const char *__to) __THROW __nonnull ((1, 3)) __wur;
+libc_hidden_proto(symlinkat)
/* Like readlink but a relative PATH is interpreted relative to FD. */
-extern ssize_t readlinkat (int __fd, __const char *__restrict __path,
+extern ssize_t readlinkat (int __fd, const char *__restrict __path,
char *__restrict __buf, size_t __len)
__THROW __nonnull ((2, 3)) __wur;
+libc_hidden_proto(readlinkat)
#endif
/* Remove the link NAME. */
-extern int unlink (__const char *__name) __THROW __nonnull ((1));
+extern int unlink (const char *__name) __THROW __nonnull ((1));
+libc_hidden_proto(unlink)
#ifdef __USE_ATFILE
/* Remove the link NAME relative to FD. */
-extern int unlinkat (int __fd, __const char *__name, int __flag)
+extern int unlinkat (int __fd, const char *__name, int __flag)
__THROW __nonnull ((2));
+libc_hidden_proto(unlinkat)
#endif
/* Remove the directory PATH. */
-extern int rmdir (__const char *__path) __THROW __nonnull ((1));
+extern int rmdir (const char *__path) __THROW __nonnull ((1));
+libc_hidden_proto(rmdir)
/* Return the foreground process group ID of FD. */
extern __pid_t tcgetpgrp (int __fd) __THROW;
+libc_hidden_proto(tcgetpgrp)
/* Set the foreground process group ID of FD set PGRP_ID. */
extern int tcsetpgrp (int __fd, __pid_t __pgrp_id) __THROW;
@@ -812,22 +946,23 @@ extern int tcsetpgrp (int __fd, __pid_t __pgrp_id) __THROW;
/* Return the login name of the user.
- This function is a possible cancellation points and therefore not
+ This function is a possible cancellation point and therefore not
marked with __THROW. */
extern char *getlogin (void);
+libc_hidden_proto(getlogin)
#if defined __USE_REENTRANT || defined __USE_POSIX199506
/* Return at most NAME_LEN characters of the login name of the user in NAME.
If it cannot be determined or some other error occurred, return the error
code. Otherwise return 0.
- This function is a possible cancellation points and therefore not
+ This function is a possible cancellation point and therefore not
marked with __THROW. */
extern int getlogin_r (char *__name, size_t __name_len) __nonnull ((1));
#endif
#if 0 /*def __USE_BSD*/
/* Set the login name returned by `getlogin'. */
-extern int setlogin (__const char *__name) __THROW __nonnull ((1));
+extern int setlogin (const char *__name) __THROW __nonnull ((1));
#endif
@@ -841,42 +976,50 @@ extern int setlogin (__const char *__name) __THROW __nonnull ((1));
#endif
-#if defined __USE_BSD || defined __USE_UNIX98
+#if defined __USE_BSD || defined __USE_UNIX98 || defined __USE_XOPEN2K
/* Put the name of the current host in no more than LEN bytes of NAME.
The result is null-terminated if LEN is large enough for the full
name and the terminator. */
extern int gethostname (char *__name, size_t __len) __THROW __nonnull ((1));
+libc_hidden_proto(gethostname)
#endif
#if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_UNIX98)
/* Set the name of the current host to NAME, which is LEN bytes long.
This call is restricted to the super-user. */
-extern int sethostname (__const char *__name, size_t __len)
+extern int sethostname (const char *__name, size_t __len)
__THROW __nonnull ((1)) __wur;
/* Set the current machine's Internet number to ID.
This call is restricted to the super-user. */
extern int sethostid (long int __id) __THROW __wur;
-#if defined __UCLIBC_BSD_SPECIFIC__
+
+#if defined __UCLIBC_BSD_SPECIFIC__ || defined _LIBC
/* Get and set the NIS (aka YP) domain name, if any.
Called just like `gethostname' and `sethostname'.
The NIS domain name is usually the empty string when not using NIS. */
extern int getdomainname (char *__name, size_t __len)
__THROW __nonnull ((1)) __wur;
-extern int setdomainname (__const char *__name, size_t __len)
+libc_hidden_proto(getdomainname)
+#endif
+#if defined __UCLIBC_BSD_SPECIFIC__
+extern int setdomainname (const char *__name, size_t __len)
__THROW __nonnull ((1)) __wur;
#endif
+
+#if defined __UCLIBC_LINUX_SPECIFIC__
/* Revoke access permissions to all processes currently communicating
with the control terminal, and then send a SIGHUP signal to the process
group of the control terminal. */
extern int vhangup (void) __THROW;
+#endif
#if 0
/* Revoke the access of all descriptors currently open on FILE. */
-extern int revoke (__const char *__file) __THROW __nonnull ((1)) __wur;
+extern int revoke (const char *__file) __THROW __nonnull ((1)) __wur;
/* Enable statistical profiling, writing samples of the PC into at most
@@ -893,43 +1036,48 @@ extern int profil (unsigned short int *__sample_buffer, size_t __size,
/* Turn accounting on if NAME is an existing file. The system will then write
a record for each process as it terminates, to this file. If NAME is NULL,
turn accounting off. This call is restricted to the super-user. */
-extern int acct (__const char *__name) __THROW;
+extern int acct (const char *__name) __THROW;
/* Successive calls return the shells listed in `/etc/shells'. */
extern char *getusershell (void) __THROW;
extern void endusershell (void) __THROW; /* Discard cached info. */
+libc_hidden_proto(endusershell)
extern void setusershell (void) __THROW; /* Rewind and re-read the file. */
+libc_hidden_proto(setusershell)
-#ifdef __ARCH_USE_MMU__
/* Put the program in the background, and dissociate from the controlling
terminal. If NOCHDIR is zero, do `chdir ("/")'. If NOCLOSE is zero,
redirects stdin, stdout, and stderr to /dev/null. */
extern int daemon (int __nochdir, int __noclose) __THROW __wur;
-#endif
#endif /* Use BSD || X/Open. */
#if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
/* Make PATH be the root directory (the starting point for absolute paths).
This call is restricted to the super-user. */
-extern int chroot (__const char *__path) __THROW __nonnull ((1)) __wur;
+extern int chroot (const char *__path) __THROW __nonnull ((1)) __wur;
/* Prompt with PROMPT and read a string from the terminal without echoing.
Uses /dev/tty if possible; otherwise stderr and stdin. */
-extern char *getpass (__const char *__prompt) __nonnull ((1));
+extern char *getpass (const char *__prompt) __nonnull ((1));
#endif /* Use BSD || X/Open. */
-#if defined __USE_BSD || defined __USE_XOPEN
+#if defined __USE_BSD || defined __USE_XOPEN || defined __USE_XOPEN2K
/* Make all changes done to FD actually appear on disk.
This function is a cancellation point and therefore not marked with
__THROW. */
extern int fsync (int __fd);
-#endif /* Use BSD || X/Open. */
+#endif /* Use BSD || X/Open || Unix98. */
+#if defined __USE_GNU
+/* Make all changes done to all files on the file system associated
+ * with FD actually appear on disk. */
+extern int syncfs (int __fd) __THROW;
+#endif
#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
@@ -943,29 +1091,33 @@ extern void sync (void) __THROW;
/* Return the number of bytes in a page. This is the system's page size,
which is not necessarily the same as the hardware page size. */
extern int getpagesize (void) __THROW __attribute__ ((__const__));
+libc_hidden_proto(getpagesize)
/* Return the maximum number of file descriptors
the current process could possibly have. */
extern int getdtablesize (void) __THROW;
+libc_hidden_proto(getdtablesize)
/* Truncate FILE to LENGTH bytes. */
# ifndef __USE_FILE_OFFSET64
-extern int truncate (__const char *__file, __off_t __length)
+extern int truncate (const char *__file, __off_t __length)
__THROW __nonnull ((1)) __wur;
+libc_hidden_proto(truncate)
# else
# ifdef __REDIRECT_NTH
extern int __REDIRECT_NTH (truncate,
- (__const char *__file, __off64_t __length),
+ (const char *__file, __off64_t __length),
truncate64) __nonnull ((1)) __wur;
# else
# define truncate truncate64
# endif
# endif
# ifdef __USE_LARGEFILE64
-extern int truncate64 (__const char *__file, __off64_t __length)
+extern int truncate64 (const char *__file, __off64_t __length)
__THROW __nonnull ((1)) __wur;
+libc_hidden_proto(truncate64)
# endif
#endif /* Use BSD || X/Open Unix. */
@@ -975,6 +1127,7 @@ extern int truncate64 (__const char *__file, __off64_t __length)
/* Truncate the file FD is open on to LENGTH bytes. */
# ifndef __USE_FILE_OFFSET64
extern int ftruncate (int __fd, __off_t __length) __THROW __wur;
+libc_hidden_proto(ftruncate)
# else
# ifdef __REDIRECT_NTH
extern int __REDIRECT_NTH (ftruncate, (int __fd, __off64_t __length),
@@ -985,6 +1138,7 @@ extern int __REDIRECT_NTH (ftruncate, (int __fd, __off64_t __length),
# endif
# ifdef __USE_LARGEFILE64
extern int ftruncate64 (int __fd, __off64_t __length) __THROW __wur;
+libc_hidden_proto(ftruncate64)
# endif
#endif /* Use BSD || X/Open Unix || POSIX 2003. */
@@ -995,12 +1149,14 @@ extern int ftruncate64 (int __fd, __off64_t __length) __THROW __wur;
/* Set the end of accessible data space (aka "the break") to ADDR.
Returns zero on success and -1 for errors (with errno set). */
extern int brk (void *__addr) __THROW __wur;
+libc_hidden_proto(brk)
/* Increase or decrease the end of accessible data space by DELTA bytes.
If successful, returns the address the previous end of data space
(i.e. the beginning of the new space, if DELTA > 0);
returns (void *) -1 for errors (with errno set). */
extern void *sbrk (intptr_t __delta) __THROW;
+libc_hidden_proto(sbrk)
#endif
@@ -1019,6 +1175,20 @@ extern long int syscall (long int __sysno, ...) __THROW;
#endif /* Use misc. */
+/* Are we in a secure process environment or are we dealing with setuid
+ * stuff? This value is returned by issetugid().
+ */
+extern int _pe_secure;
+libc_hidden_proto(_pe_secure)
+
+#ifdef __USE_BSD
+/* issetugid() returns 1 if the process environment or memory address space
+ is considered tainted, and returns 0 otherwise. This happens, for example,
+ when a process's privileges are elevated by the setuid or setgid flags on
+ an executable belonging to root.
+*/
+extern int issetugid(void);
+#endif
#if (defined __USE_MISC || defined __USE_XOPEN_EXTENDED) && !defined F_LOCK
/* NOTE: These declarations also appear in <fcntl.h>; be sure to keep both
@@ -1039,6 +1209,7 @@ extern long int syscall (long int __sysno, ...) __THROW;
# ifndef __USE_FILE_OFFSET64
extern int lockf (int __fd, int __cmd, __off_t __len) __wur;
+libc_hidden_proto(lockf)
# else
# ifdef __REDIRECT
extern int __REDIRECT (lockf, (int __fd, int __cmd, __off64_t __len),
@@ -1070,7 +1241,7 @@ extern int lockf64 (int __fd, int __cmd, __off64_t __len) __wur;
&& defined __UCLIBC_HAS_REALTIME__
/* Synchronize at least the data part of a file with the underlying
media. */
-extern int fdatasync (int __fildes) __THROW;
+extern int fdatasync (int __fildes);
#endif /* Use POSIX199309 */
@@ -1079,7 +1250,7 @@ extern int fdatasync (int __fildes) __THROW;
#ifdef __USE_XOPEN
# if defined __UCLIBC_HAS_CRYPT__
/* Encrypt at most 8 characters from KEY using salt to perturb DES. */
-extern char *crypt (__const char *__key, __const char *__salt)
+extern char *crypt (const char *__key, const char *__salt)
__THROW __nonnull ((1, 2));
/* Encrypt data in BLOCK in place if EDFLAG is zero; otherwise decrypt
@@ -1092,33 +1263,34 @@ extern void encrypt (char *__block, int __edflag) __THROW __nonnull ((1));
FROM and copy the result to TO. The value of TO must not be in the
range [FROM - N + 1, FROM - 1]. If N is odd the first byte in FROM
is without partner. */
-extern void swab (__const void *__restrict __from, void *__restrict __to,
+extern void swab (const void *__restrict __from, void *__restrict __to,
ssize_t __n) __THROW __nonnull ((1, 2));
#endif
/* The Single Unix specification demands this prototype to be here.
It is also found in <stdio.h>. */
-#ifdef __USE_XOPEN
+#if defined __USE_XOPEN && !defined __USE_XOPEN2K
/* Return the name of the controlling terminal. */
extern char *ctermid (char *__s) __THROW;
#endif
/* Define some macros helping to catch buffer overflows. */
-#if __USE_FORTIFY_LEVEL > 0 && !defined __cplusplus
+#if __USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline
# include <bits/unistd.h>
#endif
__END_DECLS
-#ifdef UCLIBC_INTERNAL
+#ifdef _LIBC
#ifndef smallint_type /* if arch didn't override it in bits/wordsize.h */
#define smallint_type int
#endif
typedef signed smallint_type smallint;
typedef unsigned smallint_type smalluint;
+extern size_t __pagesize attribute_hidden;
#endif
diff --git a/include/utime.h b/include/utime.h
index dd5d26570..45999ebb1 100644
--- a/include/utime.h
+++ b/include/utime.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: 5.6.6 Set File Access and Modification Times <utime.h>
@@ -43,9 +42,10 @@ struct utimbuf
/* Set the access and modification times of FILE to those given in
*FILE_TIMES. If FILE_TIMES is NULL, set them to the current time. */
-extern int utime (__const char *__file,
- __const struct utimbuf *__file_times)
+extern int utime (const char *__file,
+ const struct utimbuf *__file_times)
__THROW __nonnull ((1));
+libc_hidden_proto(utime)
__END_DECLS
diff --git a/include/utmp.h b/include/utmp.h
index 585aad12d..8ecbb54e7 100644
--- a/include/utmp.h
+++ b/include/utmp.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 _UTMP_H
#define _UTMP_H 1
@@ -37,27 +36,29 @@ __BEGIN_DECLS
+#ifdef __UCLIBC_HAS_LIBUTIL__
/* Make FD be the controlling terminal, stdin, stdout, and stderr;
then close FD. Returns 0 on success, nonzero on error. */
extern int login_tty (int __fd) __THROW;
-
+libutil_hidden_proto(login_tty)
/* Write the given entry into utmp and wtmp. */
-extern void login (__const struct utmp *__entry) __THROW;
+extern void login (const struct utmp *__entry) __THROW;
/* Write the utmp entry to say the user on UT_LINE has logged out. */
-extern int logout (__const char *__ut_line) __THROW;
+extern int logout (const char *__ut_line) __THROW;
/* Append to wtmp an entry for the current time and the given info. */
-extern void logwtmp (__const char *__ut_line, __const char *__ut_name,
- __const char *__ut_host) __THROW;
+extern void logwtmp (const char *__ut_line, const char *__ut_name,
+ const char *__ut_host) __THROW;
+#endif
/* Append entry UTMP to the wtmp-like file WTMP_FILE. */
-extern void updwtmp (__const char *__wtmp_file, __const struct utmp *__utmp)
+extern void updwtmp (const char *__wtmp_file, const struct utmp *__utmp)
__THROW;
/* Change name of the utmp file to be examined. */
-extern int utmpname (__const char *__file) __THROW;
+extern int utmpname (const char *__file) __THROW;
/* Read next entry from a utmp-like file. */
extern struct utmp *getutent (void) __THROW;
@@ -70,24 +71,24 @@ extern void endutent (void) __THROW;
/* Search forward from the current point in the utmp file until the
next entry with a ut_type matching ID->ut_type. */
-extern struct utmp *getutid (__const struct utmp *__id) __THROW;
+extern struct utmp *getutid (const struct utmp *__id) __THROW;
/* Search forward from the current point in the utmp file until the
next entry with a ut_line matching LINE->ut_line. */
-extern struct utmp *getutline (__const struct utmp *__line) __THROW;
+extern struct utmp *getutline (const struct utmp *__line) __THROW;
/* Write out entry pointed to by UTMP_PTR into the utmp file. */
-extern struct utmp *pututline (__const struct utmp *__utmp_ptr) __THROW;
+extern struct utmp *pututline (const struct utmp *__utmp_ptr) __THROW;
#if 0 /* def __USE_MISC */
/* Reentrant versions of the file for handling utmp files. */
extern int getutent_r (struct utmp *__buffer, struct utmp **__result) __THROW;
-extern int getutid_r (__const struct utmp *__id, struct utmp *__buffer,
+extern int getutid_r (const struct utmp *__id, struct utmp *__buffer,
struct utmp **__result) __THROW;
-extern int getutline_r (__const struct utmp *__line,
+extern int getutline_r (const struct utmp *__line,
struct utmp *__buffer, struct utmp **__result) __THROW;
#endif /* Use misc. */
diff --git a/include/utmpx.h b/include/utmpx.h
new file mode 100644
index 000000000..f3481275d
--- /dev/null
+++ b/include/utmpx.h
@@ -0,0 +1,126 @@
+/* Copyright (C) 1997, 1998, 1999, 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 _UTMPX_H
+#define _UTMPX_H 1
+
+#include <features.h>
+#include <sys/time.h>
+
+/* Required according to Unix98. */
+#ifndef __pid_t_defined
+typedef __pid_t pid_t;
+# define __pid_t_defined
+#endif
+
+/* Get system dependent values and data structures. */
+#include <bits/utmpx.h>
+
+#ifdef __USE_GNU
+/* Compatibility names for the strings of the canonical file names. */
+# define UTMPX_FILE _PATH_UTMPX
+# define UTMPX_FILENAME _PATH_UTMPX
+# define WTMPX_FILE _PATH_WTMPX
+# define WTMPX_FILENAME _PATH_WTMPX
+#endif
+
+/* For the getutmp{,x} functions we need the `struct utmp'. */
+#ifdef __USE_GNU
+struct utmp;
+#endif
+
+
+__BEGIN_DECLS
+
+/* Open user accounting database.
+
+ This function is a possible cancellation point and therefore not
+ marked with __THROW. */
+extern void setutxent (void);
+
+/* Close user accounting database.
+
+ This function is a possible cancellation point and therefore not
+ marked with __THROW. */
+extern void endutxent (void);
+
+/* Get the next entry from the user accounting database.
+
+ This function is a possible cancellation point and therefore not
+ marked with __THROW. */
+extern struct utmpx *getutxent (void);
+
+/* Get the user accounting database entry corresponding to ID.
+
+ This function is a possible cancellation point and therefore not
+ marked with __THROW. */
+extern struct utmpx *getutxid (const struct utmpx *__id);
+
+/* Get the user accounting database entry corresponding to LINE.
+
+ This function is a possible cancellation point and therefore not
+ marked with __THROW. */
+extern struct utmpx *getutxline (const struct utmpx *__line);
+
+/* Write the entry UTMPX into the user accounting database.
+
+ This function is a possible cancellation point and therefore not
+ marked with __THROW. */
+extern struct utmpx *pututxline (const struct utmpx *__utmpx);
+
+
+#ifdef __USE_GNU
+/* Change name of the utmpx file to be examined.
+
+ This function is not part of POSIX and therefore no official
+ cancellation point. But due to similarity with an POSIX interface
+ or due to the implementation it is a cancellation point and
+ therefore not marked with __THROW. */
+extern int utmpxname (const char *__file);
+
+/* Append entry UTMP to the wtmpx-like file WTMPX_FILE.
+
+ This function is not part of POSIX and therefore no official
+ cancellation point. But due to similarity with an POSIX interface
+ or due to the implementation it is a cancellation point and
+ therefore not marked with __THROW. */
+extern void updwtmpx (const char *__wtmpx_file,
+ const struct utmpx *__utmpx);
+
+
+/* Copy the information in UTMPX to UTMP.
+
+ This function is not part of POSIX and therefore no official
+ cancellation point. But due to similarity with an POSIX interface
+ or due to the implementation it is a cancellation point and
+ therefore not marked with __THROW. */
+extern void getutmp (const struct utmpx *__utmpx,
+ struct utmp *__utmp);
+
+/* Copy the information in UTMP to UTMPX.
+
+ This function is not part of POSIX and therefore no official
+ cancellation point. But due to similarity with an POSIX interface
+ or due to the implementation it is a cancellation point and
+ therefore not marked with __THROW. */
+extern void getutmpx (const struct utmp *__utmp,
+ struct utmpx *__utmpx);
+#endif
+
+__END_DECLS
+
+#endif /* utmpx.h */
diff --git a/include/values.h b/include/values.h
index d8bd8b50a..e0132e653 100644
--- a/include/values.h
+++ b/include/values.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/>. */
/* This interface is obsolete. New programs should use
<limits.h> and/or <float.h> instead of <values.h>. */
@@ -53,7 +52,9 @@
#include <float.h>
#define MAXDOUBLE DBL_MAX
+#ifdef __UCLIBC_SUSV4_LEGACY__
#define MAXFLOAT FLT_MAX
+#endif
#define MINDOUBLE DBL_MIN
#define MINFLOAT FLT_MIN
#define DMINEXP DBL_MIN_EXP
diff --git a/include/wchar-stub.h b/include/wchar-stub.h
new file mode 100644
index 000000000..918c78dd4
--- /dev/null
+++ b/include/wchar-stub.h
@@ -0,0 +1,13 @@
+/* This wchar.h is used if wchar support is disabled in uClibc.
+ * We still want to provide a few basic definitions as the basic
+ * C standard requires them. And it makes our lives easier with
+ * no additional overhead.
+ */
+
+#ifndef _WCHAR_H
+#define _WCHAR_H
+
+typedef unsigned int wint_t;
+#define WEOF (0xffffffffu)
+
+#endif
diff --git a/include/wchar.h b/include/wchar.h
index e461f7184..67f44b763 100644
--- a/include/wchar.h
+++ b/include/wchar.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 Standard: 7.24
@@ -133,44 +132,46 @@ __BEGIN_NAMESPACE_STD
/* This incomplete type is defined in <time.h> but needed here because
of `wcsftime'. */
struct tm;
+__END_NAMESPACE_STD
/* XXX We have to clean this up at some point. Since tm is in the std
namespace but wcsftime is in __c99 the type wouldn't be found
without inserting it in the global namespace. */
__USING_NAMESPACE_STD(tm)
-__END_NAMESPACE_STD
__BEGIN_NAMESPACE_C99
/* Copy SRC to DEST. */
extern wchar_t *wcscpy (wchar_t *__restrict __dest,
- __const wchar_t *__restrict __src) __THROW;
+ const wchar_t *__restrict __src) __THROW;
/* Copy no more than N wide-characters of SRC to DEST. */
extern wchar_t *wcsncpy (wchar_t *__restrict __dest,
- __const wchar_t *__restrict __src, size_t __n)
+ const wchar_t *__restrict __src, size_t __n)
__THROW;
/* Append SRC onto DEST. */
extern wchar_t *wcscat (wchar_t *__restrict __dest,
- __const wchar_t *__restrict __src) __THROW;
+ const wchar_t *__restrict __src) __THROW;
+libc_hidden_proto(wcscat)
/* Append no more than N wide-characters of SRC onto DEST. */
extern wchar_t *wcsncat (wchar_t *__restrict __dest,
- __const wchar_t *__restrict __src, size_t __n)
+ const wchar_t *__restrict __src, size_t __n)
__THROW;
/* Compare S1 and S2. */
-extern int wcscmp (__const wchar_t *__s1, __const wchar_t *__s2)
+extern int wcscmp (const wchar_t *__s1, const wchar_t *__s2)
__THROW __attribute_pure__;
+libc_hidden_proto(wcscmp)
/* Compare N wide-characters of S1 and S2. */
-extern int wcsncmp (__const wchar_t *__s1, __const wchar_t *__s2, size_t __n)
+extern int wcsncmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n)
__THROW __attribute_pure__;
__END_NAMESPACE_C99
#ifdef __USE_GNU
/* Compare S1 and S2, ignoring case. */
-extern int wcscasecmp (__const wchar_t *__s1, __const wchar_t *__s2) __THROW;
+extern int wcscasecmp (const wchar_t *__s1, const wchar_t *__s2) __THROW;
/* Compare no more than N chars of S1 and S2, ignoring case. */
-extern int wcsncasecmp (__const wchar_t *__s1, __const wchar_t *__s2,
+extern int wcsncasecmp (const wchar_t *__s1, const wchar_t *__s2,
size_t __n) __THROW;
#ifdef __UCLIBC_HAS_XLOCALE__
@@ -178,23 +179,26 @@ extern int wcsncasecmp (__const wchar_t *__s1, __const wchar_t *__s2,
the provided locale and not the global locale. */
# include <xlocale.h>
-extern int wcscasecmp_l (__const wchar_t *__s1, __const wchar_t *__s2,
+extern int wcscasecmp_l (const wchar_t *__s1, const wchar_t *__s2,
__locale_t __loc) __THROW;
+libc_hidden_proto(wcscasecmp_l)
-extern int wcsncasecmp_l (__const wchar_t *__s1, __const wchar_t *__s2,
+extern int wcsncasecmp_l (const wchar_t *__s1, const wchar_t *__s2,
size_t __n, __locale_t __loc) __THROW;
+libc_hidden_proto(wcsncasecmp_l)
#endif /* __UCLIBC_HAS_XLOCALE__ */
#endif
__BEGIN_NAMESPACE_C99
/* Compare S1 and S2, both interpreted as appropriate to the
LC_COLLATE category of the current locale. */
-extern int wcscoll (__const wchar_t *__s1, __const wchar_t *__s2) __THROW;
+extern int wcscoll (const wchar_t *__s1, const wchar_t *__s2) __THROW;
+libc_hidden_proto(wcscoll)
/* Transform S2 into array pointed to by S1 such that if wcscmp is
applied to two transformed strings the result is the as applying
`wcscoll' to the original strings. */
extern size_t wcsxfrm (wchar_t *__restrict __s1,
- __const wchar_t *__restrict __s2, size_t __n) __THROW;
+ const wchar_t *__restrict __s2, size_t __n) __THROW;
__END_NAMESPACE_C99
#ifdef __USE_GNU
@@ -204,92 +208,104 @@ __END_NAMESPACE_C99
/* Compare S1 and S2, both interpreted as appropriate to the
LC_COLLATE category of the given locale. */
-extern int wcscoll_l (__const wchar_t *__s1, __const wchar_t *__s2,
+extern int wcscoll_l (const wchar_t *__s1, const wchar_t *__s2,
__locale_t __loc) __THROW;
+libc_hidden_proto(wcscoll_l)
/* Transform S2 into array pointed to by S1 such that if wcscmp is
applied to two transformed strings the result is the as applying
`wcscoll' to the original strings. */
-extern size_t wcsxfrm_l (wchar_t *__s1, __const wchar_t *__s2,
+extern size_t wcsxfrm_l (wchar_t *__s1, const wchar_t *__s2,
size_t __n, __locale_t __loc) __THROW;
+libc_hidden_proto(wcsxfrm_l)
#endif /* __UCLIBC_HAS_XLOCALE__ */
/* Duplicate S, returning an identical malloc'd string. */
-extern wchar_t *wcsdup (__const wchar_t *__s) __THROW __attribute_malloc__;
+extern wchar_t *wcsdup (const wchar_t *__s) __THROW __attribute_malloc__;
#endif
__BEGIN_NAMESPACE_C99
/* Find the first occurrence of WC in WCS. */
-extern wchar_t *wcschr (__const wchar_t *__wcs, wchar_t __wc)
+extern wchar_t *wcschr (const wchar_t *__wcs, wchar_t __wc)
__THROW __attribute_pure__;
/* Find the last occurrence of WC in WCS. */
-extern wchar_t *wcsrchr (__const wchar_t *__wcs, wchar_t __wc)
+extern wchar_t *wcsrchr (const wchar_t *__wcs, wchar_t __wc)
__THROW __attribute_pure__;
__END_NAMESPACE_C99
#ifdef __USE_GNU
/* This function is similar to `wcschr'. But it returns a pointer to
the closing NUL wide character in case C is not found in S. */
-extern wchar_t *wcschrnul (__const wchar_t *__s, wchar_t __wc)
+extern wchar_t *wcschrnul (const wchar_t *__s, wchar_t __wc)
__THROW __attribute_pure__;
#endif
__BEGIN_NAMESPACE_C99
/* Return the length of the initial segmet of WCS which
consists entirely of wide characters not in REJECT. */
-extern size_t wcscspn (__const wchar_t *__wcs, __const wchar_t *__reject)
+extern size_t wcscspn (const wchar_t *__wcs, const wchar_t *__reject)
__THROW __attribute_pure__;
/* Return the length of the initial segmet of WCS which
consists entirely of wide characters in ACCEPT. */
-extern size_t wcsspn (__const wchar_t *__wcs, __const wchar_t *__accept)
+extern size_t wcsspn (const wchar_t *__wcs, const wchar_t *__accept)
__THROW __attribute_pure__;
+libc_hidden_proto(wcsspn)
/* Find the first occurrence in WCS of any character in ACCEPT. */
-extern wchar_t *wcspbrk (__const wchar_t *__wcs, __const wchar_t *__accept)
+extern wchar_t *wcspbrk (const wchar_t *__wcs, const wchar_t *__accept)
__THROW __attribute_pure__;
+libc_hidden_proto(wcspbrk)
/* Find the first occurrence of NEEDLE in HAYSTACK. */
-extern wchar_t *wcsstr (__const wchar_t *__haystack, __const wchar_t *__needle)
+/* SuSv uses restrict keyword, glibc does not */
+extern wchar_t *wcsstr (const wchar_t *__restrict __haystack, const wchar_t *__restrict __needle)
__THROW __attribute_pure__;
/* Divide WCS into tokens separated by characters in DELIM. */
extern wchar_t *wcstok (wchar_t *__restrict __s,
- __const wchar_t *__restrict __delim,
+ const wchar_t *__restrict __delim,
wchar_t **__restrict __ptr) __THROW;
/* Return the number of wide characters in S. */
-extern size_t wcslen (__const wchar_t *__s) __THROW __attribute_pure__;
+extern size_t wcslen (const wchar_t *__s) __THROW __attribute_pure__;
+libc_hidden_proto(wcslen)
__END_NAMESPACE_C99
-#ifdef __USE_XOPEN
+#if defined __USE_XOPEN && defined __UCLIBC_SUSV3_LEGACY__
/* Another name for `wcsstr' from XPG4. */
-extern wchar_t *wcswcs (__const wchar_t *__haystack, __const wchar_t *__needle)
+/* SuSv3 did not use restrict keyword, probably because it was marked LEGACY
+ we do to be in sync with wcsstr */
+extern wchar_t *wcswcs (const wchar_t *__restrict __haystack, const wchar_t *__restrict __needle)
__THROW __attribute_pure__;
#endif
#ifdef __USE_GNU
/* Return the number of wide characters in S, but at most MAXLEN. */
-extern size_t wcsnlen (__const wchar_t *__s, size_t __maxlen)
+extern size_t wcsnlen (const wchar_t *__s, size_t __maxlen)
__THROW __attribute_pure__;
+libc_hidden_proto(wcsnlen)
#endif
__BEGIN_NAMESPACE_C99
/* Search N wide characters of S for C. */
-extern wchar_t *wmemchr (__const wchar_t *__s, wchar_t __c, size_t __n)
+extern wchar_t *wmemchr (const wchar_t *__s, wchar_t __c, size_t __n)
__THROW __attribute_pure__;
+libc_hidden_proto(wmemchr)
/* Compare N wide characters of S1 and S2. */
-extern int wmemcmp (__const wchar_t *__restrict __s1,
- __const wchar_t *__restrict __s2, size_t __n)
+/* SuSv4 does not use restrict keyword for S1 and S2, glibc does */
+extern int wmemcmp (const wchar_t *__s1,
+ const wchar_t *__s2, size_t __n)
__THROW __attribute_pure__;
/* Copy N wide characters of SRC to DEST. */
extern wchar_t *wmemcpy (wchar_t *__restrict __s1,
- __const wchar_t *__restrict __s2, size_t __n) __THROW;
+ const wchar_t *__restrict __s2, size_t __n) __THROW;
+libc_hidden_proto(wmemcpy)
/* Copy N wide characters of SRC to DEST, guaranteeing
correct behavior for overlapping strings. */
-extern wchar_t *wmemmove (wchar_t *__s1, __const wchar_t *__s2, size_t __n)
+extern wchar_t *wmemmove (wchar_t *__s1, const wchar_t *__s2, size_t __n)
__THROW;
/* Set N wide characters of S to C. */
@@ -300,8 +316,9 @@ __END_NAMESPACE_C99
/* Copy N wide characters of SRC to DEST and return pointer to following
wide character. */
extern wchar_t *wmempcpy (wchar_t *__restrict __s1,
- __const wchar_t *__restrict __s2, size_t __n)
+ const wchar_t *__restrict __s2, size_t __n)
__THROW;
+libc_hidden_proto(wmempcpy)
#endif
@@ -309,6 +326,7 @@ __BEGIN_NAMESPACE_C99
/* Determine whether C constitutes a valid (one-byte) multibyte
character. */
extern wint_t btowc (int __c) __THROW;
+libc_hidden_proto(btowc)
/* Determine whether C corresponds to a member of the extended
character set whose multibyte representation is a single byte. */
@@ -316,37 +334,43 @@ extern int wctob (wint_t __c) __THROW;
/* Determine whether PS points to an object representing the initial
state. */
-extern int mbsinit (__const mbstate_t *__ps) __THROW __attribute_pure__;
+extern int mbsinit (const mbstate_t *__ps) __THROW __attribute_pure__;
+libc_hidden_proto(mbsinit)
/* Write wide character representation of multibyte character pointed
to by S to PWC. */
extern size_t mbrtowc (wchar_t *__restrict __pwc,
- __const char *__restrict __s, size_t __n,
+ const char *__restrict __s, size_t __n,
mbstate_t *__p) __THROW;
+libc_hidden_proto(mbrtowc)
/* Write multibyte representation of wide character WC to S. */
extern size_t wcrtomb (char *__restrict __s, wchar_t __wc,
mbstate_t *__restrict __ps) __THROW;
+libc_hidden_proto(wcrtomb)
/* Return number of bytes in multibyte character pointed to by S. */
#if 0 /* uClibc: disabled */
-extern size_t __mbrlen (__const char *__restrict __s, size_t __n,
+extern size_t __mbrlen (const char *__restrict __s, size_t __n,
mbstate_t *__restrict __ps) __THROW;
#endif
-extern size_t mbrlen (__const char *__restrict __s, size_t __n,
+extern size_t mbrlen (const char *__restrict __s, size_t __n,
mbstate_t *__restrict __ps) __THROW;
+libc_hidden_proto(mbrlen)
/* Write wide character representation of multibyte character string
SRC to DST. */
extern size_t mbsrtowcs (wchar_t *__restrict __dst,
- __const char **__restrict __src, size_t __len,
+ const char **__restrict __src, size_t __len,
mbstate_t *__restrict __ps) __THROW;
+libc_hidden_proto(mbsrtowcs)
/* Write multibyte character representation of wide character string
SRC to DST. */
extern size_t wcsrtombs (char *__restrict __dst,
- __const wchar_t **__restrict __src, size_t __len,
+ const wchar_t **__restrict __src, size_t __len,
mbstate_t *__restrict __ps) __THROW;
+libc_hidden_proto(wcsrtombs)
__END_NAMESPACE_C99
@@ -354,15 +378,17 @@ __END_NAMESPACE_C99
/* Write wide character representation of at most NMC bytes of the
multibyte character string SRC to DST. */
extern size_t mbsnrtowcs (wchar_t *__restrict __dst,
- __const char **__restrict __src, size_t __nmc,
+ const char **__restrict __src, size_t __nmc,
size_t __len, mbstate_t *__restrict __ps) __THROW;
+libc_hidden_proto(mbsnrtowcs)
/* Write multibyte character representation of at most NWC characters
from the wide character string SRC to DST. */
extern size_t wcsnrtombs (char *__restrict __dst,
- __const wchar_t **__restrict __src,
+ const wchar_t **__restrict __src,
size_t __nwc, size_t __len,
mbstate_t *__restrict __ps) __THROW;
+libc_hidden_proto(wcsnrtombs)
#endif /* use GNU */
@@ -373,7 +399,8 @@ extern int wcwidth (wchar_t __c) __THROW;
/* Determine number of column positions required for first N wide
characters (or fewer if S ends before this) in S. */
-extern int wcswidth (__const wchar_t *__s, size_t __n) __THROW;
+extern int wcswidth (const wchar_t *__s, size_t __n) __THROW;
+libc_hidden_proto(wcswidth)
#endif /* Use X/Open. */
@@ -381,14 +408,14 @@ __BEGIN_NAMESPACE_C99
#ifdef __UCLIBC_HAS_FLOATS__
/* Convert initial portion of the wide string NPTR to `double'
representation. */
-extern double wcstod (__const wchar_t *__restrict __nptr,
+extern double wcstod (const wchar_t *__restrict __nptr,
wchar_t **__restrict __endptr) __THROW;
#ifdef __USE_ISOC99
/* Likewise for `float' and `long double' sizes of floating-point numbers. */
-extern float wcstof (__const wchar_t *__restrict __nptr,
+extern float wcstof (const wchar_t *__restrict __nptr,
wchar_t **__restrict __endptr) __THROW;
-extern long double wcstold (__const wchar_t *__restrict __nptr,
+extern long double wcstold (const wchar_t *__restrict __nptr,
wchar_t **__restrict __endptr) __THROW;
#endif /* C99 */
#endif /* __UCLIBC_HAS_FLOATS__ */
@@ -396,44 +423,44 @@ extern long double wcstold (__const wchar_t *__restrict __nptr,
/* Convert initial portion of wide string NPTR to `long int'
representation. */
-extern long int wcstol (__const wchar_t *__restrict __nptr,
+extern long int wcstol (const wchar_t *__restrict __nptr,
wchar_t **__restrict __endptr, int __base) __THROW;
/* Convert initial portion of wide string NPTR to `unsigned long int'
representation. */
-extern unsigned long int wcstoul (__const wchar_t *__restrict __nptr,
+extern unsigned long int wcstoul (const wchar_t *__restrict __nptr,
wchar_t **__restrict __endptr, int __base)
__THROW;
#if defined __USE_ISOC99 || (defined __GNUC__ && defined __USE_GNU)
-/* Convert initial portion of wide string NPTR to `long int'
+/* Convert initial portion of wide string NPTR to `long long int'
representation. */
__extension__
-extern long long int wcstoll (__const wchar_t *__restrict __nptr,
+extern long long int wcstoll (const wchar_t *__restrict __nptr,
wchar_t **__restrict __endptr, int __base)
__THROW;
/* Convert initial portion of wide string NPTR to `unsigned long long int'
representation. */
__extension__
-extern unsigned long long int wcstoull (__const wchar_t *__restrict __nptr,
+extern unsigned long long int wcstoull (const wchar_t *__restrict __nptr,
wchar_t **__restrict __endptr,
int __base) __THROW;
#endif /* ISO C99 or GCC and GNU. */
__END_NAMESPACE_C99
#if defined __GNUC__ && defined __USE_GNU
-/* Convert initial portion of wide string NPTR to `long int'
+/* Convert initial portion of wide string NPTR to `long long int'
representation. */
__extension__
-extern long long int wcstoq (__const wchar_t *__restrict __nptr,
+extern long long int wcstoq (const wchar_t *__restrict __nptr,
wchar_t **__restrict __endptr, int __base)
__THROW;
/* Convert initial portion of wide string NPTR to `unsigned long long int'
representation. */
__extension__
-extern unsigned long long int wcstouq (__const wchar_t *__restrict __nptr,
+extern unsigned long long int wcstouq (const wchar_t *__restrict __nptr,
wchar_t **__restrict __endptr,
int __base) __THROW;
#endif /* GCC and use GNU. */
@@ -457,35 +484,35 @@ extern unsigned long long int wcstouq (__const wchar_t *__restrict __nptr,
/* Special versions of the functions above which take the locale to
use as an additional parameter. */
-extern long int wcstol_l (__const wchar_t *__restrict __nptr,
+extern long int wcstol_l (const wchar_t *__restrict __nptr,
wchar_t **__restrict __endptr, int __base,
__locale_t __loc) __THROW;
-extern unsigned long int wcstoul_l (__const wchar_t *__restrict __nptr,
+extern unsigned long int wcstoul_l (const wchar_t *__restrict __nptr,
wchar_t **__restrict __endptr,
int __base, __locale_t __loc) __THROW;
__extension__
-extern long long int wcstoll_l (__const wchar_t *__restrict __nptr,
+extern long long int wcstoll_l (const wchar_t *__restrict __nptr,
wchar_t **__restrict __endptr,
int __base, __locale_t __loc) __THROW;
__extension__
-extern unsigned long long int wcstoull_l (__const wchar_t *__restrict __nptr,
+extern unsigned long long int wcstoull_l (const wchar_t *__restrict __nptr,
wchar_t **__restrict __endptr,
int __base, __locale_t __loc)
__THROW;
#ifdef __UCLIBC_HAS_FLOATS__
-extern double wcstod_l (__const wchar_t *__restrict __nptr,
+extern double wcstod_l (const wchar_t *__restrict __nptr,
wchar_t **__restrict __endptr, __locale_t __loc)
__THROW;
-extern float wcstof_l (__const wchar_t *__restrict __nptr,
+extern float wcstof_l (const wchar_t *__restrict __nptr,
wchar_t **__restrict __endptr, __locale_t __loc)
__THROW;
-extern long double wcstold_l (__const wchar_t *__restrict __nptr,
+extern long double wcstold_l (const wchar_t *__restrict __nptr,
wchar_t **__restrict __endptr,
__locale_t __loc) __THROW;
#endif /* __UCLIBC_HAS_FLOATS__ */
@@ -496,11 +523,11 @@ extern long double wcstold_l (__const wchar_t *__restrict __nptr,
#ifdef __USE_GNU
/* Copy SRC to DEST, returning the address of the terminating L'\0' in
DEST. */
-extern wchar_t *wcpcpy (wchar_t *__dest, __const wchar_t *__src) __THROW;
+extern wchar_t *wcpcpy (wchar_t *__dest, const wchar_t *__src) __THROW;
/* Copy no more than N characters of SRC to DEST, returning the address of
the last character written into DEST. */
-extern wchar_t *wcpncpy (wchar_t *__dest, __const wchar_t *__src, size_t __n)
+extern wchar_t *wcpncpy (wchar_t *__dest, const wchar_t *__src, size_t __n)
__THROW;
#endif /* use GNU */
@@ -518,17 +545,17 @@ extern int fwide (__FILE *__fp, int __mode) __THROW;
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern int fwprintf (__FILE *__restrict __stream,
- __const wchar_t *__restrict __format, ...)
+ const wchar_t *__restrict __format, ...)
/* __attribute__ ((__format__ (__wprintf__, 2, 3))) */;
/* Write formatted output to stdout.
This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern int wprintf (__const wchar_t *__restrict __format, ...)
+extern int wprintf (const wchar_t *__restrict __format, ...)
/* __attribute__ ((__format__ (__wprintf__, 1, 2))) */;
/* Write formatted output of at most N characters to S. */
extern int swprintf (wchar_t *__restrict __s, size_t __n,
- __const wchar_t *__restrict __format, ...)
+ const wchar_t *__restrict __format, ...)
__THROW /* __attribute__ ((__format__ (__wprintf__, 3, 4))) */;
/* Write formatted output to S from argument list ARG.
@@ -536,22 +563,24 @@ extern int swprintf (wchar_t *__restrict __s, size_t __n,
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern int vfwprintf (__FILE *__restrict __s,
- __const wchar_t *__restrict __format,
+ const wchar_t *__restrict __format,
__gnuc_va_list __arg)
/* __attribute__ ((__format__ (__wprintf__, 2, 0))) */;
+libc_hidden_proto(vfwprintf)
/* Write formatted output to stdout from argument list ARG.
This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern int vwprintf (__const wchar_t *__restrict __format,
+extern int vwprintf (const wchar_t *__restrict __format,
__gnuc_va_list __arg)
/* __attribute__ ((__format__ (__wprintf__, 1, 0))) */;
/* Write formatted output of at most N character to S from argument
list ARG. */
extern int vswprintf (wchar_t *__restrict __s, size_t __n,
- __const wchar_t *__restrict __format,
+ const wchar_t *__restrict __format,
__gnuc_va_list __arg)
__THROW /* __attribute__ ((__format__ (__wprintf__, 3, 0))) */;
+libc_hidden_proto(vswprintf)
/* Read formatted input from STREAM.
@@ -559,17 +588,17 @@ extern int vswprintf (wchar_t *__restrict __s, size_t __n,
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern int fwscanf (__FILE *__restrict __stream,
- __const wchar_t *__restrict __format, ...)
+ const wchar_t *__restrict __format, ...)
/* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
/* Read formatted input from stdin.
This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern int wscanf (__const wchar_t *__restrict __format, ...)
+extern int wscanf (const wchar_t *__restrict __format, ...)
/* __attribute__ ((__format__ (__wscanf__, 1, 2))) */;
/* Read formatted input from S. */
-extern int swscanf (__const wchar_t *__restrict __s,
- __const wchar_t *__restrict __format, ...)
+extern int swscanf (const wchar_t *__restrict __s,
+ const wchar_t *__restrict __format, ...)
__THROW /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
__END_NAMESPACE_C99
@@ -583,21 +612,23 @@ __BEGIN_NAMESPACE_C99
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern int vfwscanf (__FILE *__restrict __s,
- __const wchar_t *__restrict __format,
+ const wchar_t *__restrict __format,
__gnuc_va_list __arg)
/* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
+libc_hidden_proto(vfwscanf)
/* Read formatted input from stdin into argument list ARG.
This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern int vwscanf (__const wchar_t *__restrict __format,
+extern int vwscanf (const wchar_t *__restrict __format,
__gnuc_va_list __arg)
/* __attribute__ ((__format__ (__wscanf__, 1, 0))) */;
/* Read formatted input from S into argument list ARG. */
-extern int vswscanf (__const wchar_t *__restrict __s,
- __const wchar_t *__restrict __format,
+extern int vswscanf (const wchar_t *__restrict __s,
+ const wchar_t *__restrict __format,
__gnuc_va_list __arg)
__THROW /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
+libc_hidden_proto(vswscanf)
__END_NAMESPACE_C99
#endif /* Use ISO C99. */
@@ -609,6 +640,7 @@ __BEGIN_NAMESPACE_C99
These functions are possible cancellation points and therefore not
marked with __THROW. */
extern wint_t fgetwc (__FILE *__stream);
+libc_hidden_proto(fgetwc)
extern wint_t getwc (__FILE *__stream);
/* Read a character from stdin.
@@ -623,11 +655,12 @@ extern wint_t getwchar (void);
These functions are possible cancellation points and therefore not
marked with __THROW. */
extern wint_t fputwc (wchar_t __wc, __FILE *__stream);
+libc_hidden_proto(fputwc)
extern wint_t putwc (wchar_t __wc, __FILE *__stream);
/* Write a character to stdout.
- This function is a possible cancellation points and therefore not
+ This function is a possible cancellation point and therefore not
marked with __THROW. */
extern wint_t putwchar (wchar_t __wc);
@@ -635,24 +668,26 @@ extern wint_t putwchar (wchar_t __wc);
/* Get a newline-terminated wide character string of finite length
from STREAM.
- This function is a possible cancellation points and therefore not
+ This function is a possible cancellation point and therefore not
marked with __THROW. */
extern wchar_t *fgetws (wchar_t *__restrict __ws, int __n,
__FILE *__restrict __stream);
/* Write a string to STREAM.
- This function is a possible cancellation points and therefore not
+ This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern int fputws (__const wchar_t *__restrict __ws,
+extern int fputws (const wchar_t *__restrict __ws,
__FILE *__restrict __stream);
+libc_hidden_proto(fputws)
/* Push a character back onto the input buffer of STREAM.
- This function is a possible cancellation points and therefore not
+ This function is a possible cancellation point and therefore not
marked with __THROW. */
extern wint_t ungetwc (wint_t __wc, __FILE *__stream);
+libc_hidden_proto(ungetwc)
__END_NAMESPACE_C99
@@ -674,6 +709,7 @@ extern wint_t getwchar_unlocked (void);
or due to the implementation it is a cancellation point and
therefore not marked with __THROW. */
extern wint_t fgetwc_unlocked (__FILE *__stream);
+libc_hidden_proto(fgetwc_unlocked)
/* Faster version when locking is not necessary.
@@ -682,6 +718,7 @@ extern wint_t fgetwc_unlocked (__FILE *__stream);
or due to the implementation it is a cancellation point and
therefore not marked with __THROW. */
extern wint_t fputwc_unlocked (wchar_t __wc, __FILE *__stream);
+libc_hidden_proto(fputwc_unlocked)
/* These are defined to be equivalent to the `char' functions defined
in POSIX.1:1996.
@@ -702,6 +739,7 @@ extern wint_t putwchar_unlocked (wchar_t __wc);
therefore not marked with __THROW. */
extern wchar_t *fgetws_unlocked (wchar_t *__restrict __ws, int __n,
__FILE *__restrict __stream);
+libc_hidden_proto(fgetws_unlocked)
/* This function does the same as `fputws' but does not lock the stream.
@@ -709,8 +747,9 @@ extern wchar_t *fgetws_unlocked (wchar_t *__restrict __ws, int __n,
cancellation point. But due to similarity with an POSIX interface
or due to the implementation it is a cancellation point and
therefore not marked with __THROW. */
-extern int fputws_unlocked (__const wchar_t *__restrict __ws,
+extern int fputws_unlocked (const wchar_t *__restrict __ws,
__FILE *__restrict __stream);
+libc_hidden_proto(fputws_unlocked)
#endif
@@ -719,8 +758,8 @@ __BEGIN_NAMESPACE_C99
Write no more than MAXSIZE wide characters and return the number
of wide characters written, or 0 if it would exceed MAXSIZE. */
extern size_t wcsftime (wchar_t *__restrict __s, size_t __maxsize,
- __const wchar_t *__restrict __format,
- __const struct tm *__restrict __tp) __THROW;
+ const wchar_t *__restrict __format,
+ const struct tm *__restrict __tp) __THROW;
__END_NAMESPACE_C99
# if defined __USE_GNU && defined __UCLIBC_HAS_XLOCALE__
@@ -729,9 +768,10 @@ __END_NAMESPACE_C99
/* Similar to `wcsftime' but takes the information from
the provided locale and not the global locale. */
extern size_t wcsftime_l (wchar_t *__restrict __s, size_t __maxsize,
- __const wchar_t *__restrict __format,
- __const struct tm *__restrict __tp,
+ const wchar_t *__restrict __format,
+ const struct tm *__restrict __tp,
__locale_t __loc) __THROW;
+libc_hidden_proto(wcsftime_l)
# endif
/* The X/Open standard demands that most of the functions defined in
@@ -745,6 +785,11 @@ extern size_t wcsftime_l (wchar_t *__restrict __s, size_t __maxsize,
# include <wctype.h>
#endif
+#ifdef _LIBC
+extern size_t __wcslcpy(wchar_t *__restrict dst,
+ const wchar_t *__restrict src, size_t n) attribute_hidden;
+#endif
+
__END_DECLS
#endif /* _WCHAR_H defined */
diff --git a/include/wctype.h b/include/wctype.h
index 266ffab38..aa133bd60 100644
--- a/include/wctype.h
+++ b/include/wctype.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 Standard: 7.25
@@ -120,6 +119,7 @@ __BEGIN_NAMESPACE_C99
/* Test for any wide character for which `iswalpha' or `iswdigit' is
true. */
extern int iswalnum (wint_t __wc) __THROW;
+libc_hidden_proto(iswalnum)
/* Test for any wide character for which `iswupper' or 'iswlower' is
true, or any wide character that is one of a locale-specific set of
@@ -142,6 +142,7 @@ extern int iswgraph (wint_t __wc) __THROW;
or is one of a locale-specific set of wide characters for which
none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
extern int iswlower (wint_t __wc) __THROW;
+libc_hidden_proto(iswlower)
/* Test for any printing wide character. */
extern int iswprint (wint_t __wc) __THROW;
@@ -155,11 +156,13 @@ extern int iswpunct (wint_t __wc) __THROW;
set of wide characters for which none of `iswalnum', `iswgraph', or
`iswpunct' is true. */
extern int iswspace (wint_t __wc) __THROW;
+libc_hidden_proto(iswspace)
/* Test for any wide character that corresponds to an uppercase letter
or is one of a locale-specific set of wide character for which none
of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
extern int iswupper (wint_t __wc) __THROW;
+libc_hidden_proto(iswupper)
/* Test for any wide character that corresponds to a hexadecimal-digit
character equivalent to that performed be the functions described
@@ -179,11 +182,13 @@ extern int iswblank (wint_t __wc) __THROW;
/* Construct value that describes a class of wide characters identified
by the string argument PROPERTY. */
-extern wctype_t wctype (__const char *__property) __THROW;
+extern wctype_t wctype (const char *__property) __THROW;
+libc_hidden_proto(wctype)
/* Determine whether the wide-character WC has the property described by
DESC. */
extern int iswctype (wint_t __wc, wctype_t __desc) __THROW;
+libc_hidden_proto(iswctype)
__END_NAMESPACE_C99
@@ -194,7 +199,7 @@ __END_NAMESPACE_C99
__BEGIN_NAMESPACE_C99
/* Scalar type that can hold values which represent locale-specific
character mappings. */
-/* uClibc note: glibc uses - typedef __const __int32_t *wctrans_t; */
+/* uClibc note: glibc uses - typedef const __int32_t *wctrans_t; */
typedef unsigned int wctrans_t;
__END_NAMESPACE_C99
#ifdef __USE_GNU
@@ -204,9 +209,11 @@ __USING_NAMESPACE_C99(wctrans_t)
__BEGIN_NAMESPACE_C99
/* Converts an uppercase letter to the corresponding lowercase letter. */
extern wint_t towlower (wint_t __wc) __THROW;
+libc_hidden_proto(towlower)
/* Converts an lowercase letter to the corresponding uppercase letter. */
extern wint_t towupper (wint_t __wc) __THROW;
+libc_hidden_proto(towupper)
__END_NAMESPACE_C99
__END_DECLS
@@ -227,10 +234,12 @@ __BEGIN_DECLS
__BEGIN_NAMESPACE_C99
/* Construct value that describes a mapping between wide characters
identified by the string argument PROPERTY. */
-extern wctrans_t wctrans (__const char *__property) __THROW;
+extern wctrans_t wctrans (const char *__property) __THROW;
+libc_hidden_proto(wctrans)
/* Map the wide character WC using the mapping described by DESC. */
extern wint_t towctrans (wint_t __wc, wctrans_t __desc) __THROW;
+libc_hidden_proto(towctrans)
__END_NAMESPACE_C99
#if defined(__USE_GNU) && defined(__UCLIBC_HAS_XLOCALE__)
@@ -275,6 +284,7 @@ extern int iswpunct_l (wint_t __wc, __locale_t __locale) __THROW;
set of wide characters for which none of `iswalnum', `iswgraph', or
`iswpunct' is true. */
extern int iswspace_l (wint_t __wc, __locale_t __locale) __THROW;
+libc_hidden_proto(iswspace_l)
/* Test for any wide character that corresponds to an uppercase letter
or is one of a locale-specific set of wide character for which none
@@ -293,13 +303,14 @@ extern int iswblank_l (wint_t __wc, __locale_t __locale) __THROW;
/* Construct value that describes a class of wide characters identified
by the string argument PROPERTY. */
-extern wctype_t wctype_l (__const char *__property, __locale_t __locale)
+extern wctype_t wctype_l (const char *__property, __locale_t __locale)
__THROW;
/* Determine whether the wide-character WC has the property described by
DESC. */
extern int iswctype_l (wint_t __wc, wctype_t __desc, __locale_t __locale)
__THROW;
+libc_hidden_proto(iswctype_l)
/*
@@ -308,18 +319,21 @@ extern int iswctype_l (wint_t __wc, wctype_t __desc, __locale_t __locale)
/* Converts an uppercase letter to the corresponding lowercase letter. */
extern wint_t towlower_l (wint_t __wc, __locale_t __locale) __THROW;
+libc_hidden_proto(towlower_l)
/* Converts an lowercase letter to the corresponding uppercase letter. */
extern wint_t towupper_l (wint_t __wc, __locale_t __locale) __THROW;
+libc_hidden_proto(towupper_l)
/* Construct value that describes a mapping between wide characters
identified by the string argument PROPERTY. */
-extern wctrans_t wctrans_l (__const char *__property, __locale_t __locale)
+extern wctrans_t wctrans_l (const char *__property, __locale_t __locale)
__THROW;
/* Map the wide character WC using the mapping described by DESC. */
extern wint_t towctrans_l (wint_t __wc, wctrans_t __desc,
__locale_t __locale) __THROW;
+libc_hidden_proto(towctrans_l)
# endif /* Use GNU. */
diff --git a/include/wordexp.h b/include/wordexp.h
index 1c40e6168..f270fd757 100644
--- a/include/wordexp.h
+++ b/include/wordexp.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 _WORDEXP_H
#define _WORDEXP_H 1
@@ -60,11 +59,12 @@ enum
};
/* Do word expansion of WORDS into PWORDEXP. */
-extern int wordexp (__const char *__restrict __words,
+extern int wordexp (const char *__restrict __words,
wordexp_t *__restrict __pwordexp, int __flags);
/* Free the storage allocated by a `wordexp' call. */
extern void wordfree (wordexp_t *__wordexp) __THROW;
+libc_hidden_proto(wordfree)
__END_DECLS
diff --git a/include/xlocale.h b/include/xlocale.h
index 6f726fef9..8f5a740f5 100644
--- a/include/xlocale.h
+++ b/include/xlocale.h
@@ -1,5 +1,5 @@
/* Definition of locale datatype.
- Copyright (C) 1997,2000,02 Free Software Foundation, Inc.
+ Copyright (C) 1997,2000,2002,2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -14,22 +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/>. */
#ifndef _XLOCALE_H
#define _XLOCALE_H 1
-#include <features.h>
-
-#ifndef __UCLIBC_HAS_XLOCALE__
-#error Attempted to include xlocale.h when uClibc built without extended locale support.
-#endif /* __UCLIBC_HAS_XLOCALE__ */
-
-#include <bits/uClibc_locale.h>
-/* #include <bits/uClibc_touplow.h> */
-
#if 0
/* Structure for reentrant locale using functions. This is an
(almost) opaque type for the user level programs. The file and
@@ -37,26 +27,22 @@
go away without warning. */
typedef struct __locale_struct
{
-#if 0
/* Note: LC_ALL is not a valid index into this array. */
struct locale_data *__locales[13]; /* 13 = __LC_LAST. */
-#endif
/* To increase the speed of this solution we add some special members. */
-/* const unsigned short int *__ctype_b; */
-/* const int *__ctype_tolower; */
-/* const int *__ctype_toupper; */
- const __uint16_t *__ctype_b;
- const __ctype_touplow_t *__ctype_tolower;
- const __ctype_touplow_t *__ctype_toupper;
+ const unsigned short int *__ctype_b;
+ const int *__ctype_tolower;
+ const int *__ctype_toupper;
- __uclibc_locale_t *__locale_ptr;
-
-#if 0
/* Note: LC_ALL is not a valid index into this array. */
const char *__names[13];
-#endif
} *__locale_t;
+#else
+# include <bits/uClibc_locale.h>
#endif
+/* POSIX 2008 makes locale_t official. */
+typedef __locale_t locale_t;
+
#endif /* xlocale.h */
diff --git a/ldso/include/dl-defs.h b/ldso/include/dl-defs.h
index 791d068bb..bedfa977e 100644
--- a/ldso/include/dl-defs.h
+++ b/ldso/include/dl-defs.h
@@ -5,8 +5,8 @@
* GNU Lesser General Public License version 2.1 or later.
*/
-#ifndef _LD_DEFS_H
-#define _LD_DEFS_H
+#ifndef _DL_DEFS_H
+#define _DL_DEFS_H
#define FLAG_ANY -1
#define FLAG_TYPE_MASK 0x00ff
@@ -72,6 +72,13 @@ typedef struct {
#endif
+#ifdef _LIBC
+#ifndef __ARCH_HAS_NO_SHARED__
+/* arch specific defines */
+#include <dl-sysdep.h>
+#endif
+#endif
+
/* Provide a means for a port to pass additional arguments to the _dl_start
function. */
#ifndef DL_START
@@ -99,7 +106,7 @@ typedef struct {
* from DL_START, so additional arguments passed to it may be referenced. */
#ifndef DL_BOOT_COMPUTE_DYN
#define DL_BOOT_COMPUTE_DYN(DPNT, GOT, LOAD_ADDR) \
- ((DPNT) = ((ElfW(Dyn) *) DL_RELOC_ADDR(load_addr, got)))
+ ((DPNT) = ((ElfW(Dyn) *) DL_RELOC_ADDR(LOAD_ADDR, GOT)))
#endif
/* Initialize the location of the global offset table. This is only called
@@ -179,6 +186,14 @@ typedef struct {
#define DL_LOOKUP_ADDRESS(ADDRESS) (ADDRESS)
#endif
+/* On some architectures dladdr can't use st_size of all symbols this way. */
+#define DL_ADDR_SYM_MATCH(SYM_ADDR, SYM, MATCHSYM, ADDR) \
+ ((ADDR) >= (SYM_ADDR) \
+ && ((((SYM)->st_shndx == SHN_UNDEF || (SYM)->st_size == 0) \
+ && (ADDR) == (SYM_ADDR)) \
+ || (ADDR) < (SYM_ADDR) + (SYM)->st_size) \
+ && (!(MATCHSYM) || MATCHSYM < (SYM_ADDR)))
+
/* Use this macro to convert a pointer to a function's entry point to
* a pointer to function. The pointer is assumed to have already been
* relocated. LOADADDR is passed because it may contain additional
@@ -212,7 +227,7 @@ typedef struct {
_dl_find_hash for this reloc TYPE. TPNT is the module in which the
matching SYM was found. */
#ifndef DL_FIND_HASH_VALUE
-# define DL_FIND_HASH_VALUE(TPNT, TYPE, SYM) (DL_RELOC_ADDR ((SYM)->st_value, (TPNT)->loadaddr))
+# define DL_FIND_HASH_VALUE(TPNT, TYPE, SYM) (DL_RELOC_ADDR ((TPNT)->loadaddr, (SYM)->st_value))
#endif
/* Unmap all previously-mapped segments accumulated in LOADADDR.
@@ -225,7 +240,7 @@ typedef struct {
/* Similar to DL_LOADADDR_UNMAP, but used for libraries that have been
dlopen()ed successfully, when they're dlclose()d. */
#ifndef DL_LIB_UNMAP
-# define DL_LIB_UNMAP(LIB, LEN) (DL_LOADADDR_UNMAP ((LIB)->loadaddr, (LEN)))
+# define DL_LIB_UNMAP(LIB, LEN) (DL_LOADADDR_UNMAP ((LIB)->mapaddr, (LEN)))
#endif
/* Define this to verify that a library named LIBNAME, whose ELF
@@ -251,4 +266,26 @@ typedef struct {
# define DL_MAP_SEGMENT(EPNT, PPNT, INFILE, FLAGS) 0
#endif
-#endif /* _LD_DEFS_H */
+/* Define this to declare the library offset. */
+#ifndef DL_DEF_LIB_OFFSET
+# define DL_DEF_LIB_OFFSET static unsigned long _dl_library_offset
+#endif
+
+/* Define this to get the library offset. */
+#ifndef DL_GET_LIB_OFFSET
+# define DL_GET_LIB_OFFSET() _dl_library_offset
+#endif
+
+/* Define this to set the library offset as difference beetwen the mapped
+ library address and the smallest virtual address of the first PT_LOAD
+ segment. */
+#ifndef DL_SET_LIB_OFFSET
+# define DL_SET_LIB_OFFSET(offset) (_dl_library_offset = (offset))
+#endif
+
+/* Define this to get the real object's runtime address. */
+#ifndef DL_GET_RUN_ADDR
+# define DL_GET_RUN_ADDR(loadaddr, mapaddr) (mapaddr)
+#endif
+
+#endif /* _DL_DEFS_H */
diff --git a/ldso/include/dl-elf.h b/ldso/include/dl-elf.h
index 076678cfc..80625fd5b 100644
--- a/ldso/include/dl-elf.h
+++ b/ldso/include/dl-elf.h
@@ -5,18 +5,22 @@
* GNU Lesser General Public License version 2.1 or later.
*/
-#ifndef LINUXELF_H
-#define LINUXELF_H
+#ifndef _DL_ELF_H
+#define _DL_ELF_H
+#include <features.h>
+#include <bits/wordsize.h>
#include <dl-string.h> /* before elf.h to get ELF_USES_RELOCA right */
#include <elf.h>
#include <link.h>
+#include <dl-defs.h>
+#include <dlfcn.h>
-/* Forward declarations for stuff defined in ld_hash.h */
+/* Forward declarations for stuff defined in dl-hash.h */
struct dyn_elf;
struct elf_resolve;
+struct r_scope_elem;
-#include <dl-defs.h>
#ifdef __LDSO_CACHE_SUPPORT__
extern int _dl_map_cache(void);
extern int _dl_unmap_cache(void);
@@ -25,21 +29,18 @@ static __inline__ void _dl_map_cache(void) { }
static __inline__ void _dl_unmap_cache(void) { }
#endif
-
-/* Function prototypes for non-static stuff in readelflib1.c */
+/* Function prototypes for non-static stuff in elfinterp.c */
extern void _dl_parse_lazy_relocation_information(struct dyn_elf *rpnt,
unsigned long rel_addr, unsigned long rel_size);
extern int _dl_parse_relocation_information(struct dyn_elf *rpnt,
- unsigned long rel_addr, unsigned long rel_size);
-extern struct elf_resolve * _dl_load_shared_library(int secure,
+ struct r_scope_elem *scope, unsigned long rel_addr, unsigned long rel_size);
+extern struct elf_resolve * _dl_load_shared_library(unsigned int rflags,
struct dyn_elf **rpnt, struct elf_resolve *tpnt, char *full_libname,
int trace_loaded_objects);
-extern struct elf_resolve * _dl_load_elf_shared_library(int secure,
- struct dyn_elf **rpnt, char *libname);
-extern struct elf_resolve *_dl_check_if_named_library_is_loaded(const char *full_libname,
- int trace_loaded_objects);
+extern struct elf_resolve * _dl_load_elf_shared_library(unsigned int rflags,
+ struct dyn_elf **rpnt, const char *libname);
extern int _dl_linux_resolve(void);
-extern int _dl_fixup(struct dyn_elf *rpnt, int flag);
+extern int _dl_fixup(struct dyn_elf *rpnt, struct r_scope_elem *scope, int flag);
extern void _dl_protect_relro (struct elf_resolve *l);
/*
@@ -84,33 +85,58 @@ extern void _dl_protect_relro (struct elf_resolve *l);
#endif
/* OS and/or GNU dynamic extensions */
+
+#define OS_NUM_BASE 1 /* for DT_RELOCCOUNT */
+
#ifdef __LDSO_GNU_HASH_SUPPORT__
-# define OS_NUM 2 /* for DT_RELOCCOUNT and DT_GNU_HASH entries */
+# define OS_NUM_GNU_HASH 1 /* for DT_GNU_HASH entry */
+#else
+# define OS_NUM_GNU_HASH 0
+#endif
+
+#ifdef __LDSO_PRELINK_SUPPORT__
+# define OS_NUM_PRELINK 6 /* for DT_GNU_PRELINKED entry */
#else
-# define OS_NUM 1 /* for DT_RELOCCOUNT entry */
+# define OS_NUM_PRELINK 0
#endif
+#define OS_NUM (OS_NUM_BASE + OS_NUM_GNU_HASH + OS_NUM_PRELINK)
+
#ifndef ARCH_DYNAMIC_INFO
/* define in arch specific code, if needed */
# define ARCH_NUM 0
#endif
-#define DYNAMIC_SIZE (DT_NUM+OS_NUM+ARCH_NUM)
+#define DYNAMIC_SIZE (DT_NUM + OS_NUM + ARCH_NUM)
/* Keep ARCH specific entries into dynamic section at the end of the array */
#define DT_RELCONT_IDX (DYNAMIC_SIZE - OS_NUM - ARCH_NUM)
#ifdef __LDSO_GNU_HASH_SUPPORT__
/* GNU hash comes just after the relocation count */
# define DT_GNU_HASH_IDX (DT_RELCONT_IDX + 1)
+#else
+# define DT_GNU_HASH_IDX DT_RELCONT_IDX
#endif
-extern void _dl_parse_dynamic_info(ElfW(Dyn) *dpnt, unsigned long dynamic_info[],
- void *debug_addr, DL_LOADADDR_TYPE load_off);
+#ifdef __LDSO_PRELINK_SUPPORT__
+/* GNU prelink comes just after the GNU hash if present */
+#define DT_GNU_PRELINKED_IDX (DT_GNU_HASH_IDX + 1)
+#define DT_GNU_CONFLICT_IDX (DT_GNU_HASH_IDX + 2)
+#define DT_GNU_CONFLICTSZ_IDX (DT_GNU_HASH_IDX + 3)
+#define DT_GNU_LIBLIST_IDX (DT_GNU_HASH_IDX + 4)
+#define DT_GNU_LIBLISTSZ_IDX (DT_GNU_HASH_IDX + 5)
+#define DT_CHECKSUM_IDX (DT_GNU_HASH_IDX + 6)
+#endif
+
+extern unsigned int _dl_parse_dynamic_info(ElfW(Dyn) *dpnt, unsigned long dynamic_info[],
+ void *debug_addr, DL_LOADADDR_TYPE load_off);
static __always_inline
-void __dl_parse_dynamic_info(ElfW(Dyn) *dpnt, unsigned long dynamic_info[],
- void *debug_addr, DL_LOADADDR_TYPE load_off)
+unsigned int __dl_parse_dynamic_info(ElfW(Dyn) *dpnt, unsigned long dynamic_info[],
+ void *debug_addr, DL_LOADADDR_TYPE load_off)
{
+ unsigned int rtld_flags = 0;
+
for (; dpnt->d_tag; dpnt++) {
if (dpnt->d_tag < DT_NUM) {
dynamic_info[dpnt->d_tag] = dpnt->d_un.d_val;
@@ -138,13 +164,30 @@ void __dl_parse_dynamic_info(ElfW(Dyn) *dpnt, unsigned long dynamic_info[],
} else if (dpnt->d_tag < DT_LOPROC) {
if (dpnt->d_tag == DT_RELOCCOUNT)
dynamic_info[DT_RELCONT_IDX] = dpnt->d_un.d_val;
- if (dpnt->d_tag == DT_FLAGS_1 &&
- (dpnt->d_un.d_val & DF_1_NOW))
- dynamic_info[DT_BIND_NOW] = 1;
+ if (dpnt->d_tag == DT_FLAGS_1) {
+ if (dpnt->d_un.d_val & DF_1_NOW)
+ dynamic_info[DT_BIND_NOW] = 1;
+ if (dpnt->d_un.d_val & DF_1_NODELETE)
+ rtld_flags |= RTLD_NODELETE;
+ }
#ifdef __LDSO_GNU_HASH_SUPPORT__
if (dpnt->d_tag == DT_GNU_HASH)
dynamic_info[DT_GNU_HASH_IDX] = dpnt->d_un.d_ptr;
#endif
+#ifdef __LDSO_PRELINK_SUPPORT__
+ if (dpnt->d_tag == DT_GNU_PRELINKED)
+ dynamic_info[DT_GNU_PRELINKED_IDX] = dpnt->d_un.d_val;
+ if (dpnt->d_tag == DT_GNU_CONFLICT)
+ dynamic_info[DT_GNU_CONFLICT_IDX] = dpnt->d_un.d_ptr;
+ if (dpnt->d_tag == DT_GNU_CONFLICTSZ)
+ dynamic_info[DT_GNU_CONFLICTSZ_IDX] = dpnt->d_un.d_val;
+ if (dpnt->d_tag == DT_GNU_LIBLIST)
+ dynamic_info[DT_GNU_LIBLIST_IDX] = dpnt->d_un.d_ptr;
+ if (dpnt->d_tag == DT_GNU_LIBLISTSZ)
+ dynamic_info[DT_GNU_LIBLISTSZ_IDX] = dpnt->d_un.d_val;
+ if (dpnt->d_tag == DT_CHECKSUM)
+ dynamic_info[DT_CHECKSUM_IDX] = dpnt->d_un.d_val;
+#endif
}
#ifdef ARCH_DYNAMIC_INFO
else {
@@ -157,16 +200,29 @@ void __dl_parse_dynamic_info(ElfW(Dyn) *dpnt, unsigned long dynamic_info[],
if (dynamic_info[tag]) \
dynamic_info[tag] = (unsigned long) DL_RELOC_ADDR(load_off, dynamic_info[tag]); \
} while (0)
- ADJUST_DYN_INFO(DT_HASH, load_off);
- ADJUST_DYN_INFO(DT_PLTGOT, load_off);
- ADJUST_DYN_INFO(DT_STRTAB, load_off);
- ADJUST_DYN_INFO(DT_SYMTAB, load_off);
- ADJUST_DYN_INFO(DT_RELOC_TABLE_ADDR, load_off);
- ADJUST_DYN_INFO(DT_JMPREL, load_off);
+ /* Don't adjust .dynamic unnecessarily. For FDPIC targets,
+ we'd have to walk all the loadsegs to find out if it was
+ actually unnecessary, so skip this optimization. */
+#if !defined __FRV_FDPIC__ && !defined __BFIN_FDPIC__ && !defined __DSBT__
+ if (load_off != 0)
+#endif
+ {
+ ADJUST_DYN_INFO(DT_HASH, load_off);
+ ADJUST_DYN_INFO(DT_PLTGOT, load_off);
+ ADJUST_DYN_INFO(DT_STRTAB, load_off);
+ ADJUST_DYN_INFO(DT_SYMTAB, load_off);
+ ADJUST_DYN_INFO(DT_RELOC_TABLE_ADDR, load_off);
+ ADJUST_DYN_INFO(DT_JMPREL, load_off);
#ifdef __LDSO_GNU_HASH_SUPPORT__
- ADJUST_DYN_INFO(DT_GNU_HASH_IDX, load_off);
+ ADJUST_DYN_INFO(DT_GNU_HASH_IDX, load_off);
+#endif
+ }
+#ifdef __DSBT__
+ /* Get the mapped address of the DSBT base. */
+ ADJUST_DYN_INFO(DT_DSBT_BASE_IDX, load_off);
#endif
#undef ADJUST_DYN_INFO
+ return rtld_flags;
}
/* Reloc type classes as returned by elf_machine_type_class().
@@ -196,4 +252,4 @@ void __dl_parse_dynamic_info(ElfW(Dyn) *dpnt, unsigned long dynamic_info[],
(((X) & PF_X) ? PROT_EXEC : 0))
-#endif /* LINUXELF_H */
+#endif /* _DL_ELF_H */
diff --git a/ldso/include/dl-hash.h b/ldso/include/dl-hash.h
index 9b87783fa..d6282bb0c 100644
--- a/ldso/include/dl-hash.h
+++ b/ldso/include/dl-hash.h
@@ -5,8 +5,8 @@
* GNU Lesser General Public License version 2.1 or later.
*/
-#ifndef _LD_HASH_H_
-#define _LD_HASH_H_
+#ifndef _DL_HASH_H
+#define _DL_HASH_H
#ifndef RTLD_NEXT
#define RTLD_NEXT ((void*)-1)
@@ -25,6 +25,19 @@ struct dyn_elf {
struct dyn_elf * prev;
};
+struct symbol_ref {
+ const ElfW(Sym) *sym;
+ struct elf_resolve *tpnt;
+};
+
+/* Structure to describe a single list of scope elements. The lookup
+ functions get passed an array of pointers to such structures. */
+struct r_scope_elem {
+ struct elf_resolve **r_list; /* Array of maps for the scope. */
+ unsigned int r_nlist; /* Number of entries in the scope. */
+ struct r_scope_elem *next;
+};
+
struct elf_resolve {
/* These entries must be in this order to be compatible with the interface used
by gdb to obtain the list of symbols. */
@@ -34,9 +47,41 @@ struct elf_resolve {
struct elf_resolve * next;
struct elf_resolve * prev;
/* Nothing after this address is used by gdb. */
- ElfW(Addr) mapaddr; /* Address at which ELF segments (either main app and DSO) are mapped into */
+
+#if defined(USE_TLS) && USE_TLS
+ /* Thread-local storage related info. */
+
+ /* Start of the initialization image. */
+ void *l_tls_initimage;
+ /* Size of the initialization image. */
+ size_t l_tls_initimage_size;
+ /* Size of the TLS block. */
+ size_t l_tls_blocksize;
+ /* Alignment requirement of the TLS block. */
+ size_t l_tls_align;
+ /* Offset of first byte module alignment. */
+ size_t l_tls_firstbyte_offset;
+# ifndef NO_TLS_OFFSET
+# define NO_TLS_OFFSET 0
+# endif
+ /* For objects present at startup time: offset in the static TLS block. */
+ ptrdiff_t l_tls_offset;
+ /* Index of the module in the dtv array. */
+ size_t l_tls_modid;
+ /* Nonzero if _dl_init_static_tls should be called for this module */
+ unsigned int l_need_tls_init:1;
+ /* Address of TLS descriptor hash table. */
+ void *l_tlsdesc_table;
+#endif
+
+ ElfW(Addr) mapaddr;
+#ifdef __LDSO_STANDALONE_SUPPORT__
+ /* Store the entry point from the ELF header (e_entry) */
+ ElfW(Addr) l_entry;
+#endif
enum {elf_lib, elf_executable,program_interpreter, loaded_file} libtype;
- struct dyn_elf * symbol_scope;
+ /* This is the local scope of the shared object */
+ struct r_scope_elem symbol_scope;
unsigned short usage_count;
unsigned short int init_flag;
unsigned long rtld_flags; /* RTLD_GLOBAL, RTLD_NOW etc. */
@@ -90,12 +135,18 @@ struct elf_resolve {
unsigned long data_words;
#endif
-#ifdef __FDPIC__
+#if defined(__FRV_FDPIC__) || defined(__BFIN_FDPIC__)
/* Every loaded module holds a hashtable of function descriptors of
functions defined in it, such that it's easy to release the
memory when the module is dlclose()d. */
struct funcdesc_ht *funcdesc_ht;
#endif
+#ifdef __DSBT__
+ /* Information for DSBT */
+ void **dsbt_table;
+ unsigned long dsbt_size;
+ unsigned long dsbt_index;
+#endif
};
#define RELOCS_DONE 0x000001
@@ -103,43 +154,21 @@ struct elf_resolve {
#define INIT_FUNCS_CALLED 0x000004
#define FINI_FUNCS_CALLED 0x000008
#define DL_OPENED 0x000010
+#define DL_RESERVED 0x000020
extern struct dyn_elf * _dl_symbol_tables;
extern struct elf_resolve * _dl_loaded_modules;
-extern struct dyn_elf * _dl_handles;
+extern struct dyn_elf * _dl_handles;
extern struct elf_resolve * _dl_add_elf_hash_table(const char * libname,
DL_LOADADDR_TYPE loadaddr, unsigned long * dynamic_info,
unsigned long dynamic_addr, unsigned long dynamic_size);
-extern char * _dl_lookup_hash(const char * name, struct dyn_elf * rpnt,
- struct elf_resolve *mytpnt, int type_class
-#ifdef __FDPIC__
- , struct elf_resolve **tpntp
-#endif
- );
-
-static __always_inline char *_dl_find_hash(const char *name, struct dyn_elf *rpnt,
- struct elf_resolve *mytpnt, int type_class)
-{
-#ifdef __FDPIC__
- return _dl_lookup_hash(name, rpnt, mytpnt, type_class, NULL);
-#else
- return _dl_lookup_hash(name, rpnt, mytpnt, type_class);
-#endif
-}
-
-extern int _dl_linux_dynamic_link(void);
+extern char *_dl_find_hash(const char *name, struct r_scope_elem *scope,
+ struct elf_resolve *mytpnt, int type_class,
+ struct symbol_ref *symbol);
extern char * _dl_library_path;
-extern char * _dl_not_lazy;
-
-static __inline__ int _dl_symbol(char * name)
-{
- if (name[0] != '_' || name[1] != 'd' || name[2] != 'l' || name[3] != '_')
- return 0;
- return 1;
-}
#define LD_ERROR_NOFILE 1
#define LD_ERROR_NOZERO 2
@@ -148,8 +177,9 @@ static __inline__ int _dl_symbol(char * name)
#define LD_ERROR_NOTDYN 5
#define LD_ERROR_MMAP_FAILED 6
#define LD_ERROR_NODYNAMIC 7
-#define LD_WRONG_RELOCS 8
-#define LD_BAD_HANDLE 9
-#define LD_NO_SYMBOL 10
+#define LD_ERROR_TLS_FAILED 8
+#define LD_WRONG_RELOCS 9
+#define LD_BAD_HANDLE 10
+#define LD_NO_SYMBOL 11
-#endif /* _LD_HASH_H_ */
+#endif /* _DL_HASH_H */
diff --git a/ldso/include/dl-string.h b/ldso/include/dl-string.h
index 746bd91c6..14ae617c3 100644
--- a/ldso/include/dl-string.h
+++ b/ldso/include/dl-string.h
@@ -5,12 +5,16 @@
* GNU Lesser General Public License version 2.1 or later.
*/
-#ifndef _LINUX_STRING_H_
-#define _LINUX_STRING_H_
+#ifndef _DL_STRING_H
+#define _DL_STRING_H
-#include <dl-sysdep.h> /* for do_rem */
#include <features.h>
+#define __need_NULL
+#include <stddef.h>
+
+#include <dl-defs.h> /* for do_rem by dl-sysdep.h */
+
/* provide some sane defaults */
#ifndef do_rem
# define do_rem(result, n, base) ((result) = (n) % (base))
@@ -19,26 +23,8 @@
# define do_div_10(result, remain) ((result) /= 10)
#endif
-static size_t _dl_strlen(const char * str);
-static char *_dl_strcat(char *dst, const char *src);
-static char * _dl_strcpy(char * dst,const char *src);
-static int _dl_strcmp(const char * s1,const char * s2);
-static int _dl_strncmp(const char * s1,const char * s2,size_t len);
-static char * _dl_strchr(const char * str,int c);
-static char *_dl_strrchr(const char *str, int c);
-static char *_dl_strstr(const char *s1, const char *s2);
-static void * _dl_memcpy(void * dst, const void * src, size_t len);
-static int _dl_memcmp(const void * s1,const void * s2,size_t len);
-static void *_dl_memset(void * str,int c,size_t len);
-static char *_dl_get_last_path_component(char *path);
-static char *_dl_simple_ltoa(char * local, unsigned long i);
-static char *_dl_simple_ltoahex(char * local, unsigned long i);
-
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
-
-static __always_inline size_t _dl_strlen(const char * str)
+#ifdef IS_IN_rtld
+static __always_inline size_t _dl_strlen(const char *str)
{
register const char *ptr = (char *) str-1;
while (*++ptr)
@@ -59,7 +45,7 @@ static __always_inline char * _dl_strcat(char *dst, const char *src)
return dst;
}
-static __always_inline char * _dl_strcpy(char * dst,const char *src)
+static __always_inline char * _dl_strcpy(char *dst, const char *src)
{
register char *ptr = dst;
@@ -70,7 +56,7 @@ static __always_inline char * _dl_strcpy(char * dst,const char *src)
return ptr;
}
-static __always_inline int _dl_strcmp(const char * s1,const char * s2)
+static __always_inline int _dl_strcmp(const char *s1, const char *s2)
{
register unsigned char c1, c2;
s1--;s2--;
@@ -84,23 +70,7 @@ static __always_inline int _dl_strcmp(const char * s1,const char * s2)
return c1 - c2;
}
-static __always_inline int _dl_strncmp(const char * s1,const char * s2,size_t len)
-{
- register unsigned char c1 = '\0';
- register unsigned char c2 = '\0';
-
- s1--;s2--;
- while (len > 0) {
- c1 = (unsigned char) *++s1;
- c2 = (unsigned char) *++s2;
- if (c1 == '\0' || c1 != c2)
- return c1 - c2;
- len--;
- }
- return c1 - c2;
-}
-
-static __always_inline char * _dl_strchr(const char * str,int c)
+static __always_inline char * _dl_strchr(const char *str, int c)
{
register char ch;
str--;
@@ -147,7 +117,7 @@ static __always_inline char * _dl_strstr(const char *s1, const char *s2)
} while (1);
}
-static __always_inline void * _dl_memcpy(void * dst, const void * src, size_t len)
+static __always_inline void * _dl_memcpy(void *dst, const void *src, size_t len)
{
register char *a = dst-1;
register const char *b = src-1;
@@ -159,7 +129,7 @@ static __always_inline void * _dl_memcpy(void * dst, const void * src, size_t le
return dst;
}
-static __always_inline int _dl_memcmp(const void * s1,const void * s2,size_t len)
+static __always_inline int _dl_memcmp(const void *s1, const void *s2, size_t len)
{
unsigned char *c1 = (unsigned char *)s1-1;
unsigned char *c2 = (unsigned char *)s2-1;
@@ -172,7 +142,7 @@ static __always_inline int _dl_memcmp(const void * s1,const void * s2,size_t len
return 0;
}
-#if defined(powerpc)
+#if defined(__powerpc__)
/* Will generate smaller and faster code due to loop unrolling.*/
static __always_inline void * _dl_memset(void *to, int c, size_t n)
{
@@ -200,7 +170,7 @@ lessthan4:
return to;
}
#else
-static __always_inline void * _dl_memset(void * str,int c,size_t len)
+static __always_inline void * _dl_memset(void *str, int c, size_t len)
{
register char *a = str;
@@ -228,11 +198,25 @@ static __always_inline char * _dl_get_last_path_component(char *path)
;/* empty */
return ptr == path ? ptr : ptr+1;
}
-
+#else /* IS_IN_rtld */
+# include <string.h>
+# define _dl_strlen strlen
+# define _dl_strcat strcat
+# define _dl_strcpy strcpy
+# define _dl_strcmp strcmp
+# define _dl_strchr strchr
+# define _dl_strrchr strrchr
+# define _dl_strstr strstr
+# define _dl_memcpy memcpy
+# define _dl_memcmp memcmp
+# define _dl_memset memset
+#endif /* IS_IN_rtld */
+
+#if defined IS_IN_rtld || defined __SUPPORT_LD_DEBUG__
/* Early on, we can't call printf, so use this to print out
* numbers using the SEND_STDERR() macro. Avoid using mod
* or using long division */
-static __always_inline char * _dl_simple_ltoa(char * local, unsigned long i)
+static __always_inline char * _dl_simple_ltoa(char *local, unsigned long i)
{
/* 20 digits plus a null terminator should be good for
* 64-bit or smaller ints (2^64 - 1)*/
@@ -246,8 +230,10 @@ static __always_inline char * _dl_simple_ltoa(char * local, unsigned long i)
} while (i > 0);
return p;
}
+#endif
-static __always_inline char * _dl_simple_ltoahex(char * local, unsigned long i)
+#ifdef IS_IN_rtld
+static __always_inline char * _dl_simple_ltoahex(char *local, unsigned long i)
{
/* 16 digits plus a leading "0x" plus a null terminator,
* should be good for 64-bit or smaller ints */
@@ -266,9 +252,6 @@ static __always_inline char * _dl_simple_ltoahex(char * local, unsigned long i)
return p;
}
-
-
-
/* The following macros may be used in dl-startup.c to debug
* ldso before ldso has fixed itself up to make function calls */
@@ -285,8 +268,8 @@ static __always_inline char * _dl_simple_ltoahex(char * local, unsigned long i)
/* On some arches constant strings are referenced through the GOT.
* This requires that load_addr must already be defined... */
#if defined(mc68000) || defined(__arm__) || defined(__thumb__) || \
- defined(__mips__) || defined(__sh__) || defined(__powerpc__) || \
- defined(__avr32__) || defined(__xtensa__)
+ defined(__sh__) || defined(__powerpc__) || \
+ defined(__avr32__) || defined(__xtensa__) || defined(__sparc__) || defined(__microblaze__)
# define CONSTANT_STRING_GOT_FIXUP(X) \
if ((X) < (const char *) load_addr) (X) += load_addr
# define NO_EARLY_SEND_STDERR
@@ -362,4 +345,6 @@ static __always_inline char * _dl_simple_ltoahex(char * local, unsigned long i)
# define SEND_ADDRESS_STDERR_DEBUG(X, add_a_newline)
#endif
-#endif
+#endif /* IS_IN_rtld */
+
+#endif /* _DL_STRING_H */
diff --git a/ldso/include/dl-syscall.h b/ldso/include/dl-syscall.h
index 1cbbbad0f..5528ba6a0 100644
--- a/ldso/include/dl-syscall.h
+++ b/ldso/include/dl-syscall.h
@@ -5,51 +5,40 @@
* GNU Lesser General Public License version 2.1 or later.
*/
-#ifndef _LD_SYSCALL_H_
-#define _LD_SYSCALL_H_
+#ifndef _DL_SYSCALL_H
+#define _DL_SYSCALL_H
+
+/* We can't use the real errno in ldso, since it has not yet
+ * been dynamicly linked in yet. */
+#include "sys/syscall.h"
+extern int _dl_errno;
+#undef __set_errno
+#define __set_errno(X) {(_dl_errno) = (X);}
/* Pull in the arch specific syscall implementation */
#include <dl-syscalls.h>
/* For MAP_ANONYMOUS -- differs between platforms */
#define _SYS_MMAN_H 1
#include <bits/mman.h>
+
+#ifdef __ARCH_HAS_DEPRECATED_SYSCALLS__
/* 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... */
-#if defined(__sparc_v9__) && (__WORDSIZE == 64)
-#define kernel_stat64 stat
-#else
#define kernel_stat stat
-#endif
#include <bits/kernel_stat.h>
#include <bits/kernel_types.h>
-/* _dl_open() parameters */
-#define O_RDONLY 00
-#define O_WRONLY 01
-#define O_RDWR 02
-#define O_CREAT 0100
-
-/* 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. */
-
/* 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. */
+#else
+/* 1. common-generic ABI doesn't need kernel_stat translation
+ * 3. S_IS?ID already provided by stat.h
+ */
+#include <sys/stat.h>
+#endif
/* Here are the definitions for some syscalls that are used
@@ -59,107 +48,140 @@
dynamic linking at all, so we cannot return any error codes.
We just punt if there is an error. */
#define __NR__dl_exit __NR_exit
-static __always_inline _syscall1(void, _dl_exit, int, status);
+static __always_inline attribute_noreturn __cold void _dl_exit(int status)
+{
+ INLINE_SYSCALL(_dl_exit, 1, status);
+#if __GNUC_PREREQ(4, 5)
+ __builtin_unreachable(); /* shut up warning: 'noreturn' function does return*/
+#else
+ while (1);
+#endif
+}
#define __NR__dl_close __NR_close
-static __always_inline _syscall1(int, _dl_close, int, fd);
+static __always_inline _syscall1(int, _dl_close, int, fd)
-#define __NR__dl_open __NR_open
+#if defined __NR_openat && !defined __NR_open
+static __always_inline int _dl_open(const char *fn,
+ int flags, __kernel_mode_t mode)
+{
+ return INLINE_SYSCALL(openat, 4, AT_FDCWD, fn, flags, mode);
+}
+
+#elif defined __NR_open
+# define __NR__dl_open __NR_open
static __always_inline _syscall3(int, _dl_open, const char *, fn, int, flags,
- __kernel_mode_t, mode);
+ __kernel_mode_t, mode)
+#endif
#define __NR__dl_write __NR_write
static __always_inline _syscall3(unsigned long, _dl_write, int, fd,
- const void *, buf, unsigned long, count);
+ const void *, buf, unsigned long, count)
#define __NR__dl_read __NR_read
static __always_inline _syscall3(unsigned long, _dl_read, int, fd,
- const void *, buf, unsigned long, count);
+ const void *, buf, unsigned long, count)
#define __NR__dl_mprotect __NR_mprotect
static __always_inline _syscall3(int, _dl_mprotect, const void *, addr,
- unsigned long, len, int, prot);
+ unsigned long, len, int, prot)
-#define __NR__dl_stat __NR_stat
+#if defined __NR_fstatat64 && !defined __NR_stat
+# define __NR__dl_fstatat64 __NR_fstatat64
+static __always_inline _syscall4(int, _dl_fstatat64, int, fd, const char *,
+ fn, struct stat *, stat, int, flags)
+
+static __always_inline int _dl_stat(const char *file_name,
+ struct stat *buf)
+{
+ return _dl_fstatat64(AT_FDCWD, file_name, buf, 0);
+}
+#elif defined __NR_stat
+# define __NR__dl_stat __NR_stat
static __always_inline _syscall2(int, _dl_stat, const char *, file_name,
- struct stat *, buf);
+ struct stat *, buf)
+#endif
-#define __NR__dl_fstat __NR_fstat
-static __always_inline _syscall2(int, _dl_fstat, int, fd, struct stat *, buf);
+#if defined __NR_fstat64 && !defined __NR_fstat
+# define __NR__dl_fstat __NR_fstat64
+#elif defined __NR_fstat
+# define __NR__dl_fstat __NR_fstat
+#endif
+static __always_inline _syscall2(int, _dl_fstat, int, fd, struct stat *, buf)
#define __NR__dl_munmap __NR_munmap
-static __always_inline _syscall2(int, _dl_munmap, void *, start, unsigned long, length);
+static __always_inline _syscall2(int, _dl_munmap, void *, start, unsigned long, length)
#ifdef __NR_getxuid
# define __NR_getuid __NR_getxuid
#endif
#define __NR__dl_getuid __NR_getuid
-static __always_inline _syscall0(uid_t, _dl_getuid);
+static __always_inline _syscall0(uid_t, _dl_getuid)
#ifndef __NR_geteuid
# define __NR_geteuid __NR_getuid
#endif
#define __NR__dl_geteuid __NR_geteuid
-static __always_inline _syscall0(uid_t, _dl_geteuid);
+static __always_inline _syscall0(uid_t, _dl_geteuid)
#ifdef __NR_getxgid
# define __NR_getgid __NR_getxgid
#endif
#define __NR__dl_getgid __NR_getgid
-static __always_inline _syscall0(gid_t, _dl_getgid);
+static __always_inline _syscall0(gid_t, _dl_getgid)
#ifndef __NR_getegid
# define __NR_getegid __NR_getgid
#endif
#define __NR__dl_getegid __NR_getegid
-static __always_inline _syscall0(gid_t, _dl_getegid);
+static __always_inline _syscall0(gid_t, _dl_getegid)
#ifdef __NR_getxpid
# define __NR_getpid __NR_getxpid
#endif
#define __NR__dl_getpid __NR_getpid
-static __always_inline _syscall0(gid_t, _dl_getpid);
+static __always_inline _syscall0(gid_t, _dl_getpid)
+
+#if defined __NR_readlinkat
+# define __NR__dl_readlink __NR_readlinkat
+static __always_inline _syscall4(int, _dl_readlink, int, id, const char *, path,
+ char *, buf, size_t, bufsiz)
+#endif
-#define __NR__dl_readlink __NR_readlink
-static __always_inline _syscall3(int, _dl_readlink, const char *, path, char *, buf,
- size_t, bufsiz);
+#ifdef __NR_pread64
+#define __NR___syscall_pread __NR_pread64
+static __always_inline _syscall5(ssize_t, __syscall_pread, int, fd, void *, buf,
+ size_t, count, off_t, offset_hi, off_t, offset_lo)
+
+static __always_inline ssize_t
+_dl_pread(int fd, void *buf, size_t count, off_t offset)
+{
+ return __syscall_pread(fd, buf, count, offset, offset >> 31);
+}
+#elif defined __NR_pread
+#define __NR___syscall_pread __NR_pread
+static __always_inline _syscall5(ssize_t, __syscall_pread, int, fd, void *, buf,
+ size_t, count, off_t, offset_hi, off_t, offset_lo)
+
+static __always_inline ssize_t
+_dl_pread(int fd, void *buf, size_t count, off_t offset)
+{
+ return __syscall_pread(fd, buf, count, __LONG_LONG_PAIR(offset >> 31, offset));
+}
+#endif
#ifdef __UCLIBC_HAS_SSP__
# include <sys/time.h>
# define __NR__dl_gettimeofday __NR_gettimeofday
static __always_inline _syscall2(int, _dl_gettimeofday, struct timeval *, tv,
# ifdef __USE_BSD
- struct timezone *, tz);
+ struct timezone *
# else
- void *, tz);
+ void *
# endif
+ , tz)
#endif
-
-/* handle all the fun mmap intricacies */
-#if (defined(__UCLIBC_MMAP_HAS_6_ARGS__) && defined(__NR_mmap)) || !defined(__NR_mmap2)
-# define _dl_MAX_ERRNO 4096
-# define _dl_mmap_check_error(__res) \
- (((long)__res) < 0 && ((long)__res) >= -_dl_MAX_ERRNO)
-#else
-# define MAP_FAILED ((void *) -1)
-# define _dl_mmap_check_error(X) (((void *)X) == MAP_FAILED)
-#endif
-
-/* first try mmap(), syscall6() style */
-#if defined(__UCLIBC_MMAP_HAS_6_ARGS__) && defined(__NR_mmap)
-
-# define __NR__dl_mmap __NR_mmap
-static __always_inline _syscall6(void *, _dl_mmap, void *, start, size_t, length,
- int, prot, int, flags, int, fd, off_t, offset);
-
-/* then try mmap2() */
-#elif defined(__NR_mmap2)
-
-# define __NR___syscall_mmap2 __NR_mmap2
-static __always_inline _syscall6(__ptr_t, __syscall_mmap2, __ptr_t, addr, size_t, len,
- int, prot, int, flags, int, fd, off_t, offset);
-
/* 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...
@@ -168,36 +190,41 @@ static __always_inline _syscall6(__ptr_t, __syscall_mmap2, __ptr_t, addr, size_t
# define MMAP2_PAGE_SHIFT 12
#endif
-static __always_inline void * _dl_mmap(void * addr, unsigned long size, int prot,
- int flags, int fd, unsigned long offset)
+#define MAP_FAILED ((void *) -1)
+#define _dl_mmap_check_error(X) (((void *)X) == MAP_FAILED)
+
+static __always_inline
+void *_dl_mmap(void *addr, unsigned long size, int prot,
+ int flags, int fd, unsigned long offset)
{
+#if defined(__UCLIBC_MMAP_HAS_6_ARGS__) && defined(__NR_mmap)
+ /* first try mmap(), syscall6() style */
+ return (void *)INLINE_SYSCALL(mmap, 6, addr, size, prot, flags, fd, offset);
+
+#elif defined(__NR_mmap2) && !defined (__mcoldfire__)
+ /* then try mmap2() */
+ unsigned long shifted;
+
if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1))
return MAP_FAILED;
- return __syscall_mmap2(addr, size, prot, flags,
- fd, (off_t) (offset >> MMAP2_PAGE_SHIFT));
-}
-/* finally, fall back to mmap(), syscall1() style */
-#elif defined(__NR_mmap)
+ /* gcc needs help with putting things onto the stack */
+ shifted = offset >> MMAP2_PAGE_SHIFT;
+ return (void *)INLINE_SYSCALL(mmap2, 6, addr, size, prot, flags, fd, shifted);
-# define __NR__dl_mmap_real __NR_mmap
-static __always_inline _syscall1(void *, _dl_mmap_real, unsigned long *, buffer);
-static __always_inline void * _dl_mmap(void * addr, unsigned long size, int prot,
- int flags, int fd, unsigned long offset)
-{
+#elif defined(__NR_mmap)
+ /* finally, fall back to mmap(), syscall1() style */
unsigned long buffer[6];
-
buffer[0] = (unsigned long) addr;
buffer[1] = (unsigned long) size;
buffer[2] = (unsigned long) prot;
buffer[3] = (unsigned long) flags;
buffer[4] = (unsigned long) fd;
buffer[5] = (unsigned long) offset;
- return (void *) _dl_mmap_real(buffer);
-}
-
+ return (void *)INLINE_SYSCALL(mmap, 1, buffer);
#else
# error "Your architecture doesn't seem to provide mmap() !?"
#endif
+}
-#endif /* _LD_SYSCALL_H_ */
+#endif /* _DL_SYSCALL_H */
diff --git a/ldso/include/dlfcn.h b/ldso/include/dlfcn.h
index 03afd34fb..5cdd6be53 100644
--- a/ldso/include/dlfcn.h
+++ b/ldso/include/dlfcn.h
@@ -19,9 +19,9 @@
`dladdr'. */
typedef struct
{
- __const char *dli_fname; /* File name of defining object. */
+ const char *dli_fname; /* File name of defining object. */
void *dli_fbase; /* Load address of that object. */
- __const char *dli_sname; /* Name of nearest symbol. */
+ const char *dli_sname; /* Name of nearest symbol. */
void *dli_saddr; /* Exact value of nearest symbol. */
} Dl_info;
diff --git a/ldso/include/inline-hashtab.h b/ldso/include/inline-hashtab.h
new file mode 100644
index 000000000..4a4812027
--- /dev/null
+++ b/ldso/include/inline-hashtab.h
@@ -0,0 +1,265 @@
+/*
+ * The hashcode handling code below is heavily inspired in libiberty's
+ * hashtab code, but with most adaptation points and support for
+ * deleting elements removed.
+ *
+ * Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+ * Contributed by Vladimir Makarov (vmakarov@cygnus.com).
+ */
+
+#ifndef INLINE_HASHTAB_H
+# define INLINE_HASHTAB_H 1
+
+static __always_inline unsigned long
+higher_prime_number(unsigned long n)
+{
+ /* These are primes that are near, but slightly smaller than, a power of two. */
+ static const unsigned long primes[] = {
+ 7,
+ 13,
+ 31,
+ 61,
+ 127,
+ 251,
+ 509,
+ 1021,
+ 2039,
+ 4093,
+ 8191,
+ 16381,
+ 32749,
+ 65521,
+ 131071,
+ 262139,
+ 524287,
+ 1048573,
+ 2097143,
+ 4194301,
+ 8388593,
+ 16777213,
+ 33554393,
+ 67108859,
+ 134217689,
+ 268435399,
+ 536870909,
+ 1073741789,
+ /* 4294967291 */
+ ((unsigned long) 2147483647) + ((unsigned long) 2147483644),
+ };
+ const unsigned long *low = &primes[0];
+ const unsigned long *high = &primes[ARRAY_SIZE(primes)];
+
+ while (low != high) {
+ const unsigned long *mid = low + (high - low) / 2;
+ if (n > *mid)
+ low = mid + 1;
+ else
+ high = mid;
+ }
+
+#if 0
+ /* If we've run out of primes, abort. */
+ if (n > *low) {
+ fprintf(stderr, "Cannot find prime bigger than %lu\n", n);
+ abort();
+ }
+#endif
+
+ return *low;
+}
+
+struct funcdesc_ht
+{
+ /* Table itself */
+ void **entries;
+
+ /* Current size (in entries) of the hash table */
+ size_t size;
+
+ /* Current number of elements */
+ size_t n_elements;
+};
+
+static __always_inline struct funcdesc_ht *
+htab_create(void)
+{
+ struct funcdesc_ht *ht = _dl_malloc(sizeof(*ht));
+ size_t ent_size;
+
+ if (!ht)
+ return NULL;
+ ht->size = 3;
+ ent_size = sizeof(void *) * ht->size;
+ ht->entries = _dl_malloc(ent_size);
+ if (!ht->entries)
+ return NULL;
+
+ ht->n_elements = 0;
+ _dl_memset(ht->entries, 0, ent_size);
+
+ return ht;
+}
+
+/*
+ * This is only called from _dl_loadaddr_unmap, so it's safe to call
+ * _dl_free(). See the discussion below.
+ */
+static __always_inline void
+htab_delete(struct funcdesc_ht *htab)
+{
+ size_t i;
+
+ for (i = htab->size - 1; i >= 0; i--)
+ if (htab->entries[i])
+ _dl_free(htab->entries[i]);
+
+ _dl_free(htab->entries);
+ _dl_free(htab);
+}
+
+/*
+ * Similar to htab_find_slot, but without several unwanted side effects:
+ * - Does not call htab->eq_f when it finds an existing entry.
+ * - Does not change the count of elements/searches/collisions in the
+ * hash table.
+ * This function also assumes there are no deleted entries in the table.
+ * HASH is the hash value for the element to be inserted.
+ */
+static __always_inline void **
+find_empty_slot_for_expand(struct funcdesc_ht *htab, int hash)
+{
+ size_t size = htab->size;
+ unsigned int index = hash % size;
+ void **slot = htab->entries + index;
+ int hash2;
+
+ if (!*slot)
+ return slot;
+
+ hash2 = 1 + hash % (size - 2);
+ for (;;) {
+ index += hash2;
+ if (index >= size)
+ index -= size;
+
+ slot = htab->entries + index;
+ if (!*slot)
+ return slot;
+ }
+}
+
+/*
+ * The following function changes size of memory allocated for the
+ * entries and repeatedly inserts the table elements. The occupancy
+ * of the table after the call will be about 50%. Naturally the hash
+ * table must already exist. Remember also that the place of the
+ * table entries is changed. If memory allocation failures are allowed,
+ * this function will return zero, indicating that the table could not be
+ * expanded. If all goes well, it will return a non-zero value.
+ */
+static __always_inline int
+htab_expand(struct funcdesc_ht *htab, int (*hash_fn) (void *))
+{
+ void **oentries;
+ void **olimit;
+ void **p;
+ void **nentries;
+ size_t nsize;
+
+ oentries = htab->entries;
+ olimit = oentries + htab->size;
+
+ /*
+ * Resize only when table after removal of unused elements is either
+ * too full or too empty.
+ */
+ if (htab->n_elements * 2 > htab->size)
+ nsize = higher_prime_number(htab->n_elements * 2);
+ else
+ nsize = htab->size;
+
+ nentries = _dl_malloc(sizeof(*nentries) * nsize);
+ _dl_memset(nentries, 0, sizeof(*nentries) * nsize);
+ if (nentries == NULL)
+ return 0;
+ htab->entries = nentries;
+ htab->size = nsize;
+
+ p = oentries;
+ do {
+ if (*p)
+ *find_empty_slot_for_expand(htab, hash_fn(*p)) = *p;
+ p++;
+ } while (p < olimit);
+
+#if 0
+ /*
+ * We can't tell whether this was allocated by the _dl_malloc()
+ * built into ld.so or malloc() in the main executable or libc,
+ * and calling free() for something that wasn't malloc()ed could
+ * do Very Bad Things (TM). Take the conservative approach
+ * here, potentially wasting as much memory as actually used by
+ * the hash table, even if multiple growths occur. That's not
+ * so bad as to require some overengineered solution that would
+ * enable us to keep track of how it was allocated.
+ */
+ _dl_free(oentries);
+#endif
+ return 1;
+}
+
+/*
+ * This function searches for a hash table slot containing an entry
+ * equal to the given element. To delete an entry, call this with
+ * INSERT = 0, then call htab_clear_slot on the slot returned (possibly
+ * after doing some checks). To insert an entry, call this with
+ * INSERT = 1, then write the value you want into the returned slot.
+ * When inserting an entry, NULL may be returned if memory allocation
+ * fails.
+ */
+static __always_inline void **
+htab_find_slot(struct funcdesc_ht *htab, void *ptr, int insert,
+ int (*hash_fn)(void *), int (*eq_fn)(void *, void *))
+{
+ unsigned int index;
+ int hash, hash2;
+ size_t size;
+ void **entry;
+
+ if (htab->size * 3 <= htab->n_elements * 4 &&
+ htab_expand(htab, hash_fn) == 0)
+ return NULL;
+
+ hash = hash_fn(ptr);
+
+ size = htab->size;
+ index = hash % size;
+
+ entry = &htab->entries[index];
+ if (!*entry)
+ goto empty_entry;
+ else if (eq_fn(*entry, ptr))
+ return entry;
+
+ hash2 = 1 + hash % (size - 2);
+ for (;;) {
+ index += hash2;
+ if (index >= size)
+ index -= size;
+
+ entry = &htab->entries[index];
+ if (!*entry)
+ goto empty_entry;
+ else if (eq_fn(*entry, ptr))
+ return entry;
+ }
+
+ empty_entry:
+ if (!insert)
+ return NULL;
+
+ htab->n_elements++;
+ return entry;
+}
+
+#endif
diff --git a/ldso/include/ldso.h b/ldso/include/ldso.h
index 35a72fc5e..e237885b9 100644
--- a/ldso/include/ldso.h
+++ b/ldso/include/ldso.h
@@ -5,8 +5,8 @@
* GNU Lesser General Public License version 2.1 or later.
*/
-#ifndef _LDSO_H_
-#define _LDSO_H_
+#ifndef _LDSO_H
+#define _LDSO_H
#include <features.h>
@@ -27,18 +27,46 @@
/* Pull in compiler and arch stuff */
#include <stdlib.h>
#include <stdarg.h>
+#include <stddef.h> /* for ptrdiff_t */
+#include <stdbool.h>
+#define _FCNTL_H
+/* We need this if arch has only new syscalls defined */
+#ifndef AT_FDCWD
+#define AT_FDCWD -100
+#endif /* AT_FDCWD */
+#include <bits/fcntl.h>
#include <bits/wordsize.h>
/* Pull in the arch specific type information */
#include <sys/types.h>
/* Pull in the arch specific page size */
#include <bits/uClibc_page.h>
+/* Pull in the MIN macro */
+#include <sys/param.h>
/* Pull in the ldso syscalls and string functions */
+#ifndef __ARCH_HAS_NO_SHARED__
#include <dl-syscall.h>
#include <dl-string.h>
/* Now the ldso specific headers */
#include <dl-elf.h>
+#ifdef __UCLIBC_HAS_TLS__
+/* Defines USE_TLS */
+#include <tls.h>
+#endif
#include <dl-hash.h>
+/* common align masks, if not specified by sysdep headers */
+#ifndef ADDR_ALIGN
+#define ADDR_ALIGN (_dl_pagesize - 1)
+#endif
+
+#ifndef PAGE_ALIGN
+#define PAGE_ALIGN (~ADDR_ALIGN)
+#endif
+
+#ifndef OFFS_ALIGN
+#define OFFS_ALIGN (PAGE_ALIGN & ~(1ul << (sizeof(_dl_pagesize) * 8 - 1)))
+#endif
+
/* For INIT/FINI dependency sorting. */
struct init_fini_list {
struct init_fini_list *next;
@@ -48,10 +76,25 @@ struct init_fini_list {
/* Global variables used within the shared library loader */
extern char *_dl_library_path; /* Where we look for libraries */
extern char *_dl_preload; /* Things to be loaded before the libs */
-extern char *_dl_ldsopath; /* Where the shared lib loader was found */
+#ifdef __LDSO_SEARCH_INTERP_PATH__
+extern const char *_dl_ldsopath; /* Where the shared lib loader was found */
+#endif
extern const char *_dl_progname; /* The name of the executable being run */
-extern int _dl_secure; /* Are we dealing with setuid stuff? */
extern size_t _dl_pagesize; /* Store the page size for use later */
+#ifdef __LDSO_PRELINK_SUPPORT__
+extern char *_dl_trace_prelink; /* Library for prelinking trace */
+extern struct elf_resolve *_dl_trace_prelink_map; /* Library map for prelinking trace */
+#else
+#define _dl_trace_prelink 0
+#endif
+#ifdef __DSBT__
+extern void **_dl_ldso_dsbt;
+#endif
+
+#if defined(USE_TLS) && USE_TLS
+extern void _dl_add_to_slotinfo (struct link_map *l);
+extern void ** __attribute__ ((const)) _dl_initial_error_catch_tsd (void);
+#endif
#ifdef __SUPPORT_LD_DEBUG__
extern char *_dl_debug;
@@ -63,13 +106,14 @@ extern char *_dl_debug_nofixups;
extern char *_dl_debug_bindings;
extern int _dl_debug_file;
# define __dl_debug_dprint(fmt, args...) \
- _dl_dprintf(_dl_debug_file, "%s:%i: " fmt, __FUNCTION__, __LINE__, ## args);
+ _dl_dprintf(_dl_debug_file, "%s:%i: " fmt, __func__, __LINE__, ## args);
# define _dl_if_debug_dprint(fmt, args...) \
do { if (_dl_debug) __dl_debug_dprint(fmt, ## args); } while (0)
#else
# define __dl_debug_dprint(fmt, args...) do {} while (0)
# define _dl_if_debug_dprint(fmt, args...) do {} while (0)
-# define _dl_debug_file 2
+/* disabled on purpose, _dl_debug_file should be guarded by __SUPPORT_LD_DEBUG__
+# define _dl_debug_file 2*/
#endif /* __SUPPORT_LD_DEBUG__ */
#ifdef IS_IN_rtld
@@ -100,11 +144,24 @@ extern int _dl_debug_file;
#endif
extern void *_dl_malloc(size_t size);
+extern void *_dl_calloc(size_t __nmemb, size_t __size);
+extern void *_dl_realloc(void *__ptr, size_t __size);
extern void _dl_free(void *);
extern char *_dl_getenv(const char *symbol, char **envp);
extern void _dl_unsetenv(const char *symbol, char **envp);
+#ifdef IS_IN_rtld
extern char *_dl_strdup(const char *string);
extern void _dl_dprintf(int, const char *, ...);
+#else
+# include <string.h>
+# define _dl_strdup strdup
+# include <stdio.h>
+# ifdef __USE_GNU
+# define _dl_dprintf dprintf
+# else
+# define _dl_dprintf(fd, fmt, args...) fprintf(stderr, fmt, ## args)
+# endif
+#endif
#ifndef DL_GET_READY_TO_RUN_EXTRA_PARMS
# define DL_GET_READY_TO_RUN_EXTRA_PARMS
@@ -113,7 +170,7 @@ extern void _dl_dprintf(int, const char *, ...);
# define DL_GET_READY_TO_RUN_EXTRA_ARGS
#endif
-extern void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
+extern void *_dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
ElfW(auxv_t) auxvt[AT_EGID + 1], char **envp, char **argv
DL_GET_READY_TO_RUN_EXTRA_PARMS);
@@ -121,4 +178,8 @@ extern void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load
#include <dl-inlines.h>
#endif
-#endif /* _LDSO_H_ */
+#else /* __ARCH_HAS_NO_SHARED__ */
+#include <dl-defs.h>
+#endif
+
+#endif /* _LDSO_H */
diff --git a/ldso/include/ldsodefs.h b/ldso/include/ldsodefs.h
new file mode 100644
index 000000000..9ae645c60
--- /dev/null
+++ b/ldso/include/ldsodefs.h
@@ -0,0 +1,154 @@
+#ifndef _LDSODEFS_H
+#define _LDSODEFS_H 1
+
+#include <bits/kernel-features.h>
+
+#include <features.h>
+#include <tls.h>
+
+#ifdef __mips__
+/* The MIPS ABI specifies that the dynamic section has to be read-only. */
+
+#define DL_RO_DYN_SECTION 1
+
+/* TODO: Import in 64-bit relocations from glibc. */
+#endif
+
+#ifndef SHARED
+# define EXTERN extern
+#else
+# ifdef IS_IN_rtld
+# define EXTERN
+# else
+# define EXTERN extern
+# endif
+#endif
+
+/* Non-shared code has no support for multiple namespaces. */
+#ifdef SHARED
+# define DL_NNS 16
+#else
+# define DL_NNS 1
+#endif
+
+#define GL(x) _##x
+#define GLRO(x) _##x
+
+/* Variable pointing to the end of the stack (or close to it). This value
+ must be constant over the runtime of the application. Some programs
+ might use the variable which results in copy relocations on some
+ platforms. But this does not matter, ld.so can always use the local
+ copy. */
+extern void *__libc_stack_end;
+
+/* Determine next available module ID. */
+extern size_t _dl_next_tls_modid (void) internal_function attribute_hidden;
+
+/* Calculate offset of the TLS blocks in the static TLS block. */
+extern void _dl_determine_tlsoffset (void) internal_function attribute_hidden;
+
+/* Set up the data structures for TLS, when they were not set up at startup.
+ Returns nonzero on malloc failure.
+ This is called from _dl_map_object_from_fd or by libpthread. */
+extern int _dl_tls_setup (void) internal_function;
+rtld_hidden_proto (_dl_tls_setup)
+
+/* Allocate memory for static TLS block (unless MEM is nonzero) and dtv. */
+extern void *_dl_allocate_tls (void *mem) internal_function;
+
+/* Get size and alignment requirements of the static TLS block. */
+extern void _dl_get_tls_static_info (size_t *sizep, size_t *alignp)
+ internal_function;
+
+extern void _dl_allocate_static_tls (struct link_map *map)
+ internal_function attribute_hidden;
+extern int _dl_try_allocate_static_tls (struct link_map* map)
+ internal_function attribute_hidden;
+
+/* Taken from glibc/elf/dl-reloc.c */
+#define CHECK_STATIC_TLS(sym_map) \
+ do { \
+ if (__builtin_expect ((sym_map)->l_tls_offset == NO_TLS_OFFSET, 0)) \
+ _dl_allocate_static_tls (sym_map); \
+ } while (0)
+#define TRY_STATIC_TLS(sym_map) \
+ (__builtin_expect ((sym_map)->l_tls_offset != NO_TLS_OFFSET, 1) \
+ || _dl_try_allocate_static_tls (sym_map) == 0)
+
+/* These are internal entry points to the two halves of _dl_allocate_tls,
+ only used within rtld.c itself at startup time. */
+extern void *_dl_allocate_tls_storage (void)
+ internal_function attribute_hidden;
+extern void *_dl_allocate_tls_init (void *) internal_function;
+
+/* Deallocate memory allocated with _dl_allocate_tls. */
+extern void _dl_deallocate_tls (void *tcb, bool dealloc_tcb) internal_function;
+
+extern void _dl_nothread_init_static_tls (struct link_map *) attribute_hidden;
+
+/* Highest dtv index currently needed. */
+EXTERN size_t _dl_tls_max_dtv_idx;
+/* Flag signalling whether there are gaps in the module ID allocation. */
+EXTERN bool _dl_tls_dtv_gaps;
+/* Information about the dtv slots. */
+EXTERN struct dtv_slotinfo_list
+{
+ size_t len;
+ struct dtv_slotinfo_list *next;
+ struct dtv_slotinfo
+ {
+ size_t gen;
+ bool is_static;
+ struct link_map *map;
+ } slotinfo[0];
+} *_dl_tls_dtv_slotinfo_list;
+/* Number of modules in the static TLS block. */
+EXTERN size_t _dl_tls_static_nelem;
+/* Size of the static TLS block. */
+EXTERN size_t _dl_tls_static_size;
+/* Size actually allocated in the static TLS block. */
+EXTERN size_t _dl_tls_static_used;
+/* Alignment requirement of the static TLS block. */
+EXTERN size_t _dl_tls_static_align;
+/* Function pointer for catching TLS errors. */
+#if 1 /* def _LIBC_REENTRANT */
+EXTERN void **(*_dl_error_catch_tsd) (void) __attribute__ ((const));
+#endif
+
+/* Number of additional entries in the slotinfo array of each slotinfo
+ list element. A large number makes it almost certain take we never
+ have to iterate beyond the first element in the slotinfo list. */
+# define TLS_SLOTINFO_SURPLUS (62)
+
+/* Number of additional slots in the dtv allocated. */
+# define DTV_SURPLUS (14)
+
+/* Initial dtv of the main thread, not allocated with normal malloc. */
+EXTERN void *_dl_initial_dtv;
+/* Generation counter for the dtv. */
+EXTERN size_t _dl_tls_generation;
+
+EXTERN void (*_dl_init_static_tls) (struct link_map *);
+
+/* We have the auxiliary vector. */
+#define HAVE_AUX_VECTOR
+
+/* We can assume that the kernel always provides the AT_UID, AT_EUID,
+ AT_GID, and AT_EGID values in the auxiliary vector from 2.4.0 or so on. */
+#if __ASSUME_AT_XID
+# define HAVE_AUX_XID
+#endif
+
+/* We can assume that the kernel always provides the AT_SECURE value
+ in the auxiliary vector from 2.5.74 or so on. */
+#if __ASSUME_AT_SECURE
+# define HAVE_AUX_SECURE
+#endif
+
+/* Starting with one of the 2.4.0 pre-releases the Linux kernel passes
+ up the page size information. */
+#if __ASSUME_AT_PAGESIZE
+# define HAVE_AUX_PAGESIZE
+#endif
+
+#endif
diff --git a/ldso/include/tlsdeschtab.h b/ldso/include/tlsdeschtab.h
new file mode 100644
index 000000000..056f859b7
--- /dev/null
+++ b/ldso/include/tlsdeschtab.h
@@ -0,0 +1,121 @@
+/* Hash table for TLS descriptors.
+ Copyright (C) 2005-2013 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Alexandre Oliva <aoliva@redhat.com>
+
+ uClibc port by Baruch Siach <baruch@tkos.co.il>
+
+ 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 TLSDESCHTAB_H
+# define TLSDESCHTAB_H 1
+
+# ifdef SHARED
+
+# include <inline-hashtab.h>
+
+inline static int
+hash_tlsdesc (void *p)
+{
+ struct tlsdesc_dynamic_arg *td = p;
+
+ /* We know all entries are for the same module, so ti_offset is the
+ only distinguishing entry. */
+ return td->tlsinfo.ti_offset;
+}
+
+inline static int
+eq_tlsdesc (void *p, void *q)
+{
+ struct tlsdesc_dynamic_arg *tdp = p, *tdq = q;
+
+ return tdp->tlsinfo.ti_offset == tdq->tlsinfo.ti_offset;
+}
+
+inline static int
+map_generation (struct link_map *map)
+{
+ size_t idx = map->l_tls_modid;
+ struct dtv_slotinfo_list *listp = GL(dl_tls_dtv_slotinfo_list);
+
+ /* Find the place in the dtv slotinfo list. */
+ do
+ {
+ /* Does it fit in the array of this list element? */
+ if (idx < listp->len)
+ {
+ /* We should never get here for a module in static TLS, so
+ we can assume that, if the generation count is zero, we
+ still haven't determined the generation count for this
+ module. */
+ if (listp->slotinfo[idx].gen)
+ return listp->slotinfo[idx].gen;
+ else
+ break;
+ }
+ idx -= listp->len;
+ listp = listp->next;
+ }
+ while (listp != NULL);
+
+ /* If we get to this point, the module still hasn't been assigned an
+ entry in the dtv slotinfo data structures, and it will when we're
+ done with relocations. At that point, the module will get a
+ generation number that is one past the current generation, so
+ return exactly that. */
+ return GL(dl_tls_generation) + 1;
+}
+
+void *
+internal_function
+_dl_make_tlsdesc_dynamic (struct link_map *map, size_t ti_offset)
+{
+ struct funcdesc_ht *ht;
+ void **entry;
+ struct tlsdesc_dynamic_arg *td, test;
+
+ ht = map->l_tlsdesc_table;
+ if (! ht)
+ {
+ ht = htab_create ();
+ if (! ht)
+ return 0;
+ map->l_tlsdesc_table = ht;
+ }
+
+ test.tlsinfo.ti_module = map->l_tls_modid;
+ test.tlsinfo.ti_offset = ti_offset;
+ entry = htab_find_slot (ht, &test, 1, hash_tlsdesc, eq_tlsdesc);
+ if (entry == NULL)
+ _dl_exit(1);
+ if (*entry)
+ {
+ td = *entry;
+ return td;
+ }
+
+ *entry = td = _dl_malloc (sizeof (struct tlsdesc_dynamic_arg));
+ /* This may be higher than the map's generation, but it doesn't
+ matter much. Worst case, we'll have one extra DTV update per
+ thread. */
+ td->gen_count = map_generation (map);
+ td->tlsinfo = test.tlsinfo;
+
+ return td;
+}
+
+# endif /* SHARED */
+
+#endif
diff --git a/ldso/ldso/Makefile.in b/ldso/ldso/Makefile.in
index 88b254c27..d85646a1a 100644
--- a/ldso/ldso/Makefile.in
+++ b/ldso/ldso/Makefile.in
@@ -1,28 +1,51 @@
# Makefile for uClibc
#
-# Copyright (C) 2000-2005 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.
#
-CFLAGS-ldso := -DNOT_IN_libc -DIS_IN_rtld $(SSP_DISABLE_FLAGS)
+subdirs += ldso/ldso/$(TARGET_ARCH)
+CFLAGS-rtld := -DNOT_IN_libc -DIS_IN_rtld $(SSP_DISABLE_FLAGS)
+
+ifneq ($(TARGET_ARCH),arc)
# This stuff will not work with -fomit-frame-pointer
-CFLAGS-ldso += -fno-omit-frame-pointer
+CFLAGS-rtld += -fno-omit-frame-pointer
+endif
+
+ifeq ($(DODEBUG),y)
+ifeq ($(TARGET_ARCH),arm)
+# This stuff will not work with -funwind-tables / -fasynchronous-unwind-tables
+CFLAGS-rtld += -fno-unwind-tables -fno-asynchronous-unwind-tables
+endif
+endif
-CFLAGS-ldso += -I$(top_srcdir)ldso/ldso/$(TARGET_ARCH) -I$(top_srcdir)ldso/include -I$(top_srcdir)ldso/ldso
-CFLAGS-ldso += -DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" -DUCLIBC_LDSO=\"$(UCLIBC_LDSO)\"
+CFLAGS-rtld += -I$(top_srcdir)ldso/ldso/$(TARGET_ARCH) -I$(top_srcdir)ldso/include -I$(top_srcdir)ldso/ldso
+CFLAGS-rtld += -DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" -DUCLIBC_LDSO=\"$(UCLIBC_LDSO)\"
-CFLAGS-ldso/ldso/$(TARGET_ARCH)/ := $(CFLAGS-ldso)
+# Not really much point in including debugging info, since gdb
+# can't really debug ldso, since gdb requires help from ldso to
+# debug things....
+# On arm, gcc-4.3.x onwards -Os emits calls to libgcc, which calls _div0,
+# which tries to call raise(). And raise comes from libc so a catch 22.
+# Using -O2 instead. We could have use -fno-early-inlining with -Os too.
+CFLAGS-$(DODEBUG)-ldso/ldso := -O2 -g
-CFLAGS-ldso.c := -DLDSO_ELFINTERP=\"$(TARGET_ARCH)/elfinterp.c\" $(CFLAGS-ldso)
+CFLAGS-ldso.c := -DLDSO_ELFINTERP=\"$(TARGET_ARCH)/elfinterp.c\"
+LDFLAGS-$(UCLIBC_FORMAT_DSBT_ELF)-$(UCLIBC_LDSO_NAME).so := -Wl,--dsbt-index=1
ifneq ($(SUPPORT_LD_DEBUG),y)
LDFLAGS-$(UCLIBC_LDSO_NAME).so := $(LDFLAGS)
else
LDFLAGS-$(UCLIBC_LDSO_NAME).so := $(LDFLAGS_NOSTRIP) -Wl,-z,defs
endif
-LDFLAGS-$(UCLIBC_LDSO_NAME).so += -Wl,-e,_start -Wl,-z,now -Wl,-Bsymbolic -Wl,--export-dynamic -Wl,--sort-common -Wl,--discard-locals -Wl,--discard-all -Wl,--no-undefined
+LDFLAGS-$(UCLIBC_LDSO_NAME).so += -Wl,-e,$(SYMBOL_PREFIX)_start \
+ -Wl,-z,now -Wl,-Bsymbolic \
+ -Wl,--export-dynamic $(CFLAG_-Wl--sort-common) -Wl,--discard-locals \
+ $(CFLAG_-Wl--discard-all) -Wl,--no-undefined
+
+LDFLAGS-$(LDSO_PRELINK_SUPPORT)-$(UCLIBC_LDSO_NAME).so += -Wl,-defsym=$(SYMBOL_PREFIX)_begin=0
ldso_FULL_NAME := $(UCLIBC_LDSO_NAME)-$(VERSION).so
@@ -47,15 +70,18 @@ $(UCLIBC_LDSO_NAME)_OBJS := $($(UCLIBC_LDSO_NAME)_COBJ) $($(UCLIBC_LDSO_NAME)_SO
ldso-y := $($(UCLIBC_LDSO_NAME)_OBJS:.o=.oS)
lib-so-y += $(ldso)
-objclean-y += $(UCLIBC_LDSO_NAME)_clean
+objclean-y += CLEAN_ldso/ldso
-$(ldso): $(ldso:.$(MAJOR_VERSION)=)
-$(ldso:.$(MAJOR_VERSION)=): $($(UCLIBC_LDSO_NAME)_OUT)/$(UCLIBC_LDSO_NAME)_so.a
- $(call link.so,$(ldso_FULL_NAME),$(MAJOR_VERSION))
+$(ldso): $(ldso:.$(ABI_VERSION)=)
+$(ldso:.$(ABI_VERSION)=): | $(top_builddir)lib
+$(ldso:.$(ABI_VERSION)=): $($(UCLIBC_LDSO_NAME)_OUT)/$(UCLIBC_LDSO_NAME)_so.a
+ $(call link.so,$(ldso_FULL_NAME),$(ABI_VERSION))
+ # link for backward compatibility
+ (cd $(top_builddir)lib; ln -sf $(UCLIBC_LDSO_NAME).so.$(ABI_VERSION) $(UCLIBC_LDSO_NAME).so.0 )
$($(UCLIBC_LDSO_NAME)_OUT)/$(UCLIBC_LDSO_NAME)_so.a: $(ldso-y)
$(Q)$(RM) $@
$(do_ar)
-$(UCLIBC_LDSO_NAME)_clean:
- $(RM) $($(UCLIBC_LDSO_NAME)_OUT)/*.{o,os,oS,a} $($(UCLIBC_LDSO_NAME)_OUT)/*/*.{o,os,oS}
+CLEAN_ldso/ldso:
+ $(do_rm) $(addprefix $($(UCLIBC_LDSO_NAME)_OUT)/,$(foreach e, o os oS a,$(foreach d, *. */*.,$(d)$(e))))
diff --git a/ldso/ldso/arc/dl-debug.h b/ldso/ldso/arc/dl-debug.h
new file mode 100644
index 000000000..6573e5452
--- /dev/null
+++ b/ldso/ldso/arc/dl-debug.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+static const char *_dl_reltypes_tab[] =
+{
+ "R_ARC_NONE", /* 0 */
+ "R_ARC_8",
+ "R_ARC_16",
+ "R_ARC_24",
+ "R_ARC_32",
+ "R_ARC_B26", /* 5 */
+ "R_ARC_B22_PCREL",
+ "R_ARC_H30",
+ "R_ARC_N8",
+ "R_ARC_N16",
+ "R_ARC_N24", /* 10 */
+ "R_ARC_N32",
+ "R_ARC_SDA",
+ "R_ARC_SECTOFF",
+ "R_ARC_S21H_PCREL",
+ "R_ARC_S21W_PCREL", /* 15 */
+ "R_ARC_S25H_PCREL",
+ "R_ARC_S25W_PCREL",
+ "R_ARC_SDA32",
+ "R_ARC_SDA_LDST",
+ "R_ARC_SDA_LDST1", /* 20 */
+ "R_ARC_SDA_LDST2",
+ "R_ARC_SDA16_LD",
+ "R_ARC_SDA16_LD1",
+ "R_ARC_SDA16_LD2",
+ "R_ARC_S13_PCREL", /* 25 */
+ "R_ARC_W",
+ "R_ARC_32_ME",
+ "R_ARC_N32_ME",
+ "R_ARC_SECTOFF_ME",
+ "R_ARC_SDA32_ME", /* 30 */
+ "R_ARC_W_ME",
+ "R_ARC_H30_ME",
+ "R_ARC_SECTOFF_U8",
+ "R_ARC_SECTOFF_S9",
+ "R_AC_SECTOFF_U8", /* 35 */
+ "R_AC_SECTOFF_U8_1",
+ "R_AC_SECTOFF_U8_2",
+ "R_AC_SECTOFF_S9",
+ "R_AC_SECTOFF_S9_1",
+ "R_AC_SECTOFF_S9_2", /* 40 */
+ "R_ARC_SECTOFF_ME_1",
+ "R_ARC_SECTOFF_ME_2",
+ "R_ARC_SECTOFF_1",
+ "R_ARC_SECTOFF_2",
+ "", /* 45 */
+ "",
+ "",
+ "",
+ "",
+ "R_ARC_PC32", /* 50 */
+ "R_ARC_GOTPC32",
+ "R_ARC_PLT32",
+ "R_ARC_COPY",
+ "R_ARC_GLOB_DAT",
+ "R_ARC_JMP_SLOT", /* 55 */
+ "R_ARC_RELATIVE",
+ "R_ARC_GOTOFF",
+ "R_ARC_GOTPC",
+ "R_ARC_GOT32",
+ "", /* 60 */
+ "",
+ "",
+ "",
+ "",
+ "", /* 65 */
+ "R_ARC_TLS_DTPMOD",
+ "R_ARC_TLS_DTPOFF",
+ "R_ARC_TLS_TPOFF",
+ "R_ARC_TLS_GD_GOT",
+ "R_ARC_TLS_GD_LD", /* 70 */
+ "R_ARC_TLS_GD_CALL",
+ "R_ARC_TLS_IE_GOT",
+ "",
+ "",
+};
diff --git a/ldso/ldso/arc/dl-startup.h b/ldso/ldso/arc/dl-startup.h
new file mode 100644
index 000000000..ef89b5317
--- /dev/null
+++ b/ldso/ldso/arc/dl-startup.h
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+/*
+ * vineetg: Refactoring/cleanup of loader entry point
+ * Removed 6 useless insns
+ * Joern Improved it even further:
+ * -better insn scheduling
+ * -no need for conditional code for _dl_skip_args
+ * -use of assembler .&2 expressions vs. @gotpc refs (avoids need for GP)
+ *
+ * What this code does:
+ * -ldso starts execution here when kernel returns from execve()
+ * -calls into generic ldso entry point _dl_start( )
+ * -optionally adjusts argc for executable if exec passed as cmd
+ * -calls into app main with address of finaliser
+ */
+__asm__(
+ ".section .text \n"
+ ".align 4 \n"
+ ".global _start \n"
+ ".hidden _start \n"
+ ".type _start,@function \n"
+
+ "_start: \n"
+ " ; ldso entry point, returns app entry point \n"
+ " bl.d _dl_start \n"
+ " mov_s r0, sp ; pass ptr to aux vector tbl \n"
+
+ " ; If ldso ran as cmd with executable file nm as arg \n"
+ " ; skip the extra args calc by dl_start() \n"
+ " ld_s r1, [sp] ; orig argc from aux-vec Tbl \n"
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ " ld r12, [pcl, _dl_skip_args@pcl] \n"
+
+ " add r2, pcl, _dl_fini@pcl ; finalizer \n"
+#else
+ " add r12, pcl, _dl_skip_args-.+(.&2) \n"
+ " ld r12, [r12] \n"
+ " add r2, pcl, _dl_fini-.+(.&2) ; finalizer \n"
+#endif
+
+ " add2 sp, sp, r12 ; discard argv entries from stack\n"
+ " sub_s r1, r1, r12 ; adjusted argc, on stack \n"
+ " st_s r1, [sp] \n"
+
+ " j_s.d [r0] ; app entry point \n"
+ " mov_s r0, r2 ; ptr to finalizer _dl_fini \n"
+
+ ".size _start,.-_start \n"
+ ".previous \n"
+);
+
+/*
+ * Get a pointer to the argv array. On many platforms this can be just
+ * the address if the first argument, on other platforms we need to
+ * do something a little more subtle here.
+ */
+#define GET_ARGV(ARGVP, ARGS) ARGVP = ((unsigned long*) ARGS + 1)
+
+/*
+ * Dynamic loader bootstrapping:
+ * Since we don't modify text at runtime, these can only be data relos
+ * (so safe to assume that they are word aligned).
+ * And also they HAVE to be RELATIVE relos only
+ * @RELP is the relo entry being processed
+ * @REL is the pointer to the address we are relocating.
+ * @SYMBOL is the symbol involved in the relocation
+ * @LOAD is the load address.
+ */
+
+#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB) \
+do { \
+ int type = ELF32_R_TYPE((RELP)->r_info); \
+ if (likely(type == R_ARC_RELATIVE)) \
+ *REL += (unsigned long) LOAD; \
+ else \
+ _dl_exit(1); \
+}while(0)
+
+/*
+ * This will go away once we have DT_RELACOUNT
+ */
+#define ARCH_NEEDS_BOOTSTRAP_RELOCS
+
+/* we dont need to spit out argc, argv etc for debugging */
+#define NO_EARLY_SEND_STDERR 1
diff --git a/ldso/ldso/arc/dl-syscalls.h b/ldso/ldso/arc/dl-syscalls.h
new file mode 100644
index 000000000..a3cbb011b
--- /dev/null
+++ b/ldso/ldso/arc/dl-syscalls.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.
+ */
+
+/* stub for arch-specific syscall issues */
diff --git a/ldso/ldso/arc/dl-sysdep.h b/ldso/ldso/arc/dl-sysdep.h
new file mode 100644
index 000000000..b6bda9d14
--- /dev/null
+++ b/ldso/ldso/arc/dl-sysdep.h
@@ -0,0 +1,175 @@
+/*
+ * 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 "elf.h"
+
+/*
+ * Define this if the system uses RELOCA.
+ */
+#define ELF_USES_RELOCA
+
+/*
+ * Dynamic Linking ABI for ARCompact ISA
+ *
+ * PLT
+ * --------------------------------
+ * | ld r11, [pcl, off-to-GOT[1] | 0 (20 bytes)
+ * | | 4
+ * plt0 | ld r10, [pcl, off-to-GOT[2] | 8
+ * | | 12
+ * | j [r10] | 16
+ * --------------------------------
+ * | Base address of GOT | 20
+ * --------------------------------
+ * | ld r12, [pcl, off-to-GOT[3] | 24 (12 bytes each)
+ * plt1 | |
+ * | j_s.d [r12] | 32
+ * | mov_s r12, pcl | 34
+ * --------------------------------
+ * | | 36
+ * ~ ~
+ * ~ ~
+ * | |
+ * --------------------------------
+ *
+ * GOT
+ * --------------
+ * | [0] |
+ * --------------
+ * | [1] | Module info - setup by ldso
+ * --------------
+ * | [2] | resolver entry point
+ * --------------
+ * | [3] |
+ * | ... | Runtime address for function symbols
+ * | [f] |
+ * --------------
+ * | [f+1] |
+ * | ... | Runtime address for data symbols
+ * | [last] |
+ * --------------
+ */
+
+/*
+ * Initialization sequence for a GOT.
+ * Caller elf_resolve() seeds @GOT_BASE from DT_PLTGOT - which essentially is
+ * pointer to first PLT entry. The actual GOT base is 5th word in PLT
+ *
+ */
+#define INIT_GOT(GOT_BASE,MODULE) \
+do { \
+ unsigned long *__plt_base = (unsigned long *)GOT_BASE; \
+ GOT_BASE = (unsigned long *)(__plt_base[5] + \
+ (unsigned long)MODULE->loadaddr); \
+ GOT_BASE[1] = (unsigned long) MODULE; \
+ GOT_BASE[2] = (unsigned long) _dl_linux_resolve; \
+} while(0)
+
+/* Here we define the magic numbers that this dynamic loader should accept */
+#ifdef __A7__
+#define MAGIC1 EM_ARCOMPACT
+#define ELF_TARGET "ARCompact" /* For error messages */
+#elif defined(__HS__)
+#define MAGIC1 EM_ARCV2
+#define ELF_TARGET "ARCv2" /* For error messages */
+#endif
+
+#undef MAGIC2
+
+
+struct elf_resolve;
+extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt,
+ unsigned int plt_pc);
+
+extern unsigned __udivmodsi4(unsigned, unsigned) attribute_hidden;
+
+#ifdef __A7__
+/* using "C" causes an indirection via __umodsi3 -> __udivmodsi4 */
+#define do_rem(result, n, base) ((result) = \
+ \
+ __builtin_constant_p (base) ? (n) % (unsigned) (base) : \
+ __extension__ ({ \
+ register unsigned r1 __asm__ ("r1") = (base); \
+ \
+ __asm__("bl.d @__udivmodsi4` mov r0,%1" \
+ : "=r" (r1) \
+ : "r" (n), "r" (r1) \
+ : "r0", "r2", "r3", "r4", "lp_count", "blink", "cc"); \
+ \
+ r1; \
+ }) \
+)
+#elif defined(__HS__)
+/* ARCv2 has hardware assisted divide/mod */
+#define do_rem(result, n, base) ((result) = (n) % (unsigned) (base))
+#endif
+
+/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry or
+ TLS variable so PLT entries should not be allowed to define the value.
+
+ ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one
+ of the main executable's symbols, as for a COPY reloc. */
+#define elf_machine_type_class(type) \
+ ((((type) == R_ARC_JMP_SLOT || (type) == R_ARC_TLS_DTPMOD || \
+ (type) == R_ARC_TLS_DTPOFF || (type) == R_ARC_TLS_TPOFF) \
+ * ELF_RTYPE_CLASS_PLT) \
+ | (((type) == R_ARC_COPY) * ELF_RTYPE_CLASS_COPY))
+
+/*
+ * Get the runtime address of GOT[0]
+ */
+static __always_inline Elf32_Addr elf_machine_dynamic(void)
+{
+ Elf32_Addr dyn;
+
+ __asm__("ld %0,[pcl,_DYNAMIC@gotpc]\n\t" : "=r" (dyn));
+ return dyn;
+}
+
+/* Return the run-time load address of the shared object. */
+static __always_inline Elf32_Addr elf_machine_load_address(void)
+{
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ /* To find the loadaddr we subtract the runtime addr of a non-local symbol
+ * say _DYNAMIC from it's build-time addr.
+ * N.B., gotpc loads get optimized by the linker if it finds the symbol
+ * is resolved locally.
+ * A more robust - and efficient - solution would be to use a symbol
+ * set by the linker. To make it actually save space, we'd have to
+ * suppress the unwanted text relocation in the linked dso, though.
+ * (I.e. in ldso.so.*, though it's just another dso as far as bfd/ld
+ * are concerned.)
+ */
+ Elf32_Addr addr, tmp;
+ __asm__ (
+ "ld %1, [pcl, _DYNAMIC@gotpc] ;build addr of _DYNAMIC" "\n"
+ "add %0, pcl, _DYNAMIC@pcl ;runtime addr of _DYNAMIC" "\n"
+ "sub %0, %0, %1 ;delta" "\n"
+ : "=&r" (addr), "=r"(tmp)
+ );
+#else
+ Elf32_Addr addr, tmp;
+ __asm__ (
+ "ld %1, [pcl, _dl_start@gotpc] ;build addr of _dl_start \n"
+ "add %0, pcl, _dl_start-.+(.&2) ;runtime addr of _dl_start \n"
+ "sub %0, %0, %1 ;delta \n"
+ : "=&r" (addr), "=r"(tmp)
+ );
+#endif
+ return addr;
+}
+
+static __always_inline void
+elf_machine_relative (Elf32_Addr load_off, const Elf32_Addr rel_addr,
+ Elf32_Word relative_count)
+{
+ Elf32_Rel * rpnt = (void *) rel_addr;
+ --rpnt;
+ do {
+ Elf32_Addr *const reloc_addr = (void *) (load_off + (++rpnt)->r_offset);
+ *reloc_addr += load_off;
+ } while (--relative_count);
+}
diff --git a/ldso/ldso/arc/elfinterp.c b/ldso/ldso/arc/elfinterp.c
new file mode 100644
index 000000000..2f0cf7f66
--- /dev/null
+++ b/ldso/ldso/arc/elfinterp.c
@@ -0,0 +1,311 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Lots of code copied from ../i386/elfinterp.c, so:
+ * Copyright (c) 1994-2000 Eric Youngdale, Peter MacDonald,
+ * David Engel, Hongjiu Lu and Mitch D'Souza
+ * Copyright (C) 2001-2002, Erik Andersen
+ * All rights reserved.
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+#include "ldso.h"
+
+#ifdef __A7__
+#define ARC_PLT_SIZE 12
+#else
+#define ARC_PLT_SIZE 16
+#endif
+
+unsigned long
+_dl_linux_resolver(struct elf_resolve *tpnt, unsigned int plt_pc)
+{
+ ELF_RELOC *this_reloc, *rel_base;
+ char *strtab, *symname, *new_addr;
+ ElfW(Sym) *symtab;
+ int symtab_index;
+ unsigned int *got_addr;
+ unsigned long plt_base;
+ int plt_idx;
+
+ /* start of .rela.plt */
+ rel_base = (ELF_RELOC *)(tpnt->dynamic_info[DT_JMPREL]);
+
+ /* starts of .plt (addr of PLT0) */
+ plt_base = tpnt->dynamic_info[DT_PLTGOT];
+
+ /*
+ * compute the idx of the yet-unresolved PLT entry in .plt
+ * Same idx will be used to find the relo entry in .rela.plt
+ */
+ plt_idx = (plt_pc - plt_base)/ARC_PLT_SIZE - 2; /* ignoring 2 dummy PLTs */
+
+ this_reloc = rel_base + plt_idx;
+
+ symtab_index = ELF_R_SYM(this_reloc->r_info);
+ symtab = (ElfW(Sym) *)(intptr_t) (tpnt->dynamic_info[DT_SYMTAB]);
+ strtab = (char *) (tpnt->dynamic_info[DT_STRTAB]);
+ symname= strtab + symtab[symtab_index].st_name;
+
+ /* relo-offset to fixup, shd be a .got entry */
+ got_addr = (unsigned int *)(this_reloc->r_offset + tpnt->loadaddr);
+
+ /* Get the address of the GOT entry */
+ new_addr = _dl_find_hash(symname, &_dl_loaded_modules->symbol_scope, tpnt,
+ ELF_RTYPE_CLASS_PLT, NULL);
+
+ if (unlikely(!new_addr)) {
+ _dl_dprintf(2, "%s: can't resolve symbol '%s'\n", _dl_progname, symname);
+ _dl_exit(1);
+ }
+
+
+#if defined __SUPPORT_LD_DEBUG__
+ if (_dl_debug_bindings) {
+ _dl_dprintf(_dl_debug_file, "\nresolve function: %s", symname);
+ if (_dl_debug_detail)
+ _dl_dprintf(_dl_debug_file, "\n\tpatched %x ==> %pc @ %pl\n",
+ *got_addr, new_addr, got_addr);
+ }
+
+ if (!_dl_debug_nofixups)
+ *got_addr = (unsigned int)new_addr;
+#else
+ /* Update the .got entry with the runtime address of symbol */
+ *got_addr = (unsigned int)new_addr;
+#endif
+
+ /*
+ * Return the new addres, where the asm trampoline will jump to
+ * after re-setting up the orig args
+ */
+ return (unsigned long) new_addr;
+}
+
+
+static int
+_dl_do_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
+ ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
+{
+ int reloc_type;
+ int symtab_index;
+ char *symname;
+ unsigned long *reloc_addr;
+ unsigned long symbol_addr;
+#if defined __SUPPORT_LD_DEBUG__
+ unsigned long old_val = 0;
+#endif
+ struct symbol_ref sym_ref;
+ struct elf_resolve *tls_tpnt = NULL;
+
+ reloc_addr = (unsigned long *)(tpnt->loadaddr + rpnt->r_offset);
+ reloc_type = ELF_R_TYPE(rpnt->r_info);
+ symtab_index = ELF_R_SYM(rpnt->r_info);
+ symbol_addr = 0;
+
+ sym_ref.sym = &symtab[symtab_index];
+ sym_ref.tpnt = NULL;
+
+#if defined __SUPPORT_LD_DEBUG__
+ if (reloc_addr)
+ old_val = *reloc_addr;
+#endif
+
+ if (symtab_index) {
+ symname = strtab + symtab[symtab_index].st_name;
+ symbol_addr = (unsigned long) _dl_find_hash(symname, scope, tpnt,
+ elf_machine_type_class(reloc_type), &sym_ref);
+
+ /*
+ * We want to allow undefined references to weak symbols,
+ * this might have been intentional. We should not be linking
+ * local symbols here, so all bases should be covered.
+ */
+
+ if (unlikely(!symbol_addr
+ && ELF_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK
+ && ELF_ST_TYPE(symtab[symtab_index].st_info) != STT_TLS)) {
+ /* Non-fatal if called from dlopen, hence different ret code */
+ return 1;
+ }
+
+ tls_tpnt = sym_ref.tpnt;
+ } else if (reloc_type == R_ARC_RELATIVE ) {
+ *reloc_addr += tpnt->loadaddr;
+ goto log_entry;
+ }
+
+#if defined USE_TLS && USE_TLS
+ /* In case of a TLS reloc, tls_tpnt NULL means we have an 'anonymous'
+ symbol. This is the case for a static tls variable, so the lookup
+ module is just that one is referencing the tls variable. */
+ if (!tls_tpnt)
+ tls_tpnt = tpnt;
+#endif
+
+ switch (reloc_type) {
+ case R_ARC_NONE:
+ break;
+ case R_ARC_32:
+ *reloc_addr += symbol_addr + rpnt->r_addend;
+ break;
+ case R_ARC_PC32:
+ *reloc_addr += symbol_addr + rpnt->r_addend - (unsigned long) reloc_addr;
+ break;
+ case R_ARC_GLOB_DAT:
+ case R_ARC_JMP_SLOT:
+ *reloc_addr = symbol_addr;
+ break;
+ case R_ARC_COPY:
+ _dl_memcpy((void *) reloc_addr,(void *) symbol_addr,
+ symtab[symtab_index].st_size);
+ break;
+#if defined USE_TLS && USE_TLS
+ case R_ARC_TLS_DTPMOD:
+ *reloc_addr = tls_tpnt->l_tls_modid;
+ break;
+ case R_ARC_TLS_DTPOFF:
+ *reloc_addr = symbol_addr;
+ break;
+ case R_ARC_TLS_TPOFF:
+ CHECK_STATIC_TLS ((struct link_map *) tls_tpnt);
+ *reloc_addr = tls_tpnt->l_tls_offset + symbol_addr + rpnt->r_addend;
+ break;
+#endif
+ default:
+ return -1;
+ }
+
+log_entry:
+#if defined __SUPPORT_LD_DEBUG__
+ if (_dl_debug_detail)
+ _dl_dprintf(_dl_debug_file,"\tpatched: %lx ==> %lx @ %pl: addend %x ",
+ old_val, *reloc_addr, reloc_addr, rpnt->r_addend);
+#endif
+
+ return 0;
+}
+
+static int
+_dl_do_lazy_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
+ ELF_RELOC *rpnt)
+{
+ int reloc_type;
+ unsigned long *reloc_addr;
+#if defined __SUPPORT_LD_DEBUG__
+ unsigned long old_val;
+#endif
+
+ reloc_addr = (unsigned long *)(tpnt->loadaddr + rpnt->r_offset);
+ reloc_type = ELF_R_TYPE(rpnt->r_info);
+
+#if defined __SUPPORT_LD_DEBUG__
+ old_val = *reloc_addr;
+#endif
+
+ switch (reloc_type) {
+ case R_ARC_NONE:
+ break;
+ case R_ARC_JMP_SLOT:
+ *reloc_addr += tpnt->loadaddr;
+ break;
+ default:
+ return -1;
+ }
+
+#if defined __SUPPORT_LD_DEBUG__
+ if (_dl_debug_reloc && _dl_debug_detail)
+ _dl_dprintf(_dl_debug_file, "\tpatched: %lx ==> %lx @ %pl\n",
+ old_val, *reloc_addr, reloc_addr);
+#endif
+
+ return 0;
+}
+
+#define ___DO_LAZY 1
+#define ___DO_NOW 2
+
+static int _dl_parse(struct elf_resolve *tpnt, struct r_scope_elem *scope,
+ unsigned long rel_addr, unsigned long rel_size, int type)
+{
+ unsigned int i;
+ char *strtab;
+ ElfW(Sym) *symtab;
+ ELF_RELOC *rpnt;
+ int symtab_index;
+ int res = 0;
+
+ /* Now parse the relocation information */
+ rpnt = (ELF_RELOC *)(intptr_t) (rel_addr);
+ rel_size = rel_size / sizeof(ELF_RELOC);
+
+ symtab = (ElfW(Sym) *)(intptr_t) (tpnt->dynamic_info[DT_SYMTAB]);
+ strtab = (char *) (tpnt->dynamic_info[DT_STRTAB]);
+
+ for (i = 0; i < rel_size; i++, rpnt++) {
+
+ symtab_index = ELF_R_SYM(rpnt->r_info);
+
+ debug_sym(symtab,strtab,symtab_index);
+ debug_reloc(symtab,strtab,rpnt);
+
+ /* constant propagation subsumes the 'if' */
+ if (type == ___DO_LAZY)
+ res = _dl_do_lazy_reloc(tpnt, scope, rpnt);
+ else
+ res = _dl_do_reloc(tpnt, scope, rpnt, symtab, strtab);
+
+ if (res != 0)
+ break;
+ }
+
+ if (unlikely(res != 0)) {
+ if (res < 0) {
+ int reloc_type = ELF_R_TYPE(rpnt->r_info);
+#if defined __SUPPORT_LD_DEBUG__
+ _dl_dprintf(2, "can't handle reloc type %s\n ",
+ _dl_reltypes(reloc_type));
+#else
+ _dl_dprintf(2, "can't handle reloc type %x\n",
+ reloc_type);
+#endif
+ _dl_exit(-res);
+ } else {
+ _dl_dprintf(2, "can't resolve symbol\n");
+ /* Fall thru to return res */
+ }
+ }
+
+ return res;
+}
+
+void
+_dl_parse_lazy_relocation_information(struct dyn_elf *rpnt,
+ unsigned long rel_addr,
+ unsigned long rel_size)
+{
+ /* This func is called for processing .rela.plt of loaded module(s)
+ * The relo entries handled are JMP_SLOT type for fixing up .got slots
+ * for external function calls.
+ * This function doesn't resolve the slots: that is done lazily at
+ * runtime. The build linker (at least thats what happens for ARC) had
+ * pre-init the .got slots to point to PLT0. All that is done here is
+ * to fix them up to point to load value of PLT0 (as opposed to the
+ * build value).
+ * On ARC, the loadaddr of dyn exec is zero, thus elfaddr == loadaddr
+ * Thus there is no point in adding "0" to values and un-necessarily
+ * stir up the caches and TLB.
+ * For ldso processing busybox binary, this skips over 380 relo entries
+ */
+ if (rpnt->dyn->loadaddr != 0)
+ _dl_parse(rpnt->dyn, NULL, rel_addr, rel_size, ___DO_LAZY);
+}
+
+int
+_dl_parse_relocation_information(struct dyn_elf *rpnt,
+ struct r_scope_elem *scope,
+ unsigned long rel_addr,
+ unsigned long rel_size)
+{
+ return _dl_parse(rpnt->dyn, scope, rel_addr, rel_size, ___DO_NOW);
+}
diff --git a/ldso/ldso/arc/resolve.S b/ldso/ldso/arc/resolve.S
new file mode 100644
index 000000000..891f66b97
--- /dev/null
+++ b/ldso/ldso/arc/resolve.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 <sysdep.h>
+#include <sys/syscall.h>
+
+; Save the registers which resolver could possibly clobber
+; r0-r9: args to the function - symbol being resolved
+; r10-r12 are already clobbered by PLTn, PLT0 thus neednot be saved
+
+.macro SAVE_CALLER_SAVED
+ push_s r0
+ push_s r1
+ push_s r2
+ push_s r3
+ st.a r4, [sp, -4]
+ st.a r5, [sp, -4]
+ st.a r6, [sp, -4]
+ st.a r7, [sp, -4]
+ st.a r8, [sp, -4]
+ st.a r9, [sp, -4]
+ push_s blink
+.endm
+
+.macro RESTORE_CALLER_SAVED_BUT_R0
+ ld.ab blink,[sp, 4]
+ ld.ab r9, [sp, 4]
+ ld.ab r8, [sp, 4]
+ ld.ab r7, [sp, 4]
+ ld.ab r6, [sp, 4]
+ ld.ab r5, [sp, 4]
+ ld.ab r4, [sp, 4]
+ pop_s r3
+ pop_s r2
+ pop_s r1
+.endm
+
+; Upon entry, PLTn, which led us here, sets up the following regs
+; r11 = Module info (tpnt pointer as expected by resolver)
+; r12 = PC of the PLTn itself - needed by resolver to find
+; corresponding .rela.plt entry
+
+ENTRY(_dl_linux_resolve)
+ ; args to func being resolved, which resolver might clobber
+ SAVE_CALLER_SAVED
+
+ mov_s r1, r12
+ bl.d _dl_linux_resolver
+ mov r0, r11
+
+ RESTORE_CALLER_SAVED_BUT_R0
+ j_s.d [r0] ; r0 has resolved function addr
+ pop_s r0 ; restore first arg to resolved call
+END(_dl_linux_resolve)
diff --git a/ldso/ldso/arm/aeabi_read_tp.S b/ldso/ldso/arm/aeabi_read_tp.S
new file mode 100644
index 000000000..77e0d6ecc
--- /dev/null
+++ b/ldso/ldso/arm/aeabi_read_tp.S
@@ -0,0 +1,62 @@
+/* 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.
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <features.h>
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+
+#include <sysdep.h>
+
+/* GCC will emit calls to this routine under -mtp=soft. Linux has an
+ equivalent helper function (which clobbers fewer registers than
+ a normal function call) in a high page of memory; tail call to the
+ helper.
+
+ This function is exported from libc for use by user code. libpthread, librt,
+ and the dynamic linker get their own private copies, for
+ performance (and in the case of ld.so, out of necessity); those are
+ all hidden. */
+
+#ifndef NOT_IN_libc
+ .global __aeabi_read_tp
+#else
+ .hidden __aeabi_read_tp
+#endif
+ENTRY (__aeabi_read_tp)
+ mov r0, #0xffff0fff
+ sub pc, r0, #31
+END (__aeabi_read_tp)
+
+#endif /* __UCLIBC_HAS_THREADS_NATIVE__ */
+
diff --git a/ldso/ldso/arm/dl-debug.h b/ldso/ldso/arm/dl-debug.h
index d5103202c..af14eca2d 100644
--- a/ldso/ldso/arm/dl-debug.h
+++ b/ldso/ldso/arm/dl-debug.h
@@ -27,18 +27,20 @@
* SUCH DAMAGE.
*/
-static const char *_dl_reltypes_tab[] =
+static const char * const _dl_reltypes_tab[] =
{
[0] "R_ARM_NONE", "R_ARM_PC24", "R_ARM_ABS32", "R_ARM_REL32",
[4] "R_ARM_PC13", "R_ARM_ABS16", "R_ARM_ABS12", "R_ARM_THM_ABS5",
[8] "R_ARM_ABS8", "R_ARM_SBREL32","R_ARM_THM_PC22", "R_ARM_THM_PC8",
[12] "R_ARM_AMP_VCALL9", "R_ARM_SWI24", "R_ARM_THM_SWI8", "R_ARM_XPC25",
- [16] "R_ARM_THM_XPC22",
+ [16] "R_ARM_THM_XPC22", "R_ARM_TLS_DTPMOD32", "R_ARM_TLS_DTPOFF32", "R_ARM_TLS_TPOFF32",
[20] "R_ARM_COPY", "R_ARM_GLOB_DAT","R_ARM_JUMP_SLOT", "R_ARM_RELATIVE",
[24] "R_ARM_GOTOFF", "R_ARM_GOTPC", "R_ARM_GOT32", "R_ARM_PLT32",
[32] "R_ARM_ALU_PCREL_7_0","R_ARM_ALU_PCREL_15_8","R_ARM_ALU_PCREL_23_15","R_ARM_LDR_SBREL_11_0",
[36] "R_ARM_ALU_SBREL_19_12","R_ARM_ALU_SBREL_27_20",
[100] "R_ARM_GNU_VTENTRY","R_ARM_GNU_VTINHERIT","R_ARM_THM_PC11","R_ARM_THM_PC9",
+ [104] "R_ARM_TLS_GD32","R_ARM_TLS_LDM32","R_ARM_TLS_LDO32","R_ARM_TLS_IE32",
+ [108] "R_ARM_TLS_LE32","R_ARM_TLS_LDO12","R_ARM_TLS_LE12","R_ARM_TLS_IE12GP",
[249] "R_ARM_RXPC25", "R_ARM_RSBREL32", "R_ARM_THM_RPC22", "R_ARM_RREL32",
[253] "R_ARM_RABS22", "R_ARM_RPC24", "R_ARM_RBASE",
};
diff --git a/ldso/ldso/arm/dl-startup.h b/ldso/ldso/arm/dl-startup.h
index 43985d002..eb2a9a22a 100644
--- a/ldso/ldso/arm/dl-startup.h
+++ b/ldso/ldso/arm/dl-startup.h
@@ -7,12 +7,14 @@
*/
#include <features.h>
+#include <bits/arm_bx.h>
#if !defined(__thumb__)
__asm__(
" .text\n"
" .globl _start\n"
" .type _start,%function\n"
+ " .hidden _start\n"
"_start:\n"
" @ at start time, all the args are on the stack\n"
" mov r0, sp\n"
@@ -45,11 +47,7 @@ __asm__(
" ldr r0, .L_FINI_PROC\n"
" ldr r0, [sl, r0]\n"
" @ jump to the user_s entry point\n"
-#if defined(__USE_BX__)
- " bx r6\n"
-#else
- " mov pc, r6\n"
-#endif
+ " " __stringify(BX(r6)) "\n"
".L_GET_GOT:\n"
" .word _GLOBAL_OFFSET_TABLE_ - .L_GOT_GOT - 4\n"
".L_SKIP_ARGS:\n"
@@ -111,11 +109,7 @@ __asm__(
" ldr r0, .L_FINI_PROC\n"
" ldr r0, [r7, r0]\n"
" @ jump to the user_s entry point\n"
-#if defined(__USE_BX__)
- " bx r6\n"
-#else
- " mov pc, r6\n"
-#endif
+ " " __stringify(BX(r6)) "\n"
"\n\n"
".L_GET_GOT:\n"
" .word _GLOBAL_OFFSET_TABLE_ - .L_GOT_GOT - 4\n"
@@ -131,16 +125,16 @@ __asm__(
/* Get a pointer to the argv array. On many platforms this can be just
- * the address if the first argument, on other platforms we need to
+ * the address of the first argument, on other platforms we need to
* do something a little more subtle here. */
#define GET_ARGV(ARGVP, ARGS) ARGVP = (((unsigned long*)ARGS)+1)
/* Handle relocation of the symbols in the dynamic loader. */
-static inline
+static __always_inline
void PERFORM_BOOTSTRAP_RELOC(ELF_RELOC *rpnt, unsigned long *reloc_addr,
unsigned long symbol_addr, unsigned long load_addr, Elf32_Sym *symtab)
{
- switch (ELF32_R_TYPE(rpnt->r_info)) {
+ switch (ELF_R_TYPE(rpnt->r_info)) {
case R_ARM_NONE:
break;
case R_ARM_ABS32:
@@ -159,7 +153,7 @@ void PERFORM_BOOTSTRAP_RELOC(ELF_RELOC *rpnt, unsigned long *reloc_addr,
if (topbits != 0xfe000000 && topbits != 0x00000000)
{
#if 0
- // Don't bother with this during ldso initilization...
+ /* Don't bother with this during ldso initilization... */
newvalue = fix_bad_pc24(reloc_addr, symbol_addr)
- (unsigned long)reloc_addr + (addend << 2);
topbits = newvalue & 0xfe000000;
diff --git a/ldso/ldso/arm/dl-syscalls.h b/ldso/ldso/arm/dl-syscalls.h
index 1c0e6699e..195461f83 100644
--- a/ldso/ldso/arm/dl-syscalls.h
+++ b/ldso/ldso/arm/dl-syscalls.h
@@ -1,9 +1,3 @@
-/* We can't use the real errno in ldso, since it has not yet
- * been dynamicly linked in yet. */
-#include "sys/syscall.h"
-extern int _dl_errno;
-#undef __set_errno
-#define __set_errno(X) {(_dl_errno) = (X);}
/* _call_via_rX calls are used in thumb ldso because of calls via
* function pointers, but ldso is not linked with anything which
* provides them, so define them here (only required for thumb).
diff --git a/ldso/ldso/arm/dl-sysdep.h b/ldso/ldso/arm/dl-sysdep.h
index 2f9a37f8f..dc89710c6 100644
--- a/ldso/ldso/arm/dl-sysdep.h
+++ b/ldso/ldso/arm/dl-sysdep.h
@@ -5,6 +5,9 @@
* Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.org>
*/
+#ifndef _ARCH_DL_SYSDEP
+#define _ARCH_DL_SYSDEP
+
/* Define this if the system uses RELOCA. */
#undef ELF_USES_RELOCA
#include <elf.h>
@@ -15,7 +18,7 @@
GOT_BASE[1] = (unsigned long) MODULE; \
}
-static __inline__ unsigned long arm_modulus(unsigned long m, unsigned long p)
+static __always_inline unsigned long arm_modulus(unsigned long m, unsigned long p)
{
unsigned long i,t,inc;
i=p; t=0;
@@ -55,24 +58,23 @@ static __inline__ unsigned long arm_modulus(unsigned long m, unsigned long p)
struct elf_resolve;
unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
-/* 4096 bytes alignment */
-#define PAGE_ALIGN 0xfffff000
-#define ADDR_ALIGN 0xfff
-#define OFFS_ALIGN 0x7ffff000
+/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry or
+ TLS variable, so undefined references should not be allowed to
+ define the value.
-/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry, so
- PLT entries should not be allowed to define the value.
ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one
of the main executable's symbols, as for a COPY reloc. */
-#define elf_machine_type_class(type) \
- ((((type) == R_ARM_JUMP_SLOT) * ELF_RTYPE_CLASS_PLT) \
+#define elf_machine_type_class(type) \
+ ((((type) == R_ARM_JUMP_SLOT || (type) == R_ARM_TLS_DTPMOD32 \
+ || (type) == R_ARM_TLS_DTPOFF32 || (type) == R_ARM_TLS_TPOFF32) \
+ * ELF_RTYPE_CLASS_PLT) \
| (((type) == R_ARM_COPY) * ELF_RTYPE_CLASS_COPY))
/* Return the link-time address of _DYNAMIC. Conveniently, this is the
first element of the GOT. We used to use the PIC register to do this
without a constant pool reference, but GCC 4.2 will use a pseudo-register
for the PIC base, so it may not be in r10. */
-static __inline__ Elf32_Addr __attribute__ ((unused))
+static __always_inline Elf32_Addr __attribute__ ((unused))
elf_machine_dynamic (void)
{
Elf32_Addr dynamic;
@@ -103,11 +105,12 @@ elf_machine_dynamic (void)
return dynamic;
}
+extern char __dl_start[] __asm__("_dl_start");
+
/* Return the run-time load address of the shared object. */
-static __inline__ Elf32_Addr __attribute__ ((unused))
+static __always_inline Elf32_Addr __attribute__ ((unused))
elf_machine_load_address (void)
{
- extern void __dl_start __asm__ ("_dl_start");
Elf32_Addr got_addr = (Elf32_Addr) &__dl_start;
Elf32_Addr pcrel_addr;
#if defined __OPTIMIZE__ && !defined __thumb__
@@ -128,7 +131,7 @@ elf_machine_load_address (void)
return pcrel_addr - got_addr;
}
-static __inline__ void
+static __always_inline void
elf_machine_relative (Elf32_Addr load_off, const Elf32_Addr rel_addr,
Elf32_Word relative_count)
{
@@ -140,3 +143,8 @@ elf_machine_relative (Elf32_Addr load_off, const Elf32_Addr rel_addr,
*reloc_addr += load_off;
} while (--relative_count);
}
+#endif /* !_ARCH_DL_SYSDEP */
+
+#ifdef __ARM_EABI__
+#define DL_MALLOC_ALIGN 8 /* EABI needs 8 byte alignment for STRD LDRD */
+#endif
diff --git a/ldso/ldso/arm/elfinterp.c b/ldso/ldso/arm/elfinterp.c
index 37531126a..2043263ec 100644
--- a/ldso/ldso/arm/elfinterp.c
+++ b/ldso/ldso/arm/elfinterp.c
@@ -44,50 +44,42 @@ extern int _dl_linux_resolve(void);
unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
{
- int reloc_type;
ELF_RELOC *this_reloc;
char *strtab;
char *symname;
- Elf32_Sym *symtab;
+ ElfW(Sym) *symtab;
ELF_RELOC *rel_addr;
int symtab_index;
- char *new_addr;
+ unsigned long new_addr;
char **got_addr;
unsigned long instr_addr;
rel_addr = (ELF_RELOC *) tpnt->dynamic_info[DT_JMPREL];
this_reloc = rel_addr + reloc_entry;
- reloc_type = ELF32_R_TYPE(this_reloc->r_info);
- symtab_index = ELF32_R_SYM(this_reloc->r_info);
+ symtab_index = ELF_R_SYM(this_reloc->r_info);
- symtab = (Elf32_Sym *) tpnt->dynamic_info[DT_SYMTAB];
+ symtab = (ElfW(Sym) *) tpnt->dynamic_info[DT_SYMTAB];
strtab = (char *) tpnt->dynamic_info[DT_STRTAB];
symname = strtab + symtab[symtab_index].st_name;
- if (unlikely(reloc_type != R_ARM_JUMP_SLOT)) {
- _dl_dprintf(2, "%s: Incorrect relocation type in jump relocations\n",
- _dl_progname);
- _dl_exit(1);
- }
-
/* Address of jump instruction to fix up */
instr_addr = ((unsigned long) this_reloc->r_offset +
(unsigned long) tpnt->loadaddr);
got_addr = (char **) instr_addr;
/* Get the address of the GOT entry */
- new_addr = _dl_find_hash(symname, tpnt->symbol_scope,
- tpnt, ELF_RTYPE_CLASS_PLT);
+ new_addr = (unsigned long)_dl_find_hash(symname, &_dl_loaded_modules->symbol_scope,
+ tpnt, ELF_RTYPE_CLASS_PLT, NULL);
if (unlikely(!new_addr)) {
_dl_dprintf(2, "%s: can't resolve symbol '%s'\n",
_dl_progname, symname);
_dl_exit(1);
}
#if defined (__SUPPORT_LD_DEBUG__)
-#if !defined __SUPPORT_LD_DEBUG_EARLY__
+# if !defined __SUPPORT_LD_DEBUG_EARLY__
if ((unsigned long) got_addr < 0x40000000)
-#endif
+# endif
{
if (_dl_debug_bindings)
{
@@ -97,25 +89,25 @@ unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
}
}
if (!_dl_debug_nofixups) {
- *got_addr = new_addr;
+ *got_addr = (char *)new_addr;
}
#else
- *got_addr = new_addr;
+ *got_addr = (char *)new_addr;
#endif
- return (unsigned long) new_addr;
+ return new_addr;
}
static int
-_dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
+_dl_parse(struct elf_resolve *tpnt, struct r_scope_elem *scope,
unsigned long rel_addr, unsigned long rel_size,
- int (*reloc_fnc) (struct elf_resolve *tpnt, struct dyn_elf *scope,
- ELF_RELOC *rpnt, Elf32_Sym *symtab, char *strtab))
+ int (*reloc_fnc) (struct elf_resolve *tpnt, struct r_scope_elem *scope,
+ ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab))
{
int i;
char *strtab;
int goof = 0;
- Elf32_Sym *symtab;
+ ElfW(Sym) *symtab;
ELF_RELOC *rpnt;
int symtab_index;
@@ -123,13 +115,13 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
rpnt = (ELF_RELOC *) rel_addr;
rel_size = rel_size / sizeof(ELF_RELOC);
- symtab = (Elf32_Sym *) tpnt->dynamic_info[DT_SYMTAB];
+ symtab = (ElfW(Sym) *) tpnt->dynamic_info[DT_SYMTAB];
strtab = (char *) tpnt->dynamic_info[DT_STRTAB];
for (i = 0; i < rel_size; i++, rpnt++) {
int res;
- symtab_index = ELF32_R_SYM(rpnt->r_info);
+ symtab_index = ELF_R_SYM(rpnt->r_info);
debug_sym(symtab,strtab,symtab_index);
debug_reloc(symtab,strtab,rpnt);
@@ -145,7 +137,7 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
if (unlikely(res <0))
{
- int reloc_type = ELF32_R_TYPE(rpnt->r_info);
+ int reloc_type = ELF_R_TYPE(rpnt->r_info);
#if defined (__SUPPORT_LD_DEBUG__)
_dl_dprintf(2, "can't handle reloc type %s\n ", _dl_reltypes(reloc_type));
#else
@@ -189,35 +181,55 @@ fix_bad_pc24 (unsigned long *const reloc_addr, unsigned long value)
#endif
static int
-_dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
- ELF_RELOC *rpnt, Elf32_Sym *symtab, char *strtab)
+_dl_do_reloc (struct elf_resolve *tpnt,struct r_scope_elem *scope,
+ ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
{
int reloc_type;
int symtab_index;
+ char *symname;
unsigned long *reloc_addr;
unsigned long symbol_addr;
+ struct symbol_ref sym_ref;
+ struct elf_resolve *def_mod = 0;
int goof = 0;
reloc_addr = (unsigned long *) (tpnt->loadaddr + (unsigned long) rpnt->r_offset);
- reloc_type = ELF32_R_TYPE(rpnt->r_info);
- symtab_index = ELF32_R_SYM(rpnt->r_info);
+
+ reloc_type = ELF_R_TYPE(rpnt->r_info);
+ symtab_index = ELF_R_SYM(rpnt->r_info);
symbol_addr = 0;
+ sym_ref.sym = &symtab[symtab_index];
+ sym_ref.tpnt = NULL;
+ symname = strtab + symtab[symtab_index].st_name;
if (symtab_index) {
-
- symbol_addr = (unsigned long) _dl_find_hash(strtab + symtab[symtab_index].st_name,
- scope, tpnt, elf_machine_type_class(reloc_type));
+ symbol_addr = (unsigned long)_dl_find_hash(symname, scope, tpnt,
+ elf_machine_type_class(reloc_type), &sym_ref);
/*
* We want to allow undefined references to weak symbols - this might
* have been intentional. We should not be linking local symbols
* here, so all bases should be covered.
*/
- if (!symbol_addr && ELF32_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK) {
- _dl_dprintf (2, "%s: can't resolve symbol '%s'\n",
- _dl_progname, strtab + symtab[symtab_index].st_name);
- _dl_exit (1);
+ if (!symbol_addr && (ELF_ST_TYPE(symtab[symtab_index].st_info) != STT_TLS)
+ && (ELF_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK)) {
+ /* This may be non-fatal if called from dlopen. */
+ return 1;
+
+ }
+ if (_dl_trace_prelink) {
+ _dl_debug_lookup (symname, tpnt, &symtab[symtab_index],
+ &sym_ref, elf_machine_type_class(reloc_type));
}
+ def_mod = sym_ref.tpnt;
+ } else {
+ /*
+ * Relocs against STN_UNDEF are usually treated as using a
+ * symbol value of zero, and using the module containing the
+ * reloc itself.
+ */
+ symbol_addr = symtab[symtab_index].st_value;
+ def_mod = tpnt;
}
#if defined (__SUPPORT_LD_DEBUG__)
@@ -273,6 +285,20 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
_dl_memcpy((void *) reloc_addr,
(void *) symbol_addr, symtab[symtab_index].st_size);
break;
+#if defined USE_TLS && USE_TLS
+ case R_ARM_TLS_DTPMOD32:
+ *reloc_addr = def_mod->l_tls_modid;
+ break;
+
+ case R_ARM_TLS_DTPOFF32:
+ *reloc_addr += symbol_addr;
+ break;
+
+ case R_ARM_TLS_TPOFF32:
+ CHECK_STATIC_TLS ((struct link_map *) def_mod);
+ *reloc_addr += (symbol_addr + def_mod->l_tls_offset);
+ break;
+#endif
default:
return -1; /*call _dl_exit(1) */
}
@@ -287,14 +313,14 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
}
static int
-_dl_do_lazy_reloc (struct elf_resolve *tpnt, struct dyn_elf *scope,
- ELF_RELOC *rpnt, Elf32_Sym *symtab, char *strtab)
+_dl_do_lazy_reloc (struct elf_resolve *tpnt, struct r_scope_elem *scope,
+ ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
{
int reloc_type;
unsigned long *reloc_addr;
reloc_addr = (unsigned long *) (tpnt->loadaddr + (unsigned long) rpnt->r_offset);
- reloc_type = ELF32_R_TYPE(rpnt->r_info);
+ reloc_type = ELF_R_TYPE(rpnt->r_info);
#if defined (__SUPPORT_LD_DEBUG__)
{
@@ -326,8 +352,8 @@ void _dl_parse_lazy_relocation_information(struct dyn_elf *rpnt,
}
int _dl_parse_relocation_information(struct dyn_elf *rpnt,
- unsigned long rel_addr, unsigned long rel_size)
+ struct r_scope_elem *scope, unsigned long rel_addr, unsigned long rel_size)
{
- return _dl_parse(rpnt->dyn, rpnt->dyn->symbol_scope, rel_addr, rel_size, _dl_do_reloc);
+ return _dl_parse(rpnt->dyn, scope, rel_addr, rel_size, _dl_do_reloc);
}
diff --git a/ldso/ldso/arm/resolve.S b/ldso/ldso/arm/resolve.S
index b422c334d..7e0058e0d 100644
--- a/ldso/ldso/arm/resolve.S
+++ b/ldso/ldso/arm/resolve.S
@@ -90,14 +90,17 @@
* dl-startup.c).
*/
-#include <sys/syscall.h>
+#include <features.h>
#include <bits/arm_asm.h>
+#include <bits/arm_bx.h>
-#include <features.h>
+#define sl r10
+#define fp r11
+#define ip r12
.text
.align 4 @ 16 byte boundary and there are 32 bytes below (arm case)
- #if !defined(__thumb__) || defined(__thumb2__)
+#if 1 /*(!defined(__thumb__) || defined __THUMB_INTERWORK__) || defined(__thumb2__)*/
.arm
.globl _dl_linux_resolve
.type _dl_linux_resolve,%function
@@ -109,8 +112,8 @@ _dl_linux_resolve:
@ function must branch to the real function, and that expects
@ r0-r3 and lr to be as they were before the whole PLT stuff -
@ ip can be trashed.
- @ This routine is called after pushing lr, so we must push an odd
- @ number of words to keep the stack correctly aligned.
+ @ This routine is called after pushing lr, so we must push an odd
+ @ number of words to keep the stack correctly aligned.
stmdb sp!, {r0, r1, r2, r3, r4}
ldr r0, [lr, #-4] @ r0 : = [lr-4] (GOT_TABLE[1])
@@ -119,16 +122,12 @@ _dl_linux_resolve:
@ ~x = -x-1, therefore ~(r1>>2) = (-((lr-ip)>>2)-1)
@ = - ((lr-ip)/4) - 1 = (ip - lr - 4)/4, as required
- bl _dl_linux_resolver
+ bl _dl_linux_resolver
- mov ip, r0
+ mov ip, r0
ldmia sp!, {r0, r1, r2, r3, r4, lr}
-#if defined(__USE_BX__)
- bx ip
-#else
- mov pc,ip
-#endif
+ BX(ip)
#else
@ In the thumb case _dl_linux_resolver is thumb. If a bl is used
@ from arm code the linker will insert a stub call which, with
diff --git a/ldso/ldso/arm/thumb_atomics.S b/ldso/ldso/arm/thumb_atomics.S
new file mode 100644
index 000000000..f88da2b9c
--- /dev/null
+++ b/ldso/ldso/arm/thumb_atomics.S
@@ -0,0 +1,78 @@
+/* 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.
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <features.h>
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+
+#include <sysdep.h>
+
+#if defined __thumb__
+
+/* Out-of-line atomic operations that we can't do in Thumb mode.
+ This ends up in various libraries where it is needed (and
+ a few .a archives where it isn't). */
+
+ .hidden __thumb_swpb
+ENTRY (__thumb_swpb)
+ swpb r0, r0, [r1]
+ bx lr
+END (__thumb_swpb)
+
+ .hidden __thumb_swp
+ENTRY (__thumb_swp)
+ swp r0, r0, [r1]
+ bx lr
+END (__thumb_swp)
+
+ .hidden __thumb_cmpxchg
+ENTRY (__thumb_cmpxchg)
+ stmdb sp!, {r4, lr}
+ mov r4, r0
+0: ldr r3, [r2]
+ cmp r3, r4
+ bne 1f
+ mov r0, r4
+ mov r3, #0xffff0fff
+ mov lr, pc
+ add pc, r3, #(0xffff0fc0 - 0xffff0fff)
+ bcc 0b
+ mov r3, r4
+1: mov r0, r3
+ ldmia sp!, {r4, pc}
+END (__thumb_cmpxchg)
+
+#endif /* __thumb__ */
+#endif /* __UCLIBC_HAS_THREADS_NATIVE__ */
+
diff --git a/ldso/ldso/avr32/dl-debug.h b/ldso/ldso/avr32/dl-debug.h
index fe35539f6..44b0c01da 100644
--- a/ldso/ldso/avr32/dl-debug.h
+++ b/ldso/ldso/avr32/dl-debug.h
@@ -26,7 +26,7 @@
* SUCH DAMAGE.
*/
-static const char *_dl_reltypes_tab[] = {
+static const char * const _dl_reltypes_tab[] = {
"R_AVR32_NONE",
"R_AVR32_32", "R_AVR32_16", "R_AVR32_8",
"R_AVR32_32_PCREL", "R_AVR32_16_PCREL", "R_AVR32_8_PCREL",
diff --git a/ldso/ldso/avr32/dl-startup.h b/ldso/ldso/avr32/dl-startup.h
index 3b8bf4ce2..e49101955 100644
--- a/ldso/ldso/avr32/dl-startup.h
+++ b/ldso/ldso/avr32/dl-startup.h
@@ -12,6 +12,7 @@
__asm__(" .text\n"
" .global _start\n"
" .type _start,@function\n"
+ " .hidden _start\n"
"_start:\n"
/* All arguments are on the stack initially */
" mov r12, sp\n"
@@ -41,7 +42,7 @@ __asm__(" .text\n"
" .previous\n");
/* Get a pointer to the argv array. On many platforms this can be just
- * the address if the first argument, on other platforms we need to
+ * the address of the first argument, on other platforms we need to
* do something a little more subtle here. */
#define GET_ARGV(ARGVP, ARGS) ARGVP = ((unsigned long *)ARGS + 1)
@@ -75,7 +76,7 @@ void PERFORM_BOOTSTRAP_RELOC(ELF_RELOC *rpnt, unsigned long *reloc_addr,
unsigned long symbol_addr,
unsigned long load_addr, Elf32_Sym *symtab)
{
- switch(ELF32_R_TYPE(rpnt->r_info)) {
+ switch(ELF_R_TYPE(rpnt->r_info)) {
case R_AVR32_NONE:
break;
case R_AVR32_GLOB_DAT:
@@ -91,7 +92,7 @@ void PERFORM_BOOTSTRAP_RELOC(ELF_RELOC *rpnt, unsigned long *reloc_addr,
break;
default:
SEND_STDERR("BOOTSTRAP_RELOC: unhandled reloc_type ");
- SEND_NUMBER_STDERR(ELF32_R_TYPE(rpnt->r_info), 1);
+ SEND_NUMBER_STDERR(ELF_R_TYPE(rpnt->r_info), 1);
SEND_STDERR("REL, SYMBOL, LOAD: ");
SEND_ADDRESS_STDERR(reloc_addr, 0);
SEND_STDERR(", ");
@@ -101,12 +102,3 @@ void PERFORM_BOOTSTRAP_RELOC(ELF_RELOC *rpnt, unsigned long *reloc_addr,
_dl_exit(1);
}
}
-
-/* Transfer control to the user's application, once the dynamic loader
- * is done. This routine has to exit the current function, then call
- * the _dl_elf_main function.
- *
- * Since our _dl_boot will simply call whatever is returned by
- * _dl_boot2, we can just return the address we're supposed to
- * call. */
-#define START() return _dl_elf_main;
diff --git a/ldso/ldso/avr32/dl-syscalls.h b/ldso/ldso/avr32/dl-syscalls.h
index 996bb87c6..f40c4fd31 100644
--- a/ldso/ldso/avr32/dl-syscalls.h
+++ b/ldso/ldso/avr32/dl-syscalls.h
@@ -1,6 +1 @@
-/* We can't use the real errno in ldso, since it has not yet
- * been dynamicly linked in yet. */
-#include "sys/syscall.h"
-extern int _dl_errno;
-#undef __set_errno
-#define __set_errno(X) {(_dl_errno) = (X);}
+/* stub for arch-specific syscall issues */
diff --git a/ldso/ldso/avr32/dl-sysdep.h b/ldso/ldso/avr32/dl-sysdep.h
index 5ee110101..a42212731 100644
--- a/ldso/ldso/avr32/dl-sysdep.h
+++ b/ldso/ldso/avr32/dl-sysdep.h
@@ -24,19 +24,17 @@
/* Initialization sequence for the application/library GOT. */
#define INIT_GOT(GOT_BASE,MODULE) \
do { \
- unsigned long i, nr_got; \
+ unsigned long _i, _nr_got; \
\
GOT_BASE[0] = (unsigned long) _dl_linux_resolve; \
GOT_BASE[1] = (unsigned long) MODULE; \
\
/* Add load address displacement to all GOT entries */ \
- nr_got = MODULE->dynamic_info[DT_AVR32_GOTSZ_IDX] / 4; \
- for (i = 2; i < nr_got; i++) \
- GOT_BASE[i] += (unsigned long)MODULE->loadaddr; \
+ _nr_got = MODULE->dynamic_info[DT_AVR32_GOTSZ_IDX] / 4; \
+ for (_i = 2; _i < _nr_got; _i++) \
+ GOT_BASE[_i] += (unsigned long)MODULE->loadaddr; \
} while (0)
-#define do_rem(result, n, base) ((result) = (n) % (base))
-
/* Here we define the magic numbers that this dynamic loader should accept */
#define MAGIC1 EM_AVR32
#undef MAGIC2
@@ -44,12 +42,10 @@
/* Used for error messages */
#define ELF_TARGET "AVR32"
-unsigned long _dl_linux_resolver(unsigned long got_offset, unsigned long *got);
+/* Need bootstrap relocations */
+#define ARCH_NEEDS_BOOTSTRAP_RELOCS
-/* 4096 bytes alignment */
-#define PAGE_ALIGN 0xfffff000
-#define ADDR_ALIGN 0xfff
-#define OFFS_ALIGN 0x7ffff000
+unsigned long _dl_linux_resolver(unsigned long got_offset, unsigned long *got);
#define elf_machine_type_class(type) \
((type == R_AVR32_JMP_SLOT) * ELF_RTYPE_CLASS_PLT)
@@ -60,18 +56,19 @@ unsigned long _dl_linux_resolver(unsigned long got_offset, unsigned long *got);
/* Return the link-time address of _DYNAMIC. Conveniently, this is the
first element of the GOT. This must be inlined in a function which
uses global data. */
-static __inline__ Elf32_Addr
+static __always_inline Elf32_Addr
elf_machine_dynamic (void)
{
register Elf32_Addr *got __asm__("r6");
return *got;
}
+extern char __dl_start[] __asm__("_dl_start");
+
/* Return the run-time load address of the shared object. */
-static __inline__ Elf32_Addr
+static __always_inline Elf32_Addr
elf_machine_load_address (void)
{
- extern void __dl_start __asm__("_dl_start");
Elf32_Addr got_addr = (Elf32_Addr) &__dl_start;
Elf32_Addr pcrel_addr;
@@ -91,7 +88,7 @@ elf_machine_load_address (void)
* Currently, we don't use that tag, but we might in the future as
* this would reduce the startup time somewhat (although probably not by much).
*/
-static __inline__ void
+static __always_inline void
elf_machine_relative (Elf32_Addr load_off, const Elf32_Addr rel_addr,
Elf32_Word relative_count)
{
diff --git a/ldso/ldso/avr32/elfinterp.c b/ldso/ldso/avr32/elfinterp.c
index 813179e64..17f34fae8 100644
--- a/ldso/ldso/avr32/elfinterp.c
+++ b/ldso/ldso/avr32/elfinterp.c
@@ -34,7 +34,7 @@ unsigned long _dl_linux_resolver(unsigned long got_offset, unsigned long *got)
*/
#if 0
struct elf_resolve *tpnt = (struct elf_resolve *)got[1];
- Elf32_Sym *sym;
+ ElfW(Sym) *sym;
unsigned long local_gotno;
unsigned long gotsym;
unsigned long new_addr;
@@ -45,14 +45,14 @@ unsigned long _dl_linux_resolver(unsigned long got_offset, unsigned long *got)
local_gotno = tpnt->dynamic_info[DT_AVR32_LOCAL_GOTNO];
gotsym = tpnt->dynamic_info[DT_AVR32_GOTSYM];
- sym = ((Elf32_Sym *)(tpnt->dynamic_info[DT_SYMTAB] + tpnt->loadaddr))
+ sym = ((ElfW(Sym) *)(tpnt->dynamic_info[DT_SYMTAB] + tpnt->loadaddr))
+ sym_index;
strtab = (char *)(tpnt->dynamic_info[DT_STRTAB] + tpnt->loadaddr);
symname = strtab + sym->st_name;
- new_addr = (unsigned long) _dl_find_hash(strtab + sym->st_name,
- tpnt->symbol_scope, tpnt,
- resolver);
+ new_addr = (unsigned long) _dl_find_hash(symname,
+ &_dl_loaded_modules->symbol_scope, tpnt,
+ ELF_RTYPE_CLASS_PLT, NULL);
entry = (unsigned long *)(got + local_gotno + sym_index - gotsym);
*entry = new_addr;
@@ -63,25 +63,25 @@ unsigned long _dl_linux_resolver(unsigned long got_offset, unsigned long *got)
}
static int
-_dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
+_dl_parse(struct elf_resolve *tpnt, struct r_scope_elem *scope,
unsigned long rel_addr, unsigned long rel_size,
- int (*reloc_func)(struct elf_resolve *tpnt, struct dyn_elf *scope,
- Elf32_Rela *rpnt, Elf32_Sym *symtab, char *strtab))
+ int (*reloc_func)(struct elf_resolve *tpnt, struct r_scope_elem *scope,
+ ElfW(Rela) *rpnt, ElfW(Sym) *symtab, char *strtab))
{
- Elf32_Sym *symtab;
- Elf32_Rela *rpnt;
+ ElfW(Sym) *symtab;
+ ElfW(Rela) *rpnt;
char *strtab;
int i;
- rpnt = (Elf32_Rela *)rel_addr;
- rel_size /= sizeof(Elf32_Rela);
- symtab = (Elf32_Sym *)tpnt->dynamic_info[DT_SYMTAB];
+ rpnt = (ElfW(Rela) *)rel_addr;
+ rel_size /= sizeof(ElfW(Rela));
+ symtab = (ElfW(Sym) *)tpnt->dynamic_info[DT_SYMTAB];
strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
for (i = 0; i < rel_size; i++, rpnt++) {
int symtab_index, res;
- symtab_index = ELF32_R_SYM(rpnt->r_info);
+ symtab_index = ELF_R_SYM(rpnt->r_info);
debug_sym(symtab, strtab, symtab_index);
debug_reloc(symtab, strtab, rpnt);
@@ -98,7 +98,7 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
strtab + symtab[symtab_index].st_name);
if (res < 0) {
- int reloc_type = ELF32_R_TYPE(rpnt->r_info);
+ int reloc_type = ELF_R_TYPE(rpnt->r_info);
#if defined(__SUPPORT_LD_DEBUG__)
_dl_dprintf(2, "can't handle reloc type %s\n",
_dl_reltypes(reloc_type));
@@ -116,8 +116,8 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
return 0;
}
-static int _dl_do_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
- Elf32_Rela *rpnt, Elf32_Sym *symtab, char *strtab)
+static int _dl_do_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
+ ElfW(Rela) *rpnt, ElfW(Sym) *symtab, char *strtab)
{
int reloc_type;
int symtab_index;
@@ -127,26 +127,32 @@ static int _dl_do_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
#if defined(__SUPPORT_LD_DEBUG__)
unsigned long old_val;
#endif
+ struct symbol_ref sym_ref;
reloc_addr = (unsigned long *)(tpnt->loadaddr + rpnt->r_offset);
- reloc_type = ELF32_R_TYPE(rpnt->r_info);
- symtab_index = ELF32_R_SYM(rpnt->r_info);
+ reloc_type = ELF_R_TYPE(rpnt->r_info);
+ symtab_index = ELF_R_SYM(rpnt->r_info);
symbol_addr = 0;
+ sym_ref.sym = &symtab[symtab_index];
+ sym_ref.tpnt = NULL;
symname = strtab + symtab[symtab_index].st_name;
if (symtab_index) {
symbol_addr = (unsigned long)
- _dl_find_hash(strtab + symtab[symtab_index].st_name,
- tpnt->symbol_scope, tpnt,
- elf_machine_type_class(reloc_type));
+ _dl_find_hash(symname, scope, tpnt,
+ elf_machine_type_class(reloc_type), &sym_ref);
/* Allow undefined references to weak symbols */
if (!symbol_addr &&
- ELF32_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK) {
+ ELF_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK) {
_dl_dprintf(2, "%s: can't resolve symbol '%s'\n",
_dl_progname, symname);
return 0;
}
+ if (_dl_trace_prelink) {
+ _dl_debug_lookup (symname, tpnt, &symtab[symtab_index],
+ &sym_ref, elf_machine_type_class(reloc_type));
+ }
}
#if defined(__SUPPORT_LD_DEBUG__)
@@ -185,9 +191,10 @@ void _dl_parse_lazy_relocation_information(struct dyn_elf *rpnt,
}
int _dl_parse_relocation_information(struct dyn_elf *rpnt,
+ struct r_scope_elem *scope,
unsigned long rel_addr,
unsigned long rel_size)
{
- return _dl_parse(rpnt->dyn, rpnt->dyn->symbol_scope, rel_addr, rel_size,
+ return _dl_parse(rpnt->dyn, scope, rel_addr, rel_size,
_dl_do_reloc);
}
diff --git a/ldso/ldso/bfin/dl-debug.h b/ldso/ldso/bfin/dl-debug.h
index 9dd316240..6952b6160 100644
--- a/ldso/ldso/bfin/dl-debug.h
+++ b/ldso/ldso/bfin/dl-debug.h
@@ -29,18 +29,18 @@
* SUCH DAMAGE.
*/
-static const char *_dl_reltypes_tab[] =
+static const char * const _dl_reltypes_tab[] =
{
- [0] "R_BFIN_unused0", "R_BFIN_pcrel5m2",
- [2] "R_BFIN_unused1", "R_BFIN_pcrel10",
- [4] "R_BFIN_pcrel12_jump", "R_BFIN_rimm16",
- [6] "R_BFIN_luimm16", "R_BFIN_huimm16",
- [8] "R_BFIN_pcrel12_jump_s","R_BFIN_pcrel24_jump_x",
- [10] "R_BFIN_pcrel24", "R_BFIN_unusedb",
- [12] "R_BFIN_unusedc", "R_BFIN_pcrel24_jump_l",
- [14] "R_BFIN_pcrel24_call_x","R_BFIN_var_eq_symb",
- [16] "R_BFIN_byte_data", "R_BFIN_byte2_data", "R_BFIN_byte4_data",
- [19] "R_BFIN_pcrel11",
+ [0] "R_BFIN_UNUSED0", "R_BFIN_PCREL5M2",
+ [2] "R_BFIN_UNUSED1", "R_BFIN_PCREL10",
+ [4] "R_BFIN_PCREL12_JUMP", "R_BFIN_RIMM16",
+ [6] "R_BFIN_LUIMM16", "R_BFIN_HUIMM16",
+ [8] "R_BFIN_PCREL12_JUMP_S","R_BFIN_PCREL24_JUMP_X",
+ [10] "R_BFIN_PCREL24", "R_BFIN_UNUSEDB",
+ [12] "R_BFIN_UNUSEDC", "R_BFIN_PCREL24_JUMP_L",
+ [14] "R_BFIN_PCREL24_CALL_X","R_BFIN_var_eq_symb",
+ [16] "R_BFIN_BYTE_DATA", "R_BFIN_BYTE2_DATA", "R_BFIN_BYTE4_DATA",
+ [19] "R_BFIN_PCREL11",
[20] "R_BFIN_GOT17M4", "R_BFIN_GOTHI", "R_BFIN_GOTLO",
[23] "R_BFIN_FUNCDESC",
diff --git a/ldso/ldso/bfin/dl-inlines.h b/ldso/ldso/bfin/dl-inlines.h
index f8b8f85f1..b08ce61cb 100644
--- a/ldso/ldso/bfin/dl-inlines.h
+++ b/ldso/ldso/bfin/dl-inlines.h
@@ -1,574 +1,146 @@
- /* Copyright (C) 2003, 2004 Red Hat, Inc.
- Contributed by Alexandre Oliva <aoliva@redhat.com>
-
-This file is part of uClibc.
-
-uClibc 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.
-
-uClibc is distributed in the hope that 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 uClibc; see the file COPYING.LIB. If not, write to
-the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
-USA. */
+/* Copyright (C) 2003, 2004 Red Hat, Inc.
+ * Contributed by Alexandre Oliva <aoliva@redhat.com>
+ * Copyright (C) 2006-2011 Analog Devices, Inc.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
#include <bfin_sram.h>
-#ifndef _dl_assert
-# define _dl_assert(expr)
-#endif
-
-/* Initialize a DL_LOADADDR_TYPE given a got pointer and a complete
- load map. */
-inline static void
-__dl_init_loadaddr_map (struct elf32_fdpic_loadaddr *loadaddr, Elf32_Addr dl_boot_got_pointer,
- struct elf32_fdpic_loadmap *map)
-{
- if (map->version != 0)
- {
- SEND_EARLY_STDERR ("Invalid loadmap version number\n");
- _dl_exit(-1);
- }
- if (map->nsegs == 0)
- {
- SEND_EARLY_STDERR ("Invalid segment count in loadmap\n");
- _dl_exit(-1);
- }
- loadaddr->got_value = dl_boot_got_pointer;
- loadaddr->map = map;
-}
-
-/* Figure out how many LOAD segments there are in the given headers,
- and allocate a block for the load map big enough for them.
- got_value will be properly initialized later on, with INIT_GOT. */
-inline static int
-__dl_init_loadaddr (struct elf32_fdpic_loadaddr *loadaddr, Elf32_Phdr *ppnt,
- int pcnt)
-{
- int count = 0, i;
- size_t size;
-
- for (i = 0; i < pcnt; i++)
- if (ppnt[i].p_type == PT_LOAD)
- count++;
-
- loadaddr->got_value = 0;
-
- size = sizeof (struct elf32_fdpic_loadmap)
- + sizeof (struct elf32_fdpic_loadseg) * count;
- loadaddr->map = _dl_malloc (size);
- if (! loadaddr->map)
- _dl_exit (-1);
-
- loadaddr->map->version = 0;
- loadaddr->map->nsegs = 0;
-
- return count;
-}
-
-/* Incrementally initialize a load map. */
-inline static void
-__dl_init_loadaddr_hdr (struct elf32_fdpic_loadaddr loadaddr, void *addr,
- Elf32_Phdr *phdr, int maxsegs)
-{
- struct elf32_fdpic_loadseg *segdata;
-
- if (loadaddr.map->nsegs == maxsegs)
- _dl_exit (-1);
-
- segdata = &loadaddr.map->segs[loadaddr.map->nsegs++];
- segdata->addr = (Elf32_Addr) addr;
- segdata->p_vaddr = phdr->p_vaddr;
- segdata->p_memsz = phdr->p_memsz;
-
-#if defined (__SUPPORT_LD_DEBUG__)
- {
- extern char *_dl_debug;
- extern int _dl_debug_file;
- if (_dl_debug)
- _dl_dprintf(_dl_debug_file, "%i: mapped %x at %x, size %x\n",
- loadaddr.map->nsegs-1,
- segdata->p_vaddr, segdata->addr, segdata->p_memsz);
- }
-#endif
-}
-
-inline static void __dl_loadaddr_unmap
-(struct elf32_fdpic_loadaddr loadaddr, struct funcdesc_ht *funcdesc_ht);
-
-/* Figure out whether the given address is in one of the mapped
- segments. */
-inline static int
-__dl_addr_in_loadaddr (void *p, struct elf32_fdpic_loadaddr loadaddr)
-{
- struct elf32_fdpic_loadmap *map = loadaddr.map;
- int c;
-
- for (c = 0; c < map->nsegs; c++)
- if ((void*)map->segs[c].addr <= p
- && (char*)p < (char*)map->segs[c].addr + map->segs[c].p_memsz)
- return 1;
-
- return 0;
-}
-
-inline static void * _dl_funcdesc_for (void *entry_point, void *got_value);
-
-/* The hashcode handling code below is heavily inspired in libiberty's
- hashtab code, but with most adaptation points and support for
- deleting elements removed.
-
- Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
- Contributed by Vladimir Makarov (vmakarov@cygnus.com). */
-
-inline static unsigned long
-higher_prime_number (unsigned long n)
-{
- /* These are primes that are near, but slightly smaller than, a
- power of two. */
- static const unsigned long primes[] = {
- (unsigned long) 7,
- (unsigned long) 13,
- (unsigned long) 31,
- (unsigned long) 61,
- (unsigned long) 127,
- (unsigned long) 251,
- (unsigned long) 509,
- (unsigned long) 1021,
- (unsigned long) 2039,
- (unsigned long) 4093,
- (unsigned long) 8191,
- (unsigned long) 16381,
- (unsigned long) 32749,
- (unsigned long) 65521,
- (unsigned long) 131071,
- (unsigned long) 262139,
- (unsigned long) 524287,
- (unsigned long) 1048573,
- (unsigned long) 2097143,
- (unsigned long) 4194301,
- (unsigned long) 8388593,
- (unsigned long) 16777213,
- (unsigned long) 33554393,
- (unsigned long) 67108859,
- (unsigned long) 134217689,
- (unsigned long) 268435399,
- (unsigned long) 536870909,
- (unsigned long) 1073741789,
- (unsigned long) 2147483647,
- /* 4294967291L */
- ((unsigned long) 2147483647) + ((unsigned long) 2147483644),
- };
-
- const unsigned long *low = &primes[0];
- const unsigned long *high = &primes[sizeof(primes) / sizeof(primes[0])];
-
- while (low != high)
- {
- const unsigned long *mid = low + (high - low) / 2;
- if (n > *mid)
- low = mid + 1;
- else
- high = mid;
- }
-
-#if 0
- /* If we've run out of primes, abort. */
- if (n > *low)
- {
- fprintf (stderr, "Cannot find prime bigger than %lu\n", n);
- abort ();
- }
-#endif
-
- return *low;
-}
-
-struct funcdesc_ht
-{
- /* Table itself. */
- struct funcdesc_value **entries;
-
- /* Current size (in entries) of the hash table */
- size_t size;
-
- /* Current number of elements. */
- size_t n_elements;
-};
-
-inline static int
-hash_pointer (const void *p)
-{
- return (int) ((long)p >> 3);
-}
-
-inline static struct funcdesc_ht *
-htab_create (void)
-{
- struct funcdesc_ht *ht = _dl_malloc (sizeof (struct funcdesc_ht));
-
- if (! ht)
- return NULL;
- ht->size = 3;
- ht->entries = _dl_malloc (sizeof (struct funcdesc_ht_value *) * ht->size);
- if (! ht->entries)
- return NULL;
-
- ht->n_elements = 0;
-
- _dl_memset (ht->entries, 0, sizeof (struct funcdesc_ht_value *) * ht->size);
-
- return ht;
-}
-
-/* This is only called from _dl_loadaddr_unmap, so it's safe to call
- _dl_free(). See the discussion below. */
-inline static void
-htab_delete (struct funcdesc_ht *htab)
-{
- int i;
-
- for (i = htab->size - 1; i >= 0; i--)
- if (htab->entries[i])
- _dl_free (htab->entries[i]);
-
- _dl_free (htab->entries);
- _dl_free (htab);
-}
-
-/* Similar to htab_find_slot, but without several unwanted side effects:
- - Does not call htab->eq_f when it finds an existing entry.
- - Does not change the count of elements/searches/collisions in the
- hash table.
- This function also assumes there are no deleted entries in the table.
- HASH is the hash value for the element to be inserted. */
-
-inline static struct funcdesc_value **
-find_empty_slot_for_expand (struct funcdesc_ht *htab, int hash)
-{
- size_t size = htab->size;
- unsigned int index = hash % size;
- struct funcdesc_value **slot = htab->entries + index;
- int hash2;
-
- if (! *slot)
- return slot;
-
- hash2 = 1 + hash % (size - 2);
- for (;;)
- {
- index += hash2;
- if (index >= size)
- index -= size;
-
- slot = htab->entries + index;
- if (! *slot)
- return slot;
- }
-}
-
-/* The following function changes size of memory allocated for the
- entries and repeatedly inserts the table elements. The occupancy
- of the table after the call will be about 50%. Naturally the hash
- table must already exist. Remember also that the place of the
- table entries is changed. If memory allocation failures are allowed,
- this function will return zero, indicating that the table could not be
- expanded. If all goes well, it will return a non-zero value. */
-
-inline static int
-htab_expand (struct funcdesc_ht *htab)
-{
- struct funcdesc_value **oentries;
- struct funcdesc_value **olimit;
- struct funcdesc_value **p;
- struct funcdesc_value **nentries;
- size_t nsize;
-
- oentries = htab->entries;
- olimit = oentries + htab->size;
-
- /* Resize only when table after removal of unused elements is either
- too full or too empty. */
- if (htab->n_elements * 2 > htab->size)
- nsize = higher_prime_number (htab->n_elements * 2);
- else
- nsize = htab->size;
-
- nentries = _dl_malloc (sizeof (struct funcdesc_value *) * nsize);
- _dl_memset (nentries, 0, sizeof (struct funcdesc_value *) * nsize);
- if (nentries == NULL)
- return 0;
- htab->entries = nentries;
- htab->size = nsize;
-
- p = oentries;
- do
- {
- if (*p)
- *find_empty_slot_for_expand (htab, hash_pointer ((*p)->entry_point))
- = *p;
-
- p++;
- }
- while (p < olimit);
-
-#if 0 /* We can't tell whether this was allocated by the _dl_malloc()
- built into ld.so or malloc() in the main executable or libc,
- and calling free() for something that wasn't malloc()ed could
- do Very Bad Things (TM). Take the conservative approach
- here, potentially wasting as much memory as actually used by
- the hash table, even if multiple growths occur. That's not
- so bad as to require some overengineered solution that would
- enable us to keep track of how it was allocated. */
- _dl_free (oentries);
-#endif
- return 1;
-}
-
-/* This function searches for a hash table slot containing an entry
- equal to the given element. To delete an entry, call this with
- INSERT = 0, then call htab_clear_slot on the slot returned (possibly
- after doing some checks). To insert an entry, call this with
- INSERT = 1, then write the value you want into the returned slot.
- When inserting an entry, NULL may be returned if memory allocation
- fails. */
-
-inline static struct funcdesc_value **
-htab_find_slot (struct funcdesc_ht *htab, void *ptr, int insert)
-{
- unsigned int index;
- int hash, hash2;
- size_t size;
- struct funcdesc_value **entry;
-
- if (htab->size * 3 <= htab->n_elements * 4
- && htab_expand (htab) == 0)
- return NULL;
-
- hash = hash_pointer (ptr);
-
- size = htab->size;
- index = hash % size;
-
- entry = &htab->entries[index];
- if (!*entry)
- goto empty_entry;
- else if ((*entry)->entry_point == ptr)
- return entry;
-
- hash2 = 1 + hash % (size - 2);
- for (;;)
- {
- index += hash2;
- if (index >= size)
- index -= size;
-
- entry = &htab->entries[index];
- if (!*entry)
- goto empty_entry;
- else if ((*entry)->entry_point == ptr)
- return entry;
- }
-
- empty_entry:
- if (!insert)
- return NULL;
-
- htab->n_elements++;
- return entry;
-}
-
-void *
-_dl_funcdesc_for (void *entry_point, void *got_value)
-{
- struct elf_resolve *tpnt = ((void**)got_value)[2];
- struct funcdesc_ht *ht = tpnt->funcdesc_ht;
- struct funcdesc_value **entry;
-
- _dl_assert (got_value == tpnt->loadaddr.got_value);
-
- if (! ht)
- {
- ht = htab_create ();
- if (! ht)
- return (void*)-1;
- tpnt->funcdesc_ht = ht;
- }
-
- entry = htab_find_slot (ht, entry_point, 1);
- if (*entry)
- {
- _dl_assert ((*entry)->entry_point == entry_point);
- return _dl_stabilize_funcdesc (*entry);
- }
-
- *entry = _dl_malloc (sizeof (struct funcdesc_value));
- (*entry)->entry_point = entry_point;
- (*entry)->got_value = got_value;
-
- return _dl_stabilize_funcdesc (*entry);
+#define __dl_loadaddr_unmap __dl_loadaddr_unmap
+
+#include "../fdpic/dl-inlines.h"
+
+static __always_inline void
+__dl_loadaddr_unmap(struct elf32_fdpic_loadaddr loadaddr,
+ struct funcdesc_ht *funcdesc_ht)
+{
+ int i;
+
+ for (i = 0; i < loadaddr.map->nsegs; i++) {
+ struct elf32_fdpic_loadseg *segdata;
+ ssize_t offs;
+ segdata = loadaddr.map->segs + i;
+
+ /* FIXME:
+ * A more cleaner way is to add type for struct elf32_fdpic_loadseg,
+ * and release the memory according to the type.
+ * Currently, we hardcode the memory address of L1 SRAM.
+ */
+ if ((segdata->addr & 0xff800000) == 0xff800000) {
+ _dl_sram_free((void *)segdata->addr);
+ continue;
+ }
+
+ offs = (segdata->p_vaddr & ADDR_ALIGN);
+ _dl_munmap((void*)segdata->addr - offs,
+ segdata->p_memsz + offs);
+ }
+
+ /*
+ * _dl_unmap is only called for dlopen()ed libraries, for which
+ * calling free() is safe, or before we've completed the initial
+ * relocation, in which case calling free() is probably pointless,
+ * but still safe.
+ */
+ _dl_free(loadaddr.map);
+ if (funcdesc_ht)
+ htab_delete(funcdesc_ht);
+}
+
+static __always_inline int
+__dl_is_special_segment(Elf32_Ehdr *epnt, Elf32_Phdr *ppnt)
+{
+ if (ppnt->p_type != PT_LOAD)
+ return 0;
+
+ /* Allow read-only executable segments to be loaded into L1 inst */
+ if ((epnt->e_flags & EF_BFIN_CODE_IN_L1) &&
+ !(ppnt->p_flags & PF_W) && (ppnt->p_flags & PF_X))
+ return 1;
+
+ /* Allow writable non-executable segments to be loaded into L1 data */
+ if ((epnt->e_flags & EF_BFIN_DATA_IN_L1) &&
+ (ppnt->p_flags & PF_W) && !(ppnt->p_flags & PF_X))
+ return 1;
+
+ /*
+ * These L1 memory addresses are also used in GNU ld and linux kernel.
+ * They need to be kept synchronized.
+ */
+ switch (ppnt->p_vaddr) {
+ case 0xff700000:
+ case 0xff800000:
+ case 0xff900000:
+ case 0xffa00000:
+ case 0xfeb00000:
+ case 0xfec00000:
+ return 1;
+ default:
+ return 0;
+ }
}
-inline static void const *
-_dl_lookup_address (void const *address)
+static __always_inline char *
+__dl_map_segment(Elf32_Ehdr *epnt, Elf32_Phdr *ppnt, int infile, int flags)
{
- struct elf_resolve *rpnt;
- struct funcdesc_value const *fd;
-
- /* Make sure we don't make assumptions about its alignment. */
- __asm__ ("" : "+r" (address));
-
- if ((Elf32_Addr)address & 7)
- /* It's not a function descriptor. */
- return address;
-
- fd = (struct funcdesc_value const *)address;
-
- for (rpnt = _dl_loaded_modules; rpnt; rpnt = rpnt->next)
- {
- if (! rpnt->funcdesc_ht)
- continue;
-
- if (fd->got_value != rpnt->loadaddr.got_value)
- continue;
+ void *addr;
+ unsigned long sram_flags = 0;
- address = htab_find_slot (rpnt->funcdesc_ht, (void*)fd->entry_point, 0);
-
- if (address && *(struct funcdesc_value *const*)address == fd)
+ /* Handle L1 inst mappings */
+ if (((epnt->e_flags & EF_BFIN_CODE_IN_L1) || ppnt->p_vaddr == 0xffa00000) &&
+ !(ppnt->p_flags & PF_W) && (ppnt->p_flags & PF_X))
{
- address = (*(struct funcdesc_value *const*)address)->entry_point;
- break;
+ size_t size = (ppnt->p_vaddr & ADDR_ALIGN) + ppnt->p_filesz;
+ void *status = _dl_mmap(NULL, size, LXFLAGS(ppnt->p_flags),
+ flags | MAP_EXECUTABLE | MAP_DENYWRITE,
+ infile, ppnt->p_offset & OFFS_ALIGN);
+ if (_dl_mmap_check_error(status))
+ return NULL;
+
+ addr = _dl_sram_alloc(ppnt->p_filesz, L1_INST_SRAM);
+ if (addr)
+ _dl_dma_memcpy(addr, status + (ppnt->p_vaddr & ADDR_ALIGN), ppnt->p_filesz);
+ else
+ _dl_dprintf(2, "%s:%s: sram allocation %#x failed\n",
+ _dl_progname, __func__, ppnt->p_vaddr);
+
+ _dl_munmap(status, size);
+ return addr;
}
- else
- address = fd;
- }
-
- return address;
-}
-
-void
-__dl_loadaddr_unmap (struct elf32_fdpic_loadaddr loadaddr,
- struct funcdesc_ht *funcdesc_ht)
-{
- int i;
-
- for (i = 0; i < loadaddr.map->nsegs; i++)
- {
- struct elf32_fdpic_loadseg *segdata;
- ssize_t offs;
- segdata = loadaddr.map->segs + i;
-
- /* FIXME:
- A more cleaner way is to add type for struct elf32_fdpic_loadseg,
- and release the memory according to the type.
- Currently, we hardcode the memory address of L1 SRAM. */
- if ((segdata->addr & 0xff800000) == 0xff800000)
- {
- _dl_sram_free ((void *)segdata->addr);
- continue;
- }
- offs = (segdata->p_vaddr & ADDR_ALIGN);
- _dl_munmap ((void*)segdata->addr - offs,
- segdata->p_memsz + offs);
- }
- /* _dl_unmap is only called for dlopen()ed libraries, for which
- calling free() is safe, or before we've completed the initial
- relocation, in which case calling free() is probably pointless,
- but still safe. */
- _dl_free (loadaddr.map);
- if (funcdesc_ht)
- htab_delete (funcdesc_ht);
-}
-
-inline static int
-__dl_is_special_segment (Elf32_Ehdr *epnt,
- Elf32_Phdr *ppnt)
-{
- if (ppnt->p_type != PT_LOAD)
- return 0;
-
- if ((epnt->e_flags & EF_BFIN_CODE_IN_L1)
- && !(ppnt->p_flags & PF_W)
- && (ppnt->p_flags & PF_X))
- return 1;
-
- if ((epnt->e_flags & EF_BFIN_DATA_IN_L1)
- && (ppnt->p_flags & PF_W)
- && !(ppnt->p_flags & PF_X))
- return 1;
-
- /* 0xff700000, 0xff800000, 0xff900000 and 0xffa00000 are also used in
- GNU ld and linux kernel. They need to be keep synchronized. */
- if (ppnt->p_vaddr == 0xff700000
- || ppnt->p_vaddr == 0xff800000
- || ppnt->p_vaddr == 0xff900000
- || ppnt->p_vaddr == 0xffa00000)
- return 1;
-
- return 0;
-}
-
-inline static char *
-__dl_map_segment (Elf32_Ehdr *epnt,
- Elf32_Phdr *ppnt,
- int infile,
- int flags)
-{
- char *status, *tryaddr, *l1addr;
- size_t size;
-
- if (((epnt->e_flags & EF_BFIN_CODE_IN_L1) || ppnt->p_vaddr == 0xffa00000)
- && !(ppnt->p_flags & PF_W)
- && (ppnt->p_flags & PF_X)) {
- status = (char *) _dl_mmap
- (tryaddr = 0,
- size = (ppnt->p_vaddr & ADDR_ALIGN) + ppnt->p_filesz,
- LXFLAGS(ppnt->p_flags),
- flags | MAP_EXECUTABLE | MAP_DENYWRITE,
- infile, ppnt->p_offset & OFFS_ALIGN);
- if (_dl_mmap_check_error(status)
- || (tryaddr && tryaddr != status))
- return NULL;
- l1addr = (char *) _dl_sram_alloc (ppnt->p_filesz, L1_INST_SRAM);
- if (l1addr != NULL)
- _dl_dma_memcpy (l1addr, status + (ppnt->p_vaddr & ADDR_ALIGN), ppnt->p_filesz);
- _dl_munmap (status, size);
- if (l1addr == NULL)
- _dl_dprintf(2, "%s:%i: L1 allocation failed\n", _dl_progname, __LINE__);
- return l1addr;
- }
+ /* Handle L1 data mappings */
+ if (((epnt->e_flags & EF_BFIN_DATA_IN_L1) ||
+ ppnt->p_vaddr == 0xff700000 ||
+ ppnt->p_vaddr == 0xff800000 ||
+ ppnt->p_vaddr == 0xff900000) &&
+ (ppnt->p_flags & PF_W) && !(ppnt->p_flags & PF_X))
+ {
+ switch (ppnt->p_vaddr) {
+ case 0xff800000: sram_flags = L1_DATA_A_SRAM; break;
+ case 0xff900000: sram_flags = L1_DATA_B_SRAM; break;
+ default: sram_flags = L1_DATA_SRAM; break;
+ }
+ }
- if (((epnt->e_flags & EF_BFIN_DATA_IN_L1)
- || ppnt->p_vaddr == 0xff700000
- || ppnt->p_vaddr == 0xff800000
- || ppnt->p_vaddr == 0xff900000)
- && (ppnt->p_flags & PF_W)
- && !(ppnt->p_flags & PF_X)) {
- if (ppnt->p_vaddr == 0xff800000)
- l1addr = (char *) _dl_sram_alloc (ppnt->p_memsz, L1_DATA_A_SRAM);
- else if (ppnt->p_vaddr == 0xff900000)
- l1addr = (char *) _dl_sram_alloc (ppnt->p_memsz, L1_DATA_B_SRAM);
- else
- l1addr = (char *) _dl_sram_alloc (ppnt->p_memsz, L1_DATA_SRAM);
- if (l1addr == NULL) {
- _dl_dprintf(2, "%s:%i: L1 allocation failed\n", _dl_progname, __LINE__);
- } else {
- if (_DL_PREAD (infile, l1addr, ppnt->p_filesz, ppnt->p_offset) != ppnt->p_filesz) {
- _dl_sram_free (l1addr);
- return NULL;
- }
- if (ppnt->p_filesz < ppnt->p_memsz)
- _dl_memset (l1addr + ppnt->p_filesz, 0, ppnt->p_memsz - ppnt->p_filesz);
- }
- return l1addr;
- }
+ /* Handle L2 mappings */
+ if (ppnt->p_vaddr == 0xfeb00000 || ppnt->p_vaddr == 0xfec00000)
+ sram_flags = L2_SRAM;
+
+ if (sram_flags) {
+ addr = _dl_sram_alloc(ppnt->p_memsz, sram_flags);
+ if (addr) {
+ if (_DL_PREAD(infile, addr, ppnt->p_filesz, ppnt->p_offset) != ppnt->p_filesz) {
+ _dl_sram_free(addr);
+ return NULL;
+ }
+ if (ppnt->p_filesz < ppnt->p_memsz)
+ _dl_memset(addr + ppnt->p_filesz, 0, ppnt->p_memsz - ppnt->p_filesz);
+ } else
+ _dl_dprintf(2, "%s:%s: sram allocation %#x failed\n",
+ _dl_progname, __func__, ppnt->p_vaddr);
+ return addr;
+ }
- return 0;
+ return 0;
}
diff --git a/ldso/ldso/bfin/dl-startup.h b/ldso/ldso/bfin/dl-startup.h
index a1e150e27..576b8f29f 100644
--- a/ldso/ldso/bfin/dl-startup.h
+++ b/ldso/ldso/bfin/dl-startup.h
@@ -14,17 +14,13 @@ 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 uClibc; see the file COPYING.LIB. If not, write to
-the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
-USA. */
+License along with uClibc; see the file COPYING.LIB. If not, see
+<http://www.gnu.org/licenses/>. */
/* Any assembly language/system dependent hacks needed to setup
* boot1.c so it will work as expected and cope with whatever platform
* specific wierdness is needed for this architecture.
-
- * We override the default _dl_boot function, and replace it with a
- * bit of asm. Then call the real _dl_boot function, which is now
- * named _dl_boot2. */
+ */
/* At program start-up, p0 contains a pointer to a
elf32_fdpic_loadmap that describes how the executable was loaded
@@ -40,50 +36,51 @@ USA. */
use this value to initialize the PIC register. */
__asm__(
- " .text\n" \
- " .global __dl_boot\n" \
- " .type __dl_boot,@function\n" \
- "__dl_boot:\n" \
- " call .Lcall\n" \
- ".Lcall:\n" \
- " R4 = RETS;\n" \
- " SP += -32;\n" \
- " R5 = P0;\n" \
- " R6 = P1;\n" \
- " R7 = P2;\n" \
- " R0.L = .Lcall;\n" \
- " R0.H = .Lcall;\n" \
- " R1.L = __ROFIXUP_LIST__;\n" \
- " R1.H = __ROFIXUP_LIST__;\n" \
- " R2.L = __ROFIXUP_END__;\n" \
- " R2.H = __ROFIXUP_END__;\n" \
- " R1 = R1 - R0;\n" \
- " R1 = R1 + R4;\n" \
- " R2 = R2 - R0;\n" \
- " R2 = R2 + R4;\n" \
- " R0 = P1;\n" \
- " CC = R0 == 0;\n" \
- " IF CC R0 = P0;\n" \
- " CALL ___self_reloc;\n" \
- " P3 = R0;\n" \
- " P5 = R0;\n" \
- " R1 = R5;\n" \
- " R2 = R6;\n" \
- " [SP + 12] = R7;\n" \
- " P0 = SP;\n" \
- " P0 += 24;\n" \
- " [SP + 16] = P0;\n" \
- " P0 += 8;\n" \
- " [SP + 20] = P0;\n" \
- " CALL __dl_start;\n" \
- " /* Pass our FINI ptr() to the user in P1 */\n" \
- " R7 = [P5 + __dl_fini@FUNCDESC_GOT17M4];\n" \
- " P4 = [SP + 24];\n" \
- " P3 = [SP + 28];\n" \
- " P0 = R5;\n" \
- " SP += 32;\n" \
- " JUMP (P4);\n" \
- " .size __dl_boot,.-__dl_boot\n"
+ " .text\n"
+ " .global __start\n"
+ " .type __start,@function\n"
+ " .hidden __start\n"
+ "__start:\n"
+ " call .Lcall\n"
+ ".Lcall:\n"
+ " R4 = RETS;\n"
+ " SP += -32;\n"
+ " R5 = P0;\n"
+ " R6 = P1;\n"
+ " R7 = P2;\n"
+ " R0.L = .Lcall;\n"
+ " R0.H = .Lcall;\n"
+ " R1.L = __ROFIXUP_LIST__;\n"
+ " R1.H = __ROFIXUP_LIST__;\n"
+ " R2.L = __ROFIXUP_END__;\n"
+ " R2.H = __ROFIXUP_END__;\n"
+ " R1 = R1 - R0;\n"
+ " R1 = R1 + R4;\n"
+ " R2 = R2 - R0;\n"
+ " R2 = R2 + R4;\n"
+ " R0 = P1;\n"
+ " CC = R0 == 0;\n"
+ " IF CC R0 = P0;\n"
+ " CALL ___self_reloc;\n"
+ " P3 = R0;\n"
+ " P5 = R0;\n"
+ " R1 = R5;\n"
+ " R2 = R6;\n"
+ " [SP + 12] = R7;\n"
+ " P0 = SP;\n"
+ " P0 += 24;\n"
+ " [SP + 16] = P0;\n"
+ " P0 += 8;\n"
+ " [SP + 20] = P0;\n"
+ " CALL __dl_start;\n"
+ " /* Pass our FINI ptr() to the user in P1 */\n"
+ " R7 = [P5 + __dl_fini@FUNCDESC_GOT17M4];\n"
+ " P4 = [SP + 24];\n"
+ " P3 = [SP + 28];\n"
+ " P0 = R5;\n"
+ " SP += 32;\n"
+ " JUMP (P4);\n"
+ " .size __start,.-__start\n"
);
#undef DL_START
@@ -96,11 +93,9 @@ _dl_start (Elf32_Addr dl_boot_got_pointer, \
struct funcdesc_value *dl_main_funcdesc, \
X)
-struct elf32_fdpic_loadmap;
-
/*
* Get a pointer to the argv array. On many platforms this can be just
- * the address if the first argument, on other platforms we need to
+ * the address of the first argument, on other platforms we need to
* do something a little more subtle here.
*/
#define GET_ARGV(ARGVP, ARGS) ARGVP = (((unsigned long*) ARGS) + 1)
@@ -113,8 +108,8 @@ struct elf32_fdpic_loadmap;
* load address.
*/
#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB) \
- switch(ELF32_R_TYPE((RELP)->r_info)){ \
- case R_BFIN_byte4_data: \
+ switch(ELF_R_TYPE((RELP)->r_info)){ \
+ case R_BFIN_BYTE4_DATA: \
*(REL) += (SYMBOL); \
break; \
case R_BFIN_FUNCDESC_VALUE: \
diff --git a/ldso/ldso/bfin/dl-syscalls.h b/ldso/ldso/bfin/dl-syscalls.h
index 21e4cdd2c..bfe352001 100644
--- a/ldso/ldso/bfin/dl-syscalls.h
+++ b/ldso/ldso/bfin/dl-syscalls.h
@@ -14,195 +14,24 @@ 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 uClibc; see the file COPYING.LIB. If not, write to
-the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
-USA. */
-
-/* We can't use the real errno in ldso, since it has not yet
- * been dynamicly linked in yet. */
-#include "sys/syscall.h"
-extern int _dl_errno;
-#undef __set_errno
-#define __set_errno(X) {(_dl_errno) = (X);}
-#include <sys/mman.h>
-
-/* The code below is extracted from libc/sysdeps/linux/frv/_mmap.c */
-
-#if DYNAMIC_LOADER_IN_SIMULATOR
-#define __NR___syscall_mmap2 __NR_mmap2
-static __inline__ _syscall6(__ptr_t, __syscall_mmap2, __ptr_t, addr,
- size_t, len, int, prot, int, flags, int, fd, off_t, offset);
-
-/* Make sure we don't get another definition of _dl_mmap from the
- machine-independent code. */
-#undef __NR_mmap
-#undef __NR_mmap2
-
-/* This is always 12, even on architectures where PAGE_SHIFT != 12. */
-# ifndef MMAP2_PAGE_SHIFT
-# define MMAP2_PAGE_SHIFT 12
-# endif
-
-#include <bits/uClibc_page.h> /* for PAGE_SIZE */
-inline static void *_dl_memset(void*,int,size_t);
-inline static ssize_t _dl_pread(int fd, void *buf, size_t count, off_t offset);
-
-static __ptr_t
-_dl_mmap(__ptr_t addr, size_t len, int prot, int flags, int fd, __off_t offset)
-{
- size_t plen = (len + PAGE_SIZE - 1) & -PAGE_SIZE;
-
-/* This is a hack to enable the dynamic loader to run within a
- simulator that doesn't support mmap, with a number of very ugly
- tricks. Also, it's not as useful as it sounds, since only dynamic
- executables without DT_NEEDED dependencies can be run. AFAIK, they
- can only be created with -pie. This trick suffices to enable the
- dynamic loader to obtain a blank page that it maps early in the
- bootstrap. */
- if ((flags & MAP_FIXED) == 0)
- {
- void *_dl_mmap_base = 0;
- __ptr_t *ret = 0;
-
- if (! _dl_mmap_base)
- {
- void *stack;
- __asm__ ("mov sp, %0" : "=r" (stack));
- _dl_mmap_base = (void *)(((long)stack + 2 * PAGE_SIZE) & -PAGE_SIZE);
- retry:
- if (((void **)_dl_mmap_base)[0] == _dl_mmap_base
- && ((void **)_dl_mmap_base)[1023] == _dl_mmap_base
- && (((void **)_dl_mmap_base)[177]
- == ((void **)_dl_mmap_base)[771]))
- {
- while (((void**)_dl_mmap_base)[177])
- {
- _dl_mmap_base = ((void**)_dl_mmap_base)[177];
- if (!(((void **)_dl_mmap_base)[0] == _dl_mmap_base
- && ((void **)_dl_mmap_base)[1023] == _dl_mmap_base
- && (((void **)_dl_mmap_base)[177]
- == ((void**)_dl_mmap_base)[771])))
- ((void(*)())0)();
- }
- }
- else
- {
- int i;
- for (i = 0; i < (int)PAGE_SIZE; i++)
- if (*(char*)(_dl_mmap_base + i))
- break;
- if (i != PAGE_SIZE)
- {
- _dl_mmap_base = (void*)((long)_dl_mmap_base + PAGE_SIZE);
- goto retry;
- }
- ((void**)_dl_mmap_base)[-1] =
- ((void**)_dl_mmap_base)[0] =
- ((void**)_dl_mmap_base)[1023] =
- _dl_mmap_base;
- }
- }
-
- if (_dl_mmap_base)
- {
- if (!(((void **)_dl_mmap_base)[0] == _dl_mmap_base
- && ((void **)_dl_mmap_base)[1023] == _dl_mmap_base
- && (((void **)_dl_mmap_base)[177]
- == ((void**)_dl_mmap_base)[771])))
- ((void(*)())0)();
- ret = (__ptr_t)((char*)_dl_mmap_base + PAGE_SIZE);
- _dl_mmap_base =
- ((void**)_dl_mmap_base)[177] =
- ((void**)_dl_mmap_base)[771] =
- (char*)_dl_mmap_base + plen + PAGE_SIZE;
- ((void**)_dl_mmap_base)[0] =
- ((void**)_dl_mmap_base)[1023] =
- _dl_mmap_base;
- }
-
- if ((flags & MAP_ANONYMOUS) != 0)
- {
- _dl_memset (ret, 0, plen);
- return ret;
- }
-
- flags |= MAP_FIXED;
- addr = ret;
- }
- if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1)) {
-#if 0
- __set_errno (EINVAL);
-#endif
- return MAP_FAILED;
- }
- if ((flags & MAP_FIXED) != 0)
- {
- if (_dl_pread(fd, addr, len, offset) != (ssize_t)len)
- return (void*)MAP_FAILED;
- if (plen != len)
- _dl_memset (addr + len, 0, plen - len);
- return addr;
- }
- return(__syscall_mmap2(addr, len, prot, flags, fd, (off_t) (offset >> MMAP2_PAGE_SHIFT)));
-}
-#endif
-
-#ifdef __NR_pread
-#ifdef DYNAMIC_LOADER_IN_SIMULATOR
-#include <unistd.h>
-
-#define __NR___syscall_lseek __NR_lseek
-inline static unsigned long _dl_read(int fd, const void *buf, unsigned long count);
-
-inline static _syscall3(__off_t, __syscall_lseek, int, fd, __off_t, offset,
- int, whence);
-inline static ssize_t
-_dl_pread(int fd, void *buf, size_t count, off_t offset)
-{
- __off_t orig = __syscall_lseek (fd, 0, SEEK_CUR);
- ssize_t ret;
-
- if (orig == -1)
- return -1;
-
- if (__syscall_lseek (fd, offset, SEEK_SET) != offset)
- return -1;
-
- ret = _dl_read (fd, buf, count);
-
- if (__syscall_lseek (fd, orig, SEEK_SET) != orig)
- ((void(*)())0)();
-
- return ret;
-}
-#else
-#define __NR___syscall_pread __NR_pread
-inline static _syscall5(ssize_t, __syscall_pread, int, fd, void *, buf,
- size_t, count, off_t, offset_hi, off_t, offset_lo);
-
-inline static ssize_t
-_dl_pread(int fd, void *buf, size_t count, off_t offset)
-{
- return(__syscall_pread(fd,buf,count,__LONG_LONG_PAIR (offset >> 31, offset)));
-}
-#endif
-#endif
+License along with uClibc; see the file COPYING.LIB. If not, see
+<http://www.gnu.org/licenses/>. */
#ifdef __NR_sram_alloc
#define __NR__dl_sram_alloc __NR_sram_alloc
-inline static _syscall2(__ptr_t, _dl_sram_alloc,
- size_t, len, unsigned long, flags);
+static __always_inline _syscall2(__ptr_t, _dl_sram_alloc,
+ size_t, len, unsigned long, flags)
#endif
#ifdef __NR_sram_free
#define __NR__dl_sram_free __NR_sram_free
-inline static _syscall1(int, _dl_sram_free, __ptr_t, addr);
+static __always_inline _syscall1(int, _dl_sram_free, __ptr_t, addr)
#endif
#ifdef __NR_dma_memcpy
#define __NR__dl_dma_memcpy __NR_dma_memcpy
-inline static _syscall3(__ptr_t, _dl_dma_memcpy,
- __ptr_t, dest, __ptr_t, src, size_t, len);
+static __always_inline _syscall3(__ptr_t, _dl_dma_memcpy,
+ __ptr_t, dest, __ptr_t, src, size_t, len)
#endif
#define __UCLIBC_MMAP_HAS_6_ARGS__
diff --git a/ldso/ldso/bfin/dl-sysdep.h b/ldso/ldso/bfin/dl-sysdep.h
index 52df4c91f..5758117ba 100644
--- a/ldso/ldso/bfin/dl-sysdep.h
+++ b/ldso/ldso/bfin/dl-sysdep.h
@@ -1,23 +1,10 @@
- /* Copyright (C) 2003, 2004 Red Hat, Inc.
- Contributed by Alexandre Oliva <aoliva@redhat.com>
- Based on ../i386/dl-sysdep.h
-
-This file is part of uClibc.
-
-uClibc 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.
-
-uClibc is distributed in the hope that 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 uClibc; see the file COPYING.LIB. If not, write to
-the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
-USA. */
+/* Copyright (C) 2003, 2004 Red Hat, Inc.
+ * Contributed by Alexandre Oliva <aoliva@redhat.com>
+ * Copyright (C) 2006-2011 Analog Devices, Inc.
+ * Based on ../i386/dl-sysdep.h
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
/*
* Various assembly language/system dependent hacks that are required
@@ -34,21 +21,6 @@ USA. */
#define DL_NO_COPY_RELOCS
-#define HAVE_DL_INLINES_H
-
-/*
- * Initialization sequence for a GOT. Copy the resolver function
- * descriptor and the pointer to the elf_resolve/link_map data
- * structure. Initialize the got_value in the module while at that.
- */
-#define INIT_GOT(GOT_BASE,MODULE) \
-{ \
- (MODULE)->loadaddr.got_value = (GOT_BASE); \
- GOT_BASE[0] = ((unsigned long *)&_dl_linux_resolve)[0]; \
- GOT_BASE[1] = ((unsigned long *)&_dl_linux_resolve)[1]; \
- GOT_BASE[2] = (unsigned long) MODULE; \
-}
-
/* Here we define the magic numbers that this dynamic loader should accept */
#define MAGIC1 EM_BLACKFIN
#undef MAGIC2
@@ -56,25 +28,11 @@ USA. */
/* Used for error messages */
#define ELF_TARGET "BFIN"
-struct elf_resolve;
-
-struct funcdesc_value
-{
- void *entry_point;
- void *got_value;
-} __attribute__((__aligned__(8)));
-
+/* Need bootstrap relocations */
+#define ARCH_NEEDS_BOOTSTRAP_RELOCS
extern int _dl_linux_resolve(void) __attribute__((__visibility__("hidden")));
-/* 4KiB page alignment. Should perhaps be made dynamic using
- getpagesize(), based on AT_PAGESZ from auxvt? */
-#define PAGE_ALIGN 0xfffff000
-#define ADDR_ALIGN 0xfff
-#define OFFS_ALIGN 0x7ffff000
-
-struct funcdesc_ht;
-
#undef SEND_EARLY_STDERR
#define SEND_EARLY_STDERR(S) \
do { \
@@ -92,63 +50,6 @@ struct funcdesc_ht;
for (__t = 0; __t < 0x1000000; __t++) __asm__ __volatile__ (""); } \
} while (0)
-#define DL_LOADADDR_TYPE struct elf32_fdpic_loadaddr
-
-#define DL_RELOC_ADDR(LOADADDR, ADDR) \
- ((ElfW(Addr))__reloc_pointer ((void*)(ADDR), (LOADADDR).map))
-
-#define DL_ADDR_TO_FUNC_PTR(ADDR, LOADADDR) \
- ((void(*)(void)) _dl_funcdesc_for ((void*)(ADDR), (LOADADDR).got_value))
-
-#define _dl_stabilize_funcdesc(val) \
- ({ __asm__ ("" : "+m" (*(val))); (val); })
-
-#define DL_CALL_FUNC_AT_ADDR(ADDR, LOADADDR, SIGNATURE, ...) \
- ({ struct funcdesc_value fd = { (void*)(ADDR), (LOADADDR).got_value }; \
- void (*pf)(void) = (void*) _dl_stabilize_funcdesc (&fd); \
- (* SIGNATURE pf)(__VA_ARGS__); })
-
-#define DL_INIT_LOADADDR_BOOT(LOADADDR, BASEADDR) \
- (__dl_init_loadaddr_map (&(LOADADDR), dl_boot_got_pointer, \
- dl_boot_ldsomap ?: dl_boot_progmap))
-
-#define DL_INIT_LOADADDR_PROG(LOADADDR, BASEADDR) \
- (__dl_init_loadaddr_map (&(LOADADDR), 0, dl_boot_progmap))
-
-#define DL_INIT_LOADADDR_EXTRA_DECLS \
- int dl_init_loadaddr_load_count;
-#define DL_INIT_LOADADDR(LOADADDR, BASEADDR, PHDR, PHDRCNT) \
- (dl_init_loadaddr_load_count = \
- __dl_init_loadaddr (&(LOADADDR), (PHDR), (PHDRCNT)))
-#define DL_INIT_LOADADDR_HDR(LOADADDR, ADDR, PHDR) \
- (__dl_init_loadaddr_hdr ((LOADADDR), (ADDR), (PHDR), \
- dl_init_loadaddr_load_count))
-#define DL_LOADADDR_UNMAP(LOADADDR, LEN) \
- (__dl_loadaddr_unmap ((LOADADDR), (NULL)))
-#define DL_LIB_UNMAP(LIB, LEN) \
- (__dl_loadaddr_unmap ((LIB)->loadaddr, (LIB)->funcdesc_ht))
-#define DL_LOADADDR_BASE(LOADADDR) \
- ((LOADADDR).got_value)
-
-/* This is called from dladdr(), such that we map a function
- descriptor's address to the function's entry point before trying to
- find in which library it's defined. */
-#define DL_LOOKUP_ADDRESS(ADDRESS) (_dl_lookup_address (ADDRESS))
-
-#define DL_ADDR_IN_LOADADDR(ADDR, TPNT, TFROM) \
- (! (TFROM) && __dl_addr_in_loadaddr ((void*)(ADDR), (TPNT)->loadaddr))
-
-/*
- * Compute the GOT address. On several platforms, we use assembly
- * here. on FR-V FDPIC, there's no way to compute the GOT address,
- * since the offset between text and data is not fixed, so we arrange
- * for the assembly _dl_boot to pass this value as an argument to
- * _dl_boot. */
-#define DL_BOOT_COMPUTE_GOT(got) ((got) = dl_boot_got_pointer)
-
-#define DL_BOOT_COMPUTE_DYN(dpnt, got, load_addr) \
- ((dpnt) = dl_boot_ldso_dyn_pointer)
-
/* We only support loading FDPIC independently-relocatable shared
libraries. It probably wouldn't be too hard to support loading
shared libraries that require relocation by the same amount, but we
@@ -173,57 +74,25 @@ do \
} \
while (0)
-/* We want want to apply all relocations in the interpreter during
- bootstrap. Because of this, we have to skip the interpreter
- relocations in _dl_parse_relocation_information(), see
- elfinterp.c. */
-#define DL_SKIP_BOOTSTRAP_RELOC(SYMTAB, INDEX, STRTAB) 0
-
-#ifdef __NR_pread
-#define _DL_PREAD(FD, BUF, SIZE, OFFSET) \
- (_dl_pread((FD), (BUF), (SIZE), (OFFSET)))
-#endif
-
-/* We want to return to dlsym() a function descriptor if the symbol
- turns out to be a function. */
-#define DL_FIND_HASH_VALUE(TPNT, TYPE_CLASS, SYM) \
- (((TYPE_CLASS) & ELF_RTYPE_CLASS_DLSYM) \
- && ELF32_ST_TYPE((SYM)->st_info) == STT_FUNC \
- ? _dl_funcdesc_for ((void *)DL_RELOC_ADDR ((TPNT)->loadaddr, (SYM)->st_value), \
- (TPNT)->loadaddr.got_value) \
- : DL_RELOC_ADDR ((TPNT)->loadaddr, (SYM)->st_value))
-
#define DL_IS_SPECIAL_SEGMENT(EPNT, PPNT) \
__dl_is_special_segment(EPNT, PPNT)
#define DL_MAP_SEGMENT(EPNT, PPNT, INFILE, FLAGS) \
__dl_map_segment (EPNT, PPNT, INFILE, FLAGS)
-#define DL_GET_READY_TO_RUN_EXTRA_PARMS \
- , struct elf32_fdpic_loadmap *dl_boot_progmap, Elf32_Addr dl_boot_got_pointer
-#define DL_GET_READY_TO_RUN_EXTRA_ARGS \
- , dl_boot_progmap, dl_boot_got_pointer
-
+#if defined(__BFIN_FDPIC__)
+#include "../fdpic/dl-sysdep.h"
-#ifdef __USE_GNU
-# include <link.h>
-#else
-# define __USE_GNU
-# include <link.h>
-# undef __USE_GNU
-#endif
+static __always_inline Elf32_Addr
+elf_machine_load_address (void)
+{
+ /* this is never an issue on Blackfin systems, so screw it */
+ return 0;
+}
-#include <elf.h>
-static __inline__ void
+static __always_inline void
elf_machine_relative (DL_LOADADDR_TYPE load_off, const Elf32_Addr rel_addr,
Elf32_Word relative_count)
{
-#if 0
- Elf32_Rel * rpnt = (void *) rel_addr;
- --rpnt;
- do {
- Elf32_Addr *const reloc_addr = (void *) (load_off + (++rpnt)->r_offset);
-
- *reloc_addr = DL_RELOC_ADDR (load_off, *reloc_addr);
- } while (--relative_count);
-#endif
+ return 0;
}
+#endif
diff --git a/ldso/ldso/bfin/elfinterp.c b/ldso/ldso/bfin/elfinterp.c
index ac24337a1..4e1c1c75f 100644
--- a/ldso/ldso/bfin/elfinterp.c
+++ b/ldso/ldso/bfin/elfinterp.c
@@ -20,9 +20,8 @@ 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 uClibc; see the file COPYING.LIB. If not, write to
-the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
-USA. */
+License along with uClibc; see the file COPYING.LIB. If not, see
+<http://www.gnu.org/licenses/>. */
#include <sys/cdefs.h> /* __attribute_used__ */
@@ -37,44 +36,39 @@ USA. */
a more than adequate job of explaining everything required to get this
working. */
-struct funcdesc_value volatile *__attribute__((__visibility__("hidden")))
+__attribute__((__visibility__("hidden")))
+struct funcdesc_value volatile *
_dl_linux_resolver (struct elf_resolve *tpnt, int reloc_entry)
{
- int reloc_type;
ELF_RELOC *this_reloc;
char *strtab;
ElfW(Sym) *symtab;
int symtab_index;
char *rel_addr;
- struct elf_resolve *new_tpnt;
char *new_addr;
struct funcdesc_value funcval;
struct funcdesc_value volatile *got_entry;
char *symname;
+ struct symbol_ref sym_ref;
rel_addr = (char *)tpnt->dynamic_info[DT_JMPREL];
this_reloc = (ELF_RELOC *)(intptr_t)(rel_addr + reloc_entry);
- reloc_type = ELF_R_TYPE(this_reloc->r_info);
symtab_index = ELF_R_SYM(this_reloc->r_info);
- symtab = (Elf32_Sym *) tpnt->dynamic_info[DT_SYMTAB];
+ symtab = (ElfW(Sym) *) tpnt->dynamic_info[DT_SYMTAB];
strtab = (char *) tpnt->dynamic_info[DT_STRTAB];
+ sym_ref.sym = &symtab[symtab_index];
+ sym_ref.tpnt = NULL;
symname= strtab + symtab[symtab_index].st_name;
- if (reloc_type != R_BFIN_FUNCDESC_VALUE) {
- _dl_dprintf(2, "%s: Incorrect relocation type in jump relocations\n",
- _dl_progname);
- _dl_exit(1);
- }
-
/* Address of GOT entry fix up */
got_entry = (struct funcdesc_value *) DL_RELOC_ADDR(tpnt->loadaddr, this_reloc->r_offset);
/* Get the address to be used to fill in the GOT entry. */
- new_addr = _dl_lookup_hash(symname, tpnt->symbol_scope, NULL, 0, &new_tpnt);
+ new_addr = _dl_find_hash(symname, &_dl_loaded_modules->symbol_scope, NULL, 0, &sym_ref);
if (!new_addr) {
- new_addr = _dl_lookup_hash(symname, NULL, NULL, 0, &new_tpnt);
+ new_addr = _dl_find_hash(symname, NULL, NULL, 0, &sym_ref);
if (!new_addr) {
_dl_dprintf(2, "%s: can't resolve symbol '%s'\n",
_dl_progname, symname);
@@ -83,7 +77,7 @@ _dl_linux_resolver (struct elf_resolve *tpnt, int reloc_entry)
}
funcval.entry_point = new_addr;
- funcval.got_value = new_tpnt->loadaddr.got_value;
+ funcval.got_value = sym_ref.tpnt->loadaddr.got_value;
#if defined (__SUPPORT_LD_DEBUG__)
if (_dl_debug_bindings) {
@@ -106,9 +100,9 @@ _dl_linux_resolver (struct elf_resolve *tpnt, int reloc_entry)
}
static int
-_dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
+_dl_parse(struct elf_resolve *tpnt, struct r_scope_elem *scope,
unsigned long rel_addr, unsigned long rel_size,
- int (*reloc_fnc) (struct elf_resolve *tpnt, struct dyn_elf *scope,
+ int (*reloc_fnc) (struct elf_resolve *tpnt, struct r_scope_elem *scope,
ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab))
{
unsigned int i;
@@ -157,7 +151,7 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
}
static int
-_dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
+_dl_do_reloc (struct elf_resolve *tpnt,struct r_scope_elem *scope,
ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
{
int reloc_type;
@@ -172,12 +166,15 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
#if defined (__SUPPORT_LD_DEBUG__)
unsigned long old_val;
#endif
+ struct symbol_ref sym_ref;
reloc_addr = (unsigned long *) DL_RELOC_ADDR(tpnt->loadaddr, rpnt->r_offset);
__asm__ ("" : "=r" (reloc_addr_packed) : "0" (reloc_addr));
reloc_type = ELF_R_TYPE(rpnt->r_info);
symtab_index = ELF_R_SYM(rpnt->r_info);
symbol_addr = 0;
+ sym_ref.sym = &symtab[symtab_index];
+ sym_ref.tpnt = NULL;
symname = strtab + symtab[symtab_index].st_name;
if (ELF_ST_BIND (symtab[symtab_index].st_info) == STB_LOCAL) {
@@ -186,7 +183,7 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
} else {
symbol_addr = (unsigned long)
- _dl_lookup_hash(symname, scope, NULL, 0, &symbol_tpnt);
+ _dl_find_hash(symname, scope, NULL, 0, &sym_ref);
/*
* We want to allow undefined references to weak symbols - this might
@@ -196,9 +193,14 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
if (!symbol_addr && ELF_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK) {
_dl_dprintf (2, "%s: can't resolve symbol '%s'\n",
- _dl_progname, strtab + symtab[symtab_index].st_name);
+ _dl_progname, symname);
_dl_exit (1);
}
+ if (_dl_trace_prelink) {
+ _dl_debug_lookup (symname, tpnt, &symtab[symtab_index],
+ &sym_ref, elf_machine_type_class(reloc_type));
+ }
+ symbol_tpnt = sym_ref.tpnt;
}
#if defined (__SUPPORT_LD_DEBUG__)
@@ -213,9 +215,9 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
old_val = 0;
#endif
switch (reloc_type) {
- case R_BFIN_unused0:
+ case R_BFIN_UNUSED0:
break;
- case R_BFIN_byte4_data:
+ case R_BFIN_BYTE4_DATA:
if ((long)reloc_addr_packed & 3)
reloc_value = reloc_addr_packed->v += symbol_addr;
else
@@ -282,7 +284,7 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
static int
_dl_do_lazy_reloc (struct elf_resolve *tpnt,
- struct dyn_elf *scope __attribute__((unused)),
+ struct r_scope_elem *scope __attribute__((unused)),
ELF_RELOC *rpnt, ElfW(Sym) *symtab __attribute__((unused)),
char *strtab __attribute__((unused)))
{
@@ -300,11 +302,11 @@ _dl_do_lazy_reloc (struct elf_resolve *tpnt,
old_val = (unsigned long)reloc_addr->entry_point;
#endif
switch (reloc_type) {
- case R_BFIN_unused0:
+ case R_BFIN_UNUSED0:
break;
case R_BFIN_FUNCDESC_VALUE:
funcval = *reloc_addr;
- funcval.entry_point = DL_RELOC_ADDR(tpnt->loadaddr, funcval.entry_point);
+ funcval.entry_point = (void *) DL_RELOC_ADDR(tpnt->loadaddr, funcval.entry_point);
funcval.got_value = tpnt->loadaddr.got_value;
*reloc_addr = funcval;
break;
@@ -313,7 +315,7 @@ _dl_do_lazy_reloc (struct elf_resolve *tpnt,
}
#if defined (__SUPPORT_LD_DEBUG__)
if (_dl_debug_reloc && _dl_debug_detail)
- _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x", old_val, reloc_addr->entry_point, reloc_addr);
+ _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x\n", old_val, reloc_addr->entry_point, reloc_addr);
#endif
return 0;
@@ -328,9 +330,9 @@ _dl_parse_lazy_relocation_information
int
_dl_parse_relocation_information
-(struct dyn_elf *rpnt, unsigned long rel_addr, unsigned long rel_size)
+(struct dyn_elf *rpnt, struct r_scope_elem *scope, unsigned long rel_addr, unsigned long rel_size)
{
- return _dl_parse(rpnt->dyn, rpnt->dyn->symbol_scope, rel_addr, rel_size, _dl_do_reloc);
+ return _dl_parse(rpnt->dyn, scope, rel_addr, rel_size, _dl_do_reloc);
}
/* We don't have copy relocs. */
diff --git a/ldso/ldso/bfin/resolve.S b/ldso/ldso/bfin/resolve.S
index ae7f4a4c5..4ac12c36c 100644
--- a/ldso/ldso/bfin/resolve.S
+++ b/ldso/ldso/bfin/resolve.S
@@ -14,9 +14,8 @@ 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 uClibc; see the file COPYING.LIB. If not, write to
-the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
-USA. */
+License along with uClibc; see the file COPYING.LIB. If not, see
+<http://www.gnu.org/licenses/>. */
/* The function below is tail-called by resolver stubs when a
lazily-bound function is called. It must preserve all
diff --git a/ldso/ldso/c6x/dl-debug.h b/ldso/ldso/c6x/dl-debug.h
new file mode 100644
index 000000000..d4915bf21
--- /dev/null
+++ b/ldso/ldso/c6x/dl-debug.h
@@ -0,0 +1,49 @@
+/* C6X DSBT ELF shared library loader suppport.
+ *
+ * Copyright (C) 2010 Texas Instruments Incorporated
+ * Contributed by Mark Salter <msalter@redhat.com>
+ *
+ * All rights reserved.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+static const char * const _dl_reltypes_tab[] =
+{
+ "R_C6000_NONE", /* 0 */
+ "R_C6000_ABS32",
+ "R_C6000_ABS16",
+ "R_C6000_ABS8",
+ "R_C6000_PCR_S21",
+ "R_C6000_PCR_S12", /* 5 */
+ "R_C6000_PCR_S10",
+ "R_C6000_PCR_S7",
+ "R_C6000_ABS_S16",
+ "R_C6000_ABS_L16",
+ "R_C6000_ABS_H16", /* 10 */
+ "R_C6000_SBR_U15_B",
+ "R_C6000_SBR_U15_H",
+ "R_C6000_SBR_U15_W",
+ "R_C6000_SBR_S16",
+ "R_C6000_SBR_L16_B", /* 15 */
+ "R_C6000_SBR_L16_H",
+ "R_C6000_SBR_L16_W",
+ "R_C6000_SBR_H16_B",
+ "R_C6000_SBR_H16_H",
+ "R_C6000_SBR_H16_W", /* 20 */
+ "R_C6000_SBR_GOT_U15_W",
+ "R_C6000_SBR_GOT_L16_W",
+ "R_C6000_SBR_GOT_H16_W",
+ "R_C6000_DSBT_INDEX",
+ "R_C6000_PREL31", /* 25 */
+ "R_C6000_COPY",
+ "R_C6000_JUMP_SLOT",
+ "R_C6000_SBR_GOT32",
+ "R_C6000_PCR_H16",
+ "R_C6000_PCR_L16", /* 30 */
+#if 0
+ "R_C6000_ALIGN", /* 253 */
+ "R_C6000_FPHEAD", /* 254 */
+ "R_C6000_NOCMP", /* 255 */
+#endif
+};
diff --git a/ldso/ldso/c6x/dl-inlines.h b/ldso/ldso/c6x/dl-inlines.h
new file mode 100644
index 000000000..62e1cc9ca
--- /dev/null
+++ b/ldso/ldso/c6x/dl-inlines.h
@@ -0,0 +1,120 @@
+/* Copyright (C) 2010 Texas Instruments Incorporated
+ * Contributed by Mark Salter <msalter@redhat.com>
+ *
+ * Borrowed heavily from frv arch:
+ * Copyright (C) 2003, 2004 Red Hat, Inc.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+/* Figure out whether the given address is in one of the mapped
+ segments. */
+static __always_inline int
+__dl_addr_in_loadaddr (void *p, struct elf32_dsbt_loadaddr loadaddr)
+{
+ struct elf32_dsbt_loadmap *map = loadaddr.map;
+ int c;
+
+ for (c = 0; c < map->nsegs; c++)
+ if ((void*)map->segs[c].addr <= p
+ && (char*)p < (char*)map->segs[c].addr + map->segs[c].p_memsz)
+ return 1;
+
+ return 0;
+}
+
+/* Figure out how many LOAD segments there are in the given headers,
+ and allocate a block for the load map big enough for them.
+ got_value will be properly initialized later on, with INIT_GOT. */
+static __always_inline int
+__dl_init_loadaddr (struct elf32_dsbt_loadaddr *loadaddr, Elf32_Phdr *ppnt,
+ int pcnt)
+{
+ int count = 0, i;
+ size_t size;
+
+ for (i = 0; i < pcnt; i++)
+ if (ppnt[i].p_type == PT_LOAD)
+ count++;
+
+ size = sizeof (struct elf32_dsbt_loadmap)
+ + sizeof (struct elf32_dsbt_loadseg) * count;
+ loadaddr->map = _dl_malloc (size);
+ if (! loadaddr->map)
+ _dl_exit (-1);
+
+ loadaddr->map->version = 0;
+ loadaddr->map->nsegs = 0;
+
+ return count;
+}
+
+/* Incrementally initialize a load map. */
+static __always_inline void
+__dl_init_loadaddr_hdr (struct elf32_dsbt_loadaddr loadaddr, void *addr,
+ Elf32_Phdr *phdr, int maxsegs)
+{
+ struct elf32_dsbt_loadseg *segdata;
+
+ if (loadaddr.map->nsegs == maxsegs)
+ _dl_exit (-1);
+
+ segdata = &loadaddr.map->segs[loadaddr.map->nsegs++];
+ segdata->addr = (Elf32_Addr) addr;
+ segdata->p_vaddr = phdr->p_vaddr;
+ segdata->p_memsz = phdr->p_memsz;
+
+#if defined (__SUPPORT_LD_DEBUG__)
+ {
+ if (_dl_debug)
+ _dl_dprintf(_dl_debug_file, "%i: mapped %x at %x, size %x\n",
+ loadaddr.map->nsegs-1,
+ segdata->p_vaddr, segdata->addr, segdata->p_memsz);
+ }
+#endif
+}
+
+/* Replace an existing entry in the load map. */
+static __always_inline void
+__dl_update_loadaddr_hdr (struct elf32_dsbt_loadaddr loadaddr, void *addr,
+ Elf32_Phdr *phdr)
+{
+ struct elf32_dsbt_loadseg *segdata;
+ void *oldaddr;
+ int i;
+
+ for (i = 0; i < loadaddr.map->nsegs; i++)
+ if (loadaddr.map->segs[i].p_vaddr == phdr->p_vaddr
+ && loadaddr.map->segs[i].p_memsz == phdr->p_memsz)
+ break;
+ if (i == loadaddr.map->nsegs)
+ _dl_exit (-1);
+
+ segdata = loadaddr.map->segs + i;
+ oldaddr = (void *)segdata->addr;
+ _dl_munmap (oldaddr, segdata->p_memsz);
+ segdata->addr = (Elf32_Addr) addr;
+
+#if defined (__SUPPORT_LD_DEBUG__)
+ if (_dl_debug)
+ _dl_dprintf(_dl_debug_file, "%i: changed mapping %x at %x (old %x), size %x\n",
+ loadaddr.map->nsegs-1,
+ segdata->p_vaddr, segdata->addr, oldaddr, segdata->p_memsz);
+#endif
+}
+
+static __always_inline void
+__dl_loadaddr_unmap (struct elf32_dsbt_loadaddr loadaddr)
+{
+ int i;
+
+ for (i = 0; i < loadaddr.map->nsegs; i++)
+ _dl_munmap ((void*)loadaddr.map->segs[i].addr,
+ loadaddr.map->segs[i].p_memsz);
+
+ /* _dl_unmap is only called for dlopen()ed libraries, for which
+ calling free() is safe, or before we've completed the initial
+ relocation, in which case calling free() is probably pointless,
+ but still safe. */
+ _dl_free (loadaddr.map);
+}
diff --git a/ldso/ldso/c6x/dl-startup.h b/ldso/ldso/c6x/dl-startup.h
new file mode 100644
index 000000000..c83e33cb3
--- /dev/null
+++ b/ldso/ldso/c6x/dl-startup.h
@@ -0,0 +1,189 @@
+/* Copyright (C) 2010 Texas Instruments Incorporated
+ * Contributed by Mark Salter <msalter@redhat.com>
+ *
+ * Borrowed heavily from frv arch:
+ * Copyright (C) 2003 Red Hat, Inc.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+#undef DL_START
+#define DL_START(X) \
+static void * __attribute_used__ \
+_dl_start (unsigned placeholder, \
+ struct elf32_dsbt_loadmap *dl_boot_progmap, \
+ struct elf32_dsbt_loadmap *dl_boot_ldsomap, \
+ Elf32_Dyn *dl_boot_ldso_dyn_pointer, \
+ X)
+
+/*
+ * On entry, the kernel has set up the stack thusly:
+ *
+ * 0(sp) pad0
+ * 4(sp) pad1
+ * 8(sp) argc
+ * 12(sp) argv[0]
+ * ...
+ * (4*(argc+3))(sp) NULL
+ * (4*(argc+4))(sp) envp[0]
+ * ...
+ * NULL
+ *
+ * Register values are unspecified, except:
+ *
+ * B4 --> executable loadmap address
+ * A6 --> interpreter loadmap address
+ * B6 --> dynamic section address
+ *
+ * NB: DSBT index is always 0 for the executable
+ * and 1 for the interpreter
+ */
+
+__asm__(" .text\n"
+ ".globl _start\n"
+ ".hidden _start\n"
+ "_start:\n"
+ /* Find interpreter DSBT base in dynamic section */
+ " MV .S2 B6,B2\n"
+ " || ADD .D1X B6,4,A2\n"
+ " LDW .D2T2 *B2++[2],B0\n"
+ " || LDW .D1T1 *A2++[2],A0\n"
+ " MVKL .S2 " __stringify(DT_C6000_DSBT_BASE) ",B7\n"
+ " MVKH .S2 " __stringify(DT_C6000_DSBT_BASE) ",B7\n"
+ " NOP\n"
+ " NOP\n"
+ /*
+ * B0 now holds dynamic tag and A0 holds tag value.
+ * Loop through looking for DSBT base tag
+ */
+ "0:\n"
+ " [B0] CMPEQ .L2 B0,B7,B1\n"
+ " || [!B0] MVK .S2 1,B1\n"
+ " [!B1] BNOP .S1 0b,5\n"
+ " ||[!B1] LDW .D2T2 *B2++[2],B0\n"
+ " ||[!B1] LDW .D1T1 *A2++[2],A0\n"
+ /*
+ * DSBT base in A0 needs to be relocated.
+ * Search through our loadmap to find where it got loaded.
+ *
+ * struct elf32_dsbt_loadmap {
+ * Elf32_Half version;
+ * Elf32_Half nsegs;
+ * struct {
+ * Elf32_Addr addr;
+ * Elf32_Addr p_vaddr;
+ * Elf32_Word p_memsz;
+ * } segments[];
+ * }
+ *
+ */
+ " MV .S1 A6,A1\n"
+ " [!A1] MV .S1X B4,A1\n"
+ " ADD .D1 A1,2,A3\n"
+ " LDHU .D1T2 *A3++[1],B0\n" /* nsegs */
+ " LDW .D1T1 *A3++[1],A10\n" /* addr */
+ " LDW .D1T1 *A3++[1],A11\n" /* p_vaddr */
+ " LDW .D1T1 *A3++[1],A12\n" /* p_memsz */
+ " NOP\n"
+ " NOP\n"
+ /*
+ * Here we have:
+ * B0 -> number of segments to search.
+ * A3 -> pointer to next segment to check
+ * A10 -> segment load address
+ * A11 -> ELF segment virt address
+ * A12 -> ELF segment size
+ */
+ "0:\n"
+ " [!B0] B .S2 0f\n"
+ " SUB .D2 B0,1,B0\n"
+ " CMPLTU .L1 A0,A11,A13\n"
+ " || SUB .S1 A12,1,A12\n"
+ " ADD .D1 A11,A12,A12\n"
+ " CMPGTU .L1 A0,A12,A14\n"
+ " OR .L1 A13,A14,A2\n"
+ " [A2] B .S2 0b\n"
+ " || [!A2] SUB .L1 A0,A11,A0\n"
+ " [B0] LDW .D1T1 *A3++[1],A10\n" /* addr */
+ " || [!A2] ADD .L1 A0,A10,A0\n"
+ " [B0] LDW .D1T1 *A3++[1],A11\n" /* p_vaddr */
+ " [B0] LDW .D1T1 *A3++[1],A12\n" /* p_memsz */
+ " MV .S2X A0,B14\n"
+ " NOP\n"
+ "0:\n"
+ " B .S2 _dl_start\n"
+ " STW .D2T2 B14, *+B14[1]\n"
+ " ADD .D1X B15,8,A8\n"
+ " ADDKPC .S2 ret_from_dl,B3,2\n"
+ "ret_from_dl:\n"
+ " B .S2X A4\n"
+ " || LDW .D2T2 *+B14[0],B14\n"
+ " ADDKPC .S2 __dl_fini,B0,0\n"
+ " MV .S1X B0,A4\n"
+ " NOP\n"
+ " NOP\n"
+ " NOP\n"
+ "__dl_fini:\n"
+ " LDW .D2T2 *+B14[1],B14\n"
+ " NOP 4\n"
+ " LDW .D2T1 *+B14($GOT(_dl_fini)), A0\n"
+ " NOP 4\n"
+ " BNOP .S2X A0, 5\n");
+
+__asm__(" .text\n"
+ "__c6x_cache_sync:\n"
+ " MVK .S2 330,B0\n"
+ " SWE\n"
+ " NOP\n"
+ " BNOP .S2 B3,5\n"
+ " NOP\n"
+ " NOP\n"
+ " NOP\n"
+ " NOP\n"
+ "\n"
+);
+
+/*
+ * Get a pointer to the argv array. On many platforms this can be just
+ * the address of the first argument, on other platforms we need to
+ * do something a little more subtle here.
+ */
+#define GET_ARGV(ARGVP, ARGS) ARGVP = (((unsigned long*) ARGS) + 1)
+
+struct elf32_dsbt_loadmap;
+
+/*
+ * Here is a macro to perform a relocation. This is only used when
+ * bootstrapping the dynamic loader. RELP is the relocation that we
+ * are performing, REL is the pointer to the address we are relocating.
+ * SYMBOL is the symbol involved in the relocation, and LOAD is the
+ * load address.
+ */
+#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB) \
+ switch(ELF_R_TYPE((RELP)->r_info)){ \
+ case R_C6000_ABS_L16: \
+ { \
+ unsigned int opcode = *(REL); \
+ unsigned int v = (SYMBOL) + (RELP)->r_addend; \
+ opcode &= ~0x7fff80; \
+ opcode |= ((v & 0xffff) << 7); \
+ *(REL) = opcode; \
+ } \
+ break; \
+ case R_C6000_ABS_H16: \
+ { \
+ unsigned int opcode = *(REL); \
+ unsigned int v = (SYMBOL) + (RELP)->r_addend; \
+ opcode &= ~0x7fff80; \
+ opcode |= ((v >> 9) & 0x7fff80); \
+ *(REL) = opcode; \
+ } \
+ break; \
+ case R_C6000_ABS32: \
+ *(REL) = (SYMBOL) + (RELP)->r_addend; \
+ break; \
+ default: \
+ _dl_exit(1); \
+ }
+
+extern void __c6x_cache_sync(unsigned long start, unsigned long end)
+ attribute_hidden;
diff --git a/ldso/ldso/c6x/dl-syscalls.h b/ldso/ldso/c6x/dl-syscalls.h
new file mode 100644
index 000000000..f40c4fd31
--- /dev/null
+++ b/ldso/ldso/c6x/dl-syscalls.h
@@ -0,0 +1 @@
+/* stub for arch-specific syscall issues */
diff --git a/ldso/ldso/c6x/dl-sysdep.h b/ldso/ldso/c6x/dl-sysdep.h
new file mode 100644
index 000000000..c2e91d2f0
--- /dev/null
+++ b/ldso/ldso/c6x/dl-sysdep.h
@@ -0,0 +1,230 @@
+/* Copyright (C) 2010 Texas Instruments Incorporated
+ * Contributed by Mark Salter <msalter@redhat.com>
+ *
+ * Borrowed heavily from frv arch:
+ * Copyright (C) 2003, 2004 Red Hat, Inc.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <bits/elf-dsbt.h>
+
+/*
+ * Define this if the system uses RELOCA.
+ */
+#define ELF_USES_RELOCA 1
+
+/* JMPREL relocs are inside the DT_RELA table. */
+/* Actually looks like a linker bug sets DT_JMPREL anyway */
+#define ELF_MACHINE_PLTREL_OVERLAP 1
+
+#undef DL_NO_COPY_RELOCS
+
+#define HAVE_DL_INLINES_H
+
+
+/*
+ * Various assembly language/system dependent hacks that are required
+ * so that we can minimize the amount of platform specific code.
+ */
+
+/* Initialization sequence for the GOT. */
+#define INIT_GOT(GOT_BASE,MODULE) \
+{ \
+ GOT_BASE[0] = (unsigned long) _dl_linux_resolve; \
+ GOT_BASE[1] = (unsigned long) MODULE; \
+}
+
+/* Here we define the magic numbers that this dynamic loader should accept */
+#define MAGIC1 EM_TI_C6000
+#undef MAGIC2
+
+/* Used for error messages */
+#define ELF_TARGET "C6000"
+
+/* Need bootstrap relocations */
+#define ARCH_NEEDS_BOOTSTRAP_RELOCS
+
+struct elf_resolve;
+
+extern int _dl_linux_resolve(void) attribute_hidden;
+
+struct funcdesc_ht;
+struct elf32_dsbt_loadaddr;
+
+/* Current toolchains access constant strings via unrelocated GOT
+ entries. Fortunately, we have enough in place to just call the
+ relocation function early on. */
+#undef SEND_EARLY_STDERR
+#define SEND_EARLY_STDERR(S) \
+ do { char *__p = __reloc_pointer((S), dl_boot_ldsomap?:dl_boot_progmap);\
+ SEND_STDERR (__p); } while (0)
+
+#define DL_LOADADDR_TYPE struct elf32_dsbt_loadaddr
+
+#define DL_RELOC_ADDR(LOADADDR, ADDR) \
+ ((ElfW(Addr))__reloc_pointer ((void*)(ADDR), (LOADADDR).map))
+
+#define DL_INIT_LOADADDR_BOOT(LOADADDR, BASEADDR) \
+ do { \
+ struct elf32_dsbt_loadmap *map; \
+ map = dl_boot_ldsomap ?: dl_boot_progmap; \
+ if (map->version != 0) { \
+ SEND_EARLY_STDERR ("Invalid loadmap version number\n"); \
+ _dl_exit(-1); \
+ } \
+ if (map->nsegs < 2) { \
+ SEND_EARLY_STDERR ("Invalid segment count in loadmap\n"); \
+ _dl_exit(-1); \
+ } \
+ (LOADADDR).map = map; \
+ } while(0)
+
+#define DL_INIT_LOADADDR_PROG(LOADADDR, BASEADDR) \
+ do { \
+ if (dl_boot_progmap->version != 0) { \
+ SEND_EARLY_STDERR ("Invalid loadmap version number\n"); \
+ _dl_exit(-1); \
+ } \
+ if (dl_boot_progmap->nsegs < 2) { \
+ SEND_EARLY_STDERR ("Invalid segment count in loadmap\n"); \
+ _dl_exit(-1); \
+ } \
+ (LOADADDR).map = dl_boot_progmap; \
+ } while(0)
+
+#define DL_INIT_LOADADDR_EXTRA_DECLS \
+ int dl_init_loadaddr_load_count;
+
+#define DL_INIT_LOADADDR(LOADADDR, BASEADDR, PHDR, PHDRCNT) \
+ (dl_init_loadaddr_load_count = \
+ __dl_init_loadaddr (&(LOADADDR), (PHDR), (PHDRCNT)))
+
+#define DL_INIT_LOADADDR_HDR(LOADADDR, ADDR, PHDR) \
+ (__dl_init_loadaddr_hdr ((LOADADDR), (ADDR), (PHDR), \
+ dl_init_loadaddr_load_count))
+
+#define DL_UPDATE_LOADADDR_HDR(LOADADDR, ADDR, PHDR) \
+ (__dl_update_loadaddr_hdr ((LOADADDR), (ADDR), (PHDR)))
+
+#define DL_LOADADDR_UNMAP(LOADADDR, LEN) \
+ (__dl_loadaddr_unmap ((LOADADDR)))
+
+#define DL_LIB_UNMAP(LIB, LEN) \
+ (__dl_loadaddr_unmap ((LIB)->loadaddr))
+
+#define DL_LOADADDR_BASE(LOADADDR) \
+ ((LOADADDR).map)
+
+#define DL_ADDR_IN_LOADADDR(ADDR, TPNT, TFROM) \
+ (! (TFROM) && __dl_addr_in_loadaddr ((void*)(ADDR), (TPNT)->loadaddr))
+
+
+/* We only support loading DSBT relocatable shared libraries.
+ It probably wouldn't be too hard to support loading statically
+ linked executables that require relocation.*/
+#define DL_CHECK_LIB_TYPE(epnt, piclib, _dl_progname, libname) \
+do \
+{ \
+ (piclib) = 2; \
+} \
+while (0)
+
+/* We want want to apply all relocations in the interpreter during
+ bootstrap. Because of this, we have to skip the interpreter
+ relocations in _dl_parse_relocation_information(), see
+ elfinterp.c. */
+#define DL_SKIP_BOOTSTRAP_RELOC(SYMTAB, INDEX, STRTAB) 0
+
+#ifdef __NR_pread64
+#define _DL_PREAD(FD, BUF, SIZE, OFFSET) \
+ (_dl_pread((FD), (BUF), (SIZE), (OFFSET)))
+#endif
+
+#define DL_GET_READY_TO_RUN_EXTRA_PARMS \
+ , struct elf32_dsbt_loadmap *dl_boot_progmap \
+ , struct elf32_dsbt_loadmap *dl_boot_ldsomap
+#define DL_GET_READY_TO_RUN_EXTRA_ARGS \
+ , dl_boot_progmap \
+ , dl_boot_ldsomap
+
+
+/*
+ * C6X doesn't really need the GOT here.
+ * The GOT is placed just past the DSBT table, so we could find it by
+ * using the DSBT register + table size found in the dynamic section.
+ *
+ * do { \
+ * unsigned long *ldso_dsbt; \
+ * ElfW(Dyn) *d = dl_boot_ldso_dyn_pointer; \
+ * while (d->d_tag != DT_NULL) { \
+ * if (d->d_tag == DT_C6000_DSBT_SIZE) { \
+ * __asm__ (" MV .S2 B14,%0\n" \
+ * : "=b" (ldso_dsbt)); \
+ * (GOT) = ldso_dsbt + d->d_un.d_val; \
+ * break; \
+ * } \
+ * d++; \
+ * } \
+ * } while(0)
+ *
+ * Instead, just point it to the DSBT table to avoid unused variable warning.
+ */
+#define DL_BOOT_COMPUTE_GOT(GOT) \
+ __asm__ (" MV .S2 B14,%0\n" : "=b" (GOT))
+
+#define DL_BOOT_COMPUTE_DYN(dpnt, got, load_addr) \
+ ((dpnt) = dl_boot_ldso_dyn_pointer)
+
+/* Define this to declare the library offset. */
+#define DL_DEF_LIB_OFFSET
+
+/* Define this to get the library offset. */
+#define DL_GET_LIB_OFFSET() 0
+
+/* Define this to set the library offset. */
+#define DL_SET_LIB_OFFSET(offset)
+
+/* Define this to get the real object's runtime address. */
+#define DL_GET_RUN_ADDR(loadaddr, mapaddr) (loadaddr)
+
+#ifdef __USE_GNU
+# include <link.h>
+#else
+# define __USE_GNU
+# include <link.h>
+# undef __USE_GNU
+#endif
+
+/* we need this for __LDSO_STANDALONE_SUPPORT__ */
+#define elf_machine_load_address() \
+ (dl_boot_ldsomap ?: dl_boot_progmap)->segs[0].addr
+
+static __always_inline void
+elf_machine_relative (DL_LOADADDR_TYPE load_off, const Elf32_Addr rel_addr,
+ Elf32_Word relative_count)
+{
+}
+
+/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry, so
+ PLT entries should not be allowed to define the value.
+ ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one
+ of the main executable's symbols, as for a COPY reloc. */
+#define elf_machine_type_class(type) \
+ ((((type) == R_C6000_JUMP_SLOT) * ELF_RTYPE_CLASS_PLT) \
+ | (((type) == R_C6000_COPY) * ELF_RTYPE_CLASS_COPY))
+
+#define ARCH_NUM 3
+#define DT_DSBT_BASE_IDX (DT_NUM + OS_NUM)
+#define DT_DSBT_SIZE_IDX (DT_NUM + OS_NUM + 1)
+#define DT_DSBT_INDEX_IDX (DT_NUM + OS_NUM + 2)
+
+#define ARCH_DYNAMIC_INFO(dpnt, dynamic, debug_addr) \
+do { \
+if (dpnt->d_tag == DT_C6000_DSBT_BASE) \
+ dynamic[DT_DSBT_BASE_IDX] = dpnt->d_un.d_val; \
+else if (dpnt->d_tag == DT_C6000_DSBT_SIZE) \
+ dynamic[DT_DSBT_SIZE_IDX] = dpnt->d_un.d_val; \
+else if (dpnt->d_tag == DT_C6000_DSBT_INDEX) \
+ dynamic[DT_DSBT_INDEX_IDX] = dpnt->d_un.d_val; \
+} while (0)
diff --git a/ldso/ldso/c6x/elfinterp.c b/ldso/ldso/c6x/elfinterp.c
new file mode 100644
index 000000000..f0e05b9d0
--- /dev/null
+++ b/ldso/ldso/c6x/elfinterp.c
@@ -0,0 +1,304 @@
+/* TI C64X DSBT ELF shared library loader suppport
+ * Copyright (C) 2010 Texas Instruments Incorporated
+ * Contributed by Mark Salter <msalter@redhat.com>
+ *
+ * Borrowed heavily from frv arch:
+ * Copyright (C) 2003, 2004 Red Hat, Inc.
+ * Contributed by Alexandre Oliva <aoliva@redhat.com>
+ * Lots of code copied from ../i386/elfinterp.c, so:
+ * Copyright (c) 1994-2000 Eric Youngdale, Peter MacDonald,
+ * David Engel, Hongjiu Lu and Mitch D'Souza
+ * Copyright (C) 2001-2002, Erik Andersen
+ * All rights reserved.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <features.h>
+
+/* Program to load an ELF binary on a linux system, and run it.
+ References to symbols in sharable libraries can be resolved by either
+ an ELF sharable library or a linux style of shared library. */
+
+/* Disclaimer: I have never seen any AT&T source code for SVr4, nor have
+ I ever taken any courses on internals. This program was developed using
+ information available through the book "UNIX SYSTEM V RELEASE 4,
+ Programmers guide: Ansi C and Programming Support Tools", which did
+ a more than adequate job of explaining everything required to get this
+ working. */
+
+extern void __c6x_cache_sync(unsigned long start, unsigned long end)
+ attribute_hidden;
+
+static void
+_dl_c6x_flush_relocs(struct elf32_dsbt_loadmap *map)
+{
+ unsigned long s, e;
+ s = map->segs[0].addr;
+ e = s + map->segs[0].p_memsz;
+ __c6x_cache_sync(s, e);
+ s = map->segs[1].addr;
+ e = s + map->segs[1].p_memsz;
+ __c6x_cache_sync(s, e);
+}
+
+
+attribute_hidden
+char *
+_dl_linux_resolver (struct elf_resolve *tpnt, int reloc_entry)
+{
+ ELF_RELOC *this_reloc;
+ char *strtab;
+ ElfW(Sym) *symtab;
+ int symtab_index;
+ char *rel_addr;
+ char *new_addr;
+ char **got_addr;
+ char *symname;
+
+ rel_addr = (char *)tpnt->dynamic_info[DT_JMPREL];
+
+ this_reloc = (ELF_RELOC *)(intptr_t)(rel_addr + reloc_entry);
+ symtab_index = ELF_R_SYM(this_reloc->r_info);
+
+ symtab = (ElfW(Sym) *) tpnt->dynamic_info[DT_SYMTAB];
+ strtab = (char *) tpnt->dynamic_info[DT_STRTAB];
+ symname = strtab + symtab[symtab_index].st_name;
+
+ /* Address of GOT entry fix up */
+ got_addr = (char **) DL_RELOC_ADDR(tpnt->loadaddr, this_reloc->r_offset);
+
+ /* Get the address to be used to fill in the GOT entry. */
+ new_addr = _dl_find_hash(symname, &_dl_loaded_modules->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT, NULL);
+ if (unlikely(!new_addr)) {
+ _dl_dprintf(2, "%s: can't resolve symbol '%s' in lib '%s'.\n", _dl_progname, symname, tpnt->libname);
+ _dl_exit(1);
+ }
+
+#if defined (__SUPPORT_LD_DEBUG__)
+ if (_dl_debug_bindings) {
+ _dl_dprintf(_dl_debug_file, "\nresolve function: %s", symname);
+ if (_dl_debug_detail)
+ _dl_dprintf(_dl_debug_file,
+ "\n\tpatched %x ==> %x @ %x\n",
+ *got_addr, new_addr, got_addr);
+ }
+ if (!_dl_debug_nofixups) {
+ *got_addr = new_addr;
+ }
+#else
+ *got_addr = new_addr;
+#endif
+
+ return new_addr;
+}
+
+static int
+_dl_parse(struct elf_resolve *tpnt, struct r_scope_elem *scope,
+ unsigned long rel_addr, unsigned long rel_size,
+ int (*reloc_fnc) (struct elf_resolve *tpnt, struct r_scope_elem *scope,
+ ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab))
+{
+ unsigned int i;
+ char *strtab;
+ ElfW(Sym) *symtab;
+ ELF_RELOC *rpnt;
+ int symtab_index;
+
+ /* Now parse the relocation information */
+ rpnt = (ELF_RELOC *)rel_addr;
+ rel_size = rel_size / sizeof(ELF_RELOC);
+
+ symtab = (ElfW(Sym) *)tpnt->dynamic_info[DT_SYMTAB];
+ strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
+
+ for (i = 0; i < rel_size; i++, rpnt++) {
+ int res;
+
+ symtab_index = ELF_R_SYM(rpnt->r_info);
+ debug_sym(symtab,strtab,symtab_index);
+ debug_reloc(symtab,strtab,rpnt);
+
+ res = reloc_fnc (tpnt, scope, rpnt, symtab, strtab);
+
+ if (res==0) continue;
+
+ _dl_dprintf(2, "\n%s: ",_dl_progname);
+
+ if (symtab_index)
+ _dl_dprintf(2, "symbol '%s': ", strtab + symtab[symtab_index].st_name);
+
+ if (res <0) {
+ int reloc_type = ELF_R_TYPE(rpnt->r_info);
+#if defined (__SUPPORT_LD_DEBUG__)
+ _dl_dprintf(2, "can't handle reloc type %s\n ", _dl_reltypes(reloc_type));
+#else
+ _dl_dprintf(2, "can't handle reloc type %x\n", reloc_type);
+#endif
+ _dl_exit(-res);
+ } else if (res >0) {
+ _dl_dprintf(2, "can't resolve symbol\n");
+ return res;
+ }
+ }
+ _dl_c6x_flush_relocs(tpnt->loadaddr.map);
+ return 0;
+}
+
+static int
+_dl_do_reloc (struct elf_resolve *tpnt,struct r_scope_elem *scope,
+ ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
+{
+ int reloc_type;
+ int symtab_index;
+ char *symname;
+ unsigned long *reloc_addr;
+ unsigned long symbol_addr, sym_val;
+ long reloc_addend;
+ unsigned long old_val, new_val = 0;
+ struct symbol_ref sym_ref;
+ struct elf_resolve *symbol_tpnt;
+
+ reloc_addr = (unsigned long *)(intptr_t)
+ DL_RELOC_ADDR (tpnt->loadaddr, rpnt->r_offset);
+
+ reloc_type = ELF_R_TYPE(rpnt->r_info);
+ reloc_addend = rpnt->r_addend;
+ symtab_index = ELF_R_SYM(rpnt->r_info);
+ symbol_addr = 0;
+ symname = strtab + symtab[symtab_index].st_name;
+ sym_ref.sym = &symtab[symtab_index];
+ sym_ref.tpnt = NULL;
+
+ if (ELF_ST_BIND (symtab[symtab_index].st_info) == STB_LOCAL) {
+ symbol_addr = (unsigned long)
+ DL_RELOC_ADDR (tpnt->loadaddr, symtab[symtab_index].st_value);
+ symbol_tpnt = tpnt;
+ } else {
+ symbol_addr = (unsigned long) _dl_find_hash(symname,
+ scope, NULL, elf_machine_type_class(reloc_type),
+ &sym_ref);
+ /*
+ * We want to allow undefined references to weak symbols - this might
+ * have been intentional. We should not be linking local symbols
+ * here, so all bases should be covered.
+ */
+
+ if (!symbol_addr && ELF_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK) {
+ _dl_dprintf (2, "%s: can't resolve symbol '%s'\n",
+ _dl_progname, strtab + symtab[symtab_index].st_name);
+ _dl_exit (1);
+ }
+ symbol_tpnt = sym_ref.tpnt;
+ }
+ old_val = *reloc_addr;
+ sym_val = symbol_addr + reloc_addend;
+
+ switch (reloc_type) {
+ case R_C6000_NONE:
+ break;
+ case R_C6000_ABS32:
+ case R_C6000_JUMP_SLOT:
+ new_val = sym_val;
+ *reloc_addr = sym_val;
+ break;
+ case R_C6000_DSBT_INDEX:
+ new_val = (old_val & ~0x007fff00) | ((symbol_tpnt->dsbt_index & 0x7fff) << 8);
+ *reloc_addr = new_val;
+ break;
+ case R_C6000_ABS_L16:
+ new_val = (old_val & ~0x007fff80) | ((sym_val & 0xffff) << 7);
+ *reloc_addr = new_val;
+ break;
+ case R_C6000_ABS_H16:
+ new_val = (old_val & ~0x007fff80) | ((sym_val >> 9) & 0x007fff80);
+ *reloc_addr = new_val;
+ break;
+ case R_C6000_PCR_S21:
+ new_val = sym_val - (((unsigned long)reloc_addr) & ~31);
+ *reloc_addr = (old_val & ~0x0fffff80) | (((new_val >> 2) & 0x1fffff) << 7);
+ break;
+ case R_C6000_COPY:
+ if (symbol_addr) {
+#if defined (__SUPPORT_LD_DEBUG__)
+ if (_dl_debug_move)
+ _dl_dprintf(_dl_debug_file,
+ "\n%s move %d bytes from %x to %x",
+ symname, symtab[symtab_index].st_size,
+ symbol_addr, reloc_addr);
+#endif
+
+ _dl_memcpy((char *)reloc_addr,
+ (char *)symbol_addr,
+ symtab[symtab_index].st_size);
+ }
+ return 0;
+ default:
+ return -1; /*call _dl_exit(1) */
+ }
+#if defined (__SUPPORT_LD_DEBUG__)
+ if (_dl_debug_reloc && _dl_debug_detail && reloc_type != R_C6000_NONE) {
+ _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x\n", old_val, new_val, reloc_addr);
+ }
+#endif
+ return 0;
+}
+
+static int
+_dl_do_lazy_reloc (struct elf_resolve *tpnt,
+ struct r_scope_elem *scope attribute_unused,
+ ELF_RELOC *rpnt, ElfW(Sym) *symtab attribute_unused,
+ char *strtab attribute_unused)
+{
+ int reloc_type;
+ unsigned long *reloc_addr;
+ unsigned long old_val;
+
+ reloc_addr = (unsigned long *) DL_RELOC_ADDR(tpnt->loadaddr, rpnt->r_offset);
+ reloc_type = ELF_R_TYPE(rpnt->r_info);
+
+ old_val = *reloc_addr;
+
+ switch (reloc_type) {
+ case R_C6000_NONE:
+ break;
+ case R_C6000_JUMP_SLOT:
+ *reloc_addr = DL_RELOC_ADDR(tpnt->loadaddr, old_val);
+ break;
+ default:
+ return -1;
+ }
+
+#if defined (__SUPPORT_LD_DEBUG__)
+ if (_dl_debug_reloc && _dl_debug_detail)
+ _dl_dprintf(_dl_debug_file, "\n\tpatched: %x ==> %x @ %x\n",
+ old_val, *reloc_addr, reloc_addr);
+#endif
+
+ return 0;
+}
+
+void
+_dl_parse_lazy_relocation_information
+(struct dyn_elf *rpnt, unsigned long rel_addr, unsigned long rel_size)
+{
+ _dl_parse(rpnt->dyn, NULL, rel_addr, rel_size, _dl_do_lazy_reloc);
+}
+
+int
+_dl_parse_relocation_information
+(struct dyn_elf *rpnt, struct r_scope_elem *scope, unsigned long rel_addr, unsigned long rel_size)
+{
+ return _dl_parse(rpnt->dyn, scope, rel_addr, rel_size, _dl_do_reloc);
+}
+
+/* We don't have copy relocs. */
+int
+_dl_parse_copy_information
+(struct dyn_elf *rpnt,
+ unsigned long rel_addr,
+ unsigned long rel_size)
+{
+ return 0;
+}
+
diff --git a/ldso/ldso/c6x/resolve.S b/ldso/ldso/c6x/resolve.S
new file mode 100644
index 000000000..ce3cbe793
--- /dev/null
+++ b/ldso/ldso/c6x/resolve.S
@@ -0,0 +1,68 @@
+;;
+;; Copyright (C) 2010 Texas Instruments Incorporated
+;; Mark Salter <msalter@redhat.com>
+;;
+;; Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+;;
+
+;; The function below is tail-called by resolver stubs when a
+;; lazily-bound function is called. It must preserve all
+;; registers that could be used to pass arguments to the actual
+;; function.
+
+;; _dl_linux_resolver() figures out where the jump symbol is
+;; _really_ supposed to have jumped to and returns that to us.
+;; Once we have that, we prepare to tail-call the actual
+;; function, clean up after ourselves, restoring the original
+;; arguments, then jump to the fixed up address. */
+
+; resolver stub - called from PLT to resolve target address and update GOT
+;
+; B0 : reloc offset (bytes from DT_RELPLT)
+; B1 : module pointer, loaded from GOT[1]
+; DP : caller's DP
+; A4,B4, etc: callee's arguments
+; B3 : return address
+
+ .text
+ .align 5
+ .global _dl_linux_resolve
+_dl_linux_resolve:
+ stw .d2t2 B14, *B15--[2]
+ stdw .d2t1 A15:A14, *B15--
+ stdw .d2t2 B13:B12, *B15--
+ stdw .d2t1 A13:A12, *B15--
+ stdw .d2t2 B11:B10, *B15--
+ stdw .d2t1 A11:A10, *B15--
+ stdw .d2t2 B9:B8, *B15--
+ stdw .d2t1 A9:A8, *B15--
+ stdw .d2t2 B7:B6, *B15--
+ stdw .d2t1 A7:A6, *B15--
+ stdw .d2t2 B5:B4, *B15--
+ stdw .d2t1 A5:A4, *B15--
+ stdw .d2t2 B3:B2, *B15--
+ stdw .d2t1 A3:A2, *B15--
+
+ ; call lookup routine
+ MV .S1X B1, A4 ; arg 1: module id
+|| MV .S2 B0,B4 ; arg 2: reloc offset
+ CALLP .S2 _dl_linux_resolver, B3 ; returns &f in A4
+ MV .S2X A4,B0 ; &f
+
+ lddw .d2t1 *++B15, A3:A2
+ lddw .d2t2 *++B15, B3:B2
+ lddw .d2t1 *++B15, A5:A4
+ lddw .d2t2 *++B15, B5:B4
+ lddw .d2t1 *++B15, A7:A6
+ lddw .d2t2 *++B15, B7:B6
+ lddw .d2t1 *++B15, A9:A8
+ lddw .d2t2 *++B15, B9:B8
+ lddw .d2t1 *++B15, A11:A10
+ lddw .d2t2 *++B15, B11:B10
+ lddw .d2t1 *++B15, A13:A12
+ lddw .d2t2 *++B15, B13:B12
+ lddw .d2t1 *++B15, A15:A14
+ ldw .d2t2 *++B15[2], B14
+
+ B .S2 B0 ; tail-call f
+ NOP 5
diff --git a/ldso/ldso/cris/dl-debug.h b/ldso/ldso/cris/dl-debug.h
index f6c03d21f..dcd23edb5 100644
--- a/ldso/ldso/cris/dl-debug.h
+++ b/ldso/ldso/cris/dl-debug.h
@@ -33,7 +33,7 @@
* SUCH DAMAGE.
*/
-static const char *_dl_reltypes_tab[] = {
+static const char * const _dl_reltypes_tab[] = {
[0] "R_CRIS_NONE", "R_CRIS_8", "R_CRIS_16", "R_CRIS_32",
[4] "R_CRIS_8_PCREL", "R_CRIS_16_PCREL", "R_CRIS_32_PCREL", "R_CRIS_GNU_VTINHERIT",
[8] "R_CRIS_GNU_VTENTRY", "R_CRIS_COPY", "R_CRIS_GLOB_DAT", "R_CRIS_JUMP_SLOT",
diff --git a/ldso/ldso/cris/dl-startup.h b/ldso/ldso/cris/dl-startup.h
index 832c3528b..66580004e 100644
--- a/ldso/ldso/cris/dl-startup.h
+++ b/ldso/ldso/cris/dl-startup.h
@@ -10,6 +10,7 @@ __asm__("" \
" .text\n" \
" .globl _start\n" \
" .type _start,@function\n" \
+" .hidden _start\n" \
"_start:\n" \
" move.d $sp,$r10\n" \
" lapc _dl_start,$r9\n" \
@@ -28,6 +29,7 @@ __asm__("" \
" .text\n" \
" .globl _start\n" \
" .type _start,@function\n" \
+" .hidden _start\n" \
"_start:\n" \
" move.d $sp,$r10\n" \
" move.d $pc,$r9\n" \
@@ -43,7 +45,7 @@ __asm__("" \
#endif /* __arch_v32 */
/* Get a pointer to the argv array. On many platforms this can be just
- * the address if the first argument, on other platforms we need to
+ * the address of the first argument, on other platforms we need to
* do something a little more subtle here. */
#define GET_ARGV(ARGVP, ARGS) ARGVP = (((unsigned long *) ARGS)+1)
@@ -53,11 +55,11 @@ __asm__("" \
/* Handle relocation of the symbols in the dynamic loader. */
-static inline
+static __always_inline
void PERFORM_BOOTSTRAP_RELOC(ELF_RELOC *rpnt, unsigned long *reloc_addr,
unsigned long symbol_addr, unsigned long load_addr, Elf32_Sym *symtab)
{
- switch (ELF32_R_TYPE(rpnt->r_info)) {
+ switch (ELF_R_TYPE(rpnt->r_info)) {
case R_CRIS_GLOB_DAT:
case R_CRIS_JUMP_SLOT:
case R_CRIS_32:
diff --git a/ldso/ldso/cris/dl-syscalls.h b/ldso/ldso/cris/dl-syscalls.h
index 996bb87c6..f40c4fd31 100644
--- a/ldso/ldso/cris/dl-syscalls.h
+++ b/ldso/ldso/cris/dl-syscalls.h
@@ -1,6 +1 @@
-/* We can't use the real errno in ldso, since it has not yet
- * been dynamicly linked in yet. */
-#include "sys/syscall.h"
-extern int _dl_errno;
-#undef __set_errno
-#define __set_errno(X) {(_dl_errno) = (X);}
+/* stub for arch-specific syscall issues */
diff --git a/ldso/ldso/cris/dl-sysdep.h b/ldso/ldso/cris/dl-sysdep.h
index c68541d1b..e454c10a8 100644
--- a/ldso/ldso/cris/dl-sysdep.h
+++ b/ldso/ldso/cris/dl-sysdep.h
@@ -15,14 +15,12 @@
#undef MAGIC2
#define ELF_TARGET "CRIS"
+/* Need bootstrap relocations */
+#define ARCH_NEEDS_BOOTSTRAP_RELOCS
+
struct elf_resolve;
extern unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry);
-/* 8192 bytes alignment */
-#define PAGE_ALIGN 0xffffe000
-#define ADDR_ALIGN 0x1fff
-#define OFFS_ALIGN 0xffffe000
-
/* The union of reloc-type-classes where the reloc TYPE is a member.
TYPE is in the class ELF_RTYPE_CLASS_PLT if it can describe a
@@ -39,7 +37,7 @@ extern unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entr
|| ((type) == R_CRIS_GLOB_DAT)) * ELF_RTYPE_CLASS_PLT) \
| (((type) == R_CRIS_COPY) * ELF_RTYPE_CLASS_COPY))
-static __inline__ Elf32_Addr
+static __always_inline Elf32_Addr
elf_machine_dynamic(void)
{
/* Don't just set this to an asm variable "r0" since that's not logical
@@ -61,7 +59,7 @@ elf_machine_dynamic(void)
there's some other symbol we could use, that we don't *have* to force a
GOT entry for. */
-static __inline__ Elf32_Addr
+static __always_inline Elf32_Addr
elf_machine_load_address(void)
{
Elf32_Addr gotaddr_diff;
@@ -95,7 +93,7 @@ elf_machine_load_address(void)
return gotaddr_diff;
}
-static __inline__ void
+static __always_inline void
elf_machine_relative(Elf32_Addr load_off, const Elf32_Addr rel_addr,
Elf32_Word relative_count)
{
diff --git a/ldso/ldso/cris/elfinterp.c b/ldso/ldso/cris/elfinterp.c
index 7c71df83a..5ad302559 100644
--- a/ldso/ldso/cris/elfinterp.c
+++ b/ldso/ldso/cris/elfinterp.c
@@ -41,40 +41,32 @@ extern int _dl_linux_resolve(void);
unsigned long
_dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
{
- int reloc_type;
int symtab_index;
char *strtab;
char *symname;
char *new_addr;
char *rel_addr;
char **got_addr;
- Elf32_Sym *symtab;
+ ElfW(Sym) *symtab;
ELF_RELOC *this_reloc;
unsigned long instr_addr;
rel_addr = (char *)tpnt->dynamic_info[DT_JMPREL];
this_reloc = (ELF_RELOC *)(intptr_t)(rel_addr + reloc_entry);
- reloc_type = ELF32_R_TYPE(this_reloc->r_info);
- symtab_index = ELF32_R_SYM(this_reloc->r_info);
+ symtab_index = ELF_R_SYM(this_reloc->r_info);
- symtab = (Elf32_Sym *)(intptr_t)tpnt->dynamic_info[DT_SYMTAB];
+ symtab = (ElfW(Sym) *)(intptr_t)tpnt->dynamic_info[DT_SYMTAB];
strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
symname = strtab + symtab[symtab_index].st_name;
- if (unlikely(reloc_type != R_CRIS_JUMP_SLOT)) {
- _dl_dprintf(2, "%s: Incorrect relocation type in jump relocations\n",
- _dl_progname);
- _dl_exit(1);
- }
-
/* Address of the jump instruction to fix up. */
instr_addr = ((unsigned long)this_reloc->r_offset +
(unsigned long)tpnt->loadaddr);
got_addr = (char **)instr_addr;
/* Get the address of the GOT entry. */
- new_addr = _dl_find_hash(symname, tpnt->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT);
+ new_addr = _dl_find_hash(symname, &_dl_loaded_modules->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT, NULL);
if (unlikely(!new_addr)) {
_dl_dprintf(2, "%s: Can't resolve symbol '%s'\n", _dl_progname, symname);
_dl_exit(1);
@@ -85,7 +77,7 @@ _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
_dl_dprintf(_dl_debug_file, "\nresolve function: %s", symname);
if (_dl_debug_detail)
_dl_dprintf(_dl_debug_file,
- "\n\tpatched: %x ==> %x @ %x",
+ "\n\tpatched: %x ==> %x @ %x\n",
*got_addr, new_addr, got_addr);
}
if (!_dl_debug_nofixups) {
@@ -99,28 +91,28 @@ _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
}
static int
-_dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
+_dl_parse(struct elf_resolve *tpnt, struct r_scope_elem *scope,
unsigned long rel_addr, unsigned long rel_size,
- int (*reloc_fnc)(struct elf_resolve *tpnt, struct dyn_elf *scope,
- ELF_RELOC *rpnt, Elf32_Sym *symtab, char *strtab))
+ int (*reloc_fnc)(struct elf_resolve *tpnt, struct r_scope_elem *scope,
+ ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab))
{
int symtab_index;
unsigned int i;
char *strtab;
- Elf32_Sym *symtab;
+ ElfW(Sym) *symtab;
ELF_RELOC *rpnt;
/* Parse the relocation information. */
rpnt = (ELF_RELOC *)(intptr_t)rel_addr;
rel_size /= sizeof(ELF_RELOC);
- symtab = (Elf32_Sym *)(intptr_t)tpnt->dynamic_info[DT_SYMTAB];
+ symtab = (ElfW(Sym) *)(intptr_t)tpnt->dynamic_info[DT_SYMTAB];
strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
for (i = 0; i < rel_size; i++, rpnt++) {
int res;
- symtab_index = ELF32_R_SYM(rpnt->r_info);
+ symtab_index = ELF_R_SYM(rpnt->r_info);
debug_sym(symtab, strtab, symtab_index);
debug_reloc(symtab, strtab, rpnt);
@@ -138,7 +130,7 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
strtab + symtab[symtab_index].st_name);
if (unlikely(res < 0)) {
- int reloc_type = ELF32_R_TYPE(rpnt->r_info);
+ int reloc_type = ELF_R_TYPE(rpnt->r_info);
#if defined (__SUPPORT_LD_DEBUG__)
_dl_dprintf(2, "can't handle reloc type %s\n",
@@ -158,8 +150,8 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
}
static int
-_dl_do_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
- ELF_RELOC *rpnt, Elf32_Sym *symtab, char *strtab)
+_dl_do_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
+ ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
{
int reloc_type;
int symtab_index;
@@ -169,28 +161,35 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
#if defined (__SUPPORT_LD_DEBUG__)
unsigned long old_val;
#endif
+ struct symbol_ref sym_ref;
reloc_addr = (unsigned long *)(intptr_t)(tpnt->loadaddr + (unsigned long)rpnt->r_offset);
- reloc_type = ELF32_R_TYPE(rpnt->r_info);
- symtab_index = ELF32_R_SYM(rpnt->r_info);
+ reloc_type = ELF_R_TYPE(rpnt->r_info);
+ symtab_index = ELF_R_SYM(rpnt->r_info);
symbol_addr = 0;
+ sym_ref.sym = &symtab[symtab_index];
+ sym_ref.tpnt = NULL;
symname = strtab + symtab[symtab_index].st_name;
if (symtab_index) {
if (symtab[symtab_index].st_shndx != SHN_UNDEF &&
- ELF32_ST_BIND(symtab[symtab_index].st_info) == STB_LOCAL) {
+ ELF_ST_BIND(symtab[symtab_index].st_info) == STB_LOCAL) {
symbol_addr = (unsigned long)tpnt->loadaddr;
} else {
symbol_addr = (unsigned long)_dl_find_hash(symname, scope, tpnt,
- elf_machine_type_class(reloc_type));
+ elf_machine_type_class(reloc_type), &sym_ref);
}
- if (unlikely(!symbol_addr && ELF32_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK)) {
+ if (unlikely(!symbol_addr && ELF_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK)) {
_dl_dprintf(2, "%s: can't resolve symbol '%s'\n", _dl_progname, symname);
_dl_exit(1);
}
symbol_addr += rpnt->r_addend;
+ if (_dl_trace_prelink) {
+ _dl_debug_lookup (symname, tpnt, &symtab[symtab_index],
+ &sym_ref, elf_machine_type_class(reloc_type));
+ }
}
#if defined (__SUPPORT_LD_DEBUG__)
@@ -227,7 +226,7 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
#if defined (__SUPPORT_LD_DEBUG__)
if (_dl_debug_reloc && _dl_debug_detail)
- _dl_dprintf(_dl_debug_file, "\n\tpatched: %x ==> %x @ %x",
+ _dl_dprintf(_dl_debug_file, "\n\tpatched: %x ==> %x @ %x\n",
old_val, *reloc_addr, reloc_addr);
#endif
@@ -235,8 +234,8 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
}
static int
-_dl_do_lazy_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
- ELF_RELOC *rpnt, Elf32_Sym *symtab, char *strtab)
+_dl_do_lazy_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
+ ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
{
int reloc_type;
unsigned long *reloc_addr;
@@ -250,7 +249,7 @@ _dl_do_lazy_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
(void)strtab;
reloc_addr = (unsigned long *)(intptr_t)(tpnt->loadaddr + (unsigned long)rpnt->r_offset);
- reloc_type = ELF32_R_TYPE(rpnt->r_info);
+ reloc_type = ELF_R_TYPE(rpnt->r_info);
#if defined (__SUPPORT_LD_DEBUG__)
old_val = *reloc_addr;
@@ -268,7 +267,7 @@ _dl_do_lazy_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
#if defined (__SUPPORT_LD_DEBUG__)
if (_dl_debug_reloc && _dl_debug_detail)
- _dl_dprintf(_dl_debug_file, "\n\tpatched: %x ==> %x @ %x",
+ _dl_dprintf(_dl_debug_file, "\n\tpatched: %x ==> %x @ %x\n",
old_val, *reloc_addr, reloc_addr);
#endif
@@ -287,8 +286,9 @@ _dl_parse_lazy_relocation_information(struct dyn_elf *rpnt,
int
_dl_parse_relocation_information(struct dyn_elf *rpnt,
+ struct r_scope_elem *scope,
unsigned long rel_addr,
unsigned long rel_size)
{
- return _dl_parse(rpnt->dyn, rpnt->dyn->symbol_scope, rel_addr, rel_size, _dl_do_reloc);
+ return _dl_parse(rpnt->dyn, scope, rel_addr, rel_size, _dl_do_reloc);
}
diff --git a/ldso/ldso/dl-debug.c b/ldso/ldso/dl-debug.c
index 7ce8bfbce..88a48933c 100644
--- a/ldso/ldso/dl-debug.c
+++ b/ldso/ldso/dl-debug.c
@@ -104,3 +104,54 @@ static void debug_reloc(ElfW(Sym) *symtab, char *strtab, ELF_RELOC *rpnt)
#define debug_reloc(symtab, strtab, rpnt)
#endif /* __SUPPORT_LD_DEBUG__ */
+
+#ifdef __LDSO_PRELINK_SUPPORT__
+static void
+internal_function
+_dl_debug_lookup (const char *undef_name, struct elf_resolve *undef_map,
+ const ElfW(Sym) *ref, struct symbol_ref *value, int type_class)
+{
+#ifdef SHARED
+ if (_dl_trace_prelink)
+ {
+ int conflict = 0;
+ struct symbol_ref val = { ref, NULL };
+
+ if ((_dl_trace_prelink_map == NULL
+ || _dl_trace_prelink_map == _dl_loaded_modules)
+ && undef_map != _dl_loaded_modules)
+ {
+ _dl_find_hash(undef_name, &undef_map->symbol_scope,
+ undef_map, type_class, &val);
+
+ if (val.sym != value->sym || val.tpnt != value->tpnt)
+ conflict = 1;
+ }
+
+ if (unlikely(value->sym && ELF_ST_TYPE(value->sym->st_info) == STT_TLS))
+ type_class = 4;
+
+ if (conflict
+ || _dl_trace_prelink_map == undef_map
+ || _dl_trace_prelink_map == NULL
+ || type_class == 4)
+ {
+ _dl_dprintf (1, "%s %x %x -> %x %x ",
+ conflict ? "conflict" : "lookup",
+ (size_t) undef_map->mapaddr,
+ (size_t) (((ElfW(Addr)) ref) - undef_map->mapaddr),
+ (size_t) (value->tpnt ? value->tpnt->mapaddr : 0),
+ (size_t) (value->sym ? value->sym->st_value : 0));
+ if (conflict)
+ _dl_dprintf (1, "x %x %x ",
+ (size_t) (val.tpnt ? val.tpnt->mapaddr : 0),
+ (size_t) (val.sym ? val.sym->st_value : 0));
+ _dl_dprintf (1, "/%x %s\n", type_class, undef_name);
+ }
+}
+#endif
+}
+
+#else
+#define _dl_debug_lookup(undef_name, undef_map, ref, value, type_class)
+#endif
diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c
index 6c0e80544..04e8c60a4 100644
--- a/ldso/ldso/dl-elf.c
+++ b/ldso/ldso/dl-elf.c
@@ -45,14 +45,14 @@ int _dl_map_cache(void)
libentry_t *libent;
int i, strtabsize;
- if (_dl_cache_addr == (caddr_t) - 1)
+ if (_dl_cache_addr == MAP_FAILED)
return -1;
else if (_dl_cache_addr != NULL)
return 0;
if (_dl_stat(LDSO_CACHE, &st)
- || (fd = _dl_open(LDSO_CACHE, O_RDONLY, 0)) < 0) {
- _dl_cache_addr = (caddr_t) - 1; /* so we won't try again */
+ || (fd = _dl_open(LDSO_CACHE, O_RDONLY|O_CLOEXEC, 0)) < 0) {
+ _dl_cache_addr = MAP_FAILED; /* so we won't try again */
return -1;
}
@@ -96,13 +96,13 @@ int _dl_map_cache(void)
fail:
_dl_munmap(_dl_cache_addr, _dl_cache_size);
- _dl_cache_addr = (caddr_t) - 1;
+ _dl_cache_addr = MAP_FAILED;
return -1;
}
int _dl_unmap_cache(void)
{
- if (_dl_cache_addr == NULL || _dl_cache_addr == (caddr_t) - 1)
+ if (_dl_cache_addr == NULL || _dl_cache_addr == MAP_FAILED)
return -1;
#if 1
@@ -119,8 +119,8 @@ void
_dl_protect_relro (struct elf_resolve *l)
{
ElfW(Addr) base = (ElfW(Addr)) DL_RELOC_ADDR(l->loadaddr, l->relro_addr);
- ElfW(Addr) start = (base & ~(_dl_pagesize - 1));
- ElfW(Addr) end = ((base + l->relro_size) & ~(_dl_pagesize - 1));
+ ElfW(Addr) start = (base & PAGE_ALIGN);
+ ElfW(Addr) end = ((base + l->relro_size) & PAGE_ALIGN);
_dl_if_debug_dprint("RELRO protecting %s: start:%x, end:%x\n", l->libname, start, end);
if (start != end &&
_dl_mprotect ((void *) start, end - start, PROT_READ) < 0) {
@@ -132,64 +132,63 @@ _dl_protect_relro (struct elf_resolve *l)
/* This function's behavior must exactly match that
* in uClibc/ldso/util/ldd.c */
static struct elf_resolve *
-search_for_named_library(const char *name, int secure, const char *path_list,
- struct dyn_elf **rpnt)
+search_for_named_library(const char *name, unsigned int rflags, const char *path_list,
+ struct dyn_elf **rpnt, const char* origin)
{
- char *path, *path_n, *mylibname;
+ char *mylibname;
struct elf_resolve *tpnt;
- int done;
+ const char *p, *pn;
+ int plen;
if (path_list==NULL)
return NULL;
- /* We need a writable copy of this string, but we don't
- * need this allocated permanently since we don't want
- * to leak memory, so use alloca to put path on the stack */
- done = _dl_strlen(path_list);
- path = alloca(done + 1);
-
/* another bit of local storage */
mylibname = alloca(2050);
- /* gcc inlines alloca using a single instruction adjusting
- * the stack pointer and no stack overflow check and thus
- * no NULL error return. No point leaving in dead code... */
-#if 0
- if (!path || !mylibname) {
- _dl_dprintf(2, "Out of memory!\n");
- _dl_exit(0);
- }
-#endif
-
- _dl_memcpy(path, path_list, done+1);
-
/* Unlike ldd.c, don't bother to eliminate double //s */
/* Replace colons with zeros in path_list */
/* : at the beginning or end of path maps to CWD */
/* :: anywhere maps CWD */
/* "" maps to CWD */
- done = 0;
- path_n = path;
- do {
- if (*path == 0) {
- *path = ':';
- done = 1;
- }
- if (*path == ':') {
- *path = 0;
- if (*path_n)
- _dl_strcpy(mylibname, path_n);
- else
- _dl_strcpy(mylibname, "."); /* Assume current dir if empty path */
- _dl_strcat(mylibname, "/");
- _dl_strcat(mylibname, name);
- if ((tpnt = _dl_load_elf_shared_library(secure, rpnt, mylibname)) != NULL)
- return tpnt;
- path_n = path+1;
+ for (p = path_list; p != NULL; p = pn) {
+ pn = _dl_strchr(p + 1, ':');
+ if (pn != NULL) {
+ plen = pn - p;
+ pn++;
+ } else
+ plen = _dl_strlen(p);
+
+ if (plen >= 7 && _dl_memcmp(p, "$ORIGIN", 7) == 0) {
+ int olen;
+ /* $ORIGIN is not expanded for SUID/GUID programs
+ (except if it is $ORIGIN alone) */
+ if ((rflags & __RTLD_SECURE) && plen != 7)
+ continue;
+ if (origin == NULL)
+ continue;
+ for (olen = _dl_strlen(origin) - 1; olen >= 0 && origin[olen] != '/'; olen--)
+ ;
+ if (olen <= 0)
+ continue;
+ _dl_memcpy(&mylibname[0], origin, olen);
+ _dl_memcpy(&mylibname[olen], p + 7, plen - 7);
+ mylibname[olen + plen - 7] = 0;
+ } else if (plen != 0) {
+ _dl_memcpy(mylibname, p, plen);
+ mylibname[plen] = 0;
+ } else {
+ _dl_strcpy(mylibname, ".");
}
- path++;
- } while (!done);
+ _dl_strcat(mylibname, "/");
+ _dl_strcat(mylibname, name);
+#ifdef __LDSO_SAFE_RUNPATH__
+ if (*mylibname == '/')
+#endif
+ if ((tpnt = _dl_load_elf_shared_library(rflags, rpnt, mylibname)) != NULL)
+ return tpnt;
+ }
return NULL;
}
@@ -197,8 +196,8 @@ search_for_named_library(const char *name, int secure, const char *path_list,
unsigned long _dl_error_number;
unsigned long _dl_internal_error_number;
-struct elf_resolve *_dl_load_shared_library(int secure, struct dyn_elf **rpnt,
- struct elf_resolve *tpnt, char *full_libname, int __attribute__((unused)) trace_loaded_objects)
+struct elf_resolve *_dl_load_shared_library(unsigned int rflags, struct dyn_elf **rpnt,
+ struct elf_resolve *tpnt, char *full_libname, int attribute_unused trace_loaded_objects)
{
char *pnt;
struct elf_resolve *tpnt1;
@@ -226,7 +225,7 @@ struct elf_resolve *_dl_load_shared_library(int secure, struct dyn_elf **rpnt,
if (libname != full_libname) {
_dl_if_debug_dprint("\ttrying file='%s'\n", full_libname);
- tpnt1 = _dl_load_elf_shared_library(secure, rpnt, full_libname);
+ tpnt1 = _dl_load_elf_shared_library(rflags, rpnt, full_libname);
if (tpnt1) {
return tpnt1;
}
@@ -241,20 +240,23 @@ struct elf_resolve *_dl_load_shared_library(int secure, struct dyn_elf **rpnt,
if (pnt) {
pnt += (unsigned long) tpnt->dynamic_info[DT_STRTAB];
_dl_if_debug_dprint("\tsearching RPATH='%s'\n", pnt);
- if ((tpnt1 = search_for_named_library(libname, secure, pnt, rpnt)) != NULL)
+ if ((tpnt1 = search_for_named_library(libname, rflags, pnt, rpnt,
+ tpnt->libname)) != NULL)
return tpnt1;
+
}
#endif
+#ifdef __LDSO_LD_LIBRARY_PATH__
/* Check in LD_{ELF_}LIBRARY_PATH, if specified and allowed */
if (_dl_library_path) {
_dl_if_debug_dprint("\tsearching LD_LIBRARY_PATH='%s'\n", _dl_library_path);
- if ((tpnt1 = search_for_named_library(libname, secure, _dl_library_path, rpnt)) != NULL)
+ if ((tpnt1 = search_for_named_library(libname, rflags, _dl_library_path, rpnt, NULL)) != NULL)
{
return tpnt1;
}
}
-
+#endif
/*
* The ABI specifies that RUNPATH is searched after LD_LIBRARY_PATH.
*/
@@ -263,9 +265,21 @@ struct elf_resolve *_dl_load_shared_library(int secure, struct dyn_elf **rpnt,
if (pnt) {
pnt += (unsigned long) tpnt->dynamic_info[DT_STRTAB];
_dl_if_debug_dprint("\tsearching RUNPATH='%s'\n", pnt);
- if ((tpnt1 = search_for_named_library(libname, secure, pnt, rpnt)) != NULL)
+ if ((tpnt1 = search_for_named_library(libname, rflags, pnt, rpnt, NULL)) != NULL)
return tpnt1;
}
+#ifdef __LDSO_RUNPATH_OF_EXECUTABLE__
+ /*
+ * Try the DT_RPATH of the executable itself.
+ */
+ pnt = (char *) _dl_loaded_modules->dynamic_info[DT_RPATH];
+ if (pnt) {
+ pnt += (unsigned long) _dl_loaded_modules->dynamic_info[DT_STRTAB];
+ _dl_if_debug_dprint("\tsearching exe's RPATH='%s'\n", pnt);
+ if ((tpnt1 = search_for_named_library(libname, rflags, pnt, rpnt, NULL)) != NULL)
+ return tpnt1;
+ }
+#endif
#endif
/*
@@ -274,7 +288,7 @@ struct elf_resolve *_dl_load_shared_library(int secure, struct dyn_elf **rpnt,
* the hard coded paths that follow (i.e before /lib and /usr/lib).
*/
#ifdef __LDSO_CACHE_SUPPORT__
- if (_dl_cache_addr != NULL && _dl_cache_addr != (caddr_t) - 1) {
+ if (_dl_cache_addr != NULL && _dl_cache_addr != MAP_FAILED) {
int i;
header_t *header = (header_t *) _dl_cache_addr;
libentry_t *libent = (libentry_t *) & header[1];
@@ -282,40 +296,69 @@ struct elf_resolve *_dl_load_shared_library(int secure, struct dyn_elf **rpnt,
_dl_if_debug_dprint("\tsearching cache='%s'\n", LDSO_CACHE);
for (i = 0; i < header->nlibs; i++) {
- if ((libent[i].flags == LIB_ELF ||
- libent[i].flags == LIB_ELF_LIBC0 ||
- libent[i].flags == LIB_ELF_LIBC5) &&
- _dl_strcmp(libname, strs + libent[i].sooffset) == 0 &&
- (tpnt1 = _dl_load_elf_shared_library(secure,
- rpnt, strs + libent[i].liboffset)))
+ if ((libent[i].flags == LIB_ELF
+ || libent[i].flags == LIB_ELF_LIBC0
+ || libent[i].flags == LIB_ELF_LIBC5)
+ && _dl_strcmp(libname, strs + libent[i].sooffset) == 0
+ && (tpnt1 = _dl_load_elf_shared_library(rflags, rpnt, strs + libent[i].liboffset))
+ ) {
return tpnt1;
+ }
}
}
#endif
-
+#if defined SHARED && defined __LDSO_SEARCH_INTERP_PATH__
/* Look for libraries wherever the shared library loader
* was installed */
_dl_if_debug_dprint("\tsearching ldso dir='%s'\n", _dl_ldsopath);
- if ((tpnt1 = search_for_named_library(libname, secure, _dl_ldsopath, rpnt)) != NULL)
- {
+ tpnt1 = search_for_named_library(libname, rflags, _dl_ldsopath, rpnt, NULL);
+ if (tpnt1 != NULL)
return tpnt1;
- }
-
-
+#endif
/* Lastly, search the standard list of paths for the library.
This list must exactly match the list in uClibc/ldso/util/ldd.c */
_dl_if_debug_dprint("\tsearching full lib path list\n");
- if ((tpnt1 = search_for_named_library(libname, secure,
+ tpnt1 = search_for_named_library(libname, rflags,
UCLIBC_RUNTIME_PREFIX "lib:"
UCLIBC_RUNTIME_PREFIX "usr/lib"
#ifndef __LDSO_CACHE_SUPPORT__
":" UCLIBC_RUNTIME_PREFIX "usr/X11R6/lib"
#endif
- , rpnt)
- ) != NULL)
- {
+ , rpnt, NULL);
+ if (tpnt1 != NULL)
return tpnt1;
+
+#ifdef __LDSO_RUNPATH_OF_EXECUTABLE__
+ /* Very last resort, try the executable's DT_RUNPATH and DT_RPATH */
+ /* http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#shobj_dependencies
+ * The set of directories specified by a given DT_RUNPATH entry is
+ * used to find only the immediate dependencies of the executable or
+ * shared object containing the DT_RUNPATH entry. That is, it is
+ * used only for those dependencies contained in the DT_NEEDED
+ * entries of the dynamic structure containing the DT_RUNPATH entry,
+ * itself. One object's DT_RUNPATH entry does not affect the search
+ * for any other object's dependencies.
+ *
+ * glibc (around 2.19) violates this and the usual suspects are
+ * abusing this bug^Wrelaxed, user-friendly behaviour.
+ */
+
+ pnt = (char *) _dl_loaded_modules->dynamic_info[DT_RUNPATH];
+ if (pnt) {
+ pnt += (unsigned long) _dl_loaded_modules->dynamic_info[DT_STRTAB];
+ _dl_if_debug_dprint("\tsearching exe's RUNPATH='%s'\n", pnt);
+ if ((tpnt1 = search_for_named_library(libname, rflags, pnt, rpnt, NULL)) != NULL)
+ return tpnt1;
}
+ pnt = (char *) _dl_loaded_modules->dynamic_info[DT_RPATH];
+ if (pnt) {
+ pnt += (unsigned long) _dl_loaded_modules->dynamic_info[DT_STRTAB];
+ _dl_if_debug_dprint("\tsearching exe's RPATH='%s'\n", pnt);
+ if ((tpnt1 = search_for_named_library(libname, rflags, pnt, rpnt, NULL)) != NULL)
+ return tpnt1;
+ }
+#endif
+
goof:
/* Well, we shot our wad on that one. All we can do now is punt */
@@ -327,6 +370,124 @@ goof:
return NULL;
}
+/* Define the _dl_library_offset for the architectures that need it */
+DL_DEF_LIB_OFFSET;
+
+/*
+ * Make a writeable mapping of a segment, regardless of whether PF_W is
+ * set or not.
+ */
+static void *
+map_writeable (int infile, ElfW(Phdr) *ppnt, int piclib, int flags,
+ unsigned long libaddr)
+{
+ int prot_flags = ppnt->p_flags | PF_W;
+ char *status, *retval;
+ char *tryaddr;
+ ssize_t size;
+ unsigned long map_size;
+ char *cpnt;
+ char *piclib2map = NULL;
+
+ if (piclib == 2 &&
+ /* We might be able to avoid this call if memsz doesn't
+ require an additional page, but this would require mmap
+ to always return page-aligned addresses and a whole
+ number of pages allocated. Unfortunately on uClinux
+ may return misaligned addresses and may allocate
+ partial pages, so we may end up doing unnecessary mmap
+ calls.
+
+ This is what we could do if we knew mmap would always
+ return aligned pages:
+
+ ((ppnt->p_vaddr + ppnt->p_filesz + ADDR_ALIGN) &
+ PAGE_ALIGN) < ppnt->p_vaddr + ppnt->p_memsz)
+
+ Instead, we have to do this: */
+ ppnt->p_filesz < ppnt->p_memsz)
+ {
+ piclib2map = (char *)
+ _dl_mmap(0, (ppnt->p_vaddr & ADDR_ALIGN) + ppnt->p_memsz,
+ LXFLAGS(prot_flags), flags | MAP_ANONYMOUS, -1, 0);
+ if (_dl_mmap_check_error(piclib2map))
+ return 0;
+ }
+
+ tryaddr = piclib == 2 ? piclib2map
+ : ((char *) (piclib ? libaddr : DL_GET_LIB_OFFSET()) +
+ (ppnt->p_vaddr & PAGE_ALIGN));
+
+ size = (ppnt->p_vaddr & ADDR_ALIGN) + ppnt->p_filesz;
+
+ /* For !MMU, mmap to fixed address will fail.
+ So instead of desperately call mmap and fail,
+ we set status to MAP_FAILED to save a call
+ to mmap (). */
+#ifndef __ARCH_USE_MMU__
+ if (piclib2map == 0)
+#endif
+ status = (char *) _dl_mmap
+ (tryaddr, size, LXFLAGS(prot_flags),
+ flags | (piclib2map ? MAP_FIXED : 0),
+ infile, ppnt->p_offset & OFFS_ALIGN);
+#ifndef __ARCH_USE_MMU__
+ else
+ status = MAP_FAILED;
+#endif
+#ifdef _DL_PREAD
+ if (_dl_mmap_check_error(status) && piclib2map
+ && (_DL_PREAD (infile, tryaddr, size,
+ ppnt->p_offset & OFFS_ALIGN) == size))
+ status = tryaddr;
+#endif
+ if (_dl_mmap_check_error(status) || (tryaddr && tryaddr != status))
+ return 0;
+
+ if (piclib2map)
+ retval = piclib2map;
+ else
+ retval = status;
+
+ /* Now we want to allocate and zero-out any data from the end
+ of the region we mapped in from the file (filesz) to the
+ end of the loadable segment (memsz). We may need
+ additional pages for memsz, that we map in below, and we
+ can count on the kernel to zero them out, but we have to
+ zero out stuff in the last page that we mapped in from the
+ file. However, we can't assume to have actually obtained
+ full pages from the kernel, since we didn't ask for them,
+ and uClibc may not give us full pages for small
+ allocations. So only zero out up to memsz or the end of
+ the page, whichever comes first. */
+
+ /* CPNT is the beginning of the memsz portion not backed by
+ filesz. */
+ cpnt = (char *) (status + size);
+
+ /* MAP_SIZE is the address of the
+ beginning of the next page. */
+ map_size = (ppnt->p_vaddr + ppnt->p_filesz
+ + ADDR_ALIGN) & PAGE_ALIGN;
+
+ _dl_memset (cpnt, 0,
+ MIN (map_size
+ - (ppnt->p_vaddr
+ + ppnt->p_filesz),
+ ppnt->p_memsz
+ - ppnt->p_filesz));
+
+ if (map_size < ppnt->p_vaddr + ppnt->p_memsz && !piclib2map) {
+ tryaddr = map_size + (char*)(piclib ? libaddr : 0);
+ status = (char *) _dl_mmap(tryaddr,
+ ppnt->p_vaddr + ppnt->p_memsz - map_size,
+ LXFLAGS(prot_flags),
+ flags | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
+ if (_dl_mmap_check_error(status) || tryaddr != status)
+ return NULL;
+ }
+ return retval;
+}
/*
* Read one ELF library into memory, mmap it into the correct locations and
@@ -334,23 +495,28 @@ goof:
* are required.
*/
-struct elf_resolve *_dl_load_elf_shared_library(int secure,
- struct dyn_elf **rpnt, char *libname)
+struct elf_resolve *_dl_load_elf_shared_library(unsigned int rflags,
+ struct dyn_elf **rpnt, const char *libname)
{
ElfW(Ehdr) *epnt;
unsigned long dynamic_addr = 0;
ElfW(Dyn) *dpnt;
struct elf_resolve *tpnt;
ElfW(Phdr) *ppnt;
+#if defined(USE_TLS) && USE_TLS
+ ElfW(Phdr) *tlsppnt = NULL;
+#endif
char *status, *header;
unsigned long dynamic_info[DYNAMIC_SIZE];
unsigned long *lpnt;
unsigned long libaddr;
unsigned long minvma = 0xffffffff, maxvma = 0;
+ unsigned int rtld_flags;
int i, flags, piclib, infile;
ElfW(Addr) relro_addr = 0;
size_t relro_size = 0;
struct stat st;
+ uint32_t *p32;
DL_LOADADDR_TYPE lib_loadaddr;
DL_INIT_LOADADDR_EXTRA_DECLS
@@ -366,13 +532,14 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
_dl_close(infile);
return NULL;
}
- /* If we are in secure mode (i.e. a setu/gid binary using LD_PRELOAD),
+ /* If we are in secure mode (i.e. a setuid/gid binary using LD_PRELOAD),
we don't load the library if it isn't setuid. */
- if (secure)
+ if (rflags & __RTLD_SECURE) {
if (!(st.st_mode & S_ISUID)) {
_dl_close(infile);
return NULL;
}
+ }
/* Check if file is already loaded */
for (tpnt = _dl_loaded_modules; tpnt; tpnt = tpnt->next) {
@@ -383,8 +550,12 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
return tpnt;
}
}
+ if (rflags & RTLD_NOLOAD) {
+ _dl_close(infile);
+ return NULL;
+ }
header = _dl_mmap((void *) 0, _dl_pagesize, PROT_READ | PROT_WRITE,
- MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ MAP_PRIVATE | MAP_ANONYMOUS | MAP_UNINITIALIZED, -1, 0);
if (_dl_mmap_check_error(header)) {
_dl_dprintf(2, "%s:%i: can't map '%s'\n", _dl_progname, __LINE__, libname);
_dl_internal_error_number = LD_ERROR_MMAP_FAILED;
@@ -394,11 +565,8 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
_dl_read(infile, header, _dl_pagesize);
epnt = (ElfW(Ehdr) *) (intptr_t) header;
- if (epnt->e_ident[0] != 0x7f ||
- epnt->e_ident[1] != 'E' ||
- epnt->e_ident[2] != 'L' ||
- epnt->e_ident[3] != 'F')
- {
+ p32 = (uint32_t*)&epnt->e_ident;
+ if (*p32 != ELFMAG_U32) {
_dl_dprintf(2, "%s: '%s' is not an ELF file\n", _dl_progname,
libname);
_dl_internal_error_number = LD_ERROR_NOTELF;
@@ -407,11 +575,15 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
return NULL;
}
- if ((epnt->e_type != ET_DYN) || (epnt->e_machine != MAGIC1
+ if ((epnt->e_type != ET_DYN
+#ifdef __LDSO_STANDALONE_SUPPORT__
+ && epnt->e_type != ET_EXEC
+#endif
+ ) || (epnt->e_machine != MAGIC1
#ifdef MAGIC2
&& epnt->e_machine != MAGIC2
#endif
- ))
+ ))
{
_dl_internal_error_number =
(epnt->e_type != ET_DYN ? LD_ERROR_NOTDYN : LD_ERROR_NOTMAGIC);
@@ -436,7 +608,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
if (ppnt->p_type == PT_LOAD) {
/* See if this is a PIC library. */
- if (i == 0 && ppnt->p_vaddr > 0x1000000) {
+ if (minvma == 0xffffffff && ppnt->p_vaddr > 0x1000000) {
piclib = 0;
minvma = ppnt->p_vaddr;
}
@@ -447,22 +619,48 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
maxvma = ppnt->p_vaddr + ppnt->p_memsz;
}
}
+ if (ppnt->p_type == PT_TLS) {
+#if defined(USE_TLS) && USE_TLS
+ if (ppnt->p_memsz == 0)
+ /* Nothing to do for an empty segment. */
+ continue;
+ else
+ /* Save for after 'tpnt' is actually allocated. */
+ tlsppnt = ppnt;
+#else
+ /*
+ * Yup, the user was an idiot and tried to sneak in a library with
+ * TLS in it and we don't support it. Let's fall on our own sword
+ * and scream at the luser while we die.
+ */
+ _dl_dprintf(2, "%s: '%s' library contains unsupported TLS\n",
+ _dl_progname, libname);
+ _dl_internal_error_number = LD_ERROR_TLS_FAILED;
+ _dl_close(infile);
+ _dl_munmap(header, _dl_pagesize);
+ return NULL;
+#endif
+ }
ppnt++;
}
+#ifdef __LDSO_STANDALONE_SUPPORT__
+ if (epnt->e_type == ET_EXEC)
+ piclib = 0;
+#endif
+
DL_CHECK_LIB_TYPE (epnt, piclib, _dl_progname, libname);
- maxvma = (maxvma + ADDR_ALIGN) & ~ADDR_ALIGN;
- minvma = minvma & ~0xffffU;
+ maxvma = (maxvma + ADDR_ALIGN) & PAGE_ALIGN;
+ minvma = minvma & ~ADDR_ALIGN;
flags = MAP_PRIVATE /*| MAP_DENYWRITE */ ;
- if (!piclib)
- flags |= MAP_FIXED;
if (piclib == 0 || piclib == 1) {
status = (char *) _dl_mmap((char *) (piclib ? 0 : minvma),
maxvma - minvma, PROT_NONE, flags | MAP_ANONYMOUS, -1, 0);
if (_dl_mmap_check_error(status)) {
+ cant_map:
_dl_dprintf(2, "%s:%i: can't map '%s'\n", _dl_progname, __LINE__, libname);
_dl_internal_error_number = LD_ERROR_MMAP_FAILED;
_dl_close(infile);
@@ -476,15 +674,20 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
/* Get the memory to store the library */
ppnt = (ElfW(Phdr) *)(intptr_t) & header[epnt->e_phoff];
- DL_INIT_LOADADDR(lib_loadaddr, libaddr, ppnt, epnt->e_phnum);
+ DL_INIT_LOADADDR(lib_loadaddr, libaddr - minvma, ppnt, epnt->e_phnum);
+ /* Set _dl_library_offset to lib_loadaddr or 0. */
+ DL_SET_LIB_OFFSET(lib_loadaddr);
for (i = 0; i < epnt->e_phnum; i++) {
if (DL_IS_SPECIAL_SEGMENT (epnt, ppnt)) {
char *addr;
addr = DL_MAP_SEGMENT (epnt, ppnt, infile, flags);
- if (addr == NULL)
+ if (addr == NULL) {
+ cant_map1:
+ DL_LOADADDR_UNMAP (lib_loadaddr, maxvma - minvma);
goto cant_map;
+ }
DL_INIT_LOADADDR_HDR (lib_loadaddr, addr, ppnt);
ppnt++;
@@ -498,152 +701,14 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
char *tryaddr;
ssize_t size;
- /* See if this is a PIC library. */
- if (i == 0 && ppnt->p_vaddr > 0x1000000) {
- piclib = 0;
- /* flags |= MAP_FIXED; */
- }
-
if (ppnt->p_flags & PF_W) {
- unsigned long map_size;
- char *cpnt;
- char *piclib2map = 0;
-
- if (piclib == 2 &&
- /* We might be able to avoid this
- call if memsz doesn't require
- an additional page, but this
- would require mmap to always
- return page-aligned addresses
- and a whole number of pages
- allocated. Unfortunately on
- uClinux may return misaligned
- addresses and may allocate
- partial pages, so we may end up
- doing unnecessary mmap calls.
-
- This is what we could do if we
- knew mmap would always return
- aligned pages:
-
- ((ppnt->p_vaddr + ppnt->p_filesz
- + ADDR_ALIGN)
- & PAGE_ALIGN)
- < ppnt->p_vaddr + ppnt->p_memsz)
-
- Instead, we have to do this: */
- ppnt->p_filesz < ppnt->p_memsz)
- {
- piclib2map = (char *)
- _dl_mmap(0, (ppnt->p_vaddr & ADDR_ALIGN)
- + ppnt->p_memsz,
- LXFLAGS(ppnt->p_flags),
- flags | MAP_ANONYMOUS, -1, 0);
- if (_dl_mmap_check_error(piclib2map))
- goto cant_map;
- DL_INIT_LOADADDR_HDR
- (lib_loadaddr, piclib2map
- + (ppnt->p_vaddr & ADDR_ALIGN), ppnt);
- }
-
- tryaddr = piclib == 2 ? piclib2map
- : ((char*) (piclib ? libaddr : 0) +
- (ppnt->p_vaddr & PAGE_ALIGN));
-
- size = (ppnt->p_vaddr & ADDR_ALIGN)
- + ppnt->p_filesz;
-
- /* For !MMU, mmap to fixed address will fail.
- So instead of desperately call mmap and fail,
- we set status to MAP_FAILED to save a call
- to mmap (). */
-#ifndef __ARCH_USE_MMU__
- if (piclib2map == 0)
-#endif
- status = (char *) _dl_mmap
- (tryaddr, size, LXFLAGS(ppnt->p_flags),
- flags | (piclib2map ? MAP_FIXED : 0),
- infile, ppnt->p_offset & OFFS_ALIGN);
-#ifndef __ARCH_USE_MMU__
- else
- status = MAP_FAILED;
-#endif
-#ifdef _DL_PREAD
- if (_dl_mmap_check_error(status) && piclib2map
- && (_DL_PREAD (infile, tryaddr, size,
- ppnt->p_offset & OFFS_ALIGN)
- == size))
- status = tryaddr;
-#endif
- if (_dl_mmap_check_error(status)
- || (tryaddr && tryaddr != status)) {
- cant_map:
- _dl_dprintf(2, "%s:%i: can't map '%s'\n",
- _dl_progname, __LINE__, libname);
- _dl_internal_error_number = LD_ERROR_MMAP_FAILED;
- DL_LOADADDR_UNMAP (lib_loadaddr, maxvma - minvma);
- _dl_close(infile);
- _dl_munmap(header, _dl_pagesize);
- return NULL;
- }
-
- if (! piclib2map) {
- DL_INIT_LOADADDR_HDR
- (lib_loadaddr, status
- + (ppnt->p_vaddr & ADDR_ALIGN), ppnt);
- }
- /* Now we want to allocate and
- zero-out any data from the end of
- the region we mapped in from the
- file (filesz) to the end of the
- loadable segment (memsz). We may
- need additional pages for memsz,
- that we map in below, and we can
- count on the kernel to zero them
- out, but we have to zero out stuff
- in the last page that we mapped in
- from the file. However, we can't
- assume to have actually obtained
- full pages from the kernel, since
- we didn't ask for them, and uClibc
- may not give us full pages for
- small allocations. So only zero
- out up to memsz or the end of the
- page, whichever comes first. */
-
- /* CPNT is the beginning of the memsz
- portion not backed by filesz. */
- cpnt = (char *) (status + size);
-
- /* MAP_SIZE is the address of the
- beginning of the next page. */
- map_size = (ppnt->p_vaddr + ppnt->p_filesz
- + ADDR_ALIGN) & PAGE_ALIGN;
-
-#ifndef MIN
-# define MIN(a,b) ((a) < (b) ? (a) : (b))
-#endif
- _dl_memset (cpnt, 0,
- MIN (map_size
- - (ppnt->p_vaddr
- + ppnt->p_filesz),
- ppnt->p_memsz
- - ppnt->p_filesz));
-
- if (map_size < ppnt->p_vaddr + ppnt->p_memsz
- && !piclib2map) {
- tryaddr = map_size + (char*)(piclib ? libaddr : 0);
- status = (char *) _dl_mmap(tryaddr,
- ppnt->p_vaddr + ppnt->p_memsz - map_size,
- LXFLAGS(ppnt->p_flags), flags | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
- if (_dl_mmap_check_error(status)
- || tryaddr != status)
- goto cant_map;
- }
+ status = map_writeable (infile, ppnt, piclib, flags, libaddr);
+ if (status == NULL)
+ goto cant_map1;
} else {
tryaddr = (piclib == 2 ? 0
: (char *) (ppnt->p_vaddr & PAGE_ALIGN)
- + (piclib ? libaddr : 0));
+ + (piclib ? libaddr : DL_GET_LIB_OFFSET()));
size = (ppnt->p_vaddr & ADDR_ALIGN) + ppnt->p_filesz;
status = (char *) _dl_mmap
(tryaddr, size, LXFLAGS(ppnt->p_flags),
@@ -652,11 +717,11 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
infile, ppnt->p_offset & OFFS_ALIGN);
if (_dl_mmap_check_error(status)
|| (tryaddr && tryaddr != status))
- goto cant_map;
- DL_INIT_LOADADDR_HDR
- (lib_loadaddr, status
- + (ppnt->p_vaddr & ADDR_ALIGN), ppnt);
+ goto cant_map1;
}
+ DL_INIT_LOADADDR_HDR(lib_loadaddr,
+ status + (ppnt->p_vaddr & ADDR_ALIGN),
+ ppnt);
/* if (libaddr == 0 && piclib) {
libaddr = (unsigned long) status;
@@ -665,10 +730,16 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
}
ppnt++;
}
- _dl_close(infile);
- /* For a non-PIC library, the addresses are all absolute */
+ /*
+ * The dynamic_addr must be take into acount lib_loadaddr value, to note
+ * it is zero when the SO has been mapped to the elf's physical addr
+ */
+#ifdef __LDSO_PRELINK_SUPPORT__
+ if (DL_GET_LIB_OFFSET()) {
+#else
if (piclib) {
+#endif
dynamic_addr = (unsigned long) DL_RELOC_ADDR(lib_loadaddr, dynamic_addr);
}
@@ -684,12 +755,13 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
_dl_dprintf(2, "%s: '%s' is missing a dynamic section\n",
_dl_progname, libname);
_dl_munmap(header, _dl_pagesize);
+ _dl_close(infile);
return NULL;
}
dpnt = (ElfW(Dyn) *) dynamic_addr;
_dl_memset(dynamic_info, 0, sizeof(dynamic_info));
- _dl_parse_dynamic_info(dpnt, dynamic_info, NULL, lib_loadaddr);
+ rtld_flags = _dl_parse_dynamic_info(dpnt, dynamic_info, NULL, lib_loadaddr);
/* If the TEXTREL is set, this means that we need to make the pages
writable before we perform relocations. Do this now. They get set
back again later. */
@@ -698,32 +770,103 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
#ifndef __FORCE_SHAREABLE_TEXT_SEGMENTS__
ppnt = (ElfW(Phdr) *)(intptr_t) & header[epnt->e_phoff];
for (i = 0; i < epnt->e_phnum; i++, ppnt++) {
- if (ppnt->p_type == PT_LOAD && !(ppnt->p_flags & PF_W))
- _dl_mprotect((void *) ((piclib ? libaddr : 0) +
+ if (ppnt->p_type == PT_LOAD && !(ppnt->p_flags & PF_W)) {
+#ifdef __ARCH_USE_MMU__
+ _dl_mprotect((void *) ((piclib ? libaddr : DL_GET_LIB_OFFSET()) +
(ppnt->p_vaddr & PAGE_ALIGN)),
(ppnt->p_vaddr & ADDR_ALIGN) + (unsigned long) ppnt->p_filesz,
PROT_READ | PROT_WRITE | PROT_EXEC);
+#else
+ void *new_addr;
+ new_addr = map_writeable (infile, ppnt, piclib, flags, libaddr);
+ if (!new_addr) {
+ _dl_dprintf(2, "Can't modify %s's text section.",
+ libname);
+ _dl_exit(1);
+ }
+ DL_UPDATE_LOADADDR_HDR(lib_loadaddr,
+ new_addr + (ppnt->p_vaddr & ADDR_ALIGN),
+ ppnt);
+ /* This has invalidated all pointers into the previously readonly segment.
+ Update any them to point into the remapped segment. */
+ _dl_parse_dynamic_info(dpnt, dynamic_info, NULL, lib_loadaddr);
+#endif
+ }
}
#else
- _dl_dprintf(_dl_debug_file, "Can't modify %s's text section. Use GCC option -fPIC for shared objects, please.\n",libname);
+ _dl_dprintf(2, "Can't modify %s's text section."
+ " Use GCC option -fPIC for shared objects, please.\n",
+ libname);
_dl_exit(1);
#endif
}
+ _dl_close(infile);
+
tpnt = _dl_add_elf_hash_table(libname, lib_loadaddr, dynamic_info,
dynamic_addr, 0);
+ tpnt->mapaddr = libaddr;
tpnt->relro_addr = relro_addr;
tpnt->relro_size = relro_size;
tpnt->st_dev = st.st_dev;
tpnt->st_ino = st.st_ino;
- tpnt->ppnt = (ElfW(Phdr) *) DL_RELOC_ADDR(tpnt->loadaddr, epnt->e_phoff);
+ tpnt->ppnt = (ElfW(Phdr) *)
+ DL_RELOC_ADDR(DL_GET_RUN_ADDR(tpnt->loadaddr, tpnt->mapaddr),
+ epnt->e_phoff);
tpnt->n_phent = epnt->e_phnum;
+ tpnt->rtld_flags = rflags | rtld_flags;
+#ifdef __LDSO_STANDALONE_SUPPORT__
+ tpnt->l_entry = epnt->e_entry;
+#endif
+
+#if defined(USE_TLS) && USE_TLS
+ if (tlsppnt) {
+ _dl_debug_early("Found TLS header for %s\n", libname);
+# if NO_TLS_OFFSET != 0
+ tpnt->l_tls_offset = NO_TLS_OFFSET;
+# endif
+ tpnt->l_tls_blocksize = tlsppnt->p_memsz;
+ tpnt->l_tls_align = tlsppnt->p_align;
+ if (tlsppnt->p_align == 0)
+ tpnt->l_tls_firstbyte_offset = 0;
+ else
+ tpnt->l_tls_firstbyte_offset = tlsppnt->p_vaddr &
+ (tlsppnt->p_align - 1);
+ tpnt->l_tls_initimage_size = tlsppnt->p_filesz;
+ tpnt->l_tls_initimage = (void *) tlsppnt->p_vaddr;
+
+ /* Assign the next available module ID. */
+ tpnt->l_tls_modid = _dl_next_tls_modid ();
+
+ /* We know the load address, so add it to the offset. */
+#ifdef __LDSO_STANDALONE_SUPPORT__
+ if ((tpnt->l_tls_initimage != NULL) && piclib)
+#else
+ if (tpnt->l_tls_initimage != NULL)
+#endif
+ {
+# ifdef __SUPPORT_LD_DEBUG_EARLY__
+ char *tmp = (char *) tpnt->l_tls_initimage;
+ tpnt->l_tls_initimage = (char *) tlsppnt->p_vaddr + tpnt->loadaddr;
+ _dl_debug_early("Relocated TLS initial image from %x to %x (size = %x)\n", tmp, tpnt->l_tls_initimage, tpnt->l_tls_initimage_size);
+ tmp = 0;
+# else
+ tpnt->l_tls_initimage = (char *) tlsppnt->p_vaddr + tpnt->loadaddr;
+# endif
+ }
+ }
+#endif
/*
* Add this object into the symbol chain
*/
- if (*rpnt) {
- (*rpnt)->next = (struct dyn_elf *) _dl_malloc(sizeof(struct dyn_elf));
+ if (*rpnt
+#ifdef __LDSO_STANDALONE_SUPPORT__
+ /* Do not create a new chain entry for the main executable */
+ && (*rpnt)->dyn
+#endif
+ ) {
+ (*rpnt)->next = _dl_malloc(sizeof(struct dyn_elf));
_dl_memset((*rpnt)->next, 0, sizeof(struct dyn_elf));
(*rpnt)->next->prev = (*rpnt);
*rpnt = (*rpnt)->next;
@@ -734,14 +877,17 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
* and initialize the _dl_symbol_table.
*/
else {
- *rpnt = _dl_symbol_tables = (struct dyn_elf *) _dl_malloc(sizeof(struct dyn_elf));
+ *rpnt = _dl_symbol_tables = _dl_malloc(sizeof(struct dyn_elf));
_dl_memset(*rpnt, 0, sizeof(struct dyn_elf));
}
#endif
(*rpnt)->dyn = tpnt;
- tpnt->symbol_scope = _dl_symbol_tables;
tpnt->usage_count++;
+#ifdef __LDSO_STANDALONE_SUPPORT__
+ tpnt->libtype = (epnt->e_type == ET_DYN) ? elf_lib : elf_executable;
+#else
tpnt->libtype = elf_lib;
+#endif
/*
* OK, the next thing we need to do is to insert the dynamic linker into
@@ -756,6 +902,76 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
INIT_GOT(lpnt, tpnt);
}
+#ifdef __DSBT__
+ /* Handle DSBT initialization */
+ {
+ struct elf_resolve *t, *ref;
+ int idx = tpnt->dsbt_index;
+ void **dsbt = tpnt->dsbt_table;
+
+ /*
+ * It is okay (required actually) to have zero idx for an executable.
+ * This is the case when running ldso standalone and the program
+ * is being mapped in via _dl_load_shared_library().
+ */
+ if (idx == 0 && tpnt->libtype != elf_executable) {
+ if (!dynamic_info[DT_TEXTREL]) {
+ /* This DSO has not been assigned an index. */
+ _dl_dprintf(2, "%s: '%s' is missing a dsbt index assignment!\n",
+ _dl_progname, libname);
+ _dl_exit(1);
+ }
+ /* Find a dsbt table from another module. */
+ ref = NULL;
+ for (t = _dl_loaded_modules; t; t = t->next) {
+ if (ref == NULL && t != tpnt) {
+ ref = t;
+ break;
+ }
+ }
+ idx = tpnt->dsbt_size;
+ while (idx-- > 0)
+ if (!ref || ref->dsbt_table[idx] == NULL)
+ break;
+ if (idx <= 0) {
+ _dl_dprintf(2, "%s: '%s' caused DSBT table overflow!\n",
+ _dl_progname, libname);
+ _dl_exit(1);
+ }
+ _dl_if_debug_dprint("\n\tfile='%s'; assigned index %d\n",
+ libname, idx);
+ tpnt->dsbt_index = idx;
+ }
+
+ /* make sure index is not already used */
+ if (_dl_ldso_dsbt[idx]) {
+ struct elf_resolve *dup;
+ const char *dup_name;
+
+ for (dup = _dl_loaded_modules; dup; dup = dup->next)
+ if (dup != tpnt && dup->dsbt_index == idx)
+ break;
+ if (dup)
+ dup_name = dup->libname;
+ else if (idx == 1)
+ dup_name = "runtime linker";
+ else
+ dup_name = "unknown library";
+ _dl_dprintf(2, "%s: '%s' dsbt index %d already used by %s!\n",
+ _dl_progname, libname, idx, dup_name);
+ _dl_exit(1);
+ }
+
+ /*
+ * Setup dsbt slot for this module in dsbt of all modules.
+ */
+ for (t = _dl_loaded_modules; t; t = t->next)
+ t->dsbt_table[idx] = dsbt;
+ _dl_ldso_dsbt[idx] = dsbt;
+ _dl_memcpy(dsbt, _dl_ldso_dsbt,
+ tpnt->dsbt_size * sizeof(tpnt->dsbt_table[0]));
+ }
+#endif
_dl_if_debug_dprint("\n\tfile='%s'; generating link map\n", libname);
_dl_if_debug_dprint("\t\tdynamic: %x base: %x\n", dynamic_addr, DL_LOADADDR_BASE(lib_loadaddr));
_dl_if_debug_dprint("\t\t entry: %x phdr: %x phnum: %x\n\n",
@@ -767,7 +983,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
}
/* now_flag must be RTLD_NOW or zero */
-int _dl_fixup(struct dyn_elf *rpnt, int now_flag)
+int _dl_fixup(struct dyn_elf *rpnt, struct r_scope_elem *scope, int now_flag)
{
int goof = 0;
struct elf_resolve *tpnt;
@@ -775,7 +991,7 @@ int _dl_fixup(struct dyn_elf *rpnt, int now_flag)
ElfW(Addr) reloc_addr;
if (rpnt->next)
- goof = _dl_fixup(rpnt->next, now_flag);
+ goof = _dl_fixup(rpnt->next, scope, now_flag);
if (goof)
return goof;
tpnt = rpnt->dyn;
@@ -802,10 +1018,13 @@ int _dl_fixup(struct dyn_elf *rpnt, int now_flag)
relative_count = tpnt->dynamic_info[DT_RELCONT_IDX];
if (relative_count) { /* Optimize the XX_RELATIVE relocations if possible */
reloc_size -= relative_count * sizeof(ELF_RELOC);
- elf_machine_relative(tpnt->loadaddr, reloc_addr, relative_count);
+#ifdef __LDSO_PRELINK_SUPPORT__
+ if (tpnt->loadaddr || (!tpnt->dynamic_info[DT_GNU_PRELINKED_IDX]))
+#endif
+ elf_machine_relative(tpnt->loadaddr, reloc_addr, relative_count);
reloc_addr += relative_count * sizeof(ELF_RELOC);
}
- goof += _dl_parse_relocation_information(rpnt,
+ goof += _dl_parse_relocation_information(rpnt, scope,
reloc_addr,
reloc_size);
tpnt->init_flag |= RELOCS_DONE;
@@ -821,15 +1040,26 @@ int _dl_fixup(struct dyn_elf *rpnt, int now_flag)
tpnt->dynamic_info[DT_JMPREL],
tpnt->dynamic_info [DT_PLTRELSZ]);
} else {
- goof += _dl_parse_relocation_information(rpnt,
+ goof += _dl_parse_relocation_information(rpnt, scope,
tpnt->dynamic_info[DT_JMPREL],
tpnt->dynamic_info[DT_PLTRELSZ]);
}
tpnt->init_flag |= JMP_RELOCS_DONE;
}
+
+#if 0
+/* _dl_add_to_slotinfo is called by init_tls() for initial DSO
+ or by dlopen() for dynamically loaded DSO. */
+#if defined(USE_TLS) && USE_TLS
+ /* Add object to slot information data if necessasy. */
+ if (tpnt->l_tls_blocksize != 0 && tls_init_tp_called)
+ _dl_add_to_slotinfo ((struct link_map *) tpnt);
+#endif
+#endif
return goof;
}
+#ifdef IS_IN_rtld
/* Minimal printf which handles only %s, %d, and %x */
void _dl_dprintf(int fd, const char *fmt, ...)
{
@@ -840,7 +1070,7 @@ void _dl_dprintf(int fd, const char *fmt, ...)
#endif
va_list args;
char *start, *ptr, *string;
- static char *buf;
+ char *buf;
if (!fmt)
return;
@@ -895,7 +1125,7 @@ void _dl_dprintf(int fd, const char *fmt, ...)
break;
}
case 'x':
- case 'X':
+ case 'p':
{
char tmp[22];
#if __WORDSIZE > 32
@@ -932,35 +1162,10 @@ char *_dl_strdup(const char *string)
_dl_strcpy(retval, string);
return retval;
}
+#endif
-void _dl_parse_dynamic_info(ElfW(Dyn) *dpnt, unsigned long dynamic_info[],
- void *debug_addr, DL_LOADADDR_TYPE load_off)
-{
- __dl_parse_dynamic_info(dpnt, dynamic_info, debug_addr, load_off);
-}
-
-/* we want this in ldso.so and libdl.a but nowhere else */
-#ifdef __USE_GNU
-#if defined IS_IN_rtld || (defined IS_IN_libdl && ! defined SHARED)
-extern __typeof(dl_iterate_phdr) __dl_iterate_phdr;
-int
-__dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info, size_t size, void *data), void *data)
+unsigned int _dl_parse_dynamic_info(ElfW(Dyn) *dpnt, unsigned long dynamic_info[],
+ void *debug_addr, DL_LOADADDR_TYPE load_off)
{
- struct elf_resolve *l;
- struct dl_phdr_info info;
- int ret = 0;
-
- for (l = _dl_loaded_modules; l != NULL; l = l->next) {
- info.dlpi_addr = l->loadaddr;
- info.dlpi_name = l->libname;
- info.dlpi_phdr = l->ppnt;
- info.dlpi_phnum = l->n_phent;
- ret = callback (&info, sizeof (struct dl_phdr_info), data);
- if (ret)
- break;
- }
- return ret;
+ return __dl_parse_dynamic_info(dpnt, dynamic_info, debug_addr, load_off);
}
-strong_alias(__dl_iterate_phdr, dl_iterate_phdr)
-#endif
-#endif
diff --git a/ldso/ldso/dl-hash.c b/ldso/ldso/dl-hash.c
index 2a393353b..740626e27 100644
--- a/ldso/ldso/dl-hash.c
+++ b/ldso/ldso/dl-hash.c
@@ -32,14 +32,6 @@
/* Various symbol table handling functions, including symbol lookup */
-
-/*
- * This is the start of the linked list that describes all of the files present
- * in the system with pointers to all of the symbol, string, and hash tables,
- * as well as all of the other good stuff in the binary.
- */
-struct elf_resolve *_dl_loaded_modules = NULL;
-
/*
* This is the list of modules that are loaded when the image is first
* started. As we add more via dlopen, they get added into other
@@ -103,17 +95,18 @@ struct elf_resolve *_dl_add_elf_hash_table(const char *libname,
struct elf_resolve *tpnt;
int i;
- if (!_dl_loaded_modules) {
- tpnt = _dl_loaded_modules = (struct elf_resolve *) _dl_malloc(sizeof(struct elf_resolve));
- _dl_memset(tpnt, 0, sizeof(struct elf_resolve));
- } else {
- tpnt = _dl_loaded_modules;
- while (tpnt->next)
- tpnt = tpnt->next;
- tpnt->next = (struct elf_resolve *) _dl_malloc(sizeof(struct elf_resolve));
- _dl_memset(tpnt->next, 0, sizeof(struct elf_resolve));
- tpnt->next->prev = tpnt;
- tpnt = tpnt->next;
+ tpnt = _dl_malloc(sizeof(struct elf_resolve));
+ _dl_memset(tpnt, 0, sizeof(struct elf_resolve));
+
+ if (!_dl_loaded_modules)
+ _dl_loaded_modules = tpnt;
+ else {
+ struct elf_resolve *t = _dl_loaded_modules;
+ while (t->next)
+ t = t->next;
+ t->next = tpnt;
+ t->next->prev = t;
+ tpnt = t->next;
}
tpnt->next = NULL;
@@ -122,6 +115,15 @@ struct elf_resolve *_dl_add_elf_hash_table(const char *libname,
tpnt->dynamic_addr = (ElfW(Dyn) *)dynamic_addr;
tpnt->libtype = loaded_file;
+#ifdef __DSBT__
+ if (dynamic_info[DT_DSBT_BASE_IDX] != 0)
+ tpnt->dsbt_table = (void *)dynamic_info[DT_DSBT_BASE_IDX];
+ if (dynamic_info[DT_DSBT_SIZE_IDX] != 0)
+ tpnt->dsbt_size = dynamic_info[DT_DSBT_SIZE_IDX];
+ if (dynamic_info[DT_DSBT_INDEX_IDX] != 0)
+ tpnt->dsbt_index = dynamic_info[DT_DSBT_INDEX_IDX];
+#endif /* __DSBT__ */
+
#ifdef __LDSO_GNU_HASH_SUPPORT__
if (dynamic_info[DT_GNU_HASH_IDX] != 0) {
Elf32_Word *hash32 = (Elf_Symndx*)dynamic_info[DT_GNU_HASH_IDX];
@@ -153,7 +155,6 @@ struct elf_resolve *_dl_add_elf_hash_table(const char *libname,
tpnt->chains = hash_addr;
}
tpnt->loadaddr = loadaddr;
- tpnt->mapaddr = DL_RELOC_ADDR(loadaddr, 0);
for (i = 0; i < DYNAMIC_SIZE; i++)
tpnt->dynamic_info[i] = dynamic_info[i];
return tpnt;
@@ -164,6 +165,22 @@ struct elf_resolve *_dl_add_elf_hash_table(const char *libname,
static __attribute_noinline__ const ElfW(Sym) *
check_match (const ElfW(Sym) *sym, char *strtab, const char* undef_name, int type_class)
{
+
+#if defined(USE_TLS) && USE_TLS
+ if ((sym->st_value == 0 && (ELF_ST_TYPE(sym->st_info) != STT_TLS))
+ || (type_class & (sym->st_shndx == SHN_UNDEF)))
+ /* No value or undefined symbol itself */
+ return NULL;
+
+ if (ELF_ST_TYPE(sym->st_info) > STT_FUNC
+ && ELF_ST_TYPE(sym->st_info) != STT_COMMON
+ && ELF_ST_TYPE(sym->st_info) != STT_TLS)
+ /* Ignore all but STT_NOTYPE, STT_OBJECT, STT_FUNC and STT_COMMON
+ * entries (and STT_TLS if TLS is supported) since these
+ * are no code/data definitions.
+ */
+ return NULL;
+#else
if (type_class & (sym->st_shndx == SHN_UNDEF))
/* undefined symbol itself */
return NULL;
@@ -179,7 +196,11 @@ check_match (const ElfW(Sym) *sym, char *strtab, const char* undef_name, int typ
* code/data definitions
*/
return NULL;
-
+#endif
+#ifdef ARCH_SKIP_RELOC
+ if (ARCH_SKIP_RELOC(type_class, sym))
+ return NULL;
+#endif
if (_dl_strcmp(strtab + sym->st_name, undef_name) != 0)
return NULL;
@@ -259,109 +280,116 @@ _dl_lookup_sysv_hash(struct elf_resolve *tpnt, ElfW(Sym) *symtab, unsigned long
* This function resolves externals, and this is either called when we process
* relocations or when we call an entry in the PLT table for the first time.
*/
-char *_dl_lookup_hash(const char *name, struct dyn_elf *rpnt,
- struct elf_resolve *mytpnt, int type_class
-#ifdef __FDPIC__
- , struct elf_resolve **tpntp
-#endif
- )
+char *_dl_find_hash(const char *name, struct r_scope_elem *scope, struct elf_resolve *mytpnt,
+ int type_class, struct symbol_ref *sym_ref)
{
struct elf_resolve *tpnt = NULL;
ElfW(Sym) *symtab;
+ int i = 0;
unsigned long elf_hash_number = 0xffffffff;
const ElfW(Sym) *sym = NULL;
- const ElfW(Sym) *weak_sym = 0;
- struct elf_resolve *weak_tpnt = 0;
+ char *weak_result = NULL;
+ struct r_scope_elem *loop_scope;
#ifdef __LDSO_GNU_HASH_SUPPORT__
unsigned long gnu_hash_number = _dl_gnu_hash((const unsigned char *)name);
#endif
- for (; rpnt; rpnt = rpnt->next) {
- tpnt = rpnt->dyn;
-
- if (!(tpnt->rtld_flags & RTLD_GLOBAL) && mytpnt) {
- if (mytpnt == tpnt)
- ;
- else {
- struct init_fini_list *tmp;
-
- for (tmp = mytpnt->rtld_local; tmp; tmp = tmp->next) {
- if (tmp->tpnt == tpnt)
- break;
+ if ((sym_ref) && (sym_ref->sym) && (ELF32_ST_VISIBILITY(sym_ref->sym->st_other) == STV_PROTECTED)) {
+ sym = sym_ref->sym;
+ if (mytpnt)
+ tpnt = mytpnt;
+ } else
+ for (loop_scope = scope; loop_scope && !sym; loop_scope = loop_scope->next) {
+ for (i = 0; i < loop_scope->r_nlist; i++) {
+ tpnt = loop_scope->r_list[i];
+
+ if (!(tpnt->rtld_flags & RTLD_GLOBAL) && mytpnt) {
+ if (mytpnt == tpnt)
+ ;
+ else {
+ struct init_fini_list *tmp;
+
+ for (tmp = mytpnt->rtld_local; tmp; tmp = tmp->next) {
+ if (tmp->tpnt == tpnt)
+ break;
+ }
+ if (!tmp)
+ continue;
}
- if (!tmp)
- continue;
}
- }
- /* Don't search the executable when resolving a copy reloc. */
- if ((type_class & ELF_RTYPE_CLASS_COPY) && tpnt->libtype == elf_executable)
- continue;
+ /* Don't search the executable when resolving a copy reloc. */
+ if ((type_class & ELF_RTYPE_CLASS_COPY) && tpnt->libtype == elf_executable)
+ continue;
- /* If the hash table is empty there is nothing to do here. */
- if (tpnt->nbucket == 0)
- continue;
+ /* If the hash table is empty there is nothing to do here. */
+ if (tpnt->nbucket == 0)
+ continue;
- symtab = (ElfW(Sym) *) (intptr_t) (tpnt->dynamic_info[DT_SYMTAB]);
+ symtab = (ElfW(Sym) *) (intptr_t) (tpnt->dynamic_info[DT_SYMTAB]);
#ifdef __LDSO_GNU_HASH_SUPPORT__
- /* Prefer GNU hash style, if any */
- if (tpnt->l_gnu_bitmask) {
- sym = _dl_lookup_gnu_hash(tpnt, symtab, gnu_hash_number, name, type_class);
- if (sym != NULL)
- /* If sym has been found, do not search further */
- break;
- } else {
+ /* Prefer GNU hash style, if any */
+ if (tpnt->l_gnu_bitmask) {
+ sym = _dl_lookup_gnu_hash(tpnt, symtab, gnu_hash_number, name, type_class);
+ if (sym != NULL)
+ /* If sym has been found, do not search further */
+ break;
+ } else {
#endif
- /* Use the old SysV-style hash table */
+ /* Use the old SysV-style hash table */
- /* Calculate the old sysv hash number only once */
- if (elf_hash_number == 0xffffffff)
- elf_hash_number = _dl_elf_hash((const unsigned char *)name);
+ /* Calculate the old sysv hash number only once */
+ if (elf_hash_number == 0xffffffff)
+ elf_hash_number = _dl_elf_hash((const unsigned char *)name);
- sym = _dl_lookup_sysv_hash(tpnt, symtab, elf_hash_number, name, type_class);
- if (sym != NULL)
- break;
+ sym = _dl_lookup_sysv_hash(tpnt, symtab, elf_hash_number, name, type_class);
+ if (sym != NULL)
+ /* If sym has been found, do not search further */
+ break;
#ifdef __LDSO_GNU_HASH_SUPPORT__
- }
+ }
#endif
- } /* end of for (; rpnt; rpnt = rpnt->next) { */
+ } /* End of inner for */
+ }
if (sym) {
+ if (sym_ref) {
+ sym_ref->sym = sym;
+ sym_ref->tpnt = tpnt;
+ }
/* At this point we have found the requested symbol, do binding */
+#if defined(USE_TLS) && USE_TLS
+ if (ELF_ST_TYPE(sym->st_info) == STT_TLS) {
+ _dl_assert(sym_ref != NULL);
+ return (char *)sym->st_value;
+ }
+#endif
+
switch (ELF_ST_BIND(sym->st_info)) {
case STB_WEAK:
#if 0
-/* Perhaps we should support old style weak symbol handling
- * per what glibc does when you export LD_DYNAMIC_WEAK */
- if (!weak_sym) {
- weak_tpnt = tpnt;
- weak_sym = sym;
- }
+ /* Perhaps we should support old style weak symbol handling
+ * per what glibc does when you export LD_DYNAMIC_WEAK */
+ if (!weak_result)
+ weak_result = (char *)DL_FIND_HASH_VALUE(tpnt, type_class, sym);
break;
#endif
case STB_GLOBAL:
-#ifdef __FDPIC__
- if (tpntp)
- *tpntp = tpnt;
+#if defined(__FRV_FDPIC__) || defined(__BFIN_FDPIC__)
+ if (sym_ref)
+ sym_ref->tpnt = tpnt;
#endif
- return (char *) DL_FIND_HASH_VALUE (tpnt, type_class, sym);
+ return (char *)DL_FIND_HASH_VALUE(tpnt, type_class, sym);
default: /* Local symbols not handled here */
break;
}
}
- if (weak_sym) {
-#ifdef __FDPIC__
- if (tpntp)
- *tpntp = weak_tpnt;
-#endif
- return (char *) DL_FIND_HASH_VALUE (weak_tpnt, type_class, weak_sym);
- }
-#ifdef __FDPIC__
- if (tpntp)
- *tpntp = NULL;
+#if defined(__FRV_FDPIC__) || defined(__BFIN_FDPIC__)
+ if (sym_ref)
+ sym_ref->tpnt = tpnt;
#endif
- return NULL;
+ return weak_result;
}
diff --git a/ldso/ldso/dl-startup.c b/ldso/ldso/dl-startup.c
index 42fb44e9c..18a39ce2c 100644
--- a/ldso/ldso/dl-startup.c
+++ b/ldso/ldso/dl-startup.c
@@ -32,8 +32,8 @@
/*
* The main trick with this program is that initially, we ourselves are not
- * dynamicly linked. This means that we cannot access any global variables or
- * call any functions. No globals initially, since the Global Offset Table
+ * dynamically linked. This means that we cannot access any global variables
+ * or call any functions. No globals initially, since the Global Offset Table
* (GOT) is initialized by the linker assuming a virtual address of 0, and no
* function calls initially since the Procedure Linkage Table (PLT) is not yet
* initialized.
@@ -55,12 +55,12 @@
*
* Fortunately, the linker itself leaves a few clues lying around, and when the
* kernel starts the image, there are a few further clues. First of all, there
- * is Auxiliary Vector Table information sitting on which is provided to us by
- * the kernel, and which includes information about the load address that the
- * program interpreter was loaded at, the number of sections, the address the
- * application was loaded at and so forth. Here this information is stored in
- * the array auxvt. For details see linux/fs/binfmt_elf.c where it calls
- * NEW_AUX_ENT() a bunch of time....
+ * is Auxiliary Vector Table information sitting on the stack which is provided
+ * to us by the kernel, and which includes information about the address
+ * that the program interpreter was loaded at, the number of sections, the
+ * address the application was loaded at, and so forth. Here this information
+ * is stored in the array auxvt. For details see linux/fs/binfmt_elf.c where
+ * it calls NEW_AUX_ENT() a bunch of times....
*
* Next, we need to find the GOT. On most arches there is a register pointing
* to the GOT, but just in case (and for new ports) I've added some (slow) C
@@ -94,8 +94,13 @@
/* Pull in all the arch specific stuff */
#include "dl-startup.h"
+#ifdef __LDSO_PRELINK_SUPPORT__
+/* This is defined by the linker script. */
+extern ElfW(Addr) _begin[] attribute_hidden;
+#endif
+
/* Static declarations */
-int (*_dl_elf_main) (int, char **, char **);
+static int (*_dl_elf_main) (int, char **, char **);
static void* __rtld_stack_end; /* Points to argc on stack, e.g *((long *)__rtld_stackend) == argc */
strong_alias(__rtld_stack_end, __libc_stack_end) /* Exported version of __rtld_stack_end */
@@ -103,8 +108,7 @@ strong_alias(__rtld_stack_end, __libc_stack_end) /* Exported version of __rtld_s
/* 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)
+ argv[1..argc-1] program args (pointers)
NULL
env[0...N] environment variables (pointers)
NULL
@@ -122,8 +126,9 @@ DL_START(unsigned long args)
struct elf_resolve *tpnt = &tpnt_tmp;
ElfW(auxv_t) auxvt[AT_EGID + 1];
ElfW(Dyn) *dpnt;
+ uint32_t *p32;
- /* WARNING! -- we cannot make _any_ funtion calls until we have
+ /* WARNING! -- we cannot make _any_ function calls until we have
* taken care of fixing up our own relocations. Making static
* inline calls is ok, but _no_ function calls. Not yet
* anyways. */
@@ -131,12 +136,12 @@ DL_START(unsigned long args)
/* First obtain the information on the stack that tells us more about
what binary is loaded, where it is loaded, etc, etc */
GET_ARGV(aux_dat, args);
- argc = *(aux_dat - 1);
+ argc = aux_dat[-1];
argv = (char **) aux_dat;
aux_dat += argc; /* Skip over the argv pointers */
aux_dat++; /* Skip over NULL at end of argv */
envp = (char **) aux_dat;
-#ifndef NO_EARLY_SEND_STDERR
+#if !defined(NO_EARLY_SEND_STDERR)
SEND_EARLY_STDERR_DEBUG("argc=");
SEND_NUMBER_STDERR_DEBUG(argc, 0);
SEND_EARLY_STDERR_DEBUG(" argv=");
@@ -164,11 +169,26 @@ DL_START(unsigned long args)
aux_dat += 2;
}
- /* locate the ELF header. We need this done as soon as possible
- * (esp since SEND_STDERR() needs this on some platforms... */
+ /*
+ * Locate the dynamic linker ELF header. We need this done as soon as
+ * possible (esp since SEND_STDERR() needs this on some platforms...
+ */
+
+#ifdef __LDSO_PRELINK_SUPPORT__
+ /*
+ * The `_begin' symbol created by the linker script points to ld.so ELF
+ * We use it if the kernel is not passing a valid address through the auxvt.
+ */
+
+ if (!auxvt[AT_BASE].a_un.a_val)
+ auxvt[AT_BASE].a_un.a_val = (ElfW(Addr)) &_begin;
+ /* Note: if the dynamic linker itself is prelinked, the load_addr is 0 */
+ DL_INIT_LOADADDR_BOOT(load_addr, elf_machine_load_address());
+#else
if (!auxvt[AT_BASE].a_un.a_val)
auxvt[AT_BASE].a_un.a_val = elf_machine_load_address();
DL_INIT_LOADADDR_BOOT(load_addr, auxvt[AT_BASE].a_un.a_val);
+#endif
header = (ElfW(Ehdr) *) auxvt[AT_BASE].a_un.a_val;
/* Check the ELF header to make sure everything looks ok. */
@@ -177,16 +197,14 @@ DL_START(unsigned long args)
/* Do not use an inline _dl_strncmp here or some arches
* will blow chunks, i.e. those that need to relocate all
* string constants... */
- || header->e_ident[EI_MAG0] != ELFMAG0
- || header->e_ident[EI_MAG1] != ELFMAG1
- || header->e_ident[EI_MAG2] != ELFMAG2
- || header->e_ident[EI_MAG3] != ELFMAG3)
- {
+ || *(p32 = (uint32_t*)&header->e_ident) != ELFMAG_U32
+ ) {
SEND_EARLY_STDERR("Invalid ELF header\n");
_dl_exit(0);
}
SEND_EARLY_STDERR_DEBUG("ELF header=");
- SEND_ADDRESS_STDERR_DEBUG(DL_LOADADDR_BASE(load_addr), 1);
+ SEND_ADDRESS_STDERR_DEBUG(
+ DL_LOADADDR_BASE(DL_GET_RUN_ADDR(load_addr, header)), 1);
/* Locate the global offset table. Since this code must be PIC
* we can take advantage of the magic offset register, if we
@@ -195,7 +213,7 @@ DL_START(unsigned long args)
DL_BOOT_COMPUTE_GOT(got);
/* Now, finally, fix up the location of the dynamic stuff */
- DL_BOOT_COMPUTE_DYN (dpnt, got, load_addr);
+ DL_BOOT_COMPUTE_DYN(dpnt, got, (DL_LOADADDR_TYPE)header);
SEND_EARLY_STDERR_DEBUG("First Dynamic section entry=");
SEND_ADDRESS_STDERR_DEBUG(dpnt, 1);
@@ -212,37 +230,42 @@ DL_START(unsigned long args)
_dl_parse_dynamic_info(dpnt, tpnt->dynamic_info, NULL, load_addr);
#endif
+ /*
+ * BIG ASSUMPTION: We assume that the dynamic loader does not
+ * have any TLS data itself. If this ever occurs
+ * more work than what is done below for the
+ * loader will have to happen.
+ */
+#if defined(USE_TLS) && USE_TLS
+ /* This was done by _dl_memset above. */
+ /* tpnt->l_tls_modid = 0; */
+# if NO_TLS_OFFSET != 0
+ tpnt->l_tls_offset = NO_TLS_OFFSET;
+# endif
+#endif
+
SEND_EARLY_STDERR_DEBUG("Done scanning DYNAMIC section\n");
#if defined(PERFORM_BOOTSTRAP_GOT)
-
SEND_EARLY_STDERR_DEBUG("About to do specific GOT bootstrap\n");
/* some arches (like MIPS) we have to tweak the GOT before relocations */
PERFORM_BOOTSTRAP_GOT(tpnt);
-
#endif
-#if !defined(PERFORM_BOOTSTRAP_GOT) || defined(__avr32__)
+#if !defined(PERFORM_BOOTSTRAP_GOT) || defined(__avr32__) || defined(__mips__)
/* OK, now do the relocations. We do not do a lazy binding here, so
that once we are done, we have considerably more flexibility. */
SEND_EARLY_STDERR_DEBUG("About to do library loader relocations\n");
{
- int goof, indx;
-#ifdef ELF_MACHINE_PLTREL_OVERLAP
+ int indx;
+#if defined(ELF_MACHINE_PLTREL_OVERLAP)
# define INDX_MAX 1
#else
# define INDX_MAX 2
#endif
- goof = 0;
for (indx = 0; indx < INDX_MAX; indx++) {
- unsigned int i;
- unsigned long *reloc_addr;
- unsigned long symbol_addr;
- int symtab_index;
- ElfW(Sym) *sym;
- ELF_RELOC *rpnt;
unsigned long rel_addr, rel_size;
ElfW(Word) relative_count = tpnt->dynamic_info[DT_RELCONT_IDX];
@@ -254,51 +277,65 @@ DL_START(unsigned long args)
if (!rel_addr)
continue;
- /* Now parse the relocation information */
- /* Since ldso is linked with -Bsymbolic, all relocs will be RELATIVE(for those archs that have
- RELATIVE relocs) which means that the for(..) loop below has nothing to do and can be deleted.
- Possibly one should add a HAVE_RELATIVE_RELOCS directive and #ifdef away some code. */
if (!indx && relative_count) {
rel_size -= relative_count * sizeof(ELF_RELOC);
- elf_machine_relative(load_addr, rel_addr, relative_count);
+#ifdef __LDSO_PRELINK_SUPPORT__
+ if (load_addr || !tpnt->dynamic_info[DT_GNU_PRELINKED_IDX])
+#endif
+ elf_machine_relative(load_addr, rel_addr, relative_count);
rel_addr += relative_count * sizeof(ELF_RELOC);
}
- rpnt = (ELF_RELOC *) rel_addr;
- for (i = 0; i < rel_size; i += sizeof(ELF_RELOC), rpnt++) {
- reloc_addr = (unsigned long *) DL_RELOC_ADDR(load_addr, (unsigned long)rpnt->r_offset);
- symtab_index = ELF_R_SYM(rpnt->r_info);
- symbol_addr = 0;
- sym = NULL;
- if (symtab_index) {
- char *strtab;
- ElfW(Sym) *symtab;
-
- symtab = (ElfW(Sym) *) tpnt->dynamic_info[DT_SYMTAB];
- strtab = (char *) tpnt->dynamic_info[DT_STRTAB];
- sym = &symtab[symtab_index];
- symbol_addr = (unsigned long) DL_RELOC_ADDR(load_addr, sym->st_value);
-
-#ifndef EARLY_STDERR_SPECIAL
- SEND_STDERR_DEBUG("relocating symbol: ");
- SEND_STDERR_DEBUG(strtab + sym->st_name);
- SEND_STDERR_DEBUG("\n");
+ /*
+ * Since ldso is linked with -Bsymbolic, all relocs should be RELATIVE. All archs
+ * that need bootstrap relocations need to define ARCH_NEEDS_BOOTSTRAP_RELOCS.
+ */
+#ifdef ARCH_NEEDS_BOOTSTRAP_RELOCS
+ {
+ ELF_RELOC *rpnt;
+ unsigned int i;
+ ElfW(Sym) *sym;
+ unsigned long symbol_addr;
+ int symtab_index;
+ unsigned long *reloc_addr;
+
+ /* Now parse the relocation information */
+ rpnt = (ELF_RELOC *) rel_addr;
+ for (i = 0; i < rel_size; i += sizeof(ELF_RELOC), rpnt++) {
+ reloc_addr = (unsigned long *) DL_RELOC_ADDR(load_addr, (unsigned long)rpnt->r_offset);
+ symtab_index = ELF_R_SYM(rpnt->r_info);
+ symbol_addr = 0;
+ sym = NULL;
+ if (symtab_index) {
+ char *strtab;
+ ElfW(Sym) *symtab;
+
+ symtab = (ElfW(Sym) *) tpnt->dynamic_info[DT_SYMTAB];
+ strtab = (char *) tpnt->dynamic_info[DT_STRTAB];
+ sym = &symtab[symtab_index];
+ symbol_addr = (unsigned long) DL_RELOC_ADDR(load_addr, sym->st_value);
+#if !defined(EARLY_STDERR_SPECIAL)
+ SEND_STDERR_DEBUG("relocating symbol: ");
+ SEND_STDERR_DEBUG(strtab + sym->st_name);
+ SEND_STDERR_DEBUG("\n");
#endif
- } else {
- SEND_STDERR_DEBUG("relocating unknown symbol\n");
+ } else {
+ SEND_STDERR_DEBUG("relocating unknown symbol\n");
+ }
+ /* Use this machine-specific macro to perform the actual relocation. */
+ PERFORM_BOOTSTRAP_RELOC(rpnt, reloc_addr, symbol_addr, load_addr, sym);
}
- /* Use this machine-specific macro to perform the actual relocation. */
- PERFORM_BOOTSTRAP_RELOC(rpnt, reloc_addr, symbol_addr, load_addr, sym);
}
- }
-
- if (goof) {
- _dl_exit(14);
+#else /* ARCH_NEEDS_BOOTSTRAP_RELOCS */
+ if (rel_size) {
+ SEND_EARLY_STDERR("Cannot continue, found non relative relocs during the bootstrap.\n");
+ _dl_exit(14);
+ }
+#endif
}
}
#endif
- /* Wahoo!!! */
SEND_STDERR_DEBUG("Done relocating ldso; we can now use globals and make function calls!\n");
/* Now we have done the mandatory linking of some things. We are now
@@ -308,16 +345,15 @@ DL_START(unsigned long args)
__rtld_stack_end = (void *)(argv - 1);
- _dl_get_ready_to_run(tpnt, load_addr, auxvt, envp, argv
- DL_GET_READY_TO_RUN_EXTRA_ARGS);
-
+ _dl_elf_main = (int (*)(int, char **, char **))
+ _dl_get_ready_to_run(tpnt, load_addr, auxvt, envp, argv
+ DL_GET_READY_TO_RUN_EXTRA_ARGS);
/* Transfer control to the application. */
SEND_STDERR_DEBUG("transfering control to application @ ");
- _dl_elf_main = (int (*)(int, char **, char **)) auxvt[AT_ENTRY].a_un.a_val;
SEND_ADDRESS_STDERR_DEBUG(_dl_elf_main, 1);
-#ifndef START
+#if !defined(START)
return _dl_elf_main;
#else
START();
diff --git a/ldso/ldso/dl-symbols.c b/ldso/ldso/dl-symbols.c
new file mode 100644
index 000000000..e5c00211a
--- /dev/null
+++ b/ldso/ldso/dl-symbols.c
@@ -0,0 +1,21 @@
+/*
+ * This contains all symbols shared between
+ * dynamic linker ld.so and into static libc
+ *
+ * Copyright (c) 2008 STMicroelectronics Ltd
+ * Author: Carmelo Amoroso <carmelo.amoroso@st.com>
+ *
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ *
+ */
+
+/*
+ * This is the start of the linked list that describes all of the files present
+ * in the system with pointers to all of the symbol, string, and hash tables,
+ * as well as all of the other good stuff in the binary.
+ */
+#include <ldso.h>
+
+struct elf_resolve *_dl_loaded_modules = NULL;
+
diff --git a/ldso/ldso/dl-tls.c b/ldso/ldso/dl-tls.c
new file mode 100644
index 000000000..ced20fa2b
--- /dev/null
+++ b/ldso/ldso/dl-tls.c
@@ -0,0 +1,1056 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Thread-local storage handling in the ELF dynamic linker.
+ *
+ * Copyright (C) 2005 by Steven J. Hill <sjhill@realitydiluted.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. The name of the above contributors may not be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <tls.h>
+#include <dl-tls.h>
+#include <ldsodefs.h>
+
+void *(*_dl_calloc_function) (size_t __nmemb, size_t __size) = NULL;
+void *(*_dl_realloc_function) (void *__ptr, size_t __size) = NULL;
+void *(*_dl_memalign_function) (size_t __boundary, size_t __size) = NULL;
+
+void (*_dl_free_function) (void *__ptr);
+void *_dl_memalign (size_t __boundary, size_t __size);
+struct link_map *_dl_update_slotinfo (unsigned long int req_modid);
+
+/* Round up N to the nearest multiple of P, where P is a power of 2
+ --- without using libgcc division routines. */
+#define roundup_pow2(n, p) (((n) + (p) - 1) & ~((p) - 1))
+
+void *
+_dl_calloc (size_t __nmemb, size_t __size)
+{
+ void *result;
+ size_t size = (__size * __nmemb);
+
+ if (_dl_calloc_function)
+ return (*_dl_calloc_function) (__nmemb, __size);
+
+ if ((result = _dl_malloc(size)) != NULL) {
+ _dl_memset(result, 0, size);
+ }
+
+ return result;
+}
+
+void *
+_dl_realloc (void * __ptr, size_t __size)
+{
+ if (_dl_realloc_function)
+ return (*_dl_realloc_function) (__ptr, __size);
+
+ _dl_debug_early("NOT IMPLEMENTED PROPERLY!!!\n");
+ return NULL;
+}
+
+/* The __tls_get_addr function has two basic forms which differ in the
+ arguments. The IA-64 form takes two parameters, the module ID and
+ offset. The form used, among others, on IA-32 takes a reference to
+ a special structure which contain the same information. The second
+ form seems to be more often used (in the moment) so we default to
+ it. Users of the IA-64 form have to provide adequate definitions
+ of the following macros. */
+#ifndef GET_ADDR_ARGS
+# define GET_ADDR_ARGS tls_index *ti
+#endif
+#ifndef GET_ADDR_MODULE
+# define GET_ADDR_MODULE ti->ti_module
+#endif
+#ifndef GET_ADDR_OFFSET
+# define GET_ADDR_OFFSET ti->ti_offset
+#endif
+
+/*
+ * Amount of excess space to allocate in the static TLS area
+ * to allow dynamic loading of modules defining IE-model TLS data.
+ */
+#define TLS_STATIC_SURPLUS 64 + DL_NNS * 100
+
+/* Value used for dtv entries for which the allocation is delayed. */
+#define TLS_DTV_UNALLOCATED ((void *) -1l)
+
+/*
+ * We are trying to perform a static TLS relocation in MAP, but it was
+ * dynamically loaded. This can only work if there is enough surplus in
+ * the static TLS area already allocated for each running thread. If this
+ * object's TLS segment is too big to fit, we fail. If it fits,
+ * we set MAP->l_tls_offset and return.
+ */
+int
+internal_function
+_dl_try_allocate_static_tls (struct link_map* map)
+{
+ /* If the alignment requirements are too high fail. */
+ if (map->l_tls_align > _dl_tls_static_align)
+ {
+fail:
+ return -1;
+ }
+
+# ifdef TLS_TCB_AT_TP
+ size_t freebytes;
+ size_t n;
+ size_t blsize;
+
+ freebytes = _dl_tls_static_size - _dl_tls_static_used - TLS_TCB_SIZE;
+
+ blsize = map->l_tls_blocksize + map->l_tls_firstbyte_offset;
+ if (freebytes < blsize)
+ goto fail;
+
+ n = (freebytes - blsize) & ~(map->l_tls_align - 1);
+
+ size_t offset = _dl_tls_static_used + (freebytes - n
+ - map->l_tls_firstbyte_offset);
+
+ map->l_tls_offset = _dl_tls_static_used = offset;
+# elif defined(TLS_DTV_AT_TP)
+ size_t used;
+ size_t check;
+
+ size_t offset = roundup_pow2 (_dl_tls_static_used, map->l_tls_align);
+ used = offset + map->l_tls_blocksize;
+ check = used;
+
+ /* dl_tls_static_used includes the TCB at the beginning. */
+ if (check > _dl_tls_static_size)
+ goto fail;
+
+ map->l_tls_offset = offset;
+ _dl_tls_static_used = used;
+# else
+# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
+# endif
+
+ /*
+ * If the object is not yet relocated we cannot initialize the
+ * static TLS region. Delay it.
+ */
+ if (((struct elf_resolve *) map)->init_flag & RELOCS_DONE)
+ {
+#ifdef SHARED
+ /*
+ * Update the slot information data for at least the generation of
+ * the DSO we are allocating data for.
+ */
+ if (__builtin_expect (THREAD_DTV()[0].counter != _dl_tls_generation, 0))
+ (void) _dl_update_slotinfo (map->l_tls_modid);
+#endif
+ _dl_init_static_tls (map);
+ }
+ else
+ map->l_need_tls_init = 1;
+
+ return 0;
+}
+
+/*
+ * This function intentionally does not return any value but signals error
+ * directly, as static TLS should be rare and code handling it should
+ * not be inlined as much as possible.
+ */
+void
+internal_function __attribute_noinline__
+_dl_allocate_static_tls (struct link_map *map)
+{
+ if (_dl_try_allocate_static_tls (map)) {
+ _dl_dprintf(2, "cannot allocate memory in static TLS block");
+ _dl_exit(30);
+ }
+}
+
+#ifdef SHARED
+/* Initialize static TLS area and DTV for current (only) thread.
+ libpthread implementations should provide their own hook
+ to handle all threads. */
+void
+attribute_hidden __attribute_noinline__
+_dl_nothread_init_static_tls (struct link_map *map)
+{
+# ifdef TLS_TCB_AT_TP
+ void *dest = (char *) THREAD_SELF - map->l_tls_offset;
+# elif defined(TLS_DTV_AT_TP)
+ void *dest = (char *) THREAD_SELF + map->l_tls_offset + TLS_PRE_TCB_SIZE;
+# else
+# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
+# endif
+
+ /* Fill in the DTV slot so that a later LD/GD access will find it. */
+ dtv_t *dtv = THREAD_DTV ();
+ if (!(map->l_tls_modid <= dtv[-1].counter)) {
+ _dl_dprintf(2, "map->l_tls_modid <= dtv[-1].counter FAILED!\n");
+ _dl_exit(30);
+ }
+ dtv[map->l_tls_modid].pointer.val = dest;
+ dtv[map->l_tls_modid].pointer.is_static = true;
+
+ /* Initialize the memory. */
+ _dl_memcpy(dest, map->l_tls_initimage, map->l_tls_initimage_size);
+ _dl_memset((dest + map->l_tls_initimage_size), '\0',
+ map->l_tls_blocksize - map->l_tls_initimage_size);
+}
+#endif
+
+/* Taken from glibc/sysdeps/generic/dl-tls.c */
+static void
+oom (void)
+{
+ _dl_debug_early("cannot allocate thread-local memory: ABORT\n");
+ _dl_exit(30);
+}
+
+size_t
+internal_function
+_dl_next_tls_modid (void)
+{
+ size_t result;
+
+ if (__builtin_expect (_dl_tls_dtv_gaps, false))
+ {
+ size_t disp = 0;
+ struct dtv_slotinfo_list *runp = _dl_tls_dtv_slotinfo_list;
+
+ /* Note that this branch will never be executed during program
+ start since there are no gaps at that time. Therefore it
+ does not matter that the dl_tls_dtv_slotinfo is not allocated
+ yet when the function is called for the first times.
+
+ NB: the offset +1 is due to the fact that DTV[0] is used
+ for something else. */
+ result = _dl_tls_static_nelem + 1;
+ if (result <= _dl_tls_max_dtv_idx)
+ do
+ {
+ while (result - disp < runp->len)
+ {
+ if (runp->slotinfo[result - disp].map == NULL)
+ break;
+
+ ++result;
+ _dl_assert (result <= _dl_tls_max_dtv_idx + 1);
+ }
+
+ if (result - disp < runp->len)
+ break;
+
+ disp += runp->len;
+ }
+ while ((runp = runp->next) != NULL);
+
+ if (result > _dl_tls_max_dtv_idx)
+ {
+ /* The new index must indeed be exactly one higher than the
+ previous high. */
+ _dl_assert (result == _dl_tls_max_dtv_idx + 1);
+ /* There is no gap anymore. */
+ _dl_tls_dtv_gaps = false;
+
+ goto nogaps;
+ }
+ }
+ else
+ {
+ /* No gaps, allocate a new entry. */
+ nogaps:
+
+ result = ++_dl_tls_max_dtv_idx;
+ }
+
+ return result;
+}
+
+void
+internal_function
+_dl_determine_tlsoffset (void)
+{
+ size_t max_align = TLS_TCB_ALIGN;
+ size_t freetop = 0;
+ size_t freebottom = 0;
+
+ /* The first element of the dtv slot info list is allocated. */
+ _dl_assert (_dl_tls_dtv_slotinfo_list != NULL);
+ /* There is at this point only one element in the
+ dl_tls_dtv_slotinfo_list list. */
+ _dl_assert (_dl_tls_dtv_slotinfo_list->next == NULL);
+
+ struct dtv_slotinfo *slotinfo = _dl_tls_dtv_slotinfo_list->slotinfo;
+
+ /* Determining the offset of the various parts of the static TLS
+ block has several dependencies. In addition we have to work
+ around bugs in some toolchains.
+
+ Each TLS block from the objects available at link time has a size
+ and an alignment requirement. The GNU ld computes the alignment
+ requirements for the data at the positions *in the file*, though.
+ I.e, it is not simply possible to allocate a block with the size
+ of the TLS program header entry. The data is layed out assuming
+ that the first byte of the TLS block fulfills
+
+ p_vaddr mod p_align == &TLS_BLOCK mod p_align
+
+ This means we have to add artificial padding at the beginning of
+ the TLS block. These bytes are never used for the TLS data in
+ this module but the first byte allocated must be aligned
+ according to mod p_align == 0 so that the first byte of the TLS
+ block is aligned according to p_vaddr mod p_align. This is ugly
+ and the linker can help by computing the offsets in the TLS block
+ assuming the first byte of the TLS block is aligned according to
+ p_align.
+
+ The extra space which might be allocated before the first byte of
+ the TLS block need not go unused. The code below tries to use
+ that memory for the next TLS block. This can work if the total
+ memory requirement for the next TLS block is smaller than the
+ gap. */
+
+# ifdef TLS_TCB_AT_TP
+ /* We simply start with zero. */
+ size_t cnt, offset = 0;
+
+ for (cnt = 1; slotinfo[cnt].map != NULL; ++cnt)
+ {
+ _dl_assert (cnt < _dl_tls_dtv_slotinfo_list->len);
+
+ size_t firstbyte = (-slotinfo[cnt].map->l_tls_firstbyte_offset
+ & (slotinfo[cnt].map->l_tls_align - 1));
+ size_t off;
+ max_align = MAX (max_align, slotinfo[cnt].map->l_tls_align);
+
+ if (freebottom - freetop >= slotinfo[cnt].map->l_tls_blocksize)
+ {
+ off = roundup_pow2 (freetop + slotinfo[cnt].map->l_tls_blocksize
+ - firstbyte, slotinfo[cnt].map->l_tls_align)
+ + firstbyte;
+ if (off <= freebottom)
+ {
+ freetop = off;
+
+ /* XXX For some architectures we perhaps should store the
+ negative offset. */
+ slotinfo[cnt].map->l_tls_offset = off;
+ continue;
+ }
+ }
+
+ off = roundup_pow2 (offset + slotinfo[cnt].map->l_tls_blocksize
+ - firstbyte, slotinfo[cnt].map->l_tls_align)
+ + firstbyte;
+ if (off > offset + slotinfo[cnt].map->l_tls_blocksize
+ + (freebottom - freetop))
+ {
+ freetop = offset;
+ freebottom = off - slotinfo[cnt].map->l_tls_blocksize;
+ }
+ offset = off;
+
+ /* XXX For some architectures we perhaps should store the
+ negative offset. */
+ slotinfo[cnt].map->l_tls_offset = off;
+ }
+
+ _dl_tls_static_used = offset;
+ _dl_tls_static_size = (roundup_pow2 (offset + TLS_STATIC_SURPLUS, max_align)
+ + TLS_TCB_SIZE);
+# elif defined(TLS_DTV_AT_TP)
+ /* The TLS blocks start right after the TCB. */
+ size_t offset = TLS_TCB_SIZE;
+ size_t cnt;
+
+ for (cnt = 1; slotinfo[cnt].map != NULL; ++cnt)
+ {
+ _dl_assert (cnt < _dl_tls_dtv_slotinfo_list->len);
+
+ size_t firstbyte = (-slotinfo[cnt].map->l_tls_firstbyte_offset
+ & (slotinfo[cnt].map->l_tls_align - 1));
+ size_t off;
+ max_align = MAX (max_align, slotinfo[cnt].map->l_tls_align);
+
+ if (slotinfo[cnt].map->l_tls_blocksize <= freetop - freebottom)
+ {
+ off = roundup_pow2 (freebottom, slotinfo[cnt].map->l_tls_align);
+ if (off - freebottom < firstbyte)
+ off += slotinfo[cnt].map->l_tls_align;
+ if (off + slotinfo[cnt].map->l_tls_blocksize - firstbyte <= freetop)
+ {
+ slotinfo[cnt].map->l_tls_offset = off - firstbyte;
+ freebottom = (off + slotinfo[cnt].map->l_tls_blocksize
+ - firstbyte);
+ continue;
+ }
+ }
+
+ off = roundup_pow2 (offset, slotinfo[cnt].map->l_tls_align);
+ if (off - offset < firstbyte)
+ off += slotinfo[cnt].map->l_tls_align;
+
+ slotinfo[cnt].map->l_tls_offset = off - firstbyte;
+ if (off - firstbyte - offset > freetop - freebottom)
+ {
+ freebottom = offset;
+ freetop = off - firstbyte;
+ }
+
+ offset = off + slotinfo[cnt].map->l_tls_blocksize - firstbyte;
+ }
+
+ _dl_tls_static_used = offset;
+ _dl_tls_static_size = roundup_pow2 (offset + TLS_STATIC_SURPLUS,
+ TLS_TCB_ALIGN);
+# else
+# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
+# endif
+
+ /* The alignment requirement for the static TLS block. */
+ _dl_tls_static_align = max_align;
+}
+
+/* This is called only when the data structure setup was skipped at startup,
+ when there was no need for it then. Now we have dynamically loaded
+ something needing TLS, or libpthread needs it. */
+rtld_hidden_proto(_dl_tls_setup)
+int
+internal_function
+_dl_tls_setup (void)
+{
+ _dl_assert (_dl_tls_dtv_slotinfo_list == NULL);
+ _dl_assert (_dl_tls_max_dtv_idx == 0);
+
+ const size_t nelem = 2 + TLS_SLOTINFO_SURPLUS;
+
+ _dl_tls_dtv_slotinfo_list
+ = _dl_calloc (1, (sizeof (struct dtv_slotinfo_list)
+ + nelem * sizeof (struct dtv_slotinfo)));
+ if (_dl_tls_dtv_slotinfo_list == NULL)
+ return -1;
+
+ _dl_tls_dtv_slotinfo_list->len = nelem;
+
+ /* Number of elements in the static TLS block. It can't be zero
+ because of various assumptions. The one element is null. */
+ _dl_tls_static_nelem = _dl_tls_max_dtv_idx = 1;
+
+ /* This initializes more variables for us. */
+ _dl_determine_tlsoffset ();
+
+ return 0;
+}
+rtld_hidden_def (_dl_tls_setup)
+
+static void *
+internal_function
+allocate_dtv (void *result)
+{
+ dtv_t *dtv;
+ size_t dtv_length;
+
+ /* We allocate a few more elements in the dtv than are needed for the
+ initial set of modules. This should avoid in most cases expansions
+ of the dtv. */
+ dtv_length = _dl_tls_max_dtv_idx + DTV_SURPLUS;
+ dtv = _dl_calloc (dtv_length + 2, sizeof (dtv_t));
+ if (dtv != NULL)
+ {
+ /* This is the initial length of the dtv. */
+ dtv[0].counter = dtv_length;
+
+ /* The rest of the dtv (including the generation counter) is
+ Initialize with zero to indicate nothing there. */
+
+ /* Add the dtv to the thread data structures. */
+ INSTALL_DTV (result, dtv);
+ }
+ else
+ result = NULL;
+
+ return result;
+}
+
+/* Get size and alignment requirements of the static TLS block. */
+void
+internal_function
+_dl_get_tls_static_info (size_t *sizep, size_t *alignp)
+{
+ *sizep = _dl_tls_static_size;
+ *alignp = _dl_tls_static_align;
+}
+
+void *
+internal_function
+_dl_allocate_tls_storage (void)
+{
+ void *result;
+ size_t size = _dl_tls_static_size;
+
+# if defined(TLS_DTV_AT_TP)
+ /* Memory layout is:
+ [ TLS_PRE_TCB_SIZE ] [ TLS_TCB_SIZE ] [ TLS blocks ]
+ ^ This should be returned. */
+ size += (TLS_PRE_TCB_SIZE + _dl_tls_static_align - 1)
+ & ~(_dl_tls_static_align - 1);
+# endif
+
+ /* Allocate a correctly aligned chunk of memory. */
+ result = _dl_memalign (_dl_tls_static_align, size);
+ if (__builtin_expect (result != NULL, 1))
+ {
+ /* Allocate the DTV. */
+ void *allocated = result;
+
+# ifdef TLS_TCB_AT_TP
+ /* The TCB follows the TLS blocks. */
+ result = (char *) result + size - TLS_TCB_SIZE;
+
+ /* Clear the TCB data structure. We can't ask the caller (i.e.
+ libpthread) to do it, because we will initialize the DTV et al. */
+ _dl_memset (result, '\0', TLS_TCB_SIZE);
+# elif defined(TLS_DTV_AT_TP)
+ result = (char *) result + size - _dl_tls_static_size;
+
+ /* Clear the TCB data structure and TLS_PRE_TCB_SIZE bytes before it.
+ We can't ask the caller (i.e. libpthread) to do it, because we will
+ initialize the DTV et al. */
+ _dl_memset ((char *) result - TLS_PRE_TCB_SIZE, '\0',
+ TLS_PRE_TCB_SIZE + TLS_TCB_SIZE);
+# endif
+
+ result = allocate_dtv (result);
+ if (result == NULL)
+ _dl_free (allocated);
+ }
+
+ return result;
+}
+
+void *
+internal_function
+_dl_allocate_tls_init (void *result)
+{
+ if (result == NULL)
+ /* The memory allocation failed. */
+ return NULL;
+
+ dtv_t *dtv = GET_DTV (result);
+ struct dtv_slotinfo_list *listp;
+ size_t total = 0;
+ size_t maxgen = 0;
+
+ /* We have to prepare the dtv for all currently loaded modules using
+ TLS. For those which are dynamically loaded we add the values
+ indicating deferred allocation. */
+ listp = _dl_tls_dtv_slotinfo_list;
+ while (1)
+ {
+ size_t cnt;
+
+ for (cnt = total == 0 ? 1 : 0; cnt < listp->len; ++cnt)
+ {
+ struct link_map *map;
+ void *dest;
+
+ /* Check for the total number of used slots. */
+ if (total + cnt > _dl_tls_max_dtv_idx)
+ break;
+
+ map = listp->slotinfo[cnt].map;
+ if (map == NULL)
+ /* Unused entry. */
+ continue;
+
+ /* Keep track of the maximum generation number. This might
+ not be the generation counter. */
+ maxgen = MAX (maxgen, listp->slotinfo[cnt].gen);
+
+ if (map->l_tls_offset == NO_TLS_OFFSET)
+ {
+ /* For dynamically loaded modules we simply store
+ the value indicating deferred allocation. */
+ dtv[map->l_tls_modid].pointer.val = TLS_DTV_UNALLOCATED;
+ dtv[map->l_tls_modid].pointer.is_static = false;
+ continue;
+ }
+
+ _dl_assert (map->l_tls_modid == cnt);
+ _dl_assert (map->l_tls_blocksize >= map->l_tls_initimage_size);
+# ifdef TLS_TCB_AT_TP
+ _dl_assert ((size_t) map->l_tls_offset >= map->l_tls_blocksize);
+ dest = (char *) result - map->l_tls_offset;
+# elif defined(TLS_DTV_AT_TP)
+ dest = (char *) result + map->l_tls_offset;
+# else
+# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
+# endif
+
+ /* Copy the initialization image and clear the BSS part. */
+ dtv[map->l_tls_modid].pointer.val = dest;
+ dtv[map->l_tls_modid].pointer.is_static = true;
+ _dl_memcpy(dest, map->l_tls_initimage, map->l_tls_initimage_size);
+ _dl_memset((dest + map->l_tls_initimage_size), '\0',
+ map->l_tls_blocksize - map->l_tls_initimage_size);
+
+ }
+
+ total += cnt;
+ if (total >= _dl_tls_max_dtv_idx)
+ break;
+
+ listp = listp->next;
+ _dl_assert (listp != NULL);
+ }
+
+ /* The DTV version is up-to-date now. */
+ dtv[0].counter = maxgen;
+
+ return result;
+}
+
+void *
+internal_function
+_dl_allocate_tls (void *mem)
+{
+ return _dl_allocate_tls_init (mem == NULL
+ ? _dl_allocate_tls_storage ()
+ : allocate_dtv (mem));
+}
+
+void
+internal_function
+_dl_deallocate_tls (void *tcb, bool dealloc_tcb)
+{
+ dtv_t *dtv = GET_DTV (tcb);
+ size_t cnt;
+
+ /* We need to free the memory allocated for non-static TLS. */
+ for (cnt = 0; cnt < dtv[-1].counter; ++cnt)
+ if (! dtv[1 + cnt].pointer.is_static
+ && dtv[1 + cnt].pointer.val != TLS_DTV_UNALLOCATED)
+ _dl_free (dtv[1 + cnt].pointer.val);
+
+ /* The array starts with dtv[-1]. */
+ if (dtv != _dl_initial_dtv)
+ _dl_free (dtv - 1);
+
+ if (dealloc_tcb)
+ {
+# ifdef TLS_TCB_AT_TP
+ /* The TCB follows the TLS blocks. Back up to free the whole block. */
+ tcb -= _dl_tls_static_size - TLS_TCB_SIZE;
+# elif defined(TLS_DTV_AT_TP)
+ /* Back up the TLS_PRE_TCB_SIZE bytes. */
+ tcb -= (TLS_PRE_TCB_SIZE + _dl_tls_static_align - 1)
+ & ~(_dl_tls_static_align - 1);
+# endif
+ _dl_free (tcb);
+ }
+}
+
+static void *
+allocate_and_init (struct link_map *map)
+{
+ void *newp;
+
+ newp = _dl_memalign (map->l_tls_align, map->l_tls_blocksize);
+ if (newp == NULL)
+ {
+ _dl_dprintf(2, "%s:%d: Out of memory!!!\n", __func__, __LINE__);
+ _dl_exit(1);
+ }
+
+ /* Initialize the memory. */
+ _dl_memcpy (newp, map->l_tls_initimage, map->l_tls_initimage_size);
+ _dl_memset ((newp + map->l_tls_initimage_size), '\0',
+ map->l_tls_blocksize - map->l_tls_initimage_size);
+
+ return newp;
+}
+
+struct link_map *
+_dl_update_slotinfo (unsigned long int req_modid)
+{
+ struct link_map *the_map = NULL;
+ dtv_t *dtv = THREAD_DTV ();
+
+ /* The global dl_tls_dtv_slotinfo array contains for each module
+ index the generation counter current when the entry was created.
+ This array never shrinks so that all module indices which were
+ valid at some time can be used to access it. Before the first
+ use of a new module index in this function the array was extended
+ appropriately. Access also does not have to be guarded against
+ modifications of the array. It is assumed that pointer-size
+ values can be read atomically even in SMP environments. It is
+ possible that other threads at the same time dynamically load
+ code and therefore add to the slotinfo list. This is a problem
+ since we must not pick up any information about incomplete work.
+ The solution to this is to ignore all dtv slots which were
+ created after the one we are currently interested. We know that
+ dynamic loading for this module is completed and this is the last
+ load operation we know finished. */
+ unsigned long int idx = req_modid;
+ struct dtv_slotinfo_list *listp = _dl_tls_dtv_slotinfo_list;
+
+ _dl_debug_early ("Updating slotinfo for module %d\n", req_modid);
+
+ while (idx >= listp->len)
+ {
+ idx -= listp->len;
+ listp = listp->next;
+ }
+
+ if (dtv[0].counter < listp->slotinfo[idx].gen)
+ {
+ /* The generation counter for the slot is higher than what the
+ current dtv implements. We have to update the whole dtv but
+ only those entries with a generation counter <= the one for
+ the entry we need. */
+ size_t new_gen = listp->slotinfo[idx].gen;
+ size_t total = 0;
+
+ /* We have to look through the entire dtv slotinfo list. */
+ listp = _dl_tls_dtv_slotinfo_list;
+ do
+ {
+ size_t cnt;
+
+ for (cnt = total == 0 ? 1 : 0; cnt < listp->len; ++cnt)
+ {
+ size_t gen = listp->slotinfo[cnt].gen;
+
+ if (gen > new_gen)
+ /* This is a slot for a generation younger than the
+ one we are handling now. It might be incompletely
+ set up so ignore it. */
+ continue;
+
+ /* If the entry is older than the current dtv layout we
+ know we don't have to handle it. */
+ if (gen <= dtv[0].counter)
+ continue;
+
+ /* If there is no map this means the entry is empty. */
+ struct link_map *map = listp->slotinfo[cnt].map;
+ if (map == NULL)
+ {
+ /* If this modid was used at some point the memory
+ might still be allocated. */
+ if (! dtv[total + cnt].pointer.is_static
+ && dtv[total + cnt].pointer.val != TLS_DTV_UNALLOCATED)
+ {
+ _dl_free (dtv[total + cnt].pointer.val);
+ dtv[total + cnt].pointer.val = TLS_DTV_UNALLOCATED;
+ }
+
+ continue;
+ }
+
+ /* Check whether the current dtv array is large enough. */
+ size_t modid = map->l_tls_modid;
+ _dl_assert (total + cnt == modid);
+ if (dtv[-1].counter < modid)
+ {
+ /* Reallocate the dtv. */
+ dtv_t *newp;
+ size_t newsize = _dl_tls_max_dtv_idx + DTV_SURPLUS;
+ size_t oldsize = dtv[-1].counter;
+
+ _dl_assert (map->l_tls_modid <= newsize);
+
+ if (dtv == _dl_initial_dtv)
+ {
+ /* This is the initial dtv that was allocated
+ during rtld startup using the dl-minimal.c
+ malloc instead of the real malloc. We can't
+ free it, we have to abandon the old storage. */
+
+ newp = _dl_malloc ((2 + newsize) * sizeof (dtv_t));
+ if (newp == NULL)
+ oom ();
+ _dl_memcpy (newp, &dtv[-1], oldsize * sizeof (dtv_t));
+ }
+ else
+ {
+ newp = _dl_realloc (&dtv[-1],
+ (2 + newsize) * sizeof (dtv_t));
+ if (newp == NULL)
+ oom ();
+ }
+
+ newp[0].counter = newsize;
+
+ /* Clear the newly allocated part. */
+ _dl_memset (newp + 2 + oldsize, '\0',
+ (newsize - oldsize) * sizeof (dtv_t));
+
+ /* Point dtv to the generation counter. */
+ dtv = &newp[1];
+
+ /* Install this new dtv in the thread data
+ structures. */
+ INSTALL_NEW_DTV (dtv);
+ }
+
+ /* If there is currently memory allocate for this
+ dtv entry free it. */
+ /* XXX Ideally we will at some point create a memory
+ pool. */
+ if (! dtv[modid].pointer.is_static
+ && dtv[modid].pointer.val != TLS_DTV_UNALLOCATED)
+ /* Note that free is called for NULL is well. We
+ deallocate even if it is this dtv entry we are
+ supposed to load. The reason is that we call
+ memalign and not malloc. */
+ _dl_free (dtv[modid].pointer.val);
+
+ /* This module is loaded dynamically- We defer memory
+ allocation. */
+ dtv[modid].pointer.is_static = false;
+ dtv[modid].pointer.val = TLS_DTV_UNALLOCATED;
+
+ if (modid == req_modid)
+ the_map = map;
+ }
+
+ total += listp->len;
+ }
+ while ((listp = listp->next) != NULL);
+
+ /* This will be the new maximum generation counter. */
+ dtv[0].counter = new_gen;
+ }
+
+ return the_map;
+}
+
+
+/* The generic dynamic and local dynamic model cannot be used in
+ statically linked applications. */
+void *
+__tls_get_addr (GET_ADDR_ARGS)
+{
+ dtv_t *dtv = THREAD_DTV ();
+ struct link_map *the_map = NULL;
+ void *p;
+
+ if (__builtin_expect (dtv[0].counter != _dl_tls_generation, 0))
+ {
+ the_map = _dl_update_slotinfo (GET_ADDR_MODULE);
+ dtv = THREAD_DTV ();
+ }
+
+ p = dtv[GET_ADDR_MODULE].pointer.val;
+
+ if (__builtin_expect (p == TLS_DTV_UNALLOCATED, 0))
+ {
+ /* The allocation was deferred. Do it now. */
+ if (the_map == NULL)
+ {
+ /* Find the link map for this module. */
+ size_t idx = GET_ADDR_MODULE;
+ struct dtv_slotinfo_list *listp = _dl_tls_dtv_slotinfo_list;
+
+ while (idx >= listp->len)
+ {
+ idx -= listp->len;
+ listp = listp->next;
+ }
+
+ the_map = listp->slotinfo[idx].map;
+ }
+
+ p = dtv[GET_ADDR_MODULE].pointer.val = allocate_and_init (the_map);
+ dtv[GET_ADDR_MODULE].pointer.is_static = false;
+ }
+
+ return (char *) p + GET_ADDR_OFFSET;
+}
+
+void
+_dl_add_to_slotinfo (struct link_map *l)
+{
+ /* Now that we know the object is loaded successfully add
+ modules containing TLS data to the dtv info table. We
+ might have to increase its size. */
+ struct dtv_slotinfo_list *listp;
+ struct dtv_slotinfo_list *prevp;
+ size_t idx = l->l_tls_modid;
+
+ _dl_debug_early("Adding to slotinfo for %s\n", l->l_name);
+
+ /* Find the place in the dtv slotinfo list. */
+ listp = _dl_tls_dtv_slotinfo_list;
+ prevp = NULL; /* Needed to shut up gcc. */
+ do
+ {
+ /* Does it fit in the array of this list element? */
+ if (idx < listp->len)
+ break;
+ idx -= listp->len;
+ prevp = listp;
+ listp = listp->next;
+ }
+ while (listp != NULL);
+
+ if (listp == NULL)
+ {
+ /* When we come here it means we have to add a new element
+ to the slotinfo list. And the new module must be in
+ the first slot. */
+ _dl_assert (idx == 0);
+
+ listp = prevp->next = (struct dtv_slotinfo_list *)
+ _dl_malloc (sizeof (struct dtv_slotinfo_list)
+ + TLS_SLOTINFO_SURPLUS * sizeof (struct dtv_slotinfo));
+ if (listp == NULL)
+ {
+ /* We ran out of memory. We will simply fail this
+ call but don't undo anything we did so far. The
+ application will crash or be terminated anyway very
+ soon. */
+
+ /* We have to do this since some entries in the dtv
+ slotinfo array might already point to this
+ generation. */
+ ++_dl_tls_generation;
+
+ _dl_dprintf(2, "cannot create TLS data structures: ABORT\n");
+ _dl_exit (127);
+ }
+
+ listp->len = TLS_SLOTINFO_SURPLUS;
+ listp->next = NULL;
+ _dl_memset (listp->slotinfo, '\0',
+ TLS_SLOTINFO_SURPLUS * sizeof (struct dtv_slotinfo));
+ }
+
+ /* Add the information into the slotinfo data structure. */
+ listp->slotinfo[idx].map = l;
+ listp->slotinfo[idx].gen = _dl_tls_generation + 1;
+ /* ??? ideally this would be done once per call to dlopen. However there's
+ no easy way to indicate whether a library used TLS, so do it here
+ instead. */
+ /* Bump the TLS generation number. */
+ _dl_tls_generation++;
+}
+
+/* Taken from glibc/elf/rtld.c */
+static bool tls_init_tp_called;
+
+/* _dl_error_catch_tsd points to this for the single-threaded case.
+ It's reset by the thread library for multithreaded programs. */
+void ** __attribute__ ((const))
+_dl_initial_error_catch_tsd (void)
+{
+ static
+#if 0 /* def ARCH_NEEDS_BOOTSTRAP_RELOCS */
+ /* If we have to do bootstrap relocs anyway we might as well */
+ __thread
+# endif
+ void *__tsd_data;
+ return &__tsd_data;
+}
+
+#ifdef SHARED
+void*
+internal_function
+init_tls (void);
+
+rtld_hidden_proto(init_tls)
+void *
+internal_function
+init_tls (void)
+{
+ /* Number of elements in the static TLS block. */
+ _dl_tls_static_nelem = _dl_tls_max_dtv_idx;
+
+ /* Do not do this twice. The audit interface might have required
+ the DTV interfaces to be set up early. */
+ if (_dl_initial_dtv != NULL)
+ return NULL;
+
+ /* Allocate the array which contains the information about the
+ dtv slots. We allocate a few entries more than needed to
+ avoid the need for reallocation. */
+ size_t nelem = _dl_tls_max_dtv_idx + 1 + TLS_SLOTINFO_SURPLUS;
+
+ /* Allocate. */
+ _dl_assert (_dl_tls_dtv_slotinfo_list == NULL);
+ _dl_tls_dtv_slotinfo_list = (struct dtv_slotinfo_list *)
+ _dl_calloc (sizeof (struct dtv_slotinfo_list)
+ + nelem * sizeof (struct dtv_slotinfo), 1);
+ /* No need to check the return value. If memory allocation failed
+ the program would have been terminated. */
+
+ struct dtv_slotinfo *slotinfo = _dl_tls_dtv_slotinfo_list->slotinfo;
+ _dl_tls_dtv_slotinfo_list->len = nelem;
+ _dl_tls_dtv_slotinfo_list->next = NULL;
+
+ /* Fill in the information from the loaded modules. No namespace
+ but the base one can be filled at this time. */
+ int i = 0;
+ struct link_map *l;
+ for (l = (struct link_map *) _dl_loaded_modules; l != NULL; l = l->l_next)
+ if (l->l_tls_blocksize != 0)
+ {
+ /* This is a module with TLS data. Store the map reference.
+ The generation counter is zero. */
+
+ /* Skeep slot[0]: it will be never used */
+ slotinfo[++i].map = l;
+ }
+ _dl_assert (i == _dl_tls_max_dtv_idx);
+
+ /* Compute the TLS offsets for the various blocks. */
+ _dl_determine_tlsoffset ();
+
+ /* Construct the static TLS block and the dtv for the initial
+ thread. For some platforms this will include allocating memory
+ for the thread descriptor. The memory for the TLS block will
+ never be freed. It should be allocated accordingly. The dtv
+ array can be changed if dynamic loading requires it. */
+ void *tcbp = _dl_allocate_tls_storage ();
+ if (tcbp == NULL) {
+ _dl_debug_early("\ncannot allocate TLS data structures for initial thread");
+ _dl_exit(30);
+ }
+
+ /* Store for detection of the special case by __tls_get_addr
+ so it knows not to pass this dtv to the normal realloc. */
+ _dl_initial_dtv = GET_DTV (tcbp);
+
+ /* And finally install it for the main thread. If ld.so itself uses
+ TLS we know the thread pointer was initialized earlier. */
+ const char *lossage = (char *)TLS_INIT_TP (tcbp, USE___THREAD);
+ if(__builtin_expect (lossage != NULL, 0)) {
+ _dl_debug_early("cannot set up thread-local storage: %s\n", lossage);
+ _dl_exit(30);
+ }
+ tls_init_tp_called = true;
+
+ return tcbp;
+}
+rtld_hidden_def (init_tls)
+#endif
+
diff --git a/ldso/ldso/fdpic/dl-inlines.h b/ldso/ldso/fdpic/dl-inlines.h
new file mode 100644
index 000000000..a9bfc9311
--- /dev/null
+++ b/ldso/ldso/fdpic/dl-inlines.h
@@ -0,0 +1,228 @@
+/* Copyright (C) 2003, 2004 Red Hat, Inc.
+ * Contributed by Alexandre Oliva <aoliva@redhat.com>
+ * Copyright (C) 2006-2011 Analog Devices, Inc.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <inline-hashtab.h>
+
+/* Initialize a DL_LOADADDR_TYPE given a got pointer and a complete load map. */
+static __always_inline void
+__dl_init_loadaddr_map(struct elf32_fdpic_loadaddr *loadaddr, Elf32_Addr dl_boot_got_pointer,
+ struct elf32_fdpic_loadmap *map)
+{
+ if (map->version != 0) {
+ SEND_EARLY_STDERR("Invalid loadmap version number\n");
+ _dl_exit(-1);
+ }
+ if (map->nsegs == 0) {
+ SEND_EARLY_STDERR("Invalid segment count in loadmap\n");
+ _dl_exit(-1);
+ }
+ loadaddr->got_value = (void *)dl_boot_got_pointer;
+ loadaddr->map = map;
+}
+
+/*
+ * Figure out how many LOAD segments there are in the given headers,
+ * and allocate a block for the load map big enough for them.
+ * got_value will be properly initialized later on, with INIT_GOT.
+ */
+static __always_inline int
+__dl_init_loadaddr(struct elf32_fdpic_loadaddr *loadaddr, Elf32_Phdr *ppnt,
+ int pcnt)
+{
+ int count = 0, i;
+ size_t size;
+
+ for (i = 0; i < pcnt; i++)
+ if (ppnt[i].p_type == PT_LOAD)
+ count++;
+
+ loadaddr->got_value = 0;
+
+ size = sizeof(struct elf32_fdpic_loadmap) +
+ (sizeof(struct elf32_fdpic_loadseg) * count);
+ loadaddr->map = _dl_malloc(size);
+ if (!loadaddr->map)
+ _dl_exit(-1);
+
+ loadaddr->map->version = 0;
+ loadaddr->map->nsegs = 0;
+
+ return count;
+}
+
+/* Incrementally initialize a load map. */
+static __always_inline void
+__dl_init_loadaddr_hdr(struct elf32_fdpic_loadaddr loadaddr, void *addr,
+ Elf32_Phdr *phdr, int maxsegs)
+{
+ struct elf32_fdpic_loadseg *segdata;
+
+ if (loadaddr.map->nsegs == maxsegs)
+ _dl_exit(-1);
+
+ segdata = &loadaddr.map->segs[loadaddr.map->nsegs++];
+ segdata->addr = (Elf32_Addr)addr;
+ segdata->p_vaddr = phdr->p_vaddr;
+ segdata->p_memsz = phdr->p_memsz;
+
+#if defined(__SUPPORT_LD_DEBUG__)
+ if (_dl_debug)
+ _dl_dprintf(_dl_debug_file, "%i: mapped %x at %x, size %x\n",
+ loadaddr.map->nsegs - 1,
+ segdata->p_vaddr, segdata->addr, segdata->p_memsz);
+#endif
+}
+
+/* Replace an existing entry in the load map. */
+static __always_inline void
+__dl_update_loadaddr_hdr(struct elf32_fdpic_loadaddr loadaddr, void *addr,
+ Elf32_Phdr *phdr)
+{
+ struct elf32_fdpic_loadseg *segdata;
+ void *oldaddr;
+ int i;
+
+ for (i = 0; i < loadaddr.map->nsegs; i++)
+ if (loadaddr.map->segs[i].p_vaddr == phdr->p_vaddr &&
+ loadaddr.map->segs[i].p_memsz == phdr->p_memsz)
+ break;
+ if (i == loadaddr.map->nsegs)
+ _dl_exit(-1);
+
+ segdata = loadaddr.map->segs + i;
+ oldaddr = (void *)segdata->addr;
+ _dl_munmap(oldaddr, segdata->p_memsz);
+ segdata->addr = (Elf32_Addr)addr;
+
+#if defined (__SUPPORT_LD_DEBUG__)
+ if (_dl_debug)
+ _dl_dprintf(_dl_debug_file, "%i: changed mapping %x at %x (old %x), size %x\n",
+ loadaddr.map->nsegs - 1,
+ segdata->p_vaddr, segdata->addr, oldaddr, segdata->p_memsz);
+#endif
+}
+
+
+#ifndef __dl_loadaddr_unmap
+static __always_inline void
+__dl_loadaddr_unmap(struct elf32_fdpic_loadaddr loadaddr,
+ struct funcdesc_ht *funcdesc_ht)
+{
+ int i;
+
+ for (i = 0; i < loadaddr.map->nsegs; i++)
+ _dl_munmap((void *)loadaddr.map->segs[i].addr,
+ loadaddr.map->segs[i].p_memsz);
+
+ /*
+ * _dl_unmap is only called for dlopen()ed libraries, for which
+ * calling free() is safe, or before we've completed the initial
+ * relocation, in which case calling free() is probably pointless,
+ * but still safe.
+ */
+ _dl_free(loadaddr.map);
+ if (funcdesc_ht)
+ htab_delete(funcdesc_ht);
+}
+#endif
+
+/* Figure out whether the given address is in one of the mapped segments. */
+static __always_inline int
+__dl_addr_in_loadaddr(void *p, struct elf32_fdpic_loadaddr loadaddr)
+{
+ struct elf32_fdpic_loadmap *map = loadaddr.map;
+ int c;
+
+ for (c = 0; c < map->nsegs; c++)
+ if ((void *)map->segs[c].addr <= p &&
+ (char *)p < (char *)map->segs[c].addr + map->segs[c].p_memsz)
+ return 1;
+
+ return 0;
+}
+
+static int
+hash_pointer(void *p)
+{
+ return (int) ((long)p >> 3);
+}
+
+static int
+eq_pointer(void *p, void *q)
+{
+ struct funcdesc_value *entry = p;
+
+ return entry->entry_point == q;
+}
+
+void *
+_dl_funcdesc_for (void *entry_point, void *got_value)
+{
+ struct elf_resolve *tpnt = ((void**)got_value)[2];
+ struct funcdesc_ht *ht = tpnt->funcdesc_ht;
+ struct funcdesc_value **entry;
+
+ _dl_assert(got_value == tpnt->loadaddr.got_value);
+
+ if (!ht) {
+ ht = htab_create();
+ if (!ht)
+ return (void*)-1;
+ tpnt->funcdesc_ht = ht;
+ }
+
+ entry = htab_find_slot(ht, entry_point, 1, hash_pointer, eq_pointer);
+
+ if (entry == NULL)
+ _dl_exit(1);
+
+ if (*entry) {
+ _dl_assert((*entry)->entry_point == entry_point);
+ return _dl_stabilize_funcdesc(*entry);
+ }
+
+ *entry = _dl_malloc(sizeof(**entry));
+ (*entry)->entry_point = entry_point;
+ (*entry)->got_value = got_value;
+
+ return _dl_stabilize_funcdesc(*entry);
+}
+
+static __always_inline void const *
+_dl_lookup_address(void const *address)
+{
+ struct elf_resolve *rpnt;
+ struct funcdesc_value const *fd;
+
+ /* Make sure we don't make assumptions about its alignment. */
+ __asm__ ("" : "+r" (address));
+
+ if ((Elf32_Addr)address & 7)
+ /* It's not a function descriptor. */
+ return address;
+
+ fd = address;
+
+ for (rpnt = _dl_loaded_modules; rpnt; rpnt = rpnt->next) {
+ if (!rpnt->funcdesc_ht)
+ continue;
+
+ if (fd->got_value != rpnt->loadaddr.got_value)
+ continue;
+
+ address = htab_find_slot(rpnt->funcdesc_ht, (void *)fd->entry_point, 0,
+ hash_pointer, eq_pointer);
+
+ if (address && *(struct funcdesc_value *const*)address == fd) {
+ address = (*(struct funcdesc_value *const*)address)->entry_point;
+ break;
+ } else
+ address = fd;
+ }
+
+ return address;
+}
diff --git a/ldso/ldso/fdpic/dl-sysdep.h b/ldso/ldso/fdpic/dl-sysdep.h
new file mode 100644
index 000000000..546811ad0
--- /dev/null
+++ b/ldso/ldso/fdpic/dl-sysdep.h
@@ -0,0 +1,136 @@
+/* Copyright (C) 2003, 2004 Red Hat, Inc.
+ * Contributed by Alexandre Oliva <aoliva@redhat.com>
+ * Copyright (C) 2006-2011 Analog Devices, Inc.
+ * Based on ../i386/dl-sysdep.h
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define HAVE_DL_INLINES_H
+
+/*
+ * Initialization sequence for a GOT. Copy the resolver function
+ * descriptor and the pointer to the elf_resolve/link_map data
+ * structure. Initialize the got_value in the module while at that.
+ */
+#define INIT_GOT(GOT_BASE,MODULE) \
+{ \
+ (MODULE)->loadaddr.got_value = (GOT_BASE); \
+ GOT_BASE[0] = ((unsigned long *)&_dl_linux_resolve)[0]; \
+ GOT_BASE[1] = ((unsigned long *)&_dl_linux_resolve)[1]; \
+ GOT_BASE[2] = (unsigned long) MODULE; \
+}
+
+struct elf_resolve;
+
+struct funcdesc_value
+{
+ void *entry_point;
+ void *got_value;
+} __attribute__((__aligned__(8)));
+
+struct funcdesc_ht;
+
+#define DL_LOADADDR_TYPE struct elf32_fdpic_loadaddr
+
+#define DL_RELOC_ADDR(LOADADDR, ADDR) \
+ ((ElfW(Addr))__reloc_pointer ((void*)(ADDR), (LOADADDR).map))
+
+#define DL_ADDR_TO_FUNC_PTR(ADDR, LOADADDR) \
+ ((void(*)(void)) _dl_funcdesc_for ((void*)(ADDR), (LOADADDR).got_value))
+
+#define _dl_stabilize_funcdesc(val) \
+ ({ __asm__ ("" : "+m" (*(val))); (val); })
+
+#define DL_CALL_FUNC_AT_ADDR(ADDR, LOADADDR, SIGNATURE, ...) \
+ ({ struct funcdesc_value fd = { (void*)(ADDR), (LOADADDR).got_value }; \
+ void (*pf)(void) = (void*) _dl_stabilize_funcdesc (&fd); \
+ (* SIGNATURE pf)(__VA_ARGS__); })
+
+#define DL_INIT_LOADADDR_BOOT(LOADADDR, BASEADDR) \
+ (__dl_init_loadaddr_map (&(LOADADDR), dl_boot_got_pointer, \
+ dl_boot_ldsomap ?: dl_boot_progmap))
+
+#define DL_INIT_LOADADDR_PROG(LOADADDR, BASEADDR) \
+ (__dl_init_loadaddr_map (&(LOADADDR), 0, dl_boot_progmap))
+
+#define DL_INIT_LOADADDR_EXTRA_DECLS \
+ int dl_init_loadaddr_load_count;
+#define DL_INIT_LOADADDR(LOADADDR, BASEADDR, PHDR, PHDRCNT) \
+ (dl_init_loadaddr_load_count = \
+ __dl_init_loadaddr (&(LOADADDR), (PHDR), (PHDRCNT)))
+#define DL_INIT_LOADADDR_HDR(LOADADDR, ADDR, PHDR) \
+ (__dl_init_loadaddr_hdr ((LOADADDR), (ADDR), (PHDR), \
+ dl_init_loadaddr_load_count))
+#define DL_UPDATE_LOADADDR_HDR(LOADADDR, ADDR, PHDR) \
+ (__dl_update_loadaddr_hdr ((LOADADDR), (ADDR), (PHDR)))
+#define DL_LOADADDR_UNMAP(LOADADDR, LEN) \
+ (__dl_loadaddr_unmap ((LOADADDR), (NULL)))
+#define DL_LIB_UNMAP(LIB, LEN) \
+ (__dl_loadaddr_unmap ((LIB)->loadaddr, (LIB)->funcdesc_ht))
+#define DL_LOADADDR_BASE(LOADADDR) \
+ ((LOADADDR).got_value)
+
+/* This is called from dladdr(), such that we map a function
+ descriptor's address to the function's entry point before trying to
+ find in which library it's defined. */
+#define DL_LOOKUP_ADDRESS(ADDRESS) (_dl_lookup_address (ADDRESS))
+
+#define DL_ADDR_IN_LOADADDR(ADDR, TPNT, TFROM) \
+ (! (TFROM) && __dl_addr_in_loadaddr ((void*)(ADDR), (TPNT)->loadaddr))
+
+/*
+ * Compute the GOT address. On several platforms, we use assembly
+ * here. on FDPIC, there's no way to compute the GOT address,
+ * since the offset between text and data is not fixed, so we arrange
+ * for the ldso assembly entry point to pass this value as an argument
+ * to _dl_start. */
+#define DL_BOOT_COMPUTE_GOT(got) ((got) = dl_boot_got_pointer)
+
+#define DL_BOOT_COMPUTE_DYN(dpnt, got, load_addr) \
+ ((dpnt) = dl_boot_ldso_dyn_pointer)
+
+/* We want want to apply all relocations in the interpreter during
+ bootstrap. Because of this, we have to skip the interpreter
+ relocations in _dl_parse_relocation_information(), see
+ elfinterp.c. */
+#define DL_SKIP_BOOTSTRAP_RELOC(SYMTAB, INDEX, STRTAB) 0
+
+#ifdef __NR_pread
+#define _DL_PREAD(FD, BUF, SIZE, OFFSET) \
+ (_dl_pread((FD), (BUF), (SIZE), (OFFSET)))
+#endif
+
+/* We want to return to dlsym() a function descriptor if the symbol
+ turns out to be a function. */
+#define DL_FIND_HASH_VALUE(TPNT, TYPE_CLASS, SYM) \
+ (((TYPE_CLASS) & ELF_RTYPE_CLASS_DLSYM) \
+ && ELF32_ST_TYPE((SYM)->st_info) == STT_FUNC \
+ ? _dl_funcdesc_for ((void *)DL_RELOC_ADDR ((TPNT)->loadaddr, (SYM)->st_value), \
+ (TPNT)->loadaddr.got_value) \
+ : DL_RELOC_ADDR ((TPNT)->loadaddr, (SYM)->st_value))
+
+#define DL_GET_READY_TO_RUN_EXTRA_PARMS \
+ , struct elf32_fdpic_loadmap *dl_boot_progmap, Elf32_Addr dl_boot_got_pointer
+#define DL_GET_READY_TO_RUN_EXTRA_ARGS \
+ , dl_boot_progmap, dl_boot_got_pointer
+
+/* Define this to declare the library offset. */
+#define DL_DEF_LIB_OFFSET
+
+/* Define this to get the library offset. */
+#define DL_GET_LIB_OFFSET() 0
+
+/* Define this to set the library offset. */
+#define DL_SET_LIB_OFFSET(offset)
+
+/* Define this to get the real object's runtime address. */
+#define DL_GET_RUN_ADDR(loadaddr, mapaddr) (loadaddr)
+
+#ifdef __USE_GNU
+# include <link.h>
+#else
+# define __USE_GNU
+# include <link.h>
+# undef __USE_GNU
+#endif
diff --git a/ldso/ldso/frv/dl-debug.h b/ldso/ldso/frv/dl-debug.h
index 9b146a62f..65c2386fb 100644
--- a/ldso/ldso/frv/dl-debug.h
+++ b/ldso/ldso/frv/dl-debug.h
@@ -10,7 +10,7 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-static const char *_dl_reltypes_tab[] =
+static const char * const _dl_reltypes_tab[] =
{
[0] "R_FRV_NONE", "R_FRV_32",
[2] "R_FRV_LABEL16", "R_FRV_LABEL24",
diff --git a/ldso/ldso/frv/dl-inlines.h b/ldso/ldso/frv/dl-inlines.h
index 0d469dd88..8fdf6eb48 100644
--- a/ldso/ldso/frv/dl-inlines.h
+++ b/ldso/ldso/frv/dl-inlines.h
@@ -1,456 +1 @@
-/* Copyright (C) 2003, 2004 Red Hat, Inc.
- * Contributed by Alexandre Oliva <aoliva@redhat.com>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-
-#ifndef _dl_assert
-# define _dl_assert(expr)
-#endif
-
-/* Initialize a DL_LOADADDR_TYPE given a got pointer and a complete
- load map. */
-inline static void
-__dl_init_loadaddr_map (struct elf32_fdpic_loadaddr *loadaddr, void *got_value,
- struct elf32_fdpic_loadmap *map)
-{
- if (map->version != 0)
- {
- SEND_EARLY_STDERR ("Invalid loadmap version number\n");
- _dl_exit(-1);
- }
- if (map->nsegs == 0)
- {
- SEND_EARLY_STDERR ("Invalid segment count in loadmap\n");
- _dl_exit(-1);
- }
- loadaddr->got_value = got_value;
- loadaddr->map = map;
-}
-
-/* Figure out how many LOAD segments there are in the given headers,
- and allocate a block for the load map big enough for them.
- got_value will be properly initialized later on, with INIT_GOT. */
-inline static int
-__dl_init_loadaddr (struct elf32_fdpic_loadaddr *loadaddr, Elf32_Phdr *ppnt,
- int pcnt)
-{
- int count = 0, i;
- size_t size;
-
- for (i = 0; i < pcnt; i++)
- if (ppnt[i].p_type == PT_LOAD)
- count++;
-
- loadaddr->got_value = 0;
-
- size = sizeof (struct elf32_fdpic_loadmap)
- + sizeof (struct elf32_fdpic_loadseg) * count;
- loadaddr->map = _dl_malloc (size);
- if (! loadaddr->map)
- _dl_exit (-1);
-
- loadaddr->map->version = 0;
- loadaddr->map->nsegs = 0;
-
- return count;
-}
-
-/* Incrementally initialize a load map. */
-inline static void
-__dl_init_loadaddr_hdr (struct elf32_fdpic_loadaddr loadaddr, void *addr,
- Elf32_Phdr *phdr, int maxsegs)
-{
- struct elf32_fdpic_loadseg *segdata;
-
- if (loadaddr.map->nsegs == maxsegs)
- _dl_exit (-1);
-
- segdata = &loadaddr.map->segs[loadaddr.map->nsegs++];
- segdata->addr = (Elf32_Addr) addr;
- segdata->p_vaddr = phdr->p_vaddr;
- segdata->p_memsz = phdr->p_memsz;
-
-#if defined (__SUPPORT_LD_DEBUG__)
- {
- extern char *_dl_debug;
- extern int _dl_debug_file;
- if (_dl_debug)
- _dl_dprintf(_dl_debug_file, "%i: mapped %x at %x, size %x\n",
- loadaddr.map->nsegs-1,
- segdata->p_vaddr, segdata->addr, segdata->p_memsz);
- }
-#endif
-}
-
-inline static void __dl_loadaddr_unmap
-(struct elf32_fdpic_loadaddr loadaddr, struct funcdesc_ht *funcdesc_ht);
-
-/* Figure out whether the given address is in one of the mapped
- segments. */
-inline static int
-__dl_addr_in_loadaddr (void *p, struct elf32_fdpic_loadaddr loadaddr)
-{
- struct elf32_fdpic_loadmap *map = loadaddr.map;
- int c;
-
- for (c = 0; c < map->nsegs; c++)
- if ((void*)map->segs[c].addr <= p
- && (char*)p < (char*)map->segs[c].addr + map->segs[c].p_memsz)
- return 1;
-
- return 0;
-}
-
-inline static void * _dl_funcdesc_for (void *entry_point, void *got_value);
-
-/* The hashcode handling code below is heavily inspired in libiberty's
- hashtab code, but with most adaptation points and support for
- deleting elements removed.
-
- Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
- Contributed by Vladimir Makarov (vmakarov@cygnus.com). */
-
-inline static unsigned long
-higher_prime_number (unsigned long n)
-{
- /* These are primes that are near, but slightly smaller than, a
- power of two. */
- static const unsigned long primes[] = {
- (unsigned long) 7,
- (unsigned long) 13,
- (unsigned long) 31,
- (unsigned long) 61,
- (unsigned long) 127,
- (unsigned long) 251,
- (unsigned long) 509,
- (unsigned long) 1021,
- (unsigned long) 2039,
- (unsigned long) 4093,
- (unsigned long) 8191,
- (unsigned long) 16381,
- (unsigned long) 32749,
- (unsigned long) 65521,
- (unsigned long) 131071,
- (unsigned long) 262139,
- (unsigned long) 524287,
- (unsigned long) 1048573,
- (unsigned long) 2097143,
- (unsigned long) 4194301,
- (unsigned long) 8388593,
- (unsigned long) 16777213,
- (unsigned long) 33554393,
- (unsigned long) 67108859,
- (unsigned long) 134217689,
- (unsigned long) 268435399,
- (unsigned long) 536870909,
- (unsigned long) 1073741789,
- (unsigned long) 2147483647,
- /* 4294967291L */
- ((unsigned long) 2147483647) + ((unsigned long) 2147483644),
- };
-
- const unsigned long *low = &primes[0];
- const unsigned long *high = &primes[sizeof(primes) / sizeof(primes[0])];
-
- while (low != high)
- {
- const unsigned long *mid = low + (high - low) / 2;
- if (n > *mid)
- low = mid + 1;
- else
- high = mid;
- }
-
-#if 0
- /* If we've run out of primes, abort. */
- if (n > *low)
- {
- fprintf (stderr, "Cannot find prime bigger than %lu\n", n);
- abort ();
- }
-#endif
-
- return *low;
-}
-
-struct funcdesc_ht
-{
- /* Table itself. */
- struct funcdesc_value **entries;
-
- /* Current size (in entries) of the hash table */
- size_t size;
-
- /* Current number of elements. */
- size_t n_elements;
-};
-
-inline static int
-hash_pointer (const void *p)
-{
- return (int) ((long)p >> 3);
-}
-
-inline static struct funcdesc_ht *
-htab_create (void)
-{
- struct funcdesc_ht *ht = _dl_malloc (sizeof (struct funcdesc_ht));
-
- if (! ht)
- return NULL;
- ht->size = 3;
- ht->entries = _dl_malloc (sizeof (struct funcdesc_ht_value *) * ht->size);
- if (! ht->entries)
- return NULL;
-
- ht->n_elements = 0;
-
- _dl_memset (ht->entries, 0, sizeof (struct funcdesc_ht_value *) * ht->size);
-
- return ht;
-}
-
-/* This is only called from _dl_loadaddr_unmap, so it's safe to call
- _dl_free(). See the discussion below. */
-inline static void
-htab_delete (struct funcdesc_ht *htab)
-{
- int i;
-
- for (i = htab->size - 1; i >= 0; i--)
- if (htab->entries[i])
- _dl_free (htab->entries[i]);
-
- _dl_free (htab->entries);
- _dl_free (htab);
-}
-
-/* Similar to htab_find_slot, but without several unwanted side effects:
- - Does not call htab->eq_f when it finds an existing entry.
- - Does not change the count of elements/searches/collisions in the
- hash table.
- This function also assumes there are no deleted entries in the table.
- HASH is the hash value for the element to be inserted. */
-
-inline static struct funcdesc_value **
-find_empty_slot_for_expand (struct funcdesc_ht *htab, int hash)
-{
- size_t size = htab->size;
- unsigned int index = hash % size;
- struct funcdesc_value **slot = htab->entries + index;
- int hash2;
-
- if (! *slot)
- return slot;
-
- hash2 = 1 + hash % (size - 2);
- for (;;)
- {
- index += hash2;
- if (index >= size)
- index -= size;
-
- slot = htab->entries + index;
- if (! *slot)
- return slot;
- }
-}
-
-/* The following function changes size of memory allocated for the
- entries and repeatedly inserts the table elements. The occupancy
- of the table after the call will be about 50%. Naturally the hash
- table must already exist. Remember also that the place of the
- table entries is changed. If memory allocation failures are allowed,
- this function will return zero, indicating that the table could not be
- expanded. If all goes well, it will return a non-zero value. */
-
-inline static int
-htab_expand (struct funcdesc_ht *htab)
-{
- struct funcdesc_value **oentries;
- struct funcdesc_value **olimit;
- struct funcdesc_value **p;
- struct funcdesc_value **nentries;
- size_t nsize;
-
- oentries = htab->entries;
- olimit = oentries + htab->size;
-
- /* Resize only when table after removal of unused elements is either
- too full or too empty. */
- if (htab->n_elements * 2 > htab->size)
- nsize = higher_prime_number (htab->n_elements * 2);
- else
- nsize = htab->size;
-
- nentries = _dl_malloc (sizeof (struct funcdesc_value *) * nsize);
- _dl_memset (nentries, 0, sizeof (struct funcdesc_value *) * nsize);
- if (nentries == NULL)
- return 0;
- htab->entries = nentries;
- htab->size = nsize;
-
- p = oentries;
- do
- {
- if (*p)
- *find_empty_slot_for_expand (htab, hash_pointer ((*p)->entry_point))
- = *p;
-
- p++;
- }
- while (p < olimit);
-
-#if 0 /* We can't tell whether this was allocated by the _dl_malloc()
- built into ld.so or malloc() in the main executable or libc,
- and calling free() for something that wasn't malloc()ed could
- do Very Bad Things (TM). Take the conservative approach
- here, potentially wasting as much memory as actually used by
- the hash table, even if multiple growths occur. That's not
- so bad as to require some overengineered solution that would
- enable us to keep track of how it was allocated. */
- _dl_free (oentries);
-#endif
- return 1;
-}
-
-/* This function searches for a hash table slot containing an entry
- equal to the given element. To delete an entry, call this with
- INSERT = 0, then call htab_clear_slot on the slot returned (possibly
- after doing some checks). To insert an entry, call this with
- INSERT = 1, then write the value you want into the returned slot.
- When inserting an entry, NULL may be returned if memory allocation
- fails. */
-
-inline static struct funcdesc_value **
-htab_find_slot (struct funcdesc_ht *htab, void *ptr, int insert)
-{
- unsigned int index;
- int hash, hash2;
- size_t size;
- struct funcdesc_value **entry;
-
- if (htab->size * 3 <= htab->n_elements * 4
- && htab_expand (htab) == 0)
- return NULL;
-
- hash = hash_pointer (ptr);
-
- size = htab->size;
- index = hash % size;
-
- entry = &htab->entries[index];
- if (!*entry)
- goto empty_entry;
- else if ((*entry)->entry_point == ptr)
- return entry;
-
- hash2 = 1 + hash % (size - 2);
- for (;;)
- {
- index += hash2;
- if (index >= size)
- index -= size;
-
- entry = &htab->entries[index];
- if (!*entry)
- goto empty_entry;
- else if ((*entry)->entry_point == ptr)
- return entry;
- }
-
- empty_entry:
- if (!insert)
- return NULL;
-
- htab->n_elements++;
- return entry;
-}
-
-void *
-_dl_funcdesc_for (void *entry_point, void *got_value)
-{
- struct elf_resolve *tpnt = ((void**)got_value)[2];
- struct funcdesc_ht *ht = tpnt->funcdesc_ht;
- struct funcdesc_value **entry;
-
- _dl_assert (got_value == tpnt->loadaddr.got_value);
-
- if (! ht)
- {
- ht = htab_create ();
- if (! ht)
- return (void*)-1;
- tpnt->funcdesc_ht = ht;
- }
-
- entry = htab_find_slot (ht, entry_point, 1);
- if (*entry)
- {
- _dl_assert ((*entry)->entry_point == entry_point);
- return _dl_stabilize_funcdesc (*entry);
- }
-
- *entry = _dl_malloc (sizeof (struct funcdesc_value));
- (*entry)->entry_point = entry_point;
- (*entry)->got_value = got_value;
-
- return _dl_stabilize_funcdesc (*entry);
-}
-
-inline static void const *
-_dl_lookup_address (void const *address)
-{
- struct elf_resolve *rpnt;
- struct funcdesc_value const *fd;
-
- /* Make sure we don't make assumptions about its alignment. */
- __asm__ ("" : "+r" (address));
-
- if ((Elf32_Addr)address & 7)
- /* It's not a function descriptor. */
- return address;
-
- fd = (struct funcdesc_value const *)address;
-
- for (rpnt = _dl_loaded_modules; rpnt; rpnt = rpnt->next)
- {
- if (! rpnt->funcdesc_ht)
- continue;
-
- if (fd->got_value != rpnt->loadaddr.got_value)
- continue;
-
- address = htab_find_slot (rpnt->funcdesc_ht, (void*)fd->entry_point, 0);
-
- if (address && *(struct funcdesc_value *const*)address == fd)
- {
- address = (*(struct funcdesc_value *const*)address)->entry_point;
- break;
- }
- else
- address = fd;
- }
-
- return address;
-}
-
-void
-__dl_loadaddr_unmap (struct elf32_fdpic_loadaddr loadaddr,
- struct funcdesc_ht *funcdesc_ht)
-{
- int i;
-
- for (i = 0; i < loadaddr.map->nsegs; i++)
- _dl_munmap ((void*)loadaddr.map->segs[i].addr,
- loadaddr.map->segs[i].p_memsz);
-
- /* _dl_unmap is only called for dlopen()ed libraries, for which
- calling free() is safe, or before we've completed the initial
- relocation, in which case calling free() is probably pointless,
- but still safe. */
- _dl_free (loadaddr.map);
- if (funcdesc_ht)
- htab_delete (funcdesc_ht);
-}
+#include "../fdpic/dl-inlines.h"
diff --git a/ldso/ldso/frv/dl-startup.h b/ldso/ldso/frv/dl-startup.h
index 674f81c15..45e9cb9ce 100644
--- a/ldso/ldso/frv/dl-startup.h
+++ b/ldso/ldso/frv/dl-startup.h
@@ -27,9 +27,10 @@
__asm__("" \
" .text\n" \
-" .global _dl_boot\n" \
-" .type _dl_boot,@function\n" \
-"_dl_boot:\n" \
+" .global _start\n" \
+" .type _start,@function\n" \
+" .hidden _start\n" \
+"_start:\n" \
" call .Lcall\n" \
".Lcall:\n" \
" movsg lr, gr4\n" \
@@ -54,45 +55,32 @@ __asm__("" \
" addi.p sp, #4, gr13\n" \
" addi sp, #-8, sp\n" \
" mov.p sp, gr12\n" \
-" call _dl_boot2\n" \
+" call _dl_start\n" \
" ldd.p @(sp, gr0), gr14\n" \
" addi sp, #8, sp\n" \
" movgs gr0, lr\n" \
" jmpl @(gr14, gr0)\n" \
-" .size _dl_boot,.-_dl_boot\n" \
+" .size _start,.-_start\n" \
);
-#define _dl_boot _dl_boot2
-#define DL_BOOT(X) \
+#undef DL_START
+#define DL_START(X) \
static void __attribute__ ((used)) \
-_dl_boot (void *dl_boot_got_pointer, \
+_dl_start (Elf32_Addr dl_boot_got_pointer, \
struct elf32_fdpic_loadmap *dl_boot_progmap, \
struct elf32_fdpic_loadmap *dl_boot_ldsomap, \
Elf32_Dyn *dl_boot_ldso_dyn_pointer, \
struct funcdesc_value *dl_main_funcdesc, \
X)
-struct elf32_fdpic_loadmap;
-
/*
* Get a pointer to the argv array. On many platforms this can be just
- * the address if the first argument, on other platforms we need to
+ * the address of the first argument, on other platforms we need to
* do something a little more subtle here.
*/
#define GET_ARGV(ARGVP, ARGS) ARGVP = ((unsigned long*) ARGS)
/*
- * Compute the GOT address. On several platforms, we use assembly
- * here. on FR-V FDPIC, there's no way to compute the GOT address,
- * since the offset between text and data is not fixed, so we arrange
- * for the assembly _dl_boot to pass this value as an argument to
- * _dl_boot. */
-#define DL_BOOT_COMPUTE_GOT(got) ((got) = dl_boot_got_pointer)
-
-#define DL_BOOT_COMPUTE_DYN(dpnt, got, load_addr) \
- ((dpnt) = dl_boot_ldso_dyn_pointer)
-
-/*
* Here is a macro to perform a relocation. This is only used when
* bootstrapping the dynamic loader. RELP is the relocation that we
* are performing, REL is the pointer to the address we are relocating.
@@ -100,7 +88,7 @@ struct elf32_fdpic_loadmap;
* load address.
*/
#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB) \
- switch(ELF32_R_TYPE((RELP)->r_info)){ \
+ switch(ELF_R_TYPE((RELP)->r_info)){ \
case R_FRV_32: \
*(REL) += (SYMBOL); \
break; \
@@ -128,6 +116,5 @@ struct elf32_fdpic_loadmap;
while (exec_mod->libtype != elf_executable) \
exec_mod = exec_mod->next; \
dl_main_funcdesc->got_value = exec_mod->loadaddr.got_value; \
- /* _dl_dprintf(2, "entry point is (%x,%x)\n", dl_main_funcdesc->entry_point, dl_main_funcdesc->got_value); */ \
return; \
} while (0)
diff --git a/ldso/ldso/frv/dl-syscalls.h b/ldso/ldso/frv/dl-syscalls.h
index 093d0dca8..f40c4fd31 100644
--- a/ldso/ldso/frv/dl-syscalls.h
+++ b/ldso/ldso/frv/dl-syscalls.h
@@ -1,175 +1 @@
-/* Copyright (C) 2003, 2004 Red Hat, Inc.
- * Contributed by Alexandre Oliva <aoliva@redhat.com>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-
-/* We can't use the real errno in ldso, since it has not yet
- * been dynamicly linked in yet. */
-#include "sys/syscall.h"
-extern int _dl_errno;
-#undef __set_errno
-#define __set_errno(X) {(_dl_errno) = (X);}
-#include <sys/mman.h>
-
-/* The code below is extracted from libc/sysdeps/linux/frv/_mmap.c */
-
-#if DYNAMIC_LOADER_IN_SIMULATOR
-#define __NR___syscall_mmap2 __NR_mmap2
-static __inline__ _syscall6(__ptr_t, __syscall_mmap2, __ptr_t, addr,
- size_t, len, int, prot, int, flags, int, fd, off_t, offset);
-
-/* Make sure we don't get another definition of _dl_mmap from the
- machine-independent code. */
-#undef __NR_mmap
-#undef __NR_mmap2
-
-/* This is always 12, even on architectures where PAGE_SHIFT != 12. */
-# ifndef MMAP2_PAGE_SHIFT
-# define MMAP2_PAGE_SHIFT 12
-# endif
-
-#include <bits/uClibc_page.h> /* for PAGE_SIZE */
-inline static void *_dl_memset(void*,int,size_t);
-inline static ssize_t _dl_pread(int fd, void *buf, size_t count, off_t offset);
-
-static __ptr_t
-_dl_mmap(__ptr_t addr, size_t len, int prot, int flags, int fd, __off_t offset)
-{
- size_t plen = (len + PAGE_SIZE - 1) & -PAGE_SIZE;
-
-/* This is a hack to enable the dynamic loader to run within a
- simulator that doesn't support mmap, with a number of very ugly
- tricks. Also, it's not as useful as it sounds, since only dynamic
- executables without DT_NEEDED dependencies can be run. AFAIK, they
- can only be created with -pie. This trick suffices to enable the
- dynamic loader to obtain a blank page that it maps early in the
- bootstrap. */
- if ((flags & MAP_FIXED) == 0)
- {
- void *_dl_mmap_base = 0;
- __ptr_t *ret = 0;
-
- if (! _dl_mmap_base)
- {
- void *stack;
- __asm__ ("mov sp, %0" : "=r" (stack));
- _dl_mmap_base = (void *)(((long)stack + 2 * PAGE_SIZE) & -PAGE_SIZE);
- retry:
- if (((void **)_dl_mmap_base)[0] == _dl_mmap_base
- && ((void **)_dl_mmap_base)[1023] == _dl_mmap_base
- && (((void **)_dl_mmap_base)[177]
- == ((void **)_dl_mmap_base)[771]))
- {
- while (((void**)_dl_mmap_base)[177])
- {
- _dl_mmap_base = ((void**)_dl_mmap_base)[177];
- if (!(((void **)_dl_mmap_base)[0] == _dl_mmap_base
- && ((void **)_dl_mmap_base)[1023] == _dl_mmap_base
- && (((void **)_dl_mmap_base)[177]
- == ((void**)_dl_mmap_base)[771])))
- ((void(*)())0)();
- }
- }
- else
- {
- int i;
- for (i = 0; i < (int)PAGE_SIZE; i++)
- if (*(char*)(_dl_mmap_base + i))
- break;
- if (i != PAGE_SIZE)
- {
- _dl_mmap_base = (void*)((long)_dl_mmap_base + PAGE_SIZE);
- goto retry;
- }
- ((void**)_dl_mmap_base)[-1] =
- ((void**)_dl_mmap_base)[0] =
- ((void**)_dl_mmap_base)[1023] =
- _dl_mmap_base;
- }
- }
-
- if (_dl_mmap_base)
- {
- if (!(((void **)_dl_mmap_base)[0] == _dl_mmap_base
- && ((void **)_dl_mmap_base)[1023] == _dl_mmap_base
- && (((void **)_dl_mmap_base)[177]
- == ((void**)_dl_mmap_base)[771])))
- ((void(*)())0)();
- ret = (__ptr_t)((char*)_dl_mmap_base + PAGE_SIZE);
- _dl_mmap_base =
- ((void**)_dl_mmap_base)[177] =
- ((void**)_dl_mmap_base)[771] =
- (char*)_dl_mmap_base + plen + PAGE_SIZE;
- ((void**)_dl_mmap_base)[0] =
- ((void**)_dl_mmap_base)[1023] =
- _dl_mmap_base;
- }
-
- if ((flags & MAP_ANONYMOUS) != 0)
- {
- _dl_memset (ret, 0, plen);
- return ret;
- }
-
- flags |= MAP_FIXED;
- addr = ret;
- }
- if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1)) {
-#if 0
- __set_errno (EINVAL);
-#endif
- return MAP_FAILED;
- }
- if ((flags & MAP_FIXED) != 0)
- {
- if (_dl_pread(fd, addr, len, offset) != (ssize_t)len)
- return (void*)MAP_FAILED;
- if (plen != len)
- _dl_memset (addr + len, 0, plen - len);
- return addr;
- }
- return(__syscall_mmap2(addr, len, prot, flags, fd, (off_t) (offset >> MMAP2_PAGE_SHIFT)));
-}
-#endif
-
-#ifdef __NR_pread
-#ifdef DYNAMIC_LOADER_IN_SIMULATOR
-#include <unistd.h>
-
-#define __NR___syscall_lseek __NR_lseek
-inline static unsigned long _dl_read(int fd, const void *buf, unsigned long count);
-
-inline static _syscall3(__off_t, __syscall_lseek, int, fd, __off_t, offset,
- int, whence);
-inline static ssize_t
-_dl_pread(int fd, void *buf, size_t count, off_t offset)
-{
- __off_t orig = __syscall_lseek (fd, 0, SEEK_CUR);
- ssize_t ret;
-
- if (orig == -1)
- return -1;
-
- if (__syscall_lseek (fd, offset, SEEK_SET) != offset)
- return -1;
-
- ret = _dl_read (fd, buf, count);
-
- if (__syscall_lseek (fd, orig, SEEK_SET) != orig)
- ((void(*)())0)();
-
- return ret;
-}
-#else
-#define __NR___syscall_pread __NR_pread
-inline static _syscall5(ssize_t, __syscall_pread, int, fd, void *, buf,
- size_t, count, off_t, offset_hi, off_t, offset_lo);
-
-inline static ssize_t
-_dl_pread(int fd, void *buf, size_t count, off_t offset)
-{
- return(__syscall_pread(fd,buf,count,__LONG_LONG_PAIR (offset >> 31, offset)));
-}
-#endif
-#endif
+/* stub for arch-specific syscall issues */
diff --git a/ldso/ldso/frv/dl-sysdep.h b/ldso/ldso/frv/dl-sysdep.h
index 32d86ed2c..e6bf7f187 100644
--- a/ldso/ldso/frv/dl-sysdep.h
+++ b/ldso/ldso/frv/dl-sysdep.h
@@ -20,19 +20,6 @@
#define DL_NO_COPY_RELOCS
-/*
- * Initialization sequence for a GOT. Copy the resolver function
- * descriptor and the pointer to the elf_resolve/link_map data
- * structure. Initialize the got_value in the module while at that.
- */
-#define INIT_GOT(GOT_BASE,MODULE) \
-{ \
- (MODULE)->loadaddr.got_value = (GOT_BASE); \
- GOT_BASE[0] = ((unsigned long *)&_dl_linux_resolve)[0]; \
- GOT_BASE[1] = ((unsigned long *)&_dl_linux_resolve)[1]; \
- GOT_BASE[2] = (unsigned long) MODULE; \
-}
-
/* Here we define the magic numbers that this dynamic loader should accept */
#define MAGIC1 EM_CYGNUS_FRV
#undef MAGIC2
@@ -40,25 +27,11 @@
/* Used for error messages */
#define ELF_TARGET "FR-V"
-struct elf_resolve;
-
-struct funcdesc_value
-{
- void *entry_point;
- void *got_value;
-} __attribute__((__aligned__(8)));
-
+/* Need bootstrap relocations */
+#define ARCH_NEEDS_BOOTSTRAP_RELOCS
extern int _dl_linux_resolve(void) __attribute__((__visibility__("hidden")));
-/* 16KiB page alignment. Should perhaps be made dynamic using
- getpagesize(), based on AT_PAGESZ from auxvt? */
-#define PAGE_ALIGN 0xffffc000
-#define ADDR_ALIGN 0x3fff
-#define OFFS_ALIGN 0x7fffc000
-
-struct funcdesc_ht;
-
/* We must force strings used early in the bootstrap into the data
segment, such that they are referenced with GOTOFF instead of
GPREL, because GPREL needs the GOT to have already been
@@ -67,52 +40,6 @@ struct funcdesc_ht;
#define SEND_EARLY_STDERR(S) \
do { static char __s[] = (S); SEND_STDERR (__s); } while (0)
-#define DL_LOADADDR_TYPE struct elf32_fdpic_loadaddr
-
-#define DL_RELOC_ADDR(ADDR, LOADADDR) \
- (__reloc_pointer ((void*)(ADDR), (LOADADDR).map))
-
-#define DL_ADDR_TO_FUNC_PTR(ADDR, LOADADDR) \
- ((void(*)(void)) _dl_funcdesc_for ((void*)(ADDR), (LOADADDR).got_value))
-
-#define _dl_stabilize_funcdesc(val) \
- ({ __asm__ ("" : "+m" (*(val))); (val); })
-
-#define DL_CALL_FUNC_AT_ADDR(ADDR, LOADADDR, SIGNATURE, ...) \
- ({ struct funcdesc_value fd = { (void*)(ADDR), (LOADADDR).got_value }; \
- void (*pf)(void) = (void*) _dl_stabilize_funcdesc (&fd); \
- (* SIGNATURE pf)(__VA_ARGS__); })
-
-#define DL_INIT_LOADADDR_BOOT(LOADADDR, BASEADDR) \
- (__dl_init_loadaddr_map (&(LOADADDR), dl_boot_got_pointer, \
- dl_boot_ldsomap ?: dl_boot_progmap))
-
-#define DL_INIT_LOADADDR_PROG(LOADADDR, BASEADDR) \
- (__dl_init_loadaddr_map (&(LOADADDR), 0, dl_boot_progmap))
-
-#define DL_INIT_LOADADDR_EXTRA_DECLS \
- int dl_init_loadaddr_load_count;
-#define DL_INIT_LOADADDR(LOADADDR, BASEADDR, PHDR, PHDRCNT) \
- (dl_init_loadaddr_load_count = \
- __dl_init_loadaddr (&(LOADADDR), (PHDR), (PHDRCNT)))
-#define DL_INIT_LOADADDR_HDR(LOADADDR, ADDR, PHDR) \
- (__dl_init_loadaddr_hdr ((LOADADDR), (ADDR), (PHDR), \
- dl_init_loadaddr_load_count))
-#define DL_LOADADDR_UNMAP(LOADADDR, LEN) \
- (__dl_loadaddr_unmap ((LOADADDR), (NULL)))
-#define DL_LIB_UNMAP(LIB, LEN) \
- (__dl_loadaddr_unmap ((LIB)->loadaddr, (LIB)->funcdesc_ht))
-#define DL_LOADADDR_BASE(LOADADDR) \
- ((LOADADDR).got_value)
-
-/* This is called from dladdr(), such that we map a function
- descriptor's address to the function's entry point before trying to
- find in which library it's defined. */
-#define DL_LOOKUP_ADDRESS(ADDRESS) (_dl_lookup_address (ADDRESS))
-
-#define DL_ADDR_IN_LOADADDR(ADDR, TPNT, TFROM) \
- (! (TFROM) && __dl_addr_in_loadaddr ((void*)(ADDR), (TPNT)->loadaddr))
-
/* Make sure we only load libraries that use the same number of
general-purpose and floating-point registers the dynamic loader was
compiled for. */
@@ -154,38 +81,17 @@ do \
} \
while (0)
-/* We want want to apply all relocations in the interpreter during
- bootstrap. Because of this, we have to skip the interpreter
- relocations in _dl_parse_relocation_information(), see
- elfinterp.c. */
-#define DL_SKIP_BOOTSTRAP_RELOC(SYMTAB, INDEX, STRTAB) 0
-
-#ifdef __NR_pread
-#define _DL_PREAD(FD, BUF, SIZE, OFFSET) \
- (_dl_pread((FD), (BUF), (SIZE), (OFFSET)))
-#endif
-
-/* We want to return to dlsym() a function descriptor if the symbol
- turns out to be a function. */
-#define DL_FIND_HASH_VALUE(TPNT, TYPE_CLASS, SYM) \
- (((TYPE_CLASS) & ELF_RTYPE_CLASS_DLSYM) \
- && ELF32_ST_TYPE((SYM)->st_info) == STT_FUNC \
- ? _dl_funcdesc_for (DL_RELOC_ADDR ((SYM)->st_value, (TPNT)->loadaddr), \
- (TPNT)->loadaddr.got_value) \
- : DL_RELOC_ADDR ((SYM)->st_value, (TPNT)->loadaddr))
-
-#define DL_GET_READY_TO_RUN_EXTRA_PARMS \
- , struct elf32_fdpic_loadmap *dl_boot_progmap
-#define DL_GET_READY_TO_RUN_EXTRA_ARGS \
- , dl_boot_progmap
-
-
+#include "../fdpic/dl-sysdep.h"
+static __always_inline Elf32_Addr
+elf_machine_load_address (void)
+{
+ return 0;
+}
-#ifdef __USE_GNU
-# include <link.h>
-#else
-# define __USE_GNU
-# include <link.h>
-# undef __USE_GNU
-#endif
+static __always_inline void
+elf_machine_relative (DL_LOADADDR_TYPE load_off, const Elf32_Addr rel_addr,
+ Elf32_Word relative_count)
+{
+ ;
+}
diff --git a/ldso/ldso/frv/elfinterp.c b/ldso/ldso/frv/elfinterp.c
index df41f97bf..2c954b3ab 100644
--- a/ldso/ldso/frv/elfinterp.c
+++ b/ldso/ldso/frv/elfinterp.c
@@ -10,6 +10,7 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+#include <sys/cdefs.h> /* __attribute_used__ */
#include <features.h>
/* Program to load an ELF binary on a linux system, and run it.
@@ -26,47 +27,35 @@
struct funcdesc_value volatile attribute_hidden *
_dl_linux_resolver (struct elf_resolve *tpnt, int reloc_entry)
{
- int reloc_type;
ELF_RELOC *this_reloc;
char *strtab;
- Elf32_Sym *symtab;
+ ElfW(Sym) *symtab;
int symtab_index;
char *rel_addr;
- struct elf_resolve *new_tpnt;
char *new_addr;
struct funcdesc_value funcval;
struct funcdesc_value volatile *got_entry;
char *symname;
+ struct symbol_ref sym_ref;
- rel_addr = DL_RELOC_ADDR (tpnt->dynamic_info[DT_JMPREL],
- tpnt->loadaddr);
+ rel_addr = (char *)tpnt->dynamic_info[DT_JMPREL];
this_reloc = (ELF_RELOC *)(intptr_t)(rel_addr + reloc_entry);
- reloc_type = ELF32_R_TYPE(this_reloc->r_info);
- symtab_index = ELF32_R_SYM(this_reloc->r_info);
+ symtab_index = ELF_R_SYM(this_reloc->r_info);
- symtab = (Elf32_Sym *)(intptr_t)
- DL_RELOC_ADDR (tpnt->dynamic_info[DT_SYMTAB],
- tpnt->loadaddr);
- strtab = DL_RELOC_ADDR (tpnt->dynamic_info[DT_STRTAB], tpnt->loadaddr);
+ symtab = (ElfW(Sym) *) tpnt->dynamic_info[DT_SYMTAB];
+ strtab = (char *) tpnt->dynamic_info[DT_STRTAB];
+ sym_ref.sym = &symtab[symtab_index];
+ sym_ref.tpnt = NULL;
symname= strtab + symtab[symtab_index].st_name;
- if (reloc_type != R_FRV_FUNCDESC_VALUE) {
- _dl_dprintf(2, "%s: Incorrect relocation type in jump relocations\n",
- _dl_progname);
- _dl_exit(1);
- }
-
/* Address of GOT entry fix up */
- got_entry = (struct funcdesc_value *)
- DL_RELOC_ADDR (this_reloc->r_offset, tpnt->loadaddr);
+ got_entry = (struct funcdesc_value *) DL_RELOC_ADDR(tpnt->loadaddr, this_reloc->r_offset);
/* Get the address to be used to fill in the GOT entry. */
- new_addr = _dl_find_hash_mod(symname, tpnt->symbol_scope, NULL, 0,
- &new_tpnt);
+ new_addr = _dl_find_hash(symname, &_dl_loaded_modules->symbol_scope, NULL, 0, &sym_ref);
if (!new_addr) {
- new_addr = _dl_find_hash_mod(symname, NULL, NULL, 0,
- &new_tpnt);
+ new_addr = _dl_find_hash(symname, NULL, NULL, 0, &sym_ref);
if (!new_addr) {
_dl_dprintf(2, "%s: can't resolve symbol '%s'\n",
_dl_progname, symname);
@@ -75,7 +64,7 @@ _dl_linux_resolver (struct elf_resolve *tpnt, int reloc_entry)
}
funcval.entry_point = new_addr;
- funcval.got_value = new_tpnt->loadaddr.got_value;
+ funcval.got_value = sym_ref.tpnt->loadaddr.got_value;
#if defined (__SUPPORT_LD_DEBUG__)
if (_dl_debug_bindings)
@@ -99,29 +88,28 @@ _dl_linux_resolver (struct elf_resolve *tpnt, int reloc_entry)
}
static int
-_dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
+_dl_parse(struct elf_resolve *tpnt, struct r_scope_elem *scope,
unsigned long rel_addr, unsigned long rel_size,
- int (*reloc_fnc) (struct elf_resolve *tpnt, struct dyn_elf *scope,
- ELF_RELOC *rpnt, Elf32_Sym *symtab, char *strtab))
+ int (*reloc_fnc) (struct elf_resolve *tpnt, struct r_scope_elem *scope,
+ ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab))
{
unsigned int i;
char *strtab;
- Elf32_Sym *symtab;
+ ElfW(Sym) *symtab;
ELF_RELOC *rpnt;
int symtab_index;
/* Now parse the relocation information */
- rpnt = (ELF_RELOC *)(intptr_t) DL_RELOC_ADDR (rel_addr, tpnt->loadaddr);
+ rpnt = (ELF_RELOC *) rel_addr;
rel_size = rel_size / sizeof(ELF_RELOC);
- symtab = (Elf32_Sym *)(intptr_t)
- DL_RELOC_ADDR (tpnt->dynamic_info[DT_SYMTAB], tpnt->loadaddr);
- strtab = DL_RELOC_ADDR (tpnt->dynamic_info[DT_STRTAB], tpnt->loadaddr);
+ symtab = (ElfW(Sym) *) tpnt->dynamic_info[DT_SYMTAB];
+ strtab = (char *) tpnt->dynamic_info[DT_STRTAB];
- for (i = 0; i < rel_size; i++, rpnt++) {
+ for (i = 0; i < rel_size; i++, rpnt++) {
int res;
- symtab_index = ELF32_R_SYM(rpnt->r_info);
+ symtab_index = ELF_R_SYM(rpnt->r_info);
debug_sym(symtab,strtab,symtab_index);
debug_reloc(symtab,strtab,rpnt);
@@ -136,7 +124,7 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
if (res <0)
{
- int reloc_type = ELF32_R_TYPE(rpnt->r_info);
+ int reloc_type = ELF_R_TYPE(rpnt->r_info);
#if defined (__SUPPORT_LD_DEBUG__)
_dl_dprintf(2, "can't handle reloc type %s\n ", _dl_reltypes(reloc_type));
#else
@@ -154,8 +142,8 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
}
static int
-_dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
- ELF_RELOC *rpnt, Elf32_Sym *symtab, char *strtab)
+_dl_do_reloc (struct elf_resolve *tpnt,struct r_scope_elem *scope,
+ ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
{
int reloc_type;
int symtab_index;
@@ -169,24 +157,24 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
#if defined (__SUPPORT_LD_DEBUG__)
unsigned long old_val;
#endif
+ struct symbol_ref sym_ref;
- reloc_addr = (unsigned long *)(intptr_t)
- DL_RELOC_ADDR (rpnt->r_offset, tpnt->loadaddr);
+ reloc_addr = (unsigned long *) DL_RELOC_ADDR (tpnt->loadaddr, rpnt->r_offset);
__asm__ ("" : "=r" (reloc_addr_packed) : "0" (reloc_addr));
- reloc_type = ELF32_R_TYPE(rpnt->r_info);
- symtab_index = ELF32_R_SYM(rpnt->r_info);
+ reloc_type = ELF_R_TYPE(rpnt->r_info);
+ symtab_index = ELF_R_SYM(rpnt->r_info);
symbol_addr = 0;
+ sym_ref.sym = &symtab[symtab_index];
+ sym_ref.tpnt = NULL;
symname = strtab + symtab[symtab_index].st_name;
- if (ELF32_ST_BIND (symtab[symtab_index].st_info) == STB_LOCAL) {
- symbol_addr = (unsigned long)
- DL_RELOC_ADDR (symtab[symtab_index].st_value,
- tpnt->loadaddr);
+ if (ELF_ST_BIND (symtab[symtab_index].st_info) == STB_LOCAL) {
+ symbol_addr = (unsigned long) DL_RELOC_ADDR(tpnt->loadaddr, symtab[symtab_index].st_value);
symbol_tpnt = tpnt;
} else {
symbol_addr = (unsigned long)
- _dl_find_hash_mod(symname, scope, NULL, 0, &symbol_tpnt);
+ _dl_find_hash(symname, scope, NULL, 0, &sym_ref);
/*
* We want to allow undefined references to weak symbols - this might
@@ -194,11 +182,12 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
* here, so all bases should be covered.
*/
- if (!symbol_addr && ELF32_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK) {
+ if (!symbol_addr && ELF_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK) {
_dl_dprintf (2, "%s: can't resolve symbol '%s'\n",
_dl_progname, strtab + symtab[symtab_index].st_name);
_dl_exit (1);
}
+ symbol_tpnt = sym_ref.tpnt;
}
#if defined (__SUPPORT_LD_DEBUG__)
@@ -228,7 +217,7 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
symbols must be ignored, because it
may hold the address of a lazy PLT
entry. */
- if (ELF32_ST_BIND
+ if (ELF_ST_BIND
(symtab[symtab_index].st_info)
== STB_LOCAL)
funcval.entry_point += *reloc_addr;
@@ -284,9 +273,9 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
static int
_dl_do_lazy_reloc (struct elf_resolve *tpnt,
- struct dyn_elf *scope __attribute_used__,
- ELF_RELOC *rpnt, Elf32_Sym *symtab __attribute_used__,
- char *strtab __attribute_used__)
+ struct r_scope_elem *scope __attribute__((unused)),
+ ELF_RELOC *rpnt, ElfW(Sym) *symtab __attribute__((unused)),
+ char *strtab __attribute__((unused)))
{
int reloc_type;
struct funcdesc_value volatile *reloc_addr;
@@ -296,8 +285,8 @@ _dl_do_lazy_reloc (struct elf_resolve *tpnt,
#endif
reloc_addr = (struct funcdesc_value *)(intptr_t)
- DL_RELOC_ADDR (rpnt->r_offset, tpnt->loadaddr);
- reloc_type = ELF32_R_TYPE(rpnt->r_info);
+ DL_RELOC_ADDR (tpnt->loadaddr, rpnt->r_offset);
+ reloc_type = ELF_R_TYPE(rpnt->r_info);
#if defined (__SUPPORT_LD_DEBUG__)
old_val = (unsigned long)reloc_addr->entry_point;
@@ -307,9 +296,7 @@ _dl_do_lazy_reloc (struct elf_resolve *tpnt,
break;
case R_FRV_FUNCDESC_VALUE:
funcval = *reloc_addr;
- funcval.entry_point =
- DL_RELOC_ADDR (funcval.entry_point,
- tpnt->loadaddr);
+ funcval.entry_point = (void *) DL_RELOC_ADDR(tpnt->loadaddr, funcval.entry_point);
funcval.got_value = tpnt->loadaddr.got_value;
*reloc_addr = funcval;
break;
@@ -318,7 +305,7 @@ _dl_do_lazy_reloc (struct elf_resolve *tpnt,
}
#if defined (__SUPPORT_LD_DEBUG__)
if (_dl_debug_reloc && _dl_debug_detail)
- _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x", old_val, reloc_addr->entry_point, reloc_addr);
+ _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x\n", old_val, reloc_addr->entry_point, reloc_addr);
#endif
return 0;
@@ -333,23 +320,23 @@ _dl_parse_lazy_relocation_information
int
_dl_parse_relocation_information
-(struct dyn_elf *rpnt, unsigned long rel_addr, unsigned long rel_size)
+(struct dyn_elf *rpnt, struct r_scope_elem *scope, unsigned long rel_addr, unsigned long rel_size)
{
- return _dl_parse(rpnt->dyn, rpnt->dyn->symbol_scope, rel_addr, rel_size, _dl_do_reloc);
+ return _dl_parse(rpnt->dyn, scope, rel_addr, rel_size, _dl_do_reloc);
}
/* We don't have copy relocs. */
int
_dl_parse_copy_information
-(struct dyn_elf *rpnt __attribute_used__,
- unsigned long rel_addr __attribute_used__,
- unsigned long rel_size __attribute_used__)
+(struct dyn_elf *rpnt __attribute__((unused)),
+ unsigned long rel_addr __attribute__((unused)),
+ unsigned long rel_size __attribute__((unused)))
{
return 0;
}
-#ifndef LIBDL
+#ifndef IS_IN_libdl
# include "../../libc/sysdeps/linux/frv/crtreloc.c"
#endif
diff --git a/ldso/ldso/h8300/dl-sysdep.h b/ldso/ldso/h8300/dl-sysdep.h
new file mode 100644
index 000000000..880d0484e
--- /dev/null
+++ b/ldso/ldso/h8300/dl-sysdep.h
@@ -0,0 +1 @@
+/* dl not supported */
diff --git a/ldso/ldso/i386/dl-debug.h b/ldso/ldso/i386/dl-debug.h
index 72a01f8df..82baf1fcc 100644
--- a/ldso/ldso/i386/dl-debug.h
+++ b/ldso/ldso/i386/dl-debug.h
@@ -29,7 +29,7 @@
* SUCH DAMAGE.
*/
-static const char *_dl_reltypes_tab[] = {
+static const char * const _dl_reltypes_tab[] = {
[0] "R_386_NONE", "R_386_32", "R_386_PC32", "R_386_GOT32",
[4] "R_386_PLT32", "R_386_COPY", "R_386_GLOB_DAT", "R_386_JMP_SLOT",
[8] "R_386_RELATIVE", "R_386_GOTOFF", "R_386_GOTPC",
diff --git a/ldso/ldso/i386/dl-startup.h b/ldso/ldso/i386/dl-startup.h
index 45f69b85d..125132c87 100644
--- a/ldso/ldso/i386/dl-startup.h
+++ b/ldso/ldso/i386/dl-startup.h
@@ -7,6 +7,7 @@ __asm__ (
" .text\n"
" .globl _start\n"
" .type _start,@function\n"
+ " .hidden _start\n"
"_start:\n"
" call _dl_start\n"
" # Save the user entry point address in %edi.\n"
@@ -35,7 +36,7 @@ __asm__ (
);
/* Get a pointer to the argv array. On many platforms this can be just
- * the address if the first argument, on other platforms we need to
+ * the address of the first argument, on other platforms we need to
* do something a little more subtle here. */
#define GET_ARGV(ARGVP, ARGS) ARGVP = (((unsigned long*) & ARGS)+1)
@@ -44,7 +45,7 @@ static __always_inline
void PERFORM_BOOTSTRAP_RELOC(ELF_RELOC *rpnt, unsigned long *reloc_addr,
unsigned long symbol_addr, unsigned long load_addr, attribute_unused Elf32_Sym *symtab)
{
- switch (ELF32_R_TYPE(rpnt->r_info))
+ switch (ELF_R_TYPE(rpnt->r_info))
{
case R_386_32:
*reloc_addr += symbol_addr;
diff --git a/ldso/ldso/i386/dl-syscalls.h b/ldso/ldso/i386/dl-syscalls.h
index 996bb87c6..f40c4fd31 100644
--- a/ldso/ldso/i386/dl-syscalls.h
+++ b/ldso/ldso/i386/dl-syscalls.h
@@ -1,6 +1 @@
-/* We can't use the real errno in ldso, since it has not yet
- * been dynamicly linked in yet. */
-#include "sys/syscall.h"
-extern int _dl_errno;
-#undef __set_errno
-#define __set_errno(X) {(_dl_errno) = (X);}
+/* stub for arch-specific syscall issues */
diff --git a/ldso/ldso/i386/dl-sysdep.h b/ldso/ldso/i386/dl-sysdep.h
index 7090c929d..8efa1a832 100644
--- a/ldso/ldso/i386/dl-sysdep.h
+++ b/ldso/ldso/i386/dl-sysdep.h
@@ -25,48 +25,42 @@ do { \
struct elf_resolve;
extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
-/* 4096 bytes alignment */
-#define PAGE_ALIGN 0xfffff000
-#define ADDR_ALIGN 0xfff
-#define OFFS_ALIGN 0x7ffff000
-
/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry or
TLS variable, so undefined references should not be allowed to
define the value.
ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one
of the main executable's symbols, as for a COPY reloc. */
#define elf_machine_type_class(type) \
- ((((type) == R_386_JMP_SLOT) * ELF_RTYPE_CLASS_PLT) \
+ ((((type) == R_386_JMP_SLOT || (type) == R_386_TLS_DTPMOD32 \
+ || (type) == R_386_TLS_DTPOFF32 || (type) == R_386_TLS_TPOFF32 \
+ || (type) == R_386_TLS_TPOFF) * ELF_RTYPE_CLASS_PLT) \
| (((type) == R_386_COPY) * ELF_RTYPE_CLASS_COPY))
/* Return the link-time address of _DYNAMIC. Conveniently, this is the
- first element of the GOT. This must be inlined in a function which
- uses global data. */
-static __inline__ Elf32_Addr elf_machine_dynamic (void) attribute_unused;
-static __inline__ Elf32_Addr
+ first element of the GOT, a special entry that is never relocated. */
+extern const Elf32_Addr _GLOBAL_OFFSET_TABLE_[] attribute_hidden;
+static __always_inline Elf32_Addr __attribute__ ((unused, const))
elf_machine_dynamic (void)
{
- register Elf32_Addr *got __asm__ ("%ebx");
- return *got;
+ /* This produces a GOTOFF reloc that resolves to zero at link time, so in
+ fact just loads from the GOT register directly. By doing it without
+ an asm we can let the compiler choose any register. */
+ return _GLOBAL_OFFSET_TABLE_[0];
}
+extern Elf32_Dyn bygotoff[] __asm__ ("_DYNAMIC") attribute_hidden;
/* Return the run-time load address of the shared object. */
-static __inline__ Elf32_Addr elf_machine_load_address (void) attribute_unused;
-static __inline__ Elf32_Addr
+static __always_inline Elf32_Addr attribute_unused
elf_machine_load_address (void)
{
- /* It doesn't matter what variable this is, the reference never makes
- it to assembly. We need a dummy reference to some global variable
- via the GOT to make sure the compiler initialized %ebx in time. */
- Elf32_Addr addr;
- __asm__ ("leal _dl_start@GOTOFF(%%ebx), %0\n"
- "subl _dl_start@GOT(%%ebx), %0"
- : "=r" (addr) : "m" (_dl_errno) : "cc");
- return addr;
+ /* Compute the difference between the runtime address of _DYNAMIC as seen
+ by a GOTOFF reference, and the link-time address found in the special
+ unrelocated first GOT entry. */
+ return (Elf32_Addr) &bygotoff - elf_machine_dynamic ();
}
-static __inline__ void
+static __always_inline void
elf_machine_relative (Elf32_Addr load_off, const Elf32_Addr rel_addr,
Elf32_Word relative_count)
{
diff --git a/ldso/ldso/i386/elfinterp.c b/ldso/ldso/i386/elfinterp.c
index 62e854d87..aadb00add 100644
--- a/ldso/ldso/i386/elfinterp.c
+++ b/ldso/ldso/i386/elfinterp.c
@@ -47,10 +47,9 @@ extern int _dl_linux_resolve(void);
unsigned long
_dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
{
- int reloc_type;
ELF_RELOC *this_reloc;
char *strtab;
- Elf32_Sym *symtab;
+ ElfW(Sym) *symtab;
int symtab_index;
char *rel_addr;
char *new_addr;
@@ -60,10 +59,9 @@ _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
rel_addr = (char *)tpnt->dynamic_info[DT_JMPREL];
this_reloc = (ELF_RELOC *)(intptr_t)(rel_addr + reloc_entry);
- reloc_type = ELF32_R_TYPE(this_reloc->r_info);
- symtab_index = ELF32_R_SYM(this_reloc->r_info);
+ symtab_index = ELF_R_SYM(this_reloc->r_info);
- symtab = (Elf32_Sym *)(intptr_t)tpnt->dynamic_info[DT_SYMTAB];
+ symtab = (ElfW(Sym) *)(intptr_t)tpnt->dynamic_info[DT_SYMTAB];
strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
symname = strtab + symtab[symtab_index].st_name;
@@ -73,7 +71,7 @@ _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
got_addr = (char **)instr_addr;
/* Get the address of the GOT entry. */
- new_addr = _dl_find_hash(symname, tpnt->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT);
+ new_addr = _dl_find_hash(symname, &_dl_loaded_modules->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT, NULL);
if (unlikely(!new_addr)) {
_dl_dprintf(2, "%s: can't resolve symbol '%s' in lib '%s'.\n", _dl_progname, symname, tpnt->libname);
_dl_exit(1);
@@ -100,14 +98,14 @@ _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
}
static int
-_dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
+_dl_parse(struct elf_resolve *tpnt, struct r_scope_elem *scope,
unsigned long rel_addr, unsigned long rel_size,
- int (*reloc_fnc)(struct elf_resolve *tpnt, struct dyn_elf *scope,
- ELF_RELOC *rpnt, Elf32_Sym *symtab, char *strtab))
+ int (*reloc_fnc)(struct elf_resolve *tpnt, struct r_scope_elem *scope,
+ ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab))
{
unsigned int i;
char *strtab;
- Elf32_Sym *symtab;
+ ElfW(Sym) *symtab;
ELF_RELOC *rpnt;
int symtab_index;
@@ -115,13 +113,13 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
rpnt = (ELF_RELOC *)(intptr_t)rel_addr;
rel_size /= sizeof(ELF_RELOC);
- symtab = (Elf32_Sym *)(intptr_t)tpnt->dynamic_info[DT_SYMTAB];
+ symtab = (ElfW(Sym) *)(intptr_t)tpnt->dynamic_info[DT_SYMTAB];
strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
for (i = 0; i < rel_size; i++, rpnt++) {
int res;
- symtab_index = ELF32_R_SYM(rpnt->r_info);
+ symtab_index = ELF_R_SYM(rpnt->r_info);
debug_sym(symtab, strtab, symtab_index);
debug_reloc(symtab, strtab, rpnt);
@@ -138,7 +136,7 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
strtab + symtab[symtab_index].st_name);
if (unlikely(res < 0)) {
- int reloc_type = ELF32_R_TYPE(rpnt->r_info);
+ int reloc_type = ELF_R_TYPE(rpnt->r_info);
#if defined (__SUPPORT_LD_DEBUG__)
_dl_dprintf(2, "can't handle reloc type '%s' in lib '%s'\n",
@@ -158,37 +156,50 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
}
static int
-_dl_do_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
- ELF_RELOC *rpnt, Elf32_Sym *symtab, char *strtab)
+_dl_do_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
+ ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
{
int reloc_type;
int symtab_index;
char *symname;
+ struct elf_resolve *tls_tpnt = NULL;
unsigned long *reloc_addr;
unsigned long symbol_addr;
#if defined (__SUPPORT_LD_DEBUG__)
unsigned long old_val;
#endif
+ struct symbol_ref sym_ref;
reloc_addr = (unsigned long *)(intptr_t)(tpnt->loadaddr + (unsigned long)rpnt->r_offset);
- reloc_type = ELF32_R_TYPE(rpnt->r_info);
- symtab_index = ELF32_R_SYM(rpnt->r_info);
+ reloc_type = ELF_R_TYPE(rpnt->r_info);
+ symtab_index = ELF_R_SYM(rpnt->r_info);
symbol_addr = 0;
+ sym_ref.sym = &symtab[symtab_index];
+ sym_ref.tpnt = NULL;
symname = strtab + symtab[symtab_index].st_name;
if (symtab_index) {
symbol_addr = (unsigned long)_dl_find_hash(symname, scope, tpnt,
- elf_machine_type_class(reloc_type));
+ elf_machine_type_class(reloc_type), &sym_ref);
/*
* We want to allow undefined references to weak symbols - this
* might have been intentional. We should not be linking local
* symbols here, so all bases should be covered.
*/
- if (unlikely(!symbol_addr && ELF32_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK))
+ if (unlikely(!symbol_addr && (ELF_ST_TYPE(symtab[symtab_index].st_info) != STT_TLS)
+ && ELF_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK))
return 1;
+ if (_dl_trace_prelink) {
+ _dl_debug_lookup (symname, tpnt, &symtab[symtab_index],
+ &sym_ref, elf_machine_type_class(reloc_type));
+ }
+ tls_tpnt = sym_ref.tpnt;
+ } else {
+ symbol_addr = symtab[symtab_index].st_value;
+ tls_tpnt = tpnt;
}
-
+
#if defined (__SUPPORT_LD_DEBUG__)
old_val = *reloc_addr;
#endif
@@ -224,13 +235,33 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
symtab[symtab_index].st_size);
}
break;
+#if defined USE_TLS && USE_TLS
+ case R_386_TLS_DTPMOD32:
+ *reloc_addr = tls_tpnt->l_tls_modid;
+ break;
+ case R_386_TLS_DTPOFF32:
+ /* During relocation all TLS symbols are defined and used.
+ * Therefore the offset is already correct. */
+ *reloc_addr = symbol_addr;
+ break;
+ case R_386_TLS_TPOFF32:
+ /* The offset is positive, backward from the thread pointer. */
+ CHECK_STATIC_TLS((struct link_map*) tls_tpnt);
+ *reloc_addr += tls_tpnt->l_tls_offset - symbol_addr;
+ break;
+ case R_386_TLS_TPOFF:
+ /* The offset is negative, forward from the thread pointer. */
+ CHECK_STATIC_TLS((struct link_map*) tls_tpnt);
+ *reloc_addr += symbol_addr - tls_tpnt->l_tls_offset;
+ break;
+#endif
default:
return -1;
}
#if defined (__SUPPORT_LD_DEBUG__)
if (_dl_debug_reloc && _dl_debug_detail)
- _dl_dprintf(_dl_debug_file, "\n\tpatched: %x ==> %x @ %x",
+ _dl_dprintf(_dl_debug_file, "\n\tpatched: %x ==> %x @ %x\n",
old_val, *reloc_addr, reloc_addr);
#endif
@@ -238,8 +269,8 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
}
static int
-_dl_do_lazy_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
- ELF_RELOC *rpnt, Elf32_Sym *symtab, char *strtab)
+_dl_do_lazy_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
+ ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
{
int reloc_type;
unsigned long *reloc_addr;
@@ -252,7 +283,7 @@ _dl_do_lazy_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
(void)strtab;
reloc_addr = (unsigned long *)(intptr_t)(tpnt->loadaddr + (unsigned long)rpnt->r_offset);
- reloc_type = ELF32_R_TYPE(rpnt->r_info);
+ reloc_type = ELF_R_TYPE(rpnt->r_info);
#if defined (__SUPPORT_LD_DEBUG__)
old_val = *reloc_addr;
@@ -270,7 +301,7 @@ _dl_do_lazy_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
#if defined (__SUPPORT_LD_DEBUG__)
if (_dl_debug_reloc && _dl_debug_detail)
- _dl_dprintf(_dl_debug_file, "\n\tpatched: %x ==> %x @ %x",
+ _dl_dprintf(_dl_debug_file, "\n\tpatched: %x ==> %x @ %x\n",
old_val, *reloc_addr, reloc_addr);
#endif
@@ -287,8 +318,9 @@ _dl_parse_lazy_relocation_information(struct dyn_elf *rpnt,
int
_dl_parse_relocation_information(struct dyn_elf *rpnt,
+ struct r_scope_elem *scope,
unsigned long rel_addr,
unsigned long rel_size)
{
- return _dl_parse(rpnt->dyn, rpnt->dyn->symbol_scope, rel_addr, rel_size, _dl_do_reloc);
+ return _dl_parse(rpnt->dyn, scope, rel_addr, rel_size, _dl_do_reloc);
}
diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c
index df7477c72..9f4e84130 100644
--- a/ldso/ldso/ldso.c
+++ b/ldso/ldso/ldso.c
@@ -38,38 +38,55 @@
#define ALLOW_ZERO_PLTGOT
+#if defined(USE_TLS) && USE_TLS
+#include "dl-tls.c"
+#endif
+
/* Pull in the value of _dl_progname */
#include LDSO_ELFINTERP
/* Global variables used within the shared library loader */
-char *_dl_library_path = 0; /* Where we look for libraries */
-char *_dl_preload = 0; /* Things to be loaded before the libs */
-char *_dl_ldsopath = 0; /* Location of the shared lib loader */
-int _dl_secure = 1; /* Are we dealing with setuid stuff? */
+#ifdef __LDSO_LD_LIBRARY_PATH__
+char *_dl_library_path = NULL; /* Where we look for libraries */
+#endif
+#ifdef __LDSO_PRELOAD_ENV_SUPPORT__
+char *_dl_preload = NULL; /* Things to be loaded before the libs */
+#endif
int _dl_errno = 0; /* We can't use the real errno in ldso */
size_t _dl_pagesize = 0; /* Store the page size for use later */
struct r_debug *_dl_debug_addr = NULL; /* Used to communicate with the gdb debugger */
void *(*_dl_malloc_function) (size_t size) = NULL;
void (*_dl_free_function) (void *p) = NULL;
+#ifdef __LDSO_PRELINK_SUPPORT__
+char *_dl_trace_prelink = NULL; /* Library for prelinking trace */
+struct elf_resolve *_dl_trace_prelink_map = NULL; /* Library module for prelinking trace */
+bool _dl_verbose = true; /* On by default */
+bool prelinked = false;
+#endif
+int _dl_secure = 1; /* Are we dealing with setuid stuff? */
+
#ifdef __SUPPORT_LD_DEBUG__
-char *_dl_debug = 0;
-char *_dl_debug_symbols = 0;
-char *_dl_debug_move = 0;
-char *_dl_debug_reloc = 0;
-char *_dl_debug_detail = 0;
-char *_dl_debug_nofixups = 0;
-char *_dl_debug_bindings = 0;
+char *_dl_debug = NULL;
+char *_dl_debug_symbols = NULL;
+char *_dl_debug_move = NULL;
+char *_dl_debug_reloc = NULL;
+char *_dl_debug_detail = NULL;
+char *_dl_debug_nofixups = NULL;
+char *_dl_debug_bindings = NULL;
int _dl_debug_file = 2;
#endif
-/* Needed for standalone execution. */
+#ifdef __DSBT__
+void **_dl_ldso_dsbt = NULL;
+#endif
+
unsigned long attribute_hidden _dl_skip_args = 0;
+
const char *_dl_progname = UCLIBC_LDSO; /* The name of the executable being run */
#include "dl-startup.c"
+#include "dl-symbols.c"
#include "dl-array.c"
-/* Forward function declarations */
-static int _dl_suid_ok(void);
/*
* This stub function is used by some debuggers. The idea is that they
@@ -87,28 +104,199 @@ void _dl_debug_state(void)
}
rtld_hidden_def(_dl_debug_state);
-static unsigned char *_dl_malloc_addr = 0; /* Lets _dl_malloc use the already allocated memory page */
-static unsigned char *_dl_mmap_zero = 0; /* Also used by _dl_malloc */
+static unsigned char *_dl_malloc_addr = NULL; /* Lets _dl_malloc use the already allocated memory page */
+static unsigned char *_dl_mmap_zero = NULL; /* Also used by _dl_malloc */
static struct elf_resolve **init_fini_list;
+static struct elf_resolve **scope_elem_list;
static unsigned int nlist; /* # items in init_fini_list */
extern void _start(void);
#ifdef __UCLIBC_HAS_SSP__
# include <dl-osinfo.h>
-uintptr_t stack_chk_guard;
+static uintptr_t stack_chk_guard;
# ifndef THREAD_SET_STACK_GUARD
/* Only exported for architectures that don't store the stack guard canary
* in local thread area. */
uintptr_t __stack_chk_guard attribute_relro;
-# ifdef __UCLIBC_HAS_SSP_COMPAT__
-strong_alias(__stack_chk_guard,__guard)
-# endif
-# elif __UCLIBC_HAS_SSP_COMPAT__
+# endif
+# ifdef __UCLIBC_HAS_SSP_COMPAT__
uintptr_t __guard attribute_relro;
# endif
#endif
+#ifdef __LDSO_SEARCH_INTERP_PATH__
+const char *_dl_ldsopath = NULL; /* Location of the shared lib loader */
+
+static void _dl_ldsopath_init(struct elf_resolve *tpnt)
+{
+ char *ldsopath, *ptmp;
+
+ /*
+ * Store the path where the shared lib loader was found for later use.
+ * Note that this logic isn't bullet proof when it comes to relative
+ * paths: if you use "./lib/ldso.so", and then the app does chdir()
+ * followed by dlopen(), the old ldso path won't get searched. But
+ * that is a fairly pathological use case, so if you don't like that,
+ * then set a full path to your interp and be done :P.
+ */
+ ldsopath = _dl_strdup(tpnt->libname);
+ ptmp = _dl_strrchr(ldsopath, '/');
+ /*
+ * If there is no "/", then set the path to "", and the code
+ * later on will take this to implicitly mean "search $PWD".
+ */
+ if (!ptmp)
+ ptmp = ldsopath;
+ *ptmp = '\0';
+
+ _dl_ldsopath = ldsopath;
+ _dl_debug_early("Lib Loader: (%x) %s: using path: %s\n",
+ (unsigned) DL_LOADADDR_BASE(tpnt->loadaddr), tpnt->libname,
+ _dl_ldsopath);
+}
+#else
+#define _dl_ldsopath_init(tpnt)
+#endif
+
+char *_dl_getenv(const char *symbol, char **envp)
+{
+ char *pnt;
+ const char *pnt1;
+
+ while ((pnt = *envp++)) {
+ pnt1 = symbol;
+ while (*pnt && *pnt == *pnt1)
+ pnt1++, pnt++;
+ if (!*pnt || *pnt != '=' || *pnt1)
+ continue;
+ return pnt + 1;
+ }
+ return 0;
+}
+
+void _dl_unsetenv(const char *symbol, char **envp)
+{
+ char *pnt;
+ const char *pnt1;
+ char **newenvp = envp;
+
+ for (pnt = *envp; pnt; pnt = *++envp) {
+ pnt1 = symbol;
+ while (*pnt && *pnt == *pnt1)
+ pnt1++, pnt++;
+ if (!*pnt || *pnt != '=' || *pnt1)
+ *newenvp++ = *envp;
+ }
+ *newenvp++ = *envp;
+ return;
+}
+
+static int _dl_suid_ok(void)
+{
+ __kernel_uid_t uid, euid;
+ __kernel_gid_t gid, egid;
+
+ uid = _dl_getuid();
+ euid = _dl_geteuid();
+ gid = _dl_getgid();
+ egid = _dl_getegid();
+
+ if (uid == euid && gid == egid) {
+ return 1;
+ }
+ return 0;
+}
+
+void *_dl_malloc(size_t size)
+{
+ void *retval;
+
+#if 0
+ _dl_debug_early("request for %d bytes\n", size);
+#endif
+
+ if (_dl_malloc_function)
+ return (*_dl_malloc_function) (size);
+
+ if (_dl_malloc_addr - _dl_mmap_zero + size > _dl_pagesize) {
+ size_t rounded_size;
+
+ /* Since the above assumes we get a full page even if
+ we request less than that, make sure we request a
+ full page, since uClinux may give us less than than
+ a full page. We might round even
+ larger-than-a-page sizes, but we end up never
+ reusing _dl_mmap_zero/_dl_malloc_addr in that case,
+ so we don't do it.
+
+ The actual page size doesn't really matter; as long
+ as we're self-consistent here, we're safe. */
+ if (size < _dl_pagesize)
+ rounded_size = (size + ADDR_ALIGN) & _dl_pagesize;
+ else
+ rounded_size = size;
+
+ _dl_debug_early("mmapping more memory\n");
+ _dl_mmap_zero = _dl_malloc_addr = _dl_mmap((void *) 0, rounded_size,
+ PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_UNINITIALIZED, -1, 0);
+ if (_dl_mmap_check_error(_dl_mmap_zero)) {
+ _dl_dprintf(2, "%s: mmap of a spare page failed!\n", _dl_progname);
+ _dl_exit(20);
+ }
+ }
+ retval = _dl_malloc_addr;
+ _dl_malloc_addr += size;
+
+ /*
+ * Align memory to DL_MALLOC_ALIGN byte boundary. Some
+ * platforms require this, others simply get better
+ * performance.
+ */
+ _dl_malloc_addr = (unsigned char *) (((unsigned long) _dl_malloc_addr + DL_MALLOC_ALIGN - 1) & ~(DL_MALLOC_ALIGN - 1));
+ return retval;
+}
+
+static void *_dl_zalloc(size_t size)
+{
+ void *p = _dl_malloc(size);
+ if (p)
+ _dl_memset(p, 0, size);
+ return p;
+}
+
+void _dl_free(void *p)
+{
+ if (_dl_free_function)
+ (*_dl_free_function) (p);
+}
+
+#if defined(USE_TLS) && USE_TLS
+void *_dl_memalign(size_t __boundary, size_t __size)
+{
+ void *result;
+ int i = 0;
+ size_t delta;
+ size_t rounded = 0;
+
+ if (_dl_memalign_function)
+ return (*_dl_memalign_function) (__boundary, __size);
+
+ while (rounded < __boundary) {
+ rounded = (1 << i++);
+ }
+
+ delta = (((size_t) _dl_malloc_addr + __size) & (rounded - 1));
+
+ if ((result = _dl_malloc(rounded - delta)) == NULL)
+ return result;
+
+ result = _dl_malloc(__size);
+
+ return result;
+}
+#endif
+
static void __attribute__ ((destructor)) __attribute_used__ _dl_fini(void)
{
unsigned int i;
@@ -130,20 +318,119 @@ static void __attribute__ ((destructor)) __attribute_used__ _dl_fini(void)
}
}
-void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
- ElfW(auxv_t) auxvt[AT_EGID + 1], char **envp,
- char **argv
+#ifdef __LDSO_PRELINK_SUPPORT__
+static void trace_objects(struct elf_resolve *tpnt, char *str_name)
+{
+ if (_dl_strcmp(_dl_trace_prelink, tpnt->libname) == 0)
+ _dl_trace_prelink_map = tpnt;
+ if (tpnt->libtype == elf_executable) {
+/* Main executeble */
+ _dl_dprintf(1, "\t%s => %s (%x, %x)", tpnt->libname, tpnt->libname,
+ tpnt->mapaddr, DL_LOADADDR_BASE(tpnt->loadaddr));
+ } else {
+/* Preloaded, Needed or interpreter */
+ _dl_dprintf(1, "\t%s => %s (%x, %x)", str_name, tpnt->libname,
+ tpnt->mapaddr, DL_LOADADDR_BASE(tpnt->loadaddr));
+ }
+
+#if defined USE_TLS && USE_TLS
+ if ((tpnt->libtype != program_interpreter) && (tpnt->l_tls_modid))
+ _dl_dprintf (1, " TLS(%x, %x)\n", tpnt->l_tls_modid,
+ (size_t) tpnt->l_tls_offset);
+ else
+#endif
+ _dl_dprintf (1, "\n");
+}
+#endif
+
+static struct elf_resolve * add_ldso(struct elf_resolve *tpnt,
+ DL_LOADADDR_TYPE load_addr,
+ ElfW(Addr) ldso_mapaddr,
+ ElfW(auxv_t) auxvt[AT_EGID + 1],
+ struct dyn_elf *rpnt)
+{
+ ElfW(Ehdr) *epnt = (ElfW(Ehdr) *) auxvt[AT_BASE].a_un.a_val;
+ ElfW(Phdr) *myppnt = (ElfW(Phdr) *)
+ DL_RELOC_ADDR(DL_GET_RUN_ADDR(load_addr, ldso_mapaddr),
+ epnt->e_phoff);
+ int j;
+ struct stat st;
+
+ tpnt = _dl_add_elf_hash_table(tpnt->libname, tpnt->loadaddr,
+ tpnt->dynamic_info, (unsigned long)tpnt->dynamic_addr,
+ 0);
+
+ tpnt->mapaddr = ldso_mapaddr;
+ if (_dl_stat(tpnt->libname, &st) >= 0) {
+ tpnt->st_dev = st.st_dev;
+ tpnt->st_ino = st.st_ino;
+ }
+ tpnt->n_phent = epnt->e_phnum;
+ tpnt->ppnt = myppnt;
+ for (j = 0; j < epnt->e_phnum; j++, myppnt++) {
+ if (myppnt->p_type == PT_GNU_RELRO) {
+ tpnt->relro_addr = myppnt->p_vaddr;
+ tpnt->relro_size = myppnt->p_memsz;
+ break;
+ }
+ }
+ tpnt->libtype = program_interpreter;
+ if (rpnt) {
+ rpnt->next = _dl_zalloc(sizeof(struct dyn_elf));
+ rpnt->next->prev = rpnt;
+ rpnt = rpnt->next;
+ } else {
+ rpnt = _dl_zalloc(sizeof(struct dyn_elf));
+ }
+ rpnt->dyn = tpnt;
+ tpnt->rtld_flags = RTLD_NOW | RTLD_GLOBAL; /* Must not be LAZY */
+
+ return tpnt;
+}
+
+static ptrdiff_t _dl_build_local_scope (struct elf_resolve **list,
+ struct elf_resolve *map)
+{
+ struct elf_resolve **p = list;
+ struct init_fini_list *q;
+
+ *p++ = map;
+ map->init_flag |= DL_RESERVED;
+ if (map->init_fini)
+ for (q = map->init_fini; q; q = q->next)
+ if (! (q->tpnt->init_flag & DL_RESERVED))
+ p += _dl_build_local_scope (p, q->tpnt);
+ return p - list;
+}
+
+static void _dl_setup_progname(const char *argv0)
+{
+ char image[PATH_MAX];
+ ssize_t s;
+
+ s = _dl_readlink(AT_FDCWD, "/proc/self/exe", image, sizeof(image));
+ if (s > 0 && image[0] == '/') {
+ image[s] = 0;
+ _dl_progname = _dl_strdup(image);
+ } else if (argv0) {
+ _dl_progname = argv0;
+ }
+}
+
+void *_dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
+ ElfW(auxv_t) auxvt[AT_EGID + 1], char **envp, char **argv
DL_GET_READY_TO_RUN_EXTRA_PARMS)
{
- ElfW(Addr) app_mapaddr = 0;
+ ElfW(Addr) app_mapaddr = 0, ldso_mapaddr = 0;
ElfW(Phdr) *ppnt;
ElfW(Dyn) *dpnt;
char *lpntstr;
- unsigned int i;
+ unsigned int i, cnt, nscope_elem;
int unlazy = 0, trace_loaded_objects = 0;
struct dyn_elf *rpnt;
struct elf_resolve *tcurr;
struct elf_resolve *tpnt1;
+ struct elf_resolve *ldso_tpnt = NULL;
struct elf_resolve app_tpnt_tmp;
struct elf_resolve *app_tpnt = &app_tpnt_tmp;
struct r_debug *debug_addr;
@@ -151,13 +438,18 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
unsigned long *_dl_envp; /* The environment address */
ElfW(Addr) relro_addr = 0;
size_t relro_size = 0;
- struct stat st;
+ struct r_scope_elem *global_scope;
+ struct elf_resolve **local_scope;
+
+#if defined(USE_TLS) && USE_TLS
+ void *tcbp = NULL;
+#endif
/* Wahoo!!! We managed to make a function call! Get malloc
* setup so we can use _dl_dprintf() to print debug noise
* instead of the SEND_STDERR macros used in dl-startup.c */
- _dl_memset(app_tpnt, 0x00, sizeof(*app_tpnt));
+ _dl_memset(app_tpnt, 0, sizeof(*app_tpnt));
/* Store the page size for later use */
_dl_pagesize = (auxvt[AT_PAGESZ].a_un.a_val) ? (size_t) auxvt[AT_PAGESZ].a_un.a_val : PAGE_SIZE;
@@ -176,14 +468,19 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
* been fixed up by now. Still no function calls outside of this
* library, since the dynamic resolver is not yet ready.
*/
- if (argv[0]) {
- _dl_progname = argv[0];
- }
+ _dl_setup_progname(argv[0]);
+
+#ifdef __DSBT__
+ _dl_ldso_dsbt = (void *)tpnt->dynamic_info[DT_DSBT_BASE_IDX];
+ _dl_ldso_dsbt[tpnt->dynamic_info[DT_DSBT_INDEX_IDX]] = _dl_ldso_dsbt;
+#endif
+#ifndef __LDSO_STANDALONE_SUPPORT__
if (_start == (void *) auxvt[AT_ENTRY].a_un.a_val) {
- _dl_dprintf(_dl_debug_file, "Standalone execution is not supported yet\n");
+ _dl_dprintf(2, "Standalone execution is not enabled\n");
_dl_exit(1);
}
+#endif
/* Start to build the tables of the modules that are required for
* this beast to run. We start with the basic executable, and then
@@ -203,8 +500,12 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
auxvt[AT_UID].a_un.a_val == auxvt[AT_EUID].a_un.a_val &&
auxvt[AT_GID].a_un.a_val == auxvt[AT_EGID].a_un.a_val)) {
_dl_secure = 0;
+#ifdef __LDSO_PRELOAD_ENV_SUPPORT__
_dl_preload = _dl_getenv("LD_PRELOAD", envp);
+#endif
+#ifdef __LDSO_LD_LIBRARY_PATH__
_dl_library_path = _dl_getenv("LD_LIBRARY_PATH", envp);
+#endif
} else {
static const char unsecure_envvars[] =
#ifdef EXTRA_UNSECURE_ENVVARS
@@ -214,30 +515,112 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
const char *nextp;
_dl_secure = 1;
+#ifdef __LDSO_PRELOAD_ENV_SUPPORT__
+ _dl_preload = _dl_getenv("LD_PRELOAD", envp);
+#endif
nextp = unsecure_envvars;
do {
_dl_unsetenv (nextp, envp);
/* We could use rawmemchr but this need not be fast. */
- nextp = (char *) _dl_strchr(nextp, '\0') + 1;
+ nextp = _dl_strchr(nextp, '\0') + 1;
} while (*nextp != '\0');
- _dl_preload = NULL;
+#ifdef __LDSO_LD_LIBRARY_PATH__
_dl_library_path = NULL;
+#endif
/* SUID binaries can be exploited if they do LAZY relocation. */
unlazy = RTLD_NOW;
}
- /* sjhill: your TLS init should go before this */
-#ifdef __UCLIBC_HAS_SSP__
- /* Set up the stack checker's canary. */
- stack_chk_guard = _dl_setup_stack_chk_guard ();
-# ifdef THREAD_SET_STACK_GUARD
- THREAD_SET_STACK_GUARD (stack_chk_guard);
-# ifdef __UCLIBC_HAS_SSP_COMPAT__
- __guard = stack_chk_guard;
-# endif
-# else
- __stack_chk_guard = stack_chk_guard;
-# endif
+#if defined(USE_TLS) && USE_TLS
+ _dl_error_catch_tsd = &_dl_initial_error_catch_tsd;
+ _dl_init_static_tls = &_dl_nothread_init_static_tls;
+#endif
+
+#ifdef __LDSO_STANDALONE_SUPPORT__
+ if (_start == (void *) auxvt[AT_ENTRY].a_un.a_val) {
+ ElfW(Addr) *aux_dat = (ElfW(Addr) *) argv;
+ int argc = (int) aux_dat[-1];
+
+ tpnt->libname = argv[0];
+ while (argc > 1)
+ if (! _dl_strcmp (argv[1], "--library-path") && argc > 2) {
+#ifdef __LDSO_LD_LIBRARY_PATH__
+ _dl_library_path = argv[2];
+#endif
+ _dl_skip_args += 2;
+ argc -= 2;
+ argv += 2;
+ } else
+ break;
+
+ /*
+ * If we have no further argument the program was called incorrectly.
+ * Grant the user some education.
+ */
+
+ if (argc < 2) {
+ _dl_dprintf(1, "\
+Usage: ld.so [OPTION]... EXECUTABLE-FILE [ARGS-FOR-PROGRAM...]\n\
+You have invoked `ld.so', the helper program for shared library executables.\n\
+This program usually lives in the file `/lib/ld.so', and special directives\n\
+in executable files using ELF shared libraries tell the system's program\n\
+loader to load the helper program from this file. This helper program loads\n\
+the shared libraries needed by the program executable, prepares the program\n\
+to run, and runs it. You may invoke this helper program directly from the\n\
+command line to load and run an ELF executable file; this is like executing\n\
+that file itself, but always uses this helper program from the file you\n\
+specified, instead of the helper program file specified in the executable\n\
+file you run. This is mostly of use for maintainers to test new versions\n\
+of this helper program; chances are you did not intend to run this program.\n\
+\n\
+ --library-path PATH use given PATH instead of content of the environment\n\
+ variable LD_LIBRARY_PATH\n");
+ _dl_exit(1);
+ }
+
+ ++_dl_skip_args;
+ ++argv;
+ _dl_progname = argv[0];
+
+ _dl_symbol_tables = rpnt = _dl_zalloc(sizeof(struct dyn_elf));
+ /*
+ * It needs to load the _dl_progname and to map it
+ * Usually it is the main application launched by means of the ld.so
+ * but it could be also a shared object (when ld.so used for tracing)
+ * We keep the misleading app_tpnt name to avoid variable pollution
+ */
+ app_tpnt = _dl_load_elf_shared_library(_dl_secure ? __RTLD_SECURE : 0,
+ &rpnt, _dl_progname);
+ if (!app_tpnt) {
+ _dl_dprintf(2, "can't load '%s'\n", _dl_progname);
+ _dl_exit(16);
+ }
+ /*
+ * FIXME: it needs to properly handle a PIE executable
+ * Usually for a main application, loadaddr is computed as difference
+ * between auxvt entry points and phdr, so if it is not 0, that it is a
+ * PIE executable. In this case instead we need to set the loadaddr to 0
+ * because we are actually mapping the ELF for the main application by
+ * ourselves. So the PIE case must be checked.
+ */
+
+ app_tpnt->rtld_flags = unlazy | RTLD_GLOBAL;
+
+ /*
+ * This is used by gdb to locate the chain of shared libraries that are
+ * currently loaded.
+ */
+ debug_addr = _dl_zalloc(sizeof(struct r_debug));
+ ppnt = (ElfW(Phdr) *)app_tpnt->ppnt;
+ for (i = 0; i < app_tpnt->n_phent; i++, ppnt++) {
+ if (ppnt->p_type == PT_DYNAMIC) {
+ dpnt = (ElfW(Dyn) *) DL_RELOC_ADDR(app_tpnt->loadaddr, ppnt->p_vaddr);
+ _dl_parse_dynamic_info(dpnt, app_tpnt->dynamic_info, debug_addr, app_tpnt->loadaddr);
+ }
+ }
+
+ _dl_ldsopath_init(tpnt);
+ } else {
#endif
/* At this point we are now free to examine the user application,
@@ -268,8 +651,7 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
* This is used by gdb to locate the chain of shared libraries that are
* currently loaded.
*/
- debug_addr = _dl_malloc(sizeof(struct r_debug));
- _dl_memset(debug_addr, 0, sizeof(struct r_debug));
+ debug_addr = _dl_zalloc(sizeof(struct r_debug));
ppnt = (ElfW(Phdr) *) auxvt[AT_PHDR].a_un.a_val;
for (i = 0; i < auxvt[AT_PHNUM].a_un.a_val; i++, ppnt++) {
@@ -297,7 +679,7 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
for (i = 0; i < auxvt[AT_PHNUM].a_un.a_val; i++, ppnt++) {
if (ppnt->p_type == PT_LOAD && !(ppnt->p_flags & PF_W))
_dl_mprotect((void *) (DL_RELOC_ADDR(app_tpnt->loadaddr, ppnt->p_vaddr) & PAGE_ALIGN),
- ((ppnt->p_vaddr + app_tpnt->loadaddr) & ADDR_ALIGN) +
+ (DL_RELOC_ADDR(app_tpnt->loadaddr, ppnt->p_vaddr) & ADDR_ALIGN) +
(unsigned long) ppnt->p_filesz,
PROT_READ | PROT_WRITE | PROT_EXEC);
}
@@ -305,7 +687,7 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
}
#else
if (app_tpnt->dynamic_info[DT_TEXTREL]) {
- _dl_dprintf(_dl_debug_file, "Can't modify application's text section; use the GCC option -fPIE for position-independent executables.\n");
+ _dl_dprintf(2, "Can't modify application's text section; use the GCC option -fPIE for position-independent executables.\n");
_dl_exit(1);
}
#endif
@@ -323,13 +705,16 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
_dl_loaded_modules->libtype = elf_executable;
_dl_loaded_modules->ppnt = (ElfW(Phdr) *) auxvt[AT_PHDR].a_un.a_val;
_dl_loaded_modules->n_phent = auxvt[AT_PHNUM].a_un.a_val;
- _dl_symbol_tables = rpnt = (struct dyn_elf *) _dl_malloc(sizeof(struct dyn_elf));
- _dl_memset(rpnt, 0, sizeof(struct dyn_elf));
+ _dl_symbol_tables = rpnt = _dl_zalloc(sizeof(struct dyn_elf));
rpnt->dyn = _dl_loaded_modules;
app_tpnt->mapaddr = app_mapaddr;
app_tpnt->rtld_flags = unlazy | RTLD_GLOBAL;
app_tpnt->usage_count++;
- app_tpnt->symbol_scope = _dl_symbol_tables;
+#ifdef __DSBT__
+ _dl_ldso_dsbt[0] = app_tpnt->dsbt_table;
+ _dl_memcpy(app_tpnt->dsbt_table, _dl_ldso_dsbt,
+ app_tpnt->dsbt_size * sizeof(tpnt->dsbt_table[0]));
+#endif
lpnt = (unsigned long *) (app_tpnt->dynamic_info[DT_PLTGOT]);
#ifdef ALLOW_ZERO_PLTGOT
if (lpnt)
@@ -339,24 +724,59 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
/* OK, fill this in - we did not have this before */
if (ppnt->p_type == PT_INTERP) {
- char *ptmp;
-
tpnt->libname = (char *) DL_RELOC_ADDR(app_tpnt->loadaddr, ppnt->p_vaddr);
- /* Store the path where the shared lib loader was found
- * for later use
- */
- _dl_ldsopath = _dl_strdup(tpnt->libname);
- ptmp = _dl_strrchr(_dl_ldsopath, '/');
- if (ptmp != _dl_ldsopath)
- *ptmp = '\0';
+ _dl_ldsopath_init(tpnt);
+ }
- _dl_debug_early("Lib Loader: (%x) %s\n", (unsigned) DL_LOADADDR_BASE(tpnt->loadaddr), tpnt->libname);
+ /* Discover any TLS sections if the target supports them. */
+ if (ppnt->p_type == PT_TLS) {
+#if defined(USE_TLS) && USE_TLS
+ if (ppnt->p_memsz > 0) {
+ app_tpnt->l_tls_blocksize = ppnt->p_memsz;
+ app_tpnt->l_tls_align = ppnt->p_align;
+ if (ppnt->p_align == 0)
+ app_tpnt->l_tls_firstbyte_offset = 0;
+ else
+ app_tpnt->l_tls_firstbyte_offset =
+ (ppnt->p_vaddr & (ppnt->p_align - 1));
+ app_tpnt->l_tls_initimage_size = ppnt->p_filesz;
+ app_tpnt->l_tls_initimage = (void *) ppnt->p_vaddr;
+
+ /* This image gets the ID one. */
+ _dl_tls_max_dtv_idx = app_tpnt->l_tls_modid = 1;
+
+ }
+ _dl_debug_early("Found TLS header for application program\n");
+ break;
+#else
+ _dl_dprintf(2, "Program uses unsupported TLS data!\n");
+ _dl_exit(1);
+#endif
}
}
app_tpnt->relro_addr = relro_addr;
app_tpnt->relro_size = relro_size;
+#if defined(USE_TLS) && USE_TLS
+ /*
+ * Adjust the address of the TLS initialization image in
+ * case the executable is actually an ET_DYN object.
+ */
+ if (app_tpnt->l_tls_initimage != NULL) {
+ char *tmp attribute_unused =
+ (char *) app_tpnt->l_tls_initimage;
+ app_tpnt->l_tls_initimage =
+ (char *) app_tpnt->l_tls_initimage + app_tpnt->loadaddr;
+ _dl_debug_early("Relocated TLS initial image from %x to %x (size = %x)\n",
+ tmp, app_tpnt->l_tls_initimage, app_tpnt->l_tls_initimage_size);
+ }
+#endif
+
+#ifdef __LDSO_STANDALONE_SUPPORT__
+ } /* ! ldso standalone mode */
+#endif
+
#ifdef __SUPPORT_LD_DEBUG__
_dl_debug = _dl_getenv("LD_DEBUG", envp);
if (_dl_debug) {
@@ -388,14 +808,14 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
len1 = _dl_strlen(dl_debug_output);
len2 = _dl_strlen(tmp1);
- filename = _dl_malloc(len1+len2+2);
+ filename = _dl_malloc(len1 + len2 + 2);
if (filename) {
_dl_strcpy (filename, dl_debug_output);
filename[len1] = '.';
_dl_strcpy (&filename[len1+1], tmp1);
- _dl_debug_file= _dl_open(filename, O_WRONLY|O_CREAT, 0644);
+ _dl_debug_file = _dl_open(filename, O_WRONLY|O_CREAT, 0644);
if (_dl_debug_file < 0) {
_dl_debug_file = 2;
_dl_dprintf(_dl_debug_file, "can't open file: '%s'\n",filename);
@@ -405,17 +825,28 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
}
#endif
+#ifdef __LDSO_PRELINK_SUPPORT__
+{
+ char *ld_warn = _dl_getenv ("LD_WARN", envp);
+
+ if (ld_warn && *ld_warn == '\0')
+ _dl_verbose = false;
+}
+ _dl_trace_prelink = _dl_getenv("LD_TRACE_PRELINKING", envp);
+#endif
+
if (_dl_getenv("LD_TRACE_LOADED_OBJECTS", envp) != NULL) {
trace_loaded_objects++;
}
#ifndef __LDSO_LDD_SUPPORT__
if (trace_loaded_objects) {
- _dl_dprintf(_dl_debug_file, "Use the ldd provided by uClibc\n");
+ _dl_dprintf(2, "Use the ldd provided by uClibc\n");
_dl_exit(1);
}
#endif
+ ldso_mapaddr = (ElfW(Addr)) auxvt[AT_BASE].a_un.a_val;
/*
* OK, fix one more thing - set up debug_addr so it will point
* to our chain. Later we may need to fill in more fields, but this
@@ -423,7 +854,8 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
*/
debug_addr->r_map = (struct link_map *) _dl_loaded_modules;
debug_addr->r_version = 1;
- debug_addr->r_ldbase = DL_LOADADDR_BASE(load_addr);
+ debug_addr->r_ldbase = (ElfW(Addr))
+ DL_LOADADDR_BASE(DL_GET_RUN_ADDR(load_addr, ldso_mapaddr));
debug_addr->r_brk = (unsigned long) &_dl_debug_state;
_dl_debug_addr = debug_addr;
@@ -437,6 +869,7 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
_dl_map_cache();
+#ifdef __LDSO_PRELOAD_ENV_SUPPORT__
if (_dl_preload) {
char c, *str, *str2;
@@ -454,16 +887,19 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
if (!_dl_secure || _dl_strchr(str, '/') == NULL) {
_dl_if_debug_dprint("\tfile='%s'; needed by '%s'\n", str, _dl_progname);
- tpnt1 = _dl_load_shared_library(_dl_secure, &rpnt, NULL, str, trace_loaded_objects);
+ tpnt1 = _dl_load_shared_library(
+ _dl_secure ? __RTLD_SECURE : 0,
+ &rpnt, NULL, str, trace_loaded_objects);
if (!tpnt1) {
#ifdef __LDSO_LDD_SUPPORT__
- if (trace_loaded_objects)
+ if (trace_loaded_objects || _dl_trace_prelink)
_dl_dprintf(1, "\t%s => not found\n", str);
else
#endif
{
- _dl_dprintf(2, "%s: can't load " "library '%s'\n", _dl_progname, str);
- _dl_exit(15);
+ _dl_dprintf(2, "%s: library '%s' "
+ "from LD_PRELOAD can't be preloaded: ignored.\n",
+ _dl_progname, str);
}
} else {
tpnt1->rtld_flags = unlazy | RTLD_GLOBAL;
@@ -471,7 +907,7 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
_dl_debug_early("Loading: (%x) %s\n", DL_LOADADDR_BASE(tpnt1->loadaddr), tpnt1->libname);
#ifdef __LDSO_LDD_SUPPORT__
- if (trace_loaded_objects &&
+ if (trace_loaded_objects && !_dl_trace_prelink &&
tpnt1->usage_count == 1) {
/* This is a real hack to make
* ldd not print the library
@@ -492,13 +928,14 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
str++;
}
}
+#endif /* __LDSO_PRELOAD_ENV_SUPPORT__ */
#ifdef __LDSO_PRELOAD_FILE_SUPPORT__
do {
- struct stat st;
char *preload;
int fd;
char c, *cp, *cp2;
+ struct stat st;
if (_dl_stat(LDSO_PRELOAD, &st) || st.st_size == 0) {
break;
@@ -547,11 +984,11 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
tpnt1 = _dl_load_shared_library(0, &rpnt, NULL, cp2, trace_loaded_objects);
if (!tpnt1) {
-#ifdef __LDSO_LDD_SUPPORT__
- if (trace_loaded_objects)
+# ifdef __LDSO_LDD_SUPPORT__
+ if (trace_loaded_objects || _dl_trace_prelink)
_dl_dprintf(1, "\t%s => not found\n", cp2);
else
-#endif
+# endif
{
_dl_dprintf(2, "%s: can't load library '%s'\n", _dl_progname, cp2);
_dl_exit(15);
@@ -561,14 +998,14 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
_dl_debug_early("Loading: (%x) %s\n", DL_LOADADDR_BASE(tpnt1->loadaddr), tpnt1->libname);
-#ifdef __LDSO_LDD_SUPPORT__
- if (trace_loaded_objects &&
+# ifdef __LDSO_LDD_SUPPORT__
+ if (trace_loaded_objects && !_dl_trace_prelink &&
tpnt1->usage_count == 1) {
_dl_dprintf(1, "\t%s => %s (%x)\n",
cp2, tpnt1->libname,
DL_LOADADDR_BASE(tpnt1->loadaddr));
}
-#endif
+# endif
}
/* find start of next library */
@@ -593,14 +1030,22 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
lpntstr = (char*) (tcurr->dynamic_info[DT_STRTAB] + this_dpnt->d_un.d_val);
name = _dl_get_last_path_component(lpntstr);
- if (_dl_strcmp(name, UCLIBC_LDSO) == 0)
- continue;
-
_dl_if_debug_dprint("\tfile='%s'; needed by '%s'\n", lpntstr, _dl_progname);
- if (!(tpnt1 = _dl_load_shared_library(0, &rpnt, tcurr, lpntstr, trace_loaded_objects))) {
+ if (_dl_strcmp(name, UCLIBC_LDSO) == 0) {
+ if (!ldso_tpnt) {
+ /* Insert the ld.so only once */
+ ldso_tpnt = add_ldso(tpnt, load_addr,
+ ldso_mapaddr, auxvt, rpnt);
+ }
+ ldso_tpnt->usage_count++;
+ tpnt1 = ldso_tpnt;
+ } else
+ tpnt1 = _dl_load_shared_library(0, &rpnt, tcurr, lpntstr, trace_loaded_objects);
+
+ if (!tpnt1) {
#ifdef __LDSO_LDD_SUPPORT__
- if (trace_loaded_objects) {
+ if (trace_loaded_objects || _dl_trace_prelink) {
_dl_dprintf(1, "\t%s => not found\n", lpntstr);
continue;
} else
@@ -621,7 +1066,7 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
_dl_debug_early("Loading: (%x) %s\n", DL_LOADADDR_BASE(tpnt1->loadaddr), tpnt1->libname);
#ifdef __LDSO_LDD_SUPPORT__
- if (trace_loaded_objects &&
+ if (trace_loaded_objects && !_dl_trace_prelink &&
tpnt1->usage_count == 1) {
_dl_dprintf(1, "\t%s => %s (%x)\n",
lpntstr, tpnt1->libname,
@@ -633,12 +1078,18 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
}
_dl_unmap_cache();
- --nlist; /* Exclude the application. */
+ /* Keep track of the number of elements in the global scope */
+ nscope_elem = nlist;
+
+ if (_dl_loaded_modules->libtype == elf_executable) {
+ --nlist; /* Exclude the application. */
+ tcurr = _dl_loaded_modules->next;
+ } else
+ tcurr = _dl_loaded_modules;
init_fini_list = _dl_malloc(nlist * sizeof(struct elf_resolve *));
i = 0;
- for (tcurr = _dl_loaded_modules->next; tcurr; tcurr = tcurr->next) {
+ for (; tcurr; tcurr = tcurr->next)
init_fini_list[i++] = tcurr;
- }
/* Sort the INIT/FINI list in dependency order. */
for (tcurr = _dl_loaded_modules->next; tcurr; tcurr = tcurr->next) {
@@ -684,43 +1135,13 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
* functions in the dynamic linker and to relocate the interpreter
* again once all libs are loaded.
*/
- if (tpnt) {
- ElfW(Ehdr) *epnt = (ElfW(Ehdr) *) auxvt[AT_BASE].a_un.a_val;
- ElfW(Phdr) *myppnt = (ElfW(Phdr) *) DL_RELOC_ADDR(load_addr, epnt->e_phoff);
- int j;
-
- tpnt = _dl_add_elf_hash_table(tpnt->libname, load_addr,
- tpnt->dynamic_info,
- (unsigned long)tpnt->dynamic_addr,
- 0);
-
- if (_dl_stat(tpnt->libname, &st) >= 0) {
- tpnt->st_dev = st.st_dev;
- tpnt->st_ino = st.st_ino;
- }
- tpnt->n_phent = epnt->e_phnum;
- tpnt->ppnt = myppnt;
- for (j = 0; j < epnt->e_phnum; j++, myppnt++) {
- if (myppnt->p_type == PT_GNU_RELRO) {
- tpnt->relro_addr = myppnt->p_vaddr;
- tpnt->relro_size = myppnt->p_memsz;
- break;
- }
- }
- tpnt->libtype = program_interpreter;
+ if (!ldso_tpnt) {
+ tpnt = add_ldso(tpnt, load_addr, ldso_mapaddr, auxvt, rpnt);
tpnt->usage_count++;
- tpnt->symbol_scope = _dl_symbol_tables;
- if (rpnt) {
- rpnt->next = (struct dyn_elf *) _dl_malloc(sizeof(struct dyn_elf));
- _dl_memset(rpnt->next, 0, sizeof(struct dyn_elf));
- rpnt->next->prev = rpnt;
- rpnt = rpnt->next;
- } else {
- rpnt = (struct dyn_elf *) _dl_malloc(sizeof(struct dyn_elf));
- _dl_memset(rpnt, 0, sizeof(struct dyn_elf));
- }
- rpnt->dyn = tpnt;
- tpnt->rtld_flags = RTLD_NOW | RTLD_GLOBAL; /* Must not be LAZY */
+ nscope_elem++;
+ } else
+ tpnt = ldso_tpnt;
+
#ifdef RERELOCATE_LDSO
/* Only rerelocate functions for now. */
tpnt->init_flag = RELOCS_DONE;
@@ -733,18 +1154,159 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
tpnt->init_flag = RELOCS_DONE | JMP_RELOCS_DONE;
#endif
tpnt = NULL;
+
+ /*
+ * Allocate the global scope array.
+ */
+ scope_elem_list = (struct elf_resolve **) _dl_malloc(nscope_elem * sizeof(struct elf_resolve *));
+
+ for (i = 0, tcurr = _dl_loaded_modules; tcurr; tcurr = tcurr->next)
+ scope_elem_list[i++] = tcurr;
+
+ _dl_loaded_modules->symbol_scope.r_list = scope_elem_list;
+ _dl_loaded_modules->symbol_scope.r_nlist = nscope_elem;
+ /*
+ * The symbol scope of the application, that is the first entry of the
+ * _dl_loaded_modules list, is just the global scope to be used for the
+ * symbol lookup.
+ */
+ global_scope = &_dl_loaded_modules->symbol_scope;
+
+ /* Build the local scope for each loaded modules. */
+ local_scope = _dl_malloc(nscope_elem * sizeof(struct elf_resolve *));
+ i = 1;
+ for (tcurr = _dl_loaded_modules->next; tcurr; tcurr = tcurr->next) {
+ unsigned int k;
+ cnt = _dl_build_local_scope(local_scope, scope_elem_list[i++]);
+ tcurr->symbol_scope.r_list = _dl_malloc(cnt * sizeof(struct elf_resolve *));
+ tcurr->symbol_scope.r_nlist = cnt;
+ _dl_memcpy (tcurr->symbol_scope.r_list, local_scope, cnt * sizeof (struct elf_resolve *));
+ /* Restoring the init_flag.*/
+ for (k = 1; k < nscope_elem; k++)
+ scope_elem_list[k]->init_flag &= ~DL_RESERVED;
}
+ _dl_free(local_scope);
+
#ifdef __LDSO_LDD_SUPPORT__
- /* End of the line for ldd.... */
- if (trace_loaded_objects) {
- _dl_dprintf(1, "\t%s => %s (%x)\n",
- rpnt->dyn->libname + _dl_strlen(_dl_ldsopath) + 1,
- rpnt->dyn->libname, DL_LOADADDR_BASE(rpnt->dyn->loadaddr));
+ /* Exit if LD_TRACE_LOADED_OBJECTS is on. */
+ if (trace_loaded_objects && !_dl_trace_prelink)
+ _dl_exit(0);
+#endif
+
+#if defined(USE_TLS) && USE_TLS
+ /* We do not initialize any of the TLS functionality unless any of the
+ * initial modules uses TLS. This makes dynamic loading of modules with
+ * TLS impossible, but to support it requires either eagerly doing setup
+ * now or lazily doing it later. Doing it now makes us incompatible with
+ * an old kernel that can't perform TLS_INIT_TP, even if no TLS is ever
+ * used. Trying to do it lazily is too hairy to try when there could be
+ * multiple threads (from a non-TLS-using libpthread). */
+ bool was_tls_init_tp_called = tls_init_tp_called;
+ if (tcbp == NULL) {
+ _dl_debug_early("Calling init_tls()!\n");
+ tcbp = init_tls ();
+ }
+#endif
+#ifdef __UCLIBC_HAS_SSP__
+ _dl_debug_early("Setting up SSP guards\n");
+ /* Set up the stack checker's canary. */
+ stack_chk_guard = _dl_setup_stack_chk_guard ();
+# ifdef THREAD_SET_STACK_GUARD
+ THREAD_SET_STACK_GUARD (stack_chk_guard);
+# else
+ __stack_chk_guard = stack_chk_guard;
+# endif
+# ifdef __UCLIBC_HAS_SSP_COMPAT__
+ __guard = stack_chk_guard;
+# endif
+#endif
+
+#ifdef __LDSO_PRELINK_SUPPORT__
+ if (_dl_trace_prelink) {
+
+ unsigned int nscope_trace = ldso_tpnt ? nscope_elem : (nscope_elem - 1);
+
+ for (i = 0; i < nscope_trace; i++)
+ trace_objects(scope_elem_list[i],
+ _dl_get_last_path_component(scope_elem_list[i]->libname));
+
+ if (_dl_verbose)
+ /* Warn about undefined symbols. */
+ if (_dl_symbol_tables)
+ if (_dl_fixup(_dl_symbol_tables, global_scope, unlazy))
+ _dl_exit(-1);
_dl_exit(0);
}
+
+ if (_dl_loaded_modules->dynamic_info[DT_GNU_LIBLIST_IDX]) {
+ ElfW(Lib) *liblist, *liblistend;
+ struct elf_resolve **r_list, **r_listend, *l;
+ const char *strtab = (const char *)_dl_loaded_modules->dynamic_info[DT_STRTAB];
+
+ _dl_assert (_dl_loaded_modules->dynamic_info[DT_GNU_LIBLISTSZ_IDX] != 0);
+ liblist = (ElfW(Lib) *) _dl_loaded_modules->dynamic_info[DT_GNU_LIBLIST_IDX];
+ liblistend = (ElfW(Lib) *)
+ ((char *) liblist + _dl_loaded_modules->dynamic_info[DT_GNU_LIBLISTSZ_IDX]);
+ r_list = _dl_loaded_modules->symbol_scope.r_list;
+ r_listend = r_list + nscope_elem;
+
+ for (; r_list < r_listend && liblist < liblistend; r_list++) {
+ l = *r_list;
+
+ if (l == _dl_loaded_modules)
+ continue;
+
+ /* If the library is not mapped where it should, fail. */
+ if (l->loadaddr)
+ break;
+
+ /* Next, check if checksum matches. */
+ if (l->dynamic_info[DT_CHECKSUM_IDX] == 0 ||
+ l->dynamic_info[DT_CHECKSUM_IDX] != liblist->l_checksum)
+ break;
+
+ if (l->dynamic_info[DT_GNU_PRELINKED_IDX] == 0 ||
+ (l->dynamic_info[DT_GNU_PRELINKED_IDX] != liblist->l_time_stamp))
+ break;
+
+ if (_dl_strcmp(strtab + liblist->l_name, _dl_get_last_path_component(l->libname)) != 0)
+ break;
+
+ ++liblist;
+ }
+
+
+ if (r_list == r_listend && liblist == liblistend)
+ prelinked = true;
+
+ }
+
+ _dl_debug_early ("prelink checking: %s\n", prelinked ? "ok" : "failed");
+
+ if (prelinked) {
+ if (_dl_loaded_modules->dynamic_info[DT_GNU_CONFLICT_IDX]) {
+ ELF_RELOC *conflict;
+ unsigned long conflict_size;
+
+ _dl_assert (_dl_loaded_modules->dynamic_info[DT_GNU_CONFLICTSZ_IDX] != 0);
+ conflict = (ELF_RELOC *) _dl_loaded_modules->dynamic_info[DT_GNU_CONFLICT_IDX];
+ conflict_size = _dl_loaded_modules->dynamic_info[DT_GNU_CONFLICTSZ_IDX];
+ _dl_parse_relocation_information(_dl_symbol_tables, global_scope,
+ (unsigned long) conflict, conflict_size);
+ }
+
+ /* Mark all the objects so we know they have been already relocated. */
+ for (tpnt = _dl_loaded_modules; tpnt; tpnt = tpnt->next) {
+ tpnt->init_flag |= RELOCS_DONE;
+ if (tpnt->relro_size)
+ _dl_protect_relro (tpnt);
+ }
+ } else
#endif
+ {
+
_dl_debug_early("Beginning relocation fixups\n");
#ifdef __mips__
@@ -762,13 +1324,36 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
* order so that COPY directives work correctly.
*/
if (_dl_symbol_tables)
- if (_dl_fixup(_dl_symbol_tables, unlazy))
+ if (_dl_fixup(_dl_symbol_tables, global_scope, unlazy))
_dl_exit(-1);
for (tpnt = _dl_loaded_modules; tpnt; tpnt = tpnt->next) {
if (tpnt->relro_size)
_dl_protect_relro (tpnt);
}
+ } /* not prelinked */
+
+#if defined(USE_TLS) && USE_TLS
+ if (!was_tls_init_tp_called && _dl_tls_max_dtv_idx > 0)
+ ++_dl_tls_generation;
+
+ _dl_debug_early("Calling _dl_allocate_tls_init()!\n");
+
+ /* Now that we have completed relocation, the initializer data
+ for the TLS blocks has its final values and we can copy them
+ into the main thread's TLS area, which we allocated above. */
+ _dl_allocate_tls_init (tcbp);
+
+ /* And finally install it for the main thread. If ld.so itself uses
+ TLS we know the thread pointer was initialized earlier. */
+ if (! tls_init_tp_called) {
+ const char *lossage = (char *) TLS_INIT_TP (tcbp, USE___THREAD);
+ if (__builtin_expect (lossage != NULL, 0)) {
+ _dl_debug_early("cannot set up thread-local storage: %s\n", lossage);
+ _dl_exit(30);
+ }
+ }
+#endif /* USE_TLS */
/* OK, at this point things are pretty much ready to run. Now we need
* to touch up a few items that are required, and then we can let the
@@ -777,7 +1362,7 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
* ld.so.1, so we have to look up each symbol individually.
*/
- _dl_envp = (unsigned long *) (intptr_t) _dl_find_hash(__C_SYMBOL_PREFIX__ "__environ", _dl_symbol_tables, NULL, 0);
+ _dl_envp = (unsigned long *) (intptr_t) _dl_find_hash(__C_SYMBOL_PREFIX__ "__environ", global_scope, NULL, 0, NULL);
if (_dl_envp)
*_dl_envp = (unsigned long) envp;
@@ -833,115 +1418,34 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
/* Find the real malloc function and make ldso functions use that from now on */
_dl_malloc_function = (void* (*)(size_t)) (intptr_t) _dl_find_hash(__C_SYMBOL_PREFIX__ "malloc",
- _dl_symbol_tables, NULL, ELF_RTYPE_CLASS_PLT);
+ global_scope, NULL, ELF_RTYPE_CLASS_PLT, NULL);
- /* Notify the debugger that all objects are now mapped in. */
- _dl_debug_addr->r_state = RT_CONSISTENT;
- _dl_debug_state();
-}
+#if defined(USE_TLS) && USE_TLS
+ /* Find the real functions and make ldso functions use them from now on */
+ _dl_calloc_function = (void* (*)(size_t, size_t)) (intptr_t)
+ _dl_find_hash(__C_SYMBOL_PREFIX__ "calloc", global_scope, NULL, ELF_RTYPE_CLASS_PLT, NULL);
-char *_dl_getenv(const char *symbol, char **envp)
-{
- char *pnt;
- const char *pnt1;
+ _dl_realloc_function = (void* (*)(void *, size_t)) (intptr_t)
+ _dl_find_hash(__C_SYMBOL_PREFIX__ "realloc", global_scope, NULL, ELF_RTYPE_CLASS_PLT, NULL);
- while ((pnt = *envp++)) {
- pnt1 = symbol;
- while (*pnt && *pnt == *pnt1)
- pnt1++, pnt++;
- if (!*pnt || *pnt != '=' || *pnt1)
- continue;
- return pnt + 1;
- }
- return 0;
-}
-
-void _dl_unsetenv(const char *symbol, char **envp)
-{
- char *pnt;
- const char *pnt1;
- char **newenvp = envp;
-
- for (pnt = *envp; pnt; pnt = *++envp) {
- pnt1 = symbol;
- while (*pnt && *pnt == *pnt1)
- pnt1++, pnt++;
- if (!*pnt || *pnt != '=' || *pnt1)
- *newenvp++ = *envp;
- }
- *newenvp++ = *envp;
- return;
-}
-
-static int _dl_suid_ok(void)
-{
- __kernel_uid_t uid, euid;
- __kernel_gid_t gid, egid;
+ _dl_free_function = (void (*)(void *)) (intptr_t)
+ _dl_find_hash(__C_SYMBOL_PREFIX__ "free", global_scope, NULL, ELF_RTYPE_CLASS_PLT, NULL);
- uid = _dl_getuid();
- euid = _dl_geteuid();
- gid = _dl_getgid();
- egid = _dl_getegid();
+ _dl_memalign_function = (void* (*)(size_t, size_t)) (intptr_t)
+ _dl_find_hash(__C_SYMBOL_PREFIX__ "memalign", global_scope, NULL, ELF_RTYPE_CLASS_PLT, NULL);
- if (uid == euid && gid == egid) {
- return 1;
- }
- return 0;
-}
-
-void *_dl_malloc(size_t size)
-{
- void *retval;
-
-#if 0
- _dl_debug_early("request for %d bytes\n", size);
#endif
- if (_dl_malloc_function)
- return (*_dl_malloc_function) (size);
-
- if (_dl_malloc_addr - _dl_mmap_zero + size > _dl_pagesize) {
- size_t rounded_size;
-
- /* Since the above assumes we get a full page even if
- we request less than that, make sure we request a
- full page, since uClinux may give us less than than
- a full page. We might round even
- larger-than-a-page sizes, but we end up never
- reusing _dl_mmap_zero/_dl_malloc_addr in that case,
- so we don't do it.
-
- The actual page size doesn't really matter; as long
- as we're self-consistent here, we're safe. */
- if (size < _dl_pagesize)
- rounded_size = (size + _dl_pagesize - 1) & _dl_pagesize;
- else
- rounded_size = size;
-
- _dl_debug_early("mmapping more memory\n");
- _dl_mmap_zero = _dl_malloc_addr = _dl_mmap((void *) 0, rounded_size,
- PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
- if (_dl_mmap_check_error(_dl_mmap_zero)) {
- _dl_dprintf(2, "%s: mmap of a spare page failed!\n", _dl_progname);
- _dl_exit(20);
- }
- }
- retval = _dl_malloc_addr;
- _dl_malloc_addr += size;
-
- /*
- * Align memory to DL_MALLOC_ALIGN byte boundary. Some
- * platforms require this, others simply get better
- * performance.
- */
- _dl_malloc_addr = (unsigned char *) (((unsigned long) _dl_malloc_addr + DL_MALLOC_ALIGN - 1) & ~(DL_MALLOC_ALIGN - 1));
- return retval;
-}
+ /* Notify the debugger that all objects are now mapped in. */
+ _dl_debug_addr->r_state = RT_CONSISTENT;
+ _dl_debug_state();
-void _dl_free (void *p)
-{
- if (_dl_free_function)
- (*_dl_free_function) (p);
+#ifdef __LDSO_STANDALONE_SUPPORT__
+ if (_start == (void *) auxvt[AT_ENTRY].a_un.a_val)
+ return (void *) app_tpnt->l_entry;
+ else
+#endif
+ return (void *) auxvt[AT_ENTRY].a_un.a_val;
}
#include "dl-hash.c"
diff --git a/ldso/ldso/m68k/dl-debug.h b/ldso/ldso/m68k/dl-debug.h
index a9a80a067..71b513a3e 100644
--- a/ldso/ldso/m68k/dl-debug.h
+++ b/ldso/ldso/m68k/dl-debug.h
@@ -29,7 +29,7 @@
* SUCH DAMAGE.
*/
-static const char *_dl_reltypes_tab[] = {
+static const char * const _dl_reltypes_tab[] = {
[0] "R_68K_NONE",
[1] "R_68K_32", "R_68K_16", "R_68K_8",
[4] "R_68K_PC32", "R_68K_PC16", "R_68K_PC8",
diff --git a/ldso/ldso/m68k/dl-startup.h b/ldso/ldso/m68k/dl-startup.h
index 2ed9ead50..52a950c87 100644
--- a/ldso/ldso/m68k/dl-startup.h
+++ b/ldso/ldso/m68k/dl-startup.h
@@ -4,10 +4,22 @@
* Copyright (C) 2005 by Erik Andersen <andersen@codepoet.org>
*/
+/* Perform operation OP with PC-relative SRC as the first operand and
+ * DST as the second. TMP is available as a temporary if needed. */
+
+#ifdef __mcoldfire__
+#define PCREL_OP(OP, SRC, DST, TMP, PC) \
+ "move.l #" SRC " - ., " TMP "\n\t" OP " (-8, " PC ", " TMP "), " DST
+#else
+#define PCREL_OP(OP, SRC, DST, TMP, PC) \
+ OP " " SRC "(" PC "), " DST
+#endif
+
__asm__ ("\
.text\n\
.globl _start\n\
.type _start,@function\n\
+ .hidden _start\n\
_start:\n\
move.l %sp, -(%sp)\n\
jbsr _dl_start\n\
@@ -21,7 +33,7 @@ _dl_start_user:\n\
move.l %d0, %a4\n\
# See if we were run as a command with the executable file\n\
# name as an extra leading argument.\n\
- move.l _dl_skip_args(%pc), %d0\n\
+ " PCREL_OP ("move.l", "_dl_skip_args", "%d0", "%d0", "%pc") "\n\
# Pop the original argument count\n\
move.l (%sp)+, %d1\n\
# Subtract _dl_skip_args from it.\n\
@@ -31,7 +43,7 @@ _dl_start_user:\n\
# Push back the modified argument count.\n\
move.l %d1, -(%sp)\n\
# Pass our finalizer function to the user in %a1.\n\
- lea _dl_fini(%pc), %a1\n\
+ " PCREL_OP ("lea", "_dl_fini", "%a1", "%a1", "%pc") "\n\
# Initialize %fp with the stack pointer.\n\
move.l %sp, %fp\n\
# Jump to the user's entry point.\n\
@@ -40,7 +52,7 @@ _dl_start_user:\n\
.previous");
/* Get a pointer to the argv array. On many platforms this can be just
- * the address if the first argument, on other platforms we need to
+ * the address of the first argument, on other platforms we need to
* do something a little more subtle here. */
#define GET_ARGV(ARGVP, ARGS) ARGVP = (((unsigned long *) ARGS) + 1)
@@ -49,7 +61,7 @@ static __always_inline
void PERFORM_BOOTSTRAP_RELOC(ELF_RELOC *rpnt, unsigned long *reloc_addr,
unsigned long symbol_addr, unsigned long load_addr, Elf32_Sym *symtab)
{
- switch (ELF32_R_TYPE(rpnt->r_info))
+ switch (ELF_R_TYPE(rpnt->r_info))
{
case R_68K_8:
*(char *) reloc_addr = symbol_addr + rpnt->r_addend;
diff --git a/ldso/ldso/m68k/dl-syscalls.h b/ldso/ldso/m68k/dl-syscalls.h
index 996bb87c6..f40c4fd31 100644
--- a/ldso/ldso/m68k/dl-syscalls.h
+++ b/ldso/ldso/m68k/dl-syscalls.h
@@ -1,6 +1 @@
-/* We can't use the real errno in ldso, since it has not yet
- * been dynamicly linked in yet. */
-#include "sys/syscall.h"
-extern int _dl_errno;
-#undef __set_errno
-#define __set_errno(X) {(_dl_errno) = (X);}
+/* stub for arch-specific syscall issues */
diff --git a/ldso/ldso/m68k/dl-sysdep.h b/ldso/ldso/m68k/dl-sysdep.h
index e42be3150..b5eda4e9c 100644
--- a/ldso/ldso/m68k/dl-sysdep.h
+++ b/ldso/ldso/m68k/dl-sysdep.h
@@ -22,14 +22,12 @@ do { \
/* Used for error messages */
#define ELF_TARGET "m68k"
+/* Need bootstrap relocations */
+#define ARCH_NEEDS_BOOTSTRAP_RELOCS
+
struct elf_resolve;
extern unsigned long _dl_linux_resolver (struct elf_resolve *, int);
-/* 4096 bytes alignment */
-#define PAGE_ALIGN 0xfffff000
-#define ADDR_ALIGN 0xfff
-#define OFFS_ALIGN 0x7ffff000
-
/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry, so
PLT entries should not be allowed to define the value.
ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one
@@ -41,26 +39,36 @@ extern unsigned long _dl_linux_resolver (struct elf_resolve *, int);
/* Return the link-time address of _DYNAMIC. Conveniently, this is the
first element of the GOT. This must be inlined in a function which
uses global data. */
-static __inline__ Elf32_Addr
+static __always_inline Elf32_Addr
elf_machine_dynamic (void)
{
- register Elf32_Addr *got __asm__ ("%a5");
- return *got;
+ Elf32_Addr got;
+
+ __asm__ ("move.l _DYNAMIC@GOT.w(%%a5), %0"
+ : "=a" (got));
+ return got;
}
+#ifdef __mcoldfire__
+#define PCREL_OP(OP, SRC, DST, TMP, PC) \
+ "move.l #" SRC " - ., " TMP "\n\t" OP " (-8, " PC ", " TMP "), " DST
+#else
+#define PCREL_OP(OP, SRC, DST, TMP, PC) \
+ OP " " SRC "(" PC "), " DST
+#endif
/* Return the run-time load address of the shared object. */
-static __inline__ Elf32_Addr
+static __always_inline Elf32_Addr
elf_machine_load_address (void)
{
Elf32_Addr addr;
- __asm__ ("lea _dl_start(%%pc), %0\n\t"
- "sub.l _dl_start@GOT.w(%%a5), %0"
- : "=a" (addr));
+ __asm__ (PCREL_OP ("lea", "_dl_start", "%0", "%0", "%%pc") "\n\t"
+ "sub.l _dl_start@GOT.w(%%a5), %0"
+ : "=a" (addr));
return addr;
}
-static __inline__ void
+static __always_inline void
elf_machine_relative (Elf32_Addr load_off, const Elf32_Addr rel_addr,
Elf32_Word relative_count)
{
diff --git a/ldso/ldso/m68k/elfinterp.c b/ldso/ldso/m68k/elfinterp.c
index 8f7364f30..fd7fe8513 100644
--- a/ldso/ldso/m68k/elfinterp.c
+++ b/ldso/ldso/m68k/elfinterp.c
@@ -47,7 +47,6 @@ extern int _dl_linux_resolve(void);
unsigned long
_dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
{
- int reloc_type;
ELF_RELOC *this_reloc;
char *strtab;
ElfW(Sym) *symtab;
@@ -60,25 +59,18 @@ _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
rel_addr = (char *)tpnt->dynamic_info[DT_JMPREL];
this_reloc = (ELF_RELOC *)(rel_addr + reloc_entry);
- reloc_type = ELF_R_TYPE(this_reloc->r_info);
symtab_index = ELF_R_SYM(this_reloc->r_info);
symtab = (ElfW(Sym) *)tpnt->dynamic_info[DT_SYMTAB];
strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
symname = strtab + symtab[symtab_index].st_name;
- if (unlikely(reloc_type != R_68K_JMP_SLOT)) {
- _dl_dprintf(2, "%s: Incorrect relocation type in jump relocations\n",
- _dl_progname);
- _dl_exit(1);
- }
-
/* Address of the jump instruction to fix up. */
instr_addr = (this_reloc->r_offset + tpnt->loadaddr);
got_addr = (char **)instr_addr;
/* Get the address of the GOT entry. */
- new_addr = _dl_find_hash(symname, tpnt->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT);
+ new_addr = _dl_find_hash(symname, &_dl_loaded_modules->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT, NULL);
if (unlikely(!new_addr)) {
_dl_dprintf(2, "%s: Can't resolve symbol '%s'\n", _dl_progname, symname);
_dl_exit(1);
@@ -102,9 +94,9 @@ _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
}
static int
-_dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
+_dl_parse(struct elf_resolve *tpnt, struct r_scope_elem *scope,
unsigned long rel_addr, unsigned long rel_size,
- int (*reloc_fnc)(struct elf_resolve *tpnt, struct dyn_elf *scope,
+ int (*reloc_fnc)(struct elf_resolve *tpnt, struct r_scope_elem *scope,
ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab))
{
unsigned int i;
@@ -159,13 +151,13 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
}
static int
-_dl_do_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
+_dl_do_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
{
int reloc_type;
int symtab_index;
char *symname;
- ElfW(Sym) *sym;
+ struct symbol_ref sym_ref;
ElfW(Addr) *reloc_addr;
ElfW(Addr) symbol_addr;
#if defined (__SUPPORT_LD_DEBUG__)
@@ -175,22 +167,27 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
reloc_addr = (ElfW(Addr)*)(tpnt->loadaddr + (unsigned long)rpnt->r_offset);
reloc_type = ELF_R_TYPE(rpnt->r_info);
symtab_index = ELF_R_SYM(rpnt->r_info);
- sym = &symtab[symtab_index];
+ sym_ref.sym = &symtab[symtab_index];
+ sym_ref.tpnt = NULL;
symbol_addr = 0;
- symname = strtab + sym->st_name;
+ symname = strtab + sym_ref.sym->st_name;
if (symtab_index) {
symbol_addr = (ElfW(Addr))_dl_find_hash(symname, scope, tpnt,
- elf_machine_type_class(reloc_type));
+ elf_machine_type_class(reloc_type), &sym_ref);
/*
* We want to allow undefined references to weak symbols - this
* might have been intentional. We should not be linking local
* symbols here, so all bases should be covered.
*/
- if (unlikely(!symbol_addr && ELF_ST_BIND(sym->st_info) != STB_WEAK)) {
+ if (unlikely(!symbol_addr && ELF_ST_BIND(sym_ref.sym->st_info) != STB_WEAK)) {
_dl_dprintf(2, "%s: can't resolve symbol '%s'\n", _dl_progname, symname);
_dl_exit(1);
}
+ if (_dl_trace_prelink) {
+ _dl_debug_lookup (symname, tpnt, &symtab[symtab_index],
+ &sym_ref, elf_machine_type_class(reloc_type));
+ }
}
#if defined (__SUPPORT_LD_DEBUG__)
@@ -238,14 +235,17 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
if (_dl_debug_move)
_dl_dprintf(_dl_debug_file,
"\t%s move %d bytes from %x to %x\n",
- symname, sym->st_size,
+ symname, sym_ref.sym->st_size,
symbol_addr, reloc_addr);
#endif
_dl_memcpy ((void *) reloc_addr,
(void *) symbol_addr,
- sym->st_size);
- } else
+ sym_ref.sym->st_size);
+ }
+#if defined (__SUPPORT_LD_DEBUG__)
+ else
_dl_dprintf(_dl_debug_file, "no symbol_addr to copy !?\n");
+#endif
break;
default:
@@ -264,7 +264,7 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
#undef LAZY_RELOC_WORKS
#ifdef LAZY_RELOC_WORKS
static int
-_dl_do_lazy_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
+_dl_do_lazy_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
{
int reloc_type;
@@ -313,14 +313,15 @@ _dl_parse_lazy_relocation_information(struct dyn_elf *rpnt,
#ifdef LAZY_RELOC_WORKS
(void)_dl_parse(rpnt->dyn, NULL, rel_addr, rel_size, _dl_do_lazy_reloc);
#else
- _dl_parse_relocation_information(rpnt, rel_addr, rel_size);
+ _dl_parse_relocation_information(rpnt, &_dl_loaded_modules->symbol_scope, rel_addr, rel_size);
#endif
}
int
_dl_parse_relocation_information(struct dyn_elf *rpnt,
+ struct r_scope_elem *scope,
unsigned long rel_addr,
unsigned long rel_size)
{
- return _dl_parse(rpnt->dyn, rpnt->dyn->symbol_scope, rel_addr, rel_size, _dl_do_reloc);
+ return _dl_parse(rpnt->dyn, scope, rel_addr, rel_size, _dl_do_reloc);
}
diff --git a/ldso/ldso/m68k/resolve.S b/ldso/ldso/m68k/resolve.S
index d9a2929d6..1bd5c0096 100644
--- a/ldso/ldso/m68k/resolve.S
+++ b/ldso/ldso/m68k/resolve.S
@@ -19,5 +19,10 @@ _dl_linux_resolve:
# Pop parameters
addq.l #8, %sp
# Call real function.
+#if defined __mcoldfire__
+ move.l %d0,-(%sp)
+ rts
+#else
jmp (%d0)
+#endif
.size _dl_linux_resolve,.-_dl_linux_resolve
diff --git a/ldso/ldso/metag/dl-debug.h b/ldso/ldso/metag/dl-debug.h
new file mode 100644
index 000000000..46c257c5c
--- /dev/null
+++ b/ldso/ldso/metag/dl-debug.h
@@ -0,0 +1,33 @@
+/*
+ * Meta ELF shared library loader support.
+ *
+ * Program to load an elf binary on a linux system, and run it.
+ * References to symbols in sharable libraries can be resolved
+ * by either an ELF sharable library or a linux style of shared
+ * library.
+ *
+ * Copyright (C) 2013, Imagination Technologies Ltd.
+ *
+ * Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+static const char *_dl_reltypes_tab[] = {
+ [0] "R_METAG_HIADDR16", "R_METAG_LOADDR16", "R_METAG_ADDR32",
+ [3] "R_METAG_NONE", "R_METAG_RELBRANCH", "R_METAG_GETSETOFF",
+ [6] "R_METAG_REG32OP1", "R_METAG_REG32OP2", "R_METAG_REG32OP3",
+ [9] "R_METAG_REG16OP1", "R_METAG_REG16OP2", "R_METAG_REG16OP3",
+ [12] "R_METAG_REG32OP4", "R_METAG_HIOG", "R_METAG_LOOG",
+ [30] "R_METAG_GNU_VTINHERIT", "R_METAG_GNU_VTENTRY",
+ [32] "R_METAG_HI16_GOTOFF", "R_METAG_LO16_GOTOFF",
+ [34] "R_METAG_GETSET_GOTOFF", "R_METAG_GETSET_GOT",
+ [36] "R_METAG_HI16_GOTPC", "R_METAG_LO16_GOTPC",
+ [38] "R_METAG_HI16_PLT", "R_METAG_LO16_PLT",
+ [40] "R_METAG_RELBRANCH_PLT", "R_METAG_GOTOFF",
+ [42] "R_METAG_PLT", "R_METAG_COPY", "R_METAG_JMP_SLOT",
+ [45] "R_METAG_RELATIVE", "R_METAG_GLOB_DAT", "R_METAG_TLS_GD",
+ [48] "R_METAG_TLS_LDM", "R_METAG_TLS_LDO_HI16", "R_METAG_TLS_LDO_LO16",
+ [51] "R_METAG_TLS_LDO", "R_METAG_TLS_IE", "R_METAG_TLS_IENONPIC",
+ [54] "R_METAG_TLS_IENONPIC_HI16", "R_METAG_TLS_IENONPIC_LO16",
+ [56] "R_METAG_TLS_TPOFF", "R_METAG_TLS_DTPMOD", "R_METAG_TLS_DTPOFF",
+ [59] "R_METAG_TLS_LE", "R_METAG_TLS_LE_HI16", "R_METAG_TLS_LE_LO16"
+};
diff --git a/ldso/ldso/metag/dl-inlines.h b/ldso/ldso/metag/dl-inlines.h
new file mode 100644
index 000000000..82fba93ab
--- /dev/null
+++ b/ldso/ldso/metag/dl-inlines.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2013, Imagination Technologies Ltd.
+ *
+ * Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+static __always_inline int
+__dl_is_special_segment (Elf32_Ehdr *epnt,
+ Elf32_Phdr *ppnt)
+{
+ if (ppnt->p_type != PT_LOAD &&
+ ppnt->p_type != PT_DYNAMIC)
+ return 0;
+
+ if (ppnt->p_vaddr >= 0x80000000 &&
+ ppnt->p_vaddr < 0x82060000)
+ return 1;
+
+ if (ppnt->p_vaddr >= 0xe0200000 &&
+ ppnt->p_vaddr < 0xe0260000)
+ return 1;
+
+ return 0;
+}
+
+static __always_inline char *
+__dl_map_segment (Elf32_Ehdr *epnt,
+ Elf32_Phdr *ppnt,
+ int infile,
+ int flags)
+{
+ char *addr = (char *)ppnt->p_vaddr;
+
+ if (_DL_PREAD (infile, addr, ppnt->p_filesz, ppnt->p_offset) != ppnt->p_filesz) {
+ return 0;
+ }
+
+ return addr;
+}
diff --git a/ldso/ldso/metag/dl-startup.h b/ldso/ldso/metag/dl-startup.h
new file mode 100644
index 000000000..32b2e4b74
--- /dev/null
+++ b/ldso/ldso/metag/dl-startup.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2013 Imagination Technologies Ltd.
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+/*
+ * This code fixes the stack pointer so that the dynamic linker
+ * can find argc, argv and auxvt (Auxillary Vector Table).
+ */
+
+__asm__ (
+" .text\n"
+" .global __start\n"
+" .type __start,@function\n"
+" .hidden __start\n"
+"_start:\n"
+"__start:\n"
+" MSETL [A0StP++],D0Ar4,D0Ar2\n"
+" MOV D1Ar1,D0Ar2\n"
+" CALLR D1RtP,__dl_start\n"
+" GETL D0Ar2,D1Ar1,[A0StP+#-(1*8)]\n"
+" GETL D0Ar4,D1Ar3,[A0StP+#-(2*8)]\n"
+" ADDT A1LbP,CPC1,#HI(__GLOBAL_OFFSET_TABLE__)\n"
+" ADD A1LbP,A1LbP,#LO(__GLOBAL_OFFSET_TABLE__+4)\n"
+" ADDT A1LbP,A1LbP,#HI(__dl_fini@GOTOFF)\n"
+" ADD A1LbP,A1LbP,#LO(__dl_fini@GOTOFF)\n"
+" MOV D0Ar4, A1LbP\n"
+" SUB A0StP,A0StP,#(2*8)\n"
+" MOV PC,D0Re0\n"
+" .size __start,.-__start\n"
+" .previous\n"
+);
+
+
+/*
+ * Get a pointer to the argv array. On many platforms this can be just
+ * the address if the first argument, on other platforms we need to
+ * do something a little more subtle here.
+ */
+
+#define GET_ARGV(ARGVP, ARGS) ARGVP = (((unsigned long *) ARGS))
+
+
+/* Handle relocation of the symbols in the dynamic loader. */
+static inline
+void PERFORM_BOOTSTRAP_RELOC(ELF_RELOC *rpnt, unsigned long *reloc_addr,
+ unsigned long symbol_addr, unsigned long load_addr, Elf32_Sym *symtab)
+{
+ switch (ELF32_R_TYPE(rpnt->r_info)) {
+ case R_METAG_GLOB_DAT:
+ case R_METAG_JMP_SLOT:
+ case R_METAG_ADDR32:
+ *reloc_addr = symbol_addr;
+ break;
+ case R_METAG_RELATIVE:
+ *reloc_addr = load_addr + rpnt->r_addend;
+ break;
+ case R_METAG_RELBRANCH:
+ *reloc_addr = symbol_addr + rpnt->r_addend - *reloc_addr - 4;
+ break;
+ case R_METAG_NONE:
+ break;
+ default:
+ _dl_exit(1);
+ break;
+ }
+}
diff --git a/ldso/ldso/metag/dl-syscalls.h b/ldso/ldso/metag/dl-syscalls.h
new file mode 100644
index 000000000..70ceab10e
--- /dev/null
+++ b/ldso/ldso/metag/dl-syscalls.h
@@ -0,0 +1,6 @@
+/* stub for arch-specific syscall issues
+ *
+ * Copyright (C) 2013, Imagination Technologies Ltd.
+ *
+ * Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
diff --git a/ldso/ldso/metag/dl-sysdep.h b/ldso/ldso/metag/dl-sysdep.h
new file mode 100644
index 000000000..ec17440fc
--- /dev/null
+++ b/ldso/ldso/metag/dl-sysdep.h
@@ -0,0 +1,121 @@
+/*
+ * Meta can never use Elf32_Rel relocations.
+ *
+ * Copyright (C) 2013, Imagination Technologies Ltd.
+ *
+ * Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#define ELF_USES_RELOCA
+
+#include <elf.h>
+
+/* Initialization sequence for the GOT. */
+#define INIT_GOT(GOT_BASE,MODULE) \
+{ \
+ GOT_BASE[1] = (unsigned long) MODULE; \
+ GOT_BASE[2] = (unsigned long) _dl_linux_resolve; \
+}
+
+/* Maximum unsigned GOT [GS]ETD offset size, ie. 2^(11+2). */
+#define GOT_REG_OFFSET 0x2000
+
+/* Defined some magic numbers that this ld.so should accept. */
+#define MAGIC1 EM_METAG
+#undef MAGIC2
+#define ELF_TARGET "META"
+
+/* Need bootstrap relocations */
+#define ARCH_NEEDS_BOOTSTRAP_RELOCS
+
+struct elf_resolve;
+extern unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry);
+
+/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry or
+ TLS variable, so undefined references should not be allowed to
+ define the value.
+
+ ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one
+ of the main executable's symbols, as for a COPY reloc. */
+#define elf_machine_type_class(type) \
+ ((((type) == R_METAG_JMP_SLOT || (type) == R_METAG_TLS_DTPMOD \
+ || (type) == R_METAG_TLS_DTPOFF || (type) == R_METAG_TLS_TPOFF) \
+ * ELF_RTYPE_CLASS_PLT) \
+ | (((type) == R_METAG_COPY) * ELF_RTYPE_CLASS_COPY))
+
+static inline Elf32_Addr
+elf_machine_dynamic(Elf32_Ehdr *header)
+{
+ Elf32_Addr *got;
+
+ __asm__ ("MOV %0,A1LbP" : "=r" (got));
+
+ if (header->e_ident[EI_ABIVERSION] >= 1) {
+ /* GOT register offset was introduced with ABI v1 */
+ got = (Elf32_Addr*)((void*)got - GOT_REG_OFFSET);
+ }
+ return *got;
+}
+
+#define DL_BOOT_COMPUTE_GOT(GOT) \
+ ((GOT) = elf_machine_dynamic(header))
+
+static inline Elf32_Addr
+elf_machine_load_address(void)
+{
+ Elf32_Addr addr;
+ __asm__ ("MOV D1Ar1,A1LbP\n"
+ "ADDT D1Ar1,D1Ar1,#HI(__dl_start@GOTOFF)\n"
+ "ADD D1Ar1,D1Ar1,#LO(__dl_start@GOTOFF)\n"
+ "ADDT D0Ar2,D0Ar2,#HI(__dl_start_addr@GOTOFF)\n"
+ "ADD D0Ar2,D0Ar2,#LO(__dl_start_addr@GOTOFF)\n"
+ "GETD D0Ar2,[D0Ar2]\n"
+ "SUB %0,D1Ar1,D0Ar2\n"
+ ".section .data\n"
+ "__dl_start_addr: .long __dl_start\n"
+ ".previous\n"
+ : "=d" (addr) : : "D1Ar1", "D0Ar2");
+ return addr;
+}
+
+static inline void
+elf_machine_relative(Elf32_Addr load_off, const Elf32_Addr rel_addr,
+ Elf32_Word relative_count)
+{
+ Elf32_Rela *rpnt = (void *)rel_addr;
+
+ --rpnt;
+ do {
+ Elf32_Addr *const reloc_addr =
+ (void *)(load_off + (++rpnt)->r_offset);
+
+ *reloc_addr = load_off + rpnt->r_addend;
+ } while (--relative_count);
+}
+
+#define DL_MALLOC_ALIGN 8
+
+#define HAVE_DL_INLINES_H
+
+#define DL_IS_SPECIAL_SEGMENT(EPNT, PPNT) \
+ __dl_is_special_segment(EPNT, PPNT)
+#define DL_MAP_SEGMENT(EPNT, PPNT, INFILE, FLAGS) \
+ __dl_map_segment (EPNT, PPNT, INFILE, FLAGS)
+
+#define DL_CHECK_LIB_TYPE(epnt, piclib, _dl_progname, libname) \
+do \
+{ \
+ ElfW(Phdr) *ppnt_; \
+ char *header_ = (char *)epnt; \
+ ppnt_ = (ElfW(Phdr) *)(intptr_t) & header_[epnt->e_phoff]; \
+ if (ppnt_->p_vaddr >= 0x80000000 && \
+ ppnt_->p_vaddr < 0x82060000) \
+ (piclib) = 2; \
+ if (ppnt_->p_vaddr >= 0xe0200000 && \
+ ppnt_->p_vaddr < 0xe0260000) \
+ (piclib) = 2; \
+} \
+while (0)
+
+#define _DL_PREAD(FD, BUF, SIZE, OFFSET) \
+ (_dl_pread((FD), (BUF), (SIZE), (OFFSET)))
diff --git a/ldso/ldso/metag/elfinterp.c b/ldso/ldso/metag/elfinterp.c
new file mode 100644
index 000000000..e0f981741
--- /dev/null
+++ b/ldso/ldso/metag/elfinterp.c
@@ -0,0 +1,318 @@
+/*
+ * Meta ELF shared library loader support.
+ *
+ * Program to load an elf binary on a linux system, and run it.
+ * References to symbols in sharable libraries can be resolved
+ * by either an ELF sharable library or a linux style of shared
+ * library.
+ *
+ * Copyright (C) 2013, Imagination Technologies Ltd.
+ *
+ * Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include "ldso.h"
+
+/* Defined in resolve.S. */
+extern int _dl_linux_resolve(void);
+
+static inline unsigned long __get_unaligned_reloc(unsigned long *addr)
+{
+ char *rel_addr = (char *)addr;
+ unsigned long val;
+
+ val = *rel_addr++ & 0xff;
+ val |= (*rel_addr++ << 8) & 0x0000ff00;
+ val |= (*rel_addr++ << 16) & 0x00ff0000;
+ val |= (*rel_addr++ << 24) & 0xff000000;
+
+ return val;
+}
+
+static inline void __put_unaligned_reloc(unsigned long *addr,
+ unsigned long val)
+{
+ char *rel_addr = (char *)addr;
+
+ *rel_addr++ = (val & 0x000000ff);
+ *rel_addr++ = ((val & 0x0000ff00) >> 8);
+ *rel_addr++ = ((val & 0x00ff0000) >> 16);
+ *rel_addr++ = ((val & 0xff000000) >> 24);
+}
+
+unsigned long
+_dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
+{
+ int symtab_index;
+ char *strtab;
+ char *symname;
+ char *new_addr;
+ char *rel_addr;
+ char **got_addr;
+ ElfW(Sym) *symtab;
+ ELF_RELOC *this_reloc;
+ unsigned long instr_addr;
+
+ rel_addr = (char *)tpnt->dynamic_info[DT_JMPREL];
+
+ this_reloc = (ELF_RELOC *)(intptr_t)(rel_addr + reloc_entry);
+ symtab_index = ELF_R_SYM(this_reloc->r_info);
+
+ symtab = (ElfW(Sym) *)(intptr_t)tpnt->dynamic_info[DT_SYMTAB];
+ strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
+ symname = strtab + symtab[symtab_index].st_name;
+
+ /* Address of the jump instruction to fix up. */
+ instr_addr = ((unsigned long)this_reloc->r_offset +
+ (unsigned long)tpnt->loadaddr);
+ got_addr = (char **)instr_addr;
+
+ /* Get the address of the GOT entry. */
+ new_addr = _dl_find_hash(symname, &_dl_loaded_modules->symbol_scope, tpnt,
+ ELF_RTYPE_CLASS_PLT, NULL);
+ if (unlikely(!new_addr)) {
+ _dl_dprintf(2, "%s: Can't resolve symbol '%s'\n",
+ _dl_progname, symname);
+ _dl_exit(1);
+ }
+
+#if defined (__SUPPORT_LD_DEBUG__)
+ if (_dl_debug_bindings) {
+ _dl_dprintf(_dl_debug_file, "\nresolve function: %s", symname);
+ if (_dl_debug_detail)
+ _dl_dprintf(_dl_debug_file,
+ "\n\tpatched: %x ==> %x @ %x\n",
+ *got_addr, new_addr, got_addr);
+ }
+ if (!_dl_debug_nofixups) {
+ *got_addr = new_addr;
+ }
+#else
+ *got_addr = new_addr;
+#endif
+
+ return (unsigned long)new_addr;
+}
+
+static int
+_dl_parse(struct elf_resolve *tpnt, struct r_scope_elem *scope,
+ unsigned long rel_addr, unsigned long rel_size,
+ int (*reloc_fnc)(struct elf_resolve *tpnt, struct r_scope_elem *scope,
+ ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab))
+{
+ int symtab_index;
+ unsigned int i;
+ char *strtab;
+ ElfW(Sym) *symtab;
+ ELF_RELOC *rpnt;
+
+ /* Parse the relocation information. */
+ rpnt = (ELF_RELOC *)(intptr_t)rel_addr;
+ rel_size /= sizeof(ELF_RELOC);
+
+ symtab = (ElfW(Sym) *)(intptr_t)tpnt->dynamic_info[DT_SYMTAB];
+ strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
+
+ for (i = 0; i < rel_size; i++, rpnt++) {
+ int res;
+
+ symtab_index = ELF_R_SYM(rpnt->r_info);
+
+ debug_sym(symtab, strtab, symtab_index);
+ debug_reloc(symtab, strtab, rpnt);
+
+ /* Pass over to actual relocation function. */
+ res = reloc_fnc(tpnt, scope, rpnt, symtab, strtab);
+
+ if (res == 0)
+ continue;
+
+ _dl_dprintf(2, "\n%s: ", _dl_progname);
+
+ if (symtab_index)
+ _dl_dprintf(2, "symbol '%s': ",
+ strtab + symtab[symtab_index].st_name);
+
+ if (unlikely(res < 0)) {
+ int reloc_type = ELF_R_TYPE(rpnt->r_info);
+
+#if defined (__SUPPORT_LD_DEBUG__)
+ _dl_dprintf(2, "can't handle reloc type %s\n",
+ _dl_reltypes(reloc_type));
+#else
+ _dl_dprintf(2, "can't handle reloc type %x\n",
+ reloc_type);
+#endif
+ _dl_exit(-res);
+ } else if (unlikely(res > 0)) {
+ _dl_dprintf(2, "can't resolve symbol\n");
+ return res;
+ }
+ }
+
+ return 0;
+}
+
+static int
+_dl_do_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
+ ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
+{
+ int reloc_type;
+ int symtab_index;
+ char *symname = NULL;
+ unsigned long *reloc_addr;
+ unsigned long symbol_addr;
+#if defined (__SUPPORT_LD_DEBUG__)
+ unsigned long old_val = 0;
+#endif
+ struct elf_resolve *tls_tpnt = NULL;
+ struct symbol_ref sym_ref;
+
+ reloc_addr = (unsigned long *)(tpnt->loadaddr + rpnt->r_offset);
+ reloc_type = ELF_R_TYPE(rpnt->r_info);
+ symtab_index = ELF_R_SYM(rpnt->r_info);
+ symbol_addr = 0;
+ sym_ref.sym = &symtab[symtab_index];
+ sym_ref.tpnt = NULL;
+
+ if (symtab_index) {
+ symname = strtab + symtab[symtab_index].st_name;
+ symbol_addr = (unsigned long)_dl_find_hash(symname, scope, tpnt,
+ elf_machine_type_class(reloc_type), &sym_ref);
+
+ if (!symbol_addr
+ && ELF_ST_TYPE(symtab[symtab_index].st_info) != STT_TLS
+ && ELF_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK) {
+ _dl_dprintf(2, "%s: can't resolve symbol '%s'\n",
+ _dl_progname, symname);
+ return 1;
+ };
+ if (_dl_trace_prelink) {
+ _dl_debug_lookup(symname, tpnt, &symtab[symtab_index],
+ &sym_ref, elf_machine_type_class(reloc_type));
+ }
+ tls_tpnt = sym_ref.tpnt;
+ }
+
+#if defined (__SUPPORT_LD_DEBUG__)
+ if (reloc_type != R_METAG_NONE)
+ old_val = __get_unaligned_reloc(reloc_addr);
+#endif
+
+#if defined USE_TLS && USE_TLS
+ /* In case of a TLS reloc, tls_tpnt NULL means we have an 'anonymous'
+ symbol. This is the case for a static tls variable, so the lookup
+ module is just that one is referencing the tls variable. */
+ if (!tls_tpnt)
+ tls_tpnt = tpnt;
+#endif
+ switch (reloc_type) {
+ case R_METAG_NONE:
+ break;
+ case R_METAG_GLOB_DAT:
+ case R_METAG_JMP_SLOT:
+ case R_METAG_ADDR32:
+ __put_unaligned_reloc(reloc_addr,
+ symbol_addr + rpnt->r_addend);
+ break;
+ case R_METAG_COPY:
+#if defined (__SUPPORT_LD_DEBUG__)
+ if (_dl_debug_move)
+ _dl_dprintf(_dl_debug_file,
+ "\t%s move %d bytes from %x to %x\n",
+ symname, symtab[symtab_index].st_size,
+ symbol_addr + rpnt->r_addend,
+ reloc_addr);
+#endif
+
+ _dl_memcpy((char *)reloc_addr,
+ (char *)symbol_addr + rpnt->r_addend,
+ symtab[symtab_index].st_size);
+ break;
+ case R_METAG_RELATIVE:
+ __put_unaligned_reloc(reloc_addr,
+ (unsigned long)tpnt->loadaddr +
+ rpnt->r_addend);
+ break;
+#if defined USE_TLS && USE_TLS
+ case R_METAG_TLS_DTPMOD:
+ *reloc_addr = tls_tpnt->l_tls_modid;
+ break;
+ case R_METAG_TLS_DTPOFF:
+ *reloc_addr = symbol_addr;
+ break;
+ case R_METAG_TLS_TPOFF:
+ CHECK_STATIC_TLS ((struct link_map *) tls_tpnt);
+ *reloc_addr = tls_tpnt->l_tls_offset + symbol_addr + rpnt->r_addend;
+ break;
+#endif
+ default:
+ return -1; /* Calls _dl_exit(1). */
+ }
+
+#if defined (__SUPPORT_LD_DEBUG__)
+ if (_dl_debug_reloc && _dl_debug_detail && reloc_type != R_METAG_NONE) {
+ unsigned long new_val = __get_unaligned_reloc(reloc_addr);
+ _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x\n",
+ old_val, new_val, reloc_addr);
+ }
+#endif
+
+ return 0;
+}
+
+static int
+_dl_do_lazy_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
+ ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
+{
+ int reloc_type;
+ unsigned long *reloc_addr;
+#if defined (__SUPPORT_LD_DEBUG__)
+ unsigned long old_val;
+#endif
+
+ reloc_addr = (unsigned long *)(tpnt->loadaddr + rpnt->r_offset);
+ reloc_type = ELF_R_TYPE(rpnt->r_info);
+
+#if defined (__SUPPORT_LD_DEBUG__)
+ old_val = *reloc_addr;
+#endif
+
+ switch (reloc_type) {
+ case R_METAG_NONE:
+ break;
+ case R_METAG_JMP_SLOT:
+ *reloc_addr += (unsigned long)tpnt->loadaddr;
+ break;
+ default:
+ return -1; /* Calls _dl_exit(1). */
+ }
+
+#if defined (__SUPPORT_LD_DEBUG__)
+ if (_dl_debug_reloc && _dl_debug_detail)
+ _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x\n",
+ old_val, *reloc_addr, reloc_addr);
+#endif
+
+ return 0;
+}
+
+/* External interface to the generic part of the dynamic linker. */
+
+void
+_dl_parse_lazy_relocation_information(struct dyn_elf *rpnt,
+ unsigned long rel_addr,
+ unsigned long rel_size)
+{
+ _dl_parse(rpnt->dyn, NULL, rel_addr, rel_size, _dl_do_lazy_reloc);
+}
+
+int
+_dl_parse_relocation_information(struct dyn_elf *rpnt,
+ struct r_scope_elem *scope,
+ unsigned long rel_addr,
+ unsigned long rel_size)
+{
+ return _dl_parse(rpnt->dyn, scope, rel_addr,
+ rel_size, _dl_do_reloc);
+}
diff --git a/ldso/ldso/metag/metag_load_tp.S b/ldso/ldso/metag/metag_load_tp.S
new file mode 100644
index 000000000..2f00a9fef
--- /dev/null
+++ b/ldso/ldso/metag/metag_load_tp.S
@@ -0,0 +1,20 @@
+! Copyright (C) 2013 Imagination Technologies Ltd.
+
+! Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+
+#include <features.h>
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+
+#include <sysdep.h>
+
+ .text
+ .global ___metag_load_tp
+ .type ___metag_load_tp,@function
+
+___metag_load_tp:
+ MOVT D1Ar1,#HI(0x6ffff000)
+ JUMP D1Ar1,#LO(0x6ffff000)
+ .size ___metag_load_tp,.-___metag_load_tp
+
+#endif /* __UCLIBC_HAS_THREADS_NATIVE__ */
diff --git a/ldso/ldso/metag/resolve.S b/ldso/ldso/metag/resolve.S
new file mode 100644
index 000000000..8f23a340a
--- /dev/null
+++ b/ldso/ldso/metag/resolve.S
@@ -0,0 +1,51 @@
+/*
+ * Meta dynamic resolver
+ *
+ * Copyright (C) 2013 Imagination Technologies Ltd.
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ *
+ * This function is _not_ called directly. It is jumped to (so no return
+ * address is on the stack) when attempting to use a symbol that has not yet
+ * been resolved. The first time a jump symbol (such as a function call inside
+ * a shared library) is used (before it gets resolved) it will jump here to
+ * _dl_linux_resolve. When we get called the stack looks like this:
+ * reloc_entry
+ * tpnt
+ *
+ * This function saves all the registers then makes the function call
+ * _dl_linux_resolver(tpnt, reloc_entry). _dl_linux_resolver() figures out
+ * where the jump symbol is _really_ supposed to have jumped to and returns
+ * that to us. Once we have that, we overwrite tpnt with this fixed up
+ * address. We then clean up after ourselves, put all the registers back how we
+ * found them, then we jump to the fixed up address, which is where the jump
+ * symbol that got us here really wanted to jump to in the first place.
+ * -Erik Andersen
+ */
+
+ .text
+ .global __dl_linux_resolve
+ .type __dl_linux_resolve,@function
+
+__dl_linux_resolve:
+ !! Save registers on the stack. Do we need to save any more here?
+ MSETL [A0StP++],D0Ar6,D0Ar4,D0Ar2,D0FrT
+ SETL [A0StP++],A0FrP,A1LbP
+ !! Get the args for _dl_linux_resolver off the stack
+ GETL D0Re0,D1Re0,[A0StP+#-(6*8)]
+ GETD D1Ar1,[D0Re0]
+ MOV D0Ar2,D1Re0
+ !! Multiply plt_index by sizeof(Elf32_Rela)
+ MULW D0Ar2,D0Ar2,#12
+ !! Call the resolver
+ CALLR D1RtP,__dl_linux_resolver
+ !! Restore the registers from the stack
+ SUB A0.2,A0StP,#(1*8)
+ GETL A0FrP,A1LbP,[A0.2]
+ SUB A0.2,A0.2,#(4*8)
+ MGETL D0Ar6,D0Ar4,D0Ar2,D0FrT,[A0.2]
+ !! Also take into account args pushed by PLT
+ SUB A0StP,A0StP,#(6*8)
+ !! Jump to the resolved address
+ MOV PC,D0Re0
+ .size __dl_linux_resolve, .-__dl_linux_resolve
diff --git a/ldso/ldso/microblaze/dl-debug.h b/ldso/ldso/microblaze/dl-debug.h
new file mode 100644
index 000000000..6fd7bd59f
--- /dev/null
+++ b/ldso/ldso/microblaze/dl-debug.h
@@ -0,0 +1,54 @@
+/* vi: set sw=4 ts=4: */
+/* microblaze shared library loader suppport
+ *
+ * Copyright (C) 2011 Ryan Flux
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. The name of the above contributors may not be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+static const char * const _dl_reltypes_tab[] =
+ {
+ "R_MICROBLAZE_NONE",
+ "R_MICROBLAZE_32",
+ "R_MICROBLAZE_32_PCREL",
+ "R_MICROBLAZE_64_PCREL",
+ "R_MICROBLAZE_32_PCREL_LO",
+ "R_MICROBLAZE_64",
+ "R_MICROBLAZE_32_LO",
+ "R_MICROBLAZE_SRO32",
+ "R_MICROBLAZE_SRW32",
+ "R_MICROBLAZE_64_NONE",
+ "R_MICROBLAZE_32_SYM_OP_SYM",
+ "R_MICROBLAZE_GNU_VTINHERIT",
+ "R_MICROBLAZE_GNU_VTENTRY",
+ "R_MICROBLAZE_GOTPC_64",
+ "R_MICROBLAZE_GOT_64",
+ "R_MICROBLAZE_PLT_64",
+ "R_MICROBLAZE_REL",
+ "R_MICROBLAZE_JUMP_SLOT",
+ "R_MICROBLAZE_GLOB_DAT",
+ "R_MICROBLAZE_GOTOFF_64",
+ "R_MICROBLAZE_GOTOFF_32",
+ "R_MICROBLAZE_COPY",
+ };
diff --git a/ldso/ldso/microblaze/dl-startup.h b/ldso/ldso/microblaze/dl-startup.h
new file mode 100644
index 000000000..ba15a87c3
--- /dev/null
+++ b/ldso/ldso/microblaze/dl-startup.h
@@ -0,0 +1,102 @@
+/* Startup code for the microblaze platform, based on glibc 2.3.6, dl-machine.h */
+
+/*
+ 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/>. */
+
+__asm__ ("\
+ .text\n\
+ .globl _start\n\
+ .type _start,@function\n\
+ .hidden _start\n\
+_start:\n\
+ addk r5,r0,r1\n\
+ addk r3,r0,r0\n\
+1:\n\
+ addik r5,r5,4\n\
+ lw r4,r5,r0\n\
+ bneid r4,1b\n\
+ addik r3,r3,1\n\
+ addik r3,r3,-1\n\
+ addk r5,r0,r1\n\
+ sw r3,r5,r0\n\
+ addik r1,r1,-24\n\
+ sw r15,r1,r0\n\
+ brlid r15,_dl_start\n\
+ nop\n\
+ /* FALLTHRU */\n\
+\n\
+ .globl _dl_start_user\n\
+ .type _dl_start_user,@function\n\
+_dl_start_user:\n\
+ mfs r20,rpc\n\
+ addik r20,r20,_GLOBAL_OFFSET_TABLE_+8\n\
+ lwi r4,r20,_dl_skip_args@GOTOFF\n\
+ lwi r5,r1,24\n\
+ rsubk r5,r4,r5\n\
+ addk r4,r4,r4\n\
+ addk r4,r4,r4\n\
+ addk r1,r1,r4\n\
+ swi r5,r1,24\n\
+ swi r3,r1,20\n\
+ addk r6,r5,r0\n\
+ addk r5,r5,r5\n\
+ addk r5,r5,r5\n\
+ addik r7,r1,28\n\
+ addk r8,r7,r5\n\
+ addik r8,r8,4\n\
+ lwi r5,r1,24\n\
+ lwi r3,r1,20\n\
+ addk r4,r5,r5\n\
+ addk r4,r4,r4\n\
+ addik r6,r1,28\n\
+ addk r7,r6,r4\n\
+ addik r7,r7,4\n\
+ addik r15,r20,_dl_fini@GOTOFF\n\
+ addik r15,r15,-8\n\
+ brad r3\n\
+ addik r1,r1,24\n\
+ nop\n\
+ .size _dl_start_user, . - _dl_start_user\n\
+ .previous");
+
+/*
+ * Get a pointer to the argv array. On many platforms this can be just
+ * the address of the first argument, on other platforms we need to
+ * do something a little more subtle here.
+ */
+#define GET_ARGV(ARGVP, ARGS) ARGVP = (((unsigned long*) ARGS)+1)
+
+/* The ld.so library requires relocations */
+#define ARCH_NEEDS_BOOTSTRAP_RELOCS
+
+static __always_inline
+void PERFORM_BOOTSTRAP_RELOC(ELF_RELOC *rpnt, unsigned long *reloc_addr,
+ unsigned long symbol_addr, unsigned long load_addr, attribute_unused Elf32_Sym *symtab)
+{
+
+ switch (ELF_R_TYPE(rpnt->r_info))
+ {
+ case R_MICROBLAZE_REL:
+
+ *reloc_addr = load_addr + rpnt->r_addend;
+ break;
+
+ default:
+ _dl_exit(1);
+ break;
+
+ }
+
+}
diff --git a/ldso/ldso/microblaze/dl-syscalls.h b/ldso/ldso/microblaze/dl-syscalls.h
new file mode 100644
index 000000000..f40c4fd31
--- /dev/null
+++ b/ldso/ldso/microblaze/dl-syscalls.h
@@ -0,0 +1 @@
+/* stub for arch-specific syscall issues */
diff --git a/ldso/ldso/microblaze/dl-sysdep.h b/ldso/ldso/microblaze/dl-sysdep.h
new file mode 100644
index 000000000..2b5521887
--- /dev/null
+++ b/ldso/ldso/microblaze/dl-sysdep.h
@@ -0,0 +1,84 @@
+/* elf reloc code for the microblaze platform, based on glibc 2.3.6, dl-machine.h */
+
+/*
+ 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/>. */
+
+/* Use reloca */
+#define ELF_USES_RELOCA
+
+#include <elf.h>
+
+
+/* Initialise the GOT */
+#define INIT_GOT(GOT_BASE,MODULE) \
+do { \
+ GOT_BASE[2] = (unsigned long) _dl_linux_resolve; \
+ GOT_BASE[1] = (unsigned long) MODULE; \
+} while(0)
+
+/* Here we define the magic numbers that this dynamic loader should accept */
+
+#define MAGIC1 EM_MICROBLAZE_OLD
+#undef MAGIC2
+/* Used for error messages */
+#define ELF_TARGET "microblaze"
+
+#define elf_machine_type_class(type) \
+ (((type) == R_MICROBLAZE_JUMP_SLOT) * ELF_RTYPE_CLASS_PLT \
+ | ((type) == R_MICROBLAZE_COPY) * ELF_RTYPE_CLASS_COPY)
+
+/* Return the link-time address of _DYNAMIC. Conveniently, this is the
+ first element of the GOT. This must be inlined in a function which
+ uses global data. */
+static inline Elf32_Addr
+elf_machine_dynamic (void)
+{
+ Elf32_Addr got_entry_0;
+ __asm__ __volatile__(
+ "lwi %0,r20,0"
+ :"=r"(got_entry_0)
+ );
+ return got_entry_0;
+}
+
+
+/* Return the run-time load address of the shared object. */
+static inline Elf32_Addr
+elf_machine_load_address (void)
+{
+ /* Compute the difference between the runtime address of _DYNAMIC as seen
+ by a GOTOFF reference, and the link-time address found in the special
+ unrelocated first GOT entry. */
+ Elf32_Addr dyn;
+ __asm__ __volatile__ (
+ "addik %0,r20,_DYNAMIC@GOTOFF"
+ : "=r"(dyn)
+ );
+ return dyn - elf_machine_dynamic ();
+}
+
+
+
+static __always_inline void
+elf_machine_relative (Elf32_Addr load_off, const Elf32_Addr rel_addr,
+ Elf32_Word relative_count)
+{
+ Elf32_Rel * rpnt = (void *) rel_addr;
+ do {
+ Elf32_Addr *const reloc_addr = (void *) (load_off + (rpnt)->r_offset);
+
+ *reloc_addr += load_off;
+ } while (--relative_count);
+}
diff --git a/ldso/ldso/microblaze/elfinterp.c b/ldso/ldso/microblaze/elfinterp.c
new file mode 100644
index 000000000..1f6aeffb7
--- /dev/null
+++ b/ldso/ldso/microblaze/elfinterp.c
@@ -0,0 +1,330 @@
+/* vi: set sw=4 ts=4: */
+/* microblaze ELF shared library loader suppport
+ *
+ * Copyright (c) 1994-2000 Eric Youngdale, Peter MacDonald,
+ * David Engel, Hongjiu Lu and Mitch D'Souza
+ * Copyright (C) 2001-2004 Erik Andersen
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. The name of the above contributors may not be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "ldso.h"
+
+/* Program to load an ELF binary on a linux system, and run it.
+ References to symbols in sharable libraries can be resolved by either
+ an ELF sharable library or a linux style of shared library. */
+
+/* Disclaimer: I have never seen any AT&T source code for SVr4, nor have
+ I ever taken any courses on internals. This program was developed using
+ information available through the book "UNIX SYSTEM V RELEASE 4,
+ Programmers guide: Ansi C and Programming Support Tools", which did
+ a more than adequate job of explaining everything required to get this
+ working. */
+
+extern int _dl_linux_resolve(void);
+
+unsigned long
+_dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
+{
+ ELF_RELOC *this_reloc;
+ char *strtab;
+ ElfW(Sym) *symtab;
+ int symtab_index;
+ char *rel_addr;
+ char *new_addr;
+ char **got_addr;
+ ElfW(Addr) instr_addr;
+ char *symname;
+
+ rel_addr = (char *)tpnt->dynamic_info[DT_JMPREL];
+ this_reloc = (ELF_RELOC *)(rel_addr + reloc_entry);
+ symtab_index = ELF_R_SYM(this_reloc->r_info);
+
+ symtab = (ElfW(Sym) *)tpnt->dynamic_info[DT_SYMTAB];
+ strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
+ symname = strtab + symtab[symtab_index].st_name;
+
+ /* Address of the jump instruction to fix up. */
+ instr_addr = (this_reloc->r_offset + tpnt->loadaddr);
+ got_addr = (char **)instr_addr;
+
+ /* Get the address of the GOT entry. */
+ new_addr = _dl_find_hash(symname, &_dl_loaded_modules->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT, NULL);
+ if (unlikely(!new_addr)) {
+ _dl_dprintf(2, "%s: Can't resolve symbol '%s'\n", _dl_progname, symname);
+ _dl_exit(1);
+ }
+
+#if defined (__SUPPORT_LD_DEBUG__)
+ if ((unsigned long)got_addr < 0x40000000) {
+ if (_dl_debug_bindings) {
+ _dl_dprintf(_dl_debug_file, "\nresolve function: %s", symname);
+ if (_dl_debug_detail)
+ _dl_dprintf(_dl_debug_file,
+ "\tpatched: %x ==> %x @ %x\n",
+ *got_addr, new_addr, got_addr);
+ }
+ }
+ if (!_dl_debug_nofixups)
+#endif
+ *got_addr = new_addr;
+
+ return (unsigned long)new_addr;
+}
+
+static int
+_dl_parse(struct elf_resolve *tpnt, struct r_scope_elem *scope,
+ unsigned long rel_addr, unsigned long rel_size,
+ int (*reloc_fnc)(struct elf_resolve *tpnt, struct r_scope_elem *scope,
+ ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab))
+{
+ unsigned int i;
+ char *strtab;
+ ElfW(Sym) *symtab;
+ ELF_RELOC *rpnt;
+ int symtab_index;
+
+ /* Parse the relocation information. */
+ rpnt = (ELF_RELOC *)rel_addr;
+ rel_size /= sizeof(ELF_RELOC);
+
+ symtab = (ElfW(Sym) *)tpnt->dynamic_info[DT_SYMTAB];
+ strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
+
+ for (i = 0; i < rel_size; i++, rpnt++) {
+ int res;
+
+ symtab_index = ELF_R_SYM(rpnt->r_info);
+
+ debug_sym(symtab, strtab, symtab_index);
+ debug_reloc(symtab, strtab, rpnt);
+
+ res = reloc_fnc(tpnt, scope, rpnt, symtab, strtab);
+
+ if (res == 0)
+ continue;
+
+ _dl_dprintf(2, "\n%s: ", _dl_progname);
+
+ if (symtab_index)
+ _dl_dprintf(2, "symbol '%s': ",
+ strtab + symtab[symtab_index].st_name);
+
+ if (unlikely(res < 0)) {
+ int reloc_type = ELF_R_TYPE(rpnt->r_info);
+
+ _dl_dprintf(2, "can't handle reloc type "
+#if defined (__SUPPORT_LD_DEBUG__)
+ "%s\n", _dl_reltypes(reloc_type));
+#else
+ "%x\n", reloc_type);
+#endif
+ _dl_exit(-res);
+ } else if (unlikely(res > 0)) {
+ _dl_dprintf(2, "can't resolve symbol\n");
+ return res;
+ }
+ }
+
+ return 0;
+}
+
+static int
+_dl_do_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
+ ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
+{
+ int reloc_type;
+ int symtab_index;
+ char *symname;
+#if defined USE_TLS && USE_TLS
+ struct elf_resolve *tls_tpnt;
+#endif
+ struct symbol_ref sym_ref;
+ ElfW(Addr) *reloc_addr;
+ ElfW(Addr) symbol_addr;
+#if defined (__SUPPORT_LD_DEBUG__)
+ ElfW(Addr) old_val;
+#endif
+
+ reloc_addr = (ElfW(Addr)*)(tpnt->loadaddr + (unsigned long)rpnt->r_offset);
+ reloc_type = ELF_R_TYPE(rpnt->r_info);
+ symtab_index = ELF_R_SYM(rpnt->r_info);
+ sym_ref.sym = &symtab[symtab_index];
+ sym_ref.tpnt = NULL;
+ symbol_addr = 0;
+ symname = strtab + sym_ref.sym->st_name;
+
+ if (symtab_index) {
+ symbol_addr = (ElfW(Addr))_dl_find_hash(symname, scope, tpnt,
+ elf_machine_type_class(reloc_type), &sym_ref);
+ /*
+ * We want to allow undefined references to weak symbols - this
+ * might have been intentional. We should not be linking local
+ * symbols here, so all bases should be covered.
+ */
+ if (unlikely(!symbol_addr && (ELF_ST_TYPE(sym_ref.sym->st_info) != STT_TLS)
+ && (ELF_ST_BIND(sym_ref.sym->st_info) != STB_WEAK))) {
+ /* This may be non-fatal if called from dlopen. */
+ return 1;
+ }
+#if defined USE_TLS && USE_TLS
+ tls_tpnt = sym_ref.tpnt;
+#endif
+ } else {
+ /* Relocs against STN_UNDEF are usually treated as using a
+ * symbol value of zero, and using the module containing the
+ * reloc itself. */
+ symbol_addr = sym_ref.sym->st_value;
+#if defined USE_TLS && USE_TLS
+ tls_tpnt = tpnt;
+#endif
+ }
+
+
+#if defined (__SUPPORT_LD_DEBUG__)
+ if (reloc_addr) {
+ old_val = *reloc_addr;
+ } else {
+ old_val = 0;
+ }
+#endif
+
+ switch (reloc_type) {
+ case R_MICROBLAZE_NONE:
+ case R_MICROBLAZE_64_NONE:
+ break;
+
+ case R_MICROBLAZE_64:
+ *reloc_addr = symbol_addr + rpnt->r_addend;
+ break;
+
+ case R_MICROBLAZE_32:
+ case R_MICROBLAZE_32_LO:
+ *reloc_addr = symbol_addr + rpnt->r_addend;
+ break;
+
+ case R_MICROBLAZE_32_PCREL:
+ case R_MICROBLAZE_32_PCREL_LO:
+ case R_MICROBLAZE_64_PCREL:
+ case R_MICROBLAZE_SRO32:
+ case R_MICROBLAZE_SRW32:
+ *reloc_addr = symbol_addr + rpnt->r_addend;
+ break;
+
+ case R_MICROBLAZE_GLOB_DAT:
+ case R_MICROBLAZE_JUMP_SLOT:
+ *reloc_addr = symbol_addr + rpnt->r_addend;
+ break;
+/* Handled by elf_machine_relative */
+ case R_MICROBLAZE_REL:
+ *reloc_addr = (unsigned long)tpnt->loadaddr + rpnt->r_addend;
+ break;
+
+ case R_MICROBLAZE_COPY:
+ if (symbol_addr) {
+#if defined (__SUPPORT_LD_DEBUG__)
+ if (_dl_debug_move)
+ _dl_dprintf(_dl_debug_file,
+ "\t%s move %d bytes from %x to %x\n",
+ symname, sym_ref.sym->st_size,
+ symbol_addr, reloc_addr);
+#endif
+
+ _dl_memcpy((char *)reloc_addr,
+ (char *)symbol_addr,
+ sym_ref.sym->st_size);
+ }
+#if defined (__SUPPORT_LD_DEBUG__)
+ else
+ _dl_dprintf(_dl_debug_file, "no symbol_addr to copy !?\n");
+#endif
+ break;
+
+ default:
+ return -1; /* Calls _dl_exit(1). */
+ }
+
+#if defined (__SUPPORT_LD_DEBUG__)
+ if (_dl_debug_reloc && _dl_debug_detail)
+ _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x\n",
+ old_val, *reloc_addr, reloc_addr);
+#endif
+
+ return 0;
+}
+
+static int
+_dl_do_lazy_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
+ ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
+{
+ int reloc_type;
+ int symtab_index;
+ ElfW(Addr) *reloc_addr;
+#if defined (__SUPPORT_LD_DEBUG__)
+ ElfW(Addr) old_val;
+#endif
+
+ (void)scope;
+ symtab_index = ELF_R_SYM(rpnt->r_info);
+ (void)strtab;
+
+ reloc_addr = (ElfW(Addr)*)(tpnt->loadaddr + rpnt->r_offset);
+ reloc_type = ELF_R_TYPE(rpnt->r_info);
+
+#if defined (__SUPPORT_LD_DEBUG__)
+ old_val = *reloc_addr;
+#endif
+
+ switch (reloc_type) {
+ case R_MICROBLAZE_NONE:
+ break;
+ case R_MICROBLAZE_JUMP_SLOT:
+ *reloc_addr += (unsigned long)tpnt->loadaddr;
+ break;
+ default:
+ _dl_exit(1);
+ }
+
+#if defined (__SUPPORT_LD_DEBUG__)
+ if (_dl_debug_reloc && _dl_debug_detail)
+ _dl_dprintf(_dl_debug_file, "\tpatched_lazy: %x ==> %x @ %x\n",
+ old_val, *reloc_addr, reloc_addr);
+#endif
+
+ return 0;
+}
+
+void
+_dl_parse_lazy_relocation_information(struct dyn_elf *rpnt,
+ unsigned long rel_addr, unsigned long rel_size)
+{
+ (void)_dl_parse(rpnt->dyn, NULL, rel_addr, rel_size, _dl_do_lazy_reloc);
+}
+
+int
+_dl_parse_relocation_information(struct dyn_elf *rpnt,
+ struct r_scope_elem *scope, unsigned long rel_addr, unsigned long rel_size)
+{
+ return _dl_parse(rpnt->dyn, scope, rel_addr, rel_size, _dl_do_reloc);
+}
diff --git a/ldso/ldso/microblaze/resolve.S b/ldso/ldso/microblaze/resolve.S
new file mode 100644
index 000000000..67164d27c
--- /dev/null
+++ b/ldso/ldso/microblaze/resolve.S
@@ -0,0 +1,51 @@
+
+/* This code is used in dl-runtime.c to call the `fixup' function
+ and then redirect to the address it returns. */
+/* We assume that R3 contain relocation offset and R4 contains
+ link_map (_DYNAMIC). This must be consistent with the JUMP_SLOT
+ layout generated by binutils. */
+
+/* Based on glibc 2.3.6, dl-machine.h */
+/*
+ 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/>. */
+
+.text
+.align 4
+.globl _dl_linux_resolver
+.globl _dl_linux_resolve
+.type _dl_linux_resolve,@function
+
+_dl_linux_resolve:
+ addik r1,r1,-40
+ swi r5,r1,12
+ swi r6,r1,16
+ swi r7,r1,20
+ swi r8,r1,24
+ swi r9,r1,28
+ swi r10,r1,32
+ swi r15,r1,0
+ addk r5,r0,r4
+ brlid r15, _dl_linux_resolver
+ addk r6,r0,r3; /* delay slot */
+ lwi r10,r1,32
+ lwi r9,r1,28
+ lwi r8,r1,24
+ lwi r7,r1,20
+ lwi r6,r1,16
+ lwi r5,r1,12
+ lwi r15,r1,0
+ brad r3
+ addik r1,r1,40; /* delay slot */
+ .size _dl_linux_resolve, . - _dl_linux_resolve
diff --git a/ldso/ldso/mips/README b/ldso/ldso/mips/README
index 9ca6a869b..c47109d3d 100644
--- a/ldso/ldso/mips/README
+++ b/ldso/ldso/mips/README
@@ -13,7 +13,7 @@ The code is taken from the function 'RTLD_START' in the file
elfinterp.c
-----------
Contains the runtime resolver code taken from the function
-'__dl_runtime_resolve' in 'sysdeps/mips/dl-machine.h'. Also
+'__dl_runtime_resolve' in 'sysdeps/mips/dl-trampoline.h'. Also
contains the function to perform relocations for objects
other than the linker itself. The code was taken from the
function 'elf_machine_rel' in 'sysdeps/mips/dl-machine.h'.
@@ -47,6 +47,6 @@ resolve.S
---------
Contains the low-level assembly code for the dynamic runtime
resolver. The code is taken from the assembly code function
-'_dl_runtime_resolve' in the file 'sysdeps/mips/dl-machine.h'.
+'_dl_runtime_resolve' in the file 'sysdeps/mips/dl-trampoline.h'.
The code looks a bit different since we only need to pass the
symbol index and the old GP register.
diff --git a/ldso/ldso/mips/dl-debug.h b/ldso/ldso/mips/dl-debug.h
index 07a2addfa..e71aaf739 100644
--- a/ldso/ldso/mips/dl-debug.h
+++ b/ldso/ldso/mips/dl-debug.h
@@ -27,7 +27,7 @@
* SUCH DAMAGE.
*/
-static const char *_dl_reltypes_tab[] =
+static const char * const _dl_reltypes_tab[] =
{
[0] "R_MIPS_NONE", "R_MIPS_16", "R_MIPS_32",
[3] "R_MIPS_REL32", "R_MIPS_26", "R_MIPS_HI16",
@@ -40,6 +40,15 @@ static const char *_dl_reltypes_tab[] =
[25] "R_MIPS_INSERT_A", "R_MIPS_INSERT_B", "R_MIPS_DELETE",
[28] "R_MIPS_HIGHER", "R_MIPS_HIGHEST", "R_MIPS_CALL_HI16",
[31] "R_MIPS_CALL_LO16", "R_MIPS_SCN_DISP", "R_MIPS_REL16",
- [34] "R_MIPS_ADD_IMMEDIATE", "R_MIPS_PJUMP", "R_MIPS_RELGOT",
- [37] "R_MIPS_JALR",
+ [34] "R_MIPS_ADD_IMMEDIATE", "R_MIPS_PJUMP", "R_MIPS_RELGOT",
+ [37] "R_MIPS_JALR", "R_MIPS_TLS_DTPMOD32", "R_MIPS_TLS_DTPREL32",
+ [40] "R_MIPS_TLS_DTPMOD64", "R_MIPS_TLS_DTPREL64", "R_MIPS_TLS_GD",
+ [43] "R_MIPS_TLS_LDM", "R_MIPS_TLS_DTPREL_HI16",
+ [45] "R_MIPS_TLS_DTPREL_LO16",
+ [46] "R_MIPS_TLS_GOTTPREL", "R_MIPS_TLS_TPREL32", "R_MIPS_TLS_TPREL64",
+ [49] "R_MIPS_TLS_TPREL_HI16",
+ [50] "R_MIPS_TLS_TPREL_LO16",
+ [51] "R_MIPS_GLOB_DAT",
+ [126] "R_MIPS_COPY", "R_MIPS_JUMP_SLOT",
+
};
diff --git a/ldso/ldso/mips/dl-startup.h b/ldso/ldso/mips/dl-startup.h
index 606b162a3..0cab7be32 100644
--- a/ldso/ldso/mips/dl-startup.h
+++ b/ldso/ldso/mips/dl-startup.h
@@ -12,6 +12,7 @@ __asm__(""
" .globl _start\n"
" .ent _start\n"
" .type _start,@function\n"
+ " .hidden _start\n"
"_start:\n"
" .set noreorder\n"
" move $25, $31\n"
@@ -36,6 +37,7 @@ __asm__(""
#if _MIPS_SIM == _MIPS_SIM_ABI32
" subu $29, 16\n"
#endif
+# if !defined __mips_isa_rev || __mips_isa_rev < 6
#if _MIPS_SIM == _MIPS_SIM_ABI64
" dla $8, .coff\n"
#else /* O32 || N32 */
@@ -43,6 +45,10 @@ __asm__(""
#endif /* O32 || N32 */
" bltzal $8, .coff\n"
".coff:\n"
+# else
+ ".coff:\n"
+ " lapc $31, .coff\n"
+# endif
#if _MIPS_SIM == _MIPS_SIM_ABI64
" dsubu $8, $31, $8\n"
" dla $25, _dl_start\n"
@@ -111,7 +117,7 @@ __asm__(""
/*
* Get a pointer to the argv array. On many platforms this can be just
- * the address if the first argument, on other platforms we need to
+ * the address of the first argument, on other platforms we need to
* do something a little more subtle here.
*/
#define GET_ARGV(ARGVP, ARGS) ARGVP = (((unsigned long *) ARGS)+1)
diff --git a/ldso/ldso/mips/dl-syscalls.h b/ldso/ldso/mips/dl-syscalls.h
index 996bb87c6..f40c4fd31 100644
--- a/ldso/ldso/mips/dl-syscalls.h
+++ b/ldso/ldso/mips/dl-syscalls.h
@@ -1,6 +1 @@
-/* We can't use the real errno in ldso, since it has not yet
- * been dynamicly linked in yet. */
-#include "sys/syscall.h"
-extern int _dl_errno;
-#undef __set_errno
-#define __set_errno(X) {(_dl_errno) = (X);}
+/* stub for arch-specific syscall issues */
diff --git a/ldso/ldso/mips/dl-sysdep.h b/ldso/ldso/mips/dl-sysdep.h
index 312b9e858..0122199e4 100644
--- a/ldso/ldso/mips/dl-sysdep.h
+++ b/ldso/ldso/mips/dl-sysdep.h
@@ -93,10 +93,11 @@ typedef struct
#include <link.h>
-#define ARCH_NUM 3
+#define ARCH_NUM 4
#define DT_MIPS_GOTSYM_IDX (DT_NUM + OS_NUM)
#define DT_MIPS_LOCAL_GOTNO_IDX (DT_NUM + OS_NUM +1)
#define DT_MIPS_SYMTABNO_IDX (DT_NUM + OS_NUM +2)
+#define DT_MIPS_PLTGOT_IDX (DT_NUM + OS_NUM +3)
#define ARCH_DYNAMIC_INFO(dpnt, dynamic, debug_addr) \
do { \
@@ -106,14 +107,20 @@ else if (dpnt->d_tag == DT_MIPS_LOCAL_GOTNO) \
dynamic[DT_MIPS_LOCAL_GOTNO_IDX] = dpnt->d_un.d_val; \
else if (dpnt->d_tag == DT_MIPS_SYMTABNO) \
dynamic[DT_MIPS_SYMTABNO_IDX] = dpnt->d_un.d_val; \
-else if (dpnt->d_tag == DT_MIPS_RLD_MAP) \
+else if (dpnt->d_tag == DT_MIPS_PLTGOT) \
+ dynamic[DT_MIPS_PLTGOT_IDX] = dpnt->d_un.d_val; \
+else if ((dpnt->d_tag == DT_MIPS_RLD_MAP) && (dpnt->d_un.d_ptr)) \
*(ElfW(Addr) *)(dpnt->d_un.d_ptr) = (ElfW(Addr)) debug_addr; \
} while (0)
+#define ARCH_SKIP_RELOC(type_class, sym) \
+ ((sym)->st_shndx == SHN_UNDEF && !((sym)->st_other & STO_MIPS_PLT))
+
/* Initialization sequence for the application/library GOT. */
#define INIT_GOT(GOT_BASE,MODULE) \
do { \
unsigned long idx; \
+ unsigned long *pltgot; \
\
/* Check if this is the dynamic linker itself */ \
if (MODULE->libtype == program_interpreter) \
@@ -123,6 +130,12 @@ do { \
GOT_BASE[0] = (unsigned long) _dl_runtime_resolve; \
GOT_BASE[1] = (unsigned long) MODULE; \
\
+ pltgot = (unsigned long *) MODULE->dynamic_info[DT_MIPS_PLTGOT_IDX]; \
+ if (pltgot) { \
+ pltgot[0] = (unsigned long) _dl_runtime_pltresolve; \
+ pltgot[1] = (unsigned long) MODULE; \
+ } \
+ \
/* Add load address displacement to all local GOT entries */ \
idx = 2; \
while (idx < MODULE->dynamic_info[DT_MIPS_LOCAL_GOTNO_IDX]) \
@@ -139,31 +152,41 @@ do { \
/* Used for error messages */
#define ELF_TARGET "MIPS"
+/* Need bootstrap relocations */
+#define ARCH_NEEDS_BOOTSTRAP_RELOCS
unsigned long __dl_runtime_resolve(unsigned long sym_index,
unsigned long old_gpreg);
struct elf_resolve;
+unsigned long __dl_runtime_pltresolve(struct elf_resolve *tpnt,
+ int reloc_entry);
+
void _dl_perform_mips_global_got_relocations(struct elf_resolve *tpnt, int lazy);
-/* 4096 bytes alignment */
-#if _MIPS_SIM == _MIPS_SIM_ABI64
-#define PAGE_ALIGN (~0xfffUL)
-#define ADDR_ALIGN 0xfffUL
-#define OFFS_ALIGN (0x10000000000UL-0x1000)
-#else /* O32 || N32 */
-#define PAGE_ALIGN 0xfffff000
-#define ADDR_ALIGN 0xfff
-#define OFFS_ALIGN 0x7ffff000
-#endif /* O32 || N32 */
-
-#define elf_machine_type_class(type) ELF_RTYPE_CLASS_PLT
-/* MIPS does not have COPY relocs */
-#define DL_NO_COPY_RELOCS
+#if defined USE_TLS
+# if _MIPS_SIM == _MIPS_SIM_ABI64
+# define elf_machine_type_class(type) \
+ ((((type) == R_MIPS_JUMP_SLOT || (type) == R_MIPS_TLS_DTPMOD64 \
+ || (type) == R_MIPS_TLS_DTPREL64 || (type) == R_MIPS_TLS_TPREL64) \
+ * ELF_RTYPE_CLASS_PLT) \
+ | (((type) == R_MIPS_COPY) * ELF_RTYPE_CLASS_COPY))
+# else
+# define elf_machine_type_class(type) \
+ ((((type) == R_MIPS_JUMP_SLOT || (type) == R_MIPS_TLS_DTPMOD32 \
+ || (type) == R_MIPS_TLS_DTPREL32 || (type) == R_MIPS_TLS_TPREL32) \
+ * ELF_RTYPE_CLASS_PLT) \
+ | (((type) == R_MIPS_COPY) * ELF_RTYPE_CLASS_COPY))
+# endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */
+#else
+#define elf_machine_type_class(type) \
+ ((((type) == R_MIPS_JUMP_SLOT) * ELF_RTYPE_CLASS_PLT) \
+ | (((type) == R_MIPS_COPY) * ELF_RTYPE_CLASS_COPY))
+#endif /* USE_TLS */
#define OFFSET_GP_GOT 0x7ff0
-static __inline__ ElfW(Addr) *
+static __always_inline ElfW(Addr) *
elf_mips_got_from_gpreg (ElfW(Addr) gpreg)
{
/* FIXME: the offset of gp from GOT may be system-dependent. */
@@ -173,7 +196,7 @@ elf_mips_got_from_gpreg (ElfW(Addr) gpreg)
/* Return the link-time address of _DYNAMIC. Conveniently, this is the
first element of the GOT. This must be inlined in a function which
uses global data. We assume its $gp points to the primary GOT. */
-static __inline__ ElfW(Addr)
+static __always_inline ElfW(Addr)
elf_machine_dynamic (void)
{
register ElfW(Addr) gp __asm__ ("$28");
@@ -192,15 +215,20 @@ elf_machine_dynamic (void)
#endif
/* Return the run-time load address of the shared object. */
-static __inline__ ElfW(Addr)
+static __always_inline ElfW(Addr)
elf_machine_load_address (void)
{
ElfW(Addr) addr;
__asm__ (" .set noreorder\n"
+# if !defined __mips_isa_rev || __mips_isa_rev < 6
" " STRINGXP (PTR_LA) " %0, 0f\n"
" bltzal $0, 0f\n"
" nop\n"
"0: " STRINGXP (PTR_SUBU) " %0, $31, %0\n"
+#else
+ "0: lapc $31, 0\n"
+ " " STRINGXP (PTR_SUBU) " %0, $31, %0\n"
+#endif
" .set reorder\n"
: "=r" (addr)
: /* No inputs */
@@ -208,7 +236,7 @@ elf_machine_load_address (void)
return addr;
}
-static __inline__ void
+static __always_inline void
elf_machine_relative (ElfW(Addr) load_off, const ElfW(Addr) rel_addr,
ElfW(Word) relative_count)
{
diff --git a/ldso/ldso/mips/elfinterp.c b/ldso/ldso/mips/elfinterp.c
index 1b03d9412..6310c7735 100644
--- a/ldso/ldso/mips/elfinterp.c
+++ b/ldso/ldso/mips/elfinterp.c
@@ -30,6 +30,7 @@
#include "ldso.h"
extern int _dl_runtime_resolve(void);
+extern int _dl_runtime_pltresolve(void);
#define OFFSET_GP_GOT 0x7ff0
@@ -55,7 +56,7 @@ unsigned long __dl_runtime_resolve(unsigned long sym_index,
symname = strtab + sym->st_name;
new_addr = (unsigned long) _dl_find_hash(symname,
- tpnt->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT);
+ &_dl_loaded_modules->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT, NULL);
if (unlikely(!new_addr)) {
_dl_dprintf (2, "%s: can't resolve symbol '%s'\n",
_dl_progname, symname);
@@ -83,6 +84,59 @@ unsigned long __dl_runtime_resolve(unsigned long sym_index,
return new_addr;
}
+unsigned long
+__dl_runtime_pltresolve(struct elf_resolve *tpnt, int reloc_entry)
+{
+ ELF_RELOC *this_reloc;
+ char *strtab;
+ ElfW(Sym) *symtab;
+ int symtab_index;
+ char *rel_addr;
+ char *new_addr;
+ char **got_addr;
+ unsigned long instr_addr;
+ char *symname;
+
+ rel_addr = (char *)tpnt->dynamic_info[DT_JMPREL];
+ this_reloc = (ELF_RELOC *)(intptr_t)(rel_addr + reloc_entry);
+ symtab_index = ELF_R_SYM(this_reloc->r_info);
+
+ symtab = (ElfW(Sym) *)(intptr_t)tpnt->dynamic_info[DT_SYMTAB];
+ strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
+ symname = strtab + symtab[symtab_index].st_name;
+
+ /* Address of the jump instruction to fix up. */
+ instr_addr = ((unsigned long)this_reloc->r_offset +
+ (unsigned long)tpnt->loadaddr);
+ got_addr = (char **)instr_addr;
+
+ /* Get the address of the GOT entry. */
+ new_addr = _dl_find_hash(symname, &_dl_loaded_modules->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT, NULL);
+ if (unlikely(!new_addr)) {
+ _dl_dprintf(2, "%s: can't resolve symbol '%s' in lib '%s'.\n", _dl_progname, symname, tpnt->libname);
+ _dl_exit(1);
+ }
+
+#if defined (__SUPPORT_LD_DEBUG__)
+ if ((unsigned long)got_addr < 0x40000000) {
+ if (_dl_debug_bindings) {
+ _dl_dprintf(_dl_debug_file, "\nresolve function: %s", symname);
+ if (_dl_debug_detail)
+ _dl_dprintf(_dl_debug_file,
+ "\n\tpatched: %x ==> %x @ %x",
+ *got_addr, new_addr, got_addr);
+ }
+ }
+ if (!_dl_debug_nofixups) {
+ *got_addr = new_addr;
+ }
+#else
+ *got_addr = new_addr;
+#endif
+
+ return (unsigned long)new_addr;
+}
+
void _dl_parse_lazy_relocation_information(struct dyn_elf *rpnt,
unsigned long rel_addr, unsigned long rel_size)
{
@@ -91,10 +145,10 @@ void _dl_parse_lazy_relocation_information(struct dyn_elf *rpnt,
}
int _dl_parse_relocation_information(struct dyn_elf *xpnt,
- unsigned long rel_addr, unsigned long rel_size)
+ struct r_scope_elem *scope, unsigned long rel_addr, unsigned long rel_size)
{
ElfW(Sym) *symtab;
- ElfW(Rel) *rpnt;
+ ELF_RELOC *rpnt;
char *strtab;
unsigned long i;
unsigned long *got;
@@ -102,18 +156,21 @@ int _dl_parse_relocation_information(struct dyn_elf *xpnt,
unsigned long symbol_addr;
int reloc_type, symtab_index;
struct elf_resolve *tpnt = xpnt->dyn;
+ char *symname = NULL;
#if defined (__SUPPORT_LD_DEBUG__)
unsigned long old_val=0;
#endif
+ struct symbol_ref sym_ref;
/* Now parse the relocation information */
rel_size = rel_size / sizeof(ElfW(Rel));
- rpnt = (ElfW(Rel) *) rel_addr;
+ rpnt = (ELF_RELOC *) rel_addr;
symtab = (ElfW(Sym) *) tpnt->dynamic_info[DT_SYMTAB];
strtab = (char *) tpnt->dynamic_info[DT_STRTAB];
got = (unsigned long *) tpnt->dynamic_info[DT_PLTGOT];
+
for (i = 0; i < rel_size; i++, rpnt++) {
reloc_addr = (unsigned long *) (tpnt->loadaddr +
(unsigned long) rpnt->r_offset);
@@ -123,12 +180,85 @@ int _dl_parse_relocation_information(struct dyn_elf *xpnt,
debug_sym(symtab,strtab,symtab_index);
debug_reloc(symtab,strtab,rpnt);
+ symname = strtab + symtab[symtab_index].st_name;
#if defined (__SUPPORT_LD_DEBUG__)
if (reloc_addr)
old_val = *reloc_addr;
#endif
+ if (reloc_type == R_MIPS_JUMP_SLOT || reloc_type == R_MIPS_COPY) {
+ sym_ref.tpnt = NULL;
+ sym_ref.sym = &symtab[symtab_index];
+ symbol_addr = (unsigned long)_dl_find_hash(symname,
+ scope,
+ tpnt,
+ elf_machine_type_class(reloc_type), &sym_ref);
+ if (unlikely(!symbol_addr && ELF_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK))
+ return 1;
+ if (_dl_trace_prelink) {
+ _dl_debug_lookup (symname, tpnt, &symtab[symtab_index],
+ &sym_ref, elf_machine_type_class(reloc_type));
+ }
+ }
+ if (!symtab_index) {
+ /* Relocs against STN_UNDEF are usually treated as using a
+ * symbol value of zero, and using the module containing the
+ * reloc itself.
+ */
+ symbol_addr = symtab[symtab_index].st_value;
+ }
+
switch (reloc_type) {
+#if defined USE_TLS && USE_TLS
+# if _MIPS_SIM == _MIPS_SIM_ABI64
+ case R_MIPS_TLS_DTPMOD64:
+ case R_MIPS_TLS_DTPREL64:
+ case R_MIPS_TLS_TPREL64:
+# else
+ case R_MIPS_TLS_DTPMOD32:
+ case R_MIPS_TLS_DTPREL32:
+ case R_MIPS_TLS_TPREL32:
+# endif
+ {
+ struct elf_resolve *tls_tpnt = NULL;
+ sym_ref.sym = &symtab[symtab_index];
+ sym_ref.tpnt = NULL;
+
+ if (ELF_ST_BIND(symtab[symtab_index].st_info) != STB_LOCAL) {
+ symbol_addr = (unsigned long) _dl_find_hash(symname, scope,
+ tpnt, elf_machine_type_class(reloc_type), &sym_ref);
+ tls_tpnt = sym_ref.tpnt;
+ }
+ /* In case of a TLS reloc, tls_tpnt NULL means we have an 'anonymous'
+ symbol. This is the case for a static tls variable, so the lookup
+ module is just that one is referencing the tls variable. */
+ if (!tls_tpnt)
+ tls_tpnt = tpnt;
+
+ switch (reloc_type) {
+ case R_MIPS_TLS_DTPMOD64:
+ case R_MIPS_TLS_DTPMOD32:
+ if (tls_tpnt)
+ *(ElfW(Addr) *)reloc_addr = tls_tpnt->l_tls_modid;
+ break;
+
+ case R_MIPS_TLS_DTPREL64:
+ case R_MIPS_TLS_DTPREL32:
+ *(ElfW(Addr) *)reloc_addr +=
+ TLS_DTPREL_VALUE (symbol_addr);
+ break;
+
+ case R_MIPS_TLS_TPREL32:
+ case R_MIPS_TLS_TPREL64:
+ CHECK_STATIC_TLS((struct link_map *)tls_tpnt);
+ *(ElfW(Addr) *)reloc_addr +=
+ TLS_TPREL_VALUE (tls_tpnt, symbol_addr);
+ break;
+ }
+
+ break;
+ }
+#endif /* USE_TLS */
#if _MIPS_SIM == _MIPS_SIM_ABI64
case (R_MIPS_64 << 8) | R_MIPS_REL32:
#else /* O32 || N32 */
@@ -148,6 +278,24 @@ int _dl_parse_relocation_information(struct dyn_elf *xpnt,
*reloc_addr += (unsigned long) tpnt->loadaddr;
}
break;
+ case R_MIPS_JUMP_SLOT:
+ *reloc_addr = symbol_addr;
+ break;
+ case R_MIPS_COPY:
+ if (symbol_addr) {
+#if defined (__SUPPORT_LD_DEBUG__)
+ if (_dl_debug_move)
+ _dl_dprintf(_dl_debug_file,
+ "\n%s move %d bytes from %x to %x",
+ symname, symtab[symtab_index].st_size,
+ symbol_addr, reloc_addr);
+#endif
+
+ _dl_memcpy((char *)reloc_addr,
+ (char *)symbol_addr,
+ symtab[symtab_index].st_size);
+ }
+ break;
case R_MIPS_NONE:
break;
default:
@@ -155,22 +303,21 @@ int _dl_parse_relocation_information(struct dyn_elf *xpnt,
_dl_dprintf(2, "\n%s: ",_dl_progname);
if (symtab_index)
- _dl_dprintf(2, "symbol '%s': ", strtab + symtab[symtab_index].st_name);
+ _dl_dprintf(2, "symbol '%s': ", symname);
#if defined (__SUPPORT_LD_DEBUG__)
- _dl_dprintf(2, "can't handle reloc type %s\n ", _dl_reltypes(reloc_type));
+ _dl_dprintf(2, "can't handle reloc type '%s' in lib '%s'\n", _dl_reltypes(reloc_type), tpnt->libname);
#else
- _dl_dprintf(2, "can't handle reloc type %x\n", reloc_type);
+ _dl_dprintf(2, "can't handle reloc type %x in lib '%s'\n", reloc_type, tpnt->libname);
#endif
_dl_exit(1);
}
}
-
- }
#if defined (__SUPPORT_LD_DEBUG__)
- if (_dl_debug_reloc && _dl_debug_detail && reloc_addr)
- _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x\n", old_val, *reloc_addr, reloc_addr);
+ if (_dl_debug_reloc && _dl_debug_detail && reloc_addr)
+ _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x\n", old_val, *reloc_addr, reloc_addr);
#endif
+ }
return 0;
}
@@ -209,12 +356,12 @@ void _dl_perform_mips_global_got_relocations(struct elf_resolve *tpnt, int lazy)
}
else {
*got_entry = (unsigned long) _dl_find_hash(strtab +
- sym->st_name, tpnt->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT);
+ sym->st_name, &_dl_loaded_modules->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT, NULL);
}
}
else if (sym->st_shndx == SHN_COMMON) {
*got_entry = (unsigned long) _dl_find_hash(strtab +
- sym->st_name, tpnt->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT);
+ sym->st_name, &_dl_loaded_modules->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT, NULL);
}
else if (ELF_ST_TYPE(sym->st_info) == STT_FUNC &&
*got_entry != sym->st_value && tmp_lazy) {
@@ -225,8 +372,11 @@ void _dl_perform_mips_global_got_relocations(struct elf_resolve *tpnt, int lazy)
*got_entry += (unsigned long) tpnt->loadaddr;
}
else {
+ struct symbol_ref sym_ref;
+ sym_ref.sym = sym;
+ sym_ref.tpnt = NULL;
*got_entry = (unsigned long) _dl_find_hash(strtab +
- sym->st_name, tpnt->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT);
+ sym->st_name, &_dl_loaded_modules->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT, &sym_ref);
}
got_entry++;
diff --git a/ldso/ldso/mips/resolve.S b/ldso/ldso/mips/resolve.S
index f5d988a80..d7951a1b4 100644
--- a/ldso/ldso/mips/resolve.S
+++ b/ldso/ldso/mips/resolve.S
@@ -112,3 +112,54 @@ _dl_runtime_resolve:
.end _dl_runtime_resolve
.previous
+/* Assembler veneer called from the PLT header code when using the
+ non-PIC ABI.
+
+ Code in each PLT entry puts the caller's return address into t7 ($15),
+ the PLT entry index into t8 ($24), the address of _dl_runtime_pltresolve
+ into t9 ($25) and the address of .got.plt into gp ($28). __dl_runtime_pltresolve
+ needs a0 ($4) to hold the link map and a1 ($5) to hold the index into
+ .rel.plt (== PLT entry index * 4). */
+
+ .text
+ .align 2
+ .globl _dl_runtime_pltresolve
+ .type _dl_runtime_pltresolve,@function
+ .ent _dl_runtime_pltresolve
+_dl_runtime_pltresolve:
+ .frame $29, 40, $31
+ .set noreorder
+ # Save arguments and sp value in stack.
+ subu $29, 40
+ lw $10, 4($28)
+ # Modify t9 ($25) so as to point .cpload instruction.
+ addiu $25, 12
+ # Compute GP.
+ .cpload $25
+ .set reorder
+
+ /* Store function arguments from registers to stack */
+ sw $15, 36($29)
+ sw $4, 16($29)
+ sw $5, 20($29)
+ sw $6, 24($29)
+ sw $7, 28($29)
+
+ /* Setup functions args and call __dl_runtime_pltresolve. */
+ move $4, $10
+ sll $5, $24, 3
+ jal __dl_runtime_pltresolve
+
+ /* Restore function arguments from stack to registers */
+ lw $31, 36($29)
+ lw $4, 16($29)
+ lw $5, 20($29)
+ lw $6, 24($29)
+ lw $7, 28($29)
+
+ /* Do a tail call to the original function */
+ addiu $29, 40
+ move $25, $2
+ jr $25
+ .end _dl_runtime_pltresolve
+ .previous
diff --git a/libc/string/sh64/strlen.S b/ldso/ldso/or1k/dl-debug.h
index 18f4164ff..d925577cd 100644
--- a/libc/string/sh64/strlen.S
+++ b/ldso/ldso/or1k/dl-debug.h
@@ -1,10 +1,6 @@
-/* vi: set sw=8 ts=8: */
-/*
- * libc/string/sh64/strlen.S
+/* OpenRISC 1000 shared library loader suppport
*
- * Simplistic strlen() implementation for SHmedia.
- *
- * Copyright (C) 2003 Paul Mundt <lethal@linux-sh.org>
+ * Copyright (C) 2012 Stefan Kristansson
*
* All rights reserved.
*
@@ -30,34 +26,28 @@
* SUCH DAMAGE.
*/
-#include <features.h>
-
- .section .text..SHmedia32,"ax"
- .globl strlen
- .type strlen,@function
-
- .balign 16
-strlen:
- ptabs r18, tr4
-
- /*
- * Note: We could easily deal with the NULL case here with a simple
- * sanity check, though it seems that the behavior we want is to fault
- * in the event that r2 == NULL, so we don't bother.
- */
-/* beqi r2, 0, tr4 */ ! Sanity check
-
- movi -1, r0
- pta/l loop, tr0
-loop:
- ld.b r2, 0, r1
- addi r2, 1, r2
- addi r0, 1, r0
- bnei/l r1, 0, tr0
-
- or r0, r63, r2
- blink tr4, r63
-
- .size strlen,.-strlen
-
-libc_hidden_def(strlen)
+static const char * const _dl_reltypes_tab[] =
+ {
+ "R_OR1K_NONE",
+ "R_OR1K_32",
+ "R_OR1K_16",
+ "R_OR1K_8",
+ "R_OR1K_LO_16_IN_INSN",
+ "R_OR1K_HI_16_IN_INSN",
+ "R_OR1K_INSN_REL_26",
+ "R_OR1K_GNU_VTENTRY",
+ "R_OR1K_GNU_VTINHERIT",
+ "R_OR1K_32_PCREL",
+ "R_OR1K_16_PCREL",
+ "R_OR1K_8_PCREL",
+ "R_OR1K_GOTPC_HI16",
+ "R_OR1K_GOTPC_LO16",
+ "R_OR1K_GOT16",
+ "R_OR1K_PLT26",
+ "R_OR1K_GOTOFF_HI16",
+ "R_OR1K_GOTOFF_LO16",
+ "R_OR1K_COPY",
+ "R_OR1K_GLOB_DAT",
+ "R_OR1K_JMP_SLOT",
+ "R_OR1K_RELATIVE",
+ };
diff --git a/ldso/ldso/or1k/dl-startup.h b/ldso/ldso/or1k/dl-startup.h
new file mode 100644
index 000000000..3c99bcd5c
--- /dev/null
+++ b/ldso/ldso/or1k/dl-startup.h
@@ -0,0 +1,106 @@
+/* Startup code for the OpenRISC 1000 platform,
+ based on microblaze implementation */
+/*
+ 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. */
+
+__asm__ ("\
+ .text\n\
+ .globl _start\n\
+ .type _start,@function\n\
+ .hidden _start\n\
+_start:\n\
+ l.ori r3, r9, 0\n\
+ l.ori r3, r1, 0\n\
+ l.movhi r11, 0\n\
+1:\n\
+ l.addi r3, r3, 4\n\
+ l.lwz r12, 0(r3)\n\
+ l.sfnei r12, 0\n\
+ l.addi r11, r11, 1\n\
+ l.bf 1b\n\
+ l.nop\n\
+ l.ori r3, r11, 0\n\
+ l.ori r3, r1, 0\n\
+ l.addi r11, r11, -1\n\
+ /* store argument counter to stack */\n\
+ l.sw 0(r3), r11\n\
+ l.addi r1, r1, -24\n\
+ l.sw 0(r1), r9\n\
+\n\
+ l.jal .LPC0\n\
+#ifndef __OR1K_NODELAY__\n\
+ l.nop\n\
+#endif\n\
+ /* Load the PIC register */\n\
+.LPC0:\n\
+ l.movhi r16, gotpchi(_GLOBAL_OFFSET_TABLE_+(.-.LPC0))\n\
+ l.ori r16, r16, gotpclo(_GLOBAL_OFFSET_TABLE_+(.-.LPC0))\n\
+ l.add r16, r16, r9\n\
+\n\
+ l.jal _dl_start\n\
+ l.nop\n\
+ /* FALLTHRU */\n\
+\n\
+ .globl _dl_start_user\n\
+ .type _dl_start_user,@function\n\
+_dl_start_user:\n\
+ l.movhi r12, gotoffhi(_dl_skip_args)\n\
+ l.ori r12, r12, gotofflo(_dl_skip_args)\n\
+ l.add r12, r12, r16\n\
+ l.lwz r12, 0(r12)\n\
+ l.lwz r3, 24(r1)\n\
+\n\
+ l.movhi r9, gotoffhi(_dl_fini)\n\
+ l.ori r9, r9, gotofflo(_dl_fini)\n\
+ l.add r9, r9, r16\n\
+\n\
+ l.addi r9, r9, -8\n\
+ l.addi r1, r1, 24\n\
+ l.jr r11\n\
+ l.nop\n\
+ .size _dl_start_user, . - _dl_start_user\n\
+ .previous\n\
+");
+/*
+ * Get a pointer to the argv array. On many platforms this can be just
+ * the address of the first argument, on other platforms we need to
+ * do something a little more subtle here.
+ */
+#define GET_ARGV(ARGVP, ARGS) ARGVP = (((unsigned long*) ARGS)+1)
+
+/* The ld.so library requires relocations */
+#define ARCH_NEEDS_BOOTSTRAP_RELOCS
+
+static __always_inline
+void PERFORM_BOOTSTRAP_RELOC(ELF_RELOC *rpnt, unsigned long *reloc_addr,
+ unsigned long symbol_addr, unsigned long load_addr,
+ attribute_unused Elf32_Sym *symtab)
+{
+
+ switch (ELF_R_TYPE(rpnt->r_info))
+ {
+ case R_OR1K_RELATIVE:
+
+ *reloc_addr = load_addr + rpnt->r_addend;
+ break;
+
+ default:
+ _dl_exit(1);
+ break;
+
+ }
+
+}
diff --git a/ldso/ldso/or1k/dl-syscalls.h b/ldso/ldso/or1k/dl-syscalls.h
new file mode 100644
index 000000000..f40c4fd31
--- /dev/null
+++ b/ldso/ldso/or1k/dl-syscalls.h
@@ -0,0 +1 @@
+/* stub for arch-specific syscall issues */
diff --git a/ldso/ldso/or1k/dl-sysdep.h b/ldso/ldso/or1k/dl-sysdep.h
new file mode 100644
index 000000000..21ca028c8
--- /dev/null
+++ b/ldso/ldso/or1k/dl-sysdep.h
@@ -0,0 +1,105 @@
+/* elf reloc code for the or1k platform, based on glibc 2.3.6, dl-machine.h */
+
+/*
+ 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. */
+
+/* Use reloca */
+#define ELF_USES_RELOCA
+
+#include <elf.h>
+
+
+/* Initialise the GOT */
+#define INIT_GOT(GOT_BASE,MODULE) \
+do { \
+ GOT_BASE[2] = (unsigned long) _dl_linux_resolve; \
+ GOT_BASE[1] = (unsigned long) MODULE; \
+} while(0)
+
+/* Here we define the magic numbers that this dynamic loader should accept */
+
+#define MAGIC1 EM_OR1K
+#undef MAGIC2
+/* Used for error messages */
+#define ELF_TARGET "or1k"
+
+#define elf_machine_type_class(type) \
+ (((type) == R_OR1K_JMP_SLOT) * ELF_RTYPE_CLASS_PLT \
+ | ((type) == R_OR1K_COPY) * ELF_RTYPE_CLASS_COPY)
+
+static inline Elf32_Addr *
+or1k_get_got (void)
+{
+ Elf32_Addr *got;
+ Elf32_Addr linkreg;
+ __asm__("l.ori %0, r9, 0\n"
+ "l.jal .LPC1\n"
+#ifndef __OR1K_NODELAY__
+ "l.nop\n"
+#endif
+ ".LPC1:\n"
+ "l.movhi %1, gotpchi(_GLOBAL_OFFSET_TABLE_+(.-.LPC1))\n"
+ "l.ori %1, %1, gotpclo(_GLOBAL_OFFSET_TABLE_+(.-.LPC1))\n"
+ "l.add %1, %1, r9\n"
+ "l.ori r9, %0, 0\n"
+ : "=r" (linkreg), "=r" (got));
+ return got;
+}
+
+/* Return the link-time address of _DYNAMIC. Conveniently, this is the
+ first element of the GOT. */
+static inline Elf32_Addr
+elf_machine_dynamic (void)
+{
+ Elf32_Addr *got = or1k_get_got();
+ return *got;
+}
+
+
+/* Return the run-time load address of the shared object. */
+static inline Elf32_Addr
+elf_machine_load_address (void)
+{
+ /* Compute the difference between the runtime address of _DYNAMIC as seen
+ by a GOTOFF reference, and the link-time address found in the special
+ unrelocated first GOT entry. */
+ Elf32_Addr dyn;
+ Elf32_Addr *got = or1k_get_got();
+
+ __asm__ __volatile__ (
+ "l.movhi %0, gotoffhi(_DYNAMIC);"
+ "l.ori %0, %0, gotofflo(_DYNAMIC);"
+ "l.add %0, %0, %1;"
+ : "=r"(dyn), "=r"(got)
+ );
+ return dyn - *got;
+}
+
+
+
+static __always_inline void
+elf_machine_relative (Elf32_Addr load_off, const Elf32_Addr rel_addr,
+ Elf32_Word relative_count)
+{
+ Elf32_Rela * rpnt = (void *) rel_addr;
+ --rpnt;
+ do {
+ Elf32_Addr *const reloc_addr = (void *) (load_off +
+ (++rpnt)->r_offset);
+
+ *reloc_addr += load_off;
+ } while (--relative_count);
+}
diff --git a/ldso/ldso/or1k/elfinterp.c b/ldso/ldso/or1k/elfinterp.c
new file mode 100644
index 000000000..928e95ba1
--- /dev/null
+++ b/ldso/ldso/or1k/elfinterp.c
@@ -0,0 +1,333 @@
+/* vi: set sw=4 ts=4: */
+/* OpenRISC 1000 ELF shared library loader suppport
+ *
+ * Copyright (c) 1994-2000 Eric Youngdale, Peter MacDonald,
+ * David Engel, Hongjiu Lu and Mitch D'Souza
+ * Copyright (C) 2001-2004 Erik Andersen
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. The name of the above contributors may not be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "ldso.h"
+
+/* Program to load an ELF binary on a linux system, and run it.
+ References to symbols in sharable libraries can be resolved by either
+ an ELF sharable library or a linux style of shared library. */
+
+/* Disclaimer: I have never seen any AT&T source code for SVr4, nor have
+ I ever taken any courses on internals. This program was developed using
+ information available through the book "UNIX SYSTEM V RELEASE 4,
+ Programmers guide: Ansi C and Programming Support Tools", which did
+ a more than adequate job of explaining everything required to get this
+ working. */
+
+extern int _dl_linux_resolve(void);
+
+unsigned long
+_dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
+{
+ ELF_RELOC *this_reloc;
+ char *strtab;
+ ElfW(Sym) *symtab;
+ int symtab_index;
+ char *rel_addr;
+ char *new_addr;
+ char **got_addr;
+ ElfW(Addr) instr_addr;
+ char *symname;
+
+ rel_addr = (char *)tpnt->dynamic_info[DT_JMPREL];
+ this_reloc = (ELF_RELOC *)(rel_addr + reloc_entry);
+ symtab_index = ELF_R_SYM(this_reloc->r_info);
+
+ symtab = (ElfW(Sym) *)tpnt->dynamic_info[DT_SYMTAB];
+ strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
+ symname = strtab + symtab[symtab_index].st_name;
+
+ /* Address of the jump instruction to fix up. */
+ instr_addr = (this_reloc->r_offset + tpnt->loadaddr);
+ got_addr = (char **)instr_addr;
+
+ /* Get the address of the GOT entry. */
+ new_addr = _dl_find_hash(symname, &_dl_loaded_modules->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT, NULL);
+ if (unlikely(!new_addr)) {
+ _dl_dprintf(2, "%s: can't resolve symbol '%s' in lib '%s'.\n",
+ _dl_progname, symname, tpnt->libname);
+ _dl_exit(1);
+ }
+
+#if defined (__SUPPORT_LD_DEBUG__)
+ if ((unsigned long)got_addr < 0x40000000) {
+ if (_dl_debug_bindings) {
+ _dl_dprintf(_dl_debug_file, "\nresolve function: %s", symname);
+ if (_dl_debug_detail)
+ _dl_dprintf(_dl_debug_file,
+ "\tpatched: %x ==> %x @ %x\n",
+ *got_addr, new_addr, got_addr);
+ }
+ }
+ if (!_dl_debug_nofixups)
+#endif
+ *got_addr = new_addr;
+
+ return (unsigned long)new_addr;
+}
+
+static int
+_dl_parse(struct elf_resolve *tpnt, struct r_scope_elem *scope,
+ unsigned long rel_addr, unsigned long rel_size,
+ int (*reloc_fnc)(struct elf_resolve *tpnt, struct r_scope_elem *scope,
+ ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab))
+{
+ unsigned int i;
+ char *strtab;
+ ElfW(Sym) *symtab;
+ ELF_RELOC *rpnt;
+ int symtab_index;
+
+ /* Parse the relocation information. */
+ rpnt = (ELF_RELOC *)rel_addr;
+ rel_size /= sizeof(ELF_RELOC);
+
+ symtab = (ElfW(Sym) *)tpnt->dynamic_info[DT_SYMTAB];
+ strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
+
+ for (i = 0; i < rel_size; i++, rpnt++) {
+ int res;
+
+ symtab_index = ELF_R_SYM(rpnt->r_info);
+
+ debug_sym(symtab, strtab, symtab_index);
+ debug_reloc(symtab, strtab, rpnt);
+
+ res = reloc_fnc(tpnt, scope, rpnt, symtab, strtab);
+
+ if (res == 0)
+ continue;
+
+ _dl_dprintf(2, "\n%s: ", _dl_progname);
+
+ if (symtab_index)
+ _dl_dprintf(2, "symbol '%s': ",
+ strtab + symtab[symtab_index].st_name);
+
+ if (unlikely(res < 0)) {
+ int reloc_type = ELF_R_TYPE(rpnt->r_info);
+
+ _dl_dprintf(2, "can't handle reloc type "
+#if defined (__SUPPORT_LD_DEBUG__)
+ "%s\n", _dl_reltypes(reloc_type));
+#else
+ "%x\n", reloc_type);
+#endif
+ _dl_exit(-res);
+ } else if (unlikely(res > 0)) {
+ _dl_dprintf(2, "can't resolve symbol\n");
+ return res;
+ }
+ }
+
+ return 0;
+}
+
+static int
+_dl_do_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
+ ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
+{
+ int reloc_type;
+ int symtab_index;
+ char *symname;
+#if defined USE_TLS && USE_TLS
+ struct elf_resolve *tls_tpnt;
+#endif
+ struct symbol_ref sym_ref;
+ ElfW(Addr) *reloc_addr;
+ ElfW(Addr) symbol_addr;
+#if defined (__SUPPORT_LD_DEBUG__)
+ ElfW(Addr) old_val;
+#endif
+
+ struct unaligned {
+ Elf32_Addr x;
+ } __attribute__ ((packed, may_alias));
+
+ reloc_addr = (ElfW(Addr)*)(tpnt->loadaddr + (unsigned long)rpnt->r_offset);
+ reloc_type = ELF_R_TYPE(rpnt->r_info);
+ symtab_index = ELF_R_SYM(rpnt->r_info);
+ sym_ref.sym = &symtab[symtab_index];
+ sym_ref.tpnt = NULL;
+ symbol_addr = 0;
+ symname = strtab + sym_ref.sym->st_name;
+
+ if (symtab_index) {
+ symbol_addr = (ElfW(Addr))_dl_find_hash(symname, scope, tpnt,
+ elf_machine_type_class(reloc_type), &sym_ref);
+ /*
+ * We want to allow undefined references to weak symbols - this
+ * might have been intentional. We should not be linking local
+ * symbols here, so all bases should be covered.
+ */
+ if (unlikely(!symbol_addr && (ELF_ST_TYPE(sym_ref.sym->st_info) != STT_TLS)
+ && (ELF_ST_BIND(sym_ref.sym->st_info) != STB_WEAK))) {
+ /* This may be non-fatal if called from dlopen. */
+ return 1;
+ }
+#if defined USE_TLS && USE_TLS
+ tls_tpnt = sym_ref.tpnt;
+#endif
+ } else {
+ /* Relocs against STN_UNDEF are usually treated as using a
+ * symbol value of zero, and using the module containing the
+ * reloc itself. */
+ symbol_addr = sym_ref.sym->st_value;
+#if defined USE_TLS && USE_TLS
+ tls_tpnt = tpnt;
+#endif
+ }
+
+
+#if defined (__SUPPORT_LD_DEBUG__)
+ if (reloc_addr) {
+ old_val = ((struct unaligned *)reloc_addr)->x;
+ } else {
+ old_val = 0;
+ }
+#endif
+
+ switch (reloc_type) {
+ case R_OR1K_NONE:
+ break;
+
+ case R_OR1K_8:
+ case R_OR1K_16:
+ case R_OR1K_32:
+ /* Support relocations on mis-aligned offsets. */
+ ((struct unaligned *)reloc_addr)->x = symbol_addr +
+ rpnt->r_addend;
+ break;
+
+ case R_OR1K_8_PCREL:
+ case R_OR1K_16_PCREL:
+ case R_OR1K_32_PCREL:
+ case R_OR1K_INSN_REL_26:
+ *reloc_addr = symbol_addr + rpnt->r_addend;
+ break;
+
+ case R_OR1K_GLOB_DAT:
+ case R_OR1K_JMP_SLOT:
+ *reloc_addr = symbol_addr + rpnt->r_addend;
+ break;
+/* Handled by elf_machine_relative */
+ case R_OR1K_RELATIVE:
+ *reloc_addr = (unsigned long)tpnt->loadaddr + rpnt->r_addend;
+ break;
+
+ case R_OR1K_COPY:
+ if (symbol_addr) {
+#if defined (__SUPPORT_LD_DEBUG__)
+ if (_dl_debug_move)
+ _dl_dprintf(_dl_debug_file,
+ "\t%s move %d bytes from %x to %x\n",
+ symname, sym_ref.sym->st_size,
+ symbol_addr, reloc_addr);
+#endif
+
+ _dl_memcpy((char *)reloc_addr,
+ (char *)symbol_addr,
+ sym_ref.sym->st_size);
+ }
+#if defined (__SUPPORT_LD_DEBUG__)
+ else
+ _dl_dprintf(_dl_debug_file, "no symbol_addr to copy !?\n");
+#endif
+ break;
+
+ default:
+ return -1; /* Calls _dl_exit(1). */
+ }
+
+#if defined (__SUPPORT_LD_DEBUG__)
+ if (_dl_debug_reloc && _dl_debug_detail)
+ _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x\n",
+ old_val, ((struct unaligned *)reloc_addr)->x,
+ reloc_addr);
+#endif
+
+ return 0;
+}
+
+static int
+_dl_do_lazy_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
+ ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
+{
+ int reloc_type;
+ int symtab_index;
+ ElfW(Addr) *reloc_addr;
+#if defined (__SUPPORT_LD_DEBUG__)
+ ElfW(Addr) old_val;
+#endif
+
+ (void)scope;
+ symtab_index = ELF_R_SYM(rpnt->r_info);
+ (void)strtab;
+
+ reloc_addr = (ElfW(Addr)*)(tpnt->loadaddr + rpnt->r_offset);
+ reloc_type = ELF_R_TYPE(rpnt->r_info);
+
+#if defined (__SUPPORT_LD_DEBUG__)
+ old_val = *reloc_addr;
+#endif
+
+ switch (reloc_type) {
+ case R_OR1K_NONE:
+ break;
+ case R_OR1K_JMP_SLOT:
+ *reloc_addr += (unsigned long)tpnt->loadaddr;
+ break;
+ default:
+ _dl_exit(1);
+ }
+
+#if defined (__SUPPORT_LD_DEBUG__)
+ if (_dl_debug_reloc && _dl_debug_detail)
+ _dl_dprintf(_dl_debug_file, "\tpatched_lazy: %x ==> %x @ %x\n",
+ old_val, *reloc_addr, reloc_addr);
+#endif
+
+ return 0;
+}
+
+void
+_dl_parse_lazy_relocation_information(struct dyn_elf *rpnt,
+ unsigned long rel_addr, unsigned long rel_size)
+{
+ (void)_dl_parse(rpnt->dyn, NULL, rel_addr, rel_size, _dl_do_lazy_reloc);
+}
+
+int
+_dl_parse_relocation_information(struct dyn_elf *rpnt,
+ struct r_scope_elem *scope, unsigned long rel_addr, unsigned long rel_size)
+{
+ return _dl_parse(rpnt->dyn, scope, rel_addr, rel_size, _dl_do_reloc);
+}
diff --git a/ldso/ldso/or1k/resolve.S b/ldso/ldso/or1k/resolve.S
new file mode 100644
index 000000000..4a156d529
--- /dev/null
+++ b/ldso/ldso/or1k/resolve.S
@@ -0,0 +1,54 @@
+/* This code is used in dl-runtime.c to call the `fixup' function
+ and then redirect to the address it returns. */
+/* We assume that R11 contain relocation offset and R12 contains
+ link_map (_DYNAMIC). This must be consistent with the JUMP_SLOT
+ layout generated by binutils. */
+
+/* Based on microblaze implementation */
+/*
+ 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. */
+
+.text
+.align 4
+.globl _dl_linux_resolver
+.globl _dl_linux_resolve
+.type _dl_linux_resolve,@function
+
+_dl_linux_resolve:
+ l.addi r1, r1, -32
+ l.sw 0(r1), r9
+ /* save function arguments */
+ l.sw 8(r1), r3
+ l.sw 12(r1), r4
+ l.sw 16(r1), r5
+ l.sw 20(r1), r6
+ l.sw 24(r1), r7
+ l.sw 28(r1), r8
+ l.ori r3, r12, 0
+ l.ori r4, r11, 0
+ l.jal _dl_linux_resolver
+ l.nop
+ l.lwz r8, 28(r1)
+ l.lwz r7, 24(r1)
+ l.lwz r6, 20(r1)
+ l.lwz r5, 16(r1)
+ l.lwz r4, 12(r1)
+ l.lwz r3, 8(r1)
+ l.lwz r9, 0(r1)
+ l.addi r1, r1, 32
+ l.jr r11
+ l.nop
+ .size _dl_linux_resolve, . - _dl_linux_resolve
diff --git a/ldso/ldso/powerpc/dl-debug.h b/ldso/ldso/powerpc/dl-debug.h
index cf203d25e..720536e72 100644
--- a/ldso/ldso/powerpc/dl-debug.h
+++ b/ldso/ldso/powerpc/dl-debug.h
@@ -29,7 +29,7 @@
* SUCH DAMAGE.
*/
-static const char *_dl_reltypes_tab[] =
+static const char * const _dl_reltypes_tab[] =
{ "R_PPC_NONE", "R_PPC_ADDR32", "R_PPC_ADDR24", "R_PPC_ADDR16",
"R_PPC_ADDR16_LO", "R_PPC_ADDR16_HI", "R_PPC_ADDR16_HA",
"R_PPC_ADDR14", "R_PPC_ADDR14_BRTAKEN", "R_PPC_ADDR14_BRNTAKEN",
diff --git a/ldso/ldso/powerpc/dl-startup.h b/ldso/ldso/powerpc/dl-startup.h
index 50e72c3ee..8b2a517e2 100644
--- a/ldso/ldso/powerpc/dl-startup.h
+++ b/ldso/ldso/powerpc/dl-startup.h
@@ -8,6 +8,7 @@ __asm__(
" .text\n"
" .globl _start\n"
" .type _start,@function\n"
+ " .hidden _start\n"
"_start:\n"
" mr 3,1\n" /* Pass SP to _dl_start in r3 */
" li 0,0\n"
@@ -60,7 +61,7 @@ __asm__(
/*
* Get a pointer to the argv array. On many platforms this can be just
- * the address if the first argument, on other platforms we need to
+ * the address of the first argument, on other platforms we need to
* do something a little more subtle here.
*/
#define GET_ARGV(ARGVP, ARGS) ARGVP = (((unsigned long*) ARGS)+1)
@@ -73,7 +74,7 @@ __asm__(
* load address.
*/
#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB) \
- {int type=ELF32_R_TYPE((RELP)->r_info); \
+ {int type=ELF_R_TYPE((RELP)->r_info); \
Elf32_Addr finaladdr=(SYMBOL)+(RELP)->r_addend;\
if (type==R_PPC_RELATIVE) { \
*REL=(Elf32_Word)(LOAD)+(RELP)->r_addend;\
@@ -84,6 +85,6 @@ __asm__(
*REL=OPCODE_B(delta); \
PPC_DCBST(REL); PPC_SYNC; PPC_ICBI(REL);\
} else { \
- _dl_exit(100+ELF32_R_TYPE((RELP)->r_info));\
+ _dl_exit(100+ELF_R_TYPE((RELP)->r_info));\
} \
}
diff --git a/ldso/ldso/powerpc/dl-syscalls.h b/ldso/ldso/powerpc/dl-syscalls.h
index 996bb87c6..f40c4fd31 100644
--- a/ldso/ldso/powerpc/dl-syscalls.h
+++ b/ldso/ldso/powerpc/dl-syscalls.h
@@ -1,6 +1 @@
-/* We can't use the real errno in ldso, since it has not yet
- * been dynamicly linked in yet. */
-#include "sys/syscall.h"
-extern int _dl_errno;
-#undef __set_errno
-#define __set_errno(X) {(_dl_errno) = (X);}
+/* stub for arch-specific syscall issues */
diff --git a/ldso/ldso/powerpc/dl-sysdep.h b/ldso/ldso/powerpc/dl-sysdep.h
index 768482272..a665d4e75 100644
--- a/ldso/ldso/powerpc/dl-sysdep.h
+++ b/ldso/ldso/powerpc/dl-sysdep.h
@@ -67,11 +67,6 @@ struct elf_resolve;
extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
void _dl_init_got(unsigned long *lpnt,struct elf_resolve *tpnt);
-/* 4096 bytes alignment */
-#define PAGE_ALIGN 0xfffff000
-#define ADDR_ALIGN 0xfff
-#define OFFS_ALIGN 0x7ffff000
-
/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry, so
PLT entries should not be allowed to define the value.
ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one
@@ -82,6 +77,8 @@ void _dl_init_got(unsigned long *lpnt,struct elf_resolve *tpnt);
#define elf_machine_type_class(type) \
((((type) == R_PPC_JMP_SLOT \
|| (type) == R_PPC_REL24 \
+ || ((type) >= R_PPC_DTPMOD32 /* contiguous TLS */ \
+ && (type) <= R_PPC_DTPREL32) \
|| (type) == R_PPC_ADDR24) * ELF_RTYPE_CLASS_PLT) \
| (((type) == R_PPC_COPY) * ELF_RTYPE_CLASS_COPY))
@@ -90,7 +87,7 @@ void _dl_init_got(unsigned long *lpnt,struct elf_resolve *tpnt);
#define ELF_MACHINE_PLTREL_OVERLAP 1
/* Return the value of the GOT pointer. */
-static __inline__ Elf32_Addr * __attribute__ ((const))
+static __always_inline Elf32_Addr * __attribute__ ((const))
ppc_got (void)
{
Elf32_Addr *got;
@@ -109,14 +106,14 @@ ppc_got (void)
/* Return the link-time address of _DYNAMIC, stored as
the first value in the GOT. */
-static __inline__ Elf32_Addr __attribute__ ((const))
+static __always_inline Elf32_Addr __attribute__ ((const))
elf_machine_dynamic (void)
{
return *ppc_got();
}
/* Return the run-time load address of the shared object. */
-static __inline__ Elf32_Addr __attribute__ ((const))
+static __always_inline Elf32_Addr __attribute__ ((const))
elf_machine_load_address (void)
{
Elf32_Addr *branchaddr;
@@ -164,7 +161,7 @@ elf_machine_load_address (void)
return runtime_dynamic - elf_machine_dynamic ();
}
-static __inline__ void
+static __always_inline void
elf_machine_relative (Elf32_Addr load_off, const Elf32_Addr rel_addr,
Elf32_Word relative_count)
{
diff --git a/ldso/ldso/powerpc/elfinterp.c b/ldso/ldso/powerpc/elfinterp.c
index eeb325092..81587a6af 100644
--- a/ldso/ldso/powerpc/elfinterp.c
+++ b/ldso/ldso/powerpc/elfinterp.c
@@ -30,6 +30,8 @@
*/
#include "ldso.h"
+#define TLS_DTV_OFFSET 0x8000
+#define TLS_TP_OFFSET 0x7000
extern int _dl_linux_resolve(void);
@@ -107,44 +109,37 @@ unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
{
ELF_RELOC *this_reloc;
char *strtab;
- Elf32_Sym *symtab;
+ ElfW(Sym) *symtab;
ELF_RELOC *rel_addr;
int symtab_index;
char *symname;
- Elf32_Addr *reloc_addr;
- Elf32_Addr finaladdr;
+ ElfW(Addr) *reloc_addr;
+ ElfW(Addr) finaladdr;
Elf32_Sword delta;
rel_addr = (ELF_RELOC *)tpnt->dynamic_info[DT_JMPREL];
this_reloc = (void *)rel_addr + reloc_entry;
- symtab_index = ELF32_R_SYM(this_reloc->r_info);
+ symtab_index = ELF_R_SYM(this_reloc->r_info);
- symtab = (Elf32_Sym *)tpnt->dynamic_info[DT_SYMTAB];
+ symtab = (ElfW(Sym) *)tpnt->dynamic_info[DT_SYMTAB];
strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
symname = strtab + symtab[symtab_index].st_name;
debug_sym(symtab,strtab,symtab_index);
debug_reloc(symtab,strtab,this_reloc);
-#if defined (__SUPPORT_LD_DEBUG__)
- if (unlikely(ELF32_R_TYPE(this_reloc->r_info) != R_PPC_JMP_SLOT)) {
- _dl_dprintf(2, "%s: Incorrect relocation type in jump relocation\n", _dl_progname);
- _dl_exit(1);
- }
-#endif
-
/* Address of dump instruction to fix up */
- reloc_addr = (Elf32_Addr *) (tpnt->loadaddr + this_reloc->r_offset);
+ reloc_addr = (ElfW(Addr) *) (tpnt->loadaddr + this_reloc->r_offset);
#if defined (__SUPPORT_LD_DEBUG__)
if (_dl_debug_reloc && _dl_debug_detail)
- _dl_dprintf(_dl_debug_file, "\n\tResolving symbol %s %x --> ", symname, (Elf32_Addr)reloc_addr);
+ _dl_dprintf(_dl_debug_file, "\n\tResolving symbol %s %x --> ", symname, (ElfW(Addr))reloc_addr);
#endif
/* Get the address of the GOT entry */
- finaladdr = (Elf32_Addr) _dl_find_hash(symname,
- tpnt->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT);
+ finaladdr = (ElfW(Addr)) _dl_find_hash(symname,
+ &_dl_loaded_modules->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT, NULL);
if (unlikely(!finaladdr)) {
_dl_dprintf(2, "%s: can't resolve symbol '%s' in lib '%s'.\n", _dl_progname, symname, tpnt->libname);
_dl_exit(1);
@@ -164,15 +159,15 @@ unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
*reloc_addr = OPCODE_BA (finaladdr);
} else {
/* Warning: we don't handle double-sized PLT entries */
- Elf32_Word *plt, *data_words, index, offset;
+ Elf32_Word *plt, *data_words, idx, offset;
plt = (Elf32_Word *)tpnt->dynamic_info[DT_PLTGOT];
offset = reloc_addr - plt;
- index = (offset - PLT_INITIAL_ENTRY_WORDS)/2;
+ idx = (offset - PLT_INITIAL_ENTRY_WORDS)/2;
data_words = (Elf32_Word *)tpnt->data_words;
reloc_addr += 1;
- data_words[index] = finaladdr;
+ data_words[idx] = finaladdr;
PPC_SYNC;
*reloc_addr = OPCODE_B ((PLT_LONGBRANCH_ENTRY_WORDS - (offset+1)) * 4);
}
@@ -187,50 +182,64 @@ unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
}
static __inline__ int
-_dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
- ELF_RELOC *rpnt, Elf32_Sym *symtab, char *strtab)
+_dl_do_reloc (struct elf_resolve *tpnt,struct r_scope_elem *scope,
+ ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
{
int reloc_type;
int symtab_index;
- char *symname;
- Elf32_Addr *reloc_addr;
- Elf32_Addr finaladdr;
-
+ struct symbol_ref sym_ref;
+ ElfW(Addr) *reloc_addr;
+ ElfW(Addr) finaladdr;
+ struct elf_resolve *tls_tpnt = NULL;
unsigned long symbol_addr;
+ char *symname;
#if defined (__SUPPORT_LD_DEBUG__)
unsigned long old_val;
#endif
- reloc_addr = (Elf32_Addr *)(intptr_t) (tpnt->loadaddr + (unsigned long) rpnt->r_offset);
- reloc_type = ELF32_R_TYPE(rpnt->r_info);
+
symbol_addr = tpnt->loadaddr; /* For R_PPC_RELATIVE */
- symtab_index = ELF32_R_SYM(rpnt->r_info);
- symname = strtab + symtab[symtab_index].st_name;
+ reloc_addr = (ElfW(Addr) *)(intptr_t) (symbol_addr + (unsigned long) rpnt->r_offset);
+ reloc_type = ELF_R_TYPE(rpnt->r_info);
+ symtab_index = ELF_R_SYM(rpnt->r_info);
+ sym_ref.sym = &symtab[symtab_index];
+ sym_ref.tpnt = NULL;
+ symname = strtab + sym_ref.sym->st_name;
if (symtab_index) {
symbol_addr = (unsigned long) _dl_find_hash(symname, scope, tpnt,
- elf_machine_type_class(reloc_type));
+ elf_machine_type_class(reloc_type), &sym_ref);
/* We want to allow undefined references to weak symbols - this might
* have been intentional. We should not be linking local symbols
* here, so all bases should be covered.
*/
- if (unlikely(!symbol_addr && ELF32_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK))
+ if (unlikely(!symbol_addr
+ && (ELF_ST_TYPE(sym_ref.sym->st_info) != STT_TLS
+ && ELF_ST_BIND(sym_ref.sym->st_info) != STB_WEAK)))
return 1;
+ if (_dl_trace_prelink) {
+ _dl_debug_lookup (symname, tpnt, &symtab[symtab_index],
+ &sym_ref, elf_machine_type_class(reloc_type));
+ }
+ tls_tpnt = sym_ref.tpnt;
+ } else {
+ symbol_addr = sym_ref.sym->st_value;
+ tls_tpnt = tpnt;
}
#if defined (__SUPPORT_LD_DEBUG__)
old_val = *reloc_addr;
#endif
- finaladdr = (Elf32_Addr) (symbol_addr + rpnt->r_addend);
+ finaladdr = (ElfW(Addr)) (symbol_addr + rpnt->r_addend);
switch (reloc_type) {
case R_PPC_RELATIVE:
case R_PPC_ADDR32:
case R_PPC_GLOB_DAT:
*reloc_addr = finaladdr;
- goto out_nocode; /* No code code modified */
+ goto out_nocode; /* No code modified */
case R_PPC_JMP_SLOT:
{
if (tpnt->dynamic_info[DT_PPC_GOT_IDX] != 0) {
*reloc_addr = finaladdr;
- goto out_nocode; /* No code code modified */
+ goto out_nocode; /* No code modified */
} else {
Elf32_Sword delta = finaladdr - (Elf32_Word)reloc_addr;
if (delta<<6>>6 == delta) {
@@ -239,15 +248,15 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
*reloc_addr = OPCODE_BA (finaladdr);
} else {
/* Warning: we don't handle double-sized PLT entries */
- Elf32_Word *plt, *data_words, index, offset;
+ Elf32_Word *plt, *data_words, idx, offset;
plt = (Elf32_Word *)tpnt->dynamic_info[DT_PLTGOT];
offset = reloc_addr - plt;
- index = (offset - PLT_INITIAL_ENTRY_WORDS)/2;
+ idx = (offset - PLT_INITIAL_ENTRY_WORDS)/2;
data_words = (Elf32_Word *)tpnt->data_words;
- data_words[index] = finaladdr;
- reloc_addr[0] = OPCODE_LI(11,index*4);
+ data_words[idx] = finaladdr;
+ reloc_addr[0] = OPCODE_LI(11,idx*4);
reloc_addr[1] = OPCODE_B((PLT_LONGBRANCH_ENTRY_WORDS - (offset+1)) * 4);
/* instructions were modified */
@@ -262,11 +271,11 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
#if defined (__SUPPORT_LD_DEBUG__)
if (_dl_debug_move)
_dl_dprintf(_dl_debug_file,"\n%s move %x bytes from %x to %x",
- symname, symtab[symtab_index].st_size,
+ symname, sym_ref.sym->st_size,
symbol_addr, reloc_addr);
#endif
- _dl_memcpy((char *) reloc_addr, (char *) finaladdr, symtab[symtab_index].st_size);
- goto out_nocode; /* No code code modified */
+ _dl_memcpy((char *) reloc_addr, (char *) finaladdr, sym_ref.sym->st_size);
+ goto out_nocode; /* No code modified */
case R_PPC_ADDR16_HA:
finaladdr += 0x8000; /* fall through. */
case R_PPC_ADDR16_HI:
@@ -274,6 +283,19 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
case R_PPC_ADDR16_LO:
*(short *)reloc_addr = finaladdr;
break;
+#if USE_TLS
+ case R_PPC_DTPMOD32:
+ *reloc_addr = tls_tpnt->l_tls_modid;
+ break;
+ case R_PPC_DTPREL32:
+ /* During relocation all TLS symbols are defined and used.
+ Therefore the offset is already correct. */
+ *reloc_addr = finaladdr - TLS_DTV_OFFSET;
+ break;
+ case R_PPC_TPREL32:
+ *reloc_addr = tls_tpnt->l_tls_offset + finaladdr - TLS_TP_OFFSET;
+ break;
+#endif
case R_PPC_REL24:
#if 0
{
@@ -292,7 +314,7 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
return -1;
#endif
case R_PPC_NONE:
- goto out_nocode; /* No code code modified */
+ goto out_nocode; /* No code modified */
default:
_dl_dprintf(2, "%s: can't handle reloc type ", _dl_progname);
#if defined (__SUPPORT_LD_DEBUG__)
@@ -311,7 +333,7 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
out_nocode:
#if defined (__SUPPORT_LD_DEBUG__)
if (_dl_debug_reloc && _dl_debug_detail)
- _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x", old_val, *reloc_addr, reloc_addr);
+ _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x\n", old_val, *reloc_addr, reloc_addr);
#endif
return 0;
}
@@ -326,11 +348,11 @@ void _dl_parse_lazy_relocation_information(struct dyn_elf *rpnt,
plt = (Elf32_Word *)tpnt->dynamic_info[DT_PLTGOT];
if (tpnt->dynamic_info[DT_PPC_GOT_IDX] != 0) {
/* Secure PLT */
- Elf32_Addr *got = (Elf32_Addr *)tpnt->dynamic_info[DT_PPC_GOT_IDX];
+ ElfW(Addr) *got = (ElfW(Addr) *)tpnt->dynamic_info[DT_PPC_GOT_IDX];
Elf32_Word dlrr = (Elf32_Word) _dl_linux_resolve;
- got[1] = (Elf32_Addr) dlrr;
- got[2] = (Elf32_Addr) tpnt;
+ got[1] = (ElfW(Addr)) dlrr;
+ got[2] = (ElfW(Addr)) tpnt;
/* Relocate everything in .plt by the load address offset. */
while (num_plt_entries-- != 0)
@@ -369,14 +391,14 @@ void _dl_parse_lazy_relocation_information(struct dyn_elf *rpnt,
}
static __inline__ int
-_dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
+_dl_parse(struct elf_resolve *tpnt, struct r_scope_elem *scope,
unsigned long rel_addr, unsigned long rel_size,
- int (*reloc_fnc) (struct elf_resolve *tpnt, struct dyn_elf *scope,
- ELF_RELOC *rpnt, Elf32_Sym *symtab, char *strtab))
+ int (*reloc_fnc) (struct elf_resolve *tpnt, struct r_scope_elem *scope,
+ ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab))
{
unsigned int i;
char *strtab;
- Elf32_Sym *symtab;
+ ElfW(Sym) *symtab;
ELF_RELOC *rpnt;
int symtab_index;
@@ -384,13 +406,13 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
rpnt = (ELF_RELOC *)(intptr_t)rel_addr;
rel_size = rel_size / sizeof(ELF_RELOC);
- symtab = (Elf32_Sym *)(intptr_t)tpnt->dynamic_info[DT_SYMTAB];
+ symtab = (ElfW(Sym) *)(intptr_t)tpnt->dynamic_info[DT_SYMTAB];
strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
for (i = 0; i < rel_size; i++, rpnt++) {
int res;
- symtab_index = ELF32_R_SYM(rpnt->r_info);
+ symtab_index = ELF_R_SYM(rpnt->r_info);
debug_sym(symtab,strtab,symtab_index);
debug_reloc(symtab,strtab,rpnt);
@@ -406,7 +428,7 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
if (unlikely(res <0))
{
- int reloc_type = ELF32_R_TYPE(rpnt->r_info);
+ int reloc_type = ELF_R_TYPE(rpnt->r_info);
#if defined (__SUPPORT_LD_DEBUG__)
_dl_dprintf(2, "can't handle reloc type '%s' in lib '%s'\n", _dl_reltypes(reloc_type), tpnt->libname);
#else
@@ -424,7 +446,7 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
}
int _dl_parse_relocation_information(struct dyn_elf *rpnt,
- unsigned long rel_addr, unsigned long rel_size)
+ struct r_scope_elem *scope, unsigned long rel_addr, unsigned long rel_size)
{
- return _dl_parse(rpnt->dyn, rpnt->dyn->symbol_scope, rel_addr, rel_size, _dl_do_reloc);
+ return _dl_parse(rpnt->dyn, scope, rel_addr, rel_size, _dl_do_reloc);
}
diff --git a/ldso/ldso/powerpc/resolve.S b/ldso/ldso/powerpc/resolve.S
index 03c6a79b8..c83337ccd 100644
--- a/ldso/ldso/powerpc/resolve.S
+++ b/ldso/ldso/powerpc/resolve.S
@@ -11,19 +11,19 @@
.type _dl_linux_resolve,@function
_dl_linux_resolve:
-// We need to save the registers used to pass parameters, and register 0,
-// which is used by _mcount; the registers are saved in a stack frame.
+/* We need to save the registers used to pass parameters, and register 0,
+ which is used by _mcount; the registers are saved in a stack frame. */
stwu 1,-64(1)
stw 0,12(1)
stw 3,16(1)
stw 4,20(1)
-// The code that calls this has put parameters for 'fixup' in r12 and r11.
+/* The code that calls this has put parameters for 'fixup' in r12 and r11. */
mr 3,12
stw 5,24(1)
mr 4,11
stw 6,28(1)
mflr 0
-// We also need to save some of the condition register fields.
+/* We also need to save some of the condition register fields. */
stw 7,32(1)
stw 0,48(1)
stw 8,36(1)
@@ -32,9 +32,9 @@ _dl_linux_resolve:
stw 10,44(1)
stw 0,8(1)
bl _dl_linux_resolver@local
-// 'fixup' returns the address we want to branch to.
+/* 'fixup' returns the address we want to branch to. */
mtctr 3
-// Put the registers back...
+/* Put the registers back... */
lwz 0,48(1)
lwz 10,44(1)
lwz 9,40(1)
@@ -48,7 +48,7 @@ _dl_linux_resolve:
lwz 4,20(1)
lwz 3,16(1)
lwz 0,12(1)
-// ...unwind the stack frame, and jump to the PLT entry we updated.
+/* ...unwind the stack frame, and jump to the PLT entry we updated. */
addi 1,1,64
bctr
diff --git a/ldso/ldso/sh/dl-debug.h b/ldso/ldso/sh/dl-debug.h
index e862da1ee..ac442bf35 100644
--- a/ldso/ldso/sh/dl-debug.h
+++ b/ldso/ldso/sh/dl-debug.h
@@ -28,7 +28,7 @@
* SUCH DAMAGE.
*/
-static const char *_dl_reltypes_tab[] =
+static const char * const _dl_reltypes_tab[] =
{
[0] "R_SH_NONE", "R_SH_DIR32", "R_SH_REL32", "R_SH_DIR8WPN",
[4] "R_SH_IND12W", "R_SH_DIR8WPL", "R_SH_DIR8WPZ", "R_SH_DIR8BP",
@@ -36,6 +36,8 @@ static const char *_dl_reltypes_tab[] =
[25] "R_SH_SWITCH16","R_SH_SWITCH32","R_SH_USES",
[28] "R_SH_COUNT", "R_SH_ALIGN", "R_SH_CODE", "R_SH_DATA",
[32] "R_SH_LABEL", "R_SH_SWITCH8", "R_SH_GNU_VTINHERIT","R_SH_GNU_VTENTRY",
+[144] "R_SH_TLS_GD_32","R_SH_TLS_LD_32", "R_SH_TLS_LDO_32", "R_SH_TLS_IE_32",
+[148] "R_SH_TLS_LE_32","R_SH_TLS_DTPMOD32", "R_SH_TLS_DTPOFF32", "R_SH_TLS_TPOFF32",
[160] "R_SH_GOT32", "R_SH_PLT32", "R_SH_COPY", "R_SH_GLOB_DAT",
[164] "R_SH_JMP_SLOT","R_SH_RELATIVE","R_SH_GOTOFF", "R_SH_GOTPC",
};
diff --git a/ldso/ldso/sh/dl-startup.h b/ldso/ldso/sh/dl-startup.h
index 7a3fdf235..b0b9b021d 100644
--- a/ldso/ldso/sh/dl-startup.h
+++ b/ldso/ldso/sh/dl-startup.h
@@ -6,6 +6,7 @@ __asm__(
" .text\n"
" .globl _start\n"
" .type _start,@function\n"
+ " .hidden _start\n"
"_start:\n"
" mov r15, r4\n"
" mov.l .L_dl_start, r0\n"
@@ -16,12 +17,22 @@ __asm__(
" mov.l .L_got, r12 ! Load the GOT on r12\n"
" mova .L_got, r0\n"
" add r0, r12\n"
+ " mov.l .L_dl_skip_args,r0\n"
+ " mov.l @(r0,r12),r0\n"
+ " mov.l @r0,r0\n"
+ " mov.l @r15,r5 ! Get the original argument count\n"
+ " sub r0,r5 ! Subtract _dl_skip_args from it\n"
+ " shll2 r0\n"
+ " add r0,r15 ! Adjust the stack pointer to skip _dl_skip_args words\n"
+ " mov.l r5,@r15 ! Store back the modified argument count\n"
" mov.l .L_dl_fini, r0\n"
" mov.l @(r0,r12), r4 ! Pass the finalizer in r4\n"
" jmp @r8\n"
" nop\n"
".L_dl_start:\n"
" .long _dl_start-.jmp_loc\n"
+ ".L_dl_skip_args:\n"
+ " .long _dl_skip_args@GOT\n"
".L_dl_fini:\n"
" .long _dl_fini@GOT\n"
".L_got:\n"
@@ -32,7 +43,7 @@ __asm__(
/*
* Get a pointer to the argv array. On many platforms this can be just
- * the address if the first argument, on other platforms we need to
+ * the address of the first argument, on other platforms we need to
* do something a little more subtle here.
*/
#define GET_ARGV(ARGVP, ARGS) ARGVP = ((unsigned long*) ARGS)
@@ -48,7 +59,7 @@ __asm__(
* load address.
*/
#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB) \
- switch(ELF32_R_TYPE((RELP)->r_info)){ \
+ switch(ELF_R_TYPE((RELP)->r_info)){ \
case R_SH_REL32: \
*(REL) = (SYMBOL) + (RELP)->r_addend \
- (unsigned long)(REL); \
diff --git a/ldso/ldso/sh/dl-syscalls.h b/ldso/ldso/sh/dl-syscalls.h
index d3672512f..b99a9b5a0 100644
--- a/ldso/ldso/sh/dl-syscalls.h
+++ b/ldso/ldso/sh/dl-syscalls.h
@@ -1,14 +1,7 @@
-/* We can't use the real errno in ldso, since it has not yet
- * been dynamicly linked in yet. */
-#include "sys/syscall.h"
-extern int _dl_errno;
-#undef __set_errno
-#define __set_errno(X) {(_dl_errno) = (X);}
-
-#if __GNUC_PREREQ (4, 1)
+#if __GNUC_PREREQ (4, 1) && !__GNUC_PREREQ (4, 9)
#warning !!! gcc 4.1 and later have problems with __always_inline so redefined as inline
# ifdef __always_inline
# undef __always_inline
-# define __always_inline inline
+# define __always_inline __inline__
# endif
#endif
diff --git a/ldso/ldso/sh/dl-sysdep.h b/ldso/ldso/sh/dl-sysdep.h
index fd0f236a2..21244ec1f 100644
--- a/ldso/ldso/sh/dl-sysdep.h
+++ b/ldso/ldso/sh/dl-sysdep.h
@@ -25,7 +25,7 @@
struct elf_resolve;
extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
-static __inline__ unsigned int
+static __always_inline unsigned int
_dl_urem(unsigned int n, unsigned int base)
{
int res;
@@ -83,24 +83,21 @@ _dl_urem(unsigned int n, unsigned int base)
#define do_rem(result, n, base) ((result) = _dl_urem((n), (base)))
-/* 4096 bytes alignment */
-#define PAGE_ALIGN 0xfffff000
-#define ADDR_ALIGN 0xfff
-#define OFFS_ALIGN 0x7ffff000
-
/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry or
TLS variable, so undefined references should not be allowed to
define the value.
ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one
of the main executable's symbols, as for a COPY reloc. */
-#define elf_machine_type_class(type) \
- ((((type) == R_SH_JMP_SLOT) * ELF_RTYPE_CLASS_PLT) \
+# define elf_machine_type_class(type) \
+ ((((type) == R_SH_JMP_SLOT || (type) == R_SH_TLS_DTPMOD32 \
+ || (type) == R_SH_TLS_DTPOFF32 || (type) == R_SH_TLS_TPOFF32) \
+ * ELF_RTYPE_CLASS_PLT) \
| (((type) == R_SH_COPY) * ELF_RTYPE_CLASS_COPY))
/* Return the link-time address of _DYNAMIC. Conveniently, this is the
first element of the GOT. This must be inlined in a function which
uses global data. */
-static __inline__ Elf32_Addr __attribute__ ((unused))
+static __always_inline Elf32_Addr __attribute__ ((unused))
elf_machine_dynamic (void)
{
register Elf32_Addr *got;
@@ -109,7 +106,7 @@ elf_machine_dynamic (void)
}
/* Return the run-time load address of the shared object. */
-static __inline__ Elf32_Addr __attribute__ ((unused))
+static __always_inline Elf32_Addr __attribute__ ((unused))
elf_machine_load_address (void)
{
Elf32_Addr addr;
@@ -151,7 +148,7 @@ elf_machine_load_address (void)
} \
}
-static __inline__ void
+static __always_inline void
elf_machine_relative (Elf32_Addr load_off, const Elf32_Addr rel_addr,
Elf32_Word relative_count)
{
diff --git a/ldso/ldso/sh/elfinterp.c b/ldso/ldso/sh/elfinterp.c
index c34acdf95..e6ff6a37a 100644
--- a/ldso/ldso/sh/elfinterp.c
+++ b/ldso/ldso/sh/elfinterp.c
@@ -45,10 +45,9 @@ extern int _dl_linux_resolve(void);
unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
{
- int reloc_type;
ELF_RELOC *this_reloc;
char *strtab;
- Elf32_Sym *symtab;
+ ElfW(Sym) *symtab;
int symtab_index;
char *rel_addr;
char *new_addr;
@@ -59,25 +58,19 @@ unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
rel_addr = (char *)tpnt->dynamic_info[DT_JMPREL];
this_reloc = (ELF_RELOC *)(intptr_t)(rel_addr + reloc_entry);
- reloc_type = ELF32_R_TYPE(this_reloc->r_info);
- symtab_index = ELF32_R_SYM(this_reloc->r_info);
+ symtab_index = ELF_R_SYM(this_reloc->r_info);
- symtab = (Elf32_Sym *)(intptr_t) tpnt->dynamic_info[DT_SYMTAB];
+ symtab = (ElfW(Sym) *)(intptr_t) tpnt->dynamic_info[DT_SYMTAB];
strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
symname = strtab + symtab[symtab_index].st_name;
- if (unlikely(reloc_type != R_SH_JMP_SLOT)) {
- _dl_dprintf(2, "%s: Incorrect relocation type in jump relocations\n",
- _dl_progname);
- _dl_exit(1);
- }
-
/* Address of jump instruction to fix up */
instr_addr = (unsigned long) (this_reloc->r_offset + tpnt->loadaddr);
got_addr = (char **) instr_addr;
/* Get the address of the GOT entry */
- new_addr = _dl_find_hash(symname, tpnt->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT);
+ new_addr = _dl_find_hash(symname, &_dl_loaded_modules->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT, NULL);
+
if (unlikely(!new_addr)) {
_dl_dprintf(2, "%s: can't resolve symbol '%s'\n", _dl_progname, symname);
_dl_exit(1);
@@ -102,14 +95,14 @@ unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
static int
-_dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
+_dl_parse(struct elf_resolve *tpnt, struct r_scope_elem *scope,
unsigned long rel_addr, unsigned long rel_size,
- int (*reloc_fnc) (struct elf_resolve *tpnt, struct dyn_elf *scope,
- ELF_RELOC *rpnt, Elf32_Sym *symtab, char *strtab))
+ int (*reloc_fnc) (struct elf_resolve *tpnt, struct r_scope_elem *scope,
+ ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab))
{
unsigned int i;
char *strtab;
- Elf32_Sym *symtab;
+ ElfW(Sym) *symtab;
ELF_RELOC *rpnt;
int symtab_index;
/* Now parse the relocation information */
@@ -117,13 +110,13 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
rpnt = (ELF_RELOC *)(intptr_t) rel_addr;
rel_size = rel_size / sizeof(ELF_RELOC);
- symtab = (Elf32_Sym *)(intptr_t)tpnt->dynamic_info[DT_SYMTAB];
+ symtab = (ElfW(Sym) *)(intptr_t)tpnt->dynamic_info[DT_SYMTAB];
strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
for (i = 0; i < rel_size; i++, rpnt++) {
int res;
- symtab_index = ELF32_R_SYM(rpnt->r_info);
+ symtab_index = ELF_R_SYM(rpnt->r_info);
debug_sym(symtab,strtab,symtab_index);
debug_reloc(symtab,strtab,rpnt);
@@ -137,7 +130,7 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
_dl_dprintf(2, "symbol '%s': ", strtab + symtab[symtab_index].st_name);
if (unlikely(res < 0)) {
- int reloc_type = ELF32_R_TYPE(rpnt->r_info);
+ int reloc_type = ELF_R_TYPE(rpnt->r_info);
#if defined (__SUPPORT_LD_DEBUG__)
_dl_dprintf(2, "can't handle reloc type %s\n ", _dl_reltypes(reloc_type));
#else
@@ -155,8 +148,8 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
static int
-_dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
- ELF_RELOC *rpnt, Elf32_Sym *symtab, char *strtab)
+_dl_do_reloc (struct elf_resolve *tpnt, struct r_scope_elem *scope,
+ ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
{
int reloc_type;
int symtab_index;
@@ -167,31 +160,57 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
unsigned long old_val;
#endif
+#if defined USE_TLS && USE_TLS
+ struct elf_resolve *tls_tpnt = NULL;
+#endif
+ struct symbol_ref sym_ref;
+
reloc_addr = (unsigned long *)(intptr_t) (tpnt->loadaddr + (unsigned long) rpnt->r_offset);
- reloc_type = ELF32_R_TYPE(rpnt->r_info);
- symtab_index = ELF32_R_SYM(rpnt->r_info);
+ reloc_type = ELF_R_TYPE(rpnt->r_info);
+ symtab_index = ELF_R_SYM(rpnt->r_info);
symbol_addr = 0;
- symname = strtab + symtab[symtab_index].st_name;
+ sym_ref.sym = &symtab[symtab_index];
+ sym_ref.tpnt = NULL;
if (symtab_index) {
+ symname = strtab + symtab[symtab_index].st_name;
symbol_addr = (unsigned long) _dl_find_hash(symname, scope, tpnt,
- elf_machine_type_class(reloc_type));
-
+ elf_machine_type_class(reloc_type), &sym_ref);
/*
* We want to allow undefined references to weak symbols - this might
* have been intentional. We should not be linking local symbols
* here, so all bases should be covered.
*/
- if (!symbol_addr && ELF32_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK) {
+
+ if (!symbol_addr
+ && (ELF_ST_TYPE(symtab[symtab_index].st_info) != STT_TLS)
+ && (ELF_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK)) {
_dl_dprintf(2, "%s: can't resolve symbol '%s'\n",
- _dl_progname, strtab + symtab[symtab_index].st_name);
- _dl_exit (1);
+ _dl_progname, symname);
+
+ /* Let the caller to handle the error: it may be non fatal if called from dlopen */
+ return 1;
}
+ if (_dl_trace_prelink) {
+ _dl_debug_lookup (symname, tpnt, &symtab[symtab_index],
+ &sym_ref, elf_machine_type_class(reloc_type));
+ }
+#if defined USE_TLS && USE_TLS
+ tls_tpnt = sym_ref.tpnt;
+#endif
}
#if defined (__SUPPORT_LD_DEBUG__)
old_val = *reloc_addr;
#endif
+
+#if defined USE_TLS && USE_TLS
+ /* In case of a TLS reloc, tls_tpnt NULL means we have an 'anonymous'
+ symbol. This is the case for a static tls variable, so the lookup
+ module is just that one is referencing the tls variable. */
+ if (!tls_tpnt)
+ tls_tpnt = tpnt;
+#endif
switch (reloc_type) {
case R_SH_NONE:
break;
@@ -218,12 +237,25 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
case R_SH_RELATIVE:
*reloc_addr = (unsigned long) tpnt->loadaddr + rpnt->r_addend;
break;
+#if defined USE_TLS && USE_TLS
+ case R_SH_TLS_DTPMOD32:
+ *reloc_addr = tls_tpnt->l_tls_modid;
+ break;
+ case R_SH_TLS_DTPOFF32:
+ *reloc_addr = symbol_addr;
+ break;
+ case R_SH_TLS_TPOFF32:
+ CHECK_STATIC_TLS ((struct link_map *) tls_tpnt);
+ *reloc_addr = tls_tpnt->l_tls_offset + symbol_addr + rpnt->r_addend;
+ break;
+#endif
default:
- return -1; /*call _dl_exit(1) */
+
+ return -1;
}
#if defined (__SUPPORT_LD_DEBUG__)
if (_dl_debug_reloc && _dl_debug_detail)
- _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x", old_val, *reloc_addr, reloc_addr);
+ _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x\n", old_val, *reloc_addr, reloc_addr);
#endif
return 0;
@@ -231,8 +263,8 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
static int
-_dl_do_lazy_reloc (struct elf_resolve *tpnt, struct dyn_elf *scope,
- ELF_RELOC *rpnt, Elf32_Sym *symtab, char *strtab)
+_dl_do_lazy_reloc (struct elf_resolve *tpnt, struct r_scope_elem *scope,
+ ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
{
int reloc_type;
unsigned long *reloc_addr;
@@ -244,7 +276,7 @@ _dl_do_lazy_reloc (struct elf_resolve *tpnt, struct dyn_elf *scope,
(void)strtab;
reloc_addr = (unsigned long *)(intptr_t) (tpnt->loadaddr + (unsigned long) rpnt->r_offset);
- reloc_type = ELF32_R_TYPE(rpnt->r_info);
+ reloc_type = ELF_R_TYPE(rpnt->r_info);
#if defined (__SUPPORT_LD_DEBUG__)
old_val = *reloc_addr;
@@ -256,11 +288,11 @@ _dl_do_lazy_reloc (struct elf_resolve *tpnt, struct dyn_elf *scope,
*reloc_addr += (unsigned long) tpnt->loadaddr;
break;
default:
- return -1; /*call _dl_exit(1) */
+ return -1;
}
#if defined (__SUPPORT_LD_DEBUG__)
if (_dl_debug_reloc && _dl_debug_detail)
- _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x", old_val, *reloc_addr, reloc_addr);
+ _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x\n", old_val, *reloc_addr, reloc_addr);
#endif
return 0;
@@ -273,7 +305,7 @@ void _dl_parse_lazy_relocation_information(struct dyn_elf *rpnt,
}
int _dl_parse_relocation_information(struct dyn_elf *rpnt,
- unsigned long rel_addr, unsigned long rel_size)
+ struct r_scope_elem *scope, unsigned long rel_addr, unsigned long rel_size)
{
- return _dl_parse(rpnt->dyn, rpnt->dyn->symbol_scope, rel_addr, rel_size, _dl_do_reloc);
+ return _dl_parse(rpnt->dyn, scope, rel_addr, rel_size, _dl_do_reloc);
}
diff --git a/ldso/ldso/sh64/dl-debug.h b/ldso/ldso/sh64/dl-debug.h
deleted file mode 100644
index 485aac7fa..000000000
--- a/ldso/ldso/sh64/dl-debug.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/* vi: set sw=8 ts=8: */
-/*
- * ldso/ldso/sh64/elfinterp.c
- *
- * SuperH (sh64) ELF shared library loader suppport
- *
- * Copyright (C) 2003, 2004, 2005 Paul Mundt <lethal@linux-sh.org>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. The name of the above contributors may not be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-static const char *_dl_reltypes_tab[] = {
- /* SHcompact relocs */
- [0] = "R_SH_NONE", "R_SH_DIR32",
- "R_SH_REL32", "R_SH_DIR8WPN",
- [4] = "R_SH_IND12W", "R_SH_DIR8WPL",
- "R_SH_DIR8WPZ", "R_SH_DIR8BP",
- [8] = "R_SH_DIR8W", "R_SH_DIR8L",
- [25] = "R_SH_SWITCH16", "R_SH_SWITCH32",
- "R_SH_USES", "R_SH_COUNT",
- [29] = "R_SH_ALIGN", "R_SH_CODE",
- "R_SH_DATA", "R_SH_LABEL",
- [33] = "R_SH_SWITCH8", "R_SH_GNU_VTINHERIT",
- "R_SH_GNU_VTENTRY",
- [160] = "R_SH_GOT32", "R_SH_PLT32",
- "R_SH_COPY", "R_SH_GLOB_DAT",
- [164] = "R_SH_JMP_SLOT", "R_SH_RELATIVE",
- "R_SH_GOTOFF", "R_SH_GOTPC",
-
- /* SHmedia relocs */
- [45] = "R_SH_DIR5U", "R_SH_DIR6U",
- "R_SH_DIR6S", "R_SH_DIR10S",
- [49] = "R_SH_DIR10SW", "R_SH_DIR10SL",
- "R_SH_DIR10SQ",
- [169] = "R_SH_GOT_LOW16", "R_SH_GOT_MEDLOW16",
- "R_SH_GOT_MEDHI16", "R_SH_GOT_HI16",
- [173] = "R_SH_GOTPLT_LOW16", "R_SH_GOTPLT_MEDLOW16",
- "R_SH_GOTPLT_MEDHI16", "R_SH_GOTPLT_HI16",
- [177] = "R_SH_PLT_LOW16", "R_SH_PLT_MEDLOW16",
- "R_SH_PLT_MEDHI16", "R_SH_PLT_HI16",
- [181] = "R_SH_GOTOFF_LOW16", "R_SH_GOTOFF_MEDLOW16",
- "R_SH_GOTOFF_MEDHI16", "R_SH_GOTOFF_HI16",
- [185] = "R_SH_GOTPC_LOW16", "R_SH_GOTPC_MEDLOW16",
- "R_SH_GOTPC_MEDHI16", "R_SH_GOTPC_HI16",
- [189] = "R_SH_GOT10BY4", "R_SH_GOTPLT10BY4",
- "R_SH_GOT10BY8", "R_SH_GOTPLT10BY8",
- [193] = "R_SH_COPY64", "R_SH_GLOB_DAT64",
- "R_SH_JMP_SLOT64", "R_SH_RELATIVE64",
- [197] = "R_SH_RELATIVE_LOW16", "R_SH_RELATIVE_MEDLOW16",
- "R_SH_RELATIVE_MEDHI16","R_SH_RELATIVE_HI16",
- [242] = "R_SH_SHMEDIA_CODE", "R_SH_PT_16",
- "R_SH_IMMS16", "R_SH_IMMU16",
- [246] = "R_SH_IMM_LOW16", "R_SH_IMM_LOW16_PCREL",
- "R_SH_IMM_MEDLOW16", "R_SH_IMM_MEDLOW16_PCREL",
- [250] = "R_SH_IMM_MEDHI16", "R_SH_IMM_MEDHI16_PCREL",
- "R_SH_IMM_HI16", "R_SH_IMM_HI16_PCREL",
- [254] = "R_SH_64", "R_SH_64_PCREL",
-};
diff --git a/ldso/ldso/sh64/dl-startup.h b/ldso/ldso/sh64/dl-startup.h
deleted file mode 100644
index 33512a9bc..000000000
--- a/ldso/ldso/sh64/dl-startup.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/* Any assembly language/system dependent hacks needed to setup boot1.c so it
- * will work as expected and cope with whatever platform specific wierdness is
- * needed for this architecture.
- */
-
-__asm__("" \
-" .section .text..SHmedia32,\"ax\"\n" \
-" .globl _start\n" \
-" .type _start, @function\n" \
-" .align 5\n" \
-"_start:\n" \
-" ! Set r12 to point to GOT\n" \
-" movi (((datalabel _GLOBAL_OFFSET_TABLE_-(.LZZZ3-.)) >> 16) & 0xffff), r12\n" \
-" shori ((datalabel _GLOBAL_OFFSET_TABLE_-(.LZZZ3-.)) & 0xffff), r12\n" \
-".LZZZ3:\n" \
-" ptrel/u r12, tr0\n" \
-" gettr tr0, r12 ! GOT address\n" \
-" add r18, r63, r11 ! save return address - needed?\n" \
-" add r15, r63, r2 ! arg = stack pointer\n" \
-" pt _dl_start, tr0 ! should work even if PIC\n" \
-" blink tr0, r18 ! call _dl_start - user EP is in r2\n" \
-" add r2, r63, r28\n" \
-" movi (((_dl_fini@GOT) >> 16) & 0xffff), r1\n" \
-" shori ((_dl_fini@GOT) & 0xffff), r1\n" \
-" ldx.l r1, r12, r2\n" \
-" add r11, r63, r18\n" \
-" ptabs/l r28, tr0\n" \
-" blink tr0, r63\n" \
-" .size _start,.-_start\n"
-" .previous\n"
-);
-
-/*
- * Get a pointer to the argv array. On many platforms this can be just
- * the address if the first argument, on other platforms we need to
- * do something a little more subtle here.
- */
-#define GET_ARGV(ARGVP, ARGS) ARGVP = (((unsigned long *)ARGS)+1)
-
-/*
- * Here is a macro to perform a relocation. This is only used when
- * bootstrapping the dynamic loader. RELP is the relocation that we
- * are performing, REL is the pointer to the address we are relocating.
- * SYMBOL is the symbol involved in the relocation, and LOAD is the
- * load address.
- */
-
-#include <elf.h>
-
-#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB) \
- const unsigned int r_type = ELF32_R_TYPE((RELP)->r_info); \
- int lsb = !!((SYMTAB)->st_other & STO_SH5_ISA32); \
- \
- switch (r_type) { \
- case R_SH_REL32: \
- *(REL) = (SYMBOL) + (RELP)->r_addend \
- - (unsigned long)(REL); \
- break; \
- case R_SH_DIR32: \
- case R_SH_GLOB_DAT: \
- case R_SH_JMP_SLOT: \
- *(REL) = ((SYMBOL) + (RELP)->r_addend) | lsb; \
- break; \
- case R_SH_RELATIVE: \
- *(REL) = (LOAD) + (RELP)->r_addend; \
- break; \
- case R_SH_RELATIVE_LOW16: \
- case R_SH_RELATIVE_MEDLOW16: \
- { \
- unsigned long word, value; \
- \
- word = (unsigned long)(REL) & ~0x3fffc00; \
- value = (LOAD) + (RELP)->r_addend; \
- \
- if (r_type == R_SH_RELATIVE_MEDLOW16) \
- value >>= 16; \
- \
- word |= (value & 0xffff) << 10; \
- *(REL) = word; \
- break; \
- } \
- case R_SH_IMM_LOW16: \
- case R_SH_IMM_MEDLOW16: \
- { \
- unsigned long word, value; \
- \
- word = (unsigned long)(REL) & ~0x3fffc00; \
- value = ((SYMBOL) + (RELP)->r_addend) | lsb; \
- \
- if (r_type == R_SH_IMM_MEDLOW16) \
- value >>= 16; \
- \
- word |= (value & 0xffff) << 10; \
- *(REL) = word; \
- break; \
- } \
- case R_SH_IMM_LOW16_PCREL: \
- case R_SH_IMM_MEDLOW16_PCREL: \
- { \
- unsigned long word, value; \
- \
- word = (unsigned long)(REL) & ~0x3fffc00; \
- value = (SYMBOL) + (RELP)->r_addend \
- - (unsigned long)(REL); \
- \
- if (r_type == R_SH_IMM_MEDLOW16_PCREL) \
- value >>= 16; \
- \
- word |= (value & 0xffff) << 10; \
- *(REL) = word; \
- break; \
- } \
- case R_SH_NONE: \
- break; \
- default: \
- _dl_exit(1); \
- }
diff --git a/ldso/ldso/sh64/dl-syscalls.h b/ldso/ldso/sh64/dl-syscalls.h
deleted file mode 100644
index 4fe50fac4..000000000
--- a/ldso/ldso/sh64/dl-syscalls.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* We can't use the real errno in ldso, since it has not yet
- * been dynamicly linked in yet. */
-#include "sys/syscall.h"
-extern int _dl_errno;
-#undef __set_errno
-#define __set_errno(X) {(_dl_errno) = (X);}
-
-#undef __syscall_return
-#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)) { \
- _dl_errno = -(res); \
- __sr2 = -1; \
- } \
- return (type)(__sr2); \
-} while (0)
-
diff --git a/ldso/ldso/sh64/dl-sysdep.h b/ldso/ldso/sh64/dl-sysdep.h
deleted file mode 100644
index 21bfffcb6..000000000
--- a/ldso/ldso/sh64/dl-sysdep.h
+++ /dev/null
@@ -1,169 +0,0 @@
-/* vi: set sw=8 ts=8: */
-/*
- * Various assembly language/system dependent hacks that are required
- * so that we can minimize the amount of platform specific code.
- */
-
-/* Define this if the system uses RELOCA. */
-#define ELF_USES_RELOCA
-#include <elf.h>
-/*
- * Initialization sequence for a GOT.
- */
-#define INIT_GOT(GOT_BASE,MODULE) \
-{ \
- GOT_BASE[2] = (unsigned long)_dl_linux_resolve; \
- GOT_BASE[1] = (unsigned long)(MODULE); \
-}
-
-/* Here we define the magic numbers that this dynamic loader should accept */
-#define MAGIC1 EM_SH
-#undef MAGIC2
-/* Used for error messages */
-#define ELF_TARGET "sh64"
-
-struct elf_resolve;
-extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
-
-/* 4096 bytes alignment */
-#define PAGE_ALIGN 0xfffff000
-#define ADDR_ALIGN 0xfff
-#define OFFS_ALIGN 0x7ffff000
-
-/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry or
- TLS variable, so undefined references should not be allowed to
- define the value.
- ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one
- of the main executable's symbols, as for a COPY reloc. */
-#define elf_machine_type_class(type) \
- ((((type) == R_SH_JMP_SLOT) * ELF_RTYPE_CLASS_PLT) \
- | (((type) == R_SH_COPY) * ELF_RTYPE_CLASS_COPY))
-
-/* Return the link-time address of _DYNAMIC. Conveniently, this is the
- first element of the GOT. This must be inlined in a function which
- uses global data. */
-static __inline__ Elf32_Addr elf_machine_dynamic(void)
-{
- register Elf32_Addr *got;
-
- /*
- * The toolchain adds 32768 to the GOT address, we compensate for
- * that in the movi/sub pair.
- *
- * XXX: If this is cleaned up in the toolchain, we can end up
- * saving 2 instructions and subsequently free up r1 from the
- * clobber list..
- */
- __asm__ (
- "movi\t(((datalabel _GLOBAL_OFFSET_TABLE_-(.LZZZ1-.)) >> 16) & 0xffff), r2\n\t"
- "shori\t((datalabel _GLOBAL_OFFSET_TABLE_-(.LZZZ1-.)) & 0xffff), r2\n\t"
- ".LZZZ1:\tptrel/u r2, tr0\n\t"
- "movi\t32768, r1\n\t"
- "gettr\ttr0, r2\n\t"
- "sub\tr2, r1, %0\n\t"
- : "=r" (got)
- : /* no inputs */
- : "r1", "r2", "tr0"
- );
-
- return *got;
-}
-
-/* Return the run-time load address of the shared object. */
-static __inline__ Elf32_Addr elf_machine_load_address(void)
-{
- Elf32_Addr addr;
-
- __asm__ (
- "movi\t(((datalabel _GLOBAL_OFFSET_TABLE_-(.LZZZ2-.)) >> 16) & 0xffff), r0\n\t"
- "shori\t((datalabel _GLOBAL_OFFSET_TABLE_-(.LZZZ2-.)) & 0xffff), r0\n\t"
- ".LZZZ2:\tptrel/u r0, tr0\n\t"
- "movi\t(((_dl_start@GOTOFF) >> 16) & 0xffff), r2\n\t"
- "shori\t((_dl_start@GOTOFF) & 0xffff), r2\n\t"
- "gettr\ttr0, r0\n\t"
- "add\tr2, r0, r2\n\t"
- "movi\t(((_dl_start@GOT) >> 16) & 0xffff), r1\n\t"
- "shori\t((_dl_start@GOT) & 0xffff), r1\n\t"
- "ldx.l\tr1, r0, r1\n\t"
- "sub\tr2, r1, %0\n\t"
- : "=r" (addr)
- : /* no inputs */
- : "r0", "r1", "r2", "tr0"
- );
-
- return addr;
-}
-
-/*
- * XXX: As we don't need to worry about r25 clobbering, we could probably
- * get away with inlining {st,ld}{x,}.l and friends here instead and
- * forego gcc's idea of code generation.
- */
-#define COPY_UNALIGNED_WORD(swp, twp, align) \
-{ \
- void *__s = (swp), *__t = (twp); \
- unsigned char *__s1 = __s, *__t1 = __t; \
- unsigned short *__s2 = __s, *__t2 = __t; \
- unsigned long *__s4 = __s, *__t4 = __t; \
- \
- switch ((align)) { \
- case 0: \
- *__t4 = *__s4; \
- break; \
- case 2: \
- *__t2++ = *__s2++; \
- *__t2 = *__s2; \
- break; \
- default: \
- *__t1++ = *__s1++; \
- *__t1++ = *__s1++; \
- *__t1++ = *__s1++; \
- *__t1 = *__s1; \
- break; \
- } \
-}
-
-static __inline__ void
-elf_machine_relative(Elf32_Addr load_off, const Elf32_Addr rel_addr,
- Elf32_Word relative_count)
-{
- Elf32_Addr value, word;
- Elf32_Rela *rpnt = (void *)rel_addr;
- int reloc_type = ELF32_R_TYPE(rpnt->r_info);
-
- do {
- Elf32_Addr *const reloc_addr =
- (void *)(load_off + rpnt->r_offset);
- int align = (int)reloc_addr & 3;
-
- switch (reloc_type) {
- case R_SH_RELATIVE_LOW16:
- COPY_UNALIGNED_WORD(reloc_addr, &word, align);
- word &= ~0x3fffc00;
- value = (rpnt->r_addend + load_off);
- word |= (value & 0xffff) << 10;
- COPY_UNALIGNED_WORD(&word, reloc_addr, align);
- break;
- case R_SH_RELATIVE_MEDLOW16:
- COPY_UNALIGNED_WORD(reloc_addr, &word, align);
- word &= ~0x3fffc00;
- value = (rpnt->r_addend + load_off) >> 16;
- word |= (value & 0xffff) << 10;
- COPY_UNALIGNED_WORD(&word, reloc_addr, align);
- break;
- default:
- if (rpnt->r_addend) {
- value = load_off + rpnt->r_addend;
- } else {
- COPY_UNALIGNED_WORD(reloc_addr, &value, align);
- value += load_off;
- }
-
- COPY_UNALIGNED_WORD(&value, reloc_addr, align);
- break;
- }
-
- rpnt++;
- } while (--relative_count);
-#undef COPY_UNALIGNED_WORD
-}
diff --git a/ldso/ldso/sh64/elfinterp.c b/ldso/ldso/sh64/elfinterp.c
deleted file mode 100644
index 845ff4fd0..000000000
--- a/ldso/ldso/sh64/elfinterp.c
+++ /dev/null
@@ -1,346 +0,0 @@
-/* vi: set sw=8 ts=8: */
-/*
- * ldso/ldso/sh64/elfinterp.c
- *
- * SuperH (sh64) ELF shared library loader suppport
- *
- * Copyright (C) 2003, 2004, 2005 Paul Mundt <lethal@linux-sh.org>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. The name of the above contributors may not be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/* Program to load an ELF binary on a linux system, and run it.
- References to symbols in sharable libraries can be resolved by either
- an ELF sharable library or a linux style of shared library. */
-
-/* Disclaimer: I have never seen any AT&T source code for SVr4, nor have
- I ever taken any courses on internals. This program was developed using
- information available through the book "UNIX SYSTEM V RELEASE 4,
- Programmers guide: Ansi C and Programming Support Tools", which did
- a more than adequate job of explaining everything required to get this
- working. */
-
-#include "ldso.h"
-
-extern int _dl_linux_resolve(void);
-
-unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
-{
- int reloc_type;
- ELF_RELOC *this_reloc;
- char *strtab;
- Elf32_Sym *symtab;
- int symtab_index;
- char *rel_addr;
- char *new_addr;
- char **got_addr;
- unsigned long instr_addr;
- char *symname;
-
- rel_addr = (char *)tpnt->dynamic_info[DT_JMPREL];
-
- this_reloc = (ELF_RELOC *)(intptr_t)(rel_addr + reloc_entry);
- reloc_type = ELF32_R_TYPE(this_reloc->r_info);
- symtab_index = ELF32_R_SYM(this_reloc->r_info);
-
- symtab = (Elf32_Sym *)(intptr_t)tpnt->dynamic_info[DT_SYMTAB];
- strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
- symname = strtab + symtab[symtab_index].st_name;
-
- if (unlikely(reloc_type != R_SH_JMP_SLOT)) {
- _dl_dprintf(2, "%s: Incorrect relocation type in jump reloc\n",
- _dl_progname);
- _dl_exit(1);
- }
-
- /* Address of jump instruction to fix up */
- instr_addr = ((unsigned long)this_reloc->r_offset +
- (unsigned long)tpnt->loadaddr);
- got_addr = (char **)instr_addr;
-
-
- /* Get the address of the GOT entry */
- new_addr = _dl_find_hash(symname, tpnt->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT);
- if (unlikely(!new_addr)) {
- _dl_dprintf(2, "%s: can't resolve symbol '%s'\n",
- _dl_progname, symname);
- _dl_exit(1);
- }
-
-#ifdef __SUPPORT_LD_DEBUG__
- if ((unsigned long)got_addr < 0x20000000) {
- if (_dl_debug_bindings) {
- _dl_dprintf(_dl_debug_file, "\nresolve function: %s",
- symname);
-
- if (_dl_debug_detail)
- _dl_dprintf(_dl_debug_file,
- "\n\tpatched %x ==> %x @ %x\n",
- *got_addr, new_addr, got_addr);
- }
- }
-
- if (!_dl_debug_nofixups)
- *got_addr = new_addr;
-#else
- *got_addr = new_addr;
-#endif
-
- return (unsigned long)new_addr;
-}
-
-static int _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
- unsigned long rel_addr, unsigned long rel_size,
- int (*reloc_fnc)(struct elf_resolve *tpnt,
- struct dyn_elf *scope,
- ELF_RELOC *rpnt, Elf32_Sym *symtab,
- char *strtab))
-{
- unsigned int i;
- char *strtab;
- Elf32_Sym *symtab;
- ELF_RELOC *rpnt;
- int symtab_index;
-
- /* Now parse the relocation information */
- rpnt = (ELF_RELOC *)(intptr_t)rel_addr;
- rel_size = rel_size / sizeof(ELF_RELOC);
-
- symtab = (Elf32_Sym *)(intptr_t)tpnt->dynamic_info[DT_SYMTAB];
- strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
-
- for (i = 0; i < rel_size; i++, rpnt++) {
- int res;
-
- symtab_index = ELF32_R_SYM(rpnt->r_info);
- debug_sym(symtab,strtab,symtab_index);
- debug_reloc(symtab,strtab,rpnt);
-
- res = reloc_fnc (tpnt, scope, rpnt, symtab, strtab);
- if (res == 0)
- continue;
-
- _dl_dprintf(2, "\n%s: ",_dl_progname);
-
- if (symtab_index)
- _dl_dprintf(2, "symbol '%s': ",
- strtab + symtab[symtab_index].st_name);
-
- if (unlikely(res < 0)) {
- int reloc_type = ELF32_R_TYPE(rpnt->r_info);
-
- _dl_dprintf(2, "can't handle reloc type "
-#ifdef __SUPPORT_LD_DEBUG__
- "%s\n", _dl_reltypes(reloc_type)
-#else
- "%x\n", reloc_type
-#endif
- );
-
- _dl_exit(-res);
- }
- if (unlikely(res > 0)) {
- _dl_dprintf(2, "can't resolve symbol\n");
-
- return res;
- }
- }
-
- return 0;
-}
-
-static int _dl_do_reloc(struct elf_resolve *tpnt,struct dyn_elf *scope,
- ELF_RELOC *rpnt, Elf32_Sym *symtab, char *strtab)
-{
- int reloc_type;
- int symtab_index, lsb;
- char *symname;
- unsigned long *reloc_addr;
- unsigned long symbol_addr;
-#ifdef __SUPPORT_LD_DEBUG__
- unsigned long old_val;
-#endif
-
- reloc_type = ELF32_R_TYPE(rpnt->r_info);
- symtab_index = ELF32_R_SYM(rpnt->r_info);
- symbol_addr = 0;
- lsb = !!(symtab[symtab_index].st_other & STO_SH5_ISA32);
- symname = strtab + symtab[symtab_index].st_name;
- reloc_addr = (unsigned long *)(intptr_t)
- (tpnt->loadaddr + (unsigned long)rpnt->r_offset);
-
- if (symtab_index) {
- int stb;
-
- symbol_addr = (unsigned long)_dl_find_hash(symname, scope, tpnt,
- elf_machine_type_class(reloc_type));
-
- /*
- * We want to allow undefined references to weak symbols - this
- * might have been intentional. We should not be linking local
- * symbols here, so all bases should be covered.
- */
- stb = ELF32_ST_BIND(symtab[symtab_index].st_info);
-
- if (stb != STB_WEAK && !symbol_addr) {
- _dl_dprintf (2, "%s: can't resolve symbol '%s'\n",
- _dl_progname, strtab + symtab[symtab_index].st_name);
- _dl_exit (1);
- }
- }
-
-#ifdef __SUPPORT_LD_DEBUG__
- old_val = *reloc_addr;
-#endif
-
- switch (reloc_type) {
- case R_SH_NONE:
- break;
- case R_SH_COPY:
- _dl_memcpy((char *)reloc_addr,
- (char *)symbol_addr, symtab[symtab_index].st_size);
- break;
- case R_SH_DIR32:
- case R_SH_GLOB_DAT:
- case R_SH_JMP_SLOT:
- *reloc_addr = (symbol_addr + rpnt->r_addend) | lsb;
- break;
- case R_SH_REL32:
- *reloc_addr = symbol_addr + rpnt->r_addend -
- (unsigned long)reloc_addr;
- break;
- case R_SH_RELATIVE:
- *reloc_addr = (unsigned long)tpnt->loadaddr + rpnt->r_addend;
- break;
- case R_SH_RELATIVE_LOW16:
- case R_SH_RELATIVE_MEDLOW16:
- {
- unsigned long word, value;
-
- word = (unsigned long)reloc_addr & ~0x3fffc00;
- value = (unsigned long)tpnt->loadaddr + rpnt->r_addend;
-
- if (reloc_type == R_SH_RELATIVE_MEDLOW16)
- value >>= 16;
-
- word |= (value & 0xffff) << 10;
- *reloc_addr = word;
-
- break;
- }
- case R_SH_IMM_LOW16:
- case R_SH_IMM_MEDLOW16:
- {
- unsigned long word, value;
-
- word = (unsigned long)reloc_addr & ~0x3fffc00;
- value = (symbol_addr + rpnt->r_addend) | lsb;
-
- if (reloc_type == R_SH_IMM_MEDLOW16)
- value >>= 16;
-
- word |= (value & 0xffff) << 10;
- *reloc_addr = word;
-
- break;
- }
- case R_SH_IMM_LOW16_PCREL:
- case R_SH_IMM_MEDLOW16_PCREL:
- {
- unsigned long word, value;
-
- word = (unsigned long)reloc_addr & ~0x3fffc00;
- value = symbol_addr + rpnt->r_addend -
- (unsigned long)reloc_addr;
-
- if (reloc_type == R_SH_IMM_MEDLOW16_PCREL)
- value >>= 16;
-
- word |= (value & 0xffff) << 10;
- *reloc_addr = word;
-
- break;
- }
- default:
- return -1; /*call _dl_exit(1) */
- }
-
-#ifdef __SUPPORT_LD_DEBUG__
- if (_dl_debug_reloc && _dl_debug_detail)
- _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x",
- old_val, *reloc_addr, reloc_addr);
-#endif
-
- return 0;
-}
-
-static int _dl_do_lazy_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
- ELF_RELOC *rpnt, Elf32_Sym *symtab, char *strtab)
-{
- int reloc_type, symtab_index, lsb;
- unsigned long *reloc_addr;
-#ifdef __SUPPORT_LD_DEBUG__
- unsigned long old_val;
-#endif
-
- reloc_type = ELF32_R_TYPE(rpnt->r_info);
- symtab_index = ELF32_R_SYM(rpnt->r_info);
- lsb = !!(symtab[symtab_index].st_other & STO_SH5_ISA32);
- reloc_addr = (unsigned long *)(intptr_t)
- (tpnt->loadaddr + (unsigned long)rpnt->r_offset);
-
-#ifdef __SUPPORT_LD_DEBUG__
- old_val = *reloc_addr;
-#endif
-
- switch (reloc_type) {
- case R_SH_NONE:
- break;
- case R_SH_JMP_SLOT:
- *reloc_addr += (unsigned long)tpnt->loadaddr | lsb;
- break;
- default:
- return -1; /*call _dl_exit(1) */
- }
-
-#ifdef __SUPPORT_LD_DEBUG__
- if (_dl_debug_reloc && _dl_debug_detail)
- _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x",
- old_val, *reloc_addr, reloc_addr);
-#endif
-
- return 0;
-}
-
-void _dl_parse_lazy_relocation_information(struct dyn_elf *rpnt,
- unsigned long rel_addr, unsigned long rel_size)
-{
- (void)_dl_parse(rpnt->dyn, NULL, rel_addr, rel_size, _dl_do_lazy_reloc);
-}
-
-int _dl_parse_relocation_information(struct dyn_elf *rpnt,
- unsigned long rel_addr, unsigned long rel_size)
-{
- return _dl_parse(rpnt->dyn, rpnt->dyn->symbol_scope, rel_addr, rel_size, _dl_do_reloc);
-}
diff --git a/ldso/ldso/sh64/resolve.S b/ldso/ldso/sh64/resolve.S
deleted file mode 100644
index ca915d2ef..000000000
--- a/ldso/ldso/sh64/resolve.S
+++ /dev/null
@@ -1,95 +0,0 @@
-/* vi: set sw=8 ts=8: */
-/*
- * ldso/ldso/sh64/resolve.S
- *
- * SuperH (sh64) dynamic resolver support
- *
- * Copyright (C) 2003 Paul Mundt <lethal@linux-sh.org>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. The name of the above contributors may not be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
- .section .text..SHmedia32,"ax"
- .globl _dl_linux_resolver
- .globl _dl_linux_resolve
- .type _dl_linux_resolve, @function
-
- .balign 16
-_dl_linux_resolve:
- addi r15, -72, r15 ! make room on the stack
- pt _dl_linux_resolver, tr0
- st.q r15, 0, r2 ! save regs
- st.q r15, 8, r3
- st.q r15, 16, r4
- st.q r15, 24, r5
- st.q r15, 32, r6
- st.q r15, 40, r7
- st.q r15, 48, r8
- st.q r15, 56, r9
- st.q r15, 64, r18
-
-#ifdef HAVE_FPU
- addi r15, -48, r15 ! make room for FP regs
- fst.d r15, 0, dr0 ! save FP regs
- fst.d r15, 8, dr2
- fst.d r15, 16, dr4
- fst.d r15, 24, dr6
- fst.d r15, 32, dr8
- fst.d r15, 40, dr10
-#endif
-
- /*
- * Args for _dl_linux_resolver(), set in r17/r21 by PLT code
- */
-
- add r17, r63, r2 ! link map address
- add r21, r63, r3 ! GOT offset
- blink tr0, r18 ! call _dl_linux_resolver()
- ptabs/l r2, tr0 ! save result = addr of function called
-
-#ifdef HAVE_FPU
- fld.d r15, 0, dr0 ! restore FP regs
- fld.d r15, 8, dr2
- fld.d r15, 16, dr4
- fld.d r15, 24, dr6
- fld.d r15, 32, dr8
- fld.d r15, 40, dr10
- addi r15, 48, r15
-#endif
-
- ld.q r15, 0, r2 ! restore regs
- ld.q r15, 8, r3
- ld.q r15, 16, r4
- ld.q r15, 24, r5
- ld.q r15, 32, r6
- ld.q r15, 40, r7
- ld.q r15, 48, r8
- ld.q r15, 56, r9
- ld.q r15, 64, r18
-
- addi r15, 72, r15
- blink tr0, r63 ! jump to function address
-
- .size _dl_linux_resolve, . - _dl_linux_resolve
-
diff --git a/ldso/ldso/sparc/dl-debug.h b/ldso/ldso/sparc/dl-debug.h
index 1249f7798..5c62cefad 100644
--- a/ldso/ldso/sparc/dl-debug.h
+++ b/ldso/ldso/sparc/dl-debug.h
@@ -28,7 +28,7 @@
* SUCH DAMAGE.
*/
-static const char * _dl_reltypes_tab[] = {
+static const char * const _dl_reltypes_tab[] = {
"R_SPARC_NONE", "R_SPARC_8",
"R_SPARC_16", "R_SPARC_32", "R_SPARC_DISP8", "R_SPARC_DISP16",
"R_SPARC_DISP32", "R_SPARC_WDISP30", "R_SPARC_WDISP22",
diff --git a/ldso/ldso/sparc/dl-startup.h b/ldso/ldso/sparc/dl-startup.h
index cc11ec103..8c8c2c4f3 100644
--- a/ldso/ldso/sparc/dl-startup.h
+++ b/ldso/ldso/sparc/dl-startup.h
@@ -8,6 +8,7 @@ __asm__ ("\
.text\n\
.global _start\n\
.type _start,%function\n\
+ .hidden _start\n\
.align 32\n\
.register %g2, #scratch\n\
_start:\n\
@@ -47,7 +48,7 @@ _dl_start_user:\n\
/*
* Get a pointer to the argv array. On many platforms this can be just
- * the address if the first argument, on other platforms we need to
+ * the address of the first argument, on other platforms we need to
* do something a little more subtle here. We assume that argc is stored
* at the word just below the argvp that we return here.
*/
diff --git a/ldso/ldso/sparc/dl-syscalls.h b/ldso/ldso/sparc/dl-syscalls.h
index 996bb87c6..f40c4fd31 100644
--- a/ldso/ldso/sparc/dl-syscalls.h
+++ b/ldso/ldso/sparc/dl-syscalls.h
@@ -1,6 +1 @@
-/* We can't use the real errno in ldso, since it has not yet
- * been dynamicly linked in yet. */
-#include "sys/syscall.h"
-extern int _dl_errno;
-#undef __set_errno
-#define __set_errno(X) {(_dl_errno) = (X);}
+/* stub for arch-specific syscall issues */
diff --git a/ldso/ldso/sparc/dl-sysdep.h b/ldso/ldso/sparc/dl-sysdep.h
index 27cb97e38..d35a39147 100644
--- a/ldso/ldso/sparc/dl-sysdep.h
+++ b/ldso/ldso/sparc/dl-sysdep.h
@@ -29,7 +29,7 @@
/* Here we define the magic numbers that this dynamic loader should accept
* Note that SPARCV9 doesn't use EM_SPARCV9 since the userland is still 32-bit.
*/
-#if defined(__sparc_v9__) || defined(__sparc_v8__)
+#if defined(__sparc_v9__)
#define MAGIC1 EM_SPARC32PLUS
#else
#define MAGIC1 EM_SPARC
@@ -40,6 +40,9 @@
/* Used for error messages */
#define ELF_TARGET "sparc"
+/* Need bootstrap relocations */
+#define ARCH_NEEDS_BOOTSTRAP_RELOCS
+
struct elf_resolve;
unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
@@ -49,7 +52,7 @@ unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
#ifndef COMPILE_ASM
/* Cheap modulo implementation, taken from arm/ld_sysdep.h. */
-static __inline__ unsigned long
+static __always_inline unsigned long
sparc_mod(unsigned long m, unsigned long p)
{
unsigned long i, t, inc;
@@ -89,24 +92,14 @@ sparc_mod(unsigned long m, unsigned long p)
#define do_rem(result, n, base) ((result) = sparc_mod(n, base))
#endif
-/* 4096 bytes alignment */
-#if defined(__sparc_v9__)
-/* ...but 8192 is required for mmap() on sparc64 kernel */
-#define PAGE_ALIGN 0xffffe000
-#define ADDR_ALIGN 0x1fff
-#define OFFS_ALIGN 0x7fffe000
-#elif defined(__sparc_v8__)
-#define PAGE_ALIGN 0xfffff000
-#define ADDR_ALIGN 0xfff
-#define OFFS_ALIGN 0x7ffff000
-#endif
-
/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry, so
PLT entries should not be allowed to define the value.
ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one
of the main executable's symbols, as for a COPY reloc. */
#define elf_machine_type_class(type) \
- ((((type) == R_SPARC_JMP_SLOT) * ELF_RTYPE_CLASS_PLT) \
+ ((((type) == R_SPARC_JMP_SLOT || (type) == R_SPARC_TLS_DTPMOD32 \
+ || (type) == R_SPARC_TLS_DTPOFF32 || (type) == R_SPARC_TLS_TPOFF32) \
+ * ELF_RTYPE_CLASS_PLT) \
| (((type) == R_SPARC_COPY) * ELF_RTYPE_CLASS_COPY))
/* The SPARC overlaps DT_RELA and DT_PLTREL. */
@@ -127,7 +120,7 @@ do { register Elf32_Addr pc __asm__("o7"); \
/* Return the link-time address of _DYNAMIC. Conveniently, this is the
first element of the GOT. This must be inlined in a function which
uses global data. */
-static __inline__ Elf32_Addr
+static __always_inline Elf32_Addr
elf_machine_dynamic (void)
{
register Elf32_Addr *got __asm__ ("%l7");
@@ -138,7 +131,7 @@ elf_machine_dynamic (void)
}
/* Return the run-time load address of the shared object. */
-static __inline__ Elf32_Addr
+static __always_inline Elf32_Addr
elf_machine_load_address (void)
{
register Elf32_Addr *pc __asm__ ("%o7"), *got __asm__ ("%l7");
@@ -157,7 +150,7 @@ elf_machine_load_address (void)
return (Elf32_Addr) got - *got + (pc[2] - pc[3]) * 4 - 4;
}
-static __inline__ void
+static __always_inline void
elf_machine_relative (Elf32_Addr load_off, const Elf32_Addr rel_addr,
Elf32_Word relative_count)
{
diff --git a/ldso/ldso/sparc/elfinterp.c b/ldso/ldso/sparc/elfinterp.c
index 9b425fcee..bb61be9eb 100644
--- a/ldso/ldso/sparc/elfinterp.c
+++ b/ldso/ldso/sparc/elfinterp.c
@@ -52,7 +52,6 @@ extern int _dl_linux_resolve(void);
unsigned long
_dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
{
- int reloc_type;
ELF_RELOC *this_reloc;
char *strtab;
ElfW(Sym) *symtab;
@@ -70,25 +69,18 @@ _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
reloc_entry = (reloc_entry >> 10) - 0xc;
this_reloc = (ELF_RELOC *)(rel_addr + reloc_entry);
- reloc_type = ELF_R_TYPE(this_reloc->r_info);
symtab_index = ELF_R_SYM(this_reloc->r_info);
symtab = (ElfW(Sym) *)tpnt->dynamic_info[DT_SYMTAB];
strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
symname = strtab + symtab[symtab_index].st_name;
- if (unlikely(reloc_type != R_SPARC_JMP_SLOT)) {
- _dl_dprintf(2, "%s: Incorrect relocation type in jump relocations\n",
- _dl_progname);
- _dl_exit(1);
- }
-
/* Address of the jump instruction to fix up. */
instr_addr = (this_reloc->r_offset + tpnt->loadaddr);
got_addr = (char **)instr_addr;
/* Get the address of the GOT entry */
- new_addr = _dl_find_hash(symname, tpnt->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT);
+ new_addr = _dl_find_hash(symname, &_dl_loaded_modules->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT, NULL);
if (unlikely(!new_addr)) {
_dl_dprintf(2, "%s: Can't resolve symbol '%s'\n", _dl_progname, symname);
_dl_exit(1);
@@ -107,17 +99,17 @@ _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
if (!_dl_debug_nofixups)
#endif
{
- got_addr[1] = (char *) (0x03000000 | (((unsigned int) new_addr >> 10) & 0x3fffff));
- got_addr[2] = (char *) (0x81c06000 | ((unsigned int) new_addr & 0x3ff));
+ got_addr[1] = (char *) (OPCODE_SETHI_G1 | (((unsigned int) new_addr >> 10) & 0x3fffff));
+ got_addr[2] = (char *) (OPCODE_JMP_G1 | ((unsigned int) new_addr & 0x3ff));
}
return (unsigned long)new_addr;
}
static int
-_dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
+_dl_parse(struct elf_resolve *tpnt, struct r_scope_elem *scope,
unsigned long rel_addr, unsigned long rel_size,
- int (*reloc_fnc)(struct elf_resolve *tpnt, struct dyn_elf *scope,
+ int (*reloc_fnc)(struct elf_resolve *tpnt, struct r_scope_elem *scope,
ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab))
{
unsigned int i;
@@ -172,13 +164,14 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
}
static int
-_dl_do_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
+_dl_do_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
{
int reloc_type;
int symtab_index;
char *symname;
- ElfW(Sym) *sym;
+ struct elf_resolve *tls_tpnt = NULL;
+ struct symbol_ref sym_ref;
ElfW(Addr) *reloc_addr;
ElfW(Addr) symbol_addr;
#if defined (__SUPPORT_LD_DEBUG__)
@@ -188,22 +181,36 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
reloc_addr = (ElfW(Addr)*)(tpnt->loadaddr + (unsigned long)rpnt->r_offset);
reloc_type = ELF_R_TYPE(rpnt->r_info);
symtab_index = ELF_R_SYM(rpnt->r_info);
- sym = &symtab[symtab_index];
+ sym_ref.sym = &symtab[symtab_index];
+ sym_ref.tpnt = NULL;
symbol_addr = 0;
- symname = strtab + sym->st_name;
+ symname = strtab + sym_ref.sym->st_name;
if (symtab_index) {
symbol_addr = (ElfW(Addr))_dl_find_hash(symname, scope, tpnt,
- elf_machine_type_class(reloc_type));
+ elf_machine_type_class(reloc_type), &sym_ref);
/*
* We want to allow undefined references to weak symbols - this
* might have been intentional. We should not be linking local
* symbols here, so all bases should be covered.
*/
- if (unlikely(!symbol_addr && ELF_ST_BIND(sym->st_info) != STB_WEAK)) {
- _dl_dprintf(2, "%s: can't resolve symbol '%s'\n", _dl_progname, symname);
- _dl_exit(1);
+ if (unlikely(!symbol_addr && (ELF_ST_TYPE(sym_ref.sym->st_info) != STT_TLS)
+ && (ELF_ST_BIND(sym_ref.sym->st_info) != STB_WEAK))) {
+ /* This may be non-fatal if called from dlopen. */
+ return 1;
+
}
+ if (_dl_trace_prelink) {
+ _dl_debug_lookup (symname, tpnt, &symtab[symtab_index],
+ &sym_ref, elf_machine_type_class(reloc_type));
+ }
+ tls_tpnt = sym_ref.tpnt;
+ } else {
+ /* Relocs against STN_UNDEF are usually treated as using a
+ * symbol value of zero, and using the module containing the
+ * reloc itself. */
+ symbol_addr = sym_ref.sym->st_value;
+ tls_tpnt = tpnt;
}
#if defined (__SUPPORT_LD_DEBUG__)
@@ -216,21 +223,6 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
case R_SPARC_NONE:
break;
-#if 0 /* these dont really seem to be useful */
- case R_SPARC_8:
- *(char *) reloc_addr = symbol_addr;
- break;
- case R_SPARC_16:
- *(short *) reloc_addr = symbol_addr;
- break;
- case R_SPARC_DISP8:
- *(char *) reloc_addr = (symbol_addr) - (Elf32_Addr) reloc_addr;
- break;
- case R_SPARC_DISP16:
- *(short *) reloc_addr = (symbol_addr) - (Elf32_Addr) reloc_addr;
- break;
-#endif
-
case R_SPARC_DISP32:
*reloc_addr = symbol_addr - (unsigned int) reloc_addr;
break;
@@ -240,7 +232,7 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
symbol_addr = tpnt->loadaddr + rpnt->r_addend;
else
symbol_addr += rpnt->r_addend;
- *reloc_addr = (*reloc_addr & ~0x3ff)|(symbol_addr & 0x3ff);
+ *reloc_addr = (*reloc_addr & ~0x3ff) | (symbol_addr & 0x3ff);
break;
case R_SPARC_GLOB_DAT:
@@ -249,17 +241,8 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
break;
case R_SPARC_JMP_SLOT:
-/*
-value = symbol_addr;
-value += reloc->r_addend;
-disp = value - reloc_addr;
-reloc_addr[1] = OPCODE_JMP_G1 | (value & 0x3ff);
-reloc_addr[0] = OPCODE_SETHI_G1 | (value >> 10);
- reloc_addr[1] = OPCODE_JMP_G1 | ((symbol_addr-(Elf32_Addr)reloc_addr) & 0x3ff);
- reloc_addr[0] = OPCODE_SETHI_G1 | ((symbol_addr-(Elf32_Addr)reloc_addr) >> 10);
-*/
- reloc_addr[1] = 0x03000000 | ((symbol_addr >> 10) & 0x3fffff);
- reloc_addr[2] = 0x81c06000 | (symbol_addr & 0x3ff);
+ reloc_addr[1] = OPCODE_SETHI_G1 | (( symbol_addr >> 10 ) & 0x3fffff);
+ reloc_addr[2] = OPCODE_JMP_G1 | ( symbol_addr & 0x3ff );
break;
case R_SPARC_RELATIVE:
@@ -285,16 +268,39 @@ reloc_addr[0] = OPCODE_SETHI_G1 | (value >> 10);
if (_dl_debug_move)
_dl_dprintf(_dl_debug_file,
"\t%s move %d bytes from %x to %x\n",
- symname, sym->st_size,
+ symname, sym_ref.sym->st_size,
symbol_addr, reloc_addr);
#endif
_dl_memcpy((char *)reloc_addr,
(char *)symbol_addr,
- sym->st_size);
- } else
+ sym_ref.sym->st_size);
+ }
+#if defined (__SUPPORT_LD_DEBUG__)
+ else
_dl_dprintf(_dl_debug_file, "no symbol_addr to copy !?\n");
+#endif
+ break;
+#if defined USE_TLS && USE_TLS
+ case R_SPARC_TLS_DTPMOD32:
+ *reloc_addr = tls_tpnt->l_tls_modid;
break;
+
+ case R_SPARC_TLS_DTPOFF32:
+ /* During relocation all TLS symbols are defined and used.
+ * Therefore the offset is already correct. */
+ *reloc_addr = sym_ref.sym->st_value + rpnt->r_addend;
+ break;
+
+ case R_SPARC_TLS_TPOFF32:
+ /* The offset is negative, forward from the thread pointer.
+ * We know the offset of the object the symbol is contained in.
+ * It is a negative value which will be added to the
+ * thread pointer. */
+ CHECK_STATIC_TLS ((struct link_map *) tls_tpnt);
+ *reloc_addr = sym_ref.sym->st_value - tls_tpnt->l_tls_offset + rpnt->r_addend;
+ break;
+#endif
default:
return -1; /* Calls _dl_exit(1). */
}
@@ -311,7 +317,7 @@ reloc_addr[0] = OPCODE_SETHI_G1 | (value >> 10);
#undef __SPARC_LAZY_RELOC_WORKS
#ifdef __SPARC_LAZY_RELOC_WORKS
static int
-_dl_do_lazy_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
+_dl_do_lazy_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
{
int reloc_type;
@@ -359,14 +365,16 @@ _dl_parse_lazy_relocation_information(struct dyn_elf *rpnt,
#ifdef __SPARC_LAZY_RELOC_WORKS
(void)_dl_parse(rpnt->dyn, NULL, rel_addr, rel_size, _dl_do_lazy_reloc);
#else
- _dl_parse_relocation_information(rpnt, rel_addr, rel_size);
+ _dl_parse_relocation_information(rpnt, &_dl_loaded_modules->symbol_scope,
+ rel_addr, rel_size);
#endif
}
int
_dl_parse_relocation_information(struct dyn_elf *rpnt,
+ struct r_scope_elem *scope,
unsigned long rel_addr,
unsigned long rel_size)
{
- return _dl_parse(rpnt->dyn, rpnt->dyn->symbol_scope, rel_addr, rel_size, _dl_do_reloc);
+ return _dl_parse(rpnt->dyn, scope, rel_addr, rel_size, _dl_do_reloc);
}
diff --git a/ldso/ldso/x86_64/dl-debug.h b/ldso/ldso/x86_64/dl-debug.h
index d605a0385..c47062b55 100644
--- a/ldso/ldso/x86_64/dl-debug.h
+++ b/ldso/ldso/x86_64/dl-debug.h
@@ -29,7 +29,7 @@
* SUCH DAMAGE.
*/
-static const char *_dl_reltypes_tab[] = {
+static const char * const _dl_reltypes_tab[] = {
[ 0] "R_X86_64_NONE", "R_X86_64_64", "R_X86_64_PC32", "R_X86_64_GOT32",
[ 4] "R_X86_64_PLT32", "R_X86_64_COPY", "R_X86_64_GLOB_DAT", "R_X86_64_JUMP_SLOT",
[ 8] "R_X86_64_RELATIVE", "R_X86_64_GOTPCREL", "R_X86_64_32", "R_X86_64_32S",
diff --git a/ldso/ldso/x86_64/dl-startup.h b/ldso/ldso/x86_64/dl-startup.h
index 6da888068..2f5e6ece7 100644
--- a/ldso/ldso/x86_64/dl-startup.h
+++ b/ldso/ldso/x86_64/dl-startup.h
@@ -10,6 +10,7 @@ __asm__ (
" .text\n"
" .global _start\n"
" .type _start,%function\n"
+ " .hidden _start\n"
"_start:\n"
" movq %rsp, %rdi\n"
" call _dl_start\n"
@@ -35,7 +36,7 @@ __asm__ (
);
/* Get a pointer to the argv array. On many platforms this can be just
- * the address if the first argument, on other platforms we need to
+ * the address of the first argument, on other platforms we need to
* do something a little more subtle here. */
#define GET_ARGV(ARGVP, ARGS) ARGVP = (((unsigned long*) ARGS)+1)
@@ -58,6 +59,9 @@ void PERFORM_BOOTSTRAP_RELOC(ELF_RELOC *rpnt, ElfW(Addr) *reloc_addr,
case R_X86_64_TPOFF64:
*reloc_addr = sym->st_value + rpnt->r_addend - symbol_addr;
break;
+/*TODO: case R_X86_64_RELATIVE:
+ *reloc_addr = load_addr + rpnt->r_addend;
+ break; */
default:
_dl_exit(1);
}
diff --git a/ldso/ldso/x86_64/dl-syscalls.h b/ldso/ldso/x86_64/dl-syscalls.h
index 996bb87c6..f40c4fd31 100644
--- a/ldso/ldso/x86_64/dl-syscalls.h
+++ b/ldso/ldso/x86_64/dl-syscalls.h
@@ -1,6 +1 @@
-/* We can't use the real errno in ldso, since it has not yet
- * been dynamicly linked in yet. */
-#include "sys/syscall.h"
-extern int _dl_errno;
-#undef __set_errno
-#define __set_errno(X) {(_dl_errno) = (X);}
+/* stub for arch-specific syscall issues */
diff --git a/ldso/ldso/x86_64/dl-sysdep.h b/ldso/ldso/x86_64/dl-sysdep.h
index 202eab19d..3706c0d00 100644
--- a/ldso/ldso/x86_64/dl-sysdep.h
+++ b/ldso/ldso/x86_64/dl-sysdep.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/>. */
/* Define this if the system uses RELOCA. */
#define ELF_USES_RELOCA
@@ -41,18 +40,17 @@ do { \
struct elf_resolve;
extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
-/* 4096 bytes alignment */
-#define PAGE_ALIGN 0xfffff000
-#define ADDR_ALIGN 0xfff
-#define OFFS_ALIGN 0x7ffff000
-
/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry or
TLS variable, so undefined references should not be allowed to
define the value.
ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one
of the main executable's symbols, as for a COPY reloc. */
-#define elf_machine_type_class(type) \
- ((((type) == R_X86_64_JUMP_SLOT) * ELF_RTYPE_CLASS_PLT) \
+#define elf_machine_type_class(type) \
+ ((((type) == R_X86_64_JUMP_SLOT \
+ || (type) == R_X86_64_DTPMOD64 \
+ || (type) == R_X86_64_DTPOFF64 \
+ || (type) == R_X86_64_TPOFF64) \
+ * ELF_RTYPE_CLASS_PLT) \
| (((type) == R_X86_64_COPY) * ELF_RTYPE_CLASS_COPY))
/* Return the link-time address of _DYNAMIC. Conveniently, this is the
diff --git a/ldso/ldso/x86_64/elfinterp.c b/ldso/ldso/x86_64/elfinterp.c
index e78a80969..75666a799 100644
--- a/ldso/ldso/x86_64/elfinterp.c
+++ b/ldso/ldso/x86_64/elfinterp.c
@@ -47,7 +47,6 @@ extern int _dl_linux_resolve(void);
unsigned long
_dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
{
- int reloc_type;
ELF_RELOC *this_reloc;
char *strtab;
ElfW(Sym) *symtab;
@@ -60,25 +59,18 @@ _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
rel_addr = (char *)tpnt->dynamic_info[DT_JMPREL];
this_reloc = (ELF_RELOC *)(rel_addr + reloc_entry);
- reloc_type = ELF_R_TYPE(this_reloc->r_info);
symtab_index = ELF_R_SYM(this_reloc->r_info);
symtab = (ElfW(Sym) *)tpnt->dynamic_info[DT_SYMTAB];
strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
symname = strtab + symtab[symtab_index].st_name;
- if (unlikely(reloc_type != R_X86_64_JUMP_SLOT)) {
- _dl_dprintf(2, "%s: Incorrect relocation type in jump relocations\n",
- _dl_progname);
- _dl_exit(1);
- }
-
/* Address of the jump instruction to fix up. */
instr_addr = (this_reloc->r_offset + tpnt->loadaddr);
got_addr = (char **)instr_addr;
/* Get the address of the GOT entry. */
- new_addr = _dl_find_hash(symname, tpnt->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT);
+ new_addr = _dl_find_hash(symname, &_dl_loaded_modules->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT, NULL);
if (unlikely(!new_addr)) {
_dl_dprintf(2, "%s: Can't resolve symbol '%s'\n", _dl_progname, symname);
_dl_exit(1);
@@ -102,9 +94,9 @@ _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
}
static int
-_dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
+_dl_parse(struct elf_resolve *tpnt, struct r_scope_elem *scope,
unsigned long rel_addr, unsigned long rel_size,
- int (*reloc_fnc)(struct elf_resolve *tpnt, struct dyn_elf *scope,
+ int (*reloc_fnc)(struct elf_resolve *tpnt, struct r_scope_elem *scope,
ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab))
{
unsigned int i;
@@ -159,13 +151,16 @@ _dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
}
static int
-_dl_do_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
+_dl_do_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
{
int reloc_type;
int symtab_index;
char *symname;
- ElfW(Sym) *sym;
+#if defined USE_TLS && USE_TLS
+ struct elf_resolve *tls_tpnt;
+#endif
+ struct symbol_ref sym_ref;
ElfW(Addr) *reloc_addr;
ElfW(Addr) symbol_addr;
#if defined (__SUPPORT_LD_DEBUG__)
@@ -175,22 +170,39 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
reloc_addr = (ElfW(Addr)*)(tpnt->loadaddr + (unsigned long)rpnt->r_offset);
reloc_type = ELF_R_TYPE(rpnt->r_info);
symtab_index = ELF_R_SYM(rpnt->r_info);
- sym = &symtab[symtab_index];
+ sym_ref.sym = &symtab[symtab_index];
+ sym_ref.tpnt = NULL;
symbol_addr = 0;
- symname = strtab + sym->st_name;
+ symname = strtab + sym_ref.sym->st_name;
if (symtab_index) {
symbol_addr = (ElfW(Addr))_dl_find_hash(symname, scope, tpnt,
- elf_machine_type_class(reloc_type));
+ elf_machine_type_class(reloc_type), &sym_ref);
/*
* We want to allow undefined references to weak symbols - this
* might have been intentional. We should not be linking local
* symbols here, so all bases should be covered.
*/
- if (unlikely(!symbol_addr && ELF_ST_BIND(sym->st_info) != STB_WEAK)) {
- _dl_dprintf(2, "%s: can't resolve symbol '%s'\n", _dl_progname, symname);
- _dl_exit(1);
+ if (unlikely(!symbol_addr && (ELF_ST_TYPE(sym_ref.sym->st_info) != STT_TLS)
+ && (ELF_ST_BIND(sym_ref.sym->st_info) != STB_WEAK))) {
+ /* This may be non-fatal if called from dlopen. */
+ return 1;
}
+ if (_dl_trace_prelink) {
+ _dl_debug_lookup (symname, tpnt, &symtab[symtab_index],
+ &sym_ref, elf_machine_type_class(reloc_type));
+ }
+#if defined USE_TLS && USE_TLS
+ tls_tpnt = sym_ref.tpnt;
+#endif
+ } else {
+ /* Relocs against STN_UNDEF are usually treated as using a
+ * symbol value of zero, and using the module containing the
+ * reloc itself. */
+ symbol_addr = sym_ref.sym->st_value;
+#if defined USE_TLS && USE_TLS
+ tls_tpnt = tpnt;
+#endif
}
#if defined (__SUPPORT_LD_DEBUG__)
@@ -219,15 +231,24 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
*reloc_addr = map->l_addr + rpnt->r_addend;
break;
*/
+#if defined USE_TLS && USE_TLS
case R_X86_64_DTPMOD64:
- *reloc_addr = 1;
+ *reloc_addr = tls_tpnt->l_tls_modid;
break;
case R_X86_64_DTPOFF64:
- *reloc_addr = sym->st_value + rpnt->r_addend;
+ /* During relocation all TLS symbols are defined and used.
+ * Therefore the offset is already correct. */
+ *reloc_addr = symbol_addr + rpnt->r_addend;
break;
case R_X86_64_TPOFF64:
- *reloc_addr = sym->st_value + rpnt->r_addend - symbol_addr;
+ /* The offset is negative, forward from the thread pointer.
+ * We know the offset of the object the symbol is contained in.
+ * It is a negative value which will be added to the
+ * thread pointer. */
+ CHECK_STATIC_TLS ((struct link_map *) tls_tpnt);
+ *reloc_addr = symbol_addr - tls_tpnt->l_tls_offset + rpnt->r_addend;
break;
+#endif
case R_X86_64_32:
*(unsigned int *) reloc_addr = symbol_addr + rpnt->r_addend;
/* XXX: should check for overflow eh ? */
@@ -239,15 +260,18 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
if (_dl_debug_move)
_dl_dprintf(_dl_debug_file,
"\t%s move %d bytes from %x to %x\n",
- symname, sym->st_size,
+ symname, sym_ref.sym->st_size,
symbol_addr, reloc_addr);
#endif
_dl_memcpy((char *)reloc_addr,
(char *)symbol_addr,
- sym->st_size);
- } else
+ sym_ref.sym->st_size);
+ }
+#if defined (__SUPPORT_LD_DEBUG__)
+ else
_dl_dprintf(_dl_debug_file, "no symbol_addr to copy !?\n");
+#endif
break;
default:
@@ -264,18 +288,16 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
}
static int
-_dl_do_lazy_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
+_dl_do_lazy_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
{
int reloc_type;
- int symtab_index;
ElfW(Addr) *reloc_addr;
#if defined (__SUPPORT_LD_DEBUG__)
ElfW(Addr) old_val;
#endif
(void)scope;
- symtab_index = ELF_R_SYM(rpnt->r_info);
(void)strtab;
reloc_addr = (ElfW(Addr)*)(tpnt->loadaddr + rpnt->r_offset);
@@ -314,8 +336,9 @@ _dl_parse_lazy_relocation_information(struct dyn_elf *rpnt,
int
_dl_parse_relocation_information(struct dyn_elf *rpnt,
+ struct r_scope_elem *scope,
unsigned long rel_addr,
unsigned long rel_size)
{
- return _dl_parse(rpnt->dyn, rpnt->dyn->symbol_scope, rel_addr, rel_size, _dl_do_reloc);
+ return _dl_parse(rpnt->dyn, scope, rel_addr, rel_size, _dl_do_reloc);
}
diff --git a/ldso/ldso/xtensa/dl-debug.h b/ldso/ldso/xtensa/dl-debug.h
index 327defc07..18beae5ca 100644
--- a/ldso/ldso/xtensa/dl-debug.h
+++ b/ldso/ldso/xtensa/dl-debug.h
@@ -6,56 +6,33 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-static const char *_dl_reltypes_tab[] =
+static const char * const _dl_reltypes_tab[] =
{
- "R_XTENSA_NONE",
- "R_XTENSA_32",
- "R_XTENSA_RTLD",
- "R_XTENSA_GLOB_DAT",
- "R_XTENSA_JMP_SLOT",
- "R_XTENSA_RELATIVE",
- "R_XTENSA_PLT",
- "R_XTENSA_UNUSED7",
- "R_XTENSA_OP0",
- "R_XTENSA_OP1",
- "R_XTENSA_OP2",
- "R_XTENSA_ASM_EXPAND",
- "R_XTENSA_ASM_SIMPLIFY",
- "R_XTENSA_UNUSED13",
- "R_XTENSA_UNUSED14",
- "R_XTENSA_GNU_VTINHERIT",
- "R_XTENSA_GNU_VTENTRY",
- "R_XTENSA_DIFF8",
- "R_XTENSA_DIFF16",
- "R_XTENSA_DIFF32",
- "R_XTENSA_SLOT0_OP",
- "R_XTENSA_SLOT1_OP",
- "R_XTENSA_SLOT2_OP",
- "R_XTENSA_SLOT3_OP",
- "R_XTENSA_SLOT4_OP",
- "R_XTENSA_SLOT5_OP",
- "R_XTENSA_SLOT6_OP",
- "R_XTENSA_SLOT7_OP",
- "R_XTENSA_SLOT8_OP",
- "R_XTENSA_SLOT9_OP",
- "R_XTENSA_SLOT10_OP",
- "R_XTENSA_SLOT11_OP",
- "R_XTENSA_SLOT12_OP",
- "R_XTENSA_SLOT13_OP",
- "R_XTENSA_SLOT14_OP",
- "R_XTENSA_SLOT0_ALT",
- "R_XTENSA_SLOT1_ALT",
- "R_XTENSA_SLOT2_ALT",
- "R_XTENSA_SLOT3_ALT",
- "R_XTENSA_SLOT4_ALT",
- "R_XTENSA_SLOT5_ALT",
- "R_XTENSA_SLOT6_ALT",
- "R_XTENSA_SLOT7_ALT",
- "R_XTENSA_SLOT8_ALT",
- "R_XTENSA_SLOT9_ALT",
- "R_XTENSA_SLOT10_ALT",
- "R_XTENSA_SLOT11_ALT",
- "R_XTENSA_SLOT12_ALT",
- "R_XTENSA_SLOT13_ALT",
- "R_XTENSA_SLOT14_ALT"
+ [0] "R_XTENSA_NONE", "R_XTENSA_32",
+ [2] "R_XTENSA_RTLD", "R_XTENSA_GLOB_DAT",
+ [4] "R_XTENSA_JMP_SLOT", "R_XTENSA_RELATIVE",
+ [6] "R_XTENSA_PLT", "R_XTENSA_UNUSED7",
+ [8] "R_XTENSA_OP0", "R_XTENSA_OP1",
+ [10] "R_XTENSA_OP2", "R_XTENSA_ASM_EXPAND",
+ [12] "R_XTENSA_ASM_SIMPLIFY", "R_XTENSA_UNUSED13",
+ [14] "R_XTENSA_UNUSED14", "R_XTENSA_GNU_VTINHERIT",
+ [16] "R_XTENSA_GNU_VTENTRY", "R_XTENSA_DIFF8",
+ [18] "R_XTENSA_DIFF16", "R_XTENSA_DIFF32",
+ [20] "R_XTENSA_SLOT0_OP", "R_XTENSA_SLOT1_OP",
+ [22] "R_XTENSA_SLOT2_OP", "R_XTENSA_SLOT3_OP",
+ [24] "R_XTENSA_SLOT4_OP", "R_XTENSA_SLOT5_OP",
+ [26] "R_XTENSA_SLOT6_OP", "R_XTENSA_SLOT7_OP",
+ [28] "R_XTENSA_SLOT8_OP", "R_XTENSA_SLOT9_OP",
+ [30] "R_XTENSA_SLOT10_OP", "R_XTENSA_SLOT11_OP",
+ [32] "R_XTENSA_SLOT12_OP", "R_XTENSA_SLOT13_OP",
+ [34] "R_XTENSA_SLOT14_OP", "R_XTENSA_SLOT0_ALT",
+ [36] "R_XTENSA_SLOT1_ALT", "R_XTENSA_SLOT2_ALT",
+ [38] "R_XTENSA_SLOT3_ALT", "R_XTENSA_SLOT4_ALT",
+ [40] "R_XTENSA_SLOT5_ALT", "R_XTENSA_SLOT6_ALT",
+ [42] "R_XTENSA_SLOT7_ALT", "R_XTENSA_SLOT8_ALT",
+ [44] "R_XTENSA_SLOT9_ALT", "R_XTENSA_SLOT10_ALT",
+ [46] "R_XTENSA_SLOT11_ALT", "R_XTENSA_SLOT12_ALT",
+ [48] "R_XTENSA_SLOT13_ALT", "R_XTENSA_SLOT14_ALT",
+ [50] "R_XTENSA_TLSDESC_FN", "R_XTENSA_TLSDESC_ARG",
+ [52] "R_XTENSA_TLS_TPOFF"
};
diff --git a/ldso/ldso/xtensa/dl-startup.h b/ldso/ldso/xtensa/dl-startup.h
index 8ae962408..aece0cd96 100644
--- a/ldso/ldso/xtensa/dl-startup.h
+++ b/ldso/ldso/xtensa/dl-startup.h
@@ -11,8 +11,10 @@
__asm__ (
" .text\n"
" .align 4\n"
+ " .literal_position\n"
" .global _start\n"
" .type _start, @function\n"
+ " .hidden _start\n"
"_start:\n"
" # Compute load offset in a2: the GOT has not yet been relocated\n"
" # but the entries for local symbols contain the relative offsets\n"
@@ -21,6 +23,7 @@ __asm__ (
" .align 4\n"
"0: movi a3, _start+3\n"
" sub a2, a0, a3\n"
+#if defined(__XTENSA_WINDOWED_ABI__)
" # Make sure a0 is cleared to mark the top of stack.\n"
" movi a0, 0\n"
" # user_entry_point = _dl_start(pointer to argument block)\n"
@@ -30,6 +33,17 @@ __asm__ (
" callx4 a4\n"
" # Save user_entry_point so we can jump to it.\n"
" mov a3, a6\n"
+#elif defined(__XTENSA_CALL0_ABI__)
+ " # user_entry_point = _dl_start(pointer to argument block)\n"
+ " movi a0, _dl_start\n"
+ " add a0, a0, a2\n"
+ " mov a2, sp\n"
+ " callx0 a0\n"
+ " # Save user_entry_point so we can jump to it.\n"
+ " mov a3, a2\n"
+#else
+#error Unsupported Xtensa ABI
+#endif
" l32i a7, sp, 0 # load argc\n"
" # Load _dl_skip_args into a4.\n"
" movi a4, _dl_skip_args\n"
@@ -81,6 +95,7 @@ do { \
unsigned long l_addr = tpnt->loadaddr; \
Elf32_Word relative_count; \
unsigned long rel_addr; \
+ Elf32_Addr prev_got_start = 0, prev_got_end = 0; \
int x; \
\
got_loc = (xtensa_got_location *) \
@@ -91,7 +106,24 @@ do { \
got_start = got_loc[x].offset & ~(PAGE_SIZE - 1); \
got_end = ((got_loc[x].offset + got_loc[x].length + PAGE_SIZE - 1) \
& ~(PAGE_SIZE - 1)); \
- _dl_mprotect ((void *)(got_start + l_addr), got_end - got_start, \
+ if (got_end >= prev_got_start && got_start <= prev_got_end) { \
+ if (got_end > prev_got_end) \
+ prev_got_end = got_end; \
+ if (got_start < prev_got_start) \
+ prev_got_start = got_start; \
+ continue; \
+ } else if (prev_got_start != prev_got_end) { \
+ _dl_mprotect ((void *)(prev_got_start + l_addr), \
+ prev_got_end - prev_got_start, \
+ PROT_READ | PROT_WRITE | PROT_EXEC); \
+ } \
+ prev_got_start = got_start; \
+ prev_got_end = got_end; \
+ } \
+\
+ if (prev_got_start != prev_got_end) { \
+ _dl_mprotect ((void *)(prev_got_start + l_addr), \
+ prev_got_end - prev_got_start, \
PROT_READ | PROT_WRITE | PROT_EXEC); \
} \
\
diff --git a/ldso/ldso/xtensa/dl-syscalls.h b/ldso/ldso/xtensa/dl-syscalls.h
index 4b42a57e0..f40c4fd31 100644
--- a/ldso/ldso/xtensa/dl-syscalls.h
+++ b/ldso/ldso/xtensa/dl-syscalls.h
@@ -1,7 +1 @@
-/* We can't use the real errno in ldso, since it has not yet
- * been dynamicly linked in yet. */
-#include "sys/syscall.h"
-extern int _dl_errno;
-#undef __set_errno
-#define __set_errno(X) {(_dl_errno) = (X);}
-
+/* stub for arch-specific syscall issues */
diff --git a/ldso/ldso/xtensa/dl-sysdep.h b/ldso/ldso/xtensa/dl-sysdep.h
index b58feff54..d308237d3 100644
--- a/ldso/ldso/xtensa/dl-sysdep.h
+++ b/ldso/ldso/xtensa/dl-sysdep.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/>. */
/* Define this if the system uses RELOCA. */
#define ELF_USES_RELOCA
@@ -37,6 +36,7 @@ typedef struct xtensa_got_location_struct {
do { \
xtensa_got_location *got_loc; \
Elf32_Addr l_addr = MODULE->loadaddr; \
+ Elf32_Addr prev_got_start = 0, prev_got_end = 0; \
int x; \
\
got_loc = (xtensa_got_location *) \
@@ -48,7 +48,28 @@ typedef struct xtensa_got_location_struct {
got_start = got_loc[x].offset & ~(PAGE_SIZE - 1); \
got_end = ((got_loc[x].offset + got_loc[x].length + PAGE_SIZE - 1) \
& ~(PAGE_SIZE - 1)); \
- _dl_mprotect ((void *)(got_start + l_addr) , got_end - got_start, \
+ if (got_end >= prev_got_start && got_start <= prev_got_end) \
+ { \
+ if (got_end > prev_got_end) \
+ prev_got_end = got_end; \
+ if (got_start < prev_got_start) \
+ prev_got_start = got_start; \
+ continue; \
+ } \
+ else if (prev_got_start != prev_got_end) \
+ { \
+ _dl_mprotect ((void *)(prev_got_start + l_addr), \
+ prev_got_end - prev_got_start, \
+ PROT_READ | PROT_WRITE | PROT_EXEC); \
+ } \
+ prev_got_start = got_start; \
+ prev_got_end = got_end; \
+ } \
+ \
+ if (prev_got_start != prev_got_end) \
+ { \
+ _dl_mprotect ((void *)(prev_got_start + l_addr), \
+ prev_got_end - prev_got_start, \
PROT_READ | PROT_WRITE | PROT_EXEC); \
} \
\
@@ -73,21 +94,22 @@ typedef struct xtensa_got_location_struct {
/* Used for error messages. */
#define ELF_TARGET "Xtensa"
+/* Need bootstrap relocations */
+#define ARCH_NEEDS_BOOTSTRAP_RELOCS
+
struct elf_resolve;
extern unsigned long _dl_linux_resolver (struct elf_resolve *, int);
-/* 4096 bytes alignment */
-#define PAGE_ALIGN 0xfffff000
-#define ADDR_ALIGN 0xfff
-#define OFFS_ALIGN 0x7ffff000
-
-/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry, so
- undefined references should not be allowed to define the value. */
+/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry or
+ TLS variable, so undefined references should not be allowed to define
+ the value. */
#define elf_machine_type_class(type) \
- (((type) == R_XTENSA_JMP_SLOT) * ELF_RTYPE_CLASS_PLT)
+ (((type) == R_XTENSA_JMP_SLOT || (type) == R_XTENSA_TLS_TPOFF \
+ || (type) == R_XTENSA_TLSDESC_FN || (type) == R_XTENSA_TLSDESC_ARG) \
+ * ELF_RTYPE_CLASS_PLT)
/* Return the link-time address of _DYNAMIC. */
-static __inline__ Elf32_Addr
+static __always_inline Elf32_Addr
elf_machine_dynamic (void)
{
/* This function is only used while bootstrapping the runtime linker.
@@ -97,7 +119,7 @@ elf_machine_dynamic (void)
}
/* Return the run-time load address of the shared object. */
-static __inline__ Elf32_Addr
+static __always_inline Elf32_Addr
elf_machine_load_address (void)
{
Elf32_Addr addr, tmp;
@@ -118,7 +140,7 @@ elf_machine_load_address (void)
return addr - 3;
}
-static __inline__ void
+static __always_inline void
elf_machine_relative (Elf32_Addr load_off, const Elf32_Addr rel_addr,
Elf32_Word relative_count)
{
diff --git a/ldso/ldso/xtensa/dl-tlsdesc.S b/ldso/ldso/xtensa/dl-tlsdesc.S
new file mode 100644
index 000000000..6f417f61a
--- /dev/null
+++ b/ldso/ldso/xtensa/dl-tlsdesc.S
@@ -0,0 +1,103 @@
+/* Thread-local storage handling in the ELF dynamic linker. Xtensa version.
+ Copyright (C) 2012-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/>. */
+
+#include <sysdep.h>
+
+#if defined __UCLIBC_HAS_TLS__
+#include <tls.h>
+#include "tlsdesc.h"
+
+ .text
+HIDDEN_ENTRY (_dl_tlsdesc_return)
+ rur.threadptr a3
+ add a2, a2, a3
+ abi_ret
+END (_dl_tlsdesc_return)
+
+#ifdef SHARED
+
+
+ /* This function is used for symbols that need dynamic TLS.
+
+ The argument passed to this function points to the TLS descriptor.
+
+ The assembly code that follows is a rendition of the following
+ C code, hand-optimized a little bit.
+
+ ptrdiff_t
+ _dl_tlsdesc_dynamic(struct tlsdesc_dynamic_arg *td)
+ {
+ dtv_t *dtv = (dtv_t *)THREAD_DTV();
+ if (td->gen_count <= dtv[0].counter
+ && dtv[td->tlsinfo.ti_module].pointer.val
+ != TLS_DTV_UNALLOCATED)
+ return dtv[td->tlsinfo.ti_module].pointer.val
+ + td->tlsinfo.ti_offset - __builtin_thread_pointer();
+ return __tls_get_addr (&td->tlsinfo) - __builtin_thread_pointer();
+ }
+ */
+
+HIDDEN_ENTRY (_dl_tlsdesc_dynamic)
+
+ /* dtv_t *dtv = (dtv_t *)THREAD_DTV(); */
+ rur.threadptr a3
+ l32i a4, a3, 0
+
+ /* if (td->gen_count <= dtv[0].counter */
+ l32i a6, a2, TLSDESC_GEN_COUNT
+ l32i a7, a4, 0
+ blt a7, a6, .Lslow
+
+ /* && dtv[td->tlsinfo.ti_module].pointer.val != TLS_DTV_UNALLOCATED) */
+ l32i a6, a2, TLSDESC_MODID
+ addx8 a6, a3, a6
+ l32i a6, a6, 0
+ beqi a6, -1, .Lslow
+
+ /* return dtv[td->tlsinfo.ti_module].pointer.val
+ + td->tlsinfo.ti_offset - __builtin_thread_pointer(); */
+ l32i a6, a2, TLSDESC_MODOFF
+ sub a2, a6, a3
+ abi_ret
+
+ /* return __tls_get_addr (&td->tlsinfo) - __builtin_thread_pointer(); */
+.Lslow:
+#if defined(__XTENSA_WINDOWED_ABI__)
+ mov a6, a2
+ movi a4, __tls_get_addr
+ callx4 a4
+ sub a2, a6, a3
+ retw
+#elif defined(__XTENSA_CALL0_ABI__)
+ addi a1, a1, -16
+ s32i a0, a1, 0
+ s32i a3, a1, 4
+ movi a0, __tls_get_addr
+ callx0 a0
+ l32i a3, a1, 4
+ l32i a0, a1, 0
+ sub a2, a2, a3
+ addi a1, a1, 16
+ ret
+#else
+#error Unsupported Xtensa ABI
+#endif
+END (_dl_tlsdesc_dynamic)
+
+#endif /* SHARED */
+#endif
diff --git a/ldso/ldso/xtensa/elfinterp.c b/ldso/ldso/xtensa/elfinterp.c
index a459431b1..66deb63ab 100644
--- a/ldso/ldso/xtensa/elfinterp.c
+++ b/ldso/ldso/xtensa/elfinterp.c
@@ -32,13 +32,17 @@
#include "ldso.h"
+#if defined(USE_TLS) && USE_TLS
+#include "dl-tls.h"
+#include "tlsdeschtab.h"
+#endif
+
unsigned long
_dl_linux_resolver (struct elf_resolve *tpnt, int reloc_entry)
{
- int reloc_type;
ELF_RELOC *this_reloc;
char *strtab;
- Elf32_Sym *symtab;
+ ElfW(Sym) *symtab;
int symtab_index;
char *rel_addr;
char *new_addr;
@@ -47,25 +51,18 @@ _dl_linux_resolver (struct elf_resolve *tpnt, int reloc_entry)
rel_addr = (char *) tpnt->dynamic_info[DT_JMPREL];
this_reloc = (ELF_RELOC *) (rel_addr + reloc_entry);
- reloc_type = ELF32_R_TYPE (this_reloc->r_info);
- symtab_index = ELF32_R_SYM (this_reloc->r_info);
+ symtab_index = ELF_R_SYM (this_reloc->r_info);
- symtab = (Elf32_Sym *) tpnt->dynamic_info[DT_SYMTAB];
+ symtab = (ElfW(Sym) *) tpnt->dynamic_info[DT_SYMTAB];
strtab = (char *) tpnt->dynamic_info[DT_STRTAB];
symname = strtab + symtab[symtab_index].st_name;
- if (unlikely (reloc_type != R_XTENSA_JMP_SLOT)) {
- _dl_dprintf (2, "%s: Incorrect relocation type in jump relocations\n",
- _dl_progname);
- _dl_exit (1);
- }
-
/* Address of the literal to fix up. */
got_addr = (char **) (this_reloc->r_offset + tpnt->loadaddr);
/* Get the address of the GOT entry. */
- new_addr = _dl_find_hash (symname, tpnt->symbol_scope, tpnt,
- ELF_RTYPE_CLASS_PLT);
+ new_addr = _dl_find_hash (symname, &_dl_loaded_modules->symbol_scope, tpnt,
+ ELF_RTYPE_CLASS_PLT, NULL);
if (unlikely (!new_addr)) {
_dl_dprintf (2, "%s: can't resolve symbol '%s'\n",
_dl_progname, symname);
@@ -90,14 +87,14 @@ _dl_linux_resolver (struct elf_resolve *tpnt, int reloc_entry)
static int
-_dl_parse (struct elf_resolve *tpnt, struct dyn_elf *scope,
+_dl_parse (struct elf_resolve *tpnt, struct r_scope_elem *scope,
unsigned long rel_addr, unsigned long rel_size,
- int (*reloc_fnc) (struct elf_resolve *tpnt, struct dyn_elf *scope,
- ELF_RELOC *rpnt, Elf32_Sym *symtab, char *strtab))
+ int (*reloc_fnc) (struct elf_resolve *tpnt, struct r_scope_elem *scope,
+ ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab))
{
unsigned int i;
char *strtab;
- Elf32_Sym *symtab;
+ ElfW(Sym) *symtab;
ELF_RELOC *rpnt;
int symtab_index;
@@ -105,13 +102,13 @@ _dl_parse (struct elf_resolve *tpnt, struct dyn_elf *scope,
rpnt = (ELF_RELOC *) rel_addr;
rel_size /= sizeof (ELF_RELOC);
- symtab = (Elf32_Sym *) tpnt->dynamic_info[DT_SYMTAB];
+ symtab = (ElfW(Sym) *) tpnt->dynamic_info[DT_SYMTAB];
strtab = (char *) tpnt->dynamic_info[DT_STRTAB];
for (i = 0; i < rel_size; i++, rpnt++) {
int res;
- symtab_index = ELF32_R_SYM (rpnt->r_info);
+ symtab_index = ELF_R_SYM (rpnt->r_info);
debug_sym (symtab, strtab, symtab_index);
debug_reloc (symtab, strtab, rpnt);
@@ -128,7 +125,7 @@ _dl_parse (struct elf_resolve *tpnt, struct dyn_elf *scope,
strtab + symtab[symtab_index].st_name);
if (unlikely (res < 0)) {
- int reloc_type = ELF32_R_TYPE (rpnt->r_info);
+ int reloc_type = ELF_R_TYPE (rpnt->r_info);
#if defined (__SUPPORT_LD_DEBUG__)
_dl_dprintf (2, "can't handle reloc type %s\n",
_dl_reltypes (reloc_type));
@@ -148,30 +145,34 @@ _dl_parse (struct elf_resolve *tpnt, struct dyn_elf *scope,
static int
-_dl_do_reloc (struct elf_resolve *tpnt, struct dyn_elf *scope,
- ELF_RELOC *rpnt, Elf32_Sym *symtab, char *strtab)
+_dl_do_reloc (struct elf_resolve *tpnt, struct r_scope_elem *scope,
+ ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
{
int reloc_type;
int symtab_index;
char *symname;
- Elf32_Sym *sym;
- Elf32_Addr *reloc_addr;
- Elf32_Addr symbol_addr;
+#if defined USE_TLS && USE_TLS
+ struct elf_resolve *tls_tpnt = NULL;
+#endif
+ struct symbol_ref sym_ref;
+ ElfW(Addr) *reloc_addr;
+ ElfW(Addr) symbol_addr;
#if defined (__SUPPORT_LD_DEBUG__)
- Elf32_Addr old_val;
+ ElfW(Addr) old_val;
#endif
- reloc_addr = (Elf32_Addr *) (tpnt->loadaddr + rpnt->r_offset);
- reloc_type = ELF32_R_TYPE (rpnt->r_info);
- symtab_index = ELF32_R_SYM (rpnt->r_info);
- sym = &symtab[symtab_index];
+ reloc_addr = (ElfW(Addr) *) (tpnt->loadaddr + rpnt->r_offset);
+ reloc_type = ELF_R_TYPE (rpnt->r_info);
+ symtab_index = ELF_R_SYM (rpnt->r_info);
+ sym_ref.sym = &symtab[symtab_index];
+ sym_ref.tpnt = NULL;
symbol_addr = 0;
- symname = strtab + sym->st_name;
+ symname = strtab + sym_ref.sym->st_name;
if (symtab_index) {
- symbol_addr = (Elf32_Addr)
+ symbol_addr = (ElfW(Addr))
_dl_find_hash (symname, scope, tpnt,
- elf_machine_type_class (reloc_type));
+ elf_machine_type_class (reloc_type), &sym_ref);
/*
* We want to allow undefined references to weak symbols - this might
@@ -179,11 +180,22 @@ _dl_do_reloc (struct elf_resolve *tpnt, struct dyn_elf *scope,
* here, so all bases should be covered.
*/
if (unlikely (!symbol_addr &&
- ELF32_ST_BIND (sym->st_info) != STB_WEAK)) {
- _dl_dprintf (2, "%s: can't resolve symbol '%s'\n",
- _dl_progname, symname);
- _dl_exit (1);
+ ELF_ST_TYPE (sym_ref.sym->st_info) != STT_TLS &&
+ ELF_ST_BIND (sym_ref.sym->st_info) != STB_WEAK)) {
+ return 1;
}
+ if (_dl_trace_prelink) {
+ _dl_debug_lookup (symname, tpnt, &symtab[symtab_index],
+ &sym_ref, elf_machine_type_class(reloc_type));
+ }
+#if defined USE_TLS && USE_TLS
+ tls_tpnt = sym_ref.tpnt;
+#endif
+ } else {
+ symbol_addr =symtab[symtab_index].st_value;
+#if defined USE_TLS && USE_TLS
+ tls_tpnt = tpnt;
+#endif
}
#if defined (__SUPPORT_LD_DEBUG__)
@@ -201,12 +213,12 @@ _dl_do_reloc (struct elf_resolve *tpnt, struct dyn_elf *scope,
case R_XTENSA_RTLD:
if (rpnt->r_addend == 1) {
- /* Grab the function pointer stashed at the beginning of the
- GOT by the GOT_INIT function. */
- *reloc_addr = *(Elf32_Addr *) tpnt->dynamic_info[DT_PLTGOT];
+ /* Grab the function pointer stashed at the beginning
+ of the GOT by the GOT_INIT function. */
+ *reloc_addr = *(ElfW(Addr) *) tpnt->dynamic_info[DT_PLTGOT];
} else if (rpnt->r_addend == 2) {
/* Store the link map for the object. */
- *reloc_addr = (Elf32_Addr) tpnt;
+ *reloc_addr = (ElfW(Addr)) tpnt;
} else {
_dl_exit (1);
}
@@ -216,12 +228,41 @@ _dl_do_reloc (struct elf_resolve *tpnt, struct dyn_elf *scope,
*reloc_addr += tpnt->loadaddr + rpnt->r_addend;
break;
+#if defined USE_TLS && USE_TLS
+ case R_XTENSA_TLS_TPOFF:
+ CHECK_STATIC_TLS((struct link_map *) tls_tpnt);
+ *reloc_addr = symbol_addr + tls_tpnt->l_tls_offset + rpnt->r_addend;
+ break;
+ case R_XTENSA_TLSDESC_FN:
+#ifndef SHARED
+ CHECK_STATIC_TLS((struct link_map *) tls_tpnt);
+#else
+ if (!TRY_STATIC_TLS ((struct link_map *) tls_tpnt))
+ *reloc_addr = (ElfW(Addr)) _dl_tlsdesc_dynamic;
+ else
+#endif
+ *reloc_addr = (ElfW(Addr)) _dl_tlsdesc_return;
+ break;
+ case R_XTENSA_TLSDESC_ARG:
+#ifndef SHARED
+ CHECK_STATIC_TLS((struct link_map *) tls_tpnt);
+#else
+ if (!TRY_STATIC_TLS ((struct link_map *) tls_tpnt))
+ *reloc_addr = (ElfW(Addr))
+ _dl_make_tlsdesc_dynamic((struct link_map *) tls_tpnt,
+ symbol_addr + *reloc_addr);
+ else
+#endif
+ *reloc_addr += symbol_addr + tls_tpnt->l_tls_offset;
+ break;
+#endif
+
default:
return -1; /* Calls _dl_exit(1). */
}
#if defined (__SUPPORT_LD_DEBUG__)
if (_dl_debug_reloc && _dl_debug_detail)
- _dl_dprintf (_dl_debug_file, "\tpatched: %x ==> %x @ %x",
+ _dl_dprintf (_dl_debug_file, "\tpatched: %x ==> %x @ %x\n",
old_val, *reloc_addr, reloc_addr);
#endif
@@ -230,17 +271,17 @@ _dl_do_reloc (struct elf_resolve *tpnt, struct dyn_elf *scope,
static int
-_dl_do_lazy_reloc (struct elf_resolve *tpnt, struct dyn_elf *scope,
- ELF_RELOC *rpnt, Elf32_Sym *symtab, char *strtab)
+_dl_do_lazy_reloc (struct elf_resolve *tpnt, struct r_scope_elem *scope,
+ ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
{
int reloc_type;
- Elf32_Addr *reloc_addr;
+ ElfW(Addr) *reloc_addr;
#if defined (__SUPPORT_LD_DEBUG__)
- Elf32_Addr old_val;
+ ElfW(Addr) old_val;
#endif
- reloc_addr = (Elf32_Addr *) (tpnt->loadaddr + rpnt->r_offset);
- reloc_type = ELF32_R_TYPE (rpnt->r_info);
+ reloc_addr = (ElfW(Addr) *) (tpnt->loadaddr + rpnt->r_offset);
+ reloc_type = ELF_R_TYPE (rpnt->r_info);
#if defined (__SUPPORT_LD_DEBUG__)
old_val = *reloc_addr;
@@ -260,7 +301,7 @@ _dl_do_lazy_reloc (struct elf_resolve *tpnt, struct dyn_elf *scope,
#if defined (__SUPPORT_LD_DEBUG__)
if (_dl_debug_reloc && _dl_debug_detail)
- _dl_dprintf (_dl_debug_file, "\tpatched: %x ==> %x @ %x",
+ _dl_dprintf (_dl_debug_file, "\tpatched: %x ==> %x @ %x\n",
old_val, *reloc_addr, reloc_addr);
#endif
return 0;
@@ -277,9 +318,10 @@ _dl_parse_lazy_relocation_information (struct dyn_elf *rpnt,
int
_dl_parse_relocation_information (struct dyn_elf *rpnt,
+ struct r_scope_elem *scope,
unsigned long rel_addr,
unsigned long rel_size)
{
- return _dl_parse (rpnt->dyn, rpnt->dyn->symbol_scope, rel_addr, rel_size,
+ return _dl_parse (rpnt->dyn, scope, rel_addr, rel_size,
_dl_do_reloc);
}
diff --git a/ldso/ldso/xtensa/resolve.S b/ldso/ldso/xtensa/resolve.S
index 902cd8238..12a554de7 100644
--- a/ldso/ldso/xtensa/resolve.S
+++ b/ldso/ldso/xtensa/resolve.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/>. */
#define MIN_FRAME_SIZE 32
@@ -28,16 +27,11 @@
.text
.align 4
+ .literal_position
.global _dl_linux_resolve
.type _dl_linux_resolve, @function
_dl_linux_resolve:
- /* Fix up the high 2 bits of the return address. */
- movi a13, 0f
- slli a12, a0, 2
-0: extui a13, a13, 30, 2
- ssai 2
- src a12, a13, a12
-
+#if defined(__XTENSA_WINDOWED_ABI__)
/* Call the fixup function. */
movi a8, _dl_linux_resolver
callx8 a8
@@ -54,4 +48,38 @@ _dl_linux_resolve:
/* Jump to the next instruction past the ENTRY. */
addi a10, a10, 3
jx a10
+#elif defined(__XTENSA_CALL0_ABI__)
+ /* Reserve stack space and save incoming arguments. */
+ addi a1, a1, -32
+ s32i a0, a1, 0
+ s32i a2, a1, 8
+ s32i a3, a1, 12
+ s32i a4, a1, 16
+ s32i a5, a1, 20
+ s32i a6, a1, 24
+ s32i a7, a1, 28
+
+ /* Move arguments for the _dl_linux_resolver to proper registers. */
+ mov a2, a10
+ mov a3, a11
+ /* Call the fixup function. */
+ movi a0, _dl_linux_resolver
+ callx0 a0
+ mov a10, a2
+
+ /* Restore incoming arguments from stack and deallocate reservation. */
+ l32i a0, a1, 0
+ l32i a2, a1, 8
+ l32i a3, a1, 12
+ l32i a4, a1, 16
+ l32i a5, a1, 20
+ l32i a6, a1, 24
+ l32i a7, a1, 28
+ addi a1, a1, 32
+
+ /* Jump to the target function. */
+ jx a10
+#else
+#error Unsupported Xtensa ABI
+#endif
.size _dl_linux_resolve, . - _dl_linux_resolve
diff --git a/ldso/libdl/Makefile.in b/ldso/libdl/Makefile.in
index 41cec858f..fe1eb9dab 100644
--- a/ldso/libdl/Makefile.in
+++ b/ldso/libdl/Makefile.in
@@ -1,23 +1,28 @@
# Makefile.in 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.
#
+subdirs += ldso/libdl
+
CFLAGS-libdl := -DNOT_IN_libc -DIS_IN_libdl $(SSP_ALL_CFLAGS)
CFLAGS-libdl += -I$(top_srcdir)ldso/ldso/$(TARGET_ARCH) -I$(top_srcdir)ldso/include -I$(top_srcdir)ldso/ldso
CFLAGS-libdl += -DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\"
-ifeq ($(SUPPORT_LD_DEBUG),y)
-CFLAGS-libdl += -D__SUPPORT_LD_DEBUG__
-endif
+CFLAGS-$(SUPPORT_LD_DEBUG)-ldso/libdl := -D__SUPPORT_LD_DEBUG__
CFLAGS-libdl.c := -DLDSO_ELFINTERP=\"$(TARGET_ARCH)/elfinterp.c\"
-LDFLAGS-libdl.so := $(LDFLAGS) -Wl,-fini,dl_cleanup
+LDFLAGS-$(UCLIBC_FORMAT_DSBT_ELF)-libdl.so := -Wl,--dsbt-index=3
+LDFLAGS-libdl.so := $(LDFLAGS)
+
+ifeq ($(LDSO_NO_CLEANUP),)
+LDFLAGS-libdl.so += -Wl,-fini,$(SYMBOL_PREFIX)dl_cleanup
+endif
LIBS-libdl.so := $(LIBS) $(ldso)
@@ -39,10 +44,10 @@ libdl-so-y := $(libdl_OUT)/libdl.oS
lib-a-$(HAVE_SHARED) += $(top_builddir)lib/libdl.a
lib-so-y += $(top_builddir)lib/libdl.so
-objclean-y += libdl_clean
+objclean-y += CLEAN_ldso/libdl
$(top_builddir)lib/libdl.so: $(libdl_OUT)/libdl_so.a $(libc.depend)
- $(call link.so,$(libdl_FULL_NAME),$(MAJOR_VERSION))
+ $(call link.so,$(libdl_FULL_NAME),$(ABI_VERSION))
$(libdl_OUT)/libdl_so.a: $(libdl-so-y)
$(Q)$(RM) $@
@@ -53,5 +58,5 @@ $(top_builddir)lib/libdl.a: $(libdl-a-y)
$(Q)$(RM) $@
$(do_ar)
-libdl_clean:
- $(RM) $(libdl_OUT)/*.{o,os,a,oS}
+CLEAN_ldso/libdl:
+ $(do_rm) $(addprefix $(libdl_OUT)/*., o os oS a)
diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c
index 9681e581b..42a09a8bb 100644
--- a/ldso/libdl/libdl.c
+++ b/ldso/libdl/libdl.c
@@ -32,24 +32,41 @@
#include <ldso.h>
#include <stdio.h>
-#include <string.h> /* Needed for 'strstr' prototype' */
+#include <string.h>
#include <stdbool.h>
+#include <bits/uClibc_mutex.h>
+#ifdef __UCLIBC_HAS_TLS__
+#include <tls.h>
+#endif
+
+#if defined(USE_TLS) && USE_TLS
+#include <ldsodefs.h>
+#include <dl-tls.h>
+extern void _dl_add_to_slotinfo(struct link_map *l);
+#endif
+
+/* TODO: get rid of global lock and use more finegrained locking, or
+ * perhaps RCU for the global structures */
+__UCLIBC_MUTEX_STATIC(_dl_mutex, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP);
#ifdef SHARED
+# if defined(USE_TLS) && USE_TLS
+extern struct link_map *_dl_update_slotinfo(unsigned long int req_modid);
+# endif
/* When libdl is loaded as a shared library, we need to load in
* and use a pile of symbols from ldso... */
-
-extern char *_dl_find_hash(const char *, struct dyn_elf *, struct elf_resolve *, int);
-extern struct elf_resolve * _dl_load_shared_library(int, struct dyn_elf **,
- struct elf_resolve *, char *, int);
-extern int _dl_fixup(struct dyn_elf *rpnt, int lazy);
+#include <dl-elf.h>
+#if 0
+extern int _dl_fixup(struct dyn_elf *rpnt, struct r_scope_elem *scope, int lazy);
extern void _dl_protect_relro(struct elf_resolve * tpnt);
+#endif
extern int _dl_errno;
extern struct dyn_elf *_dl_symbol_tables;
extern struct dyn_elf *_dl_handles;
extern struct elf_resolve *_dl_loaded_modules;
+extern void _dl_free (void *__ptr);
extern struct r_debug *_dl_debug_addr;
extern unsigned long _dl_error_number;
extern void *(*_dl_malloc_function)(size_t);
@@ -67,8 +84,7 @@ extern void _dl_perform_mips_global_got_relocations(struct elf_resolve *tpnt, in
extern char *_dl_debug;
#endif
-
-#else /* SHARED */
+#else /* !SHARED */
#define _dl_malloc malloc
#define _dl_free free
@@ -77,20 +93,21 @@ extern char *_dl_debug;
* the symbols that otherwise would have been loaded in from ldso... */
#ifdef __SUPPORT_LD_DEBUG__
-char *_dl_debug = 0;
-char *_dl_debug_symbols = 0;
-char *_dl_debug_move = 0;
-char *_dl_debug_reloc = 0;
-char *_dl_debug_detail = 0;
-char *_dl_debug_nofixups = 0;
-char *_dl_debug_bindings = 0;
+char *_dl_debug = NULL;
+char *_dl_debug_symbols = NULL;
+char *_dl_debug_move = NULL;
+char *_dl_debug_reloc = NULL;
+char *_dl_debug_detail = NULL;
+char *_dl_debug_nofixups = NULL;
+char *_dl_debug_bindings = NULL;
int _dl_debug_file = 2;
#endif
const char *_dl_progname = ""; /* Program name */
void *(*_dl_malloc_function)(size_t);
void (*_dl_free_function) (void *p);
-char *_dl_library_path = 0; /* Where we look for libraries */
-char *_dl_ldsopath = 0; /* Location of the shared lib loader */
+#ifdef __LDSO_LD_LIBRARY_PATH__
+char *_dl_library_path = NULL; /* Where we look for libraries */
+#endif
int _dl_errno = 0; /* We can't use the real errno in ldso */
size_t _dl_pagesize = PAGE_SIZE; /* Store the page size for use later */
/* This global variable is also to communicate with debuggers such as gdb. */
@@ -98,6 +115,15 @@ struct r_debug *_dl_debug_addr = NULL;
#include "../ldso/dl-array.c"
#include "../ldso/dl-debug.c"
+
+
+# if defined(USE_TLS) && USE_TLS
+/*
+ * Giving this initialized value preallocates some surplus bytes in the
+ * static TLS area, see __libc_setup_tls (libc-tls.c).
+ */
+size_t _dl_tls_static_size = 2048;
+# endif
#include LDSO_ELFINTERP
#include "../ldso/dl-hash.c"
#define _dl_trace_loaded_objects 0
@@ -108,7 +134,7 @@ struct r_debug *_dl_debug_addr = NULL;
# define _dl_if_debug_print(fmt, args...) \
do { \
if (_dl_debug) \
- fprintf(stderr, "%s():%i: " fmt, __FUNCTION__, __LINE__, ## args); \
+ fprintf(stderr, "%s():%i: " fmt, __func__, __LINE__, ## args); \
} while (0)
#else
# define _dl_if_debug_print(fmt, args...)
@@ -117,7 +143,7 @@ struct r_debug *_dl_debug_addr = NULL;
static int do_dlclose(void *, int need_fini);
-static const char *dl_error_names[] = {
+static const char *const dl_error_names[] = {
"",
"File not found",
"Unable to open /dev/zero",
@@ -134,6 +160,7 @@ static const char *dl_error_names[] = {
"Not an ELF shared library",
"Unable to mmap file",
"No dynamic section",
+ "Library contains unsupported TLS",
#ifdef ELF_USES_RELOCA
"Unable to process REL relocs",
#else
@@ -143,20 +170,134 @@ static const char *dl_error_names[] = {
"Unable to resolve symbol"
};
-void dl_cleanup(void) __attribute__ ((destructor));
+
+#if defined(USE_TLS) && USE_TLS
+#ifdef SHARED
+/*
+ * Systems which do not have tls_index also probably have to define
+ * DONT_USE_TLS_INDEX.
+ */
+
+# ifndef __TLS_GET_ADDR
+# define __TLS_GET_ADDR __tls_get_addr
+# endif
+
+/*
+ * Return the symbol address given the map of the module it is in and
+ * the symbol record. This is used in dl-sym.c.
+ */
+static void *
+internal_function
+_dl_tls_symaddr(struct link_map *map, const Elf32_Addr st_value)
+{
+# ifndef DONT_USE_TLS_INDEX
+ tls_index tmp =
+ {
+ .ti_module = map->l_tls_modid,
+ .ti_offset = st_value
+ };
+
+ return __TLS_GET_ADDR (&tmp);
+# else
+ return __TLS_GET_ADDR (map->l_tls_modid, st_value);
+# endif
+}
+#endif
+
+/* Returns true when a non-empty entry was found. */
+static bool
+remove_slotinfo(size_t idx, struct dtv_slotinfo_list *listp, size_t disp,
+ bool should_be_there)
+{
+ if (idx - disp >= listp->len) {
+ if (listp->next == NULL) {
+ /*
+ * The index is not actually valid in the slotinfo list,
+ * because this object was closed before it was fully set
+ * up due to some error.
+ */
+ _dl_assert(!should_be_there);
+ } else {
+ if (remove_slotinfo(idx, listp->next, disp + listp->len,
+ should_be_there))
+ return true;
+
+ /*
+ * No non-empty entry. Search from the end of this element's
+ * slotinfo array.
+ */
+ idx = disp + listp->len;
+ }
+ } else {
+ struct link_map *old_map = listp->slotinfo[idx - disp].map;
+
+ /*
+ * The entry might still be in its unused state if we are
+ * closing an object that wasn't fully set up.
+ */
+ if (__builtin_expect(old_map != NULL, 1)) {
+ _dl_assert(old_map->l_tls_modid == idx);
+
+ /* Mark the entry as unused. */
+ listp->slotinfo[idx - disp].gen = _dl_tls_generation + 1;
+ listp->slotinfo[idx - disp].map = NULL;
+ }
+
+ /*
+ * If this is not the last currently used entry no need to
+ * look further.
+ */
+ if (idx != _dl_tls_max_dtv_idx)
+ return true;
+ }
+
+ while (idx - disp > (disp == 0 ? 1 + _dl_tls_static_nelem : 0)) {
+ --idx;
+
+ if (listp->slotinfo[idx - disp].map != NULL) {
+ /* Found a new last used index. */
+ _dl_tls_max_dtv_idx = idx;
+ return true;
+ }
+ }
+
+ /* No non-entry in this list element. */
+ return false;
+}
+#endif
+
+#ifndef __LDSO_NO_CLEANUP__
+void dl_cleanup(void) attribute_hidden __attribute__ ((destructor));
void dl_cleanup(void)
{
- struct dyn_elf *d;
- for (d = _dl_handles; d; d = d->next_handle) {
- do_dlclose(d, 1);
+ struct dyn_elf *h, *n;
+
+ for (h = _dl_handles; h; h = n) {
+ n = h->next_handle;
+ do_dlclose(h, 1);
}
}
+#endif
-void *dlopen(const char *libname, int flag)
+static ptrdiff_t _dl_build_local_scope (struct elf_resolve **list,
+ struct elf_resolve *map)
+{
+ struct elf_resolve **p = list;
+ struct init_fini_list *q;
+
+ *p++ = map;
+ map->init_flag |= DL_RESERVED;
+ if (map->init_fini)
+ for (q = map->init_fini; q; q = q->next)
+ if (! (q->tpnt->init_flag & DL_RESERVED))
+ p += _dl_build_local_scope (p, q->tpnt);
+ return p - list;
+}
+
+static void *do_dlopen(const char *libname, int flag, ElfW(Addr) from)
{
struct elf_resolve *tpnt, *tfrom;
struct dyn_elf *dyn_chain, *rpnt = NULL, *dyn_ptr, *relro_ptr, *handle;
- ElfW(Addr) from;
struct elf_resolve *tpnt1;
void (*dl_brk) (void);
int now_flag;
@@ -164,15 +305,20 @@ void *dlopen(const char *libname, int flag)
unsigned int nlist, i;
struct elf_resolve **init_fini_list;
static bool _dl_init;
+ struct elf_resolve **local_scope;
+#ifdef SHARED
+ struct r_scope_elem *ls;
+#endif
+#if defined(USE_TLS) && USE_TLS
+ bool any_tls = false;
+#endif
/* A bit of sanity checking... */
- if (!(flag & (RTLD_LAZY|RTLD_NOW))) {
+ if (!(flag & (RTLD_LAZY|RTLD_NOW|RTLD_NOLOAD))) {
_dl_error_number = LD_BAD_HANDLE;
return NULL;
}
- from = (ElfW(Addr)) __builtin_return_address(0);
-
if (!_dl_init) {
_dl_init = true;
_dl_malloc_function = malloc;
@@ -186,7 +332,7 @@ void *dlopen(const char *libname, int flag)
# ifdef __SUPPORT_LD_DEBUG__
_dl_debug = getenv("LD_DEBUG");
if (_dl_debug) {
- if (_dl_strstr(_dl_debug, "all")) {
+ if (strstr(_dl_debug, "all")) {
_dl_debug_detail = _dl_debug_move = _dl_debug_symbols
= _dl_debug_reloc = _dl_debug_bindings = _dl_debug_nofixups = (void*)1;
} else {
@@ -220,14 +366,15 @@ void *dlopen(const char *libname, int flag)
tfrom = tpnt;
}
}
- for (rpnt = _dl_symbol_tables; rpnt && rpnt->next; rpnt=rpnt->next);
+ for (rpnt = _dl_symbol_tables; rpnt && rpnt->next; rpnt = rpnt->next)
+ continue;
relro_ptr = rpnt;
now_flag = (flag & RTLD_NOW) ? RTLD_NOW : 0;
if (getenv("LD_BIND_NOW"))
now_flag = RTLD_NOW;
-#ifndef SHARED
+#if !defined SHARED && defined __LDSO_LD_LIBRARY_PATH__
/* When statically linked, the _dl_library_path is not yet initialized */
_dl_library_path = getenv("LD_LIBRARY_PATH");
#endif
@@ -235,16 +382,16 @@ void *dlopen(const char *libname, int flag)
/* Try to load the specified library */
_dl_if_debug_print("Trying to dlopen '%s', RTLD_GLOBAL:%d RTLD_NOW:%d\n",
(char*)libname, (flag & RTLD_GLOBAL ? 1:0), (now_flag & RTLD_NOW ? 1:0));
- tpnt = _dl_load_shared_library(0, &rpnt, tfrom, (char*)libname, 0);
+ tpnt = _dl_load_shared_library(flag & (RTLD_NOLOAD | RTLD_GLOBAL | RTLD_NODELETE),
+ &rpnt, tfrom, (char*)libname, 0);
if (tpnt == NULL) {
_dl_unmap_cache();
return NULL;
}
dyn_chain = (struct dyn_elf *) malloc(sizeof(struct dyn_elf));
- _dl_memset(dyn_chain, 0, sizeof(struct dyn_elf));
+ memset(dyn_chain, 0, sizeof(struct dyn_elf));
dyn_chain->dyn = tpnt;
- tpnt->rtld_flags |= (flag & RTLD_GLOBAL);
dyn_chain->next_handle = _dl_handles;
_dl_handles = dyn_ptr = dyn_chain;
@@ -257,24 +404,23 @@ void *dlopen(const char *libname, int flag)
dyn_chain->init_fini.init_fini = handle->init_fini.init_fini;
dyn_chain->init_fini.nlist = handle->init_fini.nlist;
for (i = 0; i < dyn_chain->init_fini.nlist; i++)
- dyn_chain->init_fini.init_fini[i]->rtld_flags |= (flag & RTLD_GLOBAL);
+ dyn_chain->init_fini.init_fini[i]->rtld_flags |= (flag & (RTLD_GLOBAL|RTLD_NODELETE));
dyn_chain->next = handle->next;
break;
}
}
return dyn_chain;
- } else {
- tpnt->init_flag |= DL_OPENED;
}
+ tpnt->init_flag |= DL_OPENED;
+
_dl_if_debug_print("Looking for needed libraries\n");
nlist = 0;
runp = alloca(sizeof(*runp));
runp->tpnt = tpnt;
runp->next = NULL;
dep_list = runp2 = runp;
- for (; runp; runp = runp->next)
- {
+ for (; runp; runp = runp->next) {
ElfW(Dyn) *dpnt;
char *lpntstr;
@@ -286,15 +432,14 @@ void *dlopen(const char *libname, int flag)
dpnt->d_un.d_val);
_dl_if_debug_print("Trying to load '%s', needed by '%s'\n",
lpntstr, runp->tpnt->libname);
- tpnt1 = _dl_load_shared_library(0, &rpnt, runp->tpnt, lpntstr, 0);
+ tpnt1 = _dl_load_shared_library(flag & (RTLD_GLOBAL | RTLD_NODELETE),
+ &rpnt, runp->tpnt, lpntstr, 0);
if (!tpnt1)
goto oops;
- tpnt1->rtld_flags |= (flag & RTLD_GLOBAL);
-
/* This list is for dlsym() and relocation */
dyn_ptr->next = (struct dyn_elf *) malloc(sizeof(struct dyn_elf));
- _dl_memset (dyn_ptr->next, 0, sizeof (struct dyn_elf));
+ memset (dyn_ptr->next, 0, sizeof (struct dyn_elf));
dyn_ptr = dyn_ptr->next;
dyn_ptr->dyn = tpnt1;
/* Used to record RTLD_LOCAL scope */
@@ -336,6 +481,23 @@ void *dlopen(const char *libname, int flag)
}
}
+ /* Build the local scope for the dynamically loaded modules. */
+ local_scope = _dl_malloc(nlist * sizeof(struct elf_resolve *)); /* Could it allocated on stack? */
+ for (i = 0; i < nlist; i++)
+ if (init_fini_list[i]->symbol_scope.r_nlist == 0) {
+ int k, cnt;
+ cnt = _dl_build_local_scope(local_scope, init_fini_list[i]);
+ init_fini_list[i]->symbol_scope.r_list = _dl_malloc(cnt * sizeof(struct elf_resolve *));
+ init_fini_list[i]->symbol_scope.r_nlist = cnt;
+ _dl_memcpy (init_fini_list[i]->symbol_scope.r_list, local_scope,
+ cnt * sizeof (struct elf_resolve *));
+ /* Restoring the init_flag.*/
+ for (k = 0; k < nlist; k++)
+ init_fini_list[k]->init_flag &= ~DL_RESERVED;
+ }
+
+ _dl_free(local_scope);
+
/* Sort the INIT/FINI list in dependency order. */
for (runp2 = dep_list; runp2; runp2 = runp2->next) {
unsigned int j, k;
@@ -364,8 +526,8 @@ void *dlopen(const char *libname, int flag)
fprintf(stderr, "lib: %s has deps:\n", init_fini_list[i]->libname);
runp = init_fini_list[i]->init_fini;
for (; runp; runp = runp->next)
- printf(" %s ", runp->tpnt->libname);
- printf("\n");
+ fprintf(stderr, " %s ", runp->tpnt->libname);
+ fprintf(stderr, "\n");
}
}
#endif
@@ -376,6 +538,19 @@ void *dlopen(const char *libname, int flag)
* Now we go through and look for REL and RELA records that indicate fixups
* to the GOT tables. We need to do this in reverse order so that COPY
* directives work correctly */
+
+#ifdef SHARED
+ /*
+ * Get the tail of the list.
+ * In the static case doesn't need to extend the global scope, it is
+ * ready to be used as it is, because _dl_loaded_modules already points
+ * to the dlopened library.
+ */
+ for (ls = &_dl_loaded_modules->symbol_scope; ls && ls->next; ls = ls->next);
+
+ /* Extend the global scope by adding the local scope of the dlopened DSO. */
+ ls->next = &dyn_chain->dyn->symbol_scope;
+#endif
#ifdef __mips__
/*
* Relocation of the GOT entries for MIPS have to be done
@@ -384,7 +559,7 @@ void *dlopen(const char *libname, int flag)
_dl_perform_mips_global_got_relocations(tpnt, !now_flag);
#endif
- if (_dl_fixup(dyn_chain, now_flag))
+ if (_dl_fixup(dyn_chain, &_dl_loaded_modules->symbol_scope, now_flag))
goto oops;
if (relro_ptr) {
@@ -396,6 +571,51 @@ void *dlopen(const char *libname, int flag)
/* TODO: Should we set the protections of all pages back to R/O now ? */
+#if defined(USE_TLS) && USE_TLS
+
+ for (i=0; i < nlist; i++) {
+ struct elf_resolve *tmp_tpnt = init_fini_list[i];
+ /* Only add TLS memory if this object is loaded now and
+ therefore is not yet initialized. */
+
+ if (!(tmp_tpnt->init_flag & INIT_FUNCS_CALLED)
+ /* Only if the module defines thread local data. */
+ && __builtin_expect (tmp_tpnt->l_tls_blocksize > 0, 0)) {
+
+ /* Now that we know the object is loaded successfully add
+ modules containing TLS data to the slot info table. We
+ might have to increase its size. */
+ _dl_add_to_slotinfo ((struct link_map*)tmp_tpnt);
+
+ /* It is the case in which we couldn't perform TLS static
+ initialization at relocation time, and we delayed it until
+ the relocation has been completed. */
+
+ if (tmp_tpnt->l_need_tls_init) {
+ tmp_tpnt->l_need_tls_init = 0;
+# ifdef SHARED
+ /* Update the slot information data for at least the
+ generation of the DSO we are allocating data for. */
+ _dl_update_slotinfo (tmp_tpnt->l_tls_modid);
+# endif
+
+ _dl_init_static_tls((struct link_map*)tmp_tpnt);
+ _dl_assert (tmp_tpnt->l_need_tls_init == 0);
+ }
+
+ /* We have to bump the generation counter. */
+ any_tls = true;
+ }
+ }
+
+ /* Bump the generation number if necessary. */
+ if (any_tls && __builtin_expect (++_dl_tls_generation == 0, 0)) {
+ _dl_debug_early("TLS generation counter wrapped! Please report this.");
+ _dl_exit(30);
+ }
+
+#endif
+
/* Notify the debugger we have added some objects. */
if (_dl_debug_addr) {
dl_brk = (void (*)(void)) _dl_debug_addr->r_brk;
@@ -438,23 +658,36 @@ oops:
return NULL;
}
-void *dlsym(void *vhandle, const char *name)
+void *dlopen(const char *libname, int flag)
+{
+ void *ret;
+
+ __UCLIBC_MUTEX_CONDITIONAL_LOCK(_dl_mutex, 1);
+ ret = do_dlopen(libname, flag,
+ (ElfW(Addr)) __builtin_return_address(0));
+ __UCLIBC_MUTEX_CONDITIONAL_UNLOCK(_dl_mutex, 1);
+
+ return ret;
+}
+
+static void *do_dlsym(void *vhandle, const char *name, void *caller_address)
{
struct elf_resolve *tpnt, *tfrom;
struct dyn_elf *handle;
- ElfW(Addr) from;
+ ElfW(Addr) from = 0;
struct dyn_elf *rpnt;
void *ret;
+ struct symbol_ref sym_ref = { NULL, NULL };
/* Nastiness to support underscore prefixes. */
#ifdef __UCLIBC_UNDERSCORES__
char tmp_buf[80];
char *name2 = tmp_buf;
size_t nlen = strlen (name) + 1;
if (nlen + 1 > sizeof (tmp_buf))
- name2 = malloc (nlen + 1);
+ name2 = malloc (nlen + 1);
if (name2 == 0) {
- _dl_error_number = LD_ERROR_MMAP_FAILED;
- return 0;
+ _dl_error_number = LD_ERROR_MMAP_FAILED;
+ return 0;
}
name2[0] = '_';
memcpy (name2 + 1, name, nlen);
@@ -485,7 +718,7 @@ void *dlsym(void *vhandle, const char *name)
* dynamic loader itself, as it doesn't know
* how to properly treat it.
*/
- from = (ElfW(Addr)) __builtin_return_address(0);
+ from = (ElfW(Addr)) caller_address;
tfrom = NULL;
for (rpnt = _dl_symbol_tables; rpnt; rpnt = rpnt->next) {
@@ -498,8 +731,22 @@ void *dlsym(void *vhandle, const char *name)
}
tpnt = NULL;
if (handle == _dl_symbol_tables)
- tpnt = handle->dyn; /* Only search RTLD_GLOBAL objs if global object */
- ret = _dl_find_hash(name2, handle, tpnt, ELF_RTYPE_CLASS_DLSYM);
+ tpnt = handle->dyn; /* Only search RTLD_GLOBAL objs if global object */
+
+ do {
+ ret = _dl_find_hash(name2, &handle->dyn->symbol_scope, tpnt, ELF_RTYPE_CLASS_DLSYM, &sym_ref);
+ if (ret != NULL)
+ break;
+ handle = handle->next;
+ } while (from && handle);
+
+#if defined(USE_TLS) && USE_TLS && defined SHARED
+ if (sym_ref.sym && (ELF_ST_TYPE(sym_ref.sym->st_info) == STT_TLS) && (sym_ref.tpnt)) {
+ /* The found symbol is a thread-local storage variable.
+ Return its address for the current thread. */
+ ret = _dl_tls_symaddr ((struct link_map *)sym_ref.tpnt, (Elf32_Addr)ret);
+ }
+#endif
/*
* Nothing found.
@@ -514,6 +761,17 @@ out:
return ret;
}
+void *dlsym(void *vhandle, const char *name)
+{
+ void *ret;
+
+ __UCLIBC_MUTEX_CONDITIONAL_LOCK(_dl_mutex, 1);
+ ret = do_dlsym(vhandle, name, __builtin_return_address(0));
+ __UCLIBC_MUTEX_CONDITIONAL_UNLOCK(_dl_mutex, 1);
+
+ return ret;
+}
+
#if 0
void *dlvsym(void *vhandle, const char *name, const char *version)
{
@@ -530,8 +788,17 @@ static int do_dlclose(void *vhandle, int need_fini)
int (*dl_elf_fini) (void);
void (*dl_brk) (void);
struct dyn_elf *handle;
- unsigned int end;
+ unsigned int end = 0, start = 0xffffffff;
unsigned int i, j;
+ struct r_scope_elem *ls, *ls_next = NULL;
+ struct elf_resolve **handle_rlist;
+
+#if defined(USE_TLS) && USE_TLS
+ bool any_tls = false;
+ size_t tls_free_start = NO_TLS_OFFSET;
+ size_t tls_free_end = NO_TLS_OFFSET;
+ struct link_map *tls_lmap;
+#endif
handle = (struct dyn_elf *) vhandle;
if (handle == _dl_symbol_tables)
@@ -553,19 +820,34 @@ static int do_dlclose(void *vhandle, int need_fini)
_dl_handles = rpnt->next_handle;
_dl_if_debug_print("%s: usage count: %d\n",
handle->dyn->libname, handle->dyn->usage_count);
- if (handle->dyn->usage_count != 1) {
+ if (handle->dyn->usage_count != 1 || (handle->dyn->rtld_flags & RTLD_NODELETE)) {
handle->dyn->usage_count--;
free(handle);
return 0;
}
+
+ /* Store the handle's local scope array for later removal */
+ handle_rlist = handle->dyn->symbol_scope.r_list;
+
+ /* Store references to the local scope entries for later removal */
+ for (ls = &_dl_loaded_modules->symbol_scope; ls && ls->next; ls = ls->next)
+ if (ls->next->r_list[0] == handle->dyn) {
+ break;
+ }
+ /* ls points to the previous local symbol scope */
+ if(ls && ls->next)
+ ls_next = ls->next->next;
+
/* OK, this is a valid handle - now close out the file */
for (j = 0; j < handle->init_fini.nlist; ++j) {
tpnt = handle->init_fini.init_fini[j];
- if (--tpnt->usage_count == 0) {
+ tpnt->usage_count--;
+ if (tpnt->usage_count == 0 && !(tpnt->rtld_flags & RTLD_NODELETE)) {
if ((tpnt->dynamic_info[DT_FINI]
|| tpnt->dynamic_info[DT_FINI_ARRAY])
- && need_fini &&
- !(tpnt->init_flag & FINI_FUNCS_CALLED)) {
+ && need_fini
+ && !(tpnt->init_flag & FINI_FUNCS_CALLED)
+ ) {
tpnt->init_flag |= FINI_FUNCS_CALLED;
_dl_run_fini_array(tpnt);
@@ -583,10 +865,117 @@ static int do_dlclose(void *vhandle, int need_fini)
i < tpnt->n_phent; ppnt++, i++) {
if (ppnt->p_type != PT_LOAD)
continue;
+ if (ppnt->p_vaddr < start)
+ start = ppnt->p_vaddr;
if (end < ppnt->p_vaddr + ppnt->p_memsz)
end = ppnt->p_vaddr + ppnt->p_memsz;
}
- DL_LIB_UNMAP (tpnt, end);
+
+#if defined(USE_TLS) && USE_TLS
+ /* Do the cast to make things easy. */
+ tls_lmap = (struct link_map *) tpnt;
+
+ /* Remove the object from the dtv slotinfo array if it uses TLS. */
+ if (__builtin_expect (tls_lmap->l_tls_blocksize > 0, 0)) {
+ any_tls = true;
+
+ if (_dl_tls_dtv_slotinfo_list != NULL
+ && ! remove_slotinfo (tls_lmap->l_tls_modid,
+ _dl_tls_dtv_slotinfo_list, 0,
+ (tpnt->init_flag & INIT_FUNCS_CALLED)))
+ /* All dynamically loaded modules with TLS are unloaded. */
+ _dl_tls_max_dtv_idx = _dl_tls_static_nelem;
+
+ if (tls_lmap->l_tls_offset != NO_TLS_OFFSET) {
+ /*
+ * Collect a contiguous chunk built from the objects in
+ * this search list, going in either direction. When the
+ * whole chunk is at the end of the used area then we can
+ * reclaim it.
+ */
+# if defined(TLS_TCB_AT_TP)
+ if (tls_free_start == NO_TLS_OFFSET
+ || (size_t) tls_lmap->l_tls_offset == tls_free_start) {
+ /* Extend the contiguous chunk being reclaimed. */
+ tls_free_start
+ = tls_lmap->l_tls_offset -
+ tls_lmap->l_tls_blocksize;
+
+ if (tls_free_end == NO_TLS_OFFSET)
+ tls_free_end = tls_lmap->l_tls_offset;
+ } else if (tls_lmap->l_tls_offset - tls_lmap->l_tls_blocksize
+ == tls_free_end)
+ /* Extend the chunk backwards. */
+ tls_free_end = tls_lmap->l_tls_offset;
+ else {
+ /*
+ * This isn't contiguous with the last chunk freed.
+ * One of them will be leaked unless we can free
+ * one block right away.
+ */
+ if (tls_free_end == _dl_tls_static_used) {
+ _dl_tls_static_used = tls_free_start;
+ tls_free_end = tls_lmap->l_tls_offset;
+ tls_free_start
+ = tls_free_end - tls_lmap->l_tls_blocksize;
+ } else if ((size_t) tls_lmap->l_tls_offset
+ == _dl_tls_static_used)
+ _dl_tls_static_used = tls_lmap->l_tls_offset -
+ tls_lmap->l_tls_blocksize;
+ else if (tls_free_end < (size_t) tls_lmap->l_tls_offset) {
+ /*
+ * We pick the later block. It has a chance
+ * to be freed.
+ */
+ tls_free_end = tls_lmap->l_tls_offset;
+ tls_free_start = tls_free_end -
+ tls_lmap->l_tls_blocksize;
+ }
+ }
+# elif defined(TLS_DTV_AT_TP)
+ if ((size_t) tls_lmap->l_tls_offset == tls_free_end)
+ /* Extend the contiguous chunk being reclaimed. */
+ tls_free_end -= tls_lmap->l_tls_blocksize;
+ else if (tls_lmap->l_tls_offset + tls_lmap->l_tls_blocksize
+ == tls_free_start)
+ /* Extend the chunk backwards. */
+ tls_free_start = tls_lmap->l_tls_offset;
+ else {
+ /*
+ * This isn't contiguous with the last chunk
+ * freed. One of them will be leaked.
+ */
+ if (tls_free_end == _dl_tls_static_used)
+ _dl_tls_static_used = tls_free_start;
+ tls_free_start = tls_lmap->l_tls_offset;
+ tls_free_end = tls_free_start +
+ tls_lmap->l_tls_blocksize;
+ }
+# else
+# error Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined
+# endif
+ } else {
+
+#define TLS_DTV_UNALLOCATED ((void *) -1l)
+
+ dtv_t *dtv = THREAD_DTV ();
+
+ if (!(dtv[tls_lmap->l_tls_modid].pointer.is_static) &&
+ dtv[tls_lmap->l_tls_modid].pointer.val != TLS_DTV_UNALLOCATED) {
+ /* Note that free is called for NULL is well. We
+ deallocate even if it is this dtv entry we are
+ supposed to load. The reason is that we call
+ memalign and not malloc. */
+ _dl_free (dtv[tls_lmap->l_tls_modid].pointer.val);
+ dtv[tls_lmap->l_tls_modid].pointer.val = TLS_DTV_UNALLOCATED;
+ }
+ }
+ }
+#endif
+
+ end = (end + ADDR_ALIGN) & PAGE_ALIGN;
+ start = start & ~ADDR_ALIGN;
+ DL_LIB_UNMAP (tpnt, end - start);
/* Free elements in RTLD_LOCAL scope list */
for (runp = tpnt->rtld_local; runp; runp = tmp) {
tmp = runp->next;
@@ -598,8 +987,8 @@ static int do_dlclose(void *vhandle, int need_fini)
_dl_loaded_modules = tpnt->next;
if (_dl_loaded_modules)
_dl_loaded_modules->prev = 0;
- } else
- for (run_tpnt = _dl_loaded_modules; run_tpnt; run_tpnt = run_tpnt->next)
+ } else {
+ for (run_tpnt = _dl_loaded_modules; run_tpnt; run_tpnt = run_tpnt->next) {
if (run_tpnt->next == tpnt) {
_dl_if_debug_print("removing loaded_modules: %s\n", tpnt->libname);
run_tpnt->next = run_tpnt->next->next;
@@ -607,6 +996,8 @@ static int do_dlclose(void *vhandle, int need_fini)
run_tpnt->next->prev = run_tpnt;
break;
}
+ }
+ }
/* Next, remove tpnt from the global symbol table list */
if (_dl_symbol_tables) {
@@ -614,7 +1005,7 @@ static int do_dlclose(void *vhandle, int need_fini)
_dl_symbol_tables = _dl_symbol_tables->next;
if (_dl_symbol_tables)
_dl_symbol_tables->prev = 0;
- } else
+ } else {
for (rpnt1 = _dl_symbol_tables; rpnt1->next; rpnt1 = rpnt1->next) {
if (rpnt1->next->dyn == tpnt) {
_dl_if_debug_print("removing symbol_tables: %s\n", tpnt->libname);
@@ -626,14 +1017,38 @@ static int do_dlclose(void *vhandle, int need_fini)
break;
}
}
+ }
}
free(tpnt->libname);
+ if (handle->dyn != tpnt)
+ free(tpnt->symbol_scope.r_list);
free(tpnt);
}
}
+ /* Unlink and release the handle's local scope from global one */
+ if(ls)
+ ls->next = ls_next;
+ free(handle_rlist);
+
+ for (rpnt1 = handle->next; rpnt1; rpnt1 = rpnt1_tmp) {
+ rpnt1_tmp = rpnt1->next;
+ free(rpnt1);
+ }
free(handle->init_fini.init_fini);
free(handle);
+#if defined(USE_TLS) && USE_TLS
+ /* If we removed any object which uses TLS bump the generation counter. */
+ if (any_tls) {
+ if (__builtin_expect(++_dl_tls_generation == 0, 0)) {
+ _dl_debug_early("TLS generation counter wrapped! Please report to the uClibc mailing list.\n");
+ _dl_exit(30);
+ }
+
+ if (tls_free_end == _dl_tls_static_used)
+ _dl_tls_static_used = tls_free_start;
+ }
+#endif
if (_dl_debug_addr) {
dl_brk = (void (*)(void)) _dl_debug_addr->r_brk;
@@ -651,7 +1066,13 @@ static int do_dlclose(void *vhandle, int need_fini)
int dlclose(void *vhandle)
{
- return do_dlclose(vhandle, 1);
+ int ret;
+
+ __UCLIBC_MUTEX_CONDITIONAL_LOCK(_dl_mutex, 1);
+ ret = do_dlclose(vhandle, 1);
+ __UCLIBC_MUTEX_CONDITIONAL_UNLOCK(_dl_mutex, 1);
+
+ return ret;
}
char *dlerror(void)
@@ -669,8 +1090,10 @@ char *dlerror(void)
* Dump information to stderr about the current loaded modules
*/
#ifdef __USE_GNU
-static char *type[] = { "Lib", "Exe", "Int", "Mod" };
+# if 0
+static const char type[][4] = { "Lib", "Exe", "Int", "Mod" };
+/* reimplement this, being a GNU extension it should be the same as on glibc */
int dlinfo(void)
{
struct elf_resolve *tpnt;
@@ -697,8 +1120,9 @@ int dlinfo(void)
}
return 0;
}
+#endif
-int dladdr(const void *__address, Dl_info * __info)
+static int do_dladdr(const void *__address, Dl_info * __info)
{
struct elf_resolve *pelf;
struct elf_resolve *rpnt;
@@ -761,7 +1185,11 @@ int dladdr(const void *__address, Dl_info * __info)
ElfW(Addr) symbol_addr;
symbol_addr = (ElfW(Addr)) DL_RELOC_ADDR(pelf->loadaddr, symtab[si].st_value);
- if (symbol_addr <= (ElfW(Addr))__address && (!sf || sa < symbol_addr)) {
+ if ((symtab[si].st_shndx != SHN_UNDEF
+ || symtab[si].st_value != 0)
+ && ELF_ST_TYPE(symtab[si].st_info) != STT_TLS
+ && DL_ADDR_SYM_MATCH(symbol_addr, &symtab[si], sa,
+ (ElfW(Addr)) __address)) {
sa = symbol_addr;
sn = si;
sf = 1;
@@ -777,7 +1205,11 @@ int dladdr(const void *__address, Dl_info * __info)
ElfW(Addr) symbol_addr;
symbol_addr = (ElfW(Addr)) DL_RELOC_ADDR(pelf->loadaddr, symtab[si].st_value);
- if (symbol_addr <= (ElfW(Addr))__address && (!sf || sa < symbol_addr)) {
+ if ((symtab[si].st_shndx != SHN_UNDEF
+ || symtab[si].st_value != 0)
+ && ELF_ST_TYPE(symtab[si].st_info) != STT_TLS
+ && DL_ADDR_SYM_MATCH(symbol_addr, &symtab[si], sa,
+ (ElfW(Addr)) __address)) {
sa = symbol_addr;
sn = si;
sf = 1;
@@ -802,3 +1234,14 @@ int dladdr(const void *__address, Dl_info * __info)
}
}
#endif
+
+int dladdr(const void *__address, Dl_info * __info)
+{
+ int ret;
+
+ __UCLIBC_MUTEX_CONDITIONAL_LOCK(_dl_mutex, 1);
+ ret = do_dladdr(__address, __info);
+ __UCLIBC_MUTEX_CONDITIONAL_UNLOCK(_dl_mutex, 1);
+
+ return ret;
+}
diff --git a/ldso/man/dlopen.3 b/ldso/man/dlopen.3
index 8d1e09e71..0907aed9c 100644
--- a/ldso/man/dlopen.3
+++ b/ldso/man/dlopen.3
@@ -19,9 +19,8 @@
.\" GNU General Public License for more details.
.\"
.\" You should have received a copy of the GNU General Public
-.\" License along with this manual; if not, write to the Free
-.\" Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
-.\" USA.
+.\" License along with this manual; if not, see
+.\" <http://www.gnu.org/licenses/>.
.\"
.TH DLOPEN 3 "16 May 1995" "Linux" "Linux Programmer's Manual"
.SH NAME
diff --git a/libc/.gitignore b/libc/.gitignore
new file mode 100644
index 000000000..f4c03059d
--- /dev/null
+++ b/libc/.gitignore
@@ -0,0 +1 @@
+ucontext_i.[chs]
diff --git a/libc/Makefile.in b/libc/Makefile.in
index be5046da8..2abc77dce 100644
--- a/libc/Makefile.in
+++ b/libc/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.
#
@@ -15,11 +15,12 @@ ifneq ($(VERSION_SCRIPT),)
VERSION_SCRIPT := -Wl,--version-script,$(VERSION_SCRIPT)
endif
+CFLAGS-libc :=# intentionally left blank
+LDFLAGS-$(UCLIBC_FORMAT_DSBT_ELF)-libc.so := -Wl,--dsbt-index=2
LDFLAGS-libc.so := $(LDFLAGS) $(VERSION_SCRIPT) -Wl,-init,$(SYMBOL_PREFIX)__uClibc_init
-
LIBS-libc.so := $(interp) $(ldso) $(top_builddir)lib/$(NONSHARED_LIBNAME)
-# we have SHARED_MAJORNAME=libc.so.$(MAJOR_VERSION) defined in Rules.mak
+# we have SHARED_LIBNAME=libc.so.$(ABI_VERSION) defined in Rules.mak
libc_FULL_NAME := libuClibc-$(VERSION).so
# this comes first, so duplicate removal works correctly
@@ -52,25 +53,26 @@ endif
lib-a-y += $(top_builddir)lib/libc.a
lib-gdb-y += $(top_builddir)lib/libc.gdb
lib-so-y += $(libc.depend)
-objclean-y += libc_clean
+objclean-y += CLEAN_libc
-OUTPUT_FORMAT = $(CC) $(CFLAGS) -Wl,--verbose 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/OUTPUT_FORMAT ( \1 )/p'
+OUTPUT_FORMAT = $(CC) $(CFLAGS) -Wl,--verbose 2>&1 | $(SED) -n '/OUTPUT_FORMAT/,/)/p'
ifeq ($(DOMULTI),n)
$(libc.depend): $(libc_OUT)/libc_so.a $(LIBS-libc.so)
- $(call link.so,$(libc_FULL_NAME),$(MAJOR_VERSION))
+ $(call link.so,$(libc_FULL_NAME),$(ABI_VERSION))
else
$(libc.depend): $(libc_OUT)/libc.oS $(libc-nomulti-y:.o=.oS) | $(LIBS-libc.so)
- $(call linkm.so,$(libc_FULL_NAME),$(MAJOR_VERSION))
+ $(call linkm.so,$(libc_FULL_NAME),$(ABI_VERSION))
endif
$(Q)$(RM) $@
- $(Q)cp $(top_srcdir)extra/scripts/format.lds $@
- $(Q)echo "$(shell $(OUTPUT_FORMAT))" >> $@
+ $(Q)cat $(top_srcdir)extra/scripts/format.lds > $@.tmp
+ $(Q)$(OUTPUT_FORMAT) >> $@.tmp
ifeq ($(COMPAT_ATEXIT),y)
- $(Q)echo "GROUP ( $(NONSHARED_LIBNAME) $(SHARED_MAJORNAME) $(ASNEEDED) )" >> $@
+ $(Q)echo "GROUP ( $(NONSHARED_LIBNAME) $(SHARED_LIBNAME) $(ASNEEDED) )" >> $@.tmp
else
- $(Q)echo "GROUP ( $(SHARED_MAJORNAME) $(NONSHARED_LIBNAME) $(ASNEEDED) )" >> $@
+ $(Q)echo "GROUP ( $(SHARED_LIBNAME) $(NONSHARED_LIBNAME) $(ASNEEDED) )" >> $@.tmp
endif
+ $(Q)mv $@.tmp $@
$(libc_OUT)/libc_so.a: $(libc-so-y) | $(top_builddir)lib/libc.a $(top_builddir)lib/$(NONSHARED_LIBNAME)
$(Q)$(RM) $@
@@ -85,8 +87,7 @@ $(libc_OUT)/libc.oS: $(libc-multi-y) | $(top_builddir)lib/libc.a $(top_builddir)
$(Q)$(RM) $@
$(compile-m)
-$(top_builddir)lib/libc.a: $(libc-a-y) | $(crt-y)
- $(Q)$(INSTALL) -d $(dir $@)
+$(top_builddir)lib/libc.a: $(libc-a-y)
$(Q)$(RM) $@
$(do_ar)
@@ -96,5 +97,5 @@ $(top_builddir)lib/libc.a: $(libc-a-y) | $(crt-y)
$(top_builddir)lib/libc.gdb: $(libc_OUT)/libc_so.a $(LINK_FLAT_CRTS)
$(call link-flat.so,$(@:.gdb=),$(UCLIBC_SHARED_FLAT_ID))
-libc_clean:
- $(RM) $(libc_OUT)/*.{o,os,oS,a}
+CLEAN_libc:
+ $(do_rm) $(addprefix $(libc_OUT)/*., o os oS a)
diff --git a/libc/inet/Makefile.in b/libc/inet/Makefile.in
index 493041ff6..3bfe4b29e 100644
--- a/libc/inet/Makefile.in
+++ b/libc/inet/Makefile.in
@@ -1,63 +1,66 @@
# 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.
#
+subdirs += libc/inet
+
include $(top_srcdir)libc/inet/rpc/Makefile.in
INET_DIR := $(top_srcdir)libc/inet
INET_OUT := $(top_builddir)libc/inet
+V4_OR_V6 := $(findstring y,$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6))
-CSRC :=
-ifneq ($(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6),)
-CSRC += getservice.c getproto.c hostid.c getnetent.c getnetbynm.c getnetbyad.c \
+CFLAGS-y-libc/inet := -DRESOLVER="\"resolv.c\""
+CSRC-y :=
+# des uses ntohl
+CSRC-$(findstring y,$(UCLIBC_HAS_CRYPT_IMPL)$(V4_OR_V6)) += ntohl.c
+CSRC-$(V4_OR_V6) += \
+ getservice.c getproto.c getnet.c hostid.c \
inet_net.c herror.c if_index.c gai_strerror.c getaddrinfo.c \
- ether_addr.c ntohl.c ifaddrs.c ntop.c
-endif
-ifeq ($(UCLIBC_HAS_IPV6),y)
-CSRC += in6_addr.c
-endif
-
+ ifaddrs.c ntop.c
+CSRC-$(UCLIBC_HAS_IPV6) += in6_addr.c
# multi source addr.c
-addr_CSRC := inet_aton.c inet_addr.c inet_ntoa.c inet_makeaddr.c \
+CSRC-$(V4_OR_V6) += \
+ inet_aton.c inet_addr.c inet_ntoa.c inet_makeaddr.c \
inet_lnaof.c inet_netof.c
-ifneq ($(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6),)
-CSRC += $(addr_CSRC)
-endif
-
# multi source resolv.c
-resolv_CSRC += encodeh.c decodeh.c encoded.c decoded.c lengthd.c encodeq.c \
- decodeq.c lengthq.c encodea.c decodea.c \
- dnslookup.c resolveaddress.c opennameservers.c \
- closenameservers.c resolvename.c gethostbyname.c res_init.c \
- res_query.c gethostbyaddr.c read_etc_hosts_r.c get_hosts_byname_r.c \
- get_hosts_byaddr_r.c gethostbyname2.c getnameinfo.c gethostent.c \
- gethostbyname_r.c gethostbyname2_r.c gethostbyaddr_r.c \
- res_comp.c ns_name.c ethers.c
-ifneq ($(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6),)
-CSRC += $(resolv_CSRC)
-
-# unused ATM
-CSRC += encodep.c decodep.c formquery.c
-endif
-
+CSRC-$(V4_OR_V6) += \
+ encodeh.c decodeh.c encoded.c decoded.c \
+ encodeq.c encodea.c \
+ read_etc_hosts_r.c \
+ dnslookup.c opennameservers.c closenameservers.c \
+ getnameinfo.c \
+ gethostent.c gethostent_r.c
+CSRC-$(V4_OR_V6) += \
+ get_hosts_byaddr_r.c get_hosts_byname_r.c \
+ gethostbyaddr_r.c gethostbyname_r.c gethostbyname2_r.c \
+ gethostbyaddr.c gethostbyname.c gethostbyname2.c
+CSRC-$(UCLIBC_HAS_RESOLVER_SUPPORT) += \
+ ns_netint.c ns_parse.c res_data.c \
+ res_init.c res_query.c res_comp.c ns_name.c \
+ _res_state.c
+## # unused ATM
+## CSRC-y += encodep.c decodep.c formquery.c
# multi source socketcalls.c
-socketcalls_CSRC += accept.c bind.c connect.c getpeername.c getsockname.c \
+socketcalls_CSRC-y += \
+ accept.c bind.c connect.c getpeername.c getsockname.c \
getsockopt.c listen.c recv.c recvfrom.c recvmsg.c send.c sendmsg.c \
sendto.c setsockopt.c shutdown.c socket.c socketpair.c
-ifeq ($(UCLIBC_HAS_SOCKET),y)
-CSRC += $(socketcalls_CSRC) opensock.c
-endif
+socketcalls_CSRC-$(UCLIBC_LINUX_SPECIFIC) += accept4.c
+CSRC-$(UCLIBC_HAS_SOCKET) += $(socketcalls_CSRC-y) opensock.c
+
+CSRC-$(findstring y,$(UCLIBC_HAS_SOCKET)$(V4_OR_V6)) += ethers.c ether_addr.c
-INET_SRC := $(patsubst %.c,$(INET_DIR)/%.c,$(CSRC))
-INET_OBJ := $(patsubst %.c,$(INET_OUT)/%.o,$(CSRC))
+INET_SRC := $(patsubst %.c,$(INET_DIR)/%.c,$(CSRC-y))
+INET_OBJ := $(patsubst %.c,$(INET_OUT)/%.o,$(CSRC-y))
libc-y += $(INET_OBJ)
-objclean-y += inet_objclean
+objclean-y += CLEAN_libc/inet
-inet_objclean:
- $(RM) $(INET_OUT)/*.{o,os}
+CLEAN_libc/inet:
+ $(do_rm) $(addprefix $(INET_OUT)/*., o os)
diff --git a/libc/inet/_res_state.c b/libc/inet/_res_state.c
new file mode 100644
index 000000000..dc0d89f40
--- /dev/null
+++ b/libc/inet/_res_state.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2006 Steven J. Hill <sjhill@realitydiluted.com>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_res_state
+#include RESOLVER
diff --git a/libc/inet/resolveaddress.c b/libc/inet/accept4.c
index d57366c98..e2fdd6c2f 100644
--- a/libc/inet/resolveaddress.c
+++ b/libc/inet/accept4.c
@@ -4,5 +4,5 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define L_resolveaddress
-#include "resolv.c"
+#define L_accept4
+#include "socketcalls.c"
diff --git a/libc/inet/addr.c b/libc/inet/addr.c
index 2a0bb84a8..cd7151a45 100644
--- a/libc/inet/addr.c
+++ b/libc/inet/addr.c
@@ -17,8 +17,6 @@
* Changed to use _int10tostr.
*/
-#define __FORCE_GLIBC
-#include <features.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
@@ -43,12 +41,6 @@
* leading 0 -> octal
* all else -> decimal
*/
-#ifdef __UCLIBC_HAS_XLOCALE__
-libc_hidden_proto(__ctype_b_loc)
-#elif defined __UCLIBC_HAS_CTYPE_TABLES__
-libc_hidden_proto(__ctype_b)
-#endif
-libc_hidden_proto(inet_aton)
int inet_aton(const char *cp, struct in_addr *addrptr)
{
in_addr_t addr;
@@ -103,9 +95,7 @@ libc_hidden_def(inet_aton)
#endif
#ifdef L_inet_addr
-libc_hidden_proto(inet_aton)
-libc_hidden_proto(inet_addr)
in_addr_t inet_addr(const char *cp)
{
struct in_addr a;
@@ -122,8 +112,7 @@ libc_hidden_def(inet_addr)
#define INET_NTOA_MAX_LEN 16 /* max 12 digits + 3 '.'s + 1 nul */
-libc_hidden_proto(inet_ntoa_r)
-char *inet_ntoa_r(struct in_addr in, char buf[INET_NTOA_MAX_LEN])
+static char *__inet_ntoa_r(struct in_addr in, char buf[INET_NTOA_MAX_LEN])
{
in_addr_t addr = ntohl(in.s_addr);
int i;
@@ -142,13 +131,12 @@ char *inet_ntoa_r(struct in_addr in, char buf[INET_NTOA_MAX_LEN])
return p+1;
}
-libc_hidden_def(inet_ntoa_r)
+strong_alias(__inet_ntoa_r,inet_ntoa_r)
-libc_hidden_proto(inet_ntoa)
char *inet_ntoa(struct in_addr in)
{
static char buf[INET_NTOA_MAX_LEN];
- return inet_ntoa_r(in, buf);
+ return __inet_ntoa_r(in, buf);
}
libc_hidden_def(inet_ntoa)
#endif
@@ -156,27 +144,25 @@ libc_hidden_def(inet_ntoa)
#ifdef L_inet_makeaddr
/* for some reason it does not remove the jump relocation */
-/* Experimentally off - libc_hidden_proto(memmove) */
/*
* Formulate an Internet address from network + host. Used in
* building addresses stored in the ifnet structure.
*/
-libc_hidden_proto(inet_makeaddr)
struct in_addr inet_makeaddr(in_addr_t net, in_addr_t host)
{
- in_addr_t addr;
+ struct in_addr in;
if (net < 128)
- addr = (net << IN_CLASSA_NSHIFT) | (host & IN_CLASSA_HOST);
+ in.s_addr = (net << IN_CLASSA_NSHIFT) | (host & IN_CLASSA_HOST);
else if (net < 65536)
- addr = (net << IN_CLASSB_NSHIFT) | (host & IN_CLASSB_HOST);
+ in.s_addr = (net << IN_CLASSB_NSHIFT) | (host & IN_CLASSB_HOST);
else if (net < 16777216UL)
- addr = (net << IN_CLASSC_NSHIFT) | (host & IN_CLASSC_HOST);
+ in.s_addr = (net << IN_CLASSC_NSHIFT) | (host & IN_CLASSC_HOST);
else
- addr = net | host;
- addr = htonl(addr);
- return *(struct in_addr *)&addr;
+ in.s_addr = net | host;
+ in.s_addr = htonl(in.s_addr);
+ return in;
}
libc_hidden_def(inet_makeaddr)
#endif
@@ -206,7 +192,6 @@ in_addr_t inet_lnaof(struct in_addr in)
* Return the network number from an internet
* address; handles class a/b/c network #'s.
*/
-libc_hidden_proto(inet_netof)
in_addr_t
inet_netof(struct in_addr in)
{
diff --git a/libc/inet/closenameservers.c b/libc/inet/closenameservers.c
index ca4dae3fb..65889a79a 100644
--- a/libc/inet/closenameservers.c
+++ b/libc/inet/closenameservers.c
@@ -5,4 +5,4 @@
*/
#define L_closenameservers
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/decodea.c b/libc/inet/decodea.c
index 409a97843..112d5d9e0 100644
--- a/libc/inet/decodea.c
+++ b/libc/inet/decodea.c
@@ -5,4 +5,4 @@
*/
#define L_decodea
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/decoded.c b/libc/inet/decoded.c
index 73849ef5f..378cbfad7 100644
--- a/libc/inet/decoded.c
+++ b/libc/inet/decoded.c
@@ -5,4 +5,4 @@
*/
#define L_decoded
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/decodeh.c b/libc/inet/decodeh.c
index 86681fa88..7744287f6 100644
--- a/libc/inet/decodeh.c
+++ b/libc/inet/decodeh.c
@@ -5,4 +5,4 @@
*/
#define L_decodeh
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/decodep.c b/libc/inet/decodep.c
index 40b0bda0d..0e946e01f 100644
--- a/libc/inet/decodep.c
+++ b/libc/inet/decodep.c
@@ -5,4 +5,4 @@
*/
#define L_decodep
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/decodeq.c b/libc/inet/decodeq.c
index a6109677e..9e36b95d4 100644
--- a/libc/inet/decodeq.c
+++ b/libc/inet/decodeq.c
@@ -5,4 +5,4 @@
*/
#define L_decodeq
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/dnslookup.c b/libc/inet/dnslookup.c
index 4ffc34f0a..b9f59a2ff 100644
--- a/libc/inet/dnslookup.c
+++ b/libc/inet/dnslookup.c
@@ -5,4 +5,4 @@
*/
#define L_dnslookup
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/encodea.c b/libc/inet/encodea.c
index 628f9bad5..b42ee4a79 100644
--- a/libc/inet/encodea.c
+++ b/libc/inet/encodea.c
@@ -5,4 +5,4 @@
*/
#define L_encodea
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/encoded.c b/libc/inet/encoded.c
index d60618771..27f92becd 100644
--- a/libc/inet/encoded.c
+++ b/libc/inet/encoded.c
@@ -5,4 +5,4 @@
*/
#define L_encoded
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/encodeh.c b/libc/inet/encodeh.c
index 1d5488017..6a69a948b 100644
--- a/libc/inet/encodeh.c
+++ b/libc/inet/encodeh.c
@@ -5,4 +5,4 @@
*/
#define L_encodeh
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/encodep.c b/libc/inet/encodep.c
index d2f248b40..d298c2131 100644
--- a/libc/inet/encodep.c
+++ b/libc/inet/encodep.c
@@ -5,4 +5,4 @@
*/
#define L_encodep
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/encodeq.c b/libc/inet/encodeq.c
index be1a3123b..5555aa548 100644
--- a/libc/inet/encodeq.c
+++ b/libc/inet/encodeq.c
@@ -5,4 +5,4 @@
*/
#define L_encodeq
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/ether_addr.c b/libc/inet/ether_addr.c
index bcea9ba46..6d456e716 100644
--- a/libc/inet/ether_addr.c
+++ b/libc/inet/ether_addr.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; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>.
*/
/*
@@ -23,58 +22,53 @@
* - initial uClibc port
*/
-#define __FORCE_GLIBC
-#include <features.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <netinet/ether.h>
#include <netinet/if_ether.h>
-libc_hidden_proto(ether_aton_r)
-libc_hidden_proto(ether_ntoa_r)
-libc_hidden_proto(sprintf)
-#ifdef __UCLIBC_HAS_XLOCALE__
-libc_hidden_proto(__ctype_b_loc)
-libc_hidden_proto(__ctype_tolower_loc)
-#elif defined __UCLIBC_HAS_CTYPE_TABLES__
-libc_hidden_proto(__ctype_b)
-libc_hidden_proto(__ctype_tolower)
-#endif
-
struct ether_addr *ether_aton_r(const char *asc, struct ether_addr *addr)
{
- size_t cnt;
+ /* asc is "X:XX:XX:x:xx:xX" */
+ int cnt;
for (cnt = 0; cnt < 6; ++cnt) {
- unsigned int number;
- char ch;
+ unsigned char number;
+ char ch = *asc++;
- ch = _tolower(*asc++);
+ if (ch < 0x20)
+ return NULL;
+ /* | 0x20 is cheap tolower(), valid for letters/numbers only */
+ ch |= 0x20;
if ((ch < '0' || ch > '9') && (ch < 'a' || ch > 'f'))
return NULL;
- number = isdigit(ch) ? (ch - '0') : (ch - 'a' + 10);
-
- ch = _tolower(*asc);
- if ((cnt < 5 && ch != ':')
- || (cnt == 5 && ch != '\0' && !isspace(ch))) {
- ++asc;
+ number = !(ch > '9') ? (ch - '0') : (ch - 'a' + 10);
+
+ ch = *asc++;
+ if ((cnt != 5 && ch != ':') /* not last group */
+ /* What standard says ASCII ether address representation
+ * may also finish with whitespace, not only NUL?
+ * We can get rid of isspace() otherwise */
+ || (cnt == 5 && ch != '\0' /*&& !isspace(ch)*/)
+ ) {
+ ch |= 0x20; /* cheap tolower() */
if ((ch < '0' || ch > '9') && (ch < 'a' || ch > 'f'))
return NULL;
- number <<= 4;
- number += isdigit(ch) ? (ch - '0') : (ch - 'a' + 10);
+ number = (number << 4) + (!(ch > '9') ? (ch - '0') : (ch - 'a' + 10));
- ch = *asc;
- if (cnt < 5 && ch != ':')
- return NULL;
+ if (cnt != 5) {
+ ch = *asc++;
+ if (ch != ':')
+ return NULL;
+ }
}
/* Store result. */
- addr->ether_addr_octet[cnt] = (unsigned char) number;
-
- /* Skip ':'. */
- ++asc;
+ addr->ether_addr_octet[cnt] = number;
}
+ /* Looks like we allow garbage after last group?
+ * "1:2:3:4:5:66anything_at_all"? */
return addr;
}
diff --git a/libc/inet/formquery.c b/libc/inet/formquery.c
index 2c53e33de..4bc0ebe3f 100644
--- a/libc/inet/formquery.c
+++ b/libc/inet/formquery.c
@@ -5,4 +5,4 @@
*/
#define L_formquery
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/gai_strerror.c b/libc/inet/gai_strerror.c
index 61688bad9..1da55524a 100644
--- a/libc/inet/gai_strerror.c
+++ b/libc/inet/gai_strerror.c
@@ -13,17 +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/>. */
-#define __FORCE_GLIBC
-#include <features.h>
#include <stdio.h>
#include <netdb.h>
+#include <libintl.h>
-#define N_(x) x
-#define _(x) x
static const struct
{
int code;
diff --git a/libc/inet/get_hosts_byaddr_r.c b/libc/inet/get_hosts_byaddr_r.c
index c377aec13..eeac8907f 100644
--- a/libc/inet/get_hosts_byaddr_r.c
+++ b/libc/inet/get_hosts_byaddr_r.c
@@ -5,4 +5,4 @@
*/
#define L_get_hosts_byaddr_r
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/get_hosts_byname_r.c b/libc/inet/get_hosts_byname_r.c
index 7ad1e3fa5..caad0bcc7 100644
--- a/libc/inet/get_hosts_byname_r.c
+++ b/libc/inet/get_hosts_byname_r.c
@@ -5,4 +5,4 @@
*/
#define L_get_hosts_byname_r
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/getaddrinfo.c b/libc/inet/getaddrinfo.c
index df802f1d4..7ae32be39 100644
--- a/libc/inet/getaddrinfo.c
+++ b/libc/inet/getaddrinfo.c
@@ -51,16 +51,18 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
If these license terms cause you a real problem, contact the author. */
-#define __FORCE_GLIBC
-#include <features.h>
#include <assert.h>
#include <errno.h>
#include <netdb.h>
+#ifdef __UCLIBC_HAS_TLS__
+#include <tls.h>
+#endif
#include <resolv.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <stdbool.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netinet/in.h>
@@ -69,28 +71,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <sys/utsname.h>
#include <net/if.h>
#include <ifaddrs.h>
-
-/* Experimentally off - libc_hidden_proto(memcpy) */
-/* Experimentally off - libc_hidden_proto(memset) */
-/* libc_hidden_proto(strcmp) */
-/* libc_hidden_proto(stpcpy) */
-/* Experimentally off - libc_hidden_proto(strchr) */
-/* Experimentally off - libc_hidden_proto(strcpy) */
-/* Experimentally off - libc_hidden_proto(strlen) */
-libc_hidden_proto(socket)
-libc_hidden_proto(close)
-libc_hidden_proto(getservbyname_r)
-libc_hidden_proto(gethostbyname2_r)
-libc_hidden_proto(gethostbyaddr_r)
-libc_hidden_proto(inet_pton)
-libc_hidden_proto(inet_ntop)
-libc_hidden_proto(strtoul)
-libc_hidden_proto(if_nametoindex)
-libc_hidden_proto(__h_errno_location)
-/* libc_hidden_proto(uname) */
-#ifdef __UCLIBC_HAS_IPV6__
-libc_hidden_proto(in6addr_loopback)
-#endif
+#include "internal/parse_config.h"
#define GAIH_OKIFUNSPEC 0x0100
#define GAIH_EAI ~(GAIH_OKIFUNSPEC)
@@ -99,888 +80,899 @@ libc_hidden_proto(in6addr_loopback)
#define UNIX_PATH_MAX 108
#endif
-struct gaih_service
-{
- const char *name;
- int num;
+/* Useful for having small structure members/global variables */
+typedef int8_t socktype_t;
+typedef int8_t family_t;
+typedef int8_t protocol_t;
+struct BUG_too_small {
+ char BUG_socktype_t_too_small[(0
+ | SOCK_STREAM
+ | SOCK_DGRAM
+ | SOCK_RAW
+ ) <= 127 ? 1 : -1];
+ char BUG_family_t_too_small[(0
+ | AF_UNSPEC
+ | AF_INET
+ | AF_INET6
+ ) <= 127 ? 1 : -1];
+ char BUG_protocol_t_too_small[(0
+ | IPPROTO_TCP
+ | IPPROTO_UDP
+ ) <= 127 ? 1 : -1];
};
-struct gaih_servtuple
-{
- struct gaih_servtuple *next;
- int socktype;
- int protocol;
- int port;
+struct gaih_service {
+ const char *name;
+ int num;
};
-static const struct gaih_servtuple nullserv;
-
-struct gaih_addrtuple
-{
- struct gaih_addrtuple *next;
- int family;
- char addr[16];
- uint32_t scopeid;
+struct gaih_servtuple {
+ struct gaih_servtuple *next;
+ int socktype;
+ int protocol;
+ int port;
};
-struct gaih_typeproto
-{
- int socktype;
- int protocol;
- char name[4];
- int protoflag;
+struct gaih_addrtuple {
+ struct gaih_addrtuple *next;
+ int family;
+ char addr[16];
+ uint32_t scopeid;
};
+struct gaih_typeproto {
+ socktype_t socktype;
+ protocol_t protocol;
+ int8_t protoflag;
+ char name[4];
+};
/* Values for `protoflag'. */
-#define GAI_PROTO_NOSERVICE 1
-#define GAI_PROTO_PROTOANY 2
-
-static const struct gaih_typeproto gaih_inet_typeproto[] =
-{
- { 0, 0, "", 0 },
- { SOCK_STREAM, IPPROTO_TCP, "tcp", 0 },
- { SOCK_DGRAM, IPPROTO_UDP, "udp", 0 },
- { SOCK_RAW, 0, "raw", GAI_PROTO_PROTOANY|GAI_PROTO_NOSERVICE },
- { 0, 0, "", 0 }
+#define GAI_PROTO_NOSERVICE 1
+#define GAI_PROTO_PROTOANY 2
+
+static const struct gaih_typeproto gaih_inet_typeproto[] = {
+ { 0 , 0 , 0, "" },
+ { SOCK_STREAM, IPPROTO_TCP, 0, "tcp" },
+ { SOCK_DGRAM , IPPROTO_UDP, 0, "udp" },
+ { SOCK_RAW , 0 , GAI_PROTO_PROTOANY|GAI_PROTO_NOSERVICE, "raw" },
+ { 0 , 0 , 0, "" },
};
-struct gaih
-{
- int family;
- int (*gaih)(const char *name, const struct gaih_service *service,
- const struct addrinfo *req, struct addrinfo **pai);
+struct gaih {
+ int family;
+ int (*gaih)(const char *name, const struct gaih_service *service,
+ const struct addrinfo *req, struct addrinfo **pai);
};
-#if PF_UNSPEC == 0
-static const struct addrinfo default_hints;
-#else
-static const struct addrinfo default_hints =
-{ 0, PF_UNSPEC, 0, 0, 0, NULL, NULL, NULL };
-#endif
-
#define SEEN_IPV4 1
#define SEEN_IPV6 2
-static unsigned __check_pf (void)
+static unsigned __check_pf(void)
{
- unsigned seen = 0;
+ unsigned seen = 0;
+
#if defined __UCLIBC_SUPPORT_AI_ADDRCONFIG__
- {
- /* Get the interface list via getifaddrs. */
- struct ifaddrs *ifa = NULL;
- struct ifaddrs *runp;
- if (getifaddrs (&ifa) != 0)
- {
- /* We cannot determine what interfaces are available. Be
- optimistic. */
+
+ struct ifaddrs *ifa;
+ struct ifaddrs *runp;
+
+ /* Get the interface list via getifaddrs. */
+ if (getifaddrs(&ifa) != 0) {
+ /* We cannot determine what interfaces are available.
+ * Be optimistic. */
#if defined __UCLIBC_HAS_IPV4__
- seen |= SEEN_IPV4;
-#endif /* __UCLIBC_HAS_IPV4__ */
+ seen |= SEEN_IPV4;
+#endif
#if defined __UCLIBC_HAS_IPV6__
- seen |= SEEN_IPV6;
-#endif /* __UCLIBC_HAS_IPV6__ */
- return seen;
- }
+ seen |= SEEN_IPV6;
+#endif
+ return seen;
+ }
- for (runp = ifa; runp != NULL; runp = runp->ifa_next)
+ for (runp = ifa; runp != NULL; runp = runp->ifa_next) {
+ if (runp->ifa_addr == NULL)
+ continue;
#if defined __UCLIBC_HAS_IPV4__
- if (runp->ifa_addr->sa_family == PF_INET)
- seen |= SEEN_IPV4;
-#endif /* __UCLIBC_HAS_IPV4__ */
-#if defined __UCLIBC_HAS_IPV4__ && defined __UCLIBC_HAS_IPV6__
- else /* can't be both at once */
-#endif /* __UCLIBC_HAS_IPV4__ && defined __UCLIBC_HAS_IPV6__ */
+ if (runp->ifa_addr->sa_family == PF_INET)
+ seen |= SEEN_IPV4;
+#endif
#if defined __UCLIBC_HAS_IPV6__
- if (runp->ifa_addr->sa_family == PF_INET6)
- seen |= SEEN_IPV6;
-#endif /* __UCLIBC_HAS_IPV6__ */
+ if (runp->ifa_addr->sa_family == PF_INET6)
+ seen |= SEEN_IPV6;
+#endif
+ }
+ freeifaddrs(ifa);
- (void) freeifaddrs (ifa);
- }
#else
- /* AI_ADDRCONFIG is disabled, assume both ipv4 and ipv6 available. */
+
+ /* AI_ADDRCONFIG is disabled, assume both ipv4 and ipv6 available. */
#if defined __UCLIBC_HAS_IPV4__
- seen |= SEEN_IPV4;
-#endif /* __UCLIBC_HAS_IPV4__ */
+ seen |= SEEN_IPV4;
+#endif
#if defined __UCLIBC_HAS_IPV6__
- seen |= SEEN_IPV6;
-#endif /* __UCLIBC_HAS_IPV6__ */
+ seen |= SEEN_IPV6;
+#endif
#endif /* __UCLIBC_SUPPORT_AI_ADDRCONFIG__ */
- return seen;
+
+ return seen;
}
-static int addrconfig (sa_family_t af)
+static int addrconfig(sa_family_t af)
{
- int s;
- int ret;
- int saved_errno = errno;
- unsigned seen;
+ int s;
+ int ret;
+ int saved_errno = errno;
+ unsigned seen;
- seen = __check_pf();
+ seen = __check_pf();
#if defined __UCLIBC_HAS_IPV4__
- if (af == AF_INET)
- ret = seen & SEEN_IPV4;
- else
+ if (af == AF_INET)
+ ret = seen & SEEN_IPV4;
+ else
#endif
#if defined __UCLIBC_HAS_IPV6__
- if (af == AF_INET6)
- ret = seen & SEEN_IPV6;
- else
+ if (af == AF_INET6)
+ ret = seen & SEEN_IPV6;
+ else
#endif
- {
- s = socket(af, SOCK_DGRAM, 0);
- ret = 1; /* Assume PF_UNIX. */
- if (s < 0) {
- if (errno != EMFILE)
- ret = 0;
+ {
+ s = socket(af, SOCK_DGRAM, 0);
+ ret = 1; /* Assume PF_UNIX. */
+ if (s < 0) {
+ if (errno != EMFILE)
+ ret = 0;
+ } else
+ close(s);
}
- else
- close(s);
- }
- __set_errno (saved_errno);
- return ret;
+ __set_errno(saved_errno);
+ return ret;
}
#if 0
/* Using Unix sockets this way is a security risk. */
static int
-gaih_local (const char *name, const struct gaih_service *service,
- const struct addrinfo *req, struct addrinfo **pai)
+gaih_local(const char *name, const struct gaih_service *service,
+ const struct addrinfo *req, struct addrinfo **pai)
{
- struct utsname utsname;
-
- if ((name != NULL) && (req->ai_flags & AI_NUMERICHOST))
- return GAIH_OKIFUNSPEC | -EAI_NONAME;
-
- if ((name != NULL) || (req->ai_flags & AI_CANONNAME))
- if (uname (&utsname) < 0)
- return -EAI_SYSTEM;
-
- if (name != NULL)
- {
- if (strcmp(name, "localhost") &&
- strcmp(name, "local") &&
- strcmp(name, "unix") &&
- strcmp(name, utsname.nodename))
- return GAIH_OKIFUNSPEC | -EAI_NONAME;
- }
-
- if (req->ai_protocol || req->ai_socktype)
- {
- const struct gaih_typeproto *tp = gaih_inet_typeproto + 1;
-
- while (tp->name[0]
- && ((tp->protoflag & GAI_PROTO_NOSERVICE) != 0
- || (req->ai_socktype != 0 && req->ai_socktype != tp->socktype)
- || (req->ai_protocol != 0
- && !(tp->protoflag & GAI_PROTO_PROTOANY)
- && req->ai_protocol != tp->protocol)))
- ++tp;
-
- if (! tp->name[0])
- {
- if (req->ai_socktype)
- return (GAIH_OKIFUNSPEC | -EAI_SOCKTYPE);
- else
- return (GAIH_OKIFUNSPEC | -EAI_SERVICE);
+ struct utsname utsname;
+ struct addrinfo *ai = *pai;
+
+ if ((name != NULL) && (req->ai_flags & AI_NUMERICHOST))
+ return (GAIH_OKIFUNSPEC | -EAI_NONAME);
+
+ if ((name != NULL) || (req->ai_flags & AI_CANONNAME))
+ if (uname(&utsname) < 0)
+ return -EAI_SYSTEM;
+
+ if (name != NULL) {
+ if (strcmp(name, "localhost") &&
+ strcmp(name, "local") &&
+ strcmp(name, "unix") &&
+ strcmp(name, utsname.nodename))
+ return (GAIH_OKIFUNSPEC | -EAI_NONAME);
+ }
+
+ if (req->ai_protocol || req->ai_socktype) {
+ const struct gaih_typeproto *tp = gaih_inet_typeproto + 1;
+
+ while (tp->name[0]
+ && ((tp->protoflag & GAI_PROTO_NOSERVICE) != 0
+ || (req->ai_socktype != 0 && req->ai_socktype != tp->socktype)
+ || (req->ai_protocol != 0 && !(tp->protoflag & GAI_PROTO_PROTOANY) && req->ai_protocol != tp->protocol))
+ ) {
+ ++tp;
+ }
+ if (! tp->name[0]) {
+ if (req->ai_socktype)
+ return (GAIH_OKIFUNSPEC | -EAI_SOCKTYPE);
+ return (GAIH_OKIFUNSPEC | -EAI_SERVICE);
+ }
}
- }
-
- *pai = malloc (sizeof (struct addrinfo) + sizeof (struct sockaddr_un)
- + ((req->ai_flags & AI_CANONNAME)
- ? (strlen(utsname.nodename) + 1): 0));
- if (*pai == NULL)
- return -EAI_MEMORY;
-
- (*pai)->ai_next = NULL;
- (*pai)->ai_flags = req->ai_flags;
- (*pai)->ai_family = AF_LOCAL;
- (*pai)->ai_socktype = req->ai_socktype ? req->ai_socktype : SOCK_STREAM;
- (*pai)->ai_protocol = req->ai_protocol;
- (*pai)->ai_addrlen = sizeof (struct sockaddr_un);
- (*pai)->ai_addr = (void *) (*pai) + sizeof (struct addrinfo);
-
-#if SALEN
- ((struct sockaddr_un *) (*pai)->ai_addr)->sun_len =
- sizeof (struct sockaddr_un);
-#endif /* SALEN */
- ((struct sockaddr_un *)(*pai)->ai_addr)->sun_family = AF_LOCAL;
- memset(((struct sockaddr_un *)(*pai)->ai_addr)->sun_path, 0, UNIX_PATH_MAX);
+ *pai = ai = malloc(sizeof(struct addrinfo) + sizeof(struct sockaddr_un)
+ + ((req->ai_flags & AI_CANONNAME)
+ ? (strlen(utsname.nodename) + 1) : 0));
+ if (ai == NULL)
+ return -EAI_MEMORY;
+
+ ai->ai_next = NULL;
+ ai->ai_flags = req->ai_flags;
+ ai->ai_family = AF_LOCAL;
+ ai->ai_socktype = req->ai_socktype ? req->ai_socktype : SOCK_STREAM;
+ ai->ai_protocol = req->ai_protocol;
+ ai->ai_addrlen = sizeof(struct sockaddr_un);
+ ai->ai_addr = (void *)ai + sizeof(struct addrinfo);
+#if 0 /* SALEN */
+ ((struct sockaddr_un *)ai->ai_addr)->sun_len = sizeof(struct sockaddr_un);
+#endif /* SALEN */
- if (service)
- {
- struct sockaddr_un *sunp = (struct sockaddr_un *) (*pai)->ai_addr;
+ ((struct sockaddr_un *)ai->ai_addr)->sun_family = AF_LOCAL;
+ memset(((struct sockaddr_un *)ai->ai_addr)->sun_path, 0, UNIX_PATH_MAX);
- if (strchr (service->name, '/') != NULL)
- {
- if (strlen (service->name) >= sizeof (sunp->sun_path))
- return GAIH_OKIFUNSPEC | -EAI_SERVICE;
+ if (service) {
+ struct sockaddr_un *sunp = (struct sockaddr_un *)ai->ai_addr;
- strcpy (sunp->sun_path, service->name);
+ if (strchr(service->name, '/') != NULL) {
+ if (strlen(service->name) >= sizeof(sunp->sun_path))
+ return GAIH_OKIFUNSPEC | -EAI_SERVICE;
+ strcpy(sunp->sun_path, service->name);
+ } else {
+ if (strlen(P_tmpdir "/") + 1 + strlen(service->name) >= sizeof(sunp->sun_path))
+ return (GAIH_OKIFUNSPEC | -EAI_SERVICE);
+ stpcpy(stpcpy(sunp->sun_path, P_tmpdir "/"), service->name);
+ }
+ } else {
+ /* This is a dangerous use of the interface since there is a time
+ window between the test for the file and the actual creation
+ (done by the caller) in which a file with the same name could
+ be created. */
+ char *buf = ((struct sockaddr_un *)ai->ai_addr)->sun_path;
+
+ if (__path_search(buf, L_tmpnam, NULL, NULL, 0) != 0
+ || __gen_tempname(buf, __GT_NOCREATE, 0, 0) != 0
+ ) {
+ return -EAI_SYSTEM;
+ }
}
- else
- {
- if (strlen (P_tmpdir "/") + 1 + strlen (service->name) >=
- sizeof (sunp->sun_path))
- return GAIH_OKIFUNSPEC | -EAI_SERVICE;
- stpcpy (stpcpy (sunp->sun_path, P_tmpdir "/"), service->name);
- }
- }
- else
- {
- /* This is a dangerous use of the interface since there is a time
- window between the test for the file and the actual creation
- (done by the caller) in which a file with the same name could
- be created. */
- char *buf = ((struct sockaddr_un *) (*pai)->ai_addr)->sun_path;
-
- if (__builtin_expect (__path_search (buf, L_tmpnam, NULL, NULL, 0),
- 0) != 0
- || __builtin_expect (__gen_tempname (buf, __GT_NOCREATE), 0) != 0)
- return -EAI_SYSTEM;
- }
-
- if (req->ai_flags & AI_CANONNAME)
- (*pai)->ai_canonname = strcpy ((char *) *pai + sizeof (struct addrinfo)
- + sizeof (struct sockaddr_un),
- utsname.nodename);
- else
- (*pai)->ai_canonname = NULL;
- return 0;
+ ai->ai_canonname = NULL;
+ if (req->ai_flags & AI_CANONNAME)
+ ai->ai_canonname = strcpy((char *)(ai + 1) + sizeof(struct sockaddr_un),
+ utsname.nodename);
+ return 0;
}
#endif /* 0 */
static int
-gaih_inet_serv (const char *servicename, const struct gaih_typeproto *tp,
+gaih_inet_serv(const char *servicename, const struct gaih_typeproto *tp,
const struct addrinfo *req, struct gaih_servtuple *st)
{
- struct servent *s;
- size_t tmpbuflen = 1024;
- struct servent ts;
- char *tmpbuf;
- int r;
-
- do
- {
- tmpbuf = alloca (tmpbuflen);
-
- r = getservbyname_r (servicename, tp->name, &ts, tmpbuf, tmpbuflen,
- &s);
- if (r != 0 || s == NULL)
- {
- if (r == ERANGE)
+ struct servent *s;
+ size_t tmpbuflen = 1024;
+ struct servent ts;
+ char *tmpbuf;
+ int r;
+
+ while (1) {
+ tmpbuf = alloca(tmpbuflen);
+ r = getservbyname_r(servicename, tp->name, &ts, tmpbuf, tmpbuflen, &s);
+ if (r == 0 && s != NULL)
+ break;
+ if (r != ERANGE)
+ return (GAIH_OKIFUNSPEC | -EAI_SERVICE);
tmpbuflen *= 2;
- else
- return GAIH_OKIFUNSPEC | -EAI_SERVICE;
}
- }
- while (r);
-
- st->next = NULL;
- st->socktype = tp->socktype;
- st->protocol = ((tp->protoflag & GAI_PROTO_PROTOANY)
- ? req->ai_protocol : tp->protocol);
- st->port = s->s_port;
-
- return 0;
+ st->next = NULL;
+ st->socktype = tp->socktype;
+ st->protocol = ((tp->protoflag & GAI_PROTO_PROTOANY) ? req->ai_protocol : tp->protocol);
+ st->port = s->s_port;
+ return 0;
}
-#define gethosts(_family, _type) \
-{ \
- int i, herrno; \
- size_t tmpbuflen; \
- struct hostent th; \
- char *tmpbuf; \
- tmpbuflen = 512; \
- no_data = 0; \
- do { \
- tmpbuflen *= 2; \
- tmpbuf = alloca (tmpbuflen); \
- rc = gethostbyname2_r (name, _family, &th, tmpbuf, \
- tmpbuflen, &h, &herrno); \
- } while (rc == ERANGE && herrno == NETDB_INTERNAL); \
- if (rc != 0) \
- { \
- if (herrno == NETDB_INTERNAL) \
- { \
- __set_h_errno (herrno); \
- return -EAI_SYSTEM; \
- } \
- if (herrno == TRY_AGAIN) \
- no_data = EAI_AGAIN; \
- else \
- no_data = herrno == NO_DATA; \
- } \
- else if (h != NULL) \
- { \
- for (i = 0; h->h_addr_list[i]; i++) \
- { \
- if (*pat == NULL) { \
- *pat = alloca (sizeof(struct gaih_addrtuple)); \
- (*pat)->scopeid = 0; \
- } \
- (*pat)->next = NULL; \
- (*pat)->family = _family; \
- memcpy ((*pat)->addr, h->h_addr_list[i], \
- sizeof(_type)); \
- pat = &((*pat)->next); \
- } \
- } \
+#if defined __UCLIBC_HAS_IPV6__
+static uint8_t __gai_precedence = 0; /* =1 - IPv6, IPv4
+ =2 - IPv4, IPv6 */
+#endif
+
+/* NB: also uses h,pat,rc,no_data variables */
+#define gethosts(_family, _type) \
+{ \
+ int i, herrno; \
+ size_t tmpbuflen; \
+ struct hostent th; \
+ char *tmpbuf; \
+ \
+ tmpbuflen = 512; \
+ no_data = 0; \
+ do { \
+ tmpbuflen *= 2; \
+ tmpbuf = alloca(tmpbuflen); \
+ rc = gethostbyname2_r(name, _family, &th, tmpbuf, \
+ tmpbuflen, &h, &herrno); \
+ } while (rc == ERANGE && herrno == NETDB_INTERNAL); \
+ if (rc != 0) { \
+ if (herrno == NETDB_INTERNAL) { \
+ __set_h_errno(herrno); \
+ return -EAI_SYSTEM; \
+ } \
+ if (herrno == TRY_AGAIN) \
+ no_data = EAI_AGAIN; \
+ else \
+ no_data = (herrno == NO_DATA); \
+ } else if (h != NULL) { \
+ for (i = 0; h->h_addr_list[i]; i++) { \
+ if (*pat == NULL) { \
+ *pat = alloca(sizeof(struct gaih_addrtuple)); \
+ (*pat)->scopeid = 0; \
+ } \
+ (*pat)->next = NULL; \
+ (*pat)->family = _family; \
+ memcpy((*pat)->addr, h->h_addr_list[i], sizeof(_type)); \
+ pat = &((*pat)->next); \
+ } \
+ } \
}
static int
-gaih_inet (const char *name, const struct gaih_service *service,
- const struct addrinfo *req, struct addrinfo **pai)
+gaih_inet(const char *name, const struct gaih_service *service,
+ const struct addrinfo *req, struct addrinfo **pai)
{
- const struct gaih_typeproto *tp = gaih_inet_typeproto;
- struct gaih_servtuple *st = (struct gaih_servtuple *) &nullserv;
- struct gaih_addrtuple *at = NULL;
- int rc;
- int v4mapped = (req->ai_family == PF_UNSPEC || req->ai_family == PF_INET6) &&
- (req->ai_flags & AI_V4MAPPED);
- unsigned seen = __check_pf();
-
- if (req->ai_protocol || req->ai_socktype)
- {
- ++tp;
-
- while (tp->name[0]
- && ((req->ai_socktype != 0 && req->ai_socktype != tp->socktype)
- || (req->ai_protocol != 0
- && !(tp->protoflag & GAI_PROTO_PROTOANY)
- && req->ai_protocol != tp->protocol)))
- ++tp;
-
- if (! tp->name[0])
- {
- if (req->ai_socktype)
- return (GAIH_OKIFUNSPEC | -EAI_SOCKTYPE);
- else
- return (GAIH_OKIFUNSPEC | -EAI_SERVICE);
+ struct gaih_servtuple nullserv;
+
+ const struct gaih_typeproto *tp;
+ struct gaih_servtuple *st;
+ struct gaih_addrtuple *at;
+ int rc;
+ int v4mapped = req->ai_family == PF_INET6 && (req->ai_flags & AI_V4MAPPED);
+ unsigned seen = 0;
+ if (req->ai_flags & AI_ADDRCONFIG) {
+ /* "seen" is only used when AI_ADDRCONFIG is specified.
+ Avoid unnecessary call to __check_pf() otherwise
+ since it can be costly especially when RSBAC-Net is enabled. */
+ seen = __check_pf();
}
- }
- if (service != NULL)
- {
- if ((tp->protoflag & GAI_PROTO_NOSERVICE) != 0)
- return (GAIH_OKIFUNSPEC | -EAI_SERVICE);
-
- if (service->num < 0)
- {
- if (tp->name[0])
- {
- st = (struct gaih_servtuple *)
- alloca (sizeof (struct gaih_servtuple));
-
- if ((rc = gaih_inet_serv (service->name, tp, req, st)))
- return rc;
- }
- else
- {
- struct gaih_servtuple **pst = &st;
- for (tp++; tp->name[0]; tp++)
- {
- struct gaih_servtuple *newp;
-
- if ((tp->protoflag & GAI_PROTO_NOSERVICE) != 0)
- continue;
-
- if (req->ai_socktype != 0
- && req->ai_socktype != tp->socktype)
- continue;
- if (req->ai_protocol != 0
- && !(tp->protoflag & GAI_PROTO_PROTOANY)
- && req->ai_protocol != tp->protocol)
- continue;
-
- newp = (struct gaih_servtuple *)
- alloca (sizeof (struct gaih_servtuple));
-
- if ((rc = gaih_inet_serv (service->name, tp, req, newp)))
- {
- if (rc & GAIH_OKIFUNSPEC)
- continue;
- return rc;
- }
-
- *pst = newp;
- pst = &(newp->next);
+ memset(&nullserv, 0, sizeof(nullserv));
+
+ tp = gaih_inet_typeproto;
+ if (req->ai_protocol || req->ai_socktype) {
+ ++tp;
+ while (tp->name[0]) {
+ if ((req->ai_socktype == 0 || req->ai_socktype == tp->socktype)
+ && (req->ai_protocol == 0 || req->ai_protocol == tp->protocol || (tp->protoflag & GAI_PROTO_PROTOANY))
+ ) {
+ goto found;
+ }
+ ++tp;
}
- if (st == (struct gaih_servtuple *) &nullserv)
- return (GAIH_OKIFUNSPEC | -EAI_SERVICE);
- }
- }
- else
- {
- st = alloca (sizeof (struct gaih_servtuple));
- st->next = NULL;
- st->socktype = tp->socktype;
- st->protocol = ((tp->protoflag & GAI_PROTO_PROTOANY)
- ? req->ai_protocol : tp->protocol);
- st->port = htons (service->num);
+ if (req->ai_socktype)
+ return (GAIH_OKIFUNSPEC | -EAI_SOCKTYPE);
+ return (GAIH_OKIFUNSPEC | -EAI_SERVICE);
+ found: ;
}
- }
- else if (req->ai_socktype || req->ai_protocol)
- {
- st = alloca (sizeof (struct gaih_servtuple));
- st->next = NULL;
- st->socktype = tp->socktype;
- st->protocol = ((tp->protoflag & GAI_PROTO_PROTOANY)
- ? req->ai_protocol : tp->protocol);
- st->port = 0;
- }
- else
- {
- /*
- * Neither socket type nor protocol is set. Return all socket types
- * we know about.
- */
- struct gaih_servtuple **lastp = &st;
- for (++tp; tp->name[0]; ++tp)
- {
- struct gaih_servtuple *newp;
-
- newp = alloca (sizeof (struct gaih_servtuple));
- newp->next = NULL;
- newp->socktype = tp->socktype;
- newp->protocol = tp->protocol;
- newp->port = 0;
- *lastp = newp;
- lastp = &newp->next;
+ st = &nullserv;
+ if (service != NULL) {
+ if ((tp->protoflag & GAI_PROTO_NOSERVICE) != 0)
+ return (GAIH_OKIFUNSPEC | -EAI_SERVICE);
+
+ if (service->num < 0) {
+ if (tp->name[0]) {
+ st = alloca(sizeof(struct gaih_servtuple));
+ rc = gaih_inet_serv(service->name, tp, req, st);
+ if (rc)
+ return rc;
+ } else {
+ struct gaih_servtuple **pst = &st;
+ for (tp++; tp->name[0]; tp++) {
+ struct gaih_servtuple *newp;
+
+ if ((tp->protoflag & GAI_PROTO_NOSERVICE) != 0)
+ continue;
+
+ if (req->ai_socktype != 0 && req->ai_socktype != tp->socktype)
+ continue;
+ if (req->ai_protocol != 0
+ && !(tp->protoflag & GAI_PROTO_PROTOANY)
+ && req->ai_protocol != tp->protocol)
+ continue;
+
+ newp = alloca(sizeof(struct gaih_servtuple));
+ rc = gaih_inet_serv(service->name, tp, req, newp);
+ if (rc) {
+ if (rc & GAIH_OKIFUNSPEC)
+ continue;
+ return rc;
+ }
+
+ *pst = newp;
+ pst = &(newp->next);
+ }
+ if (st == &nullserv)
+ return (GAIH_OKIFUNSPEC | -EAI_SERVICE);
+ }
+ } else {
+ st = alloca(sizeof(struct gaih_servtuple));
+ st->next = NULL;
+ st->socktype = tp->socktype;
+ st->protocol = ((tp->protoflag & GAI_PROTO_PROTOANY)
+ ? req->ai_protocol : tp->protocol);
+ st->port = htons(service->num);
+ }
+ } else if (req->ai_socktype || req->ai_protocol) {
+ st = alloca(sizeof(struct gaih_servtuple));
+ st->next = NULL;
+ st->socktype = tp->socktype;
+ st->protocol = ((tp->protoflag & GAI_PROTO_PROTOANY)
+ ? req->ai_protocol : tp->protocol);
+ st->port = 0;
+ } else {
+ /*
+ * Neither socket type nor protocol is set. Return all socket types
+ * we know about.
+ */
+ struct gaih_servtuple **lastp = &st;
+ for (++tp; tp->name[0]; ++tp) {
+ struct gaih_servtuple *newp;
+
+ newp = alloca(sizeof(struct gaih_servtuple));
+ newp->next = NULL;
+ newp->socktype = tp->socktype;
+ newp->protocol = tp->protocol;
+ newp->port = 0;
+
+ *lastp = newp;
+ lastp = &newp->next;
+ }
}
- }
-
- if (name != NULL)
- {
- at = alloca (sizeof (struct gaih_addrtuple));
- at->family = AF_UNSPEC;
- at->scopeid = 0;
- at->next = NULL;
-
- if (inet_pton (AF_INET, name, at->addr) > 0)
- {
- if (req->ai_family == AF_UNSPEC || req->ai_family == AF_INET || v4mapped)
- at->family = AF_INET;
- else
- return -EAI_FAMILY;
- }
+ at = NULL;
+ if (name != NULL) {
+ at = alloca(sizeof(struct gaih_addrtuple));
+ at->family = AF_UNSPEC;
+ at->scopeid = 0;
+ at->next = NULL;
+
+ if (inet_pton(AF_INET, name, at->addr) > 0) {
+ if (req->ai_family != AF_UNSPEC && req->ai_family != AF_INET && !v4mapped)
+ return -EAI_FAMILY;
+ at->family = AF_INET;
+ }
#if defined __UCLIBC_HAS_IPV6__
- if (at->family == AF_UNSPEC)
- {
- char *namebuf = strdupa (name);
- char *scope_delim;
-
- scope_delim = strchr (namebuf, SCOPE_DELIMITER);
- if (scope_delim != NULL)
- *scope_delim = '\0';
-
- if (inet_pton (AF_INET6, namebuf, at->addr) > 0)
- {
- if (req->ai_family == AF_UNSPEC || req->ai_family == AF_INET6)
- at->family = AF_INET6;
- else
- return -EAI_FAMILY;
-
- if (scope_delim != NULL)
- {
- int try_numericscope = 0;
- if (IN6_IS_ADDR_LINKLOCAL (at->addr)
- || IN6_IS_ADDR_MC_LINKLOCAL (at->addr))
- {
- at->scopeid = if_nametoindex (scope_delim + 1);
- if (at->scopeid == 0)
- try_numericscope = 1;
- }
- else
- try_numericscope = 1;
-
- if (try_numericscope != 0)
- {
- char *end;
- assert (sizeof (uint32_t) <= sizeof (unsigned long));
- at->scopeid = (uint32_t) strtoul (scope_delim + 1, &end,
- 10);
- if (*end != '\0')
- return GAIH_OKIFUNSPEC | -EAI_NONAME;
- }
+ if (at->family == AF_UNSPEC) {
+ char *namebuf = strdupa(name);
+ char *scope_delim;
+
+ scope_delim = strchr(namebuf, SCOPE_DELIMITER);
+ if (scope_delim != NULL)
+ *scope_delim = '\0';
+
+ if (inet_pton(AF_INET6, namebuf, at->addr) > 0) {
+ if (req->ai_family != AF_UNSPEC && req->ai_family != AF_INET6)
+ return -EAI_FAMILY;
+ at->family = AF_INET6;
+ if (scope_delim != NULL) {
+ int try_numericscope = 0;
+ uint32_t *a32 = (uint32_t*)at->addr;
+ if (IN6_IS_ADDR_LINKLOCAL(a32) || IN6_IS_ADDR_MC_LINKLOCAL(at->addr)) {
+ at->scopeid = if_nametoindex(scope_delim + 1);
+ if (at->scopeid == 0)
+ try_numericscope = 1;
+ } else
+ try_numericscope = 1;
+
+ if (try_numericscope != 0) {
+ char *end;
+ assert(sizeof(uint32_t) <= sizeof(unsigned long));
+ at->scopeid = (uint32_t)strtoul(scope_delim + 1, &end, 10);
+ if (*end != '\0')
+ return (GAIH_OKIFUNSPEC | -EAI_NONAME);
+ }
+ }
+ }
}
- }
- }
#endif
- if (at->family == AF_UNSPEC && (req->ai_flags & AI_NUMERICHOST) == 0)
- {
- struct hostent *h;
- struct gaih_addrtuple **pat = &at;
- int no_data = 0;
- int no_inet6_data;
-
- /*
- * If we are looking for both IPv4 and IPv6 address we don't want
- * the lookup functions to automatically promote IPv4 addresses to
- * IPv6 addresses.
- */
-
+ if (at->family == AF_UNSPEC && !(req->ai_flags & AI_NUMERICHOST)) {
+ struct hostent *h;
+ struct gaih_addrtuple **pat = &at;
+ int no_data, no_inet6_data;
#if defined __UCLIBC_HAS_IPV6__
- if (req->ai_family == AF_UNSPEC || req->ai_family == AF_INET6)
- if (!(req->ai_flags & AI_ADDRCONFIG) || (seen & SEEN_IPV6))
- gethosts (AF_INET6, struct in6_addr);
+ bool first_try = true;
#endif
- no_inet6_data = no_data;
-
- if (req->ai_family == AF_INET ||
- (!v4mapped && req->ai_family == AF_UNSPEC) ||
- (v4mapped && (no_inet6_data != 0 || (req->ai_flags & AI_ALL))))
- if (!(req->ai_flags & AI_ADDRCONFIG) || (seen & SEEN_IPV4))
- gethosts (AF_INET, struct in_addr);
-
- if (no_data != 0 && no_inet6_data != 0)
- {
- /* If both requests timed out report this. */
- if (no_data == EAI_AGAIN && no_inet6_data == EAI_AGAIN)
- return -EAI_AGAIN;
- /*
- * We made requests but they turned out no data.
- * The name is known, though.
- */
- return (GAIH_OKIFUNSPEC | -EAI_AGAIN);
- }
- }
+ /*
+ * If we are looking for both IPv4 and IPv6 address we don't want
+ * the lookup functions to automatically promote IPv4 addresses to
+ * IPv6 addresses.
+ */
+ no_inet6_data = no_data = 0;
+#if defined __UCLIBC_HAS_IPV6__
+ if (__gai_precedence == 2)
+ goto try_v4;
+
+ try_v6:
+ if (req->ai_family == AF_UNSPEC || req->ai_family == AF_INET6)
+ if (!(req->ai_flags & AI_ADDRCONFIG) || (seen & SEEN_IPV6))
+ gethosts(AF_INET6, struct in6_addr);
+ no_inet6_data = no_data;
+ if (!first_try)
+ goto tried_all;
+ first_try = false;
+
+ try_v4:
+#endif
+ if (req->ai_family == AF_INET
+ || (!v4mapped && req->ai_family == AF_UNSPEC)
+ || (v4mapped && (no_inet6_data != 0 || (req->ai_flags & AI_ALL)))
+ ) {
+ if (!(req->ai_flags & AI_ADDRCONFIG) || (seen & SEEN_IPV4))
+ gethosts(AF_INET, struct in_addr);
+ }
+#if defined __UCLIBC_HAS_IPV6__
+ if (first_try) {
+ first_try = false;
+ goto try_v6;
+ }
- if (at->family == AF_UNSPEC)
- return (GAIH_OKIFUNSPEC | -EAI_NONAME);
- }
- else
- {
- struct gaih_addrtuple *atr;
- atr = at = alloca (sizeof (struct gaih_addrtuple));
- memset (at, '\0', sizeof (struct gaih_addrtuple));
+ tried_all:
+#endif
+ if (no_data != 0 && no_inet6_data != 0) {
+ /* If both requests timed out report this. */
+ if (no_data == EAI_AGAIN && no_inet6_data == EAI_AGAIN)
+ return -EAI_AGAIN;
+ /*
+ * We made requests but they turned out no data.
+ * The name is known, though.
+ */
+ return (GAIH_OKIFUNSPEC | -EAI_AGAIN);
+ }
+ }
- if (req->ai_family == 0)
- {
- at->next = alloca (sizeof (struct gaih_addrtuple));
- memset (at->next, '\0', sizeof (struct gaih_addrtuple));
- }
+ if (at->family == AF_UNSPEC)
+ return (GAIH_OKIFUNSPEC | -EAI_NONAME);
+ } else {
+ struct gaih_addrtuple *atr;
+ atr = at = alloca(sizeof(struct gaih_addrtuple));
+ memset(at, '\0', sizeof(struct gaih_addrtuple));
+ if (req->ai_family == 0) {
+ at->next = alloca(sizeof(struct gaih_addrtuple));
+ memset(at->next, '\0', sizeof(struct gaih_addrtuple));
+ }
#if defined __UCLIBC_HAS_IPV6__
- if (req->ai_family == 0 || req->ai_family == AF_INET6)
- {
- at->family = AF_INET6;
- if ((req->ai_flags & AI_PASSIVE) == 0)
- memcpy (at->addr, &in6addr_loopback, sizeof (struct in6_addr));
- atr = at->next;
- }
+ if (req->ai_family == 0 || req->ai_family == AF_INET6) {
+ at->family = AF_INET6;
+ if ((req->ai_flags & AI_PASSIVE) == 0)
+ memcpy(at->addr, &in6addr_loopback, sizeof(struct in6_addr));
+ atr = at->next;
+ }
#endif
-
- if (req->ai_family == 0 || req->ai_family == AF_INET)
- {
- atr->family = AF_INET;
- if ((req->ai_flags & AI_PASSIVE) == 0)
- *(uint32_t *) atr->addr = htonl (INADDR_LOOPBACK);
+ if (req->ai_family == 0 || req->ai_family == AF_INET) {
+ atr->family = AF_INET;
+ if ((req->ai_flags & AI_PASSIVE) == 0) {
+ uint32_t *a = (uint32_t*)atr->addr;
+ *a = htonl(INADDR_LOOPBACK);
+ }
+ }
}
- }
- if (pai == NULL)
- return 0;
-
- {
- const char *c = NULL;
- struct gaih_servtuple *st2;
- struct gaih_addrtuple *at2 = at;
- size_t socklen, namelen;
- sa_family_t family;
-
- /*
- * buffer is the size of an unformatted IPv6 address in
- * printable format.
- */
- char buffer[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];
+ if (pai == NULL)
+ return 0;
- while (at2 != NULL)
{
- if (req->ai_flags & AI_CANONNAME)
- {
- struct hostent *h = NULL;
-
- int herrno;
- struct hostent th;
- size_t tmpbuflen = 512;
- char *tmpbuf;
-
- do
- {
- tmpbuflen *= 2;
- tmpbuf = alloca (tmpbuflen);
-
- if (tmpbuf == NULL)
- return -EAI_MEMORY;
-
- rc = gethostbyaddr_r (at2->addr,
- ((at2->family == AF_INET6)
- ? sizeof(struct in6_addr)
- : sizeof(struct in_addr)),
- at2->family, &th, tmpbuf, tmpbuflen,
- &h, &herrno);
+ const char *c = NULL;
+ struct gaih_servtuple *st2;
+ struct gaih_addrtuple *at2 = at;
+ size_t socklen, namelen;
+ sa_family_t family;
- }
- while (rc == errno && herrno == NETDB_INTERNAL);
+ /*
+ * buffer is the size of an unformatted IPv6 address in
+ * printable format.
+ */
+ char buffer[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
+
+ while (at2 != NULL) {
+ c = inet_ntop(at2->family, at2->addr, buffer, sizeof(buffer));
+ if (c) {
+ namelen = strlen(c) + 1;
+ } else if (req->ai_flags & AI_CANONNAME) {
+ struct hostent *h = NULL;
+ int herrno;
+ struct hostent th;
+ size_t tmpbuflen = 512;
+ char *tmpbuf;
+
+ /* Hint says numeric, but address is not */
+ if (req->ai_flags & AI_NUMERICHOST)
+ return -EAI_NONAME;
+
+ do {
+ tmpbuflen *= 2;
+ tmpbuf = alloca(tmpbuflen);
+ rc = gethostbyaddr_r(at2->addr,
+#ifdef __UCLIBC_HAS_IPV6__
+ ((at2->family == AF_INET6)
+ ? sizeof(struct in6_addr)
+ : sizeof(struct in_addr)),
+#else
+ sizeof(struct in_addr),
+#endif
+ at2->family,
+ &th, tmpbuf, tmpbuflen,
+ &h, &herrno);
+ } while (rc == ERANGE && herrno == NETDB_INTERNAL);
- if (rc != 0 && herrno == NETDB_INTERNAL)
- {
- __set_h_errno (herrno);
- return -EAI_SYSTEM;
- }
+ if (rc != 0 && herrno == NETDB_INTERNAL) {
+ __set_h_errno(herrno);
+ return -EAI_SYSTEM;
+ }
- if (h == NULL)
- c = inet_ntop (at2->family, at2->addr, buffer, sizeof(buffer));
- else
- c = h->h_name;
+ if (h != NULL)
+ c = h->h_name;
- if (c == NULL)
- return GAIH_OKIFUNSPEC | -EAI_NONAME;
+ if (c == NULL)
+ return (GAIH_OKIFUNSPEC | -EAI_NONAME);
- namelen = strlen (c) + 1;
- }
- else
- namelen = 0;
+ namelen = strlen(c) + 1;
+ } else
+ namelen = 0;
#if defined __UCLIBC_HAS_IPV6__
- if (at2->family == AF_INET6 || v4mapped)
- {
- family = AF_INET6;
- socklen = sizeof (struct sockaddr_in6);
- }
+ if (at2->family == AF_INET6 || v4mapped) {
+ family = AF_INET6;
+ socklen = sizeof(struct sockaddr_in6);
+ }
#endif
#if defined __UCLIBC_HAS_IPV4__ && defined __UCLIBC_HAS_IPV6__
- else
+ else
#endif
#if defined __UCLIBC_HAS_IPV4__
- {
- family = AF_INET;
- socklen = sizeof (struct sockaddr_in);
- }
+ {
+ family = AF_INET;
+ socklen = sizeof(struct sockaddr_in);
+ }
#endif
- for (st2 = st; st2 != NULL; st2 = st2->next)
- {
- if (req->ai_flags & AI_ADDRCONFIG) {
- if (family == AF_INET && !(seen & SEEN_IPV4))
- break;
+ for (st2 = st; st2 != NULL; st2 = st2->next) {
+ if (req->ai_flags & AI_ADDRCONFIG) {
+ if (family == AF_INET && !(seen & SEEN_IPV4))
+ break;
#if defined __UCLIBC_HAS_IPV6__
- else if (family == AF_INET6 && !(seen & SEEN_IPV6))
- break;
+ else if (family == AF_INET6 && !(seen & SEEN_IPV6))
+ break;
#endif
- }
- *pai = malloc (sizeof (struct addrinfo) + socklen + namelen);
- if (*pai == NULL)
- return -EAI_MEMORY;
-
- (*pai)->ai_flags = req->ai_flags;
- (*pai)->ai_family = family;
- (*pai)->ai_socktype = st2->socktype;
- (*pai)->ai_protocol = st2->protocol;
- (*pai)->ai_addrlen = socklen;
- (*pai)->ai_addr = (void *) (*pai) + sizeof(struct addrinfo);
-#if SALEN
- (*pai)->ai_addr->sa_len = socklen;
-#endif /* SALEN */
- (*pai)->ai_addr->sa_family = family;
+ }
+ *pai = malloc(sizeof(struct addrinfo) + socklen + namelen);
+ if (*pai == NULL)
+ return -EAI_MEMORY;
+
+ (*pai)->ai_flags = req->ai_flags;
+ (*pai)->ai_family = family;
+ (*pai)->ai_socktype = st2->socktype;
+ (*pai)->ai_protocol = st2->protocol;
+ (*pai)->ai_addrlen = socklen;
+ (*pai)->ai_addr = (void *) (*pai) + sizeof(struct addrinfo);
+#if 0 /* SALEN */
+ (*pai)->ai_addr->sa_len = socklen;
+#endif
+ (*pai)->ai_addr->sa_family = family;
#if defined __UCLIBC_HAS_IPV6__
- if (family == AF_INET6)
- {
- struct sockaddr_in6 *sin6p =
- (struct sockaddr_in6 *) (*pai)->ai_addr;
-
- sin6p->sin6_flowinfo = 0;
- if (at2->family == AF_INET6)
- {
- memcpy (&sin6p->sin6_addr,
- at2->addr, sizeof (struct in6_addr));
- }
- else
- {
- sin6p->sin6_addr.s6_addr32[0] = 0;
- sin6p->sin6_addr.s6_addr32[1] = 0;
- sin6p->sin6_addr.s6_addr32[2] = htonl(0x0000ffff);
- memcpy(&sin6p->sin6_addr.s6_addr32[3],
- at2->addr, sizeof (sin6p->sin6_addr.s6_addr32[3]));
- }
- sin6p->sin6_port = st2->port;
- sin6p->sin6_scope_id = at2->scopeid;
- }
+ if (family == AF_INET6) {
+ struct sockaddr_in6 *sin6p = (struct sockaddr_in6 *) (*pai)->ai_addr;
+
+ sin6p->sin6_flowinfo = 0;
+ if (at2->family == AF_INET6) {
+ memcpy(&sin6p->sin6_addr,
+ at2->addr, sizeof(struct in6_addr));
+ } else {
+ sin6p->sin6_addr.s6_addr32[0] = 0;
+ sin6p->sin6_addr.s6_addr32[1] = 0;
+ sin6p->sin6_addr.s6_addr32[2] = htonl(0x0000ffff);
+ memcpy(&sin6p->sin6_addr.s6_addr32[3],
+ at2->addr, sizeof(sin6p->sin6_addr.s6_addr32[3]));
+ }
+ sin6p->sin6_port = st2->port;
+ sin6p->sin6_scope_id = at2->scopeid;
+ }
#endif
#if defined __UCLIBC_HAS_IPV4__ && defined __UCLIBC_HAS_IPV6__
- else
+ else
#endif
#if defined __UCLIBC_HAS_IPV4__
- {
- struct sockaddr_in *sinp =
- (struct sockaddr_in *) (*pai)->ai_addr;
-
- memcpy (&sinp->sin_addr,
- at2->addr, sizeof (struct in_addr));
- sinp->sin_port = st2->port;
- memset (sinp->sin_zero, '\0', sizeof (sinp->sin_zero));
- }
+ {
+ struct sockaddr_in *sinp = (struct sockaddr_in *) (*pai)->ai_addr;
+
+ memcpy(&sinp->sin_addr, at2->addr, sizeof(struct in_addr));
+ sinp->sin_port = st2->port;
+ memset(sinp->sin_zero, '\0', sizeof(sinp->sin_zero));
+ }
#endif
- if (c)
- {
- (*pai)->ai_canonname = ((void *) (*pai) +
- sizeof (struct addrinfo) + socklen);
- strcpy ((*pai)->ai_canonname, c);
+ if (c) {
+ (*pai)->ai_canonname = ((void *) (*pai) +
+ sizeof(struct addrinfo) + socklen);
+ strcpy((*pai)->ai_canonname, c);
+ } else {
+ (*pai)->ai_canonname = NULL;
+ }
+ (*pai)->ai_next = NULL;
+ pai = &((*pai)->ai_next);
+ }
+
+ at2 = at2->next;
}
- else
- (*pai)->ai_canonname = NULL;
-
- (*pai)->ai_next = NULL;
- pai = &((*pai)->ai_next);
- }
-
- at2 = at2->next;
}
- }
- return 0;
+ return 0;
}
-static struct gaih gaih[] =
-{
+static const struct gaih gaih[] = {
#if defined __UCLIBC_HAS_IPV6__
- { PF_INET6, gaih_inet },
+ { PF_INET6, gaih_inet },
#endif
- { PF_INET, gaih_inet },
+ { PF_INET, gaih_inet },
#if 0
- { PF_LOCAL, gaih_local },
+ { PF_LOCAL, gaih_local },
#endif
- { PF_UNSPEC, NULL }
+ { PF_UNSPEC, NULL }
};
-libc_hidden_proto(freeaddrinfo)
+#if defined __UCLIBC_HAS_IPV6__
+
+/*
+ * A call to getaddrinfo might return multiple answers. To provide
+ * possibility to change the sorting we must use /etc/gai.conf file,
+ * like glibc.
+ *
+ * gai.conf format:
+ *
+ * label <netmask> <precedence>
+ * The value is added to the label table used in
+ * the RFC 3484 sorting. If any label definition
+ * is present in the configuration file is present,
+ * the default table is not used. All the label
+ * definitions of the default table which are to
+ * be maintained have to be duplicated.
+ * precedence <netmask> <precedence>
+ * This keyword is similar to label, but instead
+ * the value is added to the precedence table as
+ * specified in RFC 3484. Once again, the presence
+ * of a single precedence line in the configuration
+ * file causes the default table to not be used.
+ *
+ * The simplified uclibc's implementation allows to change the IPv4/IPv6
+ * sorting order for a whole address space only, i.e
+ * "precedence ::ffff:0:0/96 100" is only supported.
+ */
+static void __gai_conf_parse(void)
+{
+ /* NO reread of /etc/gai.conf on change. */
+ if (__gai_precedence != 0)
+ return;
+
+ __gai_precedence = 1; /* default IPv6 */
+
+ parser_t *parser;
+ char **tok = NULL;
+
+ parser = config_open("/etc/gai.conf");
+ if (!parser)
+ return;
+
+ while (config_read(parser, &tok, 3, 3, "# \t", PARSE_NORMAL)) {
+ if (strcmp(tok[0], "precedence") == 0) {
+ char *pfx;
+ struct in6_addr mask;
+
+ pfx = strchr(tok[1], '/');
+ if (!pfx)
+ continue;
+ *(pfx++) = 0;
+ if (inet_pton(AF_INET6, tok[1], &mask) <= 0)
+ continue;
+ if (IN6_IS_ADDR_V4MAPPED(&mask)
+ && mask.s6_addr32[3] == 0
+ && atoi(pfx) == 96 && atoi(tok[2]) == 100)
+ __gai_precedence = 2; /* IPv4 first */
+ }
+ }
+ config_close(parser);
+}
+#else
+# define __gai_conf_parse(x)
+#endif /* __UCLIBC_HAS_IPV6__ */
+
void
-freeaddrinfo (struct addrinfo *ai)
+freeaddrinfo(struct addrinfo *ai)
{
- struct addrinfo *p;
-
- while (ai != NULL)
- {
- p = ai;
- ai = ai->ai_next;
- free (p);
- }
+ struct addrinfo *p;
+
+ while (ai != NULL) {
+ p = ai;
+ ai = ai->ai_next;
+ free(p);
+ }
}
libc_hidden_def(freeaddrinfo)
-libc_hidden_proto(getaddrinfo)
int
-getaddrinfo (const char *name, const char *service,
+getaddrinfo(const char *name, const char *service,
const struct addrinfo *hints, struct addrinfo **pai)
{
- int i = 0, j = 0, last_i = 0;
- struct addrinfo *p = NULL, **end;
- struct gaih *g = gaih, *pg = NULL;
- struct gaih_service gaih_service, *pservice;
-
- if (name != NULL && name[0] == '*' && name[1] == 0)
- name = NULL;
-
- if (service != NULL && service[0] == '*' && service[1] == 0)
- service = NULL;
-
- if (name == NULL && service == NULL)
- return EAI_NONAME;
-
- if (hints == NULL)
- hints = &default_hints;
-
- if (hints->ai_flags & ~(AI_PASSIVE|AI_CANONNAME|AI_NUMERICHOST|
- AI_ADDRCONFIG|AI_V4MAPPED|AI_NUMERICSERV|AI_ALL))
- return EAI_BADFLAGS;
-
- if ((hints->ai_flags & AI_CANONNAME) && name == NULL)
- return EAI_BADFLAGS;
-
- if (service && service[0])
- {
- char *c;
- gaih_service.name = service;
- gaih_service.num = strtoul (gaih_service.name, &c, 10);
- if (*c != '\0') {
- if (hints->ai_flags & AI_NUMERICSERV)
- return EAI_NONAME;
-
- gaih_service.num = -1;
+ int i, j, last_i;
+ struct addrinfo *p, **end;
+ const struct gaih *g, *pg;
+ struct gaih_service gaih_service, *pservice;
+ struct addrinfo default_hints;
+
+ if (name != NULL && name[0] == '*' && name[1] == 0)
+ name = NULL;
+
+ if (service != NULL && service[0] == '*' && service[1] == 0)
+ service = NULL;
+
+ if (name == NULL && service == NULL)
+ return EAI_NONAME;
+
+ if (hints == NULL) {
+ memset(&default_hints, 0, sizeof(default_hints));
+ if (AF_UNSPEC != 0)
+ default_hints.ai_family = AF_UNSPEC;
+ hints = &default_hints;
}
- else
- /*
- * Can't specify a numerical socket unless a protocol
- * family was given.
- */
- if (hints->ai_socktype == 0 && hints->ai_protocol == 0)
- return EAI_SERVICE;
- pservice = &gaih_service;
- }
- else
- pservice = NULL;
-
- if (pai)
- end = &p;
- else
- end = NULL;
- while (g->gaih)
- {
- if (hints->ai_family == g->family || hints->ai_family == AF_UNSPEC)
- {
- if ((hints->ai_flags & AI_ADDRCONFIG) && !addrconfig(g->family))
- {
- ++g;
- continue;
- }
- j++;
- if (pg == NULL || pg->gaih != g->gaih)
- {
- pg = g;
- i = g->gaih (name, pservice, hints, end);
- if (i != 0)
- {
- last_i = i;
-
- if (hints->ai_family == AF_UNSPEC && (i & GAIH_OKIFUNSPEC))
- continue;
-
- if (p)
- freeaddrinfo (p);
-
- return -(i & GAIH_EAI);
+ if (hints->ai_flags & ~(AI_PASSIVE|AI_CANONNAME|AI_NUMERICHOST|
+ AI_ADDRCONFIG|AI_V4MAPPED|AI_NUMERICSERV|AI_ALL))
+ return EAI_BADFLAGS;
+
+ if ((hints->ai_flags & AI_CANONNAME) && name == NULL)
+ return EAI_BADFLAGS;
+
+ if (service && service[0]) {
+ char *c;
+ gaih_service.name = service;
+ gaih_service.num = strtoul(gaih_service.name, &c, 10);
+ if (*c != '\0') {
+ if (hints->ai_flags & AI_NUMERICSERV)
+ return EAI_NONAME;
+ gaih_service.num = -1;
+ }
+ pservice = &gaih_service;
+ } else
+ pservice = NULL;
+
+ __gai_conf_parse();
+ g = gaih;
+ pg = NULL;
+ p = NULL;
+ end = NULL;
+ if (pai)
+ end = &p;
+ i = 0;
+ last_i = 0;
+ j = 0;
+ while (g->gaih) {
+ if (hints->ai_family == g->family || hints->ai_family == AF_UNSPEC) {
+ if ((hints->ai_flags & AI_ADDRCONFIG) && !addrconfig(g->family)) {
+ ++g;
+ continue;
+ }
+ j++;
+ if (pg == NULL || pg->gaih != g->gaih) {
+ pg = g;
+ i = g->gaih(name, pservice, hints, end);
+ if (i != 0) {
+ last_i = i;
+ if (hints->ai_family == AF_UNSPEC && (i & GAIH_OKIFUNSPEC))
+ continue;
+ /*if (p) - freeaddrinfo works ok on NULL too */
+ freeaddrinfo(p);
+ return -(i & GAIH_EAI);
+ }
+ if (end)
+ while (*end)
+ end = &((*end)->ai_next);
+ }
}
- if (end)
- while(*end) end = &((*end)->ai_next);
- }
+ ++g;
}
- ++g;
- }
- if (j == 0)
- return EAI_FAMILY;
+ if (j == 0)
+ return EAI_FAMILY;
- if (p)
- {
- *pai = p;
- return 0;
- }
+ if (p) {
+ *pai = p;
+ return 0;
+ }
- if (pai == NULL && last_i == 0)
- return 0;
+ if (pai == NULL && last_i == 0)
+ return 0;
- if (p)
- freeaddrinfo (p);
+ /* if (p) - never happens, see above */
+ /* freeaddrinfo(p); */
- return last_i ? -(last_i & GAIH_EAI) : EAI_NONAME;
+ return last_i ? -(last_i & GAIH_EAI) : EAI_NONAME;
}
libc_hidden_def(getaddrinfo)
diff --git a/libc/inet/gethostbyaddr.c b/libc/inet/gethostbyaddr.c
index ae8a543e5..dc16dd9eb 100644
--- a/libc/inet/gethostbyaddr.c
+++ b/libc/inet/gethostbyaddr.c
@@ -5,4 +5,4 @@
*/
#define L_gethostbyaddr
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/gethostbyaddr_r.c b/libc/inet/gethostbyaddr_r.c
index 6235c82e1..6e27e6207 100644
--- a/libc/inet/gethostbyaddr_r.c
+++ b/libc/inet/gethostbyaddr_r.c
@@ -5,4 +5,4 @@
*/
#define L_gethostbyaddr_r
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/gethostbyname.c b/libc/inet/gethostbyname.c
index 3d46ab015..9c9e9ca03 100644
--- a/libc/inet/gethostbyname.c
+++ b/libc/inet/gethostbyname.c
@@ -5,4 +5,4 @@
*/
#define L_gethostbyname
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/gethostbyname2.c b/libc/inet/gethostbyname2.c
index 685801642..5b9e74ba0 100644
--- a/libc/inet/gethostbyname2.c
+++ b/libc/inet/gethostbyname2.c
@@ -5,4 +5,4 @@
*/
#define L_gethostbyname2
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/gethostbyname2_r.c b/libc/inet/gethostbyname2_r.c
index 06d058ae7..0de0dd5e1 100644
--- a/libc/inet/gethostbyname2_r.c
+++ b/libc/inet/gethostbyname2_r.c
@@ -5,4 +5,4 @@
*/
#define L_gethostbyname2_r
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/gethostbyname_r.c b/libc/inet/gethostbyname_r.c
index fc9e56da5..4b34f8d17 100644
--- a/libc/inet/gethostbyname_r.c
+++ b/libc/inet/gethostbyname_r.c
@@ -5,4 +5,4 @@
*/
#define L_gethostbyname_r
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/gethostent.c b/libc/inet/gethostent.c
index 16133c0e4..64c183177 100644
--- a/libc/inet/gethostent.c
+++ b/libc/inet/gethostent.c
@@ -5,4 +5,4 @@
*/
#define L_gethostent
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/resolvename.c b/libc/inet/gethostent_r.c
index 157878fd1..48225d7fa 100644
--- a/libc/inet/resolvename.c
+++ b/libc/inet/gethostent_r.c
@@ -4,5 +4,5 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define L_resolvename
-#include "resolv.c"
+#define L_gethostent_r
+#include RESOLVER
diff --git a/libc/inet/getnameinfo.c b/libc/inet/getnameinfo.c
index fbfd3ede1..86edc51f3 100644
--- a/libc/inet/getnameinfo.c
+++ b/libc/inet/getnameinfo.c
@@ -5,4 +5,4 @@
*/
#define L_getnameinfo
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/getnet.c b/libc/inet/getnet.c
new file mode 100644
index 000000000..9049f97af
--- /dev/null
+++ b/libc/inet/getnet.c
@@ -0,0 +1,208 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Copyright (C) 2010 Bernhard Reutner-Fischer <uclibc@uclibc.org>
+ *
+ * Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+/* /etc/networks
+# network-name number [aliases ...]
+loopback 127.0.0.0 # optional aliases
+
+network-name: symbolic name of the netwkork
+number: official number of the network in dotted quad
+aliases: case sensitive optional space or tab separated list of other names
+*/
+
+#include <features.h>
+#include <netdb.h>
+#include <string.h>
+#include <stdlib.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <errno.h>
+#include <unistd.h>
+#include "internal/parse_config.h"
+
+#include <bits/uClibc_mutex.h>
+__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP);
+
+#define MINTOKENS 2
+#define MAXALIASES 8
+#define MAXTOKENS (MINTOKENS + MAXALIASES + 1)
+#define BUFSZ (255) /* one line */
+#define SBUFSIZE (BUFSZ + 1 + (sizeof(char *) * MAXTOKENS))
+
+static parser_t *netp = NULL;
+static struct netent nete;
+static char *netbuf = NULL;
+static smallint net_stayopen;
+
+void setnetent(int stayopen)
+{
+ __UCLIBC_MUTEX_LOCK(mylock);
+ if (netp)
+ config_close(netp);
+ netp = config_open(_PATH_NETWORKS);
+ if (stayopen)
+ net_stayopen = 1;
+ __UCLIBC_MUTEX_UNLOCK(mylock);
+}
+libc_hidden_def(setnetent)
+
+void endnetent(void)
+{
+ __UCLIBC_MUTEX_LOCK(mylock);
+ if (netp) {
+ config_close(netp);
+ netp = NULL;
+ }
+ net_stayopen = 0;
+ __UCLIBC_MUTEX_UNLOCK(mylock);
+}
+libc_hidden_def(endnetent)
+
+int getnetent_r(struct netent *result_buf,
+ char *buf, size_t buflen, struct netent **result,
+ int *h_errnop
+ )
+{
+ char **tok = NULL;
+ const size_t aliaslen = sizeof(char *) * MAXTOKENS;
+ int ret = ERANGE;
+
+ *result = NULL;
+ if (buflen < aliaslen
+ || (buflen - aliaslen) < BUFSZ + 1)
+ goto DONE_NOUNLOCK;
+
+ __UCLIBC_MUTEX_LOCK(mylock);
+ ret = ENOENT;
+ if (netp == NULL)
+ setnetent(net_stayopen);
+ if (netp == NULL)
+ goto DONE;
+ netp->data = buf;
+ netp->data_len = aliaslen;
+ netp->line_len = buflen - aliaslen;
+ /* <name>[[:space:]]<netnumber>[[:space:]][<aliases>] */
+ if (!config_read(netp, &tok, MAXTOKENS-1, MINTOKENS, "# \t/", PARSE_NORMAL)) {
+ goto DONE;
+ }
+ result_buf->n_name = *(tok++);
+ {
+ struct addrinfo hints, *addri;
+# define sa4_to_uint32(sa) \
+ (ntohl(((struct sockaddr_in*)sa)->sin_addr.s_addr))
+#ifdef __UCLIBC_HAS_IPV6__
+# define sa6_to_uint8(sa) \
+ (ntohl(((struct sockaddr_in6*)sa)->sin6_addr.s6_addr))
+#endif
+ memset(&hints, 0, sizeof(struct addrinfo));
+ hints.ai_family = AF_UNSPEC;
+ hints.ai_flags = AI_NUMERICHOST;
+ getaddrinfo(*(tok++), NULL, &hints, &addri);
+ result_buf->n_addrtype = addri->ai_family;
+ result_buf->n_net =
+#if 0 /*FIXME: implement me! def __UCLIBC_HAS_IPV6__ */
+ addri->ai_family == AF_INET6 ? sa6_to_uint8(addri->ai_addr) :
+#endif
+ sa4_to_uint32(addri->ai_addr);
+ freeaddrinfo(addri);
+ }
+ result_buf->n_aliases = tok;
+ *result = result_buf;
+ ret = 0;
+ DONE:
+ __UCLIBC_MUTEX_UNLOCK(mylock);
+ DONE_NOUNLOCK:
+ errno = ret;
+ return errno;
+}
+libc_hidden_def(getnetent_r)
+
+static void __initbuf(void)
+{
+ if (!netbuf) {
+ netbuf = malloc(SBUFSIZE);
+ if (!netbuf)
+ abort();
+ }
+}
+
+struct netent *getnetent(void)
+{
+ struct netent *result;
+ int herrnop;
+
+ __initbuf();
+ getnetent_r(&nete, netbuf, SBUFSIZE, &result, &herrnop);
+ return result;
+}
+
+int getnetbyname_r(const char *name,
+ struct netent *result_buf, char *buf, size_t buflen,
+ struct netent **result,
+ int *h_errnop
+ )
+{
+ register char **cp;
+ int ret, herrnop;
+
+ __UCLIBC_MUTEX_LOCK(mylock);
+ setnetent(net_stayopen);
+ while (!(ret = getnetent_r(result_buf, buf, buflen, result, &herrnop))) {
+ if (strcmp(name, result_buf->n_name) == 0)
+ break;
+ for (cp = result_buf->n_aliases; *cp; cp++)
+ if (strcmp(name, *cp) == 0)
+ goto gotname;
+ }
+ gotname:
+ if (!net_stayopen)
+ endnetent();
+ __UCLIBC_MUTEX_UNLOCK(mylock);
+ return *result ? 0 : ret;
+}
+libc_hidden_def(getnetbyname_r)
+
+struct netent *getnetbyname(const char *name)
+{
+ struct netent *result;
+ int herrnop;
+
+ __initbuf();
+ getnetbyname_r(name, &nete, netbuf, SBUFSIZE, &result, &herrnop);
+ return result;
+}
+
+int getnetbyaddr_r(uint32_t net, int type,
+ struct netent *result_buf, char *buf,
+ size_t buflen, struct netent **result,
+ int *h_errnop)
+{
+ int ret, herrnop;
+
+ __UCLIBC_MUTEX_LOCK(mylock);
+ setnetent(net_stayopen);
+ while (!(ret = getnetent_r(result_buf, buf, buflen, result, &herrnop))) {
+ if (net == result_buf->n_net && type == result_buf->n_addrtype)
+ break;
+ }
+ if (!net_stayopen)
+ endnetent();
+ __UCLIBC_MUTEX_UNLOCK(mylock);
+ return *result ? 0 : ret;
+}
+libc_hidden_def(getnetbyaddr_r)
+
+struct netent *getnetbyaddr(uint32_t net, int type)
+{
+ struct netent *result;
+ int herrnop;
+
+ __initbuf();
+ getnetbyaddr_r(net, type, &nete, netbuf, SBUFSIZE, &result, &herrnop);
+ return result;
+}
+
diff --git a/libc/inet/getnetbyad.c b/libc/inet/getnetbyad.c
deleted file mode 100644
index c916a18cf..000000000
--- a/libc/inet/getnetbyad.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 1983 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#define __FORCE_GLIBC
-#include <features.h>
-#include <netdb.h>
-#include <unistd.h>
-
-libc_hidden_proto(setnetent)
-libc_hidden_proto(getnetent)
-libc_hidden_proto(endnetent)
-
-extern smallint _net_stayopen attribute_hidden;
-
-struct netent *getnetbyaddr (uint32_t net, int type)
-{
- register struct netent *p;
-
- setnetent(_net_stayopen);
- while ((p = getnetent()))
- if (p->n_addrtype == type && p->n_net == net)
- break;
- if (!_net_stayopen)
- endnetent();
- return (p);
-}
diff --git a/libc/inet/getnetbynm.c b/libc/inet/getnetbynm.c
deleted file mode 100644
index 9f3655121..000000000
--- a/libc/inet/getnetbynm.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 1983 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#define __FORCE_GLIBC
-#include <features.h>
-#include <netdb.h>
-#include <string.h>
-#include <unistd.h>
-
-/* Experimentally off - libc_hidden_proto(strcmp) */
-libc_hidden_proto(setnetent)
-libc_hidden_proto(getnetent)
-libc_hidden_proto(endnetent)
-
-extern smallint _net_stayopen attribute_hidden;
-
-struct netent *
-getnetbyname(const char *name)
-{
- register struct netent *p;
- register char **cp;
-
- setnetent(_net_stayopen);
- while ((p = getnetent())) {
- if (strcmp(p->n_name, name) == 0)
- break;
- for (cp = p->n_aliases; *cp != 0; cp++)
- if (strcmp(*cp, name) == 0)
- goto found;
- }
-found:
- if (!_net_stayopen)
- endnetent();
- return (p);
-}
diff --git a/libc/inet/getnetent.c b/libc/inet/getnetent.c
deleted file mode 100644
index 863266d48..000000000
--- a/libc/inet/getnetent.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (c) 1983 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#define __FORCE_GLIBC
-#include <features.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <netdb.h>
-#include <arpa/inet.h>
-#include <unistd.h>
-
-libc_hidden_proto(fopen)
-libc_hidden_proto(fclose)
-libc_hidden_proto(inet_network)
-libc_hidden_proto(rewind)
-libc_hidden_proto(fgets)
-libc_hidden_proto(abort)
-
-#include <bits/uClibc_mutex.h>
-__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER);
-
-
-
-#define MAXALIASES 35
-static const char NETDB[] = _PATH_NETWORKS;
-static FILE *netf = NULL;
-static char *line = NULL;
-static struct netent net;
-static char *net_aliases[MAXALIASES];
-
-smallint _net_stayopen attribute_hidden;
-
-libc_hidden_proto(setnetent)
-void setnetent(int f)
-{
- __UCLIBC_MUTEX_LOCK(mylock);
- if (netf == NULL)
- netf = fopen(NETDB, "r" );
- else
- rewind(netf);
- if (f) _net_stayopen = 1;
- __UCLIBC_MUTEX_UNLOCK(mylock);
- return;
-}
-libc_hidden_def(setnetent)
-
-libc_hidden_proto(endnetent)
-void endnetent(void)
-{
- __UCLIBC_MUTEX_LOCK(mylock);
- if (netf) {
- fclose(netf);
- netf = NULL;
- }
- _net_stayopen = 0;
- __UCLIBC_MUTEX_UNLOCK(mylock);
-}
-libc_hidden_def(endnetent)
-
-static char * any(register char *cp, char *match)
-{
- register char *mp, c;
-
- while ((c = *cp)) {
- for (mp = match; *mp; mp++)
- if (*mp == c)
- return (cp);
- cp++;
- }
- return ((char *)0);
-}
-
-libc_hidden_proto(getnetent)
-struct netent *getnetent(void)
-{
- char *p;
- register char *cp, **q;
- struct netent *rv = NULL;
-
- __UCLIBC_MUTEX_LOCK(mylock);
- if (netf == NULL && (netf = fopen(NETDB, "r" )) == NULL) {
- goto DONE;
- }
-again:
-
- if (!line) {
- line = malloc(BUFSIZ + 1);
- if (!line)
- abort();
- }
-
- p = fgets(line, BUFSIZ, netf);
- if (p == NULL) {
- goto DONE;
- }
- if (*p == '#')
- goto again;
- cp = any(p, "#\n");
- if (cp == NULL)
- goto again;
- *cp = '\0';
- net.n_name = p;
- cp = any(p, " \t");
- if (cp == NULL)
- goto again;
- *cp++ = '\0';
- while (*cp == ' ' || *cp == '\t')
- cp++;
- p = any(cp, " \t");
- if (p != NULL)
- *p++ = '\0';
- net.n_net = inet_network(cp);
- net.n_addrtype = AF_INET;
- q = net.n_aliases = net_aliases;
- if (p != NULL)
- cp = p;
- while (cp && *cp) {
- if (*cp == ' ' || *cp == '\t') {
- cp++;
- continue;
- }
- if (q < &net_aliases[MAXALIASES - 1])
- *q++ = cp;
- cp = any(cp, " \t");
- if (cp != NULL)
- *cp++ = '\0';
- }
- *q = NULL;
- rv = &net;
-DONE:
- __UCLIBC_MUTEX_UNLOCK(mylock);
- return rv;
-}
-libc_hidden_def(getnetent)
diff --git a/libc/inet/getproto.c b/libc/inet/getproto.c
index a079f6487..c59da7e66 100644
--- a/libc/inet/getproto.c
+++ b/libc/inet/getproto.c
@@ -1,279 +1,182 @@
+/* vi: set sw=4 ts=4: */
/*
-** protocols.c /etc/protocols access functions
-**
-** This file is part of the NYS Library.
-**
-** The NYS 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 NYS 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 NYS Library; see the file COPYING.LIB. If
-** not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-** Cambridge, MA 02139, USA.
-**
-**
-** Copyright (c) 1983 Regents of the University of California.
-** All rights reserved.
-**
-** Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions
-** are met:
-** 1. Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** 2. Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in the
-** documentation and/or other materials provided with the distribution.
-** 3. All advertising materials mentioning features or use of this software
-** must display the following acknowledgement:
-** This product includes software developed by the University of
-** California, Berkeley and its contributors.
-** 4. Neither the name of the University nor the names of its contributors
-** may be used to endorse or promote products derived from this software
-** without specific prior written permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-** ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-** SUCH DAMAGE.
+ * Copyright (C) 2010 Bernhard Reutner-Fischer <uclibc@uclibc.org>
+ *
+ * Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+/* /etc/protocols
+# protocol-name number [aliases ...]
+ip 0 IP # internet protocol, pseudo protocol number
+
+protocol-name: case sensitive friendly name of the IP protocol
+number: decimal protocol number
+aliases: case sensitive optional space or tab separated list of other names
*/
-#define __FORCE_GLIBC
#include <features.h>
-#include <sys/types.h>
-#include <sys/socket.h>
#include <netdb.h>
-#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
+#include <stdlib.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
#include <errno.h>
#include <unistd.h>
-
-libc_hidden_proto(fopen)
-/* Experimentally off - libc_hidden_proto(strcmp) */
-/* Experimentally off - libc_hidden_proto(strpbrk) */
-libc_hidden_proto(atoi)
-libc_hidden_proto(rewind)
-libc_hidden_proto(fgets)
-libc_hidden_proto(fclose)
-libc_hidden_proto(abort)
+#include "internal/parse_config.h"
#include <bits/uClibc_mutex.h>
__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP);
+#define MINTOKENS 2
+#define MAXALIASES 8 /* will probably never be more than one */
+#define MAXTOKENS (MINTOKENS + MAXALIASES + 1)
+#define BUFSZ (255) /* one line */
+#define SBUFSIZE (BUFSZ + 1 + (sizeof(char *) * MAXTOKENS))
-
-#define MAXALIASES 35
-#define SBUFSIZE (BUFSIZ + 1 + (sizeof(char *) * MAXALIASES))
-
-static FILE *protof = NULL;
-static struct protoent proto;
-static char *static_aliases = NULL;
+static parser_t *protop = NULL;
+static struct protoent protoe;
+static char *protobuf = NULL;
static smallint proto_stayopen;
-static void __initbuf(void)
+void setprotoent(int stayopen)
{
- if (!static_aliases) {
- static_aliases = malloc(SBUFSIZE);
- if (!static_aliases)
- abort();
- }
-}
-
-libc_hidden_proto(setprotoent)
-void setprotoent(int f)
-{
- __UCLIBC_MUTEX_LOCK(mylock);
- if (protof == NULL)
- protof = fopen(_PATH_PROTOCOLS, "r" );
- else
- rewind(protof);
- if (f) proto_stayopen = 1;
- __UCLIBC_MUTEX_UNLOCK(mylock);
+ __UCLIBC_MUTEX_LOCK(mylock);
+ if (protop)
+ config_close(protop);
+ protop = config_open(_PATH_PROTOCOLS);
+ if (stayopen)
+ proto_stayopen = 1;
+ __UCLIBC_MUTEX_UNLOCK(mylock);
}
libc_hidden_def(setprotoent)
-libc_hidden_proto(endprotoent)
void endprotoent(void)
{
- __UCLIBC_MUTEX_LOCK(mylock);
- if (protof) {
- fclose(protof);
- protof = NULL;
- }
- proto_stayopen = 0;
- __UCLIBC_MUTEX_UNLOCK(mylock);
+ __UCLIBC_MUTEX_LOCK(mylock);
+ if (protop) {
+ config_close(protop);
+ protop = NULL;
+ }
+ proto_stayopen = 0;
+ __UCLIBC_MUTEX_UNLOCK(mylock);
}
libc_hidden_def(endprotoent)
-libc_hidden_proto(getprotoent_r)
int getprotoent_r(struct protoent *result_buf,
- char *buf, size_t buflen,
- struct protoent **result)
+ char *buf, size_t buflen, struct protoent **result)
{
- char *p;
- register char *cp, **q;
- char **proto_aliases;
- char *line;
- int rv;
-
- *result = NULL;
-
- if (buflen < sizeof(*proto_aliases)*MAXALIASES) {
- errno=ERANGE;
+ char **tok = NULL;
+ const size_t aliaslen = sizeof(char *) * MAXTOKENS;
+ int ret = ERANGE;
+
+ *result = NULL;
+ if (buflen < aliaslen
+ || (buflen - aliaslen) < BUFSZ + 1)
+ goto DONE_NOUNLOCK;
+
+ __UCLIBC_MUTEX_LOCK(mylock);
+ //tok = (char **) buf;
+ ret = ENOENT;
+ if (protop == NULL)
+ setprotoent(proto_stayopen);
+ if (protop == NULL)
+ goto DONE;
+ protop->data = buf;
+ protop->data_len = aliaslen;
+ protop->line_len = buflen - aliaslen;
+ /* <name>[[:space:]]<protonumber>[[:space:]][<aliases>] */
+ if (!config_read(protop, &tok, MAXTOKENS - 1, MINTOKENS, "# \t/", PARSE_NORMAL)) {
+ goto DONE;
+ }
+ result_buf->p_name = *(tok++);
+ result_buf->p_proto = atoi(*(tok++));
+ result_buf->p_aliases = tok;
+ *result = result_buf;
+ ret = 0;
+ DONE:
+ __UCLIBC_MUTEX_UNLOCK(mylock);
+ DONE_NOUNLOCK:
+ errno = ret;
return errno;
- }
- __UCLIBC_MUTEX_LOCK(mylock);
- proto_aliases=(char **)buf;
- buf+=sizeof(*proto_aliases)*MAXALIASES;
- buflen-=sizeof(*proto_aliases)*MAXALIASES;
-
- if (buflen < BUFSIZ+1) {
- errno=rv=ERANGE;
- goto DONE;
- }
- line=buf;
- buf+=BUFSIZ+1;
- buflen-=BUFSIZ+1;
-
- if (protof == NULL && (protof = fopen(_PATH_PROTOCOLS, "r" )) == NULL) {
- rv=errno;
- goto DONE;
- }
-again:
- if ((p = fgets(line, BUFSIZ, protof)) == NULL) {
- rv=TRY_AGAIN;
- goto DONE;
- }
+}
+libc_hidden_def(getprotoent_r)
- if (*p == '#')
- goto again;
- cp = strpbrk(p, "#\n");
- if (cp == NULL)
- goto again;
- *cp = '\0';
- result_buf->p_name = p;
- cp = strpbrk(p, " \t");
- if (cp == NULL)
- goto again;
- *cp++ = '\0';
- while (*cp == ' ' || *cp == '\t')
- cp++;
- p = strpbrk(cp, " \t");
- if (p != NULL)
- *p++ = '\0';
- result_buf->p_proto = atoi(cp);
- q = result_buf->p_aliases = proto_aliases;
- if (p != NULL) {
- cp = p;
- while (cp && *cp) {
- if (*cp == ' ' || *cp == '\t') {
- cp++;
- continue;
- }
- if (q < &proto_aliases[MAXALIASES - 1])
- *q++ = cp;
- cp = strpbrk(cp, " \t");
- if (cp != NULL)
- *cp++ = '\0';
+static void __initbuf(void)
+{
+ if (!protobuf) {
+ protobuf = malloc(SBUFSIZE);
+ if (!protobuf)
+ abort();
}
- }
- *q = NULL;
- *result=result_buf;
- rv = 0;
-DONE:
- __UCLIBC_MUTEX_UNLOCK(mylock);
- return rv;
}
-libc_hidden_def(getprotoent_r)
-struct protoent * getprotoent(void)
+struct protoent *getprotoent(void)
{
- struct protoent *result;
+ struct protoent *result;
- __initbuf();
- getprotoent_r(&proto, static_aliases, SBUFSIZE, &result);
- return result;
+ __initbuf();
+ getprotoent_r(&protoe, protobuf, SBUFSIZE, &result);
+ return result;
}
-
-libc_hidden_proto(getprotobyname_r)
int getprotobyname_r(const char *name,
- struct protoent *result_buf,
- char *buf, size_t buflen,
- struct protoent **result)
+ struct protoent *result_buf, char *buf, size_t buflen,
+ struct protoent **result)
{
- register char **cp;
- int ret;
-
- __UCLIBC_MUTEX_LOCK(mylock);
- setprotoent(proto_stayopen);
- while (!(ret=getprotoent_r(result_buf, buf, buflen, result))) {
- if (strcmp(result_buf->p_name, name) == 0)
- break;
- for (cp = result_buf->p_aliases; *cp != 0; cp++)
- if (strcmp(*cp, name) == 0)
- goto found;
- }
-found:
- if (!proto_stayopen)
- endprotoent();
- __UCLIBC_MUTEX_UNLOCK(mylock);
- return *result?0:ret;
+ register char **cp;
+ int ret;
+
+ __UCLIBC_MUTEX_LOCK(mylock);
+ setprotoent(proto_stayopen);
+ while (!(ret = getprotoent_r(result_buf, buf, buflen, result))) {
+ if (strcmp(name, result_buf->p_name) == 0)
+ break;
+ for (cp = result_buf->p_aliases; *cp; cp++)
+ if (strcmp(name, *cp) == 0)
+ goto gotname;
+ }
+ gotname:
+ if (!proto_stayopen)
+ endprotoent();
+ __UCLIBC_MUTEX_UNLOCK(mylock);
+ return *result ? 0 : ret;
}
libc_hidden_def(getprotobyname_r)
-
-struct protoent * getprotobyname(const char *name)
+struct protoent *getprotobyname(const char *name)
{
- struct protoent *result;
+ struct protoent *result;
- __initbuf();
- getprotobyname_r(name, &proto, static_aliases, SBUFSIZE, &result);
- return result;
+ __initbuf();
+ getprotobyname_r(name, &protoe, protobuf, SBUFSIZE, &result);
+ return result;
}
-
-libc_hidden_proto(getprotobynumber_r)
-int getprotobynumber_r (int proto_num,
- struct protoent *result_buf,
- char *buf, size_t buflen,
- struct protoent **result)
+int getprotobynumber_r(int proto,
+ struct protoent *result_buf, char *buf,
+ size_t buflen, struct protoent **result)
{
- int ret;
+ int ret;
- __UCLIBC_MUTEX_LOCK(mylock);
- setprotoent(proto_stayopen);
- while (!(ret=getprotoent_r(result_buf, buf, buflen, result)))
- if (result_buf->p_proto == proto_num)
- break;
- if (!proto_stayopen)
- endprotoent();
- __UCLIBC_MUTEX_UNLOCK(mylock);
- return *result?0:ret;
+ __UCLIBC_MUTEX_LOCK(mylock);
+ setprotoent(proto_stayopen);
+ while (!(ret = getprotoent_r(result_buf, buf, buflen, result))) {
+ if (proto == result_buf->p_proto)
+ break;
+ }
+ if (!proto_stayopen)
+ endprotoent();
+ __UCLIBC_MUTEX_UNLOCK(mylock);
+ return *result ? 0 : ret;
}
libc_hidden_def(getprotobynumber_r)
-struct protoent * getprotobynumber(int proto_num)
+struct protoent *getprotobynumber(int proto)
{
- struct protoent *result;
+ struct protoent *result;
- __initbuf();
- getprotobynumber_r(proto_num, &proto, static_aliases,
- SBUFSIZE, &result);
- return result;
+ __initbuf();
+ getprotobynumber_r(proto, &protoe, protobuf, SBUFSIZE, &result);
+ return result;
}
diff --git a/libc/inet/getservice.c b/libc/inet/getservice.c
index bb1d6d2e4..183099f5c 100644
--- a/libc/inet/getservice.c
+++ b/libc/inet/getservice.c
@@ -1,285 +1,190 @@
+/* vi: set sw=4 ts=4: */
/*
-** services.c /etc/services access functions
-**
-** This file is part of the NYS Library.
-**
-** The NYS 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 NYS 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 NYS Library; see the file COPYING.LIB. If
-** not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-** Cambridge, MA 02139, USA.
-**
-**
-** Copyright (c) 1983 Regents of the University of California.
-** All rights reserved.
-**
-** Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions
-** are met:
-** 1. Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** 2. Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in the
-** documentation and/or other materials provided with the distribution.
-** 3. All advertising materials mentioning features or use of this software
-** must display the following acknowledgement:
-** This product includes software developed by the University of
-** California, Berkeley and its contributors.
-** 4. Neither the name of the University nor the names of its contributors
-** may be used to endorse or promote products derived from this software
-** without specific prior written permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-** ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-** SUCH DAMAGE.
+ * Copyright (C) 2010 Bernhard Reutner-Fischer <uclibc@uclibc.org>
+ *
+ * Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+/* /etc/services
+# service-name port/protocol [aliases ...]
+discard 9/udp sink null
+
+service-name: case sensitive friendly name of the service
+port: decimal port number
+protocol: protocols(5) compatible entry
+aliases: case sensitive optional space or tab separated list of other names
*/
-#define __FORCE_GLIBC
#include <features.h>
-#include <sys/types.h>
-#include <sys/socket.h>
#include <netdb.h>
-#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
#include <unistd.h>
-
-/* Experimentally off - libc_hidden_proto(strcmp) */
-/* Experimentally off - libc_hidden_proto(strpbrk) */
-libc_hidden_proto(fopen)
-libc_hidden_proto(fclose)
-libc_hidden_proto(atoi)
-libc_hidden_proto(rewind)
-libc_hidden_proto(fgets)
-libc_hidden_proto(abort)
+#include "internal/parse_config.h"
#include <bits/uClibc_mutex.h>
__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP);
+#define MINTOKENS 3
+#define MAXALIASES 8 /* we seldomly need more than 1 alias */
+#define MAXTOKENS (MINTOKENS + MAXALIASES + 1)
+#define BUFSZ (255) /* one line */
+#define SBUFSIZE (BUFSZ + 1 + (sizeof(char *) * MAXTOKENS))
-
-
-#define MAXALIASES 35
-#define SBUFSIZE (BUFSIZ + 1 + (sizeof(char *) * MAXALIASES))
-
-static FILE *servf = NULL;
-static struct servent serv;
+static parser_t *servp = NULL;
+static struct servent serve;
static char *servbuf = NULL;
+static size_t servbuf_sz = SBUFSIZE;
static smallint serv_stayopen;
-static void __initbuf(void)
+void setservent(int stayopen)
{
- if (!servbuf) {
- servbuf = malloc(SBUFSIZE);
- if (!servbuf)
- abort();
- }
-}
-
-libc_hidden_proto(setservent)
-void setservent(int f)
-{
- __UCLIBC_MUTEX_LOCK(mylock);
- if (servf == NULL)
- servf = fopen(_PATH_SERVICES, "r" );
- else
- rewind(servf);
- if (f) serv_stayopen = 1;
- __UCLIBC_MUTEX_UNLOCK(mylock);
+ __UCLIBC_MUTEX_LOCK(mylock);
+ if (servp)
+ config_close(servp);
+ servp = config_open(_PATH_SERVICES);
+ if (stayopen)
+ serv_stayopen = 1;
+ __UCLIBC_MUTEX_UNLOCK(mylock);
}
libc_hidden_def(setservent)
-libc_hidden_proto(endservent)
void endservent(void)
{
- __UCLIBC_MUTEX_LOCK(mylock);
- if (servf) {
- fclose(servf);
- servf = NULL;
- }
- serv_stayopen = 0;
- __UCLIBC_MUTEX_UNLOCK(mylock);
+ __UCLIBC_MUTEX_LOCK(mylock);
+ if (servp) {
+ config_close(servp);
+ servp = NULL;
+ }
+ serv_stayopen = 0;
+ __UCLIBC_MUTEX_UNLOCK(mylock);
}
libc_hidden_def(endservent)
-libc_hidden_proto(getservent_r)
-int getservent_r(struct servent * result_buf,
- char * buf, size_t buflen,
- struct servent ** result)
+int getservent_r(struct servent *result_buf,
+ char *buf, size_t buflen, struct servent **result)
{
- char *p;
- register char *cp, **q;
- char **serv_aliases;
- char *line;
- int rv;
-
- *result=NULL;
-
- if (buflen < sizeof(*serv_aliases)*MAXALIASES) {
- errno=ERANGE;
- return errno;
- }
- __UCLIBC_MUTEX_LOCK(mylock);
- serv_aliases=(char **)buf;
- buf+=sizeof(*serv_aliases)*MAXALIASES;
- buflen-=sizeof(*serv_aliases)*MAXALIASES;
-
- if (buflen < BUFSIZ+1) {
- errno=rv=ERANGE;
- goto DONE;
- }
- line=buf;
- buf+=BUFSIZ+1;
- buflen-=BUFSIZ+1;
-
- if (servf == NULL && (servf = fopen(_PATH_SERVICES, "r" )) == NULL) {
- errno=rv=EIO;
- goto DONE;
- }
-again:
- if ((p = fgets(line, BUFSIZ, servf)) == NULL) {
- errno=rv=EIO;
- goto DONE;
- }
- if (*p == '#')
- goto again;
- cp = strpbrk(p, "#\n");
- if (cp == NULL)
- goto again;
- *cp = '\0';
- result_buf->s_name = p;
- p = strpbrk(p, " \t");
- if (p == NULL)
- goto again;
- *p++ = '\0';
- while (*p == ' ' || *p == '\t')
- p++;
- cp = strpbrk(p, ",/");
- if (cp == NULL)
- goto again;
- *cp++ = '\0';
- result_buf->s_port = htons((u_short)atoi(p));
- result_buf->s_proto = cp;
- q = result_buf->s_aliases = serv_aliases;
- cp = strpbrk(cp, " \t");
- if (cp != NULL)
- *cp++ = '\0';
- while (cp && *cp) {
- if (*cp == ' ' || *cp == '\t') {
- cp++;
- continue;
+ char **tok = NULL;
+ const size_t aliaslen = sizeof(char *) * MAXTOKENS;
+ int ret = ERANGE;
+
+ *result = NULL;
+ if (buflen < aliaslen
+ || (buflen - aliaslen) < BUFSZ + 1)
+ goto DONE_NOUNLOCK;
+
+ __UCLIBC_MUTEX_LOCK(mylock);
+ ret = ENOENT;
+ if (servp == NULL)
+ setservent(serv_stayopen);
+ if (servp == NULL)
+ goto DONE;
+
+ servp->data = buf;
+ servp->data_len = aliaslen;
+ servp->line_len = buflen - aliaslen;
+ /* <name>[[:space:]]<port>/<proto>[[:space:]][<aliases>] */
+ if (!config_read(servp, &tok, MAXTOKENS - 1, MINTOKENS, "# \t/", PARSE_NORMAL)) {
+ goto DONE;
}
- if (q < &serv_aliases[MAXALIASES - 1])
- *q++ = cp;
- cp = strpbrk(cp, " \t");
- if (cp != NULL)
- *cp++ = '\0';
- }
- *q = NULL;
- *result=result_buf;
- rv = 0;
-DONE:
- __UCLIBC_MUTEX_UNLOCK(mylock);
- return rv;
+ result_buf->s_name = *(tok++);
+ result_buf->s_port = htons((u_short) atoi(*(tok++)));
+ result_buf->s_proto = *(tok++);
+ result_buf->s_aliases = tok;
+ *result = result_buf;
+ ret = 0;
+ DONE:
+ __UCLIBC_MUTEX_UNLOCK(mylock);
+ DONE_NOUNLOCK:
+ errno = ret;
+ return errno;
}
libc_hidden_def(getservent_r)
-struct servent * getservent(void)
+static void __initbuf(void)
{
- struct servent *result;
+ if (!servbuf)
+ servbuf = malloc(SBUFSIZE);
+ if (!servbuf)
+ abort();
+}
- __initbuf();
- getservent_r(&serv, servbuf, SBUFSIZE, &result);
- return result;
+struct servent *getservent(void)
+{
+ struct servent *result;
+
+ __initbuf();
+ getservent_r(&serve, servbuf, servbuf_sz, &result);
+ return result;
}
-libc_hidden_proto(getservbyname_r)
int getservbyname_r(const char *name, const char *proto,
- struct servent * result_buf, char * buf, size_t buflen,
- struct servent ** result)
+ struct servent *result_buf, char *buf, size_t buflen,
+ struct servent **result)
{
- register char **cp;
- int ret;
-
- __UCLIBC_MUTEX_LOCK(mylock);
- setservent(serv_stayopen);
- while (!(ret=getservent_r(result_buf, buf, buflen, result))) {
- if (strcmp(name, result_buf->s_name) == 0)
- goto gotname;
- for (cp = result_buf->s_aliases; *cp; cp++)
- if (strcmp(name, *cp) == 0)
- goto gotname;
- continue;
-gotname:
- if (proto == 0 || strcmp(result_buf->s_proto, proto) == 0)
- break;
- }
- if (!serv_stayopen)
- endservent();
- __UCLIBC_MUTEX_UNLOCK(mylock);
- return *result?0:ret;
+ register char **cp;
+ int ret;
+
+ __UCLIBC_MUTEX_LOCK(mylock);
+ setservent(serv_stayopen);
+ while (!(ret = getservent_r(result_buf, buf, buflen, result))) {
+ if (strcmp(name, result_buf->s_name) == 0)
+ goto gotname;
+ for (cp = result_buf->s_aliases; *cp; cp++)
+ if (strcmp(name, *cp) == 0)
+ goto gotname;
+ continue;
+ gotname:
+ if (proto == 0 || strcmp(result_buf->s_proto, proto) == 0)
+ break;
+ }
+ if (!serv_stayopen)
+ endservent();
+ __UCLIBC_MUTEX_UNLOCK(mylock);
+ return *result ? 0 : ret;
}
libc_hidden_def(getservbyname_r)
struct servent *getservbyname(const char *name, const char *proto)
{
- struct servent *result;
+ struct servent *result;
- __initbuf();
- getservbyname_r(name, proto, &serv, servbuf, SBUFSIZE, &result);
- return result;
+ __initbuf();
+ getservbyname_r(name, proto, &serve, servbuf, servbuf_sz, &result);
+ return result;
}
-libc_hidden_proto(getservbyport_r)
int getservbyport_r(int port, const char *proto,
- struct servent * result_buf, char * buf,
- size_t buflen, struct servent ** result)
+ struct servent *result_buf, char *buf,
+ size_t buflen, struct servent **result)
{
- int ret;
-
- __UCLIBC_MUTEX_LOCK(mylock);
- setservent(serv_stayopen);
- while (!(ret=getservent_r(result_buf, buf, buflen, result))) {
- if (result_buf->s_port != port)
- continue;
- if (proto == 0 || strcmp(result_buf->s_proto, proto) == 0)
- break;
- }
- if (!serv_stayopen)
- endservent();
- __UCLIBC_MUTEX_UNLOCK(mylock);
- return *result?0:ret;
+ int ret;
+
+ __UCLIBC_MUTEX_LOCK(mylock);
+ setservent(serv_stayopen);
+ while (!(ret = getservent_r(result_buf, buf, buflen, result))) {
+ if (result_buf->s_port != port)
+ continue;
+ if (proto == 0 || strcmp(result_buf->s_proto, proto) == 0)
+ break;
+ }
+ if (!serv_stayopen)
+ endservent();
+ __UCLIBC_MUTEX_UNLOCK(mylock);
+ return *result ? 0 : ret;
}
libc_hidden_def(getservbyport_r)
-libc_hidden_proto(getservbyport)
-struct servent * getservbyport(int port, const char *proto)
+struct servent *getservbyport(int port, const char *proto)
{
- struct servent *result;
+ struct servent *result;
- __initbuf();
- getservbyport_r(port, proto, &serv, servbuf, SBUFSIZE, &result);
- return result;
+ __initbuf();
+ getservbyport_r(port, proto, &serve, servbuf, servbuf_sz, &result);
+ return result;
}
libc_hidden_def(getservbyport)
diff --git a/libc/inet/herror.c b/libc/inet/herror.c
index 063f6e93e..53d29ff3d 100644
--- a/libc/inet/herror.c
+++ b/libc/inet/herror.c
@@ -17,16 +17,12 @@
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define __FORCE_GLIBC
-#include <features.h>
#include <stdio.h>
#include <string.h>
#include <netdb.h>
-libc_hidden_proto(fprintf)
-libc_hidden_proto(__h_errno_location)
-static const char *error_msg = "Resolver error";
+static const char error_msg[] = "Resolver error";
static const char *const h_errlist[] = {
"Error 0",
"Unknown host", /* 1 HOST_NOT_FOUND */
@@ -39,7 +35,6 @@ static const int h_nerr = { sizeof(h_errlist)/sizeof(h_errlist[0]) };
/*
* herror -- print the error indicated by the h_errno value.
*/
-libc_hidden_proto(herror)
void herror(const char *s)
{
static const char colon_space[] = ": ";
@@ -52,7 +47,7 @@ void herror(const char *s)
}
p = error_msg;
if ((h_errno >= 0) && (h_errno < h_nerr)) {
- p = h_errlist[h_errno];
+ p = h_errlist[h_errno];
}
fprintf(stderr, "%s%s%s\n", s, c, p);
}
@@ -61,10 +56,8 @@ libc_hidden_def(herror)
const char *hstrerror(int err)
{
- if (err < 0) {
- return(error_msg);
- } else if (err < h_nerr) {
- return(h_errlist[err]);
- }
- return(error_msg);
+ if ((unsigned)err < h_nerr)
+ return(h_errlist[err]);
+
+ return error_msg;
}
diff --git a/libc/inet/hostid.c b/libc/inet/hostid.c
index 4972dcec2..d05a84f68 100644
--- a/libc/inet/hostid.c
+++ b/libc/inet/hostid.c
@@ -1,29 +1,18 @@
+/* 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.
*/
-#define __FORCE_GLIBC
-#include <features.h>
-#include <stdio.h>
-#include <string.h>
#include <errno.h>
-#include <sys/param.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <fcntl.h>
#include <unistd.h>
-
-/* Experimentally off - libc_hidden_proto(memcpy) */
-libc_hidden_proto(open)
-libc_hidden_proto(close)
-libc_hidden_proto(read)
-libc_hidden_proto(write)
-libc_hidden_proto(getuid)
-libc_hidden_proto(geteuid)
-libc_hidden_proto(gethostbyname_r)
-libc_hidden_proto(gethostname)
+#include <sys/types.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <netdb.h>
+#include <not-cancel.h>
#define HOSTID "/etc/hostid"
@@ -33,31 +22,34 @@ int sethostid(long int new_id)
int fd;
int ret;
- if (geteuid() || getuid()) return __set_errno(EPERM);
- if ((fd=open(HOSTID,O_CREAT|O_WRONLY,0644))<0) return -1;
- ret = write(fd,(void *)&new_id,sizeof(new_id)) == sizeof(new_id)
- ? 0 : -1;
- close (fd);
+ if (geteuid() || getuid())
+ return __set_errno(EPERM);
+ fd = open_not_cancel(HOSTID, O_CREAT|O_WRONLY, 0644);
+ if (fd < 0)
+ return fd;
+ ret = write_not_cancel(fd, &new_id, sizeof(new_id)) == sizeof(new_id) ? 0 : -1;
+ close_not_cancel_no_status (fd);
return ret;
}
#endif
+#define _addr(a) (((struct sockaddr_in*)a->ai_addr)->sin_addr.s_addr)
long int gethostid(void)
{
- char host[MAXHOSTNAMELEN + 1];
- int fd, id;
+ char host[HOST_NAME_MAX + 1];
+ int fd, id = 0;
/* If hostid was already set then we can return that value.
* It is not an error if we cannot read this file. It is not even an
* error if we cannot read all the bytes, we just carry on trying...
*/
- if ((fd=open(HOSTID,O_RDONLY))>=0 && read(fd,(void *)&id,sizeof(id)))
- {
- close (fd);
- return id;
+ fd = open_not_cancel_2(HOSTID, O_RDONLY);
+ if (fd >= 0) {
+ int i = read_not_cancel(fd, &id, sizeof(id));
+ close_not_cancel_no_status(fd);
+ if (i > 0)
+ return id;
}
- if (fd >= 0) close (fd);
-
/* Try some methods of returning a unique 32 bit id. Clearly IP
* numbers, if on the internet, will have a unique address. If they
* are not on the internet then we can return 0 which means they should
@@ -69,36 +61,18 @@ long int gethostid(void)
* setting one anyway.
* Mitch
*/
- if (gethostname(host,MAXHOSTNAMELEN)>=0 && *host) {
- struct hostent *hp;
- struct in_addr in;
- struct hostent ghbn_h;
- char ghbn_buf[sizeof(struct in_addr) +
- sizeof(struct in_addr *)*2 +
- sizeof(char *)*((2 + 5/*MAX_ALIASES*/ +
- 1)/*ALIAS_DIM*/) +
- 256/*namebuffer*/ + 32/* margin */];
- int ghbn_errno;
-
- /* replace gethostbyname() with gethostbyname_r() - ron@zing.net */
- /*if ((hp = gethostbyname(host)) == (struct hostent *)NULL)*/
- gethostbyname_r(host, &ghbn_h, ghbn_buf, sizeof(ghbn_buf), &hp, &ghbn_errno);
-
- if (hp == (struct hostent *)NULL)
-
- /* This is not a error if we get here, as all it means is that
- * this host is not on a network and/or they have not
- * configured their network properly. So we return the unset
- * hostid which should be 0, meaning that they should set it !!
- */
- return 0;
- else {
- memcpy((char *) &in, (char *) hp->h_addr, hp->h_length);
-
- /* Just so it doesn't look exactly like the IP addr */
- return(in.s_addr<<16|in.s_addr>>16);
+ if (gethostname(host, HOST_NAME_MAX) >= 0 && *host) {
+ struct addrinfo hints, *results, *addr;
+ memset(&hints, 0, sizeof(struct addrinfo));
+ if (!getaddrinfo(host, NULL, &hints, &results)) {
+ for (addr = results; addr; addr = results->ai_next) {
+ /* Just so it doesn't look exactly like the
+ IP addr */
+ id = _addr(addr) << 16 | _addr(addr) >> 16;
+ break;
+ }
+ freeaddrinfo(results);
}
}
- else return 0;
-
+ return id;
}
diff --git a/libc/inet/if_index.c b/libc/inet/if_index.c
index 36c6be45c..2d7ab27fa 100644
--- a/libc/inet/if_index.c
+++ b/libc/inet/if_index.c
@@ -13,15 +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; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>.
Reworked Dec 2002 by Erik Andersen <andersen@codepoet.org>
*/
-#define __FORCE_GLIBC
-#include <features.h>
#include <string.h>
#include <alloca.h>
#include <errno.h>
@@ -31,21 +28,12 @@
#include <net/if.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
-#include <libc-internal.h>
+#include <not-cancel.h>
#include "netlinkaccess.h"
-/* Experimentally off - libc_hidden_proto(strncpy) */
-/* Experimentally off - libc_hidden_proto(strdup) */
-libc_hidden_proto(ioctl)
-libc_hidden_proto(close)
-#if __ASSUME_NETLINK_SUPPORT
-/* Experimentally off - libc_hidden_proto(strndup) */
-#endif
-
extern int __opensock(void) attribute_hidden;
-libc_hidden_proto(if_nametoindex)
unsigned int
if_nametoindex(const char* ifname)
{
@@ -62,20 +50,20 @@ if_nametoindex(const char* ifname)
strncpy (ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
if (ioctl (fd, SIOCGIFINDEX, &ifr) < 0)
{
- int saved_errno = errno;
- close(fd);
- if (saved_errno == EINVAL)
- __set_errno(ENOSYS);
+ /* close never fails here, fd is just a unconnected socket.
+ *int saved_errno = errno; */
+ close_not_cancel_no_status(fd);
+ /*if (saved_errno == EINVAL)
+ * __set_errno(ENOSYS); */
return 0;
}
- close(fd);
+ close_not_cancel_no_status(fd);
return ifr.ifr_ifindex;
#endif
}
libc_hidden_def(if_nametoindex)
-libc_hidden_proto(if_freenameindex)
void
if_freenameindex (struct if_nameindex *ifn)
{
@@ -89,7 +77,6 @@ if_freenameindex (struct if_nameindex *ifn)
}
libc_hidden_def(if_freenameindex)
-libc_hidden_proto(if_nameindex)
#if !__ASSUME_NETLINK_SUPPORT
struct if_nameindex *
if_nameindex (void)
@@ -122,7 +109,7 @@ if_nameindex (void)
if (ioctl (fd, SIOCGIFCONF, &ifc) < 0)
{
- close (fd);
+ close_not_cancel_no_status (fd);
return NULL;
}
}
@@ -133,7 +120,7 @@ if_nameindex (void)
idx = malloc ((nifs + 1) * sizeof (struct if_nameindex));
if (idx == NULL)
{
- close(fd);
+ close_not_cancel_no_status (fd);
__set_errno(ENOBUFS);
return NULL;
}
@@ -151,7 +138,7 @@ if_nameindex (void)
for (j = 0; j < i; ++j)
free (idx[j].if_name);
free(idx);
- close(fd);
+ close_not_cancel_no_status (fd);
if (saved_errno == EINVAL)
saved_errno = ENOSYS;
else if (saved_errno == ENOMEM)
@@ -165,7 +152,7 @@ if_nameindex (void)
idx[i].if_index = 0;
idx[i].if_name = NULL;
- close(fd);
+ close_not_cancel_no_status (fd);
return idx;
#endif
}
@@ -308,14 +295,14 @@ if_indextoname (unsigned int ifindex, char *ifname)
if (ioctl (fd, SIOCGIFNAME, &ifr) < 0)
{
int serrno = errno;
- close (fd);
+ close_not_cancel_no_status (fd);
if (serrno == ENODEV)
/* POSIX requires ENXIO. */
serrno = ENXIO;
__set_errno (serrno);
return NULL;
}
- close (fd);
+ close_not_cancel_no_status (fd);
return strncpy (ifname, ifr.ifr_name, IFNAMSIZ);
# else
diff --git a/libc/inet/ifaddrs.c b/libc/inet/ifaddrs.c
index c60dcf76d..0c9310651 100644
--- a/libc/inet/ifaddrs.c
+++ b/libc/inet/ifaddrs.c
@@ -13,12 +13,9 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 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 <alloca.h>
#include <assert.h>
#include <errno.h>
@@ -33,23 +30,11 @@
#include <string.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
-#include <libc-internal.h>
#include <time.h>
#include <unistd.h>
#include "netlinkaccess.h"
-libc_hidden_proto(socket)
-libc_hidden_proto(close)
-/* Experimentally off - libc_hidden_proto(time) */
-libc_hidden_proto(sendto)
-libc_hidden_proto(recvmsg)
-libc_hidden_proto(bind)
-/* Experimentally off - libc_hidden_proto(memset) */
-/* Experimentally off - libc_hidden_proto(mempcpy) */
-libc_hidden_proto(getsockname)
-libc_hidden_proto(fclose)
-libc_hidden_proto(abort)
#ifndef __libc_use_alloca
# define __libc_use_alloca(x) (x < __MAX_ALLOCA_CUTOFF)
@@ -70,7 +55,9 @@ struct ifaddrs_storage
struct sockaddr sa;
struct sockaddr_ll sl;
struct sockaddr_in s4;
+#ifdef __UCLIBC_HAS_IPV6__
struct sockaddr_in6 s6;
+#endif
} addr, netmask, broadaddr;
char name[IF_NAMESIZE + 1];
};
@@ -81,7 +68,6 @@ void
__netlink_free_handle (struct netlink_handle *h)
{
struct netlink_res *ptr;
- int saved_errno = errno;
ptr = h->nlm_list;
while (ptr != NULL)
@@ -89,11 +75,9 @@ __netlink_free_handle (struct netlink_handle *h)
struct netlink_res *tmpptr;
tmpptr = ptr->next;
- free (ptr);
+ free (ptr); /* doesn't affect errno */
ptr = tmpptr;
}
-
- __set_errno (saved_errno);
}
@@ -131,7 +115,8 @@ __netlink_request (struct netlink_handle *h, int type)
{
struct netlink_res *nlm_next;
struct netlink_res **new_nlm_list;
- static volatile size_t buf_size = 4096;
+ static volatile size_t buf_size = 0;
+ size_t this_buf_size;
char *buf;
struct sockaddr_nl nladdr;
struct nlmsghdr *nlmh;
@@ -142,7 +127,15 @@ __netlink_request (struct netlink_handle *h, int type)
if (__netlink_sendreq (h, type) < 0)
return -1;
- size_t this_buf_size = buf_size;
+ if (buf_size)
+ this_buf_size = buf_size;
+ else {
+#ifdef PAGE_SIZE
+ this_buf_size = PAGE_SIZE;
+#else
+ this_buf_size = __pagesize;
+#endif
+ }
if (__libc_use_alloca (this_buf_size))
buf = alloca (this_buf_size);
else
@@ -308,9 +301,6 @@ __netlink_open (struct netlink_handle *h)
close_and_out:
__netlink_close (h);
out:
-#if __ASSUME_NETLINK_SUPPORT == 0
- __no_netlink_support = 1;
-#endif
return -1;
}
/* Determine the ID the kernel assigned for this netlink connection.
@@ -333,7 +323,7 @@ __netlink_open (struct netlink_handle *h)
that a RTM_NEWADDR index is not known to this map. */
static int
internal_function
-map_newlink (int index, struct ifaddrs_storage *ifas, int *map, int max)
+map_newlink (int idx, struct ifaddrs_storage *ifas, int *map, int max)
{
int i;
@@ -341,12 +331,12 @@ map_newlink (int index, struct ifaddrs_storage *ifas, int *map, int max)
{
if (map[i] == -1)
{
- map[i] = index;
+ map[i] = idx;
if (i > 0)
ifas[i - 1].ifa.ifa_next = &ifas[i].ifa;
return i;
}
- else if (map[i] == index)
+ else if (map[i] == idx)
return i;
}
/* This should never be reached. If this will be reached, we have
@@ -374,18 +364,11 @@ getifaddrs (struct ifaddrs **ifap)
if (ifap)
*ifap = NULL;
- if (! __no_netlink_support && __netlink_open (&nh) < 0)
+ if (__netlink_open (&nh) < 0)
{
-#if __ASSUME_NETLINK_SUPPORT != 0
return -1;
-#endif
}
-#if __ASSUME_NETLINK_SUPPORT == 0
- if (__no_netlink_support)
- return fallback_getifaddrs (ifap);
-#endif
-
/* Tell the kernel that we wish to get a list of all
active interfaces, collect all data for every interface. */
if (__netlink_request (&nh, RTM_GETLINK) < 0)
@@ -462,10 +445,7 @@ getifaddrs (struct ifaddrs **ifap)
/* Allocate memory for all entries we have and initialize next
pointer. */
- ifas = (struct ifaddrs_storage *) calloc (1,
- (newlink + newaddr)
- * sizeof (struct ifaddrs_storage)
- + ifa_data_size);
+ ifas = calloc (1, (newlink + newaddr) * sizeof (ifas[0]) + ifa_data_size);
if (ifas == NULL)
{
result = -1;
@@ -648,6 +628,7 @@ getifaddrs (struct ifaddrs **ifap)
rta_data, rta_payload);
break;
+#ifdef __UCLIBC_HAS_IPV6__
case AF_INET6:
/* Size must match that of an address for IPv6. */
if (rta_payload == 16)
@@ -660,6 +641,7 @@ getifaddrs (struct ifaddrs **ifap)
= ifam->ifa_index;
}
break;
+#endif
default:
if (rta_payload <= sizeof (ifas[ifa_index].addr))
@@ -695,6 +677,7 @@ getifaddrs (struct ifaddrs **ifap)
rta_data, rta_payload);
break;
+#ifdef __UCLIBC_HAS_IPV6__
case AF_INET6:
/* Size must match that of an address for IPv6. */
if (rta_payload == 16)
@@ -707,6 +690,7 @@ getifaddrs (struct ifaddrs **ifap)
ifam->ifa_index;
}
break;
+#endif
default:
if (rta_payload <= sizeof (ifas[ifa_index].addr))
@@ -736,6 +720,7 @@ getifaddrs (struct ifaddrs **ifap)
rta_data, rta_payload);
break;
+#ifdef __UCLIBC_HAS_IPV6__
case AF_INET6:
/* Size must match that of an address for IPv6. */
if (rta_payload == 16)
@@ -748,6 +733,7 @@ getifaddrs (struct ifaddrs **ifap)
= ifam->ifa_index;
}
break;
+#endif
default:
if (rta_payload <= sizeof (ifas[ifa_index].addr))
@@ -804,10 +790,12 @@ getifaddrs (struct ifaddrs **ifap)
max_prefixlen = 32;
break;
+#ifdef __UCLIBC_HAS_IPV6__
case AF_INET6:
cp = (char *) &ifas[ifa_index].netmask.s6.sin6_addr;
max_prefixlen = 128;
break;
+#endif
}
ifas[ifa_index].ifa.ifa_netmask->sa_family
@@ -862,15 +850,14 @@ getifaddrs (struct ifaddrs **ifap)
return result;
}
+libc_hidden_def(getifaddrs)
-
-#if __ASSUME_NETLINK_SUPPORT != 0
void
freeifaddrs (struct ifaddrs *ifa)
{
free (ifa);
}
-#endif
+libc_hidden_def(freeifaddrs)
#endif /* __UCLIBC_SUPPORT_AI_ADDRCONFIG__ */
diff --git a/libc/inet/in6_addr.c b/libc/inet/in6_addr.c
index c2ab375e6..2d0d0182f 100644
--- a/libc/inet/in6_addr.c
+++ b/libc/inet/in6_addr.c
@@ -13,18 +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/>. */
-#define __FORCE_GLIBC
-#include <features.h>
#include <netinet/in.h>
#ifdef __UCLIBC_HAS_IPV6__
const struct in6_addr in6addr_any =
{ { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } };
-libc_hidden_proto(in6addr_loopback)
const struct in6_addr in6addr_loopback =
{ { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } };
libc_hidden_data_def(in6addr_loopback)
diff --git a/libc/inet/inet_addr.c b/libc/inet/inet_addr.c
index 445f850a1..9f946967c 100644
--- a/libc/inet/inet_addr.c
+++ b/libc/inet/inet_addr.c
@@ -4,5 +4,5 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define L_inet_makeaddr
+#define L_inet_addr
#include "addr.c"
diff --git a/libc/inet/inet_makeaddr.c b/libc/inet/inet_makeaddr.c
index 9f946967c..445f850a1 100644
--- a/libc/inet/inet_makeaddr.c
+++ b/libc/inet/inet_makeaddr.c
@@ -4,5 +4,5 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define L_inet_addr
+#define L_inet_makeaddr
#include "addr.c"
diff --git a/libc/inet/inet_net.c b/libc/inet/inet_net.c
index e46c9a561..a1d2b3d85 100644
--- a/libc/inet/inet_net.c
+++ b/libc/inet/inet_net.c
@@ -32,24 +32,15 @@
* SUCH DAMAGE.
*/
-#define __FORCE_GLIBC
-#include <features.h>
#include <ctype.h>
#include <netinet/in.h>
#include <arpa/inet.h>
-#ifdef __UCLIBC_HAS_XLOCALE__
-libc_hidden_proto(__ctype_b_loc)
-#elif defined __UCLIBC_HAS_CTYPE_TABLES__
-libc_hidden_proto(__ctype_b)
-#endif
-
/*
* Internet network address interpretation routine.
* The library routines call this routine to interpret
* network numbers.
*/
-libc_hidden_proto(inet_network)
in_addr_t
inet_network(const char *cp)
{
diff --git a/libc/inet/lengthd.c b/libc/inet/lengthd.c
index 07c7fc6f1..d2db685b9 100644
--- a/libc/inet/lengthd.c
+++ b/libc/inet/lengthd.c
@@ -5,4 +5,4 @@
*/
#define L_lengthd
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/lengthq.c b/libc/inet/lengthq.c
index e62e6f25a..beeafc1d2 100644
--- a/libc/inet/lengthq.c
+++ b/libc/inet/lengthq.c
@@ -5,4 +5,4 @@
*/
#define L_lengthq
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/netlinkaccess.h b/libc/inet/netlinkaccess.h
index acadcb544..e9017cdd4 100644
--- a/libc/inet/netlinkaccess.h
+++ b/libc/inet/netlinkaccess.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 _NETLINKACCESS_H
#define _NETLINKACCESS_H 1
@@ -22,27 +21,11 @@
#include <features.h>
#include <stdint.h>
#include <unistd.h>
-#include <sys/types.h>
-
-#define _LINUX_TYPES_H
-typedef uint8_t __u8;
-typedef uint16_t __u16;
-typedef uint32_t __u32;
-typedef uint64_t __u64;
-typedef int32_t __s32;
+#if defined __ASSUME_NETLINK_SUPPORT || defined __UCLIBC_USE_NETLINK__
+#include <asm/types.h>
#include <linux/rtnetlink.h>
#include <linux/netlink.h>
-/* Should prob be a configure option or something */
-#ifndef __ASSUME_NETLINK_SUPPORT
-#ifdef __UCLIBC_USE_NETLINK__
-# define __ASSUME_NETLINK_SUPPORT 1
-#else
-# define __ASSUME_NETLINK_SUPPORT 0
-#endif
-#endif
-
-
struct netlink_res
{
struct netlink_res *next;
@@ -62,19 +45,17 @@ struct netlink_handle
};
-#ifdef __UCLIBC_SUPPORT_AI_ADDRCONFIG__
-#if __ASSUME_NETLINK_SUPPORT == 0
-extern smallint __no_netlink_support attribute_hidden;
-#else
-# define __no_netlink_support 0
+#ifndef __ASSUME_NETLINK_SUPPORT
+#define __ASSUME_NETLINK_SUPPORT 1
#endif
-#endif /* __UCLIBC_SUPPORT_AI_ADDRCONFIG__ */
-
extern int __netlink_open (struct netlink_handle *h) attribute_hidden;
extern void __netlink_close (struct netlink_handle *h) attribute_hidden;
extern void __netlink_free_handle (struct netlink_handle *h) attribute_hidden;
extern int __netlink_request (struct netlink_handle *h, int type) attribute_hidden;
+#else
+#define __ASSUME_NETLINK_SUPPORT 0
+#endif
-#endif /* netlinkaccess.h */
+#endif /* _NETLINKACCESS_H */
diff --git a/libc/inet/ns_name.c b/libc/inet/ns_name.c
index 158a1a331..9df9464a3 100644
--- a/libc/inet/ns_name.c
+++ b/libc/inet/ns_name.c
@@ -5,4 +5,4 @@
*/
#define L_ns_name
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/ns_netint.c b/libc/inet/ns_netint.c
new file mode 100644
index 000000000..acf88dc68
--- /dev/null
+++ b/libc/inet/ns_netint.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_ns_netint
+#include RESOLVER
diff --git a/libc/inet/ns_parse.c b/libc/inet/ns_parse.c
new file mode 100644
index 000000000..e7aecb421
--- /dev/null
+++ b/libc/inet/ns_parse.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_ns_parse
+#include RESOLVER
diff --git a/libc/inet/ntohl.c b/libc/inet/ntohl.c
index dfadf80d8..8e500a5e3 100644
--- a/libc/inet/ntohl.c
+++ b/libc/inet/ntohl.c
@@ -6,55 +6,37 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#include <stdint.h>
-#include <endian.h>
-#include <byteswap.h>
+#include <netinet/in.h>
-uint32_t ntohl (uint32_t x);
-uint16_t ntohs (uint16_t x);
-uint32_t htonl (uint32_t x);
-uint16_t htons (uint16_t x);
+#undef ntohl
+#undef ntohs
+#undef htonl
+#undef htons
-#if __BYTE_ORDER == __BIG_ENDIAN
-uint32_t ntohl (uint32_t x)
-{
- return x;
-}
-
-uint16_t ntohs (uint16_t x)
-{
- return x;
-}
-
-uint32_t htonl (uint32_t x)
-{
- return x;
-}
+#if __BYTE_ORDER != __BIG_ENDIAN && __BYTE_ORDER != __LITTLE_ENDIAN
+# error "You seem to have an unsupported byteorder"
+#endif
-uint16_t htons (uint16_t x)
-{
- return x;
-}
-#elif __BYTE_ORDER == __LITTLE_ENDIAN
uint32_t ntohl (uint32_t x)
{
+#if __BYTE_ORDER == __BIG_ENDIAN
+ return x;
+#else
return __bswap_32(x);
+#endif
}
+libc_hidden_def(ntohl)
+strong_alias(ntohl,htonl)
+libc_hidden_def(htonl)
uint16_t ntohs (uint16_t x)
{
- return __bswap_16(x);
-}
-
-uint32_t htonl (uint32_t x)
-{
- return __bswap_32(x);
-}
-
-uint16_t htons (uint16_t x)
-{
- return __bswap_16(x);
-}
+#if __BYTE_ORDER == __BIG_ENDIAN
+ return x;
#else
-#error "You seem to have an unsupported byteorder"
+ return __bswap_16(x);
#endif
+}
+libc_hidden_def(ntohs)
+strong_alias(ntohs,htons)
+libc_hidden_def(htons)
diff --git a/libc/inet/ntop.c b/libc/inet/ntop.c
index f19556dcd..30dde6f9c 100644
--- a/libc/inet/ntop.c
+++ b/libc/inet/ntop.c
@@ -15,8 +15,6 @@
* SOFTWARE.
*/
-#define __FORCE_GLIBC
-#include <features.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
@@ -30,13 +28,6 @@
#include <string.h>
#include <ctype.h>
-/* Experimentally off - libc_hidden_proto(memcpy) */
-/* Experimentally off - libc_hidden_proto(memset) */
-/* Experimentally off - libc_hidden_proto(strchr) */
-/* Experimentally off - libc_hidden_proto(strcpy) */
-/* Experimentally off - libc_hidden_proto(strlen) */
-libc_hidden_proto(sprintf)
-libc_hidden_proto(tolower)
/*
* WARNING: Don't even consider trying to compile this on a system where
@@ -58,17 +49,19 @@ libc_hidden_proto(tolower)
static const char *
inet_ntop4(const u_char *src, char *dst, size_t size)
{
- char tmp[sizeof ("255.255.255.255") + 1] = "\0";
+ char tmp[sizeof ("255.255.255.255") + 1];
int octet;
int i;
+ tmp[0] = '\0';
+
i = 0;
for (octet = 0; octet <= 3; octet++) {
#if 0 /* since src is unsigned char, it will never be > 255 ... */
if (src[octet] > 255) {
- __set_errno (ENOSPC);
- return (NULL);
+ __set_errno(ENOSPC);
+ return NULL;
}
#endif
tmp[i++] = '0' + src[octet] / 100;
@@ -83,9 +76,9 @@ inet_ntop4(const u_char *src, char *dst, size_t size)
}
tmp[i - 1] = '\0';
- if (strlen (tmp) > size) {
- __set_errno (ENOSPC);
- return (NULL);
+ if (strlen(tmp) > size) {
+ __set_errno(ENOSPC);
+ return NULL;
}
return strcpy(dst, tmp);
@@ -112,7 +105,7 @@ inet_ntop6(const u_char *src, char *dst, size_t size)
* to use pointer overlays. All the world's not a VAX.
*/
char tmp[sizeof ("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")], *tp;
- struct { int base, len; } best, cur;
+ struct { int base, len; } best = { 0, 0 }, cur = { 0, 0 };
u_int words[8];
int i;
@@ -168,7 +161,7 @@ inet_ntop6(const u_char *src, char *dst, size_t size)
if (i == 6 && best.base == 0 &&
(best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
if (!inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp)))
- return (NULL);
+ return NULL;
tp += strlen(tp);
break;
}
@@ -183,8 +176,8 @@ inet_ntop6(const u_char *src, char *dst, size_t size)
* Check for overflow, copy, and we're done.
*/
if ((size_t)(tp - tmp) > size) {
- __set_errno (ENOSPC);
- return (NULL);
+ __set_errno(ENOSPC);
+ return NULL;
}
return strcpy(dst, tmp);
}
@@ -216,25 +209,25 @@ inet_pton4(const char *src, u_char *dst)
u_int new = *tp * 10 + (ch - '0');
if (new > 255)
- return (0);
+ return 0;
*tp = new;
if (! saw_digit) {
if (++octets > 4)
- return (0);
+ return 0;
saw_digit = 1;
}
} else if (ch == '.' && saw_digit) {
if (octets == 4)
- return (0);
+ return 0;
*++tp = 0;
saw_digit = 0;
} else
- return (0);
+ return 0;
}
if (octets < 4)
- return (0);
+ return 0;
memcpy(dst, tmp, 4);
- return (1);
+ return 1;
}
/* int
@@ -253,13 +246,6 @@ inet_pton4(const char *src, u_char *dst)
#ifdef __UCLIBC_HAS_IPV6__
-/* We cannot use the macro version of tolower() or very bad
- * things happen when '*src++' gets evaluated multiple times.
- * So undef it here so we get the function version of tolower
- * instead.
- */
-#undef tolower
-
static int
inet_pton6(const char *src, u_char *dst)
{
@@ -276,19 +262,20 @@ inet_pton6(const char *src, u_char *dst)
/* Leading :: requires some special handling. */
if (*src == ':')
if (*++src != ':')
- return (0);
+ return 0;
curtok = src;
saw_xdigit = 0;
val = 0;
- while ((ch = tolower (*src++)) != '\0') {
+ while ((ch = *src++) != '\0') {
const char *pch;
- pch = strchr(xdigits, ch);
+ /* | 0x20 is cheap tolower(), valid for letters/numbers only */
+ pch = strchr(xdigits, (ch | 0x20));
if (pch != NULL) {
val <<= 4;
val |= (pch - xdigits);
if (val > 0xffff)
- return (0);
+ return 0;
saw_xdigit = 1;
continue;
}
@@ -296,16 +283,16 @@ inet_pton6(const char *src, u_char *dst)
curtok = src;
if (!saw_xdigit) {
if (colonp)
- return (0);
+ return 0;
colonp = tp;
continue;
- } else if (*src == '\0') {
- return (0);
}
+ if (*src == '\0')
+ return 0;
if (tp + 2 > endp)
- return (0);
- *tp++ = (u_char) (val >> 8) & 0xff;
- *tp++ = (u_char) val & 0xff;
+ return 0;
+ *tp++ = (u_char) (val >> 8);
+ *tp++ = (u_char) val;
saw_xdigit = 0;
val = 0;
continue;
@@ -316,13 +303,13 @@ inet_pton6(const char *src, u_char *dst)
saw_xdigit = 0;
break; /* '\0' was seen by inet_pton4(). */
}
- return (0);
+ return 0;
}
if (saw_xdigit) {
if (tp + 2 > endp)
- return (0);
- *tp++ = (u_char) (val >> 8) & 0xff;
- *tp++ = (u_char) val & 0xff;
+ return 0;
+ *tp++ = (u_char) (val >> 8);
+ *tp++ = (u_char) val;
}
if (colonp != NULL) {
/*
@@ -333,7 +320,7 @@ inet_pton6(const char *src, u_char *dst)
int i;
if (tp == endp)
- return (0);
+ return 0;
for (i = 1; i <= n; i++) {
endp[- i] = colonp[n - i];
colonp[n - i] = 0;
@@ -341,9 +328,9 @@ inet_pton6(const char *src, u_char *dst)
tp = endp;
}
if (tp != endp)
- return (0);
+ return 0;
memcpy(dst, tmp, 16);
- return (1);
+ return 1;
}
#endif /* __UCLIBC_HAS_IPV6__ */
@@ -358,20 +345,19 @@ inet_pton6(const char *src, u_char *dst)
* author:
* Paul Vixie, 1996.
*/
-libc_hidden_proto(inet_ntop)
const char *
inet_ntop(int af, const void *src, char *dst, socklen_t size)
{
switch (af) {
case AF_INET:
- return (inet_ntop4(src, dst, size));
+ return inet_ntop4(src, dst, size);
#ifdef __UCLIBC_HAS_IPV6__
case AF_INET6:
- return (inet_ntop6(src, dst, size));
+ return inet_ntop6(src, dst, size);
#endif
default:
- __set_errno (EAFNOSUPPORT);
- return (NULL);
+ __set_errno(EAFNOSUPPORT);
+ return NULL;
}
/* NOTREACHED */
}
@@ -389,20 +375,19 @@ libc_hidden_def(inet_ntop)
* author:
* Paul Vixie, 1996.
*/
-libc_hidden_proto(inet_pton)
int
inet_pton(int af, const char *src, void *dst)
{
switch (af) {
case AF_INET:
- return (inet_pton4(src, dst));
+ return inet_pton4(src, dst);
#ifdef __UCLIBC_HAS_IPV6__
case AF_INET6:
- return (inet_pton6(src, dst));
+ return inet_pton6(src, dst);
#endif
default:
- __set_errno (EAFNOSUPPORT);
- return (-1);
+ __set_errno(EAFNOSUPPORT);
+ return -1;
}
/* NOTREACHED */
}
diff --git a/libc/inet/opennameservers.c b/libc/inet/opennameservers.c
index effd10800..576c8cae3 100644
--- a/libc/inet/opennameservers.c
+++ b/libc/inet/opennameservers.c
@@ -5,4 +5,4 @@
*/
#define L_opennameservers
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/opensock.c b/libc/inet/opensock.c
index a2c09dcf5..ac7289029 100644
--- a/libc/inet/opensock.c
+++ b/libc/inet/opensock.c
@@ -12,32 +12,25 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 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 <assert.h>
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
#include <sys/socket.h>
-#include <features.h>
-#include <libc-internal.h>
-
-libc_hidden_proto(socket)
+#include <bits/kernel-features.h>
/* Return a socket of any type. The socket can be used in subsequent
ioctl calls to talk to the kernel. */
int __opensock(void) attribute_hidden;
int
-__opensock (void)
+__opensock(void)
{
- int fd;
+ int fd = -1;
#ifdef __UCLIBC_HAS_IPV6__
- fd = socket(AF_INET6, SOCK_DGRAM, 0);
- if (fd<0)
-#endif /* __UCLIBC_HAS_IPV6__ */
- fd = socket(AF_INET, SOCK_DGRAM, 0);
- return(fd);
+ fd = socket(AF_INET6, SOCK_DGRAM, 0);
+#endif
+#ifdef __UCLIBC_HAS_IPV4__
+ if (fd < 0)
+ fd = socket(AF_INET, SOCK_DGRAM, 0);
+#endif
+ return fd;
}
diff --git a/libc/inet/read_etc_hosts_r.c b/libc/inet/read_etc_hosts_r.c
index 6504e541f..1ec74a50d 100644
--- a/libc/inet/read_etc_hosts_r.c
+++ b/libc/inet/read_etc_hosts_r.c
@@ -5,4 +5,4 @@
*/
#define L_read_etc_hosts_r
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/res_comp.c b/libc/inet/res_comp.c
index 8aee6b17c..51ea4f2e6 100644
--- a/libc/inet/res_comp.c
+++ b/libc/inet/res_comp.c
@@ -5,4 +5,4 @@
*/
#define L_res_comp
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/res_data.c b/libc/inet/res_data.c
new file mode 100644
index 000000000..b554b93db
--- /dev/null
+++ b/libc/inet/res_data.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_res_data
+#include RESOLVER
diff --git a/libc/inet/res_init.c b/libc/inet/res_init.c
index 09caf4927..b1a175752 100644
--- a/libc/inet/res_init.c
+++ b/libc/inet/res_init.c
@@ -5,4 +5,4 @@
*/
#define L_res_init
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/res_query.c b/libc/inet/res_query.c
index c662510e6..f3e569fad 100644
--- a/libc/inet/res_query.c
+++ b/libc/inet/res_query.c
@@ -5,4 +5,4 @@
*/
#define L_res_query
-#include "resolv.c"
+#include RESOLVER
diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c
index 1f12be9b9..f378c9b9d 100644
--- a/libc/inet/resolv.c
+++ b/libc/inet/resolv.c
@@ -1,3 +1,4 @@
+/* vi: set sw=4 ts=4: */
/* resolv.c: DNS Resolver
*
* Copyright (C) 1998 Kenneth Albanowski <kjahds@kjahds.com>,
@@ -8,7 +9,6 @@
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*/
-
/*
* Portions Copyright (c) 1985, 1993
* The Regents of the University of California. All rights reserved.
@@ -37,7 +37,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-
/*
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
*
@@ -57,7 +56,6 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
-
/*
* Portions Copyright (c) 1996-1999 by Internet Software Consortium.
*
@@ -74,32 +72,25 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
-
/*
- *
* 5-Oct-2000 W. Greathouse wgreathouse@smva.com
- * Fix memory leak and memory corruption.
- * -- Every name resolution resulted in
- * a new parse of resolv.conf and new
- * copy of nameservers allocated by
- * strdup.
- * -- Every name resolution resulted in
- * a new read of resolv.conf without
- * resetting index from prior read...
- * resulting in exceeding array bounds.
- *
- * Limit nameservers read from resolv.conf
- *
- * Add "search" domains from resolv.conf
+ * Fix memory leak and memory corruption.
+ * -- Every name resolution resulted in
+ * a new parse of resolv.conf and new
+ * copy of nameservers allocated by
+ * strdup.
+ * -- Every name resolution resulted in
+ * a new read of resolv.conf without
+ * resetting index from prior read...
+ * resulting in exceeding array bounds.
*
- * Some systems will return a security
- * signature along with query answer for
- * dynamic DNS entries.
- * -- skip/ignore this answer
- *
- * Include arpa/nameser.h for defines.
- *
- * General cleanup
+ * Limit nameservers read from resolv.conf.
+ * Add "search" domains from resolv.conf.
+ * Some systems will return a security
+ * signature along with query answer for
+ * dynamic DNS entries -- skip/ignore this answer.
+ * Include arpa/nameser.h for defines.
+ * General cleanup.
*
* 20-Jun-2001 Michal Moskal <malekith@pld.org.pl>
* partial IPv6 support (i.e. gethostbyname2() and resolve_address2()
@@ -131,13 +122,182 @@
* 7-Sep-2004 Erik Andersen <andersen@codepoet.org>
* Added gethostent_r()
*
+ * 2008, 2009 Denys Vlasenko <vda.linux@googlemail.com>
+ * Cleanups, fixes, readability, more cleanups and more fixes.
+ *
+ * March 2010 Bernhard Reutner-Fischer
+ * Switch to common config parser
+ */
+/* Nota bene:
+ * The whole resolver code has several (severe) problems:
+ * - it doesn't even build without IPv4, i.e. !UCLIBC_HAS_IPV4 but only IPv6
+ * - it is way too big
+ *
+ * Both points above are considered bugs, patches/reimplementations welcome.
+ */
+/* RFC 1035
+...
+Whenever an octet represents a numeric quantity, the left most bit
+in the diagram is the high order or most significant bit.
+That is, the bit labeled 0 is the most significant bit.
+...
+
+4.1.1. Header section format
+ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ | ID |
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ |QR| OPCODE |AA|TC|RD|RA| 0 0 0| RCODE |
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ | QDCOUNT |
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ | ANCOUNT |
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ | NSCOUNT |
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ | ARCOUNT |
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ID 16 bit random identifier assigned by querying peer.
+ Used to match query/response.
+QR message is a query (0), or a response (1).
+OPCODE 0 standard query (QUERY)
+ 1 inverse query (IQUERY)
+ 2 server status request (STATUS)
+AA Authoritative Answer - this bit is valid in responses.
+ Responding name server is an authority for the domain name
+ in question section. Answer section may have multiple owner names
+ because of aliases. The AA bit corresponds to the name which matches
+ the query name, or the first owner name in the answer section.
+TC TrunCation - this message was truncated.
+RD Recursion Desired - this bit may be set in a query and
+ is copied into the response. If RD is set, it directs
+ the name server to pursue the query recursively.
+ Recursive query support is optional.
+RA Recursion Available - this be is set or cleared in a
+ response, and denotes whether recursive query support is
+ available in the name server.
+RCODE Response code.
+ 0 No error condition
+ 1 Format error
+ 2 Server failure - server was unable to process the query
+ due to a problem with the name server.
+ 3 Name Error - meaningful only for responses from
+ an authoritative name server. The referenced domain name
+ does not exist.
+ 4 Not Implemented.
+ 5 Refused.
+QDCOUNT number of entries in the question section.
+ANCOUNT number of records in the answer section.
+NSCOUNT number of records in the authority records section.
+ARCOUNT number of records in the additional records section.
+
+4.1.2. Question section format
+
+The section contains QDCOUNT (usually 1) entries, each of this format:
+ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ / QNAME /
+ / /
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ | QTYPE |
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ | QCLASS |
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+QNAME a domain name represented as a sequence of labels, where
+ each label consists of a length octet followed by that
+ number of octets. The domain name terminates with the
+ zero length octet for the null label of the root. Note
+ that this field may be an odd number of octets; no
+ padding is used.
+QTYPE a two octet type of the query.
+ 1 a host address [REQ_A const]
+ 2 an authoritative name server
+ 3 a mail destination (Obsolete - use MX)
+ 4 a mail forwarder (Obsolete - use MX)
+ 5 the canonical name for an alias
+ 6 marks the start of a zone of authority
+ 7 a mailbox domain name (EXPERIMENTAL)
+ 8 a mail group member (EXPERIMENTAL)
+ 9 a mail rename domain name (EXPERIMENTAL)
+ 10 a null RR (EXPERIMENTAL)
+ 11 a well known service description
+ 12 a domain name pointer [REQ_PTR const]
+ 13 host information
+ 14 mailbox or mail list information
+ 15 mail exchange
+ 16 text strings
+ 0x1c IPv6?
+ 252 a request for a transfer of an entire zone
+ 253 a request for mailbox-related records (MB, MG or MR)
+ 254 a request for mail agent RRs (Obsolete - see MX)
+ 255 a request for all records
+QCLASS a two octet code that specifies the class of the query.
+ 1 the Internet
+ (others are historic only)
+ 255 any class
+
+4.1.3. Resource record format
+
+The answer, authority, and additional sections all share the same format:
+a variable number of resource records, where the number of records
+is specified in the corresponding count field in the header.
+Each resource record has this format:
+ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ / /
+ / NAME /
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ | TYPE |
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ | CLASS |
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ | TTL |
+ | |
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ | RDLENGTH |
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
+ / RDATA /
+ / /
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+NAME a domain name to which this resource record pertains.
+TYPE two octets containing one of the RR type codes. This
+ field specifies the meaning of the data in the RDATA field.
+CLASS two octets which specify the class of the data in the RDATA field.
+TTL a 32 bit unsigned integer that specifies the time interval
+ (in seconds) that the record may be cached.
+RDLENGTH a 16 bit integer, length in octets of the RDATA field.
+RDATA a variable length string of octets that describes the resource.
+ The format of this information varies according to the TYPE
+ and CLASS of the resource record.
+ If the TYPE is A and the CLASS is IN, it's a 4 octet IP address.
+
+4.1.4. Message compression
+
+In order to reduce the size of messages, domain names can be compressed.
+An entire domain name or a list of labels at the end of a domain name
+is replaced with a pointer to a prior occurance of the same name.
+
+The pointer takes the form of a two octet sequence:
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ | 1 1| OFFSET |
+ +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+The first two bits are ones. This allows a pointer to be distinguished
+from a label, since the label must begin with two zero bits because
+labels are restricted to 63 octets or less. The OFFSET field specifies
+an offset from the start of the message (i.e., the first octet
+of the ID field in the domain header).
+A zero offset specifies the first byte of the ID field, etc.
+Domain name in a message can be represented as either:
+ - a sequence of labels ending in a zero octet
+ - a pointer
+ - a sequence of labels ending with a pointer
*/
-#define __FORCE_GLIBC
-#include <features.h>
#include <string.h>
#include <stdio.h>
+#include <stdio_ext.h>
#include <signal.h>
+#include <malloc.h>
#include <errno.h>
#include <sys/poll.h>
#include <sys/socket.h>
@@ -151,10 +311,14 @@
#include <netdb.h>
#include <ctype.h>
#include <stdbool.h>
+#include <time.h>
#include <arpa/nameser.h>
#include <sys/utsname.h>
#include <sys/un.h>
+#include <sys/stat.h>
+#include <sys/param.h>
#include <bits/uClibc_mutex.h>
+#include "internal/parse_config.h"
/* poll() is not supported in kernel <= 2.0, therefore if __NR_poll is
* not available, we assume an old Linux kernel is in use and we will
@@ -164,74 +328,21 @@
# define USE_SELECT
#endif
-__UCLIBC_MUTEX_EXTERN(__resolv_lock);
-
-/* Experimentally off - libc_hidden_proto(memcpy) */
-/* Experimentally off - libc_hidden_proto(memset) */
-/* Experimentally off - libc_hidden_proto(memmove) */
-/* Experimentally off - libc_hidden_proto(strchr) */
-/* Experimentally off - libc_hidden_proto(strcmp) */
-/* Experimentally off - libc_hidden_proto(strcpy) */
-/* Experimentally off - libc_hidden_proto(strdup) */
-/* Experimentally off - libc_hidden_proto(strlen) */
-/* Experimentally off - libc_hidden_proto(strncat) */
-/* Experimentally off - libc_hidden_proto(strncpy) */
-/* libc_hidden_proto(strnlen) */
-/* Experimentally off - libc_hidden_proto(strstr) */
-/* Experimentally off - libc_hidden_proto(strcasecmp) */
-libc_hidden_proto(socket)
-libc_hidden_proto(close)
-libc_hidden_proto(fopen)
-libc_hidden_proto(fclose)
-libc_hidden_proto(random)
-libc_hidden_proto(getservbyport)
-libc_hidden_proto(uname)
-libc_hidden_proto(inet_addr)
-libc_hidden_proto(inet_aton)
-libc_hidden_proto(inet_pton)
-libc_hidden_proto(inet_ntop)
-libc_hidden_proto(connect)
-libc_hidden_proto(poll)
-libc_hidden_proto(select)
-libc_hidden_proto(recv)
-libc_hidden_proto(send)
-libc_hidden_proto(printf)
-libc_hidden_proto(sprintf)
-libc_hidden_proto(snprintf)
-libc_hidden_proto(fgets)
-libc_hidden_proto(gethostbyname)
-libc_hidden_proto(gethostbyname_r)
-libc_hidden_proto(gethostbyname2_r)
-libc_hidden_proto(gethostbyaddr)
-libc_hidden_proto(gethostbyaddr_r)
-libc_hidden_proto(ns_name_uncompress)
-libc_hidden_proto(ns_name_unpack)
-libc_hidden_proto(ns_name_ntop)
-libc_hidden_proto(res_init)
-libc_hidden_proto(res_query)
-libc_hidden_proto(res_querydomain)
-libc_hidden_proto(gethostent_r)
-libc_hidden_proto(fprintf)
-libc_hidden_proto(__h_errno_location)
-#ifdef __UCLIBC_HAS_XLOCALE__
-libc_hidden_proto(__ctype_b_loc)
-#elif defined __UCLIBC_HAS_CTYPE_TABLES__
-libc_hidden_proto(__ctype_b)
+#if defined __UCLIBC_HAS_IPV4__ && defined __UCLIBC_HAS_IPV6__
+#define IF_HAS_BOTH(...) __VA_ARGS__
+#else
+#define IF_HAS_BOTH(...)
#endif
-int __libc_getdomainname(char *name, size_t len);
-libc_hidden_proto(__libc_getdomainname)
-#define MAX_RECURSE 5
-#define REPLY_TIMEOUT 10
-#define MAX_RETRIES 3
-#define MAX_SERVERS 3
-#define MAX_SEARCH 4
-
-#define MAX_ALIASES 5
-
+#define MAX_RECURSE 5
+#define MAXALIASES (4)
/* 1:ip + 1:full + MAX_ALIASES:aliases + 1:NULL */
-#define ALIAS_DIM (2 + MAX_ALIASES + 1)
+#define ALIAS_DIM (2 + MAXALIASES + 1)
+#define BUFSZ (80) /* one line */
+
+#define NS_TYPE_ELT 0x40 /*%< EDNS0 extended label type */
+#define DNS_LABELTYPE_BITSTRING 0x41
#undef DEBUG
/* #define DEBUG */
@@ -240,7 +351,7 @@ libc_hidden_proto(__libc_getdomainname)
#define DPRINTF(X,args...) fprintf(stderr, X, ##args)
#else
#define DPRINTF(X,args...)
-#endif /* DEBUG */
+#endif
/* Make sure the incoming char * buffer is aligned enough to handle our random
* structures. This define is the same as we use for malloc alignment (which
@@ -251,18 +362,10 @@ libc_hidden_proto(__libc_getdomainname)
#define ALIGN_BUFFER_OFFSET(buf) ((ALIGN_ATTR - ((size_t)buf % ALIGN_ATTR)) % ALIGN_ATTR)
-/* Global stuff (stuff needing to be locked to be thread safe)... */
-extern int __nameservers attribute_hidden;
-extern char * __nameserver[MAX_SERVERS] attribute_hidden;
-extern int __searchdomains attribute_hidden;
-extern char * __searchdomain[MAX_SEARCH] attribute_hidden;
-
-
-
/* Structs */
struct resolv_header {
int id;
- int qr,opcode,aa,tc,rd,ra,rcode;
+ int qr, opcode, aa, tc, rd, ra, rcode;
int qdcount;
int ancount;
int nscount;
@@ -270,18 +373,18 @@ struct resolv_header {
};
struct resolv_question {
- char * dotted;
+ char *dotted;
int qtype;
int qclass;
};
struct resolv_answer {
- char * dotted;
+ char *dotted;
int atype;
int aclass;
int ttl;
int rdlength;
- const unsigned char * rdata;
+ const unsigned char *rdata;
int rdoffset;
char* buf;
size_t buflen;
@@ -294,49 +397,178 @@ enum etc_hosts_action {
GET_HOSTS_BYADDR,
};
-/* function prototypes */
-extern int __get_hosts_byname_r(const char * name, int type,
- struct hostent * result_buf,
- char * buf, size_t buflen,
- struct hostent ** result,
- int * h_errnop) attribute_hidden;
-extern int __get_hosts_byaddr_r(const char * addr, int len, int type,
- struct hostent * result_buf,
- char * buf, size_t buflen,
- struct hostent ** result,
- int * h_errnop) attribute_hidden;
-extern FILE * __open_etc_hosts(void) attribute_hidden;
-extern int __read_etc_hosts_r(FILE *fp, const char * name, int type,
- enum etc_hosts_action action,
- struct hostent * result_buf,
- char * buf, size_t buflen,
- struct hostent ** result,
- int * h_errnop) attribute_hidden;
-extern int __dns_lookup(const char * name, int type, int nscount,
- char ** nsip, unsigned char ** outpacket, struct resolv_answer * a) attribute_hidden;
-
-extern int __encode_dotted(const char * dotted, unsigned char * dest, int maxlen) attribute_hidden;
-extern int __decode_dotted(const unsigned char * const message, int offset,
- char * dest, int maxlen) attribute_hidden;
-extern int __length_dotted(const unsigned char * const message, int offset) attribute_hidden;
-extern int __encode_header(struct resolv_header * h, unsigned char * dest, int maxlen) attribute_hidden;
-extern int __decode_header(unsigned char * data, struct resolv_header * h) attribute_hidden;
-extern int __encode_question(const struct resolv_question * const q,
- unsigned char * dest, int maxlen) attribute_hidden;
-extern int __decode_question(const unsigned char * const message, int offset,
- struct resolv_question * q) attribute_hidden;
-extern int __encode_answer(struct resolv_answer * a,
- unsigned char * dest, int maxlen) attribute_hidden;
-extern int __decode_answer(const unsigned char * message, int offset,
- struct resolv_answer * a) attribute_hidden;
-extern int __length_question(const unsigned char * const message, int offset) attribute_hidden;
+typedef union sockaddr46_t {
+ struct sockaddr sa;
+#ifdef __UCLIBC_HAS_IPV4__
+ struct sockaddr_in sa4;
+#endif
+#ifdef __UCLIBC_HAS_IPV6__
+ struct sockaddr_in6 sa6;
+#endif
+} sockaddr46_t;
+
+
+__UCLIBC_MUTEX_EXTERN(__resolv_lock) attribute_hidden;
+
+/* Protected by __resolv_lock */
+extern void (*__res_sync)(void) attribute_hidden;
+/*extern uint32_t __resolv_opts attribute_hidden; */
+extern uint8_t __resolv_timeout attribute_hidden;
+extern uint8_t __resolv_attempts attribute_hidden;
+extern unsigned __nameservers attribute_hidden;
+extern unsigned __searchdomains attribute_hidden;
+extern sockaddr46_t *__nameserver attribute_hidden;
+extern char **__searchdomain attribute_hidden;
+#ifdef __UCLIBC_HAS_IPV4__
+extern const struct sockaddr_in __local_nameserver attribute_hidden;
+#else
+extern const struct sockaddr_in6 __local_nameserver attribute_hidden;
+#endif
+/* Arbitrary */
+#define MAXLEN_searchdomain 128
+
+
+/* prototypes for internal functions */
+extern void endhostent_unlocked(void) attribute_hidden;
+extern int __get_hosts_byname_r(const char *name,
+ int type,
+ struct hostent *result_buf,
+ char *buf,
+ size_t buflen,
+ struct hostent **result,
+ int *h_errnop) attribute_hidden;
+extern int __get_hosts_byaddr_r(const char *addr,
+ int len,
+ int type,
+ struct hostent *result_buf,
+ char *buf,
+ size_t buflen,
+ struct hostent **result,
+ int *h_errnop) attribute_hidden;
+extern parser_t *__open_etc_hosts(void) attribute_hidden;
+extern int __read_etc_hosts_r(parser_t *parser,
+ const char *name,
+ int type,
+ enum etc_hosts_action action,
+ struct hostent *result_buf,
+ char *buf,
+ size_t buflen,
+ struct hostent **result,
+ int *h_errnop) attribute_hidden;
+extern int __dns_lookup(const char *name,
+ int type,
+ unsigned char **outpacket,
+ struct resolv_answer *a) attribute_hidden;
+extern int __encode_dotted(const char *dotted,
+ unsigned char *dest,
+ int maxlen) attribute_hidden;
+extern int __decode_dotted(const unsigned char *packet,
+ int offset,
+ int packet_len,
+ char *dest,
+ int dest_len) attribute_hidden;
+extern int __encode_header(struct resolv_header *h,
+ unsigned char *dest,
+ int maxlen) attribute_hidden;
+extern void __decode_header(unsigned char *data,
+ struct resolv_header *h) attribute_hidden;
+extern int __encode_question(const struct resolv_question *q,
+ unsigned char *dest,
+ int maxlen) attribute_hidden;
+extern int __encode_answer(struct resolv_answer *a,
+ unsigned char *dest,
+ int maxlen) attribute_hidden;
extern void __open_nameservers(void) attribute_hidden;
extern void __close_nameservers(void) attribute_hidden;
-extern int __dn_expand(const u_char *, const u_char *, const u_char *,
- char *, int);
+
+/*
+ * Theory of operation.
+ *
+ * gethostbyname, getaddrinfo and friends end up here, and they sometimes
+ * need to talk to DNS servers. In order to do this, we need to read /etc/resolv.conf
+ * and determine servers' addresses and the like. resolv.conf format:
+ *
+ * nameserver <IP[v6]>
+ * Address of DNS server. Cumulative.
+ * If not specified, assumed to be on localhost.
+ * search <domain1>[ <domain2>]...
+ * Append these domains to unqualified names.
+ * See ndots:n option.
+ * $LOCALDOMAIN (space-separated list) overrides this.
+ * domain <domain>
+ * Effectively same as "search" with one domain.
+ * If no "domain" line is present, the domain is determined
+ * from the local host name returned by gethostname();
+ * the domain part is taken to be everything after the first dot.
+ * If there are no dots, there will be no "domain".
+ * The domain and search keywords are mutually exclusive.
+ * If more than one instance of these keywords is present,
+ * the last instance wins.
+ * sortlist 130.155.160.0[/255.255.240.0] 130.155.0.0
+ * Allows addresses returned by gethostbyname to be sorted.
+ * Not supported.
+ * options option[ option]...
+ * (so far we support timeout:n and attempts:n)
+ * $RES_OPTIONS (space-separated list) is to be added to "options"
+ * debug sets RES_DEBUG in _res.options
+ * ndots:n how many dots there should be so that name will be tried
+ * first as an absolute name before any search list elements
+ * are appended to it. Default 1
+ * timeout:n how long to wait for response. Default 5
+ * (sun seems to have retrans:n synonym)
+ * attempts:n number of rounds to do before giving up and returning
+ * an error. Default 2
+ * (sun seems to have retry:n synonym)
+ * rotate sets RES_ROTATE in _res.options, round robin
+ * selection of nameservers. Otherwise try
+ * the first listed server first every time
+ * no-check-names
+ * sets RES_NOCHECKNAME in _res.options, which disables
+ * checking of incoming host names for invalid characters
+ * such as underscore (_), non-ASCII, or control characters
+ * inet6 sets RES_USE_INET6 in _res.options. Try a AAAA query
+ * before an A query inside the gethostbyname(), and map
+ * IPv4 responses in IPv6 "tunnelled form" if no AAAA records
+ * are found but an A record set exists
+ * no_tld_query (FreeBSDism?)
+ * do not attempt to resolve names without dots
+ *
+ * We will read and analyze /etc/resolv.conf as needed before
+ * we do a DNS request. This happens in __dns_lookup.
+ * It is reread if its mtime is changed.
+ *
+ * BSD has res_init routine which is used to initialize resolver state
+ * which is held in global structure _res.
+ * Generally, programs call res_init, then fiddle with _res.XXX
+ * (_res.options and _res.nscount, _res.nsaddr_list[N]
+ * are popular targets of fiddling) and expect subsequent calls
+ * to gethostbyname, getaddrinfo, etc to use modified information.
+ *
+ * However, historical _res structure is quite awkward.
+ * Using it for storing /etc/resolv.conf info is not desirable,
+ * and __dns_lookup does not use it.
+ *
+ * We would like to avoid using it unless absolutely necessary.
+ * If user doesn't use res_init, we should arrange it so that
+ * _res structure doesn't even *get linked in* into user's application
+ * (imagine static uclibc build here).
+ *
+ * The solution is a __res_sync function pointer, which is normally NULL.
+ * But if res_init is called, it gets set and any subsequent gethostbyname
+ * et al "syncronizes" our internal structures with potentially
+ * modified _res.XXX stuff by calling __res_sync.
+ * The trick here is that if res_init is not used and not linked in,
+ * gethostbyname itself won't reference _res and _res won't be linked in
+ * either. Other possible methods like
+ * if (__res_sync_just_an_int_flag)
+ * __sync_me_with_res()
+ * would pull in __sync_me_with_res, which pulls in _res. Bad.
+ */
+
#ifdef L_encodeh
-int attribute_hidden __encode_header(struct resolv_header *h, unsigned char *dest, int maxlen)
+
+int __encode_header(struct resolv_header *h, unsigned char *dest, int maxlen)
{
if (maxlen < HFIXEDSZ)
return -1;
@@ -360,10 +592,13 @@ int attribute_hidden __encode_header(struct resolv_header *h, unsigned char *des
return HFIXEDSZ;
}
-#endif
+#endif /* L_encodeh */
+
#ifdef L_decodeh
-int attribute_hidden __decode_header(unsigned char *data, struct resolv_header *h)
+
+void __decode_header(unsigned char *data,
+ struct resolv_header *h)
{
h->id = (data[0] << 8) | data[1];
h->qr = (data[2] & 0x80) ? 1 : 0;
@@ -377,17 +612,16 @@ int attribute_hidden __decode_header(unsigned char *data, struct resolv_header *
h->ancount = (data[6] << 8) | data[7];
h->nscount = (data[8] << 8) | data[9];
h->arcount = (data[10] << 8) | data[11];
-
- return HFIXEDSZ;
}
-#endif
+#endif /* L_decodeh */
+
#ifdef L_encoded
+
/* Encode a dotted string into nameserver transport-level encoding.
This routine is fairly dumb, and doesn't attempt to compress
the data */
-
-int attribute_hidden __encode_dotted(const char *dotted, unsigned char *dest, int maxlen)
+int __encode_dotted(const char *dotted, unsigned char *dest, int maxlen)
{
unsigned used = 0;
@@ -406,10 +640,9 @@ int attribute_hidden __encode_dotted(const char *dotted, unsigned char *dest, in
memcpy(dest + used, dotted, l);
used += l;
- if (c)
- dotted = c + 1;
- else
+ if (!c)
break;
+ dotted = c + 1;
}
if (maxlen < 1)
@@ -419,49 +652,68 @@ int attribute_hidden __encode_dotted(const char *dotted, unsigned char *dest, in
return used;
}
-#endif
+#endif /* L_encoded */
+
#ifdef L_decoded
+
/* Decode a dotted string from nameserver transport-level encoding.
This routine understands compressed data. */
-
-int attribute_hidden __decode_dotted(const unsigned char * const data, int offset,
- char *dest, int maxlen)
+int __decode_dotted(const unsigned char *packet,
+ int offset,
+ int packet_len,
+ char *dest,
+ int dest_len)
{
- int l;
+ unsigned b;
bool measure = 1;
unsigned total = 0;
unsigned used = 0;
+ unsigned maxiter = 256;
- if (!data)
+ if (!packet)
return -1;
- while ((l = data[offset++])) {
+ dest[0] = '\0';
+ while (--maxiter) {
+ if (offset >= packet_len)
+ return -1;
+ b = packet[offset++];
+ if (b == 0)
+ break;
+
if (measure)
total++;
- if ((l & 0xc0) == (0xc0)) {
+
+ if ((b & 0xc0) == 0xc0) {
+ if (offset >= packet_len)
+ return -1;
if (measure)
total++;
/* compressed item, redirect */
- offset = ((l & 0x3f) << 8) | data[offset];
+ offset = ((b & 0x3f) << 8) | packet[offset];
measure = 0;
continue;
}
- if ((used + l + 1) >= maxlen)
+ if (used + b + 1 >= dest_len)
+ return -1;
+ if (offset + b >= packet_len)
return -1;
+ memcpy(dest + used, packet + offset, b);
+ offset += b;
+ used += b;
- memcpy(dest + used, data + offset, l);
- offset += l;
- used += l;
if (measure)
- total += l;
+ total += b;
- if (data[offset] != 0)
+ if (packet[offset] != 0)
dest[used++] = '.';
else
dest[used++] = '\0';
}
+ if (!maxiter)
+ return -1;
/* The null byte must be counted too */
if (measure)
@@ -471,34 +723,14 @@ int attribute_hidden __decode_dotted(const unsigned char * const data, int offse
return total;
}
-#endif
+#endif /* L_decoded */
-#ifdef L_lengthd
-int attribute_hidden __length_dotted(const unsigned char * const data, int offset)
-{
- int orig_offset = offset;
- int l;
-
- if (!data)
- return -1;
-
- while ((l = data[offset++])) {
-
- if ((l & 0xc0) == (0xc0)) {
- offset++;
- break;
- }
-
- offset += l;
- }
-
- return offset - orig_offset;
-}
-#endif
#ifdef L_encodeq
-int attribute_hidden __encode_question(const struct resolv_question * const q,
- unsigned char *dest, int maxlen)
+
+int __encode_question(const struct resolv_question *q,
+ unsigned char *dest,
+ int maxlen)
{
int i;
@@ -519,44 +751,12 @@ int attribute_hidden __encode_question(const struct resolv_question * const q,
return i + 4;
}
-#endif
+#endif /* L_encodeq */
-#ifdef L_decodeq
-int attribute_hidden __decode_question(const unsigned char * const message, int offset,
- struct resolv_question *q)
-{
- char temp[256];
- int i;
-
- i = __decode_dotted(message, offset, temp, sizeof(temp));
- if (i < 0)
- return i;
-
- offset += i;
-
- q->dotted = strdup(temp); /* TODO: what if this fails? */
- q->qtype = (message[offset + 0] << 8) | message[offset + 1];
- q->qclass = (message[offset + 2] << 8) | message[offset + 3];
-
- return i + 4;
-}
-#endif
-
-#ifdef L_lengthq
-int attribute_hidden __length_question(const unsigned char * const message, int offset)
-{
- int i;
-
- i = __length_dotted(message, offset);
- if (i < 0)
- return i;
-
- return i + 4;
-}
-#endif
#ifdef L_encodea
-int attribute_hidden __encode_answer(struct resolv_answer *a, unsigned char *dest, int maxlen)
+
+int __encode_answer(struct resolv_answer *a, unsigned char *dest, int maxlen)
{
int i;
@@ -584,53 +784,24 @@ int attribute_hidden __encode_answer(struct resolv_answer *a, unsigned char *des
return i + RRFIXEDSZ + a->rdlength;
}
-#endif
-
-#ifdef L_decodea
-int attribute_hidden __decode_answer(const unsigned char *message, int offset,
- struct resolv_answer *a)
-{
- char temp[256];
- int i;
+#endif /* L_encodea */
- i = __decode_dotted(message, offset, temp, sizeof(temp));
- if (i < 0)
- return i;
-
- message += offset + i;
-
- a->dotted = strdup(temp); /* TODO: what if this fails? */
- a->atype = (message[0] << 8) | message[1];
- message += 2;
- a->aclass = (message[0] << 8) | message[1];
- message += 2;
- a->ttl = (message[0] << 24) |
- (message[1] << 16) | (message[2] << 8) | (message[3] << 0);
- message += 4;
- a->rdlength = (message[0] << 8) | message[1];
- message += 2;
- a->rdata = message;
- a->rdoffset = offset + i + RRFIXEDSZ;
-
- DPRINTF("i=%d,rdlength=%d\n", i, a->rdlength);
-
- return i + RRFIXEDSZ + a->rdlength;
-}
-#endif
+#ifdef CURRENTLY_UNUSED
#ifdef L_encodep
+
int __encode_packet(struct resolv_header *h,
- struct resolv_question **q,
- struct resolv_answer **an,
- struct resolv_answer **ns,
- struct resolv_answer **ar,
- unsigned char *dest, int maxlen) attribute_hidden;
+ struct resolv_question **q,
+ struct resolv_answer **an,
+ struct resolv_answer **ns,
+ struct resolv_answer **ar,
+ unsigned char *dest, int maxlen) attribute_hidden;
int __encode_packet(struct resolv_header *h,
- struct resolv_question **q,
- struct resolv_answer **an,
- struct resolv_answer **ns,
- struct resolv_answer **ar,
- unsigned char *dest, int maxlen)
+ struct resolv_question **q,
+ struct resolv_answer **an,
+ struct resolv_answer **ns,
+ struct resolv_answer **ar,
+ unsigned char *dest, int maxlen)
{
int i, total = 0;
unsigned j;
@@ -679,20 +850,32 @@ int __encode_packet(struct resolv_header *h,
return total;
}
-#endif
+#endif /* L_encodep */
+
#ifdef L_decodep
+
int __decode_packet(unsigned char *data, struct resolv_header *h) attribute_hidden;
int __decode_packet(unsigned char *data, struct resolv_header *h)
{
- return __decode_header(data, h);
+ __decode_header(data, h);
+ return HFIXEDSZ;
}
-#endif
+#endif /* L_decodep */
+
#ifdef L_formquery
-int __form_query(int id, const char *name, int type, unsigned char *packet, int maxlen);
-int __form_query(int id, const char *name, int type, unsigned char *packet,
- int maxlen)
+
+int __form_query(int id,
+ const char *name,
+ int type,
+ unsigned char *packet,
+ int maxlen) attribute_hidden;
+int __form_query(int id,
+ const char *name,
+ int type,
+ unsigned char *packet,
+ int maxlen)
{
struct resolv_header h;
struct resolv_question q;
@@ -716,24 +899,355 @@ int __form_query(int id, const char *name, int type, unsigned char *packet,
return i + j;
}
+#endif /* L_formquery */
+#endif /* CURRENTLY_UNUSED */
+
+
+#ifdef L_opennameservers
+
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+#define NAMESERVER_PORT_N (__bswap_constant_16(NAMESERVER_PORT))
+#else
+#define NAMESERVER_PORT_N NAMESERVER_PORT
+#endif
+
+__UCLIBC_MUTEX_INIT(__resolv_lock, PTHREAD_MUTEX_INITIALIZER);
+
+/* Protected by __resolv_lock */
+void (*__res_sync)(void);
+/*uint32_t __resolv_opts; */
+uint8_t __resolv_timeout = RES_TIMEOUT;
+uint8_t __resolv_attempts = RES_DFLRETRY;
+unsigned __nameservers;
+unsigned __searchdomains;
+sockaddr46_t *__nameserver;
+char **__searchdomain;
+#ifdef __UCLIBC_HAS_IPV4__
+const struct sockaddr_in __local_nameserver = {
+ .sin_family = AF_INET,
+ .sin_port = NAMESERVER_PORT_N,
+};
+#else
+const struct sockaddr_in6 __local_nameserver = {
+ .sin6_family = AF_INET6,
+ .sin6_port = NAMESERVER_PORT_N,
+};
+#endif
+
+/* Helpers. Both stop on EOL, if it's '\n', it is converted to NUL first */
+static char *skip_nospace(char *p)
+{
+ while (*p != '\0' && !isspace(*p)) {
+ if (*p == '\n') {
+ *p = '\0';
+ break;
+ }
+ p++;
+ }
+ return p;
+}
+static char *skip_and_NUL_space(char *p)
+{
+ /* NB: '\n' is not isspace! */
+ while (1) {
+ char c = *p;
+ if (c == '\0' || !isspace(c))
+ break;
+ *p = '\0';
+ if (c == '\n' || c == '#')
+ break;
+ p++;
+ }
+ return p;
+}
+
+/* Must be called under __resolv_lock. */
+void __open_nameservers(void)
+{
+ static uint32_t resolv_conf_mtime;
+
+ char szBuffer[MAXLEN_searchdomain];
+ FILE *fp;
+ int i;
+ sockaddr46_t sa;
+
+ if (!__res_sync) {
+ /* Reread /etc/resolv.conf if it was modified. */
+ struct stat sb;
+ if (stat(_PATH_RESCONF, &sb) != 0)
+ sb.st_mtime = 0;
+ if (resolv_conf_mtime != (uint32_t)sb.st_mtime) {
+ resolv_conf_mtime = sb.st_mtime;
+ __close_nameservers(); /* force config reread */
+ }
+ }
+
+ if (__nameservers)
+ goto sync;
+
+ __resolv_timeout = RES_TIMEOUT;
+ __resolv_attempts = RES_DFLRETRY;
+
+ fp = fopen(_PATH_RESCONF, "r");
+#ifdef FALLBACK_TO_CONFIG_RESOLVCONF
+ if (!fp) {
+ /* If we do not have a pre-populated /etc/resolv.conf then
+ try to use the one from /etc/config which exists on numerous
+ systems ranging from some uClinux to IRIX installations and
+ may be the only /etc dir that was mounted rw. */
+ fp = fopen("/etc/config/resolv.conf", "r");
+ }
#endif
+ if (fp) {
+ while (fgets(szBuffer, sizeof(szBuffer), fp) != NULL) {
+ void *ptr;
+ char *keyword, *p;
+
+ keyword = p = skip_and_NUL_space(szBuffer);
+ /* skip keyword */
+ p = skip_nospace(p);
+ /* find next word */
+ p = skip_and_NUL_space(p);
+
+ if (strcmp(keyword, "nameserver") == 0) {
+ /* terminate IP addr */
+ *skip_nospace(p) = '\0';
+ memset(&sa, 0, sizeof(sa));
+ if (0) /* nothing */;
+#ifdef __UCLIBC_HAS_IPV6__
+ else if (inet_pton(AF_INET6, p, &sa.sa6.sin6_addr) > 0) {
+ sa.sa6.sin6_family = AF_INET6;
+ sa.sa6.sin6_port = htons(NAMESERVER_PORT);
+ }
+#endif
+#ifdef __UCLIBC_HAS_IPV4__
+ else if (inet_pton(AF_INET, p, &sa.sa4.sin_addr) > 0) {
+ sa.sa4.sin_family = AF_INET;
+ sa.sa4.sin_port = htons(NAMESERVER_PORT);
+ }
+#endif
+ else
+ continue; /* garbage on this line */
+ ptr = realloc(__nameserver, (__nameservers + 1) * sizeof(__nameserver[0]));
+ if (!ptr)
+ continue;
+ __nameserver = ptr;
+ __nameserver[__nameservers++] = sa; /* struct copy */
+ continue;
+ }
+ if (strcmp(keyword, "domain") == 0 || strcmp(keyword, "search") == 0) {
+ char *p1;
+
+ /* free old domains ("last 'domain' or 'search' wins" rule) */
+ while (__searchdomains)
+ free(__searchdomain[--__searchdomains]);
+ /*free(__searchdomain);*/
+ /*__searchdomain = NULL; - not necessary */
+ next_word:
+ /* terminate current word */
+ p1 = skip_nospace(p);
+ /* find next word (maybe) */
+ p1 = skip_and_NUL_space(p1);
+ /* add it */
+ ptr = realloc(__searchdomain, (__searchdomains + 1) * sizeof(__searchdomain[0]));
+ if (!ptr)
+ continue;
+ __searchdomain = ptr;
+ /* NB: strlen(p) <= MAXLEN_searchdomain) because szBuffer[] is smaller */
+ ptr = strdup(p);
+ if (!ptr)
+ continue;
+ DPRINTF("adding search %s\n", (char*)ptr);
+ __searchdomain[__searchdomains++] = (char*)ptr;
+ p = p1;
+ if (*p)
+ goto next_word;
+ continue;
+ }
+ /* if (strcmp(keyword, "sortlist") == 0)... */
+ if (strcmp(keyword, "options") == 0) {
+ char *p1;
+ uint8_t *what;
+
+ if (p == NULL || (p1 = strchr(p, ':')) == NULL)
+ continue;
+ *p1++ = '\0';
+ if (strcmp(p, "timeout") == 0)
+ what = &__resolv_timeout;
+ else if (strcmp(p, "attempts") == 0)
+ what = &__resolv_attempts;
+ else
+ continue;
+ *what = atoi(p1);
+ DPRINTF("option %s:%d\n", p, *what);
+ }
+ }
+ fclose(fp);
+ }
+ if (__nameservers == 0) {
+ /* Have to handle malloc failure! What a mess...
+ * And it's not only here, we need to be careful
+ * to never write into __nameserver[0] if it points
+ * to constant __local_nameserver, or free it. */
+ __nameserver = malloc(sizeof(__nameserver[0]));
+ if (__nameserver)
+ memcpy(__nameserver, &__local_nameserver, sizeof(__local_nameserver));
+ else
+ __nameserver = (void*) &__local_nameserver;
+ __nameservers++;
+ }
+ if (__searchdomains == 0) {
+ char buf[256];
+ char *p;
+ i = gethostname(buf, sizeof(buf) - 1);
+ buf[sizeof(buf) - 1] = '\0';
+ if (i == 0 && (p = strchr(buf, '.')) != NULL && p[1]) {
+ p = strdup(p + 1);
+ if (!p)
+ goto err;
+ __searchdomain = malloc(sizeof(__searchdomain[0]));
+ if (!__searchdomain) {
+ free(p);
+ goto err;
+ }
+ __searchdomain[0] = p;
+ __searchdomains++;
+ err: ;
+ }
+ }
+ DPRINTF("nameservers = %d\n", __nameservers);
+
+ sync:
+ if (__res_sync)
+ __res_sync();
+}
+#endif /* L_opennameservers */
+
+
+#ifdef L_closenameservers
+
+/* Must be called under __resolv_lock. */
+void __close_nameservers(void)
+{
+ if (__nameserver != (void*) &__local_nameserver)
+ free(__nameserver);
+ __nameserver = NULL;
+ __nameservers = 0;
+ while (__searchdomains)
+ free(__searchdomain[--__searchdomains]);
+ free(__searchdomain);
+ __searchdomain = NULL;
+ /*__searchdomains = 0; - already is */
+}
+#endif /* L_closenameservers */
+
+
#ifdef L_dnslookup
-__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER);
-/* Just for the record, having to lock __dns_lookup() just for these two globals
- * is pretty lame. I think these two variables can probably be de-global-ized,
- * which should eliminate the need for doing locking here... Needs a closer
- * look anyways. */
-static int static_ns = 0;
-/* uint16: minimizing rw data size, even if code grows a tiny bit.
- * rw data costs more. */
-static uint16_t static_id = 1;
+/* Helpers */
+static int __length_question(const unsigned char *data, int maxlen)
+{
+ const unsigned char *start;
+ unsigned b;
+
+ if (!data)
+ return -1;
-int attribute_hidden __dns_lookup(const char *name, int type, int nscount, char **nsip,
- unsigned char **outpacket, struct resolv_answer *a)
+ start = data;
+ while (1) {
+ if (maxlen <= 0)
+ return -1;
+ b = *data++;
+ if (b == 0)
+ break;
+ if ((b & 0xc0) == 0xc0) {
+ /* It's a "compressed" name. */
+ data++; /* skip lsb of redirected offset */
+ maxlen -= 2;
+ break;
+ }
+ data += b;
+ maxlen -= (b + 1); /* account for data++ above */
+ }
+ /* Up to here we were skipping encoded name */
+
+ /* Account for QTYPE and QCLASS fields */
+ if (maxlen < 4)
+ return -1;
+ return data - start + 2 + 2;
+}
+
+static int __decode_answer(const unsigned char *message, /* packet */
+ int offset,
+ int len, /* total packet len */
+ struct resolv_answer *a)
{
- int i, j, len, fd, pos, rc;
+ char temp[256];
+ int i;
+
+ DPRINTF("decode_answer(start): off %d, len %d\n", offset, len);
+ i = __decode_dotted(message, offset, len, temp, sizeof(temp));
+ if (i < 0)
+ return i;
+
+ message += offset + i;
+ len -= i + RRFIXEDSZ + offset;
+ if (len < 0) {
+ DPRINTF("decode_answer: off %d, len %d, i %d\n", offset, len, i);
+ return len;
+ }
+
+/* TODO: what if strdup fails? */
+ a->dotted = strdup(temp);
+ a->atype = (message[0] << 8) | message[1];
+ message += 2;
+ a->aclass = (message[0] << 8) | message[1];
+ message += 2;
+ a->ttl = (message[0] << 24) |
+ (message[1] << 16) | (message[2] << 8) | (message[3] << 0);
+ message += 4;
+ a->rdlength = (message[0] << 8) | message[1];
+ message += 2;
+ a->rdata = message;
+ a->rdoffset = offset + i + RRFIXEDSZ;
+
+ DPRINTF("i=%d,rdlength=%d\n", i, a->rdlength);
+
+ if (len < a->rdlength)
+ return -1;
+ return i + RRFIXEDSZ + a->rdlength;
+}
+
+/* On entry:
+ * a.buf(len) = auxiliary buffer for IP addresses after first one
+ * a.add_count = how many additional addresses are there already
+ * outpacket = where to save ptr to raw packet? can be NULL
+ * On exit:
+ * ret < 0: error, all other data is not valid
+ * ret >= 0: length of reply packet
+ * a.add_count & a.buf: updated
+ * a.rdlength: length of addresses (4 bytes for IPv4)
+ * *outpacket: updated (packet is malloced, you need to free it)
+ * a.rdata: points into *outpacket to 1st IP addr
+ * NB: don't pass outpacket == NULL if you need to use a.rdata!
+ * a.atype: type of query?
+ * a.dotted: which name we _actually_ used. May contain search domains
+ * appended. (why the filed is called "dotted" I have no idea)
+ * This is a malloced string. May be NULL because strdup failed.
+ */
+int __dns_lookup(const char *name,
+ int type,
+ unsigned char **outpacket,
+ struct resolv_answer *a)
+{
+ /* Protected by __resolv_lock: */
+ static int last_ns_num = 0;
+ static uint16_t last_id = 1;
+
+ int i, j, fd, rc;
+ int packet_len;
+ int name_len;
#ifdef USE_SELECT
struct timeval tv;
fd_set fds;
@@ -744,221 +1258,287 @@ int attribute_hidden __dns_lookup(const char *name, int type, int nscount, char
struct resolv_question q;
struct resolv_answer ma;
bool first_answer = 1;
- unsigned retries = 0;
- unsigned char * packet = malloc(PACKETSZ);
- char *dns, *lookup = malloc(MAXDNAME);
- int variant = -1; /* search domain to append, -1 - none */
- int local_ns = -1, local_id = -1;
+ int retries_left;
+ unsigned char *packet = malloc(PACKETSZ);
+ char *lookup;
+ int variant = -1; /* search domain to append, -1: none */
+ int local_ns_num = -1; /* Nth server to use */
+ int local_id = local_id; /* for compiler */
+ int sdomains = 0;
bool ends_with_dot;
-#ifdef __UCLIBC_HAS_IPV6__
- bool v6;
- struct sockaddr_in6 sa6;
-#endif
-#ifdef __UCLIBC_HAS_IPV4__
- struct sockaddr_in sa;
-#endif
+ sockaddr46_t sa;
fd = -1;
-
- if (!packet || !lookup || !nscount || !name[0])
+ lookup = NULL;
+ name_len = strlen(name);
+ if ((unsigned)name_len >= MAXDNAME - MAXLEN_searchdomain - 2)
+ goto fail; /* paranoia */
+ lookup = malloc(name_len + 1/*for '.'*/ + MAXLEN_searchdomain + 1);
+ if (!packet || !lookup || !name[0])
goto fail;
+ ends_with_dot = (name[name_len - 1] == '.');
+ /* no strcpy! paranoia, user might change name[] under us */
+ memcpy(lookup, name, name_len);
DPRINTF("Looking up type %d answer for '%s'\n", type, name);
+ retries_left = 0; /* for compiler */
+ do {
+ int pos;
+ unsigned reply_timeout;
- ends_with_dot = (name[strlen(name) - 1] == '.');
-
- /* Mess with globals while under lock */
- __UCLIBC_MUTEX_LOCK(mylock);
- local_ns = static_ns % nscount;
- local_id = static_id;
- __UCLIBC_MUTEX_UNLOCK(mylock);
-
- while (retries < MAX_RETRIES) {
- if (fd != -1)
+ if (fd != -1) {
close(fd);
+ fd = -1;
+ }
- memset(packet, 0, PACKETSZ);
+ /* Mess with globals while under lock */
+ /* NB: even data *pointed to* by globals may vanish
+ * outside the locks. We should assume any and all
+ * globals can completely change between locked
+ * code regions. OTOH, this is rare, so we don't need
+ * to handle it "nicely" (do not skip servers,
+ * search domains, etc), we only need to ensure
+ * we do not SEGV, use freed+overwritten data
+ * or do other Really Bad Things. */
+ __UCLIBC_MUTEX_LOCK(__resolv_lock);
+ __open_nameservers();
+ if (type != T_PTR) {
+ sdomains = __searchdomains;
+ }
+ lookup[name_len] = '\0';
+ if ((unsigned)variant < sdomains) {
+ /* lookup is name_len + 1 + MAXLEN_searchdomain + 1 long */
+ /* __searchdomain[] is not bigger than MAXLEN_searchdomain */
+ lookup[name_len] = '.';
+ strcpy(&lookup[name_len + 1], __searchdomain[variant]);
+ }
+ /* first time? pick starting server etc */
+ if (local_ns_num < 0) {
+ local_id = last_id;
+/*TODO: implement /etc/resolv.conf's "options rotate"
+ (a.k.a. RES_ROTATE bit in _res.options)
+ local_ns_num = 0;
+ if (_res.options & RES_ROTATE) */
+ local_ns_num = last_ns_num;
+ retries_left = __nameservers * __resolv_attempts;
+ }
+ if (local_ns_num >= __nameservers)
+ local_ns_num = 0;
+ local_id++;
+ local_id &= 0xffff;
+ /* write new values back while still under lock */
+ last_id = local_id;
+ last_ns_num = local_ns_num;
+ /* struct copy */
+ /* can't just take a pointer, __nameserver[x]
+ * is not safe to use outside of locks */
+ sa = __nameserver[local_ns_num];
+ __UCLIBC_MUTEX_UNLOCK(__resolv_lock);
+ memset(packet, 0, PACKETSZ);
memset(&h, 0, sizeof(h));
- ++local_id;
- local_id &= 0xffff;
+ /* encode header */
h.id = local_id;
h.qdcount = 1;
h.rd = 1;
-
DPRINTF("encoding header\n", h.rd);
-
i = __encode_header(&h, packet, PACKETSZ);
if (i < 0)
goto fail;
- strncpy(lookup, name, MAXDNAME);
- __UCLIBC_MUTEX_LOCK(__resolv_lock);
- /* nsip is really __nameserver[] which is a global that
- needs to hold __resolv_lock before access!! */
- dns = nsip[local_ns];
-/* TODO: all future accesses to 'dns' are guarded by __resolv_lock too.
- * Why? We already fetched nsip[local_ns] here,
- * future changes to nsip[] by other threads cannot affect us.
- * We can use 'dns' without locking. If I'm wrong,
- * please explain in comments why locking is needed. */
- if (variant >= 0) {
- if (variant < __searchdomains) {
- strncat(lookup, ".", MAXDNAME);
- strncat(lookup, __searchdomain[variant], MAXDNAME);
- }
- }
- __UCLIBC_MUTEX_UNLOCK(__resolv_lock);
-
+ /* encode question */
DPRINTF("lookup name: %s\n", lookup);
- q.dotted = (char *)lookup;
+ q.dotted = lookup;
q.qtype = type;
q.qclass = C_IN; /* CLASS_IN */
-
j = __encode_question(&q, packet+i, PACKETSZ-i);
if (j < 0)
goto fail;
+ packet_len = i + j;
- len = i + j;
-
- DPRINTF("On try %d, sending query to port %d of machine %s\n",
- retries+1, NAMESERVER_PORT, dns);
-
-#ifdef __UCLIBC_HAS_IPV6__
- __UCLIBC_MUTEX_LOCK(__resolv_lock);
- /* 'dns' is really __nameserver[] which is a global that
- needs to hold __resolv_lock before access!! */
- v6 = inet_pton(AF_INET6, dns, &sa6.sin6_addr) > 0;
- __UCLIBC_MUTEX_UNLOCK(__resolv_lock);
- fd = socket(v6 ? AF_INET6 : AF_INET, SOCK_DGRAM, IPPROTO_UDP);
-#else
- fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
-#endif
- if (fd < 0) {
- retries++;
- continue;
- }
-
- /* Connect to the UDP socket so that asyncronous errors are returned */
+ /* send packet */
+#ifdef DEBUG
+ {
+ const socklen_t plen = sa.sa.sa_family == AF_INET ? INET_ADDRSTRLEN : INET6_ADDRSTRLEN;
+ char *pbuf = malloc(plen);
+ if (pbuf == NULL) ;/* nothing */
#ifdef __UCLIBC_HAS_IPV6__
- if (v6) {
- sa6.sin6_family = AF_INET6;
- sa6.sin6_port = htons(NAMESERVER_PORT);
- /* sa6.sin6_addr is already here */
- rc = connect(fd, (struct sockaddr *) &sa6, sizeof(sa6));
- } else {
+ else if (sa.sa.sa_family == AF_INET6)
+ pbuf = (char*)inet_ntop(AF_INET6, &sa.sa6.sin6_addr, pbuf, plen);
#endif
#ifdef __UCLIBC_HAS_IPV4__
- sa.sin_family = AF_INET;
- sa.sin_port = htons(NAMESERVER_PORT);
- __UCLIBC_MUTEX_LOCK(__resolv_lock);
- /* 'dns' is really __nameserver[] which is a global that
- needs to hold __resolv_lock before access!! */
- sa.sin_addr.s_addr = inet_addr(dns);
- __UCLIBC_MUTEX_UNLOCK(__resolv_lock);
- rc = connect(fd, (struct sockaddr *) &sa, sizeof(sa));
+ else if (sa.sa.sa_family == AF_INET)
+ pbuf = (char*)inet_ntop(AF_INET, &sa.sa4.sin_addr, pbuf, plen);
#endif
-#ifdef __UCLIBC_HAS_IPV6__
+ DPRINTF("On try %d, sending query to %s, port %d\n",
+ retries_left, pbuf, NAMESERVER_PORT);
+ free(pbuf);
}
#endif
+ fd = socket(sa.sa.sa_family, SOCK_DGRAM, IPPROTO_UDP);
+ if (fd < 0) /* paranoia */
+ goto try_next_server;
+ rc = connect(fd, &sa.sa, sizeof(sa));
if (rc < 0) {
- if (errno == ENETUNREACH) {
+ /*if (errno == ENETUNREACH) { */
/* routing error, presume not transient */
- goto tryall;
- }
+ goto try_next_server;
+ /*} */
+/*For example, what transient error this can be? Can't think of any */
/* retry */
- retries++;
- continue;
+ /*continue; */
}
-
- DPRINTF("Transmitting packet of length %d, id=%d, qr=%d\n",
- len, h.id, h.qr);
-
- send(fd, packet, len, 0);
+ DPRINTF("Xmit packet len:%d id:%d qr:%d\n", packet_len, h.id, h.qr);
+ /* no error check - if it fails, we time out on recv */
+ send(fd, packet, packet_len, 0);
#ifdef USE_SELECT
+ reply_timeout = __resolv_timeout;
+ wait_again:
FD_ZERO(&fds);
FD_SET(fd, &fds);
- tv.tv_sec = REPLY_TIMEOUT;
+ tv.tv_sec = reply_timeout;
tv.tv_usec = 0;
if (select(fd + 1, &fds, NULL, NULL, &tv) <= 0) {
DPRINTF("Timeout\n");
-
- /* timed out, so retry send and receive,
- * to next nameserver on queue */
- goto tryall;
+ /* timed out, so retry send and receive
+ * to next nameserver */
+ goto try_next_server;
}
-#else
+ reply_timeout--;
+#else /* !USE_SELECT */
+ reply_timeout = __resolv_timeout * 1000;
+ wait_again:
fds.fd = fd;
fds.events = POLLIN;
- if (poll(&fds, 1, REPLY_TIMEOUT * 1000) <= 0) {
+ if (poll(&fds, 1, reply_timeout) <= 0) {
DPRINTF("Timeout\n");
-
- /* timed out, so retry send and receive,
- * to next nameserver on queue */
- goto tryall;
+ /* timed out, so retry send and receive
+ * to next nameserver */
+ goto try_next_server;
}
+ if (fds.revents & (POLLERR | POLLHUP | POLLNVAL)) {
+ DPRINTF("Bad event\n");
+ goto try_next_server;
+ }
+/*TODO: better timeout accounting?*/
+ reply_timeout -= 1000;
+#endif /* USE_SELECT */
+
+/* vda: a bogus response seen in real world (caused SEGV in uclibc):
+ * "ping www.google.com" sending AAAA query and getting
+ * response with one answer... with answer part missing!
+ * Fixed by thorough checks for not going past the packet's end.
+ */
+#ifdef DEBUG
+ {
+ static const char test_query[32] = "\0\2\1\0\0\1\0\0\0\0\0\0\3www\6google\3com\0\0\34\0\1";
+ static const char test_respn[32] = "\0\2\201\200\0\1\0\1\0\0\0\0\3www\6google\3com\0\0\34\0\1";
+ pos = memcmp(packet + 2, test_query + 2, 30);
+ packet_len = recv(fd, packet, PACKETSZ, MSG_DONTWAIT);
+ if (pos == 0) {
+ packet_len = 32;
+ memcpy(packet + 2, test_respn + 2, 30);
+ }
+ }
+#else
+ packet_len = recv(fd, packet, PACKETSZ, MSG_DONTWAIT);
#endif
- len = recv(fd, packet, PACKETSZ, 0);
- if (len < HFIXEDSZ) {
- /* too short ! */
- goto again;
+ if (packet_len < HFIXEDSZ) {
+ /* too short!
+ * If the peer did shutdown then retry later,
+ * try next peer on error.
+ * it's just a bogus packet from somewhere */
+ bogus_packet:
+ if (packet_len >= 0 && reply_timeout)
+ goto wait_again;
+ goto try_next_server;
}
-
__decode_header(packet, &h);
-
- DPRINTF("id = %d, qr = %d\n", h.id, h.qr);
-
- if ((h.id != local_id) || (!h.qr)) {
+ DPRINTF("len:%d id:%d qr:%d\n", packet_len, h.id, h.qr);
+ if (h.id != local_id || !h.qr) {
/* unsolicited */
- goto again;
+ goto bogus_packet;
}
- DPRINTF("Got response %s\n", "(i think)!");
+ DPRINTF("Got response (i think)!\n");
DPRINTF("qrcount=%d,ancount=%d,nscount=%d,arcount=%d\n",
h.qdcount, h.ancount, h.nscount, h.arcount);
DPRINTF("opcode=%d,aa=%d,tc=%d,rd=%d,ra=%d,rcode=%d\n",
h.opcode, h.aa, h.tc, h.rd, h.ra, h.rcode);
- if ((h.rcode) || (h.ancount < 1)) {
- /* negative result, not present */
- goto again;
+ /* bug 660 says we treat negative response as an error
+ * and retry, which is, eh, an error. :)
+ * We were incurring long delays because of this. */
+ if (h.rcode == NXDOMAIN || h.rcode == SERVFAIL) {
+ /* if possible, try next search domain */
+ if (!ends_with_dot) {
+ DPRINTF("variant:%d sdomains:%d\n", variant, sdomains);
+ if (variant < sdomains - 1) {
+ /* next search domain */
+ variant++;
+ continue;
+ }
+ /* no more search domains to try */
+ }
+ if (h.rcode != SERVFAIL) {
+ /* dont loop, this is "no such host" situation */
+ h_errno = HOST_NOT_FOUND;
+ goto fail1;
+ }
}
+ /* Insert other non-fatal errors here, which do not warrant
+ * switching to next nameserver */
- pos = HFIXEDSZ;
+ /* Strange error, assuming this nameserver is feeling bad */
+ if (h.rcode != 0)
+ goto try_next_server;
+ /* Code below won't work correctly with h.ancount == 0, so... */
+ if (h.ancount <= 0) {
+ h_errno = NO_DATA; /* [is this correct code to check for?] */
+ goto fail1;
+ }
+ pos = HFIXEDSZ;
for (j = 0; j < h.qdcount; j++) {
DPRINTF("Skipping question %d at %d\n", j, pos);
- i = __length_question(packet, pos);
- DPRINTF("Length of question %d is %d\n", j, i);
- if (i < 0)
- goto again;
+ i = __length_question(packet + pos, packet_len - pos);
+ if (i < 0) {
+ DPRINTF("Packet'question section "
+ "is truncated, trying next server\n");
+ goto try_next_server;
+ }
pos += i;
+ DPRINTF("Length of question %d is %d\n", j, i);
}
DPRINTF("Decoding answer at pos %d\n", pos);
first_answer = 1;
- for (j = 0; j < h.ancount; j++, pos += i) {
- i = __decode_answer(packet, pos, &ma);
-
+ a->dotted = NULL;
+ for (j = 0; j < h.ancount; j++) {
+ i = __decode_answer(packet, pos, packet_len, &ma);
if (i < 0) {
DPRINTF("failed decode %d\n", i);
- goto again;
+ /* If the message was truncated but we have
+ * decoded some answers, pretend it's OK */
+ if (j && h.tc)
+ break;
+ goto try_next_server;
}
+ pos += i;
if (first_answer) {
ma.buf = a->buf;
ma.buflen = a->buflen;
ma.add_count = a->add_count;
+ free(a->dotted);
memcpy(a, &ma, sizeof(ma));
- if (a->atype != T_SIG && (0 == a->buf || (type != T_A && type != T_AAAA)))
+ if (a->atype != T_SIG && (NULL == a->buf || (type != T_A && type != T_AAAA)))
break;
- if (a->atype != type) {
- free(a->dotted);
+ if (a->atype != type)
continue;
- }
a->add_count = h.ancount - j - 1;
if ((a->rdlength + sizeof(struct in_addr*)) * a->add_count > a->buflen)
break;
@@ -972,846 +1552,223 @@ int attribute_hidden __dns_lookup(const char *name, int type, int nscount, char
free(a->dotted);
DPRINTF("Answer address len(%u) differs from original(%u)\n",
ma.rdlength, a->rdlength);
- goto again;
+ goto try_next_server;
}
memcpy(a->buf + (a->add_count * ma.rdlength), ma.rdata, ma.rdlength);
++a->add_count;
}
}
+ /* Success! */
DPRINTF("Answer name = |%s|\n", a->dotted);
DPRINTF("Answer type = |%d|\n", a->atype);
-
- close(fd);
-
+ if (fd != -1)
+ close(fd);
if (outpacket)
*outpacket = packet;
else
free(packet);
free(lookup);
+ return packet_len;
- /* Mess with globals while under lock */
- __UCLIBC_MUTEX_LOCK(mylock);
- static_ns = local_ns;
- static_id = local_id;
- __UCLIBC_MUTEX_UNLOCK(mylock);
-
- return len; /* success! */
-
- tryall:
- /* if there are other nameservers, give them a go,
- otherwise return with error */
+ try_next_server:
+ /* Try next nameserver */
+ retries_left--;
+ local_ns_num++;
variant = -1;
- local_ns = (local_ns + 1) % nscount;
- if (local_ns == 0)
- retries++;
-
- continue;
-
- again:
- /* if there are searchdomains, try them or fallback as passed */
- if (!ends_with_dot) {
- int sdomains;
-
- __UCLIBC_MUTEX_LOCK(__resolv_lock);
- sdomains = __searchdomains;
- __UCLIBC_MUTEX_UNLOCK(__resolv_lock);
-
- if (variant < sdomains - 1) {
- /* next search */
- variant++;
- continue;
- }
- }
- /* next server, first search */
- local_ns = (local_ns + 1) % nscount;
- if (local_ns == 0)
- retries++;
- variant = -1;
- }
+ } while (retries_left > 0);
fail:
+ h_errno = NETDB_INTERNAL;
+ fail1:
if (fd != -1)
close(fd);
free(lookup);
free(packet);
- h_errno = NETDB_INTERNAL;
- /* Mess with globals while under lock */
- if (local_ns != -1) {
- __UCLIBC_MUTEX_LOCK(mylock);
- static_ns = local_ns;
- static_id = local_id;
- __UCLIBC_MUTEX_UNLOCK(mylock);
- }
return -1;
}
-#endif
-
-#ifdef L_opennameservers
-
-/* We use __resolv_lock to guard access to the
- * '__nameservers' and __searchdomains globals */
-int __nameservers;
-char * __nameserver[MAX_SERVERS];
-int __searchdomains;
-char * __searchdomain[MAX_SEARCH];
+#endif /* L_dnslookup */
-__UCLIBC_MUTEX_INIT(__resolv_lock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP);
-
-/*
- * we currently read formats not quite the same as that on normal
- * unix systems, we can have a list of nameservers after the keyword.
- */
-
-void attribute_hidden __open_nameservers(void)
-{
- FILE *fp;
- int i;
-#define RESOLV_ARGS 5
- char szBuffer[128], *p, *argv[RESOLV_ARGS];
- int argc;
- __UCLIBC_MUTEX_LOCK(__resolv_lock);
- if (__nameservers > 0)
- goto DONE;
-
- if ((fp = fopen("/etc/resolv.conf", "r")) ||
- (fp = fopen("/etc/config/resolv.conf", "r")))
- {
- while (fgets(szBuffer, sizeof(szBuffer), fp) != NULL) {
- for (p = szBuffer; *p && isspace(*p); p++)
- /* skip white space */;
- if (*p == '\0' || *p == '\n' || *p == '#') /* skip comments etc */
- continue;
- argc = 0;
- while (*p && argc < RESOLV_ARGS) {
- argv[argc++] = p;
- while (*p && !isspace(*p) && *p != '\n')
- p++;
- while (*p && (isspace(*p) || *p == '\n')) /* remove spaces */
- *p++ = '\0';
- }
-
- if (strcmp(argv[0], "nameserver") == 0) {
- for (i = 1; i < argc && __nameservers < MAX_SERVERS; i++) {
- __nameserver[__nameservers++] = strdup(argv[i]); /* TODO: what if this fails? */
- DPRINTF("adding nameserver %s\n", argv[i]);
- }
- }
-
- /* domain and search are mutually exclusive, the last one wins */
- if (strcmp(argv[0],"domain") == 0 || strcmp(argv[0],"search") == 0) {
- while (__searchdomains > 0) {
- free(__searchdomain[--__searchdomains]);
- __searchdomain[__searchdomains] = NULL;
- }
- for (i = 1; i < argc && __searchdomains < MAX_SEARCH; i++) {
- __searchdomain[__searchdomains++] = strdup(argv[i]); /* TODO: what if this fails? */
- DPRINTF("adding search %s\n", argv[i]);
- }
- }
- }
- fclose(fp);
- DPRINTF("nameservers = %d\n", __nameservers);
- goto DONE;
- }
- DPRINTF("failed to open %s\n", "resolv.conf");
- h_errno = NO_RECOVERY;
-
- /* rv = -1; */
-
- DONE:
- __UCLIBC_MUTEX_UNLOCK(__resolv_lock);
- /* return rv; */
-}
-#endif
-
-
-#ifdef L_closenameservers
-
-void attribute_hidden __close_nameservers(void)
-{
- __UCLIBC_MUTEX_LOCK(__resolv_lock);
- while (__nameservers > 0) {
- free(__nameserver[--__nameservers]);
- __nameserver[__nameservers] = NULL;
- }
- while (__searchdomains > 0) {
- free(__searchdomain[--__searchdomains]);
- __searchdomain[__searchdomains] = NULL;
- }
- __UCLIBC_MUTEX_UNLOCK(__resolv_lock);
-}
-#endif
-
-#ifdef L_gethostbyname
-
-struct hostent *gethostbyname(const char *name)
-{
- static struct hostent h;
- static char buf[sizeof(struct in_addr) +
- sizeof(struct in_addr *)*2 +
- sizeof(char *)*ALIAS_DIM + 384/*namebuffer*/ + 32/* margin */];
- struct hostent *hp;
-
- gethostbyname_r(name, &h, buf, sizeof(buf), &hp, &h_errno);
-
- return hp;
-}
-libc_hidden_def(gethostbyname)
-#endif
-
-#ifdef L_gethostbyname2
-
-struct hostent *gethostbyname2(const char *name, int family)
-{
-#ifndef __UCLIBC_HAS_IPV6__
- return family == AF_INET ? gethostbyname(name) : (struct hostent*)0;
-#else /* __UCLIBC_HAS_IPV6__ */
- static struct hostent h;
- static char buf[sizeof(struct in6_addr) +
- sizeof(struct in6_addr *)*2 +
- sizeof(char *)*ALIAS_DIM + 384/*namebuffer*/ + 32/* margin */];
- struct hostent *hp;
-
- gethostbyname2_r(name, family, &h, buf, sizeof(buf), &hp, &h_errno);
-
- return hp;
-#endif /* __UCLIBC_HAS_IPV6__ */
-}
-#endif
-
-
-
-#ifdef L_res_init
-/* We use __resolv_lock to guard access to global '_res' */
-struct __res_state _res;
-
-int res_init(void)
-{
- struct __res_state *rp = &(_res);
-
- __UCLIBC_MUTEX_LOCK(__resolv_lock); /* must be a recursive lock! */
- __close_nameservers();
- __open_nameservers();
- rp->retrans = RES_TIMEOUT;
- rp->retry = 4;
- rp->options = RES_INIT;
- rp->id = (u_int) random();
- rp->nsaddr.sin_addr.s_addr = INADDR_ANY;
- rp->nsaddr.sin_family = AF_INET;
- rp->nsaddr.sin_port = htons(NAMESERVER_PORT);
- rp->ndots = 1;
- /** rp->pfcode = 0; **/
- rp->_vcsock = -1;
- /** rp->_flags = 0; **/
- /** rp->qhook = NULL; **/
- /** rp->rhook = NULL; **/
- /** rp->_u._ext.nsinit = 0; **/
-
- if (__searchdomains) {
- int i;
- for (i = 0; i < __searchdomains; i++)
- rp->dnsrch[i] = __searchdomain[i];
- }
-
- if (__nameservers) {
- int i;
- struct in_addr a;
- for (i = 0; i < __nameservers; i++) {
- if (inet_aton(__nameserver[i], &a)) {
- rp->nsaddr_list[i].sin_addr = a;
- rp->nsaddr_list[i].sin_family = AF_INET;
- rp->nsaddr_list[i].sin_port = htons(NAMESERVER_PORT);
- }
- }
- }
- rp->nscount = __nameservers;
- __UCLIBC_MUTEX_UNLOCK(__resolv_lock);
-
- return 0;
-}
-libc_hidden_def(res_init)
-
-#ifdef __UCLIBC_HAS_BSD_RES_CLOSE__
-void res_close(void)
-{
- __close_nameservers();
- memset(&_res, 0, sizeof(_res));
-}
-#endif
-
-#endif
-
-
-#ifdef L_res_query
-
-#ifndef MIN
-#define MIN(x, y) ((x) < (y) ? (x) : (y))
-#endif
-
-int res_query(const char *dname, int class, int type,
- unsigned char *answer, int anslen)
-{
- int i;
- unsigned char * packet = 0;
- struct resolv_answer a;
- int __nameserversXX;
- char ** __nameserverXX;
-
- __open_nameservers();
- if (!dname || class != 1 /* CLASS_IN */) {
- h_errno = NO_RECOVERY;
- return -1;
- }
-
- memset(&a, '\0', sizeof(a));
-
- __UCLIBC_MUTEX_LOCK(__resolv_lock);
- __nameserversXX = __nameservers;
- __nameserverXX = __nameserver;
- __UCLIBC_MUTEX_UNLOCK(__resolv_lock);
- i = __dns_lookup(dname, type, __nameserversXX, __nameserverXX, &packet, &a);
-
- if (i < 0) {
- h_errno = TRY_AGAIN;
- return -1;
- }
-
- free(a.dotted);
-
- if (a.atype == type) { /* CNAME */
- i = MIN(anslen, i);
- memcpy(answer, packet, i);
- }
- free(packet);
- return i;
-}
-libc_hidden_def(res_query)
-
-/*
- * Formulate a normal query, send, and retrieve answer in supplied buffer.
- * Return the size of the response on success, -1 on error.
- * If enabled, implement search rules until answer or unrecoverable failure
- * is detected. Error code, if any, is left in h_errno.
- */
-#define __TRAILING_DOT (1<<0)
-#define __GOT_NODATA (1<<1)
-#define __GOT_SERVFAIL (1<<2)
-#define __TRIED_AS_IS (1<<3)
-int res_search(const char *name, int class, int type, u_char *answer,
- int anslen)
-{
- const char *cp, * const *domain;
- HEADER *hp = (HEADER *)(void *)answer;
- u_int dots;
- unsigned _state = 0;
- int ret, saved_herrno;
- u_long _res_options;
- unsigned _res_ndots;
- char **_res_dnsrch;
-
- __UCLIBC_MUTEX_LOCK(__resolv_lock);
- _res_options = _res.options;
- __UCLIBC_MUTEX_UNLOCK(__resolv_lock);
- if ((!name || !answer) || ((_res_options & RES_INIT) == 0 && res_init() == -1)) {
- h_errno = NETDB_INTERNAL;
- return -1;
- }
-
- errno = 0;
- h_errno = HOST_NOT_FOUND; /* default, if we never query */
- dots = 0;
- for (cp = name; *cp; cp++)
- dots += (*cp == '.');
-
- if (cp > name && *--cp == '.')
- _state |= __TRAILING_DOT;
-
- /*
- * If there are dots in the name already, let's just give it a try
- * 'as is'. The threshold can be set with the "ndots" option.
- */
- saved_herrno = -1;
- __UCLIBC_MUTEX_LOCK(__resolv_lock);
- _res_ndots = _res.ndots;
- __UCLIBC_MUTEX_UNLOCK(__resolv_lock);
- if (dots >= _res_ndots) {
- ret = res_querydomain(name, NULL, class, type, answer, anslen);
- if (ret > 0)
- return ret;
- saved_herrno = h_errno;
- _state |= __TRIED_AS_IS;
- }
-
- /*
- * We do at least one level of search if
- * - there is no dot and RES_DEFNAME is set, or
- * - there is at least one dot, there is no trailing dot,
- * and RES_DNSRCH is set.
- */
- __UCLIBC_MUTEX_LOCK(__resolv_lock);
- _res_options = _res.options;
- _res_dnsrch = _res.dnsrch;
- __UCLIBC_MUTEX_UNLOCK(__resolv_lock);
- if ((!dots && (_res_options & RES_DEFNAMES)) ||
- (dots && !(_state & __TRAILING_DOT) && (_res_options & RES_DNSRCH))) {
- bool done = 0;
-
- for (domain = (const char * const *)_res_dnsrch;
- *domain && !done;
- domain++) {
-
- ret = res_querydomain(name, *domain, class, type,
- answer, anslen);
- if (ret > 0)
- return ret;
-
- /*
- * If no server present, give up.
- * If name isn't found in this domain,
- * keep trying higher domains in the search list
- * (if that's enabled).
- * On a NO_DATA error, keep trying, otherwise
- * a wildcard entry of another type could keep us
- * from finding this entry higher in the domain.
- * If we get some other error (negative answer or
- * server failure), then stop searching up,
- * but try the input name below in case it's
- * fully-qualified.
- */
- if (errno == ECONNREFUSED) {
- h_errno = TRY_AGAIN;
- return -1;
- }
-
- switch (h_errno) {
- case NO_DATA:
- _state |= __GOT_NODATA;
- /* FALLTHROUGH */
- case HOST_NOT_FOUND:
- /* keep trying */
- break;
- case TRY_AGAIN:
- if (hp->rcode == SERVFAIL) {
- /* try next search element, if any */
- _state |= __GOT_SERVFAIL;
- break;
- }
- /* FALLTHROUGH */
- default:
- /* anything else implies that we're done */
- done = 1;
- }
- /*
- * if we got here for some reason other than DNSRCH,
- * we only wanted one iteration of the loop, so stop.
- */
- __UCLIBC_MUTEX_LOCK(__resolv_lock);
- _res_options = _res.options;
- __UCLIBC_MUTEX_UNLOCK(__resolv_lock);
- if (!(_res_options & RES_DNSRCH))
- done = 1;
- }
- }
-
- /*
- * if we have not already tried the name "as is", do that now.
- * note that we do this regardless of how many dots were in the
- * name or whether it ends with a dot.
- */
- if (!(_state & __TRIED_AS_IS)) {
- ret = res_querydomain(name, NULL, class, type, answer, anslen);
- if (ret > 0)
- return ret;
- }
+#ifdef L_read_etc_hosts_r
- /*
- * if we got here, we didn't satisfy the search.
- * if we did an initial full query, return that query's h_errno
- * (note that we wouldn't be here if that query had succeeded).
- * else if we ever got a nodata, send that back as the reason.
- * else send back meaningless h_errno, that being the one from
- * the last DNSRCH we did.
- */
- if (saved_herrno != -1)
- h_errno = saved_herrno;
- else if (_state & __GOT_NODATA)
- h_errno = NO_DATA;
- else if (_state & __GOT_SERVFAIL)
- h_errno = TRY_AGAIN;
- return -1;
-}
-#undef __TRAILING_DOT
-#undef __GOT_NODATA
-#undef __GOT_SERVFAIL
-#undef __TRIED_AS_IS
-/*
- * Perform a call on res_query on the concatenation of name and domain,
- * removing a trailing dot from name if domain is NULL.
- */
-int res_querydomain(const char *name, const char *domain, int class, int type,
- u_char * answer, int anslen)
+parser_t * __open_etc_hosts(void)
{
- char nbuf[MAXDNAME];
- const char *longname = nbuf;
- size_t n, d;
- u_long _res_options;
-
- __UCLIBC_MUTEX_LOCK(__resolv_lock);
- _res_options = _res.options;
- __UCLIBC_MUTEX_UNLOCK(__resolv_lock);
- if ((!name || !answer) || ((_res_options & RES_INIT) == 0 && res_init() == -1)) {
- h_errno = NETDB_INTERNAL;
- return -1;
- }
-
-#ifdef DEBUG
- __UCLIBC_MUTEX_LOCK(__resolv_lock);
- _res_options = _res.options;
- __UCLIBC_MUTEX_UNLOCK(__resolv_lock);
- if (_res_options & RES_DEBUG)
- printf(";; res_querydomain(%s, %s, %d, %d)\n",
- name, (domain ? domain : "<Nil>"), class, type);
+ parser_t *parser;
+ parser = config_open("/etc/hosts");
+#ifdef FALLBACK_TO_CONFIG_RESOLVCONF
+ if (parser == NULL)
+ parser = config_open("/etc/config/hosts");
#endif
- if (domain == NULL) {
- /*
- * Check for trailing '.';
- * copy without '.' if present.
- */
- n = strlen(name);
- if (n + 1 > sizeof(nbuf)) {
- h_errno = NO_RECOVERY;
- return -1;
- }
- if (n > 0 && name[--n] == '.') {
- strncpy(nbuf, name, n);
- nbuf[n] = '\0';
- } else
- longname = name;
- } else {
- n = strlen(name);
- d = strlen(domain);
- if (n + 1 + d + 1 > sizeof(nbuf)) {
- h_errno = NO_RECOVERY;
- return -1;
- }
- snprintf(nbuf, sizeof(nbuf), "%s.%s", name, domain);
- }
- return res_query(longname, class, type, answer, anslen);
+ return parser;
}
-libc_hidden_def(res_querydomain)
-
-/* res_mkquery */
-/* res_send */
-/* dn_comp */
-/* dn_expand */
-#endif
-#ifdef L_gethostbyaddr
-struct hostent *gethostbyaddr (const void *addr, socklen_t len, int type)
+#define MINTOKENS 2 /* ip address + canonical name */
+#define MAXTOKENS (MINTOKENS + MAXALIASES)
+#define HALISTOFF (sizeof(char*) * (MAXTOKENS + 1)) /* reserve space for list terminator */
+#define INADDROFF (HALISTOFF + 2 * sizeof(char*))
+
+int __read_etc_hosts_r(
+ parser_t * parser,
+ const char *name,
+ int type,
+ enum etc_hosts_action action,
+ struct hostent *result_buf,
+ char *buf, size_t buflen,
+ struct hostent **result,
+ int *h_errnop)
{
- static struct hostent h;
- static char buf[
-#ifndef __UCLIBC_HAS_IPV6__
- sizeof(struct in_addr) + sizeof(struct in_addr *)*2 +
+ char **tok = NULL;
+ struct in_addr *h_addr0 = NULL;
+ const size_t aliaslen = INADDROFF +
+#ifdef __UCLIBC_HAS_IPV6__
+ sizeof(struct in6_addr)
#else
- sizeof(struct in6_addr) + sizeof(struct in6_addr *)*2 +
-#endif /* __UCLIBC_HAS_IPV6__ */
- sizeof(char *)*ALIAS_DIM + 384 /*namebuffer*/ + 32 /* margin */];
- struct hostent *hp;
-
- gethostbyaddr_r(addr, len, type, &h, buf, sizeof(buf), &hp, &h_errno);
-
- return hp;
-}
-libc_hidden_def(gethostbyaddr)
+ sizeof(struct in_addr)
#endif
+ ;
+ int ret = HOST_NOT_FOUND;
+ /* make sure pointer is aligned */
+ int i = ALIGN_BUFFER_OFFSET(buf);
+ buf += i;
+ buflen -= i;
-
-#ifdef L_read_etc_hosts_r
-
-FILE * __open_etc_hosts(void)
-{
- FILE * fp;
- if ((fp = fopen("/etc/hosts", "r")) == NULL) {
- fp = fopen("/etc/config/hosts", "r");
- }
- return fp;
-}
-
-int attribute_hidden __read_etc_hosts_r(FILE * fp, const char * name, int type,
- enum etc_hosts_action action,
- struct hostent * result_buf,
- char * buf, size_t buflen,
- struct hostent ** result,
- int * h_errnop)
-{
- struct in_addr *in = NULL;
- struct in_addr **addr_list = NULL;
-#ifdef __UCLIBC_HAS_IPV6__
- struct in6_addr *in6 = NULL;
- struct in6_addr **addr_list6 =NULL;
-#endif /* __UCLIBC_HAS_IPV6__ */
- char *cp, **alias;
- int aliases, i, ret = HOST_NOT_FOUND;
-
- /* make sure user char * is aligned */
- i = ALIGN_BUFFER_OFFSET(buf);
- if (unlikely(i)) {
- if (buflen < i)
- return ERANGE;
- buf += i;
- buflen -= i;
- }
-
- if (buflen < sizeof(char *)*ALIAS_DIM)
+ *h_errnop = NETDB_INTERNAL;
+ if (/* (ssize_t)buflen < 0 || */ buflen < aliaslen
+ || (buflen - aliaslen) < BUFSZ + 1)
return ERANGE;
- alias = (char **)buf;
- buf += sizeof(char **)*ALIAS_DIM;
- buflen -= sizeof(char **)*ALIAS_DIM;
-
- if (action != GETHOSTENT) {
-#ifdef __UCLIBC_HAS_IPV6__
- char *p = buf;
- size_t len = buflen;
-#endif /* __UCLIBC_HAS_IPV6__ */
- *h_errnop = NETDB_INTERNAL;
- if (buflen < sizeof(*in))
- return ERANGE;
- in = (struct in_addr*)buf;
- buf += sizeof(*in);
- buflen -= sizeof(*in);
-
- if (buflen < sizeof(*addr_list)*2)
- return ERANGE;
- addr_list = (struct in_addr **)buf;
- buf += sizeof(*addr_list)*2;
- buflen -= sizeof(*addr_list)*2;
-
-#ifdef __UCLIBC_HAS_IPV6__
- if (len < sizeof(*in6))
- return ERANGE;
- in6 = (struct in6_addr*)p;
- p += sizeof(*in6);
- len -= sizeof(*in6);
-
- if (len < sizeof(*addr_list6)*2)
- return ERANGE;
- addr_list6 = (struct in6_addr**)p;
- p += sizeof(*addr_list6)*2;
- len -= sizeof(*addr_list6)*2;
-
- if (len < buflen) {
- buflen = len;
- buf = p;
- }
-#endif /* __UCLIBC_HAS_IPV6__ */
-
- if (buflen < 80)
- return ERANGE;
-
- fp = __open_etc_hosts();
- if (fp == NULL) {
- result = NULL;
- return errno;
- }
+ if (parser == NULL)
+ parser = __open_etc_hosts();
+ if (parser == NULL) {
+ *result = NULL;
+ return errno;
}
-
+ /* Layout in buf:
+ * char *alias[MAXTOKENS] = {address, name, aliases...}
+ * char **h_addr_list[1] = {*in[6]_addr, NULL}
+ * struct in[6]_addr
+ * char line_buffer[BUFSZ+];
+ */
+ parser->data = buf;
+ parser->data_len = aliaslen;
+ parser->line_len = buflen - aliaslen;
*h_errnop = HOST_NOT_FOUND;
- while (fgets(buf, buflen, fp)) {
- if ((cp = strchr(buf, '#')))
- *cp = '\0';
- DPRINTF("Looking at: %s\n", buf);
- aliases = 0;
-
- cp = buf;
- while (*cp) {
- while (*cp && isspace(*cp))
- *cp++ = '\0';
- if (!*cp)
- continue;
- if (aliases < (2+MAX_ALIASES))
- alias[aliases++] = cp;
- while (*cp && !isspace(*cp))
- cp++;
- }
- alias[aliases] = 0;
-
- if (aliases < 2)
- continue; /* syntax error really */
-
+ /* <ip>[[:space:]][<aliases>] */
+ while (config_read(parser, &tok, MAXTOKENS, MINTOKENS, "# \t", PARSE_NORMAL)) {
+ result_buf->h_aliases = tok+1;
if (action == GETHOSTENT) {
/* Return whatever the next entry happens to be. */
- break;
+ ;
} else if (action == GET_HOSTS_BYADDR) {
- if (strcmp(name, alias[0]) != 0)
- continue;
- } else {
- /* GET_HOSTS_BYNAME */
- for (i = 1; i < aliases; i++)
- if (strcasecmp(name, alias[i]) == 0)
- break;
- if (i >= aliases)
+ if (strcmp(name, *tok) != 0)
continue;
+ } else { /* GET_HOSTS_BYNAME */
+ int aliases = 0;
+ char **alias = tok + 1;
+ while (aliases < MAXALIASES) {
+ char *tmp = *(alias+aliases++);
+ if (tmp && strcasecmp(name, tmp) == 0)
+ goto found;
+ }
+ continue;
}
-
- if (type == AF_INET && inet_pton(AF_INET, alias[0], in) > 0) {
+found:
+ result_buf->h_name = *(result_buf->h_aliases++);
+ result_buf->h_addr_list = (char**)(buf + HALISTOFF);
+ *(result_buf->h_addr_list + 1) = '\0';
+ h_addr0 = (struct in_addr*)(buf + INADDROFF);
+ result_buf->h_addr = (char*)h_addr0;
+ if (0) /* nothing */;
+#ifdef __UCLIBC_HAS_IPV4__
+ else if (type == AF_INET
+ && inet_pton(AF_INET, *tok, h_addr0) > 0) {
DPRINTF("Found INET\n");
- addr_list[0] = in;
- addr_list[1] = 0;
- result_buf->h_name = alias[1];
result_buf->h_addrtype = AF_INET;
- result_buf->h_length = sizeof(*in);
- result_buf->h_addr_list = (char**) addr_list;
- result_buf->h_aliases = alias + 2;
+ result_buf->h_length = sizeof(struct in_addr);
*result = result_buf;
ret = NETDB_SUCCESS;
+ }
+#endif
#ifdef __UCLIBC_HAS_IPV6__
- } else if (type == AF_INET6 && inet_pton(AF_INET6, alias[0], in6) > 0) {
+#define in6 ((struct in6_addr *)buf)
+ else if (type == AF_INET6
+ && inet_pton(AF_INET6, *tok, h_addr0) > 0) {
DPRINTF("Found INET6\n");
- addr_list6[0] = in6;
- addr_list6[1] = 0;
- result_buf->h_name = alias[1];
result_buf->h_addrtype = AF_INET6;
- result_buf->h_length = sizeof(*in6);
- result_buf->h_addr_list = (char**) addr_list6;
- result_buf->h_aliases = alias + 2;
+ result_buf->h_length = sizeof(struct in6_addr);
*result = result_buf;
ret = NETDB_SUCCESS;
-#endif /* __UCLIBC_HAS_IPV6__ */
- } else {
+ }
+#endif
+ else {
/* continue parsing in the hope the user has multiple
* host types listed in the database like so:
* <ipv4 addr> host
* <ipv6 addr> host
* If looking for an IPv6 addr, don't bail when we got the IPv4
*/
- DPRINTF("Error: Found host but diff network type\n");
+ DPRINTF("Error: Found host but different address family\n");
+ /* NB: gethostbyname2_r depends on this feature
+ * to avoid looking for IPv6 addr of "localhost" etc */
ret = TRY_AGAIN;
continue;
}
-
- if (action != GETHOSTENT)
- fclose(fp);
- return ret;
+ break;
}
if (action != GETHOSTENT)
- fclose(fp);
+ config_close(parser);
return ret;
+#undef in6
}
-#endif
-
-
-#ifdef L_gethostent
-__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER);
+#endif /* L_read_etc_hosts_r */
-static smallint __stay_open;
-static FILE * __gethostent_fp;
-
-void endhostent(void)
-{
- __UCLIBC_MUTEX_LOCK(mylock);
- __stay_open = 0;
- if (__gethostent_fp) {
- fclose(__gethostent_fp);
- __gethostent_fp = NULL;
- }
- __UCLIBC_MUTEX_UNLOCK(mylock);
-}
-
-void sethostent(int stay_open)
-{
- __UCLIBC_MUTEX_LOCK(mylock);
- __stay_open = (stay_open != 0);
- __UCLIBC_MUTEX_UNLOCK(mylock);
-}
-
-int gethostent_r(struct hostent *result_buf, char *buf, size_t buflen,
- struct hostent **result, int *h_errnop)
-{
- int ret;
-
- __UCLIBC_MUTEX_LOCK(mylock);
- if (__gethostent_fp == NULL) {
- __gethostent_fp = __open_etc_hosts();
- if (__gethostent_fp == NULL) {
- *result = NULL;
- ret = TRY_AGAIN;
- goto DONE;
- }
- }
-
- ret = __read_etc_hosts_r(__gethostent_fp, NULL, AF_INET, GETHOSTENT,
- result_buf, buf, buflen, result, h_errnop);
- if (__stay_open == 0) {
- fclose(__gethostent_fp);
- __gethostent_fp = NULL;
- }
-DONE:
- __UCLIBC_MUTEX_UNLOCK(mylock);
- return ret;
-}
-libc_hidden_def(gethostent_r)
-
-struct hostent *gethostent(void)
-{
- static struct hostent h;
- static char buf[
-#ifndef __UCLIBC_HAS_IPV6__
- sizeof(struct in_addr) + sizeof(struct in_addr *)*2 +
-#else
- sizeof(struct in6_addr) + sizeof(struct in6_addr *)*2 +
-#endif /* __UCLIBC_HAS_IPV6__ */
- sizeof(char *)*ALIAS_DIM +
- 80 /*namebuffer*/ + 2 /* margin */];
- struct hostent *host;
-
- __UCLIBC_MUTEX_LOCK(mylock);
- gethostent_r(&h, buf, sizeof(buf), &host, &h_errno);
- __UCLIBC_MUTEX_UNLOCK(mylock);
- return host;
-}
-#endif
#ifdef L_get_hosts_byname_r
-int attribute_hidden __get_hosts_byname_r(const char * name, int type,
- struct hostent * result_buf,
- char * buf, size_t buflen,
- struct hostent ** result,
- int * h_errnop)
+int __get_hosts_byname_r(const char *name,
+ int type,
+ struct hostent *result_buf,
+ char *buf,
+ size_t buflen,
+ struct hostent **result,
+ int *h_errnop)
{
return __read_etc_hosts_r(NULL, name, type, GET_HOSTS_BYNAME,
result_buf, buf, buflen, result, h_errnop);
}
-#endif
+#endif /* L_get_hosts_byname_r */
+
#ifdef L_get_hosts_byaddr_r
-int attribute_hidden __get_hosts_byaddr_r(const char * addr, int len, int type,
- struct hostent * result_buf,
- char * buf, size_t buflen,
- struct hostent ** result,
- int * h_errnop)
+int __get_hosts_byaddr_r(const char *addr,
+ int len,
+ int type,
+ struct hostent *result_buf,
+ char *buf,
+ size_t buflen,
+ struct hostent **result,
+ int *h_errnop)
{
#ifndef __UCLIBC_HAS_IPV6__
char ipaddr[INET_ADDRSTRLEN];
#else
char ipaddr[INET6_ADDRSTRLEN];
-#endif /* __UCLIBC_HAS_IPV6__ */
+#endif
switch (type) {
+#ifdef __UCLIBC_HAS_IPV4__
case AF_INET:
if (len != sizeof(struct in_addr))
return 0;
break;
+#endif
#ifdef __UCLIBC_HAS_IPV6__
case AF_INET6:
if (len != sizeof(struct in6_addr))
return 0;
break;
-#endif /* __UCLIBC_HAS_IPV6__ */
+#endif
default:
return 0;
}
@@ -1819,156 +1776,152 @@ int attribute_hidden __get_hosts_byaddr_r(const char * addr, int len, int type,
inet_ntop(type, addr, ipaddr, sizeof(ipaddr));
return __read_etc_hosts_r(NULL, ipaddr, type, GET_HOSTS_BYADDR,
- result_buf, buf, buflen, result, h_errnop);
+ result_buf, buf, buflen, result, h_errnop);
}
-#endif
+#endif /* L_get_hosts_byaddr_r */
-#ifdef L_getnameinfo
-#ifndef min
-# define min(x,y) (((x) > (y)) ? (y) : (x))
-#endif /* min */
+#ifdef L_getnameinfo
-libc_hidden_proto(getnameinfo)
-int getnameinfo(const struct sockaddr *sa, socklen_t addrlen, char *host,
- socklen_t hostlen, char *serv, socklen_t servlen,
- unsigned int flags)
+int getnameinfo(const struct sockaddr *sa,
+ socklen_t addrlen,
+ char *host,
+ socklen_t hostlen,
+ char *serv,
+ socklen_t servlen,
+ unsigned flags)
{
int serrno = errno;
- unsigned ok;
- struct hostent *h = NULL;
+ bool ok = 0;
+ struct hostent *hoste = NULL;
char domain[256];
if (flags & ~(NI_NUMERICHOST|NI_NUMERICSERV|NI_NOFQDN|NI_NAMEREQD|NI_DGRAM))
return EAI_BADFLAGS;
- if (sa == NULL || addrlen < sizeof (sa_family_t))
- goto BAD_FAM;
+ if (sa == NULL || addrlen < sizeof(sa_family_t))
+ return EAI_FAMILY;
- ok = sa->sa_family;
- if (ok == AF_LOCAL) /* valid */;
+ if (sa->sa_family == AF_LOCAL) /* valid */;
#ifdef __UCLIBC_HAS_IPV4__
- else if (ok == AF_INET) {
- if (addrlen < sizeof (struct sockaddr_in))
- goto BAD_FAM;
+ else if (sa->sa_family == AF_INET) {
+ if (addrlen < sizeof(struct sockaddr_in))
+ return EAI_FAMILY;
}
#endif
#ifdef __UCLIBC_HAS_IPV6__
- else if (ok == AF_INET6) {
- if (addrlen < sizeof (struct sockaddr_in6))
- goto BAD_FAM;
+ else if (sa->sa_family == AF_INET6) {
+ if (addrlen < sizeof(struct sockaddr_in6))
+ return EAI_FAMILY;
}
-#endif /* __UCLIBC_HAS_IPV6__ */
+#endif
else
-BAD_FAM:
return EAI_FAMILY;
- ok = 0;
if (host != NULL && hostlen > 0)
switch (sa->sa_family) {
case AF_INET:
#ifdef __UCLIBC_HAS_IPV6__
case AF_INET6:
-#endif /* __UCLIBC_HAS_IPV6__ */
+#endif
if (!(flags & NI_NUMERICHOST)) {
+ if (0) /* nothing */;
#ifdef __UCLIBC_HAS_IPV6__
- if (sa->sa_family == AF_INET6)
- h = gethostbyaddr ((const void *)
+ else if (sa->sa_family == AF_INET6)
+ hoste = gethostbyaddr((const void *)
&(((const struct sockaddr_in6 *) sa)->sin6_addr),
sizeof(struct in6_addr), AF_INET6);
-#endif /* __UCLIBC_HAS_IPV6__ */
-#if defined __UCLIBC_HAS_IPV6__ && defined __UCLIBC_HAS_IPV4__
- else
#endif
#ifdef __UCLIBC_HAS_IPV4__
- h = gethostbyaddr ((const void *) &(((const struct sockaddr_in *)sa)->sin_addr),
- sizeof(struct in_addr), AF_INET);
-#endif /* __UCLIBC_HAS_IPV4__ */
+ else
+ hoste = gethostbyaddr((const void *)
+ &(((const struct sockaddr_in *)sa)->sin_addr),
+ sizeof(struct in_addr), AF_INET);
+#endif
- if (h) {
+ if (hoste) {
char *c;
if ((flags & NI_NOFQDN)
- && (__libc_getdomainname (domain, sizeof(domain)) == 0)
- && (c = strstr (h->h_name, domain))
- && (c != h->h_name) && (*(--c) == '.')) {
- strncpy (host, h->h_name,
- min(hostlen, (size_t) (c - h->h_name)));
- host[min(hostlen - 1, (size_t) (c - h->h_name))] = '\0';
- ok = 1;
+ && (getdomainname(domain, sizeof(domain)) == 0)
+ && (c = strstr(hoste->h_name, domain)) != NULL
+ && (c != hoste->h_name) && (*(--c) == '.')
+ ) {
+ strncpy(host, hoste->h_name,
+ MIN(hostlen, (size_t) (c - hoste->h_name)));
+ host[MIN(hostlen - 1, (size_t) (c - hoste->h_name))] = '\0';
} else {
- strncpy (host, h->h_name, hostlen);
- ok = 1;
+ strncpy(host, hoste->h_name, hostlen);
}
- }
+ ok = 1;
+ }
}
if (!ok) {
+ const char *c = NULL;
+
if (flags & NI_NAMEREQD) {
errno = serrno;
return EAI_NONAME;
- } else {
- const char *c;
+ }
+ if (0) /* nothing */;
#ifdef __UCLIBC_HAS_IPV6__
- if (sa->sa_family == AF_INET6) {
- const struct sockaddr_in6 *sin6p;
+ else if (sa->sa_family == AF_INET6) {
+ const struct sockaddr_in6 *sin6p;
- sin6p = (const struct sockaddr_in6 *) sa;
-
- c = inet_ntop (AF_INET6,
- (const void *) &sin6p->sin6_addr, host, hostlen);
+ sin6p = (const struct sockaddr_in6 *) sa;
+ c = inet_ntop(AF_INET6,
+ (const void *) &sin6p->sin6_addr,
+ host, hostlen);
#if 0
- /* Does scope id need to be supported? */
- uint32_t scopeid;
- scopeid = sin6p->sin6_scope_id;
- if (scopeid != 0) {
- /* Buffer is >= IFNAMSIZ+1. */
- char scopebuf[IFNAMSIZ + 1];
- char *scopeptr;
- int ni_numericscope = 0;
- size_t real_hostlen = strnlen (host, hostlen);
- size_t scopelen = 0;
-
- scopebuf[0] = SCOPE_DELIMITER;
- scopebuf[1] = '\0';
- scopeptr = &scopebuf[1];
-
- if (IN6_IS_ADDR_LINKLOCAL (&sin6p->sin6_addr)
- || IN6_IS_ADDR_MC_LINKLOCAL (&sin6p->sin6_addr)) {
- if (if_indextoname (scopeid, scopeptr) == NULL)
- ++ni_numericscope;
- else
- scopelen = strlen (scopebuf);
- } else {
+ /* Does scope id need to be supported? */
+ uint32_t scopeid;
+ scopeid = sin6p->sin6_scope_id;
+ if (scopeid != 0) {
+ /* Buffer is >= IFNAMSIZ+1. */
+ char scopebuf[IFNAMSIZ + 1];
+ char *scopeptr;
+ int ni_numericscope = 0;
+ size_t real_hostlen = strnlen(host, hostlen);
+ size_t scopelen = 0;
+
+ scopebuf[0] = SCOPE_DELIMITER;
+ scopebuf[1] = '\0';
+ scopeptr = &scopebuf[1];
+
+ if (IN6_IS_ADDR_LINKLOCAL(&sin6p->sin6_addr)
+ || IN6_IS_ADDR_MC_LINKLOCAL(&sin6p->sin6_addr)) {
+ if (if_indextoname(scopeid, scopeptr) == NULL)
++ni_numericscope;
- }
-
- if (ni_numericscope)
- scopelen = 1 + snprintf (scopeptr,
- (scopebuf
- + sizeof scopebuf
- - scopeptr),
- "%u", scopeid);
-
- if (real_hostlen + scopelen + 1 > hostlen)
- return EAI_SYSTEM;
- memcpy (host + real_hostlen, scopebuf, scopelen + 1);
+ else
+ scopelen = strlen(scopebuf);
+ } else {
+ ++ni_numericscope;
}
-#endif
+
+ if (ni_numericscope)
+ scopelen = 1 + snprintf(scopeptr,
+ (scopebuf
+ + sizeof scopebuf
+ - scopeptr),
+ "%u", scopeid);
+
+ if (real_hostlen + scopelen + 1 > hostlen)
+ return EAI_SYSTEM;
+ memcpy(host + real_hostlen, scopebuf, scopelen + 1);
}
+#endif
+ }
#endif /* __UCLIBC_HAS_IPV6__ */
-#if defined __UCLIBC_HAS_IPV6__ && defined __UCLIBC_HAS_IPV4__
- else
-#endif /* __UCLIBC_HAS_IPV6__ && defined __UCLIBC_HAS_IPV4__ */
#if defined __UCLIBC_HAS_IPV4__
- c = inet_ntop (AF_INET, (const void *)
- &(((const struct sockaddr_in *) sa)->sin_addr),
- host, hostlen);
-#endif /* __UCLIBC_HAS_IPV4__ */
-
- if (c == NULL) {
- errno = serrno;
- return EAI_SYSTEM;
- }
+ else {
+ c = inet_ntop(AF_INET, (const void *)
+ &(((const struct sockaddr_in *) sa)->sin_addr),
+ host, hostlen);
+ }
+#endif
+ if (c == NULL) {
+ errno = serrno;
+ return EAI_SYSTEM;
}
ok = 1;
}
@@ -1978,8 +1931,8 @@ BAD_FAM:
if (!(flags & NI_NUMERICHOST)) {
struct utsname utsname;
- if (!uname (&utsname)) {
- strncpy (host, utsname.nodename, hostlen);
+ if (!uname(&utsname)) {
+ strncpy(host, utsname.nodename, hostlen);
break;
};
};
@@ -1989,29 +1942,29 @@ BAD_FAM:
return EAI_NONAME;
}
- strncpy (host, "localhost", hostlen);
+ strncpy(host, "localhost", hostlen);
break;
-
-/*Already checked above default:
+/* Already checked above
+ default:
return EAI_FAMILY;
*/
}
if (serv && (servlen > 0)) {
if (sa->sa_family == AF_LOCAL) {
- strncpy (serv, ((const struct sockaddr_un *) sa)->sun_path, servlen);
+ strncpy(serv, ((const struct sockaddr_un *) sa)->sun_path, servlen);
} else { /* AF_INET || AF_INET6 */
if (!(flags & NI_NUMERICSERV)) {
struct servent *s;
- s = getservbyport (((const struct sockaddr_in *) sa)->sin_port,
+ s = getservbyport(((const struct sockaddr_in *) sa)->sin_port,
((flags & NI_DGRAM) ? "udp" : "tcp"));
if (s) {
- strncpy (serv, s->s_name, servlen);
+ strncpy(serv, s->s_name, servlen);
goto DONE;
}
}
- snprintf (serv, servlen, "%d",
- ntohs (((const struct sockaddr_in *) sa)->sin_port));
+ snprintf(serv, servlen, "%d",
+ ntohs(((const struct sockaddr_in *) sa)->sin_port));
}
}
DONE:
@@ -2023,41 +1976,69 @@ DONE:
return 0;
}
libc_hidden_def(getnameinfo)
-#endif
+#endif /* L_getnameinfo */
#ifdef L_gethostbyname_r
-int gethostbyname_r(const char * name,
- struct hostent * result_buf,
- char * buf, size_t buflen,
- struct hostent ** result,
- int * h_errnop)
+/* Bug 671 says:
+ * "uClibc resolver's gethostbyname does not return the requested name
+ * as an alias, but instead returns the canonical name. glibc's
+ * gethostbyname has a similar bug where it returns the requested name
+ * with the search domain name appended (to make a FQDN) as an alias,
+ * but not the original name itself. Both contradict POSIX, which says
+ * that the name argument passed to gethostbyname must be in the alias list"
+ * This is fixed now, and we differ from glibc:
+ *
+ * $ ./gethostbyname_uclibc wer.google.com
+ * h_name:'c13-ss-2-lb.cnet.com'
+ * h_length:4
+ * h_addrtype:2 AF_INET
+ * alias:'wer.google.com' <===
+ * addr: 0x4174efd8 '216.239.116.65'
+ *
+ * $ ./gethostbyname_glibc wer.google.com
+ * h_name:'c13-ss-2-lb.cnet.com'
+ * h_length:4
+ * h_addrtype:2 AF_INET
+ * alias:'wer.google.com.com' <===
+ * addr:'216.239.116.65'
+ *
+ * When examples were run, /etc/resolv.conf contained "search com" line.
+ */
+int gethostbyname_r(const char *name,
+ struct hostent *result_buf,
+ char *buf,
+ size_t buflen,
+ struct hostent **result,
+ int *h_errnop)
{
- struct in_addr *in;
struct in_addr **addr_list;
char **alias;
+ char *alias0;
unsigned char *packet;
struct resolv_answer a;
int i;
- int __nameserversXX;
- char ** __nameserverXX;
+ int packet_len;
+ int wrong_af = 0;
- __open_nameservers();
*result = NULL;
if (!name)
return EINVAL;
/* do /etc/hosts first */
{
- int old_errno = errno; /* Save the old errno and reset errno */
- __set_errno(0); /* to check for missing /etc/hosts. */
-
- if ((i = __get_hosts_byname_r(name, AF_INET, result_buf,
- buf, buflen, result, h_errnop)) == 0)
+ int old_errno = errno; /* save the old errno and reset errno */
+ __set_errno(0); /* to check for missing /etc/hosts. */
+ i = __get_hosts_byname_r(name, AF_INET, result_buf,
+ buf, buflen, result, h_errnop);
+ if (i == NETDB_SUCCESS) {
+ __set_errno(old_errno);
return i;
+ }
switch (*h_errnop) {
case HOST_NOT_FOUND:
+ wrong_af = (i == TRY_AGAIN);
case NO_ADDRESS:
break;
case NETDB_INTERNAL:
@@ -2073,161 +2054,192 @@ int gethostbyname_r(const char * name,
DPRINTF("Nothing found in /etc/hosts\n");
- /* make sure user char * is aligned */
- i = ALIGN_BUFFER_OFFSET(buf);
- if (unlikely(i)) {
- if (buflen < i)
- return ERANGE;
- buf += i;
- buflen -= i;
- }
-
*h_errnop = NETDB_INTERNAL;
- if (buflen < sizeof(*in))
- return ERANGE;
- in = (struct in_addr*)buf;
- buf += sizeof(*in);
- buflen -= sizeof(*in);
-
- if (buflen < sizeof(*addr_list)*2)
- return ERANGE;
- addr_list = (struct in_addr**)buf;
- buf += sizeof(*addr_list)*2;
- buflen -= sizeof(*addr_list)*2;
- addr_list[0] = in;
- addr_list[1] = 0;
-
- if (buflen < sizeof(char *)*ALIAS_DIM)
+ /* prepare future h_aliases[0] */
+ i = strlen(name) + 1;
+ if ((ssize_t)buflen <= i)
return ERANGE;
+ memcpy(buf, name, i); /* paranoia: name might change */
+ alias0 = buf;
+ buf += i;
+ buflen -= i;
+ /* make sure pointer is aligned */
+ i = ALIGN_BUFFER_OFFSET(buf);
+ buf += i;
+ buflen -= i;
+ /* Layout in buf:
+ * char *alias[2];
+ * struct in_addr* addr_list[NN+1];
+ * struct in_addr* in[NN];
+ */
alias = (char **)buf;
- buf += sizeof(char **)*ALIAS_DIM;
- buflen -= sizeof(char **)*ALIAS_DIM;
-
- if (buflen < 256)
+ buf += sizeof(alias[0]) * 2;
+ buflen -= sizeof(alias[0]) * 2;
+ addr_list = (struct in_addr **)buf;
+ /* buflen may be < 0, must do signed compare */
+ if ((ssize_t)buflen < 256)
return ERANGE;
- strncpy(buf, name, buflen);
- alias[0] = buf;
+ /* we store only one "alias" - the name itself */
+#ifdef __UCLIBC_MJN3_ONLY__
+#warning TODO -- generate the full list
+#endif
+ alias[0] = alias0;
alias[1] = NULL;
- /* First check if this is already an address */
- if (inet_aton(name, in)) {
- result_buf->h_name = buf;
- result_buf->h_addrtype = AF_INET;
- result_buf->h_length = sizeof(*in);
- result_buf->h_addr_list = (char **) addr_list;
- result_buf->h_aliases = alias;
- *result = result_buf;
- *h_errnop = NETDB_SUCCESS;
- return NETDB_SUCCESS;
+ /* maybe it is already an address? */
+ {
+ struct in_addr *in = (struct in_addr *)(buf + sizeof(addr_list[0]) * 2);
+ if (inet_aton(name, in)) {
+ addr_list[0] = in;
+ addr_list[1] = NULL;
+ result_buf->h_name = alias0;
+ result_buf->h_aliases = alias;
+ result_buf->h_addrtype = AF_INET;
+ result_buf->h_length = sizeof(struct in_addr);
+ result_buf->h_addr_list = (char **) addr_list;
+ *result = result_buf;
+ *h_errnop = NETDB_SUCCESS;
+ return NETDB_SUCCESS;
+ }
}
- for (;;) {
- __UCLIBC_MUTEX_LOCK(__resolv_lock);
- __nameserversXX = __nameservers;
- __nameserverXX = __nameserver;
- __UCLIBC_MUTEX_UNLOCK(__resolv_lock);
- a.buf = buf;
- a.buflen = buflen;
- a.add_count = 0;
- i = __dns_lookup(name, T_A, __nameserversXX, __nameserverXX, &packet, &a);
+ /* what if /etc/hosts has it but it's not IPv4?
+ * F.e. "::1 localhost6". We don't do DNS query for such hosts -
+ * "ping localhost6" should be fast even if DNS server is down! */
+ if (wrong_af) {
+ *h_errnop = HOST_NOT_FOUND;
+ return TRY_AGAIN;
+ }
- if (i < 0) {
- *h_errnop = HOST_NOT_FOUND;
- DPRINTF("__dns_lookup\n");
- return TRY_AGAIN;
- }
+ /* talk to DNS servers */
+ a.buf = buf;
+ /* take into account that at least one address will be there,
+ * we'll need space for one in_addr + two addr_list[] elems */
+ a.buflen = buflen - ((sizeof(addr_list[0]) * 2 + sizeof(struct in_addr)));
+ a.add_count = 0;
+ packet_len = __dns_lookup(name, T_A, &packet, &a);
+ if (packet_len < 0) {
+ *h_errnop = HOST_NOT_FOUND;
+ DPRINTF("__dns_lookup returned < 0\n");
+ return TRY_AGAIN;
+ }
- if ((a.rdlength + sizeof(struct in_addr*)) * a.add_count + 256 > buflen) {
- free(a.dotted);
- free(packet);
- *h_errnop = NETDB_INTERNAL;
+ if (a.atype == T_A) { /* ADDRESS */
+ /* we need space for addr_list[] and one IPv4 address */
+ /* + 1 accounting for 1st addr (it's in a.rdata),
+ * another + 1 for NULL in last addr_list[]: */
+ int need_bytes = sizeof(addr_list[0]) * (a.add_count + 1 + 1)
+ /* for 1st addr (it's in a.rdata): */
+ + sizeof(struct in_addr);
+ /* how many bytes will 2nd and following addresses take? */
+ int ips_len = a.add_count * a.rdlength;
+
+ buflen -= (need_bytes + ips_len);
+ if ((ssize_t)buflen < 0) {
DPRINTF("buffer too small for all addresses\n");
- return ERANGE;
- } else if (a.add_count > 0) {
- memmove(buf - sizeof(struct in_addr*)*2, buf, a.add_count * a.rdlength);
- addr_list = (struct in_addr**)(buf + a.add_count * a.rdlength);
- addr_list[0] = in;
- for (i = a.add_count - 1; i >= 0; --i)
- addr_list[i+1] = (struct in_addr*)(buf - sizeof(struct in_addr*)*2 + a.rdlength * i);
- addr_list[a.add_count + 1] = 0;
- buflen -= (((char*)&(addr_list[a.add_count + 2])) - buf);
- buf = (char*)&addr_list[a.add_count + 2];
+ /* *h_errnop = NETDB_INTERNAL; - already is */
+ i = ERANGE;
+ goto free_and_ret;
}
- strncpy(buf, a.dotted, buflen);
- free(a.dotted);
+ /* if there are additional addresses in buf,
+ * move them forward so that they are not destroyed */
+ DPRINTF("a.add_count:%d a.rdlength:%d a.rdata:%p\n", a.add_count, a.rdlength, a.rdata);
+ memmove(buf + need_bytes, buf, ips_len);
- if (a.atype == T_A) { /* ADDRESS */
- memcpy(in, a.rdata, sizeof(*in));
- result_buf->h_name = buf;
- result_buf->h_addrtype = AF_INET;
- result_buf->h_length = sizeof(*in);
- result_buf->h_addr_list = (char **) addr_list;
-#ifdef __UCLIBC_MJN3_ONLY__
-#warning TODO -- generate the full list
-#endif
- result_buf->h_aliases = alias; /* TODO: generate the full list */
- free(packet);
- break;
- } else {
- free(packet);
- *h_errnop = HOST_NOT_FOUND;
- return TRY_AGAIN;
+ /* 1st address is in a.rdata, insert it */
+ buf += need_bytes - sizeof(struct in_addr);
+ memcpy(buf, a.rdata, sizeof(struct in_addr));
+
+ /* fill addr_list[] */
+ for (i = 0; i <= a.add_count; i++) {
+ addr_list[i] = (struct in_addr*)buf;
+ buf += sizeof(struct in_addr);
+ }
+ addr_list[i] = NULL;
+
+ /* if we have enough space, we can report "better" name
+ * (it may contain search domains attached by __dns_lookup,
+ * or CNAME of the host if it is different from the name
+ * we used to find it) */
+ if (a.dotted && buflen > strlen(a.dotted)) {
+ strcpy(buf, a.dotted);
+ alias0 = buf;
}
+
+ result_buf->h_name = alias0;
+ result_buf->h_aliases = alias;
+ result_buf->h_addrtype = AF_INET;
+ result_buf->h_length = sizeof(struct in_addr);
+ result_buf->h_addr_list = (char **) addr_list;
+ *result = result_buf;
+ *h_errnop = NETDB_SUCCESS;
+ i = NETDB_SUCCESS;
+ goto free_and_ret;
}
- *result = result_buf;
- *h_errnop = NETDB_SUCCESS;
- return NETDB_SUCCESS;
+ *h_errnop = HOST_NOT_FOUND;
+ __set_h_errno(HOST_NOT_FOUND);
+ i = TRY_AGAIN;
+
+ free_and_ret:
+ free(a.dotted);
+ free(packet);
+ return i;
}
libc_hidden_def(gethostbyname_r)
-#endif
+#endif /* L_gethostbyname_r */
+
#ifdef L_gethostbyname2_r
-int gethostbyname2_r(const char *name, int family,
- struct hostent * result_buf,
- char * buf, size_t buflen,
- struct hostent ** result,
- int * h_errnop)
+int gethostbyname2_r(const char *name,
+ int family,
+ struct hostent *result_buf,
+ char *buf,
+ size_t buflen,
+ struct hostent **result,
+ int *h_errnop)
{
#ifndef __UCLIBC_HAS_IPV6__
return family == (AF_INET)
? gethostbyname_r(name, result_buf, buf, buflen, result, h_errnop)
: HOST_NOT_FOUND;
-#else /* __UCLIBC_HAS_IPV6__ */
- struct in6_addr *in;
+#else
struct in6_addr **addr_list;
+ char **alias;
+ char *alias0;
unsigned char *packet;
struct resolv_answer a;
int i;
- int nest = 0;
- int __nameserversXX;
- char ** __nameserverXX;
+ int packet_len;
+ int wrong_af = 0;
if (family == AF_INET)
return gethostbyname_r(name, result_buf, buf, buflen, result, h_errnop);
+ *result = NULL;
if (family != AF_INET6)
return EINVAL;
- __open_nameservers();
- *result = NULL;
if (!name)
return EINVAL;
/* do /etc/hosts first */
{
- int old_errno = errno; /* Save the old errno and reset errno */
- __set_errno(0); /* to check for missing /etc/hosts. */
-
- if ((i = __get_hosts_byname_r(name, family, result_buf,
- buf, buflen, result, h_errnop)) == 0)
+ int old_errno = errno; /* save the old errno and reset errno */
+ __set_errno(0); /* to check for missing /etc/hosts. */
+ i = __get_hosts_byname_r(name, AF_INET6 /*family*/, result_buf,
+ buf, buflen, result, h_errnop);
+ if (i == NETDB_SUCCESS) {
+ __set_errno(old_errno);
return i;
+ }
switch (*h_errnop) {
case HOST_NOT_FOUND:
+ wrong_af = (i == TRY_AGAIN);
case NO_ADDRESS:
break;
case NETDB_INTERNAL:
@@ -2244,139 +2256,189 @@ int gethostbyname2_r(const char *name, int family,
DPRINTF("Nothing found in /etc/hosts\n");
*h_errnop = NETDB_INTERNAL;
- if (buflen < sizeof(*in))
- return ERANGE;
- in = (struct in6_addr*)buf;
- buf += sizeof(*in);
- buflen -= sizeof(*in);
- if (buflen < sizeof(*addr_list)*2)
+ /* prepare future h_aliases[0] */
+ i = strlen(name) + 1;
+ if ((ssize_t)buflen <= i)
return ERANGE;
- addr_list = (struct in6_addr**)buf;
- buf += sizeof(*addr_list)*2;
- buflen -= sizeof(*addr_list)*2;
-
- addr_list[0] = in;
- addr_list[1] = 0;
-
- if (buflen < 256)
+ memcpy(buf, name, i); /* paranoia: name might change */
+ alias0 = buf;
+ buf += i;
+ buflen -= i;
+ /* make sure pointer is aligned */
+ i = ALIGN_BUFFER_OFFSET(buf);
+ buf += i;
+ buflen -= i;
+ /* Layout in buf:
+ * char *alias[2];
+ * struct in6_addr* addr_list[NN+1];
+ * struct in6_addr* in[NN];
+ */
+ alias = (char **)buf;
+ buf += sizeof(alias[0]) * 2;
+ buflen -= sizeof(alias[0]) * 2;
+ addr_list = (struct in6_addr **)buf;
+ /* buflen may be < 0, must do signed compare */
+ if ((ssize_t)buflen < 256)
return ERANGE;
- strncpy(buf, name, buflen);
- /* First check if this is already an address */
- if (inet_pton(AF_INET6, name, in)) {
- result_buf->h_name = buf;
- result_buf->h_addrtype = AF_INET6;
- result_buf->h_length = sizeof(*in);
- result_buf->h_addr_list = (char **) addr_list;
- *result = result_buf;
- *h_errnop = NETDB_SUCCESS;
- return NETDB_SUCCESS;
- }
+ /* we store only one "alias" - the name itself */
+#ifdef __UCLIBC_MJN3_ONLY__
+#warning TODO -- generate the full list
+#endif
+ alias[0] = alias0;
+ alias[1] = NULL;
- memset((char *) &a, '\0', sizeof(a));
+ /* maybe it is already an address? */
+ {
+ struct in6_addr *in = (struct in6_addr *)(buf + sizeof(addr_list[0]) * 2);
+ if (inet_pton(AF_INET6, name, in)) {
+ addr_list[0] = in;
+ addr_list[1] = NULL;
+ result_buf->h_name = alias0;
+ result_buf->h_aliases = alias;
+ result_buf->h_addrtype = AF_INET6;
+ result_buf->h_length = sizeof(struct in6_addr);
+ result_buf->h_addr_list = (char **) addr_list;
+ *result = result_buf;
+ *h_errnop = NETDB_SUCCESS;
+ return NETDB_SUCCESS;
+ }
+ }
- for (;;) {
- __UCLIBC_MUTEX_LOCK(__resolv_lock);
- __nameserversXX = __nameservers;
- __nameserverXX = __nameserver;
- __UCLIBC_MUTEX_UNLOCK(__resolv_lock);
+ /* what if /etc/hosts has it but it's not IPv6?
+ * F.e. "127.0.0.1 localhost". We don't do DNS query for such hosts -
+ * "ping localhost" should be fast even if DNS server is down! */
+ if (wrong_af) {
+ *h_errnop = HOST_NOT_FOUND;
+ return TRY_AGAIN;
+ }
- i = __dns_lookup(buf, T_AAAA, __nameserversXX, __nameserverXX, &packet, &a);
+ /* talk to DNS servers */
+ a.buf = buf;
+ /* take into account that at least one address will be there,
+ * we'll need space of one in6_addr + two addr_list[] elems */
+ a.buflen = buflen - ((sizeof(addr_list[0]) * 2 + sizeof(struct in6_addr)));
+ a.add_count = 0;
+ packet_len = __dns_lookup(name, T_AAAA, &packet, &a);
+ if (packet_len < 0) {
+ *h_errnop = HOST_NOT_FOUND;
+ DPRINTF("__dns_lookup returned < 0\n");
+ return TRY_AGAIN;
+ }
- if (i < 0) {
- *h_errnop = HOST_NOT_FOUND;
- return TRY_AGAIN;
+ if (a.atype == T_AAAA) { /* ADDRESS */
+ /* we need space for addr_list[] and one IPv6 address */
+ /* + 1 accounting for 1st addr (it's in a.rdata),
+ * another + 1 for NULL in last addr_list[]: */
+ int need_bytes = sizeof(addr_list[0]) * (a.add_count + 1 + 1)
+ /* for 1st addr (it's in a.rdata): */
+ + sizeof(struct in6_addr);
+ /* how many bytes will 2nd and following addresses take? */
+ int ips_len = a.add_count * a.rdlength;
+
+ buflen -= (need_bytes + ips_len);
+ if ((ssize_t)buflen < 0) {
+ DPRINTF("buffer too small for all addresses\n");
+ /* *h_errnop = NETDB_INTERNAL; - already is */
+ i = ERANGE;
+ goto free_and_ret;
}
- strncpy(buf, a.dotted, buflen);
- free(a.dotted);
+ /* if there are additional addresses in buf,
+ * move them forward so that they are not destroyed */
+ DPRINTF("a.add_count:%d a.rdlength:%d a.rdata:%p\n", a.add_count, a.rdlength, a.rdata);
+ memmove(buf + need_bytes, buf, ips_len);
- if (a.atype == T_CNAME) { /* CNAME */
- DPRINTF("Got a CNAME in gethostbyname()\n");
- i = __decode_dotted(packet, a.rdoffset, buf, buflen);
- free(packet);
+ /* 1st address is in a.rdata, insert it */
+ buf += need_bytes - sizeof(struct in6_addr);
+ memcpy(buf, a.rdata, sizeof(struct in6_addr));
- if (i < 0) {
- *h_errnop = NO_RECOVERY;
- return -1;
- }
- if (++nest > MAX_RECURSE) {
- *h_errnop = NO_RECOVERY;
- return -1;
- }
- continue;
- } else if (a.atype == T_AAAA) { /* ADDRESS */
- memcpy(in, a.rdata, sizeof(*in));
- result_buf->h_name = buf;
- result_buf->h_addrtype = AF_INET6;
- result_buf->h_length = sizeof(*in);
- result_buf->h_addr_list = (char **) addr_list;
- free(packet);
- break;
- } else {
- free(packet);
- *h_errnop = HOST_NOT_FOUND;
- return TRY_AGAIN;
+ /* fill addr_list[] */
+ for (i = 0; i <= a.add_count; i++) {
+ addr_list[i] = (struct in6_addr*)buf;
+ buf += sizeof(struct in6_addr);
}
+ addr_list[i] = NULL;
+
+ /* if we have enough space, we can report "better" name
+ * (it may contain search domains attached by __dns_lookup,
+ * or CNAME of the host if it is different from the name
+ * we used to find it) */
+ if (a.dotted && buflen > strlen(a.dotted)) {
+ strcpy(buf, a.dotted);
+ alias0 = buf;
+ }
+
+ result_buf->h_name = alias0;
+ result_buf->h_aliases = alias;
+ result_buf->h_addrtype = AF_INET6;
+ result_buf->h_length = sizeof(struct in6_addr);
+ result_buf->h_addr_list = (char **) addr_list;
+ *result = result_buf;
+ *h_errnop = NETDB_SUCCESS;
+ i = NETDB_SUCCESS;
+ goto free_and_ret;
}
- *result = result_buf;
- *h_errnop = NETDB_SUCCESS;
- return NETDB_SUCCESS;
+ *h_errnop = HOST_NOT_FOUND;
+ __set_h_errno(HOST_NOT_FOUND);
+ i = TRY_AGAIN;
+
+ free_and_ret:
+ free(a.dotted);
+ free(packet);
+ return i;
#endif /* __UCLIBC_HAS_IPV6__ */
}
libc_hidden_def(gethostbyname2_r)
-#endif
+#endif /* L_gethostbyname2_r */
+
#ifdef L_gethostbyaddr_r
-int gethostbyaddr_r(const void *addr, socklen_t len, int type,
- struct hostent * result_buf,
- char * buf, size_t buflen,
- struct hostent ** result,
- int * h_errnop)
+
+int gethostbyaddr_r(const void *addr, socklen_t addrlen,
+ int type,
+ struct hostent *result_buf,
+ char *buf, size_t buflen,
+ struct hostent **result,
+ int *h_errnop)
{
struct in_addr *in;
struct in_addr **addr_list;
-#ifdef __UCLIBC_HAS_IPV6__
- char *qp;
- size_t plen;
- struct in6_addr *in6;
- struct in6_addr **addr_list6;
-#endif /* __UCLIBC_HAS_IPV6__ */
char **alias;
unsigned char *packet;
struct resolv_answer a;
int i;
+ int packet_len;
int nest = 0;
- int __nameserversXX;
- char ** __nameserverXX;
*result = NULL;
if (!addr)
return EINVAL;
- memset((char *) &a, '\0', sizeof(a));
-
switch (type) {
+#ifdef __UCLIBC_HAS_IPV4__
case AF_INET:
- if (len != sizeof(struct in_addr))
+ if (addrlen != sizeof(struct in_addr))
return EINVAL;
break;
+#endif
#ifdef __UCLIBC_HAS_IPV6__
case AF_INET6:
- if (len != sizeof(struct in6_addr))
+ if (addrlen != sizeof(struct in6_addr))
return EINVAL;
break;
-#endif /* __UCLIBC_HAS_IPV6__ */
+#endif
default:
return EINVAL;
}
/* do /etc/hosts first */
- if ((i = __get_hosts_byaddr_r(addr, len, type, result_buf,
- buf, buflen, result, h_errnop)) == 0)
+ i = __get_hosts_byaddr_r(addr, addrlen, type, result_buf,
+ buf, buflen, result, h_errnop);
+ if (i == 0)
return i;
switch (*h_errnop) {
case HOST_NOT_FOUND:
@@ -2386,145 +2448,256 @@ int gethostbyaddr_r(const void *addr, socklen_t len, int type,
return i;
}
- __open_nameservers();
-
-#ifdef __UCLIBC_HAS_IPV6__
- qp = buf;
- plen = buflen;
-#endif /* __UCLIBC_HAS_IPV6__ */
-
*h_errnop = NETDB_INTERNAL;
- if (buflen < sizeof(*in))
- return ERANGE;
+
+ /* make sure pointer is aligned */
+ i = ALIGN_BUFFER_OFFSET(buf);
+ buf += i;
+ buflen -= i;
+ /* Layout in buf:
+ * char *alias[ALIAS_DIM];
+ * struct in[6]_addr* addr_list[2];
+ * struct in[6]_addr in;
+ * char scratch_buffer[256+];
+ */
+#define in6 ((struct in6_addr *)in)
+ alias = (char **)buf;
+ addr_list = (struct in_addr**)buf;
+ buf += sizeof(*addr_list) * 2;
+ buflen -= sizeof(*addr_list) * 2;
in = (struct in_addr*)buf;
+#ifndef __UCLIBC_HAS_IPV6__
buf += sizeof(*in);
buflen -= sizeof(*in);
-
- if (buflen < sizeof(*addr_list)*2)
+ if (addrlen > sizeof(*in))
return ERANGE;
- addr_list = (struct in_addr**)buf;
- buf += sizeof(*addr_list)*2;
- buflen -= sizeof(*addr_list)*2;
-
- if (buflen < sizeof(char *)*ALIAS_DIM)
+#else
+ buf += sizeof(*in6);
+ buflen -= sizeof(*in6);
+ if (addrlen > sizeof(*in6))
return ERANGE;
- alias = (char **)buf;
- buf += sizeof(*alias)*ALIAS_DIM;
- buflen -= sizeof(*alias)*ALIAS_DIM;
+#endif
+ if ((ssize_t)buflen < 256)
+ return ERANGE;
+ alias[0] = buf;
+ alias[1] = NULL;
+ addr_list[0] = in;
+ addr_list[1] = NULL;
+ memcpy(in, addr, addrlen);
+ if (0) /* nothing */;
+#ifdef __UCLIBC_HAS_IPV4__
+ else IF_HAS_BOTH(if (type == AF_INET)) {
+ unsigned char *tp = (unsigned char *)addr;
+ sprintf(buf, "%u.%u.%u.%u.in-addr.arpa",
+ tp[3], tp[2], tp[1], tp[0]);
+ }
+#endif
#ifdef __UCLIBC_HAS_IPV6__
- if (plen < sizeof(*in6))
- return ERANGE;
- in6 = (struct in6_addr*)qp;
- qp += sizeof(*in6);
- plen -= sizeof(*in6);
+ else {
+ char *dst = buf;
+ unsigned char *tp = (unsigned char *)addr + addrlen - 1;
+ do {
+ dst += sprintf(dst, "%x.%x.", tp[0] & 0xf, tp[0] >> 4);
+ tp--;
+ } while (tp >= (unsigned char *)addr);
+ strcpy(dst, "ip6.arpa");
+ }
+#endif
- if (plen < sizeof(*addr_list6)*2)
- return ERANGE;
- addr_list6 = (struct in6_addr**)qp;
- qp += sizeof(*addr_list6)*2;
- plen -= sizeof(*addr_list6)*2;
+ memset(&a, '\0', sizeof(a));
+ for (;;) {
+/* Hmm why we memset(a) to zeros only once? */
+ packet_len = __dns_lookup(buf, T_PTR, &packet, &a);
+ if (packet_len < 0) {
+ *h_errnop = HOST_NOT_FOUND;
+ return TRY_AGAIN;
+ }
+
+ strncpy(buf, a.dotted, buflen);
+ free(a.dotted);
+ if (a.atype != T_CNAME)
+ break;
- if (plen < buflen) {
- buflen = plen;
- buf = qp;
+ DPRINTF("Got a CNAME in gethostbyaddr()\n");
+ if (++nest > MAX_RECURSE) {
+ *h_errnop = NO_RECOVERY;
+ return -1;
+ }
+ /* Decode CNAME into buf, feed it to __dns_lookup() again */
+ i = __decode_dotted(packet, a.rdoffset, packet_len, buf, buflen);
+ free(packet);
+ if (i < 0) {
+ *h_errnop = NO_RECOVERY;
+ return -1;
+ }
}
-#endif /* __UCLIBC_HAS_IPV6__ */
- if (buflen < 256)
- return ERANGE;
+ if (a.atype == T_PTR) { /* ADDRESS */
+ i = __decode_dotted(packet, a.rdoffset, packet_len, buf, buflen);
+ free(packet);
+ result_buf->h_name = buf;
+ result_buf->h_addrtype = type;
+ result_buf->h_length = addrlen;
+ result_buf->h_addr_list = (char **) addr_list;
+ result_buf->h_aliases = alias;
+ *result = result_buf;
+ *h_errnop = NETDB_SUCCESS;
+ return NETDB_SUCCESS;
+ }
- if (type == AF_INET) {
- unsigned char *tmp_addr = (unsigned char *)addr;
+ free(packet);
+ *h_errnop = NO_ADDRESS;
+ return TRY_AGAIN;
+#undef in6
+}
+libc_hidden_def(gethostbyaddr_r)
+#endif /* L_gethostbyaddr_r */
- memcpy(&in->s_addr, addr, len);
- addr_list[0] = in;
+#ifdef L_gethostent_r
- sprintf(buf, "%u.%u.%u.%u.in-addr.arpa",
- tmp_addr[3], tmp_addr[2], tmp_addr[1], tmp_addr[0]);
-#ifdef __UCLIBC_HAS_IPV6__
- } else {
- memcpy(in6->s6_addr, addr, len);
+__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER);
- addr_list6[0] = in6;
- qp = buf;
+static parser_t *hostp = NULL;
+static smallint host_stayopen;
- for (i = len - 1; i >= 0; i--) {
- qp += sprintf(qp, "%x.%x.", in6->s6_addr[i] & 0xf,
- (in6->s6_addr[i] >> 4) & 0xf);
+void endhostent_unlocked(void)
+{
+ if (hostp) {
+ config_close(hostp);
+ hostp = NULL;
+ }
+ host_stayopen = 0;
+}
+void endhostent(void)
+{
+ __UCLIBC_MUTEX_LOCK(mylock);
+ endhostent_unlocked();
+ __UCLIBC_MUTEX_UNLOCK(mylock);
+}
+
+void sethostent(int stay_open)
+{
+ __UCLIBC_MUTEX_LOCK(mylock);
+ if (stay_open)
+ host_stayopen = 1;
+ __UCLIBC_MUTEX_UNLOCK(mylock);
+}
+
+int gethostent_r(struct hostent *result_buf, char *buf, size_t buflen,
+ struct hostent **result, int *h_errnop)
+{
+ int ret;
+
+ __UCLIBC_MUTEX_LOCK(mylock);
+ if (hostp == NULL) {
+ hostp = __open_etc_hosts();
+ if (hostp == NULL) {
+ *result = NULL;
+ ret = TRY_AGAIN;
+ goto DONE;
}
- strcpy(qp, "ip6.arpa");
-#endif /* __UCLIBC_HAS_IPV6__ */
}
- addr_list[1] = 0;
+ ret = __read_etc_hosts_r(hostp, NULL, AF_INET, GETHOSTENT,
+ result_buf, buf, buflen, result, h_errnop);
+ if (!host_stayopen)
+ endhostent_unlocked();
+DONE:
+ __UCLIBC_MUTEX_UNLOCK(mylock);
+ return ret;
+}
+libc_hidden_def(gethostent_r)
+#endif /* L_gethostent_r */
+
- alias[0] = buf;
- alias[1] = 0;
+#ifndef __UCLIBC_HAS_IPV6__
+ #define GETXX_BUFSZ (sizeof(struct in_addr) + sizeof(struct in_addr *) * 2 + \
+ /*sizeof(char *)*ALIAS_DIM */+ 384/*namebuffer*/ + 32/* margin */)
+#else
+ #define GETXX_BUFSZ (sizeof(struct in6_addr) + sizeof(struct in6_addr *) * 2 + \
+ /*sizeof(char *)*ALIAS_DIM */+ 384/*namebuffer*/ + 32/* margin */)
+#endif /* __UCLIBC_HAS_IPV6__ */
- for (;;) {
- __UCLIBC_MUTEX_LOCK(__resolv_lock);
- __nameserversXX = __nameservers;
- __nameserverXX = __nameserver;
- __UCLIBC_MUTEX_UNLOCK(__resolv_lock);
- i = __dns_lookup(buf, T_PTR, __nameserversXX, __nameserverXX, &packet, &a);
+#define __INIT_GETXX_BUF(sz) \
+ if (buf == NULL) \
+ buf = (char *)__uc_malloc((sz));
- if (i < 0) {
- *h_errnop = HOST_NOT_FOUND;
- return TRY_AGAIN;
- }
+#ifdef L_gethostent
- strncpy(buf, a.dotted, buflen);
- free(a.dotted);
+struct hostent *gethostent(void)
+{
+ static struct hostent hoste;
+ static char *buf = NULL;
+ struct hostent *host = NULL;
+#ifndef __UCLIBC_HAS_IPV6__
+ #define HOSTENT_BUFSZ (sizeof(struct in_addr) + sizeof(struct in_addr *) * 2 + \
+ sizeof(char *)*ALIAS_DIM + BUFSZ /*namebuffer*/ + 2 /* margin */)
+#else
+ #define HOSTENT_BUFSZ (sizeof(struct in6_addr) + sizeof(struct in6_addr *) * 2 + \
+ sizeof(char *)*ALIAS_DIM + BUFSZ /*namebuffer*/ + 2 /* margin */)
+#endif /* __UCLIBC_HAS_IPV6__ */
- if (a.atype == T_CNAME) { /* CNAME */
- DPRINTF("Got a CNAME in gethostbyaddr()\n");
- i = __decode_dotted(packet, a.rdoffset, buf, buflen);
- free(packet);
+ __INIT_GETXX_BUF(HOSTENT_BUFSZ);
+ gethostent_r(&hoste, buf, HOSTENT_BUFSZ, &host, &h_errno);
+ return host;
+}
+#undef HOSTENT_BUFSZ
+#endif /* L_gethostent */
- if (i < 0) {
- *h_errnop = NO_RECOVERY;
- return -1;
- }
- if (++nest > MAX_RECURSE) {
- *h_errnop = NO_RECOVERY;
- return -1;
- }
- continue;
- } else if (a.atype == T_PTR) { /* ADDRESS */
- i = __decode_dotted(packet, a.rdoffset, buf, buflen);
- free(packet);
- result_buf->h_name = buf;
- result_buf->h_addrtype = type;
+#ifdef L_gethostbyname2
- if (type == AF_INET) {
- result_buf->h_length = sizeof(*in);
-#ifdef __UCLIBC_HAS_IPV6__
- } else {
- result_buf->h_length = sizeof(*in6);
+struct hostent *gethostbyname2(const char *name, int family)
+{
+ static struct hostent hoste;
+ static char *buf = NULL;
+ struct hostent *hp;
+
+ __INIT_GETXX_BUF(GETXX_BUFSZ);
+#ifndef __UCLIBC_HAS_IPV6__
+ if (family != AF_INET)
+ return (struct hostent*)NULL;
+ gethostbyname_r(name, &hoste, buf, GETXX_BUFSZ, &hp, &h_errno);
+#else
+ gethostbyname2_r(name, family, &hoste, buf, GETXX_BUFSZ, &hp, &h_errno);
#endif /* __UCLIBC_HAS_IPV6__ */
- }
- result_buf->h_addr_list = (char **) addr_list;
- result_buf->h_aliases = alias;
- break;
- } else {
- free(packet);
- *h_errnop = NO_ADDRESS;
- return TRY_AGAIN;
- }
- }
+ return hp;
+}
+libc_hidden_def(gethostbyname2)
+#endif /* L_gethostbyname2 */
- *result = result_buf;
- *h_errnop = NETDB_SUCCESS;
- return NETDB_SUCCESS;
+
+#ifdef L_gethostbyname
+
+struct hostent *gethostbyname(const char *name)
+{
+ return gethostbyname2(name, AF_INET);
}
-libc_hidden_def(gethostbyaddr_r)
-#endif
+libc_hidden_def(gethostbyname)
+#endif /* L_gethostbyname */
+
+
+#ifdef L_gethostbyaddr
+
+struct hostent *gethostbyaddr(const void *addr, socklen_t len, int type)
+{
+ static struct hostent hoste;
+ static char *buf = NULL;
+ struct hostent *hp;
+
+ __INIT_GETXX_BUF(GETXX_BUFSZ);
+ gethostbyaddr_r(addr, len, type, &hoste, buf, GETXX_BUFSZ, &hp, &h_errno);
+ return hp;
+}
+libc_hidden_def(gethostbyaddr)
+#endif /* L_gethostbyaddr */
+
#ifdef L_res_comp
+
/*
* Expand compressed domain name 'comp_dn' to full domain name.
* 'msg' is a pointer to the begining of the message,
@@ -2532,7 +2705,7 @@ libc_hidden_def(gethostbyaddr_r)
* 'exp_dn' is a pointer to a buffer of size 'length' for the result.
* Return size of compressed name or -1 if there was an error.
*/
-int __dn_expand(const u_char *msg, const u_char *eom, const u_char *src,
+int dn_expand(const u_char *msg, const u_char *eom, const u_char *src,
char *dst, int dstsiz)
{
int n = ns_name_uncompress(msg, eom, src, dst, (size_t)dstsiz);
@@ -2541,27 +2714,36 @@ int __dn_expand(const u_char *msg, const u_char *eom, const u_char *src,
dst[0] = '\0';
return n;
}
+libc_hidden_def(dn_expand)
+
+/*
+ * Pack domain name 'exp_dn' in presentation form into 'comp_dn'.
+ * Return the size of the compressed name or -1.
+ * 'length' is the size of the array pointed to by 'comp_dn'.
+ */
+int
+dn_comp(const char *src, u_char *dst, int dstsiz,
+ u_char **dnptrs, u_char **lastdnptr)
+{
+ return ns_name_compress(src, dst, (size_t) dstsiz,
+ (const u_char **) dnptrs,
+ (const u_char **) lastdnptr);
+}
+libc_hidden_def(dn_comp)
#endif /* L_res_comp */
+
#ifdef L_ns_name
-/*
- * printable(ch)
- * Thinking in noninternationalized USASCII (per the DNS spec),
- * is this character visible and not a space when printed ?
- * return:
- * boolean.
+
+/* Thinking in noninternationalized USASCII (per the DNS spec),
+ * is this character visible and not a space when printed ?
*/
static int printable(int ch)
{
return (ch > 0x20 && ch < 0x7f);
}
-
-/*
- * special(ch)
- * Thinking in noninternationalized USASCII (per the DNS spec),
- * is this characted special ("in need of quoting") ?
- * return:
- * boolean.
+/* Thinking in noninternationalized USASCII (per the DNS spec),
+ * is this characted special ("in need of quoting") ?
*/
static int special(int ch)
{
@@ -2593,7 +2775,8 @@ int ns_name_uncompress(const u_char *msg, const u_char *eom,
u_char tmp[NS_MAXCDNAME];
int n;
- if ((n = ns_name_unpack(msg, eom, src, tmp, sizeof tmp)) == -1)
+ n = ns_name_unpack(msg, eom, src, tmp, sizeof tmp);
+ if (n == -1)
return -1;
if (ns_name_ntop(tmp, dst, dstsiz) == -1)
return -1;
@@ -2601,7 +2784,6 @@ int ns_name_uncompress(const u_char *msg, const u_char *eom,
}
libc_hidden_def(ns_name_uncompress)
-
/*
* ns_name_ntop(src, dst, dstsiz)
* Convert an encoded domain name to printable ascii as per RFC1035.
@@ -2611,12 +2793,12 @@ libc_hidden_def(ns_name_uncompress)
* The root is returned as "."
* All other domains are returned in non absolute form
*/
-int ns_name_ntop(const u_char *src, char *dst, size_t dstsiz) {
+int ns_name_ntop(const u_char *src, char *dst, size_t dstsiz)
+{
const u_char *cp;
char *dn, *eom;
u_char c;
u_int n;
- const char digits[] = "0123456789";
cp = src;
dn = dst;
@@ -2639,7 +2821,7 @@ int ns_name_ntop(const u_char *src, char *dst, size_t dstsiz) {
__set_errno(EMSGSIZE);
return -1;
}
- for ((void)NULL; n > 0; n--) {
+ for (; n > 0; n--) {
c = *cp++;
if (special(c)) {
if (dn + 1 >= eom) {
@@ -2654,9 +2836,10 @@ int ns_name_ntop(const u_char *src, char *dst, size_t dstsiz) {
return -1;
}
*dn++ = '\\';
- *dn++ = digits[c / 100];
- *dn++ = digits[(c % 100) / 10];
- *dn++ = digits[c % 10];
+ *dn++ = "0123456789"[c / 100];
+ c = c % 100;
+ *dn++ = "0123456789"[c / 10];
+ *dn++ = "0123456789"[c % 10];
} else {
if (dn >= eom) {
__set_errno(EMSGSIZE);
@@ -2682,6 +2865,241 @@ int ns_name_ntop(const u_char *src, char *dst, size_t dstsiz) {
}
libc_hidden_def(ns_name_ntop)
+static int encode_bitstring(const char **bp, const char *end,
+ unsigned char **labelp,
+ unsigned char ** dst,
+ unsigned const char *eom)
+{
+ int afterslash = 0;
+ const char *cp = *bp;
+ unsigned char *tp;
+ const char *beg_blen;
+ int value = 0, count = 0, tbcount = 0, blen = 0;
+
+ beg_blen = NULL;
+
+ /* a bitstring must contain at least 2 characters */
+ if (end - cp < 2)
+ return EINVAL;
+
+ /* XXX: currently, only hex strings are supported */
+ if (*cp++ != 'x')
+ return EINVAL;
+ if (!isxdigit((unsigned char) *cp)) /*%< reject '\[x/BLEN]' */
+ return EINVAL;
+
+ for (tp = *dst + 1; cp < end && tp < eom; cp++) {
+ unsigned char c = *cp;
+
+ switch (c) {
+ case ']': /*%< end of the bitstring */
+ if (afterslash) {
+ char *end_blen;
+ if (beg_blen == NULL)
+ return EINVAL;
+ blen = (int)strtol(beg_blen, &end_blen, 10);
+ if (*end_blen != ']')
+ return EINVAL;
+ }
+ if (count)
+ *tp++ = ((value << 4) & 0xff);
+ cp++; /*%< skip ']' */
+ goto done;
+ case '/':
+ afterslash = 1;
+ break;
+ default:
+ if (afterslash) {
+ if (!__isdigit_char(c))
+ return EINVAL;
+ if (beg_blen == NULL) {
+ if (c == '0') {
+ /* blen never begings with 0 */
+ return EINVAL;
+ }
+ beg_blen = cp;
+ }
+ } else {
+ if (!__isdigit_char(c)) {
+ c = c | 0x20; /* lowercase */
+ c = c - 'a';
+ if (c > 5) /* not a-f? */
+ return EINVAL;
+ c += 10 + '0';
+ }
+ value <<= 4;
+ value += (c - '0');
+ count += 4;
+ tbcount += 4;
+ if (tbcount > 256)
+ return EINVAL;
+ if (count == 8) {
+ *tp++ = value;
+ count = 0;
+ }
+ }
+ break;
+ }
+ }
+ done:
+ if (cp >= end || tp >= eom)
+ return EMSGSIZE;
+
+ /*
+ * bit length validation:
+ * If a <length> is present, the number of digits in the <bit-data>
+ * MUST be just sufficient to contain the number of bits specified
+ * by the <length>. If there are insignificant bits in a final
+ * hexadecimal or octal digit, they MUST be zero.
+ * RFC2673, Section 3.2.
+ */
+ if (blen > 0) {
+ int traillen;
+
+ if (((blen + 3) & ~3) != tbcount)
+ return EINVAL;
+ traillen = tbcount - blen; /*%< between 0 and 3 */
+ if (((value << (8 - traillen)) & 0xff) != 0)
+ return EINVAL;
+ }
+ else
+ blen = tbcount;
+ if (blen == 256)
+ blen = 0;
+
+ /* encode the type and the significant bit fields */
+ **labelp = DNS_LABELTYPE_BITSTRING;
+ **dst = blen;
+
+ *bp = cp;
+ *dst = tp;
+
+ return 0;
+}
+
+int ns_name_pton(const char *src, u_char *dst, size_t dstsiz)
+{
+ static const char digits[] = "0123456789";
+ u_char *label, *bp, *eom;
+ int c, n, escaped, e = 0;
+ char *cp;
+
+ escaped = 0;
+ bp = dst;
+ eom = dst + dstsiz;
+ label = bp++;
+
+ while ((c = *src++) != 0) {
+ if (escaped) {
+ if (c == '[') { /*%< start a bit string label */
+ cp = strchr(src, ']');
+ if (cp == NULL) {
+ errno = EINVAL; /*%< ??? */
+ return -1;
+ }
+ e = encode_bitstring(&src, cp + 2,
+ &label, &bp, eom);
+ if (e != 0) {
+ errno = e;
+ return -1;
+ }
+ escaped = 0;
+ label = bp++;
+ c = *src++;
+ if (c == '\0')
+ goto done;
+ if (c != '.') {
+ errno = EINVAL;
+ return -1;
+ }
+ continue;
+ }
+ cp = strchr(digits, c);
+ if (cp != NULL) {
+ n = (cp - digits) * 100;
+ c = *src++;
+ if (c == '\0')
+ goto ret_EMSGSIZE;
+ cp = strchr(digits, c);
+ if (cp == NULL)
+ goto ret_EMSGSIZE;
+ n += (cp - digits) * 10;
+ c = *src++;
+ if (c == '\0')
+ goto ret_EMSGSIZE;
+ cp = strchr(digits, c);
+ if (cp == NULL)
+ goto ret_EMSGSIZE;
+ n += (cp - digits);
+ if (n > 255)
+ goto ret_EMSGSIZE;
+ c = n;
+ }
+ escaped = 0;
+ } else if (c == '\\') {
+ escaped = 1;
+ continue;
+ } else if (c == '.') {
+ c = (bp - label - 1);
+ if ((c & NS_CMPRSFLGS) != 0) { /*%< Label too big. */
+ goto ret_EMSGSIZE;
+ }
+ if (label >= eom) {
+ goto ret_EMSGSIZE;
+ }
+ *label = c;
+ /* Fully qualified ? */
+ if (*src == '\0') {
+ if (c != 0) {
+ if (bp >= eom) {
+ goto ret_EMSGSIZE;
+ }
+ *bp++ = '\0';
+ }
+ if ((bp - dst) > MAXCDNAME) {
+ goto ret_EMSGSIZE;
+ }
+
+ return 1;
+ }
+ if (c == 0 || *src == '.') {
+ goto ret_EMSGSIZE;
+ }
+ label = bp++;
+ continue;
+ }
+ if (bp >= eom) {
+ goto ret_EMSGSIZE;
+ }
+ *bp++ = (u_char)c;
+ }
+ c = (bp - label - 1);
+ if ((c & NS_CMPRSFLGS) != 0) { /*%< Label too big. */
+ goto ret_EMSGSIZE;
+ }
+ done:
+ if (label >= eom) {
+ goto ret_EMSGSIZE;
+ }
+ *label = c;
+ if (c != 0) {
+ if (bp >= eom) {
+ goto ret_EMSGSIZE;
+ }
+ *bp++ = 0;
+ }
+ if ((bp - dst) > MAXCDNAME) { /*%< src too big */
+ goto ret_EMSGSIZE;
+ }
+
+ return 0;
+
+ ret_EMSGSIZE:
+ errno = EMSGSIZE;
+ return -1;
+}
+libc_hidden_def(ns_name_pton)
+
/*
* ns_name_unpack(msg, eom, src, dst, dstsiz)
* Unpack a domain name from a message, source may be compressed.
@@ -2756,5 +3174,1193 @@ int ns_name_unpack(const u_char *msg, const u_char *eom, const u_char *src,
return len;
}
libc_hidden_def(ns_name_unpack)
+
+static int labellen(const unsigned char *lp)
+{
+ unsigned bitlen;
+ unsigned char l = *lp;
+
+ if ((l & NS_CMPRSFLGS) == NS_CMPRSFLGS) {
+ /* should be avoided by the caller */
+ return -1;
+ }
+
+ if ((l & NS_CMPRSFLGS) == NS_TYPE_ELT) {
+ if (l == DNS_LABELTYPE_BITSTRING) {
+ bitlen = lp[1];
+ if (bitlen == 0)
+ bitlen = 256;
+ return ((bitlen + 7 ) / 8 + 1);
+ }
+
+ return -1; /*%< unknwon ELT */
+ }
+
+ return l;
+}
+
+static int mklower(int ch)
+{
+ if (ch >= 0x41 && ch <= 0x5A)
+ return (ch + 0x20);
+
+ return ch;
+}
+
+static int dn_find(const unsigned char *domain,
+ const unsigned char *msg,
+ const unsigned char * const *dnptrs,
+ const unsigned char * const *lastdnptr)
+{
+ const unsigned char *dn, *cp, *sp;
+ const unsigned char * const *cpp;
+ u_int n;
+
+ for (cpp = dnptrs; cpp < lastdnptr; cpp++) {
+ sp = *cpp;
+ /*
+ * terminate search on:
+ * root label
+ * compression pointer
+ * unusable offset
+ */
+ while (*sp != 0 && (*sp & NS_CMPRSFLGS) == 0 &&
+ (sp - msg) < 0x4000) {
+ dn = domain;
+ cp = sp;
+
+ while ((n = *cp++) != 0) {
+ /*
+ * check for indirection
+ */
+ switch (n & NS_CMPRSFLGS) {
+ case 0: /*%< normal case, n == len */
+ n = labellen(cp - 1); /*%< XXX */
+ if (n != *dn++)
+ goto next;
+
+ for (; n > 0; n--)
+ if (mklower(*dn++) !=
+ mklower(*cp++))
+ goto next;
+ /* Is next root for both ? */
+ if (*dn == '\0' && *cp == '\0')
+ return (sp - msg);
+ if (*dn)
+ continue;
+ goto next;
+ case NS_CMPRSFLGS: /*%< indirection */
+ cp = msg + (((n & 0x3f) << 8) | *cp);
+ break;
+
+ default: /*%< illegal type */
+ errno = EMSGSIZE;
+ return -1;
+ }
+ }
+next:
+ sp += *sp + 1;
+ }
+ }
+
+ errno = ENOENT;
+ return -1;
+}
+
+int ns_name_pack(const unsigned char *src,
+ unsigned char *dst, int dstsiz,
+ const unsigned char **dnptrs,
+ const unsigned char **lastdnptr)
+{
+ unsigned char *dstp;
+ const unsigned char **cpp, **lpp, *eob, *msg;
+ const unsigned char *srcp;
+ int n, l, first = 1;
+
+ srcp = src;
+ dstp = dst;
+ eob = dstp + dstsiz;
+ lpp = cpp = NULL;
+
+ if (dnptrs != NULL) {
+ msg = *dnptrs++;
+ if (msg != NULL) {
+ for (cpp = dnptrs; *cpp != NULL; cpp++)
+ continue;
+
+ lpp = cpp; /*%< end of list to search */
+ }
+ } else {
+ msg = NULL;
+ }
+
+ /* make sure the domain we are about to add is legal */
+ l = 0;
+ do {
+ int l0;
+
+ n = *srcp;
+ if ((n & NS_CMPRSFLGS) == NS_CMPRSFLGS) {
+ errno = EMSGSIZE;
+ return -1;
+ }
+
+ l0 = labellen(srcp);
+ if (l0 < 0) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ l += l0 + 1;
+ if (l > MAXCDNAME) {
+ errno = EMSGSIZE;
+ return -1;
+ }
+
+ srcp += l0 + 1;
+ } while (n != 0);
+
+ /* from here on we need to reset compression pointer array on error */
+ srcp = src;
+
+ do {
+ /* Look to see if we can use pointers. */
+ n = *srcp;
+
+ if (n != 0 && msg != NULL) {
+ l = dn_find(srcp, msg, (const unsigned char * const *) dnptrs,
+ (const unsigned char * const *) lpp);
+ if (l >= 0) {
+ if (dstp + 1 >= eob) {
+ goto cleanup;
+ }
+
+ *dstp++ = ((u_int32_t)l >> 8) | NS_CMPRSFLGS;
+ *dstp++ = l % 256;
+ return (dstp - dst);
+ }
+
+ /* Not found, save it. */
+ if (lastdnptr != NULL && cpp < lastdnptr - 1 &&
+ (dstp - msg) < 0x4000 && first) {
+ *cpp++ = dstp;
+ *cpp = NULL;
+ first = 0;
+ }
+ }
+
+ /* copy label to buffer */
+ if ((n & NS_CMPRSFLGS) == NS_CMPRSFLGS) {
+ /* Should not happen. */
+ goto cleanup;
+ }
+
+ n = labellen(srcp);
+ if (dstp + 1 + n >= eob) {
+ goto cleanup;
+ }
+
+ memcpy(dstp, srcp, (size_t)(n + 1));
+ srcp += n + 1;
+ dstp += n + 1;
+ } while (n != 0);
+
+ if (dstp > eob) {
+cleanup:
+ if (msg != NULL)
+ *lpp = NULL;
+
+ errno = EMSGSIZE;
+ return -1;
+ }
+
+ return dstp - dst;
+}
+libc_hidden_def(ns_name_pack)
+
+int ns_name_compress(const char *src,
+ unsigned char *dst, size_t dstsiz,
+ const unsigned char **dnptrs,
+ const unsigned char **lastdnptr)
+{
+ unsigned char tmp[NS_MAXCDNAME];
+
+ if (ns_name_pton(src, tmp, sizeof(tmp)) == -1)
+ return -1;
+
+ return ns_name_pack(tmp, dst, dstsiz, dnptrs, lastdnptr);
+}
+libc_hidden_def(ns_name_compress)
+
+int ns_name_skip(const unsigned char **ptrptr,
+ const unsigned char *eom)
+{
+ const unsigned char *cp;
+ u_int n;
+ int l;
+
+ cp = *ptrptr;
+ while (cp < eom && (n = *cp++) != 0) {
+ /* Check for indirection. */
+ switch (n & NS_CMPRSFLGS) {
+ case 0: /*%< normal case, n == len */
+ cp += n;
+ continue;
+ case NS_TYPE_ELT: /*%< EDNS0 extended label */
+ l = labellen(cp - 1);
+ if (l < 0) {
+ errno = EMSGSIZE; /*%< XXX */
+ return -1;
+ }
+ cp += l;
+ continue;
+ case NS_CMPRSFLGS: /*%< indirection */
+ cp++;
+ break;
+ default: /*%< illegal type */
+ errno = EMSGSIZE;
+ return -1;
+ }
+
+ break;
+ }
+
+ if (cp > eom) {
+ errno = EMSGSIZE;
+ return -1;
+ }
+
+ *ptrptr = cp;
+
+ return 0;
+}
+libc_hidden_def(ns_name_skip)
+
+int dn_skipname(const unsigned char *ptr, const unsigned char *eom)
+{
+ const unsigned char *saveptr = ptr;
+
+ if (ns_name_skip(&ptr, eom) == -1)
+ return -1;
+
+ return ptr - saveptr;
+}
+libc_hidden_def(dn_skipname)
#endif /* L_ns_name */
-/* vi: set sw=4 ts=4: */
+
+
+#ifdef L_res_init
+
+/* Will be called under __resolv_lock. */
+static void res_sync_func(void)
+{
+ struct __res_state *rp = &(_res);
+ int n;
+
+ /* If we didn't get malloc failure earlier... */
+ if (__nameserver != (void*) &__local_nameserver) {
+ /* TODO:
+ * if (__nameservers < rp->nscount) - try to grow __nameserver[]?
+ */
+#ifdef __UCLIBC_HAS_IPV6__
+ if (__nameservers > rp->_u._ext.nscount)
+ __nameservers = rp->_u._ext.nscount;
+ n = __nameservers;
+ while (--n >= 0)
+ __nameserver[n].sa6 = *rp->_u._ext.nsaddrs[n]; /* struct copy */
+#else /* IPv4 only */
+ if (__nameservers > rp->nscount)
+ __nameservers = rp->nscount;
+ n = __nameservers;
+ while (--n >= 0)
+ __nameserver[n].sa4 = rp->nsaddr_list[n]; /* struct copy */
+#endif
+ }
+ __resolv_timeout = rp->retrans ? : RES_TIMEOUT;
+ __resolv_attempts = rp->retry ? : RES_DFLRETRY;
+ /* Extend and comment what program is known
+ * to use which _res.XXX member(s).
+
+ __resolv_opts = rp->options;
+ ...
+ */
+}
+
+/* has to be called under __resolv_lock */
+static int
+__res_vinit(res_state rp, int preinit)
+{
+ int i, n, options, retrans, retry, ndots;
+#ifdef __UCLIBC_HAS_IPV6__
+ int m = 0;
+#endif
+
+ __close_nameservers();
+ __open_nameservers();
+
+ if (preinit) {
+ options = rp->options;
+ retrans = rp->retrans;
+ retry = rp->retry;
+ ndots = rp->ndots;
+ }
+
+ memset(rp, 0, sizeof(*rp));
+
+ if (!preinit) {
+ rp->options = RES_DEFAULT;
+ rp->retrans = RES_TIMEOUT;
+ rp->retry = RES_DFLRETRY;
+ rp->ndots = 1;
+ } else {
+ rp->options = options;
+ rp->retrans = retrans;
+ rp->retry = retry;
+ rp->ndots = ndots;
+ }
+
+#ifdef __UCLIBC_HAS_COMPAT_RES_STATE__
+ /* Was: "rp->id = random();" but:
+ * - random() pulls in largish static buffers
+ * - isn't actually random unless, say, srandom(time(NULL)) was called
+ * - is not used by uclibc anyway :)
+ */
+ /* rp->id = 0; - memset did it */
+#endif
+#ifdef __UCLIBC_HAS_EXTRA_COMPAT_RES_STATE__
+ rp->_vcsock = -1;
+#endif
+
+ n = __searchdomains;
+ if (n > ARRAY_SIZE(rp->dnsrch))
+ n = ARRAY_SIZE(rp->dnsrch);
+ for (i = 0; i < n; i++)
+ rp->dnsrch[i] = __searchdomain[i];
+
+ /* copy nameservers' addresses */
+ i = 0;
+#ifdef __UCLIBC_HAS_IPV4__
+ n = 0;
+ while (n < ARRAY_SIZE(rp->nsaddr_list) && i < __nameservers) {
+ if (__nameserver[i].sa.sa_family == AF_INET) {
+ rp->nsaddr_list[n] = __nameserver[i].sa4; /* struct copy */
+#ifdef __UCLIBC_HAS_IPV6__
+ if (m < ARRAY_SIZE(rp->_u._ext.nsaddrs)) {
+ rp->_u._ext.nsaddrs[m] = (void*) &rp->nsaddr_list[n];
+ m++;
+ }
+#endif
+ n++;
+ }
+#ifdef __UCLIBC_HAS_IPV6__
+ if (__nameserver[i].sa.sa_family == AF_INET6
+ && m < ARRAY_SIZE(rp->_u._ext.nsaddrs)
+ ) {
+ struct sockaddr_in6 *sa6 = malloc(sizeof(*sa6));
+ if (sa6) {
+ *sa6 = __nameserver[i].sa6; /* struct copy */
+ rp->_u._ext.nsaddrs[m] = sa6;
+ m++;
+ }
+ }
+#endif
+ i++;
+ }
+ rp->nscount = n;
+#ifdef __UCLIBC_HAS_IPV6__
+ rp->_u._ext.nscount = m;
+#endif
+
+#else /* IPv6 only */
+ while (m < ARRAY_SIZE(rp->_u._ext.nsaddrs) && i < __nameservers) {
+ struct sockaddr_in6 *sa6 = malloc(sizeof(*sa6));
+ if (sa6) {
+ *sa6 = __nameserver[i].sa6; /* struct copy */
+ rp->_u._ext.nsaddrs[m] = sa6;
+ m++;
+ }
+ i++;
+ }
+ rp->_u._ext.nscount = m;
+#endif
+
+ rp->options |= RES_INIT;
+
+ return 0;
+}
+
+static unsigned int
+res_randomid(void)
+{
+ return 0xffff & getpid();
+}
+
+/* Our res_init never fails (always returns 0) */
+int
+res_init(void)
+{
+ /*
+ * These three fields used to be statically initialized. This made
+ * it hard to use this code in a shared library. It is necessary,
+ * now that we're doing dynamic initialization here, that we preserve
+ * the old semantics: if an application modifies one of these three
+ * fields of _res before res_init() is called, res_init() will not
+ * alter them. Of course, if an application is setting them to
+ * _zero_ before calling res_init(), hoping to override what used
+ * to be the static default, we can't detect it and unexpected results
+ * will follow. Zero for any of these fields would make no sense,
+ * so one can safely assume that the applications were already getting
+ * unexpected results.
+ *
+ * _res.options is tricky since some apps were known to diddle the bits
+ * before res_init() was first called. We can't replicate that semantic
+ * with dynamic initialization (they may have turned bits off that are
+ * set in RES_DEFAULT). Our solution is to declare such applications
+ * "broken". They could fool us by setting RES_INIT but none do (yet).
+ */
+
+ __UCLIBC_MUTEX_LOCK(__resolv_lock);
+
+ if (!_res.retrans)
+ _res.retrans = RES_TIMEOUT;
+ if (!_res.retry)
+ _res.retry = 4;
+ if (!(_res.options & RES_INIT))
+ _res.options = RES_DEFAULT;
+
+ /*
+ * This one used to initialize implicitly to zero, so unless the app
+ * has set it to something in particular, we can randomize it now.
+ */
+ if (!_res.id)
+ _res.id = res_randomid();
+
+ __res_sync = NULL;
+ __res_vinit(&_res, 1);
+ __res_sync = res_sync_func;
+
+ __UCLIBC_MUTEX_UNLOCK(__resolv_lock);
+
+ return 0;
+}
+libc_hidden_def(res_init)
+
+static void
+__res_iclose(res_state statp)
+{
+ struct __res_state * rp = statp;
+ __UCLIBC_MUTEX_LOCK(__resolv_lock);
+ if (rp == NULL)
+ rp = __res_state();
+ __close_nameservers();
+ __res_sync = NULL;
+#ifdef __UCLIBC_HAS_IPV6__
+ {
+ char *p1 = (char*) &(rp->nsaddr_list[0]);
+ unsigned int m = 0;
+ /* free nsaddrs[m] if they do not point to nsaddr_list[x] */
+ while (m < ARRAY_SIZE(rp->_u._ext.nsaddrs)) {
+ char *p2 = (char*)(rp->_u._ext.nsaddrs[m++]);
+ if (p2 < p1 || (p2 - p1) > (signed)sizeof(rp->nsaddr_list))
+ free(p2);
+ }
+ }
+#endif
+ memset(rp, 0, sizeof(struct __res_state));
+ __UCLIBC_MUTEX_UNLOCK(__resolv_lock);
+}
+
+/*
+ * This routine is for closing the socket if a virtual circuit is used and
+ * the program wants to close it. This provides support for endhostent()
+ * which expects to close the socket.
+ *
+ * This routine is not expected to be user visible.
+ */
+
+void
+res_nclose(res_state statp)
+{
+ __res_iclose(statp);
+}
+
+#ifdef __UCLIBC_HAS_BSD_RES_CLOSE__
+void res_close(void)
+{
+ __res_iclose(NULL);
+}
+#endif
+
+/* This needs to be after the use of _res in res_init, above. */
+#undef _res
+
+#ifndef __UCLIBC_HAS_THREADS__
+/* The resolver state for use by single-threaded programs.
+ This differs from plain `struct __res_state _res;' in that it doesn't
+ create a common definition, but a plain symbol that resides in .bss,
+ which can have an alias. */
+struct __res_state _res __attribute__((section (".bss")));
+struct __res_state *__resp = &_res;
+#else /* __UCLIBC_HAS_THREADS__ */
+struct __res_state _res __attribute__((section (".bss"))) attribute_hidden;
+
+# if defined __UCLIBC_HAS_TLS__
+# undef __resp
+__thread struct __res_state *__resp = &_res;
+extern __thread struct __res_state *__libc_resp
+ __attribute__ ((alias ("__resp"))) attribute_hidden attribute_tls_model_ie;
+# else
+# undef __resp
+struct __res_state *__resp = &_res;
+# endif
+#endif /* !__UCLIBC_HAS_THREADS__ */
+
+/*
+ * Set up default settings. If the configuration file exist, the values
+ * there will have precedence. Otherwise, the server address is set to
+ * INADDR_ANY and the default domain name comes from the gethostname().
+ *
+ * An interrim version of this code (BIND 4.9, pre-4.4BSD) used 127.0.0.1
+ * rather than INADDR_ANY ("0.0.0.0") as the default name server address
+ * since it was noted that INADDR_ANY actually meant ``the first interface
+ * you "ifconfig"'d at boot time'' and if this was a SLIP or PPP interface,
+ * it had to be "up" in order for you to reach your own name server. It
+ * was later decided that since the recommended practice is to always
+ * install local static routes through 127.0.0.1 for all your network
+ * interfaces, that we could solve this problem without a code change.
+ *
+ * The configuration file should always be used, since it is the only way
+ * to specify a default domain. If you are running a server on your local
+ * machine, you should say "nameserver 0.0.0.0" or "nameserver 127.0.0.1"
+ * in the configuration file.
+ *
+ * Return 0 if completes successfully, -1 on error
+ */
+int
+res_ninit(res_state statp)
+{
+ int ret;
+ __UCLIBC_MUTEX_LOCK(__resolv_lock);
+ ret = __res_vinit(statp, 0);
+ __UCLIBC_MUTEX_UNLOCK(__resolv_lock);
+ return ret;
+}
+
+#endif /* L_res_init */
+
+#ifdef L_res_state
+# if defined __UCLIBC_HAS_TLS__
+struct __res_state *
+__res_state (void)
+{
+ return __resp;
+}
+# else
+# undef _res
+extern struct __res_state _res;
+
+/* When threaded, _res may be a per-thread variable. */
+struct __res_state *
+weak_const_function
+__res_state (void)
+{
+ return &_res;
+}
+# endif
+
+#endif /* L_res_state */
+
+
+#ifdef L_res_query
+
+int res_query(const char *dname, int class, int type,
+ unsigned char *answer, int anslen)
+{
+ int i;
+ unsigned char *packet = NULL;
+ struct resolv_answer a;
+
+ if (!dname || class != 1 /* CLASS_IN */) {
+ h_errno = NO_RECOVERY;
+ return -1;
+ }
+
+ memset(&a, '\0', sizeof(a));
+ i = __dns_lookup(dname, type, &packet, &a);
+
+ if (i < 0) {
+ if (!h_errno) /* TODO: can this ever happen? */
+ h_errno = TRY_AGAIN;
+ return -1;
+ }
+
+ free(a.dotted);
+
+ if (i > anslen)
+ i = anslen;
+ memcpy(answer, packet, i);
+
+ free(packet);
+ return i;
+}
+libc_hidden_def(res_query)
+
+/*
+ * Formulate a normal query, send, and retrieve answer in supplied buffer.
+ * Return the size of the response on success, -1 on error.
+ * If enabled, implement search rules until answer or unrecoverable failure
+ * is detected. Error code, if any, is left in h_errno.
+ */
+#define __TRAILING_DOT (1<<0)
+#define __GOT_NODATA (1<<1)
+#define __GOT_SERVFAIL (1<<2)
+#define __TRIED_AS_IS (1<<3)
+int res_search(const char *name, int class, int type, u_char *answer,
+ int anslen)
+{
+ const char *cp;
+ char **domain;
+ HEADER *hp = (HEADER *)(void *)answer;
+ unsigned dots;
+ unsigned state;
+ int ret, saved_herrno;
+ uint32_t _res_options;
+ unsigned _res_ndots;
+ char **_res_dnsrch;
+
+ if (!name || !answer) {
+ h_errno = NETDB_INTERNAL;
+ return -1;
+ }
+
+ again:
+ __UCLIBC_MUTEX_LOCK(__resolv_lock);
+ _res_options = _res.options;
+ _res_ndots = _res.ndots;
+ _res_dnsrch = _res.dnsrch;
+ __UCLIBC_MUTEX_UNLOCK(__resolv_lock);
+ if (!(_res_options & RES_INIT)) {
+ res_init(); /* our res_init never fails */
+ goto again;
+ }
+
+ state = 0;
+ errno = 0;
+ h_errno = HOST_NOT_FOUND; /* default, if we never query */
+ dots = 0;
+ for (cp = name; *cp; cp++)
+ dots += (*cp == '.');
+
+ if (cp > name && *--cp == '.')
+ state |= __TRAILING_DOT;
+
+ /*
+ * If there are dots in the name already, let's just give it a try
+ * 'as is'. The threshold can be set with the "ndots" option.
+ */
+ saved_herrno = -1;
+ if (dots >= _res_ndots) {
+ ret = res_querydomain(name, NULL, class, type, answer, anslen);
+ if (ret > 0)
+ return ret;
+ saved_herrno = h_errno;
+ state |= __TRIED_AS_IS;
+ }
+
+ /*
+ * We do at least one level of search if
+ * - there is no dot and RES_DEFNAME is set, or
+ * - there is at least one dot, there is no trailing dot,
+ * and RES_DNSRCH is set.
+ */
+ if ((!dots && (_res_options & RES_DEFNAMES))
+ || (dots && !(state & __TRAILING_DOT) && (_res_options & RES_DNSRCH))
+ ) {
+ bool done = 0;
+
+ for (domain = _res_dnsrch; *domain && !done; domain++) {
+
+ ret = res_querydomain(name, *domain, class, type,
+ answer, anslen);
+ if (ret > 0)
+ return ret;
+
+ /*
+ * If no server present, give up.
+ * If name isn't found in this domain,
+ * keep trying higher domains in the search list
+ * (if that's enabled).
+ * On a NO_DATA error, keep trying, otherwise
+ * a wildcard entry of another type could keep us
+ * from finding this entry higher in the domain.
+ * If we get some other error (negative answer or
+ * server failure), then stop searching up,
+ * but try the input name below in case it's
+ * fully-qualified.
+ */
+ if (errno == ECONNREFUSED) {
+ h_errno = TRY_AGAIN;
+ return -1;
+ }
+
+ switch (h_errno) {
+ case NO_DATA:
+ state |= __GOT_NODATA;
+ /* FALLTHROUGH */
+ case HOST_NOT_FOUND:
+ /* keep trying */
+ break;
+ case TRY_AGAIN:
+ if (hp->rcode == SERVFAIL) {
+ /* try next search element, if any */
+ state |= __GOT_SERVFAIL;
+ break;
+ }
+ /* FALLTHROUGH */
+ default:
+ /* anything else implies that we're done */
+ done = 1;
+ }
+ /*
+ * if we got here for some reason other than DNSRCH,
+ * we only wanted one iteration of the loop, so stop.
+ */
+ if (!(_res_options & RES_DNSRCH))
+ done = 1;
+ }
+ }
+
+ /*
+ * if we have not already tried the name "as is", do that now.
+ * note that we do this regardless of how many dots were in the
+ * name or whether it ends with a dot.
+ */
+ if (!(state & __TRIED_AS_IS)) {
+ ret = res_querydomain(name, NULL, class, type, answer, anslen);
+ if (ret > 0)
+ return ret;
+ }
+
+ /*
+ * if we got here, we didn't satisfy the search.
+ * if we did an initial full query, return that query's h_errno
+ * (note that we wouldn't be here if that query had succeeded).
+ * else if we ever got a nodata, send that back as the reason.
+ * else send back meaningless h_errno, that being the one from
+ * the last DNSRCH we did.
+ */
+ if (saved_herrno != -1)
+ h_errno = saved_herrno;
+ else if (state & __GOT_NODATA)
+ h_errno = NO_DATA;
+ else if (state & __GOT_SERVFAIL)
+ h_errno = TRY_AGAIN;
+ return -1;
+}
+#undef __TRAILING_DOT
+#undef __GOT_NODATA
+#undef __GOT_SERVFAIL
+#undef __TRIED_AS_IS
+/*
+ * Perform a call on res_query on the concatenation of name and domain,
+ * removing a trailing dot from name if domain is NULL.
+ */
+int res_querydomain(const char *name, const char *domain, int class, int type,
+ u_char *answer, int anslen)
+{
+ char nbuf[MAXDNAME];
+ const char *longname = nbuf;
+ size_t n, d;
+#ifdef DEBUG
+ uint32_t _res_options;
+#endif
+
+ if (!name || !answer) {
+ h_errno = NETDB_INTERNAL;
+ return -1;
+ }
+
+#ifdef DEBUG
+ again:
+ __UCLIBC_MUTEX_LOCK(__resolv_lock);
+ _res_options = _res.options;
+ __UCLIBC_MUTEX_UNLOCK(__resolv_lock);
+ if (!(_res_options & RES_INIT)) {
+ res_init(); /* our res_init never fails */
+ goto again;
+ }
+ if (_res_options & RES_DEBUG)
+ printf(";; res_querydomain(%s, %s, %d, %d)\n",
+ name, (domain ? domain : "<Nil>"), class, type);
+#endif
+ if (domain == NULL) {
+ /*
+ * Check for trailing '.';
+ * copy without '.' if present.
+ */
+ n = strlen(name);
+ if (n + 1 > sizeof(nbuf)) {
+ h_errno = NO_RECOVERY;
+ return -1;
+ }
+ if (n > 0 && name[--n] == '.') {
+ strncpy(nbuf, name, n);
+ nbuf[n] = '\0';
+ } else
+ longname = name;
+ } else {
+ n = strlen(name);
+ d = strlen(domain);
+ if (n + 1 + d + 1 > sizeof(nbuf)) {
+ h_errno = NO_RECOVERY;
+ return -1;
+ }
+ snprintf(nbuf, sizeof(nbuf), "%s.%s", name, domain);
+ }
+ return res_query(longname, class, type, answer, anslen);
+}
+libc_hidden_def(res_querydomain)
+#endif /* L_res_query */
+
+#ifdef L_ns_netint
+unsigned int ns_get16(const unsigned char *src)
+{
+ unsigned int dst;
+ NS_GET16(dst, src);
+ return dst;
+}
+
+unsigned long ns_get32(const unsigned char *src)
+{
+ unsigned long dst;
+ NS_GET32(dst, src);
+ return dst;
+}
+
+void ns_put16(unsigned int src, unsigned char *dst)
+{
+ NS_PUT16(src, dst);
+}
+
+void ns_put32(unsigned long src, unsigned char *dst)
+{
+ NS_PUT32(src, dst);
+}
+#endif /* L_ns_netint */
+
+#ifdef L_ns_parse
+/* These need to be in the same order as the nres.h:ns_flag enum. */
+struct _ns_flagdata { unsigned short mask, shift; };
+static const struct _ns_flagdata _ns_flagdata[16] = {
+ { 0x8000, 15 }, /*%< qr. */
+ { 0x7800, 11 }, /*%< opcode. */
+ { 0x0400, 10 }, /*%< aa. */
+ { 0x0200, 9 }, /*%< tc. */
+ { 0x0100, 8 }, /*%< rd. */
+ { 0x0080, 7 }, /*%< ra. */
+ { 0x0040, 6 }, /*%< z. */
+ { 0x0020, 5 }, /*%< ad. */
+ { 0x0010, 4 }, /*%< cd. */
+ { 0x000f, 0 }, /*%< rcode. */
+ { 0x0000, 0 }, /*%< expansion (1/6). */
+ { 0x0000, 0 }, /*%< expansion (2/6). */
+ { 0x0000, 0 }, /*%< expansion (3/6). */
+ { 0x0000, 0 }, /*%< expansion (4/6). */
+ { 0x0000, 0 }, /*%< expansion (5/6). */
+ { 0x0000, 0 }, /*%< expansion (6/6). */
+};
+
+static void setsection(ns_msg *msg, ns_sect sect)
+{
+ msg->_sect = sect;
+ if (sect == ns_s_max) {
+ msg->_rrnum = -1;
+ msg->_ptr = NULL;
+ } else {
+ msg->_rrnum = 0;
+ msg->_ptr = msg->_sections[(int)sect];
+ }
+}
+
+int ns_skiprr(const unsigned char *ptr,
+ const unsigned char *eom,
+ ns_sect section, int count)
+{
+ const u_char *optr = ptr;
+
+ for (; count > 0; count--) {
+ int b, rdlength;
+
+ b = dn_skipname(ptr, eom);
+ if (b < 0) {
+ errno = EMSGSIZE;
+ return -1;
+ }
+
+ ptr += b/*Name*/ + NS_INT16SZ/*Type*/ + NS_INT16SZ/*Class*/;
+ if (section != ns_s_qd) {
+ if (ptr + NS_INT32SZ + NS_INT16SZ > eom) {
+ errno = EMSGSIZE;
+ return -1;
+ }
+
+ ptr += NS_INT32SZ/*TTL*/;
+ NS_GET16(rdlength, ptr);
+ ptr += rdlength/*RData*/;
+ }
+ }
+
+ if (ptr > eom) {
+ errno = EMSGSIZE;
+ return -1;
+ }
+
+ return ptr - optr;
+}
+libc_hidden_def(ns_skiprr)
+
+int
+ns_initparse(const unsigned char *msg, int msglen, ns_msg *handle)
+{
+ const u_char *eom = msg + msglen;
+ int i;
+
+ handle->_msg = msg;
+ handle->_eom = eom;
+ if (msg + NS_INT16SZ > eom) {
+ errno = EMSGSIZE;
+ return -1;
+ }
+
+ NS_GET16(handle->_id, msg);
+ if (msg + NS_INT16SZ > eom) {
+ errno = EMSGSIZE;
+ return -1;
+ }
+
+ NS_GET16(handle->_flags, msg);
+ for (i = 0; i < ns_s_max; i++) {
+ if (msg + NS_INT16SZ > eom) {
+ errno = EMSGSIZE;
+ return -1;
+ }
+
+ NS_GET16(handle->_counts[i], msg);
+ }
+ for (i = 0; i < ns_s_max; i++)
+ if (handle->_counts[i] == 0)
+ handle->_sections[i] = NULL;
+ else {
+ int b = ns_skiprr(msg, eom, (ns_sect)i,
+ handle->_counts[i]);
+
+ if (b < 0)
+ return -1;
+ handle->_sections[i] = msg;
+ msg += b;
+ }
+
+ if (msg != eom) {
+ errno = EMSGSIZE;
+ return -1;
+ }
+
+ setsection(handle, ns_s_max);
+ return 0;
+}
+
+int
+ns_parserr(ns_msg *handle, ns_sect section, int rrnum, ns_rr *rr)
+{
+ int b;
+ int tmp;
+
+ /* Make section right. */
+ tmp = section;
+ if (tmp < 0 || section >= ns_s_max) {
+ errno = ENODEV;
+ return -1;
+ }
+
+ if (section != handle->_sect)
+ setsection(handle, section);
+
+ /* Make rrnum right. */
+ if (rrnum == -1)
+ rrnum = handle->_rrnum;
+ if (rrnum < 0 || rrnum >= handle->_counts[(int)section]) {
+ errno = ENODEV;
+ return -1;
+ }
+ if (rrnum < handle->_rrnum)
+ setsection(handle, section);
+ if (rrnum > handle->_rrnum) {
+ b = ns_skiprr(handle->_ptr, handle->_eom, section,
+ rrnum - handle->_rrnum);
+
+ if (b < 0)
+ return -1;
+ handle->_ptr += b;
+ handle->_rrnum = rrnum;
+ }
+
+ /* Do the parse. */
+ b = dn_expand(handle->_msg, handle->_eom,
+ handle->_ptr, rr->name, NS_MAXDNAME);
+ if (b < 0)
+ return -1;
+ handle->_ptr += b;
+ if (handle->_ptr + NS_INT16SZ + NS_INT16SZ > handle->_eom) {
+ errno = EMSGSIZE;
+ return -1;
+ }
+ NS_GET16(rr->type, handle->_ptr);
+ NS_GET16(rr->rr_class, handle->_ptr);
+ if (section == ns_s_qd) {
+ rr->ttl = 0;
+ rr->rdlength = 0;
+ rr->rdata = NULL;
+ } else {
+ if (handle->_ptr + NS_INT32SZ + NS_INT16SZ > handle->_eom) {
+ errno = EMSGSIZE;
+ return -1;
+ }
+ NS_GET32(rr->ttl, handle->_ptr);
+ NS_GET16(rr->rdlength, handle->_ptr);
+ if (handle->_ptr + rr->rdlength > handle->_eom) {
+ errno = EMSGSIZE;
+ return -1;
+ }
+ rr->rdata = handle->_ptr;
+ handle->_ptr += rr->rdlength;
+ }
+ if (++handle->_rrnum > handle->_counts[(int)section])
+ setsection(handle, (ns_sect)((int)section + 1));
+
+ return 0;
+}
+
+int ns_msg_getflag(ns_msg handle, int flag)
+{
+ return ((handle)._flags & _ns_flagdata[flag].mask) >> _ns_flagdata[flag].shift;
+}
+#endif /* L_ns_parse */
+
+#ifdef L_res_data
+int res_mkquery(int op, const char *dname, int class, int type,
+ const unsigned char *data, int datalen,
+ const unsigned char *newrr_in,
+ unsigned char *buf, int buflen)
+{
+ HEADER *hp;
+ unsigned char *cp, *ep;
+ unsigned char *dnptrs[20], **dpp, **lastdnptr;
+ uint32_t _res_options;
+ int n;
+
+ if (!buf || buflen < HFIXEDSZ) {
+ h_errno = NETDB_INTERNAL;
+ return -1;
+ }
+
+ again:
+ __UCLIBC_MUTEX_LOCK(__resolv_lock);
+ _res_options = _res.options;
+ __UCLIBC_MUTEX_UNLOCK(__resolv_lock);
+ if (!(_res_options & RES_INIT)) {
+ res_init(); /* our res_init never fails */
+ goto again;
+ }
+
+#ifdef DEBUG
+ if (_res_options & RES_DEBUG)
+ printf(";; res_mkquery(%d, %s, %d, %d)\n",
+ op, dname && *dname ? dname : "<null>", class, type);
+#endif
+
+ memset(buf, 0, HFIXEDSZ);
+ hp = (HEADER *) buf;
+ hp->id = getpid() & 0xffff;
+ hp->opcode = op;
+ hp->rd = (_res_options & RES_RECURSE) != 0U;
+ hp->rcode = NOERROR;
+
+ cp = buf + HFIXEDSZ;
+ ep = buf + buflen;
+ dpp = dnptrs;
+ *dpp++ = buf;
+ *dpp++ = NULL;
+ lastdnptr = dnptrs + sizeof dnptrs / sizeof dnptrs[0];
+
+ /*
+ * perform opcode specific processing
+ */
+ switch (op) {
+ case QUERY:
+ case NS_NOTIFY_OP:
+ if (ep - cp < QFIXEDSZ)
+ return -1;
+
+ n = dn_comp(dname, cp, ep - cp - QFIXEDSZ, dnptrs, lastdnptr);
+ if (n < 0)
+ return -1;
+
+ cp += n;
+ NS_PUT16(type, cp);
+ NS_PUT16(class, cp);
+ hp->qdcount = htons(1);
+
+ if (op == QUERY || data == NULL)
+ break;
+
+ /*
+ * Make an additional record for completion domain.
+ */
+ if ((ep - cp) < RRFIXEDSZ)
+ return -1;
+
+ n = dn_comp((const char *)data, cp, ep - cp - RRFIXEDSZ,
+ dnptrs, lastdnptr);
+ if (n < 0)
+ return -1;
+
+ cp += n;
+ NS_PUT16(T_NULL, cp);
+ NS_PUT16(class, cp);
+ NS_PUT32(0, cp);
+ NS_PUT16(0, cp);
+ hp->arcount = htons(1);
+
+ break;
+
+ case IQUERY:
+ /*
+ * Initialize answer section
+ */
+ if (ep - cp < 1 + RRFIXEDSZ + datalen)
+ return -1;
+
+ *cp++ = '\0'; /*%< no domain name */
+ NS_PUT16(type, cp);
+ NS_PUT16(class, cp);
+ NS_PUT32(0, cp);
+ NS_PUT16(datalen, cp);
+
+ if (datalen) {
+ memcpy(cp, data, (size_t)datalen);
+ cp += datalen;
+ }
+
+ hp->ancount = htons(1);
+ break;
+
+ default:
+ return -1;
+ }
+
+ return cp - buf;
+}
+#endif /* L_res_data */
+
+/* Unimplemented: */
+/* res_send */
diff --git a/libc/inet/rpc/Makefile.in b/libc/inet/rpc/Makefile.in
index 2f1246b20..9abe85dc8 100644
--- a/libc/inet/rpc/Makefile.in
+++ b/libc/inet/rpc/Makefile.in
@@ -1,15 +1,16 @@
# 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.
#
-CFLAGS-rpc := -fno-strict-aliasing
+subdirs += libc/inet/rpc
+
+CFLAGS-y-libc/inet/rpc := -fno-strict-aliasing
-ifneq ($(UCLIBC_HAS_FULL_RPC),y)
# For now, only compile the stuff needed to do an NFS mount....
-CSRC:= authunix_prot.c auth_none.c auth_unix.c bindresvport.c \
+CSRC_NFS = authunix_prot.c auth_none.c auth_unix.c bindresvport.c \
clnt_perror.c clnt_simple.c clnt_tcp.c clnt_udp.c \
create_xid.c getrpcent.c \
pmap_clnt.c pm_getmaps.c pm_getport.c pmap_prot.c pmap_prot2.c \
@@ -17,29 +18,25 @@ CSRC:= authunix_prot.c auth_none.c auth_unix.c bindresvport.c \
rpc_prot.c rpc_thread.c rtime.c ruserpass.c sa_len.c \
svc.c svc_auth.c svc_authux.c \
xdr.c xdr_array.c xdr_mem.c xdr_rec.c xdr_reference.c
-endif
INET_RPC_DIR:=$(top_srcdir)libc/inet/rpc
INET_RPC_OUT:=$(top_builddir)libc/inet/rpc
-ifeq ($(UCLIBC_HAS_FULL_RPC),y)
-INET_RPC_SRC:=$(wildcard $(INET_RPC_DIR)/*.c)
-else
-INET_RPC_SRC:=$(patsubst %.c,$(INET_RPC_DIR)/%.c,$(CSRC))
-endif
-# rpc_thread.oS is better, because the header adds unneeded references to __pthread_internal_tsd*
-INET_RPC_SRC:=$(filter-out $(INET_RPC_DIR)/rpc_thread.c,$(INET_RPC_SRC))
-
-INET_RPC_OBJ:=$(patsubst $(INET_RPC_DIR)/%.c,$(INET_RPC_OUT)/%.o,$(INET_RPC_SRC))
+CSRC_ALL = $(notdir $(wildcard $(INET_RPC_DIR)/*.c))
+CSRC-y := $(if $(UCLIBC_HAS_FULL_RPC),$(CSRC_ALL),$(CSRC_NFS))
+# rpc_thread.oS is better, because the header adds unneeded references
+# to __pthread_internal_tsd*
+CSRC-y := $(filter-out rpc_thread.c,$(CSRC-y))
-libc-static-$(UCLIBC_HAS_RPC)+=$(INET_RPC_OUT)/rpc_thread.o
-libc-shared-$(UCLIBC_HAS_RPC)+=$(INET_RPC_OUT)/rpc_thread.oS
+INET_RPC_SRC:=$(patsubst %.c,$(INET_RPC_DIR)/%.c,$(CSRC-y))
+INET_RPC_OBJ:=$(patsubst %.c,$(INET_RPC_OUT)/%.o,$(CSRC-y))
+libc-static-$(UCLIBC_HAS_RPC) += $(INET_RPC_OUT)/rpc_thread.o
+libc-shared-$(UCLIBC_HAS_RPC) += $(INET_RPC_OUT)/rpc_thread.oS
libc-nomulti-$(UCLIBC_HAS_RPC) += $(INET_RPC_OUT)/rpc_thread.o
+libc-$(UCLIBC_HAS_RPC) += $(INET_RPC_OBJ)
-libc-$(UCLIBC_HAS_RPC)+=$(INET_RPC_OBJ)
-
-objclean-y+=inet_rpc_objclean
+objclean-y+=CLEAN_libc/inet/rpc
-inet_rpc_objclean:
- $(RM) $(INET_RPC_OUT)/*.{o,os,oS}
+CLEAN_libc/inet/rpc:
+ $(do_rm) $(addprefix $(INET_RPC_OUT)/*., o os oS)
diff --git a/libc/inet/rpc/auth_none.c b/libc/inet/rpc/auth_none.c
index 05851025f..4bf37cb10 100644
--- a/libc/inet/rpc/auth_none.c
+++ b/libc/inet/rpc/auth_none.c
@@ -35,12 +35,8 @@
* credentials and verifiers to remote systems.
*/
-#define __FORCE_GLIBC
-#include <features.h>
#include "rpc_private.h"
-libc_hidden_proto(xdrmem_create)
-libc_hidden_proto(xdr_opaque_auth)
#define MAX_MARSHAL_SIZE 20
@@ -68,50 +64,54 @@ struct authnone_private_s {
char marshalled_client[MAX_MARSHAL_SIZE];
u_int mcnt;
};
+
+static struct authnone_private_s authnone_private;
#ifdef __UCLIBC_HAS_THREADS__
-#define authnone_private (*(struct authnone_private_s **)&RPC_THREAD_VARIABLE(authnone_private_s))
-#else
-static struct authnone_private_s *authnone_private;
+__libc_once_define(static, authnone_private_guard);
#endif
-libc_hidden_proto(authnone_create)
-AUTH *
-authnone_create (void)
+static void authnone_create_once (void);
+
+static void
+authnone_create_once (void)
{
struct authnone_private_s *ap;
XDR xdr_stream;
XDR *xdrs;
- ap = (struct authnone_private_s *) authnone_private;
- if (ap == NULL)
- {
- ap = (struct authnone_private_s *) calloc (1, sizeof (*ap));
- if (ap == NULL)
- return NULL;
- authnone_private = ap;
- }
- if (!ap->mcnt)
- {
- ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth;
- ap->no_client.ah_ops = (struct auth_ops *)&ops;
- xdrs = &xdr_stream;
- xdrmem_create (xdrs, ap->marshalled_client, (u_int) MAX_MARSHAL_SIZE,
- XDR_ENCODE);
- (void) xdr_opaque_auth (xdrs, &ap->no_client.ah_cred);
- (void) xdr_opaque_auth (xdrs, &ap->no_client.ah_verf);
- ap->mcnt = XDR_GETPOS (xdrs);
- XDR_DESTROY (xdrs);
- }
- return (&ap->no_client);
+ ap = &authnone_private;
+
+ ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth;
+ ap->no_client.ah_ops = (struct auth_ops *) &ops;
+ xdrs = &xdr_stream;
+ xdrmem_create(xdrs, ap->marshalled_client,
+ (u_int) MAX_MARSHAL_SIZE, XDR_ENCODE);
+ (void) xdr_opaque_auth(xdrs, &ap->no_client.ah_cred);
+ (void) xdr_opaque_auth(xdrs, &ap->no_client.ah_verf);
+ ap->mcnt = XDR_GETPOS (xdrs);
+ XDR_DESTROY (xdrs);
+}
+
+AUTH *
+authnone_create (void)
+{
+#ifdef __UCLIBC_HAS_THREADS__
+ __libc_once (authnone_private_guard, authnone_create_once);
+#else
+ authnone_create_once();
+#endif
+ return &authnone_private.no_client;
}
libc_hidden_def(authnone_create)
static bool_t
-authnone_marshal (AUTH *client attribute_unused, XDR *xdrs)
+authnone_marshal (AUTH *client, XDR *xdrs)
{
struct authnone_private_s *ap;
- ap = authnone_private;
+ /* authnone_create returned authnone_private->no_client, which is
+ the first field of struct authnone_private_s. */
+ ap = (struct authnone_private_s *) client;
if (ap == NULL)
return FALSE;
return (*xdrs->x_ops->x_putbytes) (xdrs, ap->marshalled_client, ap->mcnt);
diff --git a/libc/inet/rpc/auth_unix.c b/libc/inet/rpc/auth_unix.c
index 0654b51c1..72d7a7af9 100644
--- a/libc/inet/rpc/auth_unix.c
+++ b/libc/inet/rpc/auth_unix.c
@@ -38,13 +38,11 @@
* for the credentials.
*/
-#define __FORCE_GLIBC
-#include <features.h>
-
#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
+#include <libintl.h>
#include <sys/param.h>
#include <rpc/types.h>
@@ -52,27 +50,6 @@
#include <rpc/auth.h>
#include <rpc/auth_unix.h>
-#ifdef USE_IN_LIBIO
-# include <wchar.h>
-#endif
-
-/* Experimentally off - libc_hidden_proto(memcpy) */
-libc_hidden_proto(sysconf)
-libc_hidden_proto(getegid)
-libc_hidden_proto(geteuid)
-libc_hidden_proto(getgroups)
-libc_hidden_proto(gethostname)
-libc_hidden_proto(xdrmem_create)
-libc_hidden_proto(xdr_authunix_parms)
-libc_hidden_proto(xdr_opaque_auth)
-libc_hidden_proto(gettimeofday)
-libc_hidden_proto(fputs)
-libc_hidden_proto(perror)
-libc_hidden_proto(abort)
-#ifdef USE_IN_LIBIO
-libc_hidden_proto(fwprintf)
-#endif
-
/*
* Unix authenticator operations vector
*/
@@ -82,7 +59,7 @@ static bool_t authunix_validate (AUTH *, struct opaque_auth *);
static bool_t authunix_refresh (AUTH *);
static void authunix_destroy (AUTH *);
-static struct auth_ops auth_unix_ops = {
+static const struct auth_ops auth_unix_ops = {
authunix_nextverf,
authunix_marshal,
authunix_validate,
@@ -109,7 +86,6 @@ static bool_t marshal_new_auth (AUTH *) internal_function;
* Create a unix style authenticator.
* Returns an auth handle with the given stuff in it.
*/
-libc_hidden_proto(authunix_create)
AUTH *
authunix_create (char *machname, uid_t uid, gid_t gid, int len,
gid_t *aup_gids)
@@ -129,13 +105,7 @@ authunix_create (char *machname, uid_t uid, gid_t gid, int len,
if (auth == NULL || au == NULL)
{
no_memory:
-#ifdef USE_IN_LIBIO
- if (_IO_fwide (stderr, 0) > 0)
- (void) fwprintf (stderr, L"%s",
- _("authunix_create: out of memory\n"));
- else
-#endif
- (void) fputs (_("authunix_create: out of memory\n"), stderr);
+ (void) fputs (_("authunix_create: out of memory\n"), stderr);
mem_free (auth, sizeof (*auth));
mem_free (au, sizeof (*au));
return NULL;
@@ -182,7 +152,6 @@ libc_hidden_def(authunix_create)
* Returns an auth handle with parameters determined by doing lots of
* syscalls.
*/
-libc_hidden_proto(authunix_create_default)
AUTH *
authunix_create_default (void)
{
@@ -345,7 +314,7 @@ marshal_new_auth (AUTH *auth)
xdrmem_create (xdrs, au->au_marshed, MAX_AUTH_BYTES, XDR_ENCODE);
if ((!xdr_opaque_auth (xdrs, &(auth->ah_cred))) ||
(!xdr_opaque_auth (xdrs, &(auth->ah_verf))))
- perror (_("auth_none.c - Fatal marshalling problem"));
+ perror (_("auth_unix.c - Fatal marshalling problem"));
else
au->au_mpos = XDR_GETPOS (xdrs);
diff --git a/libc/inet/rpc/authunix_prot.c b/libc/inet/rpc/authunix_prot.c
index 62d1cb724..272990056 100644
--- a/libc/inet/rpc/authunix_prot.c
+++ b/libc/inet/rpc/authunix_prot.c
@@ -39,17 +39,11 @@
#include <rpc/auth.h>
#include <rpc/auth_unix.h>
-libc_hidden_proto(xdr_string)
-libc_hidden_proto(xdr_u_int)
-libc_hidden_proto(xdr_array)
-libc_hidden_proto(xdr_u_long)
-libc_hidden_proto(xdr_u_short)
/*
* XDR for unix authentication parameters.
* Unfortunately, none of these can be declared const.
*/
-libc_hidden_proto(xdr_authunix_parms)
bool_t
xdr_authunix_parms (XDR * xdrs, struct authunix_parms *p)
{
diff --git a/libc/inet/rpc/bindresvport.c b/libc/inet/rpc/bindresvport.c
index 3f266e6cc..30bbd2684 100644
--- a/libc/inet/rpc/bindresvport.c
+++ b/libc/inet/rpc/bindresvport.c
@@ -30,9 +30,6 @@
* Copyright (c) 1987 by Sun Microsystems, Inc.
*/
-#define __FORCE_GLIBC
-#include <features.h>
-
#include <errno.h>
#include <unistd.h>
#include <string.h>
@@ -40,14 +37,10 @@
#include <sys/socket.h>
#include <netinet/in.h>
-/* Experimentally off - libc_hidden_proto(memset) */
-libc_hidden_proto(bind)
-libc_hidden_proto(getpid)
/*
* Bind a socket to a privileged IP port
*/
-libc_hidden_proto(bindresvport)
int
bindresvport (int sd, struct sockaddr_in *sin)
{
diff --git a/libc/inet/rpc/clnt_generic.c b/libc/inet/rpc/clnt_generic.c
index 54bd0e914..f2d6c1295 100644
--- a/libc/inet/rpc/clnt_generic.c
+++ b/libc/inet/rpc/clnt_generic.c
@@ -30,9 +30,6 @@
* Copyright (C) 1987, Sun Microsystems, Inc.
*/
-#define __FORCE_GLIBC
-#include <features.h>
-
#include <alloca.h>
#include <errno.h>
#include <string.h>
@@ -40,16 +37,6 @@
#include <sys/socket.h>
#include <netdb.h>
-/* Experimentally off - libc_hidden_proto(memcpy) */
-/* Experimentally off - libc_hidden_proto(memset) */
-/* Experimentally off - libc_hidden_proto(strcmp) */
-/* Experimentally off - libc_hidden_proto(strcpy) */
-libc_hidden_proto(clnttcp_create)
-libc_hidden_proto(clntudp_create)
-libc_hidden_proto(clntunix_create)
-libc_hidden_proto(getprotobyname_r)
-libc_hidden_proto(gethostbyname_r)
-libc_hidden_proto(__rpc_thread_createerr)
/*
* Generic client creation: takes (hostname, program-number, protocol) and
@@ -129,7 +116,7 @@ clnt_create (const char *hostname, u_long prog, u_long vers,
prttmpbuf = alloca (prtbuflen);
while (getprotobyname_r (proto, &protobuf, prttmpbuf, prtbuflen, &p) != 0
|| p == NULL)
- if (errno != ERANGE)
+ if (errno != ERANGE)
{
struct rpc_createerr *ce = &get_rpc_createerr ();
ce->cf_stat = RPC_UNKNOWNPROTO;
diff --git a/libc/inet/rpc/clnt_perror.c b/libc/inet/rpc/clnt_perror.c
index 7e6c907ce..190e07eb7 100644
--- a/libc/inet/rpc/clnt_perror.c
+++ b/libc/inet/rpc/clnt_perror.c
@@ -38,28 +38,10 @@ static char sccsid[] = "@(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro";
*
*/
-#define __FORCE_GLIBC
-#include <features.h>
-
#include <stdio.h>
#include <string.h>
#include "rpc_private.h"
-#ifdef USE_IN_LIBIO
-# include <wchar.h>
-# include <libio/iolibio.h>
-# define fputs(s, f) _IO_fputs (s, f)
-#endif
-
-/* Experimentally off - libc_hidden_proto(strcpy) */
-/* Experimentally off - libc_hidden_proto(strlen) */
-libc_hidden_proto(sprintf)
-libc_hidden_proto(__glibc_strerror_r)
-libc_hidden_proto(fputs)
-#ifdef USE_IN_LIBIO
-libc_hidden_proto(fwprintf)
-#endif
-
static char *auth_errmsg (enum auth_stat stat) internal_function;
#ifdef __UCLIBC_HAS_THREADS__
@@ -90,74 +72,74 @@ struct rpc_errtab
static const char rpc_errstr[] =
{
#define RPC_SUCCESS_IDX 0
- _("RPC: Success")
+ N_("RPC: Success")
"\0"
#define RPC_CANTENCODEARGS_IDX (RPC_SUCCESS_IDX + sizeof "RPC: Success")
- _("RPC: Can't encode arguments")
+ N_("RPC: Can't encode arguments")
"\0"
#define RPC_CANTDECODERES_IDX (RPC_CANTENCODEARGS_IDX \
+ sizeof "RPC: Can't encode arguments")
- _("RPC: Can't decode result")
+ N_("RPC: Can't decode result")
"\0"
#define RPC_CANTSEND_IDX (RPC_CANTDECODERES_IDX \
+ sizeof "RPC: Can't decode result")
- _("RPC: Unable to send")
+ N_("RPC: Unable to send")
"\0"
#define RPC_CANTRECV_IDX (RPC_CANTSEND_IDX \
+ sizeof "RPC: Unable to send")
- _("RPC: Unable to receive")
+ N_("RPC: Unable to receive")
"\0"
#define RPC_TIMEDOUT_IDX (RPC_CANTRECV_IDX \
+ sizeof "RPC: Unable to receive")
- _("RPC: Timed out")
+ N_("RPC: Timed out")
"\0"
#define RPC_VERSMISMATCH_IDX (RPC_TIMEDOUT_IDX \
+ sizeof "RPC: Timed out")
- _("RPC: Incompatible versions of RPC")
+ N_("RPC: Incompatible versions of RPC")
"\0"
#define RPC_AUTHERROR_IDX (RPC_VERSMISMATCH_IDX \
+ sizeof "RPC: Incompatible versions of RPC")
- _("RPC: Authentication error")
+ N_("RPC: Authentication error")
"\0"
#define RPC_PROGUNAVAIL_IDX (RPC_AUTHERROR_IDX \
+ sizeof "RPC: Authentication error")
- _("RPC: Program unavailable")
+ N_("RPC: Program unavailable")
"\0"
#define RPC_PROGVERSMISMATCH_IDX (RPC_PROGUNAVAIL_IDX \
+ sizeof "RPC: Program unavailable")
- _("RPC: Program/version mismatch")
+ N_("RPC: Program/version mismatch")
"\0"
#define RPC_PROCUNAVAIL_IDX (RPC_PROGVERSMISMATCH_IDX \
+ sizeof "RPC: Program/version mismatch")
- _("RPC: Procedure unavailable")
+ N_("RPC: Procedure unavailable")
"\0"
#define RPC_CANTDECODEARGS_IDX (RPC_PROCUNAVAIL_IDX \
+ sizeof "RPC: Procedure unavailable")
- _("RPC: Server can't decode arguments")
+ N_("RPC: Server can't decode arguments")
"\0"
#define RPC_SYSTEMERROR_IDX (RPC_CANTDECODEARGS_IDX \
+ sizeof "RPC: Server can't decode arguments")
- _("RPC: Remote system error")
+ N_("RPC: Remote system error")
"\0"
#define RPC_UNKNOWNHOST_IDX (RPC_SYSTEMERROR_IDX \
+ sizeof "RPC: Remote system error")
- _("RPC: Unknown host")
+ N_("RPC: Unknown host")
"\0"
#define RPC_UNKNOWNPROTO_IDX (RPC_UNKNOWNHOST_IDX \
+ sizeof "RPC: Unknown host")
- _("RPC: Unknown protocol")
+ N_("RPC: Unknown protocol")
"\0"
#define RPC_PMAPFAILURE_IDX (RPC_UNKNOWNPROTO_IDX \
+ sizeof "RPC: Unknown protocol")
- _("RPC: Port mapper failure")
+ N_("RPC: Port mapper failure")
"\0"
#define RPC_PROGNOTREGISTERED_IDX (RPC_PMAPFAILURE_IDX \
+ sizeof "RPC: Port mapper failure")
- _("RPC: Program not registered")
+ N_("RPC: Program not registered")
"\0"
#define RPC_FAILED_IDX (RPC_PROGNOTREGISTERED_IDX \
+ sizeof "RPC: Program not registered")
- _("RPC: Failed (unspecified error)")
+ N_("RPC: Failed (unspecified error)")
};
static const struct rpc_errtab rpc_errlist[] =
@@ -186,7 +168,6 @@ static const struct rpc_errtab rpc_errlist[] =
/*
* This interface for use by clntrpc
*/
-libc_hidden_proto(clnt_sperrno)
char *
clnt_sperrno (enum clnt_stat stat)
{
@@ -199,25 +180,19 @@ clnt_sperrno (enum clnt_stat stat)
return (char*)_(rpc_errstr + rpc_errlist[i].message_off);
}
}
- return _("RPC: (unknown error code)");
+ return N_("RPC: (unknown error code)");
}
libc_hidden_def(clnt_sperrno)
void
clnt_perrno (enum clnt_stat num)
{
-#ifdef USE_IN_LIBIO
- if (_IO_fwide (stderr, 0) > 0)
- (void) fwprintf (stderr, L"%s", clnt_sperrno (num));
- else
-#endif
- (void) fputs (clnt_sperrno (num), stderr);
+ (void) fputs (clnt_sperrno (num), stderr);
}
/*
* Print reply error info
*/
-libc_hidden_proto(clnt_sperror)
char *
clnt_sperror (CLIENT * rpch, const char *msg)
{
@@ -303,20 +278,13 @@ clnt_sperror (CLIENT * rpch, const char *msg)
}
libc_hidden_def(clnt_sperror)
-libc_hidden_proto(clnt_perror)
void
clnt_perror (CLIENT * rpch, const char *msg)
{
-#ifdef USE_IN_LIBIO
- if (_IO_fwide (stderr, 0) > 0)
- (void) fwprintf (stderr, L"%s", clnt_sperror (rpch, msg));
- else
-#endif
- (void) fputs (clnt_sperror (rpch, msg), stderr);
+ (void) fputs (clnt_sperror (rpch, msg), stderr);
}
libc_hidden_def(clnt_perror)
-libc_hidden_proto(clnt_spcreateerror)
char *
clnt_spcreateerror (const char *msg)
{
@@ -365,12 +333,7 @@ libc_hidden_def(clnt_spcreateerror)
void
clnt_pcreateerror (const char *msg)
{
-#ifdef USE_IN_LIBIO
- if (_IO_fwide (stderr, 0) > 0)
- (void) fwprintf (stderr, L"%s", clnt_spcreateerror (msg));
- else
-#endif
- (void) fputs (clnt_spcreateerror (msg), stderr);
+ (void) fputs (clnt_spcreateerror (msg), stderr);
}
struct auth_errtab
@@ -382,34 +345,34 @@ struct auth_errtab
static const char auth_errstr[] =
{
#define AUTH_OK_IDX 0
- _("Authentication OK")
+ N_("Authentication OK")
"\0"
#define AUTH_BADCRED_IDX (AUTH_OK_IDX + sizeof "Authentication OK")
- _("Invalid client credential")
+ N_("Invalid client credential")
"\0"
#define AUTH_REJECTEDCRED_IDX (AUTH_BADCRED_IDX \
+ sizeof "Invalid client credential")
- _("Server rejected credential")
+ N_("Server rejected credential")
"\0"
#define AUTH_BADVERF_IDX (AUTH_REJECTEDCRED_IDX \
+ sizeof "Server rejected credential")
- _("Invalid client verifier")
+ N_("Invalid client verifier")
"\0"
#define AUTH_REJECTEDVERF_IDX (AUTH_BADVERF_IDX \
+ sizeof "Invalid client verifier")
- _("Server rejected verifier")
+ N_("Server rejected verifier")
"\0"
#define AUTH_TOOWEAK_IDX (AUTH_REJECTEDVERF_IDX \
+ sizeof "Server rejected verifier")
- _("Client credential too weak")
+ N_("Client credential too weak")
"\0"
#define AUTH_INVALIDRESP_IDX (AUTH_TOOWEAK_IDX \
+ sizeof "Client credential too weak")
- _("Invalid server verifier")
+ N_("Invalid server verifier")
"\0"
#define AUTH_FAILED_IDX (AUTH_INVALIDRESP_IDX \
+ sizeof "Invalid server verifier")
- _("Failed (unspecified error)")
+ N_("Failed (unspecified error)")
};
static const struct auth_errtab auth_errlist[] =
diff --git a/libc/inet/rpc/clnt_raw.c b/libc/inet/rpc/clnt_raw.c
index b44bd38b8..ddc1c1421 100644
--- a/libc/inet/rpc/clnt_raw.c
+++ b/libc/inet/rpc/clnt_raw.c
@@ -42,20 +42,11 @@ static char sccsid[] = "@(#)clnt_raw.c 1.22 87/08/11 Copyr 1984 Sun Micro";
* any interference from the kernel.
*/
-#define __FORCE_GLIBC
#include <features.h>
#include "rpc_private.h"
#include <rpc/svc.h>
#include <rpc/xdr.h>
-libc_hidden_proto(perror)
-libc_hidden_proto(authnone_create)
-libc_hidden_proto(xdrmem_create)
-libc_hidden_proto(xdr_callhdr)
-libc_hidden_proto(xdr_replymsg)
-libc_hidden_proto(xdr_opaque_auth)
-libc_hidden_proto(svc_getreq)
-libc_hidden_proto(_seterr_reply)
#define MCALL_MSG_SIZE 24
@@ -84,7 +75,7 @@ static bool_t clntraw_freeres (CLIENT *, xdrproc_t, caddr_t);
static bool_t clntraw_control (CLIENT *, int, char *);
static void clntraw_destroy (CLIENT *);
-static struct clnt_ops client_ops =
+static const struct clnt_ops client_ops =
{
clntraw_call,
clntraw_abort,
@@ -141,14 +132,9 @@ clntraw_create (u_long prog, u_long vers)
}
static enum clnt_stat
-clntraw_call (h, proc, xargs, argsp, xresults, resultsp, timeout)
- CLIENT *h;
- u_long proc;
- xdrproc_t xargs;
- caddr_t argsp;
- xdrproc_t xresults;
- caddr_t resultsp;
- struct timeval timeout attribute_unused;
+clntraw_call (CLIENT *h, u_long proc, xdrproc_t xargs, caddr_t argsp,
+ xdrproc_t xresults, caddr_t resultsp,
+ struct timeval timeout attribute_unused)
{
struct clntraw_private_s *clp = clntraw_private;
XDR *xdrs = &clp->xdr_stream;
diff --git a/libc/inet/rpc/clnt_simple.c b/libc/inet/rpc/clnt_simple.c
index 745a50213..d67e69527 100644
--- a/libc/inet/rpc/clnt_simple.c
+++ b/libc/inet/rpc/clnt_simple.c
@@ -38,9 +38,6 @@ static char sccsid[] = "@(#)clnt_simple.c 1.35 87/08/11 Copyr 1984 Sun Micro";
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
-#define __FORCE_GLIBC
-#include <features.h>
-
#include <alloca.h>
#include <errno.h>
#include <stdio.h>
@@ -50,12 +47,6 @@ static char sccsid[] = "@(#)clnt_simple.c 1.35 87/08/11 Copyr 1984 Sun Micro";
#include <netdb.h>
#include <string.h>
-/* Experimentally off - libc_hidden_proto(memcpy) */
-/* Experimentally off - libc_hidden_proto(strcmp) */
-/* Experimentally off - libc_hidden_proto(strncpy) */
-libc_hidden_proto(close)
-libc_hidden_proto(clntudp_create)
-libc_hidden_proto(gethostbyname_r)
struct callrpc_private_s
{
diff --git a/libc/inet/rpc/clnt_tcp.c b/libc/inet/rpc/clnt_tcp.c
index 23e4ca863..4b19a9aab 100644
--- a/libc/inet/rpc/clnt_tcp.c
+++ b/libc/inet/rpc/clnt_tcp.c
@@ -50,46 +50,14 @@ static char sccsid[] = "@(#)clnt_tcp.c 1.37 87/10/05 Copyr 1984 Sun Micro";
* Now go hang yourself.
*/
-#define __FORCE_GLIBC
-#include <features.h>
-
#include <netdb.h>
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
-#include <rpc/rpc.h>
+#include "rpc_private.h"
#include <sys/poll.h>
#include <sys/socket.h>
#include <rpc/pmap_clnt.h>
-#ifdef USE_IN_LIBIO
-# include <wchar.h>
-#endif
-
-libc_hidden_proto(socket)
-libc_hidden_proto(read)
-libc_hidden_proto(write)
-libc_hidden_proto(close)
-libc_hidden_proto(authnone_create)
-libc_hidden_proto(xdrrec_create)
-libc_hidden_proto(xdrrec_endofrecord)
-libc_hidden_proto(xdrrec_skiprecord)
-libc_hidden_proto(xdr_callhdr)
-libc_hidden_proto(xdr_replymsg)
-libc_hidden_proto(xdr_opaque_auth)
-libc_hidden_proto(xdrmem_create)
-libc_hidden_proto(xdr_void)
-libc_hidden_proto(pmap_getport)
-libc_hidden_proto(_seterr_reply)
-libc_hidden_proto(connect)
-libc_hidden_proto(bindresvport)
-libc_hidden_proto(poll)
-libc_hidden_proto(fputs)
-libc_hidden_proto(__rpc_thread_createerr)
-#ifdef USE_IN_LIBIO
-libc_hidden_proto(fwprintf)
-#endif
-
-extern u_long _create_xid (void) attribute_hidden;
#define MCALL_MSG_SIZE 24
@@ -117,7 +85,7 @@ static bool_t clnttcp_freeres (CLIENT *, xdrproc_t, caddr_t);
static bool_t clnttcp_control (CLIENT *, int, char *);
static void clnttcp_destroy (CLIENT *);
-static struct clnt_ops tcp_ops =
+static const struct clnt_ops tcp_ops =
{
clnttcp_call,
clnttcp_abort,
@@ -141,7 +109,6 @@ static struct clnt_ops tcp_ops =
* NB: The rpch->cl_auth is set null authentication. Caller may wish to set this
* something more useful.
*/
-libc_hidden_proto(clnttcp_create)
CLIENT *
clnttcp_create (struct sockaddr_in *raddr, u_long prog, u_long vers,
int *sockp, u_int sendsz, u_int recvsz)
@@ -155,13 +122,7 @@ clnttcp_create (struct sockaddr_in *raddr, u_long prog, u_long vers,
if (h == NULL || ct == NULL)
{
struct rpc_createerr *ce = &get_rpc_createerr ();
-#ifdef USE_IN_LIBIO
- if (_IO_fwide (stderr, 0) > 0)
- (void) fwprintf (stderr, L"%s",
- _("clnttcp_create: out of memory\n"));
- else
-#endif
- (void) fputs (_("clnttcp_create: out of memory\n"), stderr);
+ (void) fputs (_("clnttcp_create: out of memory\n"), stderr);
ce->cf_stat = RPC_SYSTEMERROR;
ce->cf_error.re_errno = ENOMEM;
goto fooy;
@@ -262,14 +223,9 @@ fooy:
libc_hidden_def(clnttcp_create)
static enum clnt_stat
-clnttcp_call (h, proc, xdr_args, args_ptr, xdr_results, results_ptr, timeout)
- CLIENT *h;
- u_long proc;
- xdrproc_t xdr_args;
- caddr_t args_ptr;
- xdrproc_t xdr_results;
- caddr_t results_ptr;
- struct timeval timeout;
+clnttcp_call (CLIENT *h, u_long proc, xdrproc_t xdr_args, caddr_t args_ptr,
+ xdrproc_t xdr_results, caddr_t results_ptr,
+ struct timeval timeout)
{
struct ct_data *ct = (struct ct_data *) h->cl_private;
XDR *xdrs = &(ct->ct_xdrs);
@@ -370,9 +326,7 @@ call_again:
}
static void
-clnttcp_geterr (h, errp)
- CLIENT *h;
- struct rpc_err *errp;
+clnttcp_geterr (CLIENT *h, struct rpc_err *errp)
{
struct ct_data *ct =
(struct ct_data *) h->cl_private;
@@ -381,10 +335,7 @@ clnttcp_geterr (h, errp)
}
static bool_t
-clnttcp_freeres (cl, xdr_res, res_ptr)
- CLIENT *cl;
- xdrproc_t xdr_res;
- caddr_t res_ptr;
+clnttcp_freeres (CLIENT *cl, xdrproc_t xdr_res, caddr_t res_ptr)
{
struct ct_data *ct = (struct ct_data *) cl->cl_private;
XDR *xdrs = &(ct->ct_xdrs);
@@ -394,7 +345,7 @@ clnttcp_freeres (cl, xdr_res, res_ptr)
}
static void
-clnttcp_abort ()
+clnttcp_abort (void)
{
}
@@ -437,6 +388,7 @@ clnttcp_control (CLIENT *cl, int request, char *info)
/* This will set the xid of the NEXT call */
*(u_long *)ct->ct_mcall = htonl (*(u_long *)info - 1);
/* decrement by 1 as clnttcp_call() increments once */
+ break;
case CLGET_VERS:
/*
* This RELIES on the information that, in the call body,
diff --git a/libc/inet/rpc/clnt_udp.c b/libc/inet/rpc/clnt_udp.c
index 1d7cb4863..4fc55b732 100644
--- a/libc/inet/rpc/clnt_udp.c
+++ b/libc/inet/rpc/clnt_udp.c
@@ -37,12 +37,9 @@ static char sccsid[] = "@(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro";
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
-#define __FORCE_GLIBC
-#include <features.h>
-
#include <stdio.h>
#include <unistd.h>
-#include <rpc/rpc.h>
+#include "rpc_private.h"
#include <rpc/xdr.h>
#include <rpc/clnt.h>
#include <sys/poll.h>
@@ -52,41 +49,12 @@ static char sccsid[] = "@(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro";
#include <errno.h>
#include <rpc/pmap_clnt.h>
#include <net/if.h>
-#ifdef USE_IN_LIBIO
-# include <wchar.h>
-libc_hidden_proto(fwprintf)
-#endif
#ifdef IP_RECVERR
#include "errqueue.h"
#include <sys/uio.h>
#endif
-/* Experimentally off - libc_hidden_proto(memcmp) */
-libc_hidden_proto(ioctl)
-libc_hidden_proto(socket)
-libc_hidden_proto(close)
-/* CMSG_NXTHDR is using it */
-libc_hidden_proto(__cmsg_nxthdr)
-
-libc_hidden_proto(authnone_create)
-libc_hidden_proto(xdrmem_create)
-libc_hidden_proto(xdr_callhdr)
-libc_hidden_proto(xdr_replymsg)
-libc_hidden_proto(xdr_opaque_auth)
-libc_hidden_proto(pmap_getport)
-libc_hidden_proto(_seterr_reply)
-libc_hidden_proto(setsockopt)
-libc_hidden_proto(bindresvport)
-libc_hidden_proto(recvfrom)
-libc_hidden_proto(sendto)
-libc_hidden_proto(recvmsg)
-libc_hidden_proto(poll)
-libc_hidden_proto(fputs)
-libc_hidden_proto(__rpc_thread_createerr)
-
-extern u_long _create_xid (void) attribute_hidden;
-
/*
* UDP bases client side rpc operations
*/
@@ -98,7 +66,7 @@ static bool_t clntudp_freeres (CLIENT *, xdrproc_t, caddr_t);
static bool_t clntudp_control (CLIENT *, int, char *);
static void clntudp_destroy (CLIENT *);
-static struct clnt_ops udp_ops =
+static const struct clnt_ops udp_ops =
{
clntudp_call,
clntudp_abort,
@@ -137,17 +105,16 @@ struct cu_data
* NB: The rpch->cl_auth is initialized to null authentication.
* Caller may wish to set this something more useful.
*
- * wait is the amount of time used between retransmitting a call if
+ * _wait is the amount of time used between retransmitting a call if
* no response has been heard; retransmission occurs until the actual
* rpc call times out.
*
* sendsz and recvsz are the maximum allowable packet sizes that can be
* sent and received.
*/
-libc_hidden_proto(clntudp_bufcreate)
CLIENT *
clntudp_bufcreate (struct sockaddr_in *raddr, u_long program, u_long version,
- struct timeval wait, int *sockp, u_int sendsz,
+ struct timeval _wait, int *sockp, u_int sendsz,
u_int recvsz)
{
CLIENT *cl;
@@ -161,13 +128,7 @@ clntudp_bufcreate (struct sockaddr_in *raddr, u_long program, u_long version,
if (cl == NULL || cu == NULL)
{
struct rpc_createerr *ce = &get_rpc_createerr ();
-#ifdef USE_IN_LIBIO
- if (_IO_fwide (stderr, 0) > 0)
- (void) fwprintf (stderr, L"%s",
- _("clntudp_create: out of memory\n"));
- else
-#endif
- (void) fputs (_("clntudp_create: out of memory\n"), stderr);
+ (void) fputs (_("clntudp_create: out of memory\n"), stderr);
ce->cf_stat = RPC_SYSTEMERROR;
ce->cf_error.re_errno = ENOMEM;
goto fooy;
@@ -188,7 +149,7 @@ clntudp_bufcreate (struct sockaddr_in *raddr, u_long program, u_long version,
cl->cl_private = (caddr_t) cu;
cu->cu_raddr = *raddr;
cu->cu_rlen = sizeof (cu->cu_raddr);
- cu->cu_wait = wait;
+ cu->cu_wait = _wait;
cu->cu_total.tv_sec = -1;
cu->cu_total.tv_usec = -1;
cu->cu_sendsz = sendsz;
@@ -245,12 +206,11 @@ fooy:
}
libc_hidden_def(clntudp_bufcreate)
-libc_hidden_proto(clntudp_create)
CLIENT *
-clntudp_create (struct sockaddr_in *raddr, u_long program, u_long version, struct timeval wait, int *sockp)
+clntudp_create (struct sockaddr_in *raddr, u_long program, u_long version, struct timeval _wait, int *sockp)
{
- return clntudp_bufcreate (raddr, program, version, wait, sockp,
+ return clntudp_bufcreate (raddr, program, version, _wait, sockp,
UDPMSGSIZE, UDPMSGSIZE);
}
libc_hidden_def(clntudp_create)
@@ -283,14 +243,14 @@ is_network_up (int sock)
}
static enum clnt_stat
-clntudp_call (cl, proc, xargs, argsp, xresults, resultsp, utimeout)
- CLIENT *cl; /* client handle */
- u_long proc; /* procedure number */
- xdrproc_t xargs; /* xdr routine for args */
- caddr_t argsp; /* pointer to args */
- xdrproc_t xresults; /* xdr routine for results */
- caddr_t resultsp; /* pointer to results */
- struct timeval utimeout; /* seconds to wait before giving up */
+clntudp_call (
+ CLIENT *cl, /* client handle */
+ u_long proc, /* procedure number */
+ xdrproc_t xargs, /* xdr routine for args */
+ caddr_t argsp, /* pointer to args */
+ xdrproc_t xresults, /* xdr routine for results */
+ caddr_t resultsp, /* pointer to results */
+ struct timeval utimeout /* seconds to wait before giving up */)
{
struct cu_data *cu = (struct cu_data *) cl->cl_private;
XDR *xdrs;
@@ -577,6 +537,7 @@ clntudp_control (CLIENT *cl, int request, char *info)
/* This will set the xid of the NEXT call */
*(u_long *)cu->cu_outbuf = htonl(*(u_long *)info - 1);
/* decrement by 1 as clntudp_call() increments once */
+ break;
case CLGET_VERS:
/*
* This RELIES on the information that, in the call body,
diff --git a/libc/inet/rpc/clnt_unix.c b/libc/inet/rpc/clnt_unix.c
index 73be74288..e4a6672b7 100644
--- a/libc/inet/rpc/clnt_unix.c
+++ b/libc/inet/rpc/clnt_unix.c
@@ -46,49 +46,15 @@
* Now go hang yourself.
*/
-#define __FORCE_GLIBC
-#include <features.h>
-
#include <netdb.h>
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
-#include <rpc/rpc.h>
+#include "rpc_private.h"
#include <sys/uio.h>
#include <sys/poll.h>
#include <sys/socket.h>
#include <rpc/pmap_clnt.h>
-#ifdef USE_IN_LIBIO
-# include <wchar.h>
-libc_hidden_proto(fwprintf)
-#endif
-
-/* Experimentally off - libc_hidden_proto(strlen) */
-/* Experimentally off - libc_hidden_proto(memcpy) */
-libc_hidden_proto(socket)
-libc_hidden_proto(close)
-libc_hidden_proto(getpid)
-libc_hidden_proto(authnone_create)
-libc_hidden_proto(xdrrec_create)
-libc_hidden_proto(xdrrec_endofrecord)
-libc_hidden_proto(xdrrec_skiprecord)
-libc_hidden_proto(xdr_callhdr)
-libc_hidden_proto(xdr_replymsg)
-libc_hidden_proto(xdr_opaque_auth)
-libc_hidden_proto(xdrmem_create)
-libc_hidden_proto(xdr_void)
-libc_hidden_proto(getegid)
-libc_hidden_proto(geteuid)
-libc_hidden_proto(_seterr_reply)
-libc_hidden_proto(setsockopt)
-libc_hidden_proto(connect)
-libc_hidden_proto(recvmsg)
-libc_hidden_proto(sendmsg)
-libc_hidden_proto(poll)
-libc_hidden_proto(fputs)
-libc_hidden_proto(__rpc_thread_createerr)
-
-extern u_long _create_xid (void) attribute_hidden;
#define MCALL_MSG_SIZE 24
@@ -116,7 +82,7 @@ static bool_t clntunix_freeres (CLIENT *, xdrproc_t, caddr_t);
static bool_t clntunix_control (CLIENT *, int, char *);
static void clntunix_destroy (CLIENT *);
-static struct clnt_ops unix_ops =
+static const struct clnt_ops unix_ops =
{
clntunix_call,
clntunix_abort,
@@ -140,7 +106,6 @@ static struct clnt_ops unix_ops =
* NB: The rpch->cl_auth is set null authentication. Caller may wish to set this
* something more useful.
*/
-libc_hidden_proto(clntunix_create)
CLIENT *
clntunix_create (struct sockaddr_un *raddr, u_long prog, u_long vers,
int *sockp, u_int sendsz, u_int recvsz)
@@ -154,13 +119,7 @@ clntunix_create (struct sockaddr_un *raddr, u_long prog, u_long vers,
if (h == NULL || ct == NULL)
{
struct rpc_createerr *ce = &get_rpc_createerr ();
-#ifdef USE_IN_LIBIO
- if (_IO_fwide (stderr, 0) > 0)
- (void) fwprintf (stderr, L"%s",
- _("clntunix_create: out of memory\n"));
- else
-#endif
- (void) fputs (_("clntunix_create: out of memory\n"), stderr);
+ (void) fputs (_("clntunix_create: out of memory\n"), stderr);
ce->cf_stat = RPC_SYSTEMERROR;
ce->cf_error.re_errno = ENOMEM;
goto fooy;
@@ -242,14 +201,9 @@ fooy:
libc_hidden_def(clntunix_create)
static enum clnt_stat
-clntunix_call (h, proc, xdr_args, args_ptr, xdr_results, results_ptr, timeout)
- CLIENT *h;
- u_long proc;
- xdrproc_t xdr_args;
- caddr_t args_ptr;
- xdrproc_t xdr_results;
- caddr_t results_ptr;
- struct timeval timeout;
+clntunix_call (CLIENT *h, u_long proc, xdrproc_t xdr_args, caddr_t args_ptr,
+ xdrproc_t xdr_results, caddr_t results_ptr,
+ struct timeval timeout)
{
struct ct_data *ct = (struct ct_data *) h->cl_private;
XDR *xdrs = &(ct->ct_xdrs);
@@ -356,10 +310,7 @@ clntunix_geterr (CLIENT *h, struct rpc_err *errp)
}
static bool_t
-clntunix_freeres (cl, xdr_res, res_ptr)
- CLIENT *cl;
- xdrproc_t xdr_res;
- caddr_t res_ptr;
+clntunix_freeres (CLIENT *cl, xdrproc_t xdr_res, caddr_t res_ptr)
{
struct ct_data *ct = (struct ct_data *) cl->cl_private;
XDR *xdrs = &(ct->ct_xdrs);
@@ -369,7 +320,7 @@ clntunix_freeres (cl, xdr_res, res_ptr)
}
static void
-clntunix_abort ()
+clntunix_abort (void)
{
}
@@ -411,6 +362,7 @@ clntunix_control (CLIENT *cl, int request, char *info)
/* This will set the xid of the NEXT call */
*(u_long *) ct->ct_mcall = htonl (*(u_long *)info - 1);
/* decrement by 1 as clntunix_call() increments once */
+ break;
case CLGET_VERS:
/*
* This RELIES on the information that, in the call body,
@@ -474,7 +426,7 @@ __msgread (int sock, void *data, size_t cnt)
struct iovec iov;
struct msghdr msg;
#ifdef SCM_CREDENTIALS
- static char cm[CMSG_SPACE(sizeof (struct ucred))];
+ /*static -why??*/ char cm[CMSG_SPACE(sizeof (struct ucred))];
#endif
int len;
diff --git a/libc/inet/rpc/create_xid.c b/libc/inet/rpc/create_xid.c
index e3ee4799b..61487c6a4 100644
--- a/libc/inet/rpc/create_xid.c
+++ b/libc/inet/rpc/create_xid.c
@@ -13,35 +13,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. */
-
-#define __FORCE_GLIBC
-#include <features.h>
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <unistd.h>
#include <stdlib.h>
#include <sys/time.h>
-#include <rpc/rpc.h>
+#include "rpc_private.h"
-libc_hidden_proto(lrand48_r)
-libc_hidden_proto(srand48_r)
-libc_hidden_proto(gettimeofday)
/* The RPC code is not threadsafe, but new code should be threadsafe. */
#include <bits/uClibc_mutex.h>
__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER);
-
static smallint is_initialized;
static struct drand48_data __rpc_lrand48_data;
-u_long _create_xid (void) attribute_hidden;
u_long _create_xid (void)
{
- unsigned long res;
+ long res;
__UCLIBC_MUTEX_LOCK(mylock);
diff --git a/libc/inet/rpc/errqueue.h b/libc/inet/rpc/errqueue.h
index 9ed6dc62b..07f65e1db 100644
--- a/libc/inet/rpc/errqueue.h
+++ b/libc/inet/rpc/errqueue.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 version. */
diff --git a/libc/inet/rpc/get_myaddress.c b/libc/inet/rpc/get_myaddress.c
index a6ba07811..04999a199 100644
--- a/libc/inet/rpc/get_myaddress.c
+++ b/libc/inet/rpc/get_myaddress.c
@@ -44,17 +44,13 @@ static char sccsid[] = "@(#)get_myaddress.c 1.4 87/08/11 Copyr 1984 Sun Micro";
#include <sys/socket.h>
#include <stdio.h>
#include <unistd.h>
+#include <libintl.h>
#include <net/if.h>
#include <sys/ioctl.h>
/* Order of following two #includes reversed by roland@gnu */
#include <netinet/in.h>
#include <arpa/inet.h>
-libc_hidden_proto(ioctl)
-libc_hidden_proto(socket)
-libc_hidden_proto(close)
-libc_hidden_proto(perror)
-libc_hidden_proto(exit)
/*
* don't use gethostbyname, which would invoke yellow pages
diff --git a/libc/inet/rpc/getrpcent.c b/libc/inet/rpc/getrpcent.c
index 186bd130f..dba2a6878 100644
--- a/libc/inet/rpc/getrpcent.c
+++ b/libc/inet/rpc/getrpcent.c
@@ -33,8 +33,6 @@
* Copyright (c) 1985 by Sun Microsystems, Inc.
*/
-#define __FORCE_GLIBC
-#include <features.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
@@ -44,16 +42,6 @@
#include <arpa/inet.h>
#include <errno.h>
-/* Experimentally off - libc_hidden_proto(memcpy) */
-/* Experimentally off - libc_hidden_proto(memset) */
-/* Experimentally off - libc_hidden_proto(strchr) */
-/* Experimentally off - libc_hidden_proto(strcmp) */
-/* Experimentally off - libc_hidden_proto(strlen) */
-libc_hidden_proto(fopen)
-libc_hidden_proto(fclose)
-libc_hidden_proto(atoi)
-libc_hidden_proto(rewind)
-libc_hidden_proto(fgets)
/*
* Internet version.
@@ -70,7 +58,7 @@ static struct rpcdata {
char *domain;
} *rpcdata;
-static char RPCDB[] = "/etc/rpc";
+static const char RPCDB[] = "/etc/rpc";
static struct rpcdata *_rpcdata(void)
{
@@ -84,7 +72,6 @@ static struct rpcdata *_rpcdata(void)
return d;
}
-libc_hidden_proto(endrpcent)
void endrpcent(void)
{
register struct rpcdata *d = _rpcdata();
@@ -102,7 +89,6 @@ void endrpcent(void)
}
libc_hidden_def(endrpcent)
-libc_hidden_proto(setrpcent)
void setrpcent(int f)
{
register struct rpcdata *d = _rpcdata();
@@ -128,7 +114,6 @@ static struct rpcent *__get_next_rpcent(struct rpcdata *d)
return interpret(d);
}
-libc_hidden_proto(getrpcent)
struct rpcent *getrpcent(void)
{
register struct rpcdata *d = _rpcdata();
@@ -141,7 +126,6 @@ struct rpcent *getrpcent(void)
}
libc_hidden_def(getrpcent)
-libc_hidden_proto(getrpcbynumber)
struct rpcent *getrpcbynumber(register int number)
{
register struct rpcdata *d = _rpcdata();
@@ -159,7 +143,6 @@ struct rpcent *getrpcbynumber(register int number)
}
libc_hidden_def(getrpcbynumber)
-libc_hidden_proto(getrpcbyname)
struct rpcent *getrpcbyname(const char *name)
{
struct rpcent *rpc;
diff --git a/libc/inet/rpc/getrpcport.c b/libc/inet/rpc/getrpcport.c
index 0a57d1da9..84f1e5ff5 100644
--- a/libc/inet/rpc/getrpcport.c
+++ b/libc/inet/rpc/getrpcport.c
@@ -35,9 +35,6 @@ static char sccsid[] = "@(#)getrpcport.c 1.3 87/08/11 SMI";
* Copyright (c) 1985 by Sun Microsystems, Inc.
*/
-#define __FORCE_GLIBC
-#include <features.h>
-
#include <alloca.h>
#include <errno.h>
#include <stdio.h>
@@ -48,9 +45,6 @@ static char sccsid[] = "@(#)getrpcport.c 1.3 87/08/11 SMI";
#include <rpc/pmap_clnt.h>
#include <sys/socket.h>
-/* Experimentally off - libc_hidden_proto(memcpy) */
-libc_hidden_proto(pmap_getport)
-libc_hidden_proto(gethostbyname_r)
int
getrpcport (const char *host, u_long prognum, u_long versnum, u_int proto)
diff --git a/libc/inet/rpc/pm_getmaps.c b/libc/inet/rpc/pm_getmaps.c
index 1760adf37..910625a75 100644
--- a/libc/inet/rpc/pm_getmaps.c
+++ b/libc/inet/rpc/pm_getmaps.c
@@ -39,7 +39,7 @@ static char sccsid[] = "@(#)pmap_getmaps.c 1.10 87/08/11 Copyr 1984 Sun Micro";
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
-#include <rpc/rpc.h>
+#include "rpc_private.h"
#include <rpc/pmap_prot.h>
#include <rpc/pmap_clnt.h>
#include <netdb.h>
@@ -48,11 +48,6 @@ static char sccsid[] = "@(#)pmap_getmaps.c 1.10 87/08/11 Copyr 1984 Sun Micro";
#include <errno.h>
#include <unistd.h>
-libc_hidden_proto(clnt_perror)
-libc_hidden_proto(clnttcp_create)
-libc_hidden_proto(xdr_pmap)
-libc_hidden_proto(xdr_pmaplist)
-libc_hidden_proto(xdr_void)
/*
* Get a copy of the current port maps.
@@ -83,7 +78,7 @@ pmap_getmaps (struct sockaddr_in *address)
}
CLNT_DESTROY (client);
}
- /* (void)__close(_socket); CLNT_DESTROY already closed it */
+ /* (void)close(_socket); CLNT_DESTROY already closed it */
address->sin_port = 0;
return head;
}
diff --git a/libc/inet/rpc/pm_getport.c b/libc/inet/rpc/pm_getport.c
index 327fb9101..9a0e79178 100644
--- a/libc/inet/rpc/pm_getport.c
+++ b/libc/inet/rpc/pm_getport.c
@@ -44,10 +44,6 @@ static char sccsid[] = "@(#)pmap_getport.c 1.9 87/08/11 Copyr 1984 Sun Micro";
#include <rpc/pmap_prot.h>
#include <rpc/pmap_clnt.h>
-libc_hidden_proto(clntudp_bufcreate)
-libc_hidden_proto(__rpc_thread_createerr)
-libc_hidden_proto(xdr_u_short)
-libc_hidden_proto(xdr_pmap)
static const struct timeval timeout =
{5, 0};
@@ -59,13 +55,9 @@ static const struct timeval tottimeout =
* Calls the pmap service remotely to do the lookup.
* Returns 0 if no map exists.
*/
-libc_hidden_proto(pmap_getport)
u_short
-pmap_getport (address, program, version, protocol)
- struct sockaddr_in *address;
- u_long program;
- u_long version;
- u_int protocol;
+pmap_getport (struct sockaddr_in *address, u_long program, u_long version,
+ u_int protocol)
{
u_short port = 0;
int _socket = -1;
@@ -73,7 +65,19 @@ pmap_getport (address, program, version, protocol)
struct pmap parms;
address->sin_port = htons (PMAPPORT);
- client = clntudp_bufcreate (address, PMAPPROG,
+ if (protocol == IPPROTO_TCP)
+ {
+ // glibc does this:
+ ///* Don't need a reserved port to get ports from the portmapper. */
+ //socket = __get_socket(address); // does socket(TCP),bind(),connect(address)
+ //if (_socket != -1)
+ // closeit = true;
+ // do we need/want to do the same?
+ client = clnttcp_create (address, PMAPPROG,
+ PMAPVERS, &_socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE);
+ }
+ else
+ client = clntudp_bufcreate (address, PMAPPROG,
PMAPVERS, timeout, &_socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE);
if (client != (CLIENT *) NULL)
{
@@ -95,7 +99,7 @@ pmap_getport (address, program, version, protocol)
}
CLNT_DESTROY (client);
}
- /* (void)__close(_socket); CLNT_DESTROY already closed it */
+ /* (void)close(_socket); CLNT_DESTROY already closed it */
address->sin_port = 0;
return port;
}
diff --git a/libc/inet/rpc/pmap_clnt.c b/libc/inet/rpc/pmap_clnt.c
index 8ac41f281..20a54313b 100644
--- a/libc/inet/rpc/pmap_clnt.c
+++ b/libc/inet/rpc/pmap_clnt.c
@@ -34,9 +34,6 @@
* Client interface to pmap rpc service.
*/
-#define __FORCE_GLIBC
-#include <features.h>
-
#include <stdio.h>
#include <unistd.h>
#include <net/if.h>
@@ -44,19 +41,10 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
-#include <rpc/rpc.h>
+#include "rpc_private.h"
#include <rpc/pmap_prot.h>
#include <rpc/pmap_clnt.h>
-libc_hidden_proto(ioctl)
-libc_hidden_proto(socket)
-libc_hidden_proto(close)
-libc_hidden_proto(perror)
-libc_hidden_proto(exit)
-libc_hidden_proto(clnt_perror)
-libc_hidden_proto(clntudp_bufcreate)
-libc_hidden_proto(xdr_bool)
-libc_hidden_proto(xdr_pmap)
/*
* Same as get_myaddress, but we try to use the loopback
@@ -122,7 +110,6 @@ static const struct timeval tottimeout = {60, 0};
* Set a mapping between program,version and port.
* Calls the pmap service remotely to do the mapping.
*/
-libc_hidden_proto(pmap_set)
bool_t
pmap_set (u_long program, u_long version, int protocol, u_short port)
{
@@ -159,7 +146,6 @@ libc_hidden_def (pmap_set)
* Remove the mapping between program,version and port.
* Calls the pmap service remotely to do the un-mapping.
*/
-libc_hidden_proto(pmap_unset)
bool_t
pmap_unset (u_long program, u_long version)
{
diff --git a/libc/inet/rpc/pmap_prot.c b/libc/inet/rpc/pmap_prot.c
index 0ae2c88f3..342dbad09 100644
--- a/libc/inet/rpc/pmap_prot.c
+++ b/libc/inet/rpc/pmap_prot.c
@@ -42,13 +42,9 @@ static char sccsid[] = "@(#)pmap_prot.c 1.17 87/08/11 Copyr 1984 Sun Micro";
#include <rpc/xdr.h>
#include <rpc/pmap_prot.h>
-libc_hidden_proto(xdr_u_long)
-libc_hidden_proto(xdr_pmap)
bool_t
-xdr_pmap (xdrs, regs)
- XDR *xdrs;
- struct pmap *regs;
+xdr_pmap (XDR *xdrs, struct pmap *regs)
{
if (xdr_u_long (xdrs, &regs->pm_prog) &&
diff --git a/libc/inet/rpc/pmap_prot2.c b/libc/inet/rpc/pmap_prot2.c
index 5adc4ee2e..f383757e8 100644
--- a/libc/inet/rpc/pmap_prot2.c
+++ b/libc/inet/rpc/pmap_prot2.c
@@ -42,9 +42,6 @@ static char sccsid[] = "@(#)pmap_prot2.c 1.3 87/08/11 Copyr 1984 Sun Micro";
#include <rpc/xdr.h>
#include <rpc/pmap_prot.h>
-libc_hidden_proto(xdr_bool)
-libc_hidden_proto(xdr_reference)
-libc_hidden_proto(xdr_pmap)
/*
* What is going on with linked lists? (!)
@@ -84,11 +81,8 @@ libc_hidden_proto(xdr_pmap)
* the net, yet is the data that the pointer points to which is interesting;
* this sounds like a job for xdr_reference!
*/
-libc_hidden_proto(xdr_pmaplist)
bool_t
-xdr_pmaplist (xdrs, rp)
- XDR *xdrs;
- struct pmaplist **rp;
+xdr_pmaplist (XDR *xdrs, struct pmaplist **rp)
{
/*
* more_elements is pre-computed in case the direction is
diff --git a/libc/inet/rpc/pmap_rmt.c b/libc/inet/rpc/pmap_rmt.c
index 759534aa7..2576e396b 100644
--- a/libc/inet/rpc/pmap_rmt.c
+++ b/libc/inet/rpc/pmap_rmt.c
@@ -39,12 +39,9 @@ static char sccsid[] = "@(#)pmap_rmt.c 1.21 87/08/27 Copyr 1984 Sun Micro";
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
-#define __FORCE_GLIBC
-#include <features.h>
-
#include <unistd.h>
#include <string.h>
-#include <rpc/rpc.h>
+#include "rpc_private.h"
#include <rpc/pmap_prot.h>
#include <rpc/pmap_clnt.h>
#include <rpc/pmap_rmt.h>
@@ -52,39 +49,12 @@ static char sccsid[] = "@(#)pmap_rmt.c 1.21 87/08/27 Copyr 1984 Sun Micro";
#include <sys/socket.h>
#include <stdio.h>
#include <errno.h>
-#undef _POSIX_SOURCE /* Ultrix <sys/param.h> needs --roland@gnu */
#include <sys/param.h> /* Ultrix needs before net/if --roland@gnu */
#include <net/if.h>
#include <sys/ioctl.h>
#include <arpa/inet.h>
#define MAX_BROADCAST_SIZE 1400
-/* Experimentally off - libc_hidden_proto(memset) */
-libc_hidden_proto(ioctl)
-libc_hidden_proto(perror)
-libc_hidden_proto(socket)
-libc_hidden_proto(close)
-libc_hidden_proto(authunix_create_default)
-libc_hidden_proto(xdrmem_create)
-libc_hidden_proto(xdr_callmsg)
-libc_hidden_proto(xdr_replymsg)
-libc_hidden_proto(xdr_reference)
-libc_hidden_proto(xdr_u_long)
-libc_hidden_proto(xdr_void)
-libc_hidden_proto(xdr_rmtcallres)
-libc_hidden_proto(xdr_rmtcall_args)
-libc_hidden_proto(inet_makeaddr)
-libc_hidden_proto(inet_netof)
-libc_hidden_proto(clntudp_create)
-libc_hidden_proto(setsockopt)
-libc_hidden_proto(recvfrom)
-libc_hidden_proto(sendto)
-libc_hidden_proto(poll)
-libc_hidden_proto(fprintf)
-
-
-extern u_long _create_xid (void) attribute_hidden;
-
static const struct timeval timeout = {3, 0};
/*
@@ -95,13 +65,9 @@ static const struct timeval timeout = {3, 0};
* programs to do a lookup and call in one step.
*/
enum clnt_stat
-pmap_rmtcall (addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, port_ptr)
- struct sockaddr_in *addr;
- u_long prog, vers, proc;
- xdrproc_t xdrargs, xdrres;
- caddr_t argsp, resp;
- struct timeval tout;
- u_long *port_ptr;
+pmap_rmtcall (struct sockaddr_in *addr, u_long prog, u_long vers, u_long proc,
+ xdrproc_t xdrargs, caddr_t argsp, xdrproc_t xdrres, caddr_t resp,
+ struct timeval tout, u_long *port_ptr)
{
int _socket = -1;
CLIENT *client;
@@ -173,9 +139,7 @@ libc_hidden_def(xdr_rmtcall_args)
* written for XDR_DECODE direction only
*/
bool_t
-xdr_rmtcallres (xdrs, crp)
- XDR *xdrs;
- struct rmtcallres *crp;
+xdr_rmtcallres (XDR *xdrs, struct rmtcallres *crp)
{
caddr_t port_ptr;
@@ -253,15 +217,15 @@ getbroadcastnets (struct in_addr *addrs, int sock, char *buf)
enum clnt_stat
-clnt_broadcast (prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
- u_long prog; /* program number */
- u_long vers; /* version number */
- u_long proc; /* procedure number */
- xdrproc_t xargs; /* xdr routine for args */
- caddr_t argsp; /* pointer to args */
- xdrproc_t xresults; /* xdr routine for results */
- caddr_t resultsp; /* pointer to results */
- resultproc_t eachresult; /* call with each result obtained */
+clnt_broadcast (
+ u_long prog, /* program number */
+ u_long vers, /* version number */
+ u_long proc, /* procedure number */
+ xdrproc_t xargs, /* xdr routine for args */
+ caddr_t argsp, /* pointer to args */
+ xdrproc_t xresults, /* xdr routine for results */
+ caddr_t resultsp, /* pointer to results */
+ resultproc_t eachresult /* call with each result obtained */)
{
enum clnt_stat stat = RPC_FAILED;
AUTH *unix_auth = authunix_create_default ();
diff --git a/libc/inet/rpc/rcmd.c b/libc/inet/rpc/rcmd.c
index cd8d620c0..fdfaa0908 100644
--- a/libc/inet/rpc/rcmd.c
+++ b/libc/inet/rpc/rcmd.c
@@ -69,7 +69,6 @@ static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94";
#include <netinet/in.h>
#include <arpa/inet.h>
-#include <alloca.h>
#include <signal.h>
#include <fcntl.h>
#include <netdb.h>
@@ -77,7 +76,6 @@ static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94";
#include <pwd.h>
#include <errno.h>
#include <stdio.h>
-#include <stdio_ext.h>
#include <ctype.h>
#include <string.h>
#include <libintl.h>
@@ -86,60 +84,13 @@ static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94";
#include <wchar.h>
#endif
#include <sys/uio.h>
+#include <bits/uClibc_alloc.h>
-/* Experimentally off - libc_hidden_proto(memcmp) */
-/* Experimentally off - libc_hidden_proto(strcat) */
-/* Experimentally off - libc_hidden_proto(strchr) */
-/* Experimentally off - libc_hidden_proto(strcmp) */
-/* Experimentally off - libc_hidden_proto(strcpy) */
-/* Experimentally off - libc_hidden_proto(strlen) */
-/* Experimentally off - libc_hidden_proto(strncmp) */
-/* Experimentally off - libc_hidden_proto(memmove) */
-libc_hidden_proto(getpid)
-libc_hidden_proto(socket)
-libc_hidden_proto(close)
-libc_hidden_proto(fcntl)
-libc_hidden_proto(read)
-libc_hidden_proto(write)
-libc_hidden_proto(perror)
-libc_hidden_proto(lstat)
-libc_hidden_proto(fstat)
-libc_hidden_proto(tolower)
-libc_hidden_proto(sysconf)
-libc_hidden_proto(getline)
-libc_hidden_proto(geteuid)
-libc_hidden_proto(seteuid)
-libc_hidden_proto(getpwnam_r)
-libc_hidden_proto(gethostbyname)
-libc_hidden_proto(gethostbyname_r)
-libc_hidden_proto(fileno)
-libc_hidden_proto(sleep)
-libc_hidden_proto(inet_addr)
-libc_hidden_proto(inet_ntoa)
-libc_hidden_proto(herror)
-libc_hidden_proto(bind)
-libc_hidden_proto(connect)
-libc_hidden_proto(sigblock)
-libc_hidden_proto(snprintf)
-libc_hidden_proto(poll)
-libc_hidden_proto(accept)
-libc_hidden_proto(listen)
-libc_hidden_proto(sigsetmask)
-libc_hidden_proto(getc_unlocked)
-libc_hidden_proto(__fgetc_unlocked)
-libc_hidden_proto(fopen)
-libc_hidden_proto(fclose)
-libc_hidden_proto(fprintf)
-libc_hidden_proto(__h_errno_location)
-#ifdef __UCLIBC_HAS_XLOCALE__
-libc_hidden_proto(__ctype_b_loc)
-libc_hidden_proto(__ctype_tolower_loc)
-#elif defined __UCLIBC_HAS_CTYPE_TABLES__
-libc_hidden_proto(__ctype_b)
-libc_hidden_proto(__ctype_tolower)
-#endif
+/* sigsetmask and sigblock are not provided anymore, until this file is corrected,
+ * include the sources */
+#include "../../signal/sigblock.c"
+#include "../../signal/sigsetmask.c"
-libc_hidden_proto(rresvport)
/* some forward declarations */
static int __ivaliduser2(FILE *hostf, u_int32_t raddr,
@@ -148,11 +99,8 @@ static int iruserok2 (u_int32_t raddr, int superuser, const char *ruser,
const char *luser, const char *rhost);
-int rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
- char **ahost;
- u_short rport;
- const char *locuser, *remuser, *cmd;
- int *fd2p;
+int rcmd(char **ahost, u_short rport, const char *locuser, const char *remuser,
+ const char *cmd, int *fd2p)
{
#ifdef __UCLIBC_HAS_REENTRANT_RPC__
int herr;
@@ -172,11 +120,7 @@ int rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
#ifdef __UCLIBC_HAS_REENTRANT_RPC__
hstbuflen = 1024;
-#ifdef __ARCH_USE_MMU__
- tmphstbuf = alloca (hstbuflen);
-#else
- tmphstbuf = malloc (hstbuflen);
-#endif
+ tmphstbuf = stack_heap_alloc(hstbuflen);
while (gethostbyname_r (*ahost, &hostbuf, tmphstbuf,
hstbuflen, &hp, &herr) != 0 || hp == NULL)
@@ -184,9 +128,7 @@ int rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
if (herr != NETDB_INTERNAL || errno != ERANGE)
{
__set_h_errno (herr);
-#ifndef __ARCH_USE_MMU__
- free(tmphstbuf);
-#endif
+ stack_heap_free(tmphstbuf);
herror(*ahost);
return -1;
}
@@ -194,17 +136,11 @@ int rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
{
/* Enlarge the buffer. */
hstbuflen *= 2;
-#ifdef __ARCH_USE_MMU__
- tmphstbuf = alloca (hstbuflen);
-#else
- free(tmphstbuf);
- tmphstbuf = malloc (hstbuflen);
-#endif
+ stack_heap_free(tmphstbuf);
+ tmphstbuf = stack_heap_alloc(hstbuflen);
}
}
-#ifndef __ARCH_USE_MMU__
- free(tmphstbuf);
-#endif
+ stack_heap_free(tmphstbuf);
#else /* call the non-reentrant version */
if ((hp = gethostbyname(*ahost)) == NULL) {
return -1;
@@ -214,7 +150,7 @@ int rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
pfd[1].events = POLLIN;
*ahost = hp->h_name;
- oldmask = sigblock(sigmask(SIGURG)); /* __sigblock */
+ oldmask = sigblock(__sigmask(SIGURG)); /* sigblock */
for (timo = 1, lport = IPPORT_RESERVED - 1;;) {
s = rresvport(&lport);
if (s < 0) {
@@ -372,9 +308,8 @@ libc_hidden_def(rresvport)
*/
int __check_rhosts_file = 1;
-int ruserok(rhost, superuser, ruser, luser)
- const char *rhost, *ruser, *luser;
- int superuser;
+int ruserok(const char *rhost, int superuser, const char *ruser,
+ const char *luser)
{
struct hostent *hp;
u_int32_t addr;
@@ -388,35 +323,23 @@ int ruserok(rhost, superuser, ruser, luser)
#ifdef __UCLIBC_HAS_REENTRANT_RPC__
buflen = 1024;
-#ifdef __ARCH_USE_MMU__
- buffer = alloca (buflen);
-#else
- buffer = malloc (buflen);
-#endif
+ buffer = stack_heap_alloc(buflen);
while (gethostbyname_r (rhost, &hostbuf, buffer,
buflen, &hp, &herr) != 0 || hp == NULL)
{
if (herr != NETDB_INTERNAL || errno != ERANGE) {
-#ifndef __ARCH_USE_MMU__
- free(buffer);
-#endif
+ stack_heap_free(buffer);
return -1;
} else
{
/* Enlarge the buffer. */
buflen *= 2;
-#ifdef __ARCH_USE_MMU__
- buffer = alloca (buflen);
-#else
- free(buffer);
- buffer = malloc (buflen);
-#endif
+ stack_heap_free(buffer);
+ buffer = stack_heap_alloc(buflen);
}
}
-#ifndef __ARCH_USE_MMU__
- free(buffer);
-#endif
+ stack_heap_free(buffer);
#else
if ((hp = gethostbyname(rhost)) == NULL) {
return -1;
@@ -483,10 +406,8 @@ iruserfopen (const char *file, uid_t okuser)
* Returns 0 if ok, -1 if not ok.
*/
static int
-iruserok2 (raddr, superuser, ruser, luser, rhost)
- u_int32_t raddr;
- int superuser;
- const char *ruser, *luser, *rhost;
+iruserok2 (u_int32_t raddr, int superuser, const char *ruser, const char *luser,
+ const char *rhost)
{
FILE *hostf = NULL;
int isbad = -1;
@@ -511,23 +432,15 @@ iruserok2 (raddr, superuser, ruser, luser, rhost)
#ifdef __UCLIBC_HAS_REENTRANT_RPC__
size_t buflen = sysconf (_SC_GETPW_R_SIZE_MAX);
struct passwd pwdbuf;
-#ifdef __ARCH_USE_MMU__
- char *buffer = alloca (buflen);
-#else
- char *buffer = malloc (buflen);
-#endif
+ char *buffer = stack_heap_alloc(buflen);
if (getpwnam_r (luser, &pwdbuf, buffer,
buflen, &pwd) != 0 || pwd == NULL)
{
-#ifndef __ARCH_USE_MMU__
- free(buffer);
-#endif
+ stack_heap_free(buffer);
return -1;
}
-#ifndef __ARCH_USE_MMU__
- free(buffer);
-#endif
+ stack_heap_free(buffer);
#else
if ((pwd = getpwnam(luser)) == NULL)
return -1;
@@ -700,10 +613,8 @@ __isempty(char *p)
* Returns 0 if positive match, -1 if _not_ ok.
*/
static int
-__ivaliduser2(hostf, raddr, luser, ruser, rhost)
- FILE *hostf;
- u_int32_t raddr;
- const char *luser, *ruser, *rhost;
+__ivaliduser2(FILE *hostf, u_int32_t raddr, const char *luser,
+ const char *ruser, const char *rhost)
{
register const char *user;
register char *p;
diff --git a/libc/inet/rpc/rexec.c b/libc/inet/rpc/rexec.c
index 2eb567ed2..e17be50b2 100644
--- a/libc/inet/rpc/rexec.c
+++ b/libc/inet/rpc/rexec.c
@@ -27,8 +27,6 @@
* SUCH DAMAGE.
*/
-#define __FORCE_GLIBC
-#include <features.h>
#include <sys/types.h>
#include <sys/socket.h>
@@ -41,35 +39,14 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-
-/* Experimentally off - libc_hidden_proto(memset) */
-/* Experimentally off - libc_hidden_proto(strlen) */
-/* Experimentally off - libc_hidden_proto(strncpy) */
-libc_hidden_proto(read)
-libc_hidden_proto(write)
-libc_hidden_proto(close)
-libc_hidden_proto(socket)
-libc_hidden_proto(perror)
-libc_hidden_proto(sprintf)
-libc_hidden_proto(snprintf)
-libc_hidden_proto(getsockname)
-libc_hidden_proto(getnameinfo)
-libc_hidden_proto(getaddrinfo)
-libc_hidden_proto(freeaddrinfo)
-libc_hidden_proto(sleep)
-libc_hidden_proto(atoi)
-libc_hidden_proto(connect)
-libc_hidden_proto(accept)
-libc_hidden_proto(listen)
-libc_hidden_proto(ruserpass)
+#include <malloc.h>
#define SA_LEN(_x) __libc_sa_len((_x)->sa_family)
-extern int __libc_sa_len (sa_family_t __af) __THROW attribute_hidden;
+extern int __libc_sa_len(sa_family_t __af) __THROW attribute_hidden;
-int rexecoptions;
-char ahostbuf[NI_MAXHOST] attribute_hidden;
+/* int rexecoptions; - google does not know it */
+static char *ahostbuf = NULL;
-libc_hidden_proto(rexec_af)
int
rexec_af(char **ahost, int rport, const char *name, const char *pass, const char *cmd, int *fd2p, sa_family_t af)
{
@@ -83,27 +60,33 @@ rexec_af(char **ahost, int rport, const char *name, const char *pass, const char
int gai;
char servbuff[NI_MAXSERV];
- snprintf(servbuff, sizeof(servbuff), "%d", ntohs(rport));
- servbuff[sizeof(servbuff) - 1] = '\0';
+ if (sizeof(servbuff) < sizeof(int)*3 + 2) {
+ snprintf(servbuff, sizeof(servbuff), "%d", ntohs(rport));
+ servbuff[sizeof(servbuff) - 1] = '\0';
+ } else {
+ sprintf(servbuff, "%d", ntohs(rport));
+ }
memset(&hints, '\0', sizeof(hints));
hints.ai_family = af;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_CANONNAME;
gai = getaddrinfo(*ahost, servbuff, &hints, &res0);
- if (gai){
+ if (gai) {
/* XXX: set errno? */
return -1;
}
- if (res0->ai_canonname){
- strncpy(ahostbuf, res0->ai_canonname, sizeof(ahostbuf));
- ahostbuf[sizeof(ahostbuf)-1] = '\0';
+ if (res0->ai_canonname) {
+ if (!ahostbuf)
+ ahostbuf = __uc_malloc(NI_MAXHOST);
+ strncpy(ahostbuf, res0->ai_canonname, NI_MAXHOST);
+ ahostbuf[NI_MAXHOST-1] = '\0';
*ahost = ahostbuf;
}
- else{
+ else {
*ahost = NULL;
- __set_errno (ENOENT);
+ __set_errno(ENOENT);
return -1;
}
ruserpass(res0->ai_canonname, &name, &pass);
@@ -111,7 +94,7 @@ retry:
s = socket(res0->ai_family, res0->ai_socktype, 0);
if (s < 0) {
perror("rexec: socket");
- return (-1);
+ return -1;
}
if (connect(s, res0->ai_addr, res0->ai_addrlen) < 0) {
if (errno == ECONNREFUSED && timo <= 16) {
@@ -121,7 +104,7 @@ retry:
goto retry;
}
perror(res0->ai_canonname);
- return (-1);
+ return -1;
}
if (fd2p == 0) {
(void) write(s, "", 1);
@@ -134,10 +117,10 @@ retry:
s2 = socket(res0->ai_family, res0->ai_socktype, 0);
if (s2 < 0) {
(void) close(s);
- return (-1);
+ return -1;
}
listen(s2, 1);
- sa2len = sizeof (sa2);
+ sa2len = sizeof(sa2);
if (getsockname(s2, (struct sockaddr *)&sa2, &sa2len) < 0) {
perror("getsockname");
(void) close(s2);
@@ -154,15 +137,16 @@ retry:
port = atoi(servbuff);
(void) sprintf(num, "%u", port);
(void) write(s, num, strlen(num)+1);
- { socklen_t len = sizeof (from);
- s3 = TEMP_FAILURE_RETRY (accept(s2, (struct sockaddr *)&from,
- &len));
- close(s2);
- if (s3 < 0) {
- perror("accept");
- port = 0;
- goto bad;
- }
+ {
+ socklen_t len = sizeof(from);
+ s3 = TEMP_FAILURE_RETRY(accept(s2,
+ (struct sockaddr *)&from, &len));
+ close(s2);
+ if (s3 < 0) {
+ perror("accept");
+ port = 0;
+ goto bad;
+ }
}
*fd2p = s3;
}
@@ -174,9 +158,9 @@ retry:
/* We don't need the memory allocated for the name and the password
in ruserpass anymore. */
if (name != orig_name)
- free ((char *) name);
+ free((char *) name);
if (pass != orig_pass)
- free ((char *) pass);
+ free((char *) pass);
if (read(s, &c, 1) != 1) {
perror(*ahost);
@@ -191,22 +175,19 @@ retry:
goto bad;
}
freeaddrinfo(res0);
- return (s);
+ return s;
bad:
if (port)
(void) close(*fd2p);
(void) close(s);
freeaddrinfo(res0);
- return (-1);
+ return -1;
}
libc_hidden_def(rexec_af)
int
-rexec(ahost, rport, name, pass, cmd, fd2p)
- char **ahost;
- int rport;
- const char *name, *pass, *cmd;
- int *fd2p;
+rexec(char **ahost, int rport, const char *name, const char *pass,
+ const char *cmd, int *fd2p)
{
return rexec_af(ahost, rport, name, pass, cmd, fd2p, AF_INET);
}
diff --git a/libc/inet/rpc/rpc_cmsg.c b/libc/inet/rpc/rpc_cmsg.c
index 3206aae55..06d042ecb 100644
--- a/libc/inet/rpc/rpc_cmsg.c
+++ b/libc/inet/rpc/rpc_cmsg.c
@@ -38,24 +38,14 @@ static char sccsid[] = "@(#)rpc_callmsg.c 1.4 87/08/11 Copyr 1984 Sun Micro";
*
*/
-#define __FORCE_GLIBC
-#include <features.h>
-
#include <string.h>
#include <sys/param.h>
#include <rpc/rpc.h>
-/* Experimentally off - libc_hidden_proto(memcpy) */
-libc_hidden_proto(xdr_enum)
-libc_hidden_proto(xdr_opaque)
-libc_hidden_proto(xdr_u_int)
-libc_hidden_proto(xdr_u_long)
-libc_hidden_proto(xdr_opaque_auth)
/*
* XDR a call message
*/
-libc_hidden_proto(xdr_callmsg)
bool_t
xdr_callmsg (XDR *xdrs, struct rpc_msg *cmsg)
{
diff --git a/libc/inet/rpc/rpc_dtablesize.c b/libc/inet/rpc/rpc_dtablesize.c
index 11a7ad457..45cab6212 100644
--- a/libc/inet/rpc/rpc_dtablesize.c
+++ b/libc/inet/rpc/rpc_dtablesize.c
@@ -31,20 +31,14 @@
static char sccsid[] = "@(#)rpc_dtablesize.c 1.2 87/08/11 Copyr 1987 Sun Micro";
#endif
-#define __FORCE_GLIBC
-#define __USE_BSD
-#include <features.h>
-
#include <unistd.h>
#include <rpc/clnt.h>
-libc_hidden_proto(getdtablesize)
/*
* Cache the result of getdtablesize(), so we don't have to do an
* expensive system call every time.
*/
-libc_hidden_proto(_rpc_dtablesize)
int
_rpc_dtablesize(void)
{
diff --git a/libc/inet/rpc/rpc_private.h b/libc/inet/rpc/rpc_private.h
index 15250059a..9e01df49a 100644
--- a/libc/inet/rpc/rpc_private.h
+++ b/libc/inet/rpc/rpc_private.h
@@ -1,10 +1,11 @@
-#ifndef _RPC_RPC_H
+#ifndef _RPC_PRIVATE_H
+#define _RPC_PRIVATE_H
#include <rpc/rpc.h>
+#include <libintl.h>
/* Now define the internal interfaces. */
extern u_long _create_xid (void) attribute_hidden;
-libc_hidden_proto(__rpc_thread_createerr)
/*
* Multi-threaded support
@@ -13,14 +14,13 @@ libc_hidden_proto(__rpc_thread_createerr)
*/
#ifdef __UCLIBC_HAS_THREADS__
#include <pthread.h>
+#include <bits/libc-lock.h>
struct rpc_thread_variables {
fd_set svc_fdset_s; /* Global, rpc_common.c */
struct rpc_createerr rpc_createerr_s; /* Global, rpc_common.c */
struct pollfd *svc_pollfd_s; /* Global, rpc_common.c */
int svc_max_pollfd_s; /* Global, rpc_common.c */
- void *authnone_private_s; /* auth_none.c */
-
void *clnt_perr_buf_s; /* clnt_perr.c */
void *clntraw_private_s; /* clnt_raw.c */
diff --git a/libc/inet/rpc/rpc_prot.c b/libc/inet/rpc/rpc_prot.c
index 74658e654..d43214d18 100644
--- a/libc/inet/rpc/rpc_prot.c
+++ b/libc/inet/rpc/rpc_prot.c
@@ -44,18 +44,10 @@ static char sccsid[] = "@(#)rpc_prot.c 1.36 87/08/11 Copyr 1984 Sun Micro";
* routines are also in this program.
*/
-#define __FORCE_GLIBC
-#include <features.h>
-
#include <sys/param.h>
#include <rpc/rpc.h>
-libc_hidden_proto(xdr_bytes)
-libc_hidden_proto(xdr_union)
-libc_hidden_proto(xdr_enum)
-libc_hidden_proto(xdr_opaque)
-libc_hidden_proto(xdr_u_long)
/* * * * * * * * * * * * * * XDR Authentication * * * * * * * * * * * */
@@ -63,7 +55,6 @@ libc_hidden_proto(xdr_u_long)
* XDR an opaque authentication struct
* (see auth.h)
*/
-libc_hidden_proto(xdr_opaque_auth)
bool_t
xdr_opaque_auth (XDR *xdrs, struct opaque_auth *ap)
{
@@ -89,7 +80,6 @@ xdr_des_block (XDR *xdrs, des_block *blkp)
/*
* XDR the MSG_ACCEPTED part of a reply message union
*/
-libc_hidden_proto(xdr_accepted_reply)
bool_t
xdr_accepted_reply (XDR *xdrs, struct accepted_reply *ar)
{
@@ -116,7 +106,6 @@ libc_hidden_def(xdr_accepted_reply)
/*
* XDR the MSG_DENIED part of a reply message union
*/
-libc_hidden_proto(xdr_rejected_reply)
bool_t
xdr_rejected_reply (XDR *xdrs, struct rejected_reply *rr)
{
@@ -146,7 +135,6 @@ static const struct xdr_discrim reply_dscrm[3] =
/*
* XDR a reply message
*/
-libc_hidden_proto(xdr_replymsg)
bool_t
xdr_replymsg (XDR *xdrs, struct rpc_msg *rmsg)
{
@@ -166,7 +154,6 @@ libc_hidden_def(xdr_replymsg)
* The fields include: rm_xid, rm_direction, rpcvers, prog, and vers.
* The rm_xid is not really static, but the user can easily munge on the fly.
*/
-libc_hidden_proto(xdr_callhdr)
bool_t
xdr_callhdr (XDR *xdrs, struct rpc_msg *cmsg)
{
@@ -229,7 +216,7 @@ rejected (enum reject_stat rjct_stat,
{
switch (rjct_stat)
{
- case RPC_VERSMISMATCH:
+ case RPC_MISMATCH:
error->re_status = RPC_VERSMISMATCH;
return;
case AUTH_ERROR:
@@ -247,7 +234,6 @@ rejected (enum reject_stat rjct_stat,
/*
* given a reply message, fills in the error
*/
-libc_hidden_proto(_seterr_reply)
void
_seterr_reply (struct rpc_msg *msg,
struct rpc_err *error)
diff --git a/libc/inet/rpc/rpc_thread.c b/libc/inet/rpc/rpc_thread.c
index 2c7b8c1ea..d8d753421 100644
--- a/libc/inet/rpc/rpc_thread.c
+++ b/libc/inet/rpc/rpc_thread.c
@@ -4,20 +4,15 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define __FORCE_GLIBC
-#include <features.h>
#include <stdio.h>
#include <assert.h>
#include "rpc_private.h"
-libc_hidden_proto(__rpc_thread_svc_fdset)
-libc_hidden_proto(__rpc_thread_createerr)
-libc_hidden_proto(__rpc_thread_svc_pollfd)
-libc_hidden_proto(__rpc_thread_svc_max_pollfd)
#ifdef __UCLIBC_HAS_THREADS__
#include <bits/libc-tsd.h>
+#include <bits/libc-lock.h>
/* Variable used in non-threaded applications or for the first thread. */
static struct rpc_thread_variables __libc_tsd_RPC_VARS_mem;
@@ -34,8 +29,7 @@ __rpc_thread_destroy (void)
if (tvp != NULL && tvp != &__libc_tsd_RPC_VARS_mem) {
__rpc_thread_svc_cleanup ();
__rpc_thread_clnt_cleanup ();
- //__rpc_thread_key_cleanup ();
- free (tvp->authnone_private_s);
+ /*__rpc_thread_key_cleanup (); */
free (tvp->clnt_perr_buf_s);
free (tvp->clntraw_private_s);
free (tvp->svcraw_private_s);
diff --git a/libc/inet/rpc/rtime.c b/libc/inet/rpc/rtime.c
index 6190868ad..02016bf82 100644
--- a/libc/inet/rpc/rtime.c
+++ b/libc/inet/rpc/rtime.c
@@ -43,9 +43,6 @@ static char sccsid[] = "@(#)rtime.c 2.2 88/08/10 4.0 RPCSRC; from 1.8 88/02/08 S
* what unix uses.
*/
-#define __FORCE_GLIBC
-#include <features.h>
-
#include <stdio.h>
#include <unistd.h>
#include <rpc/rpc.h>
@@ -58,14 +55,6 @@ static char sccsid[] = "@(#)rtime.c 2.2 88/08/10 4.0 RPCSRC; from 1.8 88/02/08 S
#include <errno.h>
#include <netinet/in.h>
-libc_hidden_proto(read)
-libc_hidden_proto(socket)
-libc_hidden_proto(close)
-libc_hidden_proto(connect)
-libc_hidden_proto(recvfrom)
-libc_hidden_proto(sendto)
-libc_hidden_proto(poll)
-libc_hidden_proto(rtime)
#define NYEARS (u_long)(1970 - 1900)
#define TOFFSET (u_long)(60*60*24*(365*NYEARS + (NYEARS/4)))
@@ -158,4 +147,3 @@ rtime (struct sockaddr_in *addrp, struct rpc_timeval *timep,
timep->tv_usec = 0;
return 0;
}
-libc_hidden_def (rtime)
diff --git a/libc/inet/rpc/ruserpass.c b/libc/inet/rpc/ruserpass.c
index ad6e703c4..9197763a3 100644
--- a/libc/inet/rpc/ruserpass.c
+++ b/libc/inet/rpc/ruserpass.c
@@ -27,8 +27,6 @@
* SUCH DAMAGE.
*/
-#define __FORCE_GLIBC
-#include <features.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -37,34 +35,14 @@
#include <errno.h>
#include <netdb.h>
#include <stdio.h>
-#include <stdio_ext.h>
+#ifdef __UCLIBC_HAS_THREADS__
+# include <stdio_ext.h>
+#endif
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <libintl.h>
-/* Experimentally off - libc_hidden_proto(strcat) */
-/* Experimentally off - libc_hidden_proto(strchr) */
-/* Experimentally off - libc_hidden_proto(strcmp) */
-/* Experimentally off - libc_hidden_proto(strcpy) */
-/* Experimentally off - libc_hidden_proto(strlen) */
-/* Experimentally off - libc_hidden_proto(strcasecmp) */
-/* Experimentally off - libc_hidden_proto(strncasecmp) */
-libc_hidden_proto(getenv)
-libc_hidden_proto(printf)
-libc_hidden_proto(fstat)
-libc_hidden_proto(__fsetlocking)
-libc_hidden_proto(getgid)
-libc_hidden_proto(getuid)
-libc_hidden_proto(getegid)
-libc_hidden_proto(geteuid)
-libc_hidden_proto(gethostname)
-libc_hidden_proto(fileno)
-libc_hidden_proto(fopen)
-libc_hidden_proto(fclose)
-libc_hidden_proto(getc_unlocked)
-libc_hidden_proto(__fgetc_unlocked)
-
-#define _(X) (X)
/* #include "ftp_var.h" */
static int token (void);
@@ -114,7 +92,6 @@ static const struct toktab {
/* ruserpass - remote password check.
This function also exists in glibc but is undocumented */
-libc_hidden_proto(ruserpass)
int ruserpass(const char *host, const char **aname, const char **apass)
{
char *hdir, *buf, *tmp;
@@ -308,7 +285,7 @@ bad:
libc_hidden_def(ruserpass)
static int
-token()
+token(void)
{
char *cp;
int c;
diff --git a/libc/inet/rpc/sa_len.c b/libc/inet/rpc/sa_len.c
index 3b37eba44..886fb3e34 100644
--- a/libc/inet/rpc/sa_len.c
+++ b/libc/inet/rpc/sa_len.c
@@ -12,17 +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/>. */
-#define __FORCE_GLIBC
-#include <features.h>
#include <sys/socket.h>
#include <netinet/in.h>
-#include <netipx/ipx.h>
#include <sys/un.h>
#if 0
+#include <netipx/ipx.h>
#include <netash/ash.h>
#include <netatalk/at.h>
#include <netax25/ax25.h>
@@ -52,10 +49,14 @@ int __libc_sa_len (sa_family_t af)
#endif
case AF_INET:
return sizeof (struct sockaddr_in);
+#ifdef __UCLIBC_HAS_IPV6__
case AF_INET6:
return sizeof (struct sockaddr_in6);
+#endif
+#if 0
case AF_IPX:
return sizeof (struct sockaddr_ipx);
+#endif
case AF_LOCAL:
return sizeof (struct sockaddr_un);
}
diff --git a/libc/inet/rpc/svc.c b/libc/inet/rpc/svc.c
index 253c06379..c3d55185b 100644
--- a/libc/inet/rpc/svc.c
+++ b/libc/inet/rpc/svc.c
@@ -36,26 +36,16 @@
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
-#define __FORCE_GLIBC
-#include <features.h>
-
#include <errno.h>
#include <unistd.h>
+#include <string.h>
#include "rpc_private.h"
#include <rpc/svc.h>
#include <rpc/pmap_clnt.h>
#include <sys/poll.h>
-/* Experimentally off - libc_hidden_proto(ffs) */
-libc_hidden_proto(pmap_set)
-libc_hidden_proto(pmap_unset)
-libc_hidden_proto(_authenticate)
-libc_hidden_proto(_rpc_dtablesize)
/* used by svc_[max_]pollfd */
-libc_hidden_proto(__rpc_thread_svc_pollfd)
-libc_hidden_proto(__rpc_thread_svc_max_pollfd)
/* used by svc_fdset */
-libc_hidden_proto(__rpc_thread_svc_fdset)
#ifdef __UCLIBC_HAS_THREADS__
#define xports (*(SVCXPRT ***)&RPC_THREAD_VARIABLE(svc_xports_s))
@@ -85,7 +75,6 @@ static struct svc_callout *svc_head;
/* *************** SVCXPRT related stuff **************** */
/* Activate a transport handle. */
-libc_hidden_proto(xprt_register)
void
xprt_register (SVCXPRT *xprt)
{
@@ -129,7 +118,6 @@ xprt_register (SVCXPRT *xprt)
libc_hidden_def(xprt_register)
/* De-activate a transport handle. */
-libc_hidden_proto(xprt_unregister)
void
xprt_unregister (SVCXPRT *xprt)
{
@@ -175,7 +163,6 @@ done:
/* Add a service program to the callout list.
The dispatch routine will be called when a rpc request for this
program number comes in. */
-libc_hidden_proto(svc_register)
bool_t
svc_register (SVCXPRT * xprt, rpcprog_t prog, rpcvers_t vers,
void (*dispatch) (struct svc_req *, SVCXPRT *),
@@ -210,7 +197,6 @@ pmap_it:
libc_hidden_def(svc_register)
/* Remove a service program from the callout list. */
-libc_hidden_proto(svc_unregister)
void
svc_unregister (rpcprog_t prog, rpcvers_t vers)
{
@@ -235,7 +221,6 @@ libc_hidden_def(svc_unregister)
/* ******************* REPLY GENERATION ROUTINES ************ */
/* Send a reply to an rpc request */
-libc_hidden_proto(svc_sendreply)
bool_t
svc_sendreply (register SVCXPRT *xprt, xdrproc_t xdr_results,
caddr_t xdr_location)
@@ -266,7 +251,6 @@ svcerr_noproc (register SVCXPRT *xprt)
}
/* Can't decode args error reply */
-libc_hidden_proto(svcerr_decode)
void
svcerr_decode (register SVCXPRT *xprt)
{
@@ -294,7 +278,6 @@ svcerr_systemerr (register SVCXPRT *xprt)
}
/* Authentication error reply */
-libc_hidden_proto(svcerr_auth)
void
svcerr_auth (SVCXPRT *xprt, enum auth_stat why)
{
@@ -316,7 +299,6 @@ svcerr_weakauth (SVCXPRT *xprt)
}
/* Program unavailable error reply */
-libc_hidden_proto(svcerr_noprog)
void
svcerr_noprog (register SVCXPRT *xprt)
{
@@ -331,7 +313,6 @@ svcerr_noprog (register SVCXPRT *xprt)
libc_hidden_def(svcerr_noprog)
/* Program version mismatch error reply */
-libc_hidden_proto(svcerr_progvers)
void
svcerr_progvers (register SVCXPRT *xprt, rpcvers_t low_vers,
rpcvers_t high_vers)
@@ -366,7 +347,6 @@ libc_hidden_def(svcerr_progvers)
* is mallocated in kernel land.
*/
-libc_hidden_proto(svc_getreq_common)
void
svc_getreq_common (const int fd)
{
@@ -458,7 +438,6 @@ svc_getreq_common (const int fd)
}
libc_hidden_def(svc_getreq_common)
-libc_hidden_proto(svc_getreqset)
void
svc_getreqset (fd_set *readfds)
{
@@ -469,6 +448,8 @@ svc_getreqset (fd_set *readfds)
register int bit;
setsize = _rpc_dtablesize ();
+ if (setsize > FD_SETSIZE)
+ setsize = FD_SETSIZE;
maskp = (u_int32_t *) readfds->fds_bits;
for (sock = 0; sock < setsize; sock += 32)
for (mask = *maskp++; (bit = ffs (mask)); mask ^= (1 << (bit - 1)))
@@ -476,7 +457,6 @@ svc_getreqset (fd_set *readfds)
}
libc_hidden_def(svc_getreqset)
-libc_hidden_proto(svc_getreq)
void
svc_getreq (int rdfds)
{
@@ -488,7 +468,6 @@ svc_getreq (int rdfds)
}
libc_hidden_def(svc_getreq)
-libc_hidden_proto(svc_getreq_poll)
void
svc_getreq_poll (struct pollfd *pfdp, int pollretval)
{
diff --git a/libc/inet/rpc/svc_auth.c b/libc/inet/rpc/svc_auth.c
index 1a5dcf0ca..c902b46d2 100644
--- a/libc/inet/rpc/svc_auth.c
+++ b/libc/inet/rpc/svc_auth.c
@@ -58,9 +58,9 @@ static char sccsid[] = "@(#)svc_auth.c 1.19 87/08/11 Copyr 1984 Sun Micro";
static enum auth_stat _svcauth_null (struct svc_req *, struct rpc_msg *);
/* no authentication */
-extern enum auth_stat _svcauth_unix (struct svc_req *, struct rpc_msg *);
+extern enum auth_stat _svcauth_unix (struct svc_req *, struct rpc_msg *) attribute_hidden;
/* unix style (uid, gids) */
-extern enum auth_stat _svcauth_short (struct svc_req *, struct rpc_msg *);
+extern enum auth_stat _svcauth_short (struct svc_req *, struct rpc_msg *) attribute_hidden;
/* short hand unix style */
#ifdef CONFIG_AUTH_DES
extern enum auth_stat _svcauth_des (struct svc_req *, struct rpc_msg *);
@@ -101,7 +101,6 @@ svcauthsw[] =
* There is an assumption that any flavour less than AUTH_NULL is
* invalid.
*/
-libc_hidden_proto(_authenticate)
enum auth_stat
_authenticate (register struct svc_req *rqst, struct rpc_msg *msg)
{
diff --git a/libc/inet/rpc/svc_authux.c b/libc/inet/rpc/svc_authux.c
index 64c911f93..ca1a645e4 100644
--- a/libc/inet/rpc/svc_authux.c
+++ b/libc/inet/rpc/svc_authux.c
@@ -38,18 +38,11 @@
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
-#define __FORCE_GLIBC
-#include <features.h>
-
#include <stdio.h>
#include <string.h>
#include <rpc/rpc.h>
#include <rpc/svc.h>
-/* Experimentally off - libc_hidden_proto(memcpy) */
-libc_hidden_proto(printf)
-libc_hidden_proto(xdrmem_create)
-libc_hidden_proto(xdr_authunix_parms)
/*
* Unix longhand authenticator
diff --git a/libc/inet/rpc/svc_raw.c b/libc/inet/rpc/svc_raw.c
index 0cdbbb89a..8156042fe 100644
--- a/libc/inet/rpc/svc_raw.c
+++ b/libc/inet/rpc/svc_raw.c
@@ -40,14 +40,9 @@ static char sccsid[] = "@(#)svc_raw.c 1.15 87/08/11 Copyr 1984 Sun Micro";
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
-#define __FORCE_GLIBC
-#include <features.h>
#include "rpc_private.h"
#include <rpc/svc.h>
-libc_hidden_proto(xdrmem_create)
-libc_hidden_proto(xdr_callmsg)
-libc_hidden_proto(xdr_replymsg)
/*
* This is the "network" that we will be moving data over
@@ -72,7 +67,7 @@ static bool_t svcraw_reply (SVCXPRT *, struct rpc_msg *);
static bool_t svcraw_freeargs (SVCXPRT *, xdrproc_t, caddr_t);
static void svcraw_destroy (SVCXPRT *);
-static struct xp_ops server_ops =
+static const struct xp_ops server_ops =
{
svcraw_recv,
svcraw_stat,
@@ -108,9 +103,7 @@ svcraw_stat (SVCXPRT *xprt attribute_unused)
}
static bool_t
-svcraw_recv (xprt, msg)
- SVCXPRT *xprt attribute_unused;
- struct rpc_msg *msg;
+svcraw_recv (SVCXPRT *xprt attribute_unused, struct rpc_msg *msg)
{
struct svcraw_private_s *srp = svcraw_private;
XDR *xdrs;
diff --git a/libc/inet/rpc/svc_run.c b/libc/inet/rpc/svc_run.c
index 50e5fcd79..f3e020951 100644
--- a/libc/inet/rpc/svc_run.c
+++ b/libc/inet/rpc/svc_run.c
@@ -31,20 +31,12 @@
* Wait for input, call server program.
*/
-#define __FORCE_GLIBC
-#include <features.h>
-
#include <errno.h>
#include <unistd.h>
#include <sys/poll.h>
-#include <rpc/rpc.h>
+#include "rpc_private.h"
-libc_hidden_proto(perror)
-libc_hidden_proto(svc_getreq_poll)
-libc_hidden_proto(poll)
/* used by svc_[max_]pollfd */
-libc_hidden_proto(__rpc_thread_svc_pollfd)
-libc_hidden_proto(__rpc_thread_svc_max_pollfd)
/* This function can be used as a signal handler to terminate the
server loop. */
diff --git a/libc/inet/rpc/svc_simple.c b/libc/inet/rpc/svc_simple.c
index 72c272aa7..c770938a1 100644
--- a/libc/inet/rpc/svc_simple.c
+++ b/libc/inet/rpc/svc_simple.c
@@ -38,9 +38,6 @@ static char sccsid[] = "@(#)svc_simple.c 1.18 87/08/11 Copyr 1984 Sun Micro";
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
-#define __FORCE_GLIBC
-#include <features.h>
-
#include <stdio.h>
#include <string.h>
#include <unistd.h>
@@ -49,25 +46,6 @@ static char sccsid[] = "@(#)svc_simple.c 1.18 87/08/11 Copyr 1984 Sun Micro";
#include <sys/socket.h>
#include <netdb.h>
-#ifdef USE_IN_LIBIO
-# include <wchar.h>
-# include <libio/iolibio.h>
-# define fputs(s, f) _IO_fputs (s, f)
-#endif
-
-/* Experimentally off - libc_hidden_proto(strdup) */
-/* Experimentally off - libc_hidden_proto(memset) */
-libc_hidden_proto(asprintf)
-libc_hidden_proto(fputs)
-libc_hidden_proto(write)
-libc_hidden_proto(exit)
-libc_hidden_proto(svc_sendreply)
-libc_hidden_proto(svc_register)
-libc_hidden_proto(svcerr_decode)
-libc_hidden_proto(svcudp_create)
-libc_hidden_proto(pmap_unset)
-libc_hidden_proto(xdr_void)
-
struct proglst_
{
char *(*p_progname) (char *);
@@ -139,12 +117,7 @@ registerrpc (u_long prognum, u_long versnum, u_long procnum,
return 0;
err_out:
-#ifdef USE_IN_LIBIO
- if (_IO_fwide (stderr, 0) > 0)
- (void) __fwprintf (stderr, L"%s", buf);
- else
-#endif
- (void) fputs (buf, stderr);
+ (void) fputs (buf, stderr);
free (buf);
return -1;
}
@@ -198,12 +171,7 @@ universal (struct svc_req *rqstp, SVCXPRT *transp_l)
return;
}
(void) asprintf (&buf, _("never registered prog %d\n"), prog);
-#ifdef USE_IN_LIBIO
- if (_IO_fwide (stderr, 0) > 0)
- __fwprintf (stderr, L"%s", buf);
- else
-#endif
- fputs (buf, stderr);
+ fputs (buf, stderr);
free (buf);
exit (1);
}
diff --git a/libc/inet/rpc/svc_tcp.c b/libc/inet/rpc/svc_tcp.c
index 5e4667940..f0acf35dc 100644
--- a/libc/inet/rpc/svc_tcp.c
+++ b/libc/inet/rpc/svc_tcp.c
@@ -41,49 +41,15 @@ static char sccsid[] = "@(#)svc_tcp.c 1.21 87/08/11 Copyr 1984 Sun Micro";
* and a record/tcp stream.
*/
-#define __FORCE_GLIBC
-#include <features.h>
-
#include <stdio.h>
#include <unistd.h>
#include <string.h>
-#include <rpc/rpc.h>
+#include "rpc_private.h"
#include <sys/socket.h>
#include <sys/poll.h>
#include <errno.h>
#include <stdlib.h>
-#ifdef USE_IN_LIBIO
-# include <wchar.h>
-# include <libio/iolibio.h>
-# define fputs(s, f) _IO_fputs (s, f)
-#endif
-
-/* Experimentally off - libc_hidden_proto(memset) */
-/* Experimentally off - libc_hidden_proto(memcpy) */
-libc_hidden_proto(socket)
-libc_hidden_proto(close)
-libc_hidden_proto(read)
-libc_hidden_proto(write)
-libc_hidden_proto(perror)
-libc_hidden_proto(xdrrec_create)
-libc_hidden_proto(xdrrec_endofrecord)
-libc_hidden_proto(xdrrec_skiprecord)
-libc_hidden_proto(xdrrec_eof)
-libc_hidden_proto(xdr_callmsg)
-libc_hidden_proto(xdr_replymsg)
-libc_hidden_proto(xprt_register)
-libc_hidden_proto(xprt_unregister)
-libc_hidden_proto(getsockname)
-libc_hidden_proto(bind)
-libc_hidden_proto(bindresvport)
-libc_hidden_proto(poll)
-libc_hidden_proto(accept)
-libc_hidden_proto(listen)
-libc_hidden_proto(fputs)
-libc_hidden_proto(fclose)
-libc_hidden_proto(abort)
-
/*
* Ops vector for TCP/IP based rpc service handle
*/
@@ -204,12 +170,7 @@ svctcp_create (int sock, u_int sendsize, u_int recvsize)
xprt = (SVCXPRT *) mem_alloc (sizeof (SVCXPRT));
if (r == NULL || xprt == NULL)
{
-#ifdef USE_IN_LIBIO
- if (_IO_fwide (stderr, 0) > 0)
- (void) __fwprintf (stderr, L"%s", _("svctcp_create: out of memory\n"));
- else
-#endif
- (void) fputs (_("svctcp_create: out of memory\n"), stderr);
+ (void) fputs (_("svctcp_create: out of memory\n"), stderr);
mem_free (r, sizeof (*r));
mem_free (xprt, sizeof (SVCXPRT));
return NULL;
@@ -249,13 +210,7 @@ makefd_xprt (int fd, u_int sendsize, u_int recvsize)
cd = (struct tcp_conn *) mem_alloc (sizeof (struct tcp_conn));
if (xprt == (SVCXPRT *) NULL || cd == NULL)
{
-#ifdef USE_IN_LIBIO
- if (_IO_fwide (stderr, 0) > 0)
- (void) __fwprintf (stderr, L"%s",
- _("svc_tcp: makefd_xprt: out of memory\n"));
- else
-#endif
- (void) fputs (_("svc_tcp: makefd_xprt: out of memory\n"), stderr);
+ (void) fputs (_("svc_tcp: makefd_xprt: out of memory\n"), stderr);
mem_free (xprt, sizeof (SVCXPRT));
mem_free (cd, sizeof (struct tcp_conn));
return NULL;
diff --git a/libc/inet/rpc/svc_udp.c b/libc/inet/rpc/svc_udp.c
index e2c97bdc5..456c6ded2 100644
--- a/libc/inet/rpc/svc_udp.c
+++ b/libc/inet/rpc/svc_udp.c
@@ -39,13 +39,10 @@ static char sccsid[] = "@(#)svc_udp.c 1.24 87/08/11 Copyr 1984 Sun Micro";
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
-#define __FORCE_GLIBC
-#include <features.h>
-
#include <stdio.h>
#include <unistd.h>
#include <string.h>
-#include <rpc/rpc.h>
+#include "rpc_private.h"
#include <sys/socket.h>
#include <errno.h>
@@ -53,35 +50,6 @@ static char sccsid[] = "@(#)svc_udp.c 1.24 87/08/11 Copyr 1984 Sun Micro";
#include <sys/uio.h>
#endif
-#ifdef USE_IN_LIBIO
-# include <wchar.h>
-# include <libio/iolibio.h>
-# define fputs(s, f) _IO_fputs (s, f)
-libc_hidden_proto(fwprintf)
-#endif
-
-/* Experimentally off - libc_hidden_proto(memcmp) */
-/* Experimentally off - libc_hidden_proto(memcpy) */
-/* Experimentally off - libc_hidden_proto(memset) */
-libc_hidden_proto(perror)
-libc_hidden_proto(socket)
-libc_hidden_proto(close)
-libc_hidden_proto(xprt_register)
-libc_hidden_proto(xprt_unregister)
-libc_hidden_proto(xdrmem_create)
-libc_hidden_proto(xdr_callmsg)
-libc_hidden_proto(xdr_replymsg)
-libc_hidden_proto(getsockname)
-libc_hidden_proto(setsockopt)
-libc_hidden_proto(bind)
-libc_hidden_proto(bindresvport)
-libc_hidden_proto(recvfrom)
-libc_hidden_proto(sendto)
-libc_hidden_proto(recvmsg)
-libc_hidden_proto(sendmsg)
-libc_hidden_proto(fputs)
-libc_hidden_proto(fprintf)
-
#define rpc_buffer(xprt) ((xprt)->xp_p1)
#ifndef MAX
#define MAX(a, b) ((a > b) ? a : b)
@@ -134,7 +102,6 @@ struct svcudp_data
* see (svc.h, xprt_register).
* The routines returns NULL if a problem occurred.
*/
-libc_hidden_proto(svcudp_bufcreate)
SVCXPRT *
svcudp_bufcreate (int sock, u_int sendsz, u_int recvsz)
{
@@ -174,12 +141,7 @@ svcudp_bufcreate (int sock, u_int sendsz, u_int recvsz)
buf = mem_alloc (((MAX (sendsz, recvsz) + 3) / 4) * 4);
if (xprt == NULL || su == NULL || buf == NULL)
{
-#ifdef USE_IN_LIBIO
- if (_IO_fwide (stderr, 0) > 0)
- (void) fwprintf (stderr, L"%s", _("svcudp_create: out of memory\n"));
- else
-#endif
- (void) fputs (_("svcudp_create: out of memory\n"), stderr);
+ (void) fputs (_("svcudp_create: out of memory\n"), stderr);
mem_free (xprt, sizeof (SVCXPRT));
mem_free (su, sizeof (*su));
mem_free (buf, ((MAX (sendsz, recvsz) + 3) / 4) * 4);
@@ -200,13 +162,7 @@ svcudp_bufcreate (int sock, u_int sendsz, u_int recvsz)
+ sizeof(struct cmsghdr) + sizeof (struct in_pktinfo))
> sizeof (xprt->xp_pad))
{
-# ifdef USE_IN_LIBIO
- if (_IO_fwide (stderr, 0) > 0)
- (void) fwprintf (stderr, L"%s",
- _("svcudp_create: xp_pad is too small for IP_PKTINFO\n"));
- else
-# endif
- (void) fputs (_("svcudp_create: xp_pad is too small for IP_PKTINFO\n"),
+ (void) fputs (_("svcudp_create: xp_pad is too small for IP_PKTINFO\n"),
stderr);
return NULL;
}
@@ -226,7 +182,6 @@ svcudp_bufcreate (int sock, u_int sendsz, u_int recvsz)
}
libc_hidden_def(svcudp_bufcreate)
-libc_hidden_proto(svcudp_create)
SVCXPRT *
svcudp_create (int sock)
{
@@ -236,17 +191,14 @@ svcudp_create (int sock)
libc_hidden_def(svcudp_create)
static enum xprt_stat
-svcudp_stat (xprt)
- SVCXPRT *xprt attribute_unused;
+svcudp_stat (SVCXPRT *xprt attribute_unused)
{
return XPRT_IDLE;
}
static bool_t
-svcudp_recv (xprt, msg)
- SVCXPRT *xprt;
- struct rpc_msg *msg;
+svcudp_recv (SVCXPRT *xprt, struct rpc_msg *msg)
{
struct svcudp_data *su = su_data (xprt);
XDR *xdrs = &(su->su_xdrs);
@@ -322,9 +274,7 @@ again:
}
static bool_t
-svcudp_reply (xprt, msg)
- SVCXPRT *xprt;
- struct rpc_msg *msg;
+svcudp_reply (SVCXPRT *xprt, struct rpc_msg *msg)
{
struct svcudp_data *su = su_data (xprt);
XDR *xdrs = &(su->su_xdrs);
@@ -368,20 +318,14 @@ svcudp_reply (xprt, msg)
}
static bool_t
-svcudp_getargs (xprt, xdr_args, args_ptr)
- SVCXPRT *xprt;
- xdrproc_t xdr_args;
- caddr_t args_ptr;
+svcudp_getargs (SVCXPRT *xprt, xdrproc_t xdr_args, caddr_t args_ptr)
{
return (*xdr_args) (&(su_data (xprt)->su_xdrs), args_ptr);
}
static bool_t
-svcudp_freeargs (xprt, xdr_args, args_ptr)
- SVCXPRT *xprt;
- xdrproc_t xdr_args;
- caddr_t args_ptr;
+svcudp_freeargs (SVCXPRT *xprt, xdrproc_t xdr_args, caddr_t args_ptr)
{
XDR *xdrs = &(su_data (xprt)->su_xdrs);
@@ -390,8 +334,7 @@ svcudp_freeargs (xprt, xdr_args, args_ptr)
}
static void
-svcudp_destroy (xprt)
- SVCXPRT *xprt;
+svcudp_destroy (SVCXPRT *xprt)
{
struct svcudp_data *su = su_data (xprt);
@@ -414,16 +357,8 @@ svcudp_destroy (xprt)
#define SPARSENESS 4 /* 75% sparse */
-#ifdef USE_IN_LIBIO
-# define CACHE_PERROR(msg) \
- if (_IO_fwide (stderr, 0) > 0) \
- (void) __fwprintf(stderr, L"%s\n", msg); \
- else \
- (void) fprintf(stderr, "%s\n", msg)
-#else
-# define CACHE_PERROR(msg) \
+#define CACHE_PERROR(msg) \
(void) fprintf(stderr,"%s\n", msg)
-#endif
#define ALLOC(type, size) \
(type *) mem_alloc((unsigned) (sizeof(type) * (size)))
@@ -597,11 +532,7 @@ cache_set (SVCXPRT *xprt, u_long replylen)
* return 1 if found, 0 if not found
*/
static int
-cache_get (xprt, msg, replyp, replylenp)
- SVCXPRT *xprt;
- struct rpc_msg *msg;
- char **replyp;
- u_long *replylenp;
+cache_get (SVCXPRT *xprt, struct rpc_msg *msg, char **replyp, u_long *replylenp)
{
u_int loc;
cache_ptr ent;
diff --git a/libc/inet/rpc/svc_unix.c b/libc/inet/rpc/svc_unix.c
index 2d7790450..7a09af6a1 100644
--- a/libc/inet/rpc/svc_unix.c
+++ b/libc/inet/rpc/svc_unix.c
@@ -37,13 +37,10 @@
* and a record/unix stream.
*/
-#define __FORCE_GLIBC
-#include <features.h>
-
#include <stdio.h>
#include <unistd.h>
#include <string.h>
-#include <rpc/rpc.h>
+#include "rpc_private.h"
#include <rpc/svc.h>
#include <sys/socket.h>
#include <sys/uio.h>
@@ -51,38 +48,6 @@
#include <errno.h>
#include <stdlib.h>
-#ifdef USE_IN_LIBIO
-# include <wchar.h>
-#endif
-
-/* Experimentally off - libc_hidden_proto(memcpy) */
-/* Experimentally off - libc_hidden_proto(memset) */
-/* Experimentally off - libc_hidden_proto(strlen) */
-libc_hidden_proto(socket)
-libc_hidden_proto(close)
-libc_hidden_proto(perror)
-libc_hidden_proto(getpid)
-libc_hidden_proto(xdrrec_create)
-libc_hidden_proto(xdrrec_endofrecord)
-libc_hidden_proto(xdrrec_skiprecord)
-libc_hidden_proto(xdrrec_eof)
-libc_hidden_proto(xdr_callmsg)
-libc_hidden_proto(xdr_replymsg)
-libc_hidden_proto(xprt_register)
-libc_hidden_proto(xprt_unregister)
-libc_hidden_proto(getegid)
-libc_hidden_proto(geteuid)
-libc_hidden_proto(getsockname)
-libc_hidden_proto(setsockopt)
-libc_hidden_proto(bind)
-libc_hidden_proto(recvmsg)
-libc_hidden_proto(sendmsg)
-libc_hidden_proto(poll)
-libc_hidden_proto(accept)
-libc_hidden_proto(listen)
-libc_hidden_proto(fputs)
-libc_hidden_proto(abort)
-
/*
* Ops vector for AF_UNIX based rpc service handle
*/
@@ -203,12 +168,7 @@ svcunix_create (int sock, u_int sendsize, u_int recvsize, char *path)
xprt = (SVCXPRT *) mem_alloc (sizeof (SVCXPRT));
if (r == NULL || xprt == NULL)
{
-#ifdef USE_IN_LIBIO
- if (_IO_fwide (stderr, 0) > 0)
- __fwprintf (stderr, L"%s", _("svcunix_create: out of memory\n"));
- else
-#endif
- fputs (_("svcunix_create: out of memory\n"), stderr);
+ fputs (_("svcunix_create: out of memory\n"), stderr);
mem_free (r, sizeof (*r));
mem_free (xprt, sizeof (SVCXPRT));
return NULL;
@@ -248,13 +208,7 @@ makefd_xprt (int fd, u_int sendsize, u_int recvsize)
cd = (struct unix_conn *) mem_alloc (sizeof (struct unix_conn));
if (xprt == (SVCXPRT *) NULL || cd == (struct unix_conn *) NULL)
{
-#ifdef USE_IN_LIBIO
- if (_IO_fwide (stderr, 0) > 0)
- (void) __fwprintf (stderr, L"%s",
- _("svc_unix: makefd_xprt: out of memory\n"));
- else
-#endif
- (void) fputs (_("svc_unix: makefd_xprt: out of memory\n"), stderr);
+ (void) fputs (_("svc_unix: makefd_xprt: out of memory\n"), stderr);
mem_free (xprt, sizeof (SVCXPRT));
mem_free (cd, sizeof (struct unix_conn));
return NULL;
diff --git a/libc/inet/rpc/xdr.c b/libc/inet/rpc/xdr.c
index 54e716176..57d7dbd40 100644
--- a/libc/inet/rpc/xdr.c
+++ b/libc/inet/rpc/xdr.c
@@ -41,24 +41,14 @@ static char sccsid[] = "@(#)xdr.c 1.35 87/08/12";
* xdr.
*/
-#define __FORCE_GLIBC
-#include <features.h>
-
#include <stdio.h>
#include <limits.h>
#include <string.h>
+#include <libintl.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
-#ifdef USE_IN_LIBIO
-# include <wchar.h>
-libc_hidden_proto(fwprintf)
-#endif
-
-/* Experimentally off - libc_hidden_proto(strlen) */
-libc_hidden_proto(fputs)
-
/*
* constants specific to the xdr "protocol"
*/
@@ -87,7 +77,6 @@ xdr_free (xdrproc_t proc, char *objp)
/*
* XDR nothing
*/
-libc_hidden_proto(xdr_void)
bool_t
xdr_void (void)
{
@@ -100,11 +89,9 @@ libc_hidden_def(xdr_void)
* The definition of xdr_long() is kept for backward
* compatibility. Instead xdr_int() should be used.
*/
-libc_hidden_proto(xdr_long)
bool_t
xdr_long (XDR *xdrs, long *lp)
{
-
if (xdrs->x_op == XDR_ENCODE
&& (sizeof (int32_t) == sizeof (long)
|| (int32_t) *lp == *lp))
@@ -123,7 +110,6 @@ libc_hidden_def(xdr_long)
/*
* XDR short integers
*/
-libc_hidden_proto(xdr_short)
bool_t
xdr_short (XDR *xdrs, short *sp)
{
@@ -153,7 +139,6 @@ libc_hidden_def(xdr_short)
/*
* XDR integers
*/
-libc_hidden_proto(xdr_int)
bool_t
xdr_int (XDR *xdrs, int *ip)
{
@@ -192,7 +177,6 @@ libc_hidden_def(xdr_int)
* The definition of xdr_u_long() is kept for backward
* compatibility. Instead xdr_u_int() should be used.
*/
-libc_hidden_proto(xdr_u_long)
bool_t
xdr_u_long (XDR *xdrs, u_long *ulp)
{
@@ -226,7 +210,6 @@ libc_hidden_def(xdr_u_long)
/*
* XDR unsigned integers
*/
-libc_hidden_proto(xdr_u_int)
bool_t
xdr_u_int (XDR *xdrs, u_int *up)
{
@@ -237,10 +220,10 @@ xdr_u_int (XDR *xdrs, u_int *up)
{
case XDR_ENCODE:
l = (u_long) * up;
- return XDR_PUTLONG (xdrs, &l);
+ return XDR_PUTLONG (xdrs, (long *) &l);
case XDR_DECODE:
- if (!XDR_GETLONG (xdrs, &l))
+ if (!XDR_GETLONG (xdrs, (long *) &l))
{
return FALSE;
}
@@ -263,24 +246,24 @@ libc_hidden_def(xdr_u_int)
* XDR hyper integers
* same as xdr_u_hyper - open coded to save a proc call!
*/
-libc_hidden_proto(xdr_hyper)
bool_t
xdr_hyper (XDR *xdrs, quad_t *llp)
{
long t1;
- unsigned long int t2;
+ unsigned long t2;
if (xdrs->x_op == XDR_ENCODE)
{
t1 = (long) ((*llp) >> 32);
t2 = (long) (*llp);
- return (XDR_PUTLONG(xdrs, &t1) && XDR_PUTLONG(xdrs, &t2));
+ return (XDR_PUTLONG(xdrs, &t1) && XDR_PUTLONG(xdrs, (long *) &t2));
}
if (xdrs->x_op == XDR_DECODE)
{
- if (!XDR_GETLONG(xdrs, &t1) || !XDR_GETLONG(xdrs, &t2))
+ if (!XDR_GETLONG(xdrs, &t1) || !XDR_GETLONG(xdrs, (long *) &t2))
return FALSE;
+ /* t2 must be unsigned for this to work */
*llp = ((quad_t) t1) << 32;
*llp |= t2;
return TRUE;
@@ -298,7 +281,6 @@ libc_hidden_def(xdr_hyper)
* XDR hyper integers
* same as xdr_hyper - open coded to save a proc call!
*/
-libc_hidden_proto(xdr_u_hyper)
bool_t
xdr_u_hyper (XDR *xdrs, u_quad_t *ullp)
{
@@ -309,12 +291,12 @@ xdr_u_hyper (XDR *xdrs, u_quad_t *ullp)
{
t1 = (unsigned long) ((*ullp) >> 32);
t2 = (unsigned long) (*ullp);
- return (XDR_PUTLONG(xdrs, &t1) && XDR_PUTLONG(xdrs, &t2));
+ return (XDR_PUTLONG(xdrs, (long *) &t1) && XDR_PUTLONG(xdrs, (long *) &t2));
}
if (xdrs->x_op == XDR_DECODE)
{
- if (!XDR_GETLONG(xdrs, &t1) || !XDR_GETLONG(xdrs, &t2))
+ if (!XDR_GETLONG(xdrs, (long *) &t1) || !XDR_GETLONG(xdrs, (long *) &t2))
return FALSE;
*ullp = ((u_quad_t) t1) << 32;
*ullp |= t2;
@@ -343,7 +325,6 @@ xdr_u_longlong_t (XDR *xdrs, u_quad_t *ullp)
/*
* XDR unsigned short integers
*/
-libc_hidden_proto(xdr_u_short)
bool_t
xdr_u_short (XDR *xdrs, u_short *usp)
{
@@ -353,10 +334,10 @@ xdr_u_short (XDR *xdrs, u_short *usp)
{
case XDR_ENCODE:
l = (u_long) * usp;
- return XDR_PUTLONG (xdrs, &l);
+ return XDR_PUTLONG (xdrs, (long *) &l);
case XDR_DECODE:
- if (!XDR_GETLONG (xdrs, &l))
+ if (!XDR_GETLONG (xdrs, (long *) &l))
{
return FALSE;
}
@@ -408,7 +389,6 @@ xdr_u_char (XDR *xdrs, u_char *cp)
/*
* XDR booleans
*/
-libc_hidden_proto(xdr_bool)
bool_t
xdr_bool (XDR *xdrs, bool_t *bp)
{
@@ -438,7 +418,6 @@ libc_hidden_def(xdr_bool)
/*
* XDR enumerations
*/
-libc_hidden_proto(xdr_enum)
bool_t
xdr_enum (XDR *xdrs, enum_t *ep)
{
@@ -492,7 +471,6 @@ libc_hidden_def(xdr_enum)
* Allows the specification of a fixed size sequence of opaque bytes.
* cp points to the opaque object and cnt gives the byte length.
*/
-libc_hidden_proto(xdr_opaque)
bool_t
xdr_opaque (XDR *xdrs, caddr_t cp, u_int cnt)
{
@@ -544,7 +522,6 @@ libc_hidden_def(xdr_opaque)
* *cpp is a pointer to the bytes, *sizep is the count.
* If *cpp is NULL maxsize bytes are allocated
*/
-libc_hidden_proto(xdr_bytes)
bool_t
xdr_bytes (XDR *xdrs, char **cpp, u_int *sizep, u_int maxsize)
{
@@ -580,12 +557,7 @@ xdr_bytes (XDR *xdrs, char **cpp, u_int *sizep, u_int maxsize)
}
if (sp == NULL)
{
-#ifdef USE_IN_LIBIO
- if (_IO_fwide (stderr, 0) > 0)
- (void) fwprintf (stderr, L"%s", _("xdr_bytes: out of memory\n"));
- else
-#endif
- (void) fputs (_("xdr_bytes: out of memory\n"), stderr);
+ (void) fputs (_("xdr_bytes: out of memory\n"), stderr);
return FALSE;
}
/* fall into ... */
@@ -609,9 +581,7 @@ libc_hidden_def(xdr_bytes)
* Implemented here due to commonality of the object.
*/
bool_t
-xdr_netobj (xdrs, np)
- XDR *xdrs;
- struct netobj *np;
+xdr_netobj (XDR *xdrs, struct netobj *np)
{
return xdr_bytes (xdrs, &np->n_bytes, &np->n_len, MAX_NETOBJ_SZ);
@@ -628,7 +598,6 @@ xdr_netobj (xdrs, np)
* routine may be called.
* If there is no specific or default routine an error is returned.
*/
-libc_hidden_proto(xdr_union)
bool_t
xdr_union (XDR *xdrs, enum_t *dscmp, char *unp, const struct xdr_discrim *choices, xdrproc_t dfault)
{
@@ -675,7 +644,6 @@ libc_hidden_def(xdr_union)
* storage is allocated. The last parameter is the max allowed length
* of the string as specified by a protocol.
*/
-libc_hidden_proto(xdr_string)
bool_t
xdr_string (XDR *xdrs, char **cpp, u_int maxsize)
{
@@ -726,13 +694,7 @@ xdr_string (XDR *xdrs, char **cpp, u_int maxsize)
*cpp = sp = (char *) mem_alloc (nodesize);
if (sp == NULL)
{
-#ifdef USE_IN_LIBIO
- if (_IO_fwide (stderr, 0) > 0)
- (void) fwprintf (stderr, L"%s",
- _("xdr_string: out of memory\n"));
- else
-#endif
- (void) fputs (_("xdr_string: out of memory\n"), stderr);
+ (void) fputs (_("xdr_string: out of memory\n"), stderr);
return FALSE;
}
sp[size] = 0;
@@ -755,9 +717,7 @@ libc_hidden_def(xdr_string)
* routines like clnt_call
*/
bool_t
-xdr_wrapstring (xdrs, cpp)
- XDR *xdrs;
- char **cpp;
+xdr_wrapstring (XDR *xdrs, char **cpp)
{
if (xdr_string (xdrs, cpp, LASTUNSIGNED))
{
diff --git a/libc/inet/rpc/xdr_array.c b/libc/inet/rpc/xdr_array.c
index a2299b683..25428aac3 100644
--- a/libc/inet/rpc/xdr_array.c
+++ b/libc/inet/rpc/xdr_array.c
@@ -40,27 +40,15 @@ static char sccsid[] = "@(#)xdr_array.c 1.10 87/08/11 Copyr 1984 Sun Micro";
* arrays. See xdr.h for more info on the interface to xdr.
*/
-#define __FORCE_GLIBC
-#include <features.h>
-
#include <stdio.h>
#include <string.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
#include <limits.h>
-
-#ifdef USE_IN_LIBIO
-# include <wchar.h>
-libc_hidden_proto(fwprintf)
-#endif
-
-/* Experimentally off - libc_hidden_proto(memset) */
-libc_hidden_proto(fputs)
-libc_hidden_proto(xdr_u_int)
+#include <libintl.h>
#define LASTUNSIGNED ((u_int)0-1)
-
/*
* XDR an array of arbitrary elements
* *addrp is a pointer to the array, *sizep is the number of elements.
@@ -68,7 +56,6 @@ libc_hidden_proto(xdr_u_int)
* elsize is the size (in bytes) of each element, and elproc is the
* xdr procedure to call to handle each element of the array.
*/
-libc_hidden_proto(xdr_array)
bool_t
xdr_array (XDR *xdrs, caddr_t *addrp, u_int *sizep, u_int maxsize, u_int elsize, xdrproc_t elproc)
{
@@ -107,13 +94,7 @@ xdr_array (XDR *xdrs, caddr_t *addrp, u_int *sizep, u_int maxsize, u_int elsize,
*addrp = target = mem_alloc (nodesize);
if (target == NULL)
{
-#ifdef USE_IN_LIBIO
- if (_IO_fwide (stderr, 0) > 0)
- (void) fwprintf (stderr, L"%s",
- _("xdr_array: out of memory\n"));
- else
-#endif
- (void) fputs (_("xdr_array: out of memory\n"), stderr);
+ (void) fputs (_("xdr_array: out of memory\n"), stderr);
return FALSE;
}
memset (target, 0, nodesize);
@@ -157,12 +138,8 @@ libc_hidden_def(xdr_array)
* > xdr_elem: routine to XDR each element
*/
bool_t
-xdr_vector (xdrs, basep, nelem, elemsize, xdr_elem)
- XDR *xdrs;
- char *basep;
- u_int nelem;
- u_int elemsize;
- xdrproc_t xdr_elem;
+xdr_vector (XDR *xdrs, char *basep, u_int nelem, u_int elemsize,
+ xdrproc_t xdr_elem)
{
u_int i;
char *elptr;
diff --git a/libc/inet/rpc/xdr_float.c b/libc/inet/rpc/xdr_float.c
index 03632c5ca..f8a2bb399 100644
--- a/libc/inet/rpc/xdr_float.c
+++ b/libc/inet/rpc/xdr_float.c
@@ -41,9 +41,6 @@ static char sccsid[] = "@(#)xdr_float.c 1.12 87/08/11 Copyr 1984 Sun Micro";
* xdr.
*/
-#define __FORCE_GLIBC
-#include <features.h>
-
#include <stdio.h>
#include <endian.h>
@@ -57,69 +54,12 @@ static char sccsid[] = "@(#)xdr_float.c 1.12 87/08/11 Copyr 1984 Sun Micro";
#define LSW (__FLOAT_WORD_ORDER == __BIG_ENDIAN)
-#ifdef vax
-
-/* What IEEE single precision floating point looks like on a Vax */
-struct ieee_single {
- unsigned int mantissa: 23;
- unsigned int exp : 8;
- unsigned int sign : 1;
-};
-
-/* Vax single precision floating point */
-struct vax_single {
- unsigned int mantissa1 : 7;
- unsigned int exp : 8;
- unsigned int sign : 1;
- unsigned int mantissa2 : 16;
-};
-
-#define VAX_SNG_BIAS 0x81
-#define IEEE_SNG_BIAS 0x7f
-
-static struct sgl_limits {
- struct vax_single s;
- struct ieee_single ieee;
-} sgl_limits[2] = {
- {{ 0x7f, 0xff, 0x0, 0xffff }, /* Max Vax */
- { 0x0, 0xff, 0x0 }}, /* Max IEEE */
- {{ 0x0, 0x0, 0x0, 0x0 }, /* Min Vax */
- { 0x0, 0x0, 0x0 }} /* Min IEEE */
-};
-#endif /* vax */
-
bool_t
-xdr_float(xdrs, fp)
- XDR *xdrs;
- float *fp;
+xdr_float(XDR *xdrs, float *fp)
{
-#ifdef vax
- struct ieee_single is;
- struct vax_single vs, *vsp;
- struct sgl_limits *lim;
- int i;
-#endif
switch (xdrs->x_op) {
case XDR_ENCODE:
-#ifdef vax
- vs = *((struct vax_single *)fp);
- for (i = 0, lim = sgl_limits;
- i < sizeof(sgl_limits)/sizeof(struct sgl_limits);
- i++, lim++) {
- if ((vs.mantissa2 == lim->s.mantissa2) &&
- (vs.exp == lim->s.exp) &&
- (vs.mantissa1 == lim->s.mantissa1)) {
- is = lim->ieee;
- goto shipit;
- }
- }
- is.exp = vs.exp - VAX_SNG_BIAS + IEEE_SNG_BIAS;
- is.mantissa = (vs.mantissa1 << 16) | vs.mantissa2;
- shipit:
- is.sign = vs.sign;
- return (XDR_PUTLONG(xdrs, (long *)&is));
-#else
if (sizeof(float) == sizeof(long))
return (XDR_PUTLONG(xdrs, (long *)fp));
else if (sizeof(float) == sizeof(int)) {
@@ -127,29 +67,8 @@ xdr_float(xdrs, fp)
return (XDR_PUTLONG(xdrs, &tmp));
}
break;
-#endif
case XDR_DECODE:
-#ifdef vax
- vsp = (struct vax_single *)fp;
- if (!XDR_GETLONG(xdrs, (long *)&is))
- return (FALSE);
- for (i = 0, lim = sgl_limits;
- i < sizeof(sgl_limits)/sizeof(struct sgl_limits);
- i++, lim++) {
- if ((is.exp == lim->ieee.exp) &&
- (is.mantissa == lim->ieee.mantissa)) {
- *vsp = lim->s;
- goto doneit;
- }
- }
- vsp->exp = is.exp - IEEE_SNG_BIAS + VAX_SNG_BIAS;
- vsp->mantissa2 = is.mantissa;
- vsp->mantissa1 = (is.mantissa >> 16);
- doneit:
- vsp->sign = is.sign;
- return (TRUE);
-#else
if (sizeof(float) == sizeof(long))
return (XDR_GETLONG(xdrs, (long *)fp));
else if (sizeof(float) == sizeof(int)) {
@@ -160,7 +79,6 @@ xdr_float(xdrs, fp)
}
}
break;
-#endif
case XDR_FREE:
return (TRUE);
@@ -168,84 +86,13 @@ xdr_float(xdrs, fp)
return (FALSE);
}
-/*
- * This routine works on Suns (Sky / 68000's) and Vaxen.
- */
-
-#ifdef vax
-/* What IEEE double precision floating point looks like on a Vax */
-struct ieee_double {
- unsigned int mantissa1 : 20;
- unsigned int exp : 11;
- unsigned int sign : 1;
- unsigned int mantissa2 : 32;
-};
-
-/* Vax double precision floating point */
-struct vax_double {
- unsigned int mantissa1 : 7;
- unsigned int exp : 8;
- unsigned int sign : 1;
- unsigned int mantissa2 : 16;
- unsigned int mantissa3 : 16;
- unsigned int mantissa4 : 16;
-};
-
-#define VAX_DBL_BIAS 0x81
-#define IEEE_DBL_BIAS 0x3ff
-#define MASK(nbits) ((1 << nbits) - 1)
-
-static struct dbl_limits {
- struct vax_double d;
- struct ieee_double ieee;
-} dbl_limits[2] = {
- {{ 0x7f, 0xff, 0x0, 0xffff, 0xffff, 0xffff }, /* Max Vax */
- { 0x0, 0x7ff, 0x0, 0x0 }}, /* Max IEEE */
- {{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, /* Min Vax */
- { 0x0, 0x0, 0x0, 0x0 }} /* Min IEEE */
-};
-
-#endif /* vax */
-
-
bool_t
-xdr_double(xdrs, dp)
- XDR *xdrs;
- double *dp;
+xdr_double(XDR *xdrs, double *dp)
{
-#ifdef vax
- struct ieee_double id;
- struct vax_double vd;
- register struct dbl_limits *lim;
- int i;
-#endif
switch (xdrs->x_op) {
case XDR_ENCODE:
-#ifdef vax
- vd = *((struct vax_double *)dp);
- for (i = 0, lim = dbl_limits;
- i < sizeof(dbl_limits)/sizeof(struct dbl_limits);
- i++, lim++) {
- if ((vd.mantissa4 == lim->d.mantissa4) &&
- (vd.mantissa3 == lim->d.mantissa3) &&
- (vd.mantissa2 == lim->d.mantissa2) &&
- (vd.mantissa1 == lim->d.mantissa1) &&
- (vd.exp == lim->d.exp)) {
- id = lim->ieee;
- goto shipit;
- }
- }
- id.exp = vd.exp - VAX_DBL_BIAS + IEEE_DBL_BIAS;
- id.mantissa1 = (vd.mantissa1 << 13) | (vd.mantissa2 >> 3);
- id.mantissa2 = ((vd.mantissa2 & MASK(3)) << 29) |
- (vd.mantissa3 << 13) |
- ((vd.mantissa4 >> 3) & MASK(13));
- shipit:
- id.sign = vd.sign;
- dp = (double *)&id;
-#endif
if (2*sizeof(long) == sizeof(double)) {
long *lp = (long *)dp;
return (XDR_PUTLONG(xdrs, lp+!LSW) &&
@@ -261,31 +108,6 @@ xdr_double(xdrs, dp)
break;
case XDR_DECODE:
-#ifdef vax
- lp = (long *)&id;
- if (!XDR_GETLONG(xdrs, lp++) || !XDR_GETLONG(xdrs, lp))
- return (FALSE);
- for (i = 0, lim = dbl_limits;
- i < sizeof(dbl_limits)/sizeof(struct dbl_limits);
- i++, lim++) {
- if ((id.mantissa2 == lim->ieee.mantissa2) &&
- (id.mantissa1 == lim->ieee.mantissa1) &&
- (id.exp == lim->ieee.exp)) {
- vd = lim->d;
- goto doneit;
- }
- }
- vd.exp = id.exp - IEEE_DBL_BIAS + VAX_DBL_BIAS;
- vd.mantissa1 = (id.mantissa1 >> 13);
- vd.mantissa2 = ((id.mantissa1 & MASK(13)) << 3) |
- (id.mantissa2 >> 29);
- vd.mantissa3 = (id.mantissa2 >> 13);
- vd.mantissa4 = (id.mantissa2 << 3);
- doneit:
- vd.sign = id.sign;
- *dp = *((double *)&vd);
- return (TRUE);
-#else
if (2*sizeof(long) == sizeof(double)) {
long *lp = (long *)dp;
return (XDR_GETLONG(xdrs, lp+!LSW) &&
@@ -301,7 +123,6 @@ xdr_double(xdrs, dp)
}
}
break;
-#endif
case XDR_FREE:
return (TRUE);
diff --git a/libc/inet/rpc/xdr_intXX_t.c b/libc/inet/rpc/xdr_intXX_t.c
index d36d1623b..0688b3fc3 100644
--- a/libc/inet/rpc/xdr_intXX_t.c
+++ b/libc/inet/rpc/xdr_intXX_t.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 <rpc/types.h>
#include <rpc/xdr.h>
@@ -34,9 +33,9 @@ xdr_int64_t (XDR *xdrs, int64_t *ip)
case XDR_ENCODE:
t1 = (int32_t) ((*ip) >> 32);
t2 = (int32_t) (*ip);
- return (XDR_PUTINT32(xdrs, &t1) && XDR_PUTINT32(xdrs, &t2));
+ return (XDR_PUTINT32(xdrs, &t1) && XDR_PUTINT32(xdrs, (int32_t *) &t2));
case XDR_DECODE:
- if (!XDR_GETINT32(xdrs, &t1) || !XDR_GETINT32(xdrs, &t2))
+ if (!XDR_GETINT32(xdrs, &t1) || !XDR_GETINT32(xdrs, (int32_t *) &t2))
return FALSE;
*ip = ((int64_t) t1) << 32;
*ip |= t2;
@@ -47,6 +46,7 @@ xdr_int64_t (XDR *xdrs, int64_t *ip)
return FALSE;
}
}
+strong_alias_untyped(xdr_int64_t,xdr_quad_t)
/* XDR 64bit unsigned integers */
bool_t
@@ -75,6 +75,7 @@ xdr_uint64_t (XDR *xdrs, uint64_t *uip)
return FALSE;
}
}
+strong_alias_untyped(xdr_uint64_t,xdr_u_quad_t)
/* XDR 32bit integers */
bool_t
diff --git a/libc/inet/rpc/xdr_mem.c b/libc/inet/rpc/xdr_mem.c
index b7410c404..6773b56e2 100644
--- a/libc/inet/rpc/xdr_mem.c
+++ b/libc/inet/rpc/xdr_mem.c
@@ -43,7 +43,6 @@
#include <limits.h>
#include <rpc/rpc.h>
-/* Experimentally off - libc_hidden_proto(memcpy) */
static bool_t xdrmem_getlong (XDR *, long *);
static bool_t xdrmem_putlong (XDR *, const long *);
@@ -74,14 +73,11 @@ static const struct xdr_ops xdrmem_ops =
* The procedure xdrmem_create initializes a stream descriptor for a
* memory buffer.
*/
-libc_hidden_proto(xdrmem_create)
void
xdrmem_create (XDR *xdrs, const caddr_t addr, u_int size, enum xdr_op op)
{
xdrs->x_op = op;
- /* We have to add the const since the `struct xdr_ops' in `struct XDR'
- is not `const'. */
- xdrs->x_ops = (struct xdr_ops *) &xdrmem_ops;
+ xdrs->x_ops = &xdrmem_ops;
xdrs->x_private = xdrs->x_base = addr;
xdrs->x_handy = size;
}
@@ -175,9 +171,7 @@ xdrmem_getpos (const XDR *xdrs)
* xdrs modified
*/
static bool_t
-xdrmem_setpos (xdrs, pos)
- XDR *xdrs;
- u_int pos;
+xdrmem_setpos (XDR *xdrs, u_int pos)
{
caddr_t newaddr = xdrs->x_base + pos;
caddr_t lastaddr = xdrs->x_private + xdrs->x_handy;
diff --git a/libc/inet/rpc/xdr_rec.c b/libc/inet/rpc/xdr_rec.c
index ac331c4d3..3ad7d7275 100644
--- a/libc/inet/rpc/xdr_rec.c
+++ b/libc/inet/rpc/xdr_rec.c
@@ -44,40 +44,32 @@
* The other 31 bits encode the byte length of the fragment.
*/
-#define __FORCE_GLIBC
-#include <features.h>
-
-
#include <stdio.h>
#include <string.h>
#include <unistd.h>
-#include <rpc/rpc.h>
-
-#ifdef USE_IN_LIBIO
-# include <wchar.h>
-# include <libio/iolibio.h>
-# define fputs(s, f) _IO_fputs (s, f)
-libc_hidden_proto(fwprintf)
-#endif
-
-/* Experimentally off - libc_hidden_proto(memcpy) */
-libc_hidden_proto(fputs)
-libc_hidden_proto(lseek)
+#include "rpc_private.h"
-static bool_t xdrrec_getlong (XDR *, long *);
-static bool_t xdrrec_putlong (XDR *, const long *);
static bool_t xdrrec_getbytes (XDR *, caddr_t, u_int);
static bool_t xdrrec_putbytes (XDR *, const char *, u_int);
+static bool_t xdrrec_getint32 (XDR *, int32_t *);
+static bool_t xdrrec_putint32 (XDR *, const int32_t *);
+#if ULONG_MAX != 0xffffffff
+static bool_t xdrrec_getlong (XDR *, long *);
+static bool_t xdrrec_putlong (XDR *, const long *);
+#endif
static u_int xdrrec_getpos (const XDR *);
static bool_t xdrrec_setpos (XDR *, u_int);
static int32_t *xdrrec_inline (XDR *, u_int);
static void xdrrec_destroy (XDR *);
-static bool_t xdrrec_getint32 (XDR *, int32_t *);
-static bool_t xdrrec_putint32 (XDR *, const int32_t *);
static const struct xdr_ops xdrrec_ops = {
+#if ULONG_MAX == 0xffffffff
+ (bool_t (*)(XDR *, long *)) xdrrec_getint32,
+ (bool_t (*)(XDR *, const long *)) xdrrec_putint32,
+#else
xdrrec_getlong,
xdrrec_putlong,
+#endif
xdrrec_getbytes,
xdrrec_putbytes,
xdrrec_getpos,
@@ -146,7 +138,6 @@ static bool_t get_input_bytes (RECSTREAM *, caddr_t, int) internal_function;
* write respectively. They are like the system
* calls expect that they take an opaque handle rather than an fd.
*/
-libc_hidden_proto(xdrrec_create)
void
xdrrec_create (XDR *xdrs, u_int sendsize,
u_int recvsize, caddr_t tcp_handle,
@@ -163,12 +154,7 @@ xdrrec_create (XDR *xdrs, u_int sendsize,
if (rstrm == NULL || buf == NULL)
{
-#ifdef USE_IN_LIBIO
- if (_IO_fwide (stderr, 0) > 0)
- (void) fwprintf (stderr, L"%s", _("xdrrec_create: out of memory\n"));
- else
-#endif
- (void) fputs (_("xdrrec_create: out of memory\n"), stderr);
+ (void) fputs (_("xdrrec_create: out of memory\n"), stderr);
mem_free (rstrm, sizeof (RECSTREAM));
mem_free (buf, sendsize + recvsize + BYTES_PER_XDR_UNIT);
/*
@@ -191,9 +177,7 @@ xdrrec_create (XDR *xdrs, u_int sendsize,
/*
* now the rest ...
*/
- /* We have to add the const since the `struct xdr_ops' in `struct XDR'
- is not `const'. */
- xdrs->x_ops = (struct xdr_ops *) &xdrrec_ops;
+ xdrs->x_ops = &xdrrec_ops;
xdrs->x_private = (caddr_t) rstrm;
rstrm->tcp_handle = tcp_handle;
rstrm->readit = readit;
@@ -218,35 +202,46 @@ libc_hidden_def(xdrrec_create)
*/
static bool_t
-xdrrec_getlong (XDR *xdrs, long *lp)
+xdrrec_getint32 (XDR *xdrs, int32_t *ip)
{
RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
- int32_t *buflp = (int32_t *) rstrm->in_finger;
+ int32_t *bufip = (int32_t *) rstrm->in_finger;
int32_t mylong;
/* first try the inline, fast case */
if (rstrm->fbtbc >= BYTES_PER_XDR_UNIT &&
- rstrm->in_boundry - (char *) buflp >= BYTES_PER_XDR_UNIT)
+ rstrm->in_boundry - (char *) bufip >= BYTES_PER_XDR_UNIT)
{
- *lp = (int32_t) ntohl (*buflp);
+ *ip = ntohl (*bufip);
rstrm->fbtbc -= BYTES_PER_XDR_UNIT;
rstrm->in_finger += BYTES_PER_XDR_UNIT;
}
else
{
- if (!xdrrec_getbytes (xdrs, (caddr_t) & mylong,
+ if (!xdrrec_getbytes (xdrs, (caddr_t) &mylong,
BYTES_PER_XDR_UNIT))
return FALSE;
- *lp = (int32_t) ntohl (mylong);
+ *ip = ntohl (mylong);
}
return TRUE;
}
+#if ULONG_MAX != 0xffffffff
static bool_t
-xdrrec_putlong (XDR *xdrs, const long *lp)
+xdrrec_getlong (XDR *xdrs, long *lp)
+{
+ int32_t v;
+ bool_t r = xdrrec_getint32 (xdrs, &v);
+ *lp = v;
+ return r;
+}
+#endif
+
+static bool_t
+xdrrec_putint32 (XDR *xdrs, const int32_t *ip)
{
RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
- int32_t *dest_lp = (int32_t *) rstrm->out_finger;
+ int32_t *dest_ip = (int32_t *) rstrm->out_finger;
if ((rstrm->out_finger += BYTES_PER_XDR_UNIT) > rstrm->out_boundry)
{
@@ -258,13 +253,22 @@ xdrrec_putlong (XDR *xdrs, const long *lp)
rstrm->frag_sent = TRUE;
if (!flush_out (rstrm, FALSE))
return FALSE;
- dest_lp = (int32_t *) rstrm->out_finger;
+ dest_ip = (int32_t *) rstrm->out_finger;
rstrm->out_finger += BYTES_PER_XDR_UNIT;
}
- *dest_lp = htonl (*lp);
+ *dest_ip = htonl (*ip);
return TRUE;
}
+#if ULONG_MAX != 0xffffffff
+static bool_t
+xdrrec_putlong (XDR *xdrs, const long *lp)
+{
+ int32_t v = *lp;
+ return xdrrec_putint32 (xdrs, &v);
+}
+#endif
+
static bool_t /* must manage buffers, fragments, and records */
xdrrec_getbytes (XDR *xdrs, caddr_t addr, u_int len)
{
@@ -425,54 +429,6 @@ xdrrec_destroy (XDR *xdrs)
mem_free ((caddr_t) rstrm, sizeof (RECSTREAM));
}
-static bool_t
-xdrrec_getint32 (XDR *xdrs, int32_t *ip)
-{
- RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
- int32_t *bufip = (int32_t *) rstrm->in_finger;
- int32_t mylong;
-
- /* first try the inline, fast case */
- if (rstrm->fbtbc >= BYTES_PER_XDR_UNIT &&
- rstrm->in_boundry - (char *) bufip >= BYTES_PER_XDR_UNIT)
- {
- *ip = ntohl (*bufip);
- rstrm->fbtbc -= BYTES_PER_XDR_UNIT;
- rstrm->in_finger += BYTES_PER_XDR_UNIT;
- }
- else
- {
- if (!xdrrec_getbytes (xdrs, (caddr_t) &mylong,
- BYTES_PER_XDR_UNIT))
- return FALSE;
- *ip = ntohl (mylong);
- }
- return TRUE;
-}
-
-static bool_t
-xdrrec_putint32 (XDR *xdrs, const int32_t *ip)
-{
- RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
- int32_t *dest_ip = (int32_t *) rstrm->out_finger;
-
- if ((rstrm->out_finger += BYTES_PER_XDR_UNIT) > rstrm->out_boundry)
- {
- /*
- * this case should almost never happen so the code is
- * inefficient
- */
- rstrm->out_finger -= BYTES_PER_XDR_UNIT;
- rstrm->frag_sent = TRUE;
- if (!flush_out (rstrm, FALSE))
- return FALSE;
- dest_ip = (int32_t *) rstrm->out_finger;
- rstrm->out_finger += BYTES_PER_XDR_UNIT;
- }
- *dest_ip = htonl (*ip);
- return TRUE;
-}
-
/*
* Exported routines to manage xdr records
*/
@@ -481,7 +437,6 @@ xdrrec_putint32 (XDR *xdrs, const int32_t *ip)
* Before reading (deserializing from the stream, one should always call
* this procedure to guarantee proper record alignment.
*/
-libc_hidden_proto(xdrrec_skiprecord)
bool_t
xdrrec_skiprecord (XDR *xdrs)
{
@@ -505,7 +460,6 @@ libc_hidden_def(xdrrec_skiprecord)
* Returns TRUE iff there is no more input in the buffer
* after consuming the rest of the current record.
*/
-libc_hidden_proto(xdrrec_eof)
bool_t
xdrrec_eof (XDR *xdrs)
{
@@ -531,7 +485,6 @@ libc_hidden_def(xdrrec_eof)
* (output) tcp stream. (This lets the package support batched or
* pipelined procedure calls.) TRUE => immediate flush to tcp connection.
*/
-libc_hidden_proto(xdrrec_endofrecord)
bool_t
xdrrec_endofrecord (XDR *xdrs, bool_t sendnow)
{
diff --git a/libc/inet/rpc/xdr_reference.c b/libc/inet/rpc/xdr_reference.c
index 6282f9cb1..85765886b 100644
--- a/libc/inet/rpc/xdr_reference.c
+++ b/libc/inet/rpc/xdr_reference.c
@@ -40,24 +40,11 @@ static char sccsid[] = "@(#)xdr_reference.c 1.11 87/08/11 SMI";
* "pointers". See xdr.h for more info on the interface to xdr.
*/
-#define __FORCE_GLIBC
-#include <features.h>
-
#include <stdio.h>
#include <string.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
-
-#ifdef USE_IN_LIBIO
-# include <wchar.h>
-# include <libio/iolibio.h>
-# define fputs(s, f) _IO_fputs (s, f)
-libc_hidden_proto(fwprintf)
-#endif
-
-/* Experimentally off - libc_hidden_proto(memset) */
-libc_hidden_proto(xdr_bool)
-libc_hidden_proto(fputs)
+#include <libintl.h>
#define LASTUNSIGNED ((u_int)0-1)
@@ -70,7 +57,6 @@ libc_hidden_proto(fputs)
* size is the size of the referneced structure.
* proc is the routine to handle the referenced structure.
*/
-libc_hidden_proto(xdr_reference)
bool_t
xdr_reference (XDR *xdrs, caddr_t *pp, u_int size, xdrproc_t proc)
{
@@ -87,13 +73,7 @@ xdr_reference (XDR *xdrs, caddr_t *pp, u_int size, xdrproc_t proc)
*pp = loc = (caddr_t) mem_alloc (size);
if (loc == NULL)
{
-#ifdef USE_IN_LIBIO
- if (_IO_fwide (stderr, 0) > 0)
- (void) fwprintf (stderr, L"%s",
- _("xdr_reference: out of memory\n"));
- else
-#endif
- (void) fputs (_("xdr_reference: out of memory\n"), stderr);
+ (void) fputs (_("xdr_reference: out of memory\n"), stderr);
return FALSE;
}
memset (loc, 0, (int) size);
@@ -133,11 +113,7 @@ libc_hidden_def(xdr_reference)
*
*/
bool_t
-xdr_pointer (xdrs, objpp, obj_size, xdr_obj)
- XDR *xdrs;
- char **objpp;
- u_int obj_size;
- xdrproc_t xdr_obj;
+xdr_pointer (XDR *xdrs, char **objpp, u_int obj_size, xdrproc_t xdr_obj)
{
bool_t more_data;
diff --git a/libc/inet/rpc/xdr_stdio.c b/libc/inet/rpc/xdr_stdio.c
index 32689e132..6a18fce08 100644
--- a/libc/inet/rpc/xdr_stdio.c
+++ b/libc/inet/rpc/xdr_stdio.c
@@ -41,20 +41,6 @@
#include <stdio.h>
#include <rpc/xdr.h>
-#ifdef USE_IN_LIBIO
-# include <libio/iolibio.h>
-# define fflush(s) _IO_fflush (s)
-# define fread(p, m, n, s) _IO_fread (p, m, n, s)
-# define ftell(s) _IO_ftell (s)
-# define fwrite(p, m, n, s) _IO_fwrite (p, m, n, s)
-#endif
-
-libc_hidden_proto(fread)
-libc_hidden_proto(fwrite)
-libc_hidden_proto(fseek)
-libc_hidden_proto(fflush)
-libc_hidden_proto(ftell)
-
static bool_t xdrstdio_getlong (XDR *, long *);
static bool_t xdrstdio_putlong (XDR *, const long *);
static bool_t xdrstdio_getbytes (XDR *, caddr_t, u_int);
@@ -92,9 +78,7 @@ void
xdrstdio_create (XDR *xdrs, FILE *file, enum xdr_op op)
{
xdrs->x_op = op;
- /* We have to add the const since the `struct xdr_ops' in `struct XDR'
- is not `const'. */
- xdrs->x_ops = (struct xdr_ops *) &xdrstdio_ops;
+ xdrs->x_ops = &xdrstdio_ops;
xdrs->x_private = (caddr_t) file;
xdrs->x_handy = 0;
xdrs->x_base = 0;
diff --git a/libc/inet/socketcalls.c b/libc/inet/socketcalls.c
index ca93f6a18..1fef8100b 100644
--- a/libc/inet/socketcalls.c
+++ b/libc/inet/socketcalls.c
@@ -4,15 +4,12 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define __FORCE_GLIBC
-#include <features.h>
-#include <errno.h>
-#include <syscall.h>
+#include <stddef.h>
+#include <sys/syscall.h>
#include <sys/socket.h>
+#include <cancel.h>
#ifdef __NR_socketcall
-extern int __socketcall(int call, unsigned long *args) attribute_hidden;
-
/* Various socketcall numbers */
#define SYS_SOCKET 1
#define SYS_BIND 2
@@ -31,110 +28,167 @@ extern int __socketcall(int call, unsigned long *args) attribute_hidden;
#define SYS_GETSOCKOPT 15
#define SYS_SENDMSG 16
#define SYS_RECVMSG 17
+#define SYS_ACCEPT4 18
+#endif
+
+/* exposed on x86 since Linux commit 9dea5dc921b5f4045a18c63eb92e84dc274d17eb */
+#if defined(__sparc__) || defined(__i386__)
+#undef __NR_accept
+#undef __NR_accept4
+#undef __NR_bind
+#undef __NR_connect
+#undef __NR_getpeername
+#undef __NR_getsockname
+#undef __NR_getsockopt
+#undef __NR_listen
+#undef __NR_recv
+#undef __NR_recvfrom
+#undef __NR_recvmsg
+#undef __NR_send
+#undef __NR_sendmsg
+#undef __NR_sendto
+#undef __NR_setsockopt
+#undef __NR_shutdown
+#undef __NR_socket
+#undef __NR_socketpair
#endif
-
#ifdef L_accept
-extern __typeof(accept) __libc_accept;
-#ifdef __NR_accept
-#define __NR___libc_accept __NR_accept
-_syscall3(int, __libc_accept, int, call, struct sockaddr *, addr, socklen_t *,addrlen);
-#elif defined(__NR_socketcall)
-int __libc_accept(int s, struct sockaddr *addr, socklen_t * addrlen)
+static int __NC(accept)(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
{
+# ifdef __NR_accept
+ return INLINE_SYSCALL(accept, 3, sockfd, addr, addrlen);
+# else
unsigned long args[3];
- args[0] = s;
+ args[0] = sockfd;
args[1] = (unsigned long) addr;
args[2] = (unsigned long) addrlen;
+
return __socketcall(SYS_ACCEPT, args);
+# endif
+}
+CANCELLABLE_SYSCALL(int, accept, (int sockfd, struct sockaddr *addr, socklen_t *addrlen),
+ (sockfd, addr, addrlen))
+lt_libc_hidden(accept)
+#endif
+
+#ifdef L_accept4
+#ifdef __NR_accept4
+# define __NR___sys_accept4 __NR_accept4
+static _syscall4(int, __sys_accept4, int, fd, struct sockaddr *, addr, socklen_t *, addrlen, int, flags)
+int accept4(int fd, struct sockaddr *addr, socklen_t * addrlen, int flags)
+{
+ if (SINGLE_THREAD_P)
+ return __sys_accept4(fd, addr, addrlen, flags);
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ else {
+ int oldtype = LIBC_CANCEL_ASYNC ();
+ int result = __sys_accept4(fd, addr, addrlen, flags);
+ LIBC_CANCEL_RESET (oldtype);
+ return result;
+ }
+#endif
+}
+#elif defined(__NR_socketcall)
+int accept4(int fd, struct sockaddr *addr, socklen_t *addrlen, int flags)
+{
+ unsigned long args[4];
+
+ args[0] = fd;
+ args[1] = (unsigned long) addr;
+ args[2] = (unsigned long) addrlen;
+ args[3] = flags;
+ if (SINGLE_THREAD_P)
+ return __socketcall(SYS_ACCEPT4, args);
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ else {
+ int oldtype = LIBC_CANCEL_ASYNC ();
+ int result = __socketcall(SYS_ACCEPT4, args);
+ LIBC_CANCEL_RESET (oldtype);
+ return result;
+ }
+#endif
}
#endif
-libc_hidden_proto(accept)
-weak_alias(__libc_accept,accept)
-libc_hidden_weak(accept)
#endif
#ifdef L_bind
-libc_hidden_proto(bind)
-#ifdef __NR_bind
-_syscall3(int, bind, int, sockfd, const struct sockaddr *, myaddr, socklen_t, addrlen);
-#elif defined(__NR_socketcall)
int bind(int sockfd, const struct sockaddr *myaddr, socklen_t addrlen)
{
+# ifdef __NR_bind
+ return INLINE_SYSCALL(bind, 3, sockfd, myaddr, addrlen);
+# else
unsigned long args[3];
args[0] = sockfd;
args[1] = (unsigned long) myaddr;
args[2] = addrlen;
return __socketcall(SYS_BIND, args);
+# endif
}
-#endif
libc_hidden_def(bind)
#endif
#ifdef L_connect
-extern __typeof(connect) __libc_connect;
-#ifdef __NR_connect
-#define __NR___libc_connect __NR_connect
-_syscall3(int, __libc_connect, int, sockfd, const struct sockaddr *, saddr, socklen_t, addrlen);
-#elif defined(__NR_socketcall)
-int __libc_connect(int sockfd, const struct sockaddr *saddr, socklen_t addrlen)
+static int __NC(connect)(int sockfd, const struct sockaddr *saddr, socklen_t addrlen)
{
+# ifdef __NR_connect
+ return INLINE_SYSCALL(connect, 3, sockfd, saddr, addrlen);
+# else
unsigned long args[3];
args[0] = sockfd;
args[1] = (unsigned long) saddr;
args[2] = addrlen;
return __socketcall(SYS_CONNECT, args);
+# endif
}
-#endif
-libc_hidden_proto(connect)
-weak_alias(__libc_connect,connect)
-libc_hidden_weak(connect)
+CANCELLABLE_SYSCALL(int, connect, (int sockfd, const struct sockaddr *saddr, socklen_t addrlen),
+ (sockfd, saddr, addrlen))
+lt_libc_hidden(connect)
#endif
#ifdef L_getpeername
-#ifdef __NR_getpeername
-_syscall3(int, getpeername, int, sockfd, struct sockaddr *, addr, socklen_t *,paddrlen);
-#elif defined(__NR_socketcall)
-int getpeername(int sockfd, struct sockaddr *addr, socklen_t * paddrlen)
+int getpeername(int sockfd, struct sockaddr *addr, socklen_t *paddrlen)
{
+# ifdef __NR_getpeername
+ return INLINE_SYSCALL(getpeername, 3, sockfd, addr, paddrlen);
+# else
unsigned long args[3];
args[0] = sockfd;
args[1] = (unsigned long) addr;
args[2] = (unsigned long) paddrlen;
return __socketcall(SYS_GETPEERNAME, args);
+# endif
}
#endif
-#endif
#ifdef L_getsockname
-libc_hidden_proto(getsockname)
-#ifdef __NR_getsockname
-_syscall3(int, getsockname, int, sockfd, struct sockaddr *, addr, socklen_t *,paddrlen);
-#elif defined(__NR_socketcall)
int getsockname(int sockfd, struct sockaddr *addr, socklen_t * paddrlen)
{
+# ifdef __NR_getsockname
+ return INLINE_SYSCALL(getsockname, 3, sockfd, addr, paddrlen);
+# else
unsigned long args[3];
args[0] = sockfd;
args[1] = (unsigned long) addr;
args[2] = (unsigned long) paddrlen;
return __socketcall(SYS_GETSOCKNAME, args);
+# endif
}
-#endif
libc_hidden_def(getsockname)
#endif
#ifdef L_getsockopt
-#ifdef __NR_getsockopt
-_syscall5(int, getsockopt, int, fd, int, level, int, optname, __ptr_t, optval, socklen_t *, optlen);
-#elif defined(__NR_socketcall)
-int getsockopt(int fd, int level, int optname, __ptr_t optval,
- socklen_t * optlen)
+int getsockopt(int fd, int level, int optname, void *optval,
+ socklen_t *optlen)
{
+# ifdef __NR_getsockopt
+ return INLINE_SYSCALL(getsockopt, 5, fd, level, optname, optval, optlen);
+# else
unsigned long args[5];
args[0] = fd;
@@ -143,68 +197,56 @@ int getsockopt(int fd, int level, int optname, __ptr_t optval,
args[3] = (unsigned long) optval;
args[4] = (unsigned long) optlen;
return (__socketcall(SYS_GETSOCKOPT, args));
+# endif
}
#endif
-#endif
#ifdef L_listen
-libc_hidden_proto(listen)
-#ifdef __NR_listen
-_syscall2(int, listen, int, sockfd, int, backlog);
-#elif defined(__NR_socketcall)
int listen(int sockfd, int backlog)
{
+# ifdef __NR_listen
+ return INLINE_SYSCALL(listen, 2, sockfd, backlog);
+# else
unsigned long args[2];
args[0] = sockfd;
args[1] = backlog;
return __socketcall(SYS_LISTEN, args);
+# endif
}
-#endif
libc_hidden_def(listen)
#endif
#ifdef L_recv
-extern __typeof(recv) __libc_recv;
-#ifdef __NR_recv
-#define __NR___libc_recv __NR_recv
-_syscall4(ssize_t, __libc_recv, int, sockfd, __ptr_t, buffer, size_t, len,
- int, flags);
-#elif defined(__NR_socketcall)
-/* recv, recvfrom added by bir7@leland.stanford.edu */
-ssize_t __libc_recv(int sockfd, __ptr_t buffer, size_t len, int flags)
+static ssize_t __NC(recv)(int sockfd, void *buffer, size_t len, int flags)
{
+# ifdef __NR_recv
+ return (ssize_t)INLINE_SYSCALL(recv, 4, sockfd, buffer, len, flags);
+# elif defined __NR_recvfrom && defined _syscall6
+ return __NC(recvfrom)(sockfd, buffer, len, flags, NULL, NULL);
+# else
unsigned long args[4];
args[0] = sockfd;
args[1] = (unsigned long) buffer;
args[2] = len;
args[3] = flags;
- return (__socketcall(SYS_RECV, args));
-}
-#elif defined(__NR_recvfrom)
-libc_hidden_proto(recvfrom)
-ssize_t __libc_recv(int sockfd, __ptr_t buffer, size_t len, int flags)
-{
- return (recvfrom(sockfd, buffer, len, flags, NULL, NULL));
+ return (ssize_t)__socketcall(SYS_RECV, args);
+# endif
}
-#endif
-libc_hidden_proto(recv)
-weak_alias(__libc_recv,recv)
-libc_hidden_weak(recv)
+CANCELLABLE_SYSCALL(ssize_t, recv, (int sockfd, void *buffer, size_t len, int flags),
+ (sockfd, buffer, len, flags))
+lt_libc_hidden(recv)
#endif
#ifdef L_recvfrom
-extern __typeof(recvfrom) __libc_recvfrom;
-#ifdef __NR_recvfrom
-#define __NR___libc_recvfrom __NR_recvfrom
-_syscall6(ssize_t, __libc_recvfrom, int, sockfd, __ptr_t, buffer, size_t, len,
- int, flags, struct sockaddr *, to, socklen_t *, tolen);
-#elif defined(__NR_socketcall)
-/* recv, recvfrom added by bir7@leland.stanford.edu */
-ssize_t __libc_recvfrom(int sockfd, __ptr_t buffer, size_t len, int flags,
- struct sockaddr *to, socklen_t * tolen)
+ssize_t __NC(recvfrom)(int sockfd, void *buffer, size_t len, int flags,
+ struct sockaddr *to, socklen_t *tolen)
{
+# if defined __NR_recvfrom && defined _syscall6
+ return (ssize_t)INLINE_SYSCALL(recvfrom, 6, sockfd, buffer, len,
+ flags, to, tolen);
+# else
unsigned long args[6];
args[0] = sockfd;
@@ -213,96 +255,82 @@ ssize_t __libc_recvfrom(int sockfd, __ptr_t buffer, size_t len, int flags,
args[3] = flags;
args[4] = (unsigned long) to;
args[5] = (unsigned long) tolen;
- return (__socketcall(SYS_RECVFROM, args));
+ return (ssize_t)__socketcall(SYS_RECVFROM, args);
+# endif
}
-#endif
-libc_hidden_proto(recvfrom)
-weak_alias(__libc_recvfrom,recvfrom)
-libc_hidden_weak(recvfrom)
+CANCELLABLE_SYSCALL(ssize_t, recvfrom, (int sockfd, void *buffer, size_t len,
+ int flags, struct sockaddr *to, socklen_t *tolen),
+ (sockfd, buffer, len, flags, to, tolen))
+lt_libc_hidden(recvfrom)
#endif
#ifdef L_recvmsg
-extern __typeof(recvmsg) __libc_recvmsg;
-#ifdef __NR_recvmsg
-#define __NR___libc_recvmsg __NR_recvmsg
-_syscall3(ssize_t, __libc_recvmsg, int, sockfd, struct msghdr *, msg, int, flags);
-#elif defined(__NR_socketcall)
-ssize_t __libc_recvmsg(int sockfd, struct msghdr *msg, int flags)
+static ssize_t __NC(recvmsg)(int sockfd, struct msghdr *msg, int flags)
{
+# ifdef __NR_recvmsg
+ return (ssize_t)INLINE_SYSCALL(recvmsg, 3, sockfd, msg, flags);
+# else
unsigned long args[3];
args[0] = sockfd;
args[1] = (unsigned long) msg;
args[2] = flags;
- return (__socketcall(SYS_RECVMSG, args));
+ return (ssize_t)__socketcall(SYS_RECVMSG, args);
+# endif
}
-#endif
-libc_hidden_proto(recvmsg)
-weak_alias(__libc_recvmsg,recvmsg)
-libc_hidden_weak(recvmsg)
+CANCELLABLE_SYSCALL(ssize_t, recvmsg, (int sockfd, struct msghdr *msg, int flags),
+ (sockfd, msg, flags))
+lt_libc_hidden(recvmsg)
#endif
#ifdef L_send
-extern __typeof(send) __libc_send;
-#ifdef __NR_send
-#define __NR___libc_send __NR_send
-_syscall4(ssize_t, __libc_send, int, sockfd, const void *, buffer, size_t, len, int, flags);
-#elif defined(__NR_socketcall)
-/* send, sendto added by bir7@leland.stanford.edu */
-ssize_t __libc_send(int sockfd, const void *buffer, size_t len, int flags)
+static ssize_t __NC(send)(int sockfd, const void *buffer, size_t len, int flags)
{
+# ifdef __NR_send
+ return (ssize_t)INLINE_SYSCALL(send, 4, sockfd, buffer, len, flags);
+# elif defined __NR_sendto && defined _syscall6
+ return __NC(sendto)(sockfd, buffer, len, flags, NULL, 0);
+# else
unsigned long args[4];
args[0] = sockfd;
args[1] = (unsigned long) buffer;
args[2] = len;
args[3] = flags;
- return (__socketcall(SYS_SEND, args));
-}
-#elif defined(__NR_sendto)
-libc_hidden_proto(sendto)
-ssize_t __libc_send(int sockfd, const void *buffer, size_t len, int flags)
-{
- return (sendto(sockfd, buffer, len, flags, NULL, 0));
+ return (ssize_t)__socketcall(SYS_SEND, args);
+# endif
}
-#endif
-libc_hidden_proto(send)
-weak_alias(__libc_send,send)
-libc_hidden_weak(send)
+CANCELLABLE_SYSCALL(ssize_t, send, (int sockfd, const void *buffer, size_t len, int flags),
+ (sockfd, buffer, len, flags))
+lt_libc_hidden(send)
#endif
#ifdef L_sendmsg
-extern __typeof(sendmsg) __libc_sendmsg;
-#ifdef __NR_sendmsg
-#define __NR___libc_sendmsg __NR_sendmsg
-_syscall3(ssize_t, __libc_sendmsg, int, sockfd, const struct msghdr *, msg, int, flags);
-#elif defined(__NR_socketcall)
-ssize_t __libc_sendmsg(int sockfd, const struct msghdr *msg, int flags)
+static ssize_t __NC(sendmsg)(int sockfd, const struct msghdr *msg, int flags)
{
+# ifdef __NR_sendmsg
+ return (ssize_t)INLINE_SYSCALL(sendmsg, 3, sockfd, msg, flags);
+# else
unsigned long args[3];
args[0] = sockfd;
args[1] = (unsigned long) msg;
args[2] = flags;
- return (__socketcall(SYS_SENDMSG, args));
+ return (ssize_t)__socketcall(SYS_SENDMSG, args);
+# endif
}
-#endif
-libc_hidden_proto(sendmsg)
-weak_alias(__libc_sendmsg,sendmsg)
-libc_hidden_weak(sendmsg)
+CANCELLABLE_SYSCALL(ssize_t, sendmsg, (int sockfd, const struct msghdr *msg, int flags),
+ (sockfd, msg, flags))
+lt_libc_hidden(sendmsg)
#endif
#ifdef L_sendto
-extern __typeof(sendto) __libc_sendto;
-#ifdef __NR_sendto
-#define __NR___libc_sendto __NR_sendto
-_syscall6(ssize_t, __libc_sendto, int, sockfd, const void *, buffer,
- size_t, len, int, flags, const struct sockaddr *, to, socklen_t, tolen);
-#elif defined(__NR_socketcall)
-/* send, sendto added by bir7@leland.stanford.edu */
-ssize_t __libc_sendto(int sockfd, const void *buffer, size_t len, int flags,
- const struct sockaddr *to, socklen_t tolen)
+ssize_t __NC(sendto)(int sockfd, const void *buffer, size_t len, int flags,
+ const struct sockaddr *to, socklen_t tolen)
{
+# if defined __NR_sendto && defined _syscall6
+ return (ssize_t)INLINE_SYSCALL(sendto, 6, sockfd, buffer, len, flags, to, tolen);
+# else
unsigned long args[6];
args[0] = sockfd;
@@ -311,23 +339,21 @@ ssize_t __libc_sendto(int sockfd, const void *buffer, size_t len, int flags,
args[3] = flags;
args[4] = (unsigned long) to;
args[5] = tolen;
- return (__socketcall(SYS_SENDTO, args));
+ return (ssize_t)__socketcall(SYS_SENDTO, args);
+# endif
}
-#endif
-libc_hidden_proto(sendto)
-weak_alias(__libc_sendto,sendto)
-libc_hidden_weak(sendto)
+CANCELLABLE_SYSCALL(ssize_t, sendto, (int sockfd, const void *buffer, size_t len,
+ int flags, const struct sockaddr *to, socklen_t tolen),
+ (sockfd, buffer, len, flags, to, tolen))
+lt_libc_hidden(sendto)
#endif
#ifdef L_setsockopt
-libc_hidden_proto(setsockopt)
-#ifdef __NR_setsockopt
-_syscall5(int, setsockopt, int, fd, int, level, int, optname, const void *, optval, socklen_t, optlen);
-#elif defined(__NR_socketcall)
-/* [sg]etsockoptions by bir7@leland.stanford.edu */
-int setsockopt(int fd, int level, int optname, const void *optval,
- socklen_t optlen)
+int setsockopt(int fd, int level, int optname, const void *optval, socklen_t optlen)
{
+# ifdef __NR_setsockopt
+ return INLINE_SYSCALL(setsockopt, 5, fd, level, optname, optval, optlen);
+# else
unsigned long args[5];
args[0] = fd;
@@ -335,52 +361,50 @@ int setsockopt(int fd, int level, int optname, const void *optval,
args[2] = optname;
args[3] = (unsigned long) optval;
args[4] = optlen;
- return (__socketcall(SYS_SETSOCKOPT, args));
+ return __socketcall(SYS_SETSOCKOPT, args);
+# endif
}
-#endif
libc_hidden_def(setsockopt)
#endif
#ifdef L_shutdown
-#ifdef __NR_shutdown
-_syscall2(int, shutdown, int, sockfd, int, how);
-#elif defined(__NR_socketcall)
-/* shutdown by bir7@leland.stanford.edu */
int shutdown(int sockfd, int how)
{
+# ifdef __NR_shutdown
+ return INLINE_SYSCALL(shutdown, 2, sockfd, how);
+# else
unsigned long args[2];
args[0] = sockfd;
args[1] = how;
- return (__socketcall(SYS_SHUTDOWN, args));
+ return __socketcall(SYS_SHUTDOWN, args);
+# endif
}
#endif
-#endif
#ifdef L_socket
-libc_hidden_proto(socket)
-#ifdef __NR_socket
-_syscall3(int, socket, int, family, int, type, int, protocol);
-#elif defined(__NR_socketcall)
int socket(int family, int type, int protocol)
{
+# ifdef __NR_socket
+ return INLINE_SYSCALL(socket, 3, family, type, protocol);
+# else
unsigned long args[3];
args[0] = family;
args[1] = type;
args[2] = (unsigned long) protocol;
return __socketcall(SYS_SOCKET, args);
+# endif
}
-#endif
libc_hidden_def(socket)
#endif
#ifdef L_socketpair
-#ifdef __NR_socketpair
-_syscall4(int, socketpair, int, family, int, type, int, protocol, int *, sockvec);
-#elif defined(__NR_socketcall)
int socketpair(int family, int type, int protocol, int sockvec[2])
{
+# ifdef __NR_socketpair
+ return INLINE_SYSCALL(socketpair, 4, family, type, protocol, sockvec);
+# else
unsigned long args[4];
args[0] = family;
@@ -388,6 +412,6 @@ int socketpair(int family, int type, int protocol, int sockvec[2])
args[2] = protocol;
args[3] = (unsigned long) sockvec;
return __socketcall(SYS_SOCKETPAIR, args);
+# endif
}
#endif
-#endif
diff --git a/libc/misc/Makefile.in b/libc/misc/Makefile.in
index 104db366e..e01b3dcbd 100644
--- a/libc/misc/Makefile.in
+++ b/libc/misc/Makefile.in
@@ -12,14 +12,17 @@ include $(top_srcdir)libc/misc/assert/Makefile.in
include $(top_srcdir)libc/misc/ctype/Makefile.in
include $(top_srcdir)libc/misc/dirent/Makefile.in
include $(top_srcdir)libc/misc/error/Makefile.in
+include $(top_srcdir)libc/misc/elf/Makefile.in
include $(top_srcdir)libc/misc/file/Makefile.in
include $(top_srcdir)libc/misc/fnmatch/Makefile.in
include $(top_srcdir)libc/misc/ftw/Makefile.in
+include $(top_srcdir)libc/misc/fts/Makefile.in
include $(top_srcdir)libc/misc/glob/Makefile.in
include $(top_srcdir)libc/misc/gnu/Makefile.in
include $(top_srcdir)libc/misc/internals/Makefile.in
include $(top_srcdir)libc/misc/locale/Makefile.in
include $(top_srcdir)libc/misc/mntent/Makefile.in
+include $(top_srcdir)libc/misc/pthread/Makefile.in
include $(top_srcdir)libc/misc/regex/Makefile.in
include $(top_srcdir)libc/misc/search/Makefile.in
include $(top_srcdir)libc/misc/statfs/Makefile.in
diff --git a/libc/misc/assert/Makefile.in b/libc/misc/assert/Makefile.in
index 3c9111e68..aba8a3b8d 100644
--- a/libc/misc/assert/Makefile.in
+++ b/libc/misc/assert/Makefile.in
@@ -1,21 +1,23 @@
# 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.
#
-CSRC := __assert.c
+subdirs += libc/misc/assert
+
+CSRC-y := __assert.c
MISC_ASSERT_DIR := $(top_srcdir)libc/misc/assert
MISC_ASSERT_OUT := $(top_builddir)libc/misc/assert
-MISC_ASSERT_SRC := $(MISC_ASSERT_DIR)/__assert.c
-MISC_ASSERT_OBJ := $(MISC_ASSERT_OUT)/__assert.o
+MISC_ASSERT_SRC := $(patsubst %.c,$(MISC_ASSERT_DIR)/%.c,$(CSRC-y))
+MISC_ASSERT_OBJ := $(patsubst %.c,$(MISC_ASSERT_OUT)/%.o,$(CSRC-y))
libc-y += $(MISC_ASSERT_OBJ)
-objclean-y += misc_assert_objclean
+objclean-y += CLEAN_libc/misc/assert
-misc_assert_objclean:
- $(RM) $(MISC_ASSERT_OUT)/*.{o,os}
+CLEAN_libc/misc/assert:
+ $(do_rm) $(addprefix $(MISC_ASSERT_OUT)/*., o os)
diff --git a/libc/misc/assert/__assert.c b/libc/misc/assert/__assert.c
index 7a2fa1dce..85cedbfc2 100644
--- a/libc/misc/assert/__assert.c
+++ b/libc/misc/assert/__assert.c
@@ -13,8 +13,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/>.
*/
/* Oct 28, 2002
@@ -30,24 +30,19 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
-#include <bits/uClibc_uintmaxtostr.h>
-
-libc_hidden_proto(fprintf)
-libc_hidden_proto(abort)
/* Get the prototype from assert.h as a double-check. */
#undef NDEBUG
#include <assert.h>
#undef assert
-libc_hidden_proto(__assert)
#define ASSERT_SHOW_PROGNAME 1
static smallint in_assert; /* bss inits to 0. */
-void attribute_noreturn __assert(const char *assertion, const char * filename,
- int linenumber, register const char * function)
+void __assert(const char *assertion, const char * filename,
+ unsigned int linenumber, register const char * function)
{
if (!in_assert) {
in_assert = 1;
@@ -65,7 +60,7 @@ void attribute_noreturn __assert(const char *assertion, const char * filename,
assertion
);
}
+ /* shouldn't we? fflush(stderr); */
abort();
}
-
libc_hidden_def(__assert)
diff --git a/libc/misc/ctype/Makefile.in b/libc/misc/ctype/Makefile.in
index 1fc768ee3..0ebaec285 100644
--- a/libc/misc/ctype/Makefile.in
+++ b/libc/misc/ctype/Makefile.in
@@ -1,38 +1,36 @@
# 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.
#
+subdirs += libc/misc/ctype
+
# multi source ctype.c
-COM_SRC := \
- isalnum.c isalpha.c isascii.c iscntrl.c isdigit.c \
+COM_SRC-y := \
+ isalnum.c isalpha.c iscntrl.c isdigit.c \
isgraph.c islower.c isprint.c ispunct.c isspace.c \
- isupper.c isxdigit.c toascii.c tolower.c toupper.c \
+ isupper.c isxdigit.c tolower.c toupper.c \
isblank.c
+COM_SRC-$(UCLIBC_SUSV4_LEGACY) += isascii.c toascii.c
+CSRC-y := $(COM_SRC-y)
-CSRC := $(COM_SRC)
-
-ifeq ($(UCLIBC_HAS_CTYPE_TABLES),y)
-CSRC += __C_ctype_b.c __C_ctype_tolower.c __C_ctype_toupper.c \
+CSRC-$(UCLIBC_HAS_CTYPE_TABLES) += \
+ __C_ctype_b.c __C_ctype_tolower.c __C_ctype_toupper.c \
__ctype_b_loc.c __ctype_tolower_loc.c __ctype_toupper_loc.c \
__ctype_assert.c isctype.c
-endif
-
-ifeq ($(UCLIBC_HAS_XLOCALE),y)
-CSRC += $(patsubst %.c,%_l.c,$(COM_SRC))
-endif
+CSRC-$(UCLIBC_HAS_XLOCALE) += $(patsubst %.c,%_l.c,$(COM_SRC-y))
MISC_CTYPE_DIR := $(top_srcdir)libc/misc/ctype
MISC_CTYPE_OUT := $(top_builddir)libc/misc/ctype
-MISC_CTYPE_SRC := $(patsubst %.c,$(MISC_CTYPE_DIR)/%.c,$(CSRC))
-MISC_CTYPE_OBJ := $(patsubst %.c,$(MISC_CTYPE_OUT)/%.o,$(CSRC))
+MISC_CTYPE_SRC := $(patsubst %.c,$(MISC_CTYPE_DIR)/%.c,$(CSRC-y))
+MISC_CTYPE_OBJ := $(patsubst %.c,$(MISC_CTYPE_OUT)/%.o,$(CSRC-y))
libc-y += $(MISC_CTYPE_OBJ)
-objclean-y += misc_ctype_objclean
+objclean-y += CLEAN_libc/misc/ctype
-misc_ctype_objclean:
- $(RM) $(MISC_CTYPE_OUT)/*.{o,os}
+CLEAN_libc/misc/ctype:
+ $(do_rm) $(addprefix $(MISC_CTYPE_OUT)/*., o os)
diff --git a/libc/misc/ctype/ctype.c b/libc/misc/ctype/ctype.c
index abb76ebdc..db8061d9f 100644
--- a/libc/misc/ctype/ctype.c
+++ b/libc/misc/ctype/ctype.c
@@ -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/>.
*/
/* ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION!
@@ -35,15 +35,6 @@
#include <stdint.h>
#include <assert.h>
#include <locale.h>
-#ifdef __UCLIBC_HAS_XLOCALE__
-libc_hidden_proto(__ctype_b_loc)
-#elif defined __UCLIBC_HAS_CTYPE_TABLES__
-libc_hidden_proto(__ctype_b)
-#endif
-
-#ifdef __UCLIBC_HAS_XLOCALE__
-#include <xlocale.h>
-#endif /* __UCLIBC_HAS_XLOCALE__ */
/**********************************************************************/
#ifdef __UCLIBC_HAS_CTYPE_TABLES__
@@ -89,14 +80,17 @@ libc_hidden_proto(__ctype_b)
#undef CTYPE_NAME
#undef ISCTYPE
#undef CTYPE_ALIAS
+#undef CTYPE_DEF
#ifdef __UCLIBC_DO_XLOCALE
#define CTYPE_NAME(X) __is ## X ## _l
#define ISCTYPE(C,F) __isctype_l( C, F, locale_arg)
-#define CTYPE_ALIAS(NAME) strong_alias( __is ## NAME ## _l , is ## NAME ## _l)
+#define CTYPE_ALIAS(NAME) strong_alias( __is ## NAME ## _l , is ## NAME ## _l)
+#define CTYPE_DEF(NAME) libc_hidden_def(is ## NAME ## _l)
#else
#define CTYPE_NAME(X) is ## X
#define ISCTYPE(C,F) __isctype( C, F )
#define CTYPE_ALIAS(NAME)
+#define CTYPE_DEF(NAME) libc_hidden_def(is ## NAME)
#endif
@@ -142,13 +136,14 @@ int CTYPE_NAME(NAME) (int c __LOCALE_PARAM ) \
{ \
CTYPE_BODY(NAME,c,PASTE2(_IS,NAME)) \
} \
+CTYPE_DEF(NAME) \
CTYPE_ALIAS(NAME)
-
#else /* __UCLIBC_HAS_CTYPE_TABLES__ */
#define C_MACRO(X) PASTE2(__C_is,X)(c)
#define CTYPE_NAME(X) is ## X
+#define CTYPE_DEF(NAME) libc_hidden_def(is ## NAME)
#define IS_FUNC_BODY(NAME) \
int CTYPE_NAME(NAME) (int c) \
@@ -161,8 +156,6 @@ int CTYPE_NAME(NAME) (int c) \
#ifdef L___ctype_assert
#ifdef __UCLIBC_HAS_CTYPE_ENFORCED__
-libc_hidden_proto(fprintf)
-libc_hidden_proto(abort)
attribute_hidden void __isctype_assert(int c, int mask)
{
@@ -220,7 +213,7 @@ int CTYPE_NAME(digit) (int C __LOCALE_PARAM)
return __isdigit_int(C); /* C could be invalid. */
#endif
}
-
+CTYPE_DEF(digit)
CTYPE_ALIAS(digit)
#else /* __UCLIBC_HAS_CTYPE_TABLES__ */
@@ -276,12 +269,6 @@ IS_FUNC_BODY(xdigit);
#ifdef L_tolower
#undef tolower
-#ifdef __UCLIBC_HAS_XLOCALE__
-libc_hidden_proto(__ctype_tolower_loc)
-#elif defined __UCLIBC_HAS_CTYPE_TABLES__
-libc_hidden_proto(__ctype_tolower)
-#endif
-libc_hidden_proto(tolower)
#ifdef __UCLIBC_HAS_CTYPE_TABLES__
int tolower(int c)
@@ -307,7 +294,6 @@ libc_hidden_def(tolower)
#ifdef L_tolower_l
#undef tolower_l
-libc_hidden_proto(tolower_l)
int tolower_l(int c, __locale_t l)
{
#if defined(__UCLIBC_HAS_CTYPE_ENFORCED__)
@@ -316,19 +302,12 @@ int tolower_l(int c, __locale_t l)
return __UCLIBC_CTYPE_IN_TO_DOMAIN(c) ? l->__ctype_tolower[c] : c;
}
libc_hidden_def(tolower_l)
-weak_alias (tolower_l, __tolower_l)
#endif
/**********************************************************************/
#ifdef L_toupper
#undef toupper
-#ifdef __UCLIBC_HAS_XLOCALE__
-libc_hidden_proto(__ctype_toupper_loc)
-#elif defined __UCLIBC_HAS_CTYPE_TABLES__
-libc_hidden_proto(__ctype_toupper)
-#endif
-libc_hidden_proto(toupper)
#ifdef __UCLIBC_HAS_CTYPE_TABLES__
int toupper(int c)
@@ -354,7 +333,6 @@ libc_hidden_def(toupper)
#ifdef L_toupper_l
#undef toupper_l
-libc_hidden_proto(toupper_l)
int toupper_l(int c, __locale_t l)
{
#if defined(__UCLIBC_HAS_CTYPE_ENFORCED__)
@@ -362,8 +340,6 @@ int toupper_l(int c, __locale_t l)
#endif
return __UCLIBC_CTYPE_IN_TO_DOMAIN(c) ? l->__ctype_toupper[c] : c;
}
-libc_hidden_def(toupper_l)
-weak_alias (toupper_l, __toupper_l)
#endif
/**********************************************************************/
@@ -379,14 +355,14 @@ int __XL_NPP(isascii)(int c)
#else /* __UCLIBC_HAS_CTYPE_TABLES__ */
-libc_hidden_proto(isascii)
int isascii(int c)
{
return __isascii(c); /* locale-independent */
}
-libc_hidden_def(isascii)
#endif /* __UCLIBC_HAS_CTYPE_TABLES__ */
+CTYPE_DEF(ascii)
+
#endif
/**********************************************************************/
@@ -428,7 +404,7 @@ int isctype(int c, int mask)
const __ctype_mask_t **__ctype_b_loc(void)
{
- return &(__UCLIBC_CURLOCALE_DATA).__ctype_b;
+ return &(__UCLIBC_CURLOCALE->__ctype_b);
}
libc_hidden_def(__ctype_b_loc)
@@ -440,10 +416,9 @@ libc_hidden_def(__ctype_b_loc)
#ifdef __UCLIBC_HAS_XLOCALE__
-libc_hidden_proto(__ctype_tolower_loc)
const __ctype_touplow_t **__ctype_tolower_loc(void)
{
- return &(__UCLIBC_CURLOCALE_DATA).__ctype_tolower;
+ return &(__UCLIBC_CURLOCALE->__ctype_tolower);
}
libc_hidden_def(__ctype_tolower_loc)
@@ -455,10 +430,9 @@ libc_hidden_def(__ctype_tolower_loc)
#ifdef __UCLIBC_HAS_XLOCALE__
-libc_hidden_proto(__ctype_toupper_loc)
const __ctype_touplow_t **__ctype_toupper_loc(void)
{
- return &(__UCLIBC_CURLOCALE_DATA).__ctype_toupper;
+ return &(__UCLIBC_CURLOCALE->__ctype_toupper);
}
libc_hidden_def(__ctype_toupper_loc)
@@ -468,9 +442,7 @@ libc_hidden_def(__ctype_toupper_loc)
/**********************************************************************/
#ifdef L___C_ctype_b
-extern const __ctype_mask_t __C_ctype_b_data[];
-libc_hidden_proto(__C_ctype_b_data)
-const __ctype_mask_t __C_ctype_b_data[] = {
+static const __ctype_mask_t __C_ctype_b_data[] = {
#ifdef __UCLIBC_HAS_CTYPE_SIGNED__
/* -128 M-^@ */ 0,
/* -127 M-^A */ 0,
@@ -858,9 +830,7 @@ const __ctype_mask_t __C_ctype_b_data[] = {
/* 254 M-~ */ 0,
/* 255 M-^? */ 0
};
-libc_hidden_data_def(__C_ctype_b_data)
-libc_hidden_proto(__C_ctype_b)
const __ctype_mask_t *__C_ctype_b = __C_ctype_b_data + __UCLIBC_CTYPE_B_TBL_OFFSET;
libc_hidden_data_def(__C_ctype_b)
@@ -875,9 +845,7 @@ libc_hidden_data_def(__ctype_b)
/**********************************************************************/
#ifdef L___C_ctype_tolower
-extern const __ctype_touplow_t __C_ctype_tolower_data[];
-libc_hidden_proto(__C_ctype_tolower_data)
-const __ctype_touplow_t __C_ctype_tolower_data[] = {
+static const __ctype_touplow_t __C_ctype_tolower_data[] = {
#ifdef __UCLIBC_HAS_CTYPE_SIGNED__
-128, -127, -126, -125,
-124, -123, -122, -121,
@@ -977,18 +945,15 @@ const __ctype_touplow_t __C_ctype_tolower_data[] = {
248, 249, 250, 251,
252, 253, 254, 255
};
-libc_hidden_data_def(__C_ctype_tolower_data)
-libc_hidden_proto(__C_ctype_tolower)
-const __ctype_touplow_t *__C_ctype_tolower = __C_ctype_tolower_data
- + __UCLIBC_CTYPE_TO_TBL_OFFSET;
+const __ctype_touplow_t *__C_ctype_tolower =
+ __C_ctype_tolower_data + __UCLIBC_CTYPE_TO_TBL_OFFSET;
libc_hidden_data_def(__C_ctype_tolower)
#ifndef __UCLIBC_HAS_XLOCALE__
-libc_hidden_proto(__ctype_tolower)
-const __ctype_touplow_t *__ctype_tolower = __C_ctype_tolower_data
- + __UCLIBC_CTYPE_TO_TBL_OFFSET;
+const __ctype_touplow_t *__ctype_tolower =
+ __C_ctype_tolower_data + __UCLIBC_CTYPE_TO_TBL_OFFSET;
libc_hidden_data_def(__ctype_tolower)
#endif
@@ -997,9 +962,7 @@ libc_hidden_data_def(__ctype_tolower)
/**********************************************************************/
#ifdef L___C_ctype_toupper
-extern const __ctype_touplow_t __C_ctype_toupper_data[];
-libc_hidden_proto(__C_ctype_toupper_data)
-const __ctype_touplow_t __C_ctype_toupper_data[] = {
+static const __ctype_touplow_t __C_ctype_toupper_data[] = {
#ifdef __UCLIBC_HAS_CTYPE_SIGNED__
-128, -127, -126, -125,
-124, -123, -122, -121,
@@ -1099,18 +1062,15 @@ const __ctype_touplow_t __C_ctype_toupper_data[] = {
248, 249, 250, 251,
252, 253, 254, 255
};
-libc_hidden_data_def(__C_ctype_toupper_data)
-libc_hidden_proto(__C_ctype_toupper)
-const __ctype_touplow_t *__C_ctype_toupper = __C_ctype_toupper_data
- + __UCLIBC_CTYPE_TO_TBL_OFFSET;
+const __ctype_touplow_t *__C_ctype_toupper =
+ __C_ctype_toupper_data + __UCLIBC_CTYPE_TO_TBL_OFFSET;
libc_hidden_data_def(__C_ctype_toupper)
#ifndef __UCLIBC_HAS_XLOCALE__
-libc_hidden_proto(__ctype_toupper)
-const __ctype_touplow_t *__ctype_toupper = __C_ctype_toupper_data
- + __UCLIBC_CTYPE_TO_TBL_OFFSET;
+const __ctype_touplow_t *__ctype_toupper =
+ __C_ctype_toupper_data + __UCLIBC_CTYPE_TO_TBL_OFFSET;
libc_hidden_data_def(__ctype_toupper)
#endif
diff --git a/libc/misc/dirent/Makefile.in b/libc/misc/dirent/Makefile.in
index b35efa0b1..5cae8d44d 100644
--- a/libc/misc/dirent/Makefile.in
+++ b/libc/misc/dirent/Makefile.in
@@ -1,26 +1,28 @@
# 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.
#
-CSRC := alphasort.c closedir.c dirfd.c opendir.c readdir.c rewinddir.c \
- scandir.c seekdir.c telldir.c readdir_r.c
+subdirs += libc/misc/dirent
-ifeq ($(UCLIBC_HAS_LFS),y)
-CSRC += readdir64.c alphasort64.c scandir64.c readdir64_r.c
-endif
+CSRC := alphasort.c readdir.c scandir.c versionsort.c
+CSRC_R := readdir_r.c
+CSRC-y := closedir.c dirfd.c opendir.c rewinddir.c seekdir.c telldir.c $(CSRC) \
+ $(CSRC_R)
+CSRC-$(UCLIBC_HAS_LFS) += $(patsubst %.c,%64.c,$(CSRC))
+CSRC-$(UCLIBC_HAS_LFS) += $(patsubst %_r.c,%64_r.c,$(CSRC_R))
MISC_DIRENT_DIR := $(top_srcdir)libc/misc/dirent
MISC_DIRENT_OUT := $(top_builddir)libc/misc/dirent
-MISC_DIRENT_SRC := $(patsubst %.c,$(MISC_DIRENT_DIR)/%.c,$(CSRC))
-MISC_DIRENT_OBJ := $(patsubst %.c,$(MISC_DIRENT_OUT)/%.o,$(CSRC))
+MISC_DIRENT_SRC := $(patsubst %.c,$(MISC_DIRENT_DIR)/%.c,$(CSRC-y))
+MISC_DIRENT_OBJ := $(patsubst %.c,$(MISC_DIRENT_OUT)/%.o,$(CSRC-y))
libc-y += $(MISC_DIRENT_OBJ)
-objclean-y += misc_dirent_objclean
+objclean-y += CLEAN_libc/misc/dirent
-misc_dirent_objclean:
- $(RM) $(MISC_DIRENT_OUT)/*.{o,os}
+CLEAN_libc/misc/dirent:
+ $(do_rm) $(addprefix $(MISC_DIRENT_OUT)/*., o os)
diff --git a/libc/misc/dirent/alphasort.c b/libc/misc/dirent/alphasort.c
index 70aa2a516..67b3b7859 100644
--- a/libc/misc/dirent/alphasort.c
+++ b/libc/misc/dirent/alphasort.c
@@ -8,11 +8,10 @@
#include <string.h>
#include "dirstream.h"
-/* Experimentally off - libc_hidden_proto(strcmp) */
-
-int alphasort(const void * a, const void * b)
+int alphasort(const struct dirent **a, const struct dirent **b)
{
- return strcmp ((*(const struct dirent **) a)->d_name,
- (*(const struct dirent **) b)->d_name);
+ return strcoll((*a)->d_name, (*b)->d_name);
}
-
+#if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64
+strong_alias_untyped(alphasort,alphasort64)
+#endif
diff --git a/libc/misc/dirent/alphasort64.c b/libc/misc/dirent/alphasort64.c
index de7a87a9a..6eb414241 100644
--- a/libc/misc/dirent/alphasort64.c
+++ b/libc/misc/dirent/alphasort64.c
@@ -5,15 +5,14 @@
*/
#include <_lfs_64.h>
-
#include <dirent.h>
-#include <string.h>
-#include "dirstream.h"
-/* Experimentally off - libc_hidden_proto(strcmp) */
+#if __WORDSIZE != 64
+# include <string.h>
+# include "dirstream.h"
-int alphasort64(const void * a, const void * b)
+int alphasort64(const struct dirent64 **a, const struct dirent64 **b)
{
- return strcmp ((*(const struct dirent64 **) a)->d_name,
- (*(const struct dirent64 **) b)->d_name);
+ return strcoll((*a)->d_name, (*b)->d_name);
}
+#endif
diff --git a/libc/misc/dirent/closedir.c b/libc/misc/dirent/closedir.c
index 3dc0bd17a..dfb53f888 100644
--- a/libc/misc/dirent/closedir.c
+++ b/libc/misc/dirent/closedir.c
@@ -9,9 +9,8 @@
#include <stdlib.h>
#include <unistd.h>
#include "dirstream.h"
+#include <not-cancel.h>
-libc_hidden_proto(closedir)
-libc_hidden_proto(close)
int closedir(DIR * dir)
{
@@ -33,6 +32,6 @@ int closedir(DIR * dir)
__UCLIBC_MUTEX_UNLOCK(dir->dd_lock);
free(dir->dd_buf);
free(dir);
- return close(fd);
+ return close_not_cancel(fd);
}
libc_hidden_def(closedir)
diff --git a/libc/misc/dirent/dirfd.c b/libc/misc/dirent/dirfd.c
index c6f46e965..649dd4ad8 100644
--- a/libc/misc/dirent/dirfd.c
+++ b/libc/misc/dirent/dirfd.c
@@ -8,7 +8,6 @@
#include <errno.h>
#include "dirstream.h"
-libc_hidden_proto(dirfd)
int dirfd(DIR * dir)
{
diff --git a/libc/misc/dirent/dirstream.h b/libc/misc/dirent/dirstream.h
index 370886aa7..59b8bafb9 100644
--- a/libc/misc/dirent/dirstream.h
+++ b/libc/misc/dirent/dirstream.h
@@ -13,8 +13,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, 1992 Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
+not, see <http://www.gnu.org/licenses/>. */
/*
* POSIX Standard: 5.1.2 Directory Operations <dirent.h>
@@ -29,18 +28,6 @@ Cambridge, MA 02139, USA. */
#include <bits/uClibc_mutex.h>
-/* For now, syscall readdir () only supports one entry at a time. It
- * will be changed in the future.
-#define NUMENT 3
-*/
-#ifndef NUMENT
-#define NUMENT 1
-#endif
-
-#define SINGLE_READDIR 11
-#define MULTI_READDIR 12
-#define NEW_READDIR 13
-
/* Directory stream type. */
struct __dirstream {
/* file descriptor */
@@ -65,10 +52,4 @@ struct __dirstream {
__UCLIBC_MUTEX(dd_lock);
}; /* stream data from opendir() */
-
-extern ssize_t __getdents(int fd, char *buf, size_t count) attribute_hidden;
-#ifdef __UCLIBC_HAS_LFS__
-extern ssize_t __getdents64 (int fd, char *buf, size_t count) attribute_hidden;
-#endif
-
#endif /* dirent.h */
diff --git a/libc/misc/dirent/opendir.c b/libc/misc/dirent/opendir.c
index 26ab91511..8af00f88c 100644
--- a/libc/misc/dirent/opendir.c
+++ b/libc/misc/dirent/opendir.c
@@ -12,14 +12,56 @@
#include <unistd.h>
#include <sys/dir.h>
#include <sys/stat.h>
+#include <not-cancel.h>
+#include <dirent.h>
#include "dirstream.h"
-libc_hidden_proto(opendir)
-libc_hidden_proto(open)
-libc_hidden_proto(fcntl)
-libc_hidden_proto(close)
-libc_hidden_proto(stat)
-libc_hidden_proto(fstat)
+static DIR *fd_to_DIR(int fd, __blksize_t size)
+{
+ DIR *ptr;
+
+ ptr = malloc(sizeof(*ptr));
+ if (!ptr)
+ return NULL;
+
+ ptr->dd_fd = fd;
+ ptr->dd_nextloc = ptr->dd_size = ptr->dd_nextoff = 0;
+ ptr->dd_max = size;
+ if (ptr->dd_max < 512)
+ ptr->dd_max = 512;
+
+ ptr->dd_buf = calloc(1, ptr->dd_max);
+ if (!ptr->dd_buf) {
+ free(ptr);
+ return NULL;
+ }
+ __UCLIBC_MUTEX_INIT_VAR(ptr->dd_lock);
+
+ return ptr;
+}
+
+DIR *fdopendir(int fd)
+{
+ int flags;
+ struct stat st;
+
+ if (fstat(fd, &st))
+ return NULL;
+ if (!S_ISDIR(st.st_mode)) {
+ __set_errno(ENOTDIR);
+ return NULL;
+ }
+
+ flags = fcntl(fd, F_GETFL);
+ if (flags == -1)
+ return NULL;
+ if ((flags & O_ACCMODE) == O_WRONLY) {
+ __set_errno(EINVAL);
+ return NULL;
+ }
+
+ return fd_to_DIR(fd, st.st_blksize);
+}
/* opendir just makes an open() call - it return NULL if it fails
* (open sets errno), otherwise it returns a DIR * pointer.
@@ -40,44 +82,36 @@ DIR *opendir(const char *name)
}
# define O_DIRECTORY 0
#endif
- if ((fd = open(name, O_RDONLY|O_NDELAY|O_DIRECTORY)) < 0)
+ fd = open_not_cancel_2(name, O_RDONLY|O_NDELAY|O_DIRECTORY|O_CLOEXEC);
+ if (fd < 0)
return NULL;
-
/* Note: we should check to make sure that between the stat() and open()
* call, 'name' didnt change on us, but that's only if O_DIRECTORY isnt
* defined and since Linux has supported it for like ever, i'm not going
* to worry about it right now (if ever). */
- if (fstat(fd, &statbuf) < 0)
- goto close_and_ret;
+
+ if (fstat(fd, &statbuf) < 0) {
+ /* this close() never fails
+ *int saved_errno;
+ *saved_errno = errno; */
+ close_not_cancel_no_status(fd);
+ /*__set_errno(saved_errno);*/
+ return NULL;
+ }
/* According to POSIX, directory streams should be closed when
* exec. From "Anna Pluzhnikov" <besp@midway.uchicago.edu>.
*/
- if (fcntl(fd, F_SETFD, FD_CLOEXEC) < 0) {
- int saved_errno;
-close_and_ret:
- saved_errno = errno;
- close(fd);
- __set_errno(saved_errno);
- return NULL;
- }
- if (!(ptr = malloc(sizeof(*ptr))))
- goto nomem_close_and_ret;
+#ifndef __ASSUME_O_CLOEXEC
+ fcntl_not_cancel(fd, F_SETFD, FD_CLOEXEC);
+#endif
- ptr->dd_fd = fd;
- ptr->dd_nextloc = ptr->dd_size = ptr->dd_nextoff = 0;
- ptr->dd_max = statbuf.st_blksize;
- if (ptr->dd_max < 512)
- ptr->dd_max = 512;
+ ptr = fd_to_DIR(fd, statbuf.st_blksize);
- if (!(ptr->dd_buf = calloc(1, ptr->dd_max))) {
- free(ptr);
-nomem_close_and_ret:
- close(fd);
- __set_errno(ENOMEM);
- return NULL;
+ if (!ptr) {
+ close_not_cancel_no_status(fd);
+ /* __set_errno(ENOMEM); */
}
- __pthread_mutex_init(&(ptr->dd_lock), NULL);
return ptr;
}
libc_hidden_def(opendir)
diff --git a/libc/misc/dirent/readdir.c b/libc/misc/dirent/readdir.c
index 2fb7a7246..75171064d 100644
--- a/libc/misc/dirent/readdir.c
+++ b/libc/misc/dirent/readdir.c
@@ -4,21 +4,22 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#include <features.h>
-
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
#include <dirent.h>
+#include <errno.h>
+#define __need_NULL
+#include <stddef.h>
#include "dirstream.h"
-libc_hidden_proto(readdir)
+#ifndef __READDIR
+# define __READDIR readdir
+# define __DIRENT_TYPE struct dirent
+# define __GETDENTS __getdents
+#endif
-struct dirent *readdir(DIR * dir)
+__DIRENT_TYPE *__READDIR(DIR * dir)
{
ssize_t bytes;
- struct dirent *de;
+ __DIRENT_TYPE *de;
if (!dir) {
__set_errno(EBADF);
@@ -30,7 +31,7 @@ struct dirent *readdir(DIR * dir)
do {
if (dir->dd_size <= dir->dd_nextloc) {
/* read dir->dd_max bytes of directory entries. */
- bytes = __getdents(dir->dd_fd, dir->dd_buf, dir->dd_max);
+ bytes = __GETDENTS(dir->dd_fd, dir->dd_buf, dir->dd_max);
if (bytes <= 0) {
de = NULL;
goto all_done;
@@ -39,7 +40,7 @@ struct dirent *readdir(DIR * dir)
dir->dd_nextloc = 0;
}
- de = (struct dirent *) (((char *) dir->dd_buf) + dir->dd_nextloc);
+ de = (__DIRENT_TYPE *) (((char *) dir->dd_buf) + dir->dd_nextloc);
/* Am I right? H.J. */
dir->dd_nextloc += de->d_reclen;
@@ -54,4 +55,8 @@ all_done:
__UCLIBC_MUTEX_UNLOCK(dir->dd_lock);
return de;
}
-libc_hidden_def(readdir)
+libc_hidden_def(__READDIR)
+#if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64
+strong_alias_untyped(readdir,readdir64)
+libc_hidden_def(readdir64)
+#endif
diff --git a/libc/misc/dirent/readdir64.c b/libc/misc/dirent/readdir64.c
index e8a29da96..17577a7b6 100644
--- a/libc/misc/dirent/readdir64.c
+++ b/libc/misc/dirent/readdir64.c
@@ -5,53 +5,12 @@
*/
#include <_lfs_64.h>
-
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
#include <dirent.h>
-#include "dirstream.h"
-
-libc_hidden_proto(readdir64)
-struct dirent64 *readdir64(DIR * dir)
-{
- ssize_t bytes;
- struct dirent64 *de;
-
- if (!dir) {
- __set_errno(EBADF);
- return NULL;
- }
-
- __UCLIBC_MUTEX_LOCK(dir->dd_lock);
-
- do {
- if (dir->dd_size <= dir->dd_nextloc) {
- /* read dir->dd_max bytes of directory entries. */
- bytes = __getdents64(dir->dd_fd, dir->dd_buf, dir->dd_max);
- if (bytes <= 0) {
- de = NULL;
- goto all_done;
- }
- dir->dd_size = bytes;
- dir->dd_nextloc = 0;
- }
-
- de = (struct dirent64 *) (((char *) dir->dd_buf) + dir->dd_nextloc);
-
- /* Am I right? H.J. */
- dir->dd_nextloc += de->d_reclen;
-
- /* We have to save the next offset here. */
- dir->dd_nextoff = de->d_off;
-
- /* Skip deleted files. */
- } while (de->d_ino == 0);
-all_done:
- __UCLIBC_MUTEX_UNLOCK(dir->dd_lock);
+#if __WORDSIZE != 64
+# define __READDIR readdir64
+# define __DIRENT_TYPE struct dirent64
+# define __GETDENTS __getdents64
- return de;
-}
-libc_hidden_def(readdir64)
+# include "readdir.c"
+#endif
diff --git a/libc/misc/dirent/readdir64_r.c b/libc/misc/dirent/readdir64_r.c
index 2958b1d1a..c045cbdea 100644
--- a/libc/misc/dirent/readdir64_r.c
+++ b/libc/misc/dirent/readdir64_r.c
@@ -5,64 +5,12 @@
*/
#include <_lfs_64.h>
-
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
#include <dirent.h>
-#include "dirstream.h"
-
-/* Experimentally off - libc_hidden_proto(memcpy) */
-
-libc_hidden_proto(readdir64_r)
-int readdir64_r(DIR *dir, struct dirent64 *entry, struct dirent64 **result)
-{
- int ret;
- ssize_t bytes;
- struct dirent64 *de;
-
- if (!dir) {
- __set_errno(EBADF);
- return(EBADF);
- }
- de = NULL;
-
- __UCLIBC_MUTEX_LOCK(dir->dd_lock);
-
- do {
- if (dir->dd_size <= dir->dd_nextloc) {
- /* read dir->dd_max bytes of directory entries. */
- bytes = __getdents64(dir->dd_fd, dir->dd_buf, dir->dd_max);
- if (bytes <= 0) {
- *result = NULL;
- ret = (bytes==0)? 0 : errno;
- goto all_done;
- }
- dir->dd_size = bytes;
- dir->dd_nextloc = 0;
- }
-
- de = (struct dirent64 *) (((char *) dir->dd_buf) + dir->dd_nextloc);
-
- /* Am I right? H.J. */
- dir->dd_nextloc += de->d_reclen;
-
- /* We have to save the next offset here. */
- dir->dd_nextoff = de->d_off;
- /* Skip deleted files. */
- } while (de->d_ino == 0);
-
- if (de == NULL) {
- *result = NULL;
- } else {
- *result = memcpy (entry, de, de->d_reclen);
- }
- ret = 0;
-all_done:
+#if __WORDSIZE != 64
+# define __READDIR_R readdir64_r
+# define __DIRENT_TYPE struct dirent64
+# define __GETDENTS __getdents64
- __UCLIBC_MUTEX_UNLOCK(dir->dd_lock);
- return((de != NULL)? 0 : ret);
-}
-libc_hidden_def(readdir64_r)
+# include "readdir_r.c"
+#endif
diff --git a/libc/misc/dirent/readdir_r.c b/libc/misc/dirent/readdir_r.c
index 194af621f..5beebfed0 100644
--- a/libc/misc/dirent/readdir_r.c
+++ b/libc/misc/dirent/readdir_r.c
@@ -4,35 +4,38 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+#include <dirent.h>
#include <errno.h>
-#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
-#include <dirent.h>
+#define __need_NULL
+#include <stddef.h>
#include "dirstream.h"
-/* Experimentally off - libc_hidden_proto(memcpy) */
+#ifndef __READDIR_R
+# define __READDIR_R readdir_r
+# define __DIRENT_TYPE struct dirent
+# define __GETDENTS __getdents
+#endif
-libc_hidden_proto(readdir_r)
-int readdir_r(DIR *dir, struct dirent *entry, struct dirent **result)
+int __READDIR_R(DIR *dir, __DIRENT_TYPE *entry, __DIRENT_TYPE **result)
{
int ret;
ssize_t bytes;
- struct dirent *de;
+ __DIRENT_TYPE *de;
if (!dir) {
__set_errno(EBADF);
return(EBADF);
}
- de = NULL;
__UCLIBC_MUTEX_LOCK(dir->dd_lock);
do {
if (dir->dd_size <= dir->dd_nextloc) {
/* read dir->dd_max bytes of directory entries. */
- bytes = __getdents(dir->dd_fd, dir->dd_buf, dir->dd_max);
+ bytes = __GETDENTS(dir->dd_fd, dir->dd_buf, dir->dd_max);
if (bytes <= 0) {
+ de = NULL;
*result = NULL;
ret = (bytes==0)? 0 : errno;
goto all_done;
@@ -41,7 +44,7 @@ int readdir_r(DIR *dir, struct dirent *entry, struct dirent **result)
dir->dd_nextloc = 0;
}
- de = (struct dirent *) (((char *) dir->dd_buf) + dir->dd_nextloc);
+ de = (__DIRENT_TYPE *) (((char *) dir->dd_buf) + dir->dd_nextloc);
/* Am I right? H.J. */
dir->dd_nextloc += de->d_reclen;
@@ -63,4 +66,8 @@ all_done:
__UCLIBC_MUTEX_UNLOCK(dir->dd_lock);
return((de != NULL)? 0 : ret);
}
-libc_hidden_def(readdir_r)
+libc_hidden_def(__READDIR_R)
+#if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64
+strong_alias_untyped(readdir_r,readdir64_r)
+libc_hidden_def(readdir64_r)
+#endif
diff --git a/libc/misc/dirent/rewinddir.c b/libc/misc/dirent/rewinddir.c
index 1bbda0809..0a8f14740 100644
--- a/libc/misc/dirent/rewinddir.c
+++ b/libc/misc/dirent/rewinddir.c
@@ -9,7 +9,6 @@
#include <unistd.h>
#include "dirstream.h"
-libc_hidden_proto(lseek)
/* rewinddir() just does an lseek(fd,0,0) - see close for comments */
void rewinddir(DIR * dir)
diff --git a/libc/misc/dirent/scandir.c b/libc/misc/dirent/scandir.c
index aba63f20b..c036ce59b 100644
--- a/libc/misc/dirent/scandir.c
+++ b/libc/misc/dirent/scandir.c
@@ -1,30 +1,29 @@
+/* vi: set sw=4 ts=4: */
/*
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ * Copyright (C) 2000-2011 Erik Andersen <andersen@uclibc.org>
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
#include <dirent.h>
-#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
-#include <sys/types.h>
#include "dirstream.h"
-/* Experimentally off - libc_hidden_proto(memcpy) */
-libc_hidden_proto(readdir)
-libc_hidden_proto(opendir)
-libc_hidden_proto(closedir)
-libc_hidden_proto(qsort)
+#ifndef __SCANDIR
+# define __SCANDIR scandir
+# define __DIRENT_TYPE struct dirent
+# define __READDIR readdir
+#endif
-int scandir(const char *dir, struct dirent ***namelist,
- int (*selector) (const struct dirent *),
- int (*compar) (const void *, const void *))
+int __SCANDIR(const char *dir, __DIRENT_TYPE ***namelist,
+ int (*selector) (const __DIRENT_TYPE *),
+ int (*compar) (const __DIRENT_TYPE **, const __DIRENT_TYPE **))
{
DIR *dp = opendir (dir);
- struct dirent *current;
- struct dirent **names = NULL;
+ __DIRENT_TYPE *current;
+ __DIRENT_TYPE **names = NULL;
size_t names_size = 0, pos;
int save;
@@ -35,10 +34,21 @@ int scandir(const char *dir, struct dirent ***namelist,
__set_errno (0);
pos = 0;
- while ((current = readdir (dp)) != NULL)
- if (selector == NULL || (*selector) (current))
+ while ((current = __READDIR (dp)) != NULL) {
+ int use_it = selector == NULL;
+
+ if (! use_it)
+ {
+ use_it = (*selector) (current);
+ /* The selector function might have changed errno.
+ * It was zero before and it need to be again to make
+ * the latter tests work. */
+ if (! use_it)
+ __set_errno (0);
+ }
+ if (use_it)
{
- struct dirent *vnew;
+ __DIRENT_TYPE *vnew;
size_t dsize;
/* Ignore errors from selector or readdir */
@@ -46,24 +56,26 @@ int scandir(const char *dir, struct dirent ***namelist,
if (unlikely(pos == names_size))
{
- struct dirent **new;
+ __DIRENT_TYPE **new;
if (names_size == 0)
names_size = 10;
else
names_size *= 2;
- new = (struct dirent **) realloc (names, names_size * sizeof (struct dirent *));
+ new = (__DIRENT_TYPE **) realloc (names,
+ names_size * sizeof (__DIRENT_TYPE *));
if (new == NULL)
break;
names = new;
}
- dsize = &current->d_name[_D_ALLOC_NAMLEN (current)] - (char *) current;
- vnew = (struct dirent *) malloc (dsize);
+ dsize = &current->d_name[_D_ALLOC_NAMLEN(current)] - (char*)current;
+ vnew = (__DIRENT_TYPE *) malloc (dsize);
if (vnew == NULL)
break;
- names[pos++] = (struct dirent *) memcpy (vnew, current, dsize);
+ names[pos++] = (__DIRENT_TYPE *) memcpy (vnew, current, dsize);
}
+ }
if (unlikely(errno != 0))
{
@@ -81,7 +93,10 @@ int scandir(const char *dir, struct dirent ***namelist,
/* Sort the list if we have a comparison function to sort with. */
if (compar != NULL)
- qsort (names, pos, sizeof (struct dirent *), compar);
+ qsort (names, pos, sizeof (__DIRENT_TYPE *), (comparison_fn_t) compar);
*namelist = names;
return pos;
}
+#if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64
+strong_alias_untyped(scandir,scandir64)
+#endif
diff --git a/libc/misc/dirent/scandir64.c b/libc/misc/dirent/scandir64.c
index 083d2de18..634c5d886 100644
--- a/libc/misc/dirent/scandir64.c
+++ b/libc/misc/dirent/scandir64.c
@@ -1,105 +1,16 @@
-/* Copyright (C) 1992-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.
- */
-
-/* Modified for uClibc by Erik Andersen
- */
+/*
+ * Copyright (C) 2000-2011 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
#include <_lfs_64.h>
-
#include <dirent.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <sys/types.h>
-#include "dirstream.h"
-
-/* Experimentally off - libc_hidden_proto(memcpy) */
-libc_hidden_proto(opendir)
-libc_hidden_proto(closedir)
-libc_hidden_proto(qsort)
-libc_hidden_proto(readdir64)
-
-int scandir64(const char *dir, struct dirent64 ***namelist,
- int (*selector) (const struct dirent64 *),
- int (*compar) (const void *, const void *))
-{
- DIR *dp = opendir (dir);
- struct dirent64 *current;
- struct dirent64 **names = NULL;
- size_t names_size = 0, pos;
- int save;
-
- if (dp == NULL)
- return -1;
-
- save = errno;
- __set_errno (0);
-
- pos = 0;
- while ((current = readdir64 (dp)) != NULL)
- if (selector == NULL || (*selector) (current))
- {
- struct dirent64 *vnew;
- size_t dsize;
-
- /* Ignore errors from selector or readdir64 */
- __set_errno (0);
-
- if (unlikely(pos == names_size))
- {
- struct dirent64 **new;
- if (names_size == 0)
- names_size = 10;
- else
- names_size *= 2;
- new = (struct dirent64 **) realloc (names, names_size * sizeof (struct dirent64 *));
- if (new == NULL)
- break;
- names = new;
- }
-
- dsize = &current->d_name[_D_ALLOC_NAMLEN (current)] - (char *) current;
- vnew = (struct dirent64 *) malloc (dsize);
- if (vnew == NULL)
- break;
-
- names[pos++] = (struct dirent64 *) memcpy (vnew, current, dsize);
- }
-
- if (unlikely(errno != 0))
- {
- save = errno;
- closedir (dp);
- while (pos > 0)
- free (names[--pos]);
- free (names);
- __set_errno (save);
- return -1;
- }
- closedir (dp);
- __set_errno (save);
+#if __WORDSIZE != 64
+# define __SCANDIR scandir64
+# define __DIRENT_TYPE struct dirent64
+# define __READDIR readdir64
- /* Sort the list if we have a comparison function to sort with. */
- if (compar != NULL)
- qsort (names, pos, sizeof (struct dirent64 *), compar);
- *namelist = names;
- return pos;
-}
+# include "scandir.c"
+#endif
diff --git a/libc/misc/dirent/seekdir.c b/libc/misc/dirent/seekdir.c
index c41844856..eaf447ea2 100644
--- a/libc/misc/dirent/seekdir.c
+++ b/libc/misc/dirent/seekdir.c
@@ -9,7 +9,6 @@
#include <unistd.h>
#include "dirstream.h"
-libc_hidden_proto(lseek)
void seekdir(DIR * dir, long int offset)
{
diff --git a/libc/misc/dirent/versionsort.c b/libc/misc/dirent/versionsort.c
new file mode 100644
index 000000000..8e56ec56b
--- /dev/null
+++ b/libc/misc/dirent/versionsort.c
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2008-2009 Hai Zaar, Codefidence Ltd <haizaar@codefidence.com>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <dirent.h>
+#include <string.h>
+#include "dirstream.h"
+
+int versionsort(const struct dirent **a, const struct dirent **b)
+{
+ return strverscmp((*a)->d_name, (*b)->d_name);
+}
+#if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64
+strong_alias_untyped(versionsort,versionsort64)
+#endif
diff --git a/libc/misc/dirent/versionsort64.c b/libc/misc/dirent/versionsort64.c
new file mode 100644
index 000000000..28fef7d3f
--- /dev/null
+++ b/libc/misc/dirent/versionsort64.c
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) 2008-2009 Hai Zaar, Codefidence Ltd <haizaar@codefidence.com>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <_lfs_64.h>
+#include <dirent.h>
+
+#if __WORDSIZE != 64
+# include <string.h>
+# include "dirstream.h"
+
+int versionsort64(const struct dirent64 **a, const struct dirent64 **b)
+{
+ return strverscmp((*a)->d_name, (*b)->d_name);
+}
+#endif
diff --git a/libc/misc/elf/Makefile b/libc/misc/elf/Makefile
new file mode 100644
index 000000000..4bb6872a1
--- /dev/null
+++ b/libc/misc/elf/Makefile
@@ -0,0 +1,12 @@
+# Copyright (C) 2008 STMicroelectronics Ltd.
+# Author: Carmelo Amoroso <carmelo.amoroso@st.com>
+
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+top_srcdir=../../../
+top_builddir=../../../
+all: objs
+include $(top_builddir)Rules.mak
+include Makefile.in
+include $(top_srcdir)Makerules
diff --git a/libc/misc/elf/Makefile.in b/libc/misc/elf/Makefile.in
new file mode 100644
index 000000000..1b4bd8bf1
--- /dev/null
+++ b/libc/misc/elf/Makefile.in
@@ -0,0 +1,22 @@
+# Copyright (C) 2008 STMicroelectronics Ltd.
+# Author: Carmelo Amoroso <carmelo.amoroso@st.com>
+
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+subdirs += libc/misc/elf
+
+libc_a_CSRC = dl-support.c dl-core.c dl-iterate-phdr.c
+CFLAGS-dl-iterate-phdr.c=-D_GNU_SOURCE -I$(top_srcdir)ldso/ldso/$(TARGET_ARCH) -I$(top_srcdir)ldso/include
+CFLAGS-dl-core.c=-I$(top_srcdir)ldso/ldso/$(TARGET_ARCH) -I$(top_srcdir)ldso/include
+
+MISC_ELF_OUT:=$(top_builddir)libc/misc/elf
+MISC_ELF_OBJ:=$(patsubst %.c,$(MISC_ELF_OUT)/%.o,$(libc_a_CSRC))
+
+libc-static-y += $(MISC_ELF_OBJ)
+libc-shared-y += $(MISC_ELF_OUT)/dl-iterate-phdr.oS
+
+objclean-y+= CLEAN_libc/misc/elf
+
+CLEAN_libc/misc/elf:
+ $(do_rm) $(addprefix $(MISC_ELF_OUT)/*., o os oS)
diff --git a/libc/misc/elf/dl-core.c b/libc/misc/elf/dl-core.c
new file mode 100644
index 000000000..b32dcf828
--- /dev/null
+++ b/libc/misc/elf/dl-core.c
@@ -0,0 +1,20 @@
+/*
+ * This contains all symbols and functions to support
+ * dynamic linking into static libc.
+
+ * Copyright (c) 2008 STMicroelectronics Ltd
+ * Author: Carmelo Amoroso <carmelo.amoroso@st.com>
+ *
+ * Based on draft work by Peter S. Mazinger <ps.m@gmx.net>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ *
+ */
+
+#ifdef SHARED
+#error "This file is not suitable for linking into dynamic libc"
+#else
+/* Include ldso symbols and functions used into static libc */
+#include "../../../ldso/ldso/dl-symbols.c"
+#endif
+
diff --git a/libc/misc/elf/dl-iterate-phdr.c b/libc/misc/elf/dl-iterate-phdr.c
new file mode 100644
index 000000000..27a92544b
--- /dev/null
+++ b/libc/misc/elf/dl-iterate-phdr.c
@@ -0,0 +1,81 @@
+/* Get loaded objects program headers.
+
+ Based on GNU C library (file: libc/elf/dl-iteratephdr.c)
+
+ Copyright (C) 2001,2002,2003,2004,2006,2007 Free Software Foundation, Inc.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2001.
+
+ Copyright (C) 2008 STMicroelectronics Ltd.
+ Author: Carmelo Amoroso <carmelo.amoroso@st.com>
+
+ Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+*/
+
+
+#include <link.h>
+#include <ldso.h>
+
+/* we want this in libc but nowhere else */
+#ifdef __USE_GNU
+
+static int
+__dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info, size_t size, void *data), void *data)
+{
+ int ret = 0;
+#ifndef __ARCH_HAS_NO_SHARED__
+ struct elf_resolve *l;
+ struct dl_phdr_info info;
+
+ for (l = _dl_loaded_modules; l != NULL; l = l->next) {
+ info.dlpi_addr = l->loadaddr;
+ info.dlpi_name = l->libname;
+ info.dlpi_phdr = l->ppnt;
+ info.dlpi_phnum = l->n_phent;
+ ret = callback (&info, sizeof (struct dl_phdr_info), data);
+ if (ret)
+ break;
+ }
+#endif
+ return ret;
+}
+
+# ifdef SHARED
+
+weak_alias(__dl_iterate_phdr, dl_iterate_phdr)
+
+# else
+
+/* dl-support.c defines these and initializes them early on. */
+extern ElfW(Phdr) *_dl_phdr;
+extern size_t _dl_phnum;
+
+int
+dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info,
+ size_t size, void *data), void *data)
+{
+ if (_dl_phnum != 0)
+ {
+ /* This entry describes this statically-linked program itself. */
+ struct dl_phdr_info info;
+ int ret;
+#if defined(__FRV_FDPIC__) || defined(__BFIN_FDPIC__)
+ info.dlpi_addr.map = NULL;
+ info.dlpi_addr.got_value = NULL;
+#elif defined(__DSBT__)
+ info.dlpi_addr.map = NULL;
+#else
+ info.dlpi_addr = 0;
+#endif
+ info.dlpi_name = "";
+ info.dlpi_phdr = _dl_phdr;
+ info.dlpi_phnum = _dl_phnum;
+ ret = (*callback) (&info, sizeof (struct dl_phdr_info), data);
+ if (ret)
+ return ret;
+ }
+ /* Then invoke callback on loaded modules, if any */
+ return __dl_iterate_phdr (callback, data);
+}
+
+# endif
+#endif
diff --git a/libc/misc/elf/dl-support.c b/libc/misc/elf/dl-support.c
new file mode 100644
index 000000000..87cd1bb72
--- /dev/null
+++ b/libc/misc/elf/dl-support.c
@@ -0,0 +1,75 @@
+/*
+ * Support for dynamic linking code in static libc.
+ * Copyright (C) 1996-2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ *
+ * Partially based on GNU C Library (file: libc/elf/dl-support.c)
+ *
+ * Copyright (C) 2008 STMicroelectronics Ltd.
+ * Author: Carmelo Amoroso <carmelo.amoroso@st.com>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ *
+ */
+
+#include <link.h>
+#include <elf.h>
+#if defined(USE_TLS) && USE_TLS
+#include <assert.h>
+#include <tls.h>
+#include <ldsodefs.h>
+#include <string.h>
+#endif
+#include <bits/uClibc_page.h>
+
+#if defined(USE_TLS) && USE_TLS
+
+void (*_dl_init_static_tls) (struct link_map *) = &_dl_nothread_init_static_tls;
+
+#endif
+
+ElfW(Phdr) *_dl_phdr;
+size_t _dl_phnum;
+size_t _dl_pagesize;
+
+void internal_function _dl_aux_init (ElfW(auxv_t) *av);
+void internal_function _dl_aux_init (ElfW(auxv_t) *av)
+{
+ /* Get the program headers base address from the aux vect */
+ _dl_phdr = (ElfW(Phdr) *) av[AT_PHDR].a_un.a_val;
+
+ /* Get the number of program headers from the aux vect */
+ _dl_phnum = (size_t) av[AT_PHNUM].a_un.a_val;
+
+ /* Get the pagesize from the aux vect */
+ _dl_pagesize = (av[AT_PAGESZ].a_un.a_val) ? (size_t) av[AT_PAGESZ].a_un.a_val : PAGE_SIZE;
+}
+
+#if defined(USE_TLS) && USE_TLS
+/* Initialize static TLS area and DTV for current (only) thread.
+ libpthread implementations should provide their own hook
+ to handle all threads. */
+void
+attribute_hidden
+_dl_nothread_init_static_tls (struct link_map *map)
+{
+# if defined(TLS_TCB_AT_TP)
+ void *dest = (char *) THREAD_SELF - map->l_tls_offset;
+# elif defined(TLS_DTV_AT_TP)
+ void *dest = (char *) THREAD_SELF + map->l_tls_offset + TLS_PRE_TCB_SIZE;
+# else
+# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
+# endif
+
+ /* Fill in the DTV slot so that a later LD/GD access will find it. */
+ dtv_t *dtv = THREAD_DTV ();
+ assert (map->l_tls_modid <= dtv[-1].counter);
+ dtv[map->l_tls_modid].pointer.val = dest;
+ dtv[map->l_tls_modid].pointer.is_static = true;
+
+ /* Initialize the memory. */
+ memset (mempcpy (dest, map->l_tls_initimage, map->l_tls_initimage_size),
+ '\0', map->l_tls_blocksize - map->l_tls_initimage_size);
+}
+
+#endif
+
diff --git a/libc/misc/error/Makefile.in b/libc/misc/error/Makefile.in
index 9facacff0..fa959c131 100644
--- a/libc/misc/error/Makefile.in
+++ b/libc/misc/error/Makefile.in
@@ -1,27 +1,25 @@
# 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.
#
-CSRC :=
-ifeq ($(UCLIBC_HAS_BSD_ERR),y)
-CSRC += err.c
-endif
-ifeq ($(UCLIBC_HAS_GNU_ERROR),y)
-CSRC += error.c
-endif
+subdirs += libc/misc/error
+
+CSRC-y :=
+CSRC-$(UCLIBC_HAS_BSD_ERR) += err.c
+CSRC-$(UCLIBC_HAS_GNU_ERROR) += error.c
MISC_ERROR_DIR := $(top_srcdir)libc/misc/error
MISC_ERROR_OUT := $(top_builddir)libc/misc/error
-MISC_ERROR_SRC := $(patsubst %.c,$(MISC_ERROR_DIR)/%.c,$(CSRC))
-MISC_ERROR_OBJ := $(patsubst %.c,$(MISC_ERROR_OUT)/%.o,$(CSRC))
+MISC_ERROR_SRC := $(patsubst %.c,$(MISC_ERROR_DIR)/%.c,$(CSRC-y))
+MISC_ERROR_OBJ := $(patsubst %.c,$(MISC_ERROR_OUT)/%.o,$(CSRC-y))
libc-y += $(MISC_ERROR_OBJ)
-objclean-y += misc_error_objclean
+objclean-y += CLEAN_libc/misc/error
-misc_error_objclean:
- $(RM) $(MISC_ERROR_OUT)/*.{o,os}
+CLEAN_libc/misc/error:
+ $(do_rm) $(addprefix $(MISC_ERROR_OUT)/*., o os)
diff --git a/libc/misc/error/err.c b/libc/misc/error/err.c
index ab9c8b72b..4f1e6a33f 100644
--- a/libc/misc/error/err.c
+++ b/libc/misc/error/err.c
@@ -11,9 +11,6 @@
#include <stdarg.h>
#include <errno.h>
#include <err.h>
-#ifdef __UCLIBC_HAS_THREADS__
-#include <pthread.h>
-#endif
#ifdef __UCLIBC_MJN3_ONLY__
#warning REMINDER: Deal with wide oriented stderr case.
@@ -21,16 +18,7 @@
#if defined __USE_BSD
-libc_hidden_proto(vwarn)
-libc_hidden_proto(vwarnx)
-libc_hidden_proto(verr)
-libc_hidden_proto(verrx)
-libc_hidden_proto(fprintf)
-libc_hidden_proto(vfprintf)
-libc_hidden_proto(__xpg_strerror_r)
-libc_hidden_proto(exit)
-libc_hidden_proto(vfprintf)
static void vwarn_work(const char *format, va_list args, int showerr)
{
@@ -59,68 +47,68 @@ static void vwarn_work(const char *format, va_list args, int showerr)
__STDIO_AUTO_THREADUNLOCK(stderr);
}
-void vwarn(const char *format, va_list args)
+static void __vwarn(const char *format, va_list args)
{
vwarn_work(format, args, 1);
}
-libc_hidden_def(vwarn)
+strong_alias(__vwarn,vwarn)
void warn(const char *format, ...)
{
va_list args;
va_start(args, format);
- vwarn(format, args);
+ __vwarn(format, args);
va_end(args);
}
-void vwarnx(const char *format, va_list args)
+static void __vwarnx(const char *format, va_list args)
{
vwarn_work(format, args, 0);
}
-libc_hidden_def(vwarnx)
+strong_alias(__vwarnx,vwarnx)
void warnx(const char *format, ...)
{
va_list args;
va_start(args, format);
- vwarnx(format, args);
+ __vwarnx(format, args);
va_end(args);
}
-void verr(int status, const char *format, va_list args)
+static void attribute_noreturn __verr(int status, const char *format, va_list args)
{
- vwarn(format, args);
+ __vwarn(format, args);
exit(status);
}
-libc_hidden_def(verr)
+strong_alias(__verr,verr)
-void attribute_noreturn err(int status, const char *format, ...)
+void err(int status, const char *format, ...)
{
va_list args;
va_start(args, format);
- verr(status, format, args);
+ __verr(status, format, args);
/* This should get optimized away. We'll leave it now for safety. */
/* The loop is added only to keep gcc happy. */
while(1)
va_end(args);
}
-void verrx(int status, const char *format, va_list args)
+static void attribute_noreturn __verrx(int status, const char *format, va_list args)
{
- vwarnx(format, args);
+ __vwarnx(format, args);
exit(status);
}
-libc_hidden_def(verrx)
+strong_alias(__verrx,verrx)
-void attribute_noreturn errx(int status, const char *format, ...)
+void errx(int status, const char *format, ...)
{
va_list args;
va_start(args, format);
- verrx(status, format, args);
+ __verrx(status, format, args);
/* This should get optimized away. We'll leave it now for safety. */
/* The loop is added only to keep gcc happy. */
while(1)
diff --git a/libc/misc/error/error.c b/libc/misc/error/error.c
index ed4a62ef6..d78a6f54e 100644
--- a/libc/misc/error/error.c
+++ b/libc/misc/error/error.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/>. */
/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
/* Adjusted slightly by Erik Andersen <andersen@uclibc.org> */
@@ -26,15 +25,6 @@
#include <string.h>
#include <error.h>
-/* Experimentally off - libc_hidden_proto(strcmp) */
-/* Experimentally off - libc_hidden_proto(strerror) */
-libc_hidden_proto(fprintf)
-libc_hidden_proto(exit)
-libc_hidden_proto(putc)
-libc_hidden_proto(vfprintf)
-libc_hidden_proto(fflush)
-libc_hidden_proto(fputc)
-libc_hidden_proto(__fputc_unlocked)
/* This variable is incremented each time `error' is called. */
unsigned int error_message_count = 0;
@@ -46,8 +36,7 @@ int error_one_per_line;
function without parameters instead. */
void (*error_print_progname) (void) = NULL;
-extern __typeof(error) __error attribute_hidden;
-void __error (int status, int errnum, const char *message, ...)
+void error (int status, int errnum, const char *message, ...)
{
va_list args;
@@ -69,11 +58,9 @@ void __error (int status, int errnum, const char *message, ...)
if (status)
exit (status);
}
-weak_alias(__error,error)
-extern __typeof(error_at_line) __error_at_line attribute_hidden;
-void __error_at_line (int status, int errnum, const char *file_name,
- unsigned int line_number, const char *message, ...)
+void error_at_line (int status, int errnum, const char *file_name,
+ unsigned int line_number, const char *message, ...)
{
va_list args;
@@ -112,4 +99,3 @@ void __error_at_line (int status, int errnum, const char *file_name,
if (status)
exit (status);
}
-weak_alias(__error_at_line,error_at_line)
diff --git a/libc/misc/file/Makefile.in b/libc/misc/file/Makefile.in
index 721fe5ec0..b94efa67f 100644
--- a/libc/misc/file/Makefile.in
+++ b/libc/misc/file/Makefile.in
@@ -1,24 +1,26 @@
# 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.
#
+subdirs += libc/misc/file
+
MISC_FILE_DIR := $(top_srcdir)libc/misc/file
MISC_FILE_OUT := $(top_builddir)libc/misc/file
-MISC_FILE_SRC := $(wildcard $(MISC_FILE_DIR)/*.c)
-ifneq ($(UCLIBC_HAS_LFS),y)
-MISC_FILE_SRC := $(filter-out $(MISC_FILE_DIR)/lockf64.c,$(MISC_FILE_SRC))
-endif
-MISC_FILE_OBJ := $(patsubst $(MISC_FILE_DIR)/%.c,$(MISC_FILE_OUT)/%.o,$(MISC_FILE_SRC))
+CSRC-y := $(wildcard $(MISC_FILE_DIR)/*.c)
+CSRC_LFS := $(wildcard $(MISC_FILE_DIR)/*64.c)
+CSRC-y := $(filter-out $(CSRC_LFS),$(CSRC-y))
+CSRC-$(UCLIBC_HAS_LFS) += $(CSRC_LFS)
+MISC_FILE_OBJ := $(patsubst $(MISC_FILE_DIR)/%.c,$(MISC_FILE_OUT)/%.o,$(CSRC-y))
libc-y += $(MISC_FILE_OBJ)
libc-nomulti-$(UCLIBC_HAS_LFS) += $(MISC_FILE_OUT)/lockf64.o
-objclean-y += misc_file_objclean
+objclean-y += CLEAN_libc/misc/file
-misc_file_objclean:
- $(RM) $(MISC_FILE_OUT)/*.{o,os,oS}
+CLEAN_libc/misc/file:
+ $(do_rm) $(addprefix $(MISC_FILE_OUT)/*., o os oS)
diff --git a/libc/misc/file/isfdtype.c b/libc/misc/file/isfdtype.c
new file mode 100644
index 000000000..4d9199bd1
--- /dev/null
+++ b/libc/misc/file/isfdtype.c
@@ -0,0 +1,40 @@
+/* Determine whether descriptor has given property.
+ Copyright (C) 1996-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/>. */
+
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#ifdef __UCLIBC_HAS_LFS__
+# include <_lfs_64.h>
+#else
+# define stat64 stat
+# define fstat64 fstat
+#endif
+
+int
+isfdtype (int fildes, int fdtype)
+{
+ struct stat64 st;
+ int save_error = errno;
+ int result = fstat64 (fildes, &st);
+ __set_errno (save_error);
+ if (result)
+ return result;
+ return (st.st_mode & S_IFMT) == (mode_t) fdtype;
+}
diff --git a/libc/misc/file/issetugid.c b/libc/misc/file/issetugid.c
new file mode 100644
index 000000000..6756a1e85
--- /dev/null
+++ b/libc/misc/file/issetugid.c
@@ -0,0 +1,10 @@
+/* Copyright (C) 2013 Gentoo Foundation
+ * Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <unistd.h>
+
+int issetugid(void)
+{
+ return _pe_secure;
+}
diff --git a/libc/misc/file/lockf.c b/libc/misc/file/lockf.c
index 13b56aba4..56b3aac77 100644
--- a/libc/misc/file/lockf.c
+++ b/libc/misc/file/lockf.c
@@ -13,23 +13,15 @@
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/types.h>
-#include <unistd.h>
#include <fcntl.h>
+#include <unistd.h>
#include <errno.h>
#include <string.h>
-libc_hidden_proto(lockf)
-
-/* Experimentally off - libc_hidden_proto(memset) */
-libc_hidden_proto(fcntl)
-libc_hidden_proto(getpid)
-
/* lockf is a simplified interface to fcntl's locking facilities. */
int lockf (int fd, int cmd, off_t len)
diff --git a/libc/misc/file/lockf64.c b/libc/misc/file/lockf64.c
index b2ffe5d8c..8d950ed8b 100644
--- a/libc/misc/file/lockf64.c
+++ b/libc/misc/file/lockf64.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/>. */
#include <_lfs_64.h>
@@ -32,17 +31,12 @@
#define F_GETLK F_GETLK64
#undef F_SETLK
#define F_SETLK F_SETLK64
-libc_hidden_proto(fcntl64)
#else
-libc_hidden_proto(fcntl)
#endif
-/* Experimentally off - libc_hidden_proto(memset) */
-libc_hidden_proto(getpid)
/* lockf is a simplified interface to fcntl's locking facilities. */
-libc_hidden_proto(lockf64)
int lockf64 (int fd, int cmd, off64_t len64)
{
struct flock fl;
@@ -95,4 +89,3 @@ int lockf64 (int fd, int cmd, off64_t len64)
return fcntl(fd, cmd, &fl);
}
-libc_hidden_def(lockf64)
diff --git a/libc/misc/fnmatch/Makefile.in b/libc/misc/fnmatch/Makefile.in
index c31de9cd6..ab43e00f1 100644
--- a/libc/misc/fnmatch/Makefile.in
+++ b/libc/misc/fnmatch/Makefile.in
@@ -1,25 +1,23 @@
# 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.
#
-ifeq ($(UCLIBC_HAS_FNMATCH_OLD),y)
-CSRC := fnmatch_old.c
-else
-CSRC := fnmatch.c
-endif
+subdirs += libc/misc/fnmatch
+
+CSRC-y := $(if $(UCLIBC_HAS_FNMATCH_OLD),fnmatch_old.c,fnmatch.c)
MISC_FNMATCH_DIR := $(top_srcdir)libc/misc/fnmatch
MISC_FNMATCH_OUT := $(top_builddir)libc/misc/fnmatch
-MISC_FNMATCH_SRC := $(patsubst %.c,$(MISC_FNMATCH_DIR)/%.c,$(CSRC))
-MISC_FNMATCH_OBJ := $(patsubst %.c,$(MISC_FNMATCH_OUT)/%.o,$(CSRC))
+MISC_FNMATCH_SRC := $(patsubst %.c,$(MISC_FNMATCH_DIR)/%.c,$(CSRC-y))
+MISC_FNMATCH_OBJ := $(patsubst %.c,$(MISC_FNMATCH_OUT)/%.o,$(CSRC-y))
libc-$(UCLIBC_HAS_FNMATCH) += $(MISC_FNMATCH_OBJ)
-objclean-y += misc_fnmatch_objclean
+objclean-y += CLEAN_libc/misc/fnmatch
-misc_fnmatch_objclean:
- $(RM) $(MISC_FNMATCH_OUT)/*.{o,os}
+CLEAN_libc/misc/fnmatch:
+ $(do_rm) $(addprefix $(MISC_FNMATCH_OUT)/*., o os)
diff --git a/libc/misc/fnmatch/fnmatch.c b/libc/misc/fnmatch/fnmatch.c
index 8592d4cf6..d54b6e7c7 100644
--- a/libc/misc/fnmatch/fnmatch.c
+++ b/libc/misc/fnmatch/fnmatch.c
@@ -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/>. */
-#if HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
+/* unistd.h must be included with _LIBC defined: we need smallint */
+#include <unistd.h>
#include <features.h>
#ifdef __UCLIBC__
# undef _LIBC
@@ -41,7 +42,6 @@
#include <errno.h>
#include <fnmatch.h>
#include <ctype.h>
-#include <unistd.h>
#if HAVE_STRING_H || defined _LIBC
# include <string.h>
@@ -53,51 +53,12 @@
# include <stdlib.h>
#endif
-#ifdef __UCLIBC__
-#define __memset memset
-/* Experimentally off - libc_hidden_proto(memchr) */
-/* Experimentally off - libc_hidden_proto(memset) */
-/* Experimentally off - libc_hidden_proto(mempcpy) */
-/* Experimentally off - libc_hidden_proto(strcat) */
-/* Experimentally off - libc_hidden_proto(strcmp) */
-/*libc_hidden_proto(strchr)*/
-/*libc_hidden_proto(strchrnul)*/
-/* Experimentally off - libc_hidden_proto(strlen) */
-/* Experimentally off - libc_hidden_proto(strcoll) */
-#ifdef __UCLIBC_HAS_XLOCALE__
-libc_hidden_proto(__ctype_b_loc)
-libc_hidden_proto(__ctype_tolower_loc)
-#elif defined __UCLIBC_HAS_CTYPE_TABLES__
-libc_hidden_proto(__ctype_b)
-libc_hidden_proto(__ctype_tolower)
-#endif
-libc_hidden_proto(tolower)
-libc_hidden_proto(fnmatch)
-libc_hidden_proto(getenv)
-#endif
-
/* For platform which support the ISO C amendement 1 functionality we
support user defined character classes. */
#if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H)
/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. */
# include <wchar.h>
# include <wctype.h>
-# ifdef __UCLIBC__
-libc_hidden_proto(wctype)
-libc_hidden_proto(iswctype)
-libc_hidden_proto(btowc)
-# ifdef __UCLIBC_HAS_LOCALE__
-libc_hidden_proto(wmemchr)
-libc_hidden_proto(wmempcpy)
-libc_hidden_proto(wcscat)
-/*libc_hidden_proto(wcschr)*/
-/*libc_hidden_proto(wcschrnul)*/
-libc_hidden_proto(wcslen)
-libc_hidden_proto(wcscoll)
-libc_hidden_proto(towlower)
-libc_hidden_proto(mbsrtowcs)
-# endif
-# endif
#endif
/* We need some of the locale data (the collation sequence information)
@@ -368,13 +329,6 @@ is_char_class (const wchar_t *wcs)
# include "fnmatch_loop.c"
# endif
-#ifdef __UCLIBC_HAS_WCHAR__
-libc_hidden_proto(_stdlib_mb_cur_max)
-#else
-#undef MB_CUR_MAX
-#define MB_CUR_MAX 1
-#endif
-
int
fnmatch (const char *pattern, const char *string, int flags)
{
@@ -388,7 +342,7 @@ fnmatch (const char *pattern, const char *string, int flags)
wchar_t *wstring = NULL;
/* Convert the strings into wide characters. */
- __memset (&ps, '\0', sizeof (ps));
+ memset (&ps, '\0', sizeof (ps));
p = pattern;
#ifdef _LIBC
n = strnlen (pattern, 1024);
@@ -405,7 +359,7 @@ fnmatch (const char *pattern, const char *string, int flags)
already done? */
return -1;
if (p)
- __memset (&ps, '\0', sizeof (ps));
+ memset (&ps, '\0', sizeof (ps));
}
if (__builtin_expect (p != NULL, 0))
{
@@ -437,7 +391,7 @@ fnmatch (const char *pattern, const char *string, int flags)
already done? */
return -1;
if (p)
- __memset (&ps, '\0', sizeof (ps));
+ memset (&ps, '\0', sizeof (ps));
}
if (__builtin_expect (p != NULL, 0))
{
diff --git a/libc/misc/fnmatch/fnmatch_loop.c b/libc/misc/fnmatch/fnmatch_loop.c
index af41727c0..6d037f8f9 100644
--- a/libc/misc/fnmatch/fnmatch_loop.c
+++ b/libc/misc/fnmatch/fnmatch_loop.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/>. */
/* Match STRING against the filename pattern PATTERN, returning zero if
it matches, nonzero if not. */
@@ -508,7 +507,7 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
if (symb_table[2 * elem] == hash
&& (c1
== extra[symb_table[2 * elem + 1]])
- && __memcmp (str,
+ && memcmp (str,
&extra[symb_table[2 * elem
+ 1]
+ 1], c1) == 0)
@@ -729,7 +728,7 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
if (symb_table[2 * elem] == hash
&& (c1
== extra[symb_table[2 * elem + 1]])
- && __memcmp (str,
+ && memcmp (str,
&extra[symb_table[2 * elem + 1]
+ 1], c1) == 0)
{
diff --git a/libc/misc/fnmatch/fnmatch_old.c b/libc/misc/fnmatch/fnmatch_old.c
index 577e35676..8da456333 100644
--- a/libc/misc/fnmatch/fnmatch_old.c
+++ b/libc/misc/fnmatch/fnmatch_old.c
@@ -12,10 +12,9 @@ Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this 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/>. */
-#if HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
@@ -23,9 +22,7 @@ Cambridge, MA 02139, USA. */
#include <fnmatch.h>
#include <ctype.h>
-libc_hidden_proto(fnmatch)
-libc_hidden_proto(tolower)
/* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself. This code is part of the GNU C
Library, but also included in many other GNU distributions. Compiling
diff --git a/libc/misc/fts/Makefile b/libc/misc/fts/Makefile
new file mode 100644
index 000000000..1361db3e0
--- /dev/null
+++ b/libc/misc/fts/Makefile
@@ -0,0 +1,14 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2009 STMicroelectronics Ltd.
+# Author: Salvatore Cro <salvatore.cro at st.com>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+top_srcdir=../../../
+top_builddir=../../../
+all: objs
+include $(top_builddir)Rules.mak
+include Makefile.in
+include $(top_srcdir)Makerules
diff --git a/libc/misc/fts/Makefile.in b/libc/misc/fts/Makefile.in
new file mode 100644
index 000000000..aa87d993a
--- /dev/null
+++ b/libc/misc/fts/Makefile.in
@@ -0,0 +1,23 @@
+# FTS Makefile for uClibc
+#
+# Copyright (C) 2009 STMicroelectronics Ltd.
+# Author: Salvatore Cro <salvatore.cro at st.com>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+subdirs += libc/misc/fts
+CSRC-y := fts.c
+
+MISC_FTS_DIR := $(top_srcdir)libc/misc/fts
+MISC_FTS_OUT := $(top_builddir)libc/misc/fts
+
+MISC_FTS_SRC := $(patsubst %.c,$(MISC_FTS_DIR)/%.c,$(CSRC-y))
+MISC_FTS_OBJ := $(patsubst %.c,$(MISC_FTS_OUT)/%.o,$(CSRC-y))
+
+libc-$(UCLIBC_HAS_FTS) += $(MISC_FTS_OBJ)
+
+objclean-y += CLEAN_libc/misc/fts
+
+CLEAN_libc/misc/fts:
+ $(do_rm) $(addprefix $(MISC_FTS_OUT)/*., o os)
diff --git a/libc/misc/fts/fts.c b/libc/misc/fts/fts.c
new file mode 100644
index 000000000..7dc67683b
--- /dev/null
+++ b/libc/misc/fts/fts.c
@@ -0,0 +1,1114 @@
+/*-
+ * Copyright (c) 1990, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fts.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#ifdef __UCLIBC_HAS_LFS__
+/* this is wrong, either you include this header as first, or not at all */
+# include <_lfs_64.h>
+#else
+# define stat64 stat
+# define fstat64 fstat
+#endif
+
+/* Largest alignment size needed, minus one.
+ Usually long double is the worst case. */
+#ifndef ALIGNBYTES
+#define ALIGNBYTES (__alignof__ (long double) - 1)
+#endif
+/* Align P to that size. */
+#ifndef ALIGN
+#define ALIGN(p) (((unsigned long int) (p) + ALIGNBYTES) & ~ALIGNBYTES)
+#endif
+
+
+static FTSENT *fts_alloc (FTS *, const char *, size_t) internal_function;
+static FTSENT *fts_build (FTS *, int) internal_function;
+static void fts_lfree (FTSENT *) internal_function;
+static void fts_load (FTS *, FTSENT *) internal_function;
+static size_t fts_maxarglen (char * const *) internal_function;
+static void fts_padjust (FTS *, FTSENT *) internal_function;
+static int fts_palloc (FTS *, size_t) internal_function;
+static FTSENT *fts_sort (FTS *, FTSENT *, int) internal_function;
+static u_short fts_stat (FTS *, FTSENT *, int) internal_function;
+static int fts_safe_changedir (FTS *, FTSENT *, int, const char *)
+ internal_function;
+
+#ifndef MAX
+#define MAX(a, b) ({ __typeof__ (a) _a = (a); \
+ __typeof__ (b) _b = (b); \
+ _a > _b ? _a : _b; })
+#endif
+
+#define ISDOT(a) (a[0] == '.' && (!a[1] || (a[1] == '.' && !a[2])))
+
+#define CLR(opt) (sp->fts_options &= ~(opt))
+#define ISSET(opt) (sp->fts_options & (opt))
+#define SET(opt) (sp->fts_options |= (opt))
+
+#define FCHDIR(sp, fd) (!ISSET(FTS_NOCHDIR) && fchdir(fd))
+
+/* fts_build flags */
+#define BCHILD 1 /* fts_children */
+#define BNAMES 2 /* fts_children, names only */
+#define BREAD 3 /* fts_read */
+
+FTS *
+fts_open( char * const *argv, register int options,
+ int (*compar) (const FTSENT **, const FTSENT **))
+{
+ register FTS *sp;
+ register FTSENT *p, *root;
+ register int nitems;
+ FTSENT *parent = NULL;
+ FTSENT *tmp = NULL;
+
+ /* Options check. */
+ if (options & ~FTS_OPTIONMASK) {
+ __set_errno (EINVAL);
+ return (NULL);
+ }
+
+ /* Allocate/initialize the stream */
+ if ((sp = malloc((u_int)sizeof(FTS))) == NULL)
+ return (NULL);
+ memset(sp, 0, sizeof(FTS));
+ sp->fts_compar = (int (*) (const void *, const void *)) compar;
+ sp->fts_options = options;
+
+ /* Logical walks turn on NOCHDIR; symbolic links are too hard. */
+ if (ISSET(FTS_LOGICAL))
+ SET(FTS_NOCHDIR);
+
+ /*
+ * Start out with 1K of path space, and enough, in any case,
+ * to hold the user's paths.
+ */
+#ifndef MAXPATHLEN
+#define MAXPATHLEN 1024
+#endif
+ size_t maxarglen = fts_maxarglen(argv);
+ if (fts_palloc(sp, MAX(maxarglen, MAXPATHLEN)))
+ goto mem1;
+
+ /* Allocate/initialize root's parent. */
+ if (*argv != NULL) {
+ if ((parent = fts_alloc(sp, "", 0)) == NULL)
+ goto mem2;
+ parent->fts_level = FTS_ROOTPARENTLEVEL;
+ }
+
+ /* Allocate/initialize root(s). */
+ for (root = NULL, nitems = 0; *argv != NULL; ++argv, ++nitems) {
+ /* Don't allow zero-length paths. */
+ size_t len = strlen(*argv);
+ if (len == 0) {
+ __set_errno (ENOENT);
+ goto mem3;
+ }
+
+ p = fts_alloc(sp, *argv, len);
+ p->fts_level = FTS_ROOTLEVEL;
+ p->fts_parent = parent;
+ p->fts_accpath = p->fts_name;
+ p->fts_info = fts_stat(sp, p, ISSET(FTS_COMFOLLOW));
+
+ /* Command-line "." and ".." are real directories. */
+ if (p->fts_info == FTS_DOT)
+ p->fts_info = FTS_D;
+
+ /*
+ * If comparison routine supplied, traverse in sorted
+ * order; otherwise traverse in the order specified.
+ */
+ if (compar) {
+ p->fts_link = root;
+ root = p;
+ } else {
+ p->fts_link = NULL;
+ if (root == NULL)
+ tmp = root = p;
+ else {
+ tmp->fts_link = p;
+ tmp = p;
+ }
+ }
+ }
+ if (compar && nitems > 1)
+ root = fts_sort(sp, root, nitems);
+
+ /*
+ * Allocate a dummy pointer and make fts_read think that we've just
+ * finished the node before the root(s); set p->fts_info to FTS_INIT
+ * so that everything about the "current" node is ignored.
+ */
+ if ((sp->fts_cur = fts_alloc(sp, "", 0)) == NULL)
+ goto mem3;
+ sp->fts_cur->fts_link = root;
+ sp->fts_cur->fts_info = FTS_INIT;
+
+ /*
+ * If using chdir(2), grab a file descriptor pointing to dot to ensure
+ * that we can get back here; this could be avoided for some paths,
+ * but almost certainly not worth the effort. Slashes, symbolic links,
+ * and ".." are all fairly nasty problems. Note, if we can't get the
+ * descriptor we run anyway, just more slowly.
+ */
+ if (!ISSET(FTS_NOCHDIR)
+ && (sp->fts_rfd = open(".", O_RDONLY, 0)) < 0)
+ SET(FTS_NOCHDIR);
+
+ return (sp);
+
+mem3: fts_lfree(root);
+ free(parent);
+mem2: free(sp->fts_path);
+mem1: free(sp);
+ return (NULL);
+}
+
+static void
+internal_function
+fts_load(FTS *sp, register FTSENT *p)
+{
+ register int len;
+ register char *cp;
+
+ /*
+ * Load the stream structure for the next traversal. Since we don't
+ * actually enter the directory until after the preorder visit, set
+ * the fts_accpath field specially so the chdir gets done to the right
+ * place and the user can access the first node. From fts_open it's
+ * known that the path will fit.
+ */
+ len = p->fts_pathlen = p->fts_namelen;
+ memmove(sp->fts_path, p->fts_name, len + 1);
+ if ((cp = strrchr(p->fts_name, '/')) && (cp != p->fts_name || cp[1])) {
+ len = strlen(++cp);
+ memmove(p->fts_name, cp, len + 1);
+ p->fts_namelen = len;
+ }
+ p->fts_accpath = p->fts_path = sp->fts_path;
+ sp->fts_dev = p->fts_dev;
+}
+
+int
+fts_close(FTS *sp)
+{
+ register FTSENT *freep, *p;
+ int saved_errno;
+
+ /*
+ * This still works if we haven't read anything -- the dummy structure
+ * points to the root list, so we step through to the end of the root
+ * list which has a valid parent pointer.
+ */
+ if (sp->fts_cur) {
+ for (p = sp->fts_cur; p->fts_level >= FTS_ROOTLEVEL;) {
+ freep = p;
+ p = p->fts_link != NULL ? p->fts_link : p->fts_parent;
+ free(freep);
+ }
+ free(p);
+ }
+
+ /* Free up child linked list, sort array, path buffer. */
+ if (sp->fts_child)
+ fts_lfree(sp->fts_child);
+ free(sp->fts_array);
+ free(sp->fts_path);
+
+ /* Return to original directory, save errno if necessary. */
+ if (!ISSET(FTS_NOCHDIR)) {
+ saved_errno = fchdir(sp->fts_rfd) ? errno : 0;
+ (void)close(sp->fts_rfd);
+
+ /* Set errno and return. */
+ if (saved_errno != 0) {
+ /* Free up the stream pointer. */
+ free(sp);
+ __set_errno (saved_errno);
+ return (-1);
+ }
+ }
+
+ /* Free up the stream pointer. */
+ free(sp);
+ return (0);
+}
+
+/*
+ * Special case of "/" at the end of the path so that slashes aren't
+ * appended which would cause paths to be written as "....//foo".
+ */
+#define NAPPEND(p) \
+ (p->fts_path[p->fts_pathlen - 1] == '/' \
+ ? p->fts_pathlen - 1 : p->fts_pathlen)
+
+FTSENT *
+fts_read(register FTS *sp)
+{
+ register FTSENT *p, *tmp;
+ register int instr;
+ register char *t;
+ int saved_errno;
+
+ /* If finished or unrecoverable error, return NULL. */
+ if (sp->fts_cur == NULL || ISSET(FTS_STOP))
+ return (NULL);
+
+ /* Set current node pointer. */
+ p = sp->fts_cur;
+
+ /* Save and zero out user instructions. */
+ instr = p->fts_instr;
+ p->fts_instr = FTS_NOINSTR;
+
+ /* Any type of file may be re-visited; re-stat and re-turn. */
+ if (instr == FTS_AGAIN) {
+ p->fts_info = fts_stat(sp, p, 0);
+ return (p);
+ }
+
+ /*
+ * Following a symlink -- SLNONE test allows application to see
+ * SLNONE and recover. If indirecting through a symlink, have
+ * keep a pointer to current location. If unable to get that
+ * pointer, follow fails.
+ */
+ if (instr == FTS_FOLLOW &&
+ (p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE)) {
+ p->fts_info = fts_stat(sp, p, 1);
+ if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) {
+ if ((p->fts_symfd = open(".", O_RDONLY, 0)) < 0) {
+ p->fts_errno = errno;
+ p->fts_info = FTS_ERR;
+ } else
+ p->fts_flags |= FTS_SYMFOLLOW;
+ }
+ return (p);
+ }
+
+ /* Directory in pre-order. */
+ if (p->fts_info == FTS_D) {
+ /* If skipped or crossed mount point, do post-order visit. */
+ if (instr == FTS_SKIP ||
+ (ISSET(FTS_XDEV) && p->fts_dev != sp->fts_dev)) {
+ if (p->fts_flags & FTS_SYMFOLLOW)
+ (void)close(p->fts_symfd);
+ if (sp->fts_child) {
+ fts_lfree(sp->fts_child);
+ sp->fts_child = NULL;
+ }
+ p->fts_info = FTS_DP;
+ return (p);
+ }
+
+ /* Rebuild if only read the names and now traversing. */
+ if (sp->fts_child != NULL && ISSET(FTS_NAMEONLY)) {
+ CLR(FTS_NAMEONLY);
+ fts_lfree(sp->fts_child);
+ sp->fts_child = NULL;
+ }
+
+ /*
+ * Cd to the subdirectory.
+ *
+ * If have already read and now fail to chdir, whack the list
+ * to make the names come out right, and set the parent errno
+ * so the application will eventually get an error condition.
+ * Set the FTS_DONTCHDIR flag so that when we logically change
+ * directories back to the parent we don't do a chdir.
+ *
+ * If haven't read do so. If the read fails, fts_build sets
+ * FTS_STOP or the fts_info field of the node.
+ */
+ if (sp->fts_child != NULL) {
+ if (fts_safe_changedir(sp, p, -1, p->fts_accpath)) {
+ p->fts_errno = errno;
+ p->fts_flags |= FTS_DONTCHDIR;
+ for (p = sp->fts_child; p != NULL;
+ p = p->fts_link)
+ p->fts_accpath =
+ p->fts_parent->fts_accpath;
+ }
+ } else if ((sp->fts_child = fts_build(sp, BREAD)) == NULL) {
+ if (ISSET(FTS_STOP))
+ return (NULL);
+ return (p);
+ }
+ p = sp->fts_child;
+ sp->fts_child = NULL;
+ sp->fts_cur = p;
+ goto name;
+ }
+
+ /* Move to the next node on this level. */
+next: tmp = p;
+ if ((p = p->fts_link) != NULL) {
+ sp->fts_cur = p;
+ free(tmp);
+
+ /*
+ * If reached the top, return to the original directory (or
+ * the root of the tree), and load the paths for the next root.
+ */
+ if (p->fts_level == FTS_ROOTLEVEL) {
+ if (FCHDIR(sp, sp->fts_rfd)) {
+ SET(FTS_STOP);
+ return (NULL);
+ }
+ fts_load(sp, p);
+ return p;
+ }
+
+ /*
+ * User may have called fts_set on the node. If skipped,
+ * ignore. If followed, get a file descriptor so we can
+ * get back if necessary.
+ */
+ if (p->fts_instr == FTS_SKIP)
+ goto next;
+ if (p->fts_instr == FTS_FOLLOW) {
+ p->fts_info = fts_stat(sp, p, 1);
+ if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) {
+ if ((p->fts_symfd =
+ open(".", O_RDONLY, 0)) < 0) {
+ p->fts_errno = errno;
+ p->fts_info = FTS_ERR;
+ } else
+ p->fts_flags |= FTS_SYMFOLLOW;
+ }
+ p->fts_instr = FTS_NOINSTR;
+ }
+
+name: t = sp->fts_path + NAPPEND(p->fts_parent);
+ *t++ = '/';
+ memmove(t, p->fts_name, p->fts_namelen + 1);
+ return p;
+ }
+
+ /* Move up to the parent node. */
+ p = tmp->fts_parent;
+ sp->fts_cur = p;
+ free(tmp);
+
+ if (p->fts_level == FTS_ROOTPARENTLEVEL) {
+ /*
+ * Done; free everything up and set errno to 0 so the user
+ * can distinguish between error and EOF.
+ */
+ free(p);
+ __set_errno (0);
+ return (sp->fts_cur = NULL);
+ }
+
+ /* NUL terminate the pathname. */
+ sp->fts_path[p->fts_pathlen] = '\0';
+
+ /*
+ * Return to the parent directory. If at a root node or came through
+ * a symlink, go back through the file descriptor. Otherwise, cd up
+ * one directory.
+ */
+ if (p->fts_level == FTS_ROOTLEVEL) {
+ if (FCHDIR(sp, sp->fts_rfd)) {
+ SET(FTS_STOP);
+ return (NULL);
+ }
+ } else if (p->fts_flags & FTS_SYMFOLLOW) {
+ if (FCHDIR(sp, p->fts_symfd)) {
+ saved_errno = errno;
+ (void)close(p->fts_symfd);
+ __set_errno (saved_errno);
+ SET(FTS_STOP);
+ return (NULL);
+ }
+ (void)close(p->fts_symfd);
+ } else if (!(p->fts_flags & FTS_DONTCHDIR) &&
+ fts_safe_changedir(sp, p->fts_parent, -1, "..")) {
+ SET(FTS_STOP);
+ return (NULL);
+ }
+ p->fts_info = p->fts_errno ? FTS_ERR : FTS_DP;
+ return p;
+}
+
+/*
+ * Fts_set takes the stream as an argument although it's not used in this
+ * implementation; it would be necessary if anyone wanted to add global
+ * semantics to fts using fts_set. An error return is allowed for similar
+ * reasons.
+ */
+/* ARGSUSED */
+int
+fts_set(FTS *sp, FTSENT *p, int instr)
+{
+ if (instr != 0 && instr != FTS_AGAIN && instr != FTS_FOLLOW &&
+ instr != FTS_NOINSTR && instr != FTS_SKIP) {
+ __set_errno (EINVAL);
+ return (1);
+ }
+ p->fts_instr = instr;
+ return (0);
+}
+
+FTSENT *
+fts_children(register FTS *sp, int instr)
+{
+ register FTSENT *p;
+ int fd;
+
+ if (instr != 0 && instr != FTS_NAMEONLY) {
+ __set_errno (EINVAL);
+ return (NULL);
+ }
+
+ /* Set current node pointer. */
+ p = sp->fts_cur;
+
+ /*
+ * Errno set to 0 so user can distinguish empty directory from
+ * an error.
+ */
+ __set_errno (0);
+
+ /* Fatal errors stop here. */
+ if (ISSET(FTS_STOP))
+ return (NULL);
+
+ /* Return logical hierarchy of user's arguments. */
+ if (p->fts_info == FTS_INIT)
+ return (p->fts_link);
+
+ /*
+ * If not a directory being visited in pre-order, stop here. Could
+ * allow FTS_DNR, assuming the user has fixed the problem, but the
+ * same effect is available with FTS_AGAIN.
+ */
+ if (p->fts_info != FTS_D /* && p->fts_info != FTS_DNR */)
+ return (NULL);
+
+ /* Free up any previous child list. */
+ if (sp->fts_child != NULL)
+ fts_lfree(sp->fts_child);
+
+ if (instr == FTS_NAMEONLY) {
+ SET(FTS_NAMEONLY);
+ instr = BNAMES;
+ } else
+ instr = BCHILD;
+
+ /*
+ * If using chdir on a relative path and called BEFORE fts_read does
+ * its chdir to the root of a traversal, we can lose -- we need to
+ * chdir into the subdirectory, and we don't know where the current
+ * directory is, so we can't get back so that the upcoming chdir by
+ * fts_read will work.
+ */
+ if (p->fts_level != FTS_ROOTLEVEL || p->fts_accpath[0] == '/' ||
+ ISSET(FTS_NOCHDIR))
+ return (sp->fts_child = fts_build(sp, instr));
+
+ if ((fd = open(".", O_RDONLY, 0)) < 0)
+ return (NULL);
+ sp->fts_child = fts_build(sp, instr);
+ if (fchdir(fd))
+ return (NULL);
+ (void)close(fd);
+ return (sp->fts_child);
+}
+
+/*
+ * This is the tricky part -- do not casually change *anything* in here. The
+ * idea is to build the linked list of entries that are used by fts_children
+ * and fts_read. There are lots of special cases.
+ *
+ * The real slowdown in walking the tree is the stat calls. If FTS_NOSTAT is
+ * set and it's a physical walk (so that symbolic links can't be directories),
+ * we can do things quickly. First, if it's a 4.4BSD file system, the type
+ * of the file is in the directory entry. Otherwise, we assume that the number
+ * of subdirectories in a node is equal to the number of links to the parent.
+ * The former skips all stat calls. The latter skips stat calls in any leaf
+ * directories and for any files after the subdirectories in the directory have
+ * been found, cutting the stat calls by about 2/3.
+ */
+static FTSENT *
+internal_function
+fts_build(register FTS *sp, int type)
+{
+ register struct dirent *dp;
+ register FTSENT *p, *head;
+ register int nitems;
+ FTSENT *cur, *tail;
+ DIR *dirp;
+ void *oldaddr;
+ int /*cderrno,*/ descend, len, level, nlinks, saved_errno,
+ nostat, doadjust;
+ size_t maxlen;
+ char *cp;
+
+ /* Set current node pointer. */
+ cur = sp->fts_cur;
+
+ /*
+ * Open the directory for reading. If this fails, we're done.
+ * If being called from fts_read, set the fts_info field.
+ */
+#if defined FTS_WHITEOUT && 0
+ if (ISSET(FTS_WHITEOUT))
+ oflag = DTF_NODUP|DTF_REWIND;
+ else
+ oflag = DTF_HIDEW|DTF_NODUP|DTF_REWIND;
+#else
+# define opendir2(path, flag) opendir(path)
+#endif
+ if ((dirp = opendir2(cur->fts_accpath, oflag)) == NULL) {
+ if (type == BREAD) {
+ cur->fts_info = FTS_DNR;
+ cur->fts_errno = errno;
+ }
+ return (NULL);
+ }
+
+ /*
+ * Nlinks is the number of possible entries of type directory in the
+ * directory if we're cheating on stat calls, 0 if we're not doing
+ * any stat calls at all, -1 if we're doing stats on everything.
+ */
+ if (type == BNAMES) {
+ nlinks = 0;
+ /* Be quiet about nostat, GCC. */
+ nostat = 0;
+ } else if (ISSET(FTS_NOSTAT) && ISSET(FTS_PHYSICAL)) {
+ nlinks = cur->fts_nlink - (ISSET(FTS_SEEDOT) ? 0 : 2);
+ nostat = 1;
+ } else {
+ nlinks = -1;
+ nostat = 0;
+ }
+
+#ifdef notdef
+ (void)printf("nlinks == %d (cur: %d)\n", nlinks, cur->fts_nlink);
+ (void)printf("NOSTAT %d PHYSICAL %d SEEDOT %d\n",
+ ISSET(FTS_NOSTAT), ISSET(FTS_PHYSICAL), ISSET(FTS_SEEDOT));
+#endif
+ /*
+ * If we're going to need to stat anything or we want to descend
+ * and stay in the directory, chdir. If this fails we keep going,
+ * but set a flag so we don't chdir after the post-order visit.
+ * We won't be able to stat anything, but we can still return the
+ * names themselves. Note, that since fts_read won't be able to
+ * chdir into the directory, it will have to return different path
+ * names than before, i.e. "a/b" instead of "b". Since the node
+ * has already been visited in pre-order, have to wait until the
+ * post-order visit to return the error. There is a special case
+ * here, if there was nothing to stat then it's not an error to
+ * not be able to stat. This is all fairly nasty. If a program
+ * needed sorted entries or stat information, they had better be
+ * checking FTS_NS on the returned nodes.
+ */
+ /* cderrno = 0; */
+ if (nlinks || type == BREAD) {
+ if (fts_safe_changedir(sp, cur, dirfd(dirp), NULL)) {
+ if (nlinks && type == BREAD)
+ cur->fts_errno = errno;
+ cur->fts_flags |= FTS_DONTCHDIR;
+ descend = 0;
+ /* cderrno = errno; */
+ (void)closedir(dirp);
+ dirp = NULL;
+ } else
+ descend = 1;
+ } else
+ descend = 0;
+
+ /*
+ * Figure out the max file name length that can be stored in the
+ * current path -- the inner loop allocates more path as necessary.
+ * We really wouldn't have to do the maxlen calculations here, we
+ * could do them in fts_read before returning the path, but it's a
+ * lot easier here since the length is part of the dirent structure.
+ *
+ * If not changing directories set a pointer so that can just append
+ * each new name into the path.
+ */
+ len = NAPPEND(cur);
+ if (ISSET(FTS_NOCHDIR)) {
+ cp = sp->fts_path + len;
+ *cp++ = '/';
+ } else {
+ /* GCC, you're too verbose. */
+ cp = NULL;
+ }
+ len++;
+ maxlen = sp->fts_pathlen - len;
+
+ level = cur->fts_level + 1;
+
+ /* Read the directory, attaching each entry to the `link' pointer. */
+ doadjust = 0;
+ for (head = tail = NULL, nitems = 0; dirp && (dp = readdir(dirp));) {
+ if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name))
+ continue;
+
+ if ((p = fts_alloc(sp, dp->d_name, _D_EXACT_NAMLEN (dp))) == NULL)
+ goto mem1;
+ if (_D_EXACT_NAMLEN (dp) >= maxlen) {/* include space for NUL */
+ oldaddr = sp->fts_path;
+ if (fts_palloc(sp, _D_EXACT_NAMLEN (dp) + len + 1)) {
+ /*
+ * No more memory for path or structures. Save
+ * errno, free up the current structure and the
+ * structures already allocated.
+ */
+mem1: saved_errno = errno;
+ free(p);
+ fts_lfree(head);
+ (void)closedir(dirp);
+ cur->fts_info = FTS_ERR;
+ SET(FTS_STOP);
+ __set_errno (saved_errno);
+ return (NULL);
+ }
+ /* Did realloc() change the pointer? */
+ if (oldaddr != sp->fts_path) {
+ doadjust = 1;
+ if (ISSET(FTS_NOCHDIR))
+ cp = sp->fts_path + len;
+ }
+ maxlen = sp->fts_pathlen - len;
+ }
+
+ if (len + _D_EXACT_NAMLEN (dp) >= USHRT_MAX) {
+ /*
+ * In an FTSENT, fts_pathlen is a u_short so it is
+ * possible to wraparound here. If we do, free up
+ * the current structure and the structures already
+ * allocated, then error out with ENAMETOOLONG.
+ */
+ free(p);
+ fts_lfree(head);
+ (void)closedir(dirp);
+ cur->fts_info = FTS_ERR;
+ SET(FTS_STOP);
+ __set_errno (ENAMETOOLONG);
+ return (NULL);
+ }
+ p->fts_level = level;
+ p->fts_parent = sp->fts_cur;
+ p->fts_pathlen = len + _D_EXACT_NAMLEN (dp);
+
+#if defined FTS_WHITEOUT && 0
+ if (dp->d_type == DT_WHT)
+ p->fts_flags |= FTS_ISW;
+#endif
+
+#if 0
+ /* Unreachable code. cderrno is only ever set to a nonnull
+ value if dirp is closed at the same time. But then we
+ cannot enter this loop. */
+ if (cderrno) {
+ if (nlinks) {
+ p->fts_info = FTS_NS;
+ p->fts_errno = cderrno;
+ } else
+ p->fts_info = FTS_NSOK;
+ p->fts_accpath = cur->fts_accpath;
+ } else
+#endif
+ if (nlinks == 0
+#if defined DT_DIR && defined _DIRENT_HAVE_D_TYPE
+ || (nostat &&
+ dp->d_type != DT_DIR && dp->d_type != DT_UNKNOWN)
+#endif
+ ) {
+ p->fts_accpath =
+ ISSET(FTS_NOCHDIR) ? p->fts_path : p->fts_name;
+ p->fts_info = FTS_NSOK;
+ } else {
+ /* Build a file name for fts_stat to stat. */
+ if (ISSET(FTS_NOCHDIR)) {
+ p->fts_accpath = p->fts_path;
+ memmove(cp, p->fts_name, p->fts_namelen + 1);
+ } else
+ p->fts_accpath = p->fts_name;
+ /* Stat it. */
+ p->fts_info = fts_stat(sp, p, 0);
+
+ /* Decrement link count if applicable. */
+ if (nlinks > 0 && (p->fts_info == FTS_D ||
+ p->fts_info == FTS_DC || p->fts_info == FTS_DOT))
+ --nlinks;
+ }
+
+ /* We walk in directory order so "ls -f" doesn't get upset. */
+ p->fts_link = NULL;
+ if (head == NULL)
+ head = tail = p;
+ else {
+ tail->fts_link = p;
+ tail = p;
+ }
+ ++nitems;
+ }
+ if (dirp)
+ (void)closedir(dirp);
+
+ /*
+ * If realloc() changed the address of the path, adjust the
+ * addresses for the rest of the tree and the dir list.
+ */
+ if (doadjust)
+ fts_padjust(sp, head);
+
+ /*
+ * If not changing directories, reset the path back to original
+ * state.
+ */
+ if (ISSET(FTS_NOCHDIR)) {
+ if (len == sp->fts_pathlen || nitems == 0)
+ --cp;
+ *cp = '\0';
+ }
+
+ /*
+ * If descended after called from fts_children or after called from
+ * fts_read and nothing found, get back. At the root level we use
+ * the saved fd; if one of fts_open()'s arguments is a relative path
+ * to an empty directory, we wind up here with no other way back. If
+ * can't get back, we're done.
+ */
+ if (descend && (type == BCHILD || !nitems) &&
+ (cur->fts_level == FTS_ROOTLEVEL ?
+ FCHDIR(sp, sp->fts_rfd) :
+ fts_safe_changedir(sp, cur->fts_parent, -1, ".."))) {
+ cur->fts_info = FTS_ERR;
+ SET(FTS_STOP);
+ fts_lfree(head);
+ return (NULL);
+ }
+
+ /* If didn't find anything, return NULL. */
+ if (!nitems) {
+ if (type == BREAD)
+ cur->fts_info = FTS_DP;
+ fts_lfree(head);
+ return (NULL);
+ }
+
+ /* Sort the entries. */
+ if (sp->fts_compar && nitems > 1)
+ head = fts_sort(sp, head, nitems);
+ return (head);
+}
+
+static u_short
+internal_function
+fts_stat(FTS *sp, register FTSENT *p, int follow)
+{
+ register FTSENT *t;
+ register dev_t dev;
+ register ino_t ino;
+ struct stat *sbp, sb;
+ int saved_errno;
+
+ /* If user needs stat info, stat buffer already allocated. */
+ sbp = ISSET(FTS_NOSTAT) ? &sb : p->fts_statp;
+
+#if defined FTS_WHITEOUT && 0
+ /* check for whiteout */
+ if (p->fts_flags & FTS_ISW) {
+ if (sbp != &sb) {
+ memset(sbp, '\0', sizeof (*sbp));
+ sbp->st_mode = S_IFWHT;
+ }
+ return (FTS_W);
+ }
+#endif
+
+ /*
+ * If doing a logical walk, or application requested FTS_FOLLOW, do
+ * a stat(2). If that fails, check for a non-existent symlink. If
+ * fail, set the errno from the stat call.
+ */
+ if (ISSET(FTS_LOGICAL) || follow) {
+ if (stat(p->fts_accpath, sbp)) {
+ saved_errno = errno;
+ if (!lstat(p->fts_accpath, sbp)) {
+ __set_errno (0);
+ return (FTS_SLNONE);
+ }
+ p->fts_errno = saved_errno;
+ goto err;
+ }
+ } else if (lstat(p->fts_accpath, sbp)) {
+ p->fts_errno = errno;
+err: memset(sbp, 0, sizeof(struct stat));
+ return (FTS_NS);
+ }
+
+ if (S_ISDIR(sbp->st_mode)) {
+ /*
+ * Set the device/inode. Used to find cycles and check for
+ * crossing mount points. Also remember the link count, used
+ * in fts_build to limit the number of stat calls. It is
+ * understood that these fields are only referenced if fts_info
+ * is set to FTS_D.
+ */
+ dev = p->fts_dev = sbp->st_dev;
+ ino = p->fts_ino = sbp->st_ino;
+ p->fts_nlink = sbp->st_nlink;
+
+ if (ISDOT(p->fts_name))
+ return (FTS_DOT);
+
+ /*
+ * Cycle detection is done by brute force when the directory
+ * is first encountered. If the tree gets deep enough or the
+ * number of symbolic links to directories is high enough,
+ * something faster might be worthwhile.
+ */
+ for (t = p->fts_parent;
+ t->fts_level >= FTS_ROOTLEVEL; t = t->fts_parent)
+ if (ino == t->fts_ino && dev == t->fts_dev) {
+ p->fts_cycle = t;
+ return (FTS_DC);
+ }
+ return (FTS_D);
+ }
+ if (S_ISLNK(sbp->st_mode))
+ return (FTS_SL);
+ if (S_ISREG(sbp->st_mode))
+ return (FTS_F);
+ return (FTS_DEFAULT);
+}
+
+static FTSENT *
+internal_function
+fts_sort(FTS *sp, FTSENT *head, register int nitems)
+{
+ register FTSENT **ap, *p;
+
+ /*
+ * Construct an array of pointers to the structures and call qsort(3).
+ * Reassemble the array in the order returned by qsort. If unable to
+ * sort for memory reasons, return the directory entries in their
+ * current order. Allocate enough space for the current needs plus
+ * 40 so don't realloc one entry at a time.
+ */
+ if (nitems > sp->fts_nitems) {
+ struct _ftsent **a;
+
+ sp->fts_nitems = nitems + 40;
+ if ((a = realloc(sp->fts_array,
+ (size_t)(sp->fts_nitems * sizeof(FTSENT *)))) == NULL) {
+ free(sp->fts_array);
+ sp->fts_array = NULL;
+ sp->fts_nitems = 0;
+ return (head);
+ }
+ sp->fts_array = a;
+ }
+ for (ap = sp->fts_array, p = head; p; p = p->fts_link)
+ *ap++ = p;
+ qsort((void *)sp->fts_array, nitems, sizeof(FTSENT *), sp->fts_compar);
+ for (head = *(ap = sp->fts_array); --nitems; ++ap)
+ ap[0]->fts_link = ap[1];
+ ap[0]->fts_link = NULL;
+ return (head);
+}
+
+static FTSENT *
+internal_function
+fts_alloc(FTS *sp, const char *name, size_t namelen)
+{
+ register FTSENT *p;
+ size_t len;
+
+ /*
+ * The file name is a variable length array and no stat structure is
+ * necessary if the user has set the nostat bit. Allocate the FTSENT
+ * structure, the file name and the stat structure in one chunk, but
+ * be careful that the stat structure is reasonably aligned. Since the
+ * fts_name field is declared to be of size 1, the fts_name pointer is
+ * namelen + 2 before the first possible address of the stat structure.
+ */
+ len = sizeof(FTSENT) + namelen;
+ if (!ISSET(FTS_NOSTAT))
+ len += sizeof(struct stat) + ALIGNBYTES;
+ if ((p = malloc(len)) == NULL)
+ return (NULL);
+
+ /* Copy the name and guarantee NUL termination. */
+ memmove(p->fts_name, name, namelen);
+ p->fts_name[namelen] = '\0';
+
+ if (!ISSET(FTS_NOSTAT))
+ p->fts_statp = (struct stat *)ALIGN(p->fts_name + namelen + 2);
+ p->fts_namelen = namelen;
+ p->fts_path = sp->fts_path;
+ p->fts_errno = 0;
+ p->fts_flags = 0;
+ p->fts_instr = FTS_NOINSTR;
+ p->fts_number = 0;
+ p->fts_pointer = NULL;
+ return (p);
+}
+
+static void
+internal_function
+fts_lfree(register FTSENT *head)
+{
+ register FTSENT *p;
+
+ /* Free a linked list of structures. */
+ while ((p = head)) {
+ head = head->fts_link;
+ free(p);
+ }
+}
+
+/*
+ * Allow essentially unlimited paths; find, rm, ls should all work on any tree.
+ * Most systems will allow creation of paths much longer than MAXPATHLEN, even
+ * though the kernel won't resolve them. Add the size (not just what's needed)
+ * plus 256 bytes so don't realloc the path 2 bytes at a time.
+ */
+static int
+internal_function
+fts_palloc(FTS *sp, size_t more)
+{
+ char *p;
+
+ sp->fts_pathlen += more + 256;
+ /*
+ * Check for possible wraparound. In an FTS, fts_pathlen is
+ * a signed int but in an FTSENT it is an unsigned short.
+ * We limit fts_pathlen to USHRT_MAX to be safe in both cases.
+ */
+ if (sp->fts_pathlen < 0 || sp->fts_pathlen >= USHRT_MAX) {
+ free(sp->fts_path);
+ sp->fts_path = NULL;
+ __set_errno (ENAMETOOLONG);
+ return (1);
+ }
+ p = realloc(sp->fts_path, sp->fts_pathlen);
+ if (p == NULL) {
+ free(sp->fts_path);
+ sp->fts_path = NULL;
+ return 1;
+ }
+ sp->fts_path = p;
+ return 0;
+}
+
+/*
+ * When the path is realloc'd, have to fix all of the pointers in structures
+ * already returned.
+ */
+static void
+internal_function
+fts_padjust(FTS *sp, FTSENT *head)
+{
+ FTSENT *p;
+ char *addr = sp->fts_path;
+
+#define ADJUST(p) do { \
+ if ((p)->fts_accpath != (p)->fts_name) { \
+ (p)->fts_accpath = \
+ (char *)addr + ((p)->fts_accpath - (p)->fts_path); \
+ } \
+ (p)->fts_path = addr; \
+} while (0)
+ /* Adjust the current set of children. */
+ for (p = sp->fts_child; p; p = p->fts_link)
+ ADJUST(p);
+
+ /* Adjust the rest of the tree, including the current level. */
+ for (p = head; p->fts_level >= FTS_ROOTLEVEL;) {
+ ADJUST(p);
+ p = p->fts_link ? p->fts_link : p->fts_parent;
+ }
+}
+
+static size_t
+internal_function
+fts_maxarglen(char * const *argv)
+{
+ size_t len, max;
+
+ for (max = 0; *argv; ++argv)
+ if ((len = strlen(*argv)) > max)
+ max = len;
+ return (max + 1);
+}
+
+/*
+ * Change to dir specified by fd or p->fts_accpath without getting
+ * tricked by someone changing the world out from underneath us.
+ * Assumes p->fts_dev and p->fts_ino are filled in.
+ */
+static int
+internal_function
+fts_safe_changedir(FTS *sp, FTSENT *p, int fd, const char *path)
+{
+ int ret, oerrno, newfd;
+ struct stat64 sb;
+
+ newfd = fd;
+ if (ISSET(FTS_NOCHDIR))
+ return (0);
+ if (fd < 0 && (newfd = open(path, O_RDONLY, 0)) < 0)
+ return (-1);
+ if (fstat64(newfd, &sb)) {
+ ret = -1;
+ goto bail;
+ }
+ if (p->fts_dev != sb.st_dev || p->fts_ino != sb.st_ino) {
+ __set_errno (ENOENT); /* disinformation */
+ ret = -1;
+ goto bail;
+ }
+ ret = fchdir(newfd);
+bail:
+ oerrno = errno;
+ if (fd < 0)
+ (void)close(newfd);
+ __set_errno (oerrno);
+ return (ret);
+}
diff --git a/libc/misc/ftw/Makefile.in b/libc/misc/ftw/Makefile.in
index 501b9084d..084a73009 100644
--- a/libc/misc/ftw/Makefile.in
+++ b/libc/misc/ftw/Makefile.in
@@ -1,24 +1,24 @@
# 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.
#
-CSRC := ftw.c
-ifeq ($(UCLIBC_HAS_LFS),y)
-CSRC += ftw64.c
-endif
+subdirs += libc/misc/ftw
+
+CSRC-y := ftw.c
+CSRC-$(UCLIBC_HAS_LFS) += ftw64.c
MISC_FTW_DIR := $(top_srcdir)libc/misc/ftw
MISC_FTW_OUT := $(top_builddir)libc/misc/ftw
-MISC_FTW_SRC := $(patsubst %.c,$(MISC_FTW_DIR)/%.c,$(CSRC))
-MISC_FTW_OBJ := $(patsubst %.c,$(MISC_FTW_OUT)/%.o,$(CSRC))
+MISC_FTW_SRC := $(patsubst %.c,$(MISC_FTW_DIR)/%.c,$(CSRC-y))
+MISC_FTW_OBJ := $(patsubst %.c,$(MISC_FTW_OUT)/%.o,$(CSRC-y))
-libc-$(UCLIBC_HAS_FTW) += $(MISC_FTW_OBJ)
+libc-$(findstring y,$(UCLIBC_HAS_FTW)$(UCLIBC_HAS_NFTW)) += $(MISC_FTW_OBJ)
-objclean-y += misc_ftw_objclean
+objclean-y += CLEAN_libc/misc/ftw
-misc_ftw_objclean:
- $(RM) $(MISC_FTW_OUT)/*.{o,os}
+CLEAN_libc/misc/ftw:
+ $(do_rm) $(addprefix $(MISC_FTW_OUT)/*., o os)
diff --git a/libc/misc/ftw/ftw.c b/libc/misc/ftw/ftw.c
index c136f1e8d..05ea0fa66 100644
--- a/libc/misc/ftw/ftw.c
+++ b/libc/misc/ftw/ftw.c
@@ -14,15 +14,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/>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <features.h>
+/* need errno.h before undefining _LIBC */
+#include <errno.h>
#ifdef __UCLIBC__
#undef _LIBC
#define HAVE_DIRENT_H 1
@@ -32,6 +33,7 @@
#endif
#if __GNUC__
+# undef alloca
# define alloca __builtin_alloca
#else
# if HAVE_ALLOCA_H
@@ -67,7 +69,6 @@ char *alloca ();
# endif
#endif
-#include <errno.h>
#include <ftw.h>
#include <limits.h>
#include <search.h>
@@ -77,39 +78,13 @@ char *alloca ();
#if HAVE_SYS_PARAM_H || defined _LIBC
# include <sys/param.h>
#endif
-#ifdef _LIBC
-# include <include/sys/stat.h>
-#else
-# include <sys/stat.h>
-#endif
+#include <sys/stat.h>
-/* Experimentally off - libc_hidden_proto(memset) */
-/* Experimentally off - libc_hidden_proto(strchr) */
-/* Experimentally off - libc_hidden_proto(strlen) */
-libc_hidden_proto(dirfd)
-libc_hidden_proto(tsearch)
-libc_hidden_proto(tfind)
-libc_hidden_proto(tdestroy)
-libc_hidden_proto(getcwd)
-libc_hidden_proto(chdir)
-libc_hidden_proto(fchdir)
-/* Experimentally off - libc_hidden_proto(mempcpy) */
-libc_hidden_proto(opendir)
-#ifdef __UCLIBC_HAS_LFS__
-libc_hidden_proto(readdir64)
-libc_hidden_proto(lstat64)
-libc_hidden_proto(stat64)
-#endif
-libc_hidden_proto(closedir)
-/* Experimentally off - libc_hidden_proto(stpcpy) */
-libc_hidden_proto(lstat)
-libc_hidden_proto(stat)
-
-#if ! _LIBC && !HAVE_DECL_STPCPY && !defined stpcpy
+#if !defined _LIBC && !HAVE_DECL_STPCPY && !defined stpcpy
char *stpcpy ();
#endif
-#if ! _LIBC && ! defined HAVE_MEMPCPY && ! defined mempcpy
+#if !defined _LIBC && ! defined HAVE_MEMPCPY && ! defined mempcpy
/* Be CAREFUL that there are no side effects in N. */
# define mempcpy(D, S, N) ((void *) ((char *) memcpy (D, S, N) + (N)))
#endif
@@ -162,7 +137,7 @@ extern char *xgetcwd (void);
/* Arrange to make lstat calls go through the wrapper function
on systems with an lstat function that does not dereference symlinks
that are specified with a trailing slash. */
-#if ! _LIBC && ! LSTAT_FOLLOWS_SLASHED_SYMLINK && !defined __UCLIBC__
+#if !defined _LIBC && !defined LSTAT_FOLLOWS_SLASHED_SYMLINK && !defined __UCLIBC__
int rpl_lstat (const char *, struct stat *);
# undef lstat
# define lstat(Name, Stat_buf) rpl_lstat(Name, Stat_buf)
@@ -774,13 +749,15 @@ ftw_startup (const char *dir, int is_nftw, void *func, int descriptors,
/* Entry points. */
-
+#ifdef __UCLIBC_HAS_FTW__
int
FTW_NAME (const char *path, FTW_FUNC_T func, int descriptors)
{
return ftw_startup (path, 0, func, descriptors, 0);
}
+#endif
+#ifdef __UCLIBC_HAS_NFTW__
#ifndef _LIBC
int
NFTW_NAME (const char *path, NFTW_FUNC_T func, int descriptors, int flags)
@@ -824,3 +801,4 @@ NFTW_OLD_NAME (const char *path, NFTW_FUNC_T func, int descriptors, int flags)
compat_symbol (libc, NFTW_OLD_NAME, NFTW_NAME, GLIBC_2_1);
#endif
#endif
+#endif
diff --git a/libc/misc/ftw/ftw64.c b/libc/misc/ftw/ftw64.c
index de2fe22d1..c07b71091 100644
--- a/libc/misc/ftw/ftw64.c
+++ b/libc/misc/ftw/ftw64.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/>. */
#define FTW_NAME ftw64
#define NFTW_NAME nftw64
diff --git a/libc/misc/glob/Makefile.in b/libc/misc/glob/Makefile.in
index 93367f41b..c89d2b08d 100644
--- a/libc/misc/glob/Makefile.in
+++ b/libc/misc/glob/Makefile.in
@@ -1,31 +1,25 @@
# 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.
#
-ifeq ($(UCLIBC_HAS_GNU_GLOB),y)
-CSRC := glob.c
-ifeq ($(UCLIBC_HAS_LFS),y)
-CSRC += glob64.c
-endif
-else
-CSRC := glob-susv3.c
-ifeq ($(UCLIBC_HAS_LFS),y)
-CSRC += glob64-susv3.c
-endif
-endif
+subdirs += libc/misc/glob
+
+VARIANT := $(if $(UCLIBC_HAS_GNU_GLOB),,-susv3)
+CSRC-y := glob$(VARIANT).c
+CSRC-$(UCLIBC_HAS_LFS) += glob64$(VARIANT).c
MISC_GLOB_DIR := $(top_srcdir)libc/misc/glob
MISC_GLOB_OUT := $(top_builddir)libc/misc/glob
-MISC_GLOB_SRC := $(patsubst %.c,$(MISC_GLOB_DIR)/%.c,$(CSRC))
-MISC_GLOB_OBJ := $(patsubst %.c,$(MISC_GLOB_OUT)/%.o,$(CSRC))
+MISC_GLOB_SRC := $(patsubst %.c,$(MISC_GLOB_DIR)/%.c,$(CSRC-y))
+MISC_GLOB_OBJ := $(patsubst %.c,$(MISC_GLOB_OUT)/%.o,$(CSRC-y))
libc-$(UCLIBC_HAS_GLOB) += $(MISC_GLOB_OBJ)
-objclean-y += misc_glob_objclean
+objclean-y += CLEAN_libc/misc/glob
-misc_glob_objclean:
- $(RM) $(MISC_GLOB_OUT)/*.{o,os}
+CLEAN_libc/misc/glob:
+ $(do_rm) $(addprefix $(MISC_GLOB_OUT)/*., o os)
diff --git a/libc/misc/glob/glob-susv3.c b/libc/misc/glob/glob-susv3.c
index 00963c36e..59b4d8e5f 100644
--- a/libc/misc/glob/glob-susv3.c
+++ b/libc/misc/glob/glob-susv3.c
@@ -23,16 +23,6 @@
#include <unistd.h>
#include <stdio.h>
-/* Experimentally off - libc_hidden_proto(memcpy) */
-/* Experimentally off - libc_hidden_proto(strcat) */
-/* Experimentally off - libc_hidden_proto(strchr) */
-/* Experimentally off - libc_hidden_proto(strcmp) */
-/* Experimentally off - libc_hidden_proto(strcpy) */
-/* Experimentally off - libc_hidden_proto(strlen) */
-libc_hidden_proto(opendir)
-libc_hidden_proto(closedir)
-libc_hidden_proto(qsort)
-libc_hidden_proto(fnmatch)
struct match
{
@@ -53,12 +43,8 @@ extern int __glob_match_in_dir(const char *d, const char *p, int flags, int (*er
# define stat stat64
# define readdir_r readdir64_r
# define dirent dirent64
-libc_hidden_proto(readdir64_r)
-libc_hidden_proto(stat64)
# define struct_stat struct stat64
#else
-libc_hidden_proto(readdir_r)
-libc_hidden_proto(stat)
# define struct_stat struct stat
#endif
@@ -197,7 +183,8 @@ int __glob_match_in_dir(const char *d, const char *p, int flags, int (*errfunc)(
# ifndef BUILD_GLOB64
static
# endif
-int __glob_ignore_err(const char *path, int err)
+int __glob_ignore_err(const char * path attribute_unused,
+ int err attribute_unused)
{
return 0;
}
@@ -223,11 +210,6 @@ int __glob_sort(const void *a, const void *b)
}
#endif /* !__GLOB64 */
-#ifdef __GLOB64
-libc_hidden_proto(glob64)
-#else
-libc_hidden_proto(glob)
-#endif
int glob(const char *pat, int flags, int (*errfunc)(const char *path, int err), glob_t *g)
{
const char *p=pat, *d;
@@ -301,11 +283,6 @@ libc_hidden_def(glob64)
libc_hidden_def(glob)
#endif
-#ifdef __GLOB64
-libc_hidden_proto(globfree64)
-#else
-libc_hidden_proto(globfree)
-#endif
void globfree(glob_t *g)
{
size_t i;
diff --git a/libc/misc/glob/glob.c b/libc/misc/glob/glob.c
index 6ccbda4d7..923c03538 100644
--- a/libc/misc/glob/glob.c
+++ b/libc/misc/glob/glob.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/>. */
#undef ENABLE_GLOB_BRACE_EXPANSION
#undef ENABLE_GLOB_TILDE_EXPANSION
@@ -31,24 +30,10 @@
#include <fnmatch.h>
#include <glob.h>
-libc_hidden_proto(closedir)
-libc_hidden_proto(fnmatch)
-/* Experimentally off - libc_hidden_proto(memcpy) */
-/* Experimentally off - libc_hidden_proto(mempcpy) */
-libc_hidden_proto(opendir)
-libc_hidden_proto(qsort)
-libc_hidden_proto(readdir)
-/* Experimentally off - libc_hidden_proto(strchr) */
-/* Experimentally off - libc_hidden_proto(strcoll) */
-/* Experimentally off - libc_hidden_proto(strcpy) */
-/* Experimentally off - libc_hidden_proto(strdup) */
-/* Experimentally off - libc_hidden_proto(strlen) */
-/* Experimentally off - libc_hidden_proto(strrchr) */
#ifdef ENABLE_GLOB_TILDE_EXPANSION
#include <pwd.h>
-libc_hidden_proto(getpwnam_r)
#endif
#ifdef COMPILE_GLOB64
@@ -62,19 +47,15 @@ libc_hidden_proto(getpwnam_r)
#define glob_t glob64_t
#define glob(pattern, flags, errfunc, pglob) glob64 (pattern, flags, errfunc, pglob)
#define globfree(pglob) globfree64 (pglob)
-libc_hidden_proto(stat64)
-libc_hidden_proto(readdir64)
#else
#define __readdir readdir
#ifdef __UCLIBC_HAS_LFS__
#define __readdir64 readdir64
-libc_hidden_proto(readdir64)
#else
#define __readdir64 readdir
#endif
#define struct_stat64 struct stat
#define __stat64(fname, buf) stat (fname, buf)
-libc_hidden_proto(stat)
#endif
@@ -132,7 +113,6 @@ extern int __prefix_array (const char *dirname, char **array, size_t n) attribut
extern const char *__next_brace_sub (const char *cp, int flags) attribute_hidden;
#endif
-libc_hidden_proto(glob_pattern_p)
#ifndef COMPILE_GLOB64
/* Return nonzero if PATTERN contains any metacharacters.
Metacharacters can be quoted with backslashes if QUOTE is nonzero. */
@@ -488,13 +468,6 @@ static int glob_in_dir (const char *pattern, const char *directory, int flags,
return GLOB_NOSPACE;
}
-#ifdef COMPILE_GLOB64
-libc_hidden_proto(glob64)
-libc_hidden_proto(globfree64)
-#else
-libc_hidden_proto(glob)
-libc_hidden_proto(globfree)
-#endif
/* Do glob searching for PATTERN, placing results in PGLOB.
The bits defined above may be set in FLAGS.
If a directory cannot be opened or read and ERRFUNC is not nil,
diff --git a/libc/misc/gnu/Makefile.in b/libc/misc/gnu/Makefile.in
index d64a9eed3..99bf81442 100644
--- a/libc/misc/gnu/Makefile.in
+++ b/libc/misc/gnu/Makefile.in
@@ -1,21 +1,24 @@
# 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.
#
-CSRC := obstack.c
+subdirs += libc/misc/gnu
+
+CSRC-y :=
+CSRC-$(UCLIBC_HAS_OBSTACK) := obstack.c obprintf.c
MISC_GNU_DIR := $(top_srcdir)libc/misc/gnu
MISC_GNU_OUT := $(top_builddir)libc/misc/gnu
-MISC_GNU_SRC := $(MISC_GNU_DIR)/obstack.c
-MISC_GNU_OBJ := $(MISC_GNU_OUT)/obstack.o
+MISC_GNU_SRC := $(patsubst %.c,$(MISC_GNU_DIR)/%.c,$(CSRC-y))
+MISC_GNU_OBJ := $(patsubst %.c,$(MISC_GNU_OUT)/%.o,$(CSRC-y))
libc-y += $(MISC_GNU_OBJ)
-objclean-y += misc_gnu_objclean
+objclean-y += CLEAN_libc/misc/gnu
-misc_gnu_objclean:
- $(RM) $(MISC_GNU_OUT)/*.{o,os}
+CLEAN_libc/misc/gnu:
+ $(do_rm) $(addprefix $(MISC_GNU_OUT)/*., o os)
diff --git a/libc/misc/gnu/obprintf.c b/libc/misc/gnu/obprintf.c
new file mode 100644
index 000000000..3f8eda832
--- /dev/null
+++ b/libc/misc/gnu/obprintf.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 2013 Gentoo Foundation
+ * Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <obstack.h>
+
+int
+obstack_vprintf (struct obstack *obstack, const char *format, va_list args)
+{
+ int n;
+ char *s;
+ n = vasprintf(&s, format, args);
+ obstack_grow(obstack, s, n);
+ return n;
+}
+libc_hidden_def(obstack_vprintf)
+
+int
+obstack_printf (struct obstack *obstack, const char *format, ...)
+{
+ int n;
+ va_list ap;
+ va_start (ap, format);
+ n = obstack_vprintf (obstack, format, ap);
+ va_end (ap);
+ return n;
+}
diff --git a/libc/misc/gnu/obstack.c b/libc/misc/gnu/obstack.c
index 246d164cd..38cfd83de 100644
--- a/libc/misc/gnu/obstack.c
+++ b/libc/misc/gnu/obstack.c
@@ -1,7 +1,7 @@
/* obstack.c - subroutines used implicitly by object stack macros
- Copyright (C) 1988-1994,96,97,98,99,2000,2001 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 /gd/gnu/lib.
+ Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997, 1998,
+ 1999, 2000, 2001, 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
@@ -14,20 +14,25 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
-/* Make uClibc lie about being glibc. */
-#define __FORCE_GLIBC 1
-
-#include <locale.h>
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
-#include <obstack.h>
+#ifdef _LIBC
+# include <obstack.h>
+#ifndef __UCLIBC__
+# include <shlib-compat.h>
+#else
+# define HAVE_INTTYPES_H 1
+# define HAVE_STDINT_H 1
+#endif
+#else
+# include "obstack.h"
+#endif
/* NOTE BEFORE MODIFYING THIS FILE: This version number must be
incremented whenever callers compiled using an old obstack.h can no
@@ -51,28 +56,38 @@
# endif
#endif
-#if (defined _LIBC && defined USE_IN_LIBIO) || defined __UCLIBC_HAS_WCHAR__
-# include <wchar.h>
-#endif
+#include <stddef.h>
#ifndef ELIDE_CODE
-# if defined __STDC__ && __STDC__
-# define POINTER void *
-# else
-# define POINTER char *
+# if HAVE_INTTYPES_H
+# include <inttypes.h>
+# endif
+# if HAVE_STDINT_H || defined _LIBC
+# include <stdint.h>
# endif
/* Determine default alignment. */
-struct fooalign {char x; double d;};
-# define DEFAULT_ALIGNMENT \
- ((PTR_INT_TYPE) ((char *) &((struct fooalign *) 0)->d - (char *) 0))
+union fooround
+{
+ uintmax_t i;
+ long double d;
+ void *p;
+};
+struct fooalign
+{
+ char c;
+ union fooround u;
+};
/* If malloc were really smart, it would round addresses to DEFAULT_ALIGNMENT.
But in fact it might be less smart and round addresses to as much as
DEFAULT_ROUNDING. So we prepare for it to do that. */
-union fooround {long x; double d;};
-# define DEFAULT_ROUNDING (sizeof (union fooround))
+enum
+ {
+ DEFAULT_ALIGNMENT = offsetof (struct fooalign, u),
+ DEFAULT_ROUNDING = sizeof (union fooround)
+ };
/* When we copy a long block of data, this is the unit to do it with.
On some machines, copying successive ints does not work;
@@ -89,36 +104,29 @@ union fooround {long x; double d;};
abort gracefully or use longjump - but shouldn't return. This
variable by default points to the internal function
`print_and_abort'. */
-# if defined __STDC__ && __STDC__
static void print_and_abort (void);
-void (*obstack_alloc_failed_handler) (void) = print_and_abort;
-# else
-static void print_and_abort ();
-void (*obstack_alloc_failed_handler) () = print_and_abort;
-# endif
-
+static void (*__obstack_alloc_failed_handler) (void) = print_and_abort;
+strong_alias(__obstack_alloc_failed_handler,obstack_alloc_failed_handler)
/* Exit value used when `print_and_abort' is used. */
-# if defined __GNU_LIBRARY__ || defined HAVE_STDLIB_H
-# include <stdlib.h>
-# endif
-# ifndef EXIT_FAILURE
-# define EXIT_FAILURE 1
+# include <stdlib.h>
+# ifdef _LIBC
+static int __obstack_exit_failure = EXIT_FAILURE;
+strong_alias(__obstack_exit_failure,obstack_exit_failure)
+# else
+# include "exitfail.h"
+# define __obstack_exit_failure exit_failure
# endif
-libc_hidden_proto(fprintf)
-libc_hidden_proto(abort)
-libc_hidden_proto(exit)
-#ifdef __UCLIBC_HAS_WCHAR__
-libc_hidden_proto(fwprintf)
-#endif
-
-int obstack_exit_failure = EXIT_FAILURE;
-
-/* The non-GNU-C macros copy the obstack into this global variable
- to avoid multiple evaluation. */
-
-struct obstack *_obstack;
+# if 0
+# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3_4)
+/* A looong time ago (before 1994, anyway; we're not sure) this global variable
+ was used by non-GNU-C macros to avoid multiple evaluation. The GNU C
+ library still exports it because somebody might use it. */
+struct obstack *_obstack_compat;
+compat_symbol (libc, _obstack_compat, _obstack, GLIBC_2_0);
+# endif
+# endif
/* Define a macro that either calls functions with the traditional malloc/free
calling interface, or calls functions with the mmalloc/mfree interface
@@ -126,33 +134,18 @@ struct obstack *_obstack;
For free, do not use ?:, since some compilers, like the MIPS compilers,
do not allow (expr) ? void : void. */
-# if defined __STDC__ && __STDC__
-# define CALL_CHUNKFUN(h, size) \
+# define CALL_CHUNKFUN(h, size) \
(((h) -> use_extra_arg) \
? (*(h)->chunkfun) ((h)->extra_arg, (size)) \
: (*(struct _obstack_chunk *(*) (long)) (h)->chunkfun) ((size)))
-# define CALL_FREEFUN(h, old_chunk) \
+# define CALL_FREEFUN(h, old_chunk) \
do { \
if ((h) -> use_extra_arg) \
(*(h)->freefun) ((h)->extra_arg, (old_chunk)); \
else \
(*(void (*) (void *)) (h)->freefun) ((old_chunk)); \
} while (0)
-# else
-# define CALL_CHUNKFUN(h, size) \
- (((h) -> use_extra_arg) \
- ? (*(h)->chunkfun) ((h)->extra_arg, (size)) \
- : (*(struct _obstack_chunk *(*) ()) (h)->chunkfun) ((size)))
-
-# define CALL_FREEFUN(h, old_chunk) \
- do { \
- if ((h) -> use_extra_arg) \
- (*(h)->freefun) ((h)->extra_arg, (old_chunk)); \
- else \
- (*(void (*) ()) (h)->freefun) ((old_chunk)); \
- } while (0)
-# endif
/* Initialize an obstack H for use. Specify chunk size SIZE (0 means default).
@@ -164,23 +157,15 @@ struct obstack *_obstack;
allocation fails. */
int
-_obstack_begin (
- struct obstack *h,
- int size,
- int alignment,
-# if defined __STDC__ && __STDC__
- POINTER (*chunkfun) (long),
- void (*freefun) (void *)
-# else
- POINTER (*chunkfun) (),
- void (*freefun) ()
-# endif
- )
+_obstack_begin (struct obstack *h,
+ int size, int alignment,
+ void *(*chunkfun) (long),
+ void (*freefun) (void *))
{
register struct _obstack_chunk *chunk; /* points to new chunk */
if (alignment == 0)
- alignment = (int) DEFAULT_ALIGNMENT;
+ alignment = DEFAULT_ALIGNMENT;
if (size == 0)
/* Default size is what GNU malloc can fit in a 4096-byte block. */
{
@@ -198,21 +183,17 @@ _obstack_begin (
size = 4096 - extra;
}
-# if defined __STDC__ && __STDC__
h->chunkfun = (struct _obstack_chunk * (*)(void *, long)) chunkfun;
h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun;
-# else
- h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun;
- h->freefun = freefun;
-# endif
h->chunk_size = size;
h->alignment_mask = alignment - 1;
h->use_extra_arg = 0;
chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size);
if (!chunk)
- (*obstack_alloc_failed_handler) ();
- h->next_free = h->object_base = chunk->contents;
+ (*__obstack_alloc_failed_handler) ();
+ h->next_free = h->object_base = __PTR_ALIGN ((char *) chunk, chunk->contents,
+ alignment - 1);
h->chunk_limit = chunk->limit
= (char *) chunk + h->chunk_size;
chunk->prev = 0;
@@ -223,23 +204,15 @@ _obstack_begin (
}
int
-_obstack_begin_1 (
- struct obstack *h,
- int size,
- int alignment,
-# if defined __STDC__ && __STDC__
- POINTER (*chunkfun) (POINTER, long),
- void (*freefun) (POINTER, POINTER),
-# else
- POINTER (*chunkfun) (),
- void (*freefun) (),
-# endif
- POINTER arg)
+_obstack_begin_1 (struct obstack *h, int size, int alignment,
+ void *(*chunkfun) (void *, long),
+ void (*freefun) (void *, void *),
+ void *arg)
{
register struct _obstack_chunk *chunk; /* points to new chunk */
if (alignment == 0)
- alignment = (int) DEFAULT_ALIGNMENT;
+ alignment = DEFAULT_ALIGNMENT;
if (size == 0)
/* Default size is what GNU malloc can fit in a 4096-byte block. */
{
@@ -257,13 +230,8 @@ _obstack_begin_1 (
size = 4096 - extra;
}
-# if defined __STDC__ && __STDC__
h->chunkfun = (struct _obstack_chunk * (*)(void *,long)) chunkfun;
h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun;
-# else
- h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun;
- h->freefun = freefun;
-# endif
h->chunk_size = size;
h->alignment_mask = alignment - 1;
h->extra_arg = arg;
@@ -271,8 +239,9 @@ _obstack_begin_1 (
chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size);
if (!chunk)
- (*obstack_alloc_failed_handler) ();
- h->next_free = h->object_base = chunk->contents;
+ (*__obstack_alloc_failed_handler) ();
+ h->next_free = h->object_base = __PTR_ALIGN ((char *) chunk, chunk->contents,
+ alignment - 1);
h->chunk_limit = chunk->limit
= (char *) chunk + h->chunk_size;
chunk->prev = 0;
@@ -289,9 +258,7 @@ _obstack_begin_1 (
to the beginning of the new one. */
void
-_obstack_newchunk (
- struct obstack *h,
- int length)
+_obstack_newchunk (struct obstack *h, int length)
{
register struct _obstack_chunk *old_chunk = h->chunk;
register struct _obstack_chunk *new_chunk;
@@ -309,15 +276,14 @@ _obstack_newchunk (
/* Allocate and initialize the new chunk. */
new_chunk = CALL_CHUNKFUN (h, new_size);
if (!new_chunk)
- (*obstack_alloc_failed_handler) ();
+ (*__obstack_alloc_failed_handler) ();
h->chunk = new_chunk;
new_chunk->prev = old_chunk;
new_chunk->limit = h->chunk_limit = (char *) new_chunk + new_size;
/* Compute an aligned object_base in the new chunk */
object_base =
- __INT_TO_PTR ((__PTR_TO_INT (new_chunk->contents) + h->alignment_mask)
- & ~ (h->alignment_mask));
+ __PTR_ALIGN ((char *) new_chunk, new_chunk->contents, h->alignment_mask);
/* Move the existing object to the new chunk.
Word at a time is fast and is safe if the object
@@ -342,7 +308,10 @@ _obstack_newchunk (
/* If the object just copied was the only data in OLD_CHUNK,
free that chunk and remove it from the chain.
But not if that chunk might contain an empty object. */
- if (h->object_base == old_chunk->contents && ! h->maybe_empty_object)
+ if (! h->maybe_empty_object
+ && (h->object_base
+ == __PTR_ALIGN ((char *) old_chunk, old_chunk->contents,
+ h->alignment_mask)))
{
new_chunk->prev = old_chunk->prev;
CALL_FREEFUN (h, old_chunk);
@@ -353,21 +322,18 @@ _obstack_newchunk (
/* The new chunk certainly contains no empty object yet. */
h->maybe_empty_object = 0;
}
+libc_hidden_def(_obstack_newchunk)
/* Return nonzero if object OBJ has been allocated from obstack H.
This is here for debugging.
If you use it in a program, you are probably losing. */
-# if defined __STDC__ && __STDC__
/* Suppress -Wmissing-prototypes warning. We don't want to declare this in
obstack.h because it is just for debugging. */
-int _obstack_allocated_p (struct obstack *h, POINTER obj);
-# endif
+int _obstack_allocated_p (struct obstack *h, void *obj);
int
-_obstack_allocated_p (
- struct obstack *h,
- POINTER obj)
+_obstack_allocated_p (struct obstack *h, void *obj)
{
register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */
register struct _obstack_chunk *plp; /* point to previous chunk if any */
@@ -376,7 +342,7 @@ _obstack_allocated_p (
/* We use >= rather than > since the object cannot be exactly at
the beginning of the chunk but might be an empty object exactly
at the end of an adjacent chunk. */
- while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj))
+ while (lp != 0 && ((void *) lp >= obj || (void *) (lp)->limit < obj))
{
plp = lp->prev;
lp = plp;
@@ -389,13 +355,8 @@ _obstack_allocated_p (
# undef obstack_free
-/* This function has two names with identical definitions.
- This is the first one, called from non-ANSI code. */
-
void
-_obstack_free (
- struct obstack *h,
- POINTER obj)
+obstack_free (struct obstack *h, void *obj)
{
register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */
register struct _obstack_chunk *plp; /* point to previous chunk if any */
@@ -404,7 +365,7 @@ _obstack_free (
/* We use >= because there cannot be an object at the beginning of a chunk.
But there can be an empty object at that address
at the end of another chunk. */
- while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj))
+ while (lp != 0 && ((void *) lp >= obj || (void *) (lp)->limit < obj))
{
plp = lp->prev;
CALL_FREEFUN (h, lp);
@@ -424,43 +385,14 @@ _obstack_free (
abort ();
}
-/* This function is used from ANSI code. */
-
-void
-obstack_free (
- struct obstack *h,
- POINTER obj)
-{
- register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */
- register struct _obstack_chunk *plp; /* point to previous chunk if any */
-
- lp = h->chunk;
- /* We use >= because there cannot be an object at the beginning of a chunk.
- But there can be an empty object at that address
- at the end of another chunk. */
- while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj))
- {
- plp = lp->prev;
- CALL_FREEFUN (h, lp);
- lp = plp;
- /* If we switch chunks, we can't tell whether the new current
- chunk contains an empty object, so assume that it may. */
- h->maybe_empty_object = 1;
- }
- if (lp)
- {
- h->object_base = h->next_free = (char *) (obj);
- h->chunk_limit = lp->limit;
- h->chunk = lp;
- }
- else if (obj != 0)
- /* obj is not in any of the chunks! */
- abort ();
-}
+# if 0
+/* Older versions of libc used a function _obstack_free intended to be
+ called by non-GCC compilers. */
+strong_alias (obstack_free, _obstack_free)
+# endif
int
-_obstack_memory_used (
- struct obstack *h)
+_obstack_memory_used (struct obstack *h)
{
register struct _obstack_chunk* lp;
register int nbytes = 0;
@@ -473,20 +405,24 @@ _obstack_memory_used (
}
/* Define the error handler. */
+# ifdef _LIBC
+# include <libintl.h>
+# else
+# include "gettext.h"
+# endif
# ifndef _
-/* # if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC */
-# ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
-# include <libintl.h>
-# ifndef _
-# define _(Str) __dcgettext (NULL, Str, LC_MESSAGES)
-# endif
-# else
-# define _(Str) (Str)
-# endif
+# define _(msgid) gettext (msgid)
# endif
-# if defined _LIBC && defined USE_IN_LIBIO
+
+# if defined _LIBC && !defined __UCLIBC__
# include <libio/iolibio.h>
-# define fputs(s, f) _IO_fputs (s, f)
+# endif
+
+# ifndef __attribute__
+/* This feature is available in gcc versions 2.5 and later. */
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
+# define __attribute__(Spec) /* empty */
+# endif
# endif
static void
@@ -498,135 +434,12 @@ print_and_abort (void)
happen because the "memory exhausted" message appears in other places
like this and the translation should be reused instead of creating
a very similar string which requires a separate translation. */
-# if defined _LIBC && defined USE_IN_LIBIO
- if (_IO_fwide (stderr, 0) > 0)
- fwprintf (stderr, L"%s\n", _("memory exhausted"));
- else
+# if defined _LIBC && !defined __UCLIBC__
+ (void) __fxprintf (NULL, "%s\n", _("memory exhausted"));
+# else
+ fprintf (stderr, "%s\n", _("memory exhausted"));
# endif
- fprintf (stderr, "%s\n", _("memory exhausted"));
- exit (obstack_exit_failure);
-}
-
-# if 0
-/* These are now turned off because the applications do not use it
- and it uses bcopy via obstack_grow, which causes trouble on sysV. */
-
-/* Now define the functional versions of the obstack macros.
- Define them to simply use the corresponding macros to do the job. */
-
-# if defined __STDC__ && __STDC__
-/* These function definitions do not work with non-ANSI preprocessors;
- they won't pass through the macro names in parentheses. */
-
-/* The function names appear in parentheses in order to prevent
- the macro-definitions of the names from being expanded there. */
-
-POINTER (obstack_base) (obstack)
- struct obstack *obstack;
-{
- return obstack_base (obstack);
-}
-
-POINTER (obstack_next_free) (obstack)
- struct obstack *obstack;
-{
- return obstack_next_free (obstack);
-}
-
-int (obstack_object_size) (obstack)
- struct obstack *obstack;
-{
- return obstack_object_size (obstack);
-}
-
-int (obstack_room) (obstack)
- struct obstack *obstack;
-{
- return obstack_room (obstack);
-}
-
-int (obstack_make_room) (obstack, length)
- struct obstack *obstack;
- int length;
-{
- return obstack_make_room (obstack, length);
+ exit (__obstack_exit_failure);
}
-void (obstack_grow) (obstack, data, length)
- struct obstack *obstack;
- const POINTER data;
- int length;
-{
- obstack_grow (obstack, data, length);
-}
-
-void (obstack_grow0) (obstack, data, length)
- struct obstack *obstack;
- const POINTER data;
- int length;
-{
- obstack_grow0 (obstack, data, length);
-}
-
-void (obstack_1grow) (obstack, character)
- struct obstack *obstack;
- int character;
-{
- obstack_1grow (obstack, character);
-}
-
-void (obstack_blank) (obstack, length)
- struct obstack *obstack;
- int length;
-{
- obstack_blank (obstack, length);
-}
-
-void (obstack_1grow_fast) (obstack, character)
- struct obstack *obstack;
- int character;
-{
- obstack_1grow_fast (obstack, character);
-}
-
-void (obstack_blank_fast) (obstack, length)
- struct obstack *obstack;
- int length;
-{
- obstack_blank_fast (obstack, length);
-}
-
-POINTER (obstack_finish) (obstack)
- struct obstack *obstack;
-{
- return obstack_finish (obstack);
-}
-
-POINTER (obstack_alloc) (obstack, length)
- struct obstack *obstack;
- int length;
-{
- return obstack_alloc (obstack, length);
-}
-
-POINTER (obstack_copy) (obstack, address, length)
- struct obstack *obstack;
- const POINTER address;
- int length;
-{
- return obstack_copy (obstack, address, length);
-}
-
-POINTER (obstack_copy0) (obstack, address, length)
- struct obstack *obstack;
- const POINTER address;
- int length;
-{
- return obstack_copy0 (obstack, address, length);
-}
-
-# endif /* __STDC__ */
-
-# endif /* 0 */
-
#endif /* !ELIDE_CODE */
diff --git a/libc/misc/internals/Makefile.in b/libc/misc/internals/Makefile.in
index 1356745d6..ae094ee23 100644
--- a/libc/misc/internals/Makefile.in
+++ b/libc/misc/internals/Makefile.in
@@ -1,19 +1,23 @@
# 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.
#
-CFLAGS-__uClibc_main.c := $(SSP_DISABLE_FLAGS)
+subdirs += libc/misc/internals
-CSRC := tempname.c errno.c __errno_location.c __h_errno_location.c
+CSRC-y := tempname.c errno.c h_errno.c __errno_location.c __h_errno_location.c \
+ parse_config.c
MISC_INTERNALS_DIR := $(top_srcdir)libc/misc/internals
MISC_INTERNALS_OUT := $(top_builddir)libc/misc/internals
-MISC_INTERNALS_SRC := $(patsubst %.c,$(MISC_INTERNALS_DIR)/%.c,$(CSRC))
-MISC_INTERNALS_OBJ := $(patsubst %.c,$(MISC_INTERNALS_OUT)/%.o,$(CSRC))
+MISC_INTERNALS_SRC := $(patsubst %.c,$(MISC_INTERNALS_DIR)/%.c,$(CSRC-y))
+MISC_INTERNALS_OBJ := $(patsubst %.c,$(MISC_INTERNALS_OUT)/%.o,$(CSRC-y))
+
+CFLAGS-__uClibc_main.c := $(SSP_DISABLE_FLAGS)
+
libc-y += $(MISC_INTERNALS_OBJ)
ifneq ($(UCLIBC_FORMAT_SHARED_FLAT),y)
@@ -33,7 +37,7 @@ libc-shared-$(UCLIBC_FORMAT_SHARED_FLAT) += \
$(MISC_INTERNALS_OUT)/shared_flat_add_library.os
libc-nomulti-y += $(MISC_INTERNALS_OUT)/__uClibc_main.o
-objclean-y += misc_internals_objclean
+objclean-y += CLEAN_libc/misc/internals
-misc_internals_objclean:
- $(RM) $(MISC_INTERNALS_OUT)/*.{o,os,oS}
+CLEAN_libc/misc/internals:
+ $(do_rm) $(addprefix $(MISC_INTERNALS_OUT)/*., o os oS)
diff --git a/libc/misc/internals/__errno_location.c b/libc/misc/internals/__errno_location.c
index a44bf6062..6c359f933 100644
--- a/libc/misc/internals/__errno_location.c
+++ b/libc/misc/internals/__errno_location.c
@@ -4,14 +4,15 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#include "internal_errno.h"
+#include <features.h>
+#include <errno.h>
-/* psm: moved to bits/errno.h: libc_hidden_proto(__errno_location) */
-libc_hidden_proto(__errno_location)
-int * weak_const_function __errno_location (void)
+#ifndef __UCLIBC_HAS_TLS__
+# undef errno
+extern int errno;
+#endif
+
+int weak_const_function *__errno_location(void)
{
return &errno;
}
-#ifdef IS_IN_libc /* not really need, only to keep in sync w/ libc_hidden_proto */
-libc_hidden_weak(__errno_location)
-#endif
diff --git a/libc/misc/internals/__h_errno_location.c b/libc/misc/internals/__h_errno_location.c
index 2ac21774c..c510c8143 100644
--- a/libc/misc/internals/__h_errno_location.c
+++ b/libc/misc/internals/__h_errno_location.c
@@ -4,11 +4,15 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#include "internal_errno.h"
+#include <features.h>
+#include <netdb.h>
-libc_hidden_proto(__h_errno_location)
-int * weak_const_function __h_errno_location (void)
+#ifndef __UCLIBC_HAS_TLS__
+# undef h_errno
+extern int h_errno;
+#endif
+
+int weak_const_function *__h_errno_location(void)
{
return &h_errno;
}
-libc_hidden_weak(__h_errno_location)
diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c
index 6c0dab7fe..632a2528e 100644
--- a/libc/misc/internals/__uClibc_main.c
+++ b/libc/misc/internals/__uClibc_main.c
@@ -1,5 +1,6 @@
/*
- * Copyright (C) Feb 2001 Manuel Novoa III
+ * Copyright (C) 2006 by Steven J. Hill <sjhill@realitydiluted.com>
+ * Copyright (C) 2001 by Manuel Novoa III <mjn3@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.
@@ -13,7 +14,6 @@
* avoided in the static library case.
*/
-#define _ERRNO_H
#include <features.h>
#include <unistd.h>
#include <stdlib.h>
@@ -22,69 +22,119 @@
#include <link.h>
#include <bits/uClibc_page.h>
#include <paths.h>
-#include <asm/errno.h>
+#include <errno.h>
+#include <netdb.h>
+#include <stdio.h>
+#ifndef __ARCH_HAS_NO_LDSO__
#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/sysmacros.h>
-
-libc_hidden_proto(exit)
-
-#ifdef __UCLIBC_HAS_PROGRAM_INVOCATION_NAME__
-/* Experimentally off - libc_hidden_proto(strrchr) */
#endif
-#ifndef __ARCH_HAS_NO_LDSO__
-/* Experimentally off - libc_hidden_proto(memcpy) */
-libc_hidden_proto(getgid)
-libc_hidden_proto(getuid)
-libc_hidden_proto(getegid)
-libc_hidden_proto(geteuid)
-libc_hidden_proto(fstat)
-libc_hidden_proto(abort)
-
-extern __typeof(open) __libc_open;
-libc_hidden_proto(__libc_open)
-extern __typeof(fcntl) __libc_fcntl;
-libc_hidden_proto(__libc_fcntl)
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <pthread-functions.h>
+#include <not-cancel.h>
+#include <atomic.h>
+#include <tls.h>
+#endif
+#ifdef __UCLIBC_HAS_THREADS__
+#include <pthread.h>
+#endif
+#ifdef __UCLIBC_HAS_LOCALE__
+#include <locale.h>
#endif
+/* Are we in a secure process environment or are we dealing
+ * with setuid stuff? If we are dynamically linked, then we
+ * already have _dl_secure, otherwise we need to re-examine
+ * auxvt[] below.
+ */
+int _pe_secure = 0;
+libc_hidden_data_def(_pe_secure)
+
#ifndef SHARED
-void *__libc_stack_end=NULL;
+void *__libc_stack_end = NULL;
# ifdef __UCLIBC_HAS_SSP__
# include <dl-osinfo.h>
+static uintptr_t stack_chk_guard;
# ifndef THREAD_SET_STACK_GUARD
/* Only exported for architectures that don't store the stack guard canary
* in thread local area. */
-# include <stdint.h>
-uintptr_t stack_chk_guard;
/* for gcc-4.1 non-TLS */
uintptr_t __stack_chk_guard attribute_relro;
+# endif
/* for gcc-3.x + Etoh ssp */
-# ifdef __UCLIBC_HAS_SSP_COMPAT__
-# ifdef __HAVE_SHARED__
-strong_alias(__stack_chk_guard,__guard)
-# else
-uintptr_t __guard attribute_relro;
-# endif
-# endif
-# elif defined __UCLIBC_HAS_SSP_COMPAT__
+# ifdef __UCLIBC_HAS_SSP_COMPAT__
uintptr_t __guard attribute_relro;
# endif
# endif
+/*
+ * Needed to initialize _dl_phdr when statically linked
+ */
+
+void internal_function _dl_aux_init (ElfW(auxv_t) *av);
+
+#ifdef __UCLIBC_HAS_THREADS__
+/*
+ * uClibc internal locking requires that we have weak aliases
+ * for dummy functions in case libpthread.a is not linked in.
+ * This needs to be in compilation unit that is pulled always
+ * in or linker will disregard these weaks.
+ */
+
+static int __pthread_return_0 (pthread_mutex_t *unused) { return 0; }
+weak_alias (__pthread_return_0, __pthread_mutex_lock)
+weak_alias (__pthread_return_0, __pthread_mutex_trylock)
+weak_alias (__pthread_return_0, __pthread_mutex_unlock)
+
+int weak_function
+__pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
+{
+ return 0;
+}
+
+void weak_function
+_pthread_cleanup_push_defer(struct _pthread_cleanup_buffer *__buffer,
+ void (*__routine) (void *), void *__arg)
+{
+ __buffer->__routine = __routine;
+ __buffer->__arg = __arg;
+}
+
+void weak_function
+_pthread_cleanup_pop_restore(struct _pthread_cleanup_buffer *__buffer,
+ int __execute)
+{
+ if (__execute)
+ __buffer->__routine(__buffer->__arg);
+}
+#endif /* __UCLIBC_HAS_THREADS__ */
+
#endif /* !SHARED */
+/* Defeat compiler optimization which assumes function addresses are never NULL */
+static __always_inline int not_null_ptr(const void *p)
+{
+ const void *q;
+ __asm__ (""
+ : "=r" (q) /* output */
+ : "0" (p) /* input */
+ );
+ return q != 0;
+}
+
/*
* Prototypes.
*/
-extern void weak_function _stdio_init(void) attribute_hidden;
-extern int *weak_const_function __errno_location(void);
-extern int *weak_const_function __h_errno_location(void);
-#ifdef __UCLIBC_HAS_LOCALE__
-extern void weak_function _locale_init(void) attribute_hidden;
-#endif
#ifdef __UCLIBC_HAS_THREADS__
+#if !defined (__UCLIBC_HAS_THREADS_NATIVE__) || defined (SHARED)
extern void weak_function __pthread_initialize_minimal(void);
+#else
+extern void __pthread_initialize_minimal(void);
+#endif
+#endif
+
+#ifndef SHARED
+extern void __libc_setup_tls (size_t tcbsize, size_t tcbalign);
#endif
/* If __UCLIBC_FORMAT_SHARED_FLAT__, all array initialisation and finalisation
@@ -103,25 +153,33 @@ extern void (*__fini_array_end []) (void) attribute_hidden;
# endif
#endif
-attribute_hidden const char *__uclibc_progname = "";
-#ifdef __UCLIBC_HAS_PROGRAM_INVOCATION_NAME__
-const char *program_invocation_short_name = "";
-const char *program_invocation_name = "";
+#ifdef SHARED
+extern int _dl_secure;
+#endif
+extern size_t _dl_pagesize;
+
+const char *__uclibc_progname = "";
+#if !defined __UCLIBC_HAS___PROGNAME__ && defined __USE_GNU && defined __UCLIBC_HAS_PROGRAM_INVOCATION_NAME__
+# define __progname program_invocation_short_name
+# define __progname_full program_invocation_name
#endif
-#ifdef __UCLIBC_HAS___PROGNAME__
-weak_alias (program_invocation_short_name, __progname)
-weak_alias (program_invocation_name, __progname_full)
+#if defined __UCLIBC_HAS___PROGNAME__ || (defined __USE_GNU && defined __UCLIBC_HAS_PROGRAM_INVOCATION_NAME__)
+const char *__progname = "";
+/* psm: why have a visible __progname_full? */
+const char *__progname_full = "";
+# if defined __UCLIBC_HAS___PROGNAME__ && defined __USE_GNU && defined __UCLIBC_HAS_PROGRAM_INVOCATION_NAME__
+weak_alias (__progname, program_invocation_short_name)
+weak_alias (__progname_full, program_invocation_name)
+# endif
#endif
/*
- * Declare the __environ global variable and create a strong alias environ.
- * Note: Apparently we must initialize __environ to ensure that the strong
- * environ symbol is also included.
+ * Declare the __environ global variable and create a weak alias environ.
+ * This must be initialized; we cannot have a weak alias into bss.
*/
char **__environ = 0;
weak_alias(__environ, environ)
-/* TODO: don't export __pagesize; we cant now because libpthread uses it */
size_t __pagesize = 0;
#ifndef O_NOFOLLOW
@@ -132,13 +190,13 @@ size_t __pagesize = 0;
static void __check_one_fd(int fd, int mode)
{
/* Check if the specified fd is already open */
- if (__libc_fcntl(fd, F_GETFD) == -1)
+ if (fcntl(fd, F_GETFD) == -1)
{
/* The descriptor is probably not open, so try to use /dev/null */
- int nullfd = __libc_open(_PATH_DEVNULL, mode);
+ int nullfd = open(_PATH_DEVNULL, mode);
/* /dev/null is major=1 minor=3. Make absolutely certain
* that is in fact the device that we have opened and not
- * some other wierd file... */
+ * some other wierd file... [removed in uclibc] */
if (nullfd!=fd)
{
abort();
@@ -146,6 +204,7 @@ static void __check_one_fd(int fd, int mode)
}
}
+#ifndef SHARED
static int __check_suid(void)
{
uid_t uid, euid;
@@ -162,6 +221,7 @@ static int __check_suid(void)
return 0; /* we are not suid */
}
#endif
+#endif
/* __uClibc_init completely initialize uClibc so it is ready to use.
*
@@ -176,26 +236,32 @@ static int __check_suid(void)
* __uClibc_main.
*/
-extern void __uClibc_init(void);
-libc_hidden_proto(__uClibc_init)
+extern void __uClibc_init(void) attribute_hidden;
void __uClibc_init(void)
{
- static smallint been_there_done_that;
-
- if (been_there_done_that)
+ /* Don't recurse */
+ if (__pagesize)
return;
- been_there_done_that++;
/* Setup an initial value. This may not be perfect, but is
* better than malloc using __pagesize=0 for atexit, ctors, etc. */
__pagesize = PAGE_SIZE;
#ifdef __UCLIBC_HAS_THREADS__
+
+#if defined (__UCLIBC_HAS_THREADS_NATIVE__) && !defined (SHARED)
+ /* Unlike in the dynamically linked case the dynamic linker has not
+ taken care of initializing the TLS data structures. */
+ __libc_setup_tls (TLS_TCB_SIZE, TLS_TCB_ALIGN);
+#endif
+
/* Before we start initializing uClibc we have to call
* __pthread_initialize_minimal so we can use pthread_locks
* whenever they are needed.
*/
+#if !defined (__UCLIBC_HAS_THREADS_NATIVE__) || defined (SHARED)
if (likely(__pthread_initialize_minimal!=NULL))
+#endif
__pthread_initialize_minimal();
#endif
@@ -205,21 +271,18 @@ void __uClibc_init(void)
stack_chk_guard = _dl_setup_stack_chk_guard();
# ifdef THREAD_SET_STACK_GUARD
THREAD_SET_STACK_GUARD (stack_chk_guard);
-# ifdef __UCLIBC_HAS_SSP_COMPAT__
- __guard = stack_chk_guard;
-# endif
# else
__stack_chk_guard = stack_chk_guard;
-# if !defined __HAVE_SHARED__ && defined __UCLIBC_HAS_SSP_COMPAT__
- __guard = stack_chk_guard;
-# endif
+# endif
+# ifdef __UCLIBC_HAS_SSP_COMPAT__
+ __guard = stack_chk_guard;
# endif
# endif
#endif
#ifdef __UCLIBC_HAS_LOCALE__
/* Initialize the global locale structure. */
- if (likely(_locale_init!=NULL))
+ if (likely(not_null_ptr(_locale_init)))
_locale_init();
#endif
@@ -229,11 +292,10 @@ void __uClibc_init(void)
* Thus we get a nice size savings because the stdio functions
* won't be pulled into the final static binary unless used.
*/
- if (likely(_stdio_init != NULL))
+ if (likely(not_null_ptr(_stdio_init)))
_stdio_init();
}
-libc_hidden_def(__uClibc_init)
#ifdef __UCLIBC_CTOR_DTOR__
void attribute_hidden (*__app_fini)(void) = NULL;
@@ -241,8 +303,7 @@ void attribute_hidden (*__app_fini)(void) = NULL;
void attribute_hidden (*__rtld_fini)(void) = NULL;
-extern void __uClibc_fini(void);
-libc_hidden_proto(__uClibc_fini)
+extern void __uClibc_fini(void) attribute_hidden;
void __uClibc_fini(void)
{
#ifdef __UCLIBC_CTOR_DTOR__
@@ -261,7 +322,11 @@ void __uClibc_fini(void)
if (__rtld_fini != NULL)
(__rtld_fini)();
}
-libc_hidden_def(__uClibc_fini)
+
+#ifndef SHARED
+extern void __nptl_deallocate_tsd (void) __attribute ((weak));
+extern unsigned int __nptl_nthreads __attribute ((weak));
+#endif
/* __uClibc_main is the new main stub for uClibc. This function is
* called from crt1 (version 0.9.28 or newer), after ALL shared libraries
@@ -269,16 +334,22 @@ libc_hidden_def(__uClibc_fini)
*/
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_noreturn;
+ void (*rtld_fini)(void),
+ void *stack_end attribute_unused) attribute_noreturn;
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)
+ void (*rtld_fini)(void), void *stack_end attribute_unused)
{
-#ifndef __ARCH_HAS_NO_LDSO__
+#if !defined __ARCH_HAS_NO_LDSO__ && !defined SHARED
unsigned long *aux_dat;
ElfW(auxv_t) auxvt[AT_EGID + 1];
#endif
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ /* Result of the 'main' function. */
+ int result;
+#endif
+
#ifndef SHARED
__libc_stack_end = stack_end;
#endif
@@ -289,13 +360,13 @@ void __uClibc_main(int (*main)(int, char **, char **), int argc,
__environ = &argv[argc + 1];
/* If the first thing after argv is the arguments
- * the the environment is empty. */
+ * then the environment is empty. */
if ((char *) __environ == *argv) {
/* Make __environ point to the NULL at argv[argc] */
__environ = &argv[argc];
}
-#ifndef __ARCH_HAS_NO_LDSO__
+#if !defined __ARCH_HAS_NO_LDSO__ && !defined SHARED
/* Pull stuff from the ELF header when possible */
memset(auxvt, 0x00, sizeof(auxvt));
aux_dat = (unsigned long*)__environ;
@@ -310,6 +381,10 @@ void __uClibc_main(int (*main)(int, char **, char **), int argc,
}
aux_dat += 2;
}
+ /* Get the program headers (_dl_phdr) from the aux vector
+ It will be used into __libc_setup_tls. */
+
+ _dl_aux_init (auxvt);
#endif
/* We need to initialize uClibc. If we are dynamically linked this
@@ -318,31 +393,39 @@ void __uClibc_main(int (*main)(int, char **, char **), int argc,
__uClibc_init();
#ifndef __ARCH_HAS_NO_LDSO__
- /* Make certain getpagesize() gives the correct answer */
- __pagesize = (auxvt[AT_PAGESZ].a_un.a_val)? auxvt[AT_PAGESZ].a_un.a_val : PAGE_SIZE;
+ /* Make certain getpagesize() gives the correct answer.
+ * _dl_pagesize is defined into ld.so if SHARED or into libc.a otherwise. */
+ __pagesize = _dl_pagesize;
+#ifndef SHARED
/* Prevent starting SUID binaries where the stdin. stdout, and
* stderr file descriptors are not already opened. */
if ((auxvt[AT_UID].a_un.a_val == (size_t)-1 && __check_suid()) ||
(auxvt[AT_UID].a_un.a_val != (size_t)-1 &&
(auxvt[AT_UID].a_un.a_val != auxvt[AT_EUID].a_un.a_val ||
auxvt[AT_GID].a_un.a_val != auxvt[AT_EGID].a_un.a_val)))
+#else
+ if (_dl_secure)
+#endif
{
__check_one_fd (STDIN_FILENO, O_RDONLY | O_NOFOLLOW);
__check_one_fd (STDOUT_FILENO, O_RDWR | O_NOFOLLOW);
__check_one_fd (STDERR_FILENO, O_RDWR | O_NOFOLLOW);
+ _pe_secure = 1 ;
}
+ else
+ _pe_secure = 0 ;
#endif
__uclibc_progname = *argv;
-#ifdef __UCLIBC_HAS_PROGRAM_INVOCATION_NAME__
+#if defined __UCLIBC_HAS___PROGNAME__ || (defined __USE_GNU && defined __UCLIBC_HAS_PROGRAM_INVOCATION_NAME__)
if (*argv != NULL) {
- program_invocation_name = *argv;
- program_invocation_short_name = strrchr(*argv, '/');
- if (program_invocation_short_name != NULL)
- ++program_invocation_short_name;
+ __progname_full = *argv;
+ __progname = strrchr(*argv, '/');
+ if (__progname != NULL)
+ ++__progname;
else
- program_invocation_short_name = program_invocation_name;
+ __progname = *argv;
}
#endif
@@ -385,41 +468,62 @@ void __uClibc_main(int (*main)(int, char **, char **), int argc,
* have resulted in errno being set nonzero, so set it to 0 before
* we call main.
*/
- if (likely(__errno_location!=NULL))
+ if (likely(not_null_ptr(__errno_location)))
*(__errno_location()) = 0;
/* Set h_errno to 0 as well */
- if (likely(__h_errno_location!=NULL))
+ if (likely(not_null_ptr(__h_errno_location)))
*(__h_errno_location()) = 0;
- /*
- * Finally, invoke application's main and then exit.
- */
- exit(main(argc, argv, __environ));
-}
+#if defined HAVE_CLEANUP_JMP_BUF && defined __UCLIBC_HAS_THREADS_NATIVE__
+ /* Memory for the cancellation buffer. */
+ struct pthread_unwind_buf unwind_buf;
-#if defined(__UCLIBC_HAS_THREADS__) && !defined(SHARED)
-/* Weaks for internal library use only.
- *
- * We need to define weaks here to cover all the pthread functions that
- * libc itself will use so that we aren't forced to link libc against
- * libpthread. This file is only used in libc.a and since we have
- * weaks here, they will be automatically overridden by libpthread.a
- * if it gets linked in.
- */
+ int not_first_call;
+ not_first_call =
+ setjmp ((struct __jmp_buf_tag *) unwind_buf.cancel_jmp_buf);
+ if (__builtin_expect (! not_first_call, 1))
+ {
+ struct pthread *self = THREAD_SELF;
-static int __pthread_return_0 (void) { return 0; }
-static void __pthread_return_void (void) { return; }
+ /* Store old info. */
+ unwind_buf.priv.data.prev = THREAD_GETMEM (self, cleanup_jmp_buf);
+ unwind_buf.priv.data.cleanup = THREAD_GETMEM (self, cleanup);
-weak_alias (__pthread_return_0, __pthread_mutex_init)
-weak_alias (__pthread_return_0, __pthread_mutex_lock)
-weak_alias (__pthread_return_0, __pthread_mutex_trylock)
-weak_alias (__pthread_return_0, __pthread_mutex_unlock)
-weak_alias (__pthread_return_void, _pthread_cleanup_push_defer)
-weak_alias (__pthread_return_void, _pthread_cleanup_pop_restore)
-# ifdef __UCLIBC_HAS_THREADS_NATIVE__
-weak_alias (__pthread_return_0, __pthread_mutexattr_init)
-weak_alias (__pthread_return_0, __pthread_mutexattr_destroy)
-weak_alias (__pthread_return_0, __pthread_mutexattr_settype)
+ /* Store the new cleanup handler info. */
+ THREAD_SETMEM (self, cleanup_jmp_buf, &unwind_buf);
+
+ /* Run the program. */
+ result = main (argc, argv, __environ);
+ }
+ else
+ {
+ /* Remove the thread-local data. */
+# ifdef SHARED
+ __libc_pthread_functions.ptr__nptl_deallocate_tsd ();
+# else
+ __nptl_deallocate_tsd ();
+# endif
+
+ /* One less thread. Decrement the counter. If it is zero we
+ terminate the entire process. */
+ result = 0;
+# ifdef SHARED
+ unsigned int *const ptr = __libc_pthread_functions.ptr_nthreads;
+# else
+ unsigned int *const ptr = &__nptl_nthreads;
# endif
+
+ if (! atomic_decrement_and_test (ptr))
+ /* Not much left to do but to exit the thread, not the process. */
+ __exit_thread_inline (0);
+ }
+
+ exit (result);
+#else
+ /*
+ * Finally, invoke application's main and then exit.
+ */
+ exit (main (argc, argv, __environ));
#endif
+}
diff --git a/libc/misc/internals/errno.c b/libc/misc/internals/errno.c
index fcf143fb5..d9908853d 100644
--- a/libc/misc/internals/errno.c
+++ b/libc/misc/internals/errno.c
@@ -1,15 +1,14 @@
-#include "internal_errno.h"
+#include <features.h>
+#include <errno.h>
+#undef errno
-#ifdef __UCLIBC_HAS_THREADS__
-libc_hidden_proto(errno)
-libc_hidden_proto(h_errno)
-#endif
+#ifdef __UCLIBC_HAS_TLS__
+__thread int errno;
+extern __thread int __libc_errno __attribute__ ((alias ("errno"))) attribute_hidden;
+#else
+extern int errno;
int errno = 0;
-int h_errno = 0;
-
-#ifdef __UCLIBC_HAS_THREADS__
-libc_hidden_def(errno)
-weak_alias(errno, _errno)
-libc_hidden_def(h_errno)
-weak_alias(h_errno, _h_errno)
+# ifdef __UCLIBC_HAS_THREADS__
+strong_alias(errno,_errno)
+# endif
#endif
diff --git a/libc/misc/internals/h_errno.c b/libc/misc/internals/h_errno.c
new file mode 100644
index 000000000..8e457501e
--- /dev/null
+++ b/libc/misc/internals/h_errno.c
@@ -0,0 +1,14 @@
+#include <features.h>
+#include <netdb.h>
+#undef h_errno
+
+#ifdef __UCLIBC_HAS_TLS__
+__thread int h_errno;
+extern __thread int __libc_h_errno __attribute__ ((alias ("h_errno"))) attribute_hidden;
+#else
+extern int h_errno;
+int h_errno = 0;
+# ifdef __UCLIBC_HAS_THREADS__
+strong_alias(h_errno,_h_errno)
+# endif
+#endif
diff --git a/libc/misc/internals/internal_errno.h b/libc/misc/internals/internal_errno.h
deleted file mode 100644
index a93d0bf02..000000000
--- a/libc/misc/internals/internal_errno.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- *
- */
-
-#include <features.h>
-#include <errno.h>
-#include <netdb.h>
-
-#undef errno
-#undef h_errno
-
-extern int h_errno;
-extern int errno;
-
-#ifdef __UCLIBC_HAS_THREADS__
-libc_hidden_proto(h_errno)
-libc_hidden_proto(errno)
-#endif
diff --git a/libc/misc/internals/parse_config.c b/libc/misc/internals/parse_config.c
new file mode 100644
index 000000000..b79b7a081
--- /dev/null
+++ b/libc/misc/internals/parse_config.c
@@ -0,0 +1,278 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * config file parser helper
+ *
+ * Copyright (C) 2008 by Vladimir Dronnikov <dronnikov@gmail.com>
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Also for use in uClibc (http://uclibc.org/) licensed under LGPLv2.1 or later.
+ */
+
+#if !defined _LIBC
+#include "libbb.h"
+
+#if defined ENABLE_PARSE && ENABLE_PARSE
+int parse_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+int parse_main(int argc UNUSED_PARAM, char **argv)
+{
+ const char *delims = "# \t";
+ unsigned flags = PARSE_NORMAL;
+ int mintokens = 0, ntokens = 128;
+
+ opt_complementary = "-1:n+:m+:f+";
+ getopt32(argv, "n:m:d:f:", &ntokens, &mintokens, &delims, &flags);
+ //argc -= optind;
+ argv += optind;
+ while (*argv) {
+ parser_t *p = config_open(*argv);
+ if (p) {
+ int n;
+ char **t = xmalloc(sizeof(char *) * ntokens);
+ while ((n = config_read(p, t, ntokens, mintokens, delims, flags)) != 0) {
+ for (int i = 0; i < n; ++i)
+ printf("[%s]", t[i]);
+ puts("");
+ }
+ config_close(p);
+ }
+ argv++;
+ }
+ return EXIT_SUCCESS;
+}
+#endif
+#else
+# include <unistd.h>
+# include <string.h>
+# include <malloc.h>
+# include <bits/uClibc_page.h>
+# include "internal/parse_config.h"
+# ifndef FAST_FUNC
+# define FAST_FUNC
+# endif
+# define fopen_or_warn_stdin fopen
+# define bb_error_msg(...)
+# define xstrdup strdup
+# define xfunc_die() return 0
+/* Read up to EOF or EOL, treat line-continuations as extending the line.
+ Return number of bytes read into .line, -1 otherwise */
+static off_t bb_get_chunk_with_continuation(parser_t* parsr)
+{
+ off_t pos = 0;
+ char *chp;
+
+ while (1) {
+ if (fgets(parsr->line + pos, parsr->line_len - pos, parsr->fp) == NULL) {
+ memset(parsr->line, 0, parsr->line_len);
+ pos = -1;
+ break;
+ }
+ pos += strlen(parsr->line + pos);
+ chp = strchr(parsr->line, '\n');
+ if (chp) {
+ --pos;
+ if (--*chp == '\\')
+ --pos;
+ else
+ break;
+ } else if (parsr->allocated) {
+ parsr->line_len += PAGE_SIZE;
+ parsr->data = realloc(parsr->data,
+ parsr->data_len + parsr->line_len);
+ parsr->line = parsr->data + parsr->data_len;
+ } else {
+ /* discard rest of line if not enough space in buffer */
+ int c;
+ do {
+ c = fgetc(parsr->fp);
+ } while (c != EOF && c != '\n');
+ break;
+ }
+ }
+ return pos;
+}
+#endif
+
+/*
+
+Typical usage:
+
+----- CUT -----
+ char *t[3]; // tokens placeholder
+ parser_t *p = config_open(filename);
+ if (p) {
+ // parse line-by-line
+ while (config_read(p, t, 3, 0, delimiters, flags)) { // 1..3 tokens
+ // use tokens
+ bb_error_msg("TOKENS: [%s][%s][%s]", t[0], t[1], t[2]);
+ }
+ ...
+ // free parser
+ config_close(p);
+ }
+----- CUT -----
+
+*/
+
+static __always_inline parser_t * FAST_FUNC config_open2(const char *filename,
+ FILE* FAST_FUNC (*fopen_func)(const char *path, const char *mode))
+{
+ parser_t *parser;
+ FILE* fp;
+
+ fp = fopen_func(filename, "r");
+ if (!fp)
+ return NULL;
+ parser = calloc(1, sizeof(*parser));
+ if (parser) {
+ parser->fp = fp;
+ }
+ return parser;
+}
+
+parser_t * FAST_FUNC config_open(const char *filename)
+{
+ return config_open2(filename, fopen_or_warn_stdin);
+}
+
+#ifdef UNUSED
+static void config_free_data(parser_t *parser)
+{
+ free(parser->data);
+ parser->data = parser->line = NULL;
+}
+#endif
+
+void FAST_FUNC config_close(parser_t *parser)
+{
+ if (parser) {
+ fclose(parser->fp);
+ if (parser->allocated)
+ free(parser->data);
+ free(parser);
+ }
+}
+
+/*
+0. If parser is NULL return 0.
+1. Read a line from config file. If nothing to read then return 0.
+ Handle continuation character. Advance lineno for each physical line.
+ Discard everything past comment character.
+2. if PARSE_TRIM is set (default), remove leading and trailing delimiters.
+3. If resulting line is empty goto 1.
+4. Look for first delimiter. If !PARSE_COLLAPSE or !PARSE_TRIM is set then
+ remember the token as empty.
+5. Else (default) if number of seen tokens is equal to max number of tokens
+ (token is the last one) and PARSE_GREEDY is set then the remainder
+ of the line is the last token.
+ Else (token is not last or PARSE_GREEDY is not set) just replace
+ first delimiter with '\0' thus delimiting the token.
+6. Advance line pointer past the end of token. If number of seen tokens
+ is less than required number of tokens then goto 4.
+7. Check the number of seen tokens is not less the min number of tokens.
+ Complain or die otherwise depending on PARSE_MIN_DIE.
+8. Return the number of seen tokens.
+
+mintokens > 0 make config_read() print error message if less than mintokens
+(but more than 0) are found. Empty lines are always skipped (not warned about).
+*/
+#undef config_read
+int FAST_FUNC config_read(parser_t *parser, char ***tokens,
+ unsigned flags, const char *delims)
+{
+ char *line;
+ int ntokens, mintokens;
+ off_t len;
+ int t;
+
+ if (parser == NULL)
+ return 0;
+ ntokens = flags & 0xFF;
+ mintokens = (flags & 0xFF00) >> 8;
+again:
+ if (parser->data == NULL) {
+ if (parser->line_len == 0)
+ parser->line_len = 81;
+ if (parser->data_len == 0)
+ parser->data_len += 1 + ntokens * sizeof(char *);
+ parser->data = malloc(parser->data_len + parser->line_len);
+ if (parser->data == NULL)
+ return 0;
+ parser->allocated |= 1;
+ } /* else { assert(parser->data_len > 0); } */
+ parser->line = parser->data + parser->data_len;
+ /*config_free_data(parser);*/
+
+ /* Read one line (handling continuations with backslash) */
+ len = bb_get_chunk_with_continuation(parser);
+ if (len == -1)
+ return 0;
+ line = parser->line;
+
+ /* Skip multiple token-delimiters in the start of line? */
+ if (flags & PARSE_TRIM)
+ line += strspn(line, delims + 1);
+
+ if (line[0] == '\0' || line[0] == delims[0])
+ goto again;
+
+ *tokens = (char **) parser->data;
+ memset(*tokens, 0, sizeof(*tokens[0]) * ntokens);
+
+ /* Tokenize the line */
+ for (t = 0; *line && *line != delims[0] && t < ntokens; t++) {
+ /* Pin token */
+ *(*tokens + t) = line;
+
+ /* Combine remaining arguments? */
+ if ((t != ntokens-1) || !(flags & PARSE_GREEDY)) {
+ /* Vanilla token, find next delimiter */
+ line += strcspn(line, delims[0] ? delims : delims + 1);
+ } else {
+ /* Combining, find comment char if any */
+ line = strchrnul(line, delims[0]);
+
+ /* Trim any extra delimiters from the end */
+ if (flags & PARSE_TRIM) {
+ while (strchr(delims + 1, line[-1]) != NULL)
+ line--;
+ }
+ }
+
+ /* Token not terminated? */
+ if (line[0] == delims[0])
+ *line = '\0';
+ else if (line[0] != '\0')
+ *(line++) = '\0';
+
+#if 0 /* unused so far */
+ if (flags & PARSE_ESCAPE) {
+ const char *from;
+ char *to;
+
+ from = to = tokens[t];
+ while (*from) {
+ if (*from == '\\') {
+ from++;
+ *to++ = bb_process_escape_sequence(&from);
+ } else {
+ *to++ = *from++;
+ }
+ }
+ *to = '\0';
+ }
+#endif
+
+ /* Skip possible delimiters */
+ if (flags & PARSE_COLLAPSE)
+ line += strspn(line, delims + 1);
+ }
+
+ if (t < mintokens) {
+ bb_error_msg(/*"bad line %u: "*/"%d tokens found, %d needed",
+ /*parser->lineno, */t, mintokens);
+ if (flags & PARSE_MIN_DIE)
+ xfunc_die();
+ goto again;
+ }
+ return t;
+}
diff --git a/libc/misc/internals/tempname.c b/libc/misc/internals/tempname.c
index 0883259bd..7654eb433 100644
--- a/libc/misc/internals/tempname.c
+++ b/libc/misc/internals/tempname.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/>. */
/* March 11, 2002 Manuel Novoa III
*
@@ -45,20 +44,6 @@
#include <sys/time.h>
#include "tempname.h"
-/* Experimentally off - libc_hidden_proto(strlen) */
-/* Experimentally off - libc_hidden_proto(strcmp) */
-libc_hidden_proto(sprintf)
-libc_hidden_proto(mkdir)
-libc_hidden_proto(open)
-#ifdef __UCLIBC_HAS_LFS__
-libc_hidden_proto(open64)
-#endif
-libc_hidden_proto(read)
-libc_hidden_proto(close)
-libc_hidden_proto(getpid)
-libc_hidden_proto(stat)
-libc_hidden_proto(gettimeofday)
-
/* Return nonzero if DIR is an existent directory. */
static int direxists (const char *dir)
{
@@ -72,11 +57,14 @@ static int direxists (const char *dir)
for use with mk[s]temp. Will fail (-1) if DIR is non-null and
doesn't exist, none of the searched dirs exists, or there's not
enough space in TMPL. */
-int attribute_hidden ___path_search (char *tmpl, size_t tmpl_len, const char *dir,
+int ___path_search (char *tmpl, size_t tmpl_len, const char *dir,
const char *pfx /*, int try_tmpdir*/)
{
- //const char *d;
- size_t dlen, plen;
+ /*const char *d; */
+ /* dir and pfx lengths should always fit into an int,
+ so don't bother using size_t here. Especially since
+ the printf func requires an int for precision (%*s). */
+ int dlen, plen;
if (!pfx || !pfx[0])
{
@@ -121,7 +109,7 @@ int attribute_hidden ___path_search (char *tmpl, size_t tmpl_len, const char *di
dlen--; /* remove trailing slashes */
/* check we have room for "${dir}/${pfx}XXXXXX\0" */
- if (tmpl_len < dlen + 1 + plen + 6 + 1)
+ if (tmpl_len < (size_t)dlen + 1 + plen + 6 + 1)
{
__set_errno (EINVAL);
return -1;
@@ -175,21 +163,22 @@ static void brain_damaged_fillrand(unsigned char *buf, unsigned int len)
}
}
-/* Generate a temporary file name based on TMPL. TMPL must match the
- rules for mk[s]temp (i.e. end in "XXXXXX"). The name constructed
- does not exist at the time of the call to __gen_tempname. TMPL is
- overwritten with the result.
+/* Generate a temporary file name based on TMPL. TMPL must match the
+ rules for mk[s]temp[s] (i.e. end in "prefixXXXXXXsuffix"). The name
+ constructed does not exist at the time of the call to __gen_tempname.
+ TMPL is overwritten with the result.
KIND may be one of:
__GT_NOCREATE: simply verify that the name does not exist
- at the time of the call.
+ at the time of the call. mode argument is ignored.
__GT_FILE: create the file using open(O_CREAT|O_EXCL)
- and return a read-write fd. The file is mode 0600.
+ and return a read-write fd with given mode.
__GT_BIGFILE: same as __GT_FILE but use open64().
- __GT_DIR: create a directory, which will be mode 0700.
+ __GT_DIR: create a directory with given mode.
*/
-int attribute_hidden __gen_tempname (char *tmpl, int kind)
+int attribute_hidden __gen_tempname (char *tmpl, int kind, int flags,
+ int suffixlen, mode_t mode)
{
char *XXXXXX;
unsigned int i;
@@ -199,15 +188,16 @@ int attribute_hidden __gen_tempname (char *tmpl, int kind)
len = strlen (tmpl);
/* This is where the Xs start. */
- XXXXXX = tmpl + len - 6;
- if (len < 6 || strcmp (XXXXXX, "XXXXXX"))
+ XXXXXX = tmpl + len - 6 - suffixlen;
+ if (len < 6 || suffixlen < 0 || suffixlen > len - 6
+ || strncmp (XXXXXX, "XXXXXX", 6))
{
__set_errno (EINVAL);
return -1;
}
for (i = 0; i < TMP_MAX; ++i) {
- int j;
+ unsigned char j;
/* Get some random data. */
if (fillrand(randomness, sizeof(randomness)) != sizeof(randomness)) {
/* if random device nodes failed us, lets use the braindamaged ver */
@@ -231,15 +221,15 @@ int attribute_hidden __gen_tempname (char *tmpl, int kind)
fd = 0;
}
case __GT_FILE:
- fd = open (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
+ fd = open (tmpl, O_RDWR | O_CREAT | O_EXCL | flags, mode);
break;
#if defined __UCLIBC_HAS_LFS__
case __GT_BIGFILE:
- fd = open64 (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
+ fd = open64 (tmpl, O_RDWR | O_CREAT | O_EXCL | flags, mode);
break;
#endif
case __GT_DIR:
- fd = mkdir (tmpl, S_IRUSR | S_IWUSR | S_IXUSR);
+ fd = mkdir (tmpl, mode);
break;
default:
fd = -1;
diff --git a/libc/misc/internals/tempname.h b/libc/misc/internals/tempname.h
index ac40bef6e..cc20f756c 100644
--- a/libc/misc/internals/tempname.h
+++ b/libc/misc/internals/tempname.h
@@ -3,13 +3,15 @@
#define __need_size_t
#include <stddef.h>
+#include <sys/types.h>
/* Disable support for $TMPDIR */
extern int ___path_search (char *tmpl, size_t tmpl_len, const char *dir,
const char *pfx /*, int try_tmpdir */) attribute_hidden;
#define __path_search(tmpl, tmpl_len, dir, pfx, try_tmpdir) ___path_search(tmpl, tmpl_len, dir, pfx)
-extern int __gen_tempname (char *__tmpl, int __kind) attribute_hidden;
+extern int __gen_tempname (char *__tmpl, int __kind, int flags,
+ int suffixlen, mode_t mode) attribute_hidden;
/* The __kind argument to __gen_tempname may be one of: */
#define __GT_FILE 0 /* create a file */
diff --git a/libc/misc/locale/Makefile.in b/libc/misc/locale/Makefile.in
index 1991d04e3..3db6d5c5c 100644
--- a/libc/misc/locale/Makefile.in
+++ b/libc/misc/locale/Makefile.in
@@ -1,28 +1,27 @@
# 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.
#
+subdirs += libc/misc/locale
+
# multi source locale.c
-CSRC := setlocale.c localeconv.c _locale_init.c nl_langinfo.c
-ifeq ($(UCLIBC_HAS_LOCALE),y)
-CSRC += newlocale.c __locale_mbrtowc_l.c
-endif
-ifeq ($(UCLIBC_HAS_XLOCALE),y)
-CSRC += nl_langinfo_l.c duplocale.c freelocale.c uselocale.c __curlocale.c
-endif
+CSRC-y := setlocale.c localeconv.c _locale_init.c nl_langinfo.c
+CSRC-$(UCLIBC_HAS_LOCALE) += newlocale.c __locale_mbrtowc_l.c
+CSRC-$(UCLIBC_HAS_XLOCALE) += nl_langinfo_l.c duplocale.c freelocale.c \
+ uselocale.c __curlocale.c
MISC_LOCALE_DIR := $(top_srcdir)libc/misc/locale
MISC_LOCALE_OUT := $(top_builddir)libc/misc/locale
-MISC_LOCALE_SRC := $(patsubst %.c,$(MISC_LOCALE_DIR)/%.c,$(CSRC))
-MISC_LOCALE_OBJ := $(patsubst %.c,$(MISC_LOCALE_OUT)/%.o,$(CSRC))
+MISC_LOCALE_SRC := $(patsubst %.c,$(MISC_LOCALE_DIR)/%.c,$(CSRC-y))
+MISC_LOCALE_OBJ := $(patsubst %.c,$(MISC_LOCALE_OUT)/%.o,$(CSRC-y))
libc-y += $(MISC_LOCALE_OBJ)
-objclean-y += misc_locale_objclean
+objclean-y += CLEAN_libc/misc/locale
-misc_locale_objclean:
- $(RM) $(MISC_LOCALE_OUT)/*.{o,os}
+CLEAN_libc/misc/locale:
+ $(do_rm) $(addprefix $(MISC_LOCALE_OUT)/*., o os)
diff --git a/libc/misc/locale/locale.c b/libc/misc/locale/locale.c
index 858a02c33..68e54413e 100644
--- a/libc/misc/locale/locale.c
+++ b/libc/misc/locale/locale.c
@@ -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/>.
*/
/* Nov. 1, 2002
@@ -58,20 +58,6 @@
#include <ctype.h>
#include <stdio.h>
-/* Experimentally off - libc_hidden_proto(memcpy) */
-/* Experimentally off - libc_hidden_proto(memset) */
-/* Experimentally off - libc_hidden_proto(strtok_r) */
-/* Experimentally off - libc_hidden_proto(strlen) */
-/* Experimentally off - libc_hidden_proto(strcmp) */
-/* Experimentally off - libc_hidden_proto(strcpy) */
-/* Experimentally off - libc_hidden_proto(strncmp) */
-/* Experimentally off - libc_hidden_proto(strchr) */
-libc_hidden_proto(getenv)
-#ifdef __UCLIBC_HAS_CTYPE_TABLES__
-libc_hidden_proto(__C_ctype_toupper)
-#endif
-/*libc_hidden_proto(fflush)*/
-
#ifdef __UCLIBC_MJN3_ONLY__
#ifdef L_setlocale
#warning TODO: Make the link_warning()s a config option?
@@ -99,19 +85,17 @@ libc_hidden_proto(__C_ctype_toupper)
#endif
#endif
-/* Need to include this before locale.h and xlocale.h! */
+/* Need to include this before locale.h! */
#include <bits/uClibc_locale.h>
#undef CODESET_LIST
#define CODESET_LIST (__locale_mmap->codeset_list)
#ifdef __UCLIBC_HAS_XLOCALE__
-#include <xlocale.h>
#include <locale.h>
-#else /* __UCLIBC_HAS_XLOCALE__ */
+#else /* __UCLIBC_HAS_XLOCALE__ */
/* We need this internally... */
#define __UCLIBC_HAS_XLOCALE__ 1
-#include <xlocale.h>
#include <locale.h>
#undef __UCLIBC_HAS_XLOCALE__
#endif /* __UCLIBC_HAS_XLOCALE__ */
@@ -120,14 +104,14 @@ libc_hidden_proto(__C_ctype_toupper)
#define LOCALE_NAMES (__locale_mmap->locale_names5)
#define LOCALES (__locale_mmap->locales)
-#define LOCALE_AT_MODIFIERS (__locale_mmap->locale_at_modifiers)
+#define LOCALE_AT_MODIFIERS (__locale_mmap->locale_at_modifiers)
#define CATEGORY_NAMES (__locale_mmap->lc_names)
#ifdef __UCLIBC_MJN3_ONLY__
#warning REMINDER: redo the MAX_LOCALE_STR stuff...
#endif
-#define MAX_LOCALE_STR 256 /* TODO: Only sufficient for current case. */
-#define MAX_LOCALE_CATEGORY_STR 32 /* TODO: Only sufficient for current case. */
+#define MAX_LOCALE_STR 256 /* TODO: Only sufficient for current case. */
+#define MAX_LOCALE_CATEGORY_STR 32 /* TODO: Only sufficient for current case. */
/* Note: Best if MAX_LOCALE_CATEGORY_STR is a power of 2. */
extern int _locale_set_l(const unsigned char *p, __locale_t base) attribute_hidden;
@@ -169,7 +153,7 @@ char *setlocale(int category, register const char *locale)
: NULL;
}
-#else /* ---------------------------------------------- __LOCALE_C_ONLY */
+#else /* ---------------------------------------------- __LOCALE_C_ONLY */
#ifdef __UCLIBC_HAS_THREADS__
link_warning(setlocale,"REMINDER: The 'setlocale' function is _not_ threadsafe except for simple queries.")
@@ -193,8 +177,6 @@ static const char utf8[] = "UTF-8";
*/
static char hr_locale[(MAX_LOCALE_CATEGORY_STR * LC_ALL) + MAX_LOCALE_STR];
-/* Experimentally off - libc_hidden_proto(stpcpy) */
-libc_hidden_proto(newlocale)
static void update_hr_locale(const unsigned char *spec)
{
@@ -230,7 +212,8 @@ static void update_hr_locale(const unsigned char *spec)
+ __LOCALE_DATA_WIDTH_LOCALES * ((((int)(*s & 0x7f)) << 7)
+ (s[1] & 0x7f));
if (category == LC_ALL) {
- n = stpcpy(n, CATEGORY_NAMES + (int) CATEGORY_NAMES[i]);
+ /* CATEGORY_NAMES is unsigned char* */
+ n = stpcpy(n, (char*) CATEGORY_NAMES + (int) CATEGORY_NAMES[i]);
*n++ = '=';
}
if (*loc == 0) {
@@ -248,12 +231,12 @@ static void update_hr_locale(const unsigned char *spec)
if (loc[2] == 2) {
n = stpcpy(n, utf8);
} else if (loc[2] >= 3) {
- n = stpcpy(n, CODESET_LIST + (int)(CODESET_LIST[loc[2] - 3]));
+ n = stpcpy(n, (char*) CODESET_LIST + (int)(CODESET_LIST[loc[2] - 3]));
}
if (at) {
const char *q;
*n++ = '@';
- q = LOCALE_AT_MODIFIERS;
+ q = (char*) LOCALE_AT_MODIFIERS;
do {
if (q[1] == at) {
n = stpcpy(n, q+2);
@@ -267,7 +250,7 @@ static void update_hr_locale(const unsigned char *spec)
}
s += 2;
} while (++i < category);
- *--n = 0; /* Remove trailing ';' and nul-terminate. */
+ *--n = 0; /* Remove trailing ';' and nul-terminate. */
++category;
} while (!done);
@@ -303,7 +286,6 @@ char *setlocale(int category, const char *locale)
* placement of the fields in the struct. If necessary, we could ensure
* this usings an array of offsets but at some size cost. */
-libc_hidden_proto(localeconv)
#ifdef __LOCALE_C_ONLY
@@ -332,14 +314,14 @@ struct lconv *localeconv(void)
return &the_lconv;
}
-#else /* __LOCALE_C_ONLY */
+#else /* __LOCALE_C_ONLY */
static struct lconv the_lconv;
struct lconv *localeconv(void)
{
register char *p = (char *) &the_lconv;
- register char **q = (char **) &(__UCLIBC_CURLOCALE_DATA).decimal_point;
+ register char **q = (char **) &(__UCLIBC_CURLOCALE->decimal_point);
do {
*((char **)p) = *q;
@@ -364,15 +346,7 @@ libc_hidden_def(localeconv)
/**********************************************************************/
#if defined(L__locale_init) && !defined(__LOCALE_C_ONLY)
-libc_hidden_proto(__C_ctype_b)
-libc_hidden_proto(__C_ctype_tolower)
-#ifndef __UCLIBC_HAS_XLOCALE__
-libc_hidden_proto(__ctype_b)
-libc_hidden_proto(__ctype_tolower)
-libc_hidden_proto(__ctype_toupper)
-#endif
-
-__uclibc_locale_t __global_locale_data;
+struct __uclibc_locale_struct __global_locale_data;
__locale_t __global_locale = &__global_locale_data;
@@ -609,7 +583,7 @@ int attribute_hidden _locale_set_l(const unsigned char *p, __locale_t base)
if ((p[2*LC_COLLATE] != s[2*LC_COLLATE])
|| (p[2*LC_COLLATE + 1] != s[2*LC_COLLATE + 1])
) {
- row = (((int)(*p & 0x7f)) << 7) + (p[1] & 0x7f);
+ row = (((int)(*p & 0x7f)) << 7) + (p[1] & 0x7f);
assert(row < __LOCALE_DATA_NUM_LOCALES);
if (!init_cur_collate(__locale_mmap->locales[ __LOCALE_DATA_WIDTH_LOCALES
* row + 3 + LC_COLLATE ],
@@ -623,7 +597,7 @@ int attribute_hidden _locale_set_l(const unsigned char *p, __locale_t base)
do {
if ((*p != *s) || (p[1] != s[1])) {
- row = (((int)(*p & 0x7f)) << 7) + (p[1] & 0x7f);
+ row = (((int)(*p & 0x7f)) << 7) + (p[1] & 0x7f);
assert(row < __LOCALE_DATA_NUM_LOCALES);
*s = *p;
@@ -644,8 +618,8 @@ int attribute_hidden _locale_set_l(const unsigned char *p, __locale_t base)
io = (const uint16_t *)( ((char *)__locale_mmap) + *++stp );
ii = (const uint16_t *)( ((char *)__locale_mmap) + *++stp );
d = (const unsigned char *)( ((char *)__locale_mmap) + *++stp );
- for (c=0 ; c < len ; c++) {
- *(x + c) = d + ii[ r[crow + c] + io[c] ];
+ for (c = 0; c < len; c++) {
+ x[c] = (char*)(d + ii[r[crow + c] + io[c]]);
}
}
if (i == LC_CTYPE) {
@@ -658,7 +632,7 @@ int attribute_hidden _locale_set_l(const unsigned char *p, __locale_t base)
/* TODO - fix for bcc */
base->mb_cur_max = 6;
} else {
- assert(c==1);
+ assert(c == 1);
base->codeset = ascii;
base->encoding = __ctype_encoding_7_bit;
base->mb_cur_max = 1;
@@ -666,7 +640,8 @@ int attribute_hidden _locale_set_l(const unsigned char *p, __locale_t base)
} else {
const __codeset_8_bit_t *c8b;
r = CODESET_LIST;
- base->codeset = r + r[c -= 3];
+ c -= 3;
+ base->codeset = (char *) (r + r[c]);
base->encoding = __ctype_encoding_8_bit;
#ifdef __UCLIBC_MJN3_ONLY__
#warning REMINDER: update 8 bit mb_cur_max when translit implemented!
@@ -789,7 +764,7 @@ int attribute_hidden _locale_set_l(const unsigned char *p, __locale_t base)
+ __UCLIBC_CTYPE_TO_TBL_OFFSET;
base->__ctype_toupper = base->__ctype_toupper_data
+ __UCLIBC_CTYPE_TO_TBL_OFFSET;
-#else /* __UCLIBC_HAS_XLOCALE__ */
+#else /* __UCLIBC_HAS_XLOCALE__ */
__ctype_b = base->__ctype_b_data
+ __UCLIBC_CTYPE_B_TBL_OFFSET;
__ctype_tolower = base->__ctype_tolower_data
@@ -879,17 +854,17 @@ void attribute_hidden _locale_init_l(__locale_t base)
LC_ALL);
++base->category_item_count[0]; /* Increment for codeset entry. */
- base->category_offsets[0] = offsetof(__uclibc_locale_t, outdigit0_mb);
- base->category_offsets[1] = offsetof(__uclibc_locale_t, decimal_point);
- base->category_offsets[2] = offsetof(__uclibc_locale_t, int_curr_symbol);
- base->category_offsets[3] = offsetof(__uclibc_locale_t, abday_1);
-/* base->category_offsets[4] = offsetof(__uclibc_locale_t, collate???); */
- base->category_offsets[5] = offsetof(__uclibc_locale_t, yesexpr);
+ base->category_offsets[0] = offsetof(struct __uclibc_locale_struct, outdigit0_mb);
+ base->category_offsets[1] = offsetof(struct __uclibc_locale_struct, decimal_point);
+ base->category_offsets[2] = offsetof(struct __uclibc_locale_struct, int_curr_symbol);
+ base->category_offsets[3] = offsetof(struct __uclibc_locale_struct, abday_1);
+/* base->category_offsets[4] = offsetof(struct __uclibc_locale_struct, collate???); */
+ base->category_offsets[5] = offsetof(struct __uclibc_locale_struct, yesexpr);
#ifdef __CTYPE_HAS_8_BIT_LOCALES
base->tbl8ctype
= (const unsigned char *) &__locale_mmap->tbl8ctype;
- base->tbl8uplow
+ base->tbl8uplow
= (const unsigned char *) &__locale_mmap->tbl8uplow;
#ifdef __UCLIBC_HAS_WCHAR__
base->tbl8c2wc
@@ -905,7 +880,7 @@ void attribute_hidden _locale_init_l(__locale_t base)
base->tblwuplow
= (const unsigned char *) &__locale_mmap->tblwuplow;
base->tblwuplow_diff
- = (const uint16_t *) &__locale_mmap->tblwuplow_diff;
+ = (const int16_t *) &__locale_mmap->tblwuplow_diff;
/* base->tblwcomb */
/* = (const unsigned char *) &__locale_mmap->tblwcomb; */
/* width?? */
@@ -917,7 +892,7 @@ void attribute_hidden _locale_init_l(__locale_t base)
base->__ctype_b = __C_ctype_b;
base->__ctype_tolower = __C_ctype_tolower;
base->__ctype_toupper = __C_ctype_toupper;
-#else /* __UCLIBC_HAS_XLOCALE__ */
+#else /* __UCLIBC_HAS_XLOCALE__ */
__ctype_b = __C_ctype_b;
__ctype_tolower = __C_ctype_tolower;
__ctype_toupper = __C_ctype_toupper;
@@ -928,11 +903,9 @@ void attribute_hidden _locale_init_l(__locale_t base)
#endif
base->code2flag = __code2flag;
-
- _locale_set_l(C_LOCALE_SELECTOR, base);
+ _locale_set_l((unsigned char*) C_LOCALE_SELECTOR, base);
}
-void _locale_init(void) attribute_hidden;
void _locale_init(void)
{
/* TODO: mmap the locale file */
@@ -967,7 +940,7 @@ void _locale_init(void)
static const unsigned char nl_data[C_LC_ALL + 1 + 90 + 320] = {
/* static const char cat_start[LC_ALL + 1] = { */
- '\x00', '\x0b', '\x0e', '\x24', '\x56', '\x56', '\x5a',
+ '\x00', '\x0b', '\x0e', '\x24', '\x56', '\x56', '\x5a',
/* }; */
/* static const char item_offset[90] = { */
'\x00', '\x02', '\x04', '\x06', '\x08', '\x0a', '\x0c', '\x0e',
@@ -1026,7 +999,6 @@ static const unsigned char nl_data[C_LC_ALL + 1 + 90 + 320] = {
']', '\x00', '^', '[', 'n', 'N', ']', '\x00',
};
-libc_hidden_proto(nl_langinfo)
char *nl_langinfo(nl_item item)
{
unsigned int c;
@@ -1042,13 +1014,11 @@ char *nl_langinfo(nl_item item)
}
libc_hidden_def(nl_langinfo)
-#else /* __LOCALE_C_ONLY */
+#else /* __LOCALE_C_ONLY */
#if defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE)
-libc_hidden_proto(nl_langinfo)
-libc_hidden_proto(nl_langinfo_l)
char *nl_langinfo(nl_item item)
{
@@ -1056,13 +1026,13 @@ char *nl_langinfo(nl_item item)
}
libc_hidden_def(nl_langinfo)
-#else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
+#else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
libc_hidden_proto(__XL_NPP(nl_langinfo))
static const char empty[] = "";
-char *__XL_NPP(nl_langinfo)(nl_item item __LOCALE_PARAM )
+char *__XL_NPP(nl_langinfo)(nl_item item __LOCALE_PARAM )
{
unsigned int c = _NL_ITEM_CATEGORY(item);
unsigned int i = _NL_ITEM_INDEX(item);
@@ -1084,8 +1054,7 @@ libc_hidden_def(__XL_NPP(nl_langinfo))
/**********************************************************************/
#ifdef L_newlocale
-/* Experimentally off - libc_hidden_proto(stpcpy) */
-libc_hidden_proto(newlocale)
+#warning mask defines for extra locale categories
#ifdef __UCLIBC_MJN3_ONLY__
#warning TODO: Move posix and utf8 strings.
@@ -1117,7 +1086,7 @@ static int find_locale(int category_mask, const char *p,
/* locale name at least 5 chars long and 3rd char is '_' */
s = LOCALE_AT_MODIFIERS;
do {
- if (!strcmp(s+2, q+1)) {
+ if (!strcmp((char*) (s + 2), q + 1)) {
break;
}
s += 2 + *s; /* TODO - fix this throughout */
@@ -1142,11 +1111,11 @@ static int find_locale(int category_mask, const char *p,
/* TODO: maybe CODESET_LIST + *s ??? */
/* 7bit is 1, UTF-8 is 2, 8-bit is >= 3 */
codeset = 2;
- if (strcasecmp(utf8,p+6) != 0) {/* TODO - fix! */
+ if (strcasecmp(utf8, p + 6) != 0) {/* TODO - fix! */
s = CODESET_LIST;
do {
++codeset; /* Increment codeset first. */
- if (!strcmp(CODESET_LIST+*s, p+6)) {
+ if (!strcmp((char*) CODESET_LIST + *s, p + 6)) {
goto FIND_LANG_CULT;
}
} while (*++s);
@@ -1159,7 +1128,7 @@ static int find_locale(int category_mask, const char *p,
do { /* TODO -- do a binary search? */
/* TODO -- fix gen_mmap!*/
++lang_cult; /* Increment first since C/POSIX is 0. */
- if (!strncmp(s,p,5)) { /* Found a matching locale name; */
+ if (!strncmp((char*) s, p, 5)) { /* Found a matching locale name; */
goto FIND_LOCALE;
}
s += 5;
@@ -1217,7 +1186,8 @@ static unsigned char *composite_locale(int category_mask, const char *locale,
t = strtok_r(buf, "=", &e); /* This can't fail because of strchr test above. */
do {
c = 0;
- while (strcmp(CATEGORY_NAMES + (int) CATEGORY_NAMES[c], t)) {
+ /* CATEGORY_NAMES is unsigned char* */
+ while (strcmp((char*) CATEGORY_NAMES + (int) CATEGORY_NAMES[c], t)) {
if (++c == LC_ALL) { /* Unknown category name! */
return NULL;
}
@@ -1242,7 +1212,7 @@ static unsigned char *composite_locale(int category_mask, const char *locale,
__locale_t newlocale(int category_mask, const char *locale, __locale_t base)
{
- const unsigned char *p;
+ const char *p;
int i, j, k;
unsigned char new_selector[LOCALE_SELECTOR_SIZE];
@@ -1250,10 +1220,10 @@ __locale_t newlocale(int category_mask, const char *locale, __locale_t base)
category_mask = LC_ALL_MASK;
}
- if (!locale || (((unsigned int)(category_mask)) > LC_ALL_MASK)) {
- INVALID:
+ if (!locale || ((unsigned)(category_mask) > LC_ALL_MASK)) {
+ INVALID:
__set_errno(EINVAL);
- return NULL; /* No locale or illegal/unsupported category. */
+ return NULL; /* No locale or illegal/unsupported category. */
}
#ifdef __UCLIBC_MJN3_ONLY__
@@ -1262,11 +1232,13 @@ __locale_t newlocale(int category_mask, const char *locale, __locale_t base)
strcpy((char *) new_selector,
(base ? (char *) base->cur_locale : C_LOCALE_SELECTOR));
- if (!*locale) { /* locale == "", so check environment. */
-#ifndef __UCLIBC_HAS_THREADS__
- static /* If no threads, then envstr can be static. */
-#endif /* __UCLIBC_HAS_THREADS__ */
- const char *envstr[4] = { "LC_ALL", NULL, "LANG", posix };
+ if (!locale[0]) { /* locale == "", so check environment. */
+ const char *envstr[4];
+
+ envstr[0] = "LC_ALL";
+ envstr[1] = NULL;
+ envstr[2] = "LANG";
+ envstr[3] = posix;
i = 1;
k = 0;
@@ -1275,12 +1247,16 @@ __locale_t newlocale(int category_mask, const char *locale, __locale_t base)
/* Note: SUSv3 doesn't define a fallback mechanism here.
* So, if LC_ALL is invalid, we do _not_ continue trying
* the other environment vars. */
- envstr[1] = CATEGORY_NAMES + CATEGORY_NAMES[k];
+ envstr[1] = (char*) CATEGORY_NAMES + CATEGORY_NAMES[k];
j = 0;
- do {
+ while (1) {
p = envstr[j];
- } while ((++j < 4) && (!(p = getenv(p)) || !*p));
-
+ if (++j >= 4)
+ break; /* now p == "POSIX" */
+ p = getenv(p);
+ if (p && p[0])
+ break;
+ };
/* The user set something... is it valid? */
/* Note: Since we don't support user-supplied locales and
@@ -1313,9 +1289,9 @@ __locale_t newlocale(int category_mask, const char *locale, __locale_t base)
}
#else
if (!base) {
- if ((base = malloc(sizeof(__uclibc_locale_t))) == NULL) {
+ base = calloc(1, sizeof(struct __uclibc_locale_struct));
+ if (base == NULL)
return base;
- }
_locale_init_l(base);
}
@@ -1324,13 +1300,14 @@ __locale_t newlocale(int category_mask, const char *locale, __locale_t base)
return base;
}
+#ifdef __UCLIBC_HAS_XLOCALE__
libc_hidden_def(newlocale)
+#endif
#endif
/**********************************************************************/
#ifdef L_duplocale
-libc_hidden_proto(duplocale)
#ifdef __UCLIBC_MJN3_ONLY__
#warning REMINDER: When we allocate ctype tables, remember to dup them.
@@ -1344,12 +1321,12 @@ __locale_t duplocale(__locale_t dataset)
assert(dataset != LC_GLOBAL_LOCALE);
- if ((r = malloc(sizeof(__uclibc_locale_t))) != NULL) {
- n = 2*dataset->collate.max_col_index+2;
- if ((i2w = calloc(n, sizeof(uint16_t)))
- != NULL
- ) {
- memcpy(r, dataset, sizeof(__uclibc_locale_t));
+ r = malloc(sizeof(struct __uclibc_locale_struct));
+ if (r != NULL) {
+ n = 2 * dataset->collate.max_col_index + 2;
+ i2w = calloc(n, sizeof(uint16_t));
+ if (i2w != NULL) {
+ memcpy(r, dataset, sizeof(struct __uclibc_locale_struct));
r->collate.index2weight = i2w;
memcpy(i2w, dataset->collate.index2weight, n * sizeof(uint16_t));
} else {
@@ -1359,7 +1336,6 @@ __locale_t duplocale(__locale_t dataset)
}
return r;
}
-libc_hidden_def(duplocale)
#endif
/**********************************************************************/
@@ -1382,7 +1358,6 @@ void freelocale(__locale_t dataset)
/**********************************************************************/
#ifdef L_uselocale
-libc_hidden_proto(uselocale)
__locale_t uselocale(__locale_t dataset)
{
__locale_t old;
@@ -1416,8 +1391,9 @@ libc_hidden_def(uselocale)
__locale_t weak_const_function __curlocale(void)
{
- return __curlocale_var; /* This is overriden by the thread version. */
+ return __curlocale_var; /* This is overriden by the thread version. */
}
+libc_hidden_weak(__curlocale)
__locale_t weak_function __curlocale_set(__locale_t newloc)
{
@@ -1426,6 +1402,7 @@ __locale_t weak_function __curlocale_set(__locale_t newloc)
__curlocale_var = newloc;
return oldloc;
}
+libc_hidden_weak(__curlocale_set)
#endif
diff --git a/libc/misc/mntent/Makefile.in b/libc/misc/mntent/Makefile.in
index 958b119b3..3ced9bbd1 100644
--- a/libc/misc/mntent/Makefile.in
+++ b/libc/misc/mntent/Makefile.in
@@ -1,21 +1,23 @@
# 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.
#
-CSRC := mntent.c
+subdirs += libc/misc/mntent
+
+CSRC-y := mntent.c
MISC_MNTENT_DIR := $(top_srcdir)libc/misc/mntent
MISC_MNTENT_OUT := $(top_builddir)libc/misc/mntent
-MISC_MNTENT_SRC := $(MISC_MNTENT_DIR)/mntent.c
-MISC_MNTENT_OBJ := $(MISC_MNTENT_OUT)/mntent.o
+MISC_MNTENT_SRC := $(patsubst %.c,$(MISC_MNTENT_DIR)/%.c,$(CSRC-y))
+MISC_MNTENT_OBJ := $(patsubst %.c,$(MISC_MNTENT_OUT)/%.o,$(CSRC-y))
libc-y += $(MISC_MNTENT_OBJ)
-objclean-y += misc_mntent_objclean
+objclean-y += CLEAN_libc/misc/mntent
-misc_mntent_objclean:
- $(RM) $(MISC_MNTENT_OUT)/*.{o,os}
+CLEAN_libc/misc/mntent:
+ $(do_rm) $(addprefix $(MISC_MNTENT_OUT)/*., o os)
diff --git a/libc/misc/mntent/mntent.c b/libc/misc/mntent/mntent.c
index f4220784a..608f84c1a 100644
--- a/libc/misc/mntent/mntent.c
+++ b/libc/misc/mntent/mntent.c
@@ -12,26 +12,15 @@
__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER);
-libc_hidden_proto(getmntent_r)
-libc_hidden_proto(setmntent)
-libc_hidden_proto(endmntent)
-
-/* Experimentally off - libc_hidden_proto(strstr) */
-/* Experimentally off - libc_hidden_proto(strtok_r) */
-libc_hidden_proto(atoi)
-libc_hidden_proto(fopen)
-libc_hidden_proto(fclose)
-libc_hidden_proto(fseek)
-libc_hidden_proto(fgets)
-libc_hidden_proto(abort)
-libc_hidden_proto(fprintf)
+
/* Reentrant version of getmntent. */
struct mntent *getmntent_r (FILE *filep,
struct mntent *mnt, char *buff, int bufsize)
{
+ static const char sep[] = " \t\n";
+
char *cp, *ptrptr;
- const char *sep = " \t\n";
if (!filep || !mnt || !buff)
return NULL;
diff --git a/libc/misc/pthread/Makefile.in b/libc/misc/pthread/Makefile.in
index 0d7a9e49d..2f436ac1c 100644
--- a/libc/misc/pthread/Makefile.in
+++ b/libc/misc/pthread/Makefile.in
@@ -1,17 +1,18 @@
# 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.
#
+subdirs += libc/misc/pthread
+
MISC_PTHREAD_DIR := $(top_srcdir)libc/misc/pthread
MISC_PTHREAD_OUT := $(top_builddir)libc/misc/pthread
-libc-$(UCLIBC_HAS_THREADS) += $(MISC_PTHREAD_OUT)/unlock.o
-libc-$(UCLIBC_HAS_THREADS) += $(MISC_PTHREAD_OUT)/weaks.o
+libc-shared-$(UCLIBC_HAS_TLS) += $(MISC_PTHREAD_OUT)/tsd.os
-objclean-y += misc_pthread_objclean
+objclean-y += CLEAN_libc/misc/pthread
-misc_pthread_objclean:
- $(RM) $(MISC_PTHREAD_OUT)/*.{o,os,oS}
+CLEAN_libc/misc/pthread:
+ $(do_rm) $(addprefix $(MISC_PTHREAD_OUT)/*., o os oS)
diff --git a/libc/misc/pthread/tsd.c b/libc/misc/pthread/tsd.c
new file mode 100644
index 000000000..3598b8927
--- /dev/null
+++ b/libc/misc/pthread/tsd.c
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) 2006 by Steven J. Hill <sjhill@realitydiluted.com>
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+/* libpthread sets _dl_error_catch_tsd to point to this function.
+ We define it here instead of in libpthread so that it doesn't
+ need to have a TLS segment of its own just for this one pointer. */
+
+#include <features.h>
+
+void **__libc_dl_error_tsd(void) __attribute__ ((const));
+void ** __attribute__ ((const))
+__libc_dl_error_tsd (void)
+{
+ static __thread void *__tsd_data attribute_tls_model_ie;
+ return &__tsd_data;
+}
diff --git a/libc/misc/pthread/weaks.c b/libc/misc/pthread/weaks.c
deleted file mode 100644
index 580c3eb07..000000000
--- a/libc/misc/pthread/weaks.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* The weak pthread functions for Linux.
- 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. */
-
-#include <libc-internal.h>
-
-/* Weaks for internal library use only.
- *
- * We need to define weaks here to cover all the pthread functions that
- * libc itself will use so that we aren't forced to link libc against
- * libpthread. This file is only used in libc.a and since we have
- * weaks here, they will be automatically overridden by libpthread.a
- * if it gets linked in.
- */
-
-static int __pthread_return_0 (void) { return 0; }
-static void __pthread_return_void (void) { return; }
-
-weak_alias (__pthread_return_0, __pthread_mutex_init)
-weak_alias (__pthread_return_0, __pthread_mutex_lock)
-weak_alias (__pthread_return_0, __pthread_mutex_trylock)
-weak_alias (__pthread_return_0, __pthread_mutex_unlock)
-weak_alias (__pthread_return_void, _pthread_cleanup_push_defer)
-weak_alias (__pthread_return_void, _pthread_cleanup_pop_restore)
-#ifdef __UCLIBC_HAS_THREADS_NATIVE__
-weak_alias (__pthread_return_0, __pthread_mutexattr_init)
-weak_alias (__pthread_return_0, __pthread_mutexattr_destroy)
-weak_alias (__pthread_return_0, __pthread_mutexattr_settype)
-#endif
diff --git a/libc/misc/regex/Makefile.in b/libc/misc/regex/Makefile.in
index e9d70c596..f95a9f7a3 100644
--- a/libc/misc/regex/Makefile.in
+++ b/libc/misc/regex/Makefile.in
@@ -1,25 +1,24 @@
# 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.
#
-ifeq ($(UCLIBC_HAS_REGEX_OLD),y)
-CSRC := regex_old.c
-else
-CSRC := regex.c
-endif
+subdirs += libc/misc/regex
+
+VARIANT := $(if $(UCLIBC_HAS_REGEX_OLD),_old)
+CSRC-y := regex$(VARIANT).c
MISC_REGEX_DIR := $(top_srcdir)libc/misc/regex
MISC_REGEX_OUT := $(top_builddir)libc/misc/regex
-MISC_REGEX_SRC := $(patsubst %.c,$(MISC_REGEX_DIR)/%.c,$(CSRC))
-MISC_REGEX_OBJ := $(patsubst %.c,$(MISC_REGEX_OUT)/%.o,$(CSRC))
+MISC_REGEX_SRC := $(patsubst %.c,$(MISC_REGEX_DIR)/%.c,$(CSRC-y))
+MISC_REGEX_OBJ := $(patsubst %.c,$(MISC_REGEX_OUT)/%.o,$(CSRC-y))
libc-$(UCLIBC_HAS_REGEX) += $(MISC_REGEX_OBJ)
-objclean-y += misc_regex_objclean
+objclean-y += CLEAN_libc/misc/regex
-misc_regex_objclean:
- $(RM) $(MISC_REGEX_OUT)/*.{o,os}
+CLEAN_libc/misc/regex:
+ $(do_rm) $(addprefix $(MISC_REGEX_OUT)/*., o os)
diff --git a/libc/misc/regex/_regex.h b/libc/misc/regex/_regex.h
deleted file mode 100644
index 01bb21158..000000000
--- a/libc/misc/regex/_regex.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* this file is copied from libc/include/regex.h */
-
-#ifndef _REGEX_H
-#include <regex.h>
-
-/* Document internal interfaces. */
-extern reg_syntax_t __re_set_syntax (reg_syntax_t syntax) attribute_hidden;
-
-extern const char *__re_compile_pattern (const char *pattern, size_t length,
- struct re_pattern_buffer *buffer) attribute_hidden;
-
-extern int __re_compile_fastmap (struct re_pattern_buffer *buffer) attribute_hidden;
-
-extern int __re_search (struct re_pattern_buffer *buffer, const char *string,
- int length, int start, int range,
- struct re_registers *regs) attribute_hidden;
-
-extern int __re_search_2
- (struct re_pattern_buffer *buffer, const char *string1,
- int length1, const char *string2, int length2,
- int start, int range, struct re_registers *regs, int stop) attribute_hidden;
-
-extern int __re_match
- (struct re_pattern_buffer *buffer, const char *string,
- int length, int start, struct re_registers *regs) attribute_hidden;
-
-extern int __re_match_2
- (struct re_pattern_buffer *buffer, const char *string1,
- int length1, const char *string2, int length2,
- int start, struct re_registers *regs, int stop) attribute_hidden;
-
-extern void __re_set_registers
- (struct re_pattern_buffer *buffer, struct re_registers *regs,
- unsigned num_regs, regoff_t *starts, regoff_t *ends) attribute_hidden;
-
-extern int __regcomp (regex_t *__preg, const char *__pattern, int __cflags) attribute_hidden;
-
-extern int __regexec (const regex_t *__preg, const char *__string,
- size_t __nmatch, regmatch_t __pmatch[], int __eflags) attribute_hidden;
-
-extern size_t __regerror (int __errcode, const regex_t *__preg,
- char *__errbuf, size_t __errbuf_size) attribute_hidden;
-
-extern void __regfree (regex_t *__preg) attribute_hidden;
-#endif
diff --git a/libc/misc/regex/regcomp.c b/libc/misc/regex/regcomp.c
index 210ae05ee..dc00109dc 100644
--- a/libc/misc/regex/regcomp.c
+++ b/libc/misc/regex/regcomp.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/>. */
static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern,
size_t length, reg_syntax_t syntax);
@@ -26,7 +25,7 @@ static void re_compile_fastmap_iter (regex_t *bufp,
static reg_errcode_t init_dfa (re_dfa_t *dfa, size_t pat_len);
#ifdef RE_ENABLE_I18N
static void free_charset (re_charset_t *cset);
-#endif /* RE_ENABLE_I18N */
+#endif
static void free_workarea_compile (regex_t *preg);
static reg_errcode_t create_initial_state (re_dfa_t *dfa);
#ifdef RE_ENABLE_I18N
@@ -91,7 +90,7 @@ static reg_errcode_t build_equiv_class (bitset_t sbcset,
re_charset_t *mbcset,
int *equiv_class_alloc,
const unsigned char *name);
-static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans,
+static reg_errcode_t build_charclass (__RE_TRANSLATE_TYPE trans,
bitset_t sbcset,
re_charset_t *mbcset,
int *char_class_alloc,
@@ -100,13 +99,13 @@ static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans,
#else /* not RE_ENABLE_I18N */
static reg_errcode_t build_equiv_class (bitset_t sbcset,
const unsigned char *name);
-static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans,
+static reg_errcode_t build_charclass (__RE_TRANSLATE_TYPE trans,
bitset_t sbcset,
const unsigned char *class_name,
reg_syntax_t syntax);
#endif /* not RE_ENABLE_I18N */
static bin_tree_t *build_charclass_op (re_dfa_t *dfa,
- RE_TRANSLATE_TYPE trans,
+ __RE_TRANSLATE_TYPE trans,
const unsigned char *class_name,
const unsigned char *extra,
int non_match, reg_errcode_t *err);
@@ -126,7 +125,7 @@ static reg_errcode_t mark_opt_subexp (void *extra, bin_tree_t *node);
POSIX doesn't require that we do anything for REG_NOERROR,
but why not be nice? */
-const char __re_error_msgid[] attribute_hidden =
+static const char __re_error_msgid[] =
{
#define REG_NOERROR_IDX 0
gettext_noop ("Success") /* REG_NOERROR */
@@ -180,7 +179,7 @@ const char __re_error_msgid[] attribute_hidden =
gettext_noop ("Unmatched ) or \\)") /* REG_ERPAREN */
};
-const size_t __re_error_msgid_idx[] attribute_hidden =
+static const uint16_t __re_error_msgid_idx[] =
{
REG_NOERROR_IDX,
REG_NOMATCH_IDX,
@@ -211,10 +210,9 @@ const size_t __re_error_msgid_idx[] attribute_hidden =
are set in BUFP on entry. */
const char *
-re_compile_pattern (pattern, length, bufp)
- const char *pattern;
- size_t length;
- struct re_pattern_buffer *bufp;
+re_compile_pattern (const char *pattern,
+ size_t length,
+ struct re_pattern_buffer *bufp)
{
reg_errcode_t ret;
@@ -232,9 +230,6 @@ re_compile_pattern (pattern, length, bufp)
return NULL;
return gettext (__re_error_msgid + __re_error_msgid_idx[(int) ret]);
}
-#if defined _LIBC || defined __UCLIBC__
-strong_alias(__re_compile_pattern, re_compile_pattern)
-#endif
/* Set by `re_set_syntax' to the current regexp syntax to recognize. Can
also be assigned to arbitrarily: each pattern buffer stores its own
@@ -252,21 +247,16 @@ reg_syntax_t re_syntax_options;
defined in regex.h. We return the old syntax. */
reg_syntax_t
-re_set_syntax (syntax)
- reg_syntax_t syntax;
+re_set_syntax (reg_syntax_t syntax)
{
reg_syntax_t ret = re_syntax_options;
re_syntax_options = syntax;
return ret;
}
-#if defined _LIBC || defined __UCLIBC__
-strong_alias(__re_set_syntax, re_set_syntax)
-#endif
int
-re_compile_fastmap (bufp)
- struct re_pattern_buffer *bufp;
+re_compile_fastmap (struct re_pattern_buffer *bufp)
{
re_dfa_t *dfa = (re_dfa_t *) bufp->buffer;
char *fastmap = bufp->fastmap;
@@ -282,9 +272,7 @@ re_compile_fastmap (bufp)
bufp->fastmap_accurate = 1;
return 0;
}
-#if defined _LIBC || defined __UCLIBC__
-strong_alias(__re_compile_fastmap, re_compile_fastmap)
-#endif
+libc_hidden_def(re_compile_fastmap)
static __inline__ void
__attribute ((always_inline))
@@ -292,7 +280,7 @@ re_set_fastmap (char *fastmap, int icase, int ch)
{
fastmap[ch] = 1;
if (icase)
- fastmap[__tolower (ch)] = 1;
+ fastmap[tolower (ch)] = 1;
}
/* Helper function for re_compile_fastmap.
@@ -355,7 +343,7 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
if (cset->non_match || cset->ncoll_syms || cset->nequiv_classes
|| cset->nranges || cset->nchar_classes)
{
-# ifdef _LIBC
+# if 0
if (_NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES) != 0)
{
/* In this case we want to catch the bytes which are
@@ -375,7 +363,7 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
for (i = 0; i < SBC_MAX; ++i)
if (__btowc (i) == WEOF)
re_set_fastmap (fastmap, icase, i);
-# endif /* not _LIBC */
+# endif
}
for (i = 0; i < cset->nmbchars; ++i)
{
@@ -396,7 +384,7 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
else if (type == OP_PERIOD
#ifdef RE_ENABLE_I18N
|| type == OP_UTF8_PERIOD
-#endif /* RE_ENABLE_I18N */
+#endif
|| type == END_OF_RE)
{
memset (fastmap, '\1', sizeof (char) * SBC_MAX);
@@ -444,10 +432,9 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
the return codes and their meanings.) */
int
-regcomp (preg, pattern, cflags)
- regex_t *__restrict preg;
- const char *__restrict pattern;
- int cflags;
+regcomp (regex_t *__restrict preg,
+ const char *__restrict pattern,
+ int cflags)
{
reg_errcode_t ret;
reg_syntax_t syntax = ((cflags & REG_EXTENDED) ? RE_SYNTAX_POSIX_EXTENDED
@@ -498,19 +485,15 @@ regcomp (preg, pattern, cflags)
return (int) ret;
}
-#if defined _LIBC || defined __UCLIBC__
-strong_alias(__regcomp, regcomp)
-#endif
/* Returns a message corresponding to an error code, ERRCODE, returned
from either regcomp or regexec. We don't use PREG here. */
size_t
-regerror (errcode, preg, errbuf, errbuf_size)
- int errcode;
- const regex_t *__restrict preg;
- char *__restrict errbuf;
- size_t errbuf_size;
+regerror (int errcode,
+ const regex_t *__restrict preg,
+ char *__restrict errbuf,
+ size_t errbuf_size)
{
const char *msg;
size_t msg_size;
@@ -532,12 +515,8 @@ regerror (errcode, preg, errbuf, errbuf_size)
{
if (BE (msg_size > errbuf_size, 0))
{
-#if (defined HAVE_MEMPCPY || defined _LIBC) && defined __USE_GNU
- *((char *) __mempcpy (errbuf, msg, errbuf_size - 1)) = '\0';
-#else
memcpy (errbuf, msg, errbuf_size - 1);
errbuf[errbuf_size - 1] = 0;
-#endif
}
else
memcpy (errbuf, msg, msg_size);
@@ -545,9 +524,6 @@ regerror (errcode, preg, errbuf, errbuf_size)
return msg_size;
}
-#if defined _LIBC || defined __UCLIBC__
-strong_alias(__regerror, regerror)
-#endif
#ifdef RE_ENABLE_I18N
@@ -614,8 +590,7 @@ free_dfa_content (re_dfa_t *dfa)
/* Free dynamically allocated space used by PREG. */
void
-regfree (preg)
- regex_t *preg;
+regfree (regex_t *preg)
{
re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
if (BE (dfa != NULL, 1))
@@ -629,74 +604,84 @@ regfree (preg)
re_free (preg->translate);
preg->translate = NULL;
}
-#if defined _LIBC || defined __UCLIBC__
-strong_alias(__regfree, regfree)
-#endif
+libc_hidden_def(regfree)
/* Entry points compatible with 4.2 BSD regex library. We don't define
them unless specifically requested. */
-#if defined _REGEX_RE_COMP || defined _LIBC || defined __UCLIBC__
+#if defined _REGEX_RE_COMP || defined __UCLIBC__
/* BSD has one and only one pattern buffer. */
-static struct re_pattern_buffer re_comp_buf;
+static struct re_pattern_buffer *re_comp_buf;
char *
-# if defined _LIBC || defined __UCLIBC__
-/* Make these definitions weak in libc, so POSIX programs can redefine
+/* Make BCD definitions weak in libc, so POSIX programs can redefine
these names if they don't use our functions, and still use
regcomp/regexec above without link errors. */
weak_function
-# endif
-re_comp (s)
- const char *s;
+re_comp (const char *s)
{
reg_errcode_t ret;
- char *fastmap;
- if (!s)
+ /* "If re_comp() is passed NULL or a null string, it returns
+ * without changing the currently compiled regular expression." */
+ if (!s || !s[0])
{
- if (!re_comp_buf.buffer)
+ if (!re_comp_buf)
return gettext ("No previous regular expression");
- return 0;
+ return NULL;
}
- if (re_comp_buf.buffer)
+ if (!re_comp_buf)
{
- fastmap = re_comp_buf.fastmap;
- re_comp_buf.fastmap = NULL;
- __regfree (&re_comp_buf);
- memset (&re_comp_buf, '\0', sizeof (re_comp_buf));
- re_comp_buf.fastmap = fastmap;
+ re_comp_buf = calloc (1, sizeof(*re_comp_buf));
+ if (!re_comp_buf)
+ {
+ ret = REG_ESPACE;
+ goto err;
+ }
}
- if (re_comp_buf.fastmap == NULL)
+ if (re_comp_buf->buffer)
{
- re_comp_buf.fastmap = (char *) malloc (SBC_MAX);
- if (re_comp_buf.fastmap == NULL)
- return (char *) gettext (__re_error_msgid
- + __re_error_msgid_idx[(int) REG_ESPACE]);
+ regfree (re_comp_buf);
+ memset (re_comp_buf, '\0', sizeof(*re_comp_buf));
+ }
+
+ if (re_comp_buf->fastmap == NULL)
+ {
+ re_comp_buf->fastmap = malloc (SBC_MAX);
+ if (re_comp_buf->fastmap == NULL)
+ {
+ ret = REG_ESPACE;
+ goto err;
+ }
}
/* Since `re_exec' always passes NULL for the `regs' argument, we
don't need to initialize the pattern buffer fields which affect it. */
/* Match anchors at newlines. */
- re_comp_buf.newline_anchor = 1;
+ re_comp_buf->newline_anchor = 1;
- ret = re_compile_internal (&re_comp_buf, s, strlen (s), re_syntax_options);
+ ret = re_compile_internal (re_comp_buf, s, strlen (s), re_syntax_options);
if (!ret)
return NULL;
+ free (re_comp_buf);
+ re_comp_buf = NULL;
+ err:
/* Yes, we're discarding `const' here if !HAVE_LIBINTL. */
return (char *) gettext (__re_error_msgid + __re_error_msgid_idx[(int) ret]);
}
-#ifdef _LIBC
+#if 0
libc_freeres_fn (free_mem)
{
- __regfree (&re_comp_buf);
+ regfree (re_comp_buf);
+ free (re_comp_buf);
+ re_comp_buf = NULL;
}
#endif
@@ -805,15 +790,11 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length,
/* Initialize DFA. We use the length of the regular expression PAT_LEN
as the initial length of some arrays. */
-#ifdef __UCLIBC_HAS_WCHAR__
-libc_hidden_proto(_stdlib_mb_cur_max)
-#endif
-
static reg_errcode_t
init_dfa (re_dfa_t *dfa, size_t pat_len)
{
unsigned int table_size;
-#ifndef _LIBC
+#if 1
char *codeset_name;
#endif
@@ -837,12 +818,8 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
dfa->state_table = calloc (sizeof (struct re_state_table_entry), table_size);
dfa->state_hash_mask = table_size - 1;
-#ifdef __UCLIBC_HAS_WCHAR__
dfa->mb_cur_max = MB_CUR_MAX;
-#else
- dfa->mb_cur_max = 1;
-#endif
-#ifdef _LIBC
+#if 0
if (dfa->mb_cur_max == 6
&& strcmp (_NL_CURRENT (LC_CTYPE, _NL_CTYPE_CODESET_NAME), "UTF-8") == 0)
dfa->is_utf8 = 1;
@@ -881,7 +858,7 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
{
int i, j, ch;
- dfa->sb_char = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
+ dfa->sb_char = calloc (sizeof (bitset_t), 1);
if (BE (dfa->sb_char == NULL, 0))
return REG_ESPACE;
@@ -892,7 +869,7 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
wint_t wch = __btowc (ch);
if (wch != WEOF)
dfa->sb_char[i] |= (bitset_word_t) 1 << j;
-# ifndef _LIBC
+# if 1
if (isascii (ch) && wch != ch)
dfa->map_notascii = 1;
# endif
@@ -1975,7 +1952,7 @@ peek_token_bracket (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
token->type = CHARACTER;
return 1;
}
-#endif /* RE_ENABLE_I18N */
+#endif
if (c == '\\' && (syntax & RE_BACKSLASH_ESCAPE_IN_LISTS)
&& re_string_cur_idx (input) + 1 < re_string_length (input))
@@ -2553,8 +2530,8 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
I'm not sure, but maybe enough. */
#define BRACKET_NAME_BUF_SIZE 32
-#ifndef _LIBC
- /* Local function for parse_bracket_exp only used in case of NOT _LIBC.
+#if 1
+ /* Local function for parse_bracket_exp only used in case of NOT glibc.
Build the range expression which starts from START_ELEM, and ends
at END_ELEM. The result are written to MBCSET and SBCSET.
RANGE_ALLOC is the allocated size of mbcset->range_starts, and
@@ -2566,10 +2543,10 @@ internal_function
# ifdef RE_ENABLE_I18N
build_range_exp (bitset_t sbcset, re_charset_t *mbcset, int *range_alloc,
bracket_elem_t *start_elem, bracket_elem_t *end_elem)
-# else /* not RE_ENABLE_I18N */
+# else
build_range_exp (bitset_t sbcset, bracket_elem_t *start_elem,
bracket_elem_t *end_elem)
-# endif /* not RE_ENABLE_I18N */
+# endif
{
unsigned int start_ch, end_ch;
/* Equivalence Classes and Character Classes can't be a range start/end. */
@@ -2611,7 +2588,7 @@ build_range_exp (bitset_t sbcset, bracket_elem_t *start_elem,
return REG_ERANGE;
/* Got valid collation sequence values, add them as a new entry.
- However, for !_LIBC we have no collation elements: if the
+ However, for !glibc we have no collation elements: if the
character set is single byte, the single byte character set
that we build below suffices. parse_bracket_exp passes
no MBCSET if dfa->mb_cur_max == 1. */
@@ -2673,10 +2650,10 @@ build_range_exp (bitset_t sbcset, bracket_elem_t *start_elem,
# endif /* not RE_ENABLE_I18N */
return REG_NOERROR;
}
-#endif /* not _LIBC */
+#endif
-#ifndef _LIBC
-/* Helper function for parse_bracket_exp only used in case of NOT _LIBC..
+#if 1
+/* Helper function for parse_bracket_exp only used in case of NOT glibc.
Build the collating element which is represented by NAME.
The result are written to MBCSET and SBCSET.
COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a
@@ -2687,20 +2664,17 @@ internal_function
# ifdef RE_ENABLE_I18N
build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset,
int *coll_sym_alloc, const unsigned char *name)
-# else /* not RE_ENABLE_I18N */
+# else
build_collating_symbol (bitset_t sbcset, const unsigned char *name)
-# endif /* not RE_ENABLE_I18N */
+# endif
{
size_t name_len = strlen ((const char *) name);
if (BE (name_len != 1, 0))
return REG_ECOLLATE;
- else
- {
- bitset_set (sbcset, name[0]);
- return REG_NOERROR;
- }
+ bitset_set (sbcset, name[0]);
+ return REG_NOERROR;
}
-#endif /* not _LIBC */
+#endif
/* This function parse bracket expression like "[abc]", "[a-c]",
"[[.a-a.]]" etc. */
@@ -2709,7 +2683,7 @@ static bin_tree_t *
parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
reg_syntax_t syntax, reg_errcode_t *err)
{
-#ifdef _LIBC
+#if 0
const unsigned char *collseqmb;
const char *collseqwc;
uint32_t nrules;
@@ -2717,15 +2691,13 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
const int32_t *symb_table;
const unsigned char *extra;
- /* Local function for parse_bracket_exp used in _LIBC environement.
+ /* Local function for parse_bracket_exp used in glibc.
Seek the collating symbol entry correspondings to NAME.
Return the index of the symbol in the SYMB_TABLE. */
auto __inline__ int32_t
__attribute ((always_inline))
- seek_collating_symbol_entry (name, name_len)
- const unsigned char *name;
- size_t name_len;
+ seek_collating_symbol_entry (const unsigned char *name, size_t name_len)
{
int32_t hash = elem_hash ((const char *) name, name_len);
int32_t elem = hash % table_size;
@@ -2755,14 +2727,13 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
return elem;
}
- /* Local function for parse_bracket_exp used in _LIBC environement.
+ /* Local function for parse_bracket_exp used in glibc.
Look up the collation sequence value of BR_ELEM.
Return the value if succeeded, UINT_MAX otherwise. */
auto __inline__ unsigned int
__attribute ((always_inline))
- lookup_collation_sequence_value (br_elem)
- bracket_elem_t *br_elem;
+ lookup_collation_sequence_value (bracket_elem_t *br_elem)
{
if (br_elem->type == SB_CHAR)
{
@@ -2820,7 +2791,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
return UINT_MAX;
}
- /* Local function for parse_bracket_exp used in _LIBC environement.
+ /* Local function for parse_bracket_exp used in glibc.
Build the range expression which starts from START_ELEM, and ends
at END_ELEM. The result are written to MBCSET and SBCSET.
RANGE_ALLOC is the allocated size of mbcset->range_starts, and
@@ -2829,11 +2800,11 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
auto __inline__ reg_errcode_t
__attribute ((always_inline))
- build_range_exp (sbcset, mbcset, range_alloc, start_elem, end_elem)
- re_charset_t *mbcset;
- int *range_alloc;
- bitset_t sbcset;
- bracket_elem_t *start_elem, *end_elem;
+ build_range_exp (re_charset_t *mbcset,
+ int *range_alloc,
+ bitset_t sbcset,
+ bracket_elem_t *start_elem,
+ bracket_elem_t *end_elem)
{
unsigned int ch;
uint32_t start_collseq;
@@ -2904,7 +2875,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
return REG_NOERROR;
}
- /* Local function for parse_bracket_exp used in _LIBC environement.
+ /* Local function for parse_bracket_exp used in glibc.
Build the collating element which is represented by NAME.
The result are written to MBCSET and SBCSET.
COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a
@@ -2912,11 +2883,10 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
auto __inline__ reg_errcode_t
__attribute ((always_inline))
- build_collating_symbol (sbcset, mbcset, coll_sym_alloc, name)
- re_charset_t *mbcset;
- int *coll_sym_alloc;
- bitset_t sbcset;
- const unsigned char *name;
+ build_collating_symbol (re_charset_t *mbcset,
+ int *coll_sym_alloc,
+ bitset_t sbcset,
+ const unsigned char *name)
{
int32_t elem, idx;
size_t name_len = strlen ((const char *) name);
@@ -2978,12 +2948,12 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
re_charset_t *mbcset;
int coll_sym_alloc = 0, range_alloc = 0, mbchar_alloc = 0;
int equiv_class_alloc = 0, char_class_alloc = 0;
-#endif /* not RE_ENABLE_I18N */
+#endif
int non_match = 0;
bin_tree_t *work_tree;
int token_len;
int first_round = 1;
-#ifdef _LIBC
+#if 0
collseqmb = (const unsigned char *)
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQMB);
nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
@@ -3000,15 +2970,15 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
_NL_COLLATE_SYMB_EXTRAMB);
}
#endif
- sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
+ sbcset = calloc (sizeof (bitset_t), 1);
#ifdef RE_ENABLE_I18N
- mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
-#endif /* RE_ENABLE_I18N */
+ mbcset = calloc (sizeof (re_charset_t), 1);
+#endif
#ifdef RE_ENABLE_I18N
if (BE (sbcset == NULL || mbcset == NULL, 0))
#else
if (BE (sbcset == NULL, 0))
-#endif /* RE_ENABLE_I18N */
+#endif
{
*err = REG_ESPACE;
return NULL;
@@ -3024,7 +2994,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
{
#ifdef RE_ENABLE_I18N
mbcset->non_match = 1;
-#endif /* not RE_ENABLE_I18N */
+#endif
non_match = 1;
if (syntax & RE_HAT_LISTS_NOT_NEWLINE)
bitset_set (sbcset, '\0');
@@ -3104,7 +3074,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
token_len = peek_token_bracket (token, regexp, syntax);
-#ifdef _LIBC
+#if 0
*err = build_range_exp (sbcset, mbcset, &range_alloc,
&start_elem, &end_elem);
#else
@@ -3115,7 +3085,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
# else
*err = build_range_exp (sbcset, &start_elem, &end_elem);
# endif
-#endif /* RE_ENABLE_I18N */
+#endif
if (BE (*err != REG_NOERROR, 0))
goto parse_bracket_exp_free_return;
}
@@ -3149,7 +3119,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
*err = build_equiv_class (sbcset,
#ifdef RE_ENABLE_I18N
mbcset, &equiv_class_alloc,
-#endif /* RE_ENABLE_I18N */
+#endif
start_elem.opr.name);
if (BE (*err != REG_NOERROR, 0))
goto parse_bracket_exp_free_return;
@@ -3158,7 +3128,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
*err = build_collating_symbol (sbcset,
#ifdef RE_ENABLE_I18N
mbcset, &coll_sym_alloc,
-#endif /* RE_ENABLE_I18N */
+#endif
start_elem.opr.name);
if (BE (*err != REG_NOERROR, 0))
goto parse_bracket_exp_free_return;
@@ -3167,7 +3137,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
*err = build_charclass (regexp->trans, sbcset,
#ifdef RE_ENABLE_I18N
mbcset, &char_class_alloc,
-#endif /* RE_ENABLE_I18N */
+#endif
start_elem.opr.name, syntax);
if (BE (*err != REG_NOERROR, 0))
goto parse_bracket_exp_free_return;
@@ -3256,7 +3226,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
re_free (sbcset);
#ifdef RE_ENABLE_I18N
free_charset (mbcset);
-#endif /* RE_ENABLE_I18N */
+#endif
return NULL;
}
@@ -3353,11 +3323,11 @@ static reg_errcode_t
#ifdef RE_ENABLE_I18N
build_equiv_class (bitset_t sbcset, re_charset_t *mbcset,
int *equiv_class_alloc, const unsigned char *name)
-#else /* not RE_ENABLE_I18N */
+#else
build_equiv_class (bitset_t sbcset, const unsigned char *name)
-#endif /* not RE_ENABLE_I18N */
+#endif
{
-#ifdef _LIBC
+#if 0
uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
if (nrules != 0)
{
@@ -3426,7 +3396,7 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name)
mbcset->equiv_classes[mbcset->nequiv_classes++] = idx1;
}
else
-#endif /* _LIBC */
+#endif
{
if (BE (strlen ((const char *) name) != 1, 0))
return REG_ECOLLATE;
@@ -3443,13 +3413,13 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name)
static reg_errcode_t
#ifdef RE_ENABLE_I18N
-build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
+build_charclass (__RE_TRANSLATE_TYPE trans, bitset_t sbcset,
re_charset_t *mbcset, int *char_class_alloc,
const unsigned char *class_name, reg_syntax_t syntax)
-#else /* not RE_ENABLE_I18N */
-build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
+#else
+build_charclass (__RE_TRANSLATE_TYPE trans, bitset_t sbcset,
const unsigned char *class_name, reg_syntax_t syntax)
-#endif /* not RE_ENABLE_I18N */
+#endif
{
int i;
const char *name = (const char *) class_name;
@@ -3525,7 +3495,7 @@ build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
}
static bin_tree_t *
-build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
+build_charclass_op (re_dfa_t *dfa, __RE_TRANSLATE_TYPE trans,
const unsigned char *class_name,
const unsigned char *extra, int non_match,
reg_errcode_t *err)
@@ -3534,21 +3504,21 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
#ifdef RE_ENABLE_I18N
re_charset_t *mbcset;
int alloc = 0;
-#endif /* not RE_ENABLE_I18N */
+#endif
reg_errcode_t ret;
re_token_t br_token;
bin_tree_t *tree;
- sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
+ sbcset = calloc (sizeof (bitset_t), 1);
#ifdef RE_ENABLE_I18N
- mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
-#endif /* RE_ENABLE_I18N */
+ mbcset = calloc (sizeof (re_charset_t), 1);
+#endif
#ifdef RE_ENABLE_I18N
if (BE (sbcset == NULL || mbcset == NULL, 0))
-#else /* not RE_ENABLE_I18N */
+#else
if (BE (sbcset == NULL, 0))
-#endif /* not RE_ENABLE_I18N */
+#endif
{
*err = REG_ESPACE;
return NULL;
@@ -3562,14 +3532,14 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
bitset_set(cset->sbcset, '\0');
*/
mbcset->non_match = 1;
-#endif /* not RE_ENABLE_I18N */
+#endif
}
/* We don't care the syntax in this case. */
ret = build_charclass (trans, sbcset,
#ifdef RE_ENABLE_I18N
mbcset, &alloc,
-#endif /* RE_ENABLE_I18N */
+#endif
class_name, 0);
if (BE (ret != REG_NOERROR, 0))
@@ -3577,7 +3547,7 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
re_free (sbcset);
#ifdef RE_ENABLE_I18N
free_charset (mbcset);
-#endif /* RE_ENABLE_I18N */
+#endif
*err = ret;
return NULL;
}
@@ -3625,13 +3595,13 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
}
#else /* not RE_ENABLE_I18N */
return tree;
-#endif /* not RE_ENABLE_I18N */
+#endif
build_word_op_espace:
re_free (sbcset);
#ifdef RE_ENABLE_I18N
free_charset (mbcset);
-#endif /* RE_ENABLE_I18N */
+#endif
*err = REG_ESPACE;
return NULL;
}
@@ -3666,7 +3636,7 @@ static void
free_charset (re_charset_t *cset)
{
re_free (cset->mbchars);
-# ifdef _LIBC
+# if 0
re_free (cset->coll_syms);
re_free (cset->equiv_classes);
re_free (cset->range_starts);
@@ -3746,7 +3716,7 @@ free_token (re_token_t *node)
if (node->type == COMPLEX_BRACKET && node->duplicated == 0)
free_charset (node->opr.mbcset);
else
-#endif /* RE_ENABLE_I18N */
+#endif
if (node->type == SIMPLE_BRACKET && node->duplicated == 0)
re_free (node->opr.sbcset);
}
diff --git a/libc/misc/regex/regex.c b/libc/misc/regex/regex.c
index 10229a265..926ee269e 100644
--- a/libc/misc/regex/regex.c
+++ b/libc/misc/regex/regex.c
@@ -14,84 +14,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/>. */
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-/* uClibc addons */
#include <features.h>
#ifdef __UCLIBC__
-#undef _LIBC
-#define _REGEX_RE_COMP
-#ifdef __USE_GNU
-# define HAVE_MEMPCPY
-#endif
-#define HAVE_LANGINFO
-#define HAVE_LANGINFO_CODESET
-#include <stdbool.h>
-#include <stdint.h>
-#include <string.h>
-#include <stdlib.h>
-#ifdef __UCLIBC_HAS_WCHAR__
-#define RE_ENABLE_I18N
-#include <wchar.h>
-#include <wctype.h>
-
-#define __iswctype iswctype
-#define __wcrtomb wcrtomb
-#define __btowc btowc
-#define __wctype wctype
-libc_hidden_proto(wcscoll)
-libc_hidden_proto(wcrtomb)
-libc_hidden_proto(mbrtowc)
-libc_hidden_proto(iswctype)
-libc_hidden_proto(iswlower)
-libc_hidden_proto(iswalnum)
-libc_hidden_proto(towlower)
-libc_hidden_proto(towupper)
-libc_hidden_proto(mbsinit)
-libc_hidden_proto(btowc)
-libc_hidden_proto(wctype)
-
-#endif
-
-#include <ctype.h>
-#ifdef __UCLIBC_HAS_CTYPE_TABLES__
-#define __toupper toupper
-#define __tolower tolower
-#endif
-#define __mempcpy mempcpy
-#ifdef __UCLIBC_HAS_XLOCALE__
-libc_hidden_proto(__ctype_b_loc)
-libc_hidden_proto(__ctype_toupper_loc)
-#elif defined __UCLIBC_HAS_CTYPE_TABLES__
-libc_hidden_proto(__ctype_b)
-libc_hidden_proto(__ctype_toupper)
-#else
-libc_hidden_proto(isascii)
-#endif
-libc_hidden_proto(toupper)
-libc_hidden_proto(tolower)
-/* Experimentally off - libc_hidden_proto(memcmp) */
-/* Experimentally off - libc_hidden_proto(memcpy) */
-/* Experimentally off - libc_hidden_proto(memmove) */
-/* Experimentally off - libc_hidden_proto(memset) */
-/* Experimentally off - libc_hidden_proto(strchr) */
-/* Experimentally off - libc_hidden_proto(strcmp) */
-/* Experimentally off - libc_hidden_proto(strlen) */
-/* Experimentally off - libc_hidden_proto(strncpy) */
-libc_hidden_proto(getenv)
-/* Experimentally off - libc_hidden_proto(strcasecmp) */
-libc_hidden_proto(abort)
-#ifdef __USE_GNU
-/* Experimentally off - libc_hidden_proto(mempcpy) */
-#endif
-
+# define _REGEX_RE_COMP
+# define HAVE_LANGINFO
+# define HAVE_LANGINFO_CODESET
+# include <stdbool.h>
+# include <stdint.h>
+# include <string.h>
+# include <stdlib.h>
+# ifdef __UCLIBC_HAS_WCHAR__
+# define RE_ENABLE_I18N
+# define HAVE_WCHAR_H 1
+# define HAVE_WCRTOMB 1
+# define HAVE_MBRTOWC 1
+# define HAVE_WCSCOLL 1
+# include <wchar.h>
+# define HAVE_WCTYPE_H 1
+# include <wctype.h>
+# define __iswctype iswctype
+# define __wcrtomb wcrtomb
+# define __btowc btowc
+# define __wctype wctype
+# endif
+# include <ctype.h>
+# ifdef __UCLIBC_HAS_LOCALE__
+# define HAVE_LOCALE_H 1
+# endif
#endif
/* Make sure noone compiles this code with a C++ compiler. */
@@ -99,54 +52,14 @@ libc_hidden_proto(abort)
# error "This is C code, use a C compiler"
#endif
-#if defined _LIBC || defined __UCLIBC__
-/* We have to keep the namespace clean. */
-# define regfree(preg) __regfree (preg)
-# define regexec(pr, st, nm, pm, ef) __regexec (pr, st, nm, pm, ef)
-# define regcomp(preg, pattern, cflags) __regcomp (preg, pattern, cflags)
-# define regerror(errcode, preg, errbuf, errbuf_size) \
- __regerror(errcode, preg, errbuf, errbuf_size)
-# define re_set_registers(bu, re, nu, st, en) \
- __re_set_registers (bu, re, nu, st, en)
-# define re_match_2(bufp, string1, size1, string2, size2, pos, regs, stop) \
- __re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
-# define re_match(bufp, string, size, pos, regs) \
- __re_match (bufp, string, size, pos, regs)
-# define re_search(bufp, string, size, startpos, range, regs) \
- __re_search (bufp, string, size, startpos, range, regs)
-# define re_compile_pattern(pattern, length, bufp) \
- __re_compile_pattern (pattern, length, bufp)
-# define re_set_syntax(syntax) __re_set_syntax (syntax)
-# define re_search_2(bufp, st1, s1, st2, s2, startpos, range, regs, stop) \
- __re_search_2 (bufp, st1, s1, st2, s2, startpos, range, regs, stop)
-# define re_compile_fastmap(bufp) __re_compile_fastmap (bufp)
-
-#ifndef __UCLIBC__
-# include "../locale/localeinfo.h"
-#endif
-#endif
-
/* On some systems, limits.h sets RE_DUP_MAX to a lower value than
GNU regex allows. Include it before <regex.h>, which correctly
#undefs RE_DUP_MAX and sets it to the right value. */
#include <limits.h>
-#ifdef __UCLIBC__
-#include "_regex.h"
-#else
#include <regex.h>
-#endif
-#include "regex_internal.h"
+#include "regex_internal.h"
#include "regex_internal.c"
#include "regcomp.c"
#include "regexec.c"
-
-/* Binary backward compatibility. */
-#if _LIBC
-# include <shlib-compat.h>
-# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3)
-link_warning (re_max_failures, "the 're_max_failures' variable is obsolete and will go away.")
-int re_max_failures = 2000;
-# endif
-#endif
diff --git a/libc/misc/regex/regex_internal.c b/libc/misc/regex/regex_internal.c
index 11b1be7c2..c74c6a0c3 100644
--- a/libc/misc/regex/regex_internal.c
+++ b/libc/misc/regex/regex_internal.c
@@ -14,13 +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/>. */
static void re_string_construct_common (const char *str, int len,
re_string_t *pstr,
- RE_TRANSLATE_TYPE trans, int icase,
+ __RE_TRANSLATE_TYPE trans, int icase,
const re_dfa_t *dfa) internal_function;
static re_dfastate_t *create_ci_newstate (const re_dfa_t *dfa,
const re_node_set *nodes,
@@ -38,7 +37,7 @@ static re_dfastate_t *create_cd_newstate (const re_dfa_t *dfa,
static reg_errcode_t
internal_function
re_string_allocate (re_string_t *pstr, const char *str, int len, int init_len,
- RE_TRANSLATE_TYPE trans, int icase, const re_dfa_t *dfa)
+ __RE_TRANSLATE_TYPE trans, int icase, const re_dfa_t *dfa)
{
reg_errcode_t ret;
int init_buf_len;
@@ -66,7 +65,7 @@ re_string_allocate (re_string_t *pstr, const char *str, int len, int init_len,
static reg_errcode_t
internal_function
re_string_construct (re_string_t *pstr, const char *str, int len,
- RE_TRANSLATE_TYPE trans, int icase, const re_dfa_t *dfa)
+ __RE_TRANSLATE_TYPE trans, int icase, const re_dfa_t *dfa)
{
reg_errcode_t ret;
memset (pstr, '\0', sizeof (re_string_t));
@@ -109,7 +108,7 @@ re_string_construct (re_string_t *pstr, const char *str, int len,
if (dfa->mb_cur_max > 1)
build_wcs_buffer (pstr);
else
-#endif /* RE_ENABLE_I18N */
+#endif
{
if (trans != NULL)
re_string_translate_buffer (pstr);
@@ -162,7 +161,7 @@ re_string_realloc_buffers (re_string_t *pstr, int new_buf_len)
static void
internal_function
re_string_construct_common (const char *str, int len, re_string_t *pstr,
- RE_TRANSLATE_TYPE trans, int icase,
+ __RE_TRANSLATE_TYPE trans, int icase,
const re_dfa_t *dfa)
{
pstr->raw_mbs = (const unsigned char *) str;
@@ -195,7 +194,7 @@ static void
internal_function
build_wcs_buffer (re_string_t *pstr)
{
-#if defined _LIBC || defined __UCLIBC__
+#if defined __UCLIBC__
unsigned char buf[MB_LEN_MAX];
assert (MB_LEN_MAX >= pstr->mb_cur_max);
#else
@@ -266,7 +265,7 @@ build_wcs_upper_buffer (re_string_t *pstr)
mbstate_t prev_st;
int src_idx, byte_idx, end_idx, remain_len;
size_t mbclen;
-#if defined _LIBC || defined __UCLIBC__
+#if defined __UCLIBC__
char buf[MB_LEN_MAX];
assert (MB_LEN_MAX >= pstr->mb_cur_max);
#else
@@ -289,7 +288,7 @@ build_wcs_upper_buffer (re_string_t *pstr)
{
/* In case of a singlebyte character. */
pstr->mbs[byte_idx]
- = __toupper (pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]);
+ = toupper (pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]);
/* The next step uses the assumption that wchar_t is encoded
ASCII-safe: all ASCII values can be converted like this. */
pstr->wcs[byte_idx] = (wchar_t) pstr->mbs[byte_idx];
@@ -523,7 +522,7 @@ build_upper_buffer (re_string_t *pstr)
if (BE (pstr->trans != NULL, 0))
ch = pstr->trans[ch];
if (islower (ch))
- pstr->mbs[char_idx] = __toupper (ch);
+ pstr->mbs[char_idx] = toupper (ch);
else
pstr->mbs[char_idx] = ch;
}
@@ -565,7 +564,7 @@ re_string_reconstruct (re_string_t *pstr, int idx, int eflags)
#ifdef RE_ENABLE_I18N
if (pstr->mb_cur_max > 1)
memset (&pstr->cur_state, '\0', sizeof (mbstate_t));
-#endif /* RE_ENABLE_I18N */
+#endif
pstr->len = pstr->raw_len;
pstr->stop = pstr->raw_stop;
pstr->valid_len = 0;
@@ -596,13 +595,13 @@ re_string_reconstruct (re_string_t *pstr, int idx, int eflags)
if (pstr->mb_cur_max > 1)
memmove (pstr->wcs, pstr->wcs + offset,
(pstr->valid_len - offset) * sizeof (wint_t));
-#endif /* RE_ENABLE_I18N */
+#endif
if (BE (pstr->mbs_allocated, 0))
memmove (pstr->mbs, pstr->mbs + offset,
pstr->valid_len - offset);
pstr->valid_len -= offset;
pstr->valid_raw_len -= offset;
-#if DEBUG
+#ifdef DEBUG
assert (pstr->valid_len > 0);
#endif
}
@@ -627,14 +626,14 @@ re_string_reconstruct (re_string_t *pstr, int idx, int eflags)
if (pstr->is_utf8)
{
- const unsigned char *raw, *p, *q, *end;
+ const unsigned char *raw, *p, *end;
/* Special case UTF-8. Multi-byte chars start with any
byte other than 0x80 - 0xbf. */
raw = pstr->raw_mbs + pstr->raw_mbs_idx;
end = raw + (offset - pstr->mb_cur_max);
p = raw + offset - 1;
-#ifdef _LIBC
+#if 0
/* We know the wchar_t encoding is UCS4, so for the simple
case, ASCII characters, skip the conversion step. */
if (isascii (*p) && BE (pstr->trans == NULL, 1))
@@ -651,17 +650,8 @@ re_string_reconstruct (re_string_t *pstr, int idx, int eflags)
mbstate_t cur_state;
wchar_t wc2;
int mlen = raw + pstr->len - p;
- unsigned char buf[6];
size_t mbclen;
- q = p;
- if (BE (pstr->trans != NULL, 0))
- {
- int i = mlen < 6 ? mlen : 6;
- while (--i >= 0)
- buf[i] = pstr->trans[p[i]];
- q = buf;
- }
/* XXX Don't use mbrtowc, we know which conversion
to use (UTF-8 -> UCS4). */
memset (&cur_state, 0, sizeof (cur_state));
@@ -729,7 +719,7 @@ re_string_reconstruct (re_string_t *pstr, int idx, int eflags)
build_wcs_buffer (pstr);
}
else
-#endif /* RE_ENABLE_I18N */
+#endif
if (BE (pstr->mbs_allocated, 0))
{
if (pstr->icase)
@@ -864,14 +854,11 @@ re_string_context_at (const re_string_t *input, int idx, int eflags)
return (IS_WIDE_NEWLINE (wc) && input->newline_anchor
? CONTEXT_NEWLINE : 0);
}
- else
#endif
- {
- c = re_string_byte_at (input, idx);
- if (bitset_contain (input->word_char, c))
- return CONTEXT_WORD;
- return IS_NEWLINE (c) && input->newline_anchor ? CONTEXT_NEWLINE : 0;
- }
+ c = re_string_byte_at (input, idx);
+ if (bitset_contain (input->word_char, c))
+ return CONTEXT_WORD;
+ return IS_NEWLINE (c) && input->newline_anchor ? CONTEXT_NEWLINE : 0;
}
/* Functions for set operation. */
@@ -1068,10 +1055,9 @@ re_node_set_init_union (re_node_set *dest, const re_node_set *src1,
{
if (src1 != NULL && src1->nelem > 0)
return re_node_set_init_copy (dest, src1);
- else if (src2 != NULL && src2->nelem > 0)
+ if (src2 != NULL && src2->nelem > 0)
return re_node_set_init_copy (dest, src2);
- else
- re_node_set_init_empty (dest);
+ re_node_set_init_empty (dest);
return REG_NOERROR;
}
for (i1 = i2 = id = 0 ; i1 < src1->nelem && i2 < src2->nelem ;)
@@ -1197,8 +1183,7 @@ re_node_set_insert (re_node_set *set, int elem)
{
if (BE (re_node_set_init_1 (set, elem) == REG_NOERROR, 1))
return 1;
- else
- return -1;
+ return -1;
}
if (BE (set->nelem, 0) == 0)
@@ -1529,7 +1514,7 @@ create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
reg_errcode_t err;
re_dfastate_t *newstate;
- newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1);
+ newstate = calloc (sizeof (re_dfastate_t), 1);
if (BE (newstate == NULL, 0))
return NULL;
err = re_node_set_init_copy (&newstate->nodes, nodes);
@@ -1544,11 +1529,12 @@ create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
{
re_token_t *node = dfa->nodes + nodes->elems[i];
re_token_type_t type = node->type;
+
if (type == CHARACTER && !node->constraint)
continue;
#ifdef RE_ENABLE_I18N
newstate->accept_mb |= node->accept_mb;
-#endif /* RE_ENABLE_I18N */
+#endif
/* If the state has the halt node, the state is a halt state. */
if (type == END_OF_RE)
@@ -1579,7 +1565,7 @@ create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
reg_errcode_t err;
re_dfastate_t *newstate;
- newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1);
+ newstate = calloc (sizeof (re_dfastate_t), 1);
if (BE (newstate == NULL, 0))
return NULL;
err = re_node_set_init_copy (&newstate->nodes, nodes);
diff --git a/libc/misc/regex/regex_internal.h b/libc/misc/regex/regex_internal.h
index 725e33a5a..5d9154fa0 100644
--- a/libc/misc/regex/regex_internal.h
+++ b/libc/misc/regex/regex_internal.h
@@ -14,85 +14,58 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 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 _REGEX_INTERNAL_H
#define _REGEX_INTERNAL_H 1
#include <assert.h>
#include <ctype.h>
-#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#if defined HAVE_LANGINFO_H || defined HAVE_LANGINFO_CODESET || defined _LIBC
+#if defined HAVE_LANGINFO_H || defined HAVE_LANGINFO_CODESET
# include <langinfo.h>
-libc_hidden_proto(nl_langinfo)
#endif
-#if defined HAVE_LOCALE_H || defined _LIBC
+#if defined HAVE_LOCALE_H
# include <locale.h>
#endif
-#if defined HAVE_WCHAR_H || defined _LIBC
+#if defined HAVE_WCHAR_H
# include <wchar.h>
-#endif /* HAVE_WCHAR_H || _LIBC */
-#if defined HAVE_WCTYPE_H || defined _LIBC
+#endif
+#if defined HAVE_WCTYPE_H
# include <wctype.h>
-#endif /* HAVE_WCTYPE_H || _LIBC */
-#if defined HAVE_STDBOOL_H || defined _LIBC
-# include <stdbool.h>
-#endif /* HAVE_STDBOOL_H || _LIBC */
-#if defined HAVE_STDINT_H || defined _LIBC
-# include <stdint.h>
-#endif /* HAVE_STDINT_H || _LIBC */
-#if defined _LIBC
-# include <bits/libc-lock.h>
-#else
-# define __libc_lock_define(CLASS,NAME)
-# define __libc_lock_init(NAME) do { } while (0)
-# define __libc_lock_lock(NAME) do { } while (0)
-# define __libc_lock_unlock(NAME) do { } while (0)
#endif
-
-/* In case that the system doesn't have isblank(). */
-#if !defined _LIBC && !defined HAVE_ISBLANK && !defined isblank && !defined __UCLIBC__
-# define isblank(ch) ((ch) == ' ' || (ch) == '\t')
+#if defined HAVE_STDBOOL_H
+# include <stdbool.h>
#endif
-
-#if defined _LIBC && !defined __UCLIBC__
-# ifndef _RE_DEFINE_LOCALE_FUNCTIONS
-# define _RE_DEFINE_LOCALE_FUNCTIONS 1
-# include <locale/localeinfo.h>
-# include <locale/elem-hash.h>
-# include <locale/coll-lookup.h>
-# endif
+#if defined HAVE_STDINT_H
+# include <stdint.h>
#endif
-/* This is for other GNU distributions with internationalized messages. */
-#if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC
-# include <libintl.h>
-# ifdef _LIBC
-# undef gettext
-# define gettext(msgid) \
- INTUSE(__dcgettext) (_libc_intl_domainname, msgid, LC_MESSAGES)
-# endif
+#ifdef __UCLIBC_HAS_THREADS__
+#include <bits/libc-lock.h>
#else
-# define gettext(msgid) (msgid)
+#define __libc_lock_define(CLASS, NAME)
+#define __libc_lock_init(NAME) do { } while (0)
+#define __libc_lock_lock(NAME) do { } while (0)
+#define __libc_lock_unlock(NAME) do { } while (0)
#endif
-#ifndef gettext_noop
-/* This define is so xgettext can find the internationalizable
- strings. */
-# define gettext_noop(String) String
-#endif
+#undef gettext
+#undef gettext_noop
+#define gettext(msgid) (msgid)
+#define gettext_noop(String) String
-#if (defined MB_CUR_MAX && HAVE_LOCALE_H && HAVE_WCTYPE_H && HAVE_WCHAR_H && HAVE_WCRTOMB && HAVE_MBRTOWC && HAVE_WCSCOLL) || _LIBC
+#if (defined MB_CUR_MAX && HAVE_LOCALE_H && HAVE_WCTYPE_H && HAVE_WCHAR_H && HAVE_WCRTOMB && HAVE_MBRTOWC && HAVE_WCSCOLL)
# define RE_ENABLE_I18N
#endif
#if __GNUC__ >= 3
-# define BE(expr, val) __builtin_expect (expr, val)
+/* uclibc: lean towards smaller size a bit:
+ * OFF: # define BE(expr, val) __builtin_expect (expr, val) */
+# define BE(expr, val) (expr)
#else
# define BE(expr, val) (expr)
# define inline
@@ -107,26 +80,12 @@ libc_hidden_proto(nl_langinfo)
#define NEWLINE_CHAR '\n'
#define WIDE_NEWLINE_CHAR L'\n'
-/* Rename to standard API for using out of glibc. */
-#if !defined _LIBC && !defined __UCLIBC__
-# define __wctype wctype
-# define __iswctype iswctype
-# define __btowc btowc
-# define __mempcpy mempcpy
-# define __wcrtomb wcrtomb
-# define __regfree regfree
-# define attribute_hidden
-#endif /* not _LIBC */
-
#ifdef __GNUC__
# define __attribute(arg) __attribute__ (arg)
#else
# define __attribute(arg)
#endif
-extern const char __re_error_msgid[] attribute_hidden;
-extern const size_t __re_error_msgid_idx[] attribute_hidden;
-
/* An integer used to represent a set of bits. It must be unsigned,
and must be at least as wide as unsigned int. */
typedef unsigned long int bitset_word_t;
@@ -240,23 +199,23 @@ typedef struct
wchar_t *mbchars;
/* Collating symbols. */
-# ifdef _LIBC
+# if 0
int32_t *coll_syms;
# endif
/* Equivalence classes. */
-# ifdef _LIBC
+# if 0
int32_t *equiv_classes;
# endif
/* Range expressions. */
-# ifdef _LIBC
+# if 0
uint32_t *range_starts;
uint32_t *range_ends;
-# else /* not _LIBC */
+# else
wchar_t *range_starts;
wchar_t *range_ends;
-# endif /* not _LIBC */
+# endif
/* Character classes. */
wctype_t *char_classes;
@@ -354,7 +313,7 @@ struct re_string_t
the beginning of the input string. */
unsigned int tip_context;
/* The translation passed as a part of an argument of re_compile_pattern. */
- RE_TRANSLATE_TYPE trans;
+ __RE_TRANSLATE_TYPE trans;
/* Copy of re_dfa_t's word_char. */
re_const_bitset_ptr_t word_char;
/* 1 if REG_ICASE. */
@@ -369,18 +328,9 @@ struct re_string_t
};
typedef struct re_string_t re_string_t;
-
struct re_dfa_t;
typedef struct re_dfa_t re_dfa_t;
-#if !defined _LIBC && !defined __UCLIBC__
-# ifdef __i386__
-# define internal_function __attribute ((regparm (3), stdcall))
-# else
-# define internal_function
-# endif
-#endif
-
static reg_errcode_t re_string_realloc_buffers (re_string_t *pstr,
int new_buf_len)
internal_function;
@@ -412,8 +362,8 @@ static unsigned int re_string_context_at (const re_string_t *input, int idx,
#include <alloca.h>
-#ifndef _LIBC
-# if HAVE_ALLOCA
+#if 1
+# ifdef HAVE_ALLOCA
/* The OS usually guarantees only one guard page at the bottom of the stack,
and a page size can be as small as 4096 bytes. So we cannot safely
allocate anything larger than 4096 bytes. Also care for the possibility
@@ -557,11 +507,7 @@ typedef struct
{
/* The string object corresponding to the input string. */
re_string_t input;
-#if defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
- const re_dfa_t *const dfa;
-#else
const re_dfa_t *dfa;
-#endif
/* EFLAGS of the argument of regexec. */
int eflags;
/* Where the matching ends. */
@@ -734,7 +680,7 @@ static int
internal_function __attribute ((pure))
re_string_elem_size_at (const re_string_t *pstr, int idx)
{
-# ifdef _LIBC
+# if 0
const unsigned char *p, *extra;
const int32_t *table, *indirect;
int32_t tmp;
@@ -752,9 +698,8 @@ re_string_elem_size_at (const re_string_t *pstr, int idx)
tmp = findidx (&p);
return p - pstr->mbs - idx;
}
- else
-# endif /* _LIBC */
- return 1;
+# endif
+ return 1;
}
#endif /* RE_ENABLE_I18N */
diff --git a/libc/misc/regex/regex_old.c b/libc/misc/regex/regex_old.c
index a8a8cc79a..fa5de7a28 100644
--- a/libc/misc/regex/regex_old.c
+++ b/libc/misc/regex/regex_old.c
@@ -16,42 +16,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/>. */
/* To exclude some unwanted junk.... */
#undef emacs
#include <features.h>
+/* unistd.h must be included with _LIBC defined: we need smallint */
+#include <unistd.h>
+#include <stdio.h>
#ifdef __UCLIBC__
# undef _LIBC
# define _REGEX_RE_COMP
-# ifdef __USE_GNU
-# define HAVE_MEMPCPY
-# endif
# define STDC_HEADERS
-# define RE_TRANSLATE_TYPE char *
+# define __RE_TRANSLATE_TYPE char *
+# define RE_TRANSLATE_TYPE __RE_TRANSLATE_TYPE
#endif
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
-#include <unistd.h>
-#include <stdio.h>
-
-/* Experimentally off - libc_hidden_proto(memset) */
-/* Experimentally off - libc_hidden_proto(memcmp) */
-/* Experimentally off - libc_hidden_proto(memcpy) */
-/* Experimentally off - libc_hidden_proto(strcmp) */
-/* Experimentally off - libc_hidden_proto(strlen) */
-libc_hidden_proto(printf)
-libc_hidden_proto(abort)
-#ifdef __USE_GNU
-/* Experimentally off - libc_hidden_proto(mempcpy) */
-#endif
/* AIX requires this to be the first thing in the file. */
#if defined _AIX && !defined REGEX_MALLOC
- #pragma alloca
+# pragma alloca
#endif
#ifdef HAVE_CONFIG_H
@@ -70,45 +57,16 @@ libc_hidden_proto(abort)
/* For platform which support the ISO C amendement 1 functionality we
support user defined character classes. */
-#if defined __UCLIBC_HAS_WCHAR__
+# if defined __UCLIBC_HAS_WCHAR__
# define WIDE_CHAR_SUPPORT 1
/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. */
# include <wchar.h>
# include <wctype.h>
-libc_hidden_proto(wcslen)
-libc_hidden_proto(mbrtowc)
-libc_hidden_proto(wcrtomb)
-libc_hidden_proto(wcscoll)
-libc_hidden_proto(wctype)
-libc_hidden_proto(iswctype)
-libc_hidden_proto(iswalnum)
-libc_hidden_proto(btowc)
-
# endif
-# if defined _LIBC || defined __UCLIBC__
+# ifdef _LIBC
/* We have to keep the namespace clean. */
-# define regfree(preg) __regfree (preg)
-# define regexec(pr, st, nm, pm, ef) __regexec (pr, st, nm, pm, ef)
-# define regcomp(preg, pattern, cflags) __regcomp (preg, pattern, cflags)
-# define regerror(errcode, preg, errbuf, errbuf_size) \
- __regerror(errcode, preg, errbuf, errbuf_size)
-# define re_set_registers(bu, re, nu, st, en) \
- __re_set_registers (bu, re, nu, st, en)
-# define re_match_2(bufp, string1, size1, string2, size2, pos, regs, stop) \
- __re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
-# define re_match(bufp, string, size, pos, regs) \
- __re_match (bufp, string, size, pos, regs)
-# define re_search(bufp, string, size, startpos, range, regs) \
- __re_search (bufp, string, size, startpos, range, regs)
-# define re_compile_pattern(pattern, length, bufp) \
- __re_compile_pattern (pattern, length, bufp)
-# define re_set_syntax(syntax) __re_set_syntax (syntax)
-# define re_search_2(bufp, st1, s1, st2, s2, startpos, range, regs, stop) \
- __re_search_2 (bufp, st1, s1, st2, s2, startpos, range, regs, stop)
-# define re_compile_fastmap(bufp) __re_compile_fastmap (bufp)
-
-# ifndef __UCLIBC__
+
# define btowc __btowc
/* We are also using some library internals. */
@@ -117,10 +75,9 @@ libc_hidden_proto(btowc)
# include <langinfo.h>
# include <locale/coll-lookup.h>
# endif
-# endif
/* This is for other GNU distributions with internationalized messages. */
-# if HAVE_LIBINTL_H || defined _LIBC
+# if defined HAVE_LIBINTL_H || defined _LIBC
# include <libintl.h>
# ifdef _LIBC
# undef gettext
@@ -208,7 +165,7 @@ char *realloc ();
# endif /* not emacs */
-# if defined _LIBC || HAVE_LIMITS_H
+# if defined _LIBC || defined HAVE_LIMITS_H
# include <limits.h>
# endif
@@ -217,10 +174,8 @@ char *realloc ();
# endif
/* Get the interface, including the syntax bits. */
-# ifdef __UCLIBC__
-# include "_regex.h"
-# endif
# include <regex.h>
+# define translate __REPB_PREFIX(translate)
/* isalpha etc. are used for the character classes. */
# include <ctype.h>
@@ -270,7 +225,7 @@ char *realloc ();
# ifdef _tolower
# define TOLOWER(c) _tolower(c)
# else
-# define TOLOWER(c) __tolower(c)
+# define TOLOWER(c) tolower(c)
# endif
# ifndef NULL
@@ -307,7 +262,7 @@ static void
init_syntax_once (void)
{
register int c;
- static int done = 0;
+ static smallint done = 0;
if (done)
return;
@@ -797,7 +752,7 @@ static smallint debug;
/* Print the fastmap in human-readable form. */
# ifndef DEFINED_ONCE
-void
+static void
print_fastmap (char *fastmap)
{
unsigned was_a_range = 0;
@@ -829,7 +784,7 @@ print_fastmap (char *fastmap)
/* Print a compiled pattern string in human-readable form, starting at
the START pointer into it and ending just before the pointer END. */
-void
+static void
PREFIX(print_partial_compiled_pattern) (UCHAR_T *start, UCHAR_T *end)
{
int mcnt, mcnt2;
@@ -1162,7 +1117,7 @@ PREFIX(print_partial_compiled_pattern) (UCHAR_T *start, UCHAR_T *end)
}
-void
+static void
PREFIX(print_compiled_pattern) (struct re_pattern_buffer *bufp)
{
UCHAR_T *buffer = (UCHAR_T*) bufp->buffer;
@@ -1194,7 +1149,7 @@ PREFIX(print_compiled_pattern) (struct re_pattern_buffer *bufp)
}
-void
+static void
PREFIX(print_double_string) (
const CHAR_T *where,
const CHAR_T *string1,
@@ -1231,7 +1186,7 @@ PREFIX(print_double_string) (
}
}
-# ifndef DEFINED_ONCE
+# if 0 /* ndef DEFINED_ONCE */
void
printchar (int c)
{
@@ -1366,9 +1321,6 @@ re_set_syntax (reg_syntax_t syntax)
# endif /* DEBUG */
return ret;
}
-# if defined _LIBC || defined __UCLIBC__
-strong_alias(__re_set_syntax, re_set_syntax)
-# endif
/* This table gives an error message for each of the error codes listed
in regex.h. Obviously the order here has to be same as there.
@@ -1429,7 +1381,7 @@ static const char re_error_msgid[] =
gettext_noop ("Unmatched ) or \\)") /* REG_ERPAREN */
};
-static const size_t re_error_msgid_idx[] =
+static const uint16_t re_error_msgid_idx[] =
{
REG_NOERROR_IDX,
REG_NOMATCH_IDX,
@@ -1943,7 +1895,7 @@ static boolean PREFIX(at_endline_loc_p) (const CHAR_T *p,
static reg_errcode_t wcs_compile_range (CHAR_T range_start,
const CHAR_T **p_ptr,
const CHAR_T *pend,
- char *translate,
+ __RE_TRANSLATE_TYPE translate,
reg_syntax_t syntax,
UCHAR_T *b,
CHAR_T *char_set);
@@ -1952,7 +1904,7 @@ static void insert_space (int num, CHAR_T *loc, CHAR_T *end);
static reg_errcode_t byte_compile_range (unsigned int range_start,
const char **p_ptr,
const char *pend,
- char *translate,
+ __RE_TRANSLATE_TYPE translate,
reg_syntax_t syntax,
unsigned char *b);
# endif /* WCHAR */
@@ -2091,33 +2043,12 @@ static reg_errcode_t byte_compile_range (unsigned int range_start,
# define MAX_BUF_SIZE (1L << 16)
# define REALLOC(p,s) realloc ((p), (s))
# endif
+# endif /* not DEFINED_ONCE */
/* Extend the buffer by twice its current size via realloc and
reset the pointers that pointed into the old block to point to the
correct places in the new one. If extending the buffer results in it
being larger than MAX_BUF_SIZE, then flag memory exhausted. */
-# if __BOUNDED_POINTERS__
-# define SET_HIGH_BOUND(P) (__ptrhigh (P) = __ptrlow (P) + bufp->allocated)
-# define MOVE_BUFFER_POINTER(P) \
- (__ptrlow (P) += incr, SET_HIGH_BOUND (P), __ptrvalue (P) += incr)
-# define ELSE_EXTEND_BUFFER_HIGH_BOUND \
- else \
- { \
- SET_HIGH_BOUND (b); \
- SET_HIGH_BOUND (begalt); \
- if (fixup_alt_jump) \
- SET_HIGH_BOUND (fixup_alt_jump); \
- if (laststart) \
- SET_HIGH_BOUND (laststart); \
- if (pending_exact) \
- SET_HIGH_BOUND (pending_exact); \
- }
-# else
-# define MOVE_BUFFER_POINTER(P) (P) += incr
-# define ELSE_EXTEND_BUFFER_HIGH_BOUND
-# endif
-# endif /* not DEFINED_ONCE */
-
# ifdef WCHAR
# define EXTEND_BUFFER() \
do { \
@@ -2141,16 +2072,15 @@ static reg_errcode_t byte_compile_range (unsigned int range_start,
if (old_buffer != COMPILED_BUFFER_VAR) \
{ \
int incr = COMPILED_BUFFER_VAR - old_buffer; \
- MOVE_BUFFER_POINTER (b); \
- MOVE_BUFFER_POINTER (begalt); \
+ b += incr; \
+ begalt += incr; \
if (fixup_alt_jump) \
- MOVE_BUFFER_POINTER (fixup_alt_jump); \
+ fixup_alt_jump += incr; \
if (laststart) \
- MOVE_BUFFER_POINTER (laststart); \
+ laststart += incr; \
if (pending_exact) \
- MOVE_BUFFER_POINTER (pending_exact); \
+ pending_exact += incr; \
} \
- ELSE_EXTEND_BUFFER_HIGH_BOUND \
} while (0)
# else /* BYTE */
# define EXTEND_BUFFER() \
@@ -2169,16 +2099,15 @@ static reg_errcode_t byte_compile_range (unsigned int range_start,
if (old_buffer != COMPILED_BUFFER_VAR) \
{ \
int incr = COMPILED_BUFFER_VAR - old_buffer; \
- MOVE_BUFFER_POINTER (b); \
- MOVE_BUFFER_POINTER (begalt); \
+ b += incr; \
+ begalt += incr; \
if (fixup_alt_jump) \
- MOVE_BUFFER_POINTER (fixup_alt_jump); \
+ fixup_alt_jump += incr; \
if (laststart) \
- MOVE_BUFFER_POINTER (laststart); \
+ laststart += incr; \
if (pending_exact) \
- MOVE_BUFFER_POINTER (pending_exact); \
+ pending_exact += incr; \
} \
- ELSE_EXTEND_BUFFER_HIGH_BOUND \
} while (0)
# endif /* WCHAR */
@@ -2253,7 +2182,7 @@ typedef struct
}
# ifndef DEFINED_ONCE
-# if defined _LIBC || WIDE_CHAR_SUPPORT
+# if defined _LIBC || defined WIDE_CHAR_SUPPORT
/* The GNU C library provides support for user-defined character classes
and the functions from ISO C amendement 1. */
# ifdef CHARCLASS_NAME_MAX
@@ -2408,7 +2337,7 @@ PREFIX(regex_compile) (
#endif /* WCHAR */
/* How to translate the characters in the pattern. */
- RE_TRANSLATE_TYPE translate = bufp->translate;
+ __RE_TRANSLATE_TYPE translate = bufp->translate;
/* Address of the count-byte of the most recently inserted `exactn'
command. This makes it possible to tell if a new exact-match
@@ -3309,7 +3238,7 @@ PREFIX(regex_compile) (
the leading `:' and `[' (but set bits for them). */
if (c == ':' && *p == ']')
{
-# if defined _LIBC || WIDE_CHAR_SUPPORT
+# if defined _LIBC || defined WIDE_CHAR_SUPPORT
boolean is_lower = STREQ (str, "lower");
boolean is_upper = STREQ (str, "upper");
wctype_t wt;
@@ -4472,7 +4401,7 @@ static reg_errcode_t
wcs_compile_range (
CHAR_T range_start_char,
const CHAR_T **p_ptr, const CHAR_T *pend,
- RE_TRANSLATE_TYPE translate,
+ __RE_TRANSLATE_TYPE translate,
reg_syntax_t syntax,
CHAR_T *b, CHAR_T *char_set)
{
@@ -4558,14 +4487,14 @@ static reg_errcode_t
byte_compile_range (
unsigned int range_start_char,
const char **p_ptr, const char *pend,
- RE_TRANSLATE_TYPE translate,
+ __RE_TRANSLATE_TYPE translate,
reg_syntax_t syntax,
unsigned char *b)
{
unsigned this_char;
const char *p = *p_ptr;
reg_errcode_t ret;
-# if _LIBC
+# ifdef _LIBC
const unsigned char *collseq;
unsigned int start_colseq;
unsigned int end_colseq;
@@ -4583,7 +4512,7 @@ byte_compile_range (
/* Report an error if the range is empty and the syntax prohibits this. */
ret = syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR;
-# if _LIBC
+# ifdef _LIBC
collseq = (const unsigned char *) _NL_CURRENT (LC_COLLATE,
_NL_COLLATE_COLLSEQMB);
@@ -4978,13 +4907,10 @@ re_compile_fastmap (struct re_pattern_buffer *bufp)
# ifdef MBS_SUPPORT
if (MB_CUR_MAX != 1)
return wcs_re_compile_fastmap(bufp);
- else
# endif
- return byte_re_compile_fastmap(bufp);
-} /* re_compile_fastmap */
-#if defined _LIBC || defined __UCLIBC__
-strong_alias(__re_compile_fastmap, re_compile_fastmap)
-#endif
+ return byte_re_compile_fastmap(bufp);
+}
+libc_hidden_def(re_compile_fastmap)
/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
@@ -5021,9 +4947,6 @@ re_set_registers (
regs->start = regs->end = (regoff_t *) 0;
}
}
-#if defined _LIBC || defined __UCLIBC__
-strong_alias(__re_set_registers, re_set_registers)
-#endif
/* Searching routines. */
@@ -5040,9 +4963,7 @@ re_search (
return re_search_2 (bufp, NULL, 0, string, size, startpos, range,
regs, size);
}
-#if defined _LIBC || defined __UCLIBC__
-strong_alias(__re_search, re_search)
-#endif
+libc_hidden_def(re_search)
/* Using the compiled pattern in BUFP->buffer, first tries to match the
@@ -5080,14 +5001,11 @@ re_search_2 (
if (MB_CUR_MAX != 1)
return wcs_re_search_2 (bufp, string1, size1, string2, size2, startpos,
range, regs, stop);
- else
# endif
- return byte_re_search_2 (bufp, string1, size1, string2, size2, startpos,
- range, regs, stop);
-} /* re_search_2 */
-#if defined _LIBC || defined __UCLIBC__
-strong_alias(__re_search_2, re_search_2)
-#endif
+ return byte_re_search_2 (bufp, string1, size1, string2, size2, startpos,
+ range, regs, stop);
+}
+libc_hidden_def(re_search_2)
#endif /* not INSIDE_RECURSION */
@@ -5141,7 +5059,7 @@ PREFIX(re_search_2) (
{
int val;
register char *fastmap = bufp->fastmap;
- register RE_TRANSLATE_TYPE translate = bufp->translate;
+ register __RE_TRANSLATE_TYPE translate = bufp->translate;
int total_size = size1 + size2;
int endpos = startpos + range;
#ifdef WCHAR
@@ -5543,9 +5461,6 @@ re_match (
# endif
return result;
}
-# if defined _LIBC || defined __UCLIBC__
-strong_alias(__re_match, re_match)
-# endif
#endif /* not emacs */
#endif /* not INSIDE_RECURSION */
@@ -5561,7 +5476,7 @@ static boolean PREFIX(common_op_match_null_string_p) (UCHAR_T **p,
UCHAR_T *end,
PREFIX(register_info_type) *reg_info);
static int PREFIX(bcmp_translate) (const CHAR_T *s1, const CHAR_T *s2,
- int len, char *translate);
+ int len, __RE_TRANSLATE_TYPE translate);
#else /* not INSIDE_RECURSION */
/* re_match_2 matches the compiled pattern in BUFP against the
@@ -5604,9 +5519,6 @@ re_match_2 (
#endif
return result;
}
-#if defined _LIBC || defined __UCLIBC__
-strong_alias(__re_match_2, re_match_2)
-#endif
#endif /* not INSIDE_RECURSION */
@@ -5724,7 +5636,7 @@ byte_re_match_2_internal (
UCHAR_T *just_past_start_mem = 0;
/* We use this to map every character in the string. */
- RE_TRANSLATE_TYPE translate = bufp->translate;
+ __RE_TRANSLATE_TYPE translate = bufp->translate;
/* Failure point stack. Each place that can handle a failure further
down the line pushes a failure point on this stack. It consists of
@@ -6122,7 +6034,19 @@ byte_re_match_2_internal (
{ /* No. So allocate them with malloc. We need one
extra element beyond `num_regs' for the `-1' marker
GNU code uses. */
- regs->num_regs = MAX (RE_NREGS, num_regs + 1);
+/* regex specs say:
+ * "If REGS_UNALLOCATED, allocate space in the regs structure
+ * for max(RE_NREGS, re_nsub + 1) groups"
+ * but real-world testsuites fail with contrived examples
+ * with lots of groups.
+ * I don't see why we can't just allocate exact needed number.
+ * Incidentally, it makes RE_NREGS unused.
+ *
+ * regs->num_regs = MAX (RE_NREGS, num_regs + 1); - VERY WRONG
+ * regs->num_regs = MIN (RE_NREGS, num_regs + 1); - slightly less wrong
+ * good one which passes uclibc test/regex/tst-regex2.c:
+ */
+ regs->num_regs = num_regs + 1;
regs->start = TALLOC (regs->num_regs, regoff_t);
regs->end = TALLOC (regs->num_regs, regoff_t);
if (regs->start == NULL || regs->end == NULL)
@@ -7287,6 +7211,10 @@ byte_re_match_2_internal (
POP_FAILURE_POINT (sdummy, pdummy,
dummy_low_reg, dummy_high_reg,
reg_dummy, reg_dummy, reg_info_dummy);
+
+ /* Silence 'set but not used' warnings. */
+ (void) pdummy;
+ (void) sdummy;
}
/* Note fall through. */
@@ -7877,7 +7805,7 @@ static int
PREFIX(bcmp_translate) (
const CHAR_T *s1, const CHAR_T *s2,
register int len,
- RE_TRANSLATE_TYPE translate)
+ __RE_TRANSLATE_TYPE translate)
{
register const UCHAR_T *p1 = (const UCHAR_T *) s1;
register const UCHAR_T *p2 = (const UCHAR_T *) s2;
@@ -7910,10 +7838,9 @@ PREFIX(bcmp_translate) (
We call regex_compile to do the actual compilation. */
const char *
-re_compile_pattern (
- const char *pattern,
- size_t length,
- struct re_pattern_buffer *bufp)
+re_compile_pattern (const char *pattern,
+ size_t length,
+ struct re_pattern_buffer *bufp)
{
reg_errcode_t ret;
@@ -7940,9 +7867,6 @@ re_compile_pattern (
return NULL;
return gettext (re_error_msgid + re_error_msgid_idx[(int) ret]);
}
-#if defined _LIBC || defined __UCLIBC__
-strong_alias(__re_compile_pattern, re_compile_pattern)
-#endif
/* Entry points compatible with 4.2 BSD regex library. We don't define
them unless specifically requested. */
@@ -8081,8 +8005,8 @@ regcomp (
unsigned i;
preg->translate
- = (RE_TRANSLATE_TYPE) malloc (CHAR_SET_SIZE
- * sizeof (*(RE_TRANSLATE_TYPE)0));
+ = (__RE_TRANSLATE_TYPE) malloc (CHAR_SET_SIZE
+ * sizeof (*(__RE_TRANSLATE_TYPE)0));
if (preg->translate == NULL)
return (int) REG_ESPACE;
@@ -8134,9 +8058,6 @@ regcomp (
return (int) ret;
}
-#if defined _LIBC || defined __UCLIBC__
-strong_alias(__regcomp, regcomp)
-#endif
/* regexec searches for a given pattern, specified by PREG, in the
@@ -8167,7 +8088,8 @@ regexec (
int len = strlen (string);
boolean want_reg_info = !preg->no_sub && nmatch > 0;
- private_preg = *preg;
+ /* use hidden memcpy() ourselves rather than gcc calling public memcpy() */
+ memcpy(&private_preg, preg, sizeof(*preg));
private_preg.not_bol = !!(eflags & REG_NOTBOL);
private_preg.not_eol = !!(eflags & REG_NOTEOL);
@@ -8212,9 +8134,7 @@ regexec (
/* We want zero return to mean success, unlike `re_search'. */
return ret >= 0 ? (int) REG_NOERROR : (int) REG_NOMATCH;
}
-#if defined _LIBC || defined __UCLIBC__
-strong_alias(__regexec, regexec)
-#endif
+libc_hidden_def(regexec)
/* Returns a message corresponding to an error code, ERRCODE, returned
@@ -8223,7 +8143,7 @@ strong_alias(__regexec, regexec)
size_t
regerror (
int errcode,
- const regex_t *preg,
+ const regex_t * preg attribute_unused,
char *errbuf,
size_t errbuf_size)
{
@@ -8247,12 +8167,8 @@ regerror (
{
if (msg_size > errbuf_size)
{
-#if (defined HAVE_MEMPCPY || defined _LIBC) && defined __USE_GNU
- *((char *) mempcpy (errbuf, msg, errbuf_size - 1)) = '\0';
-#else
memcpy (errbuf, msg, errbuf_size - 1);
errbuf[errbuf_size - 1] = 0;
-#endif
}
else
memcpy (errbuf, msg, msg_size);
@@ -8260,9 +8176,6 @@ regerror (
return msg_size;
}
-#if defined _LIBC || defined __UCLIBC__
-strong_alias(__regerror, regerror)
-#endif
/* Free dynamically allocated space used by PREG. */
@@ -8283,9 +8196,7 @@ regfree (regex_t *preg)
free (preg->translate);
preg->translate = NULL;
}
-#if defined _LIBC || defined __UCLIBC__
-strong_alias(__regfree, regfree)
-#endif
+libc_hidden_def(regfree)
#endif /* not emacs */
diff --git a/libc/misc/regex/regexec.c b/libc/misc/regex/regexec.c
index 587e6af30..86bc6b8c5 100644
--- a/libc/misc/regex/regexec.c
+++ b/libc/misc/regex/regexec.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/>. */
static reg_errcode_t match_ctx_init (re_match_context_t *cache, int eflags,
int n) internal_function;
@@ -79,7 +78,7 @@ static int sift_states_iter_mb (const re_match_context_t *mctx,
re_sift_context_t *sctx,
int node_idx, int str_idx, int max_str_idx)
internal_function;
-#endif /* RE_ENABLE_I18N */
+#endif
static reg_errcode_t sift_states_backward (const re_match_context_t *mctx,
re_sift_context_t *sctx)
internal_function;
@@ -144,7 +143,7 @@ static re_dfastate_t *transit_state_sb (reg_errcode_t *err,
static reg_errcode_t transit_state_mb (re_match_context_t *mctx,
re_dfastate_t *pstate)
internal_function;
-#endif /* RE_ENABLE_I18N */
+#endif
static reg_errcode_t transit_state_bkref (re_match_context_t *mctx,
const re_node_set *nodes)
internal_function;
@@ -185,12 +184,7 @@ static int build_trtable (const re_dfa_t *dfa,
static int check_node_accept_bytes (const re_dfa_t *dfa, int node_idx,
const re_string_t *input, int idx)
internal_function;
-# ifdef _LIBC
-static unsigned int find_collation_sequence_value (const unsigned char *mbs,
- size_t name_len)
- internal_function;
-# endif /* _LIBC */
-#endif /* RE_ENABLE_I18N */
+#endif
static int group_nodes_into_DFAstates (const re_dfa_t *dfa,
const re_dfastate_t *state,
re_node_set *states_node,
@@ -218,16 +212,12 @@ static reg_errcode_t extend_buffers (re_match_context_t *mctx)
We return 0 if we find a match and REG_NOMATCH if not. */
int
-regexec (preg, string, nmatch, pmatch, eflags)
- const regex_t *__restrict preg;
- const char *__restrict string;
- size_t nmatch;
- regmatch_t pmatch[];
- int eflags;
+regexec (const regex_t *__restrict preg, const char *__restrict string,
+ size_t nmatch, regmatch_t pmatch[], int eflags)
{
reg_errcode_t err;
int start, length;
-#ifndef __UCLIBC__ /* libc_lock_lock does not exist */
+#ifdef __UCLIBC_HAS_THREADS__
re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
#endif
@@ -255,28 +245,7 @@ regexec (preg, string, nmatch, pmatch, eflags)
__libc_lock_unlock (dfa->lock);
return err != REG_NOERROR;
}
-
-#ifdef _LIBC
-# include <shlib-compat.h>
-versioned_symbol (libc, __regexec, regexec, GLIBC_2_3_4);
-
-# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3_4)
-__typeof__ (__regexec) __compat_regexec;
-
-int
-attribute_compat_text_section
-__compat_regexec (const regex_t *__restrict preg,
- const char *__restrict string, size_t nmatch,
- regmatch_t pmatch[], int eflags)
-{
- return regexec (preg, string, nmatch, pmatch,
- eflags & (REG_NOTBOL | REG_NOTEOL));
-}
-compat_symbol (libc, __compat_regexec, regexec, GLIBC_2_0);
-# endif
-#elif defined __UCLIBC__
-strong_alias(__regexec,regexec)
-#endif
+libc_hidden_def(regexec)
/* Entry points for GNU code. */
@@ -308,66 +277,43 @@ strong_alias(__regexec,regexec)
match was found and -2 indicates an internal error. */
int
-re_match (bufp, string, length, start, regs)
- struct re_pattern_buffer *bufp;
- const char *string;
- int length, start;
- struct re_registers *regs;
+re_match (struct re_pattern_buffer *bufp, const char *string, int length,
+ int start, struct re_registers *regs)
{
return re_search_stub (bufp, string, length, start, 0, length, regs, 1);
}
-#if defined _LIBC || defined __UCLIBC__
-strong_alias(__re_match, re_match)
-#endif
int
-re_search (bufp, string, length, start, range, regs)
- struct re_pattern_buffer *bufp;
- const char *string;
- int length, start, range;
- struct re_registers *regs;
+re_search (struct re_pattern_buffer *bufp, const char *string, int length,
+ int start, int range, struct re_registers *regs)
{
return re_search_stub (bufp, string, length, start, range, length, regs, 0);
}
-#if defined _LIBC || defined __UCLIBC__
-strong_alias(__re_search, re_search)
-#endif
+libc_hidden_def(re_search)
int
-re_match_2 (bufp, string1, length1, string2, length2, start, regs, stop)
- struct re_pattern_buffer *bufp;
- const char *string1, *string2;
- int length1, length2, start, stop;
- struct re_registers *regs;
+re_match_2 (struct re_pattern_buffer *bufp, const char *string1, int length1,
+ const char *string2, int length2, int start,
+ struct re_registers *regs, int stop)
{
return re_search_2_stub (bufp, string1, length1, string2, length2,
start, 0, regs, stop, 1);
}
-#if defined _LIBC || defined __UCLIBC__
-strong_alias(__re_match_2, re_match_2)
-#endif
int
-re_search_2 (bufp, string1, length1, string2, length2, start, range, regs, stop)
- struct re_pattern_buffer *bufp;
- const char *string1, *string2;
- int length1, length2, start, range, stop;
- struct re_registers *regs;
+re_search_2 (struct re_pattern_buffer *bufp, const char *string1, int lenght1,
+ const char *string2, int length2, int start, int range,
+ struct re_registers *regs, int stop)
{
- return re_search_2_stub (bufp, string1, length1, string2, length2,
+ return re_search_2_stub (bufp, string1, lenght1, string2, length2,
start, range, regs, stop, 0);
}
-#if defined _LIBC || defined __UCLIBC__
-strong_alias(__re_search_2, re_search_2)
-#endif
+libc_hidden_def(re_search_2)
-static int
-re_search_2_stub (bufp, string1, length1, string2, length2, start, range, regs,
- stop, ret_len)
- struct re_pattern_buffer *bufp;
- const char *string1, *string2;
- int length1, length2, start, range, stop, ret_len;
- struct re_registers *regs;
+static int internal_function
+re_search_2_stub (struct re_pattern_buffer *bufp, const char *string1,
+ int length1, const char *string2, int length2, int start,
+ int range, struct re_registers *regs, int stop, int ret_len)
{
const char *str;
int rval;
@@ -385,12 +331,8 @@ re_search_2_stub (bufp, string1, length1, string2, length2, start, range, regs,
if (BE (s == NULL, 0))
return -2;
-#if (defined _LIBC || defined __UCLIBC__) && defined __USE_GNU
- memcpy (__mempcpy (s, string1, length1), string2, length2);
-#else
memcpy (s, string1, length1);
memcpy (s + length1, string2, length2);
-#endif
str = s;
free_str = 1;
}
@@ -411,21 +353,18 @@ re_search_2_stub (bufp, string1, length1, string2, length2, start, range, regs,
If RET_LEN is nonzero the length of the match is returned (re_match style);
otherwise the position of the match is returned. */
-static int
-re_search_stub (bufp, string, length, start, range, stop, regs, ret_len)
- struct re_pattern_buffer *bufp;
- const char *string;
- int length, start, range, stop, ret_len;
- struct re_registers *regs;
+static int internal_function
+re_search_stub (struct re_pattern_buffer *bufp, const char *string, int length,
+ int start, int range, int stop, struct re_registers *regs,
+ int ret_len)
{
reg_errcode_t result;
regmatch_t *pmatch;
int nregs, rval;
int eflags = 0;
-#ifndef __UCLIBC__ /* libc_lock_lock does not exist */
+#ifdef __UCLIBC_HAS_THREADS__
re_dfa_t *dfa = (re_dfa_t *) bufp->buffer;
#endif
-
/* Check for out-of-range. */
if (BE (start < 0 || start > length, 0))
return -1;
@@ -502,11 +441,9 @@ re_search_stub (bufp, string, length, start, range, stop, regs, ret_len)
return rval;
}
-static unsigned
-re_copy_regs (regs, pmatch, nregs, regs_allocated)
- struct re_registers *regs;
- regmatch_t *pmatch;
- int nregs, regs_allocated;
+static unsigned internal_function
+re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, int nregs,
+ int regs_allocated)
{
int rval = REGS_REALLOCATE;
int i;
@@ -572,11 +509,8 @@ re_copy_regs (regs, pmatch, nregs, regs_allocated)
freeing the old data. */
void
-re_set_registers (bufp, regs, num_regs, starts, ends)
- struct re_pattern_buffer *bufp;
- struct re_registers *regs;
- unsigned num_regs;
- regoff_t *starts, *ends;
+re_set_registers (struct re_pattern_buffer *bufp, struct re_registers *regs,
+ unsigned num_regs, regoff_t *starts, regoff_t *ends)
{
if (num_regs)
{
@@ -592,24 +526,18 @@ re_set_registers (bufp, regs, num_regs, starts, ends)
regs->start = regs->end = (regoff_t *) 0;
}
}
-#if defined _LIBC || defined __UCLIBC__
-strong_alias(__re_set_registers, re_set_registers)
-#endif
/* Entry points compatible with 4.2 BSD regex library. We don't define
them unless specifically requested. */
-#if defined _REGEX_RE_COMP || defined _LIBC || defined __UCLIBC__
+#if defined _REGEX_RE_COMP || defined __UCLIBC__
int
-# if defined _LIBC || defined __UCLIBC__
weak_function
-# endif
-re_exec (s)
- const char *s;
+re_exec (const char *s)
{
- return 0 == regexec (&re_comp_buf, s, 0, NULL, 0);
+ return 0 == regexec (re_comp_buf, s, 0, NULL, 0);
}
-#endif /* _REGEX_RE_COMP */
+#endif
/* Internal entry point. */
@@ -621,15 +549,10 @@ re_exec (s)
otherwise return the error code.
Note: We assume front end functions already check ranges.
(START + RANGE >= 0 && START + RANGE <= LENGTH) */
-
-static reg_errcode_t
-re_search_internal (preg, string, length, start, range, stop, nmatch, pmatch,
- eflags)
- const regex_t *preg;
- const char *string;
- int length, start, range, stop, eflags;
- size_t nmatch;
- regmatch_t pmatch[];
+static reg_errcode_t internal_function
+re_search_internal (const regex_t *preg, const char *string, int length,
+ int start, int range, int stop, size_t nmatch,
+ regmatch_t pmatch[], int eflags)
{
reg_errcode_t err;
const re_dfa_t *dfa = (const re_dfa_t *) preg->buffer;
@@ -637,19 +560,13 @@ re_search_internal (preg, string, length, start, range, stop, nmatch, pmatch,
int fl_longest_match, match_first, match_kind, match_last = -1;
int extra_nmatch;
int sb, ch;
-#if defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
- re_match_context_t mctx = { .dfa = dfa };
-#else
re_match_context_t mctx;
-#endif
char *fastmap = (preg->fastmap != NULL && preg->fastmap_accurate
&& range && !preg->can_be_null) ? preg->fastmap : NULL;
- RE_TRANSLATE_TYPE t = preg->translate;
+ __RE_TRANSLATE_TYPE t = preg->translate;
-#if !(defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
memset (&mctx, '\0', sizeof (re_match_context_t));
mctx.dfa = dfa;
-#endif
extra_nmatch = (nmatch > preg->re_nsub) ? nmatch - (preg->re_nsub + 1) : 0;
nmatch -= extra_nmatch;
@@ -941,9 +858,8 @@ re_search_internal (preg, string, length, start, range, stop, nmatch, pmatch,
return err;
}
-static reg_errcode_t
-prune_impossible_nodes (mctx)
- re_match_context_t *mctx;
+static reg_errcode_t internal_function
+prune_impossible_nodes (re_match_context_t *mctx)
{
const re_dfa_t *const dfa = mctx->dfa;
int halt_node, match_last;
@@ -3435,8 +3351,7 @@ out_free:
character, or we are in a single-byte character set so we can
discern by looking at the character code: allocate a
256-entry transition table. */
- trtable = state->trtable =
- (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), SBC_MAX);
+ trtable = state->trtable = calloc (sizeof (re_dfastate_t *), SBC_MAX);
if (BE (trtable == NULL, 0))
goto out_free;
@@ -3466,8 +3381,7 @@ out_free:
by looking at the character code: build two 256-entry
transition tables, one starting at trtable[0] and one
starting at trtable[SBC_MAX]. */
- trtable = state->word_trtable =
- (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), 2 * SBC_MAX);
+ trtable = state->word_trtable = calloc (sizeof (re_dfastate_t *), 2 * SBC_MAX);
if (BE (trtable == NULL, 0))
goto out_free;
@@ -3797,12 +3711,12 @@ check_node_accept_bytes (const re_dfa_t *dfa, int node_idx,
if (node->type == COMPLEX_BRACKET)
{
const re_charset_t *cset = node->opr.mbcset;
-# ifdef _LIBC
+# if 0
const unsigned char *pin
= ((const unsigned char *) re_string_get_buffer (input) + str_idx);
int j;
uint32_t nrules;
-# endif /* _LIBC */
+# endif
int match_len = 0;
wchar_t wc = ((cset->nranges || cset->nchar_classes || cset->nmbchars)
? re_string_wchar_at (input, str_idx) : 0);
@@ -3825,7 +3739,7 @@ check_node_accept_bytes (const re_dfa_t *dfa, int node_idx,
}
}
-# ifdef _LIBC
+# if 0
nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
if (nrules != 0)
{
@@ -3914,15 +3828,13 @@ check_node_accept_bytes (const re_dfa_t *dfa, int node_idx,
}
}
else
-# endif /* _LIBC */
+# endif
{
/* match with range expression? */
-#if __GNUC__ >= 2
- wchar_t cmp_buf[] = {L'\0', L'\0', wc, L'\0', L'\0', L'\0'};
-#else
- wchar_t cmp_buf[] = {L'\0', L'\0', L'\0', L'\0', L'\0', L'\0'};
+ wchar_t cmp_buf[6];
+
+ memset (cmp_buf, 0, sizeof(cmp_buf));
cmp_buf[2] = wc;
-#endif
for (i = 0; i < cset->nranges; ++i)
{
cmp_buf[0] = cset->range_starts[i];
@@ -3935,21 +3847,18 @@ check_node_accept_bytes (const re_dfa_t *dfa, int node_idx,
}
}
}
- check_node_accept_bytes_match:
+
+ check_node_accept_bytes_match:
if (!cset->non_match)
return match_len;
- else
- {
- if (match_len > 0)
- return 0;
- else
- return (elem_len > char_len) ? elem_len : char_len;
- }
+ if (match_len > 0)
+ return 0;
+ return (elem_len > char_len) ? elem_len : char_len;
}
return 0;
}
-# ifdef _LIBC
+# if 0
static unsigned int
internal_function
find_collation_sequence_value (const unsigned char *mbs, size_t mbs_len)
@@ -4007,7 +3916,7 @@ find_collation_sequence_value (const unsigned char *mbs, size_t mbs_len)
return UINT_MAX;
}
}
-# endif /* _LIBC */
+# endif
#endif /* RE_ENABLE_I18N */
/* Check whether the node accepts the byte which is IDX-th
diff --git a/libc/misc/search/Makefile.in b/libc/misc/search/Makefile.in
index 2da1d6e01..d13766148 100644
--- a/libc/misc/search/Makefile.in
+++ b/libc/misc/search/Makefile.in
@@ -1,33 +1,35 @@
# 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.
#
-CSRC := hsearch.c
+subdirs += libc/misc/search
+
+CSRC-y := hsearch.c
# multi source _tsearch.c
-CSRC += tsearch.c tfind.c tdelete.c twalk.c tdestroy.c
+CSRC-y += tsearch.c tfind.c tdelete.c twalk.c tdestroy.c
# multi source _lsearch.c
-CSRC += lfind.c lsearch.c
+CSRC-y += lfind.c lsearch.c
# multi source insremque.c
-CSRC += insque.c remque.c
+CSRC-y += insque.c remque.c
# multi source _hsearch_r.c
-CSRC += hcreate_r.c hdestroy_r.c hsearch_r.c
+CSRC-y += hcreate_r.c hdestroy_r.c hsearch_r.c
MISC_SEARCH_DIR := $(top_srcdir)libc/misc/search
MISC_SEARCH_OUT := $(top_builddir)libc/misc/search
-MISC_SEARCH_SRC := $(patsubst %.c,$(MISC_SEARCH_DIR)/%.c,$(CSRC))
-MISC_SEARCH_OBJ := $(patsubst %.c,$(MISC_SEARCH_OUT)/%.o,$(CSRC))
+MISC_SEARCH_SRC := $(patsubst %.c,$(MISC_SEARCH_DIR)/%.c,$(CSRC-y))
+MISC_SEARCH_OBJ := $(patsubst %.c,$(MISC_SEARCH_OUT)/%.o,$(CSRC-y))
libc-y += $(MISC_SEARCH_OBJ)
-objclean-y += misc_search_objclean
+objclean-y += CLEAN_libc/misc/search
-misc_search_objclean:
- $(RM) $(MISC_SEARCH_OUT)/*.{o,os}
+CLEAN_libc/misc/search:
+ $(do_rm) $(addprefix $(MISC_SEARCH_OUT)/*., o os)
diff --git a/libc/misc/search/_hsearch_r.c b/libc/misc/search/_hsearch_r.c
index c9c4a9ccf..7b57ce16c 100644
--- a/libc/misc/search/_hsearch_r.c
+++ b/libc/misc/search/_hsearch_r.c
@@ -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; if not, write to the Free
- Software Foundation, Inc., 59 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 <malloc.h>
+#include <stdlib.h>
#include <string.h>
#include <search.h>
@@ -49,12 +48,12 @@ _ENTRY;
static int isprime (unsigned int number)
{
/* no even number will be passed */
- unsigned int div = 3;
+ unsigned int divisor = 3;
- while (div * div < number && number % div != 0)
- div += 2;
+ while (divisor * divisor < number && number % divisor != 0)
+ divisor += 2;
- return number % div != 0;
+ return number % divisor != 0;
}
@@ -64,7 +63,6 @@ static int isprime (unsigned int number)
indexing as explained in the comment for the hsearch function.
The contents of the table is zeroed, especially the field used
becomes zero. */
-libc_hidden_proto(hcreate_r)
int hcreate_r (size_t nel, struct hsearch_data *htab)
{
/* Test for correct arguments. */
@@ -100,7 +98,6 @@ libc_hidden_def(hcreate_r)
#ifdef L_hdestroy_r
/* After using the hash table it has to be destroyed. The used memory can
be freed and the local static variable can be marked as not used. */
-libc_hidden_proto(hdestroy_r)
void hdestroy_r (struct hsearch_data *htab)
{
/* Test for correct arguments. */
@@ -134,10 +131,7 @@ libc_hidden_def(hdestroy_r)
equality of the stored and the parameter value. This helps to prevent
unnecessary expensive calls of strcmp. */
-/* Experimentally off - libc_hidden_proto(strcmp) */
-/* Experimentally off - libc_hidden_proto(strlen) */
-libc_hidden_proto(hsearch_r)
int hsearch_r (ENTRY item, ACTION action, ENTRY **retval,
struct hsearch_data *htab)
{
diff --git a/libc/misc/search/_lsearch.c b/libc/misc/search/_lsearch.c
index e91ea9441..0cf496e26 100644
--- a/libc/misc/search/_lsearch.c
+++ b/libc/misc/search/_lsearch.c
@@ -12,7 +12,6 @@
#include <stdio.h>
#include <search.h>
-libc_hidden_proto(lfind)
#ifdef L_lfind
@@ -22,7 +21,7 @@ void *lfind(const void *key, const void *base, size_t *nmemb,
register int n = *nmemb;
while (n--) {
- if ((*compar) (base, key) == 0)
+ if ((*compar) (key, base) == 0)
return ((void*)base);
base += size;
}
@@ -34,7 +33,6 @@ libc_hidden_def(lfind)
#ifdef L_lsearch
-/* Experimentally off - libc_hidden_proto(memcpy) */
void *lsearch(const void *key, void *base, size_t *nmemb,
size_t size, int (*compar)(const void *, const void *))
diff --git a/libc/misc/search/_tsearch.c b/libc/misc/search/_tsearch.c
index 3d43aa543..fe9eedfa9 100644
--- a/libc/misc/search/_tsearch.c
+++ b/libc/misc/search/_tsearch.c
@@ -13,8 +13,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/>. */
/*
* Tree search generalized from Knuth (6.2.2) Algorithm T just like
@@ -50,8 +49,7 @@ register node **rootp; address of tree root
int (*compar)(); ordering function
*/
-libc_hidden_proto(tsearch)
-void *tsearch(__const void *key, void **vrootp, __compar_fn_t compar)
+void *tsearch(const void *key, void **vrootp, __compar_fn_t compar)
{
register node *q;
register node **rootp = (node **) vrootp;
@@ -81,8 +79,7 @@ libc_hidden_def(tsearch)
#endif
#ifdef L_tfind
-libc_hidden_proto(tfind)
-void *tfind(__const void *key, void * __const *vrootp, __compar_fn_t compar)
+void *tfind(const void *key, void * const *vrootp, __compar_fn_t compar)
{
register node **rootp = (node **) vrootp;
@@ -109,7 +106,7 @@ char *key; key to be deleted
register node **rootp; address of the root of tree
int (*compar)(); comparison function
*/
-void *tdelete(__const void *key, void ** vrootp, __compar_fn_t compar)
+void *tdelete(const void *key, void ** vrootp, __compar_fn_t compar)
{
node *p;
register node *q;
@@ -159,7 +156,7 @@ register node *root; Root of the tree to be walked
register void (*action)(); Function to be called at each node
register int level;
*/
-static void trecurse(__const void *vroot, __action_fn_t action, int level)
+static void trecurse(const void *vroot, __action_fn_t action, int level)
{
register node *root = (node *) vroot;
@@ -182,9 +179,9 @@ node *root; Root of the tree to be walked
void (*action)(); Function to be called at each node
PTR
*/
-void twalk(__const void *vroot, __action_fn_t action)
+void twalk(const void *vroot, __action_fn_t action)
{
- register __const node *root = (node *) vroot;
+ register const node *root = (node *) vroot;
if (root != (node *)0 && action != (__action_fn_t) 0)
trecurse(root, action, 0);
@@ -208,7 +205,6 @@ tdestroy_recurse (node *root, __free_fn_t freefct)
free (root);
}
-libc_hidden_proto(tdestroy)
void tdestroy (void *vroot, __free_fn_t freefct)
{
node *root = (node *) vroot;
diff --git a/libc/misc/search/hsearch.c b/libc/misc/search/hsearch.c
index b1228e2ee..54acfc484 100644
--- a/libc/misc/search/hsearch.c
+++ b/libc/misc/search/hsearch.c
@@ -13,15 +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/>. */
#include <search.h>
-libc_hidden_proto(hdestroy_r)
-libc_hidden_proto(hsearch_r)
-libc_hidden_proto(hcreate_r)
/* The non-reentrant version use a global space for storing the table. */
static struct hsearch_data htab;
diff --git a/libc/misc/search/insremque.c b/libc/misc/search/insremque.c
index 32edf7a4e..99399427e 100644
--- a/libc/misc/search/insremque.c
+++ b/libc/misc/search/insremque.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/>. */
#include <features.h>
#include <stddef.h>
@@ -27,12 +26,20 @@
void
insque (void *elem, void *prev)
{
- struct qelem *next = ((struct qelem *) prev)->q_forw;
- ((struct qelem *) prev)->q_forw = (struct qelem *) elem;
- if (next != NULL)
- next->q_back = (struct qelem *) elem;
- ((struct qelem *) elem)->q_forw = next;
- ((struct qelem *) elem)->q_back = (struct qelem *) prev;
+ if (prev == NULL)
+ {
+ ((struct qelem *) elem)->q_forw = NULL;
+ ((struct qelem *) elem)->q_back = NULL;
+ }
+ else
+ {
+ struct qelem *next = ((struct qelem *) prev)->q_forw;
+ ((struct qelem *) prev)->q_forw = (struct qelem *) elem;
+ if (next != NULL)
+ next->q_back = (struct qelem *) elem;
+ ((struct qelem *) elem)->q_forw = next;
+ ((struct qelem *) elem)->q_back = (struct qelem *) prev;
+ }
}
#endif
diff --git a/libc/misc/statfs/Makefile.in b/libc/misc/statfs/Makefile.in
index b0a8b84c9..d70ab8f6e 100644
--- a/libc/misc/statfs/Makefile.in
+++ b/libc/misc/statfs/Makefile.in
@@ -1,29 +1,28 @@
# 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.
#
-CSRC := statvfs.c fstatvfs.c
-ifeq ($(UCLIBC_HAS_LFS),y)
-ifeq ($(UCLIBC_LINUX_SPECIFIC),y)
-CSRC += fstatfs64.c statfs64.c
-endif
-CSRC += statvfs64.c fstatvfs64.c
-endif
+subdirs += libc/misc/statfs
+
+CSRC-y := statvfs.c fstatvfs.c
+CSRC-$(UCLIBC_HAS_LFS) += $(patsubst %.c,%64.c,$(CSRC-y))
+CSRC-$(if $(findstring yy,$(UCLIBC_HAS_LFS)$(UCLIBC_LINUX_SPECIFIC)),y) += \
+ fstatfs64.c statfs64.c
MISC_STATFS_DIR := $(top_srcdir)libc/misc/statfs
MISC_STATFS_OUT := $(top_builddir)libc/misc/statfs
-MISC_STATFS_SRC := $(patsubst %.c,$(MISC_STATFS_DIR)/%.c,$(CSRC))
-MISC_STATFS_OBJ := $(patsubst %.c,$(MISC_STATFS_OUT)/%.o,$(CSRC))
+MISC_STATFS_SRC := $(patsubst %.c,$(MISC_STATFS_DIR)/%.c,$(CSRC-y))
+MISC_STATFS_OBJ := $(patsubst %.c,$(MISC_STATFS_OUT)/%.o,$(CSRC-y))
libc-y += $(MISC_STATFS_OBJ)
libc-nomulti-$(UCLIBC_HAS_LFS) += $(MISC_STATFS_OUT)/statvfs64.o $(MISC_STATFS_OUT)/fstatvfs64.o
-objclean-y += misc_statfs_objclean
+objclean-y += CLEAN_libc/misc/statfs
-misc_statfs_objclean:
- $(RM) $(MISC_STATFS_OUT)/*.{o,os,oS}
+CLEAN_libc/misc/statfs:
+ $(do_rm) $(addprefix $(MISC_STATFS_OUT)/*., o os oS)
diff --git a/libc/misc/statfs/fstatfs64.c b/libc/misc/statfs/fstatfs64.c
index a7f94b125..7221a0b79 100644
--- a/libc/misc/statfs/fstatfs64.c
+++ b/libc/misc/statfs/fstatfs64.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 <_lfs_64.h>
@@ -23,18 +22,18 @@
#include <string.h>
#include <sys/statfs.h>
#include <sys/statvfs.h>
+#include <sys/syscall.h>
#include <stddef.h>
-/* Experimentally off - libc_hidden_proto(memcpy) */
-libc_hidden_proto(fstatfs)
+#if defined __NR_fstatfs
+extern __typeof(fstatfs) __libc_fstatfs;
/* Return information about the filesystem on which FD resides. */
-libc_hidden_proto(fstatfs64)
int fstatfs64 (int fd, struct statfs64 *buf)
{
struct statfs buf32;
- if (fstatfs (fd, &buf32) < 0)
+ if (__libc_fstatfs (fd, &buf32) < 0)
return -1;
buf->f_type = buf32.f_type;
@@ -45,9 +44,24 @@ int fstatfs64 (int fd, struct statfs64 *buf)
buf->f_files = buf32.f_files;
buf->f_ffree = buf32.f_ffree;
buf->f_fsid = buf32.f_fsid;
+# ifdef _STATFS_F_FRSIZE
+ buf->f_frsize = buf32.f_frsize;
+# endif
buf->f_namelen = buf32.f_namelen;
memcpy (buf->f_spare, buf32.f_spare, sizeof (buf32.f_spare));
return 0;
}
+#else
+/*
+ * Use the fstatfs64 system call if fstatfs is not defined
+ * This is for backwards compatibility and it should be
+ * made default in the future
+ */
+int fstatfs64(int fd, struct statfs64 *buf)
+{
+ /* Signature has 2 arguments but syscalls wants 3 */
+ return INLINE_SYSCALL(fstatfs64, 3, fd, sizeof(*buf), buf);
+}
+#endif
libc_hidden_def(fstatfs64)
diff --git a/libc/misc/statfs/fstatvfs.c b/libc/misc/statfs/fstatvfs.c
index e21235e01..ff047524f 100644
--- a/libc/misc/statfs/fstatvfs.c
+++ b/libc/misc/statfs/fstatvfs.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 <errno.h>
@@ -27,12 +26,6 @@
#include <sys/statfs.h>
#include <sys/statvfs.h>
-/* Experimentally off - libc_hidden_proto(memset) */
-/* Experimentally off - libc_hidden_proto(strcmp) */
-/* Experimentally off - libc_hidden_proto(strsep) */
-libc_hidden_proto(setmntent)
-libc_hidden_proto(getmntent_r)
-libc_hidden_proto(endmntent)
#ifndef __USE_FILE_OFFSET64
extern int fstatfs (int __fildes, struct statfs *__buf)
@@ -47,9 +40,6 @@ extern int __REDIRECT_NTH (fstatfs, (int __fildes, struct statfs *__buf),
#endif
extern __typeof(fstatfs) __libc_fstatfs;
-libc_hidden_proto(__libc_fstatfs)
-libc_hidden_proto(fstat)
-libc_hidden_proto(stat)
int fstatvfs (int fd, struct statvfs *buf)
{
@@ -66,3 +56,4 @@ int fstatvfs (int fd, struct statvfs *buf)
/* We signal success if the statfs call succeeded. */
return 0;
}
+libc_hidden_def(fstatvfs)
diff --git a/libc/misc/statfs/fstatvfs64.c b/libc/misc/statfs/fstatvfs64.c
index 2d44e4217..e465d76c3 100644
--- a/libc/misc/statfs/fstatvfs64.c
+++ b/libc/misc/statfs/fstatvfs64.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 <_lfs_64.h>
@@ -29,20 +28,8 @@
#include <sys/statvfs.h>
-/* Experimentally off - libc_hidden_proto(memset) */
-/* Experimentally off - libc_hidden_proto(strcmp) */
-/* Experimentally off - libc_hidden_proto(strsep) */
-libc_hidden_proto(setmntent)
-libc_hidden_proto(getmntent_r)
-libc_hidden_proto(endmntent)
-
#undef stat
#define stat stat64
-#if defined __UCLIBC_LINUX_SPECIFIC__
-libc_hidden_proto(fstatfs64)
-libc_hidden_proto(fstat64)
-#endif
-libc_hidden_proto(stat64)
int fstatvfs64 (int fd, struct statvfs64 *buf)
{
diff --git a/libc/misc/statfs/internal_statvfs.c b/libc/misc/statfs/internal_statvfs.c
index 6075e9cf4..a715d2f58 100644
--- a/libc/misc/statfs/internal_statvfs.c
+++ b/libc/misc/statfs/internal_statvfs.c
@@ -13,14 +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/>. */
+
+/* The kernel hints us if the f_flags is valid */
+#define ST_VALID 0x0020
/* Now fill in the fields we have information for. */
buf->f_bsize = fsbuf.f_bsize;
- /* Linux does not support f_frsize, so set it to the full block size. */
+#ifdef _STATFS_F_FRSIZE
+ buf->f_frsize = fsbuf.f_frsize;
+#else
+ /* No support for f_frsize so set it to the full block size. */
buf->f_frsize = fsbuf.f_bsize;
+#endif
buf->f_blocks = fsbuf.f_blocks;
buf->f_bfree = fsbuf.f_bfree;
buf->f_bavail = fsbuf.f_bavail;
@@ -28,7 +34,7 @@
buf->f_ffree = fsbuf.f_ffree;
if (sizeof (buf->f_fsid) == sizeof (fsbuf.f_fsid))
buf->f_fsid = (fsbuf.f_fsid.__val[0]
- | ((unsigned long int) fsbuf.f_fsid.__val[1]
+ | ((unsigned long long int) fsbuf.f_fsid.__val[1]
<< (8 * (sizeof (buf->f_fsid)
- sizeof (fsbuf.f_fsid.__val[0])))));
else
@@ -39,10 +45,7 @@
buf->__f_unused = 0;
#endif
buf->f_namemax = fsbuf.f_namelen;
- memset (buf->__f_spare, '\0', 6 * sizeof (int));
-
- /* What remains to do is to fill the fields f_favail and f_flag. */
-
+ memset (buf->__f_spare, '\0', sizeof(buf->__f_spare));
/* XXX I have no idea how to compute f_favail. Any idea??? */
buf->f_favail = buf->f_ffree;
@@ -51,61 +54,63 @@
file. The way we can test for matching filesystem is using the
device number. */
buf->f_flag = 0;
- if (STAT (&st) >= 0)
- {
- int save_errno = errno;
- struct mntent mntbuf;
- FILE *mtab;
-
- mtab = setmntent ("/proc/mounts", "r");
- if (mtab == NULL)
- mtab = setmntent (_PATH_MOUNTED, "r");
+ if (STAT (&st) >= 0
+#ifdef _STATFS_F_FLAGS
+ && (fsbuf.f_flags & ST_VALID) == 0
+#endif
+ ) {
+ int save_errno = errno;
+ struct mntent mntbuf;
+ FILE *mtab;
- if (mtab != NULL)
- {
- char tmpbuf[1024];
+ mtab = setmntent ("/proc/mounts", "r");
+ if (mtab == NULL)
+ mtab = setmntent (_PATH_MOUNTED, "r");
+ if (mtab != NULL) {
+ char tmpbuf[1024];
- while (getmntent_r (mtab, &mntbuf, tmpbuf, sizeof (tmpbuf)))
- {
- struct stat fsst;
+ while (getmntent_r (mtab, &mntbuf, tmpbuf, sizeof (tmpbuf))) {
+ struct stat fsst;
- /* Find out about the device the current entry is for. */
- if (stat (mntbuf.mnt_dir, &fsst) >= 0
- && st.st_dev == fsst.st_dev)
- {
- /* Bingo, we found the entry for the device FD is on.
- Now interpret the option string. */
- char *cp = mntbuf.mnt_opts;
- char *opt;
+ /* Find out about the device the current entry is for. */
+ if (stat (mntbuf.mnt_dir, &fsst) >= 0
+ && st.st_dev == fsst.st_dev) {
+ /* Bingo, we found the entry for the device FD is on.
+ Now interpret the option string. */
+ char *cp = mntbuf.mnt_opts;
+ char *opt;
- while ((opt = strsep (&cp, ",")) != NULL)
- if (strcmp (opt, "ro") == 0)
- buf->f_flag |= ST_RDONLY;
- else if (strcmp (opt, "nosuid") == 0)
- buf->f_flag |= ST_NOSUID;
+ while ((opt = strsep (&cp, ",")) != NULL)
+ if (strcmp (opt, "ro") == 0)
+ buf->f_flag |= ST_RDONLY;
+ else if (strcmp (opt, "nosuid") == 0)
+ buf->f_flag |= ST_NOSUID;
#ifdef __USE_GNU
- else if (strcmp (opt, "noexec") == 0)
- buf->f_flag |= ST_NOEXEC;
- else if (strcmp (opt, "nodev") == 0)
- buf->f_flag |= ST_NODEV;
- else if (strcmp (opt, "sync") == 0)
- buf->f_flag |= ST_SYNCHRONOUS;
- else if (strcmp (opt, "mand") == 0)
- buf->f_flag |= ST_MANDLOCK;
- else if (strcmp (opt, "noatime") == 0)
- buf->f_flag |= ST_NOATIME;
- else if (strcmp (opt, "nodiratime") == 0)
- buf->f_flag |= ST_NODIRATIME;
+ else if (strcmp (opt, "noexec") == 0)
+ buf->f_flag |= ST_NOEXEC;
+ else if (strcmp (opt, "nodev") == 0)
+ buf->f_flag |= ST_NODEV;
+ else if (strcmp (opt, "sync") == 0)
+ buf->f_flag |= ST_SYNCHRONOUS;
+ else if (strcmp (opt, "mand") == 0)
+ buf->f_flag |= ST_MANDLOCK;
+ else if (strcmp (opt, "noatime") == 0)
+ buf->f_flag |= ST_NOATIME;
+ else if (strcmp (opt, "nodiratime") == 0)
+ buf->f_flag |= ST_NODIRATIME;
+ else if (strcmp (opt, "relatime") == 0)
+ buf->f_flag |= ST_RELATIME;
#endif
-
- /* We can stop looking for more entries. */
- break;
+ /* We can stop looking for more entries. */
+ break;
+ }
}
- }
-
- /* Close the file. */
- endmntent (mtab);
- }
-
- __set_errno (save_errno);
- }
+ /* Close the file. */
+ endmntent (mtab);
+ }
+ __set_errno (save_errno);
+ }
+#ifdef _STATFS_F_FLAGS
+ else
+ buf->f_flag = fsbuf.f_flags ^ ST_VALID;
+#endif
diff --git a/libc/misc/statfs/statfs64.c b/libc/misc/statfs/statfs64.c
index 18ce33be8..b1a33b790 100644
--- a/libc/misc/statfs/statfs64.c
+++ b/libc/misc/statfs/statfs64.c
@@ -13,27 +13,25 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 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 <string.h>
#include <stddef.h>
#include <sys/statfs.h>
+#include <sys/syscall.h>
+extern __typeof(statfs) __libc_statfs;
-/* Experimentally off - libc_hidden_proto(memcpy) */
-libc_hidden_proto(statfs)
-
+#if defined __NR_statfs
/* Return information about the filesystem on which FILE resides. */
-libc_hidden_proto(statfs64)
int statfs64 (const char *file, struct statfs64 *buf)
{
struct statfs buf32;
- if (statfs (file, &buf32) < 0)
+ if (__libc_statfs (file, &buf32) < 0)
return -1;
buf->f_type = buf32.f_type;
@@ -45,8 +43,21 @@ int statfs64 (const char *file, struct statfs64 *buf)
buf->f_ffree = buf32.f_ffree;
buf->f_fsid = buf32.f_fsid;
buf->f_namelen = buf32.f_namelen;
+#ifdef _STATFS_F_FRSIZE
+ buf->f_frsize = buf32.f_frsize;
+#endif
+#ifdef _STATFS_F_FLAGS
+ buf->f_flags = buf32.f_flags;
+#endif
memcpy (buf->f_spare, buf32.f_spare, sizeof (buf32.f_spare));
return 0;
}
+#else
+int statfs64 (const char *file, struct statfs64 *buf)
+{
+ return INLINE_SYSCALL(statfs64, 3, file, sizeof(*buf), buf);
+}
+#endif
+
libc_hidden_def(statfs64)
diff --git a/libc/misc/statfs/statvfs.c b/libc/misc/statfs/statvfs.c
index 0feb8731d..dcd10f7af 100644
--- a/libc/misc/statfs/statvfs.c
+++ b/libc/misc/statfs/statvfs.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 <errno.h>
@@ -27,16 +26,8 @@
#include <sys/statfs.h>
#include <sys/statvfs.h>
-/* Experimentally off - libc_hidden_proto(memset) */
-/* Experimentally off - libc_hidden_proto(strcmp) */
-/* Experimentally off - libc_hidden_proto(strsep) */
-libc_hidden_proto(setmntent)
-libc_hidden_proto(getmntent_r)
-libc_hidden_proto(endmntent)
extern __typeof(statfs) __libc_statfs;
-libc_hidden_proto(__libc_statfs)
-libc_hidden_proto(stat)
int statvfs (const char *file, struct statvfs *buf)
{
@@ -53,3 +44,4 @@ int statvfs (const char *file, struct statvfs *buf)
/* We signal success if the statfs call succeeded. */
return 0;
}
+libc_hidden_def(statvfs)
diff --git a/libc/misc/statfs/statvfs64.c b/libc/misc/statfs/statvfs64.c
index 008ba78c9..b02fc6bbe 100644
--- a/libc/misc/statfs/statvfs64.c
+++ b/libc/misc/statfs/statvfs64.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 <_lfs_64.h>
@@ -28,21 +27,9 @@
#include <sys/statfs.h>
#include <sys/statvfs.h>
-/* Experimentally off - libc_hidden_proto(memset) */
-/* Experimentally off - libc_hidden_proto(strcmp) */
-/* Experimentally off - libc_hidden_proto(strsep) */
-libc_hidden_proto(setmntent)
-libc_hidden_proto(getmntent_r)
-libc_hidden_proto(endmntent)
#undef stat
#define stat stat64
-#if defined __UCLIBC_LINUX_SPECIFIC__
-libc_hidden_proto(statfs64)
-#else
-libc_hidden_proto(statvfs)
-#endif
-libc_hidden_proto(stat64)
int statvfs64 (const char *file, struct statvfs64 *buf)
{
diff --git a/libc/misc/syslog/Makefile.in b/libc/misc/syslog/Makefile.in
index 8355ac0cd..2d00a33fd 100644
--- a/libc/misc/syslog/Makefile.in
+++ b/libc/misc/syslog/Makefile.in
@@ -1,23 +1,25 @@
# 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.
#
-CSRC := syslog.c
+subdirs += libc/misc/syslog
+
+CSRC-y := syslog.c
MISC_SYSLOG_DIR := $(top_srcdir)libc/misc/syslog
MISC_SYSLOG_OUT := $(top_builddir)libc/misc/syslog
-MISC_SYSLOG_SRC := $(patsubst %.c,$(MISC_SYSLOG_DIR)/%.c,$(CSRC))
-MISC_SYSLOG_OBJ := $(patsubst %.c,$(MISC_SYSLOG_OUT)/%.o,$(CSRC))
+MISC_SYSLOG_SRC := $(patsubst %.c,$(MISC_SYSLOG_DIR)/%.c,$(CSRC-y))
+MISC_SYSLOG_OBJ := $(patsubst %.c,$(MISC_SYSLOG_OUT)/%.o,$(CSRC-y))
ifeq ($(UCLIBC_HAS_SYSLOG),y)
libc-y += $(MISC_SYSLOG_OBJ)
endif
-objclean-y += misc_syslog_objclean
+objclean-y += CLEAN_libc/misc/syslog
-misc_syslog_objclean:
- $(RM) $(MISC_SYSLOG_OUT)/*.{o,os}
+CLEAN_libc/misc/syslog:
+ $(do_rm) $(addprefix $(MISC_SYSLOG_OUT)/*., o os)
diff --git a/libc/misc/syslog/syslog.c b/libc/misc/syslog/syslog.c
index c90703ab8..1df0d1ae3 100644
--- a/libc/misc/syslog/syslog.c
+++ b/libc/misc/syslog/syslog.c
@@ -58,8 +58,6 @@
* - Major code cleanup.
*/
-#define __FORCE_GLIBC
-#include <features.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/file.h>
@@ -79,46 +77,26 @@
#include <ctype.h>
#include <signal.h>
-libc_hidden_proto(openlog)
-libc_hidden_proto(syslog)
-libc_hidden_proto(vsyslog)
-libc_hidden_proto(closelog)
-
-/* Experimentally off - libc_hidden_proto(memset) */
-/* Experimentally off - libc_hidden_proto(memcpy) */
-/* Experimentally off - libc_hidden_proto(memmove) */
-/* Experimentally off - libc_hidden_proto(strchr) */
-/* Experimentally off - libc_hidden_proto(strlen) */
-/* Experimentally off - libc_hidden_proto(strncpy) */
-libc_hidden_proto(open)
-libc_hidden_proto(fcntl)
-libc_hidden_proto(socket)
-libc_hidden_proto(close)
-libc_hidden_proto(write)
-libc_hidden_proto(getpid)
-libc_hidden_proto(ctime)
-libc_hidden_proto(sigaction)
-libc_hidden_proto(sigemptyset)
-libc_hidden_proto(connect)
-libc_hidden_proto(sprintf)
-libc_hidden_proto(vsnprintf)
-/* Experimentally off - libc_hidden_proto(time) */
#include <bits/uClibc_mutex.h>
-__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP);
+__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER);
+
+/* !glibc_compat: glibc uses argv[0] by default
+ * (default: if there was no openlog or if openlog passed NULL),
+ * not string "syslog"
+ */
+static const char *LogTag = "syslog"; /* string to tag the entry with */
static int LogFile = -1; /* fd for log */
static smalluint connected; /* have done connect */
-/* all bits in option argument for openlog() fit in 8 bits */
-static smalluint LogStat = 0; /* status bits, set by openlog() */
-static const char *LogTag = "syslog"; /* string to tag the entry with */
-/* this fits in 8 bits too (LOG_LOCAL7 = 23<<3 = 184),
- * but NB: LOG_FACMASK is bigger (= 0x03f8 = 127<<3) for some strange reason.
- * Oh well. */
-static int LogFacility = LOG_USER;/* default facility code */
-/* bits mask of priorities (eight prios - 8 bits is enough) */
-static smalluint LogMask = 0xff; /* mask of priorities to be logged */
+/* all bits in option argument for openlog fit in 8 bits */
+static smalluint LogStat = 0; /* status bits, set by openlog */
+/* default facility code if openlog is not called */
+/* (this fits in 8 bits even without >> 3 shift, but playing extra safe) */
+static smalluint LogFacility = LOG_USER >> 3;
+/* bits mask of priorities to be logged (eight prios - 8 bits is enough) */
+static smalluint LogMask = 0xff;
/* AF_UNIX address of local logger (we use struct sockaddr
* instead of struct sockaddr_un since "/dev/log" is small enough) */
static const struct sockaddr SyslogAddr = {
@@ -138,45 +116,42 @@ closelog_intern(int sig)
if (sig == 0) { /* called from closelog()? - reset to defaults */
LogStat = 0;
LogTag = "syslog";
- LogFacility = LOG_USER;
+ LogFacility = LOG_USER >> 3;
LogMask = 0xff;
}
}
-/*
- * OPENLOG -- open system log
- */
-void
-openlog(const char *ident, int logstat, int logfac)
+static void
+openlog_intern(void)
{
+ int fd;
int logType = SOCK_DGRAM;
-
- __UCLIBC_MUTEX_LOCK(mylock);
-
- if (ident != NULL)
- LogTag = ident;
- LogStat = logstat;
- if (logfac != 0 && (logfac &~ LOG_FACMASK) == 0)
- LogFacility = logfac;
- if (LogFile == -1) {
-retry:
- if (LogStat & LOG_NDELAY) {
- if ((LogFile = socket(AF_UNIX, logType, 0)) == -1) {
- goto DONE;
+ static const struct timeval tv = { 1, 0 };
+
+ fd = LogFile;
+ if (fd == -1) {
+ retry:
+ if (1) { /* if statement left in to make .diff cleaner */
+ LogFile = fd = socket(AF_UNIX, logType, 0);
+ if (fd == -1) {
+ return;
}
- fcntl(LogFile, F_SETFD, 1); /* 1 == FD_CLOEXEC */
+ fcntl(fd, F_SETFD, FD_CLOEXEC);
/* We don't want to block if e.g. syslogd is SIGSTOPed */
- fcntl(LogFile, F_SETFL, O_NONBLOCK | fcntl(LogFile, F_GETFL));
+ fcntl(fd, F_SETFL, O_NONBLOCK | fcntl(fd, F_GETFL));
}
}
- if (LogFile != -1 && !connected) {
- if (connect(LogFile, &SyslogAddr, sizeof(SyslogAddr)) != -1) {
+ if (fd != -1 && !connected) {
+ if (connect(fd, &SyslogAddr, sizeof(SyslogAddr)) != -1) {
+ /* We want to block send if e.g. syslogd is SIGSTOPed */
+ fcntl(fd, F_SETFL, ~O_NONBLOCK & fcntl(fd, F_GETFL));
+ setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv));
connected = 1;
} else {
- if (LogFile != -1) {
- close(LogFile);
- LogFile = -1;
+ if (fd != -1) {
+ close(fd);
+ LogFile = fd = -1;
}
if (logType == SOCK_DGRAM) {
logType = SOCK_STREAM;
@@ -184,18 +159,40 @@ retry:
}
}
}
+}
+
+/*
+ * OPENLOG -- open system log
+ */
+void
+openlog(const char *ident, int logstat, int logfac)
+{
+ __UCLIBC_MUTEX_LOCK(mylock);
+
+ if (ident != NULL)
+ LogTag = ident;
+ LogStat = logstat;
+ /* (we were checking also for logfac != 0, but it breaks
+ * openlog(xx, LOG_KERN) since LOG_KERN == 0) */
+ if ((logfac & ~LOG_FACMASK) == 0) /* if we don't have invalid bits */
+ LogFacility = (unsigned)logfac >> 3;
+
+ if (logstat & LOG_NDELAY)
+ openlog_intern();
-DONE:
__UCLIBC_MUTEX_UNLOCK(mylock);
}
-libc_hidden_def(openlog)
/*
* syslog, vsyslog --
* print message on log file; output is intended for syslogd(8).
*/
+static
+#ifndef __USE_BSD
+__always_inline
+#endif
void
-vsyslog(int pri, const char *fmt, va_list ap)
+__vsyslog(int pri, const char *fmt, va_list ap)
{
register char *p;
char *last_chr, *head_end, *end, *stdp;
@@ -203,29 +200,24 @@ vsyslog(int pri, const char *fmt, va_list ap)
int fd, saved_errno;
int rc;
char tbuf[1024]; /* syslogd is unable to handle longer messages */
- struct sigaction action, oldaction;
- memset(&action, 0, sizeof(action));
- action.sa_handler = closelog_intern;
- sigemptyset(&action.sa_mask); /* TODO: memset already zeroed it out! */
- /* Only two errors are possible for sigaction:
- * EFAULT (bad address of &oldaction) and EINVAL (invalid signo)
- * none of which can happen here. */
- /*int sigpipe =*/ sigaction(SIGPIPE, &action, &oldaction);
+ /* Just throw out this message if pri has bad bits. */
+ if ((pri & ~(LOG_PRIMASK|LOG_FACMASK)) != 0)
+ return;
saved_errno = errno;
__UCLIBC_MUTEX_LOCK(mylock);
- /* See if we should just throw out this message. */
- if (!(LogMask & LOG_MASK(LOG_PRI(pri))) || (pri &~ (LOG_PRIMASK|LOG_FACMASK)))
+ /* See if we should just throw out this message according to LogMask. */
+ if ((LogMask & LOG_MASK(LOG_PRI(pri))) == 0)
goto getout;
if (LogFile < 0 || !connected)
- openlog(LogTag, LogStat | LOG_NDELAY, 0);
+ openlog_intern();
/* Set default facility if none specified. */
if ((pri & LOG_FACMASK) == 0)
- pri |= LogFacility;
+ pri |= ((int)LogFacility << 3);
/* Build the message. We know the starting part of the message can take
* no longer than 64 characters plus length of the LogTag. So it's
@@ -233,7 +225,7 @@ vsyslog(int pri, const char *fmt, va_list ap)
*/
(void)time(&now);
stdp = p = tbuf + sprintf(tbuf, "<%d>%.15s ", pri, ctime(&now) + 4);
- if (LogTag) {
+ /*if (LogTag) - always true */ {
if (strlen(LogTag) < sizeof(tbuf) - 64)
p += sprintf(p, "%s", LogTag);
else
@@ -241,7 +233,7 @@ vsyslog(int pri, const char *fmt, va_list ap)
}
if (LogStat & LOG_PID)
p += sprintf(p, "[%d]", getpid());
- if (LogTag) {
+ /*if (LogTag) - always true */ {
*p++ = ':';
*p++ = ' ';
}
@@ -280,14 +272,24 @@ vsyslog(int pri, const char *fmt, va_list ap)
/* Output the message to the local logger using NUL as a message delimiter. */
p = tbuf;
- *last_chr = 0;
+ *last_chr = '\0';
+ retry:
if (LogFile >= 0) {
do {
- rc = write(LogFile, p, last_chr + 1 - p);
+ /* can't just use write, it can result in SIGPIPE */
+ rc = send(LogFile, p, last_chr + 1 - p, MSG_NOSIGNAL);
if (rc < 0) {
- /* I don't think looping forever on EAGAIN is a good idea.
- * Imagine that syslogd is SIGSTOPed... */
- if (/* (errno != EAGAIN) && */ (errno != EINTR)) {
+ switch (errno) {
+ case EINTR:
+ break;
+ case ECONNRESET:
+ /* syslogd restarted, reopen log */
+ closelog_intern(1);
+ openlog_intern();
+ goto retry;
+ case EAGAIN:
+ /* syslogd stalled, noting we can do */
+ default:
closelog_intern(1); /* 1: do not reset LogXXX globals to default */
goto write_err;
}
@@ -315,12 +317,12 @@ vsyslog(int pri, const char *fmt, va_list ap)
(void)close(fd);
}
-getout:
+ getout:
__UCLIBC_MUTEX_UNLOCK(mylock);
- /*if (sigpipe == 0)*/
- sigaction(SIGPIPE, &oldaction, (struct sigaction *) NULL);
}
-libc_hidden_def(vsyslog)
+#ifdef __USE_BSD
+strong_alias(__vsyslog,vsyslog)
+#endif
void
syslog(int pri, const char *fmt, ...)
@@ -328,7 +330,7 @@ syslog(int pri, const char *fmt, ...)
va_list ap;
va_start(ap, fmt);
- vsyslog(pri, fmt, ap);
+ __vsyslog(pri, fmt, ap);
va_end(ap);
}
libc_hidden_def(syslog)
@@ -343,7 +345,6 @@ closelog(void)
closelog_intern(0); /* 0: reset LogXXX globals to default */
__UCLIBC_MUTEX_UNLOCK(mylock);
}
-libc_hidden_def(closelog)
/* setlogmask -- set the log mask level */
int setlogmask(int pmask)
@@ -352,9 +353,9 @@ int setlogmask(int pmask)
omask = LogMask;
if (pmask != 0) {
- __UCLIBC_MUTEX_LOCK(mylock);
+/* __UCLIBC_MUTEX_LOCK(mylock);*/
LogMask = pmask;
- __UCLIBC_MUTEX_UNLOCK(mylock);
+/* __UCLIBC_MUTEX_UNLOCK(mylock);*/
}
return omask;
}
diff --git a/libc/misc/sysvipc/Makefile.in b/libc/misc/sysvipc/Makefile.in
index 6b88ad6f0..d1c124430 100644
--- a/libc/misc/sysvipc/Makefile.in
+++ b/libc/misc/sysvipc/Makefile.in
@@ -1,30 +1,32 @@
# 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.
#
-CSRC := ftok.c __syscall_ipc.c
+subdirs += libc/misc/sysvipc
+
+CSRC-y := ftok.c __syscall_ipc.c
# multi source sem.c
-CSRC += semget.c semctl.c semop.c semtimedop.c
+CSRC-y += semget.c semctl.c semop.c semtimedop.c
# multi source shm.c
-CSRC += shmat.c shmctl.c shmdt.c shmget.c
+CSRC-y += shmat.c shmctl.c shmdt.c shmget.c
# multi source msgq.c
-CSRC += msgctl.c msgget.c msgrcv.c msgsnd.c
+CSRC-y += msgctl.c msgget.c msgrcv.c msgsnd.c
MISC_SYSVIPC_DIR := $(top_srcdir)libc/misc/sysvipc
MISC_SYSVIPC_OUT := $(top_builddir)libc/misc/sysvipc
-MISC_SYSVIPC_SRC := $(patsubst %.c,$(MISC_SYSVIPC_DIR)/%.c,$(CSRC))
-MISC_SYSVIPC_OBJ := $(patsubst %.c,$(MISC_SYSVIPC_OUT)/%.o,$(CSRC))
+MISC_SYSVIPC_SRC := $(patsubst %.c,$(MISC_SYSVIPC_DIR)/%.c,$(CSRC-y))
+MISC_SYSVIPC_OBJ := $(patsubst %.c,$(MISC_SYSVIPC_OUT)/%.o,$(CSRC-y))
libc-y += $(MISC_SYSVIPC_OBJ)
-objclean-y += misc_sysvipc_objclean
+objclean-y += CLEAN_libc/misc/sysvipc
-misc_sysvipc_objclean:
- $(RM) $(MISC_SYSVIPC_OUT)/*.{o,os}
+CLEAN_libc/misc/sysvipc:
+ $(do_rm) $(addprefix $(MISC_SYSVIPC_OUT)/*., o os)
diff --git a/libc/misc/sysvipc/__syscall_ipc.c b/libc/misc/sysvipc/__syscall_ipc.c
index 99dfbf49f..304a42c29 100644
--- a/libc/misc/sysvipc/__syscall_ipc.c
+++ b/libc/misc/sysvipc/__syscall_ipc.c
@@ -13,5 +13,5 @@
#define __NR___syscall_ipc __NR_ipc
#include "ipc.h"
_syscall6(int, __syscall_ipc, unsigned int, call, long, first, long, second, long,
- third, void *, ptr, void *, fifth);
+ third, void *, ptr, void *, fifth)
#endif
diff --git a/libc/misc/sysvipc/ftok.c b/libc/misc/sysvipc/ftok.c
index 12627cad1..1e7549984 100644
--- a/libc/misc/sysvipc/ftok.c
+++ b/libc/misc/sysvipc/ftok.c
@@ -14,20 +14,22 @@
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 <sys/ipc.h>
#include <sys/stat.h>
-
-libc_hidden_proto(stat)
+#ifdef __UCLIBC_HAS_LFS__
+# include <_lfs_64.h>
+#else
+# define stat64 stat
+#endif
key_t ftok (const char *pathname, int proj_id)
{
- struct stat st;
+ struct stat64 st;
key_t key;
- if (stat(pathname, &st) < 0)
+ if (stat64(pathname, &st) < 0)
return (key_t) -1;
key = ((st.st_ino & 0xffff) | ((st.st_dev & 0xff) << 16)
diff --git a/libc/misc/sysvipc/ipc.h b/libc/misc/sysvipc/ipc.h
index 339d1364b..b342dc1cf 100644
--- a/libc/misc/sysvipc/ipc.h
+++ b/libc/misc/sysvipc/ipc.h
@@ -3,10 +3,14 @@
#include <syscall.h>
#include <bits/wordsize.h>
-#if __WORDSIZE == 32 || defined __alpha__ || defined __mips__
-# define __IPC_64 0x100
+#ifndef __ARCH_HAS_DEPRECATED_SYSCALLS__
+# define __IPC_64 0x0
#else
-# define __IPC_64 0x0
+# if __WORDSIZE == 32 || defined __alpha__ || defined __mips__
+# define __IPC_64 0x100
+# else
+# define __IPC_64 0x0
+# endif
#endif
#ifdef __NR_ipc
diff --git a/libc/misc/sysvipc/msgq.c b/libc/misc/sysvipc/msgq.c
index d83ed2208..185cd268b 100644
--- a/libc/misc/sysvipc/msgq.c
+++ b/libc/misc/sysvipc/msgq.c
@@ -1,13 +1,18 @@
#include <errno.h>
#include <sys/msg.h>
#include "ipc.h"
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include "sysdep-cancel.h"
+#else
+#define SINGLE_THREAD_P 1
+#endif
#ifdef L_msgctl
#ifdef __NR_msgctl
#define __NR___libc_msgctl __NR_msgctl
-static __inline__ _syscall3(int, __libc_msgctl, int, msqid, int, cmd, struct msqid_ds *, buf);
+static __inline__ _syscall3(int, __libc_msgctl, int, msqid, int, cmd, struct msqid_ds *, buf)
#endif
/* Message queue control operation. */
int msgctl(int msqid, int cmd, struct msqid_ds *buf)
@@ -43,31 +48,65 @@ struct new_msg_buf{
#ifdef L_msgrcv
#ifdef __NR_msgrcv
-_syscall5(int, msgrcv, int, msqid, void *, msgp, size_t, msgsz, long int, msgtyp, int, msgflg);
-#else
-int msgrcv (int msqid, void *msgp, size_t msgsz,
- long int msgtyp, int msgflg)
+#define __NR___syscall_msgrcv __NR_msgrcv
+static inline _syscall5(ssize_t, __syscall_msgrcv, int, msqid, void *, msgp,
+ size_t, msgsz, long int, msgtyp, int, msgflg)
+#endif
+static inline ssize_t do_msgrcv (int msqid, void *msgp, size_t msgsz,
+ long int msgtyp, int msgflg)
{
+#ifdef __NR_msgrcv
+ return __syscall_msgrcv(msqid, msgp, msgsz, msgtyp, msgflg);
+#else
struct new_msg_buf temp;
temp.r_msgtyp = msgtyp;
temp.oldmsg = msgp;
return __syscall_ipc(IPCOP_msgrcv ,msqid ,msgsz ,msgflg ,&temp, 0);
+#endif
}
+ssize_t msgrcv (int msqid, void *msgp, size_t msgsz,
+ long int msgtyp, int msgflg)
+{
+ if (SINGLE_THREAD_P)
+ return do_msgrcv(msqid, msgp, msgsz, msgtyp, msgflg);
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ int oldtype = LIBC_CANCEL_ASYNC ();
+ int result = do_msgrcv(msqid, msgp, msgsz, msgtyp, msgflg);
+ LIBC_CANCEL_RESET (oldtype);
+ return result;
#endif
+}
#endif
#ifdef L_msgsnd
#ifdef __NR_msgsnd
-_syscall4(int, msgsnd, int, msqid, const void *, msgp, size_t, msgsz, int, msgflg);
-#else
+#define __NR___syscall_msgsnd __NR_msgsnd
+static inline _syscall4(int, __syscall_msgsnd, int, msqid, const void *, msgp,
+ size_t, msgsz, int, msgflg)
+#endif
/* Send message to message queue. */
-int msgsnd (int msqid, const void *msgp, size_t msgsz, int msgflg)
+static inline int do_msgsnd (int msqid, const void *msgp, size_t msgsz,
+ int msgflg)
{
+#ifdef __NR_msgsnd
+ return __syscall_msgsnd(msqid, msgp, msgsz, msgflg);
+#else
return __syscall_ipc(IPCOP_msgsnd, msqid, msgsz, msgflg, (void *)msgp, 0);
+#endif
}
+int msgsnd (int msqid, const void *msgp, size_t msgsz, int msgflg)
+{
+ if (SINGLE_THREAD_P)
+ return do_msgsnd(msqid, msgp, msgsz, msgflg);
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ int oldtype = LIBC_CANCEL_ASYNC ();
+ int result = do_msgsnd(msqid, msgp, msgsz, msgflg);
+ LIBC_CANCEL_RESET (oldtype);
+ return result;
#endif
+}
#endif
diff --git a/libc/misc/sysvipc/sem.c b/libc/misc/sysvipc/sem.c
index 1caec5a8c..64be1cae0 100644
--- a/libc/misc/sysvipc/sem.c
+++ b/libc/misc/sysvipc/sem.c
@@ -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/>. */
#include <errno.h>
#include <sys/sem.h>
#include <stddef.h>
+#include <stdlib.h> /* for NULL */
+
#include "ipc.h"
@@ -27,7 +28,6 @@
/* Return identifier for array of NSEMS semaphores associated with
KEY. */
#include <stdarg.h>
-#include <stdlib.h>
/* arg for semctl system calls. */
union semun {
int val; /* value for SETVAL */
@@ -40,7 +40,7 @@ union semun {
#ifdef __NR_semctl
#define __NR___semctl __NR_semctl
-static __inline__ _syscall4(int, __semctl, int, semid, int, semnum, int, cmd, void *, arg);
+static __inline__ _syscall4(int, __semctl, int, semid, int, semnum, int, cmd, void *, arg)
#endif
int semctl(int semid, int semnum, int cmd, ...)
@@ -61,11 +61,8 @@ int semctl(int semid, int semnum, int cmd, ...)
#endif
#ifdef L_semget
-/* for definition of NULL */
-#include <stdlib.h>
-
#ifdef __NR_semget
-_syscall3(int, semget, key_t, key, int, nsems, int, semflg);
+_syscall3(int, semget, key_t, key, int, nsems, int, semflg)
#else
/* Return identifier for array of NSEMS semaphores associated
@@ -80,7 +77,7 @@ int semget (key_t key, int nsems, int semflg)
#ifdef L_semop
#ifdef __NR_semop
-_syscall3(int, semop, int, semid, struct sembuf *, sops, size_t, nsops);
+_syscall3(int, semop, int, semid, struct sembuf *, sops, size_t, nsops)
#else
/* Perform user-defined atomical operation of array of semaphores. */
@@ -94,14 +91,14 @@ int semop (int semid, struct sembuf *sops, size_t nsops)
#ifdef L_semtimedop
#ifdef __NR_semtimedop
-_syscall4(int, semtimedop, int, semid, struct sembuf *, sops, size_t, nsops, const struct timespec *, timeout);
+_syscall4(int, semtimedop, int, semid, struct sembuf *, sops, size_t, nsops, const struct timespec *, timeout)
#else
int semtimedop(int semid, struct sembuf *sops, size_t nsops,
const struct timespec *timeout)
{
- return __syscall_ipc(IPCOP_semtimedop, semid, nsops, 0, sops, timeout);
+ return __syscall_ipc(IPCOP_semtimedop, semid, nsops, 0, sops, (void *) timeout);
}
#endif
#endif
diff --git a/libc/misc/sysvipc/shm.c b/libc/misc/sysvipc/shm.c
index b1af943b8..cd46ff0dd 100644
--- a/libc/misc/sysvipc/shm.c
+++ b/libc/misc/sysvipc/shm.c
@@ -14,8 +14,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/>. */
/* SHMLBA uses it on most of the archs (not mips) */
#define __getpagesize getpagesize
@@ -34,11 +33,10 @@
# define __NR_shmat __NR_osf_shmat
#endif
#ifdef __NR_shmat
-_syscall3(void *, shmat, int, shmid, const void *,shmaddr, int, shmflg);
+_syscall3(void *, shmat, int, shmid, const void *,shmaddr, int, shmflg)
#else
/* psm: don't remove this, else mips will fail */
#include <unistd.h>
-libc_hidden_proto(getpagesize)
void * shmat (int shmid, const void *shmaddr, int shmflg)
{
@@ -55,13 +53,13 @@ void * shmat (int shmid, const void *shmaddr, int shmflg)
#ifdef L_shmctl
/* Provide operations to control over shared memory segments. */
#ifdef __NR_shmctl
-#define __NR___libc_shmctl __NR_shmctl
-static __inline__ _syscall3(int, __libc_shmctl, int, shmid, int, cmd, struct shmid_ds *, buf);
+#define __NR___syscall_shmctl __NR_shmctl
+static __always_inline _syscall3(int, __syscall_shmctl, int, shmid, int, cmd, struct shmid_ds *, buf)
#endif
int shmctl(int shmid, int cmd, struct shmid_ds *buf)
{
#ifdef __NR_shmctl
- return __libc_shmctl(shmid, cmd | __IPC_64, buf);
+ return __syscall_shmctl(shmid, cmd | __IPC_64, buf);
#else
return __syscall_ipc(IPCOP_shmctl, shmid, cmd | __IPC_64, 0, buf, 0);
#endif
@@ -73,7 +71,7 @@ int shmctl(int shmid, int cmd, struct shmid_ds *buf)
/* Detach shared memory segment starting at address specified by SHMADDR
from the caller's data segment. */
#ifdef __NR_shmdt
-_syscall1(int, shmdt, const void *, shmaddr);
+_syscall1(int, shmdt, const void *, shmaddr)
#else
int shmdt (const void *shmaddr)
{
@@ -86,7 +84,7 @@ int shmdt (const void *shmaddr)
/* Return an identifier for an shared memory segment of at least size SIZE
which is associated with KEY. */
#ifdef __NR_shmget
-_syscall3(int, shmget, key_t, key, size_t, size, int, shmflg);
+_syscall3(int, shmget, key_t, key, size_t, size, int, shmflg)
#else
int shmget (key_t key, size_t size, int shmflg)
{
diff --git a/libc/misc/time/Makefile.in b/libc/misc/time/Makefile.in
index 4c4d510b1..906a1b28e 100644
--- a/libc/misc/time/Makefile.in
+++ b/libc/misc/time/Makefile.in
@@ -1,41 +1,34 @@
# 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.
#
-CSRC := adjtime.c
-ifeq ($(UCLIBC_SUSV3_LEGACY),y)
-CSRC += ftime.c
-endif
+subdirs += libc/misc/time
+
+CSRC-y := adjtime.c
+CSRC-$(UCLIBC_SUSV3_LEGACY) += ftime.c
# multi source time.c
-CSRC += asctime.c asctime_r.c clock.c ctime.c ctime_r.c gmtime.c gmtime_r.c \
+CSRC-y += asctime.c asctime_r.c clock.c ctime.c ctime_r.c gmtime.c gmtime_r.c \
localtime.c localtime_r.c mktime.c strftime.c strptime.c tzset.c \
_time_t2tm.c __time_tm.c _time_mktime.c dysize.c timegm.c \
_time_mktime_tzi.c _time_localtime_tzi.c
-ifeq ($(UCLIBC_HAS_FLOATS),y)
-CSRC += difftime.c
-endif
-ifeq ($(UCLIBC_HAS_XLOCALE),y)
-CSRC += strftime_l.c strptime_l.c
-endif
-ifeq ($(UCLIBC_HAS_WCHAR),y)
-CSRC += wcsftime.c
-ifeq ($(UCLIBC_HAS_XLOCALE),y)
-CSRC += wcsftime_l.c
-endif
-endif
+CSRC-$(UCLIBC_HAS_FLOATS) += difftime.c
+CSRC-$(UCLIBC_HAS_XLOCALE) += strftime_l.c strptime_l.c
+CSRC-$(UCLIBC_HAS_WCHAR) += wcsftime.c
+CSRC-$(if $(findstring yy,$(UCLIBC_HAS_WCHAR)$(UCLIBC_HAS_XLOCALE)),y) += \
+ wcsftime_l.c
MISC_TIME_DIR := $(top_srcdir)libc/misc/time
MISC_TIME_OUT := $(top_builddir)libc/misc/time
-MISC_TIME_SRC := $(patsubst %.c,$(MISC_TIME_DIR)/%.c,$(CSRC))
-MISC_TIME_OBJ := $(patsubst %.c,$(MISC_TIME_OUT)/%.o,$(CSRC))
+MISC_TIME_SRC := $(patsubst %.c,$(MISC_TIME_DIR)/%.c,$(CSRC-y))
+MISC_TIME_OBJ := $(patsubst %.c,$(MISC_TIME_OUT)/%.o,$(CSRC-y))
libc-y += $(MISC_TIME_OBJ)
-objclean-y += misc_time_objclean
+objclean-y += CLEAN_libc/misc/time
-misc_time_objclean:
- $(RM) $(MISC_TIME_OUT)/*.{o,os}
+CLEAN_libc/misc/time:
+ $(do_rm) $(addprefix $(MISC_TIME_OUT)/*., o os)
diff --git a/libc/misc/time/adjtime.c b/libc/misc/time/adjtime.c
index cfa94339a..1e8087104 100644
--- a/libc/misc/time/adjtime.c
+++ b/libc/misc/time/adjtime.c
@@ -9,7 +9,6 @@
#include <sys/timex.h>
#include <errno.h>
-libc_hidden_proto(adjtimex)
#define MAX_SEC (LONG_MAX / 1000000L - 2)
#define MIN_SEC (LONG_MIN / 1000000L + 2)
diff --git a/libc/misc/time/ftime.c b/libc/misc/time/ftime.c
index 49c137ce5..c6c460594 100644
--- a/libc/misc/time/ftime.c
+++ b/libc/misc/time/ftime.c
@@ -12,22 +12,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/>. */
#include <sys/timeb.h>
#include <sys/time.h>
-libc_hidden_proto(gettimeofday)
int ftime(struct timeb *timebuf)
{
struct timeval tv;
struct timezone tz;
- if (gettimeofday (&tv, &tz) < 0)
- return -1;
+ /* In Linux, gettimeofday fails only on bad parameter.
+ * We know that here parameters aren't bad.
+ */
+ gettimeofday (&tv, &tz);
timebuf->time = tv.tv_sec;
timebuf->millitm = (tv.tv_usec + 999) / 1000;
diff --git a/libc/misc/time/time.c b/libc/misc/time/time.c
index ed135c580..03635d86d 100644
--- a/libc/misc/time/time.c
+++ b/libc/misc/time/time.c
@@ -146,46 +146,24 @@
#include <bits/uClibc_uintmaxtostr.h>
#include <bits/uClibc_mutex.h>
-
-#ifdef __UCLIBC_HAS_WCHAR__
+#if defined __UCLIBC_HAS_WCHAR__ && (defined L_wcsftime || defined L_wcsftime_l)
#include <wchar.h>
-#endif
-#ifdef __UCLIBC_HAS_XLOCALE__
-#include <xlocale.h>
-#endif
-
-libc_hidden_proto(asctime)
-libc_hidden_proto(asctime_r)
-libc_hidden_proto(ctime)
-libc_hidden_proto(localtime)
-libc_hidden_proto(localtime_r)
-
-/* Experimentally off - libc_hidden_proto(memset) */
-/* Experimentally off - libc_hidden_proto(memcpy) */
-/* Experimentally off - libc_hidden_proto(strcmp) */
-/* Experimentally off - libc_hidden_proto(strcpy) */
-/* Experimentally off - libc_hidden_proto(strlen) */
-/* Experimentally off - libc_hidden_proto(strncpy) */
-/* libc_hidden_proto(sprintf) */
-libc_hidden_proto(open)
-libc_hidden_proto(read)
-libc_hidden_proto(close)
-libc_hidden_proto(getenv)
-libc_hidden_proto(tzset)
-libc_hidden_proto(gettimeofday)
-/* Experimentally off - libc_hidden_proto(strncasecmp) */
-libc_hidden_proto(strtol)
-libc_hidden_proto(strtoul)
-libc_hidden_proto(nl_langinfo)
-
-#ifdef __UCLIBC_HAS_XLOCALE__
-/* Experimentally off - libc_hidden_proto(strncasecmp_l) */
-libc_hidden_proto(strtol_l)
-libc_hidden_proto(strtoul_l)
-libc_hidden_proto(nl_langinfo_l)
-libc_hidden_proto(__ctype_b_loc)
-#elif defined __UCLIBC_HAS_CTYPE_TABLES__
-libc_hidden_proto(__ctype_b)
+# define CHAR_T wchar_t
+# define UCHAR_T unsigned int
+# ifdef L_wcsftime
+# define strftime wcsftime
+# define L_strftime
+# if defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE)
+# define strftime_l wcsftime_l
+# endif
+# endif
+# ifdef L_wcsftime_l
+# define strftime_l wcsftime_l
+# define L_strftime_l
+# endif
+#else
+# define CHAR_T char
+# define UCHAR_T unsigned char
#endif
#ifndef __isleap
@@ -246,7 +224,7 @@ typedef struct {
char tzname[TZNAME_MAX+1];
} rule_struct;
-__UCLIBC_MUTEX_EXTERN(_time_tzlock);
+__UCLIBC_MUTEX_EXTERN(_time_tzlock) attribute_hidden;
extern rule_struct _time_tzinfo[2] attribute_hidden;
@@ -308,7 +286,7 @@ libc_hidden_def(asctime)
* If we take the implicit assumption as given, then the implementation below
* is still incorrect for tm_year values < -900, as there will be either
* 0-padding and/or a missing negative sign for the year conversion . But given
- * the ususal use of asctime(), I think it isn't unreasonable to restrict correct
+ * the usual use of asctime(), I think it isn't unreasonable to restrict correct
* operation to the domain of years between 1000 and 9999.
*/
@@ -406,16 +384,16 @@ char *asctime_r(register const struct tm *__restrict ptm,
if (((unsigned int) tmp) >= 100) { /* Just check 2 digit non-neg. */
buffer[-1] = *buffer = '?';
} else
-#else /* SAFE_ASCTIME_R */
+#else
assert(((unsigned int) tmp) < 100); /* Just check 2 digit non-neg. */
-#endif /* SAFE_ASCTIME_R */
+#endif
{
*buffer = '0' + (tmp % 10);
#ifdef __BCC__
buffer[-1] = '0' + (tmp/10);
-#else /* __BCC__ */
+#else
buffer[-1] += (tmp/10);
-#endif /* __BCC__ */
+#endif
}
} while ((buffer -= 2)[-2] == '0');
@@ -433,8 +411,6 @@ libc_hidden_def(asctime_r)
#include <sys/times.h>
-libc_hidden_proto(times)
-
#ifndef __BCC__
#if CLOCKS_PER_SEC != 1000000L
#error unexpected value for CLOCKS_PER_SEC!
@@ -501,8 +477,23 @@ clock_t clock(void)
char *ctime(const time_t *t)
{
- /* ANSI/ISO/SUSv3 say that ctime is equivalent to the following. */
- return asctime(localtime(t));
+ /* ANSI/ISO/SUSv3 say that ctime is equivalent to the following:
+ * return asctime(localtime(t));
+ * I don't think "equivalent" means "it uses the same internal buffer",
+ * it means "gives the same resultant string".
+ *
+ * I doubt anyone ever uses weird code like:
+ * struct tm *ptm = localtime(t1); ...; ctime(t2); use(ptm);
+ * which relies on the assumption that ctime's and localtime's
+ * internal static struct tm is the same.
+ *
+ * Using localtime_r instead of localtime avoids linking in
+ * localtime's static buffer:
+ */
+ struct tm xtm;
+ memset(&xtm, 0, sizeof(xtm));
+
+ return asctime(localtime_r(t, &xtm));
}
libc_hidden_def(ctime)
#endif
@@ -531,7 +522,7 @@ double difftime(time_t time1, time_t time0)
#if (LONG_MAX >> DBL_MANT_DIG) == 0
/* time_t fits in the mantissa of a double. */
- return ((double) time1) - time0;
+ return (double)time1 - (double)time0;
#elif ((LONG_MAX >> DBL_MANT_DIG) >> DBL_MANT_DIG) == 0
@@ -618,43 +609,48 @@ libc_hidden_def(localtime_r)
#ifdef __UCLIBC_HAS_TM_EXTENSIONS__
-/* Experimentally off - libc_hidden_proto(strnlen) */
-
struct ll_tzname_item;
typedef struct ll_tzname_item {
struct ll_tzname_item *next;
- char tzname[TZNAME_MAX+1];
+ char tzname[1];
} ll_tzname_item_t;
-static ll_tzname_item_t ll_tzname[] = {
- { ll_tzname + 1, "UTC" }, /* Always 1st. */
- { NULL, "???" } /* Always 2nd. (invalid or out-of-memory) */
-};
+/* Structures form a list "UTC" -> "???" -> "tzname1" -> "tzname2"... */
+static struct {
+ struct ll_tzname_item *next;
+ char tzname[4];
+} ll_tzname_UNKNOWN = { NULL, "???" };
+static const struct {
+ struct ll_tzname_item *next;
+ char tzname[4];
+} ll_tzname_UTC = { (void*)&ll_tzname_UNKNOWN, "UTC" };
static const char *lookup_tzname(const char *key)
{
- ll_tzname_item_t *p;
+ int len;
+ ll_tzname_item_t *p = (void*) &ll_tzname_UTC;
- for (p=ll_tzname ; p ; p=p->next) {
- if (!strcmp(p->tzname, key)) {
+ do {
+ if (strcmp(p->tzname, key) == 0)
return p->tzname;
- }
- }
+ p = p->next;
+ } while (p != NULL);
/* Hmm... a new name. */
- if (strnlen(key, TZNAME_MAX+1) < TZNAME_MAX+1) { /* Verify legal length */
- if ((p = malloc(sizeof(ll_tzname_item_t))) != NULL) {
+ len = strnlen(key, TZNAME_MAX+1);
+ if (len < TZNAME_MAX+1) { /* Verify legal length */
+ p = malloc(sizeof(ll_tzname_item_t) + len);
+ if (p != NULL) {
/* Insert as 3rd item in the list. */
- p->next = ll_tzname[1].next;
- ll_tzname[1].next = p;
- strcpy(p->tzname, key);
- return p->tzname;
+ p->next = ll_tzname_UNKNOWN.next;
+ ll_tzname_UNKNOWN.next = p;
+ return strcpy(p->tzname, key);
}
}
/* Either invalid or couldn't alloc. */
- return ll_tzname[1].tzname;
+ return ll_tzname_UNKNOWN.tzname;
}
#endif /* __UCLIBC_HAS_TM_EXTENSIONS__ */
@@ -687,7 +683,7 @@ static int tm_isdst(register const struct tm *__restrict ptm,
isleap = __isleap(i);
--i;
day0 = (1
- + i /* Normal years increment 1 wday. */
+ + i /* Normal years increment 1 wday. */
+ (i/4)
- (i/100)
+ (i/400) ) % 7;
@@ -700,20 +696,22 @@ static int tm_isdst(register const struct tm *__restrict ptm,
}
} else if (r->rule_type == 'M') {
/* Find 0-based day number for 1st of the month. */
- day = 31*r->month - day_cor[r->month -1];
+ day = 31 * r->month - day_cor[r->month - 1];
if (isleap && (day >= 59)) {
++day;
}
- monlen = 31 + day_cor[r->month -1] - day_cor[r->month];
- if (isleap && (r->month > 1)) {
+ monlen = 31 + day_cor[r->month - 1] - day_cor[r->month];
+ if (isleap && (r->month == 2)) {
++monlen;
}
- /* Wweekday (0 is Sunday) of 1st of the month
+ /* Weekday (0 is Sunday) of 1st of the month
* is (day0 + day) % 7. */
- if ((mday = r->day - ((day0 + day) % 7)) >= 0) {
- mday -= 7; /* Back up into prev month since r->week>0. */
+ mday = r->day - ((day0 + day) % 7);
+ if (mday >= 0) {
+ mday -= 7; /* Back up into prev month since r->week > 0. */
}
- if ((mday += 7 * r->week) >= monlen) {
+ mday += 7 * r->week;
+ if (mday >= monlen) {
mday -= 7;
}
/* So, 0-based day number is... */
@@ -805,21 +803,17 @@ time_t timegm(struct tm *timeptr)
#endif
/**********************************************************************/
-#if defined(L_strftime) || defined(L_strftime_l)
+#if defined(L_strftime) || defined(L_strftime_l) \
+ || defined(L_wcsftime) || defined(L_wcsftime_l)
#if defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE)
-libc_hidden_proto(strftime)
-
-libc_hidden_proto(strftime_l)
-
-size_t strftime(char *__restrict s, size_t maxsize,
- const char *__restrict format,
+size_t strftime(CHAR_T *__restrict s, size_t maxsize,
+ const CHAR_T *__restrict format,
const struct tm *__restrict timeptr)
{
return strftime_l(s, maxsize, format, timeptr, __UCLIBC_CURLOCALE);
}
-libc_hidden_def(strftime)
#else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
@@ -1013,30 +1007,58 @@ static int load_field(int k, const struct tm *__restrict timeptr)
return r;
}
+#if defined __UCLIBC_HAS_WCHAR__ && (defined L_wcsftime || defined L_wcsftime_l)
+static wchar_t* fmt_to_wc_1(const char *src)
+{
+ mbstate_t mbstate;
+ size_t src_len = strlen(src);
+ wchar_t *dest = (wchar_t *)malloc((src_len + 1) * sizeof(wchar_t));
+ if (dest == NULL)
+ return NULL;
+ mbstate.__mask = 0;
+ if (mbsrtowcs(dest, &src, src_len + 1, &mbstate) == (size_t) -1) {
+ free(dest);
+ return NULL;
+ }
+ return dest;
+}
+# define fmt_to_wc(dest, src) \
+ dest = alloc[++allocno] = fmt_to_wc_1(src)
+# define to_wc(dest, src) \
+ dest = fmt_to_wc_1(src)
+#else
+# define fmt_to_wc(dest, src) (dest) = (src)
+# define to_wc(dest, src) (dest) = (src)
+#endif
+
#define MAX_PUSH 4
#ifdef __UCLIBC_MJN3_ONLY__
#warning TODO: Check multibyte format string validity.
#endif
-libc_hidden_proto(__XL_NPP(strftime))
-size_t __XL_NPP(strftime)(char *__restrict s, size_t maxsize,
- const char *__restrict format,
+size_t __XL_NPP(strftime)(CHAR_T *__restrict s, size_t maxsize,
+ const CHAR_T *__restrict format,
const struct tm *__restrict timeptr __LOCALE_PARAM )
{
long tzo;
- register const char *p;
- register const char *o;
+ register const CHAR_T *p;
+ const CHAR_T *o;
+ const char *ccp;
#ifndef __UCLIBC_HAS_TM_EXTENSIONS__
const rule_struct *rsp;
#endif
- const char *stack[MAX_PUSH];
+ const CHAR_T *stack[MAX_PUSH];
+#if defined __UCLIBC_HAS_WCHAR__ && (defined L_wcsftime || defined L_wcsftime_l)
+ const CHAR_T *alloc[MAX_PUSH];
+ int allocno = -1;
+#endif
size_t count;
size_t o_count;
- int field_val, i, j, lvl;
+ int field_val = 0, i = 0, j, lvl;
int x[3]; /* wday, yday, year */
int isofm, days;
- char buf[__UIM_BUFLEN_LONG];
+ char buf[__UIM_BUFLEN_LONG] = {0,};
unsigned char mod;
unsigned char code;
@@ -1061,8 +1083,26 @@ LOOP:
}
o_count = 1;
- if ((*(o = p) == '%') && (*++p != '%')) {
+ if ((*(o = (CHAR_T *)p) == '%') && (*++p != '%')) {
+#if 0 /* TODO, same for strptime */
+ /* POSIX.1-2008 allows %0xY %+nY %-nY etc. for certain formats.
+ * Just accept these for all (for now) */
+ const int plus = *p == '+';
+ CHAR_T *q = (CHAR_T *)p;
+ long int o_width = __XL_NPP(strtol)(p, &q, 0 __LOCALE_ARG);
+ if (o_width > 0 && o_width < 256) { /* arbitrary upper limit */
+ o_count = o_width;
+ if (plus) {
+ *s++ = '+';
+ --count;
+ }
+ p = q;
+ } else {
+ o_count = 2;
+ }
+#else
o_count = 2;
+#endif
mod = ILLEGAL_SPEC;
if ((*p == 'O') || (*p == 'E')) { /* modifier */
mod |= ((*p == 'O') ? NO_O_MOD : NO_E_MOD);
@@ -1086,31 +1126,33 @@ LOOP:
}
stack[lvl++] = ++p;
if ((code &= 0xf) < 8) {
- p = ((const char *) spec) + STACKED_STRINGS_START + code;
- p += *((unsigned char *)p);
+ ccp = (const char *)(spec + STACKED_STRINGS_START + code);
+ ccp += *ccp;
+ fmt_to_wc(p, ccp);
goto LOOP;
}
- p = ((const char *) spec) + STACKED_STRINGS_NL_ITEM_START
- + (code & 7);
+ ccp = (const char *)spec + STACKED_STRINGS_NL_ITEM_START + (code & 7);
+ fmt_to_wc(p, ccp);
#ifdef ENABLE_ERA_CODE
if ((mod & NO_E_MOD) /* Actually, this means E modifier present. */
- && (*(o = __XL_NPP(nl_langinfo)(_NL_ITEM(LC_TIME,
- (int)(((unsigned char *)p)[4]))
- __LOCALE_ARG
- )))
+ && (*(ccp = __XL_NPP(nl_langinfo)(_NL_ITEM(LC_TIME,
+ (int)(((unsigned char *)p)[4]))
+ __LOCALE_ARG
+ )))
) {
- p = o;
+ fmt_to_wc(p, ccp);
goto LOOP;
}
#endif
- p = __XL_NPP(nl_langinfo)(_NL_ITEM(LC_TIME,
- (int)(*((unsigned char *)p)))
- __LOCALE_ARG
- );
+ ccp = __XL_NPP(nl_langinfo)(_NL_ITEM(LC_TIME,
+ (int)(*((unsigned char *)p)))
+ __LOCALE_ARG
+ );
+ fmt_to_wc(p, ccp);
goto LOOP;
}
- o = ((const char *) spec) + 26; /* set to "????" */
+ ccp = (const char *)(spec + 26); /* set to "????" */
if ((code & MASK_SPEC) == CALC_SPEC) {
if (*p == 's') {
@@ -1125,15 +1167,16 @@ LOOP:
goto OUTPUT;
}
#ifdef TIME_T_IS_UNSIGNED
- o = _uintmaxtostr(buf + sizeof(buf) - 1,
+ ccp = _uintmaxtostr(buf + sizeof(buf) - 1,
(uintmax_t) t,
10, __UIM_DECIMAL);
#else
- o = _uintmaxtostr(buf + sizeof(buf) - 1,
+ ccp = _uintmaxtostr(buf + sizeof(buf) - 1,
(uintmax_t) t,
-10, __UIM_DECIMAL);
#endif
o_count = sizeof(buf);
+ fmt_to_wc(o, ccp);
goto OUTPUT;
} else if (((*p) | 0x20) == 'z') { /* 'z' or 'Z' */
@@ -1168,7 +1211,7 @@ LOOP:
#endif
if (*p == 'Z') {
- o = RSP_TZNAME;
+ ccp = RSP_TZNAME;
#ifdef __UCLIBC_HAS_TM_EXTENSIONS__
/* Sigh... blasted glibc extensions. Of course we can't
* count on the pointer being valid. Best we can do is
@@ -1179,17 +1222,18 @@ LOOP:
* case... although it always seems to use the embedded
* tm_gmtoff value. What we'll do instead is treat the
* timezone name as unknown/invalid and return "???". */
- if (!o) {
- o = "???";
+ if (!ccp) {
+ ccp = (const char *)(spec + 27); /* "???" */
}
#endif
- assert(o != NULL);
+ assert(ccp != NULL);
#if 0
- if (!o) { /* PARANOIA */
- o = spec+30; /* empty string */
+ if (!ccp) { /* PARANOIA */
+ ccp = spec+30; /* empty string */
}
#endif
o_count = SIZE_MAX;
+ fmt_to_wc(o, ccp);
#ifdef __UCLIBC_HAS_TM_EXTENSIONS__
goto OUTPUT;
#endif
@@ -1207,8 +1251,7 @@ LOOP:
i = 16 + 6; /* 0-fill, width = 4 */
}
-#ifdef __UCLIBC_HAS_TM_EXTENSIONS__
-#else
+#ifndef __UCLIBC_HAS_TM_EXTENSIONS__
__UCLIBC_MUTEX_UNLOCK(_time_tzlock);
if (*p == 'Z') {
goto OUTPUT;
@@ -1234,7 +1277,7 @@ LOOP:
--field_val;
}
} else { /* ((*p == 'g') || (*p == 'G') || (*p == 'V')) */
- ISO_LOOP:
+ISO_LOOP:
isofm = (((x[1] - x[0]) + 11) % 7) - 3; /* [-3,3] */
if (x[1] < isofm) { /* belongs to previous year */
@@ -1245,7 +1288,7 @@ LOOP:
field_val = ((x[1] - isofm) / 7) + 1; /* week # */
days = 365 + __isleap(x[2]);
- isofm = ((isofm + 7*53 + 3 - days)) %7 + days - 3; /* next year */
+ isofm = ((isofm + 7*53 + 3 - days)) % 7 + days - 3; /* next year */
if (x[1] >= isofm) { /* next year */
x[1] -= days;
++x[2];
@@ -1264,7 +1307,7 @@ LOOP:
}
} else {
i = TP_OFFSETS + (code & 0x1f);
- if ((field_val = load_field(spec[i],timeptr)) < 0) {
+ if ((field_val = load_field(spec[i], timeptr)) < 0) {
goto OUTPUT;
}
@@ -1276,7 +1319,7 @@ LOOP:
}
if (i & 32) {
field_val %= j;
- if (((i&128) + field_val) == 0) { /* mod 12? == 0 */
+ if (((i & 128) + field_val) == 0) { /* mod 12? == 0 */
field_val = j; /* set to 12 */
}
}
@@ -1289,17 +1332,25 @@ LOOP:
if ((code & MASK_SPEC) == STRING_SPEC) {
o_count = SIZE_MAX;
field_val += spec[STRINGS_NL_ITEM_START + (code & 0xf)];
- o = __XL_NPP(nl_langinfo)(_NL_ITEM(LC_TIME, field_val) __LOCALE_ARG );
+ ccp = __XL_NPP(nl_langinfo)(_NL_ITEM(LC_TIME, field_val) __LOCALE_ARG);
+ fmt_to_wc(o, ccp);
} else {
+#if 0 /* TODO, same for strptime */
+ size_t min_count = ((i >> 1) & 3) + 1;
+ if (o_count < min_count)
+ o_count = min_count;
+#else
o_count = ((i >> 1) & 3) + 1;
- o = buf + o_count;
+#endif
+ ccp = buf + o_count;
do {
- *(char *)(--o) = '0' + (field_val % 10);
+ *(char *)(--ccp) = '0' + (field_val % 10);
field_val /= 10;
- } while (o > buf);
+ } while (ccp > buf);
if (*buf == '0') {
*buf = ' ' + (i & 16);
}
+ fmt_to_wc(o, ccp);
}
}
@@ -1310,9 +1361,15 @@ OUTPUT:
--o_count;
--count;
}
+#if defined __UCLIBC_HAS_WCHAR__ && (defined L_wcsftime || defined L_wcsftime_l)
+ if (allocno >= 0)
+ free((void *)alloc[allocno--]);
+#endif
goto LOOP;
}
-libc_hidden_def(__XL_NPP(strftime))
+# ifdef L_strftime_l
+libc_hidden_def(strftime_l)
+# endif
#endif /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
@@ -1330,16 +1387,11 @@ libc_hidden_def(__XL_NPP(strftime))
#if defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE)
-libc_hidden_proto(strptime)
-
-libc_hidden_proto(strptime_l)
-
char *strptime(const char *__restrict buf, const char *__restrict format,
struct tm *__restrict tm)
{
return strptime_l(buf, format, tm, __UCLIBC_CURLOCALE);
}
-libc_hidden_def(strptime)
#else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
@@ -1485,7 +1537,6 @@ static const unsigned char spec[] = {
#define MAX_PUSH 4
-libc_hidden_proto(__XL_NPP(strptime))
char *__XL_NPP(strptime)(const char *__restrict buf, const char *__restrict format,
struct tm *__restrict tm __LOCALE_PARAM)
{
@@ -1555,17 +1606,18 @@ LOOP:
#ifdef ENABLE_ERA_CODE
if ((mod & NO_E_MOD) /* Actually, this means E modifier present. */
&& (*(o = __XL_NPP(nl_langinfo)(_NL_ITEM(LC_TIME,
- (int)(((unsigned char *)p)[4]))
- __LOCALE_ARG
- )))
+ (int)(((unsigned char *)p)[4]))
+ __LOCALE_ARG
+ )))
) {
p = o;
goto LOOP;
}
#endif
p = __XL_NPP(nl_langinfo)(_NL_ITEM(LC_TIME,
- (int)(*((unsigned char *)p)))
- __LOCALE_ARG );
+ (int)(*((unsigned char *)p)))
+ __LOCALE_ARG
+ );
goto LOOP;
}
@@ -1579,7 +1631,7 @@ LOOP:
do {
--j;
o = __XL_NPP(nl_langinfo)(i+j __LOCALE_ARG);
- if (!__XL_NPP(strncasecmp)(buf,o,strlen(o) __LOCALE_ARG) && *o) {
+ if (!__XL_NPP(strncasecmp)(buf, o, strlen(o) __LOCALE_ARG) && *o) {
do { /* Found a match. */
++buf;
} while (*++o);
@@ -1669,7 +1721,7 @@ LOOP:
fields[(*x) >> 3] = i;
- if (((unsigned char)(*x - (10<< 3) + 0 + 0)) <= 8) { /* %C or %y */
+ if (((unsigned char)(*x - (10 << 3) + 0 + 0)) <= 8) { /* %C or %y */
if ((j = fields[10]) < 0) { /* No %C, so i must be %y data. */
if (i <= 68) { /* Map [0-68] to 2000+i */
i += 100;
@@ -1695,7 +1747,9 @@ LOOP:
}
return NULL;
}
-libc_hidden_def(__XL_NPP(strptime))
+# ifdef L_strptime_l
+libc_hidden_def(strptime_l)
+# endif
#endif /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
@@ -1825,53 +1879,100 @@ static const char *getnumber(register const char *e, int *pn)
#ifndef __UCLIBC_HAS_TZ_FILE_READ_MANY__
static smallint TZ_file_read; /* Let BSS initialization set this to 0. */
-#endif /* __UCLIBC_HAS_TZ_FILE_READ_MANY__ */
+#endif
static char *read_TZ_file(char *buf)
{
+ int r;
int fd;
- ssize_t r;
- size_t todo;
char *p = NULL;
- if ((fd = open(__UCLIBC_TZ_FILE_PATH__, O_RDONLY)) >= 0) {
- todo = TZ_BUFLEN;
+ fd = open(__UCLIBC_TZ_FILE_PATH__, O_RDONLY);
+ if (fd >= 0) {
+#if 0
+ /* TZ are small *files*. On files, short reads
+ * only occur on EOF (unlike, say, pipes).
+ * The code below is pedanticallly more correct,
+ * but this way we always read at least twice:
+ * 1st read is short, 2nd one is zero bytes.
+ */
+ size_t todo = TZ_BUFLEN;
p = buf;
do {
- if ((r = read(fd, p, todo)) < 0) {
+ r = read(fd, p, todo);
+ if (r < 0)
goto ERROR;
- }
- if (r == 0) {
+ if (r == 0)
break;
- }
p += r;
todo -= r;
} while (todo);
-
- if ((p > buf) && (p[-1] == '\n')) { /* Must end with newline. */
+#else
+ /* Shorter, and does one fewer read syscall */
+ r = read(fd, buf, TZ_BUFLEN);
+ if (r < 0)
+ goto ERROR;
+ p = buf + r;
+#endif
+ if ((p > buf) && (p[-1] == '\n')) { /* Must end with newline */
p[-1] = 0;
p = buf;
#ifndef __UCLIBC_HAS_TZ_FILE_READ_MANY__
TZ_file_read = 1;
-#endif /* __UCLIBC_HAS_TZ_FILE_READ_MANY__ */
+#endif
} else {
ERROR:
p = NULL;
}
close(fd);
}
+#ifdef __UCLIBC_FALLBACK_TO_ETC_LOCALTIME__
+ else {
+ fd = open("/etc/localtime", O_RDONLY);
+ if (fd >= 0) {
+ r = read(fd, buf, TZ_BUFLEN);
+ if (r != TZ_BUFLEN
+ || strncmp(buf, "TZif", 4) != 0
+ || (unsigned char)buf[4] < 2
+ || lseek(fd, -TZ_BUFLEN, SEEK_END) < 0
+ ) {
+ goto ERROR;
+ }
+ /* tzfile.h from tzcode database says about TZif2+ files:
+ **
+ ** If tzh_version is '2' or greater, the above is followed by a second instance
+ ** of tzhead and a second instance of the data in which each coded transition
+ ** time uses 8 rather than 4 chars,
+ ** then a POSIX-TZ-environment-variable-style string for use in handling
+ ** instants after the last transition time stored in the file
+ ** (with nothing between the newlines if there is no POSIX representation for
+ ** such instants).
+ */
+ r = read(fd, buf, TZ_BUFLEN);
+ if (r <= 0 || buf[--r] != '\n')
+ goto ERROR;
+ buf[r] = 0;
+ while (r != 0) {
+ if (buf[--r] == '\n') {
+ p = buf + r + 1;
+#ifndef __UCLIBC_HAS_TZ_FILE_READ_MANY__
+ TZ_file_read = 1;
+#endif
+ break;
+ }
+ } /* else ('\n' not found): p remains NULL */
+ close(fd);
+ }
+ }
+#endif /* __UCLIBC_FALLBACK_TO_ETC_LOCALTIME__ */
return p;
}
#endif /* __UCLIBC_HAS_TZ_FILE__ */
-#ifndef __UCLIBC_HAS_CTYPE_TABLES__
-libc_hidden_proto(isascii)
-#endif
-
void tzset(void)
{
- _time_tzset((time(NULL)) < new_rule_starts);
+ _time_tzset((time(NULL)) < new_rule_starts);
}
void _time_tzset(int use_old_rules)
@@ -1885,43 +1986,41 @@ void _time_tzset(int use_old_rules)
char c;
#ifdef __UCLIBC_HAS_TZ_FILE__
char buf[TZ_BUFLEN];
-#endif /* __UCLIBC_HAS_TZ_FILE__ */
+#endif
#ifdef __UCLIBC_HAS_TZ_CACHING__
static char oldval[TZ_BUFLEN]; /* BSS-zero'd. */
-#endif /* __UCLIBC_HAS_TZ_CACHING__ */
+#endif
+ /* Put this inside the lock to prevent the possibility of two different
+ * timezones being used in a threaded app. */
__UCLIBC_MUTEX_LOCK(_time_tzlock);
e = getenv(TZ); /* TZ env var always takes precedence. */
#if defined(__UCLIBC_HAS_TZ_FILE__) && !defined(__UCLIBC_HAS_TZ_FILE_READ_MANY__)
- /* Put this inside the lock to prevent the possiblity of two different
- * timezones being used in a threaded app. */
-
- if (e != NULL) {
- TZ_file_read = 0; /* Reset if the TZ env var is set. */
- } else if (TZ_file_read) {
+ if (e) {
+ /* Never use TZfile if TZ env var is set. */
+ TZ_file_read = 0;
+ }
+ if (TZ_file_read) {
+ /* We already parsed TZfile before, skip everything. */
goto FAST_DONE;
}
-#endif /* defined(__UCLIBC_HAS_TZ_FILE__) && !defined(__UCLIBC_HAS_TZ_FILE_READ_MANY__) */
+#endif
/* Warning!!! Since uClibc doesn't do lib locking, the following is
* potentially unsafe in a multi-threaded program since it is remotely
* possible that another thread could call setenv() for TZ and overwrite
* the string being parsed. So, don't do that... */
- if ((!e /* TZ env var not set... */
#ifdef __UCLIBC_HAS_TZ_FILE__
- && !(e = read_TZ_file(buf)) /* and no file or invalid file */
-#endif /* __UCLIBC_HAS_TZ_FILE__ */
- ) || !*e) { /* or set to empty string. */
-ILLEGAL: /* TODO: Clean up the following... */
-#ifdef __UCLIBC_HAS_TZ_CACHING__
- *oldval = 0; /* Set oldval to an empty string. */
-#endif /* __UCLIBC_HAS_TZ_CACHING__ */
- memset(_time_tzinfo, 0, 2*sizeof(rule_struct));
- strcpy(_time_tzinfo[0].tzname, UTC);
- goto DONE;
+ if (!e)
+ e = read_TZ_file(buf);
+#endif
+ if (!e /* TZ env var not set and no TZfile (or bad TZfile) */
+ || !*e /* or set to empty string. */
+ ) {
+ goto ILLEGAL;
}
if (*e == ':') { /* Ignore leading ':'. */
@@ -1929,14 +2028,15 @@ ILLEGAL: /* TODO: Clean up the following... */
}
#ifdef __UCLIBC_HAS_TZ_CACHING__
- if (strcmp(e, oldval) == 0) { /* Same string as last time... */
- goto FAST_DONE; /* So nothing to do. */
+ if (strcmp(e, oldval) == 0) {
+ /* Same string as last time... nothing to do. */
+ goto FAST_DONE;
}
/* Make a copy of the TZ env string. It won't be nul-terminated if
* it is too long, but it that case it will be illegal and will be reset
* to the empty string anyway. */
strncpy(oldval, e, TZ_BUFLEN);
-#endif /* __UCLIBC_HAS_TZ_CACHING__ */
+#endif
count = 0;
new_rules[1].tzname[0] = 0;
@@ -1951,10 +2051,11 @@ LOOP:
s = new_rules[count].tzname;
n = 0;
while (*e
- && isascii(*e) /* SUSv3 requires char in portable char set. */
- && (isalpha(*e)
- || (c && (isalnum(*e) || (*e == '+') || (*e == '-'))))
- ) {
+ && isascii(*e) /* SUSv3 requires char in portable char set. */
+ && (isalpha(*e)
+ || (c && (isalnum(*e) || (*e == '+') || (*e == '-')))
+ )
+ ) {
*s++ = *e++;
if (++n > TZNAME_MAX) {
goto ILLEGAL;
@@ -1963,8 +2064,8 @@ LOOP:
*s = 0;
if ((n < 3) /* Check for minimum length. */
- || (c && (*e++ != c)) /* Match any quoting '<'. */
- ) {
+ || (c && (*e++ != c)) /* Match any quoting '<'. */
+ ) {
goto ILLEGAL;
}
@@ -1979,7 +2080,8 @@ LOOP:
}
++e;
- if (!(e = getoffset(e, &off))) {
+ e = getoffset(e, &off);
+ if (!e) {
goto ILLEGAL;
}
@@ -1998,15 +2100,15 @@ SKIP_OFFSET:
} else { /* OK, we have dst, so get some rules. */
count = 0;
if (!*e) { /* No rules so default to US rules. */
- e = use_old_rules ? DEFAULT_RULES : DEFAULT_2007_RULES;
+ e = use_old_rules ? DEFAULT_RULES : DEFAULT_2007_RULES;
#ifdef DEBUG_TZSET
if (e == DEFAULT_RULES)
- printf("tzset: Using old rules.\n");
+ printf("tzset: Using old rules.\n");
else if (e == DEFAULT_2007_RULES)
- printf("tzset: Using new rules\n");
+ printf("tzset: Using new rules\n");
else
- printf("tzset: Using undefined rules\n");
-#endif /* DEBUG_TZSET */
+ printf("tzset: Using undefined rules\n");
+#endif
}
do {
@@ -2016,7 +2118,8 @@ SKIP_OFFSET:
n = 365;
s = (char *) RULE;
- if ((c = *e++) == 'M') {
+ c = *e++;
+ if (c == 'M') {
n = 12;
} else if (c == 'J') {
s += 8;
@@ -2026,26 +2129,31 @@ SKIP_OFFSET:
s += 6;
}
- *(p = &new_rules[count].rule_type) = c;
+ p = &new_rules[count].rule_type;
+ *p = c;
if (c != 'M') {
p -= 2;
}
do {
++s;
- if (!(e = getnumber(e, &f))
- || (((unsigned int)(f - s[1])) > n)
- || (*s && (*e++ != *s))
- ) {
+ e = getnumber(e, &f);
+ if (!e
+ || ((unsigned int)(f - s[1]) > n)
+ || (*s && (*e++ != *s))
+ ) {
goto ILLEGAL;
}
*--p = f;
- } while ((n = *(s += 2)) > 0);
+ s += 2;
+ n = *s;
+ } while (n > 0);
off = 2 * 60 * 60; /* Default to 2:00:00 */
if (*e == '/') {
++e;
- if (!(e = getoffset(e, &off))) {
+ e = getoffset(e, &off);
+ if (!e) {
goto ILLEGAL;
}
}
@@ -2053,7 +2161,13 @@ SKIP_OFFSET:
} while (++count < 2);
if (*e) {
- goto ILLEGAL;
+ILLEGAL:
+#ifdef __UCLIBC_HAS_TZ_CACHING__
+ oldval[0] = 0; /* oldval = "" */
+#endif
+ memset(_time_tzinfo, 0, sizeof(_time_tzinfo));
+ strcpy(_time_tzinfo[0].tzname, UTC);
+ goto DONE;
}
}
@@ -2064,7 +2178,8 @@ DONE:
daylight = !!_time_tzinfo[1].tzname[0];
timezone = _time_tzinfo[0].gmt_offset;
-#if defined(__UCLIBC_HAS_TZ_FILE__) || defined(__UCLIBC_HAS_TZ_CACHING__)
+#if (defined(__UCLIBC_HAS_TZ_FILE__) && !defined(__UCLIBC_HAS_TZ_FILE_READ_MANY__)) || \
+ defined(__UCLIBC_HAS_TZ_CACHING__)
FAST_DONE:
#endif
__UCLIBC_MUTEX_UNLOCK(_time_tzlock);
@@ -2210,7 +2325,6 @@ struct tm attribute_hidden *_time_t2tm(const time_t *__restrict timer,
t = 365;
}
-
*p += ((int) t); /* result[7] .. tm_yday */
p -= 2; /* at result[5] */
@@ -2386,7 +2500,7 @@ DST_CORRECT:
__time_localtime_tzi(&t, (struct tm *)p, tzi);
if (t == ((time_t)(-1))) { /* Remember, time_t can be unsigned. */
- goto DONE;
+ goto DONE;
}
if ((d < 0) && (((struct tm *)p)->tm_isdst != default_dst)) {
@@ -2410,35 +2524,9 @@ DONE:
#endif
/**********************************************************************/
-#if defined(L_wcsftime) || defined(L_wcsftime_l)
+#if (defined(L_wcsftime) || defined(L_wcsftime_l))
-#if defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE)
-
-libc_hidden_proto(wcsftime)
-
-libc_hidden_proto(wcsftime_l)
-
-size_t wcsftime(wchar_t *__restrict s, size_t maxsize,
- const wchar_t *__restrict format,
- const struct tm *__restrict timeptr)
-{
- return wcsftime_l(s, maxsize, format, timeptr, __UCLIBC_CURLOCALE);
-}
-libc_hidden_def(wcsftime)
-
-#else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
-
-libc_hidden_proto(__XL_NPP(wcsftime))
-size_t __XL_NPP(wcsftime)(wchar_t *__restrict s, size_t maxsize,
- const wchar_t *__restrict format,
- const struct tm *__restrict timeptr __LOCALE_PARAM )
-{
-#warning wcsftime always fails
- return 0; /* always fail */
-}
-libc_hidden_def(__XL_NPP(wcsftime))
-
-#endif /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
+/* Implemented via strftime / strftime_l wchar_t variants */
#endif
/**********************************************************************/
diff --git a/libc/misc/ttyent/Makefile.in b/libc/misc/ttyent/Makefile.in
index 288a4c09b..02d7df8d1 100644
--- a/libc/misc/ttyent/Makefile.in
+++ b/libc/misc/ttyent/Makefile.in
@@ -1,21 +1,23 @@
# 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.
#
-CSRC := getttyent.c
+subdirs += libc/misc/ttyent
+
+CSRC-y := getttyent.c
MISC_TTYENT_DIR := $(top_srcdir)libc/misc/ttyent
MISC_TTYENT_OUT := $(top_builddir)libc/misc/ttyent
-MISC_TTYENT_SRC := $(patsubst %.c,$(MISC_TTYENT_DIR)/%.c,$(CSRC))
-MISC_TTYENT_OBJ := $(patsubst %.c,$(MISC_TTYENT_OUT)/%.o,$(CSRC))
+MISC_TTYENT_SRC := $(patsubst %.c,$(MISC_TTYENT_DIR)/%.c,$(CSRC-y))
+MISC_TTYENT_OBJ := $(patsubst %.c,$(MISC_TTYENT_OUT)/%.o,$(CSRC-y))
libc-y += $(MISC_TTYENT_OBJ)
-objclean-y += misc_ttyent_objclean
+objclean-y += CLEAN_libc/misc/ttyent
-misc_ttyent_objclean:
- $(RM) $(MISC_TTYENT_OUT)/*.{o,os}
+CLEAN_libc/misc/ttyent:
+ $(do_rm) $(addprefix $(MISC_TTYENT_OUT)/*., o os)
diff --git a/libc/misc/ttyent/getttyent.c b/libc/misc/ttyent/getttyent.c
index b55cdb267..0441cb6a1 100644
--- a/libc/misc/ttyent/getttyent.c
+++ b/libc/misc/ttyent/getttyent.c
@@ -30,29 +30,11 @@
#include <features.h>
#include <ttyent.h>
#include <stdio.h>
-#include <stdio_ext.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#ifdef __UCLIBC_HAS_THREADS__
-#include <pthread.h>
-#endif
-
-/* Experimentally off - libc_hidden_proto(strchr) */
-/* Experimentally off - libc_hidden_proto(strcmp) */
-/* Experimentally off - libc_hidden_proto(strncmp) */
-libc_hidden_proto(__fsetlocking)
-libc_hidden_proto(rewind)
-libc_hidden_proto(fgets_unlocked)
-libc_hidden_proto(getc_unlocked)
-libc_hidden_proto(__fgetc_unlocked)
-libc_hidden_proto(fopen)
-libc_hidden_proto(fclose)
-libc_hidden_proto(abort)
-#ifdef __UCLIBC_HAS_XLOCALE__
-libc_hidden_proto(__ctype_b_loc)
-#elif defined __UCLIBC_HAS_CTYPE_TABLES__
-libc_hidden_proto(__ctype_b)
+# include <stdio_ext.h>
#endif
static char zapchar;
@@ -102,7 +84,6 @@ static char * value(register char *p)
return ((p = strchr(p, '=')) ? ++p : NULL);
}
-libc_hidden_proto(setttyent)
int setttyent(void)
{
@@ -120,7 +101,6 @@ int setttyent(void)
}
libc_hidden_def(setttyent)
-libc_hidden_proto(getttyent)
struct ttyent * getttyent(void)
{
register int c;
@@ -201,7 +181,6 @@ struct ttyent * getttyent(void)
}
libc_hidden_def(getttyent)
-libc_hidden_proto(endttyent)
int endttyent(void)
{
int rval;
diff --git a/libc/misc/utmp/Makefile.in b/libc/misc/utmp/Makefile.in
index ff175dc64..6c54ade96 100644
--- a/libc/misc/utmp/Makefile.in
+++ b/libc/misc/utmp/Makefile.in
@@ -1,21 +1,24 @@
# 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.
#
-CSRC := utent.c wtent.c
+subdirs += libc/misc/utmp
+
+CSRC-y :=
+CSRC-$(if $(findstring y,$(UCLIBC_HAS_UTMP)$(UCLIBC_HAS_UTMPX)),y) += utent.c
MISC_UTMP_DIR := $(top_srcdir)libc/misc/utmp
MISC_UTMP_OUT := $(top_builddir)libc/misc/utmp
-MISC_UTMP_SRC := $(patsubst %.c,$(MISC_UTMP_DIR)/%.c,$(CSRC))
-MISC_UTMP_OBJ := $(patsubst %.c,$(MISC_UTMP_OUT)/%.o,$(CSRC))
+MISC_UTMP_SRC := $(patsubst %.c,$(MISC_UTMP_DIR)/%.c,$(CSRC-y))
+MISC_UTMP_OBJ := $(patsubst %.c,$(MISC_UTMP_OUT)/%.o,$(CSRC-y))
libc-y += $(MISC_UTMP_OBJ)
-objclean-y += misc_utmp_objclean
+objclean-y += CLEAN_libc/misc/utmp
-misc_utmp_objclean:
- $(RM) $(MISC_UTMP_OUT)/*.{o,os}
+CLEAN_libc/misc/utmp:
+ $(do_rm) $(addprefix $(MISC_UTMP_OUT)/*., o os)
diff --git a/libc/misc/utmp/utent.c b/libc/misc/utmp/utent.c
index 6c1793e65..16f4b115f 100644
--- a/libc/misc/utmp/utent.c
+++ b/libc/misc/utmp/utent.c
@@ -1,3 +1,4 @@
+/* vi: set sw=4 ts=4: */
/* utent.c <ndf@linux.mit.edu> */
/* Let it be known that this is very possibly the worst standard ever. HP-UX
does one thing, someone else does another, linux another... If anyone
@@ -17,194 +18,216 @@
#include <fcntl.h>
#include <paths.h>
#include <errno.h>
+#include <malloc.h>
#include <string.h>
-#include <utmp.h>
-
-/* Experimentally off - libc_hidden_proto(strcmp) */
-/* Experimentally off - libc_hidden_proto(strdup) */
-/* Experimentally off - libc_hidden_proto(strncmp) */
-libc_hidden_proto(read)
-libc_hidden_proto(write)
-libc_hidden_proto(open)
-libc_hidden_proto(fcntl)
-libc_hidden_proto(close)
-libc_hidden_proto(lseek)
-
+#include "internal/utmp.h"
+#include <not-cancel.h>
#include <bits/uClibc_mutex.h>
-__UCLIBC_MUTEX_STATIC(utmplock, PTHREAD_MUTEX_INITIALIZER);
-
+__UCLIBC_MUTEX_STATIC(utmplock, PTHREAD_MUTEX_INITIALIZER);
/* Some global crap */
static int static_fd = -1;
-static struct utmp static_utmp;
-static const char default_file_name[] = _PATH_UTMP;
-static const char *static_ut_name = (const char *) default_file_name;
+static struct UT *static_utmp = NULL;
+static const char default_file[] = __DEFAULT_PATH_UTMP;
+static const char *current_file = default_file;
/* This function must be called with the LOCK held */
-static void __setutent(void)
+static void __set_unlocked(void)
{
- int ret;
-
- if (static_fd == -1) {
- if ((static_fd = open(static_ut_name, O_RDWR)) < 0) {
- if ((static_fd = open(static_ut_name, O_RDONLY)) < 0) {
- goto bummer;
- }
- }
- /* Make sure the file will be closed on exec() */
- ret = fcntl(static_fd, F_GETFD, 0);
- if (ret >= 0) {
- ret = fcntl(static_fd, F_SETFD, ret | FD_CLOEXEC);
- }
- if (ret < 0) {
-bummer:
- static_fd = -1;
- close(static_fd);
- return;
+ if (static_fd < 0) {
+ static_fd = open_not_cancel_2(current_file, O_RDWR | O_CLOEXEC);
+ if (static_fd < 0) {
+ static_fd = open_not_cancel_2(current_file, O_RDONLY | O_CLOEXEC);
+ if (static_fd < 0) {
+ return; /* static_fd remains < 0 */
+ }
+ }
+#ifndef __ASSUME_O_CLOEXEC
+ /* Make sure the file will be closed on exec() */
+ fcntl_not_cancel(static_fd, F_SETFD, FD_CLOEXEC);
+#endif
+ return;
}
- }
- lseek(static_fd, 0, SEEK_SET);
- return;
+ lseek(static_fd, 0, SEEK_SET);
}
-
-libc_hidden_proto(setutent)
-void setutent(void)
+#if defined __UCLIBC_HAS_THREADS__
+void set(void)
{
- __UCLIBC_MUTEX_LOCK(utmplock);
- __setutent();
- __UCLIBC_MUTEX_UNLOCK(utmplock);
+ __UCLIBC_MUTEX_LOCK(utmplock);
+ __set_unlocked();
+ __UCLIBC_MUTEX_UNLOCK(utmplock);
}
-libc_hidden_def(setutent)
+#else
+strong_alias(__set_unlocked,set)
+#endif
+/* not used in libc_hidden_def(set) */
+other(setutxent,setutent)
/* This function must be called with the LOCK held */
-static struct utmp *__getutent(int utmp_fd)
+static struct UT *__get_unlocked(void)
{
- struct utmp *ret = NULL;
+ if (static_fd < 0) {
+ __set_unlocked();
+ if (static_fd < 0)
+ return NULL;
+ }
- if (utmp_fd == -1) {
- __setutent();
- }
- if (utmp_fd == -1) {
- return NULL;
- }
+ if (static_utmp == NULL)
+ static_utmp = (struct UT *)__uc_malloc(sizeof(struct UT));
- if (read(utmp_fd, (char *) &static_utmp, sizeof(struct utmp)) == sizeof(struct utmp))
- {
- ret = &static_utmp;
- }
+ if (read_not_cancel(static_fd, static_utmp,
+ sizeof(struct UT)) == sizeof(struct UT)) {
+ return static_utmp;
+ }
- return ret;
+ return NULL;
}
-
-void endutent(void)
+#if defined __UCLIBC_HAS_THREADS__
+struct UT *get(void)
{
- __UCLIBC_MUTEX_LOCK(utmplock);
- if (static_fd != -1)
- close(static_fd);
- static_fd = -1;
- __UCLIBC_MUTEX_UNLOCK(utmplock);
+ struct UT *ret;
+
+ __UCLIBC_MUTEX_LOCK(utmplock);
+ ret = __get_unlocked();
+ __UCLIBC_MUTEX_UNLOCK(utmplock);
+ return ret;
}
+#else
+strong_alias(__get_unlocked,get)
+#endif
+/* not used in libc_hidden_def(get) */
+other(getutxent,getutent)
-struct utmp *getutent(void)
+void end(void)
{
- struct utmp *ret = NULL;
-
- __UCLIBC_MUTEX_LOCK(utmplock);
- ret = __getutent(static_fd);
- __UCLIBC_MUTEX_UNLOCK(utmplock);
- return ret;
+ __UCLIBC_MUTEX_LOCK(utmplock);
+ if (static_fd >= 0)
+ close_not_cancel_no_status(static_fd);
+ static_fd = -1;
+ __UCLIBC_MUTEX_UNLOCK(utmplock);
}
+/* not used in libc_hidden_def(end) */
+other(endutxent,endutent)
/* This function must be called with the LOCK held */
-static struct utmp *__getutid(const struct utmp *utmp_entry)
+static struct UT *__getid_unlocked(const struct UT *utmp_entry)
{
- struct utmp *lutmp;
-
- while ((lutmp = __getutent(static_fd)) != NULL) {
- if ( (utmp_entry->ut_type == RUN_LVL ||
- utmp_entry->ut_type == BOOT_TIME ||
- utmp_entry->ut_type == NEW_TIME ||
- utmp_entry->ut_type == OLD_TIME) &&
- lutmp->ut_type == utmp_entry->ut_type)
- {
- return lutmp;
- }
- if ( (utmp_entry->ut_type == INIT_PROCESS ||
- utmp_entry->ut_type == DEAD_PROCESS ||
- utmp_entry->ut_type == LOGIN_PROCESS ||
- utmp_entry->ut_type == USER_PROCESS) &&
- !strncmp(lutmp->ut_id, utmp_entry->ut_id, sizeof(lutmp->ut_id)))
- {
- return lutmp;
- }
- }
+ struct UT *lutmp;
+ unsigned type;
+
+ /* We use the fact that constants we are interested in are: */
+ /* RUN_LVL=1, ... OLD_TIME=4; INIT_PROCESS=5, ... USER_PROCESS=8 */
+ type = utmp_entry->ut_type - 1;
+ type /= 4;
+
+ while ((lutmp = __get_unlocked()) != NULL) {
+ if (type == 0 && lutmp->ut_type == utmp_entry->ut_type) {
+ /* one of RUN_LVL, BOOT_TIME, NEW_TIME, OLD_TIME */
+ return lutmp;
+ }
+ if (type == 1
+ && strncmp(lutmp->ut_id, utmp_entry->ut_id,
+ sizeof(lutmp->ut_id)) == 0) {
+ /* INIT_PROCESS, LOGIN_PROCESS, USER_PROCESS, DEAD_PROCESS */
+ return lutmp;
+ }
+ }
- return NULL;
+ return NULL;
}
-
-libc_hidden_proto(getutid)
-struct utmp *getutid(const struct utmp *utmp_entry)
+#if defined __UCLIBC_HAS_THREADS__
+struct UT *getid(const struct UT *utmp_entry)
{
- struct utmp *ret = NULL;
+ struct UT *ret;
- __UCLIBC_MUTEX_LOCK(utmplock);
- ret = __getutid(utmp_entry);
- __UCLIBC_MUTEX_UNLOCK(utmplock);
- return ret;
+ __UCLIBC_MUTEX_LOCK(utmplock);
+ ret = __getid_unlocked(utmp_entry);
+ __UCLIBC_MUTEX_UNLOCK(utmplock);
+ return ret;
}
-libc_hidden_def(getutid)
+#else
+strong_alias(__getid_unlocked,getid)
+#endif
+/* not used in libc_hidden_def(getid) */
+other(getutxid,getutid)
-struct utmp *getutline(const struct utmp *utmp_entry)
+struct UT *getline(const struct UT *utmp_entry)
{
- struct utmp *lutmp = NULL;
-
- __UCLIBC_MUTEX_LOCK(utmplock);
- while ((lutmp = __getutent(static_fd)) != NULL) {
- if ((lutmp->ut_type == USER_PROCESS || lutmp->ut_type == LOGIN_PROCESS) &&
- !strcmp(lutmp->ut_line, utmp_entry->ut_line)) {
- break;
+ struct UT *lutmp;
+
+ __UCLIBC_MUTEX_LOCK(utmplock);
+ while ((lutmp = __get_unlocked()) != NULL) {
+ if (lutmp->ut_type == USER_PROCESS || lutmp->ut_type == LOGIN_PROCESS) {
+ if (strncmp(lutmp->ut_line, utmp_entry->ut_line,
+ sizeof(lutmp->ut_line)) == 0) {
+ break;
+ }
+ }
}
- }
- __UCLIBC_MUTEX_UNLOCK(utmplock);
- return lutmp;
+ __UCLIBC_MUTEX_UNLOCK(utmplock);
+ return lutmp;
}
+/* libc_hidden_def(getline) */
+other(getutxline,getutline)
-struct utmp *pututline (const struct utmp *utmp_entry)
+struct UT *putline(const struct UT *utmp_entry)
{
- __UCLIBC_MUTEX_LOCK(utmplock);
- /* Ignore the return value. That way, if they've already positioned
- the file pointer where they want it, everything will work out. */
- lseek(static_fd, (off_t) - sizeof(struct utmp), SEEK_CUR);
-
- if (__getutid(utmp_entry) != NULL)
- lseek(static_fd, (off_t) - sizeof(struct utmp), SEEK_CUR);
- else
- lseek(static_fd, (off_t) 0, SEEK_END);
- if (write(static_fd, utmp_entry, sizeof(struct utmp)) != sizeof(struct utmp))
- utmp_entry = NULL;
-
- __UCLIBC_MUTEX_UNLOCK(utmplock);
- return (struct utmp *)utmp_entry;
+ __UCLIBC_MUTEX_LOCK(utmplock);
+ /* Ignore the return value. That way, if they've already positioned
+ the file pointer where they want it, everything will work out. */
+ lseek(static_fd, (off_t) - sizeof(struct UT), SEEK_CUR);
+
+ if (__getid_unlocked(utmp_entry) != NULL)
+ lseek(static_fd, (off_t) - sizeof(struct UT), SEEK_CUR);
+ else
+ lseek(static_fd, (off_t) 0, SEEK_END);
+ if (write(static_fd, utmp_entry, sizeof(struct UT))
+ != sizeof(struct UT))
+ utmp_entry = NULL;
+
+ __UCLIBC_MUTEX_UNLOCK(utmplock);
+ return (struct UT *)utmp_entry;
}
+/* not used in libc_hidden_def(putline) */
+other(pututxline,pututline)
-int utmpname (const char *new_ut_name)
+int name(const char *new_file)
{
- __UCLIBC_MUTEX_LOCK(utmplock);
- if (new_ut_name != NULL) {
- if (static_ut_name != default_file_name)
- free((char *)static_ut_name);
- static_ut_name = strdup(new_ut_name);
- if (static_ut_name == NULL) {
- /* We should probably whine about out-of-memory
- * errors here... Instead just reset to the default */
- static_ut_name = default_file_name;
+ __UCLIBC_MUTEX_LOCK(utmplock);
+ if (new_file != NULL) {
+ if (current_file != default_file)
+ free((char *)current_file);
+ current_file = strdup(new_file);
+ if (current_file == NULL) {
+ /* We should probably whine about out-of-memory
+ * errors here... Instead just reset to the default */
+ current_file = default_file;
+ }
}
- }
- if (static_fd != -1)
- close(static_fd);
- static_fd = -1;
- __UCLIBC_MUTEX_UNLOCK(utmplock);
- return 0;
+ if (static_fd >= 0) {
+ close_not_cancel_no_status(static_fd);
+ static_fd = -1;
+ }
+ __UCLIBC_MUTEX_UNLOCK(utmplock);
+ return 0; /* or maybe return -(current_file != new_file)? */
+}
+/* not used in libc_hidden_def(name) */
+other(utmpxname,utmpname)
+
+void updw(const char *wtmp_file, const struct UT *lutmp)
+{
+ int fd;
+
+ fd = open_not_cancel_2(wtmp_file, O_APPEND | O_WRONLY);
+ if (fd >= 0) {
+ if (lockf(fd, F_LOCK, 0) == 0) {
+ write_not_cancel(fd, lutmp, sizeof(struct UT));
+ lockf(fd, F_ULOCK, 0);
+ close_not_cancel_no_status(fd);
+ }
+ }
}
+/* not used in libc_hidden_def(updw) */
+other(updwtmpx,updwtmp)
diff --git a/libc/misc/utmp/wtent.c b/libc/misc/utmp/wtent.c
deleted file mode 100644
index 9430bbb19..000000000
--- a/libc/misc/utmp/wtent.c
+++ /dev/null
@@ -1,58 +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.
- */
-
-/* wtmp support rubbish (i.e. complete crap) */
-
-#include <string.h>
-#include <sys/time.h>
-#include <time.h>
-#include <unistd.h>
-#include <utmp.h>
-#include <fcntl.h>
-#include <sys/file.h>
-
-#if 0
-/* Experimentally off - libc_hidden_proto(memset) */
-/* Experimentally off - libc_hidden_proto(strncpy) */
-libc_hidden_proto(updwtmp)
-#endif
-libc_hidden_proto(open)
-libc_hidden_proto(write)
-libc_hidden_proto(close)
-libc_hidden_proto(lockf)
-libc_hidden_proto(gettimeofday)
-
-#if 0
-/* This is enabled in uClibc/libutil/logwtmp.c */
-void logwtmp (const char *line, const char *name, const char *host)
-{
- struct utmp lutmp;
- memset (&(lutmp), 0, sizeof (struct utmp));
-
- lutmp.ut_type = (name && *name)? USER_PROCESS : DEAD_PROCESS;
- lutmp.ut_pid = __getpid();
- strncpy(lutmp.ut_line, line, sizeof(lutmp.ut_line)-1);
- strncpy(lutmp.ut_name, name, sizeof(lutmp.ut_name)-1);
- strncpy(lutmp.ut_host, host, sizeof(lutmp.ut_host)-1);
- gettimeofday(&(lutmp.ut_tv), NULL);
-
- updwtmp(_PATH_WTMP, &(lutmp));
-}
-#endif
-
-void updwtmp(const char *wtmp_file, const struct utmp *lutmp)
-{
- int fd;
-
- fd = open(wtmp_file, O_APPEND | O_WRONLY, 0);
- if (fd >= 0) {
- if (lockf(fd, F_LOCK, 0)==0) {
- write(fd, (const char *) lutmp, sizeof(struct utmp));
- lockf(fd, F_ULOCK, 0);
- close(fd);
- }
- }
-}
diff --git a/libc/misc/wchar/Makefile.in b/libc/misc/wchar/Makefile.in
index db01f97cc..32a8dbc62 100644
--- a/libc/misc/wchar/Makefile.in
+++ b/libc/misc/wchar/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.
#
@@ -16,24 +16,24 @@
# wcsftime
#
+subdirs += libc/misc/wchar
+
# multi source wchar.c
-CSRC := btowc.c wctob.c mbsinit.c mbrlen.c mbrtowc.c wcrtomb.c mbsrtowcs.c \
+CSRC-y := btowc.c wctob.c mbsinit.c mbrlen.c mbrtowc.c wcrtomb.c mbsrtowcs.c \
wcsrtombs.c _wchar_utf8sntowcs.c _wchar_wcsntoutf8s.c \
mbsnrtowcs.c wcsnrtombs.c wcwidth.c wcswidth.c
-ifeq ($(UCLIBC_HAS_LOCALE),y)
-CSRC += iconv.c
-endif
+CSRC-$(UCLIBC_HAS_LOCALE) += iconv.c
MISC_WCHAR_DIR := $(top_srcdir)libc/misc/wchar
MISC_WCHAR_OUT := $(top_builddir)libc/misc/wchar
-MISC_WCHAR_SRC := $(patsubst %.c,$(MISC_WCHAR_DIR)/%.c,$(CSRC))
-MISC_WCHAR_OBJ := $(patsubst %.c,$(MISC_WCHAR_OUT)/%.o,$(CSRC))
+MISC_WCHAR_SRC := $(patsubst %.c,$(MISC_WCHAR_DIR)/%.c,$(CSRC-y))
+MISC_WCHAR_OBJ := $(patsubst %.c,$(MISC_WCHAR_OUT)/%.o,$(CSRC-y))
libc-$(UCLIBC_HAS_WCHAR) += $(MISC_WCHAR_OBJ)
-objclean-y += misc_wchar_objclean
+objclean-y += CLEAN_libc/misc/wchar
-misc_wchar_objclean:
- $(RM) $(MISC_WCHAR_OUT)/*.{o,os}
+CLEAN_libc/misc/wchar:
+ $(do_rm) $(addprefix $(MISC_WCHAR_OUT)/*., o os)
diff --git a/libc/misc/wchar/wchar.c b/libc/misc/wchar/wchar.c
index 567be8585..966f78d19 100644
--- a/libc/misc/wchar/wchar.c
+++ b/libc/misc/wchar/wchar.c
@@ -12,8 +12,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/>.
*/
/* ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION!
@@ -97,7 +97,7 @@
*
* Manuel
*/
-
+#ifdef _LIBC
#include <errno.h>
#include <stddef.h>
#include <limits.h>
@@ -119,7 +119,7 @@
#endif
#endif /* __UCLIBC_MJN3_ONLY__ */
-#define ENCODING ((__UCLIBC_CURLOCALE_DATA).encoding)
+#define ENCODING (__UCLIBC_CURLOCALE->encoding)
#define Cc2wc_IDX_SHIFT __LOCALE_DATA_Cc2wc_IDX_SHIFT
#define Cc2wc_ROW_LEN __LOCALE_DATA_Cc2wc_ROW_LEN
@@ -170,13 +170,11 @@ extern size_t _wchar_utf8sntowcs(wchar_t *__restrict pwc, size_t wn,
extern size_t _wchar_wcsntoutf8s(char *__restrict s, size_t n,
const wchar_t **__restrict src, size_t wn) attribute_hidden;
-
+#endif
/**********************************************************************/
#ifdef L_btowc
-libc_hidden_proto(mbrtowc)
-libc_hidden_proto(btowc)
wint_t btowc(int c)
{
#ifdef __CTYPE_HAS_8_BIT_LOCALES
@@ -188,24 +186,24 @@ wint_t btowc(int c)
if (c != EOF) {
*buf = (unsigned char) c;
mbstate.__mask = 0; /* Initialize the mbstate. */
- if (mbrtowc(&wc, buf, 1, &mbstate) <= 1) {
+ if (mbrtowc(&wc, (char*) buf, 1, &mbstate) <= 1) {
return wc;
}
}
return WEOF;
-#else /* __CTYPE_HAS_8_BIT_LOCALES */
+#else /* !__CTYPE_HAS_8_BIT_LOCALES */
#ifdef __UCLIBC_HAS_LOCALE__
assert((ENCODING == __ctype_encoding_7_bit)
|| (ENCODING == __ctype_encoding_utf8));
-#endif /* __UCLIBC_HAS_LOCALE__ */
+#endif
/* If we don't have 8-bit locale support, then this is trivial since
* anything outside of 0-0x7f is illegal in C/POSIX and UTF-8 locales. */
return (((unsigned int)c) < 0x80) ? c : WEOF;
-#endif /* __CTYPE_HAS_8_BIT_LOCALES */
+#endif /* !__CTYPE_HAS_8_BIT_LOCALES */
}
libc_hidden_def(btowc)
@@ -215,7 +213,6 @@ libc_hidden_def(btowc)
/* Note: We completely ignore ps in all currently supported conversions. */
-libc_hidden_proto(wcrtomb)
int wctob(wint_t c)
{
@@ -223,7 +220,7 @@ int wctob(wint_t c)
unsigned char buf[MB_LEN_MAX];
- return (wcrtomb(buf, c, NULL) == 1) ? *buf : EOF;
+ return (wcrtomb((char*) buf, c, NULL) == 1) ? *buf : EOF;
#else /* __CTYPE_HAS_8_BIT_LOCALES */
@@ -246,7 +243,6 @@ int wctob(wint_t c)
/**********************************************************************/
#ifdef L_mbsinit
-libc_hidden_proto(mbsinit)
int mbsinit(const mbstate_t *ps)
{
return !ps || !ps->__mask;
@@ -257,9 +253,7 @@ libc_hidden_def(mbsinit)
/**********************************************************************/
#ifdef L_mbrlen
-libc_hidden_proto(mbrtowc)
-libc_hidden_proto(mbrlen)
size_t mbrlen(const char *__restrict s, size_t n, mbstate_t *__restrict ps)
{
static mbstate_t mbstate; /* Rely on bss 0-init. */
@@ -272,9 +266,7 @@ libc_hidden_def(mbrlen)
/**********************************************************************/
#ifdef L_mbrtowc
-libc_hidden_proto(mbsnrtowcs)
-libc_hidden_proto(mbrtowc)
size_t mbrtowc(wchar_t *__restrict pwc, const char *__restrict s,
size_t n, mbstate_t *__restrict ps)
{
@@ -294,7 +286,9 @@ size_t mbrtowc(wchar_t *__restrict pwc, const char *__restrict s,
s = empty_string;
n = 1;
} else if (*s == '\0') {
- /* According to the ISO C 89 standard this is the expected behaviour. */
+ if (pwc)
+ *pwc = '\0';
+ /* According to the ISO C 89 standard this is the expected behaviour. */
return 0;
} else if (!n) {
/* TODO: change error code? */
@@ -338,12 +332,10 @@ libc_hidden_def(mbrtowc)
/**********************************************************************/
#ifdef L_wcrtomb
-libc_hidden_proto(wcsnrtombs)
/* Note: We completely ignore ps in all currently supported conversions. */
/* TODO: Check for valid state anyway? */
-libc_hidden_proto(wcrtomb)
size_t wcrtomb(register char *__restrict s, wchar_t wc,
mbstate_t *__restrict ps)
{
@@ -372,9 +364,7 @@ libc_hidden_def(wcrtomb)
/**********************************************************************/
#ifdef L_mbsrtowcs
-libc_hidden_proto(mbsnrtowcs)
-libc_hidden_proto(mbsrtowcs)
size_t mbsrtowcs(wchar_t *__restrict dst, const char **__restrict src,
size_t len, mbstate_t *__restrict ps)
{
@@ -393,9 +383,7 @@ libc_hidden_def(mbsrtowcs)
* TODO: Check for valid state anyway? */
-libc_hidden_proto(wcsnrtombs)
-libc_hidden_proto(wcsrtombs)
size_t wcsrtombs(char *__restrict dst, const wchar_t **__restrict src,
size_t len, mbstate_t *__restrict ps)
{
@@ -488,7 +476,8 @@ size_t attribute_hidden _wchar_utf8sntowcs(wchar_t *__restrict pwc, size_t wn,
#ifdef __UCLIBC_MJN3_ONLY__
#warning TODO: Fix range for 16 bit wchar_t case.
#endif
- if ( ((unsigned char)(s[-1] - 0xc0)) < (0xfe - 0xc0) ) {
+ if (( ((unsigned char)(s[-1] - 0xc0)) < (0xfe - 0xc0) ) &&
+ (((unsigned char)s[-1] != 0xc0 ) && ((unsigned char)s[-1] != 0xc1 ))) {
goto START;
}
BAD:
@@ -613,7 +602,7 @@ size_t attribute_hidden _wchar_wcsntoutf8s(char *__restrict s, size_t n,
if (!s) {
n = SIZE_MAX;
}
- s = buf;
+ s = buf;
store = 0;
}
@@ -699,7 +688,6 @@ size_t attribute_hidden _wchar_wcsntoutf8s(char *__restrict s, size_t n,
/* WARNING: We treat len as SIZE_MAX when dst is NULL! */
-libc_hidden_proto(mbsnrtowcs)
size_t mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src,
size_t NMC, size_t len, mbstate_t *__restrict ps)
{
@@ -751,8 +739,8 @@ size_t mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src,
while (count) {
if ((wc = ((unsigned char)(*s))) >= 0x80) { /* Non-ASCII... */
wc -= 0x80;
- wc = __UCLIBC_CURLOCALE_DATA.tbl8c2wc[
- (__UCLIBC_CURLOCALE_DATA.idx8c2wc[wc >> Cc2wc_IDX_SHIFT]
+ wc = __UCLIBC_CURLOCALE->tbl8c2wc[
+ (__UCLIBC_CURLOCALE->idx8c2wc[wc >> Cc2wc_IDX_SHIFT]
<< Cc2wc_IDX_SHIFT) + (wc & (Cc2wc_ROW_LEN - 1))];
if (!wc) {
goto BAD;
@@ -809,7 +797,6 @@ libc_hidden_def(mbsnrtowcs)
/* Note: We completely ignore ps in all currently supported conversions.
* TODO: Check for valid state anyway? */
-libc_hidden_proto(wcsnrtombs)
size_t wcsnrtombs(char *__restrict dst, const wchar_t **__restrict src,
size_t NWC, size_t len, mbstate_t *__restrict ps)
{
@@ -862,12 +849,12 @@ size_t wcsnrtombs(char *__restrict dst, const wchar_t **__restrict src,
} else {
u = 0;
if (wc <= Cwc2c_DOMAIN_MAX) {
- u = __UCLIBC_CURLOCALE_DATA.idx8wc2c[wc >> (Cwc2c_TI_SHIFT
+ u = __UCLIBC_CURLOCALE->idx8wc2c[wc >> (Cwc2c_TI_SHIFT
+ Cwc2c_TT_SHIFT)];
- u = __UCLIBC_CURLOCALE_DATA.tbl8wc2c[(u << Cwc2c_TI_SHIFT)
+ u = __UCLIBC_CURLOCALE->tbl8wc2c[(u << Cwc2c_TI_SHIFT)
+ ((wc >> Cwc2c_TT_SHIFT)
& ((1 << Cwc2c_TI_SHIFT)-1))];
- u = __UCLIBC_CURLOCALE_DATA.tbl8wc2c[Cwc2c_TI_LEN
+ u = __UCLIBC_CURLOCALE->tbl8wc2c[Cwc2c_TI_LEN
+ (u << Cwc2c_TT_SHIFT)
+ (wc & ((1 << Cwc2c_TT_SHIFT)-1))];
}
@@ -923,7 +910,6 @@ libc_hidden_def(wcsnrtombs)
/**********************************************************************/
#ifdef L_wcswidth
-libc_hidden_proto(wcswidth)
#ifdef __UCLIBC_MJN3_ONLY__
#warning REMINDER: If we start doing translit, wcwidth and wcswidth will need updating.
@@ -1039,13 +1025,12 @@ static const signed char new_wtbl[] = {
0, 2, 1, 2, 1, 0, 1,
};
-libc_hidden_proto(wcsnrtombs)
int wcswidth(const wchar_t *pwcs, size_t n)
{
- int h, l, m, count;
- wchar_t wc;
- unsigned char b;
+ int h, l, m, count;
+ wchar_t wc;
+ unsigned char b;
if (ENCODING == __ctype_encoding_7_bit) {
size_t i;
@@ -1081,7 +1066,7 @@ int wcswidth(const wchar_t *pwcs, size_t n)
}
#endif /* __CTYPE_HAS_UTF_8_LOCALES */
- for (count = 0 ; n && (wc = *pwcs++) ; n--) {
+ for (count = 0 ; n && (wc = *pwcs++) ; n--) {
if (wc <= 0xff) {
/* If we're here, wc != 0. */
if ((wc < 32) || ((wc >= 0x7f) && (wc < 0xa0))) {
@@ -1131,9 +1116,9 @@ int wcswidth(const wchar_t *pwcs, size_t n)
}
++count;
- }
+ }
- return count;
+ return count;
}
#else /* __UCLIBC_HAS_LOCALE__ */
@@ -1142,8 +1127,15 @@ int wcswidth(const wchar_t *pwcs, size_t n)
{
int count;
wchar_t wc;
+ size_t i;
- for (count = 0 ; n && (wc = *pwcs++) ; n--) {
+ for (i = 0 ; (i < n) && pwcs[i] ; i++) {
+ if (pwcs[i] != (pwcs[i] & 0x7f)) {
+ return -1;
+ }
+ }
+
+ for (count = 0 ; n && (wc = *pwcs++) ; n--) {
if (wc <= 0xff) {
/* If we're here, wc != 0. */
if ((wc < 32) || ((wc >= 0x7f) && (wc < 0xa0))) {
@@ -1167,11 +1159,10 @@ libc_hidden_def(wcswidth)
/**********************************************************************/
#ifdef L_wcwidth
-libc_hidden_proto(wcswidth)
int wcwidth(wchar_t wc)
{
- return wcswidth(&wc, 1);
+ return wcswidth(&wc, 1);
}
#endif
@@ -1191,45 +1182,6 @@ typedef struct {
int skip_invalid_input; /* To support iconv -c option. */
} _UC_iconv_t;
-
-
-#ifdef L_iconv
-
-#include <iconv.h>
-#include <string.h>
-#include <endian.h>
-#include <byteswap.h>
-
-#if (__BYTE_ORDER != __BIG_ENDIAN) && (__BYTE_ORDER != __LITTLE_ENDIAN)
-#error unsupported endianness for iconv
-#endif
-
-#ifndef __CTYPE_HAS_8_BIT_LOCALES
-#error currently iconv requires 8 bit locales
-#endif
-#ifndef __CTYPE_HAS_UTF_8_LOCALES
-#error currently iconv requires UTF-8 locales
-#endif
-
-
-enum {
- IC_WCHAR_T = 0xe0,
- IC_MULTIBYTE = 0xe0,
-#if __BYTE_ORDER == __BIG_ENDIAN
- IC_UCS_4 = 0xec,
- IC_UTF_32 = 0xe4,
- IC_UCS_2 = 0xe2,
- IC_UTF_16 = 0xea,
-#else
- IC_UCS_4 = 0xed,
- IC_UTF_32 = 0xe5,
- IC_UCS_2 = 0xe3,
- IC_UTF_16 = 0xeb,
-#endif
- IC_UTF_8 = 2,
- IC_ASCII = 1
-};
-
/* For the multibyte
* bit 0 means swap endian
* bit 1 means 2 byte
@@ -1237,15 +1189,23 @@ enum {
*
*/
+#if defined L_iconv && defined _LIBC
+/* Used externally only by iconv utility */
extern const unsigned char __iconv_codesets[];
libc_hidden_proto(__iconv_codesets)
+#endif
+
+#if defined L_iconv || defined L_iconv_main
+# ifdef L_iconv_main
+static
+# endif
const unsigned char __iconv_codesets[] =
"\x0a\xe0""WCHAR_T\x00" /* superset of UCS-4 but platform-endian */
#if __BYTE_ORDER == __BIG_ENDIAN
"\x08\xec""UCS-4\x00" /* always BE */
"\x0a\xec""UCS-4BE\x00"
"\x0a\xed""UCS-4LE\x00"
- "\x09\fe4""UTF-32\x00" /* platform endian with BOM */
+ "\x09\xe4""UTF-32\x00" /* platform endian with BOM */
"\x0b\xe4""UTF-32BE\x00"
"\x0b\xe5""UTF-32LE\x00"
"\x08\xe2""UCS-2\x00" /* always BE */
@@ -1271,17 +1231,57 @@ const unsigned char __iconv_codesets[] =
"\x08\x02""UTF-8\x00"
"\x0b\x01""US-ASCII\x00"
"\x07\x01""ASCII"; /* Must be last! (special case to save a nul) */
+#endif
+#if defined L_iconv && defined _LIBC
libc_hidden_data_def(__iconv_codesets)
+#endif
+
+
+#ifdef L_iconv
+
+#include <iconv.h>
+#include <string.h>
+#include <endian.h>
+#include <byteswap.h>
+
+#if (__BYTE_ORDER != __BIG_ENDIAN) && (__BYTE_ORDER != __LITTLE_ENDIAN)
+#error unsupported endianness for iconv
+#endif
+
+#ifndef __CTYPE_HAS_8_BIT_LOCALES
+#error currently iconv requires 8 bit locales
+#endif
+#ifndef __CTYPE_HAS_UTF_8_LOCALES
+#error currently iconv requires UTF-8 locales
+#endif
+
+
+enum {
+ IC_WCHAR_T = 0xe0,
+ IC_MULTIBYTE = 0xe0,
+#if __BYTE_ORDER == __BIG_ENDIAN
+ IC_UCS_4 = 0xec,
+ IC_UTF_32 = 0xe4,
+ IC_UCS_2 = 0xe2,
+ IC_UTF_16 = 0xea,
+#else
+ IC_UCS_4 = 0xed,
+ IC_UTF_32 = 0xe5,
+ IC_UCS_2 = 0xe3,
+ IC_UTF_16 = 0xeb,
+#endif
+ IC_UTF_8 = 2,
+ IC_ASCII = 1
+};
-/* Experimentally off - libc_hidden_proto(strcasecmp) */
static int find_codeset(const char *name)
{
const unsigned char *s;
int codeset;
- for (s = __iconv_codesets ; *s ; s += *s) {
- if (!strcasecmp(s+2, name)) {
+ for (s = __iconv_codesets; *s; s += *s) {
+ if (!strcasecmp((char*) (s + 2), name)) {
return s[1];
}
}
@@ -1291,7 +1291,7 @@ static int find_codeset(const char *name)
/* TODO: maybe CODESET_LIST + *s ??? */
/* 7bit is 1, UTF-8 is 2, 8-bit is >= 3 */
codeset = 2;
- s = __LOCALE_DATA_CODESET_LIST;
+ s = (const unsigned char *) __LOCALE_DATA_CODESET_LIST;
do {
++codeset; /* Increment codeset first. */
if (!strcasecmp(__LOCALE_DATA_CODESET_LIST+*s, name)) {
@@ -1311,9 +1311,9 @@ iconv_t weak_function iconv_open(const char *tocode, const char *fromcode)
&& ((fromcodeset = find_codeset(fromcode)) != 0)) {
if ((px = malloc(sizeof(_UC_iconv_t))) != NULL) {
px->tocodeset = tocodeset;
- px->tobom0 = px->tobom = (tocodeset & 0x10) >> 4;
+ px->tobom0 = px->tobom = (tocodeset >= 0xe0) ? (tocodeset & 0x10) >> 4 : 0;
px->fromcodeset0 = px->fromcodeset = fromcodeset;
- px->frombom0 = px->frombom = (fromcodeset & 0x10) >> 4;
+ px->frombom0 = px->frombom = (fromcodeset >= 0xe0) ? (fromcodeset & 0x10) >> 4 : 0;
px->skip_invalid_input = px->tostate.__mask
= px->fromstate.__mask = 0;
return (iconv_t) px;
@@ -1458,7 +1458,7 @@ size_t weak_function iconv(iconv_t cd, char **__restrict inbuf,
const __codeset_8_bit_t *c8b
= __locale_mmap->codeset_8_bit + px->fromcodeset - 3;
wc -= 0x80;
- wc = __UCLIBC_CURLOCALE_DATA.tbl8c2wc[
+ wc = __UCLIBC_CURLOCALE->tbl8c2wc[
(c8b->idx8c2wc[wc >> Cc2wc_IDX_SHIFT]
<< Cc2wc_IDX_SHIFT) + (wc & (Cc2wc_ROW_LEN - 1))];
if (!wc) {
@@ -1543,10 +1543,10 @@ size_t weak_function iconv(iconv_t cd, char **__restrict inbuf,
= __locale_mmap->codeset_8_bit + px->tocodeset - 3;
__uwchar_t u;
u = c8b->idx8wc2c[wc >> (Cwc2c_TI_SHIFT + Cwc2c_TT_SHIFT)];
- u = __UCLIBC_CURLOCALE_DATA.tbl8wc2c[(u << Cwc2c_TI_SHIFT)
+ u = __UCLIBC_CURLOCALE->tbl8wc2c[(u << Cwc2c_TI_SHIFT)
+ ((wc >> Cwc2c_TT_SHIFT)
& ((1 << Cwc2c_TI_SHIFT)-1))];
- wc = __UCLIBC_CURLOCALE_DATA.tbl8wc2c[Cwc2c_TI_LEN
+ wc = __UCLIBC_CURLOCALE->tbl8wc2c[Cwc2c_TI_LEN
+ (u << Cwc2c_TT_SHIFT)
+ (wc & ((1 << Cwc2c_TT_SHIFT)-1))];
if (wc) {
@@ -1565,172 +1565,4 @@ size_t weak_function iconv(iconv_t cd, char **__restrict inbuf,
}
return nrcount;
}
-
#endif
-/**********************************************************************/
-#ifdef L_iconv_main
-
-#include <string.h>
-#include <iconv.h>
-#include <stdarg.h>
-#include <libgen.h>
-
-extern const unsigned char __iconv_codesets[];
-
-#define IBUF BUFSIZ
-#define OBUF BUFSIZ
-
-char *progname;
-int hide_errors;
-
-static void error_msg(const char *fmt, ...)
- __attribute__ ((noreturn, format (printf, 1, 2)));
-
-static void error_msg(const char *fmt, ...)
-{
- va_list arg;
-
- if (!hide_errors) {
- fprintf(stderr, "%s: ", progname);
- va_start(arg, fmt);
- vfprintf(stderr, fmt, arg);
- va_end(arg);
- }
-
- exit(EXIT_FAILURE);
-}
-
-int main(int argc, char **argv)
-{
- FILE *ifile;
- FILE *ofile = stdout;
- const char *p;
- const char *s;
- static const char opt_chars[] = "tfocsl";
- /* 012345 */
- const char *opts[sizeof(opt_chars)]; /* last is infile name */
- iconv_t ic;
- char ibuf[IBUF];
- char obuf[OBUF];
- char *pi;
- char *po;
- size_t ni, no, r, pos;
-
- hide_errors = 0;
-
- for (s = opt_chars ; *s ; s++) {
- opts[ s - opt_chars ] = NULL;
- }
-
- progname = *argv;
- while (--argc) {
- p = *++argv;
- if ((*p != '-') || (*++p == 0)) {
- break;
- }
- do {
- if ((s = strchr(opt_chars,*p)) == NULL) {
- USAGE:
- s = basename(progname);
- fprintf(stderr,
- "%s [-cs] -f fromcode -t tocode [-o outputfile] [inputfile ...]\n"
- " or\n%s -l\n", s, s);
- return EXIT_FAILURE;
- }
- if ((s - opt_chars) < 3) {
- if ((--argc == 0) || opts[s - opt_chars]) {
- goto USAGE;
- }
- opts[s - opt_chars] = *++argv;
- } else {
- opts[s - opt_chars] = p;
- }
- } while (*++p);
- }
-
- if (opts[5]) { /* -l */
- fprintf(stderr, "Recognized codesets:\n");
- for (s = __iconv_codesets ; *s ; s += *s) {
- fprintf(stderr," %s\n", s+2);
- }
- s = __LOCALE_DATA_CODESET_LIST;
- do {
- fprintf(stderr," %s\n", __LOCALE_DATA_CODESET_LIST+ (unsigned char)(*s));
- } while (*++s);
-
- return EXIT_SUCCESS;
- }
-
- if (opts[4]) {
- hide_errors = 1;
- }
-
- if (!opts[0] || !opts[1]) {
- goto USAGE;
- }
- if ((ic = iconv_open(opts[0],opts[1])) == ((iconv_t)(-1))) {
- error_msg( "unsupported codeset in %s -> %s conversion\n", opts[0], opts[1]);
- }
- if (opts[3]) { /* -c */
- ((_UC_iconv_t *) ic)->skip_invalid_input = 1;
- }
-
- if ((s = opts[2]) != NULL) {
- if (!(ofile = fopen(s, "w"))) {
- error_msg( "couldn't open %s for writing\n", s);
- }
- }
-
- pos = ni = 0;
- do {
- if (!argc || ((**argv == '-') && !((*argv)[1]))) {
- ifile = stdin; /* we don't check for duplicates */
- } else if (!(ifile = fopen(*argv, "r"))) {
- error_msg( "couldn't open %s for reading\n", *argv);
- }
-
- while ((r = fread(ibuf + ni, 1, IBUF - ni, ifile)) > 0) {
- pos += r;
- ni += r;
- no = OBUF;
- pi = ibuf;
- po = obuf;
- if ((r = iconv(ic, &pi, &ni, &po, &no)) == ((size_t)(-1))) {
- if ((errno != EINVAL) && (errno != E2BIG)) {
- error_msg( "iconv failed at pos %lu : %m\n", (unsigned long) (pos - ni));
- }
- }
- if ((r = OBUF - no) > 0) {
- if (fwrite(obuf, 1, OBUF - no, ofile) < r) {
- error_msg( "write error\n");
- }
- }
- if (ni) { /* still bytes in buffer! */
- memmove(ibuf, pi, ni);
- }
- }
-
- if (ferror(ifile)) {
- error_msg( "read error\n");
- }
-
- ++argv;
-
- if (ifile != stdin) {
- fclose(ifile);
- }
-
- } while (--argc > 0);
-
- iconv_close(ic);
-
- if (ni) {
- error_msg( "incomplete sequence\n");
- }
-
- return (((_UC_iconv_t *) ic)->skip_invalid_input < 2)
- ? EXIT_SUCCESS : EXIT_FAILURE;
-}
-
-#endif
-/**********************************************************************/
diff --git a/libc/misc/wctype/Makefile.in b/libc/misc/wctype/Makefile.in
index f4210ebb0..d40c2d321 100644
--- a/libc/misc/wctype/Makefile.in
+++ b/libc/misc/wctype/Makefile.in
@@ -1,10 +1,12 @@
# 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.
#
+subdirs += libc/misc/wctype
+
# multi source _wctype.c
COM_SRC := \
iswalnum.c iswalpha.c iswcntrl.c iswdigit.c iswgraph.c \
@@ -12,23 +14,19 @@ COM_SRC := \
iswxdigit.c iswblank.c wctrans.c towctrans.c \
wctype.c iswctype.c towlower.c towupper.c
-CSRC :=
-ifeq ($(UCLIBC_HAS_WCHAR),y)
-CSRC += $(COM_SRC)
-endif
-ifeq ($(UCLIBC_HAS_XLOCALE),y)
-CSRC += $(patsubst %.c,%_l.c,$(COM_SRC))
-endif
+CSRC-y :=
+CSRC-$(UCLIBC_HAS_WCHAR) += $(COM_SRC)
+CSRC-$(UCLIBC_HAS_XLOCALE) += $(patsubst %.c,%_l.c,$(COM_SRC))
MISC_WCTYPE_DIR := $(top_srcdir)libc/misc/wctype
MISC_WCTYPE_OUT := $(top_builddir)libc/misc/wctype
-MISC_WCTYPE_SRC := $(patsubst %.c,$(MISC_WCTYPE_DIR)/%.c,$(CSRC))
-MISC_WCTYPE_OBJ := $(patsubst %.c,$(MISC_WCTYPE_OUT)/%.o,$(CSRC))
+MISC_WCTYPE_SRC := $(patsubst %.c,$(MISC_WCTYPE_DIR)/%.c,$(CSRC-y))
+MISC_WCTYPE_OBJ := $(patsubst %.c,$(MISC_WCTYPE_OUT)/%.o,$(CSRC-y))
libc-y += $(MISC_WCTYPE_OBJ)
-objclean-y += misc_wctype_objclean
+objclean-y += CLEAN_libc/misc/wctype
-misc_wctype_objclean:
- $(RM) $(MISC_WCTYPE_OUT)/*.{o,os}
+CLEAN_libc/misc/wctype:
+ $(do_rm) $(addprefix $(MISC_WCTYPE_OUT)/*., o os)
diff --git a/libc/misc/wctype/_wctype.c b/libc/misc/wctype/_wctype.c
index 25419b500..68fae8b54 100644
--- a/libc/misc/wctype/_wctype.c
+++ b/libc/misc/wctype/_wctype.c
@@ -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/>.
*/
/* ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION!
@@ -37,31 +37,8 @@
#include <stdint.h>
#include <bits/uClibc_uwchar.h>
-/* Experimentally off - libc_hidden_proto(strcmp) */
-libc_hidden_proto(tolower)
-libc_hidden_proto(toupper)
-libc_hidden_proto(towlower)
-libc_hidden_proto(towupper)
-libc_hidden_proto(towctrans)
-libc_hidden_proto(iswctype)
-
#if defined(__LOCALE_C_ONLY) && defined(__UCLIBC_DO_XLOCALE)
-#error xlocale functionality is not supported in stub locale mode.
-#endif
-
-#ifdef __UCLIBC_HAS_XLOCALE__
-#include <xlocale.h>
-libc_hidden_proto(towlower_l)
-libc_hidden_proto(towupper_l)
-libc_hidden_proto(towctrans_l)
-libc_hidden_proto(iswctype_l)
-#elif defined __UCLIBC_HAS_CTYPE_TABLES__
-libc_hidden_proto(__ctype_b)
-#endif /* __UCLIBC_HAS_XLOCALE__ */
-
-#ifdef __UCLIBC_HAS_CTYPE_TABLES__
-libc_hidden_proto(__C_ctype_tolower)
-libc_hidden_proto(__C_ctype_toupper)
+# error xlocale functionality is not supported in stub locale mode.
#endif
/* We know wide char support is enabled. We wouldn't be here otherwise. */
@@ -70,43 +47,9 @@ libc_hidden_proto(__C_ctype_toupper)
* towctrans function. */
/* #define SMALL_UPLOW */
-/**********************************************************************/
-#ifdef __UCLIBC_MJN3_ONLY__
-#ifdef L_iswspace
-/* generates one warning */
-#warning TODO: Fix the __CTYPE_* codes!
-#endif
-#endif /* __UCLIBC_MJN3_ONLY__ */
-
-#if 1
-/* 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
+
+/* Pull in __CTYPE_xxx constants */
+#include <bits/uClibc_charclass.h>
/* The following is used to implement wctype(), but it is defined
@@ -151,18 +94,18 @@ enum {
/*--------------------------------------------------------------------*/
#ifdef __UCLIBC_MJN3_ONLY__
-#ifdef L_iswspace
+# ifdef L_iswspace
/* generates one warning */
-#warning TODO: Fix WC* defines!
+# warning TODO: Fix WC* defines!
+# endif
#endif
-#endif /* __UCLIBC_MJN3_ONLY__ */
-#define ENCODING ((__UCLIBC_CURLOCALE_DATA).encoding)
+#define ENCODING (__UCLIBC_CURLOCALE->encoding)
-#define WCctype ((__UCLIBC_CURLOCALE_DATA).tblwctype)
-#define WCuplow ((__UCLIBC_CURLOCALE_DATA).tblwuplow)
-#define WCcmob ((__UCLIBC_CURLOCALE_DATA).tblwcomb)
-#define WCuplow_diff ((__UCLIBC_CURLOCALE_DATA).tblwuplow_diff)
+#define WCctype (__UCLIBC_CURLOCALE->tblwctype)
+#define WCuplow (__UCLIBC_CURLOCALE->tblwuplow)
+#define WCcmob (__UCLIBC_CURLOCALE->tblwcomb)
+#define WCuplow_diff (__UCLIBC_CURLOCALE->tblwuplow_diff)
#define WC_TABLE_DOMAIN_MAX __LOCALE_DATA_WC_TABLE_DOMAIN_MAX
@@ -193,28 +136,27 @@ enum {
#ifdef __UCLIBC_DO_XLOCALE
#define ISW_FUNC_BODY(NAME) \
-libc_hidden_proto(__PASTE3(isw,NAME,_l)); \
int __PASTE3(isw,NAME,_l) (wint_t wc, __locale_t l) \
{ \
return iswctype_l(wc, __PASTE2(_CTYPE_is,NAME), l); \
-} \
-libc_hidden_def(__PASTE3(isw,NAME,_l))
+}
#else /* __UCLIBC_DO_XLOCALE */
#define ISW_FUNC_BODY(NAME) \
-libc_hidden_proto(__PASTE2(isw,NAME)); \
int __PASTE2(isw,NAME) (wint_t wc) \
{ \
return iswctype(wc, __PASTE2(_CTYPE_is,NAME)); \
-} \
-libc_hidden_def(__PASTE2(isw,NAME))
+}
#endif /* __UCLIBC_DO_XLOCALE */
/**********************************************************************/
#if defined(L_iswalnum) || defined(L_iswalnum_l)
ISW_FUNC_BODY(alnum);
+# ifdef L_iswalnum
+libc_hidden_def(iswalnum)
+# endif
#endif
/**********************************************************************/
@@ -251,6 +193,9 @@ ISW_FUNC_BODY(graph);
#if defined(L_iswlower) || defined(L_iswlower_l)
ISW_FUNC_BODY(lower);
+# ifdef L_iswlower
+libc_hidden_def(iswlower)
+# endif
#endif
/**********************************************************************/
@@ -269,12 +214,20 @@ ISW_FUNC_BODY(punct);
#if defined(L_iswspace) || defined(L_iswspace_l)
ISW_FUNC_BODY(space);
+# ifdef L_iswspace
+libc_hidden_def(iswspace)
+# else
+libc_hidden_def(iswspace_l)
+# endif
#endif
/**********************************************************************/
#if defined(L_iswupper) || defined(L_iswupper_l)
ISW_FUNC_BODY(upper);
+# ifdef L_iswupper
+libc_hidden_def(iswupper)
+# endif
#endif
/**********************************************************************/
@@ -286,72 +239,66 @@ ISW_FUNC_BODY(xdigit);
/**********************************************************************/
#if defined(L_towlower) || defined(L_towlower_l)
-#ifdef L_towlower
-#define TOWLOWER(w) towlower(w)
-#else /* L_towlower */
-#define TOWLOWER(w) towlower_l(w, __locale_t locale)
-#undef __UCLIBC_CURLOCALE_DATA
-#undef __UCLIBC_CURLOCALE
-#define __UCLIBC_CURLOCALE_DATA (*locale)
-#define __UCLIBC_CURLOCALE (locale)
-#endif /* L_towlower */
+# ifdef L_towlower
+# define TOWLOWER(w) towlower(w)
+# else
+# define TOWLOWER(w) towlower_l(w, __locale_t locale)
+# undef __UCLIBC_CURLOCALE
+# define __UCLIBC_CURLOCALE (locale)
+# endif
-#ifdef __UCLIBC_HAS_XLOCALE__
-#define TOWCTRANS(w,d) towctrans_l(w,d, __UCLIBC_CURLOCALE)
-#else /* __UCLIBC_HAS_XLOCALE__ */
-#define TOWCTRANS(w,d) towctrans(w,d)
-#endif /* __UCLIBC_HAS_XLOCALE__ */
+# ifdef __UCLIBC_HAS_XLOCALE__
+# define TOWCTRANS(w,d) towctrans_l(w,d, __UCLIBC_CURLOCALE)
+# else
+# define TOWCTRANS(w,d) towctrans(w,d)
+# endif
-#define __C_towlower(wc) \
- ((((__uwchar_t)(wc)) <= 0x7f) ? (__C_ctype_tolower)[(wc)] : (wc))
+# define __C_towlower(wc) \
+ (((__uwchar_t)(wc) <= 0x7f) ? (__C_ctype_tolower)[(wc)] : (wc))
-#ifdef __LOCALE_C_ONLY
+# ifdef __LOCALE_C_ONLY
wint_t towlower(wint_t wc)
{
-#ifdef __UCLIBC_HAS_CTYPE_TABLES__
+# ifdef __UCLIBC_HAS_CTYPE_TABLES__
return __C_towlower(wc);
-#else
- return (wc == ((unsigned int)(wc)))
- ? __C_tolower(((unsigned int)(wc)))
+# else
+ return (wc == (unsigned)wc)
+ ? __C_tolower((unsigned)wc)
: 0;
-#endif
+# endif
}
-#else /* __LOCALE_C_ONLY */
+# else /* __LOCALE_C_ONLY */
-#ifdef SMALL_UPLOW
-
-#if defined(L_towlower) && defined(__UCLIBC_HAS_XLOCALE__)
+# ifdef SMALL_UPLOW
+# if defined(L_towlower) && defined(__UCLIBC_HAS_XLOCALE__)
wint_t towlower(wint_t wc)
{
return towctrans_l(wc, _CTYPE_tolower, __UCLIBC_CURLOCALE);
}
-
-#else /* defined(L_towlower) && defined(__UCLIBC_HAS_XLOCALE__) */
-
+# else /* defined(L_towlower) && defined(__UCLIBC_HAS_XLOCALE__) */
wint_t TOWLOWER(wint_t wc)
{
return TOWCTRANS(wc, _CTYPE_tolower);
}
+# endif /* defined(L_towlower) && defined(__UCLIBC_HAS_XLOCALE__) */
-#endif /* defined(L_towlower) && defined(__UCLIBC_HAS_XLOCALE__) */
+# else /* SMALL_UPLOW */
-#else /* SMALL_UPLOW */
-
-#if defined(L_towlower) && defined(__UCLIBC_HAS_XLOCALE__)
+# if defined(L_towlower) && defined(__UCLIBC_HAS_XLOCALE__)
wint_t towlower(wint_t wc)
{
return towlower_l(wc, __UCLIBC_CURLOCALE);
}
-#else /* defined(L_towlower) && defined(__UCLIBC_HAS_XLOCALE__) */
+# else /* defined(L_towlower) && defined(__UCLIBC_HAS_XLOCALE__) */
wint_t TOWLOWER(wint_t wc)
{
- unsigned int sc, n, i;
+ unsigned sc, n, i;
__uwchar_t u = wc;
if (ENCODING == __ctype_encoding_7_bit) {
@@ -365,101 +312,89 @@ wint_t TOWLOWER(wint_t wc)
n = u & ((1 << WCuplow_II_SHIFT) - 1);
u >>= WCuplow_II_SHIFT;
- i = ((unsigned int) WCuplow[u]) << WCuplow_II_SHIFT;
- i = ((unsigned int) WCuplow[WCuplow_II_LEN + i + n])
- << WCuplow_TI_SHIFT;
- i = ((unsigned int) WCuplow[WCuplow_II_LEN + WCuplow_TI_LEN
- + i + sc]) << 1;
+ i = ((unsigned) WCuplow[u]) << WCuplow_II_SHIFT;
+ i = ((unsigned) WCuplow[WCuplow_II_LEN + i + n]) << WCuplow_TI_SHIFT;
+ i = ((unsigned) WCuplow[WCuplow_II_LEN + WCuplow_TI_LEN + i + sc]) << 1;
wc += WCuplow_diff[i + 1];
}
return wc;
}
-#endif /* defined(L_towlower) && defined(__UCLIBC_HAS_XLOCALE__) */
+# endif /* defined(L_towlower) && defined(__UCLIBC_HAS_XLOCALE__) */
-#endif /* SMALL_UPLOW */
+# endif /* SMALL_UPLOW */
-#ifdef L_towlower_l
+# ifdef L_towlower_l
libc_hidden_def(towlower_l)
-#endif /* L_towlower_l */
+# endif
-#endif /* __LOCALE_C_ONLY */
+# endif /* __LOCALE_C_ONLY */
-#ifndef L_towlower_l
+# ifndef L_towlower_l
libc_hidden_def(towlower)
-#endif
+# endif
#endif
/**********************************************************************/
#if defined(L_towupper) || defined(L_towupper_l)
-#ifdef L_towupper
-#define TOWUPPER(w) towupper(w)
-#else /* L_towupper */
-#define TOWUPPER(w) towupper_l(w, __locale_t locale)
-#undef __UCLIBC_CURLOCALE_DATA
-#undef __UCLIBC_CURLOCALE
-#define __UCLIBC_CURLOCALE_DATA (*locale)
-#define __UCLIBC_CURLOCALE (locale)
-#endif /* L_towupper */
+# ifdef L_towupper
+# define TOWUPPER(w) towupper(w)
+# else
+# define TOWUPPER(w) towupper_l(w, __locale_t locale)
+# undef __UCLIBC_CURLOCALE
+# define __UCLIBC_CURLOCALE (locale)
+# endif
-#ifdef __UCLIBC_HAS_XLOCALE__
-#define TOWCTRANS(w,d) towctrans_l(w,d, __UCLIBC_CURLOCALE)
-#else /* __UCLIBC_HAS_XLOCALE__ */
-#define TOWCTRANS(w,d) towctrans(w,d)
-#endif /* __UCLIBC_HAS_XLOCALE__ */
+# ifdef __UCLIBC_HAS_XLOCALE__
+# define TOWCTRANS(w,d) towctrans_l(w,d, __UCLIBC_CURLOCALE)
+# else
+# define TOWCTRANS(w,d) towctrans(w,d)
+# endif
-#define __C_towupper(wc) \
- ((((__uwchar_t)(wc)) <= 0x7f) ? (__C_ctype_toupper)[(wc)] : (wc))
+# define __C_towupper(wc) \
+ (((__uwchar_t)(wc) <= 0x7f) ? (__C_ctype_toupper)[(wc)] : (wc))
-#ifdef __LOCALE_C_ONLY
+# ifdef __LOCALE_C_ONLY
wint_t towupper(wint_t wc)
{
-#ifdef __UCLIBC_HAS_CTYPE_TABLES__
+# ifdef __UCLIBC_HAS_CTYPE_TABLES__
return __C_towupper(wc);
-#else
- return (wc == ((unsigned int)(wc)))
- ? __C_toupper(((unsigned int)(wc)))
+# else
+ return (wc == (unsigned)wc)
+ ? __C_toupper((unsigned)wc)
: 0;
-#endif
-
+# endif
}
-#else /* __LOCALE_C_ONLY */
-
-#ifdef SMALL_UPLOW
+# else /* __LOCALE_C_ONLY */
-#if defined(L_towupper) && defined(__UCLIBC_HAS_XLOCALE__)
+# ifdef SMALL_UPLOW
+# if defined(L_towupper) && defined(__UCLIBC_HAS_XLOCALE__)
wint_t towupper(wint_t wc)
{
return towctrans_l(wc, _CTYPE_toupper, __UCLIBC_CURLOCALE);
}
-
-#else /* defined(L_towupper) && defined(__UCLIBC_HAS_XLOCALE__) */
-
+# else
wint_t TOWUPPER(wint_t wc)
{
return TOWCTRANS(wc, _CTYPE_toupper);
}
+# endif
-#endif /* defined(L_towupper) && defined(__UCLIBC_HAS_XLOCALE__) */
-
-#else /* SMALL_UPLOW */
-
-#if defined(L_towupper) && defined(__UCLIBC_HAS_XLOCALE__)
+# else /* SMALL_UPLOW */
+# if defined(L_towupper) && defined(__UCLIBC_HAS_XLOCALE__)
wint_t towupper(wint_t wc)
{
return towupper_l(wc, __UCLIBC_CURLOCALE);
}
-
-#else /* defined(L_towupper) && defined(__UCLIBC_HAS_XLOCALE__) */
-
+# else /* defined(L_towupper) && defined(__UCLIBC_HAS_XLOCALE__) */
wint_t TOWUPPER(wint_t wc)
{
- unsigned int sc, n, i;
+ unsigned sc, n, i;
__uwchar_t u = wc;
if (ENCODING == __ctype_encoding_7_bit) {
@@ -473,38 +408,33 @@ wint_t TOWUPPER(wint_t wc)
n = u & ((1 << WCuplow_II_SHIFT) - 1);
u >>= WCuplow_II_SHIFT;
- i = ((unsigned int) WCuplow[u]) << WCuplow_II_SHIFT;
- i = ((unsigned int) WCuplow[WCuplow_II_LEN + i + n])
- << WCuplow_TI_SHIFT;
- i = ((unsigned int) WCuplow[WCuplow_II_LEN + WCuplow_TI_LEN
- + i + sc]) << 1;
+ i = ((unsigned) WCuplow[u]) << WCuplow_II_SHIFT;
+ i = ((unsigned) WCuplow[WCuplow_II_LEN + i + n]) << WCuplow_TI_SHIFT;
+ i = ((unsigned) WCuplow[WCuplow_II_LEN + WCuplow_TI_LEN + i + sc]) << 1;
wc += WCuplow_diff[i];
}
return wc;
}
+# endif /* defined(L_towupper) && defined(__UCLIBC_HAS_XLOCALE__) */
-#endif /* defined(L_towupper) && defined(__UCLIBC_HAS_XLOCALE__) */
+# endif /* SMALL_UPLOW */
-#endif /* SMALL_UPLOW */
-
-#ifdef L_towupper_l
+# ifdef L_towupper_l
libc_hidden_def(towupper_l)
-#endif /* L_towupper_l */
+# endif
-#endif /* __LOCALE_C_ONLY */
+# endif /* __LOCALE_C_ONLY */
-#ifndef L_towupper_l
+# ifndef L_towupper_l
libc_hidden_def(towupper)
-#endif
+# endif
#endif
/**********************************************************************/
#ifdef L_wctype
static const unsigned char typestring[] = __CTYPE_TYPESTRING;
-/* extern const unsigned char typestring[]; */
-libc_hidden_proto(wctype)
wctype_t wctype(const char *property)
{
const unsigned char *p;
@@ -513,7 +443,7 @@ wctype_t wctype(const char *property)
p = typestring;
i = 1;
do {
- if (!strcmp(property, ++p)) {
+ if (!strcmp(property, (const char *) ++p)) {
return i;
}
++i;
@@ -530,17 +460,13 @@ libc_hidden_def(wctype)
#ifdef L_wctype_l
#ifdef __UCLIBC_MJN3_ONLY__
-#warning REMINDER: Currently wctype_l simply calls wctype.
-#endif /* __UCLIBC_MJN3_ONLY__ */
-
-libc_hidden_proto(wctype)
+# warning REMINDER: Currently wctype_l simply calls wctype.
+#endif
-libc_hidden_proto(wctype_l)
wctype_t wctype_l (const char *property, __locale_t locale)
{
return wctype(property);
}
-libc_hidden_def(wctype_l)
#endif
/**********************************************************************/
@@ -548,24 +474,25 @@ libc_hidden_def(wctype_l)
#define __C_iswdigit(c) \
((sizeof(c) == sizeof(char)) \
- ? (((unsigned char)((c) - '0')) < 10) \
- : (((__uwchar_t)((c) - '0')) < 10))
+ ? ((unsigned char)((c) - '0') < 10) \
+ : ((__uwchar_t)((c) - '0') < 10) \
+ )
#define __C_iswxdigit(c) \
(__C_iswdigit(c) \
|| ((sizeof(c) == sizeof(char)) \
- ? (((unsigned char)((((c)) | 0x20) - 'a')) < 6) \
- : (((__uwchar_t)((((c)) | 0x20) - 'a')) < 6)))
+ ? ((unsigned char)(((c) | 0x20) - 'a') < 6) \
+ : ((__uwchar_t)(((c) | 0x20) - 'a') < 6) \
+ ) \
+ )
#ifdef __UCLIBC_MJN3_ONLY__
-#ifdef L_iswctype
-#warning CONSIDER: Change to bit shift? would need to sync with wctype.h
+# ifdef L_iswctype
+# warning CONSIDER: Change to bit shift? would need to sync with wctype.h
+# endif
#endif
-#endif /* __UCLIBC_MJN3_ONLY__ */
-
#ifdef __UCLIBC_HAS_CTYPE_TABLES__
-#if !defined(__UCLIBC_HAS_XLOCALE__) || defined(L_iswctype_l)
-
+# if !defined(__UCLIBC_HAS_XLOCALE__) || defined(L_iswctype_l)
static const unsigned short int desc2flag[] = {
[_CTYPE_unclassified] = 0,
[_CTYPE_isalnum] = (unsigned short int) _ISwalnum,
@@ -581,9 +508,8 @@ static const unsigned short int desc2flag[] = {
[_CTYPE_isupper] = (unsigned short int) _ISwupper,
[_CTYPE_isxdigit] = (unsigned short int) _ISwxdigit,
};
-
-#endif /* defined(L_iswctype_L) || defined(__LOCALE_C_ONLY) */
-#endif /* __UCLIBC_HAS_CTYPE_TABLES__ */
+# endif
+#endif
#ifdef __LOCALE_C_ONLY
@@ -593,9 +519,9 @@ int iswctype(wint_t wc, wctype_t desc)
{
/* Note... wctype_t is unsigned. */
- if ((((__uwchar_t) wc) <= 0x7f)
- && (desc < (sizeof(desc2flag)/sizeof(desc2flag[0])))
- ) {
+ if ((__uwchar_t) wc <= 0x7f
+ && desc < (sizeof(desc2flag) / sizeof(desc2flag[0]))
+ ) {
return __isctype(wc, desc2flag[desc]);
}
return 0;
@@ -607,32 +533,32 @@ int iswctype(wint_t wc, wctype_t desc)
{
/* This is lame, but it is here just to get it working for now. */
- if (wc == ((unsigned int)(wc))) {
- switch(desc) {
+ if (wc == (unsigned)wc) {
+ switch (desc) {
case _CTYPE_isupper:
- return __C_isupper((unsigned int)(wc));
+ return __C_isupper((unsigned)wc);
case _CTYPE_islower:
- return __C_islower((unsigned int)(wc));
+ return __C_islower((unsigned)wc);
case _CTYPE_isalpha:
- return __C_isalpha((unsigned int)(wc));
+ return __C_isalpha((unsigned)wc);
case _CTYPE_isdigit:
- return __C_isdigit((unsigned int)(wc));
+ return __C_isdigit((unsigned)wc);
case _CTYPE_isxdigit:
- return __C_isxdigit((unsigned int)(wc));
+ return __C_isxdigit((unsigned)wc);
case _CTYPE_isspace:
- return __C_isspace((unsigned int)(wc));
+ return __C_isspace((unsigned)wc);
case _CTYPE_isprint:
- return __C_isprint((unsigned int)(wc));
+ return __C_isprint((unsigned)wc);
case _CTYPE_isgraph:
- return __C_isgraph((unsigned int)(wc));
+ return __C_isgraph((unsigned)wc);
case _CTYPE_isblank:
- return __C_isblank((unsigned int)(wc));
+ return __C_isblank((unsigned)wc);
case _CTYPE_iscntrl:
- return __C_iscntrl((unsigned int)(wc));
+ return __C_iscntrl((unsigned)wc);
case _CTYPE_ispunct:
- return __C_ispunct((unsigned int)(wc));
+ return __C_ispunct((unsigned)wc);
case _CTYPE_isalnum:
- return __C_isalnum((unsigned int)(wc));
+ return __C_isalnum((unsigned)wc);
default:
break;
}
@@ -645,20 +571,18 @@ int iswctype(wint_t wc, wctype_t desc)
#else /* __LOCALE_C_ONLY */
#ifdef __UCLIBC_MJN3_ONLY__
-#ifdef L_iswctype
-#warning CONSIDER: Handle combining class?
+# ifdef L_iswctype
+# warning CONSIDER: Handle combining class?
+# endif
#endif
-#endif /* __UCLIBC_MJN3_ONLY__ */
#ifdef L_iswctype
-#define ISWCTYPE(w,d) iswctype(w,d)
-#else /* L_iswctype */
-#define ISWCTYPE(w,d) iswctype_l(w,d, __locale_t locale)
-#undef __UCLIBC_CURLOCALE_DATA
-#undef __UCLIBC_CURLOCALE
-#define __UCLIBC_CURLOCALE_DATA (*locale)
-#define __UCLIBC_CURLOCALE (locale)
-#endif /* L_iswctype */
+# define ISWCTYPE(w,d) iswctype(w,d)
+#else
+# define ISWCTYPE(w,d) iswctype_l(w,d, __locale_t locale)
+# undef __UCLIBC_CURLOCALE
+# define __UCLIBC_CURLOCALE (locale)
+#endif
#if defined(L_iswctype) && defined(__UCLIBC_HAS_XLOCALE__)
@@ -671,12 +595,12 @@ int iswctype(wint_t wc, wctype_t desc)
int ISWCTYPE(wint_t wc, wctype_t desc)
{
- unsigned int sc, n, i0, i1;
+ unsigned sc, n, i0, i1;
unsigned char d = __CTYPE_unclassified;
- if ((ENCODING != __ctype_encoding_7_bit) || (((__uwchar_t) wc) <= 0x7f)){
+ if ((ENCODING != __ctype_encoding_7_bit) || ((__uwchar_t)wc <= 0x7f)) {
if (desc < _CTYPE_iswxdigit) {
- if (((__uwchar_t) wc) <= WC_TABLE_DOMAIN_MAX) {
+ if ((__uwchar_t)wc <= WC_TABLE_DOMAIN_MAX) {
/* From here on, we know wc > 0. */
sc = wc & WCctype_TI_MASK;
wc >>= WCctype_TI_SHIFT;
@@ -690,26 +614,24 @@ int ISWCTYPE(wint_t wc, wctype_t desc)
d = WCctype[WCctype_II_LEN + WCctype_TI_LEN + i1 + (sc >> 1)];
d = (sc & 1) ? (d >> 4) : (d & 0xf);
- } else if ( ((((__uwchar_t)(wc - 0xe0020UL)) <= 0x5f)
- || (wc == 0xe0001UL))
- || ( (((__uwchar_t)(wc - 0xf0000UL)) < 0x20000UL)
- && ((wc & 0xffffU) <= 0xfffdU))
- ) {
+ } else if ((__uwchar_t)(wc - 0xe0020UL) <= 0x5f
+ || wc == 0xe0001UL
+ || (((__uwchar_t)(wc - 0xf0000UL) < 0x20000UL) && ((wc & 0xffffU) <= 0xfffdU))
+ ) {
d = __CTYPE_punct;
}
#if 0
- return ( ((unsigned char)(d - ctype_range[2*desc]))
- <= ctype_range[2*desc + 1] )
+ return ((unsigned char)(d - ctype_range[2*desc]) <= ctype_range[2*desc + 1])
&& ((desc != _CTYPE_iswblank) || (d & 1));
#else
- return (__UCLIBC_CURLOCALE_DATA).code2flag[d] & desc2flag[desc];
+ return __UCLIBC_CURLOCALE->code2flag[d] & desc2flag[desc];
#endif
}
#ifdef __UCLIBC_MJN3_ONLY__
-#warning TODO: xdigit really needs to be handled better. Remember only for ascii!
-#endif /* __UCLIBC_MJN3_ONLY__ */
+# warning TODO: xdigit really needs to be handled better. Remember only for ascii!
+#endif
/* TODO - Add locale-specific classifications. */
return (desc == _CTYPE_iswxdigit) ? __C_iswxdigit(wc) : 0;
}
@@ -720,13 +642,13 @@ int ISWCTYPE(wint_t wc, wctype_t desc)
#ifdef L_iswctype_l
libc_hidden_def(iswctype_l)
-#endif /* L_iswctype_l */
+#endif
#endif /* __LOCALE_C_ONLY */
#ifdef L_iswctype
libc_hidden_def(iswctype)
-#endif /* L_iswctype */
+#endif
#endif
/**********************************************************************/
@@ -736,24 +658,23 @@ libc_hidden_def(iswctype)
/* Minimal support for C/POSIX locale. */
-#ifndef _tolower
-#warning _tolower is undefined!
-#define _tolower(c) tolower(c)
-#endif
-#ifndef _toupper
-#warning _toupper is undefined!
-#define _toupper(c) toupper(c)
-#endif
-
wint_t towctrans(wint_t wc, wctrans_t desc)
{
- if (((unsigned int)(desc - _CTYPE_tolower))
- <= (_CTYPE_toupper - _CTYPE_tolower)
- ) {
+ if ((unsigned)(desc - _CTYPE_tolower) <= (_CTYPE_toupper - _CTYPE_tolower)) {
/* Transliteration is either tolower or toupper. */
- if (((__uwchar_t) wc) <= 0x7f) {
+#if 0
+/* I think it's wrong: _toupper(c) assumes that c is a *lowercase* *letter* -
+ * it is defined as ((c) ^ 0x20)! */
+ if ((__uwchar_t) wc <= 0x7f) {
return (desc == _CTYPE_tolower) ? _tolower(wc) : _toupper(wc);
}
+#endif
+ __uwchar_t c = wc | 0x20; /* lowercase if it's a letter */
+ if (c >= 'a' && c <= 'z') {
+ if (desc == _CTYPE_toupper)
+ c &= ~0x20; /* uppercase */
+ return c;
+ }
} else {
__set_errno(EINVAL); /* Invalid transliteration. */
}
@@ -763,22 +684,20 @@ wint_t towctrans(wint_t wc, wctrans_t desc)
#else /* __LOCALE_C_ONLY */
#ifdef L_towctrans
-#define TOWCTRANS(w,d) towctrans(w,d)
-#else /* L_towctrans */
-#define TOWCTRANS(w,d) towctrans_l(w,d, __locale_t locale)
-#undef __UCLIBC_CURLOCALE_DATA
-#undef __UCLIBC_CURLOCALE
-#define __UCLIBC_CURLOCALE_DATA (*locale)
-#define __UCLIBC_CURLOCALE (locale)
-#endif /* L_towctrans */
+# define TOWCTRANS(w,d) towctrans(w,d)
+#else
+# define TOWCTRANS(w,d) towctrans_l(w,d, __locale_t locale)
+# undef __UCLIBC_CURLOCALE
+# define __UCLIBC_CURLOCALE (locale)
+#endif
#ifdef __UCLIBC_HAS_XLOCALE__
-#define TOWLOWER(w,l) towlower_l(w,l)
-#define TOWUPPER(w,l) towupper_l(w,l)
-#else /* __UCLIBC_HAS_XLOCALE__ */
-#define TOWLOWER(w,l) towlower(w)
-#define TOWUPPER(w,l) towupper(w)
-#endif /* __UCLIBC_HAS_XLOCALE__ */
+# define TOWLOWER(w,l) towlower_l(w,l)
+# define TOWUPPER(w,l) towupper_l(w,l)
+#else
+# define TOWLOWER(w,l) towlower(w)
+# define TOWUPPER(w,l) towupper(w)
+#endif
#if defined(L_towctrans) && defined(__UCLIBC_HAS_XLOCALE__)
@@ -793,48 +712,43 @@ wint_t towctrans(wint_t wc, wctrans_t desc)
wint_t TOWCTRANS(wint_t wc, wctrans_t desc)
{
- unsigned int sc, n, i;
+ unsigned sc, n, i;
__uwchar_t u = wc;
/* TODO - clean up */
if (ENCODING == __ctype_encoding_7_bit) {
- if ((((__uwchar_t) wc) > 0x7f)
- || (((unsigned int)(desc - _CTYPE_tolower))
- > (_CTYPE_toupper - _CTYPE_tolower))
- ){
+ if ((__uwchar_t)wc > 0x7f
+ || (unsigned)(desc - _CTYPE_tolower) > (_CTYPE_toupper - _CTYPE_tolower)
+ ) {
/* We're in the C/POSIX locale, so ignore non-ASCII values
* as well an any mappings other than toupper or tolower. */
return wc;
}
}
- if (((unsigned int)(desc - _CTYPE_tolower))
- <= (_CTYPE_totitle - _CTYPE_tolower)
- ) {
+ if ((unsigned)(desc - _CTYPE_tolower) <= (_CTYPE_totitle - _CTYPE_tolower)) {
if (u <= WC_TABLE_DOMAIN_MAX) {
sc = u & ((1 << WCuplow_TI_SHIFT) - 1);
u >>= WCuplow_TI_SHIFT;
n = u & ((1 << WCuplow_II_SHIFT) - 1);
u >>= WCuplow_II_SHIFT;
- i = ((unsigned int) WCuplow[u]) << WCuplow_II_SHIFT;
- i = ((unsigned int) WCuplow[WCuplow_II_LEN + i + n])
- << WCuplow_TI_SHIFT;
- i = ((unsigned int) WCuplow[WCuplow_II_LEN + WCuplow_TI_LEN
- + i + sc]) << 1;
+ i = ((unsigned) WCuplow[u]) << WCuplow_II_SHIFT;
+ i = ((unsigned) WCuplow[WCuplow_II_LEN + i + n]) << WCuplow_TI_SHIFT;
+ i = ((unsigned) WCuplow[WCuplow_II_LEN + WCuplow_TI_LEN + i + sc]) << 1;
if (desc == _CTYPE_tolower) {
++i;
}
wc += WCuplow_diff[i];
if (desc == _CTYPE_totitle) {
#ifdef __UCLIBC_MJN3_ONLY__
-#warning TODO: Verify totitle special cases!
-#endif /* __UCLIBC_MJN3_ONLY__ */
+# warning TODO: Verify totitle special cases!
+#endif
/* WARNING! These special cases work for glibc 2.2.4. Changes
* may be needed if the glibc locale tables are updated. */
- if ( (((__uwchar_t)(wc - 0x1c4)) <= (0x1cc - 0x1c4))
- || (wc == 0x1f1)
- ) {
+ if ((__uwchar_t)(wc - 0x1c4) <= (0x1cc - 0x1c4)
+ || wc == 0x1f1
+ ) {
++wc;
}
}
@@ -852,10 +766,9 @@ wint_t TOWCTRANS(wint_t wc, wctrans_t desc)
wint_t TOWCTRANS(wint_t wc, wctrans_t desc)
{
if (ENCODING == __ctype_encoding_7_bit) {
- if ((((__uwchar_t) wc) > 0x7f)
- || (((unsigned int)(desc - _CTYPE_tolower))
- > (_CTYPE_toupper - _CTYPE_tolower))
- ){
+ if ((__uwchar_t)wc > 0x7f
+ || (unsigned)(desc - _CTYPE_tolower) > (_CTYPE_toupper - _CTYPE_tolower)
+ ) {
/* We're in the C/POSIX locale, so ignore non-ASCII values
* as well an any mappings other than toupper or tolower. */
return wc;
@@ -864,19 +777,18 @@ wint_t TOWCTRANS(wint_t wc, wctrans_t desc)
if (desc == _CTYPE_tolower) {
return TOWLOWER(wc, __UCLIBC_CURLOCALE);
- } else if (((unsigned int)(desc - _CTYPE_toupper))
- <= (_CTYPE_totitle - _CTYPE_toupper)
- ) {
+ }
+ if ((unsigned)(desc - _CTYPE_toupper) <= (_CTYPE_totitle - _CTYPE_toupper)) {
wc = TOWUPPER(wc, __UCLIBC_CURLOCALE);
if (desc == _CTYPE_totitle) {
#ifdef __UCLIBC_MJN3_ONLY__
-#warning TODO: Verify totitle special cases!
-#endif /* __UCLIBC_MJN3_ONLY__ */
+# warning TODO: Verify totitle special cases!
+#endif
/* WARNING! These special cases work for glibc 2.2.4. Changes
* may be needed if the glibc locale tables are updated. */
- if ( (((__uwchar_t)(wc - 0x1c4)) <= (0x1cc - 0x1c4))
- || (wc == 0x1f1)
- ) {
+ if ((__uwchar_t)(wc - 0x1c4) <= (0x1cc - 0x1c4)
+ || wc == 0x1f1
+ ) {
++wc;
}
}
@@ -893,7 +805,7 @@ wint_t TOWCTRANS(wint_t wc, wctrans_t desc)
#ifdef L_towctrans_l
libc_hidden_def(towctrans_l)
-#endif /* L_towctrans_l */
+#endif
#endif /* __LOCALE_C_ONLY */
@@ -907,16 +819,15 @@ libc_hidden_def(towctrans)
static const char transstring[] = __CTYPE_TRANSTRING;
-libc_hidden_proto(wctrans)
wctrans_t wctrans(const char *property)
{
const unsigned char *p;
int i;
- p = transstring;
+ p = (const unsigned char *) transstring;
i = 1;
do {
- if (!strcmp(property, ++p)) {
+ if (!strcmp(property, (const char*) ++p)) {
return i;
}
++i;
@@ -932,11 +843,9 @@ libc_hidden_def(wctrans)
/**********************************************************************/
#ifdef L_wctrans_l
-#ifdef __UCLIBC_MJN3_ONLY__
-#warning REMINDER: Currently wctrans_l simply calls wctrans.
-#endif /* __UCLIBC_MJN3_ONLY__ */
-
-libc_hidden_proto(wctrans)
+# ifdef __UCLIBC_MJN3_ONLY__
+# warning REMINDER: Currently wctrans_l simply calls wctrans.
+# endif
wctrans_t wctrans_l(const char *property, __locale_t locale)
{
diff --git a/libc/misc/wordexp/Makefile.in b/libc/misc/wordexp/Makefile.in
index 526807f25..3d642488b 100644
--- a/libc/misc/wordexp/Makefile.in
+++ b/libc/misc/wordexp/Makefile.in
@@ -1,21 +1,23 @@
# 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.
#
-CSRC := wordexp.c
+subdirs += libc/misc/wordexp
+
+CSRC-y := wordexp.c
MISC_WORDEXP_DIR := $(top_srcdir)libc/misc/wordexp
MISC_WORDEXP_OUT := $(top_builddir)libc/misc/wordexp
-MISC_WORDEXP_SRC := $(patsubst %.c,$(MISC_WORDEXP_DIR)/%.c,$(CSRC))
-MISC_WORDEXP_OBJ := $(patsubst %.c,$(MISC_WORDEXP_OUT)/%.o,$(CSRC))
+MISC_WORDEXP_SRC := $(patsubst %.c,$(MISC_WORDEXP_DIR)/%.c,$(CSRC-y))
+MISC_WORDEXP_OBJ := $(patsubst %.c,$(MISC_WORDEXP_OUT)/%.o,$(CSRC-y))
libc-$(UCLIBC_HAS_WORDEXP) += $(MISC_WORDEXP_OBJ)
-objclean-y += misc_wordexp_objclean
+objclean-y += CLEAN_libc/misc/wordexp
-misc_wordexp_objclean:
- $(RM) $(MISC_WORDEXP_OUT)/*.{o,os}
+CLEAN_libc/misc/wordexp:
+ $(do_rm) $(addprefix $(MISC_WORDEXP_OUT)/*., o os)
diff --git a/libc/misc/wordexp/wordexp.c b/libc/misc/wordexp/wordexp.c
index d8b2db16f..b1cc60942 100644
--- a/libc/misc/wordexp/wordexp.c
+++ b/libc/misc/wordexp/wordexp.c
@@ -16,10 +16,11 @@
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 <bits/kernel-features.h>
+#include <ctype.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <fcntl.h>
@@ -35,55 +36,19 @@
#include <glob.h>
#include <wordexp.h>
-/* Experimentally off - libc_hidden_proto(mempcpy) */
-/* Experimentally off - libc_hidden_proto(stpcpy) */
-/* Experimentally off - libc_hidden_proto(strchr) */
-/* Experimentally off - libc_hidden_proto(strcpy) */
-/* Experimentally off - libc_hidden_proto(strdup) */
-/* Experimentally off - libc_hidden_proto(strlen) */
-/* Experimentally off - libc_hidden_proto(strndup) */
-/* Experimentally off - libc_hidden_proto(strspn) */
-/* Experimentally off - libc_hidden_proto(strcspn) */
-libc_hidden_proto(setenv)
-libc_hidden_proto(unsetenv)
-libc_hidden_proto(waitpid)
-libc_hidden_proto(kill)
-libc_hidden_proto(getuid)
-libc_hidden_proto(getpwnam_r)
-libc_hidden_proto(getpwuid_r)
-libc_hidden_proto(execve)
-libc_hidden_proto(dup2)
-libc_hidden_proto(atoi)
-libc_hidden_proto(fnmatch)
-libc_hidden_proto(pipe)
-libc_hidden_proto(fork)
-libc_hidden_proto(open)
-libc_hidden_proto(close)
-libc_hidden_proto(read)
-libc_hidden_proto(getenv)
-libc_hidden_proto(getpid)
-libc_hidden_proto(sprintf)
-libc_hidden_proto(fprintf)
-libc_hidden_proto(abort)
-libc_hidden_proto(glob)
-libc_hidden_proto(globfree)
-libc_hidden_proto(wordfree)
-#ifdef __UCLIBC_HAS_XLOCALE__
-libc_hidden_proto(__ctype_b_loc)
-#elif defined __UCLIBC_HAS_CTYPE_TABLES__
-libc_hidden_proto(__ctype_b)
+#ifndef __ARCH_USE_MMU__
+# define fork vfork
#endif
#define __WORDEXP_FULL
-//#undef __WORDEXP_FULL
/*
* This is a recursive-descent-style word expansion routine.
*/
/* These variables are defined and initialized in the startup code. */
-//extern int __libc_argc;
-//extern char **__libc_argv;
+/*extern int __libc_argc;*/
+/*extern char **__libc_argv;*/
/* FIXME!!!! */
int attribute_hidden __libc_argc;
@@ -138,8 +103,9 @@ static __inline__ char *w_addchar(char *buffer, size_t * actlen,
return buffer;
}
-
+#ifndef MAX
#define MAX( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) )
+#endif
static char *w_addmem(char *buffer, size_t * actlen, size_t * maxlen,
const char *str, size_t len)
{
@@ -373,8 +339,8 @@ parse_tilde(char **word, size_t * word_length, size_t * max_length,
static int
do_parse_glob(const char *glob_word, char **word, size_t * word_length,
- size_t * max_length, wordexp_t * pwordexp, const char *ifs,
- const char *ifs_white)
+ size_t * max_length, wordexp_t * pwordexp, const char *ifs
+ /*, const char *ifs_white*/)
{
int error;
int match;
@@ -497,7 +463,7 @@ parse_glob(char **word, size_t * word_length, size_t * max_length,
*word = w_newword(word_length, max_length);
for (i = 0; error == 0 && i < glob_list.we_wordc; i++)
error = do_parse_glob(glob_list.we_wordv[i], word, word_length,
- max_length, pwordexp, ifs, ifs_white);
+ max_length, pwordexp, ifs /*, ifs_white*/);
/* Now tidy up */
tidy_up:
@@ -787,6 +753,7 @@ parse_arith(char **word, size_t * word_length, size_t * max_length,
static void attribute_noreturn
exec_comm_child(char *comm, int *fildes, int showerr, int noexec)
{
+ int fd;
const char *args[4] = { _PATH_BSHELL, "-c", comm, NULL };
/* Execute the command, or just check syntax? */
@@ -794,16 +761,22 @@ exec_comm_child(char *comm, int *fildes, int showerr, int noexec)
args[1] = "-nc";
/* Redirect output. */
- dup2(fildes[1], 1);
- close(fildes[1]);
-
+ fd = fildes[1];
+ if (likely(fd != STDOUT_FILENO)) {
+ dup2(fd, STDOUT_FILENO);
+ close(fd);
+ }
+#if defined O_CLOEXEC && defined __UCLIBC_LINUX_SPECIFIC__ && defined __ASSUME_PIPE2
+ else {
+ /* Reset the close-on-exec flag (if necessary). */
+ fcntl (fd, F_SETFD, 0);
+ }
+#endif
/* Redirect stderr to /dev/null if we have to. */
if (showerr == 0) {
- int fd;
-
- close(2);
+ close(STDERR_FILENO);
fd = open(_PATH_DEVNULL, O_WRONLY);
- if (fd >= 0 && fd != 2) {
+ if (fd >= 0 && fd != STDERR_FILENO) {
dup2(fd, 2);
close(fd);
}
@@ -812,7 +785,8 @@ exec_comm_child(char *comm, int *fildes, int showerr, int noexec)
/* Make sure the subshell doesn't field-split on our behalf. */
unsetenv("IFS");
- close(fildes[0]);
+ if (fildes[0] != 1)
+ close(fildes[0]);
execve(_PATH_BSHELL, (char *const *) args, __environ);
/* Bad. What now? */
@@ -838,10 +812,15 @@ exec_comm(char *comm, char **word, size_t * word_length,
/* Don't fork() unless necessary */
if (!comm || !*comm)
return 0;
-
- if (pipe(fildes))
+#if defined O_CLOEXEC && defined __UCLIBC_LINUX_SPECIFIC__ && defined __ASSUME_PIPE2
+ if (pipe2(fildes, O_CLOEXEC) < 0)
/* Bad */
return WRDE_NOSPACE;
+#else
+ if (pipe(fildes) < 0)
+ /* Bad */
+ return WRDE_NOSPACE;
+#endif
if ((pid = fork()) < 0) {
/* Bad */
@@ -1481,28 +1460,28 @@ parse_param(char **word, size_t * word_length, size_t * max_length,
size_t exp_len;
size_t exp_maxl;
char *p;
- int quoted = 0; /* 1: single quotes; 2: double */
+ int quotes = 0; /* 1: single quotes; 2: double */
expanded = w_newword(&exp_len, &exp_maxl);
for (p = pattern; p && *p; p++) {
- size_t offset;
+ size_t _offset;
switch (*p) {
case '"':
- if (quoted == 2)
- quoted = 0;
- else if (quoted == 0)
- quoted = 2;
+ if (quotes == 2)
+ quotes = 0;
+ else if (quotes == 0)
+ quotes = 2;
else
break;
continue;
case '\'':
- if (quoted == 1)
- quoted = 0;
- else if (quoted == 0)
- quoted = 1;
+ if (quotes == 1)
+ quotes = 0;
+ else if (quotes == 0)
+ quotes = 1;
else
break;
@@ -1510,7 +1489,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length,
case '*':
case '?':
- if (quoted) {
+ if (quotes) {
/* Convert quoted wildchar to escaped wildchar. */
expanded = w_addchar(expanded, &exp_len,
&exp_maxl, '\\');
@@ -1521,9 +1500,9 @@ parse_param(char **word, size_t * word_length, size_t * max_length,
break;
case '$':
- offset = 0;
+ _offset = 0;
error = parse_dollars(&expanded, &exp_len, &exp_maxl, p,
- &offset, flags, NULL, NULL, NULL, 1);
+ &_offset, flags, NULL, NULL, NULL, 1);
if (error) {
if (free_value)
free(value);
@@ -1533,16 +1512,16 @@ parse_param(char **word, size_t * word_length, size_t * max_length,
goto do_error;
}
- p += offset;
+ p += _offset;
continue;
case '~':
- if (quoted || exp_len)
+ if (quotes || exp_len)
break;
- offset = 0;
+ _offset = 0;
error = parse_tilde(&expanded, &exp_len, &exp_maxl, p,
- &offset, 0);
+ &_offset, 0);
if (error) {
if (free_value)
free(value);
@@ -1552,7 +1531,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length,
goto do_error;
}
- p += offset;
+ p += _offset;
continue;
case '\\':
diff --git a/libc/pwd_grp/Makefile.in b/libc/pwd_grp/Makefile.in
index f9c7149e7..4a2e77385 100644
--- a/libc/pwd_grp/Makefile.in
+++ b/libc/pwd_grp/Makefile.in
@@ -1,31 +1,30 @@
# 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.
#
+subdirs += libc/pwd_grp
+
PWDGRP_DIR := $(top_srcdir)libc/pwd_grp
PWDGRP_OUT := $(top_builddir)libc/pwd_grp
-CSRC := $(notdir $(wildcard $(PWDGRP_DIR)/*.c))
-CSRC := $(filter-out pwd_grp.c pwd_grp_internal.c,$(CSRC))
-
-ifneq ($(UCLIBC_HAS_SHADOW),y)
-SHADOW_CSRC := \
- fgetspent_r.c fgetspent.c getspent_r.c getspent.c \
+CSRC-y := $(notdir $(wildcard $(PWDGRP_DIR)/*.c))
+CSRC- := pwd_grp.c pwd_grp_internal.c # multi-source and helper
+CSRC-$(UCLIBC_HAS_SHADOW) += fgetspent_r.c fgetspent.c getspent_r.c getspent.c \
getspnam_r.c getspnam.c lckpwdf.c putspent.c \
sgetspent_r.c sgetspent.c __parsespent.c
# getspuid_r.c getspuid.c
-CSRC := $(filter-out $(SHADOW_CSRC),$(CSRC))
-endif
-PWDGRP_SRC := $(patsubst %.c,$(PWDGRP_DIR)/%.c,$(CSRC))
-PWDGRP_OBJ := $(patsubst %.c,$(PWDGRP_OUT)/%.o,$(CSRC))
+CSRC-y := $(filter-out $(CSRC-),$(CSRC-y))
+
+PWDGRP_SRC := $(patsubst %.c,$(PWDGRP_DIR)/%.c,$(CSRC-y))
+PWDGRP_OBJ := $(patsubst %.c,$(PWDGRP_OUT)/%.o,$(CSRC-y))
libc-y += $(PWDGRP_OBJ)
-objclean-y += pwdgrp_objclean
+objclean-y += CLEAN_libc/pwd_grp
-pwdgrp_objclean:
- $(RM) $(PWDGRP_OUT)/*.{o,os}
+CLEAN_libc/pwd_grp:
+ $(do_rm) $(addprefix $(PWDGRP_OUT)/*., o os)
diff --git a/libc/pwd_grp/__getgrouplist_internal.c b/libc/pwd_grp/__getgrouplist_internal.c
new file mode 100644
index 000000000..c2edc99cf
--- /dev/null
+++ b/libc/pwd_grp/__getgrouplist_internal.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L___getgrouplist_internal
+#include "pwd_grp.c"
diff --git a/libc/pwd_grp/fgetgrent.c b/libc/pwd_grp/fgetgrent.c
index 695aee119..6a45799bc 100644
--- a/libc/pwd_grp/fgetgrent.c
+++ b/libc/pwd_grp/fgetgrent.c
@@ -4,5 +4,15 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define L_fgetgrent
+#include <features.h>
+
+#ifdef __USE_SVID
+
+#define GETXXKEY_FUNC fgetgrent
+#define GETXXKEY_ENTTYPE struct group
+#define GETXXKEY_ADD_PARAMS FILE *stream
+#define GETXXKEY_ADD_VARIABLES stream
+#define GETXXKEY_BUFLEN __UCLIBC_GRP_BUFFER_SIZE__
#include "pwd_grp.c"
+
+#endif
diff --git a/libc/pwd_grp/fgetpwent.c b/libc/pwd_grp/fgetpwent.c
index ddcc7ffb7..6f65cf672 100644
--- a/libc/pwd_grp/fgetpwent.c
+++ b/libc/pwd_grp/fgetpwent.c
@@ -4,5 +4,15 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define L_fgetpwent
+#include <features.h>
+
+#ifdef __USE_SVID
+
+#define GETXXKEY_FUNC fgetpwent
+#define GETXXKEY_ENTTYPE struct passwd
+#define GETXXKEY_ADD_PARAMS FILE *stream
+#define GETXXKEY_ADD_VARIABLES stream
+#define GETXXKEY_BUFLEN __UCLIBC_PWD_BUFFER_SIZE__
#include "pwd_grp.c"
+
+#endif
diff --git a/libc/pwd_grp/fgetspent.c b/libc/pwd_grp/fgetspent.c
index b7c1ef24f..77ca0b895 100644
--- a/libc/pwd_grp/fgetspent.c
+++ b/libc/pwd_grp/fgetspent.c
@@ -4,5 +4,9 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define L_fgetspent
+#define GETXXKEY_FUNC fgetspent
+#define GETXXKEY_ENTTYPE struct spwd
+#define GETXXKEY_ADD_PARAMS FILE *stream
+#define GETXXKEY_ADD_VARIABLES stream
+#define GETXXKEY_BUFLEN __UCLIBC_PWD_BUFFER_SIZE__
#include "pwd_grp.c"
diff --git a/libc/pwd_grp/getgrent.c b/libc/pwd_grp/getgrent.c
index 808e4e817..5b03b31a0 100644
--- a/libc/pwd_grp/getgrent.c
+++ b/libc/pwd_grp/getgrent.c
@@ -4,5 +4,8 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define L_getgrent
+#define GETXXKEY_FUNC getgrent
+#define GETXXKEY_ENTTYPE struct group
+#define GETXXKEY_ADD_PARAMS void
+#define GETXXKEY_BUFLEN __UCLIBC_GRP_BUFFER_SIZE__
#include "pwd_grp.c"
diff --git a/libc/pwd_grp/getgrgid.c b/libc/pwd_grp/getgrgid.c
index 96ce9039d..298845270 100644
--- a/libc/pwd_grp/getgrgid.c
+++ b/libc/pwd_grp/getgrgid.c
@@ -4,5 +4,9 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define L_getgrgid
+#define GETXXKEY_FUNC getgrgid
+#define GETXXKEY_ENTTYPE struct group
+#define GETXXKEY_ADD_PARAMS gid_t git
+#define GETXXKEY_ADD_VARIABLES git
+#define GETXXKEY_BUFLEN __UCLIBC_GRP_BUFFER_SIZE__
#include "pwd_grp.c"
diff --git a/libc/pwd_grp/getgrgid_r.c b/libc/pwd_grp/getgrgid_r.c
index a962f4cec..b0f0c9aa6 100644
--- a/libc/pwd_grp/getgrgid_r.c
+++ b/libc/pwd_grp/getgrgid_r.c
@@ -4,5 +4,10 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define L_getgrgid_r
+#define GETXXKEY_R_FUNC getgrgid_r
+#define GETXXKEY_R_PARSER __parsegrent
+#define GETXXKEY_R_ENTTYPE struct group
+#define GETXXKEY_R_TEST(ENT) ((ENT)->gr_gid == key)
+#define DO_GETXXKEY_R_KEYTYPE gid_t
+#define DO_GETXXKEY_R_PATHNAME _PATH_GROUP
#include "pwd_grp.c"
diff --git a/libc/pwd_grp/getgrnam.c b/libc/pwd_grp/getgrnam.c
index 3b47d9a9f..f6ce45953 100644
--- a/libc/pwd_grp/getgrnam.c
+++ b/libc/pwd_grp/getgrnam.c
@@ -4,5 +4,9 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define L_getgrnam
+#define GETXXKEY_FUNC getgrnam
+#define GETXXKEY_ENTTYPE struct group
+#define GETXXKEY_ADD_PARAMS const char *name
+#define GETXXKEY_ADD_VARIABLES name
+#define GETXXKEY_BUFLEN __UCLIBC_GRP_BUFFER_SIZE__
#include "pwd_grp.c"
diff --git a/libc/pwd_grp/getgrnam_r.c b/libc/pwd_grp/getgrnam_r.c
index 592a66c47..35121e70e 100644
--- a/libc/pwd_grp/getgrnam_r.c
+++ b/libc/pwd_grp/getgrnam_r.c
@@ -4,5 +4,10 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define L_getgrnam_r
+#define GETXXKEY_R_FUNC getgrnam_r
+#define GETXXKEY_R_PARSER __parsegrent
+#define GETXXKEY_R_ENTTYPE struct group
+#define GETXXKEY_R_TEST(ENT) (!strcmp((ENT)->gr_name, key))
+#define DO_GETXXKEY_R_KEYTYPE const char *__restrict
+#define DO_GETXXKEY_R_PATHNAME _PATH_GROUP
#include "pwd_grp.c"
diff --git a/libc/pwd_grp/getgrouplist.c b/libc/pwd_grp/getgrouplist.c
new file mode 100644
index 000000000..a4eba7dbb
--- /dev/null
+++ b/libc/pwd_grp/getgrouplist.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_getgrouplist
+#include "pwd_grp.c"
diff --git a/libc/pwd_grp/getpwent.c b/libc/pwd_grp/getpwent.c
index a617bc8b2..7ddc8ee8a 100644
--- a/libc/pwd_grp/getpwent.c
+++ b/libc/pwd_grp/getpwent.c
@@ -4,5 +4,8 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define L_getpwent
+#define GETXXKEY_FUNC getpwent
+#define GETXXKEY_ENTTYPE struct passwd
+#define GETXXKEY_ADD_PARAMS void
+#define GETXXKEY_BUFLEN __UCLIBC_PWD_BUFFER_SIZE__
#include "pwd_grp.c"
diff --git a/libc/pwd_grp/getpwnam.c b/libc/pwd_grp/getpwnam.c
index d00640b54..e3e8c027d 100644
--- a/libc/pwd_grp/getpwnam.c
+++ b/libc/pwd_grp/getpwnam.c
@@ -4,5 +4,10 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define L_getpwnam
+#define GETXXKEY_FUNC getpwnam
+#define GETXXKEY_ENTTYPE struct passwd
+#define GETXXKEY_ADD_PARAMS const char *name
+#define GETXXKEY_ADD_VARIABLES name
+#define GETXXKEY_BUFLEN __UCLIBC_PWD_BUFFER_SIZE__
+#define GETXXKEY_FUNC_HIDDEN
#include "pwd_grp.c"
diff --git a/libc/pwd_grp/getpwnam_r.c b/libc/pwd_grp/getpwnam_r.c
index a4440e756..bc5e3d5cf 100644
--- a/libc/pwd_grp/getpwnam_r.c
+++ b/libc/pwd_grp/getpwnam_r.c
@@ -4,5 +4,10 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define L_getpwnam_r
+#define GETXXKEY_R_FUNC getpwnam_r
+#define GETXXKEY_R_PARSER __parsepwent
+#define GETXXKEY_R_ENTTYPE struct passwd
+#define GETXXKEY_R_TEST(ENT) (!strcmp((ENT)->pw_name, key))
+#define DO_GETXXKEY_R_KEYTYPE const char *__restrict
+#define DO_GETXXKEY_R_PATHNAME _PATH_PASSWD
#include "pwd_grp.c"
diff --git a/libc/pwd_grp/getpwuid.c b/libc/pwd_grp/getpwuid.c
index 16ac50f72..1ad26888b 100644
--- a/libc/pwd_grp/getpwuid.c
+++ b/libc/pwd_grp/getpwuid.c
@@ -4,5 +4,9 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define L_getpwuid
+#define GETXXKEY_FUNC getpwuid
+#define GETXXKEY_ENTTYPE struct passwd
+#define GETXXKEY_ADD_PARAMS uid_t uid
+#define GETXXKEY_ADD_VARIABLES uid
+#define GETXXKEY_BUFLEN __UCLIBC_PWD_BUFFER_SIZE__
#include "pwd_grp.c"
diff --git a/libc/pwd_grp/getpwuid_r.c b/libc/pwd_grp/getpwuid_r.c
index 21d39ed7f..0a5aa962a 100644
--- a/libc/pwd_grp/getpwuid_r.c
+++ b/libc/pwd_grp/getpwuid_r.c
@@ -4,5 +4,10 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define L_getpwuid_r
+#define GETXXKEY_R_FUNC getpwuid_r
+#define GETXXKEY_R_PARSER __parsepwent
+#define GETXXKEY_R_ENTTYPE struct passwd
+#define GETXXKEY_R_TEST(ENT) ((ENT)->pw_uid == key)
+#define DO_GETXXKEY_R_KEYTYPE uid_t
+#define DO_GETXXKEY_R_PATHNAME _PATH_PASSWD
#include "pwd_grp.c"
diff --git a/libc/pwd_grp/getspent.c b/libc/pwd_grp/getspent.c
index 5699b67d6..4feb9f988 100644
--- a/libc/pwd_grp/getspent.c
+++ b/libc/pwd_grp/getspent.c
@@ -4,5 +4,8 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define L_getspent
+#define GETXXKEY_FUNC getspent
+#define GETXXKEY_ENTTYPE struct spwd
+#define GETXXKEY_ADD_PARAMS void
+#define GETXXKEY_BUFLEN __UCLIBC_PWD_BUFFER_SIZE__
#include "pwd_grp.c"
diff --git a/libc/pwd_grp/getspnam.c b/libc/pwd_grp/getspnam.c
index 19e40c737..a0a01ec63 100644
--- a/libc/pwd_grp/getspnam.c
+++ b/libc/pwd_grp/getspnam.c
@@ -4,5 +4,9 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define L_getspnam
+#define GETXXKEY_FUNC getspnam
+#define GETXXKEY_ENTTYPE struct spwd
+#define GETXXKEY_ADD_PARAMS const char *name
+#define GETXXKEY_ADD_VARIABLES name
+#define GETXXKEY_BUFLEN __UCLIBC_PWD_BUFFER_SIZE__
#include "pwd_grp.c"
diff --git a/libc/pwd_grp/getspnam_r.c b/libc/pwd_grp/getspnam_r.c
index 053b697ea..ea23848fe 100644
--- a/libc/pwd_grp/getspnam_r.c
+++ b/libc/pwd_grp/getspnam_r.c
@@ -4,5 +4,10 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define L_getspnam_r
+#define GETXXKEY_R_FUNC getspnam_r
+#define GETXXKEY_R_PARSER __parsespent
+#define GETXXKEY_R_ENTTYPE struct spwd
+#define GETXXKEY_R_TEST(ENT) (!strcmp((ENT)->sp_namp, key))
+#define DO_GETXXKEY_R_KEYTYPE const char *__restrict
+#define DO_GETXXKEY_R_PATHNAME _PATH_SHADOW
#include "pwd_grp.c"
diff --git a/libc/pwd_grp/lckpwdf.c b/libc/pwd_grp/lckpwdf.c
index 0b0fb471b..9b2aebcce 100644
--- a/libc/pwd_grp/lckpwdf.c
+++ b/libc/pwd_grp/lckpwdf.c
@@ -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 <features.h>
#include <fcntl.h>
@@ -28,22 +27,9 @@
#include <paths.h>
#include <shadow.h>
-/* Experimentally off - libc_hidden_proto(memset) */
-libc_hidden_proto(open)
-libc_hidden_proto(fcntl)
-libc_hidden_proto(close)
-libc_hidden_proto(sigfillset)
-libc_hidden_proto(sigaction)
-libc_hidden_proto(sigprocmask)
-libc_hidden_proto(sigaddset)
-libc_hidden_proto(sigemptyset)
-libc_hidden_proto(alarm)
-
-/* How long to wait for getting the lock before returning with an
- error. */
+/* How long to wait for getting the lock before returning with an error. */
#define TIMEOUT 15 /* sec */
-
/* File descriptor for lock file. */
static int lock_fd = -1;
@@ -51,7 +37,6 @@ static int lock_fd = -1;
#include <bits/uClibc_mutex.h>
__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER);
-
/* Prototypes for local functions. */
static void noop_handler (int __sig);
@@ -59,7 +44,6 @@ static void noop_handler (int __sig);
int
lckpwdf (void)
{
- int flags;
sigset_t saved_set; /* Saved set of caught signals. */
struct sigaction saved_act; /* Saved signal action. */
sigset_t new_set; /* New set of caught signals. */
@@ -75,90 +59,65 @@ lckpwdf (void)
/* Prevent problems caused by multiple threads. */
__UCLIBC_MUTEX_LOCK(mylock);
- lock_fd = open (_PATH_PASSWD, O_WRONLY);
+ lock_fd = open (_PATH_PASSWD, O_WRONLY | O_CLOEXEC);
if (lock_fd == -1) {
- /* Cannot create lock file. */
- goto DONE;
+ goto DONE;
}
-
+#ifndef __ASSUME_O_CLOEXEC
/* Make sure file gets correctly closed when process finished. */
- flags = fcntl (lock_fd, F_GETFD, 0);
- if (flags == -1) {
- /* Cannot get file flags. */
- close(lock_fd);
- lock_fd = -1;
- goto DONE;
- }
- flags |= FD_CLOEXEC; /* Close on exit. */
- if (fcntl (lock_fd, F_SETFD, flags) < 0) {
- /* Cannot set new flags. */
- close(lock_fd);
- lock_fd = -1;
- goto DONE;
- }
+ fcntl (lock_fd, F_SETFD, FD_CLOEXEC);
+#endif
/* Now we have to get exclusive write access. Since multiple
process could try this we won't stop when it first fails.
Instead we set a timeout for the system call. Once the timer
expires it is likely that there are some problems which cannot be
- resolved by waiting.
+ resolved by waiting. (sa_flags have no SA_RESTART. Thus SIGALRM
+ will EINTR fcntl(F_SETLKW)
It is important that we don't change the signal state. We must
restore the old signal behaviour. */
- memset (&new_act, '\0', sizeof (struct sigaction));
+ memset (&new_act, '\0', sizeof (new_act));
new_act.sa_handler = noop_handler;
- sigfillset (&new_act.sa_mask);
- new_act.sa_flags = 0ul;
+ __sigfillset (&new_act.sa_mask);
- /* Install new action handler for alarm and save old. */
- if (sigaction (SIGALRM, &new_act, &saved_act) < 0) {
- /* Cannot install signal handler. */
- close(lock_fd);
- lock_fd = -1;
- goto DONE;
- }
+ /* Install new action handler for alarm and save old.
+ * This never fails in Linux. */
+ sigaction (SIGALRM, &new_act, &saved_act);
/* Now make sure the alarm signal is not blocked. */
- sigemptyset (&new_set);
- sigaddset (&new_set, SIGALRM);
- if (sigprocmask (SIG_UNBLOCK, &new_set, &saved_set) < 0) {
- sigaction (SIGALRM, &saved_act, NULL);
- close(lock_fd);
- lock_fd = -1;
- goto DONE;
- }
+ __sigemptyset (&new_set);
+ __sigaddset (&new_set, SIGALRM);
+ sigprocmask (SIG_UNBLOCK, &new_set, &saved_set);
/* Start timer. If we cannot get the lock in the specified time we
get a signal. */
alarm (TIMEOUT);
/* Try to get the lock. */
- memset (&fl, '\0', sizeof (struct flock));
- fl.l_type = F_WRLCK;
- fl.l_whence = SEEK_SET;
+ memset (&fl, '\0', sizeof (fl));
+ if (F_WRLCK)
+ fl.l_type = F_WRLCK;
+ if (SEEK_SET)
+ fl.l_whence = SEEK_SET;
result = fcntl (lock_fd, F_SETLKW, &fl);
/* Clear alarm. */
alarm (0);
- /* Restore old set of handled signals. We don't need to know
- about the current one.*/
sigprocmask (SIG_SETMASK, &saved_set, NULL);
-
- /* Restore old action handler for alarm. We don't need to know
- about the current one. */
sigaction (SIGALRM, &saved_act, NULL);
if (result < 0) {
close(lock_fd);
lock_fd = -1;
- goto DONE;
+ goto DONE;
}
rv = 0;
DONE:
__UCLIBC_MUTEX_UNLOCK(mylock);
- return 0;
+ return rv;
}
@@ -173,7 +132,7 @@ ulckpwdf (void)
else
{
/* Prevent problems caused by multiple threads. */
- __UCLIBC_MUTEX_LOCK(mylock);
+ __UCLIBC_MUTEX_LOCK(mylock);
result = close (lock_fd);
@@ -181,7 +140,7 @@ ulckpwdf (void)
lock_fd = -1;
/* Clear mutex. */
- __UCLIBC_MUTEX_UNLOCK(mylock);
+ __UCLIBC_MUTEX_UNLOCK(mylock);
}
return result;
@@ -189,7 +148,7 @@ ulckpwdf (void)
static void
-noop_handler (int sig)
-{
+noop_handler (int sig attribute_unused) {
+
/* We simply return which makes the `fcntl' call return with an error. */
}
diff --git a/libc/pwd_grp/pwd_grp.c b/libc/pwd_grp/pwd_grp.c
index 217ed39a7..acdb08d39 100644
--- a/libc/pwd_grp/pwd_grp.c
+++ b/libc/pwd_grp/pwd_grp.c
@@ -32,28 +32,10 @@
#include <grp.h>
#include <paths.h>
#ifdef __UCLIBC_HAS_SHADOW__
-#include <shadow.h>
+# include <shadow.h>
#endif
#include <bits/uClibc_mutex.h>
-/* Experimentally off - libc_hidden_proto(strchr) */
-/* Experimentally off - libc_hidden_proto(strcmp) */
-/* Experimentally off - libc_hidden_proto(strcpy) */
-/* Experimentally off - libc_hidden_proto(strlen) */
-libc_hidden_proto(strtoul)
-libc_hidden_proto(rewind)
-libc_hidden_proto(fgets_unlocked)
-libc_hidden_proto(__fputc_unlocked)
-libc_hidden_proto(sprintf)
-libc_hidden_proto(fopen)
-libc_hidden_proto(fclose)
-libc_hidden_proto(fprintf)
-#ifdef __UCLIBC_HAS_XLOCALE__
-libc_hidden_proto(__ctype_b_loc)
-#elif defined __UCLIBC_HAS_CTYPE_TABLES__
-libc_hidden_proto(__ctype_b)
-#endif
-
/**********************************************************************/
/* Prototypes for internal functions. */
@@ -64,6 +46,8 @@ extern int __parsespent(void *sp, char *line) attribute_hidden;
extern int __pgsreader(int (*__parserfunc)(void *d, char *line), void *data,
char *__restrict line_buff, size_t buflen, FILE *f) attribute_hidden;
+extern gid_t* __getgrouplist_internal(const char *user, gid_t gid, int *ngroups) attribute_hidden;
+
/**********************************************************************/
/* For the various fget??ent_r funcs, return
*
@@ -82,7 +66,6 @@ extern int __pgsreader(int (*__parserfunc)(void *d, char *line), void *data,
#ifdef L_fgetpwent_r
#ifdef __USE_SVID
-libc_hidden_proto(fgetpwent_r)
int fgetpwent_r(FILE *__restrict stream, struct passwd *__restrict resultbuf,
char *__restrict buffer, size_t buflen,
struct passwd **__restrict result)
@@ -105,7 +88,6 @@ libc_hidden_def(fgetpwent_r)
#ifdef L_fgetgrent_r
#ifdef __USE_SVID
-libc_hidden_proto(fgetgrent_r)
int fgetgrent_r(FILE *__restrict stream, struct group *__restrict resultbuf,
char *__restrict buffer, size_t buflen,
struct group **__restrict result)
@@ -127,7 +109,6 @@ libc_hidden_def(fgetgrent_r)
/**********************************************************************/
#ifdef L_fgetspent_r
-libc_hidden_proto(fgetspent_r)
int fgetspent_r(FILE *__restrict stream, struct spwd *__restrict resultbuf,
char *__restrict buffer, size_t buflen,
struct spwd **__restrict result)
@@ -146,65 +127,8 @@ libc_hidden_def(fgetspent_r)
#endif
/**********************************************************************/
-/* For the various fget??ent funcs, return NULL on failure and a
- * pointer to the appropriate struct (statically allocated) on success.
- */
-/**********************************************************************/
-#ifdef L_fgetpwent
-
-#ifdef __USE_SVID
-libc_hidden_proto(fgetpwent_r)
-
-struct passwd *fgetpwent(FILE *stream)
-{
- static char buffer[__UCLIBC_PWD_BUFFER_SIZE__];
- static struct passwd resultbuf;
- struct passwd *result;
-
- fgetpwent_r(stream, &resultbuf, buffer, sizeof(buffer), &result);
- return result;
-}
-#endif
-
-#endif
-/**********************************************************************/
-#ifdef L_fgetgrent
-
-#ifdef __USE_SVID
-libc_hidden_proto(fgetgrent_r)
-
-struct group *fgetgrent(FILE *stream)
-{
- static char buffer[__UCLIBC_GRP_BUFFER_SIZE__];
- static struct group resultbuf;
- struct group *result;
-
- fgetgrent_r(stream, &resultbuf, buffer, sizeof(buffer), &result);
- return result;
-}
-#endif
-
-#endif
-/**********************************************************************/
-#ifdef L_fgetspent
-
-libc_hidden_proto(fgetspent_r)
-
-struct spwd *fgetspent(FILE *stream)
-{
- static char buffer[__UCLIBC_PWD_BUFFER_SIZE__];
- static struct spwd resultbuf;
- struct spwd *result;
-
- fgetspent_r(stream, &resultbuf, buffer, sizeof(buffer), &result);
- return result;
-}
-
-#endif
-/**********************************************************************/
#ifdef L_sgetspent_r
-libc_hidden_proto(sgetspent_r)
int sgetspent_r(const char *string, struct spwd *result_buf,
char *buffer, size_t buflen, struct spwd **result)
{
@@ -236,102 +160,12 @@ libc_hidden_def(sgetspent_r)
#endif
/**********************************************************************/
-
-#ifdef GETXXKEY_R_FUNC
-#error GETXXKEY_R_FUNC is already defined!
-#endif
-
-#ifdef L_getpwnam_r
-#define GETXXKEY_R_FUNC getpwnam_r
-#define GETXXKEY_R_PARSER __parsepwent
-#define GETXXKEY_R_ENTTYPE struct passwd
-#define GETXXKEY_R_TEST(ENT) (!strcmp((ENT)->pw_name, key))
-#define DO_GETXXKEY_R_KEYTYPE const char *__restrict
-#define DO_GETXXKEY_R_PATHNAME _PATH_PASSWD
-#include "pwd_grp_internal.c"
-#endif
-
-#ifdef L_getgrnam_r
-#define GETXXKEY_R_FUNC getgrnam_r
-#define GETXXKEY_R_PARSER __parsegrent
-#define GETXXKEY_R_ENTTYPE struct group
-#define GETXXKEY_R_TEST(ENT) (!strcmp((ENT)->gr_name, key))
-#define DO_GETXXKEY_R_KEYTYPE const char *__restrict
-#define DO_GETXXKEY_R_PATHNAME _PATH_GROUP
-#include "pwd_grp_internal.c"
-#endif
-
-#ifdef L_getspnam_r
-#define GETXXKEY_R_FUNC getspnam_r
-#define GETXXKEY_R_PARSER __parsespent
-#define GETXXKEY_R_ENTTYPE struct spwd
-#define GETXXKEY_R_TEST(ENT) (!strcmp((ENT)->sp_namp, key))
-#define DO_GETXXKEY_R_KEYTYPE const char *__restrict
-#define DO_GETXXKEY_R_PATHNAME _PATH_SHADOW
-#include "pwd_grp_internal.c"
-#endif
-
-#ifdef L_getpwuid_r
-#define GETXXKEY_R_FUNC getpwuid_r
-#define GETXXKEY_R_PARSER __parsepwent
-#define GETXXKEY_R_ENTTYPE struct passwd
-#define GETXXKEY_R_TEST(ENT) ((ENT)->pw_uid == key)
-#define DO_GETXXKEY_R_KEYTYPE uid_t
-#define DO_GETXXKEY_R_PATHNAME _PATH_PASSWD
-#include "pwd_grp_internal.c"
-#endif
-
-#ifdef L_getgrgid_r
-#define GETXXKEY_R_FUNC getgrgid_r
-#define GETXXKEY_R_PARSER __parsegrent
-#define GETXXKEY_R_ENTTYPE struct group
-#define GETXXKEY_R_TEST(ENT) ((ENT)->gr_gid == key)
-#define DO_GETXXKEY_R_KEYTYPE gid_t
-#define DO_GETXXKEY_R_PATHNAME _PATH_GROUP
-#include "pwd_grp_internal.c"
-#endif
-
-/**********************************************************************/
-#ifdef L_getpwuid
-
-libc_hidden_proto(getpwuid_r)
-
-struct passwd *getpwuid(uid_t uid)
-{
- static char buffer[__UCLIBC_PWD_BUFFER_SIZE__];
- static struct passwd resultbuf;
- struct passwd *result;
-
- getpwuid_r(uid, &resultbuf, buffer, sizeof(buffer), &result);
- return result;
-}
-
-#endif
-/**********************************************************************/
-#ifdef L_getgrgid
-
-libc_hidden_proto(getgrgid_r)
-
-struct group *getgrgid(gid_t gid)
-{
- static char buffer[__UCLIBC_GRP_BUFFER_SIZE__];
- static struct group resultbuf;
- struct group *result;
-
- getgrgid_r(gid, &resultbuf, buffer, sizeof(buffer), &result);
- return result;
-}
-
-#endif
-/**********************************************************************/
#ifdef L_getspuid_r
/* This function is non-standard and is currently not built. It seems
* to have been created as a reentrant version of the non-standard
* functions getspuid. Why getspuid was added, I do not know. */
-libc_hidden_proto(getpwuid_r)
-libc_hidden_proto(getspnam_r)
int getspuid_r(uid_t uid, struct spwd *__restrict resultbuf,
char *__restrict buffer, size_t buflen,
@@ -352,76 +186,8 @@ int getspuid_r(uid_t uid, struct spwd *__restrict resultbuf,
#endif
/**********************************************************************/
-#ifdef L_getspuid
-
-/* This function is non-standard and is currently not built.
- * Why it was added, I do not know. */
-
-libc_hidden_proto(getspuid_r)
-
-struct spwd *getspuid(uid_t uid)
-{
- static char buffer[__UCLIBC_PWD_BUFFER_SIZE__];
- static struct spwd resultbuf;
- struct spwd *result;
-
- getspuid_r(uid, &resultbuf, buffer, sizeof(buffer), &result);
- return result;
-}
-
-#endif
-/**********************************************************************/
-#ifdef L_getpwnam
-
-libc_hidden_proto(getpwnam_r)
-
-struct passwd *getpwnam(const char *name)
-{
- static char buffer[__UCLIBC_PWD_BUFFER_SIZE__];
- static struct passwd resultbuf;
- struct passwd *result;
-
- getpwnam_r(name, &resultbuf, buffer, sizeof(buffer), &result);
- return result;
-}
-
-#endif
-/**********************************************************************/
-#ifdef L_getgrnam
-
-libc_hidden_proto(getgrnam_r)
-
-struct group *getgrnam(const char *name)
-{
- static char buffer[__UCLIBC_GRP_BUFFER_SIZE__];
- static struct group resultbuf;
- struct group *result;
-
- getgrnam_r(name, &resultbuf, buffer, sizeof(buffer), &result);
- return result;
-}
-
-#endif
-/**********************************************************************/
-#ifdef L_getspnam
-
-libc_hidden_proto(getspnam_r)
-
-struct spwd *getspnam(const char *name)
-{
- static char buffer[__UCLIBC_PWD_BUFFER_SIZE__];
- static struct spwd resultbuf;
- struct spwd *result;
-
- getspnam_r(name, &resultbuf, buffer, sizeof(buffer), &result);
- return result;
-}
-
-#endif
-/**********************************************************************/
#ifdef L_getpw
-libc_hidden_proto(getpwuid_r)
int getpw(uid_t uid, char *buf)
{
@@ -474,7 +240,6 @@ void endpwent(void)
}
-libc_hidden_proto(getpwent_r)
int getpwent_r(struct passwd *__restrict resultbuf,
char *__restrict buffer, size_t buflen,
struct passwd **__restrict result)
@@ -531,7 +296,6 @@ void endgrent(void)
__UCLIBC_MUTEX_UNLOCK(mylock);
}
-libc_hidden_proto(getgrent_r)
int getgrent_r(struct group *__restrict resultbuf,
char *__restrict buffer, size_t buflen,
struct group **__restrict result)
@@ -588,7 +352,6 @@ void endspent(void)
__UCLIBC_MUTEX_UNLOCK(mylock);
}
-libc_hidden_proto(getspent_r)
int getspent_r(struct spwd *resultbuf, char *buffer,
size_t buflen, struct spwd **result)
{
@@ -620,67 +383,98 @@ libc_hidden_def(getspent_r)
#endif
/**********************************************************************/
-#ifdef L_getpwent
-
-libc_hidden_proto(getpwent_r)
-
-struct passwd *getpwent(void)
-{
- static char line_buff[__UCLIBC_PWD_BUFFER_SIZE__];
- static struct passwd pwd;
- struct passwd *result;
-
- getpwent_r(&pwd, line_buff, sizeof(line_buff), &result);
- return result;
-}
-
-#endif
+/* For the various fget??ent funcs, return NULL on failure and a
+ * pointer to the appropriate struct (statically allocated) on success.
+ */
/**********************************************************************/
-#ifdef L_getgrent
+#if defined(GETXXKEY_FUNC) || defined(GETXXKEY_R_FUNC)
+#include "pwd_grp_internal.c"
+#endif
-libc_hidden_proto(getgrent_r)
+/**********************************************************************/
+#ifdef L___getgrouplist_internal
-struct group *getgrent(void)
+gid_t attribute_hidden *__getgrouplist_internal(const char *user, gid_t gid, int *ngroups)
{
- static char line_buff[__UCLIBC_GRP_BUFFER_SIZE__];
- static struct group gr;
- struct group *result;
-
- getgrent_r(&gr, line_buff, sizeof(line_buff), &result);
- return result;
-}
-
-#endif
-/**********************************************************************/
-#ifdef L_getspent
+ FILE *grfile;
+ gid_t *group_list;
+ int num_groups;
+ struct group group;
+ char buff[__UCLIBC_PWD_BUFFER_SIZE__];
-libc_hidden_proto(getspent_r)
+ *ngroups = num_groups = 1;
-struct spwd *getspent(void)
-{
- static char line_buff[__UCLIBC_PWD_BUFFER_SIZE__];
- static struct spwd spwd;
- struct spwd *result;
+ /* We alloc space for 8 gids at a time. */
+ group_list = malloc(8 * sizeof(group_list[0]));
+ if (!group_list)
+ return NULL;
+
+ group_list[0] = gid;
+ grfile = fopen(_PATH_GROUP, "r");
+ /* If /etc/group doesn't exist, we still return 1-element vector */
+ if (!grfile)
+ return group_list;
+
+ __STDIO_SET_USER_LOCKING(grfile);
+
+ while (!__pgsreader(__parsegrent, &group, buff, sizeof(buff), grfile)) {
+ char **m;
+
+ assert(group.gr_mem); /* Must have at least a NULL terminator. */
+ if (group.gr_gid == gid)
+ continue;
+ for (m = group.gr_mem; *m; m++) {
+ if (strcmp(*m, user) != 0)
+ continue;
+ if (!(num_groups & 7)) {
+ gid_t *tmp = realloc(group_list, (num_groups+8) * sizeof(group_list[0]));
+ if (!tmp)
+ goto DO_CLOSE;
+ group_list = tmp;
+ }
+ group_list[num_groups++] = group.gr_gid;
+ break;
+ }
+ }
- getspent_r(&spwd, line_buff, sizeof(line_buff), &result);
- return result;
+ DO_CLOSE:
+ fclose(grfile);
+ *ngroups = num_groups;
+ return group_list;
}
#endif
/**********************************************************************/
-#ifdef L_sgetspent
-
-libc_hidden_proto(sgetspent_r)
+#ifdef L_getgrouplist
-struct spwd *sgetspent(const char *string)
+#if defined __USE_BSD || defined __USE_GNU
+int getgrouplist(const char *user, gid_t gid, gid_t *groups, int *ngroups)
{
- static char line_buff[__UCLIBC_PWD_BUFFER_SIZE__];
- static struct spwd spwd;
- struct spwd *result;
+ int sz = *ngroups;
+ gid_t *group_list = __getgrouplist_internal(user, gid, ngroups);
- sgetspent_r(string, &spwd, line_buff, sizeof(line_buff), &result);
- return result;
+ if (!group_list) {
+ /* malloc failure - what shall we do?
+ * fail with ENOMEM? I bet users never check for that */
+ /* *ngroups = 1; - already done by __getgrouplist_internal */
+ if (sz) {
+ groups[0] = gid;
+ return 1;
+ }
+ return -1;
+ }
+ /* *ngroups is non-zero here */
+
+ if (sz > *ngroups)
+ sz = *ngroups;
+ if (sz)
+ memcpy(groups, group_list, sz * sizeof(group_list[0]));
+ free(group_list);
+ if (sz < *ngroups)
+ return -1;
+ return sz;
}
+#endif
#endif
/**********************************************************************/
@@ -688,58 +482,14 @@ struct spwd *sgetspent(const char *string)
#ifdef __USE_BSD
-libc_hidden_proto(setgroups)
-
int initgroups(const char *user, gid_t gid)
{
- FILE *grfile;
- gid_t *group_list;
- int num_groups, rv;
- char **m;
- struct group group;
- char buff[__UCLIBC_PWD_BUFFER_SIZE__];
-
- rv = -1;
-
- /* We alloc space for 8 gids at a time. */
- if (((group_list = (gid_t *) malloc(8*sizeof(gid_t *))) != NULL)
- && ((grfile = fopen(_PATH_GROUP, "r")) != NULL)
- ) {
-
- __STDIO_SET_USER_LOCKING(grfile);
-
- *group_list = gid;
- num_groups = 1;
-
- while (!__pgsreader(__parsegrent, &group, buff, sizeof(buff), grfile)) {
- assert(group.gr_mem); /* Must have at least a NULL terminator. */
- if (group.gr_gid != gid) {
- for (m=group.gr_mem ; *m ; m++) {
- if (!strcmp(*m, user)) {
- if (!(num_groups & 7)) {
- gid_t *tmp = (gid_t *)
- realloc(group_list,
- (num_groups+8) * sizeof(gid_t *));
- if (!tmp) {
- rv = -1;
- goto DO_CLOSE;
- }
- group_list = tmp;
- }
- group_list[num_groups++] = group.gr_gid;
- break;
- }
- }
- }
- }
-
- rv = setgroups(num_groups, group_list);
- DO_CLOSE:
- fclose(grfile);
- }
-
- /* group_list will be NULL if initial malloc failed, which may trigger
- * warnings from various malloc debuggers. */
+ int rv;
+ int num_groups = ((unsigned)~0) >> 1; /* INT_MAX */
+ gid_t *group_list = __getgrouplist_internal(user, gid, &num_groups);
+ if (!group_list)
+ return -1;
+ rv = setgroups(num_groups, group_list);
free(group_list);
return rv;
}
diff --git a/libc/pwd_grp/pwd_grp_internal.c b/libc/pwd_grp/pwd_grp_internal.c
index c89747890..f82c298d5 100644
--- a/libc/pwd_grp/pwd_grp_internal.c
+++ b/libc/pwd_grp/pwd_grp_internal.c
@@ -26,6 +26,7 @@
#include <string.h>
#include <stddef.h>
#include <errno.h>
+#include <malloc.h>
#include <assert.h>
#include <ctype.h>
#include <pwd.h>
@@ -34,23 +35,12 @@
#ifdef __UCLIBC_HAS_SHADOW__
#include <shadow.h>
#endif
-#ifdef __UCLIBC_HAS_THREADS__
-#include <pthread.h>
-#endif
-
-/**********************************************************************/
-/* Sizes for statically allocated buffers. */
-
-/* If you change these values, also change _SC_GETPW_R_SIZE_MAX and
- * _SC_GETGR_R_SIZE_MAX in libc/unistd/sysconf.c to match */
-#define PWD_BUFFER_SIZE 256
-#define GRP_BUFFER_SIZE 256
/**********************************************************************/
/* Prototypes for internal functions. */
-#ifndef GETXXKEY_R_FUNC
-#error GETXXKEY_R_FUNC is not defined!
+#if !defined(GETXXKEY_R_FUNC) && !defined(GETXXKEY_FUNC)
+#error GETXXKEY_R_FUNC/GETXXKEY_FUNC are not defined!
#endif
/**********************************************************************/
#ifdef GETXXKEY_R_FUNC
@@ -92,9 +82,47 @@ int GETXXKEY_R_FUNC(DO_GETXXKEY_R_KEYTYPE key,
}
libc_hidden_def(GETXXKEY_R_FUNC)
+#endif /* GETXXKEY_R_FUNC */
+
+/**********************************************************************/
+#ifdef GETXXKEY_FUNC
+
+#define REENTRANT_NAME APPEND_R(GETXXKEY_FUNC)
+#define APPEND_R(name) APPEND_R1(name)
+#define APPEND_R1(name) name##_r
+
+GETXXKEY_ENTTYPE *GETXXKEY_FUNC(GETXXKEY_ADD_PARAMS)
+{
+ static char *buffer = NULL;
+ static GETXXKEY_ENTTYPE resultbuf;
+ GETXXKEY_ENTTYPE *result;
+
+ if (buffer == NULL)
+ buffer = (char *)__uc_malloc(GETXXKEY_BUFLEN);
+
+# ifdef GETXXKEY_ADD_VARIABLES
+ REENTRANT_NAME(GETXXKEY_ADD_VARIABLES, &resultbuf, buffer, GETXXKEY_BUFLEN, &result);
+# else
+ REENTRANT_NAME(&resultbuf, buffer, GETXXKEY_BUFLEN, &result);
+# endif
+ return result;
+}
+#ifdef GETXXKEY_FUNC_HIDDEN
+libc_hidden_def(GETXXKEY_FUNC)
#endif
+
+#undef REENTRANT_NAME
+#undef APPEND_R
+#undef APPEND_R1
+#endif /* GETXXKEY_FUNC */
+
/**********************************************************************/
-#undef GETXXKEY_R_FUNC_HIDDEN
+#undef GETXXKEY_FUNC
+#undef GETXXKEY_ENTTYPE
+#undef GETXXKEY_BUFLEN
+#undef GETXXKEY_FUNC_HIDDEN
+#undef GETXXKEY_ADD_PARAMS
+#undef GETXXKEY_ADD_VARIABLES
#undef GETXXKEY_R_FUNC
#undef GETXXKEY_R_PARSER
#undef GETXXKEY_R_ENTTYPE
diff --git a/libc/pwd_grp/sgetspent.c b/libc/pwd_grp/sgetspent.c
index 877a2478a..990c0b6a4 100644
--- a/libc/pwd_grp/sgetspent.c
+++ b/libc/pwd_grp/sgetspent.c
@@ -4,5 +4,9 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define L_sgetspent
+#define GETXXKEY_FUNC sgetspent
+#define GETXXKEY_ENTTYPE struct spwd
+#define GETXXKEY_ADD_PARAMS const char *string
+#define GETXXKEY_ADD_VARIABLES string
+#define GETXXKEY_BUFLEN __UCLIBC_PWD_BUFFER_SIZE__
#include "pwd_grp.c"
diff --git a/libc/signal/Makefile.in b/libc/signal/Makefile.in
index 4451d6622..6c355b5f1 100644
--- a/libc/signal/Makefile.in
+++ b/libc/signal/Makefile.in
@@ -1,34 +1,40 @@
# 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.
#
-CSRC := allocrtsig.c killpg.c raise.c sigaction.c sigaddset.c sigandset.c \
- sigblock.c sigdelset.c sigempty.c sigfillset.c siggetmask.c \
- sigintr.c sigisempty.c sigismem.c sigjmp.c signal.c \
- sigorset.c sigpause.c sigsetmask.c sigsetops.c sigwait.c
-ifeq ($(UCLIBC_HAS_OBSOLETE_BSD_SIGNAL),y)
-CSRC += sighold.c sigignore.c sigrelse.c sigset.c
-endif
-ifeq ($(UCLIBC_HAS_OBSOLETE_SYSV_SIGNAL),y)
-CSRC += sysv_signal.c
+subdirs += libc/signal
+
+CSRC-y := allocrtsig.c killpg.c raise.c sigaction.c sigaddset.c sigandset.c \
+ sigdelset.c sigempty.c sigfillset.c \
+ sigisempty.c sigismem.c sigjmp.c signal.c \
+ sigorset.c sigsetops.c sigwait.c
+CSRC-$(UCLIBC_HAS_OBSOLETE_BSD_SIGNAL) += \
+ sighold.c sigignore.c sigrelse.c sigset.c
+CSRC-$(UCLIBC_HAS_OBSOLETE_SYSV_SIGNAL) += sysv_signal.c
+CSRC-$(UCLIBC_SUSV4_LEGACY) += sigintr.c sigpause.c
+
+CSRC-$(UCLIBC_HAS_THREADS_NATIVE):=$(filter-out raise.c,$(CSRC-y))
+
+ifneq ($(strip $(ARCH_OBJS-y)),)
+CSRC-y := $(filter-out $(notdir $(ARCH_OBJS-y:.o=.c)),$(CSRC-y))
endif
-ifneq ($(strip $(ARCH_OBJS)),)
-CSRC := $(filter-out $(notdir $(ARCH_OBJS:.o=.c)),$(CSRC))
+ifneq ($(UCLIBC_HAS_BACKTRACE),)
+CFLAGS-raise.c = -fasynchronous-unwind-tables
endif
SIGNAL_DIR := $(top_srcdir)libc/signal
SIGNAL_OUT := $(top_builddir)libc/signal
-SIGNAL_SRC := $(patsubst %.c,$(SIGNAL_DIR)/%.c,$(CSRC))
-SIGNAL_OBJ := $(patsubst %.c,$(SIGNAL_OUT)/%.o,$(CSRC))
+SIGNAL_SRC := $(patsubst %.c,$(SIGNAL_DIR)/%.c,$(CSRC-y))
+SIGNAL_OBJ := $(patsubst %.c,$(SIGNAL_OUT)/%.o,$(CSRC-y))
libc-y += $(SIGNAL_OBJ)
-objclean-y += signal_objclean
+objclean-y += CLEAN_libc/signal
-signal_objclean:
- $(RM) $(SIGNAL_OUT)/*.{o,os}
+CLEAN_libc/signal:
+ $(do_rm) $(addprefix $(SIGNAL_OUT)/*., o os)
diff --git a/libc/signal/allocrtsig.c b/libc/signal/allocrtsig.c
index 3c7d6211b..974418761 100644
--- a/libc/signal/allocrtsig.c
+++ b/libc/signal/allocrtsig.c
@@ -14,13 +14,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 <signal.h>
-#include <sys/types.h>
#include <sys/syscall.h>
/* Only enable rt signals when it is supported at compile time */
@@ -34,6 +32,13 @@ static int current_rtmax = -1;
#else
# ifdef __UCLIBC_HAS_THREADS_NATIVE__
static int current_rtmin = __SIGRTMIN + 2;
+# elif defined __UCLIBC_HAS_THREADS__ && !defined __LINUXTHREADS_OLD__
+/* psm: might be good for LT old as well, do not want to break it for now */
+/* Sanity check */
+# if !defined __SIGRTMIN || (__SIGRTMAX - __SIGRTMIN) < 3
+# error "This must not happen"
+# endif
+static int current_rtmin = __SIGRTMIN + 3;
# else
static int current_rtmin = __SIGRTMIN;
# endif
@@ -52,6 +57,7 @@ int __libc_current_sigrtmax (void)
return current_rtmax;
}
+#if 0
/* Allocate real-time signal with highest/lowest available
priority. Please note that we don't use a lock since we assume
this function to be called at program start. */
@@ -64,3 +70,4 @@ int __libc_allocate_rtsig (int high)
return high ? current_rtmin++ : current_rtmax--;
}
+#endif
diff --git a/libc/signal/killpg.c b/libc/signal/killpg.c
index 46b6e4b35..e713212b7 100644
--- a/libc/signal/killpg.c
+++ b/libc/signal/killpg.c
@@ -12,15 +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 <errno.h>
#include <signal.h>
-libc_hidden_proto(kill)
-
/* Send SIG to all processes in process group PGRP.
If PGRP is zero, send SIG to all processes in
the current process's process group. */
diff --git a/libc/signal/raise.c b/libc/signal/raise.c
index 28e511635..d9dbab672 100644
--- a/libc/signal/raise.c
+++ b/libc/signal/raise.c
@@ -3,19 +3,10 @@
*/
#include <unistd.h>
-#include <string.h>
#include <signal.h>
-#include <sys/types.h>
-
-libc_hidden_proto(getpid)
-libc_hidden_proto(kill)
-
-int __raise (int signo) attribute_hidden;
-int __raise(int signo)
+int raise(int signo)
{
- return kill(getpid(), signo);
+ return kill(getpid(), signo);
}
-libc_hidden_proto(raise)
-weak_alias(__raise,raise)
libc_hidden_def(raise)
diff --git a/libc/signal/sigaction.c b/libc/signal/sigaction.c
index 88fb6b7a4..256064725 100644
--- a/libc/signal/sigaction.c
+++ b/libc/signal/sigaction.c
@@ -12,71 +12,38 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 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 <signal.h>
-#include <string.h>
-
#include <sys/syscall.h>
-/* Experimentally off - libc_hidden_proto(memcpy) */
-
-/* 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>
-
-#ifndef LIBC_SIGACTION
-extern __typeof(sigaction) __libc_sigaction;
-#endif
-
#if defined __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)
+__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
- kact.sa_restorer = act->sa_restorer;
-# 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).
+ * Try to catch this problem at uclibc build time: */
+ struct BUG_sigset_size {
+ int BUG_sigset_size
+ [sizeof(act->sa_mask) == _NSIG / 8 ? 1 : -1];
+ };
+ return __syscall_rt_sigaction(sig, act, oact, sizeof(act->sa_mask));
}
#else
+# define __need_NULL
+# include <stddef.h>
+# include <bits/kernel_sigaction.h>
/* 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;
@@ -89,11 +56,9 @@ __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact)
kact.sa_restorer = act->sa_restorer;
# endif
}
-
result = __syscall_sigaction(sig,
- act ? __ptrvalue (&kact) : NULL,
- oact ? __ptrvalue (&koact) : NULL);
-
+ 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;
@@ -102,14 +67,18 @@ __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact)
oact->sa_restorer = koact.sa_restorer;
# endif
}
-
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/signal/sigaddset.c b/libc/signal/sigaddset.c
index 9840a56bf..837f65329 100644
--- a/libc/signal/sigaddset.c
+++ b/libc/signal/sigaddset.c
@@ -12,14 +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 "sigsetops.h"
+#define __need_NULL
+#include <stddef.h>
+#include <signal.h>
+#include <errno.h>
/* Add SIGNO to SET. */
-libc_hidden_proto(sigaddset)
int
sigaddset (sigset_t *set, int signo)
{
@@ -29,6 +30,7 @@ sigaddset (sigset_t *set, int signo)
return -1;
}
- return __sigaddset (set, signo);
+ __sigaddset (set, signo);
+ return 0;
}
libc_hidden_def(sigaddset)
diff --git a/libc/signal/sigandset.c b/libc/signal/sigandset.c
index dcc37daba..24f33f3cc 100644
--- a/libc/signal/sigandset.c
+++ b/libc/signal/sigandset.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>
#include <signal.h>
diff --git a/libc/signal/sigblock.c b/libc/signal/sigblock.c
index 1f1a9fe98..dc62acdd9 100644
--- a/libc/signal/sigblock.c
+++ b/libc/signal/sigblock.c
@@ -12,30 +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/>. */
-#define __UCLIBC_HIDE_DEPRECATED__
-#include <errno.h>
+/*#define __UCLIBC_HIDE_DEPRECATED__*/
#include <signal.h>
-libc_hidden_proto(sigprocmask)
-
#include "sigset-cvt-mask.h"
/* Block signals in MASK, returning the old mask. */
-libc_hidden_proto(sigblock)
-int sigblock (int mask)
+static int sigblock (int mask)
{
sigset_t set, oset;
- if (sigset_set_old_mask (&set, mask) < 0)
- return -1;
-
- if (sigprocmask (SIG_BLOCK, &set, &oset) < 0)
- return -1;
-
+ sigset_set_old_mask (&set, mask);
+ sigprocmask (SIG_BLOCK, &set, &oset); /* can't fail */
return sigset_get_old_mask (&oset);
}
-libc_hidden_def(sigblock)
diff --git a/libc/signal/sigdelset.c b/libc/signal/sigdelset.c
index de988a7e8..9f3ab6659 100644
--- a/libc/signal/sigdelset.c
+++ b/libc/signal/sigdelset.c
@@ -12,14 +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 "sigsetops.h"
+#define __need_NULL
+#include <stddef.h>
+#include <signal.h>
+#include <errno.h>
/* Add SIGNO to SET. */
-libc_hidden_proto(sigdelset)
int sigdelset (sigset_t *set, int signo)
{
if (set == NULL || signo <= 0 || signo >= NSIG)
@@ -28,6 +29,7 @@ int sigdelset (sigset_t *set, int signo)
return -1;
}
- return __sigdelset (set, signo);
+ __sigdelset (set, signo);
+ return 0;
}
libc_hidden_def(sigdelset)
diff --git a/libc/signal/sigempty.c b/libc/signal/sigempty.c
index 7d8687bd1..393edae57 100644
--- a/libc/signal/sigempty.c
+++ b/libc/signal/sigempty.c
@@ -12,28 +12,28 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 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 <string.h>
-
-/* Experimentally off - libc_hidden_proto(memset) */
+#if 0
+#define __need_NULL
+#include <stddef.h>
+#include <errno.h>
+#endif
/* Clear all signals from SET. */
-libc_hidden_proto(sigemptyset)
int sigemptyset (sigset_t *set)
{
+#if 0 /* is it really required by standards?! */
if (set == NULL)
{
__set_errno (EINVAL);
return -1;
}
+#endif
- memset (set, 0, sizeof (sigset_t));
+ __sigemptyset (set);
return 0;
}
-libc_hidden_def(sigemptyset)
diff --git a/libc/signal/sigfillset.c b/libc/signal/sigfillset.c
index 96ab459dc..5ef4c829c 100644
--- a/libc/signal/sigfillset.c
+++ b/libc/signal/sigfillset.c
@@ -12,28 +12,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/>. */
-#include <errno.h>
#include <signal.h>
-#include <string.h>
-
-/* Experimentally off - libc_hidden_proto(memset) */
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+# include <pthreadP.h> /* SIGCANCEL */
+#endif
+#if 0
+#define __need_NULL
+#include <stddef.h>
+#include <errno.h>
+#endif
/* Set all signals in SET. */
-libc_hidden_proto(sigfillset)
int
sigfillset (sigset_t *set)
{
+#if 0 /* is it really required by standards?! */
if (set == NULL)
{
__set_errno (EINVAL);
return -1;
}
+#endif
- memset (set, 0xff, sizeof (sigset_t));
+ __sigfillset (set);
/* If the implementation uses a cancellation signal don't set the bit. */
#ifdef SIGCANCEL
@@ -46,4 +50,3 @@ sigfillset (sigset_t *set)
return 0;
}
-libc_hidden_def(sigfillset)
diff --git a/libc/signal/siggetmask.c b/libc/signal/siggetmask.c
index d3af43a12..c05a53c48 100644
--- a/libc/signal/siggetmask.c
+++ b/libc/signal/siggetmask.c
@@ -13,20 +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/>. */
#define __UCLIBC_HIDE_DEPRECATED__
#include <signal.h>
-libc_hidden_proto(sigblock)
-
int
siggetmask (void)
{
return sigblock (0);
}
-
-link_warning (siggetmask,
- "warning: `siggetmask' is obsolete; `sigprocmask' is best")
diff --git a/libc/signal/sighold.c b/libc/signal/sighold.c
index da723ac86..6fd160660 100644
--- a/libc/signal/sighold.c
+++ b/libc/signal/sighold.c
@@ -14,26 +14,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/>. */
#define __need_NULL
#include <stddef.h>
#include <signal.h>
-libc_hidden_proto(sigprocmask)
-libc_hidden_proto(sigaddset)
-
int sighold (int sig)
{
sigset_t set;
/* Retrieve current signal set. */
- if (sigprocmask (SIG_SETMASK, NULL, &set) < 0)
- return -1;
+ sigprocmask (SIG_SETMASK, NULL, &set); /* can't fail */
- /* Add the specified signal. */
+ /* Bound-check sig, add it to the set. */
if (sigaddset (&set, sig) < 0)
return -1;
diff --git a/libc/signal/sigignore.c b/libc/signal/sigignore.c
index 17d93ce19..1ddce8113 100644
--- a/libc/signal/sigignore.c
+++ b/libc/signal/sigignore.c
@@ -14,26 +14,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 <errno.h>
#define __need_NULL
#include <stddef.h>
#include <signal.h>
-#include <string.h> /* For the real memset prototype. */
-
-libc_hidden_proto(sigaction)
+#include <string.h>
int sigignore (int sig)
{
struct sigaction act;
+ memset(&act, 0, sizeof(act));
act.sa_handler = SIG_IGN;
- if (__sigemptyset (&act.sa_mask) < 0)
- return -1;
- act.sa_flags = 0;
return sigaction (sig, &act, NULL);
}
diff --git a/libc/signal/sigintr.c b/libc/signal/sigintr.c
index 43136379f..83d34978c 100644
--- a/libc/signal/sigintr.c
+++ b/libc/signal/sigintr.c
@@ -12,21 +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 <stddef.h>
#include <signal.h>
-#include <errno.h>
-
-libc_hidden_proto(sigaction)
/* If INTERRUPT is nonzero, make signal SIG interrupt system calls
(causing them to fail with EINTR); if INTERRUPT is zero, make system
calls be restarted after signal SIG. */
#ifdef SA_RESTART
-extern sigset_t _sigintr attribute_hidden; /* Defined in signal.c. */
+# define __need_NULL
+# include <stddef.h>
+#else
+# include <errno.h>
#endif
int siginterrupt (int sig, int interrupt)
@@ -34,7 +32,8 @@ int siginterrupt (int sig, int interrupt)
#ifdef SA_RESTART
struct sigaction action;
- if (sigaction (sig, (struct sigaction *) NULL, &action) < 0)
+ /* Fails if sig is bad. */
+ if (sigaction (sig, NULL, &action) < 0)
return -1;
if (interrupt)
@@ -48,10 +47,7 @@ int siginterrupt (int sig, int interrupt)
action.sa_flags |= SA_RESTART;
}
- if (sigaction (sig, &action, (struct sigaction *) NULL) < 0)
- return -1;
-
- return 0;
+ return sigaction (sig, &action, NULL);
#else
__set_errno (ENOSYS);
return -1;
diff --git a/libc/signal/sigisempty.c b/libc/signal/sigisempty.c
index a25bb473d..46153b6b4 100644
--- a/libc/signal/sigisempty.c
+++ b/libc/signal/sigisempty.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>
#include <signal.h>
diff --git a/libc/signal/sigismem.c b/libc/signal/sigismem.c
index b546f626f..06e939e96 100644
--- a/libc/signal/sigismem.c
+++ b/libc/signal/sigismem.c
@@ -12,11 +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 "sigsetops.h"
+#define __need_NULL
+#include <stddef.h>
+#include <signal.h>
+#include <errno.h>
/* Return 1 if SIGNO is in SET, 0 if not. */
int sigismember (const sigset_t *set, int signo)
diff --git a/libc/signal/sigjmp.c b/libc/signal/sigjmp.c
index d143e9376..ffd8c24b1 100644
--- a/libc/signal/sigjmp.c
+++ b/libc/signal/sigjmp.c
@@ -12,26 +12,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/>. */
+#define __need_NULL
#include <stddef.h>
#include <setjmp.h>
#include <signal.h>
-#include <libc-internal.h>
-
-libc_hidden_proto(sigprocmask)
/* This function is called by the `sigsetjmp' macro
before doing a `__setjmp' on ENV[0].__jmpbuf.
Always return zero. */
-int __sigjmp_save (sigjmp_buf env, int savemask) attribute_hidden;
int __sigjmp_save (sigjmp_buf env, int savemask)
{
env[0].__mask_was_saved = (savemask &&
- sigprocmask (SIG_BLOCK, (sigset_t *) NULL, &env[0].__saved_mask) == 0);
+ sigprocmask (SIG_BLOCK, NULL, &env[0].__saved_mask) == 0);
return 0;
}
diff --git a/libc/signal/signal.c b/libc/signal/signal.c
index 991a14f1b..d59cb38ca 100644
--- a/libc/signal/signal.c
+++ b/libc/signal/signal.c
@@ -14,23 +14,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 <errno.h>
#include <signal.h>
#include <string.h> /* For the real memset prototype. */
-libc_hidden_proto(sigaction)
-
-sigset_t _sigintr attribute_hidden; /* Set by siginterrupt. */
+sigset_t _sigintr; /* Set by siginterrupt. */
/* Set the handler for the signal SIG to HANDLER,
returning the old handler, or SIG_ERR on error. */
-extern __typeof(bsd_signal) __bsd_signal;
-attribute_hidden __sighandler_t
-__bsd_signal (int sig, __sighandler_t handler)
+__sighandler_t
+signal (int sig, __sighandler_t handler)
{
struct sigaction act, oact;
@@ -42,16 +38,16 @@ __bsd_signal (int sig, __sighandler_t handler)
}
act.sa_handler = handler;
- if (__sigemptyset (&act.sa_mask) < 0
- || __sigaddset (&act.sa_mask, sig) < 0)
- return SIG_ERR;
+ __sigemptyset (&act.sa_mask);
+ __sigaddset (&act.sa_mask, sig);
act.sa_flags = __sigismember (&_sigintr, sig) ? 0 : SA_RESTART;
+ /* In Linux (as of 2.6.25), fails only if sig is SIGKILL or SIGSTOP */
if (sigaction (sig, &act, &oact) < 0)
return SIG_ERR;
return oact.sa_handler;
}
-strong_alias(__bsd_signal,bsd_signal)
-libc_hidden_proto(signal)
-strong_alias(__bsd_signal,signal)
libc_hidden_def(signal)
+#ifdef __UCLIBC_SUSV3_LEGACY__
+strong_alias(signal,bsd_signal)
+#endif
diff --git a/libc/signal/sigorset.c b/libc/signal/sigorset.c
index 3588cc482..238814233 100644
--- a/libc/signal/sigorset.c
+++ b/libc/signal/sigorset.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>
#include <signal.h>
diff --git a/libc/signal/sigpause.c b/libc/signal/sigpause.c
index 8c99af0a1..de50d98b2 100644
--- a/libc/signal/sigpause.c
+++ b/libc/signal/sigpause.c
@@ -13,53 +13,51 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 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 __UCLIBC_HIDE_DEPRECATED__
-/* psm: need the BSD version of sigpause here */
-#include <errno.h>
-#define __FAVOR_BSD
#include <signal.h>
-#include <stddef.h> /* For NULL. */
-
-libc_hidden_proto(sigprocmask)
-libc_hidden_proto(sigdelset)
-libc_hidden_proto(sigsuspend)
+#define __need_NULL
+#include <stddef.h>
+#include <cancel.h>
#include "sigset-cvt-mask.h"
/* Set the mask of blocked signals to MASK,
wait for a signal to arrive, and then restore the mask. */
-libc_hidden_proto(__sigpause)
-int __sigpause (int sig_or_mask, int is_sig)
+static int __sigpause (int sig_or_mask, int is_sig)
{
sigset_t set;
- if (is_sig != 0)
+ if (is_sig)
{
/* The modern X/Open implementation is requested. */
- if (sigprocmask (0, NULL, &set) < 0
- /* Yes, we call `sigdelset' and not `__sigdelset'. */
- || sigdelset (&set, sig_or_mask) < 0)
+ sigprocmask (SIG_BLOCK, NULL, &set);
+ /* Bound-check sig_or_mask, remove it from the set. */
+ if (sigdelset (&set, sig_or_mask) < 0)
return -1;
}
- else if (sigset_set_old_mask (&set, sig_or_mask) < 0)
- return -1;
-
- return sigsuspend (&set);
+ else
+ sigset_set_old_mask (&set, sig_or_mask);
+
+ /* Note the sigpause() is a cancellation point. But since we call
+ sigsuspend() which itself is a cancellation point we do not have
+ to do anything here. */
+ /* uClibc note: not true on uClibc, we call the non-cancellable version */
+ return __NC(sigsuspend)(&set);
}
-libc_hidden_def(__sigpause)
-#undef sigpause
+int __bsd_sigpause(int mask);
+int __bsd_sigpause(int mask)
+{
+ return __sigpause(mask, 0);
+}
/* We have to provide a default version of this function since the
standards demand it. The version which is a bit more reasonable is
the BSD version. So make this the default. */
-libc_hidden_proto(sigpause)
-int sigpause (int mask)
+static int __NC(sigpause)(int sig)
{
- return __sigpause (mask, 0);
+ return __sigpause(sig, 1);
}
-libc_hidden_def(sigpause)
+CANCELLABLE_SYSCALL(int, sigpause, (int sig), (sig))
diff --git a/libc/signal/sigrelse.c b/libc/signal/sigrelse.c
index 8532a88f3..30ff9f794 100644
--- a/libc/signal/sigrelse.c
+++ b/libc/signal/sigrelse.c
@@ -14,26 +14,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/>. */
#define __need_NULL
#include <stddef.h>
#include <signal.h>
-libc_hidden_proto(sigprocmask)
-libc_hidden_proto(sigdelset)
-
int sigrelse (int sig)
{
sigset_t set;
/* Retrieve current signal set. */
- if (sigprocmask (SIG_SETMASK, NULL, &set) < 0)
- return -1;
+ sigprocmask (SIG_SETMASK, NULL, &set); /* can't fail */
- /* Remove the specified signal. */
+ /* Bound-check sig, remove it from the set. */
if (sigdelset (&set, sig) < 0)
return -1;
diff --git a/libc/signal/sigset-cvt-mask.h b/libc/signal/sigset-cvt-mask.h
index 7b2f4cdce..c497ebfff 100644
--- a/libc/signal/sigset-cvt-mask.h
+++ b/libc/signal/sigset-cvt-mask.h
@@ -15,26 +15,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/>. */
-static __inline__ int __attribute__ ((unused))
-sigset_set_old_mask (sigset_t *set, int mask)
-{
- unsigned long int *ptr;
- int cnt;
-
- ptr = &set->__val[0];
+#ifndef _SIGSET_CVT_MASK_H
+#define _SIGSET_CVT_MASK_H
- *ptr++ = (unsigned int) mask;
+#include <string.h>
- cnt = _SIGSET_NWORDS - 2;
- do
- *ptr++ = 0ul;
- while (--cnt >= 0);
-
- return 0;
+static __inline__ void __attribute__ ((unused))
+sigset_set_old_mask (sigset_t *set, int mask)
+{
+ if (_SIGSET_NWORDS == 2) /* typical */
+ set->__val[1] = 0;
+ if (_SIGSET_NWORDS > 2)
+ memset(set, 0, sizeof(*set));
+ set->__val[0] = (unsigned int) mask;
}
static __inline__ int __attribute__ ((unused))
@@ -42,3 +38,5 @@ sigset_get_old_mask (const sigset_t *set)
{
return (unsigned int) set->__val[0];
}
+
+#endif
diff --git a/libc/signal/sigset.c b/libc/signal/sigset.c
index db1fb7d74..55ad92ecf 100644
--- a/libc/signal/sigset.c
+++ b/libc/signal/sigset.c
@@ -12,18 +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>
#define __need_NULL
#include <stddef.h>
#include <signal.h>
-#include <string.h> /* For the real memset prototype. */
-
-libc_hidden_proto(sigaction)
-libc_hidden_proto(sigprocmask)
+#include <string.h>
/* Set the disposition for SIG. */
__sighandler_t sigset (int sig, __sighandler_t disp)
@@ -31,51 +27,39 @@ __sighandler_t sigset (int sig, __sighandler_t disp)
struct sigaction act, oact;
sigset_t set;
+ /* Check signal extents to protect __sigismember. */
+ if (disp == SIG_ERR || sig < 1 || sig >= NSIG)
+ {
+ __set_errno (EINVAL);
+ return SIG_ERR;
+ }
+
#ifdef SIG_HOLD
/* Handle SIG_HOLD first. */
if (disp == SIG_HOLD)
{
- /* Create an empty signal set. */
- if (__sigemptyset (&set) < 0)
- return SIG_ERR;
-
- /* Add the specified signal. */
- if (__sigaddset (&set, sig) < 0)
- return SIG_ERR;
+ __sigemptyset (&set);
+ __sigaddset (&set, sig);
/* Add the signal set to the current signal mask. */
- if (sigprocmask (SIG_BLOCK, &set, NULL) < 0)
- return SIG_ERR;
+ sigprocmask (SIG_BLOCK, &set, NULL); /* can't fail */
return SIG_HOLD;
}
#endif /* SIG_HOLD */
- /* Check signal extents to protect __sigismember. */
- if (disp == SIG_ERR || sig < 1 || sig >= NSIG)
- {
- __set_errno (EINVAL);
- return SIG_ERR;
- }
-
+ memset(&act, 0, sizeof(act));
act.sa_handler = disp;
- if (__sigemptyset (&act.sa_mask) < 0)
- return SIG_ERR;
- act.sa_flags = 0;
+ /* In Linux (as of 2.6.25), fails only if sig is SIGKILL or SIGSTOP */
if (sigaction (sig, &act, &oact) < 0)
return SIG_ERR;
- /* Create an empty signal set. */
- if (__sigemptyset (&set) < 0)
- return SIG_ERR;
-
- /* Add the specified signal. */
- if (__sigaddset (&set, sig) < 0)
- return SIG_ERR;
+ /* Create an empty signal set. Add the specified signal. */
+ __sigemptyset (&set);
+ __sigaddset (&set, sig);
/* Remove the signal set from the current signal mask. */
- if (sigprocmask (SIG_UNBLOCK, &set, NULL) < 0)
- return SIG_ERR;
+ sigprocmask (SIG_UNBLOCK, &set, NULL); /* can't fail */
return oact.sa_handler;
}
diff --git a/libc/signal/sigsetmask.c b/libc/signal/sigsetmask.c
index 2c074674d..72188c5fc 100644
--- a/libc/signal/sigsetmask.c
+++ b/libc/signal/sigsetmask.c
@@ -12,32 +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/>. */
-#define __UCLIBC_HIDE_DEPRECATED__
-#include <errno.h>
+/*#define __UCLIBC_HIDE_DEPRECATED__*/
#include <signal.h>
-libc_hidden_proto(sigprocmask)
-
#include "sigset-cvt-mask.h"
/* Set the mask of blocked signals to MASK, returning the old mask. */
-libc_hidden_proto(sigsetmask)
-int
+static int
sigsetmask (int mask)
{
sigset_t set, oset;
- if (sigset_set_old_mask (&set, mask) < 0)
- return -1;
-
- if (sigprocmask (SIG_SETMASK, &set, &oset) < 0)
- return -1;
-
-
+ sigset_set_old_mask (&set, mask);
+ sigprocmask (SIG_SETMASK, &set, &oset); /* can't fail */
return sigset_get_old_mask (&oset);
}
-libc_hidden_def(sigsetmask)
diff --git a/libc/signal/sigsetops.c b/libc/signal/sigsetops.c
index 6f1ae5c83..fa5fe6acf 100644
--- a/libc/signal/sigsetops.c
+++ b/libc/signal/sigsetops.c
@@ -3,9 +3,18 @@
#include <features.h>
-#define _EXTERN_INLINE
+#define __PROVIDE_OUT_OF_LINE_SIGSETFN
#ifndef __USE_EXTERN_INLINES
# define __USE_EXTERN_INLINES 1
#endif
#include <signal.h>
+
+/* Since we massaged signal.h into emitting non-inline function
+ * definitions, we need to finish PLT avoidance trick: */
+#undef __sigismember
+#undef __sigaddset
+#undef __sigdelset
+libc_hidden_def(__sigismember)
+libc_hidden_def(__sigaddset)
+libc_hidden_def(__sigdelset)
diff --git a/libc/signal/sigwait.c b/libc/signal/sigwait.c
index 99832f809..3e7286566 100644
--- a/libc/signal/sigwait.c
+++ b/libc/signal/sigwait.c
@@ -1,7 +1,8 @@
/* vi: set sw=4 ts=4: */
/* sigwait
*
- * Copyright (C) 2003 by Erik Andersen <andersen@uclibc.org>
+ * Copyright (C) 2006 by Steven J. Hill <sjhill@realitydiluted.com>
+ * Copyright (C) 2003-2005 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 Lesser General Public
@@ -14,40 +15,51 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with the GNU C Library; if not, 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/>.
+ */
-#include <errno.h>
+#define __need_NULL
+#include <stddef.h>
+#include <sys/syscall.h>
#include <signal.h>
-#include <string.h>
+#include <cancel.h>
+
+#if defined __NR_rt_sigtimedwait && defined __UCLIBC_HAS_REALTIME__
-#if defined __UCLIBC_HAS_REALTIME__
-libc_hidden_proto(sigwaitinfo)
+#include <string.h>
-int __sigwait (const sigset_t *set, int *sig) attribute_hidden;
-int __sigwait (const sigset_t *set, int *sig)
+/* Return any pending signal or wait for one for the given time. */
+static int __NC(sigwait)(const sigset_t *set, int *sig)
{
- int ret = 1;
- if ((ret = sigwaitinfo(set, NULL)) != -1) {
+ int ret;
+
+ do
+ /* we might as well use sigtimedwait and do not care about cancellation */
+ ret = __NC(sigtimedwait)(set, NULL, NULL);
+ while (ret == -1 && errno == EINTR);
+ if (ret != -1) {
*sig = ret;
- return 0;
- }
- return 1;
+ ret = 0;
+ } else
+ ret = errno;
+
+ return ret;
}
-#else /* __UCLIBC_HAS_REALTIME__ */
+
+#else /* __NR_rt_sigtimedwait */
+
/* variant without REALTIME extensions */
-libc_hidden_proto(sigfillset)
-libc_hidden_proto(sigaction)
-libc_hidden_proto(sigsuspend)
+#include <unistd.h> /* smallint */
+
+static smallint was_sig; /* obviously not thread-safe */
-static int was_sig; /* obviously not thread-safe */
static void ignore_signal(int sig)
{
was_sig = sig;
}
-int __sigwait (const sigset_t *set, int *sig) attribute_hidden;
-int __sigwait (const sigset_t *set, int *sig)
+
+static int __NC(sigwait)(const sigset_t *set, int *sig)
{
sigset_t tmp_mask;
struct sigaction saved[NSIG];
@@ -56,12 +68,12 @@ int __sigwait (const sigset_t *set, int *sig)
int this;
/* Prepare set. */
- sigfillset (&tmp_mask);
+ __sigfillset (&tmp_mask);
/* Unblock all signals in the SET and register our nice handler. */
action.sa_handler = ignore_signal;
action.sa_flags = 0;
- sigfillset (&action.sa_mask); /* Block all signals for handler. */
+ __sigfillset (&action.sa_mask); /* Block all signals for handler. */
/* Make sure we recognize error conditions by setting WAS_SIG to a
value which does not describe a legal signal number. */
@@ -74,12 +86,14 @@ int __sigwait (const sigset_t *set, int *sig)
__sigdelset (&tmp_mask, this);
/* Register temporary action handler. */
+ /* In Linux (as of 2.6.25), fails only if sig is SIGKILL or SIGSTOP */
+ /* (so, will it work correctly if set has, say, SIGSTOP?) */
if (sigaction (this, &action, &saved[this]) != 0)
goto restore_handler;
}
/* Now we can wait for signals. */
- sigsuspend (&tmp_mask);
+ __NC(sigsuspend)(&tmp_mask);
restore_handler:
save_errno = errno;
@@ -95,7 +109,6 @@ int __sigwait (const sigset_t *set, int *sig)
*sig = was_sig;
return was_sig == -1 ? -1 : 0;
}
-#endif /* __UCLIBC_HAS_REALTIME__ */
-libc_hidden_proto(sigwait)
-weak_alias(__sigwait,sigwait)
-libc_hidden_def(sigwait)
+#endif /* __NR_rt_sigtimedwait */
+
+CANCELLABLE_SYSCALL(int, sigwait, (const sigset_t *set, int *sig), (set, sig))
diff --git a/libc/signal/sysv_signal.c b/libc/signal/sysv_signal.c
index 6eebf201b..9b270fdf8 100644
--- a/libc/signal/sysv_signal.c
+++ b/libc/signal/sysv_signal.c
@@ -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 <errno.h>
#include <signal.h>
-#include <string.h> /* For the real memset prototype. */
-
-libc_hidden_proto(sigaction)
/* Tolerate non-threads versions of Posix */
#ifndef SA_ONESHOT
@@ -47,10 +43,9 @@ __sighandler_t __sysv_signal (int sig, __sighandler_t handler)
}
act.sa_handler = handler;
- if (__sigemptyset (&act.sa_mask) < 0)
- return SIG_ERR;
- act.sa_flags = SA_ONESHOT | SA_NOMASK | SA_INTERRUPT;
- act.sa_flags &= ~SA_RESTART;
+ __sigemptyset (&act.sa_mask);
+ act.sa_flags = (SA_ONESHOT | SA_NOMASK | SA_INTERRUPT) & ~SA_RESTART;
+ /* In Linux (as of 2.6.25), fails only if sig is SIGKILL or SIGSTOP */
if (sigaction (sig, &act, &oact) < 0)
return SIG_ERR;
diff --git a/libc/stdio/Makefile.in b/libc/stdio/Makefile.in
index 74f6d9aed..7d697bf82 100644
--- a/libc/stdio/Makefile.in
+++ b/libc/stdio/Makefile.in
@@ -1,107 +1,100 @@
# Makefile for uClibc
#
# Copyright (C) 2004 Manuel Novoa III <mjn3@uclibc.org>
-# 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.
#
# Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details.
#
+subdirs += libc/stdio
+
# SUSv3 functions
-CSRC := \
+CSRC-y := \
fclose.c fcloseall.c fdopen.c fgetpos.c fopen.c freopen.c \
fseeko.c fsetpos.c ftello.c getdelim.c getline.c gets.c getw.c \
perror.c puts.c putw.c remove.c rewind.c setbuf.c setbuffer.c \
setlinebuf.c setvbuf.c ungetc.c \
printf.c vprintf.c vsprintf.c fprintf.c snprintf.c dprintf.c \
asprintf.c sprintf.c vasprintf.c vdprintf.c vsnprintf.c \
- tmpfile.c tmpnam.c tmpnam_r.c popen.c tempnam.c ctermid.c
-
-ifeq ($(UCLIBC_HAS_LFS),y)
-CSRC += fgetpos64.c fopen64.c freopen64.c fseeko64.c fsetpos64.c ftello64.c
-endif
+ tmpfile.c popen.c ctermid.c
+CSRC-$(UCLIBC_HAS_LFS) += fgetpos64.c fopen64.c freopen64.c \
+ fseeko64.c fsetpos64.c ftello64.c
+CSRC-$(UCLIBC_SUSV4_LEGACY) += tmpnam.c tmpnam_r.c tempnam.c
-# getc -> alias for fgetc
-# putc -> alias for fputc
-# rename is a syscall
-
-# Implementation support functions
-CSRC += \
+# internal support functions
+CSRC-y += \
_READ.c _WRITE.c _adjust_pos.c _fopen.c _fwrite.c \
_rfill.c _stdio.c _trans2r.c _trans2w.c _wcommit.c \
_cs_funcs.c _load_inttype.c _store_inttype.c _uintmaxtostr.c
-ifeq ($(UCLIBC_HAS_FLOATS),y)
-CSRC += _fpmaxtostr.c
-endif
+CSRC-$(UCLIBC_HAS_FLOATS) += _fpmaxtostr.c
# stdio_ext.h functions
-CSRC += \
+CSRC-y += \
__fbufsize.c __flbf.c __fpending.c __fpurge.c __freadable.c \
__freading.c __fsetlocking.c __fwritable.c __fwriting.c _flushlbf.c
# Other glibc extensions
-ifeq ($(UCLIBC_HAS_GLIBC_CUSTOM_STREAMS),y)
-CSRC += fopencookie.c fmemopen.c open_memstream.c
-endif
+CSRC-$(UCLIBC_HAS_GLIBC_CUSTOM_STREAMS) += fopencookie.c fmemopen.c \
+ open_memstream.c
# pthread functions
-CSRC += flockfile.c ftrylockfile.c funlockfile.c
+CSRC-y += flockfile.c ftrylockfile.c funlockfile.c
# Functions with unlocked versions
-CUSRC := \
+CUSRC-y := \
clearerr.c feof.c ferror.c fflush.c fgetc.c fgets.c fileno.c \
fputc.c fputs.c fread.c fwrite.c getchar.c putchar.c
# getc_unlocked -> alias for fgetc_unlocked
# putc_unlocked -> alias for fputc_unlocked
# vfprintf and support functions
-ifneq ($(USE_OLD_VFPRINTF),y)
+ifeq ($(USE_OLD_VFPRINTF),y)
+VF_CSRC := old_vfprintf.c
+else
+# multi source _vfprintf.c
VF_CSRC := \
vfprintf.c \
_vfprintf_internal.c \
_ppfs_init.c _ppfs_prepargs.c _ppfs_setargs.c _ppfs_parsespec.c \
register_printf_function.c parse_printf_format.c
-CSRC += $(VF_CSRC)
-else
-CSRC += old_vfprintf.c
endif
+CSRC-y += $(VF_CSRC)
# vfscanf and support functions plus other *scanf funcs
-CSRC += \
+CSRC-y += \
vfscanf.c __scan_cookie.c __psfs_parse_spec.c __psfs_do_numeric.c \
scanf.c sscanf.c fscanf.c vscanf.c vsscanf.c
-ifeq ($(UCLIBC_HAS_WCHAR),y)
-CSRC += _wfwrite.c fwprintf.c swprintf.c vswprintf.c vwprintf.c wprintf.c \
+CSRC-$(UCLIBC_HAS_WCHAR) += \
+ _wfwrite.c fwprintf.c swprintf.c vswprintf.c vwprintf.c wprintf.c \
fwide.c ungetwc.c
-CUSRC += fgetwc.c getwchar.c fgetws.c fputwc.c putwchar.c fputws.c
+CUSRC-$(UCLIBC_HAS_WCHAR) += \
+ fgetwc.c getwchar.c fgetws.c fputwc.c putwchar.c fputws.c
# getwc (fgetwc alias) getwc_unlocked (fgetwc_unlocked alias)
# putwc (fputwc alias) putwc_unlocked (fputwc_unlocked alias)
-CSRC += vfwprintf.c _vfwprintf_internal.c
-CSRC += wscanf.c swscanf.c fwscanf.c vwscanf.c vswscanf.c vfwscanf.c
-endif
-
-CUSRC_UNLOCKED := $(patsubst %.c,%_unlocked.c,$(CUSRC))
+CSRC-$(UCLIBC_HAS_WCHAR) += vfwprintf.c _vfwprintf_internal.c \
+ wscanf.c swscanf.c fwscanf.c vwscanf.c vswscanf.c vfwscanf.c
-CSRC += $(CUSRC) $(CUSRC_UNLOCKED)
+CUSRC_UNLOCKED := $(patsubst %.c,%_unlocked.c,$(CUSRC-y))
+CSRC-y += $(CUSRC-y) $(CUSRC_UNLOCKED)
STDIO_DIR := $(top_srcdir)libc/stdio
STDIO_OUT := $(top_builddir)libc/stdio
-STDIO_SRC := $(patsubst %.c,$(STDIO_DIR)/%.c,$(CSRC))
-STDIO_OBJ := $(patsubst %.c,$(STDIO_OUT)/%.o,$(CSRC))
+STDIO_SRC := $(patsubst %.c,$(STDIO_DIR)/%.c,$(CSRC-y))
+STDIO_OBJ := $(patsubst %.c,$(STDIO_OUT)/%.o,$(CSRC-y))
libc-y += $(STDIO_OBJ)
ifneq ($(USE_OLD_VFPRINTF),y)
libc-nomulti-y += $(patsubst %.c,$(STDIO_OUT)/%.o,$(VF_CSRC))
endif
-ifeq ($(UCLIBC_HAS_WCHAR),y)
-libc-nomulti-y += $(STDIO_OUT)/vfwprintf.o $(STDIO_OUT)/vfwscanf.o
-endif
+libc-nomulti-$(UCLIBC_HAS_WCHAR) += $(STDIO_OUT)/vfwprintf.o \
+ $(STDIO_OUT)/vfwscanf.o
-objclean-y += stdio_objclean
+objclean-y += CLEAN_libc/stdio
-stdio_objclean:
- $(RM) $(STDIO_OUT)/*.{o,os,oS}
+CLEAN_libc/stdio:
+ $(do_rm) $(addprefix $(STDIO_OUT)/*., o os oS)
diff --git a/libc/stdio/_READ.c b/libc/stdio/_READ.c
index bafa8dffe..a548dbb3f 100644
--- a/libc/stdio/_READ.c
+++ b/libc/stdio/_READ.c
@@ -7,8 +7,6 @@
#include "_stdio.h"
-libc_hidden_proto(read)
-libc_hidden_proto(abort)
/* Given a reading stream without its end-of-file indicator set and
* with no buffered input or ungots, read at most 'bufsize' bytes
@@ -29,7 +27,7 @@ size_t attribute_hidden __stdio_READ(register FILE *stream,
ssize_t rv = 0;
__STDIO_STREAM_VALIDATE(stream);
- assert(stream->__filedes >= -1);
+ assert(stream->__filedes >= -2);
assert(__STDIO_STREAM_IS_READING(stream));
assert(!__STDIO_STREAM_BUFFER_RAVAIL(stream)); /* Buffer must be empty. */
assert(!(stream->__modeflags & __FLAG_UNGOT));
diff --git a/libc/stdio/_WRITE.c b/libc/stdio/_WRITE.c
index 83714bd4c..712236f8f 100644
--- a/libc/stdio/_WRITE.c
+++ b/libc/stdio/_WRITE.c
@@ -7,7 +7,6 @@
#include "_stdio.h"
-libc_hidden_proto(write)
/* Given a writing stream with no buffered output, write the
* data in 'buf' (which may be the stream's bufstart) of size
@@ -37,19 +36,16 @@ size_t attribute_hidden __stdio_WRITE(register FILE *stream,
ssize_t rv, stodo;
__STDIO_STREAM_VALIDATE(stream);
- assert(stream->__filedes >= -1);
+ assert(stream->__filedes >= -2);
assert(__STDIO_STREAM_IS_WRITING(stream));
assert(!__STDIO_STREAM_BUFFER_WUSED(stream)); /* Buffer must be empty. */
todo = bufsize;
- do {
- if (todo == 0) { /* Done? */
- __STDIO_STREAM_VALIDATE(stream);
- return bufsize;
- }
+ while (todo != 0) {
stodo = (todo <= SSIZE_MAX) ? todo : SSIZE_MAX;
- if ((rv = __WRITE(stream, (char *) buf, stodo)) >= 0) {
+ rv = __WRITE(stream, (char *) buf, stodo);
+ if (rv >= 0) {
#ifdef __UCLIBC_MJN3_ONLY__
#warning TODO: Make custom stream write return check optional.
#endif
@@ -61,26 +57,44 @@ size_t attribute_hidden __stdio_WRITE(register FILE *stream,
#endif
todo -= rv;
buf += rv;
- } else
-#ifdef __UCLIBC_MJN3_ONLY__
-#warning EINTR?
-#endif
-/* if (errno != EINTR) */
- {
+ } else {
+
__STDIO_STREAM_SET_ERROR(stream);
+ /* We buffer data on "transient" errors, but discard it
+ * on "hard" ones. Example of a hard error:
+ *
+ * close(fileno(stdout));
+ * printf("Hi there 1\n"); // EBADF
+ * dup2(good_fd, fileno(stdout));
+ * printf("Hi there 2\n"); // buffers new data
+ *
+ * This program should not print "Hi there 1" to good_fd.
+ * The rationale is that the caller of writing operation
+ * should check for error and act on it.
+ * If he didn't, then future users of the stream
+ * have no idea what to do.
+ * It's least confusing to at least not burden them with
+ * some hidden buffered crap in the buffer.
+ */
+ if (errno != EINTR && errno != EAGAIN) {
+ /* do we have other "soft" errors? */
+ break;
+ }
#ifdef __STDIO_BUFFERS
- if ((stodo = __STDIO_STREAM_BUFFER_SIZE(stream)) != 0) {
+ stodo = __STDIO_STREAM_BUFFER_SIZE(stream);
+ if (stodo != 0) {
unsigned char *s;
if (stodo > todo) {
stodo = todo;
}
- s = stream->__bufstart;
+ s = stream->__bufstart;
do {
- if (((*s = *buf) == '\n')
+ *s = *buf;
+ if ((*s == '\n')
&& __STDIO_STREAM_IS_LBF(stream)
) {
break;
@@ -95,8 +109,11 @@ size_t attribute_hidden __stdio_WRITE(register FILE *stream,
}
#endif /* __STDIO_BUFFERS */
- __STDIO_STREAM_VALIDATE(stream);
- return bufsize - todo;
+ bufsize -= todo;
+ break;
}
- } while (1);
+ }
+
+ __STDIO_STREAM_VALIDATE(stream);
+ return bufsize;
}
diff --git a/libc/stdio/__fpending.c b/libc/stdio/__fpending.c
index a7fe05463..e7e33e80a 100644
--- a/libc/stdio/__fpending.c
+++ b/libc/stdio/__fpending.c
@@ -18,13 +18,6 @@
* convert wide chars to their multibyte encodings and buffer _those_.
*/
-#ifdef __UCLIBC_HAS_WCHAR__
-#warning Note: Unlike the glibc version, this __fpending returns bytes in buffer for wide streams too!
-
-link_warning(__fpending, "This version of __fpending returns bytes remaining in buffer for both narrow and wide streams. glibc's version returns wide chars in buffer for the wide stream case.")
-
-#endif
-
size_t __fpending(register FILE * __restrict stream)
{
__STDIO_STREAM_VALIDATE(stream);
diff --git a/libc/stdio/__fsetlocking.c b/libc/stdio/__fsetlocking.c
index 2e8710076..6d4fc18b8 100644
--- a/libc/stdio/__fsetlocking.c
+++ b/libc/stdio/__fsetlocking.c
@@ -8,7 +8,6 @@
#include "_stdio.h"
#include <stdio_ext.h>
-libc_hidden_proto(__fsetlocking)
/* Not threadsafe. */
diff --git a/libc/stdio/_cs_funcs.c b/libc/stdio/_cs_funcs.c
index 38a8351e5..be416a450 100644
--- a/libc/stdio/_cs_funcs.c
+++ b/libc/stdio/_cs_funcs.c
@@ -7,55 +7,6 @@
#include "_stdio.h"
-libc_hidden_proto(read)
-libc_hidden_proto(write)
-libc_hidden_proto(close)
-#ifdef __UCLIBC_HAS_LFS__
-libc_hidden_proto(lseek64)
-#else
-libc_hidden_proto(lseek)
-#endif
-
-/**********************************************************************/
-#ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__
-/**********************************************************************/
-
-ssize_t attribute_hidden _cs_read(void *cookie, char *buf, size_t bufsize)
-{
- return read(*((int *) cookie), buf, bufsize);
-}
-
-/**********************************************************************/
-
-ssize_t attribute_hidden _cs_write(void *cookie, const char *buf, size_t bufsize)
-{
- return write(*((int *) cookie), (char *) buf, bufsize);
-}
-
-/**********************************************************************/
-
-int attribute_hidden _cs_seek(void *cookie, register __offmax_t *pos, int whence)
-{
- __offmax_t res;
-
-#ifdef __UCLIBC_HAS_LFS__
- res = lseek64(*((int *) cookie), *pos, whence);
-#else
- res = lseek(*((int *) cookie), *pos, whence);
-#endif
-
- return (res >= 0) ? ((*pos = res), 0) : ((int) res);
-}
-
-/**********************************************************************/
-
-int attribute_hidden _cs_close(void *cookie)
-{
- return close(*((int *) cookie));
-}
-
-/**********************************************************************/
-#else
/**********************************************************************/
int attribute_hidden __stdio_seek(FILE *stream, register __offmax_t *pos, int whence)
@@ -72,5 +23,3 @@ int attribute_hidden __stdio_seek(FILE *stream, register __offmax_t *pos, int wh
}
/**********************************************************************/
-#endif
-/**********************************************************************/
diff --git a/libc/stdio/_flushlbf.c b/libc/stdio/_flushlbf.c
index 8a551a746..c322c3e33 100644
--- a/libc/stdio/_flushlbf.c
+++ b/libc/stdio/_flushlbf.c
@@ -8,7 +8,6 @@
#include "_stdio.h"
#include <stdio_ext.h>
-libc_hidden_proto(fflush_unlocked)
/* Solaris function --
* Flush all line buffered (writing) streams.
diff --git a/libc/stdio/_fopen.c b/libc/stdio/_fopen.c
index 5243e33f7..be05c48a5 100644
--- a/libc/stdio/_fopen.c
+++ b/libc/stdio/_fopen.c
@@ -7,9 +7,6 @@
#include "_stdio.h"
-libc_hidden_proto(isatty)
-libc_hidden_proto(open)
-libc_hidden_proto(fcntl)
/*
* Cases:
@@ -72,7 +69,8 @@ FILE attribute_hidden *_stdio_fopen(intptr_t fname_or_mode,
#warning CONSIDER: Implement glibc mmap option for readonly files?
#warning CONSIDER: Implement a text mode using custom read/write funcs?
#endif
-#if defined(__UCLIBC_HAS_FOPEN_EXCLUSIVE_MODE__) || defined(__UCLIBC_HAS_FOPEN_LARGEFILE_MODE__)
+#if defined(__UCLIBC_HAS_FOPEN_EXCLUSIVE_MODE__) || defined(__UCLIBC_HAS_FOPEN_LARGEFILE_MODE__) || \
+ defined(__UCLIBC_HAS_FOPEN_CLOSEEXEC_MODE__)
while (*++mode) {
# ifdef __UCLIBC_HAS_FOPEN_EXCLUSIVE_MODE__
@@ -87,6 +85,12 @@ FILE attribute_hidden *_stdio_fopen(intptr_t fname_or_mode,
continue;
}
# endif
+# ifdef __UCLIBC_HAS_FOPEN_CLOSEEXEC_MODE__
+ if (*mode == 'e') { /* Close on exec (a glibc extension). */
+ open_mode |= O_CLOEXEC;
+ continue;
+ }
+# endif
}
#endif
@@ -102,7 +106,7 @@ FILE attribute_hidden *_stdio_fopen(intptr_t fname_or_mode,
#ifdef __UCLIBC_HAS_THREADS__
/* We only initialize the mutex in the non-freopen case. */
/* stream->__user_locking = _stdio_user_locking; */
- __stdio_init_mutex(&stream->__lock);
+ STDIO_INIT_MUTEX(stream->__lock);
#endif
}
@@ -121,11 +125,11 @@ FILE attribute_hidden *_stdio_fopen(intptr_t fname_or_mode,
i = (open_mode & (O_ACCMODE|O_LARGEFILE)) + 1;
/* NOTE: fopencookie needs changing if the basic check changes! */
- if (((i & (((int) fname_or_mode) + 1)) != i) /* Basic agreement? */
- || (((open_mode & ~((__mode_t) fname_or_mode)) & O_APPEND)
- && fcntl(filedes, F_SETFL, O_APPEND)) /* Need O_APPEND. */
- ) {
+ if ((i & ((int)fname_or_mode + 1)) != i) /* Basic agreement? */
goto DO_EINVAL;
+ if ((open_mode & ~(__mode_t)fname_or_mode) & O_APPEND) {
+ if (fcntl(filedes, F_SETFL, O_APPEND)) /* Need O_APPEND. */
+ goto DO_EINVAL;
}
/* For later... to reflect largefile setting in stream flags. */
__STDIO_WHEN_LFS( open_mode |= (((__mode_t) fname_or_mode)
@@ -159,9 +163,15 @@ FILE attribute_hidden *_stdio_fopen(intptr_t fname_or_mode,
((((open_mode & O_ACCMODE) + 1) ^ 0x03) * __FLAG_WRITEONLY);
#ifdef __STDIO_BUFFERS
- i = errno; /* Preserve errno against isatty call. */
- stream->__modeflags |= (isatty(stream->__filedes) * __FLAG_LBF);
- __set_errno(i);
+ if (stream->__filedes != INT_MAX) {
+ /* NB: fopencookie uses bogus filedes == INT_MAX,
+ * avoiding isatty() in that case.
+ */
+ i = errno; /* preserve errno against isatty call. */
+ if (isatty(stream->__filedes))
+ stream->__modeflags |= __FLAG_LBF;
+ __set_errno(i);
+ }
if (!stream->__bufstart) {
if ((stream->__bufstart = malloc(BUFSIZ)) != NULL) {
@@ -182,8 +192,6 @@ FILE attribute_hidden *_stdio_fopen(intptr_t fname_or_mode,
__STDIO_STREAM_INIT_BUFREAD_BUFPOS(stream);
#endif
- __STDIO_STREAM_RESET_GCS(stream);
-
#ifdef __UCLIBC_HAS_WCHAR__
stream->__ungot_width[0] = 0;
#endif
@@ -194,7 +202,7 @@ FILE attribute_hidden *_stdio_fopen(intptr_t fname_or_mode,
#ifdef __UCLIBC_HAS_THREADS__
/* Even in the freopen case, we reset the user locking flag. */
stream->__user_locking = _stdio_user_locking;
- /* __stdio_init_mutex(&stream->__lock); */
+ /* STDIO_INIT_MUTEX(stream->__lock); */
#endif
#ifdef __STDIO_HAS_OPENLIST
diff --git a/libc/stdio/_fpmaxtostr.c b/libc/stdio/_fpmaxtostr.c
index b8d93a091..35805844a 100644
--- a/libc/stdio/_fpmaxtostr.c
+++ b/libc/stdio/_fpmaxtostr.c
@@ -1,6 +1,7 @@
-/* Copyright (C) 2004 Manuel Novoa III <mjn3@codepoet.org>
+/*
+ * Copyright (C) 2000,2001,2003,2004 Manuel Novoa III <mjn3@codepoet.org>
*
- * GNU Library General Public License (LGPL) version 2 or later.
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*
* Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details.
*/
@@ -9,16 +10,9 @@
#include <printf.h>
#include <float.h>
#include <locale.h>
-#include <bits/uClibc_fpmax.h>
+#include "_fpmaxtostr.h"
-/* Experimentally off - libc_hidden_proto(memset) */
-
-typedef size_t (__fp_outfunc_t)(FILE *fp, intptr_t type, intptr_t len,
- intptr_t buf);
-
-
-/* Copyright (C) 2000, 2001, 2003 Manuel Novoa III
- *
+/*
* Function:
*
* ssize_t _fpmaxtostr(FILE * fp, __fpmax_t x, struct printf_info *info,
@@ -41,7 +35,6 @@ typedef size_t (__fp_outfunc_t)(FILE *fp, intptr_t type, intptr_t len,
* It should also be fairly portable, as no assumptions are made about the
* bit-layout of doubles. Of course, that does make it less efficient than
* it could be.
- *
*/
/*****************************************************************************/
@@ -52,11 +45,6 @@ typedef size_t (__fp_outfunc_t)(FILE *fp, intptr_t type, intptr_t len,
*/
#define isnan(x) ((x) != (x))
-/* Without seminumerical functions to examine the sign bit, this is
- * about the best we can do to test for '-0'.
- */
-#define zeroisnegative(x) ((1./(x)) < 0)
-
/*****************************************************************************/
/* Don't change anything that follows peroid!!! ;-) */
/*****************************************************************************/
@@ -68,9 +56,6 @@ typedef size_t (__fp_outfunc_t)(FILE *fp, intptr_t type, intptr_t len,
#define NUM_HEX_DIGITS ((FPMAX_MANT_DIG + 3)/ 4)
-/* WARNING: Adjust _fp_out_wide() below if this changes! */
-/* With 32 bit ints, we can get 9 decimal digits per block. */
-#define DIGITS_PER_BLOCK 9
#define HEX_DIGITS_PER_BLOCK 8
/* Maximum number of subcases to output double is...
@@ -88,15 +73,9 @@ typedef size_t (__fp_outfunc_t)(FILE *fp, intptr_t type, intptr_t len,
/*****************************************************************************/
-#define NUM_DIGIT_BLOCKS ((DECIMAL_DIG+DIGITS_PER_BLOCK-1)/DIGITS_PER_BLOCK)
#define NUM_HEX_DIGIT_BLOCKS \
((NUM_HEX_DIGITS+HEX_DIGITS_PER_BLOCK-1)/HEX_DIGITS_PER_BLOCK)
-/* WARNING: Adjust _fp_out_wide() below if this changes! */
-
-/* extra space for '-', '.', 'e+###', and nul */
-#define BUF_SIZE ( 3 + NUM_DIGIT_BLOCKS * DIGITS_PER_BLOCK )
-
/*****************************************************************************/
static const char fmt[] = "inf\0INF\0nan\0NAN\0.\0,";
@@ -201,8 +180,6 @@ static const __fpmax_t exp16_table[] = {
#define FPO_STR_PREC 'p'
ssize_t _fpmaxtostr(FILE * fp, __fpmax_t x, struct printf_info *info,
- __fp_outfunc_t fp_outfunc) attribute_hidden;
-ssize_t _fpmaxtostr(FILE * fp, __fpmax_t x, struct printf_info *info,
__fp_outfunc_t fp_outfunc)
{
#ifdef __UCLIBC_HAS_HEXADECIMAL_FLOATS__
@@ -220,8 +197,8 @@ ssize_t _fpmaxtostr(FILE * fp, __fpmax_t x, struct printf_info *info,
#ifdef __UCLIBC_HAS_GLIBC_DIGIT_GROUPING__
int num_groups = 0;
int initial_group; /* This does not need to be initialized. */
- int tslen; /* This does not need to be initialized. */
- int nblk2; /* This does not need to be initialized. */
+ int tslen; /* This does not need to be initialized. */
+ int nblk2; /* This does not need to be initialized. */
const char *ts; /* This does not need to be initialized. */
#endif /* __UCLIBC_HAS_GLIBC_DIGIT_GROUPING__ */
int round, o_exp;
@@ -280,7 +257,13 @@ ssize_t _fpmaxtostr(FILE * fp, __fpmax_t x, struct printf_info *info,
if (x == 0) { /* Handle 0 now to avoid false positive. */
#ifdef __UCLIBC_HAVE_SIGNED_ZERO__
- if (zeroisnegative(x)) { /* Handle 'signed' zero. */
+ union {
+ double x;
+ struct {
+ unsigned int l1, l2;
+ } i;
+ } u = {x};
+ if (u.i.l1 ^ u.i.l2) { /* Handle 'signed' zero. */
*sign_str = '-';
}
#endif /* __UCLIBC_HAVE_SIGNED_ZERO__ */
@@ -501,8 +484,8 @@ ssize_t _fpmaxtostr(FILE * fp, __fpmax_t x, struct printf_info *info,
const char *p;
if (PRINT_INFO_FLAG_VAL(info,group)
- && *(p = __UCLIBC_CURLOCALE_DATA.grouping)
- ) {
+ && *(p = __UCLIBC_CURLOCALE->grouping)
+ ) {
int nblk1;
nblk2 = nblk1 = *p;
@@ -522,8 +505,8 @@ ssize_t _fpmaxtostr(FILE * fp, __fpmax_t x, struct printf_info *info,
tslen = 1;
} else {
#endif /* __UCLIBC_HAS_WCHAR__ */
- ts = __UCLIBC_CURLOCALE_DATA.thousands_sep;
- tslen = __UCLIBC_CURLOCALE_DATA.thousands_sep_len;
+ ts = __UCLIBC_CURLOCALE->thousands_sep;
+ tslen = __UCLIBC_CURLOCALE->thousands_sep_len;
#ifdef __UCLIBC_HAS_WCHAR__
}
#endif /* __UCLIBC_HAS_WCHAR__ */
@@ -576,8 +559,8 @@ ssize_t _fpmaxtostr(FILE * fp, __fpmax_t x, struct printf_info *info,
ppc[2] = (intptr_t)(fmt + DECPT_OFFSET);
} else {
#endif /* __UCLIBC_HAS_WCHAR__ */
- ppc[1] = __UCLIBC_CURLOCALE_DATA.decimal_point_len;
- ppc[2] = (intptr_t)(__UCLIBC_CURLOCALE_DATA.decimal_point);
+ ppc[1] = __UCLIBC_CURLOCALE->decimal_point_len;
+ ppc[2] = (intptr_t)(__UCLIBC_CURLOCALE->decimal_point);
#ifdef __UCLIBC_HAS_WCHAR__
}
#endif /* __UCLIBC_HAS_WCHAR__ */
diff --git a/libc/stdio/_fpmaxtostr.h b/libc/stdio/_fpmaxtostr.h
new file mode 100644
index 000000000..7694629ec
--- /dev/null
+++ b/libc/stdio/_fpmaxtostr.h
@@ -0,0 +1,49 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Copyright (C) 2000,2001,2003,2004 Manuel Novoa III <mjn3@codepoet.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ *
+ * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details.
+ */
+
+#ifndef _FPMAXTOSTR_H
+#define _FPMAXTOSTR_H 1
+
+#include <features.h>
+#define __need_size_t
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <printf.h>
+#include <sys/types.h>
+
+#ifdef __UCLIBC_HAS_FLOATS__
+# include <float.h>
+# include <bits/uClibc_fpmax.h>
+
+/* WARNING: Adjust _fp_out_wide() in _vfprintf.c if this changes! */
+/* With 32 bit ints, we can get 9 decimal digits per block. */
+# define DIGITS_PER_BLOCK 9
+
+# define NUM_DIGIT_BLOCKS ((DECIMAL_DIG+DIGITS_PER_BLOCK-1)/DIGITS_PER_BLOCK)
+
+/* WARNING: Adjust _fp_out_wide() in _vfprintf.c if this changes! */
+/* extra space for '-', '.', 'e+###', and nul */
+# define BUF_SIZE ( 3 + NUM_DIGIT_BLOCKS * DIGITS_PER_BLOCK )
+
+/* psm: why do these internals differ? */
+# ifdef __USE_OLD_VFPRINTF__
+typedef void (__fp_outfunc_t)(FILE *fp, intptr_t type, intptr_t len, intptr_t buf);
+
+extern size_t _fpmaxtostr(FILE * fp, __fpmax_t x, struct printf_info *info,
+ __fp_outfunc_t fp_outfunc) attribute_hidden;
+# else
+typedef size_t (__fp_outfunc_t)(FILE *fp, intptr_t type, intptr_t len, intptr_t buf);
+
+extern ssize_t _fpmaxtostr(FILE * fp, __fpmax_t x, struct printf_info *info,
+ __fp_outfunc_t fp_outfunc) attribute_hidden;
+# endif
+
+# endif /* __UCLIBC_HAS_FLOATS__ */
+#endif /* _FPMAXTOSTR_H */
diff --git a/libc/stdio/_fwrite.c b/libc/stdio/_fwrite.c
index ba4b02fb1..47860afbf 100644
--- a/libc/stdio/_fwrite.c
+++ b/libc/stdio/_fwrite.c
@@ -7,9 +7,6 @@
#include "_stdio.h"
-/* Experimentally off - libc_hidden_proto(memchr) */
-/* Experimentally off - libc_hidden_proto(memcpy) */
-/* Experimentally off - libc_hidden_proto(memrchr) */
#ifdef __STDIO_BUFFERS
diff --git a/libc/stdio/_load_inttype.c b/libc/stdio/_load_inttype.c
index 057f5f256..8c0a60abe 100644
--- a/libc/stdio/_load_inttype.c
+++ b/libc/stdio/_load_inttype.c
@@ -8,7 +8,6 @@
#include "_stdio.h"
#include <printf.h>
-uintmax_t _load_inttype(int desttype, register const void *src, int uflag) attribute_hidden;
uintmax_t _load_inttype(int desttype, register const void *src, int uflag)
{
if (uflag >= 0) { /* unsigned */
@@ -57,7 +56,7 @@ uintmax_t _load_inttype(int desttype, register const void *src, int uflag)
{
int x;
x = *((int *) src);
- if (desttype == __PA_FLAG_CHAR) x = (char) x;
+ if (desttype == __PA_FLAG_CHAR) x = (signed char) x;
#if SHRT_MAX != INT_MAX
if (desttype == PA_FLAG_SHORT) x = (short int) x;
#endif
diff --git a/libc/stdio/_rfill.c b/libc/stdio/_rfill.c
index d61b1a9f9..e9d2fa698 100644
--- a/libc/stdio/_rfill.c
+++ b/libc/stdio/_rfill.c
@@ -24,7 +24,7 @@ size_t attribute_hidden __stdio_rfill(register FILE *__restrict stream)
size_t rv;
__STDIO_STREAM_VALIDATE(stream);
- assert(stream->__filedes >= -1);
+ assert(stream->__filedes >= -2);
assert(__STDIO_STREAM_IS_READING(stream));
assert(!__STDIO_STREAM_BUFFER_RAVAIL(stream)); /* Buffer must be empty. */
assert(__STDIO_STREAM_BUFFER_SIZE(stream)); /* Must have a buffer. */
diff --git a/libc/stdio/_scanf.c b/libc/stdio/_scanf.c
index 3b004d5f0..80e49567f 100644
--- a/libc/stdio/_scanf.c
+++ b/libc/stdio/_scanf.c
@@ -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/>.
*/
/* Aug 1, 2003
@@ -43,7 +43,6 @@
* standards and from an official C standard defect report.
*/
-#define _ISOC99_SOURCE /* for LLONG_MAX primarily... */
#include <features.h>
#include "_stdio.h"
#include <stdlib.h>
@@ -77,41 +76,6 @@
#include <bits/uClibc_fpmax.h>
#endif /* __UCLIBC_HAS_FLOATS__ */
-/* Experimentally off - libc_hidden_proto(memcmp) */
-/* Experimentally off - libc_hidden_proto(memset) */
-/* Experimentally off - libc_hidden_proto(strcpy) */
-/* Experimentally off - libc_hidden_proto(strlen) */
-libc_hidden_proto(ungetc)
-libc_hidden_proto(vfscanf)
-libc_hidden_proto(vsscanf)
-libc_hidden_proto(fclose)
-libc_hidden_proto(getc_unlocked)
-libc_hidden_proto(__fgetc_unlocked)
-#ifdef __UCLIBC_HAS_WCHAR__
-libc_hidden_proto(wcslen)
-libc_hidden_proto(vfwscanf)
-libc_hidden_proto(vswscanf)
-libc_hidden_proto(mbsrtowcs)
-libc_hidden_proto(mbrtowc)
-libc_hidden_proto(wcrtomb)
-libc_hidden_proto(ungetwc)
-libc_hidden_proto(iswspace)
-libc_hidden_proto(fgetwc_unlocked)
-#endif
-#ifdef __UCLIBC_HAS_XLOCALE__
-libc_hidden_proto(__ctype_b_loc)
-#elif defined __UCLIBC_HAS_CTYPE_TABLES__
-libc_hidden_proto(__ctype_b)
-#endif
-
-#ifdef __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__
-#ifdef L_vfscanf
-/* only emit this once */
-#warning Forcing undef of __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__ until implemented!
-#endif
-#undef __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__
-#endif
-
#undef __STDIO_HAS_VSSCANF
#if defined(__STDIO_BUFFERS) || !defined(__UCLIBC_HAS_WCHAR__) || defined(__UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__)
#define __STDIO_HAS_VSSCANF 1
@@ -126,8 +90,6 @@ typedef struct {
#endif
-extern void _store_inttype(void *dest, int desttype, uintmax_t val);
-
#if defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX)
extern unsigned long long
@@ -165,7 +127,6 @@ _stdlib_strto_l(register const char * __restrict str,
/**********************************************************************/
#ifdef L_fscanf
-libc_hidden_proto(fscanf)
int fscanf(FILE * __restrict stream, const char * __restrict format, ...)
{
va_list arg;
@@ -201,7 +162,6 @@ int scanf(const char * __restrict format, ...)
#ifdef __STDIO_HAS_VSSCANF
-libc_hidden_proto(sscanf)
int sscanf(const char * __restrict str, const char * __restrict format, ...)
{
va_list arg;
@@ -223,12 +183,10 @@ libc_hidden_def(sscanf)
/**********************************************************************/
#ifdef L_vscanf
-libc_hidden_proto(vscanf)
int vscanf(const char * __restrict format, va_list arg)
{
return vfscanf(stdin, format, arg);
}
-libc_hidden_def(vscanf)
#endif
/**********************************************************************/
@@ -240,19 +198,10 @@ libc_hidden_def(vscanf)
#ifdef __STDIO_BUFFERS
-int vsscanf(__const char *sp, __const char *fmt, va_list ap)
+int vsscanf(const char *sp, const char *fmt, va_list ap)
{
FILE f;
-/* __STDIO_STREAM_RESET_GCS(&f); */
-#ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__
- f.__cookie = &(f.__filedes);
- f.__gcs.read = NULL;
- f.__gcs.write = NULL;
- f.__gcs.seek = NULL;
- f.__gcs.close = NULL;
-#endif
-
f.__filedes = __STDIO_STREAM_FAKE_VSSCANF_FILEDES;
f.__modeflags = (__FLAG_NARROW|__FLAG_READONLY|__FLAG_READING);
@@ -265,7 +214,7 @@ int vsscanf(__const char *sp, __const char *fmt, va_list ap)
#ifdef __UCLIBC_HAS_THREADS__
f.__user_locking = 1; /* Set user locking. */
- __stdio_init_mutex(&f.__lock);
+ STDIO_INIT_MUTEX(f.__lock);
#endif
f.__nextopen = NULL;
@@ -284,22 +233,13 @@ libc_hidden_def(vsscanf)
#elif !defined(__UCLIBC_HAS_WCHAR__)
-int vsscanf(__const char *sp, __const char *fmt, va_list ap)
+int vsscanf(const char *sp, const char *fmt, va_list ap)
{
__FILE_vsscanf f;
f.bufpos = (unsigned char *) ((void *) sp);
f.bufread = f.bufpos + strlen(sp);
-/* __STDIO_STREAM_RESET_GCS(&f.f); */
-#ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__
- f.f.__cookie = &(f.f.__filedes);
- f.f.__gcs.read = NULL;
- f.f.__gcs.write = NULL;
- f.f.__gcs.seek = NULL;
- f.f.__gcs.close = NULL;
-#endif
-
f.f.__filedes = __STDIO_STREAM_FAKE_VSSCANF_FILEDES_NB;
f.f.__modeflags = (__FLAG_NARROW|__FLAG_READONLY|__FLAG_READING);
@@ -313,7 +253,7 @@ int vsscanf(__const char *sp, __const char *fmt, va_list ap)
#ifdef __UCLIBC_HAS_THREADS__
f.f.__user_locking = 1; /* Set user locking. */
- __stdio_init_mutex(&f.f.__lock);
+ STDIO_INIT_MUTEX(f.f.__lock);
#endif
f.f.__nextopen = NULL;
@@ -323,7 +263,7 @@ libc_hidden_def(vsscanf)
#elif defined(__UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__)
-int vsscanf(__const char *sp, __const char *fmt, va_list ap)
+int vsscanf(const char *sp, const char *fmt, va_list ap)
{
FILE *f;
int rv = EOF;
@@ -419,21 +359,12 @@ int vswscanf(const wchar_t * __restrict str, const wchar_t * __restrict format,
FILE f;
f.__bufstart =
- f.__bufpos = (char *) str;
+ f.__bufpos = (unsigned char *) str;
f.__bufread =
- f.__bufend = (char *)(str + wcslen(str));
+ f.__bufend = (unsigned char *)(str + wcslen(str));
__STDIO_STREAM_DISABLE_GETC(&f);
__STDIO_STREAM_DISABLE_PUTC(&f);
-/* __STDIO_STREAM_RESET_GCS(&f); */
-#ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__
- f.__cookie = &(f.__filedes);
- f.__gcs.read = NULL;
- f.__gcs.write = NULL;
- f.__gcs.seek = NULL;
- f.__gcs.close = NULL;
-#endif
-
f.__filedes = __STDIO_STREAM_FAKE_VSWSCANF_FILEDES;
f.__modeflags = (__FLAG_WIDE|__FLAG_READONLY|__FLAG_READING);
@@ -446,7 +377,7 @@ int vswscanf(const wchar_t * __restrict str, const wchar_t * __restrict format,
#ifdef __UCLIBC_HAS_THREADS__
f.__user_locking = 1; /* Set user locking. */
- __stdio_init_mutex(&f.__lock);
+ STDIO_INIT_MUTEX(f.__lock);
#endif
f.__nextopen = NULL;
@@ -464,18 +395,19 @@ libc_hidden_def(vswscanf)
/* float layout 0123456789012345678901 repeat n for "l[" */
-#define SPEC_CHARS "npxXoudifFeEgGaACSncs["
-/* npxXoudif eEgG CS cs[ */
+#define SPEC_CHARS "npxXoudifFeEgGaACSnmcs["
+/* npxXoudif eEgG CS cs[ */
+/* NOTE: the 'm' flag must come before any convs that support it */
-/* NOTE: Ordering is important! In particular, CONV_LEFTBRACKET
- * must immediately precede CONV_c. */
+/* NOTE: Ordering is important! The CONV_{C,S,LEFTBRACKET} must map
+ simply to their lowercase equivalents. */
enum {
CONV_n = 0,
CONV_p,
CONV_x, CONV_X, CONV_o, CONV_u, CONV_d, CONV_i,
CONV_f, CONV_F, CONV_e, CONV_E, CONV_g, CONV_G, CONV_a, CONV_A,
- CONV_C, CONV_S, CONV_LEFTBRACKET, CONV_c, CONV_s, CONV_leftbracket,
+ CONV_C, CONV_S, CONV_LEFTBRACKET, CONV_m, CONV_c, CONV_s, CONV_leftbracket,
CONV_percent, CONV_whitespace /* not in SPEC_* and no flags */
};
@@ -505,7 +437,7 @@ enum {
FLAG_SURPRESS = 0x10, /* MUST BE 1ST!! See DO_FLAGS. */
FLAG_THOUSANDS = 0x20,
FLAG_I18N = 0x40, /* only works for d, i, u */
- FLAG_MALLOC = 0x80, /* only works for s, S, and [ (and l[)*/
+ FLAG_MALLOC = 0x80, /* only works for c, s, S, and [ (and l[)*/
};
@@ -522,7 +454,7 @@ enum {
/* fFeEgGaA */ (0x0c|FLAG_SURPRESS|FLAG_THOUSANDS|FLAG_I18N), \
/* C */ ( 0|FLAG_SURPRESS), \
/* S and l[ */ ( 0|FLAG_SURPRESS|FLAG_MALLOC), \
- /* c */ (0x04|FLAG_SURPRESS), \
+ /* c */ (0x04|FLAG_SURPRESS|FLAG_MALLOC), \
/* s and [ */ (0x04|FLAG_SURPRESS|FLAG_MALLOC), \
}
@@ -580,21 +512,22 @@ enum {
#elif defined(LLONG_MAX) && (INTMAX_MAX == LLONG_MAX)
#define IMS 8
#else
-#error fix QUAL_CHARS ptrdiff_t entry 't'!
+#error fix QUAL_CHARS intmax_t entry 'j'!
#endif
#define QUAL_CHARS { \
/* j:(u)intmax_t z:(s)size_t t:ptrdiff_t \0:int q:long_long */ \
'h', 'l', 'L', 'j', 'z', 't', 'q', 0, \
- 2, 4, 8, IMS, SS, PDS, 8, 0, /* TODO -- fix!!! */\
- 1, 8 }
+ 2, 4, 8, IMS, SS, PDS, 8, 0, /* TODO -- fix!!! */ \
+ 1, 8 \
+}
/**********************************************************************/
#ifdef L_vfwscanf
-#if WINT_MIN > EOF
-#error Unfortunately, we currently need wint_t to be able to store EOF. Sorry.
+#if WINT_MIN > WEOF
+#error Unfortunately, we currently need wint_t to be able to store WEOF. Sorry.
#endif
#define W_EOF WEOF
#define Wint wint_t
@@ -717,26 +650,26 @@ void attribute_hidden __init_scan_cookie(register struct scan_cookie *sc,
#endif /* __UCLIBC_HAS_WCHAR__ */
#ifdef __UCLIBC_HAS_GLIBC_DIGIT_GROUPING__
- if (*(sc->grouping = __UCLIBC_CURLOCALE_DATA.grouping)) {
- sc->thousands_sep = __UCLIBC_CURLOCALE_DATA.thousands_sep;
- sc->tslen = __UCLIBC_CURLOCALE_DATA.thousands_sep_len;
+ if (*(sc->grouping = __UCLIBC_CURLOCALE->grouping)) {
+ sc->thousands_sep = (const unsigned char *) __UCLIBC_CURLOCALE->thousands_sep;
+ sc->tslen = __UCLIBC_CURLOCALE->thousands_sep_len;
#ifdef __UCLIBC_HAS_WCHAR__
- sc->thousands_sep_wc = __UCLIBC_CURLOCALE_DATA.thousands_sep_wc;
+ sc->thousands_sep_wc = __UCLIBC_CURLOCALE->thousands_sep_wc;
#endif /* __UCLIBC_HAS_WCHAR__ */
}
#endif /* __UCLIBC_HAS_GLIBC_DIGIT_GROUPING__ */
#ifdef __UCLIBC_HAS_FLOATS__
#ifdef __UCLIBC_HAS_LOCALE__
- sc->decpt = __UCLIBC_CURLOCALE_DATA.decimal_point;
- sc->decpt_len = __UCLIBC_CURLOCALE_DATA.decimal_point_len;
+ sc->decpt = (const unsigned char *) __UCLIBC_CURLOCALE->decimal_point;
+ sc->decpt_len = __UCLIBC_CURLOCALE->decimal_point_len;
#else /* __UCLIBC_HAS_LOCALE__ */
sc->fake_decpt = sc->decpt = (unsigned char *) decpt_str;
sc->decpt_len = 1;
#endif /* __UCLIBC_HAS_LOCALE__ */
#ifdef __UCLIBC_HAS_WCHAR__
#ifdef __UCLIBC_HAS_LOCALE__
- sc->decpt_wc = __UCLIBC_CURLOCALE_DATA.decimal_point_wc;
+ sc->decpt_wc = __UCLIBC_CURLOCALE->decimal_point_wc;
#else
sc->decpt_wc = '.';
#endif
@@ -933,17 +866,17 @@ int attribute_hidden __psfs_parse_spec(register psfs_t *psfs)
if (*psfs->fmt == *p) {
int p_m_spec_chars = p - spec_chars;
-#ifdef __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__
-#error implement gnu a flag
- if ((*p == 'a')
- && ((psfs->fmt[1] == '[') || ((psfs->fmt[1]|0x20) == 's'))
- ) { /* Assumes ascii for 's' and 'S' test. */
- psfs->flags |= FLAG_MALLOC;
+ if (*p == 'm' &&
+ (psfs->fmt[1] == '[' || psfs->fmt[1] == 'c' ||
+ /* Assumes ascii for 's' and 'S' test. */
+ (psfs->fmt[1] | 0x20) == 's'))
+ {
+ if (psfs->store)
+ psfs->flags |= FLAG_MALLOC;
++psfs->fmt;
++p;
- continue; /* The related conversions follow 'a'. */
+ continue; /* The related conversions follow 'm'. */
}
-#endif /* __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__ */
for (p = spec_ranges; p_m_spec_chars > *p ; ++p) {}
if (((psfs->dataargtype >> 8) | psfs->flags)
@@ -952,9 +885,12 @@ int attribute_hidden __psfs_parse_spec(register psfs_t *psfs)
goto ERROR_EINVAL;
}
- if ((p_m_spec_chars >= CONV_c)
+ if (p_m_spec_chars == CONV_p) {
+ /* a pointer has the same size as 'long int' */
+ psfs->dataargtype = PA_FLAG_LONG;
+ } else if ((p_m_spec_chars >= CONV_c)
&& (psfs->dataargtype & PA_FLAG_LONG)) {
- p_m_spec_chars -= 3; /* lc -> C, ls -> S, l[ -> ?? */
+ p_m_spec_chars -= CONV_c - CONV_C; /* lc -> C, ls -> S, l[ -> ?? */
}
psfs->conv_num = p_m_spec_chars;
@@ -1154,22 +1090,12 @@ static __inline void kill_scan_cookie(register struct scan_cookie *sc)
#endif
}
-#ifdef L_vfwscanf
-#ifdef __UCLIBC_HAS_FLOATS__
-static const char fake_decpt_str[] = ".";
-#endif
-#ifdef __UCLIBC_HAS_GLIBC_DIGIT_GROUPING__
-static const char fake_thousands_sep_str[] = ",";
-#endif
-#endif /* L_vfwscanf */
-
int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
{
const Wuchar *fmt;
unsigned char *b;
-
#ifdef L_vfwscanf
wchar_t wbuf[1];
wchar_t *wb;
@@ -1181,7 +1107,6 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
struct scan_cookie sc;
psfs_t psfs;
-
int i;
#ifdef __UCLIBC_MJN3_ONLY__
@@ -1191,7 +1116,7 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
unsigned char buf[MAX_DIGITS+2];
#ifdef L_vfscanf
unsigned char scanset[UCHAR_MAX + 1];
- unsigned char invert; /* Careful! Meaning changes. */
+ unsigned char invert = 0; /* Careful! Meaning changes. */
#endif /* L_vfscanf */
unsigned char fail;
unsigned char zero_conversions = 1;
@@ -1204,7 +1129,7 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
#if defined(__UCLIBC_HAS_LOCALE__) && !defined(L_vfwscanf)
/* ANSI/ISO C99 requires format string to be a valid multibyte string
* beginning and ending in its initial shift state. */
- if (((__UCLIBC_CURLOCALE_DATA).encoding) != __ctype_encoding_7_bit) {
+ if (__UCLIBC_CURLOCALE->encoding != __ctype_encoding_7_bit) {
const char *p = format;
mbstate.__mask = 0; /* Initialize the mbstate. */
if (mbsrtowcs(NULL, &p, SIZE_MAX, &mbstate) == ((size_t)(-1))) {
@@ -1233,13 +1158,13 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
#ifdef __UCLIBC_HAS_GLIBC_DIGIT_GROUPING__
if (*sc.grouping) {
- sc.thousands_sep = fake_thousands_sep_str;
+ sc.thousands_sep = (const unsigned char *) ",";
sc.tslen = 1;
}
#endif /* __UCLIBC_HAS_GLIBC_DIGIT_GROUPING__ */
#ifdef __UCLIBC_HAS_FLOATS__
- sc.fake_decpt = fake_decpt_str;
+ sc.fake_decpt = (const unsigned char *) ".";
#endif /* __UCLIBC_HAS_FLOATS__ */
#else /* L_vfwscanf */
@@ -1302,12 +1227,6 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
while (*wf && __isascii(*wf) && (b < buf + sizeof(buf) - 1)) {
*b++ = *wf++;
}
-#ifdef __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__
-#error this is wrong... we need to ched in __psfs_parse_spec instead since this checks last char in buffer and conversion my have stopped before it.
- if ((*b == 'a') && ((*wf == '[') || ((*wf|0x20) == 's'))) {
- goto DONE; /* Spec was excessively long. */
- }
-#endif /* __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__ */
*b = 0;
if (b == buf) { /* Bad conversion specifier! */
goto DONE;
@@ -1405,7 +1324,20 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
(psfs.conv_num >= CONV_c)
#endif /* __UCLIBC_HAS_WCHAR__ */
{
+ /* We might have to handle the allocation ourselves */
+ int len;
+ unsigned char **ptr;
+
b = (psfs.store ? ((unsigned char *) psfs.cur_ptr) : buf);
+ /* With 'm', we actually got a pointer to a pointer */
+ ptr = (void *)b;
+
+ if (psfs.flags & FLAG_MALLOC) {
+ len = 0;
+ b = NULL;
+ } else
+ len = -1;
+
fail = 1;
if (psfs.conv_num == CONV_c) {
@@ -1413,27 +1345,42 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
sc.width = 1;
}
+ if (psfs.flags & FLAG_MALLOC)
+ b = malloc(sc.width);
+
+ i = 0;
while (__scan_getc(&sc) >= 0) {
zero_conversions = 0;
- *b = sc.cc;
- b += psfs.store;
+ b[i] = sc.cc;
+ i += psfs.store;
}
__scan_ungetc(&sc);
if (sc.width > 0) { /* Failed to read all required. */
goto DONE;
}
+ if (psfs.flags & FLAG_MALLOC)
+ *ptr = b;
psfs.cnt += psfs.store;
goto NEXT_FMT;
}
if (psfs.conv_num == CONV_s) {
+
+ i = 0;
/* Yes, believe it or not, a %s conversion can store nuls. */
while ((__scan_getc(&sc) >= 0) && !isspace(sc.cc)) {
zero_conversions = 0;
- *b = sc.cc;
- b += psfs.store;
+ if (i == len) {
+ /* Pick a size that won't trigger a lot of
+ * mallocs early on ... */
+ len += 256;
+ b = realloc(b, len + 1);
+ }
+ b[i] = sc.cc;
+ i += psfs.store;
fail = 0;
}
+
} else {
#ifdef __UCLIBC_HAS_WCHAR__
assert((psfs.conv_num == CONV_LEFTBRACKET) || \
@@ -1484,13 +1431,20 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
#endif /* __UCLIBC_HAS_WCHAR__ */
+ i = 0;
while (__scan_getc(&sc) >= 0) {
zero_conversions = 0;
if (!scanset[sc.cc]) {
break;
}
- *b = sc.cc;
- b += psfs.store;
+ if (i == len) {
+ /* Pick a size that won't trigger a lot of
+ * mallocs early on ... */
+ len += 256;
+ b = realloc(b, len + 1);
+ }
+ b[i] = sc.cc;
+ i += psfs.store;
fail = 0;
}
}
@@ -1500,6 +1454,9 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
if (fail) { /* nothing stored! */
goto DONE;
}
+ if (psfs.flags & FLAG_MALLOC)
+ *ptr = b;
+ b += i;
*b = 0; /* Nul-terminate string. */
psfs.cnt += psfs.store;
goto NEXT_FMT;
@@ -1607,7 +1564,7 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
*wb = sc.wc;
wb += psfs.store;
} else {
- i = wcrtomb(b, sc.wc, &mbstate);
+ i = wcrtomb((char*) b, sc.wc, &mbstate);
if (i < 0) { /* Conversion failure. */
goto DONE_DO_UNGET;
}
@@ -1635,7 +1592,7 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
*wb = sc.wc;
wb += psfs.store;
} else {
- i = wcrtomb(b, sc.wc, &mbstate);
+ i = wcrtomb((char*) b, sc.wc, &mbstate);
if (i < 0) { /* Conversion failure. */
goto DONE_DO_UNGET;
}
@@ -1709,7 +1666,7 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
*wb = sc.wc;
wb += psfs.store;
} else {
- i = wcrtomb(b, sc.wc, &mbstate);
+ i = wcrtomb((char*) b, sc.wc, &mbstate);
if (i < 0) { /* Conversion failure. */
goto DONE_DO_UNGET;
}
@@ -1882,7 +1839,7 @@ int attribute_hidden __psfs_do_numeric(psfs_t *psfs, struct scan_cookie *sc)
#ifdef __UCLIBC_HAS_GLIBC_DIGIT_GROUPING__
if ((psfs->flags & FLAG_THOUSANDS) && (base == 10)
- && *(p = sc->grouping)
+ && *(p = (const unsigned char *) sc->grouping)
) {
int nblk1, nblk2, nbmax, lastblock, pass, i;
@@ -2004,7 +1961,7 @@ int attribute_hidden __psfs_do_numeric(psfs_t *psfs, struct scan_cookie *sc)
p = sc->fake_decpt + k;
do {
if (!*++p) {
- strcpy(b, sc->decpt);
+ strcpy((char*) b, (char*) sc->decpt);
b += sc->decpt_len;
goto GOT_DECPT;
}
diff --git a/libc/stdio/_stdio.c b/libc/stdio/_stdio.c
index d8c0ae20d..2a1054618 100644
--- a/libc/stdio/_stdio.c
+++ b/libc/stdio/_stdio.c
@@ -7,9 +7,6 @@
#include "_stdio.h"
-/* Experimentally off - libc_hidden_proto(memcpy) */
-libc_hidden_proto(isatty)
-
/* This is pretty much straight from uClibc, but with one important
* difference.
*
@@ -54,13 +51,6 @@ libc_hidden_proto(isatty)
#define __STDIO_FILE_INIT_BUFFERS(buf,bufsize)
#endif
-#ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__
-#define __STDIO_FILE_INIT_CUSTOM_STREAM(stream) \
- &((stream).__filedes), { _cs_read, _cs_write, _cs_seek, _cs_close },
-#else
-#define __STDIO_FILE_INIT_CUSTOM_STREAM(stream)
-#endif
-
#ifdef __STDIO_MBSTATE
#define __STDIO_FILE_INIT_MBSTATE \
{ 0, 0 },
@@ -76,8 +66,13 @@ libc_hidden_proto(isatty)
#endif
#ifdef __UCLIBC_HAS_THREADS__
+#ifdef __USE_STDIO_FUTEXES__
+#define __STDIO_FILE_INIT_THREADSAFE \
+ 2, _LIBC_LOCK_RECURSIVE_INITIALIZER,
+#else
#define __STDIO_FILE_INIT_THREADSAFE \
2, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP,
+#endif
#else
#define __STDIO_FILE_INIT_THREADSAFE
#endif
@@ -90,7 +85,6 @@ libc_hidden_proto(isatty)
__STDIO_FILE_INIT_BUFGETC((buf)) \
__STDIO_FILE_INIT_BUFPUTC((buf)) \
__STDIO_FILE_INIT_NEXT(next) \
- __STDIO_FILE_INIT_CUSTOM_STREAM(stream) \
__STDIO_FILE_INIT_WUNGOT \
__STDIO_FILE_INIT_MBSTATE \
__STDIO_FILE_INIT_UNUSED \
@@ -154,14 +148,13 @@ FILE *__stdout = _stdio_streams + 1; /* For putchar() macro. */
FILE *_stdio_openlist = _stdio_streams;
# ifdef __UCLIBC_HAS_THREADS__
-__UCLIBC_MUTEX_INIT(_stdio_openlist_add_lock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP);
-#ifdef __STDIO_BUFFERS
-__UCLIBC_MUTEX_INIT(_stdio_openlist_del_lock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP);
+__UCLIBC_IO_MUTEX_INIT(_stdio_openlist_add_lock);
+# ifdef __STDIO_BUFFERS
+__UCLIBC_IO_MUTEX_INIT(_stdio_openlist_del_lock);
volatile int _stdio_openlist_use_count = 0;
int _stdio_openlist_del_count = 0;
-#endif
+# endif
# endif
-
#endif
/**********************************************************************/
#ifdef __UCLIBC_HAS_THREADS__
@@ -169,6 +162,7 @@ int _stdio_openlist_del_count = 0;
/* 2 if threading not initialized and 0 otherwise; */
int _stdio_user_locking = 2;
+#ifndef __USE_STDIO_FUTEXES__
void attribute_hidden __stdio_init_mutex(__UCLIBC_MUTEX_TYPE *m)
{
const __UCLIBC_MUTEX_STATIC(__stdio_mutex_initializer,
@@ -176,12 +170,13 @@ void attribute_hidden __stdio_init_mutex(__UCLIBC_MUTEX_TYPE *m)
memcpy(m, &__stdio_mutex_initializer, sizeof(__stdio_mutex_initializer));
}
+#endif
#endif
/**********************************************************************/
/* We assume here that we are the only remaining thread. */
-void attribute_hidden _stdio_term(void)
+void _stdio_term(void)
{
#if defined(__STDIO_BUFFERS) || defined(__UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__)
register FILE *ptr;
@@ -191,10 +186,9 @@ void attribute_hidden _stdio_term(void)
* locked, then I suppose there is a chance that a pointer in the
* chain might be corrupt due to a partial store.
*/
- __stdio_init_mutex(&_stdio_openlist_add_lock);
-#warning check
+ STDIO_INIT_MUTEX(_stdio_openlist_add_lock);
#ifdef __STDIO_BUFFERS
- __stdio_init_mutex(&_stdio_openlist_del_lock);
+ STDIO_INIT_MUTEX(_stdio_openlist_del_lock);
#endif
/* Next we need to worry about the streams themselves. If a stream
@@ -216,7 +210,7 @@ void attribute_hidden _stdio_term(void)
}
ptr->__user_locking = 1; /* Set locking mode to "by caller". */
- __stdio_init_mutex(&ptr->__lock); /* Shouldn't be necessary, but... */
+ STDIO_INIT_MUTEX(ptr->__lock); /* Shouldn't be necessary, but... */
}
#endif
@@ -238,7 +232,7 @@ void attribute_hidden _stdio_term(void)
#endif
#ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__
/* Actually close all custom streams to perform any special cleanup. */
- if (ptr->__cookie != &ptr->__filedes) {
+ if (__STDIO_STREAM_IS_CUSTOM(ptr)) {
__CLOSE(ptr);
}
#endif
@@ -248,13 +242,15 @@ void attribute_hidden _stdio_term(void)
}
#if defined __STDIO_BUFFERS || !defined __UCLIBC__
-void attribute_hidden _stdio_init(void)
+void _stdio_init(void)
{
#ifdef __STDIO_BUFFERS
int old_errno = errno;
/* stdin and stdout uses line buffering when connected to a tty. */
- _stdio_streams[0].__modeflags ^= (1-isatty(0)) * __FLAG_LBF;
- _stdio_streams[1].__modeflags ^= (1-isatty(1)) * __FLAG_LBF;
+ if (!isatty(0))
+ _stdio_streams[0].__modeflags ^= __FLAG_LBF;
+ if (!isatty(1))
+ _stdio_streams[1].__modeflags ^= __FLAG_LBF;
__set_errno(old_errno);
#endif
#ifndef __UCLIBC__
@@ -271,27 +267,18 @@ void attribute_hidden _stdio_init(void)
#error Assumption violated about __MASK_READING and __FLAG_UNGOT
#endif
-#ifdef __UCLIBC_HAS_THREADS__
-#include <pthread.h>
-#endif
-
#ifndef NDEBUG
-void _stdio_validate_FILE(const FILE *stream)
+void attribute_hidden _stdio_validate_FILE(const FILE *stream)
{
#ifdef __UCLIBC_HAS_THREADS__
assert(((unsigned int)(stream->__user_locking)) <= 2);
#endif
#warning Define a constant for minimum possible valid __filedes?
- assert(stream->__filedes >= -3);
+ assert(stream->__filedes >= -4);
if (stream->__filedes < 0) {
-/* assert((stream->__filedes != -1) */
-/* #ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__ */
-/* || (stream->__cookie == &stream->__filedes) /\* custom *\/ */
-/* #endif */
-/* ); */
/* assert((stream->__filedes == -1) || __STDIO_STREAM_IS_FBF(stream)); */
assert(!__STDIO_STREAM_IS_FAKE_VSNPRINTF(stream)
@@ -308,12 +295,6 @@ void _stdio_validate_FILE(const FILE *stream)
#endif
}
-#ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__
- if (stream->__cookie != &stream->__filedes) { /* custom */
- assert(stream->__filedes == -1);
- }
-#endif
-
/* Can not be both narrow and wide oriented at the same time. */
assert(!(__STDIO_STREAM_IS_NARROW(stream)
&& __STDIO_STREAM_IS_WIDE(stream)));
diff --git a/libc/stdio/_stdio.h b/libc/stdio/_stdio.h
index 27075a8ac..310510d66 100644
--- a/libc/stdio/_stdio.h
+++ b/libc/stdio/_stdio.h
@@ -4,6 +4,8 @@
*
* Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details.
*/
+#ifndef __STDIO_H_I
+#define __STDIO_H_I 1
#include <features.h>
#include <assert.h>
@@ -24,21 +26,24 @@
#include <bits/uClibc_mutex.h>
#define __STDIO_THREADLOCK_OPENLIST_ADD \
- __UCLIBC_MUTEX_LOCK(_stdio_openlist_add_lock)
+ __UCLIBC_IO_MUTEX_LOCK(_stdio_openlist_add_lock)
#define __STDIO_THREADUNLOCK_OPENLIST_ADD \
- __UCLIBC_MUTEX_UNLOCK(_stdio_openlist_add_lock)
+ __UCLIBC_IO_MUTEX_UNLOCK(_stdio_openlist_add_lock)
#ifdef __STDIO_BUFFERS
#define __STDIO_THREADLOCK_OPENLIST_DEL \
- __UCLIBC_MUTEX_LOCK(_stdio_openlist_del_lock)
+ __UCLIBC_IO_MUTEX_LOCK(_stdio_openlist_del_lock)
#define __STDIO_THREADUNLOCK_OPENLIST_DEL \
- __UCLIBC_MUTEX_UNLOCK(_stdio_openlist_del_lock)
+ __UCLIBC_IO_MUTEX_UNLOCK(_stdio_openlist_del_lock)
#ifdef __UCLIBC_HAS_THREADS__
+extern void __stdio_init_mutex(__UCLIBC_MUTEX_TYPE *m) attribute_hidden;
+
+extern volatile int _stdio_openlist_use_count attribute_hidden; /* _stdio_openlist_del_lock */
#define __STDIO_OPENLIST_INC_USE \
do { \
__STDIO_THREADLOCK_OPENLIST_DEL; \
@@ -46,11 +51,12 @@ do { \
__STDIO_THREADUNLOCK_OPENLIST_DEL; \
} while (0)
-extern void _stdio_openlist_dec_use(void);
+extern void _stdio_openlist_dec_use(void) attribute_hidden;
#define __STDIO_OPENLIST_DEC_USE \
_stdio_openlist_dec_use()
+extern int _stdio_openlist_del_count attribute_hidden; /* _stdio_openlist_del_lock */
#define __STDIO_OPENLIST_INC_DEL_CNT \
do { \
__STDIO_THREADLOCK_OPENLIST_DEL; \
@@ -92,48 +98,61 @@ do { \
/**********************************************************************/
#ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__
-extern __ssize_t _cs_read(void *cookie, char *buf, size_t bufsize) attribute_hidden;
-extern __ssize_t _cs_write(void *cookie, const char *buf, size_t bufsize) attribute_hidden;
-extern int _cs_seek(void *cookie, __offmax_t *pos, int whence) attribute_hidden;
-extern int _cs_close(void *cookie) attribute_hidden;
-
-#define __STDIO_STREAM_RESET_GCS(S) \
- (S)->__cookie = &((S)->__filedes); \
- (S)->__gcs.read = _cs_read; \
- (S)->__gcs.write = _cs_write; \
- (S)->__gcs.seek = _cs_seek; \
- (S)->__gcs.close = _cs_close
-
-
-#define __READ(STREAMPTR,BUF,SIZE) \
- ((((STREAMPTR)->__gcs.read) == NULL) ? -1 : \
- (((STREAMPTR)->__gcs.read)((STREAMPTR)->__cookie,(BUF),(SIZE))))
-#define __WRITE(STREAMPTR,BUF,SIZE) \
- ((((STREAMPTR)->__gcs.write) == NULL) ? -1 : \
- (((STREAMPTR)->__gcs.write)((STREAMPTR)->__cookie,(BUF),(SIZE))))
-#define __SEEK(STREAMPTR,PPOS,WHENCE) \
- ((((STREAMPTR)->__gcs.seek) == NULL) ? -1 : \
- (((STREAMPTR)->__gcs.seek)((STREAMPTR)->__cookie,(PPOS),(WHENCE))))
-#define __CLOSE(STREAMPTR) \
- ((((STREAMPTR)->__gcs.close) == NULL) ? 0 : \
- (((STREAMPTR)->__gcs.close)((STREAMPTR)->__cookie)))
+#define __STDIO_STREAM_GLIBC_CUSTOM_FILEDES (-2)
+
+#define __STDIO_STREAM_IS_CUSTOM(S) \
+ ((S)->__filedes == __STDIO_STREAM_GLIBC_CUSTOM_FILEDES)
+
+#define __STDIO_STREAM_CUSTOM_IO_FUNC(S, NAME, RC, ARGS...) \
+ if (__STDIO_STREAM_IS_CUSTOM((S))) { \
+ _IO_cookie_file_t *cfile = (_IO_cookie_file_t *) (S); \
+ return (cfile->__gcs.NAME == NULL) ? (RC) : \
+ cfile->__gcs.NAME(cfile->__cookie, ##ARGS); \
+ }
+
+typedef struct {
+ struct __STDIO_FILE_STRUCT __fp;
+ void *__cookie;
+ _IO_cookie_io_functions_t __gcs;
+} _IO_cookie_file_t;
#else /* __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__ */
+#undef __STDIO_STREAM_GLIBC_CUSTOM_FILEDES
+#define __STDIO_STREAM_IS_CUSTOM(S) (0)
+#define __STDIO_STREAM_CUSTOM_IO_FUNC(S, NAME, RC, ARGS...)
+
+#endif /* __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__ */
+
extern int __stdio_seek(FILE *stream, register __offmax_t *pos, int whence) attribute_hidden;
-#define __STDIO_STREAM_RESET_GCS(S) ((void)0)
+static inline ssize_t __READ(FILE *stream, char *buf, size_t bufsize)
+{
+ __STDIO_STREAM_CUSTOM_IO_FUNC(stream, read, -1, buf, bufsize);
-#define __READ(STREAMPTR,BUF,SIZE) \
- (read((STREAMPTR)->__filedes,(BUF),(SIZE)))
-#define __WRITE(STREAMPTR,BUF,SIZE) \
- (write((STREAMPTR)->__filedes,(BUF),(SIZE)))
-#define __SEEK(STREAMPTR,PPOS,WHENCE) \
- (__stdio_seek((STREAMPTR),(PPOS),(WHENCE)))
-#define __CLOSE(STREAMPTR) \
- (close((STREAMPTR)->__filedes))
+ return read(stream->__filedes, buf, bufsize);
+}
-#endif /* __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__ */
+static inline ssize_t __WRITE(FILE *stream, const char *buf, size_t bufsize)
+{
+ __STDIO_STREAM_CUSTOM_IO_FUNC(stream, write, -1, buf, bufsize);
+
+ return write(stream->__filedes, buf, bufsize);
+}
+
+static inline int __SEEK(FILE *stream, register __offmax_t *pos, int whence)
+{
+ __STDIO_STREAM_CUSTOM_IO_FUNC(stream, seek, -1, pos, whence);
+
+ return __stdio_seek(stream, pos, whence);
+}
+
+static inline int __CLOSE(FILE *stream)
+{
+ __STDIO_STREAM_CUSTOM_IO_FUNC(stream, close, 0);
+
+ return close(stream->__filedes);
+}
/**********************************************************************/
#ifdef __UCLIBC_HAS_WCHAR__
@@ -250,12 +269,6 @@ extern int __stdio_seek(FILE *stream, register __offmax_t *pos, int whence) attr
# define __STDIO_STREAM_CAN_USE_BUFFER_ADD(S) (0)
#endif
-#ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__
-#define __STDIO_STREAM_IS_CUSTOM(S) ((S)->__cookie != &((S)->__filedes))
-#else
-#define __STDIO_STREAM_IS_CUSTOM(S) (0)
-#endif
-
/**********************************************************************/
#ifdef __STDIO_BUFFERS
@@ -308,6 +321,9 @@ extern int __stdio_trans2w(FILE *__restrict stream) attribute_hidden;
extern int __stdio_trans2r_o(FILE *__restrict stream, int oflag) attribute_hidden;
extern int __stdio_trans2w_o(FILE *__restrict stream, int oflag) attribute_hidden;
+extern uintmax_t _load_inttype(int desttype, register const void *src, int uflag) attribute_hidden;
+extern void _store_inttype(void *dest, int desttype, uintmax_t val) attribute_hidden;
+
/**********************************************************************/
#ifdef __STDIO_BUFFERS
@@ -339,10 +355,10 @@ extern int __stdio_trans2w_o(FILE *__restrict stream, int oflag) attribute_hidde
(S)->__bufread = (S)->__bufpos = (S)->__bufstart
-#define __STDIO_STREAM_FAKE_VSNPRINTF_FILEDES (-2)
-#define __STDIO_STREAM_FAKE_VSSCANF_FILEDES (-2)
-#define __STDIO_STREAM_FAKE_VSWPRINTF_FILEDES (-3)
-#define __STDIO_STREAM_FAKE_VSWSCANF_FILEDES (-3)
+#define __STDIO_STREAM_FAKE_VSNPRINTF_FILEDES (-3)
+#define __STDIO_STREAM_FAKE_VSSCANF_FILEDES (-3)
+#define __STDIO_STREAM_FAKE_VSWPRINTF_FILEDES (-4)
+#define __STDIO_STREAM_FAKE_VSWSCANF_FILEDES (-4)
#define __STDIO_STREAM_IS_FAKE_VSNPRINTF(S) \
((S)->__filedes == __STDIO_STREAM_FAKE_VSNPRINTF_FILEDES)
@@ -379,6 +395,7 @@ extern int __stdio_trans2w_o(FILE *__restrict stream, int oflag) attribute_hidde
#define __STDIO_STREAM_IS_FAKE_VSNPRINTF(S) (0)
#define __STDIO_STREAM_IS_FAKE_VSSCANF(S) (0)
#undef __STDIO_STREAM_IS_FAKE_VSWPRINTF
+#undef __STDIO_STREAM_IS_FAKE_VSWSCANF
# ifdef __USE_OLD_VFPRINTF__
# define __STDIO_STREAM_FAKE_VSNPRINTF_FILEDES_NB (-2)
@@ -408,7 +425,7 @@ extern int __stdio_adjust_position(FILE *__restrict stream, __offmax_t *pos) att
#ifdef NDEBUG
#define __STDIO_STREAM_VALIDATE(S) ((void)0)
#else
-extern void _stdio_validate_FILE(const FILE *stream);
+extern void _stdio_validate_FILE(const FILE *stream) attribute_hidden;
#define __STDIO_STREAM_VALIDATE(S) _stdio_validate_FILE((S))
#endif
@@ -454,3 +471,5 @@ extern int _vfwprintf_internal (FILE * __restrict stream,
#if defined(__STDIO_BUFFERS) || defined(__USE_OLD_VFPRINTF__) || defined(__UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__)
#define __STDIO_HAS_VSNPRINTF 1
#endif
+
+#endif /* __STDIO_H_I */
diff --git a/libc/stdio/_store_inttype.c b/libc/stdio/_store_inttype.c
index fdd4dce05..7ecfe6ed0 100644
--- a/libc/stdio/_store_inttype.c
+++ b/libc/stdio/_store_inttype.c
@@ -28,7 +28,6 @@
/* We assume int may be short or long, but short and long are different. */
-void _store_inttype(register void *dest, int desttype, uintmax_t val) attribute_hidden;
void _store_inttype(register void *dest, int desttype, uintmax_t val)
{
if (desttype == __PA_FLAG_CHAR) { /* assume char not int */
diff --git a/libc/stdio/_trans2w.c b/libc/stdio/_trans2w.c
index ed1a583fc..c72237939 100644
--- a/libc/stdio/_trans2w.c
+++ b/libc/stdio/_trans2w.c
@@ -7,7 +7,6 @@
#include "_stdio.h"
-libc_hidden_proto(fseek)
/* Function to handle transition to writing.
* Initialize or verify the stream's orientation (even if readonly).
diff --git a/libc/stdio/_uintmaxtostr.c b/libc/stdio/_uintmaxtostr.c
index 0d25a0a9f..82eb862e1 100644
--- a/libc/stdio/_uintmaxtostr.c
+++ b/libc/stdio/_uintmaxtostr.c
@@ -5,13 +5,11 @@
* Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details.
*/
-#define _ISOC99_SOURCE /* for ULLONG primarily... */
#include "_stdio.h"
#include <limits.h>
#include <locale.h>
#include <bits/uClibc_uintmaxtostr.h>
-/* Experimentally off - libc_hidden_proto(memcpy) */
/* Avoid using long long / and % operations to cut down dependencies on
* libgcc.a. Definitely helps on i386 at least. */
@@ -22,8 +20,8 @@
char attribute_hidden *_uintmaxtostr(register char * __restrict bufend, uintmax_t uval,
int base, __UIM_CASE alphacase)
{
- int negative;
- unsigned int digit;
+ int negative;
+ unsigned int digit;
#ifdef INTERNAL_DIV_MOD
unsigned int H, L, high, low, rh;
#endif
@@ -50,21 +48,21 @@ char attribute_hidden *_uintmaxtostr(register char * __restrict bufend, uintmax_
alphacase ^= outdigit;
if (alphacase == __UIM_GROUP) {
assert(base == 10);
- if (*(g = __UCLIBC_CURLOCALE_DATA.grouping)) {
+ if (*(g = __UCLIBC_CURLOCALE->grouping)) {
grouping = *g;
}
}
#endif /* __LOCALE_C_ONLY */
- *bufend = '\0';
+ *bufend = '\0';
#ifndef INTERNAL_DIV_MOD
- do {
+ do {
#ifndef __LOCALE_C_ONLY
if (!grouping) { /* Finished a group. */
- bufend -= __UCLIBC_CURLOCALE_DATA.thousands_sep_len;
- memcpy(bufend, __UCLIBC_CURLOCALE_DATA.thousands_sep,
- __UCLIBC_CURLOCALE_DATA.thousands_sep_len);
+ bufend -= __UCLIBC_CURLOCALE->thousands_sep_len;
+ memcpy(bufend, __UCLIBC_CURLOCALE->thousands_sep,
+ __UCLIBC_CURLOCALE->thousands_sep_len);
if (g[1] != 0) { /* g[1] == 0 means repeat last grouping. */
/* Note: g[1] == -1 means no further grouping. But since
* we'll never wrap around, we can set grouping to -1 without
@@ -80,16 +78,16 @@ char attribute_hidden *_uintmaxtostr(register char * __restrict bufend, uintmax_
#ifndef __LOCALE_C_ONLY
if (unlikely(outdigit)) {
- bufend -= __UCLIBC_CURLOCALE_DATA.outdigit_length[digit];
+ bufend -= __UCLIBC_CURLOCALE->outdigit_length[digit];
memcpy(bufend,
- (&__UCLIBC_CURLOCALE_DATA.outdigit0_mb)[digit],
- __UCLIBC_CURLOCALE_DATA.outdigit_length[digit]);
+ (&__UCLIBC_CURLOCALE->outdigit0_mb)[digit],
+ __UCLIBC_CURLOCALE->outdigit_length[digit]);
} else
#endif
{
*--bufend = ( (digit < 10) ? digit + '0' : digit + alphacase );
}
- } while (uval);
+ } while (uval);
#else /* ************************************************** */
@@ -102,12 +100,12 @@ char attribute_hidden *_uintmaxtostr(register char * __restrict bufend, uintmax_
low = (unsigned int) uval;
high = (unsigned int) (uval >> (sizeof(unsigned int) * CHAR_BIT));
- do {
+ do {
#ifndef __LOCALE_C_ONLY
if (!grouping) { /* Finished a group. */
- bufend -= __UCLIBC_CURLOCALE_DATA.thousands_sep_len;
- memcpy(bufend, __UCLIBC_CURLOCALE_DATA.thousands_sep,
- __UCLIBC_CURLOCALE_DATA.thousands_sep_len);
+ bufend -= __UCLIBC_CURLOCALE->thousands_sep_len;
+ memcpy(bufend, __UCLIBC_CURLOCALE->thousands_sep,
+ __UCLIBC_CURLOCALE->thousands_sep_len);
if (g[1] != 0) { /* g[1] == 0 means repeat last grouping. */
/* Note: g[1] == -1 means no further grouping. But since
* we'll never wrap around, we can set grouping to -1 without
@@ -132,22 +130,22 @@ char attribute_hidden *_uintmaxtostr(register char * __restrict bufend, uintmax_
#ifndef __LOCALE_C_ONLY
if (unlikely(outdigit)) {
- bufend -= __UCLIBC_CURLOCALE_DATA.outdigit_length[digit];
+ bufend -= __UCLIBC_CURLOCALE->outdigit_length[digit];
memcpy(bufend,
- (&__UCLIBC_CURLOCALE_DATA.outdigit0_mb)[digit],
- __UCLIBC_CURLOCALE_DATA.outdigit_length[digit]);
+ (&__UCLIBC_CURLOCALE->outdigit0_mb)[digit],
+ __UCLIBC_CURLOCALE->outdigit_length[digit]);
} else
#endif
{
*--bufend = ( (digit < 10) ? digit + '0' : digit + alphacase );
}
- } while (low | high);
+ } while (low | high);
#endif /******************************************************/
- if (negative) {
+ if (negative) {
*--bufend = '-';
- }
+ }
- return bufend;
+ return bufend;
}
diff --git a/libc/stdio/_vfprintf.c b/libc/stdio/_vfprintf.c
index 61a730d75..a795f4979 100644
--- a/libc/stdio/_vfprintf.c
+++ b/libc/stdio/_vfprintf.c
@@ -12,8 +12,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/>.
*/
/* This code needs a lot of clean up. Some of that is on hold until uClibc
@@ -88,7 +88,6 @@
* treats this as an error.
*/
-#define _ISOC99_SOURCE /* for ULLONG primarily... */
#include <features.h>
#include "_stdio.h"
#include <stdlib.h>
@@ -101,37 +100,19 @@
#include <stdint.h>
#include <errno.h>
#include <locale.h>
-#include <printf.h>
#ifdef __UCLIBC_HAS_THREADS__
-#include <stdio_ext.h>
-#include <pthread.h>
-#endif /* __UCLIBC_HAS_THREADS__ */
+# include <stdio_ext.h>
+# include <pthread.h>
+#endif
#ifdef __UCLIBC_HAS_WCHAR__
-#include <wchar.h>
-#endif /* __UCLIBC_HAS_WCHAR__ */
+# include <wchar.h>
+#endif
#include <bits/uClibc_uintmaxtostr.h>
#include <bits/uClibc_va_copy.h>
-/* Experimentally off - libc_hidden_proto(memcpy) */
-/* Experimentally off - libc_hidden_proto(memset) */
-/* Experimentally off - libc_hidden_proto(strlen) */
-/* Experimentally off - libc_hidden_proto(strnlen) */
-libc_hidden_proto(__glibc_strerror_r)
-libc_hidden_proto(fputs_unlocked)
-libc_hidden_proto(abort)
-#ifdef __UCLIBC_HAS_WCHAR__
-libc_hidden_proto(wcslen)
-libc_hidden_proto(wcsnlen)
-libc_hidden_proto(mbsrtowcs)
-libc_hidden_proto(wcsrtombs)
-libc_hidden_proto(btowc)
-libc_hidden_proto(wcrtomb)
-libc_hidden_proto(fputws)
-#endif
-
/* Some older or broken gcc toolchains define LONG_LONG_MAX but not
* LLONG_MAX. Since LLONG_MAX is part of the standard, that's what
* we use. So complain if we do not have it but should.
@@ -140,82 +121,46 @@ libc_hidden_proto(fputws)
#error Apparently, LONG_LONG_MAX is defined but LLONG_MAX is not. You need to fix your toolchain headers to support the standard macros for (unsigned) long long.
#endif
-/**********************************************************************/
-/* These provide some control over printf's feature set */
-
-/* This is undefined below depeding on uClibc's configuration. */
-#define __STDIO_PRINTF_FLOAT 1
-
-/* Now controlled by uClibc_stdio.h. */
-/* #define __UCLIBC_HAS_PRINTF_M_SPEC__ */
-
-
-/**********************************************************************/
-
-#if defined(__UCLIBC__) && !defined(__UCLIBC_HAS_FLOATS__)
-#undef __STDIO_PRINTF_FLOAT
-#endif
-
-#ifdef __BCC__
-#undef __STDIO_PRINTF_FLOAT
-#endif
-
-#ifdef __STDIO_PRINTF_FLOAT
-#include <float.h>
-#include <bits/uClibc_fpmax.h>
-#else /* __STDIO_PRINTF_FLOAT */
-#undef L__fpmaxtostr
-#endif /* __STDIO_PRINTF_FLOAT */
-
+#include "_fpmaxtostr.h"
#undef __STDIO_HAS_VSNPRINTF
#if defined(__STDIO_BUFFERS) || defined(__USE_OLD_VFPRINTF__) || defined(__UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__)
-#define __STDIO_HAS_VSNPRINTF 1
+# define __STDIO_HAS_VSNPRINTF 1
#endif
/**********************************************************************/
-/* Now controlled by uClibc_stdio.h. */
-/* #define __UCLIBC_HAS_GLIBC_CUSTOM_PRINTF__ */
-
-/* TODO -- move these to a configuration section? */
-#define MAX_FIELD_WIDTH 4095
-
#ifdef __UCLIBC_MJN3_ONLY__
-#ifdef L_register_printf_function
+# ifdef L_register_printf_function
/* emit only once */
-#warning WISHLIST: Make MAX_USER_SPEC configurable?
-#warning WISHLIST: Make MAX_ARGS_PER_SPEC configurable?
+# warning WISHLIST: Make MAX_USER_SPEC configurable?
+# warning WISHLIST: Make MAX_ARGS_PER_SPEC configurable?
+# endif
#endif
-#endif /* __UCLIBC_MJN3_ONLY__ */
#ifdef __UCLIBC_HAS_GLIBC_CUSTOM_PRINTF__
-
-#define MAX_USER_SPEC 10
-#define MAX_ARGS_PER_SPEC 5
-
-#else /* __UCLIBC_HAS_GLIBC_CUSTOM_PRINTF__ */
-
-#undef MAX_USER_SPEC
-#define MAX_ARGS_PER_SPEC 1
-
-#endif /* __UCLIBC_HAS_GLIBC_CUSTOM_PRINTF__ */
+# define MAX_USER_SPEC 10
+# define MAX_ARGS_PER_SPEC 5
+#else
+# undef MAX_USER_SPEC
+# define MAX_ARGS_PER_SPEC 1
+#endif
#if MAX_ARGS_PER_SPEC < 1
-#error MAX_ARGS_PER_SPEC < 1!
-#undef MAX_ARGS_PER_SPEC
-#define MAX_ARGS_PER_SPEC 1
+# error MAX_ARGS_PER_SPEC < 1!
+# undef MAX_ARGS_PER_SPEC
+# define MAX_ARGS_PER_SPEC 1
#endif
#if defined(NL_ARGMAX) && (NL_ARGMAX < 9)
-#error NL_ARGMAX < 9!
+# error NL_ARGMAX < 9!
#endif
#if defined(NL_ARGMAX) && (NL_ARGMAX >= (MAX_ARGS_PER_SPEC + 2))
-#define MAX_ARGS NL_ARGMAX
+# define MAX_ARGS NL_ARGMAX
#else
/* N for spec itself, plus 1 each for width and precision */
-#define MAX_ARGS (MAX_ARGS_PER_SPEC + 2)
+# define MAX_ARGS (MAX_ARGS_PER_SPEC + 2)
#endif
/**********************************************************************/
@@ -227,20 +172,20 @@ libc_hidden_proto(fputws)
extern printf_function _custom_printf_handler[MAX_USER_SPEC] attribute_hidden;
extern printf_arginfo_function *_custom_printf_arginfo[MAX_USER_SPEC] attribute_hidden;
extern char *_custom_printf_spec attribute_hidden;
-#endif /* __UCLIBC_HAS_GLIBC_CUSTOM_PRINTF__ */
+#endif
/**********************************************************************/
#define SPEC_FLAGS " +0-#'I"
enum {
- FLAG_SPACE = 0x01,
- FLAG_PLUS = 0x02, /* must be 2 * FLAG_SPACE */
- FLAG_ZERO = 0x04,
- FLAG_MINUS = 0x08, /* must be 2 * FLAG_ZERO */
- FLAG_HASH = 0x10,
- FLAG_THOUSANDS = 0x20,
- FLAG_I18N = 0x40, /* only works for d, i, u */
- FLAG_WIDESTREAM = 0x80
+ FLAG_SPACE = 0x01,
+ FLAG_PLUS = 0x02, /* must be 2 * FLAG_SPACE */
+ FLAG_ZERO = 0x04,
+ FLAG_MINUS = 0x08, /* must be 2 * FLAG_ZERO */
+ FLAG_HASH = 0x10,
+ FLAG_THOUSANDS = 0x20,
+ FLAG_I18N = 0x40, /* only works for d, i, u */
+ FLAG_WIDESTREAM = 0x80
};
/**********************************************************************/
@@ -260,10 +205,10 @@ enum {
};
/* p x X o u d i */
-#define SPEC_BASE { 16, 16, 16, 8, 10, 10, 10 }
+#define SPEC_BASE { 16, 16, 16, 8, 10, 10, 10 }
-#define SPEC_RANGES { CONV_n, CONV_p, CONV_i, CONV_A, \
- CONV_C, CONV_S, CONV_c, CONV_s, CONV_custom0 }
+#define SPEC_RANGES { CONV_n, CONV_p, CONV_i, CONV_A, \
+ CONV_C, CONV_S, CONV_c, CONV_s, CONV_custom0 }
#define SPEC_OR_MASK { \
/* n */ (PA_FLAG_PTR|PA_INT), \
@@ -304,43 +249,43 @@ enum {
/* #endif */
#ifdef PDS
-#error PDS already defined!
+# error PDS already defined!
#endif
#ifdef SS
-#error SS already defined!
+# error SS already defined!
#endif
#ifdef IMS
-#error IMS already defined!
+# error IMS already defined!
#endif
#if PTRDIFF_MAX == INT_MAX
-#define PDS 0
+# define PDS 0
#elif PTRDIFF_MAX == LONG_MAX
-#define PDS 4
+# define PDS 4
#elif defined(LLONG_MAX) && (PTRDIFF_MAX == LLONG_MAX)
-#define PDS 8
+# define PDS 8
#else
-#error fix QUAL_CHARS ptrdiff_t entry 't'!
+# error fix QUAL_CHARS ptrdiff_t entry 't'!
#endif
#if SIZE_MAX == UINT_MAX
-#define SS 0
+# define SS 0
#elif SIZE_MAX == ULONG_MAX
-#define SS 4
+# define SS 4
#elif defined(LLONG_MAX) && (SIZE_MAX == ULLONG_MAX)
-#define SS 8
+# define SS 8
#else
-#error fix QUAL_CHARS size_t entries 'z', 'Z'!
+# error fix QUAL_CHARS size_t entries 'z', 'Z'!
#endif
#if INTMAX_MAX == INT_MAX
-#define IMS 0
+# define IMS 0
#elif INTMAX_MAX == LONG_MAX
-#define IMS 4
+# define IMS 4
#elif defined(LLONG_MAX) && (INTMAX_MAX == LLONG_MAX)
-#define IMS 8
+# define IMS 8
#else
-#error fix QUAL_CHARS intmax_t entry 'j'!
+# error fix QUAL_CHARS intmax_t entry 'j'!
#endif
#define QUAL_CHARS { \
@@ -348,51 +293,52 @@ enum {
/* q:long_long Z:(s)size_t */ \
'h', 'l', 'L', 'j', 'z', 't', 'q', 'Z', 0, \
2, 4, 8, IMS, SS, PDS, 8, SS, 0, /* TODO -- fix!!! */\
- 1, 8 \
+ 1, 8 \
}
/**********************************************************************/
#ifdef __STDIO_VA_ARG_PTR
-#ifdef __BCC__
-#define __va_arg_ptr(ap,type) (((type *)(ap += sizeof(type))) - 1)
-#endif
+# ifdef __BCC__
+# define __va_arg_ptr(ap,type) (((type *)(ap += sizeof(type))) - 1)
+# endif
-#if 1
-#ifdef __GNUC__
+# if 1
+# ifdef __GNUC__
/* TODO -- need other than for 386 as well! */
-#ifndef __va_rounded_size
-#define __va_rounded_size(TYPE) \
- (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
-#endif
-#define __va_arg_ptr(AP, TYPE) \
- (AP = (va_list) ((char *) (AP) + __va_rounded_size (TYPE)), \
- ((void *) ((char *) (AP) - __va_rounded_size (TYPE))))
-#endif
-#endif
+# ifndef __va_rounded_size
+# define __va_rounded_size(TYPE) \
+ (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
+# endif
+# define __va_arg_ptr(AP, TYPE) \
+ (AP = (va_list) ((char *) (AP) + __va_rounded_size (TYPE)), \
+ ((void *) ((char *) (AP) - __va_rounded_size (TYPE))) \
+ )
+# endif
+# endif
#endif /* __STDIO_VA_ARG_PTR */
#ifdef __va_arg_ptr
-#define GET_VA_ARG(AP,F,TYPE,ARGS) (*(AP) = __va_arg_ptr(ARGS,TYPE))
-#define GET_ARG_VALUE(AP,F,TYPE) (*((TYPE *)(*(AP))))
+# define GET_VA_ARG(AP,F,TYPE,ARGS) (*(AP) = __va_arg_ptr(ARGS,TYPE))
+# define GET_ARG_VALUE(AP,F,TYPE) (*((TYPE *)(*(AP))))
#else
typedef union {
wchar_t wc;
unsigned int u;
unsigned long ul;
-#ifdef ULLONG_MAX
+# ifdef ULLONG_MAX
unsigned long long ull;
-#endif
-#ifdef __STDIO_PRINTF_FLOAT
+# endif
+# ifdef __UCLIBC_HAS_FLOATS__
double d;
long double ld;
-#endif /* __STDIO_PRINTF_FLOAT */
+# endif
void *p;
} argvalue_t;
-#define GET_VA_ARG(AU,F,TYPE,ARGS) (AU->F = va_arg(ARGS,TYPE))
-#define GET_ARG_VALUE(AU,F,TYPE) ((TYPE)((AU)->F))
+# define GET_VA_ARG(AU,F,TYPE,ARGS) (AU->F = va_arg(ARGS,TYPE))
+# define GET_ARG_VALUE(AU,F,TYPE) ((TYPE)((AU)->F))
#endif
typedef struct {
@@ -400,7 +346,7 @@ typedef struct {
struct printf_info info;
#ifdef NL_ARGMAX
int maxposarg; /* > 0 if args are positional, 0 if not, -1 if unknown */
-#endif /* NL_ARGMAX */
+#endif
int num_data_args; /* TODO: use sentinal??? */
unsigned int conv_num;
unsigned char argnumber[4]; /* width | prec | 1st data | unused */
@@ -421,25 +367,16 @@ typedef struct {
/* TODO: fix printf to return 0 and set errno if format error. Standard says
only returns -1 if sets error indicator for the stream. */
-#ifdef __STDIO_PRINTF_FLOAT
-typedef size_t (__fp_outfunc_t)(FILE *fp, intptr_t type, intptr_t len,
- intptr_t buf);
-
-extern ssize_t _fpmaxtostr(FILE * fp, __fpmax_t x, struct printf_info *info,
- __fp_outfunc_t fp_outfunc) attribute_hidden;
-#endif
-
extern int _ppfs_init(ppfs_t *ppfs, const char *fmt0) attribute_hidden; /* validates */
extern void _ppfs_prepargs(ppfs_t *ppfs, va_list arg) attribute_hidden; /* sets posargptrs */
extern void _ppfs_setargs(ppfs_t *ppfs) attribute_hidden; /* sets argptrs for current spec */
extern int _ppfs_parsespec(ppfs_t *ppfs) attribute_hidden; /* parses specifier */
-extern void _store_inttype(void *dest, int desttype, uintmax_t val) attribute_hidden;
-extern uintmax_t _load_inttype(int desttype, const void *src, int uflag) attribute_hidden;
-
/**********************************************************************/
#ifdef L_parse_printf_format
+#ifdef __UCLIBC_HAS_GLIBC_CUSTOM_PRINTF__
+
/* NOTE: This function differs from the glibc version in that parsing stops
* upon encountering an invalid conversion specifier. Since this is the way
* my printf functions work, I think it makes sense to do it that way here.
@@ -456,7 +393,8 @@ size_t parse_printf_format(register const char *template,
if (_ppfs_init(&ppfs, template) >= 0) {
#ifdef NL_ARGMAX
- if (ppfs.maxposarg > 0) { /* Using positional args. */
+ if (ppfs.maxposarg > 0) {
+ /* Using positional args. */
count = ppfs.maxposarg;
if (n > count) {
n = count;
@@ -464,8 +402,10 @@ size_t parse_printf_format(register const char *template,
for (i = 0 ; i < n ; i++) {
*argtypes++ = ppfs.argtype[i];
}
- } else { /* Not using positional args. */
-#endif /* NL_ARGMAX */
+ } else
+#endif
+ {
+ /* Not using positional args. */
while (*template) {
if ((*template == '%') && (*++template != '%')) {
ppfs.fmtpos = template;
@@ -498,15 +438,15 @@ size_t parse_printf_format(register const char *template,
++template;
}
}
-#ifdef NL_ARGMAX
}
-#endif /* NL_ARGMAX */
}
return count;
}
#endif
+
+#endif
/**********************************************************************/
#ifdef L__ppfs_init
@@ -518,14 +458,14 @@ int attribute_hidden _ppfs_init(register ppfs_t *ppfs, const char *fmt0)
memset(ppfs, 0, sizeof(ppfs_t)); /* TODO: nonportable???? */
#ifdef NL_ARGMAX
--ppfs->maxposarg; /* set to -1 */
-#endif /* NL_ARGMAX */
+#endif
ppfs->fmtpos = fmt0;
#ifdef __UCLIBC_MJN3_ONLY__
-#warning TODO: Make checking of the format string in C locale an option.
+# warning TODO: Make checking of the format string in C locale an option.
#endif
#ifdef __UCLIBC_HAS_LOCALE__
/* To support old programs, don't check mb validity if in C locale. */
- if (((__UCLIBC_CURLOCALE_DATA).encoding) != __ctype_encoding_7_bit) {
+ if (__UCLIBC_CURLOCALE->encoding != __ctype_encoding_7_bit) {
/* ANSI/ISO C99 requires format string to be a valid multibyte string
* beginning and ending in its initial shift state. */
static const char invalid_mbs[] = "Invalid multibyte format string.";
@@ -570,7 +510,8 @@ int attribute_hidden _ppfs_init(register ppfs_t *ppfs, const char *fmt0)
while (*fmt) {
if ((*fmt == '%') && (*++fmt != '%')) {
ppfs->fmtpos = fmt; /* back up to the '%' */
- if ((r = _ppfs_parsespec(ppfs)) < 0) {
+ r = _ppfs_parsespec(ppfs);
+ if (r < 0) {
return -1;
}
fmt = ppfs->fmtpos; /* update to one past end of spec */
@@ -581,7 +522,7 @@ int attribute_hidden _ppfs_init(register ppfs_t *ppfs, const char *fmt0)
ppfs->fmtpos = fmt0; /* rewind */
}
-#ifdef NL_MAX_ARG
+#ifdef NL_ARGMAX
/* If we have positional args, make sure we know all the types. */
{
register int *p = ppfs->argtype;
@@ -593,7 +534,7 @@ int attribute_hidden _ppfs_init(register ppfs_t *ppfs, const char *fmt0)
++p;
}
}
-#endif /* NL_MAX_ARG */
+#endif /* NL_ARGMAX */
return 0;
}
@@ -607,13 +548,14 @@ void attribute_hidden _ppfs_prepargs(register ppfs_t *ppfs, va_list arg)
va_copy(ppfs->arg, arg);
#ifdef NL_ARGMAX
- if ((i = ppfs->maxposarg) > 0) { /* init for positional args */
+ i = ppfs->maxposarg; /* init for positional args */
+ if (i > 0) {
ppfs->num_data_args = i;
ppfs->info.width = ppfs->info.prec = ppfs->maxposarg = 0;
_ppfs_setargs(ppfs);
ppfs->maxposarg = i;
}
-#endif /* NL_ARGMAX */
+#endif
}
#endif
/**********************************************************************/
@@ -630,7 +572,7 @@ void attribute_hidden _ppfs_setargs(register ppfs_t *ppfs)
#ifdef NL_ARGMAX
if (ppfs->maxposarg == 0) { /* initing for or no pos args */
-#endif /* NL_ARGMAX */
+#endif
if (ppfs->info.width == INT_MIN) {
ppfs->info.width =
#ifdef __va_arg_ptr
@@ -669,7 +611,7 @@ void attribute_hidden _ppfs_setargs(register ppfs_t *ppfs)
/* we're assuming wchar_t is at least an int */
GET_VA_ARG(p,wc,wchar_t,ppfs->arg);
break;
-#ifdef __STDIO_PRINTF_FLOAT
+#ifdef __UCLIBC_HAS_FLOATS__
/* PA_FLOAT */
case PA_DOUBLE:
GET_VA_ARG(p,d,double,ppfs->arg);
@@ -677,12 +619,12 @@ void attribute_hidden _ppfs_setargs(register ppfs_t *ppfs)
case (PA_DOUBLE|PA_FLAG_LONG_DOUBLE):
GET_VA_ARG(p,ld,long double,ppfs->arg);
break;
-#else /* __STDIO_PRINTF_FLOAT */
+#else /* __UCLIBC_HAS_FLOATS__ */
case PA_DOUBLE:
case (PA_DOUBLE|PA_FLAG_LONG_DOUBLE):
assert(0);
continue;
-#endif /* __STDIO_PRINTF_FLOAT */
+#endif /* __UCLIBC_HAS_FLOATS__ */
default:
/* TODO -- really need to ensure this can't happen */
assert(ppfs->argtype[i-1] & PA_FLAG_PTR);
@@ -728,12 +670,6 @@ void attribute_hidden _ppfs_setargs(register ppfs_t *ppfs)
/**********************************************************************/
#ifdef L__ppfs_parsespec
-#ifdef __UCLIBC_HAS_XLOCALE__
-libc_hidden_proto(__ctype_b_loc)
-#elif defined __UCLIBC_HAS_CTYPE_TABLES__
-libc_hidden_proto(__ctype_b)
-#endif
-
/* Notes: argtype differs from glibc for the following:
* mine glibc
* lc PA_WCHAR PA_CHAR the standard says %lc means %C
@@ -765,11 +701,11 @@ static const short int type_codes[] = {
PA_INT|PA_FLAG_LONG,
PA_INT|PA_FLAG_LONG_LONG,
PA_WCHAR,
-#ifdef __STDIO_PRINTF_FLOAT
+#ifdef __UCLIBC_HAS_FLOATS__
/* PA_FLOAT, */
PA_DOUBLE,
PA_DOUBLE|PA_FLAG_LONG_DOUBLE,
-#endif /* __STDIO_PRINTF_FLOAT */
+#endif
};
static const unsigned char type_sizes[] = {
@@ -788,11 +724,11 @@ static const unsigned char type_sizes[] = {
PROMOTED_SIZE_OF(long), /* TODO -- is this correct? (above too) */
#endif
PROMOTED_SIZE_OF(wchar_t),
-#ifdef __STDIO_PRINTF_FLOAT
+#ifdef __UCLIBC_HAS_FLOATS__
/* PROMOTED_SIZE_OF(float), */
PROMOTED_SIZE_OF(double),
PROMOTED_SIZE_OF(long double),
-#endif /* __STDIO_PRINTF_FLOAT */
+#endif
};
static int _promoted_size(int argtype)
@@ -851,7 +787,7 @@ int attribute_hidden _ppfs_parsespec(ppfs_t *ppfs)
int dpoint;
#ifdef NL_ARGMAX
int maxposarg;
-#endif /* NL_ARGMAX */
+#endif
int p_m_spec_chars;
int n;
int argtype[MAX_ARGS_PER_SPEC+2];
@@ -864,7 +800,7 @@ int attribute_hidden _ppfs_parsespec(ppfs_t *ppfs)
static const char qual_chars[] = QUAL_CHARS;
#ifdef __UCLIBC_HAS_WCHAR__
char buf[32];
-#endif /* __UCLIBC_HAS_WCHAR__ */
+#endif
/* WIDE note: we can test against '%' here since we don't allow */
/* WIDE note: other mappings of '%' in the wide char set. */
@@ -875,7 +811,7 @@ int attribute_hidden _ppfs_parsespec(ppfs_t *ppfs)
argtype[1] = __PA_NOARG;
#ifdef NL_ARGMAX
maxposarg = ppfs->maxposarg;
-#endif /* NL_ARGMAX */
+#endif
#ifdef __UCLIBC_HAS_WCHAR__
/* This is somewhat lame, but saves a lot of code. If we're dealing with
@@ -885,15 +821,15 @@ int attribute_hidden _ppfs_parsespec(ppfs_t *ppfs)
* While there a legal specifiers that won't, the all involve duplicate
* flags or outrageous field widths/precisions. */
width = dpoint = 0;
- if ((flags = ppfs->info._flags & FLAG_WIDESTREAM) == 0) {
+ flags = ppfs->info._flags & FLAG_WIDESTREAM;
+ if (flags == 0) {
fmt = ppfs->fmtpos;
} else {
fmt = buf + 1;
i = 0;
do {
- if ((buf[i] = (char) (((wchar_t *) ppfs->fmtpos)[i-1]))
- != (((wchar_t *) ppfs->fmtpos)[i-1])
- ) {
+ buf[i] = (char) (((wchar_t *) ppfs->fmtpos)[i-1]);
+ if (buf[i] != (((wchar_t *) ppfs->fmtpos)[i-1])) {
return -1;
}
} while (buf[i++] && (i < sizeof(buf)));
@@ -902,7 +838,7 @@ int attribute_hidden _ppfs_parsespec(ppfs_t *ppfs)
#else /* __UCLIBC_HAS_WCHAR__ */
width = flags = dpoint = 0;
fmt = ppfs->fmtpos;
-#endif /* __UCLIBC_HAS_WCHAR__ */
+#endif
assert(fmt[-1] == '%');
assert(fmt[0] != '%');
@@ -916,8 +852,11 @@ int attribute_hidden _ppfs_parsespec(ppfs_t *ppfs)
}
i = 0;
while (isdigit(*fmt)) {
- if (i < MAX_FIELD_WIDTH) { /* Avoid overflow. */
+ if (i < INT_MAX / 10
+ || (i == INT_MAX / 10 && (*fmt - '0') <= INT_MAX % 10)) {
i = (i * 10) + (*fmt - '0');
+ } else {
+ i = INT_MAX; /* best we can do... */
}
++fmt;
}
@@ -931,22 +870,23 @@ int attribute_hidden _ppfs_parsespec(ppfs_t *ppfs)
if (maxposarg == 0) {
return -1;
}
- if ((argnumber[2] = i) > maxposarg) {
+ argnumber[2] = i;
+ if (argnumber[2] > maxposarg) {
maxposarg = i;
}
/* Now fall through to check flags. */
} else {
if (maxposarg > 0) {
-#ifdef __UCLIBC_HAS_PRINTF_M_SPEC__
-#ifdef __UCLIBC_MJN3_ONLY__
-#warning TODO: Support prec and width for %m when positional args used
+# ifdef __UCLIBC_HAS_PRINTF_M_SPEC__
+# ifdef __UCLIBC_MJN3_ONLY__
+# warning TODO: Support prec and width for %m when positional args used
/* Actually, positional arg processing will fail in general
* for specifiers that don't require an arg. */
-#endif /* __UCLIBC_MJN3_ONLY__ */
+# endif
if (*fmt == 'm') {
goto PREC_WIDTH;
}
-#endif /* __UCLIBC_HAS_PRINTF_M_SPEC__ */
+# endif /* __UCLIBC_HAS_PRINTF_M_SPEC__ */
return -1;
}
maxposarg = 0; /* Possible redundant store, but cuts size. */
@@ -1005,7 +945,7 @@ int attribute_hidden _ppfs_parsespec(ppfs_t *ppfs)
}
argnumber[-dpoint] = i;
} else
-#endif /* NL_ARGMAX */
+#endif
if (++p != fmt) {
/* Not using pos args but digits followed *. */
return -1;
@@ -1077,33 +1017,30 @@ int attribute_hidden _ppfs_parsespec(ppfs_t *ppfs)
if (*fmt == 'm') {
ppfs->conv_num = CONV_m;
ppfs->num_data_args = 0;
- goto DONE;
- }
+ } else
#endif
-#ifdef __UCLIBC_HAS_GLIBC_CUSTOM_PRINTF__
-
- /* Handle custom arg -- WARNING -- overwrites p!!! */
- ppfs->conv_num = CONV_custom0;
- p = _custom_printf_spec;
- do {
- if (*p == *fmt) {
- if ((ppfs->num_data_args
- = ((*_custom_printf_arginfo[(int)(p-_custom_printf_spec)])
- (&(ppfs->info), MAX_ARGS_PER_SPEC, argtype+2)))
- > MAX_ARGS_PER_SPEC) {
- break; /* Error -- too many args! */
+ {
+#ifndef __UCLIBC_HAS_GLIBC_CUSTOM_PRINTF__
+ return -1; /* Error */
+#else
+ /* Handle custom arg -- WARNING -- overwrites p!!! */
+ ppfs->conv_num = CONV_custom0;
+ p = _custom_printf_spec;
+ while (1) {
+ if (*p == *fmt) {
+ printf_arginfo_function *fp = _custom_printf_arginfo[(int)(p - _custom_printf_spec)];
+ ppfs->num_data_args = fp(&(ppfs->info), MAX_ARGS_PER_SPEC, argtype + 2);
+ if (ppfs->num_data_args > MAX_ARGS_PER_SPEC) {
+ return -1; /* Error -- too many args! */
+ }
+ break;
}
- goto DONE;
+ if (++p >= (_custom_printf_spec + MAX_USER_SPEC))
+ return -1; /* Error */
}
- } while (++p < (_custom_printf_spec + MAX_USER_SPEC));
-#endif /* __UCLIBC_HAS_GLIBC_CUSTOM_PRINTF__ */
- /* Otherwise error. */
- return -1;
- }
-
-#if defined(__UCLIBC_HAS_GLIBC_CUSTOM_PRINTF__) || defined(__UCLIBC_HAS_PRINTF_M_SPEC__)
- DONE:
#endif
+ }
+ }
#ifdef NL_ARGMAX
if (maxposarg > 0) {
@@ -1114,7 +1051,8 @@ int attribute_hidden _ppfs_parsespec(ppfs_t *ppfs)
? (ppfs->argnumber[i] = argnumber[i])
: argnumber[2] + (i-2));
if (n > maxposarg) {
- if ((maxposarg = n) > NL_ARGMAX) {
+ maxposarg = n;
+ if (maxposarg > NL_ARGMAX) {
return -1;
}
}
@@ -1124,18 +1062,20 @@ int attribute_hidden _ppfs_parsespec(ppfs_t *ppfs)
ppfs->argtype[n] = argtype[i];
}
} while (++i < ppfs->num_data_args + 2);
- } else {
+ } else
#endif /* NL_ARGMAX */
+ {
ppfs->argnumber[2] = 1;
memcpy(ppfs->argtype, argtype + 2, ppfs->num_data_args * sizeof(int));
-#ifdef NL_ARGMAX
}
+#ifdef NL_ARGMAX
ppfs->maxposarg = maxposarg;
-#endif /* NL_ARGMAX */
+#endif
#ifdef __UCLIBC_HAS_WCHAR__
- if ((flags = ppfs->info._flags & FLAG_WIDESTREAM) == 0) {
+ flags = ppfs->info._flags & FLAG_WIDESTREAM;
+ if (flags == 0) {
ppfs->fmtpos = ++fmt;
} else {
ppfs->fmtpos = (const char *) (((const wchar_t *)(ppfs->fmtpos))
@@ -1143,7 +1083,7 @@ int attribute_hidden _ppfs_parsespec(ppfs_t *ppfs)
}
#else /* __UCLIBC_HAS_WCHAR__ */
ppfs->fmtpos = ++fmt;
-#endif /* __UCLIBC_HAS_WCHAR__ */
+#endif
return ppfs->num_data_args + 2;
}
@@ -1214,10 +1154,10 @@ static size_t _charpad(FILE * __restrict stream, int padchar, size_t numpad);
#define _PPFS_init _ppfs_init
#define OUTPUT(F,S) fputs_unlocked(S,F)
/* #define _outnstr(stream, string, len) __stdio_fwrite(string, len, stream) */
-#define _outnstr(stream, string, len) ((len > 0) ? __stdio_fwrite(string, len, stream) : 0)
+#define _outnstr(stream, string, len) ((len > 0) ? __stdio_fwrite((const unsigned char *)(string), len, stream) : 0)
#define FP_OUT _fp_out_narrow
-#ifdef __STDIO_PRINTF_FLOAT
+#ifdef __UCLIBC_HAS_FLOATS__
static size_t _fp_out_narrow(FILE *fp, intptr_t type, intptr_t len, intptr_t buf)
{
@@ -1225,17 +1165,19 @@ static size_t _fp_out_narrow(FILE *fp, intptr_t type, intptr_t len, intptr_t buf
if (type & 0x80) { /* Some type of padding needed. */
int buflen = strlen((const char *) buf);
- if ((len -= buflen) > 0) {
- if ((r = _charpad(fp, (type & 0x7f), len)) != len) {
+ len -= buflen;
+ if (len > 0) {
+ r = _charpad(fp, (type & 0x7f), len);
+ if (r != len) {
return r;
}
}
len = buflen;
}
- return r + OUTNSTR(fp, (const unsigned char *) buf, len);
+ return r + OUTNSTR(fp, (const char *) buf, len);
}
-#endif /* __STDIO_PRINTF_FLOAT */
+#endif /* __UCLIBC_HAS_FLOATS__ */
#else /* L__vfprintf_internal */
@@ -1245,9 +1187,9 @@ static size_t _fp_out_narrow(FILE *fp, intptr_t type, intptr_t len, intptr_t buf
#define STRLEN wcslen
#define _PPFS_init _ppwfs_init
/* Pulls in fseek: */
-#define OUTPUT(F,S) fputws(S,F)
+#define OUTPUT(F,S) fputws_unlocked(S,F)
/* TODO: #define OUTPUT(F,S) _wstdio_fwrite((S),wcslen(S),(F)) */
-#define _outnwcs(stream, wstring, len) _wstdio_fwrite(wstring, len, stream)
+#define _outnwcs(stream, wstring, len) _wstdio_fwrite((const wchar_t *)(wstring), len, stream)
#define FP_OUT _fp_out_wide
static size_t _outnstr(FILE *stream, const char *s, size_t wclen)
@@ -1277,16 +1219,7 @@ static size_t _outnstr(FILE *stream, const char *s, size_t wclen)
return wclen - todo;
}
-#ifdef __STDIO_PRINTF_FLOAT
-
-#ifdef __UCLIBC_MJN3_ONLY__
-#warning TODO: Move defines from _fpmaxtostr. Put them in a common header.
-#endif
-
-/* The following defines are from _fpmaxtostr.*/
-#define DIGITS_PER_BLOCK 9
-#define NUM_DIGIT_BLOCKS ((DECIMAL_DIG+DIGITS_PER_BLOCK-1)/DIGITS_PER_BLOCK)
-#define BUF_SIZE ( 3 + NUM_DIGIT_BLOCKS * DIGITS_PER_BLOCK )
+#ifdef __UCLIBC_HAS_FLOATS__
static size_t _fp_out_wide(FILE *fp, intptr_t type, intptr_t len, intptr_t buf)
{
@@ -1297,8 +1230,10 @@ static size_t _fp_out_wide(FILE *fp, intptr_t type, intptr_t len, intptr_t buf)
if (type & 0x80) { /* Some type of padding needed */
int buflen = strlen(s);
- if ((len -= buflen) > 0) {
- if ((r = _charpad(fp, (type & 0x7f), len)) != len) {
+ len -= buflen;
+ if (len > 0) {
+ r = _charpad(fp, (type & 0x7f), len);
+ if (r != len) {
return r;
}
}
@@ -1310,15 +1245,15 @@ static size_t _fp_out_wide(FILE *fp, intptr_t type, intptr_t len, intptr_t buf)
do {
#ifdef __LOCALE_C_ONLY
wbuf[i] = s[i];
-#else /* __LOCALE_C_ONLY */
+#else
-#ifdef __UCLIBC_HAS_GLIBC_DIGIT_GROUPING__
+# ifdef __UCLIBC_HAS_GLIBC_DIGIT_GROUPING__
if (s[i] == ',') {
- wbuf[i] = __UCLIBC_CURLOCALE_DATA.thousands_sep_wc;
+ wbuf[i] = __UCLIBC_CURLOCALE->thousands_sep_wc;
} else
-#endif /* __UCLIBC_HAS_GLIBC_DIGIT_GROUPING__ */
+# endif
if (s[i] == '.') {
- wbuf[i] = __UCLIBC_CURLOCALE_DATA.decimal_point_wc;
+ wbuf[i] = __UCLIBC_CURLOCALE->decimal_point_wc;
} else {
wbuf[i] = s[i];
}
@@ -1332,7 +1267,7 @@ static size_t _fp_out_wide(FILE *fp, intptr_t type, intptr_t len, intptr_t buf)
return r;
}
-#endif /* __STDIO_PRINTF_FLOAT */
+#endif /* __UCLIBC_HAS_FLOATS__ */
static int _ppwfs_init(register ppfs_t *ppfs, const wchar_t *fmt0)
{
@@ -1343,7 +1278,7 @@ static int _ppwfs_init(register ppfs_t *ppfs, const wchar_t *fmt0)
memset(ppfs, 0, sizeof(ppfs_t)); /* TODO: nonportable???? */
#ifdef NL_ARGMAX
--ppfs->maxposarg; /* set to -1 */
-#endif /* NL_ARGMAX */
+#endif
ppfs->fmtpos = (const char *) fmt0;
ppfs->info._flags = FLAG_WIDESTREAM;
@@ -1389,7 +1324,8 @@ static int _ppwfs_init(register ppfs_t *ppfs, const wchar_t *fmt0)
while (*fmt) {
if ((*fmt == '%') && (*++fmt != '%')) {
ppfs->fmtpos = (const char *) fmt; /* back up to the '%' */
- if ((r = _ppfs_parsespec(ppfs)) < 0) {
+ r = _ppfs_parsespec(ppfs);
+ if (r < 0) {
return -1;
}
fmt = (const wchar_t *) ppfs->fmtpos; /* update to one past end of spec */
@@ -1428,7 +1364,7 @@ static size_t _charpad(FILE * __restrict stream, int padchar, size_t numpad)
FMT_TYPE pad[1];
*pad = padchar;
- while (todo && (OUTNSTR(stream, (const unsigned char *) pad, 1) == 1)) {
+ while (todo && (OUTNSTR(stream, (const char *) pad, 1) == 1)) {
--todo;
}
@@ -1442,10 +1378,10 @@ static int _do_one_spec(FILE * __restrict stream,
static const char spec_base[] = SPEC_BASE;
#ifdef L__vfprintf_internal
static const char prefix[] = "+\0-\0 \0000x\0000X";
- /* 0 2 4 6 9 11*/
-#else /* L__vfprintf_internal */
+ /* 0 2 4 6 9 11*/
+#else
static const wchar_t prefix[] = L"+\0-\0 \0000x\0000X";
-#endif /* L__vfprintf_internal */
+#endif
enum {
PREFIX_PLUS = 0,
PREFIX_MINUS = 2,
@@ -1464,7 +1400,7 @@ static int _do_one_spec(FILE * __restrict stream,
#ifdef __UCLIBC_HAS_WCHAR__
const wchar_t *ws = NULL;
mbstate_t mbstate;
-#endif /* __UCLIBC_HAS_WCHAR__ */
+#endif
size_t slen;
#ifdef L__vfprintf_internal
#define SLEN slen
@@ -1480,7 +1416,7 @@ static int _do_one_spec(FILE * __restrict stream,
char padchar = ' ';
#ifdef __UCLIBC_MJN3_ONLY__
#warning TODO: Determine appropriate buf size.
-#endif /* __UCLIBC_MJN3_ONLY__ */
+#endif
/* TODO: buf needs to be big enough for any possible error return strings
* and also for any locale-grouped long long integer strings generated.
* This should be large enough for any of the current archs/locales, but
@@ -1500,21 +1436,21 @@ static int _do_one_spec(FILE * __restrict stream,
/* Deal with the argptr vs argvalue issue. */
#ifdef __va_arg_ptr
argptr = (const void * const *) ppfs->argptr;
-#ifdef NL_ARGMAX
+# ifdef NL_ARGMAX
if (ppfs->maxposarg > 0) { /* Using positional args... */
argptr += ppfs->argnumber[2] - 1;
}
-#endif /* NL_ARGMAX */
+# endif
#else
/* Need to build a local copy... */
{
register argvalue_t *p = ppfs->argvalue;
int i;
-#ifdef NL_ARGMAX
+# ifdef NL_ARGMAX
if (ppfs->maxposarg > 0) { /* Using positional args... */
p += ppfs->argnumber[2] - 1;
}
-#endif /* NL_ARGMAX */
+# endif
for (i = 0 ; i < ppfs->num_data_args ; i++ ) {
argptr[i] = (void *) p++;
}
@@ -1536,8 +1472,9 @@ static int _do_one_spec(FILE * __restrict stream,
#ifdef L__vfprintf_internal
#warning CONSIDER: Should we ignore these flags if stub locale? What about custom specs?
#endif
-#endif /* __UCLIBC_MJN3_ONLY__ */
- if ((base = spec_base[(int)(ppfs->conv_num - CONV_p)]) == 10) {
+#endif
+ base = spec_base[(int)(ppfs->conv_num - CONV_p)];
+ if (base == 10) {
if (PRINT_INFO_FLAG_VAL(&(ppfs->info),group)) {
alphacase = __UIM_GROUP;
}
@@ -1564,7 +1501,7 @@ static int _do_one_spec(FILE * __restrict stream,
#ifdef L__vfprintf_internal
#warning CONSIDER: If using outdigits and/or grouping, how should we interpret precision?
#endif
-#endif /* __UCLIBC_MJN3_ONLY__ */
+#endif
s = _uintmaxtostr(buf + sizeof(buf) - 1,
(uintmax_t)
_load_inttype(ppfs->conv_num == CONV_p ? PA_FLAG_LONG : *argtype & __PA_INTMASK,
@@ -1620,7 +1557,7 @@ static int _do_one_spec(FILE * __restrict stream,
}
numfill = ((numfill > SLEN) ? numfill - SLEN : 0);
} else if (ppfs->conv_num <= CONV_A) { /* floating point */
-#ifdef __STDIO_PRINTF_FLOAT
+#ifdef __UCLIBC_HAS_FLOATS__
ssize_t nf;
nf = _fpmaxtostr(stream,
(__fpmax_t)
@@ -1634,16 +1571,17 @@ static int _do_one_spec(FILE * __restrict stream,
*count += nf;
return 0;
-#else /* __STDIO_PRINTF_FLOAT */
+#else /* __UCLIBC_HAS_FLOATS__ */
return -1; /* TODO -- try to continue? */
-#endif /* __STDIO_PRINTF_FLOAT */
+#endif
} else if (ppfs->conv_num <= CONV_S) { /* wide char or string */
#ifdef L__vfprintf_internal
#ifdef __UCLIBC_HAS_WCHAR__
mbstate.__mask = 0; /* Initialize the mbstate. */
if (ppfs->conv_num == CONV_S) { /* wide string */
- if (!(ws = *((const wchar_t **) *argptr))) {
+ ws = *((const wchar_t **) *argptr);
+ if (!ws) {
goto NULL_STRING;
}
/* We use an awful uClibc-specific hack here, passing
@@ -1651,12 +1589,12 @@ static int _do_one_spec(FILE * __restrict stream,
* uClibc's wcsrtombs that we want a "restricted" length
* such that the mbs fits in a buffer of the specified
* size with no partial conversions. */
- if ((slen = wcsrtombs((char *) &ws, &ws, /* Use awful hack! */
- ((ppfs->info.prec >= 0)
- ? ppfs->info.prec
- : SIZE_MAX), &mbstate))
- == ((size_t)-1)
- ) {
+ slen = wcsrtombs((char *) &ws, &ws, /* Use awful hack! */
+ ((ppfs->info.prec >= 0)
+ ? ppfs->info.prec
+ : SIZE_MAX),
+ &mbstate);
+ if (slen == ((size_t)-1)) {
return -1; /* EILSEQ */
}
} else { /* wide char */
@@ -1669,7 +1607,7 @@ static int _do_one_spec(FILE * __restrict stream,
}
#else /* __UCLIBC_HAS_WCHAR__ */
return -1;
-#endif /* __UCLIBC_HAS_WCHAR__ */
+#endif
} else if (ppfs->conv_num <= CONV_s) { /* char or string */
if (ppfs->conv_num == CONV_s) { /* string */
s = *((char **) (*argptr));
@@ -1685,6 +1623,9 @@ static int _do_one_spec(FILE * __restrict stream,
#endif
s = "(null)";
slen = 6;
+ /* Use an empty string rather than truncation if precision is too small. */
+ if (ppfs->info.prec >= 0 && ppfs->info.prec < slen)
+ slen = 0;
}
} else { /* char */
s = buf;
@@ -1715,7 +1656,7 @@ static int _do_one_spec(FILE * __restrict stream,
if (ppfs->conv_num == CONV_s) { /* string */
#ifdef __UCLIBC_MJN3_ONLY__
#warning TODO: Fix %s for _vfwprintf_internal... output upto illegal sequence?
-#endif /* __UCLIBC_MJN3_ONLY__ */
+#endif
s = *((char **) (*argptr));
if (s) {
#ifdef __UCLIBC_HAS_PRINTF_M_SPEC__
@@ -1741,6 +1682,9 @@ static int _do_one_spec(FILE * __restrict stream,
NULL_STRING:
s = "(null)";
SLEN = slen = 6;
+ /* Use an empty string rather than truncation if precision is too small. */
+ if (ppfs->info.prec >= 0 && ppfs->info.prec < slen)
+ SLEN = slen = 0;
}
} else { /* char */
*wbuf = btowc( (unsigned char)(*((const int *) *argptr)) );
@@ -1782,7 +1726,7 @@ static int _do_one_spec(FILE * __restrict stream,
#ifdef L__vfprintf_internal
#warning CONSIDER: If using outdigits and/or grouping, how should we pad?
#endif
-#endif /* __UCLIBC_MJN3_ONLY__ */
+#endif
{
size_t t;
@@ -1813,7 +1757,7 @@ static int _do_one_spec(FILE * __restrict stream,
#ifdef L__vfprintf_internal
-#ifdef __UCLIBC_HAS_WCHAR__
+# ifdef __UCLIBC_HAS_WCHAR__
if (!ws) {
assert(s);
if (_outnstr(stream, s, slen) != slen) {
@@ -1825,18 +1769,18 @@ static int _do_one_spec(FILE * __restrict stream,
while (slen) {
t = (slen <= sizeof(buf)) ? slen : sizeof(buf);
t = wcsrtombs(buf, &ws, t, &mbstate);
- assert (t != ((size_t)(-1)));
+ assert(t != ((size_t)(-1)));
if (_outnstr(stream, buf, t) != t) {
return -1;
}
slen -= t;
}
}
-#else /* __UCLIBC_HAS_WCHAR__ */
+# else /* __UCLIBC_HAS_WCHAR__ */
if (_outnstr(stream, (const unsigned char *) s, slen) != slen) {
return -1;
}
-#endif /* __UCLIBC_HAS_WCHAR__ */
+# endif
#else /* L__vfprintf_internal */
@@ -1860,7 +1804,6 @@ static int _do_one_spec(FILE * __restrict stream,
return 0;
}
-libc_hidden_proto(fprintf)
int VFPRINTF_internal (FILE * __restrict stream,
const FMT_TYPE * __restrict format,
@@ -1874,7 +1817,7 @@ int VFPRINTF_internal (FILE * __restrict stream,
s = format;
if (_PPFS_init(&ppfs, format) < 0) { /* Bad format string. */
- OUTNSTR(stream, (const unsigned char *) ppfs.fmtpos,
+ OUTNSTR(stream, (const char *) ppfs.fmtpos,
STRLEN((const FMT_TYPE *)(ppfs.fmtpos)));
#if defined(L__vfprintf_internal) && !defined(NDEBUG)
fprintf(stderr,"\nIMbS: \"%s\"\n\n", format);
@@ -1888,8 +1831,9 @@ int VFPRINTF_internal (FILE * __restrict stream,
++format;
}
- if (format-s) { /* output any literal text in format string */
- if ( (r = OUTNSTR(stream, (const unsigned char *) s, format-s)) != (format-s)) {
+ if (format - s) { /* output any literal text in format string */
+ r = OUTNSTR(stream, (const char *) s, format - s);
+ if (r != (format - s)) {
count = -1;
break;
}
@@ -1904,7 +1848,8 @@ int VFPRINTF_internal (FILE * __restrict stream,
/* TODO: _do_one_spec needs to know what the output funcs are!!! */
ppfs.fmtpos = (const char *)(++format);
/* TODO: check -- should only fail on stream error */
- if ( (r = _do_one_spec(stream, &ppfs, &count)) < 0) {
+ r = _do_one_spec(stream, &ppfs, &count);
+ if (r < 0) {
count = -1;
break;
}
@@ -1940,13 +1885,13 @@ int VFPRINTF_internal (FILE * __restrict stream,
* is using __stdio_fwrite (TODO: do the same for wide functions).
*/
#ifdef L_vfprintf
-#define VFPRINTF vfprintf
-#define VFPRINTF_internal _vfprintf_internal
-#define FMT_TYPE char
+# define VFPRINTF vfprintf
+# define VFPRINTF_internal _vfprintf_internal
+# define FMT_TYPE char
#else
-#define VFPRINTF vfwprintf
-#define VFPRINTF_internal _vfwprintf_internal
-#define FMT_TYPE wchar_t
+# define VFPRINTF vfwprintf
+# define VFPRINTF_internal _vfwprintf_internal
+# define FMT_TYPE wchar_t
#endif
libc_hidden_proto(VFPRINTF)
diff --git a/libc/stdio/_wfwrite.c b/libc/stdio/_wfwrite.c
index fb5c6b3ee..517e3a7a3 100644
--- a/libc/stdio/_wfwrite.c
+++ b/libc/stdio/_wfwrite.c
@@ -16,8 +16,6 @@
#warning TODO: Fix prototype.
#endif
-libc_hidden_proto(wmemcpy)
-libc_hidden_proto(wcsnrtombs)
size_t attribute_hidden _wstdio_fwrite(const wchar_t *__restrict ws, size_t n,
register FILE *__restrict stream)
@@ -38,7 +36,7 @@ size_t attribute_hidden _wstdio_fwrite(const wchar_t *__restrict ws, size_t n,
}
if (count) {
wmemcpy((wchar_t *)(stream->__bufpos), ws, count);
- stream->__bufpos = (char *)(((wchar_t *)(stream->__bufpos)) + count);
+ stream->__bufpos = (unsigned char *)(((wchar_t *)(stream->__bufpos)) + count);
}
__STDIO_STREAM_VALIDATE(stream);
return n;
@@ -59,7 +57,7 @@ size_t attribute_hidden _wstdio_fwrite(const wchar_t *__restrict ws, size_t n,
++r; /* 0 is returned when nul is reached. */
pw = ws + count + r; /* pw was set to NULL, so correct. */
}
- if (__stdio_fwrite(buf, r, stream) == r) {
+ if (__stdio_fwrite((const unsigned char *)buf, r, stream) == r) {
count = pw - ws;
continue;
}
diff --git a/libc/stdio/asprintf.c b/libc/stdio/asprintf.c
index 3f1992559..6334cc72a 100644
--- a/libc/stdio/asprintf.c
+++ b/libc/stdio/asprintf.c
@@ -11,9 +11,7 @@
#include "_stdio.h"
#include <stdarg.h>
-libc_hidden_proto(asprintf)
-libc_hidden_proto(vasprintf)
#ifndef __STDIO_HAS_VSNPRINTF
#warning Skipping asprintf and __asprintf since no vsnprintf!
diff --git a/libc/stdio/ctermid.c b/libc/stdio/ctermid.c
index 26369d6f5..854c526ea 100644
--- a/libc/stdio/ctermid.c
+++ b/libc/stdio/ctermid.c
@@ -7,7 +7,6 @@
#include "_stdio.h"
-/* Experimentally off - libc_hidden_proto(strcpy) */
char *ctermid(register char *s)
{
diff --git a/libc/stdio/dprintf.c b/libc/stdio/dprintf.c
index a8b2704b2..3fab12739 100644
--- a/libc/stdio/dprintf.c
+++ b/libc/stdio/dprintf.c
@@ -11,7 +11,6 @@
#include "_stdio.h"
#include <stdarg.h>
-libc_hidden_proto(vdprintf)
int dprintf(int filedes, const char * __restrict format, ...)
{
diff --git a/libc/stdio/fclose.c b/libc/stdio/fclose.c
index 27d3c7e96..7e7bc3b5b 100644
--- a/libc/stdio/fclose.c
+++ b/libc/stdio/fclose.c
@@ -6,10 +6,7 @@
*/
#include "_stdio.h"
-libc_hidden_proto(fclose)
-libc_hidden_proto(close)
-libc_hidden_proto(fflush_unlocked)
int fclose(register FILE *stream)
{
@@ -72,8 +69,6 @@ int fclose(register FILE *stream)
stream->__modeflags |= (__FLAG_READONLY|__FLAG_WRITEONLY);
#ifndef NDEBUG
- __STDIO_STREAM_RESET_GCS(stream);
-
/* Reinitialize everything (including putc since fflush could fail). */
__STDIO_STREAM_DISABLE_GETC(stream);
__STDIO_STREAM_DISABLE_PUTC(stream);
diff --git a/libc/stdio/fcloseall.c b/libc/stdio/fcloseall.c
index d3cbb67f8..4d78b37d6 100644
--- a/libc/stdio/fcloseall.c
+++ b/libc/stdio/fcloseall.c
@@ -10,7 +10,6 @@
#ifdef __USE_GNU
#include "_stdio.h"
-libc_hidden_proto(fclose)
/* NOTE: GLIBC difference!!! -- fcloseall
* According to the info pages, glibc actually fclose()s all open files.
diff --git a/libc/stdio/fdopen.c b/libc/stdio/fdopen.c
index 635ab803d..76c239f4d 100644
--- a/libc/stdio/fdopen.c
+++ b/libc/stdio/fdopen.c
@@ -7,15 +7,14 @@
#include "_stdio.h"
-libc_hidden_proto(fdopen)
-libc_hidden_proto(fcntl)
FILE *fdopen(int filedes, const char *mode)
{
intptr_t cur_mode;
- return (((cur_mode = fcntl(filedes, F_GETFL))) != -1)
- ? _stdio_fopen(cur_mode, mode, NULL, filedes)
- : NULL;
+ cur_mode = fcntl(filedes, F_GETFL);
+ if (cur_mode != -1)
+ return _stdio_fopen(cur_mode, mode, NULL, filedes);
+ return NULL;
}
libc_hidden_def(fdopen)
diff --git a/libc/stdio/fflush.c b/libc/stdio/fflush.c
index e1527b3a3..cf0356a38 100644
--- a/libc/stdio/fflush.c
+++ b/libc/stdio/fflush.c
@@ -7,7 +7,6 @@
#include "_stdio.h"
-libc_hidden_proto(fflush_unlocked)
#ifdef __DO_UNLOCKED
@@ -19,15 +18,15 @@ libc_hidden_proto(fflush_unlocked)
* when all (lbf) writing streams are flushed. */
#define __MY_STDIO_THREADLOCK(__stream) \
- __UCLIBC_MUTEX_CONDITIONAL_LOCK((__stream)->__lock, \
+ __UCLIBC_IO_MUTEX_CONDITIONAL_LOCK((__stream)->__lock, \
(_stdio_user_locking != 2))
#define __MY_STDIO_THREADUNLOCK(__stream) \
- __UCLIBC_MUTEX_CONDITIONAL_UNLOCK((__stream)->__lock, \
+ __UCLIBC_IO_MUTEX_CONDITIONAL_UNLOCK((__stream)->__lock, \
(_stdio_user_locking != 2))
#if defined(__UCLIBC_HAS_THREADS__) && defined(__STDIO_BUFFERS)
-void _stdio_openlist_dec_use(void)
+void attribute_hidden _stdio_openlist_dec_use(void)
{
__STDIO_THREADLOCK_OPENLIST_DEL;
if ((_stdio_openlist_use_count == 1) && (_stdio_openlist_del_count > 0)) {
@@ -98,8 +97,6 @@ int fflush_unlocked(register FILE *stream)
while(stream) {
/* We only care about currently writing streams and do not want to
* block trying to obtain mutexes on non-writing streams. */
-#warning fix for nonatomic
-#warning unnecessary check if no threads
if (__STDIO_STREAM_IS_WRITING(stream)) { /* ONLY IF ATOMIC!!! */
__MY_STDIO_THREADLOCK(stream);
/* Need to check again once we have the lock. */
@@ -179,14 +176,12 @@ int fflush_unlocked(register FILE *stream)
libc_hidden_def(fflush_unlocked)
#ifndef __UCLIBC_HAS_THREADS__
-libc_hidden_proto(fflush)
strong_alias(fflush_unlocked,fflush)
libc_hidden_def(fflush)
#endif
#elif defined __UCLIBC_HAS_THREADS__
-libc_hidden_proto(fflush)
int fflush(register FILE *stream)
{
int retval;
diff --git a/libc/stdio/fgetc.c b/libc/stdio/fgetc.c
index 7eb2b6ea2..56a284c02 100644
--- a/libc/stdio/fgetc.c
+++ b/libc/stdio/fgetc.c
@@ -13,11 +13,9 @@
#undef getc
#undef getc_unlocked
-libc_hidden_proto(__fgetc_unlocked)
#ifdef __DO_UNLOCKED
-libc_hidden_proto(fflush_unlocked)
int __fgetc_unlocked(FILE *stream)
{
@@ -75,20 +73,13 @@ int __fgetc_unlocked(FILE *stream)
}
libc_hidden_def(__fgetc_unlocked)
-libc_hidden_proto(fgetc_unlocked)
strong_alias(__fgetc_unlocked,fgetc_unlocked)
libc_hidden_def(fgetc_unlocked)
-//libc_hidden_proto(__getc_unlocked)
-//strong_alias(__fgetc_unlocked,__getc_unlocked)
-//libc_hidden_def(__getc_unlocked)
-
-libc_hidden_proto(getc_unlocked)
strong_alias(__fgetc_unlocked,getc_unlocked)
libc_hidden_def(getc_unlocked)
#ifndef __UCLIBC_HAS_THREADS__
-libc_hidden_proto(fgetc)
strong_alias(__fgetc_unlocked,fgetc)
libc_hidden_def(fgetc)
@@ -97,7 +88,6 @@ strong_alias(__fgetc_unlocked,getc)
#elif defined __UCLIBC_HAS_THREADS__
-libc_hidden_proto(fgetc)
int fgetc(register FILE *stream)
{
if (stream->__user_locking != 0) {
diff --git a/libc/stdio/fgets.c b/libc/stdio/fgets.c
index 5acaf91ed..bc710c764 100644
--- a/libc/stdio/fgets.c
+++ b/libc/stdio/fgets.c
@@ -7,11 +7,9 @@
#include "_stdio.h"
-libc_hidden_proto(fgets_unlocked)
#ifdef __DO_UNLOCKED
-libc_hidden_proto(__fgetc_unlocked)
char *fgets_unlocked(char *__restrict s, int n,
register FILE * __restrict stream)
@@ -64,14 +62,12 @@ char *fgets_unlocked(char *__restrict s, int n,
libc_hidden_def(fgets_unlocked)
#ifndef __UCLIBC_HAS_THREADS__
-libc_hidden_proto(fgets)
strong_alias(fgets_unlocked,fgets)
libc_hidden_def(fgets)
#endif
#elif defined __UCLIBC_HAS_THREADS__
-libc_hidden_proto(fgets)
char *fgets(char *__restrict s, int n,
register FILE * __restrict stream)
{
diff --git a/libc/stdio/fgetwc.c b/libc/stdio/fgetwc.c
index 062d825d6..32d9e0ea3 100644
--- a/libc/stdio/fgetwc.c
+++ b/libc/stdio/fgetwc.c
@@ -7,9 +7,7 @@
#include "_stdio.h"
-libc_hidden_proto(fgetwc_unlocked)
-libc_hidden_proto(mbrtowc)
#ifdef __DO_UNLOCKED
@@ -58,12 +56,12 @@ wint_t fgetwc_unlocked(register FILE *stream)
stream->__ungot_width[0] = 0; /* then reset the width. */
}
- LOOP:
+ LOOP:
if ((n = __STDIO_STREAM_BUFFER_RAVAIL(stream)) == 0) {
goto FILL_BUFFER;
}
- r = mbrtowc(wc, stream->__bufpos, n, &stream->__state);
+ r = mbrtowc(wc, (const char*) stream->__bufpos, n, &stream->__state);
if (((ssize_t) r) >= 0) { /* Success... */
if (r == 0) { /* Nul wide char... means 0 byte for us so */
++r; /* increment r and handle below as single. */
@@ -78,7 +76,7 @@ wint_t fgetwc_unlocked(register FILE *stream)
/* Potentially valid but incomplete and no more buffered. */
stream->__bufpos += n; /* Update bufpos for stream. */
stream->__ungot_width[0] += n;
- FILL_BUFFER:
+ FILL_BUFFER:
if(__STDIO_FILL_READ_BUFFER(stream)) { /* Refill succeeded? */
goto LOOP;
}
@@ -98,7 +96,7 @@ wint_t fgetwc_unlocked(register FILE *stream)
* error indicator is set. */
stream->__modeflags |= __FLAG_ERROR;
- DONE:
+ DONE:
if (stream->__bufstart == sbuf) { /* Need to un-munge the stream. */
munge_stream(stream, NULL);
}
@@ -113,7 +111,6 @@ libc_hidden_def(fgetwc_unlocked)
strong_alias(fgetwc_unlocked,getwc_unlocked)
#ifndef __UCLIBC_HAS_THREADS__
-libc_hidden_proto(fgetwc)
strong_alias(fgetwc_unlocked,fgetwc)
libc_hidden_def(fgetwc)
@@ -122,7 +119,6 @@ strong_alias(fgetwc_unlocked,getwc)
#elif defined __UCLIBC_HAS_THREADS__
-libc_hidden_proto(fgetwc)
wint_t fgetwc(register FILE *stream)
{
wint_t retval;
diff --git a/libc/stdio/fgetws.c b/libc/stdio/fgetws.c
index c7dcc7d2b..b59d74b15 100644
--- a/libc/stdio/fgetws.c
+++ b/libc/stdio/fgetws.c
@@ -7,9 +7,7 @@
#include "_stdio.h"
-libc_hidden_proto(fgetws_unlocked)
-libc_hidden_proto(fgetwc_unlocked)
#ifdef __DO_UNLOCKED
diff --git a/libc/stdio/fileno.c b/libc/stdio/fileno.c
index 929936bfd..452572bae 100644
--- a/libc/stdio/fileno.c
+++ b/libc/stdio/fileno.c
@@ -7,7 +7,6 @@
#include "_stdio.h"
-libc_hidden_proto(fileno_unlocked)
#ifdef __DO_UNLOCKED
@@ -25,14 +24,12 @@ int fileno_unlocked(register FILE *stream)
libc_hidden_def(fileno_unlocked)
#ifndef __UCLIBC_HAS_THREADS__
-libc_hidden_proto(fileno)
strong_alias(fileno_unlocked,fileno)
libc_hidden_def(fileno)
#endif
#elif defined __UCLIBC_HAS_THREADS__
-libc_hidden_proto(fileno)
int fileno(register FILE *stream)
{
int retval;
diff --git a/libc/stdio/fmemopen.c b/libc/stdio/fmemopen.c
index ba194d726..4a67376f5 100644
--- a/libc/stdio/fmemopen.c
+++ b/libc/stdio/fmemopen.c
@@ -10,8 +10,6 @@
#ifdef __USE_GNU
#include "_stdio.h"
-/* Experimentally off - libc_hidden_proto(memcpy) */
-libc_hidden_proto(fopencookie)
#ifndef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__
#error no custom streams!
diff --git a/libc/stdio/fopen.c b/libc/stdio/fopen.c
index ec14b5956..a2d6617e8 100644
--- a/libc/stdio/fopen.c
+++ b/libc/stdio/fopen.c
@@ -9,12 +9,11 @@
#ifndef __DO_LARGEFILE
# define FILEDES_ARG (-1)
-#undef fopen
+# undef fopen
#else
-#undef fopen64
+# undef fopen64
#endif
-libc_hidden_proto(fopen)
FILE *fopen(const char * __restrict filename, const char * __restrict mode)
{
return _stdio_fopen(((intptr_t) filename), mode, NULL, FILEDES_ARG);
diff --git a/libc/stdio/fopencookie.c b/libc/stdio/fopencookie.c
index 0b7ed84b1..216dac39d 100644
--- a/libc/stdio/fopencookie.c
+++ b/libc/stdio/fopencookie.c
@@ -31,7 +31,6 @@
/* Currently no real reentrancy issues other than a possible double close(). */
#ifndef __BCC__
-libc_hidden_proto(fopencookie)
FILE *fopencookie(void * __restrict cookie, const char * __restrict mode,
cookie_io_functions_t io_functions)
#else
@@ -40,21 +39,34 @@ FILE *_fopencookie(void * __restrict cookie, const char * __restrict mode,
#endif
{
FILE *stream;
+ _IO_cookie_file_t *new_f;
+ new_f = malloc(sizeof(_IO_cookie_file_t));
+ if (new_f == NULL) {
+ return NULL;
+ }
+ new_f->__fp.__modeflags = __FLAG_FREEFILE;
+#ifdef __STDIO_BUFFERS
+ new_f->__fp.__bufstart = NULL; /* We allocate a buffer below. */
+#endif
+#ifdef __UCLIBC_HAS_THREADS__
+ /* We only initialize the mutex in the non-freopen case. */
+ STDIO_INIT_MUTEX(new_f->__fp.__lock);
+#endif
/* Fake an fdopen guaranteed to pass the _stdio_fopen basic agreement
* check without an fcntl call. */
- stream = _stdio_fopen(((intptr_t)(INT_MAX-1)), mode, NULL, INT_MAX);
+ stream = _stdio_fopen(((intptr_t)(INT_MAX-1)), mode, &new_f->__fp, INT_MAX);
if (stream) {
- stream->__filedes = -1;
+ stream->__filedes = __STDIO_STREAM_GLIBC_CUSTOM_FILEDES;
#ifndef __BCC__
- stream->__gcs = io_functions;
+ new_f->__gcs = io_functions;
#else
- stream->__gcs.read = io_functions->read;
- stream->__gcs.write = io_functions->write;
- stream->__gcs.seek = io_functions->seek;
- stream->__gcs.close = io_functions->close;
+ new_f->__gcs.read = io_functions->read;
+ new_f->__gcs.write = io_functions->write;
+ new_f->__gcs.seek = io_functions->seek;
+ new_f->__gcs.close = io_functions->close;
#endif
- stream->__cookie = cookie;
+ new_f->__cookie = cookie;
__STDIO_STREAM_VALIDATE(stream);
}
diff --git a/libc/stdio/fprintf.c b/libc/stdio/fprintf.c
index 4f73441e1..fb7549566 100644
--- a/libc/stdio/fprintf.c
+++ b/libc/stdio/fprintf.c
@@ -8,9 +8,7 @@
#include "_stdio.h"
#include <stdarg.h>
-libc_hidden_proto(vfprintf)
-libc_hidden_proto(fprintf)
int fprintf(FILE * __restrict stream, const char * __restrict format, ...)
{
va_list arg;
diff --git a/libc/stdio/fputc.c b/libc/stdio/fputc.c
index ac3b23ec5..7876d77af 100644
--- a/libc/stdio/fputc.c
+++ b/libc/stdio/fputc.c
@@ -12,7 +12,6 @@
#undef putc
#undef putc_unlocked
-libc_hidden_proto(__fputc_unlocked)
#ifdef __DO_UNLOCKED
@@ -72,28 +71,18 @@ int __fputc_unlocked(int c, register FILE *stream)
}
libc_hidden_def(__fputc_unlocked)
-/* exposing these would be fundamentally *wrong*! fix you, instead! */
-/* libc_hidden_proto(fputc_unlocked) */
strong_alias(__fputc_unlocked,fputc_unlocked)
-/* exposing these would be fundamentally *wrong*! fix you, instead! */
-/* libc_hidden_def(fputc_unlocked) */
-libc_hidden_proto(putc_unlocked)
strong_alias(__fputc_unlocked,putc_unlocked)
-libc_hidden_def(putc_unlocked)
#ifndef __UCLIBC_HAS_THREADS__
-libc_hidden_proto(fputc)
strong_alias(__fputc_unlocked,fputc)
libc_hidden_def(fputc)
-libc_hidden_proto(putc)
strong_alias(__fputc_unlocked,putc)
-libc_hidden_def(putc)
#endif
#elif defined __UCLIBC_HAS_THREADS__
-libc_hidden_proto(fputc)
int fputc(int c, register FILE *stream)
{
if (stream->__user_locking != 0) {
@@ -108,8 +97,6 @@ int fputc(int c, register FILE *stream)
}
libc_hidden_def(fputc)
-libc_hidden_proto(putc)
strong_alias(fputc,putc)
-libc_hidden_def(putc)
#endif
diff --git a/libc/stdio/fputs.c b/libc/stdio/fputs.c
index 8a5fd4087..b3ede6871 100644
--- a/libc/stdio/fputs.c
+++ b/libc/stdio/fputs.c
@@ -7,10 +7,7 @@
#include "_stdio.h"
-libc_hidden_proto(fputs_unlocked)
-/* Experimentally off - libc_hidden_proto(strlen) */
-libc_hidden_proto(fwrite_unlocked)
/* Note: The standard says fputs returns a nonnegative number on
* success. In this implementation, we return the length of the
@@ -29,14 +26,12 @@ int fputs_unlocked(register const char * __restrict s,
libc_hidden_def(fputs_unlocked)
#ifndef __UCLIBC_HAS_THREADS__
-libc_hidden_proto(fputs)
strong_alias(fputs_unlocked,fputs)
libc_hidden_def(fputs)
#endif
#elif defined __UCLIBC_HAS_THREADS__
-libc_hidden_proto(fputs)
int fputs(const char * __restrict s, register FILE * __restrict stream)
{
int retval;
diff --git a/libc/stdio/fputwc.c b/libc/stdio/fputwc.c
index 240c1e9c4..b699e9d4b 100644
--- a/libc/stdio/fputwc.c
+++ b/libc/stdio/fputwc.c
@@ -7,7 +7,6 @@
#include "_stdio.h"
-libc_hidden_proto(fputwc_unlocked)
#ifdef __DO_UNLOCKED
@@ -20,6 +19,7 @@ libc_hidden_def(fputwc_unlocked)
strong_alias(fputwc_unlocked,putwc_unlocked)
#ifndef __UCLIBC_HAS_THREADS__
strong_alias(fputwc_unlocked,fputwc)
+libc_hidden_def(fputwc)
strong_alias(fputwc_unlocked,putwc)
#endif
@@ -38,6 +38,7 @@ wint_t fputwc(wchar_t wc, register FILE *stream)
return retval;
}
+libc_hidden_def(fputwc)
strong_alias(fputwc,putwc)
diff --git a/libc/stdio/fputws.c b/libc/stdio/fputws.c
index ecbc121dd..7a1892188 100644
--- a/libc/stdio/fputws.c
+++ b/libc/stdio/fputws.c
@@ -7,9 +7,7 @@
#include "_stdio.h"
-libc_hidden_proto(fputws_unlocked)
-libc_hidden_proto(wcslen)
#ifdef __DO_UNLOCKED
@@ -23,14 +21,12 @@ int fputws_unlocked(const wchar_t *__restrict ws,
libc_hidden_def(fputws_unlocked)
#ifndef __UCLIBC_HAS_THREADS__
-libc_hidden_proto(fputws)
strong_alias(fputws_unlocked,fputws)
libc_hidden_def(fputws)
#endif
#elif defined __UCLIBC_HAS_THREADS__
-libc_hidden_proto(fputws)
int fputws(const wchar_t *__restrict ws, register FILE *__restrict stream)
{
int retval;
diff --git a/libc/stdio/fread.c b/libc/stdio/fread.c
index 4f9c98465..5df33b468 100644
--- a/libc/stdio/fread.c
+++ b/libc/stdio/fread.c
@@ -7,18 +7,15 @@
#include "_stdio.h"
-libc_hidden_proto(fread_unlocked)
#ifdef __DO_UNLOCKED
-/* Experimentally off - libc_hidden_proto(memcpy) */
-libc_hidden_proto(fflush_unlocked)
size_t fread_unlocked(void * __restrict ptr, size_t size, size_t nmemb,
FILE * __restrict stream)
{
__STDIO_STREAM_VALIDATE(stream);
- assert(stream->__filedes >= -1);
+ assert(stream->__filedes >= -2);
/* Note: If nmbem * size > SIZE_MAX then there is an application
* bug since no array can be larger than SIZE_MAX in size. */
@@ -90,14 +87,12 @@ size_t fread_unlocked(void * __restrict ptr, size_t size, size_t nmemb,
libc_hidden_def(fread_unlocked)
#ifndef __UCLIBC_HAS_THREADS__
-libc_hidden_proto(fread)
strong_alias(fread_unlocked,fread)
libc_hidden_def(fread)
#endif
#elif defined __UCLIBC_HAS_THREADS__
-libc_hidden_proto(fread)
size_t fread(void * __restrict ptr, size_t size, size_t nmemb,
register FILE * __restrict stream)
{
diff --git a/libc/stdio/freopen.c b/libc/stdio/freopen.c
index 942a67991..f48a43b73 100644
--- a/libc/stdio/freopen.c
+++ b/libc/stdio/freopen.c
@@ -7,7 +7,6 @@
#include "_stdio.h"
-libc_hidden_proto(fclose)
#ifndef __DO_LARGEFILE
# define FILEDES_ARG (-1)
diff --git a/libc/stdio/fseeko.c b/libc/stdio/fseeko.c
index 251040231..16b0c043a 100644
--- a/libc/stdio/fseeko.c
+++ b/libc/stdio/fseeko.c
@@ -16,11 +16,6 @@
# define OFFSET_TYPE long int
#endif
-#ifdef __UCLIBC_HAS_LFS__
-libc_hidden_proto(fseeko64)
-#endif
-libc_hidden_proto(fseek)
-
int FSEEK(register FILE *stream, OFFSET_TYPE offset, int whence)
{
#if defined(__UCLIBC_HAS_LFS__) && !defined(__DO_LARGEFILE)
@@ -82,5 +77,5 @@ int FSEEK(register FILE *stream, OFFSET_TYPE offset, int whence)
libc_hidden_def(fseeko64)
#else
libc_hidden_def(fseek)
-strong_alias(fseek,fseeko)
+strong_alias_untyped(fseek,fseeko)
#endif
diff --git a/libc/stdio/ftello.c b/libc/stdio/ftello.c
index bae1d877c..219b6996a 100644
--- a/libc/stdio/ftello.c
+++ b/libc/stdio/ftello.c
@@ -7,11 +7,6 @@
#include "_stdio.h"
-#ifdef __UCLIBC_HAS_LFS__
-libc_hidden_proto(ftello64)
-#endif
-libc_hidden_proto(ftell)
-
#ifndef __DO_LARGEFILE
# define FTELL ftell
# define OFFSET_TYPE long int
@@ -58,5 +53,5 @@ OFFSET_TYPE FTELL(register FILE *stream)
libc_hidden_def(ftello64)
#else
libc_hidden_def(ftell)
-strong_alias(ftell,ftello)
+strong_alias_untyped(ftell,ftello)
#endif
diff --git a/libc/stdio/fwprintf.c b/libc/stdio/fwprintf.c
index f2a1afbec..954970867 100644
--- a/libc/stdio/fwprintf.c
+++ b/libc/stdio/fwprintf.c
@@ -9,7 +9,6 @@
#include <stdarg.h>
#include <wchar.h>
-libc_hidden_proto(vfwprintf)
int fwprintf(FILE * __restrict stream, const wchar_t * __restrict format, ...)
{
diff --git a/libc/stdio/fwrite.c b/libc/stdio/fwrite.c
index 7be794ab4..71793ff26 100644
--- a/libc/stdio/fwrite.c
+++ b/libc/stdio/fwrite.c
@@ -7,7 +7,6 @@
#include "_stdio.h"
-libc_hidden_proto(fwrite_unlocked)
#ifdef __DO_UNLOCKED
@@ -38,14 +37,12 @@ size_t fwrite_unlocked(const void * __restrict ptr, size_t size,
libc_hidden_def(fwrite_unlocked)
#ifndef __UCLIBC_HAS_THREADS__
-libc_hidden_proto(fwrite)
strong_alias(fwrite_unlocked,fwrite)
libc_hidden_def(fwrite)
#endif
#elif defined __UCLIBC_HAS_THREADS__
-libc_hidden_proto(fwrite)
size_t fwrite(const void * __restrict ptr, size_t size,
size_t nmemb, register FILE * __restrict stream)
{
diff --git a/libc/stdio/getchar.c b/libc/stdio/getchar.c
index e29c426c8..b6c650c9b 100644
--- a/libc/stdio/getchar.c
+++ b/libc/stdio/getchar.c
@@ -7,14 +7,12 @@
#include "_stdio.h"
-libc_hidden_proto(__fgetc_unlocked)
#undef getchar
#ifdef __DO_UNLOCKED
/* the only use of the hidden getchar_unlocked is in gets.c */
#undef getchar_unlocked
-libc_hidden_proto(getchar_unlocked)
int getchar_unlocked(void)
{
register FILE *stream = stdin;
diff --git a/libc/stdio/getdelim.c b/libc/stdio/getdelim.c
index 21c86f400..987e32a19 100644
--- a/libc/stdio/getdelim.c
+++ b/libc/stdio/getdelim.c
@@ -10,9 +10,7 @@
#ifdef __USE_GNU
#include "_stdio.h"
-libc_hidden_proto(getdelim)
-libc_hidden_proto(__fgetc_unlocked)
/* Note: There is a defect in this function. (size_t vs ssize_t). */
diff --git a/libc/stdio/getline.c b/libc/stdio/getline.c
index 22b67b831..98ce8d108 100644
--- a/libc/stdio/getline.c
+++ b/libc/stdio/getline.c
@@ -10,9 +10,7 @@
#ifdef __USE_GNU
#include "_stdio.h"
-libc_hidden_proto(getline)
-libc_hidden_proto(getdelim)
ssize_t getline(char **__restrict lineptr, size_t *__restrict n,
FILE *__restrict stream)
diff --git a/libc/stdio/gets.c b/libc/stdio/gets.c
index 85bb8475a..9f4b751a1 100644
--- a/libc/stdio/gets.c
+++ b/libc/stdio/gets.c
@@ -7,13 +7,10 @@
#include "_stdio.h"
-link_warning(gets, "the 'gets' function is dangerous and should not be used.")
-
/* UNSAFE FUNCTION -- do not bother optimizing */
/* disable macro, force actual function call */
#undef getchar_unlocked
-libc_hidden_proto(getchar_unlocked)
char *gets(char *s)
{
diff --git a/libc/stdio/getw.c b/libc/stdio/getw.c
index e3aeda92c..625f17f3e 100644
--- a/libc/stdio/getw.c
+++ b/libc/stdio/getw.c
@@ -7,7 +7,6 @@
#include "_stdio.h"
-libc_hidden_proto(fread_unlocked)
/* SUSv2 Legacy function -- need not be reentrant. */
diff --git a/libc/stdio/getwchar.c b/libc/stdio/getwchar.c
index 9c480b564..75266de3a 100644
--- a/libc/stdio/getwchar.c
+++ b/libc/stdio/getwchar.c
@@ -9,7 +9,6 @@
#ifdef __DO_UNLOCKED
-libc_hidden_proto(fgetwc_unlocked)
wint_t getwchar_unlocked(void)
{
@@ -22,7 +21,6 @@ strong_alias(getwchar_unlocked,getwchar)
#elif defined __UCLIBC_HAS_THREADS__
-libc_hidden_proto(fgetwc)
wint_t getwchar(void)
{
diff --git a/libc/stdio/old_vfprintf.c b/libc/stdio/old_vfprintf.c
index a7ec28d8d..75bf3413e 100644
--- a/libc/stdio/old_vfprintf.c
+++ b/libc/stdio/old_vfprintf.c
@@ -127,9 +127,7 @@
/**************************************************************************/
-#define _ISOC99_SOURCE /* for ULLONG primarily... */
#include "_stdio.h"
-/* #include <stdio.h> */
#include <stdarg.h>
#include <limits.h>
#include <stdint.h>
@@ -137,20 +135,9 @@
#include <errno.h>
#include <ctype.h>
#include <bits/uClibc_uintmaxtostr.h>
-#include <printf.h>
-#ifdef __UCLIBC_HAS_THREADS__
-#include <pthread.h>
-#endif /* __UCLIBC_HAS_THREADS__ */
+#include "_fpmaxtostr.h"
-/* Experimentally off - libc_hidden_proto(strlen) */
-/* Experimentally off - libc_hidden_proto(strnlen) */
-/* Experimentally off - libc_hidden_proto(memcpy) */
-libc_hidden_proto(putc_unlocked)
-libc_hidden_proto(__fputc_unlocked)
-libc_hidden_proto(__glibc_strerror_r)
-
-/* #undef __UCLIBC_HAS_FLOATS__ */
/* #undef WANT_FLOAT_ERROR */
/* #define WANT_FLOAT_ERROR 1 */
@@ -214,14 +201,6 @@ static void putc_unlocked_sprintf(int c, __FILE_vsnprintf *f)
#endif /* __STDIO_BUFFERS */
#ifdef __UCLIBC_HAS_FLOATS__
-#include <float.h>
-#include <bits/uClibc_fpmax.h>
-
-typedef void (__fp_outfunc_t)(FILE *fp, intptr_t type, intptr_t len,
- intptr_t buf);
-
-extern size_t _fpmaxtostr(FILE * fp, __fpmax_t x, struct printf_info *info,
- __fp_outfunc_t fp_outfunc) attribute_hidden;
static void _charpad(FILE * __restrict stream, int padchar, size_t numpad)
{
@@ -265,9 +244,6 @@ static const char spec[] = "+-#0 ";
/**********************************************************************/
-extern void _store_inttype(void *dest, int desttype, uintmax_t val) attribute_hidden;
-extern uintmax_t _load_inttype(int desttype, const void *src, int uflag) attribute_hidden;
-
/*
* In order to ease translation to what arginfo and _print_info._flags expect,
* we map: 0:int 1:char 2:longlong 4:long 8:short
@@ -343,7 +319,6 @@ static const char u_spec[] = "%nbopxXudics";
/* u_radix[i] <-> u_spec[i+2] for unsigned entries only */
static const char u_radix[] = "\x02\x08\x10\x10\x10\x0a";
-libc_hidden_proto(vfprintf)
int vfprintf(FILE * __restrict op, register const char * __restrict fmt,
va_list ap)
{
diff --git a/libc/stdio/open_memstream.c b/libc/stdio/open_memstream.c
index 5861017e4..17ef191cb 100644
--- a/libc/stdio/open_memstream.c
+++ b/libc/stdio/open_memstream.c
@@ -10,9 +10,6 @@
#ifdef __USE_GNU
#include "_stdio.h"
-/* Experimentally off - libc_hidden_proto(memcpy) */
-/* Experimentally off - libc_hidden_proto(memset) */
-libc_hidden_proto(fopencookie)
#ifndef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__
#error no custom streams!
@@ -20,6 +17,8 @@ libc_hidden_proto(fopencookie)
#define COOKIE ((__oms_cookie *) cookie)
+#define MEMSTREAM_BUFSIZ 256
+
typedef struct {
char *buf;
size_t len;
@@ -131,14 +130,13 @@ static const cookie_io_functions_t _oms_io_funcs = {
* (ie replace the FILE buffer with the cookie buffer and update FILE bufstart,
* etc. whenever we seek). */
-libc_hidden_proto(open_memstream)
-FILE *open_memstream(char **__restrict bufloc, size_t *__restrict sizeloc)
+FILE *open_memstream(char **bufloc, size_t *sizeloc)
{
register __oms_cookie *cookie;
register FILE *fp;
if ((cookie = malloc(sizeof(__oms_cookie))) != NULL) {
- if ((cookie->buf = malloc(cookie->len = BUFSIZ)) == NULL) {
+ if ((cookie->buf = malloc(cookie->len = MEMSTREAM_BUFSIZ)) == NULL) {
goto EXIT_cookie;
}
*cookie->buf = 0; /* Set nul terminator for buffer. */
diff --git a/libc/stdio/perror.c b/libc/stdio/perror.c
index 993fcf428..8b943e467 100644
--- a/libc/stdio/perror.c
+++ b/libc/stdio/perror.c
@@ -7,14 +7,11 @@
#include "_stdio.h"
-libc_hidden_proto(fprintf)
-libc_hidden_proto(__glibc_strerror_r)
#ifdef __UCLIBC_MJN3_ONLY__
#warning CONSIDER: Increase buffer size for error message (non-%m case)?
#endif
-libc_hidden_proto(perror)
void perror(register const char *s)
{
/* If the program is calling perror, it's a safe bet that printf and
diff --git a/libc/stdio/popen.c b/libc/stdio/popen.c
index 43d07fa0f..1efbd3b7a 100644
--- a/libc/stdio/popen.c
+++ b/libc/stdio/popen.c
@@ -17,6 +17,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <paths.h>
#include <errno.h>
#include <unistd.h>
#include <sys/wait.h>
@@ -26,25 +27,6 @@
#warning "hmm... susv3 says Pipe streams are byte-oriented."
#endif /* __UCLIBC_MJN3_ONLY__ */
-libc_hidden_proto(close)
-libc_hidden_proto(_exit)
-libc_hidden_proto(waitpid)
-libc_hidden_proto(execl)
-libc_hidden_proto(dup2)
-libc_hidden_proto(fdopen)
-libc_hidden_proto(pipe)
-libc_hidden_proto(vfork)
-libc_hidden_proto(fclose)
-
-/* uClinux-2.0 has vfork, but Linux 2.0 doesn't */
-#include <sys/syscall.h>
-#if ! defined __NR_vfork
-# define vfork fork
-# define VFORK_LOCK ((void) 0)
-# define VFORK_UNLOCK ((void) 0)
-libc_hidden_proto(fork)
-#endif
-
#ifndef VFORK_LOCK
__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER);
# define VFORK_LOCK __UCLIBC_MUTEX_LOCK(mylock)
@@ -110,7 +92,7 @@ FILE *popen(const char *command, const char *modes)
close(po->f->__filedes);
}
- execl("/bin/sh", "sh", "-c", command, (char *)0);
+ execl(_PATH_BSHELL, "sh", "-c", command, (char *)0);
/* SUSv3 mandates an exit code of 127 for the child if the
* command interpreter can not be invoked. */
@@ -143,12 +125,10 @@ FILE *popen(const char *command, const char *modes)
return NULL;
}
-#warning is pclose correct wrt the new mutex semantics?
-
int pclose(FILE *stream)
{
struct popen_list_item *p;
- int stat;
+ int status;
pid_t pid;
/* First, find the list entry corresponding to stream and remove it
@@ -183,8 +163,8 @@ int pclose(FILE *stream)
/* SUSv3 specificly requires that pclose not return before the child
* terminates, in order to disallow pclose from returning on EINTR. */
do {
- if (waitpid(pid, &stat, 0) >= 0) {
- return stat;
+ if (waitpid(pid, &status, 0) >= 0) {
+ return status;
}
if (errno != EINTR) {
break;
diff --git a/libc/stdio/printf.c b/libc/stdio/printf.c
index 617561fec..8cd3db9f1 100644
--- a/libc/stdio/printf.c
+++ b/libc/stdio/printf.c
@@ -8,9 +8,7 @@
#include "_stdio.h"
#include <stdarg.h>
-libc_hidden_proto(vfprintf)
-libc_hidden_proto(printf)
int printf(const char * __restrict format, ...)
{
va_list arg;
diff --git a/libc/stdio/putchar.c b/libc/stdio/putchar.c
index b54a7a815..583e90f44 100644
--- a/libc/stdio/putchar.c
+++ b/libc/stdio/putchar.c
@@ -7,7 +7,6 @@
#include "_stdio.h"
-libc_hidden_proto(__fputc_unlocked)
#undef putchar
#ifdef __DO_UNLOCKED
diff --git a/libc/stdio/puts.c b/libc/stdio/puts.c
index 08525b2f6..67775ff7c 100644
--- a/libc/stdio/puts.c
+++ b/libc/stdio/puts.c
@@ -7,8 +7,6 @@
#include "_stdio.h"
-libc_hidden_proto(__fputc_unlocked)
-libc_hidden_proto(fputs_unlocked)
int puts(register const char * __restrict s)
{
diff --git a/libc/stdio/putw.c b/libc/stdio/putw.c
index 469e44aea..ffdb11478 100644
--- a/libc/stdio/putw.c
+++ b/libc/stdio/putw.c
@@ -7,7 +7,6 @@
#include "_stdio.h"
-libc_hidden_proto(fwrite_unlocked)
/* SUSv2 Legacy function -- need not be reentrant. */
diff --git a/libc/stdio/putwchar.c b/libc/stdio/putwchar.c
index 7a6501c28..96de6a285 100644
--- a/libc/stdio/putwchar.c
+++ b/libc/stdio/putwchar.c
@@ -9,8 +9,6 @@
#ifdef __DO_UNLOCKED
-libc_hidden_proto(fputwc_unlocked)
-
wint_t putwchar_unlocked(wchar_t wc)
{
return fputwc_unlocked(wc, stdout);
@@ -22,13 +20,9 @@ strong_alias(putwchar_unlocked,putwchar)
#elif defined __UCLIBC_HAS_THREADS__
-libc_hidden_proto(__fputc_unlocked)
-/* psm: should this be fputwc? */
-libc_hidden_proto(fputc)
-
wint_t putwchar(wchar_t wc)
{
- return fputc(wc, stdout);
+ return fputwc(wc, stdout);
}
#endif
diff --git a/libc/stdio/remove.c b/libc/stdio/remove.c
index f322411e4..af2850733 100644
--- a/libc/stdio/remove.c
+++ b/libc/stdio/remove.c
@@ -10,22 +10,19 @@
#include <unistd.h>
#include <errno.h>
-libc_hidden_proto(rmdir)
-libc_hidden_proto(unlink)
-
/* SUSv3 states:
* If path does not name a directory, remove(path) shall be equivalent
* to unlink(path). If path names a directory, remove(path) shall be
* equivalent to rmdir(path).
*/
-libc_hidden_proto(remove)
int remove(register const char *filename)
{
int saved_errno = errno;
int rv;
- if (((rv = rmdir(filename)) < 0) && (errno == ENOTDIR)) {
+ rv = rmdir(filename);
+ if ((rv < 0) && (errno == ENOTDIR)) {
__set_errno(saved_errno); /* Need to restore errno. */
rv = unlink(filename);
}
diff --git a/libc/stdio/rewind.c b/libc/stdio/rewind.c
index e04d7a086..1b170443a 100644
--- a/libc/stdio/rewind.c
+++ b/libc/stdio/rewind.c
@@ -7,9 +7,7 @@
#include "_stdio.h"
-libc_hidden_proto(fseek)
-libc_hidden_proto(rewind)
void rewind(register FILE *stream)
{
__STDIO_AUTO_THREADLOCK_VAR;
diff --git a/libc/stdio/setbuf.c b/libc/stdio/setbuf.c
index 6de2c91a1..e6080a522 100644
--- a/libc/stdio/setbuf.c
+++ b/libc/stdio/setbuf.c
@@ -7,7 +7,6 @@
#include "_stdio.h"
-libc_hidden_proto(setvbuf)
void setbuf(FILE * __restrict stream, register char * __restrict buf)
{
diff --git a/libc/stdio/setbuffer.c b/libc/stdio/setbuffer.c
index ea2421aa8..b566bfc39 100644
--- a/libc/stdio/setbuffer.c
+++ b/libc/stdio/setbuffer.c
@@ -9,7 +9,6 @@
#ifdef __USE_BSD
-libc_hidden_proto(setvbuf)
/* A BSD function. The implementation matches the linux man page,
* except that we do not bother calling setvbuf if not configured
diff --git a/libc/stdio/setlinebuf.c b/libc/stdio/setlinebuf.c
index 9b4be53eb..932338886 100644
--- a/libc/stdio/setlinebuf.c
+++ b/libc/stdio/setlinebuf.c
@@ -9,7 +9,6 @@
#ifdef __USE_BSD
-libc_hidden_proto(setvbuf)
/* A BSD function. The implementation matches the linux man page,
* except that we do not bother calling setvbuf if not configured
diff --git a/libc/stdio/setvbuf.c b/libc/stdio/setvbuf.c
index 6dbb532db..0b0ea0dde 100644
--- a/libc/stdio/setvbuf.c
+++ b/libc/stdio/setvbuf.c
@@ -14,7 +14,6 @@
#error Assumption violated for buffering mode flags
#endif
-libc_hidden_proto(setvbuf)
int setvbuf(register FILE * __restrict stream, register char * __restrict buf,
int mode, size_t size)
{
diff --git a/libc/stdio/snprintf.c b/libc/stdio/snprintf.c
index ef9c69215..e0902ac70 100644
--- a/libc/stdio/snprintf.c
+++ b/libc/stdio/snprintf.c
@@ -12,9 +12,7 @@
#warning Skipping snprintf since no vsnprintf!
#else
-libc_hidden_proto(vsnprintf)
-libc_hidden_proto(snprintf)
int snprintf(char *__restrict buf, size_t size,
const char * __restrict format, ...)
{
diff --git a/libc/stdio/sprintf.c b/libc/stdio/sprintf.c
index 360245366..44304b5da 100644
--- a/libc/stdio/sprintf.c
+++ b/libc/stdio/sprintf.c
@@ -12,9 +12,7 @@
#warning Skipping sprintf since no vsnprintf!
#else
-libc_hidden_proto(vsnprintf)
-libc_hidden_proto(sprintf)
int sprintf(char *__restrict buf, const char * __restrict format, ...)
{
va_list arg;
diff --git a/libc/stdio/swprintf.c b/libc/stdio/swprintf.c
index 0c209fe4b..8e037d20d 100644
--- a/libc/stdio/swprintf.c
+++ b/libc/stdio/swprintf.c
@@ -9,7 +9,6 @@
#include <stdarg.h>
#include <wchar.h>
-libc_hidden_proto(vswprintf)
#ifndef __STDIO_BUFFERS
#warning Skipping swprintf since no buffering!
diff --git a/libc/stdio/tempnam.c b/libc/stdio/tempnam.c
index 3673f4bda..46c921014 100644
--- a/libc/stdio/tempnam.c
+++ b/libc/stdio/tempnam.c
@@ -13,14 +13,12 @@
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 <stdio.h>
#include <string.h>
#include "../misc/internals/tempname.h"
-/* Experimentally off - libc_hidden_proto(strdup) */
/* Generate a unique temporary filename using up to five characters of PFX
if it is not NULL. The directory to put this file in is searched for
@@ -37,9 +35,8 @@ tempnam (const char *dir, const char *pfx)
if (__path_search (buf, FILENAME_MAX, dir, pfx, 1))
return NULL;
- if (__gen_tempname (buf, __GT_NOCREATE))
+ if (__gen_tempname (buf, __GT_NOCREATE, 0, 0, 0))
return NULL;
return strdup (buf);
}
-
diff --git a/libc/stdio/tmpfile.c b/libc/stdio/tmpfile.c
index f83944539..3654f9e3a 100644
--- a/libc/stdio/tmpfile.c
+++ b/libc/stdio/tmpfile.c
@@ -13,17 +13,15 @@
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 <stdio.h>
+#include <sys/stat.h>
#include <unistd.h>
#include "../misc/internals/tempname.h"
+#include <not-cancel.h>
-libc_hidden_proto(fdopen)
-libc_hidden_proto(remove)
-libc_hidden_proto(close)
/* This returns a new stream opened on a temporary file (generated
by tmpnam). The file is opened with mode "w+b" (binary read/write).
@@ -37,7 +35,7 @@ FILE * tmpfile (void)
if (__path_search (buf, FILENAME_MAX, NULL, "tmpf", 0))
return NULL;
- fd = __gen_tempname (buf, __GT_FILE);
+ fd = __gen_tempname (buf, __GT_FILE, 0, 0, S_IRUSR | S_IWUSR);
if (fd < 0)
return NULL;
@@ -46,7 +44,7 @@ FILE * tmpfile (void)
(void) remove (buf);
if ((f = fdopen (fd, "w+b")) == NULL)
- close (fd);
+ close_not_cancel (fd);
return f;
}
diff --git a/libc/stdio/tmpnam.c b/libc/stdio/tmpnam.c
index 8df6ff57f..a9f67962e 100644
--- a/libc/stdio/tmpnam.c
+++ b/libc/stdio/tmpnam.c
@@ -12,15 +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 <stdio.h>
#include <string.h>
#include "../misc/internals/tempname.h"
-/* Experimentally off - libc_hidden_proto(memcpy) */
static char tmpnam_buffer[L_tmpnam];
@@ -42,7 +40,7 @@ tmpnam (char *s)
0))
return NULL;
- if (__builtin_expect (__gen_tempname (tmpbuf, __GT_NOCREATE), 0))
+ if (__builtin_expect (__gen_tempname (tmpbuf, __GT_NOCREATE, 0, 0, 0), 0))
return NULL;
if (s == NULL)
@@ -50,6 +48,3 @@ tmpnam (char *s)
return s;
}
-
-link_warning (tmpnam,
- "the use of `tmpnam' is dangerous, better use `mkstemp'")
diff --git a/libc/stdio/tmpnam_r.c b/libc/stdio/tmpnam_r.c
index eec589e39..2e70c2da6 100644
--- a/libc/stdio/tmpnam_r.c
+++ b/libc/stdio/tmpnam_r.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/>. */
#include <stdio.h>
#include "../misc/internals/tempname.h"
@@ -28,7 +27,7 @@ char * tmpnam_r (char *s)
if (__path_search (s, L_tmpnam, NULL, NULL, 0))
return NULL;
- if (__gen_tempname (s, __GT_NOCREATE))
+ if (__gen_tempname (s, __GT_NOCREATE, 0, 0, 0))
return NULL;
return s;
diff --git a/libc/stdio/ungetc.c b/libc/stdio/ungetc.c
index d900928b2..ea4edd22c 100644
--- a/libc/stdio/ungetc.c
+++ b/libc/stdio/ungetc.c
@@ -24,7 +24,6 @@
* (See section 7.19.6.2 of the C9X rationale -- WG14/N897.)
*/
-libc_hidden_proto(ungetc)
int ungetc(int c, register FILE *stream)
{
__STDIO_AUTO_THREADLOCK_VAR;
diff --git a/libc/stdio/ungetwc.c b/libc/stdio/ungetwc.c
index 579022240..25b12b887 100644
--- a/libc/stdio/ungetwc.c
+++ b/libc/stdio/ungetwc.c
@@ -12,7 +12,6 @@
* as reset stream->__ungot_width[1] for use by _stdio_adjpos().
*/
-libc_hidden_proto(ungetwc)
wint_t ungetwc(wint_t c, register FILE *stream)
{
__STDIO_AUTO_THREADLOCK_VAR;
diff --git a/libc/stdio/vasprintf.c b/libc/stdio/vasprintf.c
index b7e2e0852..fa7926c60 100644
--- a/libc/stdio/vasprintf.c
+++ b/libc/stdio/vasprintf.c
@@ -22,15 +22,6 @@
#warning Skipping vasprintf since no vsnprintf!
#else
-#ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__
-libc_hidden_proto(open_memstream)
-libc_hidden_proto(fclose)
-libc_hidden_proto(vfprintf)
-#else
-libc_hidden_proto(vsnprintf)
-#endif
-
-libc_hidden_proto(vasprintf)
int vasprintf(char **__restrict buf, const char * __restrict format,
va_list arg)
{
@@ -48,6 +39,8 @@ int vasprintf(char **__restrict buf, const char * __restrict format,
if (rv < 0) {
free(*buf);
*buf = NULL;
+ } else {
+ *buf = realloc(*buf, rv + 1);
}
}
diff --git a/libc/stdio/vdprintf.c b/libc/stdio/vdprintf.c
index 6e28b14c0..46b8dfe39 100644
--- a/libc/stdio/vdprintf.c
+++ b/libc/stdio/vdprintf.c
@@ -11,12 +11,7 @@
#include "_stdio.h"
#include <stdarg.h>
-#ifdef __USE_OLD_VFPRINTF__
-libc_hidden_proto(vfprintf)
-#endif
-libc_hidden_proto(fflush_unlocked)
-libc_hidden_proto(vdprintf)
int vdprintf(int filedes, const char * __restrict format, va_list arg)
{
FILE f;
@@ -31,30 +26,21 @@ int vdprintf(int filedes, const char * __restrict format, va_list arg)
__STDIO_STREAM_INIT_BUFREAD_BUFPOS(&f);
#endif
-/* __STDIO_STREAM_RESET_GCS(&f); */
-#ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__
- f.__cookie = &(f.__filedes);
- f.__gcs.read = NULL;
- f.__gcs.write = _cs_write;
- f.__gcs.seek = NULL;
- f.__gcs.close = NULL;
-#endif
-
f.__filedes = filedes;
f.__modeflags = (__FLAG_NARROW|__FLAG_WRITEONLY|__FLAG_WRITING);
#ifdef __UCLIBC_HAS_WCHAR__
f.__ungot_width[0] = 0;
-#endif /* __UCLIBC_HAS_WCHAR__ */
+#endif
#ifdef __STDIO_MBSTATE
__INIT_MBSTATE(&(f.__state));
-#endif /* __STDIO_MBSTATE */
+#endif
/* _vfprintf_internal doesn't do any locking, locking init is here
* only because of fflush_unlocked. TODO? */
#if (defined(__STDIO_BUFFERS) || defined(__USE_OLD_VFPRINTF__)) && defined(__UCLIBC_HAS_THREADS__)
f.__user_locking = 1; /* Set user locking. */
- __stdio_init_mutex(&f.__lock);
+ STDIO_INIT_MUTEX(f.__lock);
#endif
f.__nextopen = NULL;
diff --git a/libc/stdio/vprintf.c b/libc/stdio/vprintf.c
index 7848a078d..853f340cc 100644
--- a/libc/stdio/vprintf.c
+++ b/libc/stdio/vprintf.c
@@ -8,7 +8,6 @@
#include "_stdio.h"
#include <stdarg.h>
-libc_hidden_proto(vfprintf)
int vprintf(const char * __restrict format, va_list arg)
{
diff --git a/libc/stdio/vsnprintf.c b/libc/stdio/vsnprintf.c
index e5a14d51a..3a4c60794 100644
--- a/libc/stdio/vsnprintf.c
+++ b/libc/stdio/vsnprintf.c
@@ -8,11 +8,6 @@
#include "_stdio.h"
#include <stdarg.h>
-libc_hidden_proto(vsnprintf)
-
-#ifdef __USE_OLD_VFPRINTF__
-libc_hidden_proto(vfprintf)
-#endif
#ifdef __UCLIBC_MJN3_ONLY__
#warning WISHLIST: Implement vsnprintf for non-buffered and no custom stream case.
@@ -27,15 +22,6 @@ int vsnprintf(char *__restrict buf, size_t size,
FILE f;
int rv;
-/* __STDIO_STREAM_RESET_GCS(&f); */
-#ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__
- f.__cookie = &(f.__filedes);
- f.__gcs.read = NULL;
- f.__gcs.write = NULL;
- f.__gcs.seek = NULL;
- f.__gcs.close = NULL;
-#endif
-
f.__filedes = __STDIO_STREAM_FAKE_VSNPRINTF_FILEDES;
f.__modeflags = (__FLAG_NARROW|__FLAG_WRITEONLY|__FLAG_WRITING);
@@ -46,9 +32,9 @@ int vsnprintf(char *__restrict buf, size_t size,
__INIT_MBSTATE(&(f.__state));
#endif /* __STDIO_MBSTATE */
-#if defined(__USE_OLD_VFPRINTF__) && defined(__UCLIBC_HAS_THREADS__)
+#if (defined(__STDIO_BUFFERS) || defined(__USE_OLD_VFPRINTF__)) && defined(__UCLIBC_HAS_THREADS__)
f.__user_locking = 1; /* Set user locking. */
- __stdio_init_mutex(&f.__lock);
+ STDIO_INIT_MUTEX(f.__lock);
#endif
f.__nextopen = NULL;
@@ -101,15 +87,6 @@ int vsnprintf(char *__restrict buf, size_t size,
}
f.bufend = buf + size;
-/* __STDIO_STREAM_RESET_GCS(&f.f); */
-#ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__
- f.f.__cookie = &(f.f.__filedes);
- f.f.__gcs.read = NULL;
- f.f.__gcs.write = NULL;
- f.f.__gcs.seek = NULL;
- f.f.__gcs.close = NULL;
-#endif
-
f.f.__filedes = __STDIO_STREAM_FAKE_VSNPRINTF_FILEDES_NB;
f.f.__modeflags = (__FLAG_NARROW|__FLAG_WRITEONLY|__FLAG_WRITING);
@@ -122,7 +99,7 @@ int vsnprintf(char *__restrict buf, size_t size,
#ifdef __UCLIBC_HAS_THREADS__
f.f.__user_locking = 1; /* Set user locking. */
- __stdio_init_mutex(&f.f.__lock);
+ STDIO_INIT_MUTEX(f.f.__lock);
#endif
f.f.__nextopen = NULL;
@@ -142,7 +119,7 @@ libc_hidden_def(vsnprintf)
typedef struct {
size_t pos;
size_t len;
- unsigned char *buf;
+ char *buf;
FILE *fp;
} __snpf_cookie;
@@ -180,34 +157,34 @@ static ssize_t snpf_write(register void *cookie, const char *buf,
int vsnprintf(char *__restrict buf, size_t size,
const char * __restrict format, va_list arg)
{
- FILE f;
+ _IO_cookie_file_t cf;
__snpf_cookie cookie;
int rv;
cookie.buf = buf;
cookie.len = size;
cookie.pos = 0;
- cookie.fp = &f;
+ cookie.fp = &cf.__fp;
- f.__cookie = &cookie;
- f.__gcs.write = snpf_write;
- f.__gcs.read = NULL;
- f.__gcs.seek = NULL;
- f.__gcs.close = NULL;
+ cf.__cookie = &cookie;
+ cf.__gcs.write = snpf_write;
+ cf.__gcs.read = NULL;
+ cf.__gcs.seek = NULL;
+ cf.__gcs.close = NULL;
- f.__filedes = -1; /* For debugging. */
- f.__modeflags = (__FLAG_NARROW|__FLAG_WRITEONLY|__FLAG_WRITING);
+ cf.__fp.__filedes = __STDIO_STREAM_GLIBC_CUSTOM_FILEDES;
+ cf.__fp.__modeflags = (__FLAG_NARROW|__FLAG_WRITEONLY|__FLAG_WRITING);
#ifdef __UCLIBC_HAS_WCHAR__
- f.__ungot_width[0] = 0;
+ cf.__fp.__ungot_width[0] = 0;
#endif /* __UCLIBC_HAS_WCHAR__ */
#ifdef __STDIO_MBSTATE
- __INIT_MBSTATE(&(f.__state));
+ __INIT_MBSTATE(&(cf.__fp.__state));
#endif /* __STDIO_MBSTATE */
- f.__nextopen = NULL;
+ cf.__fp.__nextopen = NULL;
- rv = _vfprintf_internal(&f, format, arg);
+ rv = _vfprintf_internal(&cf.__fp, format, arg);
return rv;
}
diff --git a/libc/stdio/vsprintf.c b/libc/stdio/vsprintf.c
index 8e27c19d9..d87090147 100644
--- a/libc/stdio/vsprintf.c
+++ b/libc/stdio/vsprintf.c
@@ -12,7 +12,6 @@
#warning Skipping vsprintf since no vsnprintf!
#else
-libc_hidden_proto(vsnprintf)
int vsprintf(char *__restrict buf, const char * __restrict format,
va_list arg)
diff --git a/libc/stdio/vswprintf.c b/libc/stdio/vswprintf.c
index cddf1d5d9..58a06a763 100644
--- a/libc/stdio/vswprintf.c
+++ b/libc/stdio/vswprintf.c
@@ -9,7 +9,6 @@
#include <stdarg.h>
#include <wchar.h>
-libc_hidden_proto(vswprintf)
/* NB: this file is not used if __USE_OLD_VFPRINTF__ */
@@ -23,15 +22,6 @@ int vswprintf(wchar_t *__restrict buf, size_t size,
FILE f;
int rv;
-/* __STDIO_STREAM_RESET_GCS(&f); */
-#ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__
- f.__cookie = &(f.__filedes);
- f.__gcs.read = NULL;
- f.__gcs.write = NULL;
- f.__gcs.seek = NULL;
- f.__gcs.close = NULL;
-#endif
-
f.__filedes = __STDIO_STREAM_FAKE_VSWPRINTF_FILEDES;
f.__modeflags = (__FLAG_WIDE|__FLAG_WRITEONLY|__FLAG_WRITING);
@@ -40,14 +30,19 @@ int vswprintf(wchar_t *__restrict buf, size_t size,
__INIT_MBSTATE(&(f.__state));
#endif /* __STDIO_MBSTATE */
+#ifdef __UCLIBC_HAS_THREADS__
+ f.__user_locking = 1; /* Set user locking. */
+ STDIO_INIT_MUTEX(f.__lock);
+#endif /* __UCLIBC_HAS_THREADS__ */
+
f.__nextopen = NULL;
if (size > ((SIZE_MAX - (size_t) buf)/sizeof(wchar_t))) {
size = ((SIZE_MAX - (size_t) buf)/sizeof(wchar_t));
}
- f.__bufstart = (char *) buf;
- f.__bufend = (char *)(buf + size);
+ f.__bufstart = (unsigned char *) buf;
+ f.__bufend = (unsigned char *) (buf + size);
__STDIO_STREAM_INIT_BUFREAD_BUFPOS(&f);
__STDIO_STREAM_DISABLE_GETC(&f);
__STDIO_STREAM_DISABLE_PUTC(&f);
@@ -58,7 +53,7 @@ int vswprintf(wchar_t *__restrict buf, size_t size,
if (f.__bufpos == f.__bufend) {
rv = -1;
if (size) {
- f.__bufpos = (char *)(((wchar_t *) f.__bufpos) - 1);
+ f.__bufpos = (unsigned char *) (((wchar_t *) f.__bufpos) - 1);
}
}
if (size) {
diff --git a/libc/stdio/vwprintf.c b/libc/stdio/vwprintf.c
index 1c32887a4..25dd5b3fa 100644
--- a/libc/stdio/vwprintf.c
+++ b/libc/stdio/vwprintf.c
@@ -9,7 +9,6 @@
#include <stdarg.h>
#include <wchar.h>
-libc_hidden_proto(vfwprintf)
int vwprintf(const wchar_t * __restrict format, va_list arg)
{
diff --git a/libc/stdio/wprintf.c b/libc/stdio/wprintf.c
index 9dc274aec..b3a6318a5 100644
--- a/libc/stdio/wprintf.c
+++ b/libc/stdio/wprintf.c
@@ -9,7 +9,6 @@
#include <stdarg.h>
#include <wchar.h>
-libc_hidden_proto(vfwprintf)
int wprintf(const wchar_t * __restrict format, ...)
{
diff --git a/libc/stdlib/Makefile.in b/libc/stdlib/Makefile.in
index dfef6d18e..ae74995bb 100644
--- a/libc/stdlib/Makefile.in
+++ b/libc/stdlib/Makefile.in
@@ -1,99 +1,85 @@
# 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.
#
+subdirs += libc/stdlib
+
include $(top_srcdir)libc/stdlib/malloc/Makefile.in
include $(top_srcdir)libc/stdlib/malloc-simple/Makefile.in
include $(top_srcdir)libc/stdlib/malloc-standard/Makefile.in
-CSRC := \
- abort.c getenv.c mkdtemp.c mktemp.c realpath.c mkstemp.c \
- rand.c random.c random_r.c setenv.c system.c div.c ldiv.c lldiv.c \
- getpt.c drand48-iter.c jrand48.c \
- jrand48_r.c lrand48.c lrand48_r.c mrand48.c mrand48_r.c nrand48.c \
+CSRC-y := \
+ abort.c getenv.c mkdtemp.c realpath.c canonicalize.c mkstemp.c mkostemp.c \
+ mkstemps.c mkostemps.c rand.c random.c random_r.c setenv.c div.c ldiv.c \
+ lldiv.c getpt.c drand48-iter.c jrand48.c \
+ jrand48_r.c lcong48.c lrand48.c lrand48_r.c mrand48.c mrand48_r.c nrand48.c \
nrand48_r.c rand_r.c srand48.c srand48_r.c seed48.c seed48_r.c \
- valloc.c a64l.c l64a.c __uc_malloc.c
-ifeq ($(UCLIBC_HAS_ADVANCED_REALTIME),y)
-CSRC += posix_memalign.c
-endif
-ifeq ($(UCLIBC_HAS_PTY),y)
-CSRC += grantpt.c unlockpt.c ptsname.c
-endif
-ifeq ($(UCLIBC_HAS_ARC4RANDOM),y)
-CSRC += arc4random.c
-endif
-ifeq ($(UCLIBC_HAS_LFS),y)
-CSRC += mkstemp64.c
-endif
-ifeq ($(UCLIBC_HAS_FLOATS),y)
-CSRC += drand48.c drand48_r.c erand48.c erand48_r.c
-ifeq ($(UCLIBC_SUSV3_LEGACY),y)
-CSRC += gcvt.c
-endif
+ a64l.c l64a.c __uc_malloc.c
+CSRC-$(UCLIBC_SUSV2_LEGACY) += valloc.c
+CSRC-$(UCLIBC_HAS_ADVANCED_REALTIME) += posix_memalign.c
+CSRC-$(UCLIBC_HAS_PTY) += grantpt.c unlockpt.c ptsname.c
+CSRC-$(UCLIBC_HAS_ARC4RANDOM) += arc4random.c
+CSRC-$(UCLIBC_HAS_LFS) += mkstemp64.c mkostemp64.c mkstemps64.c mkostemps64.c
+CSRC-$(UCLIBC_HAS_FLOATS) += drand48.c drand48_r.c erand48.c erand48_r.c
+CSRC-$(if $(findstring yy,$(UCLIBC_HAS_FLOATS)$(UCLIBC_SUSV3_LEGACY)),y) += \
+ gcvt.c
+CSRC-$(UCLIBC_SUSV3_LEGACY) += mktemp.c
+
+ifneq ($(UCLIBC_HAS_BACKTRACE),)
+CFLAGS-abort.c = -fasynchronous-unwind-tables
endif
# multi source stdlib.c
-CSRC += abs.c labs.c atoi.c atol.c strtol.c strtoul.c _stdlib_strto_l.c \
- qsort.c bsearch.c \
+CSRC-y += abs.c labs.c atoi.c atol.c strtol.c strtoul.c _stdlib_strto_l.c \
+ qsort.c qsort_r.c bsearch.c rpmatch.c \
llabs.c atoll.c strtoll.c strtoull.c _stdlib_strto_ll.c
# (aliases) strtoq.o strtouq.o
-ifeq ($(UCLIBC_HAS_FLOATS),y)
-CSRC += atof.c
-endif
-ifeq ($(UCLIBC_HAS_XLOCALE),y)
-CSRC += strtol_l.c strtoul_l.c _stdlib_strto_l_l.c \
+CSRC-$(UCLIBC_HAS_FLOATS) += atof.c
+CSRC-$(UCLIBC_HAS_XLOCALE) += strtol_l.c strtoul_l.c _stdlib_strto_l_l.c \
strtoll_l.c strtoull_l.c _stdlib_strto_ll_l.c
-endif
-ifeq ($(UCLIBC_HAS_WCHAR),y)
-CSRC += mblen.c mbtowc.c wctomb.c mbstowcs.c wcstombs.c \
+
+CSRC-$(UCLIBC_HAS_WCHAR) += mblen.c mbtowc.c wctomb.c mbstowcs.c wcstombs.c \
_stdlib_mb_cur_max.c _stdlib_wcsto_l.c _stdlib_wcsto_ll.c \
wcstol.c wcstoul.c wcstoll.c wcstoull.c
-ifeq ($(UCLIBC_HAS_XLOCALE),y)
-CSRC +=_stdlib_wcsto_l_l.c _stdlib_wcsto_ll_l.c \
+CSRC-$(if $(findstring yy,$(UCLIBC_HAS_WCHAR)$(UCLIBC_HAS_XLOCALE)),y) += \
+ _stdlib_wcsto_l_l.c _stdlib_wcsto_ll_l.c \
wcstol_l.c wcstoul_l.c wcstoll_l.c wcstoull_l.c
-endif
-endif
# multi source _strtod.c
-ifeq ($(UCLIBC_HAS_FLOATS),y)
-CSRC += strtod.c strtof.c strtold.c __strtofpmax.c __fp_range_check.c
-ifeq ($(UCLIBC_HAS_XLOCALE),y)
-CSRC += strtod_l.c strtof_l.c strtold_l.c __strtofpmax_l.c
-endif
-ifeq ($(UCLIBC_HAS_WCHAR),y)
-CSRC += wcstod.c wcstof.c wcstold.c __wcstofpmax.c
-ifeq ($(UCLIBC_HAS_XLOCALE),y)
-CSRC += wcstod_l.c wcstof_l.c wcstold_l.c __wcstofpmax_l.c
-endif
-endif
-endif
+CSRC-$(UCLIBC_HAS_FLOATS) += strtod.c strtof.c strtold.c __strtofpmax.c __fp_range_check.c
+CSRC-$(if $(findstring yy,$(UCLIBC_HAS_FLOATS)$(UCLIBC_HAS_XLOCALE)),y) += \
+ strtod_l.c strtof_l.c strtold_l.c __strtofpmax_l.c
+CSRC-$(if $(findstring yy,$(UCLIBC_HAS_FLOATS)$(UCLIBC_HAS_WCHAR)),y) += \
+ wcstod.c wcstof.c wcstold.c __wcstofpmax.c
+CSRC-$(if $(findstring yyy,$(UCLIBC_HAS_FLOATS)$(UCLIBC_HAS_WCHAR)$(UCLIBC_HAS_XLOCALE)),y) += \
+ wcstod_l.c wcstof_l.c wcstold_l.c __wcstofpmax_l.c
# (aliases) wcstoq.o wcstouq.o
# wcstod wcstof wcstold
# multi source _atexit.c
-CSRC += __cxa_atexit.c __cxa_finalize.c __exit_handler.c exit.c on_exit.c
-ifeq ($(COMPAT_ATEXIT),y)
-CSRC += old_atexit.c
-endif
+CSRC-y += __cxa_atexit.c __cxa_finalize.c __exit_handler.c exit.c on_exit.c
STDLIB_DIR := $(top_srcdir)libc/stdlib
STDLIB_OUT := $(top_builddir)libc/stdlib
-STDLIB_SRC := $(patsubst %.c,$(STDLIB_DIR)/%.c,$(CSRC))
-STDLIB_OBJ := $(patsubst %.c,$(STDLIB_OUT)/%.o,$(CSRC))
+STDLIB_SRC := $(patsubst %.c,$(STDLIB_DIR)/%.c,$(CSRC-y))
+STDLIB_OBJ := $(patsubst %.c,$(STDLIB_OUT)/%.o,$(CSRC-y))
libc-y += $(STDLIB_OBJ)
-libc-static-y += $(STDLIB_OUT)/atexit.o
+libc-static-y += $(STDLIB_OUT)/atexit.o $(STDLIB_OUT)/system.o
+libc-static-$(COMPAT_ATEXIT) += $(STDLIB_OUT)/old_atexit.o
+libc-shared-y += $(STDLIB_OUT)/system.oS
+
# this should always be the PIC version, because it could be used in shared libs
libc-nonshared-y += $(STDLIB_OUT)/atexit.os
-
+libc-nonshared-$(COMPAT_ATEXIT) += $(STDLIB_OUT)/old_atexit.os
libc-nomulti-y += $(STDLIB_OUT)/labs.o $(STDLIB_OUT)/atol.o $(STDLIB_OUT)/_stdlib_strto_l.o $(STDLIB_OUT)/_stdlib_strto_ll.o
libc-nomulti-$(UCLIBC_HAS_XLOCALE) += $(STDLIB_OUT)/_stdlib_strto_l_l.o $(STDLIB_OUT)/_stdlib_strto_ll_l.o
-objclean-y += stdlib_objclean
+objclean-y += CLEAN_libc/stdlib
-stdlib_objclean:
- $(RM) $(STDLIB_OUT)/*.{o,os,oS}
+CLEAN_libc/stdlib:
+ $(do_rm) $(addprefix $(STDLIB_OUT)/*., o os oS)
diff --git a/libc/stdlib/__uc_malloc.c b/libc/stdlib/__uc_malloc.c
index 81eee1343..e1b6c8407 100644
--- a/libc/stdlib/__uc_malloc.c
+++ b/libc/stdlib/__uc_malloc.c
@@ -13,8 +13,7 @@ Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this 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/>.
*/
@@ -22,9 +21,6 @@ Cambridge, MA 02139, USA.
#include <unistd.h>
#include <malloc.h>
-libc_hidden_proto(_exit)
-libc_hidden_proto(__uc_malloc)
-libc_hidden_proto(__uc_malloc_failed)
void (*__uc_malloc_failed)(size_t size) = NULL;
/* Seemingly superfluous assigment of NULL above prevents gas error
@@ -42,6 +38,7 @@ void *__uc_malloc(size_t size)
return p;
if (!__uc_malloc_failed)
_exit(1);
+ free(p);
__uc_malloc_failed(size);
}
}
diff --git a/libc/stdlib/_atexit.c b/libc/stdlib/_atexit.c
index e5840f471..8a3196781 100644
--- a/libc/stdlib/_atexit.c
+++ b/libc/stdlib/_atexit.c
@@ -40,19 +40,21 @@
#include <features.h>
#include <unistd.h>
#include <stdlib.h>
+#include <stdio.h>
#include <errno.h>
#include <atomic.h>
+#if defined __UCLIBC_HAS_THREADS__ && defined __UCLIBC_HAS_THREADS_NATIVE__
+# include <fork.h>
+#endif
#include <bits/uClibc_mutex.h>
-__UCLIBC_MUTEX_EXTERN(__atexit_lock);
+__UCLIBC_MUTEX_EXTERN(__atexit_lock) attribute_hidden;
-libc_hidden_proto(exit)
-libc_hidden_proto(_exit)
-typedef void (*aefuncp) (void); /* atexit function pointer */
-typedef void (*oefuncp) (int, void *); /* on_exit function pointer */
-typedef void (*cxaefuncp) (void *); /* __cxa_atexit function pointer */
+typedef void (*aefuncp)(void); /* atexit function pointer */
+typedef void (*oefuncp)(int, void *); /* on_exit function pointer */
+typedef void (*cxaefuncp)(void *); /* __cxa_atexit function pointer */
typedef enum {
ef_free,
ef_in_use,
@@ -61,7 +63,7 @@ typedef enum {
} ef_type; /* exit function types */
/* this is in the L_exit object */
-extern void (*__exit_cleanup) (int) attribute_hidden;
+extern void (*__exit_cleanup)(int) attribute_hidden;
/* these are in the L___do_exit object */
extern int __exit_slots attribute_hidden;
@@ -90,10 +92,10 @@ extern struct exit_function *__exit_function_table attribute_hidden;
#else
extern struct exit_function __exit_function_table[__UCLIBC_MAX_ATEXIT] attribute_hidden;
#endif
-extern struct exit_function *__new_exitfn (void) attribute_hidden;
+extern struct exit_function *__new_exitfn(void) attribute_hidden;
/* this is in the L___cxa_atexit object */
-extern int __cxa_atexit (cxaefuncp, void *arg, void *dso_handle);
+extern int __cxa_atexit(cxaefuncp, void *arg, void *dso_handle);
/* remove old_atexit after 0.9.29 */
@@ -155,7 +157,7 @@ int on_exit(oefuncp func, void *arg)
#ifdef L___cxa_atexit
libc_hidden_proto(__cxa_atexit)
-int __cxa_atexit (cxaefuncp func, void *arg, void *dso_handle)
+int __cxa_atexit(cxaefuncp func, void *arg, void *dso_handle)
{
struct exit_function *efp;
@@ -185,8 +187,8 @@ libc_hidden_def(__cxa_atexit)
* with the same dso handle. Otherwise, if D is NULL, call all of the
* registered handlers.
*/
-void __cxa_finalize (void *dso_handle);
-void __cxa_finalize (void *dso_handle)
+void __cxa_finalize(void *dso_handle);
+void __cxa_finalize(void *dso_handle)
{
struct exit_function *efp;
int exit_count_snapshot = __exit_count;
@@ -209,17 +211,15 @@ void __cxa_finalize (void *dso_handle)
}
}
-#if 0 /* haven't looked into this yet... */
/*
* Remove the registered fork handlers. We do not have to
* unregister anything if the program is going to terminate anyway.
*/
#ifdef UNREGISTER_ATFORK
- if (d != NULL) {
- UNREGISTER_ATFORK (d);
+ if (dso_handle != NULL) {
+ UNREGISTER_ATFORK(dso_handle);
}
#endif
-#endif
}
#endif
@@ -242,13 +242,23 @@ struct exit_function attribute_hidden *__new_exitfn(void)
__UCLIBC_MUTEX_LOCK(__atexit_lock);
+ /*
+ * Reuse free slots at the end of the list.
+ * This avoids eating memory when dlopen and dlclose modules multiple times.
+ */
+ while (__exit_count > 0) {
+ if (__exit_function_table[__exit_count-1].type == ef_free) {
+ --__exit_count;
+ } else break;
+ }
+
#ifdef __UCLIBC_DYNAMIC_ATEXIT__
/* If we are out of function table slots, make some more */
if (__exit_slots < __exit_count+1) {
- efp=realloc(__exit_function_table,
+ efp = realloc(__exit_function_table,
(__exit_slots+20)*sizeof(struct exit_function));
if (efp == NULL) {
- __set_errno(ENOMEM);
+ /* __set_errno(ENOMEM); */
goto DONE;
}
__exit_function_table = efp;
@@ -281,18 +291,18 @@ void __exit_handler(int status)
struct exit_function *efp;
/* In reverse order */
- while ( __exit_count ) {
+ while (__exit_count) {
efp = &__exit_function_table[--__exit_count];
switch (efp->type) {
case ef_on_exit:
if (efp->funcs.on_exit.func) {
- (efp->funcs.on_exit.func) (status, efp->funcs.on_exit.arg);
+ (efp->funcs.on_exit.func)(status, efp->funcs.on_exit.arg);
}
break;
case ef_cxa_atexit:
if (efp->funcs.cxa_atexit.func) {
/* glibc passes status too, but that's not in the prototype */
- (efp->funcs.cxa_atexit.func) (efp->funcs.cxa_atexit.arg);
+ (efp->funcs.cxa_atexit.func)(efp->funcs.cxa_atexit.arg);
}
break;
}
@@ -305,12 +315,22 @@ void __exit_handler(int status)
#endif
#ifdef L_exit
+/* Defeat compiler optimization which assumes function addresses are never NULL */
+static __always_inline int not_null_ptr(const void *p)
+{
+ const void *q;
+ __asm__ (""
+ : "=r" (q) /* output */
+ : "0" (p) /* input */
+ );
+ return q != 0;
+}
+
extern void weak_function _stdio_term(void) attribute_hidden;
-attribute_hidden void (*__exit_cleanup) (int) = 0;
+attribute_hidden void (*__exit_cleanup)(int) = 0;
__UCLIBC_MUTEX_INIT(__atexit_lock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP);
-extern void __uClibc_fini(void);
-libc_hidden_proto(__uClibc_fini)
+extern void __uClibc_fini(void) attribute_hidden;
/*
* Normal program termination
@@ -319,19 +339,19 @@ void exit(int rv)
{
/* Perform exit-specific cleanup (atexit and on_exit) */
__UCLIBC_MUTEX_LOCK(__atexit_lock);
- if (__exit_cleanup) {
+ if (not_null_ptr(__exit_cleanup)) {
__exit_cleanup(rv);
}
__UCLIBC_MUTEX_UNLOCK(__atexit_lock);
__uClibc_fini();
- /* If we are using stdio, try to shut it down. At the very least,
+ /* If we are using stdio, try to shut it down. At the very least,
* this will attempt to commit all buffered writes. It may also
* unbuffer all writable files, or close them outright.
* Check the stdio routines for details. */
- if (_stdio_term)
- _stdio_term();
+ if (not_null_ptr(_stdio_term))
+ _stdio_term();
_exit(rv);
}
diff --git a/libc/stdlib/_strtod.c b/libc/stdlib/_strtod.c
index 1b2adc986..c4c79e511 100644
--- a/libc/stdlib/_strtod.c
+++ b/libc/stdlib/_strtod.c
@@ -36,7 +36,7 @@
*/
/**********************************************************************/
-/* OPTIONS */
+/* OPTIONS */
/**********************************************************************/
/* Defined if we want to recognize "nan", "inf", and "infinity". (C99) */
@@ -79,7 +79,7 @@
#define _STRTOD_ZERO_CHECK 1
/**********************************************************************/
-/* Don't change anything that follows. */
+/* Don't change anything that follows. */
/**********************************************************************/
#ifdef _STRTOD_ERRNO
@@ -95,7 +95,6 @@
/**********************************************************************/
-#define _ISOC99_SOURCE 1
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
@@ -107,23 +106,16 @@
#include <locale.h>
#ifdef __UCLIBC_HAS_WCHAR__
-
-#include <wchar.h>
-#include <wctype.h>
-#include <bits/uClibc_uwchar.h>
-libc_hidden_proto(iswspace)
+# include <wchar.h>
+# include <wctype.h>
+# include <bits/uClibc_uwchar.h>
#endif
-#ifdef __UCLIBC_HAS_XLOCALE__
-#include <xlocale.h>
-libc_hidden_proto(iswspace_l)
-#endif /* __UCLIBC_HAS_XLOCALE__ */
-
/* Handle _STRTOD_HEXADECIMAL_FLOATS via uClibc config now. */
#undef _STRTOD_HEXADECIMAL_FLOATS
#ifdef __UCLIBC_HAS_HEXADECIMAL_FLOATS__
-#define _STRTOD_HEXADECIMAL_FLOATS 1
-#endif /* __UCLIBC_HAS_HEXADECIMAL_FLOATS__ */
+# define _STRTOD_HEXADECIMAL_FLOATS 1
+#endif
/**********************************************************************/
@@ -175,13 +167,6 @@ extern void __fp_range_check(__fpmax_t y, __fpmax_t x) attribute_hidden;
/**********************************************************************/
#if defined(L___strtofpmax) || defined(L___strtofpmax_l) || defined(L___wcstofpmax) || defined(L___wcstofpmax_l)
-#ifdef __UCLIBC_HAS_XLOCALE__
-libc_hidden_proto(__ctype_b_loc)
-#elif defined __UCLIBC_HAS_CTYPE_TABLES__
-libc_hidden_proto(__ctype_b)
-libc_hidden_proto(__ctype_tolower)
-#endif
-
#if defined(L___wcstofpmax) || defined(L___wcstofpmax_l)
#define __strtofpmax __wcstofpmax
@@ -215,7 +200,6 @@ __fpmax_t attribute_hidden __strtofpmax(const Wchar *str, Wchar **endptr, int ex
#else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
-/* Experimentally off - libc_hidden_proto(memcmp) */
__fpmax_t attribute_hidden __XL_NPP(__strtofpmax)(const Wchar *str, Wchar **endptr, int exponent_power
__LOCALE_PARAM )
@@ -348,16 +332,11 @@ __fpmax_t attribute_hidden __XL_NPP(__strtofpmax)(const Wchar *str, Wchar **endp
static const char nan_inf_str[] = "\05nan\0\012infinity\0\05inf\0";
int i = 0;
-#ifdef __UCLIBC_HAS_LOCALE__
- /* Avoid tolower problems for INFINITY in the tr_TR locale. (yuk)*/
-#undef _tolower
-#define _tolower(C) ((C)|0x20)
-#endif /* __UCLIBC_HAS_LOCALE__ */
-
do {
/* Unfortunately, we have no memcasecmp(). */
int j = 0;
- while (_tolower(pos[j]) == nan_inf_str[i+1+j]) {
+ /* | 0x20 is a cheap lowercasing (valid for ASCII letters and numbers only) */
+ while ((pos[j] | 0x20) == nan_inf_str[i+1+j]) {
++j;
if (!nan_inf_str[i+1+j]) {
number = i / 0.;
@@ -525,7 +504,6 @@ void attribute_hidden __fp_range_check(__fpmax_t y, __fpmax_t x)
#endif
-libc_hidden_proto(__XL_NPP(strtof))
float __XL_NPP(strtof)(const Wchar *str, Wchar **endptr __LOCALE_PARAM )
{
#if FPMAX_TYPE == 1
@@ -542,7 +520,6 @@ float __XL_NPP(strtof)(const Wchar *str, Wchar **endptr __LOCALE_PARAM )
return y;
#endif
}
-libc_hidden_def(__XL_NPP(strtof))
#endif
#endif
@@ -560,7 +537,6 @@ libc_hidden_def(__XL_NPP(strtof))
#define Wchar char
#endif
-libc_hidden_proto(__XL_NPP(strtod))
double __XL_NPP(strtod)(const Wchar *__restrict str,
Wchar **__restrict endptr __LOCALE_PARAM )
{
@@ -578,7 +554,9 @@ double __XL_NPP(strtod)(const Wchar *__restrict str,
return y;
#endif
}
-libc_hidden_def(__XL_NPP(strtod))
+#ifdef L_strtod
+libc_hidden_def(strtod)
+#endif
#endif
#endif
@@ -596,7 +574,6 @@ libc_hidden_def(__XL_NPP(strtod))
#define Wchar char
#endif
-libc_hidden_proto(__XL_NPP(strtold))
long double __XL_NPP(strtold) (const Wchar *str, Wchar **endptr __LOCALE_PARAM )
{
#if FPMAX_TYPE == 3
@@ -613,7 +590,6 @@ long double __XL_NPP(strtold) (const Wchar *str, Wchar **endptr __LOCALE_PARAM
return y;
#endif
}
-libc_hidden_def(__XL_NPP(strtold))
#endif
#endif
diff --git a/libc/stdlib/a64l.c b/libc/stdlib/a64l.c
index d09dbf464..05396b275 100644
--- a/libc/stdlib/a64l.c
+++ b/libc/stdlib/a64l.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 <stdlib.h>
diff --git a/libc/stdlib/abort.c b/libc/stdlib/abort.c
index b71512f33..dc2747f61 100644
--- a/libc/stdlib/abort.c
+++ b/libc/stdlib/abort.c
@@ -13,8 +13,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/>. */
/* Hacked up for uClibc by Erik Andersen */
@@ -26,13 +25,18 @@ Cambridge, MA 02139, USA. */
#include <signal.h>
#include <errno.h>
-libc_hidden_proto(abort)
-/* Experimentally off - libc_hidden_proto(memset) */
-libc_hidden_proto(sigaction)
-libc_hidden_proto(sigprocmask)
-libc_hidden_proto(raise)
-libc_hidden_proto(_exit)
+
+/* Defeat compiler optimization which assumes function addresses are never NULL */
+static __always_inline int not_null_ptr(const void *p)
+{
+ const void *q;
+ __asm__ (""
+ : "=r" (q) /* output */
+ : "0" (p) /* input */
+ );
+ return q != 0;
+}
/* Our last ditch effort to commit suicide */
#ifdef __UCLIBC_ABORT_INSTRUCTION__
@@ -42,9 +46,6 @@ libc_hidden_proto(_exit)
# warning "no abort instruction defined for your arch"
#endif
-#ifdef __UCLIBC_HAS_STDIO_SHUTDOWN_ON_ABORT__
-extern void weak_function _stdio_term(void) attribute_hidden;
-#endif
static smallint been_there_done_that = 0;
/* Be prepared in case multiple threads try to abort() */
@@ -60,9 +61,9 @@ void abort(void)
__UCLIBC_MUTEX_LOCK_CANCEL_UNSAFE(mylock);
/* Unmask SIGABRT to be sure we can get it */
- if (__sigemptyset(&sigs) == 0 && __sigaddset(&sigs, SIGABRT) == 0) {
- sigprocmask(SIG_UNBLOCK, &sigs, (sigset_t *) NULL);
- }
+ __sigemptyset(&sigs);
+ __sigaddset(&sigs, SIGABRT);
+ sigprocmask(SIG_UNBLOCK, &sigs, NULL);
while (1) {
/* Try to suicide with a SIGABRT */
@@ -74,7 +75,7 @@ void abort(void)
* this will attempt to commit all buffered writes. It may also
* unbuffer all writable files, or close them outright.
* Check the stdio routines for details. */
- if (_stdio_term) {
+ if (not_null_ptr(_stdio_term)) {
_stdio_term();
}
#endif
@@ -91,9 +92,9 @@ abort_it:
been_there_done_that++;
memset(&act, '\0', sizeof(struct sigaction));
- act.sa_handler = SIG_DFL;
+ if (SIG_DFL) /* if it's constant zero, already done */
+ act.sa_handler = SIG_DFL;
__sigfillset(&act.sa_mask);
- act.sa_flags = 0;
sigaction(SIGABRT, &act, NULL);
goto abort_it;
diff --git a/libc/stdlib/arc4random.c b/libc/stdlib/arc4random.c
index bf6a4cd30..0013612e9 100644
--- a/libc/stdlib/arc4random.c
+++ b/libc/stdlib/arc4random.c
@@ -1,24 +1,29 @@
-/* $$$: arc4random.c 2005/02/08 robert */
-/* $NetBSD: arc4random.c,v 1.5.2.1 2004/03/26 22:52:50 jmc Exp $ */
-/* $OpenBSD: arc4random.c,v 1.6 2001/06/05 05:05:38 pvalchev Exp $ */
-
/*
- * Arc4 random number generator for OpenBSD.
- * Copyright 1996 David Mazieres <dm@lcs.mit.edu>.
+ * Copyright (c) 1996, David Mazieres <dm@uun.org>
*
- * Modification and redistribution in source and binary forms is
- * permitted provided that due credit is given to the author and the
- * OpenBSD project by leaving this copyright notice intact.
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
+ * Arc4 random number generator for OpenBSD.
+ *
* This code is derived from section 17.1 of Applied Cryptography,
* second edition, which describes a stream cipher allegedly
* compatible with RSA Labs "RC4" cipher (the actual description of
* which is a trade secret). The same algorithm is used as a stream
* cipher called "arcfour" in Tatu Ylonen's ssh package.
*
- * Here the stream cipher has been modified always to include the time
+ * Here the stream cipher has been modified always to include entropy
* when initializing the state. That makes it impossible to
* regenerate the same random sequence twice, so this can't be used
* for encryption, but will generate good random numbers.
@@ -26,41 +31,29 @@
* RC4 is a registered trademark of RSA Laboratories.
*/
+/* $OpenBSD: arc4random.c,v 1.16 2007/02/12 19:58:47 otto Exp $ */
+
#include <features.h>
+
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
-#include <sys/param.h>
#include <sys/time.h>
-#ifdef __ARC4RANDOM_USE_ERANDOM__
-#include <sys/sysctl.h>
-//libc_hidden_proto(sysctl)
-#endif
-
-libc_hidden_proto(open)
-libc_hidden_proto(read)
-libc_hidden_proto(close)
-libc_hidden_proto(gettimeofday)
struct arc4_stream {
- uint8_t i;
- uint8_t j;
- uint8_t s[256];
+ u_int8_t i;
+ u_int8_t j;
+ u_int8_t s[256];
};
-static int rs_initialized;
+static smallint rs_initialized;
static struct arc4_stream rs;
-
-static __inline__ void arc4_init(struct arc4_stream *);
-static __inline__ void arc4_addrandom(struct arc4_stream *, u_char *, int);
-static void arc4_stir(struct arc4_stream *);
-static __inline__ uint8_t arc4_getbyte(struct arc4_stream *);
-static __inline__ uint32_t arc4_getword(struct arc4_stream *);
+static pid_t arc4_stir_pid;
+static int arc4_count;
static __inline__ void
-arc4_init(as)
- struct arc4_stream *as;
+arc4_init(struct arc4_stream *as)
{
int n;
@@ -70,14 +63,25 @@ arc4_init(as)
as->j = 0;
}
+static __inline__ u_int8_t
+arc4_getbyte(struct arc4_stream *as)
+{
+ u_int8_t si, sj;
+
+ as->i = (as->i + 1);
+ si = as->s[as->i];
+ as->j = (as->j + si);
+ sj = as->s[as->j];
+ as->s[as->i] = sj;
+ as->s[as->j] = si;
+ return (as->s[(si + sj) & 0xff]);
+}
+
static __inline__ void
-arc4_addrandom(as, dat, datlen)
- struct arc4_stream *as;
- u_char *dat;
- int datlen;
+arc4_addrandom(struct arc4_stream *as, u_char *dat, int datlen)
{
int n;
- uint8_t si;
+ u_int8_t si;
as->i--;
for (n = 0; n < 256; n++) {
@@ -91,76 +95,90 @@ arc4_addrandom(as, dat, datlen)
}
static void
-arc4_stir(as)
- struct arc4_stream *as;
+arc4_stir(struct arc4_stream *as)
{
- int fd;
- struct {
- struct timeval tv;
- uint rnd[(128 - sizeof(struct timeval)) / sizeof(uint)];
- } rdat;
int n;
+ u_char rnd[128];
+ struct timeval tv;
+
+#ifndef __ARC4RANDOM_USES_NODEV__
+ int fd;
- gettimeofday(&rdat.tv, NULL);
fd = open("/dev/urandom", O_RDONLY);
if (fd != -1) {
- read(fd, rdat.rnd, sizeof(rdat.rnd));
+ read(fd, rnd, sizeof(rnd));
close(fd);
}
-#ifdef __ARC4RANDOM_USE_ERANDOM__
+ /* Did the pseudo-random device fail? Use gettimeofday(). */
+ else
+#endif
+ if (gettimeofday(&tv, NULL) != (-1)) {
+
+ /* Initialize the first element so it's hopefully not '0',
+ * to help out the next loop. Tossing in some prime numbers
+ * probably can't hurt. */
+ rnd[0] = (tv.tv_sec % 10000) * 3 + tv.tv_usec * 7 + \
+ (getpid() % 1000) * 13;
+
+ for (n = 1; n < 127 ; n++) {
+
+ /* Take advantage of the stack space. Only initialize
+ * elements equal to '0'. This will make the rnd[]
+ * array much less vulnerable to timing attacks. Here
+ * we'll stir getpid() into the value of the previous
+ * element. Approximately 1 in 128 elements will still
+ * become '0'. */
+
+ if (rnd[n] == 0) {
+ rnd[n] = ((rnd[n - 1] + n) ^ \
+ ((getpid() % 1000) * 17));
+ }
+ }
+ }
else {
- int mib[3];
- uint i;
- size_t len;
-
- /* Device could not be opened, we might be chrooted, take
- * randomness from sysctl. */
-
- mib[0] = CTL_KERN;
- mib[1] = KERN_RANDOM;
- mib[2] = RANDOM_ERANDOM;
-
- for (i = 0; i < sizeof(rdat.rnd) / sizeof(uint); i++) {
- len = sizeof(uint);
- if (sysctl(mib, 3, &rdat.rnd[i], &len, NULL, 0) == -1)
- break;
+ /* gettimeofday() failed? Do the same thing as above, but only
+ * with getpid(). */
+
+ rnd[0] = (getpid() % 1000) * 19;
+ for (n = 1; n < 127 ; n++) {
+ if (rnd[n] == 0) {
+ rnd[n] = ((rnd[n - 1] + n) ^ \
+ ((getpid() % 1000) * 23));
+ }
}
}
-#endif
- arc4_addrandom(as, (void *) &rdat, sizeof(rdat));
+ arc4_stir_pid = getpid();
+ arc4_addrandom(as, rnd, sizeof(rnd));
/*
- * Throw away the first N words of output, as suggested in the
- * paper "Weaknesses in the Key Scheduling Algorithm of RC4"
- * by Fluher, Mantin, and Shamir.
+ * Discard early keystream, as per recommendations in:
* http://www.wisdom.weizmann.ac.il/~itsik/RC4/Papers/Rc4_ksa.ps
- * N = 256 in our case.
*/
- for (n = 0; n < 256 * 4; n++)
- arc4_getbyte(as);
+ for (n = 0; n < 256; n++)
+ (void)arc4_getbyte(as);
+ arc4_count = 1600000;
}
-static __inline__ uint8_t
-arc4_getbyte(as)
- struct arc4_stream *as;
+#if 0
+static void __arc4random_stir(void);
+/*
+ * __arc4_getbyte() is a libc private function intended for use
+ * with malloc.
+ */
+u_int8_t
+__arc4_getbyte(void)
{
- uint8_t si, sj;
-
- as->i = (as->i + 1);
- si = as->s[as->i];
- as->j = (as->j + si);
- sj = as->s[as->j];
- as->s[as->i] = sj;
- as->s[as->j] = si;
- return (as->s[(si + sj) & 0xff]);
+ if (--arc4_count == 0 || !rs_initialized)
+ __arc4random_stir();
+ return arc4_getbyte(&rs);
}
+#endif
-static __inline__ uint32_t
-arc4_getword(as)
- struct arc4_stream *as;
+static __inline__ u_int32_t
+arc4_getword(struct arc4_stream *as)
{
- uint32_t val;
+ u_int32_t val;
val = arc4_getbyte(as) << 24;
val |= arc4_getbyte(as) << 16;
val |= arc4_getbyte(as) << 8;
@@ -168,9 +186,8 @@ arc4_getword(as)
return val;
}
-libc_hidden_proto(arc4random_stir)
-void
-arc4random_stir(void)
+static void
+__arc4random_stir(void)
{
if (!rs_initialized) {
arc4_init(&rs);
@@ -178,33 +195,21 @@ arc4random_stir(void)
}
arc4_stir(&rs);
}
-libc_hidden_def(arc4random_stir)
+strong_alias(__arc4random_stir,arc4random_stir)
void
arc4random_addrandom(u_char *dat, int datlen)
{
if (!rs_initialized)
- arc4random_stir();
+ __arc4random_stir();
arc4_addrandom(&rs, dat, datlen);
}
-uint32_t
+u_int32_t
arc4random(void)
{
- if (!rs_initialized)
- arc4random_stir();
+ arc4_count -= 4;
+ if (arc4_count <= 0 || !rs_initialized || arc4_stir_pid != getpid())
+ __arc4random_stir();
return arc4_getword(&rs);
}
-
-#if 0
-/*-------- Test code --------*/
-#include <stdlib.h>
-#include <stdio.h>
-
-int main(void) {
- int random_number;
- random_number = arc4random() % 65536;
- printf("%d\n", random_number);
- return 0;
-}
-#endif
diff --git a/libc/stdlib/bsd_getpt.c b/libc/stdlib/bsd_getpt.c
index 1afd57f47..289748617 100644
--- a/libc/stdlib/bsd_getpt.c
+++ b/libc/stdlib/bsd_getpt.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 <fcntl.h>
@@ -23,8 +22,6 @@
#include <unistd.h>
#if defined __USE_BSD
-libc_hidden_proto(open)
-/* Experimentally off - libc_hidden_proto(mempcpy) */
/* Prefix for master pseudo terminal nodes. */
#define _PATH_PTY "/dev/pty"
@@ -42,7 +39,7 @@ const char __libc_ptyname1[] attribute_hidden = PTYNAME1;
const char __libc_ptyname2[] attribute_hidden = PTYNAME2;
/* Open a master pseudo terminal and return its file descriptor. */
-int
+static __inline__ int
__getpt (void)
{
char buf[sizeof (_PATH_PTY) + 2];
diff --git a/libc/stdlib/canonicalize.c b/libc/stdlib/canonicalize.c
new file mode 100644
index 000000000..da09d5841
--- /dev/null
+++ b/libc/stdlib/canonicalize.c
@@ -0,0 +1,19 @@
+/*
+ * canonicalize.c -- Return a malloc'd string containing the canonical
+ * absolute name of the named file. The last file name component need
+ * not exist, and may be a symlink to a nonexistent file.
+ * Copyright (C) 2009 STMicroelectronics
+ * Author: Salvatore Cro <salvatore.cro@st.com>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <stdlib.h>
+
+#ifdef __USE_GNU
+
+char * canonicalize_file_name (const char *name)
+{
+ return realpath (name, NULL);
+}
+#endif
diff --git a/libc/stdlib/drand48-iter.c b/libc/stdlib/drand48-iter.c
index 221cbe08f..b4b7b33b0 100644
--- a/libc/stdlib/drand48-iter.c
+++ b/libc/stdlib/drand48-iter.c
@@ -13,23 +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/>. */
#include <errno.h>
#include <stdlib.h>
#include <limits.h>
#include <stdint.h>
+#include <stdlib.h>
#include <sys/types.h>
/* Global state for non-reentrant functions. */
-struct drand48_data __libc_drand48_data attribute_hidden;
+struct drand48_data __libc_drand48_data;
#ifdef __UCLIBC_MJN3_ONLY__
#warning turn int __drand48_iterate into void
#endif /* __UCLIBC_MJN3_ONLY__ */
-int __drand48_iterate (unsigned short int xsubi[3], struct drand48_data *buffer) attribute_hidden;
int __drand48_iterate (unsigned short int xsubi[3], struct drand48_data *buffer)
{
uint64_t X;
diff --git a/libc/stdlib/drand48.c b/libc/stdlib/drand48.c
index f96947cb2..1e3684fb5 100644
--- a/libc/stdlib/drand48.c
+++ b/libc/stdlib/drand48.c
@@ -13,17 +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/>. */
#include <stdlib.h>
-libc_hidden_proto(erand48_r)
-
-/* Global state for non-reentrant functions. Defined in drand48-iter.c. */
-extern struct drand48_data __libc_drand48_data attribute_hidden;
-
double drand48 (void)
{
double result;
diff --git a/libc/stdlib/drand48_r.c b/libc/stdlib/drand48_r.c
index 1000a3acb..6413434c9 100644
--- a/libc/stdlib/drand48_r.c
+++ b/libc/stdlib/drand48_r.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 <math.h>
#include <stdlib.h>
-libc_hidden_proto(erand48_r)
int drand48_r (struct drand48_data *buffer, double *result)
{
diff --git a/libc/stdlib/erand48.c b/libc/stdlib/erand48.c
index 853c2c35a..d0d313039 100644
--- a/libc/stdlib/erand48.c
+++ b/libc/stdlib/erand48.c
@@ -13,17 +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/>. */
#include <stdlib.h>
-libc_hidden_proto(erand48_r)
-
-/* Global state for non-reentrant functions. Defined in drand48-iter.c. */
-extern struct drand48_data __libc_drand48_data attribute_hidden;
-
double erand48 (unsigned short int xsubi[3])
{
double result;
diff --git a/libc/stdlib/erand48_r.c b/libc/stdlib/erand48_r.c
index 42db6f74b..9c1ce1d3c 100644
--- a/libc/stdlib/erand48_r.c
+++ b/libc/stdlib/erand48_r.c
@@ -13,18 +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 <ieee754.h>
#include <stdlib.h>
#include <limits.h>
-extern int __drand48_iterate(unsigned short xsubi[3],
- struct drand48_data *buffer) attribute_hidden;
-
-libc_hidden_proto(erand48_r)
int erand48_r (unsigned short int xsubi[3], struct drand48_data *buffer, double *result)
{
union ieee754_double temp;
diff --git a/libc/stdlib/gcvt.c b/libc/stdlib/gcvt.c
index f1c1f4270..3c27b62c4 100644
--- a/libc/stdlib/gcvt.c
+++ b/libc/stdlib/gcvt.c
@@ -1,7 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
-libc_hidden_proto(sprintf)
#ifdef __UCLIBC_HAS_FLOATS__
#define MAX_NDIGIT 17
diff --git a/libc/stdlib/getenv.c b/libc/stdlib/getenv.c
index 7b3df7e64..9b04d0fab 100644
--- a/libc/stdlib/getenv.c
+++ b/libc/stdlib/getenv.c
@@ -8,9 +8,6 @@
#include <unistd.h>
#include <stdlib.h>
-libc_hidden_proto(getenv)
-/* Experimentally off - libc_hidden_proto(memcmp) */
-/* Experimentally off - libc_hidden_proto(strlen) */
/* IEEE Std 1003.1-2001 says getenv need not be thread safe, so
* don't bother locking access to __environ */
@@ -30,4 +27,4 @@ char *getenv(const char *var)
}
return NULL;
}
-libc_hidden_def(getenv)
+libc_hidden_weak(getenv)
diff --git a/libc/stdlib/getpt.c b/libc/stdlib/getpt.c
index 3033a13aa..a46e084a7 100644
--- a/libc/stdlib/getpt.c
+++ b/libc/stdlib/getpt.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 <fcntl.h>
@@ -26,10 +25,7 @@
#include <sys/statfs.h>
extern __typeof(statfs) __libc_statfs;
-libc_hidden_proto(__libc_statfs)
-libc_hidden_proto(open)
-libc_hidden_proto(close)
#if !defined __ASSUME_DEVPTS__
@@ -46,12 +42,12 @@ libc_hidden_proto(close)
#if !defined __UNIX98PTY_ONLY__ && defined __UCLIBC_HAS_GETPT__
/* Prototype for function that opens BSD-style master pseudo-terminals. */
-extern int __bsd_getpt (void) attribute_hidden;
+static __inline__ int __bsd_getpt (void);
#endif
/* Open a master pseudo terminal and return its file descriptor. */
-int
-posix_openpt (int flags)
+static int
+__posix_openpt (int flags)
{
#define have_no_dev_ptmx (1<<0)
#define devpts_mounted (1<<1)
@@ -74,14 +70,19 @@ posix_openpt (int flags)
/* Check that the /dev/pts filesystem is mounted
or if /dev is a devfs filesystem (this implies /dev/pts). */
- if ((_state & devpts_mounted)
- || (__libc_statfs (_PATH_DEVPTS, &fsbuf) == 0
+ if (
+#if !defined __UNIX98PTY_ONLY__
+ (_state & devpts_mounted) ||
+#endif
+ (__libc_statfs (_PATH_DEVPTS, &fsbuf) == 0
&& fsbuf.f_type == DEVPTS_SUPER_MAGIC)
|| (__libc_statfs (_PATH_DEV, &fsbuf) == 0
&& fsbuf.f_type == DEVFS_SUPER_MAGIC))
{
/* Everything is ok. */
+#if !defined __UNIX98PTY_ONLY__
_state |= devpts_mounted;
+#endif
return fd;
}
@@ -103,25 +104,24 @@ posix_openpt (int flags)
return -1;
}
}
+#if !defined __UNIX98PTY_ONLY__ && defined __UCLIBC_HAS_GETPT__
+ /* If we have no ptmx then ignore flags and use the fallback. */
+ if (_state & have_no_dev_ptmx)
+ return __bsd_getpt();
+#endif
return -1;
}
-libc_hidden_def(posix_openpt)
+strong_alias(__posix_openpt,posix_openpt)
#undef have_no_dev_ptmx
#undef devpts_mounted
#if defined __USE_GNU && defined __UCLIBC_HAS_GETPT__
-int
-getpt (void)
+int getpt (void)
{
- int fd = posix_openpt(O_RDWR);
-#if !defined __UNIX98PTY_ONLY__
- if (fd == -1)
- fd = __bsd_getpt();
-#endif
- return fd;
+ return __posix_openpt(O_RDWR);
}
-#if !defined __UNIX98PTY_ONLY__
+#if !defined __UNIX98PTY_ONLY__ && defined __UCLIBC_HAS_GETPT__
# define PTYNAME1 "pqrstuvwxyzabcde";
# define PTYNAME2 "0123456789abcdef";
diff --git a/libc/stdlib/grantpt.c b/libc/stdlib/grantpt.c
index b60ffe7dc..f80f0946c 100644
--- a/libc/stdlib/grantpt.c
+++ b/libc/stdlib/grantpt.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/>. */
#include <limits.h>
#include <stdlib.h>
@@ -33,25 +32,18 @@
/* Prototype for function that changes ownership and access permission
for slave pseudo terminals that do not live on a `devpts'
filesystem. */
-int __unix_grantpt (int fd);
+static int __unix_grantpt (int fd);
/* Prototype for private function that gets the name of the slave
pseudo terminal in a safe way. */
static int pts_name (int fd, char **pts, size_t buf_len);
-
-#endif
+extern __typeof(statfs) __libc_statfs;
/* Change the ownership and access permission of the slave pseudo
terminal associated with the master pseudo terminal specified
by FD. */
-int
-#if !defined __ASSUME_DEVPTS__
-grantpt (int fd)
-#else
-grantpt (attribute_unused int fd)
-#endif
+int grantpt (int fd)
{
-#if !defined __ASSUME_DEVPTS__
struct statfs fsbuf;
char _buf[PATH_MAX];
char *buf = _buf;
@@ -59,18 +51,25 @@ grantpt (attribute_unused int fd)
if (pts_name (fd, &buf, sizeof (_buf)))
return -1;
- if (statfs (buf, &fsbuf) < 0)
+ if (__libc_statfs (buf, &fsbuf) < 0)
return -1;
/* If the slave pseudo terminal lives on a `devpts' filesystem, the
ownership and access permission are already set. */
if (fsbuf.f_type != DEVPTS_SUPER_MAGIC && fsbuf.f_type != DEVFS_SUPER_MAGIC)
- return __unix_grantpt (fd);
-#endif
+ return __unix_grantpt (fd);
+
return 0;
}
-#if !defined __ASSUME_DEVPTS__
# define grantpt __unix_grantpt
# include "unix_grantpt.c"
+
+#else
+
+int grantpt (attribute_unused int fd)
+{
+ return 0;
+}
+
#endif
diff --git a/libc/stdlib/jrand48.c b/libc/stdlib/jrand48.c
index 6f812068b..c18c28e0b 100644
--- a/libc/stdlib/jrand48.c
+++ b/libc/stdlib/jrand48.c
@@ -13,17 +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/>. */
#include <stdlib.h>
-libc_hidden_proto(jrand48_r)
-
-/* Global state for non-reentrant functions. Defined in drand48-iter.c. */
-extern struct drand48_data __libc_drand48_data attribute_hidden;
-
long int jrand48 (unsigned short int xsubi[3])
{
long int result;
diff --git a/libc/stdlib/jrand48_r.c b/libc/stdlib/jrand48_r.c
index fe77c3c38..e6d09ca17 100644
--- a/libc/stdlib/jrand48_r.c
+++ b/libc/stdlib/jrand48_r.c
@@ -13,16 +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/>. */
#include <stdlib.h>
-extern int __drand48_iterate(unsigned short xsubi[3],
- struct drand48_data *buffer) attribute_hidden;
-
-libc_hidden_proto(jrand48_r)
int jrand48_r (unsigned short int xsubi[3], struct drand48_data *buffer, long int *result)
{
/* Compute next state. */
diff --git a/libc/stdlib/l64a.c b/libc/stdlib/l64a.c
index a8b2d551e..6f2888a6d 100644
--- a/libc/stdlib/l64a.c
+++ b/libc/stdlib/l64a.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 <stdlib.h>
@@ -36,21 +35,21 @@ char * l64a (long int n)
{
unsigned long int m = (unsigned long int) n;
static char result[7];
- int cnt;
+ char *p;
/* The standard says that only 32 bits are used. */
- m &= 0xffffffff;
+ if (sizeof(m) != 4)
+ m &= 0xffffffff;
- if (m == 0ul)
- /* The value for N == 0 is defined to be the empty string. */
- return (char *) "";
-
- for (cnt = 0; m > 0ul; ++cnt)
+ /* The value for N == 0 is defined to be the empty string,
+ * this code provides that as well. */
+ p = result;
+ while (m)
{
- result[cnt] = conv_table[m & 0x3f];
+ *p++ = conv_table[m & 0x3f];
m >>= 6;
}
- result[cnt] = '\0';
+ *p = '\0';
return result;
}
diff --git a/libc/stdlib/lcong48.c b/libc/stdlib/lcong48.c
new file mode 100644
index 000000000..06cab6672
--- /dev/null
+++ b/libc/stdlib/lcong48.c
@@ -0,0 +1,29 @@
+/* vi: set sw=4 ts=4: */
+/* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. */
+
+#include <features.h>
+
+#if defined __USE_SVID || defined __USE_XOPEN
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+static int __lcong48_r (unsigned short int param[7], struct drand48_data *buffer)
+{
+ /* Store the given values. */
+ memcpy (buffer->__x, &param[0], sizeof (buffer->__x));
+ buffer->__a = ((uint64_t) param[5] << 32 | (uint32_t) param[4] << 16 | param[3]);
+ buffer->__c = param[6];
+ buffer->__init = 1;
+
+ return 0;
+}
+# ifdef __USE_MISC
+strong_alias(__lcong48_r,lcong48_r)
+# endif
+
+void lcong48 (unsigned short int param[7])
+{
+ (void) __lcong48_r (param, &__libc_drand48_data);
+}
+#endif
diff --git a/libc/stdlib/ldiv.c b/libc/stdlib/ldiv.c
index 88a877116..34ad8a37d 100644
--- a/libc/stdlib/ldiv.c
+++ b/libc/stdlib/ldiv.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 <stdlib.h>
diff --git a/libc/stdlib/lldiv.c b/libc/stdlib/lldiv.c
index ff670174c..166bd46e4 100644
--- a/libc/stdlib/lldiv.c
+++ b/libc/stdlib/lldiv.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 <stdlib.h>
diff --git a/libc/stdlib/lrand48.c b/libc/stdlib/lrand48.c
index 863951f07..a88ad6cc7 100644
--- a/libc/stdlib/lrand48.c
+++ b/libc/stdlib/lrand48.c
@@ -13,17 +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/>. */
#include <stdlib.h>
-libc_hidden_proto(nrand48_r)
-
-/* Global state for non-reentrant functions. Defined in drand48-iter.c. */
-extern struct drand48_data __libc_drand48_data attribute_hidden;
-
long int lrand48 (void)
{
long int result;
diff --git a/libc/stdlib/lrand48_r.c b/libc/stdlib/lrand48_r.c
index 277fb9ae3..09a9327b5 100644
--- a/libc/stdlib/lrand48_r.c
+++ b/libc/stdlib/lrand48_r.c
@@ -13,15 +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 <stdlib.h>
-libc_hidden_proto(nrand48_r)
-libc_hidden_proto(lrand48_r)
int lrand48_r (struct drand48_data *buffer, long int *result)
{
/* Be generous for the arguments, detect some errors. */
diff --git a/libc/stdlib/malloc-simple/Makefile.in b/libc/stdlib/malloc-simple/Makefile.in
index 51488ff58..c3ef4b73f 100644
--- a/libc/stdlib/malloc-simple/Makefile.in
+++ b/libc/stdlib/malloc-simple/Makefile.in
@@ -1,22 +1,26 @@
# 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.
#
+subdirs += libc/stdlib/malloc-simple
+
STDLIB_MALLOC_SIMPLE_DIR := $(top_srcdir)libc/stdlib/malloc-simple
STDLIB_MALLOC_SIMPLE_OUT := $(top_builddir)libc/stdlib/malloc-simple
-CSRC := $(notdir $(wildcard $(STDLIB_MALLOC_SIMPLE_DIR)/*.c))
-CSRC := $(filter-out alloc.c,$(CSRC))
+CSRC-y := $(notdir $(wildcard $(STDLIB_MALLOC_SIMPLE_DIR)/*.c))
+# multi source alloc.c
+CSRC- := alloc.c
+CSRC-y := $(filter-out $(CSRC-),$(CSRC-y))
-STDLIB_MALLOC_SIMPLE_SRC := $(patsubst %.c,$(STDLIB_MALLOC_SIMPLE_DIR)/%.c,$(CSRC))
-STDLIB_MALLOC_SIMPLE_OBJ := $(patsubst %.c,$(STDLIB_MALLOC_SIMPLE_OUT)/%.o,$(CSRC))
+STDLIB_MALLOC_SIMPLE_SRC := $(patsubst %.c,$(STDLIB_MALLOC_SIMPLE_DIR)/%.c,$(CSRC-y))
+STDLIB_MALLOC_SIMPLE_OBJ := $(patsubst %.c,$(STDLIB_MALLOC_SIMPLE_OUT)/%.o,$(CSRC-y))
libc-$(MALLOC_SIMPLE) += $(STDLIB_MALLOC_SIMPLE_OBJ)
-objclean-y += stdlib_malloc_simple_objclean
+objclean-y += CLEAN_libc/stdlib/malloc-simple
-stdlib_malloc_simple_objclean:
- $(RM) $(STDLIB_MALLOC_SIMPLE_OUT)/*.{o,os}
+CLEAN_libc/stdlib/malloc-simple:
+ $(do_rm) $(addprefix $(STDLIB_MALLOC_SIMPLE_OUT)/*., o os)
diff --git a/libc/stdlib/malloc-simple/alloc.c b/libc/stdlib/malloc-simple/alloc.c
index 13d4166a7..a3c068a5b 100644
--- a/libc/stdlib/malloc-simple/alloc.c
+++ b/libc/stdlib/malloc-simple/alloc.c
@@ -15,11 +15,9 @@
#include <string.h>
#include <errno.h>
#include <sys/mman.h>
+#include <malloc.h>
-/* Experimentally off - libc_hidden_proto(memcpy) */
-/*libc_hidden_proto(memset)*/
-libc_hidden_proto(mmap)
-libc_hidden_proto(munmap)
+extern int weak_function __libc_free_aligned(void *ptr) attribute_hidden;
#ifdef L_malloc
void *malloc(size_t size)
@@ -39,13 +37,15 @@ void *malloc(size_t size)
#ifdef __ARCH_USE_MMU__
# define MMAP_FLAGS MAP_PRIVATE | MAP_ANONYMOUS
#else
-# define MMAP_FLAGS MAP_SHARED | MAP_ANONYMOUS
+# define MMAP_FLAGS MAP_SHARED | MAP_ANONYMOUS | MAP_UNINITIALIZED
#endif
result = mmap((void *) 0, size + sizeof(size_t), PROT_READ | PROT_WRITE,
MMAP_FLAGS, 0, 0);
- if (result == MAP_FAILED)
+ if (result == MAP_FAILED) {
+ __set_errno(ENOMEM);
return 0;
+ }
* (size_t *) result = size;
return(result + sizeof(size_t));
}
@@ -63,11 +63,10 @@ void * calloc(size_t nmemb, size_t lsize)
__set_errno(ENOMEM);
return NULL;
}
- result=malloc(size);
-#if 0
- /* Standard unix mmap using /dev/zero clears memory so calloc
- * doesn't need to actually zero anything....
- */
+ result = malloc(size);
+
+#ifndef __ARCH_USE_MMU__
+ /* mmap'd with MAP_UNINITIALIZED, we have to blank memory ourselves */
if (result != NULL) {
memset(result, 0, size);
}
@@ -99,7 +98,6 @@ void *realloc(void *ptr, size_t size)
#endif
#ifdef L_free
-extern int weak_function __libc_free_aligned(void *ptr);
void free(void *ptr)
{
if (unlikely(ptr == NULL))
@@ -116,7 +114,7 @@ void free(void *ptr)
#ifdef L_memalign
#include <bits/uClibc_mutex.h>
-__UCLIBC_MUTEX_STATIC(__malloc_lock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP);
+__UCLIBC_MUTEX_INIT(__malloc_lock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP);
#define __MALLOC_LOCK __UCLIBC_MUTEX_LOCK(__malloc_lock)
#define __MALLOC_UNLOCK __UCLIBC_MUTEX_UNLOCK(__malloc_lock)
@@ -127,7 +125,7 @@ struct alignlist
__ptr_t aligned; /* The address that memaligned returned. */
__ptr_t exact; /* The address that malloc returned. */
};
-struct alignlist *_aligned_blocks;
+static struct alignlist *_aligned_blocks;
/* Return memory to the heap. */
int __libc_free_aligned(void *ptr)
@@ -186,4 +184,5 @@ DONE:
return result;
}
+libc_hidden_def(memalign)
#endif
diff --git a/libc/stdlib/malloc-standard/Makefile.in b/libc/stdlib/malloc-standard/Makefile.in
index 3bbe93e08..04a46b681 100644
--- a/libc/stdlib/malloc-standard/Makefile.in
+++ b/libc/stdlib/malloc-standard/Makefile.in
@@ -1,23 +1,23 @@
# 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.
#
-# calloc.c can be found at uClibc/libc/stdlib/calloc.c
-# valloc.c can be found at uClibc/libc/stdlib/valloc.c
-CSRC := malloc.c calloc.c realloc.c free.c memalign.c mallopt.c mallinfo.c
+subdirs += libc/stdlib/malloc-standard
STDLIB_MALLOC_STANDARD_DIR := $(top_srcdir)libc/stdlib/malloc-standard
STDLIB_MALLOC_STANDARD_OUT := $(top_builddir)libc/stdlib/malloc-standard
-STDLIB_MALLOC_STANDARD_SRC := $(patsubst %.c,$(STDLIB_MALLOC_STANDARD_DIR)/%.c,$(CSRC))
-STDLIB_MALLOC_STANDARD_OBJ := $(patsubst %.c,$(STDLIB_MALLOC_STANDARD_OUT)/%.o,$(CSRC))
+CSRC-y := $(notdir $(wildcard $(STDLIB_MALLOC_STANDARD_DIR)/*.c))
+
+STDLIB_MALLOC_STANDARD_SRC := $(patsubst %.c,$(STDLIB_MALLOC_STANDARD_DIR)/%.c,$(CSRC-y))
+STDLIB_MALLOC_STANDARD_OBJ := $(patsubst %.c,$(STDLIB_MALLOC_STANDARD_OUT)/%.o,$(CSRC-y))
libc-$(MALLOC_STANDARD) += $(STDLIB_MALLOC_STANDARD_OBJ)
-objclean-y += stdlib_malloc_standard_objclean
+objclean-y += CLEAN_libc/stdlib/malloc-standard
-stdlib_malloc_standard_objclean:
- $(RM) $(STDLIB_MALLOC_STANDARD_OUT)/*.{o,os}
+CLEAN_libc/stdlib/malloc-standard:
+ $(do_rm) $(addprefix $(STDLIB_MALLOC_STANDARD_OUT)/*., o os)
diff --git a/libc/stdlib/malloc-standard/calloc.c b/libc/stdlib/malloc-standard/calloc.c
index 80ba3d04a..a70516f0e 100644
--- a/libc/stdlib/malloc-standard/calloc.c
+++ b/libc/stdlib/malloc-standard/calloc.c
@@ -16,7 +16,6 @@
#include "malloc.h"
-/* Experimentally off - libc_hidden_proto(memset) */
/* ------------------------------ calloc ------------------------------ */
void* calloc(size_t n_elements, size_t elem_size)
diff --git a/libc/stdlib/malloc-standard/free.c b/libc/stdlib/malloc-standard/free.c
index 4d24697be..8b7a81fca 100644
--- a/libc/stdlib/malloc-standard/free.c
+++ b/libc/stdlib/malloc-standard/free.c
@@ -16,7 +16,6 @@
#include "malloc.h"
-libc_hidden_proto(munmap)
/* ------------------------- __malloc_trim -------------------------
__malloc_trim is an inverse of sorts to __malloc_alloc. It gives memory
@@ -105,9 +104,13 @@ static int __malloc_trim(size_t pad, mstate av)
*/
int malloc_trim(size_t pad)
{
+ int r;
+ __MALLOC_LOCK;
mstate av = get_malloc_state();
__malloc_consolidate(av);
- return __malloc_trim(pad, av);
+ r = __malloc_trim(pad, av);
+ __MALLOC_UNLOCK;
+ return r;
}
/*
diff --git a/libc/stdlib/malloc-standard/mallinfo.c b/libc/stdlib/malloc-standard/mallinfo.c
index 18331010a..dbe4d49b8 100644
--- a/libc/stdlib/malloc-standard/mallinfo.c
+++ b/libc/stdlib/malloc-standard/mallinfo.c
@@ -15,11 +15,10 @@
*/
#include "malloc.h"
+#include <stdio.h> /* fprintf */
-libc_hidden_proto(fprintf)
/* ------------------------------ mallinfo ------------------------------ */
-libc_hidden_proto(mallinfo)
struct mallinfo mallinfo(void)
{
mstate av;
@@ -82,16 +81,12 @@ struct mallinfo mallinfo(void)
}
libc_hidden_def(mallinfo)
-void malloc_stats(FILE *file)
+void malloc_stats(void)
{
struct mallinfo mi;
- if (file==NULL) {
- file = stderr;
- }
-
mi = mallinfo();
- fprintf(file,
+ fprintf(stderr,
"total bytes allocated = %10u\n"
"total bytes in use bytes = %10u\n"
"total non-mmapped bytes allocated = %10d\n"
diff --git a/libc/stdlib/malloc-standard/malloc.c b/libc/stdlib/malloc-standard/malloc.c
index 3253ebda6..fd33b50c7 100644
--- a/libc/stdlib/malloc-standard/malloc.c
+++ b/libc/stdlib/malloc-standard/malloc.c
@@ -744,7 +744,7 @@ static void* __malloc_alloc(size_t nb, mstate av)
}
/* catch all failure paths */
- errno = ENOMEM;
+ __set_errno(ENOMEM);
return 0;
}
@@ -832,8 +832,6 @@ void* malloc(size_t bytes)
}
#endif
- __MALLOC_LOCK;
- av = get_malloc_state();
/*
Convert request size to internal form by adding (sizeof(size_t)) bytes
overhead plus possibly more to obtain necessary alignment and/or
@@ -845,6 +843,9 @@ void* malloc(size_t bytes)
checked_request2size(bytes, nb);
+ __MALLOC_LOCK;
+ av = get_malloc_state();
+
/*
Bypass search if no frees yet
*/
diff --git a/libc/stdlib/malloc-standard/malloc.h b/libc/stdlib/malloc-standard/malloc.h
index e0f3658b7..1a4cc5a62 100644
--- a/libc/stdlib/malloc-standard/malloc.h
+++ b/libc/stdlib/malloc-standard/malloc.h
@@ -24,13 +24,13 @@
#include <sys/mman.h>
#include <bits/uClibc_mutex.h>
-libc_hidden_proto(mmap)
-libc_hidden_proto(sysconf)
-libc_hidden_proto(sbrk)
-libc_hidden_proto(abort)
-__UCLIBC_MUTEX_EXTERN(__malloc_lock);
+__UCLIBC_MUTEX_EXTERN(__malloc_lock)
+#if defined __UCLIBC_HAS_THREADS__ && !defined __LINUXTHREADS_OLD__
+ attribute_hidden
+#endif
+ ;
#define __MALLOC_LOCK __UCLIBC_MUTEX_LOCK(__malloc_lock)
#define __MALLOC_UNLOCK __UCLIBC_MUTEX_UNLOCK(__malloc_lock)
@@ -353,16 +353,13 @@ __UCLIBC_MUTEX_EXTERN(__malloc_lock);
#endif
#ifdef __ARCH_USE_MMU__
-
-#define MMAP(addr, size, prot) \
- (mmap((addr), (size), (prot), MAP_PRIVATE|MAP_ANONYMOUS, 0, 0))
-
+# define _MAP_UNINITIALIZED 0
#else
+# define _MAP_UNINITIALIZED MAP_UNINITIALIZED
+#endif
#define MMAP(addr, size, prot) \
- (mmap((addr), (size), (prot), MAP_SHARED|MAP_ANONYMOUS, 0, 0))
-
-#endif
+ (mmap((addr), (size), (prot), MAP_PRIVATE|MAP_ANONYMOUS|_MAP_UNINITIALIZED, 0, 0))
/* ----------------------- Chunk representations ----------------------- */
@@ -515,7 +512,7 @@ nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
#define checked_request2size(req, sz) \
if (REQUEST_OUT_OF_RANGE(req)) { \
- errno = ENOMEM; \
+ __set_errno(ENOMEM); \
return 0; \
} \
(sz) = request2size(req);
@@ -917,7 +914,7 @@ typedef struct malloc_state *mstate;
malloc relies on the property that malloc_state is initialized to
all zeroes (as is true of C statics).
*/
-extern struct malloc_state __malloc_state; /* never directly referenced */
+extern struct malloc_state __malloc_state attribute_hidden; /* never directly referenced */
/*
All uses of av_ are via get_malloc_state().
@@ -954,12 +951,12 @@ void __malloc_consolidate(mstate) attribute_hidden;
#define check_malloced_chunk(P,N) __do_check_malloced_chunk(P,N)
#define check_malloc_state() __do_check_malloc_state()
-extern void __do_check_chunk(mchunkptr p);
-extern void __do_check_free_chunk(mchunkptr p);
-extern void __do_check_inuse_chunk(mchunkptr p);
-extern void __do_check_remalloced_chunk(mchunkptr p, size_t s);
-extern void __do_check_malloced_chunk(mchunkptr p, size_t s);
-extern void __do_check_malloc_state(void);
+extern void __do_check_chunk(mchunkptr p) attribute_hidden;
+extern void __do_check_free_chunk(mchunkptr p) attribute_hidden;
+extern void __do_check_inuse_chunk(mchunkptr p) attribute_hidden;
+extern void __do_check_remalloced_chunk(mchunkptr p, size_t s) attribute_hidden;
+extern void __do_check_malloced_chunk(mchunkptr p, size_t s) attribute_hidden;
+extern void __do_check_malloc_state(void) attribute_hidden;
#include <assert.h>
diff --git a/libc/stdlib/malloc-standard/memalign.c b/libc/stdlib/malloc-standard/memalign.c
index 7e0674be5..e9ae5a7b9 100644
--- a/libc/stdlib/malloc-standard/memalign.c
+++ b/libc/stdlib/malloc-standard/memalign.c
@@ -52,8 +52,8 @@ void* memalign(size_t alignment, size_t bytes)
alignment = a;
}
- __MALLOC_LOCK;
checked_request2size(bytes, nb);
+ __MALLOC_LOCK;
/* Strategy: find a spot within that chunk that meets the alignment
* request, and then possibly free the leading and trailing space. */
@@ -127,4 +127,4 @@ void* memalign(size_t alignment, size_t bytes)
__MALLOC_UNLOCK;
return retval;
}
-
+libc_hidden_def(memalign)
diff --git a/libc/stdlib/malloc-standard/realloc.c b/libc/stdlib/malloc-standard/realloc.c
index 41cae43d1..e49d11125 100644
--- a/libc/stdlib/malloc-standard/realloc.c
+++ b/libc/stdlib/malloc-standard/realloc.c
@@ -16,8 +16,6 @@
#include "malloc.h"
-libc_hidden_proto(mremap)
-/* Experimentally off - libc_hidden_proto(memcpy) */
/* ------------------------------ realloc ------------------------------ */
void* realloc(void* oldmem, size_t bytes)
@@ -56,9 +54,9 @@ void* realloc(void* oldmem, size_t bytes)
return NULL;
}
+ checked_request2size(bytes, nb);
__MALLOC_LOCK;
av = get_malloc_state();
- checked_request2size(bytes, nb);
oldp = mem2chunk(oldmem);
oldsize = chunksize(oldp);
diff --git a/libc/stdlib/malloc/Makefile.in b/libc/stdlib/malloc/Makefile.in
index 73e0d6419..9efd34e8b 100644
--- a/libc/stdlib/malloc/Makefile.in
+++ b/libc/stdlib/malloc/Makefile.in
@@ -2,17 +2,19 @@
#
# Copyright (C) 2002-2003 NEC Electronics Corporation
# Copyright (C) 2002-2003 Miles Bader <miles@gnu.org>
-# 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.
#
-CSRC := malloc.c calloc.c free.c realloc.c memalign.c \
+subdirs += libc/stdlib/malloc
+
+CSRC-y := malloc.c calloc.c free.c realloc.c memalign.c \
heap_alloc.c heap_alloc_at.c heap_free.c
# Turn on malloc debugging if requested
+CSRC-$(UCLIBC_MALLOC_DEBUGGING) += malloc_debug.c heap_debug.c
ifeq ($(UCLIBC_MALLOC_DEBUGGING),y)
-CSRC += malloc_debug.c heap_debug.c
CFLAGS += -DMALLOC_DEBUGGING -DHEAP_DEBUGGING
ifeq ($(UCLIBC_UCLINUX_BROKEN_MUNMAP),y)
CFLAGS += -DMALLOC_MMB_DEBUGGING
@@ -22,15 +24,15 @@ endif
STDLIB_MALLOC_DIR := $(top_srcdir)libc/stdlib/malloc
STDLIB_MALLOC_OUT := $(top_builddir)libc/stdlib/malloc
-STDLIB_MALLOC_SRC := $(patsubst %.c,$(STDLIB_MALLOC_DIR)/%.c,$(CSRC))
-STDLIB_MALLOC_OBJ := $(patsubst %.c,$(STDLIB_MALLOC_OUT)/%.o,$(CSRC))
+STDLIB_MALLOC_SRC := $(patsubst %.c,$(STDLIB_MALLOC_DIR)/%.c,$(CSRC-y))
+STDLIB_MALLOC_OBJ := $(patsubst %.c,$(STDLIB_MALLOC_OUT)/%.o,$(CSRC-y))
libc-$(MALLOC) += $(STDLIB_MALLOC_OBJ)
-objclean-y += stdlib_malloc_objclean
+objclean-y += CLEAN_libc/stdlib/malloc
-stdlib_malloc_objclean:
- $(RM) $(STDLIB_MALLOC_OUT)/*.{o,os}
+CLEAN_libc/stdlib/malloc:
+ $(do_rm) $(addprefix $(STDLIB_MALLOC_OUT)/*., o os)
malloc.o free.o realloc.o memalign.o: malloc.h
# Depend on uClinux_config.h to cache changes in __UCLIBC_MALLOC_DEBUGGING__
diff --git a/libc/stdlib/malloc/calloc.c b/libc/stdlib/malloc/calloc.c
index 79e6ec6c7..2b315dbc8 100644
--- a/libc/stdlib/malloc/calloc.c
+++ b/libc/stdlib/malloc/calloc.c
@@ -14,15 +14,14 @@
* 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 <stdlib.h>
#include <string.h>
#include <errno.h>
-/* Experimentally off - libc_hidden_proto(memset) */
void * calloc(size_t nmemb, size_t lsize)
{
diff --git a/libc/stdlib/malloc/free.c b/libc/stdlib/malloc/free.c
index da395331b..14d110153 100644
--- a/libc/stdlib/malloc/free.c
+++ b/libc/stdlib/malloc/free.c
@@ -15,14 +15,22 @@
#include <unistd.h>
#include <sys/mman.h>
-libc_hidden_proto(munmap)
-libc_hidden_proto(sbrk)
#include "malloc.h"
#include "heap.h"
+#ifdef HEAP_USE_LOCKING
+#define free_to_heap(mem, heap, lck) __free_to_heap(mem, heap, lck)
+#else
+#define free_to_heap(mem, heap, lck) __free_to_heap(mem, heap)
+#endif
+
static void
-free_to_heap (void *mem, struct heap *heap)
+__free_to_heap (void *mem, struct heap_free_area **heap
+#ifdef HEAP_USE_LOCKING
+ , __UCLIBC_MUTEX_TYPE *heap_lock
+#endif
+ )
{
size_t size;
struct heap_free_area *fa;
@@ -39,7 +47,7 @@ free_to_heap (void *mem, struct heap *heap)
size = MALLOC_SIZE (mem);
mem = MALLOC_BASE (mem);
- __heap_lock (heap);
+ __heap_lock (heap_lock);
/* Put MEM back in the heap, and get the free-area it was placed in. */
fa = __heap_free (heap, mem, size);
@@ -48,7 +56,7 @@ free_to_heap (void *mem, struct heap *heap)
unmapped. */
if (HEAP_FREE_AREA_SIZE (fa) < MALLOC_UNMAP_THRESHOLD)
/* Nope, nothing left to do, just release the lock. */
- __heap_unlock (heap);
+ __heap_unlock (heap_lock);
else
/* Yup, try to unmap FA. */
{
@@ -81,7 +89,7 @@ free_to_heap (void *mem, struct heap *heap)
MALLOC_DEBUG (-1, "not unmapping: 0x%lx - 0x%lx (%ld bytes)",
start, end, end - start);
__malloc_unlock_sbrk ();
- __heap_unlock (heap);
+ __heap_unlock (heap_lock);
return;
}
#endif
@@ -98,7 +106,7 @@ free_to_heap (void *mem, struct heap *heap)
another free area, even if it's smaller than
MALLOC_MIN_SIZE, will cause us not to reserve anything. */
{
- /* Put the reserved memory back in the heap; we asssume that
+ /* Put the reserved memory back in the heap; we assume that
MALLOC_UNMAP_THRESHOLD is greater than MALLOC_MIN_SIZE, so
we use the latter unconditionally here. */
__heap_free (heap, (void *)start, MALLOC_MIN_SIZE);
@@ -108,7 +116,7 @@ free_to_heap (void *mem, struct heap *heap)
#ifdef MALLOC_USE_SBRK
/* Release the heap lock; we're still holding the sbrk lock. */
- __heap_unlock (heap);
+ __heap_unlock (heap_lock);
/* Lower the brk. */
sbrk (start - end);
/* Release the sbrk lock too; now we hold no locks. */
@@ -169,18 +177,18 @@ free_to_heap (void *mem, struct heap *heap)
/* Start searching again from the end of this block. */
start = mmb_end;
+ /* Release the descriptor block we used. */
+ free_to_heap (mmb, &__malloc_mmb_heap, &__malloc_mmb_heap_lock);
+
/* We have to unlock the heap before we recurse to free the mmb
descriptor, because we might be unmapping from the mmb
heap. */
- __heap_unlock (heap);
-
- /* Release the descriptor block we used. */
- free_to_heap (mmb, &__malloc_mmb_heap);
+ __heap_unlock (heap_lock);
/* Do the actual munmap. */
munmap ((void *)mmb_start, mmb_end - mmb_start);
- __heap_lock (heap);
+ __heap_lock (heap_lock);
# ifdef __UCLIBC_HAS_THREADS__
/* In a multi-threaded program, it's possible that PREV_MMB has
@@ -213,7 +221,7 @@ free_to_heap (void *mem, struct heap *heap)
}
/* Finally release the lock for good. */
- __heap_unlock (heap);
+ __heap_unlock (heap_lock);
MALLOC_MMB_DEBUG_INDENT (-1);
@@ -243,7 +251,7 @@ free_to_heap (void *mem, struct heap *heap)
}
/* Release the heap lock before we do the system call. */
- __heap_unlock (heap);
+ __heap_unlock (heap_lock);
if (unmap_end > unmap_start)
/* Finally, actually unmap the memory. */
@@ -260,5 +268,5 @@ free_to_heap (void *mem, struct heap *heap)
void
free (void *mem)
{
- free_to_heap (mem, &__malloc_heap);
+ free_to_heap (mem, &__malloc_heap, &__malloc_heap_lock);
}
diff --git a/libc/stdlib/malloc/heap.h b/libc/stdlib/malloc/heap.h
index 6505cd223..11bd49ffe 100644
--- a/libc/stdlib/malloc/heap.h
+++ b/libc/stdlib/malloc/heap.h
@@ -13,48 +13,27 @@
#include <features.h>
-
-/* On multi-threaded systems, the heap includes a lock. */
+#include <bits/uClibc_mutex.h>
#ifdef __UCLIBC_HAS_THREADS__
-# include <pthread.h>
-# include <bits/uClibc_pthread.h>
# define HEAP_USE_LOCKING
#endif
+#define __heap_lock(heap_lock) __UCLIBC_MUTEX_LOCK_CANCEL_UNSAFE(*(heap_lock))
+#define __heap_unlock(heap_lock) __UCLIBC_MUTEX_UNLOCK_CANCEL_UNSAFE(*(heap_lock))
/* The heap allocates in multiples of, and aligned to, HEAP_GRANULARITY.
HEAP_GRANULARITY must be a power of 2. Malloc depends on this being the
same as MALLOC_ALIGNMENT. */
-#define HEAP_GRANULARITY_TYPE double __attribute_aligned__ (sizeof (size_t))
-#define HEAP_GRANULARITY (__alignof__ (HEAP_GRANULARITY_TYPE))
+#define HEAP_GRANULARITY_TYPE double __attribute_aligned__ (HEAP_GRANULARITY)
+#define HEAP_GRANULARITY \
+ (__alignof__ (double) > sizeof (size_t) ? __alignof__ (double) : sizeof (size_t))
-/* A heap is a collection of memory blocks, from which smaller blocks
- of memory can be allocated. */
-struct heap
-{
- /* A list of memory in the heap available for allocation. */
- struct heap_free_area *free_areas;
-
-#ifdef HEAP_USE_LOCKING
- /* A lock that can be used by callers to control access to the heap.
- The heap code _does not_ use this lock, it's merely here for the
- convenience of users! */
- pthread_mutex_t lock;
-#endif
-};
-/* The HEAP_INIT macro can be used as a static initializer for a heap
- variable. The HEAP_INIT_WITH_FA variant is used to initialize a heap
+/* The HEAP_INIT_WITH_FA variant is used to initialize a heap
with an initial static free-area; its argument FA should be declared
using HEAP_DECLARE_STATIC_FREE_AREA. */
-#ifdef HEAP_USE_LOCKING
-# define HEAP_INIT { 0, PTHREAD_MUTEX_INITIALIZER }
-# define HEAP_INIT_WITH_FA(fa) { &fa._fa, PTHREAD_MUTEX_INITIALIZER }
-#else
-# define HEAP_INIT { 0 }
-# define HEAP_INIT_WITH_FA(fa) { &fa._fa }
-#endif
+# define HEAP_INIT_WITH_FA(fa) &fa._fa
/* A free-list area `header'. These are actually stored at the _ends_ of
free areas (to make allocating from the beginning of the area simpler),
@@ -106,50 +85,33 @@ struct heap_free_area
#define HEAP_MIN_FREE_AREA_SIZE \
HEAP_ADJUST_SIZE (sizeof (struct heap_free_area) + 32)
-
-/* branch-prediction macros; they may already be defined by libc. */
-#ifndef likely
-#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
-#define likely(cond) __builtin_expect(!!(int)(cond), 1)
-#define unlikely(cond) __builtin_expect((int)(cond), 0)
-#else
-#define likely(cond) (cond)
-#define unlikely(cond) (cond)
-#endif
-#endif /* !likely */
-
-
/* Define HEAP_DEBUGGING to cause the heap routines to emit debugging info
to stderr when the variable __heap_debug is set to true. */
#ifdef HEAP_DEBUGGING
-extern int __heap_debug;
+extern int __heap_debug attribute_hidden;
#define HEAP_DEBUG(heap, str) (__heap_debug ? __heap_dump (heap, str) : 0)
#else
#define HEAP_DEBUG(heap, str) (void)0
#endif
/* Output a text representation of HEAP to stderr, labelling it with STR. */
-extern void __heap_dump (struct heap *heap, const char *str);
+extern void __heap_dump (struct heap_free_area *heap, const char *str) attribute_hidden;
/* Do some consistency checks on HEAP. If they fail, output an error
message to stderr, and exit. STR is printed with the failure message. */
-extern void __heap_check (struct heap *heap, const char *str);
-
-
-#define __heap_lock(heap) __pthread_mutex_lock (&(heap)->lock)
-#define __heap_unlock(heap) __pthread_mutex_unlock (&(heap)->lock)
+extern void __heap_check (struct heap_free_area *heap, const char *str) attribute_hidden;
/* Delete the free-area FA from HEAP. */
static __inline__ void
-__heap_delete (struct heap *heap, struct heap_free_area *fa)
+__heap_delete (struct heap_free_area **heap, struct heap_free_area *fa)
{
if (fa->next)
fa->next->prev = fa->prev;
if (fa->prev)
fa->prev->next = fa->next;
else
- heap->free_areas = fa->next;
+ *heap = fa->next;
}
@@ -157,7 +119,7 @@ __heap_delete (struct heap *heap, struct heap_free_area *fa)
HEAP. PREV and NEXT may be 0; if PREV is 0, FA is installed as the
first free-area. */
static __inline__ void
-__heap_link_free_area (struct heap *heap, struct heap_free_area *fa,
+__heap_link_free_area (struct heap_free_area **heap, struct heap_free_area *fa,
struct heap_free_area *prev,
struct heap_free_area *next)
{
@@ -167,7 +129,7 @@ __heap_link_free_area (struct heap *heap, struct heap_free_area *fa,
if (prev)
prev->next = fa;
else
- heap->free_areas = fa;
+ *heap = fa;
if (next)
next->prev = fa;
}
@@ -176,14 +138,14 @@ __heap_link_free_area (struct heap *heap, struct heap_free_area *fa,
PREV may be 0, in which case FA is installed as the first free-area (but
FA may not be 0). */
static __inline__ void
-__heap_link_free_area_after (struct heap *heap,
+__heap_link_free_area_after (struct heap_free_area **heap,
struct heap_free_area *fa,
struct heap_free_area *prev)
{
if (prev)
prev->next = fa;
else
- heap->free_areas = fa;
+ *heap = fa;
fa->prev = prev;
}
@@ -192,7 +154,7 @@ __heap_link_free_area_after (struct heap *heap,
PREV and NEXT may be 0; if PREV is 0, MEM is installed as the first
free-area. */
static __inline__ struct heap_free_area *
-__heap_add_free_area (struct heap *heap, void *mem, size_t size,
+__heap_add_free_area (struct heap_free_area **heap, void *mem, size_t size,
struct heap_free_area *prev,
struct heap_free_area *next)
{
@@ -210,7 +172,7 @@ __heap_add_free_area (struct heap *heap, void *mem, size_t size,
/* Allocate SIZE bytes from the front of the free-area FA in HEAP, and
return the amount actually allocated (which may be more than SIZE). */
static __inline__ size_t
-__heap_free_area_alloc (struct heap *heap,
+__heap_free_area_alloc (struct heap_free_area **heap,
struct heap_free_area *fa, size_t size)
{
size_t fa_size = fa->size;
@@ -234,16 +196,16 @@ __heap_free_area_alloc (struct heap *heap,
/* Allocate and return a block at least *SIZE bytes long from HEAP.
*SIZE is adjusted to reflect the actual amount allocated (which may be
greater than requested). */
-extern void *__heap_alloc (struct heap *heap, size_t *size);
+extern void *__heap_alloc (struct heap_free_area **heap, size_t *size) attribute_hidden;
/* Allocate SIZE bytes at address MEM in HEAP. Return the actual size
allocated, or 0 if we failed. */
-extern size_t __heap_alloc_at (struct heap *heap, void *mem, size_t size);
+extern size_t __heap_alloc_at (struct heap_free_area **heap, void *mem, size_t size) attribute_hidden;
/* Return the memory area MEM of size SIZE to HEAP.
Returns the heap free area into which the memory was placed. */
-extern struct heap_free_area *__heap_free (struct heap *heap,
- void *mem, size_t size);
+extern struct heap_free_area *__heap_free (struct heap_free_area **heap,
+ void *mem, size_t size) attribute_hidden;
/* Return true if HEAP contains absolutely no memory. */
-#define __heap_is_empty(heap) (! (heap)->free_areas)
+#define __heap_is_empty(heap) (! (heap))
diff --git a/libc/stdlib/malloc/heap_alloc.c b/libc/stdlib/malloc/heap_alloc.c
index 9f5fd6c1a..77b7d8560 100644
--- a/libc/stdlib/malloc/heap_alloc.c
+++ b/libc/stdlib/malloc/heap_alloc.c
@@ -20,7 +20,7 @@
*SIZE is adjusted to reflect the actual amount allocated (which may be
greater than requested). */
void *
-__heap_alloc (struct heap *heap, size_t *size)
+__heap_alloc (struct heap_free_area **heap, size_t *size)
{
struct heap_free_area *fa;
size_t _size = *size;
@@ -33,10 +33,10 @@ __heap_alloc (struct heap *heap, size_t *size)
we must make sure that every allocated block can hold one. */
_size = HEAP_ADJUST_SIZE (sizeof (struct heap_free_area));
- HEAP_DEBUG (heap, "before __heap_alloc");
+ HEAP_DEBUG (*heap, "before __heap_alloc");
/* Look for a free area that can contain _SIZE bytes. */
- for (fa = heap->free_areas; fa; fa = fa->next)
+ for (fa = *heap; fa; fa = fa->next)
if (fa->size >= _size)
{
/* Found one! */
@@ -45,7 +45,7 @@ __heap_alloc (struct heap *heap, size_t *size)
break;
}
- HEAP_DEBUG (heap, "after __heap_alloc");
+ HEAP_DEBUG (*heap, "after __heap_alloc");
return mem;
}
diff --git a/libc/stdlib/malloc/heap_alloc_at.c b/libc/stdlib/malloc/heap_alloc_at.c
index a65140fea..45d68598a 100644
--- a/libc/stdlib/malloc/heap_alloc_at.c
+++ b/libc/stdlib/malloc/heap_alloc_at.c
@@ -19,17 +19,17 @@
/* Allocate SIZE bytes at address MEM in HEAP. Return the actual size
allocated, or 0 if we failed. */
size_t
-__heap_alloc_at (struct heap *heap, void *mem, size_t size)
+__heap_alloc_at (struct heap_free_area **heap, void *mem, size_t size)
{
struct heap_free_area *fa;
size_t alloced = 0;
size = HEAP_ADJUST_SIZE (size);
- HEAP_DEBUG (heap, "before __heap_alloc_at");
+ HEAP_DEBUG (*heap, "before __heap_alloc_at");
/* Look for a free area that can contain SIZE bytes. */
- for (fa = heap->free_areas; fa; fa = fa->next)
+ for (fa = *heap; fa; fa = fa->next)
{
void *fa_mem = HEAP_FREE_AREA_START (fa);
if (fa_mem <= mem)
@@ -41,7 +41,7 @@ __heap_alloc_at (struct heap *heap, void *mem, size_t size)
}
}
- HEAP_DEBUG (heap, "after __heap_alloc_at");
+ HEAP_DEBUG (*heap, "after __heap_alloc_at");
return alloced;
}
diff --git a/libc/stdlib/malloc/heap_debug.c b/libc/stdlib/malloc/heap_debug.c
index a2a9f4ec1..5f17aae04 100644
--- a/libc/stdlib/malloc/heap_debug.c
+++ b/libc/stdlib/malloc/heap_debug.c
@@ -17,9 +17,6 @@
#include <string.h>
#include <unistd.h>
-libc_hidden_proto(vfprintf)
-libc_hidden_proto(fprintf)
-libc_hidden_proto(_exit)
#include "malloc.h"
#include "heap.h"
@@ -31,10 +28,10 @@ int __heap_debug = 0;
static void
-__heap_dump_freelist (struct heap *heap)
+__heap_dump_freelist (struct heap_free_area *heap)
{
struct heap_free_area *fa;
- for (fa = heap->free_areas; fa; fa = fa->next)
+ for (fa = heap; fa; fa = fa->next)
__malloc_debug_printf (0,
"0x%lx: 0x%lx - 0x%lx (%d)\tP=0x%lx, N=0x%lx",
(long)fa,
@@ -47,7 +44,7 @@ __heap_dump_freelist (struct heap *heap)
/* Output a text representation of HEAP to stderr, labelling it with STR. */
void
-__heap_dump (struct heap *heap, const char *str)
+__heap_dump (struct heap_free_area *heap, const char *str)
{
static smallint recursed;
@@ -69,7 +66,7 @@ __heap_dump (struct heap *heap, const char *str)
/* Output an error message to stderr, and exit. STR is printed with the
failure message. */
static void attribute_noreturn
-__heap_check_failure (struct heap *heap, struct heap_free_area *fa,
+__heap_check_failure (struct heap_free_area *heap, struct heap_free_area *fa,
const char *str, char *fmt, ...)
{
va_list val;
@@ -95,11 +92,11 @@ __heap_check_failure (struct heap *heap, struct heap_free_area *fa,
/* Do some consistency checks on HEAP. If they fail, output an error
message to stderr, and exit. STR is printed with the failure message. */
void
-__heap_check (struct heap *heap, const char *str)
+__heap_check (struct heap_free_area *heap, const char *str)
{
typedef unsigned long ul_t;
struct heap_free_area *fa, *prev;
- struct heap_free_area *first_fa = heap->free_areas;
+ struct heap_free_area *first_fa = heap;
if (first_fa && first_fa->prev)
__heap_check_failure (heap, first_fa, str,
diff --git a/libc/stdlib/malloc/heap_free.c b/libc/stdlib/malloc/heap_free.c
index 1c4634c55..15343c05a 100644
--- a/libc/stdlib/malloc/heap_free.c
+++ b/libc/stdlib/malloc/heap_free.c
@@ -18,12 +18,12 @@
/* Return the block of memory at MEM, of size SIZE, to HEAP. */
struct heap_free_area *
-__heap_free (struct heap *heap, void *mem, size_t size)
+__heap_free (struct heap_free_area **heap, void *mem, size_t size)
{
struct heap_free_area *fa, *prev_fa;
void *end = (char *)mem + size;
- HEAP_DEBUG (heap, "before __heap_free");
+ HEAP_DEBUG (*heap, "before __heap_free");
/* Find the right position in the free-list entry to place the new block.
This is the most speed critical loop in this malloc implementation:
@@ -32,7 +32,7 @@ __heap_free (struct heap *heap, void *mem, size_t size)
in the free-list when it becomes fragmented and long. [A better
implemention would use a balanced tree or something for the free-list,
though that bloats the code-size and complexity quite a bit.] */
- for (prev_fa = 0, fa = heap->free_areas; fa; prev_fa = fa, fa = fa->next)
+ for (prev_fa = 0, fa = *heap; fa; prev_fa = fa, fa = fa->next)
if (unlikely (HEAP_FREE_AREA_END (fa) >= mem))
break;
@@ -83,7 +83,7 @@ __heap_free (struct heap *heap, void *mem, size_t size)
/* Make the new block into a separate free-list entry. */
fa = __heap_add_free_area (heap, mem, size, prev_fa, fa);
- HEAP_DEBUG (heap, "after __heap_free");
+ HEAP_DEBUG (*heap, "after __heap_free");
return fa;
}
diff --git a/libc/stdlib/malloc/malloc.c b/libc/stdlib/malloc/malloc.c
index ce74c5608..f6bf10a93 100644
--- a/libc/stdlib/malloc/malloc.c
+++ b/libc/stdlib/malloc/malloc.c
@@ -16,8 +16,6 @@
#include <errno.h>
#include <sys/mman.h>
-libc_hidden_proto(mmap)
-libc_hidden_proto(sbrk)
#include "malloc.h"
#include "heap.h"
@@ -26,16 +24,19 @@ libc_hidden_proto(sbrk)
/* The malloc heap. We provide a bit of initial static space so that
programs can do a little mallocing without mmaping in more space. */
HEAP_DECLARE_STATIC_FREE_AREA (initial_fa, 256);
-struct heap __malloc_heap = HEAP_INIT_WITH_FA (initial_fa);
+struct heap_free_area *__malloc_heap = HEAP_INIT_WITH_FA (initial_fa);
+#ifdef HEAP_USE_LOCKING
+__UCLIBC_MUTEX_INIT(__malloc_heap_lock,PTHREAD_MUTEX_INITIALIZER);
+#endif
#if defined(MALLOC_USE_LOCKING) && defined(MALLOC_USE_SBRK)
/* A lock protecting our use of sbrk. */
-malloc_mutex_t __malloc_sbrk_lock;
+__UCLIBC_MUTEX(__malloc_sbrk_lock);
#endif /* MALLOC_USE_LOCKING && MALLOC_USE_SBRK */
#ifdef __UCLIBC_UCLINUX_BROKEN_MUNMAP__
-/* A list of all malloc_mmb structures describing blocsk that
+/* A list of all malloc_mmb structures describing blocks that
malloc has mmapped, ordered by the block address. */
struct malloc_mmb *__malloc_mmapped_blocks = 0;
@@ -43,12 +44,24 @@ struct malloc_mmb *__malloc_mmapped_blocks = 0;
them from the main heap, but that tends to cause heap fragmentation in
annoying ways. */
HEAP_DECLARE_STATIC_FREE_AREA (initial_mmb_fa, 48); /* enough for 3 mmbs */
-struct heap __malloc_mmb_heap = HEAP_INIT_WITH_FA (initial_mmb_fa);
+struct heap_free_area *__malloc_mmb_heap = HEAP_INIT_WITH_FA (initial_mmb_fa);
+#ifdef HEAP_USE_LOCKING
+__UCLIBC_MUTEX_INIT(__malloc_mmb_heap_lock,PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP);
+#endif
#endif /* __UCLIBC_UCLINUX_BROKEN_MUNMAP__ */
+#ifdef HEAP_USE_LOCKING
+#define malloc_from_heap(size, heap, lck) __malloc_from_heap(size, heap, lck)
+#else
+#define malloc_from_heap(size, heap, lck) __malloc_from_heap(size, heap)
+#endif
static void *
-malloc_from_heap (size_t size, struct heap *heap)
+__malloc_from_heap (size_t size, struct heap_free_area **heap
+#ifdef HEAP_USE_LOCKING
+ , __UCLIBC_MUTEX_TYPE *heap_lock
+#endif
+ )
{
void *mem;
@@ -57,12 +70,12 @@ malloc_from_heap (size_t size, struct heap *heap)
/* Include extra space to record the size of the allocated block. */
size += MALLOC_HEADER_SIZE;
- __heap_lock (heap);
+ __heap_lock (heap_lock);
/* First try to get memory that's already in our heap. */
mem = __heap_alloc (heap, &size);
- __heap_unlock (heap);
+ __heap_unlock (heap_lock);
if (unlikely (! mem))
/* We couldn't allocate from the heap, so grab some more
@@ -111,7 +124,7 @@ malloc_from_heap (size_t size, struct heap *heap)
MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
#else
block = mmap ((void *)0, block_size, PROT_READ | PROT_WRITE,
- MAP_SHARED | MAP_ANONYMOUS, 0, 0);
+ MAP_SHARED | MAP_ANONYMOUS | MAP_UNINITIALIZED, 0, 0);
#endif
#endif /* MALLOC_USE_SBRK */
@@ -122,11 +135,11 @@ malloc_from_heap (size_t size, struct heap *heap)
struct malloc_mmb *mmb, *prev_mmb, *new_mmb;
#endif
- MALLOC_DEBUG (1, "adding system memroy to heap: 0x%lx - 0x%lx (%d bytes)",
+ MALLOC_DEBUG (1, "adding system memory to heap: 0x%lx - 0x%lx (%d bytes)",
(long)block, (long)block + block_size, block_size);
/* Get back the heap lock. */
- __heap_lock (heap);
+ __heap_lock (heap_lock);
/* Put BLOCK into the heap. */
__heap_free (heap, block, block_size);
@@ -136,19 +149,19 @@ malloc_from_heap (size_t size, struct heap *heap)
/* Try again to allocate. */
mem = __heap_alloc (heap, &size);
- __heap_unlock (heap);
#if !defined(MALLOC_USE_SBRK) && defined(__UCLIBC_UCLINUX_BROKEN_MUNMAP__)
/* Insert a record of BLOCK in sorted order into the
__malloc_mmapped_blocks list. */
+ new_mmb = malloc_from_heap (sizeof *new_mmb, &__malloc_mmb_heap, &__malloc_mmb_heap_lock);
+
for (prev_mmb = 0, mmb = __malloc_mmapped_blocks;
mmb;
prev_mmb = mmb, mmb = mmb->next)
if (block < mmb->mem)
break;
- new_mmb = malloc_from_heap (sizeof *new_mmb, &__malloc_mmb_heap);
new_mmb->next = mmb;
new_mmb->mem = block;
new_mmb->size = block_size;
@@ -162,6 +175,7 @@ malloc_from_heap (size_t size, struct heap *heap)
(unsigned)new_mmb,
(unsigned)new_mmb->mem, block_size);
#endif /* !MALLOC_USE_SBRK && __UCLIBC_UCLINUX_BROKEN_MUNMAP__ */
+ __heap_unlock (heap_lock);
}
}
@@ -191,7 +205,7 @@ malloc (size_t size)
__malloc_debug_init ();
}
if (__malloc_check)
- __heap_check (&__malloc_heap, "malloc");
+ __heap_check (__malloc_heap, "malloc");
#endif
#ifdef __MALLOC_GLIBC_COMPAT__
@@ -207,7 +221,7 @@ malloc (size_t size)
if (unlikely(((unsigned long)size > (unsigned long)(MALLOC_HEADER_SIZE*-2))))
goto oom;
- mem = malloc_from_heap (size, &__malloc_heap);
+ mem = malloc_from_heap (size, &__malloc_heap, &__malloc_heap_lock);
if (unlikely (!mem))
{
oom:
diff --git a/libc/stdlib/malloc/malloc.h b/libc/stdlib/malloc/malloc.h
index 7277cd2cf..aa41870b9 100644
--- a/libc/stdlib/malloc/malloc.h
+++ b/libc/stdlib/malloc/malloc.h
@@ -17,11 +17,10 @@
alignment can be a significant win on targets like m68k and Coldfire,
where __alignof__(double) == 2. */
#define MALLOC_ALIGNMENT \
- __alignof__ (double __attribute_aligned__ (sizeof (size_t)))
+ (__alignof__ (double) > sizeof (size_t) ? __alignof__ (double) : sizeof (size_t))
/* The system pagesize... */
-extern size_t __pagesize;
-#define MALLOC_PAGE_SIZE __pagesize
+#define MALLOC_PAGE_SIZE sysconf(_SC_PAGESIZE)
/* The minimum size of block we request from the the system to extend the
heap for small allocations (we may request a bigger block if necessary to
@@ -70,14 +69,14 @@ struct malloc_mmb
struct malloc_mmb *next;
};
-/* A list of all malloc_mmb structures describing blocsk that malloc has
+/* A list of all malloc_mmb structures describing blocks that malloc has
mmapped, ordered by the block address. */
extern struct malloc_mmb *__malloc_mmapped_blocks;
/* A heap used for allocating malloc_mmb structures. We could allocate
them from the main heap, but that tends to cause heap fragmentation in
annoying ways. */
-extern struct heap __malloc_mmb_heap;
+extern struct heap_free_area *__malloc_mmb_heap;
/* Define MALLOC_MMB_DEBUGGING to cause malloc to emit debugging info about
about mmap block allocation/freeing by the `uclinux broken munmap' code
@@ -128,70 +127,46 @@ extern int __malloc_mmb_debug;
/* Return the size of a malloc allocation, given the user address. */
#define MALLOC_SIZE(addr) (*(size_t *)MALLOC_BASE(addr))
+#include <bits/uClibc_mutex.h>
-/* Locking for multithreaded apps. */
#ifdef __UCLIBC_HAS_THREADS__
-
-# include <pthread.h>
-# include <bits/uClibc_pthread.h>
-
# define MALLOC_USE_LOCKING
+#endif
-typedef pthread_mutex_t malloc_mutex_t;
-# define MALLOC_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
-
-# ifdef MALLOC_USE_SBRK
+#ifdef MALLOC_USE_SBRK
/* This lock is used to serialize uses of the `sbrk' function (in both
malloc and free, sbrk may be used several times in succession, and
things will break if these multiple calls are interleaved with another
thread's use of sbrk!). */
-extern malloc_mutex_t __malloc_sbrk_lock;
-# define __malloc_lock_sbrk() __pthread_mutex_lock (&__malloc_sbrk_lock)
-# define __malloc_unlock_sbrk() __pthread_mutex_unlock (&__malloc_sbrk_lock)
-# endif /* MALLOC_USE_SBRK */
-
-#else /* !__UCLIBC_HAS_THREADS__ */
-
-/* Without threads, mutex operations are a nop. */
+__UCLIBC_MUTEX_EXTERN(__malloc_sbrk_lock);
+# define __malloc_lock_sbrk() __UCLIBC_MUTEX_LOCK_CANCEL_UNSAFE (__malloc_sbrk_lock)
+# define __malloc_unlock_sbrk() __UCLIBC_MUTEX_UNLOCK_CANCEL_UNSAFE (__malloc_sbrk_lock)
+#else
# define __malloc_lock_sbrk() (void)0
# define __malloc_unlock_sbrk() (void)0
-
-#endif /* __UCLIBC_HAS_THREADS__ */
-
-
-/* branch-prediction macros; they may already be defined by libc. */
-#ifndef likely
-#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
-#define likely(cond) __builtin_expect(!!(int)(cond), 1)
-#define unlikely(cond) __builtin_expect((int)(cond), 0)
-#else
-#define likely(cond) (cond)
-#define unlikely(cond) (cond)
-#endif
-#endif /* !likely */
-
+#endif /* MALLOC_USE_SBRK */
/* Define MALLOC_DEBUGGING to cause malloc to emit debugging info to stderr
when the variable __malloc_debug is set to true. */
#ifdef MALLOC_DEBUGGING
-extern void __malloc_debug_init (void);
+extern void __malloc_debug_init (void) attribute_hidden;
/* The number of spaces in a malloc debug indent level. */
#define MALLOC_DEBUG_INDENT_SIZE 3
-extern int __malloc_debug, __malloc_check;
+extern int __malloc_debug attribute_hidden, __malloc_check attribute_hidden;
# define MALLOC_DEBUG(indent, fmt, args...) \
(__malloc_debug ? __malloc_debug_printf (indent, fmt , ##args) : 0)
# define MALLOC_DEBUG_INDENT(indent) \
(__malloc_debug ? __malloc_debug_indent (indent) : 0)
-extern int __malloc_debug_cur_indent;
+extern int __malloc_debug_cur_indent attribute_hidden;
/* Print FMT and args indented at the current debug print level, followed
by a newline, and change the level by INDENT. */
-extern void __malloc_debug_printf (int indent, const char *fmt, ...);
+extern void __malloc_debug_printf (int indent, const char *fmt, ...) attribute_hidden;
/* Change the current debug print level by INDENT, and return the value. */
#define __malloc_debug_indent(indent) (__malloc_debug_cur_indent += indent)
@@ -221,4 +196,18 @@ extern void __malloc_debug_printf (int indent, const char *fmt, ...);
/* The malloc heap. */
-extern struct heap __malloc_heap;
+extern struct heap_free_area *__malloc_heap attribute_hidden;
+#ifdef __UCLIBC_HAS_THREADS__
+__UCLIBC_MUTEX_EXTERN(__malloc_heap_lock)
+# ifndef __LINUXTHREADS_OLD__
+ attribute_hidden
+# endif
+ ;
+# ifdef __UCLIBC_UCLINUX_BROKEN_MUNMAP__
+__UCLIBC_MUTEX_EXTERN(__malloc_mmb_heap_lock)
+# ifndef __LINUXTHREADS_OLD__
+ attribute_hidden
+# endif
+ ;
+# endif
+#endif
diff --git a/libc/stdlib/malloc/malloc_debug.c b/libc/stdlib/malloc/malloc_debug.c
index 39c3919c5..1a5374faa 100644
--- a/libc/stdlib/malloc/malloc_debug.c
+++ b/libc/stdlib/malloc/malloc_debug.c
@@ -16,10 +16,6 @@
#include <unistd.h>
#include <stdarg.h>
-libc_hidden_proto(atoi)
-libc_hidden_proto(vfprintf)
-libc_hidden_proto(putc)
-libc_hidden_proto(getenv)
#include "malloc.h"
#include "heap.h"
diff --git a/libc/stdlib/malloc/memalign.c b/libc/stdlib/malloc/memalign.c
index 5b248f3e2..74d5dbd2d 100644
--- a/libc/stdlib/malloc/memalign.c
+++ b/libc/stdlib/malloc/memalign.c
@@ -19,8 +19,6 @@
#include "heap.h"
-#define MAX(x,y) ((x) > (y) ? (x) : (y))
-
/*
______________________ TOTAL _________________________
/ \
@@ -31,12 +29,14 @@
*/
void *memalign (size_t alignment, size_t size);
+/* XXX shadow outer malloc.h */
+libc_hidden_proto(memalign)
void *
memalign (size_t alignment, size_t size)
{
void *mem, *base;
unsigned long tot_addr, tot_end_addr, addr, end_addr;
- struct heap *heap = &__malloc_heap;
+ struct heap_free_area **heap = &__malloc_heap;
/* Make SIZE something we like. */
size = HEAP_ADJUST_SIZE (size);
@@ -93,3 +93,4 @@ memalign (size_t alignment, size_t size)
return MALLOC_SETUP (base, end_addr - (unsigned long)base);
}
+libc_hidden_def(memalign)
diff --git a/libc/stdlib/malloc/realloc.c b/libc/stdlib/malloc/realloc.c
index 948326762..bdfb52694 100644
--- a/libc/stdlib/malloc/realloc.c
+++ b/libc/stdlib/malloc/realloc.c
@@ -15,7 +15,6 @@
#include <string.h>
#include <errno.h>
-/* Experimentally off - libc_hidden_proto(memcpy) */
#include "malloc.h"
#include "heap.h"
@@ -27,14 +26,19 @@ realloc (void *mem, size_t new_size)
size_t size;
char *base_mem;
+ if (! mem)
+ return malloc (new_size);
+
/* Check for special cases. */
if (! new_size)
{
free (mem);
- return malloc (new_size);
+ return NULL;
}
- if (! mem)
- return malloc (new_size);
+
+ /* This matches the check in malloc() */
+ if (unlikely(((unsigned long)new_size > (unsigned long)(MALLOC_HEADER_SIZE*-2))))
+ return NULL;
/* Normal realloc. */
@@ -59,9 +63,9 @@ realloc (void *mem, size_t new_size)
{
size_t extra = new_size - size;
- __heap_lock (&__malloc_heap);
+ __heap_lock (&__malloc_heap_lock);
extra = __heap_alloc_at (&__malloc_heap, base_mem + size, extra);
- __heap_unlock (&__malloc_heap);
+ __heap_unlock (&__malloc_heap_lock);
if (extra)
/* Record the changed size. */
@@ -82,9 +86,9 @@ realloc (void *mem, size_t new_size)
else if (new_size + MALLOC_REALLOC_MIN_FREE_SIZE <= size)
/* Shrink the block. */
{
- __heap_lock (&__malloc_heap);
+ __heap_lock (&__malloc_heap_lock);
__heap_free (&__malloc_heap, base_mem + new_size, size - new_size);
- __heap_unlock (&__malloc_heap);
+ __heap_unlock (&__malloc_heap_lock);
MALLOC_SET_SIZE (base_mem, new_size);
}
diff --git a/libc/stdlib/mkdtemp.c b/libc/stdlib/mkdtemp.c
index fa9ae3b05..185e206a3 100644
--- a/libc/stdlib/mkdtemp.c
+++ b/libc/stdlib/mkdtemp.c
@@ -14,11 +14,11 @@
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 <stdio.h>
#include <stdlib.h>
+#include <sys/stat.h>
#include "../misc/internals/tempname.h"
#ifdef __USE_BSD
@@ -29,7 +29,7 @@
(This function comes from OpenBSD.) */
char * mkdtemp (char *template)
{
- if (__gen_tempname (template, __GT_DIR))
+ if (__gen_tempname (template, __GT_DIR, 0, 0, S_IRUSR | S_IWUSR | S_IXUSR))
return NULL;
else
return template;
diff --git a/libc/stdlib/mkostemp.c b/libc/stdlib/mkostemp.c
new file mode 100644
index 000000000..4eab0797a
--- /dev/null
+++ b/libc/stdlib/mkostemp.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 1998-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 <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include "../misc/internals/tempname.h"
+
+/* Generate a unique temporary file name from TEMPLATE.
+ The last six characters of TEMPLATE must be "XXXXXX";
+ they are replaced with a string that makes the filename unique.
+ Then open the file and return a fd. */
+int
+mkostemp (char *template, int flags)
+{
+ flags -= flags & O_ACCMODE; /* Remove O_RDONLY, O_WRONLY, and O_RDWR. */
+ return __gen_tempname (template, __GT_FILE, flags, 0, S_IRUSR | S_IWUSR);
+}
diff --git a/libc/stdlib/mkostemp64.c b/libc/stdlib/mkostemp64.c
new file mode 100644
index 000000000..25595ad96
--- /dev/null
+++ b/libc/stdlib/mkostemp64.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 2000-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 <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "../misc/internals/tempname.h"
+
+/* Generate a unique temporary file name from TEMPLATE.
+ The last six characters of TEMPLATE must be "XXXXXX";
+ they are replaced with a string that makes the filename unique.
+ Then open the file and return a fd. */
+int
+mkostemp64 (char *template, int flags)
+{
+ return __gen_tempname (template, __GT_BIGFILE, flags | O_LARGEFILE, 0,
+ S_IRUSR | S_IWUSR | S_IXUSR);
+}
diff --git a/libc/stdlib/mkostemps.c b/libc/stdlib/mkostemps.c
new file mode 100644
index 000000000..13a517185
--- /dev/null
+++ b/libc/stdlib/mkostemps.c
@@ -0,0 +1,36 @@
+/* Copyright (C) 1998-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 <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include "../misc/internals/tempname.h"
+
+/* Generate a unique temporary file name from TEMPLATE.
+ The TEMPLATE is of the form "XXXXXXsuffix" where six characters
+ after the TEMPLATE must be "XXXXXX" followed by the suffix.
+ The suffix length must be specified with suffixlen.
+ "XXXXXX" are replaced with a string that makes the filename unique.
+ Then open the file and return a fd. */
+int mkostemps (char *template, int suffixlen, int flags)
+{
+ flags -= flags & O_ACCMODE; /* Remove O_RDONLY, O_WRONLY, and O_RDWR. */
+ return __gen_tempname (template, __GT_FILE, flags, suffixlen,
+ S_IRUSR | S_IWUSR);
+}
+
+
diff --git a/libc/stdlib/mkostemps64.c b/libc/stdlib/mkostemps64.c
new file mode 100644
index 000000000..0436fcf81
--- /dev/null
+++ b/libc/stdlib/mkostemps64.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 1998-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 <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include "../misc/internals/tempname.h"
+
+/* Generate a unique temporary file name from TEMPLATE.
+ The TEMPLATE is of the form "XXXXXXsuffix" where six characters
+ after the TEMPLATE must be "XXXXXX" followed by the suffix.
+ The suffix length must be specified with suffixlen.
+ "XXXXXX" are replaced with a string that makes the filename unique.
+ Then open the file and return a fd. */
+int mkostemps64 (char *template, int suffixlen, int flags)
+{
+ flags -= flags & O_ACCMODE; /* Remove O_RDONLY, O_WRONLY, and O_RDWR. */
+ return __gen_tempname (template, __GT_FILE, flags, suffixlen,
+ S_IRUSR | S_IWUSR);
+}
diff --git a/libc/stdlib/mkstemp.c b/libc/stdlib/mkstemp.c
index c569ceaf5..abcc93e62 100644
--- a/libc/stdlib/mkstemp.c
+++ b/libc/stdlib/mkstemp.c
@@ -13,11 +13,11 @@
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 <stdio.h>
#include <stdlib.h>
+#include <sys/stat.h>
#include "../misc/internals/tempname.h"
/* Generate a unique temporary file name from TEMPLATE.
@@ -26,5 +26,5 @@
Then open the file and return a fd. */
int mkstemp (char *template)
{
- return __gen_tempname (template, __GT_FILE);
+ return __gen_tempname (template, __GT_FILE, 0, 0, S_IRUSR | S_IWUSR);
}
diff --git a/libc/stdlib/mkstemp64.c b/libc/stdlib/mkstemp64.c
index 02a03f00e..82c6da531 100644
--- a/libc/stdlib/mkstemp64.c
+++ b/libc/stdlib/mkstemp64.c
@@ -13,11 +13,11 @@
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 <stdio.h>
#include <stdlib.h>
+#include <sys/stat.h>
#include "../misc/internals/tempname.h"
/* Generate a unique temporary file name from TEMPLATE.
@@ -26,5 +26,5 @@
Then open the file and return a fd. */
int mkstemp64 (char *template)
{
- return __gen_tempname (template, __GT_BIGFILE);
+ return __gen_tempname (template, __GT_BIGFILE, 0, 0, S_IRUSR | S_IWUSR);
}
diff --git a/libc/stdlib/mkstemps.c b/libc/stdlib/mkstemps.c
new file mode 100644
index 000000000..22aebf4ba
--- /dev/null
+++ b/libc/stdlib/mkstemps.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1998-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 <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include "../misc/internals/tempname.h"
+
+/* Generate a unique temporary file name from TEMPLATE.
+ The TEMPLATE is of the form "XXXXXXsuffix" where six characters
+ after the TEMPLATE must be "XXXXXX" followed by the suffix.
+ The suffix length must be specified with suffixlen.
+ "XXXXXX" are replaced with a string that makes the filename unique.
+ Then open the file and return a fd. */
+int mkstemps (char *template, int suffixlen)
+{
+ return __gen_tempname (template, __GT_FILE, 0, suffixlen,
+ S_IRUSR | S_IWUSR);
+}
diff --git a/libc/stdlib/mkstemps64.c b/libc/stdlib/mkstemps64.c
new file mode 100644
index 000000000..19fb4c861
--- /dev/null
+++ b/libc/stdlib/mkstemps64.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1998-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 <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include "../misc/internals/tempname.h"
+
+/* Generate a unique temporary file name from TEMPLATE.
+ The TEMPLATE is of the form "XXXXXXsuffix" where six characters
+ after the TEMPLATE must be "XXXXXX" followed by the suffix.
+ The suffix length must be specified with suffixlen.
+ "XXXXXX" are replaced with a string that makes the filename unique.
+ Then open the file and return a fd. */
+int mkstemps64 (char *template, int suffixlen)
+{
+ return __gen_tempname (template, __GT_BIGFILE, 0, suffixlen,
+ S_IRUSR | S_IWUSR);
+}
diff --git a/libc/stdlib/mktemp.c b/libc/stdlib/mktemp.c
index f3af1c15c..be8815358 100644
--- a/libc/stdlib/mktemp.c
+++ b/libc/stdlib/mktemp.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/>. */
#include <stdio.h>
#include <stdlib.h>
@@ -25,11 +24,9 @@
* they are replaced with a string that makes the filename unique. */
char *mktemp(char *template)
{
- if (__gen_tempname (template, __GT_NOCREATE) < 0)
+ if (__gen_tempname (template, __GT_NOCREATE, 0,0, 0) < 0)
/* We return the null string if we can't find a unique file name. */
template[0] = '\0';
return template;
}
-
-link_warning(mktemp, "the use of `mktemp' is dangerous, better use `mkstemp'")
diff --git a/libc/stdlib/mrand48.c b/libc/stdlib/mrand48.c
index 6905545bd..d86f7ba5c 100644
--- a/libc/stdlib/mrand48.c
+++ b/libc/stdlib/mrand48.c
@@ -13,17 +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/>. */
#include <stdlib.h>
-libc_hidden_proto(jrand48_r)
-
-/* Global state for non-reentrant functions. Defined in drand48-iter.c. */
-extern struct drand48_data __libc_drand48_data attribute_hidden;
-
long int mrand48 (void)
{
long int result;
diff --git a/libc/stdlib/mrand48_r.c b/libc/stdlib/mrand48_r.c
index ca2bd7bbb..0c4df4aa5 100644
--- a/libc/stdlib/mrand48_r.c
+++ b/libc/stdlib/mrand48_r.c
@@ -13,13 +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/>. */
#include <stdlib.h>
-libc_hidden_proto(jrand48_r)
int mrand48_r (struct drand48_data *buffer, long int *result)
{
diff --git a/libc/stdlib/nrand48.c b/libc/stdlib/nrand48.c
index 0199a30a5..3eda3ec09 100644
--- a/libc/stdlib/nrand48.c
+++ b/libc/stdlib/nrand48.c
@@ -13,17 +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/>. */
#include <stdlib.h>
-libc_hidden_proto(nrand48_r)
-
-/* Global state for non-reentrant functions. Defined in drand48-iter.c. */
-extern struct drand48_data __libc_drand48_data attribute_hidden;
-
long int nrand48 (unsigned short int xsubi[3])
{
long int result;
diff --git a/libc/stdlib/nrand48_r.c b/libc/stdlib/nrand48_r.c
index 63b0ac8ef..ff7ab52d1 100644
--- a/libc/stdlib/nrand48_r.c
+++ b/libc/stdlib/nrand48_r.c
@@ -13,16 +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/>. */
#include <stdlib.h>
-extern int __drand48_iterate(unsigned short xsubi[3],
- struct drand48_data *buffer) attribute_hidden;
-
-libc_hidden_proto(nrand48_r)
int nrand48_r (unsigned short int xsubi[3], struct drand48_data *buffer, long int *result)
{
/* Compute next state. */
diff --git a/libc/stdlib/posix_memalign.c b/libc/stdlib/posix_memalign.c
index 115fb8999..523bc2cbd 100644
--- a/libc/stdlib/posix_memalign.c
+++ b/libc/stdlib/posix_memalign.c
@@ -15,9 +15,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 <stdlib.h>
diff --git a/libc/stdlib/ptsname.c b/libc/stdlib/ptsname.c
index bd9c3cab2..2d3b31731 100644
--- a/libc/stdlib/ptsname.c
+++ b/libc/stdlib/ptsname.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 <stdio.h>
#include <errno.h>
@@ -29,13 +28,6 @@
#include <unistd.h>
#include <bits/uClibc_uintmaxtostr.h>
-/* Experimentally off - libc_hidden_proto(strcat) */
-/* Experimentally off - libc_hidden_proto(strcpy) */
-/* Experimentally off - libc_hidden_proto(strlen) */
-libc_hidden_proto(isatty)
-libc_hidden_proto(ioctl)
-libc_hidden_proto(fstat)
-libc_hidden_proto(stat)
#if !defined __UNIX98PTY_ONLY__
@@ -68,7 +60,6 @@ extern const char __libc_ptyname2[] attribute_hidden;
/* Store at most BUFLEN characters of the pathname of the slave pseudo
terminal associated with the master FD is open on in BUF.
Return 0 on success, otherwise an error number. */
-libc_hidden_proto(ptsname_r)
int ptsname_r (int fd, char *buf, size_t buflen)
{
int save_errno = errno;
diff --git a/libc/stdlib/pty-private.h b/libc/stdlib/pty-private.h
index 621dbfd6f..ef628a112 100644
--- a/libc/stdlib/pty-private.h
+++ b/libc/stdlib/pty-private.h
@@ -15,8 +15,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 _PTY_PRIVATE_H
#define _PTY_PRIVATE_H 1
diff --git a/libc/stdlib/qsort_r.c b/libc/stdlib/qsort_r.c
new file mode 100644
index 000000000..1db270e62
--- /dev/null
+++ b/libc/stdlib/qsort_r.c
@@ -0,0 +1,7 @@
+/* Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_qsort_r
+#include "stdlib.c"
diff --git a/libc/stdlib/rand.c b/libc/stdlib/rand.c
index 03323f501..4b899c0fc 100644
--- a/libc/stdlib/rand.c
+++ b/libc/stdlib/rand.c
@@ -7,10 +7,8 @@
#include <stdlib.h>
-libc_hidden_proto(random)
-int rand (void)
+int rand(void)
{
- return((int)random());
+ return (int)random();
}
-
diff --git a/libc/stdlib/rand_r.c b/libc/stdlib/rand_r.c
index 610044083..722ba4949 100644
--- a/libc/stdlib/rand_r.c
+++ b/libc/stdlib/rand_r.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/>. */
#include <stdlib.h>
diff --git a/libc/stdlib/random.c b/libc/stdlib/random.c
index 3eb8aed8a..b009c4310 100644
--- a/libc/stdlib/random.c
+++ b/libc/stdlib/random.c
@@ -27,10 +27,6 @@
#include <stddef.h>
#include <stdlib.h>
-libc_hidden_proto(random_r)
-libc_hidden_proto(srandom_r)
-libc_hidden_proto(setstate_r)
-libc_hidden_proto(initstate_r)
/* POSIX.1c requires that there is mutual exclusion for the `rand' and
`srand' functions to prevent concurrent calls from modifying common
@@ -74,11 +70,7 @@ __UCLIBC_MUTEX_STATIC(mylock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP);
-/* For each of the currently supported random number generators, we have a
- break value on the amount of state information (you need at least this many
- bytes of state info to support this random number generator), a degree for
- the polynomial (actually a trinomial) that the R.N.G. is based on, and
- separation between the two lower order coefficients of the trinomial. */
+/* Keep constants in sync with random_r.c */
/* Linear congruential. */
#define TYPE_0 0
@@ -110,13 +102,8 @@ __UCLIBC_MUTEX_STATIC(mylock, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP);
#define DEG_4 63
#define SEP_4 1
-
-/* Array versions of the above information to make code run faster.
- Relies on fact that TYPE_i == i. */
-
#define MAX_TYPES 5 /* Max number of types above. */
-
/* Initially, everything is set up as if from:
initstate(1, randtbl, 128);
Note that this initialization takes advantage of the fact that srandom
@@ -244,7 +231,6 @@ char * setstate (char *arg_state)
rear pointers can't wrap on the same call by not testing the rear
pointer if the front one has wrapped. Returns a 31-bit random number. */
-libc_hidden_proto(random)
long int random (void)
{
int32_t retval;
diff --git a/libc/stdlib/random_r.c b/libc/stdlib/random_r.c
index ca80a7808..4b2b3f85d 100644
--- a/libc/stdlib/random_r.c
+++ b/libc/stdlib/random_r.c
@@ -27,8 +27,7 @@
#include <limits.h>
#include <stddef.h>
#include <stdlib.h>
-
-
+#include <unistd.h>
/* An improved random number generation package. In addition to the standard
rand()/srand() like interface, this package also has a special state info
@@ -109,8 +108,8 @@
struct random_poly_info
{
- int seps[MAX_TYPES];
- int degrees[MAX_TYPES];
+ smallint seps[MAX_TYPES];
+ smallint degrees[MAX_TYPES];
};
static const struct random_poly_info random_poly_info =
@@ -121,7 +120,6 @@ static const struct random_poly_info random_poly_info =
-
/* If we are using the trivial TYPE_0 R.N.G., just do the old linear
congruential bit. Otherwise, we do our fancy trinomial stuff, which is the
same in all the other cases due to all the global variables that have been
@@ -133,7 +131,6 @@ static const struct random_poly_info random_poly_info =
rear pointers can't wrap on the same call by not testing the rear
pointer if the front one has wrapped. Returns a 31-bit random number. */
-libc_hidden_proto(random_r)
int random_r(struct random_data *buf, int32_t *result)
{
int32_t *state;
@@ -191,7 +188,6 @@ libc_hidden_def(random_r)
information a given number of times to get rid of any initial dependencies
introduced by the L.C.R.N.G. Note that the initialization of randtbl[]
for default usage relies on values produced by this routine. */
-libc_hidden_proto(srandom_r)
int srandom_r (unsigned int seed, struct random_data *buf)
{
int type;
@@ -259,7 +255,6 @@ libc_hidden_def(srandom_r)
Note: The first thing we do is save the current state, if any, just like
setstate so that it doesn't matter when initstate is called.
Returns a pointer to the old state. */
-libc_hidden_proto(initstate_r)
int initstate_r (unsigned int seed, char *arg_state, size_t n, struct random_data *buf)
{
int type;
@@ -318,7 +313,6 @@ libc_hidden_def(initstate_r)
to the order in which things are done, it is OK to call setstate with the
same state as the current state
Returns a pointer to the old state information. */
-libc_hidden_proto(setstate_r)
int setstate_r (char *arg_state, struct random_data *buf)
{
int32_t *new_state = 1 + (int32_t *) arg_state;
diff --git a/libc/stdlib/realpath.c b/libc/stdlib/realpath.c
index e9eabdfaa..cf9d45fa2 100644
--- a/libc/stdlib/realpath.c
+++ b/libc/stdlib/realpath.c
@@ -21,11 +21,6 @@
#include <sys/stat.h> /* for S_IFLNK */
-/* Experimentally off - libc_hidden_proto(strcat) */
-/* Experimentally off - libc_hidden_proto(strcpy) */
-/* Experimentally off - libc_hidden_proto(strlen) */
-libc_hidden_proto(readlink)
-libc_hidden_proto(getcwd)
#ifndef PATH_MAX
#ifdef _POSIX_VERSION
@@ -41,19 +36,10 @@ libc_hidden_proto(getcwd)
#define MAX_READLINKS 32
-#ifdef __STDC__
char *realpath(const char *path, char got_path[])
-#else
-char *realpath(path, got_path)
-const char *path;
-char got_path[];
-#endif
{
char copy_path[PATH_MAX];
- /* use user supplied buffer directly - reduces stack usage */
- /* char got_path[PATH_MAX]; */
- char *max_path;
- char *new_path;
+ char *max_path, *new_path, *allocated_path;
size_t path_len;
int readlinks = 0;
#ifdef S_IFLNK
@@ -77,12 +63,13 @@ char got_path[];
/* Copy so that path is at the end of copy_path[] */
strcpy(copy_path + (PATH_MAX-1) - path_len, path);
path = copy_path + (PATH_MAX-1) - path_len;
+ allocated_path = got_path ? NULL : (got_path = malloc(PATH_MAX));
max_path = got_path + PATH_MAX - 2; /* points to last non-NUL char */
new_path = got_path;
if (*path != '/') {
/* If it's a relative pathname use getcwd for starters. */
if (!getcwd(new_path, PATH_MAX - 1))
- return NULL;
+ goto err;
new_path += strlen(new_path);
if (new_path[-1] != '/')
*new_path++ = '/';
@@ -119,6 +106,8 @@ char got_path[];
while (*path != '\0' && *path != '/') {
if (new_path > max_path) {
__set_errno(ENAMETOOLONG);
+ err:
+ free(allocated_path);
return NULL;
}
*new_path++ = *path++;
@@ -127,7 +116,7 @@ char got_path[];
/* Protect against infinite loops. */
if (readlinks++ > MAX_READLINKS) {
__set_errno(ELOOP);
- return NULL;
+ goto err;
}
path_len = strlen(path);
/* See if last (so far) pathname component is a symlink. */
@@ -138,13 +127,13 @@ char got_path[];
if (link_len < 0) {
/* EINVAL means the file exists but isn't a symlink. */
if (errno != EINVAL) {
- return NULL;
+ goto err;
}
} else {
/* Safe sex check. */
if (path_len + link_len >= PATH_MAX - 2) {
__set_errno(ENAMETOOLONG);
- return NULL;
+ goto err;
}
/* Note: readlink doesn't add the null byte. */
/* copy_path[link_len] = '\0'; - we don't need it too */
@@ -170,3 +159,4 @@ char got_path[];
*new_path = '\0';
return got_path;
}
+libc_hidden_def(realpath)
diff --git a/libc/stdlib/rpmatch.c b/libc/stdlib/rpmatch.c
new file mode 100644
index 000000000..dce06b641
--- /dev/null
+++ b/libc/stdlib/rpmatch.c
@@ -0,0 +1,7 @@
+/* Copyright (C) 2012 Bernhard Reutner-Fischer <uclibc@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1+, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_rpmatch
+#include "stdlib.c"
diff --git a/libc/stdlib/seed48.c b/libc/stdlib/seed48.c
index f068b980d..285b5c220 100644
--- a/libc/stdlib/seed48.c
+++ b/libc/stdlib/seed48.c
@@ -13,17 +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/>. */
#include <stdlib.h>
-libc_hidden_proto(seed48_r)
-
-/* Global state for non-reentrant functions. Defined in drand48-iter.c. */
-extern struct drand48_data __libc_drand48_data attribute_hidden;
-
unsigned short int *
seed48 (unsigned short int seed16v[3])
{
diff --git a/libc/stdlib/seed48_r.c b/libc/stdlib/seed48_r.c
index 3769e0fa7..7444370d6 100644
--- a/libc/stdlib/seed48_r.c
+++ b/libc/stdlib/seed48_r.c
@@ -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/>. */
#include <stdlib.h>
#include <string.h>
#include <limits.h>
-/* Experimentally off - libc_hidden_proto(memcpy) */
-libc_hidden_proto(seed48_r)
int seed48_r (unsigned short int seed16v[3], struct drand48_data *buffer)
{
/* Save old value at a private place to be used as return value. */
diff --git a/libc/stdlib/setenv.c b/libc/stdlib/setenv.c
index 833bd8fcd..ecc302536 100644
--- a/libc/stdlib/setenv.c
+++ b/libc/stdlib/setenv.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; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>.
modified for uClibc by Erik Andersen <andersen@codepoet.org>
*/
@@ -25,12 +24,6 @@
#include <string.h>
#include <unistd.h>
-/* Experimentally off - libc_hidden_proto(memcpy) */
-/* Experimentally off - libc_hidden_proto(strchr) */
-/* Experimentally off - libc_hidden_proto(strlen) */
-/* Experimentally off - libc_hidden_proto(strncmp) */
-/* Experimentally off - libc_hidden_proto(strndup) */
-libc_hidden_proto(unsetenv)
#include <bits/uClibc_mutex.h>
__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER);
@@ -46,116 +39,112 @@ static char **last_environ;
is then placed in the environment, while the argument of `putenv'
must be used directly. This is all complicated by the fact that we try
to reuse values once generated for a `setenv' call since we can never
- free the strings. */
-int __add_to_environ (const char *name, const char *value,
- const char *combined, int replace) attribute_hidden;
-int __add_to_environ (const char *name, const char *value,
- const char *combined, int replace)
+ free the strings. [in uclibc, we do not] */
+static int __add_to_environ(const char *name, const char *value,
+ int replace)
{
- register char **ep;
- register size_t size;
- const size_t namelen = strlen (name);
- const size_t vallen = value != NULL ? strlen (value) + 1 : 0;
- int rv = -1;
-
- __UCLIBC_MUTEX_LOCK(mylock);
-
- /* We have to get the pointer now that we have the lock and not earlier
- since another thread might have created a new environment. */
- ep = __environ;
-
- size = 0;
- if (ep != NULL) {
- for (; *ep != NULL; ++ep) {
- if (!strncmp (*ep, name, namelen) && (*ep)[namelen] == '=')
- break;
- else
- ++size;
- }
- }
-
- if (ep == NULL || *ep == NULL) {
- char **new_environ;
-
- /* We allocated this space; we can extend it. */
- new_environ = (char **) realloc (last_environ, (size + 2) * sizeof (char *));
- if (new_environ == NULL) {
- goto DONE;
- }
-
- /* If the whole entry is given add it. */
- if (combined != NULL) {
- /* We must not add the string to the search tree since it belongs
- to the user. */
- new_environ[size] = (char *) combined;
- } else {
- /* See whether the value is already known. */
- new_environ[size] = (char *) malloc (namelen + 1 + vallen);
- if (new_environ[size] == NULL) {
- __set_errno (ENOMEM);
- goto DONE;
+ register char **ep;
+ register size_t size;
+ char *var_val;
+ char **new_environ;
+ /* name may come from putenv() and thus may contain "=VAL" part */
+ const size_t namelen = strchrnul(name, '=') - name;
+ int rv = -1;
+
+ __UCLIBC_MUTEX_LOCK(mylock);
+
+ /* We have to get the pointer now that we have the lock and not earlier
+ since another thread might have created a new environment. */
+ ep = __environ;
+
+ size = 0;
+ if (ep != NULL) {
+ while (*ep != NULL) {
+ if (!strncmp(*ep, name, namelen) && (*ep)[namelen] == '=') {
+ /* Found */
+ if (!replace)
+ goto DONE_OK;
+ goto REPLACE;
}
-
- memcpy (new_environ[size], name, namelen);
- new_environ[size][namelen] = '=';
- memcpy (&new_environ[size][namelen + 1], value, vallen);
- }
-
- if (__environ != last_environ) {
- memcpy ((char *) new_environ, (char *) __environ,
- size * sizeof (char *));
+ ++size;
+ ++ep;
}
-
- new_environ[size + 1] = NULL;
- last_environ = __environ = new_environ;
- } else if (replace) {
- char *np;
-
- /* Use the user string if given. */
- if (combined != NULL) {
- np = (char *) combined;
- } else {
- np = malloc (namelen + 1 + vallen);
- if (np == NULL) {
- goto DONE;
- }
- memcpy (np, name, namelen);
- np[namelen] = '=';
- memcpy (&np[namelen + 1], value, vallen);
+ }
+
+ /* Not found, add at the end */
+
+ /* We allocated this space; we can extend it. */
+ new_environ = realloc(last_environ, (size + 2) * sizeof(char *));
+ if (new_environ == NULL) {
+ /* __set_errno(ENOMEM); */
+ goto DONE;
+ }
+ if (__environ != last_environ) {
+ memcpy(new_environ, __environ, size * sizeof(char *));
+ }
+ last_environ = __environ = new_environ;
+
+ ep = &new_environ[size];
+ /* Ensure env is NULL terminated in case malloc below fails */
+ ep[0] = NULL;
+ ep[1] = NULL;
+
+ REPLACE:
+ var_val = (char*) name;
+ /* Build VAR=VAL if we called by setenv, not putenv. */
+ if (value != NULL) {
+ const size_t vallen = strlen(value) + 1;
+
+ var_val = malloc(namelen + 1 + vallen);
+ if (var_val == NULL) {
+ /* __set_errno(ENOMEM); */
+ goto DONE;
}
- *ep = np;
- }
+ memcpy(var_val, name, namelen);
+ var_val[namelen] = '=';
+ memcpy(&var_val[namelen + 1], value, vallen);
+ }
+ *ep = var_val;
- rv = 0;
+ DONE_OK:
+ rv = 0;
DONE:
- __UCLIBC_MUTEX_UNLOCK(mylock);
- return rv;
+ __UCLIBC_MUTEX_UNLOCK(mylock);
+ return rv;
}
-libc_hidden_proto(setenv)
-int setenv (const char *name, const char *value, int replace)
+int setenv(const char *name, const char *value, int replace)
{
- return __add_to_environ (name, value, NULL, replace);
+ if (name == NULL || *name == '\0' || strchr (name, '=') != NULL) {
+ __set_errno(EINVAL);
+ return -1;
+ }
+
+ /* NB: setenv("VAR", NULL, 1) inserts "VAR=" string */
+ return __add_to_environ(name, value ? value : "", replace);
}
libc_hidden_def(setenv)
-libc_hidden_proto(unsetenv)
-int unsetenv (const char *name)
+int unsetenv(const char *name)
{
- size_t len;
- char **ep;
-
- if (name == NULL || *name == '\0' || strchr (name, '=') != NULL) {
- __set_errno (EINVAL);
+ const char *eq;
+ size_t len;
+ char **ep;
+
+ if (name == NULL || *name == '\0'
+ || *(eq = strchrnul(name, '=')) == '='
+ ) {
+ __set_errno(EINVAL);
return -1;
- }
-
- len = strlen (name);
- __UCLIBC_MUTEX_LOCK(mylock);
- ep = __environ;
- while (*ep != NULL) {
- if (!strncmp (*ep, name, len) && (*ep)[len] == '=') {
+ }
+ len = eq - name; /* avoiding strlen this way */
+
+ __UCLIBC_MUTEX_LOCK(mylock);
+ ep = __environ;
+ /* NB: clearenv(); unsetenv("foo"); should not segfault */
+ if (ep) while (*ep != NULL) {
+ if (!strncmp(*ep, name, len) && (*ep)[len] == '=') {
/* Found it. Remove this pointer by moving later ones back. */
char **dp = ep;
do {
@@ -165,42 +154,34 @@ int unsetenv (const char *name)
} else {
++ep;
}
- }
- __UCLIBC_MUTEX_UNLOCK(mylock);
- return 0;
+ }
+ __UCLIBC_MUTEX_UNLOCK(mylock);
+ return 0;
}
libc_hidden_def(unsetenv)
/* The `clearenv' was planned to be added to POSIX.1 but probably
never made it. Nevertheless the POSIX.9 standard (POSIX bindings
for Fortran 77) requires this function. */
-int clearenv (void)
+int clearenv(void)
{
- __UCLIBC_MUTEX_LOCK(mylock);
- if (__environ == last_environ && __environ != NULL) {
- /* We allocated this environment so we can free it. */
- free (__environ);
- last_environ = NULL;
- }
- /* Clear the environment pointer removes the whole environment. */
- __environ = NULL;
- __UCLIBC_MUTEX_UNLOCK(mylock);
- return 0;
+ __UCLIBC_MUTEX_LOCK(mylock);
+ /* If we allocated this environment we can free it.
+ * If we did not allocate this environment, it's NULL already
+ * and is safe to free(). */
+ free(last_environ);
+ last_environ = NULL;
+ /* Clearing environ removes the whole environment. */
+ __environ = NULL;
+ __UCLIBC_MUTEX_UNLOCK(mylock);
+ return 0;
}
/* Put STRING, which is of the form "NAME=VALUE", in the environment. */
-int putenv (char *string)
+int putenv(char *string)
{
- int result;
- const char *const name_end = strchr (string, '=');
-
- if (name_end != NULL) {
- char *name = strndup(string, name_end - string);
- result = __add_to_environ (name, NULL, string, 1);
- free(name);
- return(result);
- }
- unsetenv (string);
- return 0;
+ if (strchr(string, '=') != NULL) {
+ return __add_to_environ(string, NULL, 1);
+ }
+ return unsetenv(string);
}
-
diff --git a/libc/stdlib/srand48.c b/libc/stdlib/srand48.c
index 42e90c9f9..ef526c172 100644
--- a/libc/stdlib/srand48.c
+++ b/libc/stdlib/srand48.c
@@ -13,17 +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/>. */
#include <stdlib.h>
-libc_hidden_proto(srand48_r)
-
-/* Global state for non-reentrant functions. Defined in drand48-iter.c. */
-extern struct drand48_data __libc_drand48_data attribute_hidden;
-
void srand48 (long seedval)
{
srand48_r (seedval, &__libc_drand48_data);
diff --git a/libc/stdlib/srand48_r.c b/libc/stdlib/srand48_r.c
index 45bb75f11..d65825c4b 100644
--- a/libc/stdlib/srand48_r.c
+++ b/libc/stdlib/srand48_r.c
@@ -13,14 +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 <stdlib.h>
#include <limits.h>
-libc_hidden_proto(srand48_r)
int srand48_r (long int seedval, struct drand48_data *buffer)
{
/* The standards say we only have 32 bits. */
diff --git a/libc/stdlib/stdlib.c b/libc/stdlib/stdlib.c
index 68796656a..6c887eabc 100644
--- a/libc/stdlib/stdlib.c
+++ b/libc/stdlib/stdlib.c
@@ -12,8 +12,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/>.
*/
/* ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION!
@@ -32,58 +32,8 @@
* Add wscto{inttype} functions.
*/
-#define _ISOC99_SOURCE /* for ULLONG primarily... */
#include <limits.h>
#include <stdint.h>
-/* Work around gcc's refusal to create aliases.
- * TODO: Add in a define to disable the aliases? */
-
-#if UINT_MAX == ULONG_MAX
-#ifdef L_labs
-#define abs __ignore_abs
-#endif
-#ifdef L_atol
-#define atoi __ignore_atoi
-#endif
-#endif
-#if defined(ULLONG_MAX) && (ULLONG_MAX == ULONG_MAX)
-#ifdef L_labs
-#define llabs __ignore_llabs
-#endif
-#ifdef L_atol
-#define atoll __ignore_atoll
-#endif
-#ifdef L_strtol
-#define strtoll __ignore_strtoll
-#endif
-#ifdef L_strtoul
-#define strtoull __ignore_strtoull
-#endif
-#ifdef L_wcstol
-#define wcstoll __ignore_wcstoll
-#endif
-#ifdef L_wcstoul
-#define wcstoull __ignore_wcstoull
-#endif
-#ifdef strtol_l
-#define strtoll_l __ignore_strtoll_l
-#endif
-#ifdef L_strtoul_l
-#define strtoull_l __ignore_strtoull_l
-#endif
-#ifdef L_wcstol_l
-#define wcstoll_l __ignore_wcstoll_l
-#endif
-#ifdef L_wcstoul_l
-#define wcstoull_l __ignore_wcstoull_l
-#endif
-#endif
-#if defined(ULLONG_MAX) && (ULLONG_MAX == UINTMAX_MAX)
-#if defined L_labs || defined L_llabs
-#define imaxabs __ignore_imaxabs
-#endif
-#endif
-
#include <stdint.h>
#include <inttypes.h>
#include <ctype.h>
@@ -100,10 +50,6 @@
#include <wctype.h>
#include <bits/uClibc_uwchar.h>
-#ifdef __UCLIBC_HAS_XLOCALE__
-#include <xlocale.h>
-#endif /* __UCLIBC_HAS_XLOCALE__ */
-
/* TODO: clean up the following... */
#if WCHAR_MAX > 0xffffUL
@@ -114,7 +60,7 @@
#ifdef __UCLIBC_HAS_LOCALE__
-#define ENCODING ((__UCLIBC_CURLOCALE_DATA).encoding)
+#define ENCODING (__UCLIBC_CURLOCALE->encoding)
#ifndef __CTYPE_HAS_UTF_8_LOCALES
#ifdef L_mblen
/* emit only once */
@@ -197,7 +143,6 @@ _stdlib_wcsto_ll(register const wchar_t * __restrict str,
/**********************************************************************/
#ifdef L_atof
-libc_hidden_proto(strtod)
double atof(const char *nptr)
{
@@ -227,21 +172,15 @@ long int labs(long int j)
}
#if UINT_MAX == ULONG_MAX
-#undef abs
-extern __typeof(labs) abs;
-strong_alias(labs,abs)
+strong_alias_untyped(labs,abs)
#endif
#if defined(ULLONG_MAX) && (ULLONG_MAX == ULONG_MAX)
-#undef llabs
-extern __typeof(labs) llabs;
-strong_alias(labs,llabs)
+strong_alias_untyped(labs,llabs)
#endif
#if ULONG_MAX == UINTMAX_MAX
-#undef imaxabs
-extern __typeof(labs) imaxabs;
-strong_alias(labs,imaxabs)
+strong_alias_untyped(labs,imaxabs)
#endif
#endif
@@ -256,9 +195,7 @@ long long int llabs(long long int j)
}
#if (ULLONG_MAX == UINTMAX_MAX)
-#undef imaxabs
-extern __typeof(llabs) imaxabs;
-strong_alias(llabs,imaxabs)
+strong_alias_untyped(llabs,imaxabs)
#endif
#endif /* defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX) */
@@ -269,9 +206,7 @@ strong_alias(llabs,imaxabs)
#if INT_MAX < LONG_MAX
-libc_hidden_proto(strtol)
-libc_hidden_proto(atoi)
int atoi(const char *nptr)
{
return (int) strtol(nptr, (char **) NULL, 10);
@@ -284,27 +219,19 @@ libc_hidden_def(atoi)
/**********************************************************************/
#ifdef L_atol
-libc_hidden_proto(strtol)
-libc_hidden_proto(atol)
long atol(const char *nptr)
{
return strtol(nptr, (char **) NULL, 10);
}
-libc_hidden_def(atol)
#if UINT_MAX == ULONG_MAX
-#undef atoi
-extern __typeof(atol) atoi;
-libc_hidden_proto(atoi)
-strong_alias(atol,atoi)
+strong_alias_untyped(atol,atoi)
libc_hidden_def(atoi)
#endif
#if defined(ULLONG_MAX) && (ULLONG_MAX == ULONG_MAX)
-#undef atoll
-extern __typeof(atol) atoll;
-strong_alias(atol,atoll)
+strong_alias_untyped(atol,atoll)
#endif
#endif
@@ -313,7 +240,6 @@ strong_alias(atol,atoll)
#if defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX)
-libc_hidden_proto(strtoll)
long long atoll(const char *nptr)
{
@@ -324,9 +250,16 @@ long long atoll(const char *nptr)
#endif
/**********************************************************************/
+#ifdef L_rpmatch
+int rpmatch (const char *__response)
+{
+ return (__response[0] == 'y' || __response[0] == 'Y') ? 1 :
+ (__response[0] == 'n' || __response[0] == 'N') ? 0 : -1;
+}
+#endif
+/**********************************************************************/
#if defined(L_strtol) || defined(L_strtol_l)
-libc_hidden_proto(__XL_NPP(strtol))
long __XL_NPP(strtol)(const char * __restrict str, char ** __restrict endptr,
int base __LOCALE_PARAM)
{
@@ -339,15 +272,11 @@ strong_alias(strtol,strtoimax)
#endif
#if defined(ULLONG_MAX) && (ULLONG_MAX == ULONG_MAX)
-#ifdef L_strtol_l
-#undef strtoll_l
-#else
-#undef strtoll
-#endif
-extern __typeof(strtol) __XL_NPP(strtoll);
-libc_hidden_proto(__XL_NPP(strtoll))
-strong_alias(__XL_NPP(strtol),__XL_NPP(strtoll))
+strong_alias_untyped(__XL_NPP(strtol),__XL_NPP(strtoll))
+#ifdef L_strtol
libc_hidden_def(__XL_NPP(strtoll))
+strong_alias(strtol,strtoq)
+#endif
#endif
#endif
@@ -356,16 +285,14 @@ libc_hidden_def(__XL_NPP(strtoll))
#if defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX)
-libc_hidden_proto(__XL_NPP(strtoll))
long long __XL_NPP(strtoll)(const char * __restrict str,
char ** __restrict endptr, int base
__LOCALE_PARAM)
{
return (long long) __XL_NPP(_stdlib_strto_ll)(str, endptr, base, 1 __LOCALE_ARG);
}
+#ifdef L_strtoll
libc_hidden_def(__XL_NPP(strtoll))
-
-#if !defined(L_strtoll_l)
#if (ULLONG_MAX == UINTMAX_MAX)
strong_alias(strtoll,strtoimax)
#endif
@@ -378,7 +305,6 @@ strong_alias(strtoll,strtoq)
/**********************************************************************/
#if defined(L_strtoul) || defined(L_strtoul_l)
-libc_hidden_proto(__XL_NPP(strtoul))
unsigned long __XL_NPP(strtoul)(const char * __restrict str,
char ** __restrict endptr, int base
__LOCALE_PARAM)
@@ -392,15 +318,10 @@ strong_alias(strtoul,strtoumax)
#endif
#if defined(ULLONG_MAX) && (ULLONG_MAX == ULONG_MAX)
-#ifdef L_strtoul_l
-#undef strtoull_l
-#else
-#undef strtoull
+strong_alias_untyped(__XL_NPP(strtoul),__XL_NPP(strtoull))
+#if !defined(L_strtoul_l)
+strong_alias(strtoul,strtouq)
#endif
-extern __typeof(strtoul) __XL_NPP(strtoull);
-libc_hidden_proto(__XL_NPP(strtoull))
-strong_alias(__XL_NPP(strtoul),__XL_NPP(strtoull))
-libc_hidden_def(__XL_NPP(strtoull))
#endif
@@ -410,14 +331,12 @@ libc_hidden_def(__XL_NPP(strtoull))
#if defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX)
-libc_hidden_proto(__XL_NPP(strtoull))
unsigned long long __XL_NPP(strtoull)(const char * __restrict str,
char ** __restrict endptr, int base
__LOCALE_PARAM)
{
return __XL_NPP(_stdlib_strto_ll)(str, endptr, base, 0 __LOCALE_ARG);
}
-libc_hidden_def(__XL_NPP(strtoull))
#if !defined(L_strtoull_l)
#if (ULLONG_MAX == UINTMAX_MAX)
@@ -465,10 +384,8 @@ strong_alias(strtoull,strtouq)
#define Wuchar __uwchar_t
#ifdef __UCLIBC_DO_XLOCALE
#define ISSPACE(C) iswspace_l((C), locale_arg)
-libc_hidden_proto(iswspace_l)
#else
#define ISSPACE(C) iswspace((C))
-libc_hidden_proto(iswspace)
#endif
#else /* defined(L__stdlib_wcsto_l) || defined(L__stdlib_wcsto_l_l) */
@@ -477,10 +394,8 @@ libc_hidden_proto(iswspace)
#define Wuchar unsigned char
#ifdef __UCLIBC_DO_XLOCALE
#define ISSPACE(C) isspace_l((C), locale_arg)
-libc_hidden_proto(isspace_l)
#else
#define ISSPACE(C) isspace((C))
-libc_hidden_proto(isspace)
#endif
#endif /* defined(L__stdlib_wcsto_l) || defined(L__stdlib_wcsto_l_l) */
@@ -500,12 +415,6 @@ unsigned long attribute_hidden _stdlib_strto_l(register const Wchar * __restrict
/* This is the main work fuction which handles both strtol (sflag = 1) and
* strtoul (sflag = 0). */
-#ifdef __UCLIBC_HAS_XLOCALE__
-libc_hidden_proto(__ctype_b_loc)
-#elif defined __UCLIBC_HAS_CTYPE_TABLES__
-libc_hidden_proto(__ctype_b)
-#endif
-
unsigned long attribute_hidden __XL_NPP(_stdlib_strto_l)(register const Wchar * __restrict str,
Wchar ** __restrict endptr, int base,
int sflag __LOCALE_PARAM)
@@ -620,10 +529,8 @@ unsigned long attribute_hidden __XL_NPP(_stdlib_strto_l)(register const Wchar *
#define Wuchar __uwchar_t
#ifdef __UCLIBC_DO_XLOCALE
#define ISSPACE(C) iswspace_l((C), locale_arg)
-libc_hidden_proto(iswspace_l)
#else
#define ISSPACE(C) iswspace((C))
-libc_hidden_proto(iswspace)
#endif
#else /* defined(L__stdlib_wcsto_ll) || defined(L__stdlib_wcsto_ll_l) */
@@ -632,10 +539,8 @@ libc_hidden_proto(iswspace)
#define Wuchar unsigned char
#ifdef __UCLIBC_DO_XLOCALE
#define ISSPACE(C) isspace_l((C), locale_arg)
-libc_hidden_proto(isspace_l)
#else
#define ISSPACE(C) isspace((C))
-libc_hidden_proto(isspace)
#endif
#endif /* defined(L__stdlib_wcsto_ll) || defined(L__stdlib_wcsto_ll_l) */
@@ -652,9 +557,6 @@ unsigned long long attribute_hidden _stdlib_strto_ll(register const Wchar * __re
#else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
-#if !defined __UCLIBC_HAS_XLOCALE__ && defined __UCLIBC_HAS_CTYPE_TABLES__
-libc_hidden_proto(__ctype_b)
-#endif
/* This is the main work fuction which handles both strtoll (sflag = 1) and
* strtoull (sflag = 0). */
@@ -765,17 +667,7 @@ unsigned long long attribute_hidden __XL_NPP(_stdlib_strto_ll)(register const Wc
#endif /* defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX) */
#endif
-/**********************************************************************/
-/* Made _Exit() an alias for _exit(), as per C99. */
-/* #ifdef L__Exit */
-/* libc_hidden_proto(_exit) */
-/* void _Exit(int status) */
-/* { */
-/* _exit(status); */
-/* } */
-
-/* #endif */
-/**********************************************************************/
+
#ifdef L_bsearch
void *bsearch(const void *key, const void *base, size_t /* nmemb */ high,
@@ -806,7 +698,7 @@ void *bsearch(const void *key, const void *base, size_t /* nmemb */ high,
#endif
/**********************************************************************/
-#ifdef L_qsort
+#ifdef L_qsort_r
/* This code is derived from a public domain shell sort routine by
* Ray Gardner and found in Bob Stout's snippets collection. The
@@ -816,11 +708,11 @@ void *bsearch(const void *key, const void *base, size_t /* nmemb */ high,
* calculation, as well as to reduce the generated code size with
* bcc and gcc. */
-libc_hidden_proto(qsort)
-void qsort(void *base,
+void qsort_r(void *base,
size_t nel,
size_t width,
- int (*comp)(const void *, const void *))
+ __compar_d_fn_t comp,
+ void *arg)
{
size_t wgap, i, j, k;
char tmp;
@@ -846,7 +738,7 @@ void qsort(void *base,
j -= wgap;
a = j + ((char *)base);
b = a + wgap;
- if ((*comp)(a, b) <= 0) {
+ if ((*comp)(a, b, arg) <= 0) {
break;
}
k = width;
@@ -862,7 +754,7 @@ void qsort(void *base,
} while (wgap);
}
}
-libc_hidden_def(qsort)
+libc_hidden_def(qsort_r)
/* ---------- original snippets version below ---------- */
@@ -909,14 +801,25 @@ void ssort(void *base,
#endif
#endif
+
+#ifdef L_qsort
+void qsort(void *base,
+ size_t nel,
+ size_t width,
+ __compar_fn_t comp)
+{
+ return qsort_r (base, nel, width, (__compar_d_fn_t) comp, NULL);
+}
+libc_hidden_def(qsort)
+#endif
+
/**********************************************************************/
#ifdef L__stdlib_mb_cur_max
-libc_hidden_proto(_stdlib_mb_cur_max)
size_t _stdlib_mb_cur_max(void)
{
#ifdef __CTYPE_HAS_UTF_8_LOCALES
- return __UCLIBC_CURLOCALE_DATA.mb_cur_max;
+ return __UCLIBC_CURLOCALE->mb_cur_max;
#else
#ifdef __CTYPE_HAS_8_BIT_LOCALES
#ifdef __UCLIBC_MJN3_ONLY__
@@ -936,7 +839,7 @@ libc_hidden_def(_stdlib_mb_cur_max)
* To note, until now all the supported encoding are stateless.
*/
-static inline int is_stateful(unsigned char encoding)
+static __always_inline int is_stateful(unsigned char encoding)
{
switch (encoding)
{
@@ -956,7 +859,6 @@ static inline int is_stateful(unsigned char encoding)
/**********************************************************************/
#ifdef L_mblen
-libc_hidden_proto(mbrlen)
int mblen(register const char *s, size_t n)
{
@@ -988,7 +890,6 @@ int mblen(register const char *s, size_t n)
/**********************************************************************/
#ifdef L_mbtowc
-libc_hidden_proto(mbrtowc)
int mbtowc(wchar_t *__restrict pwc, register const char *__restrict s, size_t n)
{
@@ -1023,7 +924,6 @@ int mbtowc(wchar_t *__restrict pwc, register const char *__restrict s, size_t n)
/* Note: We completely ignore state in all currently supported conversions. */
-libc_hidden_proto(wcrtomb)
int wctomb(register char *__restrict s, wchar_t swc)
{
@@ -1042,7 +942,6 @@ int wctomb(register char *__restrict s, wchar_t swc)
/**********************************************************************/
#ifdef L_mbstowcs
-libc_hidden_proto(mbsrtowcs)
size_t mbstowcs(wchar_t * __restrict pwcs, const char * __restrict s, size_t n)
{
@@ -1059,7 +958,6 @@ size_t mbstowcs(wchar_t * __restrict pwcs, const char * __restrict s, size_t n)
/* Note: We completely ignore state in all currently supported conversions. */
-libc_hidden_proto(wcsrtombs)
size_t wcstombs(char * __restrict s, const wchar_t * __restrict pwcs, size_t n)
{
@@ -1072,28 +970,18 @@ size_t wcstombs(char * __restrict s, const wchar_t * __restrict pwcs, size_t n)
/**********************************************************************/
#if defined(L_wcstol) || defined(L_wcstol_l)
-libc_hidden_proto(__XL_NPP(wcstol))
long __XL_NPP(wcstol)(const wchar_t * __restrict str,
wchar_t ** __restrict endptr, int base __LOCALE_PARAM)
{
return __XL_NPP(_stdlib_wcsto_l)(str, endptr, base, 1 __LOCALE_ARG);
}
-libc_hidden_def(__XL_NPP(wcstol))
#if (ULONG_MAX == UINTMAX_MAX) && !defined(L_wcstol_l)
strong_alias(wcstol,wcstoimax)
#endif
#if defined(ULLONG_MAX) && (ULLONG_MAX == ULONG_MAX)
-#ifdef L_wcstol_l
-#undef wcstoll_l
-#else
-#undef wcstoll
-#endif
-extern __typeof(wcstol) __XL_NPP(wcstoll);
-libc_hidden_proto(__XL_NPP(wcstoll))
-strong_alias(__XL_NPP(wcstol),__XL_NPP(wcstoll))
-libc_hidden_def(__XL_NPP(wcstoll))
+strong_alias_untyped(__XL_NPP(wcstol),__XL_NPP(wcstoll))
#endif
#endif
@@ -1102,14 +990,12 @@ libc_hidden_def(__XL_NPP(wcstoll))
#if defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX)
-libc_hidden_proto(__XL_NPP(wcstoll))
long long __XL_NPP(wcstoll)(const wchar_t * __restrict str,
wchar_t ** __restrict endptr, int base
__LOCALE_PARAM)
{
return (long long) __XL_NPP(_stdlib_wcsto_ll)(str, endptr, base, 1 __LOCALE_ARG);
}
-libc_hidden_def(__XL_NPP(wcstoll))
#if !defined(L_wcstoll_l)
#if (ULLONG_MAX == UINTMAX_MAX)
@@ -1124,29 +1010,19 @@ strong_alias(wcstoll,wcstoq)
/**********************************************************************/
#if defined(L_wcstoul) || defined(L_wcstoul_l)
-libc_hidden_proto(__XL_NPP(wcstoul))
unsigned long __XL_NPP(wcstoul)(const wchar_t * __restrict str,
wchar_t ** __restrict endptr, int base
__LOCALE_PARAM)
{
return __XL_NPP(_stdlib_wcsto_l)(str, endptr, base, 0 __LOCALE_ARG);
}
-libc_hidden_def(__XL_NPP(wcstoul))
#if (ULONG_MAX == UINTMAX_MAX) && !defined(L_wcstoul_l)
strong_alias(wcstoul,wcstoumax)
#endif
#if defined(ULLONG_MAX) && (ULLONG_MAX == ULONG_MAX)
-#ifdef L_wcstoul_l
-#undef wcstoull_l
-#else
-#undef wcstoull
-#endif
-extern __typeof(wcstoul) __XL_NPP(wcstoull);
-libc_hidden_proto(__XL_NPP(wcstoull))
-strong_alias(__XL_NPP(wcstoul),__XL_NPP(wcstoull))
-libc_hidden_def(__XL_NPP(wcstoull))
+strong_alias_untyped(__XL_NPP(wcstoul),__XL_NPP(wcstoull))
#endif
#endif
@@ -1155,14 +1031,12 @@ libc_hidden_def(__XL_NPP(wcstoull))
#if defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX)
-libc_hidden_proto(__XL_NPP(wcstoull))
unsigned long long __XL_NPP(wcstoull)(const wchar_t * __restrict str,
wchar_t ** __restrict endptr, int base
__LOCALE_PARAM)
{
return __XL_NPP(_stdlib_wcsto_ll)(str, endptr, base, 0 __LOCALE_ARG);
}
-libc_hidden_def(__XL_NPP(wcstoull))
#if !defined(L_wcstoull_l)
#if (ULLONG_MAX == UINTMAX_MAX)
diff --git a/libc/stdlib/system.c b/libc/stdlib/system.c
index 4d75a4077..771c30e3f 100644
--- a/libc/stdlib/system.c
+++ b/libc/stdlib/system.c
@@ -5,66 +5,259 @@
*/
#include <stdio.h>
+#include <string.h>
#include <stddef.h>
#include <signal.h>
#include <unistd.h>
#include <sys/wait.h>
#include <stdlib.h>
-
-libc_hidden_proto(_exit)
-libc_hidden_proto(wait4)
-libc_hidden_proto(execl)
-libc_hidden_proto(signal)
-libc_hidden_proto(vfork)
-
-/* uClinux-2.0 has vfork, but Linux 2.0 doesn't */
-#include <sys/syscall.h>
-#ifndef __NR_vfork
-# define vfork fork
-libc_hidden_proto(fork)
+#include <paths.h>
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <sched.h>
+#include <errno.h>
+#include <bits/libc-lock.h>
+#include <sysdep-cancel.h>
#endif
extern __typeof(system) __libc_system;
+#if !defined __UCLIBC_HAS_THREADS_NATIVE__
+#include <sys/syscall.h>
+
int __libc_system(const char *command)
{
int wait_val, pid;
- __sighandler_t save_quit, save_int, save_chld;
+ struct sigaction sa, save_quit, save_int;
+ sigset_t save_mask;
if (command == 0)
return 1;
- save_quit = signal(SIGQUIT, SIG_IGN);
- save_int = signal(SIGINT, SIG_IGN);
- save_chld = signal(SIGCHLD, SIG_DFL);
+ memset(&sa, 0, sizeof(sa));
+ sa.sa_handler = SIG_IGN;
+ /* __sigemptyset(&sa.sa_mask); - done by memset() */
+ /* sa.sa_flags = 0; - done by memset() */
+
+ sigaction(SIGQUIT, &sa, &save_quit);
+ sigaction(SIGINT, &sa, &save_int);
+ __sigaddset(&sa.sa_mask, SIGCHLD);
+ sigprocmask(SIG_BLOCK, &sa.sa_mask, &save_mask);
if ((pid = vfork()) < 0) {
- signal(SIGQUIT, save_quit);
- signal(SIGINT, save_int);
- signal(SIGCHLD, save_chld);
- return -1;
+ wait_val = -1;
+ goto out;
}
if (pid == 0) {
- signal(SIGQUIT, SIG_DFL);
- signal(SIGINT, SIG_DFL);
- signal(SIGCHLD, SIG_DFL);
+ sigaction(SIGQUIT, &save_quit, NULL);
+ sigaction(SIGINT, &save_int, NULL);
+ sigprocmask(SIG_SETMASK, &save_mask, NULL);
- execl("/bin/sh", "sh", "-c", command, (char *) 0);
+ execl(_PATH_BSHELL, "sh", "-c", command, (char *) 0);
_exit(127);
}
- /* Signals are not absolutly guarenteed with vfork */
- signal(SIGQUIT, SIG_IGN);
- signal(SIGINT, SIG_IGN);
#if 0
__printf("Waiting for child %d\n", pid);
#endif
- if (wait4(pid, &wait_val, 0, 0) == -1)
+ if (__wait4_nocancel(pid, &wait_val, 0, 0) == -1)
wait_val = -1;
- signal(SIGQUIT, save_quit);
- signal(SIGINT, save_int);
- signal(SIGCHLD, save_chld);
+out:
+ sigaction(SIGQUIT, &save_quit, NULL);
+ sigaction(SIGINT, &save_int, NULL);
+ sigprocmask(SIG_SETMASK, &save_mask, NULL);
return wait_val;
}
+#else
+/* We have to and actually can handle cancelable system(). The big
+ problem: we have to kill the child process if necessary. To do
+ this a cleanup handler has to be registered and is has to be able
+ to find the PID of the child. The main problem is to reliable have
+ the PID when needed. It is not necessary for the parent thread to
+ return. It might still be in the kernel when the cancellation
+ request comes. Therefore we have to use the clone() calls ability
+ to have the kernel write the PID into the user-level variable. */
+
+libc_hidden_proto(sigaction)
+libc_hidden_proto(waitpid)
+
+#if defined __ia64__
+# define FORK() \
+ INLINE_SYSCALL (clone2, 6, CLONE_PARENT_SETTID | SIGCHLD, NULL, 0, \
+ &pid, NULL, NULL)
+#elif defined __sparc__
+# define FORK() \
+ INLINE_CLONE_SYSCALL (CLONE_PARENT_SETTID | SIGCHLD, 0, &pid, NULL, NULL)
+#else
+# define FORK() \
+ INLINE_SYSCALL (clone, 3, CLONE_PARENT_SETTID | SIGCHLD, 0, &pid)
+#endif
+
+static void cancel_handler (void *arg);
+
+# define CLEANUP_HANDLER \
+ __libc_cleanup_region_start (1, cancel_handler, &pid)
+
+# define CLEANUP_RESET \
+ __libc_cleanup_region_end (0)
+
+static struct sigaction intr, quit;
+static int sa_refcntr;
+__libc_lock_define_initialized (static, lock);
+
+# define DO_LOCK() __libc_lock_lock (lock)
+# define DO_UNLOCK() __libc_lock_unlock (lock)
+# define INIT_LOCK() ({ __libc_lock_init (lock); sa_refcntr = 0; })
+# define ADD_REF() sa_refcntr++
+# define SUB_REF() --sa_refcntr
+
+/* Execute LINE as a shell command, returning its status. */
+static int
+do_system (const char *line)
+{
+ int status, save;
+ pid_t pid;
+ struct sigaction sa;
+ sigset_t omask;
+
+ memset(&sa, 0, sizeof(sa));
+ sa.sa_handler = SIG_IGN;
+ /*sa.sa_flags = 0; - done by memset */
+ /*__sigemptyset (&sa.sa_mask); - done by memset */
+
+ DO_LOCK ();
+ if (ADD_REF () == 0)
+ {
+ if (sigaction (SIGINT, &sa, &intr) < 0)
+ {
+ SUB_REF ();
+ goto out;
+ }
+ if (sigaction (SIGQUIT, &sa, &quit) < 0)
+ {
+ save = errno;
+ SUB_REF ();
+ goto out_restore_sigint;
+ }
+ }
+ DO_UNLOCK ();
+
+ /* We reuse the bitmap in the 'sa' structure. */
+ __sigaddset (&sa.sa_mask, SIGCHLD);
+ save = errno;
+ if (sigprocmask (SIG_BLOCK, &sa.sa_mask, &omask) < 0)
+ {
+ {
+ DO_LOCK ();
+ if (SUB_REF () == 0)
+ {
+ save = errno;
+ (void) sigaction (SIGQUIT, &quit, (struct sigaction *) NULL);
+ out_restore_sigint:
+ (void) sigaction (SIGINT, &intr, (struct sigaction *) NULL);
+ __set_errno (save);
+ }
+ out:
+ DO_UNLOCK ();
+ return -1;
+ }
+ }
+
+ CLEANUP_HANDLER;
+
+ pid = FORK ();
+ if (pid == (pid_t) 0)
+ {
+ /* Child side. */
+ const char *new_argv[4];
+ new_argv[0] = _PATH_BSHELL;
+ new_argv[1] = "-c";
+ new_argv[2] = line;
+ new_argv[3] = NULL;
+
+ /* Restore the signals. */
+ (void) sigaction (SIGINT, &intr, (struct sigaction *) NULL);
+ (void) sigaction (SIGQUIT, &quit, (struct sigaction *) NULL);
+ (void) sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL);
+ INIT_LOCK ();
+
+ /* Exec the shell. */
+ (void) execve (_PATH_BSHELL, (char *const *) new_argv, __environ);
+ _exit (127);
+ }
+ else if (pid < (pid_t) 0)
+ /* The fork failed. */
+ status = -1;
+ else
+ /* Parent side. */
+ {
+ /* Note the system() is a cancellation point. But since we call
+ waitpid() which itself is a cancellation point we do not
+ have to do anything here. */
+ if (TEMP_FAILURE_RETRY (waitpid (pid, &status, 0)) != pid)
+ status = -1;
+ }
+
+ CLEANUP_RESET;
+
+ save = errno;
+ DO_LOCK ();
+ if ((SUB_REF () == 0
+ && (sigaction (SIGINT, &intr, (struct sigaction *) NULL)
+ | sigaction (SIGQUIT, &quit, (struct sigaction *) NULL)) != 0)
+ || sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL) != 0)
+ {
+ status = -1;
+ }
+ DO_UNLOCK ();
+
+ return status;
+}
+
+
+int
+__libc_system (const char *line)
+{
+ if (line == NULL)
+ /* Check that we have a command processor available. It might
+ not be available after a chroot(), for example. */
+ return do_system ("exit 0") == 0;
+
+ if (SINGLE_THREAD_P)
+ return do_system (line);
+
+ int oldtype = LIBC_CANCEL_ASYNC ();
+
+ int result = do_system (line);
+
+ LIBC_CANCEL_RESET (oldtype);
+
+ return result;
+}
+
+
+/* The cancellation handler. */
+static void
+cancel_handler (void *arg)
+{
+ pid_t child = *(pid_t *) arg;
+
+ INTERNAL_SYSCALL_DECL (err);
+ INTERNAL_SYSCALL (kill, err, 2, child, SIGKILL);
+
+ TEMP_FAILURE_RETRY (waitpid (child, NULL, 0));
+
+ DO_LOCK ();
+
+ if (SUB_REF () == 0)
+ {
+ (void) sigaction (SIGQUIT, &quit, (struct sigaction *) NULL);
+ (void) sigaction (SIGINT, &intr, (struct sigaction *) NULL);
+ }
+
+ DO_UNLOCK ();
+}
+#endif
+#ifdef IS_IN_libc
weak_alias(__libc_system,system)
+#endif
diff --git a/libc/stdlib/unix_grantpt.c b/libc/stdlib/unix_grantpt.c
index d1eef9efd..66c18c0ed 100644
--- a/libc/stdlib/unix_grantpt.c
+++ b/libc/stdlib/unix_grantpt.c
@@ -14,8 +14,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 <assert.h>
#include <errno.h>
@@ -30,26 +29,6 @@
#include <unistd.h>
#include "pty-private.h"
-/* Experimentally off - libc_hidden_proto(memchr) */
-libc_hidden_proto(getgid)
-libc_hidden_proto(getuid)
-libc_hidden_proto(setrlimit)
-libc_hidden_proto(waitpid)
-libc_hidden_proto(dup2)
-libc_hidden_proto(chmod)
-libc_hidden_proto(chown)
-libc_hidden_proto(vfork)
-libc_hidden_proto(fork)
-libc_hidden_proto(stat)
-libc_hidden_proto(ptsname_r)
-libc_hidden_proto(execle)
-libc_hidden_proto(_exit)
-
-/* uClinux-2.0 has vfork, but Linux 2.0 doesn't */
-#include <sys/syscall.h>
-#if ! defined __NR_vfork
-#define vfork fork
-#endif
/* Return the result of ptsname_r in the buffer pointed to by PTS,
which should be of length BUF_LEN. If it is too long to fit in
@@ -89,7 +68,7 @@ pts_name (int fd, char **pts, size_t buf_len)
if (! new_buf)
{
rv = -1;
- errno = ENOMEM;
+ /* __set_errno(ENOMEM); */
break;
}
buf = new_buf;
diff --git a/libc/stdlib/unlockpt.c b/libc/stdlib/unlockpt.c
index 8c426553c..a4476e147 100644
--- a/libc/stdlib/unlockpt.c
+++ b/libc/stdlib/unlockpt.c
@@ -14,15 +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/>. */
#include <errno.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <termios.h>
-libc_hidden_proto(ioctl)
/* Unlock the slave pseudo terminal associated with the master pseudo
terminal specified by FD. */
diff --git a/libc/stdlib/valloc.c b/libc/stdlib/valloc.c
index 13dbe0f67..0351387c7 100644
--- a/libc/stdlib/valloc.c
+++ b/libc/stdlib/valloc.c
@@ -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 this 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/>.
The author may be reached (Email) at the address mike@@ai.mit.edu,
or (US mail) as Mike Haertel c/o Free Software Foundation. */
@@ -24,7 +23,6 @@ Cambridge, MA 02139, USA.
#include <unistd.h>
#include <malloc.h>
-libc_hidden_proto(getpagesize)
static size_t pagesize;
diff --git a/libc/string/Makefile.in b/libc/string/Makefile.in
index 2f14cc0e6..e7f2ccde1 100644
--- a/libc/string/Makefile.in
+++ b/libc/string/Makefile.in
@@ -1,10 +1,12 @@
# 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.
#
+subdirs += libc/string/$(TARGET_ARCH) libc/string/generic
+
#
# Arch specific fun
#
@@ -16,7 +18,10 @@ STRING_SUBARCH_OUT := $(top_builddir)libc/string/$(TARGET_ARCH)/$(TARGET_SUBARCH
STRING_SUBARCH_SSRC := $(wildcard $(STRING_SUBARCH_OUT)/*.S)
STRING_SUBARCH_SOBJ := $(patsubst $(STRING_SUBARCH_DIR)/%.S,$(STRING_SUBARCH_OUT)/%.o,$(STRING_SUBARCH_SSRC))
-STRING_SUBARCH_OBJS := $(STRING_SUBARCH_SOBJ)
+STRING_SUBARCH_CSRC := $(wildcard $(STRING_SUBARCH_OUT)/*.c)
+STRING_SUBARCH_COBJ := $(patsubst $(STRING_SUBARCH_DIR)/%.c,$(STRING_SUBARCH_OUT)/%.o,$(STRING_SUBARCH_CSRC))
+
+STRING_SUBARCH_OBJS := $(STRING_SUBARCH_SOBJ) $(STRING_SUBARCH_COBJ)
endif
# Collect the arch specific implementation (asm, c files)
@@ -133,7 +138,7 @@ libc-y += $(STRING_COBJ)
libc-nomulti-$(UCLIBC_HAS_XLOCALE) += $(STRING_OUT)/wcsxfrm_l.o
libc-nomulti-y += $(STRING_OUT)/__xpg_strerror_r.o
-objclean-y += string_objclean
+objclean-y += CLEAN_libc/string
-string_objclean:
- $(RM) $(STRING_OUT)/{,*/}{,*/}*.{o,os,oS}
+CLEAN_libc/string:
+ $(do_rm) $(addprefix $(STRING_OUT)/,$(addprefix *., o os oS) $(addprefix */*., o os oS) $(addprefix */*/*., o os oS))
diff --git a/libc/string/__glibc_strerror_r.c b/libc/string/__glibc_strerror_r.c
index 0f9cd16a9..96b881700 100644
--- a/libc/string/__glibc_strerror_r.c
+++ b/libc/string/__glibc_strerror_r.c
@@ -5,11 +5,13 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+/* get rid of REDIRECT */
+#define strerror_r __hide_strerror_r
+
#include <features.h>
#include <string.h>
-libc_hidden_proto(__glibc_strerror_r)
-libc_hidden_proto(__xpg_strerror_r)
+#undef strerror_r
char *__glibc_strerror_r(int errnum, char *strerrbuf, size_t buflen)
{
@@ -18,3 +20,6 @@ char *__glibc_strerror_r(int errnum, char *strerrbuf, size_t buflen)
return strerrbuf;
}
libc_hidden_def(__glibc_strerror_r)
+#if !defined __USE_XOPEN2K || defined __USE_GNU
+strong_alias(__glibc_strerror_r,strerror_r)
+#endif
diff --git a/libc/string/__xpg_basename.c b/libc/string/__xpg_basename.c
index 2449d1d42..2e7ade913 100644
--- a/libc/string/__xpg_basename.c
+++ b/libc/string/__xpg_basename.c
@@ -5,7 +5,6 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#include "_string.h"
#include <libgen.h>
char *__xpg_basename(register char *path)
@@ -34,3 +33,7 @@ char *__xpg_basename(register char *path)
return first;
}
+#ifndef __USE_GNU
+# undef basename
+weak_alias(__xpg_basename,basename)
+#endif
diff --git a/libc/string/__xpg_strerror_r.c b/libc/string/__xpg_strerror_r.c
index ff41192e5..3e78da1be 100644
--- a/libc/string/__xpg_strerror_r.c
+++ b/libc/string/__xpg_strerror_r.c
@@ -5,8 +5,8 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-/* Make sure we get proper strerror_r() prototype */
-#define strerror_r _hidestrerror_r
+/* get rid of REDIRECT */
+#define strerror_r __hide_strerror_r
#include <features.h>
#include <errno.h>
@@ -15,10 +15,6 @@
#undef strerror_r
-libc_hidden_proto(__xpg_strerror_r)
-/* Experimentally off - libc_hidden_proto(memcpy) */
-/* Experimentally off - libc_hidden_proto(strlen) */
-
#ifdef __UCLIBC_HAS_ERRNO_MESSAGES__
extern const char _string_syserrmsgs[] attribute_hidden;
@@ -276,4 +272,6 @@ int __xpg_strerror_r(int errnum, char *strerrbuf, size_t buflen)
#endif /* __UCLIBC_HAS_ERRNO_MESSAGES__ */
libc_hidden_def(__xpg_strerror_r)
-weak_alias(__xpg_strerror_r, strerror_r)
+#if defined __USE_XOPEN2K && !defined __USE_GNU
+strong_alias(__xpg_strerror_r,strerror_r)
+#endif
diff --git a/libc/string/_collate.c b/libc/string/_collate.c
index 64b5d9608..93501b85e 100644
--- a/libc/string/_collate.c
+++ b/libc/string/_collate.c
@@ -19,15 +19,6 @@
#include <errno.h>
#include <assert.h>
-/* Experimentally off - libc_hidden_proto(memset) */
-/* Experimentally off - libc_hidden_proto(memcpy) */
-/* Experimentally off - libc_hidden_proto(strlcpy) */
-/* Experimentally off - libc_hidden_proto(strcmp) */
-#ifdef WANT_WIDE
-libc_hidden_proto(wcsxfrm)
-libc_hidden_proto(wcscmp)
-#endif
-
#ifdef __UCLIBC_HAS_LOCALE__
#if defined(L_strxfrm) || defined(L_strxfrm_l) || defined(L_wcsxfrm) || defined(L_wcsxfrm_l)
@@ -59,29 +50,24 @@ libc_hidden_proto(wcscmp)
#if defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE)
-libc_hidden_proto(wcscoll_l)
-libc_hidden_proto(wcscoll)
int wcscoll (const Wchar *s0, const Wchar *s1)
{
return wcscoll_l(s0, s1, __UCLIBC_CURLOCALE );
}
libc_hidden_def(wcscoll)
-libc_hidden_proto(wcsxfrm_l)
-libc_hidden_proto(wcsxfrm)
size_t wcsxfrm(Wchar *__restrict ws1, const Wchar *__restrict ws2, size_t n)
{
return wcsxfrm_l(ws1, ws2, n, __UCLIBC_CURLOCALE );
}
-libc_hidden_def(wcsxfrm)
#else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
#if 0
-#define CUR_COLLATE (&__UCLIBC_CURLOCALE_DATA.collate)
+#define CUR_COLLATE (&__UCLIBC_CURLOCALE->collate)
#else
#define CUR_COLLATE (& __LOCALE_PTR->collate)
#endif
@@ -173,7 +159,7 @@ static void next_weight(col_state_t *cs, int pass __LOCALE_PARAM )
#define N (1)
#else /* WANT_WIDE */
wchar_t WC;
- size_t n0, nx;
+ size_t n0, nx = 0;
#define N n0
#endif /* WANT_WIDE */
@@ -381,7 +367,7 @@ static void next_weight(col_state_t *cs, int pass __LOCALE_PARAM )
if (cs->back_buf == cs->ibb) { /* was using internal buffer */
cs->bp = malloc(cs->bb_size + 128);
if (!cs->bp) {
- __set_errno(ENOMEM);
+ /* __set_errno(ENOMEM); */
#ifdef __UCLIBC_MJN3_ONLY__
#warning what to do here?
#endif
@@ -393,7 +379,7 @@ static void next_weight(col_state_t *cs, int pass __LOCALE_PARAM )
} else {
cs->bp = realloc(cs->back_buf, cs->bb_size + 128);
if (!cs->bp) {
- __set_errno(ENOMEM);
+ /* __set_errno(ENOMEM); */
#ifdef __UCLIBC_MJN3_ONLY__
#warning what to do here?
#endif
@@ -513,7 +499,6 @@ static void next_weight(col_state_t *cs, int pass __LOCALE_PARAM )
} while (1);
}
-libc_hidden_proto(__XL_NPP(wcscoll))
int __XL_NPP(wcscoll) (const Wchar *s0, const Wchar *s1 __LOCALE_PARAM )
{
col_state_t ws[2];
@@ -522,9 +507,9 @@ int __XL_NPP(wcscoll) (const Wchar *s0, const Wchar *s1 __LOCALE_PARAM )
if (!CUR_COLLATE->num_weights) { /* C locale */
#ifdef WANT_WIDE
return wcscmp(s0, s1);
-#else /* WANT_WIDE */
+#else
return strcmp(s0, s1);
-#endif /* WANT_WIDE */
+#endif
}
pass = 0;
@@ -551,10 +536,6 @@ libc_hidden_def(__XL_NPP(wcscoll))
#ifdef WANT_WIDE
-extern size_t __wcslcpy(wchar_t *__restrict dst,
- const wchar_t *__restrict src, size_t n);
-
-libc_hidden_proto(__XL_NPP(wcsxfrm))
size_t __XL_NPP(wcsxfrm)(wchar_t *__restrict ws1, const wchar_t *__restrict ws2,
size_t n __LOCALE_PARAM )
{
@@ -592,7 +573,9 @@ size_t __XL_NPP(wcsxfrm)(wchar_t *__restrict ws1, const wchar_t *__restrict ws2,
}
return count-1;
}
+#if defined L_strxfrm_l || defined L_wcsxfrm_l
libc_hidden_def(__XL_NPP(wcsxfrm))
+#endif
#else /* WANT_WIDE */
@@ -636,7 +619,6 @@ static size_t store(unsigned char *s, size_t count, size_t n, __uwchar_t weight)
return r;
}
-libc_hidden_proto(__XL_NPP(strxfrm))
size_t __XL_NPP(strxfrm)(char *__restrict ws1, const char *__restrict ws2, size_t n
__LOCALE_PARAM )
{
@@ -674,7 +656,9 @@ size_t __XL_NPP(strxfrm)(char *__restrict ws1, const char *__restrict ws2, size_
}
return count-1;
}
+#ifdef L_strxfrm_l
libc_hidden_def(__XL_NPP(strxfrm))
+#endif
#endif /* WANT_WIDE */
diff --git a/libc/string/arc/Makefile b/libc/string/arc/Makefile
new file mode 100755
index 000000000..523cf6842
--- /dev/null
+++ b/libc/string/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.in
+include $(top_srcdir)Makerules
diff --git a/libc/string/arc/arcv2/memcpy.S b/libc/string/arc/arcv2/memcpy.S
new file mode 100644
index 000000000..7573daf51
--- /dev/null
+++ b/libc/string/arc/arcv2/memcpy.S
@@ -0,0 +1,236 @@
+/*
+ * Copyright (C) 2014-15 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 <sysdep.h>
+
+#ifdef __LITTLE_ENDIAN__
+# define SHIFT_1(RX,RY,IMM) asl RX, RY, IMM ; <<
+# define SHIFT_2(RX,RY,IMM) lsr RX, RY, IMM ; >>
+# define MERGE_1(RX,RY,IMM) asl RX, RY, IMM
+# define MERGE_2(RX,RY,IMM)
+# define EXTRACT_1(RX,RY,IMM) and RX, RY, 0xFFFF
+# define EXTRACT_2(RX,RY,IMM) lsr RX, RY, IMM
+#else
+# define SHIFT_1(RX,RY,IMM) lsr RX, RY, IMM ; >>
+# define SHIFT_2(RX,RY,IMM) asl RX, RY, IMM ; <<
+# define MERGE_1(RX,RY,IMM) asl RX, RY, IMM ; <<
+# define MERGE_2(RX,RY,IMM) asl RX, RY, IMM ; <<
+# define EXTRACT_1(RX,RY,IMM) lsr RX, RY, IMM
+# define EXTRACT_2(RX,RY,IMM) lsr RX, RY, 0x08
+#endif
+
+#ifdef __LL64__
+# define PREFETCH_READ(RX) prefetch [RX, 56]
+# define PREFETCH_WRITE(RX) prefetchw [RX, 64]
+# define LOADX(DST,RX) ldd.ab DST, [RX, 8]
+# define STOREX(SRC,RX) std.ab SRC, [RX, 8]
+# define ZOLSHFT 5
+# define ZOLAND 0x1F
+#else
+# define PREFETCH_READ(RX) prefetch [RX, 28]
+# define PREFETCH_WRITE(RX) prefetchw [RX, 32]
+# define LOADX(DST,RX) ld.ab DST, [RX, 4]
+# define STOREX(SRC,RX) st.ab SRC, [RX, 4]
+# define ZOLSHFT 4
+# define ZOLAND 0xF
+#endif
+
+ENTRY(memcpy)
+ prefetch [r1] ; Prefetch the read location
+ prefetchw [r0] ; Prefetch the write location
+ mov.f 0, r2
+;;; if size is zero
+ jz.d [blink]
+ mov r3, r0 ; don't clobber ret val
+
+;;; if size <= 8
+ cmp r2, 8
+ bls.d @.Lsmallchunk
+ mov.f lp_count, r2
+
+ and.f r4, r0, 0x03
+ rsub lp_count, r4, 4
+ lpnz @.Laligndestination
+ ;; LOOP BEGIN
+ ldb.ab r5, [r1,1]
+ sub r2, r2, 1
+ stb.ab r5, [r3,1]
+.Laligndestination:
+
+;;; Check the alignment of the source
+ and.f r4, r1, 0x03
+ bnz.d @.Lsourceunaligned
+
+;;; CASE 0: Both source and destination are 32bit aligned
+;;; Convert len to Dwords, unfold x4
+ lsr.f lp_count, r2, ZOLSHFT
+ lpnz @.Lcopy32_64bytes
+ ;; LOOP START
+ LOADX (r6, r1)
+ PREFETCH_READ (r1)
+ PREFETCH_WRITE (r3)
+ LOADX (r8, r1)
+ LOADX (r10, r1)
+ LOADX (r4, r1)
+ STOREX (r6, r3)
+ STOREX (r8, r3)
+ STOREX (r10, r3)
+ STOREX (r4, r3)
+.Lcopy32_64bytes:
+
+ and.f lp_count, r2, ZOLAND ;Last remaining 31 bytes
+.Lsmallchunk:
+ lpnz @.Lcopyremainingbytes
+ ;; LOOP START
+ ldb.ab r5, [r1,1]
+ stb.ab r5, [r3,1]
+.Lcopyremainingbytes:
+
+ j [blink]
+;;; END CASE 0
+
+.Lsourceunaligned:
+ cmp r4, 2
+ beq.d @.LunalignedOffby2
+ sub r2, r2, 1
+
+ bhi.d @.LunalignedOffby3
+ ldb.ab r5, [r1, 1]
+
+;;; CASE 1: The source is unaligned, off by 1
+ ;; Hence I need to read 1 byte for a 16bit alignment
+ ;; and 2bytes to reach 32bit alignment
+ ldh.ab r6, [r1, 2]
+ sub r2, r2, 2
+ ;; Convert to words, unfold x2
+ lsr.f lp_count, r2, 3
+ MERGE_1 (r6, r6, 8)
+ MERGE_2 (r5, r5, 24)
+ or r5, r5, r6
+
+ ;; Both src and dst are aligned
+ lpnz @.Lcopy8bytes_1
+ ;; LOOP START
+ ld.ab r6, [r1, 4]
+ prefetch [r1, 28] ;Prefetch the next read location
+ ld.ab r8, [r1,4]
+ prefetchw [r3, 32] ;Prefetch the next write location
+
+ SHIFT_1 (r7, r6, 24)
+ or r7, r7, r5
+ SHIFT_2 (r5, r6, 8)
+
+ SHIFT_1 (r9, r8, 24)
+ or r9, r9, r5
+ SHIFT_2 (r5, r8, 8)
+
+ st.ab r7, [r3, 4]
+ st.ab r9, [r3, 4]
+.Lcopy8bytes_1:
+
+ ;; Write back the remaining 16bits
+ EXTRACT_1 (r6, r5, 16)
+ sth.ab r6, [r3, 2]
+ ;; Write back the remaining 8bits
+ EXTRACT_2 (r5, r5, 16)
+ stb.ab r5, [r3, 1]
+
+ and.f lp_count, r2, 0x07 ;Last 8bytes
+ lpnz @.Lcopybytewise_1
+ ;; LOOP START
+ ldb.ab r6, [r1,1]
+ stb.ab r6, [r3,1]
+.Lcopybytewise_1:
+ j [blink]
+
+.LunalignedOffby2:
+;;; CASE 2: The source is unaligned, off by 2
+ ldh.ab r5, [r1, 2]
+ sub r2, r2, 1
+
+ ;; Both src and dst are aligned
+ ;; Convert to words, unfold x2
+ lsr.f lp_count, r2, 3
+#ifdef __BIG_ENDIAN__
+ asl.nz r5, r5, 16
+#endif
+ lpnz @.Lcopy8bytes_2
+ ;; LOOP START
+ ld.ab r6, [r1, 4]
+ prefetch [r1, 28] ;Prefetch the next read location
+ ld.ab r8, [r1,4]
+ prefetchw [r3, 32] ;Prefetch the next write location
+
+ SHIFT_1 (r7, r6, 16)
+ or r7, r7, r5
+ SHIFT_2 (r5, r6, 16)
+
+ SHIFT_1 (r9, r8, 16)
+ or r9, r9, r5
+ SHIFT_2 (r5, r8, 16)
+
+ st.ab r7, [r3, 4]
+ st.ab r9, [r3, 4]
+.Lcopy8bytes_2:
+
+#ifdef __BIG_ENDIAN__
+ lsr.nz r5, r5, 16
+#endif
+ sth.ab r5, [r3, 2]
+
+ and.f lp_count, r2, 0x07 ;Last 8bytes
+ lpnz @.Lcopybytewise_2
+ ;; LOOP START
+ ldb.ab r6, [r1,1]
+ stb.ab r6, [r3,1]
+.Lcopybytewise_2:
+ j [blink]
+
+.LunalignedOffby3:
+;;; CASE 3: The source is unaligned, off by 3
+;;; Hence, I need to read 1byte for achieve the 32bit alignment
+
+ ;; Both src and dst are aligned
+ ;; Convert to words, unfold x2
+ lsr.f lp_count, r2, 3
+#ifdef __BIG_ENDIAN__
+ asl.ne r5, r5, 24
+#endif
+ lpnz @.Lcopy8bytes_3
+ ;; LOOP START
+ ld.ab r6, [r1, 4]
+ prefetch [r1, 28] ;Prefetch the next read location
+ ld.ab r8, [r1,4]
+ prefetchw [r3, 32] ;Prefetch the next write location
+
+ SHIFT_1 (r7, r6, 8)
+ or r7, r7, r5
+ SHIFT_2 (r5, r6, 24)
+
+ SHIFT_1 (r9, r8, 8)
+ or r9, r9, r5
+ SHIFT_2 (r5, r8, 24)
+
+ st.ab r7, [r3, 4]
+ st.ab r9, [r3, 4]
+.Lcopy8bytes_3:
+
+#ifdef __BIG_ENDIAN__
+ lsr.nz r5, r5, 24
+#endif
+ stb.ab r5, [r3, 1]
+
+ and.f lp_count, r2, 0x07 ;Last 8bytes
+ lpnz @.Lcopybytewise_3
+ ;; LOOP START
+ ldb.ab r6, [r1,1]
+ stb.ab r6, [r3,1]
+.Lcopybytewise_3:
+ j [blink]
+
+END(memcpy)
+libc_hidden_def(memcpy)
diff --git a/libc/string/arc/arcv2/memset.S b/libc/string/arc/arcv2/memset.S
new file mode 100644
index 000000000..0918d3774
--- /dev/null
+++ b/libc/string/arc/arcv2/memset.S
@@ -0,0 +1,115 @@
+
+/*
+ * Copyright (C) 2014-15 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 <sysdep.h>
+
+#ifdef DONT_USE_PREALLOC
+#define PREWRITE(A,B) prefetchw [(A),(B)]
+#else
+#define PREWRITE(A,B) prealloc [(A),(B)]
+#endif
+
+ENTRY(memset)
+ prefetchw [r0] ; Prefetch the write location
+ mov.f 0, r2
+;;; if size is zero
+ jz.d [blink]
+ mov r3, r0 ; don't clobber ret val
+
+;;; if length < 8
+ brls.d.nt r2, 8, .Lsmallchunk
+ mov.f lp_count,r2
+
+ and.f r4, r0, 0x03
+ rsub lp_count, r4, 4
+ lpnz @.Laligndestination
+ ;; LOOP BEGIN
+ stb.ab r1, [r3,1]
+ sub r2, r2, 1
+.Laligndestination:
+
+;;; Destination is aligned
+ and r1, r1, 0xFF
+ asl r4, r1, 8
+ or r4, r4, r1
+ asl r5, r4, 16
+ or r5, r5, r4
+ mov r4, r5
+
+ sub3 lp_count, r2, 8
+ cmp r2, 64
+ bmsk.hi r2, r2, 5
+ mov.ls lp_count, 0
+ add3.hi r2, r2, 8
+
+;;; Convert len to Dwords, unfold x8
+ lsr.f lp_count, lp_count, 6
+ lpnz @.Lset64bytes
+ ;; LOOP START
+ PREWRITE(r3, 64) ;Prefetch the next write location
+#ifdef __LL64__
+ std.ab r4, [r3, 8]
+ std.ab r4, [r3, 8]
+ std.ab r4, [r3, 8]
+ std.ab r4, [r3, 8]
+ std.ab r4, [r3, 8]
+ std.ab r4, [r3, 8]
+ std.ab r4, [r3, 8]
+ std.ab r4, [r3, 8]
+#else
+ st.ab r4, [r3, 4]
+ st.ab r4, [r3, 4]
+ st.ab r4, [r3, 4]
+ st.ab r4, [r3, 4]
+ st.ab r4, [r3, 4]
+ st.ab r4, [r3, 4]
+ st.ab r4, [r3, 4]
+ st.ab r4, [r3, 4]
+ st.ab r4, [r3, 4]
+ st.ab r4, [r3, 4]
+ st.ab r4, [r3, 4]
+ st.ab r4, [r3, 4]
+ st.ab r4, [r3, 4]
+ st.ab r4, [r3, 4]
+ st.ab r4, [r3, 4]
+ st.ab r4, [r3, 4]
+#endif
+.Lset64bytes:
+
+ lsr.f lp_count, r2, 5 ;Last remaining max 124 bytes
+ lpnz .Lset32bytes
+ ;; LOOP START
+ prefetchw [r3, 32] ;Prefetch the next write location
+#ifdef __LL64__
+ std.ab r4, [r3, 8]
+ std.ab r4, [r3, 8]
+ std.ab r4, [r3, 8]
+ std.ab r4, [r3, 8]
+#else
+ st.ab r4, [r3, 4]
+ st.ab r4, [r3, 4]
+ st.ab r4, [r3, 4]
+ st.ab r4, [r3, 4]
+ st.ab r4, [r3, 4]
+ st.ab r4, [r3, 4]
+ st.ab r4, [r3, 4]
+ st.ab r4, [r3, 4]
+#endif
+.Lset32bytes:
+
+ and.f lp_count, r2, 0x1F ;Last remaining 31 bytes
+.Lsmallchunk:
+ lpnz .Lcopy3bytes
+ ;; LOOP START
+ stb.ab r1, [r3, 1]
+.Lcopy3bytes:
+
+ j [blink]
+
+END(memset)
+libc_hidden_def(memset)
diff --git a/libc/string/arc/arcv2/strcmp.S b/libc/string/arc/arcv2/strcmp.S
new file mode 100644
index 000000000..2e0e64a0c
--- /dev/null
+++ b/libc/string/arc/arcv2/strcmp.S
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2014-15 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 <sysdep.h>
+
+ENTRY(strcmp)
+ or r2, r0, r1
+ bmsk_s r2, r2, 1
+ brne r2, 0, @.Lcharloop
+
+;;; s1 and s2 are word aligned
+ ld.ab r2, [r0, 4]
+
+ mov_s r12, 0x01010101
+ ror r11, r12
+ .align 4
+.LwordLoop:
+ ld.ab r3, [r1, 4]
+ ;; Detect NULL char in str1
+ sub r4, r2, r12
+ ld.ab r5, [r0, 4]
+ bic r4, r4, r2
+ and r4, r4, r11
+ brne.d.nt r4, 0, .LfoundNULL
+ ;; Check if the read locations are the same
+ cmp r2, r3
+ beq.d .LwordLoop
+ mov.eq r2, r5
+
+ ;; A match is found, spot it out
+#ifdef __LITTLE_ENDIAN__
+ swape r3, r3
+ mov_s r0, 1
+ swape r2, r2
+#else
+ mov_s r0, 1
+#endif
+ cmp_s r2, r3
+ j_s.d [blink]
+ bset.lo r0, r0, 31
+
+ .align 4
+.LfoundNULL:
+#ifdef __BIG_ENDIAN__
+ swape r4, r4
+ swape r2, r2
+ swape r3, r3
+#endif
+ ;; Find null byte
+ ffs r0, r4
+ bmsk r2, r2, r0
+ bmsk r3, r3, r0
+ swape r2, r2
+ swape r3, r3
+ ;; make the return value
+ sub.f r0, r2, r3
+ mov.hi r0, 1
+ j_s.d [blink]
+ bset.lo r0, r0, 31
+
+ .align 4
+.Lcharloop:
+ ldb.ab r2, [r0, 1]
+ ldb.ab r3, [r1, 1]
+ nop
+ breq r2, 0, .Lcmpend
+ breq r2, r3, .Lcharloop
+
+ .align 4
+.Lcmpend:
+ j_s.d [blink]
+ sub r0, r2, r3
+END(strcmp)
+libc_hidden_def(strcmp)
+
+#ifndef __UCLIBC_HAS_LOCALE__
+strong_alias(strcmp,strcoll)
+libc_hidden_def(strcoll)
+#endif
diff --git a/libc/string/arc/memcmp.S b/libc/string/arc/memcmp.S
new file mode 100644
index 000000000..a60757e7a
--- /dev/null
+++ b/libc/string/arc/memcmp.S
@@ -0,0 +1,157 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ * Copyright (C) 2007 ARC International (UK) LTD
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sysdep.h>
+#include <features.h>
+
+#ifdef __LITTLE_ENDIAN__
+#define WORD2 r2
+#define SHIFT r3
+#else /* BIG ENDIAN */
+#define WORD2 r3
+#define SHIFT r2
+#endif
+
+ENTRY(memcmp)
+ or r12,r0,r1
+ asl_s r12,r12,30
+ sub r3,r2,1
+ brls r2,r12,.Lbytewise
+ ld r4,[r0,0]
+ ld r5,[r1,0]
+ lsr.f lp_count,r3,3
+#ifdef __HS__
+ /* In ARCv2 a branch can't be the last instruction in a zero overhead
+ * loop.
+ * So we move the branch to the start of the loop, duplicate it
+ * after the end, and set up r12 so that the branch isn't taken
+ * initially.
+ */
+ mov_s r12,WORD2
+ lpne .Loop_end
+ brne WORD2,r12,.Lodd
+ ld WORD2,[r0,4]
+#else
+ lpne .Loop_end
+ ld_s WORD2,[r0,4]
+#endif
+ ld_s r12,[r1,4]
+ brne r4,r5,.Leven
+ ld.a r4,[r0,8]
+ ld.a r5,[r1,8]
+#ifdef __HS__
+.Loop_end:
+ brne WORD2,r12,.Lodd
+#else
+ brne WORD2,r12,.Lodd
+.Loop_end:
+#endif
+ asl_s SHIFT,SHIFT,3
+ bhs_s .Last_cmp
+ brne r4,r5,.Leven
+ ld r4,[r0,4]
+ ld r5,[r1,4]
+#ifdef __LITTLE_ENDIAN__
+ nop_s
+ ; one more load latency cycle
+.Last_cmp:
+ xor r0,r4,r5
+ bset r0,r0,SHIFT
+ sub_s r1,r0,1
+ bic_s r1,r1,r0
+ norm r1,r1
+ b.d .Leven_cmp
+ and r1,r1,24
+.Leven:
+ xor r0,r4,r5
+ sub_s r1,r0,1
+ bic_s r1,r1,r0
+ norm r1,r1
+ ; slow track insn
+ and r1,r1,24
+.Leven_cmp:
+ asl r2,r4,r1
+ asl r12,r5,r1
+ lsr_s r2,r2,1
+ lsr_s r12,r12,1
+ j_s.d [blink]
+ sub r0,r2,r12
+ .balign 4
+.Lodd:
+ xor r0,WORD2,r12
+ sub_s r1,r0,1
+ bic_s r1,r1,r0
+ norm r1,r1
+ ; slow track insn
+ and r1,r1,24
+ asl_s r2,r2,r1
+ asl_s r12,r12,r1
+ lsr_s r2,r2,1
+ lsr_s r12,r12,1
+ j_s.d [blink]
+ sub r0,r2,r12
+#else /* BIG ENDIAN */
+.Last_cmp:
+ neg_s SHIFT,SHIFT
+ lsr r4,r4,SHIFT
+ lsr r5,r5,SHIFT
+ ; slow track insn
+.Leven:
+ sub.f r0,r4,r5
+ mov.ne r0,1
+ j_s.d [blink]
+ bset.cs r0,r0,31
+.Lodd:
+ cmp_s WORD2,r12
+ mov_s r0,1
+ j_s.d [blink]
+ bset.cs r0,r0,31
+#endif /* ENDIAN */
+ .balign 4
+.Lbytewise:
+ breq r2,0,.Lnil
+ ldb r4,[r0,0]
+ ldb r5,[r1,0]
+ lsr.f lp_count,r3
+#ifdef __HS__
+ mov r12,r3
+ lpne .Lbyte_end
+ brne r3,r12,.Lbyte_odd
+#else
+ lpne .Lbyte_end
+#endif
+ ldb_s r3,[r0,1]
+ ldb r12,[r1,1]
+ brne r4,r5,.Lbyte_even
+ ldb.a r4,[r0,2]
+ ldb.a r5,[r1,2]
+#ifdef __HS__
+.Lbyte_end:
+ brne r3,r12,.Lbyte_odd
+#else
+ brne r3,r12,.Lbyte_odd
+.Lbyte_end:
+#endif
+ bcc .Lbyte_even
+ brne r4,r5,.Lbyte_even
+ ldb_s r3,[r0,1]
+ ldb_s r12,[r1,1]
+.Lbyte_odd:
+ j_s.d [blink]
+ sub r0,r3,r12
+.Lbyte_even:
+ j_s.d [blink]
+ sub r0,r4,r5
+.Lnil:
+ j_s.d [blink]
+ mov r0,0
+END(memcmp)
+libc_hidden_def(memcmp)
+
+#ifdef __UCLIBC_SUSV3_LEGACY__
+strong_alias(memcmp,bcmp)
+#endif
diff --git a/libc/string/arc/memcpy.S b/libc/string/arc/memcpy.S
new file mode 100644
index 000000000..1c11951e4
--- /dev/null
+++ b/libc/string/arc/memcpy.S
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ * Copyright (C) 2007 ARC International (UK) LTD
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sysdep.h>
+
+/* This memcpy implementation does not support objects of 1GB or larger -
+ the check for alignment does not work then. */
+/* We assume that most sources and destinations are aligned, and
+ that also lengths are mostly a multiple of four, although to a lesser
+ extent. */
+ENTRY(memcpy)
+ or r3,r0,r1
+ asl_s r3,r3,30
+ mov_s r5,r0
+ brls.d r2,r3,.Lcopy_bytewise
+ sub.f r3,r2,1
+ ld_s r12,[r1,0]
+ asr.f lp_count,r3,3
+ bbit0.d r3,2,.Lnox4
+ bmsk_s r2,r2,1
+ st.ab r12,[r5,4]
+ ld.a r12,[r1,4]
+.Lnox4:
+ lppnz .Lendloop
+ ld_s r3,[r1,4]
+ st.ab r12,[r5,4]
+ ld.a r12,[r1,8]
+ st.ab r3,[r5,4]
+.Lendloop:
+ breq r2,0,.Last_store
+ ld r3,[r5,0]
+#ifdef __LITTLE_ENDIAN__
+ add3 r2,-1,r2
+ ; uses long immediate
+ xor_s r12,r12,r3
+ bmsk r12,r12,r2
+ xor_s r12,r12,r3
+#else /* BIG ENDIAN */
+ sub3 r2,31,r2
+ ; uses long immediate
+ xor_s r3,r3,r12
+ bmsk r3,r3,r2
+ xor_s r12,r12,r3
+#endif /* ENDIAN */
+.Last_store:
+ j_s.d [blink]
+ st r12,[r5,0]
+
+ .balign 4
+.Lcopy_bytewise:
+ jcs [blink]
+ ldb_s r12,[r1,0]
+ lsr.f lp_count,r3
+ bhs_s .Lnox1
+ stb.ab r12,[r5,1]
+ ldb.a r12,[r1,1]
+.Lnox1:
+ lppnz .Lendbloop
+ ldb_s r3,[r1,1]
+ stb.ab r12,[r5,1]
+ ldb.a r12,[r1,2]
+ stb.ab r3,[r5,1]
+.Lendbloop:
+ j_s.d [blink]
+ stb r12,[r5,0]
+END(memcpy)
+libc_hidden_def(memcpy)
diff --git a/libc/string/arc/memset.S b/libc/string/arc/memset.S
new file mode 100644
index 000000000..f4048455a
--- /dev/null
+++ b/libc/string/arc/memset.S
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ * Copyright (C) 2007 ARC International (UK) LTD
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sysdep.h>
+
+#define SMALL 7 /* Must be at least 6 to deal with alignment/loop issues. */
+
+ENTRY(memset)
+
+ mov_s r4,r0
+ or r12,r0,r2
+ bmsk.f r12,r12,1
+ extb_s r1,r1
+ asl r3,r1,8
+ beq.d .Laligned
+ or_s r1,r1,r3
+ brls r2,SMALL,.Ltiny
+ add r3,r2,r0
+ stb r1,[r3,-1]
+ bclr_s r3,r3,0
+ stw r1,[r3,-2]
+ bmsk.f r12,r0,1
+ add_s r2,r2,r12
+ sub.ne r2,r2,4
+ stb.ab r1,[r4,1]
+ and r4,r4,-2
+ stw.ab r1,[r4,2]
+ and r4,r4,-4
+.Laligned: ; This code address should be aligned for speed.
+ asl r3,r1,16
+ lsr.f lp_count,r2,2
+ or_s r1,r1,r3
+ lpne .Loop_end
+ st.ab r1,[r4,4]
+.Loop_end:
+ j_s [blink]
+
+
+ .balign 4
+.Ltiny:
+ mov.f lp_count,r2
+ lpne .Ltiny_end
+ stb.ab r1,[r4,1]
+.Ltiny_end:
+ j_s [blink]
+END(memset)
+libc_hidden_def(memset)
diff --git a/libc/string/arc/strchr.S b/libc/string/arc/strchr.S
new file mode 100644
index 000000000..443993589
--- /dev/null
+++ b/libc/string/arc/strchr.S
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ * Copyright (C) 2007 ARC International (UK) LTD
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sysdep.h>
+#include <features.h>
+
+/* ARC700 has a relatively long pipeline and branch prediction, so we want
+ to avoid branches that are hard to predict. On the other hand, the
+ presence of the norm instruction makes it easier to operate on whole
+ words branch-free. */
+
+ENTRY(strchr)
+ extb_s r1,r1
+ asl r5,r1,8
+ bmsk r2,r0,1
+ or r5,r5,r1
+ mov_s r3,0x01010101
+ breq.d r2,r0,.Laligned
+ asl r4,r5,16
+ sub_s r0,r0,r2
+ asl r7,r2,3
+ ld_s r2,[r0]
+#ifdef __LITTLE_ENDIAN__
+ asl r7,r3,r7
+#else
+ lsr r7,r3,r7
+#endif
+ or r5,r5,r4
+ ror r4,r3
+ sub r12,r2,r7
+ bic_s r12,r12,r2
+ and r12,r12,r4
+ brne.d r12,0,.Lfound0_ua
+ xor r6,r2,r5
+ ld.a r2,[r0,4]
+ sub r12,r6,r7
+ bic r12,r12,r6
+#ifdef __LITTLE_ENDIAN__
+ and r7,r12,r4
+ breq r7,0,.Loop ; For speed, we want this branch to be unaligned.
+ b .Lfound_char ; Likewise this one.
+#else
+ and r12,r12,r4
+ breq r12,0,.Loop ; For speed, we want this branch to be unaligned.
+ lsr_s r12,r12,7
+ bic r2,r7,r6
+ b.d .Lfound_char_b
+ and_s r2,r2,r12
+#endif
+; /* We require this code address to be unaligned for speed... */
+.Laligned:
+ ld_s r2,[r0]
+ or r5,r5,r4
+ ror r4,r3
+; /* ... so that this code address is aligned, for itself and ... */
+.Loop:
+ sub r12,r2,r3
+ bic_s r12,r12,r2
+ and r12,r12,r4
+ brne.d r12,0,.Lfound0
+ xor r6,r2,r5
+ ld.a r2,[r0,4]
+ sub r12,r6,r3
+ bic r12,r12,r6
+ and r7,r12,r4
+ breq r7,0,.Loop /* ... so that this branch is unaligned. */
+ ; Found searched-for character. r0 has already advanced to next word.
+#ifdef __LITTLE_ENDIAN__
+/* We only need the information about the first matching byte
+ (i.e. the least significant matching byte) to be exact,
+ hence there is no problem with carry effects. */
+.Lfound_char:
+ sub r3,r7,1
+ bic r3,r3,r7
+ norm r2,r3
+ sub_s r0,r0,1
+ asr_s r2,r2,3
+ j.d [blink]
+ sub_s r0,r0,r2
+
+ .balign 4
+.Lfound0_ua:
+ mov r3,r7
+.Lfound0:
+ sub r3,r6,r3
+ bic r3,r3,r6
+ and r2,r3,r4
+ or_s r12,r12,r2
+ sub_s r3,r12,1
+ bic_s r3,r3,r12
+ norm r3,r3
+ add_s r0,r0,3
+ asr_s r12,r3,3
+ asl.f 0,r2,r3
+ sub_s r0,r0,r12
+ j_s.d [blink]
+ mov.pl r0,0
+#else /* BIG ENDIAN */
+.Lfound_char:
+ lsr r7,r7,7
+
+ bic r2,r7,r6
+.Lfound_char_b:
+ norm r2,r2
+ sub_s r0,r0,4
+ asr_s r2,r2,3
+ j.d [blink]
+ add_s r0,r0,r2
+
+.Lfound0_ua:
+ mov_s r3,r7
+.Lfound0:
+ asl_s r2,r2,7
+ or r7,r6,r4
+ bic_s r12,r12,r2
+ sub r2,r7,r3
+ or r2,r2,r6
+ bic r12,r2,r12
+ bic.f r3,r4,r12
+ norm r3,r3
+
+ add.pl r3,r3,1
+ asr_s r12,r3,3
+ asl.f 0,r2,r3
+ add_s r0,r0,r12
+ j_s.d [blink]
+ mov.mi r0,0
+#endif /* ENDIAN */
+END(strchr)
+libc_hidden_def(strchr)
+
+#ifdef __UCLIBC_SUSV3_LEGACY__
+strong_alias(strchr,index)
+#endif
diff --git a/libc/string/arc/strcmp.S b/libc/string/arc/strcmp.S
new file mode 100644
index 000000000..5a0e56045
--- /dev/null
+++ b/libc/string/arc/strcmp.S
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ * Copyright (C) 2007 ARC International (UK) LTD
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <features.h>
+#include <sysdep.h>
+
+/* This is optimized primarily for the ARC700.
+ It would be possible to speed up the loops by one cycle / word
+ respective one cycle / byte by forcing double source 1 alignment, unrolling
+ by a factor of two, and speculatively loading the second word / byte of
+ source 1; however, that would increase the overhead for loop setup / finish,
+ and strcmp might often terminate early. */
+
+ENTRY(strcmp)
+ or r2,r0,r1
+ bmsk_s r2,r2,1
+ brne r2,0,.Lcharloop
+ mov_s r12,0x01010101
+ ror r5,r12
+.Lwordloop:
+ ld.ab r2,[r0,4]
+ ld.ab r3,[r1,4]
+ nop_s
+ sub r4,r2,r12
+ bic r4,r4,r2
+ and r4,r4,r5
+ brne r4,0,.Lfound0
+ breq r2,r3,.Lwordloop
+#ifdef __LITTLE_ENDIAN__
+ xor r0,r2,r3 ; mask for difference
+ sub_s r1,r0,1
+ bic_s r0,r0,r1 ; mask for least significant difference bit
+ sub r1,r5,r0
+ xor r0,r5,r1 ; mask for least significant difference byte
+ and_s r2,r2,r0
+ and_s r3,r3,r0
+#endif /* LITTLE ENDIAN */
+ cmp_s r2,r3
+ mov_s r0,1
+ j_s.d [blink]
+ bset.lo r0,r0,31
+
+ .balign 4
+#ifdef __LITTLE_ENDIAN__
+.Lfound0:
+ xor r0,r2,r3 ; mask for difference
+ or r0,r0,r4 ; or in zero indicator
+ sub_s r1,r0,1
+ bic_s r0,r0,r1 ; mask for least significant difference bit
+ sub r1,r5,r0
+ xor r0,r5,r1 ; mask for least significant difference byte
+ and_s r2,r2,r0
+ and_s r3,r3,r0
+ sub.f r0,r2,r3
+ mov.hi r0,1
+ j_s.d [blink]
+ bset.lo r0,r0,31
+#else /* BIG ENDIAN */
+ /* The zero-detection above can mis-detect 0x01 bytes as zeroes
+ because of carry-propagateion from a lower significant zero byte.
+ We can compensate for this by checking that bit0 is zero.
+ This compensation is not necessary in the step where we
+ get a low estimate for r2, because in any affected bytes
+ we already have 0x00 or 0x01, which will remain unchanged
+ when bit 7 is cleared. */
+ .balign 4
+.Lfound0:
+ lsr r0,r4,8
+ lsr_s r1,r2
+ bic_s r2,r2,r0 ; get low estimate for r2 and get ...
+ bic_s r0,r0,r1 ; <this is the adjusted mask for zeros>
+ or_s r3,r3,r0 ; ... high estimate r3 so that r2 > r3 will ...
+ cmp_s r3,r2 ; ... be independent of trailing garbage
+ or_s r2,r2,r0 ; likewise for r3 > r2
+ bic_s r3,r3,r0
+ rlc r0,0 ; r0 := r2 > r3 ? 1 : 0
+ cmp_s r2,r3
+ j_s.d [blink]
+ bset.lo r0,r0,31
+#endif /* ENDIAN */
+
+ .balign 4
+.Lcharloop:
+ ldb.ab r2,[r0,1]
+ ldb.ab r3,[r1,1]
+ nop_s
+ breq r2,0,.Lcmpend
+ breq r2,r3,.Lcharloop
+.Lcmpend:
+ j_s.d [blink]
+ sub r0,r2,r3
+END(strcmp)
+libc_hidden_def(strcmp)
+
+#ifndef __UCLIBC_HAS_LOCALE__
+strong_alias(strcmp,strcoll)
+libc_hidden_def(strcoll)
+#endif
diff --git a/libc/string/arc/strcpy.S b/libc/string/arc/strcpy.S
new file mode 100644
index 000000000..241bf3ee6
--- /dev/null
+++ b/libc/string/arc/strcpy.S
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ * Copyright (C) 2007 ARC International (UK) LTD
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+
+#include <sysdep.h>
+
+/* If dst and src are 4 byte aligned, copy 8 bytes at a time.
+ If the src is 4, but not 8 byte aligned, we first read 4 bytes to get
+ it 8 byte aligned. Thus, we can do a little read-ahead, without
+ dereferencing a cache line that we should not touch.
+ Note that short and long instructions have been scheduled to avoid
+ branch stalls.
+ The beq_s to r3z could be made unaligned & long to avoid a stall
+ there, but the it is not likely to be taken often, and it
+ would also be likey to cost an unaligned mispredict at the next call. */
+
+ENTRY(strcpy)
+ or r2,r0,r1
+ bmsk_s r2,r2,1
+ brne.d r2,0,charloop
+ mov_s r10,r0
+ ld_s r3,[r1,0]
+ mov r8,0x01010101
+ bbit0.d r1,2,loop_start
+ ror r12,r8
+ sub r2,r3,r8
+ bic_s r2,r2,r3
+ tst_s r2,r12
+ bne r3z
+ mov_s r4,r3
+ .balign 4
+loop:
+ ld.a r3,[r1,4]
+ st.ab r4,[r10,4]
+loop_start:
+ ld.a r4,[r1,4]
+ sub r2,r3,r8
+ bic_s r2,r2,r3
+ tst_s r2,r12
+ bne_s r3z
+ st.ab r3,[r10,4]
+ sub r2,r4,r8
+ bic r2,r2,r4
+ tst r2,r12
+ beq loop
+ mov_s r3,r4
+#ifdef __LITTLE_ENDIAN__
+r3z: bmsk.f r1,r3,7
+ lsr_s r3,r3,8
+#else
+r3z: lsr.f r1,r3,24
+ asl_s r3,r3,8
+#endif
+ bne.d r3z
+ stb.ab r1,[r10,1]
+ j_s [blink]
+
+ .balign 4
+charloop:
+ ldb.ab r3,[r1,1]
+
+
+ brne.d r3,0,charloop
+ stb.ab r3,[r10,1]
+ j [blink]
+END(strcpy)
+libc_hidden_def(strcpy)
diff --git a/libc/string/arc/strlen.S b/libc/string/arc/strlen.S
new file mode 100644
index 000000000..0b9b93815
--- /dev/null
+++ b/libc/string/arc/strlen.S
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ * Copyright (C) 2007 ARC International (UK) LTD
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+
+#include <sysdep.h>
+
+ENTRY(strlen)
+ or r3,r0,7
+ ld r2,[r3,-7]
+ ld.a r6,[r3,-3]
+ mov r4,0x01010101
+ ; uses long immediate
+#ifdef __LITTLE_ENDIAN__
+ asl_s r1,r0,3
+ btst_s r0,2
+ asl r7,r4,r1
+ ror r5,r4
+ sub r1,r2,r7
+ bic_s r1,r1,r2
+ mov.eq r7,r4
+ sub r12,r6,r7
+ bic r12,r12,r6
+ or.eq r12,r12,r1
+ and r12,r12,r5
+ brne r12,0,.Learly_end
+#else /* BIG ENDIAN */
+ ror r5,r4
+ btst_s r0,2
+ mov_s r1,31
+ sub3 r7,r1,r0
+ sub r1,r2,r4
+ bic_s r1,r1,r2
+ bmsk r1,r1,r7
+ sub r12,r6,r4
+ bic r12,r12,r6
+ bmsk.ne r12,r12,r7
+ or.eq r12,r12,r1
+ and r12,r12,r5
+ brne r12,0,.Learly_end
+#endif /* ENDIAN */
+
+.Loop:
+ ld_s r2,[r3,4]
+ ld.a r6,[r3,8]
+ ; stall for load result
+ sub r1,r2,r4
+ bic_s r1,r1,r2
+ sub r12,r6,r4
+ bic r12,r12,r6
+ or r12,r12,r1
+ and r12,r12,r5
+ breq r12,0,.Loop
+.Lend:
+ and.f r1,r1,r5
+ sub.ne r3,r3,4
+ mov.eq r1,r12
+#ifdef __LITTLE_ENDIAN__
+ sub_s r2,r1,1
+ bic_s r2,r2,r1
+ norm r1,r2
+ sub_s r0,r0,3
+ lsr_s r1,r1,3
+ sub r0,r3,r0
+ j_s.d [blink]
+ sub r0,r0,r1
+#else /* BIG ENDIAN */
+ lsr_s r1,r1,7
+ mov.eq r2,r6
+ bic_s r1,r1,r2
+ norm r1,r1
+ sub r0,r3,r0
+ lsr_s r1,r1,3
+ j_s.d [blink]
+ add r0,r0,r1
+#endif /* ENDIAN */
+.Learly_end:
+ b.d .Lend
+ sub_s.ne r1,r1,r1
+END(strlen)
+libc_hidden_def(strlen)
diff --git a/libc/string/arm/_memcpy.S b/libc/string/arm/_memcpy.S
index 103580a0c..2999e8ee6 100644
--- a/libc/string/arm/_memcpy.S
+++ b/libc/string/arm/_memcpy.S
@@ -40,6 +40,7 @@
#include <features.h>
#include <endian.h>
#include <bits/arm_asm.h>
+#include <bits/arm_bx.h>
#if !defined(THUMB1_ONLY)
/*
@@ -67,8 +68,9 @@
* a time where possible.
*
* Note: r12 (aka ip) can be trashed during the function along with
- * r0-r3 although r0-r2 have defined uses i.e. src, dest, len through out.
+ * r0-r3 although r0-r2 have defined uses i.e. dest, src, len throughout.
* Additional registers are preserved prior to use i.e. r4, r5 & lr
+ * The return value in r0 must be the destination address.
*
* Apologies for the state of the comments ;-)
*/
@@ -108,12 +110,8 @@ _memcpy:
cmp r1, r0
bcc .Lmemcpy_backwards
- IT(tt, eq) /* Quick abort for src=dst */
-#if defined(__USE_BX__)
- bxeq lr
-#else
- moveq pc, lr
-#endif
+ IT(t, eq) /* Quick abort for src=dst */
+ BXC(eq, lr)
stmdb sp!, {r0, lr} /* memcpy() returns dest addr */
subs r2, r2, #4
blt .Lmemcpy_fl4 /* less than 4 bytes */
@@ -453,11 +451,7 @@ _memcpy:
/* less than 4 bytes to go */
adds r2, r2, #4
IT(t, eq)
-#if defined(__USE_BX__)
- bxeq lr
-#else
- moveq pc, lr /* done */
-#endif
+ BXC(eq, lr) /* done */
/* copy the crud byte at a time */
cmp r2, #2
ldrb r3, [r1, #-1]!
@@ -475,11 +469,7 @@ _memcpy:
ldrgtb r3, [r1, #-1]!
strgtb r3, [r0, #-1]!
#endif
-#if defined(__USE_BX__)
- bx lr
-#else
- mov pc, lr
-#endif
+ BX(lr)
/* erg - unaligned destination */
.Lmemcpy_bdestul:
cmp r12, #2
diff --git a/libc/string/arm/memcmp.S b/libc/string/arm/memcmp.S
index 65409f43a..5b9473cd0 100644
--- a/libc/string/arm/memcmp.S
+++ b/libc/string/arm/memcmp.S
@@ -31,6 +31,7 @@
#include <features.h>
#include <bits/arm_asm.h>
+#include <bits/arm_bx.h>
.text
.global memcmp
@@ -66,11 +67,7 @@ memcmp:
subs r2, r2, #1
IT(tt, mi)
movmi r0, #0
-#if defined(__USE_BX__)
- bxmi lr
-#else
- movmi pc, lr
-#endif
+ BXC(mi, lr)
/* ip == last src address to compare */
add ip, r0, r2
1:
@@ -81,11 +78,7 @@ memcmp:
cmpcs r2, r3
beq 1b
sub r0, r2, r3
-#if defined(__USE_BX__)
- bx lr
-#else
- mov pc, lr
-#endif
+ BX(lr)
#endif
.size memcmp,.-memcmp
diff --git a/libc/string/arm/memset.S b/libc/string/arm/memset.S
index 66aa6039c..2be4850e4 100644
--- a/libc/string/arm/memset.S
+++ b/libc/string/arm/memset.S
@@ -13,13 +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 <sys/syscall.h>
#include <bits/arm_asm.h>
+#include <bits/arm_bx.h>
.text
.global memset
@@ -109,11 +108,7 @@ memset:
2:
movs a3, a3 @ anything left?
IT(t, eq)
-#if defined(__USE_BX__)
- bxeq lr
-#else
- moveq pc, lr @ nope
-#endif
+ BXC(eq, lr) @ nope
#if defined (__thumb2__)
1:
strb a2, [a4], #1
@@ -131,11 +126,7 @@ memset:
strb a2, [a4], $1
strb a2, [a4], $1
strb a2, [a4], $1
-#if defined(__USE_BX__)
- bx lr
-#else
- mov pc, lr
-#endif
+ BX(lr)
#endif
#endif
diff --git a/libc/string/arm/strcmp.S b/libc/string/arm/strcmp.S
index 97363c1c2..81416a9a5 100644
--- a/libc/string/arm/strcmp.S
+++ b/libc/string/arm/strcmp.S
@@ -31,6 +31,7 @@
#include <features.h>
#include <bits/arm_asm.h>
+#include <bits/arm_bx.h>
.text
.global strcmp
@@ -62,11 +63,7 @@ strcmp:
cmpcs r2, r3
beq 1b
sub r0, r2, r3
-#if defined(__USE_BX__)
- bx lr
-#else
- mov pc, lr
-#endif
+ BX(lr)
#endif
.size strcmp,.-strcmp
diff --git a/libc/string/arm/strlen.S b/libc/string/arm/strlen.S
index 949e918f4..9995d768c 100644
--- a/libc/string/arm/strlen.S
+++ b/libc/string/arm/strlen.S
@@ -13,14 +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 <features.h>
#include <endian.h>
-#include <sys/syscall.h>
#include <bits/arm_asm.h>
+#include <bits/arm_bx.h>
/* size_t strlen(const char *S)
* entry: r0 -> string
@@ -99,11 +98,7 @@ Llastword: @ drop through to here once we find a
IT(t, ne)
addne r0, r0, $1 @ must be zero)
#endif
-#if defined(__USE_BX__)
- bx lr
-#else
- mov pc,lr
-#endif
+ BX(lr)
#endif
.size strlen,.-strlen
diff --git a/libc/string/arm/strncmp.S b/libc/string/arm/strncmp.S
deleted file mode 100644
index 8487639c8..000000000
--- a/libc/string/arm/strncmp.S
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (c) 2002 ARM Ltd
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the company may not be used to endorse or promote
- * products derived from this software without specific prior written
- * permission.
- *
- * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Adapted for uClibc from NetBSD strncmp.S, version 1.2 2003/04/05
- * by Erik Andersen <andersen@codepoet.org>
- */
-
-#include <features.h>
-#include <bits/arm_asm.h>
-
-.text
-.global strncmp
-.type strncmp,%function
-.align 4
-
-#if defined(THUMB1_ONLY)
-.thumb_func
-strncmp:
- /* if (len == 0) return 0 */
- cmp r2, #0
- bne 1f
- mov r0, #0
- bx lr
-1:
- push {r4}
-
- /* ip == last src address to compare */
- add r4, r0, r2
-2:
- cmp r4, r0
- beq 3f
- ldrb r2, [r0]
- add r0, r0, #1
- ldrb r3, [r1]
- add r1, r1, #1
- cmp r2, #0
- beq 3f
- cmp r2, r3
- beq 2b
-3:
- sub r0, r2, r3
- pop {r4}
- bx lr
-#else
-strncmp:
- /* if (len == 0) return 0 */
- cmp r2, #0
- IT(tt, eq)
- moveq r0, #0
-#if defined(__USE_BX__)
- bxeq lr
-#else
- moveq pc, lr
-#endif
- subs r2, r2, #1
-
- /* ip == last src address to compare */
- add ip, r0, r2
-1:
- ldrb r2, [r0], #1
- ldrb r3, [r1], #1
- cmp ip, r0
- IT(tt, cs)
- cmpcs r2, #1
- cmpcs r2, r3
- beq 1b
- sub r0, r2, r3
-#if defined(__USE_BX__)
- bx lr
-#else
- mov pc, lr
-#endif
-#endif
-
-.size strncmp,.-strncmp
-
-libc_hidden_weak(strncmp)
diff --git a/libc/string/avr32/Makefile b/libc/string/avr32/Makefile
index e19e9d9ec..385cf085e 100644
--- a/libc/string/avr32/Makefile
+++ b/libc/string/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/string/basename.c b/libc/string/basename.c
index a076c20e9..abc9d89db 100644
--- a/libc/string/basename.c
+++ b/libc/string/basename.c
@@ -5,10 +5,9 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#include "_string.h"
+#include <string.h>
#ifdef __USE_GNU
-/* Experimentally off - libc_hidden_proto(basename) */
char *basename(const char *path)
{
@@ -25,5 +24,4 @@ char *basename(const char *path)
return (char *) p;
}
-libc_hidden_def(basename)
#endif
diff --git a/libc/string/bcopy.c b/libc/string/bcopy.c
index 3aa7eab1e..e16ba241d 100644
--- a/libc/string/bcopy.c
+++ b/libc/string/bcopy.c
@@ -5,35 +5,14 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#include "_string.h"
+#include <string.h>
#ifdef __UCLIBC_SUSV3_LEGACY__
-
-/* Experimentally off - libc_hidden_proto(memmove) */
-
void bcopy(const void *s2, void *s1, size_t n)
{
#if 1
memmove(s1, s2, n);
#else
-#ifdef __BCC__
- register char *s;
- register const char *p;
-
- s = s1;
- p = s2;
- if (p >= s) {
- while (n--) {
- *s++ = *p++;
- }
- } else {
- s += n;
- p += n;
- while (n--) {
- *--s = *--p;
- }
- }
-#else
register char *s;
register const char *p;
@@ -51,6 +30,5 @@ void bcopy(const void *s2, void *s1, size_t n)
}
}
#endif
-#endif
}
#endif
diff --git a/libc/string/bfin/memchr.S b/libc/string/bfin/memchr.S
index 88e46bef6..26d419f7c 100644
--- a/libc/string/bfin/memchr.S
+++ b/libc/string/bfin/memchr.S
@@ -25,8 +25,8 @@
.weak _memchr
ENTRY(_memchr)
- P0 = R0; // P0 = address
- P2 = R2; // P2 = count
+ P0 = R0; /* P0 = address */
+ P2 = R2; /* P2 = count */
R1 = R1.B(Z);
CC = R2 == 0;
IF CC JUMP .Lfailed;
diff --git a/libc/string/bfin/strcmp.S b/libc/string/bfin/strcmp.S
index 12e8c53c6..ef23aa9ab 100644
--- a/libc/string/bfin/strcmp.S
+++ b/libc/string/bfin/strcmp.S
@@ -29,66 +29,66 @@ ENTRY(_strcmp)
p1 = r0;
p2 = r1;
- p0 = -1; // (need for loop counter init)
+ p0 = -1; /* (need for loop counter init) */
- // check if byte aligned
- r0 = r0 | r1; // check both pointers at same time
- r0 <<= 30; // dump all but last 2 bits
- cc = az; // are they zero?
- if !cc jump .Lunaligned; // no; use unaligned code.
- // fall-thru for aligned case..
+ /* check if byte aligned */
+ r0 = r0 | r1; /* check both pointers at same time */
+ r0 <<= 30; /* dump all but last 2 bits */
+ cc = az; /* are they zero? */
+ if !cc jump .Lunaligned; /* no; use unaligned code. */
+ /* fall-thru for aligned case.. */
- // note that r0 is zero from the previous...
- // p0 set to -1
+ /* note that r0 is zero from the previous... */
+ /* p0 set to -1 */
LSETUP (.Lbeginloop, .Lendloop) lc0=p0;
- // pick up first words
+ /* pick up first words */
r1 = [p1++];
r2 = [p2++];
- // make up mask: 0FF0FF
+ /* make up mask: 0FF0FF */
r7 = 0xFF;
r7.h = 0xFF;
- // loop : 9 cycles to check 4 characters
+ /* loop : 9 cycles to check 4 characters */
cc = r1 == r2;
.Lbeginloop:
- if !cc jump .Lnotequal4; // compare failure, exit loop
+ if !cc jump .Lnotequal4; /* compare failure, exit loop */
- // starting with 44332211
- // see if char 3 or char 1 is 0
- r3 = r1 & r7; // form 00330011
- // add to zero, and (r2 is free, reload)
+ /* starting with 44332211 */
+ /* see if char 3 or char 1 is 0 */
+ r3 = r1 & r7; /* form 00330011 */
+ /* add to zero, and (r2 is free, reload) */
r6 = r3 +|+ r0 || r2 = [p2++] || nop;
- cc = az; // true if either is zero
- r3 = r1 ^ r3; // form 44002200 (4321^0301 => 4020)
- // (trick, saves having another mask)
- // add to zero, and (r1 is free, reload)
+ cc = az; /* true if either is zero */
+ r3 = r1 ^ r3; /* form 44002200 (4321^0301 => 4020) */
+ /* (trick, saves having another mask) */
+ /* add to zero, and (r1 is free, reload) */
r6 = r3 +|+ r0 || r1 = [p1++] || nop;
- cc |= az; // true if either is zero
- if cc jump .Lzero4; // leave if a zero somewhere
+ cc |= az; /* true if either is zero */
+ if cc jump .Lzero4; /* leave if a zero somewhere */
.Lendloop:
cc = r1 == r2;
- // loop exits
-.Lnotequal4: // compare failure on 4-char compare
- // address pointers are one word ahead;
- // faster to use zero4 exit code
+ /* loop exits */
+.Lnotequal4: /* compare failure on 4-char compare */
+ /* address pointers are one word ahead; */
+ /* faster to use zero4 exit code */
p1 += 4;
p2 += 4;
-.Lzero4: // one of the bytes in word 1 is zero
- // but we've already fetched the next word; so
- // backup two to look at failing word again
+.Lzero4: /* one of the bytes in word 1 is zero */
+ /* but we've already fetched the next word; so */
+ /* backup two to look at failing word again */
p1 += -8;
p2 += -8;
- // here when pointers are unaligned: checks one
- // character at a time. Also use at the end of
- // the word-check algorithm to figure out what happened
+ /* here when pointers are unaligned: checks one */
+ /* character at a time. Also use at the end of */
+ /* the word-check algorithm to figure out what happened */
.Lunaligned:
- // R0 is non-zero from before.
- // p0 set to -1
+ /* R0 is non-zero from before. */
+ /* p0 set to -1 */
r0 = 0 (Z);
r1 = B[p1++] (Z);
@@ -96,18 +96,18 @@ ENTRY(_strcmp)
LSETUP (.Lbeginloop1, .Lendloop1) lc0=p0;
.Lbeginloop1:
- cc = r1; // first char must be non-zero
- // chars must be the same
+ cc = r1; /* first char must be non-zero */
+ /* chars must be the same */
r3 = r2 - r1 (NS) || r1 = B[p1++] (Z) || nop;
cc &= az;
- r3 = r0 - r2; // second char must be non-zero
+ r3 = r0 - r2; /* second char must be non-zero */
cc &= an;
if !cc jump .Lexitloop1;
.Lendloop1:
r2 = B[p2++] (Z);
-.Lexitloop1: // here means we found a zero or a difference.
- // we have r2(N), p2(N), r1(N+1), p1(N+2)
+.Lexitloop1: /* here means we found a zero or a difference. */
+ /* we have r2(N), p2(N), r1(N+1), p1(N+2) */
r1=B[p1+ -2] (Z);
r0 = r1 - r2;
(r7:4) = [sp++];
diff --git a/libc/string/bzero.c b/libc/string/bzero.c
index 7498f795f..32dce416e 100644
--- a/libc/string/bzero.c
+++ b/libc/string/bzero.c
@@ -5,30 +5,20 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#include "_string.h"
+#include <string.h>
#ifdef __UCLIBC_SUSV3_LEGACY__
-
-/* Experimentally off - libc_hidden_proto(memset) */
-
void bzero(void *s, size_t n)
{
#if 1
(void)memset(s, 0, n);
#else
register unsigned char *p = s;
-#ifdef __BCC__
- /* bcc can optimize the counter if it thinks it is a pointer... */
- register const char *np = (const char *) n;
-#else
-#define np n
-#endif
- while (np) {
+ while (n) {
*p++ = 0;
- --np;
+ --n;
}
#endif
}
-#undef np
#endif
diff --git a/libc/string/cris/memcopy.h b/libc/string/cris/memcopy.h
index 449c75641..ccd447c83 100644
--- a/libc/string/cris/memcopy.h
+++ b/libc/string/cris/memcopy.h
@@ -16,8 +16,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 "../generic/memcopy.h"
diff --git a/libc/string/cris/memcpy.c b/libc/string/cris/memcpy.c
index cc14188b8..94e576f4f 100644
--- a/libc/string/cris/memcpy.c
+++ b/libc/string/cris/memcpy.c
@@ -1,264 +1,242 @@
-/* Copyright (C) 2001, 2003 Free Software Foundation, Inc.
- Copyright (C) 1994, 1995, 2000 Axis Communications AB.
-
- 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. */
-
-/*#************************************************************************#*/
-/*#-------------------------------------------------------------------------*/
-/*# */
-/*# FUNCTION NAME: memcpy() */
-/*# */
-/*# PARAMETERS: void* dst; Destination address. */
-/*# void* src; Source address. */
-/*# int len; Number of bytes to copy. */
-/*# */
-/*# RETURNS: dst. */
-/*# */
-/*# DESCRIPTION: Copies len bytes of memory from src to dst. No guarantees */
-/*# about copying of overlapping memory areas. This routine is */
-/*# very sensitive to compiler changes in register allocation. */
-/*# Should really be rewritten to avoid this problem. */
-/*# */
-/*#-------------------------------------------------------------------------*/
-/*# */
-/*# HISTORY */
-/*# */
-/*# DATE NAME CHANGES */
-/*# ---- ---- ------- */
-/*# 941007 Kenny R Creation */
-/*# 941011 Kenny R Lots of optimizations and inlining. */
-/*# 941129 Ulf A Adapted for use in libc. */
-/*# 950216 HP N==0 forgotten if non-aligned src/dst. */
-/*# Added some optimizations. */
-/*# 001025 HP Make src and dst char *. Align dst to */
-/*# dword, not just word-if-both-src-and-dst- */
-/*# are-misaligned. */
-/*# 070806 RW Modified for uClibc */
-/*# (__arch_v32 -> __CONFIG_CRISV32__, */
-/*# include features.h to reach it.) */
-/*# */
-/*#-------------------------------------------------------------------------*/
-
-#include <features.h>
-
-#ifdef __CONFIG_CRISV32__
+/* A memcpy for CRIS.
+ Copyright (C) 1994-2008 Axis Communications.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Neither the name of Axis Communications nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY AXIS COMMUNICATIONS AND ITS CONTRIBUTORS
+ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AXIS
+ COMMUNICATIONS OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE. */
+
+/* FIXME: This file should really only be used for reference, as the
+ result is somewhat depending on gcc generating what we expect rather
+ than what we describe. An assembly file should be used instead. */
+
+#include <string.h>
+
+#ifdef __arch_v32
/* For CRISv32, movem is very cheap. */
-#define MEMCPY_BLOCK_THRESHOLD (44)
+#define MEMCPY_BY_BLOCK_THRESHOLD (44)
#else
-/* Break even between movem and move16 is at 38.7*2, but modulo 44. */
-#define MEMCPY_BLOCK_THRESHOLD (44*2)
+/* Break even between movem and move16 is really at 38.7 * 2, but
+ modulo 44, so up to the next multiple of 44, we use ordinary code. */
+#define MEMCPY_BY_BLOCK_THRESHOLD (44 * 2)
#endif
-void *memcpy(void *, const void *, unsigned int);
+/* No name ambiguities in this file. */
+__asm__ (".syntax no_register_prefix");
-/* Experimentally off - libc_hidden_proto(memcpy) */
-void *memcpy(void *pdst,
- const void *psrc,
- unsigned int pn)
+void *
+memcpy(void *pdst, const void *psrc, size_t pn)
{
- /* Ok. Now we want the parameters put in special registers.
+ /* Now we want the parameters put in special registers.
Make sure the compiler is able to make something useful of this.
- As it is now: r10 -> r13; r11 -> r11 (nop); r12 -> r12 (nop).
+ As it is now: r10 -> r13; r11 -> r11 (nop); r12 -> r12 (nop).
If gcc was allright, it really would need no temporaries, and no
- stack space to save stuff on. */
+ stack space to save stuff on. */
-#ifndef MEMPCPY
register void *return_dst __asm__ ("r10") = pdst;
-#else
- /* FIXME: Use R10 for something. */
-# define return_dst dst
-#endif
-
- register char *dst __asm__ ("r13") = pdst;
- register char *src __asm__ ("r11") = (char *) psrc;
+ register unsigned char *dst __asm__ ("r13") = pdst;
+ register unsigned const char *src __asm__ ("r11") = psrc;
register int n __asm__ ("r12") = pn;
-
/* When src is aligned but not dst, this makes a few extra needless
cycles. I believe it would take as many to check that the
re-alignment was unnecessary. */
if (((unsigned long) dst & 3) != 0
/* Don't align if we wouldn't copy more than a few bytes; so we
- don't have to check further for overflows. */
+ don't have to check further for overflows. */
&& n >= 3)
{
if ((unsigned long) dst & 1)
- {
- n--;
- *(char*)dst = *(char*)src;
- src++;
- dst++;
- }
+ {
+ n--;
+ *dst = *src;
+ src++;
+ dst++;
+ }
if ((unsigned long) dst & 2)
- {
- n -= 2;
- *(short*)dst = *(short*)src;
- src += 2;
- dst += 2;
- }
+ {
+ n -= 2;
+ *(short *) dst = *(short *) src;
+ src += 2;
+ dst += 2;
+ }
}
- /* Decide which copying method to use. */
- if (n >= MEMCPY_BLOCK_THRESHOLD)
- {
- /* For large copies we use 'movem' */
-
- /* It is not optimal to tell the compiler about clobbering any
- registers; that will move the saving/restoring of those registers
- to the function prologue/epilogue, and make non-movem sizes
- suboptimal.
-
- This method is not foolproof; it assumes that the "register asm"
- declarations at the beginning of the function really are used
- here (beware: they may be moved to temporary registers).
- This way, we do not have to save/move the registers around into
- temporaries; we can safely use them straight away. */
- __asm__ __volatile__ ("\
- .syntax no_register_prefix \n\
- \n\
- ;; Check that the register asm declaration got right. \n\
- ;; The GCC manual explicitly says TRT will happen. \n\
- .ifnc %0-%1-%2,$r13-$r11-$r12 \n\
- .err \n\
- .endif \n\
- \n\
- ;; Save the registers we'll use in the movem process \n\
- ;; on the stack. \n\
- subq 11*4,sp \n\
- movem r10,[sp] \n\
- \n\
- ;; Now we've got this: \n\
- ;; r11 - src \n\
- ;; r13 - dst \n\
- ;; r12 - n \n\
- \n\
- ;; Update n for the first loop \n\
- subq 44,r12 \n\
-0: \n\
- movem [r11+],r10 \n\
- subq 44,r12 \n\
- bge 0b \n\
- movem r10,[r13+] \n\
- \n\
- addq 44,r12 ;; compensate for last loop underflowing n \n\
- \n\
- ;; Restore registers from stack \n\
- movem [sp+],r10"
-
- /* Outputs */ : "=r" (dst), "=r" (src), "=r" (n)
- /* Inputs */ : "0" (dst), "1" (src), "2" (n));
- }
+ /* Decide which copying method to use. */
+ if (n >= MEMCPY_BY_BLOCK_THRESHOLD)
+ {
+ /* It is not optimal to tell the compiler about clobbering any
+ registers; that will move the saving/restoring of those registers
+ to the function prologue/epilogue, and make non-movem sizes
+ suboptimal. */
+ __asm__ __volatile__
+ ("\
+ ;; GCC does promise correct register allocations, but let's \n\
+ ;; make sure it keeps its promises. \n\
+ .ifnc %0-%1-%2,$r13-$r11-$r12 \n\
+ .error \"GCC reg alloc bug: %0-%1-%4 != $r13-$r12-$r11\" \n\
+ .endif \n\
+ \n\
+ ;; Save the registers we'll use in the movem process \n\
+ ;; on the stack. \n\
+ subq 11*4,sp \n\
+ movem r10,[sp] \n\
+ \n\
+ ;; Now we've got this: \n\
+ ;; r11 - src \n\
+ ;; r13 - dst \n\
+ ;; r12 - n \n\
+ \n\
+ ;; Update n for the first loop. \n\
+ subq 44,r12 \n\
+0: \n\
+"
+#ifdef __arch_common_v10_v32
+ /* Cater to branch offset difference between v32 and v10. We
+ assume the branch below has an 8-bit offset. */
+" setf\n"
+#endif
+" movem [r11+],r10 \n\
+ subq 44,r12 \n\
+ bge 0b \n\
+ movem r10,[r13+] \n\
+ \n\
+ ;; Compensate for last loop underflowing n. \n\
+ addq 44,r12 \n\
+ \n\
+ ;; Restore registers from stack. \n\
+ movem [sp+],r10"
+
+ /* Outputs. */
+ : "=r" (dst), "=r" (src), "=r" (n)
+
+ /* Inputs. */
+ : "0" (dst), "1" (src), "2" (n));
+ }
- /* Either we directly starts copying, using dword copying
- in a loop, or we copy as much as possible with 'movem'
- and then the last block (<44 bytes) is copied here.
- This will work since 'movem' will have updated src,dst,n. */
+ while (n >= 16)
+ {
+ *(long *) dst = *(long *) src; dst += 4; src += 4;
+ *(long *) dst = *(long *) src; dst += 4; src += 4;
+ *(long *) dst = *(long *) src; dst += 4; src += 4;
+ *(long *) dst = *(long *) src; dst += 4; src += 4;
- while ( n >= 16 )
- {
- *((long*)dst)++ = *((long*)src)++;
- *((long*)dst)++ = *((long*)src)++;
- *((long*)dst)++ = *((long*)src)++;
- *((long*)dst)++ = *((long*)src)++;
- n -= 16;
- }
+ n -= 16;
+ }
- /* A switch() is definitely the fastest although it takes a LOT of code.
- * Particularly if you inline code this.
- */
switch (n)
- {
+ {
case 0:
break;
+
case 1:
- *((char*)dst)++ = *((char*)src)++;
+ *dst = *src;
break;
+
case 2:
- *((short*)dst)++ = *((short*)src)++;
+ *(short *) dst = *(short *) src;
break;
+
case 3:
- *((short*)dst)++ = *((short*)src)++;
- *((char*)dst)++ = *((char*)src)++;
+ *(short *) dst = *(short *) src; dst += 2; src += 2;
+ *dst = *src;
break;
+
case 4:
- *((long*)dst)++ = *((long*)src)++;
+ *(long *) dst = *(long *) src;
break;
+
case 5:
- *((long*)dst)++ = *((long*)src)++;
- *((char*)dst)++ = *((char*)src)++;
+ *(long *) dst = *(long *) src; dst += 4; src += 4;
+ *dst = *src;
break;
+
case 6:
- *((long*)dst)++ = *((long*)src)++;
- *((short*)dst)++ = *((short*)src)++;
+ *(long *) dst = *(long *) src; dst += 4; src += 4;
+ *(short *) dst = *(short *) src;
break;
+
case 7:
- *((long*)dst)++ = *((long*)src)++;
- *((short*)dst)++ = *((short*)src)++;
- *((char*)dst)++ = *((char*)src)++;
+ *(long *) dst = *(long *) src; dst += 4; src += 4;
+ *(short *) dst = *(short *) src; dst += 2; src += 2;
+ *dst = *src;
break;
+
case 8:
- *((long*)dst)++ = *((long*)src)++;
- *((long*)dst)++ = *((long*)src)++;
+ *(long *) dst = *(long *) src; dst += 4; src += 4;
+ *(long *) dst = *(long *) src;
break;
+
case 9:
- *((long*)dst)++ = *((long*)src)++;
- *((long*)dst)++ = *((long*)src)++;
- *((char*)dst)++ = *((char*)src)++;
+ *(long *) dst = *(long *) src; dst += 4; src += 4;
+ *(long *) dst = *(long *) src; dst += 4; src += 4;
+ *dst = *src;
break;
+
case 10:
- *((long*)dst)++ = *((long*)src)++;
- *((long*)dst)++ = *((long*)src)++;
- *((short*)dst)++ = *((short*)src)++;
+ *(long *) dst = *(long *) src; dst += 4; src += 4;
+ *(long *) dst = *(long *) src; dst += 4; src += 4;
+ *(short *) dst = *(short *) src;
break;
+
case 11:
- *((long*)dst)++ = *((long*)src)++;
- *((long*)dst)++ = *((long*)src)++;
- *((short*)dst)++ = *((short*)src)++;
- *((char*)dst)++ = *((char*)src)++;
+ *(long *) dst = *(long *) src; dst += 4; src += 4;
+ *(long *) dst = *(long *) src; dst += 4; src += 4;
+ *(short *) dst = *(short *) src; dst += 2; src += 2;
+ *dst = *src;
break;
+
case 12:
- *((long*)dst)++ = *((long*)src)++;
- *((long*)dst)++ = *((long*)src)++;
- *((long*)dst)++ = *((long*)src)++;
+ *(long *) dst = *(long *) src; dst += 4; src += 4;
+ *(long *) dst = *(long *) src; dst += 4; src += 4;
+ *(long *) dst = *(long *) src;
break;
+
case 13:
- *((long*)dst)++ = *((long*)src)++;
- *((long*)dst)++ = *((long*)src)++;
- *((long*)dst)++ = *((long*)src)++;
- *((char*)dst)++ = *((char*)src)++;
+ *(long *) dst = *(long *) src; dst += 4; src += 4;
+ *(long *) dst = *(long *) src; dst += 4; src += 4;
+ *(long *) dst = *(long *) src; dst += 4; src += 4;
+ *dst = *src;
break;
+
case 14:
- *((long*)dst)++ = *((long*)src)++;
- *((long*)dst)++ = *((long*)src)++;
- *((long*)dst)++ = *((long*)src)++;
- *((short*)dst)++ = *((short*)src)++;
+ *(long *) dst = *(long *) src; dst += 4; src += 4;
+ *(long *) dst = *(long *) src; dst += 4; src += 4;
+ *(long *) dst = *(long *) src; dst += 4; src += 4;
+ *(short *) dst = *(short *) src;
break;
+
case 15:
- *((long*)dst)++ = *((long*)src)++;
- *((long*)dst)++ = *((long*)src)++;
- *((long*)dst)++ = *((long*)src)++;
- *((short*)dst)++ = *((short*)src)++;
- *((char*)dst)++ = *((char*)src)++;
+ *(long *) dst = *(long *) src; dst += 4; src += 4;
+ *(long *) dst = *(long *) src; dst += 4; src += 4;
+ *(long *) dst = *(long *) src; dst += 4; src += 4;
+ *(short *) dst = *(short *) src; dst += 2; src += 2;
+ *dst = *src;
break;
- }
+ }
- return return_dst; /* destination pointer. */
-} /* memcpy() */
+ return return_dst;
+}
libc_hidden_def(memcpy)
diff --git a/libc/string/cris/memmove.c b/libc/string/cris/memmove.c
index fa495eba4..906ef8e74 100644
--- a/libc/string/cris/memmove.c
+++ b/libc/string/cris/memmove.c
@@ -18,16 +18,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 <string.h>
#include "memcopy.h"
#include "../generic/pagecopy.h"
-/* Experimentally off - libc_hidden_proto(memmove) */
void *memmove (void *dest, const void *src, size_t len)
{
unsigned long int dstp = (long int) dest;
diff --git a/libc/string/cris/memset.c b/libc/string/cris/memset.c
index b578aac5d..fab4e8b66 100644
--- a/libc/string/cris/memset.c
+++ b/libc/string/cris/memset.c
@@ -1,271 +1,262 @@
-/* Copyright (C) 2001, 2003 Free Software Foundation, Inc.
- Copyright (C) 1999, 2000 Axis Communications AB.
-
- 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. */
-
-/*#************************************************************************#*/
-/*#-------------------------------------------------------------------------*/
-/*# */
-/*# FUNCTION NAME: memset() */
-/*# */
-/*# PARAMETERS: void* dst; Destination address. */
-/*# int c; Value of byte to write. */
-/*# int len; Number of bytes to write. */
-/*# */
-/*# RETURNS: dst. */
-/*# */
-/*# DESCRIPTION: Sets the memory dst of length len bytes to c, as standard. */
-/*# Framework taken from memcpy. This routine is */
-/*# very sensitive to compiler changes in register allocation. */
-/*# Should really be rewritten to avoid this problem. */
-/*# */
-/*#-------------------------------------------------------------------------*/
-/*# */
-/*# HISTORY */
-/*# */
-/*# DATE NAME CHANGES */
-/*# ---- ---- ------- */
-/*# 990713 HP Tired of watching this function (or */
-/*# really, the nonoptimized generic */
-/*# implementation) take up 90% of simulator */
-/*# output. Measurements needed. */
-/*# */
-/*#-------------------------------------------------------------------------*/
-
-/* No, there's no macro saying 12*4, since it is "hard" to get it into
- the asm in a good way. Thus better to expose the problem everywhere.
- */
-
-/* Assuming 1 cycle per dword written or read (ok, not really true), and
- one per instruction, then 43+3*(n/48-1) <= 24+24*(n/48-1)
- so n >= 45.7; n >= 0.9; we win on the first full 48-byte block to set. */
-
-#define ZERO_BLOCK_SIZE (1*12*4)
-
-void *memset(void *, int, unsigned long);
-
-/* Experimentally off - libc_hidden_proto(memset) */
-void *memset(void *pdst,
- int c,
- unsigned long plen)
+/* A memset for CRIS.
+ Copyright (C) 1999-2008 Axis Communications.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Neither the name of Axis Communications nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY AXIS COMMUNICATIONS AND ITS CONTRIBUTORS
+ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AXIS
+ COMMUNICATIONS OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE. */
+
+/* FIXME: This file should really only be used for reference, as the
+ result is somewhat depending on gcc generating what we expect rather
+ than what we describe. An assembly file should be used instead. */
+
+#include <string.h>
+
+/* Note the multiple occurrence of the expression "12*4", including the
+ asm. It is hard to get it into the asm in a good way. Thus better to
+ expose the problem everywhere: no macro. */
+
+/* Assuming one cycle per dword written or read (ok, not really true; the
+ world is not ideal), and one cycle per instruction, then 43+3*(n/48-1)
+ <= 24+24*(n/48-1) so n >= 45.7; n >= 0.9; we win on the first full
+ 48-byte block to set. */
+
+#define MEMSET_BY_BLOCK_THRESHOLD (1 * 48)
+
+/* No name ambiguities in this file. */
+__asm__ (".syntax no_register_prefix");
+
+void *memset(void *pdst, int c, unsigned int plen)
{
- /* Ok. Now we want the parameters put in special registers.
- Make sure the compiler is able to make something useful of this. */
+ /* Now we want the parameters in special registers. Make sure the
+ compiler does something usable with this. */
register char *return_dst __asm__ ("r10") = pdst;
- register long n __asm__ ("r12") = plen;
+ register int n __asm__ ("r12") = plen;
register int lc __asm__ ("r11") = c;
- /* Most apps use memset sanely. Only those memsetting about 3..4
- bytes or less get penalized compared to the generic implementation
- - and that's not really sane use. */
+ /* Most apps use memset sanely. Memsetting about 3..4 bytes or less get
+ penalized here compared to the generic implementation. */
- /* Ugh. This is fragile at best. Check with newer GCC releases, if
- they compile cascaded "x |= x << 8" sanely! */
- __asm__("movu.b %0,$r13 \n\
- lslq 8,$r13 \n\
- move.b %0,$r13 \n\
- move.d $r13,%0 \n\
- lslq 16,$r13 \n\
- or.d $r13,%0"
- : "=r" (lc) : "0" (lc) : "r13");
+ /* This is fragile performancewise at best. Check with newer GCC
+ releases, if they compile cascaded "x |= x << 8" to sane code. */
+ __asm__("movu.b %0,r13 \n\
+ lslq 8,r13 \n\
+ move.b %0,r13 \n\
+ move.d r13,%0 \n\
+ lslq 16,r13 \n\
+ or.d r13,%0"
+ : "=r" (lc) /* Inputs. */
+ : "0" (lc) /* Outputs. */
+ : "r13"); /* Trash. */
{
register char *dst __asm__ ("r13") = pdst;
- if (((unsigned long) pdst & 3) != 0
- /* Oops! n=0 must be a legal call, regardless of alignment. */
- && n >= 3)
- {
- if ((unsigned long)dst & 1)
- {
- *dst = (char) lc;
- n--;
- dst++;
- }
-
- if ((unsigned long)dst & 2)
- {
- *(short *)dst = lc;
- n -= 2;
- dst += 2;
- }
- }
+ if (((unsigned long) pdst & 3) != 0
+ /* Oops! n = 0 must be a valid call, regardless of alignment. */
+ && n >= 3)
+ {
+ if ((unsigned long) dst & 1)
+ {
+ *dst = (char) lc;
+ n--;
+ dst++;
+ }
- /* Now the fun part. For the threshold value of this, check the equation
- above. */
- /* Decide which copying method to use. */
- if (n >= ZERO_BLOCK_SIZE)
- {
- /* For large copies we use 'movem' */
-
- /* It is not optimal to tell the compiler about clobbering any
- registers; that will move the saving/restoring of those registers
- to the function prologue/epilogue, and make non-movem sizes
- suboptimal.
-
- This method is not foolproof; it assumes that the "asm reg"
- declarations at the beginning of the function really are used
- here (beware: they may be moved to temporary registers).
- This way, we do not have to save/move the registers around into
- temporaries; we can safely use them straight away. */
- __asm__ __volatile__ (" \n\
- .syntax no_register_prefix \n\
- \n\
- ;; Check that the register asm declaration got right. \n\
- ;; The GCC manual explicitly says there's no warranty for that (too). \n\
- .ifnc %0-%1-%4,$r13-$r12-$r11 \n\
- .err \n\
- .endif \n\
- \n\
- ;; Save the registers we'll clobber in the movem process \n\
- ;; on the stack. Don't mention them to gcc, it will only be \n\
- ;; upset. \n\
- subq 11*4,sp \n\
- movem r10,[sp] \n\
- \n\
- move.d r11,r0 \n\
- move.d r11,r1 \n\
- move.d r11,r2 \n\
- move.d r11,r3 \n\
- move.d r11,r4 \n\
- move.d r11,r5 \n\
- move.d r11,r6 \n\
- move.d r11,r7 \n\
- move.d r11,r8 \n\
- move.d r11,r9 \n\
- move.d r11,r10 \n\
- \n\
- ;; Now we've got this: \n\
- ;; r13 - dst \n\
- ;; r12 - n \n\
- \n\
- ;; Update n for the first loop \n\
- subq 12*4,r12 \n\
-0: \n\
- subq 12*4,r12 \n\
- bge 0b \n\
- movem r11,[r13+] \n\
- \n\
- addq 12*4,r12 ;; compensate for last loop underflowing n \n\
- \n\
- ;; Restore registers from stack \n\
- movem [sp+],r10"
-
- /* Outputs */ : "=r" (dst), "=r" (n)
- /* Inputs */ : "0" (dst), "1" (n), "r" (lc));
+ if ((unsigned long) dst & 2)
+ {
+ *(short *) dst = lc;
+ n -= 2;
+ dst += 2;
+ }
+ }
- }
+ /* Decide which setting method to use. */
+ if (n >= MEMSET_BY_BLOCK_THRESHOLD)
+ {
+ /* It is not optimal to tell the compiler about clobbering any
+ registers; that will move the saving/restoring of those registers
+ to the function prologue/epilogue, and make non-block sizes
+ suboptimal. */
+ __asm__ __volatile__
+ ("\
+ ;; GCC does promise correct register allocations, but let's \n\
+ ;; make sure it keeps its promises. \n\
+ .ifnc %0-%1-%4,$r13-$r12-$r11 \n\
+ .error \"GCC reg alloc bug: %0-%1-%4 != $r13-$r12-$r11\" \n\
+ .endif \n\
+ \n\
+ ;; Save the registers we'll clobber in the movem process \n\
+ ;; on the stack. Don't mention them to gcc, it will only be \n\
+ ;; upset. \n\
+ subq 11*4,sp \n\
+ movem r10,[sp] \n\
+ \n\
+ move.d r11,r0 \n\
+ move.d r11,r1 \n\
+ move.d r11,r2 \n\
+ move.d r11,r3 \n\
+ move.d r11,r4 \n\
+ move.d r11,r5 \n\
+ move.d r11,r6 \n\
+ move.d r11,r7 \n\
+ move.d r11,r8 \n\
+ move.d r11,r9 \n\
+ move.d r11,r10 \n\
+ \n\
+ ;; Now we've got this: \n\
+ ;; r13 - dst \n\
+ ;; r12 - n \n\
+ \n\
+ ;; Update n for the first loop \n\
+ subq 12*4,r12 \n\
+0: \n\
+"
+#ifdef __arch_common_v10_v32
+ /* Cater to branch offset difference between v32 and v10. We
+ assume the branch below has an 8-bit offset. */
+" setf\n"
+#endif
+" subq 12*4,r12 \n\
+ bge 0b \n\
+ movem r11,[r13+] \n\
+ \n\
+ ;; Compensate for last loop underflowing n. \n\
+ addq 12*4,r12 \n\
+ \n\
+ ;; Restore registers from stack. \n\
+ movem [sp+],r10"
+
+ /* Outputs. */
+ : "=r" (dst), "=r" (n)
+
+ /* Inputs. */
+ : "0" (dst), "1" (n), "r" (lc));
+ }
+
+ /* An ad-hoc unroll, used for 4*12-1..16 bytes. */
+ while (n >= 16)
+ {
+ *(long *) dst = lc; dst += 4;
+ *(long *) dst = lc; dst += 4;
+ *(long *) dst = lc; dst += 4;
+ *(long *) dst = lc; dst += 4;
+ n -= 16;
+ }
- /* Either we directly starts copying, using dword copying
- in a loop, or we copy as much as possible with 'movem'
- and then the last block (<44 bytes) is copied here.
- This will work since 'movem' will have updated src,dst,n. */
-
- while ( n >= 16 )
- {
- *((long*)dst)++ = lc;
- *((long*)dst)++ = lc;
- *((long*)dst)++ = lc;
- *((long*)dst)++ = lc;
- n -= 16;
- }
-
- /* A switch() is definitely the fastest although it takes a LOT of code.
- * Particularly if you inline code this.
- */
switch (n)
- {
+ {
case 0:
break;
+
case 1:
- *(char*)dst = (char) lc;
+ *dst = (char) lc;
break;
+
case 2:
- *(short*)dst = (short) lc;
+ *(short *) dst = (short) lc;
break;
+
case 3:
- *((short*)dst)++ = (short) lc;
- *(char*)dst = (char) lc;
+ *(short *) dst = (short) lc; dst += 2;
+ *dst = (char) lc;
break;
+
case 4:
- *((long*)dst)++ = lc;
+ *(long *) dst = lc;
break;
+
case 5:
- *((long*)dst)++ = lc;
- *(char*)dst = (char) lc;
+ *(long *) dst = lc; dst += 4;
+ *dst = (char) lc;
break;
+
case 6:
- *((long*)dst)++ = lc;
- *(short*)dst = (short) lc;
+ *(long *) dst = lc; dst += 4;
+ *(short *) dst = (short) lc;
break;
+
case 7:
- *((long*)dst)++ = lc;
- *((short*)dst)++ = (short) lc;
- *(char*)dst = (char) lc;
+ *(long *) dst = lc; dst += 4;
+ *(short *) dst = (short) lc; dst += 2;
+ *dst = (char) lc;
break;
+
case 8:
- *((long*)dst)++ = lc;
- *((long*)dst)++ = lc;
+ *(long *) dst = lc; dst += 4;
+ *(long *) dst = lc;
break;
+
case 9:
- *((long*)dst)++ = lc;
- *((long*)dst)++ = lc;
- *(char*)dst = (char) lc;
+ *(long *) dst = lc; dst += 4;
+ *(long *) dst = lc; dst += 4;
+ *dst = (char) lc;
break;
+
case 10:
- *((long*)dst)++ = lc;
- *((long*)dst)++ = lc;
- *(short*)dst = (short) lc;
+ *(long *) dst = lc; dst += 4;
+ *(long *) dst = lc; dst += 4;
+ *(short *) dst = (short) lc;
break;
+
case 11:
- *((long*)dst)++ = lc;
- *((long*)dst)++ = lc;
- *((short*)dst)++ = (short) lc;
- *(char*)dst = (char) lc;
+ *(long *) dst = lc; dst += 4;
+ *(long *) dst = lc; dst += 4;
+ *(short *) dst = (short) lc; dst += 2;
+ *dst = (char) lc;
break;
+
case 12:
- *((long*)dst)++ = lc;
- *((long*)dst)++ = lc;
- *((long*)dst)++ = lc;
+ *(long *) dst = lc; dst += 4;
+ *(long *) dst = lc; dst += 4;
+ *(long *) dst = lc;
break;
+
case 13:
- *((long*)dst)++ = lc;
- *((long*)dst)++ = lc;
- *((long*)dst)++ = lc;
- *(char*)dst = (char) lc;
+ *(long *) dst = lc; dst += 4;
+ *(long *) dst = lc; dst += 4;
+ *(long *) dst = lc; dst += 4;
+ *dst = (char) lc;
break;
+
case 14:
- *((long*)dst)++ = lc;
- *((long*)dst)++ = lc;
- *((long*)dst)++ = lc;
- *(short*)dst = (short) lc;
+ *(long *) dst = lc; dst += 4;
+ *(long *) dst = lc; dst += 4;
+ *(long *) dst = lc; dst += 4;
+ *(short *) dst = (short) lc;
break;
+
case 15:
- *((long*)dst)++ = lc;
- *((long*)dst)++ = lc;
- *((long*)dst)++ = lc;
- *((short*)dst)++ = (short) lc;
- *(char*)dst = (char) lc;
+ *(long *) dst = lc; dst += 4;
+ *(long *) dst = lc; dst += 4;
+ *(long *) dst = lc; dst += 4;
+ *(short *) dst = (short) lc; dst += 2;
+ *dst = (char) lc;
break;
- }
+ }
}
- return return_dst; /* destination pointer. */
-} /* memset() */
+ return return_dst;
+}
libc_hidden_def(memset)
diff --git a/libc/string/cris/strcpy.c b/libc/string/cris/strcpy.c
index 955a990b7..40e6389b9 100644
--- a/libc/string/cris/strcpy.c
+++ b/libc/string/cris/strcpy.c
@@ -6,7 +6,6 @@
#include <string.h>
-/* Experimentally off - libc_hidden_proto(strcpy) */
char *strcpy(char *dest, const char *src)
{
char *ret = dest;
diff --git a/libc/string/cris/strncpy.c b/libc/string/cris/strncpy.c
index 3f2775bdd..8d074071a 100644
--- a/libc/string/cris/strncpy.c
+++ b/libc/string/cris/strncpy.c
@@ -6,9 +6,7 @@
#include <string.h>
-/* Experimentally off - libc_hidden_proto(memset) */
-/* Experimentally off - libc_hidden_proto(strncpy) */
char *strncpy(char *dest, const char *src, size_t count)
{
char *ret = dest;
diff --git a/libc/string/dirname.c b/libc/string/dirname.c
index 6265e562e..c7f4dec1f 100644
--- a/libc/string/dirname.c
+++ b/libc/string/dirname.c
@@ -5,7 +5,8 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#include "_string.h"
+#define __need_NULL
+#include <stddef.h>
#include <libgen.h>
char *dirname(char *path)
diff --git a/libc/string/ffs.c b/libc/string/ffs.c
index 241b7456f..f39d304b7 100644
--- a/libc/string/ffs.c
+++ b/libc/string/ffs.c
@@ -5,12 +5,9 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-/* ffsl,ffsll */
-
-#include "_string.h"
-
-/* Experimentally off - libc_hidden_proto(ffs) */
-
+#include <limits.h>
+#include <string.h>
+
int ffs(int i)
{
#if 1
@@ -53,3 +50,6 @@ int ffs(int i)
#endif
}
libc_hidden_def(ffs)
+#if ULONG_MAX == UINT_MAX
+strong_alias_untyped(ffs, ffsl)
+#endif
diff --git a/libc/string/ffsll.c b/libc/string/ffsll.c
new file mode 100644
index 000000000..967fc5168
--- /dev/null
+++ b/libc/string/ffsll.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 1991, 1992, 1997, 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Torbjorn Granlund (tege@sics.se).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <limits.h>
+#include <string.h>
+
+/* Find the first bit set in I. */
+int ffsll (long long int i)
+{
+ unsigned long long int x = i & -i;
+
+ if (x <= 0xffffffff)
+ return ffs (i);
+ else
+ return 32 + ffs (i >> 32);
+}
+
+#if ULONG_MAX != UINT_MAX
+strong_alias_untyped(ffsll, ffsl)
+#endif
diff --git a/libc/string/frv/memcpy.S b/libc/string/frv/memcpy.S
index ae843797d..47773726a 100644
--- a/libc/string/frv/memcpy.S
+++ b/libc/string/frv/memcpy.S
@@ -14,8 +14,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/>.
*/
#include <features.h>
diff --git a/libc/string/frv/memset.S b/libc/string/frv/memset.S
index 477597dcd..17013672e 100644
--- a/libc/string/frv/memset.S
+++ b/libc/string/frv/memset.S
@@ -14,8 +14,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/>.
*/
#include <features.h>
@@ -155,4 +155,4 @@ memset:
bralr
.size memset, .-memset
-/* Experimentally off - libc_hidden_proto(memset) */
+libc_hidden_def(memset)
diff --git a/libc/string/generic/bp-checks.h b/libc/string/generic/bp-checks.h
deleted file mode 100644
index 08c70aa5d..000000000
--- a/libc/string/generic/bp-checks.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/* Bounded-pointer checking macros for C.
- Copyright (C) 2000 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Greg McGary <greg@mcgary.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, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#ifndef _bp_checks_h_
-#define _bp_checks_h_ 1
-
-#if __BOUNDED_POINTERS__
-
-# define BOUNDS_VIOLATED (__builtin_trap (), 0)
-
-/* Verify that pointer's value >= low. Return pointer value. */
-# define CHECK_BOUNDS_LOW(ARG) \
- (((__ptrvalue (ARG) < __ptrlow (ARG)) && BOUNDS_VIOLATED), \
- __ptrvalue (ARG))
-
-/* Verify that pointer's value < high. Return pointer value. */
-# define CHECK_BOUNDS_HIGH(ARG) \
- (((__ptrvalue (ARG) > __ptrhigh (ARG)) && BOUNDS_VIOLATED), \
- __ptrvalue (ARG))
-
-# define _CHECK_N(ARG, N, COND) \
- (((COND) \
- && (__ptrvalue (ARG) < __ptrlow (ARG) \
- || __ptrvalue (ARG) + (N) > __ptrhigh (ARG)) \
- && BOUNDS_VIOLATED), \
- __ptrvalue (ARG))
-
-extern void *__unbounded __ubp_memchr (const void *__unbounded, int, unsigned);
-
-# define _CHECK_STRING(ARG, COND) \
- (((COND) \
- && (__ptrvalue (ARG) < __ptrlow (ARG) \
- || !__ubp_memchr (__ptrvalue (ARG), '\0', \
- (__ptrhigh (ARG) - __ptrvalue (ARG)))) \
- && BOUNDS_VIOLATED), \
- __ptrvalue (ARG))
-
-/* Check bounds of a pointer seated to an array of N objects. */
-# define CHECK_N(ARG, N) _CHECK_N ((ARG), (N), 1)
-/* Same as CHECK_N, but tolerate ARG == NULL. */
-# define CHECK_N_NULL_OK(ARG, N) _CHECK_N ((ARG), (N), __ptrvalue (ARG))
-
-/* Check bounds of a pointer seated to a single object. */
-# define CHECK_1(ARG) CHECK_N ((ARG), 1)
-/* Same as CHECK_1, but tolerate ARG == NULL. */
-# define CHECK_1_NULL_OK(ARG) CHECK_N_NULL_OK ((ARG), 1)
-
-/* Check for NUL-terminator within string's bounds. */
-# define CHECK_STRING(ARG) _CHECK_STRING ((ARG), 1)
-/* Same as CHECK_STRING, but tolerate ARG == NULL. */
-# define CHECK_STRING_NULL_OK(ARG) _CHECK_STRING ((ARG), __ptrvalue (ARG))
-
-/* Check bounds of signal syscall args with type sigset_t. */
-# define CHECK_SIGSET(SET) CHECK_N ((SET), _NSIG / (8 * sizeof *(SET)))
-/* Same as CHECK_SIGSET, but tolerate SET == NULL. */
-# define CHECK_SIGSET_NULL_OK(SET) CHECK_N_NULL_OK ((SET), _NSIG / (8 * sizeof *(SET)))
-
-# if defined (_IOC_SIZESHIFT) && defined (_IOC_SIZEBITS)
-/* Extract the size of the ioctl data and check its bounds. */
-# define CHECK_IOCTL(ARG, CMD) \
- CHECK_N ((const char *) (ARG), \
- (((CMD) >> _IOC_SIZESHIFT) & ((1 << _IOC_SIZEBITS) - 1)))
-# else
-/* We don't know the size of the ioctl data, so the best we can do
- is check that the first byte is within bounds. */
-# define CHECK_IOCTL(ARG, CMD) CHECK_1 ((const char *) ARG)
-# endif
-
-/* Check bounds of `struct flock *' for the locking fcntl commands. */
-# define CHECK_FCNTL(ARG, CMD) \
- (((CMD) == F_GETLK || (CMD) == F_SETLK || (CMD) == F_SETLKW) \
- ? CHECK_1 ((struct flock *) ARG) : (unsigned long) (ARG))
-
-/* Check bounds of an array of mincore residency-status flags that
- cover a region of NBYTES. Such a vector occupies one byte per page
- of memory. */
-# define CHECK_N_PAGES(ARG, NBYTES) \
- ({ int _page_size_ = __sysconf (_SC_PAGE_SIZE); \
- CHECK_N ((const char *) (ARG), \
- ((NBYTES) + _page_size_ - 1) / _page_size_); })
-
-/* Return a bounded pointer with value PTR that satisfies CHECK_N (PTR, N). */
-# define BOUNDED_N(PTR, N) \
- ({ __typeof (PTR) __bounded _p_; \
- __ptrvalue _p_ = __ptrlow _p_ = __ptrvalue (PTR); \
- __ptrhigh _p_ = __ptrvalue _p_ + (N); \
- _p_; })
-
-#else /* !__BOUNDED_POINTERS__ */
-
-/* Do nothing if not compiling with -fbounded-pointers. */
-
-# define BOUNDS_VIOLATED
-# define CHECK_BOUNDS_LOW(ARG) (ARG)
-# define CHECK_BOUNDS_HIGH(ARG) (ARG)
-# define CHECK_1(ARG) (ARG)
-# define CHECK_1_NULL_OK(ARG) (ARG)
-# define CHECK_N(ARG, N) (ARG)
-# define CHECK_N_NULL_OK(ARG, N) (ARG)
-# define CHECK_STRING(ARG) (ARG)
-# define CHECK_SIGSET(SET) (SET)
-# define CHECK_SIGSET_NULL_OK(SET) (SET)
-# define CHECK_IOCTL(ARG, CMD) (ARG)
-# define CHECK_FCNTL(ARG, CMD) (ARG)
-# define CHECK_N_PAGES(ARG, NBYTES) (ARG)
-# define BOUNDED_N(PTR, N) (PTR)
-
-#endif /* !__BOUNDED_POINTERS__ */
-
-#define BOUNDED_1(PTR) BOUNDED_N (PTR, 1)
-
-#endif /* _bp_checks_h_ */
diff --git a/libc/string/generic/memchr.c b/libc/string/generic/memchr.c
index 3c7c997bc..967ae51ea 100644
--- a/libc/string/generic/memchr.c
+++ b/libc/string/generic/memchr.c
@@ -17,22 +17,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 <string.h>
#include <stdlib.h>
#include <limits.h>
-/* Experimentally off - libc_hidden_proto(memchr) */
-libc_hidden_proto(abort)
-
#include "memcopy.h"
#define LONG_MAX_32_BITS 2147483647
/* Search no more than N bytes of S for C. */
+#undef memchr
void *memchr (const void * s, int c_in, size_t n)
{
const unsigned char *char_ptr;
diff --git a/libc/string/generic/memcmp.c b/libc/string/generic/memcmp.c
index fc63a2eae..170c50997 100644
--- a/libc/string/generic/memcmp.c
+++ b/libc/string/generic/memcmp.c
@@ -14,22 +14,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>
#include "memcopy.h"
-/* Experimentally off - libc_hidden_proto(memcmp) */
#include <endian.h>
#if __BYTE_ORDER == __BIG_ENDIAN
-# define WORDS_BIGENDIAN
-#endif
-
-#ifdef WORDS_BIGENDIAN
# define CMP_LT_OR_GT(a, b) ((a) > (b) ? 1 : -1)
#else
# define CMP_LT_OR_GT(a, b) memcmp_bytes ((a), (b))
@@ -48,17 +42,12 @@
3. Compare the few remaining bytes. */
-#ifndef WORDS_BIGENDIAN
+#if __BYTE_ORDER != __BIG_ENDIAN
/* memcmp_bytes -- Compare A and B bytewise in the byte order of the machine.
A and B are known to be different.
This is needed only on little-endian machines. */
-static int memcmp_bytes __P((op_t, op_t));
-
-# ifdef __GNUC__
-__inline
-# endif
-static int
+static __inline__ int
memcmp_bytes (op_t a, op_t b)
{
long int srcp1 = (long int) &a;
@@ -77,8 +66,6 @@ memcmp_bytes (op_t a, op_t b)
}
#endif
-static int memcmp_common_alignment __P((long, long, size_t));
-
/* memcmp_common_alignment -- Compare blocks at SRCP1 and SRCP2 with LEN `op_t'
objects (not LEN bytes!). Both SRCP1 and SRCP2 should be aligned for
memory operations on `op_t's. */
@@ -161,8 +148,6 @@ memcmp_common_alignment (long int srcp1, long int srcp2, size_t len)
return 0;
}
-static int memcmp_not_common_alignment __P((long, long, size_t));
-
/* memcmp_not_common_alignment -- Compare blocks at SRCP1 and SRCP2 with LEN
`op_t' objects (not LEN bytes!). SRCP2 should be aligned for memory
operations on `op_t', but SRCP1 *should be unaligned*. */
diff --git a/libc/string/generic/memcopy.h b/libc/string/generic/memcopy.h
index fab4da764..031557ac8 100644
--- a/libc/string/generic/memcopy.h
+++ b/libc/string/generic/memcopy.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/>. */
/* The strategy of the memory functions is:
@@ -107,7 +106,6 @@ typedef unsigned char byte;
} \
} while (0)
-#ifdef __ARCH_HAS_BWD_MEMCPY__
/* Copy *up to* NBYTES bytes from SRC_BP to DST_BP, with
the assumption that DST_BP is aligned on an OPSIZ multiple. If
not all bytes could be easily copied, store remaining number of bytes
@@ -126,8 +124,6 @@ typedef unsigned char byte;
(nbytes_left) = (nbytes) % OPSIZ; \
} while (0)
-#endif
-
/* Copy *up to* NBYTES_TO_COPY bytes from SRC_END_PTR to DST_END_PTR,
beginning at the words (of type op_t) right before the pointers and
continuing towards smaller addresses. May take advantage of that
diff --git a/libc/string/generic/memcpy.c b/libc/string/generic/memcpy.c
index 4284f2fe5..ca2e7e0f9 100644
--- a/libc/string/generic/memcpy.c
+++ b/libc/string/generic/memcpy.c
@@ -15,15 +15,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 <string.h>
#include "memcopy.h"
#include "pagecopy.h"
+#include "_memcpy_fwd.c"
-/* Experimentally off - libc_hidden_proto(memcpy) */
void *memcpy (void *dstpp, const void *srcpp, size_t len)
{
diff --git a/libc/string/generic/memmem.c b/libc/string/generic/memmem.c
index c75bb2426..753e43ae5 100644
--- a/libc/string/generic/memmem.c
+++ b/libc/string/generic/memmem.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 <string.h>
#include <stddef.h>
#ifdef __USE_GNU
-/* Experimentally off - libc_hidden_proto(memmem) */
-/* Experimentally off - libc_hidden_proto(memcmp) */
/* Return the first occurrence of NEEDLE in HAYSTACK. */
void *memmem (const void *haystack, size_t haystack_len,
@@ -50,5 +47,4 @@ void *memmem (const void *haystack, size_t haystack_len,
return NULL;
}
-libc_hidden_def(memmem)
#endif
diff --git a/libc/string/generic/memmove.c b/libc/string/generic/memmove.c
index 7f945b150..bf78c4778 100644
--- a/libc/string/generic/memmove.c
+++ b/libc/string/generic/memmove.c
@@ -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 <string.h>
@@ -29,8 +28,6 @@
#include "_memcpy_fwd.c"
#endif
-/* Experimentally off - libc_hidden_proto(memmove) */
-/* Experimentally off - libc_hidden_proto(memcpy) */
static void _wordcopy_bwd_aligned (long int dstp, long int srcp, size_t len)
{
diff --git a/libc/string/generic/mempcpy.c b/libc/string/generic/mempcpy.c
index 8d7356486..bb5563a6a 100644
--- a/libc/string/generic/mempcpy.c
+++ b/libc/string/generic/mempcpy.c
@@ -8,13 +8,13 @@
#include <string.h>
#ifdef __USE_GNU
-/* Experimentally off - libc_hidden_proto(mempcpy) */
-/* Experimentally off - libc_hidden_proto(memcpy) */
+# undef mempcpy
void *mempcpy (void *dstpp, const void *srcpp, size_t len)
{
memcpy(dstpp, srcpp, len);
return (void *)(((char *)dstpp) + len);
}
libc_hidden_weak(mempcpy)
+strong_alias(mempcpy,__mempcpy)
#endif
diff --git a/libc/string/generic/memrchr.c b/libc/string/generic/memrchr.c
index 9ab805cf7..b74cf5152 100644
--- a/libc/string/generic/memrchr.c
+++ b/libc/string/generic/memrchr.c
@@ -18,17 +18,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 <string.h>
#include <stdlib.h>
#include <limits.h>
#ifdef __USE_GNU
-/* Experimentally off - libc_hidden_proto(memrchr) */
-libc_hidden_proto(abort)
#include "memcopy.h"
diff --git a/libc/string/generic/memset.c b/libc/string/generic/memset.c
index 62cc36fe3..5644e2522 100644
--- a/libc/string/generic/memset.c
+++ b/libc/string/generic/memset.c
@@ -12,14 +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 <string.h>
#include "memcopy.h"
-/* Experimentally off - libc_hidden_proto(memset) */
void *memset (void *dstpp, int c, size_t len)
{
long int dstp = (long int) dstpp;
diff --git a/libc/string/generic/pagecopy.h b/libc/string/generic/pagecopy.h
index 5a0ada1fa..16aaacab6 100644
--- a/libc/string/generic/pagecopy.h
+++ b/libc/string/generic/pagecopy.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/>. */
/* This file defines the macro:
@@ -40,7 +39,7 @@
*/
-#if PAGE_COPY_THRESHOLD
+#if defined PAGE_COPY_THRESHOLD && PAGE_COPY_THRESHOLD
#include <assert.h>
@@ -48,7 +47,7 @@
do \
{ \
if ((nbytes) >= PAGE_COPY_THRESHOLD && \
- PAGE_OFFSET ((dstp) - (srcp)) == 0) \
+ PAGE_OFFSET ((dstp) - (srcp)) == 0) \
{ \
/* The amount to copy is past the threshold for copying \
pages virtually with kernel VM operations, and the \
diff --git a/libc/string/generic/rawmemchr.c b/libc/string/generic/rawmemchr.c
index f8b97a61d..816589649 100644
--- a/libc/string/generic/rawmemchr.c
+++ b/libc/string/generic/rawmemchr.c
@@ -17,17 +17,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 <string.h>
#include <stdlib.h>
#include <limits.h>
#ifdef __USE_GNU
-/* Experimentally off - libc_hidden_proto(rawmemchr) */
-libc_hidden_proto(abort)
#include "memcopy.h"
diff --git a/libc/string/generic/strcat.c b/libc/string/generic/strcat.c
index e00494038..68fc2a289 100644
--- a/libc/string/generic/strcat.c
+++ b/libc/string/generic/strcat.c
@@ -12,14 +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 <string.h>
#include "memcopy.h"
-/* Experimentally off - libc_hidden_proto(strcat) */
/* Append SRC on the end of DEST. */
char *strcat (char *dest, const char *src)
{
diff --git a/libc/string/generic/strchr.c b/libc/string/generic/strchr.c
index 66aed1e25..321d2b8c3 100644
--- a/libc/string/generic/strchr.c
+++ b/libc/string/generic/strchr.c
@@ -17,15 +17,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 <string.h>
#include <stdlib.h>
-/* Experimentally off - libc_hidden_proto(strchr) */
-libc_hidden_proto(abort)
#include "memcopy.h"
diff --git a/libc/string/generic/strchrnul.c b/libc/string/generic/strchrnul.c
index 72cab2891..d11d9e00d 100644
--- a/libc/string/generic/strchrnul.c
+++ b/libc/string/generic/strchrnul.c
@@ -17,16 +17,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 <string.h>
#include <stdlib.h>
#ifdef __USE_GNU
-/* Experimentally off - libc_hidden_proto(strchrnul) */
-libc_hidden_proto(abort)
#include "memcopy.h"
diff --git a/libc/string/generic/strcmp.c b/libc/string/generic/strcmp.c
index 50acd3548..24ad14382 100644
--- a/libc/string/generic/strcmp.c
+++ b/libc/string/generic/strcmp.c
@@ -12,15 +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 <string.h>
#include "memcopy.h"
-/* Experimentally off - libc_hidden_proto(strcmp) */
/* Compare S1 and S2, returning less than, equal to or
greater than zero if S1 is lexicographically less than,
equal to or greater than S2. */
@@ -44,7 +42,6 @@ int strcmp (const char *p1, const char *p2)
libc_hidden_weak(strcmp)
#ifndef __UCLIBC_HAS_LOCALE__
-/* Experimentally off - libc_hidden_proto(strcoll) */
strong_alias(strcmp,strcoll)
libc_hidden_def(strcoll)
#endif
diff --git a/libc/string/generic/strcpy.c b/libc/string/generic/strcpy.c
index 99e077139..924615fca 100644
--- a/libc/string/generic/strcpy.c
+++ b/libc/string/generic/strcpy.c
@@ -12,36 +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/>. */
#include <string.h>
-#include <stddef.h>
-#include "memcopy.h"
-#include "bp-checks.h"
-
-/* Experimentally off - libc_hidden_proto(strcpy) */
/* Copy SRC to DEST. */
-char *strcpy (char *dest, const char *src)
+char *strcpy(char *dest, const char *src)
{
- reg_char c;
- char *__unbounded s = (char *__unbounded) CHECK_BOUNDS_LOW (src);
- const ptrdiff_t off = CHECK_BOUNDS_LOW (dest) - s - 1;
- size_t n;
-
- do
- {
- c = *s++;
- s[off] = c;
- }
- while (c != '\0');
+ char *dst = dest;
- n = s - src;
- (void) CHECK_BOUNDS_HIGH (src + n);
- (void) CHECK_BOUNDS_HIGH (dest + n);
+ while ((*dst = *src) != '\0') {
+ src++;
+ dst++;
+ }
- return dest;
+ return dest;
}
libc_hidden_def(strcpy)
diff --git a/libc/string/generic/strcspn.c b/libc/string/generic/strcspn.c
index b65b3b995..ca9506bdd 100644
--- a/libc/string/generic/strcspn.c
+++ b/libc/string/generic/strcspn.c
@@ -12,14 +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 <string.h>
-/* Experimentally off - libc_hidden_proto(strcspn) */
-/* Experimentally off - libc_hidden_proto(strchr) */
/* Return the length of the maximum initial segment of S
which contains no characters from REJECT. */
diff --git a/libc/string/generic/strlen.c b/libc/string/generic/strlen.c
index 764dae18d..dc383398b 100644
--- a/libc/string/generic/strlen.c
+++ b/libc/string/generic/strlen.c
@@ -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 <string.h>
#include <stdlib.h>
-/* Experimentally off - libc_hidden_proto(strlen) */
-libc_hidden_proto(abort)
/* Return the length of the null-terminated string STR. Scan for
the null terminator quickly by testing four bytes at a time. */
diff --git a/libc/string/generic/strncat.c b/libc/string/generic/strncat.c
index 8e3423e49..f0cf8f995 100644
--- a/libc/string/generic/strncat.c
+++ b/libc/string/generic/strncat.c
@@ -12,15 +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 <string.h>
#include "memcopy.h"
-/* Experimentally off - libc_hidden_proto(strncat) */
char *strncat (char *s1, const char *s2, size_t n)
{
reg_char c;
diff --git a/libc/string/generic/strncmp.c b/libc/string/generic/strncmp.c
index c49f36d8b..ca980415e 100644
--- a/libc/string/generic/strncmp.c
+++ b/libc/string/generic/strncmp.c
@@ -12,14 +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 <string.h>
#include "memcopy.h"
-/* Experimentally off - libc_hidden_proto(strncmp) */
/* Compare no more than N characters of S1 and S2,
returning less than, equal to or greater than zero
if S1 is lexicographically less than, equal to or
diff --git a/libc/string/generic/strncpy.c b/libc/string/generic/strncpy.c
index d2d693f2b..0256bcc6b 100644
--- a/libc/string/generic/strncpy.c
+++ b/libc/string/generic/strncpy.c
@@ -12,14 +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 <string.h>
#include "memcopy.h"
-/* Experimentally off - libc_hidden_proto(strncpy) */
char *strncpy (char *s1, const char *s2, size_t n)
{
reg_char c;
diff --git a/libc/string/generic/strnlen.c b/libc/string/generic/strnlen.c
index d9ba76129..4d4cde84f 100644
--- a/libc/string/generic/strnlen.c
+++ b/libc/string/generic/strnlen.c
@@ -17,16 +17,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; 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/>. */
#include <string.h>
#include <stdlib.h>
#ifdef __USE_GNU
-/* Experimentally off - libc_hidden_proto(strnlen) */
-libc_hidden_proto(abort)
/* Find the length of S, but scan at most MAXLEN characters. If no
'\0' terminator is found in that many characters, return MAXLEN. */
@@ -34,7 +31,7 @@ size_t strnlen (const char *str, size_t maxlen)
{
const char *char_ptr, *end_ptr = str + maxlen;
const unsigned long int *longword_ptr;
- unsigned long int longword, magic_bits, himagic, lomagic;
+ unsigned long int longword, himagic, lomagic;
if (maxlen == 0)
return 0;
@@ -68,14 +65,12 @@ size_t strnlen (const char *str, size_t maxlen)
The 1-bits make sure that carries propagate to the next 0-bit.
The 0-bits provide holes for carries to fall into. */
- magic_bits = 0x7efefeffL;
himagic = 0x80808080L;
lomagic = 0x01010101L;
if (sizeof (longword) > 4)
{
/* 64-bit version of the magic. */
/* Do the shift in two steps to avoid a warning if long has 32 bits. */
- magic_bits = ((0x7efefefeL << 16) << 16) | 0xfefefeffL;
himagic = ((himagic << 16) << 16) | himagic;
lomagic = ((lomagic << 16) << 16) | lomagic;
}
diff --git a/libc/string/generic/strrchr.c b/libc/string/generic/strrchr.c
index c85707241..8ca404843 100644
--- a/libc/string/generic/strrchr.c
+++ b/libc/string/generic/strrchr.c
@@ -12,14 +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 <string.h>
-/* Experimentally off - libc_hidden_proto(strrchr) */
-/* Experimentally off - libc_hidden_proto(strchr) */
/* Find the last occurrence of C in S. */
char *strrchr (const char *s, int c)
diff --git a/libc/string/generic/strsep.c b/libc/string/generic/strsep.c
index e02e57068..bbdaf8849 100644
--- a/libc/string/generic/strsep.c
+++ b/libc/string/generic/strsep.c
@@ -12,18 +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 <string.h>
#ifdef __USE_BSD
-/* Experimentally off - libc_hidden_proto(strchr) */
-/* Experimentally off - libc_hidden_proto(strpbrk) */
-/* Experimentally off - libc_hidden_proto(strsep) */
char *strsep (char **stringp, const char *delim)
{
char *begin, *end;
diff --git a/libc/string/generic/strspn.c b/libc/string/generic/strspn.c
index 010567744..86bcdcb70 100644
--- a/libc/string/generic/strspn.c
+++ b/libc/string/generic/strspn.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 <string.h>
-/* Experimentally off - libc_hidden_proto(strspn) */
/* Return the length of the maximum initial segment
of S which contains only characters in ACCEPT. */
size_t strspn (const char *s, const char *accept)
diff --git a/libc/string/generic/strstr.c b/libc/string/generic/strstr.c
index c12dceb33..dd101768b 100644
--- a/libc/string/generic/strstr.c
+++ b/libc/string/generic/strstr.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/>. */
/*
* My personal strstr() implementation that beats most other algorithms.
@@ -28,7 +27,6 @@
#include <string.h>
-/* Experimentally off - libc_hidden_proto(strstr) */
typedef unsigned chartype;
diff --git a/libc/string/generic/strtok_r.c b/libc/string/generic/strtok_r.c
index d082d226e..253964395 100644
--- a/libc/string/generic/strtok_r.c
+++ b/libc/string/generic/strtok_r.c
@@ -13,33 +13,27 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 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(strtok_r) */
-/* Experimentally off - libc_hidden_proto(strspn) */
-/* Experimentally off - libc_hidden_proto(strpbrk) */
#ifdef __USE_GNU
# define __rawmemchr rawmemchr
-/* Experimentally off - libc_hidden_proto(rawmemchr) */
#else
# define __rawmemchr strchr
-/* Experimentally off - libc_hidden_proto(strchr) */
#endif
-
-/* Parse S into tokens separated by characters in DELIM.
+#if 0
+ Parse S into tokens separated by characters in DELIM.
If S is NULL, the saved pointer in SAVE_PTR is used as
the next starting point. For example:
char s[] = "-abc-=-def";
char *sp;
- x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def"
- x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL
- x = strtok_r(NULL, "=", &sp); // x = NULL
- // s = "abc\0-def\0"
-*/
+ x = strtok_r(s, "-", &sp); /* x = "abc", sp = "=-def" */
+ x = strtok_r(NULL, "-=", &sp); /* x = "def", sp = NULL */
+ x = strtok_r(NULL, "=", &sp); /* x = NULL */
+ /* s = "abc\0-def\0" */
+#endif
char *strtok_r (char *s, const char *delim, char **save_ptr)
{
char *token;
diff --git a/libc/string/i386/memchr.c b/libc/string/i386/memchr.c
index fe4537914..1960f6ba4 100644
--- a/libc/string/i386/memchr.c
+++ b/libc/string/i386/memchr.c
@@ -32,20 +32,44 @@
#include <string.h>
-/* Experimentally off - libc_hidden_proto(memchr) */
-void *memchr(const void *cs, int c, size_t count)
+#undef memchr
+/*#define memchr TESTING*/
+void *memchr(const void *s, int c, size_t count)
{
- int d0;
- register void * __res;
- if (!count)
- return NULL;
- __asm__ __volatile__(
- "repne\n\t"
- "scasb\n\t"
- "je 1f\n\t"
- "movl $1,%0\n"
- "1:\tdecl %0"
- :"=D" (__res), "=&c" (d0) : "a" (c),"0" (cs),"1" (count));
- return __res;
+ void *edi;
+ int ecx;
+ __asm__ __volatile__(
+ " jecxz 1f\n"
+ " repne; scasb\n"
+ " leal -1(%%edi), %%edi\n"
+ " je 2f\n"
+ "1:\n"
+ " xorl %%edi, %%edi\n" /* NULL */
+ "2:\n"
+ : "=&D" (edi), "=&c" (ecx)
+ : "a" (c), "0" (s), "1" (count)
+ /* : no clobbers */
+ );
+ return edi;
}
+#ifndef memchr
libc_hidden_def(memchr)
+#else
+/* Uncomment TESTING, gcc -D_GNU_SOURCE -m32 -Os memchr.c -o memchr
+ * and run ./memchr
+ */
+int main()
+{
+ static const char str[] = "abc.def";
+ printf((char*)memchr(str, '.',-2) - str == 3 ? "ok\n" : "BAD!\n");
+ printf((char*)memchr(str, '.',-1) - str == 3 ? "ok\n" : "BAD!\n");
+ printf((char*)memchr(str, '.', 0) == NULL ? "ok\n" : "BAD!\n");
+ printf((char*)memchr(str, '.', 1) == NULL ? "ok\n" : "BAD!\n");
+ printf((char*)memchr(str, '.', 2) == NULL ? "ok\n" : "BAD!\n");
+ printf((char*)memchr(str, '.', 3) == NULL ? "ok\n" : "BAD!\n");
+ printf((char*)memchr(str, '.', 4) - str == 3 ? "ok\n" : "BAD!\n");
+ printf((char*)memchr(str, '.', 5) - str == 3 ? "ok\n" : "BAD!\n");
+ printf((char*)memchr(str+3, '.', 0) == NULL ? "ok\n" : "BAD!\n");
+ printf((char*)memchr(str+3, '.', 5) - str == 3 ? "ok\n" : "BAD!\n");
+}
+#endif
diff --git a/libc/string/i386/memcpy.c b/libc/string/i386/memcpy.c
index 285583f3b..697d0bdc2 100644
--- a/libc/string/i386/memcpy.c
+++ b/libc/string/i386/memcpy.c
@@ -32,22 +32,23 @@
#include <string.h>
-/* Experimentally off - libc_hidden_proto(memcpy) */
+#undef memcpy
void *memcpy(void * to, const void * from, size_t n)
{
- int d0, d1, d2;
- __asm__ __volatile__(
- "rep ; movsl\n\t"
- "testb $2,%b4\n\t"
- "je 1f\n\t"
- "movsw\n"
- "1:\ttestb $1,%b4\n\t"
- "je 2f\n\t"
- "movsb\n"
- "2:"
- : "=&c" (d0), "=&D" (d1), "=&S" (d2)
- :"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from)
- : "memory");
- return (to);
+ int d0, d1, d2;
+ __asm__ __volatile__(
+ " rep; movsl\n"
+ " movl %4, %%ecx\n"
+ " andl $3, %%ecx\n"
+ /* jz is optional. avoids "rep; movsb" with ecx == 0,
+ * but adds a branch, which is currently (2008) faster */
+ " jz 1f\n"
+ " rep; movsb\n"
+ "1:\n"
+ : "=&c" (d0), "=&D" (d1), "=&S" (d2)
+ : "0" (n / 4), "g" (n), "1" ((long)to), "2" ((long)from)
+ : "memory"
+ );
+ return to;
}
libc_hidden_def(memcpy)
diff --git a/libc/string/i386/memmove.c b/libc/string/i386/memmove.c
index a924efcbc..0ec8016a5 100644
--- a/libc/string/i386/memmove.c
+++ b/libc/string/i386/memmove.c
@@ -32,28 +32,40 @@
#include <string.h>
-/* Experimentally off - libc_hidden_proto(memmove) */
+#undef memmove
+/*#define memmove TESTING*/
void *memmove(void *dest, const void *src, size_t n)
{
- int d0, d1, d2;
- if (dest<src)
+ int eax, ecx, esi, edi;
__asm__ __volatile__(
- "rep\n\t"
- "movsb"
- : "=&c" (d0), "=&S" (d1), "=&D" (d2)
- :"0" (n),"1" (src),"2" (dest)
- : "memory");
- else
- __asm__ __volatile__(
- "std\n\t"
- "rep\n\t"
- "movsb\n\t"
- "cld"
- : "=&c" (d0), "=&S" (d1), "=&D" (d2)
- :"0" (n),
- "1" (n-1+(const char *)src),
- "2" (n-1+(char *)dest)
- :"memory");
- return dest;
+ " movl %%eax, %%edi\n"
+ " cmpl %%esi, %%eax\n"
+ " je 2f\n" /* (optional) src == dest -> NOP */
+ " jb 1f\n" /* src > dest -> simple copy */
+ " leal -1(%%esi,%%ecx), %%esi\n"
+ " leal -1(%%eax,%%ecx), %%edi\n"
+ " std\n"
+ "1: rep; movsb\n"
+ " cld\n"
+ "2:\n"
+ : "=&c" (ecx), "=&S" (esi), "=&a" (eax), "=&D" (edi)
+ : "0" (n), "1" (src), "2" (dest)
+ : "memory"
+ );
+ return (void*)eax;
}
+#ifndef memmove
libc_hidden_def(memmove)
+#else
+/* Uncomment TESTING, gcc -D_GNU_SOURCE -m32 -Os memmove.c -o memmove
+ * and run ./memmove
+ */
+int main()
+{
+ static char str[] = "abcdef.123";
+ memmove(str + 1, str, 5);
+ printf(strcmp(str, "aabcde.123") == 0 ? "ok\n" : "BAD!\n");
+ memmove(str, str + 1, 5);
+ printf(strcmp(str, "abcdee.123") == 0 ? "ok\n" : "BAD!\n");
+}
+#endif
diff --git a/libc/string/i386/memset.c b/libc/string/i386/memset.c
index bbaa45215..9f51f3c60 100644
--- a/libc/string/i386/memset.c
+++ b/libc/string/i386/memset.c
@@ -28,20 +28,68 @@
* More importantly, these should provide a good example for
* others to follow when adding arch specific optimizations.
* -Erik
+ *
+ * 2009-04: modified by Denys Vlasenko <vda.linux@googlemail.com>
+ * Fill byte-by-byte is a bit too slow. I prefer 46 byte function
+ * which fills x4 faster than 21 bytes one.
*/
#include <string.h>
-/* Experimentally off - libc_hidden_proto(memset) */
+#undef memset
void *memset(void *s, int c, size_t count)
{
- int d0, d1;
- __asm__ __volatile__(
- "rep\n\t"
- "stosb"
- : "=&c" (d0), "=&D" (d1)
- :"a" (c),"1" (s),"0" (count)
- :"memory");
- return s;
+ int reg, edi;
+ __asm__ __volatile__(
+
+ /* Most of the time, count is divisible by 4 and nonzero */
+ /* It's better to make this case faster */
+ /* " jecxz 9f\n" - (optional) count == 0: goto ret */
+ " mov %%ecx, %1\n"
+ " shr $2, %%ecx\n"
+ " jz 1f\n" /* zero words: goto fill_bytes */
+ /* extend 8-bit fill to 32 bits */
+ " movzx %%al, %%eax\n" /* 3 bytes */
+ /* or: " and $0xff, %%eax\n" - 5 bytes */
+ " imul $0x01010101, %%eax\n" /* 6 bytes */
+ /* fill full words */
+ " rep; stosl\n"
+ /* fill 0-3 bytes */
+ "1: and $3, %1\n"
+ " jz 9f\n" /* (count & 3) == 0: goto end */
+ "2: stosb\n"
+ " dec %1\n"
+ " jnz 2b\n"
+ /* end */
+ "9:\n"
+
+ : "=&D" (edi), "=&r" (reg)
+ : "0" (s), "a" (c), "c" (count)
+ : "memory"
+ );
+ return s;
}
libc_hidden_def(memset)
+
+/*
+gcc 4.3.1
+=========
+57 push %edi
+8b 7c 24 08 mov 0x8(%esp),%edi
+8b 4c 24 10 mov 0x10(%esp),%ecx
+8b 44 24 0c mov 0xc(%esp),%eax
+89 ca mov %ecx,%edx
+c1 e9 02 shr $0x2,%ecx
+74 0b je 1f <__GI_memset+0x1f>
+0f b6 c0 movzbl %al,%eax
+69 c0 01 01 01 01 imul $0x1010101,%eax,%eax
+f3 ab rep stos %eax,%es:(%edi)
+83 e2 03 and $0x3,%edx
+74 04 je 28 <__GI_memset+0x28>
+aa stos %al,%es:(%edi)
+4a dec %edx
+75 fc jne 24 <__GI_memset+0x24>
+8b 44 24 08 mov 0x8(%esp),%eax
+5f pop %edi
+c3 ret
+*/
diff --git a/libc/string/i386/rawmemchr.c b/libc/string/i386/rawmemchr.c
new file mode 100644
index 000000000..be0b142c3
--- /dev/null
+++ b/libc/string/i386/rawmemchr.c
@@ -0,0 +1,24 @@
+/*
+ * Adapted from strlen.c code
+ *
+ * Copyright (C) 2008 Denys Vlasenko <vda.linux@googlemail.com>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <string.h>
+
+#undef rawmemchr
+void *rawmemchr(const void *s, int c)
+{
+ void *eax;
+ int ecx, edi;
+ __asm__ __volatile__(
+ " repne; scasb\n"
+ " leal -1(%%edi), %%eax\n"
+ : "=&c" (ecx), "=&D" (edi), "=&a" (eax)
+ : "0" (0xffffffff), "1" (s), "2" (c)
+ );
+ return eax;
+}
+libc_hidden_def(rawmemchr)
diff --git a/libc/string/i386/strcat.c b/libc/string/i386/strcat.c
index 2cf0237a6..e71aad4f7 100644
--- a/libc/string/i386/strcat.c
+++ b/libc/string/i386/strcat.c
@@ -32,7 +32,6 @@
#include <string.h>
-/* Experimentally off - libc_hidden_proto(strcat) */
char *strcat(char * dest, const char * src)
{
int d0, d1, d2, d3;
diff --git a/libc/string/i386/strchr.c b/libc/string/i386/strchr.c
index 46b1dfb6e..93cc9583e 100644
--- a/libc/string/i386/strchr.c
+++ b/libc/string/i386/strchr.c
@@ -32,23 +32,25 @@
#include <string.h>
-/* Experimentally off - libc_hidden_proto(strchr) */
+#undef strchr
char *strchr(const char *s, int c)
{
- int d0;
- register char * __res;
- __asm__ __volatile__(
- "movb %%al,%%ah\n"
- "1:\tlodsb\n\t"
- "cmpb %%ah,%%al\n\t"
- "je 2f\n\t"
- "testb %%al,%%al\n\t"
- "jne 1b\n\t"
- "movl $1,%1\n"
- "2:\tmovl %1,%0\n\t"
- "decl %0"
- :"=a" (__res), "=&S" (d0) : "1" (s),"0" (c));
- return __res;
+ int esi;
+ register char * eax;
+ __asm__ __volatile__(
+ " movb %%al, %%ah\n"
+ "1: lodsb\n"
+ " cmpb %%ah, %%al\n"
+ " je 2f\n"
+ " testb %%al, %%al\n"
+ " jnz 1b\n"
+ " movl $1, %%esi\n" /* can use shorter xor + inc */
+ "2: leal -1(%%esi), %%eax\n"
+ : "=a" (eax), "=&S" (esi)
+ : "0" (c), "1" (s)
+ /* no clobbers */
+ );
+ return eax;
}
libc_hidden_def(strchr)
#ifdef __UCLIBC_SUSV3_LEGACY__
diff --git a/libc/string/i386/strchrnul.c b/libc/string/i386/strchrnul.c
new file mode 100644
index 000000000..d48427214
--- /dev/null
+++ b/libc/string/i386/strchrnul.c
@@ -0,0 +1,47 @@
+/*
+ * Adapted from strchr.c code
+ *
+ * Copyright (C) 2008 Denys Vlasenko <vda.linux@googlemail.com>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <string.h>
+
+#undef strchrnul
+/*#define strchrnul TESTING*/
+char *strchrnul(const char *s, int c)
+{
+ int esi;
+ char *eax;
+ __asm__ __volatile__(
+ " movb %%al, %%ah\n"
+ "1: lodsb\n"
+ " cmpb %%ah, %%al\n"
+ " je 2f\n"
+ " testb %%al, %%al\n"
+ " jnz 1b\n"
+ /* with this, we'd get strchr(): */
+ /* " movl $1, %%esi\n" */
+ "2: leal -1(%%esi), %%eax\n"
+ : "=a" (eax), "=&S" (esi)
+ : "0" (c), "1" (s)
+ /* no clobbers */
+ );
+ return eax;
+}
+#ifndef strchrnul
+libc_hidden_def(strchrnul)
+#else
+/* Uncomment TESTING, gcc -D_GNU_SOURCE -m32 -Os strchrnul.c -o strchrnul
+ * and run ./strchrnul
+ */
+int main()
+{
+ static const char str[] = "abc.def";
+ printf((char*)strchrnul(str, '.') - str == 3 ? "ok\n" : "BAD!\n");
+ printf((char*)strchrnul(str, '*') - str == 7 ? "ok\n" : "BAD!\n");
+ printf((char*)strchrnul(str, 0) - str == 7 ? "ok\n" : "BAD!\n");
+ printf((char*)strchrnul(str+3, '.') - str == 3 ? "ok\n" : "BAD!\n");
+}
+#endif
diff --git a/libc/string/i386/strcmp.c b/libc/string/i386/strcmp.c
index eff230c5c..9621f66f8 100644
--- a/libc/string/i386/strcmp.c
+++ b/libc/string/i386/strcmp.c
@@ -32,7 +32,6 @@
#include <string.h>
-/* Experimentally off - libc_hidden_proto(strcmp) */
int strcmp(const char *cs, const char *ct)
{
int d0, d1;
@@ -55,7 +54,6 @@ int strcmp(const char *cs, const char *ct)
libc_hidden_def(strcmp)
#ifndef __UCLIBC_HAS_LOCALE__
-/* Experimentally off - libc_hidden_proto(strcoll) */
strong_alias(strcmp,strcoll)
libc_hidden_def(strcoll)
#endif
diff --git a/libc/string/i386/strcpy.c b/libc/string/i386/strcpy.c
index 09065a9b7..fff1bd006 100644
--- a/libc/string/i386/strcpy.c
+++ b/libc/string/i386/strcpy.c
@@ -32,7 +32,7 @@
#include <string.h>
-/* Experimentally off - libc_hidden_proto(strcpy) */
+#undef strcpy
char *strcpy(char * dest, const char * src)
{
int d0, d1, d2;
diff --git a/libc/string/i386/string.h b/libc/string/i386/string.h
new file mode 100644
index 000000000..cf4333dec
--- /dev/null
+++ b/libc/string/i386/string.h
@@ -0,0 +1,338 @@
+/*
+ * Copyright (C) 2008 Denys Vlasenko <vda.linux@googlemail.com>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball
+ */
+
+#if !defined _STRING_H
+#error "Never use <libc-string_i386.h> directly; include <string.h> instead"
+#endif
+
+#ifndef _LIBC_STRING_i386_H
+#define _LIBC_STRING_i386_H 1
+
+static __always_inline
+void *inlined_memset_const_c_count4(void *s, unsigned eax, unsigned count)
+{
+ int ecx, edi;
+
+ if (count == 0)
+ return s;
+
+ /* Very small (2 stores or less) are best done with direct
+ * mov <const>,<mem> instructions (they do not clobber registers) */
+ if (count == 1) {
+ *(char *)(s + 0) = eax;
+ return s;
+ }
+
+ /* You wonder why & 0xff is needed? Try memset(p, '\xff', size).
+ * If char is signed, '\xff' == -1! */
+ eax = (eax & 0xff) * 0x01010101; /* done at compile time */
+
+ if (count == 2) {
+ *(short *)(s + 0) = eax;
+ return s;
+ }
+ if (count == 3) {
+ *(short *)(s + 0) = eax;
+ *(char *) (s + 2) = eax;
+ return s;
+ }
+ if (count == 1*4 + 0) {
+ *(int *)(s + 0) = eax;
+ return s;
+ }
+ if (count == 1*4 + 1) {
+ *(int *) (s + 0) = eax;
+ *(char *)(s + 4) = eax;
+ return s;
+ }
+ if (count == 1*4 + 2) {
+ *(int *) (s + 0) = eax;
+ *(short *)(s + 4) = eax;
+ return s;
+ }
+
+ /* Small string stores: don't clobber ecx
+ * (clobbers only eax and edi) */
+#define small_store(arg) { \
+ __asm__ __volatile__( \
+ arg \
+ : "=&D" (edi) \
+ : "a" (eax), "0" (s) \
+ : "memory" \
+ ); \
+ return s; \
+}
+ if (count == 1*4 + 3) small_store("stosl; stosw; stosb");
+ if (count == 2*4 + 0) {
+ ((int *)s)[0] = eax;
+ ((int *)s)[1] = eax;
+ return s;
+ }
+ if (count == 2*4 + 1) small_store("stosl; stosl; stosb");
+ if (count == 2*4 + 2) small_store("stosl; stosl; stosw");
+ if (count == 2*4 + 3) small_store("stosl; stosl; stosw; stosb");
+ if (count == 3*4 + 0) small_store("stosl; stosl; stosl");
+ if (count == 3*4 + 1) small_store("stosl; stosl; stosl; stosb");
+ if (count == 3*4 + 2) small_store("stosl; stosl; stosl; stosw");
+ if (count == 3*4 + 3) small_store("stosl; stosl; stosl; stosw; stosb");
+ if (count == 4*4 + 0) small_store("stosl; stosl; stosl; stosl");
+ if (count == 4*4 + 1) small_store("stosl; stosl; stosl; stosl; stosb");
+ /* going over 7 bytes is suboptimal */
+ /* stosw is 2-byte insn, so this one takes 6 bytes: */
+ if (count == 4*4 + 2) small_store("stosl; stosl; stosl; stosl; stosw");
+ /* 7 bytes */
+ if (count == 4*4 + 3) small_store("stosl; stosl; stosl; stosl; stosw; stosb");
+ /* 5 bytes */
+ if (count == 5*4 + 0) small_store("stosl; stosl; stosl; stosl; stosl");
+ /* 6 bytes */
+ if (count == 5*4 + 1) small_store("stosl; stosl; stosl; stosl; stosl; stosb");
+ /* 7 bytes */
+ if (count == 5*4 + 2) small_store("stosl; stosl; stosl; stosl; stosl; stosw");
+ /* 8 bytes, but oh well... */
+ if (count == 5*4 + 3) small_store("stosl; stosl; stosl; stosl; stosl; stosw; stosb");
+ /* 6 bytes */
+ if (count == 6*4 + 0) small_store("stosl; stosl; stosl; stosl; stosl; stosl");
+ /* the rest would be 7+ bytes and is handled below instead */
+#undef small_store
+
+ /* Not small, but multiple-of-4 store.
+ * "mov <const>,%ecx; rep; stosl" sequence is 7 bytes */
+ __asm__ __volatile__(
+ " rep; stosl\n"
+ : "=&c" (ecx), "=&D" (edi)
+ : "a" (eax), "0" (count / 4), "1" (s)
+ : "memory"
+ );
+ return s;
+}
+#if 1 /* -51 bytes on shared i386 build with gcc 4.3.0 */
+#define memset(s, c, count) ( \
+ ( !(__builtin_constant_p(c) && __builtin_constant_p(count)) \
+ || ((count) > (6*4 + 0) && ((count) % 4) != 0) \
+ ) \
+ ? memset((s), (c), (count)) \
+ : inlined_memset_const_c_count4((s), (c), (count)) \
+ )
+#endif
+
+
+static __always_inline
+void *inlined_mempcpy_const_count4(void *d, const void *s, unsigned count)
+{
+ int ecx;
+ char *esi, *edi;
+
+ if (count == 0)
+ return d;
+
+ if (count == 1) {
+ *(char *)d = *(char *)s;
+ return d + 1;
+ }
+ if (count == 2) {
+ *(short *)d = *(short *)s;
+ return d + 2;
+ }
+ /* Small string moves: don't clobber ecx
+ * (clobbers only esi and edi) */
+#define small_move(arg) { \
+ __asm__ __volatile__( \
+ arg \
+ : "=&S" (esi), "=&D" (edi) \
+ : "0" (s), "1" (d) \
+ : "memory" \
+ ); \
+ return edi; \
+}
+ if (count == 3) small_move("movsw; movsb");
+ if (count == 1*4 + 0) {
+ *(int *)d = *(int *)s;
+ return d + 4;
+ }
+ if (count == 1*4 + 1) small_move("movsl; movsb");
+ if (count == 1*4 + 2) small_move("movsl; movsw");
+ if (count == 1*4 + 3) small_move("movsl; movsw; movsb");
+ if (count == 2*4 + 0) small_move("movsl; movsl");
+ if (count == 2*4 + 1) small_move("movsl; movsl; movsb");
+ if (count == 2*4 + 2) small_move("movsl; movsl; movsw");
+ if (count == 2*4 + 3) small_move("movsl; movsl; movsw; movsb");
+ if (count == 3*4 + 0) small_move("movsl; movsl; movsl");
+ if (count == 3*4 + 1) small_move("movsl; movsl; movsl; movsb");
+ if (count == 3*4 + 2) small_move("movsl; movsl; movsl; movsw");
+ if (count == 3*4 + 3) small_move("movsl; movsl; movsl; movsw; movsb");
+ if (count == 4*4 + 0) small_move("movsl; movsl; movsl; movsl");
+ if (count == 4*4 + 1) small_move("movsl; movsl; movsl; movsl; movsb");
+ /* going over 7 bytes is suboptimal */
+ /* movsw is 2-byte insn, so this one takes 6 bytes: */
+ if (count == 4*4 + 2) small_move("movsl; movsl; movsl; movsl; movsw");
+ /* 7 bytes */
+ if (count == 4*4 + 3) small_move("movsl; movsl; movsl; movsl; movsw; movsb");
+ /* 5 bytes */
+ if (count == 5*4 + 0) small_move("movsl; movsl; movsl; movsl; movsl");
+ /* 6 bytes */
+ if (count == 5*4 + 1) small_move("movsl; movsl; movsl; movsl; movsl; movsb");
+ /* 7 bytes */
+ if (count == 5*4 + 2) small_move("movsl; movsl; movsl; movsl; movsl; movsw");
+ /* 8 bytes, but oh well... */
+ if (count == 5*4 + 3) small_move("movsl; movsl; movsl; movsl; movsl; movsw; movsb");
+ /* 6 bytes */
+ if (count == 6*4 + 0) small_move("movsl; movsl; movsl; movsl; movsl; movsl");
+ /* the rest would be 7+ bytes and is handled below instead */
+#undef small_move
+
+ /* Not small, but multiple-of-4 move.
+ * "mov <const>,%ecx; rep; movsl" sequence is 7 bytes */
+ __asm__ __volatile__(
+ " rep; movsl\n"
+ : "=&c" (ecx), "=&S" (esi), "=&D" (edi)
+ : "0" (count / 4), "1" (s), "2" (d)
+ : "memory"
+ );
+ return edi;
+}
+static __always_inline
+void *inlined_memcpy_const_count4(void *d, const void *s, unsigned count)
+{
+ inlined_mempcpy_const_count4(d, s, count);
+ return d;
+}
+#if 1 /* +34 bytes on shared i386 build with gcc 4.3.0 */
+#define mempcpy(d, s, count) ( \
+ ( !(__builtin_constant_p(count)) \
+ || ((count) > (6*4 + 0) && ((count) % 4) != 0) \
+ ) \
+ ? mempcpy((d), (s), (count)) \
+ : inlined_mempcpy_const_count4((d), (s), (count)) \
+ )
+#define memcpy(d, s, count) ( \
+ ( !(__builtin_constant_p(count)) \
+ || ((count) > (6*4 + 0) && ((count) % 4) != 0) \
+ ) \
+ ? memcpy((d), (s), (count)) \
+ : inlined_memcpy_const_count4((d), (s), (count)) \
+ )
+#endif
+
+
+static __always_inline
+size_t inlined_strlen(const char *s)
+{
+ int edi;
+ int ecx;
+ __asm__ __volatile__(
+ " repne; scasb\n"
+ /* " notl %0\n" */
+ /* " decl %0\n" */
+ : "=c" (ecx), "=&D" (edi)
+ : "1" (s), "a" (0), "0" (0xffffffffu)
+ /* : no clobbers */
+ );
+ return -ecx - 1;
+}
+#if 0 /* +1108 bytes on shared i386 build with gcc 4.3.0 */
+#define strlen(s) inlined_strlen(s)
+#endif
+
+
+static __always_inline
+char *inlined_stpcpy(char *dest, const char *src)
+{
+ char *esi, *edi;
+ int eax;
+ __asm__ __volatile__(
+ "1: lodsb\n"
+ " stosb\n"
+ " testb %%al, %%al\n"
+ " jnz 1b\n"
+ : "=&S" (esi), "=&D" (edi), "=&a" (eax)
+ : "0" (src), "1" (dest)
+ : "memory"
+ );
+ return edi - 1;
+}
+static __always_inline
+char *inlined_strcpy(char *dest, const char *src)
+{
+ inlined_stpcpy(dest, src);
+ return dest;
+}
+#if 0 /* +562 bytes on shared i386 build with gcc 4.3.0 */
+#define stpcpy(dest, src) inlined_stpcpy(dest, src)
+#define strcpy(dest, src) inlined_strcpy(dest, src)
+#endif
+
+
+static __always_inline
+void *inlined_memchr(const void *s, int c, size_t count)
+{
+ void *edi;
+ int ecx;
+ /* Unfortunately, c gets loaded to %eax (wide insn), not %al */
+ __asm__ __volatile__(
+ " jecxz 1f\n"
+ " repne; scasb\n"
+ " leal -1(%%edi), %%edi\n"
+ " je 2f\n"
+ "1:\n"
+ " xorl %%edi, %%edi\n"
+ "2:\n"
+ : "=&D" (edi), "=&c" (ecx)
+ : "a" (c), "0" (s), "1" (count)
+ /* : no clobbers */
+ );
+ return edi;
+}
+static __always_inline
+void *inlined_memchr_const_c(const void *s, int c, size_t count)
+{
+#if defined __OPTIMIZE__
+ void *edi;
+ int ecx, eax;
+ __asm__ __volatile__(
+ " jecxz 1f\n"
+ " movb %4, %%al\n" /* const c to %%al */
+ " repne; scasb\n"
+ " leal -1(%%edi), %%edi\n"
+ " je 2f\n"
+ "1:\n"
+ " xorl %%edi, %%edi\n"
+ "2:\n"
+ : "=&D" (edi), "=&c" (ecx), "=&a" (eax)
+ : "0" (s), "i" (c), "1" (count)
+ /* : no clobbers */
+ );
+ return edi;
+#else
+ /* With -O0, gcc can't figure out how to encode CONST c
+ * as an immediate operand. Generating slightly bigger code
+ * (usually "movl CONST,%eax", 3 bytes bigger than needed):
+ */
+ void *edi;
+ int ecx, eax;
+ __asm__ __volatile__(
+ " jecxz 1f\n"
+ " repne; scasb\n"
+ " leal -1(%%edi), %%edi\n"
+ " je 2f\n"
+ "1:\n"
+ " xorl %%edi, %%edi\n"
+ "2:\n"
+ : "=&D" (edi), "=&c" (ecx), "=&a" (eax)
+ : "0" (s), "2" (c), "1" (count)
+ /* : no clobbers */
+ );
+ return edi;
+#endif
+}
+#if 1 /* +2 bytes on shared i386 build with gcc 4.3.0 */
+#define memchr(s, c, count) ( \
+ __builtin_constant_p(c) \
+ ? inlined_memchr_const_c(s, (c) & 0xff, count) \
+ : inlined_memchr(s, c, count) \
+ )
+#endif
+
+#endif /* _LIBC_STRING_i386_H */
diff --git a/libc/string/i386/strlen.c b/libc/string/i386/strlen.c
index 61a178393..ff2baeb38 100644
--- a/libc/string/i386/strlen.c
+++ b/libc/string/i386/strlen.c
@@ -32,17 +32,17 @@
#include <string.h>
-/* Experimentally off - libc_hidden_proto(strlen) */
+#undef strlen
size_t strlen(const char *s)
{
- int d0;
- register int __res;
- __asm__ __volatile__(
- "repne\n\t"
- "scasb\n\t"
- "notl %0\n\t"
- "decl %0"
- :"=c" (__res), "=&D" (d0) :"1" (s),"a" (0), "0" (0xffffffff));
- return __res;
+ int eax, ecx, edi;
+ __asm__ __volatile__(
+ " repne; scasb\n"
+ " notl %%ecx\n"
+ " leal -1(%%ecx), %%eax\n"
+ : "=&c" (ecx), "=&D" (edi), "=&a" (eax)
+ : "0" (0xffffffff), "1" (s), "2" (0)
+ );
+ return eax;
}
libc_hidden_def(strlen)
diff --git a/libc/string/i386/strncat.c b/libc/string/i386/strncat.c
index 3872679d5..12f0a302b 100644
--- a/libc/string/i386/strncat.c
+++ b/libc/string/i386/strncat.c
@@ -32,30 +32,55 @@
#include <string.h>
-/* Experimentally off - libc_hidden_proto(strncat) */
-char *strncat(char * dest,
- const char * src, size_t count)
+#undef strncat
+/*#define strncat TESTING*/
+char *strncat(char * dest, const char * src, size_t count)
{
- int d0, d1, d2, d3;
- __asm__ __volatile__(
- "repne\n\t"
- "scasb\n\t"
- "decl %1\n\t"
- "movl %8,%3\n"
- "incl %3\n"
- "1:\tdecl %3\n\t"
- "jz 2f\n"
- "lodsb\n\t"
- "stosb\n\t"
- "testb %%al,%%al\n\t"
- "jne 1b\n"
- "jmp 3f\n"
- "2:\txorl %2,%2\n\t"
- "stosb\n"
- "3:"
- : "=&S" (d0), "=&D" (d1), "=&a" (d2), "=&c" (d3)
- : "0" (src),"1" (dest),"2" (0),"3" (0xffffffff), "g" (count)
- : "memory");
- return dest;
+ int esi, edi, eax, ecx, edx;
+ __asm__ __volatile__(
+ " xorl %%eax, %%eax\n"
+ " incl %%edx\n"
+ " pushl %%edi\n" /* save dest */
+ " repne; scasb\n"
+ " decl %%edi\n" /* edi => NUL in dest */
+ /* count-- */
+ "1: decl %%edx\n"
+ /* if count reached 0, store NUL and bail out */
+ " movl %%edx, %%eax\n"
+ " jz 2f\n"
+ /* else copy a char */
+ " lodsb\n"
+ "2: stosb\n"
+ " testb %%al, %%al\n"
+ " jnz 1b\n"
+ /* end of loop */
+ " popl %%eax\n" /* restore dest into eax */
+ : "=&S" (esi), "=&D" (edi), "=&a" (eax), "=&c" (ecx), "=&d" (edx)
+ : "0" (src), "1" (dest), "3" (0xffffffff), "4" (count)
+ : "memory"
+ );
+ return (char *)eax;
}
+#ifndef strncat
libc_hidden_def(strncat)
+#else
+/* Uncomment TESTING, gcc -m32 -Os strncat.c -o strncat
+ * and run ./strncat
+ */
+int main()
+{
+ char buf[99];
+
+ strcpy(buf, "abc"); buf[4] = '*'; strncat(buf, "def", 0);
+ printf(strcmp(buf, "abc") == 0 && buf[4] == '*' ? "ok\n" : "BAD!\n");
+
+ strcpy(buf, "abc"); buf[6] = 1; buf[7] = '*'; strncat(buf, "def", 50);
+ printf(strcmp(buf, "abcdef") == 0 && buf[7] == '*' ? "ok\n" : "BAD!\n");
+
+ strcpy(buf, "abc"); buf[6] = 1; buf[7] = '*'; strncat(buf, "def", -1);
+ printf(strcmp(buf, "abcdef") == 0 && buf[7] == '*' ? "ok\n" : "BAD!\n");
+
+ strcpy(buf, "abc"); buf[6] = 1; buf[7] = '*'; strncat(buf, "def123", 3);
+ printf(strcmp(buf, "abcdef") == 0 && buf[7] == '*' ? "ok\n" : "BAD!\n");
+}
+#endif
diff --git a/libc/string/i386/strncmp.c b/libc/string/i386/strncmp.c
index a14bb503b..bfb20c307 100644
--- a/libc/string/i386/strncmp.c
+++ b/libc/string/i386/strncmp.c
@@ -32,27 +32,28 @@
#include <string.h>
-/* Experimentally off - libc_hidden_proto(strncmp) */
+#undef strncmp
int strncmp(const char *cs, const char *ct, size_t count)
{
- register int __res;
- int d0, d1, d2;
- __asm__ __volatile__(
- "incl %3\n"
- "1:\tdecl %3\n\t"
- "jz 2f\n"
- "lodsb\n\t"
- "scasb\n\t"
- "jne 3f\n\t"
- "testb %%al,%%al\n\t"
- "jne 1b\n"
- "2:\txorl %%eax,%%eax\n\t"
- "jmp 4f\n"
- "3:\tsbbl %%eax,%%eax\n\t"
- "orb $1,%%al\n"
- "4:"
- :"=a" (__res), "=&S" (d0), "=&D" (d1), "=&c" (d2)
- :"1" (cs),"2" (ct),"3" (count));
- return __res;
+ int eax;
+ int esi, edi, ecx;
+ __asm__ __volatile__(
+ " incl %%ecx\n"
+ "1: decl %%ecx\n"
+ " jz 2f\n"
+ " lodsb\n"
+ " scasb\n"
+ " jne 3f\n"
+ " testb %%al, %%al\n"
+ " jnz 1b\n"
+ "2: xorl %%eax, %%eax\n"
+ " jmp 4f\n"
+ "3: sbbl %%eax, %%eax\n"
+ " orb $1, %%al\n"
+ "4:\n"
+ : "=a" (eax), "=&S" (esi), "=&D" (edi), "=&c" (ecx)
+ : "1" (cs), "2" (ct), "3" (count)
+ );
+ return eax;
}
libc_hidden_weak(strncmp)
diff --git a/libc/string/i386/strncpy.c b/libc/string/i386/strncpy.c
index 76aa6ae1b..99d104b0d 100644
--- a/libc/string/i386/strncpy.c
+++ b/libc/string/i386/strncpy.c
@@ -32,25 +32,44 @@
#include <string.h>
-/* Experimentally off - libc_hidden_proto(strncpy) */
+#undef strncpy
+/*#define strncpy TESTING*/
char *strncpy(char * dest, const char * src, size_t count)
{
- int d0, d1, d2, d3;
- __asm__ __volatile__(
- "incl %2\n"
- "1:\n"
- "decl %2\n"
- "jz 2f\n"
- "lodsb\n\t"
- "stosb\n\t"
- "testb %%al,%%al\n\t"
- "jne 1b\n\t"
- "decl %2\n"
- "rep\n\t"
- "stosb\n"
- "2:"
- : "=&S" (d0), "=&D" (d1), "=&c" (d2), "=&a" (d3)
- :"0" (src),"1" (dest),"2" (count) : "memory");
- return dest;
+ int esi, edi, ecx, eax;
+ __asm__ __volatile__(
+ "1: subl $1, %%ecx\n" /* not dec! it doesnt set CF */
+ " jc 2f\n"
+ " lodsb\n"
+ " stosb\n"
+ " testb %%al, %%al\n"
+ " jnz 1b\n"
+ " rep; stosb\n"
+ "2:\n"
+ : "=&S" (esi), "=&D" (edi), "=&c" (ecx), "=&a" (eax)
+ : "0" (src), "1" (dest), "2" (count)
+ : "memory"
+ );
+ return dest;
}
+#ifndef strncpy
libc_hidden_def(strncpy)
+#else
+/* Uncomment TESTING, gcc -D_GNU_SOURCE -m32 -Os strncpy.c -o strncpy
+ * and run ./strncpy
+ */
+int main()
+{
+ static char str[99];
+
+ str[3] = '*'; str[4] = 0; strncpy(str, "abc", 3);
+ printf(strcmp(str, "abc*") == 0 ? "ok\n" : "BAD!\n");
+
+ str[4] = '*'; str[5] = '+'; strncpy(str, "abc", 5);
+ printf(strcmp(str, "abc") == 0 && str[4] == 0 && str[5] == '+' ?
+ "ok\n" : "BAD!\n");
+ strncpy(str, "def", 0); /* should do nothing */
+ printf(strcmp(str, "abc") == 0 && str[4] == 0 && str[5] == '+' ?
+ "ok\n" : "BAD!\n");
+}
+#endif
diff --git a/libc/string/i386/strnlen.c b/libc/string/i386/strnlen.c
index 02c72f530..f58f698d1 100644
--- a/libc/string/i386/strnlen.c
+++ b/libc/string/i386/strnlen.c
@@ -33,24 +33,43 @@
#include <string.h>
#ifdef __USE_GNU
-/* Experimentally off - libc_hidden_proto(strnlen) */
+
+#undef strnlen
+/*#define strnlen TESTING*/
size_t strnlen(const char *s, size_t count)
{
- int d0;
- register int __res;
- __asm__ __volatile__(
- "movl %2,%0\n\t"
- "incl %1\n"
- "jmp 2f\n"
- "1:\tcmpb $0,(%0)\n\t"
- "je 3f\n\t"
- "incl %0\n"
- "2:\tdecl %1\n\t"
- "jne 1b\n"
- "3:\tsubl %2,%0"
- :"=a" (__res), "=&d" (d0)
- :"c" (s),"1" (count));
- return __res;
+ int edx;
+ int eax;
+ __asm__ __volatile__(
+ " leal -1(%%ecx), %%eax\n"
+ "1: incl %%eax\n"
+ " decl %%edx\n"
+ " jz 3f\n"
+ " cmpb $0, (%%eax)\n"
+ " jnz 1b\n"
+ "3: subl %%ecx, %%eax"
+ : "=a" (eax), "=&d" (edx)
+ : "c" (s), "1" (count + 1)
+ );
+ return eax;
}
+#ifndef strnlen
libc_hidden_def(strnlen)
+#else
+/* Uncomment TESTING, gcc -D_GNU_SOURCE -m32 -Os strnlen.c -o strnlen
+ * and run ./strnlen
+ */
+int main()
+{
+ printf(strnlen("abc\0def", -2) == 3 ? "ok\n" : "BAD!\n");
+ printf(strnlen("abc\0def", -1) == 3 ? "ok\n" : "BAD!\n");
+ printf(strnlen("abc\0def", 0) == 0 ? "ok\n" : "BAD!\n");
+ printf(strnlen("abc\0def", 1) == 1 ? "ok\n" : "BAD!\n");
+ printf(strnlen("abc\0def", 2) == 2 ? "ok\n" : "BAD!\n");
+ printf(strnlen("abc\0def", 3) == 3 ? "ok\n" : "BAD!\n");
+ printf(strnlen("abc\0def", 4) == 3 ? "ok\n" : "BAD!\n");
+ printf(strnlen("abc\0def", 5) == 3 ? "ok\n" : "BAD!\n");
+}
+#endif
+
#endif
diff --git a/libc/string/i386/strrchr.c b/libc/string/i386/strrchr.c
index ef378685b..5c349f683 100644
--- a/libc/string/i386/strrchr.c
+++ b/libc/string/i386/strrchr.c
@@ -32,21 +32,25 @@
#include <string.h>
-/* Experimentally off - libc_hidden_proto(strrchr) */
char *strrchr(const char *s, int c)
{
- int d0, d1;
- register char * __res;
- __asm__ __volatile__(
- "movb %%al,%%ah\n"
- "1:\tlodsb\n\t"
- "cmpb %%ah,%%al\n\t"
- "jne 2f\n\t"
- "leal -1(%%esi),%0\n"
- "2:\ttestb %%al,%%al\n\t"
- "jne 1b"
- :"=g" (__res), "=&S" (d0), "=&a" (d1) :"0" (0),"1" (s),"2" (c));
- return __res;
+ char *eax;
+
+ __asm__ __volatile__(
+ " movb %%cl, %%ch\n"
+ "1: movb (%1), %%cl\n" /* load char */
+ " cmpb %%cl, %%ch\n" /* char == c? */
+ " jne 2f\n"
+ " movl %1, %%eax\n"
+ "2: incl %1\n"
+ " testb %%cl, %%cl\n" /* char == NUL? */
+ " jnz 1b\n"
+ /* "=c": use ecx, not ebx (-fpic uses it). */
+ : "=a" (eax), "=r" (s), "=c" (c)
+ : "0" (0), "1" (s), "2" (c)
+ /* : no clobbers */
+ );
+ return eax;
}
libc_hidden_def(strrchr)
#ifdef __UCLIBC_SUSV3_LEGACY__
diff --git a/libc/string/ia64/bcopy.S b/libc/string/ia64/bcopy.S
index c5637c369..62da68d74 100644
--- a/libc/string/ia64/bcopy.S
+++ b/libc/string/ia64/bcopy.S
@@ -1,4 +1,4 @@
-#include "sysdep.h"
+#include <sysdep.h>
#ifdef __UCLIBC_SUSV3_LEGACY__
diff --git a/libc/string/ia64/bzero.S b/libc/string/ia64/bzero.S
index d390838a6..79419579a 100644
--- a/libc/string/ia64/bzero.S
+++ b/libc/string/ia64/bzero.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/>. */
/* Return: dest
@@ -32,7 +31,7 @@
Since a stf.spill f0 can store 16B in one go, we use this instruction
to get peak speed. */
-#include "sysdep.h"
+#include <sysdep.h>
#ifdef __UCLIBC_SUSV3_LEGACY__
@@ -47,13 +46,13 @@
#define ptr1 r28
#define ptr2 r27
#define ptr3 r26
-#define ptr9 r24
+#define ptr9 r24
#define loopcnt r23
#define linecnt r22
#define bytecnt r21
-// This routine uses only scratch predicate registers (p6 - p15)
-#define p_scr p6 // default register for same-cycle branches
+/* This routine uses only scratch predicate registers (p6 - p15) */
+#define p_scr p6 /* default register for same-cycle branches */
#define p_unalgn p9
#define p_y p11
#define p_n p12
@@ -65,7 +64,7 @@
#define MIN1 15
#define MIN1P1HALF 8
#define LINE_SIZE 128
-#define LSIZE_SH 7 // shift amount
+#define LSIZE_SH 7 /* shift amount */
#define PREF_AHEAD 8
#define USE_FLP
@@ -87,49 +86,49 @@ ENTRY(bzero)
movi0 save_lc = ar.lc
} { .mmi
.body
- mov ret0 = dest // return value
+ mov ret0 = dest /* return value */
nop.m 0
cmp.eq p_scr, p0 = cnt, r0
;; }
{ .mmi
- and ptr2 = -(MIN1+1), dest // aligned address
- and tmp = MIN1, dest // prepare to check for alignment
- tbit.nz p_y, p_n = dest, 0 // Do we have an odd address? (M_B_U)
+ and ptr2 = -(MIN1+1), dest /* aligned address */
+ and tmp = MIN1, dest /* prepare to check for alignment */
+ tbit.nz p_y, p_n = dest, 0 /* Do we have an odd address? (M_B_U) */
} { .mib
mov ptr1 = dest
nop.i 0
-(p_scr) br.ret.dpnt.many rp // return immediately if count = 0
+(p_scr) br.ret.dpnt.many rp /* return immediately if count = 0 */
;; }
{ .mib
cmp.ne p_unalgn, p0 = tmp, r0
-} { .mib // NB: # of bytes to move is 1
- sub bytecnt = (MIN1+1), tmp // higher than loopcnt
- cmp.gt p_scr, p0 = 16, cnt // is it a minimalistic task?
-(p_scr) br.cond.dptk.many .move_bytes_unaligned // go move just a few (M_B_U)
+} { .mib /* NB: # of bytes to move is 1 */
+ sub bytecnt = (MIN1+1), tmp /* higher than loopcnt */
+ cmp.gt p_scr, p0 = 16, cnt /* is it a minimalistic task? */
+(p_scr) br.cond.dptk.many .move_bytes_unaligned /* go move just a few (M_B_U) */
;; }
{ .mmi
-(p_unalgn) add ptr1 = (MIN1+1), ptr2 // after alignment
-(p_unalgn) add ptr2 = MIN1P1HALF, ptr2 // after alignment
-(p_unalgn) tbit.nz.unc p_y, p_n = bytecnt, 3 // should we do a st8 ?
+(p_unalgn) add ptr1 = (MIN1+1), ptr2 /* after alignment */
+(p_unalgn) add ptr2 = MIN1P1HALF, ptr2 /* after alignment */
+(p_unalgn) tbit.nz.unc p_y, p_n = bytecnt, 3 /* should we do a st8 ? */
;; }
{ .mib
(p_y) add cnt = -8, cnt
-(p_unalgn) tbit.nz.unc p_yy, p_nn = bytecnt, 2 // should we do a st4 ?
+(p_unalgn) tbit.nz.unc p_yy, p_nn = bytecnt, 2 /* should we do a st4 ? */
} { .mib
(p_y) st8 [ptr2] = r0,-4
(p_n) add ptr2 = 4, ptr2
;; }
{ .mib
(p_yy) add cnt = -4, cnt
-(p_unalgn) tbit.nz.unc p_y, p_n = bytecnt, 1 // should we do a st2 ?
+(p_unalgn) tbit.nz.unc p_y, p_n = bytecnt, 1 /* should we do a st2 ? */
} { .mib
(p_yy) st4 [ptr2] = r0,-2
(p_nn) add ptr2 = 2, ptr2
;; }
{ .mmi
- mov tmp = LINE_SIZE+1 // for compare
+ mov tmp = LINE_SIZE+1 /* for compare */
(p_y) add cnt = -2, cnt
-(p_unalgn) tbit.nz.unc p_yy, p_nn = bytecnt, 0 // should we do a st1 ?
+(p_unalgn) tbit.nz.unc p_yy, p_nn = bytecnt, 0 /* should we do a st1 ? */
} { .mmi
nop.m 0
(p_y) st2 [ptr2] = r0,-1
@@ -138,44 +137,44 @@ ENTRY(bzero)
{ .mmi
(p_yy) st1 [ptr2] = r0
- cmp.gt p_scr, p0 = tmp, cnt // is it a minimalistic task?
+ cmp.gt p_scr, p0 = tmp, cnt /* is it a minimalistic task? */
} { .mbb
(p_yy) add cnt = -1, cnt
-(p_scr) br.cond.dpnt.many .fraction_of_line // go move just a few
+(p_scr) br.cond.dpnt.many .fraction_of_line /* go move just a few */
;; }
{ .mib
- nop.m 0
+ nop.m 0
shr.u linecnt = cnt, LSIZE_SH
nop.b 0
;; }
.align 32
-.l1b: // ------------------// L1B: store ahead into cache lines; fill later
+.l1b: /* ------------------ L1B: store ahead into cache lines; fill later */
{ .mmi
- and tmp = -(LINE_SIZE), cnt // compute end of range
- mov ptr9 = ptr1 // used for prefetching
- and cnt = (LINE_SIZE-1), cnt // remainder
+ and tmp = -(LINE_SIZE), cnt /* compute end of range */
+ mov ptr9 = ptr1 /* used for prefetching */
+ and cnt = (LINE_SIZE-1), cnt /* remainder */
} { .mmi
- mov loopcnt = PREF_AHEAD-1 // default prefetch loop
- cmp.gt p_scr, p0 = PREF_AHEAD, linecnt // check against actual value
+ mov loopcnt = PREF_AHEAD-1 /* default prefetch loop */
+ cmp.gt p_scr, p0 = PREF_AHEAD, linecnt /* check against actual value */
;; }
{ .mmi
(p_scr) add loopcnt = -1, linecnt
- add ptr2 = 16, ptr1 // start of stores (beyond prefetch stores)
- add ptr1 = tmp, ptr1 // first address beyond total range
+ add ptr2 = 16, ptr1 /* start of stores (beyond prefetch stores) */
+ add ptr1 = tmp, ptr1 /* first address beyond total range */
;; }
{ .mmi
- add tmp = -1, linecnt // next loop count
+ add tmp = -1, linecnt /* next loop count */
movi0 ar.lc = loopcnt
;; }
.pref_l1b:
{ .mib
- stf.spill [ptr9] = f0, 128 // Do stores one cache line apart
+ stf.spill [ptr9] = f0, 128 /* Do stores one cache line apart */
nop.i 0
br.cloop.dptk.few .pref_l1b
;; }
{ .mmi
- add ptr0 = 16, ptr2 // Two stores in parallel
+ add ptr0 = 16, ptr2 /* Two stores in parallel */
movi0 ar.lc = tmp
;; }
.l1bx:
@@ -190,7 +189,7 @@ ENTRY(bzero)
{ .mmi
stf.spill [ptr2] = f0, 32
stf.spill [ptr0] = f0, 64
- cmp.lt p_scr, p0 = ptr9, ptr1 // do we need more prefetching?
+ cmp.lt p_scr, p0 = ptr9, ptr1 /* do we need more prefetching? */
;; }
{ .mmb
stf.spill [ptr2] = f0, 32
@@ -198,14 +197,14 @@ ENTRY(bzero)
br.cloop.dptk.few .l1bx
;; }
{ .mib
- cmp.gt p_scr, p0 = 8, cnt // just a few bytes left ?
+ cmp.gt p_scr, p0 = 8, cnt /* just a few bytes left ? */
(p_scr) br.cond.dpnt.many .move_bytes_from_alignment
;; }
.fraction_of_line:
{ .mib
add ptr2 = 16, ptr1
- shr.u loopcnt = cnt, 5 // loopcnt = cnt / 32
+ shr.u loopcnt = cnt, 5 /* loopcnt = cnt / 32 */
;; }
{ .mib
cmp.eq p_scr, p0 = loopcnt, r0
@@ -213,11 +212,11 @@ ENTRY(bzero)
(p_scr) br.cond.dpnt.many .store_words
;; }
{ .mib
- and cnt = 0x1f, cnt // compute the remaining cnt
+ and cnt = 0x1f, cnt /* compute the remaining cnt */
movi0 ar.lc = loopcnt
;; }
.align 32
-.l2: // -----------------------------// L2A: store 32B in 2 cycles
+.l2: /* ----------------------------- L2A: store 32B in 2 cycles */
{ .mmb
store [ptr1] = myval, 8
store [ptr2] = myval, 8
@@ -228,38 +227,38 @@ ENTRY(bzero)
;; }
.store_words:
{ .mib
- cmp.gt p_scr, p0 = 8, cnt // just a few bytes left ?
-(p_scr) br.cond.dpnt.many .move_bytes_from_alignment // Branch
+ cmp.gt p_scr, p0 = 8, cnt /* just a few bytes left ? */
+(p_scr) br.cond.dpnt.many .move_bytes_from_alignment /* Branch */
;; }
{ .mmi
- store [ptr1] = myval, 8 // store
- cmp.le p_y, p_n = 16, cnt //
- add cnt = -8, cnt // subtract
+ store [ptr1] = myval, 8 /* store */
+ cmp.le p_y, p_n = 16, cnt /* */
+ add cnt = -8, cnt /* subtract */
;; }
{ .mmi
-(p_y) store [ptr1] = myval, 8 // store
+(p_y) store [ptr1] = myval, 8 /* store */
(p_y) cmp.le.unc p_yy, p_nn = 16, cnt
-(p_y) add cnt = -8, cnt // subtract
+(p_y) add cnt = -8, cnt /* subtract */
;; }
-{ .mmi // store
+{ .mmi /* store */
(p_yy) store [ptr1] = myval, 8
-(p_yy) add cnt = -8, cnt // subtract
+(p_yy) add cnt = -8, cnt /* subtract */
;; }
.move_bytes_from_alignment:
{ .mib
cmp.eq p_scr, p0 = cnt, r0
- tbit.nz.unc p_y, p0 = cnt, 2 // should we terminate with a st4 ?
+ tbit.nz.unc p_y, p0 = cnt, 2 /* should we terminate with a st4 ? */
(p_scr) br.cond.dpnt.few .restore_and_exit
;; }
{ .mib
(p_y) st4 [ptr1] = r0,4
- tbit.nz.unc p_yy, p0 = cnt, 1 // should we terminate with a st2 ?
+ tbit.nz.unc p_yy, p0 = cnt, 1 /* should we terminate with a st2 ? */
;; }
{ .mib
(p_yy) st2 [ptr1] = r0,2
- tbit.nz.unc p_y, p0 = cnt, 0 // should we terminate with a st1 ?
+ tbit.nz.unc p_y, p0 = cnt, 0 /* should we terminate with a st1 ? */
;; }
{ .mib
@@ -281,38 +280,38 @@ ENTRY(bzero)
(p_n) add ptr2 = 2, ptr1
} { .mmi
(p_y) add ptr2 = 3, ptr1
-(p_y) st1 [ptr1] = r0, 1 // fill 1 (odd-aligned) byte
-(p_y) add cnt = -1, cnt // [15, 14 (or less) left]
+(p_y) st1 [ptr1] = r0, 1 /* fill 1 (odd-aligned) byte */
+(p_y) add cnt = -1, cnt /* [15, 14 (or less) left] */
;; }
{ .mmi
(p_yy) cmp.le.unc p_y, p0 = 8, cnt
- add ptr3 = ptr1, cnt // prepare last store
+ add ptr3 = ptr1, cnt /* prepare last store */
movi0 ar.lc = save_lc
} { .mmi
-(p_yy) st2 [ptr1] = r0, 4 // fill 2 (aligned) bytes
-(p_yy) st2 [ptr2] = r0, 4 // fill 2 (aligned) bytes
-(p_yy) add cnt = -4, cnt // [11, 10 (o less) left]
+(p_yy) st2 [ptr1] = r0, 4 /* fill 2 (aligned) bytes */
+(p_yy) st2 [ptr2] = r0, 4 /* fill 2 (aligned) bytes */
+(p_yy) add cnt = -4, cnt /* [11, 10 (o less) left] */
;; }
{ .mmi
(p_y) cmp.le.unc p_yy, p0 = 8, cnt
- add ptr3 = -1, ptr3 // last store
- tbit.nz p_scr, p0 = cnt, 1 // will there be a st2 at the end ?
+ add ptr3 = -1, ptr3 /* last store */
+ tbit.nz p_scr, p0 = cnt, 1 /* will there be a st2 at the end ? */
} { .mmi
-(p_y) st2 [ptr1] = r0, 4 // fill 2 (aligned) bytes
-(p_y) st2 [ptr2] = r0, 4 // fill 2 (aligned) bytes
-(p_y) add cnt = -4, cnt // [7, 6 (or less) left]
+(p_y) st2 [ptr1] = r0, 4 /* fill 2 (aligned) bytes */
+(p_y) st2 [ptr2] = r0, 4 /* fill 2 (aligned) bytes */
+(p_y) add cnt = -4, cnt /* [7, 6 (or less) left] */
;; }
{ .mmi
-(p_yy) st2 [ptr1] = r0, 4 // fill 2 (aligned) bytes
-(p_yy) st2 [ptr2] = r0, 4 // fill 2 (aligned) bytes
- // [3, 2 (or less) left]
- tbit.nz p_y, p0 = cnt, 0 // will there be a st1 at the end ?
+(p_yy) st2 [ptr1] = r0, 4 /* fill 2 (aligned) bytes */
+(p_yy) st2 [ptr2] = r0, 4 /* fill 2 (aligned) bytes */
+ /* [3, 2 (or less) left] */
+ tbit.nz p_y, p0 = cnt, 0 /* will there be a st1 at the end ? */
} { .mmi
(p_yy) add cnt = -4, cnt
;; }
{ .mmb
-(p_scr) st2 [ptr1] = r0 // fill 2 (aligned) bytes
-(p_y) st1 [ptr3] = r0 // fill last byte (using ptr3)
+(p_scr) st2 [ptr1] = r0 /* fill 2 (aligned) bytes */
+(p_y) st1 [ptr3] = r0 /* fill last byte (using ptr3) */
br.ret.sptk.many rp
;; }
END(bzero)
diff --git a/libc/string/ia64/memccpy.S b/libc/string/ia64/memccpy.S
index 1afba3637..5c4d7e3c2 100644
--- a/libc/string/ia64/memccpy.S
+++ b/libc/string/ia64/memccpy.S
@@ -14,16 +14,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/>. */
/* Return: a pointer to the next byte after char in dest or NULL
Inputs:
in0: dest
in1: src
- in2: char
+ in2: char
in3: byte count
This implementation assumes little endian mode (UM.be = 0).
@@ -31,7 +30,7 @@
This implementation assumes that it is safe to do read ahead
in the src block, without getting beyond its limit. */
-#include "sysdep.h"
+#include <sysdep.h>
#undef ret
#define OP_T_THRES 16
@@ -69,75 +68,75 @@ ENTRY(memccpy)
.rotr r[MEMLAT + 7], tmp1[4], tmp2[4], val[4], tmp3[2], pos0[2]
.rotp p[MEMLAT + 6 + 1]
- mov ret0 = r0 // return NULL if no match
+ mov ret0 = r0 /* return NULL if no match */
.save pr, saved_pr
- mov saved_pr = pr // save the predicate registers
- mov dest = in0 // dest
+ mov saved_pr = pr /* save the predicate registers */
+ mov dest = in0 /* dest */
.save ar.lc, saved_lc
- mov saved_lc = ar.lc // save the loop counter
- mov saved_ec = ar.ec // save the loop counter
+ mov saved_lc = ar.lc /* save the loop counter */
+ mov saved_ec = ar.ec /* save the loop counter */
.body
- mov src = in1 // src
- extr.u char = in2, 0, 8 // char
- mov len = in3 // len
- sub tmp = r0, in0 // tmp = -dest
- cmp.ne p7, p0 = r0, r0 // clear p7
+ mov src = in1 /* src */
+ extr.u char = in2, 0, 8 /* char */
+ mov len = in3 /* len */
+ sub tmp = r0, in0 /* tmp = -dest */
+ cmp.ne p7, p0 = r0, r0 /* clear p7 */
;;
- and loopcnt = 7, tmp // loopcnt = -dest % 8
- cmp.ge p6, p0 = OP_T_THRES, len // is len <= OP_T_THRES
- mov ar.ec = 0 // ec not guaranteed zero on entry
-(p6) br.cond.spnt .cpyfew // copy byte by byte
+ and loopcnt = 7, tmp /* loopcnt = -dest % 8 */
+ cmp.ge p6, p0 = OP_T_THRES, len /* is len <= OP_T_THRES */
+ mov ar.ec = 0 /* ec not guaranteed zero on entry */
+(p6) br.cond.spnt .cpyfew /* copy byte by byte */
;;
cmp.eq p6, p0 = loopcnt, r0
mux1 charx8 = char, @brcst
(p6) br.cond.sptk .dest_aligned
- sub len = len, loopcnt // len -= -dest % 8
- adds loopcnt = -1, loopcnt // --loopcnt
+ sub len = len, loopcnt /* len -= -dest % 8 */
+ adds loopcnt = -1, loopcnt /* --loopcnt */
;;
mov ar.lc = loopcnt
-.l1: // copy -dest % 8 bytes
- ld1 value = [src], 1 // value = *src++
+.l1: /* copy -dest % 8 bytes */
+ ld1 value = [src], 1 /* value = *src++ */
;;
- st1 [dest] = value, 1 // *dest++ = value
+ st1 [dest] = value, 1 /* *dest++ = value */
cmp.eq p6, p0 = value, char
(p6) br.cond.spnt .foundit
br.cloop.dptk .l1
.dest_aligned:
- and sh1 = 7, src // sh1 = src % 8
- and tmp = -8, len // tmp = len & -OPSIZ
- and asrc = -8, src // asrc = src & -OPSIZ -- align src
- shr.u loopcnt = len, 3 // loopcnt = len / 8
- and len = 7, len ;; // len = len % 8
- shl sh1 = sh1, 3 // sh1 = 8 * (src % 8)
- adds loopcnt = -1, loopcnt // --loopcnt
- mov pr.rot = 1 << 16 ;; // set rotating predicates
- sub sh2 = 64, sh1 // sh2 = 64 - sh1
- mov ar.lc = loopcnt // set LC
- cmp.eq p6, p0 = sh1, r0 // is the src aligned?
+ and sh1 = 7, src /* sh1 = src % 8 */
+ and tmp = -8, len /* tmp = len & -OPSIZ */
+ and asrc = -8, src /* asrc = src & -OPSIZ -- align src */
+ shr.u loopcnt = len, 3 /* loopcnt = len / 8 */
+ and len = 7, len ;; /* len = len % 8 */
+ shl sh1 = sh1, 3 /* sh1 = 8 * (src % 8) */
+ adds loopcnt = -1, loopcnt /* --loopcnt */
+ mov pr.rot = 1 << 16 ;; /* set rotating predicates */
+ sub sh2 = 64, sh1 /* sh2 = 64 - sh1 */
+ mov ar.lc = loopcnt /* set LC */
+ cmp.eq p6, p0 = sh1, r0 /* is the src aligned? */
(p6) br.cond.sptk .src_aligned ;;
- add src = src, tmp // src += len & -OPSIZ
- mov ar.ec = MEMLAT + 6 + 1 // six more passes needed
- ld8 r[1] = [asrc], 8 // r[1] = w0
- cmp.ne p6, p0 = r0, r0 ;; // clear p6
+ add src = src, tmp /* src += len & -OPSIZ */
+ mov ar.ec = MEMLAT + 6 + 1 /* six more passes needed */
+ ld8 r[1] = [asrc], 8 /* r[1] = w0 */
+ cmp.ne p6, p0 = r0, r0 ;; /* clear p6 */
ALIGN(32)
.l2:
-(p[0]) ld8.s r[0] = [asrc], 8 // r[0] = w1
-(p[MEMLAT]) shr.u tmp1[0] = r[1 + MEMLAT], sh1 // tmp1 = w0 >> sh1
-(p[MEMLAT]) shl tmp2[0] = r[0 + MEMLAT], sh2 // tmp2 = w1 << sh2
+(p[0]) ld8.s r[0] = [asrc], 8 /* r[0] = w1 */
+(p[MEMLAT]) shr.u tmp1[0] = r[1 + MEMLAT], sh1 /* tmp1 = w0 >> sh1 */
+(p[MEMLAT]) shl tmp2[0] = r[0 + MEMLAT], sh2 /* tmp2 = w1 << sh2 */
(p[MEMLAT+4]) xor tmp3[0] = val[1], charx8
(p[MEMLAT+5]) czx1.r pos0[0] = tmp3[1]
-(p[MEMLAT+6]) chk.s r[6 + MEMLAT], .recovery1 // our data isn't
- // valid - rollback!
+(p[MEMLAT+6]) chk.s r[6 + MEMLAT], .recovery1 /* our data isn't */
+ /* valid - rollback! */
(p[MEMLAT+6]) cmp.ne p6, p0 = 8, pos0[1]
(p6) br.cond.spnt .gotit
-(p[MEMLAT+6]) st8 [dest] = val[3], 8 // store val to dest
-(p[MEMLAT+3]) or val[0] = tmp1[3], tmp2[3] // val = tmp1 | tmp2
+(p[MEMLAT+6]) st8 [dest] = val[3], 8 /* store val to dest */
+(p[MEMLAT+3]) or val[0] = tmp1[3], tmp2[3] /* val = tmp1 | tmp2 */
br.ctop.sptk .l2
br.cond.sptk .cpyfew
.src_aligned:
- cmp.ne p6, p0 = r0, r0 // clear p6
- mov ar.ec = MEMLAT + 2 + 1 ;; // set EC
+ cmp.ne p6, p0 = r0, r0 /* clear p6 */
+ mov ar.ec = MEMLAT + 2 + 1 ;; /* set EC */
.l3:
(p[0]) ld8.s r[0] = [src], 8
(p[MEMLAT]) xor tmp3[0] = r[MEMLAT], charx8
@@ -149,8 +148,8 @@ ENTRY(memccpy)
(p[MEMLAT+2]) st8 [dest] = r[MEMLAT+2], 8
br.ctop.dptk .l3
.cpyfew:
- cmp.eq p6, p0 = len, r0 // is len == 0 ?
- adds len = -1, len // --len;
+ cmp.eq p6, p0 = len, r0 /* is len == 0 ? */
+ adds len = -1, len /* --len; */
(p6) br.cond.spnt .restore_and_exit ;;
mov ar.lc = len
.l4:
@@ -163,14 +162,14 @@ ENTRY(memccpy)
.foundit:
(p6) mov ret0 = dest
.restore_and_exit:
- mov pr = saved_pr, -1 // restore the predicate registers
- mov ar.lc = saved_lc // restore the loop counter
- mov ar.ec = saved_ec ;; // restore the epilog counter
+ mov pr = saved_pr, -1 /* restore the predicate registers */
+ mov ar.lc = saved_lc /* restore the loop counter */
+ mov ar.ec = saved_ec ;; /* restore the epilog counter */
br.ret.sptk.many b0
.gotit:
.pred.rel "mutex" p6, p7
-(p6) mov value = val[3] // if coming from l2
-(p7) mov value = r[MEMLAT+2] // if coming from l3
+(p6) mov value = val[3] /* if coming from l2 */
+(p7) mov value = r[MEMLAT+2] /* if coming from l3 */
mov ar.lc = pos0[1] ;;
.l5:
extr.u tmp = value, 0, 8 ;;
diff --git a/libc/string/ia64/memchr.S b/libc/string/ia64/memchr.S
index 2bf078fe6..fcd9f9305 100644
--- a/libc/string/ia64/memchr.S
+++ b/libc/string/ia64/memchr.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/>. */
/* Return: the address of the first occurence of chr in str or NULL
@@ -40,7 +39,7 @@
All the loops in this function could have had the internal branch removed
if br.ctop and br.cloop could be predicated :-(. */
-#include "sysdep.h"
+#include <sysdep.h>
#undef ret
#define saved_pr r15
@@ -62,18 +61,18 @@ ENTRY(__memchr)
.rotr value[MEMLAT+1], addr[MEMLAT+3], aux[2], poschr[2]
.rotp p[MEMLAT+3]
.save ar.lc, saved_lc
- mov saved_lc = ar.lc // save the loop counter
+ mov saved_lc = ar.lc /* save the loop counter */
.save pr, saved_pr
- mov saved_pr = pr // save the predicates
+ mov saved_pr = pr /* save the predicates */
.body
mov ret0 = str
- and tmp = 7, str // tmp = str % 8
- cmp.ne p7, p0 = r0, r0 // clear p7
- extr.u chr = in1, 0, 8 // chr = (unsigned char) in1
+ and tmp = 7, str /* tmp = str % 8 */
+ cmp.ne p7, p0 = r0, r0 /* clear p7 */
+ extr.u chr = in1, 0, 8 /* chr = (unsigned char) in1 */
mov len = in2
- cmp.gtu p6, p0 = 16, in2 // use a simple loop for short
-(p6) br.cond.spnt .srchfew ;; // searches
- sub loopcnt = 8, tmp // loopcnt = 8 - tmp
+ cmp.gtu p6, p0 = 16, in2 /* use a simple loop for short */
+(p6) br.cond.spnt .srchfew ;; /* searches */
+ sub loopcnt = 8, tmp /* loopcnt = 8 - tmp */
cmp.eq p6, p0 = tmp, r0
(p6) br.cond.sptk .str_aligned;;
sub len = len, loopcnt
@@ -86,12 +85,12 @@ ENTRY(__memchr)
(p6) br.cond.spnt .foundit
br.cloop.sptk .l1 ;;
.str_aligned:
- cmp.ne p6, p0 = r0, r0 // clear p6
- shr.u loopcnt = len, 3 // loopcnt = len / 8
- and len = 7, len ;; // remaining len = len & 7
+ cmp.ne p6, p0 = r0, r0 /* clear p6 */
+ shr.u loopcnt = len, 3 /* loopcnt = len / 8 */
+ and len = 7, len ;; /* remaining len = len & 7 */
adds loopcnt = -1, loopcnt
mov ar.ec = MEMLAT + 3
- mux1 chrx8 = chr, @brcst ;; // get a word full of chr
+ mux1 chrx8 = chr, @brcst ;; /* get a word full of chr */
mov ar.lc = loopcnt
mov pr.rot = 1 << 16 ;;
.l2:
@@ -114,20 +113,18 @@ ENTRY(__memchr)
(p6) br.cond.dpnt .foundit
br.cloop.sptk .l3 ;;
.notfound:
- cmp.ne p6, p0 = r0, r0 // clear p6 (p7 was already 0 when we got here)
- mov ret0 = r0 ;; // return NULL
+ cmp.ne p6, p0 = r0, r0 /* clear p6 (p7 was already 0 when we got here) */
+ mov ret0 = r0 ;; /* return NULL */
.foundit:
.pred.rel "mutex" p6, p7
-(p6) adds ret0 = -1, ret0 // if we got here from l1 or l3
-(p7) add ret0 = addr[MEMLAT+2], poschr[1] // if we got here from l2
+(p6) adds ret0 = -1, ret0 /* if we got here from l1 or l3 */
+(p7) add ret0 = addr[MEMLAT+2], poschr[1] /* if we got here from l2 */
mov pr = saved_pr, -1
mov ar.lc = saved_lc
br.ret.sptk.many b0
END(__memchr)
-weak_alias (__memchr, memchr)
-#if !__BOUNDED_POINTERS__
-weak_alias (__memchr, __ubp_memchr)
-#endif
-libc_hidden_def (memchr)
+weak_alias(__memchr, memchr)
+weak_alias(__memchr, __ubp_memchr)
+libc_hidden_def(memchr)
diff --git a/libc/string/ia64/memcmp.S b/libc/string/ia64/memcmp.S
index 8b0c096ce..0cf54e7db 100644
--- a/libc/string/ia64/memcmp.S
+++ b/libc/string/ia64/memcmp.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/>. */
/* Return: the result of the comparison
@@ -28,16 +27,16 @@
In this form, it assumes little endian mode. For big endian mode, the
the two shifts in .l2 must be inverted:
- shl tmp1[0] = r[1 + MEMLAT], sh1 // tmp1 = w0 << sh1
+ shl tmp1[0] = r[1 + MEMLAT], sh1 // tmp1 = w0 << sh1
shr.u tmp2[0] = r[0 + MEMLAT], sh2 // tmp2 = w1 >> sh2
and all the mux1 instructions should be replaced by plain mov's. */
-#include "sysdep.h"
+#include <sysdep.h>
#undef ret
-#define OP_T_THRES 16
-#define OPSIZ 8
+#define OP_T_THRES 16
+#define OPSIZ 8
#define MEMLAT 2
#define start r15
@@ -56,85 +55,85 @@
ENTRY(memcmp)
.prologue
- alloc r2 = ar.pfs, 3, 37, 0, 40
+ alloc r2 = ar.pfs, 3, 37, 0, 40
.rotr r[MEMLAT + 2], q[MEMLAT + 5], tmp1[4], tmp2[4], val[2]
.rotp p[MEMLAT + 4 + 1]
- mov ret0 = r0 // by default return value = 0
+ mov ret0 = r0 /* by default return value = 0 */
.save pr, saved_pr
- mov saved_pr = pr // save the predicate registers
+ mov saved_pr = pr /* save the predicate registers */
.save ar.lc, saved_lc
- mov saved_lc = ar.lc // save the loop counter
+ mov saved_lc = ar.lc /* save the loop counter */
.body
- mov dest = in0 // dest
- mov src = in1 // src
- mov len = in2 // len
- sub tmp = r0, in0 // tmp = -dest
+ mov dest = in0 /* dest */
+ mov src = in1 /* src */
+ mov len = in2 /* len */
+ sub tmp = r0, in0 /* tmp = -dest */
;;
- and loopcnt = 7, tmp // loopcnt = -dest % 8
- cmp.ge p6, p0 = OP_T_THRES, len // is len <= OP_T_THRES
-(p6) br.cond.spnt .cmpfew // compare byte by byte
+ and loopcnt = 7, tmp /* loopcnt = -dest % 8 */
+ cmp.ge p6, p0 = OP_T_THRES, len /* is len <= OP_T_THRES */
+(p6) br.cond.spnt .cmpfew /* compare byte by byte */
;;
cmp.eq p6, p0 = loopcnt, r0
(p6) br.cond.sptk .dest_aligned
- sub len = len, loopcnt // len -= -dest % 8
- adds loopcnt = -1, loopcnt // --loopcnt
+ sub len = len, loopcnt /* len -= -dest % 8 */
+ adds loopcnt = -1, loopcnt /* --loopcnt */
;;
mov ar.lc = loopcnt
-.l1: // copy -dest % 8 bytes
- ld1 value1 = [src], 1 // value = *src++
+.l1: /* copy -dest % 8 bytes */
+ ld1 value1 = [src], 1 /* value = *src++ */
ld1 value2 = [dest], 1
;;
cmp.ne p6, p0 = value1, value2
(p6) br.cond.spnt .done
br.cloop.dptk .l1
.dest_aligned:
- and sh1 = 7, src // sh1 = src % 8
- and tmp = -8, len // tmp = len & -OPSIZ
- and asrc = -8, src // asrc = src & -OPSIZ -- align src
- shr.u loopcnt = len, 3 // loopcnt = len / 8
- and len = 7, len ;; // len = len % 8
- shl sh1 = sh1, 3 // sh1 = 8 * (src % 8)
- adds loopcnt = -1, loopcnt // --loopcnt
- mov pr.rot = 1 << 16 ;; // set rotating predicates
- sub sh2 = 64, sh1 // sh2 = 64 - sh1
- mov ar.lc = loopcnt // set LC
- cmp.eq p6, p0 = sh1, r0 // is the src aligned?
+ and sh1 = 7, src /* sh1 = src % 8 */
+ and tmp = -8, len /* tmp = len & -OPSIZ */
+ and asrc = -8, src /* asrc = src & -OPSIZ -- align src */
+ shr.u loopcnt = len, 3 /* loopcnt = len / 8 */
+ and len = 7, len ;; /* len = len % 8 */
+ shl sh1 = sh1, 3 /* sh1 = 8 * (src % 8) */
+ adds loopcnt = -1, loopcnt /* --loopcnt */
+ mov pr.rot = 1 << 16 ;; /* set rotating predicates */
+ sub sh2 = 64, sh1 /* sh2 = 64 - sh1 */
+ mov ar.lc = loopcnt /* set LC */
+ cmp.eq p6, p0 = sh1, r0 /* is the src aligned? */
(p6) br.cond.sptk .src_aligned
- add src = src, tmp // src += len & -OPSIZ
- mov ar.ec = MEMLAT + 4 + 1 // four more passes needed
- ld8 r[1] = [asrc], 8 ;; // r[1] = w0
+ add src = src, tmp /* src += len & -OPSIZ */
+ mov ar.ec = MEMLAT + 4 + 1 /* four more passes needed */
+ ld8 r[1] = [asrc], 8 ;; /* r[1] = w0 */
.align 32
-// We enter this loop with p6 cleared by the above comparison
+/* We enter this loop with p6 cleared by the above comparison */
.l2:
-(p[0]) ld8 r[0] = [asrc], 8 // r[0] = w1
+(p[0]) ld8 r[0] = [asrc], 8 /* r[0] = w1 */
(p[0]) ld8 q[0] = [dest], 8
-(p[MEMLAT]) shr.u tmp1[0] = r[1 + MEMLAT], sh1 // tmp1 = w0 >> sh1
-(p[MEMLAT]) shl tmp2[0] = r[0 + MEMLAT], sh2 // tmp2 = w1 << sh2
+(p[MEMLAT]) shr.u tmp1[0] = r[1 + MEMLAT], sh1 /* tmp1 = w0 >> sh1 */
+(p[MEMLAT]) shl tmp2[0] = r[0 + MEMLAT], sh2 /* tmp2 = w1 << sh2 */
(p[MEMLAT+4]) cmp.ne p6, p0 = q[MEMLAT + 4], val[1]
-(p[MEMLAT+3]) or val[0] = tmp1[3], tmp2[3] // val = tmp1 | tmp2
+(p[MEMLAT+3]) or val[0] = tmp1[3], tmp2[3] /* val = tmp1 | tmp2 */
(p6) br.cond.spnt .l2exit
br.ctop.sptk .l2
br.cond.sptk .cmpfew
.l3exit:
mux1 value1 = r[MEMLAT], @rev
mux1 value2 = q[MEMLAT], @rev
- cmp.ne p6, p0 = r0, r0 ;; // clear p6
+ cmp.ne p6, p0 = r0, r0 ;; /* clear p6 */
.l2exit:
(p6) mux1 value1 = val[1], @rev
(p6) mux1 value2 = q[MEMLAT + 4], @rev ;;
cmp.ltu p6, p7 = value2, value1 ;;
(p6) mov ret0 = -1
(p7) mov ret0 = 1
- mov pr = saved_pr, -1 // restore the predicate registers
- mov ar.lc = saved_lc // restore the loop counter
+ mov pr = saved_pr, -1 /* restore the predicate registers */
+ mov ar.lc = saved_lc /* restore the loop counter */
br.ret.sptk.many b0
.src_aligned:
- cmp.ne p6, p0 = r0, r0 // clear p6
- mov ar.ec = MEMLAT + 1 ;; // set EC
+ cmp.ne p6, p0 = r0, r0 /* clear p6 */
+ mov ar.ec = MEMLAT + 1 ;; /* set EC */
.l3:
(p[0]) ld8 r[0] = [src], 8
(p[0]) ld8 q[0] = [dest], 8
@@ -142,8 +141,8 @@ ENTRY(memcmp)
(p6) br.cond.spnt .l3exit
br.ctop.dptk .l3 ;;
.cmpfew:
- cmp.eq p6, p0 = len, r0 // is len == 0 ?
- adds len = -1, len // --len;
+ cmp.eq p6, p0 = len, r0 /* is len == 0 ? */
+ adds len = -1, len /* --len; */
(p6) br.cond.spnt .restore_and_exit ;;
mov ar.lc = len
.l4:
@@ -154,10 +153,10 @@ ENTRY(memcmp)
(p6) br.cond.spnt .done
br.cloop.dptk .l4 ;;
.done:
-(p6) sub ret0 = value2, value1 // don't execute it if falling thru
+(p6) sub ret0 = value2, value1 /* don't execute it if falling thru */
.restore_and_exit:
- mov pr = saved_pr, -1 // restore the predicate registers
- mov ar.lc = saved_lc // restore the loop counter
+ mov pr = saved_pr, -1 /* restore the predicate registers */
+ mov ar.lc = saved_lc /* restore the loop counter */
br.ret.sptk.many b0
END(memcmp)
libc_hidden_def (memcmp)
diff --git a/libc/string/ia64/memcpy.S b/libc/string/ia64/memcpy.S
index 810eb0c0e..5f2e79414 100644
--- a/libc/string/ia64/memcpy.S
+++ b/libc/string/ia64/memcpy.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/>. */
/* Return: dest
@@ -37,13 +36,13 @@
#define USE_LFETCH
#define USE_FLP
-#include "sysdep.h"
+#include <sysdep.h>
#undef ret
#define LFETCH_DIST 500
-#define ALIGN_UNROLL_no 4 // no. of elements
-#define ALIGN_UNROLL_sh 2 // (shift amount)
+#define ALIGN_UNROLL_no 4 /* no. of elements */
+#define ALIGN_UNROLL_sh 2 /* (shift amount) */
#define MEMLAT 8
#define Nrot ((4*(MEMLAT+2) + 7) & ~7)
@@ -168,76 +167,76 @@ ENTRY(memcpy)
.rotr r[MEMLAT+1], s[MEMLAT+2], q[MEMLAT+1], t[MEMLAT+1]
.rotp p[MEMLAT+2]
.rotf fr[MEMLAT+1], fq[MEMLAT+1], fs[MEMLAT+1], ft[MEMLAT+1]
- mov ret0 = in0 // return tmp2 = dest
+ mov ret0 = in0 /* return tmp2 = dest */
.save pr, saved_pr
- movi0 saved_pr = pr // save the predicate registers
+ movi0 saved_pr = pr /* save the predicate registers */
} { .mmi
- and tmp4 = 7, in0 // check if destination is aligned
- mov dest = in0 // dest
- mov src = in1 // src
+ and tmp4 = 7, in0 /* check if destination is aligned */
+ mov dest = in0 /* dest */
+ mov src = in1 /* src */
;; }
{ .mii
- cmp.eq p_scr, p0 = in2, r0 // if (len == 0)
+ cmp.eq p_scr, p0 = in2, r0 /* if (len == 0) */
.save ar.lc, saved_lc
- movi0 saved_lc = ar.lc // save the loop counter
+ movi0 saved_lc = ar.lc /* save the loop counter */
.body
- cmp.ge p_few, p0 = OP_T_THRES, in2 // is len <= OP_T_THRESH
+ cmp.ge p_few, p0 = OP_T_THRES, in2 /* is len <= OP_T_THRESH */
} { .mbb
- mov len = in2 // len
-(p_scr) br.cond.dpnt.few .restore_and_exit // Branch no. 1: return dest
-(p_few) br.cond.dpnt.many .copy_bytes // Branch no. 2: copy byte by byte
+ mov len = in2 /* len */
+(p_scr) br.cond.dpnt.few .restore_and_exit /* Branch no. 1: return dest */
+(p_few) br.cond.dpnt.many .copy_bytes /* Branch no. 2: copy byte by byte */
;; }
{ .mmi
#if defined(USE_LFETCH)
- lfetch.nt1 [dest] //
- lfetch.nt1 [src] //
+ lfetch.nt1 [dest] /* */
+ lfetch.nt1 [src] /* */
#endif
- shr.u elemcnt = len, 3 // elemcnt = len / 8
+ shr.u elemcnt = len, 3 /* elemcnt = len / 8 */
} { .mib
- cmp.eq p_scr, p0 = tmp4, r0 // is destination aligned?
- sub loopcnt = 7, tmp4 //
+ cmp.eq p_scr, p0 = tmp4, r0 /* is destination aligned? */
+ sub loopcnt = 7, tmp4 /* */
(p_scr) br.cond.dptk.many .dest_aligned
;; }
{ .mmi
- ld1 tmp2 = [src], 1 //
- sub len = len, loopcnt, 1 // reduce len
- movi0 ar.lc = loopcnt //
+ ld1 tmp2 = [src], 1 /* */
+ sub len = len, loopcnt, 1 /* reduce len */
+ movi0 ar.lc = loopcnt /* */
} { .mib
- cmp.ne p_scr, p0 = 0, loopcnt // avoid loading beyond end-point
+ cmp.ne p_scr, p0 = 0, loopcnt /* avoid loading beyond end-point */
;; }
-.l0: // ---------------------------- // L0: Align src on 8-byte boundary
+.l0: /* ---------------------------- L0: Align src on 8-byte boundary */
{ .mmi
- st1 [dest] = tmp2, 1 //
-(p_scr) ld1 tmp2 = [src], 1 //
+ st1 [dest] = tmp2, 1 /* */
+(p_scr) ld1 tmp2 = [src], 1 /* */
} { .mib
- cmp.lt p_scr, p0 = 1, loopcnt // avoid load beyond end-point
+ cmp.lt p_scr, p0 = 1, loopcnt /* avoid load beyond end-point */
add loopcnt = -1, loopcnt
- br.cloop.dptk.few .l0 //
+ br.cloop.dptk.few .l0 /* */
;; }
.dest_aligned:
{ .mmi
- and tmp4 = 7, src // ready for alignment check
- shr.u elemcnt = len, 3 // elemcnt = len / 8
+ and tmp4 = 7, src /* ready for alignment check */
+ shr.u elemcnt = len, 3 /* elemcnt = len / 8 */
;; }
{ .mib
- cmp.ne p_scr, p0 = tmp4, r0 // is source also aligned
- tbit.nz p_xtr, p_nxtr = src, 3 // prepare a separate move if src
-} { .mib // is not 16B aligned
- add ptr2 = LFETCH_DIST, dest // prefetch address
+ cmp.ne p_scr, p0 = tmp4, r0 /* is source also aligned */
+ tbit.nz p_xtr, p_nxtr = src, 3 /* prepare a separate move if src */
+} { .mib /* is not 16B aligned */
+ add ptr2 = LFETCH_DIST, dest /* prefetch address */
add ptr1 = LFETCH_DIST, src
(p_scr) br.cond.dptk.many .src_not_aligned
;; }
-// The optimal case, when dest, and src are aligned
+/* The optimal case, when dest, and src are aligned */
.both_aligned:
{ .mmi
.pred.rel "mutex",p_xtr,p_nxtr
-(p_xtr) cmp.gt p_scr, p0 = ALIGN_UNROLL_no+1, elemcnt // Need N + 1 to qualify
-(p_nxtr) cmp.gt p_scr, p0 = ALIGN_UNROLL_no, elemcnt // Need only N to qualify
- movi0 pr.rot = 1 << 16 // set rotating predicates
+(p_xtr) cmp.gt p_scr, p0 = ALIGN_UNROLL_no+1, elemcnt /* Need N + 1 to qualify */
+(p_nxtr) cmp.gt p_scr, p0 = ALIGN_UNROLL_no, elemcnt /* Need only N to qualify */
+ movi0 pr.rot = 1 << 16 /* set rotating predicates */
} { .mib
(p_scr) br.cond.dpnt.many .copy_full_words
;; }
@@ -245,21 +244,21 @@ ENTRY(memcpy)
{ .mmi
(p_xtr) load tempreg = [src], 8
(p_xtr) add elemcnt = -1, elemcnt
- movi0 ar.ec = MEMLAT + 1 // set the epilog counter
+ movi0 ar.ec = MEMLAT + 1 /* set the epilog counter */
;; }
{ .mmi
-(p_xtr) add len = -8, len //
- add asrc = 16, src // one bank apart (for USE_INT)
- shr.u loopcnt = elemcnt, ALIGN_UNROLL_sh // cater for unrolling
+(p_xtr) add len = -8, len /* */
+ add asrc = 16, src /* one bank apart (for USE_INT) */
+ shr.u loopcnt = elemcnt, ALIGN_UNROLL_sh /* cater for unrolling */
;;}
{ .mmi
add loopcnt = -1, loopcnt
-(p_xtr) store [dest] = tempreg, 8 // copy the "extra" word
+(p_xtr) store [dest] = tempreg, 8 /* copy the "extra" word */
nop.i 0
;; }
{ .mib
add adest = 16, dest
- movi0 ar.lc = loopcnt // set the loop counter
+ movi0 ar.lc = loopcnt /* set the loop counter */
;; }
#ifdef GAS_ALIGN_BREAKS_UNWIND_INFO
@@ -268,7 +267,7 @@ ENTRY(memcpy)
.align 32
#endif
#if defined(USE_FLP)
-.l1: // ------------------------------- // L1: Everything a multiple of 8
+.l1: /* ------------------------------- L1: Everything a multiple of 8 */
{ .mmi
#if defined(USE_LFETCH)
(p[0]) lfetch.nt1 [ptr2],32
@@ -290,7 +289,7 @@ ENTRY(memcpy)
br.ctop.dptk.many .l1
;; }
#elif defined(USE_INT)
-.l1: // ------------------------------- // L1: Everything a multiple of 8
+.l1: /* ------------------------------- L1: Everything a multiple of 8 */
{ .mmi
(p[0]) load the_r[0] = [src], 8
(p[0]) load the_q[0] = [asrc], 8
@@ -317,58 +316,58 @@ ENTRY(memcpy)
.copy_full_words:
{ .mib
- cmp.gt p_scr, p0 = 8, len //
- shr.u elemcnt = len, 3 //
+ cmp.gt p_scr, p0 = 8, len /* */
+ shr.u elemcnt = len, 3 /* */
(p_scr) br.cond.dpnt.many .copy_bytes
;; }
{ .mii
load tempreg = [src], 8
- add loopcnt = -1, elemcnt //
+ add loopcnt = -1, elemcnt /* */
;; }
{ .mii
- cmp.ne p_scr, p0 = 0, loopcnt //
- mov ar.lc = loopcnt //
+ cmp.ne p_scr, p0 = 0, loopcnt /* */
+ mov ar.lc = loopcnt /* */
;; }
-.l2: // ------------------------------- // L2: Max 4 words copied separately
+.l2: /* ------------------------------- L2: Max 4 words copied separately */
{ .mmi
store [dest] = tempreg, 8
-(p_scr) load tempreg = [src], 8 //
+(p_scr) load tempreg = [src], 8 /* */
add len = -8, len
} { .mib
- cmp.lt p_scr, p0 = 1, loopcnt // avoid load beyond end-point
+ cmp.lt p_scr, p0 = 1, loopcnt /* avoid load beyond end-point */
add loopcnt = -1, loopcnt
br.cloop.dptk.few .l2
;; }
.copy_bytes:
{ .mib
- cmp.eq p_scr, p0 = len, r0 // is len == 0 ?
- add loopcnt = -1, len // len--;
+ cmp.eq p_scr, p0 = len, r0 /* is len == 0 ? */
+ add loopcnt = -1, len /* len--; */
(p_scr) br.cond.spnt .restore_and_exit
;; }
{ .mii
ld1 tmp2 = [src], 1
movi0 ar.lc = loopcnt
- cmp.ne p_scr, p0 = 0, loopcnt // avoid load beyond end-point
+ cmp.ne p_scr, p0 = 0, loopcnt /* avoid load beyond end-point */
;; }
-.l3: // ------------------------------- // L3: Final byte move
+.l3: /* ------------------------------- L3: Final byte move */
{ .mmi
st1 [dest] = tmp2, 1
(p_scr) ld1 tmp2 = [src], 1
} { .mib
- cmp.lt p_scr, p0 = 1, loopcnt // avoid load beyond end-point
+ cmp.lt p_scr, p0 = 1, loopcnt /* avoid load beyond end-point */
add loopcnt = -1, loopcnt
br.cloop.dptk.few .l3
;; }
.restore_and_exit:
{ .mmi
- movi0 pr = saved_pr, -1 // restore the predicate registers
+ movi0 pr = saved_pr, -1 /* restore the predicate registers */
;; }
{ .mib
- movi0 ar.lc = saved_lc // restore the loop counter
+ movi0 ar.lc = saved_lc /* restore the loop counter */
br.ret.sptk.many b0
;; }
@@ -376,41 +375,41 @@ ENTRY(memcpy)
.src_not_aligned:
{ .mmi
cmp.gt p_scr, p0 = 16, len
- and sh1 = 7, src // sh1 = src % 8
- shr.u loopcnt = len, 4 // element-cnt = len / 16
+ and sh1 = 7, src /* sh1 = src % 8 */
+ shr.u loopcnt = len, 4 /* element-cnt = len / 16 */
} { .mib
add tmp4 = @ltoff(.table), gp
add tmp3 = @ltoff(.loop56), gp
-(p_scr) br.cond.dpnt.many .copy_bytes // do byte by byte if too few
+(p_scr) br.cond.dpnt.many .copy_bytes /* do byte by byte if too few */
;; }
{ .mmi
- and asrc = -8, src // asrc = (-8) -- align src for loop
- add loopcnt = -1, loopcnt // loopcnt--
- shl sh1 = sh1, 3 // sh1 = 8 * (src % 8)
+ and asrc = -8, src /* asrc = (-8) -- align src for loop */
+ add loopcnt = -1, loopcnt /* loopcnt-- */
+ shl sh1 = sh1, 3 /* sh1 = 8 * (src % 8) */
} { .mmi
- ld8 ptable = [tmp4] // ptable = &table
- ld8 ploop56 = [tmp3] // ploop56 = &loop56
- and tmp2 = -16, len // tmp2 = len & -OPSIZ
+ ld8 ptable = [tmp4] /* ptable = &table */
+ ld8 ploop56 = [tmp3] /* ploop56 = &loop56 */
+ and tmp2 = -16, len /* tmp2 = len & -OPSIZ */
;; }
{ .mmi
- add tmp3 = ptable, sh1 // tmp3 = &table + sh1
- add src = src, tmp2 // src += len & (-16)
- movi0 ar.lc = loopcnt // set LC
+ add tmp3 = ptable, sh1 /* tmp3 = &table + sh1 */
+ add src = src, tmp2 /* src += len & (-16) */
+ movi0 ar.lc = loopcnt /* set LC */
;; }
{ .mmi
- ld8 tmp4 = [tmp3] // tmp4 = loop offset
- sub len = len, tmp2 // len -= len & (-16)
- movi0 ar.ec = MEMLAT + 2 // one more pass needed
+ ld8 tmp4 = [tmp3] /* tmp4 = loop offset */
+ sub len = len, tmp2 /* len -= len & (-16) */
+ movi0 ar.ec = MEMLAT + 2 /* one more pass needed */
;; }
{ .mmi
- ld8 s[1] = [asrc], 8 // preload
- sub loopaddr = ploop56,tmp4 // loopadd = &loop56 - loop offset
- movi0 pr.rot = 1 << 16 // set rotating predicates
+ ld8 s[1] = [asrc], 8 /* preload */
+ sub loopaddr = ploop56,tmp4 /* loopadd = &loop56 - loop offset */
+ movi0 pr.rot = 1 << 16 /* set rotating predicates */
;; }
{ .mib
nop.m 0
movi0 b6 = loopaddr
- br b6 // jump to the appropriate loop
+ br b6 /* jump to the appropriate loop */
;; }
LOOP(8)
@@ -426,7 +425,7 @@ libc_hidden_def (memcpy)
.rodata
.align 8
.table:
- data8 0 // dummy entry
+ data8 0 /* dummy entry */
data8 .loop56 - .loop8
data8 .loop56 - .loop16
data8 .loop56 - .loop24
diff --git a/libc/string/ia64/memmove.S b/libc/string/ia64/memmove.S
index 00342d8e0..7d830f912 100644
--- a/libc/string/ia64/memmove.S
+++ b/libc/string/ia64/memmove.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/>. */
/* Return: dest
@@ -33,7 +32,7 @@
sh1 must be computed using an extra instruction: sub sh1 = 64, sh1
or the UM.be bit should be cleared at the beginning and set at the end. */
-#include "sysdep.h"
+#include <sysdep.h>
#undef ret
#define OP_T_THRES 16
@@ -81,48 +80,48 @@ ENTRY(memmove)
alloc r2 = ar.pfs, 3, Nrot - 3, 0, Nrot
.rotr r[MEMLAT + 2], q[MEMLAT + 1]
.rotp p[MEMLAT + 2]
- mov ret0 = in0 // return value = dest
+ mov ret0 = in0 /* return value = dest */
.save pr, saved_pr
- mov saved_pr = pr // save the predicate registers
+ mov saved_pr = pr /* save the predicate registers */
.save ar.lc, saved_lc
- mov saved_lc = ar.lc // save the loop counter
+ mov saved_lc = ar.lc /* save the loop counter */
.body
- or tmp3 = in0, in1 ;; // tmp3 = dest | src
- or tmp3 = tmp3, in2 // tmp3 = dest | src | len
- mov dest = in0 // dest
- mov src = in1 // src
- mov len = in2 // len
- sub tmp2 = r0, in0 // tmp2 = -dest
- cmp.eq p6, p0 = in2, r0 // if (len == 0)
-(p6) br.cond.spnt .restore_and_exit;;// return dest;
- and tmp4 = 7, tmp3 // tmp4 = (dest | src | len) & 7
- cmp.le p6, p0 = dest, src // if dest <= src it's always safe
-(p6) br.cond.spnt .forward // to copy forward
+ or tmp3 = in0, in1 ;; /* tmp3 = dest | src */
+ or tmp3 = tmp3, in2 /* tmp3 = dest | src | len */
+ mov dest = in0 /* dest */
+ mov src = in1 /* src */
+ mov len = in2 /* len */
+ sub tmp2 = r0, in0 /* tmp2 = -dest */
+ cmp.eq p6, p0 = in2, r0 /* if (len == 0) */
+(p6) br.cond.spnt .restore_and_exit;;/* return dest; */
+ and tmp4 = 7, tmp3 /* tmp4 = (dest | src | len) & 7 */
+ cmp.le p6, p0 = dest, src /* if dest <= src it's always safe */
+(p6) br.cond.spnt .forward /* to copy forward */
add tmp3 = src, len;;
- cmp.lt p6, p0 = dest, tmp3 // if dest > src && dest < src + len
-(p6) br.cond.spnt .backward // we have to copy backward
+ cmp.lt p6, p0 = dest, tmp3 /* if dest > src && dest < src + len */
+(p6) br.cond.spnt .backward /* we have to copy backward */
.forward:
- shr.u loopcnt = len, 4 ;; // loopcnt = len / 16
- cmp.ne p6, p0 = tmp4, r0 // if ((dest | src | len) & 7 != 0)
-(p6) br.cond.sptk .next // goto next;
+ shr.u loopcnt = len, 4 ;; /* loopcnt = len / 16 */
+ cmp.ne p6, p0 = tmp4, r0 /* if ((dest | src | len) & 7 != 0) */
+(p6) br.cond.sptk .next /* goto next; */
-// The optimal case, when dest, src and len are all multiples of 8
+/* The optimal case, when dest, src and len are all multiples of 8 */
and tmp3 = 0xf, len
- mov pr.rot = 1 << 16 // set rotating predicates
- mov ar.ec = MEMLAT + 1 ;; // set the epilog counter
- cmp.ne p6, p0 = tmp3, r0 // do we have to copy an extra word?
- adds loopcnt = -1, loopcnt;; // --loopcnt
+ mov pr.rot = 1 << 16 /* set rotating predicates */
+ mov ar.ec = MEMLAT + 1 ;; /* set the epilog counter */
+ cmp.ne p6, p0 = tmp3, r0 /* do we have to copy an extra word? */
+ adds loopcnt = -1, loopcnt;; /* --loopcnt */
(p6) ld8 value = [src], 8;;
-(p6) st8 [dest] = value, 8 // copy the "odd" word
- mov ar.lc = loopcnt // set the loop counter
+(p6) st8 [dest] = value, 8 /* copy the "odd" word */
+ mov ar.lc = loopcnt /* set the loop counter */
cmp.eq p6, p0 = 8, len
-(p6) br.cond.spnt .restore_and_exit;;// the one-word special case
- adds adest = 8, dest // set adest one word ahead of dest
- adds asrc = 8, src ;; // set asrc one word ahead of src
- nop.b 0 // get the "golden" alignment for
- nop.b 0 // the next loop
+(p6) br.cond.spnt .restore_and_exit;;/* the one-word special case */
+ adds adest = 8, dest /* set adest one word ahead of dest */
+ adds asrc = 8, src ;; /* set asrc one word ahead of src */
+ nop.b 0 /* get the "golden" alignment for */
+ nop.b 0 /* the next loop */
.l0:
(p[0]) ld8 r[0] = [src], 16
(p[0]) ld8 q[0] = [asrc], 16
@@ -130,50 +129,50 @@ ENTRY(memmove)
(p[MEMLAT]) st8 [adest] = q[MEMLAT], 16
br.ctop.dptk .l0 ;;
- mov pr = saved_pr, -1 // restore the predicate registers
- mov ar.lc = saved_lc // restore the loop counter
+ mov pr = saved_pr, -1 /* restore the predicate registers */
+ mov ar.lc = saved_lc /* restore the loop counter */
br.ret.sptk.many b0
.next:
- cmp.ge p6, p0 = OP_T_THRES, len // is len <= OP_T_THRES
- and loopcnt = 7, tmp2 // loopcnt = -dest % 8
-(p6) br.cond.spnt .cpyfew // copy byte by byte
+ cmp.ge p6, p0 = OP_T_THRES, len /* is len <= OP_T_THRES */
+ and loopcnt = 7, tmp2 /* loopcnt = -dest % 8 */
+(p6) br.cond.spnt .cpyfew /* copy byte by byte */
;;
cmp.eq p6, p0 = loopcnt, r0
(p6) br.cond.sptk .dest_aligned
- sub len = len, loopcnt // len -= -dest % 8
- adds loopcnt = -1, loopcnt // --loopcnt
+ sub len = len, loopcnt /* len -= -dest % 8 */
+ adds loopcnt = -1, loopcnt /* --loopcnt */
;;
mov ar.lc = loopcnt
-.l1: // copy -dest % 8 bytes
- ld1 value = [src], 1 // value = *src++
+.l1: /* copy -dest % 8 bytes */
+ ld1 value = [src], 1 /* value = *src++ */
;;
- st1 [dest] = value, 1 // *dest++ = value
+ st1 [dest] = value, 1 /* *dest++ = value */
br.cloop.dptk .l1
.dest_aligned:
- and sh1 = 7, src // sh1 = src % 8
- and tmp2 = -8, len // tmp2 = len & -OPSIZ
- and asrc = -8, src // asrc = src & -OPSIZ -- align src
- shr.u loopcnt = len, 3 // loopcnt = len / 8
- and len = 7, len;; // len = len % 8
- adds loopcnt = -1, loopcnt // --loopcnt
+ and sh1 = 7, src /* sh1 = src % 8 */
+ and tmp2 = -8, len /* tmp2 = len & -OPSIZ */
+ and asrc = -8, src /* asrc = src & -OPSIZ -- align src */
+ shr.u loopcnt = len, 3 /* loopcnt = len / 8 */
+ and len = 7, len;; /* len = len % 8 */
+ adds loopcnt = -1, loopcnt /* --loopcnt */
addl tmp4 = @ltoff(.table), gp
addl tmp3 = @ltoff(.loop56), gp
- mov ar.ec = MEMLAT + 1 // set EC
- mov pr.rot = 1 << 16;; // set rotating predicates
- mov ar.lc = loopcnt // set LC
- cmp.eq p6, p0 = sh1, r0 // is the src aligned?
+ mov ar.ec = MEMLAT + 1 /* set EC */
+ mov pr.rot = 1 << 16;; /* set rotating predicates */
+ mov ar.lc = loopcnt /* set LC */
+ cmp.eq p6, p0 = sh1, r0 /* is the src aligned? */
(p6) br.cond.sptk .src_aligned
- add src = src, tmp2 // src += len & -OPSIZ
- shl sh1 = sh1, 3 // sh1 = 8 * (src % 8)
- ld8 ploop56 = [tmp3] // ploop56 = &loop56
- ld8 ptable = [tmp4];; // ptable = &table
- add tmp3 = ptable, sh1;; // tmp3 = &table + sh1
- mov ar.ec = MEMLAT + 1 + 1 // one more pass needed
- ld8 tmp4 = [tmp3];; // tmp4 = loop offset
- sub loopaddr = ploop56,tmp4 // loopadd = &loop56 - loop offset
- ld8 r[1] = [asrc], 8;; // w0
+ add src = src, tmp2 /* src += len & -OPSIZ */
+ shl sh1 = sh1, 3 /* sh1 = 8 * (src % 8) */
+ ld8 ploop56 = [tmp3] /* ploop56 = &loop56 */
+ ld8 ptable = [tmp4];; /* ptable = &table */
+ add tmp3 = ptable, sh1;; /* tmp3 = &table + sh1 */
+ mov ar.ec = MEMLAT + 1 + 1 /* one more pass needed */
+ ld8 tmp4 = [tmp3];; /* tmp4 = loop offset */
+ sub loopaddr = ploop56,tmp4 /* loopadd = &loop56 - loop offset */
+ ld8 r[1] = [asrc], 8;; /* w0 */
mov b6 = loopaddr;;
- br b6 // jump to the appropriate loop
+ br b6 /* jump to the appropriate loop */
LOOP(8)
LOOP(16)
@@ -189,8 +188,8 @@ ENTRY(memmove)
(p[MEMLAT]) st8 [dest] = r[MEMLAT], 8
br.ctop.dptk .l3
.cpyfew:
- cmp.eq p6, p0 = len, r0 // is len == 0 ?
- adds len = -1, len // --len;
+ cmp.eq p6, p0 = len, r0 /* is len == 0 ? */
+ adds len = -1, len /* --len; */
(p6) br.cond.spnt .restore_and_exit ;;
mov ar.lc = len
.l4:
@@ -199,36 +198,36 @@ ENTRY(memmove)
st1 [dest] = value, 1
br.cloop.dptk .l4 ;;
.restore_and_exit:
- mov pr = saved_pr, -1 // restore the predicate registers
- mov ar.lc = saved_lc // restore the loop counter
+ mov pr = saved_pr, -1 /* restore the predicate registers */
+ mov ar.lc = saved_lc /* restore the loop counter */
br.ret.sptk.many b0
-// In the case of a backward copy, optimise only the case when everything
-// is a multiple of 8, otherwise copy byte by byte. The backward copy is
-// used only when the blocks are overlapping and dest > src.
-
+/* In the case of a backward copy, optimise only the case when everything
+ is a multiple of 8, otherwise copy byte by byte. The backward copy is
+ used only when the blocks are overlapping and dest > src.
+*/
.backward:
- shr.u loopcnt = len, 3 // loopcnt = len / 8
- add src = src, len // src points one byte past the end
- add dest = dest, len ;; // dest points one byte past the end
- mov ar.ec = MEMLAT + 1 // set the epilog counter
- mov pr.rot = 1 << 16 // set rotating predicates
- adds loopcnt = -1, loopcnt // --loopcnt
- cmp.ne p6, p0 = tmp4, r0 // if ((dest | src | len) & 7 != 0)
-(p6) br.cond.sptk .bytecopy ;; // copy byte by byte backward
- adds src = -8, src // src points to the last word
- adds dest = -8, dest // dest points to the last word
- mov ar.lc = loopcnt;; // set the loop counter
+ shr.u loopcnt = len, 3 /* loopcnt = len / 8 */
+ add src = src, len /* src points one byte past the end */
+ add dest = dest, len ;; /* dest points one byte past the end */
+ mov ar.ec = MEMLAT + 1 /* set the epilog counter */
+ mov pr.rot = 1 << 16 /* set rotating predicates */
+ adds loopcnt = -1, loopcnt /* --loopcnt */
+ cmp.ne p6, p0 = tmp4, r0 /* if ((dest | src | len) & 7 != 0) */
+(p6) br.cond.sptk .bytecopy ;; /* copy byte by byte backward */
+ adds src = -8, src /* src points to the last word */
+ adds dest = -8, dest /* dest points to the last word */
+ mov ar.lc = loopcnt;; /* set the loop counter */
.l5:
(p[0]) ld8 r[0] = [src], -8
(p[MEMLAT]) st8 [dest] = r[MEMLAT], -8
br.ctop.dptk .l5
br.cond.sptk .restore_and_exit
.bytecopy:
- adds src = -1, src // src points to the last byte
- adds dest = -1, dest // dest points to the last byte
- adds loopcnt = -1, len;; // loopcnt = len - 1
- mov ar.lc = loopcnt;; // set the loop counter
+ adds src = -1, src /* src points to the last byte */
+ adds dest = -1, dest /* dest points to the last byte */
+ adds loopcnt = -1, len;; /* loopcnt = len - 1 */
+ mov ar.lc = loopcnt;; /* set the loop counter */
.l6:
(p[0]) ld1 r[0] = [src], -1
(p[MEMLAT]) st1 [dest] = r[MEMLAT], -1
@@ -239,7 +238,7 @@ END(memmove)
.rodata
.align 8
.table:
- data8 0 // dummy entry
+ data8 0 /* dummy entry */
data8 .loop56 - .loop8
data8 .loop56 - .loop16
data8 .loop56 - .loop24
diff --git a/libc/string/ia64/memset.S b/libc/string/ia64/memset.S
index ed27f3f31..7bd15c88a 100644
--- a/libc/string/ia64/memset.S
+++ b/libc/string/ia64/memset.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/>. */
/* Return: dest
@@ -33,7 +32,7 @@
Since a stf.spill f0 can store 16B in one go, we use this instruction
to get peak speed when value = 0. */
-#include "sysdep.h"
+#include <sysdep.h>
#undef ret
#define dest in0
@@ -46,15 +45,15 @@
#define ptr1 r28
#define ptr2 r27
#define ptr3 r26
-#define ptr9 r24
+#define ptr9 r24
#define loopcnt r23
#define linecnt r22
#define bytecnt r21
#define fvalue f6
-// This routine uses only scratch predicate registers (p6 - p15)
-#define p_scr p6 // default register for same-cycle branches
+/* This routine uses only scratch predicate registers (p6 - p15) */
+#define p_scr p6 /* default register for same-cycle branches */
#define p_nz p7
#define p_zr p8
#define p_unalgn p9
@@ -68,7 +67,7 @@
#define MIN1 15
#define MIN1P1HALF 8
#define LINE_SIZE 128
-#define LSIZE_SH 7 // shift amount
+#define LSIZE_SH 7 /* shift amount */
#define PREF_AHEAD 8
#define USE_FLP
@@ -90,97 +89,97 @@ ENTRY(memset)
movi0 save_lc = ar.lc
} { .mmi
.body
- mov ret0 = dest // return value
- cmp.ne p_nz, p_zr = value, r0 // use stf.spill if value is zero
+ mov ret0 = dest /* return value */
+ cmp.ne p_nz, p_zr = value, r0 /* use stf.spill if value is zero */
cmp.eq p_scr, p0 = cnt, r0
;; }
{ .mmi
- and ptr2 = -(MIN1+1), dest // aligned address
- and tmp = MIN1, dest // prepare to check for alignment
- tbit.nz p_y, p_n = dest, 0 // Do we have an odd address? (M_B_U)
+ and ptr2 = -(MIN1+1), dest /* aligned address */
+ and tmp = MIN1, dest /* prepare to check for alignment */
+ tbit.nz p_y, p_n = dest, 0 /* Do we have an odd address? (M_B_U) */
} { .mib
mov ptr1 = dest
- mux1 value = value, @brcst // create 8 identical bytes in word
-(p_scr) br.ret.dpnt.many rp // return immediately if count = 0
+ mux1 value = value, @brcst /* create 8 identical bytes in word */
+(p_scr) br.ret.dpnt.many rp /* return immediately if count = 0 */
;; }
{ .mib
cmp.ne p_unalgn, p0 = tmp, r0
-} { .mib // NB: # of bytes to move is 1 higher
- sub bytecnt = (MIN1+1), tmp // than loopcnt
- cmp.gt p_scr, p0 = 16, cnt // is it a minimalistic task?
-(p_scr) br.cond.dptk.many .move_bytes_unaligned // go move just a few (M_B_U)
+} { .mib /* NB: # of bytes to move is 1 higher */
+ sub bytecnt = (MIN1+1), tmp /* than loopcnt */
+ cmp.gt p_scr, p0 = 16, cnt /* is it a minimalistic task? */
+(p_scr) br.cond.dptk.many .move_bytes_unaligned /* go move just a few (M_B_U) */
;; }
{ .mmi
-(p_unalgn) add ptr1 = (MIN1+1), ptr2 // after alignment
-(p_unalgn) add ptr2 = MIN1P1HALF, ptr2 // after alignment
-(p_unalgn) tbit.nz.unc p_y, p_n = bytecnt, 3 // should we do a st8 ?
+(p_unalgn) add ptr1 = (MIN1+1), ptr2 /* after alignment */
+(p_unalgn) add ptr2 = MIN1P1HALF, ptr2 /* after alignment */
+(p_unalgn) tbit.nz.unc p_y, p_n = bytecnt, 3 /* should we do a st8 ? */
;; }
{ .mib
(p_y) add cnt = -8, cnt
-(p_unalgn) tbit.nz.unc p_yy, p_nn = bytecnt, 2 // should we do a st4 ?
+(p_unalgn) tbit.nz.unc p_yy, p_nn = bytecnt, 2 /* should we do a st4 ? */
} { .mib
(p_y) st8 [ptr2] = value, -4
(p_n) add ptr2 = 4, ptr2
;; }
{ .mib
(p_yy) add cnt = -4, cnt
-(p_unalgn) tbit.nz.unc p_y, p_n = bytecnt, 1 // should we do a st2 ?
+(p_unalgn) tbit.nz.unc p_y, p_n = bytecnt, 1 /* should we do a st2 ? */
} { .mib
(p_yy) st4 [ptr2] = value, -2
(p_nn) add ptr2 = 2, ptr2
;; }
{ .mmi
- mov tmp = LINE_SIZE+1 // for compare
+ mov tmp = LINE_SIZE+1 /* for compare */
(p_y) add cnt = -2, cnt
-(p_unalgn) tbit.nz.unc p_yy, p_nn = bytecnt, 0 // should we do a st1 ?
+(p_unalgn) tbit.nz.unc p_yy, p_nn = bytecnt, 0 /* should we do a st1 ? */
} { .mmi
- setf.sig fvalue=value // transfer value to FLP side
+ setf.sig fvalue=value /* transfer value to FLP side */
(p_y) st2 [ptr2] = value, -1
(p_n) add ptr2 = 1, ptr2
;; }
{ .mmi
(p_yy) st1 [ptr2] = value
- cmp.gt p_scr, p0 = tmp, cnt // is it a minimalistic task?
+ cmp.gt p_scr, p0 = tmp, cnt /* is it a minimalistic task? */
} { .mbb
(p_yy) add cnt = -1, cnt
-(p_scr) br.cond.dpnt.many .fraction_of_line // go move just a few
+(p_scr) br.cond.dpnt.many .fraction_of_line /* go move just a few */
;; }
{ .mib
nop.m 0
shr.u linecnt = cnt, LSIZE_SH
-(p_zr) br.cond.dptk.many .l1b // Jump to use stf.spill
+(p_zr) br.cond.dptk.many .l1b /* Jump to use stf.spill */
;; }
#ifndef GAS_ALIGN_BREAKS_UNWIND_INFO
- .align 32 // -------- // L1A: store ahead into cache lines; fill later
+ .align 32 /* -------- L1A: store ahead into cache lines; fill later */
#endif
{ .mmi
- and tmp = -(LINE_SIZE), cnt // compute end of range
- mov ptr9 = ptr1 // used for prefetching
- and cnt = (LINE_SIZE-1), cnt // remainder
+ and tmp = -(LINE_SIZE), cnt /* compute end of range */
+ mov ptr9 = ptr1 /* used for prefetching */
+ and cnt = (LINE_SIZE-1), cnt /* remainder */
} { .mmi
- mov loopcnt = PREF_AHEAD-1 // default prefetch loop
- cmp.gt p_scr, p0 = PREF_AHEAD, linecnt // check against actual value
+ mov loopcnt = PREF_AHEAD-1 /* default prefetch loop */
+ cmp.gt p_scr, p0 = PREF_AHEAD, linecnt /* check against actual value */
;; }
{ .mmi
-(p_scr) add loopcnt = -1, linecnt // start of stores
- add ptr2 = 8, ptr1 // (beyond prefetch stores)
- add ptr1 = tmp, ptr1 // first address beyond total
-;; } // range
+(p_scr) add loopcnt = -1, linecnt /* start of stores */
+ add ptr2 = 8, ptr1 /* (beyond prefetch stores) */
+ add ptr1 = tmp, ptr1 /* first address beyond total */
+;; } /* range */
{ .mmi
- add tmp = -1, linecnt // next loop count
+ add tmp = -1, linecnt /* next loop count */
movi0 ar.lc = loopcnt
;; }
.pref_l1a:
{ .mib
- store [ptr9] = myval, 128 // Do stores one cache line apart
+ store [ptr9] = myval, 128 /* Do stores one cache line apart */
nop.i 0
br.cloop.dptk.few .pref_l1a
;; }
{ .mmi
- add ptr0 = 16, ptr2 // Two stores in parallel
+ add ptr0 = 16, ptr2 /* Two stores in parallel */
movi0 ar.lc = tmp
;; }
.l1ax:
@@ -211,7 +210,7 @@ ENTRY(memset)
{ .mmi
store [ptr2] = myval, 8
store [ptr0] = myval, 32
- cmp.lt p_scr, p0 = ptr9, ptr1 // do we need more prefetching?
+ cmp.lt p_scr, p0 = ptr9, ptr1 /* do we need more prefetching? */
;; }
{ .mmb
store [ptr2] = myval, 24
@@ -219,9 +218,9 @@ ENTRY(memset)
br.cloop.dptk.few .l1ax
;; }
{ .mbb
- cmp.le p_scr, p0 = 8, cnt // just a few bytes left ?
-(p_scr) br.cond.dpnt.many .fraction_of_line // Branch no. 2
- br.cond.dpnt.many .move_bytes_from_alignment // Branch no. 3
+ cmp.le p_scr, p0 = 8, cnt /* just a few bytes left ? */
+(p_scr) br.cond.dpnt.many .fraction_of_line /* Branch no. 2 */
+ br.cond.dpnt.many .move_bytes_from_alignment /* Branch no. 3 */
;; }
#ifdef GAS_ALIGN_BREAKS_UNWIND_INFO
@@ -229,32 +228,32 @@ ENTRY(memset)
#else
.align 32
#endif
-.l1b: // ------------------ // L1B: store ahead into cache lines; fill later
+.l1b: /* ------------------ L1B: store ahead into cache lines; fill later */
{ .mmi
- and tmp = -(LINE_SIZE), cnt // compute end of range
- mov ptr9 = ptr1 // used for prefetching
- and cnt = (LINE_SIZE-1), cnt // remainder
+ and tmp = -(LINE_SIZE), cnt /* compute end of range */
+ mov ptr9 = ptr1 /* used for prefetching */
+ and cnt = (LINE_SIZE-1), cnt /* remainder */
} { .mmi
- mov loopcnt = PREF_AHEAD-1 // default prefetch loop
- cmp.gt p_scr, p0 = PREF_AHEAD, linecnt // check against actual value
+ mov loopcnt = PREF_AHEAD-1 /* default prefetch loop */
+ cmp.gt p_scr, p0 = PREF_AHEAD, linecnt /* check against actual value */
;; }
{ .mmi
(p_scr) add loopcnt = -1, linecnt
- add ptr2 = 16, ptr1 // start of stores (beyond prefetch stores)
- add ptr1 = tmp, ptr1 // first address beyond total range
+ add ptr2 = 16, ptr1 /* start of stores (beyond prefetch stores) */
+ add ptr1 = tmp, ptr1 /* first address beyond total range */
;; }
{ .mmi
- add tmp = -1, linecnt // next loop count
+ add tmp = -1, linecnt /* next loop count */
movi0 ar.lc = loopcnt
;; }
.pref_l1b:
{ .mib
- stf.spill [ptr9] = f0, 128 // Do stores one cache line apart
+ stf.spill [ptr9] = f0, 128 /* Do stores one cache line apart */
nop.i 0
br.cloop.dptk.few .pref_l1b
;; }
{ .mmi
- add ptr0 = 16, ptr2 // Two stores in parallel
+ add ptr0 = 16, ptr2 /* Two stores in parallel */
movi0 ar.lc = tmp
;; }
.l1bx:
@@ -269,7 +268,7 @@ ENTRY(memset)
{ .mmi
stf.spill [ptr2] = f0, 32
stf.spill [ptr0] = f0, 64
- cmp.lt p_scr, p0 = ptr9, ptr1 // do we need more prefetching?
+ cmp.lt p_scr, p0 = ptr9, ptr1 /* do we need more prefetching? */
;; }
{ .mmb
stf.spill [ptr2] = f0, 32
@@ -277,14 +276,14 @@ ENTRY(memset)
br.cloop.dptk.few .l1bx
;; }
{ .mib
- cmp.gt p_scr, p0 = 8, cnt // just a few bytes left ?
+ cmp.gt p_scr, p0 = 8, cnt /* just a few bytes left ? */
(p_scr) br.cond.dpnt.many .move_bytes_from_alignment
;; }
.fraction_of_line:
{ .mib
add ptr2 = 16, ptr1
- shr.u loopcnt = cnt, 5 // loopcnt = cnt / 32
+ shr.u loopcnt = cnt, 5 /* loopcnt = cnt / 32 */
;; }
{ .mib
cmp.eq p_scr, p0 = loopcnt, r0
@@ -292,13 +291,13 @@ ENTRY(memset)
(p_scr) br.cond.dpnt.many store_words
;; }
{ .mib
- and cnt = 0x1f, cnt // compute the remaining cnt
+ and cnt = 0x1f, cnt /* compute the remaining cnt */
movi0 ar.lc = loopcnt
;; }
#ifndef GAS_ALIGN_BREAKS_UNWIND_INFO
.align 32
#endif
-.l2: // ---------------------------- // L2A: store 32B in 2 cycles
+.l2: /* ---------------------------- L2A: store 32B in 2 cycles */
{ .mmb
store [ptr1] = myval, 8
store [ptr2] = myval, 8
@@ -309,34 +308,34 @@ ENTRY(memset)
;; }
store_words:
{ .mib
- cmp.gt p_scr, p0 = 8, cnt // just a few bytes left ?
-(p_scr) br.cond.dpnt.many .move_bytes_from_alignment // Branch
+ cmp.gt p_scr, p0 = 8, cnt /* just a few bytes left ? */
+(p_scr) br.cond.dpnt.many .move_bytes_from_alignment /* Branch */
;; }
{ .mmi
- store [ptr1] = myval, 8 // store
- cmp.le p_y, p_n = 16, cnt //
- add cnt = -8, cnt // subtract
+ store [ptr1] = myval, 8 /* store */
+ cmp.le p_y, p_n = 16, cnt /* */
+ add cnt = -8, cnt /* subtract */
;; }
{ .mmi
-(p_y) store [ptr1] = myval, 8 // store
-(p_y) cmp.le.unc p_yy, p_nn = 16, cnt //
-(p_y) add cnt = -8, cnt // subtract
+(p_y) store [ptr1] = myval, 8 /* store */
+(p_y) cmp.le.unc p_yy, p_nn = 16, cnt /* */
+(p_y) add cnt = -8, cnt /* subtract */
;; }
-{ .mmi // store
-(p_yy) store [ptr1] = myval, 8 //
-(p_yy) add cnt = -8, cnt // subtract
+{ .mmi /* store */
+(p_yy) store [ptr1] = myval, 8 /* */
+(p_yy) add cnt = -8, cnt /* subtract */
;; }
.move_bytes_from_alignment:
{ .mib
cmp.eq p_scr, p0 = cnt, r0
- tbit.nz.unc p_y, p0 = cnt, 2 // should we terminate with a st4 ?
+ tbit.nz.unc p_y, p0 = cnt, 2 /* should we terminate with a st4 ? */
(p_scr) br.cond.dpnt.few .restore_and_exit
;; }
{ .mib
(p_y) st4 [ptr1] = value, 4
- tbit.nz.unc p_yy, p0 = cnt, 1 // should we terminate with a st2 ?
+ tbit.nz.unc p_yy, p0 = cnt, 1 /* should we terminate with a st2 ? */
;; }
{ .mib
(p_yy) st2 [ptr1] = value, 2
@@ -362,38 +361,38 @@ store_words:
(p_n) add ptr2 = 2, ptr1
} { .mmi
(p_y) add ptr2 = 3, ptr1
-(p_y) st1 [ptr1] = value, 1 // fill 1 (odd-aligned) byte
-(p_y) add cnt = -1, cnt // [15, 14 (or less) left]
+(p_y) st1 [ptr1] = value, 1 /* fill 1 (odd-aligned) byte */
+(p_y) add cnt = -1, cnt /* [15, 14 (or less) left] */
;; }
{ .mmi
(p_yy) cmp.le.unc p_y, p0 = 8, cnt
- add ptr3 = ptr1, cnt // prepare last store
+ add ptr3 = ptr1, cnt /* prepare last store */
movi0 ar.lc = save_lc
} { .mmi
-(p_yy) st2 [ptr1] = value, 4 // fill 2 (aligned) bytes
-(p_yy) st2 [ptr2] = value, 4 // fill 2 (aligned) bytes
-(p_yy) add cnt = -4, cnt // [11, 10 (o less) left]
+(p_yy) st2 [ptr1] = value, 4 /* fill 2 (aligned) bytes */
+(p_yy) st2 [ptr2] = value, 4 /* fill 2 (aligned) bytes */
+(p_yy) add cnt = -4, cnt /* [11, 10 (o less) left] */
;; }
{ .mmi
(p_y) cmp.le.unc p_yy, p0 = 8, cnt
- add ptr3 = -1, ptr3 // last store
- tbit.nz p_scr, p0 = cnt, 1 // will there be a st2 at the end ?
+ add ptr3 = -1, ptr3 /* last store */
+ tbit.nz p_scr, p0 = cnt, 1 /* will there be a st2 at the end ? */
} { .mmi
-(p_y) st2 [ptr1] = value, 4 // fill 2 (aligned) bytes
-(p_y) st2 [ptr2] = value, 4 // fill 2 (aligned) bytes
-(p_y) add cnt = -4, cnt // [7, 6 (or less) left]
+(p_y) st2 [ptr1] = value, 4 /* fill 2 (aligned) bytes */
+(p_y) st2 [ptr2] = value, 4 /* fill 2 (aligned) bytes */
+(p_y) add cnt = -4, cnt /* [7, 6 (or less) left] */
;; }
{ .mmi
-(p_yy) st2 [ptr1] = value, 4 // fill 2 (aligned) bytes
-(p_yy) st2 [ptr2] = value, 4 // fill 2 (aligned) bytes
- // [3, 2 (or less) left]
- tbit.nz p_y, p0 = cnt, 0 // will there be a st1 at the end ?
+(p_yy) st2 [ptr1] = value, 4 /* fill 2 (aligned) bytes */
+(p_yy) st2 [ptr2] = value, 4 /* fill 2 (aligned) bytes */
+ /* [3, 2 (or less) left] */
+ tbit.nz p_y, p0 = cnt, 0 /* will there be a st1 at the end ? */
} { .mmi
(p_yy) add cnt = -4, cnt
;; }
{ .mmb
-(p_scr) st2 [ptr1] = value // fill 2 (aligned) bytes
-(p_y) st1 [ptr3] = value // fill last byte (using ptr3)
+(p_scr) st2 [ptr1] = value /* fill 2 (aligned) bytes */
+(p_y) st1 [ptr3] = value /* fill last byte (using ptr3) */
br.ret.sptk.many rp
;; }
END(memset)
diff --git a/libc/string/ia64/softpipe.h b/libc/string/ia64/softpipe.h
index d71af735e..a9a9dc679 100644
--- a/libc/string/ia64/softpipe.h
+++ b/libc/string/ia64/softpipe.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/>. */
/* The latency of a memory load assumed by the assembly implementation
of the mem and str functions. Since we don't have any clue about
diff --git a/libc/string/ia64/strchr.S b/libc/string/ia64/strchr.S
index 401a07941..034fd3096 100644
--- a/libc/string/ia64/strchr.S
+++ b/libc/string/ia64/strchr.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/>. */
/* Return: the address of the first occurence of chr in str or NULL
@@ -30,7 +29,7 @@
This implementation assumes little endian mode. For big endian mode,
the instruction czx1.r should be replaced by czx1.l. */
-#include "sysdep.h"
+#include <sysdep.h>
#undef ret
#define saved_lc r18
@@ -49,15 +48,15 @@ ENTRY(strchr)
.prologue
alloc r2 = ar.pfs, 2, 0, 0, 0
.save ar.lc, saved_lc
- mov saved_lc = ar.lc // save the loop counter
+ mov saved_lc = ar.lc /* save the loop counter */
.body
mov ret0 = str
- and tmp = 7, str // tmp = str % 8
+ and tmp = 7, str /* tmp = str % 8 */
mux1 chrx8 = chr, @brcst
- extr.u chr = chr, 0, 8 // retain only the last byte
- cmp.ne p8, p0 = r0, r0 // clear p8
+ extr.u chr = chr, 0, 8 /* retain only the last byte */
+ cmp.ne p8, p0 = r0, r0 /* clear p8 */
;;
- sub loopcnt = 8, tmp // loopcnt = 8 - tmp
+ sub loopcnt = 8, tmp /* loopcnt = 8 - tmp */
cmp.eq p6, p0 = tmp, r0
(p6) br.cond.sptk .str_aligned;;
adds loopcnt = -1, loopcnt;;
@@ -75,10 +74,10 @@ ENTRY(strchr)
nop.b 0
nop.b 0
.l2:
- ld8.s val2 = [ret0], 8 // don't bomb out here
+ ld8.s val2 = [ret0], 8 /* don't bomb out here */
czx1.r pos0 = val1
- xor tmp = val1, chrx8 // if val1 contains chr, tmp will
- ;; // contain a zero in its position
+ xor tmp = val1, chrx8 /* if val1 contains chr, tmp will */
+ ;; /* contain a zero in its position */
czx1.r poschr = tmp
cmp.ne p6, p0 = 8, pos0
;;
@@ -90,21 +89,21 @@ ENTRY(strchr)
mov val1 = val2
br.cond.dptk .l2
.foundit:
-(p6) cmp.lt p8, p0 = pos0, poschr // we found chr and null in the word
-(p8) br.cond.spnt .notfound // null was found before chr
+(p6) cmp.lt p8, p0 = pos0, poschr /* we found chr and null in the word */
+(p8) br.cond.spnt .notfound /* null was found before chr */
add ret0 = ret0, poschr ;;
- adds ret0 = -15, ret0 ;; // should be -16, but we decrement
-.restore_and_exit: // ret0 in the next instruction
- adds ret0 = -1, ret0 // ret0 was pointing 1 char too far
- mov ar.lc = saved_lc // restore the loop counter
+ adds ret0 = -15, ret0 ;; /* should be -16, but we decrement */
+.restore_and_exit: /* ret0 in the next instruction */
+ adds ret0 = -1, ret0 /* ret0 was pointing 1 char too far */
+ mov ar.lc = saved_lc /* restore the loop counter */
br.ret.sptk.many b0
.notfound:
- mov ret0 = r0 // return NULL if null was found
+ mov ret0 = r0 /* return NULL if null was found */
mov ar.lc = saved_lc
br.ret.sptk.many b0
.recovery:
adds ret0 = -8, ret0;;
- ld8 val2 = [ret0], 8 // bomb out here
+ ld8 val2 = [ret0], 8 /* bomb out here */
br.cond.sptk .back
END(strchr)
libc_hidden_def (strchr)
diff --git a/libc/string/ia64/strcmp.S b/libc/string/ia64/strcmp.S
index d3b41e642..c45ab4801 100644
--- a/libc/string/ia64/strcmp.S
+++ b/libc/string/ia64/strcmp.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/>. */
/* Return: the result of the comparison
@@ -27,7 +26,7 @@
Unlike memcmp(), this function is optimized for mismatches within the
first few characters. */
-#include "sysdep.h"
+#include <sysdep.h>
#undef ret
#define s1 in0
@@ -42,7 +41,7 @@ ENTRY(strcmp)
.loop:
ld1 val1 = [s1], 1
ld1 val2 = [s2], 1
- cmp.eq p6, p0 = r0, r0 // set p6
+ cmp.eq p6, p0 = r0, r0 /* set p6 */
;;
cmp.ne.and p6, p0 = val1, r0
cmp.ne.and p6, p0 = val2, r0
diff --git a/libc/string/ia64/strcpy.S b/libc/string/ia64/strcpy.S
index e4a9915ca..c9b3bc143 100644
--- a/libc/string/ia64/strcpy.S
+++ b/libc/string/ia64/strcpy.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/>. */
/* Return: dest
@@ -27,11 +26,11 @@
In this form, it assumes little endian mode. For big endian mode, the
the two shifts in .l2 must be inverted:
- shl value = r[1], sh1 // value = w0 << sh1
- shr.u tmp = r[0], sh2 // tmp = w1 >> sh2
+ shl value = r[1], sh1 // value = w0 << sh1
+ shr.u tmp = r[0], sh2 // tmp = w1 >> sh2
*/
-#include "sysdep.h"
+#include <sysdep.h>
#undef ret
#define saved_lc r15
@@ -53,62 +52,62 @@
ENTRY(strcpy)
.prologue
- alloc r2 = ar.pfs, 2, 0, 30, 32
+ alloc r2 = ar.pfs, 2, 0, 30, 32
#define MEMLAT 2
.rotr r[MEMLAT + 2]
.rotp p[MEMLAT + 1]
- mov ret0 = in0 // return value = dest
+ mov ret0 = in0 /* return value = dest */
.save pr, saved_pr
- mov saved_pr = pr // save the predicate registers
+ mov saved_pr = pr /* save the predicate registers */
.save ar.lc, saved_lc
- mov saved_lc = ar.lc // save the loop counter
+ mov saved_lc = ar.lc /* save the loop counter */
.body
- sub tmp = r0, in0 ;; // tmp = -dest
- mov dest = in0 // dest
- mov src = in1 // src
- and loopcnt = 7, tmp ;; // loopcnt = -dest % 8
+ sub tmp = r0, in0 ;; /* tmp = -dest */
+ mov dest = in0 /* dest */
+ mov src = in1 /* src */
+ and loopcnt = 7, tmp ;; /* loopcnt = -dest % 8 */
cmp.eq p6, p0 = loopcnt, r0
- adds loopcnt = -1, loopcnt // --loopcnt
+ adds loopcnt = -1, loopcnt /* --loopcnt */
(p6) br.cond.sptk .dest_aligned ;;
mov ar.lc = loopcnt
-.l1: // copy -dest % 8 bytes
- ld1 c = [src], 1 // c = *src++
+.l1: /* copy -dest % 8 bytes */
+ ld1 c = [src], 1 /* c = *src++ */
;;
- st1 [dest] = c, 1 // *dest++ = c
+ st1 [dest] = c, 1 /* *dest++ = c */
cmp.eq p6, p0 = c, r0
(p6) br.cond.dpnt .restore_and_exit
br.cloop.dptk .l1 ;;
.dest_aligned:
- and sh1 = 7, src // sh1 = src % 8
- mov ar.lc = -1 // "infinite" loop
- and asrc = -8, src ;; // asrc = src & -OPSIZ -- align src
+ and sh1 = 7, src /* sh1 = src % 8 */
+ mov ar.lc = -1 /* "infinite" loop */
+ and asrc = -8, src ;; /* asrc = src & -OPSIZ -- align src */
sub thresh = 8, sh1
- mov pr.rot = 1 << 16 // set rotating predicates
- cmp.ne p7, p0 = r0, r0 // clear p7
- shl sh1 = sh1, 3 ;; // sh1 = 8 * (src % 8)
- sub sh2 = 64, sh1 // sh2 = 64 - sh1
- cmp.eq p6, p0 = sh1, r0 // is the src aligned?
+ mov pr.rot = 1 << 16 /* set rotating predicates */
+ cmp.ne p7, p0 = r0, r0 /* clear p7 */
+ shl sh1 = sh1, 3 ;; /* sh1 = 8 * (src % 8) */
+ sub sh2 = 64, sh1 /* sh2 = 64 - sh1 */
+ cmp.eq p6, p0 = sh1, r0 /* is the src aligned? */
(p6) br.cond.sptk .src_aligned ;;
ld8 r[1] = [asrc],8 ;;
.align 32
.l2:
ld8.s r[0] = [asrc], 8
- shr.u value = r[1], sh1 ;; // value = w0 >> sh1
- czx1.r pos = value ;; // do we have an "early" zero
- cmp.lt p7, p0 = pos, thresh // in w0 >> sh1?
+ shr.u value = r[1], sh1 ;; /* value = w0 >> sh1 */
+ czx1.r pos = value ;; /* do we have an "early" zero */
+ cmp.lt p7, p0 = pos, thresh /* in w0 >> sh1? */
(p7) br.cond.dpnt .found0
- chk.s r[0], .recovery2 // it is safe to do that only
-.back2: // after the previous test
- shl tmp = r[0], sh2 // tmp = w1 << sh2
+ chk.s r[0], .recovery2 /* it is safe to do that only */
+.back2: /* after the previous test */
+ shl tmp = r[0], sh2 /* tmp = w1 << sh2 */
;;
- or value = value, tmp ;; // value |= tmp
+ or value = value, tmp ;; /* value |= tmp */
czx1.r pos = value ;;
cmp.ne p7, p0 = 8, pos
(p7) br.cond.dpnt .found0
- st8 [dest] = value, 8 // store val to dest
+ st8 [dest] = value, 8 /* store val to dest */
br.ctop.dptk .l2 ;;
.src_aligned:
.l3:
@@ -124,14 +123,14 @@ ENTRY(strcpy)
.found0:
mov ar.lc = pos
.l4:
- extr.u c = value, 0, 8 // c = value & 0xff
+ extr.u c = value, 0, 8 /* c = value & 0xff */
shr.u value = value, 8
;;
st1 [dest] = c, 1
br.cloop.dptk .l4 ;;
.restore_and_exit:
- mov ar.lc = saved_lc // restore the loop counter
- mov pr = saved_pr, -1 // restore the predicate registers
+ mov ar.lc = saved_lc /* restore the loop counter */
+ mov pr = saved_pr, -1 /* restore the predicate registers */
br.ret.sptk.many b0
.recovery2:
add tmp = -8, asrc ;;
diff --git a/libc/string/ia64/strlen.S b/libc/string/ia64/strlen.S
index 9b27a2d1b..83244cd76 100644
--- a/libc/string/ia64/strlen.S
+++ b/libc/string/ia64/strlen.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/>. */
/* Return: the length of the input string
@@ -33,7 +32,7 @@
This implementation assumes little endian mode. For big endian mode,
the instruction czx1.r should be replaced by czx1.l. */
-#include "sysdep.h"
+#include <sysdep.h>
#undef ret
#define saved_lc r18
@@ -50,13 +49,13 @@ ENTRY(strlen)
.prologue
alloc r2 = ar.pfs, 1, 0, 0, 0
.save ar.lc, saved_lc
- mov saved_lc = ar.lc // save the loop counter
+ mov saved_lc = ar.lc /* save the loop counter */
.body
mov str = in0
- mov len = r0 // len = 0
- and tmp = 7, in0 // tmp = str % 8
+ mov len = r0 /* len = 0 */
+ and tmp = 7, in0 /* tmp = str % 8 */
;;
- sub loopcnt = 8, tmp // loopcnt = 8 - tmp
+ sub loopcnt = 8, tmp /* loopcnt = 8 - tmp */
cmp.eq p6, p0 = tmp, r0
(p6) br.cond.sptk .str_aligned;;
adds loopcnt = -1, loopcnt;;
@@ -69,11 +68,11 @@ ENTRY(strlen)
adds len = 1, len
br.cloop.dptk .l1
.str_aligned:
- mov origadd = str // origadd = orig
+ mov origadd = str /* origadd = orig */
ld8 val1 = [str], 8;;
nop.b 0
nop.b 0
-.l2: ld8.s val2 = [str], 8 // don't bomb out here
+.l2: ld8.s val2 = [str], 8 /* don't bomb out here */
czx1.r pos0 = val1
;;
cmp.ne p6, p0 = 8, pos0
@@ -83,16 +82,16 @@ ENTRY(strlen)
mov val1 = val2
br.cond.dptk .l2
.foundit:
- sub tmp = str, origadd // tmp = crt address - orig
+ sub tmp = str, origadd /* tmp = crt address - orig */
add len = len, pos0;;
add len = len, tmp;;
adds len = -16, len
.restore_and_exit:
- mov ar.lc = saved_lc // restore the loop counter
+ mov ar.lc = saved_lc /* restore the loop counter */
br.ret.sptk.many b0
.recovery:
adds str = -8, str;;
- ld8 val2 = [str], 8 // bomb out here
+ ld8 val2 = [str], 8 /* bomb out here */
br.cond.sptk .back
END(strlen)
libc_hidden_def (strlen)
diff --git a/libc/string/ia64/strncmp.S b/libc/string/ia64/strncmp.S
index 8e0373c7f..d58a2007e 100644
--- a/libc/string/ia64/strncmp.S
+++ b/libc/string/ia64/strncmp.S
@@ -14,21 +14,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/>. */
/* Return: the result of the comparison
Inputs:
in0: s1
in1: s2
- in2: n
+ in2: n
Unlike memcmp(), this function is optimized for mismatches within the
first few characters. */
-#include "sysdep.h"
+#include <sysdep.h>
#undef ret
#define s1 in0
@@ -42,13 +41,13 @@
ENTRY(strncmp)
alloc r2 = ar.pfs, 3, 0, 0, 0
mov ret0 = r0
- cmp.eq p6, p0 = r0, r0 // set p6
- cmp.eq p7, p0 = n, r0 // return immediately if n == 0
+ cmp.eq p6, p0 = r0, r0 /* set p6 */
+ cmp.eq p7, p0 = n, r0 /* return immediately if n == 0 */
(p7) br.cond.spnt .restore_and_exit ;;
.loop:
ld1 val1 = [s1], 1
ld1 val2 = [s2], 1
- adds n = -1, n // n--
+ adds n = -1, n /* n-- */
;;
cmp.ne.and p6, p0 = val1, r0
cmp.ne.and p6, p0 = val2, r0
@@ -58,5 +57,5 @@ ENTRY(strncmp)
sub ret0 = val1, val2
.restore_and_exit:
br.ret.sptk.many b0
-END(strncmp)
+END(strncmp)
libc_hidden_weak (strncmp)
diff --git a/libc/string/ia64/strncpy.S b/libc/string/ia64/strncpy.S
index 4f1129350..b72e8a70c 100644
--- a/libc/string/ia64/strncpy.S
+++ b/libc/string/ia64/strncpy.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/>. */
/* Return: dest
@@ -29,7 +28,7 @@
In this form, it assumes little endian mode.
*/
-#include "sysdep.h"
+#include <sysdep.h>
#undef ret
#define saved_lc r15
@@ -58,64 +57,64 @@ ENTRY(strncpy)
.rotr r[MEMLAT + 2]
.rotp p[MEMLAT + 1]
- mov ret0 = in0 // return value = dest
+ mov ret0 = in0 /* return value = dest */
.save pr, saved_pr
- mov saved_pr = pr // save the predicate registers
+ mov saved_pr = pr /* save the predicate registers */
.save ar.lc, saved_lc
- mov saved_lc = ar.lc // save the loop counter
- mov ar.ec = 0 // ec is not guaranteed to
- // be zero upon function entry
+ mov saved_lc = ar.lc /* save the loop counter */
+ mov ar.ec = 0 /* ec is not guaranteed to */
+ /* be zero upon function entry */
.body
cmp.geu p6, p5 = 24, in2
(p6) br.cond.spnt .short_len
- sub tmp = r0, in0 ;; // tmp = -dest
- mov len = in2 // len
- mov dest = in0 // dest
- mov src = in1 // src
- and tmp = 7, tmp ;; // loopcnt = -dest % 8
+ sub tmp = r0, in0 ;; /* tmp = -dest */
+ mov len = in2 /* len */
+ mov dest = in0 /* dest */
+ mov src = in1 /* src */
+ and tmp = 7, tmp ;; /* loopcnt = -dest % 8 */
cmp.eq p6, p7 = tmp, r0
- adds loopcnt = -1, tmp // --loopcnt
+ adds loopcnt = -1, tmp /* --loopcnt */
(p6) br.cond.sptk .dest_aligned ;;
- sub len = len, tmp // len -= -dest % 8
+ sub len = len, tmp /* len -= -dest % 8 */
mov ar.lc = loopcnt
-.l1: // copy -dest % 8 bytes
-(p5) ld1 c = [src], 1 // c = *src++
+.l1: /* copy -dest % 8 bytes */
+(p5) ld1 c = [src], 1 /* c = *src++ */
;;
- st1 [dest] = c, 1 // *dest++ = c
+ st1 [dest] = c, 1 /* *dest++ = c */
cmp.ne p5, p7 = c, r0
br.cloop.dptk .l1 ;;
(p7) br.cond.dpnt .found0_align
-.dest_aligned: // p7 should be cleared here
- shr.u c = len, 3 // c = len / 8
- and sh1 = 7, src // sh1 = src % 8
- and asrc = -8, src ;; // asrc = src & -OPSIZ -- align src
- adds c = (MEMLAT-1), c // c = (len / 8) + MEMLAT - 1
+.dest_aligned: /* p7 should be cleared here */
+ shr.u c = len, 3 /* c = len / 8 */
+ and sh1 = 7, src /* sh1 = src % 8 */
+ and asrc = -8, src ;; /* asrc = src & -OPSIZ -- align src */
+ adds c = (MEMLAT-1), c /* c = (len / 8) + MEMLAT - 1 */
sub thresh = 8, sh1
- mov pr.rot = 1 << 16 // set rotating predicates
- shl sh1 = sh1, 3 ;; // sh1 = 8 * (src % 8)
- mov ar.lc = c // "infinite" loop
- sub sh2 = 64, sh1 // sh2 = 64 - sh1
- cmp.eq p6, p0 = sh1, r0 // is the src aligned?
+ mov pr.rot = 1 << 16 /* set rotating predicates */
+ shl sh1 = sh1, 3 ;; /* sh1 = 8 * (src % 8) */
+ mov ar.lc = c /* "infinite" loop */
+ sub sh2 = 64, sh1 /* sh2 = 64 - sh1 */
+ cmp.eq p6, p0 = sh1, r0 /* is the src aligned? */
(p6) br.cond.sptk .src_aligned
- adds c = -(MEMLAT-1), c ;; // c = (len / 8)
+ adds c = -(MEMLAT-1), c ;; /* c = (len / 8) */
ld8 r[1] = [asrc],8
mov ar.lc = c ;;
.align 32
.l2:
-(p6) st8 [dest] = value, 8 // store val to dest
+(p6) st8 [dest] = value, 8 /* store val to dest */
ld8.s r[0] = [asrc], 8
- shr.u value = r[1], sh1 ;; // value = w0 >> sh1
- czx1.r pos = value ;; // do we have an "early" zero
- cmp.lt p7, p0 = pos, thresh // in w0 >> sh1?
- adds len = -8, len // len -= 8
+ shr.u value = r[1], sh1 ;; /* value = w0 >> sh1 */
+ czx1.r pos = value ;; /* do we have an "early" zero */
+ cmp.lt p7, p0 = pos, thresh /* in w0 >> sh1? */
+ adds len = -8, len /* len -= 8 */
(p7) br.cond.dpnt .nonalign_found0
- chk.s r[0], .recovery2 // it is safe to do that only
-.back2: // after the previous test
- shl tmp = r[0], sh2 // tmp = w1 << sh2
+ chk.s r[0], .recovery2 /* it is safe to do that only */
+.back2: /* after the previous test */
+ shl tmp = r[0], sh2 /* tmp = w1 << sh2 */
;;
- or value = value, tmp ;; // value |= tmp
+ or value = value, tmp ;; /* value |= tmp */
czx1.r pos = value ;;
cmp.ne p7, p6 = 8, pos
(p7) br.cond.dpnt .nonalign_found0
@@ -137,7 +136,7 @@ ENTRY(strncpy)
(p[MEMLAT]) mov value = r[MEMLAT]
(p[MEMLAT]) czx1.r pos = r[MEMLAT] ;;
(p[MEMLAT]) cmp.ne p7, p0 = 8, pos
-(p[MEMLAT]) adds len = -8, len // len -= 8
+(p[MEMLAT]) adds len = -8, len /* len -= 8 */
(p7) br.cond.dpnt .found0
(p[MEMLAT]) st8 [dest] = r[MEMLAT], 8
br.ctop.dptk .l3 ;;
@@ -152,7 +151,7 @@ ENTRY(strncpy)
(p5) br.cond.dptk .restore_and_exit ;;
mov ar.lc = len
.l4:
-(p6) extr.u c = value, 0, 8 // c = value & 0xff
+(p6) extr.u c = value, 0, 8 /* c = value & 0xff */
(p6) shr.u value = value, 8 ;;
st1 [dest] = c, 1
cmp.ne p6, p0 = c, r0
@@ -165,7 +164,7 @@ ENTRY(strncpy)
mov value = 0 ;;
.found0:
shl tmp = pos, 3
- shr.u loopcnt = len, 4 // loopcnt = len / 16
+ shr.u loopcnt = len, 4 /* loopcnt = len / 16 */
mov c = -1 ;;
cmp.eq p6, p0 = loopcnt, r0
adds loopcnt = -1, loopcnt
@@ -192,24 +191,24 @@ ENTRY(strncpy)
st1 [dest] = r0, 1
br.cloop.dptk .l7 ;;
.restore_and_exit:
- mov ar.lc = saved_lc // restore the loop counter
- mov pr = saved_pr, -1 // restore the predicate registers
+ mov ar.lc = saved_lc /* restore the loop counter */
+ mov pr = saved_pr, -1 /* restore the predicate registers */
br.ret.sptk.many b0
.short_len:
cmp.eq p5, p0 = in2, r0
adds loopcnt = -1, in2
(p5) br.cond.spnt .restore_and_exit ;;
- mov ar.lc = loopcnt // p6 should be set when we get here
+ mov ar.lc = loopcnt /* p6 should be set when we get here */
.l8:
-(p6) ld1 c = [in1], 1 // c = *src++
+(p6) ld1 c = [in1], 1 /* c = *src++ */
;;
- st1 [in0] = c, 1 // *dest++ = c
+ st1 [in0] = c, 1 /* *dest++ = c */
(p6) cmp.ne p6, p0 = c, r0
br.cloop.dptk .l8
;;
- mov ar.lc = saved_lc // restore the loop counter
- mov pr = saved_pr, -1 // restore the predicate registers
+ mov ar.lc = saved_lc /* restore the loop counter */
+ mov pr = saved_pr, -1 /* restore the predicate registers */
br.ret.sptk.many b0
.recovery2:
add c = 8, len
diff --git a/libc/string/ia64/sysdep.h b/libc/string/ia64/sysdep.h
deleted file mode 100644
index d10020ac1..000000000
--- a/libc/string/ia64/sysdep.h
+++ /dev/null
@@ -1,168 +0,0 @@
-/* Copyright (C) 1999, 2000, 2002, 2003, 2004 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Written by Jes Sorensen, <Jes.Sorensen@cern.ch>, April 1999.
- Based on code originally written by David Mosberger-Tang
-
- 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_IA64_SYSDEP_H
-#define _LINUX_IA64_SYSDEP_H 1
-
-#include <features.h>
-#include <asm/unistd.h>
-
-#ifdef __ASSEMBLER__
-
-/* Macros to help writing .prologue directives in assembly code. */
-#define ASM_UNW_PRLG_RP 0x8
-#define ASM_UNW_PRLG_PFS 0x4
-#define ASM_UNW_PRLG_PSP 0x2
-#define ASM_UNW_PRLG_PR 0x1
-#define ASM_UNW_PRLG_GRSAVE(ninputs) (32+(ninputs))
-
-#ifdef __STDC__
-#define C_LABEL(name) name :
-#else
-#define C_LABEL(name) name/**/:
-#endif
-
-#define CALL_MCOUNT
-
-#define ENTRY(name) \
- .text; \
- .align 32; \
- .proc C_SYMBOL_NAME(name); \
- .global C_SYMBOL_NAME(name); \
- C_LABEL(name) \
- CALL_MCOUNT
-
-#define LEAF(name) \
- .text; \
- .align 32; \
- .proc C_SYMBOL_NAME(name); \
- .global name; \
- C_LABEL(name)
-
-/* Mark the end of function SYM. */
-#undef END
-#define END(sym) .endp C_SYMBOL_NAME(sym)
-
-/* 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
-
-/* 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 %d0 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 handler to be visible in the symbol
- table when we define it here. */
-#define SYSCALL_ERROR_LABEL __syscall_error
-
-#undef PSEUDO
-#define PSEUDO(name, syscall_name, args) \
- ENTRY(name) \
- DO_CALL (SYS_ify(syscall_name)); \
- cmp.eq p6,p0=-1,r10; \
-(p6) br.cond.spnt.few __syscall_error;
-
-#define DO_CALL_VIA_BREAK(num) \
- mov r15=num; \
- break __BREAK_SYSCALL
-
-#ifdef IA64_USE_NEW_STUB
-# ifdef SHARED
-# define DO_CALL(num) \
- .prologue; \
- adds r2 = SYSINFO_OFFSET, r13;; \
- ld8 r2 = [r2]; \
- .save ar.pfs, r11; \
- mov r11 = ar.pfs;; \
- .body; \
- mov r15 = num; \
- mov b7 = r2; \
- br.call.sptk.many b6 = b7;; \
- .restore sp; \
- mov ar.pfs = r11; \
- .prologue; \
- .body
-# else /* !SHARED */
-# define DO_CALL(num) \
- .prologue; \
- mov r15 = num; \
- movl r2 = _dl_sysinfo;; \
- ld8 r2 = [r2]; \
- .save ar.pfs, r11; \
- mov r11 = ar.pfs;; \
- .body; \
- mov b7 = r2; \
- br.call.sptk.many b6 = b7;; \
- .restore sp; \
- mov ar.pfs = r11; \
- .prologue; \
- .body
-# endif
-#else
-# define DO_CALL(num) DO_CALL_VIA_BREAK(num)
-#endif
-
-#undef PSEUDO_END
-#define PSEUDO_END(name) .endp C_SYMBOL_NAME(name);
-
-#undef PSEUDO_NOERRNO
-#define PSEUDO_NOERRNO(name, syscall_name, args) \
- ENTRY(name) \
- DO_CALL (SYS_ify(syscall_name));
-
-#undef PSEUDO_END_NOERRNO
-#define PSEUDO_END_NOERRNO(name) .endp C_SYMBOL_NAME(name);
-
-#undef PSEUDO_ERRVAL
-#define PSEUDO_ERRVAL(name, syscall_name, args) \
- ENTRY(name) \
- DO_CALL (SYS_ify(syscall_name)); \
- cmp.eq p6,p0=-1,r10; \
-(p6) mov r10=r8;
-
-
-#undef PSEUDO_END_ERRVAL
-#define PSEUDO_END_ERRVAL(name) .endp C_SYMBOL_NAME(name);
-
-#undef END
-#define END(name) \
- .size C_SYMBOL_NAME(name), . - C_SYMBOL_NAME(name) ; \
- .endp C_SYMBOL_NAME(name)
-
-#define ret br.ret.sptk.few b0
-#define ret_NOERRNO ret
-#define ret_ERRVAL ret
-
-#endif /* not __ASSEMBLER__ */
-
-#endif /* linux/ia64/sysdep.h */
diff --git a/libc/string/memchr.c b/libc/string/memchr.c
index 413999722..99e13a2fc 100644
--- a/libc/string/memchr.c
+++ b/libc/string/memchr.c
@@ -10,31 +10,23 @@
#ifdef WANT_WIDE
# define Wmemchr wmemchr
#else
+# undef memchr
# define Wmemchr memchr
#endif
-libc_hidden_proto(Wmemchr)
-
Wvoid *Wmemchr(const Wvoid *s, Wint c, size_t n)
{
register const Wuchar *r = (const Wuchar *) s;
-#ifdef __BCC__
- /* bcc can optimize the counter if it thinks it is a pointer... */
- register const char *np = (const char *) n;
-#else
-# define np n
-#endif
- while (np) {
+ while (n) {
if (*r == ((Wuchar)c)) {
return (Wvoid *) r; /* silence the warning */
}
++r;
- --np;
+ --n;
}
return NULL;
}
-#undef np
libc_hidden_def(Wmemchr)
diff --git a/libc/string/memcmp.c b/libc/string/memcmp.c
index 762fc23c1..6cb37f417 100644
--- a/libc/string/memcmp.c
+++ b/libc/string/memcmp.c
@@ -10,7 +10,6 @@
#ifdef WANT_WIDE
# define Wmemcmp wmemcmp
#else
-/* Experimentally off - libc_hidden_proto(memcmp) */
# define Wmemcmp memcmp
#endif
diff --git a/libc/string/memcpy.c b/libc/string/memcpy.c
index dc2986778..42436e0b6 100644
--- a/libc/string/memcpy.c
+++ b/libc/string/memcpy.c
@@ -10,26 +10,19 @@
#ifdef WANT_WIDE
# define Wmemcpy wmemcpy
#else
+# undef memcpy
# define Wmemcpy memcpy
#endif
-libc_hidden_proto(Wmemcpy)
-
Wvoid *Wmemcpy(Wvoid * __restrict s1, const Wvoid * __restrict s2, size_t n)
{
register Wchar *r1 = s1;
register const Wchar *r2 = s2;
-#ifdef __BCC__
- while (n--) {
- *r1++ = *r2++;
- }
-#else
while (n) {
*r1++ = *r2++;
--n;
}
-#endif
return s1;
}
diff --git a/libc/string/memmem.c b/libc/string/memmem.c
index 9dcd4c4c0..1b3a0bab6 100644
--- a/libc/string/memmem.c
+++ b/libc/string/memmem.c
@@ -8,7 +8,6 @@
#include "_string.h"
#ifdef __USE_GNU
-/* Experimentally off - libc_hidden_proto(memmem) */
void *memmem(const void *haystack, size_t haystacklen,
const void *needle, size_t needlelen)
{
@@ -38,5 +37,4 @@ void *memmem(const void *haystack, size_t haystacklen,
return NULL;
}
-libc_hidden_def(memmem)
#endif
diff --git a/libc/string/memmove.c b/libc/string/memmove.c
index 0bea9b497..b768b6ea9 100644
--- a/libc/string/memmove.c
+++ b/libc/string/memmove.c
@@ -10,30 +10,11 @@
#ifdef WANT_WIDE
# define Wmemmove wmemmove
#else
-/* Experimentally off - libc_hidden_proto(memmove) */
# define Wmemmove memmove
#endif
Wvoid *Wmemmove(Wvoid *s1, const Wvoid *s2, size_t n)
{
-#ifdef __BCC__
- register Wchar *s = (Wchar *) s1;
- register const Wchar *p = (const Wchar *) s2;
-
- if (p >= s) {
- while (n--) {
- *s++ = *p++;
- }
- } else {
- s += n;
- p += n;
- while (n--) {
- *--s = *--p;
- }
- }
-
- return s1;
-#else
register Wchar *s = (Wchar *) s1;
register const Wchar *p = (const Wchar *) s2;
@@ -50,9 +31,8 @@ Wvoid *Wmemmove(Wvoid *s1, const Wvoid *s2, size_t n)
}
return s1;
-#endif
}
#ifndef WANT_WIDE
-libc_hidden_def(Wmemmove)
+libc_hidden_def(memmove)
#endif
diff --git a/libc/string/mempcpy.c b/libc/string/mempcpy.c
index 91896434b..d1d752b50 100644
--- a/libc/string/mempcpy.c
+++ b/libc/string/mempcpy.c
@@ -12,26 +12,19 @@
#ifdef WANT_WIDE
# define Wmempcpy wmempcpy
#else
+# undef mempcpy
# define Wmempcpy mempcpy
#endif
-libc_hidden_proto(Wmempcpy)
-
Wvoid *Wmempcpy(Wvoid * __restrict s1, const Wvoid * __restrict s2, size_t n)
{
register Wchar *r1 = s1;
register const Wchar *r2 = s2;
-#ifdef __BCC__
- while (n--) {
- *r1++ = *r2++;
- }
-#else
while (n) {
*r1++ = *r2++;
--n;
}
-#endif
return r1;
}
diff --git a/libc/string/memrchr.c b/libc/string/memrchr.c
index 48ec50a4e..60211f804 100644
--- a/libc/string/memrchr.c
+++ b/libc/string/memrchr.c
@@ -8,31 +8,21 @@
#include "_string.h"
#ifdef __USE_GNU
-
-/* Experimentally off - libc_hidden_proto(memrchr) */
-
void *memrchr(const void *s, int c, size_t n)
{
register const unsigned char *r;
-#ifdef __BCC__
- /* bcc can optimize the counter if it thinks it is a pointer... */
- register const char *np = (const char *) n;
-#else
-#define np n
-#endif
- r = ((unsigned char *)s) + ((size_t) np);
+ r = ((unsigned char *)s) + ((size_t) n);
- while (np) {
+ while (n) {
if (*--r == ((unsigned char)c)) {
return (void *) r; /* silence the warning */
}
- --np;
+ --n;
}
return NULL;
}
-#undef np
libc_hidden_def(memrchr)
#endif
diff --git a/libc/string/memset.c b/libc/string/memset.c
index 6dd20d668..2a7c19dee 100644
--- a/libc/string/memset.c
+++ b/libc/string/memset.c
@@ -10,28 +10,21 @@
#ifdef WANT_WIDE
# define Wmemset wmemset
#else
-/* Experimentally off - libc_hidden_proto(memset) */
+# undef memset
# define Wmemset memset
#endif
Wvoid *Wmemset(Wvoid *s, Wint c, size_t n)
{
register Wuchar *p = (Wuchar *) s;
-#ifdef __BCC__
- /* bcc can optimize the counter if it thinks it is a pointer... */
- register const char *np = (const char *) n;
-#else
-# define np n
-#endif
- while (np) {
+ while (n) {
*p++ = (Wuchar) c;
- --np;
+ --n;
}
return s;
}
-#undef np
#ifndef WANT_WIDE
libc_hidden_def(memset)
diff --git a/libc/string/metag/Makefile b/libc/string/metag/Makefile
new file mode 100644
index 000000000..523cf6842
--- /dev/null
+++ b/libc/string/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.in
+include $(top_srcdir)Makerules
diff --git a/libc/string/metag/memchr.S b/libc/string/metag/memchr.S
new file mode 100644
index 000000000..8b48d863c
--- /dev/null
+++ b/libc/string/metag/memchr.S
@@ -0,0 +1,156 @@
+! Copyright (C) 2013 Imagination Technologies Ltd.
+!
+! Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+
+ .text
+ .global _memchr
+ .type _memchr,function
+! D0Ar6 src
+! D0Ar2 c
+! D1Ar3 n
+_memchr:
+ CMP D1Ar3, #0
+ BEQ $Lexit_fail
+ !! convert c to unsigned char
+ AND D0Ar2,D0Ar2,#0xff
+ MOV D0Ar6, D1Ar1
+ MOV D1Ar5, D0Ar6
+ !! test alignment
+ AND D1Ar5, D1Ar5, #7
+ CMP D1Ar5, #0
+ BNZ $Lunaligned_loop
+ !! length must be greater than or equal to 8 for aligned loop
+ CMP D1Ar3, #8
+ BGE $Laligned_setup
+$Lunaligned_loop:
+ !! get 1 char from s
+ GETB D0Re0, [D0Ar6++]
+ !! increase alignment counter
+ ADD D1Ar5, D1Ar5, #1
+ !! decrement n
+ SUB D1Ar3, D1Ar3, #1
+ !! exit if we have a match
+ CMP D0Re0, D0Ar2
+ BZ $Lexit_success1
+ !! exit if we have hit the end of the string
+ CMP D1Ar3, #0
+ BZ $Lexit_fail
+ !! fall through if the buffer is aligned now
+ CMP D1Ar5, #8
+ BNE $Lunaligned_loop
+ !! fall through if there is more than 8 bytes left
+ CMP D1Ar3, #8
+ BLT $Lunaligned_loop
+$Laligned_setup:
+ !! fill the c into 4 bytes
+ MOV D0Ar4, D0Ar2
+ LSL D0Ar4, D0Ar4, #8
+ ADD D0Ar4, D0Ar4, D0Ar2
+ LSL D0Ar4, D0Ar4, #8
+ ADD D0Ar4, D0Ar4, D0Ar2
+ LSL D0Ar4, D0Ar4, #8
+ ADD D0Ar4, D0Ar4, D0Ar2
+ !! divide n by 8
+ MOV D1Ar5, D1Ar3
+ LSR D1Ar5, D1Ar5, #3
+$Laligned_loop:
+ !! get 8 chars from s
+ GETL D0Re0, D1Re0, [D0Ar6++]
+ !! decrement loop counter
+ SUB D1Ar5, D1Ar5, #1
+ !! test first 4 chars
+ XOR D0Re0, D0Re0, D0Ar4
+ !! test second 4 chars
+ MOV D0Ar2, D1Re0
+ XOR D1Re0, D0Ar2, D0Ar4
+ !! check for matches in the first 4 chars
+ MOV D0Ar2, D0Re0
+ ADDT D0Re0, D0Re0, #HI(0xfefefeff)
+ ADD D0Re0, D0Re0, #LO(0xfefefeff)
+ XOR D0Ar2, D0Ar2, #-1
+ AND D0Re0, D0Re0, D0Ar2
+ ANDMT D0Re0, D0Re0, #HI(0x80808080)
+ ANDMB D0Re0, D0Re0, #LO(0x80808080)
+ CMP D0Re0, #0
+ BNZ $Lmatch_word1
+ !! check for matches in the second 4 chars
+ MOV D1Ar1, D1Re0
+ ADDT D1Re0, D1Re0, #HI(0xfefefeff)
+ ADD D1Re0, D1Re0, #LO(0xfefefeff)
+ XOR D1Ar1, D1Ar1, #-1
+ AND D1Re0, D1Re0, D1Ar1
+ ANDMT D1Re0, D1Re0, #HI(0x80808080)
+ ANDMB D1Re0, D1Re0, #LO(0x80808080)
+ CMP D1Re0, #0
+ BNZ $Lmatch_word2
+ !! check if we have reached the end of the buffer
+ CMP D1Ar5, #0
+ BNE $Laligned_loop
+ !! exit if there are no chars left to check
+ AND D1Ar3, D1Ar3, #7
+ CMP D1Ar3, #0
+ BZ $Lexit_fail
+ !! recover c
+ AND D0Ar2, D0Ar4, #0xff
+$Lbyte_loop:
+ !! get 1 char from s
+ GETB D0Re0, [D0Ar6++]
+ !! decrement n
+ SUB D1Ar3, D1Ar3, #1
+ !! exit if we have a match
+ CMP D0Re0, D0Ar2
+ BZ $Lexit_success1
+ !! fall through if we have run out of chars
+ CMP D1Ar3, #0
+ BNE $Lbyte_loop
+
+$Lexit_fail:
+ MOV D0Re0, #0
+ B $Lend
+
+$Lmatch_word1:
+ !! move the match word into D1Re0
+ MOV D1Re0, D0Re0
+ !! roll back the buffer pointer by 4 chars
+ SUB D0Ar6, D0Ar6, #4
+$Lmatch_word2:
+ !! roll back the buffer pointer by 4 chars
+ SUB D0Ar6, D0Ar6, #4
+ !! exit if lowest byte is 0
+ MOV D1Ar1, D1Re0
+ AND D1Ar1, D1Ar1, #0xff
+ CMP D1Ar1, #0
+ BNE $Lexit_success2
+ !! advance buffer pointer to the next char
+ ADD D0Ar6, D0Ar6, #1
+ !! shift in the next lowest byte
+ LSR D1Re0, D1Re0, #8
+ !! exit if lowest byte is 0
+ MOV D1Ar1, D1Re0
+ AND D1Ar1, D1Ar1, #0xff
+ CMP D1Ar1, #0
+ BNE $Lexit_success2
+ !! advance buffer pointer to the next char
+ ADD D0Ar6, D0Ar6, #1
+ !! shift in the next lowest byte
+ LSR D1Re0, D1Re0, #8
+ !! exit if lowest byte is 0
+ MOV D1Ar1, D1Re0
+ AND D1Ar1, D1Ar1, #0xff
+ CMP D1Ar1, #0
+ BNE $Lexit_success2
+ !! the match must be in the last byte, exit
+ ADD D0Ar6, D0Ar6, #1
+ B $Lexit_success2
+
+$Lexit_success1:
+ SUB D0Ar6, D0Ar6, #1
+$Lexit_success2:
+ !! return the buffer pointer
+ MOV D0Re0, D0Ar6
+$Lend:
+ MOV PC, D1RtP
+
+ .size _memchr,.-_memchr
+
+libc_hidden_def(memchr)
diff --git a/libc/string/metag/memcpy.S b/libc/string/metag/memcpy.S
new file mode 100644
index 000000000..f96c9d131
--- /dev/null
+++ b/libc/string/metag/memcpy.S
@@ -0,0 +1,189 @@
+! Copyright (C) 2013 Imagination Technologies Ltd.
+
+! Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+
+ .text
+ .global _memcpy
+ .type _memcpy,function
+! D1Ar1 dst
+! D0Ar2 src
+! D1Ar3 cnt
+! D0Re0 dst
+_memcpy:
+ CMP D1Ar3, #16
+ MOV A1.2, D0Ar2 ! source pointer
+ MOV A0.2, D1Ar1 ! destination pointer
+ MOV A0.3, D1Ar1 ! for return value
+! If there are less than 16 bytes to copy use the byte copy loop
+ BGE $Llong_copy
+
+$Lbyte_copy:
+! Simply copy a byte at a time
+ SUBS TXRPT, D1Ar3, #1
+ BLT $Lend
+$Lloop_byte:
+ GETB D1Re0, [A1.2++]
+ SETB [A0.2++], D1Re0
+ BR $Lloop_byte
+
+$Lend:
+! Finally set return value and return
+ MOV D0Re0, A0.3
+ MOV PC, D1RtP
+
+$Llong_copy:
+ ANDS D1Ar5, D1Ar1, #7 ! test destination alignment
+ BZ $Laligned_dst
+
+! The destination address is not 8 byte aligned. We will copy bytes from
+! the source to the destination until the remaining data has an 8 byte
+! destination address alignment (i.e we should never copy more than 7
+! bytes here).
+$Lalign_dst:
+ GETB D0Re0, [A1.2++]
+ ADD D1Ar5, D1Ar5, #1 ! dest is aligned when D1Ar5 reaches #8
+ SUB D1Ar3, D1Ar3, #1 ! decrement count of remaining bytes
+ SETB [A0.2++], D0Re0
+ CMP D1Ar5, #8
+ BNE $Lalign_dst
+
+! We have at least (16 - 7) = 9 bytes to copy - calculate the number of 8 byte
+! blocks, then jump to the unaligned copy loop or fall through to the aligned
+! copy loop as appropriate.
+$Laligned_dst:
+ MOV D0Ar4, A1.2
+ LSR D1Ar5, D1Ar3, #3 ! D1Ar5 = number of 8 byte blocks
+ ANDS D0Ar4, D0Ar4, #7 ! test source alignment
+ BNZ $Lunaligned_copy ! if unaligned, use unaligned copy loop
+
+! Both source and destination are 8 byte aligned - the easy case.
+$Laligned_copy:
+ LSRS D1Ar5, D1Ar3, #5 ! D1Ar5 = number of 32 byte blocks
+ BZ $Lbyte_copy
+ SUB TXRPT, D1Ar5, #1
+
+$Laligned_32:
+ GETL D0Re0, D1Re0, [A1.2++]
+ GETL D0Ar6, D1Ar5, [A1.2++]
+ SETL [A0.2++], D0Re0, D1Re0
+ SETL [A0.2++], D0Ar6, D1Ar5
+ GETL D0Re0, D1Re0, [A1.2++]
+ GETL D0Ar6, D1Ar5, [A1.2++]
+ SETL [A0.2++], D0Re0, D1Re0
+ SETL [A0.2++], D0Ar6, D1Ar5
+ BR $Laligned_32
+
+! If there are any remaining bytes use the byte copy loop, otherwise we are done
+ ANDS D1Ar3, D1Ar3, #0x1f
+ BNZ $Lbyte_copy
+ B $Lend
+
+! The destination is 8 byte aligned but the source is not, and there are 8
+! or more bytes to be copied.
+$Lunaligned_copy:
+! Adjust the source pointer (A1.2) to the 8 byte boundary before its
+! current value
+ MOV D0Ar4, A1.2
+ MOV D0Ar6, A1.2
+ ANDMB D0Ar4, D0Ar4, #0xfff8
+ MOV A1.2, D0Ar4
+! Save the number of bytes of mis-alignment in D0Ar4 for use later
+ SUBS D0Ar6, D0Ar6, D0Ar4
+ MOV D0Ar4, D0Ar6
+! if there is no mis-alignment after all, use the aligned copy loop
+ BZ $Laligned_copy
+
+! prefetch 8 bytes
+ GETL D0Re0, D1Re0, [A1.2]
+
+ SUB TXRPT, D1Ar5, #1
+
+! There are 3 mis-alignment cases to be considered. Less than 4 bytes, exactly
+! 4 bytes, and more than 4 bytes.
+ CMP D0Ar6, #4
+ BLT $Lunaligned_1_2_3 ! use 1-3 byte mis-alignment loop
+ BZ $Lunaligned_4 ! use 4 byte mis-alignment loop
+
+! The mis-alignment is more than 4 bytes
+$Lunaligned_5_6_7:
+ SUB D0Ar6, D0Ar6, #4
+! Calculate the bit offsets required for the shift operations necesssary
+! to align the data.
+! D0Ar6 = bit offset, D1Ar5 = (32 - bit offset)
+ MULW D0Ar6, D0Ar6, #8
+ MOV D1Ar5, #32
+ SUB D1Ar5, D1Ar5, D0Ar6
+! Move data 4 bytes before we enter the main loop
+ MOV D0Re0, D1Re0
+
+$Lloop_5_6_7:
+ GETL D0Ar2, D1Ar1, [++A1.2]
+! form 64-bit data in D0Re0, D1Re0
+ LSR D0Re0, D0Re0, D0Ar6
+ MOV D1Re0, D0Ar2
+ LSL D1Re0, D1Re0, D1Ar5
+ ADD D0Re0, D0Re0, D1Re0
+
+ LSR D0Ar2, D0Ar2, D0Ar6
+ LSL D1Re0, D1Ar1, D1Ar5
+ ADD D1Re0, D1Re0, D0Ar2
+
+ SETL [A0.2++], D0Re0, D1Re0
+ MOV D0Re0, D1Ar1
+ BR $Lloop_5_6_7
+
+ B $Lunaligned_end
+
+$Lunaligned_1_2_3:
+! Calculate the bit offsets required for the shift operations necesssary
+! to align the data.
+! D0Ar6 = bit offset, D1Ar5 = (32 - bit offset)
+ MULW D0Ar6, D0Ar6, #8
+ MOV D1Ar5, #32
+ SUB D1Ar5, D1Ar5, D0Ar6
+
+$Lloop_1_2_3:
+! form 64-bit data in D0Re0,D1Re0
+ LSR D0Re0, D0Re0, D0Ar6
+ LSL D1Ar1, D1Re0, D1Ar5
+ ADD D0Re0, D0Re0, D1Ar1
+ MOV D0Ar2, D1Re0
+ LSR D0FrT, D0Ar2, D0Ar6
+ GETL D0Ar2, D1Ar1, [++A1.2]
+
+ MOV D1Re0, D0Ar2
+ LSL D1Re0, D1Re0, D1Ar5
+ ADD D1Re0, D1Re0, D0FrT
+
+ SETL [A0.2++], D0Re0, D1Re0
+ MOV D0Re0, D0Ar2
+ MOV D1Re0, D1Ar1
+ BR $Lloop_1_2_3
+
+ B $Lunaligned_end
+
+! The 4 byte mis-alignment case - this does not require any shifting, just a
+! shuffling of registers.
+$Lunaligned_4:
+ MOV D0Re0, D1Re0
+$Lloop_4:
+ GETL D0Ar2, D1Ar1, [++A1.2]
+ MOV D1Re0, D0Ar2
+ SETL [A0.2++], D0Re0, D1Re0
+ MOV D0Re0, D1Ar1
+ BR $Lloop_4
+
+$Lunaligned_end:
+! If there are no remaining bytes to copy, we are done.
+ ANDS D1Ar3, D1Ar3, #7
+ BZ $Lend
+! Re-adjust the source pointer (A1.2) back to the actual (unaligned) byte
+! address of the remaining bytes, and fall through to the byte copy loop.
+ MOV D0Ar6, A1.2
+ ADD D1Ar5, D0Ar4, D0Ar6
+ MOV A1.2, D1Ar5
+ B $Lbyte_copy
+
+ .size _memcpy,.-_memcpy
+
+libc_hidden_def(memcpy)
diff --git a/libc/string/metag/memmove.S b/libc/string/metag/memmove.S
new file mode 100644
index 000000000..3416fd558
--- /dev/null
+++ b/libc/string/metag/memmove.S
@@ -0,0 +1,350 @@
+! Copyright (C) 2013 Imagination Technologies Ltd.
+
+! Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+
+
+ .text
+ .global _memmove
+ .type _memmove,function
+! D1Ar1 dst
+! D0Ar2 src
+! D1Ar3 cnt
+! D0Re0 dst
+_memmove:
+ CMP D1Ar3, #0
+ MOV D0Re0, D1Ar1
+ BZ $LEND2
+ MSETL [A0StP], D0.5, D0.6, D0.7
+ MOV D1Ar5, D0Ar2
+ CMP D1Ar1, D1Ar5
+ BLT $Lforwards_copy
+ SUB D0Ar4, D1Ar1, D1Ar3
+ ADD D0Ar4, D0Ar4, #1
+ CMP D0Ar2, D0Ar4
+ BLT $Lforwards_copy
+ ! should copy backwards
+ MOV D1Re0, D0Ar2
+ ! adjust pointer to the end of mem
+ ADD D0Ar2, D1Re0, D1Ar3
+ ADD D1Ar1, D1Ar1, D1Ar3
+
+ MOV A1.2, D0Ar2
+ MOV A0.2, D1Ar1
+ CMP D1Ar3, #8
+ BLT $Lbbyte_loop
+
+ MOV D0Ar4, D0Ar2
+ MOV D1Ar5, D1Ar1
+
+ ! test 8 byte alignment
+ ANDS D1Ar5, D1Ar5, #7
+ BNE $Lbdest_unaligned
+
+ ANDS D0Ar4, D0Ar4, #7
+ BNE $Lbsrc_unaligned
+
+ LSR D1Ar5, D1Ar3, #3
+
+$Lbaligned_loop:
+ GETL D0Re0, D1Re0, [--A1.2]
+ SETL [--A0.2], D0Re0, D1Re0
+ SUBS D1Ar5, D1Ar5, #1
+ BNE $Lbaligned_loop
+
+ ANDS D1Ar3, D1Ar3, #7
+ BZ $Lbbyte_loop_exit
+$Lbbyte_loop:
+ GETB D1Re0, [--A1.2]
+ SETB [--A0.2], D1Re0
+ SUBS D1Ar3, D1Ar3, #1
+ BNE $Lbbyte_loop
+$Lbbyte_loop_exit:
+ MOV D0Re0, A0.2
+$LEND:
+ SUB A0.2, A0StP, #24
+ MGETL D0.5, D0.6, D0.7, [A0.2]
+ SUB A0StP, A0StP, #24
+$LEND2:
+ MOV PC, D1RtP
+
+$Lbdest_unaligned:
+ GETB D0Re0, [--A1.2]
+ SETB [--A0.2], D0Re0
+ SUBS D1Ar5, D1Ar5, #1
+ SUB D1Ar3, D1Ar3, #1
+ BNE $Lbdest_unaligned
+ CMP D1Ar3, #8
+ BLT $Lbbyte_loop
+$Lbsrc_unaligned:
+ LSR D1Ar5, D1Ar3, #3
+ ! adjust A1.2
+ MOV D0Ar4, A1.2
+ ! save original address
+ MOV D0Ar6, A1.2
+
+ ADD D0Ar4, D0Ar4, #7
+ ANDMB D0Ar4, D0Ar4, #0xfff8
+ ! new address is the 8-byte aligned one above the original
+ MOV A1.2, D0Ar4
+
+ ! A0.2 dst 64-bit is aligned
+ ! measure the gap size
+ SUB D0Ar6, D0Ar4, D0Ar6
+ MOVS D0Ar4, D0Ar6
+ ! keep this information for the later adjustment
+ ! both aligned
+ BZ $Lbaligned_loop
+
+ ! prefetch
+ GETL D0Re0, D1Re0, [--A1.2]
+
+ CMP D0Ar6, #4
+ BLT $Lbunaligned_1_2_3
+ ! 32-bit aligned
+ BZ $Lbaligned_4
+
+ SUB D0Ar6, D0Ar6, #4
+ ! D1.6 stores the gap size in bits
+ MULW D1.6, D0Ar6, #8
+ MOV D0.6, #32
+ ! D0.6 stores the complement of the gap size
+ SUB D0.6, D0.6, D1.6
+
+$Lbunaligned_5_6_7:
+ GETL D0.7, D1.7, [--A1.2]
+ ! form 64-bit data in D0Re0, D1Re0
+ MOV D1Re0, D0Re0
+ ! D1Re0 << gap-size
+ LSL D1Re0, D1Re0, D1.6
+ MOV D0Re0, D1.7
+ ! D0Re0 >> complement
+ LSR D0Re0, D0Re0, D0.6
+ MOV D1.5, D0Re0
+ ! combine the both
+ ADD D1Re0, D1Re0, D1.5
+
+ MOV D1.5, D1.7
+ LSL D1.5, D1.5, D1.6
+ MOV D0Re0, D0.7
+ LSR D0Re0, D0Re0, D0.6
+ MOV D0.5, D1.5
+ ADD D0Re0, D0Re0, D0.5
+
+ SETL [--A0.2], D0Re0, D1Re0
+ MOV D0Re0, D0.7
+ MOV D1Re0, D1.7
+ SUBS D1Ar5, D1Ar5, #1
+ BNE $Lbunaligned_5_6_7
+
+ ANDS D1Ar3, D1Ar3, #7
+ BZ $Lbbyte_loop_exit
+ ! Adjust A1.2
+ ! A1.2 <- A1.2 +8 - gapsize
+ ADD A1.2, A1.2, #8
+ SUB A1.2, A1.2, D0Ar4
+ B $Lbbyte_loop
+
+$Lbunaligned_1_2_3:
+ MULW D1.6, D0Ar6, #8
+ MOV D0.6, #32
+ SUB D0.6, D0.6, D1.6
+
+$Lbunaligned_1_2_3_loop:
+ GETL D0.7, D1.7, [--A1.2]
+ ! form 64-bit data in D0Re0, D1Re0
+ LSL D1Re0, D1Re0, D1.6
+ ! save D0Re0 for later use
+ MOV D0.5, D0Re0
+ LSR D0Re0, D0Re0, D0.6
+ MOV D1.5, D0Re0
+ ADD D1Re0, D1Re0, D1.5
+
+ ! orignal data in D0Re0
+ MOV D1.5, D0.5
+ LSL D1.5, D1.5, D1.6
+ MOV D0Re0, D1.7
+ LSR D0Re0, D0Re0, D0.6
+ MOV D0.5, D1.5
+ ADD D0Re0, D0Re0, D0.5
+
+ SETL [--A0.2], D0Re0, D1Re0
+ MOV D0Re0, D0.7
+ MOV D1Re0, D1.7
+ SUBS D1Ar5, D1Ar5, #1
+ BNE $Lbunaligned_1_2_3_loop
+
+ ANDS D1Ar3, D1Ar3, #7
+ BZ $Lbbyte_loop_exit
+ ! Adjust A1.2
+ ADD A1.2, A1.2, #8
+ SUB A1.2, A1.2, D0Ar4
+ B $Lbbyte_loop
+
+$Lbaligned_4:
+ GETL D0.7, D1.7, [--A1.2]
+ MOV D1Re0, D0Re0
+ MOV D0Re0, D1.7
+ SETL [--A0.2], D0Re0, D1Re0
+ MOV D0Re0, D0.7
+ MOV D1Re0, D1.7
+ SUBS D1Ar5, D1Ar5, #1
+ BNE $Lbaligned_4
+ ANDS D1Ar3, D1Ar3, #7
+ BZ $Lbbyte_loop_exit
+ ! Adjust A1.2
+ ADD A1.2, A1.2, #8
+ SUB A1.2, A1.2, D0Ar4
+ B $Lbbyte_loop
+
+$Lforwards_copy:
+ MOV A1.2, D0Ar2
+ MOV A0.2, D1Ar1
+ CMP D1Ar3, #8
+ BLT $Lfbyte_loop
+
+ MOV D0Ar4, D0Ar2
+ MOV D1Ar5, D1Ar1
+
+ ANDS D1Ar5, D1Ar5, #7
+ BNE $Lfdest_unaligned
+
+ ANDS D0Ar4, D0Ar4, #7
+ BNE $Lfsrc_unaligned
+
+ LSR D1Ar5, D1Ar3, #3
+
+$Lfaligned_loop:
+ GETL D0Re0, D1Re0, [A1.2++]
+ SUBS D1Ar5, D1Ar5, #1
+ SETL [A0.2++], D0Re0, D1Re0
+ BNE $Lfaligned_loop
+
+ ANDS D1Ar3, D1Ar3, #7
+ BZ $Lfbyte_loop_exit
+$Lfbyte_loop:
+ GETB D1Re0, [A1.2++]
+ SETB [A0.2++], D1Re0
+ SUBS D1Ar3, D1Ar3, #1
+ BNE $Lfbyte_loop
+$Lfbyte_loop_exit:
+ MOV D0Re0, D1Ar1
+ B $LEND
+
+$Lfdest_unaligned:
+ GETB D0Re0, [A1.2++]
+ ADD D1Ar5, D1Ar5, #1
+ SUB D1Ar3, D1Ar3, #1
+ SETB [A0.2++], D0Re0
+ CMP D1Ar5, #8
+ BNE $Lfdest_unaligned
+ CMP D1Ar3, #8
+ BLT $Lfbyte_loop
+$Lfsrc_unaligned:
+ ! adjust A1.2
+ LSR D1Ar5, D1Ar3, #3
+
+ MOV D0Ar4, A1.2
+ MOV D0Ar6, A1.2
+ ANDMB D0Ar4, D0Ar4, #0xfff8
+ MOV A1.2, D0Ar4
+
+ ! A0.2 dst 64-bit is aligned
+ SUB D0Ar6, D0Ar6, D0Ar4
+ ! keep the information for the later adjustment
+ MOVS D0Ar4, D0Ar6
+
+ ! both aligned
+ BZ $Lfaligned_loop
+
+ ! prefetch
+ GETL D0Re0, D1Re0, [A1.2]
+
+ CMP D0Ar6, #4
+ BLT $Lfunaligned_1_2_3
+ BZ $Lfaligned_4
+
+ SUB D0Ar6, D0Ar6, #4
+ MULW D0.6, D0Ar6, #8
+ MOV D1.6, #32
+ SUB D1.6, D1.6, D0.6
+
+$Lfunaligned_5_6_7:
+ GETL D0.7, D1.7, [++A1.2]
+ ! form 64-bit data in D0Re0, D1Re0
+ MOV D0Re0, D1Re0
+ LSR D0Re0, D0Re0, D0.6
+ MOV D1Re0, D0.7
+ LSL D1Re0, D1Re0, D1.6
+ MOV D0.5, D1Re0
+ ADD D0Re0, D0Re0, D0.5
+
+ MOV D0.5, D0.7
+ LSR D0.5, D0.5, D0.6
+ MOV D1Re0, D1.7
+ LSL D1Re0, D1Re0, D1.6
+ MOV D1.5, D0.5
+ ADD D1Re0, D1Re0, D1.5
+
+ SETL [A0.2++], D0Re0, D1Re0
+ MOV D0Re0, D0.7
+ MOV D1Re0, D1.7
+ SUBS D1Ar5, D1Ar5, #1
+ BNE $Lfunaligned_5_6_7
+
+ ANDS D1Ar3, D1Ar3, #7
+ BZ $Lfbyte_loop_exit
+ ! Adjust A1.2
+ ADD A1.2, A1.2, D0Ar4
+ B $Lfbyte_loop
+
+$Lfunaligned_1_2_3:
+ MULW D0.6, D0Ar6, #8
+ MOV D1.6, #32
+ SUB D1.6, D1.6, D0.6
+
+$Lfunaligned_1_2_3_loop:
+ GETL D0.7, D1.7, [++A1.2]
+ ! form 64-bit data in D0Re0, D1Re0
+ LSR D0Re0, D0Re0, D0.6
+ MOV D1.5, D1Re0
+ LSL D1Re0, D1Re0, D1.6
+ MOV D0.5, D1Re0
+ ADD D0Re0, D0Re0, D0.5
+
+ MOV D0.5, D1.5
+ LSR D0.5, D0.5, D0.6
+ MOV D1Re0, D0.7
+ LSL D1Re0, D1Re0, D1.6
+ MOV D1.5, D0.5
+ ADD D1Re0, D1Re0, D1.5
+
+ SETL [A0.2++], D0Re0, D1Re0
+ MOV D0Re0, D0.7
+ MOV D1Re0, D1.7
+ SUBS D1Ar5, D1Ar5, #1
+ BNE $Lfunaligned_1_2_3_loop
+
+ ANDS D1Ar3, D1Ar3, #7
+ BZ $Lfbyte_loop_exit
+ ! Adjust A1.2
+ ADD A1.2, A1.2, D0Ar4
+ B $Lfbyte_loop
+
+$Lfaligned_4:
+ GETL D0.7, D1.7, [++A1.2]
+ MOV D0Re0, D1Re0
+ MOV D1Re0, D0.7
+ SETL [A0.2++], D0Re0, D1Re0
+ MOV D0Re0, D0.7
+ MOV D1Re0, D1.7
+ SUBS D1Ar5, D1Ar5, #1
+ BNE $Lfaligned_4
+ ANDS D1Ar3, D1Ar3, #7
+ BZ $Lfbyte_loop_exit
+ ! Adjust A1.2
+ ADD A1.2, A1.2, D0Ar4
+ B $Lfbyte_loop
+
+ .size _memmove,.-_memmove
+
+libc_hidden_def(memmove)
diff --git a/libc/string/metag/memset.S b/libc/string/metag/memset.S
new file mode 100644
index 000000000..8d4e9a158
--- /dev/null
+++ b/libc/string/metag/memset.S
@@ -0,0 +1,90 @@
+! Copyright (C) 2013 Imagination Technologies Ltd.
+
+! Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+
+
+ .text
+ .global _memset
+ .type _memset,function
+! D1Ar1 dst
+! D0Ar2 c
+! D1Ar3 cnt
+! D0Re0 dst
+_memset:
+ AND D0Ar2,D0Ar2,#0xFF ! Ensure a byte input value
+ MULW D0Ar2,D0Ar2,#0x0101 ! Duplicate byte value into 0-15
+ ANDS D0Ar4,D1Ar1,#7 ! Extract bottom LSBs of dst
+ LSL D0Re0,D0Ar2,#16 ! Duplicate byte value into 16-31
+ ADD A0.2,D0Ar2,D0Re0 ! Duplicate byte value into 4 (A0.2)
+ MOV D0Re0,D1Ar1 ! Return dst
+ BZ $LLongStub ! if start address is aligned
+ ! start address is not aligned on an 8 byte boundary, so we
+ ! need the number of bytes up to the next 8 byte address
+ ! boundary, or the length of the string if less than 8, in D1Ar5
+ MOV D0Ar2,#8 ! Need 8 - N in D1Ar5 ...
+ SUB D1Ar5,D0Ar2,D0Ar4 ! ... subtract N
+ CMP D1Ar3,D1Ar5
+ MOVMI D1Ar5,D1Ar3
+ B $LByteStub ! dst is mis-aligned, do $LByteStub
+
+!
+! Preamble to LongLoop which generates 4*8 bytes per interation (5 cycles)
+!
+$LLongStub:
+ LSRS D0Ar2,D1Ar3,#5
+ AND D1Ar3,D1Ar3,#0x1F
+ MOV A1.2,A0.2
+ BEQ $LLongishStub
+ SUB TXRPT,D0Ar2,#1
+ CMP D1Ar3,#0
+$LLongLoop:
+ SETL [D1Ar1++],A0.2,A1.2
+ SETL [D1Ar1++],A0.2,A1.2
+ SETL [D1Ar1++],A0.2,A1.2
+ SETL [D1Ar1++],A0.2,A1.2
+ BR $LLongLoop
+ BZ $Lexit
+!
+! Preamble to LongishLoop which generates 1*8 bytes per interation (2 cycles)
+!
+$LLongishStub:
+ LSRS D0Ar2,D1Ar3,#3
+ AND D1Ar3,D1Ar3,#0x7
+ MOV D1Ar5,D1Ar3
+ BEQ $LByteStub
+ SUB TXRPT,D0Ar2,#1
+ CMP D1Ar3,#0
+$LLongishLoop:
+ SETL [D1Ar1++],A0.2,A1.2
+ BR $LLongishLoop
+ BZ $Lexit
+!
+! This does a byte structured burst of up to 7 bytes
+!
+! D1Ar1 should point to the location required
+! D1Ar3 should be the remaining total byte count
+! D1Ar5 should be burst size (<= D1Ar3)
+!
+$LByteStub:
+ SUBS D1Ar3,D1Ar3,D1Ar5 ! Reduce count
+ ADD D1Ar1,D1Ar1,D1Ar5 ! Advance pointer to end of area
+ MULW D1Ar5,D1Ar5,#4 ! Scale to (1*4), (2*4), (3*4)
+ SUB D1Ar5,D1Ar5,#(8*4) ! Rebase to -(7*4), -(6*4), -(5*4), ...
+ MOV A1.2,D1Ar5
+ SUB PC,CPC1,A1.2 ! Jump into table below
+ SETB [D1Ar1+#(-7)],A0.2
+ SETB [D1Ar1+#(-6)],A0.2
+ SETB [D1Ar1+#(-5)],A0.2
+ SETB [D1Ar1+#(-4)],A0.2
+ SETB [D1Ar1+#(-3)],A0.2
+ SETB [D1Ar1+#(-2)],A0.2
+ SETB [D1Ar1+#(-1)],A0.2
+!
+! Return if all data has been output, otherwise do $LLongStub
+!
+ BNZ $LLongStub
+$Lexit:
+ MOV PC,D1RtP
+ .size _memset,.-_memset
+
+libc_hidden_def(memset)
diff --git a/libc/string/metag/strchr.S b/libc/string/metag/strchr.S
new file mode 100644
index 000000000..6b0f2ea43
--- /dev/null
+++ b/libc/string/metag/strchr.S
@@ -0,0 +1,167 @@
+! Copyright (C) 2013 Imagination Technologies Ltd.
+
+! Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+
+
+#include <features.h>
+
+ .text
+ .global _strchr
+ .type _strchr, function
+! D1Ar1 src
+! D0Ar2 c
+_strchr:
+ AND D0Ar2,D0Ar2,#0xff ! Drop all but 8 bits of c
+ MOV D1Ar5, D1Ar1 ! Copy src to D1Ar5
+ AND D1Ar5, D1Ar5, #7 ! Check 64 bit alignment
+ CMP D1Ar5, #0
+ BZ $Laligned64bit ! Jump to 64 bit aligned strchr
+$Lalign64bit:
+ GETB D0Re0, [D1Ar1++] ! Get the next character
+ ADD D1Ar5, D1Ar5, #1 ! Increment alignment counter
+ CMP D0Re0, D0Ar2 ! Is the char c
+ BZ $Lcharatprevious ! If so exit returning position
+ CMP D0Re0, #0 ! End of string?
+ BZ $Lnotfound ! If so exit
+ CMP D1Ar5, #8 ! Are we aligned 64bit yet?
+ BNZ $Lalign64bit ! If not keep aligning
+$Laligned64bit: ! src is 64bit aligned
+ MOV D0Ar4, D0Ar2 ! put c into D0Ar4
+ LSL D0Ar4, D0Ar4, #8 ! Shift it up
+ ADD D0Ar4, D0Ar4, D0Ar2 ! another c
+ LSL D0Ar4, D0Ar4, #8 ! shift
+ ADD D0Ar4, D0Ar4, D0Ar2 ! another c
+ LSL D0Ar4, D0Ar4, #8 ! shift
+ ADD D0Ar4, D0Ar4, D0Ar2 ! 4 copies of c
+$Lcheck8bytes:
+ GETL D0Re0, D1Re0, [D1Ar1++] ! grab 16 bytes
+ MOV A0.3, D0Re0 ! save for later use
+ ! first word
+ ! check for \0
+ MOV D0Ar2, D0Re0 ! D0Ar2 is a scratch now
+ ADDT D0Re0, D0Re0, #HI(0xfefefeff) ! Do 4 1-byte compares
+ ADD D0Re0, D0Re0, #LO(0xfefefeff)
+ XOR D0Ar2, D0Ar2, #-1
+ AND D0Re0, D0Re0, D0Ar2
+ ANDMT D0Re0, D0Re0, #HI(0x80808080)
+ ANDMB D0Re0, D0Re0, #LO(0x80808080)
+ CMP D0Re0, #0
+ BNZ $Lnullinword1 ! found \0 (or c if c==\0)
+
+ ! Check for c
+ MOV D0Re0, A0.3 ! restore the first word
+ XOR D0Re0, D0Re0, D0Ar4
+ MOV D0Ar2, D0Re0 ! DO 4 1-byte compares
+ ADDT D0Re0, D0Re0, #HI(0xfefefeff)
+ ADD D0Re0, D0Re0, #LO(0xfefefeff)
+ XOR D0Ar2, D0Ar2, #-1
+ AND D0Re0, D0Re0, D0Ar2
+ ANDMT D0Re0, D0Re0, #HI(0x80808080)
+ ANDMB D0Re0, D0Re0, #LO(0x80808080)
+ CMP D0Re0, #0
+ BNZ $Lcharinword1 ! found c
+
+ ! second word
+ ! check for \0
+ MOV A0.3, D1Re0 ! save for later use
+ MOV D1Ar3, D1Re0
+ ADDT D1Re0, D1Re0, #HI(0xfefefeff) ! Do 4 1-byte compares
+ ADD D1Re0, D1Re0, #LO(0xfefefeff)
+ XOR D1Ar3, D1Ar3, #-1
+ AND D1Re0, D1Re0, D1Ar3
+ ANDMT D1Re0, D1Re0, #HI(0x80808080)
+ ANDMB D1Re0, D1Re0, #LO(0x80808080)
+ CMP D1Re0, #0
+ BNZ $Lnullinword2 ! Found \0 (or c if c==\0)
+
+ MOV D0.4, A0.3 ! restore the second word
+ XOR D1Re0, D0.4, D0Ar4 ! test c
+
+ MOV D1Ar3, D1Re0
+ ADDT D1Re0, D1Re0, #HI(0xfefefeff) ! Do 4 1-byte compares
+ ADD D1Re0, D1Re0, #LO(0xfefefeff)
+ XOR D1Ar3, D1Ar3, #-1
+ AND D1Re0, D1Re0, D1Ar3
+ ANDMT D1Re0, D1Re0, #HI(0x80808080)
+ ANDMB D1Re0, D1Re0, #LO(0x80808080)
+ CMP D1Re0, #0
+ BNZ $Lcharinword2 ! found c
+
+ B $Lcheck8bytes ! Keep checking
+
+$Lnullinword1: ! found \0 somewhere, check for c too
+ SUB D1Ar1, D1Ar1, #4
+$Lnullinword2:
+ SUB D1Ar1, D1Ar1, #4
+ AND D0Ar2, D0Ar4, #0xff ! restore c
+ MOV D0Re0, A0.3 ! restore the word
+ MOV D0.4, D0Re0 ! for shifting later
+ AND D0Re0, D0Re0, #0xff ! take first byte of word
+ CMP D0Re0, D0Ar2
+ BZ $Lcharatcurrent ! found c
+ CMP D0Re0, #0!
+ BZ $Lnotfound ! found \0
+
+ ADD D1Ar1, D1Ar1, #1
+ LSR D0.4, D0.4, #8
+ MOV D0Re0, D0.4
+ AND D0Re0, D0Re0, #0xff ! take second byte of word
+ CMP D0Re0, D0Ar2
+ BZ $Lcharatcurrent ! found c
+ CMP D0Re0, #0
+ BZ $Lnotfound ! found \0
+
+ ADD D1Ar1, D1Ar1, #1
+ LSR D0.4, D0.4, #8
+ MOV D0Re0, D0.4
+ AND D0Re0, D0Re0, #0xff ! take third byte of word
+ CMP D0Re0, D0Ar2
+ BZ $Lcharatcurrent ! found c
+ CMP D0Re0, #0
+ BZ $Lnotfound ! found \0
+
+ ADD D1Ar1, D1Ar1, #1 ! move to 4th byte
+ CMP D0Ar2, #0 ! If c was \0
+ BZ $Lcharatcurrent ! c has been found!
+
+$Lnotfound:
+ MOV D0Re0, #0 ! End of string c not found
+ B $Lend
+
+$Lcharinword1: ! found c in first word
+ MOV D1Re0, D0Re0
+ SUB D1Ar1, D1Ar1, #4
+$Lcharinword2: ! found c in second word
+ SUB D1Ar1, D1Ar1, #4
+
+ AND D0Re0, D1Re0, #0xff ! First byte
+ CMP D0Re0, #0 ! Test c (zero indicates c due
+ ! to the 4 1-byte compare code)
+ BNE $Lcharatcurrent
+ ADD D1Ar1, D1Ar1, #1
+
+ LSR D1Re0, D1Re0, #8
+ AND D0Re0, D1Re0, #0xff ! Second byte
+ CMP D0Re0, #0 ! Test c (indicated by zero)
+ BNE $Lcharatcurrent
+ ADD D1Ar1, D1Ar1, #1
+
+ LSR D1Re0, D1Re0, #8
+ AND D0Re0, D1Re0, #0xff ! Third byte
+ CMP D0Re0, #0 ! Test c (indicated by zero)
+ BNE $Lcharatcurrent
+ ADD D1Ar1, D1Ar1, #1 ! Must be the fourth byte
+ B $Lcharatcurrent
+
+$Lcharatprevious:
+ SUB D1Ar1, D1Ar1, #1 ! Fix-up pointer
+$Lcharatcurrent:
+ MOV D0Re0, D1Ar1 ! Return the string pointer
+$Lend:
+ MOV PC, D1RtP
+ .size _strchr,.-_strchr
+
+libc_hidden_def(strchr)
+#ifdef __UCLIBC_SUSV3_LEGACY__
+strong_alias(strchr,index)
+#endif
diff --git a/libc/string/metag/strcmp.S b/libc/string/metag/strcmp.S
new file mode 100644
index 000000000..3278ffaa5
--- /dev/null
+++ b/libc/string/metag/strcmp.S
@@ -0,0 +1,65 @@
+! Copyright (C) 2013 Imagination Technologies Ltd.
+
+! Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+
+
+#include <features.h>
+
+ .text
+ .global _strcmp
+ .type _strcmp,function
+!D1Ar1 s1
+!D0Ar2 s2
+_strcmp:
+ TST D1Ar1,#3
+ TSTZ D0Ar2,#3
+ MOVT D1Re0,#0x0101
+ ADD D1Re0,D1Re0,#0x0101
+ BNZ $Lstrcmp_slow
+ GETD D1Ar3,[D1Ar1+#4++] ! Load 32-bits from s1
+ GETD D1Ar5,[D0Ar2+#4++] ! Load 32-bits from s2
+ LSL D0FrT,D1Re0,#7 ! D0FrT = 0x80808080
+$Lstrcmp4_loop:
+ SUB D0Re0,D1Ar3,D1Re0 ! D1Re0 = 0x01010101
+ MOV D0Ar6,D1Ar3
+ SUBS D0Ar4,D1Ar3,D1Ar5 ! Calculate difference
+ XOR D0Ar6,D0Ar6,#-1
+ GETD D1Ar3,[D1Ar1+#4++] ! Load 32-bits from s1
+ AND D0Re0,D0Re0,D0Ar6
+ ANDSZ D0Ar6,D0Re0,D0FrT ! D0FrT = 0x80808080
+ GETD D1Ar5,[D0Ar2+#4++] ! Load 32-bits from s2
+ BZ $Lstrcmp4_loop
+ AND D0Ar6, D0Re0, D0FrT ! D0FrT = 0x80808080
+!
+! Either they are different or they both contain a NULL + junk
+!
+$Lstrcmp4_end:
+ LSLS D0Re0,D0Ar4,#24 ! Was Byte[0] the same?
+ LSLSZ D0Ar2,D0Ar6,#24 ! Yes: AND they where not zero?
+ LSLSZ D0Re0,D0Ar4,#16 ! Yes: Was Byte[1] the same?
+ LSLSZ D0Ar2,D0Ar6,#16 ! Yes: AND they where not zero?
+ LSLSZ D0Re0,D0Ar4,#8 ! Tes: Was Byte[2] the same?
+ LSLSZ D0Ar2,D0Ar6,#8 ! Yes: AND they where not zero?
+ MOVZ D0Re0,D0Ar4 ! Yes: Must by Byte[3] thats the result
+ ASR D0Re0,D0Re0,#24 ! Sign extend result to integer
+ MOV PC,D1RtP
+!
+! Misaligned case, byte at a time
+!
+$Lstrcmp_slow:
+ GETB D1Ar3,[D1Ar1++] ! Load char from s1
+ GETB D1Ar5,[D0Ar2++] ! Load char from s2
+ CMP D1Ar3,#1 ! Null -> C and NZ, rest -> NC (\1->Z)
+ CMPNC D1Ar3,D1Ar5 ! NOT Null: Same -> Z, else -> NZ
+ BZ $Lstrcmp_slow ! NOT Null and Same: Loop
+ SUB D0Re0,D1Ar3,D1Ar5 ! Generate result
+ MOV PC,D1RtP
+
+ .size _strcmp,.-_strcmp
+
+
+libc_hidden_def(strcmp)
+#ifndef __UCLIBC_HAS_LOCALE__
+strong_alias(strcmp,strcoll)
+libc_hidden_def(strcoll)
+#endif
diff --git a/libc/string/metag/strcpy.S b/libc/string/metag/strcpy.S
new file mode 100644
index 000000000..529ac9279
--- /dev/null
+++ b/libc/string/metag/strcpy.S
@@ -0,0 +1,94 @@
+! Copyright (C) 2013 Imagination Technologies Ltd.
+
+! Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+
+
+ .text
+ .global _strcpy
+ .type _strcpy,function
+! D1Ar1 dst
+! D0Ar2 src
+
+_strcpy:
+ MOV A1.2, D1Ar1
+
+ ! test 4 byte alignment of src
+ ANDS D0Ar4, D0Ar2, #3
+ BNZ $Lbyteloop
+
+ ! test 4 byte alignment of dest
+ ANDS D1Ar5, D1Ar1, #3
+ BNZ $Lbyteloop
+
+ ! load mask values for aligned loops
+ MOVT D1Ar3, #HI(0xfefefeff)
+ ADD D1Ar3, D1Ar3, #LO(0xfefefeff)
+ MOVT D0FrT, #HI(0x80808080)
+ ADD D0FrT, D0FrT, #LO(0x80808080)
+
+ ! test 8 byte alignment of src
+ ANDS D0Ar4, D0Ar2, #7
+ BNZ $Lwordloop
+
+ ! test 8 byte alignment of dest
+ ANDS D1Ar5, D1Ar1, #7
+ BNZ $Lwordloop
+
+$L8byteloop:
+ GETL D1Ar5, D0Ar6, [D0Ar2++]
+ MOV D1Re0, D1Ar5
+ MOV D0Re0, D1Ar5
+ ADD D1Re0, D1Re0, D1Ar3
+ XOR D0Re0, D0Re0, #-1
+ AND D1Re0, D1Re0, D0Re0
+ ANDS D1Re0, D1Re0, D0FrT
+ BNZ $Lnullfound ! NULL in first word
+
+ MOV D1Re0, D0Ar6
+ MOV D0Re0, D0Ar6
+ ADD D1Re0, D1Re0, D1Ar3
+ XOR D0Re0, D0Re0, #-1
+ AND D1Re0, D1Re0, D0Re0
+ ANDS D1Re0, D1Re0, D0FrT
+ BNZ $Lnullfound2 ! NULL in the second word
+
+ SETL [A1.2++], D1Ar5, D0Ar6
+ B $L8byteloop
+
+$Lwordloop:
+ GETD D0Ar6, [D0Ar2++]
+ MOV D1Re0, D0Ar6
+ MOV D0Re0, D0Ar6
+ ADD D1Re0, D1Re0, D1Ar3
+ XOR D0Re0, D0Re0, #-1
+ AND D1Re0, D1Re0, D0Re0
+ ANDS D1Re0, D1Re0, D0FrT
+ MOV D1Ar5, D0Ar6
+ BNZ $Lnullfound
+ SETD [A1.2++], D0Ar6
+ B $Lwordloop
+
+$Lnullfound2:
+ SETD [A1.2++], D1Ar5
+ MOV D1Ar5, D0Ar6
+
+$Lnullfound:
+ SETB [A1.2++], D1Ar5
+ ANDS D0Ar6, D1Ar5, #0xff
+ LSR D1Ar5, D1Ar5, #8
+ BNZ $Lnullfound
+ B $Lend
+
+$Lbyteloop:
+ GETB D0Ar6, [D0Ar2++]
+ SETB [A1.2++], D0Ar6
+ CMP D0Ar6, #0
+ BNZ $Lbyteloop
+
+$Lend:
+ MOV D0Re0, D1Ar1
+ MOV PC, D1RtP
+
+ .size _strcpy,.-_strcpy
+
+libc_hidden_def(strcpy)
diff --git a/libc/string/sh64/Makefile b/libc/string/microblaze/Makefile
index 0a95346fd..5bdfef2f7 100644
--- a/libc/string/sh64/Makefile
+++ b/libc/string/microblaze/Makefile
@@ -5,8 +5,8 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-top_srcdir:=../../../
-top_builddir:=../../../
+top_srcdir := ../../../
+top_builddir := ../../../
all: objs
include $(top_builddir)Rules.mak
include ../Makefile.in
diff --git a/libc/string/microblaze/memcpy.S b/libc/string/microblaze/memcpy.S
new file mode 100644
index 000000000..5219e9919
--- /dev/null
+++ b/libc/string/microblaze/memcpy.S
@@ -0,0 +1,334 @@
+/*
+ * Copyright (C) 2008-2009 Michal Simek <monstr@monstr.eu>
+ * Copyright (C) 2008-2009 PetaLogix
+ * Copyright (C) 2008 Jim Law - Iris LP All rights reserved.
+ *
+ * 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.
+ *
+ * Written by Jim Law <jlaw@irispower.com>
+ *
+ * intended to replace:
+ * memcpy in memcpy.c and
+ * memmove in memmove.c
+ * ... in arch/microblaze/lib
+ *
+ *
+ * assly_fastcopy.S
+ *
+ * Attempt at quicker memcpy and memmove for MicroBlaze
+ * Input : Operand1 in Reg r5 - destination address
+ * Operand2 in Reg r6 - source address
+ * Operand3 in Reg r7 - number of bytes to transfer
+ * Output: Result in Reg r3 - starting destinaition address
+ *
+ *
+ * Explanation:
+ * Perform (possibly unaligned) copy of a block of memory
+ * between mem locations with size of xfer spec'd in bytes
+ */
+
+ .text
+ .globl memcpy
+ .type memcpy, @function
+ .ent memcpy
+
+#ifdef __MICROBLAZEEL__
+# define BSLLI bsrli
+# define BSRLI bslli
+#else
+# define BSLLI bslli
+# define BSRLI bsrli
+#endif
+
+memcpy:
+fast_memcpy_ascending:
+ /* move d to return register as value of function */
+ addi r3, r5, 0
+
+ addi r4, r0, 4 /* n = 4 */
+ cmpu r4, r4, r7 /* n = c - n (unsigned) */
+ blti r4, a_xfer_end /* if n < 0, less than one word to transfer */
+
+ /* transfer first 0~3 bytes to get aligned dest address */
+ andi r4, r5, 3 /* n = d & 3 */
+ /* if zero, destination already aligned */
+ beqi r4, a_dalign_done
+ /* n = 4 - n (yields 3, 2, 1 transfers for 1, 2, 3 addr offset) */
+ rsubi r4, r4, 4
+ rsub r7, r4, r7 /* c = c - n adjust c */
+
+a_xfer_first_loop:
+ /* if no bytes left to transfer, transfer the bulk */
+ beqi r4, a_dalign_done
+ lbui r11, r6, 0 /* h = *s */
+ sbi r11, r5, 0 /* *d = h */
+ addi r6, r6, 1 /* s++ */
+ addi r5, r5, 1 /* d++ */
+ brid a_xfer_first_loop /* loop */
+ addi r4, r4, -1 /* n-- (IN DELAY SLOT) */
+
+a_dalign_done:
+ addi r4, r0, 32 /* n = 32 */
+ cmpu r4, r4, r7 /* n = c - n (unsigned) */
+ /* if n < 0, less than one block to transfer */
+ blti r4, a_block_done
+
+a_block_xfer:
+ andi r9, r6, 3 /* t1 = s & 3 */
+ /* if temp == 0, everything is word-aligned */
+ beqi r9, a_word_xfer
+
+a_block_unaligned:
+ andi r4, r7, 0xffffffe0 /* n = c & ~31 */
+ rsub r7, r4, r7 /* c = c - n */
+ andi r8, r6, 0xfffffffc /* as = s & ~3 */
+ add r6, r6, r4 /* s = s + n */
+ lwi r11, r8, 0 /* h = *(as + 0) */
+
+ addi r9, r9, -1
+ beqi r9, a_block_u1 /* t1 was 1 => 1 byte offset */
+ addi r9, r9, -1
+ beqi r9, a_block_u2 /* t1 was 2 => 2 byte offset */
+
+a_block_u3:
+ BSLLI r11, r11, 24 /* h = h << 24 */
+a_bu3_loop:
+ lwi r12, r8, 4 /* v = *(as + 4) */
+ BSRLI r9, r12, 8 /* t1 = v >> 8 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 0 /* *(d + 0) = t1 */
+ BSLLI r11, r12, 24 /* h = v << 24 */
+ lwi r12, r8, 8 /* v = *(as + 8) */
+ BSRLI r9, r12, 8 /* t1 = v >> 8 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 4 /* *(d + 4) = t1 */
+ BSLLI r11, r12, 24 /* h = v << 24 */
+ lwi r12, r8, 12 /* v = *(as + 12) */
+ BSRLI r9, r12, 8 /* t1 = v >> 8 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 8 /* *(d + 8) = t1 */
+ BSLLI r11, r12, 24 /* h = v << 24 */
+ lwi r12, r8, 16 /* v = *(as + 16) */
+ BSRLI r9, r12, 8 /* t1 = v >> 8 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 12 /* *(d + 12) = t1 */
+ BSLLI r11, r12, 24 /* h = v << 24 */
+ lwi r12, r8, 20 /* v = *(as + 20) */
+ BSRLI r9, r12, 8 /* t1 = v >> 8 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 16 /* *(d + 16) = t1 */
+ BSLLI r11, r12, 24 /* h = v << 24 */
+ lwi r12, r8, 24 /* v = *(as + 24) */
+ BSRLI r9, r12, 8 /* t1 = v >> 8 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 20 /* *(d + 20) = t1 */
+ BSLLI r11, r12, 24 /* h = v << 24 */
+ lwi r12, r8, 28 /* v = *(as + 28) */
+ BSRLI r9, r12, 8 /* t1 = v >> 8 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 24 /* *(d + 24) = t1 */
+ BSLLI r11, r12, 24 /* h = v << 24 */
+ lwi r12, r8, 32 /* v = *(as + 32) */
+ BSRLI r9, r12, 8 /* t1 = v >> 8 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 28 /* *(d + 28) = t1 */
+ BSLLI r11, r12, 24 /* h = v << 24 */
+ addi r8, r8, 32 /* as = as + 32 */
+ addi r4, r4, -32 /* n = n - 32 */
+ bneid r4, a_bu3_loop /* while (n) loop */
+ addi r5, r5, 32 /* d = d + 32 (IN DELAY SLOT) */
+ bri a_block_done
+
+a_block_u1:
+ BSLLI r11, r11, 8 /* h = h << 8 */
+a_bu1_loop:
+ lwi r12, r8, 4 /* v = *(as + 4) */
+ BSRLI r9, r12, 24 /* t1 = v >> 24 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 0 /* *(d + 0) = t1 */
+ BSLLI r11, r12, 8 /* h = v << 8 */
+ lwi r12, r8, 8 /* v = *(as + 8) */
+ BSRLI r9, r12, 24 /* t1 = v >> 24 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 4 /* *(d + 4) = t1 */
+ BSLLI r11, r12, 8 /* h = v << 8 */
+ lwi r12, r8, 12 /* v = *(as + 12) */
+ BSRLI r9, r12, 24 /* t1 = v >> 24 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 8 /* *(d + 8) = t1 */
+ BSLLI r11, r12, 8 /* h = v << 8 */
+ lwi r12, r8, 16 /* v = *(as + 16) */
+ BSRLI r9, r12, 24 /* t1 = v >> 24 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 12 /* *(d + 12) = t1 */
+ BSLLI r11, r12, 8 /* h = v << 8 */
+ lwi r12, r8, 20 /* v = *(as + 20) */
+ BSRLI r9, r12, 24 /* t1 = v >> 24 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 16 /* *(d + 16) = t1 */
+ BSLLI r11, r12, 8 /* h = v << 8 */
+ lwi r12, r8, 24 /* v = *(as + 24) */
+ BSRLI r9, r12, 24 /* t1 = v >> 24 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 20 /* *(d + 20) = t1 */
+ BSLLI r11, r12, 8 /* h = v << 8 */
+ lwi r12, r8, 28 /* v = *(as + 28) */
+ BSRLI r9, r12, 24 /* t1 = v >> 24 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 24 /* *(d + 24) = t1 */
+ BSLLI r11, r12, 8 /* h = v << 8 */
+ lwi r12, r8, 32 /* v = *(as + 32) */
+ BSRLI r9, r12, 24 /* t1 = v >> 24 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 28 /* *(d + 28) = t1 */
+ BSLLI r11, r12, 8 /* h = v << 8 */
+ addi r8, r8, 32 /* as = as + 32 */
+ addi r4, r4, -32 /* n = n - 32 */
+ bneid r4, a_bu1_loop /* while (n) loop */
+ addi r5, r5, 32 /* d = d + 32 (IN DELAY SLOT) */
+ bri a_block_done
+
+a_block_u2:
+ BSLLI r11, r11, 16 /* h = h << 16 */
+a_bu2_loop:
+ lwi r12, r8, 4 /* v = *(as + 4) */
+ BSRLI r9, r12, 16 /* t1 = v >> 16 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 0 /* *(d + 0) = t1 */
+ BSLLI r11, r12, 16 /* h = v << 16 */
+ lwi r12, r8, 8 /* v = *(as + 8) */
+ BSRLI r9, r12, 16 /* t1 = v >> 16 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 4 /* *(d + 4) = t1 */
+ BSLLI r11, r12, 16 /* h = v << 16 */
+ lwi r12, r8, 12 /* v = *(as + 12) */
+ BSRLI r9, r12, 16 /* t1 = v >> 16 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 8 /* *(d + 8) = t1 */
+ BSLLI r11, r12, 16 /* h = v << 16 */
+ lwi r12, r8, 16 /* v = *(as + 16) */
+ BSRLI r9, r12, 16 /* t1 = v >> 16 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 12 /* *(d + 12) = t1 */
+ BSLLI r11, r12, 16 /* h = v << 16 */
+ lwi r12, r8, 20 /* v = *(as + 20) */
+ BSRLI r9, r12, 16 /* t1 = v >> 16 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 16 /* *(d + 16) = t1 */
+ BSLLI r11, r12, 16 /* h = v << 16 */
+ lwi r12, r8, 24 /* v = *(as + 24) */
+ BSRLI r9, r12, 16 /* t1 = v >> 16 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 20 /* *(d + 20) = t1 */
+ BSLLI r11, r12, 16 /* h = v << 16 */
+ lwi r12, r8, 28 /* v = *(as + 28) */
+ BSRLI r9, r12, 16 /* t1 = v >> 16 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 24 /* *(d + 24) = t1 */
+ BSLLI r11, r12, 16 /* h = v << 16 */
+ lwi r12, r8, 32 /* v = *(as + 32) */
+ BSRLI r9, r12, 16 /* t1 = v >> 16 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 28 /* *(d + 28) = t1 */
+ BSLLI r11, r12, 16 /* h = v << 16 */
+ addi r8, r8, 32 /* as = as + 32 */
+ addi r4, r4, -32 /* n = n - 32 */
+ bneid r4, a_bu2_loop /* while (n) loop */
+ addi r5, r5, 32 /* d = d + 32 (IN DELAY SLOT) */
+
+a_block_done:
+ addi r4, r0, 4 /* n = 4 */
+ cmpu r4, r4, r7 /* n = c - n (unsigned) */
+ blti r4, a_xfer_end /* if n < 0, less than one word to transfer */
+
+a_word_xfer:
+ andi r4, r7, 0xfffffffc /* n = c & ~3 */
+ addi r10, r0, 0 /* offset = 0 */
+
+ andi r9, r6, 3 /* t1 = s & 3 */
+ /* if temp != 0, unaligned transfers needed */
+ bnei r9, a_word_unaligned
+
+a_word_aligned:
+ lw r9, r6, r10 /* t1 = *(s+offset) */
+ sw r9, r5, r10 /* *(d+offset) = t1 */
+ addi r4, r4,-4 /* n-- */
+ bneid r4, a_word_aligned /* loop */
+ addi r10, r10, 4 /* offset++ (IN DELAY SLOT) */
+
+ bri a_word_done
+
+a_word_unaligned:
+ andi r8, r6, 0xfffffffc /* as = s & ~3 */
+ lwi r11, r8, 0 /* h = *(as + 0) */
+ addi r8, r8, 4 /* as = as + 4 */
+
+ addi r9, r9, -1
+ beqi r9, a_word_u1 /* t1 was 1 => 1 byte offset */
+ addi r9, r9, -1
+ beqi r9, a_word_u2 /* t1 was 2 => 2 byte offset */
+
+a_word_u3:
+ BSLLI r11, r11, 24 /* h = h << 24 */
+a_wu3_loop:
+ lw r12, r8, r10 /* v = *(as + offset) */
+ BSRLI r9, r12, 8 /* t1 = v >> 8 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ sw r9, r5, r10 /* *(d + offset) = t1 */
+ BSLLI r11, r12, 24 /* h = v << 24 */
+ addi r4, r4,-4 /* n = n - 4 */
+ bneid r4, a_wu3_loop /* while (n) loop */
+ addi r10, r10, 4 /* offset = ofset + 4 (IN DELAY SLOT) */
+
+ bri a_word_done
+
+a_word_u1:
+ BSLLI r11, r11, 8 /* h = h << 8 */
+a_wu1_loop:
+ lw r12, r8, r10 /* v = *(as + offset) */
+ BSRLI r9, r12, 24 /* t1 = v >> 24 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ sw r9, r5, r10 /* *(d + offset) = t1 */
+ BSLLI r11, r12, 8 /* h = v << 8 */
+ addi r4, r4,-4 /* n = n - 4 */
+ bneid r4, a_wu1_loop /* while (n) loop */
+ addi r10, r10, 4 /* offset = ofset + 4 (IN DELAY SLOT) */
+
+ bri a_word_done
+
+a_word_u2:
+ BSLLI r11, r11, 16 /* h = h << 16 */
+a_wu2_loop:
+ lw r12, r8, r10 /* v = *(as + offset) */
+ BSRLI r9, r12, 16 /* t1 = v >> 16 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ sw r9, r5, r10 /* *(d + offset) = t1 */
+ BSLLI r11, r12, 16 /* h = v << 16 */
+ addi r4, r4,-4 /* n = n - 4 */
+ bneid r4, a_wu2_loop /* while (n) loop */
+ addi r10, r10, 4 /* offset = ofset + 4 (IN DELAY SLOT) */
+
+a_word_done:
+ add r5, r5, r10 /* d = d + offset */
+ add r6, r6, r10 /* s = s + offset */
+ rsub r7, r10, r7 /* c = c - offset */
+
+a_xfer_end:
+a_xfer_end_loop:
+ beqi r7, a_done /* while (c) */
+ lbui r9, r6, 0 /* t1 = *s */
+ addi r6, r6, 1 /* s++ */
+ sbi r9, r5, 0 /* *d = t1 */
+ addi r7, r7, -1 /* c-- */
+ brid a_xfer_end_loop /* loop */
+ addi r5, r5, 1 /* d++ (IN DELAY SLOT) */
+
+a_done:
+ rtsd r15, 8
+ nop
+
+.size memcpy, . - memcpy
+.end memcpy
+libc_hidden_def(memcpy)
diff --git a/libc/string/microblaze/memmove.S b/libc/string/microblaze/memmove.S
new file mode 100644
index 000000000..6bac01620
--- /dev/null
+++ b/libc/string/microblaze/memmove.S
@@ -0,0 +1,356 @@
+/*
+ * Copyright (C) 2008-2009 Michal Simek <monstr@monstr.eu>
+ * Copyright (C) 2008-2009 PetaLogix
+ * Copyright (C) 2008 Jim Law - Iris LP All rights reserved.
+ *
+ * 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.
+ *
+ * Written by Jim Law <jlaw@irispower.com>
+ *
+ * intended to replace:
+ * memcpy in memcpy.c and
+ * memmove in memmove.c
+ * ... in arch/microblaze/lib
+ *
+ *
+ * assly_fastcopy.S
+ *
+ * Attempt at quicker memcpy and memmove for MicroBlaze
+ * Input : Operand1 in Reg r5 - destination address
+ * Operand2 in Reg r6 - source address
+ * Operand3 in Reg r7 - number of bytes to transfer
+ * Output: Result in Reg r3 - starting destinaition address
+ *
+ *
+ * Explanation:
+ * Perform (possibly unaligned) copy of a block of memory
+ * between mem locations with size of xfer spec'd in bytes
+ */
+
+ .globl memmove
+ .type memmove, @function
+ .ent memmove
+
+#ifdef __MICROBLAZEEL__
+# define BSLLI bsrli
+# define BSRLI bslli
+#else
+# define BSLLI bslli
+# define BSRLI bsrli
+#endif
+
+memmove:
+ cmpu r4, r5, r6 /* n = s - d */
+ bgei r4, HIDDEN_JUMPTARGET(memcpy)
+
+fast_memcpy_descending:
+ /* move d to return register as value of function */
+ addi r3, r5, 0
+
+ add r5, r5, r7 /* d = d + c */
+ add r6, r6, r7 /* s = s + c */
+
+ addi r4, r0, 4 /* n = 4 */
+ cmpu r4, r4, r7 /* n = c - n (unsigned) */
+ blti r4,d_xfer_end /* if n < 0, less than one word to transfer */
+
+ /* transfer first 0~3 bytes to get aligned dest address */
+ andi r4, r5, 3 /* n = d & 3 */
+ /* if zero, destination already aligned */
+ beqi r4,d_dalign_done
+ rsub r7, r4, r7 /* c = c - n adjust c */
+
+d_xfer_first_loop:
+ /* if no bytes left to transfer, transfer the bulk */
+ beqi r4,d_dalign_done
+ addi r6, r6, -1 /* s-- */
+ addi r5, r5, -1 /* d-- */
+ lbui r11, r6, 0 /* h = *s */
+ sbi r11, r5, 0 /* *d = h */
+ brid d_xfer_first_loop /* loop */
+ addi r4, r4, -1 /* n-- (IN DELAY SLOT) */
+
+d_dalign_done:
+ addi r4, r0, 32 /* n = 32 */
+ cmpu r4, r4, r7 /* n = c - n (unsigned) */
+ /* if n < 0, less than one block to transfer */
+ blti r4, d_block_done
+
+d_block_xfer:
+ andi r4, r7, 0xffffffe0 /* n = c & ~31 */
+ rsub r7, r4, r7 /* c = c - n */
+
+ andi r9, r6, 3 /* t1 = s & 3 */
+ /* if temp != 0, unaligned transfers needed */
+ bnei r9, d_block_unaligned
+
+d_block_aligned:
+ addi r6, r6, -32 /* s = s - 32 */
+ addi r5, r5, -32 /* d = d - 32 */
+ lwi r9, r6, 28 /* t1 = *(s + 28) */
+ lwi r10, r6, 24 /* t2 = *(s + 24) */
+ lwi r11, r6, 20 /* t3 = *(s + 20) */
+ lwi r12, r6, 16 /* t4 = *(s + 16) */
+ swi r9, r5, 28 /* *(d + 28) = t1 */
+ swi r10, r5, 24 /* *(d + 24) = t2 */
+ swi r11, r5, 20 /* *(d + 20) = t3 */
+ swi r12, r5, 16 /* *(d + 16) = t4 */
+ lwi r9, r6, 12 /* t1 = *(s + 12) */
+ lwi r10, r6, 8 /* t2 = *(s + 8) */
+ lwi r11, r6, 4 /* t3 = *(s + 4) */
+ lwi r12, r6, 0 /* t4 = *(s + 0) */
+ swi r9, r5, 12 /* *(d + 12) = t1 */
+ swi r10, r5, 8 /* *(d + 8) = t2 */
+ swi r11, r5, 4 /* *(d + 4) = t3 */
+ addi r4, r4, -32 /* n = n - 32 */
+ bneid r4, d_block_aligned /* while (n) loop */
+ swi r12, r5, 0 /* *(d + 0) = t4 (IN DELAY SLOT) */
+ bri d_block_done
+
+d_block_unaligned:
+ andi r8, r6, 0xfffffffc /* as = s & ~3 */
+ rsub r6, r4, r6 /* s = s - n */
+ lwi r11, r8, 0 /* h = *(as + 0) */
+
+ addi r9, r9, -1
+ beqi r9,d_block_u1 /* t1 was 1 => 1 byte offset */
+ addi r9, r9, -1
+ beqi r9,d_block_u2 /* t1 was 2 => 2 byte offset */
+
+d_block_u3:
+ BSRLI r11, r11, 8 /* h = h >> 8 */
+d_bu3_loop:
+ addi r8, r8, -32 /* as = as - 32 */
+ addi r5, r5, -32 /* d = d - 32 */
+ lwi r12, r8, 28 /* v = *(as + 28) */
+ BSLLI r9, r12, 24 /* t1 = v << 24 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 28 /* *(d + 28) = t1 */
+ BSRLI r11, r12, 8 /* h = v >> 8 */
+ lwi r12, r8, 24 /* v = *(as + 24) */
+ BSLLI r9, r12, 24 /* t1 = v << 24 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 24 /* *(d + 24) = t1 */
+ BSRLI r11, r12, 8 /* h = v >> 8 */
+ lwi r12, r8, 20 /* v = *(as + 20) */
+ BSLLI r9, r12, 24 /* t1 = v << 24 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 20 /* *(d + 20) = t1 */
+ BSRLI r11, r12, 8 /* h = v >> 8 */
+ lwi r12, r8, 16 /* v = *(as + 16) */
+ BSLLI r9, r12, 24 /* t1 = v << 24 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 16 /* *(d + 16) = t1 */
+ BSRLI r11, r12, 8 /* h = v >> 8 */
+ lwi r12, r8, 12 /* v = *(as + 12) */
+ BSLLI r9, r12, 24 /* t1 = v << 24 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 12 /* *(d + 112) = t1 */
+ BSRLI r11, r12, 8 /* h = v >> 8 */
+ lwi r12, r8, 8 /* v = *(as + 8) */
+ BSLLI r9, r12, 24 /* t1 = v << 24 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 8 /* *(d + 8) = t1 */
+ BSRLI r11, r12, 8 /* h = v >> 8 */
+ lwi r12, r8, 4 /* v = *(as + 4) */
+ BSLLI r9, r12, 24 /* t1 = v << 24 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 4 /* *(d + 4) = t1 */
+ BSRLI r11, r12, 8 /* h = v >> 8 */
+ lwi r12, r8, 0 /* v = *(as + 0) */
+ BSLLI r9, r12, 24 /* t1 = v << 24 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 0 /* *(d + 0) = t1 */
+ addi r4, r4, -32 /* n = n - 32 */
+ bneid r4, d_bu3_loop /* while (n) loop */
+ BSRLI r11, r12, 8 /* h = v >> 8 (IN DELAY SLOT) */
+ bri d_block_done
+
+d_block_u1:
+ BSRLI r11, r11, 24 /* h = h >> 24 */
+d_bu1_loop:
+ addi r8, r8, -32 /* as = as - 32 */
+ addi r5, r5, -32 /* d = d - 32 */
+ lwi r12, r8, 28 /* v = *(as + 28) */
+ BSLLI r9, r12, 8 /* t1 = v << 8 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 28 /* *(d + 28) = t1 */
+ BSRLI r11, r12, 24 /* h = v >> 24 */
+ lwi r12, r8, 24 /* v = *(as + 24) */
+ BSLLI r9, r12, 8 /* t1 = v << 8 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 24 /* *(d + 24) = t1 */
+ BSRLI r11, r12, 24 /* h = v >> 24 */
+ lwi r12, r8, 20 /* v = *(as + 20) */
+ BSLLI r9, r12, 8 /* t1 = v << 8 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 20 /* *(d + 20) = t1 */
+ BSRLI r11, r12, 24 /* h = v >> 24 */
+ lwi r12, r8, 16 /* v = *(as + 16) */
+ BSLLI r9, r12, 8 /* t1 = v << 8 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 16 /* *(d + 16) = t1 */
+ BSRLI r11, r12, 24 /* h = v >> 24 */
+ lwi r12, r8, 12 /* v = *(as + 12) */
+ BSLLI r9, r12, 8 /* t1 = v << 8 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 12 /* *(d + 112) = t1 */
+ BSRLI r11, r12, 24 /* h = v >> 24 */
+ lwi r12, r8, 8 /* v = *(as + 8) */
+ BSLLI r9, r12, 8 /* t1 = v << 8 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 8 /* *(d + 8) = t1 */
+ BSRLI r11, r12, 24 /* h = v >> 24 */
+ lwi r12, r8, 4 /* v = *(as + 4) */
+ BSLLI r9, r12, 8 /* t1 = v << 8 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 4 /* *(d + 4) = t1 */
+ BSRLI r11, r12, 24 /* h = v >> 24 */
+ lwi r12, r8, 0 /* v = *(as + 0) */
+ BSLLI r9, r12, 8 /* t1 = v << 8 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 0 /* *(d + 0) = t1 */
+ addi r4, r4, -32 /* n = n - 32 */
+ bneid r4, d_bu1_loop /* while (n) loop */
+ BSRLI r11, r12, 24 /* h = v >> 24 (IN DELAY SLOT) */
+ bri d_block_done
+
+d_block_u2:
+ BSRLI r11, r11, 16 /* h = h >> 16 */
+d_bu2_loop:
+ addi r8, r8, -32 /* as = as - 32 */
+ addi r5, r5, -32 /* d = d - 32 */
+ lwi r12, r8, 28 /* v = *(as + 28) */
+ BSLLI r9, r12, 16 /* t1 = v << 16 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 28 /* *(d + 28) = t1 */
+ BSRLI r11, r12, 16 /* h = v >> 16 */
+ lwi r12, r8, 24 /* v = *(as + 24) */
+ BSLLI r9, r12, 16 /* t1 = v << 16 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 24 /* *(d + 24) = t1 */
+ BSRLI r11, r12, 16 /* h = v >> 16 */
+ lwi r12, r8, 20 /* v = *(as + 20) */
+ BSLLI r9, r12, 16 /* t1 = v << 16 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 20 /* *(d + 20) = t1 */
+ BSRLI r11, r12, 16 /* h = v >> 16 */
+ lwi r12, r8, 16 /* v = *(as + 16) */
+ BSLLI r9, r12, 16 /* t1 = v << 16 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 16 /* *(d + 16) = t1 */
+ BSRLI r11, r12, 16 /* h = v >> 16 */
+ lwi r12, r8, 12 /* v = *(as + 12) */
+ BSLLI r9, r12, 16 /* t1 = v << 16 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 12 /* *(d + 112) = t1 */
+ BSRLI r11, r12, 16 /* h = v >> 16 */
+ lwi r12, r8, 8 /* v = *(as + 8) */
+ BSLLI r9, r12, 16 /* t1 = v << 16 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 8 /* *(d + 8) = t1 */
+ BSRLI r11, r12, 16 /* h = v >> 16 */
+ lwi r12, r8, 4 /* v = *(as + 4) */
+ BSLLI r9, r12, 16 /* t1 = v << 16 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 4 /* *(d + 4) = t1 */
+ BSRLI r11, r12, 16 /* h = v >> 16 */
+ lwi r12, r8, 0 /* v = *(as + 0) */
+ BSLLI r9, r12, 16 /* t1 = v << 16 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ swi r9, r5, 0 /* *(d + 0) = t1 */
+ addi r4, r4, -32 /* n = n - 32 */
+ bneid r4, d_bu2_loop /* while (n) loop */
+ BSRLI r11, r12, 16 /* h = v >> 16 (IN DELAY SLOT) */
+
+d_block_done:
+ addi r4, r0, 4 /* n = 4 */
+ cmpu r4, r4, r7 /* n = c - n (unsigned) */
+ blti r4,d_xfer_end /* if n < 0, less than one word to transfer */
+
+d_word_xfer:
+ andi r4, r7, 0xfffffffc /* n = c & ~3 */
+ rsub r5, r4, r5 /* d = d - n */
+ rsub r6, r4, r6 /* s = s - n */
+ rsub r7, r4, r7 /* c = c - n */
+
+ andi r9, r6, 3 /* t1 = s & 3 */
+ /* if temp != 0, unaligned transfers needed */
+ bnei r9, d_word_unaligned
+
+d_word_aligned:
+ addi r4, r4,-4 /* n-- */
+ lw r9, r6, r4 /* t1 = *(s+n) */
+ bneid r4, d_word_aligned /* loop */
+ sw r9, r5, r4 /* *(d+n) = t1 (IN DELAY SLOT) */
+
+ bri d_word_done
+
+d_word_unaligned:
+ andi r8, r6, 0xfffffffc /* as = s & ~3 */
+ lw r11, r8, r4 /* h = *(as + n) */
+
+ addi r9, r9, -1
+ beqi r9,d_word_u1 /* t1 was 1 => 1 byte offset */
+ addi r9, r9, -1
+ beqi r9,d_word_u2 /* t1 was 2 => 2 byte offset */
+
+d_word_u3:
+ BSRLI r11, r11, 8 /* h = h >> 8 */
+d_wu3_loop:
+ addi r4, r4,-4 /* n = n - 4 */
+ lw r12, r8, r4 /* v = *(as + n) */
+ BSLLI r9, r12, 24 /* t1 = v << 24 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ sw r9, r5, r4 /* *(d + n) = t1 */
+ bneid r4, d_wu3_loop /* while (n) loop */
+ BSRLI r11, r12, 8 /* h = v >> 8 (IN DELAY SLOT) */
+
+ bri d_word_done
+
+d_word_u1:
+ BSRLI r11, r11, 24 /* h = h >> 24 */
+d_wu1_loop:
+ addi r4, r4,-4 /* n = n - 4 */
+ lw r12, r8, r4 /* v = *(as + n) */
+ BSLLI r9, r12, 8 /* t1 = v << 8 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ sw r9, r5, r4 /* *(d + n) = t1 */
+ bneid r4, d_wu1_loop /* while (n) loop */
+ BSRLI r11, r12, 24 /* h = v >> 24 (IN DELAY SLOT) */
+
+ bri d_word_done
+
+d_word_u2:
+ BSRLI r11, r11, 16 /* h = h >> 16 */
+d_wu2_loop:
+ addi r4, r4,-4 /* n = n - 4 */
+ lw r12, r8, r4 /* v = *(as + n) */
+ BSLLI r9, r12, 16 /* t1 = v << 16 */
+ or r9, r11, r9 /* t1 = h | t1 */
+ sw r9, r5, r4 /* *(d + n) = t1 */
+ bneid r4, d_wu2_loop /* while (n) loop */
+ BSRLI r11, r12, 16 /* h = v >> 16 (IN DELAY SLOT) */
+
+d_word_done:
+
+d_xfer_end:
+d_xfer_end_loop:
+ beqi r7, a_done /* while (c) */
+ addi r6, r6, -1 /* s-- */
+ lbui r9, r6, 0 /* t1 = *s */
+ addi r5, r5, -1 /* d-- */
+ sbi r9, r5, 0 /* *d = t1 */
+ brid d_xfer_end_loop /* loop */
+ addi r7, r7, -1 /* c-- (IN DELAY SLOT) */
+
+a_done:
+d_done:
+ rtsd r15, 8
+ nop
+
+.size memmove, . - memmove
+.end memmove
+libc_hidden_def(memmove)
diff --git a/libc/string/mips/memcpy.S b/libc/string/mips/memcpy.S
index 9b05ee6da..59f9f0a3a 100644
--- a/libc/string/mips/memcpy.S
+++ b/libc/string/mips/memcpy.S
@@ -1,6 +1,5 @@
-/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2012-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
- Contributed by Hartvig Ekner <hartvige@mips.com>, 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
@@ -13,245 +12,861 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 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 <sysdep.h>*/
-#include <endian.h>
-#include "sysdep.h"
+#ifdef ANDROID_CHANGES
+# include "machine/asm.h"
+# include "machine/regdef.h"
+# define USE_MEMMOVE_FOR_OVERLAP
+# define PREFETCH_LOAD_HINT PREFETCH_HINT_LOAD_STREAMED
+# define PREFETCH_STORE_HINT PREFETCH_HINT_PREPAREFORSTORE
+#elif _LIBC
+# include <sysdep.h>
+# include <sys/regdef.h>
+# include <sys/asm.h>
+# define PREFETCH_LOAD_HINT PREFETCH_HINT_LOAD_STREAMED
+# define PREFETCH_STORE_HINT PREFETCH_HINT_PREPAREFORSTORE
+#elif defined _COMPILING_NEWLIB
+# include "machine/asm.h"
+# include "machine/regdef.h"
+# define PREFETCH_LOAD_HINT PREFETCH_HINT_LOAD_STREAMED
+# define PREFETCH_STORE_HINT PREFETCH_HINT_PREPAREFORSTORE
+#else
+# include <sys/regdef.h>
+# include <sys/asm.h>
+#endif
+
+#if (_MIPS_ISA == _MIPS_ISA_MIPS4) || (_MIPS_ISA == _MIPS_ISA_MIPS5) || \
+ (_MIPS_ISA == _MIPS_ISA_MIPS32) || (_MIPS_ISA == _MIPS_ISA_MIPS64)
+# ifndef DISABLE_PREFETCH
+# define USE_PREFETCH
+# endif
+#endif
+
+#if defined(_MIPS_SIM) && ((_MIPS_SIM == _ABI64) || (_MIPS_SIM == _ABIN32))
+# ifndef DISABLE_DOUBLE
+# define USE_DOUBLE
+# endif
+#endif
+
+/* Some asm.h files do not have the L macro definition. */
+#ifndef L
+# if _MIPS_SIM == _ABIO32
+# define L(label) $L ## label
+# else
+# define L(label) .L ## label
+# endif
+#endif
+
+/* Some asm.h files do not have the PTR_ADDIU macro definition. */
+#ifndef PTR_ADDIU
+# ifdef USE_DOUBLE
+# define PTR_ADDIU daddiu
+# else
+# define PTR_ADDIU addiu
+# endif
+#endif
+
+/* Some asm.h files do not have the PTR_SRA macro definition. */
+#ifndef PTR_SRA
+# ifdef USE_DOUBLE
+# define PTR_SRA dsra
+# else
+# define PTR_SRA sra
+# endif
+#endif
+
+/* New R6 instructions that may not be in asm.h. */
+#ifndef PTR_LSA
+# if _MIPS_SIM == _ABI64
+# define PTR_LSA dlsa
+# else
+# define PTR_LSA lsa
+# endif
+#endif
+
+/*
+ * Using PREFETCH_HINT_LOAD_STREAMED instead of PREFETCH_LOAD on load
+ * prefetches appears to offer a slight preformance advantage.
+ *
+ * Using PREFETCH_HINT_PREPAREFORSTORE instead of PREFETCH_STORE
+ * or PREFETCH_STORE_STREAMED offers a large performance advantage
+ * but PREPAREFORSTORE has some special restrictions to consider.
+ *
+ * Prefetch with the 'prepare for store' hint does not copy a memory
+ * location into the cache, it just allocates a cache line and zeros
+ * it out. This means that if you do not write to the entire cache
+ * line before writing it out to memory some data will get zero'ed out
+ * when the cache line is written back to memory and data will be lost.
+ *
+ * Also if you are using this memcpy to copy overlapping buffers it may
+ * not behave correctly when using the 'prepare for store' hint. If you
+ * use the 'prepare for store' prefetch on a memory area that is in the
+ * memcpy source (as well as the memcpy destination), then you will get
+ * some data zero'ed out before you have a chance to read it and data will
+ * be lost.
+ *
+ * If you are going to use this memcpy routine with the 'prepare for store'
+ * prefetch you may want to set USE_MEMMOVE_FOR_OVERLAP in order to avoid
+ * the problem of running memcpy on overlapping buffers.
+ *
+ * There are ifdef'ed sections of this memcpy to make sure that it does not
+ * do prefetches on cache lines that are not going to be completely written.
+ * This code is only needed and only used when PREFETCH_STORE_HINT is set to
+ * PREFETCH_HINT_PREPAREFORSTORE. This code assumes that cache lines are
+ * 32 bytes and if the cache line is larger it will not work correctly.
+ */
+
+#ifdef USE_PREFETCH
+# define PREFETCH_HINT_LOAD 0
+# define PREFETCH_HINT_STORE 1
+# define PREFETCH_HINT_LOAD_STREAMED 4
+# define PREFETCH_HINT_STORE_STREAMED 5
+# define PREFETCH_HINT_LOAD_RETAINED 6
+# define PREFETCH_HINT_STORE_RETAINED 7
+# define PREFETCH_HINT_WRITEBACK_INVAL 25
+# define PREFETCH_HINT_PREPAREFORSTORE 30
+
+/*
+ * If we have not picked out what hints to use at this point use the
+ * standard load and store prefetch hints.
+ */
+# ifndef PREFETCH_STORE_HINT
+# define PREFETCH_STORE_HINT PREFETCH_HINT_STORE
+# endif
+# ifndef PREFETCH_LOAD_HINT
+# define PREFETCH_LOAD_HINT PREFETCH_HINT_LOAD
+# endif
+
+/*
+ * We double everything when USE_DOUBLE is true so we do 2 prefetches to
+ * get 64 bytes in that case. The assumption is that each individual
+ * prefetch brings in 32 bytes.
+ */
+
+# ifdef USE_DOUBLE
+# define PREFETCH_CHUNK 64
+# define PREFETCH_FOR_LOAD(chunk, reg) \
+ pref PREFETCH_LOAD_HINT, (chunk)*64(reg); \
+ pref PREFETCH_LOAD_HINT, ((chunk)*64)+32(reg)
+# define PREFETCH_FOR_STORE(chunk, reg) \
+ pref PREFETCH_STORE_HINT, (chunk)*64(reg); \
+ pref PREFETCH_STORE_HINT, ((chunk)*64)+32(reg)
+# else
+# define PREFETCH_CHUNK 32
+# define PREFETCH_FOR_LOAD(chunk, reg) \
+ pref PREFETCH_LOAD_HINT, (chunk)*32(reg)
+# define PREFETCH_FOR_STORE(chunk, reg) \
+ pref PREFETCH_STORE_HINT, (chunk)*32(reg)
+# endif
+/* MAX_PREFETCH_SIZE is the maximum size of a prefetch, it must not be less
+ * than PREFETCH_CHUNK, the assumed size of each prefetch. If the real size
+ * of a prefetch is greater than MAX_PREFETCH_SIZE and the PREPAREFORSTORE
+ * hint is used, the code will not work correctly. If PREPAREFORSTORE is not
+ * used then MAX_PREFETCH_SIZE does not matter. */
+# define MAX_PREFETCH_SIZE 128
+/* PREFETCH_LIMIT is set based on the fact that we never use an offset greater
+ * than 5 on a STORE prefetch and that a single prefetch can never be larger
+ * than MAX_PREFETCH_SIZE. We add the extra 32 when USE_DOUBLE is set because
+ * we actually do two prefetches in that case, one 32 bytes after the other. */
+# ifdef USE_DOUBLE
+# define PREFETCH_LIMIT (5 * PREFETCH_CHUNK) + 32 + MAX_PREFETCH_SIZE
+# else
+# define PREFETCH_LIMIT (5 * PREFETCH_CHUNK) + MAX_PREFETCH_SIZE
+# endif
+# if (PREFETCH_STORE_HINT == PREFETCH_HINT_PREPAREFORSTORE) \
+ && ((PREFETCH_CHUNK * 4) < MAX_PREFETCH_SIZE)
+/* We cannot handle this because the initial prefetches may fetch bytes that
+ * are before the buffer being copied. We start copies with an offset
+ * of 4 so avoid this situation when using PREPAREFORSTORE. */
+#error "PREFETCH_CHUNK is too large and/or MAX_PREFETCH_SIZE is too small."
+# endif
+#else /* USE_PREFETCH not defined */
+# define PREFETCH_FOR_LOAD(offset, reg)
+# define PREFETCH_FOR_STORE(offset, reg)
+#endif
+
+#if __mips_isa_rev > 5
+# if (PREFETCH_STORE_HINT == PREFETCH_HINT_PREPAREFORSTORE)
+# undef PREFETCH_STORE_HINT
+# define PREFETCH_STORE_HINT PREFETCH_HINT_STORE_STREAMED
+# endif
+# define R6_CODE
+#endif
-/* void *memcpy(void *s1, const void *s2, size_t n); */
+/* Allow the routine to be named something else if desired. */
+#ifndef MEMCPY_NAME
+# define MEMCPY_NAME memcpy
+#endif
+
+/* We use these 32/64 bit registers as temporaries to do the copying. */
+#define REG0 t0
+#define REG1 t1
+#define REG2 t2
+#define REG3 t3
+#if defined(_MIPS_SIM) && ((_MIPS_SIM == _ABIO32) || (_MIPS_SIM == _ABIO64))
+# define REG4 t4
+# define REG5 t5
+# define REG6 t6
+# define REG7 t7
+#else
+# define REG4 ta0
+# define REG5 ta1
+# define REG6 ta2
+# define REG7 ta3
+#endif
-#ifdef __mips64
+/* We load/store 64 bits at a time when USE_DOUBLE is true.
+ * The C_ prefix stands for CHUNK and is used to avoid macro name
+ * conflicts with system header files. */
-#include <sys/asm.h>
+#ifdef USE_DOUBLE
+# define C_ST sd
+# define C_LD ld
+# ifdef __MIPSEB
+# define C_LDHI ldl /* high part is left in big-endian */
+# define C_STHI sdl /* high part is left in big-endian */
+# define C_LDLO ldr /* low part is right in big-endian */
+# define C_STLO sdr /* low part is right in big-endian */
+# else
+# define C_LDHI ldr /* high part is right in little-endian */
+# define C_STHI sdr /* high part is right in little-endian */
+# define C_LDLO ldl /* low part is left in little-endian */
+# define C_STLO sdl /* low part is left in little-endian */
+# endif
+# define C_ALIGN dalign /* r6 align instruction */
+#else
+# define C_ST sw
+# define C_LD lw
+# ifdef __MIPSEB
+# define C_LDHI lwl /* high part is left in big-endian */
+# define C_STHI swl /* high part is left in big-endian */
+# define C_LDLO lwr /* low part is right in big-endian */
+# define C_STLO swr /* low part is right in big-endian */
+# else
+# define C_LDHI lwr /* high part is right in little-endian */
+# define C_STHI swr /* high part is right in little-endian */
+# define C_LDLO lwl /* low part is left in little-endian */
+# define C_STLO swl /* low part is left in little-endian */
+# endif
+# define C_ALIGN align /* r6 align instruction */
+#endif
-#if __BYTE_ORDER == __BIG_ENDIAN
-# define LDHI ldl /* high part is left in big-endian */
-# define SDHI sdl /* high part is left in big-endian */
-# define LDLO ldr /* low part is right in big-endian */
-# define SDLO sdr /* low part is right in big-endian */
+/* Bookkeeping values for 32 vs. 64 bit mode. */
+#ifdef USE_DOUBLE
+# define NSIZE 8
+# define NSIZEMASK 0x3f
+# define NSIZEDMASK 0x7f
#else
-# define LDHI ldr /* high part is right in little-endian */
-# define SDHI sdr /* high part is right in little-endian */
-# define LDLO ldl /* low part is left in little-endian */
-# define SDLO sdl /* low part is left in little-endian */
+# define NSIZE 4
+# define NSIZEMASK 0x1f
+# define NSIZEDMASK 0x3f
#endif
+#define UNIT(unit) ((unit)*NSIZE)
+#define UNITM1(unit) (((unit)*NSIZE)-1)
-ENTRY (memcpy)
+#ifdef ANDROID_CHANGES
+LEAF(MEMCPY_NAME, 0)
+#else
+LEAF(MEMCPY_NAME)
+#endif
+ .set nomips16
.set noreorder
+/*
+ * Below we handle the case where memcpy is called with overlapping src and dst.
+ * Although memcpy is not required to handle this case, some parts of Android
+ * like Skia rely on such usage. We call memmove to handle such cases.
+ */
+#ifdef USE_MEMMOVE_FOR_OVERLAP
+ PTR_SUBU t0,a0,a1
+ PTR_SRA t2,t0,31
+ xor t1,t0,t2
+ PTR_SUBU t0,t1,t2
+ sltu t2,t0,a2
+ beq t2,zero,L(memcpy)
+ la t9,memmove
+ jr t9
+ nop
+L(memcpy):
+#endif
+/*
+ * If the size is less than 2*NSIZE (8 or 16), go to L(lastb). Regardless of
+ * size, copy dst pointer to v0 for the return value.
+ */
+ slti t2,a2,(2 * NSIZE)
+ bne t2,zero,L(lasts)
+#if defined(RETURN_FIRST_PREFETCH) || defined(RETURN_LAST_PREFETCH)
+ move v0,zero
+#else
+ move v0,a0
+#endif
- slti t0, a2, 16 # Less than 16?
- bne t0, zero, L(last16)
- move v0, a0 # Setup exit value before too late
-
- xor t0, a1, a0 # Find a0/a1 displacement
- andi t0, 0x7
- bne t0, zero, L(shift) # Go handle the unaligned case
- PTR_SUBU t1, zero, a1
- andi t1, 0x7 # a0/a1 are aligned, but are we
- beq t1, zero, L(chk8w) # starting in the middle of a word?
- PTR_SUBU a2, t1
- LDHI t0, 0(a1) # Yes we are... take care of that
- PTR_ADDU a1, t1
- SDHI t0, 0(a0)
- PTR_ADDU a0, t1
-
-L(chk8w):
- andi t0, a2, 0x3f # 64 or more bytes left?
- beq t0, a2, L(chk1w)
- PTR_SUBU a3, a2, t0 # Yes
- PTR_ADDU a3, a1 # a3 = end address of loop
- move a2, t0 # a2 = what will be left after loop
-L(lop8w):
- ld t0, 0(a1) # Loop taking 8 words at a time
- ld t1, 8(a1)
- ld t2, 16(a1)
- ld t3, 24(a1)
- ld ta0, 32(a1)
- ld ta1, 40(a1)
- ld ta2, 48(a1)
- ld ta3, 56(a1)
- PTR_ADDIU a0, 64
- PTR_ADDIU a1, 64
- sd t0, -64(a0)
- sd t1, -56(a0)
- sd t2, -48(a0)
- sd t3, -40(a0)
- sd ta0, -32(a0)
- sd ta1, -24(a0)
- sd ta2, -16(a0)
- bne a1, a3, L(lop8w)
- sd ta3, -8(a0)
+#ifndef R6_CODE
-L(chk1w):
- andi t0, a2, 0x7 # 8 or more bytes left?
- beq t0, a2, L(last16)
- PTR_SUBU a3, a2, t0 # Yes, handle them one dword at a time
- PTR_ADDU a3, a1 # a3 again end address
- move a2, t0
-L(lop1w):
- ld t0, 0(a1)
- PTR_ADDIU a0, 8
- PTR_ADDIU a1, 8
- bne a1, a3, L(lop1w)
- sd t0, -8(a0)
-
-L(last16):
- blez a2, L(lst16e) # Handle last 16 bytes, one at a time
- PTR_ADDU a3, a2, a1
-L(lst16l):
- lb t0, 0(a1)
- PTR_ADDIU a0, 1
- PTR_ADDIU a1, 1
- bne a1, a3, L(lst16l)
- sb t0, -1(a0)
-L(lst16e):
- jr ra # Bye, bye
- nop
+/*
+ * If src and dst have different alignments, go to L(unaligned), if they
+ * have the same alignment (but are not actually aligned) do a partial
+ * load/store to make them aligned. If they are both already aligned
+ * we can start copying at L(aligned).
+ */
+ xor t8,a1,a0
+ andi t8,t8,(NSIZE-1) /* t8 is a0/a1 word-displacement */
+ bne t8,zero,L(unaligned)
+ PTR_SUBU a3, zero, a0
-L(shift):
- PTR_SUBU a3, zero, a0 # Src and Dest unaligned
- andi a3, 0x7 # (unoptimized case...)
- beq a3, zero, L(shft1)
- PTR_SUBU a2, a3 # a2 = bytes left
- LDHI t0, 0(a1) # Take care of first odd part
- LDLO t0, 7(a1)
- PTR_ADDU a1, a3
- SDHI t0, 0(a0)
- PTR_ADDU a0, a3
-L(shft1):
- andi t0, a2, 0x7
- PTR_SUBU a3, a2, t0
- PTR_ADDU a3, a1
-L(shfth):
- LDHI t1, 0(a1) # Limp through, dword by dword
- LDLO t1, 7(a1)
- PTR_ADDIU a0, 8
- PTR_ADDIU a1, 8
- bne a1, a3, L(shfth)
- sd t1, -8(a0)
- b L(last16) # Handle anything which may be left
- move a2, t0
+ andi a3,a3,(NSIZE-1) /* copy a3 bytes to align a0/a1 */
+ beq a3,zero,L(aligned) /* if a3=0, it is already aligned */
+ PTR_SUBU a2,a2,a3 /* a2 is the remining bytes count */
- .set reorder
-END (memcpy)
+ C_LDHI t8,0(a1)
+ PTR_ADDU a1,a1,a3
+ C_STHI t8,0(a0)
+ PTR_ADDU a0,a0,a3
+
+#else /* R6_CODE */
+
+/*
+ * Align the destination and hope that the source gets aligned too. If it
+ * doesn't we jump to L(r6_unaligned*) to do unaligned copies using the r6
+ * align instruction.
+ */
+ andi t8,a0,7
+ lapc t9,L(atable)
+ PTR_LSA t9,t8,t9,2
+ jrc t9
+L(atable):
+ bc L(lb0)
+ bc L(lb7)
+ bc L(lb6)
+ bc L(lb5)
+ bc L(lb4)
+ bc L(lb3)
+ bc L(lb2)
+ bc L(lb1)
+L(lb7):
+ lb a3, 6(a1)
+ sb a3, 6(a0)
+L(lb6):
+ lb a3, 5(a1)
+ sb a3, 5(a0)
+L(lb5):
+ lb a3, 4(a1)
+ sb a3, 4(a0)
+L(lb4):
+ lb a3, 3(a1)
+ sb a3, 3(a0)
+L(lb3):
+ lb a3, 2(a1)
+ sb a3, 2(a0)
+L(lb2):
+ lb a3, 1(a1)
+ sb a3, 1(a0)
+L(lb1):
+ lb a3, 0(a1)
+ sb a3, 0(a0)
+
+ li t9,8
+ subu t8,t9,t8
+ PTR_SUBU a2,a2,t8
+ PTR_ADDU a0,a0,t8
+ PTR_ADDU a1,a1,t8
+L(lb0):
-#else /* !__mips64 */
+ andi t8,a1,(NSIZE-1)
+ lapc t9,L(jtable)
+ PTR_LSA t9,t8,t9,2
+ jrc t9
+L(jtable):
+ bc L(aligned)
+ bc L(r6_unaligned1)
+ bc L(r6_unaligned2)
+ bc L(r6_unaligned3)
+# ifdef USE_DOUBLE
+ bc L(r6_unaligned4)
+ bc L(r6_unaligned5)
+ bc L(r6_unaligned6)
+ bc L(r6_unaligned7)
+# endif
+#endif /* R6_CODE */
-#if __BYTE_ORDER == __BIG_ENDIAN
-# define LWHI lwl /* high part is left in big-endian */
-# define SWHI swl /* high part is left in big-endian */
-# define LWLO lwr /* low part is right in big-endian */
-# define SWLO swr /* low part is right in big-endian */
+L(aligned):
+
+/*
+ * Now dst/src are both aligned to (word or double word) aligned addresses
+ * Set a2 to count how many bytes we have to copy after all the 64/128 byte
+ * chunks are copied and a3 to the dst pointer after all the 64/128 byte
+ * chunks have been copied. We will loop, incrementing a0 and a1 until a0
+ * equals a3.
+ */
+
+ andi t8,a2,NSIZEDMASK /* any whole 64-byte/128-byte chunks? */
+ beq a2,t8,L(chkw) /* if a2==t8, no 64-byte/128-byte chunks */
+ PTR_SUBU a3,a2,t8 /* subtract from a2 the reminder */
+ PTR_ADDU a3,a0,a3 /* Now a3 is the final dst after loop */
+
+/* When in the loop we may prefetch with the 'prepare to store' hint,
+ * in this case the a0+x should not be past the "t0-32" address. This
+ * means: for x=128 the last "safe" a0 address is "t0-160". Alternatively,
+ * for x=64 the last "safe" a0 address is "t0-96" In the current version we
+ * will use "prefetch hint,128(a0)", so "t0-160" is the limit.
+ */
+#if defined(USE_PREFETCH) && (PREFETCH_STORE_HINT == PREFETCH_HINT_PREPAREFORSTORE)
+ PTR_ADDU t0,a0,a2 /* t0 is the "past the end" address */
+ PTR_SUBU t9,t0,PREFETCH_LIMIT /* t9 is the "last safe pref" address */
+#endif
+ PREFETCH_FOR_LOAD (0, a1)
+ PREFETCH_FOR_LOAD (1, a1)
+ PREFETCH_FOR_LOAD (2, a1)
+ PREFETCH_FOR_LOAD (3, a1)
+#if defined(USE_PREFETCH) && (PREFETCH_STORE_HINT != PREFETCH_HINT_PREPAREFORSTORE)
+ PREFETCH_FOR_STORE (1, a0)
+ PREFETCH_FOR_STORE (2, a0)
+ PREFETCH_FOR_STORE (3, a0)
+#endif
+#if defined(RETURN_FIRST_PREFETCH) && defined(USE_PREFETCH)
+# if PREFETCH_STORE_HINT == PREFETCH_HINT_PREPAREFORSTORE
+ sltu v1,t9,a0
+ bgtz v1,L(skip_set)
+ nop
+ PTR_ADDIU v0,a0,(PREFETCH_CHUNK*4)
+L(skip_set):
+# else
+ PTR_ADDIU v0,a0,(PREFETCH_CHUNK*1)
+# endif
+#endif
+#if defined(RETURN_LAST_PREFETCH) && defined(USE_PREFETCH) \
+ && (PREFETCH_STORE_HINT != PREFETCH_HINT_PREPAREFORSTORE)
+ PTR_ADDIU v0,a0,(PREFETCH_CHUNK*3)
+# ifdef USE_DOUBLE
+ PTR_ADDIU v0,v0,32
+# endif
+#endif
+L(loop16w):
+ C_LD t0,UNIT(0)(a1)
+#if defined(USE_PREFETCH) && (PREFETCH_STORE_HINT == PREFETCH_HINT_PREPAREFORSTORE)
+ sltu v1,t9,a0 /* If a0 > t9 don't use next prefetch */
+ bgtz v1,L(skip_pref)
+#endif
+ C_LD t1,UNIT(1)(a1)
+#ifdef R6_CODE
+ PREFETCH_FOR_STORE (2, a0)
#else
-# define LWHI lwr /* high part is right in little-endian */
-# define SWHI swr /* high part is right in little-endian */
-# define LWLO lwl /* low part is left in little-endian */
-# define SWLO swl /* low part is left in little-endian */
+ PREFETCH_FOR_STORE (4, a0)
+ PREFETCH_FOR_STORE (5, a0)
+#endif
+#if defined(RETURN_LAST_PREFETCH) && defined(USE_PREFETCH)
+ PTR_ADDIU v0,a0,(PREFETCH_CHUNK*5)
+# ifdef USE_DOUBLE
+ PTR_ADDIU v0,v0,32
+# endif
#endif
+L(skip_pref):
+ C_LD REG2,UNIT(2)(a1)
+ C_LD REG3,UNIT(3)(a1)
+ C_LD REG4,UNIT(4)(a1)
+ C_LD REG5,UNIT(5)(a1)
+ C_LD REG6,UNIT(6)(a1)
+ C_LD REG7,UNIT(7)(a1)
+#ifdef R6_CODE
+ PREFETCH_FOR_LOAD (3, a1)
+#else
+ PREFETCH_FOR_LOAD (4, a1)
+#endif
+ C_ST t0,UNIT(0)(a0)
+ C_ST t1,UNIT(1)(a0)
+ C_ST REG2,UNIT(2)(a0)
+ C_ST REG3,UNIT(3)(a0)
+ C_ST REG4,UNIT(4)(a0)
+ C_ST REG5,UNIT(5)(a0)
+ C_ST REG6,UNIT(6)(a0)
+ C_ST REG7,UNIT(7)(a0)
-ENTRY (memcpy)
- .set noreorder
+ C_LD t0,UNIT(8)(a1)
+ C_LD t1,UNIT(9)(a1)
+ C_LD REG2,UNIT(10)(a1)
+ C_LD REG3,UNIT(11)(a1)
+ C_LD REG4,UNIT(12)(a1)
+ C_LD REG5,UNIT(13)(a1)
+ C_LD REG6,UNIT(14)(a1)
+ C_LD REG7,UNIT(15)(a1)
+#ifndef R6_CODE
+ PREFETCH_FOR_LOAD (5, a1)
+#endif
+ C_ST t0,UNIT(8)(a0)
+ C_ST t1,UNIT(9)(a0)
+ C_ST REG2,UNIT(10)(a0)
+ C_ST REG3,UNIT(11)(a0)
+ C_ST REG4,UNIT(12)(a0)
+ C_ST REG5,UNIT(13)(a0)
+ C_ST REG6,UNIT(14)(a0)
+ C_ST REG7,UNIT(15)(a0)
+ PTR_ADDIU a0,a0,UNIT(16) /* adding 64/128 to dest */
+ bne a0,a3,L(loop16w)
+ PTR_ADDIU a1,a1,UNIT(16) /* adding 64/128 to src */
+ move a2,t8
+
+/* Here we have src and dest word-aligned but less than 64-bytes or
+ * 128 bytes to go. Check for a 32(64) byte chunk and copy if if there
+ * is one. Otherwise jump down to L(chk1w) to handle the tail end of
+ * the copy.
+ */
+
+L(chkw):
+ PREFETCH_FOR_LOAD (0, a1)
+ andi t8,a2,NSIZEMASK /* Is there a 32-byte/64-byte chunk. */
+ /* The t8 is the reminder count past 32-bytes */
+ beq a2,t8,L(chk1w) /* When a2=t8, no 32-byte chunk */
+ nop
+ C_LD t0,UNIT(0)(a1)
+ C_LD t1,UNIT(1)(a1)
+ C_LD REG2,UNIT(2)(a1)
+ C_LD REG3,UNIT(3)(a1)
+ C_LD REG4,UNIT(4)(a1)
+ C_LD REG5,UNIT(5)(a1)
+ C_LD REG6,UNIT(6)(a1)
+ C_LD REG7,UNIT(7)(a1)
+ PTR_ADDIU a1,a1,UNIT(8)
+ C_ST t0,UNIT(0)(a0)
+ C_ST t1,UNIT(1)(a0)
+ C_ST REG2,UNIT(2)(a0)
+ C_ST REG3,UNIT(3)(a0)
+ C_ST REG4,UNIT(4)(a0)
+ C_ST REG5,UNIT(5)(a0)
+ C_ST REG6,UNIT(6)(a0)
+ C_ST REG7,UNIT(7)(a0)
+ PTR_ADDIU a0,a0,UNIT(8)
+
+/*
+ * Here we have less than 32(64) bytes to copy. Set up for a loop to
+ * copy one word (or double word) at a time. Set a2 to count how many
+ * bytes we have to copy after all the word (or double word) chunks are
+ * copied and a3 to the dst pointer after all the (d)word chunks have
+ * been copied. We will loop, incrementing a0 and a1 until a0 equals a3.
+ */
+L(chk1w):
+ andi a2,t8,(NSIZE-1) /* a2 is the reminder past one (d)word chunks */
+ beq a2,t8,L(lastw)
+ PTR_SUBU a3,t8,a2 /* a3 is count of bytes in one (d)word chunks */
+ PTR_ADDU a3,a0,a3 /* a3 is the dst address after loop */
- slti t0, a2, 8 # Less than 8?
- bne t0, zero, L(last8)
- move v0, a0 # Setup exit value before too late
-
- xor t0, a1, a0 # Find a0/a1 displacement
- andi t0, 0x3
- bne t0, zero, L(shift) # Go handle the unaligned case
- subu t1, zero, a1
- andi t1, 0x3 # a0/a1 are aligned, but are we
- beq t1, zero, L(chk8w) # starting in the middle of a word?
- subu a2, t1
- LWHI t0, 0(a1) # Yes we are... take care of that
- addu a1, t1
- SWHI t0, 0(a0)
- addu a0, t1
-
-L(chk8w):
- andi t0, a2, 0x1f # 32 or more bytes left?
- beq t0, a2, L(chk1w)
- subu a3, a2, t0 # Yes
- addu a3, a1 # a3 = end address of loop
- move a2, t0 # a2 = what will be left after loop
-L(lop8w):
- lw t0, 0(a1) # Loop taking 8 words at a time
- lw t1, 4(a1)
- lw t2, 8(a1)
- lw t3, 12(a1)
- lw t4, 16(a1)
- lw t5, 20(a1)
- lw t6, 24(a1)
- lw t7, 28(a1)
- addiu a0, 32
- addiu a1, 32
- sw t0, -32(a0)
- sw t1, -28(a0)
- sw t2, -24(a0)
- sw t3, -20(a0)
- sw t4, -16(a0)
- sw t5, -12(a0)
- sw t6, -8(a0)
- bne a1, a3, L(lop8w)
- sw t7, -4(a0)
-
-L(chk1w):
- andi t0, a2, 0x3 # 4 or more bytes left?
- beq t0, a2, L(last8)
- subu a3, a2, t0 # Yes, handle them one word at a time
- addu a3, a1 # a3 again end address
- move a2, t0
-L(lop1w):
- lw t0, 0(a1)
- addiu a0, 4
- addiu a1, 4
- bne a1, a3, L(lop1w)
- sw t0, -4(a0)
-
-L(last8):
- blez a2, L(lst8e) # Handle last 8 bytes, one at a time
- addu a3, a2, a1
-L(lst8l):
- lb t0, 0(a1)
- addiu a0, 1
- addiu a1, 1
- bne a1, a3, L(lst8l)
- sb t0, -1(a0)
-L(lst8e):
- jr ra # Bye, bye
+/* copying in words (4-byte or 8-byte chunks) */
+L(wordCopy_loop):
+ C_LD REG3,UNIT(0)(a1)
+ PTR_ADDIU a0,a0,UNIT(1)
+ PTR_ADDIU a1,a1,UNIT(1)
+ bne a0,a3,L(wordCopy_loop)
+ C_ST REG3,UNIT(-1)(a0)
+
+/* If we have been copying double words, see if we can copy a single word
+ before doing byte copies. We can have, at most, one word to copy. */
+
+L(lastw):
+#ifdef USE_DOUBLE
+ andi t8,a2,3 /* a2 is the remainder past 4 byte chunks. */
+ beq t8,a2,L(lastb)
+ move a2,t8
+ lw REG3,0(a1)
+ sw REG3,0(a0)
+ PTR_ADDIU a0,a0,4
+ PTR_ADDIU a1,a1,4
+#endif
+
+/* Copy the last 8 (or 16) bytes */
+L(lastb):
+ blez a2,L(leave)
+ PTR_ADDU a3,a0,a2 /* a3 is the last dst address */
+L(lastbloop):
+ lb v1,0(a1)
+ PTR_ADDIU a0,a0,1
+ PTR_ADDIU a1,a1,1
+ bne a0,a3,L(lastbloop)
+ sb v1,-1(a0)
+L(leave):
+ j ra
nop
-L(shift):
- subu a3, zero, a0 # Src and Dest unaligned
- andi a3, 0x3 # (unoptimized case...)
- beq a3, zero, L(shft1)
- subu a2, a3 # a2 = bytes left
- LWHI t0, 0(a1) # Take care of first odd part
- LWLO t0, 3(a1)
- addu a1, a3
- SWHI t0, 0(a0)
- addu a0, a3
-L(shft1):
- andi t0, a2, 0x3
- subu a3, a2, t0
- addu a3, a1
-L(shfth):
- LWHI t1, 0(a1) # Limp through, word by word
- LWLO t1, 3(a1)
- addiu a0, 4
- addiu a1, 4
- bne a1, a3, L(shfth)
- sw t1, -4(a0)
- b L(last8) # Handle anything which may be left
- move a2, t0
+/* We jump here with a memcpy of less than 8 or 16 bytes, depending on
+ whether or not USE_DOUBLE is defined. Instead of just doing byte
+ copies, check the alignment and size and use lw/sw if possible.
+ Otherwise, do byte copies. */
- .set reorder
-END (memcpy)
+L(lasts):
+ andi t8,a2,3
+ beq t8,a2,L(lastb)
+
+ andi t9,a0,3
+ bne t9,zero,L(lastb)
+ andi t9,a1,3
+ bne t9,zero,L(lastb)
+
+ PTR_SUBU a3,a2,t8
+ PTR_ADDU a3,a0,a3
+
+L(wcopy_loop):
+ lw REG3,0(a1)
+ PTR_ADDIU a0,a0,4
+ PTR_ADDIU a1,a1,4
+ bne a0,a3,L(wcopy_loop)
+ sw REG3,-4(a0)
-#endif /* !__mips64 */
+ b L(lastb)
+ move a2,t8
-libc_hidden_def(memcpy)
+#ifndef R6_CODE
+/*
+ * UNALIGNED case, got here with a3 = "negu a0"
+ * This code is nearly identical to the aligned code above
+ * but only the destination (not the source) gets aligned
+ * so we need to do partial loads of the source followed
+ * by normal stores to the destination (once we have aligned
+ * the destination).
+ */
+
+L(unaligned):
+ andi a3,a3,(NSIZE-1) /* copy a3 bytes to align a0/a1 */
+ beqz a3,L(ua_chk16w) /* if a3=0, it is already aligned */
+ PTR_SUBU a2,a2,a3 /* a2 is the remining bytes count */
+
+ C_LDHI v1,UNIT(0)(a1)
+ C_LDLO v1,UNITM1(1)(a1)
+ PTR_ADDU a1,a1,a3
+ C_STHI v1,UNIT(0)(a0)
+ PTR_ADDU a0,a0,a3
+
+/*
+ * Now the destination (but not the source) is aligned
+ * Set a2 to count how many bytes we have to copy after all the 64/128 byte
+ * chunks are copied and a3 to the dst pointer after all the 64/128 byte
+ * chunks have been copied. We will loop, incrementing a0 and a1 until a0
+ * equals a3.
+ */
+
+L(ua_chk16w):
+ andi t8,a2,NSIZEDMASK /* any whole 64-byte/128-byte chunks? */
+ beq a2,t8,L(ua_chkw) /* if a2==t8, no 64-byte/128-byte chunks */
+ PTR_SUBU a3,a2,t8 /* subtract from a2 the reminder */
+ PTR_ADDU a3,a0,a3 /* Now a3 is the final dst after loop */
+
+# if defined(USE_PREFETCH) && (PREFETCH_STORE_HINT == PREFETCH_HINT_PREPAREFORSTORE)
+ PTR_ADDU t0,a0,a2 /* t0 is the "past the end" address */
+ PTR_SUBU t9,t0,PREFETCH_LIMIT /* t9 is the "last safe pref" address */
+# endif
+ PREFETCH_FOR_LOAD (0, a1)
+ PREFETCH_FOR_LOAD (1, a1)
+ PREFETCH_FOR_LOAD (2, a1)
+# if defined(USE_PREFETCH) && (PREFETCH_STORE_HINT != PREFETCH_HINT_PREPAREFORSTORE)
+ PREFETCH_FOR_STORE (1, a0)
+ PREFETCH_FOR_STORE (2, a0)
+ PREFETCH_FOR_STORE (3, a0)
+# endif
+# if defined(RETURN_FIRST_PREFETCH) && defined(USE_PREFETCH)
+# if (PREFETCH_STORE_HINT == PREFETCH_HINT_PREPAREFORSTORE)
+ sltu v1,t9,a0
+ bgtz v1,L(ua_skip_set)
+ nop
+ PTR_ADDIU v0,a0,(PREFETCH_CHUNK*4)
+L(ua_skip_set):
+# else
+ PTR_ADDIU v0,a0,(PREFETCH_CHUNK*1)
+# endif
+# endif
+L(ua_loop16w):
+ PREFETCH_FOR_LOAD (3, a1)
+ C_LDHI t0,UNIT(0)(a1)
+ C_LDHI t1,UNIT(1)(a1)
+ C_LDHI REG2,UNIT(2)(a1)
+# if defined(USE_PREFETCH) && (PREFETCH_STORE_HINT == PREFETCH_HINT_PREPAREFORSTORE)
+ sltu v1,t9,a0
+ bgtz v1,L(ua_skip_pref)
+# endif
+ C_LDHI REG3,UNIT(3)(a1)
+ PREFETCH_FOR_STORE (4, a0)
+ PREFETCH_FOR_STORE (5, a0)
+L(ua_skip_pref):
+ C_LDHI REG4,UNIT(4)(a1)
+ C_LDHI REG5,UNIT(5)(a1)
+ C_LDHI REG6,UNIT(6)(a1)
+ C_LDHI REG7,UNIT(7)(a1)
+ C_LDLO t0,UNITM1(1)(a1)
+ C_LDLO t1,UNITM1(2)(a1)
+ C_LDLO REG2,UNITM1(3)(a1)
+ C_LDLO REG3,UNITM1(4)(a1)
+ C_LDLO REG4,UNITM1(5)(a1)
+ C_LDLO REG5,UNITM1(6)(a1)
+ C_LDLO REG6,UNITM1(7)(a1)
+ C_LDLO REG7,UNITM1(8)(a1)
+ PREFETCH_FOR_LOAD (4, a1)
+ C_ST t0,UNIT(0)(a0)
+ C_ST t1,UNIT(1)(a0)
+ C_ST REG2,UNIT(2)(a0)
+ C_ST REG3,UNIT(3)(a0)
+ C_ST REG4,UNIT(4)(a0)
+ C_ST REG5,UNIT(5)(a0)
+ C_ST REG6,UNIT(6)(a0)
+ C_ST REG7,UNIT(7)(a0)
+ C_LDHI t0,UNIT(8)(a1)
+ C_LDHI t1,UNIT(9)(a1)
+ C_LDHI REG2,UNIT(10)(a1)
+ C_LDHI REG3,UNIT(11)(a1)
+ C_LDHI REG4,UNIT(12)(a1)
+ C_LDHI REG5,UNIT(13)(a1)
+ C_LDHI REG6,UNIT(14)(a1)
+ C_LDHI REG7,UNIT(15)(a1)
+ C_LDLO t0,UNITM1(9)(a1)
+ C_LDLO t1,UNITM1(10)(a1)
+ C_LDLO REG2,UNITM1(11)(a1)
+ C_LDLO REG3,UNITM1(12)(a1)
+ C_LDLO REG4,UNITM1(13)(a1)
+ C_LDLO REG5,UNITM1(14)(a1)
+ C_LDLO REG6,UNITM1(15)(a1)
+ C_LDLO REG7,UNITM1(16)(a1)
+ PREFETCH_FOR_LOAD (5, a1)
+ C_ST t0,UNIT(8)(a0)
+ C_ST t1,UNIT(9)(a0)
+ C_ST REG2,UNIT(10)(a0)
+ C_ST REG3,UNIT(11)(a0)
+ C_ST REG4,UNIT(12)(a0)
+ C_ST REG5,UNIT(13)(a0)
+ C_ST REG6,UNIT(14)(a0)
+ C_ST REG7,UNIT(15)(a0)
+ PTR_ADDIU a0,a0,UNIT(16) /* adding 64/128 to dest */
+ bne a0,a3,L(ua_loop16w)
+ PTR_ADDIU a1,a1,UNIT(16) /* adding 64/128 to src */
+ move a2,t8
+
+/* Here we have src and dest word-aligned but less than 64-bytes or
+ * 128 bytes to go. Check for a 32(64) byte chunk and copy if if there
+ * is one. Otherwise jump down to L(ua_chk1w) to handle the tail end of
+ * the copy. */
+
+L(ua_chkw):
+ PREFETCH_FOR_LOAD (0, a1)
+ andi t8,a2,NSIZEMASK /* Is there a 32-byte/64-byte chunk. */
+ /* t8 is the reminder count past 32-bytes */
+ beq a2,t8,L(ua_chk1w) /* When a2=t8, no 32-byte chunk */
+ nop
+ C_LDHI t0,UNIT(0)(a1)
+ C_LDHI t1,UNIT(1)(a1)
+ C_LDHI REG2,UNIT(2)(a1)
+ C_LDHI REG3,UNIT(3)(a1)
+ C_LDHI REG4,UNIT(4)(a1)
+ C_LDHI REG5,UNIT(5)(a1)
+ C_LDHI REG6,UNIT(6)(a1)
+ C_LDHI REG7,UNIT(7)(a1)
+ C_LDLO t0,UNITM1(1)(a1)
+ C_LDLO t1,UNITM1(2)(a1)
+ C_LDLO REG2,UNITM1(3)(a1)
+ C_LDLO REG3,UNITM1(4)(a1)
+ C_LDLO REG4,UNITM1(5)(a1)
+ C_LDLO REG5,UNITM1(6)(a1)
+ C_LDLO REG6,UNITM1(7)(a1)
+ C_LDLO REG7,UNITM1(8)(a1)
+ PTR_ADDIU a1,a1,UNIT(8)
+ C_ST t0,UNIT(0)(a0)
+ C_ST t1,UNIT(1)(a0)
+ C_ST REG2,UNIT(2)(a0)
+ C_ST REG3,UNIT(3)(a0)
+ C_ST REG4,UNIT(4)(a0)
+ C_ST REG5,UNIT(5)(a0)
+ C_ST REG6,UNIT(6)(a0)
+ C_ST REG7,UNIT(7)(a0)
+ PTR_ADDIU a0,a0,UNIT(8)
+/*
+ * Here we have less than 32(64) bytes to copy. Set up for a loop to
+ * copy one word (or double word) at a time.
+ */
+L(ua_chk1w):
+ andi a2,t8,(NSIZE-1) /* a2 is the reminder past one (d)word chunks */
+ beq a2,t8,L(ua_smallCopy)
+ PTR_SUBU a3,t8,a2 /* a3 is count of bytes in one (d)word chunks */
+ PTR_ADDU a3,a0,a3 /* a3 is the dst address after loop */
+
+/* copying in words (4-byte or 8-byte chunks) */
+L(ua_wordCopy_loop):
+ C_LDHI v1,UNIT(0)(a1)
+ C_LDLO v1,UNITM1(1)(a1)
+ PTR_ADDIU a0,a0,UNIT(1)
+ PTR_ADDIU a1,a1,UNIT(1)
+ bne a0,a3,L(ua_wordCopy_loop)
+ C_ST v1,UNIT(-1)(a0)
+
+/* Copy the last 8 (or 16) bytes */
+L(ua_smallCopy):
+ beqz a2,L(leave)
+ PTR_ADDU a3,a0,a2 /* a3 is the last dst address */
+L(ua_smallCopy_loop):
+ lb v1,0(a1)
+ PTR_ADDIU a0,a0,1
+ PTR_ADDIU a1,a1,1
+ bne a0,a3,L(ua_smallCopy_loop)
+ sb v1,-1(a0)
+
+ j ra
+ nop
+
+#else /* R6_CODE */
+
+# ifdef __MIPSEB
+# define SWAP_REGS(X,Y) X, Y
+# define ALIGN_OFFSET(N) (N)
+# else
+# define SWAP_REGS(X,Y) Y, X
+# define ALIGN_OFFSET(N) (NSIZE-N)
+# endif
+# define R6_UNALIGNED_WORD_COPY(BYTEOFFSET) \
+ andi REG7, a2, (NSIZE-1);/* REG7 is # of bytes to by bytes. */ \
+ beq REG7, a2, L(lastb); /* Check for bytes to copy by word */ \
+ PTR_SUBU a3, a2, REG7; /* a3 is number of bytes to be copied in */ \
+ /* (d)word chunks. */ \
+ move a2, REG7; /* a2 is # of bytes to copy byte by byte */ \
+ /* after word loop is finished. */ \
+ PTR_ADDU REG6, a0, a3; /* REG6 is the dst address after loop. */ \
+ PTR_SUBU REG2, a1, t8; /* REG2 is the aligned src address. */ \
+ PTR_ADDU a1, a1, a3; /* a1 is addr of source after word loop. */ \
+ C_LD t0, UNIT(0)(REG2); /* Load first part of source. */ \
+L(r6_ua_wordcopy##BYTEOFFSET): \
+ C_LD t1, UNIT(1)(REG2); /* Load second part of source. */ \
+ C_ALIGN REG3, SWAP_REGS(t1,t0), ALIGN_OFFSET(BYTEOFFSET); \
+ PTR_ADDIU a0, a0, UNIT(1); /* Increment destination pointer. */ \
+ PTR_ADDIU REG2, REG2, UNIT(1); /* Increment aligned source pointer.*/ \
+ move t0, t1; /* Move second part of source to first. */ \
+ bne a0, REG6,L(r6_ua_wordcopy##BYTEOFFSET); \
+ C_ST REG3, UNIT(-1)(a0); \
+ j L(lastb); \
+ nop
+
+ /* We are generating R6 code, the destination is 4 byte aligned and
+ the source is not 4 byte aligned. t8 is 1, 2, or 3 depending on the
+ alignment of the source. */
+
+L(r6_unaligned1):
+ R6_UNALIGNED_WORD_COPY(1)
+L(r6_unaligned2):
+ R6_UNALIGNED_WORD_COPY(2)
+L(r6_unaligned3):
+ R6_UNALIGNED_WORD_COPY(3)
+# ifdef USE_DOUBLE
+L(r6_unaligned4):
+ R6_UNALIGNED_WORD_COPY(4)
+L(r6_unaligned5):
+ R6_UNALIGNED_WORD_COPY(5)
+L(r6_unaligned6):
+ R6_UNALIGNED_WORD_COPY(6)
+L(r6_unaligned7):
+ R6_UNALIGNED_WORD_COPY(7)
+# endif
+#endif /* R6_CODE */
+
+ .set at
+ .set reorder
+END(MEMCPY_NAME)
+#ifndef ANDROID_CHANGES
+# ifdef _LIBC
+# ifdef __UCLIBC__
+libc_hidden_def(MEMCPY_NAME)
+# else
+libc_hidden_builtin_def (MEMCPY_NAME)
+# endif
+# endif
+#endif
diff --git a/libc/string/mips/memset.S b/libc/string/mips/memset.S
index ff0554ff9..43034cebb 100644
--- a/libc/string/mips/memset.S
+++ b/libc/string/mips/memset.S
@@ -1,6 +1,5 @@
-/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2013-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
- Contributed by Hartvig Ekner <hartvige@mips.com>, 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
@@ -13,147 +12,420 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 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 <sysdep.h>*/
-#include <endian.h>
-#include "sysdep.h"
+#ifdef ANDROID_CHANGES
+# include "machine/asm.h"
+# include "machine/regdef.h"
+# define PREFETCH_STORE_HINT PREFETCH_HINT_PREPAREFORSTORE
+#elif _LIBC
+# include <sysdep.h>
+# include <sys/regdef.h>
+# include <sys/asm.h>
+# define PREFETCH_STORE_HINT PREFETCH_HINT_PREPAREFORSTORE
+#elif defined _COMPILING_NEWLIB
+# include "machine/asm.h"
+# include "machine/regdef.h"
+# define PREFETCH_STORE_HINT PREFETCH_HINT_PREPAREFORSTORE
+#else
+# include <sys/regdef.h>
+# include <sys/asm.h>
+#endif
+
+/* Check to see if the MIPS architecture we are compiling for supports
+ prefetching. */
+
+#if (__mips == 4) || (__mips == 5) || (__mips == 32) || (__mips == 64)
+# ifndef DISABLE_PREFETCH
+# define USE_PREFETCH
+# endif
+#endif
+
+#if defined(_MIPS_SIM) && ((_MIPS_SIM == _ABI64) || (_MIPS_SIM == _ABIN32))
+# ifndef DISABLE_DOUBLE
+# define USE_DOUBLE
+# endif
+#endif
+
+#ifndef USE_DOUBLE
+# ifndef DISABLE_DOUBLE_ALIGN
+# define DOUBLE_ALIGN
+# endif
+#endif
+
+
+/* Some asm.h files do not have the L macro definition. */
+#ifndef L
+# if _MIPS_SIM == _ABIO32
+# define L(label) $L ## label
+# else
+# define L(label) .L ## label
+# endif
+#endif
+
+/* Some asm.h files do not have the PTR_ADDIU macro definition. */
+#ifndef PTR_ADDIU
+# ifdef USE_DOUBLE
+# define PTR_ADDIU daddiu
+# else
+# define PTR_ADDIU addiu
+# endif
+#endif
-/* void *memset(void *s, int c, size_t n). */
+/* New R6 instructions that may not be in asm.h. */
+#ifndef PTR_LSA
+# if _MIPS_SIM == _ABI64
+# define PTR_LSA dlsa
+# else
+# define PTR_LSA lsa
+# endif
+#endif
+
+/* Using PREFETCH_HINT_PREPAREFORSTORE instead of PREFETCH_STORE
+ or PREFETCH_STORE_STREAMED offers a large performance advantage
+ but PREPAREFORSTORE has some special restrictions to consider.
+
+ Prefetch with the 'prepare for store' hint does not copy a memory
+ location into the cache, it just allocates a cache line and zeros
+ it out. This means that if you do not write to the entire cache
+ line before writing it out to memory some data will get zero'ed out
+ when the cache line is written back to memory and data will be lost.
+
+ There are ifdef'ed sections of this memcpy to make sure that it does not
+ do prefetches on cache lines that are not going to be completely written.
+ This code is only needed and only used when PREFETCH_STORE_HINT is set to
+ PREFETCH_HINT_PREPAREFORSTORE. This code assumes that cache lines are
+ less than MAX_PREFETCH_SIZE bytes and if the cache line is larger it will
+ not work correctly. */
+
+#ifdef USE_PREFETCH
+# define PREFETCH_HINT_STORE 1
+# define PREFETCH_HINT_STORE_STREAMED 5
+# define PREFETCH_HINT_STORE_RETAINED 7
+# define PREFETCH_HINT_PREPAREFORSTORE 30
+
+/* If we have not picked out what hints to use at this point use the
+ standard load and store prefetch hints. */
+# ifndef PREFETCH_STORE_HINT
+# define PREFETCH_STORE_HINT PREFETCH_HINT_STORE
+# endif
+
+/* We double everything when USE_DOUBLE is true so we do 2 prefetches to
+ get 64 bytes in that case. The assumption is that each individual
+ prefetch brings in 32 bytes. */
+# ifdef USE_DOUBLE
+# define PREFETCH_CHUNK 64
+# define PREFETCH_FOR_STORE(chunk, reg) \
+ pref PREFETCH_STORE_HINT, (chunk)*64(reg); \
+ pref PREFETCH_STORE_HINT, ((chunk)*64)+32(reg)
+# else
+# define PREFETCH_CHUNK 32
+# define PREFETCH_FOR_STORE(chunk, reg) \
+ pref PREFETCH_STORE_HINT, (chunk)*32(reg)
+# endif
-#ifdef __mips64
+/* MAX_PREFETCH_SIZE is the maximum size of a prefetch, it must not be less
+ than PREFETCH_CHUNK, the assumed size of each prefetch. If the real size
+ of a prefetch is greater than MAX_PREFETCH_SIZE and the PREPAREFORSTORE
+ hint is used, the code will not work correctly. If PREPAREFORSTORE is not
+ used than MAX_PREFETCH_SIZE does not matter. */
+# define MAX_PREFETCH_SIZE 128
+/* PREFETCH_LIMIT is set based on the fact that we never use an offset greater
+ than 5 on a STORE prefetch and that a single prefetch can never be larger
+ than MAX_PREFETCH_SIZE. We add the extra 32 when USE_DOUBLE is set because
+ we actually do two prefetches in that case, one 32 bytes after the other. */
+# ifdef USE_DOUBLE
+# define PREFETCH_LIMIT (5 * PREFETCH_CHUNK) + 32 + MAX_PREFETCH_SIZE
+# else
+# define PREFETCH_LIMIT (5 * PREFETCH_CHUNK) + MAX_PREFETCH_SIZE
+# endif
-#include <sys/asm.h>
+# if (PREFETCH_STORE_HINT == PREFETCH_HINT_PREPAREFORSTORE) \
+ && ((PREFETCH_CHUNK * 4) < MAX_PREFETCH_SIZE)
+/* We cannot handle this because the initial prefetches may fetch bytes that
+ are before the buffer being copied. We start copies with an offset
+ of 4 so avoid this situation when using PREPAREFORSTORE. */
+# error "PREFETCH_CHUNK is too large and/or MAX_PREFETCH_SIZE is too small."
+# endif
+#else /* USE_PREFETCH not defined */
+# define PREFETCH_FOR_STORE(offset, reg)
+#endif
+
+#if __mips_isa_rev > 5
+# if (PREFETCH_STORE_HINT == PREFETCH_HINT_PREPAREFORSTORE)
+# undef PREFETCH_STORE_HINT
+# define PREFETCH_STORE_HINT PREFETCH_HINT_STORE_STREAMED
+# endif
+# define R6_CODE
+#endif
-#if __BYTE_ORDER == __BIG_ENDIAN
-# define SDHI sdl /* high part is left in big-endian */
+/* Allow the routine to be named something else if desired. */
+#ifndef MEMSET_NAME
+# define MEMSET_NAME memset
+#endif
+
+/* We load/store 64 bits at a time when USE_DOUBLE is true.
+ The C_ prefix stands for CHUNK and is used to avoid macro name
+ conflicts with system header files. */
+
+#ifdef USE_DOUBLE
+# define C_ST sd
+# ifdef __MIPSEB
+# define C_STHI sdl /* high part is left in big-endian */
+# else
+# define C_STHI sdr /* high part is right in little-endian */
+# endif
#else
-# define SDHI sdr /* high part is right in little-endian */
+# define C_ST sw
+# ifdef __MIPSEB
+# define C_STHI swl /* high part is left in big-endian */
+# else
+# define C_STHI swr /* high part is right in little-endian */
+# endif
#endif
-ENTRY (memset)
- .set noreorder
+/* Bookkeeping values for 32 vs. 64 bit mode. */
+#ifdef USE_DOUBLE
+# define NSIZE 8
+# define NSIZEMASK 0x3f
+# define NSIZEDMASK 0x7f
+#else
+# define NSIZE 4
+# define NSIZEMASK 0x1f
+# define NSIZEDMASK 0x3f
+#endif
+#define UNIT(unit) ((unit)*NSIZE)
+#define UNITM1(unit) (((unit)*NSIZE)-1)
- slti ta1, a2, 16 # Less than 16?
- bne ta1, zero, L(last16)
- move v0, a0 # Setup exit value before too late
-
- beq a1, zero, L(ueven) # If zero pattern, no need to extend
- andi a1, 0xff # Avoid problems with bogus arguments
- dsll ta0, a1, 8
- or a1, ta0
- dsll ta0, a1, 16
- or a1, ta0 # a1 is now pattern in full word
- dsll ta0, a1, 32
- or a1, ta0 # a1 is now pattern in double word
-
-L(ueven):
- PTR_SUBU ta0, zero, a0 # Unaligned address?
- andi ta0, 0x7
- beq ta0, zero, L(chkw)
- PTR_SUBU a2, ta0
- SDHI a1, 0(a0) # Yes, handle first unaligned part
- PTR_ADDU a0, ta0 # Now both a0 and a2 are updated
+#ifdef ANDROID_CHANGES
+LEAF(MEMSET_NAME,0)
+#else
+LEAF(MEMSET_NAME)
+#endif
-L(chkw):
- andi ta0, a2, 0xf # Enough left for one loop iteration?
- beq ta0, a2, L(chkl)
- PTR_SUBU a3, a2, ta0
- PTR_ADDU a3, a0 # a3 is last loop address +1
- move a2, ta0 # a2 is now # of bytes left after loop
-L(loopw):
- PTR_ADDIU a0, 16 # Handle 2 dwords pr. iteration
- sd a1, -16(a0)
- bne a0, a3, L(loopw)
- sd a1, -8(a0)
-
-L(chkl):
- andi ta0, a2, 0x8 # Check if there is at least a double
- beq ta0, zero, L(last16) # word remaining after the loop
- PTR_SUBU a2, ta0
- sd a1, 0(a0) # Yes...
- PTR_ADDIU a0, 8
-
-L(last16):
- blez a2, L(exit) # Handle last 16 bytes (if cnt>0)
- PTR_ADDU a3, a2, a0 # a3 is last address +1
-L(lst16l):
- PTR_ADDIU a0, 1
- bne a0, a3, L(lst16l)
- sb a1, -1(a0)
-L(exit):
- j ra # Bye, bye
+ .set nomips16
+ .set noreorder
+/* If the size is less than 2*NSIZE (8 or 16), go to L(lastb). Regardless of
+ size, copy dst pointer to v0 for the return value. */
+ slti t2,a2,(2 * NSIZE)
+ bne t2,zero,L(lastb)
+ move v0,a0
+
+/* If memset value is not zero, we copy it to all the bytes in a 32 or 64
+ bit word. */
+ beq a1,zero,L(set0) /* If memset value is zero no smear */
+ PTR_SUBU a3,zero,a0
nop
- .set reorder
-END (memset)
+ /* smear byte into 32 or 64 bit word */
+#if ((__mips == 64) || (__mips == 32)) && (__mips_isa_rev >= 2)
+# ifdef USE_DOUBLE
+ dins a1, a1, 8, 8 /* Replicate fill byte into half-word. */
+ dins a1, a1, 16, 16 /* Replicate fill byte into word. */
+ dins a1, a1, 32, 32 /* Replicate fill byte into dbl word. */
+# else
+ ins a1, a1, 8, 8 /* Replicate fill byte into half-word. */
+ ins a1, a1, 16, 16 /* Replicate fill byte into word. */
+# endif
+#else
+# ifdef USE_DOUBLE
+ and a1,0xff
+ dsll t2,a1,8
+ or a1,t2
+ dsll t2,a1,16
+ or a1,t2
+ dsll t2,a1,32
+ or a1,t2
+# else
+ and a1,0xff
+ sll t2,a1,8
+ or a1,t2
+ sll t2,a1,16
+ or a1,t2
+# endif
+#endif
+
+/* If the destination address is not aligned do a partial store to get it
+ aligned. If it is already aligned just jump to L(aligned). */
+L(set0):
+#ifndef R6_CODE
+ andi t2,a3,(NSIZE-1) /* word-unaligned address? */
+ beq t2,zero,L(aligned) /* t2 is the unalignment count */
+ PTR_SUBU a2,a2,t2
+ C_STHI a1,0(a0)
+ PTR_ADDU a0,a0,t2
+#else /* R6_CODE */
+ andi t2,a0,(NSIZE-1)
+ lapc t9,L(atable)
+ PTR_LSA t9,t2,t9,2
+ jrc t9
+L(atable):
+ bc L(aligned)
+# ifdef USE_DOUBLE
+ bc L(lb7)
+ bc L(lb6)
+ bc L(lb5)
+ bc L(lb4)
+# endif
+ bc L(lb3)
+ bc L(lb2)
+ bc L(lb1)
+L(lb7):
+ sb a1,6(a0)
+L(lb6):
+ sb a1,5(a0)
+L(lb5):
+ sb a1,4(a0)
+L(lb4):
+ sb a1,3(a0)
+L(lb3):
+ sb a1,2(a0)
+L(lb2):
+ sb a1,1(a0)
+L(lb1):
+ sb a1,0(a0)
+
+ li t9,NSIZE
+ subu t2,t9,t2
+ PTR_SUBU a2,a2,t2
+ PTR_ADDU a0,a0,t2
+#endif /* R6_CODE */
+
+L(aligned):
+/* If USE_DOUBLE is not set we may still want to align the data on a 16
+ byte boundry instead of an 8 byte boundry to maximize the opportunity
+ of proAptiv chips to do memory bonding (combining two sequential 4
+ byte stores into one 8 byte store). We know there are at least 4 bytes
+ left to store or we would have jumped to L(lastb) earlier in the code. */
+#ifdef DOUBLE_ALIGN
+ andi t2,a3,4
+ beq t2,zero,L(double_aligned)
+ PTR_SUBU a2,a2,t2
+ sw a1,0(a0)
+ PTR_ADDU a0,a0,t2
+L(double_aligned):
+#endif
-#else /* !__mips64 */
+/* Now the destination is aligned to (word or double word) aligned address
+ Set a2 to count how many bytes we have to copy after all the 64/128 byte
+ chunks are copied and a3 to the dest pointer after all the 64/128 byte
+ chunks have been copied. We will loop, incrementing a0 until it equals
+ a3. */
+ andi t8,a2,NSIZEDMASK /* any whole 64-byte/128-byte chunks? */
+ beq a2,t8,L(chkw) /* if a2==t8, no 64-byte/128-byte chunks */
+ PTR_SUBU a3,a2,t8 /* subtract from a2 the reminder */
+ PTR_ADDU a3,a0,a3 /* Now a3 is the final dst after loop */
-#if __BYTE_ORDER == __BIG_ENDIAN
-# define SWHI swl /* high part is left in big-endian */
+/* When in the loop we may prefetch with the 'prepare to store' hint,
+ in this case the a0+x should not be past the "t0-32" address. This
+ means: for x=128 the last "safe" a0 address is "t0-160". Alternatively,
+ for x=64 the last "safe" a0 address is "t0-96" In the current version we
+ will use "prefetch hint,128(a0)", so "t0-160" is the limit. */
+#if defined(USE_PREFETCH) \
+ && (PREFETCH_STORE_HINT == PREFETCH_HINT_PREPAREFORSTORE)
+ PTR_ADDU t0,a0,a2 /* t0 is the "past the end" address */
+ PTR_SUBU t9,t0,PREFETCH_LIMIT /* t9 is the "last safe pref" address */
+#endif
+#if defined(USE_PREFETCH) \
+ && (PREFETCH_STORE_HINT != PREFETCH_HINT_PREPAREFORSTORE)
+ PREFETCH_FOR_STORE (1, a0)
+ PREFETCH_FOR_STORE (2, a0)
+ PREFETCH_FOR_STORE (3, a0)
+#endif
+
+L(loop16w):
+#if defined(USE_PREFETCH) \
+ && (PREFETCH_STORE_HINT == PREFETCH_HINT_PREPAREFORSTORE)
+ sltu v1,t9,a0 /* If a0 > t9 don't use next prefetch */
+ bgtz v1,L(skip_pref)
+ nop
+#endif
+#ifdef R6_CODE
+ PREFETCH_FOR_STORE (2, a0)
#else
-# define SWHI swr /* high part is right in little-endian */
+ PREFETCH_FOR_STORE (4, a0)
+ PREFETCH_FOR_STORE (5, a0)
#endif
+L(skip_pref):
+ C_ST a1,UNIT(0)(a0)
+ C_ST a1,UNIT(1)(a0)
+ C_ST a1,UNIT(2)(a0)
+ C_ST a1,UNIT(3)(a0)
+ C_ST a1,UNIT(4)(a0)
+ C_ST a1,UNIT(5)(a0)
+ C_ST a1,UNIT(6)(a0)
+ C_ST a1,UNIT(7)(a0)
+ C_ST a1,UNIT(8)(a0)
+ C_ST a1,UNIT(9)(a0)
+ C_ST a1,UNIT(10)(a0)
+ C_ST a1,UNIT(11)(a0)
+ C_ST a1,UNIT(12)(a0)
+ C_ST a1,UNIT(13)(a0)
+ C_ST a1,UNIT(14)(a0)
+ C_ST a1,UNIT(15)(a0)
+ PTR_ADDIU a0,a0,UNIT(16) /* adding 64/128 to dest */
+ bne a0,a3,L(loop16w)
+ nop
+ move a2,t8
-ENTRY (memset)
- .set noreorder
+/* Here we have dest word-aligned but less than 64-bytes or 128 bytes to go.
+ Check for a 32(64) byte chunk and copy if if there is one. Otherwise
+ jump down to L(chk1w) to handle the tail end of the copy. */
+L(chkw):
+ andi t8,a2,NSIZEMASK /* is there a 32-byte/64-byte chunk. */
+ /* the t8 is the reminder count past 32-bytes */
+ beq a2,t8,L(chk1w)/* when a2==t8, no 32-byte chunk */
+ nop
+ C_ST a1,UNIT(0)(a0)
+ C_ST a1,UNIT(1)(a0)
+ C_ST a1,UNIT(2)(a0)
+ C_ST a1,UNIT(3)(a0)
+ C_ST a1,UNIT(4)(a0)
+ C_ST a1,UNIT(5)(a0)
+ C_ST a1,UNIT(6)(a0)
+ C_ST a1,UNIT(7)(a0)
+ PTR_ADDIU a0,a0,UNIT(8)
+
+/* Here we have less than 32(64) bytes to set. Set up for a loop to
+ copy one word (or double word) at a time. Set a2 to count how many
+ bytes we have to copy after all the word (or double word) chunks are
+ copied and a3 to the dest pointer after all the (d)word chunks have
+ been copied. We will loop, incrementing a0 until a0 equals a3. */
+L(chk1w):
+ andi a2,t8,(NSIZE-1) /* a2 is the reminder past one (d)word chunks */
+ beq a2,t8,L(lastb)
+ PTR_SUBU a3,t8,a2 /* a3 is count of bytes in one (d)word chunks */
+ PTR_ADDU a3,a0,a3 /* a3 is the dst address after loop */
- slti t1, a2, 8 # Less than 8?
- bne t1, zero, L(last8)
- move v0, a0 # Setup exit value before too late
-
- beq a1, zero, L(ueven) # If zero pattern, no need to extend
- andi a1, 0xff # Avoid problems with bogus arguments
- sll t0, a1, 8
- or a1, t0
- sll t0, a1, 16
- or a1, t0 # a1 is now pattern in full word
-
-L(ueven):
- subu t0, zero, a0 # Unaligned address?
- andi t0, 0x3
- beq t0, zero, L(chkw)
- subu a2, t0
- SWHI a1, 0(a0) # Yes, handle first unaligned part
- addu a0, t0 # Now both a0 and a2 are updated
-
-L(chkw):
- andi t0, a2, 0x7 # Enough left for one loop iteration?
- beq t0, a2, L(chkl)
- subu a3, a2, t0
- addu a3, a0 # a3 is last loop address +1
- move a2, t0 # a2 is now # of bytes left after loop
-L(loopw):
- addiu a0, 8 # Handle 2 words pr. iteration
- sw a1, -8(a0)
- bne a0, a3, L(loopw)
- sw a1, -4(a0)
-
-L(chkl):
- andi t0, a2, 0x4 # Check if there is at least a full
- beq t0, zero, L(last8) # word remaining after the loop
- subu a2, t0
- sw a1, 0(a0) # Yes...
- addiu a0, 4
-
-L(last8):
- blez a2, L(exit) # Handle last 8 bytes (if cnt>0)
- addu a3, a2, a0 # a3 is last address +1
-L(lst8l):
- addiu a0, 1
- bne a0, a3, L(lst8l)
- sb a1, -1(a0)
-L(exit):
- j ra # Bye, bye
+/* copying in words (4-byte or 8 byte chunks) */
+L(wordCopy_loop):
+ PTR_ADDIU a0,a0,UNIT(1)
+ bne a0,a3,L(wordCopy_loop)
+ C_ST a1,UNIT(-1)(a0)
+
+/* Copy the last 8 (or 16) bytes */
+L(lastb):
+ blez a2,L(leave)
+ PTR_ADDU a3,a0,a2 /* a3 is the last dst address */
+L(lastbloop):
+ PTR_ADDIU a0,a0,1
+ bne a0,a3,L(lastbloop)
+ sb a1,-1(a0)
+L(leave):
+ j ra
nop
+ .set at
.set reorder
-END (memset)
-
-#endif /* !__mips64 */
+END(MEMSET_NAME)
+#ifndef ANDROID_CHANGES
+# ifdef _LIBC
+# ifdef __UCLIBC__
+libc_hidden_def(MEMSET_NAME)
+# else
+libc_hidden_builtin_def (MEMSET_NAME)
+# endif
+# endif
+#endif
-libc_hidden_def(memset)
diff --git a/libc/string/mips/sysdep.h b/libc/string/mips/sysdep.h
deleted file mode 100644
index 5dad8342e..000000000
--- a/libc/string/mips/sysdep.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* Adapted from glibc's sysdeps/unix/mips/sysdep.h */
-
-/* Copyright (C) 1992, 1995, 1997, 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, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#ifdef __ASSEMBLER__
-
-#include <sgidefs.h>
-#include <sys/regdef.h>
-
-#define ENTRY(name) \
- .globl name; \
- .align 2; \
- .ent name,0; \
- name/* use a comment rather than ## to workaround bug in gcc-3.4.x */:
-
-#undef END
-#define END(function) \
- .end function; \
- .size function,.-function
-
-#if _MIPS_SIM == _MIPS_SIM_ABI32 || _MIPS_SIM == _MIPS_SIM_ABIO64
-# define L(label) $L ## label
-#else
-# define L(label) .L ## label
-#endif
-
-#endif
diff --git a/libc/string/powerpc/memcpy.c b/libc/string/powerpc/memcpy.c
index f3d800739..22794ec33 100644
--- a/libc/string/powerpc/memcpy.c
+++ b/libc/string/powerpc/memcpy.c
@@ -21,16 +21,15 @@
#include <string.h>
-/* Experimentally off - libc_hidden_proto(memcpy) */
-void *memcpy(void *to, const void *from, size_t n)
-/* PPC can do pre increment and load/store, but not post increment and load/store.
- Therefore use *++ptr instead of *ptr++. */
+/* PPC can do pre increment and load/store, but not post increment and
+ load/store. Therefore use *++ptr instead of *ptr++. */
+void *memcpy(void *to, const void *from, size_t len)
{
unsigned long rem, chunks, tmp1, tmp2;
unsigned char *tmp_to;
unsigned char *tmp_from = (unsigned char *)from;
- chunks = n / 8;
+ chunks = len / 8;
tmp_from -= 4;
tmp_to = to - 4;
if (!chunks)
@@ -49,30 +48,33 @@ void *memcpy(void *to, const void *from, size_t n)
*(unsigned long *)tmp_to = tmp2;
} while (--chunks);
lessthan8:
- n = n % 8;
- if (n >= 4) {
- *(unsigned long *)(tmp_to+4) = *(unsigned long *)(tmp_from+4);
+ len = len % 8;
+ if (len >= 4) {
tmp_from += 4;
tmp_to += 4;
- n = n-4;
+ *(unsigned long *)(tmp_to) = *(unsigned long *)(tmp_from);
+ len -= 4;
}
- if (!n ) return to;
+ if (!len)
+ return to;
tmp_from += 3;
tmp_to += 3;
do {
*++tmp_to = *++tmp_from;
- } while (--n);
+ } while (--len);
return to;
align:
+ /* ???: Do we really need to generate the carry flag here? If not, then:
+ rem -= 4; */
rem = 4 - rem;
- n = n - rem;
+ len -= rem;
do {
*(tmp_to+4) = *(tmp_from+4);
++tmp_from;
++tmp_to;
} while (--rem);
- chunks = n / 8;
+ chunks = len / 8;
if (chunks)
goto copy_chunks;
goto lessthan8;
diff --git a/libc/string/powerpc/memmove.c b/libc/string/powerpc/memmove.c
index 8badae37d..6bd79915d 100644
--- a/libc/string/powerpc/memmove.c
+++ b/libc/string/powerpc/memmove.c
@@ -21,9 +21,7 @@
#include <string.h>
-/* Experimentally off - libc_hidden_proto(memcpy) */
-/* Experimentally off - libc_hidden_proto(memmove) */
void *memmove(void *to, const void *from, size_t n)
{
unsigned long rem, chunks, tmp1, tmp2;
diff --git a/libc/string/powerpc/memset.c b/libc/string/powerpc/memset.c
index 1cbfd04fc..a900b92cb 100644
--- a/libc/string/powerpc/memset.c
+++ b/libc/string/powerpc/memset.c
@@ -21,7 +21,6 @@
#include <string.h>
-/* Experimentally off - libc_hidden_proto(memset) */
static __inline__ int expand_byte_word(int c){
/* this does:
diff --git a/libc/string/psignal.c b/libc/string/psignal.c
index 1ca8725db..3e1f68b94 100644
--- a/libc/string/psignal.c
+++ b/libc/string/psignal.c
@@ -10,8 +10,6 @@
#include <string.h>
#include <signal.h>
-libc_hidden_proto(fprintf)
-/* Experimentally off - libc_hidden_proto(strsignal) */
/* TODO: make this threadsafe with a reentrant version of strsignal? */
diff --git a/libc/string/rawmemchr.c b/libc/string/rawmemchr.c
index 3cddefa10..f0cb7ee47 100644
--- a/libc/string/rawmemchr.c
+++ b/libc/string/rawmemchr.c
@@ -8,7 +8,6 @@
#include "_string.h"
#ifdef __USE_GNU
-/* Experimentally off - libc_hidden_proto(rawmemchr) */
void *rawmemchr(const void *s, int c)
{
register const unsigned char *r = s;
diff --git a/libc/string/sh/memchr.S b/libc/string/sh/memchr.S
new file mode 100644
index 000000000..6b7142f69
--- /dev/null
+++ b/libc/string/sh/memchr.S
@@ -0,0 +1,30 @@
+/* $Id: memchr.S,v 1.1 2000/04/14 16:49:01 mjd Exp $
+ *
+ * "memchr" implementation of SuperH
+ *
+ * Copyright (C) 1999 Niibe Yutaka
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+/*
+ * void *memchr(const void *s, int c, size_t n);
+ */
+
+#include <sysdep.h>
+
+ENTRY(memchr)
+ tst r6,r6
+ bt/s 2f
+ exts.b r5,r5
+1: mov.b @r4,r1
+ cmp/eq r1,r5
+ bt/s 3f
+ dt r6
+ bf/s 1b
+ add #1,r4
+2: mov #0,r4
+3: rts
+ mov r4,r0
+END(memchr)
+libc_hidden_def (memchr)
diff --git a/libc/string/sh/sh4/memcpy.S b/libc/string/sh/sh4/memcpy.S
index 2d918293e..6a229a06c 100644
--- a/libc/string/sh/sh4/memcpy.S
+++ b/libc/string/sh/sh4/memcpy.S
@@ -6,6 +6,9 @@
* Modified from memcpy.S and micro-optimised for SH4
* Stuart Menefy (stuart.menefy@st.com)
*
+ * Copyright (c) 2009 STMicroelectronics Ltd
+ * Optimised using prefetching and 64bit data transfer via FPU
+ * Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
*/
/*
@@ -15,8 +18,32 @@
* If there is an overlap, then the results are undefined.
*/
+#include <sysdep.h>
#include <endian.h>
+#if defined (__LITTLE_ENDIAN__) && defined (__SH_FPU_ANY__)
+#define MEMCPY_USES_FPU
+/* Use paired single precision load or store mode for 64-bit tranfering.
+ * FPSCR.SZ=1,FPSCR.SZ=0 is well defined on both SH4-200 and SH4-300.
+ * Currenlty it has been only implemented and tested for little endian mode. */
+.macro FPU_SET_PAIRED_PREC
+ sts fpscr, r7
+ mov #0x10, r0 ! PR=0 SZ=1
+ shll16 r0
+ lds r0, fpscr
+.endm
+.macro RESTORE_FPSCR
+ lds r7, fpscr
+.endm
+.macro DALLOC
+ ! Cache allocate + store on dst-32.
+ add #-32, r1
+ movca.l r0, @r1
+ add #32, r1
+.endm
+
+#endif
+
!
! GHIJ KLMN OPQR --> ...G HIJK LMNO PQR.
!
@@ -127,10 +154,10 @@
mov.l r3,@-r0 ! 30 LS
#else
-3: mov r1,r3 ! OPQR
+3: mov r7,r3 ! OPQR
shlr8 r3 ! xOPQ
- mov.l @(r0,r5),r1 ! KLMN
- mov r1,r6
+ mov.l @(r0,r5),r7 ! KLMN
+ mov r7,r6
shll16 r6
shll8 r6 ! Nxxx
or r6,r3 ! NOPQ
@@ -157,12 +184,7 @@
9: rts
nop
-/* void * memcpy(void *dst, const void *src, size_t len) */
-.text
-.align 4
-.type memcpy,@function
-.globl memcpy;
-memcpy:
+ENTRY(memcpy)
! Calculate the invariants which will be used in the remainder
! of the code:
@@ -189,9 +211,7 @@ memcpy:
mov r4, r0 ! 5 MT (0 cycle latency)
add r6, r0 ! 49 EX
- mov #16, r1 ! 6 EX
bt/s .Lcase00 ! 111 BR (aligned)
-
sub r4, r5 ! 75 EX
! Arguments are not nicely long word aligned or zero len.
@@ -207,6 +227,7 @@ memcpy:
! However the penalty for getting it 'wrong' is much higher for long word
! aligned data (and this is more common), so use a value of 16.
+ mov #16, r1 ! 6 EX
cmp/gt r6,r1 ! 56 MT
add #-1,r5 ! 50 EX
@@ -447,6 +468,183 @@ memcpy:
mov.l r7, @-r0 ! 30 LS
+#ifdef MEMCPY_USES_FPU
+ ! Copy the cache line aligned blocks by using the FPU registers.
+ ! If src and dst are well aligned adopt 64-bit data transfer.
+ ! We also need r0 as a temporary (for movca), so 'undo' the invariant:
+ ! r5: src (was r0+r5)
+ ! r1: dest (was r0)
+1:
+ add r0, r5
+ mov r0, r1
+
+ mov r1, r3 ! MT
+ sub r2, r3 ! EX (r3 - r2 -> r3)
+ mov #-5, r0
+ shld r0, r3 ! number of the cache lines
+
+ mov #8, r0
+ cmp/ge r0, r3 ! Check if there are many cache lines to copy.
+ bf 45f ! Copy cache line aligned blocks without pref.
+ mov r5, r0
+ add #-0x7c, r0
+ tst #7, r0 ! src is 8byte aligned
+ bf 45f
+
+ ! Many cache lines have to be copied and the buffers are well aligned.
+ ! Aggressive prefetching and FPU in single paired precision.
+ mov r0, r5
+ mov r5, r6
+ add #-0x80, r6 ! prefetch head
+
+ ! store FPU (in single precision mode, do not check R15 align).
+ fmov fr12, @-r15
+ fmov fr13, @-r15
+ fmov fr14, @-r15
+ fmov fr15, @-r15
+
+ FPU_SET_PAIRED_PREC
+
+ mov #4, r0
+67:
+ add #-0x20, r6
+ pref @r6
+ add #-0x20, r6
+ pref @r6
+
+ fmov @r5+, dr0
+ fmov @r5+, dr2
+ fmov @r5+, dr4
+ fmov @r5+, dr6
+ fmov @r5+, dr8
+ fmov @r5+, dr10
+ fmov @r5+, dr12
+ fmov @r5+, dr14
+ fmov @r5+, xd0
+ fmov @r5+, xd2
+ fmov @r5+, xd4
+ fmov @r5+, xd6
+ fmov @r5+, xd8
+ fmov @r5+, xd10
+ fmov @r5+, xd12
+ fmov @r5+, xd14
+
+ DALLOC
+ fmov xd14, @-r1
+ fmov xd12, @-r1
+ fmov xd10, @-r1
+ fmov xd8, @-r1
+ DALLOC
+ fmov xd6, @-r1
+ fmov xd4, @-r1
+ fmov xd2, @-r1
+ fmov xd0, @-r1
+ DALLOC
+ fmov dr14, @-r1
+ fmov dr12, @-r1
+ fmov dr10, @-r1
+ fmov dr8, @-r1
+ DALLOC
+ fmov dr6, @-r1
+ add #-0x80, r5
+ fmov dr4, @-r1
+ add #-0x80, r5
+ fmov dr2, @-r1
+ add #-0x20, r6
+ fmov dr0, @-r1
+ add #-4, r3
+ pref @r6
+ add #-0x20, r6
+ cmp/ge r0, r3
+ bt/s 67b
+ pref @r6
+
+ RESTORE_FPSCR
+
+ ! Restore FPU callee save registers
+ fmov @r15+, fr15
+ fmov @r15+, fr14
+ fmov @r15+, fr13
+ fmov @r15+, fr12
+
+ ! Other cache lines could be copied: so use the FPU in single paired
+ ! precision without prefetching. No check for alignment is necessary.
+
+ mov #1, r0
+ cmp/ge r0, r3
+ bt/s 3f
+ add #0x60, r5
+
+ bra 5f
+ nop
+
+ ! No prefetch and FPU in single precision.
+45:
+ add #-0x1c, r5
+ mov r5, r0
+ tst #7, r0
+ bt 3f
+
+2: fmov.s @r5+, fr0
+ fmov.s @r5+, fr1
+ fmov.s @r5+, fr2
+ fmov.s @r5+, fr3
+ fmov.s @r5+, fr4
+ fmov.s @r5+, fr5
+ fmov.s @r5+, fr6
+ fmov.s @r5+, fr7
+
+ DALLOC
+
+ fmov.s fr7, @-r1
+ fmov.s fr6, @-r1
+ fmov.s fr5, @-r1
+ fmov.s fr4, @-r1
+ fmov.s fr3, @-r1
+ fmov.s fr2, @-r1
+ fmov.s fr1, @-r1
+ fmov.s fr0, @-r1
+
+ cmp/eq r2,r1
+
+ bf/s 2b
+ add #-0x40, r5
+
+ bra 5f
+ nop
+
+ ! No prefetch and FPU in single paired precision.
+
+3: FPU_SET_PAIRED_PREC
+
+4: fmov @r5+, dr0
+ fmov @r5+, dr2
+ fmov @r5+, dr4
+ fmov @r5+, dr6
+
+ DALLOC
+
+ fmov dr6, @-r1
+ fmov dr4, @-r1
+ fmov dr2, @-r1
+ fmov dr0, @-r1
+ cmp/eq r2,r1
+
+ bf/s 4b
+ add #-0x40, r5
+
+ RESTORE_FPSCR
+
+5: mov r1, r0
+
+ cmp/eq r4, r0 ! 54 MT
+ bf/s 1f ! 109 BR
+ sub r1, r5 ! 75 EX
+
+ rts
+ nop
+1:
+#else
! Copy the cache line aligned blocks
!
! In use: r0, r2, r4, r5
@@ -512,6 +710,7 @@ memcpy:
rts
1: mov.l @r15+, r8 ! 15 LS
+#endif
sub r4, r1 ! 75 EX (len remaining)
! number of trailing bytes is non-zero
@@ -733,30 +932,30 @@ memcpy:
mov.l @(0x04,r5), r11 ! 18 LS (latency=2)
xtrct r9, r8 ! 48 EX
- mov.w @(0x02,r5), r12 ! 18 LS (latency=2)
+ mov.l @(0x00,r5), r12 ! 18 LS (latency=2)
xtrct r10, r9 ! 48 EX
movca.l r0,@r1 ! 40 LS (latency=3-7)
add #-0x1c, r1 ! 50 EX
- mov.l r3, @(0x1c,r1) ! 33 LS
+ mov.l r3, @(0x18,r1) ! 33 LS
xtrct r11, r10 ! 48 EX
- mov.l r6, @(0x18,r1) ! 33 LS
+ mov.l r6, @(0x14,r1) ! 33 LS
xtrct r12, r11 ! 48 EX
- mov.l r7, @(0x14,r1) ! 33 LS
+ mov.l r7, @(0x10,r1) ! 33 LS
- mov.l r8, @(0x10,r1) ! 33 LS
- add #-0x3e, r5 ! 50 EX
+ mov.l r8, @(0x0c,r1) ! 33 LS
+ add #-0x1e, r5 ! 50 EX
- mov.l r9, @(0x0c,r1) ! 33 LS
+ mov.l r9, @(0x08,r1) ! 33 LS
cmp/eq r2,r1 ! 54 MT
- mov.l r10, @(0x08,r1) ! 33 LS
+ mov.l r10, @(0x04,r1) ! 33 LS
bf/s 2b ! 109 BR
- mov.l r11, @(0x04,r1) ! 33 LS
+ mov.l r11, @(0x00,r1) ! 33 LS
#endif
mov.l @r15+, r12
@@ -803,6 +1002,5 @@ memcpy:
rts
mov.b r1,@-r0
-.size memcpy,.-memcpy;
-
+END(memcpy)
libc_hidden_def (memcpy)
diff --git a/libc/string/sh/sh4/memmove.c b/libc/string/sh/sh4/memmove.c
new file mode 100644
index 000000000..8059bd4cc
--- /dev/null
+++ b/libc/string/sh/sh4/memmove.c
@@ -0,0 +1,121 @@
+/* memmove implementation for SH4
+ *
+ * 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.
+ */
+
+#ifndef __SH_FPU_ANY__
+#include "../../generic/memmove.c"
+#else
+
+#include <string.h>
+
+#define FPSCR_SR (1 << 20)
+#define STORE_FPSCR(x) __asm__ __volatile__("sts fpscr, %0" : "=r"(x))
+#define LOAD_FPSCR(x) __asm__ __volatile__("lds %0, fpscr" : : "r"(x))
+
+static void fpu_optimised_copy_fwd(void *dest, const void *src, size_t len)
+{
+ char *d = (char *)dest;
+ char *s = (char *)src;
+
+ if (len >= 64) {
+ unsigned long fpscr;
+ int *s1;
+ int *d1;
+
+ /* Align the dest to 4 byte boundary. */
+ while ((unsigned)d & 0x7) {
+ *d++ = *s++;
+ len--;
+ }
+
+ s1 = (int *)s;
+ d1 = (int *)d;
+
+ /* check if s is well aligned to use FPU */
+ if (!((unsigned)s1 & 0x7)) {
+
+ /* Align the dest to cache-line boundary */
+ while ((unsigned)d1 & 0x1c) {
+ *d1++ = *s1++;
+ len -= 4;
+ }
+
+ /* Use paired single precision load or store mode for
+ * 64-bit tranfering.*/
+ STORE_FPSCR(fpscr);
+ LOAD_FPSCR(FPSCR_SR);
+
+ while (len >= 32) {
+ __asm__ __volatile__ ("fmov @%0+,dr0":"+r" (s1));
+ __asm__ __volatile__ ("fmov @%0+,dr2":"+r" (s1));
+ __asm__ __volatile__ ("fmov @%0+,dr4":"+r" (s1));
+ __asm__ __volatile__ ("fmov @%0+,dr6":"+r" (s1));
+ __asm__
+ __volatile__ ("fmov dr0,@%0"::"r"
+ (d1):"memory");
+ d1 += 2;
+ __asm__
+ __volatile__ ("fmov dr2,@%0"::"r"
+ (d1):"memory");
+ d1 += 2;
+ __asm__
+ __volatile__ ("fmov dr4,@%0"::"r"
+ (d1):"memory");
+ d1 += 2;
+ __asm__
+ __volatile__ ("fmov dr6,@%0"::"r"
+ (d1):"memory");
+ d1 += 2;
+ len -= 32;
+ }
+ LOAD_FPSCR(fpscr);
+ }
+ s = (char *)s1;
+ d = (char *)d1;
+ /*TODO: other subcases could be covered here?!?*/
+ }
+ /* Go to per-byte copy */
+ while (len > 0) {
+ *d++ = *s++;
+ len--;
+ }
+ return;
+}
+
+void *memmove(void *dest, const void *src, size_t len)
+{
+ unsigned long int d = (long int)dest;
+ unsigned long int s = (long int)src;
+ unsigned long int res;
+
+ if (d >= s)
+ res = d - s;
+ else
+ res = s - d;
+ /*
+ * 1) dest and src are not overlap ==> memcpy (BWD/FDW)
+ * 2) dest and src are 100% overlap ==> memcpy (BWD/FDW)
+ * 3) left-to-right overlap ==> Copy from the beginning to the end
+ * 4) right-to-left overlap ==> Copy from the end to the beginning
+ */
+
+ if (res == 0) /* 100% overlap */
+ memcpy(dest, src, len); /* No overlap */
+ else if (res >= len)
+ memcpy(dest, src, len);
+ else {
+ if (d > s) /* right-to-left overlap */
+ memcpy(dest, src, len); /* memcpy is BWD */
+ else /* cannot use SH4 memcpy for this case */
+ fpu_optimised_copy_fwd(dest, src, len);
+ }
+ return (dest);
+}
+
+libc_hidden_def(memmove)
+#endif /*__SH_FPU_ANY__ */
diff --git a/libc/string/sh/sh4/memset.S b/libc/string/sh/sh4/memset.S
new file mode 100644
index 000000000..eb83355ce
--- /dev/null
+++ b/libc/string/sh/sh4/memset.S
@@ -0,0 +1,152 @@
+/* $Id: memset.S,v 1.1 2000/04/14 16:49:01 mjd Exp $
+ *
+ * "memset" implementation of SuperH
+ *
+ * Copyright (C) 1999 Niibe Yutaka
+ *
+ * Copyright (c) 2009 STMicroelectronics Ltd
+ * Optimised using 64bit data transfer (via FPU) and the movca.l inst.
+ * Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+/*
+ * void *memset(void *s, int c, size_t n);
+ */
+
+#include <sysdep.h>
+
+#if defined (__LITTLE_ENDIAN__) && defined (__SH_FPU_ANY__)
+#define MEMSET_USES_FPU
+/* Use paired single precision load or store mode for 64-bit tranfering.
+ * FPSCR.SZ=1,FPSCR.SZ=0 is well defined on both SH4-200 and SH4-300.
+ * Currenlty it has been only implemented and tested for little endian mode. */
+.macro FPU_SET_PAIRED_PREC
+ sts fpscr, r3
+ mov #0x10, r1 ! PR=0 SZ=1
+ shll16 r1
+ lds r1, fpscr
+.endm
+.macro RESTORE_FPSCR
+ lds r3, fpscr
+.endm
+#endif
+
+ENTRY(memset)
+ mov #12,r0
+ add r6,r4
+ cmp/gt r6,r0
+ bt/s 40f ! if it's too small, set a byte at once
+ mov r4,r0
+ and #3,r0
+ cmp/eq #0,r0
+ bt/s 2f ! It's aligned
+ sub r0,r6
+1:
+ dt r0
+ bf/s 1b
+ mov.b r5,@-r4
+2: ! make VVVV
+ extu.b r5,r5
+ swap.b r5,r0 ! V0
+ or r0,r5 ! VV
+ swap.w r5,r0 ! VV00
+ or r0,r5 ! VVVV
+
+ ! Check if enough bytes need to be copied to be worth the big loop
+ mov #0x40, r0 ! (MT)
+ cmp/gt r6,r0 ! (MT) 64 > len => slow loop
+
+ bt/s 22f
+ mov r6,r0
+
+ ! align the dst to the cache block size if necessary
+ mov r4, r3
+ mov #~(0x1f), r1
+
+ and r3, r1
+ cmp/eq r3, r1
+
+ bt/s 11f ! dst is already aligned
+ sub r1, r3 ! r3-r1 -> r3
+ shlr2 r3 ! number of loops
+
+10: mov.l r5,@-r4
+ dt r3
+ bf/s 10b
+ add #-4, r6
+
+11: ! dst is 32byte aligned
+ mov r6,r2
+ mov #-5,r0
+ shld r0,r2 ! number of loops
+
+ add #-32, r4
+ mov r5, r0
+
+#ifdef MEMSET_USES_FPU
+ lds r5, fpul ! (CO)
+ fsts fpul, fr0 ! Dr0 will be 'VVVVVVVV'
+ fsts fpul, fr1
+
+ FPU_SET_PAIRED_PREC
+12:
+ movca.l r0, @r4
+ mov.l r5, @(4, r4)
+ add #32, r4
+ fmov dr0, @-r4
+ fmov dr0, @-r4
+ add #-0x20, r6
+ fmov dr0, @-r4
+ dt r2
+ bf/s 12b
+ add #-40, r4
+
+ RESTORE_FPSCR
+#else
+12:
+ movca.l r0,@r4
+ mov.l r5,@(4, r4)
+ mov.l r5,@(8, r4)
+ mov.l r5,@(12,r4)
+ mov.l r5,@(16,r4)
+ mov.l r5,@(20,r4)
+ add #-0x20, r6
+ mov.l r5,@(24,r4)
+ dt r2
+ mov.l r5,@(28,r4)
+ bf/s 12b
+ add #-32, r4
+
+#endif
+ add #32, r4
+ mov #8, r0
+ cmp/ge r0, r6
+ bf 40f
+
+ mov r6,r0
+22:
+ shlr2 r0
+ shlr r0 ! r0 = r6 >> 3
+3:
+ dt r0
+ mov.l r5,@-r4 ! set 8-byte at once
+ bf/s 3b
+ mov.l r5,@-r4
+ !
+ mov #7,r0
+ and r0,r6
+
+ ! fill bytes (length may be zero)
+40: tst r6,r6
+ bt 5f
+4:
+ dt r6
+ bf/s 4b
+ mov.b r5,@-r4
+5:
+ rts
+ mov r4,r0
+END(memset)
+libc_hidden_def (memset)
diff --git a/libc/string/sh/sh4/strcpy.S b/libc/string/sh/sh4/strcpy.S
new file mode 100644
index 000000000..0f8278017
--- /dev/null
+++ b/libc/string/sh/sh4/strcpy.S
@@ -0,0 +1,28 @@
+/* strcpy implementation 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.
+ */
+
+/*
+ char *strcpy(char *dest, const char *src);
+ */
+
+#include <sysdep.h>
+
+ENTRY(strcpy)
+ mov r4,r2
+1:
+ mov.b @r5+,r1
+ tst r1,r1
+ mov.b r1,@r2
+ bf/s 1b
+ add #1,r2
+
+ rts
+ mov r4,r0
+END(strcpy)
+libc_hidden_def (strcpy)
diff --git a/libc/string/sh/sh4/strncpy.S b/libc/string/sh/sh4/strncpy.S
new file mode 100644
index 000000000..8a16f39d4
--- /dev/null
+++ b/libc/string/sh/sh4/strncpy.S
@@ -0,0 +1,43 @@
+/* strncpy implementation 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.
+ */
+
+/*
+ char *strncpy(char *dest, const char *src, size_t n);
+ */
+
+#include <sysdep.h>
+
+ENTRY(strncpy)
+ mov #0,r0
+ bra 2f
+ mov r4,r2
+1:
+ mov.b r1,@(r0,r2)
+ add #1,r0
+2:
+ cmp/hs r6,r0
+ bt 5f
+ mov.b @(r0,r5),r1
+ tst r1,r1
+ bf/s 1b
+ cmp/hs r6,r0
+ bra 4f
+ nop
+3:
+ mov.b r1,@(r0,r2)
+ add #1,r0
+ cmp/hs r6,r0
+4:
+ bf/s 3b
+ mov #0,r1
+5:
+ rts
+ mov r2,r0
+END(strncpy)
+libc_hidden_def(strncpy)
diff --git a/libc/string/sh/strlen.S b/libc/string/sh/strlen.S
new file mode 100644
index 000000000..1ccecc17b
--- /dev/null
+++ b/libc/string/sh/strlen.S
@@ -0,0 +1,75 @@
+/* $Id: strlen.S,v 1.2 2001/06/29 14:07:15 gniibe Exp $
+ *
+ * "strlen" implementation of SuperH
+ *
+ * Copyright (C) 1999 Kaz Kojima
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+/* size_t strlen (const char *s) */
+
+#include <sysdep.h>
+#include <endian.h>
+
+ENTRY(strlen)
+ mov r4,r0
+ and #3,r0
+ tst r0,r0
+ bt/s 1f
+ mov #0,r2
+
+ add #-1,r0
+ shll2 r0
+ shll r0
+ braf r0
+ nop
+
+ mov.b @r4+,r1
+ tst r1,r1
+ bt 8f
+ add #1,r2
+
+ mov.b @r4+,r1
+ tst r1,r1
+ bt 8f
+ add #1,r2
+
+ mov.b @r4+,r1
+ tst r1,r1
+ bt 8f
+ add #1,r2
+
+1:
+ mov #0,r3
+2:
+ mov.l @r4+,r1
+ cmp/str r3,r1
+ bf/s 2b
+ add #4,r2
+
+ add #-4,r2
+#ifndef __LITTLE_ENDIAN__
+ swap.b r1,r1
+ swap.w r1,r1
+ swap.b r1,r1
+#endif
+ extu.b r1,r0
+ tst r0,r0
+ bt/s 8f
+ shlr8 r1
+ add #1,r2
+ extu.b r1,r0
+ tst r0,r0
+ bt/s 8f
+ shlr8 r1
+ add #1,r2
+ extu.b r1,r0
+ tst r0,r0
+ bt 8f
+ add #1,r2
+8:
+ rts
+ mov r2,r0
+END(strlen)
+libc_hidden_def (strlen)
diff --git a/libc/string/sh64/memcpy.S b/libc/string/sh64/memcpy.S
deleted file mode 100644
index 3c0ea0c0d..000000000
--- a/libc/string/sh64/memcpy.S
+++ /dev/null
@@ -1,205 +0,0 @@
-/* Cloned and hacked for uClibc by Paul Mundt, December 2003 */
-/* Modified by SuperH, Inc. September 2003 */
-!
-! Fast SH memcpy
-!
-! by Toshiyasu Morita (tm@netcom.com)
-! hacked by J"orn Rernnecke (joern.rennecke@superh.com) ("o for o-umlaut)
-! SH5 code Copyright 2002 SuperH Ltd.
-!
-! Entry: ARG0: destination pointer
-! ARG1: source pointer
-! ARG2: byte count
-!
-! Exit: RESULT: destination pointer
-! any other registers in the range r0-r7: trashed
-!
-! Notes: Usually one wants to do small reads and write a longword, but
-! unfortunately it is difficult in some cases to concatanate bytes
-! into a longword on the SH, so this does a longword read and small
-! writes.
-!
-! This implementation makes two assumptions about how it is called:
-!
-! 1.: If the byte count is nonzero, the address of the last byte to be
-! copied is unsigned greater than the address of the first byte to
-! be copied. This could be easily swapped for a signed comparison,
-! but the algorithm used needs some comparison.
-!
-! 2.: When there are two or three bytes in the last word of an 11-or-more
-! bytes memory chunk to b copied, the rest of the word can be read
-! without side effects.
-! This could be easily changed by increasing the minumum size of
-! a fast memcpy and the amount subtracted from r7 before L_2l_loop be 2,
-! however, this would cost a few extra cyles on average.
-! For SHmedia, the assumption is that any quadword can be read in its
-! enirety if at least one byte is included in the copy.
-!
-
-#include <features.h>
-
- .section .text..SHmedia32,"ax"
- .globl memcpy
- .type memcpy, @function
- .align 5
-
-memcpy:
-
-#define LDUAQ(P,O,D0,D1) ldlo.q P,O,D0; ldhi.q P,O+7,D1
-#define STUAQ(P,O,D0,D1) stlo.q P,O,D0; sthi.q P,O+7,D1
-#define LDUAL(P,O,D0,D1) ldlo.l P,O,D0; ldhi.l P,O+3,D1
-#define STUAL(P,O,D0,D1) stlo.l P,O,D0; sthi.l P,O+3,D1
-
- ld.b r3,0,r63
- pta/l Large,tr0
- movi 25,r0
- bgeu/u r4,r0,tr0
- nsb r4,r0
- shlli r0,5,r0
- movi (L1-L0+63*32 + 1) & 0xffff,r1
- sub r1, r0, r0
-L0: ptrel r0,tr0
- add r2,r4,r5
- ptabs r18,tr1
- add r3,r4,r6
- blink tr0,r63
-
-/* Rearranged to make cut2 safe */
- .balign 8
-L4_7: /* 4..7 byte memcpy cntd. */
- stlo.l r2, 0, r0
- or r6, r7, r6
- sthi.l r5, -1, r6
- stlo.l r5, -4, r6
- blink tr1,r63
-
- .balign 8
-L1: /* 0 byte memcpy */
- nop
- blink tr1,r63
- nop
- nop
- nop
- nop
-
-L2_3: /* 2 or 3 byte memcpy cntd. */
- st.b r5,-1,r6
- blink tr1,r63
-
- /* 1 byte memcpy */
- ld.b r3,0,r0
- st.b r2,0,r0
- blink tr1,r63
-
-L8_15: /* 8..15 byte memcpy cntd. */
- stlo.q r2, 0, r0
- or r6, r7, r6
- sthi.q r5, -1, r6
- stlo.q r5, -8, r6
- blink tr1,r63
-
- /* 2 or 3 byte memcpy */
- ld.b r3,0,r0
- ld.b r2,0,r63
- ld.b r3,1,r1
- st.b r2,0,r0
- pta/l L2_3,tr0
- ld.b r6,-1,r6
- st.b r2,1,r1
- blink tr0, r63
-
- /* 4 .. 7 byte memcpy */
- LDUAL (r3, 0, r0, r1)
- pta L4_7, tr0
- ldlo.l r6, -4, r7
- or r0, r1, r0
- sthi.l r2, 3, r0
- ldhi.l r6, -1, r6
- blink tr0, r63
-
- /* 8 .. 15 byte memcpy */
- LDUAQ (r3, 0, r0, r1)
- pta L8_15, tr0
- ldlo.q r6, -8, r7
- or r0, r1, r0
- sthi.q r2, 7, r0
- ldhi.q r6, -1, r6
- blink tr0, r63
-
- /* 16 .. 24 byte memcpy */
- LDUAQ (r3, 0, r0, r1)
- LDUAQ (r3, 8, r8, r9)
- or r0, r1, r0
- sthi.q r2, 7, r0
- or r8, r9, r8
- sthi.q r2, 15, r8
- ldlo.q r6, -8, r7
- ldhi.q r6, -1, r6
- stlo.q r2, 8, r8
- stlo.q r2, 0, r0
- or r6, r7, r6
- sthi.q r5, -1, r6
- stlo.q r5, -8, r6
- blink tr1,r63
-
-Large:
- ld.b r2, 0, r63
- pta/l Loop_ua, tr1
- ori r3, -8, r7
- sub r2, r7, r22
- sub r3, r2, r6
- add r2, r4, r5
- ldlo.q r3, 0, r0
- addi r5, -16, r5
- movi 64+8, r27 // could subtract r7 from that.
- stlo.q r2, 0, r0
- sthi.q r2, 7, r0
- ldx.q r22, r6, r0
- bgtu/l r27, r4, tr1
-
- addi r5, -48, r27
- pta/l Loop_line, tr0
- addi r6, 64, r36
- addi r6, -24, r19
- addi r6, -16, r20
- addi r6, -8, r21
-
-Loop_line:
- ldx.q r22, r36, r63
- alloco r22, 32
- addi r22, 32, r22
- ldx.q r22, r19, r23
- sthi.q r22, -25, r0
- ldx.q r22, r20, r24
- ldx.q r22, r21, r25
- stlo.q r22, -32, r0
- ldx.q r22, r6, r0
- sthi.q r22, -17, r23
- sthi.q r22, -9, r24
- sthi.q r22, -1, r25
- stlo.q r22, -24, r23
- stlo.q r22, -16, r24
- stlo.q r22, -8, r25
- bgeu r27, r22, tr0
-
-Loop_ua:
- addi r22, 8, r22
- sthi.q r22, -1, r0
- stlo.q r22, -8, r0
- ldx.q r22, r6, r0
- bgtu/l r5, r22, tr1
-
- add r3, r4, r7
- ldlo.q r7, -8, r1
- sthi.q r22, 7, r0
- ldhi.q r7, -1, r7
- ptabs r18,tr1
- stlo.q r22, 0, r0
- or r1, r7, r1
- sthi.q r5, 15, r1
- stlo.q r5, 8, r1
- blink tr1, r63
-
- .size memcpy,.-memcpy
-
-libc_hidden_def(memcpy)
diff --git a/libc/string/sh64/memset.S b/libc/string/sh64/memset.S
deleted file mode 100644
index f588323f0..000000000
--- a/libc/string/sh64/memset.S
+++ /dev/null
@@ -1,96 +0,0 @@
-/* Cloned and hacked for uClibc by Paul Mundt, December 2003 */
-/* Modified by SuperH, Inc. September 2003 */
-!
-! Fast SH memset
-!
-! by Toshiyasu Morita (tm@netcom.com)
-!
-! SH5 code by J"orn Rennecke (joern.rennecke@superh.com)
-! Copyright 2002 SuperH Ltd.
-!
-
-#include <features.h>
-#include <endian.h>
-
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define SHHI shlld
-#define SHLO shlrd
-#else
-#define SHHI shlrd
-#define SHLO shlld
-#endif
-
- .section .text..SHmedia32,"ax"
- .globl memset
- .type memset, @function
-
- .align 5
-
-memset:
- pta/l multiquad, tr0
- andi r2, 7, r22
- ptabs r18, tr2
- mshflo.b r3,r3,r3
- add r4, r22, r23
- mperm.w r3, r63, r3 // Fill pattern now in every byte of r3
-
- movi 8, r9
- bgtu/u r23, r9, tr0 // multiquad
-
- beqi/u r4, 0, tr2 // Return with size 0 - ensures no mem accesses
- ldlo.q r2, 0, r7
- shlli r4, 2, r4
- movi -1, r8
- SHHI r8, r4, r8
- SHHI r8, r4, r8
- mcmv r7, r8, r3
- stlo.q r2, 0, r3
- blink tr2, r63
-
-multiquad:
- pta/l lastquad, tr0
- stlo.q r2, 0, r3
- shlri r23, 3, r24
- add r2, r4, r5
- beqi/u r24, 1, tr0 // lastquad
- pta/l loop, tr1
- sub r2, r22, r25
- andi r5, -8, r20 // calculate end address and
- addi r20, -7*8, r8 // loop end address; This might overflow, so we need
- // to use a different test before we start the loop
- bge/u r24, r9, tr1 // loop
- st.q r25, 8, r3
- st.q r20, -8, r3
- shlri r24, 1, r24
- beqi/u r24, 1, tr0 // lastquad
- st.q r25, 16, r3
- st.q r20, -16, r3
- beqi/u r24, 2, tr0 // lastquad
- st.q r25, 24, r3
- st.q r20, -24, r3
-lastquad:
- sthi.q r5, -1, r3
- blink tr2,r63
-
-loop:
-!!! alloco r25, 32 // QQQ comment out for short-term fix to SHUK #3895.
- // QQQ commenting out is locically correct, but sub-optimal
- // QQQ Sean McGoogan - 4th April 2003.
- st.q r25, 8, r3
- st.q r25, 16, r3
- st.q r25, 24, r3
- st.q r25, 32, r3
- addi r25, 32, r25
- bgeu/l r8, r25, tr1 // loop
-
- st.q r20, -40, r3
- st.q r20, -32, r3
- st.q r20, -24, r3
- st.q r20, -16, r3
- st.q r20, -8, r3
- sthi.q r5, -1, r3
- blink tr2,r63
-
- .size memset,.-memset
-
-libc_hidden_def(memset)
diff --git a/libc/string/sh64/strcpy.S b/libc/string/sh64/strcpy.S
deleted file mode 100644
index da79d5143..000000000
--- a/libc/string/sh64/strcpy.S
+++ /dev/null
@@ -1,102 +0,0 @@
-/* Cloned and hacked for uClibc by Paul Mundt, December 2003 */
-/* Modified by SuperH, Inc. September 2003 */
-! Entry: arg0: destination
-! arg1: source
-! Exit: result: destination
-!
-! SH5 code Copyright 2002 SuperH Ltd.
-
-#include <features.h>
-#include <endian.h>
-
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define SHHI shlld
-#define SHLO shlrd
-#else
-#define SHHI shlrd
-#define SHLO shlld
-#endif
-
- .section .text..SHmedia32,"ax"
- .globl strcpy
- .type strcpy, @function
- .align 5
-
-strcpy:
-
- pta/l shortstring,tr1
- ldlo.q r3,0,r4
- ptabs r18,tr4
- shlli r3,3,r7
- addi r2, 8, r0
- mcmpeq.b r4,r63,r6
- SHHI r6,r7,r6
- bnei/u r6,0,tr1 // shortstring
- pta/l no_lddst, tr2
- ori r3,-8,r23
- sub r2, r23, r0
- sub r3, r2, r21
- addi r21, 8, r20
- ldx.q r0, r21, r5
- pta/l loop, tr0
- ori r2,-8,r22
- mcmpeq.b r5, r63, r6
- bgt/u r22, r23, tr2 // no_lddst
-
- // r22 < r23 : Need to do a load from the destination.
- // r22 == r23 : Doesn't actually need to load from destination,
- // but still can be handled here.
- ldlo.q r2, 0, r9
- movi -1, r8
- SHLO r8, r7, r8
- mcmv r4, r8, r9
- stlo.q r2, 0, r9
- beqi/l r6, 0, tr0 // loop
-
- add r5, r63, r4
- addi r0, 8, r0
- blink tr1, r63 // shortstring
-no_lddst:
- // r22 > r23: note that for r22 == r23 the sthi.q would clobber
- // bytes before the destination region.
- stlo.q r2, 0, r4
- SHHI r4, r7, r4
- sthi.q r0, -1, r4
- beqi/l r6, 0, tr0 // loop
-
- add r5, r63, r4
- addi r0, 8, r0
-shortstring:
-#if __BYTE_ORDER != __LITTLE_ENDIAN
- pta/l shortstring2,tr1
- byterev r4,r4
-#endif
-shortstring2:
- st.b r0,-8,r4
- andi r4,0xff,r5
- shlri r4,8,r4
- addi r0,1,r0
- bnei/l r5,0,tr1
- blink tr4,r63 // return
-
- .balign 8
-loop:
- stlo.q r0, 0, r5
- ldx.q r0, r20, r4
- addi r0, 16, r0
- sthi.q r0, -9, r5
- mcmpeq.b r4, r63, r6
- bnei/u r6, 0, tr1 // shortstring
- ldx.q r0, r21, r5
- stlo.q r0, -8, r4
- sthi.q r0, -1, r4
- mcmpeq.b r5, r63, r6
- beqi/l r6, 0, tr0 // loop
-
- add r5, r63, r4
- addi r0, 8, r0
- blink tr1, r63 // shortstring
-
- .size strcpy,.-strcpy
-
-libc_hidden_def(strcpy)
diff --git a/libc/string/sparc/sparc32/memchr.S b/libc/string/sparc/sparc32/memchr.S
index 4d57a553b..1949db2e5 100644
--- a/libc/string/sparc/sparc32/memchr.S
+++ b/libc/string/sparc/sparc32/memchr.S
@@ -24,9 +24,8 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 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
@@ -139,6 +138,4 @@ ENTRY(memchr)
END(memchr)
libc_hidden_def(memchr)
-#if !__BOUNDED_POINTERS__
weak_alias(memchr,__ubp_memchr)
-#endif
diff --git a/libc/string/sparc/sparc32/memcpy.S b/libc/string/sparc/sparc32/memcpy.S
index 25a48844d..2fb87bb17 100644
--- a/libc/string/sparc/sparc32/memcpy.S
+++ b/libc/string/sparc/sparc32/memcpy.S
@@ -17,9 +17,8 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 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/string/sparc/sparc32/memset.S b/libc/string/sparc/sparc32/memset.S
index 6c6424cf8..6d02fc1a8 100644
--- a/libc/string/sparc/sparc32/memset.S
+++ b/libc/string/sparc/sparc32/memset.S
@@ -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/>. */
#include <features.h>
diff --git a/libc/string/sparc/sparc32/stpcpy.S b/libc/string/sparc/sparc32/stpcpy.S
index daf116eb1..2984ea156 100644
--- a/libc/string/sparc/sparc32/stpcpy.S
+++ b/libc/string/sparc/sparc32/stpcpy.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/>. */
/* Normally, this uses ((xword - 0x01010101) & 0x80808080) test
to find out if any byte in xword could be zero. This is fast, but
diff --git a/libc/string/sparc/sparc32/strcat.S b/libc/string/sparc/sparc32/strcat.S
index eda029a16..e968a18a3 100644
--- a/libc/string/sparc/sparc32/strcat.S
+++ b/libc/string/sparc/sparc32/strcat.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/>. */
/* Normally, this uses ((xword - 0x01010101) & 0x80808080) test
to find out if any byte in xword could be zero. This is fast, but
diff --git a/libc/string/sparc/sparc32/strchr.S b/libc/string/sparc/sparc32/strchr.S
index 16710d4e8..fabc3e7e5 100644
--- a/libc/string/sparc/sparc32/strchr.S
+++ b/libc/string/sparc/sparc32/strchr.S
@@ -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/>. */
/* Normally, this uses ((xword - 0x01010101) & 0x80808080) test
to find out if any byte in xword could be zero. This is fast, but
diff --git a/libc/string/sparc/sparc32/strcmp.S b/libc/string/sparc/sparc32/strcmp.S
index d43883de6..07284cd18 100644
--- a/libc/string/sparc/sparc32/strcmp.S
+++ b/libc/string/sparc/sparc32/strcmp.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/>. */
/* Normally, this uses ((xword - 0x01010101) & 0x80808080) test
to find out if any byte in xword could be zero. This is fast, but
diff --git a/libc/string/sparc/sparc32/strcpy.S b/libc/string/sparc/sparc32/strcpy.S
index 4d7742ebc..3287546f3 100644
--- a/libc/string/sparc/sparc32/strcpy.S
+++ b/libc/string/sparc/sparc32/strcpy.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/>. */
/* Normally, this uses ((xword - 0x01010101) & 0x80808080) test
to find out if any byte in xword could be zero. This is fast, but
diff --git a/libc/string/sparc/sparc32/strlen.S b/libc/string/sparc/sparc32/strlen.S
index 4edfe7e78..66c790cb6 100644
--- a/libc/string/sparc/sparc32/strlen.S
+++ b/libc/string/sparc/sparc32/strlen.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/>. */
/* Normally, this uses ((xword - 0x01010101) & 0x80808080) test
to find out if any byte in xword could be zero. This is fast, but
diff --git a/libc/string/sparc/sparc64/memchr.S b/libc/string/sparc/sparc64/memchr.S
deleted file mode 100644
index 6096cc218..000000000
--- a/libc/string/sparc/sparc64/memchr.S
+++ /dev/null
@@ -1,261 +0,0 @@
-/* memchr (str, ch, n) -- Return pointer to first occurrence of CH in STR less
- than N.
- For SPARC v9.
- Copyright (C) 1998, 1999, 2000, 2003 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Jan Vondrak <jvon4518@ss1000.ms.mff.cuni.cz> and
- Jakub Jelinek <jj@ultra.linux.cz>.
- This version is developed using the same algorithm as the fast C
- version which carries the following introduction:
- Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
- with help from Dan Sahlin (dan@sics.se) and
- commentary by Jim Blandy (jimb@ai.mit.edu);
- adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu),
- and implemented by Roland McGrath (roland@ai.mit.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. */
-
-#include <asm/asi.h>
-#ifndef XCC
-#define XCC xcc
-#define USE_BPR
- .register %g2, #scratch
- .register %g3, #scratch
-#endif
-
- /* Normally, this uses
- ((xword - 0x0101010101010101) & 0x8080808080808080) test
- to find out if any byte in xword could be zero. This is fast, but
- also gives false alarm for any byte in range 0x81-0xff. It does
- not matter for correctness, as if this test tells us there could
- be some zero byte, we check it byte by byte, but if bytes with
- high bits set are common in the strings, then this will give poor
- performance. You can #define EIGHTBIT_NOT_RARE and the algorithm
- will use one tick slower, but more precise test
- ((xword - 0x0101010101010101) & (~xword) & 0x8080808080808080),
- which does not give any false alarms (but if some bits are set,
- one cannot assume from it which bytes are zero and which are not).
- It is yet to be measured, what is the correct default for glibc
- in these days for an average user.
- */
-
- .text
- .align 32
-ENTRY(memchr)
- and %o1, 0xff, %o1 /* IEU0 Group */
-#ifdef USE_BPR
- brz,pn %o2, 12f /* CTI+IEU1 */
-#else
- tst %o2 /* IEU1 */
- be,pn %XCC, 12f /* CTI */
-#endif
- sll %o1, 8, %g3 /* IEU0 Group */
- add %o0, %o2, %o2 /* IEU1 */
-
- sethi %hi(0x01010101), %g1 /* IEU0 Group */
- or %g3, %o1, %g3 /* IEU1 */
- ldub [%o0], %o3 /* Load */
- sllx %g3, 16, %g5 /* IEU0 Group */
-
- or %g1, %lo(0x01010101), %g1 /* IEU1 */
- sllx %g1, 32, %g2 /* IEU0 Group */
- or %g3, %g5, %g3 /* IEU1 */
- sllx %g3, 32, %g5 /* IEU0 Group */
-
- cmp %o3, %o1 /* IEU1 */
- be,pn %xcc, 13f /* CTI */
- or %g1, %g2, %g1 /* IEU0 Group */
- andcc %o0, 7, %g0 /* IEU1 */
-
- bne,a,pn %icc, 21f /* CTI */
- add %o0, 1, %o0 /* IEU0 Group */
- ldx [%o0], %o3 /* Load Group */
- sllx %g1, 7, %g2 /* IEU0 */
-
- or %g3, %g5, %g3 /* IEU1 */
-1: add %o0, 8, %o0 /* IEU0 Group */
- xor %o3, %g3, %o4 /* IEU1 */
- /* %g1 = 0101010101010101 *
- * %g2 = 8080088080808080 *
- * %g3 = c c c c c c c c *
- * %o3 = value *
- * %o4 = value XOR c */
-2: cmp %o0, %o2 /* IEU1 Group */
-
- bg,pn %XCC, 11f /* CTI */
- ldxa [%o0] ASI_PNF, %o3 /* Load */
- sub %o4, %g1, %o5 /* IEU0 Group */
- add %o0, 8, %o0 /* IEU1 */
-#ifdef EIGHTBIT_NOT_RARE
- andn %o5, %o4, %o5 /* IEU0 Group */
-#endif
-
- andcc %o5, %g2, %g0 /* IEU1 Group */
- be,a,pt %xcc, 2b /* CTI */
- xor %o3, %g3, %o4 /* IEU0 */
- srlx %o4, 56, %g5 /* IEU0 */
-
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 3f /* CTI */
- srlx %o4, 48, %g5 /* IEU0 */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
-
- be,pn %icc, 4f /* CTI */
- srlx %o4, 40, %g5 /* IEU0 */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 5f /* CTI */
-
- srlx %o4, 32, %g5 /* IEU0 */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 6f /* CTI */
- srlx %o4, 24, %g5 /* IEU0 */
-
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 7f /* CTI */
- srlx %o4, 16, %g5 /* IEU0 */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
-
- be,pn %icc, 8f /* CTI */
- srlx %o4, 8, %g5 /* IEU0 */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 9f /* CTI */
-
- andcc %o4, 0xff, %g0 /* IEU1 Group */
- bne,pt %icc, 2b /* CTI */
- xor %o3, %g3, %o4 /* IEU0 */
- retl /* CTI+IEU1 Group */
-
- add %o0, -9, %o0 /* IEU0 */
-
- .align 16
-3: retl /* CTI+IEU1 Group */
- add %o0, -16, %o0 /* IEU0 */
-4: retl /* CTI+IEU1 Group */
- add %o0, -15, %o0 /* IEU0 */
-
-5: retl /* CTI+IEU1 Group */
- add %o0, -14, %o0 /* IEU0 */
-6: retl /* CTI+IEU1 Group */
- add %o0, -13, %o0 /* IEU0 */
-
-7: retl /* CTI+IEU1 Group */
- add %o0, -12, %o0 /* IEU0 */
-8: retl /* CTI+IEU1 Group */
- add %o0, -11, %o0 /* IEU0 */
-
-9: retl /* CTI+IEU1 Group */
- add %o0, -10, %o0 /* IEU0 */
-11: sub %o4, %g1, %o5 /* IEU0 Group */
- sub %o0, 8, %o0 /* IEU1 */
-
- andcc %o5, %g2, %g0 /* IEU1 Group */
- be,pt %xcc, 12f /* CTI */
- sub %o2, %o0, %o2 /* IEU0 */
- tst %o2 /* IEU1 Group */
-
- be,pn %XCC, 12f /* CTI */
- srlx %o4, 56, %g5 /* IEU0 */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 13f /* CTI */
-
- cmp %o2, 1 /* IEU0 */
- be,pn %XCC, 12f /* CTI Group */
- srlx %o4, 48, %g5 /* IEU0 */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
-
- be,pn %icc, 14f /* CTI */
- cmp %o2, 2 /* IEU1 Group */
- be,pn %XCC, 12f /* CTI */
- srlx %o4, 40, %g5 /* IEU0 */
-
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 15f /* CTI */
- cmp %o2, 3 /* IEU1 Group */
- be,pn %XCC, 12f /* CTI */
-
- srlx %o4, 32, %g5 /* IEU0 */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 16f /* CTI */
- cmp %o2, 4 /* IEU1 Group */
-
- be,pn %XCC, 12f /* CTI */
- srlx %o4, 24, %g5 /* IEU0 */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 17f /* CTI */
-
- cmp %o2, 5 /* IEU1 Group */
- be,pn %XCC, 12f /* CTI */
- srlx %o4, 16, %g5 /* IEU0 */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
-
- be,pn %icc, 18f /* CTI */
- cmp %o2, 6 /* IEU1 Group */
- be,pn %XCC, 12f /* CTI */
- srlx %o4, 8, %g5 /* IEU0 */
-
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 19f /* CTI */
- nop /* IEU0 */
-12: retl /* CTI+IEU1 Group */
-
- clr %o0 /* IEU0 */
- nop /* Stub */
-13: retl /* CTI+IEU1 Group */
- nop /* IEU0 */
-
-14: retl /* CTI+IEU1 Group */
- add %o0, 1, %o0 /* IEU0 */
-15: retl /* CTI+IEU1 Group */
- add %o0, 2, %o0 /* IEU0 */
-
-16: retl /* CTI+IEU1 Group */
- add %o0, 3, %o0 /* IEU0 */
-17: retl /* CTI+IEU1 Group */
- add %o0, 4, %o0 /* IEU0 */
-
-18: retl /* CTI+IEU1 Group */
- add %o0, 5, %o0 /* IEU0 */
-19: retl /* CTI+IEU1 Group */
- add %o0, 6, %o0 /* IEU0 */
-
-21: cmp %o0, %o2 /* IEU1 */
- be,pn %XCC, 12b /* CTI */
- sllx %g1, 7, %g2 /* IEU0 Group */
- ldub [%o0], %o3 /* Load */
-
- or %g3, %g5, %g3 /* IEU1 */
-22: andcc %o0, 7, %g0 /* IEU1 Group */
- be,a,pn %icc, 1b /* CTI */
- ldx [%o0], %o3 /* Load */
-
- cmp %o3, %o1 /* IEU1 Group */
- be,pn %xcc, 23f /* CTI */
- add %o0, 1, %o0 /* IEU0 */
- cmp %o0, %o2 /* IEU1 Group */
-
- bne,a,pt %XCC, 22b /* CTI */
- ldub [%o0], %o3 /* Load */
- retl /* CTI+IEU1 Group */
- clr %o0 /* IEU0 */
-
-23: retl /* CTI+IEU1 Group */
- add %o0, -1, %o0 /* IEU0 */
-END(memchr)
-
-libc_hidden_def(memchr)
-#if !__BOUNDED_POINTERS__
-weak_alias(memchr,__ubp_memchr)
-#endif
diff --git a/libc/string/sparc/sparc64/memcpy.S b/libc/string/sparc/sparc64/memcpy.S
deleted file mode 100644
index db63d1da2..000000000
--- a/libc/string/sparc/sparc64/memcpy.S
+++ /dev/null
@@ -1,923 +0,0 @@
-/* Copy SIZE bytes from SRC to DEST.
- For UltraSPARC.
- Copyright (C) 1996, 97, 98, 99, 2003 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by David S. Miller (davem@caip.rutgers.edu) and
- Jakub Jelinek (jakub@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, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#include <features.h>
-#include <asm/asi.h>
-#ifndef XCC
-#define USE_BPR
- .register %g2, #scratch
- .register %g3, #scratch
- .register %g6, #scratch
-#define XCC xcc
-#endif
-#define FPRS_FEF 4
-
-#define FREG_FROB(f1, f2, f3, f4, f5, f6, f7, f8, f9) \
- faligndata %f1, %f2, %f48; \
- faligndata %f2, %f3, %f50; \
- faligndata %f3, %f4, %f52; \
- faligndata %f4, %f5, %f54; \
- faligndata %f5, %f6, %f56; \
- faligndata %f6, %f7, %f58; \
- faligndata %f7, %f8, %f60; \
- faligndata %f8, %f9, %f62;
-
-#define MAIN_LOOP_CHUNK(src, dest, fdest, fsrc, len, jmptgt) \
- ldda [%src] %asi, %fdest; \
- add %src, 0x40, %src; \
- add %dest, 0x40, %dest; \
- subcc %len, 0x40, %len; \
- be,pn %xcc, jmptgt; \
- stda %fsrc, [%dest - 0x40] %asi;
-
-#define LOOP_CHUNK1(src, dest, len, branch_dest) \
- MAIN_LOOP_CHUNK(src, dest, f0, f48, len, branch_dest)
-#define LOOP_CHUNK2(src, dest, len, branch_dest) \
- MAIN_LOOP_CHUNK(src, dest, f16, f48, len, branch_dest)
-#define LOOP_CHUNK3(src, dest, len, branch_dest) \
- MAIN_LOOP_CHUNK(src, dest, f32, f48, len, branch_dest)
-
-#define STORE_SYNC(dest, fsrc) \
- stda %fsrc, [%dest] %asi; \
- add %dest, 0x40, %dest;
-
-#define STORE_JUMP(dest, fsrc, target) \
- stda %fsrc, [%dest] %asi; \
- add %dest, 0x40, %dest; \
- ba,pt %xcc, target;
-
-#define VISLOOP_PAD nop; nop; nop; nop; \
- nop; nop; nop; nop; \
- nop; nop; nop; nop; \
- nop; nop; nop;
-
-#define FINISH_VISCHUNK(dest, f0, f1, left) \
- subcc %left, 8, %left; \
- bl,pn %xcc, 205f; \
- faligndata %f0, %f1, %f48; \
- std %f48, [%dest]; \
- add %dest, 8, %dest;
-
-#define UNEVEN_VISCHUNK(dest, f0, f1, left) \
- subcc %left, 8, %left; \
- bl,pn %xcc, 205f; \
- fsrc1 %f0, %f1; \
- ba,a,pt %xcc, 204f;
-
- /* Macros for non-VIS memcpy code. */
-#define MOVE_BIGCHUNK(src, dst, offset, t0, t1, t2, t3) \
- ldx [%src + offset + 0x00], %t0; \
- ldx [%src + offset + 0x08], %t1; \
- ldx [%src + offset + 0x10], %t2; \
- ldx [%src + offset + 0x18], %t3; \
- stw %t0, [%dst + offset + 0x04]; \
- srlx %t0, 32, %t0; \
- stw %t0, [%dst + offset + 0x00]; \
- stw %t1, [%dst + offset + 0x0c]; \
- srlx %t1, 32, %t1; \
- stw %t1, [%dst + offset + 0x08]; \
- stw %t2, [%dst + offset + 0x14]; \
- srlx %t2, 32, %t2; \
- stw %t2, [%dst + offset + 0x10]; \
- stw %t3, [%dst + offset + 0x1c]; \
- srlx %t3, 32, %t3; \
- stw %t3, [%dst + offset + 0x18];
-
-#define MOVE_BIGALIGNCHUNK(src, dst, offset, t0, t1, t2, t3) \
- ldx [%src + offset + 0x00], %t0; \
- ldx [%src + offset + 0x08], %t1; \
- ldx [%src + offset + 0x10], %t2; \
- ldx [%src + offset + 0x18], %t3; \
- stx %t0, [%dst + offset + 0x00]; \
- stx %t1, [%dst + offset + 0x08]; \
- stx %t2, [%dst + offset + 0x10]; \
- stx %t3, [%dst + offset + 0x18]; \
- ldx [%src + offset + 0x20], %t0; \
- ldx [%src + offset + 0x28], %t1; \
- ldx [%src + offset + 0x30], %t2; \
- ldx [%src + offset + 0x38], %t3; \
- stx %t0, [%dst + offset + 0x20]; \
- stx %t1, [%dst + offset + 0x28]; \
- stx %t2, [%dst + offset + 0x30]; \
- stx %t3, [%dst + offset + 0x38];
-
-#define MOVE_LASTCHUNK(src, dst, offset, t0, t1, t2, t3) \
- ldx [%src - offset - 0x10], %t0; \
- ldx [%src - offset - 0x08], %t1; \
- stw %t0, [%dst - offset - 0x0c]; \
- srlx %t0, 32, %t2; \
- stw %t2, [%dst - offset - 0x10]; \
- stw %t1, [%dst - offset - 0x04]; \
- srlx %t1, 32, %t3; \
- stw %t3, [%dst - offset - 0x08];
-
-#define MOVE_LASTALIGNCHUNK(src, dst, offset, t0, t1) \
- ldx [%src - offset - 0x10], %t0; \
- ldx [%src - offset - 0x08], %t1; \
- stx %t0, [%dst - offset - 0x10]; \
- stx %t1, [%dst - offset - 0x08];
-
- /* Macros for non-VIS memmove code. */
-#define RMOVE_BIGCHUNK(src, dst, offset, t0, t1, t2, t3) \
- ldx [%src - offset - 0x20], %t0; \
- ldx [%src - offset - 0x18], %t1; \
- ldx [%src - offset - 0x10], %t2; \
- ldx [%src - offset - 0x08], %t3; \
- stw %t0, [%dst - offset - 0x1c]; \
- srlx %t0, 32, %t0; \
- stw %t0, [%dst - offset - 0x20]; \
- stw %t1, [%dst - offset - 0x14]; \
- srlx %t1, 32, %t1; \
- stw %t1, [%dst - offset - 0x18]; \
- stw %t2, [%dst - offset - 0x0c]; \
- srlx %t2, 32, %t2; \
- stw %t2, [%dst - offset - 0x10]; \
- stw %t3, [%dst - offset - 0x04]; \
- srlx %t3, 32, %t3; \
- stw %t3, [%dst - offset - 0x08];
-
-#define RMOVE_BIGALIGNCHUNK(src, dst, offset, t0, t1, t2, t3) \
- ldx [%src - offset - 0x20], %t0; \
- ldx [%src - offset - 0x18], %t1; \
- ldx [%src - offset - 0x10], %t2; \
- ldx [%src - offset - 0x08], %t3; \
- stx %t0, [%dst - offset - 0x20]; \
- stx %t1, [%dst - offset - 0x18]; \
- stx %t2, [%dst - offset - 0x10]; \
- stx %t3, [%dst - offset - 0x08]; \
- ldx [%src - offset - 0x40], %t0; \
- ldx [%src - offset - 0x38], %t1; \
- ldx [%src - offset - 0x30], %t2; \
- ldx [%src - offset - 0x28], %t3; \
- stx %t0, [%dst - offset - 0x40]; \
- stx %t1, [%dst - offset - 0x38]; \
- stx %t2, [%dst - offset - 0x30]; \
- stx %t3, [%dst - offset - 0x28];
-
-#define RMOVE_LASTCHUNK(src, dst, offset, t0, t1, t2, t3) \
- ldx [%src + offset + 0x00], %t0; \
- ldx [%src + offset + 0x08], %t1; \
- stw %t0, [%dst + offset + 0x04]; \
- srlx %t0, 32, %t2; \
- stw %t2, [%dst + offset + 0x00]; \
- stw %t1, [%dst + offset + 0x0c]; \
- srlx %t1, 32, %t3; \
- stw %t3, [%dst + offset + 0x08];
-
-#define RMOVE_LASTALIGNCHUNK(src, dst, offset, t0, t1) \
- ldx [%src + offset + 0x00], %t0; \
- ldx [%src + offset + 0x08], %t1; \
- stx %t0, [%dst + offset + 0x00]; \
- stx %t1, [%dst + offset + 0x08];
-
- .text
- .align 32
-
-#ifdef __UCLIBC_SUSV3_LEGACY__
-ENTRY(bcopy)
- sub %o1, %o0, %o4 /* IEU0 Group */
- mov %o0, %g3 /* IEU1 */
- cmp %o4, %o2 /* IEU1 Group */
- mov %o1, %o0 /* IEU0 */
- bgeu,pt %XCC, 210f /* CTI */
- mov %g3, %o1 /* IEU0 Group */
-#ifndef USE_BPR
- srl %o2, 0, %o2 /* IEU1 */
-#endif
- brnz,pn %o2, 220f /* CTI Group */
- add %o0, %o2, %o0 /* IEU0 */
- retl
- nop
-END(bcopy)
-#endif
-
- .align 32
-200: be,pt %xcc, 201f /* CTI */
- andcc %o0, 0x38, %g5 /* IEU1 Group */
- mov 8, %g1 /* IEU0 */
- sub %g1, %g2, %g2 /* IEU0 Group */
- andcc %o0, 1, %g0 /* IEU1 */
- be,pt %icc, 2f /* CTI */
- sub %o2, %g2, %o2 /* IEU0 Group */
-1: ldub [%o1], %o5 /* Load Group */
- add %o1, 1, %o1 /* IEU0 */
- add %o0, 1, %o0 /* IEU1 */
- subcc %g2, 1, %g2 /* IEU1 Group */
- be,pn %xcc, 3f /* CTI */
- stb %o5, [%o0 - 1] /* Store */
-2: ldub [%o1], %o5 /* Load Group */
- add %o0, 2, %o0 /* IEU0 */
- ldub [%o1 + 1], %g3 /* Load Group */
- subcc %g2, 2, %g2 /* IEU1 Group */
- stb %o5, [%o0 - 2] /* Store */
- add %o1, 2, %o1 /* IEU0 */
- bne,pt %xcc, 2b /* CTI Group */
- stb %g3, [%o0 - 1] /* Store */
-3: andcc %o0, 0x38, %g5 /* IEU1 Group */
-201: be,pt %icc, 202f /* CTI */
- mov 64, %g1 /* IEU0 */
- fmovd %f0, %f2 /* FPU */
- sub %g1, %g5, %g5 /* IEU0 Group */
- alignaddr %o1, %g0, %g1 /* GRU Group */
- ldd [%g1], %f4 /* Load Group */
- sub %o2, %g5, %o2 /* IEU0 */
-1: ldd [%g1 + 0x8], %f6 /* Load Group */
- add %g1, 0x8, %g1 /* IEU0 Group */
- subcc %g5, 8, %g5 /* IEU1 */
- faligndata %f4, %f6, %f0 /* GRU Group */
- std %f0, [%o0] /* Store */
- add %o1, 8, %o1 /* IEU0 Group */
- be,pn %xcc, 202f /* CTI */
- add %o0, 8, %o0 /* IEU1 */
- ldd [%g1 + 0x8], %f4 /* Load Group */
- add %g1, 8, %g1 /* IEU0 */
- subcc %g5, 8, %g5 /* IEU1 */
- faligndata %f6, %f4, %f0 /* GRU Group */
- std %f0, [%o0] /* Store */
- add %o1, 8, %o1 /* IEU0 */
- bne,pt %xcc, 1b /* CTI Group */
- add %o0, 8, %o0 /* IEU0 */
-202: membar #LoadStore | #StoreStore | #StoreLoad /* LSU Group */
- wr %g0, ASI_BLK_P, %asi /* LSU Group */
- subcc %o2, 0x40, %g6 /* IEU1 Group */
- mov %o1, %g1 /* IEU0 */
- andncc %g6, (0x40 - 1), %g6 /* IEU1 Group */
- srl %g1, 3, %g2 /* IEU0 */
- sub %o2, %g6, %g3 /* IEU0 Group */
- andn %o1, (0x40 - 1), %o1 /* IEU1 */
- and %g2, 7, %g2 /* IEU0 Group */
- andncc %g3, 0x7, %g3 /* IEU1 */
- fmovd %f0, %f2 /* FPU */
- sub %g3, 0x10, %g3 /* IEU0 Group */
- sub %o2, %g6, %o2 /* IEU1 */
- alignaddr %g1, %g0, %g0 /* GRU Group */
- add %g1, %g6, %g1 /* IEU0 Group */
- subcc %o2, %g3, %o2 /* IEU1 */
- ldda [%o1 + 0x00] %asi, %f0 /* LSU Group */
- add %g1, %g3, %g1 /* IEU0 */
- ldda [%o1 + 0x40] %asi, %f16 /* LSU Group */
- sub %g6, 0x80, %g6 /* IEU0 */
- ldda [%o1 + 0x80] %asi, %f32 /* LSU Group */
- /* Clk1 Group 8-( */
- /* Clk2 Group 8-( */
- /* Clk3 Group 8-( */
- /* Clk4 Group 8-( */
-203: rd %pc, %g5 /* PDU Group 8-( */
- addcc %g5, %lo(300f - 203b), %g5 /* IEU1 Group */
- sll %g2, 9, %g2 /* IEU0 */
- jmpl %g5 + %g2, %g0 /* CTI Group brk forced*/
- addcc %o1, 0xc0, %o1 /* IEU1 Group */
-
- .align 512 /* OK, here comes the fun part... */
-300: FREG_FROB(f0, f2, f4, f6, f8, f10,f12,f14,f16) LOOP_CHUNK1(o1, o0, g6, 301f)
- FREG_FROB(f16,f18,f20,f22,f24,f26,f28,f30,f32) LOOP_CHUNK2(o1, o0, g6, 302f)
- FREG_FROB(f32,f34,f36,f38,f40,f42,f44,f46,f0) LOOP_CHUNK3(o1, o0, g6, 303f)
- b,pt %xcc, 300b+4; faligndata %f0, %f2, %f48
-301: FREG_FROB(f16,f18,f20,f22,f24,f26,f28,f30,f32) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f32,f34,f36,f38,f40,f42,f44,f46,f0) STORE_JUMP(o0, f48, 400f) membar #Sync
-302: FREG_FROB(f32,f34,f36,f38,f40,f42,f44,f46,f0) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f0, f2, f4, f6, f8, f10,f12,f14,f16) STORE_JUMP(o0, f48, 416f) membar #Sync
-303: FREG_FROB(f0, f2, f4, f6, f8, f10,f12,f14,f16) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f16,f18,f20,f22,f24,f26,f28,f30,f32) STORE_JUMP(o0, f48, 432f) membar #Sync
- VISLOOP_PAD
-310: FREG_FROB(f2, f4, f6, f8, f10,f12,f14,f16,f18) LOOP_CHUNK1(o1, o0, g6, 311f)
- FREG_FROB(f18,f20,f22,f24,f26,f28,f30,f32,f34) LOOP_CHUNK2(o1, o0, g6, 312f)
- FREG_FROB(f34,f36,f38,f40,f42,f44,f46,f0, f2) LOOP_CHUNK3(o1, o0, g6, 313f)
- b,pt %xcc, 310b+4; faligndata %f2, %f4, %f48
-311: FREG_FROB(f18,f20,f22,f24,f26,f28,f30,f32,f34) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f34,f36,f38,f40,f42,f44,f46,f0, f2) STORE_JUMP(o0, f48, 402f) membar #Sync
-312: FREG_FROB(f34,f36,f38,f40,f42,f44,f46,f0, f2) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f2, f4, f6, f8, f10,f12,f14,f16,f18) STORE_JUMP(o0, f48, 418f) membar #Sync
-313: FREG_FROB(f2, f4, f6, f8, f10,f12,f14,f16,f18) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f18,f20,f22,f24,f26,f28,f30,f32,f34) STORE_JUMP(o0, f48, 434f) membar #Sync
- VISLOOP_PAD
-320: FREG_FROB(f4, f6, f8, f10,f12,f14,f16,f18,f20) LOOP_CHUNK1(o1, o0, g6, 321f)
- FREG_FROB(f20,f22,f24,f26,f28,f30,f32,f34,f36) LOOP_CHUNK2(o1, o0, g6, 322f)
- FREG_FROB(f36,f38,f40,f42,f44,f46,f0, f2, f4) LOOP_CHUNK3(o1, o0, g6, 323f)
- b,pt %xcc, 320b+4; faligndata %f4, %f6, %f48
-321: FREG_FROB(f20,f22,f24,f26,f28,f30,f32,f34,f36) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f36,f38,f40,f42,f44,f46,f0, f2, f4) STORE_JUMP(o0, f48, 404f) membar #Sync
-322: FREG_FROB(f36,f38,f40,f42,f44,f46,f0, f2, f4) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f4, f6, f8, f10,f12,f14,f16,f18,f20) STORE_JUMP(o0, f48, 420f) membar #Sync
-323: FREG_FROB(f4, f6, f8, f10,f12,f14,f16,f18,f20) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f20,f22,f24,f26,f28,f30,f32,f34,f36) STORE_JUMP(o0, f48, 436f) membar #Sync
- VISLOOP_PAD
-330: FREG_FROB(f6, f8, f10,f12,f14,f16,f18,f20,f22) LOOP_CHUNK1(o1, o0, g6, 331f)
- FREG_FROB(f22,f24,f26,f28,f30,f32,f34,f36,f38) LOOP_CHUNK2(o1, o0, g6, 332f)
- FREG_FROB(f38,f40,f42,f44,f46,f0, f2, f4, f6) LOOP_CHUNK3(o1, o0, g6, 333f)
- b,pt %xcc, 330b+4; faligndata %f6, %f8, %f48
-331: FREG_FROB(f22,f24,f26,f28,f30,f32,f34,f36,f38) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f38,f40,f42,f44,f46,f0, f2, f4, f6) STORE_JUMP(o0, f48, 406f) membar #Sync
-332: FREG_FROB(f38,f40,f42,f44,f46,f0, f2, f4, f6) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f6, f8, f10,f12,f14,f16,f18,f20,f22) STORE_JUMP(o0, f48, 422f) membar #Sync
-333: FREG_FROB(f6, f8, f10,f12,f14,f16,f18,f20,f22) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f22,f24,f26,f28,f30,f32,f34,f36,f38) STORE_JUMP(o0, f48, 438f) membar #Sync
- VISLOOP_PAD
-340: FREG_FROB(f8, f10,f12,f14,f16,f18,f20,f22,f24) LOOP_CHUNK1(o1, o0, g6, 341f)
- FREG_FROB(f24,f26,f28,f30,f32,f34,f36,f38,f40) LOOP_CHUNK2(o1, o0, g6, 342f)
- FREG_FROB(f40,f42,f44,f46,f0, f2, f4, f6, f8) LOOP_CHUNK3(o1, o0, g6, 343f)
- b,pt %xcc, 340b+4; faligndata %f8, %f10, %f48
-341: FREG_FROB(f24,f26,f28,f30,f32,f34,f36,f38,f40) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f40,f42,f44,f46,f0, f2, f4, f6, f8) STORE_JUMP(o0, f48, 408f) membar #Sync
-342: FREG_FROB(f40,f42,f44,f46,f0, f2, f4, f6, f8) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f8, f10,f12,f14,f16,f18,f20,f22,f24) STORE_JUMP(o0, f48, 424f) membar #Sync
-343: FREG_FROB(f8, f10,f12,f14,f16,f18,f20,f22,f24) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f24,f26,f28,f30,f32,f34,f36,f38,f40) STORE_JUMP(o0, f48, 440f) membar #Sync
- VISLOOP_PAD
-350: FREG_FROB(f10,f12,f14,f16,f18,f20,f22,f24,f26) LOOP_CHUNK1(o1, o0, g6, 351f)
- FREG_FROB(f26,f28,f30,f32,f34,f36,f38,f40,f42) LOOP_CHUNK2(o1, o0, g6, 352f)
- FREG_FROB(f42,f44,f46,f0, f2, f4, f6, f8, f10) LOOP_CHUNK3(o1, o0, g6, 353f)
- b,pt %xcc, 350b+4; faligndata %f10, %f12, %f48
-351: FREG_FROB(f26,f28,f30,f32,f34,f36,f38,f40,f42) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f42,f44,f46,f0, f2, f4, f6, f8, f10) STORE_JUMP(o0, f48, 410f) membar #Sync
-352: FREG_FROB(f42,f44,f46,f0, f2, f4, f6, f8, f10) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f10,f12,f14,f16,f18,f20,f22,f24,f26) STORE_JUMP(o0, f48, 426f) membar #Sync
-353: FREG_FROB(f10,f12,f14,f16,f18,f20,f22,f24,f26) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f26,f28,f30,f32,f34,f36,f38,f40,f42) STORE_JUMP(o0, f48, 442f) membar #Sync
- VISLOOP_PAD
-360: FREG_FROB(f12,f14,f16,f18,f20,f22,f24,f26,f28) LOOP_CHUNK1(o1, o0, g6, 361f)
- FREG_FROB(f28,f30,f32,f34,f36,f38,f40,f42,f44) LOOP_CHUNK2(o1, o0, g6, 362f)
- FREG_FROB(f44,f46,f0, f2, f4, f6, f8, f10,f12) LOOP_CHUNK3(o1, o0, g6, 363f)
- b,pt %xcc, 360b+4; faligndata %f12, %f14, %f48
-361: FREG_FROB(f28,f30,f32,f34,f36,f38,f40,f42,f44) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f44,f46,f0, f2, f4, f6, f8, f10,f12) STORE_JUMP(o0, f48, 412f) membar #Sync
-362: FREG_FROB(f44,f46,f0, f2, f4, f6, f8, f10,f12) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f12,f14,f16,f18,f20,f22,f24,f26,f28) STORE_JUMP(o0, f48, 428f) membar #Sync
-363: FREG_FROB(f12,f14,f16,f18,f20,f22,f24,f26,f28) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f28,f30,f32,f34,f36,f38,f40,f42,f44) STORE_JUMP(o0, f48, 444f) membar #Sync
- VISLOOP_PAD
-370: FREG_FROB(f14,f16,f18,f20,f22,f24,f26,f28,f30) LOOP_CHUNK1(o1, o0, g6, 371f)
- FREG_FROB(f30,f32,f34,f36,f38,f40,f42,f44,f46) LOOP_CHUNK2(o1, o0, g6, 372f)
- FREG_FROB(f46,f0, f2, f4, f6, f8, f10,f12,f14) LOOP_CHUNK3(o1, o0, g6, 373f)
- b,pt %xcc, 370b+4; faligndata %f14, %f16, %f48
-371: FREG_FROB(f30,f32,f34,f36,f38,f40,f42,f44,f46) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f46,f0, f2, f4, f6, f8, f10,f12,f14) STORE_JUMP(o0, f48, 414f) membar #Sync
-372: FREG_FROB(f46,f0, f2, f4, f6, f8, f10,f12,f14) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f14,f16,f18,f20,f22,f24,f26,f28,f30) STORE_JUMP(o0, f48, 430f) membar #Sync
-373: FREG_FROB(f14,f16,f18,f20,f22,f24,f26,f28,f30) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f30,f32,f34,f36,f38,f40,f42,f44,f46) STORE_JUMP(o0, f48, 446f) membar #Sync
- VISLOOP_PAD
-400: FINISH_VISCHUNK(o0, f0, f2, g3)
-402: FINISH_VISCHUNK(o0, f2, f4, g3)
-404: FINISH_VISCHUNK(o0, f4, f6, g3)
-406: FINISH_VISCHUNK(o0, f6, f8, g3)
-408: FINISH_VISCHUNK(o0, f8, f10, g3)
-410: FINISH_VISCHUNK(o0, f10, f12, g3)
-412: FINISH_VISCHUNK(o0, f12, f14, g3)
-414: UNEVEN_VISCHUNK(o0, f14, f0, g3)
-416: FINISH_VISCHUNK(o0, f16, f18, g3)
-418: FINISH_VISCHUNK(o0, f18, f20, g3)
-420: FINISH_VISCHUNK(o0, f20, f22, g3)
-422: FINISH_VISCHUNK(o0, f22, f24, g3)
-424: FINISH_VISCHUNK(o0, f24, f26, g3)
-426: FINISH_VISCHUNK(o0, f26, f28, g3)
-428: FINISH_VISCHUNK(o0, f28, f30, g3)
-430: UNEVEN_VISCHUNK(o0, f30, f0, g3)
-432: FINISH_VISCHUNK(o0, f32, f34, g3)
-434: FINISH_VISCHUNK(o0, f34, f36, g3)
-436: FINISH_VISCHUNK(o0, f36, f38, g3)
-438: FINISH_VISCHUNK(o0, f38, f40, g3)
-440: FINISH_VISCHUNK(o0, f40, f42, g3)
-442: FINISH_VISCHUNK(o0, f42, f44, g3)
-444: FINISH_VISCHUNK(o0, f44, f46, g3)
-446: UNEVEN_VISCHUNK(o0, f46, f0, g3)
-204: ldd [%o1], %f2 /* Load Group */
- add %o1, 8, %o1 /* IEU0 */
- subcc %g3, 8, %g3 /* IEU1 */
- faligndata %f0, %f2, %f8 /* GRU Group */
- std %f8, [%o0] /* Store */
- bl,pn %xcc, 205f /* CTI */
- add %o0, 8, %o0 /* IEU0 Group */
- ldd [%o1], %f0 /* Load Group */
- add %o1, 8, %o1 /* IEU0 */
- subcc %g3, 8, %g3 /* IEU1 */
- faligndata %f2, %f0, %f8 /* GRU Group */
- std %f8, [%o0] /* Store */
- bge,pt %xcc, 204b /* CTI */
- add %o0, 8, %o0 /* IEU0 Group */
-205: brz,pt %o2, 207f /* CTI Group */
- mov %g1, %o1 /* IEU0 */
-206: ldub [%o1], %g5 /* LOAD */
- add %o1, 1, %o1 /* IEU0 */
- add %o0, 1, %o0 /* IEU1 */
- subcc %o2, 1, %o2 /* IEU1 */
- bne,pt %xcc, 206b /* CTI */
- stb %g5, [%o0 - 1] /* Store Group */
-207: membar #StoreLoad | #StoreStore /* LSU Group */
- wr %g0, FPRS_FEF, %fprs
- retl
- mov %g4, %o0
-
-208: andcc %o2, 1, %g0 /* IEU1 Group */
- be,pt %icc, 2f+4 /* CTI */
-1: ldub [%o1], %g5 /* LOAD Group */
- add %o1, 1, %o1 /* IEU0 */
- add %o0, 1, %o0 /* IEU1 */
- subcc %o2, 1, %o2 /* IEU1 Group */
- be,pn %xcc, 209f /* CTI */
- stb %g5, [%o0 - 1] /* Store */
-2: ldub [%o1], %g5 /* LOAD Group */
- add %o0, 2, %o0 /* IEU0 */
- ldub [%o1 + 1], %o5 /* LOAD Group */
- add %o1, 2, %o1 /* IEU0 */
- subcc %o2, 2, %o2 /* IEU1 Group */
- stb %g5, [%o0 - 2] /* Store */
- bne,pt %xcc, 2b /* CTI */
- stb %o5, [%o0 - 1] /* Store */
-209: retl
- mov %g4, %o0
-
-#ifdef USE_BPR
-
- /* void *__align_cpy_4(void *dest, void *src, size_t n)
- * SPARC v9 SYSV ABI
- * Like memcpy, but results are undefined if (!n || ((dest | src | n) & 3))
- */
-
- .align 32
-ENTRY(__align_cpy_4)
- mov %o0, %g4 /* IEU0 Group */
- cmp %o2, 15 /* IEU1 */
- bleu,pn %xcc, 208b /* CTI */
- cmp %o2, (64 * 6) /* IEU1 Group */
- bgeu,pn %xcc, 200b /* CTI */
- andcc %o0, 7, %g2 /* IEU1 Group */
- ba,pt %xcc, 216f /* CTI */
- andcc %o1, 4, %g0 /* IEU1 Group */
-END(__align_cpy_4)
-
- /* void *__align_cpy_8(void *dest, void *src, size_t n)
- * SPARC v9 SYSV ABI
- * Like memcpy, but results are undefined if (!n || ((dest | src | n) & 7))
- */
-
- .align 32
-ENTRY(__align_cpy_8)
- mov %o0, %g4 /* IEU0 Group */
- cmp %o2, 15 /* IEU1 */
- bleu,pn %xcc, 208b /* CTI */
- cmp %o2, (64 * 6) /* IEU1 Group */
- bgeu,pn %xcc, 201b /* CTI */
- andcc %o0, 0x38, %g5 /* IEU1 Group */
- andcc %o2, -128, %g6 /* IEU1 Group */
- bne,a,pt %xcc, 82f + 4 /* CTI */
- ldx [%o1], %g1 /* Load */
- ba,pt %xcc, 41f /* CTI Group */
- andcc %o2, 0x70, %g6 /* IEU1 */
-END(__align_cpy_8)
-
- /* void *__align_cpy_16(void *dest, void *src, size_t n)
- * SPARC v9 SYSV ABI
- * Like memcpy, but results are undefined if (!n || ((dest | src | n) & 15))
- */
-
- .align 32
-ENTRY(__align_cpy_16)
- mov %o0, %g4 /* IEU0 Group */
- cmp %o2, (64 * 6) /* IEU1 */
- bgeu,pn %xcc, 201b /* CTI */
- andcc %o0, 0x38, %g5 /* IEU1 Group */
- andcc %o2, -128, %g6 /* IEU1 Group */
- bne,a,pt %xcc, 82f + 4 /* CTI */
- ldx [%o1], %g1 /* Load */
- ba,pt %xcc, 41f /* CTI Group */
- andcc %o2, 0x70, %g6 /* IEU1 */
-END(__align_cpy_16)
-
-#endif
-
- .align 32
-ENTRY(memcpy)
-210:
-#ifndef USE_BPR
- srl %o2, 0, %o2 /* IEU1 Group */
-#endif
- brz,pn %o2, 209b /* CTI Group */
- mov %o0, %g4 /* IEU0 */
-218: cmp %o2, 15 /* IEU1 Group */
- bleu,pn %xcc, 208b /* CTI */
- cmp %o2, (64 * 6) /* IEU1 Group */
- bgeu,pn %xcc, 200b /* CTI */
- andcc %o0, 7, %g2 /* IEU1 Group */
- sub %o0, %o1, %g5 /* IEU0 */
- andcc %g5, 3, %o5 /* IEU1 Group */
- bne,pn %xcc, 212f /* CTI */
- andcc %o1, 3, %g0 /* IEU1 Group */
- be,a,pt %xcc, 216f /* CTI */
- andcc %o1, 4, %g0 /* IEU1 Group */
- andcc %o1, 1, %g0 /* IEU1 Group */
- be,pn %xcc, 4f /* CTI */
- andcc %o1, 2, %g0 /* IEU1 Group */
- ldub [%o1], %g2 /* Load Group */
- add %o1, 1, %o1 /* IEU0 */
- add %o0, 1, %o0 /* IEU1 */
- sub %o2, 1, %o2 /* IEU0 Group */
- bne,pn %xcc, 5f /* CTI Group */
- stb %g2, [%o0 - 1] /* Store */
-4: lduh [%o1], %g2 /* Load Group */
- add %o1, 2, %o1 /* IEU0 */
- add %o0, 2, %o0 /* IEU1 */
- sub %o2, 2, %o2 /* IEU0 */
- sth %g2, [%o0 - 2] /* Store Group + bubble */
-5: andcc %o1, 4, %g0 /* IEU1 */
-216: be,a,pn %xcc, 2f /* CTI */
- andcc %o2, -128, %g6 /* IEU1 Group */
- lduw [%o1], %g5 /* Load Group */
- add %o1, 4, %o1 /* IEU0 */
- add %o0, 4, %o0 /* IEU1 */
- sub %o2, 4, %o2 /* IEU0 Group */
- stw %g5, [%o0 - 4] /* Store */
- andcc %o2, -128, %g6 /* IEU1 Group */
-2: be,pn %xcc, 215f /* CTI */
- andcc %o0, 4, %g0 /* IEU1 Group */
- be,pn %xcc, 82f + 4 /* CTI Group */
-5: MOVE_BIGCHUNK(o1, o0, 0x00, g1, g3, g5, o5)
- MOVE_BIGCHUNK(o1, o0, 0x20, g1, g3, g5, o5)
- MOVE_BIGCHUNK(o1, o0, 0x40, g1, g3, g5, o5)
- MOVE_BIGCHUNK(o1, o0, 0x60, g1, g3, g5, o5)
-35: subcc %g6, 128, %g6 /* IEU1 Group */
- add %o1, 128, %o1 /* IEU0 */
- bne,pt %xcc, 5b /* CTI */
- add %o0, 128, %o0 /* IEU0 Group */
-215: andcc %o2, 0x70, %g6 /* IEU1 Group */
-41: be,pn %xcc, 80f /* CTI */
- andcc %o2, 8, %g0 /* IEU1 Group */
- /* Clk1 8-( */
- /* Clk2 8-( */
- /* Clk3 8-( */
- /* Clk4 8-( */
-79: rd %pc, %o5 /* PDU Group */
- sll %g6, 1, %g5 /* IEU0 Group */
- add %o1, %g6, %o1 /* IEU1 */
- sub %o5, %g5, %o5 /* IEU0 Group */
- jmpl %o5 + %lo(80f - 79b), %g0 /* CTI Group brk forced*/
- add %o0, %g6, %o0 /* IEU0 Group */
-36: MOVE_LASTCHUNK(o1, o0, 0x60, g2, g3, g5, o5)
- MOVE_LASTCHUNK(o1, o0, 0x50, g2, g3, g5, o5)
- MOVE_LASTCHUNK(o1, o0, 0x40, g2, g3, g5, o5)
- MOVE_LASTCHUNK(o1, o0, 0x30, g2, g3, g5, o5)
- MOVE_LASTCHUNK(o1, o0, 0x20, g2, g3, g5, o5)
- MOVE_LASTCHUNK(o1, o0, 0x10, g2, g3, g5, o5)
- MOVE_LASTCHUNK(o1, o0, 0x00, g2, g3, g5, o5)
-80: be,pt %xcc, 81f /* CTI */
- andcc %o2, 4, %g0 /* IEU1 */
- ldx [%o1], %g2 /* Load Group */
- add %o0, 8, %o0 /* IEU0 */
- stw %g2, [%o0 - 0x4] /* Store Group */
- add %o1, 8, %o1 /* IEU1 */
- srlx %g2, 32, %g2 /* IEU0 Group */
- stw %g2, [%o0 - 0x8] /* Store */
-81: be,pt %xcc, 1f /* CTI */
- andcc %o2, 2, %g0 /* IEU1 Group */
- lduw [%o1], %g2 /* Load Group */
- add %o1, 4, %o1 /* IEU0 */
- stw %g2, [%o0] /* Store Group */
- add %o0, 4, %o0 /* IEU0 */
-1: be,pt %xcc, 1f /* CTI */
- andcc %o2, 1, %g0 /* IEU1 Group */
- lduh [%o1], %g2 /* Load Group */
- add %o1, 2, %o1 /* IEU0 */
- sth %g2, [%o0] /* Store Group */
- add %o0, 2, %o0 /* IEU0 */
-1: be,pt %xcc, 211f /* CTI */
- nop /* IEU1 */
- ldub [%o1], %g2 /* Load Group */
- stb %g2, [%o0] /* Store Group + bubble */
-211: retl
- mov %g4, %o0
-
-82: MOVE_BIGALIGNCHUNK(o1, o0, 0x00, g1, g3, g5, o5)
- MOVE_BIGALIGNCHUNK(o1, o0, 0x40, g1, g3, g5, o5)
-37: subcc %g6, 128, %g6 /* IEU1 Group */
- add %o1, 128, %o1 /* IEU0 */
- bne,pt %xcc, 82b /* CTI */
- add %o0, 128, %o0 /* IEU0 Group */
- andcc %o2, 0x70, %g6 /* IEU1 */
- be,pn %xcc, 84f /* CTI */
- andcc %o2, 8, %g0 /* IEU1 Group */
- /* Clk1 8-( */
- /* Clk2 8-( */
- /* Clk3 8-( */
- /* Clk4 8-( */
-83: rd %pc, %o5 /* PDU Group */
- add %o1, %g6, %o1 /* IEU0 Group */
- sub %o5, %g6, %o5 /* IEU1 */
- jmpl %o5 + %lo(84f - 83b), %g0 /* CTI Group brk forced*/
- add %o0, %g6, %o0 /* IEU0 Group */
-38: MOVE_LASTALIGNCHUNK(o1, o0, 0x60, g2, g3)
- MOVE_LASTALIGNCHUNK(o1, o0, 0x50, g2, g3)
- MOVE_LASTALIGNCHUNK(o1, o0, 0x40, g2, g3)
- MOVE_LASTALIGNCHUNK(o1, o0, 0x30, g2, g3)
- MOVE_LASTALIGNCHUNK(o1, o0, 0x20, g2, g3)
- MOVE_LASTALIGNCHUNK(o1, o0, 0x10, g2, g3)
- MOVE_LASTALIGNCHUNK(o1, o0, 0x00, g2, g3)
-84: be,pt %xcc, 85f /* CTI Group */
- andcc %o2, 4, %g0 /* IEU1 */
- ldx [%o1], %g2 /* Load Group */
- add %o0, 8, %o0 /* IEU0 */
- add %o1, 8, %o1 /* IEU0 Group */
- stx %g2, [%o0 - 0x8] /* Store */
-85: be,pt %xcc, 1f /* CTI */
- andcc %o2, 2, %g0 /* IEU1 Group */
- lduw [%o1], %g2 /* Load Group */
- add %o0, 4, %o0 /* IEU0 */
- add %o1, 4, %o1 /* IEU0 Group */
- stw %g2, [%o0 - 0x4] /* Store */
-1: be,pt %xcc, 1f /* CTI */
- andcc %o2, 1, %g0 /* IEU1 Group */
- lduh [%o1], %g2 /* Load Group */
- add %o0, 2, %o0 /* IEU0 */
- add %o1, 2, %o1 /* IEU0 Group */
- sth %g2, [%o0 - 0x2] /* Store */
-1: be,pt %xcc, 1f /* CTI */
- nop /* IEU0 Group */
- ldub [%o1], %g2 /* Load Group */
- stb %g2, [%o0] /* Store Group + bubble */
-1: retl
- mov %g4, %o0
-
-212: brz,pt %g2, 2f /* CTI Group */
- mov 8, %g1 /* IEU0 */
- sub %g1, %g2, %g2 /* IEU0 Group */
- sub %o2, %g2, %o2 /* IEU0 Group */
-1: ldub [%o1], %g5 /* Load Group */
- add %o1, 1, %o1 /* IEU0 */
- add %o0, 1, %o0 /* IEU1 */
- subcc %g2, 1, %g2 /* IEU1 Group */
- bne,pt %xcc, 1b /* CTI */
- stb %g5, [%o0 - 1] /* Store */
-2: andn %o2, 7, %g5 /* IEU0 Group */
- and %o2, 7, %o2 /* IEU1 */
- fmovd %f0, %f2 /* FPU */
- alignaddr %o1, %g0, %g1 /* GRU Group */
- ldd [%g1], %f4 /* Load Group */
-1: ldd [%g1 + 0x8], %f6 /* Load Group */
- add %g1, 0x8, %g1 /* IEU0 Group */
- subcc %g5, 8, %g5 /* IEU1 */
- faligndata %f4, %f6, %f0 /* GRU Group */
- std %f0, [%o0] /* Store */
- add %o1, 8, %o1 /* IEU0 Group */
- be,pn %xcc, 213f /* CTI */
- add %o0, 8, %o0 /* IEU1 */
- ldd [%g1 + 0x8], %f4 /* Load Group */
- add %g1, 8, %g1 /* IEU0 */
- subcc %g5, 8, %g5 /* IEU1 */
- faligndata %f6, %f4, %f0 /* GRU Group */
- std %f0, [%o0] /* Store */
- add %o1, 8, %o1 /* IEU0 */
- bne,pn %xcc, 1b /* CTI Group */
- add %o0, 8, %o0 /* IEU0 */
-213: brz,pn %o2, 214f /* CTI Group */
- nop /* IEU0 */
- ldub [%o1], %g5 /* LOAD */
- add %o1, 1, %o1 /* IEU0 */
- add %o0, 1, %o0 /* IEU1 */
- subcc %o2, 1, %o2 /* IEU1 */
- bne,pt %xcc, 206b /* CTI */
- stb %g5, [%o0 - 1] /* Store Group */
-214: wr %g0, FPRS_FEF, %fprs
- retl
- mov %g4, %o0
-END(memcpy)
-libc_hidden_def(memcpy)
-
- .align 32
-228: andcc %o2, 1, %g0 /* IEU1 Group */
- be,pt %icc, 2f+4 /* CTI */
-1: ldub [%o1 - 1], %o5 /* LOAD Group */
- sub %o1, 1, %o1 /* IEU0 */
- sub %o0, 1, %o0 /* IEU1 */
- subcc %o2, 1, %o2 /* IEU1 Group */
- be,pn %xcc, 229f /* CTI */
- stb %o5, [%o0] /* Store */
-2: ldub [%o1 - 1], %o5 /* LOAD Group */
- sub %o0, 2, %o0 /* IEU0 */
- ldub [%o1 - 2], %g5 /* LOAD Group */
- sub %o1, 2, %o1 /* IEU0 */
- subcc %o2, 2, %o2 /* IEU1 Group */
- stb %o5, [%o0 + 1] /* Store */
- bne,pt %xcc, 2b /* CTI */
- stb %g5, [%o0] /* Store */
-229: retl
- mov %g4, %o0
-219: retl
- nop
-
- .align 32
-ENTRY(memmove)
-#ifndef USE_BPR
- srl %o2, 0, %o2 /* IEU1 Group */
-#endif
- brz,pn %o2, 219b /* CTI Group */
- sub %o0, %o1, %o4 /* IEU0 */
- cmp %o4, %o2 /* IEU1 Group */
- bgeu,pt %XCC, 218b /* CTI */
- mov %o0, %g4 /* IEU0 */
- add %o0, %o2, %o0 /* IEU0 Group */
-220: add %o1, %o2, %o1 /* IEU1 */
- cmp %o2, 15 /* IEU1 Group */
- bleu,pn %xcc, 228b /* CTI */
- andcc %o0, 7, %g2 /* IEU1 Group */
- sub %o0, %o1, %g5 /* IEU0 */
- andcc %g5, 3, %o5 /* IEU1 Group */
- bne,pn %xcc, 232f /* CTI */
- andcc %o1, 3, %g0 /* IEU1 Group */
- be,a,pt %xcc, 236f /* CTI */
- andcc %o1, 4, %g0 /* IEU1 Group */
- andcc %o1, 1, %g0 /* IEU1 Group */
- be,pn %xcc, 4f /* CTI */
- andcc %o1, 2, %g0 /* IEU1 Group */
- ldub [%o1 - 1], %g2 /* Load Group */
- sub %o1, 1, %o1 /* IEU0 */
- sub %o0, 1, %o0 /* IEU1 */
- sub %o2, 1, %o2 /* IEU0 Group */
- be,pn %xcc, 5f /* CTI Group */
- stb %g2, [%o0] /* Store */
-4: lduh [%o1 - 2], %g2 /* Load Group */
- sub %o1, 2, %o1 /* IEU0 */
- sub %o0, 2, %o0 /* IEU1 */
- sub %o2, 2, %o2 /* IEU0 */
- sth %g2, [%o0] /* Store Group + bubble */
-5: andcc %o1, 4, %g0 /* IEU1 */
-236: be,a,pn %xcc, 2f /* CTI */
- andcc %o2, -128, %g6 /* IEU1 Group */
- lduw [%o1 - 4], %g5 /* Load Group */
- sub %o1, 4, %o1 /* IEU0 */
- sub %o0, 4, %o0 /* IEU1 */
- sub %o2, 4, %o2 /* IEU0 Group */
- stw %g5, [%o0] /* Store */
- andcc %o2, -128, %g6 /* IEU1 Group */
-2: be,pn %xcc, 235f /* CTI */
- andcc %o0, 4, %g0 /* IEU1 Group */
- be,pn %xcc, 282f + 4 /* CTI Group */
-5: RMOVE_BIGCHUNK(o1, o0, 0x00, g1, g3, g5, o5)
- RMOVE_BIGCHUNK(o1, o0, 0x20, g1, g3, g5, o5)
- RMOVE_BIGCHUNK(o1, o0, 0x40, g1, g3, g5, o5)
- RMOVE_BIGCHUNK(o1, o0, 0x60, g1, g3, g5, o5)
- subcc %g6, 128, %g6 /* IEU1 Group */
- sub %o1, 128, %o1 /* IEU0 */
- bne,pt %xcc, 5b /* CTI */
- sub %o0, 128, %o0 /* IEU0 Group */
-235: andcc %o2, 0x70, %g6 /* IEU1 Group */
-41: be,pn %xcc, 280f /* CTI */
- andcc %o2, 8, %g0 /* IEU1 Group */
- /* Clk1 8-( */
- /* Clk2 8-( */
- /* Clk3 8-( */
- /* Clk4 8-( */
-279: rd %pc, %o5 /* PDU Group */
- sll %g6, 1, %g5 /* IEU0 Group */
- sub %o1, %g6, %o1 /* IEU1 */
- sub %o5, %g5, %o5 /* IEU0 Group */
- jmpl %o5 + %lo(280f - 279b), %g0 /* CTI Group brk forced*/
- sub %o0, %g6, %o0 /* IEU0 Group */
- RMOVE_LASTCHUNK(o1, o0, 0x60, g2, g3, g5, o5)
- RMOVE_LASTCHUNK(o1, o0, 0x50, g2, g3, g5, o5)
- RMOVE_LASTCHUNK(o1, o0, 0x40, g2, g3, g5, o5)
- RMOVE_LASTCHUNK(o1, o0, 0x30, g2, g3, g5, o5)
- RMOVE_LASTCHUNK(o1, o0, 0x20, g2, g3, g5, o5)
- RMOVE_LASTCHUNK(o1, o0, 0x10, g2, g3, g5, o5)
- RMOVE_LASTCHUNK(o1, o0, 0x00, g2, g3, g5, o5)
-280: be,pt %xcc, 281f /* CTI */
- andcc %o2, 4, %g0 /* IEU1 */
- ldx [%o1 - 8], %g2 /* Load Group */
- sub %o0, 8, %o0 /* IEU0 */
- stw %g2, [%o0 + 4] /* Store Group */
- sub %o1, 8, %o1 /* IEU1 */
- srlx %g2, 32, %g2 /* IEU0 Group */
- stw %g2, [%o0] /* Store */
-281: be,pt %xcc, 1f /* CTI */
- andcc %o2, 2, %g0 /* IEU1 Group */
- lduw [%o1 - 4], %g2 /* Load Group */
- sub %o1, 4, %o1 /* IEU0 */
- stw %g2, [%o0 - 4] /* Store Group */
- sub %o0, 4, %o0 /* IEU0 */
-1: be,pt %xcc, 1f /* CTI */
- andcc %o2, 1, %g0 /* IEU1 Group */
- lduh [%o1 - 2], %g2 /* Load Group */
- sub %o1, 2, %o1 /* IEU0 */
- sth %g2, [%o0 - 2] /* Store Group */
- sub %o0, 2, %o0 /* IEU0 */
-1: be,pt %xcc, 211f /* CTI */
- nop /* IEU1 */
- ldub [%o1 - 1], %g2 /* Load Group */
- stb %g2, [%o0 - 1] /* Store Group + bubble */
-211: retl
- mov %g4, %o0
-
-282: RMOVE_BIGALIGNCHUNK(o1, o0, 0x00, g1, g3, g5, o5)
- RMOVE_BIGALIGNCHUNK(o1, o0, 0x40, g1, g3, g5, o5)
- subcc %g6, 128, %g6 /* IEU1 Group */
- sub %o1, 128, %o1 /* IEU0 */
- bne,pt %xcc, 282b /* CTI */
- sub %o0, 128, %o0 /* IEU0 Group */
- andcc %o2, 0x70, %g6 /* IEU1 */
- be,pn %xcc, 284f /* CTI */
- andcc %o2, 8, %g0 /* IEU1 Group */
- /* Clk1 8-( */
- /* Clk2 8-( */
- /* Clk3 8-( */
- /* Clk4 8-( */
-283: rd %pc, %o5 /* PDU Group */
- sub %o1, %g6, %o1 /* IEU0 Group */
- sub %o5, %g6, %o5 /* IEU1 */
- jmpl %o5 + %lo(284f - 283b), %g0 /* CTI Group brk forced*/
- sub %o0, %g6, %o0 /* IEU0 Group */
- RMOVE_LASTALIGNCHUNK(o1, o0, 0x60, g2, g3)
- RMOVE_LASTALIGNCHUNK(o1, o0, 0x50, g2, g3)
- RMOVE_LASTALIGNCHUNK(o1, o0, 0x40, g2, g3)
- RMOVE_LASTALIGNCHUNK(o1, o0, 0x30, g2, g3)
- RMOVE_LASTALIGNCHUNK(o1, o0, 0x20, g2, g3)
- RMOVE_LASTALIGNCHUNK(o1, o0, 0x10, g2, g3)
- RMOVE_LASTALIGNCHUNK(o1, o0, 0x00, g2, g3)
-284: be,pt %xcc, 285f /* CTI Group */
- andcc %o2, 4, %g0 /* IEU1 */
- ldx [%o1 - 8], %g2 /* Load Group */
- sub %o0, 8, %o0 /* IEU0 */
- sub %o1, 8, %o1 /* IEU0 Group */
- stx %g2, [%o0] /* Store */
-285: be,pt %xcc, 1f /* CTI */
- andcc %o2, 2, %g0 /* IEU1 Group */
- lduw [%o1 - 4], %g2 /* Load Group */
- sub %o0, 4, %o0 /* IEU0 */
- sub %o1, 4, %o1 /* IEU0 Group */
- stw %g2, [%o0] /* Store */
-1: be,pt %xcc, 1f /* CTI */
- andcc %o2, 1, %g0 /* IEU1 Group */
- lduh [%o1 - 2], %g2 /* Load Group */
- sub %o0, 2, %o0 /* IEU0 */
- sub %o1, 2, %o1 /* IEU0 Group */
- sth %g2, [%o0] /* Store */
-1: be,pt %xcc, 1f /* CTI */
- nop /* IEU0 Group */
- ldub [%o1 - 1], %g2 /* Load Group */
- stb %g2, [%o0 - 1] /* Store Group + bubble */
-1: retl
- mov %g4, %o0
-
-232: brz,pt %g2, 2f /* CTI Group */
- sub %o2, %g2, %o2 /* IEU0 Group */
-1: ldub [%o1 - 1], %g5 /* Load Group */
- sub %o1, 1, %o1 /* IEU0 */
- sub %o0, 1, %o0 /* IEU1 */
- subcc %g2, 1, %g2 /* IEU1 Group */
- bne,pt %xcc, 1b /* CTI */
- stb %g5, [%o0] /* Store */
-2: andn %o2, 7, %g5 /* IEU0 Group */
- and %o2, 7, %o2 /* IEU1 */
- fmovd %f0, %f2 /* FPU */
- alignaddr %o1, %g0, %g1 /* GRU Group */
- ldd [%g1], %f4 /* Load Group */
-1: ldd [%g1 - 8], %f6 /* Load Group */
- sub %g1, 8, %g1 /* IEU0 Group */
- subcc %g5, 8, %g5 /* IEU1 */
- faligndata %f6, %f4, %f0 /* GRU Group */
- std %f0, [%o0 - 8] /* Store */
- sub %o1, 8, %o1 /* IEU0 Group */
- be,pn %xcc, 233f /* CTI */
- sub %o0, 8, %o0 /* IEU1 */
- ldd [%g1 - 8], %f4 /* Load Group */
- sub %g1, 8, %g1 /* IEU0 */
- subcc %g5, 8, %g5 /* IEU1 */
- faligndata %f4, %f6, %f0 /* GRU Group */
- std %f0, [%o0 - 8] /* Store */
- sub %o1, 8, %o1 /* IEU0 */
- bne,pn %xcc, 1b /* CTI Group */
- sub %o0, 8, %o0 /* IEU0 */
-233: brz,pn %o2, 234f /* CTI Group */
- nop /* IEU0 */
-237: ldub [%o1 - 1], %g5 /* LOAD */
- sub %o1, 1, %o1 /* IEU0 */
- sub %o0, 1, %o0 /* IEU1 */
- subcc %o2, 1, %o2 /* IEU1 */
- bne,pt %xcc, 237b /* CTI */
- stb %g5, [%o0] /* Store Group */
-234: wr %g0, FPRS_FEF, %fprs
- retl
- mov %g4, %o0
-END(memmove)
-libc_hidden_def(memmove)
-
-#ifdef USE_BPR
-weak_alias(memcpy,__align_cpy_1)
-weak_alias(memcpy,__align_cpy_2)
-#endif
diff --git a/libc/string/sparc/sparc64/memset.S b/libc/string/sparc/sparc64/memset.S
deleted file mode 100644
index 50e404bcc..000000000
--- a/libc/string/sparc/sparc64/memset.S
+++ /dev/null
@@ -1,317 +0,0 @@
-/* Set a block of memory to some byte value.
- For UltraSPARC.
- Copyright (C) 1996, 97, 98, 99, 2003 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by David S. Miller (davem@caip.rutgers.edu) 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, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#include <features.h>
-#include <asm/asi.h>
-#ifndef XCC
-#define XCC xcc
-#define USE_BPR
-#endif
-#define FPRS_FEF 4
-
-#define SET_BLOCKS(base, offset, source) \
- stx source, [base - offset - 0x18]; \
- stx source, [base - offset - 0x10]; \
- stx source, [base - offset - 0x08]; \
- stx source, [base - offset - 0x00];
-
- /* Well, memset is a lot easier to get right than bcopy... */
- .text
- .align 32
-ENTRY(memset)
- andcc %o1, 0xff, %o1
- mov %o0, %o5
- be,a,pt %icc, 50f
-#ifndef USE_BPR
- srl %o2, 0, %o1
-#else
- mov %o2, %o1
-#endif
- cmp %o2, 7
-#ifndef USE_BPR
- srl %o2, 0, %o2
-#endif
- bleu,pn %XCC, 17f
- andcc %o0, 3, %g5
- be,pt %xcc, 4f
- and %o1, 0xff, %o1
- cmp %g5, 3
- be,pn %xcc, 2f
- stb %o1, [%o0 + 0x00]
- cmp %g5, 2
- be,pt %xcc, 2f
- stb %o1, [%o0 + 0x01]
- stb %o1, [%o0 + 0x02]
-2: sub %g5, 4, %g5
- sub %o0, %g5, %o0
- add %o2, %g5, %o2
-4: sllx %o1, 8, %g1
- andcc %o0, 4, %g0
- or %o1, %g1, %o1
- sllx %o1, 16, %g1
- or %o1, %g1, %o1
- be,pt %xcc, 2f
- sllx %o1, 32, %g1
- stw %o1, [%o0]
- sub %o2, 4, %o2
- add %o0, 4, %o0
-2: cmp %o2, 128
- or %o1, %g1, %o1
- blu,pn %xcc, 9f
- andcc %o0, 0x38, %g5
- be,pn %icc, 6f
- mov 64, %o4
- andcc %o0, 8, %g0
- be,pn %icc, 1f
- sub %o4, %g5, %o4
- stx %o1, [%o0]
- add %o0, 8, %o0
-1: andcc %o4, 16, %g0
- be,pn %icc, 1f
- sub %o2, %o4, %o2
- stx %o1, [%o0]
- stx %o1, [%o0 + 8]
- add %o0, 16, %o0
-1: andcc %o4, 32, %g0
- be,pn %icc, 7f
- andncc %o2, 0x3f, %o3
- stw %o1, [%o0]
- stw %o1, [%o0 + 4]
- stw %o1, [%o0 + 8]
- stw %o1, [%o0 + 12]
- stw %o1, [%o0 + 16]
- stw %o1, [%o0 + 20]
- stw %o1, [%o0 + 24]
- stw %o1, [%o0 + 28]
- add %o0, 32, %o0
-7: be,pn %xcc, 9f
- nop
- ldd [%o0 - 8], %f0
-18: wr %g0, ASI_BLK_P, %asi
- membar #StoreStore | #LoadStore
- andcc %o3, 0xc0, %g5
- and %o2, 0x3f, %o2
- fmovd %f0, %f2
- fmovd %f0, %f4
- andn %o3, 0xff, %o3
- fmovd %f0, %f6
- cmp %g5, 64
- fmovd %f0, %f8
- fmovd %f0, %f10
- fmovd %f0, %f12
- brz,pn %g5, 10f
- fmovd %f0, %f14
- be,pn %icc, 2f
- stda %f0, [%o0 + 0x00] %asi
- cmp %g5, 128
- be,pn %icc, 2f
- stda %f0, [%o0 + 0x40] %asi
- stda %f0, [%o0 + 0x80] %asi
-2: brz,pn %o3, 12f
- add %o0, %g5, %o0
-10: stda %f0, [%o0 + 0x00] %asi
- stda %f0, [%o0 + 0x40] %asi
- stda %f0, [%o0 + 0x80] %asi
- stda %f0, [%o0 + 0xc0] %asi
-11: subcc %o3, 256, %o3
- bne,pt %xcc, 10b
- add %o0, 256, %o0
-12: wr %g0, FPRS_FEF, %fprs
- membar #StoreLoad | #StoreStore
-9: andcc %o2, 0x78, %g5
- be,pn %xcc, 13f
- andcc %o2, 7, %o2
-14: rd %pc, %o4
- srl %g5, 1, %o3
- sub %o4, %o3, %o4
- jmpl %o4 + (13f - 14b), %g0
- add %o0, %g5, %o0
-12: SET_BLOCKS (%o0, 0x68, %o1)
- SET_BLOCKS (%o0, 0x48, %o1)
- SET_BLOCKS (%o0, 0x28, %o1)
- SET_BLOCKS (%o0, 0x08, %o1)
-13: be,pn %xcc, 8f
- andcc %o2, 4, %g0
- be,pn %xcc, 1f
- andcc %o2, 2, %g0
- stw %o1, [%o0]
- add %o0, 4, %o0
-1: be,pn %xcc, 1f
- andcc %o2, 1, %g0
- sth %o1, [%o0]
- add %o0, 2, %o0
-1: bne,a,pn %xcc, 8f
- stb %o1, [%o0]
-8: retl
- mov %o5, %o0
-17: brz,pn %o2, 0f
-8: add %o0, 1, %o0
- subcc %o2, 1, %o2
- bne,pt %xcc, 8b
- stb %o1, [%o0 - 1]
-0: retl
- mov %o5, %o0
-
-6: stx %o1, [%o0]
- andncc %o2, 0x3f, %o3
- be,pn %xcc, 9b
- nop
- ba,pt %xcc, 18b
- ldd [%o0], %f0
-END(memset)
-libc_hidden_def(memset)
-
-#define ZERO_BLOCKS(base, offset, source) \
- stx source, [base - offset - 0x38]; \
- stx source, [base - offset - 0x30]; \
- stx source, [base - offset - 0x28]; \
- stx source, [base - offset - 0x20]; \
- stx source, [base - offset - 0x18]; \
- stx source, [base - offset - 0x10]; \
- stx source, [base - offset - 0x08]; \
- stx source, [base - offset - 0x00];
-
- .text
- .align 32
-#ifdef __UCLIBC_SUSV3_LEGACY__
-ENTRY(bzero)
-#ifndef USE_BPR
- srl %o1, 0, %o1
-#endif
- mov %o0, %o5
-#endif
-50: cmp %o1, 7
- bleu,pn %xcc, 17f
- andcc %o0, 3, %o2
- be,a,pt %xcc, 4f
- andcc %o0, 4, %g0
- cmp %o2, 3
- be,pn %xcc, 2f
- stb %g0, [%o0 + 0x00]
- cmp %o2, 2
- be,pt %xcc, 2f
- stb %g0, [%o0 + 0x01]
- stb %g0, [%o0 + 0x02]
-2: sub %o2, 4, %o2
- sub %o0, %o2, %o0
- add %o1, %o2, %o1
- andcc %o0, 4, %g0
-4: be,pt %xcc, 2f
- cmp %o1, 128
- stw %g0, [%o0]
- sub %o1, 4, %o1
- add %o0, 4, %o0
-2: blu,pn %xcc, 9f
- andcc %o0, 0x38, %o2
- be,pn %icc, 6f
- mov 64, %o4
- andcc %o0, 8, %g0
- be,pn %icc, 1f
- sub %o4, %o2, %o4
- stx %g0, [%o0]
- add %o0, 8, %o0
-1: andcc %o4, 16, %g0
- be,pn %icc, 1f
- sub %o1, %o4, %o1
- stx %g0, [%o0]
- stx %g0, [%o0 + 8]
- add %o0, 16, %o0
-1: andcc %o4, 32, %g0
- be,pn %icc, 7f
- andncc %o1, 0x3f, %o3
- stx %g0, [%o0]
- stx %g0, [%o0 + 8]
- stx %g0, [%o0 + 16]
- stx %g0, [%o0 + 24]
- add %o0, 32, %o0
-6: andncc %o1, 0x3f, %o3
-7: be,pn %xcc, 9f
- wr %g0, ASI_BLK_P, %asi
- membar #StoreLoad | #StoreStore | #LoadStore
- fzero %f0
- andcc %o3, 0xc0, %o2
- and %o1, 0x3f, %o1
- fzero %f2
- andn %o3, 0xff, %o3
- faddd %f0, %f2, %f4
- fmuld %f0, %f2, %f6
- cmp %o2, 64
- faddd %f0, %f2, %f8
- fmuld %f0, %f2, %f10
- faddd %f0, %f2, %f12
- brz,pn %o2, 10f
- fmuld %f0, %f2, %f14
- be,pn %icc, 2f
- stda %f0, [%o0 + 0x00] %asi
- cmp %o2, 128
- be,pn %icc, 2f
- stda %f0, [%o0 + 0x40] %asi
- stda %f0, [%o0 + 0x80] %asi
-2: brz,pn %o3, 12f
- add %o0, %o2, %o0
-10: stda %f0, [%o0 + 0x00] %asi
- stda %f0, [%o0 + 0x40] %asi
- stda %f0, [%o0 + 0x80] %asi
- stda %f0, [%o0 + 0xc0] %asi
-11: subcc %o3, 256, %o3
- bne,pt %xcc, 10b
- add %o0, 256, %o0
-12: wr %g0, FPRS_FEF, %fprs
- membar #StoreLoad | #StoreStore
-9: andcc %o1, 0xf8, %o2
- be,pn %xcc, 13f
- andcc %o1, 7, %o1
-14: rd %pc, %o4
- srl %o2, 1, %o3
- sub %o4, %o3, %o4
- jmpl %o4 + (13f - 14b), %g0
- add %o0, %o2, %o0
-12: ZERO_BLOCKS (%o0, 0xc8, %g0)
- ZERO_BLOCKS (%o0, 0x88, %g0)
- ZERO_BLOCKS (%o0, 0x48, %g0)
- ZERO_BLOCKS (%o0, 0x08, %g0)
-13: be,pn %xcc, 8f
- andcc %o1, 4, %g0
- be,pn %xcc, 1f
- andcc %o1, 2, %g0
- stw %g0, [%o0]
- add %o0, 4, %o0
-1: be,pn %xcc, 1f
- andcc %o1, 1, %g0
- sth %g0, [%o0]
- add %o0, 2, %o0
-1: bne,a,pn %xcc, 8f
- stb %g0, [%o0]
-8: retl
- mov %o5, %o0
-17: be,pn %xcc, 13b
- orcc %o1, 0, %g0
- be,pn %xcc, 0f
-8: add %o0, 1, %o0
- subcc %o1, 1, %o1
- bne,pt %xcc, 8b
- stb %g0, [%o0 - 1]
-0: retl
- mov %o5, %o0
-#ifdef __UCLIBC_SUSV3_LEGACY__
-END(bzero)
-#endif
diff --git a/libc/string/sparc/sparc64/sparcv9b/memcpy.S b/libc/string/sparc/sparc64/sparcv9b/memcpy.S
deleted file mode 100644
index 64f6a92e0..000000000
--- a/libc/string/sparc/sparc64/sparcv9b/memcpy.S
+++ /dev/null
@@ -1,612 +0,0 @@
-/* Copy SIZE bytes from SRC to DEST.
- For UltraSPARC-III.
- Copyright (C) 2001, 2003 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by 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, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#include <features.h>
-
-#define ASI_BLK_P 0xf0
-#define FPRS_FEF 0x04
-#define VISEntryHalf rd %fprs, %o5; wr %g0, FPRS_FEF, %fprs
-#define VISExitHalf and %o5, FPRS_FEF, %o5; wr %o5, 0x0, %fprs
-
-#ifndef XCC
-#define USE_BPR
-#define XCC xcc
-#endif
-
- .register %g2,#scratch
- .register %g3,#scratch
- .register %g6,#scratch
-
- .text
- .align 32
-
-#ifdef __UCLIBC_SUSV3_LEGACY__
-ENTRY(bcopy)
- sub %o1, %o0, %o4
- mov %o0, %g4
- cmp %o4, %o2
- mov %o1, %o0
- bgeu,pt %XCC, 100f
- mov %g4, %o1
-#ifndef USE_BPR
- srl %o2, 0, %o2
-#endif
- brnz,pn %o2, 220f
- add %o0, %o2, %o0
- retl
- nop
-END(bcopy)
-#endif
-
- /* Special/non-trivial issues of this code:
- *
- * 1) %o5 is preserved from VISEntryHalf to VISExitHalf
- * 2) Only low 32 FPU registers are used so that only the
- * lower half of the FPU register set is dirtied by this
- * code. This is especially important in the kernel.
- * 3) This code never prefetches cachelines past the end
- * of the source buffer.
- *
- * The cheetah's flexible spine, oversized liver, enlarged heart,
- * slender muscular body, and claws make it the swiftest hunter
- * in Africa and the fastest animal on land. Can reach speeds
- * of up to 2.4GB per second.
- */
- .align 32
-ENTRY(memcpy)
-
-100: /* %o0=dst, %o1=src, %o2=len */
- mov %o0, %g5
- cmp %o2, 0
- be,pn %XCC, out
-218: or %o0, %o1, %o3
- cmp %o2, 16
- bleu,a,pn %XCC, small_copy
- or %o3, %o2, %o3
-
- cmp %o2, 256
- blu,pt %XCC, medium_copy
- andcc %o3, 0x7, %g0
-
- ba,pt %xcc, enter
- andcc %o0, 0x3f, %g2
-
- /* Here len >= 256 and condition codes reflect execution
- * of "andcc %o0, 0x7, %g2", done by caller.
- */
- .align 64
-enter:
- /* Is 'dst' already aligned on an 64-byte boundary? */
- be,pt %XCC, 2f
-
- /* Compute abs((dst & 0x3f) - 0x40) into %g2. This is the number
- * of bytes to copy to make 'dst' 64-byte aligned. We pre-
- * subtract this from 'len'.
- */
- sub %g2, 0x40, %g2
- sub %g0, %g2, %g2
- sub %o2, %g2, %o2
-
- /* Copy %g2 bytes from src to dst, one byte at a time. */
-1: ldub [%o1 + 0x00], %o3
- add %o1, 0x1, %o1
- add %o0, 0x1, %o0
- subcc %g2, 0x1, %g2
-
- bg,pt %XCC, 1b
- stb %o3, [%o0 + -1]
-
-2: VISEntryHalf
- and %o1, 0x7, %g1
- ba,pt %xcc, begin
- alignaddr %o1, %g0, %o1
-
- .align 64
-begin:
- prefetch [%o1 + 0x000], #one_read
- prefetch [%o1 + 0x040], #one_read
- andn %o2, (0x40 - 1), %o4
- prefetch [%o1 + 0x080], #one_read
- prefetch [%o1 + 0x0c0], #one_read
- ldd [%o1 + 0x000], %f0
- prefetch [%o1 + 0x100], #one_read
- ldd [%o1 + 0x008], %f2
- prefetch [%o1 + 0x140], #one_read
- ldd [%o1 + 0x010], %f4
- prefetch [%o1 + 0x180], #one_read
- faligndata %f0, %f2, %f16
- ldd [%o1 + 0x018], %f6
- faligndata %f2, %f4, %f18
- ldd [%o1 + 0x020], %f8
- faligndata %f4, %f6, %f20
- ldd [%o1 + 0x028], %f10
- faligndata %f6, %f8, %f22
-
- ldd [%o1 + 0x030], %f12
- faligndata %f8, %f10, %f24
- ldd [%o1 + 0x038], %f14
- faligndata %f10, %f12, %f26
- ldd [%o1 + 0x040], %f0
-
- sub %o4, 0x80, %o4
- add %o1, 0x40, %o1
- ba,pt %xcc, loop
- srl %o4, 6, %o3
-
- .align 64
-loop:
- ldd [%o1 + 0x008], %f2
- faligndata %f12, %f14, %f28
- ldd [%o1 + 0x010], %f4
- faligndata %f14, %f0, %f30
- stda %f16, [%o0] ASI_BLK_P
- ldd [%o1 + 0x018], %f6
- faligndata %f0, %f2, %f16
-
- ldd [%o1 + 0x020], %f8
- faligndata %f2, %f4, %f18
- ldd [%o1 + 0x028], %f10
- faligndata %f4, %f6, %f20
- ldd [%o1 + 0x030], %f12
- faligndata %f6, %f8, %f22
- ldd [%o1 + 0x038], %f14
- faligndata %f8, %f10, %f24
-
- ldd [%o1 + 0x040], %f0
- prefetch [%o1 + 0x180], #one_read
- faligndata %f10, %f12, %f26
- subcc %o3, 0x01, %o3
- add %o1, 0x40, %o1
- bg,pt %XCC, loop
- add %o0, 0x40, %o0
-
- /* Finally we copy the last full 64-byte block. */
-loopfini:
- ldd [%o1 + 0x008], %f2
- faligndata %f12, %f14, %f28
- ldd [%o1 + 0x010], %f4
- faligndata %f14, %f0, %f30
- stda %f16, [%o0] ASI_BLK_P
- ldd [%o1 + 0x018], %f6
- faligndata %f0, %f2, %f16
- ldd [%o1 + 0x020], %f8
- faligndata %f2, %f4, %f18
- ldd [%o1 + 0x028], %f10
- faligndata %f4, %f6, %f20
- ldd [%o1 + 0x030], %f12
- faligndata %f6, %f8, %f22
- ldd [%o1 + 0x038], %f14
- faligndata %f8, %f10, %f24
- cmp %g1, 0
- be,pt %XCC, 1f
- add %o0, 0x40, %o0
- ldd [%o1 + 0x040], %f0
-1: faligndata %f10, %f12, %f26
- faligndata %f12, %f14, %f28
- faligndata %f14, %f0, %f30
- stda %f16, [%o0] ASI_BLK_P
- add %o0, 0x40, %o0
- add %o1, 0x40, %o1
- membar #Sync
-
- /* Now we copy the (len modulo 64) bytes at the end.
- * Note how we borrow the %f0 loaded above.
- *
- * Also notice how this code is careful not to perform a
- * load past the end of the src buffer.
- */
-loopend:
- and %o2, 0x3f, %o2
- andcc %o2, 0x38, %g2
- be,pn %XCC, endcruft
- subcc %g2, 0x8, %g2
- be,pn %XCC, endcruft
- cmp %g1, 0
-
- be,a,pt %XCC, 1f
- ldd [%o1 + 0x00], %f0
-
-1: ldd [%o1 + 0x08], %f2
- add %o1, 0x8, %o1
- sub %o2, 0x8, %o2
- subcc %g2, 0x8, %g2
- faligndata %f0, %f2, %f8
- std %f8, [%o0 + 0x00]
- be,pn %XCC, endcruft
- add %o0, 0x8, %o0
- ldd [%o1 + 0x08], %f0
- add %o1, 0x8, %o1
- sub %o2, 0x8, %o2
- subcc %g2, 0x8, %g2
- faligndata %f2, %f0, %f8
- std %f8, [%o0 + 0x00]
- bne,pn %XCC, 1b
- add %o0, 0x8, %o0
-
- /* If anything is left, we copy it one byte at a time.
- * Note that %g1 is (src & 0x3) saved above before the
- * alignaddr was performed.
- */
-endcruft:
- cmp %o2, 0
- add %o1, %g1, %o1
- VISExitHalf
- be,pn %XCC, out
- sub %o0, %o1, %o3
-
- andcc %g1, 0x7, %g0
- bne,pn %icc, small_copy_unaligned
- andcc %o2, 0x8, %g0
- be,pt %icc, 1f
- nop
- ldx [%o1], %o5
- stx %o5, [%o1 + %o3]
- add %o1, 0x8, %o1
-
-1: andcc %o2, 0x4, %g0
- be,pt %icc, 1f
- nop
- lduw [%o1], %o5
- stw %o5, [%o1 + %o3]
- add %o1, 0x4, %o1
-
-1: andcc %o2, 0x2, %g0
- be,pt %icc, 1f
- nop
- lduh [%o1], %o5
- sth %o5, [%o1 + %o3]
- add %o1, 0x2, %o1
-
-1: andcc %o2, 0x1, %g0
- be,pt %icc, out
- nop
- ldub [%o1], %o5
- ba,pt %xcc, out
- stb %o5, [%o1 + %o3]
-
-medium_copy: /* 16 < len <= 64 */
- bne,pn %XCC, small_copy_unaligned
- sub %o0, %o1, %o3
-
-medium_copy_aligned:
- andn %o2, 0x7, %o4
- and %o2, 0x7, %o2
-1: subcc %o4, 0x8, %o4
- ldx [%o1], %o5
- stx %o5, [%o1 + %o3]
- bgu,pt %XCC, 1b
- add %o1, 0x8, %o1
- andcc %o2, 0x4, %g0
- be,pt %XCC, 1f
- nop
- sub %o2, 0x4, %o2
- lduw [%o1], %o5
- stw %o5, [%o1 + %o3]
- add %o1, 0x4, %o1
-1: cmp %o2, 0
- be,pt %XCC, out
- nop
- ba,pt %xcc, small_copy_unaligned
- nop
-
-small_copy: /* 0 < len <= 16 */
- andcc %o3, 0x3, %g0
- bne,pn %XCC, small_copy_unaligned
- sub %o0, %o1, %o3
-
-small_copy_aligned:
- subcc %o2, 4, %o2
- lduw [%o1], %g1
- stw %g1, [%o1 + %o3]
- bgu,pt %XCC, small_copy_aligned
- add %o1, 4, %o1
-
-out: retl
- mov %g5, %o0
-
- .align 32
-small_copy_unaligned:
- subcc %o2, 1, %o2
- ldub [%o1], %g1
- stb %g1, [%o1 + %o3]
- bgu,pt %XCC, small_copy_unaligned
- add %o1, 1, %o1
- retl
- mov %g5, %o0
-
-END(memcpy)
-libc_hidden_def(memcpy)
-
-#define RMOVE_BIGCHUNK(src, dst, offset, t0, t1, t2, t3) \
- ldx [%src - offset - 0x20], %t0; \
- ldx [%src - offset - 0x18], %t1; \
- ldx [%src - offset - 0x10], %t2; \
- ldx [%src - offset - 0x08], %t3; \
- stw %t0, [%dst - offset - 0x1c]; \
- srlx %t0, 32, %t0; \
- stw %t0, [%dst - offset - 0x20]; \
- stw %t1, [%dst - offset - 0x14]; \
- srlx %t1, 32, %t1; \
- stw %t1, [%dst - offset - 0x18]; \
- stw %t2, [%dst - offset - 0x0c]; \
- srlx %t2, 32, %t2; \
- stw %t2, [%dst - offset - 0x10]; \
- stw %t3, [%dst - offset - 0x04]; \
- srlx %t3, 32, %t3; \
- stw %t3, [%dst - offset - 0x08];
-
-#define RMOVE_BIGALIGNCHUNK(src, dst, offset, t0, t1, t2, t3) \
- ldx [%src - offset - 0x20], %t0; \
- ldx [%src - offset - 0x18], %t1; \
- ldx [%src - offset - 0x10], %t2; \
- ldx [%src - offset - 0x08], %t3; \
- stx %t0, [%dst - offset - 0x20]; \
- stx %t1, [%dst - offset - 0x18]; \
- stx %t2, [%dst - offset - 0x10]; \
- stx %t3, [%dst - offset - 0x08]; \
- ldx [%src - offset - 0x40], %t0; \
- ldx [%src - offset - 0x38], %t1; \
- ldx [%src - offset - 0x30], %t2; \
- ldx [%src - offset - 0x28], %t3; \
- stx %t0, [%dst - offset - 0x40]; \
- stx %t1, [%dst - offset - 0x38]; \
- stx %t2, [%dst - offset - 0x30]; \
- stx %t3, [%dst - offset - 0x28];
-
-#define RMOVE_LASTCHUNK(src, dst, offset, t0, t1, t2, t3) \
- ldx [%src + offset + 0x00], %t0; \
- ldx [%src + offset + 0x08], %t1; \
- stw %t0, [%dst + offset + 0x04]; \
- srlx %t0, 32, %t2; \
- stw %t2, [%dst + offset + 0x00]; \
- stw %t1, [%dst + offset + 0x0c]; \
- srlx %t1, 32, %t3; \
- stw %t3, [%dst + offset + 0x08];
-
-#define RMOVE_LASTALIGNCHUNK(src, dst, offset, t0, t1) \
- ldx [%src + offset + 0x00], %t0; \
- ldx [%src + offset + 0x08], %t1; \
- stx %t0, [%dst + offset + 0x00]; \
- stx %t1, [%dst + offset + 0x08];
-
- .align 32
-228: andcc %o2, 1, %g0 /* IEU1 Group */
- be,pt %icc, 2f+4 /* CTI */
-1: ldub [%o1 - 1], %o5 /* LOAD Group */
- sub %o1, 1, %o1 /* IEU0 */
- sub %o0, 1, %o0 /* IEU1 */
- subcc %o2, 1, %o2 /* IEU1 Group */
- be,pn %xcc, 229f /* CTI */
- stb %o5, [%o0] /* Store */
-2: ldub [%o1 - 1], %o5 /* LOAD Group */
- sub %o0, 2, %o0 /* IEU0 */
- ldub [%o1 - 2], %g5 /* LOAD Group */
- sub %o1, 2, %o1 /* IEU0 */
- subcc %o2, 2, %o2 /* IEU1 Group */
- stb %o5, [%o0 + 1] /* Store */
- bne,pt %xcc, 2b /* CTI */
- stb %g5, [%o0] /* Store */
-229: retl
- mov %g4, %o0
-
- .align 32
-ENTRY(memmove)
- mov %o0, %g5
-#ifndef USE_BPR
- srl %o2, 0, %o2 /* IEU1 Group */
-#endif
- brz,pn %o2, out /* CTI Group */
- sub %o0, %o1, %o4 /* IEU0 */
- cmp %o4, %o2 /* IEU1 Group */
- bgeu,pt %XCC, 218b /* CTI */
- mov %o0, %g4 /* IEU0 */
- add %o0, %o2, %o0 /* IEU0 Group */
-220: add %o1, %o2, %o1 /* IEU1 */
- cmp %o2, 15 /* IEU1 Group */
- bleu,pn %xcc, 228b /* CTI */
- andcc %o0, 7, %g2 /* IEU1 Group */
- sub %o0, %o1, %g5 /* IEU0 */
- andcc %g5, 3, %o5 /* IEU1 Group */
- bne,pn %xcc, 232f /* CTI */
- andcc %o1, 3, %g0 /* IEU1 Group */
- be,a,pt %xcc, 236f /* CTI */
- andcc %o1, 4, %g0 /* IEU1 Group */
- andcc %o1, 1, %g0 /* IEU1 Group */
- be,pn %xcc, 4f /* CTI */
- andcc %o1, 2, %g0 /* IEU1 Group */
- ldub [%o1 - 1], %g2 /* Load Group */
- sub %o1, 1, %o1 /* IEU0 */
- sub %o0, 1, %o0 /* IEU1 */
- sub %o2, 1, %o2 /* IEU0 Group */
- be,pn %xcc, 5f /* CTI Group */
- stb %g2, [%o0] /* Store */
-4: lduh [%o1 - 2], %g2 /* Load Group */
- sub %o1, 2, %o1 /* IEU0 */
- sub %o0, 2, %o0 /* IEU1 */
- sub %o2, 2, %o2 /* IEU0 */
- sth %g2, [%o0] /* Store Group + bubble */
-5: andcc %o1, 4, %g0 /* IEU1 */
-236: be,a,pn %xcc, 2f /* CTI */
- andcc %o2, -128, %g6 /* IEU1 Group */
- lduw [%o1 - 4], %g5 /* Load Group */
- sub %o1, 4, %o1 /* IEU0 */
- sub %o0, 4, %o0 /* IEU1 */
- sub %o2, 4, %o2 /* IEU0 Group */
- stw %g5, [%o0] /* Store */
- andcc %o2, -128, %g6 /* IEU1 Group */
-2: be,pn %xcc, 235f /* CTI */
- andcc %o0, 4, %g0 /* IEU1 Group */
- be,pn %xcc, 282f + 4 /* CTI Group */
-5: RMOVE_BIGCHUNK(o1, o0, 0x00, g1, g3, g5, o5)
- RMOVE_BIGCHUNK(o1, o0, 0x20, g1, g3, g5, o5)
- RMOVE_BIGCHUNK(o1, o0, 0x40, g1, g3, g5, o5)
- RMOVE_BIGCHUNK(o1, o0, 0x60, g1, g3, g5, o5)
- subcc %g6, 128, %g6 /* IEU1 Group */
- sub %o1, 128, %o1 /* IEU0 */
- bne,pt %xcc, 5b /* CTI */
- sub %o0, 128, %o0 /* IEU0 Group */
-235: andcc %o2, 0x70, %g6 /* IEU1 Group */
-41: be,pn %xcc, 280f /* CTI */
- andcc %o2, 8, %g0 /* IEU1 Group */
- /* Clk1 8-( */
- /* Clk2 8-( */
- /* Clk3 8-( */
- /* Clk4 8-( */
-279: rd %pc, %o5 /* PDU Group */
- sll %g6, 1, %g5 /* IEU0 Group */
- sub %o1, %g6, %o1 /* IEU1 */
- sub %o5, %g5, %o5 /* IEU0 Group */
- jmpl %o5 + %lo(280f - 279b), %g0 /* CTI Group brk forced*/
- sub %o0, %g6, %o0 /* IEU0 Group */
- RMOVE_LASTCHUNK(o1, o0, 0x60, g2, g3, g5, o5)
- RMOVE_LASTCHUNK(o1, o0, 0x50, g2, g3, g5, o5)
- RMOVE_LASTCHUNK(o1, o0, 0x40, g2, g3, g5, o5)
- RMOVE_LASTCHUNK(o1, o0, 0x30, g2, g3, g5, o5)
- RMOVE_LASTCHUNK(o1, o0, 0x20, g2, g3, g5, o5)
- RMOVE_LASTCHUNK(o1, o0, 0x10, g2, g3, g5, o5)
- RMOVE_LASTCHUNK(o1, o0, 0x00, g2, g3, g5, o5)
-280: be,pt %xcc, 281f /* CTI */
- andcc %o2, 4, %g0 /* IEU1 */
- ldx [%o1 - 8], %g2 /* Load Group */
- sub %o0, 8, %o0 /* IEU0 */
- stw %g2, [%o0 + 4] /* Store Group */
- sub %o1, 8, %o1 /* IEU1 */
- srlx %g2, 32, %g2 /* IEU0 Group */
- stw %g2, [%o0] /* Store */
-281: be,pt %xcc, 1f /* CTI */
- andcc %o2, 2, %g0 /* IEU1 Group */
- lduw [%o1 - 4], %g2 /* Load Group */
- sub %o1, 4, %o1 /* IEU0 */
- stw %g2, [%o0 - 4] /* Store Group */
- sub %o0, 4, %o0 /* IEU0 */
-1: be,pt %xcc, 1f /* CTI */
- andcc %o2, 1, %g0 /* IEU1 Group */
- lduh [%o1 - 2], %g2 /* Load Group */
- sub %o1, 2, %o1 /* IEU0 */
- sth %g2, [%o0 - 2] /* Store Group */
- sub %o0, 2, %o0 /* IEU0 */
-1: be,pt %xcc, 211f /* CTI */
- nop /* IEU1 */
- ldub [%o1 - 1], %g2 /* Load Group */
- stb %g2, [%o0 - 1] /* Store Group + bubble */
-211: retl
- mov %g4, %o0
-
-282: RMOVE_BIGALIGNCHUNK(o1, o0, 0x00, g1, g3, g5, o5)
- RMOVE_BIGALIGNCHUNK(o1, o0, 0x40, g1, g3, g5, o5)
- subcc %g6, 128, %g6 /* IEU1 Group */
- sub %o1, 128, %o1 /* IEU0 */
- bne,pt %xcc, 282b /* CTI */
- sub %o0, 128, %o0 /* IEU0 Group */
- andcc %o2, 0x70, %g6 /* IEU1 */
- be,pn %xcc, 284f /* CTI */
- andcc %o2, 8, %g0 /* IEU1 Group */
- /* Clk1 8-( */
- /* Clk2 8-( */
- /* Clk3 8-( */
- /* Clk4 8-( */
-283: rd %pc, %o5 /* PDU Group */
- sub %o1, %g6, %o1 /* IEU0 Group */
- sub %o5, %g6, %o5 /* IEU1 */
- jmpl %o5 + %lo(284f - 283b), %g0 /* CTI Group brk forced*/
- sub %o0, %g6, %o0 /* IEU0 Group */
- RMOVE_LASTALIGNCHUNK(o1, o0, 0x60, g2, g3)
- RMOVE_LASTALIGNCHUNK(o1, o0, 0x50, g2, g3)
- RMOVE_LASTALIGNCHUNK(o1, o0, 0x40, g2, g3)
- RMOVE_LASTALIGNCHUNK(o1, o0, 0x30, g2, g3)
- RMOVE_LASTALIGNCHUNK(o1, o0, 0x20, g2, g3)
- RMOVE_LASTALIGNCHUNK(o1, o0, 0x10, g2, g3)
- RMOVE_LASTALIGNCHUNK(o1, o0, 0x00, g2, g3)
-284: be,pt %xcc, 285f /* CTI Group */
- andcc %o2, 4, %g0 /* IEU1 */
- ldx [%o1 - 8], %g2 /* Load Group */
- sub %o0, 8, %o0 /* IEU0 */
- sub %o1, 8, %o1 /* IEU0 Group */
- stx %g2, [%o0] /* Store */
-285: be,pt %xcc, 1f /* CTI */
- andcc %o2, 2, %g0 /* IEU1 Group */
- lduw [%o1 - 4], %g2 /* Load Group */
- sub %o0, 4, %o0 /* IEU0 */
- sub %o1, 4, %o1 /* IEU0 Group */
- stw %g2, [%o0] /* Store */
-1: be,pt %xcc, 1f /* CTI */
- andcc %o2, 1, %g0 /* IEU1 Group */
- lduh [%o1 - 2], %g2 /* Load Group */
- sub %o0, 2, %o0 /* IEU0 */
- sub %o1, 2, %o1 /* IEU0 Group */
- sth %g2, [%o0] /* Store */
-1: be,pt %xcc, 1f /* CTI */
- nop /* IEU0 Group */
- ldub [%o1 - 1], %g2 /* Load Group */
- stb %g2, [%o0 - 1] /* Store Group + bubble */
-1: retl
- mov %g4, %o0
-
-232: brz,pt %g2, 2f /* CTI Group */
- sub %o2, %g2, %o2 /* IEU0 Group */
-1: ldub [%o1 - 1], %g5 /* Load Group */
- sub %o1, 1, %o1 /* IEU0 */
- sub %o0, 1, %o0 /* IEU1 */
- subcc %g2, 1, %g2 /* IEU1 Group */
- bne,pt %xcc, 1b /* CTI */
- stb %g5, [%o0] /* Store */
-2: andn %o2, 7, %g5 /* IEU0 Group */
- and %o2, 7, %o2 /* IEU1 */
- fmovd %f0, %f2 /* FPU */
- alignaddr %o1, %g0, %g1 /* GRU Group */
- ldd [%g1], %f4 /* Load Group */
-1: ldd [%g1 - 8], %f6 /* Load Group */
- sub %g1, 8, %g1 /* IEU0 Group */
- subcc %g5, 8, %g5 /* IEU1 */
- faligndata %f6, %f4, %f0 /* GRU Group */
- std %f0, [%o0 - 8] /* Store */
- sub %o1, 8, %o1 /* IEU0 Group */
- be,pn %xcc, 233f /* CTI */
- sub %o0, 8, %o0 /* IEU1 */
- ldd [%g1 - 8], %f4 /* Load Group */
- sub %g1, 8, %g1 /* IEU0 */
- subcc %g5, 8, %g5 /* IEU1 */
- faligndata %f4, %f6, %f0 /* GRU Group */
- std %f0, [%o0 - 8] /* Store */
- sub %o1, 8, %o1 /* IEU0 */
- bne,pn %xcc, 1b /* CTI Group */
- sub %o0, 8, %o0 /* IEU0 */
-233: brz,pn %o2, 234f /* CTI Group */
- nop /* IEU0 */
-237: ldub [%o1 - 1], %g5 /* LOAD */
- sub %o1, 1, %o1 /* IEU0 */
- sub %o0, 1, %o0 /* IEU1 */
- subcc %o2, 1, %o2 /* IEU1 */
- bne,pt %xcc, 237b /* CTI */
- stb %g5, [%o0] /* Store Group */
-234: wr %g0, FPRS_FEF, %fprs
- retl
- mov %g4, %o0
-END(memmove)
-libc_hidden_def(memmove)
-
-#ifdef USE_BPR
-weak_alias(memcpy,__align_cpy_1)
-weak_alias(memcpy,__align_cpy_2)
-weak_alias(memcpy,__align_cpy_4)
-weak_alias(memcpy,__align_cpy_8)
-weak_alias(memcpy,__align_cpy_16)
-#endif
diff --git a/libc/string/sparc/sparc64/stpcpy.S b/libc/string/sparc/sparc64/stpcpy.S
deleted file mode 100644
index 8c26c6bec..000000000
--- a/libc/string/sparc/sparc64/stpcpy.S
+++ /dev/null
@@ -1,271 +0,0 @@
-/* Copy SRC to DEST returning the address of the terminating '\0' in DEST.
- For SPARC v9.
- Copyright (C) 1998, 1999, 2002, 2003, 2004 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Jan Vondrak <jvon4518@ss1000.ms.mff.cuni.cz> 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, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#include <asm/asi.h>
-#ifndef XCC
- .register %g2, #scratch
- .register %g3, #scratch
- .register %g6, #scratch
-#endif
-
- /* Normally, this uses
- ((xword - 0x0101010101010101) & 0x8080808080808080) test
- to find out if any byte in xword could be zero. This is fast, but
- also gives false alarm for any byte in range 0x81-0xff. It does
- not matter for correctness, as if this test tells us there could
- be some zero byte, we check it byte by byte, but if bytes with
- high bits set are common in the strings, then this will give poor
- performance. You can #define EIGHTBIT_NOT_RARE and the algorithm
- will use one tick slower, but more precise test
- ((xword - 0x0101010101010101) & (~xword) & 0x8080808080808080),
- which does not give any false alarms (but if some bits are set,
- one cannot assume from it which bytes are zero and which are not).
- It is yet to be measured, what is the correct default for glibc
- in these days for an average user.
- */
-
- .text
- .align 32
-ENTRY(stpcpy)
- sethi %hi(0x01010101), %g1 /* IEU0 Group */
- or %g1, %lo(0x01010101), %g1 /* IEU0 Group */
- andcc %o0, 7, %g0 /* IEU1 */
- sllx %g1, 32, %g2 /* IEU0 Group */
-
- bne,pn %icc, 12f /* CTI */
- andcc %o1, 7, %g3 /* IEU1 */
- or %g1, %g2, %g1 /* IEU0 Group */
- bne,pn %icc, 14f /* CTI */
-
- sllx %g1, 7, %g2 /* IEU0 Group */
-1: ldx [%o1], %o3 /* Load */
- add %o1, 8, %o1 /* IEU1 */
-2: mov %o3, %g3 /* IEU0 Group */
-
- sub %o3, %g1, %o2 /* IEU1 */
-3: ldxa [%o1] ASI_PNF, %o3 /* Load */
-#ifdef EIGHTBIT_NOT_RARE
- andn %o2, %g3, %o2 /* IEU0 Group */
-#endif
- add %o0, 8, %o0 /* IEU0 Group */
- andcc %o2, %g2, %g0 /* IEU1 */
-
- add %o1, 8, %o1 /* IEU0 Group */
- be,a,pt %xcc, 2b /* CTI */
- stx %g3, [%o0 - 8] /* Store */
- srlx %g3, 56, %g5 /* IEU0 Group */
-
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 11f /* CTI */
- srlx %g3, 48, %g4 /* IEU0 */
- andcc %g4, 0xff, %g0 /* IEU1 Group */
-
- be,pn %icc, 10f /* CTI */
- srlx %g3, 40, %g5 /* IEU0 */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 9f /* CTI */
-
- srlx %g3, 32, %g4 /* IEU0 */
- andcc %g4, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 8f /* CTI */
- srlx %g3, 24, %g5 /* IEU0 */
-
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 7f /* CTI */
- srlx %g3, 16, %g4 /* IEU0 */
- andcc %g4, 0xff, %g0 /* IEU1 Group */
-
- be,pn %icc, 6f /* CTI */
- srlx %g3, 8, %g5 /* IEU0 */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 5f /* CTI */
-
- sub %o3, %g1, %o2 /* IEU0 */
- stx %g3, [%o0 - 8] /* Store Group */
- andcc %g3, 0xff, %g0 /* IEU1 */
- bne,pt %icc, 3b /* CTI */
-
- mov %o3, %g3 /* IEU0 Group */
-4: retl /* CTI+IEU1 Group */
- sub %o0, 1, %o0 /* IEU0 */
-
- .align 16
-6: ba,pt %xcc, 23f /* CTI Group */
- sub %o0, 3, %g6 /* IEU0 */
-5: sub %o0, 2, %g6 /* IEU0 Group */
- stb %g5, [%o0 - 2] /* Store */
-
- srlx %g3, 16, %g4 /* IEU0 Group */
-23: sth %g4, [%o0 - 4] /* Store */
- srlx %g3, 32, %g4 /* IEU0 Group */
- stw %g4, [%o0 - 8] /* Store */
-
- retl /* CTI+IEU1 Group */
- mov %g6, %o0 /* IEU0 */
-8: ba,pt %xcc, 24f /* CTI Group */
- sub %o0, 5, %g6 /* IEU0 */
-
-7: sub %o0, 4, %g6 /* IEU0 Group */
- stb %g5, [%o0 - 4] /* Store */
- srlx %g3, 32, %g4 /* IEU0 Group */
-24: stw %g4, [%o0 - 8] /* Store */
-
- retl /* CTI+IEU1 Group */
- mov %g6, %o0 /* IEU0 */
-10: ba,pt %xcc, 25f /* CTI Group */
- sub %o0, 7, %g6 /* IEU0 */
-
-9: sub %o0, 6, %g6 /* IEU0 Group */
- stb %g5, [%o0 - 6] /* Store */
- srlx %g3, 48, %g4 /* IEU0 */
-25: sth %g4, [%o0 - 8] /* Store Group */
-
- retl /* CTI+IEU1 Group */
- mov %g6, %o0 /* IEU0 */
-11: stb %g5, [%o0 - 8] /* Store Group */
- retl /* CTI+IEU1 Group */
-
- sub %o0, 8, %o0 /* IEU0 */
-
- .align 16
-12: or %g1, %g2, %g1 /* IEU0 Group */
- ldub [%o1], %o3 /* Load */
- sllx %g1, 7, %g2 /* IEU0 Group */
- stb %o3, [%o0] /* Store Group */
-
-13: add %o0, 1, %o0 /* IEU0 */
- add %o1, 1, %o1 /* IEU1 */
- andcc %o3, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 4b /* CTI */
-
- lduba [%o1] ASI_PNF, %o3 /* Load */
- andcc %o0, 7, %g0 /* IEU1 Group */
- bne,a,pt %icc, 13b /* CTI */
- stb %o3, [%o0] /* Store */
-
- andcc %o1, 7, %g3 /* IEU1 Group */
- be,a,pt %icc, 1b /* CTI */
- ldx [%o1], %o3 /* Load */
-14: orcc %g0, 64, %g4 /* IEU1 Group */
-
- sllx %g3, 3, %g5 /* IEU0 */
- sub %o1, %g3, %o1 /* IEU0 Group */
- sub %g4, %g5, %g4 /* IEU1 */
- /* %g1 = 0101010101010101 *
- * %g2 = 8080808080808080 *
- * %g3 = source alignment *
- * %g5 = number of bits to shift left *
- * %g4 = number of bits to shift right */
- ldxa [%o1] ASI_PNF, %o5 /* Load Group */
-
- addcc %o1, 8, %o1 /* IEU1 */
-15: sllx %o5, %g5, %o3 /* IEU0 Group */
- ldxa [%o1] ASI_PNF, %o5 /* Load */
- srlx %o5, %g4, %o4 /* IEU0 Group */
-
- add %o0, 8, %o0 /* IEU1 */
- or %o3, %o4, %o3 /* IEU0 Group */
- add %o1, 8, %o1 /* IEU1 */
- sub %o3, %g1, %o4 /* IEU0 Group */
-
-#ifdef EIGHTBIT_NOT_RARE
- andn %o4, %o3, %o4 /* IEU0 Group */
-#endif
- andcc %o4, %g2, %g0 /* IEU1 Group */
- be,a,pt %xcc, 15b /* CTI */
- stx %o3, [%o0 - 8] /* Store */
- srlx %o3, 56, %o4 /* IEU0 Group */
-
- andcc %o4, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 22f /* CTI */
- srlx %o3, 48, %o4 /* IEU0 */
- andcc %o4, 0xff, %g0 /* IEU1 Group */
-
- be,pn %icc, 21f /* CTI */
- srlx %o3, 40, %o4 /* IEU0 */
- andcc %o4, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 20f /* CTI */
-
- srlx %o3, 32, %o4 /* IEU0 */
- andcc %o4, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 19f /* CTI */
- srlx %o3, 24, %o4 /* IEU0 */
-
- andcc %o4, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 18f /* CTI */
- srlx %o3, 16, %o4 /* IEU0 */
- andcc %o4, 0xff, %g0 /* IEU1 Group */
-
- be,pn %icc, 17f /* CTI */
- srlx %o3, 8, %o4 /* IEU0 */
- andcc %o4, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 16f /* CTI */
-
- andcc %o3, 0xff, %g0 /* IEU1 Group */
- bne,pn %icc, 15b /* CTI */
- stx %o3, [%o0 - 8] /* Store */
- retl /* CTI+IEU1 Group */
-
- sub %o0, 1, %o0 /* IEU0 */
-
- .align 16
-17: ba,pt %xcc, 26f /* CTI Group */
- subcc %o0, 3, %g6 /* IEU1 */
-18: ba,pt %xcc, 27f /* CTI Group */
- subcc %o0, 4, %g6 /* IEU1 */
-
-19: ba,pt %xcc, 28f /* CTI Group */
- subcc %o0, 5, %g6 /* IEU1 */
-16: subcc %o0, 2, %g6 /* IEU1 Group */
- srlx %o3, 8, %o4 /* IEU0 */
-
- stb %o4, [%o0 - 2] /* Store */
-26: srlx %o3, 16, %o4 /* IEU0 Group */
- stb %o4, [%o0 - 3] /* Store */
-27: srlx %o3, 24, %o4 /* IEU0 Group */
-
- stb %o4, [%o0 - 4] /* Store */
-28: srlx %o3, 32, %o4 /* IEU0 Group */
- stw %o4, [%o0 - 8] /* Store */
- retl /* CTI+IEU1 Group */
-
- mov %g6, %o0 /* IEU0 */
-
- .align 16
-21: ba,pt %xcc, 29f /* CTI Group */
- subcc %o0, 7, %g6 /* IEU1 */
-22: ba,pt %xcc, 30f /* CTI Group */
- subcc %o0, 8, %g6 /* IEU1 */
-
-20: subcc %o0, 6, %g6 /* IEU1 Group */
- srlx %o3, 40, %o4 /* IEU0 */
- stb %o4, [%o0 - 6] /* Store */
-29: srlx %o3, 48, %o4 /* IEU0 Group */
-
- stb %o4, [%o0 - 7] /* Store */
-30: srlx %o3, 56, %o4 /* IEU0 Group */
- stb %o4, [%o0 - 8] /* Store */
- retl /* CTI+IEU1 Group */
-
- mov %g6, %o0 /* IEU0 */
-END(stpcpy)
-libc_hidden_def(stpcpy)
diff --git a/libc/string/sparc/sparc64/strcat.S b/libc/string/sparc/sparc64/strcat.S
deleted file mode 100644
index fcc4ba59c..000000000
--- a/libc/string/sparc/sparc64/strcat.S
+++ /dev/null
@@ -1,339 +0,0 @@
-/* strcat (dest, src) -- Append SRC on the end of DEST.
- For SPARC v9.
- Copyright (C) 1998, 1999, 2003 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Jakub Jelinek <jj@ultra.linux.cz> and
- Jan Vondrak <jvon4518@ss1000.ms.mff.cuni.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, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#include <asm/asi.h>
-#ifndef XCC
-#define XCC xcc
-#define USE_BPR
- .register %g2, #scratch
- .register %g3, #scratch
- .register %g6, #scratch
-#endif
-
- /* Normally, this uses
- ((xword - 0x0101010101010101) & 0x8080808080808080) test
- to find out if any byte in xword could be zero. This is fast, but
- also gives false alarm for any byte in range 0x81-0xff. It does
- not matter for correctness, as if this test tells us there could
- be some zero byte, we check it byte by byte, but if bytes with
- high bits set are common in the strings, then this will give poor
- performance. You can #define EIGHTBIT_NOT_RARE and the algorithm
- will use one tick slower, but more precise test
- ((xword - 0x0101010101010101) & (~xword) & 0x8080808080808080),
- which does not give any false alarms (but if some bits are set,
- one cannot assume from it which bytes are zero and which are not).
- It is yet to be measured, what is the correct default for glibc
- in these days for an average user.
- */
-
- .text
- .align 32
-ENTRY(strcat)
- sethi %hi(0x01010101), %g1 /* IEU0 Group */
- ldub [%o0], %o3 /* Load */
- or %g1, %lo(0x01010101), %g1 /* IEU0 Group */
- mov %o0, %g6 /* IEU1 */
-
- sllx %g1, 32, %g2 /* IEU0 Group */
- andcc %o0, 7, %g0 /* IEU1 */
- or %g1, %g2, %g1 /* IEU0 Group */
- bne,pn %icc, 32f /* CTI */
-
- sllx %g1, 7, %g2 /* IEU0 Group */
- brz,pn %o3, 30f /* CTI+IEU1 */
- ldx [%o0], %o3 /* Load */
-48: add %o0, 8, %o0 /* IEU0 Group */
-
-49: sub %o3, %g1, %o2 /* IEU0 Group */
-#ifdef EIGHTBIT_NOT_RARE
- andn %o2, %o3, %g5 /* IEU0 Group */
- ldxa [%o0] ASI_PNF, %o3 /* Load */
- andcc %g5, %g2, %g0 /* IEU1 Group */
-#else
- ldxa [%o0] ASI_PNF, %o3 /* Load */
- andcc %o2, %g2, %g0 /* IEU1 Group */
-#endif
- be,pt %xcc, 49b /* CTI */
-
- add %o0, 8, %o0 /* IEU0 */
- addcc %o2, %g1, %g3 /* IEU1 Group */
- srlx %o2, 32, %o2 /* IEU0 */
-50: andcc %o2, %g2, %g0 /* IEU1 Group */
-
- be,pn %xcc, 51f /* CTI */
- srlx %g3, 56, %o2 /* IEU0 */
- andcc %o2, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 29f /* CTI */
-
- srlx %g3, 48, %o2 /* IEU0 */
- andcc %o2, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 28f /* CTI */
- srlx %g3, 40, %o2 /* IEU0 */
-
- andcc %o2, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 27f /* CTI */
- srlx %g3, 32, %o2 /* IEU0 */
- andcc %o2, 0xff, %g0 /* IEU1 Group */
-
- be,pn %icc, 26f /* CTI */
-51: srlx %g3, 24, %o2 /* IEU0 */
- andcc %o2, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 25f /* CTI */
-
- srlx %g3, 16, %o2 /* IEU0 */
- andcc %o2, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 24f /* CTI */
- srlx %g3, 8, %o2 /* IEU0 */
-
- andcc %o2, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 23f /* CTI */
- sub %o3, %g1, %o2 /* IEU0 */
- andcc %g3, 0xff, %g0 /* IEU1 Group */
-
- be,pn %icc, 52f /* CTI */
- ldxa [%o0] ASI_PNF, %o3 /* Load */
- andcc %o2, %g2, %g0 /* IEU1 Group */
- be,pt %xcc, 49b /* CTI */
-
- add %o0, 8, %o0 /* IEU0 */
- addcc %o2, %g1, %g3 /* IEU1 Group */
- ba,pt %xcc, 50b /* CTI */
- srlx %o2, 32, %o2 /* IEU0 */
-
- .align 16
-52: ba,pt %xcc, 12f /* CTI Group */
- add %o0, -9, %o0 /* IEU0 */
-23: ba,pt %xcc, 12f /* CTI Group */
- add %o0, -10, %o0 /* IEU0 */
-
-24: ba,pt %xcc, 12f /* CTI Group */
- add %o0, -11, %o0 /* IEU0 */
-25: ba,pt %xcc, 12f /* CTI Group */
- add %o0, -12, %o0 /* IEU0 */
-
-26: ba,pt %xcc, 12f /* CTI Group */
- add %o0, -13, %o0 /* IEU0 */
-27: ba,pt %xcc, 12f /* CTI Group */
- add %o0, -14, %o0 /* IEU0 */
-
-28: ba,pt %xcc, 12f /* CTI Group */
- add %o0, -15, %o0 /* IEU0 */
-29: add %o0, -16, %o0 /* IEU0 Group */
-30: andcc %o1, 7, %g3 /* IEU1 */
-
-31: bne,pn %icc, 14f /* CTI */
- orcc %g0, 64, %g4 /* IEU1 Group */
-1: ldx [%o1], %o3 /* Load */
- add %o1, 8, %o1 /* IEU1 */
-
-2: mov %o3, %g3 /* IEU0 Group */
-3: sub %o3, %g1, %o2 /* IEU1 */
- ldxa [%o1] ASI_PNF, %o3 /* Load */
-#ifdef EIGHTBIT_NOT_RARE
- andn %o2, %g3, %o2 /* IEU0 Group */
-#endif
- add %o0, 8, %o0 /* IEU0 Group */
-
- andcc %o2, %g2, %g0 /* IEU1 */
- add %o1, 8, %o1 /* IEU0 Group */
- be,a,pt %xcc, 2b /* CTI */
- stx %g3, [%o0 - 8] /* Store */
-
- srlx %g3, 56, %g5 /* IEU0 Group */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 11f /* CTI */
- srlx %g3, 48, %g4 /* IEU0 */
-
- andcc %g4, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 10f /* CTI */
- srlx %g3, 40, %g5 /* IEU0 */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
-
- be,pn %icc, 9f /* CTI */
- srlx %g3, 32, %g4 /* IEU0 */
- andcc %g4, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 8f /* CTI */
-
- srlx %g3, 24, %g5 /* IEU0 */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 7f /* CTI */
- srlx %g3, 16, %g4 /* IEU0 */
-
- andcc %g4, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 6f /* CTI */
- srlx %g3, 8, %g5 /* IEU0 */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
-
- be,pn %icc, 5f /* CTI */
- sub %o3, %g1, %o2 /* IEU0 */
- stx %g3, [%o0 - 8] /* Store Group */
- andcc %g3, 0xff, %g0 /* IEU1 */
-
- bne,pt %icc, 3b /* CTI */
- mov %o3, %g3 /* IEU0 Group */
-4: retl /* CTI+IEU1 Group */
- mov %g6, %o0 /* IEU0 */
-
- .align 16
-5: stb %g5, [%o0 - 2] /* Store Group */
- srlx %g3, 16, %g4 /* IEU0 */
-6: sth %g4, [%o0 - 4] /* Store Group */
- srlx %g3, 32, %g4 /* IEU0 */
-
- stw %g4, [%o0 - 8] /* Store Group */
- retl /* CTI+IEU1 Group */
- mov %g6, %o0 /* IEU0 */
-7: stb %g5, [%o0 - 4] /* Store Group */
-
- srlx %g3, 32, %g4 /* IEU0 */
-8: stw %g4, [%o0 - 8] /* Store Group */
- retl /* CTI+IEU1 Group */
- mov %g6, %o0 /* IEU0 */
-
-9: stb %g5, [%o0 - 6] /* Store Group */
- srlx %g3, 48, %g4 /* IEU0 */
-10: sth %g4, [%o0 - 8] /* Store Group */
- retl /* CTI+IEU1 Group */
-
- mov %g6, %o0 /* IEU0 */
-11: stb %g5, [%o0 - 8] /* Store Group */
- retl /* CTI+IEU1 Group */
- mov %g6, %o0 /* IEU0 */
-
- .align 16
-32: andcc %o0, 7, %g0 /* IEU1 Group */
- be,a,pn %icc, 48b /* CTI */
- ldx [%o0], %o3 /* Load */
- add %o0, 1, %o0 /* IEU0 Group */
-
- brnz,a,pt %o3, 32b /* CTI+IEU1 */
- lduba [%o0] ASI_PNF, %o3 /* Load */
- add %o0, -1, %o0 /* IEU0 Group */
- andcc %o0, 7, %g0 /* IEU1 Group */
-
- be,a,pn %icc, 31b /* CTI */
- andcc %o1, 7, %g3 /* IEU1 Group */
-12: ldub [%o1], %o3 /* Load */
- stb %o3, [%o0] /* Store Group */
-
-13: add %o0, 1, %o0 /* IEU0 */
- add %o1, 1, %o1 /* IEU1 */
- andcc %o3, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 4b /* CTI */
-
- lduba [%o1] ASI_PNF, %o3 /* Load */
- andcc %o0, 7, %g0 /* IEU1 Group */
- bne,a,pt %icc, 13b /* CTI */
- stb %o3, [%o0] /* Store */
-
- andcc %o1, 7, %g3 /* IEU1 Group */
- be,a,pt %icc, 1b /* CTI */
- ldx [%o1], %o3 /* Load */
- orcc %g0, 64, %g4 /* IEU1 Group */
-
-14: sllx %g3, 3, %g5 /* IEU0 */
- sub %o1, %g3, %o1 /* IEU0 Group */
- sub %g4, %g5, %g4 /* IEU1 */
- /* %g1 = 0101010101010101 *
- * %g2 = 8080808080808080 *
- * %g3 = source alignment *
- * %g5 = number of bits to shift left *
- * %g4 = number of bits to shift right */
- ldxa [%o1] ASI_PNF, %o5 /* Load Group */
-
- addcc %o1, 8, %o1 /* IEU1 */
-15: sllx %o5, %g5, %o3 /* IEU0 Group */
- ldxa [%o1] ASI_PNF, %o5 /* Load */
- srlx %o5, %g4, %o4 /* IEU0 Group */
-
- add %o0, 8, %o0 /* IEU1 */
- or %o3, %o4, %o3 /* IEU0 Group */
- add %o1, 8, %o1 /* IEU1 */
- sub %o3, %g1, %o4 /* IEU0 Group */
-
-#ifdef EIGHTBIT_NOT_RARE
- andn %o4, %o3, %o4 /* IEU0 Group */
-#endif
- andcc %o4, %g2, %g0 /* IEU1 Group */
- be,a,pt %xcc, 15b /* CTI */
- stx %o3, [%o0 - 8] /* Store */
- srlx %o3, 56, %o4 /* IEU0 Group */
-
- andcc %o4, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 22f /* CTI */
- srlx %o3, 48, %o4 /* IEU0 */
- andcc %o4, 0xff, %g0 /* IEU1 Group */
-
- be,pn %icc, 21f /* CTI */
- srlx %o3, 40, %o4 /* IEU0 */
- andcc %o4, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 20f /* CTI */
-
- srlx %o3, 32, %o4 /* IEU0 */
- andcc %o4, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 19f /* CTI */
- srlx %o3, 24, %o4 /* IEU0 */
-
- andcc %o4, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 18f /* CTI */
- srlx %o3, 16, %o4 /* IEU0 */
- andcc %o4, 0xff, %g0 /* IEU1 Group */
-
- be,pn %icc, 17f /* CTI */
- srlx %o3, 8, %o4 /* IEU0 */
- andcc %o4, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 16f /* CTI */
-
- andcc %o3, 0xff, %g0 /* IEU1 Group */
- bne,pn %icc, 15b /* CTI */
- stx %o3, [%o0 - 8] /* Store */
- retl /* CTI+IEU1 Group */
-
- mov %g6, %o0 /* IEU0 */
-
- .align 16
-16: srlx %o3, 8, %o4 /* IEU0 Group */
- stb %o4, [%o0 - 2] /* Store */
-17: srlx %o3, 16, %o4 /* IEU0 Group */
- stb %o4, [%o0 - 3] /* Store */
-
-18: srlx %o3, 24, %o4 /* IEU0 Group */
- stb %o4, [%o0 - 4] /* Store */
-19: srlx %o3, 32, %o4 /* IEU0 Group */
- stw %o4, [%o0 - 8] /* Store */
-
- retl /* CTI+IEU1 Group */
- mov %g6, %o0 /* IEU0 */
- nop
- nop
-
-20: srlx %o3, 40, %o4 /* IEU0 Group */
- stb %o4, [%o0 - 6] /* Store */
-21: srlx %o3, 48, %o4 /* IEU0 Group */
- stb %o4, [%o0 - 7] /* Store */
-
-22: srlx %o3, 56, %o4 /* IEU0 Group */
- stb %o4, [%o0 - 8] /* Store */
- retl /* CTI+IEU1 Group */
- mov %g6, %o0 /* IEU0 */
-END(strcat)
-libc_hidden_def(strcat)
diff --git a/libc/string/sparc/sparc64/strchr.S b/libc/string/sparc/sparc64/strchr.S
deleted file mode 100644
index da26d1f9c..000000000
--- a/libc/string/sparc/sparc64/strchr.S
+++ /dev/null
@@ -1,486 +0,0 @@
-/* strchr (str, ch) -- Return pointer to first occurrence of CH in STR.
- For SPARC v9.
- Copyright (C) 1998, 1999, 2003 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Jan Vondrak <jvon4518@ss1000.ms.mff.cuni.cz> 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, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#include <features.h>
-#include <asm/asi.h>
-#ifndef XCC
-#define XCC xcc
-#define USE_BPR
- .register %g2, #scratch
- .register %g3, #scratch
- .register %g6, #scratch
-#endif
-
- /* Normally, this uses
- ((xword - 0x0101010101010101) & 0x8080808080808080) test
- to find out if any byte in xword could be zero. This is fast, but
- also gives false alarm for any byte in range 0x81-0xff. It does
- not matter for correctness, as if this test tells us there could
- be some zero byte, we check it byte by byte, but if bytes with
- high bits set are common in the strings, then this will give poor
- performance. You can #define EIGHTBIT_NOT_RARE and the algorithm
- will use one tick slower, but more precise test
- ((xword - 0x0101010101010101) & (~xword) & 0x8080808080808080),
- which does not give any false alarms (but if some bits are set,
- one cannot assume from it which bytes are zero and which are not).
- It is yet to be measured, what is the correct default for glibc
- in these days for an average user.
- */
-
- .text
- .align 32
-ENTRY(strchr)
- andcc %o1, 0xff, %o1 /* IEU1 Group */
- be,pn %icc, 17f /* CTI */
- sllx %o1, 8, %g3 /* IEU0 Group */
- sethi %hi(0x01010101), %g1 /* IEU1 */
-
- or %g3, %o1, %g3 /* IEU0 Group */
- ldub [%o0], %o3 /* Load */
- sllx %g3, 16, %g5 /* IEU0 Group */
- or %g1, %lo(0x01010101), %g1 /* IEU1 */
-
- sllx %g1, 32, %g2 /* IEU0 Group */
- brz,pn %o3, 5f /* CTI+IEU1 */
- orcc %g3, %g5, %g3 /* IEU1 Group */
- sllx %g3, 32, %g5 /* IEU0 */
-
- cmp %o3, %o1 /* IEU1 Group */
- be,pn %xcc, 14f /* CTI */
- or %g1, %g2, %g1 /* IEU0 */
- andcc %o0, 7, %g0 /* IEU1 Group */
-
- bne,a,pn %icc, 15f /* CTI */
- add %o0, 1, %o0 /* IEU0 */
- ldx [%o0], %o3 /* Load Group */
-1: sllx %g1, 7, %g2 /* IEU0 */
-
- or %g3, %g5, %g3 /* IEU1 */
- add %o0, 8, %o0 /* IEU0 Group */
- xor %o3, %g3, %o4 /* IEU1 */
- /* %g1 = 0101010101010101 *
- * %g2 = 8080088080808080 *
- * %g3 = c c c c c c c c *
- * %o3 = value *
- * %o4 = value XOR c */
-2: sub %o3, %g1, %o2 /* IEU0 Group */
-
- sub %o4, %g1, %o5 /* IEU1 */
-#ifdef EIGHTBIT_NOT_RARE
- andn %o2, %o3, %g6 /* IEU0 Group */
- andn %o5, %o4, %o5 /* IEU1 */
- ldxa [%o0] ASI_PNF, %o3 /* Load */
- or %o5, %g6, %o5 /* IEU0 Group */
-#else
- ldxa [%o0] ASI_PNF, %o3 /* Load */
- or %o5, %o2, %o5 /* IEU0 Group */
-#endif
- add %o0, 8, %o0 /* IEU1 */
-
- andcc %o5, %g2, %g0 /* IEU1 Group */
- be,a,pt %xcc, 2b /* CTI */
- xor %o3, %g3, %o4 /* IEU0 */
- srlx %o5, 32, %g5 /* IEU0 Group */
-
- add %o2, %g1, %o2 /* IEU1 */
-3: andcc %g5, %g2, %g0 /* IEU1 Group */
- be,pn %xcc, 4f /* CTI */
- srlx %o2, 56, %g5 /* IEU0 */
-
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 5f /* CTI */
- srlx %o4, 56, %g5 /* IEU0 */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
-
- be,pn %icc, 6f /* CTI */
- srlx %o2, 48, %g5 /* IEU0 */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 5f /* CTI */
-
- srlx %o4, 48, %g5 /* IEU0 */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 7f /* CTI */
- srlx %o2, 40, %g5 /* IEU0 */
-
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 5f /* CTI */
- srlx %o4, 40, %g5 /* IEU0 */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
-
- be,pn %icc, 8f /* CTI */
- srlx %o2, 32, %g5 /* IEU0 */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 5f /* CTI */
-
- srlx %o4, 32, %g5 /* IEU0 */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 9f /* CTI */
-4: srlx %o2, 24, %g5 /* IEU0 */
-
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 5f /* CTI */
- srlx %o4, 24, %g5 /* IEU0 */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
-
- be,pn %icc, 10f /* CTI */
- srlx %o2, 16, %g5 /* IEU0 */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 5f /* CTI */
-
- srlx %o4, 16, %g5 /* IEU0 */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 11f /* CTI */
- srlx %o2, 8, %g5 /* IEU0 */
-
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 5f /* CTI */
- srlx %o4, 8, %g5 /* IEU0 */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
-
- be,pn %icc, 12f /* CTI */
- andcc %o2, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 5f /* CTI */
- sub %o3, %g1, %o2 /* IEU0 */
-
- andcc %o4, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 13f /* CTI */
- xor %o3, %g3, %o4 /* IEU0 */
- ldxa [%o0] ASI_PNF, %o3 /* Load Group */
-
- sub %o4, %g1, %o5 /* IEU0 */
- or %o5, %o2, %o5 /* IEU1 */
- add %o0, 8, %o0 /* IEU0 Group */
- andcc %o5, %g2, %g0 /* IEU1 */
-
- be,a,pt %xcc, 2b /* CTI */
- xor %o3, %g3, %o4 /* IEU0 Group */
- srlx %o5, 32, %g5 /* IEU0 Group */
- ba,pt %xcc, 3b /* CTI */
-
- add %o2, %g1, %o2 /* IEU1 */
-
- .align 16
-5: retl /* CTI+IEU1 Group */
- clr %o0 /* IEU0 */
-6: retl /* CTI+IEU1 Group */
- add %o0, -16, %o0 /* IEU0 */
-
-7: retl /* CTI+IEU1 Group */
- add %o0, -15, %o0 /* IEU0 */
-8: retl /* CTI+IEU1 Group */
- add %o0, -14, %o0 /* IEU0 */
-
-9: retl /* CTI+IEU1 Group */
- add %o0, -13, %o0 /* IEU0 */
-10: retl /* CTI+IEU1 Group */
- add %o0, -12, %o0 /* IEU0 */
-
-11: retl /* CTI+IEU1 Group */
- add %o0, -11, %o0 /* IEU0 */
-12: retl /* CTI+IEU1 Group */
- add %o0, -10, %o0 /* IEU0 */
-
-13: retl /* CTI+IEU1 Group */
- add %o0, -9, %o0 /* IEU0 */
-14: retl /* CTI+IEU1 Group */
- nop /* IEU0 */
-
- .align 16
-15: ldub [%o0], %o3 /* Load Group */
-16: andcc %o0, 7, %g0 /* IEU1 */
- be,a,pn %icc, 1b /* CTI */
- ldx [%o0], %o3 /* Load Group */
-
- andcc %o3, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 5b /* CTI */
- add %o0, 1, %o0 /* IEU0 */
- cmp %o3, %o1 /* IEU1 Group */
-
- bne,a,pn %icc, 16b /* CTI */
- ldub [%o0], %o3 /* Load */
- retl /* CTI+IEU1 Group */
- add %o0, -1, %o0 /* IEU0 */
-
- /* strchr (str, 0) */
- .align 32
- nop
- .align 16
-17: sethi %hi(0x01010101), %g1 /* IEU0 Group */
- ldub [%o0], %o3 /* Load */
- or %g1, %lo(0x01010101), %g1 /* IEU0 Group */
- sllx %g1, 32, %g2 /* IEU0 Group */
-
- andcc %o0, 7, %g0 /* IEU1 */
- or %g1, %g2, %g1 /* IEU0 Group */
- bne,pn %icc, 32f /* CTI */
- sllx %g1, 7, %g2 /* IEU0 Group */
-
- brz,pn %o3, 30f /* CTI+IEU1 */
- ldx [%o0], %o3 /* Load */
-18: add %o0, 8, %o0 /* IEU0 Group */
-19: sub %o3, %g1, %o2 /* IEU0 Group */
-
-#ifdef EIGHTBIT_NOT_RARE
- andn %o2, %o3, %g6 /* IEU0 Group */
- ldxa [%o0] ASI_PNF, %o3 /* Load */
- andcc %g6, %g2, %g0 /* IEU1 Group */
-#else
- ldxa [%o0] ASI_PNF, %o3 /* Load */
- andcc %o2, %g2, %g0 /* IEU1 Group */
-#endif
- be,pt %xcc, 19b /* CTI */
- add %o0, 8, %o0 /* IEU0 */
-
- addcc %o2, %g1, %g3 /* IEU1 Group */
- srlx %o2, 32, %o2 /* IEU0 */
-20: andcc %o2, %g2, %g0 /* IEU1 Group */
- be,pn %xcc, 21f /* CTI */
-
- srlx %g3, 56, %o2 /* IEU0 */
- andcc %o2, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 29f /* CTI */
- srlx %g3, 48, %o2 /* IEU0 */
-
- andcc %o2, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 28f /* CTI */
- srlx %g3, 40, %o2 /* IEU0 */
- andcc %o2, 0xff, %g0 /* IEU1 Group */
-
- be,pn %icc, 27f /* CTI */
- srlx %g3, 32, %o2 /* IEU0 */
- andcc %o2, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 26f /* CTI */
-
-21: srlx %g3, 24, %o2 /* IEU0 */
- andcc %o2, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 25f /* CTI */
- srlx %g3, 16, %o2 /* IEU0 */
-
- andcc %o2, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 24f /* CTI */
- srlx %g3, 8, %o2 /* IEU0 */
- andcc %o2, 0xff, %g0 /* IEU1 Group */
-
- be,pn %icc, 23f /* CTI */
- sub %o3, %g1, %o2 /* IEU0 */
- andcc %g3, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 22f /* CTI */
-
- ldxa [%o0] ASI_PNF, %o3 /* Load */
- andcc %o2, %g2, %g0 /* IEU1 Group */
- be,pt %xcc, 19b /* CTI */
- add %o0, 8, %o0 /* IEU0 */
-
- addcc %o2, %g1, %g3 /* IEU1 Group */
- ba,pt %xcc, 20b /* CTI */
- srlx %o2, 32, %o2 /* IEU0 */
-
- .align 16
-22: retl /* CTI+IEU1 Group */
- add %o0, -9, %o0 /* IEU0 */
-23: retl /* CTI+IEU1 Group */
- add %o0, -10, %o0 /* IEU0 */
-
-24: retl /* CTI+IEU1 Group */
- add %o0, -11, %o0 /* IEU0 */
-25: retl /* CTI+IEU1 Group */
- add %o0, -12, %o0 /* IEU0 */
-
-26: retl /* CTI+IEU1 Group */
- add %o0, -13, %o0 /* IEU0 */
-27: retl /* CTI+IEU1 Group */
- add %o0, -14, %o0 /* IEU0 */
-
-28: retl /* CTI+IEU1 Group */
- add %o0, -15, %o0 /* IEU0 */
-29: retl /* CTI+IEU1 Group */
- add %o0, -16, %o0 /* IEU0 */
-
-30: retl /* CTI+IEU1 Group */
- nop /* IEU0 */
-
- .align 16
-32: andcc %o0, 7, %g0 /* IEU1 Group */
- be,a,pn %icc, 18b /* CTI */
- ldx [%o0], %o3 /* Load */
- add %o0, 1, %o0 /* IEU0 Group */
-
- brnz,a,pt %o3, 32b /* CTI+IEU1 */
- lduba [%o0] ASI_PNF, %o3 /* Load */
- retl /* CTI+IEU1 Group */
- add %o0, -1, %o0 /* IEU0 */
-END(strchr)
-libc_hidden_def(strchr)
-#ifdef __UCLIBC_SUSV3_LEGACY__
-strong_alias(strchr,index)
-#endif
-
- .align 32
-ENTRY(strrchr)
- andcc %o1, 0xff, %o1 /* IEU1 Group */
- be,pn %icc, 17b /* CTI */
- clr %g4 /* IEU0 */
- andcc %o0, 7, %g0 /* IEU1 Group */
-
- bne,pn %icc, 13f /* CTI */
- sllx %o1, 8, %g3 /* IEU0 */
- ldx [%o0], %o3 /* Load Group */
-1: sethi %hi(0x01010101), %g1 /* IEU0 */
-
- or %g3, %o1, %g3 /* IEU1 */
- sllx %g3, 16, %g5 /* IEU0 Group */
- or %g1, %lo(0x01010101), %g1 /* IEU1 */
- sllx %g1, 32, %g2 /* IEU0 Group */
-
- or %g3, %g5, %g3 /* IEU1 */
- sllx %g3, 32, %g5 /* IEU0 Group */
- or %g1, %g2, %g1 /* IEU1 */
- sllx %g1, 7, %g2 /* IEU0 Group */
-
- or %g3, %g5, %g3 /* IEU1 */
- add %o0, 8, %o0 /* IEU0 Group */
- xor %o3, %g3, %o4 /* IEU1 */
- /* %g1 = 0101010101010101 *
- * %g2 = 8080088080808080 *
- * %g3 = c c c c c c c c *
- * %o3 = value *
- * %o4 = value XOR c */
-2: sub %o3, %g1, %o2 /* IEU0 Group */
-
-3: sub %o4, %g1, %o5 /* IEU1 */
-#ifdef EIGHTBIT_NOT_RARE
- andn %o2, %o3, %g6 /* IEU0 Group */
- andn %o5, %o4, %o5 /* IEU1 */
- ldxa [%o0] ASI_PNF, %o3 /* Load */
-
- or %o5, %g6, %o5 /* IEU0 Group */
-#else
- ldxa [%o0] ASI_PNF, %o3 /* Load */
-
- or %o5, %o2, %o5 /* IEU0 Group */
-#endif
- add %o0, 8, %o0 /* IEU1 */
- andcc %o5, %g2, %g0 /* IEU1 Group */
- be,a,pt %xcc, 2b /* CTI */
-
- xor %o3, %g3, %o4 /* IEU0 */
- srlx %o5, 32, %g5 /* IEU0 Group */
- add %o2, %g1, %o2 /* IEU1 */
- andcc %g5, %g2, %g0 /* IEU1 Group */
-
- be,pn %xcc, 7f /* CTI */
- srlx %o2, 56, %g5 /* IEU0 */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 12f /* CTI */
-
- srlx %o4, 56, %g5 /* IEU0 */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- srlx %o2, 48, %g5 /* IEU0 */
- be,a,pn %icc, 4f /* CTI */
-
- add %o0, -16, %g4 /* IEU0 Group */
-4: andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 12f /* CTI */
- srlx %o4, 48, %g5 /* IEU0 */
-
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- srlx %o2, 40, %g5 /* IEU0 */
- be,a,pn %icc, 5f /* CTI */
- add %o0, -15, %g4 /* IEU0 Group */
-
-5: andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 12f /* CTI */
- srlx %o4, 40, %g5 /* IEU0 */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
-
- srlx %o2, 32, %g5 /* IEU0 */
- be,a,pn %icc, 6f /* CTI */
- add %o0, -14, %g4 /* IEU0 Group */
-6: andcc %g5, 0xff, %g0 /* IEU1 Group */
-
- be,pn %icc, 12f /* CTI */
- srlx %o4, 32, %g5 /* IEU0 */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,a,pn %icc, 7f /* CTI */
-
- add %o0, -13, %g4 /* IEU0 */
-7: srlx %o2, 24, %g5 /* IEU0 */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 12f /* CTI */
-
- srlx %o4, 24, %g5 /* IEU0 */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- srlx %o2, 16, %g5 /* IEU0 */
- be,a,pn %icc, 8f /* CTI */
-
- add %o0, -12, %g4 /* IEU0 Group */
-8: andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 12f /* CTI */
- srlx %o4, 16, %g5 /* IEU0 */
-
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- srlx %o2, 8, %g5 /* IEU0 */
- be,a,pn %icc, 9f /* CTI */
- add %o0, -11, %g4 /* IEU0 Group */
-
-9: andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 12f /* CTI */
- srlx %o4, 8, %g5 /* IEU0 */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
-
- be,a,pn %icc, 10f /* CTI */
- add %o0, -10, %g4 /* IEU0 */
-10: andcc %o2, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 12f /* CTI */
-
- sub %o3, %g1, %o2 /* IEU0 */
- andcc %o4, 0xff, %g0 /* IEU1 Group */
- be,a,pn %icc, 11f /* CTI */
- add %o0, -9, %g4 /* IEU0 */
-
-11: ba,pt %xcc, 3b /* CTI Group */
- xor %o3, %g3, %o4 /* IEU0 Group */
-12: retl /* CTI+IEU1 Group */
- mov %g4, %o0 /* IEU0 */
-
- .align 16
-13: ldub [%o0], %o3 /* Load Group */
- add %o0, 1, %o0 /* IEU0 */
-14: andcc %o3, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 12b /* CTI */
-
- cmp %o3, %o1 /* IEU1 Group */
- ldub [%o0], %o3 /* Load */
- be,a,pn %icc, 15f /* CTI */
- add %o0, -1, %g4 /* IEU0 Group */
-
-15: andcc %o0, 7, %g0 /* IEU1 Group */
- bne,a,pt %icc, 14b /* CTI */
- add %o0, 1, %o0 /* IEU0 */
- ba,pt %xcc, 1b /* CTI Group */
-
- ldx [%o0], %o3 /* Load */
-END(strrchr)
-libc_hidden_def(strrchr)
-#ifdef __UCLIBC_SUSV3_LEGACY__
-strong_alias(strrchr,rindex)
-#endif
diff --git a/libc/string/sparc/sparc64/strcmp.S b/libc/string/sparc/sparc64/strcmp.S
deleted file mode 100644
index df9e69179..000000000
--- a/libc/string/sparc/sparc64/strcmp.S
+++ /dev/null
@@ -1,279 +0,0 @@
-/* Compare two strings for differences.
- For SPARC v9.
- Copyright (C) 1997, 1999, 2003 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Jan Vondrak <jvon4518@ss1000.ms.mff.cuni.cz> 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, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#include <asm/asi.h>
-#ifndef XCC
- .register %g2, #scratch
- .register %g3, #scratch
- .register %g6, #scratch
-#endif
-
- /* Normally, this uses
- ((xword - 0x0101010101010101) & 0x8080808080808080) test
- to find out if any byte in xword could be zero. This is fast, but
- also gives false alarm for any byte in range 0x81-0xff. It does
- not matter for correctness, as if this test tells us there could
- be some zero byte, we check it byte by byte, but if bytes with
- high bits set are common in the strings, then this will give poor
- performance. You can #define EIGHTBIT_NOT_RARE and the algorithm
- will use one tick slower, but more precise test
- ((xword - 0x0101010101010101) & (~xword) & 0x8080808080808080),
- which does not give any false alarms (but if some bits are set,
- one cannot assume from it which bytes are zero and which are not).
- It is yet to be measured, what is the correct default for glibc
- in these days for an average user.
- */
-
- .text
- .align 32
-ENTRY(strcmp)
- sethi %hi(0x01010101), %g1 /* IEU0 Group */
- andcc %o0, 7, %g0 /* IEU1 */
- bne,pn %icc, 7f /* CTI */
- or %g1, %lo(0x01010101), %g1 /* IEU0 Group */
-
- andcc %o1, 7, %g3 /* IEU1 */
- bne,pn %icc, 9f /* CTI */
- sllx %g1, 32, %g2 /* IEU0 Group */
- ldx [%o0], %o2 /* Load */
-
- or %g1, %g2, %g1 /* IEU0 Group */
-1: ldx [%o1], %o3 /* Load */
- sub %o1, %o0, %o1 /* IEU1 */
- sllx %g1, 7, %g2 /* IEU0 Group */
-
-2: add %o0, 8, %o0 /* IEU1 */
- sub %o2, %g1, %g3 /* IEU0 Group */
- subcc %o2, %o3, %g0 /* IEU1 */
- bne,pn %xcc, 13f /* CTI */
-
-#ifdef EIGHTBIT_NOT_RARE
- andn %g3, %o2, %g4 /* IEU0 Group */
- ldxa [%o0] ASI_PNF, %o2 /* Load */
- andcc %g4, %g2, %g0 /* IEU1 Group */
-#else
- ldxa [%o0] ASI_PNF, %o2 /* Load Group */
- andcc %g3, %g2, %g0 /* IEU1 */
-#endif
- be,a,pt %xcc, 2b /* CTI */
- ldxa [%o1 + %o0] ASI_PNF, %o3 /* Load Group */
-
- addcc %g3, %g1, %o4 /* IEU1 */
- srlx %g3, 32, %g3 /* IEU0 */
- andcc %g3, %g2, %g0 /* IEU1 Group */
- be,pt %xcc, 3f /* CTI */
-
- srlx %o4, 56, %o5 /* IEU0 */
- andcc %o5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 4f /* CTI */
- srlx %o4, 48, %o5 /* IEU0 */
-
- andcc %o5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 4f /* CTI */
- srlx %o4, 40, %o5 /* IEU0 */
- andcc %o5, 0xff, %g0 /* IEU1 Group */
-
- be,pn %icc, 4f /* CTI */
- srlx %o4, 32, %o5 /* IEU0 */
- andcc %o5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 4f /* CTI */
-
-3: srlx %o4, 24, %o5 /* IEU0 */
- andcc %o5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 4f /* CTI */
- srlx %o4, 16, %o5 /* IEU0 */
-
- andcc %o5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 4f /* CTI */
- srlx %o4, 8, %o5 /* IEU0 */
- andcc %o5, 0xff, %g0 /* IEU1 Group */
-
- be,pn %icc, 4f /* CTI */
- andcc %o4, 0xff, %g0 /* IEU1 Group */
- bne,a,pn %icc, 2b /* CTI */
- ldxa [%o1 + %o0] ASI_PNF, %o3 /* Load */
-
-4: retl /* CTI+IEU1 Group */
- clr %o0 /* IEU0 */
-
- .align 32
-13: mov 0xff, %g6 /* IEU0 Group */
-#ifdef EIGHTBIT_NOT_RARE
- andcc %g4, %g2, %g0 /* IEU1 */
-#else
- andcc %g3, %g2, %g0 /* IEU1 */
-#endif
- be,pt %xcc, 25f /* CTI */
- addcc %g3, %g1, %o4 /* IEU1 Group */
-
- srlx %g3, 32, %g3 /* IEU0 */
- andcc %g3, %g2, %g0 /* IEU1 Group */
- be,pt %xcc, 23f /* CTI */
- sllx %g6, 56, %o5 /* IEU0 */
-
- andcc %o4, %o5, %g0 /* IEU1 Group */
- be,pn %xcc, 24f /* CTI */
- sllx %g6, 48, %o5 /* IEU0 */
- andcc %o4, %o5, %g0 /* IEU1 Group */
-
- be,pn %xcc, 24f /* CTI */
- sllx %g6, 40, %o5 /* IEU0 */
- andcc %o4, %o5, %g0 /* IEU1 Group */
- be,pn %xcc, 24f /* CTI */
-
- sllx %g6, 32, %o5 /* IEU0 */
- andcc %o4, %o5, %g0 /* IEU1 Group */
- be,pn %xcc, 24f /* CTI */
-23: sllx %g6, 24, %o5 /* IEU0 */
-
- andcc %o4, %o5, %g0 /* IEU1 Group */
- be,pn %icc, 24f /* CTI */
- sllx %g6, 16, %o5 /* IEU0 */
- andcc %o4, %o5, %g0 /* IEU1 Group */
-
- be,pn %icc, 24f /* CTI */
- sllx %g6, 8, %o5 /* IEU0 */
- andcc %o4, %o5, %g0 /* IEU1 Group */
- be,pn %icc, 24f /* CTI */
-
- mov %g6, %o5 /* IEU0 */
-25: cmp %o4, %o3 /* IEU1 Group */
-5: mov -1, %o0 /* IEU0 */
- retl /* CTI+IEU1 Group */
-
- movgu %xcc, 1, %o0 /* Single Group */
-
- .align 16
-24: sub %o5, 1, %g6 /* IEU0 Group */
- clr %o0 /* IEU1 */
- or %o5, %g6, %o5 /* IEU0 Group */
- andn %o4, %o5, %o4 /* IEU0 Group */
-
- andn %o3, %o5, %o3 /* IEU1 */
- cmp %o4, %o3 /* IEU1 Group */
- movgu %xcc, 1, %o0 /* Single Group */
- retl /* CTI+IEU1 Group */
-
- movlu %xcc, -1, %o0 /* Single Group */
-6: retl /* CTI+IEU1 Group */
- mov %o4, %o0 /* IEU0 */
-
- .align 16
-7: ldub [%o0], %o2 /* Load */
- add %o0, 1, %o0 /* IEU1 */
- ldub [%o1], %o3 /* Load Group */
- sllx %g1, 32, %g2 /* IEU0 */
-
-8: add %o1, 1, %o1 /* IEU1 */
- subcc %o2, %o3, %o4 /* IEU1 Group */
- bne,pn %xcc, 6b /* CTI */
- lduba [%o0] ASI_PNF, %o2 /* Load */
-
- brz,pn %o3, 4b /* CTI+IEU1 Group */
- lduba [%o1] ASI_PNF, %o3 /* Load */
- andcc %o0, 7, %g0 /* IEU1 Group */
- bne,a,pn %icc, 8b /* CTI */
-
- add %o0, 1, %o0 /* IEU0 */
- or %g1, %g2, %g1 /* IEU0 Group */
- andcc %o1, 7, %g3 /* IEU1 */
- be,a,pn %icc, 1b /* CTI */
-
- ldxa [%o0] ASI_PNF, %o2 /* Load Group */
-9: sllx %g3, 3, %g5 /* IEU0 */
- mov 64, %o5 /* IEU1 */
- sub %o1, %g3, %o1 /* IEU0 Group */
-
- sub %o5, %g5, %o5 /* IEU1 */
- ldxa [%o1] ASI_PNF, %g6 /* Load Group */
- or %g1, %g2, %g1 /* IEU0 */
- sub %o1, %o0, %o1 /* IEU1 */
-
- sllx %g1, 7, %g2 /* IEU0 Group */
- add %o1, 8, %o1 /* IEU1 */
- /* %g1 = 0101010101010101
- * %g2 = 8080808080800880
- * %g5 = number of bits to shift left
- * %o5 = number of bits to shift right */
-10: sllx %g6, %g5, %o3 /* IEU0 Group */
- ldxa [%o1 + %o0] ASI_PNF, %g6 /* Load */
-
-11: srlx %g6, %o5, %o4 /* IEU0 Group */
- ldxa [%o0] ASI_PNF, %o2 /* Load */
- or %o3, %o4, %o3 /* IEU1 */
- add %o0, 8, %o0 /* IEU0 Group */
-
- subcc %o2, %o3, %g0 /* IEU1 */
-#ifdef EIGHTBIT_NOT_RARE
- sub %o2, %g1, %g3 /* IEU0 Group */
- bne,pn %xcc, 13b /* CTI */
- andn %g3, %o2, %g4 /* IEU0 Group */
-
- andcc %g4, %g2, %g0 /* IEU1 Group */
- be,pt %xcc, 10b /* CTI */
- srlx %g4, 32, %g4 /* IEU0 */
- andcc %g4, %g2, %g0 /* IEU1 Group */
-#else
- bne,pn %xcc, 13b /* CTI */
- sub %o2, %g1, %g3 /* IEU0 Group */
- andcc %g3, %g2, %g0 /* IEU1 Group */
-
- be,pt %xcc, 10b /* CTI */
- srlx %g3, 32, %g3 /* IEU0 */
- andcc %g3, %g2, %g0 /* IEU1 Group */
-#endif
- be,pt %xcc, 12f /* CTI */
-
- srlx %o2, 56, %g3 /* IEU0 */
- andcc %g3, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 4b /* CTI */
- srlx %o2, 48, %g3 /* IEU0 */
-
- andcc %g3, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 4b /* CTI */
- srlx %o2, 40, %g3 /* IEU0 */
- andcc %g3, 0xff, %g0 /* IEU1 Group */
-
- be,pn %icc, 4b /* CTI */
- srlx %o2, 32, %g3 /* IEU0 */
- andcc %g3, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 4b /* CTI */
-
-12: srlx %o2, 24, %g3 /* IEU0 */
- andcc %g3, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 4b /* CTI */
- srlx %o2, 16, %g3 /* IEU0 */
-
- andcc %g3, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 4b /* CTI */
- srlx %o2, 8, %g3 /* IEU0 */
- andcc %g3, 0xff, %g0 /* IEU1 Group */
-
- be,pn %icc, 4b /* CTI */
- andcc %o2, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 4b /* CTI */
- sllx %g6, %g5, %o3 /* IEU0 */
-
- ba,pt %xcc, 11b /* CTI Group */
- ldxa [%o1 + %o0] ASI_PNF, %g6 /* Load */
-END(strcmp)
-libc_hidden_def(strcmp)
diff --git a/libc/string/sparc/sparc64/strcpy.S b/libc/string/sparc/sparc64/strcpy.S
deleted file mode 100644
index 1317d5489..000000000
--- a/libc/string/sparc/sparc64/strcpy.S
+++ /dev/null
@@ -1,245 +0,0 @@
-/* Copy SRC to DEST returning DEST.
- For SPARC v9.
- Copyright (C) 1998, 1999, 2003 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Jan Vondrak <jvon4518@ss1000.ms.mff.cuni.cz> 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, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#include <asm/asi.h>
-#ifndef XCC
- .register %g2, #scratch
- .register %g3, #scratch
- .register %g6, #scratch
-#endif
-
- /* Normally, this uses
- ((xword - 0x0101010101010101) & 0x8080808080808080) test
- to find out if any byte in xword could be zero. This is fast, but
- also gives false alarm for any byte in range 0x81-0xff. It does
- not matter for correctness, as if this test tells us there could
- be some zero byte, we check it byte by byte, but if bytes with
- high bits set are common in the strings, then this will give poor
- performance. You can #define EIGHTBIT_NOT_RARE and the algorithm
- will use one tick slower, but more precise test
- ((xword - 0x0101010101010101) & (~xword) & 0x8080808080808080),
- which does not give any false alarms (but if some bits are set,
- one cannot assume from it which bytes are zero and which are not).
- It is yet to be measured, what is the correct default for glibc
- in these days for an average user.
- */
-
- .text
- .align 32
-ENTRY(strcpy)
- sethi %hi(0x01010101), %g1 /* IEU0 Group */
- mov %o0, %g6 /* IEU1 */
- or %g1, %lo(0x01010101), %g1 /* IEU0 Group */
- andcc %o0, 7, %g0 /* IEU1 */
-
- sllx %g1, 32, %g2 /* IEU0 Group */
- bne,pn %icc, 12f /* CTI */
- andcc %o1, 7, %g3 /* IEU1 */
- or %g1, %g2, %g1 /* IEU0 Group */
-
- bne,pn %icc, 14f /* CTI */
- sllx %g1, 7, %g2 /* IEU0 Group */
-1: ldx [%o1], %o3 /* Load */
- add %o1, 8, %o1 /* IEU1 */
-
-2: mov %o3, %g3 /* IEU0 Group */
-3: sub %o3, %g1, %o2 /* IEU1 */
- ldxa [%o1] ASI_PNF, %o3 /* Load */
-#ifdef EIGHTBIT_NOT_RARE
- andn %o2, %g3, %o2 /* IEU0 Group */
-#endif
- add %o0, 8, %o0 /* IEU0 Group */
-
- andcc %o2, %g2, %g0 /* IEU1 */
- add %o1, 8, %o1 /* IEU0 Group */
- be,a,pt %xcc, 2b /* CTI */
- stx %g3, [%o0 - 8] /* Store */
-
- srlx %g3, 56, %g5 /* IEU0 Group */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 11f /* CTI */
- srlx %g3, 48, %g4 /* IEU0 */
-
- andcc %g4, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 10f /* CTI */
- srlx %g3, 40, %g5 /* IEU0 */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
-
- be,pn %icc, 9f /* CTI */
- srlx %g3, 32, %g4 /* IEU0 */
- andcc %g4, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 8f /* CTI */
-
- srlx %g3, 24, %g5 /* IEU0 */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 7f /* CTI */
- srlx %g3, 16, %g4 /* IEU0 */
-
- andcc %g4, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 6f /* CTI */
- srlx %g3, 8, %g5 /* IEU0 */
- andcc %g5, 0xff, %g0 /* IEU1 Group */
-
- be,pn %icc, 5f /* CTI */
- sub %o3, %g1, %o2 /* IEU0 */
- stx %g3, [%o0 - 8] /* Store Group */
- andcc %g3, 0xff, %g0 /* IEU1 */
-
- bne,pt %icc, 3b /* CTI */
- mov %o3, %g3 /* IEU0 Group */
-4: retl /* CTI+IEU1 Group */
- mov %g6, %o0 /* IEU0 */
-
- .align 16
-5: stb %g5, [%o0 - 2] /* Store Group */
- srlx %g3, 16, %g4 /* IEU0 */
-6: sth %g4, [%o0 - 4] /* Store Group */
- srlx %g3, 32, %g4 /* IEU0 */
-
- stw %g4, [%o0 - 8] /* Store Group */
- retl /* CTI+IEU1 Group */
- mov %g6, %o0 /* IEU0 */
-7: stb %g5, [%o0 - 4] /* Store Group */
-
- srlx %g3, 32, %g4 /* IEU0 */
-8: stw %g4, [%o0 - 8] /* Store Group */
- retl /* CTI+IEU1 Group */
- mov %g6, %o0 /* IEU0 */
-
-9: stb %g5, [%o0 - 6] /* Store Group */
- srlx %g3, 48, %g4 /* IEU0 */
-10: sth %g4, [%o0 - 8] /* Store Group */
- retl /* CTI+IEU1 Group */
-
- mov %g6, %o0 /* IEU0 */
-11: stb %g5, [%o0 - 8] /* Store Group */
- retl /* CTI+IEU1 Group */
- mov %g6, %o0 /* IEU0 */
-
-12: or %g1, %g2, %g1 /* IEU0 Group */
- ldub [%o1], %o3 /* Load */
- sllx %g1, 7, %g2 /* IEU0 Group */
- stb %o3, [%o0] /* Store Group */
-
-13: add %o0, 1, %o0 /* IEU0 */
- add %o1, 1, %o1 /* IEU1 */
- andcc %o3, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 4b /* CTI */
-
- lduba [%o1] ASI_PNF, %o3 /* Load */
- andcc %o0, 7, %g0 /* IEU1 Group */
- bne,a,pt %icc, 13b /* CTI */
- stb %o3, [%o0] /* Store */
-
- andcc %o1, 7, %g3 /* IEU1 Group */
- be,a,pt %icc, 1b /* CTI */
- ldx [%o1], %o3 /* Load */
-14: orcc %g0, 64, %g4 /* IEU1 Group */
-
- sllx %g3, 3, %g5 /* IEU0 */
- sub %o1, %g3, %o1 /* IEU0 Group */
- sub %g4, %g5, %g4 /* IEU1 */
- /* %g1 = 0101010101010101 *
- * %g2 = 8080808080808080 *
- * %g3 = source alignment *
- * %g5 = number of bits to shift left *
- * %g4 = number of bits to shift right */
- ldxa [%o1] ASI_PNF, %o5 /* Load Group */
-
- addcc %o1, 8, %o1 /* IEU1 */
-15: sllx %o5, %g5, %o3 /* IEU0 Group */
- ldxa [%o1] ASI_PNF, %o5 /* Load */
- srlx %o5, %g4, %o4 /* IEU0 Group */
-
- add %o0, 8, %o0 /* IEU1 */
- or %o3, %o4, %o3 /* IEU0 Group */
- add %o1, 8, %o1 /* IEU1 */
- sub %o3, %g1, %o4 /* IEU0 Group */
-
-#ifdef EIGHTBIT_NOT_RARE
- andn %o4, %o3, %o4 /* IEU0 Group */
-#endif
- andcc %o4, %g2, %g0 /* IEU1 Group */
- be,a,pt %xcc, 15b /* CTI */
- stx %o3, [%o0 - 8] /* Store */
- srlx %o3, 56, %o4 /* IEU0 Group */
-
- andcc %o4, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 22f /* CTI */
- srlx %o3, 48, %o4 /* IEU0 */
- andcc %o4, 0xff, %g0 /* IEU1 Group */
-
- be,pn %icc, 21f /* CTI */
- srlx %o3, 40, %o4 /* IEU0 */
- andcc %o4, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 20f /* CTI */
-
- srlx %o3, 32, %o4 /* IEU0 */
- andcc %o4, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 19f /* CTI */
- srlx %o3, 24, %o4 /* IEU0 */
-
- andcc %o4, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 18f /* CTI */
- srlx %o3, 16, %o4 /* IEU0 */
- andcc %o4, 0xff, %g0 /* IEU1 Group */
-
- be,pn %icc, 17f /* CTI */
- srlx %o3, 8, %o4 /* IEU0 */
- andcc %o4, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 16f /* CTI */
-
- andcc %o3, 0xff, %g0 /* IEU1 Group */
- bne,pn %icc, 15b /* CTI */
- stx %o3, [%o0 - 8] /* Store */
- retl /* CTI+IEU1 Group */
-
- mov %g6, %o0 /* IEU0 */
-
- .align 16
-16: srlx %o3, 8, %o4 /* IEU0 Group */
- stb %o4, [%o0 - 2] /* Store */
-17: srlx %o3, 16, %o4 /* IEU0 Group */
- stb %o4, [%o0 - 3] /* Store */
-
-18: srlx %o3, 24, %o4 /* IEU0 Group */
- stb %o4, [%o0 - 4] /* Store */
-19: srlx %o3, 32, %o4 /* IEU0 Group */
- stw %o4, [%o0 - 8] /* Store */
-
- retl /* CTI+IEU1 Group */
- mov %g6, %o0 /* IEU0 */
- nop
- nop
-
-20: srlx %o3, 40, %o4 /* IEU0 Group */
- stb %o4, [%o0 - 6] /* Store */
-21: srlx %o3, 48, %o4 /* IEU0 Group */
- stb %o4, [%o0 - 7] /* Store */
-
-22: srlx %o3, 56, %o4 /* IEU0 Group */
- stb %o4, [%o0 - 8] /* Store */
- retl /* CTI+IEU1 Group */
- mov %g6, %o0 /* IEU0 */
-END(strcpy)
-
-libc_hidden_def(strcpy)
diff --git a/libc/string/sparc/sparc64/strlen.S b/libc/string/sparc/sparc64/strlen.S
deleted file mode 100644
index 1fe854961..000000000
--- a/libc/string/sparc/sparc64/strlen.S
+++ /dev/null
@@ -1,173 +0,0 @@
-/* Determine the length of a string. For SPARC v9.
- Copyright (C) 1998, 1999, 2003 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Jan Vondrak <jvon4518@ss1000.ms.mff.cuni.cz> 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, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#include <asm/asi.h>
-
- /* Normally, this uses
- ((xword - 0x0101010101010101) & 0x8080808080808080) test
- to find out if any byte in xword could be zero. This is fast, but
- also gives false alarm for any byte in range 0x81-0xff. It does
- not matter for correctness, as if this test tells us there could
- be some zero byte, we check it byte by byte, but if bytes with
- high bits set are common in the strings, then this will give poor
- performance. You can #define EIGHTBIT_NOT_RARE and the algorithm
- will use one tick slower, but more precise test
- ((xword - 0x0101010101010101) & (~xword) & 0x8080808080808080),
- which does not give any false alarms (but if some bits are set,
- one cannot assume from it which bytes are zero and which are not).
- It is yet to be measured, what is the correct default for glibc
- in these days for an average user.
- */
-
- .text
- .align 32
-ENTRY(strlen)
- sethi %hi(0x01010101), %g1 /* IEU0 Group */
- ldub [%o0], %o3 /* Load */
- or %g1, %lo(0x01010101), %g1 /* IEU0 Group */
- mov %o0, %o1 /* IEU1 */
-
- sllx %g1, 32, %g4 /* IEU0 Group */
- andcc %o0, 7, %g0 /* IEU1 */
- or %g1, %g4, %g1 /* IEU0 Group */
- brz,pn %o3, 13f /* CTI+IEU1 */
-
- sllx %g1, 7, %g4 /* IEU0 Group */
- bne,a,pn %icc, 15f /* CTI */
- add %o0, 1, %o0 /* IEU1 */
- /* %g1 = 0x0101010101010101 *
- * %g4 = 0x8080808080808080 *
- * %o0 = string pointer *
- * %o1 = start of string */
-1: ldx [%o0], %o3 /* Load Group */
-
- add %o0, 8, %o0 /* IEU1 */
-2: sub %o3, %g1, %o2 /* IEU0 Group */
-#ifdef EIGHTBIT_NOT_RARE
- andn %o2, %o3, %o5 /* IEU0 Group */
- ldxa [%o0] ASI_PNF, %o3 /* Load */
- andcc %o5, %g4, %g0 /* IEU1 Group */
-#else
- ldxa [%o0] ASI_PNF, %o3 /* Load */
- andcc %o2, %g4, %g0 /* IEU1 Group */
-#endif
-
- be,pt %xcc, 2b /* CTI */
- add %o0, 8, %o0 /* IEU0 */
- addcc %o2, %g1, %g5 /* IEU1 Group */
-#ifdef EIGHTBIT_NOT_RARE
- srlx %o5, 32, %o5 /* IEU0 */
-
-3: andcc %o5, %g4, %g0 /* IEU1 Group */
-#else
- srlx %o2, 32, %o2 /* IEU0 */
-
-3: andcc %o2, %g4, %g0 /* IEU1 Group */
-#endif
- be,pn %xcc, 4f /* CTI */
- srlx %g5, 56, %o2 /* IEU0 */
- andcc %o2, 0xff, %g0 /* IEU1 Group */
-
- be,pn %icc, 12f /* CTI */
- srlx %g5, 48, %o2 /* IEU0 */
- andcc %o2, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 11f /* CTI */
-
- srlx %g5, 40, %o2 /* IEU0 */
- andcc %o2, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 10f /* CTI */
- srlx %g5, 32, %o2 /* IEU0 */
-
- andcc %o2, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 9f /* CTI */
-4: srlx %g5, 24, %o2 /* IEU0 */
- andcc %o2, 0xff, %g0 /* IEU1 Group */
-
- be,pn %icc, 8f /* CTI */
- srlx %g5, 16, %o2 /* IEU0 */
- andcc %o2, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 7f /* CTI */
-
- srlx %g5, 8, %o2 /* IEU0 */
- andcc %o2, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 6f /* CTI */
- sub %o3, %g1, %o2 /* IEU0 */
-
- andcc %g5, 0xff, %g0 /* IEU1 Group */
- be,pn %icc, 5f /* CTI */
- ldxa [%o0] ASI_PNF, %o3 /* Load */
- andcc %o2, %g4, %g0 /* IEU1 Group */
-
- be,pt %xcc, 2b /* CTI */
- add %o0, 8, %o0 /* IEU0 */
- addcc %o2, %g1, %g5 /* IEU1 Group */
- ba,pt %xcc, 3b /* CTI */
-
- srlx %o2, 32, %o2 /* IEU0 */
-5: add %o0, -9, %o0 /* IEU0 Group */
- retl /* CTI+IEU1 Group */
- sub %o0, %o1, %o0 /* IEU0 */
-
-6: add %o0, -10, %o0 /* IEU0 Group */
- retl /* CTI+IEU1 Group */
- sub %o0, %o1, %o0 /* IEU0 */
-7: add %o0, -11, %o0 /* IEU0 Group */
-
- retl /* CTI+IEU1 Group */
- sub %o0, %o1, %o0 /* IEU0 */
-8: add %o0, -12, %o0 /* IEU0 Group */
- retl /* CTI+IEU1 Group */
-
- sub %o0, %o1, %o0 /* IEU0 */
-9: add %o0, -13, %o0 /* IEU0 Group */
- retl /* CTI+IEU1 Group */
- sub %o0, %o1, %o0 /* IEU0 */
-
-10: add %o0, -14, %o0 /* IEU0 Group */
- retl /* CTI+IEU1 Group */
- sub %o0, %o1, %o0 /* IEU0 */
-11: add %o0, -15, %o0 /* IEU0 Group */
-
- retl /* CTI+IEU1 Group */
- sub %o0, %o1, %o0 /* IEU0 */
-12: add %o0, -16, %o0 /* IEU0 Group */
- retl /* CTI+IEU1 Group */
-
- sub %o0, %o1, %o0 /* IEU0 */
-13: retl /* CTI+IEU1 Group */
- mov 0, %o0 /* IEU0 */
- nop
-
-15: ldub [%o0], %o3 /* Load Group */
-16: andcc %o0, 7, %g0 /* IEU1 */
- be,pn %icc, 1b /* CTI */
- nop /* IEU0 Group */
-
- add %o0, 1, %o0 /* IEU1 */
- andcc %o3, 0xff, %g0 /* IEU1 Group */
- bne,a,pt %icc, 16b /* CTI */
- lduba [%o0] ASI_PNF, %o3 /* Load */
-
- add %o0, -1, %o0 /* IEU0 Group */
- retl /* CTI+IEU1 Group */
- sub %o0, %o1, %o0 /* IEU0 */
-END(strlen)
-libc_hidden_def(strlen)
diff --git a/libc/string/stpcpy.c b/libc/string/stpcpy.c
index 8a487584e..2fd2c0648 100644
--- a/libc/string/stpcpy.c
+++ b/libc/string/stpcpy.c
@@ -10,19 +10,13 @@
#ifdef WANT_WIDE
# define Wstpcpy wcpcpy
#else
-/* Experimentally off - libc_hidden_proto(stpcpy) */
+# undef stpcpy
# define Wstpcpy stpcpy
#endif
Wchar *Wstpcpy(register Wchar * __restrict s1, const Wchar * __restrict s2)
{
-#ifdef __BCC__
- do {
- *s1 = *s2++;
- } while (*s1++ != 0);
-#else
while ( (*s1++ = *s2++) != 0 );
-#endif
return s1 - 1;
}
diff --git a/libc/string/stpncpy.c b/libc/string/stpncpy.c
index dac8471fd..50d83a131 100644
--- a/libc/string/stpncpy.c
+++ b/libc/string/stpncpy.c
@@ -10,7 +10,6 @@
#ifdef WANT_WIDE
# define Wstpncpy wcpncpy
#else
-/* Experimentally off - libc_hidden_proto(stpncpy) */
# define Wstpncpy stpncpy
#endif
@@ -21,22 +20,10 @@ Wchar *Wstpncpy(register Wchar * __restrict s1,
Wchar *s = s1;
const Wchar *p = s2;
-#ifdef __BCC__
- while (n--) {
- if ((*s = *s2) != 0) s2++; /* Need to fill tail with 0s. */
- ++s;
- }
- return s1 + (s2 - p);
-#else
while (n) {
if ((*s = *s2) != 0) s2++; /* Need to fill tail with 0s. */
++s;
--n;
}
return s1 + (s2 - p);
-#endif
}
-
-#ifndef WANT_WIDE
-libc_hidden_def(stpncpy)
-#endif
diff --git a/libc/string/strcasecmp.c b/libc/string/strcasecmp.c
index f9852236b..f894e426e 100644
--- a/libc/string/strcasecmp.c
+++ b/libc/string/strcasecmp.c
@@ -12,28 +12,15 @@
#ifdef WANT_WIDE
# define strcasecmp wcscasecmp
# define strcasecmp_l wcscasecmp_l
-libc_hidden_proto(wcscasecmp)
-# if defined(__USE_GNU) && defined(__UCLIBC_HAS_XLOCALE__)
-libc_hidden_proto(wcscasecmp_l)
-# endif
# ifdef __UCLIBC_DO_XLOCALE
-libc_hidden_proto(towlower_l)
# define TOLOWER(C) towlower_l((C), locale_arg)
# else
-libc_hidden_proto(towlower)
# define TOLOWER(C) towlower((C))
# endif
#else
-/* Experimentally off - libc_hidden_proto(strcasecmp) */
-/* Experimentally off - libc_hidden_proto(strcasecmp_l) */
# ifdef __UCLIBC_DO_XLOCALE
-libc_hidden_proto(tolower_l)
# define TOLOWER(C) tolower_l((C), locale_arg)
# else
-#if !defined __UCLIBC_HAS_XLOCALE__ && defined __UCLIBC_HAS_CTYPE_TABLES__
-libc_hidden_proto(__ctype_tolower)
-#endif
-libc_hidden_proto(tolower)
# define TOLOWER(C) tolower((C))
# endif
#endif
@@ -44,11 +31,12 @@ int strcasecmp(register const Wchar *s1, register const Wchar *s2)
{
return strcasecmp_l(s1, s2, __UCLIBC_CURLOCALE);
}
+#ifndef WANT_WIDE
libc_hidden_def(strcasecmp)
+#endif
#else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
-/* Experimentally off - libc_hidden_proto(__XL_NPP(strcasecmp)) */
int __XL_NPP(strcasecmp)(register const Wchar *s1, register const Wchar *s2
__LOCALE_PARAM )
{
@@ -73,6 +61,8 @@ int __XL_NPP(strcasecmp)(register const Wchar *s1, register const Wchar *s2
return r;
#endif
}
+#if !defined WANT_WIDE || (defined WANT_WIDE && defined __UCLIBC_DO_XLOCALE)
libc_hidden_def(__XL_NPP(strcasecmp))
+#endif
#endif /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
diff --git a/libc/string/strcasestr.c b/libc/string/strcasestr.c
index 2671b4b98..3334086bf 100644
--- a/libc/string/strcasestr.c
+++ b/libc/string/strcasestr.c
@@ -8,13 +8,6 @@
#include "_string.h"
#include <ctype.h>
-#ifdef __UCLIBC_HAS_XLOCALE__
-libc_hidden_proto(__ctype_tolower_loc)
-#elif defined __UCLIBC_HAS_CTYPE_TABLES__
-libc_hidden_proto(__ctype_tolower)
-#endif
-libc_hidden_proto(tolower)
-
char *strcasestr(const char *s1, const char *s2)
{
register const char *s = s1;
diff --git a/libc/string/strcat.c b/libc/string/strcat.c
index 40a9be111..63619bcc8 100644
--- a/libc/string/strcat.c
+++ b/libc/string/strcat.c
@@ -13,8 +13,6 @@
# define Wstrcat strcat
#endif
-libc_hidden_proto(Wstrcat)
-
Wchar *Wstrcat(Wchar * __restrict s1, register const Wchar * __restrict s2)
{
register Wchar *s = s1;
diff --git a/libc/string/strchr.c b/libc/string/strchr.c
index 329545e9f..7ea477362 100644
--- a/libc/string/strchr.c
+++ b/libc/string/strchr.c
@@ -13,8 +13,6 @@
# define Wstrchr strchr
#endif
-libc_hidden_proto(Wstrchr)
-
Wchar *Wstrchr(register const Wchar *s, Wint c)
{
do {
@@ -25,8 +23,9 @@ Wchar *Wstrchr(register const Wchar *s, Wint c)
return NULL;
}
-libc_hidden_def(Wstrchr)
-
-#if !defined WANT_WIDE && defined __UCLIBC_SUSV3_LEGACY__
+#ifndef WANT_WIDE
+libc_hidden_def(strchr)
+# ifdef __UCLIBC_SUSV3_LEGACY__
weak_alias(strchr,index)
+# endif
#endif
diff --git a/libc/string/strchrnul.c b/libc/string/strchrnul.c
index 6fe7f6c3d..9c10e1fc8 100644
--- a/libc/string/strchrnul.c
+++ b/libc/string/strchrnul.c
@@ -15,13 +15,13 @@
# define Wstrchrnul strchrnul
#endif
-libc_hidden_proto(Wstrchrnul)
-
Wchar *Wstrchrnul(register const Wchar *s, Wint c)
{
--s;
while (*++s && (*s != ((Wchar)c)));
return (Wchar *) s;
}
-libc_hidden_def(Wstrchrnul)
+# ifndef WANT_WIDE
+libc_hidden_def(strchrnul)
+# endif
#endif
diff --git a/libc/string/strcmp.c b/libc/string/strcmp.c
index 5477adf3a..abae61812 100644
--- a/libc/string/strcmp.c
+++ b/libc/string/strcmp.c
@@ -15,8 +15,6 @@
# define Wstrcoll strcoll
#endif
-libc_hidden_proto(Wstrcmp)
-
int Wstrcmp(register const Wchar *s1, register const Wchar *s2)
{
#ifdef WANT_WIDE
@@ -40,7 +38,6 @@ int Wstrcmp(register const Wchar *s1, register const Wchar *s2)
libc_hidden_def(Wstrcmp)
#ifndef __UCLIBC_HAS_LOCALE__
-libc_hidden_proto(Wstrcoll)
strong_alias(Wstrcmp,Wstrcoll)
libc_hidden_def(Wstrcoll)
#endif
diff --git a/libc/string/strcpy.c b/libc/string/strcpy.c
index cda4094ac..549360c22 100644
--- a/libc/string/strcpy.c
+++ b/libc/string/strcpy.c
@@ -13,20 +13,15 @@
# define Wstrcpy strcpy
#endif
-libc_hidden_proto(Wstrcpy)
-
Wchar *Wstrcpy(Wchar * __restrict s1, const Wchar * __restrict s2)
{
register Wchar *s = s1;
-#ifdef __BCC__
- do {
- *s = *s2++;
- } while (*s++ != 0);
-#else
while ( (*s++ = *s2++) != 0 );
-#endif
return s1;
}
-libc_hidden_def(Wstrcpy)
+
+#ifndef WANT_WIDE
+libc_hidden_def(strcpy)
+#endif
diff --git a/libc/string/strcspn.c b/libc/string/strcspn.c
index 1ec460a15..0466af99b 100644
--- a/libc/string/strcspn.c
+++ b/libc/string/strcspn.c
@@ -10,7 +10,6 @@
#ifdef WANT_WIDE
# define Wstrcspn wcscspn
#else
-/* Experimentally off - libc_hidden_proto(strcspn) */
# define Wstrcspn strcspn
#endif
diff --git a/libc/string/strdup.c b/libc/string/strdup.c
index 61fc186c8..049a23f63 100644
--- a/libc/string/strdup.c
+++ b/libc/string/strdup.c
@@ -9,16 +9,12 @@
#include <stdlib.h>
#ifdef WANT_WIDE
-libc_hidden_proto(wcslen)
# define Wstrdup wcsdup
# define Wstrlen wcslen
#else
-/* Experimentally off - libc_hidden_proto(strdup) */
-/* Experimentally off - libc_hidden_proto(strlen) */
# define Wstrdup strdup
# define Wstrlen strlen
#endif
-/* Experimentally off - libc_hidden_proto(memcpy) */
Wchar *Wstrdup(register const Wchar *s1)
{
diff --git a/libc/string/strerror.c b/libc/string/strerror.c
index 355c7bdda..7250da07d 100644
--- a/libc/string/strerror.c
+++ b/libc/string/strerror.c
@@ -9,8 +9,6 @@
#include <string.h>
#include "_syserrmsg.h"
-/* Experimentally off - libc_hidden_proto(strerror) */
-libc_hidden_proto(__xpg_strerror_r)
char *strerror(int errnum)
{
diff --git a/libc/string/strlcpy.c b/libc/string/strlcpy.c
index cdad4dc5d..83787049a 100644
--- a/libc/string/strlcpy.c
+++ b/libc/string/strlcpy.c
@@ -11,21 +11,14 @@
# define Wstrlcpy __wcslcpy
# define Wstrxfrm wcsxfrm
#else
-/* Experimentally off - libc_hidden_proto(strlcpy) */
# define Wstrlcpy strlcpy
# define Wstrxfrm strxfrm
#endif
-
/* OpenBSD function:
* Copy at most n-1 chars from src to dst and nul-terminate dst.
* Returns strlen(src), so truncation occurred if the return value is >= n. */
-#ifdef WANT_WIDE
-size_t Wstrlcpy(register Wchar *__restrict dst,
- register const Wchar *__restrict src,
- size_t n) attribute_hidden;
-#endif
size_t Wstrlcpy(register Wchar *__restrict dst,
register const Wchar *__restrict src,
size_t n)
@@ -51,13 +44,8 @@ size_t Wstrlcpy(register Wchar *__restrict dst,
}
#ifndef WANT_WIDE
libc_hidden_def(strlcpy)
-#ifndef __UCLIBC_HAS_LOCALE__
-/* Experimentally off - libc_hidden_proto(strxfrm) */
-strong_alias(strlcpy,strxfrm)
-libc_hidden_def(strxfrm)
#endif
-#else
+
#ifndef __UCLIBC_HAS_LOCALE__
-strong_alias(__wcslcpy,wcsxfrm)
-#endif
+strong_alias(Wstrlcpy,Wstrxfrm)
#endif
diff --git a/libc/string/strlen.c b/libc/string/strlen.c
index 2edb6e4e8..021a8cabc 100644
--- a/libc/string/strlen.c
+++ b/libc/string/strlen.c
@@ -13,8 +13,6 @@
# define Wstrlen strlen
#endif
-libc_hidden_proto(Wstrlen)
-
size_t Wstrlen(const Wchar *s)
{
register const Wchar *p;
diff --git a/libc/string/strncasecmp.c b/libc/string/strncasecmp.c
index ed052fa21..2eac47dd4 100644
--- a/libc/string/strncasecmp.c
+++ b/libc/string/strncasecmp.c
@@ -12,28 +12,15 @@
#ifdef WANT_WIDE
# define strncasecmp wcsncasecmp
# define strncasecmp_l wcsncasecmp_l
-libc_hidden_proto(wcsncasecmp)
-# if defined(__USE_GNU) && defined(__UCLIBC_HAS_XLOCALE__)
-libc_hidden_proto(wcsncasecmp_l)
-# endif
# ifdef __UCLIBC_DO_XLOCALE
-libc_hidden_proto(towlower_l)
# define TOLOWER(C) towlower_l((C), locale_arg)
# else
-libc_hidden_proto(towlower)
# define TOLOWER(C) towlower((C))
# endif
#else
-/* Experimentally off - libc_hidden_proto(strncasecmp) */
-/* Experimentally off - libc_hidden_proto(strncasecmp_l) */
# ifdef __UCLIBC_DO_XLOCALE
-libc_hidden_proto(tolower_l)
# define TOLOWER(C) tolower_l((C), locale_arg)
# else
-#if !defined __UCLIBC_HAS_XLOCALE__ && defined __UCLIBC_HAS_CTYPE_TABLES__
-libc_hidden_proto(__ctype_tolower)
-#endif
-libc_hidden_proto(tolower)
# define TOLOWER(C) tolower((C))
# endif
#endif
@@ -44,11 +31,12 @@ int strncasecmp(register const Wchar *s1, register const Wchar *s2, size_t n)
{
return strncasecmp_l(s1, s2, n, __UCLIBC_CURLOCALE);
}
+#ifndef WANT_WIDE
libc_hidden_def(strncasecmp)
+#endif
#else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
-/* Experimentally off - libc_hidden_proto(__XL_NPP(strncasecmp)) */
int __XL_NPP(strncasecmp)(register const Wchar *s1, register const Wchar *s2,
size_t n __LOCALE_PARAM )
{
@@ -76,6 +64,8 @@ int __XL_NPP(strncasecmp)(register const Wchar *s1, register const Wchar *s2,
return r;
#endif
}
+#if !defined WANT_WIDE || (defined WANT_WIDE && defined __UCLIBC_DO_XLOCALE)
libc_hidden_def(__XL_NPP(strncasecmp))
+#endif
#endif /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
diff --git a/libc/string/strncat.c b/libc/string/strncat.c
index 0180d1328..0fa9b4ae1 100644
--- a/libc/string/strncat.c
+++ b/libc/string/strncat.c
@@ -10,7 +10,6 @@
#ifdef WANT_WIDE
# define Wstrncat wcsncat
#else
-/* Experimentally off - libc_hidden_proto(strncat) */
# define Wstrncat strncat
#endif
@@ -21,14 +20,10 @@ Wchar *Wstrncat(Wchar * __restrict s1, register const Wchar * __restrict s2,
while (*s++);
--s;
-#ifdef __BCC__
- while (n-- && ((*s = *s2++) != 0)) ++s;
-#else
while (n && ((*s = *s2++) != 0)) {
--n;
++s;
}
-#endif
*s = 0;
return s1;
diff --git a/libc/string/strncmp.c b/libc/string/strncmp.c
index 59e4a2c22..2da61771c 100644
--- a/libc/string/strncmp.c
+++ b/libc/string/strncmp.c
@@ -10,7 +10,6 @@
#ifdef WANT_WIDE
# define Wstrncmp wcsncmp
#else
-/* Experimentally off - libc_hidden_proto(strncmp) */
# define Wstrncmp strncmp
#endif
diff --git a/libc/string/strncpy.c b/libc/string/strncpy.c
index d93561294..4a44e1f02 100644
--- a/libc/string/strncpy.c
+++ b/libc/string/strncpy.c
@@ -10,7 +10,6 @@
#ifdef WANT_WIDE
# define Wstrncpy wcsncpy
#else
-/* Experimentally off - libc_hidden_proto(strncpy) */
# define Wstrncpy strncpy
#endif
@@ -19,18 +18,11 @@ Wchar *Wstrncpy(Wchar * __restrict s1, register const Wchar * __restrict s2,
{
register Wchar *s = s1;
-#ifdef __BCC__
- while (n--) {
- if ((*s = *s2) != 0) s2++; /* Need to fill tail with 0s. */
- ++s;
- }
-#else
while (n) {
if ((*s = *s2) != 0) s2++; /* Need to fill tail with 0s. */
++s;
--n;
}
-#endif
return s1;
}
diff --git a/libc/string/strndup.c b/libc/string/strndup.c
index 96a36d404..8e608669c 100644
--- a/libc/string/strndup.c
+++ b/libc/string/strndup.c
@@ -8,9 +8,6 @@
#include "_string.h"
#include <stdlib.h>
-/* Experimentally off - libc_hidden_proto(strndup) */
-/* Experimentally off - libc_hidden_proto(strnlen) */
-/* Experimentally off - libc_hidden_proto(memcpy) */
char *strndup(register const char *s1, size_t n)
{
diff --git a/libc/string/strnlen.c b/libc/string/strnlen.c
index 8fbc25c11..08de0887d 100644
--- a/libc/string/strnlen.c
+++ b/libc/string/strnlen.c
@@ -15,26 +15,17 @@
# define Wstrnlen strnlen
#endif
-libc_hidden_proto(Wstrnlen)
-
size_t Wstrnlen(const Wchar *s, size_t max)
{
register const Wchar *p = s;
-#ifdef __BCC__
- /* bcc can optimize the counter if it thinks it is a pointer... */
- register const char *maxp = (const char *) max;
-#else
-# define maxp max
-#endif
- while (maxp && *p) {
+ while (max && *p) {
++p;
- --maxp;
+ --max;
}
return p - s;
}
-#undef maxp
libc_hidden_def(Wstrnlen)
#endif
diff --git a/libc/string/strpbrk.c b/libc/string/strpbrk.c
index abeb84380..ddfc75172 100644
--- a/libc/string/strpbrk.c
+++ b/libc/string/strpbrk.c
@@ -13,8 +13,6 @@
# define Wstrpbrk strpbrk
#endif
-libc_hidden_proto(Wstrpbrk)
-
Wchar *Wstrpbrk(const Wchar *s1, const Wchar *s2)
{
register const Wchar *s;
diff --git a/libc/string/strrchr.c b/libc/string/strrchr.c
index 253c4166d..db12bbc7c 100644
--- a/libc/string/strrchr.c
+++ b/libc/string/strrchr.c
@@ -10,7 +10,6 @@
#ifdef WANT_WIDE
# define Wstrrchr wcsrchr
#else
-/* Experimentally off - libc_hidden_proto(strrchr) */
# define Wstrrchr strrchr
#endif
diff --git a/libc/string/strsep.c b/libc/string/strsep.c
index 373b00a71..ce17dcf89 100644
--- a/libc/string/strsep.c
+++ b/libc/string/strsep.c
@@ -9,10 +9,7 @@
#ifdef __USE_BSD
-/* Experimentally off - libc_hidden_proto(strpbrk) */
-/* Experimentally off - libc_hidden_proto(strcspn) */
-/* Experimentally off - libc_hidden_proto(strsep) */
char *strsep(char ** __restrict s1, const char * __restrict s2)
{
register char *s = *s1;
diff --git a/libc/string/strsignal.c b/libc/string/strsignal.c
index ee083d649..0fbbf8504 100644
--- a/libc/string/strsignal.c
+++ b/libc/string/strsignal.c
@@ -18,16 +18,13 @@
#include <bits/uClibc_uintmaxtostr.h>
#include <signal.h>
-/* Experimentally off - libc_hidden_proto(strsignal) */
-/* Experimentally off - libc_hidden_proto(memcpy) */
-
#define _SYS_NSIG 32
#ifdef __UCLIBC_HAS_SIGNUM_MESSAGES__
# define _SYS_SIGMSG_MAXLEN 25
-#else /* __UCLIBC_HAS_SIGNUM_MESSAGES__ */
+#else
# define _SYS_SIGMSG_MAXLEN 0
-#endif /* __UCLIBC_HAS_SIGNUM_MESSAGES__ */
+#endif
#if _SYS_SIGMSG_MAXLEN < __UIM_BUFLEN_INT + 15
# define _STRSIGNAL_BUFSIZE (__UIM_BUFLEN_INT + 15)
@@ -85,16 +82,16 @@ static const unsigned char sstridx[] = {
char *strsignal(int signum)
{
- register char *s;
- int i;
- static char buf[_STRSIGNAL_BUFSIZE];
- static const char unknown[] = {
+ register char *s;
+ int i;
+ static char buf[_STRSIGNAL_BUFSIZE];
+ static const char unknown[] = {
'U', 'n', 'k', 'n', 'o', 'w', 'n', ' ', 's', 'i', 'g', 'n', 'a', 'l', ' '
- };
+ };
#if defined(__alpha__) || defined(__mips__) || defined(__hppa__) || defined(__sparc__)
/* Need to translate signum to string index. */
- for (i = 0 ; i < sizeof(sstridx)/sizeof(sstridx[0]) ; i++) {
+ for (i = 0; i < sizeof(sstridx)/sizeof(sstridx[0]); i++) {
if (sstridx[i] == signum) {
goto GOT_SSTRIDX;
}
@@ -106,12 +103,12 @@ char *strsignal(int signum)
i = signum;
#endif
- if (((unsigned int) signum) < _SYS_NSIG) {
+ if (((unsigned int) signum) < _SYS_NSIG) {
/* Trade time for space. This function should rarely be called
* so rather than keeping an array of pointers for the different
* messages, just run through the buffer until we find the
* correct string. */
- for (s = (char *) _string_syssigmsgs ; i ; ++s) {
+ for (s = (char *) _string_syssigmsgs; i; ++s) {
if (!*s) {
--i;
}
@@ -119,10 +116,10 @@ char *strsignal(int signum)
if (*s) { /* Make sure we have an actual message. */
goto DONE;
}
- }
+ }
- s = _int10tostr(buf+sizeof(buf)-1, signum) - sizeof(unknown);
- memcpy(s, unknown, sizeof(unknown));
+ s = _int10tostr(buf + sizeof(buf)-1, signum) - sizeof(unknown);
+ memcpy(s, unknown, sizeof(unknown));
DONE:
return s;
@@ -132,13 +129,12 @@ char *strsignal(int signum)
char *strsignal(int signum)
{
- static char buf[_STRSIGNAL_BUFSIZE];
- static const char unknown[] = {
+ static char buf[_STRSIGNAL_BUFSIZE];
+ static const char unknown[] = {
'U', 'n', 'k', 'n', 'o', 'w', 'n', ' ', 's', 'i', 'g', 'n', 'a', 'l', ' '
- };
+ };
- return (char *) memcpy(_int10tostr(buf+sizeof(buf)-1, signum)
- - sizeof(unknown),
+ return memcpy(_int10tostr(buf + sizeof(buf)-1, signum) - sizeof(unknown),
unknown, sizeof(unknown));
}
diff --git a/libc/string/strspn.c b/libc/string/strspn.c
index ca83ef900..942b6f308 100644
--- a/libc/string/strspn.c
+++ b/libc/string/strspn.c
@@ -13,8 +13,6 @@
# define Wstrspn strspn
#endif
-libc_hidden_proto(Wstrspn)
-
size_t Wstrspn(const Wchar *s1, const Wchar *s2)
{
register const Wchar *s = s1;
diff --git a/libc/string/strstr.c b/libc/string/strstr.c
index 05712e62b..7e2a64e7d 100644
--- a/libc/string/strstr.c
+++ b/libc/string/strstr.c
@@ -10,7 +10,6 @@
#ifdef WANT_WIDE
# define Wstrstr wcsstr
#else
-/* Experimentally off - libc_hidden_proto(strstr) */
# define Wstrstr strstr
#endif
@@ -39,6 +38,6 @@ Wchar *Wstrstr(const Wchar *s1, const Wchar *s2)
}
#ifndef WANT_WIDE
libc_hidden_def(strstr)
-#else
+#elif defined __UCLIBC_SUSV3_LEGACY__
strong_alias(wcsstr,wcswcs)
#endif
diff --git a/libc/string/strtok.c b/libc/string/strtok.c
index 159dd6b6a..c337d81a7 100644
--- a/libc/string/strtok.c
+++ b/libc/string/strtok.c
@@ -15,7 +15,6 @@
# define Wstrtok_r strtok_r
#endif
-/* Experimentally off - libc_hidden_proto(Wstrtok_r) */
Wchar *Wstrtok(Wchar * __restrict s1, const Wchar * __restrict s2)
{
diff --git a/libc/string/strtok_r.c b/libc/string/strtok_r.c
index 2ad7746b1..2026888f8 100644
--- a/libc/string/strtok_r.c
+++ b/libc/string/strtok_r.c
@@ -8,15 +8,10 @@
#include "_string.h"
#ifdef WANT_WIDE
-libc_hidden_proto(wcsspn)
-libc_hidden_proto(wcspbrk)
# define Wstrtok_r wcstok
# define Wstrspn wcsspn
# define Wstrpbrk wcspbrk
#else
-/* Experimentally off - libc_hidden_proto(strtok_r) */
-/* Experimentally off - libc_hidden_proto(strspn) */
-/* Experimentally off - libc_hidden_proto(strpbrk) */
# define Wstrtok_r strtok_r
# define Wstrspn strspn
# define Wstrpbrk strpbrk
diff --git a/libc/string/strverscmp.c b/libc/string/strverscmp.c
new file mode 100644
index 000000000..7818a9186
--- /dev/null
+++ b/libc/string/strverscmp.c
@@ -0,0 +1,106 @@
+/* Compare strings while treating digits characters numerically.
+ Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jean-François Bignolles <bignolle@ecoledoc.ibp.fr>, 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/>. */
+
+#include <stdint.h>
+#include <string.h>
+#include <ctype.h>
+
+/* states: S_N: normal, S_I: comparing integral part, S_F: comparing
+ fractionnal parts, S_Z: idem but with leading Zeroes only */
+#define S_N 0x0
+#define S_I 0x3
+#define S_F 0x6
+#define S_Z 0x9
+
+/* result_type: CMP: return diff; LEN: compare using len_diff/diff */
+#define CMP 2
+#define LEN 3
+
+
+/* Compare S1 and S2 as strings holding indices/version numbers,
+ returning less than, equal to or greater than zero if S1 is less than,
+ equal to or greater than S2 (for more info, see the texinfo doc).
+*/
+
+int strverscmp (const char *s1, const char *s2)
+{
+ const unsigned char *p1 = (const unsigned char *) s1;
+ const unsigned char *p2 = (const unsigned char *) s2;
+
+ /* Symbol(s) 0 [1-9] others
+ Transition (10) 0 (01) d (00) x */
+ static const uint8_t next_state[] =
+ {
+ /* state x d 0 */
+ /* S_N */ S_N, S_I, S_Z,
+ /* S_I */ S_N, S_I, S_I,
+ /* S_F */ S_N, S_F, S_F,
+ /* S_Z */ S_N, S_F, S_Z
+ };
+
+ static const int8_t result_type[] =
+ {
+ /* state x/x x/d x/0 d/x d/d d/0 0/x 0/d 0/0 */
+
+ /* S_N */ CMP, CMP, CMP, CMP, LEN, CMP, CMP, CMP, CMP,
+ /* S_I */ CMP, -1, -1, +1, LEN, LEN, +1, LEN, LEN,
+ /* S_F */ CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP,
+ /* S_Z */ CMP, +1, +1, -1, CMP, CMP, -1, CMP, CMP
+ };
+ unsigned char c1, c2;
+ int state, diff;
+
+ if (p1 == p2)
+ return 0;
+
+ c1 = *p1++;
+ c2 = *p2++;
+ /* Hint: '0' is a digit too. */
+ state = S_N + ((c1 == '0') + (isdigit (c1) != 0));
+
+ while ((diff = c1 - c2) == 0)
+ {
+ if (c1 == '\0')
+ return diff;
+
+ state = next_state[state];
+ c1 = *p1++;
+ c2 = *p2++;
+ state += (c1 == '0') + (isdigit (c1) != 0);
+ }
+
+ state = result_type[state * 3 + (((c2 == '0') + (isdigit (c2) != 0)))];
+
+ switch (state)
+ {
+ case CMP:
+ return diff;
+
+ case LEN:
+ while (isdigit (*p1++))
+ if (!isdigit (*p2++))
+ return 1;
+
+ return isdigit (*p2) ? -1 : diff;
+
+ default:
+ return state;
+ }
+}
+libc_hidden_def(strverscmp)
diff --git a/libc/string/sys_errlist.c b/libc/string/sys_errlist.c
index 17ed4d62c..682ff0e7e 100644
--- a/libc/string/sys_errlist.c
+++ b/libc/string/sys_errlist.c
@@ -12,8 +12,6 @@ extern const char _string_syserrmsgs[] attribute_hidden;
#ifdef __UCLIBC_HAS_SYS_ERRLIST__
-link_warning(_sys_errlist, "sys_nerr and sys_errlist are obsolete and uClibc support for them (in at least some configurations) will probably be unavailable in the near future.")
-
const char *const sys_errlist[] = {
[0] = _string_syserrmsgs + 0,
[EPERM] = _string_syserrmsgs + 8,
diff --git a/libc/string/x86_64/bzero.S b/libc/string/x86_64/bzero.S
index 4d179ec4e..231d7cb41 100644
--- a/libc/string/x86_64/bzero.S
+++ b/libc/string/x86_64/bzero.S
@@ -1,5 +1,6 @@
#include <features.h>
#ifdef __UCLIBC_SUSV3_LEGACY__
# define memset bzero
+# define __memset_chk __bzero_chk
# include "memset.S"
#endif
diff --git a/libc/string/x86_64/memcpy.S b/libc/string/x86_64/memcpy.S
index 697b992d0..e164278df 100644
--- a/libc/string/x86_64/memcpy.S
+++ b/libc/string/x86_64/memcpy.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/>. */
#include "_glibc_inc.h"
@@ -26,7 +25,7 @@
#define MEMPCPY_P (defined memcpy)
.text
-#if defined PIC && !defined NOT_IN_libc
+#if defined __PIC__ && !defined NOT_IN_libc && defined __UCLIBC_HAS_FORTIFY__
ENTRY (__memcpy_chk)
cmpq %rdx, %rcx
jb HIDDEN_JUMPTARGET (__chk_fail)
diff --git a/libc/string/x86_64/mempcpy.S b/libc/string/x86_64/mempcpy.S
index 3816d9f72..b0607aa57 100644
--- a/libc/string/x86_64/mempcpy.S
+++ b/libc/string/x86_64/mempcpy.S
@@ -1,3 +1,4 @@
#define memcpy mempcpy
+#define __memcpy_chk __mempcpy_chk
#include "memcpy.S"
libc_hidden_def(mempcpy)
diff --git a/libc/string/x86_64/memset.S b/libc/string/x86_64/memset.S
index 46751006b..d6744129d 100644
--- a/libc/string/x86_64/memset.S
+++ b/libc/string/x86_64/memset.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 "_glibc_inc.h"
@@ -29,7 +28,7 @@
#define LARGE $120000
.text
-#if !BZERO_P && defined PIC && !defined NOT_IN_libc
+#if defined __PIC__ && !defined NOT_IN_libc && defined __UCLIBC_HAS_FORTIFY__
ENTRY (__memset_chk)
cmpq %rdx, %rcx
jb HIDDEN_JUMPTARGET (__chk_fail)
@@ -142,6 +141,6 @@ END (memset)
libc_hidden_def(memset)
#endif
-#if !BZERO_P && defined PIC && !defined NOT_IN_libc
+#if !BZERO_P && defined __PIC__ && !defined NOT_IN_libc && defined __UCLIBC_HAS_FORTIFY__
strong_alias (__memset_chk, __memset_zero_constant_len_parameter)
#endif
diff --git a/libc/string/x86_64/strcat.S b/libc/string/x86_64/strcat.S
index 23d068fea..55e09e5f1 100644
--- a/libc/string/x86_64/strcat.S
+++ b/libc/string/x86_64/strcat.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 "_glibc_inc.h"
diff --git a/libc/string/x86_64/strchr.S b/libc/string/x86_64/strchr.S
index 9ef46b7f2..256b97911 100644
--- a/libc/string/x86_64/strchr.S
+++ b/libc/string/x86_64/strchr.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/>. */
#include "_glibc_inc.h"
diff --git a/libc/string/x86_64/strcmp.S b/libc/string/x86_64/strcmp.S
index 437e145bf..05d6f39c1 100644
--- a/libc/string/x86_64/strcmp.S
+++ b/libc/string/x86_64/strcmp.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 "_glibc_inc.h"
diff --git a/libc/string/x86_64/strcpy.S b/libc/string/x86_64/strcpy.S
index 612a30d1a..3ada70fbd 100644
--- a/libc/string/x86_64/strcpy.S
+++ b/libc/string/x86_64/strcpy.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/>. */
#include "_glibc_inc.h"
diff --git a/libc/string/x86_64/strcspn.S b/libc/string/x86_64/strcspn.S
index fd9b09c48..7a06c8867 100644
--- a/libc/string/x86_64/strcspn.S
+++ b/libc/string/x86_64/strcspn.S
@@ -19,9 +19,8 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 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 "_glibc_inc.h"
diff --git a/libc/string/x86_64/strlen.S b/libc/string/x86_64/strlen.S
index 4213f0ab6..9e84326c2 100644
--- a/libc/string/x86_64/strlen.S
+++ b/libc/string/x86_64/strlen.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/>. */
#include "_glibc_inc.h"
diff --git a/libc/string/x86_64/strspn.S b/libc/string/x86_64/strspn.S
index 41cff0490..366377649 100644
--- a/libc/string/x86_64/strspn.S
+++ b/libc/string/x86_64/strspn.S
@@ -19,9 +19,8 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 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 "_glibc_inc.h"
diff --git a/libc/string/xtensa/memcpy.S b/libc/string/xtensa/memcpy.S
index 19f3a6818..244205611 100644
--- a/libc/string/xtensa/memcpy.S
+++ b/libc/string/xtensa/memcpy.S
@@ -13,11 +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., 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 "../../sysdeps/linux/xtensa/sysdep.h"
+#include <sysdep.h>
#include <bits/xtensa-config.h>
.macro src_b r, w0, w1
@@ -83,7 +82,7 @@ __memcpy_aux:
loopnez a4, 2f
#else
beqz a4, 2f
- add a7, a3, a4 // a7 = end address for source
+ add a7, a3, a4 /* a7 = end address for source */
#endif
1: l8ui a6, a3, 0
addi a3, a3, 1
@@ -92,13 +91,13 @@ __memcpy_aux:
#if !XCHAL_HAVE_LOOPS
blt a3, a7, 1b
#endif
-2: retw
+2: abi_ret
/* Destination is unaligned. */
.align 4
-.Ldst1mod2: // dst is only byte aligned
+.Ldst1mod2: /* dst is only byte aligned */
/* Do short copies byte-by-byte. */
_bltui a4, 7, .Lbytecopy
@@ -113,7 +112,7 @@ __memcpy_aux:
/* Return to main algorithm if dst is now aligned. */
_bbci.l a5, 1, .Ldstaligned
-.Ldst2mod4: // dst has 16-bit alignment
+.Ldst2mod4: /* dst has 16-bit alignment */
/* Do short copies byte-by-byte. */
_bltui a4, 6, .Lbytecopy
@@ -134,7 +133,7 @@ __memcpy_aux:
ENTRY (memcpy)
/* a2 = dst, a3 = src, a4 = len */
- mov a5, a2 // copy dst so that a2 is return value
+ mov a5, a2 /* copy dst so that a2 is return value */
_bbsi.l a2, 0, .Ldst1mod2
_bbsi.l a2, 1, .Ldst2mod4
.Ldstaligned:
@@ -152,7 +151,7 @@ ENTRY (memcpy)
#else
beqz a7, 2f
slli a8, a7, 4
- add a8, a8, a3 // a8 = end of last 16B source chunk
+ add a8, a8, a3 /* a8 = end of last 16B source chunk */
#endif
1: l32i a6, a3, 0
l32i a7, a3, 4
@@ -182,7 +181,7 @@ ENTRY (memcpy)
3: bbsi.l a4, 2, 4f
bbsi.l a4, 1, 5f
bbsi.l a4, 0, 6f
- retw
+ abi_ret
/* Copy 4 bytes. */
4: l32i a6, a3, 0
@@ -191,7 +190,7 @@ ENTRY (memcpy)
addi a5, a5, 4
bbsi.l a4, 1, 5f
bbsi.l a4, 0, 6f
- retw
+ abi_ret
/* Copy 2 bytes. */
5: l16ui a6, a3, 0
@@ -199,14 +198,14 @@ ENTRY (memcpy)
s16i a6, a5, 0
addi a5, a5, 2
bbsi.l a4, 0, 6f
- retw
+ abi_ret
/* Copy 1 byte. */
6: l8ui a6, a3, 0
s8i a6, a5, 0
.Ldone:
- retw
+ abi_ret
/* Destination is aligned; source is unaligned. */
@@ -218,18 +217,18 @@ ENTRY (memcpy)
/* Copy 16 bytes per iteration for word-aligned dst and
unaligned src. */
- ssa8 a3 // set shift amount from byte offset
+ ssa8 a3 /* set shift amount from byte offset */
#if UNALIGNED_ADDRESSES_CHECKED
- and a11, a3, a8 // save unalignment offset for below
- sub a3, a3, a11 // align a3
+ and a11, a3, a8 /* save unalignment offset for below */
+ sub a3, a3, a11 /* align a3 */
#endif
- l32i a6, a3, 0 // load first word
+ l32i a6, a3, 0 /* load first word */
#if XCHAL_HAVE_LOOPS
loopnez a7, 2f
#else
beqz a7, 2f
slli a10, a7, 4
- add a10, a10, a3 // a10 = end of last 16B source chunk
+ add a10, a10, a3 /* a10 = end of last 16B source chunk */
#endif
1: l32i a7, a3, 4
l32i a8, a3, 8
@@ -273,11 +272,11 @@ ENTRY (memcpy)
mov a6, a7
4:
#if UNALIGNED_ADDRESSES_CHECKED
- add a3, a3, a11 // readjust a3 with correct misalignment
+ add a3, a3, a11 /* readjust a3 with correct misalignment */
#endif
bbsi.l a4, 1, 5f
bbsi.l a4, 0, 6f
- retw
+ abi_ret
/* Copy 2 bytes. */
5: l8ui a6, a3, 0
@@ -287,11 +286,11 @@ ENTRY (memcpy)
s8i a7, a5, 1
addi a5, a5, 2
bbsi.l a4, 0, 6f
- retw
+ abi_ret
/* Copy 1 byte. */
6: l8ui a6, a3, 0
s8i a6, a5, 0
- retw
+ abi_ret
libc_hidden_def (memcpy)
diff --git a/libc/string/xtensa/memset.S b/libc/string/xtensa/memset.S
index c0928825d..20bf14c75 100644
--- a/libc/string/xtensa/memset.S
+++ b/libc/string/xtensa/memset.S
@@ -13,11 +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., 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 "../../sysdeps/linux/xtensa/sysdep.h"
+#include <sysdep.h>
#include <bits/xtensa-config.h>
/* Do not use .literal_position in the ENTRY macro. */
@@ -29,7 +28,7 @@
The algorithm is as follows:
Create a word with c in all byte positions.
-
+
If the destination is aligned, set 16B chunks with a loop, and then
finish up with 8B, 4B, 2B, and 1B stores conditional on the length.
@@ -57,21 +56,21 @@ __memset_aux:
loopnez a4, 2f
#else
beqz a4, 2f
- add a6, a5, a4 // a6 = ending address
+ add a6, a5, a4 /* a6 = ending address */
#endif
1: s8i a3, a5, 0
addi a5, a5, 1
#if !XCHAL_HAVE_LOOPS
blt a5, a6, 1b
#endif
-2: retw
+2: abi_ret
/* Destination is unaligned. */
.align 4
-.Ldst1mod2: // dst is only byte aligned
+.Ldst1mod2: /* dst is only byte aligned */
/* Do short sizes byte-by-byte. */
bltui a4, 8, .Lbyteset
@@ -84,7 +83,7 @@ __memset_aux:
/* Now retest if dst is aligned. */
_bbci.l a5, 1, .Ldstaligned
-.Ldst2mod4: // dst has 16-bit alignment
+.Ldst2mod4: /* dst has 16-bit alignment */
/* Do short sizes byte-by-byte. */
bltui a4, 8, .Lbyteset
@@ -108,7 +107,7 @@ ENTRY (memset)
slli a7, a3, 16
or a3, a3, a7
- mov a5, a2 // copy dst so that a2 is return value
+ mov a5, a2 /* copy dst so that a2 is return value */
/* Check if dst is unaligned. */
_bbsi.l a2, 0, .Ldst1mod2
@@ -124,7 +123,7 @@ ENTRY (memset)
#else
beqz a7, 2f
slli a6, a7, 4
- add a6, a6, a5 // a6 = end of last 16B chunk
+ add a6, a6, a5 /* a6 = end of last 16B chunk */
#endif
/* Set 16 bytes per iteration. */
1: s32i a3, a5, 0
@@ -160,6 +159,6 @@ ENTRY (memset)
/* Set 1 byte. */
s8i a3, a5, 0
-6: retw
+6: abi_ret
libc_hidden_def (memset)
diff --git a/libc/string/xtensa/strcmp.S b/libc/string/xtensa/strcmp.S
index 622bb27ed..2dce590db 100644
--- a/libc/string/xtensa/strcmp.S
+++ b/libc/string/xtensa/strcmp.S
@@ -13,11 +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., 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 "../../sysdeps/linux/xtensa/sysdep.h"
+#include <sysdep.h>
#include <bits/xtensa-config.h>
#include <features.h>
@@ -35,45 +34,46 @@
#define MASK4 0x40404040
+ .text
+ .align 4
+ .literal_position
.literal .Lmask0, MASK0
.literal .Lmask1, MASK1
.literal .Lmask2, MASK2
.literal .Lmask3, MASK3
.literal .Lmask4, MASK4
-
- .text
ENTRY (strcmp)
/* a2 = s1, a3 = s2 */
- l8ui a8, a2, 0 // byte 0 from s1
- l8ui a9, a3, 0 // byte 0 from s2
- movi a10, 3 // mask
+ l8ui a8, a2, 0 /* byte 0 from s1 */
+ l8ui a9, a3, 0 /* byte 0 from s2 */
+ movi a10, 3 /* mask */
bne a8, a9, .Lretdiff
or a11, a2, a3
bnone a11, a10, .Laligned
- xor a11, a2, a3 // compare low two bits of s1 and s2
- bany a11, a10, .Lunaligned // if they have different alignment
+ xor a11, a2, a3 /* compare low two bits of s1 and s2 */
+ bany a11, a10, .Lunaligned /* if they have different alignment */
/* s1/s2 are not word-aligned. */
- addi a2, a2, 1 // advance s1
- beqz a8, .Leq // bytes equal, if zero, strings are equal
- addi a3, a3, 1 // advance s2
- bnone a2, a10, .Laligned // if s1/s2 now aligned
- l8ui a8, a2, 0 // byte 1 from s1
- l8ui a9, a3, 0 // byte 1 from s2
- addi a2, a2, 1 // advance s1
- bne a8, a9, .Lretdiff // if different, return difference
- beqz a8, .Leq // bytes equal, if zero, strings are equal
- addi a3, a3, 1 // advance s2
- bnone a2, a10, .Laligned // if s1/s2 now aligned
- l8ui a8, a2, 0 // byte 2 from s1
- l8ui a9, a3, 0 // byte 2 from s2
- addi a2, a2, 1 // advance s1
- bne a8, a9, .Lretdiff // if different, return difference
- beqz a8, .Leq // bytes equal, if zero, strings are equal
- addi a3, a3, 1 // advance s2
+ addi a2, a2, 1 /* advance s1 */
+ beqz a8, .Leq /* bytes equal, if zero, strings are equal */
+ addi a3, a3, 1 /* advance s2 */
+ bnone a2, a10, .Laligned /* if s1/s2 now aligned */
+ l8ui a8, a2, 0 /* byte 1 from s1 */
+ l8ui a9, a3, 0 /* byte 1 from s2 */
+ addi a2, a2, 1 /* advance s1 */
+ bne a8, a9, .Lretdiff /* if different, return difference */
+ beqz a8, .Leq /* bytes equal, if zero, strings are equal */
+ addi a3, a3, 1 /* advance s2 */
+ bnone a2, a10, .Laligned /* if s1/s2 now aligned */
+ l8ui a8, a2, 0 /* byte 2 from s1 */
+ l8ui a9, a3, 0 /* byte 2 from s2 */
+ addi a2, a2, 1 /* advance s1 */
+ bne a8, a9, .Lretdiff /* if different, return difference */
+ beqz a8, .Leq /* bytes equal, if zero, strings are equal */
+ addi a3, a3, 1 /* advance s2 */
j .Laligned
/* s1 and s2 have different alignment.
@@ -92,8 +92,8 @@ ENTRY (strcmp)
/* (2 mod 4) alignment for loop instruction */
.Lunaligned:
#if XCHAL_HAVE_LOOPS
- _movi.n a8, 0 // set up for the maximum loop count
- loop a8, .Lretdiff // loop forever (almost anyway)
+ _movi.n a8, 0 /* set up for the maximum loop count */
+ loop a8, .Lretdiff /* loop forever (almost anyway) */
#endif
.Lnextbyte:
l8ui a8, a2, 0
@@ -108,7 +108,7 @@ ENTRY (strcmp)
#endif
.Lretdiff:
sub a2, a8, a9
- retw
+ abi_ret
/* s1 is word-aligned; s2 is word-aligned.
@@ -131,32 +131,32 @@ ENTRY (strcmp)
#if XCHAL_HAVE_LOOPS
.Laligned:
.begin no-transform
- l32r a4, .Lmask0 // mask for byte 0
+ l32r a4, .Lmask0 /* mask for byte 0 */
l32r a7, .Lmask4
/* Loop forever. (a4 is more than than the maximum number
of iterations) */
loop a4, .Laligned_done
/* First unrolled loop body. */
- l32i a8, a2, 0 // get word from s1
- l32i a9, a3, 0 // get word from s2
+ l32i a8, a2, 0 /* get word from s1 */
+ l32i a9, a3, 0 /* get word from s2 */
slli a5, a8, 1
bne a8, a9, .Lwne2
or a9, a8, a5
bnall a9, a7, .Lprobeq
/* Second unrolled loop body. */
- l32i a8, a2, 4 // get word from s1+4
- l32i a9, a3, 4 // get word from s2+4
+ l32i a8, a2, 4 /* get word from s1+4 */
+ l32i a9, a3, 4 /* get word from s2+4 */
slli a5, a8, 1
bne a8, a9, .Lwne2
or a9, a8, a5
bnall a9, a7, .Lprobeq2
- addi a2, a2, 8 // advance s1 pointer
- addi a3, a3, 8 // advance s2 pointer
+ addi a2, a2, 8 /* advance s1 pointer */
+ addi a3, a3, 8 /* advance s2 pointer */
.Laligned_done:
- or a1, a1, a1 // nop
+ or a1, a1, a1 /* nop */
.Lprobeq2:
/* Adjust pointers to account for the loop unrolling. */
@@ -166,15 +166,15 @@ ENTRY (strcmp)
#else /* !XCHAL_HAVE_LOOPS */
.Laligned:
- movi a4, MASK0 // mask for byte 0
+ movi a4, MASK0 /* mask for byte 0 */
movi a7, MASK4
j .Lfirstword
.Lnextword:
- addi a2, a2, 4 // advance s1 pointer
- addi a3, a3, 4 // advance s2 pointer
+ addi a2, a2, 4 /* advance s1 pointer */
+ addi a3, a3, 4 /* advance s2 pointer */
.Lfirstword:
- l32i a8, a2, 0 // get word from s1
- l32i a9, a3, 0 // get word from s2
+ l32i a8, a2, 0 /* get word from s1 */
+ l32i a9, a3, 0 /* get word from s2 */
slli a5, a8, 1
bne a8, a9, .Lwne2
or a9, a8, a5
@@ -186,50 +186,50 @@ ENTRY (strcmp)
/* Words are probably equal, but check for sure.
If not, loop over the rest of string using normal algorithm. */
- bnone a8, a4, .Leq // if byte 0 is zero
- l32r a5, .Lmask1 // mask for byte 1
- l32r a6, .Lmask2 // mask for byte 2
- bnone a8, a5, .Leq // if byte 1 is zero
- l32r a7, .Lmask3 // mask for byte 3
- bnone a8, a6, .Leq // if byte 2 is zero
- bnone a8, a7, .Leq // if byte 3 is zero
- addi.n a2, a2, 4 // advance s1 pointer
- addi.n a3, a3, 4 // advance s2 pointer
+ bnone a8, a4, .Leq /* if byte 0 is zero */
+ l32r a5, .Lmask1 /* mask for byte 1 */
+ l32r a6, .Lmask2 /* mask for byte 2 */
+ bnone a8, a5, .Leq /* if byte 1 is zero */
+ l32r a7, .Lmask3 /* mask for byte 3 */
+ bnone a8, a6, .Leq /* if byte 2 is zero */
+ bnone a8, a7, .Leq /* if byte 3 is zero */
+ addi.n a2, a2, 4 /* advance s1 pointer */
+ addi.n a3, a3, 4 /* advance s2 pointer */
#if XCHAL_HAVE_LOOPS
/* align (1 mod 4) */
- loop a4, .Leq // loop forever (a4 is bigger than max iters)
+ loop a4, .Leq /* loop forever (a4 is bigger than max iters) */
.end no-transform
- l32i a8, a2, 0 // get word from s1
- l32i a9, a3, 0 // get word from s2
- addi a2, a2, 4 // advance s1 pointer
+ l32i a8, a2, 0 /* get word from s1 */
+ l32i a9, a3, 0 /* get word from s2 */
+ addi a2, a2, 4 /* advance s1 pointer */
bne a8, a9, .Lwne
- bnone a8, a4, .Leq // if byte 0 is zero
- bnone a8, a5, .Leq // if byte 1 is zero
- bnone a8, a6, .Leq // if byte 2 is zero
- bnone a8, a7, .Leq // if byte 3 is zero
- addi a3, a3, 4 // advance s2 pointer
+ bnone a8, a4, .Leq /* if byte 0 is zero */
+ bnone a8, a5, .Leq /* if byte 1 is zero */
+ bnone a8, a6, .Leq /* if byte 2 is zero */
+ bnone a8, a7, .Leq /* if byte 3 is zero */
+ addi a3, a3, 4 /* advance s2 pointer */
#else /* !XCHAL_HAVE_LOOPS */
j .Lfirstword2
.Lnextword2:
- addi a3, a3, 4 // advance s2 pointer
+ addi a3, a3, 4 /* advance s2 pointer */
.Lfirstword2:
- l32i a8, a2, 0 // get word from s1
- l32i a9, a3, 0 // get word from s2
- addi a2, a2, 4 // advance s1 pointer
+ l32i a8, a2, 0 /* get word from s1 */
+ l32i a9, a3, 0 /* get word from s2 */
+ addi a2, a2, 4 /* advance s1 pointer */
bne a8, a9, .Lwne
- bnone a8, a4, .Leq // if byte 0 is zero
- bnone a8, a5, .Leq // if byte 1 is zero
- bnone a8, a6, .Leq // if byte 2 is zero
- bany a8, a7, .Lnextword2 // if byte 3 is zero
+ bnone a8, a4, .Leq /* if byte 0 is zero */
+ bnone a8, a5, .Leq /* if byte 1 is zero */
+ bnone a8, a6, .Leq /* if byte 2 is zero */
+ bany a8, a7, .Lnextword2 /* if byte 3 is zero */
#endif /* !XCHAL_HAVE_LOOPS */
/* Words are equal; some byte is zero. */
-.Leq: movi a2, 0 // return equal
- retw
+.Leq: movi a2, 0 /* return equal */
+ abi_ret
.Lwne2: /* Words are not equal. On big-endian processors, if none of the
bytes are zero, the return value can be determined by a simple
@@ -239,22 +239,22 @@ ENTRY (strcmp)
bnall a10, a7, .Lsomezero
bgeu a8, a9, .Lposreturn
movi a2, -1
- retw
+ abi_ret
.Lposreturn:
movi a2, 1
- retw
-.Lsomezero: // There is probably some zero byte.
+ abi_ret
+.Lsomezero: /* There is probably some zero byte. */
#endif /* __XTENSA_EB__ */
.Lwne: /* Words are not equal. */
- xor a2, a8, a9 // get word with nonzero in byte that differs
- bany a2, a4, .Ldiff0 // if byte 0 differs
- movi a5, MASK1 // mask for byte 1
- bnone a8, a4, .Leq // if byte 0 is zero
- bany a2, a5, .Ldiff1 // if byte 1 differs
- movi a6, MASK2 // mask for byte 2
- bnone a8, a5, .Leq // if byte 1 is zero
- bany a2, a6, .Ldiff2 // if byte 2 differs
- bnone a8, a6, .Leq // if byte 2 is zero
+ xor a2, a8, a9 /* get word with nonzero in byte that differs */
+ bany a2, a4, .Ldiff0 /* if byte 0 differs */
+ movi a5, MASK1 /* mask for byte 1 */
+ bnone a8, a4, .Leq /* if byte 0 is zero */
+ bany a2, a5, .Ldiff1 /* if byte 1 differs */
+ movi a6, MASK2 /* mask for byte 2 */
+ bnone a8, a5, .Leq /* if byte 1 is zero */
+ bany a2, a6, .Ldiff2 /* if byte 2 differs */
+ bnone a8, a6, .Leq /* if byte 2 is zero */
#ifdef __XTENSA_EB__
.Ldiff3:
.Ldiff2:
@@ -263,14 +263,14 @@ ENTRY (strcmp)
byte. Just subtract words to get the return value.
The high order equal bytes cancel, leaving room for the sign. */
sub a2, a8, a9
- retw
+ abi_ret
.Ldiff0:
/* Need to make room for the sign, so can't subtract whole words. */
extui a10, a8, 24, 8
extui a11, a9, 24, 8
sub a2, a10, a11
- retw
+ abi_ret
#else /* !__XTENSA_EB__ */
/* Little-endian is a little more difficult because can't subtract
@@ -281,28 +281,28 @@ ENTRY (strcmp)
extui a10, a8, 24, 8
extui a11, a9, 24, 8
sub a2, a10, a11
- retw
+ abi_ret
.Ldiff0:
/* Byte 0 is different. */
extui a10, a8, 0, 8
extui a11, a9, 0, 8
sub a2, a10, a11
- retw
+ abi_ret
.Ldiff1:
/* Byte 0 is equal; byte 1 is different. */
extui a10, a8, 8, 8
extui a11, a9, 8, 8
sub a2, a10, a11
- retw
+ abi_ret
.Ldiff2:
/* Bytes 0-1 are equal; byte 2 is different. */
extui a10, a8, 16, 8
extui a11, a9, 16, 8
sub a2, a10, a11
- retw
+ abi_ret
#endif /* !__XTENSA_EB */
diff --git a/libc/string/xtensa/strcpy.S b/libc/string/xtensa/strcpy.S
index 108070384..9f42b34e6 100644
--- a/libc/string/xtensa/strcpy.S
+++ b/libc/string/xtensa/strcpy.S
@@ -13,11 +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., 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 "../../sysdeps/linux/xtensa/sysdep.h"
+#include <sysdep.h>
#include <bits/xtensa-config.h>
#ifdef __XTENSA_EB__
@@ -36,7 +35,7 @@
ENTRY (strcpy)
/* a2 = dst, a3 = src */
- mov a10, a2 // leave dst in return value register
+ mov a10, a2 /* leave dst in return value register */
movi a4, MASK0
movi a5, MASK1
movi a6, MASK2
@@ -51,25 +50,25 @@ ENTRY (strcpy)
j .Ldstunaligned
-.Lsrc1mod2: // src address is odd
- l8ui a8, a3, 0 // get byte 0
- addi a3, a3, 1 // advance src pointer
- s8i a8, a10, 0 // store byte 0
- beqz a8, 1f // if byte 0 is zero
- addi a10, a10, 1 // advance dst pointer
- bbci.l a3, 1, .Lsrcaligned // if src is now word-aligned
+.Lsrc1mod2: /* src address is odd */
+ l8ui a8, a3, 0 /* get byte 0 */
+ addi a3, a3, 1 /* advance src pointer */
+ s8i a8, a10, 0 /* store byte 0 */
+ beqz a8, 1f /* if byte 0 is zero */
+ addi a10, a10, 1 /* advance dst pointer */
+ bbci.l a3, 1, .Lsrcaligned /* if src is now word-aligned */
-.Lsrc2mod4: // src address is 2 mod 4
- l8ui a8, a3, 0 // get byte 0
+.Lsrc2mod4: /* src address is 2 mod 4 */
+ l8ui a8, a3, 0 /* get byte 0 */
/* 1-cycle interlock */
- s8i a8, a10, 0 // store byte 0
- beqz a8, 1f // if byte 0 is zero
- l8ui a8, a3, 1 // get byte 0
- addi a3, a3, 2 // advance src pointer
- s8i a8, a10, 1 // store byte 0
- addi a10, a10, 2 // advance dst pointer
+ s8i a8, a10, 0 /* store byte 0 */
+ beqz a8, 1f /* if byte 0 is zero */
+ l8ui a8, a3, 1 /* get byte 0 */
+ addi a3, a3, 2 /* advance src pointer */
+ s8i a8, a10, 1 /* store byte 0 */
+ addi a10, a10, 2 /* advance dst pointer */
bnez a8, .Lsrcaligned
-1: retw
+1: abi_ret
/* dst is word-aligned; src is word-aligned. */
@@ -78,46 +77,46 @@ ENTRY (strcpy)
#if XCHAL_HAVE_LOOPS
/* (2 mod 4) alignment for loop instruction */
.Laligned:
- _movi.n a8, 0 // set up for the maximum loop count
- loop a8, .Lz3 // loop forever (almost anyway)
- l32i a8, a3, 0 // get word from src
- addi a3, a3, 4 // advance src pointer
- bnone a8, a4, .Lz0 // if byte 0 is zero
- bnone a8, a5, .Lz1 // if byte 1 is zero
- bnone a8, a6, .Lz2 // if byte 2 is zero
- s32i a8, a10, 0 // store word to dst
- bnone a8, a7, .Lz3 // if byte 3 is zero
- addi a10, a10, 4 // advance dst pointer
+ _movi.n a8, 0 /* set up for the maximum loop count */
+ loop a8, .Lz3 /* loop forever (almost anyway) */
+ l32i a8, a3, 0 /* get word from src */
+ addi a3, a3, 4 /* advance src pointer */
+ bnone a8, a4, .Lz0 /* if byte 0 is zero */
+ bnone a8, a5, .Lz1 /* if byte 1 is zero */
+ bnone a8, a6, .Lz2 /* if byte 2 is zero */
+ s32i a8, a10, 0 /* store word to dst */
+ bnone a8, a7, .Lz3 /* if byte 3 is zero */
+ addi a10, a10, 4 /* advance dst pointer */
#else /* !XCHAL_HAVE_LOOPS */
-1: addi a10, a10, 4 // advance dst pointer
+1: addi a10, a10, 4 /* advance dst pointer */
.Laligned:
- l32i a8, a3, 0 // get word from src
- addi a3, a3, 4 // advance src pointer
- bnone a8, a4, .Lz0 // if byte 0 is zero
- bnone a8, a5, .Lz1 // if byte 1 is zero
- bnone a8, a6, .Lz2 // if byte 2 is zero
- s32i a8, a10, 0 // store word to dst
- bany a8, a7, 1b // if byte 3 is zero
+ l32i a8, a3, 0 /* get word from src */
+ addi a3, a3, 4 /* advance src pointer */
+ bnone a8, a4, .Lz0 /* if byte 0 is zero */
+ bnone a8, a5, .Lz1 /* if byte 1 is zero */
+ bnone a8, a6, .Lz2 /* if byte 2 is zero */
+ s32i a8, a10, 0 /* store word to dst */
+ bany a8, a7, 1b /* if byte 3 is zero */
#endif /* !XCHAL_HAVE_LOOPS */
.Lz3: /* Byte 3 is zero. */
- retw
+ abi_ret
.Lz0: /* Byte 0 is zero. */
#ifdef __XTENSA_EB__
movi a8, 0
#endif
s8i a8, a10, 0
- retw
+ abi_ret
.Lz1: /* Byte 1 is zero. */
#ifdef __XTENSA_EB__
extui a8, a8, 16, 16
#endif
s16i a8, a10, 0
- retw
+ abi_ret
.Lz2: /* Byte 2 is zero. */
#ifdef __XTENSA_EB__
@@ -126,15 +125,15 @@ ENTRY (strcpy)
s16i a8, a10, 0
movi a8, 0
s8i a8, a10, 2
- retw
+ abi_ret
.align 4
/* (2 mod 4) alignment for loop instruction */
.Ldstunaligned:
#if XCHAL_HAVE_LOOPS
- _movi.n a8, 0 // set up for the maximum loop count
- loop a8, 2f // loop forever (almost anyway)
+ _movi.n a8, 0 /* set up for the maximum loop count */
+ loop a8, 2f /* loop forever (almost anyway) */
#endif
1: l8ui a8, a3, 0
addi a3, a3, 1
@@ -145,6 +144,6 @@ ENTRY (strcpy)
#else
bnez a8, 1b
#endif
-2: retw
+2: abi_ret
libc_hidden_def (strcpy)
diff --git a/libc/string/xtensa/strlen.S b/libc/string/xtensa/strlen.S
index dd72c16fa..e1c98c8f0 100644
--- a/libc/string/xtensa/strlen.S
+++ b/libc/string/xtensa/strlen.S
@@ -13,11 +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., 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 "../../sysdeps/linux/xtensa/sysdep.h"
+#include <sysdep.h>
#include <bits/xtensa-config.h>
#ifdef __XTENSA_EB__
@@ -36,7 +35,7 @@
ENTRY (strlen)
/* a2 = s */
- addi a3, a2, -4 // because we overincrement at the end
+ addi a3, a2, -4 /* because we overincrement at the end */
movi a4, MASK0
movi a5, MASK1
movi a6, MASK2
@@ -45,22 +44,22 @@ ENTRY (strlen)
bbsi.l a2, 1, .L2mod4
j .Laligned
-.L1mod2: // address is odd
- l8ui a8, a3, 4 // get byte 0
- addi a3, a3, 1 // advance string pointer
- beqz a8, .Lz3 // if byte 0 is zero
- bbci.l a3, 1, .Laligned // if string pointer is now word-aligned
+.L1mod2: /* address is odd */
+ l8ui a8, a3, 4 /* get byte 0 */
+ addi a3, a3, 1 /* advance string pointer */
+ beqz a8, .Lz3 /* if byte 0 is zero */
+ bbci.l a3, 1, .Laligned /* if string pointer is now word-aligned */
-.L2mod4: // address is 2 mod 4
- addi a3, a3, 2 // advance ptr for aligned access
- l32i a8, a3, 0 // get word with first two bytes of string
- bnone a8, a6, .Lz2 // if byte 2 (of word, not string) is zero
- bany a8, a7, .Laligned // if byte 3 (of word, not string) is nonzero
+.L2mod4: /* address is 2 mod 4 */
+ addi a3, a3, 2 /* advance ptr for aligned access */
+ l32i a8, a3, 0 /* get word with first two bytes of string */
+ bnone a8, a6, .Lz2 /* if byte 2 (of word, not string) is zero */
+ bany a8, a7, .Laligned /* if byte 3 (of word, not string) is nonzero */
/* Byte 3 is zero. */
- addi a3, a3, 3 // point to zero byte
- sub a2, a3, a2 // subtract to get length
- retw
+ addi a3, a3, 3 /* point to zero byte */
+ sub a2, a3, a2 /* subtract to get length */
+ abi_ret
/* String is word-aligned. */
@@ -69,36 +68,36 @@ ENTRY (strlen)
/* (2 mod 4) alignment for loop instruction */
.Laligned:
#if XCHAL_HAVE_LOOPS
- _movi.n a8, 0 // set up for the maximum loop count
- loop a8, .Lz3 // loop forever (almost anyway)
+ _movi.n a8, 0 /* set up for the maximum loop count */
+ loop a8, .Lz3 /* loop forever (almost anyway) */
#endif
-1: l32i a8, a3, 4 // get next word of string
- addi a3, a3, 4 // advance string pointer
- bnone a8, a4, .Lz0 // if byte 0 is zero
- bnone a8, a5, .Lz1 // if byte 1 is zero
- bnone a8, a6, .Lz2 // if byte 2 is zero
+1: l32i a8, a3, 4 /* get next word of string */
+ addi a3, a3, 4 /* advance string pointer */
+ bnone a8, a4, .Lz0 /* if byte 0 is zero */
+ bnone a8, a5, .Lz1 /* if byte 1 is zero */
+ bnone a8, a6, .Lz2 /* if byte 2 is zero */
#if XCHAL_HAVE_LOOPS
- bnone a8, a7, .Lz3 // if byte 3 is zero
+ bnone a8, a7, .Lz3 /* if byte 3 is zero */
#else
- bany a8, a7, 1b // repeat if byte 3 is non-zero
+ bany a8, a7, 1b /* repeat if byte 3 is non-zero */
#endif
.Lz3: /* Byte 3 is zero. */
- addi a3, a3, 3 // point to zero byte
+ addi a3, a3, 3 /* point to zero byte */
/* Fall through.... */
.Lz0: /* Byte 0 is zero. */
- sub a2, a3, a2 // subtract to get length
- retw
+ sub a2, a3, a2 /* subtract to get length */
+ abi_ret
.Lz1: /* Byte 1 is zero. */
- addi a3, a3, 1 // point to zero byte
- sub a2, a3, a2 // subtract to get length
- retw
+ addi a3, a3, 1 /* point to zero byte */
+ sub a2, a3, a2 /* subtract to get length */
+ abi_ret
.Lz2: /* Byte 2 is zero. */
- addi a3, a3, 2 // point to zero byte
- sub a2, a3, a2 // subtract to get length
- retw
+ addi a3, a3, 2 /* point to zero byte */
+ sub a2, a3, a2 /* subtract to get length */
+ abi_ret
libc_hidden_def (strlen)
diff --git a/libc/string/xtensa/strncpy.S b/libc/string/xtensa/strncpy.S
index 7ba2ef77d..aa8db5da1 100644
--- a/libc/string/xtensa/strncpy.S
+++ b/libc/string/xtensa/strncpy.S
@@ -13,11 +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., 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 "../../sysdeps/linux/xtensa/sysdep.h"
+#include <sysdep.h>
#include <bits/xtensa-config.h>
#ifdef __XTENSA_EB__
@@ -41,41 +40,41 @@
.literal_position
__strncpy_aux:
-.Lsrc1mod2: // src address is odd
- l8ui a8, a3, 0 // get byte 0
- addi a3, a3, 1 // advance src pointer
- s8i a8, a10, 0 // store byte 0
- addi a4, a4, -1 // decrement n
- beqz a4, .Lret // if n is zero
- addi a10, a10, 1 // advance dst pointer
- beqz a8, .Lfill // if byte 0 is zero
- bbci.l a3, 1, .Lsrcaligned // if src is now word-aligned
-
-.Lsrc2mod4: // src address is 2 mod 4
- l8ui a8, a3, 0 // get byte 0
- addi a4, a4, -1 // decrement n
- s8i a8, a10, 0 // store byte 0
- beqz a4, .Lret // if n is zero
- addi a10, a10, 1 // advance dst pointer
- beqz a8, .Lfill // if byte 0 is zero
- l8ui a8, a3, 1 // get byte 0
- addi a3, a3, 2 // advance src pointer
- s8i a8, a10, 0 // store byte 0
- addi a4, a4, -1 // decrement n
- beqz a4, .Lret // if n is zero
- addi a10, a10, 1 // advance dst pointer
+.Lsrc1mod2: /* src address is odd */
+ l8ui a8, a3, 0 /* get byte 0 */
+ addi a3, a3, 1 /* advance src pointer */
+ s8i a8, a10, 0 /* store byte 0 */
+ addi a4, a4, -1 /* decrement n */
+ beqz a4, .Lret /* if n is zero */
+ addi a10, a10, 1 /* advance dst pointer */
+ beqz a8, .Lfill /* if byte 0 is zero */
+ bbci.l a3, 1, .Lsrcaligned /* if src is now word-aligned */
+
+.Lsrc2mod4: /* src address is 2 mod 4 */
+ l8ui a8, a3, 0 /* get byte 0 */
+ addi a4, a4, -1 /* decrement n */
+ s8i a8, a10, 0 /* store byte 0 */
+ beqz a4, .Lret /* if n is zero */
+ addi a10, a10, 1 /* advance dst pointer */
+ beqz a8, .Lfill /* if byte 0 is zero */
+ l8ui a8, a3, 1 /* get byte 0 */
+ addi a3, a3, 2 /* advance src pointer */
+ s8i a8, a10, 0 /* store byte 0 */
+ addi a4, a4, -1 /* decrement n */
+ beqz a4, .Lret /* if n is zero */
+ addi a10, a10, 1 /* advance dst pointer */
bnez a8, .Lsrcaligned
j .Lfill
.Lret:
- retw
+ abi_ret
ENTRY (strncpy)
/* a2 = dst, a3 = src */
- mov a10, a2 // leave dst in return value register
- beqz a4, .Lret // if n is zero
+ mov a10, a2 /* leave dst in return value register */
+ beqz a4, .Lret /* if n is zero */
movi a11, MASK0
movi a5, MASK1
@@ -125,28 +124,28 @@ ENTRY (strncpy)
.Lfillcleanup:
/* Fill leftover (1 to 3) bytes with zero. */
- s8i a9, a10, 0 // store byte 0
- addi a4, a4, -1 // decrement n
+ s8i a9, a10, 0 /* store byte 0 */
+ addi a4, a4, -1 /* decrement n */
addi a10, a10, 1
- bnez a4, .Lfillcleanup
-
-2: retw
-
-.Lfill1mod2: // dst address is odd
- s8i a9, a10, 0 // store byte 0
- addi a4, a4, -1 // decrement n
- beqz a4, 2b // if n is zero
- addi a10, a10, 1 // advance dst pointer
- bbci.l a10, 1, .Lfillaligned // if dst is now word-aligned
-
-.Lfill2mod4: // dst address is 2 mod 4
- s8i a9, a10, 0 // store byte 0
- addi a4, a4, -1 // decrement n
- beqz a4, 2b // if n is zero
- s8i a9, a10, 1 // store byte 1
- addi a4, a4, -1 // decrement n
- beqz a4, 2b // if n is zero
- addi a10, a10, 2 // advance dst pointer
+ bnez a4, .Lfillcleanup
+
+2: abi_ret
+
+.Lfill1mod2: /* dst address is odd */
+ s8i a9, a10, 0 /* store byte 0 */
+ addi a4, a4, -1 /* decrement n */
+ beqz a4, 2b /* if n is zero */
+ addi a10, a10, 1 /* advance dst pointer */
+ bbci.l a10, 1, .Lfillaligned /* if dst is now word-aligned */
+
+.Lfill2mod4: /* dst address is 2 mod 4 */
+ s8i a9, a10, 0 /* store byte 0 */
+ addi a4, a4, -1 /* decrement n */
+ beqz a4, 2b /* if n is zero */
+ s8i a9, a10, 1 /* store byte 1 */
+ addi a4, a4, -1 /* decrement n */
+ beqz a4, 2b /* if n is zero */
+ addi a10, a10, 2 /* advance dst pointer */
j .Lfillaligned
@@ -156,32 +155,32 @@ ENTRY (strncpy)
/* (2 mod 4) alignment for loop instruction */
.Laligned:
#if XCHAL_HAVE_LOOPS
- _movi.n a8, 0 // set up for the maximum loop count
- loop a8, 1f // loop forever (almost anyway)
- blti a4, 5, .Ldstunaligned // n is near limit; do one at a time
- l32i a8, a3, 0 // get word from src
- addi a3, a3, 4 // advance src pointer
- bnone a8, a11, .Lz0 // if byte 0 is zero
- bnone a8, a5, .Lz1 // if byte 1 is zero
- bnone a8, a6, .Lz2 // if byte 2 is zero
- s32i a8, a10, 0 // store word to dst
- addi a4, a4, -4 // decrement n
- addi a10, a10, 4 // advance dst pointer
- bnone a8, a7, .Lfill // if byte 3 is zero
-1:
+ _movi.n a8, 0 /* set up for the maximum loop count */
+ loop a8, 1f /* loop forever (almost anyway) */
+ blti a4, 5, .Ldstunaligned /* n is near limit; do one at a time */
+ l32i a8, a3, 0 /* get word from src */
+ addi a3, a3, 4 /* advance src pointer */
+ bnone a8, a11, .Lz0 /* if byte 0 is zero */
+ bnone a8, a5, .Lz1 /* if byte 1 is zero */
+ bnone a8, a6, .Lz2 /* if byte 2 is zero */
+ s32i a8, a10, 0 /* store word to dst */
+ addi a4, a4, -4 /* decrement n */
+ addi a10, a10, 4 /* advance dst pointer */
+ bnone a8, a7, .Lfill /* if byte 3 is zero */
+1:
#else /* !XCHAL_HAVE_LOOPS */
-1: blti a4, 5, .Ldstunaligned // n is near limit; do one at a time
- l32i a8, a3, 0 // get word from src
- addi a3, a3, 4 // advance src pointer
- bnone a8, a11, .Lz0 // if byte 0 is zero
- bnone a8, a5, .Lz1 // if byte 1 is zero
- bnone a8, a6, .Lz2 // if byte 2 is zero
- s32i a8, a10, 0 // store word to dst
- addi a4, a4, -4 // decrement n
- addi a10, a10, 4 // advance dst pointer
- bany a8, a7, 1b // no zeroes
+1: blti a4, 5, .Ldstunaligned /* n is near limit; do one at a time */
+ l32i a8, a3, 0 /* get word from src */
+ addi a3, a3, 4 /* advance src pointer */
+ bnone a8, a11, .Lz0 /* if byte 0 is zero */
+ bnone a8, a5, .Lz1 /* if byte 1 is zero */
+ bnone a8, a6, .Lz2 /* if byte 2 is zero */
+ s32i a8, a10, 0 /* store word to dst */
+ addi a4, a4, -4 /* decrement n */
+ addi a10, a10, 4 /* advance dst pointer */
+ bany a8, a7, 1b /* no zeroes */
#endif /* !XCHAL_HAVE_LOOPS */
j .Lfill
@@ -191,8 +190,8 @@ ENTRY (strncpy)
movi a8, 0
#endif
s8i a8, a10, 0
- addi a4, a4, -1 // decrement n
- addi a10, a10, 1 // advance dst pointer
+ addi a4, a4, -1 /* decrement n */
+ addi a10, a10, 1 /* advance dst pointer */
j .Lfill
.Lz1: /* Byte 1 is zero. */
@@ -200,8 +199,8 @@ ENTRY (strncpy)
extui a8, a8, 16, 16
#endif
s16i a8, a10, 0
- addi a4, a4, -2 // decrement n
- addi a10, a10, 2 // advance dst pointer
+ addi a4, a4, -2 /* decrement n */
+ addi a10, a10, 2 /* advance dst pointer */
j .Lfill
.Lz2: /* Byte 2 is zero. */
@@ -211,8 +210,8 @@ ENTRY (strncpy)
s16i a8, a10, 0
movi a8, 0
s8i a8, a10, 2
- addi a4, a4, -3 // decrement n
- addi a10, a10, 3 // advance dst pointer
+ addi a4, a4, -3 /* decrement n */
+ addi a10, a10, 3 /* advance dst pointer */
j .Lfill
.align 4
@@ -220,8 +219,8 @@ ENTRY (strncpy)
.Ldstunaligned:
#if XCHAL_HAVE_LOOPS
- _movi.n a8, 0 // set up for the maximum loop count
- loop a8, 2f // loop forever (almost anyway)
+ _movi.n a8, 0 /* set up for the maximum loop count */
+ loop a8, 2f /* loop forever (almost anyway) */
#endif
1: l8ui a8, a3, 0
addi a3, a3, 1
@@ -236,6 +235,6 @@ ENTRY (strncpy)
#endif
2: j .Lfill
-3: retw
+3: abi_ret
libc_hidden_def (strncpy)
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/mman.h b/libc/sysdeps/linux/arm/bits/mman.h
deleted file mode 100644
index 828ec944c..000000000
--- a/libc/sysdeps/linux/arm/bits/mman.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/* Definitions for POSIX memory map interface. Linux/ARM 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/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/nios/bits/endian.h b/libc/sysdeps/linux/c6x/bits/endian.h
index 252597931..7297f9e2e 100644
--- a/libc/sysdeps/linux/nios/bits/endian.h
+++ b/libc/sysdeps/linux/c6x/bits/endian.h
@@ -1,8 +1,11 @@
-/* nios is little-endian. */
+/* c6x is little-endian by default. */
#ifndef _ENDIAN_H
# error "Never use <bits/endian.h> directly; include <endian.h> instead."
#endif
-//mle
+#ifdef _BIG_ENDIAN
+#define __BYTE_ORDER __BIG_ENDIAN
+#else
#define __BYTE_ORDER __LITTLE_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/m68k/bits/mman.h b/libc/sysdeps/linux/common/bits/mman-common.h
index fbec1a03f..6cde5daa3 100644
--- a/libc/sysdeps/linux/m68k/bits/mman.h
+++ b/libc/sysdeps/linux/common/bits/mman-common.h
@@ -1,5 +1,5 @@
-/* Definitions for POSIX memory map interface. Linux/m68k version.
- Copyright (C) 1997, 2000, 2003, 2005 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,13 +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_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/common/eventfd_read.c b/libc/sysdeps/linux/common/eventfd_read.c
new file mode 100644
index 000000000..75f2aaa11
--- /dev/null
+++ b/libc/sysdeps/linux/common/eventfd_read.c
@@ -0,0 +1,27 @@
+/* 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_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/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/sys/ucontext.h b/libc/sysdeps/linux/i960/sys/ucontext.h
deleted file mode 100644
index 8c55ea45b..000000000
--- a/libc/sysdeps/linux/i960/sys/ucontext.h
+++ /dev/null
@@ -1,76 +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 32 /* 16 global and 16 local */
-
-/* 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;
-
-/* 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/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/e1/bits/fcntl.h b/libc/sysdeps/linux/lm32/bits/fcntl.h
index 87d193923..5f40957f8 100644
--- a/libc/sysdeps/linux/e1/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/v850/bits/uClibc_arch_features.h b/libc/sysdeps/linux/lm32/bits/uClibc_arch_features.h
index f4adaf5ad..a64f65351 100644
--- a/libc/sysdeps/linux/v850/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/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/v850/bits/fcntl.h b/libc/sysdeps/linux/metag/bits/fcntl.h
index 87d193923..8142a8307 100644
--- a/libc/sysdeps/linux/v850/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/e1/bits/uClibc_arch_features.h b/libc/sysdeps/linux/metag/bits/uClibc_arch_features.h
index f4adaf5ad..1433c588c 100644
--- a/libc/sysdeps/linux/e1/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/vax/sys/ucontext.h b/libc/sysdeps/linux/metag/sys/ucontext.h
index f57b91e4f..899c20035 100644
--- a/libc/sysdeps/linux/vax/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,61 +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 37
-#define NFPREG 33
+#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];
+typedef elf_gregset_t gregset_t;
-/* 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;
+/* 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. */
-typedef struct
- {
- gregset_t gregs;
- fpregset_t fpregs;
- } mcontext_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/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/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/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/endian.h b/libc/sysdeps/linux/vax/bits/endian.h
deleted file mode 100644
index 9f0c4e2a9..000000000
--- a/libc/sysdeps/linux/vax/bits/endian.h
+++ /dev/null
@@ -1,9 +0,0 @@
-/* VAX is little endian */
-
-#ifndef _ENDIAN_H
-# error "Never use <bits/endian.h> directly; include <endian.h> instead."
-#endif
-
-#define __BYTE_ORDER __LITTLE_ENDIAN
-
-/*#define __FLOAT_WORD_ORDER __BIG_ENDIAN*/
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/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/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
diff --git a/libc/termios/Makefile.in b/libc/termios/Makefile.in
index 99b1a729f..73f72729e 100644
--- a/libc/termios/Makefile.in
+++ b/libc/termios/Makefile.in
@@ -1,10 +1,12 @@
# 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.
#
+subdirs += libc/termios
+
TERMIOS_DIR := $(top_srcdir)libc/termios
TERMIOS_OUT := $(top_builddir)libc/termios
@@ -13,7 +15,7 @@ TERMIOS_OBJ := $(patsubst $(TERMIOS_DIR)/%.c,$(TERMIOS_OUT)/%.o,$(TERMIOS_SRC))
libc-y += $(TERMIOS_OBJ)
-objclean-y += termios_objclean
+objclean-y += CLEAN_libc/termios
-termios_objclean:
- $(RM) $(TERMIOS_OUT)/*.{o,os}
+CLEAN_libc/termios:
+ $(do_rm) $(addprefix $(TERMIOS_OUT)/*., o os)
diff --git a/libc/termios/cfmakeraw.c b/libc/termios/cfmakeraw.c
index aae76782d..0c5ec4651 100644
--- a/libc/termios/cfmakeraw.c
+++ b/libc/termios/cfmakeraw.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 <termios.h>
diff --git a/libc/termios/cfsetspeed.c b/libc/termios/cfsetspeed.c
index 5d5eb8cda..f2bfa4e8c 100644
--- a/libc/termios/cfsetspeed.c
+++ b/libc/termios/cfsetspeed.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 <termios.h>
#include <errno.h>
@@ -22,8 +21,6 @@
#ifdef __USE_BSD
-libc_hidden_proto(cfsetispeed)
-libc_hidden_proto(cfsetospeed)
struct speed_struct
{
diff --git a/libc/termios/isatty.c b/libc/termios/isatty.c
index 7532f334b..9c054d962 100644
--- a/libc/termios/isatty.c
+++ b/libc/termios/isatty.c
@@ -12,15 +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 <unistd.h>
#include <termios.h>
-libc_hidden_proto(isatty)
-libc_hidden_proto(tcgetattr)
/* Return 1 if FD is a terminal, 0 if not. */
int isatty (int fd)
diff --git a/libc/termios/kernel_termios.h b/libc/termios/kernel_termios.h
index 87d5c07e4..defb462b7 100644
--- a/libc/termios/kernel_termios.h
+++ b/libc/termios/kernel_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 _KERNEL_TERMIOS_H
#define _KERNEL_TERMIOS_H 1
diff --git a/libc/termios/speed.c b/libc/termios/speed.c
index 52647b9cc..a32e5ed71 100644
--- a/libc/termios/speed.c
+++ b/libc/termios/speed.c
@@ -14,16 +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/>. */
#include <stddef.h>
#include <errno.h>
#include <termios.h>
-libc_hidden_proto(cfsetispeed)
-libc_hidden_proto(cfsetospeed)
/* This is a gross hack around a kernel bug. If the cfsetispeed functions
is called with the SPEED argument set to zero this means use the same
diff --git a/libc/termios/tcdrain.c b/libc/termios/tcdrain.c
index a13374cb5..011a78636 100644
--- a/libc/termios/tcdrain.c
+++ b/libc/termios/tcdrain.c
@@ -12,13 +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 <errno.h>
#include <termios.h>
#include <sys/ioctl.h>
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <sysdep-cancel.h>
+#endif
libc_hidden_proto(ioctl)
@@ -26,6 +28,21 @@ extern __typeof(tcdrain) __libc_tcdrain;
/* Wait for pending output to be written on FD. */
int __libc_tcdrain (int fd)
{
- return ioctl(fd, TCSBRK, 1);
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ if (SINGLE_THREAD_P)
+ /* With an argument of 1, TCSBRK for output to be drain. */
+ return INLINE_SYSCALL (ioctl, 3, fd, TCSBRK, 1);
+
+ int oldtype = LIBC_CANCEL_ASYNC ();
+
+ /* With an argument of 1, TCSBRK for output to be drain. */
+ int result = INLINE_SYSCALL (ioctl, 3, fd, TCSBRK, 1);
+
+ LIBC_CANCEL_RESET (oldtype);
+
+ return result;
+#else
+ return ioctl(fd, TCSBRK, 1);
+#endif
}
weak_alias(__libc_tcdrain,tcdrain)
diff --git a/libc/termios/tcflow.c b/libc/termios/tcflow.c
index 63f96a860..10cc008d0 100644
--- a/libc/termios/tcflow.c
+++ b/libc/termios/tcflow.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 <termios.h>
#include <sys/ioctl.h>
-libc_hidden_proto(ioctl)
/* Suspend or restart transmission on FD. */
int tcflow (int fd, int action)
diff --git a/libc/termios/tcflush.c b/libc/termios/tcflush.c
index 159231fb1..ec36a836c 100644
--- a/libc/termios/tcflush.c
+++ b/libc/termios/tcflush.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 <termios.h>
#include <sys/ioctl.h>
-libc_hidden_proto(ioctl)
/* Flush pending data on FD. */
int
diff --git a/libc/termios/tcgetattr.c b/libc/termios/tcgetattr.c
index 541beb4f6..53e40c39a 100644
--- a/libc/termios/tcgetattr.c
+++ b/libc/termios/tcgetattr.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 <features.h>
#include <string.h>
@@ -23,11 +22,6 @@
#include <sys/ioctl.h>
#include <sys/types.h>
-libc_hidden_proto(ioctl)
-/* Experimentally off - libc_hidden_proto(memset) */
-/* Experimentally off - libc_hidden_proto(memcpy) */
-/* Experimentally off - libc_hidden_proto(mempcpy) */
-libc_hidden_proto(tcgetattr)
/* The difference here is that the termios structure used in the
kernel is not the same as we use in the libc. Therefore we must
diff --git a/libc/termios/tcgetpgrp.c b/libc/termios/tcgetpgrp.c
index 1ad317139..7cec39c3d 100644
--- a/libc/termios/tcgetpgrp.c
+++ b/libc/termios/tcgetpgrp.c
@@ -12,17 +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 <sys/ioctl.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
-libc_hidden_proto(tcgetpgrp)
-libc_hidden_proto(ioctl)
/* Return the foreground process group ID of FD. */
pid_t tcgetpgrp (int fd)
diff --git a/libc/termios/tcgetsid.c b/libc/termios/tcgetsid.c
index 8d3a40242..5e811422c 100644
--- a/libc/termios/tcgetsid.c
+++ b/libc/termios/tcgetsid.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>
#include <termios.h>
@@ -22,9 +21,6 @@
#include <sys/types.h>
#include <unistd.h>
-libc_hidden_proto(ioctl)
-libc_hidden_proto(getsid)
-libc_hidden_proto(tcgetpgrp)
/* Return the session ID of FD. */
pid_t
diff --git a/libc/termios/tcsendbrk.c b/libc/termios/tcsendbrk.c
index ae04cb947..8339cfa46 100644
--- a/libc/termios/tcsendbrk.c
+++ b/libc/termios/tcsendbrk.c
@@ -13,16 +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/>. */
#include <errno.h>
#include <stddef.h>
#include <termios.h>
#include <sys/ioctl.h>
-libc_hidden_proto(ioctl)
/* Send zero bits on FD. */
int
diff --git a/libc/termios/tcsetattr.c b/libc/termios/tcsetattr.c
index d0d82c2ac..8b9d25361 100644
--- a/libc/termios/tcsetattr.c
+++ b/libc/termios/tcsetattr.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>
#include <string.h>
@@ -22,9 +21,6 @@
#include <sys/ioctl.h>
#include <sys/types.h>
-libc_hidden_proto(tcsetattr)
-/* Experimentally off - libc_hidden_proto(memcpy) */
-libc_hidden_proto(ioctl)
/* The difference here is that the termios structure used in the
kernel is not the same as we use in the libc. Therefore we must
diff --git a/libc/termios/tcsetpgrp.c b/libc/termios/tcsetpgrp.c
index 9bf1cdaef..ee73fb149 100644
--- a/libc/termios/tcsetpgrp.c
+++ b/libc/termios/tcsetpgrp.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 <sys/types.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <unistd.h>
-libc_hidden_proto(ioctl)
/* Set the foreground process group ID of FD set PGRP_ID. */
int tcsetpgrp (int fd, pid_t pgrp_id)
diff --git a/libc/termios/ttyname.c b/libc/termios/ttyname.c
index 9d6a8ce36..5fcf23b64 100644
--- a/libc/termios/ttyname.c
+++ b/libc/termios/ttyname.c
@@ -31,15 +31,6 @@
#include <dirent.h>
#include <sys/stat.h>
-libc_hidden_proto(ttyname_r)
-libc_hidden_proto(fstat)
-libc_hidden_proto(lstat)
-/* Experimentally off - libc_hidden_proto(strcpy) */
-/* Experimentally off - libc_hidden_proto(strlen) */
-libc_hidden_proto(opendir)
-libc_hidden_proto(closedir)
-libc_hidden_proto(readdir)
-libc_hidden_proto(isatty)
#define TTYNAME_BUFLEN 32
diff --git a/libc/unistd/Makefile.in b/libc/unistd/Makefile.in
index 8095aa641..659008d4d 100644
--- a/libc/unistd/Makefile.in
+++ b/libc/unistd/Makefile.in
@@ -1,48 +1,40 @@
# 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.
#
+subdirs += libc/unistd
+
UNISTD_DIR := $(top_srcdir)libc/unistd
UNISTD_OUT := $(top_builddir)libc/unistd
-CSRC := $(notdir $(wildcard $(UNISTD_DIR)/*.c))
-# multi source
-CSRC := $(filter-out exec.c,$(CSRC))
-
-ifeq ($(ARCH_USE_MMU),y)
-CSRC := $(filter-out __exec_alloc.c,$(CSRC))
-else
-CSRC := $(filter-out daemon.c,$(CSRC))
-endif
+CSRC-y := $(notdir $(wildcard $(UNISTD_DIR)/*.c))
+OMIT-y := exec.c # multi source
+OMIT-$(ARCH_USE_MMU) += __exec_alloc.c
+OMIT-$(if $(UCLIBC_SUSV3_LEGACY),,y) += ualarm.c usleep.c
+#OMIT-$(UCLIBC_HAS_THREADS_NATIVE) += sleep.c
ifeq ($(UCLIBC_HAS_GNU_GETOPT),y)
-CSRC := $(filter-out getopt-susv3.c getopt_long-simple.c,$(CSRC))
+# GNU getopt family
+OMIT-y += getopt-susv3.c getopt_long-simple.c getsubopt-susv3.c
+OMIT-y += $(if $(UCLIBC_HAS_GNU_GETSUBOPT),,getsubopt.c)
else
-CSRC := $(filter-out getopt.c,$(CSRC))
-ifneq ($(UCLIBC_HAS_GETOPT_LONG),y)
-CSRC := $(filter-out getopt_long-simple.c,$(CSRC))
-endif
+# SuS getopt family
+OMIT-y += getopt.c getsubopt.c
+OMIT-y += $(if $(UCLIBC_HAS_GETOPT_LONG),,getopt_long-simple.c)
+OMIT-y += $(if $(UCLIBC_HAS_GNU_GETSUBOPT),,getsubopt-susv3.c)
endif
-ifeq ($(UCLIBC_HAS_GNU_GETSUBOPT),y)
-CSRC := $(filter-out getsubopt-susv3.c,$(CSRC))
-else
-CSRC := $(filter-out getsubopt.c,$(CSRC))
-endif
-
-ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
-CSRC := $(filter-out sleep.c,$(CSRC))
-endif
+CSRC-y := $(filter-out $(OMIT-y),$(CSRC-y))
-UNISTD_SRC := $(patsubst %.c,$(UNISTD_DIR)/%.c,$(CSRC))
-UNISTD_OBJ := $(patsubst %.c,$(UNISTD_OUT)/%.o,$(CSRC))
+UNISTD_SRC := $(patsubst %.c,$(UNISTD_DIR)/%.c,$(CSRC-y))
+UNISTD_OBJ := $(patsubst %.c,$(UNISTD_OUT)/%.o,$(CSRC-y))
libc-y += $(UNISTD_OBJ)
-objclean-y += unistd_objclean
+objclean-y += CLEAN_libc/unistd
-unistd_objclean:
- $(RM) $(UNISTD_OUT)/*.{o,os}
+CLEAN_libc/unistd:
+ $(do_rm) $(addprefix $(UNISTD_OUT)/*., o os)
diff --git a/libc/unistd/confstr.c b/libc/unistd/confstr.c
index 67a9d585a..373644265 100644
--- a/libc/unistd/confstr.c
+++ b/libc/unistd/confstr.c
@@ -13,16 +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/>. */
#include <stddef.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
-/* Experimentally off - libc_hidden_proto(memcpy) */
#define CS_PATH "/bin:/usr/bin"
@@ -43,6 +41,26 @@ size_t confstr (int name, char *buf, size_t len)
string_len = sizeof (cs_path);
}
break;
+#ifdef __UCLIBC_HAS_THREADS__
+ case _CS_GNU_LIBPTHREAD_VERSION:
+# if defined __LINUXTHREADS_OLD__
+ string = "linuxthreads-0.01";
+ string_len = sizeof("linuxthreads-x.xx");
+# elif defined __LINUXTHREADS_NEW__
+ string = "linuxthreads-0.10";
+ string_len = sizeof("linuxthreads-x.xx");
+# elif defined __UCLIBC_HAS_THREADS_NATIVE__
+# define __NPTL_VERSION ("NPTL " \
+ __stringify(__UCLIBC_MAJOR__) "." \
+ __stringify(__UCLIBC_MINOR__) "." \
+ __stringify(__UCLIBC_SUBLEVEL__))
+ string = __NPTL_VERSION;
+ string_len = sizeof(__NPTL_VERSION);
+# else
+# error unable to determine thread impl
+# endif
+ break;
+#endif
default:
__set_errno (EINVAL);
return 0;
diff --git a/libc/unistd/daemon.c b/libc/unistd/daemon.c
index d565ed41d..8fa292850 100644
--- a/libc/unistd/daemon.c
+++ b/libc/unistd/daemon.c
@@ -44,49 +44,100 @@
#include <features.h>
#include <fcntl.h>
#include <paths.h>
+#include <signal.h>
#include <unistd.h>
+#include <not-cancel.h>
+#include <errno.h>
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <sys/stat.h>
+#endif
+
+#ifdef __UCLIBC_HAS_LFS__
+#define STAT stat64
+#define FSTAT fstat64
+#else
+#define STAT stat
+#define FSTAT fstat
+#endif
#if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_UNIX98)
-libc_hidden_proto(open)
-libc_hidden_proto(close)
-libc_hidden_proto(_exit)
-libc_hidden_proto(dup2)
-libc_hidden_proto(setsid)
-libc_hidden_proto(chdir)
-libc_hidden_proto(fork)
+#ifndef __ARCH_USE_MMU__
+#include <sys/syscall.h>
+#include <sched.h>
+/* use clone() to get fork() like behavior here -- we just want to disassociate
+ * from the controlling terminal
+ */
+pid_t _fork_parent(void)
+{
+ INTERNAL_SYSCALL_DECL(err);
+ register long ret = INTERNAL_SYSCALL(clone, err, 2, CLONE_VM, 0);
+ if (ret > 0)
+ /* parent needs to die now w/out touching stack */
+ INTERNAL_SYSCALL(exit, err, 1, 0);
+ return ret;
+}
+static inline pid_t fork_parent(void)
+{
+ /* Block all signals to keep the parent from using the stack */
+ pid_t ret;
+ sigset_t new_set, old_set;
+ sigfillset(&new_set);
+ sigprocmask(SIG_BLOCK, &new_set, &old_set);
+ ret = _fork_parent();
+ sigprocmask(SIG_SETMASK, &old_set, NULL);
+ return ret;
+}
+#else
+static inline pid_t fork_parent(void)
+{
+ switch (fork()) {
+ case -1: return -1;
+ case 0: return 0;
+ default: _exit(0);
+ }
+}
+#endif
-int daemon( int nochdir, int noclose )
+int daemon(int nochdir, int noclose)
{
int fd;
- switch (fork()) {
- case -1:
- return(-1);
- case 0:
- break;
- default:
- _exit(0);
- }
+ if (fork_parent() == -1)
+ return -1;
if (setsid() == -1)
- return(-1);
-
- /* Make certain we are not a session leader, or else we
- * might reacquire a controlling terminal */
- if (fork())
- _exit(0);
+ return -1;
if (!nochdir)
chdir("/");
- if (!noclose && (fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) {
- dup2(fd, STDIN_FILENO);
- dup2(fd, STDOUT_FILENO);
- dup2(fd, STDERR_FILENO);
- if (fd > 2)
- close(fd);
+ if (!noclose)
+ {
+ struct STAT st;
+
+ if ((fd = open_not_cancel_2(_PATH_DEVNULL, O_RDWR)) != -1
+ && (__builtin_expect (FSTAT (fd, &st), 0) == 0))
+ {
+ if (__builtin_expect (S_ISCHR (st.st_mode), 1) != 0) {
+ dup2(fd, STDIN_FILENO);
+ dup2(fd, STDOUT_FILENO);
+ dup2(fd, STDERR_FILENO);
+ if (fd > 2)
+ close(fd);
+ } else {
+ /* We must set an errno value since no
+ function call actually failed. */
+ close_not_cancel_no_status (fd);
+ __set_errno (ENODEV);
+ return -1;
+ }
+ } else {
+ close_not_cancel_no_status (fd);
+ return -1;
+ }
}
- return(0);
+ return 0;
}
#endif
diff --git a/libc/unistd/exec.c b/libc/unistd/exec.c
index 9134e4370..9be856d4f 100644
--- a/libc/unistd/exec.c
+++ b/libc/unistd/exec.c
@@ -20,6 +20,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <paths.h>
#include <string.h>
#include <errno.h>
#include <stdarg.h>
@@ -27,23 +28,13 @@
#include <unistd.h>
#include <sys/mman.h>
-libc_hidden_proto(execl)
-libc_hidden_proto(execle)
-libc_hidden_proto(execlp)
-libc_hidden_proto(execv)
-libc_hidden_proto(execvp)
-/* Experimentally off - libc_hidden_proto(memcpy) */
-/* Experimentally off - libc_hidden_proto(strchr) */
-/* Experimentally off - libc_hidden_proto(strlen) */
-libc_hidden_proto(execve)
-libc_hidden_proto(mmap)
-libc_hidden_proto(munmap)
-libc_hidden_proto(getenv)
/**********************************************************************/
#define EXEC_FUNC_COMMON 0
#define EXEC_FUNC_EXECVP 1
+#define EXEC_FUNC_EXECVPE 2
+
#if defined(__ARCH_USE_MMU__)
/* We have an MMU, so use alloca() to grab space for buffers and arg lists. */
@@ -70,6 +61,7 @@ libc_hidden_proto(getenv)
* execle(a) -> execve(-)
* execv(-) -> execve(-)
* execvp(a) -> execve(-)
+ * execvpe(a) -> execve(-)
*/
# define EXEC_ALLOC_SIZE(VAR) /* nothing to do */
@@ -80,7 +72,7 @@ extern void *__exec_alloc(size_t size, int func) attribute_hidden;
# ifdef L___exec_alloc
-void attribute_hidden *__exec_alloc(size_t size, int func)
+void *__exec_alloc(size_t size, int func)
{
static void *common_cache, *execvp_cache;
static size_t common_size, execvp_size;
@@ -147,7 +139,7 @@ libc_hidden_def(execl)
/**********************************************************************/
#ifdef L_execv
-int execv(__const char *path, char *__const argv[])
+int execv(const char *path, char *const argv[])
{
return execve(path, argv, __environ);
}
@@ -231,16 +223,18 @@ libc_hidden_def(execlp)
#endif
/**********************************************************************/
-#ifdef L_execvp
+#if defined (L_execvp) || defined(L_execvpe)
-/* Experimentally off - libc_hidden_proto(strchrnul) */
/* Use a default path that matches glibc behavior, since SUSv3 says
* this is implementation-defined. The default is current working dir,
* /bin, and then /usr/bin. */
static const char default_path[] = ":/bin:/usr/bin";
-
+#if defined (L_execvp)
int execvp(const char *path, char *const argv[])
+#elif defined (L_execvpe)
+int execvpe(const char *path, char *const argv[], char *const envp[])
+#endif
{
char *buf = NULL;
char *p;
@@ -258,7 +252,11 @@ int execvp(const char *path, char *const argv[])
}
if (strchr(path, '/')) {
+#if defined (L_execvp)
execve(path, argv, __environ);
+#elif defined (L_execvpe)
+ execve(path, argv, envp);
+#endif
if (errno == ENOEXEC) {
char **nargv;
EXEC_ALLOC_SIZE(size2) /* Do NOT add a semicolon! */
@@ -267,11 +265,19 @@ int execvp(const char *path, char *const argv[])
/* Need the dimension - 1. We omit counting the trailing
* NULL but we actually omit the first entry. */
for (n=0 ; argv[n] ; n++) {}
+#if defined (L_execvp)
nargv = (char **) EXEC_ALLOC((n+2) * sizeof(char *), size2, EXEC_FUNC_EXECVP);
+#elif defined (L_execvpe)
+ nargv = (char **) EXEC_ALLOC((n+2) * sizeof(char *), size2, EXEC_FUNC_EXECVPE);
+#endif
nargv[0] = argv[0];
nargv[1] = (char *)path;
memcpy(nargv+2, argv+1, n*sizeof(char *));
- execve("/bin/sh", nargv, __environ);
+#if defined (L_execvp)
+ execve(_PATH_BSHELL, nargv, __environ);
+#elif defined (L_execvpe)
+ execve(_PATH_BSHELL, nargv, envp);
+#endif
EXEC_FREE(nargv, size2);
}
} else {
@@ -290,8 +296,11 @@ int execvp(const char *path, char *const argv[])
return -1;
}
len = (FILENAME_MAX - 1) - plen;
-
+#if defined (L_execvp)
buf = EXEC_ALLOC(FILENAME_MAX, size, EXEC_FUNC_EXECVP);
+#elif defined (L_execvpe)
+ buf = EXEC_ALLOC(FILENAME_MAX, size, EXEC_FUNC_EXECVPE);
+#endif
{
int seen_small = 0;
s0 = buf + len;
@@ -313,8 +322,11 @@ int execvp(const char *path, char *const argv[])
s[plen-1] = '/';
}
+#if defined (L_execvp)
execve(s, argv, __environ);
-
+#elif defined (L_execvpe)
+ execve(s, argv, envp);
+#endif
seen_small = 1;
if (errno == ENOEXEC) {
@@ -338,7 +350,11 @@ int execvp(const char *path, char *const argv[])
return -1;
}
+#if defined (L_execvp)
libc_hidden_def(execvp)
-
+#elif defined (L_execvpe)
+libc_hidden_def(execvpe)
#endif
+
+#endif /* #if defined (L_execvp) || defined(L_execvpe) */
/**********************************************************************/
diff --git a/libc/unistd/execvpe.c b/libc/unistd/execvpe.c
new file mode 100644
index 000000000..c3c1e43fe
--- /dev/null
+++ b/libc/unistd/execvpe.c
@@ -0,0 +1,7 @@
+/* Copyright (C) 2011-2013 Hennning Heinold <heinold@inf.fu-berlin.de>
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_execvpe
+#include "exec.c"
diff --git a/libc/unistd/fpathconf.c b/libc/unistd/fpathconf.c
index 7b0457c75..fe4bcea67 100644
--- a/libc/unistd/fpathconf.c
+++ b/libc/unistd/fpathconf.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,11 +23,7 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/statfs.h>
-//#include <sys/statvfs.h>
-//#include "linux_fsinfo.h"
-
-libc_hidden_proto(fstat)
#ifndef __USE_FILE_OFFSET64
extern int fstatfs (int __fildes, struct statfs *__buf)
@@ -43,7 +38,6 @@ extern int fstatfs (int __fildes, struct statfs *__buf)
#endif
extern __typeof(fstatfs) __libc_fstatfs;
-libc_hidden_proto(__libc_fstatfs)
/* The Linux kernel headers mention this as a kind of generic value. */
#define LINUX_LINK_MAX 127
diff --git a/libc/unistd/getlogin.c b/libc/unistd/getlogin.c
index 1998a7fc8..b855e50ac 100644
--- a/libc/unistd/getlogin.c
+++ b/libc/unistd/getlogin.c
@@ -10,9 +10,6 @@
#include <unistd.h>
#include <stdio.h>
-/* Experimentally off - libc_hidden_proto(strcpy) */
-/* Experimentally off - libc_hidden_proto(strncpy) */
-libc_hidden_proto(getenv)
/* uClibc makes it policy to not mess with the utmp file whenever
* possible, since I consider utmp a complete waste of time. Since
@@ -20,7 +17,6 @@ libc_hidden_proto(getenv)
* the user specify whatever they want via the LOGNAME environment
* variable, or we return NULL if getenv() fails to find anything */
-libc_hidden_proto(getlogin)
char * getlogin(void)
{
return (getenv("LOGNAME"));
diff --git a/libc/unistd/getopt-susv3.c b/libc/unistd/getopt-susv3.c
index c22dd9ffb..49f9626bc 100644
--- a/libc/unistd/getopt-susv3.c
+++ b/libc/unistd/getopt-susv3.c
@@ -22,16 +22,7 @@
#include <string.h>
#include <stdio.h>
#include <getopt.h>
-
-libc_hidden_proto(fprintf)
-/* Experimentally off - libc_hidden_proto(strchr) */
-
-#ifdef __UCLIBC_MJN3_ONLY__
-#warning TODO: Enable gettext awareness.
-#endif /* __UCLIBC_MJN3_ONLY__ */
-
-#undef _
-#define _(X) X
+#include <libintl.h>
#ifdef __BCC__
static const char missing[] = "option requires an argument";
@@ -46,7 +37,6 @@ int optind = 1;
int optopt = 0;
char *optarg = NULL;
-libc_hidden_proto(getopt)
int getopt(int argc, char * const argv[], const char *optstring)
{
static const char *o; /* multi opt position */
diff --git a/libc/unistd/getopt.c b/libc/unistd/getopt.c
index ac005e4f8..db5e12c59 100644
--- a/libc/unistd/getopt.c
+++ b/libc/unistd/getopt.c
@@ -17,9 +17,8 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 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 Manuel Novoa III on 1/5/01.
@@ -36,9 +35,6 @@
# include <config.h>
#endif
-#define __FORCE_GLIBC
-#include <features.h>
-
#include <stdio.h>
/* Comment out all this code if we are using the GNU C Library, and are not
@@ -62,7 +58,7 @@
/* This needs to come after some library #include
to get __GNU_LIBRARY__ defined. */
-#ifdef __GNU_LIBRARY__
+#if defined __GNU_LIBRARY__ || defined __UCLIBC__
/* Don't include stdlib.h for non-GNU C libraries because some of them
contain conflicting prototypes for getopt. */
# include <stdlib.h>
@@ -75,22 +71,12 @@
# include <unixlib.h>
#endif
-#if !defined __UCLIBC__ && !defined __UCLIBC_HAS_GETTEXT_AWARENESS__
#ifdef _LIBC
# include <libintl.h>
#else
# include "gettext.h"
# define _(msgid) gettext (msgid)
#endif
-#else
-#ifdef __UCLIBC_MJN3_ONLY__
-#warning TODO: Enable gettext awareness.
-#endif /* __UCLIBC_MJN3_ONLY__ */
-
-#undef _
-#define _(X) X
-
-#endif
/* Treat '-W foo' the same as the long option '--foo',
* disabled for the moment since it costs about 2k... */
@@ -119,14 +105,8 @@
they can distinguish the relative order of options and other arguments. */
#include <getopt.h>
-#include "getopt_int.h"
+#include <bits/getopt_int.h>
-/* Experimentally off - libc_hidden_proto(strchr) */
-/* Experimentally off - libc_hidden_proto(strcmp) */
-/* Experimentally off - libc_hidden_proto(strlen) */
-/* Experimentally off - libc_hidden_proto(strncmp) */
-libc_hidden_proto(getenv)
-libc_hidden_proto(fprintf)
/* For communication from `getopt' to the caller.
When `getopt' finds an option that takes an argument,
@@ -167,7 +147,7 @@ int optopt = '?';
static struct _getopt_data getopt_data;
-#ifndef __GNU_LIBRARY__
+#if !defined __GNU_LIBRARY__ && !defined __UCLIBC__
/* Avoid depending on library functions or files
whose names are inconsistent. */
@@ -241,7 +221,7 @@ exchange (char **argv, struct _getopt_data *d)
d->__nonoption_flags_len = d->__nonoption_flags_max_len = 0;
else
{
- memset (__mempcpy (new_str, __getopt_nonoption_flags,
+ memset (mempcpy (new_str, __getopt_nonoption_flags,
d->__nonoption_flags_max_len),
'\0', top + 1 - d->__nonoption_flags_max_len);
d->__nonoption_flags_max_len = top + 1;
@@ -347,7 +327,7 @@ _getopt_initialize (attribute_unused int argc, attribute_unused char *const *arg
if (__getopt_nonoption_flags == NULL)
d->__nonoption_flags_max_len = -1;
else
- memset (__mempcpy (__getopt_nonoption_flags, orig_str, len),
+ memset (mempcpy (__getopt_nonoption_flags, orig_str, len),
'\0', d->__nonoption_flags_max_len - len);
}
}
@@ -1180,7 +1160,9 @@ getopt (int argc, char *const *argv, const char *optstring)
(int *) 0,
0);
}
+libc_hidden_def(getopt)
+#if defined __UCLIBC_HAS_GETOPT_LONG__
int
getopt_long (int argc, char *const *argv, const char *options,
const struct option *long_options, int *opt_index)
@@ -1188,6 +1170,15 @@ getopt_long (int argc, char *const *argv, const char *options,
return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
}
+int
+_getopt_long_r (int argc, char *const *argv, const char *options,
+ const struct option *long_options, int *opt_index,
+ struct _getopt_data *d)
+{
+ return _getopt_internal_r (argc, argv, options, long_options, opt_index,
+ 0, d);
+}
+
/* Like getopt_long, but '-' as well as '--' can indicate a long option.
If an option that starts with '-' (not '--') doesn't match a long option,
but does match a short option, it is parsed as a short option
@@ -1199,5 +1190,14 @@ getopt_long_only (int argc, char *const *argv, const char *options,
{
return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
}
+#endif /* __UCLIBC_HAS_GETOPT_LONG__ */
+
+int
+_getopt_long_only_r (int argc, char *const *argv, const char *options,
+ const struct option *long_options, int *opt_index,
+ struct _getopt_data *d)
+{
+ return _getopt_internal_r (argc, argv, options, long_options, opt_index, 1, d);
+}
#endif /* Not ELIDE_CODE. */
diff --git a/libc/unistd/getopt_int.h b/libc/unistd/getopt_int.h
index a871785d1..a70fa8b92 100644
--- a/libc/unistd/getopt_int.h
+++ b/libc/unistd/getopt_int.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_INT_H
#define _GETOPT_INT_H 1
diff --git a/libc/unistd/getopt_long-simple.c b/libc/unistd/getopt_long-simple.c
index 2dae341a3..47612dfe6 100644
--- a/libc/unistd/getopt_long-simple.c
+++ b/libc/unistd/getopt_long-simple.c
@@ -8,7 +8,6 @@
#include <getopt.h>
#include <stdio.h>
-libc_hidden_proto(getopt)
static int __getopt_long(int argc, char *const *argv, const char *optstring, const struct option *longopts, int *idx, int longonly)
{
diff --git a/libc/unistd/getpass.c b/libc/unistd/getpass.c
index d1100b308..c46d3d442 100644
--- a/libc/unistd/getpass.c
+++ b/libc/unistd/getpass.c
@@ -12,30 +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 <stdio.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
+#include <malloc.h>
#if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
-/* Experimentally off - libc_hidden_proto(strlen) */
-libc_hidden_proto(tcsetattr)
-libc_hidden_proto(tcgetattr)
-libc_hidden_proto(setvbuf)
-libc_hidden_proto(fopen)
-libc_hidden_proto(fclose)
-libc_hidden_proto(fileno)
-libc_hidden_proto(fflush)
-libc_hidden_proto(fgets)
-libc_hidden_proto(fputs)
-libc_hidden_proto(fputc)
-libc_hidden_proto(putc)
-libc_hidden_proto(__fputc_unlocked)
/* It is desirable to use this bit on systems that have it.
The only bit of terminal state we want to twiddle is echoing, which is
@@ -52,23 +39,31 @@ char * getpass (const char *prompt)
FILE *in, *out;
struct termios s, t;
int tty_changed;
- static char buf[PWD_BUFFER_SIZE];
+ static char *buf = NULL;
int nread;
+ if (buf == NULL)
+ buf = (char *)__uc_malloc(PWD_BUFFER_SIZE);
+
/* Try to write to and read from the terminal if we can.
If we can't open the terminal, use stderr and stdin. */
- in = fopen ("/dev/tty", "r+");
+ out = in = fopen ("/dev/tty", "r+");
if (in == NULL)
{
in = stdin;
out = stderr;
}
else
- out = in;
+ {
+ /* Disable buffering for read/write FILE to prevent problems with
+ * fseek and buffering for read/write auto-transitioning. */
+ setvbuf(in, NULL, _IONBF, 0);
+ }
/* Turn echoing off if it is on now. */
+ tty_changed = 0;
if (tcgetattr (fileno (in), &t) == 0)
{
/* Save the old one. */
@@ -76,41 +71,28 @@ char * getpass (const char *prompt)
/* Tricky, tricky. */
t.c_lflag &= ~(ECHO|ISIG);
tty_changed = (tcsetattr (fileno (in), TCSAFLUSH|TCSASOFT, &t) == 0);
- if (in != stdin) {
- /* Disable buffering for read/write FILE to prevent problems with
- * fseek and buffering for read/write auto-transitioning. */
- setvbuf(in, NULL, _IONBF, 0);
- }
}
- else
- tty_changed = 0;
/* Write the prompt. */
fputs(prompt, out);
fflush(out);
/* Read the password. */
- fgets (buf, PWD_BUFFER_SIZE-1, in);
- if (buf != NULL)
+ if (!fgets (buf, PWD_BUFFER_SIZE, in))
+ buf[0] = '\0';
+ nread = strlen(buf);
+ if (nread > 0 && buf[nread - 1] == '\n')
+ /* Remove the newline. */
+ buf[nread - 1] = '\0';
+
+ if (tty_changed)
{
- nread = strlen(buf);
- if (nread < 0)
- buf[0] = '\0';
- else if (buf[nread - 1] == '\n')
- {
- /* Remove the newline. */
- buf[nread - 1] = '\0';
- if (tty_changed)
- /* Write the newline that was not echoed. */
- putc('\n', out);
- }
+ /* Write the newline that was not echoed. */
+ putc('\n', out);
+ /* Restore the original setting. */
+ (void) tcsetattr (fileno (in), TCSAFLUSH|TCSASOFT, &s);
}
- /* Restore the original setting. */
- if (tty_changed) {
- (void) tcsetattr (fileno (in), TCSAFLUSH|TCSASOFT, &s);
- }
-
if (in != stdin)
/* We opened the terminal; now close it. */
fclose (in);
diff --git a/libc/unistd/getsubopt-susv3.c b/libc/unistd/getsubopt-susv3.c
index 10c97ca9a..9ff33ef11 100644
--- a/libc/unistd/getsubopt-susv3.c
+++ b/libc/unistd/getsubopt-susv3.c
@@ -7,9 +7,6 @@
#include <stdlib.h>
#include <string.h>
-/* Experimentally off - libc_hidden_proto(strchr) */
-/* Experimentally off - libc_hidden_proto(strlen) */
-/* Experimentally off - libc_hidden_proto(strncmp) */
int getsubopt(char **opt, char *const *keys, char **val)
{
diff --git a/libc/unistd/getsubopt.c b/libc/unistd/getsubopt.c
index 301410232..6e4659523 100644
--- a/libc/unistd/getsubopt.c
+++ b/libc/unistd/getsubopt.c
@@ -14,16 +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 <stdlib.h>
#include <string.h>
-/* Experimentally off - libc_hidden_proto(memchr) */
-/* Experimentally off - libc_hidden_proto(strncmp) */
-/* Experimentally off - libc_hidden_proto(strchrnul) */
/* Parse comma separated suboption from *OPTIONP and match against
strings in TOKENS. If found return index and set *VALUEP to
diff --git a/libc/unistd/pathconf.c b/libc/unistd/pathconf.c
index 7f7efbb7f..de78a83e9 100644
--- a/libc/unistd/pathconf.c
+++ b/libc/unistd/pathconf.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/>. */
/* pathconf -- adjusted for busybox */
@@ -29,11 +28,8 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/statfs.h>
-//#include <sys/statvfs.h>
extern __typeof(statfs) __libc_statfs;
-libc_hidden_proto(__libc_statfs)
-libc_hidden_proto(stat)
/* The Linux kernel headers mention this as a kind of generic value. */
diff --git a/libc/unistd/sleep.c b/libc/unistd/sleep.c
index 435d105c5..9d50ee163 100644
--- a/libc/unistd/sleep.c
+++ b/libc/unistd/sleep.c
@@ -15,27 +15,62 @@
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 <errno.h>
#include <time.h>
#include <signal.h>
#include <unistd.h>
-libc_hidden_proto(sleep)
-
-libc_hidden_proto(sigaction)
-libc_hidden_proto(sigprocmask)
/* version perusing nanosleep */
#if defined __UCLIBC_HAS_REALTIME__
-//libc_hidden_proto(__sigaddset)
-//libc_hidden_proto(__sigemptyset)
-//libc_hidden_proto(__sigismember)
-/*libc_hidden_proto(nanosleep) need the reloc for cancellation*/
-#if 0
+/* I am unable to reproduce alleged "Linux quirk".
+ * I used the following test program:
+#include <unistd.h>
+#include <time.h>
+#include <signal.h>
+static void dummy(int sig) {}
+int main() {
+ struct timespec t = { 2, 0 };
+ if (fork() == 0) {
+ sleep(1);
+ return 0;
+ }
+ signal(SIGCHLD, SIG_DFL); //
+ signal(SIGCHLD, dummy); // Pick one
+ signal(SIGCHLD, SIG_IGN); //
+ nanosleep(&t, &t);
+ return 0;
+}
+ * Testing on 2.4.20 and on 2.6.35-rc4:
+ * With SIG_DFL, nanosleep is not interrupted by SIGCHLD. Ok.
+ * With dummy handler, nanosleep is interrupted by SIGCHLD. Ok.
+ * With SIG_IGN, nanosleep is NOT interrupted by SIGCHLD.
+ * It looks like sleep's workaround for SIG_IGN is no longer needed?
+ * The only emails I can find are from 1998 (!):
+ * ----------
+ * Subject: Re: sleep ignore sigchld
+ * From: Linus Torvalds <torvalds@transmeta.com>
+ * Date: Mon, 16 Nov 1998 11:02:15 -0800 (PST)
+ *
+ * On Mon, 16 Nov 1998, H. J. Lu wrote:
+ * > That is a kernel bug. SIGCHLD is a special one. Usually it cannot
+ * > be ignored. [snip...]
+ *
+ * No can do.
+ *
+ * "nanosleep()" is implemented in a bad way that makes it impossible to
+ * restart it cleanly. It was done that way because glibc wanted it that way,
+ * not because it's a good idea. [snip...]
+ * ----------
+ * I assume that in the passed twelve+ years, nanosleep got fixed,
+ * but the hack in sleep to work around broken nanosleep was never removed.
+ */
+
+# if 0
+
/* This is a quick and dirty, but not 100% compliant with
* the stupid SysV SIGCHLD vs. SIG_IGN behaviour. It is
* fine unless you are messing with SIGCHLD... */
@@ -48,7 +83,7 @@ unsigned int sleep (unsigned int sec)
return res;
}
-#else
+# else
/* We are going to use the `nanosleep' syscall of the kernel. But the
kernel does not implement the sstupid SysV SIGCHLD vs. SIG_IGN
@@ -56,69 +91,55 @@ unsigned int sleep (unsigned int sec)
unsigned int sleep (unsigned int seconds)
{
struct timespec ts = { .tv_sec = (long int) seconds, .tv_nsec = 0 };
- sigset_t set, oset;
+ sigset_t set;
+ struct sigaction oact;
unsigned int result;
/* This is not necessary but some buggy programs depend on this. */
- if (seconds == 0)
+ if (seconds == 0) {
+# ifdef CANCELLATION_P
+ int cancelhandling;
+ CANCELLATION_P (THREAD_SELF);
+# endif
return 0;
+ }
/* Linux will wake up the system call, nanosleep, when SIGCHLD
arrives even if SIGCHLD is ignored. We have to deal with it
- in libc. We block SIGCHLD first. */
- if (__sigemptyset (&set) < 0
- || __sigaddset (&set, SIGCHLD) < 0
- || sigprocmask (SIG_BLOCK, &set, &oset))
- return -1;
-
- /* If SIGCHLD is already blocked, we don't have to do anything. */
- if (!__sigismember (&oset, SIGCHLD))
- {
- int saved_errno;
- struct sigaction oact;
-
- if (__sigemptyset (&set) < 0 || __sigaddset (&set, SIGCHLD) < 0)
- return -1;
-
- /* We get the signal handler for SIGCHLD. */
- if (sigaction (SIGCHLD, (struct sigaction *) NULL, &oact) < 0)
- {
- saved_errno = errno;
- /* Restore the original signal mask. */
- (void) sigprocmask (SIG_SETMASK, &oset, (sigset_t *) NULL);
- __set_errno (saved_errno);
- return -1;
- }
-
- if (oact.sa_handler == SIG_IGN)
- {
- /* We should leave SIGCHLD blocked. */
- result = nanosleep (&ts, &ts);
-
- saved_errno = errno;
- /* Restore the original signal mask. */
- (void) sigprocmask (SIG_SETMASK, &oset, (sigset_t *) NULL);
- __set_errno (saved_errno);
- }
- else
- {
- /* We should unblock SIGCHLD. Restore the original signal mask. */
- (void) sigprocmask (SIG_SETMASK, &oset, (sigset_t *) NULL);
- result = nanosleep (&ts, &ts);
- }
+ in libc. */
+
+ __sigemptyset (&set);
+ __sigaddset (&set, SIGCHLD);
+
+ /* Is SIGCHLD set to SIG_IGN? */
+ sigaction (SIGCHLD, NULL, &oact); /* never fails */
+ if (oact.sa_handler == SIG_IGN) {
+ /* Yes. Block SIGCHLD, save old mask. */
+ sigprocmask (SIG_BLOCK, &set, &set); /* never fails */
}
- else
- result = nanosleep (&ts, &ts);
- if (result != 0)
- /* Round remaining time. */
+ /* Run nanosleep, with SIGCHLD blocked if SIGCHLD is SIG_IGNed. */
+ result = nanosleep (&ts, &ts);
+ if (result != 0) {
+ /* Got EINTR. Return remaining time. */
result = (unsigned int) ts.tv_sec + (ts.tv_nsec >= 500000000L);
+ }
+
+ if (!__sigismember (&set, SIGCHLD)) {
+ /* We did block SIGCHLD, and old mask had no SIGCHLD bit.
+ IOW: we need to unblock SIGCHLD now. Do it. */
+ /* this sigprocmask call never fails, thus never updates errno,
+ and therefore we don't need to save/restore it. */
+ sigprocmask (SIG_SETMASK, &set, NULL); /* never fails */
+ }
return result;
}
-#endif
+
+# endif
+
#else /* __UCLIBC_HAS_REALTIME__ */
-libc_hidden_proto(sigaction)
+
/* no nanosleep, use signals and alarm() */
static void sleep_alarm_handler(int attribute_unused sig)
{
@@ -136,29 +157,27 @@ unsigned int sleep (unsigned int seconds)
return 0;
/* block SIGALRM */
- if (__sigemptyset (&set) < 0
- || __sigaddset (&set, SIGALRM) < 0
- || sigprocmask (SIG_BLOCK, &set, &oset))
- return seconds;
+ __sigemptyset (&set);
+ __sigaddset (&set, SIGALRM);
+ sigprocmask (SIG_BLOCK, &set, &oset); /* can't fail */
act.sa_handler = sleep_alarm_handler;
act.sa_flags = 0;
act.sa_mask = oset;
- if (sigaction(SIGALRM, &act, &oact) < 0)
- return seconds;
+ sigaction(SIGALRM, &act, &oact); /* never fails */
before = time(NULL);
remaining = alarm(seconds);
if (remaining && remaining > seconds) {
/* restore user's alarm */
- (void) sigaction(SIGALRM, &oact, (struct sigaction *) NULL);
+ sigaction(SIGALRM, &oact, NULL);
alarm(remaining); /* restore old alarm */
sigsuspend(&oset);
after = time(NULL);
} else {
sigsuspend (&oset);
after = time(NULL);
- (void) sigaction (SIGALRM, &oact, NULL);
+ sigaction (SIGALRM, &oact, NULL);
}
result = after - before;
alarm(remaining > result ? remaining - result : 0);
@@ -168,5 +187,7 @@ unsigned int sleep (unsigned int seconds)
return result > seconds ? 0 : seconds - result;
}
+
#endif /* __UCLIBC_HAS_REALTIME__ */
+
libc_hidden_def(sleep)
diff --git a/libc/unistd/sysconf.c b/libc/unistd/sysconf.c
index 549c13ca6..503b39585 100644
--- a/libc/unistd/sysconf.c
+++ b/libc/unistd/sysconf.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1991, 93, 95, 96, 97, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1991,1993,1995-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
@@ -13,11 +14,11 @@
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 _XOPEN_SOURCE 500
#include <features.h>
+#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <grp.h>
@@ -30,14 +31,87 @@
#include <sys/syscall.h>
#include <sys/sysinfo.h>
#include <sys/types.h>
+#include <sys/param.h>
#ifdef __UCLIBC_HAS_REGEX__
#include <regex.h>
#endif
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <sysdep.h>
+#endif
+#include <sys/resource.h>
+#include <string.h>
+#include <dirent.h>
+#include "internal/parse_config.h"
+
+static int nprocessors_onln(void)
+{
+ char **l = NULL;
+ parser_t *p = config_open("/proc/stat");
+ int ret = 0;
+
+ if (p) {
+ while (config_read(p, &l, 2, 1, " ", 0))
+ if (l[0][0] == 'c'
+ && l[0][1] == 'p'
+ && l[0][2] == 'u'
+ && isdigit(l[0][3]))
+ ++ret;
+ } else if ((p = config_open("/proc/cpuinfo"))) {
+#if defined __sparc__
+ while (config_read(p, &l, 2, 2, "\0:", PARSE_NORMAL))
+ if (strncmp("ncpus active", l[0], 12) == 0) {
+ ret = atoi(l[1]);
+ break;
+ }
+#else
+ while (config_read(p, &l, 2, 2, "\0:\t", PARSE_NORMAL))
+ if (strcmp("processor", l[0]) == 0)
+ ++ret;
+#endif
+ }
+ config_close(p);
+ return ret != 0 ? ret : 1;
+}
-libc_hidden_proto(sysconf)
+#if defined __UCLIBC__ && !defined __UCLIBC_HAS_LFS__
+# define readdir64 readdir
+# define dirent64 dirent
+#endif
+static int nprocessors_conf(void)
+{
+ int ret = 0;
+ DIR *dir = opendir("/sys/devices/system/cpu");
+
+ if (dir) {
+ struct dirent64 *dp;
+
+ while ((dp = readdir64(dir))) {
+ if (dp->d_type == DT_DIR
+ && dp->d_name[0] == 'c'
+ && dp->d_name[1] == 'p'
+ && dp->d_name[2] == 'u'
+ && isdigit(dp->d_name[3]))
+ ++ret;
+ }
+ closedir(dir);
+ } else
+ {
+#if defined __sparc__
+ char **l = NULL;
+ parser_t *p = config_open("/proc/stat");
+ while (config_read(p, &l, 2, 2, "\0:", PARSE_NORMAL))
+ if (strncmp("ncpus probed", l[0], 13) == 0) {
+ ret = atoi(l[1]);
+ break;
+ }
+ config_close(p);
+#else
+ ret = nprocessors_onln();
+#endif
+ }
+ return ret != 0 ? ret : 1;
+}
-libc_hidden_proto(getpagesize)
-libc_hidden_proto(getdtablesize)
#ifndef __UCLIBC_CLK_TCK_CONST
#error __UCLIBC_CLK_TCK_CONST not defined!
@@ -73,9 +147,15 @@ libc_hidden_proto(getdtablesize)
#define RETURN_FUNCTION(f) return f;
#endif /* _UCLIBC_GENERATE_SYSCONF_ARCH */
+/* Legacy value of ARG_MAX. The macro is now not defined since the
+ actual value varies based on the stack size. */
+#define legacy_ARG_MAX 131072
+
/* Get the value of the system variable NAME. */
long int sysconf(int name)
{
+ struct rlimit rlimit;
+
switch (name)
{
default:
@@ -83,10 +163,13 @@ long int sysconf(int name)
return -1;
case _SC_ARG_MAX:
-#ifdef ARG_MAX
+ /* Use getrlimit to get the stack limit. */
+ if (getrlimit (RLIMIT_STACK, &rlimit) == 0)
+ return MAX (legacy_ARG_MAX, rlimit.rlim_cur / 4);
+#if defined ARG_MAX
return ARG_MAX;
#else
- RETURN_NEG_1;
+ return legacy_ARG_MAX;
#endif
case _SC_CHILD_MAX:
@@ -658,20 +741,10 @@ long int sysconf(int name)
#endif
case _SC_NPROCESSORS_CONF:
-#if 0
- RETURN_FUNCTION(get_nprocs_conf());
-#else
- /* this is a hack. for now always claim we have exactly one cpu */
- return 1;
-#endif
+ RETURN_FUNCTION(nprocessors_conf());
case _SC_NPROCESSORS_ONLN:
-#if 0
- RETURN_FUNCTION(get_nprocs());
-#else
- /* this is a hack. for now always claim we have exactly one cpu */
- return 1;
-#endif
+ RETURN_FUNCTION(nprocessors_onln());
case _SC_PHYS_PAGES:
#if 0
@@ -866,6 +939,30 @@ long int sysconf(int name)
#else
RETURN_NEG_1;
#endif
+ case _SC_V7_ILP32_OFF32:
+#ifdef _POSIX_V7_ILP32_OFF32
+ return _POSIX_V7_ILP32_OFF32;
+#else
+ RETURN_NEG_1;
+#endif
+ case _SC_V7_ILP32_OFFBIG:
+#ifdef _POSIX_V7_ILP32_OFFBIG
+ return _POSIX_V7_ILP32_OFFBIG;
+#else
+ RETURN_NEG_1;
+#endif
+ case _SC_V7_LP64_OFF64:
+#ifdef _POSIX_V7_LP64_OFF64
+ return _POSIX_V7_LP64_OFF64;
+#else
+ RETURN_NEG_1;
+#endif
+ case _SC_V7_LPBIG_OFFBIG:
+#ifdef _POSIX_V7_LPBIG_OFFBIG
+ return _POSIX_V7_LPBIG_OFFBIG;
+#else
+ RETURN_NEG_1;
+#endif
case _SC_XOPEN_LEGACY:
return _XOPEN_LEGACY;
@@ -885,12 +982,19 @@ long int sysconf(int name)
case _SC_MONOTONIC_CLOCK:
#if defined __UCLIBC_HAS_REALTIME__ && defined __NR_clock_getres
- /* Check using the clock_getres system call. */
if (clock_getres(CLOCK_MONOTONIC, NULL) >= 0)
return _POSIX_VERSION;
#endif
+ RETURN_NEG_1;
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ case _SC_THREAD_CPUTIME:
+# if _POSIX_THREAD_CPUTIME > 0
+ return _POSIX_THREAD_CPUTIME;
+# else
RETURN_NEG_1;
+# endif
+#endif
}
}
libc_hidden_def(sysconf)
diff --git a/libc/unistd/ualarm.c b/libc/unistd/ualarm.c
index 07bea2a50..82eb972b2 100644
--- a/libc/unistd/ualarm.c
+++ b/libc/unistd/ualarm.c
@@ -9,7 +9,6 @@
#include <sys/types.h>
#include <unistd.h>
-libc_hidden_proto(setitimer)
useconds_t ualarm(useconds_t value, useconds_t interval)
{
diff --git a/libc/unistd/usershell.c b/libc/unistd/usershell.c
index 1bf143daf..261c1c10c 100644
--- a/libc/unistd/usershell.c
+++ b/libc/unistd/usershell.c
@@ -1,146 +1,78 @@
-/*
- * Copyright (c) 1985, 1993
- * The Regents of the University of California. All rights reserved.
+/* setusershell(), getusershell(), endusershell() for uClibc.
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
+ * Copyright (C) 2010 Bernhard Reutner-Fischer <uclibc@uclibc.org>
*
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This version has been hevily modified for use with uClibc
- * November 2002, Erik Andersen <andersen@codepoet.org>
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in
+ * this tarball.
+ */
+/* My manpage reads:
+ * The getusershell() function returns the next line from the file
+ * /etc/shells, opening the file if necessary. The line should contain
+ * the pathname of a valid user shell. If /etc/shells does not exist
+ * or is unreadable, getusershell() behaves as if /bin/sh and /bin/csh
+ * were listed in the file.
+ * The getusershell() function returns a NULL pointer on end-of-file.
*/
-
-#include <sys/param.h>
-#include <sys/file.h>
-#include <sys/stat.h>
-#include <stdio.h>
-#include <stdio_ext.h>
-#include <ctype.h>
-#include <stdlib.h>
#include <unistd.h>
+#include <stdlib.h>
#include <paths.h>
+#include <string.h>
+#include "internal/parse_config.h"
#if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_UNIX98)
-libc_hidden_proto(fstat)
-libc_hidden_proto(fopen)
-libc_hidden_proto(fclose)
-libc_hidden_proto(__fsetlocking)
-libc_hidden_proto(fileno)
-libc_hidden_proto(fgets_unlocked)
-#ifdef __UCLIBC_HAS_XLOCALE__
-libc_hidden_proto(__ctype_b_loc)
-#elif defined __UCLIBC_HAS_CTYPE_TABLES__
-libc_hidden_proto(__ctype_b)
-#endif
-
-/*
- * Local shells should NOT be added here. They should be added in
- * /etc/shells.
- */
-
-static const char * const validsh[] = { _PATH_BSHELL, _PATH_CSHELL, NULL };
-static char **curshell, **shells, *strings;
-static char **initshells __P((void));
-
-/*
- * Get a list of shells from _PATH_SHELLS, if it exists.
- */
-char * getusershell(void)
-{
- char *ret;
-
- if (curshell == NULL)
- curshell = initshells();
- ret = *curshell;
- if (ret != NULL)
- curshell++;
- return (ret);
-}
-
-static void __free_initshell_memory(void)
-{
- free(shells);
- shells = NULL;
- free(strings);
- strings = NULL;
-}
+static const char * const defaultsh[] = { _PATH_BSHELL, _PATH_CSHELL, NULL};
+static char *shellb, **shells;
+static parser_t *shellp;
void endusershell(void)
{
- __free_initshell_memory();
- curshell = NULL;
+ if (shellp) {
+ shells = (char**) shellb;
+ while (shells && *shells) {
+ char*xxx = *shells++;
+ free(xxx);
+ }
+ config_close(shellp);
+ shellp = NULL;
+ }
+ free(shellb);
+ shellb = NULL;
+ shells = NULL;
}
+libc_hidden_def(endusershell)
void setusershell(void)
{
- curshell = initshells();
-}
+ endusershell();
+ shellp = config_open(_PATH_SHELLS);
+ if (shellp == NULL)
+ shells = (char **)defaultsh;
+ else {
+ char **shell = NULL;
+ int pos = 0;
-static char ** initshells(void)
-{
- register char **sp, *cp;
- register FILE *fp;
- struct stat statb;
- int flen;
-
- __free_initshell_memory();
+ while (config_read(shellp, &shell, 1, 1, "# \t", PARSE_NORMAL))
+ {
+ shellb = realloc(shellb, (pos + 2) * sizeof(char*));
+ shells = (char**) shellb + pos++;
+ *shells++ = strdup(*shell);
+ *shells = NULL;
- if ((fp = fopen(_PATH_SHELLS, "r")) == NULL)
- return (char **) validsh;
- if (fstat(fileno(fp), &statb) == -1) {
- goto cleanup;
- }
- if ((strings = malloc((unsigned)statb.st_size + 1)) == NULL) {
- goto cleanup;
- }
- if ((shells = calloc((unsigned)statb.st_size / 3, sizeof (char *))) == NULL) {
- goto cleanup;
- }
- /* No threads using this stream. */
-#ifdef __UCLIBC_HAS_THREADS__
- __fsetlocking (fp, FSETLOCKING_BYCALLER);
-#endif
- sp = shells;
- cp = strings;
- flen = statb.st_size;
- while (fgets_unlocked(cp, flen - (cp - strings), fp) != NULL) {
- while (*cp != '#' && *cp != '/' && *cp != '\0')
- cp++;
- if (*cp == '#' || *cp == '\0')
- continue;
- *sp++ = cp;
- while (!isspace(*cp) && *cp != '#' && *cp != '\0')
- cp++;
- *cp++ = '\0';
- }
- *sp = NULL;
- fclose(fp);
- return (shells);
+ }
+ shells = (char **)shellb;
+ }
+}
+libc_hidden_def(setusershell)
-cleanup:
- __free_initshell_memory();
- fclose(fp);
- return (char **) validsh;
+char *getusershell(void)
+{
+ char *sh;
+ if (shells == NULL)
+ setusershell();
+ sh = *shells;
+ if (sh)
+ shells++;
+ return sh;
}
#endif
diff --git a/libc/unistd/usleep.c b/libc/unistd/usleep.c
index 8a27f900a..8d01703ec 100644
--- a/libc/unistd/usleep.c
+++ b/libc/unistd/usleep.c
@@ -11,24 +11,22 @@
#if defined __USE_BSD || defined __USE_POSIX98
#if defined __UCLIBC_HAS_REALTIME__
-/*libc_hidden_proto(nanosleep) need the reloc for cancellation*/
int usleep (__useconds_t usec)
{
- const struct timespec ts = {
- .tv_sec = (long int) (usec / 1000000),
- .tv_nsec = (long int) (usec % 1000000) * 1000ul
- };
- return(nanosleep(&ts, NULL));
+ const struct timespec ts = {
+ .tv_sec = (long int) (usec / 1000000),
+ .tv_nsec = (long int) (usec % 1000000) * 1000ul
+ };
+ return nanosleep(&ts, NULL);
}
#else /* __UCLIBC_HAS_REALTIME__ */
-libc_hidden_proto(select)
int usleep (__useconds_t usec)
{
struct timeval tv;
- tv.tv_sec = 0;
- tv.tv_usec = usec;
+ tv.tv_sec = (long int) (usec / 1000000);
+ tv.tv_usec = (long int) (usec % 1000000);
return select(0, NULL, NULL, NULL, &tv);
}
#endif /* __UCLIBC_HAS_REALTIME__ */
diff --git a/libcrypt/Makefile.in b/libcrypt/Makefile.in
index a74e4ec0c..94753f4ad 100644
--- a/libcrypt/Makefile.in
+++ b/libcrypt/Makefile.in
@@ -1,12 +1,15 @@
# 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.
#
+subdirs += libcrypt
+
CFLAGS-libcrypt := -DNOT_IN_libc -DIS_IN_libcrypt $(SSP_ALL_CFLAGS)
+LDFLAGS-$(UCLIBC_FORMAT_DSBT_ELF)-libcrypt.so := -Wl,--dsbt-index=4
LDFLAGS-libcrypt.so := $(LDFLAGS)
LIBS-libcrypt.so := $(LIBS)
@@ -16,14 +19,13 @@ libcrypt_FULL_NAME := libcrypt-$(VERSION).so
libcrypt_DIR := $(top_srcdir)libcrypt
libcrypt_OUT := $(top_builddir)libcrypt
-ifeq ($(UCLIBC_HAS_CRYPT_IMPL),y)
-CSRC := crypt.c des.c md5.c
-endif
-ifeq ($(UCLIBC_HAS_CRYPT_STUB),y)
-CSRC := crypt_stub.c
-endif
+libcrypt_SRC-y :=
+libcrypt_SRC-$(UCLIBC_HAS_CRYPT_IMPL) += crypt.c des.c md5.c
+libcrypt_SRC-$(UCLIBC_HAS_SHA256_CRYPT_IMPL) += sha256.c sha256-crypt.c
+libcrypt_SRC-$(UCLIBC_HAS_SHA512_CRYPT_IMPL) += sha512.c sha512-crypt.c
+libcrypt_SRC-$(UCLIBC_HAS_CRYPT_STUB) += crypt_stub.c
-libcrypt_SRC := $(addprefix $(libcrypt_DIR)/,$(CSRC))
+libcrypt_SRC := $(addprefix $(libcrypt_DIR)/,$(libcrypt_SRC-y))
libcrypt_OBJ := $(patsubst $(libcrypt_DIR)/%.c,$(libcrypt_OUT)/%.o,$(libcrypt_SRC))
ifeq ($(DOPIC),y)
@@ -33,11 +35,9 @@ libcrypt-a-y := $(libcrypt_OBJ)
endif
libcrypt-so-y := $(libcrypt_OBJ:.o=.os)
-ifeq ($(UCLIBC_HAS_CRYPT),y)
-lib-a-y += $(top_builddir)lib/libcrypt.a
-lib-so-y += $(top_builddir)lib/libcrypt.so
-endif
-objclean-y += libcrypt_clean
+lib-a-$(UCLIBC_HAS_CRYPT) += $(top_builddir)lib/libcrypt.a
+lib-so-$(UCLIBC_HAS_CRYPT) += $(top_builddir)lib/libcrypt.so
+objclean-y += CLEAN_libcrypt
ifeq ($(DOMULTI),n)
ifeq ($(DOPIC),y)
@@ -45,10 +45,10 @@ $(top_builddir)lib/libcrypt.so: $(top_builddir)lib/libcrypt.a $(libc.depend)
else
$(top_builddir)lib/libcrypt.so: $(libcrypt_OUT)/libcrypt_so.a $(libc.depend)
endif
- $(call link.so,$(libcrypt_FULL_NAME),$(MAJOR_VERSION))
+ $(call link.so,$(libcrypt_FULL_NAME),$(ABI_VERSION))
else
$(top_builddir)lib/libcrypt.so: $(libcrypt_OUT)/libcrypt.oS | $(libc.depend)
- $(call linkm.so,$(libcrypt_FULL_NAME),$(MAJOR_VERSION))
+ $(call linkm.so,$(libcrypt_FULL_NAME),$(ABI_VERSION))
endif
$(libcrypt_OUT)/libcrypt_so.a: $(libcrypt-so-y)
@@ -64,5 +64,5 @@ $(top_builddir)lib/libcrypt.a: $(libcrypt-a-y)
$(Q)$(RM) $@
$(do_ar)
-libcrypt_clean:
- $(RM) $(libcrypt_OUT)/*.{o,os,oS,a}
+CLEAN_libcrypt:
+ $(do_rm) $(addprefix $(libcrypt_OUT)/*., o os oS a)
diff --git a/libcrypt/crypt.c b/libcrypt/crypt.c
index 8b361d393..10061a073 100644
--- a/libcrypt/crypt.c
+++ b/libcrypt/crypt.c
@@ -5,17 +5,30 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define __FORCE_GLIBC
-#include <crypt.h>
#include <unistd.h>
+#include <crypt.h>
#include "libcrypt.h"
char *crypt(const char *key, const char *salt)
{
- /* First, check if we are supposed to be using the MD5 replacement
- * instead of DES... */
- if (salt[0]=='$' && salt[1]=='1' && salt[2]=='$')
- return __md5_crypt((unsigned char*)key, (unsigned char*)salt);
- else
- return __des_crypt((unsigned char*)key, (unsigned char*)salt);
+ const unsigned char *ukey = (const unsigned char *)key;
+ const unsigned char *usalt = (const unsigned char *)salt;
+
+ if (salt[0] == '$') {
+ if (salt[1] && salt[2] == '$') { /* no blowfish '2X' here ATM */
+ if (*++salt == '1')
+ return __md5_crypt(ukey, usalt);
+#ifdef __UCLIBC_HAS_SHA256_CRYPT_IMPL__
+ else if (*salt == '5')
+ return __sha256_crypt(ukey, usalt);
+#endif
+#ifdef __UCLIBC_HAS_SHA512_CRYPT_IMPL__
+ else if (*salt == '6')
+ return __sha512_crypt(ukey, usalt);
+#endif
+ }
+ /* __set_errno(EINVAL);*/ /* ENOSYS might be misleading */
+ return NULL;
+ }
+ return __des_crypt(ukey, usalt);
}
diff --git a/libcrypt/crypt_stub.c b/libcrypt/crypt_stub.c
index 76645a046..580df6c8b 100644
--- a/libcrypt/crypt_stub.c
+++ b/libcrypt/crypt_stub.c
@@ -5,7 +5,6 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define __FORCE_GLIBC
#include <crypt.h>
#include <unistd.h>
#include "libcrypt.h"
diff --git a/libcrypt/des.c b/libcrypt/des.c
index eb1e13fec..64a977c3b 100644
--- a/libcrypt/des.c
+++ b/libcrypt/des.c
@@ -56,7 +56,6 @@
* alignment).
*/
-#define __FORCE_GLIBC
#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/param.h>
@@ -454,33 +453,26 @@ des_setkey(const char *key)
static int
do_des( u_int32_t l_in, u_int32_t r_in, u_int32_t *l_out, u_int32_t *r_out, int count)
{
- /*
- * l_in, r_in, l_out, and r_out are in pseudo-"big-endian" format.
- */
+ /* l_in, r_in, l_out, and r_out are in pseudo-"big-endian" format. */
u_int32_t l, r, *kl, *kr, *kl1, *kr1;
u_int32_t f, r48l, r48r;
int round;
if (count == 0) {
- return(1);
- } else if (count > 0) {
- /*
- * Encrypting
- */
+ return 1;
+ }
+ if (count > 0) {
+ /* Encrypting */
kl1 = en_keysl;
kr1 = en_keysr;
} else {
- /*
- * Decrypting
- */
+ /* Decrypting */
count = -count;
kl1 = de_keysl;
kr1 = de_keysr;
}
- /*
- * Do initial permutation (IP).
- */
+ /* Do initial permutation (IP). */
l = ip_maskl[0][l_in >> 24]
| ip_maskl[1][(l_in >> 16) & 0xff]
| ip_maskl[2][(l_in >> 8) & 0xff]
@@ -499,22 +491,17 @@ do_des( u_int32_t l_in, u_int32_t r_in, u_int32_t *l_out, u_int32_t *r_out, int
| ip_maskr[7][r_in & 0xff];
while (count--) {
- /*
- * Do each round.
- */
+ /* Do each round. */
kl = kl1;
kr = kr1;
round = 16;
- while (round--) {
- /*
- * Expand R to 48 bits (simulate the E-box).
- */
+ do {
+ /* Expand R to 48 bits (simulate the E-box). */
r48l = ((r & 0x00000001) << 23)
| ((r & 0xf8000000) >> 9)
| ((r & 0x1f800000) >> 11)
| ((r & 0x01f80000) >> 13)
| ((r & 0x001f8000) >> 15);
-
r48r = ((r & 0x0001f800) << 7)
| ((r & 0x00001f80) << 5)
| ((r & 0x000001f8) << 3)
@@ -535,19 +522,15 @@ do_des( u_int32_t l_in, u_int32_t r_in, u_int32_t *l_out, u_int32_t *r_out, int
| psbox[1][m_sbox[1][r48l & 0xfff]]
| psbox[2][m_sbox[2][r48r >> 12]]
| psbox[3][m_sbox[3][r48r & 0xfff]];
- /*
- * Now that we've permuted things, complete f().
- */
+ /* Now that we've permuted things, complete f(). */
f ^= l;
l = r;
r = f;
- }
+ } while (--round);
r = l;
l = f;
}
- /*
- * Do final permutation (inverse of IP).
- */
+ /* Do final permutation (inverse of IP). */
*l_out = fp_maskl[0][l >> 24]
| fp_maskl[1][(l >> 16) & 0xff]
| fp_maskl[2][(l >> 8) & 0xff]
diff --git a/libcrypt/libcrypt.h b/libcrypt/libcrypt.h
index 11866200c..67733d17f 100644
--- a/libcrypt/libcrypt.h
+++ b/libcrypt/libcrypt.h
@@ -9,8 +9,13 @@
#define __LIBCRYPT_H__
extern char *__md5_crypt(const unsigned char *pw, const unsigned char *salt) attribute_hidden;
+extern char *__sha256_crypt(const unsigned char *pw, const unsigned char *salt) attribute_hidden;
+extern char *__sha512_crypt(const unsigned char *pw, const unsigned char *salt) attribute_hidden;
extern char *__des_crypt(const unsigned char *pw, const unsigned char *salt) attribute_hidden;
+extern char *__sha256_crypt_r (const char *key, const char *salt, char *buffer, int buflen) attribute_hidden;
+extern char *__sha512_crypt_r (const char *key, const char *salt, char *buffer, int buflen) attribute_hidden;
+
/* shut up gcc-4.x signed warnings */
#define strcpy(dst,src) strcpy((char*)dst,(char*)src)
#define strlen(s) strlen((char*)s)
diff --git a/libcrypt/md5.c b/libcrypt/md5.c
index ab5548c0a..1af11ed83 100644
--- a/libcrypt/md5.c
+++ b/libcrypt/md5.c
@@ -531,7 +531,8 @@ static void __md5_to64( char *s, unsigned long v, int n)
char *__md5_crypt(const unsigned char *pw, const unsigned char *salt)
{
/* Static stuff */
- static char passwd[120];
+ /* "$1$" + salt_up_to_8_chars + "$" + 22_bytes_of_hash + NUL */
+ static char passwd[3 + 8 + 1 + 22 + 1];
const unsigned char *sp, *ep;
char *p;
@@ -584,9 +585,9 @@ char *__md5_crypt(const unsigned char *pw, const unsigned char *salt)
}
/* Now make the output string */
- strcpy(passwd,__md5__magic);
- strncat(passwd,sp,sl);
- strcat(passwd,"$");
+ strcpy(passwd,__md5__magic); /* 3 bytes */
+ strncpy(passwd+MD5_MAGIC_LEN,(char*)sp,sl); /* 8 or less */
+ passwd[MD5_MAGIC_LEN+sl] = '$';
__md5_Final(final,&ctx);
@@ -615,15 +616,17 @@ char *__md5_crypt(const unsigned char *pw, const unsigned char *salt)
__md5_Final(final,&ctx1);
}
- p = passwd + strlen(passwd);
-
+ /* Add 5*4+2 = 22 bytes of hash, + NUL byte. */
+ p = passwd + MD5_MAGIC_LEN + sl + 1;
final[16] = final[5];
for ( i=0 ; i < 5 ; i++ ) {
l = (final[i]<<16) | (final[i+6]<<8) | final[i+12];
- __md5_to64(p,l,4); p += 4;
+ __md5_to64(p,l,4);
+ p += 4;
}
l = final[11];
- __md5_to64(p,l,2); p += 2;
+ __md5_to64(p,l,2);
+ p += 2;
*p = '\0';
/* Don't leave anything around in vm they could use. */
diff --git a/libcrypt/sha256-crypt.c b/libcrypt/sha256-crypt.c
new file mode 100644
index 000000000..81bbe6ae6
--- /dev/null
+++ b/libcrypt/sha256-crypt.c
@@ -0,0 +1,325 @@
+/* One way encryption based on SHA256 sum.
+ Copyright (C) 2007, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2007.
+
+ 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 <assert.h>
+#include <errno.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/param.h>
+
+#include "sha256.h"
+#include "libcrypt.h"
+
+/* Define our magic string to mark salt for SHA256 "encryption"
+ replacement. */
+static const char sha256_salt_prefix[] = "$5$";
+
+/* Prefix for optional rounds specification. */
+static const char sha256_rounds_prefix[] = "rounds=";
+
+/* Maximum salt string length. */
+#define SALT_LEN_MAX 16
+/* Default number of rounds if not explicitly specified. */
+#define ROUNDS_DEFAULT 5000
+/* Minimum number of rounds. */
+#define ROUNDS_MIN 1000
+/* Maximum number of rounds. */
+#define ROUNDS_MAX 999999999
+
+/* Table with characters for base64 transformation. */
+static const char b64t[64] =
+"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+
+#define B64_FROM_24BIT(b2, b1, b0, steps) \
+ { \
+ int n = (steps); \
+ unsigned int w = ((b2) << 16) | ((b1) << 8) | (b0); \
+ while (n-- > 0 && buflen > 0) \
+ { \
+ *cp++ = b64t[w & 0x3f]; \
+ --buflen; \
+ w >>= 6; \
+ } \
+ }
+
+char *
+__sha256_crypt_r (const char *key,
+ const char *salt,
+ char *buffer,
+ int buflen)
+{
+ unsigned char alt_result[32]
+ __attribute__ ((__aligned__ (__alignof__ (uint32_t))));
+ unsigned char temp_result[32]
+ __attribute__ ((__aligned__ (__alignof__ (uint32_t))));
+ size_t salt_len;
+ size_t key_len;
+ size_t cnt;
+ char *cp;
+ char *copied_key = NULL;
+ char *copied_salt = NULL;
+ char *p_bytes;
+ char *s_bytes;
+ /* Default number of rounds. */
+ size_t rounds = ROUNDS_DEFAULT;
+ bool rounds_custom = false;
+
+ /* Find beginning of salt string. The prefix should normally always
+ be present. Just in case it is not. */
+ if (strncmp (sha256_salt_prefix, salt, sizeof (sha256_salt_prefix) - 1) == 0)
+ /* Skip salt prefix. */
+ salt += sizeof (sha256_salt_prefix) - 1;
+
+ if (strncmp (salt, sha256_rounds_prefix, sizeof (sha256_rounds_prefix) - 1)
+ == 0)
+ {
+ const char *num = salt + sizeof (sha256_rounds_prefix) - 1;
+ char *endp;
+ unsigned long int srounds = strtoul (num, &endp, 10);
+ if (*endp == '$')
+ {
+ salt = endp + 1;
+ rounds = MAX (ROUNDS_MIN, MIN (srounds, ROUNDS_MAX));
+ rounds_custom = true;
+ }
+ }
+
+ salt_len = MIN (strcspn (salt, "$"), SALT_LEN_MAX);
+ key_len = strlen (key);
+
+ if ((key - (char *) 0) % __alignof__ (uint32_t) != 0)
+ {
+ char *tmp = (char *) alloca (key_len + __alignof__ (uint32_t));
+ key = copied_key =
+ memcpy (tmp + __alignof__ (uint32_t)
+ - (tmp - (char *) 0) % __alignof__ (uint32_t),
+ key, key_len);
+ assert ((key - (char *) 0) % __alignof__ (uint32_t) == 0);
+ }
+
+ if ((salt - (char *) 0) % __alignof__ (uint32_t) != 0)
+ {
+ char *tmp = (char *) alloca (salt_len + __alignof__ (uint32_t));
+ salt = copied_salt =
+ memcpy (tmp + __alignof__ (uint32_t)
+ - (tmp - (char *) 0) % __alignof__ (uint32_t),
+ salt, salt_len);
+ assert ((salt - (char *) 0) % __alignof__ (uint32_t) == 0);
+ }
+
+ struct sha256_ctx ctx;
+ struct sha256_ctx alt_ctx;
+
+ /* Prepare for the real work. */
+ __sha256_init_ctx (&ctx);
+
+ /* Add the key string. */
+ __sha256_process_bytes (key, key_len, &ctx);
+
+ /* The last part is the salt string. This must be at most 16
+ characters and it ends at the first `$' character. */
+ __sha256_process_bytes (salt, salt_len, &ctx);
+
+
+ /* Compute alternate SHA256 sum with input KEY, SALT, and KEY. The
+ final result will be added to the first context. */
+ __sha256_init_ctx (&alt_ctx);
+
+ /* Add key. */
+ __sha256_process_bytes (key, key_len, &alt_ctx);
+
+ /* Add salt. */
+ __sha256_process_bytes (salt, salt_len, &alt_ctx);
+
+ /* Add key again. */
+ __sha256_process_bytes (key, key_len, &alt_ctx);
+
+ /* Now get result of this (32 bytes) and add it to the other
+ context. */
+ __sha256_finish_ctx (&alt_ctx, alt_result);
+
+ /* Add for any character in the key one byte of the alternate sum. */
+ for (cnt = key_len; cnt > 32; cnt -= 32)
+ __sha256_process_bytes (alt_result, 32, &ctx);
+ __sha256_process_bytes (alt_result, cnt, &ctx);
+
+ /* Take the binary representation of the length of the key and for every
+ 1 add the alternate sum, for every 0 the key. */
+ for (cnt = key_len; cnt > 0; cnt >>= 1)
+ if ((cnt & 1) != 0)
+ __sha256_process_bytes (alt_result, 32, &ctx);
+ else
+ __sha256_process_bytes (key, key_len, &ctx);
+
+ /* Create intermediate result. */
+ __sha256_finish_ctx (&ctx, alt_result);
+
+ /* Start computation of P byte sequence. */
+ __sha256_init_ctx (&alt_ctx);
+
+ /* For every character in the password add the entire password. */
+ for (cnt = 0; cnt < key_len; ++cnt)
+ __sha256_process_bytes (key, key_len, &alt_ctx);
+
+ /* Finish the digest. */
+ __sha256_finish_ctx (&alt_ctx, temp_result);
+
+ /* Create byte sequence P. */
+ cp = p_bytes = alloca (key_len);
+ for (cnt = key_len; cnt >= 32; cnt -= 32)
+ cp = mempcpy (cp, temp_result, 32);
+ memcpy (cp, temp_result, cnt);
+
+ /* Start computation of S byte sequence. */
+ __sha256_init_ctx (&alt_ctx);
+
+ /* For every character in the password add the entire password. */
+ for (cnt = 0; cnt < 16 + alt_result[0]; ++cnt)
+ __sha256_process_bytes (salt, salt_len, &alt_ctx);
+
+ /* Finish the digest. */
+ __sha256_finish_ctx (&alt_ctx, temp_result);
+
+ /* Create byte sequence S. */
+ cp = s_bytes = alloca (salt_len);
+ for (cnt = salt_len; cnt >= 32; cnt -= 32)
+ cp = mempcpy (cp, temp_result, 32);
+ memcpy (cp, temp_result, cnt);
+
+ /* Repeatedly run the collected hash value through SHA256 to burn
+ CPU cycles. */
+ for (cnt = 0; cnt < rounds; ++cnt)
+ {
+ /* New context. */
+ __sha256_init_ctx (&ctx);
+
+ /* Add key or last result. */
+ if ((cnt & 1) != 0)
+ __sha256_process_bytes (p_bytes, key_len, &ctx);
+ else
+ __sha256_process_bytes (alt_result, 32, &ctx);
+
+ /* Add salt for numbers not divisible by 3. */
+ if (cnt % 3 != 0)
+ __sha256_process_bytes (s_bytes, salt_len, &ctx);
+
+ /* Add key for numbers not divisible by 7. */
+ if (cnt % 7 != 0)
+ __sha256_process_bytes (p_bytes, key_len, &ctx);
+
+ /* Add key or last result. */
+ if ((cnt & 1) != 0)
+ __sha256_process_bytes (alt_result, 32, &ctx);
+ else
+ __sha256_process_bytes (p_bytes, key_len, &ctx);
+
+ /* Create intermediate result. */
+ __sha256_finish_ctx (&ctx, alt_result);
+ }
+
+ /* Now we can construct the result string. It consists of three
+ parts. */
+ cp = stpncpy (buffer, sha256_salt_prefix, MAX (0, buflen));
+ buflen -= sizeof (sha256_salt_prefix) - 1;
+
+ if (rounds_custom)
+ {
+ int n = snprintf (cp, MAX (0, buflen), "%s%zu$",
+ sha256_rounds_prefix, rounds);
+ cp += n;
+ buflen -= n;
+ }
+
+ cp = stpncpy (cp, salt, MIN ((size_t) MAX (0, buflen), salt_len));
+ buflen -= MIN ((size_t) MAX (0, buflen), salt_len);
+
+ if (buflen > 0)
+ {
+ *cp++ = '$';
+ --buflen;
+ }
+
+ B64_FROM_24BIT (alt_result[0], alt_result[10], alt_result[20], 4);
+ B64_FROM_24BIT (alt_result[21], alt_result[1], alt_result[11], 4);
+ B64_FROM_24BIT (alt_result[12], alt_result[22], alt_result[2], 4);
+ B64_FROM_24BIT (alt_result[3], alt_result[13], alt_result[23], 4);
+ B64_FROM_24BIT (alt_result[24], alt_result[4], alt_result[14], 4);
+ B64_FROM_24BIT (alt_result[15], alt_result[25], alt_result[5], 4);
+ B64_FROM_24BIT (alt_result[6], alt_result[16], alt_result[26], 4);
+ B64_FROM_24BIT (alt_result[27], alt_result[7], alt_result[17], 4);
+ B64_FROM_24BIT (alt_result[18], alt_result[28], alt_result[8], 4);
+ B64_FROM_24BIT (alt_result[9], alt_result[19], alt_result[29], 4);
+ B64_FROM_24BIT (0, alt_result[31], alt_result[30], 3);
+ if (buflen <= 0)
+ {
+ __set_errno (ERANGE);
+ buffer = NULL;
+ }
+ else
+ *cp = '\0'; /* Terminate the string. */
+
+ /* Clear the buffer for the intermediate result so that people
+ attaching to processes or reading core dumps cannot get any
+ information. We do it in this way to clear correct_words[]
+ inside the SHA256 implementation as well. */
+ __sha256_init_ctx (&ctx);
+ __sha256_finish_ctx (&ctx, alt_result);
+ memset (&ctx, '\0', sizeof (ctx));
+ memset (&alt_ctx, '\0', sizeof (alt_ctx));
+
+ memset (temp_result, '\0', sizeof (temp_result));
+ memset (p_bytes, '\0', key_len);
+ memset (s_bytes, '\0', salt_len);
+ if (copied_key != NULL)
+ memset (copied_key, '\0', key_len);
+ if (copied_salt != NULL)
+ memset (copied_salt, '\0', salt_len);
+
+ return buffer;
+}
+
+static char *buffer;
+
+/* This entry point is equivalent to the `crypt' function in Unix
+ libcs. */
+char *
+__sha256_crypt (const unsigned char *key, const unsigned char *salt)
+{
+ /* We don't want to have an arbitrary limit in the size of the
+ password. We can compute an upper bound for the size of the
+ result in advance and so we can prepare the buffer we pass to
+ `sha256_crypt_r'. */
+ static int buflen;
+ int needed = (sizeof (sha256_salt_prefix) - 1
+ + sizeof (sha256_rounds_prefix) + 9 + 1
+ + strlen (salt) + 1 + 43 + 1);
+
+ if (buflen < needed)
+ {
+ char *new_buffer = (char *) realloc (buffer, needed);
+ if (new_buffer == NULL)
+ return NULL;
+
+ buffer = new_buffer;
+ buflen = needed;
+ }
+
+ return __sha256_crypt_r ((const char *) key, (const char *) salt, buffer, buflen);
+}
diff --git a/libcrypt/sha256.c b/libcrypt/sha256.c
new file mode 100644
index 000000000..3e12b5ce4
--- /dev/null
+++ b/libcrypt/sha256.c
@@ -0,0 +1,293 @@
+/* Functions to compute SHA256 message digest of files or memory blocks.
+ according to the definition of SHA256 in FIPS 180-2.
+ 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/>. */
+
+/* Written by Ulrich Drepper <drepper@redhat.com>, 2007. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <endian.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+
+#include "sha256.h"
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+# ifdef _LIBC
+# include <byteswap.h>
+# define SWAP(n) bswap_32 (n)
+# else
+# define SWAP(n) \
+ (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24))
+# endif
+#else
+# define SWAP(n) (n)
+#endif
+
+
+/* This array contains the bytes used to pad the buffer to the next
+ 64-byte boundary. (FIPS 180-2:5.1.1) */
+static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };
+
+
+/* Constants for SHA256 from FIPS 180-2:4.2.2. */
+static const uint32_t K[64] =
+ {
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
+ 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
+ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
+ 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
+ 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
+ 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
+ 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
+ 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
+ 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
+ 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
+ };
+
+
+/* Process LEN bytes of BUFFER, accumulating context into CTX.
+ It is assumed that LEN % 64 == 0. */
+static void
+sha256_process_block (const void *buffer, size_t len, struct sha256_ctx *ctx)
+{
+ const uint32_t *words = buffer;
+ size_t nwords = len / sizeof (uint32_t);
+ uint32_t a = ctx->H[0];
+ uint32_t b = ctx->H[1];
+ uint32_t c = ctx->H[2];
+ uint32_t d = ctx->H[3];
+ uint32_t e = ctx->H[4];
+ uint32_t f = ctx->H[5];
+ uint32_t g = ctx->H[6];
+ uint32_t h = ctx->H[7];
+
+ /* First increment the byte count. FIPS 180-2 specifies the possible
+ length of the file up to 2^64 bits. Here we only compute the
+ number of bytes. Do a double word increment. */
+ ctx->total[0] += len;
+ if (ctx->total[0] < len)
+ ++ctx->total[1];
+
+ /* Process all bytes in the buffer with 64 bytes in each round of
+ the loop. */
+ while (nwords > 0)
+ {
+ uint32_t W[64];
+ uint32_t a_save = a;
+ uint32_t b_save = b;
+ uint32_t c_save = c;
+ uint32_t d_save = d;
+ uint32_t e_save = e;
+ uint32_t f_save = f;
+ uint32_t g_save = g;
+ uint32_t h_save = h;
+
+ /* Operators defined in FIPS 180-2:4.1.2. */
+#define _Ch(x, y, z) ((x & y) ^ (~x & z))
+#define _Maj(x, y, z) ((x & y) ^ (x & z) ^ (y & z))
+#define _S0(x) (CYCLIC (x, 2) ^ CYCLIC (x, 13) ^ CYCLIC (x, 22))
+#define _S1(x) (CYCLIC (x, 6) ^ CYCLIC (x, 11) ^ CYCLIC (x, 25))
+#define _R0(x) (CYCLIC (x, 7) ^ CYCLIC (x, 18) ^ (x >> 3))
+#define _R1(x) (CYCLIC (x, 17) ^ CYCLIC (x, 19) ^ (x >> 10))
+
+ /* It is unfortunate that C does not provide an operator for
+ cyclic rotation. Hope the C compiler is smart enough. */
+#define CYCLIC(w, s) ((w >> s) | (w << (32 - s)))
+
+ /* Compute the message schedule according to FIPS 180-2:6.2.2 step 2. */
+ for (unsigned int t = 0; t < 16; ++t)
+ {
+ W[t] = SWAP (*words);
+ ++words;
+ }
+ for (unsigned int t = 16; t < 64; ++t)
+ W[t] = _R1 (W[t - 2]) + W[t - 7] + _R0 (W[t - 15]) + W[t - 16];
+
+ /* The actual computation according to FIPS 180-2:6.2.2 step 3. */
+ for (unsigned int t = 0; t < 64; ++t)
+ {
+ uint32_t T1 = h + _S1 (e) + _Ch (e, f, g) + K[t] + W[t];
+ uint32_t T2 = _S0 (a) + _Maj (a, b, c);
+ h = g;
+ g = f;
+ f = e;
+ e = d + T1;
+ d = c;
+ c = b;
+ b = a;
+ a = T1 + T2;
+ }
+
+ /* Add the starting values of the context according to FIPS 180-2:6.2.2
+ step 4. */
+ a += a_save;
+ b += b_save;
+ c += c_save;
+ d += d_save;
+ e += e_save;
+ f += f_save;
+ g += g_save;
+ h += h_save;
+
+ /* Prepare for the next round. */
+ nwords -= 16;
+ }
+
+ /* Put checksum in context given as argument. */
+ ctx->H[0] = a;
+ ctx->H[1] = b;
+ ctx->H[2] = c;
+ ctx->H[3] = d;
+ ctx->H[4] = e;
+ ctx->H[5] = f;
+ ctx->H[6] = g;
+ ctx->H[7] = h;
+}
+
+
+/* Initialize structure containing state of computation.
+ (FIPS 180-2:5.3.2) */
+void
+__sha256_init_ctx (struct sha256_ctx *ctx)
+{
+ ctx->H[0] = 0x6a09e667;
+ ctx->H[1] = 0xbb67ae85;
+ ctx->H[2] = 0x3c6ef372;
+ ctx->H[3] = 0xa54ff53a;
+ ctx->H[4] = 0x510e527f;
+ ctx->H[5] = 0x9b05688c;
+ ctx->H[6] = 0x1f83d9ab;
+ ctx->H[7] = 0x5be0cd19;
+
+ ctx->total[0] = ctx->total[1] = 0;
+ ctx->buflen = 0;
+}
+
+
+/* Process the remaining bytes in the internal buffer and the usual
+ prolog according to the standard and write the result to RESBUF.
+
+ IMPORTANT: On some systems it is required that RESBUF is correctly
+ aligned for a 32 bits value. */
+void *
+__sha256_finish_ctx (struct sha256_ctx *ctx, void *resbuf)
+{
+ /* Take yet unprocessed bytes into account. */
+ uint32_t bytes = ctx->buflen;
+ size_t pad;
+
+ /* Now count remaining bytes. */
+ ctx->total[0] += bytes;
+ if (ctx->total[0] < bytes)
+ ++ctx->total[1];
+
+ pad = bytes >= 56 ? 64 + 56 - bytes : 56 - bytes;
+ memcpy (&ctx->buffer[bytes], fillbuf, pad);
+
+ /* Put the 64-bit file length in *bits* at the end of the buffer. */
+ *(uint32_t *) &ctx->buffer[bytes + pad + 4] = SWAP (ctx->total[0] << 3);
+ *(uint32_t *) &ctx->buffer[bytes + pad] = SWAP ((ctx->total[1] << 3) |
+ (ctx->total[0] >> 29));
+
+ /* Process last bytes. */
+ sha256_process_block (ctx->buffer, bytes + pad + 8, ctx);
+
+ /* Put result from CTX in first 32 bytes following RESBUF. */
+ for (unsigned int i = 0; i < 8; ++i)
+ ((uint32_t *) resbuf)[i] = SWAP (ctx->H[i]);
+
+ return resbuf;
+}
+
+
+void
+__sha256_process_bytes (const void *buffer, size_t len, struct sha256_ctx *ctx)
+{
+ /* When we already have some bits in our internal buffer concatenate
+ both inputs first. */
+ if (ctx->buflen != 0)
+ {
+ size_t left_over = ctx->buflen;
+ size_t add = 128 - left_over > len ? len : 128 - left_over;
+
+ memcpy (&ctx->buffer[left_over], buffer, add);
+ ctx->buflen += add;
+
+ if (ctx->buflen > 64)
+ {
+ sha256_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
+
+ ctx->buflen &= 63;
+ /* The regions in the following copy operation cannot overlap. */
+ memcpy (ctx->buffer, &ctx->buffer[(left_over + add) & ~63],
+ ctx->buflen);
+ }
+
+ buffer = (const char *) buffer + add;
+ len -= add;
+ }
+
+ /* Process available complete blocks. */
+ if (len >= 64)
+ {
+#if __GNUC__ >= 2
+# define UNALIGNED_P(p) (((uintptr_t) p) % __alignof__ (uint32_t) != 0)
+#else
+# define UNALIGNED_P(p) (((uintptr_t) p) % sizeof (uint32_t) != 0)
+#endif
+ if (UNALIGNED_P (buffer))
+ while (len > 64)
+ {
+ sha256_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx);
+ buffer = (const char *) buffer + 64;
+ len -= 64;
+ }
+ else
+ {
+ sha256_process_block (buffer, len & ~63, ctx);
+ buffer = (const char *) buffer + (len & ~63);
+ len &= 63;
+ }
+ }
+
+ /* Move remaining bytes into internal buffer. */
+ if (len > 0)
+ {
+ size_t left_over = ctx->buflen;
+
+ memcpy (&ctx->buffer[left_over], buffer, len);
+ left_over += len;
+ if (left_over >= 64)
+ {
+ sha256_process_block (ctx->buffer, 64, ctx);
+ left_over -= 64;
+ memcpy (ctx->buffer, &ctx->buffer[64], left_over);
+ }
+ ctx->buflen = left_over;
+ }
+}
diff --git a/libcrypt/sha256.h b/libcrypt/sha256.h
new file mode 100644
index 000000000..7c5f74582
--- /dev/null
+++ b/libcrypt/sha256.h
@@ -0,0 +1,57 @@
+/* Declaration of functions and data types used for SHA256 sum computing
+ library functions.
+ 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/>. */
+
+#ifndef _SHA256_H
+#define _SHA256_H 1
+
+#include <limits.h>
+#include <stdint.h>
+#include <stdio.h>
+
+
+/* Structure to save state of computation between the single steps. */
+struct sha256_ctx
+{
+ uint32_t H[8];
+
+ uint32_t total[2];
+ uint32_t buflen;
+ char buffer[128] __attribute__ ((__aligned__ (__alignof__ (uint32_t))));
+};
+
+/* Initialize structure containing state of computation.
+ (FIPS 180-2: 5.3.2) */
+extern void __sha256_init_ctx (struct sha256_ctx *ctx) attribute_hidden;
+
+/* Starting with the result of former calls of this function (or the
+ initialization function update the context for the next LEN bytes
+ starting at BUFFER.
+ It is NOT required that LEN is a multiple of 64. */
+extern void __sha256_process_bytes (const void *buffer, size_t len,
+ struct sha256_ctx *ctx) attribute_hidden;
+
+/* Process the remaining bytes in the buffer and put result from CTX
+ in first 32 bytes following RESBUF.
+
+ IMPORTANT: On some systems it is required that RESBUF is correctly
+ aligned for a 32 bits value. */
+extern void *__sha256_finish_ctx (struct sha256_ctx *ctx, void *resbuf)
+ attribute_hidden;
+
+#endif /* sha256.h */
diff --git a/libcrypt/sha512-crypt.c b/libcrypt/sha512-crypt.c
new file mode 100644
index 000000000..9d17255aa
--- /dev/null
+++ b/libcrypt/sha512-crypt.c
@@ -0,0 +1,338 @@
+/* One way encryption based on SHA512 sum.
+ Copyright (C) 2007, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2007.
+
+ 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 <assert.h>
+#include <errno.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/param.h>
+
+#include "sha512.h"
+#include "libcrypt.h"
+
+/* Define our magic string to mark salt for SHA512 "encryption"
+ replacement. */
+static const char sha512_salt_prefix[] = "$6$";
+
+/* Prefix for optional rounds specification. */
+static const char sha512_rounds_prefix[] = "rounds=";
+
+/* Maximum salt string length. */
+#define SALT_LEN_MAX 16
+/* Default number of rounds if not explicitly specified. */
+#define ROUNDS_DEFAULT 5000
+/* Minimum number of rounds. */
+#define ROUNDS_MIN 1000
+/* Maximum number of rounds. */
+#define ROUNDS_MAX 999999999
+
+/* Table with characters for base64 transformation. */
+static const char b64t[64] =
+"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+
+#define B64_FROM_24BIT(b2, b1, b0, steps) \
+ { \
+ int n = (steps); \
+ unsigned int w = ((b2) << 16) | ((b1) << 8) | (b0); \
+ while (n-- > 0 && buflen > 0) \
+ { \
+ *cp++ = b64t[w & 0x3f]; \
+ --buflen; \
+ w >>= 6; \
+ } \
+ }
+
+char *
+__sha512_crypt_r (const char *key,
+ const char *salt,
+ char *buffer,
+ int buflen)
+{
+ unsigned char alt_result[64]
+ __attribute__ ((__aligned__ (__alignof__ (uint64_t))));
+ unsigned char temp_result[64]
+ __attribute__ ((__aligned__ (__alignof__ (uint64_t))));
+ size_t salt_len;
+ size_t key_len;
+ size_t cnt;
+ char *cp;
+ char *copied_key = NULL;
+ char *copied_salt = NULL;
+ char *p_bytes;
+ char *s_bytes;
+ /* Default number of rounds. */
+ size_t rounds = ROUNDS_DEFAULT;
+ bool rounds_custom = false;
+
+ /* Find beginning of salt string. The prefix should normally always
+ be present. Just in case it is not. */
+ if (strncmp (sha512_salt_prefix, salt, sizeof (sha512_salt_prefix) - 1) == 0)
+ /* Skip salt prefix. */
+ salt += sizeof (sha512_salt_prefix) - 1;
+
+ if (strncmp (salt, sha512_rounds_prefix, sizeof (sha512_rounds_prefix) - 1)
+ == 0)
+ {
+ const char *num = salt + sizeof (sha512_rounds_prefix) - 1;
+ char *endp;
+ unsigned long int srounds = strtoul (num, &endp, 10);
+ if (*endp == '$')
+ {
+ salt = endp + 1;
+ rounds = MAX (ROUNDS_MIN, MIN (srounds, ROUNDS_MAX));
+ rounds_custom = true;
+ }
+ }
+
+ salt_len = MIN (strcspn (salt, "$"), SALT_LEN_MAX);
+ key_len = strlen (key);
+
+ if ((key - (char *) 0) % __alignof__ (uint64_t) != 0)
+ {
+ char *tmp = (char *) alloca (key_len + __alignof__ (uint64_t));
+ key = copied_key =
+ memcpy (tmp + __alignof__ (uint64_t)
+ - (tmp - (char *) 0) % __alignof__ (uint64_t),
+ key, key_len);
+ assert ((key - (char *) 0) % __alignof__ (uint64_t) == 0);
+ }
+
+ if ((salt - (char *) 0) % __alignof__ (uint64_t) != 0)
+ {
+ char *tmp = (char *) alloca (salt_len + __alignof__ (uint64_t));
+ salt = copied_salt =
+ memcpy (tmp + __alignof__ (uint64_t)
+ - (tmp - (char *) 0) % __alignof__ (uint64_t),
+ salt, salt_len);
+ assert ((salt - (char *) 0) % __alignof__ (uint64_t) == 0);
+ }
+
+ struct sha512_ctx ctx;
+ struct sha512_ctx alt_ctx;
+
+ /* Prepare for the real work. */
+ __sha512_init_ctx (&ctx);
+
+ /* Add the key string. */
+ __sha512_process_bytes (key, key_len, &ctx);
+
+ /* The last part is the salt string. This must be at most 16
+ characters and it ends at the first `$' character. */
+ __sha512_process_bytes (salt, salt_len, &ctx);
+
+
+ /* Compute alternate SHA512 sum with input KEY, SALT, and KEY. The
+ final result will be added to the first context. */
+ __sha512_init_ctx (&alt_ctx);
+
+ /* Add key. */
+ __sha512_process_bytes (key, key_len, &alt_ctx);
+
+ /* Add salt. */
+ __sha512_process_bytes (salt, salt_len, &alt_ctx);
+
+ /* Add key again. */
+ __sha512_process_bytes (key, key_len, &alt_ctx);
+
+ /* Now get result of this (64 bytes) and add it to the other
+ context. */
+ __sha512_finish_ctx (&alt_ctx, alt_result);
+
+ /* Add for any character in the key one byte of the alternate sum. */
+ for (cnt = key_len; cnt > 64; cnt -= 64)
+ __sha512_process_bytes (alt_result, 64, &ctx);
+
+ __sha512_process_bytes (alt_result, cnt, &ctx);
+
+ /* Take the binary representation of the length of the key and for every
+ 1 add the alternate sum, for every 0 the key. */
+ for (cnt = key_len; cnt > 0; cnt >>= 1)
+ if ((cnt & 1) != 0)
+ __sha512_process_bytes (alt_result, 64, &ctx);
+ else
+ __sha512_process_bytes (key, key_len, &ctx);
+
+ /* Create intermediate result. */
+ __sha512_finish_ctx (&ctx, alt_result);
+
+ /* Start computation of P byte sequence. */
+ __sha512_init_ctx (&alt_ctx);
+
+ /* For every character in the password add the entire password. */
+ for (cnt = 0; cnt < key_len; ++cnt)
+ __sha512_process_bytes (key, key_len, &alt_ctx);
+
+ /* Finish the digest. */
+ __sha512_finish_ctx (&alt_ctx, temp_result);
+
+ /* Create byte sequence P. */
+ cp = p_bytes = alloca (key_len);
+ for (cnt = key_len; cnt >= 64; cnt -= 64)
+ cp = mempcpy (cp, temp_result, 64);
+ memcpy (cp, temp_result, cnt);
+
+ /* Start computation of S byte sequence. */
+ __sha512_init_ctx (&alt_ctx);
+
+ /* For every character in the password add the entire password. */
+ for (cnt = 0; cnt < 16 + alt_result[0]; ++cnt)
+ __sha512_process_bytes (salt, salt_len, &alt_ctx);
+
+ /* Finish the digest. */
+ __sha512_finish_ctx (&alt_ctx, temp_result);
+
+ /* Create byte sequence S. */
+ cp = s_bytes = alloca (salt_len);
+ for (cnt = salt_len; cnt >= 64; cnt -= 64)
+ cp = mempcpy (cp, temp_result, 64);
+ memcpy (cp, temp_result, cnt);
+
+ /* Repeatedly run the collected hash value through SHA512 to burn
+ CPU cycles. */
+ for (cnt = 0; cnt < rounds; ++cnt)
+ {
+ /* New context. */
+ __sha512_init_ctx (&ctx);
+
+ /* Add key or last result. */
+ if ((cnt & 1) != 0)
+ __sha512_process_bytes (p_bytes, key_len, &ctx);
+ else
+ __sha512_process_bytes (alt_result, 64, &ctx);
+
+ /* Add salt for numbers not divisible by 3. */
+ if (cnt % 3 != 0)
+ __sha512_process_bytes (s_bytes, salt_len, &ctx);
+
+ /* Add key for numbers not divisible by 7. */
+ if (cnt % 7 != 0)
+ __sha512_process_bytes (p_bytes, key_len, &ctx);
+
+ /* Add key or last result. */
+ if ((cnt & 1) != 0)
+ __sha512_process_bytes (alt_result, 64, &ctx);
+ else
+ __sha512_process_bytes (p_bytes, key_len, &ctx);
+
+ /* Create intermediate result. */
+ __sha512_finish_ctx (&ctx, alt_result);
+ }
+
+ /* Now we can construct the result string. It consists of three
+ parts. */
+ cp = stpncpy (buffer, sha512_salt_prefix, MAX (0, buflen));
+ buflen -= sizeof (sha512_salt_prefix) - 1;
+
+ if (rounds_custom)
+ {
+ int n = snprintf (cp, MAX (0, buflen), "%s%zu$",
+ sha512_rounds_prefix, rounds);
+ cp += n;
+ buflen -= n;
+ }
+
+ cp = stpncpy (cp, salt, MIN ((size_t) MAX (0, buflen), salt_len));
+ buflen -= MIN ((size_t) MAX (0, buflen), salt_len);
+
+ if (buflen > 0)
+ {
+ *cp++ = '$';
+ --buflen;
+ }
+
+ B64_FROM_24BIT (alt_result[0], alt_result[21], alt_result[42], 4);
+ B64_FROM_24BIT (alt_result[22], alt_result[43], alt_result[1], 4);
+ B64_FROM_24BIT (alt_result[44], alt_result[2], alt_result[23], 4);
+ B64_FROM_24BIT (alt_result[3], alt_result[24], alt_result[45], 4);
+ B64_FROM_24BIT (alt_result[25], alt_result[46], alt_result[4], 4);
+ B64_FROM_24BIT (alt_result[47], alt_result[5], alt_result[26], 4);
+ B64_FROM_24BIT (alt_result[6], alt_result[27], alt_result[48], 4);
+ B64_FROM_24BIT (alt_result[28], alt_result[49], alt_result[7], 4);
+ B64_FROM_24BIT (alt_result[50], alt_result[8], alt_result[29], 4);
+ B64_FROM_24BIT (alt_result[9], alt_result[30], alt_result[51], 4);
+ B64_FROM_24BIT (alt_result[31], alt_result[52], alt_result[10], 4);
+ B64_FROM_24BIT (alt_result[53], alt_result[11], alt_result[32], 4);
+ B64_FROM_24BIT (alt_result[12], alt_result[33], alt_result[54], 4);
+ B64_FROM_24BIT (alt_result[34], alt_result[55], alt_result[13], 4);
+ B64_FROM_24BIT (alt_result[56], alt_result[14], alt_result[35], 4);
+ B64_FROM_24BIT (alt_result[15], alt_result[36], alt_result[57], 4);
+ B64_FROM_24BIT (alt_result[37], alt_result[58], alt_result[16], 4);
+ B64_FROM_24BIT (alt_result[59], alt_result[17], alt_result[38], 4);
+ B64_FROM_24BIT (alt_result[18], alt_result[39], alt_result[60], 4);
+ B64_FROM_24BIT (alt_result[40], alt_result[61], alt_result[19], 4);
+ B64_FROM_24BIT (alt_result[62], alt_result[20], alt_result[41], 4);
+ B64_FROM_24BIT (0, 0, alt_result[63], 2);
+
+ if (buflen <= 0)
+ {
+ __set_errno (ERANGE);
+ buffer = NULL;
+ }
+ else
+ *cp = '\0'; /* Terminate the string. */
+
+ /* Clear the buffer for the intermediate result so that people
+ attaching to processes or reading core dumps cannot get any
+ information. We do it in this way to clear correct_words[]
+ inside the SHA512 implementation as well. */
+ __sha512_init_ctx (&ctx);
+ __sha512_finish_ctx (&ctx, alt_result);
+ memset (&ctx, '\0', sizeof (ctx));
+ memset (&alt_ctx, '\0', sizeof (alt_ctx));
+
+ memset (temp_result, '\0', sizeof (temp_result));
+ memset (p_bytes, '\0', key_len);
+ memset (s_bytes, '\0', salt_len);
+ if (copied_key != NULL)
+ memset (copied_key, '\0', key_len);
+ if (copied_salt != NULL)
+ memset (copied_salt, '\0', salt_len);
+
+ return buffer;
+}
+
+static char *buffer;
+
+/* This entry point is equivalent to the `crypt' function in Unix
+ libcs. */
+char *
+__sha512_crypt (const unsigned char *key, const unsigned char *salt)
+{
+ /* We don't want to have an arbitrary limit in the size of the
+ password. We can compute an upper bound for the size of the
+ result in advance and so we can prepare the buffer we pass to
+ `sha512_crypt_r'. */
+ static int buflen;
+ int needed = (sizeof (sha512_salt_prefix) - 1
+ + sizeof (sha512_rounds_prefix) + 9 + 1
+ + strlen (salt) + 1 + 86 + 1);
+
+ if (buflen < needed)
+ {
+ char *new_buffer = (char *) realloc (buffer, needed);
+ if (new_buffer == NULL)
+ return NULL;
+
+ buffer = new_buffer;
+ buflen = needed;
+ }
+
+ return __sha512_crypt_r ((const char *) key, (const char *) salt, buffer, buflen);
+}
diff --git a/libcrypt/sha512.c b/libcrypt/sha512.c
new file mode 100644
index 000000000..b2e36a3b3
--- /dev/null
+++ b/libcrypt/sha512.c
@@ -0,0 +1,325 @@
+/* Functions to compute SHA512 message digest of files or memory blocks.
+ according to the definition of SHA512 in FIPS 180-2.
+ 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/>. */
+
+/* Written by Ulrich Drepper <drepper@redhat.com>, 2007. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <endian.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+
+#include "sha512.h"
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+# ifdef _LIBC
+# include <byteswap.h>
+# define SWAP(n) bswap_64 (n)
+# else
+# define SWAP(n) \
+ (((n) << 56) \
+ | (((n) & 0xff00) << 40) \
+ | (((n) & 0xff0000) << 24) \
+ | (((n) & 0xff000000) << 8) \
+ | (((n) >> 8) & 0xff000000) \
+ | (((n) >> 24) & 0xff0000) \
+ | (((n) >> 40) & 0xff00) \
+ | ((n) >> 56))
+# endif
+#else
+# define SWAP(n) (n)
+#endif
+
+
+/* This array contains the bytes used to pad the buffer to the next
+ 64-byte boundary. (FIPS 180-2:5.1.2) */
+static const unsigned char fillbuf[128] = { 0x80, 0 /* , 0, 0, ... */ };
+
+
+/* Constants for SHA512 from FIPS 180-2:4.2.3. */
+static const uint64_t K[80] =
+ {
+ UINT64_C (0x428a2f98d728ae22), UINT64_C (0x7137449123ef65cd),
+ UINT64_C (0xb5c0fbcfec4d3b2f), UINT64_C (0xe9b5dba58189dbbc),
+ UINT64_C (0x3956c25bf348b538), UINT64_C (0x59f111f1b605d019),
+ UINT64_C (0x923f82a4af194f9b), UINT64_C (0xab1c5ed5da6d8118),
+ UINT64_C (0xd807aa98a3030242), UINT64_C (0x12835b0145706fbe),
+ UINT64_C (0x243185be4ee4b28c), UINT64_C (0x550c7dc3d5ffb4e2),
+ UINT64_C (0x72be5d74f27b896f), UINT64_C (0x80deb1fe3b1696b1),
+ UINT64_C (0x9bdc06a725c71235), UINT64_C (0xc19bf174cf692694),
+ UINT64_C (0xe49b69c19ef14ad2), UINT64_C (0xefbe4786384f25e3),
+ UINT64_C (0x0fc19dc68b8cd5b5), UINT64_C (0x240ca1cc77ac9c65),
+ UINT64_C (0x2de92c6f592b0275), UINT64_C (0x4a7484aa6ea6e483),
+ UINT64_C (0x5cb0a9dcbd41fbd4), UINT64_C (0x76f988da831153b5),
+ UINT64_C (0x983e5152ee66dfab), UINT64_C (0xa831c66d2db43210),
+ UINT64_C (0xb00327c898fb213f), UINT64_C (0xbf597fc7beef0ee4),
+ UINT64_C (0xc6e00bf33da88fc2), UINT64_C (0xd5a79147930aa725),
+ UINT64_C (0x06ca6351e003826f), UINT64_C (0x142929670a0e6e70),
+ UINT64_C (0x27b70a8546d22ffc), UINT64_C (0x2e1b21385c26c926),
+ UINT64_C (0x4d2c6dfc5ac42aed), UINT64_C (0x53380d139d95b3df),
+ UINT64_C (0x650a73548baf63de), UINT64_C (0x766a0abb3c77b2a8),
+ UINT64_C (0x81c2c92e47edaee6), UINT64_C (0x92722c851482353b),
+ UINT64_C (0xa2bfe8a14cf10364), UINT64_C (0xa81a664bbc423001),
+ UINT64_C (0xc24b8b70d0f89791), UINT64_C (0xc76c51a30654be30),
+ UINT64_C (0xd192e819d6ef5218), UINT64_C (0xd69906245565a910),
+ UINT64_C (0xf40e35855771202a), UINT64_C (0x106aa07032bbd1b8),
+ UINT64_C (0x19a4c116b8d2d0c8), UINT64_C (0x1e376c085141ab53),
+ UINT64_C (0x2748774cdf8eeb99), UINT64_C (0x34b0bcb5e19b48a8),
+ UINT64_C (0x391c0cb3c5c95a63), UINT64_C (0x4ed8aa4ae3418acb),
+ UINT64_C (0x5b9cca4f7763e373), UINT64_C (0x682e6ff3d6b2b8a3),
+ UINT64_C (0x748f82ee5defb2fc), UINT64_C (0x78a5636f43172f60),
+ UINT64_C (0x84c87814a1f0ab72), UINT64_C (0x8cc702081a6439ec),
+ UINT64_C (0x90befffa23631e28), UINT64_C (0xa4506cebde82bde9),
+ UINT64_C (0xbef9a3f7b2c67915), UINT64_C (0xc67178f2e372532b),
+ UINT64_C (0xca273eceea26619c), UINT64_C (0xd186b8c721c0c207),
+ UINT64_C (0xeada7dd6cde0eb1e), UINT64_C (0xf57d4f7fee6ed178),
+ UINT64_C (0x06f067aa72176fba), UINT64_C (0x0a637dc5a2c898a6),
+ UINT64_C (0x113f9804bef90dae), UINT64_C (0x1b710b35131c471b),
+ UINT64_C (0x28db77f523047d84), UINT64_C (0x32caab7b40c72493),
+ UINT64_C (0x3c9ebe0a15c9bebc), UINT64_C (0x431d67c49c100d4c),
+ UINT64_C (0x4cc5d4becb3e42b6), UINT64_C (0x597f299cfc657e2a),
+ UINT64_C (0x5fcb6fab3ad6faec), UINT64_C (0x6c44198c4a475817)
+ };
+
+
+/* Process LEN bytes of BUFFER, accumulating context into CTX.
+ It is assumed that LEN % 128 == 0. */
+static void
+sha512_process_block (const void *buffer, size_t len, struct sha512_ctx *ctx)
+{
+ const uint64_t *words = buffer;
+ size_t nwords = len / sizeof (uint64_t);
+ uint64_t a = ctx->H[0];
+ uint64_t b = ctx->H[1];
+ uint64_t c = ctx->H[2];
+ uint64_t d = ctx->H[3];
+ uint64_t e = ctx->H[4];
+ uint64_t f = ctx->H[5];
+ uint64_t g = ctx->H[6];
+ uint64_t h = ctx->H[7];
+
+ /* First increment the byte count. FIPS 180-2 specifies the possible
+ length of the file up to 2^128 bits. Here we only compute the
+ number of bytes. Do a double word increment. */
+ ctx->total[0] += len;
+ if (ctx->total[0] < len)
+ ++ctx->total[1];
+
+ /* Process all bytes in the buffer with 128 bytes in each round of
+ the loop. */
+ while (nwords > 0)
+ {
+ uint64_t W[80];
+ uint64_t a_save = a;
+ uint64_t b_save = b;
+ uint64_t c_save = c;
+ uint64_t d_save = d;
+ uint64_t e_save = e;
+ uint64_t f_save = f;
+ uint64_t g_save = g;
+ uint64_t h_save = h;
+
+ /* Operators defined in FIPS 180-2:4.1.2. */
+#define _Ch(x, y, z) ((x & y) ^ (~x & z))
+#define _Maj(x, y, z) ((x & y) ^ (x & z) ^ (y & z))
+#define _S0(x) (CYCLIC (x, 28) ^ CYCLIC (x, 34) ^ CYCLIC (x, 39))
+#define _S1(x) (CYCLIC (x, 14) ^ CYCLIC (x, 18) ^ CYCLIC (x, 41))
+#define _R0(x) (CYCLIC (x, 1) ^ CYCLIC (x, 8) ^ (x >> 7))
+#define _R1(x) (CYCLIC (x, 19) ^ CYCLIC (x, 61) ^ (x >> 6))
+
+ /* It is unfortunate that C does not provide an operator for
+ cyclic rotation. Hope the C compiler is smart enough. */
+#define CYCLIC(w, s) ((w >> s) | (w << (64 - s)))
+
+ /* Compute the message schedule according to FIPS 180-2:6.3.2 step 2. */
+ for (unsigned int t = 0; t < 16; ++t)
+ {
+ W[t] = SWAP (*words);
+ ++words;
+ }
+ for (unsigned int t = 16; t < 80; ++t)
+ W[t] = _R1 (W[t - 2]) + W[t - 7] + _R0 (W[t - 15]) + W[t - 16];
+
+ /* The actual computation according to FIPS 180-2:6.3.2 step 3. */
+ for (unsigned int t = 0; t < 80; ++t)
+ {
+ uint64_t T1 = h + _S1 (e) + _Ch (e, f, g) + K[t] + W[t];
+ uint64_t T2 = _S0 (a) + _Maj (a, b, c);
+ h = g;
+ g = f;
+ f = e;
+ e = d + T1;
+ d = c;
+ c = b;
+ b = a;
+ a = T1 + T2;
+ }
+
+ /* Add the starting values of the context according to FIPS 180-2:6.3.2
+ step 4. */
+ a += a_save;
+ b += b_save;
+ c += c_save;
+ d += d_save;
+ e += e_save;
+ f += f_save;
+ g += g_save;
+ h += h_save;
+
+ /* Prepare for the next round. */
+ nwords -= 16;
+ }
+
+ /* Put checksum in context given as argument. */
+ ctx->H[0] = a;
+ ctx->H[1] = b;
+ ctx->H[2] = c;
+ ctx->H[3] = d;
+ ctx->H[4] = e;
+ ctx->H[5] = f;
+ ctx->H[6] = g;
+ ctx->H[7] = h;
+}
+
+
+/* Initialize structure containing state of computation.
+ (FIPS 180-2:5.3.3) */
+void
+__sha512_init_ctx (struct sha512_ctx *ctx)
+{
+ ctx->H[0] = UINT64_C (0x6a09e667f3bcc908);
+ ctx->H[1] = UINT64_C (0xbb67ae8584caa73b);
+ ctx->H[2] = UINT64_C (0x3c6ef372fe94f82b);
+ ctx->H[3] = UINT64_C (0xa54ff53a5f1d36f1);
+ ctx->H[4] = UINT64_C (0x510e527fade682d1);
+ ctx->H[5] = UINT64_C (0x9b05688c2b3e6c1f);
+ ctx->H[6] = UINT64_C (0x1f83d9abfb41bd6b);
+ ctx->H[7] = UINT64_C (0x5be0cd19137e2179);
+
+ ctx->total[0] = ctx->total[1] = 0;
+ ctx->buflen = 0;
+}
+
+
+/* Process the remaining bytes in the internal buffer and the usual
+ prolog according to the standard and write the result to RESBUF.
+
+ IMPORTANT: On some systems it is required that RESBUF is correctly
+ aligned for a 32 bits value. */
+void *
+__sha512_finish_ctx (struct sha512_ctx *ctx, void *resbuf)
+{
+ /* Take yet unprocessed bytes into account. */
+ uint64_t bytes = ctx->buflen;
+ size_t pad;
+
+ /* Now count remaining bytes. */
+ ctx->total[0] += bytes;
+ if (ctx->total[0] < bytes)
+ ++ctx->total[1];
+
+ pad = bytes >= 112 ? 128 + 112 - bytes : 112 - bytes;
+ memcpy (&ctx->buffer[bytes], fillbuf, pad);
+
+ /* Put the 128-bit file length in *bits* at the end of the buffer. */
+ *(uint64_t *) &ctx->buffer[bytes + pad + 8] = SWAP (ctx->total[0] << 3);
+ *(uint64_t *) &ctx->buffer[bytes + pad] = SWAP ((ctx->total[1] << 3) |
+ (ctx->total[0] >> 61));
+
+ /* Process last bytes. */
+ sha512_process_block (ctx->buffer, bytes + pad + 16, ctx);
+
+ /* Put result from CTX in first 64 bytes following RESBUF. */
+ for (unsigned int i = 0; i < 8; ++i)
+ ((uint64_t *) resbuf)[i] = SWAP (ctx->H[i]);
+
+ return resbuf;
+}
+
+
+void
+__sha512_process_bytes (const void *buffer, size_t len, struct sha512_ctx *ctx)
+{
+ /* When we already have some bits in our internal buffer concatenate
+ both inputs first. */
+ if (ctx->buflen != 0)
+ {
+ size_t left_over = ctx->buflen;
+ size_t add = 256 - left_over > len ? len : 256 - left_over;
+
+ memcpy (&ctx->buffer[left_over], buffer, add);
+ ctx->buflen += add;
+
+ if (ctx->buflen > 128)
+ {
+ sha512_process_block (ctx->buffer, ctx->buflen & ~127, ctx);
+
+ ctx->buflen &= 127;
+ /* The regions in the following copy operation cannot overlap. */
+ memcpy (ctx->buffer, &ctx->buffer[(left_over + add) & ~127],
+ ctx->buflen);
+ }
+
+ buffer = (const char *) buffer + add;
+ len -= add;
+ }
+
+ /* Process available complete blocks. */
+ if (len >= 128)
+ {
+#if __GNUC__ >= 2
+# define UNALIGNED_P(p) (((uintptr_t) p) % __alignof__ (uint64_t) != 0)
+#else
+# define UNALIGNED_P(p) (((uintptr_t) p) % sizeof (uint64_t) != 0)
+#endif
+ if (UNALIGNED_P (buffer))
+ while (len > 128)
+ {
+ sha512_process_block (memcpy (ctx->buffer, buffer, 128), 128,
+ ctx);
+ buffer = (const char *) buffer + 128;
+ len -= 128;
+ }
+ else
+ {
+ sha512_process_block (buffer, len & ~127, ctx);
+ buffer = (const char *) buffer + (len & ~127);
+ len &= 127;
+ }
+ }
+
+ /* Move remaining bytes into internal buffer. */
+ if (len > 0)
+ {
+ size_t left_over = ctx->buflen;
+
+ memcpy (&ctx->buffer[left_over], buffer, len);
+ left_over += len;
+ if (left_over >= 128)
+ {
+ sha512_process_block (ctx->buffer, 128, ctx);
+ left_over -= 128;
+ memcpy (ctx->buffer, &ctx->buffer[128], left_over);
+ }
+ ctx->buflen = left_over;
+ }
+}
diff --git a/libcrypt/sha512.h b/libcrypt/sha512.h
new file mode 100644
index 000000000..c1280074b
--- /dev/null
+++ b/libcrypt/sha512.h
@@ -0,0 +1,57 @@
+/* Declaration of functions and data types used for SHA512 sum computing
+ library functions.
+ 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/>. */
+
+#ifndef _SHA512_H
+#define _SHA512_H 1
+
+#include <limits.h>
+#include <stdint.h>
+#include <stdio.h>
+
+
+/* Structure to save state of computation between the single steps. */
+struct sha512_ctx
+{
+ uint64_t H[8];
+
+ uint64_t total[2];
+ uint64_t buflen;
+ char buffer[256] __attribute__ ((__aligned__ (__alignof__ (uint64_t))));
+};
+
+/* Initialize structure containing state of computation.
+ (FIPS 180-2: 5.3.3) */
+extern void __sha512_init_ctx (struct sha512_ctx *ctx) attribute_hidden;
+
+/* Starting with the result of former calls of this function (or the
+ initialization function update the context for the next LEN bytes
+ starting at BUFFER.
+ It is NOT required that LEN is a multiple of 128. */
+extern void __sha512_process_bytes (const void *buffer, size_t len,
+ struct sha512_ctx *ctx) attribute_hidden;
+
+/* Process the remaining bytes in the buffer and put result from CTX
+ in first 64 bytes following RESBUF.
+
+ IMPORTANT: On some systems it is required that RESBUF is correctly
+ aligned for a 64 bits value. */
+extern void *__sha512_finish_ctx (struct sha512_ctx *ctx, void *resbuf)
+ attribute_hidden;
+
+#endif /* sha512.h */
diff --git a/libintl/Makefile.in b/libintl/Makefile.in
index 238ad4466..22ae70cf6 100644
--- a/libintl/Makefile.in
+++ b/libintl/Makefile.in
@@ -1,10 +1,12 @@
# 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.
#
+subdirs += libintl
+
CFLAGS-libintl := -DNOT_IN_libc -DIS_IN_libintl $(SSP_ALL_CFLAGS)
LDFLAGS-libintl.so := $(LDFLAGS)
@@ -37,18 +39,18 @@ libintl-so-y := $(libintl_MOBJ:.o=.os)
lib-a-$(UCLIBC_HAS_GETTEXT_AWARENESS) += $(top_builddir)lib/libintl.a
lib-so-$(UCLIBC_HAS_GETTEXT_AWARENESS) += $(top_builddir)lib/libintl.so
-objclean-y += libintl_clean
+objclean-y += CLEAN_libintl
ifeq ($(DOMULTI),n)
ifeq ($(DOPIC),y)
-$(top_builddir)lib/libintl.so: $(top_builddir)lib/libintl.a $(libc)
+$(top_builddir)lib/libintl.so: $(top_builddir)lib/libintl.a $(libc.depend)
else
-$(top_builddir)lib/libintl.so: $(libintl_OUT)/libintl_so.a $(libc)
+$(top_builddir)lib/libintl.so: $(libintl_OUT)/libintl_so.a $(libc.depend)
endif
- $(call link.so,$(libintl_FULL_NAME),$(MAJOR_VERSION))
+ $(call link.so,$(libintl_FULL_NAME),$(ABI_VERSION))
else
-$(top_builddir)lib/libintl.so: $(libintl_OUT)/libintl.oS | $(libc)
- $(call linkm.so,$(libintl_FULL_NAME),$(MAJOR_VERSION))
+$(top_builddir)lib/libintl.so: $(libintl_OUT)/libintl.oS | $(libc.depend)
+ $(call linkm.so,$(libintl_FULL_NAME),$(ABI_VERSION))
endif
$(libintl_OUT)/libintl_so.a: $(libintl-so-y)
@@ -70,5 +72,5 @@ $(libintl_MOBJ): $(libintl_MSRC)
$(libintl_MOBJ:.o=.os): $(libintl_MSRC)
$(compile.m)
-libintl_clean:
- $(RM) $(libintl_OUT)/*.{o,os,a}
+CLEAN_libintl:
+ $(do_rm) $(addprefix $(libintl_OUT)/*., o os oS a)
diff --git a/libm/Makefile.in b/libm/Makefile.in
index f3768d38e..835e7bf3f 100644
--- a/libm/Makefile.in
+++ b/libm/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.
#
@@ -20,9 +20,11 @@
# by Erik Andersen <andersen@codepoet.org>
#
+subdirs += libm libm/$(TARGET_ARCH)
+
CFLAGS-libm := -DNOT_IN_libc -DIS_IN_libm $(SSP_ALL_CFLAGS)
-CFLAGS-libm += -D_IEEE_LIBM
+LDFLAGS-$(UCLIBC_FORMAT_DSBT_ELF)-libm.so := -Wl,--dsbt-index=5
LDFLAGS-libm.so := $(LDFLAGS)
LIBS-libm.so := $(LIBS)
@@ -32,86 +34,222 @@ libm_FULL_NAME := libm-$(VERSION).so
libm_DIR:=$(top_srcdir)libm
libm_OUT:=$(top_builddir)libm
-# Fix builds for powerpc as there are different cores in this
-# section now.`
-ifeq ($(TARGET_ARCH),powerpc)
-ifeq ($(CONFIG_E500),y)
-libm_ARCH_DIR:=$(libm_DIR)/$(TARGET_ARCH)/e500
-libm_ARCH_OUT:=$(libm_OUT)/$(TARGET_ARCH)/e500
-else
-libm_ARCH_DIR:=$(libm_DIR)/$(TARGET_ARCH)/classic
-libm_ARCH_OUT:=$(libm_OUT)/$(TARGET_ARCH)/classic
-endif
-else
libm_ARCH_DIR:=$(libm_DIR)/$(TARGET_ARCH)
libm_ARCH_OUT:=$(libm_OUT)/$(TARGET_ARCH)
-endif
-libm_ARCH_fpu_DIR:=$(libm_ARCH_DIR)/fpu
-libm_ARCH_fpu_OUT:=$(libm_ARCH_OUT)/fpu
+ifneq ($(TARGET_SUBARCH),)
+libm_SUBARCH_DIR:=$(libm_DIR)/$(TARGET_ARCH)/$(TARGET_SUBARCH)
+libm_SUBARCH_OUT:=$(libm_OUT)/$(TARGET_ARCH)/$(TARGET_SUBARCH)
+endif
ifeq ($(UCLIBC_HAS_FPU),y)
ifeq ($(DO_C99_MATH),y)
-include $(libm_ARCH_DIR)/Makefile.arch
+-include $(libm_SUBARCH_DIR)/Makefile.arch
endif
endif
FL_MSRC := float_wrappers.c
+LD_MSRC := ldouble_wrappers.c
ifeq ($(DO_C99_MATH),y)
libm_CSRC := \
e_acos.c e_acosh.c e_asin.c e_atan2.c e_atanh.c e_cosh.c \
- e_exp.c e_fmod.c e_gamma.c e_gamma_r.c e_hypot.c e_j0.c \
- e_j1.c e_jn.c e_lgamma.c e_lgamma_r.c e_log.c e_log10.c \
+ e_exp.c e_exp10.c e_fmod.c e_hypot.c \
+ e_lgamma_r.c e_log.c e_log2.c e_log10.c \
e_pow.c e_remainder.c e_rem_pio2.c e_scalb.c e_sinh.c \
- e_sqrt.c k_cos.c k_rem_pio2.c k_sin.c k_standard.c k_tan.c \
+ e_sqrt.c k_cos.c k_rem_pio2.c k_sin.c k_tan.c \
s_asinh.c s_atan.c s_cbrt.c s_ceil.c s_copysign.c s_cos.c \
s_erf.c s_expm1.c s_fabs.c s_finite.c s_floor.c s_frexp.c \
s_ilogb.c s_ldexp.c s_lib_version.c s_lrint.c s_lround.c s_llround.c \
- s_log1p.c s_logb.c s_matherr.c s_modf.c s_nextafter.c s_round.c \
+ s_log1p.c s_logb.c s_modf.c s_nextafter.c \
+ s_nextafterf.c s_round.c \
s_rint.c s_scalbn.c s_signgam.c s_significand.c s_sin.c s_tan.c \
- s_tanh.c s_trunc.c w_acos.c w_acosh.c w_asin.c w_atan2.c w_atanh.c \
- w_cabs.c w_cosh.c w_drem.c w_exp.c w_fmod.c w_gamma.c w_gamma_r.c \
- w_hypot.c w_j0.c w_j1.c w_jn.c w_lgamma.c w_lgamma_r.c \
- w_log.c w_log10.c w_pow.c w_remainder.c w_scalb.c w_sinh.c \
- w_sqrt.c fpmacros.c nan.c carg.c s_llrint.c
+ s_tanh.c s_trunc.c \
+ w_cabs.c \
+ nan.c carg.c s_llrint.c \
+ s_fpclassify.c s_fpclassifyf.c s_signbit.c s_signbitf.c \
+ s_isnan.c s_isnanf.c s_isinf.c s_isinff.c s_finitef.c \
+ s_fdim.c s_fma.c s_fmax.c s_fmin.c \
+ s_remquo.c w_exp2.c \
+ cexp.c sincos.c
+
FL_MOBJ := \
- acosf.o acoshf.o asinf.o asinhf.o atan2f.o atanf.o atanhf.o cbrtf.o \
- ceilf.o copysignf.o cosf.o coshf.o erfcf.o erff.o exp2f.o expf.o \
- expm1f.o fabsf.o fdimf.o floorf.o fmaf.o fmaxf.o fminf.o fmodf.o \
- frexpf.o hypotf.o ilogbf.o ldexpf.o lgammaf.o llroundf.o log10f.o \
- log1pf.o log2f.o logbf.o logf.o lrintf.o lroundf.o modff.o nearbyintf.o \
- nextafterf.o powf.o remainderf.o remquof.o rintf.o roundf.o \
- scalblnf.o scalbnf.o sinf.o sinhf.o sqrtf.o tanf.o tanhf.o \
- tgammaf.o truncf.o cargf.o llrintf.o
+ acosf.o \
+ acoshf.o \
+ asinf.o \
+ asinhf.o \
+ atan2f.o \
+ atanf.o \
+ atanhf.o \
+ cargf.o \
+ cbrtf.o \
+ ceilf.o \
+ copysignf.o \
+ cosf.o \
+ coshf.o \
+ erfcf.o \
+ erff.o \
+ exp2f.o \
+ expf.o \
+ expm1f.o \
+ fabsf.o \
+ fdimf.o \
+ floorf.o \
+ fmaf.o \
+ fmaxf.o \
+ fminf.o \
+ fmodf.o \
+ frexpf.o \
+ gammaf.o \
+ hypotf.o \
+ ilogbf.o \
+ ldexpf.o \
+ lgammaf.o \
+ llrintf.o \
+ llroundf.o \
+ log10f.o \
+ log1pf.o \
+ log2f.o \
+ logbf.o \
+ logf.o \
+ lrintf.o \
+ lroundf.o \
+ modff.o \
+ nearbyintf.o \
+ nexttowardf.o \
+ powf.o \
+ remainderf.o \
+ remquof.o \
+ rintf.o \
+ roundf.o \
+ scalblnf.o \
+ scalbnf.o \
+ significandf.o \
+ sinf.o \
+ sinhf.o \
+ sqrtf.o \
+ tanf.o \
+ tanhf.o \
+ tgammaf.o \
+ truncf.o \
+
+ifeq ($(UCLIBC_SUSV3_LEGACY),y)
+FL_MOBJ += scalbf.o
+endif
+
+# Do not (yet?) implement the float variants of bessel functions
+ifeq (not-yet-implemented-$(DO_XSI_MATH),y)
+FL_MOBJ += \
+ j0f.o \
+ j1f.o \
+ jnf.o \
+ y0f.o \
+ y1f.o \
+ ynf.o
+endif
+
+LD_MOBJ := \
+ __finitel.o \
+ __fpclassifyl.o \
+ __isinfl.o \
+ __isnanl.o \
+ __signbitl.o \
+ acoshl.o \
+ acosl.o \
+ asinhl.o \
+ asinl.o \
+ atan2l.o \
+ atanhl.o \
+ atanl.o \
+ cargl.o \
+ cbrtl.o \
+ ceill.o \
+ copysignl.o \
+ coshl.o \
+ cosl.o \
+ erfcl.o \
+ erfl.o \
+ exp2l.o \
+ expl.o \
+ expm1l.o \
+ fabsl.o \
+ fdiml.o \
+ floorl.o \
+ fmal.o \
+ fmaxl.o \
+ fminl.o \
+ fmodl.o \
+ frexpl.o \
+ gammal.o \
+ hypotl.o \
+ ilogbl.o \
+ ldexpl.o \
+ lgammal.o \
+ llrintl.o \
+ llroundl.o \
+ log10l.o \
+ log1pl.o \
+ log2l.o \
+ logbl.o \
+ logl.o \
+ lrintl.o \
+ lroundl.o \
+ modfl.o \
+ nearbyintl.o \
+ nextafterl.o \
+ nexttowardl.o \
+ powl.o \
+ remainderl.o \
+ remquol.o \
+ rintl.o \
+ roundl.o \
+ scalblnl.o \
+ scalbnl.o \
+ significandl.o \
+ sinhl.o \
+ sinl.o \
+ sqrtl.o \
+ tanhl.o \
+ tanl.o \
+ tgammal.o \
+ truncl.o \
+
+# Do not (yet?) implement the long double variants of bessel functions
+ifeq (not-yet-implemented-$(DO_XSI_MATH),y)
+LD_MOBJ += \
+ j0l.o \
+ j1l.o \
+ jnl.o \
+ y0l.o \
+ y1l.o \
+ ynl.o
+endif
+
else
+
# This list of math functions was taken from POSIX/IEEE 1003.1b-1993
libm_CSRC := \
- w_acos.c w_asin.c s_atan.c w_atan2.c s_ceil.c s_cos.c \
- w_cosh.c w_exp.c s_fabs.c s_floor.c w_fmod.c s_frexp.c \
- s_ldexp.c w_log.c w_log10.c s_modf.c w_pow.c s_sin.c \
- w_sinh.c w_sqrt.c s_tan.c s_tanh.c \
+ s_atan.c s_ceil.c s_cos.c \
+ s_fabs.c s_floor.c s_frexp.c \
+ s_ldexp.c s_modf.c s_sin.c \
+ s_tan.c s_tanh.c \
s_expm1.c s_scalbn.c s_copysign.c e_acos.c e_asin.c e_atan2.c \
k_cos.c e_cosh.c e_exp.c e_fmod.c e_log.c e_log10.c e_pow.c \
k_sin.c e_sinh.c e_sqrt.c k_tan.c e_rem_pio2.c k_rem_pio2.c \
- s_finite.c
+ s_finite.c e_exp10.c
# We'll add sqrtf to avoid problems with libstdc++
FL_MOBJ := sqrtf.o
endif
+ifeq ($(DO_XSI_MATH),y)
+libm_CSRC += e_j0.c e_j1.c e_jn.c
+endif
+
# assume that arch specific versions are provided as single sources/objects
ifeq ($(UCLIBC_HAS_FPU),y)
ifeq ($(DO_C99_MATH),y)
ifneq ($(strip $(libm_ARCH_OBJS)),)
-ifeq ($(TARGET_ARCH),powerpc)
-ifeq ($(CONFIG_E500),y)
-CFLAGS-libm/$(TARGET_ARCH)/e500/ := $(CFLAGS-libm)
-else
-CFLAGS-libm/$(TARGET_ARCH)/classic/ := $(CFLAGS-libm)
-endif
-else
-CFLAGS-libm/$(TARGET_ARCH)/ := $(CFLAGS-libm)
-endif
# remove generic sources, if arch specific version is present
ifneq ($(strip $(libm_ARCH_SRC)),)
@@ -120,9 +258,11 @@ endif
# remove generic objects built from multi-sources, if arch specific version is present
FL_MOBJ := $(filter-out $(notdir $(libm_ARCH_OBJS)),$(FL_MOBJ))
+LD_MOBJ := $(filter-out $(notdir $(libm_ARCH_OBJS)),$(LD_MOBJ))
# we also try to remove % if s_% is in arch specific subdir
FL_MOBJ := $(filter-out $(patsubst s_%.o,%.o,$(notdir $(libm_ARCH_OBJS))),$(FL_MOBJ))
+LD_MOBJ := $(filter-out $(patsubst s_%.o,%.o,$(notdir $(libm_ARCH_OBJS))),$(LD_MOBJ))
endif
endif
endif
@@ -130,14 +270,22 @@ endif
libm_SRC := $(patsubst %.c,$(libm_DIR)/%.c,$(libm_CSRC))
libm_OBJ := $(patsubst $(libm_DIR)/%.c,$(libm_OUT)/%.o,$(libm_SRC))
-libm_MSRC := $(libm_DIR)/$(FL_MSRC)
-libm_MOBJ := $(patsubst %.o,$(libm_OUT)/%.o,$(FL_MOBJ))
+ifeq ($(strip $(UCLIBC_HAS_LONG_DOUBLE_MATH)),y)
+libm_MSRC_LD := $(libm_DIR)/$(LD_MSRC)
+libm_MOBJ_LD := $(patsubst %.o,$(libm_OUT)/%.o,$(LD_MOBJ))
+endif
+libm_MSRC_FL := $(libm_DIR)/$(FL_MSRC)
+libm_MOBJ_FL := $(patsubst %.o,$(libm_OUT)/%.o,$(FL_MOBJ))
+
ifneq ($(DOMULTI),n)
-CFLAGS-libm += $(patsubst %,-DL_%,$(subst .o,,$(notdir $(libm_MOBJ))))
+CFLAGS-libm += $(patsubst %,-DL_%,$(subst .o,,$(notdir $(libm_MOBJ_FL))))
+ifeq ($(strip $(UCLIBC_HAS_LONG_DOUBLE_MATH)),y)
+CFLAGS-libm += $(patsubst %,-DL_%,$(subst .o,,$(notdir $(libm_MOBJ_LD))))
+endif
endif
-libm_OBJS := $(libm_OBJ) $(libm_MOBJ)
+libm_OBJS := $(libm_OBJ) $(libm_MOBJ_FL) $(libm_MOBJ_LD)
ifeq ($(DOPIC),y)
libm-a-y += $(libm_OBJS:.o=.os)
@@ -148,7 +296,7 @@ libm-so-y += $(libm_OBJS:.o=.os)
lib-a-$(UCLIBC_HAS_FLOATS) += $(top_builddir)lib/libm.a
lib-so-$(UCLIBC_HAS_FLOATS) += $(top_builddir)lib/libm.so
-objclean-y += libm_clean
+objclean-y += CLEAN_libm
ifeq ($(DOMULTI),n)
ifeq ($(DOPIC),y)
@@ -156,17 +304,17 @@ $(top_builddir)lib/libm.so: $(top_builddir)lib/libm.a $(libc.depend)
else
$(top_builddir)lib/libm.so: $(libm_OUT)/libm_so.a $(libc.depend)
endif
- $(call link.so,$(libm_FULL_NAME),$(MAJOR_VERSION))
+ $(call link.so,$(libm_FULL_NAME),$(ABI_VERSION))
else
$(top_builddir)lib/libm.so: $(libm_OUT)/libm.oS | $(libc.depend)
- $(call linkm.so,$(libm_FULL_NAME),$(MAJOR_VERSION))
+ $(call linkm.so,$(libm_FULL_NAME),$(ABI_VERSION))
endif
$(libm_OUT)/libm_so.a: $(libm-so-y)
$(Q)$(RM) $@
$(do_ar)
-$(libm_OUT)/libm.oS: $(libm_SRC) $(libm_MSRC) $(libm_ARCH_SRC)
+$(libm_OUT)/libm.oS: $(libm_SRC) $(libm_MSRC_FL) $(libm_MSRC_LD) $(libm_ARCH_SRC)
$(Q)$(RM) $@
$(compile-m)
@@ -175,11 +323,24 @@ $(top_builddir)lib/libm.a: $(libm-a-y)
$(Q)$(RM) $@
$(do_ar)
-$(libm_MOBJ): $(libm_MSRC)
+$(libm_MOBJ_FL): $(libm_MSRC_FL)
+ $(compile.m)
+
+$(libm_MOBJ_LD): $(libm_MSRC_LD)
$(compile.m)
-$(libm_MOBJ:.o=.os): $(libm_MSRC)
+$(libm_MOBJ_FL:.o=.os): $(libm_MSRC_FL)
$(compile.m)
-libm_clean:
- $(RM) $(libm_OUT)/{,*/,*/*/}*.{o,os,oS,a}
+$(libm_MOBJ_LD:.o=.os): $(libm_MSRC_LD)
+ $(compile.m)
+
+# spare us from adding a gazillion dummy two-liner files
+$(libm_MOBJ_FL:.o=.i): $(libm_MSRC_FL)
+ $(compile.mi)
+
+$(libm_MOBJ_LD:.o=.i): $(libm_MSRC_LD)
+ $(compile.mi)
+
+CLEAN_libm:
+ $(do_rm) $(addprefix $(libm_OUT)/,$(foreach e, o os oS a,$(foreach d, *. */*. */*/*.,$(d)$(e))))
diff --git a/libm/README b/libm/README
index 2c69a54af..306f03e40 100644
--- a/libm/README
+++ b/libm/README
@@ -13,4 +13,3 @@ is as follows:
It has been ported to work with uClibc and generally behave
by Erik Andersen <andersen@codepoet.org>
22 May, 2001
-
diff --git a/libm/carg.c b/libm/carg.c
index 7641d5dfe..305320d9c 100644
--- a/libm/carg.c
+++ b/libm/carg.c
@@ -14,20 +14,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 <complex.h>
#include <math.h>
-libm_hidden_proto(atan2)
-libm_hidden_proto(carg)
-
double
carg (__complex__ double x)
{
return atan2 (__imag__ x, __real__ x);
}
-
libm_hidden_def(carg)
diff --git a/libm/cexp.c b/libm/cexp.c
new file mode 100644
index 000000000..87512b7c5
--- /dev/null
+++ b/libm/cexp.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2011 William Pitcock <nenolod@dereferenced.org>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <features.h>
+#include <math.h>
+#include <complex.h>
+
+__complex__ double cexp(__complex__ double z)
+{
+ __complex__ double ret;
+ double r_exponent = exp(__real__ z);
+
+ __real__ ret = r_exponent * cos(__imag__ z);
+ __imag__ ret = r_exponent * sin(__imag__ z);
+
+ return ret;
+}
+libm_hidden_def(cexp)
+
+libm_hidden_proto(cexpf)
+__complex__ float cexpf(__complex__ float z)
+{
+ __complex__ float ret;
+ double r_exponent = exp(__real__ z);
+
+ __real__ ret = r_exponent * cosf(__imag__ z);
+ __imag__ ret = r_exponent * sinf(__imag__ z);
+
+ return ret;
+}
+libm_hidden_def(cexpf)
+
+#if defined __UCLIBC_HAS_LONG_DOUBLE_MATH__ && !defined __NO_LONG_DOUBLE_MATH
+libm_hidden_proto(cexpl)
+__complex__ long double cexpl(__complex__ long double z)
+{
+ __complex__ long double ret;
+ long double r_exponent = expl(__real__ z);
+
+ __real__ ret = r_exponent * cosl(__imag__ z);
+ __imag__ ret = r_exponent * sinl(__imag__ z);
+
+ return ret;
+}
+libm_hidden_def(cexpl)
+#endif
diff --git a/libm/e_acos.c b/libm/e_acos.c
index 265619325..acf10130e 100644
--- a/libm/e_acos.c
+++ b/libm/e_acos.c
@@ -1,4 +1,3 @@
-/* @(#)e_acos.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: e_acos.c,v 1.9 1995/05/12 04:57:13 jtc Exp $";
-#endif
-
/* __ieee754_acos(x)
* Method :
* acos(x) = pi/2 - asin(x)
@@ -41,11 +36,7 @@ static char rcsid[] = "$NetBSD: e_acos.c,v 1.9 1995/05/12 04:57:13 jtc Exp $";
#include "math.h"
#include "math_private.h"
-#ifdef __STDC__
static const double
-#else
-static double
-#endif
one= 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
pi = 3.14159265358979311600e+00, /* 0x400921FB, 0x54442D18 */
pio2_hi = 1.57079632679489655800e+00, /* 0x3FF921FB, 0x54442D18 */
@@ -61,12 +52,7 @@ qS2 = 2.02094576023350569471e+00, /* 0x40002AE5, 0x9C598AC8 */
qS3 = -6.88283971605453293030e-01, /* 0xBFE6066C, 0x1B8D0159 */
qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */
-#ifdef __STDC__
- double attribute_hidden __ieee754_acos(double x)
-#else
- double attribute_hidden __ieee754_acos(x)
- double x;
-#endif
+double __ieee754_acos(double x)
{
double z,p,q,r,w,s,c,df;
int32_t hx,ix;
@@ -109,3 +95,6 @@ qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */
return 2.0*(df+w);
}
}
+
+strong_alias(__ieee754_acos, acos)
+libm_hidden_def(acos)
diff --git a/libm/e_acosh.c b/libm/e_acosh.c
index d5e510eff..17e29c824 100644
--- a/libm/e_acosh.c
+++ b/libm/e_acosh.c
@@ -1,4 +1,3 @@
-/* @(#)e_acosh.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: e_acosh.c,v 1.9 1995/05/12 04:57:18 jtc Exp $";
-#endif
-
/* __ieee754_acosh(x)
* Method :
* Based on
@@ -31,23 +26,11 @@ static char rcsid[] = "$NetBSD: e_acosh.c,v 1.9 1995/05/12 04:57:18 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(log1p)
-libm_hidden_proto(sqrt)
-
-#ifdef __STDC__
static const double
-#else
-static double
-#endif
one = 1.0,
ln2 = 6.93147180559945286227e-01; /* 0x3FE62E42, 0xFEFA39EF */
-#ifdef __STDC__
- double attribute_hidden __ieee754_acosh(double x)
-#else
- double attribute_hidden __ieee754_acosh(x)
- double x;
-#endif
+double __ieee754_acosh(double x)
{
double t;
int32_t hx;
@@ -70,3 +53,6 @@ ln2 = 6.93147180559945286227e-01; /* 0x3FE62E42, 0xFEFA39EF */
return log1p(t+sqrt(2.0*t+t*t));
}
}
+
+strong_alias(__ieee754_acosh, acosh)
+libm_hidden_def(acosh)
diff --git a/libm/e_asin.c b/libm/e_asin.c
index 8a639771b..1441acb3d 100644
--- a/libm/e_asin.c
+++ b/libm/e_asin.c
@@ -1,4 +1,3 @@
-/* @(#)e_asin.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: e_asin.c,v 1.9 1995/05/12 04:57:22 jtc Exp $";
-#endif
-
/* __ieee754_asin(x)
* Method :
* Since asin(x) = x + x^3/6 + x^5*3/40 + x^7*15/336 + ...
@@ -44,17 +39,10 @@ static char rcsid[] = "$NetBSD: e_asin.c,v 1.9 1995/05/12 04:57:22 jtc Exp $";
*
*/
-
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(fabs)
-
-#ifdef __STDC__
static const double
-#else
-static double
-#endif
one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
huge = 1.000e+300,
pio2_hi = 1.57079632679489655800e+00, /* 0x3FF921FB, 0x54442D18 */
@@ -72,12 +60,7 @@ qS2 = 2.02094576023350569471e+00, /* 0x40002AE5, 0x9C598AC8 */
qS3 = -6.88283971605453293030e-01, /* 0xBFE6066C, 0x1B8D0159 */
qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */
-#ifdef __STDC__
- double attribute_hidden __ieee754_asin(double x)
-#else
- double attribute_hidden __ieee754_asin(x)
- double x;
-#endif
+double __ieee754_asin(double x)
{
double t=0.0,w,p,q,c,r,s;
int32_t hx,ix;
@@ -121,3 +104,6 @@ qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */
}
if(hx>0) return t; else return -t;
}
+
+strong_alias(__ieee754_asin, asin)
+libm_hidden_def(asin)
diff --git a/libm/e_atan2.c b/libm/e_atan2.c
index 7bb38da81..ef379aa7a 100644
--- a/libm/e_atan2.c
+++ b/libm/e_atan2.c
@@ -1,4 +1,3 @@
-/* @(#)e_atan2.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: e_atan2.c,v 1.8 1995/05/10 20:44:51 jtc Exp $";
-#endif
-
/* __ieee754_atan2(y,x)
* Method :
* 1. Reduce y to positive by atan2(y,x)=-atan2(-y,x).
@@ -44,14 +39,7 @@ static char rcsid[] = "$NetBSD: e_atan2.c,v 1.8 1995/05/10 20:44:51 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(atan)
-libm_hidden_proto(fabs)
-
-#ifdef __STDC__
static const double
-#else
-static double
-#endif
tiny = 1.0e-300,
zero = 0.0,
pi_o_4 = 7.8539816339744827900E-01, /* 0x3FE921FB, 0x54442D18 */
@@ -59,12 +47,7 @@ pi_o_2 = 1.5707963267948965580E+00, /* 0x3FF921FB, 0x54442D18 */
pi = 3.1415926535897931160E+00, /* 0x400921FB, 0x54442D18 */
pi_lo = 1.2246467991473531772E-16; /* 0x3CA1A626, 0x33145C07 */
-#ifdef __STDC__
- double attribute_hidden __ieee754_atan2(double y, double x)
-#else
- double attribute_hidden __ieee754_atan2(y,x)
- double y,x;
-#endif
+double __ieee754_atan2(double y, double x)
{
double z;
int32_t k,m,hx,hy,ix,iy;
@@ -131,3 +114,6 @@ pi_lo = 1.2246467991473531772E-16; /* 0x3CA1A626, 0x33145C07 */
return (z-pi_lo)-pi;/* atan(-,-) */
}
}
+
+strong_alias(__ieee754_atan2, atan2)
+libm_hidden_def(atan2)
diff --git a/libm/e_atanh.c b/libm/e_atanh.c
index cfbe02bed..fb36a1af1 100644
--- a/libm/e_atanh.c
+++ b/libm/e_atanh.c
@@ -1,4 +1,3 @@
-/* @(#)e_atanh.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: e_atanh.c,v 1.8 1995/05/10 20:44:55 jtc Exp $";
-#endif
-
/* __ieee754_atanh(x)
* Method :
* 1.Reduced x to positive by atanh(-x) = -atanh(x)
@@ -35,26 +30,11 @@ static char rcsid[] = "$NetBSD: e_atanh.c,v 1.8 1995/05/10 20:44:55 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(log1p)
-
-#ifdef __STDC__
static const double one = 1.0, huge = 1e300;
-#else
-static double one = 1.0, huge = 1e300;
-#endif
-#ifdef __STDC__
static const double zero = 0.0;
-#else
-static double zero = 0.0;
-#endif
-#ifdef __STDC__
- double attribute_hidden __ieee754_atanh(double x)
-#else
- double attribute_hidden __ieee754_atanh(x)
- double x;
-#endif
+double __ieee754_atanh(double x)
{
double t;
int32_t hx,ix;
@@ -74,3 +54,6 @@ static double zero = 0.0;
t = 0.5*log1p((x+x)/(one-x));
if(hx>=0) return t; else return -t;
}
+
+strong_alias(__ieee754_atanh, atanh)
+libm_hidden_def(atanh)
diff --git a/libm/e_cosh.c b/libm/e_cosh.c
index aa25eefcb..a8e34aa45 100644
--- a/libm/e_cosh.c
+++ b/libm/e_cosh.c
@@ -1,4 +1,3 @@
-/* @(#)e_cosh.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: e_cosh.c,v 1.7 1995/05/10 20:44:58 jtc Exp $";
-#endif
-
/* __ieee754_cosh(x)
* Method :
* mathematically cosh(x) if defined to be (exp(x)+exp(-x))/2
@@ -38,21 +33,9 @@ static char rcsid[] = "$NetBSD: e_cosh.c,v 1.7 1995/05/10 20:44:58 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(expm1)
-libm_hidden_proto(fabs)
-
-#ifdef __STDC__
static const double one = 1.0, half=0.5, huge = 1.0e300;
-#else
-static double one = 1.0, half=0.5, huge = 1.0e300;
-#endif
-#ifdef __STDC__
- double attribute_hidden __ieee754_cosh(double x)
-#else
- double attribute_hidden __ieee754_cosh(x)
- double x;
-#endif
+double __ieee754_cosh(double x)
{
double t,w;
int32_t ix;
@@ -94,3 +77,6 @@ static double one = 1.0, half=0.5, huge = 1.0e300;
/* |x| > overflowthresold, cosh(x) overflow */
return huge*huge;
}
+
+strong_alias(__ieee754_cosh, cosh)
+libm_hidden_def(cosh)
diff --git a/libm/e_exp.c b/libm/e_exp.c
index f9c5371d9..ce958d111 100644
--- a/libm/e_exp.c
+++ b/libm/e_exp.c
@@ -1,4 +1,3 @@
-/* @(#)e_exp.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: e_exp.c,v 1.8 1995/05/10 20:45:03 jtc Exp $";
-#endif
-
/* __ieee754_exp(x)
* Returns the exponential of x.
*
@@ -80,11 +75,7 @@ static char rcsid[] = "$NetBSD: e_exp.c,v 1.8 1995/05/10 20:45:03 jtc Exp $";
#include "math.h"
#include "math_private.h"
-#ifdef __STDC__
static const double
-#else
-static double
-#endif
one = 1.0,
halF[2] = {0.5,-0.5,},
huge = 1.0e+300,
@@ -102,13 +93,7 @@ P3 = 6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */
P4 = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */
P5 = 4.13813679705723846039e-08; /* 0x3E663769, 0x72BEA4D0 */
-
-#ifdef __STDC__
- double attribute_hidden __ieee754_exp(double x) /* default IEEE double exp */
-#else
- double attribute_hidden __ieee754_exp(x) /* default IEEE double exp */
- double x;
-#endif
+double __ieee754_exp(double x) /* default IEEE double exp */
{
double y;
double hi = 0.0;
@@ -170,3 +155,6 @@ P5 = 4.13813679705723846039e-08; /* 0x3E663769, 0x72BEA4D0 */
return y*twom1000;
}
}
+
+strong_alias(__ieee754_exp, exp)
+libm_hidden_def(exp)
diff --git a/libm/e_exp10.c b/libm/e_exp10.c
new file mode 100644
index 000000000..f0ee87809
--- /dev/null
+++ b/libm/e_exp10.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1998-2015 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 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/>. */
+
+#include "math.h"
+#include "math_private.h"
+#include <float.h>
+
+double __ieee754_exp10 (double arg)
+{
+ if (isfinite (arg) && arg < DBL_MIN_10_EXP - DBL_DIG - 10)
+ return DBL_MIN * DBL_MIN;
+ else
+ /* This is a very stupid and inprecise implementation. It'll get
+ replaced sometime (soon?). */
+ return __ieee754_exp (M_LN10 * arg);
+}
+strong_alias(__ieee754_exp10, exp10)
+libm_hidden_def(exp10)
diff --git a/libm/e_fmod.c b/libm/e_fmod.c
index 1e8487cf0..7857854f8 100644
--- a/libm/e_fmod.c
+++ b/libm/e_fmod.c
@@ -1,4 +1,3 @@
-/* @(#)e_fmod.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: e_fmod.c,v 1.8 1995/05/10 20:45:07 jtc Exp $";
-#endif
-
/*
* __ieee754_fmod(x,y)
* Return x mod y in exact arithmetic
@@ -23,18 +18,9 @@ static char rcsid[] = "$NetBSD: e_fmod.c,v 1.8 1995/05/10 20:45:07 jtc Exp $";
#include "math.h"
#include "math_private.h"
-#ifdef __STDC__
static const double one = 1.0, Zero[] = {0.0, -0.0,};
-#else
-static double one = 1.0, Zero[] = {0.0, -0.0,};
-#endif
-#ifdef __STDC__
- double attribute_hidden __ieee754_fmod(double x, double y)
-#else
- double attribute_hidden __ieee754_fmod(x,y)
- double x,y ;
-#endif
+double __ieee754_fmod(double x, double y)
{
int32_t n,hx,hy,hz,ix,iy,sx,i;
u_int32_t lx,ly,lz;
@@ -138,3 +124,6 @@ static double one = 1.0, Zero[] = {0.0, -0.0,};
}
return x; /* exact output */
}
+
+strong_alias(__ieee754_fmod, fmod)
+libm_hidden_def(fmod)
diff --git a/libm/e_gamma_r.c b/libm/e_gamma_r.c
deleted file mode 100644
index 36b0d45d6..000000000
--- a/libm/e_gamma_r.c
+++ /dev/null
@@ -1,33 +0,0 @@
-
-/* @(#)e_gamma_r.c 5.1 93/09/24 */
-/*
- * ====================================================
- * 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.
- * ====================================================
- *
- */
-
-/* __ieee754_gamma_r(x, signgamp)
- * Reentrant version of the logarithm of the Gamma function
- * with user provide pointer for the sign of Gamma(x).
- *
- * Method: See __ieee754_lgamma_r
- */
-
-#include "math_private.h"
-
-#ifdef __STDC__
- //__private_extern__
- double attribute_hidden __ieee754_gamma_r(double x, int *signgamp)
-#else
- double attribute_hidden __ieee754_gamma_r(x,signgamp)
- double x; int *signgamp;
-#endif
-{
- return __ieee754_lgamma_r(x,signgamp);
-}
diff --git a/libm/e_hypot.c b/libm/e_hypot.c
index 62acc8d03..cd63b73ae 100644
--- a/libm/e_hypot.c
+++ b/libm/e_hypot.c
@@ -1,4 +1,3 @@
-/* @(#)e_hypot.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: e_hypot.c,v 1.9 1995/05/12 04:57:27 jtc Exp $";
-#endif
-
/* __ieee754_hypot(x,y)
*
* Method :
@@ -49,14 +44,9 @@ static char rcsid[] = "$NetBSD: e_hypot.c,v 1.9 1995/05/12 04:57:27 jtc Exp $";
#include "math.h"
#include "math_private.h"
-#ifdef __STDC__
- double attribute_hidden __ieee754_hypot(double x, double y)
-#else
- double attribute_hidden __ieee754_hypot(x,y)
- double x, y;
-#endif
+double __ieee754_hypot(double x, double y)
{
- double a=x,b=y,t1,t2,y1,y2,w;
+ double a=x,b=y,t1,t2,_y1,y2,w;
int32_t j,k,ha,hb;
GET_HIGH_WORD(ha,x);
@@ -110,13 +100,13 @@ static char rcsid[] = "$NetBSD: e_hypot.c,v 1.9 1995/05/12 04:57:27 jtc Exp $";
w = __ieee754_sqrt(t1*t1-(b*(-b)-t2*(a+t1)));
} else {
a = a+a;
- y1 = 0;
- SET_HIGH_WORD(y1,hb);
- y2 = b - y1;
+ _y1 = 0;
+ SET_HIGH_WORD(_y1,hb);
+ y2 = b - _y1;
t1 = 0;
SET_HIGH_WORD(t1,ha+0x00100000);
t2 = a - t1;
- w = __ieee754_sqrt(t1*y1-(w*(-w)-(t1*y2+t2*b)));
+ w = __ieee754_sqrt(t1*_y1-(w*(-w)-(t1*y2+t2*b)));
}
if(k!=0) {
u_int32_t high;
@@ -126,3 +116,6 @@ static char rcsid[] = "$NetBSD: e_hypot.c,v 1.9 1995/05/12 04:57:27 jtc Exp $";
return t1*w;
} else return w;
}
+
+strong_alias(__ieee754_hypot, hypot)
+libm_hidden_def(hypot)
diff --git a/libm/e_j0.c b/libm/e_j0.c
index 74defacdf..f740d1902 100644
--- a/libm/e_j0.c
+++ b/libm/e_j0.c
@@ -1,4 +1,3 @@
-/* @(#)e_j0.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: e_j0.c,v 1.8 1995/05/10 20:45:23 jtc Exp $";
-#endif
-
/* __ieee754_j0(x), __ieee754_y0(x)
* Bessel function of the first and second kinds of order zero.
* Method -- j0(x):
@@ -62,22 +57,9 @@ static char rcsid[] = "$NetBSD: e_j0.c,v 1.8 1995/05/10 20:45:23 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(sin)
-libm_hidden_proto(cos)
-libm_hidden_proto(sqrt)
-libm_hidden_proto(fabs)
-
-#ifdef __STDC__
static double pzero(double), qzero(double);
-#else
-static double pzero(), qzero();
-#endif
-#ifdef __STDC__
static const double
-#else
-static double
-#endif
huge = 1e300,
one = 1.0,
invsqrtpi= 5.64189583547756279280e-01, /* 0x3FE20DD7, 0x50429B6D */
@@ -92,18 +74,9 @@ S02 = 1.16926784663337450260e-04, /* 0x3F1EA6D2, 0xDD57DBF4 */
S03 = 5.13546550207318111446e-07, /* 0x3EA13B54, 0xCE84D5A9 */
S04 = 1.16614003333790000205e-09; /* 0x3E1408BC, 0xF4745D8F */
-#ifdef __STDC__
static const double zero = 0.0;
-#else
-static double zero = 0.0;
-#endif
-#ifdef __STDC__
- double attribute_hidden __ieee754_j0(double x)
-#else
- double attribute_hidden __ieee754_j0(x)
- double x;
-#endif
+double __ieee754_j0(double x)
{
double z, s,c,ss,cc,r,u,v;
int32_t hx,ix;
@@ -150,11 +123,9 @@ static double zero = 0.0;
}
}
-#ifdef __STDC__
+strong_alias(__ieee754_j0, j0)
+
static const double
-#else
-static double
-#endif
u00 = -7.38042951086872317523e-02, /* 0xBFB2E4D6, 0x99CBD01F */
u01 = 1.76666452509181115538e-01, /* 0x3FC69D01, 0x9DE9E3FC */
u02 = -1.38185671945596898896e-02, /* 0xBF8C4CE8, 0xB16CFA97 */
@@ -167,12 +138,7 @@ v02 = 7.60068627350353253702e-05, /* 0x3F13ECBB, 0xF578C6C1 */
v03 = 2.59150851840457805467e-07, /* 0x3E91642D, 0x7FF202FD */
v04 = 4.41110311332675467403e-10; /* 0x3DFE5018, 0x3BD6D9EF */
-#ifdef __STDC__
- double attribute_hidden __ieee754_y0(double x)
-#else
- double attribute_hidden __ieee754_y0(x)
- double x;
-#endif
+double __ieee754_y0(double x)
{
double z, s,c,ss,cc,u,v;
int32_t hx,ix,lx;
@@ -224,6 +190,8 @@ v04 = 4.41110311332675467403e-10; /* 0x3DFE5018, 0x3BD6D9EF */
return(u/v + tpi*(__ieee754_j0(x)*__ieee754_log(x)));
}
+strong_alias(__ieee754_y0, y0)
+
/* The asymptotic expansions of pzero is
* 1 - 9/128 s^2 + 11025/98304 s^4 - ..., where s = 1/x.
* For x >= 2, We approximate pzero by
@@ -233,11 +201,7 @@ v04 = 4.41110311332675467403e-10; /* 0x3DFE5018, 0x3BD6D9EF */
* and
* | pzero(x)-1-R/S | <= 2 ** ( -60.26)
*/
-#ifdef __STDC__
static const double pR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
-#else
-static double pR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
-#endif
0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */
-7.03124999999900357484e-02, /* 0xBFB1FFFF, 0xFFFFFD32 */
-8.08167041275349795626e+00, /* 0xC02029D0, 0xB44FA779 */
@@ -245,11 +209,7 @@ static double pR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
-2.48521641009428822144e+03, /* 0xC0A36A6E, 0xCD4DCAFC */
-5.25304380490729545272e+03, /* 0xC0B4850B, 0x36CC643D */
};
-#ifdef __STDC__
static const double pS8[5] = {
-#else
-static double pS8[5] = {
-#endif
1.16534364619668181717e+02, /* 0x405D2233, 0x07A96751 */
3.83374475364121826715e+03, /* 0x40ADF37D, 0x50596938 */
4.05978572648472545552e+04, /* 0x40E3D2BB, 0x6EB6B05F */
@@ -257,11 +217,7 @@ static double pS8[5] = {
4.76277284146730962675e+04, /* 0x40E74177, 0x4F2C49DC */
};
-#ifdef __STDC__
static const double pR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
-#else
-static double pR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
-#endif
-1.14125464691894502584e-11, /* 0xBDA918B1, 0x47E495CC */
-7.03124940873599280078e-02, /* 0xBFB1FFFF, 0xE69AFBC6 */
-4.15961064470587782438e+00, /* 0xC010A370, 0xF90C6BBF */
@@ -269,11 +225,7 @@ static double pR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
-3.31231299649172967747e+02, /* 0xC074B3B3, 0x6742CC63 */
-3.46433388365604912451e+02, /* 0xC075A6EF, 0x28A38BD7 */
};
-#ifdef __STDC__
static const double pS5[5] = {
-#else
-static double pS5[5] = {
-#endif
6.07539382692300335975e+01, /* 0x404E6081, 0x0C98C5DE */
1.05125230595704579173e+03, /* 0x40906D02, 0x5C7E2864 */
5.97897094333855784498e+03, /* 0x40B75AF8, 0x8FBE1D60 */
@@ -281,11 +233,7 @@ static double pS5[5] = {
2.40605815922939109441e+03, /* 0x40A2CC1D, 0xC70BE864 */
};
-#ifdef __STDC__
static const double pR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
-#else
-static double pR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
-#endif
-2.54704601771951915620e-09, /* 0xBE25E103, 0x6FE1AA86 */
-7.03119616381481654654e-02, /* 0xBFB1FFF6, 0xF7C0E24B */
-2.40903221549529611423e+00, /* 0xC00345B2, 0xAEA48074 */
@@ -293,11 +241,7 @@ static double pR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
-5.80791704701737572236e+01, /* 0xC04D0A22, 0x420A1A45 */
-3.14479470594888503854e+01, /* 0xC03F72AC, 0xA892D80F */
};
-#ifdef __STDC__
static const double pS3[5] = {
-#else
-static double pS3[5] = {
-#endif
3.58560338055209726349e+01, /* 0x4041ED92, 0x84077DD3 */
3.61513983050303863820e+02, /* 0x40769839, 0x464A7C0E */
1.19360783792111533330e+03, /* 0x4092A66E, 0x6D1061D6 */
@@ -305,11 +249,7 @@ static double pS3[5] = {
1.73580930813335754692e+02, /* 0x4065B296, 0xFC379081 */
};
-#ifdef __STDC__
static const double pR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
-#else
-static double pR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
-#endif
-8.87534333032526411254e-08, /* 0xBE77D316, 0xE927026D */
-7.03030995483624743247e-02, /* 0xBFB1FF62, 0x495E1E42 */
-1.45073846780952986357e+00, /* 0xBFF73639, 0x8A24A843 */
@@ -317,11 +257,7 @@ static double pR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
-1.11931668860356747786e+01, /* 0xC02662E6, 0xC5246303 */
-3.23364579351335335033e+00, /* 0xC009DE81, 0xAF8FE70F */
};
-#ifdef __STDC__
static const double pS2[5] = {
-#else
-static double pS2[5] = {
-#endif
2.22202997532088808441e+01, /* 0x40363865, 0x908B5959 */
1.36206794218215208048e+02, /* 0x4061069E, 0x0EE8878F */
2.70470278658083486789e+02, /* 0x4070E786, 0x42EA079B */
@@ -329,18 +265,9 @@ static double pS2[5] = {
1.46576176948256193810e+01, /* 0x402D50B3, 0x44391809 */
};
-#ifdef __STDC__
- static double pzero(double x)
-#else
- static double pzero(x)
- double x;
-#endif
+static double pzero(double x)
{
-#ifdef __STDC__
const double *p = 0,*q = 0;
-#else
- double *p,*q;
-#endif
double z,r,s;
int32_t ix;
GET_HIGH_WORD(ix,x);
@@ -365,11 +292,7 @@ static double pS2[5] = {
* and
* | qzero(x)/s +1.25-R/S | <= 2 ** ( -61.22)
*/
-#ifdef __STDC__
static const double qR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
-#else
-static double qR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
-#endif
0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */
7.32421874999935051953e-02, /* 0x3FB2BFFF, 0xFFFFFE2C */
1.17682064682252693899e+01, /* 0x40278952, 0x5BB334D6 */
@@ -377,11 +300,7 @@ static double qR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
8.85919720756468632317e+03, /* 0x40C14D99, 0x3E18F46D */
3.70146267776887834771e+04, /* 0x40E212D4, 0x0E901566 */
};
-#ifdef __STDC__
static const double qS8[6] = {
-#else
-static double qS8[6] = {
-#endif
1.63776026895689824414e+02, /* 0x406478D5, 0x365B39BC */
8.09834494656449805916e+03, /* 0x40BFA258, 0x4E6B0563 */
1.42538291419120476348e+05, /* 0x41016652, 0x54D38C3F */
@@ -390,11 +309,7 @@ static double qS8[6] = {
-3.43899293537866615225e+05, /* 0xC114FD6D, 0x2C9530C5 */
};
-#ifdef __STDC__
static const double qR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
-#else
-static double qR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
-#endif
1.84085963594515531381e-11, /* 0x3DB43D8F, 0x29CC8CD9 */
7.32421766612684765896e-02, /* 0x3FB2BFFF, 0xD172B04C */
5.83563508962056953777e+00, /* 0x401757B0, 0xB9953DD3 */
@@ -402,11 +317,7 @@ static double qR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
1.02724376596164097464e+03, /* 0x40900CF9, 0x9DC8C481 */
1.98997785864605384631e+03, /* 0x409F17E9, 0x53C6E3A6 */
};
-#ifdef __STDC__
static const double qS5[6] = {
-#else
-static double qS5[6] = {
-#endif
8.27766102236537761883e+01, /* 0x4054B1B3, 0xFB5E1543 */
2.07781416421392987104e+03, /* 0x40A03BA0, 0xDA21C0CE */
1.88472887785718085070e+04, /* 0x40D267D2, 0x7B591E6D */
@@ -415,11 +326,7 @@ static double qS5[6] = {
-5.35434275601944773371e+03, /* 0xC0B4EA57, 0xBEDBC609 */
};
-#ifdef __STDC__
static const double qR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
-#else
-static double qR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
-#endif
4.37741014089738620906e-09, /* 0x3E32CD03, 0x6ADECB82 */
7.32411180042911447163e-02, /* 0x3FB2BFEE, 0x0E8D0842 */
3.34423137516170720929e+00, /* 0x400AC0FC, 0x61149CF5 */
@@ -427,11 +334,7 @@ static double qR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
1.70808091340565596283e+02, /* 0x406559DB, 0xE25EFD1F */
1.66733948696651168575e+02, /* 0x4064D77C, 0x81FA21E0 */
};
-#ifdef __STDC__
static const double qS3[6] = {
-#else
-static double qS3[6] = {
-#endif
4.87588729724587182091e+01, /* 0x40486122, 0xBFE343A6 */
7.09689221056606015736e+02, /* 0x40862D83, 0x86544EB3 */
3.70414822620111362994e+03, /* 0x40ACF04B, 0xE44DFC63 */
@@ -440,11 +343,7 @@ static double qS3[6] = {
-1.49247451836156386662e+02, /* 0xC062A7EB, 0x201CF40F */
};
-#ifdef __STDC__
static const double qR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
-#else
-static double qR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
-#endif
1.50444444886983272379e-07, /* 0x3E84313B, 0x54F76BDB */
7.32234265963079278272e-02, /* 0x3FB2BEC5, 0x3E883E34 */
1.99819174093815998816e+00, /* 0x3FFFF897, 0xE727779C */
@@ -452,11 +351,7 @@ static double qR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
3.16662317504781540833e+01, /* 0x403FAA8E, 0x29FBDC4A */
1.62527075710929267416e+01, /* 0x403040B1, 0x71814BB4 */
};
-#ifdef __STDC__
static const double qS2[6] = {
-#else
-static double qS2[6] = {
-#endif
3.03655848355219184498e+01, /* 0x403E5D96, 0xF7C07AED */
2.69348118608049844624e+02, /* 0x4070D591, 0xE4D14B40 */
8.44783757595320139444e+02, /* 0x408A6645, 0x22B3BF22 */
@@ -465,18 +360,9 @@ static double qS2[6] = {
-5.31095493882666946917e+00, /* 0xC0153E6A, 0xF8B32931 */
};
-#ifdef __STDC__
- static double qzero(double x)
-#else
- static double qzero(x)
- double x;
-#endif
+static double qzero(double x)
{
-#ifdef __STDC__
const double *p=0,*q=0;
-#else
- double *p,*q;
-#endif
double s,r,z;
int32_t ix;
GET_HIGH_WORD(ix,x);
diff --git a/libm/e_j1.c b/libm/e_j1.c
index bb3e650eb..78754b4c1 100644
--- a/libm/e_j1.c
+++ b/libm/e_j1.c
@@ -1,4 +1,3 @@
-/* @(#)e_j1.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: e_j1.c,v 1.8 1995/05/10 20:45:27 jtc Exp $";
-#endif
-
/* __ieee754_j1(x), __ieee754_y1(x)
* Bessel function of the first and second kinds of order zero.
* Method -- j1(x):
@@ -62,22 +57,9 @@ static char rcsid[] = "$NetBSD: e_j1.c,v 1.8 1995/05/10 20:45:27 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(sin)
-libm_hidden_proto(cos)
-libm_hidden_proto(sqrt)
-libm_hidden_proto(fabs)
-
-#ifdef __STDC__
static double pone(double), qone(double);
-#else
-static double pone(), qone();
-#endif
-#ifdef __STDC__
static const double
-#else
-static double
-#endif
huge = 1e300,
one = 1.0,
invsqrtpi= 5.64189583547756279280e-01, /* 0x3FE20DD7, 0x50429B6D */
@@ -93,18 +75,9 @@ s03 = 1.17718464042623683263e-06, /* 0x3EB3BFF8, 0x333F8498 */
s04 = 5.04636257076217042715e-09, /* 0x3E35AC88, 0xC97DFF2C */
s05 = 1.23542274426137913908e-11; /* 0x3DAB2ACF, 0xCFB97ED8 */
-#ifdef __STDC__
static const double zero = 0.0;
-#else
-static double zero = 0.0;
-#endif
-#ifdef __STDC__
- double attribute_hidden __ieee754_j1(double x)
-#else
- double attribute_hidden __ieee754_j1(x)
- double x;
-#endif
+double __ieee754_j1(double x)
{
double z, s,c,ss,cc,r,u,v,y;
int32_t hx,ix;
@@ -145,22 +118,16 @@ static double zero = 0.0;
return(x*0.5+r/s);
}
-#ifdef __STDC__
+strong_alias(__ieee754_j1, j1)
+
static const double U0[5] = {
-#else
-static double U0[5] = {
-#endif
-1.96057090646238940668e-01, /* 0xBFC91866, 0x143CBC8A */
5.04438716639811282616e-02, /* 0x3FA9D3C7, 0x76292CD1 */
-1.91256895875763547298e-03, /* 0xBF5F55E5, 0x4844F50F */
2.35252600561610495928e-05, /* 0x3EF8AB03, 0x8FA6B88E */
-9.19099158039878874504e-08, /* 0xBE78AC00, 0x569105B8 */
};
-#ifdef __STDC__
static const double V0[5] = {
-#else
-static double V0[5] = {
-#endif
1.99167318236649903973e-02, /* 0x3F94650D, 0x3F4DA9F0 */
2.02552581025135171496e-04, /* 0x3F2A8C89, 0x6C257764 */
1.35608801097516229404e-06, /* 0x3EB6C05A, 0x894E8CA6 */
@@ -168,12 +135,7 @@ static double V0[5] = {
1.66559246207992079114e-11, /* 0x3DB25039, 0xDACA772A */
};
-#ifdef __STDC__
- double attribute_hidden __ieee754_y1(double x)
-#else
- double attribute_hidden __ieee754_y1(x)
- double x;
-#endif
+double __ieee754_y1(double x)
{
double z, s,c,ss,cc,u,v;
int32_t hx,ix,lx;
@@ -221,6 +183,8 @@ static double V0[5] = {
return(x*(u/v) + tpi*(__ieee754_j1(x)*__ieee754_log(x)-one/x));
}
+strong_alias(__ieee754_y1, y1)
+
/* For x >= 8, the asymptotic expansions of pone is
* 1 + 15/128 s^2 - 4725/2^15 s^4 - ..., where s = 1/x.
* We approximate pone by
@@ -231,11 +195,7 @@ static double V0[5] = {
* | pone(x)-1-R/S | <= 2 ** ( -60.06)
*/
-#ifdef __STDC__
static const double pr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
-#else
-static double pr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
-#endif
0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */
1.17187499999988647970e-01, /* 0x3FBDFFFF, 0xFFFFFCCE */
1.32394806593073575129e+01, /* 0x402A7A9D, 0x357F7FCE */
@@ -243,11 +203,7 @@ static double pr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
3.87474538913960532227e+03, /* 0x40AE457D, 0xA3A532CC */
7.91447954031891731574e+03, /* 0x40BEEA7A, 0xC32782DD */
};
-#ifdef __STDC__
static const double ps8[5] = {
-#else
-static double ps8[5] = {
-#endif
1.14207370375678408436e+02, /* 0x405C8D45, 0x8E656CAC */
3.65093083420853463394e+03, /* 0x40AC85DC, 0x964D274F */
3.69562060269033463555e+04, /* 0x40E20B86, 0x97C5BB7F */
@@ -255,11 +211,7 @@ static double ps8[5] = {
3.08042720627888811578e+04, /* 0x40DE1511, 0x697A0B2D */
};
-#ifdef __STDC__
static const double pr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
-#else
-static double pr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
-#endif
1.31990519556243522749e-11, /* 0x3DAD0667, 0xDAE1CA7D */
1.17187493190614097638e-01, /* 0x3FBDFFFF, 0xE2C10043 */
6.80275127868432871736e+00, /* 0x401B3604, 0x6E6315E3 */
@@ -267,11 +219,7 @@ static double pr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
5.17636139533199752805e+02, /* 0x40802D16, 0xD052D649 */
5.28715201363337541807e+02, /* 0x408085B8, 0xBB7E0CB7 */
};
-#ifdef __STDC__
static const double ps5[5] = {
-#else
-static double ps5[5] = {
-#endif
5.92805987221131331921e+01, /* 0x404DA3EA, 0xA8AF633D */
9.91401418733614377743e+02, /* 0x408EFB36, 0x1B066701 */
5.35326695291487976647e+03, /* 0x40B4E944, 0x5706B6FB */
@@ -279,11 +227,7 @@ static double ps5[5] = {
1.50404688810361062679e+03, /* 0x40978030, 0x036F5E51 */
};
-#ifdef __STDC__
static const double pr3[6] = {
-#else
-static double pr3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
-#endif
3.02503916137373618024e-09, /* 0x3E29FC21, 0xA7AD9EDD */
1.17186865567253592491e-01, /* 0x3FBDFFF5, 0x5B21D17B */
3.93297750033315640650e+00, /* 0x400F76BC, 0xE85EAD8A */
@@ -291,11 +235,7 @@ static double pr3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
9.10550110750781271918e+01, /* 0x4056C385, 0x4D2C1837 */
4.85590685197364919645e+01, /* 0x4048478F, 0x8EA83EE5 */
};
-#ifdef __STDC__
static const double ps3[5] = {
-#else
-static double ps3[5] = {
-#endif
3.47913095001251519989e+01, /* 0x40416549, 0xA134069C */
3.36762458747825746741e+02, /* 0x40750C33, 0x07F1A75F */
1.04687139975775130551e+03, /* 0x40905B7C, 0x5037D523 */
@@ -303,11 +243,7 @@ static double ps3[5] = {
1.03787932439639277504e+02, /* 0x4059F26D, 0x7C2EED53 */
};
-#ifdef __STDC__
static const double pr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
-#else
-static double pr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
-#endif
1.07710830106873743082e-07, /* 0x3E7CE9D4, 0xF65544F4 */
1.17176219462683348094e-01, /* 0x3FBDFF42, 0xBE760D83 */
2.36851496667608785174e+00, /* 0x4002F2B7, 0xF98FAEC0 */
@@ -315,11 +251,7 @@ static double pr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
1.76939711271687727390e+01, /* 0x4031B1A8, 0x177F8EE2 */
5.07352312588818499250e+00, /* 0x40144B49, 0xA574C1FE */
};
-#ifdef __STDC__
static const double ps2[5] = {
-#else
-static double ps2[5] = {
-#endif
2.14364859363821409488e+01, /* 0x40356FBD, 0x8AD5ECDC */
1.25290227168402751090e+02, /* 0x405F5293, 0x14F92CD5 */
2.32276469057162813669e+02, /* 0x406D08D8, 0xD5A2DBD9 */
@@ -327,18 +259,9 @@ static double ps2[5] = {
8.36463893371618283368e+00, /* 0x4020BAB1, 0xF44E5192 */
};
-#ifdef __STDC__
- static double pone(double x)
-#else
- static double pone(x)
- double x;
-#endif
+static double pone(double x)
{
-#ifdef __STDC__
const double *p=0,*q=0;
-#else
- double *p,*q;
-#endif
double z,r,s;
int32_t ix;
GET_HIGH_WORD(ix,x);
@@ -364,11 +287,7 @@ static double ps2[5] = {
* | qone(x)/s -0.375-R/S | <= 2 ** ( -61.13)
*/
-#ifdef __STDC__
static const double qr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
-#else
-static double qr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
-#endif
0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */
-1.02539062499992714161e-01, /* 0xBFBA3FFF, 0xFFFFFDF3 */
-1.62717534544589987888e+01, /* 0xC0304591, 0xA26779F7 */
@@ -376,11 +295,7 @@ static double qr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */
-1.18498066702429587167e+04, /* 0xC0C724E7, 0x40F87415 */
-4.84385124285750353010e+04, /* 0xC0E7A6D0, 0x65D09C6A */
};
-#ifdef __STDC__
static const double qs8[6] = {
-#else
-static double qs8[6] = {
-#endif
1.61395369700722909556e+02, /* 0x40642CA6, 0xDE5BCDE5 */
7.82538599923348465381e+03, /* 0x40BE9162, 0xD0D88419 */
1.33875336287249578163e+05, /* 0x4100579A, 0xB0B75E98 */
@@ -389,11 +304,7 @@ static double qs8[6] = {
-2.94490264303834643215e+05, /* 0xC111F969, 0x0EA5AA18 */
};
-#ifdef __STDC__
static const double qr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
-#else
-static double qr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
-#endif
-2.08979931141764104297e-11, /* 0xBDB6FA43, 0x1AA1A098 */
-1.02539050241375426231e-01, /* 0xBFBA3FFF, 0xCB597FEF */
-8.05644828123936029840e+00, /* 0xC0201CE6, 0xCA03AD4B */
@@ -401,11 +312,7 @@ static double qr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */
-1.37319376065508163265e+03, /* 0xC09574C6, 0x6931734F */
-2.61244440453215656817e+03, /* 0xC0A468E3, 0x88FDA79D */
};
-#ifdef __STDC__
static const double qs5[6] = {
-#else
-static double qs5[6] = {
-#endif
8.12765501384335777857e+01, /* 0x405451B2, 0xFF5A11B2 */
1.99179873460485964642e+03, /* 0x409F1F31, 0xE77BF839 */
1.74684851924908907677e+04, /* 0x40D10F1F, 0x0D64CE29 */
@@ -414,11 +321,7 @@ static double qs5[6] = {
-4.71918354795128470869e+03, /* 0xC0B26F2E, 0xFCFFA004 */
};
-#ifdef __STDC__
static const double qr3[6] = {
-#else
-static double qr3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
-#endif
-5.07831226461766561369e-09, /* 0xBE35CFA9, 0xD38FC84F */
-1.02537829820837089745e-01, /* 0xBFBA3FEB, 0x51AEED54 */
-4.61011581139473403113e+00, /* 0xC01270C2, 0x3302D9FF */
@@ -426,11 +329,7 @@ static double qr3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */
-2.28244540737631695038e+02, /* 0xC06C87D3, 0x4718D55F */
-2.19210128478909325622e+02, /* 0xC06B66B9, 0x5F5C1BF6 */
};
-#ifdef __STDC__
static const double qs3[6] = {
-#else
-static double qs3[6] = {
-#endif
4.76651550323729509273e+01, /* 0x4047D523, 0xCCD367E4 */
6.73865112676699709482e+02, /* 0x40850EEB, 0xC031EE3E */
3.38015286679526343505e+03, /* 0x40AA684E, 0x448E7C9A */
@@ -439,11 +338,7 @@ static double qs3[6] = {
-1.35201191444307340817e+02, /* 0xC060E670, 0x290A311F */
};
-#ifdef __STDC__
static const double qr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
-#else
-static double qr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
-#endif
-1.78381727510958865572e-07, /* 0xBE87F126, 0x44C626D2 */
-1.02517042607985553460e-01, /* 0xBFBA3E8E, 0x9148B010 */
-2.75220568278187460720e+00, /* 0xC0060484, 0x69BB4EDA */
@@ -451,11 +346,7 @@ static double qr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */
-4.23253133372830490089e+01, /* 0xC04529A3, 0xDE104AAA */
-2.13719211703704061733e+01, /* 0xC0355F36, 0x39CF6E52 */
};
-#ifdef __STDC__
static const double qs2[6] = {
-#else
-static double qs2[6] = {
-#endif
2.95333629060523854548e+01, /* 0x403D888A, 0x78AE64FF */
2.52981549982190529136e+02, /* 0x406F9F68, 0xDB821CBA */
7.57502834868645436472e+02, /* 0x4087AC05, 0xCE49A0F7 */
@@ -464,18 +355,9 @@ static double qs2[6] = {
-4.95949898822628210127e+00, /* 0xC013D686, 0xE71BE86B */
};
-#ifdef __STDC__
- static double qone(double x)
-#else
- static double qone(x)
- double x;
-#endif
+static double qone(double x)
{
-#ifdef __STDC__
const double *p=0,*q=0;
-#else
- double *p,*q;
-#endif
double s,r,z;
int32_t ix;
GET_HIGH_WORD(ix,x);
diff --git a/libm/e_jn.c b/libm/e_jn.c
index 53c6396f6..2133905e4 100644
--- a/libm/e_jn.c
+++ b/libm/e_jn.c
@@ -1,4 +1,3 @@
-/* @(#)e_jn.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: e_jn.c,v 1.9 1995/05/10 20:45:34 jtc Exp $";
-#endif
-
/*
* __ieee754_jn(n, x), __ieee754_yn(n, x)
* floating point Bessel's function of the 1st and 2nd kind
@@ -43,32 +38,14 @@ static char rcsid[] = "$NetBSD: e_jn.c,v 1.9 1995/05/10 20:45:34 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(sin)
-libm_hidden_proto(cos)
-libm_hidden_proto(sqrt)
-libm_hidden_proto(fabs)
-
-#ifdef __STDC__
static const double
-#else
-static double
-#endif
invsqrtpi= 5.64189583547756279280e-01, /* 0x3FE20DD7, 0x50429B6D */
two = 2.00000000000000000000e+00, /* 0x40000000, 0x00000000 */
one = 1.00000000000000000000e+00; /* 0x3FF00000, 0x00000000 */
-#ifdef __STDC__
static const double zero = 0.00000000000000000000e+00;
-#else
-static double zero = 0.00000000000000000000e+00;
-#endif
-#ifdef __STDC__
- double attribute_hidden __ieee754_jn(int n, double x)
-#else
- double attribute_hidden __ieee754_jn(n,x)
- int n; double x;
-#endif
+double __ieee754_jn(int n, double x)
{
int32_t i,hx,ix,lx, sgn;
double a, b, temp=0, di;
@@ -223,12 +200,9 @@ static double zero = 0.00000000000000000000e+00;
if(sgn==1) return -b; else return b;
}
-#ifdef __STDC__
- double attribute_hidden __ieee754_yn(int n, double x)
-#else
- double attribute_hidden __ieee754_yn(n,x)
- int n; double x;
-#endif
+strong_alias(__ieee754_jn, jn)
+
+double __ieee754_yn(int n, double x)
{
int32_t i,hx,ix,lx;
int32_t sign;
@@ -284,3 +258,5 @@ static double zero = 0.00000000000000000000e+00;
}
if(sign>0) return b; else return -b;
}
+
+strong_alias(__ieee754_yn, yn)
diff --git a/libm/e_lgamma_r.c b/libm/e_lgamma_r.c
index 5e1b373c0..82005ea17 100644
--- a/libm/e_lgamma_r.c
+++ b/libm/e_lgamma_r.c
@@ -1,4 +1,3 @@
-/* @(#)er_lgamma.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: e_lgamma_r.c,v 1.7 1995/05/10 20:45:42 jtc Exp $";
-#endif
-
/* __ieee754_lgamma_r(x, signgamp)
* Reentrant version of the logarithm of the Gamma function
* with user provide pointer for the sign of Gamma(x).
@@ -84,14 +79,7 @@ static char rcsid[] = "$NetBSD: e_lgamma_r.c,v 1.7 1995/05/10 20:45:42 jtc Exp $
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(floor)
-libm_hidden_proto(fabs)
-
-#ifdef __STDC__
static const double
-#else
-static double
-#endif
two52= 4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */
half= 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */
one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
@@ -159,22 +147,13 @@ w4 = -5.95187557450339963135e-04, /* 0xBF4380CB, 0x8C0FE741 */
w5 = 8.36339918996282139126e-04, /* 0x3F4B67BA, 0x4CDAD5D1 */
w6 = -1.63092934096575273989e-03; /* 0xBF5AB89D, 0x0B9E43E4 */
-#ifdef __STDC__
static const double zero= 0.00000000000000000000e+00;
-#else
-static double zero= 0.00000000000000000000e+00;
-#endif
static
#ifdef __GNUC__
-inline
-#endif
-#ifdef __STDC__
- double sin_pi(double x)
-#else
- double sin_pi(x)
- double x;
+__inline__
#endif
+double sin_pi(double x)
{
double y,z;
int n,ix;
@@ -218,13 +197,7 @@ inline
return -y;
}
-
-#ifdef __STDC__
- double attribute_hidden __ieee754_lgamma_r(double x, int *signgamp)
-#else
- double attribute_hidden __ieee754_lgamma_r(x,signgamp)
- double x; int *signgamp;
-#endif
+double __ieee754_lgamma_r(double x, int *signgamp)
{
double t,y,z,nadj=0,p,p1,p2,p3,q,r,w;
int i,hx,lx,ix;
@@ -235,7 +208,11 @@ inline
*signgamp = 1;
ix = hx&0x7fffffff;
if(ix>=0x7ff00000) return x*x;
- if((ix|lx)==0) return one/zero;
+ if((ix|lx)==0) {
+ if (signbit(x))
+ *signgamp = -1;
+ return one/zero;
+ }
if(ix<0x3b900000) { /* |x|<2**-70, return -log(|x|) */
if(hx<0) {
*signgamp = -1;
@@ -317,3 +294,62 @@ inline
if(hx<0) r = nadj - r;
return r;
}
+
+strong_alias(__ieee754_lgamma_r, lgamma_r)
+libm_hidden_def(lgamma_r)
+
+/* __ieee754_lgamma(x)
+ * Return the logarithm of the Gamma function of x.
+ */
+double __ieee754_lgamma(double x)
+{
+ return __ieee754_lgamma_r(x, &signgam);
+}
+
+strong_alias(__ieee754_lgamma, lgamma);
+libm_hidden_def(lgamma)
+
+
+/* NB: gamma function is an old name for lgamma.
+ * It is deprecated.
+ * Some C math libraries redefine it as a "true gamma", i.e.,
+ * not a ln(|Gamma(x)|) but just Gamma(x), but standards
+ * introduced tgamma name for that.
+ */
+strong_alias(__ieee754_lgamma_r, gamma_r)
+strong_alias(__ieee754_lgamma, gamma)
+libm_hidden_def(gamma)
+
+
+/* double tgamma(double x)
+ * Return the Gamma function of x.
+ */
+double tgamma(double x)
+{
+ int sign_of_gamma;
+ int32_t hx;
+ u_int32_t lx;
+
+ /* We don't have a real gamma implementation now. We'll use lgamma
+ and the exp function. But due to the required boundary
+ conditions we must check some values separately. */
+
+ EXTRACT_WORDS(hx, lx, x);
+
+ if (((hx & 0x7fffffff) | lx) == 0) {
+ /* Return value for x == 0 is Inf with divide by zero exception. */
+ return 1.0 / x;
+ }
+ if (hx < 0 && (u_int32_t)hx < 0xfff00000 && rint(x) == x) {
+ /* Return value for integer x < 0 is NaN with invalid exception. */
+ return (x - x) / (x - x);
+ }
+ if ((u_int32_t)hx == 0xfff00000 && lx == 0) {
+ /* x == -Inf. According to ISO this is NaN. */
+ return x - x;
+ }
+
+ x = exp(lgamma_r(x, &sign_of_gamma));
+ return sign_of_gamma >= 0 ? x : -x;
+}
+libm_hidden_def(tgamma)
diff --git a/libm/e_log.c b/libm/e_log.c
index fce0617aa..1ca453d04 100644
--- a/libm/e_log.c
+++ b/libm/e_log.c
@@ -1,4 +1,3 @@
-/* @(#)e_log.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: e_log.c,v 1.8 1995/05/10 20:45:49 jtc Exp $";
-#endif
-
/* __ieee754_log(x)
* Return the logrithm of x
*
@@ -68,11 +63,7 @@ static char rcsid[] = "$NetBSD: e_log.c,v 1.8 1995/05/10 20:45:49 jtc Exp $";
#include "math.h"
#include "math_private.h"
-#ifdef __STDC__
static const double
-#else
-static double
-#endif
ln2_hi = 6.93147180369123816490e-01, /* 3fe62e42 fee00000 */
ln2_lo = 1.90821492927058770002e-10, /* 3dea39ef 35793c76 */
two54 = 1.80143985094819840000e+16, /* 43500000 00000000 */
@@ -84,18 +75,9 @@ Lg5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */
Lg6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */
Lg7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
-#ifdef __STDC__
static const double zero = 0.0;
-#else
-static double zero = 0.0;
-#endif
-#ifdef __STDC__
- double attribute_hidden __ieee754_log(double x)
-#else
- double attribute_hidden __ieee754_log(x)
- double x;
-#endif
+double __ieee754_log(double x)
{
double hfsq,f,s,z,R,w,t1,t2,dk;
int32_t k,hx,i,j;
@@ -145,3 +127,6 @@ static double zero = 0.0;
return dk*ln2_hi-((s*(f-R)-dk*ln2_lo)-f);
}
}
+
+strong_alias(__ieee754_log, log)
+libm_hidden_def(log)
diff --git a/libm/e_log10.c b/libm/e_log10.c
index 5b25c0f76..3c62081e6 100644
--- a/libm/e_log10.c
+++ b/libm/e_log10.c
@@ -1,4 +1,3 @@
-/* @(#)e_log10.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: e_log10.c,v 1.9 1995/05/10 20:45:51 jtc Exp $";
-#endif
-
/* __ieee754_log10(x)
* Return the base 10 logarithm of x
*
@@ -50,28 +45,15 @@ static char rcsid[] = "$NetBSD: e_log10.c,v 1.9 1995/05/10 20:45:51 jtc Exp $";
#include "math.h"
#include "math_private.h"
-#ifdef __STDC__
static const double
-#else
-static double
-#endif
two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */
ivln10 = 4.34294481903251816668e-01, /* 0x3FDBCB7B, 0x1526E50E */
log10_2hi = 3.01029995663611771306e-01, /* 0x3FD34413, 0x509F6000 */
log10_2lo = 3.69423907715893078616e-13; /* 0x3D59FEF3, 0x11F12B36 */
-#ifdef __STDC__
-static const double zero = 0.0;
-#else
-static double zero = 0.0;
-#endif
+static const double zero = 0.0;
-#ifdef __STDC__
- double attribute_hidden __ieee754_log10(double x)
-#else
- double attribute_hidden __ieee754_log10(x)
- double x;
-#endif
+double __ieee754_log10(double x)
{
double y,z;
int32_t i,k,hx;
@@ -96,3 +78,6 @@ static double zero = 0.0;
z = y*log10_2lo + ivln10*__ieee754_log(x);
return z+y*log10_2hi;
}
+
+strong_alias(__ieee754_log10, log10)
+libm_hidden_def(log10)
diff --git a/libm/e_log2.c b/libm/e_log2.c
new file mode 100644
index 000000000..b5dfc802d
--- /dev/null
+++ b/libm/e_log2.c
@@ -0,0 +1,119 @@
+/* Adapted for log2 by Ulrich Drepper <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.
+ * ====================================================
+ */
+
+/* __ieee754_log2(x)
+ * Return the logarithm to base 2 of x
+ *
+ * Method :
+ * 1. Argument Reduction: find k and f such that
+ * x = 2^k * (1+f),
+ * where sqrt(2)/2 < 1+f < sqrt(2) .
+ *
+ * 2. Approximation of log(1+f).
+ * Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s)
+ * = 2s + 2/3 s**3 + 2/5 s**5 + .....,
+ * = 2s + s*R
+ * We use a special Reme algorithm on [0,0.1716] to generate
+ * a polynomial of degree 14 to approximate R The maximum error
+ * of this polynomial approximation is bounded by 2**-58.45. In
+ * other words,
+ * 2 4 6 8 10 12 14
+ * R(z) ~ Lg1*s +Lg2*s +Lg3*s +Lg4*s +Lg5*s +Lg6*s +Lg7*s
+ * (the values of Lg1 to Lg7 are listed in the program)
+ * and
+ * | 2 14 | -58.45
+ * | Lg1*s +...+Lg7*s - R(z) | <= 2
+ * | |
+ * Note that 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2.
+ * In order to guarantee error in log below 1ulp, we compute log
+ * by
+ * log(1+f) = f - s*(f - R) (if f is not too large)
+ * log(1+f) = f - (hfsq - s*(hfsq+R)). (better accuracy)
+ *
+ * 3. Finally, log(x) = k + log(1+f).
+ * = k+(f-(hfsq-(s*(hfsq+R))))
+ *
+ * Special cases:
+ * log2(x) is NaN with signal if x < 0 (including -INF) ;
+ * log2(+INF) is +INF; log(0) is -INF with signal;
+ * log2(NaN) is that NaN with no signal.
+ *
+ * Constants:
+ * The hexadecimal values are the intended ones for the following
+ * constants. The decimal values may be used, provided that the
+ * compiler will convert from decimal to binary accurately enough
+ * to produce the hexadecimal values shown.
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+static const double
+ln2 = 0.69314718055994530942,
+two54 = 1.80143985094819840000e+16, /* 43500000 00000000 */
+Lg1 = 6.666666666666735130e-01, /* 3FE55555 55555593 */
+Lg2 = 3.999999999940941908e-01, /* 3FD99999 9997FA04 */
+Lg3 = 2.857142874366239149e-01, /* 3FD24924 94229359 */
+Lg4 = 2.222219843214978396e-01, /* 3FCC71C5 1D8E78AF */
+Lg5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */
+Lg6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */
+Lg7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
+
+static const double zero = 0.0;
+
+double __ieee754_log2(double x)
+{
+ double hfsq,f,s,z,R,w,t1,t2,dk;
+ int32_t k,hx,i,j;
+ u_int32_t lx;
+
+ EXTRACT_WORDS(hx,lx,x);
+
+ k=0;
+ if (hx < 0x00100000) { /* x < 2**-1022 */
+ if (((hx&0x7fffffff)|lx)==0)
+ return -two54/(x-x); /* log(+-0)=-inf */
+ if (hx<0) return (x-x)/(x-x); /* log(-#) = NaN */
+ k -= 54; x *= two54; /* subnormal number, scale up x */
+ GET_HIGH_WORD(hx,x);
+ }
+ if (hx >= 0x7ff00000) return x+x;
+ k += (hx>>20)-1023;
+ hx &= 0x000fffff;
+ i = (hx+0x95f64)&0x100000;
+ SET_HIGH_WORD(x,hx|(i^0x3ff00000)); /* normalize x or x/2 */
+ k += (i>>20);
+ dk = (double) k;
+ f = x-1.0;
+ if((0x000fffff&(2+hx))<3) { /* |f| < 2**-20 */
+ if(f==zero) return dk;
+ R = f*f*(0.5-0.33333333333333333*f);
+ return dk-(R-f)/ln2;
+ }
+ s = f/(2.0+f);
+ z = s*s;
+ i = hx-0x6147a;
+ w = z*z;
+ j = 0x6b851-hx;
+ t1= w*(Lg2+w*(Lg4+w*Lg6));
+ t2= z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7)));
+ i |= j;
+ R = t2+t1;
+ if(i>0) {
+ hfsq=0.5*f*f;
+ return dk-((hfsq-(s*(hfsq+R)))-f)/ln2;
+ } else {
+ return dk-((s*(f-R))-f)/ln2;
+ }
+}
+strong_alias(__ieee754_log2,log2)
+libm_hidden_def(log2)
diff --git a/libm/e_pow.c b/libm/e_pow.c
index 675149e1f..1958fe619 100644
--- a/libm/e_pow.c
+++ b/libm/e_pow.c
@@ -1,4 +1,3 @@
-/* @(#)e_pow.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: e_pow.c,v 1.9 1995/05/12 04:57:32 jtc Exp $";
-#endif
-
/* __ieee754_pow(x,y) return x**y
*
* n
@@ -26,25 +21,26 @@ static char rcsid[] = "$NetBSD: e_pow.c,v 1.9 1995/05/12 04:57:32 jtc Exp $";
* 3. Return x**y = 2**n*exp(y'*log2)
*
* Special cases:
- * 1. (anything) ** 0 is 1
- * 2. (anything) ** 1 is itself
- * 3. (anything) ** NAN is NAN
- * 4. NAN ** (anything except 0) is NAN
- * 5. +-(|x| > 1) ** +INF is +INF
- * 6. +-(|x| > 1) ** -INF is +0
- * 7. +-(|x| < 1) ** +INF is +0
- * 8. +-(|x| < 1) ** -INF is +INF
- * 9. +-1 ** +-INF is NAN
- * 10. +0 ** (+anything except 0, NAN) is +0
- * 11. -0 ** (+anything except 0, NAN, odd integer) is +0
- * 12. +0 ** (-anything except 0, NAN) is +INF
- * 13. -0 ** (-anything except 0, NAN, odd integer) is +INF
- * 14. -0 ** (odd integer) = -( +0 ** (odd integer) )
- * 15. +INF ** (+anything except 0,NAN) is +INF
- * 16. +INF ** (-anything except 0,NAN) is +0
- * 17. -INF ** (anything) = -0 ** (-anything)
- * 18. (-anything) ** (integer) is (-1)**(integer)*(+anything**integer)
- * 19. (-anything except 0 and inf) ** (non-integer) is NAN
+ * 1. +-1 ** anything is 1.0
+ * 2. +-1 ** +-INF is 1.0
+ * 3. (anything) ** 0 is 1
+ * 4. (anything) ** 1 is itself
+ * 5. (anything) ** NAN is NAN
+ * 6. NAN ** (anything except 0) is NAN
+ * 7. +-(|x| > 1) ** +INF is +INF
+ * 8. +-(|x| > 1) ** -INF is +0
+ * 9. +-(|x| < 1) ** +INF is +0
+ * 10 +-(|x| < 1) ** -INF is +INF
+ * 11. +0 ** (+anything except 0, NAN) is +0
+ * 12. -0 ** (+anything except 0, NAN, odd integer) is +0
+ * 13. +0 ** (-anything except 0, NAN) is +INF
+ * 14. -0 ** (-anything except 0, NAN, odd integer) is +INF
+ * 15. -0 ** (odd integer) = -( +0 ** (odd integer) )
+ * 16. +INF ** (+anything except 0,NAN) is +INF
+ * 17. +INF ** (-anything except 0,NAN) is +0
+ * 18. -INF ** (anything) = -0 ** (-anything)
+ * 19. (-anything) ** (integer) is (-1)**(integer)*(+anything**integer)
+ * 20. (-anything except 0 and inf) ** (non-integer) is NAN
*
* Accuracy:
* pow(x,y) returns x**y nearly rounded. In particular
@@ -62,14 +58,7 @@ static char rcsid[] = "$NetBSD: e_pow.c,v 1.9 1995/05/12 04:57:32 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(scalbn)
-libm_hidden_proto(fabs)
-
-#ifdef __STDC__
static const double
-#else
-static double
-#endif
bp[] = {1.0, 1.5,},
dp_h[] = { 0.0, 5.84962487220764160156e-01,}, /* 0x3FE2B803, 0x40000000 */
dp_l[] = { 0.0, 1.35003920212974897128e-08,}, /* 0x3E4CFDEB, 0x43CFD006 */
@@ -102,22 +91,23 @@ ivln2 = 1.44269504088896338700e+00, /* 0x3FF71547, 0x652B82FE =1/ln2 */
ivln2_h = 1.44269502162933349609e+00, /* 0x3FF71547, 0x60000000 =24b 1/ln2*/
ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/
-#ifdef __STDC__
- double attribute_hidden __ieee754_pow(double x, double y)
-#else
- double attribute_hidden __ieee754_pow(x,y)
- double x, y;
-#endif
+double __ieee754_pow(double x, double y)
{
double z,ax,z_h,z_l,p_h,p_l;
- double y1,t1,t2,r,s,t,u,v,w;
+ double _y1,t1,t2,r,s,t,u,v,w;
int32_t i,j,k,yisint,n;
int32_t hx,hy,ix,iy;
u_int32_t lx,ly;
EXTRACT_WORDS(hx,lx,x);
+ /* x==1: 1**y = 1 (even if y is NaN) */
+ if (hx==0x3ff00000 && lx==0) {
+ return x;
+ }
+ ix = hx&0x7fffffff;
+
EXTRACT_WORDS(hy,ly,y);
- ix = hx&0x7fffffff; iy = hy&0x7fffffff;
+ iy = hy&0x7fffffff;
/* y==zero: x**0 = 1 */
if((iy|ly)==0) return one;
@@ -149,13 +139,13 @@ ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/
/* special value of y */
if(ly==0) {
- if (iy==0x7ff00000) { /* y is +-inf */
- if(((ix-0x3ff00000)|lx)==0)
- return y - y; /* inf**+-1 is NaN */
- else if (ix >= 0x3ff00000)/* (|x|>1)**+-inf = inf,0 */
- return (hy>=0)? y: zero;
- else /* (|x|<1)**-,+inf = inf,0 */
- return (hy<0)?-y: zero;
+ if (iy==0x7ff00000) { /* y is +-inf */
+ if (((ix-0x3ff00000)|lx)==0)
+ return one; /* +-1**+-inf is 1 (yes, weird rule) */
+ if (ix >= 0x3ff00000) /* (|x|>1)**+-inf = inf,0 */
+ return (hy>=0) ? y : zero;
+ /* (|x|<1)**-,+inf = inf,0 */
+ return (hy<0) ? -y : zero;
}
if(iy==0x3ff00000) { /* y is +-1 */
if(hy<0) return one/x; else return x;
@@ -163,7 +153,7 @@ ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/
if(hy==0x40000000) return x*x; /* y is 2 */
if(hy==0x3fe00000) { /* y is 0.5 */
if(hx>=0) /* x >= +0 */
- return __ieee754_sqrt(x);
+ return __ieee754_sqrt(x);
}
}
@@ -259,10 +249,10 @@ ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/
s = -one;/* (-ve)**(odd int) */
/* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */
- y1 = y;
- SET_LOW_WORD(y1,0);
- p_l = (y-y1)*t1+y*t2;
- p_h = y1*t1;
+ _y1 = y;
+ SET_LOW_WORD(_y1,0);
+ p_l = (y-_y1)*t1+y*t2;
+ p_h = _y1*t1;
z = p_l+p_h;
EXTRACT_WORDS(j,i,z);
if (j>=0x40900000) { /* z >= 1024 */
@@ -309,3 +299,6 @@ ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/
else SET_HIGH_WORD(z,j);
return s*z;
}
+
+strong_alias(__ieee754_pow, pow)
+libm_hidden_def(pow)
diff --git a/libm/e_rem_pio2.c b/libm/e_rem_pio2.c
index 97ce7bab1..3bbcd0072 100644
--- a/libm/e_rem_pio2.c
+++ b/libm/e_rem_pio2.c
@@ -1,4 +1,3 @@
-/* @(#)e_rem_pio2.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: e_rem_pio2.c,v 1.8 1995/05/10 20:46:02 jtc Exp $";
-#endif
-
/* __ieee754_rem_pio2(x,y)
*
* return the remainder of x rem pi/2 in y[0]+y[1]
@@ -23,16 +18,10 @@ static char rcsid[] = "$NetBSD: e_rem_pio2.c,v 1.8 1995/05/10 20:46:02 jtc Exp $
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(fabs)
-
/*
* Table of constants for 2/pi, 396 Hex digits (476 decimal) of 2/pi
*/
-#ifdef __STDC__
static const int32_t two_over_pi[] = {
-#else
-static int32_t two_over_pi[] = {
-#endif
0xA2F983, 0x6E4E44, 0x1529FC, 0x2757D1, 0xF534DD, 0xC0DB62,
0x95993C, 0x439041, 0xFE5163, 0xABDEBB, 0xC561B7, 0x246E3A,
0x424DD2, 0xE00649, 0x2EEA09, 0xD1921C, 0xFE1DEB, 0x1CB129,
@@ -46,11 +35,7 @@ static int32_t two_over_pi[] = {
0x4D7327, 0x310606, 0x1556CA, 0x73A8C9, 0x60E27B, 0xC08C6B,
};
-#ifdef __STDC__
static const int32_t npio2_hw[] = {
-#else
-static int32_t npio2_hw[] = {
-#endif
0x3FF921FB, 0x400921FB, 0x4012D97C, 0x401921FB, 0x401F6A7A, 0x4022D97C,
0x4025FDBB, 0x402921FB, 0x402C463A, 0x402F6A7A, 0x4031475C, 0x4032D97C,
0x40346B9C, 0x4035FDBB, 0x40378FDB, 0x403921FB, 0x403AB41B, 0x403C463A,
@@ -69,11 +54,7 @@ static int32_t npio2_hw[] = {
* pio2_3t: pi/2 - (pio2_1+pio2_2+pio2_3)
*/
-#ifdef __STDC__
static const double
-#else
-static double
-#endif
zero = 0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */
half = 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */
two24 = 1.67772160000000000000e+07, /* 0x41700000, 0x00000000 */
@@ -85,12 +66,7 @@ pio2_2t = 2.02226624879595063154e-21, /* 0x3BA3198A, 0x2E037073 */
pio2_3 = 2.02226624871116645580e-21, /* 0x3BA3198A, 0x2E000000 */
pio2_3t = 8.47842766036889956997e-32; /* 0x397B839A, 0x252049C1 */
-#ifdef __STDC__
- int32_t attribute_hidden __ieee754_rem_pio2(double x, double *y)
-#else
- int32_t attribute_hidden __ieee754_rem_pio2(x,y)
- double x,y[];
-#endif
+int32_t __ieee754_rem_pio2(double x, double *y)
{
double z=0.0,w,t,r,fn;
double tx[3];
diff --git a/libm/e_remainder.c b/libm/e_remainder.c
index 17047b385..8a00ff24f 100644
--- a/libm/e_remainder.c
+++ b/libm/e_remainder.c
@@ -1,4 +1,3 @@
-/* @(#)e_remainder.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: e_remainder.c,v 1.8 1995/05/10 20:46:05 jtc Exp $";
-#endif
-
/* __ieee754_remainder(x,p)
* Return :
* returns x REM p = x - [x/p]*p as if in infinite
@@ -26,21 +21,9 @@ static char rcsid[] = "$NetBSD: e_remainder.c,v 1.8 1995/05/10 20:46:05 jtc Exp
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(fabs)
-
-#ifdef __STDC__
static const double zero = 0.0;
-#else
-static double zero = 0.0;
-#endif
-
-#ifdef __STDC__
- double attribute_hidden __ieee754_remainder(double x, double p)
-#else
- double attribute_hidden __ieee754_remainder(x,p)
- double x,p;
-#endif
+double __ieee754_remainder(double x, double p)
{
int32_t hx,hp;
u_int32_t sx,lx,lp;
@@ -80,3 +63,7 @@ static double zero = 0.0;
SET_HIGH_WORD(x,hx^sx);
return x;
}
+
+strong_alias(__ieee754_remainder, remainder)
+strong_alias(__ieee754_remainder, drem)
+libm_hidden_def(remainder)
diff --git a/libm/e_scalb.c b/libm/e_scalb.c
index 772d95523..cc85b48d3 100644
--- a/libm/e_scalb.c
+++ b/libm/e_scalb.c
@@ -1,4 +1,3 @@
-/* @(#)e_scalb.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,45 +9,20 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: e_scalb.c,v 1.6 1995/05/10 20:46:09 jtc Exp $";
-#endif
-
/*
- * __ieee754_scalb(x, fn) is provide for
- * passing various standard test suite. One
- * should use scalbn() instead.
+ * __ieee754_scalb(x, fn) is provided for
+ * passing various standard test suites.
+ * One should use scalbn() instead.
*/
#include "math.h"
#include "math_private.h"
+#include <errno.h>
-libm_hidden_proto(scalbn)
-libm_hidden_proto(finite)
-libm_hidden_proto(rint)
-libm_hidden_proto(__isnan)
-
-#ifdef _SCALB_INT
-#ifdef __STDC__
- double attribute_hidden __ieee754_scalb(double x, int fn)
-#else
- double attribute_hidden __ieee754_scalb(x,fn)
- double x; int fn;
-#endif
-#else
-#ifdef __STDC__
- double attribute_hidden __ieee754_scalb(double x, double fn)
-#else
- double attribute_hidden __ieee754_scalb(x,fn)
- double x, fn;
-#endif
-#endif
+double __ieee754_scalb(double x, double fn)
{
-#ifdef _SCALB_INT
- return scalbn(x,fn);
-#else
if (isnan(x)||isnan(fn)) return x*fn;
- if (!finite(fn)) {
+ if (!isfinite(fn)) {
if(fn>0.0) return x*fn;
else return x/(-fn);
}
@@ -56,5 +30,9 @@ libm_hidden_proto(__isnan)
if ( fn > 65000.0) return scalbn(x, 65000);
if (-fn > 65000.0) return scalbn(x,-65000);
return scalbn(x,(int)fn);
-#endif
}
+
+#if defined __UCLIBC_SUSV3_LEGACY__
+strong_alias(__ieee754_scalb, scalb)
+libm_hidden_def(scalb)
+#endif /* UCLIBC_SUSV3_LEGACY */
diff --git a/libm/e_sinh.c b/libm/e_sinh.c
index e8452c287..52b33d5d1 100644
--- a/libm/e_sinh.c
+++ b/libm/e_sinh.c
@@ -1,4 +1,3 @@
-/* @(#)e_sinh.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: e_sinh.c,v 1.7 1995/05/10 20:46:13 jtc Exp $";
-#endif
-
/* __ieee754_sinh(x)
* Method :
* mathematically sinh(x) if defined to be (exp(x)-exp(-x))/2
@@ -35,21 +30,9 @@ static char rcsid[] = "$NetBSD: e_sinh.c,v 1.7 1995/05/10 20:46:13 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(expm1)
-libm_hidden_proto(fabs)
-
-#ifdef __STDC__
static const double one = 1.0, shuge = 1.0e307;
-#else
-static double one = 1.0, shuge = 1.0e307;
-#endif
-#ifdef __STDC__
- double attribute_hidden __ieee754_sinh(double x)
-#else
- double attribute_hidden __ieee754_sinh(x)
- double x;
-#endif
+double __ieee754_sinh(double x)
{
double t,w,h;
int32_t ix,jx;
@@ -87,3 +70,6 @@ static double one = 1.0, shuge = 1.0e307;
/* |x| > overflowthresold, sinh(x) overflow */
return x*shuge;
}
+
+strong_alias(__ieee754_sinh, sinh)
+libm_hidden_def(sinh)
diff --git a/libm/e_sqrt.c b/libm/e_sqrt.c
index c8385d673..a5b2049bc 100644
--- a/libm/e_sqrt.c
+++ b/libm/e_sqrt.c
@@ -1,4 +1,3 @@
-/* @(#)e_sqrt.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: e_sqrt.c,v 1.8 1995/05/10 20:46:17 jtc Exp $";
-#endif
-
/* __ieee754_sqrt(x)
* Return correctly rounded sqrt.
* ------------------------------------------
@@ -87,18 +82,9 @@ static char rcsid[] = "$NetBSD: e_sqrt.c,v 1.8 1995/05/10 20:46:17 jtc Exp $";
#include "math.h"
#include "math_private.h"
-#ifdef __STDC__
-static const double one = 1.0, tiny=1.0e-300;
-#else
-static double one = 1.0, tiny=1.0e-300;
-#endif
-
-#ifdef __STDC__
- double attribute_hidden __ieee754_sqrt(double x)
-#else
- double attribute_hidden __ieee754_sqrt(x)
- double x;
-#endif
+static const double one = 1.0, tiny = 1.0e-300;
+
+double __ieee754_sqrt(double x)
{
double z;
int32_t sign = (int)0x80000000;
@@ -194,6 +180,10 @@ static double one = 1.0, tiny=1.0e-300;
return z;
}
+strong_alias(__ieee754_sqrt, sqrt)
+libm_hidden_def(sqrt)
+
+
/*
Other methods (use floating-point arithmetic)
-------------
@@ -450,4 +440,3 @@ B. sqrt(x) by Reciproot Iteration
(4) Special cases (see (4) of Section A).
*/
-
diff --git a/libm/float_wrappers.c b/libm/float_wrappers.c
index cd0ae1832..105486e46 100644
--- a/libm/float_wrappers.c
+++ b/libm/float_wrappers.c
@@ -10,22 +10,42 @@
* GNU Lesser General Public License version 2.1 or later.
*/
+#include <features.h>
+/* Prevent math.h from defining colliding inlines */
+#undef __USE_EXTERN_INLINES
#include <math.h>
#include <complex.h>
-/* For the time being, do _NOT_ implement these functions
- * that are defined by SuSv3 */
-#undef L_exp2f /*float exp2f(float);*/
-#undef L_fdimf /*float fdimf(float, float);*/
-#undef L_fmaf /*float fmaf(float, float, float);*/
-#undef L_fmaxf /*float fmaxf(float, float);*/
-#undef L_fminf /*float fminf(float, float);*/
-#undef L_log2f /*float log2f(float);*/
-#undef L_nearbyintf /*float nearbyintf(float);*/
-#undef L_nexttowardf /*float nexttowardf(float, long double);*/
-#undef L_remquof /*float remquof(float, float, int *);*/
-#undef L_scalblnf /*float scalblnf(float, long);*/
-#undef L_tgammaf /*float tgammaf(float);*/
+
+#define WRAPPER1(func) \
+float func##f (float x) \
+{ \
+ return (float) func((double)x); \
+}
+#define int_WRAPPER1(func) \
+int func##f (float x) \
+{ \
+ return func((double)x); \
+}
+#define long_WRAPPER1(func) \
+long func##f (float x) \
+{ \
+ return func((double)x); \
+}
+#define long_long_WRAPPER1(func) \
+long long func##f (float x) \
+{ \
+ return func((double)x); \
+}
+
+#ifndef __DO_XSI_MATH__
+# undef L_j0f /* float j0f(float x); */
+# undef L_j1f /* float j1f(float x); */
+# undef L_jnf /* float jnf(int n, float x); */
+# undef L_y0f /* float y0f(float x); */
+# undef L_y1f /* float y1f(float x); */
+# undef L_ynf /* float ynf(int n, float x); */
+#endif
/* Implement the following, as defined by SuSv3 */
#if 0
@@ -36,6 +56,7 @@ float asinhf(float);
float atan2f(float, float);
float atanf(float);
float atanhf(float);
+float cargf(float complex);
float cbrtf(float);
float ceilf(float);
float copysignf(float, float);
@@ -43,6 +64,7 @@ float cosf(float);
float coshf(float);
float erfcf(float);
float erff(float);
+float exp2f(float);
float expf(float);
float expm1f(float);
float fabsf(float);
@@ -56,11 +78,11 @@ float lgammaf(float);
long long llroundf(float);
float log10f(float);
float log1pf(float);
+float log2f(float);
float logbf(float);
float logf(float);
long lroundf(float);
float modff(float, float *);
-float nextafterf(float, float);
float powf(float, float);
float remainderf(float, float);
float rintf(float);
@@ -73,519 +95,330 @@ float tanf(float);
float tanhf(float);
#endif
-
#ifdef L_acosf
-libm_hidden_proto(acos)
-float acosf (float x)
-{
- return (float) acos( (double)x );
-}
+WRAPPER1(acos)
#endif
-
#ifdef L_acoshf
-libm_hidden_proto(acosh)
-float acoshf (float x)
-{
- return (float) acosh( (double)x );
-}
+WRAPPER1(acosh)
#endif
-
#ifdef L_asinf
-libm_hidden_proto(asin)
-float asinf (float x)
-{
- return (float) asin( (double)x );
-}
+WRAPPER1(asin)
#endif
-
#ifdef L_asinhf
-libm_hidden_proto(asinh)
-float asinhf (float x)
-{
- return (float) asinh( (double)x );
-}
+WRAPPER1(asinh)
#endif
-
#ifdef L_atan2f
-libm_hidden_proto(atan2)
float atan2f (float x, float y)
{
return (float) atan2( (double)x, (double)y );
}
#endif
-
#ifdef L_atanf
-libm_hidden_proto(atan)
-float atanf (float x)
-{
- return (float) atan( (double)x );
-}
+WRAPPER1(atan)
#endif
-
#ifdef L_atanhf
-libm_hidden_proto(atanh)
-float atanhf (float x)
-{
- return (float) atanh( (double)x );
-}
+WRAPPER1(atanh)
#endif
-
#ifdef L_cargf
-libm_hidden_proto(carg)
float cargf (float complex x)
{
- return (float) carg( (double)x );
+ return (float) carg( (double complex)x );
}
#endif
-
#ifdef L_cbrtf
-libm_hidden_proto(cbrt)
-float cbrtf (float x)
-{
- return (float) cbrt( (double)x );
-}
+WRAPPER1(cbrt)
#endif
-
#ifdef L_ceilf
-libm_hidden_proto(ceil)
-float ceilf (float x)
-{
- return (float) ceil( (double)x );
-}
+WRAPPER1(ceil)
#endif
-
#ifdef L_copysignf
-libm_hidden_proto(copysign)
float copysignf (float x, float y)
{
return (float) copysign( (double)x, (double)y );
}
#endif
-
#ifdef L_cosf
-libm_hidden_proto(cos)
-float cosf (float x)
-{
- return (float) cos( (double)x );
-}
+WRAPPER1(cos)
+libm_hidden_def(cosf)
#endif
-
#ifdef L_coshf
-libm_hidden_proto(cosh)
-float coshf (float x)
-{
- return (float) cosh( (double)x );
-}
+WRAPPER1(cosh)
#endif
-
#ifdef L_erfcf
-libm_hidden_proto(erfc)
-float erfcf (float x)
-{
- return (float) erfc( (double)x );
-}
+WRAPPER1(erfc)
#endif
-
#ifdef L_erff
-libm_hidden_proto(erf)
-float erff (float x)
-{
- return (float) erf( (double)x );
-}
+WRAPPER1(erf)
#endif
-
#ifdef L_exp2f
-libm_hidden_proto(exp2)
-float exp2f (float x)
-{
- return (float) exp2( (double)x );
-}
+WRAPPER1(exp2)
#endif
-
#ifdef L_expf
-libm_hidden_proto(exp)
-float expf (float x)
-{
- return (float) exp( (double)x );
-}
+WRAPPER1(exp)
#endif
-
#ifdef L_expm1f
-libm_hidden_proto(expm1)
-float expm1f (float x)
-{
- return (float) expm1( (double)x );
-}
+WRAPPER1(expm1)
#endif
-
#ifdef L_fabsf
-libm_hidden_proto(fabs)
-float fabsf (float x)
-{
- return (float) fabs( (double)x );
-}
+WRAPPER1(fabs)
#endif
-
#ifdef L_fdimf
-libm_hidden_proto(fdim)
float fdimf (float x, float y)
{
return (float) fdim( (double)x, (double)y );
}
#endif
-
#ifdef L_floorf
-libm_hidden_proto(floor)
-float floorf (float x)
-{
- return (float) floor( (double)x );
-}
+WRAPPER1(floor)
#endif
-
#ifdef L_fmaf
-libm_hidden_proto(fma)
float fmaf (float x, float y, float z)
{
return (float) fma( (double)x, (double)y, (double)z );
}
#endif
-
#ifdef L_fmaxf
-libm_hidden_proto(fmax)
float fmaxf (float x, float y)
{
return (float) fmax( (double)x, (double)y );
}
#endif
-
#ifdef L_fminf
-libm_hidden_proto(fmin)
float fminf (float x, float y)
{
return (float) fmin( (double)x, (double)y );
}
#endif
-
#ifdef L_fmodf
-libm_hidden_proto(fmod)
float fmodf (float x, float y)
{
return (float) fmod( (double)x, (double)y );
}
#endif
-
#ifdef L_frexpf
-libm_hidden_proto(frexp)
float frexpf (float x, int *_exp)
{
return (float) frexp( (double)x, _exp );
}
#endif
-
#ifdef L_hypotf
-libm_hidden_proto(hypot)
float hypotf (float x, float y)
{
return (float) hypot( (double)x, (double)y );
}
#endif
-
#ifdef L_ilogbf
-libm_hidden_proto(ilogb)
-int ilogbf (float x)
+int_WRAPPER1(ilogb)
+#endif
+
+#ifdef L_j0f
+WRAPPER1(j0)
+#endif
+
+#ifdef L_j1f
+WRAPPER1(j1)
+#endif
+
+#ifdef L_jnf
+float jnf(int n, float x)
{
- return (int) ilogb( (double)x );
+ return (float) jn(n, (double)x);
}
#endif
-
#ifdef L_ldexpf
-libm_hidden_proto(ldexp)
float ldexpf (float x, int _exp)
{
return (float) ldexp( (double)x, _exp );
}
#endif
-
#ifdef L_lgammaf
-libm_hidden_proto(lgamma)
-float lgammaf (float x)
-{
- return (float) lgamma( (double)x );
-}
+WRAPPER1(lgamma)
#endif
-
#ifdef L_llrintf
-libm_hidden_proto(llrint)
-long long llrintf (float x)
-{
- return (long long) llrint( (double)x );
-}
+long_long_WRAPPER1(llrint)
#endif
-
#ifdef L_llroundf
-libm_hidden_proto(llround)
-long long llroundf (float x)
-{
- return (long long) llround( (double)x );
-}
+long_long_WRAPPER1(llround)
#endif
-
#ifdef L_log10f
-libm_hidden_proto(log10)
-float log10f (float x)
-{
- return (float) log10( (double)x );
-}
+WRAPPER1(log10)
#endif
-
#ifdef L_log1pf
-libm_hidden_proto(log1p)
-float log1pf (float x)
-{
- return (float) log1p( (double)x );
-}
+WRAPPER1(log1p)
#endif
-
#ifdef L_log2f
-libm_hidden_proto(log2)
-float log2f (float x)
-{
- return (float) log2( (double)x );
-}
+WRAPPER1(log2)
#endif
-
#ifdef L_logbf
-libm_hidden_proto(logb)
-float logbf (float x)
-{
- return (float) logb( (double)x );
-}
+WRAPPER1(logb)
#endif
-
#ifdef L_logf
-libm_hidden_proto(log)
-float logf (float x)
-{
- return (float) log( (double)x );
-}
+WRAPPER1(log)
#endif
-
#ifdef L_lrintf
-libm_hidden_proto(lrint)
-long lrintf (float x)
-{
- return (long) lrint( (double)x );
-}
+long_WRAPPER1(lrint)
#endif
-
#ifdef L_lroundf
-libm_hidden_proto(lround)
-long lroundf (float x)
-{
- return (long) lround( (double)x );
-}
+long_WRAPPER1(lround)
#endif
-
#ifdef L_modff
-libm_hidden_proto(modf)
float modff (float x, float *iptr)
{
double y, result;
- result = modf ( x, &y );
+ result = modf( x, &y );
*iptr = (float)y;
return (float) result;
-
}
#endif
-
#ifdef L_nearbyintf
-libm_hidden_proto(nearbyint)
-float nearbyintf (float x)
-{
- return (float) nearbyint( (double)x );
-}
+WRAPPER1(nearbyint)
#endif
-
-#ifdef L_nextafterf
-libm_hidden_proto(nextafter)
-float nextafterf (float x, float y)
-{
- return (float) nextafter( (double)x, (double)y );
-}
-#endif
-
-
#ifdef L_nexttowardf
-libm_hidden_proto(nexttoward)
float nexttowardf (float x, long double y)
{
- return (float) nexttoward( (double)x, (double)y );
+ return (float) nexttoward( (double)x, (long double)y );
}
#endif
-
#ifdef L_powf
-libm_hidden_proto(pow)
float powf (float x, float y)
{
return (float) pow( (double)x, (double)y );
}
#endif
-
#ifdef L_remainderf
-libm_hidden_proto(remainder)
float remainderf (float x, float y)
{
return (float) remainder( (double)x, (double)y );
}
#endif
-
#ifdef L_remquof
-libm_hidden_proto(remquo)
float remquof (float x, float y, int *quo)
{
return (float) remquo( (double)x, (double)y, quo );
}
#endif
-
#ifdef L_rintf
-libm_hidden_proto(rint)
-float rintf (float x)
-{
- return (float) rint( (double)x );
-}
+WRAPPER1(rint)
#endif
-
#ifdef L_roundf
-libm_hidden_proto(round)
-float roundf (float x)
-{
- return (float) round( (double)x );
-}
+WRAPPER1(round)
#endif
-
#ifdef L_scalblnf
-libm_hidden_proto(scalbln)
float scalblnf (float x, long _exp)
{
return (float) scalbln( (double)x, _exp );
}
#endif
-
#ifdef L_scalbnf
-libm_hidden_proto(scalbn)
float scalbnf (float x, int _exp)
{
return (float) scalbn( (double)x, _exp );
}
#endif
-
#ifdef L_sinf
-libm_hidden_proto(sin)
-float sinf (float x)
-{
- return (float) sin( (double)x );
-}
+WRAPPER1(sin)
+libm_hidden_def(sinf)
#endif
-
#ifdef L_sinhf
-libm_hidden_proto(sinh)
-float sinhf (float x)
-{
- return (float) sinh( (double)x );
-}
+WRAPPER1(sinh)
#endif
-
#ifdef L_sqrtf
-libm_hidden_proto(sqrt)
-float sqrtf (float x)
-{
- return (float) sqrt( (double)x );
-}
+WRAPPER1(sqrt)
#endif
-
#ifdef L_tanf
-libm_hidden_proto(tan)
-float tanf (float x)
-{
- return (float) tan( (double)x );
-}
+WRAPPER1(tan)
#endif
-
#ifdef L_tanhf
-libm_hidden_proto(tanh)
-float tanhf (float x)
-{
- return (float) tanh( (double)x );
-}
+WRAPPER1(tanh)
#endif
-
#ifdef L_tgammaf
-libm_hidden_proto(tgamma)
-float tgammaf (float x)
+WRAPPER1(tgamma)
+#endif
+
+#ifdef L_truncf
+WRAPPER1(trunc)
+#endif
+
+#if defined L_scalbf && defined __UCLIBC_SUSV3_LEGACY__
+float scalbf (float x, float y)
{
- return (float) tgamma( (double)x );
+ return (float) scalb( (double)x, (double)y );
}
#endif
+#ifdef L_gammaf
+WRAPPER1(gamma)
+#endif
-#ifdef L_truncf
-libm_hidden_proto(trunc)
-float truncf (float x)
+#ifdef L_significandf
+WRAPPER1(significand)
+#endif
+
+#ifdef L_y0f
+WRAPPER1(y0)
+#endif
+
+#ifdef L_y1f
+WRAPPER1(y1)
+#endif
+
+#ifdef L_ynf
+float ynf(int n, float x)
{
- return (float) trunc( (double)x );
+ return (float) yn(n, (double)x);
}
#endif
diff --git a/libm/fp_private.h b/libm/fp_private.h
deleted file mode 100644
index 0ddb616c4..000000000
--- a/libm/fp_private.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
-* *
-* File fp_private.h, *
-* All pack 4 dependencies for the MathLib elems plus some defines used *
-* throughout MathLib. *
-* *
-* Copyright © 1991 Apple Computer, Inc. All rights reserved. *
-* *
-* Written by Ali Sazegari, started on October 1991, *
-* *
-* W A R N I N G: This routine expects a 64 bit double model. *
-* *
-*******************************************************************************/
-
-#define NoException 0
-
-/*******************************************************************************
-* Values of constants. *
-*******************************************************************************/
-
-//#define SgnMask 0x8000
-#define dSgnMask 0x80000000
-#define sSgnMask 0x7FFFFFFF
-
-//#define ExpMask 0x7FFF
-#define dExpMask 0x7FF00000
-#define sExpMask 0xFF000000
-
- /* according to rounding BIG & SMALL are: */
-#define BIG 1.1e+300 /* used to deliver ±° or largest number, */
-#define SMALL 1.1e-300 /* used to deliver ±0 or smallest number. */
-#define InfExp 0x7FF
-#define dMaxExp 0x7FF00000
-
-#define MaxExpP1 1024
-#define MaxExp 1023
-
-#define DenormLimit -52
-
-//#define ManMask 0x80000000
-#define dManMask 0x00080000
-
-//#define IsItDenorm 0x80000000
-#define dIsItDenorm 0x00080000
-
-//#define xIsItSNaN 0x40000000
-#define dIsItSNaN 0x00080000
-
-#define dHighMan 0x000FFFFF
-#define dFirstBitSet 0x00080000
-#define BIAS 0x3FF
-
-//#define GetSign 0x8000
-#define dGetSign 0x80000000
-#define sGetSign 0x80000000
-
-//#define Infinity(x) ( x.hex.exponent & ExpMask ) == ExpMask
-#define dInfinity(x) ( x.hex.high & dExpMask ) == dExpMask
-#define sInfinity(x) ( ( x.hexsgl << 1 ) & sExpMask ) == sExpMask
-
-//#define Exponent(x) x.hex.exponent & ExpMask
-#define dExponent(x) x.hex.high & dExpMask
-#define sExponent(x) ( ( x.hexsgl << 1 ) & sExpMask )
-
-#define sZero(x) ( x.hexsgl & sSgnMask ) == 0
-//#define Sign(x) ( x.hex.exponent & SgnMask ) == SgnMask
-
-/*******************************************************************************
-* Types used in the auxiliary functions. *
-*******************************************************************************/
-
-#include <stdint.h>
-#include <endian.h>
-
-typedef struct /* Hex representation of a double. */
- {
-#if (__BYTE_ORDER == __BIG_ENDIAN)
- uint32_t high;
- uint32_t low;
-#else
- uint32_t low;
- uint32_t high;
-#endif
- } dHexParts;
-
-typedef union
- {
- unsigned char byties[8];
- double dbl;
- } DblInHex;
diff --git a/libm/fpmacros.c b/libm/fpmacros.c
deleted file mode 100644
index 0a079c016..000000000
--- a/libm/fpmacros.c
+++ /dev/null
@@ -1,303 +0,0 @@
-/***********************************************************************
-** File: fpmacros.c
-**
-** Contains: C source code for implementations of floating-point
-** functions which involve float format numbers, as
-** defined in header <fp.h>. In particular, this file
-** contains implementations of functions
-** __fpclassify(d,f), __isnormal(d,f), __isfinite(d,f),
-** __isnan(d,f), and __signbit(d,f). This file targets
-** PowerPC platforms.
-**
-** Written by: Robert A. Murley, Ali Sazegari
-**
-** Copyright: c 2001 by Apple Computer, Inc., all rights reserved
-**
-** Change History (most recent first):
-**
-** 07 Jul 01 ram First created from fpfloatfunc.c, fp.c,
-** classify.c and sign.c in MathLib v3 Mac OS9.
-**
-***********************************************************************/
-
-#include <features.h>
-#include <sys/types.h>
-#include <math.h>
-#include "fp_private.h"
-
-#define SIGN_MASK 0x80000000
-#define NSIGN_MASK 0x7fffffff
-#define FEXP_MASK 0x7f800000
-#define FFRAC_MASK 0x007fffff
-
-/***********************************************************************
- int __fpclassifyf(float x) returns the classification code of the
- argument x, as defined in <fp.h>.
-
- Exceptions: INVALID signaled if x is a signaling NaN; in this case,
- the FP_QNAN code is returned.
-
- Calls: none
-***********************************************************************/
-
-libm_hidden_proto(__fpclassifyf)
-int __fpclassifyf ( float x )
-{
- unsigned int iexp;
-
- union {
- u_int32_t lval;
- float fval;
- } z;
-
- z.fval = x;
- iexp = z.lval & FEXP_MASK; /* isolate float exponent */
-
- if (iexp == FEXP_MASK) { /* NaN or INF case */
- if ((z.lval & 0x007fffff) == 0)
- return FP_INFINITE;
- return FP_NAN;
- }
-
- if (iexp != 0) /* normal float */
- return FP_NORMAL;
-
- if (x == 0.0)
- return FP_ZERO; /* zero */
- else
- return FP_SUBNORMAL; /* must be subnormal */
-}
-libm_hidden_def(__fpclassifyf)
-
-
-/***********************************************************************
- Function __fpclassify,
- Implementation of classify of a double number for the PowerPC.
-
- Exceptions: INVALID signaled if x is a signaling NaN; in this case,
- the FP_QNAN code is returned.
-
- Calls: none
-***********************************************************************/
-
-libm_hidden_proto(__fpclassify)
-int __fpclassify ( double arg )
-{
- register unsigned int exponent;
- union
- {
- dHexParts hex;
- double dbl;
- } x;
-
- x.dbl = arg;
-
- exponent = x.hex.high & dExpMask;
- if ( exponent == dExpMask )
- {
- if ( ( ( x.hex.high & dHighMan ) | x.hex.low ) == 0 )
- return FP_INFINITE;
- else
- return FP_NAN;
- }
- else if ( exponent != 0)
- return FP_NORMAL;
- else {
- if ( arg == 0.0 )
- return FP_ZERO;
- else
- return FP_SUBNORMAL;
- }
-}
-libm_hidden_def(__fpclassify)
-
-
-/***********************************************************************
- int __isnormalf(float x) returns nonzero if and only if x is a
- normalized float number and zero otherwise.
-
- Exceptions: INVALID is raised if x is a signaling NaN; in this case,
- zero is returned.
-
- Calls: none
-***********************************************************************/
-
-int __isnormalf ( float x );
-int __isnormalf ( float x )
-{
- unsigned int iexp;
- union {
- u_int32_t lval;
- float fval;
- } z;
-
- z.fval = x;
- iexp = z.lval & FEXP_MASK; /* isolate float exponent */
- return ((iexp != FEXP_MASK) && (iexp != 0));
-}
-
-
-int __isnormal ( double x );
-int __isnormal ( double x )
-{
- return ( __fpclassify ( x ) == FP_NORMAL );
-}
-
-
-/***********************************************************************
- int __isfinitef(float x) returns nonzero if and only if x is a
- finite (normal, subnormal, or zero) float number and zero otherwise.
-
- Exceptions: INVALID is raised if x is a signaling NaN; in this case,
- zero is returned.
-
- Calls: none
-***********************************************************************/
-
-int __finitef ( float x )
-{
- union {
- u_int32_t lval;
- float fval;
- } z;
-
- z.fval = x;
- return ((z.lval & FEXP_MASK) != FEXP_MASK);
-}
-strong_alias(__finitef,finitef)
-
-#if 0 /* use __finite in s_finite.c */
-int __finite ( double x )
-{
- return ( __fpclassify ( x ) >= FP_ZERO );
-}
-strong_alias(__finite,finite)
-#endif
-
-
-/***********************************************************************
- int __signbitf(float x) returns nonzero if and only if the sign
- bit of x is set and zero otherwise.
-
- Exceptions: INVALID is raised if x is a signaling NaN.
-
- Calls: none
-***********************************************************************/
-
-libm_hidden_proto(__signbitf)
-int __signbitf ( float x )
-{
- union {
- u_int32_t lval;
- float fval;
- } z;
-
- z.fval = x;
- return ((z.lval & SIGN_MASK) != 0);
-}
-libm_hidden_def(__signbitf)
-
-
-/***********************************************************************
- Function sign of a double.
- Implementation of sign bit for the PowerPC.
-
- Calls: none
-***********************************************************************/
-
-libm_hidden_proto(__signbit)
-int __signbit ( double arg )
-{
- union
- {
- dHexParts hex;
- double dbl;
- } x;
- int sign;
-
- x.dbl = arg;
- sign = ( ( x.hex.high & dSgnMask ) == dSgnMask ) ? 1 : 0;
- return sign;
-}
-libm_hidden_def(__signbit)
-
-
-/***********************************************************************
-* int __isinff(float x) returns -1 if value represents negative
-* infinity, 1 if value represents positive infinity,
-* and 0 otherwise.
-*
-* Calls: __signbit
-* +***********************************************************************/
-int __isinff ( float x )
-{
- int class = __fpclassifyf(x);
- if ( class == FP_INFINITE ) {
- return ( (__signbitf(x)) ? -1 : 1);
- }
- return 0;
-}
-strong_alias(__isinff,isinff)
-
-int __isinf ( double x )
-{
- int class = __fpclassify(x);
- if ( class == FP_INFINITE ) {
- return ( (__signbit(x)) ? -1 : 1);
- }
- return 0;
-}
-strong_alias(__isinf,isinf)
-
-#if 0
-int __isinfl ( long double x )
-{
- int class = __fpclassify(x);
- if ( class == FP_INFINITE ) {
- return ( (__signbit(x)) ? -1 : 1);
- }
- return 0;
-}
-strong_alias(__isinfl,isinfl)
-#endif
-
-/***********************************************************************
- int __isnanf(float x) returns nonzero if and only if x is a
- NaN and zero otherwise.
-
- Exceptions: INVALID is raised if x is a signaling NaN; in this case,
- nonzero is returned.
-
- Calls: none
-***********************************************************************/
-
-int __isnanf ( float x )
-{
- union {
- u_int32_t lval;
- float fval;
- } z;
-
- z.fval = x;
- return (((z.lval&FEXP_MASK) == FEXP_MASK) && ((z.lval&FFRAC_MASK) != 0));
-}
-strong_alias(__isnanf,isnanf)
-
-libm_hidden_proto(__isnan)
-int __isnan ( double x )
-{
- int class = __fpclassify(x);
- return ( class == FP_NAN );
-}
-libm_hidden_def(__isnan)
-strong_alias(__isnan,isnan)
-
-#if 0
-int __isnanl ( long double x )
-{
- int class = __fpclassify(x);
- return ( class == FP_NAN );
-}
-strong_alias(__isnanl,isnanl)
-#endif
-
diff --git a/libm/i386/fclrexcpt.c b/libm/i386/fclrexcpt.c
index a34060ce8..f8e89d76c 100644
--- a/libm/i386/fclrexcpt.c
+++ b/libm/i386/fclrexcpt.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/>. */
#include <fenv.h>
#include <unistd.h>
diff --git a/libm/i386/fedisblxcpt.c b/libm/i386/fedisblxcpt.c
index 75dc17897..6f378c9bd 100644
--- a/libm/i386/fedisblxcpt.c
+++ b/libm/i386/fedisblxcpt.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/>. */
#include <fenv.h>
#include <unistd.h>
diff --git a/libm/i386/feenablxcpt.c b/libm/i386/feenablxcpt.c
index 174f9f1ad..f4f04ba60 100644
--- a/libm/i386/feenablxcpt.c
+++ b/libm/i386/feenablxcpt.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/>. */
#include <fenv.h>
#include <unistd.h>
diff --git a/libm/i386/fegetenv.c b/libm/i386/fegetenv.c
index abbf179e0..1ff819802 100644
--- a/libm/i386/fegetenv.c
+++ b/libm/i386/fegetenv.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/>. */
#include <fenv.h>
diff --git a/libm/i386/fegetexcept.c b/libm/i386/fegetexcept.c
index 71bac788b..e5da558f9 100644
--- a/libm/i386/fegetexcept.c
+++ b/libm/i386/fegetexcept.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/>. */
#include <fenv.h>
diff --git a/libm/i386/fegetround.c b/libm/i386/fegetround.c
index 8ae0c3aff..c71f52804 100644
--- a/libm/i386/fegetround.c
+++ b/libm/i386/fegetround.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/>. */
#include <fenv.h>
diff --git a/libm/i386/feholdexcpt.c b/libm/i386/feholdexcpt.c
index d283e9e44..c0204e677 100644
--- a/libm/i386/feholdexcpt.c
+++ b/libm/i386/feholdexcpt.c
@@ -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 <fenv.h>
#include <unistd.h>
diff --git a/libm/i386/fesetenv.c b/libm/i386/fesetenv.c
index fdb4fcc92..c71c7716d 100644
--- a/libm/i386/fesetenv.c
+++ b/libm/i386/fesetenv.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/>. */
#include <fenv.h>
#include <assert.h>
diff --git a/libm/i386/fesetround.c b/libm/i386/fesetround.c
index e1ba16975..66e3d1a33 100644
--- a/libm/i386/fesetround.c
+++ b/libm/i386/fesetround.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/>. */
#include <fenv.h>
#include <unistd.h>
diff --git a/libm/i386/feupdateenv.c b/libm/i386/feupdateenv.c
index 91b535dc6..250b47aac 100644
--- a/libm/i386/feupdateenv.c
+++ b/libm/i386/feupdateenv.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/>. */
#include <fenv.h>
#include <unistd.h>
diff --git a/libm/i386/fgetexcptflg.c b/libm/i386/fgetexcptflg.c
index f99122610..a68587d6c 100644
--- a/libm/i386/fgetexcptflg.c
+++ b/libm/i386/fgetexcptflg.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/>. */
#include <fenv.h>
diff --git a/libm/i386/fraiseexcpt.c b/libm/i386/fraiseexcpt.c
index fcb3d0e84..d8effab54 100644
--- a/libm/i386/fraiseexcpt.c
+++ b/libm/i386/fraiseexcpt.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/>. */
#include <fenv.h>
#include <math.h>
diff --git a/libm/i386/fsetexcptflg.c b/libm/i386/fsetexcptflg.c
index bdd1dcca0..81793ead4 100644
--- a/libm/i386/fsetexcptflg.c
+++ b/libm/i386/fsetexcptflg.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/>. */
#include <fenv.h>
#include <math.h>
diff --git a/libm/i386/ftestexcept.c b/libm/i386/ftestexcept.c
index f45beced9..4cac50d00 100644
--- a/libm/i386/ftestexcept.c
+++ b/libm/i386/ftestexcept.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/>. */
#include <fenv.h>
#include <unistd.h>
diff --git a/libm/k_cos.c b/libm/k_cos.c
index b2bbca0ca..f95cc077f 100644
--- a/libm/k_cos.c
+++ b/libm/k_cos.c
@@ -1,4 +1,3 @@
-/* @(#)k_cos.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: k_cos.c,v 1.8 1995/05/10 20:46:22 jtc Exp $";
-#endif
-
/*
* __kernel_cos( x, y )
* kernel cos function on [-pi/4, pi/4], pi/4 ~ 0.785398164
@@ -52,11 +47,7 @@ static char rcsid[] = "$NetBSD: k_cos.c,v 1.8 1995/05/10 20:46:22 jtc Exp $";
#include "math.h"
#include "math_private.h"
-#ifdef __STDC__
static const double
-#else
-static double
-#endif
one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
C1 = 4.16666666666666019037e-02, /* 0x3FA55555, 0x5555554C */
C2 = -1.38888888888741095749e-03, /* 0xBF56C16C, 0x16C15177 */
@@ -65,12 +56,7 @@ C4 = -2.75573143513906633035e-07, /* 0xBE927E4F, 0x809C52AD */
C5 = 2.08757232129817482790e-09, /* 0x3E21EE9E, 0xBDB4B1C4 */
C6 = -1.13596475577881948265e-11; /* 0xBDA8FAE9, 0xBE8838D4 */
-#ifdef __STDC__
- double attribute_hidden __kernel_cos(double x, double y)
-#else
- double attribute_hidden __kernel_cos(x, y)
- double x,y;
-#endif
+double __kernel_cos(double x, double y)
{
double a,hz,z,r,qx;
int32_t ix;
diff --git a/libm/k_rem_pio2.c b/libm/k_rem_pio2.c
index e3b9bc195..17ea9386c 100644
--- a/libm/k_rem_pio2.c
+++ b/libm/k_rem_pio2.c
@@ -1,4 +1,3 @@
-/* @(#)k_rem_pio2.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: k_rem_pio2.c,v 1.7 1995/05/10 20:46:25 jtc Exp $";
-#endif
-
/*
* __kernel_rem_pio2(x,y,e0,nx,prec,ipio2)
* double x[],y[]; int e0,nx,prec; int ipio2[];
@@ -133,20 +128,9 @@ static char rcsid[] = "$NetBSD: k_rem_pio2.c,v 1.7 1995/05/10 20:46:25 jtc Exp $
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(scalbn)
-libm_hidden_proto(floor)
-
-#ifdef __STDC__
static const int init_jk[] = {2,3,4,6}; /* initial value for jk */
-#else
-static int init_jk[] = {2,3,4,6};
-#endif
-#ifdef __STDC__
static const double PIo2[] = {
-#else
-static double PIo2[] = {
-#endif
1.57079625129699707031e+00, /* 0x3FF921FB, 0x40000000 */
7.54978941586159635335e-08, /* 0x3E74442D, 0x00000000 */
5.39030252995776476554e-15, /* 0x3CF84698, 0x80000000 */
@@ -157,22 +141,13 @@ static double PIo2[] = {
2.16741683877804819444e-51, /* 0x3569F31D, 0x00000000 */
};
-#ifdef __STDC__
static const double
-#else
-static double
-#endif
zero = 0.0,
one = 1.0,
two24 = 1.67772160000000000000e+07, /* 0x41700000, 0x00000000 */
twon24 = 5.96046447753906250000e-08; /* 0x3E700000, 0x00000000 */
-#ifdef __STDC__
- int attribute_hidden __kernel_rem_pio2(double *x, double *y, int e0, int nx, int prec, const int32_t *ipio2)
-#else
- int attribute_hidden __kernel_rem_pio2(x,y,e0,nx,prec,ipio2)
- double x[], y[]; int e0,nx,prec; int32_t ipio2[];
-#endif
+int __kernel_rem_pio2(double *x, double *y, int e0, int nx, int prec, const int32_t *ipio2)
{
int32_t jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih;
double z,fw,f[20],fq[20],q[20];
diff --git a/libm/k_sin.c b/libm/k_sin.c
index 153f37ece..b670be324 100644
--- a/libm/k_sin.c
+++ b/libm/k_sin.c
@@ -1,4 +1,3 @@
-/* @(#)k_sin.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: k_sin.c,v 1.8 1995/05/10 20:46:31 jtc Exp $";
-#endif
-
/* __kernel_sin( x, y, iy)
* kernel sin function on [-pi/4, pi/4], pi/4 ~ 0.7854
* Input x is assumed to be bounded by ~pi/4 in magnitude.
@@ -45,11 +40,7 @@ static char rcsid[] = "$NetBSD: k_sin.c,v 1.8 1995/05/10 20:46:31 jtc Exp $";
#include "math.h"
#include "math_private.h"
-#ifdef __STDC__
static const double
-#else
-static double
-#endif
half = 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */
S1 = -1.66666666666666324348e-01, /* 0xBFC55555, 0x55555549 */
S2 = 8.33333333332248946124e-03, /* 0x3F811111, 0x1110F8A6 */
@@ -58,12 +49,7 @@ S4 = 2.75573137070700676789e-06, /* 0x3EC71DE3, 0x57B1FE7D */
S5 = -2.50507602534068634195e-08, /* 0xBE5AE5E6, 0x8A2B9CEB */
S6 = 1.58969099521155010221e-10; /* 0x3DE5D93A, 0x5ACFD57C */
-#ifdef __STDC__
- double attribute_hidden __kernel_sin(double x, double y, int iy)
-#else
- double attribute_hidden __kernel_sin(x, y, iy)
- double x,y; int iy; /* iy=0 if y is zero */
-#endif
+double __kernel_sin(double x, double y, int iy)
{
double z,r,v;
int32_t ix;
diff --git a/libm/k_standard.c b/libm/k_standard.c
deleted file mode 100644
index 4df189853..000000000
--- a/libm/k_standard.c
+++ /dev/null
@@ -1,789 +0,0 @@
-/* @(#)k_standard.c 5.1 93/09/24 */
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
-
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: k_standard.c,v 1.6 1995/05/10 20:46:35 jtc Exp $";
-#endif
-
-#include <math.h>
-#include "math_private.h"
-#include <errno.h>
-
-#ifndef _IEEE_LIBM
-
-libm_hidden_proto(copysign)
-libm_hidden_proto(matherr)
-libm_hidden_proto(rint)
-
-#ifndef _USE_WRITE
-#include <stdio.h> /* fputs(), stderr */
-#define WRITE2(u,v) fputs(u, stderr)
-#else /* !defined(_USE_WRITE) */
-#include <unistd.h> /* write */
-#define WRITE2(u,v) write(2, u, v)
-#undef fflush
-#endif /* !defined(_USE_WRITE) */
-
-#ifdef __STDC__
-static const double zero = 0.0; /* used as const */
-#else
-static double zero = 0.0; /* used as const */
-#endif
-
-/*
- * Standard conformance (non-IEEE) on exception cases.
- * Mapping:
- * 1 -- acos(|x|>1)
- * 2 -- asin(|x|>1)
- * 3 -- atan2(+-0,+-0)
- * 4 -- hypot overflow
- * 5 -- cosh overflow
- * 6 -- exp overflow
- * 7 -- exp underflow
- * 8 -- y0(0)
- * 9 -- y0(-ve)
- * 10-- y1(0)
- * 11-- y1(-ve)
- * 12-- yn(0)
- * 13-- yn(-ve)
- * 14-- lgamma(finite) overflow
- * 15-- lgamma(-integer)
- * 16-- log(0)
- * 17-- log(x<0)
- * 18-- log10(0)
- * 19-- log10(x<0)
- * 20-- pow(0.0,0.0)
- * 21-- pow(x,y) overflow
- * 22-- pow(x,y) underflow
- * 23-- pow(0,negative)
- * 24-- pow(neg,non-integral)
- * 25-- sinh(finite) overflow
- * 26-- sqrt(negative)
- * 27-- fmod(x,0)
- * 28-- remainder(x,0)
- * 29-- acosh(x<1)
- * 30-- atanh(|x|>1)
- * 31-- atanh(|x|=1)
- * 32-- scalb overflow
- * 33-- scalb underflow
- * 34-- j0(|x|>X_TLOSS)
- * 35-- y0(x>X_TLOSS)
- * 36-- j1(|x|>X_TLOSS)
- * 37-- y1(x>X_TLOSS)
- * 38-- jn(|x|>X_TLOSS, n)
- * 39-- yn(x>X_TLOSS, n)
- * 40-- gamma(finite) overflow
- * 41-- gamma(-integer)
- * 42-- pow(NaN,0.0)
- */
-
-
-#ifdef __STDC__
- double __kernel_standard(double x, double y, int type)
-#else
- double __kernel_standard(x,y,type)
- double x,y; int type;
-#endif
-{
- struct exception exc;
-#ifndef HUGE_VAL /* this is the only routine that uses HUGE_VAL */
-#define HUGE_VAL inf
- double inf = 0.0;
-
- SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */
-#endif
-
-#ifdef _USE_WRITE
- (void) fflush(stdout);
-#endif
- exc.arg1 = x;
- exc.arg2 = y;
- switch(type) {
- case 1:
- case 101:
- /* acos(|x|>1) */
- exc.type = DOMAIN;
- exc.name = type < 100 ? "acos" : "acosf";
- exc.retval = zero;
- if (_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- if(_LIB_VERSION == _SVID_) {
- (void) WRITE2("acos: DOMAIN error\n", 19);
- }
- errno = EDOM;
- }
- break;
- case 2:
- case 102:
- /* asin(|x|>1) */
- exc.type = DOMAIN;
- exc.name = type < 100 ? "asin" : "asinf";
- exc.retval = zero;
- if(_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- if(_LIB_VERSION == _SVID_) {
- (void) WRITE2("asin: DOMAIN error\n", 19);
- }
- errno = EDOM;
- }
- break;
- case 3:
- case 103:
- /* atan2(+-0,+-0) */
- exc.arg1 = y;
- exc.arg2 = x;
- exc.type = DOMAIN;
- exc.name = type < 100 ? "atan2" : "atan2f";
- exc.retval = zero;
- if(_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- if(_LIB_VERSION == _SVID_) {
- (void) WRITE2("atan2: DOMAIN error\n", 20);
- }
- errno = EDOM;
- }
- break;
- case 4:
- case 104:
- /* hypot(finite,finite) overflow */
- exc.type = OVERFLOW;
- exc.name = type < 100 ? "hypot" : "hypotf";
- if (_LIB_VERSION == _SVID_)
- exc.retval = HUGE;
- else
- exc.retval = HUGE_VAL;
- if (_LIB_VERSION == _POSIX_)
- errno = ERANGE;
- else if (!matherr(&exc)) {
- errno = ERANGE;
- }
- break;
- case 5:
- case 105:
- /* cosh(finite) overflow */
- exc.type = OVERFLOW;
- exc.name = type < 100 ? "cosh" : "coshf";
- if (_LIB_VERSION == _SVID_)
- exc.retval = HUGE;
- else
- exc.retval = HUGE_VAL;
- if (_LIB_VERSION == _POSIX_)
- errno = ERANGE;
- else if (!matherr(&exc)) {
- errno = ERANGE;
- }
- break;
- case 6:
- case 106:
- /* exp(finite) overflow */
- exc.type = OVERFLOW;
- exc.name = type < 100 ? "exp" : "expf";
- if (_LIB_VERSION == _SVID_)
- exc.retval = HUGE;
- else
- exc.retval = HUGE_VAL;
- if (_LIB_VERSION == _POSIX_)
- errno = ERANGE;
- else if (!matherr(&exc)) {
- errno = ERANGE;
- }
- break;
- case 7:
- case 107:
- /* exp(finite) underflow */
- exc.type = UNDERFLOW;
- exc.name = type < 100 ? "exp" : "expf";
- exc.retval = zero;
- if (_LIB_VERSION == _POSIX_)
- errno = ERANGE;
- else if (!matherr(&exc)) {
- errno = ERANGE;
- }
- break;
- case 8:
- case 108:
- /* y0(0) = -inf */
- exc.type = DOMAIN; /* should be SING for IEEE */
- exc.name = type < 100 ? "y0" : "y0f";
- if (_LIB_VERSION == _SVID_)
- exc.retval = -HUGE;
- else
- exc.retval = -HUGE_VAL;
- if (_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- if (_LIB_VERSION == _SVID_) {
- (void) WRITE2("y0: DOMAIN error\n", 17);
- }
- errno = EDOM;
- }
- break;
- case 9:
- case 109:
- /* y0(x<0) = NaN */
- exc.type = DOMAIN;
- exc.name = type < 100 ? "y0" : "y0f";
- if (_LIB_VERSION == _SVID_)
- exc.retval = -HUGE;
- else
- exc.retval = -HUGE_VAL;
- if (_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- if (_LIB_VERSION == _SVID_) {
- (void) WRITE2("y0: DOMAIN error\n", 17);
- }
- errno = EDOM;
- }
- break;
- case 10:
- case 110:
- /* y1(0) = -inf */
- exc.type = DOMAIN; /* should be SING for IEEE */
- exc.name = type < 100 ? "y1" : "y1f";
- if (_LIB_VERSION == _SVID_)
- exc.retval = -HUGE;
- else
- exc.retval = -HUGE_VAL;
- if (_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- if (_LIB_VERSION == _SVID_) {
- (void) WRITE2("y1: DOMAIN error\n", 17);
- }
- errno = EDOM;
- }
- break;
- case 11:
- case 111:
- /* y1(x<0) = NaN */
- exc.type = DOMAIN;
- exc.name = type < 100 ? "y1" : "y1f";
- if (_LIB_VERSION == _SVID_)
- exc.retval = -HUGE;
- else
- exc.retval = -HUGE_VAL;
- if (_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- if (_LIB_VERSION == _SVID_) {
- (void) WRITE2("y1: DOMAIN error\n", 17);
- }
- errno = EDOM;
- }
- break;
- case 12:
- case 112:
- /* yn(n,0) = -inf */
- exc.type = DOMAIN; /* should be SING for IEEE */
- exc.name = type < 100 ? "yn" : "ynf";
- if (_LIB_VERSION == _SVID_)
- exc.retval = -HUGE;
- else
- exc.retval = -HUGE_VAL;
- if (_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- if (_LIB_VERSION == _SVID_) {
- (void) WRITE2("yn: DOMAIN error\n", 17);
- }
- errno = EDOM;
- }
- break;
- case 13:
- case 113:
- /* yn(x<0) = NaN */
- exc.type = DOMAIN;
- exc.name = type < 100 ? "yn" : "ynf";
- if (_LIB_VERSION == _SVID_)
- exc.retval = -HUGE;
- else
- exc.retval = -HUGE_VAL;
- if (_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- if (_LIB_VERSION == _SVID_) {
- (void) WRITE2("yn: DOMAIN error\n", 17);
- }
- errno = EDOM;
- }
- break;
- case 14:
- case 114:
- /* lgamma(finite) overflow */
- exc.type = OVERFLOW;
- exc.name = type < 100 ? "lgamma" : "lgammaf";
- if (_LIB_VERSION == _SVID_)
- exc.retval = HUGE;
- else
- exc.retval = HUGE_VAL;
- if (_LIB_VERSION == _POSIX_)
- errno = ERANGE;
- else if (!matherr(&exc)) {
- errno = ERANGE;
- }
- break;
- case 15:
- case 115:
- /* lgamma(-integer) or lgamma(0) */
- exc.type = SING;
- exc.name = type < 100 ? "lgamma" : "lgammaf";
- if (_LIB_VERSION == _SVID_)
- exc.retval = HUGE;
- else
- exc.retval = HUGE_VAL;
- if (_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- if (_LIB_VERSION == _SVID_) {
- (void) WRITE2("lgamma: SING error\n", 19);
- }
- errno = EDOM;
- }
- break;
- case 16:
- case 116:
- /* log(0) */
- exc.type = SING;
- exc.name = type < 100 ? "log" : "logf";
- if (_LIB_VERSION == _SVID_)
- exc.retval = -HUGE;
- else
- exc.retval = -HUGE_VAL;
- if (_LIB_VERSION == _POSIX_)
- errno = ERANGE;
- else if (!matherr(&exc)) {
- if (_LIB_VERSION == _SVID_) {
- (void) WRITE2("log: SING error\n", 16);
- }
- errno = EDOM;
- }
- break;
- case 17:
- case 117:
- /* log(x<0) */
- exc.type = DOMAIN;
- exc.name = type < 100 ? "log" : "logf";
- if (_LIB_VERSION == _SVID_)
- exc.retval = -HUGE;
- else
- exc.retval = -HUGE_VAL;
- if (_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- if (_LIB_VERSION == _SVID_) {
- (void) WRITE2("log: DOMAIN error\n", 18);
- }
- errno = EDOM;
- }
- break;
- case 18:
- case 118:
- /* log10(0) */
- exc.type = SING;
- exc.name = type < 100 ? "log10" : "log10f";
- if (_LIB_VERSION == _SVID_)
- exc.retval = -HUGE;
- else
- exc.retval = -HUGE_VAL;
- if (_LIB_VERSION == _POSIX_)
- errno = ERANGE;
- else if (!matherr(&exc)) {
- if (_LIB_VERSION == _SVID_) {
- (void) WRITE2("log10: SING error\n", 18);
- }
- errno = EDOM;
- }
- break;
- case 19:
- case 119:
- /* log10(x<0) */
- exc.type = DOMAIN;
- exc.name = type < 100 ? "log10" : "log10f";
- if (_LIB_VERSION == _SVID_)
- exc.retval = -HUGE;
- else
- exc.retval = -HUGE_VAL;
- if (_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- if (_LIB_VERSION == _SVID_) {
- (void) WRITE2("log10: DOMAIN error\n", 20);
- }
- errno = EDOM;
- }
- break;
- case 20:
- case 120:
- /* pow(0.0,0.0) */
- /* error only if _LIB_VERSION == _SVID_ */
- exc.type = DOMAIN;
- exc.name = type < 100 ? "pow" : "powf";
- exc.retval = zero;
- if (_LIB_VERSION != _SVID_) exc.retval = 1.0;
- else if (!matherr(&exc)) {
- (void) WRITE2("pow(0,0): DOMAIN error\n", 23);
- errno = EDOM;
- }
- break;
- case 21:
- case 121:
- /* pow(x,y) overflow */
- exc.type = OVERFLOW;
- exc.name = type < 100 ? "pow" : "powf";
- if (_LIB_VERSION == _SVID_) {
- exc.retval = HUGE;
- y *= 0.5;
- if(x<zero&&rint(y)!=y) exc.retval = -HUGE;
- } else {
- exc.retval = HUGE_VAL;
- y *= 0.5;
- if(x<zero&&rint(y)!=y) exc.retval = -HUGE_VAL;
- }
- if (_LIB_VERSION == _POSIX_)
- errno = ERANGE;
- else if (!matherr(&exc)) {
- errno = ERANGE;
- }
- break;
- case 22:
- case 122:
- /* pow(x,y) underflow */
- exc.type = UNDERFLOW;
- exc.name = type < 100 ? "pow" : "powf";
- exc.retval = zero;
- if (_LIB_VERSION == _POSIX_)
- errno = ERANGE;
- else if (!matherr(&exc)) {
- errno = ERANGE;
- }
- break;
- case 23:
- case 123:
- /* 0**neg */
- exc.type = DOMAIN;
- exc.name = type < 100 ? "pow" : "powf";
- if (_LIB_VERSION == _SVID_)
- exc.retval = zero;
- else
- exc.retval = -HUGE_VAL;
- if (_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- if (_LIB_VERSION == _SVID_) {
- (void) WRITE2("pow(0,neg): DOMAIN error\n", 25);
- }
- errno = EDOM;
- }
- break;
- case 24:
- case 124:
- /* neg**non-integral */
- exc.type = DOMAIN;
- exc.name = type < 100 ? "pow" : "powf";
- if (_LIB_VERSION == _SVID_)
- exc.retval = zero;
- else
- exc.retval = zero/zero; /* X/Open allow NaN */
- if (_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- if (_LIB_VERSION == _SVID_) {
- (void) WRITE2("neg**non-integral: DOMAIN error\n", 32);
- }
- errno = EDOM;
- }
- break;
- case 25:
- case 125:
- /* sinh(finite) overflow */
- exc.type = OVERFLOW;
- exc.name = type < 100 ? "sinh" : "sinhf";
- if (_LIB_VERSION == _SVID_)
- exc.retval = ( (x>zero) ? HUGE : -HUGE);
- else
- exc.retval = ( (x>zero) ? HUGE_VAL : -HUGE_VAL);
- if (_LIB_VERSION == _POSIX_)
- errno = ERANGE;
- else if (!matherr(&exc)) {
- errno = ERANGE;
- }
- break;
- case 26:
- case 126:
- /* sqrt(x<0) */
- exc.type = DOMAIN;
- exc.name = type < 100 ? "sqrt" : "sqrtf";
- if (_LIB_VERSION == _SVID_)
- exc.retval = zero;
- else
- exc.retval = zero/zero;
- if (_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- if (_LIB_VERSION == _SVID_) {
- (void) WRITE2("sqrt: DOMAIN error\n", 19);
- }
- errno = EDOM;
- }
- break;
- case 27:
- case 127:
- /* fmod(x,0) */
- exc.type = DOMAIN;
- exc.name = type < 100 ? "fmod" : "fmodf";
- if (_LIB_VERSION == _SVID_)
- exc.retval = x;
- else
- exc.retval = zero/zero;
- if (_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- if (_LIB_VERSION == _SVID_) {
- (void) WRITE2("fmod: DOMAIN error\n", 20);
- }
- errno = EDOM;
- }
- break;
- case 28:
- case 128:
- /* remainder(x,0) */
- exc.type = DOMAIN;
- exc.name = type < 100 ? "remainder" : "remainderf";
- exc.retval = zero/zero;
- if (_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- if (_LIB_VERSION == _SVID_) {
- (void) WRITE2("remainder: DOMAIN error\n", 24);
- }
- errno = EDOM;
- }
- break;
- case 29:
- case 129:
- /* acosh(x<1) */
- exc.type = DOMAIN;
- exc.name = type < 100 ? "acosh" : "acoshf";
- exc.retval = zero/zero;
- if (_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- if (_LIB_VERSION == _SVID_) {
- (void) WRITE2("acosh: DOMAIN error\n", 20);
- }
- errno = EDOM;
- }
- break;
- case 30:
- case 130:
- /* atanh(|x|>1) */
- exc.type = DOMAIN;
- exc.name = type < 100 ? "atanh" : "atanhf";
- exc.retval = zero/zero;
- if (_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- if (_LIB_VERSION == _SVID_) {
- (void) WRITE2("atanh: DOMAIN error\n", 20);
- }
- errno = EDOM;
- }
- break;
- case 31:
- case 131:
- /* atanh(|x|=1) */
- exc.type = SING;
- exc.name = type < 100 ? "atanh" : "atanhf";
- exc.retval = x/zero; /* sign(x)*inf */
- if (_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- if (_LIB_VERSION == _SVID_) {
- (void) WRITE2("atanh: SING error\n", 18);
- }
- errno = EDOM;
- }
- break;
- case 32:
- case 132:
- /* scalb overflow; SVID also returns +-HUGE_VAL */
- exc.type = OVERFLOW;
- exc.name = type < 100 ? "scalb" : "scalbf";
- exc.retval = x > zero ? HUGE_VAL : -HUGE_VAL;
- if (_LIB_VERSION == _POSIX_)
- errno = ERANGE;
- else if (!matherr(&exc)) {
- errno = ERANGE;
- }
- break;
- case 33:
- case 133:
- /* scalb underflow */
- exc.type = UNDERFLOW;
- exc.name = type < 100 ? "scalb" : "scalbf";
- exc.retval = copysign(zero,x);
- if (_LIB_VERSION == _POSIX_)
- errno = ERANGE;
- else if (!matherr(&exc)) {
- errno = ERANGE;
- }
- break;
- case 34:
- case 134:
- /* j0(|x|>X_TLOSS) */
- exc.type = TLOSS;
- exc.name = type < 100 ? "j0" : "j0f";
- exc.retval = zero;
- if (_LIB_VERSION == _POSIX_)
- errno = ERANGE;
- else if (!matherr(&exc)) {
- if (_LIB_VERSION == _SVID_) {
- (void) WRITE2(exc.name, 2);
- (void) WRITE2(": TLOSS error\n", 14);
- }
- errno = ERANGE;
- }
- break;
- case 35:
- case 135:
- /* y0(x>X_TLOSS) */
- exc.type = TLOSS;
- exc.name = type < 100 ? "y0" : "y0f";
- exc.retval = zero;
- if (_LIB_VERSION == _POSIX_)
- errno = ERANGE;
- else if (!matherr(&exc)) {
- if (_LIB_VERSION == _SVID_) {
- (void) WRITE2(exc.name, 2);
- (void) WRITE2(": TLOSS error\n", 14);
- }
- errno = ERANGE;
- }
- break;
- case 36:
- case 136:
- /* j1(|x|>X_TLOSS) */
- exc.type = TLOSS;
- exc.name = type < 100 ? "j1" : "j1f";
- exc.retval = zero;
- if (_LIB_VERSION == _POSIX_)
- errno = ERANGE;
- else if (!matherr(&exc)) {
- if (_LIB_VERSION == _SVID_) {
- (void) WRITE2(exc.name, 2);
- (void) WRITE2(": TLOSS error\n", 14);
- }
- errno = ERANGE;
- }
- break;
- case 37:
- case 137:
- /* y1(x>X_TLOSS) */
- exc.type = TLOSS;
- exc.name = type < 100 ? "y1" : "y1f";
- exc.retval = zero;
- if (_LIB_VERSION == _POSIX_)
- errno = ERANGE;
- else if (!matherr(&exc)) {
- if (_LIB_VERSION == _SVID_) {
- (void) WRITE2(exc.name, 2);
- (void) WRITE2(": TLOSS error\n", 14);
- }
- errno = ERANGE;
- }
- break;
- case 38:
- case 138:
- /* jn(|x|>X_TLOSS) */
- exc.type = TLOSS;
- exc.name = type < 100 ? "jn" : "jnf";
- exc.retval = zero;
- if (_LIB_VERSION == _POSIX_)
- errno = ERANGE;
- else if (!matherr(&exc)) {
- if (_LIB_VERSION == _SVID_) {
- (void) WRITE2(exc.name, 2);
- (void) WRITE2(": TLOSS error\n", 14);
- }
- errno = ERANGE;
- }
- break;
- case 39:
- case 139:
- /* yn(x>X_TLOSS) */
- exc.type = TLOSS;
- exc.name = type < 100 ? "yn" : "ynf";
- exc.retval = zero;
- if (_LIB_VERSION == _POSIX_)
- errno = ERANGE;
- else if (!matherr(&exc)) {
- if (_LIB_VERSION == _SVID_) {
- (void) WRITE2(exc.name, 2);
- (void) WRITE2(": TLOSS error\n", 14);
- }
- errno = ERANGE;
- }
- break;
- case 40:
- case 140:
- /* gamma(finite) overflow */
- exc.type = OVERFLOW;
- exc.name = type < 100 ? "gamma" : "gammaf";
- if (_LIB_VERSION == _SVID_)
- exc.retval = HUGE;
- else
- exc.retval = HUGE_VAL;
- if (_LIB_VERSION == _POSIX_)
- errno = ERANGE;
- else if (!matherr(&exc)) {
- errno = ERANGE;
- }
- break;
- case 41:
- case 141:
- /* gamma(-integer) or gamma(0) */
- exc.type = SING;
- exc.name = type < 100 ? "gamma" : "gammaf";
- if (_LIB_VERSION == _SVID_)
- exc.retval = HUGE;
- else
- exc.retval = HUGE_VAL;
- if (_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- if (_LIB_VERSION == _SVID_) {
- (void) WRITE2("gamma: SING error\n", 18);
- }
- errno = EDOM;
- }
- break;
- case 42:
- case 142:
- /* pow(NaN,0.0) */
- /* error only if _LIB_VERSION == _SVID_ & _XOPEN_ */
- exc.type = DOMAIN;
- exc.name = type < 100 ? "pow" : "powf";
- exc.retval = x;
- if (_LIB_VERSION == _IEEE_ ||
- _LIB_VERSION == _POSIX_) exc.retval = 1.0;
- else if (!matherr(&exc)) {
- errno = EDOM;
- }
- break;
- }
- return exc.retval;
-}
-#endif /* _IEEE_LIBM */
diff --git a/libm/k_tan.c b/libm/k_tan.c
index 2ba464421..65cb4a6c4 100644
--- a/libm/k_tan.c
+++ b/libm/k_tan.c
@@ -1,4 +1,3 @@
-/* @(#)k_tan.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: k_tan.c,v 1.8 1995/05/10 20:46:37 jtc Exp $";
-#endif
-
/* __kernel_tan( x, y, k )
* kernel tan function on [-pi/4, pi/4], pi/4 ~ 0.7854
* Input x is assumed to be bounded by ~pi/4 in magnitude.
@@ -51,13 +46,7 @@ static char rcsid[] = "$NetBSD: k_tan.c,v 1.8 1995/05/10 20:46:37 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(fabs)
-
-#ifdef __STDC__
static const double
-#else
-static double
-#endif
one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
pio4 = 7.85398163397448278999e-01, /* 0x3FE921FB, 0x54442D18 */
pio4lo= 3.06161699786838301793e-17, /* 0x3C81A626, 0x33145C07 */
@@ -77,12 +66,7 @@ T[] = {
2.59073051863633712884e-05, /* 0x3EFB2A70, 0x74BF7AD4 */
};
-#ifdef __STDC__
- double attribute_hidden __kernel_tan(double x, double y, int iy)
-#else
- double attribute_hidden __kernel_tan(x, y, iy)
- double x,y; int iy;
-#endif
+double __kernel_tan(double x, double y, int iy)
{
double z,r,v,w,s;
int32_t ix,hx;
diff --git a/libm/ldouble_wrappers.c b/libm/ldouble_wrappers.c
new file mode 100644
index 000000000..840293fe6
--- /dev/null
+++ b/libm/ldouble_wrappers.c
@@ -0,0 +1,453 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Wrapper functions implementing all the long double math functions
+ * defined by SuSv3 by actually calling the double version of
+ * each function and then casting the result back to a long double
+ * to return to the user.
+ *
+ * Copyright (C) 2005 by Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <features.h>
+/* Prevent math.h from defining colliding inlines */
+#undef __USE_EXTERN_INLINES
+#include "math.h"
+#include <complex.h>
+
+#if !defined __NO_LONG_DOUBLE_MATH
+# define WRAPPER1(func) \
+long double func##l(long double x) \
+{ \
+ return (long double) func((double) x); \
+}
+# define WRAPPER2(func) \
+long double func##l(long double x, long double y) \
+{ \
+ return (long double) func((double) x, (double) y); \
+}
+# define int_WRAPPER1(func) \
+int func##l(long double x) \
+{ \
+ return func((double) x); \
+}
+# define long_WRAPPER1(func) \
+long func##l(long double x) \
+{ \
+ return func((double) x); \
+}
+# define long_long_WRAPPER1(func) \
+long long func##l(long double x) \
+{ \
+ return func((double) x); \
+}
+
+#ifndef __DO_XSI_MATH__
+# undef L_j0l /* long double j0l(long double x); */
+# undef L_j1l /* long double j1l(long double x); */
+# undef L_jnl /* long double jnl(int n, long double x); */
+# undef L_y0l /* long double y0l(long double x); */
+# undef L_y1l /* long double y1l(long double x); */
+# undef L_ynl /* long double ynl(int n, long double x); */
+#endif
+
+/* Implement the following, as defined by SuSv3 */
+#if 0
+long double acoshl(long double);
+long double acosl(long double);
+long double asinhl(long double);
+long double asinl(long double);
+long double atan2l(long double, long double);
+long double atanhl(long double);
+long double atanl(long double);
+long double cargl(long double complex);
+long double cbrtl(long double);
+long double ceill(long double);
+long double copysignl(long double, long double);
+long double coshl(long double);
+long double cosl(long double);
+long double erfcl(long double);
+long double erfl(long double);
+long double exp2l(long double);
+long double expl(long double);
+long double expm1l(long double);
+long double fabsl(long double);
+long double fdiml(long double, long double);
+long double floorl(long double);
+long double fmal(long double, long double, long double);
+long double fmaxl(long double, long double);
+long double fminl(long double, long double);
+long double fmodl(long double, long double);
+long double frexpl(long double value, int *);
+long double hypotl(long double, long double);
+int ilogbl(long double);
+long double ldexpl(long double, int);
+long double lgammal(long double);
+long long llrintl(long double);
+long long llroundl(long double);
+long double log10l(long double);
+long double log1pl(long double);
+long double log2l(long double);
+long double logbl(long double);
+long double logl(long double);
+long lrintl(long double);
+long lroundl(long double);
+long double modfl(long double, long double *);
+long double nearbyintl(long double);
+long double nextafterl(long double, long double);
+long double nexttowardl(long double, long double);
+long double powl(long double, long double);
+long double remainderl(long double, long double);
+long double remquol(long double, long double, int *);
+long double rintl(long double);
+long double roundl(long double);
+long double scalblnl(long double, long);
+long double scalbnl(long double, int);
+long double sinhl(long double);
+long double sinl(long double);
+long double sqrtl(long double);
+long double tanhl(long double);
+long double tanl(long double);
+long double tgammal(long double);
+long double truncl(long double);
+#endif
+
+#ifdef L_acoshl
+WRAPPER1(acosh)
+#endif
+
+#ifdef L_acosl
+WRAPPER1(acos)
+#endif
+
+#ifdef L_asinhl
+WRAPPER1(asinh)
+#endif
+
+#ifdef L_asinl
+WRAPPER1(asin)
+#endif
+
+#ifdef L_atan2l
+WRAPPER2(atan2)
+#endif
+
+#ifdef L_atanhl
+WRAPPER1(atanh)
+#endif
+
+#ifdef L_atanl
+WRAPPER1(atan)
+#endif
+
+#ifdef L_cargl
+long double cargl (long double complex x)
+{
+ return (long double) carg( (double complex)x );
+}
+#endif
+
+#ifdef L_cbrtl
+WRAPPER1(cbrt)
+#endif
+
+#ifdef L_ceill
+WRAPPER1(ceil)
+#endif
+
+#ifdef L_copysignl
+WRAPPER2(copysign)
+#endif
+
+#ifdef L_coshl
+WRAPPER1(cosh)
+#endif
+
+#ifdef L_cosl
+WRAPPER1(cos)
+libm_hidden_def(cosl)
+#endif
+
+#ifdef L_erfcl
+WRAPPER1(erfc)
+#endif
+
+#ifdef L_erfl
+WRAPPER1(erf)
+#endif
+
+#ifdef L_exp2l
+WRAPPER1(exp2)
+#endif
+
+#ifdef L_expl
+WRAPPER1(exp)
+libm_hidden_def(expl)
+#endif
+
+#ifdef L_expm1l
+WRAPPER1(expm1)
+#endif
+
+#ifdef L_fabsl
+WRAPPER1(fabs)
+#endif
+
+#ifdef L_fdiml
+WRAPPER2(fdim)
+#endif
+
+#ifdef L_floorl
+WRAPPER1(floor)
+#endif
+
+#ifdef L_fmal
+long double fmal (long double x, long double y, long double z)
+{
+ return (long double) fma( (double)x, (double)y, (double)z );
+}
+#endif
+
+#ifdef L_fmaxl
+WRAPPER2(fmax)
+#endif
+
+#ifdef L_fminl
+WRAPPER2(fmin)
+#endif
+
+#ifdef L_fmodl
+WRAPPER2(fmod)
+#endif
+
+#ifdef L_frexpl
+long double frexpl (long double x, int *ex)
+{
+ return (long double) frexp( (double)x, ex );
+}
+#endif
+
+#ifdef L_gammal
+WRAPPER1(gamma)
+#endif
+
+#ifdef L_hypotl
+WRAPPER2(hypot)
+libm_hidden_def(hypotl)
+#endif
+
+#ifdef L_ilogbl
+int_WRAPPER1(ilogb)
+#endif
+
+#ifdef L_j0l
+ WRAPPER1(j0)
+#endif
+
+#ifdef L_j1l
+ WRAPPER1(j1)
+#endif
+
+#ifdef L_jnl
+long double jnl(int n, long double x)
+{
+ return (long double) jn(n, (double)x);
+}
+#endif
+
+#ifdef L_ldexpl
+long double ldexpl (long double x, int ex)
+{
+ return (long double) ldexp( (double)x, ex );
+}
+#endif
+
+#ifdef L_lgammal
+WRAPPER1(lgamma)
+#endif
+
+#ifdef L_llrintl
+long_long_WRAPPER1(llrint)
+#endif
+
+#ifdef L_llroundl
+long_long_WRAPPER1(llround)
+#endif
+
+#ifdef L_log10l
+WRAPPER1(log10)
+#endif
+
+#ifdef L_log1pl
+WRAPPER1(log1p)
+#endif
+
+#ifdef L_log2l
+WRAPPER1(log2)
+#endif
+
+#ifdef L_logbl
+WRAPPER1(logb)
+#endif
+
+#ifdef L_logl
+WRAPPER1(log)
+#endif
+
+#ifdef L_lrintl
+long_WRAPPER1(lrint)
+#endif
+
+#ifdef L_lroundl
+long_WRAPPER1(lround)
+#endif
+
+#ifdef L_modfl
+long double modfl (long double x, long double *iptr)
+{
+ double y, result;
+ result = modf ( x, &y );
+ *iptr = (long double)y;
+ return (long double) result;
+}
+#endif
+
+#ifdef L_nearbyintl
+WRAPPER1(nearbyint)
+#endif
+
+#ifdef L_nextafterl
+WRAPPER2(nextafter)
+libm_hidden_def(nextafterl)
+#endif
+
+#ifdef L_nexttowardl
+# if 0 /* TODO */
+strong_alias(nextafterl, nexttowardl)
+# else
+long double nexttowardl(long double x, long double y)
+{
+ return nextafterl(x, y);
+}
+#endif
+#endif
+
+#ifdef L_powl
+WRAPPER2(pow)
+#endif
+
+#ifdef L_remainderl
+WRAPPER2(remainder)
+#endif
+
+#ifdef L_remquol
+long double remquol (long double x, long double y, int *quo)
+{
+ return (long double) remquo( (double)x, (double)y, quo );
+}
+#endif
+
+#ifdef L_rintl
+WRAPPER1(rint)
+#endif
+
+#ifdef L_roundl
+WRAPPER1(round)
+#endif
+
+#ifdef L_scalblnl
+long double scalblnl (long double x, long ex)
+{
+ return (long double) scalbln( (double)x, ex );
+}
+#endif
+
+#ifdef L_scalbnl
+long double scalbnl (long double x, int ex)
+{
+ return (long double) scalbn( (double)x, ex );
+}
+#endif
+
+/* scalb is an obsolete function */
+
+#ifdef L_sinhl
+WRAPPER1(sinh)
+#endif
+
+#ifdef L_sinl
+WRAPPER1(sin)
+libm_hidden_def(sinl)
+#endif
+
+#ifdef L_sqrtl
+WRAPPER1(sqrt)
+#endif
+
+#ifdef L_tanhl
+WRAPPER1(tanh)
+#endif
+
+#ifdef L_tanl
+WRAPPER1(tan)
+#endif
+
+#ifdef L_tgammal
+WRAPPER1(tgamma)
+#endif
+
+#ifdef L_truncl
+WRAPPER1(trunc)
+#endif
+
+#ifdef L_significandl
+WRAPPER1(significand)
+#endif
+
+#ifdef L_y0l
+WRAPPER1(y0)
+#endif
+
+#ifdef L_y1l
+WRAPPER1(y1)
+#endif
+
+#ifdef L_ynl
+long double ynl(int n, long double x)
+{
+ return (long double) yn(n, (double)x);
+}
+#endif
+
+
+#if defined __DO_C99_MATH__ && !defined __NO_LONG_DOUBLE_MATH
+
+# ifdef L___fpclassifyl
+int_WRAPPER1(__fpclassify)
+libm_hidden_def(__fpclassifyl)
+# endif
+
+# ifdef L___finitel
+int_WRAPPER1(__finite)
+libm_hidden_def(__finitel)
+# endif
+
+# ifdef L___signbitl
+int_WRAPPER1(__signbit)
+libm_hidden_def(__signbitl)
+# endif
+
+# ifdef L___isnanl
+int_WRAPPER1(__isnan)
+libm_hidden_def(__isnanl)
+# endif
+
+# ifdef L___isinfl
+int_WRAPPER1(__isinf)
+libm_hidden_def(__isinfl)
+# endif
+
+#endif /* __DO_C99_MATH__ */
+
+#endif /* __NO_LONG_DOUBLE_MATH */
diff --git a/libm/math_private.h b/libm/math_private.h
index b0d948c07..620ce9a44 100644
--- a/libm/math_private.h
+++ b/libm/math_private.h
@@ -9,11 +9,6 @@
* ====================================================
*/
-/*
- * from: @(#)fdlibm.h 5.1 93/09/24
- * $Id: math_private.h,v 1.3 2004/02/09 07:10:38 andersen Exp $
- */
-
#ifndef _MATH_PRIVATE_H_
#define _MATH_PRIVATE_H_
@@ -158,17 +153,19 @@ extern double __ieee754_sqrt (double) attribute_hidden;
extern double __ieee754_acos (double) attribute_hidden;
extern double __ieee754_acosh (double) attribute_hidden;
extern double __ieee754_log (double) attribute_hidden;
+extern double __ieee754_log2 (double) attribute_hidden;
extern double __ieee754_atanh (double) attribute_hidden;
extern double __ieee754_asin (double) attribute_hidden;
extern double __ieee754_atan2 (double,double) attribute_hidden;
extern double __ieee754_exp (double) attribute_hidden;
+extern double __ieee754_exp10 (double) attribute_hidden;
extern double __ieee754_cosh (double) attribute_hidden;
extern double __ieee754_fmod (double,double) attribute_hidden;
extern double __ieee754_pow (double,double) attribute_hidden;
extern double __ieee754_lgamma_r (double,int *) attribute_hidden;
-extern double __ieee754_gamma_r (double,int *) attribute_hidden;
+/*extern double __ieee754_gamma_r (double,int *) attribute_hidden;*/
extern double __ieee754_lgamma (double) attribute_hidden;
-extern double __ieee754_gamma (double) attribute_hidden;
+/*extern double __ieee754_gamma (double) attribute_hidden;*/
extern double __ieee754_log10 (double) attribute_hidden;
extern double __ieee754_sinh (double) attribute_hidden;
extern double __ieee754_hypot (double,double) attribute_hidden;
@@ -180,19 +177,81 @@ extern double __ieee754_jn (int,double) attribute_hidden;
extern double __ieee754_yn (int,double) attribute_hidden;
extern double __ieee754_remainder (double,double) attribute_hidden;
extern int __ieee754_rem_pio2 (double,double*) attribute_hidden;
-#if defined(_SCALB_INT)
-extern double __ieee754_scalb (double,int) attribute_hidden;
-#else
extern double __ieee754_scalb (double,double) attribute_hidden;
-#endif
/* fdlibm kernel function */
-#ifndef _IEEE_LIBM
-extern double __kernel_standard (double,double,int) attribute_hidden;
-#endif
extern double __kernel_sin (double,double,int) attribute_hidden;
extern double __kernel_cos (double,double) attribute_hidden;
extern double __kernel_tan (double,double,int) attribute_hidden;
extern int __kernel_rem_pio2 (double*,double*,int,int,int,const int*) attribute_hidden;
+/*
+ * math_opt_barrier(x): safely load x, even if it was manipulated
+ * by non-floationg point operations. This macro returns the value of x.
+ * This ensures compiler does not (ab)use its knowledge about x value
+ * and don't optimize future operations. Example:
+ * float x;
+ * SET_FLOAT_WORD(x, 0x80000001); // sets a bit pattern
+ * y = math_opt_barrier(x); // "compiler, do not cheat!"
+ * y = y * y; // compiler can't optimize, must use real multiply insn
+ *
+ * math_force_eval(x): force expression x to be evaluated.
+ * Useful if otherwise compiler may eliminate the expression
+ * as unused. This macro returns no value.
+ * Example: "void fn(float f) { f = f * f; }"
+ * versus "void fn(float f) { f = f * f; math_force_eval(f); }"
+ *
+ * Currently, math_force_eval(x) stores x into
+ * a floating point register or memory *of the appropriate size*.
+ * There is no guarantee this will not change.
+ */
+#if defined(__i386__)
+#define math_opt_barrier(x) ({ \
+ __typeof(x) __x = (x); \
+ /* "t": load x into top-of-stack fpreg */ \
+ __asm__ ("" : "=t" (__x) : "0" (__x)); \
+ __x; \
+})
+#define math_force_eval(x) do { \
+ __typeof(x) __x = (x); \
+ if (sizeof(__x) <= sizeof(double)) \
+ /* "m": store x into a memory location */ \
+ __asm__ __volatile__ ("" : : "m" (__x)); \
+ else /* long double */ \
+ /* "f": load x into (any) fpreg */ \
+ __asm__ __volatile__ ("" : : "f" (__x)); \
+} while (0)
+#endif
+
+#if defined(__x86_64__)
+#define math_opt_barrier(x) ({ \
+ __typeof(x) __x = (x); \
+ if (sizeof(__x) <= sizeof(double)) \
+ /* "x": load into XMM SSE register */ \
+ __asm__ ("" : "=x" (__x) : "0" (__x)); \
+ else /* long double */ \
+ /* "t": load x into top-of-stack fpreg */ \
+ __asm__ ("" : "=t" (__x) : "0" (__x)); \
+ __x; \
+})
+#define math_force_eval(x) do { \
+ __typeof(x) __x = (x); \
+ if (sizeof(__x) <= sizeof(double)) \
+ /* "x": load into XMM SSE register */ \
+ __asm__ __volatile__ ("" : : "x" (__x)); \
+ else /* long double */ \
+ /* "f": load x into (any) fpreg */ \
+ __asm__ __volatile__ ("" : : "f" (__x)); \
+} while (0)
+#endif
+
+/* Default implementations force store to a memory location */
+#ifndef math_opt_barrier
+#define math_opt_barrier(x) ({ __typeof(x) __x = (x); __asm__ ("" : "+m" (__x)); __x; })
+#endif
+#ifndef math_force_eval
+#define math_force_eval(x) do { __typeof(x) __x = (x); __asm__ __volatile__ ("" : : "m" (__x)); } while (0)
+#endif
+
+
#endif /* _MATH_PRIVATE_H_ */
diff --git a/libm/metag/Makefile.arch b/libm/metag/Makefile.arch
new file mode 100644
index 000000000..bcae0e27a
--- /dev/null
+++ b/libm/metag/Makefile.arch
@@ -0,0 +1,23 @@
+# 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.
+#
+
+ifeq ($(UCLIBC_HAS_FENV),y)
+ifeq ($(CONFIG_META_2_1),y)
+libm_ARCH_SRC:=$(wildcard $(libm_ARCH_DIR)/*.c)
+libm_ARCH_OBJ:=$(patsubst $(libm_ARCH_DIR)/%.c,$(libm_ARCH_OUT)/%.o,$(libm_ARCH_SRC))
+CFLAGS-y-libm/metag := -Wa,-mfpu=metac21
+endif
+endif
+
+libm_ARCH_OBJS:=$(libm_ARCH_OBJ)
+
+ifeq ($(DOPIC),y)
+libm-a-y+=$(libm_ARCH_OBJS:.o=.os)
+else
+libm-a-y+=$(libm_ARCH_OBJS)
+endif
+libm-so-y+=$(libm_ARCH_OBJS:.o=.os)
diff --git a/libm/metag/fclrexcpt.c b/libm/metag/fclrexcpt.c
new file mode 100644
index 000000000..10bdc870b
--- /dev/null
+++ b/libm/metag/fclrexcpt.c
@@ -0,0 +1,44 @@
+/* Clear given exceptions in current floating-point environment.
+ 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
+ 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 <fenv.h>
+#include <unistd.h>
+
+#include "internal.h"
+
+int
+feclearexcept (int excepts)
+{
+ unsigned int temp;
+
+ /* Get the current exceptions. */
+ __asm__ ("MOV %0,TXDEFR" : "=r" (temp));
+
+ /* Mask out unsupported bits/exceptions. */
+ excepts &= FE_ALL_EXCEPT;
+
+ excepts <<= 16;
+
+ temp &= ~excepts;
+
+ metag_set_fpu_flags(temp);
+
+ /* Success. */
+ return 0;
+}
diff --git a/libm/metag/fedisblxcpt.c b/libm/metag/fedisblxcpt.c
new file mode 100644
index 000000000..07313fa9b
--- /dev/null
+++ b/libm/metag/fedisblxcpt.c
@@ -0,0 +1,40 @@
+/* Disable floating-point exceptions.
+ 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
+ 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 <fenv.h>
+#include <unistd.h>
+
+#include "internal.h"
+
+int
+fedisableexcept (int excepts)
+{
+ unsigned int old_exc;
+
+ /* Get the current control word. */
+ __asm__ ("MOV %0,TXDEFR" : "=r" (old_exc));
+
+ old_exc &= FE_ALL_EXCEPT;
+
+ excepts = old_exc & ~excepts;
+
+ metag_set_fpu_flags(excepts);
+
+ return old_exc;
+}
diff --git a/libc/signal/sigsetops.h b/libm/metag/feenablxcpt.c
index 52081c2ba..8feb9641c 100644
--- a/libc/signal/sigsetops.h
+++ b/libm/metag/feenablxcpt.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1991, 1995, 1996 Free Software Foundation, Inc.
+/* Enable floating-point exceptions.
+ 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
@@ -16,18 +17,24 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-/* Definitions relevant to functions that operate on `sigset_t's. */
+#include <fenv.h>
+#include <unistd.h>
-#include <errno.h>
-#include <signal.h>
-#include <string.h>
+#include "internal.h"
-#define BITS (_NSIG - 1)
-#define ELT(signo) (((signo) - 1) / BITS)
-#define MASK(signo) (1 << (((signo) - 1) % BITS))
+int
+feenableexcept (int excepts)
+{
+ unsigned int old_exc;
-#undef sigemptyset
-#undef sigfillset
-#undef sigaddset
-#undef sigdelset
-#undef sigismember
+ /* Get the current control word. */
+ __asm__ ("MOV %0,TXDEFR" : "=r" (old_exc));
+
+ old_exc &= FE_ALL_EXCEPT;
+
+ excepts |= old_exc;
+
+ metag_set_fpu_flags(excepts);
+
+ return old_exc;
+}
diff --git a/libm/metag/fegetenv.c b/libm/metag/fegetenv.c
new file mode 100644
index 000000000..c932514c2
--- /dev/null
+++ b/libm/metag/fegetenv.c
@@ -0,0 +1,36 @@
+/* Store current floating-point environment.
+ 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
+ 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 <fenv.h>
+
+int
+fegetenv (fenv_t *envp)
+{
+ unsigned int txdefr;
+ unsigned int txmode;
+
+ __asm__ ("MOV %0,TXDEFR" : "=r" (txdefr));
+ __asm__ ("MOV %0,TXMODE" : "=r" (txmode));
+
+ envp->txdefr = txdefr;
+ envp->txmode = txmode;
+
+ /* Success. */
+ return 0;
+}
diff --git a/libm/metag/fegetexcept.c b/libm/metag/fegetexcept.c
new file mode 100644
index 000000000..8021f6c78
--- /dev/null
+++ b/libm/metag/fegetexcept.c
@@ -0,0 +1,31 @@
+/* Get enabled floating-point exceptions.
+ 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
+ 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 <fenv.h>
+
+int
+fegetexcept (void)
+{
+ unsigned int exc;
+
+ /* Get the current control word. */
+ __asm__ ("MOV %0,TXDEFR" : "=r" (exc));
+
+ return exc & FE_ALL_EXCEPT;
+}
diff --git a/libm/metag/fegetround.c b/libm/metag/fegetround.c
new file mode 100644
index 000000000..1fb5ce2b1
--- /dev/null
+++ b/libm/metag/fegetround.c
@@ -0,0 +1,30 @@
+/* Return current rounding direction.
+ 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
+ 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 <fenv.h>
+
+int
+fegetround (void)
+{
+ unsigned int txmode;
+
+ __asm__ ("MOV %0,TXMODE" : "=r" (txmode));
+
+ return (txmode >> 16) & 0x3;
+}
diff --git a/libm/metag/feholdexcpt.c b/libm/metag/feholdexcpt.c
new file mode 100644
index 000000000..98ef4d097
--- /dev/null
+++ b/libm/metag/feholdexcpt.c
@@ -0,0 +1,41 @@
+/* Store current floating-point environment and clear exceptions.
+ Copyright (C) 2013 Imagination Technologies Ltd.
+ 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 <fenv.h>
+#include <unistd.h>
+
+#include "internal.h"
+
+int
+feholdexcept (fenv_t *envp)
+{
+ unsigned int txdefr;
+ unsigned int txmode;
+
+ __asm__ ("MOV %0,TXDEFR" : "=r" (txdefr));
+ __asm__ ("MOV %0,TXMODE" : "=r" (txmode));
+
+ envp->txdefr = txdefr;
+ envp->txmode = txmode;
+
+ metag_set_fpu_flags(0);
+
+ return 0;
+}
diff --git a/libm/metag/fesetenv.c b/libm/metag/fesetenv.c
new file mode 100644
index 000000000..7295492b8
--- /dev/null
+++ b/libm/metag/fesetenv.c
@@ -0,0 +1,60 @@
+/* Install given floating-point environment.
+ 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
+ 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 <fenv.h>
+#include <assert.h>
+
+#include "internal.h"
+
+libm_hidden_proto(fesetenv)
+
+int
+fesetenv (const fenv_t *envp)
+{
+ unsigned int exc;
+ unsigned int txmode;
+
+ __asm__ ("MOV %0,TXMODE" : "=r" (txmode));
+
+ /* Clear rounding mode bits (round to nearest). */
+ txmode &= ~(0x3 << 16);
+
+ if (envp == FE_DFL_ENV)
+ {
+ exc = 0;
+ }
+ else if (envp == FE_NOMASK_ENV)
+ {
+ exc = 0x1f;
+ }
+ else
+ {
+ exc = envp->txdefr & (FE_ALL_EXCEPT | (FE_ALL_EXCEPT << 16));
+ /* Write rounding mode and guard bit. */
+ txmode |= (0x1 << 18 ) | (envp->txmode & (0x3 << 16));
+ }
+
+ __asm__ ("MOV TXMODE,%0" : : "r" (txmode));
+
+ metag_set_fpu_flags(exc);
+
+ /* Success. */
+ return 0;
+}
+libm_hidden_def(fesetenv)
diff --git a/libm/metag/fesetround.c b/libm/metag/fesetround.c
new file mode 100644
index 000000000..2d5b2526f
--- /dev/null
+++ b/libm/metag/fesetround.c
@@ -0,0 +1,41 @@
+/* Set current rounding direction.
+ 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
+ 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 <fenv.h>
+#include <unistd.h>
+
+int
+fesetround (int round)
+{
+ unsigned int txmode;
+
+ if ((round & ~0x3) != 0)
+ /* ROUND is no valid rounding mode. */
+ return 1;
+
+ __asm__ ("MOV %0,TXMODE" : "=r" (txmode));
+
+ txmode &= ~(0x3 << 16);
+ /* Write rounding mode and guard bit. */
+ txmode |= (0x1 << 18 ) | (round << 16);
+
+ __asm__ ("MOV TXMODE,%0" : : "r" (txmode));
+
+ return 0;
+}
diff --git a/libm/metag/feupdateenv.c b/libm/metag/feupdateenv.c
new file mode 100644
index 000000000..f2fc69f54
--- /dev/null
+++ b/libm/metag/feupdateenv.c
@@ -0,0 +1,45 @@
+/* Install given floating-point environment and raise exceptions.
+ 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
+ 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 <fenv.h>
+#include <unistd.h>
+
+libm_hidden_proto(fesetenv)
+libm_hidden_proto(feraiseexcept)
+
+int
+feupdateenv (const fenv_t *envp)
+{
+ unsigned int temp;
+
+ /* Save current exceptions. */
+ __asm__ ("MOV %0,TXDEFR" : "=r" (temp));
+
+ temp >>= 16;
+ temp &= FE_ALL_EXCEPT;
+
+ /* Install new environment. */
+ fesetenv (envp);
+
+ /* Raise the saved exception. */
+ feraiseexcept ((int) temp);
+
+ /* Success. */
+ return 0;
+}
diff --git a/libm/metag/fgetexcptflg.c b/libm/metag/fgetexcptflg.c
new file mode 100644
index 000000000..e1a4bdfaa
--- /dev/null
+++ b/libm/metag/fgetexcptflg.c
@@ -0,0 +1,34 @@
+/* Store current representation for exceptions.
+ 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
+ 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 <fenv.h>
+
+int
+fegetexceptflag (fexcept_t *flagp, int excepts)
+{
+ unsigned int temp;
+
+ /* Get the current exceptions. */
+ __asm__ ("MOV %0,TXDEFR" : "=r" (temp));
+
+ *flagp = temp & excepts & FE_ALL_EXCEPT;
+
+ /* Success. */
+ return 0;
+}
diff --git a/libm/metag/fraiseexcpt.c b/libm/metag/fraiseexcpt.c
new file mode 100644
index 000000000..9ab39bbf6
--- /dev/null
+++ b/libm/metag/fraiseexcpt.c
@@ -0,0 +1,92 @@
+/* Raise given exceptions.
+ 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
+ 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 <fenv.h>
+#include <math.h>
+
+libm_hidden_proto(feraiseexcept)
+
+int
+feraiseexcept (int excepts)
+{
+ /* Raise exceptions represented by EXPECTS. But we must raise only
+ one signal at a time. It is important that if the overflow/underflow
+ exception and the inexact exception are given at the same time,
+ the overflow/underflow exception follows the inexact exception. */
+
+ /* First: invalid exception. */
+ if ((FE_INVALID & excepts) != 0)
+ {
+ /* Reciprocal square root of a negative number is invalid. */
+ __asm__ volatile(
+ "F MOV FX.0,#0xc000 ! -2\n"
+ "F RSQ FX.1,FX.0\n"
+ );
+ }
+
+ /* Next: division by zero. */
+ if ((FE_DIVBYZERO & excepts) != 0)
+ {
+ __asm__ volatile(
+ "F MOV FX.0,#0\n"
+ "F RCP FX.1,FX.0\n"
+ );
+ }
+
+ /* Next: overflow. */
+ if ((FE_OVERFLOW & excepts) != 0)
+ {
+ /* Adding a large number in single precision can cause overflow. */
+ __asm__ volatile(
+ " MOVT D0.0,#0x7f7f\n"
+ " ADD D0.0,D0.0,#0xffff\n"
+ "F MOV FX.0,D0.0\n"
+ "F ADD FX.1,FX.0,FX.0\n"
+ );
+ }
+
+ /* Next: underflow. */
+ if ((FE_UNDERFLOW & excepts) != 0)
+ {
+ /* Multiplying a small value by 0.5 will cause an underflow. */
+ __asm__ volatile(
+ " MOV D0.0,#1\n"
+ "F MOV FX.0,D0.0\n"
+ " MOVT D0.0,#0x3f00\n"
+ "F MOV FX.1,D0.0\n"
+ "F MUL FX.2,FX.1,FX.0\n"
+ );
+ }
+
+ /* Last: inexact. */
+ if ((FE_INEXACT & excepts) != 0)
+ {
+ /* Converting a small single precision value to half precision
+ can cause an inexact exception. */
+ __asm__ volatile(
+ " MOV D0.0,#0x0001\n"
+ "F MOV FX.0,D0.0\n"
+ "F FTOH FX.1,FX.0\n"
+ );
+ }
+
+ /* Success. */
+ return 0;
+}
+libm_hidden_def(feraiseexcept)
diff --git a/libm/metag/fsetexcptflg.c b/libm/metag/fsetexcptflg.c
new file mode 100644
index 000000000..11ae917e5
--- /dev/null
+++ b/libm/metag/fsetexcptflg.c
@@ -0,0 +1,44 @@
+/* Set floating-point environment exception handling.
+ 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
+ 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 <fenv.h>
+#include <math.h>
+#include <unistd.h>
+
+#include "internal.h"
+
+int
+fesetexceptflag (const fexcept_t *flagp, int excepts)
+{
+ unsigned int temp;
+
+ /* Get the current exceptions. */
+ __asm__ ("MOV %0,TXDEFR" : "=r" (temp));
+
+ excepts &= FE_ALL_EXCEPT;
+ excepts <<= 16;
+
+ temp &= ~excepts;
+ temp |= *flagp & excepts;
+
+ metag_set_fpu_flags(temp);
+
+ /* Success. */
+ return 0;
+}
diff --git a/libm/metag/ftestexcept.c b/libm/metag/ftestexcept.c
new file mode 100644
index 000000000..898630d14
--- /dev/null
+++ b/libm/metag/ftestexcept.c
@@ -0,0 +1,32 @@
+/* Test exception in current environment.
+ 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
+ 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 <fenv.h>
+#include <unistd.h>
+
+int
+fetestexcept (int excepts)
+{
+ unsigned int temp;
+
+ /* Get the current exceptions. */
+ __asm__ ("MOV %0,TXDEFR" : "=r" (temp));
+
+ return (temp >> 16) & excepts & FE_ALL_EXCEPT;
+}
diff --git a/libm/metag/internal.h b/libm/metag/internal.h
new file mode 100644
index 000000000..77297727b
--- /dev/null
+++ b/libm/metag/internal.h
@@ -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.
+ */
+
+void metag_set_fpu_flags(unsigned int flags);
diff --git a/libm/nan.c b/libm/nan.c
index 16e5c1772..eee3b1cc4 100644
--- a/libm/nan.c
+++ b/libm/nan.c
@@ -31,7 +31,9 @@ double nan (const char *tagp)
}
return NAN;
}
+libm_hidden_def(nan)
+libm_hidden_proto(nanf)
float nanf (const char *tagp)
{
if (tagp[0] != '\0') {
@@ -41,8 +43,10 @@ float nanf (const char *tagp)
}
return NAN;
}
+libm_hidden_def(nanf)
-#if 0
+#if defined __UCLIBC_HAS_LONG_DOUBLE_MATH__ && !defined __NO_LONG_DOUBLE_MATH
+libm_hidden_proto(nanl)
long double nanl (const char *tagp)
{
if (tagp[0] != '\0') {
@@ -52,4 +56,5 @@ long double nanl (const char *tagp)
}
return NAN;
}
+libm_hidden_def(nanl)
#endif
diff --git a/libm/powerpc/classic/Makefile.arch b/libm/powerpc/classic/Makefile.arch
index 7c7600f80..53c6d2cac 100644
--- a/libm/powerpc/classic/Makefile.arch
+++ b/libm/powerpc/classic/Makefile.arch
@@ -5,8 +5,8 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-libm_ARCH_SRC:=$(wildcard $(libm_ARCH_DIR)/*.c)
-libm_ARCH_OBJ:=$(patsubst $(libm_ARCH_DIR)/%.c,$(libm_ARCH_OUT)/%.o,$(libm_ARCH_SRC))
+libm_ARCH_SRC:=$(wildcard $(libm_SUBARCH_DIR)/*.c)
+libm_ARCH_OBJ:=$(patsubst $(libm_SUBARCH_DIR)/%.c,$(libm_SUBARCH_OUT)/%.o,$(libm_ARCH_SRC))
libm_ARCH_OBJS:=$(libm_ARCH_OBJ)
diff --git a/libm/powerpc/classic/s_ceil.c b/libm/powerpc/classic/s_ceil.c
deleted file mode 100644
index ee4ceb5fc..000000000
--- a/libm/powerpc/classic/s_ceil.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
-* *
-* File ceilfloor.c, *
-* Function ceil(x) and floor(x), *
-* Implementation of ceil and floor for the PowerPC. *
-* *
-* Copyright © 1991 Apple Computer, Inc. All rights reserved. *
-* *
-* Written by Ali Sazegari, started on November 1991, *
-* *
-* based on math.h, library code for Macintoshes with a 68881/68882 *
-* by Jim Thomas. *
-* *
-* W A R N I N G: This routine expects a 64 bit double model. *
-* *
-* December 03 1992: first rs6000 port. *
-* July 14 1993: comment changes and addition of #pragma fenv_access. *
-* May 06 1997: port of the ibm/taligent ceil and floor routines. *
-* April 11 2001: first port to os x using gcc. *
-* June 13 2001: replaced __setflm with in-line assembly *
-* *
-*******************************************************************************/
-
-#include <math.h>
-#include <endian.h>
-
-static const double twoTo52 = 4503599627370496.0;
-static const unsigned long signMask = 0x80000000ul;
-
-typedef union
- {
- struct {
-#if (__BYTE_ORDER == __BIG_ENDIAN)
- unsigned long int hi;
- unsigned long int lo;
-#else
- unsigned long int lo;
- unsigned long int hi;
-#endif
- } words;
- double dbl;
- } DblInHex;
-
-/*******************************************************************************
-* Functions needed for the computation. *
-*******************************************************************************/
-
-/*******************************************************************************
-* Ceil(x) returns the smallest integer not less than x. *
-*******************************************************************************/
-
-libm_hidden_proto(ceil)
-double ceil ( double x )
- {
- DblInHex xInHex,OldEnvironment;
- register double y;
- register unsigned long int xhi;
- register int target;
-
- xInHex.dbl = x;
- xhi = xInHex.words.hi & 0x7fffffffUL; // xhi is the high half of |x|
- target = ( xInHex.words.hi < signMask );
-
- if ( xhi < 0x43300000ul )
-/*******************************************************************************
-* Is |x| < 2.0^52? *
-*******************************************************************************/
- {
- if ( xhi < 0x3ff00000ul )
-/*******************************************************************************
-* Is |x| < 1.0? *
-*******************************************************************************/
- {
- if ( ( xhi | xInHex.words.lo ) == 0ul ) // zero x is exact case
- return ( x );
- else
- { // inexact case
- __asm__ ("mffs %0" : "=f" (OldEnvironment.dbl));
- OldEnvironment.words.lo |= 0x02000000ul;
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( OldEnvironment.dbl ));
- if ( target )
- return ( 1.0 );
- else
- return ( -0.0 );
- }
- }
-/*******************************************************************************
-* Is 1.0 < |x| < 2.0^52? *
-*******************************************************************************/
- if ( target )
- {
- y = ( x + twoTo52 ) - twoTo52; // round at binary pt.
- if ( y < x )
- return ( y + 1.0 );
- else
- return ( y );
- }
-
- else
- {
- y = ( x - twoTo52 ) + twoTo52; // round at binary pt.
- if ( y < x )
- return ( y + 1.0 );
- else
- return ( y );
- }
- }
-/*******************************************************************************
-* |x| >= 2.0^52 or x is a NaN. *
-*******************************************************************************/
- return ( x );
- }
-libm_hidden_def(ceil)
diff --git a/libm/powerpc/classic/s_copysign.c b/libm/powerpc/classic/s_copysign.c
deleted file mode 100644
index c6f1307a3..000000000
--- a/libm/powerpc/classic/s_copysign.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
-* *
-* File sign.c, *
-* Functions copysign and __signbitd. *
-* For PowerPC based machines. *
-* *
-* Copyright © 1991, 2001 Apple Computer, Inc. All rights reserved. *
-* *
-* Written by Ali Sazegari, started on June 1991. *
-* *
-* August 26 1991: no CFront Version 1.1d17 warnings. *
-* September 06 1991: passes the test suite with invalid raised on *
-* signaling nans. sane rom code behaves the same. *
-* September 24 1992: took the Ò#include support.hÓ out. *
-* Dcember 02 1992: PowerPC port. *
-* July 20 1994: __fabs added *
-* July 21 1994: deleted unnecessary functions: neg, COPYSIGNnew, *
-* and SIGNNUMnew. *
-* April 11 2001: first port to os x using gcc. *
-* removed fabs and deffered to gcc for direct *
-* instruction generation. *
-* *
-*******************************************************************************/
-
-#include <math.h>
-#include "../../fp_private.h"
-
-/*******************************************************************************
-* *
-* Function copysign. *
-* Implementation of copysign for the PowerPC. *
-* *
-********************************************************************************
-* Note: The order of the operands in this function is reversed from that *
-* suggested in the IEEE standard 754. *
-*******************************************************************************/
-
-libm_hidden_proto(copysign)
-double copysign ( double arg2, double arg1 )
- {
- union
- {
- dHexParts hex;
- double dbl;
- } x, y;
-
-/*******************************************************************************
-* No need to flush NaNs out. *
-*******************************************************************************/
-
- x.dbl = arg1;
- y.dbl = arg2;
-
- y.hex.high = y.hex.high & 0x7FFFFFFF;
- y.hex.high = ( y.hex.high | ( x.hex.high & dSgnMask ) );
-
- return y.dbl;
- }
-libm_hidden_def(copysign)
diff --git a/libm/powerpc/classic/s_floor.c b/libm/powerpc/classic/s_floor.c
deleted file mode 100644
index 2cd720eff..000000000
--- a/libm/powerpc/classic/s_floor.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
-* *
-* File ceilfloor.c, *
-* Function ceil(x) and floor(x), *
-* Implementation of ceil and floor for the PowerPC. *
-* *
-* Copyright © 1991 Apple Computer, Inc. All rights reserved. *
-* *
-* Written by Ali Sazegari, started on November 1991, *
-* *
-* based on math.h, library code for Macintoshes with a 68881/68882 *
-* by Jim Thomas. *
-* *
-* W A R N I N G: This routine expects a 64 bit double model. *
-* *
-* December 03 1992: first rs6000 port. *
-* July 14 1993: comment changes and addition of #pragma fenv_access. *
-* May 06 1997: port of the ibm/taligent ceil and floor routines. *
-* April 11 2001: first port to os x using gcc. *
-* June 13 2001: replaced __setflm with in-line assembly *
-* *
-*******************************************************************************/
-
-#include <math.h>
-#include <endian.h>
-
-static const double twoTo52 = 4503599627370496.0;
-static const unsigned long signMask = 0x80000000ul;
-
-typedef union
- {
- struct {
-#if (__BYTE_ORDER == __BIG_ENDIAN)
- unsigned long int hi;
- unsigned long int lo;
-#else
- unsigned long int lo;
- unsigned long int hi;
-#endif
- } words;
- double dbl;
- } DblInHex;
-
-/*******************************************************************************
-* Functions needed for the computation. *
-*******************************************************************************/
-
-/*******************************************************************************
-* Floor(x) returns the largest integer not greater than x. *
-*******************************************************************************/
-
-libm_hidden_proto(floor)
-double floor ( double x )
- {
- DblInHex xInHex,OldEnvironment;
- register double y;
- register unsigned long int xhi;
- register long int target;
-
- xInHex.dbl = x;
- xhi = xInHex.words.hi & 0x7fffffffUL; // xhi is the high half of |x|
- target = ( xInHex.words.hi < signMask );
-
- if ( xhi < 0x43300000ul )
-/*******************************************************************************
-* Is |x| < 2.0^52? *
-*******************************************************************************/
- {
- if ( xhi < 0x3ff00000ul )
-/*******************************************************************************
-* Is |x| < 1.0? *
-*******************************************************************************/
- {
- if ( ( xhi | xInHex.words.lo ) == 0ul ) // zero x is exact case
- return ( x );
- else
- { // inexact case
- __asm__ ("mffs %0" : "=f" (OldEnvironment.dbl));
- OldEnvironment.words.lo |= 0x02000000ul;
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( OldEnvironment.dbl ));
- if ( target )
- return ( 0.0 );
- else
- return ( -1.0 );
- }
- }
-/*******************************************************************************
-* Is 1.0 < |x| < 2.0^52? *
-*******************************************************************************/
- if ( target )
- {
- y = ( x + twoTo52 ) - twoTo52; // round at binary pt.
- if ( y > x )
- return ( y - 1.0 );
- else
- return ( y );
- }
-
- else
- {
- y = ( x - twoTo52 ) + twoTo52; // round at binary pt.
- if ( y > x )
- return ( y - 1.0 );
- else
- return ( y );
- }
- }
-/*******************************************************************************
-* |x| >= 2.0^52 or x is a NaN. *
-*******************************************************************************/
- return ( x );
- }
-libm_hidden_def(floor)
diff --git a/libm/powerpc/classic/s_frexp.c b/libm/powerpc/classic/s_frexp.c
deleted file mode 100644
index 001aaf708..000000000
--- a/libm/powerpc/classic/s_frexp.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
-* *
-* File frexpldexp.c, *
-* Functions frexp(x) and ldexp(x), *
-* Implementation of frexp and ldexp functions for the PowerPC. *
-* *
-* Copyright © 1991 Apple Computer, Inc. All rights reserved. *
-* *
-* Written by Ali Sazegari, started on January 1991, *
-* *
-* W A R N I N G: This routine expects a 64 bit double model. *
-* *
-* December03 1992: first rs6000 implementation. *
-* October 05 1993: added special cases for NaN and ° in frexp. *
-* May 27 1997: improved the performance of frexp by eliminating the *
-* switch statement. *
-* June 13 2001: (ram) rewrote frexp to eliminate calls to scalb and *
-* logb. *
-* *
-*******************************************************************************/
-
-#include <limits.h>
-#include <math.h>
-#include <endian.h>
-
-static const double two54 = 1.80143985094819840000e+16; /* 0x43500000, 0x00000000 */
-
-typedef union
- {
- struct {
-#if (__BYTE_ORDER == __BIG_ENDIAN)
- unsigned long int hi;
- unsigned long int lo;
-#else
- unsigned long int lo;
- unsigned long int hi;
-#endif
- } words;
- double dbl;
- } DblInHex;
-
-libm_hidden_proto(frexp)
-double frexp ( double value, int *eptr )
- {
- DblInHex argument;
- unsigned long int valueHead;
-
- argument.dbl = value;
- valueHead = argument.words.hi & 0x7fffffffUL; // valueHead <- |x|
-
- *eptr = 0;
- if ( valueHead >= 0x7ff00000 || ( valueHead | argument.words.lo ) == 0 )
- return value; // 0, inf, or NaN
-
- if ( valueHead < 0x00100000 )
- { // denorm
- argument.dbl = two54 * value;
- valueHead = argument.words.hi &0x7fffffff;
- *eptr = -54;
- }
- *eptr += ( valueHead >> 20 ) - 1022;
- argument.words.hi = ( argument.words.hi & 0x800fffff ) | 0x3fe00000;
- return argument.dbl;
- }
-libm_hidden_def(frexp)
diff --git a/libm/powerpc/classic/s_ldexp.c b/libm/powerpc/classic/s_ldexp.c
deleted file mode 100644
index 10100d7c2..000000000
--- a/libm/powerpc/classic/s_ldexp.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
-* *
-* File frexpldexp.c, *
-* Functions frexp(x) and ldexp(x), *
-* Implementation of frexp and ldexp functions for the PowerPC. *
-* *
-* Copyright © 1991 Apple Computer, Inc. All rights reserved. *
-* *
-* Written by Ali Sazegari, started on January 1991, *
-* *
-* W A R N I N G: This routine expects a 64 bit double model. *
-* *
-* December03 1992: first rs6000 implementation. *
-* October 05 1993: added special cases for NaN and ° in frexp. *
-* May 27 1997: improved the performance of frexp by eliminating the *
-* switch statement. *
-* June 13 2001: (ram) rewrote frexp to eliminate calls to scalb and *
-* logb. *
-* *
-*******************************************************************************/
-
-#include <limits.h>
-#include <math.h>
-#include <endian.h>
-
-typedef union
- {
- struct {
-#if (__BYTE_ORDER == __BIG_ENDIAN)
- unsigned long int hi;
- unsigned long int lo;
-#else
- unsigned long int lo;
- unsigned long int hi;
-#endif
- } words;
- double dbl;
- } DblInHex;
-
-libm_hidden_proto(ldexp)
-double ldexp ( double value, int exp )
- {
- if ( exp > SHRT_MAX )
- exp = SHRT_MAX;
- else if ( exp < -SHRT_MAX )
- exp = -SHRT_MAX;
- return scalb ( value, exp );
- }
-libm_hidden_def(ldexp)
diff --git a/libm/powerpc/classic/s_logb.c b/libm/powerpc/classic/s_logb.c
deleted file mode 100644
index 81daa412e..000000000
--- a/libm/powerpc/classic/s_logb.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
-* *
-* File logb.c, *
-* Functions logb. *
-* Implementation of logb for the PowerPC. *
-* *
-* Copyright © 1991 Apple Computer, Inc. All rights reserved. *
-* *
-* Written by Ali Sazegari, started on June 1991, *
-* *
-* August 26 1991: removed CFront Version 1.1d17 warnings. *
-* August 27 1991: no errors reported by the test suite. *
-* November 11 1991: changed CLASSEXTENDED to the macro CLASSIFY and *
-* + or - infinity to constants. *
-* November 18 1991: changed the macro CLASSIFY to CLASSEXTENDEDint to *
-* improve performance. *
-* February 07 1992: changed bit operations to macros ( object size is *
-* unchanged ). *
-* September24 1992: took the "#include support.h" out. *
-* December 03 1992: first rs/6000 port. *
-* August 30 1992: set the divide by zero for the zero argument case. *
-* October 05 1993: corrected the environment. *
-* October 17 1994: replaced all environmental functions with __setflm. *
-* May 28 1997: made speed improvements. *
-* April 30 2001: forst mac os x port using gcc. *
-* *
-********************************************************************************
-* The C math library offers a similar function called "frexp". It is *
-* different in details from logb, but similar in spirit. This current *
-* implementation of logb follows the recommendation in IEEE Standard 854 *
-* which is different in its handling of denormalized numbers from the IEEE *
-* Standard 754. *
-*******************************************************************************/
-
-#include <math.h>
-#include <endian.h>
-
-typedef union
- {
- struct {
-#if (__BYTE_ORDER == __BIG_ENDIAN)
- unsigned long int hi;
- unsigned long int lo;
-#else
- unsigned long int lo;
- unsigned long int hi;
-#endif
- } words;
- double dbl;
- } DblInHex;
-
-static const double twoTo52 = 4.50359962737049600e15; // 0x1p52
-static const double klTod = 4503601774854144.0; // 0x1.000008p52
-static const unsigned long int signMask = 0x80000000ul;
-static const DblInHex minusInf = {{ 0xFFF00000, 0x00000000 }};
-
-
-/*******************************************************************************
-********************************************************************************
-* L O G B *
-********************************************************************************
-*******************************************************************************/
-
-libm_hidden_proto(logb)
-double logb ( double x )
- {
- DblInHex xInHex;
- long int shiftedExp;
-
- xInHex.dbl = x;
- shiftedExp = ( xInHex.words.hi & 0x7ff00000UL ) >> 20;
-
- if ( shiftedExp == 2047 )
- { // NaN or INF
- if ( ( ( xInHex.words.hi & signMask ) == 0 ) || ( x != x ) )
- return x; // NaN or +INF return x
- else
- return -x; // -INF returns +INF
- }
-
- if ( shiftedExp != 0 ) // normal number
- shiftedExp -= 1023; // unbias exponent
-
- else if ( x == 0.0 )
- { // zero
- xInHex.words.hi = 0x0UL; // return -infinity
- return ( minusInf.dbl );
- }
-
- else
- { // subnormal number
- xInHex.dbl *= twoTo52; // scale up
- shiftedExp = ( xInHex.words.hi & 0x7ff00000UL ) >> 20;
- shiftedExp -= 1075; // unbias exponent
- }
-
- if ( shiftedExp == 0 ) // zero result
- return ( 0.0 );
-
- else
- { // nonzero result
- xInHex.dbl = klTod;
- xInHex.words.lo += shiftedExp;
- return ( xInHex.dbl - klTod );
- }
- }
-libm_hidden_def(logb)
diff --git a/libm/powerpc/classic/s_modf.c b/libm/powerpc/classic/s_modf.c
deleted file mode 100644
index c2221bc0b..000000000
--- a/libm/powerpc/classic/s_modf.c
+++ /dev/null
@@ -1,344 +0,0 @@
-/*******************************************************************************
-** File: rndint.c
-**
-** Contains: C source code for implementations of floating-point
-** functions which round to integral value or format, as
-** defined in header <fp.h>. In particular, this file
-** contains implementations of functions rinttol, roundtol,
-** modf and modfl. This file targets PowrPC or Power platforms.
-**
-** Written by: A. Sazegari, Apple AltiVec Group
-** Created originally by Jon Okada, Apple Numerics Group
-**
-** Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved
-**
-** Change History (most recent first):
-**
-** 13 Jul 01 ram replaced --setflm calls with inline assembly
-** 03 Mar 01 ali first port to os x using gcc, added the crucial __setflm
-** definition.
-** 1. removed double_t, put in double for now.
-** 2. removed iclass from nearbyint.
-** 3. removed wrong comments intrunc.
-** 4.
-** 13 May 97 ali made performance improvements in rint, rinttol, roundtol
-** and trunc by folding some of the taligent ideas into this
-** implementation. nearbyint is faster than the one in taligent,
-** rint is more elegant, but slower by %30 than the taligent one.
-** 09 Apr 97 ali deleted modfl and deferred to AuxiliaryDD.c
-** 15 Sep 94 ali Major overhaul and performance improvements of all functions.
-** 20 Jul 94 PAF New faster version
-** 16 Jul 93 ali Added the modfl function.
-** 18 Feb 93 ali Changed the return value of fenv functions
-** feclearexcept and feraiseexcept to their new
-** NCEG X3J11.1/93-001 definitions.
-** 16 Dec 92 JPO Removed __itrunc implementation to a
-** separate file.
-** 15 Dec 92 JPO Added __itrunc implementation and modified
-** rinttol to include conversion from double
-** to long int format. Modified roundtol to
-** call __itrunc.
-** 10 Dec 92 JPO Added modf (double) implementation.
-** 04 Dec 92 JPO First created.
-**
-*******************************************************************************/
-
-#include <limits.h>
-#include <math.h>
-#include <endian.h>
-
-#define SET_INVALID 0x01000000UL
-
-typedef union
- {
- struct {
-#if (__BYTE_ORDER == __BIG_ENDIAN)
- unsigned long int hi;
- unsigned long int lo;
-#else
- unsigned long int lo;
- unsigned long int hi;
-#endif
- } words;
- double dbl;
- } DblInHex;
-
-static const unsigned long int signMask = 0x80000000ul;
-static const double twoTo52 = 4503599627370496.0;
-static const double doubleToLong = 4503603922337792.0; // 2^52
-static const DblInHex TOWARDZERO = {{ 0x00000000, 0x00000001 }};
-
-
-/*******************************************************************************
-* *
-* The function rinttol converts its double argument to integral value *
-* according to the current rounding direction and returns the result in *
-* long int format. This conversion signals invalid if the argument is a *
-* NaN or the rounded intermediate result is out of range of the *
-* destination long int format, and it delivers an unspecified result in *
-* this case. This function signals inexact if the rounded result is *
-* within range of the long int format but unequal to the operand. *
-* *
-*******************************************************************************/
-
-long int rinttol ( double x )
- {
- register double y;
- DblInHex argument, OldEnvironment;
- unsigned long int xHead;
- register long int target;
-
- argument.dbl = x;
- target = ( argument.words.hi < signMask ); // flag positive sign
- xHead = argument.words.hi & 0x7ffffffful; // high 32 bits of x
-
- if ( target )
-/*******************************************************************************
-* Sign of x is positive. *
-*******************************************************************************/
- {
- if ( xHead < 0x41dffffful )
- { // x is safely in long range
- y = ( x + twoTo52 ) - twoTo52; // round at binary point
- argument.dbl = y + doubleToLong; // force result into argument.words.lo
- return ( ( long ) argument.words.lo );
- }
-
- __asm__ ("mffs %0" : "=f" (OldEnvironment.dbl)); // get environment
-
- if ( xHead > 0x41dffffful )
- { // x is safely out of long range
- OldEnvironment.words.lo |= SET_INVALID;
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( OldEnvironment.dbl ));
- return ( LONG_MAX );
- }
-
-/*******************************************************************************
-* x > 0.0 and may or may not be out of range of long. *
-*******************************************************************************/
-
- y = ( x + twoTo52 ) - twoTo52; // do rounding
- if ( y > ( double ) LONG_MAX )
- { // out of range of long
- OldEnvironment.words.lo |= SET_INVALID;
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( OldEnvironment.dbl ));
- return ( LONG_MAX );
- }
- argument.dbl = y + doubleToLong; // in range
- return ( ( long ) argument.words.lo ); // return result & flags
- }
-
-/*******************************************************************************
-* Sign of x is negative. *
-*******************************************************************************/
- if ( xHead < 0x41e00000ul )
- { // x is safely in long range
- y = ( x - twoTo52 ) + twoTo52;
- argument.dbl = y + doubleToLong;
- return ( ( long ) argument.words.lo );
- }
-
- __asm__ ("mffs %0" : "=f" (OldEnvironment.dbl)); // get environment
-
- if ( xHead > 0x41e00000ul )
- { // x is safely out of long range
- OldEnvironment.words.lo |= SET_INVALID;
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( OldEnvironment.dbl ));
- return ( LONG_MIN );
- }
-
-/*******************************************************************************
-* x < 0.0 and may or may not be out of range of long. *
-*******************************************************************************/
-
- y = ( x - twoTo52 ) + twoTo52; // do rounding
- if ( y < ( double ) LONG_MIN )
- { // out of range of long
- OldEnvironment.words.lo |= SET_INVALID;
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( OldEnvironment.dbl ));
- return ( LONG_MIN );
- }
- argument.dbl = y + doubleToLong; // in range
- return ( ( long ) argument.words.lo ); // return result & flags
- }
-
-/*******************************************************************************
-* *
-* The function roundtol converts its double argument to integral format *
-* according to the "add half to the magnitude and chop" rounding mode of *
-* Pascal's Round function and FORTRAN's NINT function. This conversion *
-* signals invalid if the argument is a NaN or the rounded intermediate *
-* result is out of range of the destination long int format, and it *
-* delivers an unspecified result in this case. This function signals *
-* inexact if the rounded result is within range of the long int format but *
-* unequal to the operand. *
-* *
-*******************************************************************************/
-
-long int roundtol ( double x )
- {
- register double y, z;
- DblInHex argument, OldEnvironment;
- register unsigned long int xhi;
- register long int target;
- const DblInHex kTZ = {{ 0x0, 0x1 }};
- const DblInHex kUP = {{ 0x0, 0x2 }};
-
- argument.dbl = x;
- xhi = argument.words.hi & 0x7ffffffful; // high 32 bits of x
- target = ( argument.words.hi < signMask ); // flag positive sign
-
- if ( xhi > 0x41e00000ul )
-/*******************************************************************************
-* Is x is out of long range or NaN? *
-*******************************************************************************/
- {
- __asm__ ("mffs %0" : "=f" (OldEnvironment.dbl)); // get environment
- OldEnvironment.words.lo |= SET_INVALID;
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( OldEnvironment.dbl ));
- if ( target ) // pin result
- return ( LONG_MAX );
- else
- return ( LONG_MIN );
- }
-
- if ( target )
-/*******************************************************************************
-* Is sign of x is "+"? *
-*******************************************************************************/
- {
- if ( x < 2147483647.5 )
-/*******************************************************************************
-* x is in the range of a long. *
-*******************************************************************************/
- {
- y = ( x + doubleToLong ) - doubleToLong; // round at binary point
- if ( y != x )
- { // inexact case
- __asm__ ("mffs %0" : "=f" (OldEnvironment.dbl)); // save environment
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( kTZ.dbl )); // truncate rounding
- z = x + 0.5; // truncate x + 0.5
- argument.dbl = z + doubleToLong;
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( OldEnvironment.dbl ));
- return ( ( long ) argument.words.lo );
- }
-
- argument.dbl = y + doubleToLong; // force result into argument.words.lo
- return ( ( long ) argument.words.lo ); // return long result
- }
-/*******************************************************************************
-* Rounded positive x is out of the range of a long. *
-*******************************************************************************/
- __asm__ ("mffs %0" : "=f" (OldEnvironment.dbl));
- OldEnvironment.words.lo |= SET_INVALID;
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( OldEnvironment.dbl ));
- return ( LONG_MAX ); // return pinned result
- }
-/*******************************************************************************
-* x < 0.0 and may or may not be out of the range of a long. *
-*******************************************************************************/
- if ( x > -2147483648.5 )
-/*******************************************************************************
-* x is in the range of a long. *
-*******************************************************************************/
- {
- y = ( x + doubleToLong ) - doubleToLong; // round at binary point
- if ( y != x )
- { // inexact case
- __asm__ ("mffs %0" : "=f" (OldEnvironment.dbl)); // save environment
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( kUP.dbl )); // round up
- z = x - 0.5; // truncate x - 0.5
- argument.dbl = z + doubleToLong;
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( OldEnvironment.dbl ));
- return ( ( long ) argument.words.lo );
- }
-
- argument.dbl = y + doubleToLong;
- return ( ( long ) argument.words.lo ); // return long result
- }
-/*******************************************************************************
-* Rounded negative x is out of the range of a long. *
-*******************************************************************************/
- __asm__ ("mffs %0" : "=f" (OldEnvironment.dbl));
- OldEnvironment.words.lo |= SET_INVALID;
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( OldEnvironment.dbl ));
- return ( LONG_MIN ); // return pinned result
- }
-
-/*******************************************************************************
-* The modf family of functions separate a floating-point number into its *
-* fractional and integral parts, returning the fractional part and writing *
-* the integral part in floating-point format to the object pointed to by a *
-* pointer argument. If the input argument is integral or infinite in *
-* value, the return value is a zero with the sign of the input argument. *
-* The modf family of functions raises no floating-point exceptions. older *
-* implemenation set the INVALID flag due to signaling NaN input. *
-* *
-*******************************************************************************/
-
-/*******************************************************************************
-* modf is the double implementation. *
-*******************************************************************************/
-
-libm_hidden_proto(modf)
-double modf ( double x, double *iptr )
- {
- register double OldEnvironment, xtrunc;
- register unsigned long int xHead, signBit;
- DblInHex argument;
-
- argument.dbl = x;
- xHead = argument.words.hi & 0x7ffffffful; // |x| high bit pattern
- signBit = ( argument.words.hi & 0x80000000ul ); // isolate sign bit
- if (xHead == 0x7ff81fe0)
- signBit = signBit | 0;
-
- if ( xHead < 0x43300000ul )
-/*******************************************************************************
-* Is |x| < 2.0^53? *
-*******************************************************************************/
- {
- if ( xHead < 0x3ff00000ul )
-/*******************************************************************************
-* Is |x| < 1.0? *
-*******************************************************************************/
- {
- argument.words.hi = signBit; // truncate to zero
- argument.words.lo = 0ul;
- *iptr = argument.dbl;
- return ( x );
- }
-/*******************************************************************************
-* Is 1.0 < |x| < 2.0^52? *
-*******************************************************************************/
- __asm__ ("mffs %0" : "=f" (OldEnvironment)); // save environment
- // round toward zero
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( TOWARDZERO.dbl ));
- if ( signBit == 0ul ) // truncate to integer
- xtrunc = ( x + twoTo52 ) - twoTo52;
- else
- xtrunc = ( x - twoTo52 ) + twoTo52;
- // restore caller's env
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( OldEnvironment ));
- *iptr = xtrunc; // store integral part
- if ( x != xtrunc ) // nonzero fraction
- return ( x - xtrunc );
- else
- { // zero with x's sign
- argument.words.hi = signBit;
- argument.words.lo = 0ul;
- return ( argument.dbl );
- }
- }
-
- *iptr = x; // x is integral or NaN
- if ( x != x ) // NaN is returned
- return x;
- else
- { // zero with x's sign
- argument.words.hi = signBit;
- argument.words.lo = 0ul;
- return ( argument.dbl );
- }
- }
-libm_hidden_def(modf)
diff --git a/libm/powerpc/classic/s_nearbyint.c b/libm/powerpc/classic/s_nearbyint.c
deleted file mode 100644
index d08430dc6..000000000
--- a/libm/powerpc/classic/s_nearbyint.c
+++ /dev/null
@@ -1,38 +0,0 @@
-#include <limits.h>
-#include <math.h>
-
-/*******************************************************************************
-* *
-* The function nearbyint rounds its double argument to integral value *
-* according to the current rounding direction and returns the result in *
-* double format. This function does not signal inexact. *
-* *
-********************************************************************************
-* *
-* This function calls fabs and copysign. *
-* *
-*******************************************************************************/
-
-static const double twoTo52 = 4503599627370496.0;
-
-libm_hidden_proto(nearbyint)
-double nearbyint ( double x )
- {
- double y;
- double OldEnvironment;
-
- y = twoTo52;
-
- __asm__ ("mffs %0" : "=f" (OldEnvironment)); /* get the environement */
-
- if ( fabs ( x ) >= y ) /* huge case is exact */
- return x;
- if ( x < 0 ) y = -y; /* negative case */
- y = ( x + y ) - y; /* force rounding */
- if ( y == 0.0 ) /* zero results mirror sign of x */
- y = copysign ( y, x );
-// restore old flags
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( OldEnvironment ));
- return ( y );
- }
-libm_hidden_def(nearbyint)
diff --git a/libm/powerpc/classic/s_rint.c b/libm/powerpc/classic/s_rint.c
deleted file mode 100644
index dd2ae585e..000000000
--- a/libm/powerpc/classic/s_rint.c
+++ /dev/null
@@ -1,159 +0,0 @@
-/*******************************************************************************
-** File: rndint.c
-**
-** Contains: C source code for implementations of floating-point
-** functions which round to integral value or format, as
-** defined in header <fp.h>. In particular, this file
-** contains implementations of functions rint, nearbyint,
-** rinttol, round, roundtol, trunc, modf and modfl. This file
-** targets PowerPC or Power platforms.
-**
-** Written by: A. Sazegari, Apple AltiVec Group
-** Created originally by Jon Okada, Apple Numerics Group
-**
-** Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved
-**
-** Change History (most recent first):
-**
-** 13 Jul 01 ram replaced --setflm calls with inline assembly
-** 03 Mar 01 ali first port to os x using gcc, added the crucial __setflm
-** definition.
-** 1. removed double_t, put in double for now.
-** 2. removed iclass from nearbyint.
-** 3. removed wrong comments intrunc.
-** 4.
-** 13 May 97 ali made performance improvements in rint, rinttol, roundtol
-** and trunc by folding some of the taligent ideas into this
-** implementation. nearbyint is faster than the one in taligent,
-** rint is more elegant, but slower by %30 than the taligent one.
-** 09 Apr 97 ali deleted modfl and deferred to AuxiliaryDD.c
-** 15 Sep 94 ali Major overhaul and performance improvements of all functions.
-** 20 Jul 94 PAF New faster version
-** 16 Jul 93 ali Added the modfl function.
-** 18 Feb 93 ali Changed the return value of fenv functions
-** feclearexcept and feraiseexcept to their new
-** NCEG X3J11.1/93-001 definitions.
-** 16 Dec 92 JPO Removed __itrunc implementation to a
-** separate file.
-** 15 Dec 92 JPO Added __itrunc implementation and modified
-** rinttol to include conversion from double
-** to long int format. Modified roundtol to
-** call __itrunc.
-** 10 Dec 92 JPO Added modf (double) implementation.
-** 04 Dec 92 JPO First created.
-**
-*******************************************************************************/
-
-#include <limits.h>
-#include <math.h>
-#include <endian.h>
-
-#define SET_INVALID 0x01000000UL
-
-typedef union
- {
- struct {
-#if (__BYTE_ORDER == __BIG_ENDIAN)
- unsigned long int hi;
- unsigned long int lo;
-#else
- unsigned long int lo;
- unsigned long int hi;
-#endif
- } words;
- double dbl;
- } DblInHex;
-
-static const unsigned long int signMask = 0x80000000ul;
-static const double twoTo52 = 4503599627370496.0;
-static const double doubleToLong = 4503603922337792.0; // 2^52
-static const DblInHex Huge = {{ 0x7FF00000, 0x00000000 }};
-static const DblInHex TOWARDZERO = {{ 0x00000000, 0x00000001 }};
-
-libm_hidden_proto(rint)
-/*******************************************************************************
-* *
-* The function rint rounds its double argument to integral value *
-* according to the current rounding direction and returns the result in *
-* double format. This function signals inexact if an ordered return *
-* value is not equal to the operand. *
-* *
-********************************************************************************
-* *
-* This function calls: fabs. *
-* *
-*******************************************************************************/
-
-/*******************************************************************************
-* First, an elegant implementation. *
-********************************************************************************
-*
-*double rint ( double x )
-* {
-* double y;
-*
-* y = twoTo52.fval;
-*
-* if ( fabs ( x ) >= y ) // huge case is exact
-* return x;
-* if ( x < 0 ) y = -y; // negative case
-* y = ( x + y ) - y; // force rounding
-* if ( y == 0.0 ) // zero results mirror sign of x
-* y = copysign ( y, x );
-* return ( y );
-* }
-********************************************************************************
-* Now a bit twidling version that is about %30 faster. *
-*******************************************************************************/
-
-double rint ( double x )
- {
- DblInHex argument;
- register double y;
- unsigned long int xHead;
- register long int target;
-
- argument.dbl = x;
- xHead = argument.words.hi & 0x7fffffffUL; // xHead <- high half of |x|
- target = ( argument.words.hi < signMask ); // flags positive sign
-
- if ( xHead < 0x43300000ul )
-/*******************************************************************************
-* Is |x| < 2.0^52? *
-*******************************************************************************/
- {
- if ( xHead < 0x3ff00000ul )
-/*******************************************************************************
-* Is |x| < 1.0? *
-*******************************************************************************/
- {
- if ( target )
- y = ( x + twoTo52 ) - twoTo52; // round at binary point
- else
- y = ( x - twoTo52 ) + twoTo52; // round at binary point
- if ( y == 0.0 )
- { // fix sign of zero result
- if ( target )
- return ( 0.0 );
- else
- return ( -0.0 );
- }
- return y;
- }
-
-/*******************************************************************************
-* Is 1.0 < |x| < 2.0^52? *
-*******************************************************************************/
-
- if ( target )
- return ( ( x + twoTo52 ) - twoTo52 ); // round at binary pt.
- else
- return ( ( x - twoTo52 ) + twoTo52 );
- }
-
-/*******************************************************************************
-* |x| >= 2.0^52 or x is a NaN. *
-*******************************************************************************/
- return ( x );
- }
-libm_hidden_def(rint)
diff --git a/libm/powerpc/classic/s_round.c b/libm/powerpc/classic/s_round.c
deleted file mode 100644
index 9fd73801d..000000000
--- a/libm/powerpc/classic/s_round.c
+++ /dev/null
@@ -1,115 +0,0 @@
-#include <limits.h>
-#include <math.h>
-#include <endian.h>
-
-typedef union
- {
- struct {
-#if (__BYTE_ORDER == __BIG_ENDIAN)
- unsigned long int hi;
- unsigned long int lo;
-#else
- unsigned long int lo;
- unsigned long int hi;
-#endif
- } words;
- double dbl;
- } DblInHex;
-
-static const unsigned long int signMask = 0x80000000ul;
-static const double twoTo52 = 4503599627370496.0;
-
-/*******************************************************************************
-* *
-* The function round rounds its double argument to integral value *
-* according to the "add half to the magnitude and truncate" rounding of *
-* Pascal's Round function and FORTRAN's ANINT function and returns the *
-* result in double format. This function signals inexact if an ordered *
-* return value is not equal to the operand. *
-* *
-*******************************************************************************/
-
-libm_hidden_proto(round)
-double round ( double x )
- {
- DblInHex argument, OldEnvironment;
- register double y, z;
- register unsigned long int xHead;
- register long int target;
-
- argument.dbl = x;
- xHead = argument.words.hi & 0x7fffffffUL; // xHead <- high half of |x|
- target = ( argument.words.hi < signMask ); // flag positive sign
-
- if ( xHead < 0x43300000ul )
-/*******************************************************************************
-* Is |x| < 2.0^52? *
-*******************************************************************************/
- {
- if ( xHead < 0x3ff00000ul )
-/*******************************************************************************
-* Is |x| < 1.0? *
-*******************************************************************************/
- {
- __asm__ ("mffs %0" : "=f" (OldEnvironment.dbl)); // get environment
- if ( xHead < 0x3fe00000ul )
-/*******************************************************************************
-* Is |x| < 0.5? *
-*******************************************************************************/
- {
- if ( ( xHead | argument.words.lo ) != 0ul )
- OldEnvironment.words.lo |= 0x02000000ul;
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( OldEnvironment.dbl ));
- if ( target )
- return ( 0.0 );
- else
- return ( -0.0 );
- }
-/*******************************************************************************
-* Is 0.5 ² |x| < 1.0? *
-*******************************************************************************/
- OldEnvironment.words.lo |= 0x02000000ul;
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( OldEnvironment.dbl ));
- if ( target )
- return ( 1.0 );
- else
- return ( -1.0 );
- }
-/*******************************************************************************
-* Is 1.0 < |x| < 2.0^52? *
-*******************************************************************************/
- if ( target )
- { // positive x
- y = ( x + twoTo52 ) - twoTo52; // round at binary point
- if ( y == x ) // exact case
- return ( x );
- z = x + 0.5; // inexact case
- y = ( z + twoTo52 ) - twoTo52; // round at binary point
- if ( y > z )
- return ( y - 1.0 );
- else
- return ( y );
- }
-
-/*******************************************************************************
-* Is x < 0? *
-*******************************************************************************/
- else
- {
- y = ( x - twoTo52 ) + twoTo52; // round at binary point
- if ( y == x )
- return ( x );
- z = x - 0.5;
- y = ( z - twoTo52 ) + twoTo52; // round at binary point
- if ( y < z )
- return ( y + 1.0 );
- else
- return ( y );
- }
- }
-/*******************************************************************************
-* |x| >= 2.0^52 or x is a NaN. *
-*******************************************************************************/
- return ( x );
- }
-libm_hidden_def(round)
diff --git a/libm/powerpc/classic/s_trunc.c b/libm/powerpc/classic/s_trunc.c
deleted file mode 100644
index e9c668127..000000000
--- a/libm/powerpc/classic/s_trunc.c
+++ /dev/null
@@ -1,89 +0,0 @@
-#include <limits.h>
-#include <math.h>
-#include <endian.h>
-
-typedef union
- {
- struct {
-#if (__BYTE_ORDER == __BIG_ENDIAN)
- unsigned long int hi;
- unsigned long int lo;
-#else
- unsigned long int lo;
- unsigned long int hi;
-#endif
- } words;
- double dbl;
- } DblInHex;
-
-static const unsigned long int signMask = 0x80000000ul;
-static const double twoTo52 = 4503599627370496.0;
-
-/*******************************************************************************
-* *
-* The function trunc truncates its double argument to integral value *
-* and returns the result in double format. This function signals *
-* inexact if an ordered return value is not equal to the operand. *
-* *
-*******************************************************************************/
-
-libm_hidden_proto(trunc)
-double trunc ( double x )
- {
- DblInHex argument,OldEnvironment;
- register double y;
- register unsigned long int xhi;
- register long int target;
-
- argument.dbl = x;
- xhi = argument.words.hi & 0x7fffffffUL; // xhi <- high half of |x|
- target = ( argument.words.hi < signMask ); // flag positive sign
-
- if ( xhi < 0x43300000ul )
-/*******************************************************************************
-* Is |x| < 2.0^53? *
-*******************************************************************************/
- {
- if ( xhi < 0x3ff00000ul )
-/*******************************************************************************
-* Is |x| < 1.0? *
-*******************************************************************************/
- {
- if ( ( xhi | argument.words.lo ) != 0ul )
- { // raise deserved INEXACT
- __asm__ ("mffs %0" : "=f" (OldEnvironment.dbl));
- OldEnvironment.words.lo |= 0x02000000ul;
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( OldEnvironment.dbl ));
- }
- if ( target ) // return properly signed zero
- return ( 0.0 );
- else
- return ( -0.0 );
- }
-/*******************************************************************************
-* Is 1.0 < |x| < 2.0^52? *
-*******************************************************************************/
- if ( target )
- {
- y = ( x + twoTo52 ) - twoTo52; // round at binary point
- if ( y > x )
- return ( y - 1.0 );
- else
- return ( y );
- }
-
- else
- {
- y = ( x - twoTo52 ) + twoTo52; // round at binary point.
- if ( y < x )
- return ( y + 1.0 );
- else
- return ( y );
- }
- }
-/*******************************************************************************
-* Is |x| >= 2.0^52 or x is a NaN. *
-*******************************************************************************/
- return ( x );
- }
-libm_hidden_def(trunc)
diff --git a/libm/powerpc/classic/w_scalb.c b/libm/powerpc/classic/w_scalb.c
deleted file mode 100644
index 408136001..000000000
--- a/libm/powerpc/classic/w_scalb.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/***********************************************************************
-** File: scalb.c
-**
-** Contains: C source code for implementations of floating-point
-** scalb functions defined in header <fp.h>. In
-** particular, this file contains implementations of
-** functions scalb and scalbl for double and long double
-** formats on PowerPC platforms.
-**
-** Written by: Jon Okada, SANEitation Engineer, ext. 4-4838
-**
-** Copyright: © 1992 by Apple Computer, Inc., all rights reserved
-**
-** Change History ( most recent first ):
-**
-** 28 May 97 ali made an speed improvement for large n,
-** removed scalbl.
-** 12 Dec 92 JPO First created.
-**
-***********************************************************************/
-
-#include <math.h>
-#include <endian.h>
-
-typedef union
- {
- struct {
-#if (__BYTE_ORDER == __BIG_ENDIAN)
- unsigned long int hi;
- unsigned long int lo;
-#else
- unsigned long int lo;
- unsigned long int hi;
-#endif
- } words;
- double dbl;
- } DblInHex;
-
-static const double twoTo1023 = 8.988465674311579539e307; // 0x1p1023
-static const double twoToM1022 = 2.225073858507201383e-308; // 0x1p-1022
-
-
-/***********************************************************************
- double scalb( double x, long int n ) returns its argument x scaled
- by the factor 2^m. NaNs, signed zeros, and infinities are propagated
- by this function regardless of the value of n.
-
- Exceptions: OVERFLOW/INEXACT or UNDERFLOW inexact may occur;
- INVALID for signaling NaN inputs ( quiet NaN returned ).
-
- Calls: none.
-***********************************************************************/
-
-libm_hidden_proto(scalb)
-#ifdef _SCALB_INT
-double scalb ( double x, int n )
-#else
-double scalb ( double x, double n )
-#endif
- {
- DblInHex xInHex;
-
- xInHex.words.lo = 0UL; // init. low half of xInHex
-
- if ( n > 1023 )
- { // large positive scaling
- if ( n > 2097 ) // huge scaling
- return ( ( x * twoTo1023 ) * twoTo1023 ) * twoTo1023;
- while ( n > 1023 )
- { // scale reduction loop
- x *= twoTo1023; // scale x by 2^1023
- n -= 1023; // reduce n by 1023
- }
- }
-
- else if ( n < -1022 )
- { // large negative scaling
- if ( n < -2098 ) // huge negative scaling
- return ( ( x * twoToM1022 ) * twoToM1022 ) * twoToM1022;
- while ( n < -1022 )
- { // scale reduction loop
- x *= twoToM1022; // scale x by 2^( -1022 )
- n += 1022; // incr n by 1022
- }
- }
-
-/*******************************************************************************
-* -1022 <= n <= 1023; convert n to double scale factor. *
-*******************************************************************************/
-
- xInHex.words.hi = ( ( unsigned long ) ( n + 1023 ) ) << 20;
- return ( x * xInHex.dbl );
- }
-libm_hidden_def(scalb)
diff --git a/libm/powerpc/e500/Makefile.arch b/libm/powerpc/e500/Makefile.arch
index bec21caef..febde67be 100644
--- a/libm/powerpc/e500/Makefile.arch
+++ b/libm/powerpc/e500/Makefile.arch
@@ -5,5 +5,7 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
+libm_ARCH_fpu_DIR := $(libm_SUBARCH_DIR)/fpu
+libm_ARCH_fpu_OUT := $(libm_SUBARCH_OUT)/fpu
-include $(libm_ARCH_fpu_DIR)/Makefile.arch
diff --git a/libm/powerpc/e500/fpu/Makefile.arch b/libm/powerpc/e500/fpu/Makefile.arch
index 8f00e0916..904561e91 100644
--- a/libm/powerpc/e500/fpu/Makefile.arch
+++ b/libm/powerpc/e500/fpu/Makefile.arch
@@ -6,8 +6,10 @@
#
+ifeq ($(UCLIBC_HAS_FENV),y)
libm_ARCH_SRC:=$(wildcard $(libm_ARCH_fpu_DIR)/*.c)
libm_ARCH_OBJ:=$(patsubst $(libm_ARCH_fpu_DIR)/%.c,$(libm_ARCH_fpu_OUT)/%.o,$(libm_ARCH_SRC))
+endif
libm_ARCH_OBJS:=$(libm_ARCH_OBJ)
diff --git a/libm/powerpc/e500/fpu/fclrexcpt.c b/libm/powerpc/e500/fpu/fclrexcpt.c
index 42e8b6bab..805aaa487 100644
--- a/libm/powerpc/e500/fpu/fclrexcpt.c
+++ b/libm/powerpc/e500/fpu/fclrexcpt.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 "fenv_libc.h"
#undef feclearexcept
diff --git a/libm/powerpc/e500/fpu/fe_nomask.c b/libm/powerpc/e500/fpu/fe_nomask.c
index ad7b324c0..d5915165c 100644
--- a/libm/powerpc/e500/fpu/fe_nomask.c
+++ b/libm/powerpc/e500/fpu/fe_nomask.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 <fenv.h>
#include <errno.h>
diff --git a/libm/powerpc/e500/fpu/fedisblxcpt.c b/libm/powerpc/e500/fpu/fedisblxcpt.c
index aeca87bc6..0700f4577 100644
--- a/libm/powerpc/e500/fpu/fedisblxcpt.c
+++ b/libm/powerpc/e500/fpu/fedisblxcpt.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/>. */
#include "fenv_libc.h"
#include <syscall.h>
diff --git a/libm/powerpc/e500/fpu/feenablxcpt.c b/libm/powerpc/e500/fpu/feenablxcpt.c
index 999fdd734..9f03181f4 100644
--- a/libm/powerpc/e500/fpu/feenablxcpt.c
+++ b/libm/powerpc/e500/fpu/feenablxcpt.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/>. */
#include "fenv_libc.h"
#include <syscall.h>
diff --git a/libm/powerpc/e500/fpu/fegetenv.c b/libm/powerpc/e500/fpu/fegetenv.c
index fbafdc208..c1a914dc3 100644
--- a/libm/powerpc/e500/fpu/fegetenv.c
+++ b/libm/powerpc/e500/fpu/fegetenv.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/>. */
#include "fenv_libc.h"
#include <syscall.h>
diff --git a/libm/powerpc/e500/fpu/fegetexcept.c b/libm/powerpc/e500/fpu/fegetexcept.c
index c0398461c..bf0215d62 100644
--- a/libm/powerpc/e500/fpu/fegetexcept.c
+++ b/libm/powerpc/e500/fpu/fegetexcept.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/>. */
#include "fenv_libc.h"
diff --git a/libm/powerpc/e500/fpu/fegetround.c b/libm/powerpc/e500/fpu/fegetround.c
index 6e568fa23..f501c6ce8 100644
--- a/libm/powerpc/e500/fpu/fegetround.c
+++ b/libm/powerpc/e500/fpu/fegetround.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/>. */
#include "fenv_libc.h"
diff --git a/libm/powerpc/e500/fpu/feholdexcpt.c b/libm/powerpc/e500/fpu/feholdexcpt.c
index eccde4217..edeb2cf81 100644
--- a/libm/powerpc/e500/fpu/feholdexcpt.c
+++ b/libm/powerpc/e500/fpu/feholdexcpt.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/>. */
#include "fenv_libc.h"
#include <syscall.h>
diff --git a/libm/powerpc/e500/fpu/fenv_const.c b/libm/powerpc/e500/fpu/fenv_const.c
index 073fc9277..3c9f5578a 100644
--- a/libm/powerpc/e500/fpu/fenv_const.c
+++ b/libm/powerpc/e500/fpu/fenv_const.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/>. */
/* If the default argument is used we use this value. */
const unsigned long long __fe_dfl_env __attribute__ ((aligned (8))) =
diff --git a/libm/powerpc/e500/fpu/fenv_libc.h b/libm/powerpc/e500/fpu/fenv_libc.h
index 22c3f1452..0926fca37 100644
--- a/libm/powerpc/e500/fpu/fenv_libc.h
+++ b/libm/powerpc/e500/fpu/fenv_libc.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 _FENV_LIBC_H
#define _FENV_LIBC_H 1
diff --git a/libm/powerpc/e500/fpu/fesetenv.c b/libm/powerpc/e500/fpu/fesetenv.c
index cc0cc18be..392e0c0bf 100644
--- a/libm/powerpc/e500/fpu/fesetenv.c
+++ b/libm/powerpc/e500/fpu/fesetenv.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 "fenv_libc.h"
#include <syscall.h>
diff --git a/libm/powerpc/e500/fpu/fesetround.c b/libm/powerpc/e500/fpu/fesetround.c
index 0f29a91a6..783541d5b 100644
--- a/libm/powerpc/e500/fpu/fesetround.c
+++ b/libm/powerpc/e500/fpu/fesetround.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/>. */
#include "fenv_libc.h"
diff --git a/libm/powerpc/e500/fpu/feupdateenv.c b/libm/powerpc/e500/fpu/feupdateenv.c
index 03f3af8d9..47f316318 100644
--- a/libm/powerpc/e500/fpu/feupdateenv.c
+++ b/libm/powerpc/e500/fpu/feupdateenv.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/>. */
#include "fenv_libc.h"
#include <syscall.h>
diff --git a/libm/powerpc/e500/fpu/fgetexcptflg.c b/libm/powerpc/e500/fpu/fgetexcptflg.c
index 62d7f2c32..d27356574 100644
--- a/libm/powerpc/e500/fpu/fgetexcptflg.c
+++ b/libm/powerpc/e500/fpu/fgetexcptflg.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/>. */
#include "fenv_libc.h"
diff --git a/libm/powerpc/e500/fpu/fraiseexcpt.c b/libm/powerpc/e500/fpu/fraiseexcpt.c
index 39caf79d3..0c92b2868 100644
--- a/libm/powerpc/e500/fpu/fraiseexcpt.c
+++ b/libm/powerpc/e500/fpu/fraiseexcpt.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/>. */
#include "fenv_libc.h"
diff --git a/libm/powerpc/e500/fpu/fsetexcptflg.c b/libm/powerpc/e500/fpu/fsetexcptflg.c
index 8e4bb895d..11ea89f16 100644
--- a/libm/powerpc/e500/fpu/fsetexcptflg.c
+++ b/libm/powerpc/e500/fpu/fsetexcptflg.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 "fenv_libc.h"
diff --git a/libm/powerpc/e500/fpu/ftestexcept.c b/libm/powerpc/e500/fpu/ftestexcept.c
index 971c51965..55f752b25 100644
--- a/libm/powerpc/e500/fpu/ftestexcept.c
+++ b/libm/powerpc/e500/fpu/ftestexcept.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/>. */
#include "fenv_libc.h"
diff --git a/libm/powerpc/e500/spe-raise.c b/libm/powerpc/e500/spe-raise.c
index b83087fd0..42b1598bd 100644
--- a/libm/powerpc/e500/spe-raise.c
+++ b/libm/powerpc/e500/spe-raise.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 "fpu/fenv_libc.h"
diff --git a/libm/s_asinh.c b/libm/s_asinh.c
index 9e9a05660..7c79d6828 100644
--- a/libm/s_asinh.c
+++ b/libm/s_asinh.c
@@ -1,4 +1,3 @@
-/* @(#)s_asinh.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: s_asinh.c,v 1.9 1995/05/12 04:57:37 jtc Exp $";
-#endif
-
/* asinh(x)
* Method :
* Based on
@@ -28,25 +23,12 @@ static char rcsid[] = "$NetBSD: s_asinh.c,v 1.9 1995/05/12 04:57:37 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(log1p)
-libm_hidden_proto(fabs)
-
-#ifdef __STDC__
static const double
-#else
-static double
-#endif
one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
ln2 = 6.93147180559945286227e-01, /* 0x3FE62E42, 0xFEFA39EF */
huge= 1.00000000000000000000e+300;
-libm_hidden_proto(asinh)
-#ifdef __STDC__
- double asinh(double x)
-#else
- double asinh(x)
- double x;
-#endif
+double asinh(double x)
{
double t,w;
int32_t hx,ix;
diff --git a/libm/s_atan.c b/libm/s_atan.c
index 9c8035569..08cfb08e8 100644
--- a/libm/s_atan.c
+++ b/libm/s_atan.c
@@ -1,4 +1,3 @@
-/* @(#)s_atan.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: s_atan.c,v 1.8 1995/05/10 20:46:45 jtc Exp $";
-#endif
-
/* atan(x)
* Method
* 1. Reduce x to positive by atan(x) = -atan(-x).
@@ -37,35 +32,21 @@ static char rcsid[] = "$NetBSD: s_atan.c,v 1.8 1995/05/10 20:46:45 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(fabs)
-
-#ifdef __STDC__
static const double atanhi[] = {
-#else
-static double atanhi[] = {
-#endif
4.63647609000806093515e-01, /* atan(0.5)hi 0x3FDDAC67, 0x0561BB4F */
7.85398163397448278999e-01, /* atan(1.0)hi 0x3FE921FB, 0x54442D18 */
9.82793723247329054082e-01, /* atan(1.5)hi 0x3FEF730B, 0xD281F69B */
1.57079632679489655800e+00, /* atan(inf)hi 0x3FF921FB, 0x54442D18 */
};
-#ifdef __STDC__
static const double atanlo[] = {
-#else
-static double atanlo[] = {
-#endif
2.26987774529616870924e-17, /* atan(0.5)lo 0x3C7A2B7F, 0x222F65E2 */
3.06161699786838301793e-17, /* atan(1.0)lo 0x3C81A626, 0x33145C07 */
1.39033110312309984516e-17, /* atan(1.5)lo 0x3C700788, 0x7AF0CBBD */
6.12323399573676603587e-17, /* atan(inf)lo 0x3C91A626, 0x33145C07 */
};
-#ifdef __STDC__
static const double aT[] = {
-#else
-static double aT[] = {
-#endif
3.33333333333329318027e-01, /* 0x3FD55555, 0x5555550D */
-1.99999999998764832476e-01, /* 0xBFC99999, 0x9998EBC4 */
1.42857142725034663711e-01, /* 0x3FC24924, 0x920083FF */
@@ -79,21 +60,11 @@ static double aT[] = {
1.62858201153657823623e-02, /* 0x3F90AD3A, 0xE322DA11 */
};
-libm_hidden_proto(atan)
-#ifdef __STDC__
- static const double
-#else
- static double
-#endif
+static const double
one = 1.0,
huge = 1.0e300;
-#ifdef __STDC__
- double atan(double x)
-#else
- double atan(x)
- double x;
-#endif
+double atan(double x)
{
double w,s1,s2,z;
int32_t ix,hx,id;
diff --git a/libm/s_cbrt.c b/libm/s_cbrt.c
index f4635874c..14e8ab02f 100644
--- a/libm/s_cbrt.c
+++ b/libm/s_cbrt.c
@@ -1,4 +1,3 @@
-/* @(#)s_cbrt.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,42 +9,24 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: s_cbrt.c,v 1.8 1995/05/10 20:46:49 jtc Exp $";
-#endif
-
#include "math.h"
#include "math_private.h"
/* cbrt(x)
* Return cube root of x
*/
-#ifdef __STDC__
static const u_int32_t
-#else
-static u_int32_t
-#endif
B1 = 715094163, /* B1 = (682-0.03306235651)*2**20 */
B2 = 696219795; /* B2 = (664-0.03306235651)*2**20 */
-#ifdef __STDC__
static const double
-#else
-static double
-#endif
C = 5.42857142857142815906e-01, /* 19/35 = 0x3FE15F15, 0xF15F15F1 */
D = -7.05306122448979611050e-01, /* -864/1225 = 0xBFE691DE, 0x2532C834 */
E = 1.41428571428571436819e+00, /* 99/70 = 0x3FF6A0EA, 0x0EA0EA0F */
F = 1.60714285714285720630e+00, /* 45/28 = 0x3FF9B6DB, 0x6DB6DB6E */
G = 3.57142857142857150787e-01; /* 5/14 = 0x3FD6DB6D, 0xB6DB6DB7 */
-libm_hidden_proto(cbrt)
-#ifdef __STDC__
- double cbrt(double x)
-#else
- double cbrt(x)
- double x;
-#endif
+double cbrt(double x)
{
int32_t hx;
double r,s,t=0.0,w;
diff --git a/libm/s_ceil.c b/libm/s_ceil.c
index 46839410e..edbf9346f 100644
--- a/libm/s_ceil.c
+++ b/libm/s_ceil.c
@@ -1,4 +1,3 @@
-/* @(#)s_ceil.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: s_ceil.c,v 1.8 1995/05/10 20:46:53 jtc Exp $";
-#endif
-
/*
* ceil(x)
* Return x rounded toward -inf to integral value
@@ -23,52 +18,45 @@ static char rcsid[] = "$NetBSD: s_ceil.c,v 1.8 1995/05/10 20:46:53 jtc Exp $";
* Inexact flag raised if x not equal to ceil(x).
*/
+#include <features.h>
+/* Prevent math.h from defining a colliding inline */
+#undef __USE_EXTERN_INLINES
#include "math.h"
#include "math_private.h"
-#ifdef __STDC__
static const double huge = 1.0e300;
-#else
-static double huge = 1.0e300;
-#endif
-libm_hidden_proto(ceil)
-#ifdef __STDC__
- double ceil(double x)
-#else
- double ceil(x)
- double x;
-#endif
+double ceil(double x)
{
- int32_t i0,i1,j0;
+ int32_t i0,i1,_j0;
u_int32_t i,j;
EXTRACT_WORDS(i0,i1,x);
- j0 = ((i0>>20)&0x7ff)-0x3ff;
- if(j0<20) {
- if(j0<0) { /* raise inexact if x != 0 */
+ _j0 = ((i0>>20)&0x7ff)-0x3ff;
+ if(_j0<20) {
+ if(_j0<0) { /* raise inexact if x != 0 */
if(huge+x>0.0) {/* return 0*sign(x) if |x|<1 */
if(i0<0) {i0=0x80000000;i1=0;}
else if((i0|i1)!=0) { i0=0x3ff00000;i1=0;}
}
} else {
- i = (0x000fffff)>>j0;
+ i = (0x000fffff)>>_j0;
if(((i0&i)|i1)==0) return x; /* x is integral */
if(huge+x>0.0) { /* raise inexact flag */
- if(i0>0) i0 += (0x00100000)>>j0;
+ if(i0>0) i0 += (0x00100000)>>_j0;
i0 &= (~i); i1=0;
}
}
- } else if (j0>51) {
- if(j0==0x400) return x+x; /* inf or NaN */
+ } else if (_j0>51) {
+ if(_j0==0x400) return x+x; /* inf or NaN */
else return x; /* x is integral */
} else {
- i = ((u_int32_t)(0xffffffff))>>(j0-20);
+ i = ((u_int32_t)(0xffffffff))>>(_j0-20);
if((i1&i)==0) return x; /* x is integral */
if(huge+x>0.0) { /* raise inexact flag */
if(i0>0) {
- if(j0==20) i0+=1;
+ if(_j0==20) i0+=1;
else {
- j = i1 + (1<<(52-j0));
+ j = i1 + (1<<(52-_j0));
if(j<i1) i0+=1; /* got a carry */
i1 = j;
}
diff --git a/libm/s_copysign.c b/libm/s_copysign.c
index 145a26cc1..33e153167 100644
--- a/libm/s_copysign.c
+++ b/libm/s_copysign.c
@@ -1,4 +1,3 @@
-/* @(#)s_copysign.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: s_copysign.c,v 1.8 1995/05/10 20:46:57 jtc Exp $";
-#endif
-
/*
* copysign(double x, double y)
* copysign(x,y) returns a value with the magnitude of x and
@@ -23,13 +18,7 @@ static char rcsid[] = "$NetBSD: s_copysign.c,v 1.8 1995/05/10 20:46:57 jtc Exp $
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(copysign)
-#ifdef __STDC__
- double copysign(double x, double y)
-#else
- double copysign(x,y)
- double x,y;
-#endif
+double copysign(double x, double y)
{
u_int32_t hx,hy;
GET_HIGH_WORD(hx,x);
diff --git a/libm/s_cos.c b/libm/s_cos.c
index f05a8a53b..c4b1f8643 100644
--- a/libm/s_cos.c
+++ b/libm/s_cos.c
@@ -1,4 +1,3 @@
-/* @(#)s_cos.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: s_cos.c,v 1.7 1995/05/10 20:47:02 jtc Exp $";
-#endif
-
/* cos(x)
* Return cosine function of x.
*
@@ -48,13 +43,7 @@ static char rcsid[] = "$NetBSD: s_cos.c,v 1.7 1995/05/10 20:47:02 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(cos)
-#ifdef __STDC__
- double cos(double x)
-#else
- double cos(x)
- double x;
-#endif
+double cos(double x)
{
double y[2],z=0.0;
int32_t n, ix;
diff --git a/libm/s_erf.c b/libm/s_erf.c
index 0d24e2174..27083d240 100644
--- a/libm/s_erf.c
+++ b/libm/s_erf.c
@@ -1,4 +1,3 @@
-/* @(#)s_erf.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: s_erf.c,v 1.8 1995/05/10 20:47:05 jtc Exp $";
-#endif
-
/* double erf(double x)
* double erfc(double x)
* x
@@ -108,17 +103,10 @@ static char rcsid[] = "$NetBSD: s_erf.c,v 1.8 1995/05/10 20:47:05 jtc Exp $";
* erfc/erf(NaN) is NaN
*/
-
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(fabs)
-
-#ifdef __STDC__
static const double
-#else
-static double
-#endif
tiny = 1e-300,
half= 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */
one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
@@ -193,13 +181,7 @@ sb5 = 2.55305040643316442583e+03, /* 0x40A3F219, 0xCEDF3BE6 */
sb6 = 4.74528541206955367215e+02, /* 0x407DA874, 0xE79FE763 */
sb7 = -2.24409524465858183362e+01; /* 0xC03670E2, 0x42712D62 */
-libm_hidden_proto(erf)
-#ifdef __STDC__
- double erf(double x)
-#else
- double erf(x)
- double x;
-#endif
+double erf(double x)
{
int32_t hx,ix,i;
double R,S,P,Q,s,y,z,r;
@@ -251,13 +233,7 @@ libm_hidden_proto(erf)
}
libm_hidden_def(erf)
-libm_hidden_proto(erfc)
-#ifdef __STDC__
- double erfc(double x)
-#else
- double erfc(x)
- double x;
-#endif
+double erfc(double x)
{
int32_t hx,ix;
double R,S,P,Q,s,y,z,r;
diff --git a/libm/s_expm1.c b/libm/s_expm1.c
index 2adeead0b..8e51ae748 100644
--- a/libm/s_expm1.c
+++ b/libm/s_expm1.c
@@ -1,4 +1,3 @@
-/* @(#)s_expm1.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: s_expm1.c,v 1.8 1995/05/10 20:47:09 jtc Exp $";
-#endif
-
/* expm1(x)
* Returns exp(x)-1, the exponential of x minus 1.
*
@@ -112,11 +107,7 @@ static char rcsid[] = "$NetBSD: s_expm1.c,v 1.8 1995/05/10 20:47:09 jtc Exp $";
#include "math.h"
#include "math_private.h"
-#ifdef __STDC__
static const double
-#else
-static double
-#endif
one = 1.0,
huge = 1.0e+300,
tiny = 1.0e-300,
@@ -131,13 +122,7 @@ Q3 = -7.93650757867487942473e-05, /* BF14CE19 9EAADBB7 */
Q4 = 4.00821782732936239552e-06, /* 3ED0CFCA 86E65239 */
Q5 = -2.01099218183624371326e-07; /* BE8AFDB7 6E09C32D */
-libm_hidden_proto(expm1)
-#ifdef __STDC__
- double expm1(double x)
-#else
- double expm1(x)
- double x;
-#endif
+double expm1(double x)
{
double y,hi,lo,c=0.0,t,e,hxs,hfx,r1;
int32_t k,xsb;
diff --git a/libm/s_fabs.c b/libm/s_fabs.c
index c1538ca9e..d2c647ff3 100644
--- a/libm/s_fabs.c
+++ b/libm/s_fabs.c
@@ -1,4 +1,3 @@
-/* @(#)s_fabs.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,24 +9,17 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: s_fabs.c,v 1.7 1995/05/10 20:47:13 jtc Exp $";
-#endif
-
/*
* fabs(x) returns the absolute value of x.
*/
+#include <features.h>
+/* Prevent math.h from defining a colliding inline */
+#undef __USE_EXTERN_INLINES
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(fabs)
-#ifdef __STDC__
- double fabs(double x)
-#else
- double fabs(x)
- double x;
-#endif
+double fabs(double x)
{
u_int32_t high;
GET_HIGH_WORD(high,x);
diff --git a/libm/s_fdim.c b/libm/s_fdim.c
new file mode 100644
index 000000000..6ed695c3d
--- /dev/null
+++ b/libm/s_fdim.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software
+ * is freely granted, provided that this notice is preserved.
+ */
+
+#include "math.h"
+#include "math_private.h"
+#include <errno.h>
+
+double fdim(double x, double y)
+{
+ int cx = __fpclassify(x); /* need both NAN and INF */
+ int cy = __fpclassify(y); /* need both NAN and INF */
+ if (cx == FP_NAN || cy == NAN)
+ return x - y;
+
+ if (x <= y)
+ return .0;
+
+ double z = x - y;
+ if (isinf(z) && cx != FP_INFINITE && cy != FP_INFINITE)
+ __set_errno(ERANGE);
+
+ return z;
+}
+libm_hidden_def(fdim)
diff --git a/libm/s_finite.c b/libm/s_finite.c
index 70b9aadc4..9bbc00286 100644
--- a/libm/s_finite.c
+++ b/libm/s_finite.c
@@ -1,4 +1,3 @@
-/* @(#)s_finite.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,29 +9,24 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: s_finite.c,v 1.8 1995/05/10 20:47:17 jtc Exp $";
-#endif
-
/*
* finite(x) returns 1 is x is finite, else 0;
* no branching!
*/
+#include <features.h>
+/* Prevent math.h from defining a colliding inline */
+#undef __USE_EXTERN_INLINES
#include "math.h"
#include "math_private.h"
-#ifdef __STDC__
- int __finite(double x)
-#else
- int __finite(x)
- double x;
-#endif
+int __finite(double x)
{
- int32_t hx;
- GET_HIGH_WORD(hx,x);
- return (int)((u_int32_t)((hx&0x7fffffff)-0x7ff00000)>>31);
+ u_int32_t hx;
+
+ GET_HIGH_WORD(hx, x);
+ /* Finite numbers have at least one zero bit in exponent. */
+ /* All other numbers will result in 0xffffffff after OR: */
+ return (hx | 0x800fffff) != 0xffffffff;
}
-libm_hidden_proto(finite)
-strong_alias(__finite,finite)
-libm_hidden_def(finite)
+libm_hidden_def(__finite)
diff --git a/libm/s_finitef.c b/libm/s_finitef.c
new file mode 100644
index 000000000..b427ea691
--- /dev/null
+++ b/libm/s_finitef.c
@@ -0,0 +1,33 @@
+/* s_finitef.c -- float version of s_finite.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@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.
+ * ====================================================
+ */
+
+/*
+ * finitef(x) returns 1 is x is finite, else 0;
+ * no branching!
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+int __finitef(float x)
+{
+ u_int32_t ix;
+
+ GET_FLOAT_WORD(ix, x);
+ /* Finite numbers have at least one zero bit in exponent. */
+ /* All other numbers will result in 0xffffffff after OR: */
+ return (ix | 0x807fffff) != 0xffffffff;
+}
+libm_hidden_def(__finitef)
diff --git a/libm/s_floor.c b/libm/s_floor.c
index 39b24c05b..21d9821e4 100644
--- a/libm/s_floor.c
+++ b/libm/s_floor.c
@@ -1,4 +1,3 @@
-/* @(#)s_floor.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: s_floor.c,v 1.8 1995/05/10 20:47:20 jtc Exp $";
-#endif
-
/*
* floor(x)
* Return x rounded toward -inf to integral value
@@ -23,53 +18,46 @@ static char rcsid[] = "$NetBSD: s_floor.c,v 1.8 1995/05/10 20:47:20 jtc Exp $";
* Inexact flag raised if x not equal to floor(x).
*/
+#include <features.h>
+/* Prevent math.h from defining a colliding inline */
+#undef __USE_EXTERN_INLINES
#include "math.h"
#include "math_private.h"
-#ifdef __STDC__
static const double huge = 1.0e300;
-#else
-static double huge = 1.0e300;
-#endif
-libm_hidden_proto(floor)
-#ifdef __STDC__
- double floor(double x)
-#else
- double floor(x)
- double x;
-#endif
+double floor(double x)
{
- int32_t i0,i1,j0;
+ int32_t i0,i1,_j0;
u_int32_t i,j;
EXTRACT_WORDS(i0,i1,x);
- j0 = ((i0>>20)&0x7ff)-0x3ff;
- if(j0<20) {
- if(j0<0) { /* raise inexact if x != 0 */
+ _j0 = ((i0>>20)&0x7ff)-0x3ff;
+ if(_j0<20) {
+ if(_j0<0) { /* raise inexact if x != 0 */
if(huge+x>0.0) {/* return 0*sign(x) if |x|<1 */
if(i0>=0) {i0=i1=0;}
else if(((i0&0x7fffffff)|i1)!=0)
{ i0=0xbff00000;i1=0;}
}
} else {
- i = (0x000fffff)>>j0;
+ i = (0x000fffff)>>_j0;
if(((i0&i)|i1)==0) return x; /* x is integral */
if(huge+x>0.0) { /* raise inexact flag */
- if(i0<0) i0 += (0x00100000)>>j0;
+ if(i0<0) i0 += (0x00100000)>>_j0;
i0 &= (~i); i1=0;
}
}
- } else if (j0>51) {
- if(j0==0x400) return x+x; /* inf or NaN */
+ } else if (_j0>51) {
+ if(_j0==0x400) return x+x; /* inf or NaN */
else return x; /* x is integral */
} else {
- i = ((u_int32_t)(0xffffffff))>>(j0-20);
+ i = ((u_int32_t)(0xffffffff))>>(_j0-20);
if((i1&i)==0) return x; /* x is integral */
if(huge+x>0.0) { /* raise inexact flag */
if(i0<0) {
- if(j0==20) i0+=1;
+ if(_j0==20) i0+=1;
else {
- j = i1+(1<<(52-j0));
+ j = i1+(1<<(52-_j0));
if(j<i1) i0 +=1 ; /* got a carry */
i1=j;
}
diff --git a/libm/s_fma.c b/libm/s_fma.c
new file mode 100644
index 000000000..986dbeb3b
--- /dev/null
+++ b/libm/s_fma.c
@@ -0,0 +1,27 @@
+/* Compute x * y + z as ternary operation.
+ Copyright (C) 1997, 2001 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <math.h>
+
+double
+fma (double x, double y, double z)
+{
+ return (x * y) + z;
+}
+libm_hidden_def(fma)
diff --git a/libm/s_fmax.c b/libm/s_fmax.c
new file mode 100644
index 000000000..5f29ad8e3
--- /dev/null
+++ b/libm/s_fmax.c
@@ -0,0 +1,19 @@
+/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software
+ * is freely granted, provided that this notice is preserved.
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+double fmax(double x, double y)
+{
+ if (isnan(x))
+ return y;
+ if (isnan(y))
+ return x;
+
+ return x > y ? x : y;
+}
+libm_hidden_def(fmax)
diff --git a/libm/s_fmin.c b/libm/s_fmin.c
new file mode 100644
index 000000000..a549678ee
--- /dev/null
+++ b/libm/s_fmin.c
@@ -0,0 +1,19 @@
+/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software
+ * is freely granted, provided that this notice is preserved.
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+double fmin(double x, double y)
+{
+ if (isnan(x))
+ return y;
+ if (isnan(y))
+ return x;
+
+ return x < y ? x : y;
+}
+libm_hidden_def(fmin)
diff --git a/libm/s_fpclassify.c b/libm/s_fpclassify.c
new file mode 100644
index 000000000..f810828ce
--- /dev/null
+++ b/libm/s_fpclassify.c
@@ -0,0 +1,41 @@
+/* Return classification value corresponding to argument.
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <math.h>
+
+#include "math_private.h"
+
+int __fpclassify(double x)
+{
+ u_int32_t hx, lx;
+ int retval = FP_NORMAL;
+
+ EXTRACT_WORDS (hx, lx, x);
+ lx |= hx & 0xfffff;
+ hx &= 0x7ff00000;
+ if ((hx | lx) == 0)
+ retval = FP_ZERO;
+ else if (hx == 0)
+ retval = FP_SUBNORMAL;
+ else if (hx == 0x7ff00000)
+ retval = lx != 0 ? FP_NAN : FP_INFINITE;
+
+ return retval;
+}
+libm_hidden_def(__fpclassify)
diff --git a/libm/s_fpclassifyf.c b/libm/s_fpclassifyf.c
new file mode 100644
index 000000000..65d34b2fa
--- /dev/null
+++ b/libm/s_fpclassifyf.c
@@ -0,0 +1,39 @@
+/* Return classification value corresponding to argument.
+ Copyright (C) 1997, 2000, 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <math.h>
+#include "math_private.h"
+
+int __fpclassifyf (float x)
+{
+ u_int32_t wx;
+ int retval = FP_NORMAL;
+
+ GET_FLOAT_WORD (wx, x);
+ wx &= 0x7fffffff;
+ if (wx == 0)
+ retval = FP_ZERO;
+ else if (wx < 0x800000)
+ retval = FP_SUBNORMAL;
+ else if (wx >= 0x7f800000)
+ retval = wx > 0x7f800000 ? FP_NAN : FP_INFINITE;
+
+ return retval;
+}
+libm_hidden_def(__fpclassifyf)
diff --git a/libm/s_frexp.c b/libm/s_frexp.c
index ed5e31395..212ec47af 100644
--- a/libm/s_frexp.c
+++ b/libm/s_frexp.c
@@ -1,4 +1,3 @@
-/* @(#)s_frexp.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: s_frexp.c,v 1.9 1995/05/10 20:47:24 jtc Exp $";
-#endif
-
/*
* for non-zero x
* x = frexp(arg,&exp);
@@ -27,20 +22,10 @@ static char rcsid[] = "$NetBSD: s_frexp.c,v 1.9 1995/05/10 20:47:24 jtc Exp $";
#include "math.h"
#include "math_private.h"
-#ifdef __STDC__
static const double
-#else
-static double
-#endif
two54 = 1.80143985094819840000e+16; /* 0x43500000, 0x00000000 */
-libm_hidden_proto(frexp)
-#ifdef __STDC__
- double frexp(double x, int *eptr)
-#else
- double frexp(x, eptr)
- double x; int *eptr;
-#endif
+double frexp(double x, int *eptr)
{
int32_t hx, ix, lx;
EXTRACT_WORDS(hx,lx,x);
diff --git a/libm/s_ilogb.c b/libm/s_ilogb.c
index db7c8553e..259ae7b55 100644
--- a/libm/s_ilogb.c
+++ b/libm/s_ilogb.c
@@ -1,4 +1,3 @@
-/* @(#)s_ilogb.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,44 +9,49 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: s_ilogb.c,v 1.9 1995/05/10 20:47:28 jtc Exp $";
-#endif
-
/* ilogb(double x)
- * return the binary exponent of non-zero x
- * ilogb(0) = 0x80000001
- * ilogb(inf/NaN) = 0x7fffffff (no signal is raised)
+ * return the binary exponent of x
+ * ilogb(+-0) = FP_ILOGB0
+ * ilogb(+-inf) = INT_MAX
+ * ilogb(NaN) = FP_ILOGBNAN (no signal is raised)
*/
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(ilogb)
-#ifdef __STDC__
- int ilogb(double x)
-#else
- int ilogb(x)
- double x;
-#endif
+int ilogb(double x)
{
int32_t hx,lx,ix;
- GET_HIGH_WORD(hx,x);
+ GET_HIGH_WORD(hx, x);
hx &= 0x7fffffff;
- if(hx<0x00100000) {
- GET_LOW_WORD(lx,x);
- if((hx|lx)==0)
- return 0x80000001; /* ilogb(0) = 0x80000001 */
- else /* subnormal x */
- if(hx==0) {
- for (ix = -1043; lx>0; lx<<=1) ix -=1;
- } else {
- for (ix = -1022,hx<<=11; hx>0; hx<<=1) ix -=1;
+
+ if (hx < 0x00100000) {
+ GET_LOW_WORD(lx, x);
+ if ((hx|lx)==0) /* +-0, ilogb(0) = FP_ILOGB0 */
+ return FP_ILOGB0;
+ /* subnormal x */
+ ix = -1043;
+ if (hx != 0) {
+ ix = -1022;
+ lx = (hx << 11);
}
- return ix;
+ /* each leading zero mantissa bit makes exponent smaller */
+ for (; lx > 0; lx <<= 1)
+ ix--;
+ return ix;
+ }
+
+ if (hx < 0x7ff00000) /* normal x */
+ return (hx>>20) - 1023;
+
+ if (FP_ILOGBNAN != (~0U >> 1)) {
+ GET_LOW_WORD(lx, x);
+ if (hx == 0x7ff00000 && lx == 0) /* +-inf */
+ return ~0U >> 1; /* = INT_MAX */
}
- else if (hx<0x7ff00000) return (hx>>20)-1023;
- else return 0x7fffffff;
+
+ /* NAN. ilogb(NAN) = FP_ILOGBNAN */
+ return FP_ILOGBNAN;
}
libm_hidden_def(ilogb)
diff --git a/libm/s_isinf.c b/libm/s_isinf.c
new file mode 100644
index 000000000..62e5263bb
--- /dev/null
+++ b/libm/s_isinf.c
@@ -0,0 +1,23 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Changed to return -1 for -Inf by Ulrich Drepper <drepper@cygnus.com>.
+ * Public domain.
+ */
+
+/*
+ * isinf(x) returns 1 is x is inf, -1 if x is -inf, else 0;
+ * no branching!
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+int __isinf(double x)
+{
+ int32_t hx,lx;
+ EXTRACT_WORDS(hx,lx,x);
+ lx |= (hx & 0x7fffffff) ^ 0x7ff00000;
+ lx |= -lx;
+ return ~(lx >> 31) & (hx >> 30);
+}
+libm_hidden_def(__isinf)
diff --git a/libm/s_isinff.c b/libm/s_isinff.c
new file mode 100644
index 000000000..6727f0464
--- /dev/null
+++ b/libm/s_isinff.c
@@ -0,0 +1,23 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+/*
+ * isinff(x) returns 1 if x is inf, -1 if x is -inf, else 0;
+ * no branching!
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+int __isinff (float x)
+{
+ int32_t ix,t;
+ GET_FLOAT_WORD(ix,x);
+ t = ix & 0x7fffffff;
+ t ^= 0x7f800000;
+ t |= -t;
+ return ~(t >> 31) & (ix >> 30);
+}
+libm_hidden_def(__isinff)
diff --git a/libm/e_gamma.c b/libm/s_isnan.c
index 296ebb8f3..1bc49cb02 100644
--- a/libm/e_gamma.c
+++ b/libm/s_isnan.c
@@ -1,5 +1,3 @@
-
-/* @(#)e_gamma.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -9,27 +7,23 @@
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
- *
*/
-/* __ieee754_gamma(x)
- * Return the logarithm of the Gamma function of x.
- *
- * Method: call __ieee754_gamma_r
+/*
+ * isnan(x) returns 1 is x is nan, else 0;
+ * no branching!
*/
-#include <math.h>
+#include "math.h"
#include "math_private.h"
-libm_hidden_proto(signgam)
-
-#ifdef __STDC__
- //__private_extern__
- double attribute_hidden __ieee754_gamma(double x)
-#else
- double attribute_hidden __ieee754_gamma(x)
- double x;
-#endif
+int __isnan(double x)
{
- return __ieee754_gamma_r(x,&signgam);
+ int32_t hx,lx;
+ EXTRACT_WORDS(hx,lx,x);
+ hx &= 0x7fffffff;
+ hx |= (u_int32_t)(lx|(-lx))>>31;
+ hx = 0x7ff00000 - hx;
+ return (int)(((u_int32_t)hx)>>31);
}
+libm_hidden_def(__isnan)
diff --git a/libm/s_matherr.c b/libm/s_isnanf.c
index 0c102e628..d868264f7 100644
--- a/libm/s_matherr.c
+++ b/libm/s_isnanf.c
@@ -1,4 +1,7 @@
-/* @(#)s_matherr.c 5.1 93/09/24 */
+/* s_isnanf.c -- float version of s_isnan.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,26 +13,20 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: s_matherr.c,v 1.6 1995/05/10 20:47:53 jtc Exp $";
-#endif
+/*
+ * isnanf(x) returns 1 is x is nan, else 0;
+ * no branching!
+ */
#include "math.h"
#include "math_private.h"
-#ifndef _IEEE_LIBM
-
-libm_hidden_proto(matherr)
-#ifdef __STDC__
- int matherr(struct exception *x)
-#else
- int matherr(x)
- struct exception *x;
-#endif
+int __isnanf(float x)
{
- int n=0;
- if(x->arg1!=x->arg1) return 0;
- return n;
+ int32_t ix;
+ GET_FLOAT_WORD(ix,x);
+ ix &= 0x7fffffff;
+ ix = 0x7f800000 - ix;
+ return (int)(((u_int32_t)(ix))>>31);
}
-libm_hidden_def(matherr)
-#endif
+libm_hidden_def(__isnanf)
diff --git a/libm/s_ldexp.c b/libm/s_ldexp.c
index ffc268b52..bc0f08e99 100644
--- a/libm/s_ldexp.c
+++ b/libm/s_ldexp.c
@@ -1,4 +1,3 @@
-/* @(#)s_ldexp.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,28 +9,31 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: s_ldexp.c,v 1.6 1995/05/10 20:47:40 jtc Exp $";
-#endif
-
#include "math.h"
#include "math_private.h"
#include <errno.h>
-libm_hidden_proto(scalbn)
-libm_hidden_proto(finite)
+/* TODO: POSIX says:
+ *
+ * "If the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
+ * then errno shall be set to [ERANGE]. If the integer expression
+ * (math_errhandling & MATH_ERREXCEPT) is non-zero, then the underflow
+ * floating-point exception shall be raised."
+ *
+ * *And it says the same about scalbn*! Thus these two functions
+ * are the same and can be just aliased.
+ *
+ * Currently, ldexp tries to be vaguely POSIX compliant while scalbn
+ * does not (it does not set ERRNO).
+ */
-libm_hidden_proto(ldexp)
-#ifdef __STDC__
- double ldexp(double value, int exp)
-#else
- double ldexp(value, exp)
- double value; int exp;
-#endif
+double ldexp(double value, int _exp)
{
- if(!finite(value)||value==0.0) return value;
- value = scalbn(value,exp);
- if(!finite(value)||value==0.0) errno = ERANGE;
+ if (!isfinite(value) || value == 0.0)
+ return value;
+ value = scalbn(value, _exp);
+ if (!isfinite(value) || value == 0.0)
+ errno = ERANGE;
return value;
}
libm_hidden_def(ldexp)
diff --git a/libm/s_lib_version.c b/libm/s_lib_version.c
index fde8e3bf6..e3119423f 100644
--- a/libm/s_lib_version.c
+++ b/libm/s_lib_version.c
@@ -1,4 +1,3 @@
-/* @(#)s_lib_ver.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: s_lib_version.c,v 1.6 1995/05/10 20:47:44 jtc Exp $";
-#endif
-
/*
* MACRO for standards
*/
diff --git a/libm/s_llrint.c b/libm/s_llrint.c
index 047290ab8..d0c97422f 100644
--- a/libm/s_llrint.c
+++ b/libm/s_llrint.c
@@ -15,12 +15,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 <features.h>
+/* Prevent math.h from defining a colliding inline */
+#undef __USE_EXTERN_INLINES
#include <math.h>
-
#include "math_private.h"
static const double two52[2] =
@@ -29,12 +30,10 @@ static const double two52[2] =
-4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */
};
-libm_hidden_proto(llrint)
-
long long int
llrint (double x)
{
- int32_t j0;
+ int32_t _j0;
u_int32_t i1, i0;
long long int result;
volatile double w;
@@ -42,39 +41,39 @@ llrint (double x)
int sx;
EXTRACT_WORDS (i0, i1, x);
- j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
+ _j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
sx = i0 >> 31;
i0 &= 0xfffff;
i0 |= 0x100000;
- if (j0 < 20)
+ if (_j0 < 20)
{
w = two52[sx] + x;
t = w - two52[sx];
EXTRACT_WORDS (i0, i1, t);
- j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
+ _j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
i0 &= 0xfffff;
i0 |= 0x100000;
- result = (j0 < 0 ? 0 : i0 >> (20 - j0));
+ result = (_j0 < 0 ? 0 : i0 >> (20 - _j0));
}
- else if (j0 < (int32_t) (8 * sizeof (long long int)) - 1)
+ else if (_j0 < (int32_t) (8 * sizeof (long long int)) - 1)
{
- if (j0 >= 52)
- result = (((long long int) i0 << 32) | i1) << (j0 - 52);
+ if (_j0 >= 52)
+ result = (((long long int) i0 << 32) | i1) << (_j0 - 52);
else
{
w = two52[sx] + x;
t = w - two52[sx];
EXTRACT_WORDS (i0, i1, t);
- j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
+ _j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
i0 &= 0xfffff;
i0 |= 0x100000;
- if (j0 == 20)
+ if (_j0 == 20)
result = (long long int) i0;
else
- result = ((long long int) i0 << (j0 - 20)) | (i1 >> (52 - j0));
+ result = ((long long int) i0 << (_j0 - 20)) | (i1 >> (52 - _j0));
}
}
else
diff --git a/libm/s_llround.c b/libm/s_llround.c
index 1db0c2836..889e979bb 100644
--- a/libm/s_llround.c
+++ b/libm/s_llround.c
@@ -14,54 +14,51 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 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>
-
#include "math_private.h"
-libm_hidden_proto(llround)
long long int
llround (double x)
{
- int32_t j0;
+ int32_t _j0;
u_int32_t i1, i0;
long long int result;
int sign;
EXTRACT_WORDS (i0, i1, x);
- j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
+ _j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
sign = (i0 & 0x80000000) != 0 ? -1 : 1;
i0 &= 0xfffff;
i0 |= 0x100000;
- if (j0 < 20)
+ if (_j0 < 20)
{
- if (j0 < 0)
- return j0 < -1 ? 0 : sign;
+ if (_j0 < 0)
+ return _j0 < -1 ? 0 : sign;
else
{
- i0 += 0x80000 >> j0;
+ i0 += 0x80000 >> _j0;
- result = i0 >> (20 - j0);
+ result = i0 >> (20 - _j0);
}
}
- else if (j0 < (int32_t) (8 * sizeof (long long int)) - 1)
+ else if (_j0 < (int32_t) (8 * sizeof (long long int)) - 1)
{
- if (j0 >= 52)
- result = (((long long int) i0 << 32) | i1) << (j0 - 52);
+ if (_j0 >= 52)
+ result = (((long long int) i0 << 32) | i1) << (_j0 - 52);
else
{
- u_int32_t j = i1 + (0x80000000 >> (j0 - 20));
+ u_int32_t j = i1 + (0x80000000 >> (_j0 - 20));
if (j < i1)
++i0;
- if (j0 == 20)
+ if (_j0 == 20)
result = (long long int) i0;
else
- result = ((long long int) i0 << (j0 - 20)) | (j >> (52 - j0));
+ result = ((long long int) i0 << (_j0 - 20)) | (j >> (52 - _j0));
}
}
else
diff --git a/libm/s_log1p.c b/libm/s_log1p.c
index 7acf6289b..454056300 100644
--- a/libm/s_log1p.c
+++ b/libm/s_log1p.c
@@ -1,4 +1,3 @@
-/* @(#)s_log1p.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: s_log1p.c,v 1.8 1995/05/10 20:47:46 jtc Exp $";
-#endif
-
/* double log1p(double x)
*
* Method :
@@ -82,11 +77,7 @@ static char rcsid[] = "$NetBSD: s_log1p.c,v 1.8 1995/05/10 20:47:46 jtc Exp $";
#include "math.h"
#include "math_private.h"
-#ifdef __STDC__
static const double
-#else
-static double
-#endif
ln2_hi = 6.93147180369123816490e-01, /* 3fe62e42 fee00000 */
ln2_lo = 1.90821492927058770002e-10, /* 3dea39ef 35793c76 */
two54 = 1.80143985094819840000e+16, /* 43500000 00000000 */
@@ -98,19 +89,9 @@ Lp5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */
Lp6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */
Lp7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
-#ifdef __STDC__
static const double zero = 0.0;
-#else
-static double zero = 0.0;
-#endif
-libm_hidden_proto(log1p)
-#ifdef __STDC__
- double log1p(double x)
-#else
- double log1p(x)
- double x;
-#endif
+double log1p(double x)
{
double hfsq,f=0,c=0,s,z,R,u;
int32_t k,hx,hu=0,ax;
diff --git a/libm/s_logb.c b/libm/s_logb.c
index ff47ab476..9016b9721 100644
--- a/libm/s_logb.c
+++ b/libm/s_logb.c
@@ -1,4 +1,3 @@
-/* @(#)s_logb.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: s_logb.c,v 1.8 1995/05/10 20:47:50 jtc Exp $";
-#endif
-
/*
* double logb(x)
* IEEE 754 logb. Included to pass IEEE test suite. Not recommend.
@@ -23,15 +18,7 @@ static char rcsid[] = "$NetBSD: s_logb.c,v 1.8 1995/05/10 20:47:50 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(fabs)
-
-libm_hidden_proto(logb)
-#ifdef __STDC__
- double logb(double x)
-#else
- double logb(x)
- double x;
-#endif
+double logb(double x)
{
int32_t lx,ix;
EXTRACT_WORDS(ix,lx,x);
diff --git a/libm/s_lrint.c b/libm/s_lrint.c
index 61c521240..09800d8de 100644
--- a/libm/s_lrint.c
+++ b/libm/s_lrint.c
@@ -15,12 +15,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 <features.h>
+/* Prevent math.h from defining a colliding inline */
+#undef __USE_EXTERN_INLINES
#include <math.h>
-
#include "math_private.h"
static const double two52[2] =
@@ -30,11 +31,10 @@ static const double two52[2] =
};
-libm_hidden_proto(lrint)
long int
lrint (double x)
{
- int32_t j0;
+ int32_t _j0;
u_int32_t i0,i1;
volatile double w;
double t;
@@ -42,44 +42,44 @@ lrint (double x)
int sx;
EXTRACT_WORDS (i0, i1, x);
- j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
+ _j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
sx = i0 >> 31;
i0 &= 0xfffff;
i0 |= 0x100000;
- if (j0 < 20)
+ if (_j0 < 20)
{
- if (j0 < -1)
+ if (_j0 < -1)
return 0;
else
{
w = two52[sx] + x;
t = w - two52[sx];
EXTRACT_WORDS (i0, i1, t);
- j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
+ _j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
i0 &= 0xfffff;
i0 |= 0x100000;
- result = i0 >> (20 - j0);
+ result = i0 >> (20 - _j0);
}
}
- else if (j0 < (int32_t) (8 * sizeof (long int)) - 1)
+ else if (_j0 < (int32_t) (8 * sizeof (long int)) - 1)
{
- if (j0 >= 52)
- result = ((long int) i0 << (j0 - 20)) | (i1 << (j0 - 52));
+ if (_j0 >= 52)
+ result = ((long int) i0 << (_j0 - 20)) | (i1 << (_j0 - 52));
else
{
w = two52[sx] + x;
t = w - two52[sx];
EXTRACT_WORDS (i0, i1, t);
- j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
+ _j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
i0 &= 0xfffff;
i0 |= 0x100000;
- if (j0 == 20)
+ if (_j0 == 20)
result = (long int) i0;
else
- result = ((long int) i0 << (j0 - 20)) | (i1 >> (52 - j0));
+ result = ((long int) i0 << (_j0 - 20)) | (i1 >> (52 - _j0));
}
}
else
diff --git a/libm/s_lround.c b/libm/s_lround.c
index 604004f7f..7a9e1f9fd 100644
--- a/libm/s_lround.c
+++ b/libm/s_lround.c
@@ -14,54 +14,51 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 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>
-
#include "math_private.h"
-libm_hidden_proto(lround)
long int
lround (double x)
{
- int32_t j0;
+ int32_t _j0;
u_int32_t i1, i0;
long int result;
int sign;
EXTRACT_WORDS (i0, i1, x);
- j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
+ _j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
sign = (i0 & 0x80000000) != 0 ? -1 : 1;
i0 &= 0xfffff;
i0 |= 0x100000;
- if (j0 < 20)
+ if (_j0 < 20)
{
- if (j0 < 0)
- return j0 < -1 ? 0 : sign;
+ if (_j0 < 0)
+ return _j0 < -1 ? 0 : sign;
else
{
- i0 += 0x80000 >> j0;
+ i0 += 0x80000 >> _j0;
- result = i0 >> (20 - j0);
+ result = i0 >> (20 - _j0);
}
}
- else if (j0 < (int32_t) (8 * sizeof (long int)) - 1)
+ else if (_j0 < (int32_t) (8 * sizeof (long int)) - 1)
{
- if (j0 >= 52)
- result = ((long int) i0 << (j0 - 20)) | (i1 << (j0 - 52));
+ if (_j0 >= 52)
+ result = ((long int) i0 << (_j0 - 20)) | (i1 << (_j0 - 52));
else
{
- u_int32_t j = i1 + (0x80000000 >> (j0 - 20));
+ u_int32_t j = i1 + (0x80000000 >> (_j0 - 20));
if (j < i1)
++i0;
- if (j0 == 20)
+ if (_j0 == 20)
result = (long int) i0;
else
- result = ((long int) i0 << (j0 - 20)) | (j >> (52 - j0));
+ result = ((long int) i0 << (_j0 - 20)) | (j >> (52 - _j0));
}
}
else
diff --git a/libm/s_modf.c b/libm/s_modf.c
index 0cf0e8356..0a2026cea 100644
--- a/libm/s_modf.c
+++ b/libm/s_modf.c
@@ -1,4 +1,3 @@
-/* @(#)s_modf.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: s_modf.c,v 1.8 1995/05/10 20:47:55 jtc Exp $";
-#endif
-
/*
* modf(double x, double *iptr)
* return fraction part of x, and return x's integral part in *iptr.
@@ -27,54 +22,41 @@ static char rcsid[] = "$NetBSD: s_modf.c,v 1.8 1995/05/10 20:47:55 jtc Exp $";
#include "math.h"
#include "math_private.h"
-#ifdef __STDC__
static const double one = 1.0;
-#else
-static double one = 1.0;
-#endif
-libm_hidden_proto(modf)
-#ifdef __STDC__
- double modf(double x, double *iptr)
-#else
- double modf(x, iptr)
- double x,*iptr;
-#endif
+double modf(double x, double *iptr)
{
- int32_t i0,i1,j0;
+ int32_t i0,i1,_j0;
u_int32_t i;
EXTRACT_WORDS(i0,i1,x);
- j0 = ((i0>>20)&0x7ff)-0x3ff; /* exponent of x */
- if(j0<20) { /* integer part in high x */
- if(j0<0) { /* |x|<1 */
+ _j0 = ((i0>>20)&0x7ff)-0x3ff; /* exponent of x */
+ if(_j0<20) { /* integer part in high x */
+ if(_j0<0) { /* |x|<1 */
INSERT_WORDS(*iptr,i0&0x80000000,0); /* *iptr = +-0 */
return x;
} else {
- i = (0x000fffff)>>j0;
+ i = (0x000fffff)>>_j0;
if(((i0&i)|i1)==0) { /* x is integral */
- u_int32_t high;
*iptr = x;
- GET_HIGH_WORD(high,x);
- INSERT_WORDS(x,high&0x80000000,0); /* return +-0 */
+ INSERT_WORDS(x,i0&0x80000000,0); /* return +-0 */
return x;
} else {
INSERT_WORDS(*iptr,i0&(~i),0);
return x - *iptr;
}
}
- } else if (j0>51) { /* no fraction part */
- u_int32_t high;
+ } else if (_j0>51) { /* no fraction part */
*iptr = x*one;
- GET_HIGH_WORD(high,x);
- INSERT_WORDS(x,high&0x80000000,0); /* return +-0 */
+ /* We must handle NaNs separately. */
+ if (_j0 == 0x400 && ((i0 & 0xfffff) | i1))
+ return x*one;
+ INSERT_WORDS(x,i0&0x80000000,0); /* return +-0 */
return x;
} else { /* fraction part in low x */
- i = ((u_int32_t)(0xffffffff))>>(j0-20);
+ i = ((u_int32_t)(0xffffffff))>>(_j0-20);
if((i1&i)==0) { /* x is integral */
- u_int32_t high;
*iptr = x;
- GET_HIGH_WORD(high,x);
- INSERT_WORDS(x,high&0x80000000,0); /* return +-0 */
+ INSERT_WORDS(x,i0&0x80000000,0); /* return +-0 */
return x;
} else {
INSERT_WORDS(*iptr,i0,i1&(~i));
diff --git a/libm/s_nextafter.c b/libm/s_nextafter.c
index bdc6f3a61..73a8ab2be 100644
--- a/libm/s_nextafter.c
+++ b/libm/s_nextafter.c
@@ -1,4 +1,3 @@
-/* @(#)s_nextafter.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: s_nextafter.c,v 1.8 1995/05/10 20:47:58 jtc Exp $";
-#endif
-
/* IEEE functions
* nextafter(x,y)
* return the next machine floating-point number of x in the
@@ -24,13 +19,7 @@ static char rcsid[] = "$NetBSD: s_nextafter.c,v 1.8 1995/05/10 20:47:58 jtc Exp
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(nextafter)
-#ifdef __STDC__
- double nextafter(double x, double y)
-#else
- double nextafter(x,y)
- double x,y;
-#endif
+double nextafter(double x, double y)
{
int32_t hx,hy,ix,iy;
u_int32_t lx,ly;
@@ -43,7 +32,7 @@ libm_hidden_proto(nextafter)
if(((ix>=0x7ff00000)&&((ix-0x7ff00000)|lx)!=0) || /* x is nan */
((iy>=0x7ff00000)&&((iy-0x7ff00000)|ly)!=0)) /* y is nan */
return x+y;
- if(x==y) return x; /* x=y, return x */
+ if(x==y) return y; /* x=y, return y */
if((ix|lx)==0) { /* x == 0 */
INSERT_WORDS(x,hy&0x80000000,1); /* return +-minsubnormal */
y = x*x;
@@ -79,3 +68,5 @@ libm_hidden_proto(nextafter)
return x;
}
libm_hidden_def(nextafter)
+strong_alias_untyped(nextafter, nexttoward)
+libm_hidden_def(nexttoward)
diff --git a/libm/s_nextafterf.c b/libm/s_nextafterf.c
new file mode 100644
index 000000000..e0cb81613
--- /dev/null
+++ b/libm/s_nextafterf.c
@@ -0,0 +1,96 @@
+/* s_nextafterf.c -- float version of s_nextafter.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@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.
+ * ====================================================
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+float nextafterf(float x, float y)
+{
+ int32_t hx, hy, ix, iy;
+
+ GET_FLOAT_WORD(hx, x);
+ GET_FLOAT_WORD(hy, y);
+ ix = hx & 0x7fffffff; /* |x| */
+ iy = hy & 0x7fffffff; /* |y| */
+
+ /* x is nan or y is nan? */
+ if ((ix > 0x7f800000) || (iy > 0x7f800000))
+ return x + y;
+
+ if (x == y)
+ return y;
+
+ if (ix == 0) { /* x == 0? */
+/* glibc 2.4 does not seem to set underflow? */
+/* float u; */
+ /* return +-minsubnormal */
+ SET_FLOAT_WORD(x, (hy & 0x80000000) | 1);
+/* u = x * x; raise underflow flag */
+/* math_force_eval(u); */
+ return x;
+ }
+
+ if (hx >= 0) { /* x > 0 */
+ if (hx > hy) { /* x > y: x -= ulp */
+ hx -= 1;
+ } else { /* x < y: x += ulp */
+ hx += 1;
+ }
+ } else { /* x < 0 */
+ if (hy >= 0 || hx > hy) { /* x < y: x -= ulp */
+ hx -= 1;
+ } else { /* x > y: x += ulp */
+ hx += 1;
+ }
+ }
+ hy = hx & 0x7f800000;
+ if (hy >= 0x7f800000) {
+ x = x + x; /* overflow */
+ return x; /* overflow */
+ }
+ if (hy < 0x00800000) {
+ float u = x * x; /* underflow */
+ math_force_eval(u); /* raise underflow flag */
+ }
+ SET_FLOAT_WORD(x, hx);
+ return x;
+}
+
+#if 0
+/* "testprog N a b"
+ * calculates a = nextafterf(a, b) and prints a as float
+ * and as raw bytes; repeats it N times.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+int main(int argc, char **argv)
+{
+ int cnt, i;
+ float a, b;
+ cnt = atoi(argv[1]);
+ a = strtod(argv[2], NULL);
+ b = strtod(argv[3], NULL);
+ while (cnt-- > 0) {
+ for (i = 0; i < sizeof(a); i++) {
+ unsigned char c = ((char*)(&a))[i];
+ printf("%x%x", (c >> 4), (c & 0xf));
+ }
+ printf(" %f\n", a);
+ a = nextafterf(a, b);
+ }
+ return 0;
+}
+#endif
diff --git a/libm/s_remquo.c b/libm/s_remquo.c
new file mode 100644
index 000000000..f72c56f3f
--- /dev/null
+++ b/libm/s_remquo.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software
+ * is freely granted, provided that this notice is preserved.
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+double remquo(double x, double y, int *quo) /* wrapper remquo */
+{
+ int signx, signy, signres;
+ int mswx;
+ int mswy;
+ double x_over_y;
+
+ GET_HIGH_WORD(mswx, x);
+ GET_HIGH_WORD(mswy, y);
+
+ signx = (mswx & 0x80000000) >> 31;
+ signy = (mswy & 0x80000000) >> 31;
+
+ signres = (signx ^ signy) ? -1 : 1;
+
+ x_over_y = fabs(x / y);
+
+ *quo = signres * (lrint(x_over_y) & 0x7f);
+
+ return remainder(x,y);
+}
+libm_hidden_def(remquo)
diff --git a/libm/s_rint.c b/libm/s_rint.c
index ce42aa99d..02ec404e6 100644
--- a/libm/s_rint.c
+++ b/libm/s_rint.c
@@ -1,4 +1,3 @@
-/* @(#)s_rint.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: s_rint.c,v 1.8 1995/05/10 20:48:04 jtc Exp $";
-#endif
-
/*
* rint(x)
* Return x rounded to integral value according to the prevailing
@@ -27,62 +22,71 @@ static char rcsid[] = "$NetBSD: s_rint.c,v 1.8 1995/05/10 20:48:04 jtc Exp $";
#include "math.h"
#include "math_private.h"
-#ifdef __STDC__
static const double
-#else
-static double
-#endif
TWO52[2]={
4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */
-4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */
};
-libm_hidden_proto(rint)
-#ifdef __STDC__
- double rint(double x)
-#else
- double rint(x)
- double x;
-#endif
+double rint(double x)
{
- int32_t i0,j0,sx;
+ int32_t i0, _j0, sx;
u_int32_t i,i1;
- double w,t;
+ double t;
+ /* We use w = x + 2^52; t = w - 2^52; trick to round x to integer.
+ * This trick requires that compiler does not optimize it
+ * by keeping intermediate result w in a register wider than double.
+ * Declaring w volatile assures that value gets truncated to double
+ * (unfortunately, it also forces store+load):
+ */
+ volatile double w;
+
EXTRACT_WORDS(i0,i1,x);
- sx = (i0>>31)&1;
- j0 = ((i0>>20)&0x7ff)-0x3ff;
- if(j0<20) {
- if(j0<0) {
- if(((i0&0x7fffffff)|i1)==0) return x;
+ /* Unbiased exponent */
+ _j0 = ((((u_int32_t)i0) >> 20)&0x7ff)-0x3ff;
+
+ if (_j0 > 51) {
+ //Why bother? Just returning x works too
+ //if (_j0 == 0x400) /* inf or NaN */
+ // return x+x;
+ return x; /* x is integral */
+ }
+
+ /* Sign */
+ sx = ((u_int32_t)i0) >> 31;
+
+ if (_j0<20) {
+ if (_j0<0) { /* |x| < 1 */
+ if (((i0&0x7fffffff)|i1)==0) return x;
i1 |= (i0&0x0fffff);
i0 &= 0xfffe0000;
i0 |= ((i1|-i1)>>12)&0x80000;
SET_HIGH_WORD(x,i0);
- w = TWO52[sx]+x;
- t = w-TWO52[sx];
+ w = TWO52[sx]+x;
+ t = w-TWO52[sx];
GET_HIGH_WORD(i0,t);
SET_HIGH_WORD(t,(i0&0x7fffffff)|(sx<<31));
- return t;
+ return t;
} else {
- i = (0x000fffff)>>j0;
- if(((i0&i)|i1)==0) return x; /* x is integral */
+ i = (0x000fffff)>>_j0;
+ if (((i0&i)|i1)==0) return x; /* x is integral */
i>>=1;
- if(((i0&i)|i1)!=0) {
- if(j0==19) i1 = 0x40000000; else
- i0 = (i0&(~i))|((0x20000)>>j0);
+ if (((i0&i)|i1)!=0) {
+ if (_j0==19) i1 = 0x40000000;
+ else i0 = (i0&(~i))|((0x20000)>>_j0);
}
}
- } else if (j0>51) {
- if(j0==0x400) return x+x; /* inf or NaN */
- else return x; /* x is integral */
} else {
- i = ((u_int32_t)(0xffffffff))>>(j0-20);
- if((i1&i)==0) return x; /* x is integral */
+ i = ((u_int32_t)(0xffffffff))>>(_j0-20);
+ if ((i1&i)==0) return x; /* x is integral */
i>>=1;
- if((i1&i)!=0) i1 = (i1&(~i))|((0x40000000)>>(j0-20));
+ if ((i1&i)!=0) i1 = (i1&(~i))|((0x40000000)>>(_j0-20));
}
INSERT_WORDS(x,i0,i1);
w = TWO52[sx]+x;
return w-TWO52[sx];
}
libm_hidden_def(rint)
+
+strong_alias(rint, nearbyint)
+libm_hidden_def(nearbyint)
diff --git a/libm/s_round.c b/libm/s_round.c
index 03089482b..cf5d280e3 100644
--- a/libm/s_round.c
+++ b/libm/s_round.c
@@ -14,56 +14,52 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 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>
-
#include "math_private.h"
-
static const double huge = 1.0e300;
-libm_hidden_proto(round)
double
round (double x)
{
- int32_t i0, j0;
+ int32_t i0, _j0;
u_int32_t i1;
EXTRACT_WORDS (i0, i1, x);
- j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
- if (j0 < 20)
+ _j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
+ if (_j0 < 20)
{
- if (j0 < 0)
+ if (_j0 < 0)
{
if (huge + x > 0.0)
{
i0 &= 0x80000000;
- if (j0 == -1)
+ if (_j0 == -1)
i0 |= 0x3ff00000;
i1 = 0;
}
}
else
{
- u_int32_t i = 0x000fffff >> j0;
+ u_int32_t i = 0x000fffff >> _j0;
if (((i0 & i) | i1) == 0)
/* X is integral. */
return x;
if (huge + x > 0.0)
{
/* Raise inexact if x != 0. */
- i0 += 0x00080000 >> j0;
+ i0 += 0x00080000 >> _j0;
i0 &= ~i;
i1 = 0;
}
}
}
- else if (j0 > 51)
+ else if (_j0 > 51)
{
- if (j0 == 0x400)
+ if (_j0 == 0x400)
/* Inf or NaN. */
return x + x;
else
@@ -71,7 +67,7 @@ round (double x)
}
else
{
- u_int32_t i = 0xffffffff >> (j0 - 20);
+ u_int32_t i = 0xffffffff >> (_j0 - 20);
if ((i1 & i) == 0)
/* X is integral. */
return x;
@@ -79,7 +75,7 @@ round (double x)
if (huge + x > 0.0)
{
/* Raise inexact if x != 0. */
- u_int32_t j = i1 + (1 << (51 - j0));
+ u_int32_t j = i1 + (1 << (51 - _j0));
if (j < i1)
i0 += 1;
i1 = j;
diff --git a/libm/s_scalbn.c b/libm/s_scalbn.c
index 6a7452485..4d2005c72 100644
--- a/libm/s_scalbn.c
+++ b/libm/s_scalbn.c
@@ -1,4 +1,3 @@
-/* @(#)s_scalbn.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,62 +9,64 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: s_scalbn.c,v 1.8 1995/05/10 20:48:08 jtc Exp $";
-#endif
-
/*
- * scalbn (double x, int n)
- * scalbn(x,n) returns x* 2**n computed by exponent
+ * scalbln(double x, long n)
+ * scalbln(x,n) returns x * 2**n computed by exponent
* manipulation rather than by actually performing an
* exponentiation or a multiplication.
*/
#include "math.h"
#include "math_private.h"
+#include <limits.h>
-libm_hidden_proto(copysign)
-
-#ifdef __STDC__
static const double
-#else
-static double
-#endif
-two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */
-twom54 = 5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */
+two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */
+twom54 = 5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */
huge = 1.0e+300,
tiny = 1.0e-300;
-libm_hidden_proto(scalbn)
-#ifdef __STDC__
- double scalbn (double x, int n)
-#else
- double scalbn (x,n)
- double x; int n;
-#endif
+double scalbln(double x, long n)
{
- int32_t k,hx,lx;
- EXTRACT_WORDS(hx,lx,x);
- k = (hx&0x7ff00000)>>20; /* extract exponent */
- if (k==0) { /* 0 or subnormal x */
- if ((lx|(hx&0x7fffffff))==0) return x; /* +-0 */
- x *= two54;
- GET_HIGH_WORD(hx,x);
- k = ((hx&0x7ff00000)>>20) - 54;
- if (n< -50000) return tiny*x; /*underflow*/
- }
- if (k==0x7ff) return x+x; /* NaN or Inf */
- k = k+n;
- if (k > 0x7fe) return huge*copysign(huge,x); /* overflow */
- if (k > 0) /* normal result */
- {SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20)); return x;}
- if (k <= -54) {
- if (n > 50000) /* in case integer overflow in n+k */
- return huge*copysign(huge,x); /*overflow*/
- else return tiny*copysign(tiny,x); /*underflow*/
+ int32_t k, hx, lx;
+
+ EXTRACT_WORDS(hx, lx, x);
+ k = (hx & 0x7ff00000) >> 20; /* extract exponent */
+ if (k == 0) { /* 0 or subnormal x */
+ if ((lx | (hx & 0x7fffffff)) == 0)
+ return x; /* +-0 */
+ x *= two54;
+ GET_HIGH_WORD(hx, x);
+ k = ((hx & 0x7ff00000) >> 20) - 54;
}
- k += 54; /* subnormal result */
- SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20));
- return x*twom54;
+ if (k == 0x7ff)
+ return x + x; /* NaN or Inf */
+ k = k + n;
+ if (k > 0x7fe)
+ return huge * copysign(huge, x); /* overflow */
+ if (n < -50000)
+ return tiny * copysign(tiny, x); /* underflow */
+ if (k > 0) { /* normal result */
+ SET_HIGH_WORD(x, (hx & 0x800fffff) | (k << 20));
+ return x;
+ }
+ if (k <= -54) {
+ if (n > 50000) /* in case integer overflow in n+k */
+ return huge * copysign(huge, x); /* overflow */
+ return tiny * copysign(tiny, x); /* underflow */
+ }
+ k += 54; /* subnormal result */
+ SET_HIGH_WORD(x, (hx & 0x800fffff) | (k << 20));
+ return x * twom54;
}
+libm_hidden_def(scalbln)
+
+#if LONG_MAX == INT_MAX
+strong_alias_untyped(scalbln,scalbn)
+#else
+double scalbn(double x, int n)
+{
+ return scalbln(x, n);
+}
+#endif
libm_hidden_def(scalbn)
diff --git a/libm/s_signbit.c b/libm/s_signbit.c
new file mode 100644
index 000000000..398a5eecf
--- /dev/null
+++ b/libm/s_signbit.c
@@ -0,0 +1,34 @@
+/* Return nonzero value if number is negative.
+ Copyright (C) 1997 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <features.h>
+/* Prevent math.h from defining a colliding inline */
+#undef __USE_EXTERN_INLINES
+#include <math.h>
+#include "math_private.h"
+
+int
+__signbit (double x)
+{
+ int32_t hx;
+
+ GET_HIGH_WORD (hx, x);
+ return hx & 0x80000000;
+}
+libm_hidden_def(__signbit)
diff --git a/libm/s_signbitf.c b/libm/s_signbitf.c
new file mode 100644
index 000000000..b72fee677
--- /dev/null
+++ b/libm/s_signbitf.c
@@ -0,0 +1,34 @@
+/* Return nonzero value if number is negative.
+ Copyright (C) 1997 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <features.h>
+/* Prevent math.h from defining a colliding inline */
+#undef __USE_EXTERN_INLINES
+#include <math.h>
+#include "math_private.h"
+
+int
+__signbitf (float x)
+{
+ int32_t hx;
+
+ GET_FLOAT_WORD (hx, x);
+ return hx & 0x80000000;
+}
+libm_hidden_def(__signbitf)
diff --git a/libm/s_signgam.c b/libm/s_signgam.c
index 13d2a1c34..d67d5918e 100644
--- a/libm/s_signgam.c
+++ b/libm/s_signgam.c
@@ -1,5 +1,3 @@
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(signgam)
int signgam = 0;
-libm_hidden_def(signgam)
diff --git a/libm/s_significand.c b/libm/s_significand.c
index e47618cfc..2d681dcb1 100644
--- a/libm/s_significand.c
+++ b/libm/s_significand.c
@@ -1,4 +1,3 @@
-/* @(#)s_signif.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: s_significand.c,v 1.6 1995/05/10 20:48:11 jtc Exp $";
-#endif
-
/*
* significand(x) computes just
* scalb(x, (double) -ilogb(x)),
@@ -23,14 +18,8 @@ static char rcsid[] = "$NetBSD: s_significand.c,v 1.6 1995/05/10 20:48:11 jtc Ex
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(ilogb)
-
-#ifdef __STDC__
- double significand(double x)
-#else
- double significand(x)
- double x;
-#endif
+double significand(double x)
{
return __ieee754_scalb(x,(double) -ilogb(x));
}
+libm_hidden_def(significand)
diff --git a/libm/s_sin.c b/libm/s_sin.c
index ef9a36d7d..03867e773 100644
--- a/libm/s_sin.c
+++ b/libm/s_sin.c
@@ -1,4 +1,3 @@
-/* @(#)s_sin.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: s_sin.c,v 1.7 1995/05/10 20:48:15 jtc Exp $";
-#endif
-
/* sin(x)
* Return sine function of x.
*
@@ -48,13 +43,7 @@ static char rcsid[] = "$NetBSD: s_sin.c,v 1.7 1995/05/10 20:48:15 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(sin)
-#ifdef __STDC__
- double sin(double x)
-#else
- double sin(x)
- double x;
-#endif
+double sin(double x)
{
double y[2],z=0.0;
int32_t n, ix;
diff --git a/libm/s_tan.c b/libm/s_tan.c
index bab343c73..5a2bc930c 100644
--- a/libm/s_tan.c
+++ b/libm/s_tan.c
@@ -1,4 +1,3 @@
-/* @(#)s_tan.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: s_tan.c,v 1.7 1995/05/10 20:48:18 jtc Exp $";
-#endif
-
/* tan(x)
* Return tangent function of x.
*
@@ -47,13 +42,7 @@ static char rcsid[] = "$NetBSD: s_tan.c,v 1.7 1995/05/10 20:48:18 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(tan)
-#ifdef __STDC__
- double tan(double x)
-#else
- double tan(x)
- double x;
-#endif
+double tan(double x)
{
double y[2],z=0.0;
int32_t n, ix;
diff --git a/libm/s_tanh.c b/libm/s_tanh.c
index ecabbef98..89ee2718b 100644
--- a/libm/s_tanh.c
+++ b/libm/s_tanh.c
@@ -1,4 +1,3 @@
-/* @(#)s_tanh.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: s_tanh.c,v 1.7 1995/05/10 20:48:22 jtc Exp $";
-#endif
-
/* Tanh(x)
* Return the Hyperbolic Tangent of x
*
@@ -41,22 +36,9 @@ static char rcsid[] = "$NetBSD: s_tanh.c,v 1.7 1995/05/10 20:48:22 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(expm1)
-libm_hidden_proto(fabs)
-
-#ifdef __STDC__
static const double one=1.0, two=2.0, tiny = 1.0e-300;
-#else
-static double one=1.0, two=2.0, tiny = 1.0e-300;
-#endif
-libm_hidden_proto(tanh)
-#ifdef __STDC__
- double tanh(double x)
-#else
- double tanh(x)
- double x;
-#endif
+double tanh(double x)
{
double t,z;
int32_t jx,ix;
diff --git a/libm/s_trunc.c b/libm/s_trunc.c
index 8a4f5ae05..693a442c0 100644
--- a/libm/s_trunc.c
+++ b/libm/s_trunc.c
@@ -14,43 +14,39 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 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>
-
#include "math_private.h"
-
-libm_hidden_proto(trunc)
double
trunc (double x)
{
- int32_t i0, j0;
+ int32_t i0, _j0;
u_int32_t i1;
int sx;
EXTRACT_WORDS (i0, i1, x);
sx = i0 & 0x80000000;
- j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
- if (j0 < 20)
+ _j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
+ if (_j0 < 20)
{
- if (j0 < 0)
+ if (_j0 < 0)
/* The magnitude of the number is < 1 so the result is +-0. */
INSERT_WORDS (x, sx, 0);
else
- INSERT_WORDS (x, sx | (i0 & ~(0x000fffff >> j0)), 0);
+ INSERT_WORDS (x, sx | (i0 & ~(0x000fffff >> _j0)), 0);
}
- else if (j0 > 51)
+ else if (_j0 > 51)
{
- if (j0 == 0x400)
+ if (_j0 == 0x400)
/* x is inf or NaN. */
return x + x;
}
else
{
- INSERT_WORDS (x, i0, i1 & ~(0xffffffffu >> (j0 - 20)));
+ INSERT_WORDS (x, i0, i1 & ~(0xffffffffu >> (_j0 - 20)));
}
return x;
diff --git a/libm/sh/sh4/Makefile.arch b/libm/sh/sh4/Makefile.arch
new file mode 100644
index 000000000..e38e99c15
--- /dev/null
+++ b/libm/sh/sh4/Makefile.arch
@@ -0,0 +1,24 @@
+# Makefile for uClibc
+#
+# Copyright (c) 2007, 2010 STMicroelectronics Ltd
+#
+# Author(s): Carmelo Amoroso <carmelo.amoroso@st.com>
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+ifeq ($(UCLIBC_HAS_FENV),y)
+libm_ARCH_CSRC:=$(wildcard $(libm_SUBARCH_DIR)/*.c)
+libm_ARCH_COBJ:=$(patsubst $(libm_SUBARCH_DIR)/%.c,$(libm_SUBARCH_OUT)/%.o,$(libm_ARCH_SRC))
+libm_ARCH_SSRC:=$(wildcard $(libm_SUBARCH_DIR)/*.S)
+libm_ARCH_SOBJ:=$(patsubst $(libm_SUBARCH_DIR)/%.S,$(libm_SUBARCH_OUT)/%.o,$(libm_ARCH_SSRC))
+endif
+
+libm_ARCH_OBJS:=$(libm_ARCH_COBJ) $(libm_ARCH_SOBJ)
+
+ifeq ($(DOPIC),y)
+libm-a-y+=$(libm_ARCH_OBJS:.o=.os)
+else
+libm-a-y+=$(libm_ARCH_OBJS)
+endif
+libm-so-y+=$(libm_ARCH_OBJS:.o=.os)
+
diff --git a/libm/sh/sh4/feholdexcpt.c b/libm/sh/sh4/feholdexcpt.c
new file mode 100644
index 000000000..70b51e8dd
--- /dev/null
+++ b/libm/sh/sh4/feholdexcpt.c
@@ -0,0 +1,29 @@
+/*
+ *
+ * Copyright (c) 2007 STMicroelectronics Ltd
+ * Filippo Arcidiacono (filippo.arcidiacono@st.com)
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ *
+ * Taken from glibc 2.6
+ *
+ */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+int
+feholdexcept (fenv_t *envp)
+{
+ unsigned long int temp;
+
+ /* Store the environment. */
+ _FPU_GETCW (temp);
+ envp->__fpscr = temp;
+
+ /* Now set all exceptions to non-stop. */
+ temp &= ~FE_ALL_EXCEPT;
+ _FPU_SETCW (temp);
+
+ return 1;
+}
diff --git a/libm/sh/sh4/fesetenv.c b/libm/sh/sh4/fesetenv.c
new file mode 100644
index 000000000..c5cfc1d51
--- /dev/null
+++ b/libm/sh/sh4/fesetenv.c
@@ -0,0 +1,26 @@
+/*
+ *
+ * Copyright (c) 2007 STMicroelectronics Ltd
+ * Filippo Arcidiacono (filippo.arcidiacono@st.com)
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ *
+ * Taken from glibc 2.6
+ *
+ */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+int
+fesetenv (const fenv_t *envp)
+{
+ if (envp == FE_DFL_ENV)
+ _FPU_SETCW (_FPU_DEFAULT);
+ else
+ {
+ unsigned long int temp = envp->__fpscr;
+ _FPU_SETCW (temp);
+ }
+ return 0;
+}
diff --git a/libm/sh/sh4/s_lrintf.S b/libm/sh/sh4/s_lrintf.S
new file mode 100644
index 000000000..d8cec329c
--- /dev/null
+++ b/libm/sh/sh4/s_lrintf.S
@@ -0,0 +1,52 @@
+/* Round argument to nearest integer value. SH4 version.
+ * According to ISO/IEC 9899:1999. This version doesn't handle range error.
+ * If arg is not finite or if the result cannot be represented into a long,
+ * return an unspecified value. No exception raised.
+ *
+ * Copyright (C) 2010 STMicroelectronics Ltd.
+ *
+ * Author: Christian Bruel <christian.bruel@st.com>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sysdep.h>
+
+ENTRY(lrintf)
+ mov #0,r0
+ sts fpscr,r3
+ lds r0,fpscr
+ flds fr5,fpul
+ mov.l LOCAL(mask),r1
+ sts fpul,r2
+ and r2,r1
+ mov.l LOCAL(midway),r2
+ or r1,r2
+ lds r2,fpul
+ fsts fpul,fr2
+ fadd fr2,fr5
+ ftrc fr5,fpul
+ sts fpul,r0
+ float fpul,fr2
+ fcmp/eq fr5,fr2
+ bf/s 0f
+ mov #1,r2
+ tst r1,r1
+ and r0,r2
+ movt r1
+ shal r1
+ tst r2,r2
+ add #-1,r1
+ bt 0f
+ sub r1,r0
+0:
+ rts
+ lds r3,fpscr
+
+ .align 2
+LOCAL(mask):
+ .long 0x80000000
+LOCAL(midway):
+ .long 1056964608
+
+END(lrintf)
diff --git a/libm/sh/sh4/s_lroundf.S b/libm/sh/sh4/s_lroundf.S
new file mode 100644
index 000000000..fda3a4b91
--- /dev/null
+++ b/libm/sh/sh4/s_lroundf.S
@@ -0,0 +1,39 @@
+/* Round argument toward 0. SH4 version.
+ * According to ISO/IEC 9899:1999. This version doesn't handle range error.
+ * If arg is not finite or if the result cannot be represented into a long,
+ * return an unspecified value. No exception raised.
+ *
+ * Copyright (C) 2010 STMicroelectronics Ltd.
+ *
+ * Author: Christian Bruel <christian.bruel@st.com>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sysdep.h>
+
+ENTRY(lroundf)
+ mov #0,r0
+ sts fpscr,r3
+ lds r0,fpscr
+ flds fr5,fpul
+ mov.l LOCAL(mask),r1
+ sts fpul,r2
+ and r2,r1
+ mov.l LOCAL(midway),r2
+ or r1,r2
+ lds r2,fpul
+ fsts fpul,fr2
+ fadd fr2,fr5
+ ftrc fr5,fpul
+ sts fpul,r0
+ rts
+ lds r3,fpscr
+
+ .align 2
+LOCAL(mask):
+ .long 0x80000000
+LOCAL(midway):
+ .long 1056964608
+
+END(lroundf)
diff --git a/libm/sincos.c b/libm/sincos.c
new file mode 100644
index 000000000..df6b670f8
--- /dev/null
+++ b/libm/sincos.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2011 William Pitcock <nenolod@dereferenced.org>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <features.h>
+#include <math.h>
+
+libm_hidden_proto(sincos)
+void sincos(double x, double *s, double *c)
+{
+ *s = sin(x);
+ *c = cos(x);
+}
+libm_hidden_def(sincos)
+
+libm_hidden_proto(sincosf)
+void sincosf(float x, float *s, float *c)
+{
+ *s = sinf(x);
+ *c = cosf(x);
+}
+libm_hidden_def(sincosf)
+
+#if defined __UCLIBC_HAS_LONG_DOUBLE_MATH__ && !defined __NO_LONG_DOUBLE_MATH
+libm_hidden_proto(sincosl)
+void sincosl(long double x, long double *s, long double *c)
+{
+ *s = sinl(x);
+ *c = cosl(x);
+}
+libm_hidden_def(sincosl)
+#endif
diff --git a/libm/w_acos.c b/libm/w_acos.c
deleted file mode 100644
index ea00cf010..000000000
--- a/libm/w_acos.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* @(#)w_acos.c 5.1 93/09/24 */
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
-
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_acos.c,v 1.6 1995/05/10 20:48:26 jtc Exp $";
-#endif
-
-/*
- * wrap_acos(x)
- */
-
-#include "math.h"
-#include "math_private.h"
-
-libm_hidden_proto(acos)
-#ifdef __STDC__
- double acos(double x) /* wrapper acos */
-#else
- double acos(x) /* wrapper acos */
- double x;
-#endif
-{
-#ifdef _IEEE_LIBM
- return __ieee754_acos(x);
-#else
- double z;
- z = __ieee754_acos(x);
- if(_LIB_VERSION == _IEEE_ || isnan(x)) return z;
- if(fabs(x)>1.0) {
- return __kernel_standard(x,x,1); /* acos(|x|>1) */
- } else
- return z;
-#endif
-}
-libm_hidden_def(acos)
diff --git a/libm/w_acosh.c b/libm/w_acosh.c
deleted file mode 100644
index e0efb8a63..000000000
--- a/libm/w_acosh.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* @(#)w_acosh.c 5.1 93/09/24 */
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
-
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_acosh.c,v 1.6 1995/05/10 20:48:31 jtc Exp $";
-#endif
-
-/*
- * wrapper acosh(x)
- */
-
-#include "math.h"
-#include "math_private.h"
-
-libm_hidden_proto(acosh)
-#ifdef __STDC__
- double acosh(double x) /* wrapper acosh */
-#else
- double acosh(x) /* wrapper acosh */
- double x;
-#endif
-{
-#ifdef _IEEE_LIBM
- return __ieee754_acosh(x);
-#else
- double z;
- z = __ieee754_acosh(x);
- if(_LIB_VERSION == _IEEE_ || isnan(x)) return z;
- if(x<1.0) {
- return __kernel_standard(x,x,29); /* acosh(x<1) */
- } else
- return z;
-#endif
-}
-libm_hidden_def(acosh)
diff --git a/libm/w_asin.c b/libm/w_asin.c
deleted file mode 100644
index ad156ef05..000000000
--- a/libm/w_asin.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* @(#)w_asin.c 5.1 93/09/24 */
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
-
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_asin.c,v 1.6 1995/05/10 20:48:35 jtc Exp $";
-#endif
-
-/*
- * wrapper asin(x)
- */
-
-
-#include "math.h"
-#include "math_private.h"
-
-
-libm_hidden_proto(asin)
-#ifdef __STDC__
- double asin(double x) /* wrapper asin */
-#else
- double asin(x) /* wrapper asin */
- double x;
-#endif
-{
-#ifdef _IEEE_LIBM
- return __ieee754_asin(x);
-#else
- double z;
- z = __ieee754_asin(x);
- if(_LIB_VERSION == _IEEE_ || isnan(x)) return z;
- if(fabs(x)>1.0) {
- return __kernel_standard(x,x,2); /* asin(|x|>1) */
- } else
- return z;
-#endif
-}
-libm_hidden_def(asin)
diff --git a/libm/w_atan2.c b/libm/w_atan2.c
deleted file mode 100644
index c2da4681c..000000000
--- a/libm/w_atan2.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* @(#)w_atan2.c 5.1 93/09/24 */
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
-
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_atan2.c,v 1.6 1995/05/10 20:48:39 jtc Exp $";
-#endif
-
-/*
- * wrapper atan2(y,x)
- */
-#include "math.h"
-#include "math_private.h"
-
-libm_hidden_proto(atan2)
-#ifdef __STDC__
- double atan2(double y, double x) /* wrapper atan2 */
-#else
- double atan2(y,x) /* wrapper atan2 */
- double y,x;
-#endif
-{
-#ifdef _IEEE_LIBM
- return __ieee754_atan2(y,x);
-#else
- double z;
- z = __ieee754_atan2(y,x);
- if(_LIB_VERSION == _IEEE_||isnan(x)||isnan(y)) return z;
- if(x==0.0&&y==0.0) {
- return __kernel_standard(y,x,3); /* atan2(+-0,+-0) */
- } else
- return z;
-#endif
-}
-libm_hidden_def(atan2)
diff --git a/libm/w_atanh.c b/libm/w_atanh.c
deleted file mode 100644
index 18d0a4a80..000000000
--- a/libm/w_atanh.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/* @(#)w_atanh.c 5.1 93/09/24 */
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
-
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_atanh.c,v 1.6 1995/05/10 20:48:43 jtc Exp $";
-#endif
-
-/*
- * wrapper atanh(x)
- */
-
-#include "math.h"
-#include "math_private.h"
-
-libm_hidden_proto(atanh)
-#ifdef __STDC__
- double atanh(double x) /* wrapper atanh */
-#else
- double atanh(x) /* wrapper atanh */
- double x;
-#endif
-{
-#ifdef _IEEE_LIBM
- return __ieee754_atanh(x);
-#else
- double z,y;
- z = __ieee754_atanh(x);
- if(_LIB_VERSION == _IEEE_ || isnan(x)) return z;
- y = fabs(x);
- if(y>=1.0) {
- if(y>1.0)
- return __kernel_standard(x,x,30); /* atanh(|x|>1) */
- else
- return __kernel_standard(x,x,31); /* atanh(|x|==1) */
- } else
- return z;
-#endif
-}
-libm_hidden_def(atanh)
diff --git a/libm/w_cabs.c b/libm/w_cabs.c
index 485e120db..b2592484c 100644
--- a/libm/w_cabs.c
+++ b/libm/w_cabs.c
@@ -8,9 +8,24 @@
#include <complex.h>
#include <math.h>
-libm_hidden_proto(hypot)
-
double cabs(double _Complex z)
{
return hypot(__real__ z, __imag__ z);
}
+libm_hidden_def(cabs)
+
+libm_hidden_proto(cabsf)
+float cabsf(float _Complex z)
+{
+ return (float) hypot(__real__ z, __imag__ z);
+}
+libm_hidden_def(cabsf)
+
+#if defined __UCLIBC_HAS_LONG_DOUBLE_MATH__ && !defined __NO_LONG_DOUBLE_MATH
+libm_hidden_proto(cabsl)
+long double cabsl(long double _Complex z)
+{
+ return hypotl(__real__ z, __imag__ z);
+}
+libm_hidden_def(cabsl)
+#endif
diff --git a/libm/w_cosh.c b/libm/w_cosh.c
deleted file mode 100644
index c785af4b5..000000000
--- a/libm/w_cosh.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* @(#)w_cosh.c 5.1 93/09/24 */
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
-
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_cosh.c,v 1.6 1995/05/10 20:48:47 jtc Exp $";
-#endif
-
-/*
- * wrapper cosh(x)
- */
-
-#include "math.h"
-#include "math_private.h"
-
-libm_hidden_proto(cosh)
-#ifdef __STDC__
- double cosh(double x) /* wrapper cosh */
-#else
- double cosh(x) /* wrapper cosh */
- double x;
-#endif
-{
-#ifdef _IEEE_LIBM
- return __ieee754_cosh(x);
-#else
- double z;
- z = __ieee754_cosh(x);
- if(_LIB_VERSION == _IEEE_ || isnan(x)) return z;
- if(fabs(x)>7.10475860073943863426e+02) {
- return __kernel_standard(x,x,5); /* cosh overflow */
- } else
- return z;
-#endif
-}
-libm_hidden_def(cosh)
diff --git a/libm/w_drem.c b/libm/w_drem.c
deleted file mode 100644
index 22e281761..000000000
--- a/libm/w_drem.c
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * drem() wrapper for remainder().
- *
- * Written by J.T. Conklin, <jtc@wimsey.com>
- * Placed into the Public Domain, 1994.
- */
-
-#include <math.h>
-
-libm_hidden_proto(remainder)
-
-double drem(double x, double y)
-{
- return remainder(x, y);
-}
diff --git a/libm/w_exp.c b/libm/w_exp.c
deleted file mode 100644
index b9b7ccc26..000000000
--- a/libm/w_exp.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/* @(#)w_exp.c 5.1 93/09/24 */
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
-
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_exp.c,v 1.6 1995/05/10 20:48:51 jtc Exp $";
-#endif
-
-/*
- * wrapper exp(x)
- */
-
-#include "math.h"
-#include "math_private.h"
-
-#ifdef __STDC__
-static const double
-#else
-static double
-#endif
-o_threshold= 7.09782712893383973096e+02, /* 0x40862E42, 0xFEFA39EF */
-u_threshold= -7.45133219101941108420e+02; /* 0xc0874910, 0xD52D3051 */
-
-libm_hidden_proto(exp)
-#ifdef __STDC__
- double exp(double x) /* wrapper exp */
-#else
- double exp(x) /* wrapper exp */
- double x;
-#endif
-{
-#ifdef _IEEE_LIBM
- return __ieee754_exp(x);
-#else
- double z;
- z = __ieee754_exp(x);
- if(_LIB_VERSION == _IEEE_) return z;
- if(finite(x)) {
- if(x>o_threshold)
- return __kernel_standard(x,x,6); /* exp overflow */
- else if(x<u_threshold)
- return __kernel_standard(x,x,7); /* exp underflow */
- }
- return z;
-#endif
-}
-libm_hidden_def(exp)
diff --git a/libm/e_lgamma.c b/libm/w_exp2.c
index 4dce71c80..e00277abf 100644
--- a/libm/e_lgamma.c
+++ b/libm/w_exp2.c
@@ -1,5 +1,3 @@
-
-/* @(#)e_lgamma.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -9,27 +7,13 @@
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
- *
- */
-
-/* __ieee754_lgamma(x)
- * Return the logarithm of the Gamma function of x.
- *
- * Method: call __ieee754_lgamma_r
*/
-#include <math.h>
+#include "math.h"
#include "math_private.h"
-libm_hidden_proto(signgam)
-
-#ifdef __STDC__
- //__private_extern__
- double attribute_hidden __ieee754_lgamma(double x)
-#else
- double attribute_hidden __ieee754_lgamma(x)
- double x;
-#endif
+double exp2(double x)
{
- return __ieee754_lgamma_r(x,&signgam);
+ return pow(2.0, x);
}
+libm_hidden_def(exp2)
diff --git a/libm/w_fmod.c b/libm/w_fmod.c
deleted file mode 100644
index eed38372b..000000000
--- a/libm/w_fmod.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* @(#)w_fmod.c 5.1 93/09/24 */
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
-
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_fmod.c,v 1.6 1995/05/10 20:48:55 jtc Exp $";
-#endif
-
-/*
- * wrapper fmod(x,y)
- */
-
-#include "math.h"
-#include "math_private.h"
-
-libm_hidden_proto(fmod)
-#ifdef __STDC__
- double fmod(double x, double y) /* wrapper fmod */
-#else
- double fmod(x,y) /* wrapper fmod */
- double x,y;
-#endif
-{
-#ifdef _IEEE_LIBM
- return __ieee754_fmod(x,y);
-#else
- double z;
- z = __ieee754_fmod(x,y);
- if(_LIB_VERSION == _IEEE_ ||isnan(y)||isnan(x)) return z;
- if(y==0.0) {
- return __kernel_standard(x,y,27); /* fmod(x,0) */
- } else
- return z;
-#endif
-}
-libm_hidden_def(fmod)
diff --git a/libm/w_gamma.c b/libm/w_gamma.c
deleted file mode 100644
index 182dece3e..000000000
--- a/libm/w_gamma.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/* @(#)w_gamma.c 5.1 93/09/24 */
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
-
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_gamma.c,v 1.7 1995/11/20 22:06:43 jtc Exp $";
-#endif
-
-/* double gamma(double x)
- * Return the logarithm of the Gamma function of x.
- *
- * Method: call gamma_r
- */
-
-#include <math.h>
-#include "math_private.h"
-
-libm_hidden_proto(signgam)
-
-#ifdef __STDC__
- double gamma(double x)
-#else
- double gamma(x)
- double x;
-#endif
-{
-#ifdef _IEEE_LIBM
- return __ieee754_lgamma_r(x,&signgam);
-#else
- double y;
- y = __ieee754_lgamma_r(x,&signgam);
- if(_LIB_VERSION == _IEEE_) return y;
- if(!finite(y)&&finite(x)) {
- if(floor(x)==x&&x<=0.0)
- return __kernel_standard(x,x,41); /* gamma pole */
- else
- return __kernel_standard(x,x,40); /* gamma overflow */
- } else
- return y;
-#endif
-}
diff --git a/libm/w_gamma_r.c b/libm/w_gamma_r.c
deleted file mode 100644
index 321e86480..000000000
--- a/libm/w_gamma_r.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/* @(#)wr_gamma.c 5.1 93/09/24 */
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
-
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_gamma_r.c,v 1.7 1995/11/20 22:06:45 jtc Exp $";
-#endif
-
-/*
- * wrapper double gamma_r(double x, int *signgamp)
- */
-
-#include "math.h"
-#include "math_private.h"
-
-
-double gamma_r(double x, int *signgamp);
-#ifdef __STDC__
- double gamma_r(double x, int *signgamp) /* wrapper lgamma_r */
-#else
- double gamma_r(x,signgamp) /* wrapper lgamma_r */
- double x; int *signgamp;
-#endif
-{
-#ifdef _IEEE_LIBM
- return __ieee754_lgamma_r(x,signgamp);
-#else
- double y;
- y = __ieee754_lgamma_r(x,signgamp);
- if(_LIB_VERSION == _IEEE_) return y;
- if(!finite(y)&&finite(x)) {
- if(floor(x)==x&&x<=0.0)
- return __kernel_standard(x,x,41); /* gamma pole */
- else
- return __kernel_standard(x,x,40); /* gamma overflow */
- } else
- return y;
-#endif
-}
diff --git a/libm/w_hypot.c b/libm/w_hypot.c
deleted file mode 100644
index e4b299d5f..000000000
--- a/libm/w_hypot.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* @(#)w_hypot.c 5.1 93/09/24 */
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
-
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_hypot.c,v 1.6 1995/05/10 20:49:07 jtc Exp $";
-#endif
-
-/*
- * wrapper hypot(x,y)
- */
-
-#include "math.h"
-#include "math_private.h"
-
-libm_hidden_proto(hypot)
-#ifdef __STDC__
- double hypot(double x, double y)/* wrapper hypot */
-#else
- double hypot(x,y) /* wrapper hypot */
- double x,y;
-#endif
-{
-#ifdef _IEEE_LIBM
- return __ieee754_hypot(x,y);
-#else
- double z;
- z = __ieee754_hypot(x,y);
- if(_LIB_VERSION == _IEEE_) return z;
- if((!finite(z))&&finite(x)&&finite(y))
- return __kernel_standard(x,y,4); /* hypot overflow */
- else
- return z;
-#endif
-}
-libm_hidden_def(hypot)
diff --git a/libm/w_j0.c b/libm/w_j0.c
deleted file mode 100644
index 61f4f20fc..000000000
--- a/libm/w_j0.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/* @(#)w_j0.c 5.1 93/09/24 */
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
-
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_j0.c,v 1.6 1995/05/10 20:49:11 jtc Exp $";
-#endif
-
-/*
- * wrapper j0(double x), y0(double x)
- */
-
-#include "math.h"
-#include "math_private.h"
-
-#ifdef __STDC__
- double j0(double x) /* wrapper j0 */
-#else
- double j0(x) /* wrapper j0 */
- double x;
-#endif
-{
-#ifdef _IEEE_LIBM
- return __ieee754_j0(x);
-#else
- double z = __ieee754_j0(x);
- if(_LIB_VERSION == _IEEE_ || isnan(x)) return z;
- if(fabs(x)>X_TLOSS) {
- return __kernel_standard(x,x,34); /* j0(|x|>X_TLOSS) */
- } else
- return z;
-#endif
-}
-
-#ifdef __STDC__
- double y0(double x) /* wrapper y0 */
-#else
- double y0(x) /* wrapper y0 */
- double x;
-#endif
-{
-#ifdef _IEEE_LIBM
- return __ieee754_y0(x);
-#else
- double z;
- z = __ieee754_y0(x);
- if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z;
- if(x <= 0.0){
- if(x==0.0)
- /* d= -one/(x-x); */
- return __kernel_standard(x,x,8);
- else
- /* d = zero/(x-x); */
- return __kernel_standard(x,x,9);
- }
- if(x>X_TLOSS) {
- return __kernel_standard(x,x,35); /* y0(x>X_TLOSS) */
- } else
- return z;
-#endif
-}
diff --git a/libm/w_j1.c b/libm/w_j1.c
deleted file mode 100644
index 389dc156c..000000000
--- a/libm/w_j1.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/* @(#)w_j1.c 5.1 93/09/24 */
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
-
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_j1.c,v 1.6 1995/05/10 20:49:15 jtc Exp $";
-#endif
-
-/*
- * wrapper of j1,y1
- */
-
-#include "math.h"
-#include "math_private.h"
-
-#ifdef __STDC__
- double j1(double x) /* wrapper j1 */
-#else
- double j1(x) /* wrapper j1 */
- double x;
-#endif
-{
-#ifdef _IEEE_LIBM
- return __ieee754_j1(x);
-#else
- double z;
- z = __ieee754_j1(x);
- if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z;
- if(fabs(x)>X_TLOSS) {
- return __kernel_standard(x,x,36); /* j1(|x|>X_TLOSS) */
- } else
- return z;
-#endif
-}
-
-#ifdef __STDC__
- double y1(double x) /* wrapper y1 */
-#else
- double y1(x) /* wrapper y1 */
- double x;
-#endif
-{
-#ifdef _IEEE_LIBM
- return __ieee754_y1(x);
-#else
- double z;
- z = __ieee754_y1(x);
- if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z;
- if(x <= 0.0){
- if(x==0.0)
- /* d= -one/(x-x); */
- return __kernel_standard(x,x,10);
- else
- /* d = zero/(x-x); */
- return __kernel_standard(x,x,11);
- }
- if(x>X_TLOSS) {
- return __kernel_standard(x,x,37); /* y1(x>X_TLOSS) */
- } else
- return z;
-#endif
-}
diff --git a/libm/w_jn.c b/libm/w_jn.c
deleted file mode 100644
index 173f6aa9e..000000000
--- a/libm/w_jn.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/* @(#)w_jn.c 5.1 93/09/24 */
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
-
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_jn.c,v 1.6 1995/05/10 20:49:19 jtc Exp $";
-#endif
-
-/*
- * wrapper jn(int n, double x), yn(int n, double x)
- * floating point Bessel's function of the 1st and 2nd kind
- * of order n
- *
- * Special cases:
- * y0(0)=y1(0)=yn(n,0) = -inf with division by zero signal;
- * y0(-ve)=y1(-ve)=yn(n,-ve) are NaN with invalid signal.
- * Note 2. About jn(n,x), yn(n,x)
- * For n=0, j0(x) is called,
- * for n=1, j1(x) is called,
- * for n<x, forward recursion us used starting
- * from values of j0(x) and j1(x).
- * for n>x, a continued fraction approximation to
- * j(n,x)/j(n-1,x) is evaluated and then backward
- * recursion is used starting from a supposed value
- * for j(n,x). The resulting value of j(0,x) is
- * compared with the actual value to correct the
- * supposed value of j(n,x).
- *
- * yn(n,x) is similar in all respects, except
- * that forward recursion is used for all
- * values of n>1.
- *
- */
-
-#include "math.h"
-#include "math_private.h"
-
-#ifdef __STDC__
- double jn(int n, double x) /* wrapper jn */
-#else
- double jn(n,x) /* wrapper jn */
- double x; int n;
-#endif
-{
-#ifdef _IEEE_LIBM
- return __ieee754_jn(n,x);
-#else
- double z;
- z = __ieee754_jn(n,x);
- if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z;
- if(fabs(x)>X_TLOSS) {
- return __kernel_standard((double)n,x,38); /* jn(|x|>X_TLOSS,n) */
- } else
- return z;
-#endif
-}
-
-#ifdef __STDC__
- double yn(int n, double x) /* wrapper yn */
-#else
- double yn(n,x) /* wrapper yn */
- double x; int n;
-#endif
-{
-#ifdef _IEEE_LIBM
- return __ieee754_yn(n,x);
-#else
- double z;
- z = __ieee754_yn(n,x);
- if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z;
- if(x <= 0.0){
- if(x==0.0)
- /* d= -one/(x-x); */
- return __kernel_standard((double)n,x,12);
- else
- /* d = zero/(x-x); */
- return __kernel_standard((double)n,x,13);
- }
- if(x>X_TLOSS) {
- return __kernel_standard((double)n,x,39); /* yn(x>X_TLOSS,n) */
- } else
- return z;
-#endif
-}
diff --git a/libm/w_lgamma.c b/libm/w_lgamma.c
deleted file mode 100644
index de0394b5e..000000000
--- a/libm/w_lgamma.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/* @(#)w_lgamma.c 5.1 93/09/24 */
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
-
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_lgamma.c,v 1.6 1995/05/10 20:49:24 jtc Exp $";
-#endif
-
-/* double lgamma(double x)
- * Return the logarithm of the Gamma function of x.
- *
- * Method: call __ieee754_lgamma_r
- */
-
-#include <math.h>
-#include "math_private.h"
-
-libm_hidden_proto(signgam)
-
-libm_hidden_proto(lgamma)
-#ifdef __STDC__
- double lgamma(double x)
-#else
- double lgamma(x)
- double x;
-#endif
-{
-#ifdef _IEEE_LIBM
- return __ieee754_lgamma_r(x,&signgam);
-#else
- double y;
- y = __ieee754_lgamma_r(x,&signgam);
- if(_LIB_VERSION == _IEEE_) return y;
- if(!finite(y)&&finite(x)) {
- if(floor(x)==x&&x<=0.0)
- return __kernel_standard(x,x,15); /* lgamma pole */
- else
- return __kernel_standard(x,x,14); /* lgamma overflow */
- } else
- return y;
-#endif
-}
-libm_hidden_def(lgamma)
diff --git a/libm/w_lgamma_r.c b/libm/w_lgamma_r.c
deleted file mode 100644
index 6ca56d6da..000000000
--- a/libm/w_lgamma_r.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* @(#)wr_lgamma.c 5.1 93/09/24 */
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
-
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_lgamma_r.c,v 1.6 1995/05/10 20:49:27 jtc Exp $";
-#endif
-
-/*
- * wrapper double lgamma_r(double x, int *signgamp)
- */
-
-#include "math.h"
-#include "math_private.h"
-
-
-#ifdef __STDC__
- double lgamma_r(double x, int *signgamp) /* wrapper lgamma_r */
-#else
- double lgamma_r(x,signgamp) /* wrapper lgamma_r */
- double x; int *signgamp;
-#endif
-{
-#ifdef _IEEE_LIBM
- return __ieee754_lgamma_r(x,signgamp);
-#else
- double y;
- y = __ieee754_lgamma_r(x,signgamp);
- if(_LIB_VERSION == _IEEE_) return y;
- if(!finite(y)&&finite(x)) {
- if(floor(x)==x&&x<=0.0)
- return __kernel_standard(x,x,15); /* lgamma pole */
- else
- return __kernel_standard(x,x,14); /* lgamma overflow */
- } else
- return y;
-#endif
-}
diff --git a/libm/w_log.c b/libm/w_log.c
deleted file mode 100644
index 12c8282d5..000000000
--- a/libm/w_log.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* @(#)w_log.c 5.1 93/09/24 */
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
-
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_log.c,v 1.6 1995/05/10 20:49:33 jtc Exp $";
-#endif
-
-/*
- * wrapper log(x)
- */
-
-#include "math.h"
-#include "math_private.h"
-
-libm_hidden_proto(log)
-#ifdef __STDC__
- double log(double x) /* wrapper log */
-#else
- double log(x) /* wrapper log */
- double x;
-#endif
-{
-#ifdef _IEEE_LIBM
- return __ieee754_log(x);
-#else
- double z;
- z = __ieee754_log(x);
- if(_LIB_VERSION == _IEEE_ || isnan(x) || x > 0.0) return z;
- if(x==0.0)
- return __kernel_standard(x,x,16); /* log(0) */
- else
- return __kernel_standard(x,x,17); /* log(x<0) */
-#endif
-}
-libm_hidden_def(log)
diff --git a/libm/w_log10.c b/libm/w_log10.c
deleted file mode 100644
index cf52f6e65..000000000
--- a/libm/w_log10.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/* @(#)w_log10.c 5.1 93/09/24 */
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
-
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_log10.c,v 1.6 1995/05/10 20:49:35 jtc Exp $";
-#endif
-
-/*
- * wrapper log10(X)
- */
-
-#include "math.h"
-#include "math_private.h"
-
-libm_hidden_proto(log10)
-#ifdef __STDC__
- double log10(double x) /* wrapper log10 */
-#else
- double log10(x) /* wrapper log10 */
- double x;
-#endif
-{
-#ifdef _IEEE_LIBM
- return __ieee754_log10(x);
-#else
- double z;
- z = __ieee754_log10(x);
- if(_LIB_VERSION == _IEEE_ || isnan(x)) return z;
- if(x<=0.0) {
- if(x==0.0)
- return __kernel_standard(x,x,18); /* log10(0) */
- else
- return __kernel_standard(x,x,19); /* log10(x<0) */
- } else
- return z;
-#endif
-}
-libm_hidden_def(log10)
diff --git a/libm/w_pow.c b/libm/w_pow.c
deleted file mode 100644
index 89cd08f73..000000000
--- a/libm/w_pow.c
+++ /dev/null
@@ -1,62 +0,0 @@
-
-
-/* @(#)w_pow.c 5.2 93/10/01 */
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
-
-/*
- * wrapper pow(x,y) return x**y
- */
-
-#include "math.h"
-#include "math_private.h"
-
-libm_hidden_proto(pow)
-#ifdef __STDC__
- double pow(double x, double y) /* wrapper pow */
-#else
- double pow(x,y) /* wrapper pow */
- double x,y;
-#endif
-{
-#ifdef _IEEE_LIBM
- return __ieee754_pow(x,y);
-#else
- double z;
- z=__ieee754_pow(x,y);
- if(_LIB_VERSION == _IEEE_|| isnan(y)) return z;
- if(isnan(x)) {
- if(y==0.0)
- return __kernel_standard(x,y,42); /* pow(NaN,0.0) */
- else
- return z;
- }
- if(x==0.0){
- if(y==0.0)
- return __kernel_standard(x,y,20); /* pow(0.0,0.0) */
- if(finite(y)&&y<0.0)
- return __kernel_standard(x,y,23); /* pow(0.0,negative) */
- return z;
- }
- if(!finite(z)) {
- if(finite(x)&&finite(y)) {
- if(isnan(z))
- return __kernel_standard(x,y,24); /* pow neg**non-int */
- else
- return __kernel_standard(x,y,21); /* pow overflow */
- }
- }
- if(z==0.0&&finite(x)&&finite(y))
- return __kernel_standard(x,y,22); /* pow underflow */
- return z;
-#endif
-}
-libm_hidden_def(pow)
diff --git a/libm/w_remainder.c b/libm/w_remainder.c
deleted file mode 100644
index be3dd02c9..000000000
--- a/libm/w_remainder.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* @(#)w_remainder.c 5.1 93/09/24 */
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
-
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_remainder.c,v 1.6 1995/05/10 20:49:44 jtc Exp $";
-#endif
-
-/*
- * wrapper remainder(x,p)
- */
-
-#include "math.h"
-#include "math_private.h"
-
-libm_hidden_proto(remainder)
-#ifdef __STDC__
- double remainder(double x, double y) /* wrapper remainder */
-#else
- double remainder(x,y) /* wrapper remainder */
- double x,y;
-#endif
-{
-#ifdef _IEEE_LIBM
- return __ieee754_remainder(x,y);
-#else
- double z;
- z = __ieee754_remainder(x,y);
- if(_LIB_VERSION == _IEEE_ || isnan(y)) return z;
- if(y==0.0)
- return __kernel_standard(x,y,28); /* remainder(x,0) */
- else
- return z;
-#endif
-}
-libm_hidden_def(remainder)
diff --git a/libm/w_scalb.c b/libm/w_scalb.c
deleted file mode 100644
index a5f88de39..000000000
--- a/libm/w_scalb.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/* @(#)w_scalb.c 5.1 93/09/24 */
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
-
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_scalb.c,v 1.6 1995/05/10 20:49:48 jtc Exp $";
-#endif
-
-/*
- * wrapper scalb(double x, double fn) is provide for
- * passing various standard test suite. One
- * should use scalbn() instead.
- */
-
-#include <math.h>
-#include "math_private.h"
-
-#include <errno.h>
-
-#ifdef __STDC__
-#ifdef _SCALB_INT
- double scalb(double x, int fn) /* wrapper scalb */
-#else
- double scalb(double x, double fn) /* wrapper scalb */
-#endif
-#else
- double scalb(x,fn) /* wrapper scalb */
-#ifdef _SCALB_INT
- double x; int fn;
-#else
- double x,fn;
-#endif
-#endif
-{
-#ifdef _IEEE_LIBM
- return __ieee754_scalb(x,fn);
-#else
- double z;
- z = __ieee754_scalb(x,fn);
- if(_LIB_VERSION == _IEEE_) return z;
- if(!(finite(z)||isnan(z))&&finite(x)) {
- return __kernel_standard(x,(double)fn,32); /* scalb overflow */
- }
- if(z==0.0&&z!=x) {
- return __kernel_standard(x,(double)fn,33); /* scalb underflow */
- }
-#ifndef _SCALB_INT
- if(!finite(fn)) errno = ERANGE;
-#endif
- return z;
-#endif
-}
diff --git a/libm/w_sinh.c b/libm/w_sinh.c
deleted file mode 100644
index bed9bb3f9..000000000
--- a/libm/w_sinh.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* @(#)w_sinh.c 5.1 93/09/24 */
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
-
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_sinh.c,v 1.6 1995/05/10 20:49:51 jtc Exp $";
-#endif
-
-/*
- * wrapper sinh(x)
- */
-
-#include "math.h"
-#include "math_private.h"
-
-libm_hidden_proto(sinh)
-#ifdef __STDC__
- double sinh(double x) /* wrapper sinh */
-#else
- double sinh(x) /* wrapper sinh */
- double x;
-#endif
-{
-#ifdef _IEEE_LIBM
- return __ieee754_sinh(x);
-#else
- double z;
- z = __ieee754_sinh(x);
- if(_LIB_VERSION == _IEEE_) return z;
- if(!finite(z)&&finite(x)) {
- return __kernel_standard(x,x,25); /* sinh overflow */
- } else
- return z;
-#endif
-}
-libm_hidden_def(sinh)
diff --git a/libm/w_sqrt.c b/libm/w_sqrt.c
deleted file mode 100644
index 0a37249b1..000000000
--- a/libm/w_sqrt.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* @(#)w_sqrt.c 5.1 93/09/24 */
-/*
- * ====================================================
- * 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.
- * ====================================================
- */
-
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: w_sqrt.c,v 1.6 1995/05/10 20:49:55 jtc Exp $";
-#endif
-
-/*
- * wrapper sqrt(x)
- */
-
-#include "math.h"
-#include "math_private.h"
-
-libm_hidden_proto(sqrt)
-#ifdef __STDC__
- double sqrt(double x) /* wrapper sqrt */
-#else
- double sqrt(x) /* wrapper sqrt */
- double x;
-#endif
-{
-#ifdef _IEEE_LIBM
- return __ieee754_sqrt(x);
-#else
- double z;
- z = __ieee754_sqrt(x);
- if(_LIB_VERSION == _IEEE_ || isnan(x)) return z;
- if(x<0.0) {
- return __kernel_standard(x,x,26); /* sqrt(negative) */
- } else
- return z;
-#endif
-}
-libm_hidden_def(sqrt)
diff --git a/libnsl/Makefile.in b/libnsl/Makefile.in
index a66b90c6f..333c4907b 100644
--- a/libnsl/Makefile.in
+++ b/libnsl/Makefile.in
@@ -1,13 +1,16 @@
# Makefile for uClibc
#
-# Copyright (C) 2000-2005 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.
#
+subdirs += libnsl
+
CFLAGS-libnsl := -DNOT_IN_libc -DIS_IN_libnsl $(SSP_ALL_CFLAGS)
-LDFLAGS-libnsl.so := $(LDFLAGS)
+LDFLAGS-$(UCLIBC_FORMAT_DSBT_ELF)-libnsl.so := -Wl,--dsbt-index=6
+LDFLAGS-libnsl.so := $(LDFLAGS) $(call link.asneeded,-lc)
LIBS-libnsl.so := $(LIBS)
@@ -26,16 +29,16 @@ libnsl-a-y := $(libnsl_OBJ)
endif
libnsl-so-y := $(libnsl_OBJ:.o=.os)
-lib-a-y += $(top_builddir)lib/libnsl.a
-lib-so-y += $(top_builddir)lib/libnsl.so
-objclean-y += libnsl_clean
+lib-a-$(UCLIBC_HAS_LIBNSL_STUB) += $(top_builddir)lib/libnsl.a
+lib-so-$(UCLIBC_HAS_LIBNSL_STUB) += $(top_builddir)lib/libnsl.so
+objclean-y += CLEAN_libnsl
ifeq ($(DOPIC),y)
$(top_builddir)lib/libnsl.so: $(top_builddir)lib/libnsl.a $(libc.depend)
else
$(top_builddir)lib/libnsl.so: $(libnsl_OUT)/libnsl_so.a $(libc.depend)
endif
- $(call link.so,$(libnsl_FULL_NAME),$(MAJOR_VERSION))
+ $(call link.so,$(libnsl_FULL_NAME),$(ABI_VERSION))
$(libnsl_OUT)/libnsl_so.a: $(libnsl-so-y)
$(Q)$(RM) $@
@@ -46,5 +49,5 @@ $(top_builddir)lib/libnsl.a: $(libnsl-a-y)
$(Q)$(RM) $@
$(do_ar)
-libnsl_clean:
- $(RM) $(libnsl_OUT)/*.{o,os,a}
+CLEAN_libnsl:
+ $(do_rm) $(addprefix $(libnsl_OUT)/*., o os a)
diff --git a/libnsl/nsl.c b/libnsl/nsl.c
index 37d5b9369..a91ec93a7 100644
--- a/libnsl/nsl.c
+++ b/libnsl/nsl.c
@@ -7,8 +7,6 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#include <features.h>
-
void __stub2(void);
void __stub2(void)
{
diff --git a/libpthread/Makefile.in b/libpthread/Makefile.in
index bda935b5b..d1f8528a9 100644
--- a/libpthread/Makefile.in
+++ b/libpthread/Makefile.in
@@ -6,6 +6,6 @@
#
ifneq ($(PTNAME),)
-include $(PTDIR)/Makefile.in
-include $(PTDIR)_db/Makefile.in
+include $(top_srcdir)$(PTDIR)/Makefile.in
+include $(top_srcdir)$(PTDIR)_db/Makefile.in
endif
diff --git a/libpthread/linuxthreads.old/Makefile.in b/libpthread/linuxthreads.old/Makefile.in
index fe29f2cd1..6be2099d2 100644
--- a/libpthread/linuxthreads.old/Makefile.in
+++ b/libpthread/linuxthreads.old/Makefile.in
@@ -1,21 +1,22 @@
# Makefile for uClibc
#
# Copyright (C) 2003 Paul Mundt <lethal@linux-sh.org>
-# 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.
#
-CFLAGS-dir_linuxthreads.old := -DNOT_IN_libc -DIS_IN_libpthread
-CFLAGS-linuxthreads.old := $(CFLAGS-dir_linuxthreads.old) $(SSP_ALL_CFLAGS)
+subdirs += libpthread/linuxthreads.old
-CFLAGS-libpthread/linuxthreads.old/sysdeps/$(TARGET_ARCH)/ := $(CFLAGS-linuxthreads.old)
+CFLAGS-dir_linuxthreads.old := -DNOT_IN_libc -DIS_IN_libpthread
+CFLAGS-libpthread/linuxthreads.old := $(CFLAGS-dir_linuxthreads.old) $(SSP_ALL_CFLAGS)
ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
LDFLAGS-libpthread.so := $(LDFLAGS_NOSTRIP) -Wl,-z,defs
else
LDFLAGS-libpthread.so := $(LDFLAGS)
endif
+LDFLAGS-$(UCLIBC_FORMAT_DSBT_ELF)-libpthread.so := -Wl,--dsbt-index=10
LIBS-libpthread.so := $(LIBS) $(ldso)
@@ -31,15 +32,12 @@ libpthread_OUT := $(top_builddir)libpthread/linuxthreads.old
libpthread_SRC := \
attr.c cancel.c condvar.c errno.c events.c join.c lockfile.c manager.c \
- mutex.c oldsemaphore.c pt-machine.c ptfork.c ptlongjmp.c \
+ mutex.c pt-machine.c ptfork.c pthread.c ptlongjmp.c \
rwlock.c semaphore.c signals.c specific.c spinlock.c wrapsyscall.c
ifeq ($(UCLIBC_HAS_XLOCALE),y)
libpthread_SRC += locale.c
endif
-libpthread_SPEC_SRC := pthread.c
-libpthread_SPEC_SRC := $(patsubst %.c,$(libpthread_DIR)/%.c,$(libpthread_SPEC_SRC))
-
# remove generic sources, if arch specific version is present
ifneq ($(strip $(libpthread_ARCH_SRC)),)
libpthread_SRC := $(filter-out $(patsubst %.c,$(libpthread_DIR)/%.c,$(notdir $(libpthread_ARCH_SRC))),$(libpthread_SRC))
@@ -59,28 +57,22 @@ libpthread_libc_OBJ := $(patsubst %.c, $(libpthread_OUT)/%.o,$(libpthread_libc_
libc-static-y += $(libpthread_OUT)/libc_pthread_init.o
libc-shared-y += $(libpthread_libc_OBJ:.o=.oS)
-libpthread-static-y += $(patsubst $(libpthread_DIR)/%.c,$(libpthread_OUT)/%.o,$(libpthread_SPEC_SRC))
-libpthread-shared-y += $(patsubst $(libpthread_DIR)/%.c,$(libpthread_OUT)/%.oS,$(libpthread_SPEC_SRC))
-
ifeq ($(DOPIC),y)
-libpthread-a-y += $(libpthread_OBJ:.o=.os) $(libpthread-static-y:.o=.os)
+libpthread-a-y += $(libpthread_OBJ:.o=.os)
else
-libpthread-a-y += $(libpthread_OBJ) $(libpthread-static-y)
+libpthread-a-y += $(libpthread_OBJ)
endif
-libpthread-so-y += $(libpthread_OBJ:.o=.os) $(libpthread-shared-y)
+libpthread-so-y += $(libpthread_OBJ:.o=.oS)
lib-a-$(UCLIBC_HAS_THREADS) += $(top_builddir)lib/libpthread.a
lib-so-$(UCLIBC_HAS_THREADS) += $(top_builddir)lib/libpthread.so
-objclean-y += libpthread_clean
-headers-$(UCLIBC_HAS_THREADS) += linuxthreads_headers
-headers_clean-y += linuxthreads_headers_clean
#ifeq ($(DOMULTI),n)
$(top_builddir)lib/libpthread.so: $(libpthread_OUT)/libpthread_so.a $(libc.depend)
- $(call link.so,$(libpthread_FULL_NAME),$(MAJOR_VERSION))
+ $(call link.so,$(libpthread_FULL_NAME),$(ABI_VERSION))
#else
#$(top_builddir)lib/libpthread.so: $(libpthread_OUT)/libpthread.oS | $(libc.depend)
-# $(call linkm.so,$(libpthread_FULL_NAME),$(MAJOR_VERSION))
+# $(call linkm.so,$(libpthread_FULL_NAME),$(ABI_VERSION))
#endif
ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
@@ -93,7 +85,7 @@ $(libpthread_OUT)/libpthread_so.a: $(libpthread-so-y)
ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
$(libpthread_OUT)/libpthread.oS: STRIP_FLAGS:=$(STRIP_FLAGS:-x=-X --strip-debug)
endif
-$(libpthread_OUT)/libpthread.oS: $(libpthread_SRC) $(libpthread_SPEC_SRC)
+$(libpthread_OUT)/libpthread.oS: $(libpthread_SRC)
$(Q)$(RM) $@
$(compile-m)
@@ -105,19 +97,23 @@ $(top_builddir)lib/libpthread.a: $(libpthread-a-y)
$(Q)$(RM) $@
$(do_ar)
-include/pthread.h:
- $(do_ln) ../$(PTDIR)/sysdeps/pthread/$(@F) $(top_builddir)$@
-include/semaphore.h:
- $(do_ln) ../$(PTDIR)/$(@F) $(top_builddir)$@
-include/bits/pthreadtypes.h: | include/bits
- $(do_ln) ../../$(PTDIR)/sysdeps/pthread/bits/$(@F) $(top_builddir)$@
-linuxthreads_headers: include/pthread.h include/semaphore.h \
- include/bits/pthreadtypes.h
-
-linuxthreads_headers_clean:
- $(RM) $(top_builddir)include/pthread.h \
- $(top_builddir)include/semaphore.h \
- $(top_builddir)include/bits/pthreadtypes.h
-
-libpthread_clean:
- $(RM) $(libpthread_OUT)/*.{o,os,oS,a}
+$(top_builddir)include/pthread.h:
+ $(do_ln) $(call rel_srcdir)$(PTDIR)/sysdeps/pthread/$(@F) $@
+$(top_builddir)include/semaphore.h:
+ $(do_ln) $(call rel_srcdir)$(PTDIR)/$(@F) $@
+$(top_builddir)include/bits/pthreadtypes.h: | $(top_builddir)include/bits
+ $(do_ln) $(call rel_srcdir)$(PTDIR)/sysdeps/pthread/bits/$(@F) $@
+
+linuxthreads_headers := $(top_builddir)include/pthread.h \
+ $(top_builddir)include/semaphore.h \
+ $(top_builddir)include/bits/pthreadtypes.h
+$(linuxthreads_headers): $(wildcard $(addprefix $(top_builddir)include/config/linuxthreads/,old.h new.h))
+headers-$(UCLIBC_HAS_THREADS) += $(linuxthreads_headers)
+
+objclean-y += CLEAN_libpthread/linuxthreads.old
+headers_clean-y += HEADERCLEAN_libpthread/linuxthreads.old
+HEADERCLEAN_libpthread/linuxthreads.old:
+ $(do_rm) $(linuxthreads_headers)
+
+CLEAN_libpthread/linuxthreads.old:
+ $(do_rm) $(addprefix $(libpthread_OUT)/*., o os oS a)
diff --git a/libpthread/linuxthreads.old/attr.c b/libpthread/linuxthreads.old/attr.c
index 30294afe4..8465c234c 100644
--- a/libpthread/linuxthreads.old/attr.c
+++ b/libpthread/linuxthreads.old/attr.c
@@ -42,7 +42,7 @@ libpthread_hidden_proto(pthread_attr_setscope)
* Therefore, define the function pthread_attr_init() here using
* a strong symbol. */
-//int __pthread_attr_init_2_1(pthread_attr_t *attr)
+/*int __pthread_attr_init_2_1(pthread_attr_t *attr)*/
int pthread_attr_init(pthread_attr_t *attr)
{
size_t ps = getpagesize ();
@@ -61,7 +61,7 @@ int pthread_attr_init(pthread_attr_t *attr)
libpthread_hidden_def(pthread_attr_init)
/* uClibc: leave out this for now. */
-#if DO_PTHREAD_VERSIONING_WITH_UCLIBC
+#if defined DO_PTHREAD_VERSIONING_WITH_UCLIBC
#if defined __PIC__ && defined DO_VERSIONING
default_symbol_version (__pthread_attr_init_2_1, pthread_attr_init, GLIBC_2.1);
@@ -201,6 +201,7 @@ int __pthread_attr_getguardsize(const pthread_attr_t *attr, size_t *guardsize)
}
weak_alias (__pthread_attr_getguardsize, pthread_attr_getguardsize)
+#if 0 /* uClibc: deprecated stuff disabled */
int __pthread_attr_setstackaddr(pthread_attr_t *attr, void *stackaddr)
{
attr->__stackaddr = stackaddr;
@@ -218,6 +219,7 @@ int __pthread_attr_getstackaddr(const pthread_attr_t *attr, void **stackaddr)
return 0;
}
weak_alias (__pthread_attr_getstackaddr, pthread_attr_getstackaddr)
+#endif
int __pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize)
{
diff --git a/libpthread/linuxthreads.old/cancel.c b/libpthread/linuxthreads.old/cancel.c
index 239b821f1..392d1d586 100644
--- a/libpthread/linuxthreads.old/cancel.c
+++ b/libpthread/linuxthreads.old/cancel.c
@@ -14,8 +14,6 @@
/* Thread cancellation */
-#define __FORCE_GLIBC
-#include <features.h>
#include <errno.h>
#include "pthread.h"
#include "internals.h"
@@ -31,7 +29,7 @@ extern void __rpc_thread_destroy(void);
#ifdef _STACK_GROWS_DOWN
# define FRAME_LEFT(frame, other) ((char *) frame >= (char *) other)
-#elif _STACK_GROWS_UP
+#elif defined _STACK_GROWS_UP
# define FRAME_LEFT(frame, other) ((char *) frame <= (char *) other)
#else
# error "Define either _STACK_GROWS_DOWN or _STACK_GROWS_UP"
@@ -193,10 +191,10 @@ void __pthread_perform_cleanup(char *currentframe)
for (c = THREAD_GETMEM(self, p_cleanup); c != NULL; c = c->__prev)
{
-#if _STACK_GROWS_DOWN
+#ifdef _STACK_GROWS_DOWN
if ((char *) c <= currentframe)
break;
-#elif _STACK_GROWS_UP
+#elif defined _STACK_GROWS_UP
if ((char *) c >= currentframe)
break;
#else
@@ -213,9 +211,9 @@ void __pthread_perform_cleanup(char *currentframe)
}
#ifndef __PIC__
-/* We need a hook to force the cancelation wrappers to be linked in when
+/* We need a hook to force the cancellation wrappers to be linked in when
static libpthread is used. */
-extern const int __pthread_provide_wrappers;
-static const int * const __pthread_require_wrappers =
+extern const char __pthread_provide_wrappers;
+static const char *const __pthread_require_wrappers =
&__pthread_provide_wrappers;
#endif
diff --git a/libpthread/linuxthreads.old/condvar.c b/libpthread/linuxthreads.old/condvar.c
index 23e71393c..35daacf15 100644
--- a/libpthread/linuxthreads.old/condvar.c
+++ b/libpthread/linuxthreads.old/condvar.c
@@ -25,16 +25,6 @@
#include "queue.h"
#include "restart.h"
-libpthread_hidden_proto(pthread_cond_broadcast)
-libpthread_hidden_proto(pthread_cond_destroy)
-libpthread_hidden_proto(pthread_cond_init)
-libpthread_hidden_proto(pthread_cond_signal)
-libpthread_hidden_proto(pthread_cond_wait)
-libpthread_hidden_proto(pthread_cond_timedwait)
-
-libpthread_hidden_proto(pthread_condattr_destroy)
-libpthread_hidden_proto(pthread_condattr_init)
-
int pthread_cond_init(pthread_cond_t *cond,
const pthread_condattr_t *cond_attr attribute_unused)
{
diff --git a/libpthread/linuxthreads.old/errno.c b/libpthread/linuxthreads.old/errno.c
index f5778f98a..748c1d512 100644
--- a/libpthread/linuxthreads.old/errno.c
+++ b/libpthread/linuxthreads.old/errno.c
@@ -14,8 +14,6 @@
/* Define the location of errno for the remainder of the C library */
-#define __FORCE_GLIBC
-#include <features.h>
#include <errno.h>
#include <netdb.h>
#include "pthread.h"
diff --git a/libpthread/linuxthreads.old/events.c b/libpthread/linuxthreads.old/events.c
index a4bf1f898..2a76f91d4 100644
--- a/libpthread/linuxthreads.old/events.c
+++ b/libpthread/linuxthreads.old/events.c
@@ -14,8 +14,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/>. */
/* The functions contained here do nothing, they just return. */
diff --git a/libpthread/linuxthreads.old/forward.c b/libpthread/linuxthreads.old/forward.c
index eeaefd7a3..5a1771b90 100644
--- a/libpthread/linuxthreads.old/forward.c
+++ b/libpthread/linuxthreads.old/forward.c
@@ -13,30 +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 <stdlib.h>
#include <dlfcn.h>
/* psm: keep this before internals.h */
-libc_hidden_proto(exit)
-/* vda: here's why:
+#if 0
+vda: here is why:
+headers contain libc_hidden_proto(foo).
In libpthread/linuxthreads.old/sysdeps/pthread/bits/libc-lock.h
adding libc_hidden_proto(foo) just before weak_extern (__pthread_initialize)
will not warn:
- //libc_hidden_proto(foo)
+ /* libc_hidden_proto(foo) */
weak_extern (__pthread_initialize)
- //libc_hidden_proto(foo)
+ /* libc_hidden_proto(foo) */
but adding after will! Which is extremely strange -
weak_extern expands into just "#pragma weak __pthread_initialize".
TODO: determine whether it is a gcc bug or what
-(see gcc.gnu.org/bugzilla/show_bug.cgi?id=36282).
+(see gcc.gnu.org/PR36282).
For now, just include all headers before internals.h
(they are again included in internals.h - maybe remove them there later)
-*/
+#endif
+
#include <string.h>
#include <limits.h>
#include <setjmp.h>
@@ -44,6 +45,7 @@ For now, just include all headers before internals.h
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <sys/time.h>
#include "internals.h"
@@ -160,8 +162,12 @@ FORWARD (pthread_setcancelstate, (int state, int *oldstate), (state, oldstate),
FORWARD (pthread_setcanceltype, (int type, int *oldtype), (type, oldtype), 0)
+#if 0
FORWARD2 (_pthread_cleanup_push, void, (struct _pthread_cleanup_buffer * buffer, void (*routine)(void *), void * arg), (buffer, routine, arg), return)
+#endif
FORWARD2 (_pthread_cleanup_push_defer, void, (struct _pthread_cleanup_buffer * buffer, void (*routine)(void *), void * arg), (buffer, routine, arg), return)
+#if 0
FORWARD2 (_pthread_cleanup_pop, void, (struct _pthread_cleanup_buffer * buffer, int execute), (buffer, execute), return)
+#endif
FORWARD2 (_pthread_cleanup_pop_restore, void, (struct _pthread_cleanup_buffer * buffer, int execute), (buffer, execute), return)
diff --git a/libpthread/linuxthreads.old/internals.h b/libpthread/linuxthreads.old/internals.h
index 38290a5fe..ea274d824 100644
--- a/libpthread/linuxthreads.old/internals.h
+++ b/libpthread/linuxthreads.old/internals.h
@@ -36,9 +36,7 @@
/* Use a funky version in a probably vein attempt at preventing gdb
* from dlopen()'ing glibc's libthread_db library... */
-#define STRINGIFY(s) STRINGIFY2 (s)
-#define STRINGIFY2(s) #s
-#define VERSION STRINGIFY(__UCLIBC_MAJOR__) "." STRINGIFY(__UCLIBC_MINOR__) "." STRINGIFY(__UCLIBC_SUBLEVEL__)
+#define VERSION __stringify(__UCLIBC_MAJOR__) "." __stringify(__UCLIBC_MINOR__) "." __stringify(__UCLIBC_SUBLEVEL__)
#ifndef THREAD_GETMEM
# define THREAD_GETMEM(descr, member) descr->member
@@ -254,17 +252,25 @@ extern pthread_descr __pthread_main_thread;
Initially 0, meaning that the current thread is (by definition)
the initial thread. */
-/* For non-MMU systems also remember to stack top of the initial thread.
- * This is adapted when other stacks are malloc'ed since we don't know
- * the bounds a-priori. -StS */
-
extern char *__pthread_initial_thread_bos;
#ifndef __ARCH_USE_MMU__
-extern char *__pthread_initial_thread_tos;
+/* For non-MMU systems, we have no idea the bounds of the initial thread
+ * stack, so we have to track it on the fly relative to other stacks. Do
+ * so by scaling back our assumptions on the limits of the bos/tos relative
+ * to the known mid point. See also the comments in pthread_initialize(). */
+extern char *__pthread_initial_thread_tos, *__pthread_initial_thread_mid;
#define NOMMU_INITIAL_THREAD_BOUNDS(tos,bos) \
- if ((tos)>=__pthread_initial_thread_bos \
- && (bos)<__pthread_initial_thread_tos) \
- __pthread_initial_thread_bos = (tos)+1
+ do { \
+ char *__tos = (tos); \
+ char *__bos = (bos); \
+ if (__tos >= __pthread_initial_thread_bos && \
+ __bos < __pthread_initial_thread_tos) { \
+ if (__bos < __pthread_initial_thread_mid) \
+ __pthread_initial_thread_bos = __tos; \
+ else \
+ __pthread_initial_thread_tos = __bos; \
+ } \
+ } while (0)
#else
#define NOMMU_INITIAL_THREAD_BOUNDS(tos,bos) /* empty */
#endif /* __ARCH_USE_MMU__ */
@@ -321,32 +327,28 @@ static __inline__ int invalid_handle(pthread_handle h, pthread_t id)
/* The page size we can get from the system. This should likely not be
changed by the machine file but, you never know. */
-extern size_t __pagesize;
-#include <bits/uClibc_page.h>
-#ifndef PAGE_SIZE
-#define PAGE_SIZE (sysconf (_SC_PAGESIZE))
-#endif
+#define __PAGE_SIZE (sysconf (_SC_PAGESIZE))
/* The max size of the thread stack segments. If the default
THREAD_SELF implementation is used, this must be a power of two and
- a multiple of PAGE_SIZE. */
+ a multiple of __PAGE_SIZE. */
#ifndef STACK_SIZE
#ifdef __ARCH_USE_MMU__
#define STACK_SIZE (2 * 1024 * 1024)
#else
-#define STACK_SIZE (4 * __pagesize)
+#define STACK_SIZE (4 * __PAGE_SIZE)
#endif
#endif
-/* The initial size of the thread stack. Must be a multiple of PAGE_SIZE. */
+/* The initial size of the thread stack. Must be a multiple of __PAGE_SIZE. */
#ifndef INITIAL_STACK_SIZE
-#define INITIAL_STACK_SIZE (4 * __pagesize)
+#define INITIAL_STACK_SIZE (4 * __PAGE_SIZE)
#endif
/* Size of the thread manager stack. The "- 32" avoids wasting space
with some malloc() implementations. */
#ifndef THREAD_MANAGER_STACK_SIZE
-#define THREAD_MANAGER_STACK_SIZE (2 * __pagesize - 32)
+#define THREAD_MANAGER_STACK_SIZE (2 * __PAGE_SIZE - 32)
#endif
/* The base of the "array" of thread stacks. The array will grow down from
@@ -379,7 +381,7 @@ extern size_t __pagesize;
/* Recover thread descriptor for the current thread */
-extern pthread_descr __pthread_find_self (void) __attribute__ ((const));
+extern pthread_descr __pthread_find_self (void) __attribute__ ((const)) attribute_hidden;
static __inline__ pthread_descr thread_self (void) __attribute__ ((const));
static __inline__ pthread_descr thread_self (void)
@@ -449,17 +451,18 @@ extern int __librt_multiple_threads;
/* Internal global functions */
void __pthread_do_exit (void *retval, char *currentframe)
- __attribute__ ((__noreturn__));
-void __pthread_destroy_specifics(void);
-void __pthread_perform_cleanup(char *currentframe);
-int __pthread_initialize_manager(void);
-void __pthread_message(char * fmt, ...);
-int __pthread_manager(void *reqfd);
-int __pthread_manager_event(void *reqfd);
-void __pthread_manager_sighandler(int sig);
-void __pthread_reset_main_thread(void);
-void __fresetlockfiles(void);
-void __pthread_manager_adjust_prio(int thread_prio);
+ __attribute__ ((__noreturn__)) attribute_hidden;
+void __pthread_destroy_specifics(void) attribute_hidden;
+void __pthread_perform_cleanup(char *currentframe) attribute_hidden;
+int __pthread_initialize_manager(void) attribute_hidden;
+void __pthread_message(char * fmt, ...)
+ __attribute__ ((__format__ (printf, 1, 2))) attribute_hidden;
+int __pthread_manager(void *reqfd) attribute_hidden;
+int __pthread_manager_event(void *reqfd) attribute_hidden;
+void __pthread_manager_sighandler(int sig) attribute_hidden;
+void __pthread_reset_main_thread(void) attribute_hidden;
+void __fresetlockfiles(void) attribute_hidden;
+void __pthread_manager_adjust_prio(int thread_prio) attribute_hidden;
void __pthread_initialize_minimal (void);
extern void __pthread_exit (void *retval)
@@ -468,53 +471,47 @@ extern void __pthread_exit (void *retval)
#endif
;
-extern int __pthread_attr_setguardsize __P ((pthread_attr_t *__attr,
- size_t __guardsize));
-extern int __pthread_attr_getguardsize __P ((__const pthread_attr_t *__attr,
- size_t *__guardsize));
-extern int __pthread_attr_setstackaddr __P ((pthread_attr_t *__attr,
- void *__stackaddr));
-extern int __pthread_attr_getstackaddr __P ((__const pthread_attr_t *__attr,
- void **__stackaddr));
-extern int __pthread_attr_setstacksize __P ((pthread_attr_t *__attr,
- size_t __stacksize));
-extern int __pthread_attr_getstacksize __P ((__const pthread_attr_t *__attr,
- size_t *__stacksize));
-extern int __pthread_getconcurrency __P ((void));
-extern int __pthread_setconcurrency __P ((int __level));
-extern void __pthread_kill_other_threads_np __P ((void));
-
-extern void __pthread_restart_old(pthread_descr th);
-extern void __pthread_suspend_old(pthread_descr self);
-extern int __pthread_timedsuspend_old(pthread_descr self, const struct timespec *abstime);
-
-extern void __pthread_restart_new(pthread_descr th);
-extern void __pthread_suspend_new(pthread_descr self);
-extern int __pthread_timedsuspend_new(pthread_descr self, const struct timespec *abstime);
-
-extern void __pthread_wait_for_restart_signal(pthread_descr self);
+extern int __pthread_attr_setguardsize(pthread_attr_t *__attr,
+ size_t __guardsize) attribute_hidden;
+extern int __pthread_attr_getguardsize(const pthread_attr_t *__attr,
+ size_t *__guardsize) attribute_hidden;
+extern int __pthread_attr_setstackaddr(pthread_attr_t *__attr,
+ void *__stackaddr) attribute_hidden;
+extern int __pthread_attr_getstackaddr(const pthread_attr_t *__attr,
+ void **__stackaddr) attribute_hidden;
+extern int __pthread_attr_setstacksize(pthread_attr_t *__attr,
+ size_t __stacksize) attribute_hidden;
+extern int __pthread_attr_getstacksize(const pthread_attr_t *__attr,
+ size_t *__stacksize) attribute_hidden;
+extern int __pthread_getconcurrency(void) attribute_hidden;
+extern int __pthread_setconcurrency(int __level) attribute_hidden;
+extern void __pthread_kill_other_threads_np(void) attribute_hidden;
+
+extern void __pthread_restart_old(pthread_descr th) attribute_hidden;
+extern void __pthread_suspend_old(pthread_descr self) attribute_hidden;
+extern int __pthread_timedsuspend_old(pthread_descr self, const struct timespec *abstime) attribute_hidden;
+
+extern void __pthread_restart_new(pthread_descr th) attribute_hidden;
+extern void __pthread_suspend_new(pthread_descr self) attribute_hidden;
+extern int __pthread_timedsuspend_new(pthread_descr self, const struct timespec *abstime) attribute_hidden;
+
+extern void __pthread_wait_for_restart_signal(pthread_descr self) attribute_hidden;
/* Global pointers to old or new suspend functions */
-extern void (*__pthread_restart)(pthread_descr);
-extern void (*__pthread_suspend)(pthread_descr);
-
-/* Prototypes for the function without cancelation support when the
- normal version has it. */
-extern __typeof(close) __libc_close;
-extern __typeof(nanosleep) __libc_nanosleep;
-extern __typeof(read) __libc_read;
-extern __typeof(waitpid) __libc_waitpid;
-extern __typeof(write) __libc_write;
+extern void (*__pthread_restart)(pthread_descr) attribute_hidden;
+extern void (*__pthread_suspend)(pthread_descr) attribute_hidden;
+#if defined NOT_IN_libc && defined IS_IN_libpthread
extern __typeof(pthread_mutex_init) __pthread_mutex_init attribute_hidden;
extern __typeof(pthread_mutex_destroy) __pthread_mutex_destroy attribute_hidden;
extern __typeof(pthread_mutex_lock) __pthread_mutex_lock attribute_hidden;
extern __typeof(pthread_mutex_trylock) __pthread_mutex_trylock attribute_hidden;
-extern __typeof(pthread_mutex_unlock) __pthread_mutex_attribute_hidden;
+extern __typeof(pthread_mutex_unlock) __pthread_mutex_unlock attribute_hidden;
+#endif
/* Prototypes for some of the new semaphore functions. */
-extern int __new_sem_post (sem_t * sem);
+/*extern int __new_sem_post (sem_t * sem);*/
/* TSD. */
extern int __pthread_internal_tsd_set (int key, const void * pointer);
@@ -523,12 +520,10 @@ extern void ** __attribute__ ((__const__))
__pthread_internal_tsd_address (int key);
/* The functions called the signal events. */
-extern void __linuxthreads_create_event (void);
-extern void __linuxthreads_death_event (void);
-extern void __linuxthreads_reap_event (void);
+extern void __linuxthreads_create_event (void) attribute_hidden;
+extern void __linuxthreads_death_event (void) attribute_hidden;
+extern void __linuxthreads_reap_event (void) attribute_hidden;
#include <pthread-functions.h>
-extern int * __libc_pthread_init (const struct pthread_functions *functions);
-
#endif /* internals.h */
diff --git a/libpthread/linuxthreads.old/join.c b/libpthread/linuxthreads.old/join.c
index a46d0b68d..c7e547951 100644
--- a/libpthread/linuxthreads.old/join.c
+++ b/libpthread/linuxthreads.old/join.c
@@ -25,7 +25,7 @@
#include "restart.h"
#include "debug.h" /* PDEBUG, added by StS */
-libpthread_hidden_proto (pthread_exit)
+libpthread_hidden_proto(pthread_exit)
void pthread_exit(void * retval)
{
__pthread_do_exit (retval, CURRENT_STACK_FRAME);
@@ -77,7 +77,7 @@ void __pthread_do_exit(void *retval, char *currentframe)
THREAD_SETMEM(self, p_terminated, 1);
/* See if someone is joining on us */
joining = THREAD_GETMEM(self, p_joining);
- PDEBUG("joining = %p, pid=%d\n", joining, joining->p_pid);
+ PDEBUG("joining = %p, pid=%d\n", joining, joining ? joining->p_pid : 0);
__pthread_unlock(THREAD_GETMEM(self, p_lock));
/* Restart joining thread if any */
if (joining != NULL) restart(joining);
@@ -87,7 +87,7 @@ void __pthread_do_exit(void *retval, char *currentframe)
if (self == __pthread_main_thread && __pthread_manager_request >= 0) {
request.req_thread = self;
request.req_kind = REQ_MAIN_THREAD_EXIT;
- TEMP_FAILURE_RETRY(__libc_write(__pthread_manager_request,
+ TEMP_FAILURE_RETRY(write(__pthread_manager_request,
(char *)&request, sizeof(request)));
suspend(self);
/* Main thread flushes stdio streams and runs atexit functions.
@@ -186,10 +186,148 @@ int pthread_join(pthread_t thread_id, void ** thread_return)
request.req_thread = self;
request.req_kind = REQ_FREE;
request.req_args.free.thread_id = thread_id;
+ TEMP_FAILURE_RETRY(write(__pthread_manager_request,
+ (char *) &request, sizeof(request)));
+ }
+ return 0;
+}
+
+int pthread_tryjoin_np(pthread_t thread_id, void ** thread_return)
+{
+ volatile pthread_descr self = thread_self();
+ struct pthread_request request;
+ pthread_handle handle = thread_handle(thread_id);
+ pthread_descr th;
+ int result = 0;
+
+ /* Make sure the descriptor is valid. */
+ __pthread_lock(&handle->h_lock, self);
+ if (invalid_handle(handle, thread_id)) {
+ result = ESRCH;
+ goto err;
+ }
+ th = handle->h_descr;
+ /* Is the thread joinable?. */
+ if (th->p_detached || th->p_joining != NULL) {
+ result = EINVAL;
+ goto err;
+ }
+ if (th == self) {
+ result = EDEADLK;
+ goto err;
+ }
+ /* Return right away if the thread hasn't terminated yet. */
+ if (! th->p_terminated) {
+ result = EBUSY;
+ goto err;
+ }
+
+ /* Get return value */
+ if (thread_return != NULL) *thread_return = th->p_retval;
+ __pthread_unlock(&handle->h_lock);
+ /* Send notification to thread manager */
+ if (__pthread_manager_request >= 0) {
+ request.req_thread = self;
+ request.req_kind = REQ_FREE;
+ request.req_args.free.thread_id = thread_id;
TEMP_FAILURE_RETRY(__libc_write(__pthread_manager_request,
(char *) &request, sizeof(request)));
}
return 0;
+
+err:
+ __pthread_unlock(&handle->h_lock);
+ return result;
+}
+
+int pthread_timedjoin_np(pthread_t thread_id, void ** thread_return,
+ const struct timespec *abstime)
+{
+ volatile pthread_descr self = thread_self();
+ struct pthread_request request;
+ pthread_handle handle = thread_handle(thread_id);
+ pthread_descr th;
+ pthread_extricate_if extr;
+ int already_canceled = 0;
+ int result = 0;
+ PDEBUG("\n");
+
+ /* Set up extrication interface */
+ extr.pu_object = handle;
+ extr.pu_extricate_func = join_extricate_func;
+
+ __pthread_lock(&handle->h_lock, self);
+ if (invalid_handle(handle, thread_id)) {
+ result = ESRCH;
+ goto err;
+ }
+ th = handle->h_descr;
+ if (th == self) {
+ result = EDEADLK;
+ goto err;
+ }
+ /* If detached or already joined, error */
+ if (th->p_detached || th->p_joining != NULL) {
+ result = EINVAL;
+ goto err;
+ }
+ /* If not terminated yet, suspend ourselves. */
+ if (! th->p_terminated) {
+ /* Register extrication interface */
+ __pthread_set_own_extricate_if(self, &extr);
+ if (!(THREAD_GETMEM(self, p_canceled)
+ && THREAD_GETMEM(self, p_cancelstate) == PTHREAD_CANCEL_ENABLE))
+ th->p_joining = self;
+ else
+ already_canceled = 1;
+ __pthread_unlock(&handle->h_lock);
+
+ if (already_canceled) {
+ __pthread_set_own_extricate_if(self, 0);
+ __pthread_do_exit(PTHREAD_CANCELED, CURRENT_STACK_FRAME);
+ }
+
+ PDEBUG("before suspend\n");
+ result = (timedsuspend(self, abstime) == 0) ? ETIMEDOUT : 0;
+ PDEBUG("after suspend\n");
+ /* Deregister extrication interface */
+ __pthread_set_own_extricate_if(self, 0);
+
+ /* This is a cancellation point */
+ if (result == 0
+ && THREAD_GETMEM(self, p_woken_by_cancel)
+ && THREAD_GETMEM(self, p_cancelstate) == PTHREAD_CANCEL_ENABLE) {
+ THREAD_SETMEM(self, p_woken_by_cancel, 0);
+ __pthread_do_exit(PTHREAD_CANCELED, CURRENT_STACK_FRAME);
+ }
+ __pthread_lock(&handle->h_lock, self);
+ }
+
+ /* We might have timed out. */
+ if (result == 0) {
+ /* Get return value */
+ if (thread_return != NULL) *thread_return = th->p_retval;
+ }
+ else
+ th->p_joining = NULL;
+
+ __pthread_unlock(&handle->h_lock);
+
+ if (result == 0) {
+ /* Send notification to thread manager */
+ if (__pthread_manager_request >= 0) {
+ request.req_thread = self;
+ request.req_kind = REQ_FREE;
+ request.req_args.free.thread_id = thread_id;
+ TEMP_FAILURE_RETRY(__libc_write(__pthread_manager_request,
+ (char *) &request, sizeof(request)));
+ }
+ }
+ return result;
+
+err:
+ __pthread_unlock(&handle->h_lock);
+ return result;
}
int pthread_detach(pthread_t thread_id)
@@ -224,7 +362,7 @@ int pthread_detach(pthread_t thread_id)
request.req_thread = thread_self();
request.req_kind = REQ_FREE;
request.req_args.free.thread_id = thread_id;
- TEMP_FAILURE_RETRY(__libc_write(__pthread_manager_request,
+ TEMP_FAILURE_RETRY(write(__pthread_manager_request,
(char *) &request, sizeof(request)));
}
return 0;
diff --git a/libpthread/linuxthreads.old/libc_pthread_init.c b/libpthread/linuxthreads.old/libc_pthread_init.c
index 09606effb..dfdcbcccc 100644
--- a/libpthread/linuxthreads.old/libc_pthread_init.c
+++ b/libpthread/linuxthreads.old/libc_pthread_init.c
@@ -13,22 +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 <features.h>
#include <locale.h>
-#include <stdlib.h>
#include <string.h>
-#include "internals.h"
-#include "sysdeps/pthread/pthread-functions.h"
+#include <linuxthreads.old/sysdeps/pthread/pthread-functions.h>
-/* Experimentally off - libc_hidden_proto(memcpy) */
-
-#if !(USE_TLS && HAVE___THREAD) && defined __UCLIBC_HAS_XLOCALE__
-libc_hidden_proto(uselocale)
-#endif
int __libc_multiple_threads attribute_hidden __attribute__((nocommon));
@@ -42,7 +33,7 @@ int * __libc_pthread_init (const struct pthread_functions *functions)
sizeof (__libc_pthread_functions));
#endif
-#if !(USE_TLS && HAVE___THREAD) && defined __UCLIBC_HAS_XLOCALE__
+#if !defined __UCLIBC_HAS_TLS__ && defined __UCLIBC_HAS_XLOCALE__
/* Initialize thread-locale current locale to point to the global one.
With __thread support, the variable's initializer takes care of this. */
uselocale (LC_GLOBAL_LOCALE);
diff --git a/libpthread/linuxthreads.old/locale.c b/libpthread/linuxthreads.old/locale.c
index c0879d0ce..12497182d 100644
--- a/libpthread/linuxthreads.old/locale.c
+++ b/libpthread/linuxthreads.old/locale.c
@@ -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/>.
*/
#include <features.h>
diff --git a/libpthread/linuxthreads.old/lockfile.c b/libpthread/linuxthreads.old/lockfile.c
index d054b62cb..de834c476 100644
--- a/libpthread/linuxthreads.old/lockfile.c
+++ b/libpthread/linuxthreads.old/lockfile.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; 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/>. */
#include <stdio.h>
#include <pthread.h>
diff --git a/libpthread/linuxthreads.old/manager.c b/libpthread/linuxthreads.old/manager.c
index 69fdd1cb5..e4022f8ea 100644
--- a/libpthread/linuxthreads.old/manager.c
+++ b/libpthread/linuxthreads.old/manager.c
@@ -35,6 +35,9 @@
#include "semaphore.h"
#include "debug.h" /* PDEBUG, added by StS */
+#ifndef THREAD_STACK_OFFSET
+#define THREAD_STACK_OFFSET 0
+#endif
/* poll() is not supported in kernel <= 2.0, therefore is __NR_poll is
* not available, we assume an old Linux kernel is in use and we will
@@ -137,7 +140,7 @@ int attribute_noreturn __pthread_manager(void *arg)
#endif /* __UCLIBC_HAS_XLOCALE__ */
/* Block all signals except __pthread_sig_cancel and SIGTRAP */
- sigfillset(&manager_mask);
+ __sigfillset(&manager_mask);
sigdelset(&manager_mask, __pthread_sig_cancel); /* for thread termination */
sigdelset(&manager_mask, SIGTRAP); /* for debugging purposes */
if (__pthread_threads_debug && __pthread_sig_debug > 0)
@@ -146,7 +149,7 @@ int attribute_noreturn __pthread_manager(void *arg)
/* Raise our priority to match that of main thread */
__pthread_manager_adjust_prio(__pthread_main_thread->p_priority);
/* Synchronize debugging of the thread manager */
- n = TEMP_FAILURE_RETRY(__libc_read(reqfd, (char *)&request,
+ n = TEMP_FAILURE_RETRY(read(reqfd, (char *)&request,
sizeof(request)));
#ifndef USE_SELECT
ufd.fd = reqfd;
@@ -183,9 +186,9 @@ int attribute_noreturn __pthread_manager(void *arg)
#endif
{
- PDEBUG("before __libc_read\n");
- n = __libc_read(reqfd, (char *)&request, sizeof(request));
- PDEBUG("after __libc_read, n=%d\n", n);
+ PDEBUG("before read\n");
+ n = read(reqfd, (char *)&request, sizeof(request));
+ PDEBUG("after read, n=%d\n", n);
switch(request.req_kind) {
case REQ_CREATE:
PDEBUG("got REQ_CREATE\n");
@@ -198,7 +201,7 @@ int attribute_noreturn __pthread_manager(void *arg)
request.req_thread->p_pid,
request.req_thread->p_report_events,
&request.req_thread->p_eventbuf.eventmask);
- PDEBUG("restarting %d\n", request.req_thread);
+ PDEBUG("restarting %p\n", request.req_thread);
restart(request.req_thread);
break;
case REQ_FREE:
@@ -206,7 +209,7 @@ int attribute_noreturn __pthread_manager(void *arg)
pthread_handle_free(request.req_args.free.thread_id);
break;
case REQ_PROCESS_EXIT:
- PDEBUG("got REQ_PROCESS_EXIT from %d, exit code = %d\n",
+ PDEBUG("got REQ_PROCESS_EXIT from %p, exit code = %d\n",
request.req_thread, request.req_args.exit.code);
pthread_handle_exit(request.req_thread,
request.req_args.exit.code);
@@ -229,14 +232,14 @@ int attribute_noreturn __pthread_manager(void *arg)
break;
case REQ_POST:
PDEBUG("got REQ_POST\n");
- __new_sem_post(request.req_args.post);
+ sem_post(request.req_args.post);
break;
case REQ_DEBUG:
PDEBUG("got REQ_DEBUG\n");
/* Make gdb aware of new thread and gdb will restart the
new thread when it is ready to handle the new thread. */
if (__pthread_threads_debug && __pthread_sig_debug > 0) {
- PDEBUG("about to call raise(__pthread_sig_debug)\n");
+ PDEBUG("about to call raise(__pthread_sig_debug)\n");
raise(__pthread_sig_debug);
}
case REQ_KICK:
@@ -248,7 +251,7 @@ int attribute_noreturn __pthread_manager(void *arg)
}
}
-int __pthread_manager_event(void *arg)
+int attribute_noreturn __pthread_manager_event(void *arg)
{
/* If we have special thread_self processing, initialize it. */
#ifdef INIT_THREAD_SELF
@@ -260,7 +263,7 @@ int __pthread_manager_event(void *arg)
/* Free it immediately. */
__pthread_unlock (THREAD_GETMEM((&__pthread_manager_thread), p_lock));
- return __pthread_manager(arg);
+ __pthread_manager(arg);
}
/* Process creation */
@@ -301,7 +304,7 @@ pthread_start_thread(void *arg)
if (__pthread_threads_debug && __pthread_sig_debug > 0) {
request.req_thread = self;
request.req_kind = REQ_DEBUG;
- TEMP_FAILURE_RETRY(__libc_write(__pthread_manager_request,
+ TEMP_FAILURE_RETRY(write(__pthread_manager_request,
(char *) &request, sizeof(request)));
suspend(self);
}
@@ -349,8 +352,7 @@ static int pthread_allocate_stack(const pthread_attr_t *attr,
if (attr != NULL && attr->__stackaddr_set)
{
/* The user provided a stack. */
- new_thread =
- (pthread_descr) ((long)(attr->__stackaddr) & -sizeof(void *)) - 1;
+ new_thread = (pthread_descr) ((long)(attr->__stackaddr) & -sizeof(void *)) - 1;
new_thread_bottom = (char *) attr->__stackaddr - attr->__stacksize;
guardaddr = NULL;
guardsize = 0;
@@ -368,7 +370,7 @@ static int pthread_allocate_stack(const pthread_attr_t *attr,
#ifdef __ARCH_USE_MMU__
stacksize = STACK_SIZE - pagesize;
if (attr != NULL)
- stacksize = MIN (stacksize, roundup(attr->__stacksize, pagesize));
+ stacksize = MIN(stacksize, roundup(attr->__stacksize, pagesize));
/* Allocate space for stack and thread descriptor at default address */
new_thread = default_new_thread;
new_thread_bottom = (char *) (new_thread + 1) - stacksize;
@@ -394,7 +396,7 @@ static int pthread_allocate_stack(const pthread_attr_t *attr,
/* Put a bad page at the bottom of the stack */
guardsize = attr->__guardsize;
guardaddr = (void *)new_thread_bottom - guardsize;
- if (mmap ((caddr_t) guardaddr, guardsize, 0, MAP_FIXED, -1, 0)
+ if (mmap((caddr_t) guardaddr, guardsize, 0, MAP_FIXED, -1, 0)
== MAP_FAILED)
{
/* We don't make this an error. */
@@ -477,6 +479,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
int pid;
pthread_descr new_thread;
char * new_thread_bottom;
+ char * new_thread_top;
pthread_t new_thread_id;
char *guardaddr = NULL;
size_t guardsize = 0;
@@ -562,7 +565,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
/* Do the cloning. We have to use two different functions depending
on whether we are debugging or not. */
pid = 0; /* Note that the thread never can have PID zero. */
-
+ new_thread_top = ((char *)new_thread - THREAD_STACK_OFFSET);
/* ******************************************************** */
/* This code was moved from below to cope with running threads
@@ -579,9 +582,9 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
/* See whether the TD_CREATE event bit is set in any of the
masks. */
int idx = __td_eventword (TD_CREATE);
- uint32_t mask = __td_eventmask (TD_CREATE);
+ uint32_t m = __td_eventmask (TD_CREATE);
- if ((mask & (__pthread_threads_events.event_bits[idx]
+ if ((m & (__pthread_threads_events.event_bits[idx]
| event_maskp->event_bits[idx])) != 0)
{
/* Lock the mutex the child will use now so that it will stop. */
@@ -589,12 +592,12 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
/* We have to report this event. */
#ifdef __ia64__
- pid = __clone2(pthread_start_thread_event, (void **) new_thread,
- (char *)new_thread - new_thread_bottom,
+ pid = __clone2(pthread_start_thread_event, new_thread_top,
+ new_thread_top - new_thread_bottom,
CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
__pthread_sig_cancel, new_thread);
#else
- pid = clone(pthread_start_thread_event, (void **) new_thread,
+ pid = clone(pthread_start_thread_event, new_thread_top,
CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
__pthread_sig_cancel, new_thread);
#endif
@@ -627,12 +630,12 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
{
PDEBUG("cloning new_thread = %p\n", new_thread);
#ifdef __ia64__
- pid = __clone2(pthread_start_thread, (void **) new_thread,
- (char *)new_thread - new_thread_bottom,
+ pid = __clone2(pthread_start_thread, new_thread_top,
+ new_thread_top - new_thread_bottom,
CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
__pthread_sig_cancel, new_thread);
#else
- pid = clone(pthread_start_thread, (void **) new_thread,
+ pid = clone(pthread_start_thread, new_thread_top,
CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
__pthread_sig_cancel, new_thread);
#endif
@@ -663,7 +666,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
__pthread_handles[sseg].h_descr = NULL;
__pthread_handles[sseg].h_bottom = NULL;
__pthread_handles_num--;
- return errno;
+ return saved_errno;
}
PDEBUG("new thread pid = %d\n", pid);
@@ -701,12 +704,16 @@ static void pthread_free(pthread_descr th)
{
pthread_handle handle;
pthread_readlock_info *iter, *next;
+#ifndef __ARCH_USE_MMU__
char *h_bottom_save;
+#endif
/* Make the handle invalid */
handle = thread_handle(th->p_tid);
__pthread_lock(&handle->h_lock, NULL);
+#ifndef __ARCH_USE_MMU__
h_bottom_save = handle->h_bottom;
+#endif
handle->h_descr = NULL;
handle->h_bottom = (char *)(-1L);
__pthread_unlock(&handle->h_lock);
@@ -734,20 +741,18 @@ static void pthread_free(pthread_descr th)
/* If initial thread, nothing to free */
if (th == &__pthread_initial_thread) return;
-#ifdef __ARCH_USE_MMU__
if (!th->p_userstack)
{
+#ifdef __ARCH_USE_MMU__
/* Free the stack and thread descriptor area */
if (th->p_guardsize != 0)
munmap(th->p_guardaddr, th->p_guardsize);
munmap((caddr_t) ((char *)(th+1) - STACK_SIZE), STACK_SIZE);
- }
#else
- /* For non-MMU systems we always malloc the stack, so free it here. -StS */
- if (!th->p_userstack) {
+ /* For non-MMU systems we always malloc the stack, so free it here. -StS */
free(h_bottom_save);
- }
#endif /* __ARCH_USE_MMU__ */
+ }
}
/* Handle threads that have exited */
@@ -808,7 +813,7 @@ static void pthread_reap_children(void)
int status;
PDEBUG("\n");
- while ((pid = __libc_waitpid(-1, &status, WNOHANG | __WCLONE)) > 0) {
+ while ((pid = waitpid(-1, &status, WNOHANG | __WCLONE)) > 0) {
pthread_exited(pid);
if (WIFSIGNALED(status)) {
/* If a thread died due to a signal, send the same signal to
@@ -907,7 +912,7 @@ void __pthread_manager_sighandler(int sig attribute_unused)
struct pthread_request request;
request.req_thread = 0;
request.req_kind = REQ_KICK;
- TEMP_FAILURE_RETRY(__libc_write(__pthread_manager_request,
+ TEMP_FAILURE_RETRY(write(__pthread_manager_request,
(char *) &request, sizeof(request)));
}
}
diff --git a/libpthread/linuxthreads.old/oldsemaphore.c b/libpthread/linuxthreads.old/oldsemaphore.c
deleted file mode 100644
index 2a7b40acc..000000000
--- a/libpthread/linuxthreads.old/oldsemaphore.c
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * This file contains the old semaphore code that we need to
- * preserve for glibc-2.0 backwards compatibility. Port to glibc 2.1
- * done by Cristian Gafton.
- */
-
-/* Linuxthreads - a simple clone()-based implementation of Posix */
-/* threads for Linux. */
-/* Copyright (C) 1996 Xavier Leroy (Xavier.Leroy@inria.fr) */
-/* */
-/* 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. */
-
-/* Semaphores a la POSIX 1003.1b */
-
-#include <errno.h>
-#include "pthread.h"
-#include "internals.h"
-#include "spinlock.h"
-#include "restart.h"
-#include "queue.h"
-
-typedef struct {
- long int sem_status;
- int sem_spinlock;
-} old_sem_t;
-
-/* Maximum value the semaphore can have. */
-#define SEM_VALUE_MAX ((int) ((~0u) >> 1))
-
-static __inline__ int sem_compare_and_swap(old_sem_t *sem, long oldval, long newval)
-{
- return compare_and_swap(&sem->sem_status, oldval, newval, &sem->sem_spinlock);
-}
-
-/* The state of a semaphore is represented by a long int encoding
- either the semaphore count if >= 0 and no thread is waiting on it,
- or the head of the list of threads waiting for the semaphore.
- To distinguish the two cases, we encode the semaphore count N
- as 2N+1, so that it has the lowest bit set.
-
- A sequence of sem_wait operations on a semaphore initialized to N
- result in the following successive states:
- 2N+1, 2N-1, ..., 3, 1, &first_waiting_thread, &second_waiting_thread, ...
-*/
-
-static void sem_restart_list(pthread_descr waiting);
-
-int __old_sem_init(old_sem_t *sem, int pshared, unsigned int value);
-int __old_sem_init(old_sem_t *sem, int pshared, unsigned int value)
-{
- if (value > SEM_VALUE_MAX) {
- errno = EINVAL;
- return -1;
- }
- if (pshared) {
- errno = ENOSYS;
- return -1;
- }
- sem->sem_spinlock = 0;
- sem->sem_status = ((long)value << 1) + 1;
- return 0;
-}
-
-/* Function called by pthread_cancel to remove the thread from
- waiting inside __old_sem_wait. Here we simply unconditionally
- indicate that the thread is to be woken, by returning 1. */
-
-static int old_sem_extricate_func(void *obj attribute_unused, pthread_descr th attribute_unused)
-{
- return 1;
-}
-
-int __old_sem_wait(old_sem_t * sem);
-int __old_sem_wait(old_sem_t * sem)
-{
- long oldstatus, newstatus;
- volatile pthread_descr self = thread_self();
- pthread_descr * th;
- pthread_extricate_if extr;
-
- /* Set up extrication interface */
- extr.pu_object = 0;
- extr.pu_extricate_func = old_sem_extricate_func;
-
- while (1) {
- /* Register extrication interface */
- __pthread_set_own_extricate_if(self, &extr);
- do {
- oldstatus = sem->sem_status;
- if ((oldstatus & 1) && (oldstatus != 1))
- newstatus = oldstatus - 2;
- else {
- newstatus = (long) self;
- self->p_nextwaiting = (pthread_descr) oldstatus;
- }
- }
- while (! sem_compare_and_swap(sem, oldstatus, newstatus));
- if (newstatus & 1) {
- /* We got the semaphore. */
- __pthread_set_own_extricate_if(self, 0);
- return 0;
- }
- /* Wait for sem_post or cancellation */
- suspend(self);
- __pthread_set_own_extricate_if(self, 0);
-
- /* This is a cancellation point */
- if (self->p_canceled && self->p_cancelstate == PTHREAD_CANCEL_ENABLE) {
- /* Remove ourselves from the waiting list if we're still on it */
- /* First check if we're at the head of the list. */
- do {
- oldstatus = sem->sem_status;
- if (oldstatus != (long) self) break;
- newstatus = (long) self->p_nextwaiting;
- }
- while (! sem_compare_and_swap(sem, oldstatus, newstatus));
- /* Now, check if we're somewhere in the list.
- There's a race condition with sem_post here, but it does not matter:
- the net result is that at the time pthread_exit is called,
- self is no longer reachable from sem->sem_status. */
- if (oldstatus != (long) self && (oldstatus & 1) == 0) {
- for (th = &(((pthread_descr) oldstatus)->p_nextwaiting);
- *th != NULL && *th != (pthread_descr) 1;
- th = &((*th)->p_nextwaiting)) {
- if (*th == self) {
- *th = self->p_nextwaiting;
- break;
- }
- }
- }
- __pthread_do_exit(PTHREAD_CANCELED, CURRENT_STACK_FRAME);
- }
- }
-}
-
-int __old_sem_trywait(old_sem_t * sem);
-int __old_sem_trywait(old_sem_t * sem)
-{
- long oldstatus, newstatus;
-
- do {
- oldstatus = sem->sem_status;
- if ((oldstatus & 1) == 0 || (oldstatus == 1)) {
- errno = EAGAIN;
- return -1;
- }
- newstatus = oldstatus - 2;
- }
- while (! sem_compare_and_swap(sem, oldstatus, newstatus));
- return 0;
-}
-
-int __old_sem_post(old_sem_t * sem);
-int __old_sem_post(old_sem_t * sem)
-{
- long oldstatus, newstatus;
-
- do {
- oldstatus = sem->sem_status;
- if ((oldstatus & 1) == 0)
- newstatus = 3;
- else {
- if (oldstatus >= SEM_VALUE_MAX) {
- /* Overflow */
- errno = ERANGE;
- return -1;
- }
- newstatus = oldstatus + 2;
- }
- }
- while (! sem_compare_and_swap(sem, oldstatus, newstatus));
- if ((oldstatus & 1) == 0)
- sem_restart_list((pthread_descr) oldstatus);
- return 0;
-}
-
-int __old_sem_getvalue(old_sem_t * sem, int * sval);
-int __old_sem_getvalue(old_sem_t * sem, int * sval)
-{
- long status = sem->sem_status;
- if (status & 1)
- *sval = (int)((unsigned long) status >> 1);
- else
- *sval = 0;
- return 0;
-}
-
-int __old_sem_destroy(old_sem_t * sem);
-int __old_sem_destroy(old_sem_t * sem)
-{
- if ((sem->sem_status & 1) == 0) {
- errno = EBUSY;
- return -1;
- }
- return 0;
-}
-
-/* Auxiliary function for restarting all threads on a waiting list,
- in priority order. */
-
-static void sem_restart_list(pthread_descr waiting)
-{
- pthread_descr th, towake, *p;
-
- /* Sort list of waiting threads by decreasing priority (insertion sort) */
- towake = NULL;
- while (waiting != (pthread_descr) 1) {
- th = waiting;
- waiting = waiting->p_nextwaiting;
- p = &towake;
- while (*p != NULL && th->p_priority < (*p)->p_priority)
- p = &((*p)->p_nextwaiting);
- th->p_nextwaiting = *p;
- *p = th;
- }
- /* Wake up threads in priority order */
- while (towake != NULL) {
- th = towake;
- towake = towake->p_nextwaiting;
- th->p_nextwaiting = NULL;
- restart(th);
- }
-}
-
-#if defined __PIC__ && defined DO_VERSIONING
-symbol_version (__old_sem_init, sem_init, GLIBC_2.0);
-symbol_version (__old_sem_wait, sem_wait, GLIBC_2.0);
-symbol_version (__old_sem_trywait, sem_trywait, GLIBC_2.0);
-symbol_version (__old_sem_post, sem_post, GLIBC_2.0);
-symbol_version (__old_sem_getvalue, sem_getvalue, GLIBC_2.0);
-symbol_version (__old_sem_destroy, sem_destroy, GLIBC_2.0);
-#endif
-
diff --git a/libpthread/linuxthreads.old/pt-machine.c b/libpthread/linuxthreads.old/pt-machine.c
index 438008d5d..6963dfcab 100644
--- a/libpthread/linuxthreads.old/pt-machine.c
+++ b/libpthread/linuxthreads.old/pt-machine.c
@@ -14,8 +14,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/>. */
#define PT_EI
diff --git a/libpthread/linuxthreads.old/ptfork.c b/libpthread/linuxthreads.old/ptfork.c
index c34ea8104..6f1e2d3c9 100644
--- a/libpthread/linuxthreads.old/ptfork.c
+++ b/libpthread/linuxthreads.old/ptfork.c
@@ -20,6 +20,7 @@
#ifdef __ARCH_USE_MMU__
+#include <bits/uClibc_mutex.h>
#include <stddef.h>
#include <stdlib.h>
#include <unistd.h>
@@ -36,6 +37,16 @@ static struct handler_list * pthread_atfork_prepare = NULL;
static struct handler_list * pthread_atfork_parent = NULL;
static struct handler_list * pthread_atfork_child = NULL;
+#ifdef __MALLOC__
+__UCLIBC_MUTEX_EXTERN(__malloc_heap_lock);
+__UCLIBC_MUTEX_EXTERN(__malloc_sbrk_lock);
+#ifdef __UCLIBC_UCLINUX_BROKEN_MUNMAP__
+__UCLIBC_MUTEX_EXTERN(__malloc_mmb_heap_lock);
+#endif
+#elif defined(__MALLOC_STANDARD__) || defined(__MALLOC_SIMPLE__)
+__UCLIBC_MUTEX_EXTERN(__malloc_lock);
+#endif
+
static void pthread_insert_list(struct handler_list ** list,
void (*handler)(void),
struct handler_list * newlist,
@@ -71,17 +82,18 @@ int pthread_atfork(void (*prepare)(void),
__pthread_mutex_unlock(&pthread_atfork_lock);
return 0;
}
-//strong_alias (__pthread_atfork, pthread_atfork)
+/*strong_alias (__pthread_atfork, pthread_atfork)*/
static __inline__ void pthread_call_handlers(struct handler_list * list)
{
for (/*nothing*/; list != NULL; list = list->next) (list->handler)();
}
-extern __typeof(fork) __libc_fork;
+void __pthread_once_fork_prepare(void);
+void __pthread_once_fork_child(void);
+void __pthread_once_fork_parent(void);
-pid_t __fork(void) attribute_hidden;
-pid_t __fork(void)
+static pid_t __fork(void)
{
pid_t pid;
struct handler_list * prepare, * child, * parent;
@@ -90,24 +102,53 @@ pid_t __fork(void)
prepare = pthread_atfork_prepare;
child = pthread_atfork_child;
parent = pthread_atfork_parent;
- __pthread_mutex_unlock(&pthread_atfork_lock);
pthread_call_handlers(prepare);
+
+ __pthread_once_fork_prepare();
+#ifdef __MALLOC__
+ __pthread_mutex_lock(&__malloc_sbrk_lock);
+ __pthread_mutex_lock(&__malloc_heap_lock);
+#ifdef __UCLIBC_UCLINUX_BROKEN_MUNMAP__
+ __pthread_mutex_lock(&__malloc_mmb_heap_lock);
+#endif
+#elif defined(__MALLOC_STANDARD__) || defined(__MALLOC_SIMPLE__)
+ __pthread_mutex_lock(&__malloc_lock);
+#endif
+
pid = __libc_fork();
if (pid == 0) {
+#if defined(__MALLOC_STANDARD__) || defined(__MALLOC_SIMPLE__)
+ __libc_lock_init_recursive(__malloc_lock);
+#elif defined(__MALLOC__)
+#ifdef __UCLIBC_UCLINUX_BROKEN_MUNMAP__
+ __libc_lock_init_adaptive(__malloc_mmb_heap_lock);
+#endif
+ __libc_lock_init_adaptive(__malloc_heap_lock);
+ __libc_lock_init(__malloc_sbrk_lock);
+#endif
+ __libc_lock_init_adaptive(pthread_atfork_lock);
__pthread_reset_main_thread();
__fresetlockfiles();
+ __pthread_once_fork_child();
pthread_call_handlers(child);
} else {
+#if defined(__MALLOC_STANDARD__) || defined(__MALLOC_SIMPLE__)
+ __pthread_mutex_unlock(&__malloc_lock);
+#elif defined(__MALLOC__)
+#ifdef __UCLIBC_UCLINUX_BROKEN_MUNMAP__
+ __pthread_mutex_unlock(&__malloc_mmb_heap_lock);
+#endif
+ __pthread_mutex_unlock(&__malloc_heap_lock);
+ __pthread_mutex_unlock(&__malloc_sbrk_lock);
+#endif
+ __pthread_mutex_unlock(&pthread_atfork_lock);
+ __pthread_once_fork_parent();
pthread_call_handlers(parent);
}
return pid;
}
strong_alias(__fork,fork)
-
-pid_t vfork(void)
-{
- return __fork();
-}
+strong_alias(__fork,vfork)
#else
diff --git a/libpthread/linuxthreads.old/pthread.c b/libpthread/linuxthreads.old/pthread.c
index 35de4b731..00197b158 100644
--- a/libpthread/linuxthreads.old/pthread.c
+++ b/libpthread/linuxthreads.old/pthread.c
@@ -14,8 +14,6 @@
/* Thread creation, initialization, and basic low-level routines */
-#define __FORCE_GLIBC
-#include <features.h>
#include <errno.h>
#include <netdb.h> /* for h_errno */
#include <stddef.h>
@@ -38,8 +36,6 @@
#include <sys/types.h>
#include <sys/syscall.h>
-/* mods for uClibc: __libc_sigaction is not in any standard headers */
-extern __typeof(sigaction) __libc_sigaction;
libpthread_hidden_proto(waitpid)
libpthread_hidden_proto(raise)
@@ -168,12 +164,10 @@ pthread_descr __pthread_main_thread = &__pthread_initial_thread;
char *__pthread_initial_thread_bos = NULL;
-/* For non-MMU systems also remember to stack top of the initial thread.
- * This is adapted when other stacks are malloc'ed since we don't know
- * the bounds a-priori. -StS */
-
#ifndef __ARCH_USE_MMU__
+/* See nommu notes in internals.h and pthread_initialize() below. */
char *__pthread_initial_thread_tos = NULL;
+char *__pthread_initial_thread_mid = NULL;
#endif /* __ARCH_USE_MMU__ */
/* File descriptor for sending requests to the thread manager. */
@@ -262,6 +256,7 @@ int __libc_current_sigrtmax (void)
return current_rtmax;
}
+#if 0
/* Allocate real-time signal with highest/lowest available
priority. Please note that we don't use a lock since we assume
this function to be called at program start. */
@@ -274,6 +269,7 @@ int __libc_allocate_rtsig (int high)
return high ? current_rtmin++ : current_rtmax--;
}
#endif
+#endif
/* Initialize the pthread library.
Initialization is split in two functions:
@@ -321,7 +317,7 @@ libpthread_hidden_proto(pthread_condattr_init)
struct pthread_functions __pthread_functions =
{
-#if !(USE_TLS && HAVE___THREAD)
+#if !defined __UCLIBC_HAS_TLS__ && defined __UCLIBC_HAS_RPC__
.ptr_pthread_internal_tsd_set = __pthread_internal_tsd_set,
.ptr_pthread_internal_tsd_get = __pthread_internal_tsd_get,
.ptr_pthread_internal_tsd_address = __pthread_internal_tsd_address,
@@ -369,10 +365,10 @@ struct pthread_functions __pthread_functions =
.ptr_pthread_sigwait = pthread_sigwait,
.ptr_pthread_raise = pthread_raise,
.ptr__pthread_cleanup_push = _pthread_cleanup_push,
- .ptr__pthread_cleanup_pop = _pthread_cleanup_pop
+ .ptr__pthread_cleanup_pop = _pthread_cleanup_pop,
*/
.ptr__pthread_cleanup_push_defer = __pthread_cleanup_push_defer,
- .ptr__pthread_cleanup_pop_restore = __pthread_cleanup_pop_restore,
+ .ptr__pthread_cleanup_pop_restore = __pthread_cleanup_pop_restore
};
#ifdef SHARED
# define ptr_pthread_functions &__pthread_functions
@@ -457,12 +453,19 @@ static void pthread_initialize(void)
setrlimit(RLIMIT_STACK, &limit);
}
#else
- /* For non-MMU assume __pthread_initial_thread_tos at upper page boundary, and
- * __pthread_initial_thread_bos at address 0. These bounds are refined as we
- * malloc other stack frames such that they don't overlap. -StS
+ /* For non-MMU, the initial thread stack can reside anywhere in memory.
+ * We don't have a way of knowing where the kernel started things -- top
+ * or bottom (well, that isn't exactly true, but the solution is fairly
+ * complex and error prone). All we can determine here is an address
+ * that lies within that stack. Save that address as a reference so that
+ * as other thread stacks are created, we can adjust the estimated bounds
+ * of the initial thread's stack appropriately.
+ *
+ * This checking is handled in NOMMU_INITIAL_THREAD_BOUNDS(), so see that
+ * for a few more details.
*/
- __pthread_initial_thread_tos =
- (char *)(((long)CURRENT_STACK_FRAME + getpagesize()) & ~(getpagesize() - 1));
+ __pthread_initial_thread_mid = CURRENT_STACK_FRAME;
+ __pthread_initial_thread_tos = (char *) -1;
__pthread_initial_thread_bos = (char *) 1; /* set it non-zero so we know we have been here */
PDEBUG("initial thread stack bounds: bos=%p, tos=%p\n",
__pthread_initial_thread_bos, __pthread_initial_thread_tos);
@@ -471,22 +474,19 @@ static void pthread_initialize(void)
/* Setup signal handlers for the initial thread.
Since signal handlers are shared between threads, these settings
will be inherited by all other threads. */
+ memset(&sa, 0, sizeof(sa));
sa.sa_handler = pthread_handle_sigrestart;
- sigemptyset(&sa.sa_mask);
- sa.sa_flags = 0;
__libc_sigaction(__pthread_sig_restart, &sa, NULL);
sa.sa_handler = pthread_handle_sigcancel;
sigaddset(&sa.sa_mask, __pthread_sig_restart);
- // sa.sa_flags = 0;
__libc_sigaction(__pthread_sig_cancel, &sa, NULL);
if (__pthread_sig_debug > 0) {
sa.sa_handler = pthread_handle_sigdebug;
- sigemptyset(&sa.sa_mask);
- // sa.sa_flags = 0;
+ __sigemptyset(&sa.sa_mask);
__libc_sigaction(__pthread_sig_debug, &sa, NULL);
}
/* Initially, block __pthread_sig_restart. Will be unblocked on demand. */
- sigemptyset(&mask);
+ __sigemptyset(&mask);
sigaddset(&mask, __pthread_sig_restart);
sigprocmask(SIG_BLOCK, &mask, NULL);
/* And unblock __pthread_sig_cancel if it has been blocked. */
@@ -526,11 +526,11 @@ int __pthread_initialize_manager(void)
/* On non-MMU systems we make sure that the initial thread bounds don't overlap
* with the manager stack frame */
NOMMU_INITIAL_THREAD_BOUNDS(__pthread_manager_thread_tos,__pthread_manager_thread_bos);
- PDEBUG("manager stack: size=%d, bos=%p, tos=%p\n", THREAD_MANAGER_STACK_SIZE,
+ PDEBUG("manager stack: size=%ld, bos=%p, tos=%p\n", THREAD_MANAGER_STACK_SIZE,
__pthread_manager_thread_bos, __pthread_manager_thread_tos);
#if 0
PDEBUG("initial stack: estimate bos=%p, tos=%p\n",
- __pthread_initial_thread_bos, __pthread_initial_thread_tos);
+ __pthread_initial_thread_bos, __pthread_initial_thread_tos);
#endif
/* Setup pipe to communicate with thread manager */
@@ -540,7 +540,7 @@ int __pthread_initialize_manager(void)
}
/* Start the thread manager */
pid = 0;
-#ifdef USE_TLS
+#if defined(USE_TLS) && USE_TLS
if (__linuxthreads_initial_report_events != 0)
THREAD_SETMEM (((pthread_descr) NULL), p_report_events,
__linuxthreads_initial_report_events);
@@ -613,8 +613,8 @@ int __pthread_initialize_manager(void)
}
if (pid == -1) {
free(__pthread_manager_thread_bos);
- __libc_close(manager_pipe[0]);
- __libc_close(manager_pipe[1]);
+ close(manager_pipe[0]);
+ close(manager_pipe[1]);
return -1;
}
__pthread_manager_request = manager_pipe[1]; /* writing end */
@@ -633,7 +633,7 @@ int __pthread_initialize_manager(void)
/* Synchronize debugging of the thread manager */
PDEBUG("send REQ_DEBUG to manager thread\n");
request.req_kind = REQ_DEBUG;
- TEMP_FAILURE_RETRY(__libc_write(__pthread_manager_request,
+ TEMP_FAILURE_RETRY(write(__pthread_manager_request,
(char *) &request, sizeof(request)));
return 0;
}
@@ -653,10 +653,9 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
request.req_args.create.attr = attr;
request.req_args.create.fn = start_routine;
request.req_args.create.arg = arg;
- sigprocmask(SIG_SETMASK, (const sigset_t *) NULL,
- &request.req_args.create.mask);
+ sigprocmask(SIG_SETMASK, NULL, &request.req_args.create.mask);
PDEBUG("write REQ_CREATE to manager thread\n");
- TEMP_FAILURE_RETRY(__libc_write(__pthread_manager_request,
+ TEMP_FAILURE_RETRY(write(__pthread_manager_request,
(char *) &request, sizeof(request)));
PDEBUG("before suspend(self)\n");
suspend(self);
@@ -714,7 +713,7 @@ static pthread_descr thread_self_stack(void)
if (sp >= __pthread_manager_thread_bos && sp < __pthread_manager_thread_tos)
return manager_thread;
h = __pthread_handles + 2;
-# ifdef USE_TLS
+# if defined(USE_TLS) && USE_TLS
while (h->h_descr == NULL
|| ! (sp <= (char *) h->h_descr->p_stackaddr && sp >= h->h_bottom))
h++;
@@ -785,7 +784,7 @@ static void pthread_onexit_process(int retcode, void *arg attribute_unused)
request.req_thread = self;
request.req_kind = REQ_PROCESS_EXIT;
request.req_args.exit.code = retcode;
- TEMP_FAILURE_RETRY(__libc_write(__pthread_manager_request,
+ TEMP_FAILURE_RETRY(write(__pthread_manager_request,
(char *) &request, sizeof(request)));
suspend(self);
/* Main thread should accumulate times for thread manager and its
@@ -849,7 +848,7 @@ static void pthread_handle_sigcancel(int sig)
/* Main thread should accumulate times for thread manager and its
children, so that timings for main thread account for all threads. */
if (self == __pthread_main_thread) {
-#ifdef USE_TLS
+#if defined(USE_TLS) && USE_TLS
waitpid(__pthread_manager_thread->p_pid, NULL, __WCLONE);
#else
waitpid(__pthread_manager_thread.p_pid, NULL, __WCLONE);
@@ -899,8 +898,8 @@ void __pthread_reset_main_thread(void)
free(__pthread_manager_thread_bos);
__pthread_manager_thread_bos = __pthread_manager_thread_tos = NULL;
/* Close the two ends of the pipe */
- __libc_close(__pthread_manager_request);
- __libc_close(__pthread_manager_reader);
+ close(__pthread_manager_request);
+ close(__pthread_manager_reader);
__pthread_manager_request = __pthread_manager_reader = -1;
}
@@ -928,9 +927,9 @@ void __pthread_kill_other_threads_np(void)
/* Reset the signal handlers behaviour for the signals the
implementation uses since this would be passed to the new
process. */
- sigemptyset(&sa.sa_mask);
- sa.sa_flags = 0;
- sa.sa_handler = SIG_DFL;
+ memset(&sa, 0, sizeof(sa));
+ if (SIG_DFL) /* if it's constant zero, it's already done */
+ sa.sa_handler = SIG_DFL;
__libc_sigaction(__pthread_sig_restart, &sa, NULL);
__libc_sigaction(__pthread_sig_cancel, &sa, NULL);
if (__pthread_sig_debug > 0)
@@ -1007,7 +1006,7 @@ __pthread_timedsuspend_old(pthread_descr self, const struct timespec *abstime)
THREAD_SETMEM(self, p_signal_jmp, &jmpbuf);
THREAD_SETMEM(self, p_signal, 0);
/* Unblock the restart signal */
- sigemptyset(&unblock);
+ __sigemptyset(&unblock);
sigaddset(&unblock, __pthread_sig_restart);
sigprocmask(SIG_UNBLOCK, &unblock, &initial_mask);
@@ -1026,7 +1025,7 @@ __pthread_timedsuspend_old(pthread_descr self, const struct timespec *abstime)
/* Sleep for the required duration. If woken by a signal,
resume waiting as required by Single Unix Specification. */
- if (reltime.tv_sec < 0 || __libc_nanosleep(&reltime, NULL) == 0)
+ if (reltime.tv_sec < 0 || nanosleep(&reltime, NULL) == 0)
break;
}
@@ -1092,7 +1091,7 @@ int __pthread_timedsuspend_new(pthread_descr self, const struct timespec *abstim
THREAD_SETMEM(self, p_signal_jmp, &jmpbuf);
THREAD_SETMEM(self, p_signal, 0);
/* Unblock the restart signal */
- sigemptyset(&unblock);
+ __sigemptyset(&unblock);
sigaddset(&unblock, __pthread_sig_restart);
sigprocmask(SIG_UNBLOCK, &unblock, &initial_mask);
@@ -1111,7 +1110,7 @@ int __pthread_timedsuspend_new(pthread_descr self, const struct timespec *abstim
/* Sleep for the required duration. If woken by a signal,
resume waiting as required by Single Unix Specification. */
- if (reltime.tv_sec < 0 || __libc_nanosleep(&reltime, NULL) == 0)
+ if (reltime.tv_sec < 0 || nanosleep(&reltime, NULL) == 0)
break;
}
@@ -1151,16 +1150,16 @@ void __pthread_message(char * fmt, ...)
va_start(args, fmt);
vsnprintf(buffer + 8, sizeof(buffer) - 8, fmt, args);
va_end(args);
- TEMP_FAILURE_RETRY(__libc_write(2, buffer, strlen(buffer)));
+ TEMP_FAILURE_RETRY(write(2, buffer, strlen(buffer)));
}
#endif
#ifndef __PIC__
-/* We need a hook to force the cancelation wrappers to be linked in when
+/* We need a hook to force the cancellation wrappers to be linked in when
static libpthread is used. */
-extern const int __pthread_provide_wrappers;
-static const int *const __pthread_require_wrappers =
+extern const char __pthread_provide_wrappers;
+static const char *const __pthread_require_wrappers =
&__pthread_provide_wrappers;
#endif
diff --git a/libpthread/linuxthreads.old/ptlongjmp.c b/libpthread/linuxthreads.old/ptlongjmp.c
index b3ff2746f..5cb708944 100644
--- a/libpthread/linuxthreads.old/ptlongjmp.c
+++ b/libpthread/linuxthreads.old/ptlongjmp.c
@@ -19,11 +19,7 @@
#include "pthread.h"
#include "internals.h"
#include <bits/stackinfo.h>
-
-/* These functions are not declared anywhere since they shouldn't be
- used at another place but here. */
-extern __typeof(siglongjmp) __libc_siglongjmp attribute_noreturn;
-extern __typeof(longjmp) __libc_longjmp attribute_noreturn;
+#include <jmpbuf-unwind.h>
static void pthread_cleanup_upto(__jmp_buf target)
{
@@ -35,13 +31,13 @@ static void pthread_cleanup_upto(__jmp_buf target)
c != NULL && _JMPBUF_UNWINDS(target, c);
c = c->__prev)
{
-#if _STACK_GROWS_DOWN
+#ifdef _STACK_GROWS_DOWN
if ((char *) c <= currentframe)
{
c = NULL;
break;
}
-#elif _STACK_GROWS_UP
+#elif defined _STACK_GROWS_UP
if ((char *) c >= currentframe)
{
c = NULL;
@@ -58,13 +54,13 @@ static void pthread_cleanup_upto(__jmp_buf target)
THREAD_SETMEM(self, p_in_sighandler, NULL);
}
-void attribute_noreturn siglongjmp(sigjmp_buf env, int val)
+void siglongjmp(sigjmp_buf env, int val)
{
pthread_cleanup_upto(env->__jmpbuf);
__libc_siglongjmp(env, val);
}
-void attribute_noreturn longjmp(jmp_buf env, int val)
+void longjmp(jmp_buf env, int val)
{
pthread_cleanup_upto(env->__jmpbuf);
__libc_longjmp(env, val);
diff --git a/libpthread/linuxthreads.old/rwlock.c b/libpthread/linuxthreads.old/rwlock.c
index eaf71e77c..3ab940261 100644
--- a/libpthread/linuxthreads.old/rwlock.c
+++ b/libpthread/linuxthreads.old/rwlock.c
@@ -16,8 +16,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 <errno.h>
#include <pthread.h>
diff --git a/libpthread/linuxthreads.old/semaphore.c b/libpthread/linuxthreads.old/semaphore.c
index 7502b6e78..9025dfee6 100644
--- a/libpthread/linuxthreads.old/semaphore.c
+++ b/libpthread/linuxthreads.old/semaphore.c
@@ -15,6 +15,7 @@
/* Semaphores a la POSIX 1003.1b */
#include <features.h>
+#include <limits.h>
#include <errno.h>
#include "pthread.h"
#include "semaphore.h"
@@ -23,8 +24,7 @@
#include "restart.h"
#include "queue.h"
-int __new_sem_init(sem_t *sem, int pshared, unsigned int value);
-int __new_sem_init(sem_t *sem, int pshared, unsigned int value)
+int sem_init(sem_t *sem, int pshared, unsigned int value)
{
if (value > SEM_VALUE_MAX) {
errno = EINVAL;
@@ -41,7 +41,7 @@ int __new_sem_init(sem_t *sem, int pshared, unsigned int value)
}
/* Function called by pthread_cancel to remove the thread from
- waiting inside __new_sem_wait. */
+ waiting inside sem_wait. */
static int new_sem_extricate_func(void *obj, pthread_descr th)
{
@@ -56,8 +56,7 @@ static int new_sem_extricate_func(void *obj, pthread_descr th)
return did_remove;
}
-int __new_sem_wait(sem_t * sem);
-int __new_sem_wait(sem_t * sem)
+int sem_wait(sem_t * sem)
{
volatile pthread_descr self = thread_self();
pthread_extricate_if extr;
@@ -119,8 +118,7 @@ int __new_sem_wait(sem_t * sem)
return 0;
}
-int __new_sem_trywait(sem_t * sem);
-int __new_sem_trywait(sem_t * sem)
+int sem_trywait(sem_t * sem)
{
int retval;
@@ -136,8 +134,7 @@ int __new_sem_trywait(sem_t * sem)
return retval;
}
-int __new_sem_post(sem_t * sem);
-int __new_sem_post(sem_t * sem)
+int sem_post(sem_t * sem)
{
pthread_descr self = thread_self();
pthread_descr th;
@@ -172,21 +169,19 @@ int __new_sem_post(sem_t * sem)
}
request.req_kind = REQ_POST;
request.req_args.post = sem;
- TEMP_FAILURE_RETRY(__libc_write(__pthread_manager_request,
+ TEMP_FAILURE_RETRY(write(__pthread_manager_request,
(char *) &request, sizeof(request)));
}
return 0;
}
-int __new_sem_getvalue(sem_t * sem, int * sval);
-int __new_sem_getvalue(sem_t * sem, int * sval)
+int sem_getvalue(sem_t * sem, int * sval)
{
*sval = sem->__sem_value;
return 0;
}
-int __new_sem_destroy(sem_t * sem);
-int __new_sem_destroy(sem_t * sem)
+int sem_destroy(sem_t * sem)
{
if (sem->__sem_waiting != NULL) {
__set_errno (EBUSY);
@@ -302,12 +297,3 @@ int sem_timedwait(sem_t *sem, const struct timespec *abstime)
/* We got the semaphore */
return 0;
}
-
-
-weak_alias (__new_sem_init, sem_init)
-weak_alias (__new_sem_wait, sem_wait)
-weak_alias (__new_sem_trywait, sem_trywait)
-weak_alias (__new_sem_post, sem_post)
-weak_alias (__new_sem_getvalue, sem_getvalue)
-weak_alias (__new_sem_destroy, sem_destroy)
-
diff --git a/libpthread/linuxthreads.old/semaphore.h b/libpthread/linuxthreads.old/semaphore.h
index fac2e5937..3924a471d 100644
--- a/libpthread/linuxthreads.old/semaphore.h
+++ b/libpthread/linuxthreads.old/semaphore.h
@@ -17,6 +17,7 @@
#include <features.h>
#include <sys/types.h>
+#include <limits.h>
#ifdef __USE_XOPEN2K
# define __need_timespec
# include <time.h>
@@ -42,7 +43,9 @@ typedef struct
#define SEM_FAILED ((sem_t *) 0)
/* Maximum value the semaphore can have. */
-#define SEM_VALUE_MAX ((int) ((~0u) >> 1))
+#ifndef SEM_VALUE_MAX
+#define SEM_VALUE_MAX ((int) ((~0u) >> 1))
+#endif
__BEGIN_DECLS
@@ -55,13 +58,13 @@ extern int sem_init (sem_t *__sem, int __pshared, unsigned int __value) __THROW;
extern int sem_destroy (sem_t *__sem) __THROW;
/* Open a named semaphore NAME with open flags OFLAG. */
-extern sem_t *sem_open (__const char *__name, int __oflag, ...) __THROW;
+extern sem_t *sem_open (const char *__name, int __oflag, ...) __THROW;
/* Close descriptor for named semaphore SEM. */
extern int sem_close (sem_t *__sem) __THROW;
/* Remove named semaphore NAME. */
-extern int sem_unlink (__const char *__name) __THROW;
+extern int sem_unlink (const char *__name) __THROW;
/* Wait for SEM being posted.
@@ -75,14 +78,14 @@ extern int sem_wait (sem_t *__sem);
This function is a cancellation point and therefore not marked with
__THROW. */
extern int sem_timedwait (sem_t *__restrict __sem,
- __const struct timespec *__restrict __abstime);
+ const struct timespec *__restrict __abstime);
#endif
/* Test whether SEM is posted. */
-extern int sem_trywait (sem_t *__sem) __THROW;
+extern int sem_trywait (sem_t *__sem) __THROWNL;
/* Post SEM. */
-extern int sem_post (sem_t *__sem) __THROW;
+extern int sem_post (sem_t *__sem) __THROWNL;
/* Get current value of SEM and store it in *SVAL. */
extern int sem_getvalue (sem_t *__restrict __sem, int *__restrict __sval)
diff --git a/libpthread/linuxthreads.old/signals.c b/libpthread/linuxthreads.old/signals.c
index 23ba9778f..d8dbc78bd 100644
--- a/libpthread/linuxthreads.old/signals.c
+++ b/libpthread/linuxthreads.old/signals.c
@@ -20,12 +20,8 @@
#include "pthread.h"
#include "internals.h"
#include "spinlock.h"
-#include <ucontext.h>
#include <bits/sigcontextinfo.h>
-/* mods for uClibc: __libc_sigaction is not in any standard headers */
-extern __typeof(sigaction) __libc_sigaction;
-
int pthread_sigmask(int how, const sigset_t * newmask, sigset_t * oldmask)
{
sigset_t mask;
@@ -196,7 +192,7 @@ int sigwait(const sigset_t * set, int * sig)
and if not, install our dummy handler. This is conformant to
POSIX: "The effect of sigwait() on the signal actions for the
signals in set is unspecified." */
- sigfillset(&mask);
+ __sigfillset(&mask);
sigdelset(&mask, __pthread_sig_cancel);
for (s = 1; s <= NSIG; s++) {
if (sigismember(set, s) &&
@@ -207,9 +203,8 @@ int sigwait(const sigset_t * set, int * sig)
if (sighandler[s].old == NULL ||
sighandler[s].old == (arch_sighandler_t) SIG_DFL ||
sighandler[s].old == (arch_sighandler_t) SIG_IGN) {
+ memset(&sa, 0, sizeof(sa));
sa.sa_handler = pthread_null_sighandler;
- sigemptyset(&sa.sa_mask);
- sa.sa_flags = 0;
sigaction(s, &sa, NULL);
}
}
diff --git a/libpthread/linuxthreads.old/specific.c b/libpthread/linuxthreads.old/specific.c
index dd86148d8..c4bcfbf8c 100644
--- a/libpthread/linuxthreads.old/specific.c
+++ b/libpthread/linuxthreads.old/specific.c
@@ -167,7 +167,7 @@ void __pthread_destroy_specifics(void)
__pthread_unlock(THREAD_GETMEM(self, p_lock));
}
-#if !(USE_TLS && HAVE___THREAD)
+#if !defined __UCLIBC_HAS_TLS__ && defined __UCLIBC_HAS_RPC__
/* Thread-specific data for libc. */
diff --git a/libpthread/linuxthreads.old/spinlock.c b/libpthread/linuxthreads.old/spinlock.c
index 24c81d47e..80aeda529 100644
--- a/libpthread/linuxthreads.old/spinlock.c
+++ b/libpthread/linuxthreads.old/spinlock.c
@@ -14,8 +14,6 @@
/* Internal locks */
-#define __FORCE_GLIBC
-#include <features.h>
#include <errno.h>
#include <sched.h>
#include <time.h>
@@ -67,7 +65,6 @@ void internal_function __pthread_lock(struct _pthread_fastlock * lock,
#if defined HAS_COMPARE_AND_SWAP
long oldstatus, newstatus;
int successful_seizure, spurious_wakeup_count;
- int spin_count;
#endif
#if defined TEST_FOR_COMPARE_AND_SWAP
@@ -87,11 +84,11 @@ void internal_function __pthread_lock(struct _pthread_fastlock * lock,
return;
spurious_wakeup_count = 0;
- spin_count = 0;
/* On SMP, try spinning to get the lock. */
#if 0
if (__pthread_smp_kernel) {
+ int spin_count;
int max_count = lock->__spinlock * 2 + 10;
if (max_count > MAX_ADAPTIVE_SPIN_COUNT)
diff --git a/libpthread/linuxthreads.old/sysdeps/alpha/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/alpha/pt-machine.h
index 97c38394b..b47343ba7 100644
--- a/libpthread/linuxthreads.old/sysdeps/alpha/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/alpha/pt-machine.h
@@ -17,8 +17,7 @@
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. */
+ see <http://www.gnu.org/licenses/>. */
#ifndef _PT_MACHINE_H
#define _PT_MACHINE_H 1
diff --git a/libpthread/linuxthreads.old/sysdeps/arc/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/arc/pt-machine.h
new file mode 100644
index 000000000..8df1e77e3
--- /dev/null
+++ b/libpthread/linuxthreads.old/sysdeps/arc/pt-machine.h
@@ -0,0 +1,42 @@
+/*
+ * 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 _PT_MACHINE_H
+#define _PT_MACHINE_H 1
+#include <features.h>
+
+#ifndef PT_EI
+# define PT_EI __extern_always_inline
+#endif
+
+extern long int testandset (int *spinlock);
+extern int __compare_and_swap (long int *p, long int oldval, long int newval);
+
+PT_EI long int
+testandset (int *spinlock)
+{
+ unsigned int old = 1;
+
+ /* Atomically exchange @spinlock with 1 */
+ __asm__ __volatile__(
+ "ex %0, [%1]"
+ : "+r" (old)
+ : "r" (spinlock)
+ : "memory");
+
+ return old;
+
+}
+
+/* Get some notion of the current stack. Need not be exactly the top
+ of the stack, just something somewhere in the current frame.
+ I don't trust register variables, so let's do this the safe way. */
+#define CURRENT_STACK_FRAME \
+__extension__ ({ char *__sp; __asm__ ("mov %0,sp" : "=r" (__sp)); __sp; })
+
+#else
+#error PT_MACHINE already defined
+#endif /* pt-machine.h */
diff --git a/libpthread/linuxthreads.old/sysdeps/arm/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/arm/pt-machine.h
index 14eb6f6da..2b877f980 100644
--- a/libpthread/linuxthreads.old/sysdeps/arm/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/arm/pt-machine.h
@@ -15,22 +15,40 @@
Lesser General 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 _PT_MACHINE_H
#define _PT_MACHINE_H 1
-#include <features.h>
+#include <sys/syscall.h>
+#include <unistd.h>
#ifndef PT_EI
# define PT_EI __extern_always_inline
#endif
-/* This will not work on ARM1 or ARM2 because SWP is lacking on those
- machines. Unfortunately we have no way to detect this at compile
- time; let's hope nobody tries to use one. */
+#if defined(__thumb__)
+#if defined(__USE_LDREXSTREX__)
+PT_EI long int ldrex(int *spinlock)
+{
+ long int ret;
+ __asm__ __volatile__(
+ "ldrex %0, [%1]\n"
+ : "=r"(ret)
+ : "r"(spinlock) : "memory");
+ return ret;
+}
+
+PT_EI long int strex(int val, int *spinlock)
+{
+ long int ret;
+ __asm__ __volatile__(
+ "strex %0, %1, [%2]\n"
+ : "=r"(ret)
+ : "r" (val), "r"(spinlock) : "memory");
+ return ret;
+}
/* Spinlock implementation; required. */
PT_EI long int
@@ -38,7 +56,24 @@ testandset (int *spinlock)
{
register unsigned int ret;
-#if defined(__thumb__)
+ do {
+ ret = ldrex(spinlock);
+ } while (strex(1, spinlock));
+
+ return ret;
+}
+
+#else /* __USE_LDREXSTREX__ */
+
+/* This will not work on ARM1 or ARM2 because SWP is lacking on those
+ machines. Unfortunately we have no way to detect this at compile
+ time; let's hope nobody tries to use one. */
+
+/* Spinlock implementation; required. */
+PT_EI long int testandset (int *spinlock);
+PT_EI long int testandset (int *spinlock)
+{
+ register unsigned int ret;
void *pc;
__asm__ __volatile__(
".align 0\n"
@@ -51,15 +86,21 @@ testandset (int *spinlock)
"\t.force_thumb"
: "=r"(ret), "=r"(pc)
: "0"(1), "r"(spinlock));
-#else
+ return ret;
+}
+#endif
+#else /* __thumb__ */
+
+PT_EI long int testandset (int *spinlock);
+PT_EI long int testandset (int *spinlock)
+{
+ register unsigned int ret;
__asm__ __volatile__("swp %0, %1, [%2]"
: "=r"(ret)
: "0"(1), "r"(spinlock));
-#endif
-
return ret;
}
-
+#endif
/* Get some notion of the current stack. Need not be exactly the top
of the stack, just something somewhere in the current frame. */
diff --git a/libpthread/linuxthreads.old/sysdeps/avr32/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/avr32/pt-machine.h
index cd45d5faf..5735d0ea2 100644
--- a/libpthread/linuxthreads.old/sysdeps/avr32/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/avr32/pt-machine.h
@@ -15,7 +15,7 @@
# define PT_EI __extern_always_inline
#endif
-static inline int
+static __inline__ int
_test_and_set (int *p, int v)
{
int result;
diff --git a/libpthread/linuxthreads.old/sysdeps/bfin/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/bfin/pt-machine.h
index e81ecffbe..912d64b2c 100644
--- a/libpthread/linuxthreads.old/sysdeps/bfin/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/bfin/pt-machine.h
@@ -15,8 +15,7 @@
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. */
+ not, see <http://www.gnu.org/licenses/>. */
#ifndef _PT_MACHINE_H
#define _PT_MACHINE_H 1
diff --git a/libpthread/linuxthreads.old/sysdeps/c6x/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/c6x/pt-machine.h
new file mode 100644
index 000000000..5e8bfca56
--- /dev/null
+++ b/libpthread/linuxthreads.old/sysdeps/c6x/pt-machine.h
@@ -0,0 +1,63 @@
+/* Machine-dependent pthreads configuration and inline functions.
+ C6x version.
+ Copyright (C) 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Aurelien Jacquiot <aurelien.jacquiot@jaluna.com>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef _PT_MACHINE_H
+#define _PT_MACHINE_H 1
+
+#ifndef PT_EI
+# define PT_EI extern inline
+#endif
+
+extern int __compare_and_swap (long int *p, long int oldval, long int newval);
+
+/* Spinlock implementation; required. */
+static inline long int
+testandset (int *spinlock)
+{
+ register unsigned int ret = 1;
+ int dummy;
+ __asm__ __volatile__ ("mvc .s2 CSR, %0\n\tand .s2 -2, %0, %0\n\tmvc .s2 %0, CSR\n"
+ : "=b" (dummy));
+
+ if (*spinlock == 0) {
+ *spinlock = 1;
+ ret = 0;
+ }
+ __asm__ __volatile__ ("mvc .s2 CSR, %0\n\tor .s2 1, %0, %0\n\tmvc .s2 %0, CSR\n"
+ : "=b" (dummy));
+ return ret;
+}
+
+#define WRITE_MEMORY_BARRIER()
+#define READ_MEMORY_BARRIER()
+
+/* Get some notion of the current stack. Need not be exactly the top
+ of the stack, just something somewhere in the current frame. */
+#define CURRENT_STACK_FRAME get_stack_pointer()
+static inline char * get_stack_pointer(void)
+{
+ char *sp;
+ __asm__ __volatile__ ("mv .d2 B15, %0" : "=b" (sp));
+ return sp;
+}
+
+#define THREAD_STACK_OFFSET 8
+
+#endif /* pt-machine.h */
diff --git a/libpthread/linuxthreads.old/sysdeps/cris/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/cris/pt-machine.h
index 6d626fb4b..a89579ee0 100644
--- a/libpthread/linuxthreads.old/sysdeps/cris/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/cris/pt-machine.h
@@ -15,8 +15,7 @@
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. */
+ see <http://www.gnu.org/licenses/>. */
#ifndef _PT_MACHINE_H
#define _PT_MACHINE_H 1
diff --git a/libpthread/linuxthreads.old/sysdeps/frv/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/frv/pt-machine.h
index 9c9d0d76a..6f867ade7 100644
--- a/libpthread/linuxthreads.old/sysdeps/frv/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/frv/pt-machine.h
@@ -16,8 +16,7 @@
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. */
+ not, see <http://www.gnu.org/licenses/>. */
#ifndef _PT_MACHINE_H
#define _PT_MACHINE_H 1
diff --git a/libpthread/linuxthreads.old/sysdeps/h8300/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/h8300/pt-machine.h
index 121f496d7..a37384de9 100644
--- a/libpthread/linuxthreads.old/sysdeps/h8300/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/h8300/pt-machine.h
@@ -16,8 +16,7 @@
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. */
+ not, see <http://www.gnu.org/licenses/>. */
#ifndef _PT_MACHINE_H
#define _PT_MACHINE_H 1
diff --git a/libpthread/linuxthreads/sysdeps/sparc/sparc32/pspinlock.c b/libpthread/linuxthreads.old/sysdeps/hppa/pspinlock.c
index 812c7ff2a..1a6aa64a9 100644
--- a/libpthread/linuxthreads/sysdeps/sparc/sparc32/pspinlock.c
+++ b/libpthread/linuxthreads.old/sysdeps/hppa/pspinlock.c
@@ -1,4 +1,4 @@
-/* POSIX spinlock implementation. SPARC32 version.
+/* POSIX spinlock implementation. hppa version.
Copyright (C) 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -13,32 +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; 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/>. */
#include <errno.h>
#include <pthread.h>
#include "internals.h"
-/* This implementation is similar to the one used in the Linux kernel. */
int
__pthread_spin_lock (pthread_spinlock_t *lock)
{
- __asm__ __volatile__
- ("1: ldstub [%0], %%g2\n"
- " orcc %%g2, 0x0, %%g0\n"
- " bne,a 2f\n"
- " ldub [%0], %%g2\n"
- ".subsection 2\n"
- "2: orcc %%g2, 0x0, %%g0\n"
- " bne,a 2b\n"
- " ldub [%0], %%g2\n"
- " b,a 1b\n"
- ".previous"
- : /* no outputs */
- : "r" (lock)
- : "g2", "memory", "cc");
+ unsigned int val;
+
+ do
+ __asm__ __volatile__ ("ldcw %1,%0"
+ : "=r" (val), "=m" (*lock)
+ : "m" (*lock));
+ while (!val);
+
return 0;
}
weak_alias (__pthread_spin_lock, pthread_spin_lock)
@@ -47,13 +39,13 @@ weak_alias (__pthread_spin_lock, pthread_spin_lock)
int
__pthread_spin_trylock (pthread_spinlock_t *lock)
{
- int result;
- __asm__ __volatile__
- ("ldstub [%1], %0"
- : "=r" (result)
- : "r" (lock)
- : "memory");
- return result == 0 ? 0 : EBUSY;
+ unsigned int val;
+
+ __asm__ __volatile__ ("ldcw %1,%0"
+ : "=r" (val), "=m" (*lock)
+ : "m" (*lock));
+
+ return val ? 0 : EBUSY;
}
weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
@@ -61,7 +53,7 @@ weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
int
__pthread_spin_unlock (pthread_spinlock_t *lock)
{
- *lock = 0;
+ *lock = 1;
return 0;
}
weak_alias (__pthread_spin_unlock, pthread_spin_unlock)
@@ -73,7 +65,7 @@ __pthread_spin_init (pthread_spinlock_t *lock, int pshared)
/* We can ignore the `pshared' parameter. Since we are busy-waiting
all processes which can access the memory location `lock' points
to can use the spinlock. */
- *lock = 0;
+ *lock = 1;
return 0;
}
weak_alias (__pthread_spin_init, pthread_spin_init)
diff --git a/libpthread/linuxthreads.old/sysdeps/hppa/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/hppa/pt-machine.h
new file mode 100644
index 000000000..85c453c77
--- /dev/null
+++ b/libpthread/linuxthreads.old/sysdeps/hppa/pt-machine.h
@@ -0,0 +1,59 @@
+/* Machine-dependent pthreads configuration and inline functions.
+ hppa version.
+ Copyright (C) 2000, 2002, 2003 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; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef _PT_MACHINE_H
+#define _PT_MACHINE_H 1
+
+#include <features.h>
+#include <bits/initspin.h>
+
+#ifndef PT_EI
+# define PT_EI __extern_always_inline
+#endif
+
+/* Get some notion of the current stack. Need not be exactly the top
+ of the stack, just something somewhere in the current frame. */
+#define CURRENT_STACK_FRAME stack_pointer
+register char * stack_pointer __asm__ ("%r30");
+
+
+/* The hppa only has one atomic read and modify memory operation,
+ load and clear, so hppa spinlocks must use zero to signify that
+ someone is holding the lock. */
+
+#define xstr(s) str(s)
+#define str(s) #s
+/* Spinlock implementation; required. */
+PT_EI long int
+testandset (int *spinlock)
+{
+ int ret;
+
+ __asm__ __volatile__(
+ "ldcw 0(%2),%0"
+ : "=r"(ret), "=m"(*spinlock)
+ : "r"(spinlock));
+
+ return ret == 0;
+}
+#undef str
+#undef xstr
+
+#endif /* pt-machine.h */
diff --git a/libpthread/linuxthreads.old/sysdeps/i386/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/i386/pt-machine.h
index a6256c58f..24c5e6c7c 100644
--- a/libpthread/linuxthreads.old/sysdeps/i386/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/i386/pt-machine.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; 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 _PT_MACHINE_H
#define _PT_MACHINE_H 1
diff --git a/libpthread/linuxthreads.old/sysdeps/i386/tls.h b/libpthread/linuxthreads.old/sysdeps/i386/tls.h
index 8534cab80..4469f0776 100644
--- a/libpthread/linuxthreads.old/sysdeps/i386/tls.h
+++ b/libpthread/linuxthreads.old/sysdeps/i386/tls.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 _TLS_H
#define _TLS_H
diff --git a/libpthread/linuxthreads.old/sysdeps/i386/useldt.h b/libpthread/linuxthreads.old/sysdeps/i386/useldt.h
index ca5677cc9..02326729a 100644
--- a/libpthread/linuxthreads.old/sysdeps/i386/useldt.h
+++ b/libpthread/linuxthreads.old/sysdeps/i386/useldt.h
@@ -16,8 +16,7 @@
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. */
+ see <http://www.gnu.org/licenses/>. */
#ifndef __ASSEMBLER__
#include <stddef.h> /* For offsetof. */
diff --git a/libpthread/linuxthreads.old/sysdeps/ia64/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/ia64/pt-machine.h
index 668057a2a..f4c6be989 100644
--- a/libpthread/linuxthreads.old/sysdeps/ia64/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/ia64/pt-machine.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; 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 _PT_MACHINE_H
#define _PT_MACHINE_H 1
diff --git a/libpthread/linuxthreads.old/sysdeps/ia64/tls.h b/libpthread/linuxthreads.old/sysdeps/ia64/tls.h
index 81b41eb73..a78f0ec7a 100644
--- a/libpthread/linuxthreads.old/sysdeps/ia64/tls.h
+++ b/libpthread/linuxthreads.old/sysdeps/ia64/tls.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 _TLS_H
#define _TLS_H
diff --git a/libpthread/linuxthreads.old/sysdeps/m68k/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/m68k/pt-machine.h
index 295495baf..3be216524 100644
--- a/libpthread/linuxthreads.old/sysdeps/m68k/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/m68k/pt-machine.h
@@ -16,8 +16,7 @@
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. */
+ not, see <http://www.gnu.org/licenses/>. */
#ifndef _PT_MACHINE_H
#define _PT_MACHINE_H 1
@@ -40,7 +39,7 @@ testandset (int *spinlock)
#else
"bset #7,%1; sne %0"
#endif
- : "=dm"(ret), "=m"(*spinlock)
+ : "=&dm"(ret), "=m"(*spinlock)
: "m"(*spinlock)
: "cc");
diff --git a/libpthread/linuxthreads.old/sysdeps/microblaze/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/microblaze/pt-machine.h
new file mode 100644
index 000000000..e8c03f9e5
--- /dev/null
+++ b/libpthread/linuxthreads.old/sysdeps/microblaze/pt-machine.h
@@ -0,0 +1,106 @@
+/*
+ * sysdeps/microblaze/pt-machine.h -- microblaze-specific pthread definitions
+ *
+ * Copyright (C) 2003 John Williams <jwilliams@itee.uq.edu.au>
+ * 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>
+ */
+
+#ifndef _PT_MACHINE_H
+#define _PT_MACHINE_H 1
+
+#include <features.h>
+
+#ifndef PT_EI
+# define PT_EI extern inline
+#endif
+
+extern long int testandset (int *spinlock);
+extern int __compare_and_swap (long *ptr, long old, long new);
+
+/* Get some notion of the current stack. Need not be exactly the top
+ of the stack, just something somewhere in the current frame. */
+#define CURRENT_STACK_FRAME __stack_pointer
+register char *__stack_pointer __asm__ ("r1");
+
+#define HAS_COMPARE_AND_SWAP
+#define HAS_COMPARE_AND_SWAP_WITH_RELEASE_SEMANTICS
+#define IMPLEMENT_TAS_WITH_CAS
+
+/* Atomically: If *PTR == OLD, set *PTR to NEW and return true,
+ otherwise do nothing and return false. */
+PT_EI int __compare_and_swap (long *ptr, long old, long new)
+{
+ unsigned long psw;
+
+ /* disable interrupts */
+ /* This is ugly ugly ugly! */
+ __asm__ __volatile__ ("mfs %0, rmsr;"
+ "andi r3, %0, ~2;"
+ "mts rmsr, r3;"
+ : "=&r" (psw)
+ :
+ : "r3");
+
+ if (likely (*ptr == old))
+ {
+ *ptr = new;
+ __asm__ __volatile__ ("mts rmsr, %0;" :: "r" (psw)); /* re-enable */
+ return 1;
+ }
+ else
+ {
+ __asm__ __volatile__ ("mts rmsr, %0;" :: "r" (psw)); /* re-enable */
+ return 0;
+ }
+}
+
+/* like above's __compare_and_swap() but it first syncs the memory
+ (This is also the difference between both functions in e.g.
+ ../powerpc/pt-machine.h)
+ Doing this additional sync fixes a hang of __pthread_alt_unlock()
+ (Falk Brettschneider <fbrettschneider@baumeroptronic.de>) */
+PT_EI int
+__compare_and_swap_with_release_semantics (long *p,
+ long oldval, long newval)
+{
+ __asm__ __volatile__ ("" : : : "memory"); /*MEMORY_BARRIER ();*/
+ return __compare_and_swap (p, oldval, newval);
+}
+
+
+#ifndef IMPLEMENT_TAS_WITH_CAS
+/* Spinlock implementation; required. */
+PT_EI long int testandset (int *spinlock)
+{
+ unsigned psw;
+
+ /* disable interrupts */
+ __asm__ __volatile__ ("mfs %0, rmsr;"
+ "andi r3, %0, ~2;"
+ "mts rmsr, r3;"
+ : "=&r" (psw)
+ :
+ : "r3");
+
+ if (*spinlock)
+ {
+ /* Enable ints */
+ __asm__ __volatile__ ("mts rmsr, %0;" :: "r" (psw));
+ return 1;
+ } else {
+ *spinlock=1;
+ /* Enable ints */
+ __asm__ __volatile__ ("mts rmsr, %0;" :: "r" (psw));
+ return 0;
+ }
+}
+
+#endif
+#endif /* pt-machine.h */
diff --git a/libc/sysdeps/linux/v850/bits/sigcontextinfo.h b/libpthread/linuxthreads.old/sysdeps/microblaze/sigcontextinfo.h
index de450ff8a..f5408ad08 100644
--- a/libc/sysdeps/linux/v850/bits/sigcontextinfo.h
+++ b/libpthread/linuxthreads.old/sysdeps/microblaze/sigcontextinfo.h
@@ -1,5 +1,5 @@
/*
- * sysdeps/v850/sigcontextinfo.h -- v850-specific pthread signal definitions
+ * sysdeps/microblaze/sigcontextinfo.h -- microblaze-specific pthread signal definitions
*
* Copyright (C) 2002 NEC Electronics Corporation
* Copyright (C) 2002 Miles Bader <miles@gnu.org>
diff --git a/libpthread/linuxthreads.old/sysdeps/mips/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/mips/pt-machine.h
index fb1cc0e6d..caaf9a7c0 100644
--- a/libpthread/linuxthreads.old/sysdeps/mips/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/mips/pt-machine.h
@@ -18,8 +18,7 @@
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. */
+ not, see <http://www.gnu.org/licenses/>. */
#ifndef _PT_MACHINE_H
#define _PT_MACHINE_H 1
diff --git a/libpthread/linuxthreads.old/sysdeps/nios/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/nios/pt-machine.h
deleted file mode 100644
index 140455013..000000000
--- a/libpthread/linuxthreads.old/sysdeps/nios/pt-machine.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* Machine-dependent pthreads configuration and inline functions.
- ARM version.
- Copyright (C) 1997, 1998 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Philip Blundell <philb@gnu.org>.
-
- 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 _PT_MACHINE_H
-#define _PT_MACHINE_H 1
-
-#include <features.h>
-
-#ifndef PT_EI
-# define PT_EI __extern_always_inline
-#endif
-
-/* Spinlock implementation; required. */
-/* it is weird and dangerous to disable interrupt in userspace, but for nios
- what else we can do before we have a swap like instruction? This is better
- than nothing
- */
-PT_EI long int
-testandset (int *spinlock)
-{
- unsigned int ret;
-
- __asm__ __volatile__("pfx 8\n\t"
- "wrctl %1 ; disable interrupt\n\t"
- "nop\n\t"
- "nop\n\t"
- "ld %0, [%2]\n\t"
- "st [%2], %1\n\t"
- "pfx 9\n\t"
- "wrctl %1 ; enable interrupt\n\t"
- "nop\n\t"
- "nop\n\t"
- : "=&r"(ret)
- : "r"(1), "r"(spinlock)
- : "memory");
-
- return ret;
-}
-
-
-/* Get some notion of the current stack. Need not be exactly the top
- of the stack, just something somewhere in the current frame. */
-#define CURRENT_STACK_FRAME stack_pointer
-register char * stack_pointer __asm__ ("%sp");
-
-/* nios needs more because of reg windows */
-#define THREAD_MANAGER_STACK_SIZE (32*1024)
-#define STACK_SIZE (32*1024)
-
-#endif /* pt-machine.h */
diff --git a/libpthread/linuxthreads.old/sysdeps/nios2/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/nios2/pt-machine.h
index 061fa735e..e3260811b 100644
--- a/libpthread/linuxthreads.old/sysdeps/nios2/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/nios2/pt-machine.h
@@ -15,8 +15,7 @@
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. */
+ not, see <http://www.gnu.org/licenses/>. */
#ifndef _PT_MACHINE_H
#define _PT_MACHINE_H 1
diff --git a/libpthread/linuxthreads.old/sysdeps/sh64/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/or1k/pt-machine.h
index b87448a75..c6c8ee470 100644
--- a/libpthread/linuxthreads.old/sysdeps/sh64/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/or1k/pt-machine.h
@@ -1,23 +1,19 @@
-/* Cloned for uClibc by Paul Mundt, December 2003 */
-/* Modified by SuperH, Inc. September 2003 */
-
/* Machine-dependent pthreads configuration and inline functions.
- SuperH version.
- Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+ OpenRISC version.
+ Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
- Contributed by Niibe Yutaka <gniibe@m17n.org>.
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
+ 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
+ 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. */
@@ -26,14 +22,34 @@
#define _PT_MACHINE_H 1
#include <features.h>
+#include <sys/syscall.h>
#ifndef PT_EI
# define PT_EI __extern_always_inline
#endif
+PT_EI long int testandset(int*);
+
+#define OR1K_ATOMIC_XCHG 1
+
+PT_EI long int
+testandset (int *spinlock)
+{
+ int err;
+ int oldvalue = 1;
+
+ err = INLINE_SYSCALL(or1k_atomic, 3, OR1K_ATOMIC_XCHG, spinlock, &oldvalue);
+
+ return (oldvalue);
+}
+
/* Get some notion of the current stack. Need not be exactly the top
of the stack, just something somewhere in the current frame. */
-#define CURRENT_STACK_FRAME stack_pointer
-register char * stack_pointer __asm__ ("r15");
-
+#define CURRENT_STACK_FRAME stack_pointer()
+static inline char *stack_pointer(void)
+{
+ unsigned long ret;
+ __asm__ __volatile__ ("l.ori %0, r1, 0" : "=r" (ret));
+ return (char *)ret;
+}
#endif /* pt-machine.h */
diff --git a/libpthread/linuxthreads.old/sysdeps/powerpc/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/powerpc/pt-machine.h
index 561f8958e..aa2d206b0 100644
--- a/libpthread/linuxthreads.old/sysdeps/powerpc/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/powerpc/pt-machine.h
@@ -15,8 +15,7 @@
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. */
+ not, see <http://www.gnu.org/licenses/>. */
/* These routines are from Appendix G of the 'PowerPC 601 RISC Microprocessor
User's Manual', by IBM and Motorola. */
diff --git a/libpthread/linuxthreads.old/sysdeps/pthread/bits/libc-lock.h b/libpthread/linuxthreads.old/sysdeps/pthread/bits/libc-lock.h
index 740e793be..8833e343d 100644
--- a/libpthread/linuxthreads.old/sysdeps/pthread/bits/libc-lock.h
+++ b/libpthread/linuxthreads.old/sysdeps/pthread/bits/libc-lock.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; 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_LIBC_LOCK_H
#define _BITS_LIBC_LOCK_H 1
@@ -30,7 +29,7 @@
/* Mutex type. */
#if defined(_LIBC) || defined(_IO_MTSAFE_IO)
typedef pthread_mutex_t __libc_lock_t;
-typedef struct { pthread_mutex_t mutex; } __libc_lock_recursive_t;
+typedef pthread_mutex_t __libc_lock_recursive_t;
# ifdef __USE_UNIX98
typedef pthread_rwlock_t __libc_rwlock_t;
# else
@@ -132,15 +131,39 @@ typedef pthread_key_t __libc_key_t;
#define __libc_rwlock_init(NAME) \
(__libc_maybe_call (__pthread_rwlock_init, (&(NAME), NULL), 0));
+/* Same as last but this time we initialize an adaptive mutex. */
+#if defined _LIBC && !defined NOT_IN_libc && defined SHARED
+#define __libc_lock_init_adaptive(NAME) \
+ ({ \
+ (NAME).__m_count = 0; \
+ (NAME).__m_owner = NULL; \
+ (NAME).__m_kind = PTHREAD_MUTEX_ADAPTIVE_NP; \
+ (NAME).__m_lock.__status = 0; \
+ (NAME).__m_lock.__spinlock = __LT_SPINLOCK_INIT; \
+ 0; })
+#else
+#define __libc_lock_init_adaptive(NAME) \
+ do { \
+ if (__pthread_mutex_init != NULL) \
+ { \
+ pthread_mutexattr_t __attr; \
+ __pthread_mutexattr_init (&__attr); \
+ __pthread_mutexattr_settype (&__attr, PTHREAD_MUTEX_ADAPTIVE_NP); \
+ __pthread_mutex_init (&(NAME), &__attr); \
+ __pthread_mutexattr_destroy (&__attr); \
+ } \
+ } while (0);
+#endif
+
/* Same as last but this time we initialize a recursive mutex. */
#if defined _LIBC && !defined NOT_IN_libc && defined SHARED
#define __libc_lock_init_recursive(NAME) \
({ \
- (NAME).mutex.__m_count = 0; \
- (NAME).mutex.__m_owner = NULL; \
- (NAME).mutex.__m_kind = PTHREAD_MUTEX_RECURSIVE_NP; \
- (NAME).mutex.__m_lock.__status = 0; \
- (NAME).mutex.__m_lock.__spinlock = __LT_SPINLOCK_INIT; \
+ (NAME).__m_count = 0; \
+ (NAME).__m_owner = NULL; \
+ (NAME).__m_kind = PTHREAD_MUTEX_RECURSIVE_NP; \
+ (NAME).__m_lock.__status = 0; \
+ (NAME).__m_lock.__spinlock = __LT_SPINLOCK_INIT; \
0; })
#else
#define __libc_lock_init_recursive(NAME) \
@@ -150,7 +173,7 @@ typedef pthread_key_t __libc_key_t;
pthread_mutexattr_t __attr; \
__pthread_mutexattr_init (&__attr); \
__pthread_mutexattr_settype (&__attr, PTHREAD_MUTEX_RECURSIVE_NP); \
- __pthread_mutex_init (&(NAME).mutex, &__attr); \
+ __pthread_mutex_init (&(NAME), &__attr); \
__pthread_mutexattr_destroy (&__attr); \
} \
} while (0);
@@ -247,6 +270,7 @@ typedef pthread_key_t __libc_key_t;
_pthread_cleanup_pop_restore (&_buffer, (DOIT)); \
}
+#if 0
#define __libc_cleanup_push(fct, arg) \
{ struct _pthread_cleanup_buffer _buffer; \
__libc_maybe_call (_pthread_cleanup_push, (&_buffer, (fct), (arg)), 0)
@@ -254,6 +278,7 @@ typedef pthread_key_t __libc_key_t;
#define __libc_cleanup_pop(execute) \
__libc_maybe_call (_pthread_cleanup_pop, (&_buffer, execute), 0); \
}
+#endif
/* Create thread-specific key. */
#define __libc_key_create(KEY, DESTRUCTOR) \
@@ -276,7 +301,7 @@ typedef pthread_key_t __libc_key_t;
library. */
extern int __pthread_mutex_init (pthread_mutex_t *__mutex,
- __const pthread_mutexattr_t *__mutex_attr);
+ const pthread_mutexattr_t *__mutex_attr);
extern int __pthread_mutex_destroy (pthread_mutex_t *__mutex);
@@ -295,7 +320,7 @@ extern int __pthread_mutexattr_settype (pthread_mutexattr_t *__attr,
#ifdef __USE_UNIX98
extern int __pthread_rwlock_init (pthread_rwlock_t *__rwlock,
- __const pthread_rwlockattr_t *__attr);
+ const pthread_rwlockattr_t *__attr);
extern int __pthread_rwlock_destroy (pthread_rwlock_t *__rwlock);
@@ -314,7 +339,7 @@ extern int __pthread_key_create (pthread_key_t *__key,
void (*__destr_function) (void *));
extern int __pthread_setspecific (pthread_key_t __key,
- __const void *__pointer);
+ const void *__pointer);
extern void *__pthread_getspecific (pthread_key_t __key);
@@ -351,7 +376,6 @@ weak_extern (BP_SYM (__pthread_key_create))
weak_extern (BP_SYM (__pthread_setspecific))
weak_extern (BP_SYM (__pthread_getspecific))
weak_extern (BP_SYM (__pthread_once))
-weak_extern (__pthread_initialize)
weak_extern (__pthread_atfork)
weak_extern (BP_SYM (_pthread_cleanup_push))
weak_extern (BP_SYM (_pthread_cleanup_pop))
@@ -376,7 +400,6 @@ weak_extern (BP_SYM (_pthread_cleanup_pop_restore))
# pragma weak __pthread_setspecific
# pragma weak __pthread_getspecific
# pragma weak __pthread_once
-# pragma weak __pthread_initialize
# pragma weak __pthread_atfork
# pragma weak _pthread_cleanup_push_defer
# pragma weak _pthread_cleanup_pop_restore
diff --git a/libpthread/linuxthreads.old/sysdeps/pthread/bits/libc-tsd.h b/libpthread/linuxthreads.old/sysdeps/pthread/bits/libc-tsd.h
index 2b889e621..97af75ebf 100644
--- a/libpthread/linuxthreads.old/sysdeps/pthread/bits/libc-tsd.h
+++ b/libpthread/linuxthreads.old/sysdeps/pthread/bits/libc-tsd.h
@@ -13,15 +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; 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_LIBC_TSD_H
#define _BITS_LIBC_TSD_H 1
-#include <libc-internal.h>
-
/* Fast thread-specific data internal to libc. */
enum __libc_tsd_key_t { _LIBC_TSD_KEY_MALLOC = 0,
_LIBC_TSD_KEY_DL_ERROR,
@@ -32,12 +29,11 @@ enum __libc_tsd_key_t { _LIBC_TSD_KEY_MALLOC = 0,
_LIBC_TSD_KEY_CTYPE_TOUPPER,
_LIBC_TSD_KEY_N };
-#include <sys/cdefs.h>
-#include <tls.h>
-
+#include <features.h>
#include <linuxthreads.old/internals.h>
-#if defined(USE_TLS) && USE_TLS && HAVE___THREAD
+#ifdef __UCLIBC_HAS_TLS__
+#include <tls.h>
/* When __thread works, the generic definition is what we want. */
# include <sysdeps/generic/bits/libc-tsd.h>
diff --git a/libpthread/linuxthreads.old/sysdeps/pthread/bits/pthreadtypes.h b/libpthread/linuxthreads.old/sysdeps/pthread/bits/pthreadtypes.h
index faec63b06..3eb592919 100644
--- a/libpthread/linuxthreads.old/sysdeps/pthread/bits/pthreadtypes.h
+++ b/libpthread/linuxthreads.old/sysdeps/pthread/bits/pthreadtypes.h
@@ -19,6 +19,9 @@
#ifndef _BITS_PTHREADTYPES_H
#define _BITS_PTHREADTYPES_H 1
+#define __need_size_t
+#include <stddef.h>
+
#define __need_schedparam
#include <bits/sched.h>
diff --git a/libpthread/linuxthreads.old/sysdeps/pthread/not-cancel.h b/libpthread/linuxthreads.old/sysdeps/pthread/not-cancel.h
new file mode 100644
index 000000000..bbdb0739c
--- /dev/null
+++ b/libpthread/linuxthreads.old/sysdeps/pthread/not-cancel.h
@@ -0,0 +1,113 @@
+/* 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>
+
+/* 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
+
+/* 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)
+
+/* 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))
+
+/* Uncancelable write. */
+#define write_not_cancel(fd, buf, n) \
+ INLINE_SYSCALL (write, 3, (fd), (buf), (n))
+
+/* 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)
+
+/* Uncancelable waitpid. */
+#ifdef __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
+
+/* Uncancelable pause. */
+#ifdef __NR_pause
+# define pause_not_cancel() \
+ INLINE_SYSCALL (pause, 0)
+#else
+# 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
+
+/* Uncancelable sigsuspend. */
+#define sigsuspend_not_cancel(set) \
+ __sigsuspend_nocancel (set)
diff --git a/libpthread/linuxthreads.old/sysdeps/pthread/pthread-functions.h b/libpthread/linuxthreads.old/sysdeps/pthread/pthread-functions.h
index ce6d10fba..2afaa52e8 100644
--- a/libpthread/linuxthreads.old/sysdeps/pthread/pthread-functions.h
+++ b/libpthread/linuxthreads.old/sysdeps/pthread/pthread-functions.h
@@ -13,25 +13,28 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 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 _PTHREAD_FUNCTIONS_H
#define _PTHREAD_FUNCTIONS_H 1
#include <pthread.h>
+#if 0
#include <setjmp.h>
#include <linuxthreads.old/internals.h>
struct fork_block;
+#endif
/* Data type shared with libc. The libc uses it to pass on calls to
the thread functions. Wine pokes directly into this structure,
so if possible avoid breaking it and append new hooks to the end. */
struct pthread_functions
{
+#if 0
pid_t (*ptr_pthread_fork) (struct fork_block *);
+#endif
int (*ptr_pthread_attr_destroy) (pthread_attr_t *);
int (*ptr_pthread_attr_init) (pthread_attr_t *);
int (*ptr_pthread_attr_getdetachstate) (const pthread_attr_t *, int *);
@@ -68,26 +71,36 @@ struct pthread_functions
pthread_t (*ptr_pthread_self) (void);
int (*ptr_pthread_setcancelstate) (int, int *);
int (*ptr_pthread_setcanceltype) (int, int *);
+#if 0
void (*ptr_pthread_do_exit) (void *retval, char *currentframe);
void (*ptr_pthread_cleanup_upto) (__jmp_buf target,
char *targetframe);
pthread_descr (*ptr_pthread_thread_self) (void);
+#endif
+#if !defined __UCLIBC_HAS_TLS__ && defined __UCLIBC_HAS_RPC__
int (*ptr_pthread_internal_tsd_set) (int key, const void *pointer);
void * (*ptr_pthread_internal_tsd_get) (int key);
void ** __attribute__ ((__const__))
(*ptr_pthread_internal_tsd_address) (int key);
+#endif
+#if 0
int (*ptr_pthread_sigaction) (int sig, const struct sigaction * act,
struct sigaction *oact);
int (*ptr_pthread_sigwait) (const sigset_t *set, int *sig);
int (*ptr_pthread_raise) (int sig);
+#endif
int (*ptr_pthread_cond_timedwait) (pthread_cond_t *, pthread_mutex_t *,
const struct timespec *);
+#if 0
void (*ptr__pthread_cleanup_push) (struct _pthread_cleanup_buffer * buffer,
void (*routine)(void *), void * arg);
+#endif
void (*ptr__pthread_cleanup_push_defer) (struct _pthread_cleanup_buffer * buffer,
void (*routine)(void *), void * arg);
+#if 0
void (*ptr__pthread_cleanup_pop) (struct _pthread_cleanup_buffer * buffer,
int execute);
+#endif
void (*ptr__pthread_cleanup_pop_restore) (struct _pthread_cleanup_buffer * buffer,
int execute);
};
@@ -95,4 +108,6 @@ struct pthread_functions
/* Variable in libc.so. */
extern struct pthread_functions __libc_pthread_functions attribute_hidden;
+extern int * __libc_pthread_init (const struct pthread_functions *functions);
+
#endif /* pthread-functions.h */
diff --git a/libpthread/linuxthreads.old/sysdeps/pthread/pthread.h b/libpthread/linuxthreads.old/sysdeps/pthread/pthread.h
index 870e37fa5..3c7044d8b 100644
--- a/libpthread/linuxthreads.old/sysdeps/pthread/pthread.h
+++ b/libpthread/linuxthreads.old/sysdeps/pthread/pthread.h
@@ -161,9 +161,9 @@ enum
if ATTR is NULL), and call function START_ROUTINE with given
arguments ARG. */
extern int pthread_create (pthread_t *__restrict __threadp,
- __const pthread_attr_t *__restrict __attr,
+ const pthread_attr_t *__restrict __attr,
void *(*__start_routine) (void *),
- void *__restrict __arg) __THROW;
+ void *__restrict __arg) __THROWNL;
/* Obtain the identifier of the current thread. */
extern pthread_t pthread_self (void) __THROW;
@@ -179,6 +179,21 @@ extern void pthread_exit (void *__retval) __attribute__ ((__noreturn__));
is not NULL. */
extern int pthread_join (pthread_t __th, void **__thread_return);
+#ifdef __USE_GNU
+/* Check whether thread TH has terminated. If yes return the status of
+ the thread in *THREAD_RETURN, if THREAD_RETURN is not NULL. */
+extern int pthread_tryjoin_np (pthread_t __th, void **__thread_return) __THROW;
+
+/* Make calling thread wait for termination of the thread TH, but only
+ until TIMEOUT. The exit status of the thread is stored in
+ *THREAD_RETURN, if THREAD_RETURN is not NULL.
+
+ This function is a cancellation point and therefore not marked with
+ __THROW. */
+extern int pthread_timedjoin_np (pthread_t __th, void **__thread_return,
+ __const struct timespec *__abstime);
+#endif
+
/* Indicate that the thread TH is never to be joined with PTHREAD_JOIN.
The resources of TH will therefore be freed immediately when it
terminates, instead of waiting for another thread to perform PTHREAD_JOIN
@@ -201,16 +216,16 @@ extern int pthread_attr_setdetachstate (pthread_attr_t *__attr,
int __detachstate) __THROW;
/* Return in *DETACHSTATE the `detachstate' attribute in *ATTR. */
-extern int pthread_attr_getdetachstate (__const pthread_attr_t *__attr,
+extern int pthread_attr_getdetachstate (const pthread_attr_t *__attr,
int *__detachstate) __THROW;
/* Set scheduling parameters (priority, etc) in *ATTR according to PARAM. */
extern int pthread_attr_setschedparam (pthread_attr_t *__restrict __attr,
- __const struct sched_param *__restrict
+ const struct sched_param *__restrict
__param) __THROW;
/* Return in *PARAM the scheduling parameters of *ATTR. */
-extern int pthread_attr_getschedparam (__const pthread_attr_t *__restrict
+extern int pthread_attr_getschedparam (const pthread_attr_t *__restrict
__attr,
struct sched_param *__restrict __param)
__THROW;
@@ -220,7 +235,7 @@ extern int pthread_attr_setschedpolicy (pthread_attr_t *__attr, int __policy)
__THROW;
/* Return in *POLICY the scheduling policy of *ATTR. */
-extern int pthread_attr_getschedpolicy (__const pthread_attr_t *__restrict
+extern int pthread_attr_getschedpolicy (const pthread_attr_t *__restrict
__attr, int *__restrict __policy)
__THROW;
@@ -229,7 +244,7 @@ extern int pthread_attr_setinheritsched (pthread_attr_t *__attr,
int __inherit) __THROW;
/* Return in *INHERIT the scheduling inheritance mode of *ATTR. */
-extern int pthread_attr_getinheritsched (__const pthread_attr_t *__restrict
+extern int pthread_attr_getinheritsched (const pthread_attr_t *__restrict
__attr, int *__restrict __inherit)
__THROW;
@@ -238,7 +253,7 @@ extern int pthread_attr_setscope (pthread_attr_t *__attr, int __scope)
__THROW;
/* Return in *SCOPE the scheduling contention scope of *ATTR. */
-extern int pthread_attr_getscope (__const pthread_attr_t *__restrict __attr,
+extern int pthread_attr_getscope (const pthread_attr_t *__restrict __attr,
int *__restrict __scope) __THROW;
#ifdef __USE_UNIX98
@@ -247,11 +262,12 @@ extern int pthread_attr_setguardsize (pthread_attr_t *__attr,
size_t __guardsize) __THROW;
/* Get the size of the guard area at the bottom of the thread. */
-extern int pthread_attr_getguardsize (__const pthread_attr_t *__restrict
+extern int pthread_attr_getguardsize (const pthread_attr_t *__restrict
__attr, size_t *__restrict __guardsize)
__THROW;
#endif
+#if 0 /* uClibc: deprecated stuff disabled. def __UCLIBC_SUSV3_LEGACY__ */
/* Set the starting address of the stack of the thread to be created.
Depending on whether the stack grows up or down the value must either
be higher or lower than all the address in the memory block. The
@@ -260,9 +276,10 @@ extern int pthread_attr_setstackaddr (pthread_attr_t *__attr,
void *__stackaddr) __THROW;
/* Return the previously set address for the stack. */
-extern int pthread_attr_getstackaddr (__const pthread_attr_t *__restrict
+extern int pthread_attr_getstackaddr (const pthread_attr_t *__restrict
__attr, void **__restrict __stackaddr)
__THROW;
+#endif
#ifdef __USE_XOPEN2K
/* The following two interfaces are intended to replace the last two. They
@@ -272,7 +289,7 @@ extern int pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr,
size_t __stacksize) __THROW;
/* Return the previously set address for the stack. */
-extern int pthread_attr_getstack (__const pthread_attr_t *__restrict __attr,
+extern int pthread_attr_getstack (const pthread_attr_t *__restrict __attr,
void **__restrict __stackaddr,
size_t *__restrict __stacksize) __THROW;
#endif
@@ -284,7 +301,7 @@ extern int pthread_attr_setstacksize (pthread_attr_t *__attr,
size_t __stacksize) __THROW;
/* Return the currently used minimal stack size. */
-extern int pthread_attr_getstacksize (__const pthread_attr_t *__restrict
+extern int pthread_attr_getstacksize (const pthread_attr_t *__restrict
__attr, size_t *__restrict __stacksize)
__THROW;
@@ -293,7 +310,7 @@ extern int pthread_attr_getstacksize (__const pthread_attr_t *__restrict
#ifdef __USE_GNU
/* Initialize thread attribute *ATTR with attributes corresponding to the
- already running thread TH. It shall be called on unitialized ATTR
+ already running thread TH. It shall be called on uninitialized ATTR
and destroyed with pthread_attr_destroy when no longer needed. */
extern int pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr) __THROW;
#endif
@@ -304,7 +321,7 @@ extern int pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr) __THROW;
/* Set the scheduling parameters for TARGET_THREAD according to POLICY
and *PARAM. */
extern int pthread_setschedparam (pthread_t __target_thread, int __policy,
- __const struct sched_param *__param)
+ const struct sched_param *__param)
__THROW;
/* Return in *POLICY and *PARAM the scheduling parameters for TARGET_THREAD. */
@@ -321,32 +338,37 @@ extern int pthread_getconcurrency (void) __THROW;
extern int pthread_setconcurrency (int __level) __THROW;
#endif
+#ifdef __USE_GNU
+/* Same thing, different name */
+#define pthread_yield() sched_yield()
+#endif
+
/* Functions for mutex handling. */
/* Initialize MUTEX using attributes in *MUTEX_ATTR, or use the
default values if later is NULL. */
extern int pthread_mutex_init (pthread_mutex_t *__restrict __mutex,
- __const pthread_mutexattr_t *__restrict
+ const pthread_mutexattr_t *__restrict
__mutex_attr) __THROW;
/* Destroy MUTEX. */
extern int pthread_mutex_destroy (pthread_mutex_t *__mutex) __THROW;
/* Try to lock MUTEX. */
-extern int pthread_mutex_trylock (pthread_mutex_t *__mutex) __THROW;
+extern int pthread_mutex_trylock (pthread_mutex_t *__mutex) __THROWNL;
/* Wait until lock for MUTEX becomes available and lock it. */
-extern int pthread_mutex_lock (pthread_mutex_t *__mutex) __THROW;
+extern int pthread_mutex_lock (pthread_mutex_t *__mutex) __THROWNL;
#ifdef __USE_XOPEN2K
/* Wait until lock becomes available, or specified time passes. */
extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex,
- __const struct timespec *__restrict
- __abstime) __THROW;
+ const struct timespec *__restrict
+ __abstime) __THROWNL;
#endif
/* Unlock MUTEX. */
-extern int pthread_mutex_unlock (pthread_mutex_t *__mutex) __THROW;
+extern int pthread_mutex_unlock (pthread_mutex_t *__mutex) __THROWNL;
/* Functions for handling mutex attributes. */
@@ -359,7 +381,7 @@ extern int pthread_mutexattr_init (pthread_mutexattr_t *__attr) __THROW;
extern int pthread_mutexattr_destroy (pthread_mutexattr_t *__attr) __THROW;
/* Get the process-shared flag of the mutex attribute ATTR. */
-extern int pthread_mutexattr_getpshared (__const pthread_mutexattr_t *
+extern int pthread_mutexattr_getpshared (const pthread_mutexattr_t *
__restrict __attr,
int *__restrict __pshared) __THROW;
@@ -375,7 +397,7 @@ extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind)
__THROW;
/* Return in *KIND the mutex kind attribute in *ATTR. */
-extern int pthread_mutexattr_gettype (__const pthread_mutexattr_t *__restrict
+extern int pthread_mutexattr_gettype (const pthread_mutexattr_t *__restrict
__attr, int *__restrict __kind) __THROW;
#endif
@@ -385,22 +407,27 @@ extern int pthread_mutexattr_gettype (__const pthread_mutexattr_t *__restrict
/* Initialize condition variable COND using attributes ATTR, or use
the default values if later is NULL. */
extern int pthread_cond_init (pthread_cond_t *__restrict __cond,
- __const pthread_condattr_t *__restrict
+ const pthread_condattr_t *__restrict
__cond_attr) __THROW;
+libpthread_hidden_proto(pthread_cond_init)
/* Destroy condition variable COND. */
extern int pthread_cond_destroy (pthread_cond_t *__cond) __THROW;
+libpthread_hidden_proto(pthread_cond_destroy)
/* Wake up one thread waiting for condition variable COND. */
-extern int pthread_cond_signal (pthread_cond_t *__cond) __THROW;
+extern int pthread_cond_signal (pthread_cond_t *__cond) __THROWNL;
+libpthread_hidden_proto(pthread_cond_signal)
/* Wake up all threads waiting for condition variables COND. */
-extern int pthread_cond_broadcast (pthread_cond_t *__cond) __THROW;
+extern int pthread_cond_broadcast (pthread_cond_t *__cond) __THROWNL;
+libpthread_hidden_proto(pthread_cond_broadcast)
/* Wait for condition variable COND to be signaled or broadcast.
MUTEX is assumed to be locked before. */
extern int pthread_cond_wait (pthread_cond_t *__restrict __cond,
pthread_mutex_t *__restrict __mutex);
+libpthread_hidden_proto(pthread_cond_wait)
/* Wait for condition variable COND to be signaled or broadcast until
ABSTIME. MUTEX is assumed to be locked before. ABSTIME is an
@@ -408,19 +435,22 @@ extern int pthread_cond_wait (pthread_cond_t *__restrict __cond,
(00:00:00 GMT, January 1, 1970). */
extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,
pthread_mutex_t *__restrict __mutex,
- __const struct timespec *__restrict
+ const struct timespec *__restrict
__abstime);
+libpthread_hidden_proto(pthread_cond_timedwait)
/* Functions for handling condition variable attributes. */
/* Initialize condition variable attribute ATTR. */
extern int pthread_condattr_init (pthread_condattr_t *__attr) __THROW;
+libpthread_hidden_proto(pthread_condattr_init)
/* Destroy condition variable attribute ATTR. */
extern int pthread_condattr_destroy (pthread_condattr_t *__attr) __THROW;
+libpthread_hidden_proto(pthread_condattr_destroy)
/* Get the process-shared flag of the condition variable attribute ATTR. */
-extern int pthread_condattr_getpshared (__const pthread_condattr_t *
+extern int pthread_condattr_getpshared (const pthread_condattr_t *
__restrict __attr,
int *__restrict __pshared) __THROW;
@@ -435,40 +465,40 @@ extern int pthread_condattr_setpshared (pthread_condattr_t *__attr,
/* Initialize read-write lock RWLOCK using attributes ATTR, or use
the default values if later is NULL. */
extern int pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock,
- __const pthread_rwlockattr_t *__restrict
+ const pthread_rwlockattr_t *__restrict
__attr) __THROW;
/* Destroy read-write lock RWLOCK. */
extern int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock) __THROW;
/* Acquire read lock for RWLOCK. */
-extern int pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock) __THROW;
+extern int pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock) __THROWNL;
/* Try to acquire read lock for RWLOCK. */
-extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock) __THROW;
+extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock) __THROWNL;
# ifdef __USE_XOPEN2K
/* Try to acquire read lock for RWLOCK or return after specfied time. */
extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock,
- __const struct timespec *__restrict
- __abstime) __THROW;
+ const struct timespec *__restrict
+ __abstime) __THROWNL;
# endif
/* Acquire write lock for RWLOCK. */
-extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock) __THROW;
+extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock) __THROWNL;
/* Try to acquire write lock for RWLOCK. */
-extern int pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock) __THROW;
+extern int pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock) __THROWNL;
# ifdef __USE_XOPEN2K
/* Try to acquire write lock for RWLOCK or return after specfied time. */
extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock,
- __const struct timespec *__restrict
- __abstime) __THROW;
+ const struct timespec *__restrict
+ __abstime) __THROWNL;
# endif
/* Unlock RWLOCK. */
-extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock) __THROW;
+extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock) __THROWNL;
/* Functions for handling read-write lock attributes. */
@@ -480,7 +510,7 @@ extern int pthread_rwlockattr_init (pthread_rwlockattr_t *__attr) __THROW;
extern int pthread_rwlockattr_destroy (pthread_rwlockattr_t *__attr) __THROW;
/* Return current setting of process-shared attribute of ATTR in PSHARED. */
-extern int pthread_rwlockattr_getpshared (__const pthread_rwlockattr_t *
+extern int pthread_rwlockattr_getpshared (const pthread_rwlockattr_t *
__restrict __attr,
int *__restrict __pshared) __THROW;
@@ -489,7 +519,7 @@ extern int pthread_rwlockattr_setpshared (pthread_rwlockattr_t *__attr,
int __pshared) __THROW;
/* Return current setting of reader/writer preference. */
-extern int pthread_rwlockattr_getkind_np (__const pthread_rwlockattr_t *__attr,
+extern int pthread_rwlockattr_getkind_np (const pthread_rwlockattr_t *__attr,
int *__pref) __THROW;
/* Set reader/write preference. */
@@ -513,19 +543,19 @@ extern int pthread_spin_init (pthread_spinlock_t *__lock, int __pshared)
extern int pthread_spin_destroy (pthread_spinlock_t *__lock) __THROW;
/* Wait until spinlock LOCK is retrieved. */
-extern int pthread_spin_lock (pthread_spinlock_t *__lock) __THROW;
+extern int pthread_spin_lock (pthread_spinlock_t *__lock) __THROWNL;
/* Try to lock spinlock LOCK. */
-extern int pthread_spin_trylock (pthread_spinlock_t *__lock) __THROW;
+extern int pthread_spin_trylock (pthread_spinlock_t *__lock) __THROWNL;
/* Release spinlock LOCK. */
-extern int pthread_spin_unlock (pthread_spinlock_t *__lock) __THROW;
+extern int pthread_spin_unlock (pthread_spinlock_t *__lock) __THROWNL;
/* Barriers are a also a new feature in 1003.1j-2000. */
extern int pthread_barrier_init (pthread_barrier_t *__restrict __barrier,
- __const pthread_barrierattr_t *__restrict
+ const pthread_barrierattr_t *__restrict
__attr, unsigned int __count) __THROW;
extern int pthread_barrier_destroy (pthread_barrier_t *__barrier) __THROW;
@@ -534,14 +564,14 @@ extern int pthread_barrierattr_init (pthread_barrierattr_t *__attr) __THROW;
extern int pthread_barrierattr_destroy (pthread_barrierattr_t *__attr) __THROW;
-extern int pthread_barrierattr_getpshared (__const pthread_barrierattr_t *
+extern int pthread_barrierattr_getpshared (const pthread_barrierattr_t *
__restrict __attr,
int *__restrict __pshared) __THROW;
extern int pthread_barrierattr_setpshared (pthread_barrierattr_t *__attr,
int __pshared) __THROW;
-extern int pthread_barrier_wait (pthread_barrier_t *__barrier) __THROW;
+extern int pthread_barrier_wait (pthread_barrier_t *__barrier) __THROWNL;
#endif
#endif
@@ -562,7 +592,7 @@ extern int pthread_key_delete (pthread_key_t __key) __THROW;
/* Store POINTER in the thread-specific data slot identified by KEY. */
extern int pthread_setspecific (pthread_key_t __key,
- __const void *__pointer) __THROW;
+ const void *__pointer) __THROW;
/* Return current value of the thread-specific data slot identified by KEY. */
extern void *pthread_getspecific (pthread_key_t __key) __THROW;
diff --git a/libpthread/linuxthreads.old/sysdeps/pthread/tls.h b/libpthread/linuxthreads.old/sysdeps/pthread/tls.h
index 6a23ec05e..2068f1e77 100644
--- a/libpthread/linuxthreads.old/sysdeps/pthread/tls.h
+++ b/libpthread/linuxthreads.old/sysdeps/pthread/tls.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/>. */
/* By default no TLS support is available. This is signaled by the
absence of the symbol USE_TLS. */
diff --git a/libpthread/linuxthreads.old/sysdeps/sh/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/sh/pt-machine.h
index 793f80b2d..7d1484e71 100644
--- a/libpthread/linuxthreads.old/sysdeps/sh/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/sh/pt-machine.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; 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 _PT_MACHINE_H
#define _PT_MACHINE_H 1
diff --git a/libpthread/linuxthreads.old/sysdeps/sh/tls.h b/libpthread/linuxthreads.old/sysdeps/sh/tls.h
index 7bc29800a..25bef830f 100644
--- a/libpthread/linuxthreads.old/sysdeps/sh/tls.h
+++ b/libpthread/linuxthreads.old/sysdeps/sh/tls.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 _TLS_H
#define _TLS_H
diff --git a/libpthread/linuxthreads.old/sysdeps/sh64/Makefile.arch b/libpthread/linuxthreads.old/sysdeps/sh64/Makefile.arch
deleted file mode 100644
index e4cb95b76..000000000
--- a/libpthread/linuxthreads.old/sysdeps/sh64/Makefile.arch
+++ /dev/null
@@ -1,30 +0,0 @@
-# Makefile for uClibc
-#
-# 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.
-#
-
-libpthread_ARCH_DIR:=$(top_srcdir)libpthread/linuxthreads.old/sysdeps/sh64
-libpthread_ARCH_OUT:=$(top_builddir)libpthread/linuxthreads.old/sysdeps/sh64
-
-libpthread_ARCH_SRC:=$(wildcard $(libpthread_ARCH_DIR)/*.c)
-libpthread_ARCH_OBJ:=$(patsubst $(libpthread_ARCH_DIR)/%.c,$(libpthread_ARCH_OUT)/%.o,$(libpthread_ARCH_SRC))
-
-libpthread-a-y+=$(libpthread_ARCH_OBJ)
-libpthread-so-y+=$(libpthread_ARCH_OBJ:.o=.os)
-
-libpthread-multi-y+=$(libpthread_ARCH_SRC)
-
-objclean-y+=libpthread_arch_objclean
-
-# We need to build as SHcompact for tas..
-$(libpthread_ARCH_OBJ): %.o : %.c
- $(compile.c:32media=compact)
-
-$(libpthread_ARCH_OBJ:.o=.os): %.os : %.c
- $(compile.c:32media=compact)
-
-libpthread_arch_objclean:
- $(RM) $(libpthread_ARCH_OUT)/*.{o,os}
diff --git a/libpthread/linuxthreads.old/sysdeps/sh64/pt-machine.c b/libpthread/linuxthreads.old/sysdeps/sh64/pt-machine.c
deleted file mode 100644
index bd2c401fc..000000000
--- a/libpthread/linuxthreads.old/sysdeps/sh64/pt-machine.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/* Cloned for uClibc by Paul Mundt, December 2003 */
-/* Modified by SuperH, Inc. September 2003 */
-
-/* Machine-dependent pthreads configuration and inline functions.
- SH5 version.
- Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Niibe Yutaka <gniibe@m17n.org>.
-
- 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 "pt-machine.h"
-
-/* Spinlock implementation; required. */
-
-/* The SH5 does not have a suitable test-and-set instruction (SWAP only
- operates on an aligned quad word). So we use the SH4 version instead.
- This must be seperately compiled in SHcompact mode, so it cannot be
- inline. */
-
-long int testandset (int *spinlock)
-{
- int ret;
-
- __asm__ __volatile__(
- "tas.b @%1\n\t"
- "movt %0"
- : "=r" (ret)
- : "r" (spinlock)
- : "memory", "cc");
-
- return (ret == 0);
-}
-
diff --git a/libpthread/linuxthreads.old/sysdeps/sparc/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/sparc/pt-machine.h
index ab90810f1..d502c759a 100644
--- a/libpthread/linuxthreads.old/sysdeps/sparc/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/sparc/pt-machine.h
@@ -1,8 +1,82 @@
-#include <features.h>
-#include <bits/wordsize.h>
+/* Machine-dependent pthreads configuration and inline functions.
+ sparc version.
+ Copyright (C) 1996-1998, 2000-2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson <rth@tamu.edu>.
-#if __WORDSIZE == 32
-# include "sparc32/pt-machine.h"
-#else
-# include "sparc64/pt-machine.h"
+ 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/>. */
+
+#ifndef _PT_MACHINE_H
+#define _PT_MACHINE_H 1
+
+#ifndef PT_EI
+# define PT_EI __extern_always_inline
#endif
+
+extern long int testandset (int *spinlock);
+extern int __compare_and_swap (long int *p, long int oldval, long int newval);
+
+/* Spinlock implementation; required. */
+PT_EI long int
+testandset (int *spinlock)
+{
+ int ret;
+
+ __asm__ __volatile__("ldstub %1,%0"
+ : "=r"(ret), "=m"(*spinlock)
+ : "m"(*spinlock));
+
+ return ret;
+}
+
+
+/* Memory barrier; default is to do nothing */
+#define MEMORY_BARRIER() __asm__ __volatile__("stbar" : : : "memory")
+
+
+/* Get some notion of the current stack. Need not be exactly the top
+ of the stack, just something somewhere in the current frame. */
+#define CURRENT_STACK_FRAME (stack_pointer + (2 * 64))
+register char *stack_pointer __asm__("%sp");
+
+
+/* Registers %g6 and %g7 are reserved by the ABI for "system use".
+ %g7 is specified in the TLS ABI as thread pointer -- we do the same. */
+struct _pthread_descr_struct;
+register struct _pthread_descr_struct *__thread_self __asm__("%g7");
+
+/* Return the thread descriptor for the current thread. */
+#define THREAD_SELF __thread_self
+
+/* Initialize the thread-unique value. */
+#define INIT_THREAD_SELF(descr, nr) (__thread_self = (descr))
+
+/* Access to data in the thread descriptor is easy. */
+#define THREAD_GETMEM(descr, member) \
+ ((void) sizeof (descr), THREAD_SELF->member)
+#define THREAD_GETMEM_NC(descr, member) \
+ ((void) sizeof (descr), THREAD_SELF->member)
+#define THREAD_SETMEM(descr, member, value) \
+ ((void) sizeof (descr), THREAD_SELF->member = (value))
+#define THREAD_SETMEM_NC(descr, member, value) \
+ ((void) sizeof (descr), THREAD_SELF->member = (value))
+
+/* We want the OS to assign stack addresses. */
+#define FLOATING_STACKS 1
+
+/* Maximum size of the stack if the rlimit is unlimited. */
+#define ARCH_STACK_MAX_SIZE 8*1024*1024
+
+#endif /* pt-machine.h */
diff --git a/libpthread/linuxthreads.old/sysdeps/sparc/sparc32/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/sparc/sparc32/pt-machine.h
deleted file mode 100644
index 43c05f2a6..000000000
--- a/libpthread/linuxthreads.old/sysdeps/sparc/sparc32/pt-machine.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/* Machine-dependent pthreads configuration and inline functions.
- sparc version.
- Copyright (C) 1996-1998, 2000-2003 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; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-#ifndef _PT_MACHINE_H
-#define _PT_MACHINE_H 1
-
-#ifndef PT_EI
-# define PT_EI __extern_always_inline
-#endif
-
-extern long int testandset (int *spinlock);
-extern int __compare_and_swap (long int *p, long int oldval, long int newval);
-
-/* Spinlock implementation; required. */
-PT_EI long int
-testandset (int *spinlock)
-{
- int ret;
-
- __asm__ __volatile__("ldstub %1,%0"
- : "=r"(ret), "=m"(*spinlock)
- : "m"(*spinlock));
-
- return ret;
-}
-
-
-/* Memory barrier; default is to do nothing */
-#define MEMORY_BARRIER() __asm__ __volatile__("stbar" : : : "memory")
-
-
-/* Get some notion of the current stack. Need not be exactly the top
- of the stack, just something somewhere in the current frame. */
-#define CURRENT_STACK_FRAME (stack_pointer + (2 * 64))
-register char *stack_pointer __asm__("%sp");
-
-
-/* Registers %g6 and %g7 are reserved by the ABI for "system use".
- %g7 is specified in the TLS ABI as thread pointer -- we do the same. */
-struct _pthread_descr_struct;
-register struct _pthread_descr_struct *__thread_self __asm__("%g7");
-
-/* Return the thread descriptor for the current thread. */
-#define THREAD_SELF __thread_self
-
-/* Initialize the thread-unique value. */
-#define INIT_THREAD_SELF(descr, nr) (__thread_self = (descr))
-
-/* Access to data in the thread descriptor is easy. */
-#define THREAD_GETMEM(descr, member) \
- ((void) sizeof (descr), THREAD_SELF->member)
-#define THREAD_GETMEM_NC(descr, member) \
- ((void) sizeof (descr), THREAD_SELF->member)
-#define THREAD_SETMEM(descr, member, value) \
- ((void) sizeof (descr), THREAD_SELF->member = (value))
-#define THREAD_SETMEM_NC(descr, member, value) \
- ((void) sizeof (descr), THREAD_SELF->member = (value))
-
-/* We want the OS to assign stack addresses. */
-#define FLOATING_STACKS 1
-
-/* Maximum size of the stack if the rlimit is unlimited. */
-#define ARCH_STACK_MAX_SIZE 8*1024*1024
-
-#endif /* pt-machine.h */
diff --git a/libpthread/linuxthreads.old/sysdeps/sparc/sparc64/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/sparc/sparc64/pt-machine.h
deleted file mode 100644
index 815d70e8d..000000000
--- a/libpthread/linuxthreads.old/sysdeps/sparc/sparc64/pt-machine.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/* Machine-dependent pthreads configuration and inline functions.
- Sparc v9 version.
- Copyright (C) 1997-2002, 2003 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; see the file COPYING.LIB. If
- not, write to the Free Software Foundation, Inc.,
- 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#ifndef _PT_MACHINE_H
-#define _PT_MACHINE_H 1
-
-#ifndef PT_EI
-# define PT_EI __extern_always_inline
-#endif
-
-extern long int testandset (int *spinlock);
-extern int __compare_and_swap (long int *p, long int oldval, long int newval);
-
-/* Spinlock implementation; required. */
-PT_EI long int
-testandset (int *spinlock)
-{
- int ret;
-
- __asm__ __volatile__("ldstub %1,%0"
- : "=r" (ret), "=m" (*spinlock) : "m" (*spinlock));
-
- return ret;
-}
-
-
-/* Memory barrier; default is to do nothing */
-#define MEMORY_BARRIER() \
- __asm__ __volatile__("membar #LoadLoad | #LoadStore | #StoreLoad | #StoreStore" : : : "memory")
-/* Read barrier. */
-#define READ_MEMORY_BARRIER() \
- __asm__ __volatile__("membar #LoadLoad | #LoadStore" : : : "memory")
-/* Write barrier. */
-#define WRITE_MEMORY_BARRIER() \
- __asm__ __volatile__("membar #StoreLoad | #StoreStore" : : : "memory")
-
-
-/* Get some notion of the current stack. Need not be exactly the top
- of the stack, just something somewhere in the current frame. */
-#define CURRENT_STACK_FRAME (stack_pointer + (2 * 128))
-register char *stack_pointer __asm__ ("%sp");
-
-
-/* Registers %g6 and %g7 are reserved by the ABI for "system use". The
- TLS ABI specifies %g7 as the thread pointer. */
-struct _pthread_descr_struct;
-register struct _pthread_descr_struct *__thread_self __asm__ ("%g7");
-
-/* Return the thread descriptor for the current thread. */
-#define THREAD_SELF __thread_self
-
-/* Initialize the thread-unique value. */
-#define INIT_THREAD_SELF(descr, nr) (__thread_self = (descr))
-
-
-/* Compare-and-swap for semaphores. */
-
-#define HAS_COMPARE_AND_SWAP
-PT_EI int
-__compare_and_swap (long int *p, long int oldval, long int newval)
-{
- long int readval;
-
- __asm__ __volatile__ ("casx [%4], %2, %0"
- : "=r"(readval), "=m"(*p)
- : "r"(oldval), "m"(*p), "r"(p), "0"(newval));
- MEMORY_BARRIER();
- return readval == oldval;
-}
-
-/* Access to data in the thread descriptor is easy. */
-#define THREAD_GETMEM(descr, member) \
- ((void) sizeof (descr), THREAD_SELF->member)
-#define THREAD_GETMEM_NC(descr, member) \
- ((void) sizeof (descr), THREAD_SELF->member)
-#define THREAD_SETMEM(descr, member, value) \
- ((void) sizeof (descr), THREAD_SELF->member = (value))
-#define THREAD_SETMEM_NC(descr, member, value) \
- ((void) sizeof (descr), THREAD_SELF->member = (value))
-
-/* We want the OS to assign stack addresses. */
-#define FLOATING_STACKS 1
-
-/* Maximum size of the stack if the rlimit is unlimited. */
-#define ARCH_STACK_MAX_SIZE 32*1024*1024
-
-#endif /* pt-machine.h */
diff --git a/libpthread/linuxthreads.old/sysdeps/sparc/tcb-offsets.h b/libpthread/linuxthreads.old/sysdeps/sparc/tcb-offsets.h
new file mode 100644
index 000000000..6d6f111f4
--- /dev/null
+++ b/libpthread/linuxthreads.old/sysdeps/sparc/tcb-offsets.h
@@ -0,0 +1 @@
+#include "../../../linuxthreads/sysdeps/pthread/tcb-offsets.h"
diff --git a/libpthread/linuxthreads.old/sysdeps/v850/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/v850/pt-machine.h
deleted file mode 100644
index 34de63b9f..000000000
--- a/libpthread/linuxthreads.old/sysdeps/v850/pt-machine.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * sysdeps/v850/pt-machine.h -- v850-specific pthread 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>
- */
-
-#ifndef _PT_MACHINE_H
-#define _PT_MACHINE_H 1
-
-#include <features.h>
-
-#ifndef PT_EI
-# define PT_EI __extern_always_inline
-#endif
-
-/* Get some notion of the current stack. Need not be exactly the top
- of the stack, just something somewhere in the current frame. */
-#define CURRENT_STACK_FRAME __stack_pointer
-register char *__stack_pointer __asm__ ("sp");
-
-#define HAS_COMPARE_AND_SWAP
-
-/* Atomically: If *PTR == OLD, set *PTR to NEW and return true,
- otherwise do nothing and return false. */
-PT_EI int
-__compare_and_swap (long *ptr, long old, long new)
-{
- unsigned long psw;
-
- /* disable interrupts */
- __asm__ __volatile__ ("stsr psw, %0; di" : "=&r" (psw));
-
- if (likely (*ptr == old))
- {
- *ptr = new;
- __asm__ __volatile__ ("ldsr %0, psw" :: "r" (psw)); /* re-enable */
- return 1;
- }
- else
- {
- __asm__ __volatile__ ("ldsr %0, psw" :: "r" (psw)); /* re-enable */
- return 0;
- }
-}
-#endif /* pt-machine.h */
diff --git a/libpthread/linuxthreads.old/sysdeps/x86_64/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/x86_64/pt-machine.h
index ce07bbb03..ed1fa30b1 100644
--- a/libpthread/linuxthreads.old/sysdeps/x86_64/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/x86_64/pt-machine.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 _PT_MACHINE_H
#define _PT_MACHINE_H 1
@@ -33,6 +32,9 @@
# define PT_EI __extern_always_inline
# endif
+extern long int testandset (int *);
+extern int __compare_and_swap (long int *, long int, long int);
+
/* Get some notion of the current stack. Need not be exactly the top
of the stack, just something somewhere in the current frame. */
# define CURRENT_STACK_FRAME stack_pointer
diff --git a/libpthread/linuxthreads.old/sysdeps/x86_64/tls.h b/libpthread/linuxthreads.old/sysdeps/x86_64/tls.h
index 5e7239d17..24ed3fca9 100644
--- a/libpthread/linuxthreads.old/sysdeps/x86_64/tls.h
+++ b/libpthread/linuxthreads.old/sysdeps/x86_64/tls.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 _TLS_H
#define _TLS_H
diff --git a/libpthread/linuxthreads.old/sysdeps/xtensa/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/xtensa/pt-machine.h
index acd4d109f..2c68ddfb5 100644
--- a/libpthread/linuxthreads.old/sysdeps/xtensa/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/xtensa/pt-machine.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., 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 _PT_MACHINE_H
#define _PT_MACHINE_H 1
@@ -26,19 +25,51 @@
#include <asm/unistd.h>
#ifndef PT_EI
-# define PT_EI __extern_always_inline
+# define PT_EI extern inline __attribute__ ((gnu_inline))
#endif
-/* Memory barrier. */
#define MEMORY_BARRIER() __asm__ ("memw" : : : "memory")
+#define HAS_COMPARE_AND_SWAP
+
+extern long int testandset (int *spinlock);
+extern int __compare_and_swap (long int *p, long int oldval, long int newval);
/* Spinlock implementation; required. */
PT_EI long int
testandset (int *spinlock)
{
- int unused = 0;
- return INTERNAL_SYSCALL (xtensa, , 4, SYS_XTENSA_ATOMIC_SET,
- spinlock, 1, unused);
+ unsigned long tmp;
+ __asm__ volatile (
+" movi %0, 0 \n"
+" wsr %0, SCOMPARE1 \n"
+" movi %0, 1 \n"
+" s32c1i %0, %1, 0 \n"
+ : "=&a" (tmp)
+ : "a" (spinlock)
+ : "memory"
+ );
+ return tmp;
+}
+
+PT_EI int
+__compare_and_swap (long int *p, long int oldval, long int newval)
+{
+ unsigned long tmp;
+ unsigned long value;
+ __asm__ volatile (
+"1: l32i %0, %2, 0 \n"
+" bne %0, %4, 2f \n"
+" wsr %0, SCOMPARE1 \n"
+" mov %1, %0 \n"
+" mov %0, %3 \n"
+" s32c1i %0, %2, 0 \n"
+" bne %1, %0, 1b \n"
+"2: \n"
+ : "=&a" (tmp), "=&a" (value)
+ : "a" (p), "a" (newval), "a" (oldval)
+ : "memory" );
+
+ return tmp == oldval;
}
/* Get some notion of the current stack. Need not be exactly the top
diff --git a/libpthread/linuxthreads.old/wrapsyscall.c b/libpthread/linuxthreads.old/wrapsyscall.c
index 466589ef9..668b3911c 100644
--- a/libpthread/linuxthreads.old/wrapsyscall.c
+++ b/libpthread/linuxthreads.old/wrapsyscall.c
@@ -1,4 +1,4 @@
-/* Wrapper arpund system calls to provide cancelation points.
+/* Wrapper around system calls to provide cancellation points.
Copyright (C) 1996,1997,1998,1999,2000,2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@@ -15,11 +15,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 __FORCE_GLIBC
-#include <features.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <pthread.h>
@@ -28,6 +25,7 @@
#include <stddef.h>
#include <stdlib.h>
#include <termios.h>
+#include <sys/epoll.h>
#include <sys/resource.h>
#include <sys/wait.h>
#include <sys/socket.h>
@@ -37,39 +35,40 @@
#ifndef __PIC__
/* We need a hook to force this file to be linked in when static
libpthread is used. */
-const int __pthread_provide_wrappers = 0;
+const char __pthread_provide_wrappers = 0;
#endif
-
-#define CANCELABLE_SYSCALL(res_type, name, param_list, params) \
-res_type __libc_##name param_list; \
-res_type \
-__attribute__ ((weak)) \
-name param_list \
-{ \
- res_type result; \
- int oldtype; \
- pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype); \
- result = __libc_##name params; \
- pthread_setcanceltype (oldtype, NULL); \
- return result; \
+/* Using private interface to libc (__libc_foo) to implement
+ * cancellable versions of some libc functions */
+#define CANCELABLE_SYSCALL(res_type, name, param_list, params) \
+res_type __libc_##name param_list; \
+res_type \
+__attribute__ ((weak)) \
+name param_list \
+{ \
+ res_type result; \
+ int oldtype; \
+ pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype); \
+ result = __libc_##name params; \
+ pthread_setcanceltype (oldtype, NULL); \
+ return result; \
}
-#define CANCELABLE_SYSCALL_VA(res_type, name, param_list, params, last_arg) \
-res_type __libc_##name param_list; \
-res_type \
-__attribute__ ((weak)) \
-name param_list \
-{ \
- res_type result; \
- int oldtype; \
- va_list ap; \
- pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype); \
- va_start (ap, last_arg); \
- result = __libc_##name params; \
- va_end (ap); \
- pthread_setcanceltype (oldtype, NULL); \
- return result; \
+#define CANCELABLE_SYSCALL_VA(res_type, name, param_list, params, last_arg) \
+res_type __libc_##name param_list; \
+res_type \
+__attribute__ ((weak)) \
+name param_list \
+{ \
+ res_type result; \
+ int oldtype; \
+ va_list ap; \
+ pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype); \
+ va_start (ap, last_arg); \
+ result = __libc_##name params; \
+ va_end (ap); \
+ pthread_setcanceltype (oldtype, NULL); \
+ return result; \
}
@@ -81,6 +80,12 @@ CANCELABLE_SYSCALL (int, close, (int fd), (fd))
CANCELABLE_SYSCALL_VA (int, fcntl, (int fd, int cmd, ...),
(fd, cmd, va_arg (ap, long int)), cmd)
+#if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 32
+/* fcntl64(2). */
+CANCELABLE_SYSCALL_VA (int, fcntl64, (int fd, int cmd, ...),
+ (fd, cmd, va_arg (ap, long int)), cmd)
+#endif
+
/* fsync(2). */
CANCELABLE_SYSCALL (int, fsync, (int fd), (fd))
@@ -183,7 +188,7 @@ libpthread_hidden_def(waitpid)
CANCELABLE_SYSCALL (ssize_t, write, (int fd, const void *buf, size_t n),
(fd, buf, n))
-
+#if defined __UCLIBC_HAS_SOCKET__
/* The following system calls are thread cancellation points specified
in XNS. */
@@ -225,3 +230,17 @@ CANCELABLE_SYSCALL (ssize_t, sendto, (int fd, const __ptr_t buf, size_t n,
int flags, __CONST_SOCKADDR_ARG addr,
socklen_t addr_len),
(fd, buf, n, flags, addr, addr_len))
+#endif /* __UCLIBC_HAS_SOCKET__ */
+
+#ifdef __UCLIBC_HAS_EPOLL__
+# include <sys/epoll.h>
+# ifdef __NR_epoll_wait
+CANCELABLE_SYSCALL (int, epoll_wait, (int epfd, struct epoll_event *events, int maxevents, int timeout),
+ (epfd, events, maxevents, timeout))
+# endif
+# ifdef __NR_epoll_pwait
+CANCELABLE_SYSCALL (int, epoll_pwait, (int epfd, struct epoll_event *events, int maxevents, int timeout,
+ const sigset_t *set),
+ (epfd, events, maxevents, timeout, set))
+# endif
+#endif
diff --git a/libpthread/linuxthreads.old_db/Makefile.in b/libpthread/linuxthreads.old_db/Makefile.in
index e99d4ddfc..cf0ceb394 100644
--- a/libpthread/linuxthreads.old_db/Makefile.in
+++ b/libpthread/linuxthreads.old_db/Makefile.in
@@ -1,12 +1,14 @@
# 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.
#
+subdirs += libpthread/linuxthreads.old_db
+
# Get the thread include dependencies and shared object name
-CFLAGS-linuxthreads.old_db := -DNOT_IN_libc -DLIBPTHREAD_SO="\"libpthread.so.$(MAJOR_VERSION)\""
+CFLAGS-libpthread/linuxthreads.old_db := -DNOT_IN_libc -DLIBPTHREAD_SO="\"libpthread.so.$(ABI_VERSION)\""
LDFLAGS-libthread_db.so := $(LDFLAGS_NOSTRIP) $(if $(call check_ld,--warn-unresolved-symbols),-Wl$(comma)--warn-unresolved-symbols)
ifeq ($(DOSTRIP),y)
@@ -33,9 +35,6 @@ endif
lib-a-$(PTHREADS_DEBUG_SUPPORT) += $(top_builddir)lib/libthread_db.a
lib-so-$(PTHREADS_DEBUG_SUPPORT) += $(top_builddir)lib/libthread_db.so
-objclean-y += libthread_db_clean
-headers-$(PTHREADS_DEBUG_SUPPORT) += linuxthreads_db_headers
-headers_clean-y += linuxthreads_db_headers_clean
#ifeq ($(DOMULTI),n)
ifeq ($(DOPIC),y)
@@ -62,11 +61,18 @@ $(top_builddir)lib/libthread_db.a: $(libthread_db-a-y)
$(Q)$(RM) $@
$(do_ar)
-linuxthreads_db_headers:
- $(Q)$(LN) -sf ../$(PTDIR)_db/thread_db.h $(top_builddir)include/
+$(top_builddir)include/thread_db.h:
+ $(do_ln) $(call rel_srcdir)$(PTDIR)_db/$(@F) $@
+
+linuxthreads_db_headers := $(top_builddir)include/thread_db.h
+$(linuxthreads_db_headers): $(wildcard $(addprefix $(top_builddir)include/config/linuxthreads/,old.h new.h))
+headers-$(PTHREADS_DEBUG_SUPPORT) += $(linuxthreads_db_headers)
+
+objclean-y += CLEAN_libpthread/linuxthreads.old_db
+headers_clean-y += HEADERCLEAN_libpthread/linuxthreads.old_db
-linuxthreads_db_headers_clean:
- $(RM) $(top_builddir)include/thread_db.h
+HEADERCLEAN_libpthread/linuxthreads.old_db:
+ $(do_rm) $(linuxthreads_db_headers)
-libthread_db_clean:
- $(RM) $(libthread_db_OUT)/*.{o,os,oS,a}
+CLEAN_libpthread/linuxthreads.old_db:
+ $(do_rm) $(addprefix $(libthread_db_OUT)/*., o os oS a)
diff --git a/libpthread/linuxthreads.old_db/proc_service.h b/libpthread/linuxthreads.old_db/proc_service.h
index 74136c03e..6f33ccdda 100644
--- a/libpthread/linuxthreads.old_db/proc_service.h
+++ b/libpthread/linuxthreads.old_db/proc_service.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/>. */
/* The definitions in this file must correspond to those in the debugger. */
#include <sys/procfs.h>
diff --git a/libpthread/linuxthreads.old_db/td_init.c b/libpthread/linuxthreads.old_db/td_init.c
index 6f0e1584c..ecb0d3de2 100644
--- a/libpthread/linuxthreads.old_db/td_init.c
+++ b/libpthread/linuxthreads.old_db/td_init.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads.old_db/td_log.c b/libpthread/linuxthreads.old_db/td_log.c
index 025273a63..c82ffa54d 100644
--- a/libpthread/linuxthreads.old_db/td_log.c
+++ b/libpthread/linuxthreads.old_db/td_log.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads.old_db/td_symbol_list.c b/libpthread/linuxthreads.old_db/td_symbol_list.c
index 599c04596..fd29333d5 100644
--- a/libpthread/linuxthreads.old_db/td_symbol_list.c
+++ b/libpthread/linuxthreads.old_db/td_symbol_list.c
@@ -14,19 +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 <assert.h>
#include "thread_dbP.h"
-#ifdef HAVE_ASM_GLOBAL_DOT_NAME
-# define DOT "." /* PPC64 requires . prefix on code symbols. */
-#else
-# define DOT /* No prefix. */
-#endif
-
static const char *symbol_list_arr[] =
{
[PTHREAD_THREADS_EVENTS] = "__pthread_threads_events",
@@ -37,9 +30,9 @@ static const char *symbol_list_arr[] =
[LINUXTHREADS_PTHREAD_THREADS_MAX] = "__linuxthreads_pthread_threads_max",
[LINUXTHREADS_PTHREAD_KEYS_MAX] = "__linuxthreads_pthread_keys_max",
[LINUXTHREADS_PTHREAD_SIZEOF_DESCR] = "__linuxthreads_pthread_sizeof_descr",
- [LINUXTHREADS_CREATE_EVENT] = DOT "__linuxthreads_create_event",
- [LINUXTHREADS_DEATH_EVENT] = DOT "__linuxthreads_death_event",
- [LINUXTHREADS_REAP_EVENT] = DOT "__linuxthreads_reap_event",
+ [LINUXTHREADS_CREATE_EVENT] = "__linuxthreads_create_event",
+ [LINUXTHREADS_DEATH_EVENT] = "__linuxthreads_death_event",
+ [LINUXTHREADS_REAP_EVENT] = "__linuxthreads_reap_event",
[LINUXTHREADS_INITIAL_REPORT_EVENTS] = "__linuxthreads_initial_report_events",
[LINUXTHREADS_VERSION] = "__linuxthreads_version",
[NUM_MESSAGES] = NULL
diff --git a/libpthread/linuxthreads.old_db/td_ta_clear_event.c b/libpthread/linuxthreads.old_db/td_ta_clear_event.c
index cbb7ddc97..e827b46ae 100644
--- a/libpthread/linuxthreads.old_db/td_ta_clear_event.c
+++ b/libpthread/linuxthreads.old_db/td_ta_clear_event.c
@@ -14,17 +14,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 "thread_dbP.h"
td_err_e
-td_ta_clear_event (ta, event)
- const td_thragent_t *ta;
- td_thr_events_t *event;
+td_ta_clear_event(const td_thragent_t *ta,td_thr_events_t *event)
{
td_thr_events_t old_event;
int i;
diff --git a/libpthread/linuxthreads.old_db/td_ta_delete.c b/libpthread/linuxthreads.old_db/td_ta_delete.c
index 0e6ec17d0..9bc5c08ac 100644
--- a/libpthread/linuxthreads.old_db/td_ta_delete.c
+++ b/libpthread/linuxthreads.old_db/td_ta_delete.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/>. */
#include <stdlib.h>
@@ -45,7 +44,7 @@ td_ta_delete (td_thragent_t *ta)
runp = runp->next;
if (runp->next == NULL)
- /* It's not a valid decriptor since it is not in the list. */
+ /* It's not a valid descriptor since it is not in the list. */
return TD_BADTA;
runp->next = runp->next->next;
diff --git a/libpthread/linuxthreads.old_db/td_ta_enable_stats.c b/libpthread/linuxthreads.old_db/td_ta_enable_stats.c
index 1d4c34a8d..9d3408ece 100644
--- a/libpthread/linuxthreads.old_db/td_ta_enable_stats.c
+++ b/libpthread/linuxthreads.old_db/td_ta_enable_stats.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads.old_db/td_ta_event_addr.c b/libpthread/linuxthreads.old_db/td_ta_event_addr.c
index 8bce35ae8..72d426555 100644
--- a/libpthread/linuxthreads.old_db/td_ta_event_addr.c
+++ b/libpthread/linuxthreads.old_db/td_ta_event_addr.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads.old_db/td_ta_event_getmsg.c b/libpthread/linuxthreads.old_db/td_ta_event_getmsg.c
index ba535da79..b7c2fcd72 100644
--- a/libpthread/linuxthreads.old_db/td_ta_event_getmsg.c
+++ b/libpthread/linuxthreads.old_db/td_ta_event_getmsg.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/>. */
#include <stddef.h>
#include <string.h>
diff --git a/libpthread/linuxthreads.old_db/td_ta_get_nthreads.c b/libpthread/linuxthreads.old_db/td_ta_get_nthreads.c
index 839b56be5..144f4ffee 100644
--- a/libpthread/linuxthreads.old_db/td_ta_get_nthreads.c
+++ b/libpthread/linuxthreads.old_db/td_ta_get_nthreads.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads.old_db/td_ta_get_ph.c b/libpthread/linuxthreads.old_db/td_ta_get_ph.c
index 23d328508..fdf44fbe1 100644
--- a/libpthread/linuxthreads.old_db/td_ta_get_ph.c
+++ b/libpthread/linuxthreads.old_db/td_ta_get_ph.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads.old_db/td_ta_get_stats.c b/libpthread/linuxthreads.old_db/td_ta_get_stats.c
index 6bf2f5352..eca9ba5b4 100644
--- a/libpthread/linuxthreads.old_db/td_ta_get_stats.c
+++ b/libpthread/linuxthreads.old_db/td_ta_get_stats.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads.old_db/td_ta_map_id2thr.c b/libpthread/linuxthreads.old_db/td_ta_map_id2thr.c
index c57f25a5a..dc24533b8 100644
--- a/libpthread/linuxthreads.old_db/td_ta_map_id2thr.c
+++ b/libpthread/linuxthreads.old_db/td_ta_map_id2thr.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads.old_db/td_ta_map_lwp2thr.c b/libpthread/linuxthreads.old_db/td_ta_map_lwp2thr.c
index 2be1e3de5..00efc43d6 100644
--- a/libpthread/linuxthreads.old_db/td_ta_map_lwp2thr.c
+++ b/libpthread/linuxthreads.old_db/td_ta_map_lwp2thr.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads.old_db/td_ta_new.c b/libpthread/linuxthreads.old_db/td_ta_new.c
index 2b0b68bf0..7cf0edc66 100644
--- a/libpthread/linuxthreads.old_db/td_ta_new.c
+++ b/libpthread/linuxthreads.old_db/td_ta_new.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/>. */
#include <stddef.h>
#include <stdlib.h>
diff --git a/libpthread/linuxthreads.old_db/td_ta_reset_stats.c b/libpthread/linuxthreads.old_db/td_ta_reset_stats.c
index b3ddbd07b..ce41e1751 100644
--- a/libpthread/linuxthreads.old_db/td_ta_reset_stats.c
+++ b/libpthread/linuxthreads.old_db/td_ta_reset_stats.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads.old_db/td_ta_set_event.c b/libpthread/linuxthreads.old_db/td_ta_set_event.c
index 6edb38e57..3a75e7b7f 100644
--- a/libpthread/linuxthreads.old_db/td_ta_set_event.c
+++ b/libpthread/linuxthreads.old_db/td_ta_set_event.c
@@ -14,17 +14,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 "thread_dbP.h"
td_err_e
-td_ta_set_event (ta, event)
- const td_thragent_t *ta;
- td_thr_events_t *event;
+td_ta_set_event(const td_thragent_t *ta,td_thr_events_t *event)
{
td_thr_events_t old_event;
int i;
diff --git a/libpthread/linuxthreads.old_db/td_ta_setconcurrency.c b/libpthread/linuxthreads.old_db/td_ta_setconcurrency.c
index 408e76309..111dfd583 100644
--- a/libpthread/linuxthreads.old_db/td_ta_setconcurrency.c
+++ b/libpthread/linuxthreads.old_db/td_ta_setconcurrency.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads.old_db/td_ta_thr_iter.c b/libpthread/linuxthreads.old_db/td_ta_thr_iter.c
index 771a12de4..da230096f 100644
--- a/libpthread/linuxthreads.old_db/td_ta_thr_iter.c
+++ b/libpthread/linuxthreads.old_db/td_ta_thr_iter.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/>. */
#include "thread_dbP.h"
#include <alloca.h>
diff --git a/libpthread/linuxthreads.old_db/td_ta_tsd_iter.c b/libpthread/linuxthreads.old_db/td_ta_tsd_iter.c
index 7ad98dd91..758222cd7 100644
--- a/libpthread/linuxthreads.old_db/td_ta_tsd_iter.c
+++ b/libpthread/linuxthreads.old_db/td_ta_tsd_iter.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/>. */
#include "thread_dbP.h"
#include <alloca.h>
diff --git a/libpthread/linuxthreads.old_db/td_thr_clear_event.c b/libpthread/linuxthreads.old_db/td_thr_clear_event.c
index 147d18037..67a592a10 100644
--- a/libpthread/linuxthreads.old_db/td_thr_clear_event.c
+++ b/libpthread/linuxthreads.old_db/td_thr_clear_event.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/>. */
#include <stddef.h>
@@ -24,9 +23,7 @@
td_err_e
-td_thr_clear_event (th, event)
- const td_thrhandle_t *th;
- td_thr_events_t *event;
+td_thr_clear_event(const td_thrhandle_t *th,td_thr_events_t *event)
{
td_thr_events_t old_event;
int i;
diff --git a/libpthread/linuxthreads.old_db/td_thr_dbresume.c b/libpthread/linuxthreads.old_db/td_thr_dbresume.c
index 7b7f6eef9..3e63d8f41 100644
--- a/libpthread/linuxthreads.old_db/td_thr_dbresume.c
+++ b/libpthread/linuxthreads.old_db/td_thr_dbresume.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads.old_db/td_thr_dbsuspend.c b/libpthread/linuxthreads.old_db/td_thr_dbsuspend.c
index ef668023d..557e88862 100644
--- a/libpthread/linuxthreads.old_db/td_thr_dbsuspend.c
+++ b/libpthread/linuxthreads.old_db/td_thr_dbsuspend.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads.old_db/td_thr_event_enable.c b/libpthread/linuxthreads.old_db/td_thr_event_enable.c
index 407f3fc44..d55a2ce75 100644
--- a/libpthread/linuxthreads.old_db/td_thr_event_enable.c
+++ b/libpthread/linuxthreads.old_db/td_thr_event_enable.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/>. */
#include <stddef.h>
@@ -24,9 +23,7 @@
td_err_e
-td_thr_event_enable (th, onoff)
- const td_thrhandle_t *th;
- int onoff;
+td_thr_event_enable(const td_thrhandle_t *th, int onoff)
{
LOG ("td_thr_event_enable");
diff --git a/libpthread/linuxthreads.old_db/td_thr_event_getmsg.c b/libpthread/linuxthreads.old_db/td_thr_event_getmsg.c
index bf4ddd4ad..d4db08b6f 100644
--- a/libpthread/linuxthreads.old_db/td_thr_event_getmsg.c
+++ b/libpthread/linuxthreads.old_db/td_thr_event_getmsg.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/>. */
#include <stddef.h>
#include <string.h>
diff --git a/libpthread/linuxthreads.old_db/td_thr_get_info.c b/libpthread/linuxthreads.old_db/td_thr_get_info.c
index 4666bda97..c73f33020 100644
--- a/libpthread/linuxthreads.old_db/td_thr_get_info.c
+++ b/libpthread/linuxthreads.old_db/td_thr_get_info.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/>. */
#include <stddef.h>
#include <string.h>
diff --git a/libpthread/linuxthreads.old_db/td_thr_getfpregs.c b/libpthread/linuxthreads.old_db/td_thr_getfpregs.c
index 31c55c876..0fc22097e 100644
--- a/libpthread/linuxthreads.old_db/td_thr_getfpregs.c
+++ b/libpthread/linuxthreads.old_db/td_thr_getfpregs.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads.old_db/td_thr_getgregs.c b/libpthread/linuxthreads.old_db/td_thr_getgregs.c
index a9ec6a37d..a33789847 100644
--- a/libpthread/linuxthreads.old_db/td_thr_getgregs.c
+++ b/libpthread/linuxthreads.old_db/td_thr_getgregs.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads.old_db/td_thr_getxregs.c b/libpthread/linuxthreads.old_db/td_thr_getxregs.c
index 39cd73cf1..b98e19dd8 100644
--- a/libpthread/linuxthreads.old_db/td_thr_getxregs.c
+++ b/libpthread/linuxthreads.old_db/td_thr_getxregs.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads.old_db/td_thr_getxregsize.c b/libpthread/linuxthreads.old_db/td_thr_getxregsize.c
index 5d8ac288e..d7b4b13bb 100644
--- a/libpthread/linuxthreads.old_db/td_thr_getxregsize.c
+++ b/libpthread/linuxthreads.old_db/td_thr_getxregsize.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads.old_db/td_thr_set_event.c b/libpthread/linuxthreads.old_db/td_thr_set_event.c
index 1e1def511..31a04f1e6 100644
--- a/libpthread/linuxthreads.old_db/td_thr_set_event.c
+++ b/libpthread/linuxthreads.old_db/td_thr_set_event.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/>. */
#include <stddef.h>
@@ -24,9 +23,7 @@
td_err_e
-td_thr_set_event (th, event)
- const td_thrhandle_t *th;
- td_thr_events_t *event;
+td_thr_set_event(const td_thrhandle_t *th, td_thr_events_t *event)
{
td_thr_events_t old_event;
int i;
diff --git a/libpthread/linuxthreads.old_db/td_thr_setfpregs.c b/libpthread/linuxthreads.old_db/td_thr_setfpregs.c
index e4d9ec65e..793d02ed3 100644
--- a/libpthread/linuxthreads.old_db/td_thr_setfpregs.c
+++ b/libpthread/linuxthreads.old_db/td_thr_setfpregs.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads.old_db/td_thr_setgregs.c b/libpthread/linuxthreads.old_db/td_thr_setgregs.c
index 8c021a473..32e394b63 100644
--- a/libpthread/linuxthreads.old_db/td_thr_setgregs.c
+++ b/libpthread/linuxthreads.old_db/td_thr_setgregs.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads.old_db/td_thr_setprio.c b/libpthread/linuxthreads.old_db/td_thr_setprio.c
index 98d202dfe..554e8ffc9 100644
--- a/libpthread/linuxthreads.old_db/td_thr_setprio.c
+++ b/libpthread/linuxthreads.old_db/td_thr_setprio.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads.old_db/td_thr_setsigpending.c b/libpthread/linuxthreads.old_db/td_thr_setsigpending.c
index 98e30140e..c6729b4c0 100644
--- a/libpthread/linuxthreads.old_db/td_thr_setsigpending.c
+++ b/libpthread/linuxthreads.old_db/td_thr_setsigpending.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads.old_db/td_thr_setxregs.c b/libpthread/linuxthreads.old_db/td_thr_setxregs.c
index da77ab3b4..cb6b7e2fe 100644
--- a/libpthread/linuxthreads.old_db/td_thr_setxregs.c
+++ b/libpthread/linuxthreads.old_db/td_thr_setxregs.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads.old_db/td_thr_sigsetmask.c b/libpthread/linuxthreads.old_db/td_thr_sigsetmask.c
index 8b0eb8185..e990101d3 100644
--- a/libpthread/linuxthreads.old_db/td_thr_sigsetmask.c
+++ b/libpthread/linuxthreads.old_db/td_thr_sigsetmask.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads.old_db/td_thr_tls_get_addr.c b/libpthread/linuxthreads.old_db/td_thr_tls_get_addr.c
index a28b07450..ac4d706c4 100644
--- a/libpthread/linuxthreads.old_db/td_thr_tls_get_addr.c
+++ b/libpthread/linuxthreads.old_db/td_thr_tls_get_addr.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/>. */
#include <link.h>
#include "thread_dbP.h"
@@ -31,7 +30,7 @@ td_thr_tls_get_addr (const td_thrhandle_t *th __attribute__ ((unused)),
size_t offset __attribute__ ((unused)),
void **address __attribute__ ((unused)))
{
-#if USE_TLS
+#if defined(USE_TLS) && USE_TLS
size_t modid;
union dtv pdtv, *dtvp;
diff --git a/libpthread/linuxthreads.old_db/td_thr_tsd.c b/libpthread/linuxthreads.old_db/td_thr_tsd.c
index 2ab71c588..f18832f46 100644
--- a/libpthread/linuxthreads.old_db/td_thr_tsd.c
+++ b/libpthread/linuxthreads.old_db/td_thr_tsd.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads.old_db/td_thr_validate.c b/libpthread/linuxthreads.old_db/td_thr_validate.c
index 2cf7727b6..ca82637b9 100644
--- a/libpthread/linuxthreads.old_db/td_thr_validate.c
+++ b/libpthread/linuxthreads.old_db/td_thr_validate.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads.old_db/thread_db.h b/libpthread/linuxthreads.old_db/thread_db.h
index c115399a3..13c30af5b 100644
--- a/libpthread/linuxthreads.old_db/thread_db.h
+++ b/libpthread/linuxthreads.old_db/thread_db.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 _THREAD_DB_H
#define _THREAD_DB_H 1
diff --git a/libpthread/linuxthreads.old_db/thread_dbP.h b/libpthread/linuxthreads.old_db/thread_dbP.h
index b120c42b3..64fd2e511 100644
--- a/libpthread/linuxthreads.old_db/thread_dbP.h
+++ b/libpthread/linuxthreads.old_db/thread_dbP.h
@@ -2,8 +2,6 @@
#ifndef _THREAD_DBP_H
#define _THREAD_DBP_H 1
-#define __FORCE_GLIBC
-#include <features.h>
#include <string.h>
#include <unistd.h>
#include "proc_service.h"
diff --git a/libpthread/linuxthreads/.cvsignore b/libpthread/linuxthreads/.cvsignore
deleted file mode 100644
index 688daf411..000000000
--- a/libpthread/linuxthreads/.cvsignore
+++ /dev/null
@@ -1,3 +0,0 @@
-.cvsignore
-*.os
-Makefile.in
diff --git a/libpthread/linuxthreads/Makefile.in b/libpthread/linuxthreads/Makefile.in
index b7c8914f5..c1ec1c9c7 100644
--- a/libpthread/linuxthreads/Makefile.in
+++ b/libpthread/linuxthreads/Makefile.in
@@ -1,17 +1,17 @@
# Makefile for uClibc
#
# Copyright (C) 2003 Paul Mundt <lethal@linux-sh.org>
-# 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.
#
-CFLAGS-dir_linuxthreads := -DNOT_IN_libc -DIS_IN_libpthread
-CFLAGS-linuxthreads := $(CFLAGS-dir_linuxthreads) $(SSP_ALL_CFLAGS)
+subdirs += libpthread/linuxthreads/sysdeps/$(TARGET_ARCH)
+subdirs += libpthread/linuxthreads/sysdeps/unix/sysv/linux
+subdirs += libpthread/linuxthreads/sysdeps/pthread
-CFLAGS-libpthread/linuxthreads/sysdeps/$(TARGET_ARCH)/ := $(CFLAGS-linuxthreads)
-CFLAGS-libpthread/linuxthreads/sysdeps/unix/sysv/linux/ := $(CFLAGS-linuxthreads)
-CFLAGS-libpthread/linuxthreads/sysdeps/pthread/ := $(CFLAGS-linuxthreads)
+CFLAGS-dir_linuxthreads := -DNOT_IN_libc -DIS_IN_libpthread
+CFLAGS-libpthread/linuxthreads := $(CFLAGS-dir_linuxthreads) $(SSP_ALL_CFLAGS)
# This stuff will not compile without at least -O1
# psm: can't handle this here, could maybe search for -O0 in CFLAGS
@@ -65,7 +65,7 @@ CFLAGS-OMIT-libc_pthread_init.c := $(CFLAGS-dir_linuxthreads)
libpthread_libc_CSRC := \
forward.c libc-cancellation.c libc_pthread_init.c # alloca_cutoff.c
libpthread_libc_OBJ := $(patsubst %.c, $(libpthread_OUT)/%.o,$(libpthread_libc_CSRC))
-libc-static-y += $(libpthread_OUT)/libc_pthread_init.o
+libc-static-y += $(libpthread_OUT)/libc_pthread_init.o $(libpthread_OUT)/libc-cancellation.o
libc-shared-y += $(libpthread_libc_OBJ:.o=.oS)
libpthread-static-y += $(patsubst %,$(libpthread_OUT)/%.o,$(libpthread_static_SRC))
@@ -81,20 +81,18 @@ libpthread-so-y += $(libpthread_OBJ:.o=.oS)
lib-a-$(UCLIBC_HAS_THREADS) += $(top_builddir)lib/libpthread.a
lib-so-$(UCLIBC_HAS_THREADS) += $(top_builddir)lib/libpthread.so
-objclean-y += libpthread_clean
-headers-$(UCLIBC_HAS_THREADS) += linuxthreads_headers
-headers_clean-y += linuxthreads_headers_clean
#ifeq ($(DOMULTI),n)
$(top_builddir)lib/libpthread.so: $(libpthread_OUT)/libpthread_so.a $(libc.depend) $(top_builddir)lib/libpthread_nonshared.a
- $(call link.so,$(libpthread_FULL_NAME),$(MAJOR_VERSION))
+ $(call link.so,$(libpthread_FULL_NAME),$(ABI_VERSION))
#else
#$(top_builddir)lib/libpthread.so: $(libpthread_OUT)/libpthread.oS | $(libc.depend) $(top_builddir)lib/libpthread_nonshared.a
-# $(call linkm.so,$(libpthread_FULL_NAME),$(MAJOR_VERSION))
+# $(call linkm.so,$(libpthread_FULL_NAME),$(ABI_VERSION))
#endif
$(Q)$(RM) $@
- $(Q)cp $(top_srcdir)extra/scripts/format.lds $@
- $(Q)echo "GROUP ( $(notdir $@).$(MAJOR_VERSION) libpthread_nonshared.a )" >> $@
+ $(Q)cat $(top_srcdir)extra/scripts/format.lds > $@.tmp
+ $(Q)echo "GROUP ( $(notdir $@).$(ABI_VERSION) libpthread_nonshared.a )" >> $@.tmp
+ $(Q)mv $@.tmp $@
ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
$(libpthread_OUT)/libpthread_so.a: STRIP_FLAGS:=$(STRIP_FLAGS:-x=-X --strip-debug)
@@ -118,19 +116,23 @@ $(top_builddir)lib/libpthread.a: $(libpthread-a-y)
$(Q)$(RM) $@
$(do_ar)
-include/pthread.h:
- $(do_ln) ../$(PTDIR)/sysdeps/pthread/$(@F) $(top_builddir)$@
-include/semaphore.h:
- $(do_ln) ../$(PTDIR)/$(@F) $(top_builddir)$@
-include/bits/pthreadtypes.h: | include/bits
- $(do_ln) ../../$(PTDIR)/sysdeps/pthread/bits/$(@F) $(top_builddir)$@
-linuxthreads_headers: include/pthread.h include/semaphore.h \
- include/bits/pthreadtypes.h
-
-linuxthreads_headers_clean:
- $(RM) $(top_builddir)include/pthread.h \
- $(top_builddir)include/semaphore.h \
- $(top_builddir)include/bits/pthreadtypes.h
-
-libpthread_clean:
- $(RM) $(libpthread_OUT)/{,*/,*/*/,*/*/*/,*/*/*/*/}*.{o,os,oS,a}
+$(top_builddir)include/pthread.h:
+ $(do_ln) $(call rel_srcdir)$(PTDIR)/sysdeps/pthread/$(@F) $@
+$(top_builddir)include/semaphore.h:
+ $(do_ln) $(call rel_srcdir)$(PTDIR)/$(@F) $@
+$(top_builddir)include/bits/pthreadtypes.h: | $(top_builddir)include/bits
+ $(do_ln) $(call rel_srcdir)$(PTDIR)/sysdeps/pthread/bits/$(@F) $@
+
+linuxthreads_headers := $(top_builddir)include/pthread.h \
+ $(top_builddir)include/semaphore.h \
+ $(top_builddir)include/bits/pthreadtypes.h
+$(linuxthreads_headers): $(wildcard $(addprefix $(top_builddir)include/config/linuxthreads/,old.h new.h))
+headers-$(UCLIBC_HAS_THREADS) += $(linuxthreads_headers)
+
+objclean-y += CLEAN_libpthread/linuxthreads
+headers_clean-y += HEADERCLEAN_libpthread/linuxthreads
+HEADERCLEAN_libpthread/linuxthreads:
+ $(do_rm) $(linuxthreads_headers)
+
+CLEAN_libpthread/linuxthreads:
+ $(do_rm) $(addprefix $(libpthread_OUT)/,$(foreach e, o os oS a,$(foreach d, *. */*. */*/*. */*/*/*.,$(d)$(e))))
diff --git a/libpthread/linuxthreads/alloca_cutoff.c b/libpthread/linuxthreads/alloca_cutoff.c
index ca064b3bb..9fe13a39d 100644
--- a/libpthread/linuxthreads/alloca_cutoff.c
+++ b/libpthread/linuxthreads/alloca_cutoff.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; 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/>. */
#include <alloca.h>
#include <stdlib.h>
diff --git a/libpthread/linuxthreads/attr.c b/libpthread/linuxthreads/attr.c
index 52e115c8e..959ffda99 100644
--- a/libpthread/linuxthreads/attr.c
+++ b/libpthread/linuxthreads/attr.c
@@ -172,9 +172,6 @@ int __pthread_attr_setstackaddr(pthread_attr_t *attr, void *stackaddr)
}
weak_alias (__pthread_attr_setstackaddr, pthread_attr_setstackaddr)
-link_warning (pthread_attr_setstackaddr,
- "the use of `pthread_attr_setstackaddr' is deprecated, use `pthread_attr_setstack'")
-
int __pthread_attr_getstackaddr(const pthread_attr_t *attr, void **stackaddr)
{
/* XXX This function has a stupid definition. The standard specifies
@@ -185,8 +182,6 @@ int __pthread_attr_getstackaddr(const pthread_attr_t *attr, void **stackaddr)
}
weak_alias (__pthread_attr_getstackaddr, pthread_attr_getstackaddr)
-link_warning (pthread_attr_getstackaddr,
- "the use of `pthread_attr_getstackaddr' is deprecated, use `pthread_attr_getstack'")
#endif
@@ -361,7 +356,7 @@ int pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
attr->__scope = PTHREAD_SCOPE_SYSTEM;
#ifdef _STACK_GROWS_DOWN
-# ifdef USE_TLS
+# ifdef __UCLIBC_HAS_TLS__
attr->__stacksize = descr->p_stackaddr - (char *)descr->p_guardaddr
- descr->p_guardsize;
# else
@@ -369,7 +364,7 @@ int pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
- descr->p_guardsize;
# endif
#else
-# ifdef USE_TLS
+# ifdef __UCLIBC_HAS_TLS__
attr->__stacksize = (char *)descr->p_guardaddr - descr->p_stackaddr;
# else
attr->__stacksize = (char *)descr->p_guardaddr - (char *)descr;
@@ -385,7 +380,7 @@ int pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
otherwise the range of the stack area cannot be computed. */
attr->__stacksize += attr->__guardsize;
#endif
-#ifdef USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
attr->__stackaddr = descr->p_stackaddr;
#else
# ifndef _STACK_GROWS_UP
@@ -395,7 +390,7 @@ int pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
# endif
#endif
-#ifdef USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
if (attr->__stackaddr == NULL)
#else
if (descr == &__pthread_initial_thread)
diff --git a/libpthread/linuxthreads/barrier.c b/libpthread/linuxthreads/barrier.c
index 37d997cfc..2e2521b19 100644
--- a/libpthread/linuxthreads/barrier.c
+++ b/libpthread/linuxthreads/barrier.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; 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/>. */
#include <errno.h>
#include "pthread.h"
diff --git a/libpthread/linuxthreads/cancel.c b/libpthread/linuxthreads/cancel.c
index 34356801a..21b8d900c 100644
--- a/libpthread/linuxthreads/cancel.c
+++ b/libpthread/linuxthreads/cancel.c
@@ -15,7 +15,6 @@
/* Thread cancellation */
#include <errno.h>
-#include <libc-internal.h>
#include "pthread.h"
#include "internals.h"
#include "spinlock.h"
@@ -23,7 +22,7 @@
#ifdef _STACK_GROWS_DOWN
# define FRAME_LEFT(frame, other) ((char *) frame >= (char *) other)
-#elif _STACK_GROWS_UP
+#elif defined _STACK_GROWS_UP
# define FRAME_LEFT(frame, other) ((char *) frame <= (char *) other)
#else
# error "Define either _STACK_GROWS_DOWN or _STACK_GROWS_UP"
diff --git a/libpthread/linuxthreads/descr.h b/libpthread/linuxthreads/descr.h
index 24ec30b41..1c816b225 100644
--- a/libpthread/linuxthreads/descr.h
+++ b/libpthread/linuxthreads/descr.h
@@ -23,7 +23,7 @@
#include <stdint.h>
#include <sys/types.h>
#include <hp-timing.h>
-#ifdef USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
#include <tls.h>
#endif
#include "uClibc-glue.h"
@@ -112,7 +112,7 @@ union dtv;
struct _pthread_descr_struct
{
-#if !defined USE_TLS || !TLS_DTV_AT_TP || INCLUDE_TLS_PADDING
+#if !defined __UCLIBC_HAS_TLS__ || !TLS_DTV_AT_TP || INCLUDE_TLS_PADDING
/* This overlaps tcbhead_t (see tls.h), as used for TLS without threads. */
union
{
@@ -123,9 +123,7 @@ struct _pthread_descr_struct
union dtv *dtvp;
pthread_descr self; /* Pointer to this structure */
int multiple_threads;
-# ifdef NEED_DL_SYSINFO
uintptr_t sysinfo;
-# endif
} data;
void *__padding[16];
} p_header;
@@ -159,7 +157,7 @@ struct _pthread_descr_struct
char p_sigwaiting; /* true if a sigwait() is in progress */
struct pthread_start_args p_start_args; /* arguments for thread creation */
void ** p_specific[PTHREAD_KEY_1STLEVEL_SIZE]; /* thread-specific data */
-#if !(USE_TLS && HAVE___THREAD)
+#ifndef __UCLIBC_HAS_TLS__
void * p_libc_specific[_LIBC_TSD_KEY_N]; /* thread-specific data for libc */
int * p_errnop; /* pointer to used errno variable */
int p_errno; /* error returned by last system call */
@@ -187,7 +185,7 @@ struct _pthread_descr_struct
#if HP_TIMING_AVAIL
hp_timing_t p_cpuclock_offset; /* Initial CPU clock for thread. */
#endif
-#ifdef USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
char *p_stackaddr; /* Stack address. */
#endif
size_t p_alloca_cutoff; /* Maximum size which should be allocated
diff --git a/libpthread/linuxthreads/errno.c b/libpthread/linuxthreads/errno.c
index 03c23f867..b8d9eb343 100644
--- a/libpthread/linuxthreads/errno.c
+++ b/libpthread/linuxthreads/errno.c
@@ -20,7 +20,7 @@
#include "pthread.h"
#include "internals.h"
-#if !USE_TLS || !HAVE___THREAD
+#ifndef __UCLIBC_HAS_TLS__
/* The definition in libc is sufficient if we use TLS. */
int *
__errno_location (void)
diff --git a/libpthread/linuxthreads/events.c b/libpthread/linuxthreads/events.c
index b4ca3846e..62bf122fa 100644
--- a/libpthread/linuxthreads/events.c
+++ b/libpthread/linuxthreads/events.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; 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 functions contained here do nothing, they just return. */
diff --git a/libpthread/linuxthreads/forward.c b/libpthread/linuxthreads/forward.c
index 2cd019651..486d254dc 100644
--- a/libpthread/linuxthreads/forward.c
+++ b/libpthread/linuxthreads/forward.c
@@ -13,21 +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/>. */
#include <features.h>
#include <stdlib.h>
#include <dlfcn.h>
/* psm: keep this before internals.h */
-libc_hidden_proto(exit)
#include "internals.h"
/* Pointers to the libc functions. */
-struct pthread_functions __libc_pthread_functions attribute_hidden;
+struct pthread_functions __libc_pthread_functions;
# define FORWARD2(name, rettype, decl, params, defaction) \
diff --git a/libpthread/linuxthreads/internals.h b/libpthread/linuxthreads/internals.h
index ecb7b03dd..00c7078ee 100644
--- a/libpthread/linuxthreads/internals.h
+++ b/libpthread/linuxthreads/internals.h
@@ -30,7 +30,7 @@
#include <bits/sigcontextinfo.h>
#include <bits/pthreadtypes.h>
-#ifdef USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
#include <tls.h>
#endif
#include "descr.h"
@@ -200,19 +200,17 @@ static __inline__ int nonexisting_handle(pthread_handle h, pthread_t id)
/* The page size we can get from the system. This should likely not be
changed by the machine file but, you never know. */
-#ifndef PAGE_SIZE
-#define PAGE_SIZE (sysconf (_SC_PAGE_SIZE))
-#endif
+#define __PAGE_SIZE (sysconf (_SC_PAGESIZE))
-/* The initial size of the thread stack. Must be a multiple of PAGE_SIZE. */
+/* The initial size of the thread stack. Must be a multiple of __PAGE_SIZE. */
#ifndef INITIAL_STACK_SIZE
-#define INITIAL_STACK_SIZE (4 * PAGE_SIZE)
+#define INITIAL_STACK_SIZE (4 * __PAGE_SIZE)
#endif
/* Size of the thread manager stack. The "- 32" avoids wasting space
with some malloc() implementations. */
#ifndef THREAD_MANAGER_STACK_SIZE
-#define THREAD_MANAGER_STACK_SIZE (2 * PAGE_SIZE - 32)
+#define THREAD_MANAGER_STACK_SIZE (2 * __PAGE_SIZE - 32)
#endif
/* The base of the "array" of thread stacks. The array will grow down from
@@ -285,7 +283,7 @@ extern void __pthread_destroy_specifics (void);
extern void __pthread_perform_cleanup (char *currentframe);
extern void __pthread_init_max_stacksize (void);
extern int __pthread_initialize_manager (void);
-extern void __pthread_message (const char * fmt, ...);
+extern void __pthread_message (const char * fmt, ...) attribute_hidden;
extern int __pthread_manager (void *reqfd);
extern int __pthread_manager_event (void *reqfd);
extern void __pthread_manager_sighandler (int sig);
@@ -347,7 +345,7 @@ extern int __pthread_mutexattr_gettype (const pthread_mutexattr_t *__attr,
int *__kind);
extern void __pthread_kill_other_threads_np (void);
extern int __pthread_mutex_init (pthread_mutex_t *__mutex,
- __const pthread_mutexattr_t *__mutex_attr);
+ const pthread_mutexattr_t *__mutex_attr);
extern int __pthread_mutex_destroy (pthread_mutex_t *__mutex);
extern int __pthread_mutex_lock (pthread_mutex_t *__mutex);
extern int __pthread_mutex_trylock (pthread_mutex_t *__mutex);
@@ -393,14 +391,14 @@ extern void __pthread_wait_for_restart_signal(pthread_descr self);
extern void __pthread_sigsuspend (const sigset_t *mask) attribute_hidden;
extern int __pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock,
- __const struct timespec *__restrict
+ const struct timespec *__restrict
__abstime);
extern int __pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock,
- __const struct timespec *__restrict
+ const struct timespec *__restrict
__abstime);
extern int __pthread_rwlockattr_destroy (pthread_rwlockattr_t *__attr);
-extern int __pthread_barrierattr_getpshared (__const pthread_barrierattr_t *
+extern int __pthread_barrierattr_getpshared (const pthread_barrierattr_t *
__restrict __attr,
int *__restrict __pshared);
@@ -416,11 +414,6 @@ extern void (*__pthread_restart)(pthread_descr);
extern void (*__pthread_suspend)(pthread_descr);
extern int (*__pthread_timedsuspend)(pthread_descr, const struct timespec *);
-/* Prototypes for the function without cancelation support when the
- normal version has it. */
-extern int __libc_close (int fd);
-extern int __libc_nanosleep (const struct timespec *requested_time,
- struct timespec *remaining);
/* Prototypes for some of the new semaphore functions. */
extern int sem_post (sem_t * sem);
extern int sem_init (sem_t *__sem, int __pshared, unsigned int __value);
@@ -445,10 +438,12 @@ extern void __linuxthreads_reap_event (void);
extern void __pthread_initialize (void);
/* TSD. */
+#if !defined __UCLIBC_HAS_TLS__ && defined __UCLIBC_HAS_RPC__
extern int __pthread_internal_tsd_set (int key, const void * pointer);
extern void * __pthread_internal_tsd_get (int key);
extern void ** __attribute__ ((__const__))
__pthread_internal_tsd_address (int key);
+#endif
/* Sighandler wrappers. */
extern void __pthread_sighandler(int signo, SIGCONTEXT ctx);
@@ -480,7 +475,7 @@ extern pid_t __pthread_fork (struct fork_block *b) attribute_hidden;
#define asm_handle(name) _asm_handle(name)
#define _asm_handle(name) #name
-#define ASM_GLOBAL asm_handle(ASM_GLOBAL_DIRECTIVE)
+#define ASM_GLOBAL asm_handle(.globl)
#define ASM_CANCEL(name) asm_handle(C_SYMBOL_NAME(name))
#if !defined NOT_IN_libc
@@ -513,8 +508,6 @@ extern pid_t __pthread_fork (struct fork_block *b) attribute_hidden;
# define LIBC_CANCEL_HANDLED() /* Nothing. */
#endif
-extern int * __libc_pthread_init (const struct pthread_functions *functions);
-
#if !defined NOT_IN_libc && !defined FLOATING_STACKS
# ifdef SHARED
# define thread_self() \
@@ -525,7 +518,7 @@ weak_extern (__pthread_thread_self)
# endif
#endif
-#ifndef USE_TLS
+#ifndef __UCLIBC_HAS_TLS__
# define __manager_thread (&__pthread_manager_thread)
#else
# define __manager_thread __pthread_manager_threadp
diff --git a/libpthread/linuxthreads/libc-cancellation.c b/libpthread/linuxthreads/libc-cancellation.c
index d97359b22..e41e9c81a 100644
--- a/libpthread/linuxthreads/libc-cancellation.c
+++ b/libpthread/linuxthreads/libc-cancellation.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 <rpc/rpc.h>
@@ -31,9 +30,6 @@
weak_extern (__pthread_do_exit)
# endif
-int __libc_multiple_threads attribute_hidden __attribute__((nocommon));
-strong_alias (__libc_multiple_threads, __librt_multiple_threads)
-
/* The next two functions are similar to pthread_setcanceltype() but
more specialized for the use in the cancelable functions like write().
They do not need to check parameters etc. */
diff --git a/libpthread/linuxthreads/libc_pthread_init.c b/libpthread/linuxthreads/libc_pthread_init.c
index f89c2872e..384bf2f7f 100644
--- a/libpthread/linuxthreads/libc_pthread_init.c
+++ b/libpthread/linuxthreads/libc_pthread_init.c
@@ -13,29 +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/>. */
#include <locale.h>
#include <stdlib.h>
#include <string.h>
-#ifdef USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
#include <tls.h>
#endif
#include "internals.h"
-#ifdef SHARED
-/* Experimentally off - libc_hidden_proto(memcpy) */
-#endif
-#if !(USE_TLS && HAVE___THREAD) && defined __UCLIBC_HAS_XLOCALE__
-libc_hidden_proto(uselocale)
-#endif
+int __libc_multiple_threads attribute_hidden __attribute__((nocommon));
+strong_alias (__libc_multiple_threads, __librt_multiple_threads)
+
int *
-__libc_pthread_init (functions)
- const struct pthread_functions *functions;
+__libc_pthread_init(const struct pthread_functions *functions)
{
#ifdef SHARED
/* We copy the content of the variable pointed to by the FUNCTIONS
@@ -45,7 +40,7 @@ __libc_pthread_init (functions)
sizeof (__libc_pthread_functions));
#endif
-#if !(USE_TLS && HAVE___THREAD)
+#ifndef __UCLIBC_HAS_TLS__
/* Initialize thread-locale current locale to point to the global one.
With __thread support, the variable's initializer takes care of this. */
__uselocale (LC_GLOBAL_LOCALE);
diff --git a/libpthread/linuxthreads/lockfile.c b/libpthread/linuxthreads/lockfile.c
index 5266b1848..1f6584a88 100644
--- a/libpthread/linuxthreads/lockfile.c
+++ b/libpthread/linuxthreads/lockfile.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; 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/>. */
#include <bits/libc-lock.h>
#include <stdio.h>
diff --git a/libpthread/linuxthreads/manager.c b/libpthread/linuxthreads/manager.c
index b0a2a3712..3c5bee876 100644
--- a/libpthread/linuxthreads/manager.c
+++ b/libpthread/linuxthreads/manager.c
@@ -126,13 +126,13 @@ __pthread_manager(void *arg)
#ifdef INIT_THREAD_SELF
INIT_THREAD_SELF(self, 1);
#endif
-#if !(USE_TLS && HAVE___THREAD)
+#ifndef __UCLIBC_HAS_TLS__
/* Set the error variable. */
self->p_errnop = &self->p_errno;
self->p_h_errnop = &self->p_h_errno;
#endif
/* Block all signals except __pthread_sig_cancel and SIGTRAP */
- sigfillset(&manager_mask);
+ __sigfillset(&manager_mask);
sigdelset(&manager_mask, __pthread_sig_cancel); /* for thread termination */
sigdelset(&manager_mask, SIGTRAP); /* for debugging purposes */
if (__pthread_threads_debug && __pthread_sig_debug > 0)
@@ -289,11 +289,11 @@ pthread_start_thread(void *arg)
__sched_setscheduler(THREAD_GETMEM(self, p_pid),
SCHED_OTHER, &default_params);
}
-#if !(USE_TLS && HAVE___THREAD)
+#ifndef __UCLIBC_HAS_TLS__
/* Initialize thread-locale current locale to point to the global one.
With __thread support, the variable's initializer takes care of this. */
__uselocale (LC_GLOBAL_LOCALE);
-#else
+#elif defined __UCLIBC_HAS_RESOLVER_SUPPORT__
/* Initialize __resp. */
__resp = &self->p_res;
#endif
@@ -333,7 +333,7 @@ pthread_start_thread_event(void *arg)
pthread_start_thread (arg);
}
-#if defined USE_TLS && !FLOATING_STACKS
+#if defined __UCLIBC_HAS_TLS__ && !FLOATING_STACKS
# error "TLS can only work with floating stacks"
#endif
@@ -351,7 +351,7 @@ static int pthread_allocate_stack(const pthread_attr_t *attr,
char * guardaddr;
size_t stacksize, guardsize;
-#ifdef USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
/* TLS cannot work with fixed thread descriptor addresses. */
assert (default_new_thread == NULL);
#endif
@@ -360,7 +360,7 @@ static int pthread_allocate_stack(const pthread_attr_t *attr,
{
#ifdef _STACK_GROWS_UP
/* The user provided a stack. */
-# ifdef USE_TLS
+# ifdef __UCLIBC_HAS_TLS__
/* This value is not needed. */
new_thread = (pthread_descr) attr->__stackaddr;
new_thread_bottom = (char *) new_thread;
@@ -381,7 +381,7 @@ static int pthread_allocate_stack(const pthread_attr_t *attr,
addresses, stackaddr would be the lowest address in the stack
segment, so that it is consistently close to the initial sp
value. */
-# ifdef USE_TLS
+# ifdef __UCLIBC_HAS_TLS__
new_thread = (pthread_descr) attr->__stackaddr;
# else
new_thread =
@@ -394,7 +394,7 @@ static int pthread_allocate_stack(const pthread_attr_t *attr,
#ifndef THREAD_SELF
__pthread_nonstandard_stacks = 1;
#endif
-#ifndef USE_TLS
+#ifndef __UCLIBC_HAS_TLS__
/* Clear the thread data structure. */
memset (new_thread, '\0', sizeof (*new_thread));
#endif
@@ -438,31 +438,31 @@ static int pthread_allocate_stack(const pthread_attr_t *attr,
mprotect (guardaddr, guardsize, PROT_NONE);
new_thread_bottom = (char *) map_addr;
-# ifdef USE_TLS
+# ifdef __UCLIBC_HAS_TLS__
new_thread = ((pthread_descr) (new_thread_bottom + stacksize
+ guardsize));
# else
new_thread = ((pthread_descr) (new_thread_bottom + stacksize
+ guardsize)) - 1;
# endif
-# elif _STACK_GROWS_DOWN
+# elif defined _STACK_GROWS_DOWN
guardaddr = map_addr;
if (guardsize > 0)
mprotect (guardaddr, guardsize, PROT_NONE);
new_thread_bottom = (char *) map_addr + guardsize;
-# ifdef USE_TLS
+# ifdef __UCLIBC_HAS_TLS__
new_thread = ((pthread_descr) (new_thread_bottom + stacksize));
# else
new_thread = ((pthread_descr) (new_thread_bottom + stacksize)) - 1;
# endif
-# elif _STACK_GROWS_UP
+# elif defined _STACK_GROWS_UP
guardaddr = map_addr + stacksize;
if (guardsize > 0)
mprotect (guardaddr, guardsize, PROT_NONE);
new_thread = (pthread_descr) map_addr;
-# ifdef USE_TLS
+# ifdef __UCLIBC_HAS_TLS__
new_thread_bottom = (char *) new_thread;
# else
new_thread_bottom = (char *) (new_thread + 1);
@@ -597,11 +597,11 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
int pagesize = __getpagesize();
int saved_errno = 0;
-#ifdef USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
new_thread = _dl_allocate_tls (NULL);
if (new_thread == NULL)
return EAGAIN;
-# if TLS_DTV_AT_TP
+# if defined(TLS_DTV_AT_TP)
/* pthread_descr is below TP. */
new_thread = (pthread_descr) ((char *) new_thread - TLS_PRE_TCB_SIZE);
# endif
@@ -621,8 +621,8 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
{
if (sseg >= PTHREAD_THREADS_MAX)
{
-#ifdef USE_TLS
-# if TLS_DTV_AT_TP
+#ifdef __UCLIBC_HAS_TLS__
+# if defined(TLS_DTV_AT_TP)
new_thread = (pthread_descr) ((char *) new_thread + TLS_PRE_TCB_SIZE);
# endif
_dl_deallocate_tls (new_thread, true);
@@ -635,7 +635,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
pagesize, &stack_addr, &new_thread_bottom,
&guardaddr, &guardsize, &stksize) == 0)
{
-#ifdef USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
new_thread->p_stackaddr = stack_addr;
#else
new_thread = (pthread_descr) stack_addr;
@@ -657,18 +657,18 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
new_thread_id = sseg + pthread_threads_counter;
/* Initialize the thread descriptor. Elements which have to be
initialized to zero already have this value. */
-#if !defined USE_TLS || !TLS_DTV_AT_TP
+#if !defined __UCLIBC_HAS_TLS__ || !TLS_DTV_AT_TP
new_thread->p_header.data.tcb = new_thread;
new_thread->p_header.data.self = new_thread;
#endif
-#if TLS_MULTIPLE_THREADS_IN_TCB || !defined USE_TLS || !TLS_DTV_AT_TP
+#if TLS_MULTIPLE_THREADS_IN_TCB || !defined __UCLIBC_HAS_TLS__ || !TLS_DTV_AT_TP
new_thread->p_multiple_threads = 1;
#endif
new_thread->p_tid = new_thread_id;
new_thread->p_lock = &(__pthread_handles[sseg].h_lock);
new_thread->p_cancelstate = PTHREAD_CANCEL_ENABLE;
new_thread->p_canceltype = PTHREAD_CANCEL_DEFERRED;
-#if !(USE_TLS && HAVE___THREAD)
+#ifndef __UCLIBC_HAS_TLS__
new_thread->p_errnop = &new_thread->p_errno;
new_thread->p_h_errnop = &new_thread->p_h_errno;
new_thread->p_resp = &new_thread->p_res;
@@ -742,15 +742,15 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
pid = __clone2(pthread_start_thread_event,
(void **)new_thread_bottom,
(char *)stack_addr - new_thread_bottom,
- CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
+ CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_SYSVSEM |
__pthread_sig_cancel, new_thread);
-#elif _STACK_GROWS_UP
+#elif defined _STACK_GROWS_UP
pid = __clone(pthread_start_thread_event, (void *) new_thread_bottom,
- CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
+ CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_SYSVSEM |
__pthread_sig_cancel, new_thread);
#else
pid = __clone(pthread_start_thread_event, stack_addr,
- CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
+ CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_SYSVSEM |
__pthread_sig_cancel, new_thread);
#endif
saved_errno = errno;
@@ -783,15 +783,15 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
pid = __clone2(pthread_start_thread,
(void **)new_thread_bottom,
(char *)stack_addr - new_thread_bottom,
- CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
+ CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_SYSVSEM |
__pthread_sig_cancel, new_thread);
-#elif _STACK_GROWS_UP
+#elif defined _STACK_GROWS_UP
pid = __clone(pthread_start_thread, (void *) new_thread_bottom,
- CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
+ CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_SYSVSEM |
__pthread_sig_cancel, new_thread);
#else
pid = __clone(pthread_start_thread, stack_addr,
- CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
+ CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_SYSVSEM |
__pthread_sig_cancel, new_thread);
#endif /* !NEED_SEPARATE_REGISTER_STACK */
saved_errno = errno;
@@ -806,8 +806,8 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
- new_thread_bottom);
munmap((caddr_t)new_thread_bottom,
2 * stacksize + new_thread->p_guardsize);
-#elif _STACK_GROWS_UP
-# ifdef USE_TLS
+#elif defined _STACK_GROWS_UP
+# ifdef __UCLIBC_HAS_TLS__
size_t stacksize = guardaddr - stack_addr;
munmap(stack_addr, stacksize + guardsize);
# else
@@ -815,7 +815,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
munmap(new_thread, stacksize + guardsize);
# endif
#else
-# ifdef USE_TLS
+# ifdef __UCLIBC_HAS_TLS__
size_t stacksize = stack_addr - new_thread_bottom;
# else
size_t stacksize = (char *)(new_thread+1) - new_thread_bottom;
@@ -823,8 +823,8 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
munmap(new_thread_bottom - guardsize, guardsize + stacksize);
#endif
}
-#ifdef USE_TLS
-# if TLS_DTV_AT_TP
+#ifdef __UCLIBC_HAS_TLS__
+# if defined(TLS_DTV_AT_TP)
new_thread = (pthread_descr) ((char *) new_thread + TLS_PRE_TCB_SIZE);
# endif
_dl_deallocate_tls (new_thread, true);
@@ -890,16 +890,17 @@ static void pthread_free(pthread_descr th)
/* Free the stack and thread descriptor area */
char *guardaddr = th->p_guardaddr;
#ifdef _STACK_GROWS_UP
-# ifdef USE_TLS
+# ifdef __UCLIBC_HAS_TLS__
size_t stacksize = guardaddr - th->p_stackaddr;
+ guardaddr = th->p_stackaddr;
# else
size_t stacksize = guardaddr - (char *)th;
-# endif
guardaddr = (char *)th;
+# endif
#else
/* Guardaddr is always set, even if guardsize is 0. This allows
us to compute everything else. */
-# ifdef USE_TLS
+# ifdef __UCLIBC_HAS_TLS__
size_t stacksize = th->p_stackaddr - guardaddr - guardsize;
# else
size_t stacksize = (char *)(th+1) - guardaddr - guardsize;
@@ -915,8 +916,8 @@ static void pthread_free(pthread_descr th)
}
-#ifdef USE_TLS
-# if TLS_DTV_AT_TP
+#ifdef __UCLIBC_HAS_TLS__
+# if defined(TLS_DTV_AT_TP)
th = (pthread_descr) ((char *) th + TLS_PRE_TCB_SIZE);
# endif
_dl_deallocate_tls (th, true);
diff --git a/libpthread/linuxthreads/pt-machine.c b/libpthread/linuxthreads/pt-machine.c
index 5cd477ce9..d932cf84b 100644
--- a/libpthread/linuxthreads/pt-machine.c
+++ b/libpthread/linuxthreads/pt-machine.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; 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/>. */
#define PT_EI
diff --git a/libpthread/linuxthreads/ptcleanup.c b/libpthread/linuxthreads/ptcleanup.c
index 6213b56f3..88b9453ff 100644
--- a/libpthread/linuxthreads/ptcleanup.c
+++ b/libpthread/linuxthreads/ptcleanup.c
@@ -20,8 +20,8 @@
#include <setjmp.h>
#include "pthread.h"
#include "internals.h"
-#ifndef NO_PTR_DEMANGLE
#include <jmpbuf-unwind.h>
+#ifndef NO_PTR_DEMANGLE
#define __JMPBUF_UNWINDS(a,b,c) _JMPBUF_UNWINDS(a,b,c)
#else
#define __JMPBUF_UNWINDS(a,b,c) _JMPBUF_UNWINDS(a,b)
@@ -49,13 +49,13 @@ void __pthread_cleanup_upto (__jmp_buf target, char *targetframe)
c != NULL && __JMPBUF_UNWINDS(target, c, demangle_ptr);
c = c->__prev)
{
-#if _STACK_GROWS_DOWN
+#ifdef _STACK_GROWS_DOWN
if ((char *) c <= targetframe)
{
c = NULL;
break;
}
-#elif _STACK_GROWS_UP
+#elif defined _STACK_GROWS_UP
if ((char *) c >= targetframe)
{
c = NULL;
diff --git a/libpthread/linuxthreads/ptclock_gettime.c b/libpthread/linuxthreads/ptclock_gettime.c
index 755f83d10..dc28d0c68 100644
--- a/libpthread/linuxthreads/ptclock_gettime.c
+++ b/libpthread/linuxthreads/ptclock_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; 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/>. */
#include <errno.h>
#include <time.h>
-#include <libc-internal.h>
#include "internals.h"
#include "spinlock.h"
diff --git a/libpthread/linuxthreads/ptclock_settime.c b/libpthread/linuxthreads/ptclock_settime.c
index a4f218c77..bea015d2c 100644
--- a/libpthread/linuxthreads/ptclock_settime.c
+++ b/libpthread/linuxthreads/ptclock_settime.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; 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/>. */
#include <errno.h>
#include <time.h>
-#include <libc-internal.h>
#include "internals.h"
#include "spinlock.h"
diff --git a/libpthread/linuxthreads/ptfork.c b/libpthread/linuxthreads/ptfork.c
index 853aeea92..71404acf1 100644
--- a/libpthread/linuxthreads/ptfork.c
+++ b/libpthread/linuxthreads/ptfork.c
@@ -23,8 +23,6 @@
#include <bits/libc-lock.h>
#include "fork.h"
-extern int __libc_fork (void);
-
pid_t __pthread_fork (struct fork_block *b)
{
pid_t pid;
diff --git a/libpthread/linuxthreads/pthread.c b/libpthread/linuxthreads/pthread.c
index 4c44252ab..5dccd939f 100644
--- a/libpthread/linuxthreads/pthread.c
+++ b/libpthread/linuxthreads/pthread.c
@@ -37,22 +37,20 @@
# error "This must not happen"
#endif
-/* mods for uClibc: __libc_sigaction is not in any standard headers */
-extern __typeof(sigaction) __libc_sigaction;
-
-#if !(USE_TLS && HAVE___THREAD)
+#ifndef __UCLIBC_HAS_TLS__
/* These variables are used by the setup code. */
extern int _errno;
extern int _h_errno;
+# if defined __UCLIBC_HAS_RESOLVER_SUPPORT__
/* We need the global/static resolver state here. */
# include <resolv.h>
# undef _res
-
-extern struct __res_state _res;
+extern struct __res_state *__resp;
+# endif
#endif
-#ifdef USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
/* We need only a few variables. */
#define manager_thread __pthread_manager_threadp
@@ -69,10 +67,9 @@ struct _pthread_descr_struct __pthread_initial_thread = {
.p_tid = PTHREAD_THREADS_MAX,
.p_lock = &__pthread_handles[0].h_lock,
.p_start_args = PTHREAD_START_ARGS_INITIALIZER(NULL),
-#if !(USE_TLS && HAVE___THREAD)
+#ifndef __UCLIBC_HAS_TLS__
.p_errnop = &_errno,
.p_h_errnop = &_h_errno,
- .p_resp = &_res,
#endif
.p_userstack = 1,
.p_resume_count = __ATOMIC_INITIALIZER,
@@ -89,7 +86,7 @@ struct _pthread_descr_struct __pthread_manager_thread = {
.p_header.data.multiple_threads = 1,
.p_lock = &__pthread_handles[1].h_lock,
.p_start_args = PTHREAD_START_ARGS_INITIALIZER(__pthread_manager),
-#if !(USE_TLS && HAVE___THREAD)
+#ifndef __UCLIBC_HAS_TLS__
.p_errnop = &__pthread_manager_thread.p_errno,
#endif
.p_nr = 1,
@@ -101,7 +98,7 @@ struct _pthread_descr_struct __pthread_manager_thread = {
/* Pointer to the main thread (the father of the thread manager thread) */
/* Originally, this is the initial thread, but this changes after fork() */
-#ifdef USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
pthread_descr __pthread_main_thread;
#else
pthread_descr __pthread_main_thread = &__pthread_initial_thread;
@@ -227,13 +224,13 @@ extern void *__dso_handle __attribute__ ((weak));
#endif
-#if defined USE_TLS && !defined SHARED
+#if defined __UCLIBC_HAS_TLS__ && !defined SHARED
extern void __libc_setup_tls (size_t tcbsize, size_t tcbalign);
#endif
struct pthread_functions __pthread_functions =
{
-#if !(USE_TLS && HAVE___THREAD)
+#if !defined __UCLIBC_HAS_TLS__ && defined __UCLIBC_HAS_RPC__
.ptr_pthread_internal_tsd_set = __pthread_internal_tsd_set,
.ptr_pthread_internal_tsd_get = __pthread_internal_tsd_get,
.ptr_pthread_internal_tsd_address = __pthread_internal_tsd_address,
@@ -295,7 +292,7 @@ static int *__libc_multiple_threads_ptr;
void
__pthread_initialize_minimal(void)
{
-#ifdef USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
pthread_descr self;
/* First of all init __pthread_handles[0] and [1] if needed. */
@@ -307,7 +304,7 @@ __pthread_initialize_minimal(void)
/* Unlike in the dynamically linked case the dynamic linker has not
taken care of initializing the TLS data structures. */
__libc_setup_tls (TLS_TCB_SIZE, TLS_TCB_ALIGN);
-# elif !USE___THREAD
+# elif !defined __UCLIBC_HAS_TLS__
if (__builtin_expect (GL(dl_tls_dtv_slotinfo_list) == NULL, 0))
{
tcbhead_t *tcbp;
@@ -363,7 +360,7 @@ cannot allocate TLS data structures for initial thread\n";
self->p_nextlive = self->p_prevlive = self;
self->p_tid = PTHREAD_THREADS_MAX;
self->p_lock = &__pthread_handles[0].h_lock;
-# ifndef HAVE___THREAD
+# ifndef __UCLIBC_HAS_TLS__
self->p_errnop = &_errno;
self->p_h_errnop = &_h_errno;
# endif
@@ -380,7 +377,7 @@ cannot allocate TLS data structures for initial thread\n";
/* And fill in the pointer the the thread __pthread_handles array. */
__pthread_handles[0].h_descr = self;
-#else /* USE_TLS */
+#else /* __UCLIBC_HAS_TLS__ */
/* First of all init __pthread_handles[0] and [1]. */
# if __LT_SPINLOCK_INIT != 0
@@ -398,7 +395,7 @@ cannot allocate TLS data structures for initial thread\n";
#endif
#if HP_TIMING_AVAIL
-# ifdef USE_TLS
+# ifdef __UCLIBC_HAS_TLS__
self->p_cpuclock_offset = GL(dl_cpuclock_offset);
# else
__pthread_initial_thread.p_cpuclock_offset = GL(dl_cpuclock_offset);
@@ -442,7 +439,7 @@ __pthread_init_max_stacksize(void)
__pthread_max_stacksize = max_stack;
if (max_stack / 4 < __MAX_ALLOCA_CUTOFF)
{
-#ifdef USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
pthread_descr self = THREAD_SELF;
self->p_alloca_cutoff = max_stack / 4;
#else
@@ -451,10 +448,8 @@ __pthread_init_max_stacksize(void)
}
}
-/* psm: we do not have any ld.so support yet
- * remove the USE_TLS guard if nptl is added */
-#if defined SHARED && defined USE_TLS
-# if USE___THREAD
+#if defined SHARED && defined __UCLIBC_HAS_TLS__
+# ifdef __UCLIBC_HAS_TLS__
/* When using __thread for this, we do it in libc so as not
to give libpthread its own TLS segment just for this. */
extern void **__libc_dl_error_tsd (void) __attribute__ ((const));
@@ -467,14 +462,14 @@ __libc_dl_error_tsd (void)
# endif
#endif
-#ifdef USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
static __inline__ void __attribute__((always_inline))
init_one_static_tls (pthread_descr descr, struct link_map *map)
{
-# if TLS_TCB_AT_TP
+# if defined(TLS_TCB_AT_TP)
dtv_t *dtv = GET_DTV (descr);
void *dest = (char *) descr - map->l_tls_offset;
-# elif TLS_DTV_AT_TP
+# elif defined(TLS_DTV_AT_TP)
dtv_t *dtv = GET_DTV ((pthread_descr) ((char *) descr + TLS_PRE_TCB_SIZE));
void *dest = (char *) descr + map->l_tls_offset + TLS_PRE_TCB_SIZE;
# else
@@ -486,7 +481,7 @@ init_one_static_tls (pthread_descr descr, struct link_map *map)
dtv[map->l_tls_modid].pointer.is_static = true;
/* Initialize the memory. */
- memset (__mempcpy (dest, map->l_tls_initimage, map->l_tls_initimage_size),
+ memset (mempcpy (dest, map->l_tls_initimage, map->l_tls_initimage_size),
'\0', map->l_tls_blocksize - map->l_tls_initimage_size);
}
@@ -536,18 +531,20 @@ static void pthread_initialize(void)
(char *)(((long)CURRENT_STACK_FRAME - 2 * STACK_SIZE) & ~(STACK_SIZE - 1));
# endif
#endif
-#ifdef USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
/* Update the descriptor for the initial thread. */
THREAD_SETMEM (((pthread_descr) NULL), p_pid, __getpid());
-# ifndef HAVE___THREAD
+# if defined __UCLIBC_HAS_RESOLVER_SUPPORT__
/* Likewise for the resolver state _res. */
- THREAD_SETMEM (((pthread_descr) NULL), p_resp, &_res);
+ THREAD_SETMEM (((pthread_descr) NULL), p_resp, __resp);
# endif
#else
/* Update the descriptor for the initial thread. */
__pthread_initial_thread.p_pid = __getpid();
+# if defined __UCLIBC_HAS_RESOLVER_SUPPORT__
/* Likewise for the resolver state _res. */
- __pthread_initial_thread.p_resp = &_res;
+ __pthread_initial_thread.p_resp = __resp;
+# endif
#endif
#if !__ASSUME_REALTIME_SIGNALS
/* Initialize real-time signals. */
@@ -556,22 +553,19 @@ static void pthread_initialize(void)
/* Setup signal handlers for the initial thread.
Since signal handlers are shared between threads, these settings
will be inherited by all other threads. */
+ memset(&sa, 0, sizeof(sa));
sa.sa_handler = pthread_handle_sigrestart;
- sigemptyset(&sa.sa_mask);
- sa.sa_flags = 0;
__libc_sigaction(__pthread_sig_restart, &sa, NULL);
sa.sa_handler = pthread_handle_sigcancel;
sigaddset(&sa.sa_mask, __pthread_sig_restart);
- // sa.sa_flags = 0;
__libc_sigaction(__pthread_sig_cancel, &sa, NULL);
if (__pthread_sig_debug > 0) {
sa.sa_handler = pthread_handle_sigdebug;
- sigemptyset(&sa.sa_mask);
- // sa.sa_flags = 0;
+ __sigemptyset(&sa.sa_mask);
__libc_sigaction(__pthread_sig_debug, &sa, NULL);
}
/* Initially, block __pthread_sig_restart. Will be unblocked on demand. */
- sigemptyset(&mask);
+ __sigemptyset(&mask);
sigaddset(&mask, __pthread_sig_restart);
sigprocmask(SIG_BLOCK, &mask, NULL);
/* And unblock __pthread_sig_cancel if it has been blocked. */
@@ -591,9 +585,7 @@ static void pthread_initialize(void)
/* How many processors. */
__pthread_smp_kernel = is_smp_system ();
-/* psm: we do not have any ld.so support yet
- * remove the USE_TLS guard if nptl is added */
-#if defined SHARED && defined USE_TLS
+#if defined SHARED && defined __UCLIBC_HAS_TLS__
/* Transfer the old value from the dynamic linker's internal location. */
*__libc_dl_error_tsd () = *(*GL(dl_error_catch_tsd)) ();
GL(dl_error_catch_tsd) = &__libc_dl_error_tsd;
@@ -608,9 +600,20 @@ static void pthread_initialize(void)
__pthread_mutex_lock (&GL(dl_load_lock).mutex);
#endif
-#ifdef USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
GL(dl_init_static_tls) = &__pthread_init_static_tls;
#endif
+
+ /* uClibc-specific stdio initialization for threads. */
+ {
+ FILE *fp;
+ _stdio_user_locking = 0; /* 2 if threading not initialized */
+ for (fp = _stdio_openlist; fp != NULL; fp = fp->__nextopen) {
+ if (fp->__user_locking != 1) {
+ fp->__user_locking = 0;
+ }
+ }
+ }
}
void __pthread_initialize(void)
@@ -625,12 +628,12 @@ int __pthread_initialize_manager(void)
struct pthread_request request;
int report_events;
pthread_descr mgr;
-#ifdef USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
tcbhead_t *tcbp;
#endif
__pthread_multiple_threads = 1;
-#if TLS_MULTIPLE_THREADS_IN_TCB || !defined USE_TLS || !TLS_DTV_AT_TP
+#if TLS_MULTIPLE_THREADS_IN_TCB || !defined __UCLIBC_HAS_TLS__ || !TLS_DTV_AT_TP
__pthread_main_thread->p_multiple_threads = 1;
#endif
*__libc_multiple_threads_ptr = 1;
@@ -657,7 +660,7 @@ int __pthread_initialize_manager(void)
return -1;
}
-#ifdef USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
/* Allocate memory for the thread descriptor and the dtv. */
tcbp = _dl_allocate_tls (NULL);
if (tcbp == NULL) {
@@ -667,9 +670,9 @@ int __pthread_initialize_manager(void)
return -1;
}
-# if TLS_TCB_AT_TP
+# if defined(TLS_TCB_AT_TP)
mgr = (pthread_descr) tcbp;
-# elif TLS_DTV_AT_TP
+# elif defined(TLS_DTV_AT_TP)
/* pthread_descr is located right below tcbhead_t which _dl_allocate_tls
returns. */
mgr = (pthread_descr) ((char *) tcbp - TLS_PRE_TCB_SIZE);
@@ -677,7 +680,7 @@ int __pthread_initialize_manager(void)
__pthread_handles[1].h_descr = manager_thread = mgr;
/* Initialize the descriptor. */
-#if !defined USE_TLS || !TLS_DTV_AT_TP
+#if !defined __UCLIBC_HAS_TLS__ || !TLS_DTV_AT_TP
mgr->p_header.data.tcb = tcbp;
mgr->p_header.data.self = mgr;
mgr->p_header.data.multiple_threads = 1;
@@ -685,7 +688,7 @@ int __pthread_initialize_manager(void)
mgr->p_multiple_threads = 1;
#endif
mgr->p_lock = &__pthread_handles[1].h_lock;
-# ifndef HAVE___THREAD
+# ifndef __UCLIBC_HAS_TLS__
mgr->p_errnop = &mgr->p_errno;
# endif
mgr->p_start_args = (struct pthread_start_args) PTHREAD_START_ARGS_INITIALIZER(__pthread_manager);
@@ -703,7 +706,7 @@ int __pthread_initialize_manager(void)
/* Start the thread manager */
pid = 0;
-#ifdef USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
if (__linuxthreads_initial_report_events != 0)
THREAD_SETMEM (((pthread_descr) NULL), p_report_events,
__linuxthreads_initial_report_events);
@@ -722,7 +725,7 @@ int __pthread_initialize_manager(void)
uint32_t mask = __td_eventmask (TD_CREATE);
uint32_t event_bits;
-#ifdef USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
event_bits = THREAD_GETMEM_NC (((pthread_descr) NULL),
p_eventbuf.eventmask.event_bits[idx]);
#else
@@ -738,17 +741,17 @@ int __pthread_initialize_manager(void)
pid = __clone2(__pthread_manager_event,
(void **) __pthread_manager_thread_bos,
THREAD_MANAGER_STACK_SIZE,
- CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND,
+ CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_SYSVSEM,
mgr);
-#elif _STACK_GROWS_UP
+#elif defined _STACK_GROWS_UP
pid = __clone(__pthread_manager_event,
(void **) __pthread_manager_thread_bos,
- CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND,
+ CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_SYSVSEM,
mgr);
#else
pid = __clone(__pthread_manager_event,
(void **) __pthread_manager_thread_tos,
- CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND,
+ CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_SYSVSEM,
mgr);
#endif
@@ -778,17 +781,17 @@ int __pthread_initialize_manager(void)
#ifdef NEED_SEPARATE_REGISTER_STACK
pid = __clone2(__pthread_manager, (void **) __pthread_manager_thread_bos,
THREAD_MANAGER_STACK_SIZE,
- CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND, mgr);
-#elif _STACK_GROWS_UP
+ CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_SYSVSEM, mgr);
+#elif defined _STACK_GROWS_UP
pid = __clone(__pthread_manager, (void **) __pthread_manager_thread_bos,
- CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND, mgr);
+ CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_SYSVSEM, mgr);
#else
pid = __clone(__pthread_manager, (void **) __pthread_manager_thread_tos,
- CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND, mgr);
+ CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_SYSVSEM, mgr);
#endif
}
if (__builtin_expect (pid, 0) == -1) {
-#ifdef USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
_dl_deallocate_tls (tcbp, true);
#endif
free(__pthread_manager_thread_bos);
@@ -829,8 +832,7 @@ int __pthread_create(pthread_t *thread, const pthread_attr_t *attr,
request.req_args.create.attr = attr;
request.req_args.create.fn = start_routine;
request.req_args.create.arg = arg;
- sigprocmask(SIG_SETMASK, (const sigset_t *) NULL,
- &request.req_args.create.mask);
+ sigprocmask(SIG_SETMASK, NULL, &request.req_args.create.mask);
TEMP_FAILURE_RETRY(write_not_cancel(__pthread_manager_request,
(char *) &request, sizeof(request)));
suspend(self);
@@ -891,7 +893,7 @@ pthread_descr __pthread_self_stack(void)
if (sp >= __pthread_manager_thread_bos && sp < __pthread_manager_thread_tos)
return manager_thread;
h = __pthread_handles + 2;
-# ifdef USE_TLS
+# ifdef __UCLIBC_HAS_TLS__
# ifdef _STACK_GROWS_UP
while (h->h_descr == NULL
|| ! (sp >= h->h_descr->p_stackaddr && sp < h->h_descr->p_guardaddr))
@@ -971,6 +973,10 @@ static void pthread_onexit_process(int retcode, void *arg)
struct pthread_request request;
pthread_descr self = thread_self();
+ /* Make sure we come back here after suspend(), in case we entered
+ from a signal handler. */
+ THREAD_SETMEM(self, p_signal_jmp, NULL);
+
request.req_thread = self;
request.req_kind = REQ_PROCESS_EXIT;
request.req_args.exit.code = retcode;
@@ -981,7 +987,7 @@ static void pthread_onexit_process(int retcode, void *arg)
children, so that timings for main thread account for all threads. */
if (self == __pthread_main_thread)
{
-#ifdef USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
waitpid(manager_thread->p_pid, NULL, __WCLONE);
#else
waitpid(__pthread_manager_thread.p_pid, NULL, __WCLONE);
@@ -989,9 +995,9 @@ static void pthread_onexit_process(int retcode, void *arg)
/* Since all threads have been asynchronously terminated
(possibly holding locks), free cannot be used any more.
For mtrace, we'd like to print something though. */
- /* #ifdef USE_TLS
+ /* #ifdef __UCLIBC_HAS_TLS__
tcbhead_t *tcbp = (tcbhead_t *) manager_thread;
- # if TLS_DTV_AT_TP
+ # if defined(TLS_DTV_AT_TP)
tcbp = (tcbhead_t) ((char *) tcbp + TLS_PRE_TCB_SIZE);
# endif
_dl_deallocate_tls (tcbp, true);
@@ -1047,7 +1053,7 @@ static void pthread_handle_sigcancel(int sig)
/* Main thread should accumulate times for thread manager and its
children, so that timings for main thread account for all threads. */
if (self == __pthread_main_thread) {
-#ifdef USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
waitpid(manager_thread->p_pid, NULL, __WCLONE);
#else
waitpid(__pthread_manager_thread.p_pid, NULL, __WCLONE);
@@ -1108,11 +1114,13 @@ void __pthread_reset_main_thread(void)
__pthread_main_thread = self;
THREAD_SETMEM(self, p_nextlive, self);
THREAD_SETMEM(self, p_prevlive, self);
-#if !(USE_TLS && HAVE___THREAD)
+#ifndef __UCLIBC_HAS_TLS__
/* Now this thread modifies the global variables. */
THREAD_SETMEM(self, p_errnop, &_errno);
THREAD_SETMEM(self, p_h_errnop, &_h_errno);
- THREAD_SETMEM(self, p_resp, &_res);
+# if defined __UCLIBC_HAS_RESOLVER_SUPPORT__
+ THREAD_SETMEM(self, p_resp, __resp);
+# endif
#endif
#ifndef FLOATING_STACKS
@@ -1144,9 +1152,9 @@ void __pthread_kill_other_threads_np(void)
/* Reset the signal handlers behaviour for the signals the
implementation uses since this would be passed to the new
process. */
- sigemptyset(&sa.sa_mask);
- sa.sa_flags = 0;
- sa.sa_handler = SIG_DFL;
+ memset(&sa, 0, sizeof(sa));
+ if (SIG_DFL) /* if it's constant zero, it's already done */
+ sa.sa_handler = SIG_DFL;
__libc_sigaction(__pthread_sig_restart, &sa, NULL);
__libc_sigaction(__pthread_sig_cancel, &sa, NULL);
if (__pthread_sig_debug > 0)
@@ -1198,13 +1206,13 @@ void __pthread_wait_for_restart_signal(pthread_descr self)
void __pthread_restart_old(pthread_descr th)
{
- if (atomic_increment(&th->p_resume_count) == -1)
+ if (pthread_atomic_increment(&th->p_resume_count) == -1)
kill(th->p_pid, __pthread_sig_restart);
}
void __pthread_suspend_old(pthread_descr self)
{
- if (atomic_decrement(&self->p_resume_count) <= 0)
+ if (pthread_atomic_decrement(&self->p_resume_count) <= 0)
__pthread_wait_for_restart_signal(self);
}
@@ -1215,7 +1223,7 @@ __pthread_timedsuspend_old(pthread_descr self, const struct timespec *abstime)
int was_signalled = 0;
sigjmp_buf jmpbuf;
- if (atomic_decrement(&self->p_resume_count) == 0) {
+ if (pthread_atomic_decrement(&self->p_resume_count) == 0) {
/* Set up a longjmp handler for the restart signal, unblock
the signal and sleep. */
@@ -1223,7 +1231,7 @@ __pthread_timedsuspend_old(pthread_descr self, const struct timespec *abstime)
THREAD_SETMEM(self, p_signal_jmp, &jmpbuf);
THREAD_SETMEM(self, p_signal, 0);
/* Unblock the restart signal */
- sigemptyset(&unblock);
+ __sigemptyset(&unblock);
sigaddset(&unblock, __pthread_sig_restart);
sigprocmask(SIG_UNBLOCK, &unblock, &initial_mask);
@@ -1242,7 +1250,7 @@ __pthread_timedsuspend_old(pthread_descr self, const struct timespec *abstime)
/* Sleep for the required duration. If woken by a signal,
resume waiting as required by Single Unix Specification. */
- if (reltime.tv_sec < 0 || __libc_nanosleep(&reltime, NULL) == 0)
+ if (reltime.tv_sec < 0 || nanosleep(&reltime, NULL) == 0)
break;
}
@@ -1272,9 +1280,9 @@ __pthread_timedsuspend_old(pthread_descr self, const struct timespec *abstime)
being delivered. */
if (!was_signalled) {
- if (atomic_increment(&self->p_resume_count) != -1) {
+ if (pthread_atomic_increment(&self->p_resume_count) != -1) {
__pthread_wait_for_restart_signal(self);
- atomic_decrement(&self->p_resume_count); /* should be zero now! */
+ pthread_atomic_decrement(&self->p_resume_count); /* should be zero now! */
/* woke spontaneously and consumed restart signal */
return 1;
}
@@ -1310,7 +1318,7 @@ __pthread_timedsuspend_new(pthread_descr self, const struct timespec *abstime)
THREAD_SETMEM(self, p_signal_jmp, &jmpbuf);
THREAD_SETMEM(self, p_signal, 0);
/* Unblock the restart signal */
- sigemptyset(&unblock);
+ __sigemptyset(&unblock);
sigaddset(&unblock, __pthread_sig_restart);
sigprocmask(SIG_UNBLOCK, &unblock, &initial_mask);
@@ -1329,7 +1337,7 @@ __pthread_timedsuspend_new(pthread_descr self, const struct timespec *abstime)
/* Sleep for the required duration. If woken by a signal,
resume waiting as required by Single Unix Specification. */
- if (reltime.tv_sec < 0 || __libc_nanosleep(&reltime, NULL) == 0)
+ if (reltime.tv_sec < 0 || nanosleep(&reltime, NULL) == 0)
break;
}
diff --git a/libpthread/linuxthreads/pthread_atfork.c b/libpthread/linuxthreads/pthread_atfork.c
index 2464acb6b..436c3b400 100644
--- a/libpthread/linuxthreads/pthread_atfork.c
+++ b/libpthread/linuxthreads/pthread_atfork.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/>. */
#include "internals.h"
#include <fork.h>
diff --git a/libpthread/linuxthreads/pthread_setegid.c b/libpthread/linuxthreads/pthread_setegid.c
index e357bb9ef..ff0f250a5 100644
--- a/libpthread/linuxthreads/pthread_setegid.c
+++ b/libpthread/linuxthreads/pthread_setegid.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 <pthread.h>
#include <unistd.h>
diff --git a/libpthread/linuxthreads/pthread_seteuid.c b/libpthread/linuxthreads/pthread_seteuid.c
index 6a1464c58..a5423a9f3 100644
--- a/libpthread/linuxthreads/pthread_seteuid.c
+++ b/libpthread/linuxthreads/pthread_seteuid.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 <pthread.h>
#include <unistd.h>
diff --git a/libpthread/linuxthreads/pthread_setgid.c b/libpthread/linuxthreads/pthread_setgid.c
index 31b5a595b..3e49b19bf 100644
--- a/libpthread/linuxthreads/pthread_setgid.c
+++ b/libpthread/linuxthreads/pthread_setgid.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 <pthread.h>
#include <unistd.h>
diff --git a/libpthread/linuxthreads/pthread_setregid.c b/libpthread/linuxthreads/pthread_setregid.c
index 8964eb774..21cabab61 100644
--- a/libpthread/linuxthreads/pthread_setregid.c
+++ b/libpthread/linuxthreads/pthread_setregid.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 <pthread.h>
#include <unistd.h>
diff --git a/libpthread/linuxthreads/pthread_setresgid.c b/libpthread/linuxthreads/pthread_setresgid.c
index a330afcdb..1cbf1b5f7 100644
--- a/libpthread/linuxthreads/pthread_setresgid.c
+++ b/libpthread/linuxthreads/pthread_setresgid.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 <pthread.h>
#include <unistd.h>
diff --git a/libpthread/linuxthreads/pthread_setresuid.c b/libpthread/linuxthreads/pthread_setresuid.c
index 0fa28954d..0e35ba8ca 100644
--- a/libpthread/linuxthreads/pthread_setresuid.c
+++ b/libpthread/linuxthreads/pthread_setresuid.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 <pthread.h>
#include <unistd.h>
diff --git a/libpthread/linuxthreads/pthread_setreuid.c b/libpthread/linuxthreads/pthread_setreuid.c
index 78738e3cd..680eb5394 100644
--- a/libpthread/linuxthreads/pthread_setreuid.c
+++ b/libpthread/linuxthreads/pthread_setreuid.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 <pthread.h>
#include <unistd.h>
diff --git a/libpthread/linuxthreads/pthread_setuid.c b/libpthread/linuxthreads/pthread_setuid.c
index 107001e26..e1af5a196 100644
--- a/libpthread/linuxthreads/pthread_setuid.c
+++ b/libpthread/linuxthreads/pthread_setuid.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 <pthread.h>
#include <unistd.h>
diff --git a/libpthread/linuxthreads/restart.h b/libpthread/linuxthreads/restart.h
index f53642eda..694ec48cf 100644
--- a/libpthread/linuxthreads/restart.h
+++ b/libpthread/linuxthreads/restart.h
@@ -13,7 +13,7 @@
/* GNU Library General Public License for more details. */
#include <signal.h>
-#include <kernel-features.h>
+#include <bits/kernel-features.h>
/* Primitives for controlling thread execution */
diff --git a/libpthread/linuxthreads/rwlock.c b/libpthread/linuxthreads/rwlock.c
index f565f1870..af72876f5 100644
--- a/libpthread/linuxthreads/rwlock.c
+++ b/libpthread/linuxthreads/rwlock.c
@@ -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; 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/>. */
#include <bits/libc-lock.h>
#include <errno.h>
diff --git a/libpthread/linuxthreads/semaphore.c b/libpthread/linuxthreads/semaphore.c
index 392c37bfa..b66735bed 100644
--- a/libpthread/linuxthreads/semaphore.c
+++ b/libpthread/linuxthreads/semaphore.c
@@ -15,6 +15,7 @@
/* Semaphores a la POSIX 1003.1b */
#include <errno.h>
+#include <limits.h>
#include "pthread.h"
#include "semaphore.h"
#include "internals.h"
diff --git a/libpthread/linuxthreads/semaphore.h b/libpthread/linuxthreads/semaphore.h
index 3084209f6..7ab772bfa 100644
--- a/libpthread/linuxthreads/semaphore.h
+++ b/libpthread/linuxthreads/semaphore.h
@@ -17,6 +17,7 @@
#include <features.h>
#include <sys/types.h>
+#include <limits.h>
#ifdef __USE_XOPEN2K
# define __need_timespec
# include <time.h>
@@ -42,7 +43,9 @@ typedef struct
#define SEM_FAILED ((sem_t *) 0)
/* Maximum value the semaphore can have. */
+#ifndef SEM_VALUE_MAX
#define SEM_VALUE_MAX (2147483647)
+#endif
__BEGIN_DECLS
@@ -55,13 +58,13 @@ extern int sem_init (sem_t *__sem, int __pshared, unsigned int __value) __THROW;
extern int sem_destroy (sem_t *__sem) __THROW;
/* Open a named semaphore NAME with open flags OFLAG. */
-extern sem_t *sem_open (__const char *__name, int __oflag, ...) __THROW;
+extern sem_t *sem_open (const char *__name, int __oflag, ...) __THROW;
/* Close descriptor for named semaphore SEM. */
extern int sem_close (sem_t *__sem) __THROW;
/* Remove named semaphore NAME. */
-extern int sem_unlink (__const char *__name) __THROW;
+extern int sem_unlink (const char *__name) __THROW;
/* Wait for SEM being posted.
@@ -75,14 +78,14 @@ extern int sem_wait (sem_t *__sem);
This function is a cancellation point and therefore not marked with
__THROW. */
extern int sem_timedwait (sem_t *__restrict __sem,
- __const struct timespec *__restrict __abstime);
+ const struct timespec *__restrict __abstime);
#endif
/* Test whether SEM is posted. */
-extern int sem_trywait (sem_t *__sem) __THROW;
+extern int sem_trywait (sem_t *__sem) __THROWNL;
/* Post SEM. */
-extern int sem_post (sem_t *__sem) __THROW;
+extern int sem_post (sem_t *__sem) __THROWNL;
/* Get current value of SEM and store it in *SVAL. */
extern int sem_getvalue (sem_t *__restrict __sem, int *__restrict __sval)
diff --git a/libpthread/linuxthreads/signals.c b/libpthread/linuxthreads/signals.c
index 62e83211a..672b8e4d9 100644
--- a/libpthread/linuxthreads/signals.c
+++ b/libpthread/linuxthreads/signals.c
@@ -19,10 +19,6 @@
#include "pthread.h"
#include "internals.h"
#include "spinlock.h"
-#include <ucontext.h>
-
-/* mods for uClibc: __libc_sigaction is not in any standard headers */
-extern __typeof(sigaction) __libc_sigaction;
int pthread_sigmask(int how, const sigset_t * newmask, sigset_t * oldmask)
{
@@ -114,7 +110,7 @@ int __pthread_sigaction(int sig, const struct sigaction * act,
newactp = NULL;
if (__libc_sigaction(sig, newactp, oact) == -1)
{
- if (act)
+ if (act && (sig > 0 && sig < NSIG))
__sighandler[sig].old = (arch_sighandler_t) old;
return -1;
}
@@ -153,7 +149,7 @@ int __pthread_sigwait(const sigset_t * set, int * sig)
and if not, install our dummy handler. This is conformant to
POSIX: "The effect of sigwait() on the signal actions for the
signals in set is unspecified." */
- sigfillset(&mask);
+ __sigfillset(&mask);
sigdelset(&mask, __pthread_sig_cancel);
for (s = 1; s < NSIG; s++) {
if (sigismember(set, s) &&
@@ -165,7 +161,7 @@ int __pthread_sigwait(const sigset_t * set, int * sig)
__sighandler[s].old == (arch_sighandler_t) SIG_DFL ||
__sighandler[s].old == (arch_sighandler_t) SIG_IGN) {
sa.sa_handler = __pthread_null_sighandler;
- sigfillset(&sa.sa_mask);
+ __sigfillset(&sa.sa_mask);
sa.sa_flags = 0;
sigaction(s, &sa, NULL);
}
diff --git a/libpthread/linuxthreads/specific.c b/libpthread/linuxthreads/specific.c
index 92eec3d99..0daad83f5 100644
--- a/libpthread/linuxthreads/specific.c
+++ b/libpthread/linuxthreads/specific.c
@@ -104,13 +104,14 @@ int pthread_key_delete(pthread_key_t key)
that if the key is reallocated later by pthread_key_create, its
associated values will be NULL in all threads.
- If no threads have been created yet, clear it just in the
- current thread. */
+ If no threads have been created yet, or if we are exiting, clear
+ it just in the current thread. */
struct pthread_key_delete_helper_args args;
args.idx1st = key / PTHREAD_KEY_2NDLEVEL_SIZE;
args.idx2nd = key % PTHREAD_KEY_2NDLEVEL_SIZE;
- if (__pthread_manager_request != -1)
+ if (__pthread_manager_request != -1
+ && !(__builtin_expect (__pthread_exit_requested, 0)))
{
struct pthread_request request;
@@ -203,14 +204,15 @@ void __pthread_destroy_specifics()
__pthread_lock(THREAD_GETMEM(self, p_lock), self);
for (i = 0; i < PTHREAD_KEY_1STLEVEL_SIZE; i++) {
if (THREAD_GETMEM_NC(self, p_specific[i]) != NULL) {
- free(THREAD_GETMEM_NC(self, p_specific[i]));
+ void *p = THREAD_GETMEM_NC(self, p_specific[i]);
THREAD_SETMEM_NC(self, p_specific[i], NULL);
+ free(p);
}
}
__pthread_unlock(THREAD_GETMEM(self, p_lock));
}
-#if !(USE_TLS && HAVE___THREAD)
+#if !defined __UCLIBC_HAS_TLS__ && defined __UCLIBC_HAS_RPC__
/* Thread-specific data for libc. */
diff --git a/libpthread/linuxthreads/spinlock.c b/libpthread/linuxthreads/spinlock.c
index f32540286..f0cf19c54 100644
--- a/libpthread/linuxthreads/spinlock.c
+++ b/libpthread/linuxthreads/spinlock.c
@@ -637,8 +637,20 @@ void __pthread_alt_unlock(struct _pthread_fastlock *lock)
#if defined HAS_COMPARE_AND_SWAP
wait_node_dequeue(pp_head, pp_max_prio, p_max_prio);
#endif
+
+ /* Release the spinlock *before* restarting. */
+#if defined TEST_FOR_COMPARE_AND_SWAP
+ if (!__pthread_has_cas)
+#endif
+#if !defined HAS_COMPARE_AND_SWAP || defined TEST_FOR_COMPARE_AND_SWAP
+ {
+ __pthread_release(&lock->__spinlock);
+ }
+#endif
+
restart(p_max_prio->thr);
- break;
+
+ return;
}
}
diff --git a/libpthread/linuxthreads/spinlock.h b/libpthread/linuxthreads/spinlock.h
index 210ead471..2a3c2277f 100644
--- a/libpthread/linuxthreads/spinlock.h
+++ b/libpthread/linuxthreads/spinlock.h
@@ -172,7 +172,8 @@ static __inline__ int __pthread_alt_trylock (struct _pthread_fastlock * lock)
/* Operations on pthread_atomic, which is defined in internals.h */
-static __inline__ long atomic_increment(struct pthread_atomic *pa)
+static __inline__ long
+pthread_atomic_increment (struct pthread_atomic *pa)
{
long oldval;
@@ -184,7 +185,8 @@ static __inline__ long atomic_increment(struct pthread_atomic *pa)
}
-static __inline__ long atomic_decrement(struct pthread_atomic *pa)
+static __inline__ long
+pthread_atomic_decrement (struct pthread_atomic *pa)
{
long oldval;
diff --git a/libpthread/linuxthreads/sysdeps/alpha/elf/pt-initfini.c b/libpthread/linuxthreads/sysdeps/alpha/elf/pt-initfini.c
index ee2558210..6cdc69d58 100644
--- a/libpthread/linuxthreads/sysdeps/alpha/elf/pt-initfini.c
+++ b/libpthread/linuxthreads/sysdeps/alpha/elf/pt-initfini.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/>. */
/* This file is compiled into assembly code which is then munged by a sed
script into two files: crti.s and crtn.s.
diff --git a/libpthread/linuxthreads/sysdeps/alpha/pspinlock.c b/libpthread/linuxthreads/sysdeps/alpha/pspinlock.c
index d54a2a98b..cdf4be99c 100644
--- a/libpthread/linuxthreads/sysdeps/alpha/pspinlock.c
+++ b/libpthread/linuxthreads/sysdeps/alpha/pspinlock.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; 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/>. */
#include <errno.h>
#include <pthread.h>
diff --git a/libpthread/linuxthreads/sysdeps/alpha/pt-machine.h b/libpthread/linuxthreads/sysdeps/alpha/pt-machine.h
index 97c38394b..b47343ba7 100644
--- a/libpthread/linuxthreads/sysdeps/alpha/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/alpha/pt-machine.h
@@ -17,8 +17,7 @@
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. */
+ see <http://www.gnu.org/licenses/>. */
#ifndef _PT_MACHINE_H
#define _PT_MACHINE_H 1
diff --git a/libpthread/linuxthreads/sysdeps/alpha/tls.h b/libpthread/linuxthreads/sysdeps/alpha/tls.h
index 3eb9438ce..51c7fea8b 100644
--- a/libpthread/linuxthreads/sysdeps/alpha/tls.h
+++ b/libpthread/linuxthreads/sysdeps/alpha/tls.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 _TLS_H
#define _TLS_H
diff --git a/libpthread/linuxthreads/sysdeps/arm/pspinlock.c b/libpthread/linuxthreads/sysdeps/arm/pspinlock.c
index 9deb0b1b1..691085270 100644
--- a/libpthread/linuxthreads/sysdeps/arm/pspinlock.c
+++ b/libpthread/linuxthreads/sysdeps/arm/pspinlock.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; 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/>. */
#include <errno.h>
#include <pthread.h>
diff --git a/libpthread/linuxthreads/sysdeps/arm/pt-machine.h b/libpthread/linuxthreads/sysdeps/arm/pt-machine.h
index 9ffc8bdc4..0a455b97d 100644
--- a/libpthread/linuxthreads/sysdeps/arm/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/arm/pt-machine.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; 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 _PT_MACHINE_H
#define _PT_MACHINE_H 1
diff --git a/libpthread/linuxthreads/sysdeps/arm/sysdep-cancel.h b/libpthread/linuxthreads/sysdeps/arm/sysdep-cancel.h
new file mode 100644
index 000000000..ba6a1e04b
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/arm/sysdep-cancel.h
@@ -0,0 +1,8 @@
+#include <sysdep.h>
+
+/* No multi-thread handling enabled. */
+#define SINGLE_THREAD_P (1)
+#define RTLD_SINGLE_THREAD_P (1)
+#define LIBC_CANCEL_ASYNC() 0 /* Just a dummy value. */
+#define LIBC_CANCEL_RESET(val) ((void)(val)) /* Nothing, but evaluate it. */
+#define LIBC_CANCEL_HANDLED() /* Nothing. */
diff --git a/libpthread/linuxthreads/sysdeps/arm/tls.h b/libpthread/linuxthreads/sysdeps/arm/tls.h
index 8057a5413..df8d97009 100644
--- a/libpthread/linuxthreads/sysdeps/arm/tls.h
+++ b/libpthread/linuxthreads/sysdeps/arm/tls.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 _TLS_H
#define _TLS_H
diff --git a/libpthread/linuxthreads/sysdeps/avr32/pt-machine.h b/libpthread/linuxthreads/sysdeps/avr32/pt-machine.h
index b93bc47f0..5735d0ea2 100644
--- a/libpthread/linuxthreads/sysdeps/avr32/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/avr32/pt-machine.h
@@ -15,8 +15,8 @@
# define PT_EI __extern_always_inline
#endif
-static inline int
-_test_and_set (int *p, int v) __THROW
+static __inline__ int
+_test_and_set (int *p, int v)
{
int result;
@@ -52,7 +52,7 @@ register char * stack_pointer __asm__ ("sp");
PT_EI int
__compare_and_swap(long int *p, long int oldval, long int newval)
{
- int result;
+ long int result;
__asm__ __volatile__(
"/* Inline compare and swap */\n"
diff --git a/libpthread/linuxthreads/sysdeps/cris/pspinlock.c b/libpthread/linuxthreads/sysdeps/cris/pspinlock.c
index 402e838c0..7e3e62959 100644
--- a/libpthread/linuxthreads/sysdeps/cris/pspinlock.c
+++ b/libpthread/linuxthreads/sysdeps/cris/pspinlock.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; 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/>. */
#include <errno.h>
#include <pthread.h>
diff --git a/libpthread/linuxthreads/sysdeps/cris/pt-machine.h b/libpthread/linuxthreads/sysdeps/cris/pt-machine.h
index 33cf57908..9b2acb761 100644
--- a/libpthread/linuxthreads/sysdeps/cris/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/cris/pt-machine.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; 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 _PT_MACHINE_H
#define _PT_MACHINE_H 1
diff --git a/libpthread/linuxthreads/sysdeps/hppa/pspinlock.c b/libpthread/linuxthreads/sysdeps/hppa/pspinlock.c
index 71a537fd6..1a6aa64a9 100644
--- a/libpthread/linuxthreads/sysdeps/hppa/pspinlock.c
+++ b/libpthread/linuxthreads/sysdeps/hppa/pspinlock.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; 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/>. */
#include <errno.h>
#include <pthread.h>
diff --git a/libpthread/linuxthreads/sysdeps/hppa/pt-machine.h b/libpthread/linuxthreads/sysdeps/hppa/pt-machine.h
index 780af7b96..85c453c77 100644
--- a/libpthread/linuxthreads/sysdeps/hppa/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/hppa/pt-machine.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; 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 _PT_MACHINE_H
#define _PT_MACHINE_H 1
diff --git a/libpthread/linuxthreads/sysdeps/i386/i686/pt-machine.h b/libpthread/linuxthreads/sysdeps/i386/i686/pt-machine.h
index 222d44a3f..2e52abe2e 100644
--- a/libpthread/linuxthreads/sysdeps/i386/i686/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/i386/i686/pt-machine.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; 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 _PT_MACHINE_H
#define _PT_MACHINE_H 1
@@ -25,7 +24,7 @@
#ifndef PT_EI
# define PT_EI __extern_always_inline
#endif
-#include "kernel-features.h"
+#include <bits/kernel-features.h>
#ifndef __ASSEMBLER__
extern long int testandset (int *spinlock);
diff --git a/libpthread/linuxthreads/sysdeps/i386/pspinlock.c b/libpthread/linuxthreads/sysdeps/i386/pspinlock.c
index c9c62724b..7936735f9 100644
--- a/libpthread/linuxthreads/sysdeps/i386/pspinlock.c
+++ b/libpthread/linuxthreads/sysdeps/i386/pspinlock.c
@@ -13,14 +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; 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/>. */
#include <errno.h>
#include <pthread.h>
#include "internals.h"
-#include <kernel-features.h>
+#include <bits/kernel-features.h>
/* This implementation is similar to the one used in the Linux kernel.
diff --git a/libpthread/linuxthreads/sysdeps/i386/pt-machine.h b/libpthread/linuxthreads/sysdeps/i386/pt-machine.h
index f96452599..82a5cf077 100644
--- a/libpthread/linuxthreads/sysdeps/i386/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/i386/pt-machine.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; 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/>. */
#if defined __pentiumpro__ || defined __pentium4__ || defined __athlon__ || \
defined __k8__
@@ -32,10 +31,9 @@
# define PT_EI __extern_always_inline
#endif
-/*
extern long int testandset (int *spinlock);
extern int __compare_and_swap (long int *p, long int oldval, long int newval);
-*/
+
/* Get some notion of the current stack. Need not be exactly the top
of the stack, just something somewhere in the current frame. */
#define CURRENT_STACK_FRAME __builtin_frame_address (0)
diff --git a/libpthread/linuxthreads/sysdeps/i386/tls.h b/libpthread/linuxthreads/sysdeps/i386/tls.h
index 2abd3a093..d79bf0779 100644
--- a/libpthread/linuxthreads/sysdeps/i386/tls.h
+++ b/libpthread/linuxthreads/sysdeps/i386/tls.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 _TLS_H
#define _TLS_H
@@ -46,9 +45,7 @@ typedef struct
dtv_t *dtv;
void *self; /* Pointer to the thread descriptor. */
int multiple_threads;
-#ifdef NEED_DL_SYSINFO
uintptr_t sysinfo;
-#endif
} tcbhead_t;
#else /* __ASSEMBLER__ */
diff --git a/libpthread/linuxthreads/sysdeps/i386/useldt.h b/libpthread/linuxthreads/sysdeps/i386/useldt.h
index fa9a2a528..067e5e242 100644
--- a/libpthread/linuxthreads/sysdeps/i386/useldt.h
+++ b/libpthread/linuxthreads/sysdeps/i386/useldt.h
@@ -16,8 +16,7 @@
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. */
+ see <http://www.gnu.org/licenses/>. */
#ifndef __ASSEMBLER__
#include <stddef.h> /* For offsetof. */
@@ -87,7 +86,7 @@ extern int __modify_ldt (int, struct modify_ldt_ldt_s *, size_t);
because we inherited the value set up in the main thread by TLS setup.
We need to extract that value and set up the same segment in this
thread. */
-#if defined (USE_TLS) && USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
# define DO_SET_THREAD_AREA_REUSE(nr) 1
#else
/* Without TLS, we do the initialization of the main thread, where NR == 0. */
diff --git a/libpthread/linuxthreads/sysdeps/ia64/pspinlock.c b/libpthread/linuxthreads/sysdeps/ia64/pspinlock.c
index fa10c7b37..d5e52ff6b 100644
--- a/libpthread/linuxthreads/sysdeps/ia64/pspinlock.c
+++ b/libpthread/linuxthreads/sysdeps/ia64/pspinlock.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; 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/>. */
#include <errno.h>
#include <pthread.h>
diff --git a/libpthread/linuxthreads/sysdeps/ia64/pt-machine.h b/libpthread/linuxthreads/sysdeps/ia64/pt-machine.h
index e36468a74..55bdd5df5 100644
--- a/libpthread/linuxthreads/sysdeps/ia64/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/ia64/pt-machine.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; 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 _PT_MACHINE_H
#define _PT_MACHINE_H 1
diff --git a/libpthread/linuxthreads/sysdeps/ia64/tcb-offsets.sym b/libpthread/linuxthreads/sysdeps/ia64/tcb-offsets.sym
index f7793f766..1000ad0a9 100644
--- a/libpthread/linuxthreads/sysdeps/ia64/tcb-offsets.sym
+++ b/libpthread/linuxthreads/sysdeps/ia64/tcb-offsets.sym
@@ -2,7 +2,7 @@
#include <tls.h>
--
-#ifdef USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
MULTIPLE_THREADS_OFFSET offsetof (struct _pthread_descr_struct, p_multiple_threads) - sizeof (struct _pthread_descr_struct)
#else
MULTIPLE_THREADS_OFFSET offsetof (tcbhead_t, multiple_threads)
diff --git a/libpthread/linuxthreads/sysdeps/ia64/tls.h b/libpthread/linuxthreads/sysdeps/ia64/tls.h
index 0311a9ccb..c86073f26 100644
--- a/libpthread/linuxthreads/sysdeps/ia64/tls.h
+++ b/libpthread/linuxthreads/sysdeps/ia64/tls.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 _TLS_H
#define _TLS_H
diff --git a/libpthread/linuxthreads/sysdeps/m68k/pspinlock.c b/libpthread/linuxthreads/sysdeps/m68k/pspinlock.c
index 35b851faf..af77c2a9d 100644
--- a/libpthread/linuxthreads/sysdeps/m68k/pspinlock.c
+++ b/libpthread/linuxthreads/sysdeps/m68k/pspinlock.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; 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/>. */
#include <errno.h>
#include <pthread.h>
@@ -28,10 +27,15 @@ __pthread_spin_lock (pthread_spinlock_t *lock)
unsigned int val;
do
- __asm__ __volatile__ ("tas %1; sne %0"
- : "=dm" (val), "=m" (*lock)
- : "m" (*lock)
- : "cc");
+ __asm__ __volatile__ (
+#if !defined(__mcoldfire__) && !defined(__mcf5200__) && !defined(__m68000)
+ "tas %1; sne %0"
+#else
+ "bset #7,%1; sne %0"
+#endif
+ : "=dm" (val), "=m" (*lock)
+ : "m" (*lock)
+ : "cc");
while (val);
return 0;
@@ -44,7 +48,12 @@ __pthread_spin_trylock (pthread_spinlock_t *lock)
{
unsigned int val;
- __asm__ __volatile__ ("tas %1; sne %0"
+ __asm__ __volatile__ (
+#if !defined(__mcoldfire__) && !defined(__mcf5200__) && !defined(__m68000)
+ "tas %1; sne %0"
+#else
+ "bset #7,%1; sne %0"
+#endif
: "=dm" (val), "=m" (*lock)
: "m" (*lock)
: "cc");
diff --git a/libpthread/linuxthreads/sysdeps/m68k/pt-machine.h b/libpthread/linuxthreads/sysdeps/m68k/pt-machine.h
index a13c06946..1eb9fd57b 100644
--- a/libpthread/linuxthreads/sysdeps/m68k/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/m68k/pt-machine.h
@@ -16,8 +16,7 @@
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. */
+ not, see <http://www.gnu.org/licenses/>. */
#ifndef _PT_MACHINE_H
#define _PT_MACHINE_H 1
@@ -29,12 +28,18 @@
#endif
/* Spinlock implementation; required. */
+PT_EI long int testandset (int *spinlock);
PT_EI long int
testandset (int *spinlock)
{
char ret;
- __asm__ __volatile__("tas %1; sne %0"
+ __asm__ __volatile__(
+#if !defined(__mcoldfire__) && !defined(__mcf5200__) && !defined(__m68000)
+ "tas %1; sne %0"
+#else
+ "bset #7,%1; sne %0"
+#endif
: "=dm"(ret), "=m"(*spinlock)
: "m"(*spinlock)
: "cc");
@@ -51,6 +56,7 @@ register char * stack_pointer __asm__ ("%sp");
/* Compare-and-swap for semaphores. */
+#if !defined(__mcoldfire__) && !defined(__mcf5200__) && !defined(__mc68000)
#define HAS_COMPARE_AND_SWAP
PT_EI int
__compare_and_swap (long int *p, long int oldval, long int newval)
@@ -64,5 +70,5 @@ __compare_and_swap (long int *p, long int oldval, long int newval)
return ret;
}
-
+#endif
#endif /* pt-machine.h */
diff --git a/libpthread/linuxthreads/sysdeps/mips/pspinlock.c b/libpthread/linuxthreads/sysdeps/mips/pspinlock.c
index a106c0f77..7b9205ef0 100644
--- a/libpthread/linuxthreads/sysdeps/mips/pspinlock.c
+++ b/libpthread/linuxthreads/sysdeps/mips/pspinlock.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; 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/>. */
#include <errno.h>
#include <pthread.h>
@@ -23,8 +22,6 @@
#include <sys/tas.h>
#include "internals.h"
-#include <sgidefs.h>
-
/* This implementation is similar to the one used in the Linux kernel. */
int
__pthread_spin_lock (pthread_spinlock_t *lock)
diff --git a/libpthread/linuxthreads/sysdeps/mips/pt-machine.h b/libpthread/linuxthreads/sysdeps/mips/pt-machine.h
index 0ab7ac13f..74e8807eb 100644
--- a/libpthread/linuxthreads/sysdeps/mips/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/mips/pt-machine.h
@@ -18,8 +18,7 @@
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. */
+ not, see <http://www.gnu.org/licenses/>. */
#ifndef _PT_MACHINE_H
#define _PT_MACHINE_H 1
diff --git a/libpthread/linuxthreads/sysdeps/mips/tls.h b/libpthread/linuxthreads/sysdeps/mips/tls.h
index 15dda696d..4e7887a74 100644
--- a/libpthread/linuxthreads/sysdeps/mips/tls.h
+++ b/libpthread/linuxthreads/sysdeps/mips/tls.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 _TLS_H
#define _TLS_H
diff --git a/libpthread/linuxthreads/sysdeps/or1k/pt-machine.h b/libpthread/linuxthreads/sysdeps/or1k/pt-machine.h
new file mode 100644
index 000000000..c6c8ee470
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/or1k/pt-machine.h
@@ -0,0 +1,55 @@
+/* Machine-dependent pthreads configuration and inline functions.
+ OpenRISC 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; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifndef _PT_MACHINE_H
+#define _PT_MACHINE_H 1
+
+#include <features.h>
+#include <sys/syscall.h>
+
+#ifndef PT_EI
+# define PT_EI __extern_always_inline
+#endif
+
+PT_EI long int testandset(int*);
+
+#define OR1K_ATOMIC_XCHG 1
+
+PT_EI long int
+testandset (int *spinlock)
+{
+ int err;
+ int oldvalue = 1;
+
+ err = INLINE_SYSCALL(or1k_atomic, 3, OR1K_ATOMIC_XCHG, spinlock, &oldvalue);
+
+ return (oldvalue);
+}
+
+/* Get some notion of the current stack. Need not be exactly the top
+ of the stack, just something somewhere in the current frame. */
+#define CURRENT_STACK_FRAME stack_pointer()
+static inline char *stack_pointer(void)
+{
+ unsigned long ret;
+ __asm__ __volatile__ ("l.ori %0, r1, 0" : "=r" (ret));
+ return (char *)ret;
+}
+#endif /* pt-machine.h */
diff --git a/libpthread/linuxthreads/sysdeps/powerpc/powerpc32/pspinlock.c b/libpthread/linuxthreads/sysdeps/powerpc/powerpc32/pspinlock.c
index 15fd545c1..875aa3876 100644
--- a/libpthread/linuxthreads/sysdeps/powerpc/powerpc32/pspinlock.c
+++ b/libpthread/linuxthreads/sysdeps/powerpc/powerpc32/pspinlock.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; 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/>. */
#include <errno.h>
#include <pthread.h>
diff --git a/libpthread/linuxthreads/sysdeps/powerpc/powerpc32/pt-machine.h b/libpthread/linuxthreads/sysdeps/powerpc/powerpc32/pt-machine.h
index bfb13df67..a2b8b61e6 100644
--- a/libpthread/linuxthreads/sysdeps/powerpc/powerpc32/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/powerpc/powerpc32/pt-machine.h
@@ -16,8 +16,7 @@
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. */
+ not, see <http://www.gnu.org/licenses/>. */
/* These routines are from Appendix G of the 'PowerPC 601 RISC Microprocessor
User's Manual', by IBM and Motorola. */
diff --git a/libpthread/linuxthreads/sysdeps/powerpc/powerpc64/pspinlock.c b/libpthread/linuxthreads/sysdeps/powerpc/powerpc64/pspinlock.c
index 19161c6e1..f588c62c7 100644
--- a/libpthread/linuxthreads/sysdeps/powerpc/powerpc64/pspinlock.c
+++ b/libpthread/linuxthreads/sysdeps/powerpc/powerpc64/pspinlock.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; 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/>. */
#include <errno.h>
#include <pthread.h>
diff --git a/libpthread/linuxthreads/sysdeps/powerpc/powerpc64/pt-machine.h b/libpthread/linuxthreads/sysdeps/powerpc/powerpc64/pt-machine.h
index d7ed84108..b9193a871 100644
--- a/libpthread/linuxthreads/sysdeps/powerpc/powerpc64/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/powerpc/powerpc64/pt-machine.h
@@ -15,8 +15,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. */
+ not, see <http://www.gnu.org/licenses/>. */
/* These routines are from Appendix G of the 'PowerPC 601 RISC Microprocessor
User's Manual', by IBM and Motorola. */
diff --git a/libpthread/linuxthreads/sysdeps/powerpc/tcb-offsets.sym b/libpthread/linuxthreads/sysdeps/powerpc/tcb-offsets.sym
index 7c5cca01e..7940cf620 100644
--- a/libpthread/linuxthreads/sysdeps/powerpc/tcb-offsets.sym
+++ b/libpthread/linuxthreads/sysdeps/powerpc/tcb-offsets.sym
@@ -3,7 +3,7 @@
-- This line separates the #include lines from conditionals.
-# ifdef USE_TLS
+# ifdef __UCLIBC_HAS_TLS__
-- Abuse tls.h macros to derive offsets relative to the thread register.
# undef __thread_register
diff --git a/libpthread/linuxthreads/sysdeps/powerpc/tls.h b/libpthread/linuxthreads/sysdeps/powerpc/tls.h
index 1ae0b60ff..8555b239d 100644
--- a/libpthread/linuxthreads/sysdeps/powerpc/tls.h
+++ b/libpthread/linuxthreads/sysdeps/powerpc/tls.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 _TLS_H
#define _TLS_H
diff --git a/libpthread/linuxthreads/sysdeps/pthread/.cvsignore b/libpthread/linuxthreads/sysdeps/pthread/.cvsignore
deleted file mode 100644
index 7ee8f5969..000000000
--- a/libpthread/linuxthreads/sysdeps/pthread/.cvsignore
+++ /dev/null
@@ -1,2 +0,0 @@
-.cvsignore
-*.os
diff --git a/libpthread/linuxthreads/sysdeps/pthread/bits/initspin.h b/libpthread/linuxthreads/sysdeps/pthread/bits/initspin.h
index a19ec077e..b9e4acf30 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/bits/initspin.h
+++ b/libpthread/linuxthreads/sysdeps/pthread/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/libpthread/linuxthreads/sysdeps/pthread/bits/libc-lock.h b/libpthread/linuxthreads/sysdeps/pthread/bits/libc-lock.h
index 2299b3af5..855efff12 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/bits/libc-lock.h
+++ b/libpthread/linuxthreads/sysdeps/pthread/bits/libc-lock.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; 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_LIBC_LOCK_H
#define _BITS_LIBC_LOCK_H 1
@@ -293,7 +292,7 @@ typedef pthread_key_t __libc_key_t;
library. */
extern int __pthread_mutex_init (pthread_mutex_t *__mutex,
- __const pthread_mutexattr_t *__mutex_attr);
+ const pthread_mutexattr_t *__mutex_attr);
extern int __pthread_mutex_destroy (pthread_mutex_t *__mutex);
@@ -312,7 +311,7 @@ extern int __pthread_mutexattr_settype (pthread_mutexattr_t *__attr,
#ifdef __USE_UNIX98
extern int __pthread_rwlock_init (pthread_rwlock_t *__rwlock,
- __const pthread_rwlockattr_t *__attr);
+ const pthread_rwlockattr_t *__attr);
extern int __pthread_rwlock_destroy (pthread_rwlock_t *__rwlock);
@@ -331,7 +330,7 @@ extern int __pthread_key_create (pthread_key_t *__key,
void (*__destr_function) (void *));
extern int __pthread_setspecific (pthread_key_t __key,
- __const void *__pointer);
+ const void *__pointer);
extern void *__pthread_getspecific (pthread_key_t __key);
diff --git a/libpthread/linuxthreads/sysdeps/pthread/bits/libc-tsd.h b/libpthread/linuxthreads/sysdeps/pthread/bits/libc-tsd.h
index fa6eb4be2..7cc5f9cf6 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/bits/libc-tsd.h
+++ b/libpthread/linuxthreads/sysdeps/pthread/bits/libc-tsd.h
@@ -13,18 +13,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; 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_LIBC_TSD_H
#define _BITS_LIBC_TSD_H 1
#include <linuxthreads/descr.h>
+#ifdef __UCLIBC_HAS_TLS__
#include <tls.h>
-#if USE_TLS && HAVE___THREAD
-
/* When __thread works, the generic definition is what we want. */
# include <sysdeps/generic/bits/libc-tsd.h>
diff --git a/libpthread/linuxthreads/sysdeps/pthread/bits/pthreadtypes.h b/libpthread/linuxthreads/sysdeps/pthread/bits/pthreadtypes.h
index 4ea6d8ac5..8d01c8908 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/bits/pthreadtypes.h
+++ b/libpthread/linuxthreads/sysdeps/pthread/bits/pthreadtypes.h
@@ -19,6 +19,9 @@
#ifndef _BITS_PTHREADTYPES_H
#define _BITS_PTHREADTYPES_H 1
+#define __need_size_t
+#include <stddef.h>
+
#define __need_schedparam
#include <bits/sched.h>
diff --git a/libpthread/linuxthreads/sysdeps/pthread/bits/typesizes.h b/libpthread/linuxthreads/sysdeps/pthread/bits/typesizes.h
index 45264ac9c..0e900d2d5 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/bits/typesizes.h
+++ b/libpthread/linuxthreads/sysdeps/pthread/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/libpthread/linuxthreads/sysdeps/pthread/errno-loc.c b/libpthread/linuxthreads/sysdeps/pthread/errno-loc.c
index c3b3087e4..8bdfff485 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/errno-loc.c
+++ b/libpthread/linuxthreads/sysdeps/pthread/errno-loc.c
@@ -14,26 +14,25 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 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 <linuxthreads/internals.h>
#include <sysdep-cancel.h>
-#if ! USE___THREAD && !RTLD_PRIVATE_ERRNO
+#if !defined __UCLIBC_HAS_TLS__ && !RTLD_PRIVATE_ERRNO
#undef errno
extern int errno;
#endif
int *
-#if ! USE___THREAD
+#ifndef __UCLIBC_HAS_TLS__
weak_const_function
#endif
__errno_location (void)
{
-#if ! USE___THREAD && !defined NOT_IN_libc
+#if !defined __UCLIBC_HAS_TLS__ && !defined NOT_IN_libc
if (! SINGLE_THREAD_P)
{
pthread_descr self = thread_self();
diff --git a/libpthread/linuxthreads/sysdeps/pthread/flockfile.c b/libpthread/linuxthreads/sysdeps/pthread/flockfile.c
index 918cb84f6..538e368a0 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/flockfile.c
+++ b/libpthread/linuxthreads/sysdeps/pthread/flockfile.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 <pthread.h>
#include <stdio.h>
diff --git a/libpthread/linuxthreads/sysdeps/pthread/ftrylockfile.c b/libpthread/linuxthreads/sysdeps/pthread/ftrylockfile.c
index 21c1ea01e..d814258d8 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/ftrylockfile.c
+++ b/libpthread/linuxthreads/sysdeps/pthread/ftrylockfile.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 <pthread.h>
diff --git a/libpthread/linuxthreads/sysdeps/pthread/funlockfile.c b/libpthread/linuxthreads/sysdeps/pthread/funlockfile.c
index f941fc985..f45479936 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/funlockfile.c
+++ b/libpthread/linuxthreads/sysdeps/pthread/funlockfile.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 <pthread.h>
#include <stdio.h>
diff --git a/libpthread/linuxthreads/sysdeps/pthread/getcpuclockid.c b/libpthread/linuxthreads/sysdeps/pthread/getcpuclockid.c
index 1c64e6c2b..6acb179c5 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/getcpuclockid.c
+++ b/libpthread/linuxthreads/sysdeps/pthread/getcpuclockid.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; 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/>. */
#include <errno.h>
#include <pthread.h>
@@ -23,7 +22,7 @@
#include <time.h>
#include <internals.h>
#include <spinlock.h>
-#include <kernel-features.h>
+#include <bits/kernel-features.h>
#include <kernel-posix-cpu-timers.h>
diff --git a/libpthread/linuxthreads/sysdeps/pthread/herrno-loc.c b/libpthread/linuxthreads/sysdeps/pthread/herrno-loc.c
index fbc557616..634c75245 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/herrno-loc.c
+++ b/libpthread/linuxthreads/sysdeps/pthread/herrno-loc.c
@@ -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/>. */
#include <netdb.h>
+#ifdef __UCLIBC_HAS_TLS__
#include <tls.h>
+#endif
#include <linuxthreads/internals.h>
#include <sysdep-cancel.h>
-#if ! USE___THREAD
+#ifndef __UCLIBC_HAS_TLS__
# undef h_errno
extern int h_errno;
#endif
@@ -31,7 +32,7 @@ int *
weak_const_function
__h_errno_location (void)
{
-#if ! USE___THREAD
+#ifndef __UCLIBC_HAS_TLS__
if (! SINGLE_THREAD_P)
{
pthread_descr self = thread_self();
diff --git a/libpthread/linuxthreads/sysdeps/pthread/kernel-features.h b/libpthread/linuxthreads/sysdeps/pthread/kernel-features.h
deleted file mode 100644
index 88a71828b..000000000
--- a/libpthread/linuxthreads/sysdeps/pthread/kernel-features.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* 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, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-/* 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
-
-/* Real-time signal became usable in 2.1.70. */
-#if __LINUX_KERNEL_VERSION >= 131398
-# define __ASSUME_REALTIME_SIGNALS 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
-
-/* 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
-
-/* 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
-
-/* 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
-
-/* 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
-
-/* 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
-
-/* 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
diff --git a/libpthread/linuxthreads/sysdeps/pthread/list.h b/libpthread/linuxthreads/sysdeps/pthread/list.h
index 75decfbb7..232988fd6 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/list.h
+++ b/libpthread/linuxthreads/sysdeps/pthread/list.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 _LIST_H
#define _LIST_H 1
diff --git a/libpthread/linuxthreads/sysdeps/pthread/malloc-machine.h b/libpthread/linuxthreads/sysdeps/pthread/malloc-machine.h
index 5191f8c77..f70729fd7 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/malloc-machine.h
+++ b/libpthread/linuxthreads/sysdeps/pthread/malloc-machine.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 _MALLOC_MACHINE_H
#define _MALLOC_MACHINE_H
diff --git a/libpthread/linuxthreads/sysdeps/pthread/not-cancel.h b/libpthread/linuxthreads/sysdeps/pthread/not-cancel.h
index 4373917df..b46d2ab49 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/not-cancel.h
+++ b/libpthread/linuxthreads/sysdeps/pthread/not-cancel.h
@@ -1,5 +1,5 @@
/* Uncancelable versions of cancelable interfaces. Linux version.
- Copyright (C) 2003 Free Software Foundation, Inc.
+ 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.
@@ -14,19 +14,48 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 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>
-#undef INLINE_SYSCALL
-#define INLINE_SYSCALL(func, numargs, args...) syscall(__NR_ ## func, args)
+#include <sys/types.h>
+#include <sysdep.h>
/* Uncancelable open. */
+#if defined __NR_openat && !defined __NR_open
+#define open_not_cancel(name, flags, mode) \
+ INLINE_SYSCALL (openat, 4, (int) (AT_FDCWD), (const char *) (name), \
+ (flags), (mode))
+#define open_not_cancel_2(name, flags) \
+ INLINE_SYSCALL (openat, 3, (int) (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
+
+/* 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)
/* Uncancelable close. */
#define close_not_cancel(fd) \
@@ -60,3 +89,25 @@
# define waitpid_not_cancel(pid, stat_loc, options) \
INLINE_SYSCALL (wait4, 4, pid, stat_loc, options, NULL)
#endif
+
+/* Uncancelable pause. */
+#ifdef __NR_pause
+# define pause_not_cancel() \
+ INLINE_SYSCALL (pause, 0)
+#else
+# 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
+
+/* Uncancelable sigsuspend. */
+#define sigsuspend_not_cancel(set) \
+ __sigsuspend_nocancel (set)
diff --git a/libpthread/linuxthreads/sysdeps/pthread/posix-timer.h b/libpthread/linuxthreads/sysdeps/pthread/posix-timer.h
index 5486f7d6a..4ac64d9ac 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/posix-timer.h
+++ b/libpthread/linuxthreads/sysdeps/pthread/posix-timer.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; 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/>. */
#include <limits.h>
#include <signal.h>
diff --git a/libpthread/linuxthreads/sysdeps/pthread/pt-initfini.c b/libpthread/linuxthreads/sysdeps/pthread/pt-initfini.c
index 15aeb2166..86d4c84e9 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/pt-initfini.c
+++ b/libpthread/linuxthreads/sysdeps/pthread/pt-initfini.c
@@ -23,8 +23,7 @@
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, 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
+ see <http://www.gnu.org/licenses/>. */
/* This file is compiled into assembly code which is then munged by a sed
script into two files: crti.s and crtn.s.
diff --git a/libpthread/linuxthreads/sysdeps/pthread/pthread-functions.h b/libpthread/linuxthreads/sysdeps/pthread/pthread-functions.h
index 258e1fc23..6d8663dcb 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/pthread-functions.h
+++ b/libpthread/linuxthreads/sysdeps/pthread/pthread-functions.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 _PTHREAD_FUNCTIONS_H
#define _PTHREAD_FUNCTIONS_H 1
@@ -72,10 +71,12 @@ struct pthread_functions
void (*ptr_pthread_cleanup_upto) (__jmp_buf target,
char *targetframe);
pthread_descr (*ptr_pthread_thread_self) (void);
+#if !defined __UCLIBC_HAS_TLS__ && defined __UCLIBC_HAS_RPC__
int (*ptr_pthread_internal_tsd_set) (int key, const void *pointer);
void * (*ptr_pthread_internal_tsd_get) (int key);
void ** __attribute__ ((__const__))
(*ptr_pthread_internal_tsd_address) (int key);
+#endif
int (*ptr_pthread_sigaction) (int sig, const struct sigaction * act,
struct sigaction *oact);
int (*ptr_pthread_sigwait) (const sigset_t *set, int *sig);
@@ -95,4 +96,6 @@ struct pthread_functions
/* Variable in libc.so. */
extern struct pthread_functions __libc_pthread_functions attribute_hidden;
+extern int * __libc_pthread_init (const struct pthread_functions *functions);
+
#endif /* pthread-functions.h */
diff --git a/libpthread/linuxthreads/sysdeps/pthread/pthread.h b/libpthread/linuxthreads/sysdeps/pthread/pthread.h
index 0fa3be131..df01c111f 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/pthread.h
+++ b/libpthread/linuxthreads/sysdeps/pthread/pthread.h
@@ -161,9 +161,9 @@ enum
if ATTR is NULL), and call function START_ROUTINE with given
arguments ARG. */
extern int pthread_create (pthread_t *__restrict __threadp,
- __const pthread_attr_t *__restrict __attr,
+ const pthread_attr_t *__restrict __attr,
void *(*__start_routine) (void *),
- void *__restrict __arg) __THROW;
+ void *__restrict __arg) __THROWNL;
/* Obtain the identifier of the current thread. */
extern pthread_t pthread_self (void) __THROW;
@@ -201,16 +201,16 @@ extern int pthread_attr_setdetachstate (pthread_attr_t *__attr,
int __detachstate) __THROW;
/* Return in *DETACHSTATE the `detachstate' attribute in *ATTR. */
-extern int pthread_attr_getdetachstate (__const pthread_attr_t *__attr,
+extern int pthread_attr_getdetachstate (const pthread_attr_t *__attr,
int *__detachstate) __THROW;
/* Set scheduling parameters (priority, etc) in *ATTR according to PARAM. */
extern int pthread_attr_setschedparam (pthread_attr_t *__restrict __attr,
- __const struct sched_param *__restrict
+ const struct sched_param *__restrict
__param) __THROW;
/* Return in *PARAM the scheduling parameters of *ATTR. */
-extern int pthread_attr_getschedparam (__const pthread_attr_t *__restrict
+extern int pthread_attr_getschedparam (const pthread_attr_t *__restrict
__attr,
struct sched_param *__restrict __param)
__THROW;
@@ -220,7 +220,7 @@ extern int pthread_attr_setschedpolicy (pthread_attr_t *__attr, int __policy)
__THROW;
/* Return in *POLICY the scheduling policy of *ATTR. */
-extern int pthread_attr_getschedpolicy (__const pthread_attr_t *__restrict
+extern int pthread_attr_getschedpolicy (const pthread_attr_t *__restrict
__attr, int *__restrict __policy)
__THROW;
@@ -229,7 +229,7 @@ extern int pthread_attr_setinheritsched (pthread_attr_t *__attr,
int __inherit) __THROW;
/* Return in *INHERIT the scheduling inheritance mode of *ATTR. */
-extern int pthread_attr_getinheritsched (__const pthread_attr_t *__restrict
+extern int pthread_attr_getinheritsched (const pthread_attr_t *__restrict
__attr, int *__restrict __inherit)
__THROW;
@@ -238,7 +238,7 @@ extern int pthread_attr_setscope (pthread_attr_t *__attr, int __scope)
__THROW;
/* Return in *SCOPE the scheduling contention scope of *ATTR. */
-extern int pthread_attr_getscope (__const pthread_attr_t *__restrict __attr,
+extern int pthread_attr_getscope (const pthread_attr_t *__restrict __attr,
int *__restrict __scope) __THROW;
#ifdef __USE_UNIX98
@@ -247,11 +247,12 @@ extern int pthread_attr_setguardsize (pthread_attr_t *__attr,
size_t __guardsize) __THROW;
/* Get the size of the guard area at the bottom of the thread. */
-extern int pthread_attr_getguardsize (__const pthread_attr_t *__restrict
+extern int pthread_attr_getguardsize (const pthread_attr_t *__restrict
__attr, size_t *__restrict __guardsize)
__THROW;
#endif
+#if 0 /* uClibc: deprecated stuff disabled. def __UCLIBC_SUSV3_LEGACY__ */
/* Set the starting address of the stack of the thread to be created.
Depending on whether the stack grows up or down the value must either
be higher or lower than all the address in the memory block. The
@@ -260,9 +261,10 @@ extern int pthread_attr_setstackaddr (pthread_attr_t *__attr,
void *__stackaddr) __THROW;
/* Return the previously set address for the stack. */
-extern int pthread_attr_getstackaddr (__const pthread_attr_t *__restrict
+extern int pthread_attr_getstackaddr (const pthread_attr_t *__restrict
__attr, void **__restrict __stackaddr)
__THROW;
+#endif
#ifdef __USE_XOPEN2K
/* The following two interfaces are intended to replace the last two. They
@@ -272,7 +274,7 @@ extern int pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr,
size_t __stacksize) __THROW;
/* Return the previously set address for the stack. */
-extern int pthread_attr_getstack (__const pthread_attr_t *__restrict __attr,
+extern int pthread_attr_getstack (const pthread_attr_t *__restrict __attr,
void **__restrict __stackaddr,
size_t *__restrict __stacksize) __THROW;
#endif
@@ -284,13 +286,13 @@ extern int pthread_attr_setstacksize (pthread_attr_t *__attr,
size_t __stacksize) __THROW;
/* Return the currently used minimal stack size. */
-extern int pthread_attr_getstacksize (__const pthread_attr_t *__restrict
+extern int pthread_attr_getstacksize (const pthread_attr_t *__restrict
__attr, size_t *__restrict __stacksize)
__THROW;
#ifdef __USE_GNU
/* Initialize thread attribute *ATTR with attributes corresponding to the
- already running thread TH. It shall be called on unitialized ATTR
+ already running thread TH. It shall be called on uninitialized ATTR
and destroyed with pthread_attr_destroy when no longer needed. */
extern int pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr) __THROW;
#endif
@@ -300,7 +302,7 @@ extern int pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr) __THROW;
/* Set the scheduling parameters for TARGET_THREAD according to POLICY
and *PARAM. */
extern int pthread_setschedparam (pthread_t __target_thread, int __policy,
- __const struct sched_param *__param)
+ const struct sched_param *__param)
__THROW;
/* Return in *POLICY and *PARAM the scheduling parameters for TARGET_THREAD. */
@@ -322,27 +324,27 @@ extern int pthread_setconcurrency (int __level) __THROW;
/* Initialize MUTEX using attributes in *MUTEX_ATTR, or use the
default values if later is NULL. */
extern int pthread_mutex_init (pthread_mutex_t *__restrict __mutex,
- __const pthread_mutexattr_t *__restrict
+ const pthread_mutexattr_t *__restrict
__mutex_attr) __THROW;
/* Destroy MUTEX. */
extern int pthread_mutex_destroy (pthread_mutex_t *__mutex) __THROW;
/* Try to lock MUTEX. */
-extern int pthread_mutex_trylock (pthread_mutex_t *__mutex) __THROW;
+extern int pthread_mutex_trylock (pthread_mutex_t *__mutex) __THROWNL;
/* Wait until lock for MUTEX becomes available and lock it. */
-extern int pthread_mutex_lock (pthread_mutex_t *__mutex) __THROW;
+extern int pthread_mutex_lock (pthread_mutex_t *__mutex) __THROWNL;
#ifdef __USE_XOPEN2K
/* Wait until lock becomes available, or specified time passes. */
extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex,
- __const struct timespec *__restrict
- __abstime) __THROW;
+ const struct timespec *__restrict
+ __abstime) __THROWNL;
#endif
/* Unlock MUTEX. */
-extern int pthread_mutex_unlock (pthread_mutex_t *__mutex) __THROW;
+extern int pthread_mutex_unlock (pthread_mutex_t *__mutex) __THROWNL;
/* Functions for handling mutex attributes. */
@@ -355,7 +357,7 @@ extern int pthread_mutexattr_init (pthread_mutexattr_t *__attr) __THROW;
extern int pthread_mutexattr_destroy (pthread_mutexattr_t *__attr) __THROW;
/* Get the process-shared flag of the mutex attribute ATTR. */
-extern int pthread_mutexattr_getpshared (__const pthread_mutexattr_t *
+extern int pthread_mutexattr_getpshared (const pthread_mutexattr_t *
__restrict __attr,
int *__restrict __pshared) __THROW;
@@ -371,7 +373,7 @@ extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind)
__THROW;
/* Return in *KIND the mutex kind attribute in *ATTR. */
-extern int pthread_mutexattr_gettype (__const pthread_mutexattr_t *__restrict
+extern int pthread_mutexattr_gettype (const pthread_mutexattr_t *__restrict
__attr, int *__restrict __kind) __THROW;
#endif
@@ -381,17 +383,17 @@ extern int pthread_mutexattr_gettype (__const pthread_mutexattr_t *__restrict
/* Initialize condition variable COND using attributes ATTR, or use
the default values if later is NULL. */
extern int pthread_cond_init (pthread_cond_t *__restrict __cond,
- __const pthread_condattr_t *__restrict
+ const pthread_condattr_t *__restrict
__cond_attr) __THROW;
/* Destroy condition variable COND. */
extern int pthread_cond_destroy (pthread_cond_t *__cond) __THROW;
/* Wake up one thread waiting for condition variable COND. */
-extern int pthread_cond_signal (pthread_cond_t *__cond) __THROW;
+extern int pthread_cond_signal (pthread_cond_t *__cond) __THROWNL;
/* Wake up all threads waiting for condition variables COND. */
-extern int pthread_cond_broadcast (pthread_cond_t *__cond) __THROW;
+extern int pthread_cond_broadcast (pthread_cond_t *__cond) __THROWNL;
/* Wait for condition variable COND to be signaled or broadcast.
MUTEX is assumed to be locked before. */
@@ -404,7 +406,7 @@ extern int pthread_cond_wait (pthread_cond_t *__restrict __cond,
(00:00:00 GMT, January 1, 1970). */
extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,
pthread_mutex_t *__restrict __mutex,
- __const struct timespec *__restrict
+ const struct timespec *__restrict
__abstime);
/* Functions for handling condition variable attributes. */
@@ -416,7 +418,7 @@ extern int pthread_condattr_init (pthread_condattr_t *__attr) __THROW;
extern int pthread_condattr_destroy (pthread_condattr_t *__attr) __THROW;
/* Get the process-shared flag of the condition variable attribute ATTR. */
-extern int pthread_condattr_getpshared (__const pthread_condattr_t *
+extern int pthread_condattr_getpshared (const pthread_condattr_t *
__restrict __attr,
int *__restrict __pshared) __THROW;
@@ -431,40 +433,40 @@ extern int pthread_condattr_setpshared (pthread_condattr_t *__attr,
/* Initialize read-write lock RWLOCK using attributes ATTR, or use
the default values if later is NULL. */
extern int pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock,
- __const pthread_rwlockattr_t *__restrict
+ const pthread_rwlockattr_t *__restrict
__attr) __THROW;
/* Destroy read-write lock RWLOCK. */
extern int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock) __THROW;
/* Acquire read lock for RWLOCK. */
-extern int pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock) __THROW;
+extern int pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock) __THROWNL;
/* Try to acquire read lock for RWLOCK. */
-extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock) __THROW;
+extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock) __THROWNL;
# ifdef __USE_XOPEN2K
/* Try to acquire read lock for RWLOCK or return after specfied time. */
extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock,
- __const struct timespec *__restrict
- __abstime) __THROW;
+ const struct timespec *__restrict
+ __abstime) __THROWNL;
# endif
/* Acquire write lock for RWLOCK. */
-extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock) __THROW;
+extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock) __THROWNL;
/* Try to acquire write lock for RWLOCK. */
-extern int pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock) __THROW;
+extern int pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock) __THROWNL;
# ifdef __USE_XOPEN2K
/* Try to acquire write lock for RWLOCK or return after specfied time. */
extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock,
- __const struct timespec *__restrict
- __abstime) __THROW;
+ const struct timespec *__restrict
+ __abstime) __THROWNL;
# endif
/* Unlock RWLOCK. */
-extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock) __THROW;
+extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock) __THROWNL;
/* Functions for handling read-write lock attributes. */
@@ -476,7 +478,7 @@ extern int pthread_rwlockattr_init (pthread_rwlockattr_t *__attr) __THROW;
extern int pthread_rwlockattr_destroy (pthread_rwlockattr_t *__attr) __THROW;
/* Return current setting of process-shared attribute of ATTR in PSHARED. */
-extern int pthread_rwlockattr_getpshared (__const pthread_rwlockattr_t *
+extern int pthread_rwlockattr_getpshared (const pthread_rwlockattr_t *
__restrict __attr,
int *__restrict __pshared) __THROW;
@@ -485,7 +487,7 @@ extern int pthread_rwlockattr_setpshared (pthread_rwlockattr_t *__attr,
int __pshared) __THROW;
/* Return current setting of reader/writer preference. */
-extern int pthread_rwlockattr_getkind_np (__const pthread_rwlockattr_t *__attr,
+extern int pthread_rwlockattr_getkind_np (const pthread_rwlockattr_t *__attr,
int *__pref) __THROW;
/* Set reader/write preference. */
@@ -506,19 +508,19 @@ extern int pthread_spin_init (pthread_spinlock_t *__lock, int __pshared)
extern int pthread_spin_destroy (pthread_spinlock_t *__lock) __THROW;
/* Wait until spinlock LOCK is retrieved. */
-extern int pthread_spin_lock (pthread_spinlock_t *__lock) __THROW;
+extern int pthread_spin_lock (pthread_spinlock_t *__lock) __THROWNL;
/* Try to lock spinlock LOCK. */
-extern int pthread_spin_trylock (pthread_spinlock_t *__lock) __THROW;
+extern int pthread_spin_trylock (pthread_spinlock_t *__lock) __THROWNL;
/* Release spinlock LOCK. */
-extern int pthread_spin_unlock (pthread_spinlock_t *__lock) __THROW;
+extern int pthread_spin_unlock (pthread_spinlock_t *__lock) __THROWNL;
/* Barriers are a also a new feature in 1003.1j-2000. */
extern int pthread_barrier_init (pthread_barrier_t *__restrict __barrier,
- __const pthread_barrierattr_t *__restrict
+ const pthread_barrierattr_t *__restrict
__attr, unsigned int __count) __THROW;
extern int pthread_barrier_destroy (pthread_barrier_t *__barrier) __THROW;
@@ -527,14 +529,14 @@ extern int pthread_barrierattr_init (pthread_barrierattr_t *__attr) __THROW;
extern int pthread_barrierattr_destroy (pthread_barrierattr_t *__attr) __THROW;
-extern int pthread_barrierattr_getpshared (__const pthread_barrierattr_t *
+extern int pthread_barrierattr_getpshared (const pthread_barrierattr_t *
__restrict __attr,
int *__restrict __pshared) __THROW;
extern int pthread_barrierattr_setpshared (pthread_barrierattr_t *__attr,
int __pshared) __THROW;
-extern int pthread_barrier_wait (pthread_barrier_t *__barrier) __THROW;
+extern int pthread_barrier_wait (pthread_barrier_t *__barrier) __THROWNL;
#endif
@@ -554,7 +556,7 @@ extern int pthread_key_delete (pthread_key_t __key) __THROW;
/* Store POINTER in the thread-specific data slot identified by KEY. */
extern int pthread_setspecific (pthread_key_t __key,
- __const void *__pointer) __THROW;
+ const void *__pointer) __THROW;
/* Return current value of the thread-specific data slot identified by KEY. */
extern void *pthread_getspecific (pthread_key_t __key) __THROW;
diff --git a/libpthread/linuxthreads/sysdeps/pthread/ptlongjmp.c b/libpthread/linuxthreads/sysdeps/pthread/ptlongjmp.c
index a2a56b8d9..ee5522036 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/ptlongjmp.c
+++ b/libpthread/linuxthreads/sysdeps/pthread/ptlongjmp.c
@@ -19,13 +19,6 @@
#include "pthread.h"
#include "internals.h"
-/* These functions are not declared anywhere since they shouldn't be
- used at another place but here. */
-extern void __libc_siglongjmp (sigjmp_buf env, int val)
- __attribute__ ((noreturn));
-extern void __libc_longjmp (sigjmp_buf env, int val)
- __attribute__ ((noreturn));
-
#ifdef SHARED
void siglongjmp (sigjmp_buf env, int val)
{
diff --git a/libpthread/linuxthreads/sysdeps/pthread/res-state.c b/libpthread/linuxthreads/sysdeps/pthread/res-state.c
index 016e20b4e..6b4354972 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/res-state.c
+++ b/libpthread/linuxthreads/sysdeps/pthread/res-state.c
@@ -12,28 +12,27 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 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 <resolv.h>
#include <tls.h>
#include <linuxthreads/internals.h>
#include <sysdep-cancel.h>
-#if ! USE___THREAD
+#ifndef __UCLIBC_HAS_TLS__
# undef _res
extern struct __res_state _res;
#endif
/* When threaded, _res may be a per-thread variable. */
struct __res_state *
-#if ! USE___THREAD
+#ifndef __UCLIBC_HAS_TLS__
weak_const_function
#endif
__res_state (void)
{
-#if ! USE___THREAD
+#ifndef __UCLIBC_HAS_TLS__
if (! SINGLE_THREAD_P)
{
pthread_descr self = thread_self();
diff --git a/libpthread/linuxthreads/sysdeps/pthread/sigaction.c b/libpthread/linuxthreads/sysdeps/pthread/sigaction.c
index 0a0a9e29f..eecb8c395 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/sigaction.c
+++ b/libpthread/linuxthreads/sysdeps/pthread/sigaction.c
@@ -13,9 +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/>. */
+
+/* Somebody please explain what's going on here. --vda */
/* This is tricky. GCC doesn't like #include_next in the primary
source file and even if it did, the first #include_next is this
diff --git a/libpthread/linuxthreads/sysdeps/pthread/timer_create.c b/libpthread/linuxthreads/sysdeps/pthread/timer_create.c
index 7f7e886c8..36fce3567 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/timer_create.c
+++ b/libpthread/linuxthreads/sysdeps/pthread/timer_create.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; 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/>. */
#include <errno.h>
#include <signal.h>
diff --git a/libpthread/linuxthreads/sysdeps/pthread/timer_delete.c b/libpthread/linuxthreads/sysdeps/pthread/timer_delete.c
index 48ba1f272..a529d7392 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/timer_delete.c
+++ b/libpthread/linuxthreads/sysdeps/pthread/timer_delete.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; 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/>. */
#include <assert.h>
#include <errno.h>
diff --git a/libpthread/linuxthreads/sysdeps/pthread/timer_getoverr.c b/libpthread/linuxthreads/sysdeps/pthread/timer_getoverr.c
index f3e22215b..6d753e30d 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/timer_getoverr.c
+++ b/libpthread/linuxthreads/sysdeps/pthread/timer_getoverr.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; 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/>. */
#include <errno.h>
#include <pthread.h>
diff --git a/libpthread/linuxthreads/sysdeps/pthread/timer_gettime.c b/libpthread/linuxthreads/sysdeps/pthread/timer_gettime.c
index 723a61632..6bd2b84e2 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/timer_gettime.c
+++ b/libpthread/linuxthreads/sysdeps/pthread/timer_gettime.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; 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/>. */
#include <errno.h>
#include <pthread.h>
diff --git a/libpthread/linuxthreads/sysdeps/pthread/timer_routines.c b/libpthread/linuxthreads/sysdeps/pthread/timer_routines.c
index 25b4630ee..9f6096ba5 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/timer_routines.c
+++ b/libpthread/linuxthreads/sysdeps/pthread/timer_routines.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; 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/>. */
#include <assert.h>
#include <errno.h>
diff --git a/libpthread/linuxthreads/sysdeps/pthread/timer_settime.c b/libpthread/linuxthreads/sysdeps/pthread/timer_settime.c
index 592b5271b..da0908b0b 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/timer_settime.c
+++ b/libpthread/linuxthreads/sysdeps/pthread/timer_settime.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; 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/>. */
#include <errno.h>
#include <pthread.h>
diff --git a/libpthread/linuxthreads/sysdeps/pthread/tst-timer.c b/libpthread/linuxthreads/sysdeps/pthread/tst-timer.c
index 7417bcd5f..0a679d9c6 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/tst-timer.c
+++ b/libpthread/linuxthreads/sysdeps/pthread/tst-timer.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; 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/>. */
#include <errno.h>
#include <signal.h>
diff --git a/libpthread/linuxthreads/sysdeps/pthread/uClibc-glue.h b/libpthread/linuxthreads/sysdeps/pthread/uClibc-glue.h
index 92619e5b4..b957dedc9 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/uClibc-glue.h
+++ b/libpthread/linuxthreads/sysdeps/pthread/uClibc-glue.h
@@ -6,7 +6,7 @@
#include <bits/uClibc_page.h>
#ifdef IS_IN_libpthread
-#include "kernel-features.h"
+#include <bits/kernel-features.h>
#ifndef __GLIBC_HAVE_LONG_LONG
# define __GLIBC_HAVE_LONG_LONG
@@ -42,8 +42,6 @@ extern int __cxa_atexit (void (*func) (void *), void *arg, void *d);
/* Use a funky version in a probably vein attempt at preventing gdb
* from dlopen()'ing glibc's libthread_db library... */
-#define STRINGIFY(s) STRINGIFY2 (s)
-#define STRINGIFY2(s) #s
-#define VERSION STRINGIFY(__UCLIBC_MAJOR__) "." STRINGIFY(__UCLIBC_MINOR__) "." STRINGIFY(__UCLIBC_SUBLEVEL__)
+#define VERSION __stringify(__UCLIBC_MAJOR__) "." __stringify(__UCLIBC_MINOR__) "." __stringify(__UCLIBC_SUBLEVEL__)
#endif
diff --git a/libpthread/linuxthreads/sysdeps/s390/pspinlock.c b/libpthread/linuxthreads/sysdeps/s390/pspinlock.c
deleted file mode 100644
index 98be504e1..000000000
--- a/libpthread/linuxthreads/sysdeps/s390/pspinlock.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/* POSIX spinlock implementation. S/390 version.
- Copyright (C) 2000, 2004 Free Software Foundation, Inc.
- Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of the
- License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-#include <errno.h>
-#include <pthread.h>
-#include "internals.h"
-
-/* This implementation is similar to the one used in the Linux kernel.
- But the kernel is byte instructions for the memory access. This is
- faster but unusable here. The problem is that only 128
- threads/processes could use the spinlock at the same time. If (by
- a design error in the program) a thread/process would hold the
- spinlock for a time long enough to accumulate 128 waiting
- processes, the next one will find a positive value in the spinlock
- and assume it is unlocked. We cannot accept that. */
-
-int
-__pthread_spin_lock (pthread_spinlock_t *lock)
-{
- __asm__ __volatile__(" basr 1,0\n"
- "0: slr 0,0\n"
- " cs 0,1,%1\n"
- " jl 0b\n"
- : "=m" (*lock)
- : "m" (*lock) : "0", "1", "cc" );
- return 0;
-}
-weak_alias (__pthread_spin_lock, pthread_spin_lock)
-
-int
-__pthread_spin_trylock (pthread_spinlock_t *lock)
-{
- int oldval;
-
- __asm__ __volatile__(" slr %1,%1\n"
- " basr 1,0\n"
- "0: cs %1,1,%0"
- : "=m" (*lock), "=&d" (oldval)
- : "m" (*lock) : "1", "cc" );
- return oldval == 0 ? 0 : EBUSY;
-}
-weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
-
-
-int
-__pthread_spin_unlock (pthread_spinlock_t *lock)
-{
- __asm__ __volatile__(" xc 0(4,%0),0(%0)\n"
- " bcr 15,0"
- : : "a" (lock) : "memory" );
- return 0;
-}
-weak_alias (__pthread_spin_unlock, pthread_spin_unlock)
-
-
-int
-__pthread_spin_init (pthread_spinlock_t *lock, int pshared)
-{
- /* We can ignore the `pshared' parameter. Since we are busy-waiting
- all processes which can access the memory location `lock' points
- to can use the spinlock. */
- *lock = 0;
- return 0;
-}
-weak_alias (__pthread_spin_init, pthread_spin_init)
-
-
-int
-__pthread_spin_destroy (pthread_spinlock_t *lock)
-{
- /* Nothing to do. */
- return 0;
-}
-weak_alias (__pthread_spin_destroy, pthread_spin_destroy)
diff --git a/libpthread/linuxthreads/sysdeps/s390/s390-32/pt-machine.h b/libpthread/linuxthreads/sysdeps/s390/s390-32/pt-machine.h
deleted file mode 100644
index d52d600ad..000000000
--- a/libpthread/linuxthreads/sysdeps/s390/s390-32/pt-machine.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/* Machine-dependent pthreads configuration and inline functions.
- S390 version.
- Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
- Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of the
- License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-#ifndef _PT_MACHINE_H
-#define _PT_MACHINE_H 1
-
-#ifndef PT_EI
-# define PT_EI __extern_always_inline
-#endif
-
-extern long int testandset (int *spinlock);
-extern int __compare_and_swap (long int *p, long int oldval, long int newval);
-
-/* For multiprocessor systems, we want to ensure all memory accesses
- are completed before we reset a lock. On other systems, we still
- need to make sure that the compiler has flushed everything to memory. */
-#define MEMORY_BARRIER() __asm__ __volatile__ ("bcr 15,0" : : : "memory")
-
-/* Spinlock implementation; required. */
-PT_EI long int
-testandset (int *spinlock)
-{
- int ret;
-
- __asm__ __volatile__(
- " la 1,%1\n"
- " lhi 0,1\n"
- " l %0,%1\n"
- "0: cs %0,0,0(1)\n"
- " jl 0b"
- : "=&d" (ret), "+m" (*spinlock)
- : : "0", "1", "cc");
-
- return ret;
-}
-
-
-/* Get some notion of the current stack. Need not be exactly the top
- of the stack, just something somewhere in the current frame. */
-#define CURRENT_STACK_FRAME stack_pointer
-register char * stack_pointer __asm__ ("15");
-
-#ifdef USE_TLS
-/* Return the thread descriptor for the current thread. */
-# define THREAD_SELF ((pthread_descr) __builtin_thread_pointer ())
-
-/* Initialize the thread-unique value. */
-#define INIT_THREAD_SELF(descr, nr) __builtin_set_thread_pointer (descr)
-#else
-/* Return the thread descriptor for the current thread.
- S/390 registers uses access register 0 as "thread register". */
-#define THREAD_SELF ({ \
- register pthread_descr __self; \
- __asm__ ("ear %0,%%a0" : "=d" (__self) ); \
- __self; \
-})
-
-/* Initialize the thread-unique value. */
-#define INIT_THREAD_SELF(descr, nr) ({ \
- __asm__ ("sar %%a0,%0" : : "d" (descr) ); \
-})
-#endif
-
-/* Access to data in the thread descriptor is easy. */
-#define THREAD_GETMEM(descr, member) \
- ((void) sizeof (descr), THREAD_SELF->member)
-#define THREAD_GETMEM_NC(descr, member) \
- ((void) sizeof (descr), THREAD_SELF->member)
-#define THREAD_SETMEM(descr, member, value) \
- ((void) sizeof (descr), THREAD_SELF->member = (value))
-#define THREAD_SETMEM_NC(descr, member, value) \
- ((void) sizeof (descr), THREAD_SELF->member = (value))
-
-/* We want the OS to assign stack addresses. */
-#define FLOATING_STACKS 1
-
-/* Maximum size of the stack if the rlimit is unlimited. */
-#define ARCH_STACK_MAX_SIZE 8*1024*1024
-
-/* Compare-and-swap for semaphores. */
-
-#define HAS_COMPARE_AND_SWAP
-
-PT_EI int
-__compare_and_swap(long int *p, long int oldval, long int newval)
-{
- int retval;
-
- __asm__ __volatile__(
- " la 1,%1\n"
- " lr 0,%2\n"
- " cs 0,%3,0(1)\n"
- " ipm %0\n"
- " srl %0,28\n"
- "0:"
- : "=&d" (retval), "+m" (*p)
- : "d" (oldval) , "d" (newval)
- : "cc", "0", "1" );
- return retval == 0;
-}
-
-#endif /* pt-machine.h */
diff --git a/libpthread/linuxthreads/sysdeps/s390/s390-64/pt-machine.h b/libpthread/linuxthreads/sysdeps/s390/s390-64/pt-machine.h
deleted file mode 100644
index 187e1f872..000000000
--- a/libpthread/linuxthreads/sysdeps/s390/s390-64/pt-machine.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/* Machine-dependent pthreads configuration and inline functions.
- 64 bit S/390 version.
- Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
- Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of the
- License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-#ifndef _PT_MACHINE_H
-#define _PT_MACHINE_H 1
-
-#ifndef PT_EI
-# define PT_EI __extern_always_inline
-#endif
-
-extern long int testandset (int *spinlock);
-extern int __compare_and_swap (long int *p, long int oldval, long int newval);
-
-/* For multiprocessor systems, we want to ensure all memory accesses
- are completed before we reset a lock. On other systems, we still
- need to make sure that the compiler has flushed everything to memory. */
-#define MEMORY_BARRIER() __asm__ __volatile__ ("bcr 15,0" : : : "memory")
-
-/* Spinlock implementation; required. */
-PT_EI long int
-testandset (int *spinlock)
-{
- int ret;
-
- __asm__ __volatile__(
- " la 1,%1\n"
- " lhi 0,1\n"
- " l %0,%1\n"
- "0: cs %0,0,0(1)\n"
- " jl 0b"
- : "=&d" (ret), "+m" (*spinlock)
- : : "0", "1", "cc");
-
- return ret;
-}
-
-
-/* Get some notion of the current stack. Need not be exactly the top
- of the stack, just something somewhere in the current frame. */
-#define CURRENT_STACK_FRAME stack_pointer
-register char * stack_pointer __asm__ ("15");
-
-#ifdef USE_TLS
-/* Return the thread descriptor for the current thread. */
-# define THREAD_SELF ((pthread_descr) __builtin_thread_pointer ())
-
-/* Initialize the thread-unique value. */
-#define INIT_THREAD_SELF(descr, nr) __builtin_set_thread_pointer (descr)
-#else
-/* Return the thread descriptor for the current thread.
- 64 bit S/390 uses access register 0 and 1 as "thread register". */
-#define THREAD_SELF ({ \
- register pthread_descr __self; \
- __asm__ (" ear %0,%%a0\n" \
- " sllg %0,%0,32\n" \
- " ear %0,%%a1\n" \
- : "=d" (__self) ); \
- __self; \
-})
-
-/* Initialize the thread-unique value. */
-#define INIT_THREAD_SELF(descr, nr) ({ \
- __asm__ (" sar %%a1,%0\n" \
- " srlg 0,%0,32\n" \
- " sar %%a0,0\n" \
- : : "d" (descr) : "0" ); \
-})
-#endif
-
-/* Access to data in the thread descriptor is easy. */
-#define THREAD_GETMEM(descr, member) \
- ((void) sizeof (descr), THREAD_SELF->member)
-#define THREAD_GETMEM_NC(descr, member) \
- ((void) sizeof (descr), THREAD_SELF->member)
-#define THREAD_SETMEM(descr, member, value) \
- ((void) sizeof (descr), THREAD_SELF->member = (value))
-#define THREAD_SETMEM_NC(descr, member, value) \
- ((void) sizeof (descr), THREAD_SELF->member = (value))
-
-/* We want the OS to assign stack addresses. */
-#define FLOATING_STACKS 1
-
-/* Maximum size of the stack if the rlimit is unlimited. */
-#define ARCH_STACK_MAX_SIZE 8*1024*1024
-
-/* Compare-and-swap for semaphores. */
-
-#define HAS_COMPARE_AND_SWAP
-
-PT_EI int
-__compare_and_swap(long int *p, long int oldval, long int newval)
-{
- int retval;
-
- __asm__ __volatile__(
- " lgr 0,%2\n"
- " csg 0,%3,%1\n"
- " ipm %0\n"
- " srl %0,28\n"
- "0:"
- : "=&d" (retval), "+m" (*p)
- : "d" (oldval) , "d" (newval)
- : "cc", "0");
- return retval == 0;
-}
-
-#endif /* pt-machine.h */
diff --git a/libpthread/linuxthreads/sysdeps/s390/tcb-offsets.sym b/libpthread/linuxthreads/sysdeps/s390/tcb-offsets.sym
deleted file mode 100644
index aee6be257..000000000
--- a/libpthread/linuxthreads/sysdeps/s390/tcb-offsets.sym
+++ /dev/null
@@ -1,4 +0,0 @@
-#include <sysdep.h>
-#include <tls.h>
-
-MULTIPLE_THREADS_OFFSET offsetof (tcbhead_t, multiple_threads)
diff --git a/libpthread/linuxthreads/sysdeps/s390/tls.h b/libpthread/linuxthreads/sysdeps/s390/tls.h
deleted file mode 100644
index f750f2d6f..000000000
--- a/libpthread/linuxthreads/sysdeps/s390/tls.h
+++ /dev/null
@@ -1,145 +0,0 @@
-/* Definitions for thread-local data handling. linuxthreads/s390 version.
- Copyright (C) 2002, 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 _TLS_H
-#define _TLS_H
-
-#ifndef __ASSEMBLER__
-
-# include <pt-machine.h>
-# include <stdbool.h>
-# include <stddef.h>
-
-/* Type for the dtv. */
-typedef union dtv
-{
- size_t counter;
- struct
- {
- void *val;
- bool is_static;
- } pointer;
-} dtv_t;
-
-typedef struct
-{
- void *tcb; /* Pointer to the TCB. Not necessary the
- thread descriptor used by libpthread. */
- dtv_t *dtv;
- void *self; /* Pointer to the thread descriptor. */
- int multiple_threads;
-} tcbhead_t;
-
-#else /* __ASSEMBLER__ */
-# include <tcb-offsets.h>
-#endif /* __ASSEMBLER__ */
-
-/* TLS is always supported if the tools support it. There are no
- kernel dependencies. To avoid bothering with the TLS support code
- at all, use configure --without-tls.
-
- We need USE_TLS to be consistently defined, for ldsodefs.h
- conditionals. */
-
-#ifdef HAVE_TLS_SUPPORT
-
-/* Signal that TLS support is available. */
-# define USE_TLS 1
-
-# ifndef __ASSEMBLER__
-/* Get system call information. */
-# include <sysdep.h>
-
-
-/* Get the thread descriptor definition. */
-# include <linuxthreads/descr.h>
-
-/* This is the size of the initial TCB. */
-# define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
-
-/* Alignment requirements for the initial TCB. */
-# define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
-
-/* This is the size of the TCB. */
-# define TLS_TCB_SIZE sizeof (struct _pthread_descr_struct)
-
-/* Alignment requirements for the TCB. */
-# define TLS_TCB_ALIGN __alignof__ (struct _pthread_descr_struct)
-
-/* The TCB can have any size and the memory following the address the
- thread pointer points to is unspecified. Allocate the TCB there. */
-# define TLS_TCB_AT_TP 1
-
-
-/* Install the dtv pointer. The pointer passed is to the element with
- index -1 which contain the length. */
-# define INSTALL_DTV(descr, dtvp) \
- ((tcbhead_t *) (descr))->dtv = (dtvp) + 1
-
-/* Install new dtv for current thread. */
-# define INSTALL_NEW_DTV(dtv) \
- (((tcbhead_t *) __builtin_thread_pointer ())->dtv = (dtv))
-
-/* Return dtv of given thread descriptor. */
-# define GET_DTV(descr) \
- (((tcbhead_t *) (descr))->dtv)
-
-/* Code to initially initialize the thread pointer. This might need
- special attention since 'errno' is not yet available and if the
- operation can cause a failure 'errno' must not be touched.
-
- The value of this macro is null if successful, or an error string. */
-# define TLS_INIT_TP(descr, secondcall) \
- ({ \
- void *_descr = (descr); \
- tcbhead_t *head = _descr; \
- \
- head->tcb = _descr; \
- /* For now the thread descriptor is at the same address. */ \
- head->self = _descr; \
- \
- __builtin_set_thread_pointer (_descr); \
- NULL; \
- })
-
-/* Return the address of the dtv for the current thread. */
-# define THREAD_DTV() \
- (((tcbhead_t *) __builtin_thread_pointer ())->dtv)
-
-# endif /* __ASSEMBLER__ */
-
-#else /* HAVE_TLS_SUPPORT && (FLOATING_STACKS || !IS_IN_libpthread) */
-
-# ifndef __ASSEMBLER__
-
-/* Get the thread descriptor definition. */
-# include <linuxthreads/descr.h>
-
-# define NONTLS_INIT_TP \
- do { \
- static const tcbhead_t nontls_init_tp \
- = { .multiple_threads = 0 }; \
- INIT_THREAD_SELF (&nontls_init_tp, 0); \
- } while (0)
-
-# endif /* __ASSEMBLER__ */
-
-#endif /* HAVE_TLS_SUPPORT && (FLOATING_STACKS || !IS_IN_libpthread) */
-
-#endif /* tls.h */
diff --git a/libpthread/linuxthreads/sysdeps/sh/pspinlock.c b/libpthread/linuxthreads/sysdeps/sh/pspinlock.c
index c4e333a74..2f039de53 100644
--- a/libpthread/linuxthreads/sysdeps/sh/pspinlock.c
+++ b/libpthread/linuxthreads/sysdeps/sh/pspinlock.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; 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/>. */
#include <errno.h>
#include <pthread.h>
diff --git a/libpthread/linuxthreads/sysdeps/sh/pt-machine.h b/libpthread/linuxthreads/sysdeps/sh/pt-machine.h
index 793f80b2d..7d1484e71 100644
--- a/libpthread/linuxthreads/sysdeps/sh/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/sh/pt-machine.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; 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 _PT_MACHINE_H
#define _PT_MACHINE_H 1
diff --git a/libpthread/linuxthreads/sysdeps/sh/tcb-offsets.sym b/libpthread/linuxthreads/sysdeps/sh/tcb-offsets.sym
index 328eb0573..6324a016c 100644
--- a/libpthread/linuxthreads/sysdeps/sh/tcb-offsets.sym
+++ b/libpthread/linuxthreads/sysdeps/sh/tcb-offsets.sym
@@ -2,7 +2,7 @@
#include <tls.h>
--
-#ifdef USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
MULTIPLE_THREADS_OFFSET offsetof (struct _pthread_descr_struct, p_multiple_threads)
TLS_PRE_TCB_SIZE sizeof (struct _pthread_descr_struct)
#else
diff --git a/libpthread/linuxthreads/sysdeps/sh/tls.h b/libpthread/linuxthreads/sysdeps/sh/tls.h
index 350d129db..512e3181e 100644
--- a/libpthread/linuxthreads/sysdeps/sh/tls.h
+++ b/libpthread/linuxthreads/sysdeps/sh/tls.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 _TLS_H
#define _TLS_H
diff --git a/libpthread/linuxthreads/sysdeps/sparc/pspinlock.c b/libpthread/linuxthreads/sysdeps/sparc/pspinlock.c
index 72a9af5b1..4de152be3 100644
--- a/libpthread/linuxthreads/sysdeps/sparc/pspinlock.c
+++ b/libpthread/linuxthreads/sysdeps/sparc/pspinlock.c
@@ -1,14 +1,87 @@
-#include <features.h>
-#include <bits/wordsize.h>
+/* POSIX spinlock implementation. SPARC32 version.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
-#if __WORDSIZE == 32
+ 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.
-# if defined(__CONFIG_SPARC_V9B__)
-# include "sparc32/sparcv9b/pspinlock.c"
-# else
-# include "sparc32/pspinlock.c"
-# endif
+ 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.
-#else
-# include "sparc64/pspinlock.c"
-#endif
+ 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/>. */
+
+#include <errno.h>
+#include <pthread.h>
+#include "internals.h"
+
+/* This implementation is similar to the one used in the Linux kernel. */
+int
+__pthread_spin_lock (pthread_spinlock_t *lock)
+{
+ __asm__ __volatile__
+ ("1: ldstub [%0], %%g2\n"
+ " orcc %%g2, 0x0, %%g0\n"
+ " bne,a 2f\n"
+ " ldub [%0], %%g2\n"
+ ".subsection 2\n"
+ "2: orcc %%g2, 0x0, %%g0\n"
+ " bne,a 2b\n"
+ " ldub [%0], %%g2\n"
+ " b,a 1b\n"
+ ".previous"
+ : /* no outputs */
+ : "r" (lock)
+ : "g2", "memory", "cc");
+ return 0;
+}
+weak_alias (__pthread_spin_lock, pthread_spin_lock)
+
+
+int
+__pthread_spin_trylock (pthread_spinlock_t *lock)
+{
+ int result;
+ __asm__ __volatile__
+ ("ldstub [%1], %0"
+ : "=r" (result)
+ : "r" (lock)
+ : "memory");
+ return result == 0 ? 0 : EBUSY;
+}
+weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
+
+
+int
+__pthread_spin_unlock (pthread_spinlock_t *lock)
+{
+ *lock = 0;
+ return 0;
+}
+weak_alias (__pthread_spin_unlock, pthread_spin_unlock)
+
+
+int
+__pthread_spin_init (pthread_spinlock_t *lock, int pshared)
+{
+ /* We can ignore the `pshared' parameter. Since we are busy-waiting
+ all processes which can access the memory location `lock' points
+ to can use the spinlock. */
+ *lock = 0;
+ return 0;
+}
+weak_alias (__pthread_spin_init, pthread_spin_init)
+
+
+int
+__pthread_spin_destroy (pthread_spinlock_t *lock)
+{
+ /* Nothing to do. */
+ return 0;
+}
+weak_alias (__pthread_spin_destroy, pthread_spin_destroy)
diff --git a/libpthread/linuxthreads/sysdeps/sparc/pt-machine.h b/libpthread/linuxthreads/sysdeps/sparc/pt-machine.h
index ab90810f1..d502c759a 100644
--- a/libpthread/linuxthreads/sysdeps/sparc/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/sparc/pt-machine.h
@@ -1,8 +1,82 @@
-#include <features.h>
-#include <bits/wordsize.h>
+/* Machine-dependent pthreads configuration and inline functions.
+ sparc version.
+ Copyright (C) 1996-1998, 2000-2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson <rth@tamu.edu>.
-#if __WORDSIZE == 32
-# include "sparc32/pt-machine.h"
-#else
-# include "sparc64/pt-machine.h"
+ 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/>. */
+
+#ifndef _PT_MACHINE_H
+#define _PT_MACHINE_H 1
+
+#ifndef PT_EI
+# define PT_EI __extern_always_inline
#endif
+
+extern long int testandset (int *spinlock);
+extern int __compare_and_swap (long int *p, long int oldval, long int newval);
+
+/* Spinlock implementation; required. */
+PT_EI long int
+testandset (int *spinlock)
+{
+ int ret;
+
+ __asm__ __volatile__("ldstub %1,%0"
+ : "=r"(ret), "=m"(*spinlock)
+ : "m"(*spinlock));
+
+ return ret;
+}
+
+
+/* Memory barrier; default is to do nothing */
+#define MEMORY_BARRIER() __asm__ __volatile__("stbar" : : : "memory")
+
+
+/* Get some notion of the current stack. Need not be exactly the top
+ of the stack, just something somewhere in the current frame. */
+#define CURRENT_STACK_FRAME (stack_pointer + (2 * 64))
+register char *stack_pointer __asm__("%sp");
+
+
+/* Registers %g6 and %g7 are reserved by the ABI for "system use".
+ %g7 is specified in the TLS ABI as thread pointer -- we do the same. */
+struct _pthread_descr_struct;
+register struct _pthread_descr_struct *__thread_self __asm__("%g7");
+
+/* Return the thread descriptor for the current thread. */
+#define THREAD_SELF __thread_self
+
+/* Initialize the thread-unique value. */
+#define INIT_THREAD_SELF(descr, nr) (__thread_self = (descr))
+
+/* Access to data in the thread descriptor is easy. */
+#define THREAD_GETMEM(descr, member) \
+ ((void) sizeof (descr), THREAD_SELF->member)
+#define THREAD_GETMEM_NC(descr, member) \
+ ((void) sizeof (descr), THREAD_SELF->member)
+#define THREAD_SETMEM(descr, member, value) \
+ ((void) sizeof (descr), THREAD_SELF->member = (value))
+#define THREAD_SETMEM_NC(descr, member, value) \
+ ((void) sizeof (descr), THREAD_SELF->member = (value))
+
+/* We want the OS to assign stack addresses. */
+#define FLOATING_STACKS 1
+
+/* Maximum size of the stack if the rlimit is unlimited. */
+#define ARCH_STACK_MAX_SIZE 8*1024*1024
+
+#endif /* pt-machine.h */
diff --git a/libpthread/linuxthreads/sysdeps/sparc/sparc32/pt-machine.h b/libpthread/linuxthreads/sysdeps/sparc/sparc32/pt-machine.h
deleted file mode 100644
index 43c05f2a6..000000000
--- a/libpthread/linuxthreads/sysdeps/sparc/sparc32/pt-machine.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/* Machine-dependent pthreads configuration and inline functions.
- sparc version.
- Copyright (C) 1996-1998, 2000-2003 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; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-#ifndef _PT_MACHINE_H
-#define _PT_MACHINE_H 1
-
-#ifndef PT_EI
-# define PT_EI __extern_always_inline
-#endif
-
-extern long int testandset (int *spinlock);
-extern int __compare_and_swap (long int *p, long int oldval, long int newval);
-
-/* Spinlock implementation; required. */
-PT_EI long int
-testandset (int *spinlock)
-{
- int ret;
-
- __asm__ __volatile__("ldstub %1,%0"
- : "=r"(ret), "=m"(*spinlock)
- : "m"(*spinlock));
-
- return ret;
-}
-
-
-/* Memory barrier; default is to do nothing */
-#define MEMORY_BARRIER() __asm__ __volatile__("stbar" : : : "memory")
-
-
-/* Get some notion of the current stack. Need not be exactly the top
- of the stack, just something somewhere in the current frame. */
-#define CURRENT_STACK_FRAME (stack_pointer + (2 * 64))
-register char *stack_pointer __asm__("%sp");
-
-
-/* Registers %g6 and %g7 are reserved by the ABI for "system use".
- %g7 is specified in the TLS ABI as thread pointer -- we do the same. */
-struct _pthread_descr_struct;
-register struct _pthread_descr_struct *__thread_self __asm__("%g7");
-
-/* Return the thread descriptor for the current thread. */
-#define THREAD_SELF __thread_self
-
-/* Initialize the thread-unique value. */
-#define INIT_THREAD_SELF(descr, nr) (__thread_self = (descr))
-
-/* Access to data in the thread descriptor is easy. */
-#define THREAD_GETMEM(descr, member) \
- ((void) sizeof (descr), THREAD_SELF->member)
-#define THREAD_GETMEM_NC(descr, member) \
- ((void) sizeof (descr), THREAD_SELF->member)
-#define THREAD_SETMEM(descr, member, value) \
- ((void) sizeof (descr), THREAD_SELF->member = (value))
-#define THREAD_SETMEM_NC(descr, member, value) \
- ((void) sizeof (descr), THREAD_SELF->member = (value))
-
-/* We want the OS to assign stack addresses. */
-#define FLOATING_STACKS 1
-
-/* Maximum size of the stack if the rlimit is unlimited. */
-#define ARCH_STACK_MAX_SIZE 8*1024*1024
-
-#endif /* pt-machine.h */
diff --git a/libpthread/linuxthreads/sysdeps/sparc/sparc32/sparcv9/pspinlock.c b/libpthread/linuxthreads/sysdeps/sparc/sparc32/sparcv9/pspinlock.c
deleted file mode 100644
index 7e55df414..000000000
--- a/libpthread/linuxthreads/sysdeps/sparc/sparc32/sparcv9/pspinlock.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/* POSIX spinlock implementation. SPARC v9 version.
- Copyright (C) 2000 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of the
- License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; 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 <errno.h>
-#include <pthread.h>
-#include "internals.h"
-
-
-/* This implementation is similar to the one used in the Linux kernel. */
-int
-__pthread_spin_lock (pthread_spinlock_t *lock)
-{
- __asm__ __volatile__
- ("1: ldstub [%0], %%g2\n"
- " brnz,pn %%g2, 2f\n"
- " membar #StoreLoad | #StoreStore\n"
- ".subsection 2\n"
- "2: ldub [%0], %%g2\n"
- " brnz,pt %%g2, 2b\n"
- " membar #LoadLoad\n"
- " b,a,pt %%xcc, 1b\n"
- ".previous"
- : /* no outputs */
- : "r" (lock)
- : "g2", "memory");
- return 0;
-}
-weak_alias (__pthread_spin_lock, pthread_spin_lock)
-
-
-int
-__pthread_spin_trylock (pthread_spinlock_t *lock)
-{
- int result;
- __asm__ __volatile__
- ("ldstub [%1], %0\n"
- "membar #StoreLoad | #StoreStore"
- : "=r" (result)
- : "r" (lock)
- : "memory");
- return result == 0 ? 0 : EBUSY;
-}
-weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
-
-
-int
-__pthread_spin_unlock (pthread_spinlock_t *lock)
-{
- __asm__ __volatile__
- ("membar #StoreStore | #LoadStore\n"
- "stb %%g0, [%0]"
- :
- : "r" (lock)
- : "memory");
- return 0;
-}
-weak_alias (__pthread_spin_unlock, pthread_spin_unlock)
-
-
-int
-__pthread_spin_init (pthread_spinlock_t *lock, int pshared)
-{
- /* We can ignore the `pshared' parameter. Since we are busy-waiting
- all processes which can access the memory location `lock' points
- to can use the spinlock. */
- *lock = 0;
- return 0;
-}
-weak_alias (__pthread_spin_init, pthread_spin_init)
-
-
-int
-__pthread_spin_destroy (pthread_spinlock_t *lock)
-{
- /* Nothing to do. */
- return 0;
-}
-weak_alias (__pthread_spin_destroy, pthread_spin_destroy)
diff --git a/libpthread/linuxthreads/sysdeps/sparc/sparc64/pspinlock.c b/libpthread/linuxthreads/sysdeps/sparc/sparc64/pspinlock.c
deleted file mode 100644
index e0c350e6b..000000000
--- a/libpthread/linuxthreads/sysdeps/sparc/sparc64/pspinlock.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/* POSIX spinlock implementation. SPARC64 version.
- Copyright (C) 2000 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of the
- License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; 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 <errno.h>
-#include <pthread.h>
-#include "internals.h"
-
-/* This implementation is similar to the one used in the Linux kernel. */
-int
-__pthread_spin_lock (pthread_spinlock_t *lock)
-{
- __asm__ __volatile__
- ("1: ldstub [%0], %%g5\n"
- " brnz,pn %%g5, 2f\n"
- " membar #StoreLoad | #StoreStore\n"
- ".subsection 2\n"
- "2: ldub [%0], %%g5\n"
- " brnz,pt %%g5, 2b\n"
- " membar #LoadLoad\n"
- " b,a,pt %%xcc, 1b\n"
- ".previous"
- : /* no outputs */
- : "r" (lock)
- : "g5", "memory");
- return 0;
-}
-weak_alias (__pthread_spin_lock, pthread_spin_lock)
-
-
-int
-__pthread_spin_trylock (pthread_spinlock_t *lock)
-{
- int result;
- __asm__ __volatile__
- ("ldstub [%1], %0\n"
- "membar #StoreLoad | #StoreStore"
- : "=r" (result)
- : "r" (lock)
- : "memory");
- return result == 0 ? 0 : EBUSY;
-}
-weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
-
-
-int
-__pthread_spin_unlock (pthread_spinlock_t *lock)
-{
- __asm__ __volatile__
- ("membar #StoreStore | #LoadStore\n"
- "stb %%g0, [%0]"
- :
- : "r" (lock)
- : "memory");
- return 0;
-}
-weak_alias (__pthread_spin_unlock, pthread_spin_unlock)
-
-
-int
-__pthread_spin_init (pthread_spinlock_t *lock, int pshared)
-{
- /* We can ignore the `pshared' parameter. Since we are busy-waiting
- all processes which can access the memory location `lock' points
- to can use the spinlock. */
- *lock = 0;
- return 0;
-}
-weak_alias (__pthread_spin_init, pthread_spin_init)
-
-
-int
-__pthread_spin_destroy (pthread_spinlock_t *lock)
-{
- /* Nothing to do. */
- return 0;
-}
-weak_alias (__pthread_spin_destroy, pthread_spin_destroy)
diff --git a/libpthread/linuxthreads/sysdeps/sparc/sparc64/pt-machine.h b/libpthread/linuxthreads/sysdeps/sparc/sparc64/pt-machine.h
deleted file mode 100644
index 815d70e8d..000000000
--- a/libpthread/linuxthreads/sysdeps/sparc/sparc64/pt-machine.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/* Machine-dependent pthreads configuration and inline functions.
- Sparc v9 version.
- Copyright (C) 1997-2002, 2003 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; see the file COPYING.LIB. If
- not, write to the Free Software Foundation, Inc.,
- 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#ifndef _PT_MACHINE_H
-#define _PT_MACHINE_H 1
-
-#ifndef PT_EI
-# define PT_EI __extern_always_inline
-#endif
-
-extern long int testandset (int *spinlock);
-extern int __compare_and_swap (long int *p, long int oldval, long int newval);
-
-/* Spinlock implementation; required. */
-PT_EI long int
-testandset (int *spinlock)
-{
- int ret;
-
- __asm__ __volatile__("ldstub %1,%0"
- : "=r" (ret), "=m" (*spinlock) : "m" (*spinlock));
-
- return ret;
-}
-
-
-/* Memory barrier; default is to do nothing */
-#define MEMORY_BARRIER() \
- __asm__ __volatile__("membar #LoadLoad | #LoadStore | #StoreLoad | #StoreStore" : : : "memory")
-/* Read barrier. */
-#define READ_MEMORY_BARRIER() \
- __asm__ __volatile__("membar #LoadLoad | #LoadStore" : : : "memory")
-/* Write barrier. */
-#define WRITE_MEMORY_BARRIER() \
- __asm__ __volatile__("membar #StoreLoad | #StoreStore" : : : "memory")
-
-
-/* Get some notion of the current stack. Need not be exactly the top
- of the stack, just something somewhere in the current frame. */
-#define CURRENT_STACK_FRAME (stack_pointer + (2 * 128))
-register char *stack_pointer __asm__ ("%sp");
-
-
-/* Registers %g6 and %g7 are reserved by the ABI for "system use". The
- TLS ABI specifies %g7 as the thread pointer. */
-struct _pthread_descr_struct;
-register struct _pthread_descr_struct *__thread_self __asm__ ("%g7");
-
-/* Return the thread descriptor for the current thread. */
-#define THREAD_SELF __thread_self
-
-/* Initialize the thread-unique value. */
-#define INIT_THREAD_SELF(descr, nr) (__thread_self = (descr))
-
-
-/* Compare-and-swap for semaphores. */
-
-#define HAS_COMPARE_AND_SWAP
-PT_EI int
-__compare_and_swap (long int *p, long int oldval, long int newval)
-{
- long int readval;
-
- __asm__ __volatile__ ("casx [%4], %2, %0"
- : "=r"(readval), "=m"(*p)
- : "r"(oldval), "m"(*p), "r"(p), "0"(newval));
- MEMORY_BARRIER();
- return readval == oldval;
-}
-
-/* Access to data in the thread descriptor is easy. */
-#define THREAD_GETMEM(descr, member) \
- ((void) sizeof (descr), THREAD_SELF->member)
-#define THREAD_GETMEM_NC(descr, member) \
- ((void) sizeof (descr), THREAD_SELF->member)
-#define THREAD_SETMEM(descr, member, value) \
- ((void) sizeof (descr), THREAD_SELF->member = (value))
-#define THREAD_SETMEM_NC(descr, member, value) \
- ((void) sizeof (descr), THREAD_SELF->member = (value))
-
-/* We want the OS to assign stack addresses. */
-#define FLOATING_STACKS 1
-
-/* Maximum size of the stack if the rlimit is unlimited. */
-#define ARCH_STACK_MAX_SIZE 32*1024*1024
-
-#endif /* pt-machine.h */
diff --git a/libpthread/linuxthreads/sysdeps/sparc/tls.h b/libpthread/linuxthreads/sysdeps/sparc/tls.h
index 2df97d61e..1e31c2e63 100644
--- a/libpthread/linuxthreads/sysdeps/sparc/tls.h
+++ b/libpthread/linuxthreads/sysdeps/sparc/tls.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 _TLS_H
#define _TLS_H
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/.cvsignore b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/.cvsignore
deleted file mode 100644
index 7ee8f5969..000000000
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/.cvsignore
+++ /dev/null
@@ -1,2 +0,0 @@
-.cvsignore
-*.os
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/allocalim.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/allocalim.h
index f62f7d6e9..3d3d2219f 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/allocalim.h
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/allocalim.h
@@ -14,12 +14,11 @@
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 <limits.h>
-extern inline int __libc_use_alloca (size_t size)
+__extern_always_inline int __libc_use_alloca (size_t size)
{
return (__builtin_expect (size <= PTHREAD_STACK_MIN / 4, 1)
|| __libc_alloca_cutoff (size));
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/allocrtsig.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/allocrtsig.c
index b9ada6417..69bc0d79a 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/allocrtsig.c
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/allocrtsig.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/>. */
#include <signal.h>
@@ -70,6 +69,7 @@ __libc_current_sigrtmax (void)
strong_alias (__libc_current_sigrtmax, __libc_current_sigrtmax_private)
libc_hidden_def (__libc_current_sigrtmax)
+#if 0
/* Allocate real-time signal with highest/lowest available
priority. Please note that we don't use a lock since we assume
this function to be called at program start. */
@@ -85,3 +85,4 @@ __libc_allocate_rtsig (int high)
return high ? current_rtmin++ : current_rtmax--;
}
strong_alias (__libc_allocate_rtsig, __libc_allocate_rtsig_private)
+#endif
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/bits/local_lim.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/bits/local_lim.h
index 96893c59d..001403a19 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/bits/local_lim.h
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/bits/local_lim.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/>. */
/* The kernel header pollutes the namespace with the NR_OPEN symbol
and defines LINK_MAX although filesystems have different maxima. A
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
index a2724885e..6d917e7f5 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/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/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/pt-sigsuspend.S b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/pt-sigsuspend.S
index 91e5c8678..754fc5b1c 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/pt-sigsuspend.S
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/pt-sigsuspend.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/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h
index 9ea779e0d..8ce43153d 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.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 <sysdep.h>
#ifndef __ASSEMBLER__
@@ -118,7 +117,7 @@ __LABEL($syscall_error) \
# define __local_multiple_threads __libc_multiple_threads
# endif
-# ifdef PIC
+# ifdef __PIC__
# define CENABLE bsr ra, __local_enable_asynccancel !samegp
# define CDISABLE bsr ra, __local_disable_asynccancel !samegp
# else
@@ -130,7 +129,7 @@ __LABEL($syscall_error) \
extern int __local_multiple_threads attribute_hidden;
# define SINGLE_THREAD_P \
__builtin_expect (__local_multiple_threads == 0, 1)
-# elif defined(PIC)
+# elif defined(__PIC__)
# define SINGLE_THREAD_P(reg) ldl reg, __local_multiple_threads(gp) !gprel
# else
# define SINGLE_THREAD_P(reg) \
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/vfork.S b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/vfork.S
index cfaae1060..80fdcc6fb 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/vfork.S
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/alpha/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-cancel.h>
@@ -30,7 +29,7 @@ __vfork:
#ifdef SHARED
ldq t0, __libc_pthread_functions(gp) !gprel
- bne t0, HIDDEN_JUMPTARGET (__fork) !samegp
+ bne t0, HIDDEN_JUMPTARGET (fork) !samegp
#else
.weak pthread_create
ldq t0, pthread_create(gp) !literal
@@ -50,7 +49,7 @@ $do_fork:
cfi_adjust_cfa_offset(16)
stq ra, 0(sp)
cfi_offset(ra, -16)
- jsr ra, HIDDEN_JUMPTARGET (__fork)
+ jsr ra, HIDDEN_JUMPTARGET (fork)
ldgp gp, 0(ra)
ldq ra, 0(sp)
addq sp, 16, sp
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h
new file mode 100644
index 000000000..2c1eba65f
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h
@@ -0,0 +1,129 @@
+/* Copyright (C) 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Phil Blundell <pb@nexus.co.uk>, 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 <tls.h>
+#include <pt-machine.h>
+#ifndef __ASSEMBLER__
+# include <linuxthreads/internals.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread
+
+/* We push lr onto the stack, so we have to use ldmib instead of ldmia
+ to find the saved arguments. */
+# ifdef __PIC__
+# undef DOARGS_5
+# undef DOARGS_6
+# undef DOARGS_7
+# define DOARGS_5 str r4, [sp, $-4]!; ldr r4, [sp, $8];
+# define DOARGS_6 mov ip, sp; stmfd sp!, {r4, r5}; ldmib ip, {r4, r5};
+# define DOARGS_7 mov ip, sp; stmfd sp!, {r4, r5, r6}; ldmib ip, {r4, r5, r6};
+# endif
+
+# undef PSEUDO_RET
+# define PSEUDO_RET \
+ ldrcc pc, [sp], $4; \
+ ldr lr, [sp], $4; \
+ b PLTJMP(SYSCALL_ERROR)
+
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .section ".text"; \
+ PSEUDO_PROLOGUE; \
+ ENTRY (name); \
+ SINGLE_THREAD_P; \
+ bne .Lpseudo_cancel; \
+ DO_CALL (syscall_name, args); \
+ cmn r0, $4096; \
+ RETINSTR(cc, lr); \
+ b PLTJMP(SYSCALL_ERROR); \
+ .Lpseudo_cancel: \
+ str lr, [sp, $-4]!; \
+ DOCARGS_##args; /* save syscall args around CENABLE. */ \
+ CENABLE; \
+ mov ip, r0; /* put mask in safe place. */ \
+ UNDOCARGS_##args; /* restore syscall args. */ \
+ swi SYS_ify (syscall_name); /* do the call. */ \
+ str r0, [sp, $-4]!; /* save syscall return value. */ \
+ mov r0, ip; /* get mask back. */ \
+ CDISABLE; \
+ ldr r0, [sp], $4; /* retrieve return value. */ \
+ UNDOC2ARGS_##args; /* fix register damage. */ \
+ cmn r0, $4096;
+
+# define DOCARGS_0
+# define UNDOCARGS_0
+# define UNDOC2ARGS_0
+
+# define DOCARGS_1 str r0, [sp, #-4]!;
+# define UNDOCARGS_1 ldr r0, [sp], #4;
+# define UNDOC2ARGS_1
+
+# define DOCARGS_2 str r1, [sp, #-4]!; str r0, [sp, #-4]!;
+# define UNDOCARGS_2 ldr r0, [sp], #4; ldr r1, [sp], #4;
+# define UNDOC2ARGS_2
+
+# define DOCARGS_3 str r2, [sp, #-4]!; str r1, [sp, #-4]!; str r0, [sp, #-4]!;
+# define UNDOCARGS_3 ldr r0, [sp], #4; ldr r1, [sp], #4; ldr r2, [sp], #4
+# define UNDOC2ARGS_3
+
+# define DOCARGS_4 stmfd sp!, {r0-r3}
+# define UNDOCARGS_4 ldmfd sp!, {r0-r3}
+# define UNDOC2ARGS_4
+
+# define DOCARGS_5 stmfd sp!, {r0-r3}
+# define UNDOCARGS_5 ldmfd sp, {r0-r3}; str r4, [sp, #-4]!; ldr r4, [sp, #24]
+# define UNDOC2ARGS_5 ldr r4, [sp], #20
+
+# ifdef IS_IN_libpthread
+# define CENABLE bl PLTJMP(__pthread_enable_asynccancel)
+# define CDISABLE bl PLTJMP(__pthread_disable_asynccancel)
+# define __local_multiple_threads __pthread_multiple_threads
+# else
+# define CENABLE bl PLTJMP(__libc_enable_asynccancel)
+# define CDISABLE bl PLTJMP(__libc_disable_asynccancel)
+# define __local_multiple_threads __libc_multiple_threads
+# endif
+
+# ifndef __ASSEMBLER__
+extern int __local_multiple_threads attribute_hidden;
+# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
+# else
+# if !defined __PIC__
+# define SINGLE_THREAD_P \
+ ldr ip, =__local_multiple_threads; \
+ ldr ip, [ip]; \
+ teq ip, #0;
+# define PSEUDO_PROLOGUE
+# else
+# define SINGLE_THREAD_P \
+ ldr ip, 1b; \
+2: \
+ ldr ip, [pc, ip]; \
+ teq ip, #0;
+# define PSEUDO_PROLOGUE \
+ 1: .word __local_multiple_threads - 2f - 8;
+# endif
+# endif
+
+#elif !defined __ASSEMBLER__
+
+/* This code should never be used but we define it anyhow. */
+# define SINGLE_THREAD_P (1)
+
+#endif
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/arm/vfork.S b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/arm/vfork.S
new file mode 100644
index 000000000..3d9e49a0f
--- /dev/null
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/arm/vfork.S
@@ -0,0 +1,77 @@
+/* Copyright (C) 1999, 2002, 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Philip Blundell <philb@gnu.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 <sysdep-cancel.h>
+#define _ERRNO_H 1
+#include <bits/errno.h>
+#include <kernel-features.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. */
+
+ENTRY (__vfork)
+
+#ifdef __NR_vfork
+
+#ifdef SHARED
+ ldr ip, 1f
+ ldr r0, 2f
+3: add ip, pc, ip
+ ldr r0, [ip, r0]
+#else
+ ldr r0, 1f
+#endif
+ movs r0, r0
+ bne HIDDEN_JUMPTARGET (fork)
+
+ DO_CALL (vfork, 0)
+ cmn a1, #4096
+ RETINSTR(cc, lr)
+
+#ifndef __ASSUME_VFORK_SYSCALL
+ /* Check if vfork syscall is known at all. */
+ cmn a1, #ENOSYS
+ bne PLTJMP(C_SYMBOL_NAME(__syscall_error))
+#endif
+
+#endif
+
+#ifndef __ASSUME_VFORK_SYSCALL
+ /* If we don't have vfork, fork is close enough. */
+ DO_CALL (fork, 0)
+ cmn a1, #4096
+ RETINSTR(cc, lr)
+#elif !defined __NR_vfork
+# error "__NR_vfork not available and __ASSUME_VFORK_SYSCALL defined"
+#endif
+ b PLTJMP(C_SYMBOL_NAME(__syscall_error))
+
+#ifdef SHARED
+1: .word _GLOBAL_OFFSET_TABLE_ - 3b - 8
+2: .word __libc_pthread_functions(GOTOFF)
+#else
+ .weak pthread_create
+1: .word pthread_create
+#endif
+
+PSEUDO_END (__vfork)
+libc_hidden_def (__vfork)
+
+weak_alias (__vfork, vfork)
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/execve.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/execve.c
index 9fa912b90..cae12182f 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/execve.c
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/execve.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>
#include <unistd.h>
@@ -22,52 +21,19 @@
#include <sysdep.h>
#include <alloca.h>
#include <sys/syscall.h>
-#include <bp-checks.h>
-
-extern int __syscall_execve (const char *__unbounded file,
- char *__unbounded const *__unbounded argv,
- char *__unbounded const *__unbounded envp);
-extern void __pthread_kill_other_threads_np (void);
-weak_extern (__pthread_kill_other_threads_np)
+extern int __syscall_execve(const char *file,
+ char *const *argv,
+ char *const *envp);
+extern void __pthread_kill_other_threads_np(void);
+weak_extern(__pthread_kill_other_threads_np)
int
-__execve (file, argv, envp)
- const char *file;
- char *const argv[];
- char *const envp[];
+__execve(const char *file, char *const argv[], char *const envp[])
{
- /* If this is a threaded application kill all other threads. */
- if (__pthread_kill_other_threads_np)
- __pthread_kill_other_threads_np ();
-#if __BOUNDED_POINTERS__
- {
- char *const *v;
- int i;
- char *__unbounded *__unbounded ubp_argv;
- char *__unbounded *__unbounded ubp_envp;
- char *__unbounded *__unbounded ubp_v;
-
- for (v = argv; *v; v++)
- ;
- i = v - argv + 1;
- ubp_argv = (char *__unbounded *__unbounded) alloca (sizeof (*ubp_argv) * i);
- for (v = argv, ubp_v = ubp_argv; --i; v++, ubp_v++)
- *ubp_v = CHECK_STRING (*v);
- *ubp_v = 0;
-
- for (v = envp; *v; v++)
- ;
- i = v - envp + 1;
- ubp_envp = (char *__unbounded *__unbounded) alloca (sizeof (*ubp_envp) * i);
- for (v = envp, ubp_v = ubp_envp; --i; v++, ubp_v++)
- *ubp_v = CHECK_STRING (*v);
- *ubp_v = 0;
-
- return INLINE_SYSCALL (execve, 3, CHECK_STRING (file), ubp_argv, ubp_envp);
- }
-#else
- return INLINE_SYSCALL (execve, 3, file, argv, envp);
-#endif
+ /* If this is a threaded application kill all other threads. */
+ if (__pthread_kill_other_threads_np)
+ __pthread_kill_other_threads_np();
+ return INLINE_SYSCALL(execve, 3, file, argv, envp);
}
-weak_alias (__execve, execve)
+weak_alias(__execve, execve)
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/fork.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/fork.c
index e15b99b82..8f954d8d9 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/fork.c
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/fork.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 <fork.h>
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/fork.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/fork.h
index 85477eb48..8245d9ef0 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/fork.h
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/fork.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 <list.h>
#include <bits/libc-lock.h>
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/bits/initspin.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/bits/initspin.h
index 9b1340028..e367fb9d8 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/bits/initspin.h
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/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. PA-RISC only implements atomic load
and clear so this must be non-zero. */
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/malloc-machine.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/malloc-machine.h
index 6a53da2a0..e6b71f441 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/malloc-machine.h
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/malloc-machine.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 _MALLOC_MACHINE_H
#define _MALLOC_MACHINE_H
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/pt-initfini.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/pt-initfini.c
index 27f850cf8..60607ad4f 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/pt-initfini.c
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/pt-initfini.c
@@ -23,8 +23,7 @@
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, 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
+ see <http://www.gnu.org/licenses/>. */
/* This file is compiled into assembly code which is then munged by a sed
script into two files: crti.s and crtn.s.
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h
index 134977e07..8a7bd9705 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/sysdep-cancel.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 <sysdep.h>
#ifndef __ASSEMBLER__
@@ -104,7 +103,7 @@
# define POPARGS_6 POPARGS_5 ldw -54(%sr0,%sp), %r21 ASM_LINE_SEP
# ifdef IS_IN_libpthread
-# ifdef PIC
+# ifdef __PIC__
# define CENABLE .import __pthread_enable_asynccancel,code ASM_LINE_SEP \
bl __pthread_enable_asynccancel,%r2 ASM_LINE_SEP
# define CDISABLE .import __pthread_disable_asynccancel,code ASM_LINE_SEP \
@@ -116,7 +115,7 @@
bl __pthread_disable_asynccancel,%r2 ASM_LINE_SEP
# endif
# elif !defined NOT_IN_libc
-# ifdef PIC
+# ifdef __PIC__
# define CENABLE .import __libc_enable_asynccancel,code ASM_LINE_SEP \
bl __libc_enable_asynccancel,%r2 ASM_LINE_SEP
# define CDISABLE .import __libc_disable_asynccancel,code ASM_LINE_SEP \
@@ -128,7 +127,7 @@
bl __libc_disable_asynccancel,%r2 ASM_LINE_SEP
# endif
# else
-# ifdef PIC
+# ifdef __PIC__
# define CENABLE .import __librt_enable_asynccancel,code ASM_LINE_SEP \
bl __librt_enable_asynccancel,%r2 ASM_LINE_SEP
# define CDISABLE .import __librt_disable_asynccancel,code ASM_LINE_SEP \
@@ -167,7 +166,7 @@
nop ASM_LINE_SEP \
ldw MULTIPLE_THREADS_OFFSET(%sr0,%ret0),%ret0 ASM_LINE_SEP \
Lstp: ASM_LINE_SEP
-# ifdef PIC
+# ifdef __PIC__
/* Slower version uses GOT to get value of __local_multiple_threads */
# define SINGLE_THREAD_P \
addil LT%__local_multiple_threads, %r19 ASM_LINE_SEP \
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h
index a5dbeff1e..d330e664e 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/i386/sysdep-cancel.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 <tls.h>
#include <pt-machine.h>
@@ -101,7 +100,7 @@
# define CENABLE call __pthread_enable_asynccancel;
# define CDISABLE call __pthread_disable_asynccancel
# elif defined IS_IN_librt
-# ifdef PIC
+# ifdef __PIC__
# define CENABLE pushl %ebx; \
call __i686.get_pc_thunk.bx; \
addl $_GLOBAL_OFFSET_TABLE_, %ebx; \
@@ -139,7 +138,7 @@
#endif
# ifndef __ASSEMBLER__
-# if defined FLOATING_STACKS && USE___THREAD && defined PIC
+# if defined FLOATING_STACKS && defined __UCLIBC_HAS_TLS__ && defined __PIC__
# define SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, \
p_header.data.multiple_threads) == 0, 1)
@@ -153,9 +152,9 @@ extern int __local_multiple_threads
# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
# endif
# else
-# if !defined PIC
+# if !defined __PIC__
# define SINGLE_THREAD_P cmpl $0, __local_multiple_threads
-# elif defined FLOATING_STACKS && USE___THREAD
+# elif defined FLOATING_STACKS && defined __UCLIBC_HAS_TLS__
# define SINGLE_THREAD_P cmpl $0, %gs:MULTIPLE_THREADS_OFFSET
# else
# if !defined NOT_IN_libc || defined IS_IN_libpthread
@@ -165,7 +164,7 @@ extern int __local_multiple_threads
movl __local_multiple_threads@GOT(%ecx), %ecx;\
cmpl $0, (%ecx)
# endif
-# if !defined HAVE_HIDDEN || !USE___THREAD
+# if !defined HAVE_HIDDEN || !defined __UCLIBC_HAS_TLS__
# define SINGLE_THREAD_P \
SETUP_PIC_REG (cx); \
addl $_GLOBAL_OFFSET_TABLE_, %ecx; \
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/i386/vfork.S b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/i386/vfork.S
index c7a120d23..83ad9f3b5 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/i386/vfork.S
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/i386/vfork.S
@@ -13,14 +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 <sysdep-cancel.h>
#define _ERRNO_H 1
#include <bits/errno.h>
-#include <kernel-features.h>
+#include <bits/kernel-features.h>
/* Clone the calling process, but without copying the whole address space.
The calling process is suspended until the new process exits or is
@@ -32,7 +31,7 @@ ENTRY (__vfork)
#ifdef __NR_vfork
# ifdef SHARED
-# if !defined HAVE_HIDDEN || !USE___THREAD
+# if !defined HAVE_HIDDEN || !defined __UCLIBC_HAS_TLS__
SETUP_PIC_REG (cx)
# else
call __i686.get_pc_thunk.cx
@@ -44,7 +43,7 @@ ENTRY (__vfork)
movl $pthread_create, %eax
testl %eax, %eax
# endif
- jne HIDDEN_JUMPTARGET (__fork)
+ jne HIDDEN_JUMPTARGET (fork)
/* Pop the return PC value into ECX. */
popl %ecx
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/bits/local_lim.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/bits/local_lim.h
index 629b1f89c..ad12181ff 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/bits/local_lim.h
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/bits/local_lim.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/>. */
/* The kernel header pollutes the namespace with the NR_OPEN symbol
and defines LINK_MAX although filesystems have different maxima. A
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/fork.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/fork.h
index 30a0cc191..88f286145 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/fork.h
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/fork.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 <signal.h>
#include <sysdep.h>
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/pt-initfini.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/pt-initfini.c
index af8a63c16..025566587 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/pt-initfini.c
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/pt-initfini.c
@@ -23,8 +23,7 @@
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, 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
+ see <http://www.gnu.org/licenses/>. */
/* This file is compiled into assembly code which is then munged by a sed
script into two files: crti.s and crtn.s.
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/pt-sigsuspend.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/pt-sigsuspend.c
index 0b96e3d5b..edb08439a 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/pt-sigsuspend.c
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/pt-sigsuspend.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 <signal.h>
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h
index dd9637d2b..595644044 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.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 <sysdep.h>
#include <tls.h>
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/vfork.S b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/vfork.S
index 54acedad4..9b5fa767f 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/ia64/vfork.S
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/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-cancel.h>
@@ -38,7 +37,7 @@ ENTRY(__vfork)
#endif
ld8 r14 = [r14];;
cmp.ne p6, p7 = 0, r14
-(p6) br.cond.spnt.few HIDDEN_JUMPTARGET (__fork);;
+(p6) br.cond.spnt.few HIDDEN_JUMPTARGET (fork);;
alloc r2=ar.pfs,0,0,2,0
mov out0=CLONE_VM+CLONE_VFORK+SIGCHLD
mov out1=0 /* Standard sp value. */
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/jmp-unwind.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/jmp-unwind.c
index 4b9031570..3e04f515f 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/jmp-unwind.c
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/jmp-unwind.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 <setjmp.h>
#include <stddef.h>
@@ -32,3 +31,4 @@ _longjmp_unwind (jmp_buf env, int val)
(env->__jmpbuf, __builtin_frame_address (0)),
(void) 0);
}
+libc_hidden_def(_longjmp_unwind)
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h
index bb798e40d..54b99d688 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/m68k/sysdep-cancel.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 <sysdep.h>
#ifndef __ASSEMBLER__
@@ -77,7 +76,7 @@
# define UNDOCARGS_5 UNDOCARGS_4; move.l (%sp)+, %d5;
# ifdef IS_IN_libpthread
-# ifdef PIC
+# ifdef __PIC__
# define CENABLE jbsr __pthread_enable_asynccancel@PLTPC
# define CDISABLE jbsr __pthread_disable_asynccancel@PLTPC
# else
@@ -85,7 +84,7 @@
# define CDISABLE jbsr __pthread_disable_asynccancel
# endif
# elif !defined NOT_IN_libc
-# ifdef PIC
+# ifdef __PIC__
# define CENABLE jbsr __libc_enable_asynccancel@PLTPC
# define CDISABLE jbsr __libc_disable_asynccancel@PLTPC
# else
@@ -93,7 +92,7 @@
# define CDISABLE jbsr __libc_disable_asynccancel
# endif
# else
-# ifdef PIC
+# ifdef __PIC__
# define CENABLE jbsr __librt_enable_asynccancel@PLTPC
# define CDISABLE jbsr __librt_disable_asynccancel@PLTPC
# else
@@ -114,7 +113,7 @@
extern int __local_multiple_threads attribute_hidden;
# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
# else
-# if !defined PIC
+# if !defined __PIC__
# define SINGLE_THREAD_P tst.l __local_multiple_threads
# else
# define SINGLE_THREAD_P tst.l (__local_multiple_threads, %pc)
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/m68k/vfork.S b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/m68k/vfork.S
index 49b8a3c0a..2a4d3862c 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/m68k/vfork.S
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/m68k/vfork.S
@@ -13,14 +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 <sysdep-cancel.h>
#define _ERRNO_H 1
#include <bits/errno.h>
-#include <kernel-features.h>
+#include <bits/kernel-features.h>
/* Clone the calling process, but without copying the whole address space.
The calling process is suspended until the new process exits or is
@@ -35,7 +34,7 @@ ENTRY (__vfork)
.weak pthread_create
movel #pthread_create, %d0
#endif
- jbne HIDDEN_JUMPTARGET (__fork)
+ jbne HIDDEN_JUMPTARGET (fork)
#ifdef __NR_vfork
@@ -56,7 +55,7 @@ ENTRY (__vfork)
movel %a0,%sp@-
# ifdef __ASSUME_VFORK_SYSCALL
-# ifndef PIC
+# ifndef __PIC__
jbra SYSCALL_ERROR_LABEL
# endif
# else
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h
index fc5177425..10c82a61c 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.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/>. */
#include <sysdep.h>
#ifndef __ASSEMBLER__
@@ -31,7 +30,7 @@
# undef PSEUDO
# define PSEUDO(name, syscall_name, args) \
.align 2; \
- 99: \
+ 99: move a0, v0; \
PTR_LA t9,__syscall_error; \
/* manual cpreturn. */ \
REG_L gp, STKOFF_GP(sp); \
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h
index 1fff78239..4e6dec775 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/sysdep-cancel.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 <sysdep.h>
#ifndef __ASSEMBLER__
@@ -28,7 +27,8 @@
# undef PSEUDO
# define PSEUDO(name, syscall_name, args) \
.align 2; \
- 99: la t9,__syscall_error; \
+ 99: move a0, v0; \
+ la t9,__syscall_error; \
jr t9; \
ENTRY (name) \
.set noreorder; \
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/vfork.S b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/vfork.S
index 7bbab5c59..09dcfa683 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/vfork.S
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mips/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/>. */
/* vfork() is just a special case of clone(). */
@@ -80,6 +79,7 @@ NESTED(__vfork,FRAMESZ,sp)
/* Something bad happened -- no child created. */
L(error):
+ move a0, v0
#ifdef __PIC__
PTR_LA t9, __syscall_error
RESTORE_GP64
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mq_notify.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mq_notify.c
index 6cd0f09c1..13daefee6 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mq_notify.c
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/mq_notify.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 <assert.h>
#include <errno.h>
@@ -76,7 +75,7 @@ __attribute__ ((noinline))
change_sigmask (int how, sigset_t *oss)
{
sigset_t ss;
- sigfillset (&ss);
+ __sigfillset (&ss);
return pthread_sigmask (how, &ss, oss);
}
@@ -163,8 +162,7 @@ init_mq_netlink (void)
return;
/* Make sure the descriptor is closed on exec. */
- if (fcntl (netlink_socket, F_SETFD, FD_CLOEXEC) != 0)
- goto errout;
+ fcntl (netlink_socket, F_SETFD, FD_CLOEXEC);
}
int err = 1;
@@ -213,7 +211,6 @@ init_mq_netlink (void)
if (err != 0)
{
- errout:
close_not_cancel_no_status (netlink_socket);
netlink_socket = -1;
}
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h
index 865da8e8c..6c3dc12a0 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.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 <sysdep.h>
#include <tls.h>
@@ -89,7 +88,7 @@
# else
# define CENABLE bl JUMPTARGET(__librt_enable_asynccancel)
# define CDISABLE bl JUMPTARGET(__librt_disable_asynccancel)
-# if defined HAVE_AS_REL16 && defined PIC
+# if defined HAVE_AS_REL16 && defined __PIC__
# undef CGOTSETUP
# define CGOTSETUP \
bcl 20,31,1f; \
@@ -122,7 +121,7 @@
extern int __local_multiple_threads attribute_hidden;
# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
# else
-# if !defined PIC
+# if !defined __PIC__
# define SINGLE_THREAD_P \
lis 10,__local_multiple_threads@ha; \
lwz 10,__local_multiple_threads@l(10); \
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S
index 724d4cc54..4b16829be 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S
@@ -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 <sysdep-cancel.h>
#define _ERRNO_H 1
#include <bits/errno.h>
-#include <kernel-features.h>
+#include <bits/kernel-features.h>
/* Clone the calling process, but without copying the whole address space.
The calling process is suspended until the new process exits or is
@@ -66,7 +65,7 @@ ENTRY (__vfork)
# endif
.Lhidden_fork:
- b HIDDEN_JUMPTARGET(__fork)
+ b HIDDEN_JUMPTARGET(fork)
#endif
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h
index 0c7467676..901982ec8 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.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 <sysdep.h>
#include <tls.h>
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S
index b408e31b7..47c91dfd4 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S
@@ -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 <sysdep-cancel.h>
#define _ERRNO_H 1
#include <bits/errno.h>
-#include <kernel-features.h>
+#include <bits/kernel-features.h>
/* Clone the calling process, but without copying the whole address space.
The calling process is suspended until the new process exits or is
@@ -42,7 +41,7 @@ ENTRY (__vfork)
ld 10,.LC0@toc(2)
ld 10,0(10)
cmpwi 10,0
- bne- HIDDEN_JUMPTARGET(__fork)
+ bne- HIDDEN_JUMPTARGET(fork)
# else
.weak pthread_create
lis 10,pthread_create@highest
@@ -80,7 +79,7 @@ ENTRY (__vfork)
# ifndef SHARED
.Lhidden_fork:
- b HIDDEN_JUMPTARGET(__fork)
+ b HIDDEN_JUMPTARGET(fork)
.Lsyscall_error:
b JUMPTARGET(__syscall_error)
# endif
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/pt-sigsuspend.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/pt-sigsuspend.c
index 7c9fe36e2..83f678c8b 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/pt-sigsuspend.c
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/pt-sigsuspend.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 <signal.h>
@@ -24,7 +23,7 @@
#include <sys/syscall.h>
#include <linuxthreads/internals.h>
-#include <kernel-features.h>
+#include <bits/kernel-features.h>
void
__pthread_sigsuspend (const sigset_t *set)
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/raise.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/raise.c
index 61209cfaf..1e11a4812 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/raise.c
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/raise.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 <signal.h>
#include <unistd.h>
@@ -40,4 +39,3 @@ raise (sig)
#endif
}
libc_hidden_def (raise)
-weak_alias (raise, gsignal)
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/register-atfork.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/register-atfork.c
index 2dce262a3..338d421e3 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/register-atfork.c
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/register-atfork.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 <stdlib.h>
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/s390/bits/typesizes.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/s390/bits/typesizes.h
deleted file mode 100644
index bee7639f0..000000000
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/s390/bits/typesizes.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* bits/typesizes.h -- underlying types for *_t. Linux/s390 version.
- Copyright (C) 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 _BITS_TYPES_H
-# error "Never include <bits/typesizes.h> directly; use <sys/types.h> instead."
-#endif
-
-#ifndef _BITS_TYPESIZES_H
-#define _BITS_TYPESIZES_H 1
-
-/* See <bits/types.h> for the meaning of these macros. This file exists so
- that <bits/types.h> need not vary across different GNU platforms. */
-
-#define __DEV_T_TYPE __UQUAD_TYPE
-#define __UID_T_TYPE __U32_TYPE
-#define __GID_T_TYPE __U32_TYPE
-#define __INO_T_TYPE __ULONGWORD_TYPE
-#define __INO64_T_TYPE __UQUAD_TYPE
-#define __MODE_T_TYPE __U32_TYPE
-#define __NLINK_T_TYPE __UWORD_TYPE
-#define __OFF_T_TYPE __SLONGWORD_TYPE
-#define __OFF64_T_TYPE __SQUAD_TYPE
-#define __PID_T_TYPE __S32_TYPE
-#define __RLIM_T_TYPE __ULONGWORD_TYPE
-#define __RLIM64_T_TYPE __UQUAD_TYPE
-#define __BLKCNT_T_TYPE __SLONGWORD_TYPE
-#define __BLKCNT64_T_TYPE __SQUAD_TYPE
-#define __FSBLKCNT_T_TYPE __ULONGWORD_TYPE
-#define __FSBLKCNT64_T_TYPE __UQUAD_TYPE
-#define __FSFILCNT_T_TYPE __ULONGWORD_TYPE
-#define __FSFILCNT64_T_TYPE __UQUAD_TYPE
-#define __ID_T_TYPE __U32_TYPE
-#define __CLOCK_T_TYPE __SLONGWORD_TYPE
-#define __TIME_T_TYPE __SLONGWORD_TYPE
-#define __USECONDS_T_TYPE __U32_TYPE
-#define __SUSECONDS_T_TYPE __SLONGWORD_TYPE
-#define __DADDR_T_TYPE __S32_TYPE
-#define __SWBLK_T_TYPE __SLONGWORD_TYPE
-#define __KEY_T_TYPE __S32_TYPE
-#define __CLOCKID_T_TYPE __S32_TYPE
-#define __TIMER_T_TYPE __S32_TYPE
-#define __BLKSIZE_T_TYPE __SLONGWORD_TYPE
-#define __FSID_T_TYPE struct { int __val[2]; }
-#if defined __GNUC__ && __GNUC__ <= 2
-/* Compatibility with g++ 2.95.x. */
-#define __SSIZE_T_TYPE __SWORD_TYPE
-#else
-/* size_t is unsigned long int on s390 -m31. */
-#define __SSIZE_T_TYPE __SLONGWORD_TYPE
-#endif
-
-/* Number of descriptors that can fit in an `fd_set'. */
-#define __FD_SETSIZE 1024
-
-
-#endif /* bits/typesizes.h */
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-32/pt-initfini.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-32/pt-initfini.c
deleted file mode 100644
index b7d901c4c..000000000
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-32/pt-initfini.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/* Special .init and .fini section support for S/390.
- Copyright (C) 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.
-
- 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 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 Lesser General 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, 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-/* This file is compiled into assembly code which is then munged by a sed
- script into two files: crti.s and crtn.s.
-
- * crti.s puts a function prologue at the beginning of the
- .init and .fini sections and defines global symbols for
- those addresses, so they can be called as functions.
-
- * crtn.s puts the corresponding function epilogues
- in the .init and .fini sections. */
-
-__asm__ ("\
-\n\
-#include \"defs.h\"\n\
-\n\
-/*@HEADER_ENDS*/\n\
-\n\
-/*@TESTS_BEGIN*/\n\
-\n\
-/*@TESTS_END*/\n\
-\n\
-/*@_init_PROLOG_BEGINS*/\n\
-\n\
- .section .init\n\
-#NO_APP\n\
- .align 4\n\
-.globl _init\n\
- .type _init,@function\n\
-_init:\n\
-# leaf function 0\n\
-# automatics 0\n\
-# outgoing args 0\n\
-# need frame pointer 0\n\
-# call alloca 0\n\
-# has varargs 0\n\
-# incoming args (stack) 0\n\
-# function length 36\n\
- STM 6,15,24(15)\n\
- BRAS 13,.LTN1_0\n\
-.LT1_0:\n\
-.LC13:\n\
- .long __pthread_initialize_minimal@PLT-.LT1_0\n\
-.LC14:\n\
- .long __gmon_start__@GOT\n\
-.LC15:\n\
- .long _GLOBAL_OFFSET_TABLE_-.LT1_0\n\
-.LTN1_0:\n\
- LR 1,15\n\
- AHI 15,-96\n\
- ST 1,0(15)\n\
- L 12,.LC15-.LT1_0(13)\n\
- AR 12,13\n\
- L 1,.LC13-.LT1_0(13)\n\
- LA 1,0(1,13)\n\
- BASR 14,1\n\
- L 1,.LC14-.LT1_0(13)\n\
- L 1,0(1,12)\n\
- LTR 1,1\n\
- JE .L22\n\
- BASR 14,1\n\
-.L22:\n\
-#APP\n\
- .align 4,0x07\n\
- END_INIT\n\
-\n\
-/*@_init_PROLOG_ENDS*/\n\
-\n\
-/*@_init_EPILOG_BEGINS*/\n\
- .align 4\n\
- .section .init\n\
-#NO_APP\n\
- .align 4\n\
- L 4,152(15)\n\
- LM 6,15,120(15)\n\
- BR 4\n\
-#APP\n\
- END_INIT\n\
-\n\
-/*@_init_EPILOG_ENDS*/\n\
-\n\
-/*@_fini_PROLOG_BEGINS*/\n\
- .section .fini\n\
-#NO_APP\n\
- .align 4\n\
-.globl _fini\n\
- .type _fini,@function\n\
-_fini:\n\
-# leaf function 0\n\
-# automatics 0\n\
-# outgoing args 0\n\
-# need frame pointer 0\n\
-# call alloca 0\n\
-# has varargs 0\n\
-# incoming args (stack) 0\n\
-# function length 30\n\
- STM 6,15,24(15)\n\
- BRAS 13,.LTN2_0\n\
-.LT2_0:\n\
-.LC17:\n\
- .long _GLOBAL_OFFSET_TABLE_-.LT2_0\n\
-.LTN2_0:\n\
- LR 1,15\n\
- AHI 15,-96\n\
- ST 1,0(15)\n\
- L 12,.LC17-.LT2_0(13)\n\
- AR 12,13\n\
-#APP\n\
- .align 4,0x07\n\
- END_FINI\n\
-\n\
-/*@_fini_PROLOG_ENDS*/\n\
-\n\
-/*@_fini_EPILOG_BEGINS*/\n\
- .align 4\n\
- .section .fini\n\
-#NO_APP\n\
- .align 4\n\
- L 4,152(15)\n\
- LM 6,15,120(15)\n\
- BR 4\n\
-#APP\n\
- END_FINI\n\
-\n\
-/*@_fini_EPILOG_ENDS*/\n\
-\n\
-/*@TRAILER_BEGINS*/\
-");
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h
deleted file mode 100644
index 06f7aed7d..000000000
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h
+++ /dev/null
@@ -1,137 +0,0 @@
-/* Copyright (C) 2003, 2004 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, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#include <sysdep.h>
-#include <tls.h>
-#ifndef __ASSEMBLER__
-# include <linuxthreads/internals.h>
-#endif
-
-#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
-
-# if !defined NOT_IN_libc || defined IS_IN_libpthread
-
-# define PSEUDO_CANCEL(name, syscall_name, args) \
-L(pseudo_cancel): \
- STM_##args \
- stm %r12,%r15,48(%r15); \
- lr %r14,%r15; \
- ahi %r15,-96; \
- st %r14,0(%r15); \
- basr %r13,0; \
-0: l %r1,1f-0b(%r13); \
- bas %r14,0(%r1,%r13); \
- lr %r0,%r2; \
- LM_##args \
- DO_CALL(syscall_name, args); \
- l %r1,2f-0b(%r13); \
- lr %r12,%r2; \
- lr %r2,%r0; \
- bas %r14,0(%r1,%r13); \
- lr %r2,%r12; \
- lm %r12,%r15,48+96(%r15); \
- j L(pseudo_check); \
-1: .long CENABLE-0b; \
-2: .long CDISABLE-0b;
-
-# else /* !libc.so && !libpthread.so */
-
-# define PSEUDO_CANCEL(name, syscall_name, args) \
-L(pseudo_cancel): \
- STM_##args \
- stm %r11,%r15,44(%r15); \
- lr %r14,%r15; \
- ahi %r15,-96; \
- st %r14,0(%r15); \
- basr %r13,0; \
-0: l %r12,3f-0b(%r13); \
- l %r1,1f-0b(%r13); \
- la %r12,0(%r12,%r13); \
- bas %r14,0(%r1,%r13); \
- lr %r0,%r2; \
- LM_##args \
- DO_CALL(syscall_name, args); \
- l %r1,2f-0b(%r13); \
- lr %r11,%r2; \
- lr %r2,%r0; \
- bas %r14,0(%r1,%r13); \
- lr %r2,%r11; \
- lm %r11,%r15,44+96(%r15); \
- j L(pseudo_check); \
-1: .long CENABLE@PLT-0b; \
-2: .long CDISABLE@PLT-0b; \
-3: .long _GLOBAL_OFFSET_TABLE_-0b;
-
-# endif
-
-# undef PSEUDO
-# define PSEUDO(name, syscall_name, args) \
- .text; \
-PSEUDO_CANCEL(name, syscall_name, args) \
-ENTRY(name) \
- SINGLE_THREAD_P(%r1) \
- jne L(pseudo_cancel); \
- DO_CALL(syscall_name, args); \
-L(pseudo_check): \
- lhi %r4,-4095; \
- clr %r2,%r4; \
- jnl SYSCALL_ERROR_LABEL; \
-L(pseudo_end):
-
-# ifdef IS_IN_libpthread
-# define CENABLE __pthread_enable_asynccancel
-# define CDISABLE __pthread_disable_asynccancel
-# elif !defined NOT_IN_libc
-# define CENABLE __libc_enable_asynccancel
-# define CDISABLE __libc_disable_asynccancel
-# else
-# define CENABLE __librt_enable_asynccancel
-# define CDISABLE __librt_disable_asynccancel
-# endif
-
-#define STM_0 /* Nothing */
-#define STM_1 st %r2,8(%r15);
-#define STM_2 stm %r2,%r3,8(%r15);
-#define STM_3 stm %r2,%r4,8(%r15);
-#define STM_4 stm %r2,%r5,8(%r15);
-#define STM_5 stm %r2,%r5,8(%r15);
-
-#define LM_0 /* Nothing */
-#define LM_1 l %r2,8+96(%r15);
-#define LM_2 lm %r2,%r3,8+96(%r15);
-#define LM_3 lm %r2,%r4,8+96(%r15);
-#define LM_4 lm %r2,%r5,8+96(%r15);
-#define LM_5 lm %r2,%r5,8+96(%r15);
-
-# ifndef __ASSEMBLER__
-# define SINGLE_THREAD_P \
- __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
- p_header.data.multiple_threads) == 0, 1)
-# else
-# define SINGLE_THREAD_P(reg) \
- ear reg,%a0; \
- icm reg,15,MULTIPLE_THREADS_OFFSET(reg);
-# endif
-
-#elif !defined __ASSEMBLER__
-
-/* This code should never be used but we define it anyhow. */
-# define SINGLE_THREAD_P (1)
-
-#endif
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-64/pt-initfini.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-64/pt-initfini.c
deleted file mode 100644
index 540443e6a..000000000
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-64/pt-initfini.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/* Special .init and .fini section support for 64 bit S/390.
- Copyright (C) 2001 Free Software Foundation, Inc.
- Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
- 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 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 Lesser General 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, 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-/* This file is compiled into assembly code which is then munged by a sed
- script into two files: crti.s and crtn.s.
-
- * crti.s puts a function prologue at the beginning of the
- .init and .fini sections and defines global symbols for
- those addresses, so they can be called as functions.
-
- * crtn.s puts the corresponding function epilogues
- in the .init and .fini sections. */
-
-__asm__ ("\
-\n\
-#include \"defs.h\"\n\
-\n\
-/*@HEADER_ENDS*/\n\
-\n\
-/*@TESTS_BEGIN*/\n\
-\n\
-/*@TESTS_END*/\n\
-\n\
-/*@_init_PROLOG_BEGINS*/\n\
-\n\
- .section .init\n\
-#NO_APP\n\
- .align 4\n\
-.globl _init\n\
- .type _init,@function\n\
-_init:\n\
-# leaf function 0\n\
-# automatics 0\n\
-# outgoing args 0\n\
-# need frame pointer 0\n\
-# call alloca 0\n\
-# has varargs 0\n\
-# incoming args (stack) 0\n\
-# function length 36\n\
- STMG 6,15,48(15)\n\
- LGR 1,15\n\
- AGHI 15,-160\n\
- STG 1,0(15)\n\
- LARL 12,_GLOBAL_OFFSET_TABLE_\n\
- BRASL 14,__pthread_initialize_minimal@PLT\n\
- LARL 1,__gmon_start__@GOTENT\n\
- LG 1,0(1)\n\
- LTGR 1,1\n\
- JE .L22\n\
- BASR 14,1\n\
-.L22:\n\
-#APP\n\
- .align 4,0x07\n\
- END_INIT\n\
-\n\
-/*@_init_PROLOG_ENDS*/\n\
-\n\
-/*@_init_EPILOG_BEGINS*/\n\
- .align 4\n\
- .section .init\n\
-#NO_APP\n\
- .align 4\n\
- LG 4,272(15)\n\
- LMG 6,15,208(15)\n\
- BR 4\n\
-#APP\n\
- END_INIT\n\
-\n\
-/*@_init_EPILOG_ENDS*/\n\
-\n\
-/*@_fini_PROLOG_BEGINS*/\n\
- .section .fini\n\
-#NO_APP\n\
- .align 4\n\
-.globl _fini\n\
- .type _fini,@function\n\
-_fini:\n\
-# leaf function 0\n\
-# automatics 0\n\
-# outgoing args 0\n\
-# need frame pointer 0\n\
-# call alloca 0\n\
-# has varargs 0\n\
-# incoming args (stack) 0\n\
-# function length 30\n\
- STMG 6,15,48(15)\n\
- LGR 1,15\n\
- AGHI 15,-160\n\
- STG 1,0(15)\n\
- LARL 12,_GLOBAL_OFFSET_TABLE_\n\
-#APP\n\
- .align 4,0x07\n\
- END_FINI\n\
-\n\
-/*@_fini_PROLOG_ENDS*/\n\
-\n\
-/*@_fini_EPILOG_BEGINS*/\n\
- .align 4\n\
- .section .fini\n\
-#NO_APP\n\
- .align 4\n\
- LG 4,272(15)\n\
- LMG 6,15,208(15)\n\
- BR 4\n\
-#APP\n\
- END_FINI\n\
-\n\
-/*@_fini_EPILOG_ENDS*/\n\
-\n\
-/*@TRAILER_BEGINS*/\n\
- ");
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-64/pt-sigsuspend.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-64/pt-sigsuspend.c
deleted file mode 100644
index d57283ad2..000000000
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-64/pt-sigsuspend.c
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../ia64/pt-sigsuspend.c"
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h
deleted file mode 100644
index f71ef3f68..000000000
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/* Copyright (C) 2003, 2004 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, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#include <sysdep.h>
-#include <tls.h>
-#ifndef __ASSEMBLER__
-# include <linuxthreads/internals.h>
-#endif
-
-#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
-
-# undef PSEUDO
-# define PSEUDO(name, syscall_name, args) \
- .text; \
-L(pseudo_cancel): \
- STM_##args \
- stmg %r13,%r15,104(%r15); \
- lgr %r14,%r15; \
- aghi %r15,-160; \
- stg %r14,0(%r15); \
- brasl %r14,CENABLE; \
- lgr %r0,%r2; \
- LM_##args \
- DO_CALL(syscall_name, args); \
- lgr %r13,%r2; \
- lgr %r2,%r0; \
- brasl %r14,CDISABLE; \
- lgr %r2,%r13; \
- lmg %r13,%r15,104+160(%r15); \
- j L(pseudo_check); \
-ENTRY(name) \
- SINGLE_THREAD_P \
- jne L(pseudo_cancel); \
- DO_CALL(syscall_name, args); \
-L(pseudo_check): \
- lghi %r4,-4095; \
- clgr %r2,%r4; \
- jgnl SYSCALL_ERROR_LABEL; \
-L(pseudo_end):
-
-# ifdef IS_IN_libpthread
-# define CENABLE __pthread_enable_asynccancel
-# define CDISABLE __pthread_disable_asynccancel
-# define __local_multiple_threads __pthread_multiple_threads
-# elif !defined NOT_IN_libc
-# define CENABLE __libc_enable_asynccancel
-# define CDISABLE __libc_disable_asynccancel
-# define __local_multiple_threads __libc_multiple_threads
-# else
-# define CENABLE __librt_enable_asynccancel@PLT
-# define CDISABLE __librt_disable_asynccancel@PLT
-# endif
-
-#define STM_0 /* Nothing */
-#define STM_1 stg %r2,16(%r15);
-#define STM_2 stmg %r2,%r3,16(%r15);
-#define STM_3 stmg %r2,%r4,16(%r15);
-#define STM_4 stmg %r2,%r5,16(%r15);
-#define STM_5 stmg %r2,%r5,16(%r15);
-
-#define LM_0 /* Nothing */
-#define LM_1 lg %r2,16+160(%r15);
-#define LM_2 lmg %r2,%r3,16+160(%r15);
-#define LM_3 lmg %r2,%r4,16+160(%r15);
-#define LM_4 lmg %r2,%r5,16+160(%r15);
-#define LM_5 lmg %r2,%r5,16+160(%r15);
-
-# if !defined NOT_IN_libc || defined IS_IN_libpthread
-# ifndef __ASSEMBLER__
-extern int __local_multiple_threads attribute_hidden;
-# define SINGLE_THREAD_P \
- __builtin_expect (__local_multiple_threads == 0, 1)
-# else
-# define SINGLE_THREAD_P \
- larl %r1,__local_multiple_threads; \
- icm %r0,15,0(%r1);
-# endif
-
-# else
-
-# ifndef __ASSEMBLER__
-# define SINGLE_THREAD_P \
- __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
- p_header.data.multiple_threads) == 0, 1)
-# else
-# define SINGLE_THREAD_P \
- ear %r1,%a0; \
- sllg %r1,%r1,32; \
- ear %r1,%a1; \
- icm %r1,15,MULTIPLE_THREADS_OFFSET(%r1);
-# endif
-
-# endif
-
-#elif !defined __ASSEMBLER__
-
-/* This code should never be used but we define it anyhow. */
-# define SINGLE_THREAD_P (1)
-
-#endif
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/pt-initfini.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/pt-initfini.c
index 1cdb98f0f..500fff091 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/pt-initfini.c
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/pt-initfini.c
@@ -23,8 +23,7 @@
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, 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
+ see <http://www.gnu.org/licenses/>. */
/* This file is compiled into assembly code which is then munged by a sed
script into two files: crti.s and crtn.s.
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/smp.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/smp.h
index 5e2f43cda..7d8ced7d7 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/smp.h
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/smp.h
@@ -14,8 +14,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/>. */
static __inline__ int
is_smp_system (void)
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h
index 03c6fedbf..58c726b20 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/sysdep-cancel.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 <sysdep.h>
#include <tls.h>
@@ -102,7 +101,7 @@
# define __local_multiple_threads __librt_multiple_threads
# endif
-# if defined IS_IN_librt && defined PIC
+# if defined IS_IN_librt && defined __PIC__
# define CENABLE \
mov.l r12,@-r15; \
mov.l 1f,r12; \
@@ -155,7 +154,7 @@
# endif
# ifndef __ASSEMBLER__
-# if defined FLOATING_STACKS && USE___THREAD && defined PIC
+# if defined FLOATING_STACKS && defined __UCLIBC_HAS_TLS__ && defined __PIC__
# define SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, p_multiple_threads) == 0, 1)
# else
@@ -163,7 +162,7 @@ extern int __local_multiple_threads attribute_hidden;
# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
# endif
# else
-# if !defined PIC
+# if !defined __PIC__
# define SINGLE_THREAD_P \
mov.l 1f,r0; \
mov.l @r0,r0; \
@@ -172,7 +171,7 @@ extern int __local_multiple_threads attribute_hidden;
.align 2; \
1: .long __local_multiple_threads; \
2:
-# elif defined FLOATING_STACKS && USE___THREAD
+# elif defined FLOATING_STACKS && defined __UCLIBC_HAS_TLS__
# define SINGLE_THREAD_P \
stc gbr,r0; \
mov.w 0f,r1; \
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/vfork.S b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/vfork.S
index f230c0122..90733119e 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/vfork.S
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sh/vfork.S
@@ -12,13 +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 <sysdep-cancel.h>
#define _ERRNO_H 1
#include <bits/errno.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
@@ -39,12 +39,12 @@ ENTRY (__vfork)
bf .Lhidden_fork
mov.w .L1, r3
- trapa #0x10
+ trapa #__SH_SYSCALL_TRAP_BASE
mov r0, r1
mov #-12, r2
shad r2, r1
- 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 .Lpseudo_end
SYSCALL_ERROR_HANDLER
.Lpseudo_end:
@@ -63,13 +63,13 @@ ENTRY (__vfork)
.long pthread_create
#endif
-.Lhidden_fork:
+.Lhidden_fork:
mov.l .L2, r1
braf r1
nop
1:
.align 2
-.L2: .long HIDDEN_JUMPTARGET(__fork)-1b
+.L2: .long HIDDEN_JUMPTARGET(fork)-1b
PSEUDO_END (__vfork)
libc_hidden_def (__vfork)
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sigwait.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sigwait.c
index 3432125bb..2e09d1ba5 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sigwait.c
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sigwait.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>
#include <signal.h>
@@ -23,11 +22,10 @@
#include <sysdep-cancel.h>
#include <sys/syscall.h>
-#include <bp-checks.h>
#include <bits/libc-lock.h>
-extern int __syscall_rt_sigtimedwait (const sigset_t *__unbounded, siginfo_t *__unbounded,
- const struct timespec *__unbounded, size_t);
+extern int __syscall_rt_sigtimedwait (const sigset_t *, siginfo_t *,
+ const struct timespec *, size_t);
/* Return any pending signal or wait for one for the given time. */
@@ -40,7 +38,7 @@ do_sigwait (const sigset_t *set, int *sig)
real size of the user-level sigset_t. */
#ifdef INTERNAL_SYSCALL
INTERNAL_SYSCALL_DECL (err);
- ret = INTERNAL_SYSCALL (rt_sigtimedwait, err, 4, CHECK_SIGSET (set),
+ ret = INTERNAL_SYSCALL (rt_sigtimedwait, err, 4, set,
NULL, NULL, _NSIG / 8);
if (! INTERNAL_SYSCALL_ERROR_P (ret, err))
{
@@ -50,7 +48,7 @@ do_sigwait (const sigset_t *set, int *sig)
else
ret = INTERNAL_SYSCALL_ERRNO (ret, err);
#else
- ret = INLINE_SYSCALL (rt_sigtimedwait, 4, CHECK_SIGSET (set),
+ ret = INLINE_SYSCALL (rt_sigtimedwait, 4, set,
NULL, NULL, _NSIG / 8);
if (ret != -1)
{
@@ -69,9 +67,7 @@ weak_extern (__pthread_sigwait)
#endif
int
-__sigwait (set, sig)
- const sigset_t *set;
- int *sig;
+sigwait (const sigset_t *set, int *sig)
{
#ifndef NOT_IN_libc
return __libc_maybe_call2 (pthread_sigwait, (set, sig),
@@ -80,9 +76,7 @@ __sigwait (set, sig)
return do_sigwait (set, sig);
#endif
}
-libc_hidden_def (__sigwait)
-weak_alias (__sigwait, sigwait)
-strong_alias (__sigwait, __libc_sigwait)
+strong_alias(sigwait, __libc_sigwait)
/* Cancellation is handled in __pthread_sigwait. */
LIBC_CANCEL_HANDLED ();
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/smp.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/smp.h
index 9ab75e8e6..6f03b9d55 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/smp.h
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/smp.h
@@ -14,8 +14,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 <sys/sysctl.h>
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/bits/local_lim.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/bits/local_lim.h
index 27ffa668f..3f22f8ae3 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/bits/local_lim.h
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/bits/local_lim.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/>. */
/* The kernel header pollutes the namespace with the NR_OPEN symbol
and defines LINK_MAX although filesystems have different maxima. A
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
index 7e4253789..3efee0b8d 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/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/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/fork.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/fork.h
index b736526c1..ce98a3bb9 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/fork.h
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/fork.h
@@ -13,22 +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 <sysdep.h>
-
-#define ARCH_FORK() \
-({ \
- register long __o0 __asm__ ("o0"); \
- register long __o1 __asm__ ("o1"); \
- register long __g1 __asm__ ("g1") = __NR_fork; \
- __asm__ __volatile__ (__SYSCALL_STRING \
- : "=r" (__g1), "=r" (__o0), "=r" (__o1) \
- : "0" (__g1) \
- : __SYSCALL_CLOBBERS); \
- __o0 == -1 ? __o0 : (__o0 & (__o1 - 1)); \
-})
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include_next <fork.h>
+
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc64/pt-sigsuspend.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc64/pt-sigsuspend.c
deleted file mode 100644
index d57283ad2..000000000
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc64/pt-sigsuspend.c
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../ia64/pt-sigsuspend.c"
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S
deleted file mode 100644
index 8a6d2771e..000000000
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S
+++ /dev/null
@@ -1,64 +0,0 @@
-/* Copyright (C) 2003 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, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#include <sysdep-cancel.h>
-
-#ifdef SHARED
-.LLGETPC0:
- retl
- add %o7, %o0, %o0
-#endif
-ENTRY(__vfork)
-#ifdef SHARED
- mov %o7, %o1
- sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %o0
- call .LLGETPC0
- add %o0, %lo(_GLOBAL_OFFSET_TABLE_+4), %o0
- sethi %hi(__libc_pthread_functions), %o2
- mov %o1, %o7
- or %o2, %lo(__libc_pthread_functions), %o2
- ldx [%o0 + %o2], %o2
- ldx [%o2], %o0
-#else
- .weak pthread_create
- sethi %hi(pthread_create), %o0
- or %o0, %lo(pthread_create), %o0
-#endif
-#if defined SHARED && !defined BROKEN_SPARC_WDISP22
- cmp %o0, 0
- bne HIDDEN_JUMPTARGET(__fork)
-#else
- brnz,pn %o0, 1f
-#endif
- mov __NR_vfork, %g1
- ta 0x6d
- bcs,pn %xcc, __syscall_error_handler
- nop
- sub %o1, 1, %o1
- retl
- and %o0, %o1, %o0
-#if !defined SHARED || defined BROKEN_SPARC_WDISP22
-1: mov %o7, %g1
- call HIDDEN_JUMPTARGET(__fork)
- mov %g1, %o7
-#endif
- SYSCALL_ERROR_HANDLER
-PSEUDO_END (__vfork)
-libc_hidden_def (__vfork)
-weak_alias (__vfork, vfork)
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h
index dd3f52a98..bd9bb0d6a 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h
@@ -13,11 +13,9 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 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>
#include <tls.h>
#ifndef __ASSEMBLER__
# include <linuxthreads/internals.h>
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/vfork.S
index 132da67a1..ab2286ee8 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/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/>. */
#include <sysdep-cancel.h>
@@ -43,7 +42,7 @@ ENTRY(__vfork)
orcc %o0, %lo(pthread_create), %o0
#endif
#if defined SHARED && !defined BROKEN_SPARC_WDISP22
- bne HIDDEN_JUMPTARGET(__fork)
+ bne HIDDEN_JUMPTARGET(fork)
#else
bne 1f
#endif
@@ -56,7 +55,7 @@ ENTRY(__vfork)
and %o0, %o1, %o0
#if !defined SHARED || defined BROKEN_SPARC_WDISP22
1: mov %o7, %g1
- call HIDDEN_JUMPTARGET(__fork)
+ call HIDDEN_JUMPTARGET(fork)
mov %g1, %o7
#endif
SYSCALL_ERROR_HANDLER
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/unregister-atfork.c b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/unregister-atfork.c
index dad273fdf..4bc83d6cc 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/unregister-atfork.c
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/unregister-atfork.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 <stdlib.h>
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h
index e82e6dfdd..0b05c96f6 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.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 <sysdep.h>
#include <tls.h>
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/x86_64/vfork.S b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/x86_64/vfork.S
index 25d1d3f96..1a58077c4 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/x86_64/vfork.S
+++ b/libpthread/linuxthreads/sysdeps/unix/sysv/linux/x86_64/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-cancel.h>
#define _ERRNO_H 1
@@ -34,7 +33,7 @@ ENTRY (__vfork)
movq $pthread_create, %rax
testq %rax, %rax
#endif
- jne HIDDEN_JUMPTARGET (__fork)
+ jne HIDDEN_JUMPTARGET (fork)
/* Pop the return PC value into RDI. We need a register that
is preserved by the syscall and that we're allowed to destroy. */
diff --git a/libpthread/linuxthreads/sysdeps/x86_64/pspinlock.c b/libpthread/linuxthreads/sysdeps/x86_64/pspinlock.c
index b43d4ac8d..80c1b05a8 100644
--- a/libpthread/linuxthreads/sysdeps/x86_64/pspinlock.c
+++ b/libpthread/linuxthreads/sysdeps/x86_64/pspinlock.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 <pthread.h>
diff --git a/libpthread/linuxthreads/sysdeps/x86_64/pt-machine.h b/libpthread/linuxthreads/sysdeps/x86_64/pt-machine.h
index 23615dbd8..0e0851e1e 100644
--- a/libpthread/linuxthreads/sysdeps/x86_64/pt-machine.h
+++ b/libpthread/linuxthreads/sysdeps/x86_64/pt-machine.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 _PT_MACHINE_H
#define _PT_MACHINE_H 1
diff --git a/libpthread/linuxthreads/sysdeps/x86_64/tls.h b/libpthread/linuxthreads/sysdeps/x86_64/tls.h
index 5e7239d17..24ed3fca9 100644
--- a/libpthread/linuxthreads/sysdeps/x86_64/tls.h
+++ b/libpthread/linuxthreads/sysdeps/x86_64/tls.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 _TLS_H
#define _TLS_H
diff --git a/libpthread/linuxthreads_db/.cvsignore b/libpthread/linuxthreads_db/.cvsignore
deleted file mode 100644
index e60a14bdf..000000000
--- a/libpthread/linuxthreads_db/.cvsignore
+++ /dev/null
@@ -1,5 +0,0 @@
-.cvsignore
-.svn
-*.os
-Makefile
-Makefile.in
diff --git a/libpthread/linuxthreads_db/Makefile.in b/libpthread/linuxthreads_db/Makefile.in
index a611c6ee0..52cc7c838 100644
--- a/libpthread/linuxthreads_db/Makefile.in
+++ b/libpthread/linuxthreads_db/Makefile.in
@@ -1,12 +1,14 @@
# 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.
#
+subdirs += libpthread/linuxthreads_db
+
# Get the thread include dependencies and shared object name
-CFLAGS-linuxthreads_db := -DNOT_IN_libc -DLIBPTHREAD_SO="\"libpthread.so.$(MAJOR_VERSION)\""
+CFLAGS-libpthread/linuxthreads_db := -DNOT_IN_libc -DLIBPTHREAD_SO="\"libpthread.so.$(ABI_VERSION)\""
LDFLAGS-libthread_db.so := $(LDFLAGS_NOSTRIP) $(if $(call check_ld,--warn-unresolved-symbols),-Wl$(comma)--warn-unresolved-symbols)
ifeq ($(DOSTRIP),y)
@@ -33,9 +35,6 @@ endif
lib-a-$(PTHREADS_DEBUG_SUPPORT) += $(top_builddir)lib/libthread_db.a
lib-so-$(PTHREADS_DEBUG_SUPPORT) += $(top_builddir)lib/libthread_db.so
-objclean-y += libthread_db_clean
-headers-$(PTHREADS_DEBUG_SUPPORT) += linuxthreads_db_headers
-headers_clean-y += linuxthreads_db_headers_clean
#ifeq ($(DOMULTI),n)
ifeq ($(DOPIC),y)
@@ -62,11 +61,18 @@ $(top_builddir)lib/libthread_db.a: $(libthread_db-a-y)
$(Q)$(RM) $@
$(do_ar)
-linuxthreads_db_headers:
- $(Q)$(LN) -sf ../$(PTDIR)_db/thread_db.h $(top_builddir)include/
+$(top_builddir)include/thread_db.h:
+ $(do_ln) $(call rel_srcdir)$(PTDIR)_db/$(@F) $@
+
+linuxthreads_db_headers := $(top_builddir)include/thread_db.h
+$(linuxthreads_db_headers): $(wildcard $(addprefix $(top_builddir)include/config/linuxthreads/,old.h new.h))
+headers-$(PTHREADS_DEBUG_SUPPORT) += $(linuxthreads_db_headers)
+
+objclean-y += CLEAN_libpthread/linuxthreads_db
+headers_clean-y += HEADERCLEAN_libpthread/linuxthreads_db
-linuxthreads_db_headers_clean:
- $(RM) $(top_builddir)include/thread_db.h
+HEADERCLEAN_libpthread/linuxthreads_db:
+ $(do_rm) $(linuxthreads_db_headers)
-libthread_db_clean:
- $(RM) $(libthread_db_OUT)/*.{o,os,oS,a}
+CLEAN_libpthread/linuxthreads_db:
+ $(do_rm) $(addprefix $(libthread_db_OUT)/*., o os oS a)
diff --git a/libpthread/linuxthreads_db/Makefile.old b/libpthread/linuxthreads_db/Makefile.old
index 53e46f775..014ddf835 100644
--- a/libpthread/linuxthreads_db/Makefile.old
+++ b/libpthread/linuxthreads_db/Makefile.old
@@ -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; see the file COPYING.LIB. If
+# not, see <http://www.gnu.org/licenses/>.
# Makefile for linuxthreads debug library subdirectory of GNU C Library.
diff --git a/libpthread/linuxthreads_db/proc_service.h b/libpthread/linuxthreads_db/proc_service.h
index 74136c03e..6f33ccdda 100644
--- a/libpthread/linuxthreads_db/proc_service.h
+++ b/libpthread/linuxthreads_db/proc_service.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/>. */
/* The definitions in this file must correspond to those in the debugger. */
#include <sys/procfs.h>
diff --git a/libpthread/linuxthreads_db/td_init.c b/libpthread/linuxthreads_db/td_init.c
index 66e9849bb..1edf53d3a 100644
--- a/libpthread/linuxthreads_db/td_init.c
+++ b/libpthread/linuxthreads_db/td_init.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads_db/td_log.c b/libpthread/linuxthreads_db/td_log.c
index 025273a63..c82ffa54d 100644
--- a/libpthread/linuxthreads_db/td_log.c
+++ b/libpthread/linuxthreads_db/td_log.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads_db/td_symbol_list.c b/libpthread/linuxthreads_db/td_symbol_list.c
index 599c04596..fd29333d5 100644
--- a/libpthread/linuxthreads_db/td_symbol_list.c
+++ b/libpthread/linuxthreads_db/td_symbol_list.c
@@ -14,19 +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 <assert.h>
#include "thread_dbP.h"
-#ifdef HAVE_ASM_GLOBAL_DOT_NAME
-# define DOT "." /* PPC64 requires . prefix on code symbols. */
-#else
-# define DOT /* No prefix. */
-#endif
-
static const char *symbol_list_arr[] =
{
[PTHREAD_THREADS_EVENTS] = "__pthread_threads_events",
@@ -37,9 +30,9 @@ static const char *symbol_list_arr[] =
[LINUXTHREADS_PTHREAD_THREADS_MAX] = "__linuxthreads_pthread_threads_max",
[LINUXTHREADS_PTHREAD_KEYS_MAX] = "__linuxthreads_pthread_keys_max",
[LINUXTHREADS_PTHREAD_SIZEOF_DESCR] = "__linuxthreads_pthread_sizeof_descr",
- [LINUXTHREADS_CREATE_EVENT] = DOT "__linuxthreads_create_event",
- [LINUXTHREADS_DEATH_EVENT] = DOT "__linuxthreads_death_event",
- [LINUXTHREADS_REAP_EVENT] = DOT "__linuxthreads_reap_event",
+ [LINUXTHREADS_CREATE_EVENT] = "__linuxthreads_create_event",
+ [LINUXTHREADS_DEATH_EVENT] = "__linuxthreads_death_event",
+ [LINUXTHREADS_REAP_EVENT] = "__linuxthreads_reap_event",
[LINUXTHREADS_INITIAL_REPORT_EVENTS] = "__linuxthreads_initial_report_events",
[LINUXTHREADS_VERSION] = "__linuxthreads_version",
[NUM_MESSAGES] = NULL
diff --git a/libpthread/linuxthreads_db/td_ta_clear_event.c b/libpthread/linuxthreads_db/td_ta_clear_event.c
index cbb7ddc97..d912e4478 100644
--- a/libpthread/linuxthreads_db/td_ta_clear_event.c
+++ b/libpthread/linuxthreads_db/td_ta_clear_event.c
@@ -14,17 +14,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 "thread_dbP.h"
td_err_e
-td_ta_clear_event (ta, event)
- const td_thragent_t *ta;
- td_thr_events_t *event;
+td_ta_clear_event(const td_thragent_t *ta, td_thr_events_t *event)
{
td_thr_events_t old_event;
int i;
diff --git a/libpthread/linuxthreads_db/td_ta_delete.c b/libpthread/linuxthreads_db/td_ta_delete.c
index 0e6ec17d0..9bc5c08ac 100644
--- a/libpthread/linuxthreads_db/td_ta_delete.c
+++ b/libpthread/linuxthreads_db/td_ta_delete.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/>. */
#include <stdlib.h>
@@ -45,7 +44,7 @@ td_ta_delete (td_thragent_t *ta)
runp = runp->next;
if (runp->next == NULL)
- /* It's not a valid decriptor since it is not in the list. */
+ /* It's not a valid descriptor since it is not in the list. */
return TD_BADTA;
runp->next = runp->next->next;
diff --git a/libpthread/linuxthreads_db/td_ta_enable_stats.c b/libpthread/linuxthreads_db/td_ta_enable_stats.c
index 1d4c34a8d..9d3408ece 100644
--- a/libpthread/linuxthreads_db/td_ta_enable_stats.c
+++ b/libpthread/linuxthreads_db/td_ta_enable_stats.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads_db/td_ta_event_addr.c b/libpthread/linuxthreads_db/td_ta_event_addr.c
index 8bce35ae8..72d426555 100644
--- a/libpthread/linuxthreads_db/td_ta_event_addr.c
+++ b/libpthread/linuxthreads_db/td_ta_event_addr.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads_db/td_ta_event_getmsg.c b/libpthread/linuxthreads_db/td_ta_event_getmsg.c
index c3a4492a1..c23d9264f 100644
--- a/libpthread/linuxthreads_db/td_ta_event_getmsg.c
+++ b/libpthread/linuxthreads_db/td_ta_event_getmsg.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/>. */
#include <stddef.h>
#include <string.h>
diff --git a/libpthread/linuxthreads_db/td_ta_get_nthreads.c b/libpthread/linuxthreads_db/td_ta_get_nthreads.c
index 839b56be5..144f4ffee 100644
--- a/libpthread/linuxthreads_db/td_ta_get_nthreads.c
+++ b/libpthread/linuxthreads_db/td_ta_get_nthreads.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads_db/td_ta_get_ph.c b/libpthread/linuxthreads_db/td_ta_get_ph.c
index 23d328508..fdf44fbe1 100644
--- a/libpthread/linuxthreads_db/td_ta_get_ph.c
+++ b/libpthread/linuxthreads_db/td_ta_get_ph.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads_db/td_ta_get_stats.c b/libpthread/linuxthreads_db/td_ta_get_stats.c
index 6bf2f5352..eca9ba5b4 100644
--- a/libpthread/linuxthreads_db/td_ta_get_stats.c
+++ b/libpthread/linuxthreads_db/td_ta_get_stats.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads_db/td_ta_map_id2thr.c b/libpthread/linuxthreads_db/td_ta_map_id2thr.c
index ddeb2d3c4..a90286865 100644
--- a/libpthread/linuxthreads_db/td_ta_map_id2thr.c
+++ b/libpthread/linuxthreads_db/td_ta_map_id2thr.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/>. */
#include "thread_dbP.h"
#include <linuxthreads/internals.h>
diff --git a/libpthread/linuxthreads_db/td_ta_map_lwp2thr.c b/libpthread/linuxthreads_db/td_ta_map_lwp2thr.c
index dd2fcbfe4..d8f2254fe 100644
--- a/libpthread/linuxthreads_db/td_ta_map_lwp2thr.c
+++ b/libpthread/linuxthreads_db/td_ta_map_lwp2thr.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/>. */
#include "thread_dbP.h"
#include <linuxthreads/internals.h>
diff --git a/libpthread/linuxthreads_db/td_ta_new.c b/libpthread/linuxthreads_db/td_ta_new.c
index 2b0b68bf0..7cf0edc66 100644
--- a/libpthread/linuxthreads_db/td_ta_new.c
+++ b/libpthread/linuxthreads_db/td_ta_new.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/>. */
#include <stddef.h>
#include <stdlib.h>
diff --git a/libpthread/linuxthreads_db/td_ta_reset_stats.c b/libpthread/linuxthreads_db/td_ta_reset_stats.c
index b3ddbd07b..ce41e1751 100644
--- a/libpthread/linuxthreads_db/td_ta_reset_stats.c
+++ b/libpthread/linuxthreads_db/td_ta_reset_stats.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads_db/td_ta_set_event.c b/libpthread/linuxthreads_db/td_ta_set_event.c
index 6edb38e57..25330b952 100644
--- a/libpthread/linuxthreads_db/td_ta_set_event.c
+++ b/libpthread/linuxthreads_db/td_ta_set_event.c
@@ -14,17 +14,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 "thread_dbP.h"
td_err_e
-td_ta_set_event (ta, event)
- const td_thragent_t *ta;
- td_thr_events_t *event;
+td_ta_set_event(const td_thragent_t *ta, td_thr_events_t *event)
{
td_thr_events_t old_event;
int i;
diff --git a/libpthread/linuxthreads_db/td_ta_setconcurrency.c b/libpthread/linuxthreads_db/td_ta_setconcurrency.c
index 408e76309..111dfd583 100644
--- a/libpthread/linuxthreads_db/td_ta_setconcurrency.c
+++ b/libpthread/linuxthreads_db/td_ta_setconcurrency.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads_db/td_ta_thr_iter.c b/libpthread/linuxthreads_db/td_ta_thr_iter.c
index 9ab04e14e..35a2e7834 100644
--- a/libpthread/linuxthreads_db/td_ta_thr_iter.c
+++ b/libpthread/linuxthreads_db/td_ta_thr_iter.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/>. */
#include "thread_dbP.h"
#include <linuxthreads/internals.h>
@@ -40,7 +39,7 @@ handle_descr (const td_thragent_t *ta, td_thr_iter_f *callback,
memset (&pds, '\0', sizeof (pds));
/* Empty thread descriptor the thread library would create. */
-#if !defined USE_TLS || !TLS_DTV_AT_TP
+#if !defined __UCLIBC_HAS_TLS__ || !TLS_DTV_AT_TP
pds.p_header.data.self = &pds;
#endif
pds.p_nextlive = pds.p_prevlive = &pds;
diff --git a/libpthread/linuxthreads_db/td_ta_tsd_iter.c b/libpthread/linuxthreads_db/td_ta_tsd_iter.c
index 2eb41f6a1..eb428bf12 100644
--- a/libpthread/linuxthreads_db/td_ta_tsd_iter.c
+++ b/libpthread/linuxthreads_db/td_ta_tsd_iter.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/>. */
#include "thread_dbP.h"
#include <linuxthreads/internals.h>
diff --git a/libpthread/linuxthreads_db/td_thr_clear_event.c b/libpthread/linuxthreads_db/td_thr_clear_event.c
index 147d18037..9674f9f0f 100644
--- a/libpthread/linuxthreads_db/td_thr_clear_event.c
+++ b/libpthread/linuxthreads_db/td_thr_clear_event.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/>. */
#include <stddef.h>
@@ -24,9 +23,7 @@
td_err_e
-td_thr_clear_event (th, event)
- const td_thrhandle_t *th;
- td_thr_events_t *event;
+td_thr_clear_event(const td_thrhandle_t *th, td_thr_events_t *event)
{
td_thr_events_t old_event;
int i;
diff --git a/libpthread/linuxthreads_db/td_thr_dbresume.c b/libpthread/linuxthreads_db/td_thr_dbresume.c
index 7b7f6eef9..3e63d8f41 100644
--- a/libpthread/linuxthreads_db/td_thr_dbresume.c
+++ b/libpthread/linuxthreads_db/td_thr_dbresume.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads_db/td_thr_dbsuspend.c b/libpthread/linuxthreads_db/td_thr_dbsuspend.c
index ef668023d..557e88862 100644
--- a/libpthread/linuxthreads_db/td_thr_dbsuspend.c
+++ b/libpthread/linuxthreads_db/td_thr_dbsuspend.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads_db/td_thr_event_enable.c b/libpthread/linuxthreads_db/td_thr_event_enable.c
index 407f3fc44..d55a2ce75 100644
--- a/libpthread/linuxthreads_db/td_thr_event_enable.c
+++ b/libpthread/linuxthreads_db/td_thr_event_enable.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/>. */
#include <stddef.h>
@@ -24,9 +23,7 @@
td_err_e
-td_thr_event_enable (th, onoff)
- const td_thrhandle_t *th;
- int onoff;
+td_thr_event_enable(const td_thrhandle_t *th, int onoff)
{
LOG ("td_thr_event_enable");
diff --git a/libpthread/linuxthreads_db/td_thr_event_getmsg.c b/libpthread/linuxthreads_db/td_thr_event_getmsg.c
index bf4ddd4ad..d4db08b6f 100644
--- a/libpthread/linuxthreads_db/td_thr_event_getmsg.c
+++ b/libpthread/linuxthreads_db/td_thr_event_getmsg.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/>. */
#include <stddef.h>
#include <string.h>
diff --git a/libpthread/linuxthreads_db/td_thr_get_info.c b/libpthread/linuxthreads_db/td_thr_get_info.c
index 4666bda97..c73f33020 100644
--- a/libpthread/linuxthreads_db/td_thr_get_info.c
+++ b/libpthread/linuxthreads_db/td_thr_get_info.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/>. */
#include <stddef.h>
#include <string.h>
diff --git a/libpthread/linuxthreads_db/td_thr_getfpregs.c b/libpthread/linuxthreads_db/td_thr_getfpregs.c
index 31c55c876..0fc22097e 100644
--- a/libpthread/linuxthreads_db/td_thr_getfpregs.c
+++ b/libpthread/linuxthreads_db/td_thr_getfpregs.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads_db/td_thr_getgregs.c b/libpthread/linuxthreads_db/td_thr_getgregs.c
index a9ec6a37d..a33789847 100644
--- a/libpthread/linuxthreads_db/td_thr_getgregs.c
+++ b/libpthread/linuxthreads_db/td_thr_getgregs.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads_db/td_thr_getxregs.c b/libpthread/linuxthreads_db/td_thr_getxregs.c
index 39cd73cf1..b98e19dd8 100644
--- a/libpthread/linuxthreads_db/td_thr_getxregs.c
+++ b/libpthread/linuxthreads_db/td_thr_getxregs.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads_db/td_thr_getxregsize.c b/libpthread/linuxthreads_db/td_thr_getxregsize.c
index 5d8ac288e..d7b4b13bb 100644
--- a/libpthread/linuxthreads_db/td_thr_getxregsize.c
+++ b/libpthread/linuxthreads_db/td_thr_getxregsize.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads_db/td_thr_set_event.c b/libpthread/linuxthreads_db/td_thr_set_event.c
index 1e1def511..31a04f1e6 100644
--- a/libpthread/linuxthreads_db/td_thr_set_event.c
+++ b/libpthread/linuxthreads_db/td_thr_set_event.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/>. */
#include <stddef.h>
@@ -24,9 +23,7 @@
td_err_e
-td_thr_set_event (th, event)
- const td_thrhandle_t *th;
- td_thr_events_t *event;
+td_thr_set_event(const td_thrhandle_t *th, td_thr_events_t *event)
{
td_thr_events_t old_event;
int i;
diff --git a/libpthread/linuxthreads_db/td_thr_setfpregs.c b/libpthread/linuxthreads_db/td_thr_setfpregs.c
index e4d9ec65e..793d02ed3 100644
--- a/libpthread/linuxthreads_db/td_thr_setfpregs.c
+++ b/libpthread/linuxthreads_db/td_thr_setfpregs.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads_db/td_thr_setgregs.c b/libpthread/linuxthreads_db/td_thr_setgregs.c
index 8c021a473..32e394b63 100644
--- a/libpthread/linuxthreads_db/td_thr_setgregs.c
+++ b/libpthread/linuxthreads_db/td_thr_setgregs.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads_db/td_thr_setprio.c b/libpthread/linuxthreads_db/td_thr_setprio.c
index 98d202dfe..554e8ffc9 100644
--- a/libpthread/linuxthreads_db/td_thr_setprio.c
+++ b/libpthread/linuxthreads_db/td_thr_setprio.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads_db/td_thr_setsigpending.c b/libpthread/linuxthreads_db/td_thr_setsigpending.c
index 98e30140e..c6729b4c0 100644
--- a/libpthread/linuxthreads_db/td_thr_setsigpending.c
+++ b/libpthread/linuxthreads_db/td_thr_setsigpending.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads_db/td_thr_setxregs.c b/libpthread/linuxthreads_db/td_thr_setxregs.c
index da77ab3b4..cb6b7e2fe 100644
--- a/libpthread/linuxthreads_db/td_thr_setxregs.c
+++ b/libpthread/linuxthreads_db/td_thr_setxregs.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads_db/td_thr_sigsetmask.c b/libpthread/linuxthreads_db/td_thr_sigsetmask.c
index 8b0eb8185..e990101d3 100644
--- a/libpthread/linuxthreads_db/td_thr_sigsetmask.c
+++ b/libpthread/linuxthreads_db/td_thr_sigsetmask.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/>. */
#include "thread_dbP.h"
diff --git a/libpthread/linuxthreads_db/td_thr_tls_get_addr.c b/libpthread/linuxthreads_db/td_thr_tls_get_addr.c
index c900cac8e..892acba6b 100644
--- a/libpthread/linuxthreads_db/td_thr_tls_get_addr.c
+++ b/libpthread/linuxthreads_db/td_thr_tls_get_addr.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/>. */
#include <link.h>
#include "thread_dbP.h"
@@ -27,7 +26,7 @@ td_thr_tls_get_addr (const td_thrhandle_t *th __attribute__ ((unused)),
size_t offset __attribute__ ((unused)),
void **address __attribute__ ((unused)))
{
-#if USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
/* Read the module ID from the link_map. */
size_t modid;
if (ps_pdread (th->th_ta_p->ph,
diff --git a/libpthread/linuxthreads_db/td_thr_tlsbase.c b/libpthread/linuxthreads_db/td_thr_tlsbase.c
index 5a7e31b9e..ac86c42fe 100644
--- a/libpthread/linuxthreads_db/td_thr_tlsbase.c
+++ b/libpthread/linuxthreads_db/td_thr_tlsbase.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 "thread_dbP.h"
@@ -30,15 +29,15 @@ td_thr_tlsbase (const td_thrhandle_t *th,
if (modid < 1)
return TD_NOTLS;
-#if USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
union dtv pdtv, *dtvp;
LOG ("td_thr_tlsbase");
psaddr_t dtvpp = th->th_unique;
-#if TLS_TCB_AT_TP
+#if defined(TLS_TCB_AT_TP)
dtvpp += offsetof (struct _pthread_descr_struct, p_header.data.dtvp);
-#elif TLS_DTV_AT_TP
+#elif defined(TLS_DTV_AT_TP)
/* Special case hack. If TLS_TCB_SIZE == 0 (on PowerPC), there is no TCB
containing the DTV at the TP, but actually the TCB lies behind the TP,
i.e. at the very end of the area covered by TLS_PRE_TCB_SIZE. */
diff --git a/libpthread/linuxthreads_db/td_thr_tsd.c b/libpthread/linuxthreads_db/td_thr_tsd.c
index 978dc5e52..7b0db6b9d 100644
--- a/libpthread/linuxthreads_db/td_thr_tsd.c
+++ b/libpthread/linuxthreads_db/td_thr_tsd.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/>. */
#include "thread_dbP.h"
#include <linuxthreads/internals.h>
diff --git a/libpthread/linuxthreads_db/td_thr_validate.c b/libpthread/linuxthreads_db/td_thr_validate.c
index 6f893d3f7..5108ea97d 100644
--- a/libpthread/linuxthreads_db/td_thr_validate.c
+++ b/libpthread/linuxthreads_db/td_thr_validate.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/>. */
#include "thread_dbP.h"
#include <linuxthreads/internals.h>
diff --git a/libpthread/linuxthreads_db/thread_db.h b/libpthread/linuxthreads_db/thread_db.h
index c115399a3..13c30af5b 100644
--- a/libpthread/linuxthreads_db/thread_db.h
+++ b/libpthread/linuxthreads_db/thread_db.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 _THREAD_DB_H
#define _THREAD_DB_H 1
diff --git a/libpthread/nptl/.gitignore b/libpthread/nptl/.gitignore
new file mode 100644
index 000000000..6565dcd83
--- /dev/null
+++ b/libpthread/nptl/.gitignore
@@ -0,0 +1,30 @@
+#
+# Never ignore these
+#
+!.gitignore
+#
+# Generated files
+#
+/pthread-errnos.h
+/gen_pthread-errnos.[cs]
+!sysdeps/pthread/tcb-offsets.h
+sysdeps/*/tcb-offsets.h
+sysdeps/*/gen_tcb-offsets.[cs]
+sysdeps/unix/sysv/linux/gen_*.[cs]
+sysdeps/unix/sysv/linux/lowlevelbarrier.h
+sysdeps/unix/sysv/linux/lowlevelcond.h
+sysdeps/unix/sysv/linux/lowlevelrwlock.h
+sysdeps/unix/sysv/linux/lowlevelrobustlock.h
+sysdeps/unix/sysv/linux/structsem.h
+sysdeps/unix/sysv/linux/unwindbuf.h
+sysdeps/unix/sysv/linux/pthread-pi-defines.h
+sysdeps/pthread/crt[in].S
+sysdeps/pthread/defs.h
+sysdeps/pthread/pt-initfini.s
+sysdeps/pthread/pt-crti.S
+sysdeps/pthread/pt-crtn.S
+#
+# symlinks
+#
+sysdeps/pthread/pt-sigfillset.c
+sysdeps/pthread/pt-sigprocmask.c
diff --git a/libpthread/nptl/ChangeLog b/libpthread/nptl/ChangeLog
new file mode 100644
index 000000000..ec22ebb64
--- /dev/null
+++ b/libpthread/nptl/ChangeLog
@@ -0,0 +1,11100 @@
+2010-01-15 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S:
+ Fix unwind info.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Likewise.
+
+2010-01-15 Michal Schmidt <mschmidt@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S:
+ Fix pthread_cond_timedwait with requeue-PI.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S:
+ Fix pthread_cond_wait with requeue-PI.
+
+2010-01-14 Ulrich Drepper <drepper@redhat.com>
+
+ * Versions: Add pthread_mutex_consistent, pthread_mutexattr_getrobust,
+ and pthread_mutexattr_setrobust for GLIBC_2.12.
+ * pthread_mutex_consistent.c: Define alias pthread_mutex_consistent.
+ * pthread_mutexattr_getrobust.c: Define alias
+ pthread_mutexattr_getrobust.
+ * pthread_mutexattr_setrobust.c: Define alias
+ pthread_mutexattr_setrobust.
+
+2010-01-12 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/pthread.h: Cleanup. Fix up for XPG7.
+
+2010-01-08 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/pthread.h: Fix pthread_mutex_consistent declaration.
+
+2009-12-18 Thomas Schwinge <thomas@codesourcery.com>
+
+ * sysdeps/unix/sysv/linux/s390/s390-32/pt-initfini.c (_init): Don't
+ call __gmon_start__.
+ * sysdeps/unix/sysv/linux/s390/s390-64/pt-initfini.c (_init): Likewise.
+
+2009-12-17 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_rwlock_init.c (__pthread_rwlock_init): Simplify code by
+ using memset.
+
+2009-12-01 Dinakar Guniguntala <dino@in.ibm.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevellock.h: Define
+ FUTEX_WAIT_REQUEUE_PI and FUTEX_CMP_REQUEUE_PI.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S: If mutex
+ is a non robust PI mutex, then use FUTEX_CMP_REQUEUE_PI.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: If mutex
+ is a non robust PI mutex, then use FUTEX_WAIT_REQUEUE_PI.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Likewise.
+
+2009-12-12 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S (sem_timedwait):
+ Don't update nwaiters after invalid timeout is recognized.
+
+2009-11-27 Thomas Schwinge <thomas@codesourcery.com>
+
+ * sysdeps/unix/sysv/linux/sh/pt-initfini.c (_init): Don't call
+ __gmon_start__.
+
+2009-11-27 Andreas Schwab <schwab@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/cancellation.S: Reload
+ THREAD_SELF->cancelhandling after returning from futex call.
+
+2009-11-24 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-sem13.c: New file.
+ * Makefile (tests): Add tst-sem13.
+
+2009-11-22 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/dl-sysdep.h: # include "i686/dl-sysdep.h"
+ instead of recapitulating its contents.
+
+2009-11-18 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S: Minor
+ optimizations and cleanups.
+
+2009-11-18 Dinakar Guniguntala <dino@in.ibm.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S:
+ Remove redundant code. Fix cfi offsets.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S:
+ Fix cfi offsets.
+
+2009-11-17 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Minimally
+ reduce size of unwind info.
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Convert to use
+ cfi directives.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Likewise.
+ Based on a patch by Dinakar Guniguntala <dino@in.ibm.com>.
+
+2009-11-03 Andreas Schwab <schwab@linux-m68k.org>
+
+ [BZ #4457]
+ * sysdeps/pthread/unwind-resume.c: Include <libgcc_s.h> and use
+ LIBGCC_S_SO.
+ * sysdeps/pthread/unwind-forcedunwind.c: Likewise.
+
+2009-10-30 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-sem11.c (main): Rewrite to avoid aliasing problems.
+
+ [BZ #3270]
+ * allocatestack.c (__nptl_setxid): Perform the operation in multiple
+ steps to avoid races with creation and terminations.
+ * nptl-init.c (sighandler_setxid): Adjust.
+ Patch by Daniel Jacobowitz.
+
+2009-09-07 Andreas Schwab <schwab@redhat.com>
+
+ * sysdeps/pthread/bits/libc-lock.h (BP_SYM): Remove space before paren.
+
+2009-09-02 Suzuki K P <suzuki@in.ibm.com>
+ Joseph Myers <joseph@codesourcery.com>
+
+ [BZ #7094]
+ * sysdeps/unix/sysv/linux/timer_create.c (timer_create):
+ Initialize the sigev_notify field for newly created timer to make sure
+ the timer gets deleted from the active timer's list upon timer_delete.
+
+2009-08-27 Andrew Stubbs <ams@codesourcery.com>
+
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.S (__lll_timedlock_wait):
+ Correct a logic error.
+
+2009-08-25 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/x86_64/tls.h (RTLD_ENABLE_FOREIGN_CALL): Store old value
+ of the field in local variables.
+ (RTLD_FINALIZE_FOREIGN_CALL): Restore rtld_must_xmm_save from local
+ variable and don't unconditionally clear it.
+
+2009-08-24 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_create.c (start_thread): Hint to the kernel that memory for
+ the stack can be reused. We do not mark all the memory. The part
+ still in use and some reserve are kept.
+
+2009-08-23 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/bits/posix_opt.h: Clean up namespace.
+
+2009-08-11 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S: Add CFI
+ directives.
+
+2009-08-10 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S: Add CFI
+ directives.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S: Likewise.
+
+2009-08-10 Andreas Schwab <schwab@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
+ (__pthread_cond_signal): Don't clobber register used for syscall
+ number.
+
+2009-08-08 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S (sem_timedwait):
+ Optimize code path used when FUTEX_CLOCK_REALTIME is supported.
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
+ (__pthread_cond_wait): Optimize by avoiding use of callee-safe
+ register.
+
+2009-08-07 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/sem_wait.S: Little optimizations
+ enabled by the special *_asynccancel functions.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Likewise.
+
+ * sysdeps/unix/sysv/linux/x86_64/cancellation.S: Include lowlevellock.h.
+
+2009-08-04 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/cancellation.S: New file.
+ * sysdeps/unix/sysv/linux/x86_64/libc-cancellation.S: New file.
+ * sysdeps/unix/sysv/linux/x86_64/librt-cancellation.S: New file.
+ * sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h (PSEUDO): Optimize
+ since we can assume the special __*_{en,dis}able_asynccancel
+ functions.
+ (PUSHARGS_*, POPARGS_*, SAVESTK_*, RESTSTK_*): Removed.
+ * sysdeps/x86_64/tcb-offsets.sym: Add cancellation-related bits
+ and PTHREAD_CANCELED.
+
+2009-07-31 Ulrich Drepper <drepper@redhat.com>
+
+ * descr.h: Better definition of *_BITMASK macros for cancellation.
+
+2009-07-29 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/x86_64/tls.h (TLS_TCB_ALIGN): Define explicitly to 32.
+
+ * sysdeps/x86_64/tls.h (tcbhead_t): Add room for SSE registers the
+ dynamic linker might have to save.
+ Define RTLD_CHECK_FOREIGN_CALL, RTLD_ENABLE_FOREIGN_CALL,
+ RTLD_PREPARE_FOREIGN_CALL, and RTLD_FINALIZE_FOREIGN_CALL. Pretty
+ printing.
+
+ * sysdeps/x86_64/tcb-offsets.sym: Add RTLD_SAVESPACE_SSE.
+
+2009-07-28 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_mutex_lock.c [NO_INCR] (__pthread_mutex_cond_lock_adjust):
+ New function.
+ * pthreadP.h: Declare __pthread_mutex_cond_lock_adjust.
+ * sysdeps/unix/sysv/linux/pthread-pi-defines.sym: Add ROBUST_BIT.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S: Don't use
+ requeue_pi for robust mutexes.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Likewise.
+ Don't only skip __pthread_mutex_cond_lock. Call instead
+ __pthread_mutex_cond_lock_adjust.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Likewise.
+
+ * pthread_mutex_unlock.c (__pthread_mutex_unlock_full): Minor
+ optimization of PI mutex handling.
+
+2009-07-27 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #10418]
+ * pthread_mutex_unlock.c (__pthread_mutex_unlock_full): Use _rel
+ instead of of _acq variants of cmpxchg.
+
+2009-07-23 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/x86_64/configure.in: New file.
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Fix error
+ path when not using absolute timeout futex.
+
+2009-07-20 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Minor
+ optimizations of last changes.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Likewise.
+
+2009-07-19 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Define
+ FUTEX_WAIT_REQUEUE_PI and FUTEX_CMP_REQUEUE_PI.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S: If mutex
+ is a PI mutex, then use FUTEX_CMP_REQUEUE_PI.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: If mutex
+ is a PI mutex, then use FUTEX_WAIT_REQUEUE_PI.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Likewise.
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
+ (__pthread_cond_timedwait): Make more robust.
+
+2009-07-18 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
+ (__lll_robust_timedlock_wait): If possible use FUTEX_WAIT_BITSET to
+ directly use absolute timeout.
+
+ * tst-sem5.c (do_test): Add test for premature timeout.
+ * Makefile: Linu tst-sem5 with librt.
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
+ (pthread_rwlock_timedwrlock): If possible use FUTEX_WAIT_BITSET to
+ directly use absolute timeout.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
+ (pthread_rwlock_timedrdlock): Likewise.
+
+ * tst-cond11.c (run_test): Add test to check that the timeout is
+ long enough.
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
+ (__pthread_cond_timedwait): If possible use FUTEX_WAIT_BITSET to
+ directly use absolute timeout.
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
+ (__pthread_cond_wait): Convert to using exception handler instead of
+ registered unwind buffer.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
+ (__pthread_cond_timedwait): Likewise.
+
+2009-07-17 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S (sem_timedwait):
+ If possible use FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME to directly
+ use absolute timeout.
+
+ * sysdeps/unix/sysv/linux/x86_64/sem_wait.S (sem_wait): Optimize
+ handling of uncontested semaphore.
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
+ (__condvar_cleanup): Rewrite to use cfi directives instead of
+ hand-coded unwind tables.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_once.S (__pthread_once):
+ Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sem_wait.S (sem_wait): Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S (sem_timedwait):
+ Likewise.
+
+2009-06-12 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (libpthread-routines): Add pthread_sigqueue.
+ * Versions: Add pthread_sigqueue for GLIBC_2.11.
+ * sysdeps/pthread/bits/sigthread.h: Declare pthread_sigqueue.
+ * sysdeps/unix/sysv/linux/pthread_sigqueue.c: New file.
+
+2009-06-11 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #10262]
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S
+ (LOAD_FUTEX_WAIT_ABS): Fix futex parameter in case private futexes
+ cannot be assumed.
+ Patch by Bryan Kadzban <bz-glibc@kdzbn.homelinux.net>.
+
+2009-05-16 Ulrich Drepper <drepper@redhat.com>
+
+ * libc-cancellation.c: Move __libc_cleanup_routine to...
+ * libc-cleanup.c: ...here. New file.
+ * Makefile (routines): Add libc-cleanup.
+
+ * cancellation.c (__pthread_disable_asynccancel): Remove unnecessary
+ test.
+ * libc-cancellation.c: Use <nptl/cancellation.c: to define the code.
+ * sysdeps/pthread/librt-cancellation.c: Likewise.
+
+ [BZ #9924]
+ * nptl-init.c: Renamed from init.c.
+ * Makefile: Change all occurences of init.c to nptl-init.c.
+
+2009-05-15 Ulrich Drepper <drepper@redhat.com>
+
+ * cancellation.c (__pthread_disable_asynccancel): Correct the bits
+ to test when deciding on the delay.
+ * libc-cancellation.c (__libc_disable_asynccancel): Likewise.
+ * pthread_cancel.c: Close race between deciding on sending a signal
+ and setting the CANCELING_BIT bit.
+
+ * cancellation.c (__pthread_disable_asynccancel): Don't return if
+ thread is canceled.
+ * libc-cancellation.c (__libc_disable_asynccancel): Likewise.
+
+2009-04-27 Ulrich Drepper <drepper@redhat.com>
+
+ * cancellation.c (__pthread_disable_asynccancel): Use THREAD_ATOMIC_AND
+ is available.
+ * libc-cancellation.c (__libc_disable_asynccancel): Likewise.
+ * sysdeps/x86_64/tls.h: Define THREAD_ATOMIC_AND.
+ * sysdeps/i386/tls.h: Likewise.
+ (tcbhead_t): Add __private_tm member.
+
+2009-04-26 Ulrich Drepper <drepper@redhat.com>
+
+ * sem_open.c (sem_open): Rewrite initialization of initsem to
+ avoid warnings.
+
+ * sysdeps/unix/sysv/linux/libc_pthread_init.c (__libc_pthread_init):
+ Avoid warning by using may_alias attribute on ptrhack.
+
+2009-04-22 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #10090]
+ * pthread_attr_setschedparam.c (__pthread_attr_setschedparam):
+ Check policy and priority for validity.
+ Patch mostly by Zhang Xiliang <zhangxiliang@cn.fujitsu.com>.
+
+2009-03-15 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
+ (__pthread_cond_timedwait): Change to use cfi directives instead of
+ hand-coded unwind sections.
+
+2009-03-10 Ulrich Drepper <drepper@redhat.com>
+
+ * init.c (nptl_freeres): Compile only for SHARED.
+
+2009-03-09 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/sparc/lowlevellock.h: Define
+ FUTEX_WAIT_BITSET, FUTEX_WAKE_BITSET, FUTEX_CLOCK_REALTIME and
+ FUTEX_BITSET_MATCH_ANY.
+
+2009-02-27 Roland McGrath <roland@redhat.com>
+
+ * init.c (__nptl_initial_report_events): Mark __attribute_used__.
+ * pthread_create.c (__nptl_threads_events, __nptl_last_event): Likewise.
+
+2009-02-26 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/bits/posix_opt.h: Define
+ _POSIX_THREAD_ROBUST_PRIO_INHERIT and
+ _POSIX_THREAD_ROBUST_PRIO_PROTECT. Reset value of macros from
+ 200112L to 200809L.
+
+2009-02-25 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/pthread.h: The robust mutex functions are in
+ POSIX 2008.
+
+2009-02-24 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/bits/posix_opt.h (_BITS_POSIX_OPT_H):
+ Unify name of include protector macro.
+
+2009-02-14 SUGIOKA Toshinobu <sugioka@itonet.co.jp>
+
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.S: Define
+ LOAD_FUTEX_WAIT_ABS even if (FUTEX_WAIT == 0).
+
+2009-01-29 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/unwind-forcedunwind.c: Encrypt all function
+ pointer variables.
+
+ * allocatestack.c (__free_stacks): Renamed from free_stacks.
+ (__free_stack_cache): Removed. Change callers to call __free_stacks.
+ * init.c (nptl_freeres): New function.
+ (pthread_functions): Initialize ptr_freeres to nptl_freeres.
+ * pthreadP.h: Don't declare __free_stack_cache. Declare __free_stacks.
+ * sysdeps/pthread/unwind-forcedunwind.c (libgcc_s_handle): New
+ variable.
+ (pthread_cancel_init): Depend in libgcc_s_handle for decision to
+ load DSO. Assign last.
+ (__unwind_freeres): New function.
+
+ * allocatestack.c (__reclaim_stacks): Reset in_flight_stack later
+ for better debugging. No need to use stack_list_add here.
+
+2009-01-14 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.S
+ (__lll_timedlock_wait): Use FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME
+ instead of computing relative timeout.
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.h: Define
+ FUTEX_CLOCK_REALTIME and FUTEX_BITSET_MATCH_ANY.
+
+2009-01-25 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_mutex_lock.c (__pthread_mutex_lock): Remove unused label out.
+
+2009-01-08 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/list.h (list_add): Initialize new element first.
+ (list_add_tail): Removed.
+
+2009-01-07 Ulrich Drepper <drepper@redhat.com>
+
+ * (in_flight_stack): New variable.
+ (stack_list_del): New function. Use instead of list_del.
+ (stack_list_add): New function. Use instead of list_add when adding to
+ stack_cache and stack_used lists.
+ (__reclaim_stacks): Complete operations on stack_cache and stack_used lists
+ when the fork call interrupted another thread.
+
+2009-01-04 Ulrich Drepper <drepper@redhat.com>
+
+ * init.c (__pthread_initialize_minimal_internal): Optimize test
+ FUTEX_CLOCK_REALTIME a bit.
+
+2009-01-03 Ulrich Drepper <drepper@redhat.com>
+
+ * init.c (__pthread_initialize_minimal_internal): Cheat a bit by
+ only passing five parameters to FUTEX_WAIT_BITSET call.
+
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S
+ (__lll_timedlock_wait): Use FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME
+ instead of computing relative timeout.
+
+2009-01-02 Ulrich Drepper <drepper@redhat.com>
+
+ * init.c (__pthread_initialize_minimal_internal): Check for
+ FUTEX_CLOCK_REALTIME flag.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.S (__lll_timedlock_wait):
+ Use FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME instead of computing
+ relative timeout.
+
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Define
+ FUTEX_CLOCK_REALTIME and FUTEX_BITSET_MATCH_ANY.
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/s390/lowlevellock.h: Likewise.
+
+2008-12-09 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/pthread.h (pthread_cleanup_pop): Use { } as empty
+ loop body instead of ; to avoid gcc warnings.
+ (pthread_cleanup_pop_restore_np): Likewise.
+ Patch by Caolán McNamara <caolanm@redhat.com>.
+
+2008-12-09 Jakub Jelinek <jakub@redhat.com>
+
+ * pthread_mutex_lock.c (__pthread_mutex_lock): Handle only the
+ fast path here, for robust/PI/PP mutexes call
+ __pthread_mutex_lock_full. Don't use switch, instead use a series
+ of ifs according to their probability.
+ (__pthread_mutex_lock_full): New function.
+ * pthread_mutex_unlock.c: Include assert.h.
+ (__pthread_mutex_unlock_usercnt): Handle only the
+ fast path here, for robust/PI/PP mutexes call
+ __pthread_mutex_unlock_full. Don't use switch, instead use a series
+ of ifs according to their probability.
+ (__pthread_mutex_unlock_full): New function.
+ * sysdeps/unix/sysv/linux/pthread_mutex_cond_lock.c
+ (__pthread_mutex_lock_full): Define.
+
+2008-12-08 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/x86_64/tls.h (tcbhead_t): Add fields reserved for TM
+ implementation. Add necessary padding and.
+ * descr.h (struct pthread): Increase padding for tcbhead_t to 24
+ words.
+
+2008-12-04 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.h: Define FUTEX_WAIT_BITSET
+ and FUTEX_WAKE_BITSET.
+
+2008-12-02 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h: Define FUTEX_WAIT_BITSET
+ and FUTEX_WAKE_BITSET.
+ * sysdeps/unix/sysv/linux/ia64/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/s390/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Likewise.
+
+2008-11-25 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/alpha, sysdeps/unix/sysv/linux/alpha:
+ Subdirectories moved to ports repository as
+ sysdeps/.../nptl subdirectories.
+
+2008-11-12 Jakub Jelinek <jakub@redhat.com>
+
+ [BZ #7008]
+ * pthread_condattr_setclock.c (pthread_condattr_setclock): Fix masking
+ of old value.
+ * pthread_cond_init.c (__pthread_cond_init): Fix
+ cond->__data.__nwaiters initialization.
+ * Makefile (tests): Add tst-cond23.
+ * tst-cond23.c: New test.
+
+2008-11-07 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/pthread/malloc-machine.h (MALLOC): Adjust __libc_tsd_define
+ arguments.
+ (tsd_setspecific, tsd_getspecific): Adjust __libc_tsd_{set,get}
+ arguments.
+
+2008-11-01 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #6955]
+ * pthread_mutex_lock.c: Add support for private PI mutexes.
+ * pthread_mutex_timedlock.c: Likewise.
+ * pthread_mutex_trylock.c: Likewise.
+ * pthread_mutex_unlock.c: Likewise.
+ Patch mostly by Ben Jackson <ben@ben.com>.
+
+2008-10-31 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #6843]
+ * sysdeps/pthread/gai_misc.h (__gai_create_helper_thread):
+ Increase stack size for helper thread.
+
+2008-10-06 Martin Schwidefsky <schwidefsky@de.ibm.com>
+
+ * sysdeps/s390/tls.h (THREAD_SET_STACK_GUARD): Add empty inline
+ assembly with a clobber list for access registers a0 and a1.
+
+2008-09-11 Martin Schwidefsky <schwidefsky@de.ibm.com>
+
+ * sysdeps/unix/sysv/linux/fork.c (__libc_fork): Add memory barrier
+ to force runp->refcntr to be read from memory.
+
+2008-09-08 Richard Guenther <rguenther@suse.de>
+
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h (lll_lock,
+ lll_robust_lock, lll_cond_lock, lll_robust_cond_lock,
+ lll_timedlock, lll_robust_timedlock, lll_unlock,
+ lll_robust_unlock): Promote private to int.
+
+2008-08-15 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/x86_64/pthreaddef.h: Remove ARCH_MAP_FLAGS and
+ ARCH_RETRY_MMAP definitions.
+ * allocatestack.c: Remove definition of ARCH_MAP_FLAGS.
+ Define MAP_STACK when not defined.
+ (allocate_stack): Use MAP_STACK instead of ARCH_MAP_FLAGS. Remove
+ handling of ARCH_RETRY_MMAP.
+
+2008-07-30 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-align2.c (f): Print message that f is reached.
+
+2008-04-28 Hiroki Kaminaga <kaminaga@sm.sony.co.jp>
+
+ [BZ #6740]
+ * sysdeps/powerpc/tcb-offsets.sym (PRIVATE_FUTEX_OFFSET): Guard symbol
+ definition with #ifndef __ASSUME_PRIVATE_FUTEX.
+
+2008-07-25 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/mq_notify.c (init_mq_netlink): Use
+ SOCK_CLOEXEC if possible.
+
+2008-05-29 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (tests): Add tst-rwlock2a.
+ * tst-rwlock2.c: Use TYPE macro to decide what rwlock type to use.
+ * tst-rwlock2a.c: New file.
+
+2008-06-12 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/pthread.h: Remove inadvertant checkin.
+
+2008-05-17 Samuel Thibault <samuel.thibault@ens-lyon.org>
+
+ * sysdeps/pthread/pthread.h: Fix typo in comment.
+
+2008-05-28 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/createthread.c (do_clone): Pass accurate length
+ of CPU set to the kernel.
+
+2008-05-23 Paul Pluzhnikov <ppluzhnikov@google.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_barrier_wait.S: Add
+ cfi directives.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_unlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_post.S: Likewise.
+
+2008-05-22 Paul Pluzhnikov <ppluzhnikov@google.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S: Add
+ cfi directives.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S:
+ Likewise.
+
+2008-05-26 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-typesizes.c: Explicitly check __SIZEOF_PTHREAD_* constants.
+
+2008-05-20 Jakub Jelinek <jakub@redhat.com>
+
+ David S. Miller <davem@davemloft.net>
+
+ * sysdeps/unix/sysv/linux/sparc/sparc64/Makefile: New file.
+
+2008-05-10 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S: Access
+ __pshared correctly.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_unlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S:
+ Likewise.
+ Reported by Clemens Kolbitsch <clemens.kol@gmx.at>.
+
+2008-04-14 David S. Miller <davem@davemloft.net>
+
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sem_wait.c
+ (__old_sem_wait): Fix argument to lll_futex_wait().
+
+2007-11-26 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * pthread_create.c: Require pthread_mutex_trylock and
+ pthread_key_delete for libgcc.
+
+2008-04-08 Jakub Jelinek <jakub@redhat.com>
+
+ [BZ #6020]
+ * sysdeps/unix/sysv/linux/sparc/lowlevellock.h
+ (lll_futex_wake_unlock): Add private argument to the pre-v9 macro.
+ Patch by Sunil Amitkumar Janki <devel.sjanki@gmail.com>.
+
+2008-03-27 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/bits/local_lim.h: Undefine ARG_MAX if
+ <linux/limits.h> has defined it.
+ * sysdeps/unix/sysv/linux/alpha/bits/local_lim.h: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/bits/local_lim.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/bits/local_lim.h: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/bits/local_lim.h: Likewise.
+
+2008-03-18 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/ia64/dl-sysdep.h: Use __ASSEMBLER__ instead
+ of ASSEMBLER.
+ * sysdeps/unix/sysv/linux/i386/i686/dl-sysdep.h: Likewise.
+ * sysdeps/unix/sysv/linux/i386/dl-sysdep.h: Likewise.
+
+2008-03-14 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/dl-sysdep.h: Define
+ HAVE_DL_DISCOVER_OSVERSION.
+ * sysdeps/unix/sysv/linux/i386/i686/dl-sysdep.h: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/dl-sysdep.h: Likewise.
+
+2008-03-07 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #5778]
+ * sysdeps/unix/sysv/linux/bits/posix_opt.h: Change
+ _POSIX_CHOWN_RESTRICTED value to zero.
+
+2008-01-31 Roland McGrath <roland@redhat.com>
+
+ * Makefile (omit-deps): Variable removed.
+
+2008-01-30 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/sem_post.S (sem_post): Avoid
+ unnecessary addr32 prefix.
+
+2008-01-29 Roland McGrath <roland@redhat.com>
+
+ * Makeconfig (ptw-CPPFLAGS, sysd-rules-patterns): New variables.
+
+2008-01-22 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/unix/sysv/linux/sh/sem_post.S: Don't overflow value field.
+
+2008-01-21 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/unix/sysv/linux/sh/lowlevel-atomic.h (XADD): Use
+ a scratch register.
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.S
+ (__lll_lock_wait_private): Fix typo.
+ * sysdeps/unix/sysv/linux/sh/pthread_barrier_wait.S
+ (pthread_barrier_wait): Likewise. Adjust XADD use.
+ * sysdeps/unix/sysv/linux/sh/sem_post.S (__new_sem_post):
+ Adjust XADD use.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedrdlock.S
+ (pthread_rwlock_timedrdlock): Return correct return value.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedwrlock.S
+ (pthread_rwlock_timedwrlock): Likewise.
+
+2008-01-15 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-eintr2.c (do_test): make sure that if mutex_lock in main
+ thread returns the program exits with an error code.
+
+2008-01-10 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread-errnos.sym: Add EOVERFLOW.
+ * sysdeps/unix/sysv/linux/structsem.sym: Add SEM_VALUE_MAX.
+ * sysdeps/unix/sysv/linux/sem_post.c: Don't overflow value field.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_post.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sem_post.S: Likewise.
+
+2007-12-14 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/x86_64/pthreaddef.h (ARCH_RETRY_MMAP): Take additional
+ parameter. Passed it as permission to mmap.
+ * allocatestack.c (allocate_stack): Pass prot as second parameter
+ to ARCH_RETRY_MMAP.
+
+2007-12-12 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-basic7.c: Allocate memory for the stack.
+
+ [BZ #5465]
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S [!SHARED]
+ (__pthread_cond_timedwait): Don't use VDSO.
+ Patch by Michal Januszewski.
+
+2007-12-07 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #5455]
+ * sysdeps/pthread/pthread.h [!__EXCEPTIONS] (pthread_cleanup_pop):
+ Allow label before pthread_cleanup_pop.
+ (pthread_cleanup_pop_restore_np): Likewise.
+
+2007-12-04 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.S (__lll_timedlock_wait):
+ Store 2 before returning ETIMEDOUT.
+
+2007-11-23 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.S (__lll_timedlock_wait):
+ Store 2 before returning ETIMEDOUT.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S: Likewise
+ * sysdeps/unix/sysv/linux/lowlevellock.c: Likewise.
+ (__lll_lock_wait_private): Optimize.
+ (__lll_lock_wait): Likewise.
+
+2007-11-20 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/pthread/pthread.h (pthread_cleanup_push,
+ pthread_cleanup_push_defer_np): Add extra (void *) cast to shut up
+ g++ 4.1 and 4.2 -Wstrict-aliasing warnings.
+
+2007-11-08 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #5240]
+ * sysdeps/unix/sysv/linux/lowlevellock.c (__lll_timedlock_wait):
+ If we time out, try one last time to lock the futex to avoid
+ losing a wakeup signal.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.S: Likewise.
+
+ [BZ #5245]
+ * sysdeps/pthread/createthread.c (do_clone): Translate clone error
+ if necessary.
+
+2007-11-07 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #5245]
+ * allocatestack.c (allocate_stack): Change ENOMEM error in case
+ mmap failed to EAGAIN.
+ * Makefile (tests): Add tst-basic7.
+ * tst-basic7.c: New file.
+
+2007-11-05 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/register-atfork.c (__register_atfork):
+ Use __linkin_atfork.
+
+2007-11-03 Mike Frysinger <vapier@gentoo.org>
+
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.S (LOAD_FUTEX_WAIT): Add
+ missing line continuations.
+ * sysdeps/unix/sysv/linux/sh/lowlevelrobustlock.S (LOAD_FUTEX_WAIT,
+ LOAD_FUTEX_WAKE): Likewise. Also add missing 3rd parameter.
+
+2007-10-28 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #5220]
+ * sysdeps/unix/sysv/linux/kernel-posix-timers.h: Declare
+ __active_timer_sigev_thread and __active_timer_sigev_thread_lock.
+ (struct timer): Add next element.
+ * sysdeps/unix/sysv/linux/timer_create.c: For SIGEV_THREAD timers,
+ enqueue timer structure into __active_timer_sigev_thread list.
+ * sysdeps/unix/sysv/linux/timer_delete.c: For SIGEV_THREAD timers,
+ remove timer struct from __active_timer_sigev_thread.
+ * sysdeps/unix/sysv/linux/timer_routines.c (timer_helper_thread):
+ Before using timer structure make sure it is still on the
+ __active_timer_sigev_thread list. Keep lock until done.
+ Define __active_timer_sigev_thread and
+ __active_timer_sigev_thread_lock.
+
+2007-10-27 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/malloc-machine.h: Define ATFORK_MEM.
+ Redefine thread_atfork for use of ATFORK_MEM.
+ * sysdeps/unix/sysv/linux/fork.h: Define __linkin_atfork.
+ * sysdeps/unix/sysv/linux/register-atfork.c (__linkin_atfork): New
+ function.
+ * sysdeps/unix/sysv/linux/unregister-atfork.c (__unregister_atfork):
+ Use atomic operation when removing first element of list.
+
+2007-10-17 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/sem_post.S (__old_sem_post): New
+ routine instead of an alias to __new_sem_post.
+
+2007-10-15 Jakub Jelinek <jakub@redhat.com>
+
+ * init.c (__pthread_initialize_minimal): Initialize word to appease
+ valgrind.
+
+2007-10-10 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/pthread/bits/libc-lock.h (__libc_rwlock_init): Inside of
+ libc.so just clear NAME.
+ (__libc_rwlock_fini): Nop inside of libc.so.
+ * tst-initializers1.c (main): Test if PTHREAD_RWLOCK_INITIALIZER is
+ all zeros.
+
+2007-09-02 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
+ (__pthread_cond_wait): Fix unlocking of internal lock after mutex
+ unlocking failed.
+ Patch by Luca Barbieri <luca.barbieri@gmail.com>.
+
+2007-08-21 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #4938]
+ * allocatestack.c (__reclaim_stacks): Clear the TSD in the
+ reclaimed stack if necessary.
+ * Makefile (tests): Add tst-tsd6.
+ * tst-tsd6.c: New file.
+
+2007-08-21 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/alpha/lowlevellock.h (lll_robust_dead):
+ Add private argument.
+
+2007-08-20 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
+ (__pthread_cond_timedwait): Use clock_gettime from VDSO if possible.
+
+2007-08-16 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/alpha/lowlevellock.h
+ (__lll_robust_timedlock): Pass private as last argument to
+ __lll_robust_timedlock_wait.
+ (__lll_unlock): Fix a pasto.
+
+2007-08-15 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/sparc/internaltypes.h (sparc_new_sem,
+ sparc_old_sem): New structs.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sem_wait.c
+ (__sem_wait_cleanup): New function.
+ (__new_sem_wait): Use sparc_new_sem structure. Bump and afterwards
+ decrease nwaiters. Register __sem_wait_cleanup as cleanup handler.
+ Pass isem->private ^ FUTEX_PRIVATE_FLAG as last argument to
+ lll_futex_wait.
+ (__old_sem_wait): New function.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/sem_wait.c: Include
+ nptl/sysdeps/unix/sysv/linux/sparc version.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/sem_timedwait.c:
+ Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/sem_post.c: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sem_trywait.c
+ (__new_sem_trywait): Use sparc_old_sem structure.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sem_timedwait.c
+ (sem_timedwait): Use sparc_new_sem structure. Bump and afterwards
+ decrease nwaiters. Register __sem_wait_cleanup as cleanup handler.
+ Pass isem->private ^ FUTEX_PRIVATE_FLAG as last argument to
+ lll_futex_timed_wait.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sem_post.c (__new_sem_post):
+ Use sparc_new_sem structure. Only wake if nwaiters > 0. Pass
+ isem->private ^ FUTEX_PRIVATE_FLAG as last argument to
+ lll_futex_wake.
+ (__old_sem_post): New function.
+ * sysdeps/unix/sysv/linux/sparc/sem_wait.c: New file.
+ * sysdeps/unix/sysv/linux/sparc/sem_init.c: New file.
+ * sysdeps/unix/sysv/linux/sparc/sem_timedwait.c: New file.
+ * sysdeps/unix/sysv/linux/sparc/sem_post.c: New file.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/sem_init.c: Remove.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sem_init.c: Remove.
+
+2007-08-14 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_broadcast.S
+ (__pthread_cond_broadcast): Pass LLL_PRIVATE to lll_* and or
+ FUTEX_PRIVATE_FLAG into SYS_futex op if cv is process private.
+ Don't use FUTEX_CMP_REQUEUE if dep_mutex is not process private.
+ * sysdeps/unix/sysv/linux/shpthread_cond_signal.S
+ (__pthread_cond_signal): Pass LLL_PRIVATE to lll_* and or
+ FUTEX_PRIVATE_FLAG into SYS_futex op if cv is process private.
+ Use FUTEX_WAKE_OP.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S: Include
+ kernel-features.h and tcb-offsets.h.
+ (__pthread_cond_wait, __condvar_w_cleanup): Pass LLL_PRIVATE to
+ lll_* and or FUTEX_PRIVATE_FLAG into SYS_futex op if cv is
+ process private.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S: Include
+ tcb-offsets.h.
+ (__pthread_cond_timedwait, __condvar_tw_cleanup): Pass LLL_PRIVATE
+ to lll_* and or FUTEX_PRIVATE_FLAG into SYS_futex op if cv is
+ process private.
+ * sysdeps/unix/sysv/linux/sh/pthread_once.S: Use #ifdef
+ __ASSUME_PRIVATE_FUTEX instead of #if __ASSUME_PRIVATE_FUTEX.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_rdlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedrdlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedwrlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_unlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_wrlock.S: Likewise.
+
+2007-08-14 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/lowlevellock.c: Comment fix.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/lowlevellock.c
+ (__lll_timedwait_tid): Pass LLL_SHARED as 4th argument to
+ lll_futex_timed_wait.
+
+ * sysdeps/unix/sysv/linux/alpha/lowlevellock.h (__lll_unlock,
+ __lll_robust_unlock): Rewrite as macros instead of inline functions.
+ * sysdeps/unix/sysv/linux/s390/lowlevellock.h (__lll_unlock,
+ __lll_robust_unlock, __lll_wait_tid): Likewise.
+
+2007-08-13 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h (__lll_private_flag):
+ Fix a pasto.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S
+ (__pthread_cond_broadcast): Pass LLL_PRIVATE to lll_* and or
+ FUTEX_PRIVATE_FLAG into SYS_futex op if cv is process private.
+ Don't use FUTEX_CMP_REQUEUE if dep_mutex is not process private.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S
+ (__pthread_cond_signal): Pass LLL_PRIVATE to lll_* and or
+ FUTEX_PRIVATE_FLAG into SYS_futex op if cv is process private.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Include
+ kernel-features.h.
+ (__pthread_cond_wait, __condvar_w_cleanup): Pass LLL_PRIVATE to
+ lll_* and or FUTEX_PRIVATE_FLAG into SYS_futex op if cv is
+ process private. Switch DW_CFA_advance_loc1 and some
+ DW_CFA_advance_loc .eh_frame opcodes to DW_CFA_advance_loc4.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S
+ (__pthread_cond_timedwait, __condvar_tw_cleanup): Pass LLL_PRIVATE to
+ lll_* and or FUTEX_PRIVATE_FLAG into SYS_futex op if cv is
+ process private. Switch DW_CFA_advance_loc{1,2} and some
+ DW_CFA_advance_loc .eh_frame opcodes to DW_CFA_advance_loc4.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S: Use
+ #ifdef __ASSUME_PRIVATE_FUTEX instead of #if __ASSUME_PRIVATE_FUTEX.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_unlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
+ (__pthread_cond_broadcast): Compare %r8 instead of
+ dep_mutex-cond_*(%rdi) with $-1.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
+ (__pthread_cond_signal): Xor FUTEX_WAKE_OP with FUTEX_WAKE instead
+ of oring.
+
+2007-08-13 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i786/Implies: New file.
+
+2007-08-13 Jakub Jelinek <jakub@redhat.com>
+
+ * allocatestack.c: Include kernel-features.h.
+ * pthread_create.c: Likewise.
+ * pthread_mutex_init.c: Likewise.
+ * init.c: Likewise.
+ * pthread_cond_timedwait.c: Likewise.
+ * sysdeps/unix/sysv/linux/alpha/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_unlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/s390/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S: Likewise.
+
+2007-08-12 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/sparc/bits/pthreadtypes.h
+ [__WORDSIZE=32] (pthread_rwlock_t): Split __flags element into four
+ byte elements. One of them is the new __shared element.
+ [__WORDSIZE=64] (pthread_rwlock_t): Renamed __pad1 element to __shared,
+ adjust names of other padding elements.
+ * sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h
+ [__WORDSIZE=32] (pthread_rwlock_t): Split __flags element into four
+ byte elements. One of them is the new __shared element.
+ [__WORDSIZE=64] (pthread_rwlock_t): Renamed __pad1 element to __shared,
+ adjust names of other padding elements.
+ * sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h (pthread_rwlock_t):
+ Renamed __pad1 element to __shared, adjust names of other padding
+ elements.
+ * sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h
+ (pthread_rwlock_t): Likewise.
+ * sysdeps/unix/sysv/linux/ia64/lowlevellock.h (__lll_lock): Fix a
+ typo.
+
+2007-08-09 Anton Blanchard <anton@samba.org>
+
+ * sysdeps/unix/sysv/linux/powerpc/pthread_spin_unlock.c: New file.
+
+2007-08-12 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Include
+ <kernel-features.h>.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Likewise.
+
+2007-08-11 Ulrich Drepper <drepper@redhat.com>
+
+ * pthreadP.h (PTHREAD_ROBUST_MUTEX_PSHARED): Define.
+ * pthread_mutex_lock.c: Use it instead of PTHREAD_MUTEX_PSHARED when
+ dealing with robust mutexes.
+ * pthread_mutex_timedlock.c: Likewise.
+ * pthread_mutex_trylock.c: Likewise.
+ * pthread_mutex_unlock.c: Likewise.
+ * sysdeps/unix/sysv/linux/pthread_mutex_cond_lock.c: Likewise.
+
+2007-08-06 Jakub Jelinek <jakub@redhat.com>
+
+ * pthreadP.h (PTHREAD_MUTEX_PSHARED_BIT): Define.
+ (PTHREAD_MUTEX_TYPE): Mask __kind with 127.
+ (PTHREAD_MUTEX_PSHARED): Define.
+ * pthread_mutex_init.c (__pthread_mutex_init): Set
+ PTHREAD_MUTEX_PSHARED_BIT for pshared or robust
+ mutexes.
+ * pthread_mutex_lock.c (LLL_MUTEX_LOCK): Take mutex as argument
+ instead of its __data.__lock field, pass PTHREAD_MUTEX_PSHARED
+ as second argument to lll_lock.
+ (LLL_MUTEX_TRYLOCK): Take mutex as argument
+ instead of its __data.__lock field.
+ (LLL_ROBUST_MUTEX_LOCK): Take mutex as argument instead of its
+ __data.__lock field, pass PTHREAD_MUTEX_PSHARED as second argument
+ to lll_robust_lock.
+ (__pthread_mutex_lock): Update LLL_MUTEX_LOCK, LLL_MUTEX_TRYLOCK,
+ LLL_ROBUST_MUTEX_LOCK users, use PTHREAD_MUTEX_TYPE (mutex)
+ instead of mutex->__data.__kind directly, pass
+ PTHREAD_MUTEX_PSHARED (mutex) to lll_unlock and lll_futex_wait.
+ * pthread_mutex_trylock.c (__pthread_mutex_trylock): Use
+ PTHREAD_MUTEX_TYPE (mutex) instead of mutex->__data.__kind
+ directly, pass PTHREAD_MUTEX_PSHARED (mutex) to lll_unlock.
+ (pthread_mutex_timedlock): Pass PTHREAD_MUTEX_PSHARED (mutex)
+ to lll_timedlock, lll_robust_timedlock, lll_unlock and
+ lll_futex_timed_wait. Use PTHREAD_MUTEX_TYPE (mutex) instead
+ of mutex->__data.__kind directly.
+ * pthread_mutex_timedlock.c (pthread_mutex_timedlock): Pass
+ PTHREAD_MUTEX_PSHARED (mutex) to lll_timedlock,
+ lll_robust_timedlock, lll_unlock and lll_futex_timed_wait. Use
+ PTHREAD_MUTEX_TYPE (mutex) instead of mutex->__data.__kind directly.
+ * pthread_mutex_unlock.c (__pthread_mutex_unlock_usercnt): Pass
+ PTHREAD_MUTEX_PSHARED (mutex) to lll_unlock, lll_robust_unlock
+ and lll_futex_wake.
+ * pthread_mutex_setprioceiling.c (pthread_mutex_setprioceiling): Pass
+ PTHREAD_MUTEX_PSHARED (mutex) to lll_futex_wait and lll_futex_wake.
+ Use PTHREAD_MUTEX_TYPE (mutex) instead of mutex->__data.__kind
+ directly.
+ * sysdeps/unix/sysv/linux/pthread_mutex_cond_lock.c (LLL_MUTEX_LOCK):
+ Take mutex as argument instead of its __data.__lock field, pass
+ PTHREAD_MUTEX_PSHARED as second argument to lll_cond_lock.
+ (LLL_MUTEX_TRYLOCK): Take mutex as argument instead of its
+ __data.__lock field.
+ (LLL_ROBUST_MUTEX_LOCK): Take mutex as argument instead of its
+ __data.__lock field, pass PTHREAD_MUTEX_PSHARED as second argument
+ to lll_robust_cond_lock.
+ * pthread_cond_broadcast.c (__pthread_cond_broadcast): Add pshared
+ variable, pass it to lll_lock, lll_unlock, lll_futex_requeue and
+ lll_futex_wake. Don't use lll_futex_requeue if dependent mutex
+ has PTHREAD_MUTEX_PSHARED_BIT bit set in its __data.__kind.
+ * pthread_cond_destroy.c (__pthread_cond_destroy): Add pshared
+ variable, pass it to lll_lock, lll_unlock, lll_futex_wake and
+ lll_futex_wait.
+ * pthread_cond_signal.c (__pthread_cond_signal): Add pshared
+ variable, pass it to lll_lock, lll_unlock, lll_futex_wake_unlock and
+ lll_futex_wake.
+ * pthread_cond_timedwait.c (__pthread_cond_wait): Add
+ pshared variable, pass it to lll_lock, lll_unlock,
+ lll_futex_timedwait and lll_futex_wake.
+ * pthread_cond_wait.c (__condvar_cleanup, __pthread_cond_wait): Add
+ pshared variable, pass it to lll_lock, lll_unlock, lll_futex_wait
+ and lll_futex_wake.
+ * sysdeps/unix/sysv/linux/alpha/lowlevellock.h (lll_futex_requeue,
+ lll_futex_wake_unlock): Add private argument, use __lll_private_flag
+ macro.
+ * sysdeps/unix/sysv/linux/ia64/lowlevellock.h (lll_futex_requeue,
+ lll_futex_wake_unlock): Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h (lll_futex_requeue):
+ Likewise.
+ * sysdeps/unix/sysv/linux/sparc/lowlevellock.h (lll_futex_requeue,
+ lll_futex_wake_unlock): Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h (lll_futex_requeue):
+ Likewise.
+ * sysdeps/unix/sysv/linux/s390/lowlevellock.h (lll_futex_requeue,
+ lll_futex_wake_unlock): Likewise.
+ (lll_futex_wake): Fix a typo.
+ * sysdeps/unix/sysv/linux/pthread-pi-defines.sym (PS_BIT): Add.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
+ (__pthread_cond_broadcast): Pass LLL_PRIVATE to lll_* and or
+ FUTEX_PRIVATE_FLAG into SYS_futex op if cv is process private.
+ Don't use FUTEX_CMP_REQUEUE if dep_mutex is not process private.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
+ (__pthread_cond_signal): Pass LLL_PRIVATE to lll_* and or
+ FUTEX_PRIVATE_FLAG into SYS_futex op if cv is process private.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
+ (__pthread_cond_timedwait): Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:
+ (__condvar_cleanup, __pthread_cond_wait): Likewise.
+
+2007-08-05 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h (PSEUDO):
+ Don't use CGOTSETUP and CGOTRESTORE macros.
+ (CGOTSETUP, CGOTRESTORE): Remove.
+ <IS_IN_rtld> (CENABLE, CDISABLE): Don't use JUMPTARGET, branch to
+ @local symbol.
+
+2007-08-01 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/unix/sysv/linux/sh/libc-lowlevellock.S: Remove
+ definitions for private futexes.
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.S: Include
+ kernel-features.h and lowlevellock.h. Use private futexes if
+ they are available.
+ (__lll_lock_wait_private, __lll_unlock_wake_private): New.
+ (__lll_mutex_lock_wait): Rename to
+ (__lll_lock_wait): ... this. Don't compile in for libc.so.
+ (__lll_mutex_timedlock_wait): Rename to ...
+ (__lll_timedlock_wait): ... this. Use __NR_gettimeofday.
+ Don't compile in for libc.so.
+ (__lll_mutex_unlock_wake): Rename to ...
+ (__lll_unlock_wake): ... this. Don't compile in for libc.so.
+ (__lll_timedwait_tid): Use __NR_gettimeofday.
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.h: Allow including
+ the header from assembler. Renamed all lll_mutex_* resp.
+ lll_robust_mutex_* macros to lll_* resp. lll_robust_*.
+ Renamed all LLL_MUTEX_LOCK_* macros to LLL_LOCK_*.
+ (FUTEX_CMP_REQUEUE, FUTEX_WAKE_OP, FUTEX_OP_CLEAR_WAKE_IF_GT_ONE):
+ Define.
+ (__lll_lock_wait_private): Add prototype.
+ (__lll_lock_wait, __lll_timedlock_wait, __lll_robust_lock_wait,
+ __lll_robust_timedlock_wait, __lll_unlock_wake_private,
+ __lll_unlock_wake): Likewise.
+ (lll_lock): Add private argument. Call __lll_lock_wait_private
+ if private is constant LLL_PRIVATE.
+ (lll_robust_lock, lll_cond_lock, lll_robust_cond_lock,
+ lll_timedlock, lll_robust_timedlock): Add private argument.
+ (lll_unlock): Add private argument. Call __lll_unlock_wake_private
+ if private is constant LLL_PRIVATE.
+ (lll_robust_unlock, lll_robust_dead): Add private argument.
+ (lll_lock_t): Remove.
+ (__lll_cond_wait, __lll_cond_timedwait, __lll_cond_wake,
+ __lll_cond_broadcast, lll_cond_wait, lll_cond_timedwait,
+ lll_cond_wake, lll_cond_broadcast): Remove.
+ * sysdeps/unix/sysv/linux/sh/lowlevelrobustlock.S: Include
+ kernel-features.h and lowlevellock.h.
+ (SYS_gettimeofday, SYS_futex, FUTEX_WAIT, FUTEX_WAKE): Remove.
+ (LOAD_FUTEX_WAIT): Define.
+ (__lll_robust_mutex_lock_wait): Rename to ...
+ (__lll_robust_lock_wait): ... this. Add private argument.
+ Use LOAD_FUTEX_WAIT macro.
+ (__lll_robust_mutex_timedlock_wait): Rename to ...
+ (__lll_robust_timedlock_wait): ... this. Add private argument.
+ Use __NR_gettimeofday. Use LOAD_FUTEX_WAIT macro.
+ * sysdeps/unix/sysv/linux/sh/pthread_barrier_wait.S: Include
+ lowlevellock.h.
+ (SYS_futex, FUTEX_WAIT, FUTEX_WAKE): Remove.
+ (pthread_barrier_wait): Use __lll_{lock,unlock}_* instead of
+ __lll_mutex_{lock,unlock}_*.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_broadcast.S: Include
+ lowlevellock.h and pthread-errnos.h.
+ (SYS_futex, FUTEX_WAIT, FUTEX_WAKE, FUTEX_REQUEUE,
+ FUTEX_CMP_REQUEUE, EINVAL): Remove.
+ (__pthread_cond_broadcast): Use __lll_{lock,unlock}_* instead of
+ __lll_mutex_{lock,unlock}_*.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_signal.S: Include
+ lowlevellock.h and pthread-errnos.h.
+ (SYS_futex, FUTEX_WAIT, FUTEX_WAKE, FUTEX_REQUEUE, EINVAL): Remove.
+ (__pthread_cond_signal): Use __lll_{lock,unlock}_* instead of
+ __lll_mutex_{lock,unlock}_*.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S: Include
+ lowlevellock.h.
+ (SYS_futex, SYS_gettimeofday, FUTEX_WAIT, FUTEX_WAKE): Remove.
+ (__pthread_cond_timedwait): Use __lll_{lock,unlock}_* instead of
+ __lll_mutex_{lock,unlock}_*. Use __NR_gettimeofday.
+ (__condvar_tw_cleanup): Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S: Include
+ lowlevellock.h.
+ (SYS_futex, FUTEX_WAIT, FUTEX_WAKE): Remove.
+ (__pthread_cond_wait): Use __lll_{lock,unlock}_* instead of
+ __lll_mutex_{lock,unlock}_*.
+ ( __condvar_w_cleanup): Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_once.S: Include lowlevellock.h.
+ (SYS_futex, FUTEX_WAIT, FUTEX_WAKE, FUTEX_PRIVATE_FLAG): Remove.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_rdlock.S: Include
+ lowlevellock.h.
+ (SYS_futex, FUTEX_WAIT, FUTEX_WAKE, FUTEX_PRIVATE_FLAG): Remove.
+ (__pthread_rwlock_rdlock): Use __lll_{lock,unlock}_* instead of
+ __lll_mutex_{lock,unlock}_*.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedrdlock.S: Include
+ lowlevellock.h.
+ (SYS_gettimeofday, SYS_futex, FUTEX_WAIT, FUTEX_WAKE,
+ FUTEX_PRIVATE_FLAG): Remove.
+ (pthread_rwlock_timedrdlock): Use __lll_{lock,unlock}_* instead of
+ __lll_mutex_{lock,unlock}_*. Use __NR_gettimeofday.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedwrlock.S: Include
+ lowlevellock.h.
+ (SYS_gettimeofday, SYS_futex, FUTEX_WAIT, FUTEX_WAKE,
+ FUTEX_PRIVATE_FLAG): Remove.
+ (pthread_rwlock_timedwrlock): Use __lll_{lock,unlock}_* instead of
+ __lll_mutex_{lock,unlock}_*. Use __NR_gettimeofday.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_unlock.S: Include
+ lowlevellock.h.
+ (SYS_futex, FUTEX_WAIT, FUTEX_WAKE, FUTEX_PRIVATE_FLAG): Remove.
+ (__pthread_rwlock_unlock): Use __lll_{lock,unlock}_* instead of
+ __lll_mutex_{lock,unlock}_*.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_wrlock.S: Include
+ lowlevellock.h.
+ (SYS_futex, FUTEX_WAIT, FUTEX_WAKE, FUTEX_PRIVATE_FLAG): Remove.
+ (__pthread_rwlock_wrlock): Use __lll_{lock,unlock}_* instead of
+ __lll_mutex_{lock,unlock}_*.
+ * sysdeps/unix/sysv/linux/sh/sem_post.S: Include lowlevellock.h.
+ (SYS_futex, FUTEX_WAIT, FUTEX_WAKE, FUTEX_PRIVATE_FLAG): Remove.
+ (__new_sem_post): Use standard initial exec code sequences.
+ * sysdeps/unix/sysv/linux/sh/sem_timedwait.S: Include
+ lowlevellock.h.
+ (SYS_gettimeofday, SYS_futex, FUTEX_WAIT, FUTEX_WAKE,
+ FUTEX_PRIVATE_FLAG): Remove.
+ (sem_timedwait): Use __NR_gettimeofday. Use standard initial
+ exec code sequences.
+ * sysdeps/unix/sysv/linux/sh/sem_trywait.S: Include lowlevellock.h.
+ (__new_sem_trywait): Use standard initial exec code sequences.
+ * sysdeps/unix/sysv/linux/sh/sem_wait.S: Include lowlevellock.h.
+ (__new_sem_wait): Use standard initial exec code sequences.
+
+2007-07-31 Anton Blanchard <anton@samba.org>
+
+ * sysdeps/unix/sysv/linux/powerpc/sem_post.c (__new_sem_post):
+ Use __asm __volatile (__lll_acq_instr ::: "memory") instead of
+ atomic_full_barrier.
+
+2007-07-31 Jakub Jelinek <jakub@redhat.com>
+
+ * allocatestack.c (stack_cache_lock): Change type to int.
+ (get_cached_stack, allocate_stack, __deallocate_stack,
+ __make_stacks_executable, __find_thread_by_id, __nptl_setxid,
+ __pthread_init_static_tls, __wait_lookup_done): Add LLL_PRIVATE
+ as second argument to lll_lock and lll_unlock macros on
+ stack_cache_lock.
+ * pthread_create.c (__find_in_stack_list): Likewise.
+ (start_thread): Similarly with pd->lock. Use lll_robust_dead
+ macro instead of lll_robust_mutex_dead, pass LLL_SHARED to it
+ as second argument.
+ * descr.h (struct pthread): Change lock and setxid_futex field
+ type to int.
+ * old_pthread_cond_broadcast.c (__pthread_cond_broadcast_2_0): Use
+ LLL_LOCK_INITIALIZER instead of LLL_MUTEX_LOCK_INITIALIZER.
+ * old_pthread_cond_signal.c (__pthread_cond_signal_2_0): Likewise.
+ * old_pthread_cond_timedwait.c (__pthread_cond_timedwait_2_0):
+ Likewise.
+ * old_pthread_cond_wait.c (__pthread_cond_wait_2_0): Likewise.
+ * pthread_cond_init.c (__pthread_cond_init): Likewise.
+ * pthreadP.h (__attr_list_lock): Change type to int.
+ * pthread_attr_init.c (__attr_list_lock): Likewise.
+ * pthread_barrier_destroy.c (pthread_barrier_destroy): Pass
+ ibarrier->private ^ FUTEX_PRIVATE_FLAG as second argument to
+ lll_{,un}lock.
+ * pthread_barrier_wait.c (pthread_barrier_wait): Likewise and
+ also for lll_futex_{wake,wait}.
+ * pthread_barrier_init.c (pthread_barrier_init): Make iattr
+ a pointer to const.
+ * pthread_cond_broadcast.c (__pthread_cond_broadcast): Pass
+ LLL_SHARED as second argument to lll_{,un}lock.
+ * pthread_cond_destroy.c (__pthread_cond_destroy): Likewise.
+ * pthread_cond_signal.c (__pthread_cond_singal): Likewise.
+ * pthread_cond_timedwait.c (__pthread_cond_timedwait): Likewise.
+ * pthread_cond_wait.c (__condvar_cleanup, __pthread_cond_wait):
+ Likewise.
+ * pthread_getattr_np.c (pthread_getattr_np): Add LLL_PRIVATE
+ as second argument to lll_{,un}lock macros on pd->lock.
+ * pthread_getschedparam.c (__pthread_getschedparam): Likewise.
+ * pthread_setschedparam.c (__pthread_setschedparam): Likewise.
+ * pthread_setschedprio.c (pthread_setschedprio): Likewise.
+ * tpp.c (__pthread_tpp_change_priority, __pthread_current_priority):
+ Likewise.
+ * sysdeps/pthread/createthread.c (do_clone, create_thread):
+ Likewise.
+ * pthread_once.c (once_lock): Change type to int.
+ (__pthread_once): Pass LLL_PRIVATE as second argument to
+ lll_{,un}lock macros on once_lock.
+ * pthread_rwlock_rdlock.c (__pthread_rwlock_rdlock): Use
+ lll_{,un}lock macros instead of lll_mutex_{,un}lock, pass
+ rwlock->__data.__shared as second argument to them and similarly
+ for lll_futex_w*.
+ * pthread_rwlock_timedrdlock.c (pthread_rwlock_timedrdlock):
+ Likewise.
+ * pthread_rwlock_timedwrlock.c (pthread_rwlock_timedwrlock):
+ Likewise.
+ * pthread_rwlock_tryrdlock.c (__pthread_rwlock_tryrdlock): Likewise.
+ * pthread_rwlock_trywrlock.c (__pthread_rwlock_trywrlock): Likewise.
+ * pthread_rwlock_unlock.c (__pthread_rwlock_unlock): Likewise.
+ * pthread_rwlock_wrlock.c (__pthread_rwlock_wrlock): Likewise.
+ * sem_close.c (sem_close): Pass LLL_PRIVATE as second argument
+ to lll_{,un}lock macros on __sem_mappings_lock.
+ * sem_open.c (check_add_mapping): Likewise.
+ (__sem_mappings_lock): Change type to int.
+ * semaphoreP.h (__sem_mappings_lock): Likewise.
+ * pthread_mutex_lock.c (LLL_MUTEX_LOCK, LLL_MUTEX_TRYLOCK,
+ LLL_ROBUST_MUTEX_LOCK): Use lll_{,try,robust_}lock macros
+ instead of lll_*mutex_*, pass LLL_SHARED as last
+ argument.
+ (__pthread_mutex_lock): Use lll_unlock instead of lll_mutex_unlock,
+ pass LLL_SHARED as last argument.
+ * sysdeps/unix/sysv/linux/pthread_mutex_cond_lock.c (LLL_MUTEX_LOCK,
+ LLL_MUTEX_TRYLOCK, LLL_ROBUST_MUTEX_LOCK): Use
+ lll_{cond_,cond_try,robust_cond}lock macros instead of lll_*mutex_*,
+ pass LLL_SHARED as last argument.
+ * pthread_mutex_timedlock.c (pthread_mutex_timedlock): Use
+ lll_{timed,try,robust_timed,un}lock instead of lll_*mutex*, pass
+ LLL_SHARED as last argument.
+ * pthread_mutex_trylock.c (__pthread_mutex_trylock): Similarly.
+ * pthread_mutex_unlock.c (__pthread_mutex_unlock_usercnt):
+ Similarly.
+ * sysdeps/pthread/bits/libc-lock.h (__libc_lock_lock,
+ __libc_lock_lock_recursive, __libc_lock_unlock,
+ __libc_lock_unlock_recursive): Pass LLL_PRIVATE as second
+ argument to lll_{,un}lock.
+ * sysdeps/pthread/bits/stdio-lock.h (_IO_lock_lock,
+ _IO_lock_unlock): Likewise.
+ * sysdeps/unix/sysv/linux/fork.c (__libc_fork): Don't use
+ compound literal.
+ * sysdeps/unix/sysv/linux/unregister-atfork.c (__unregister_atfork):
+ Pass LLL_PRIVATE as second argument to lll_{,un}lock macros on
+ __fork_lock.
+ * sysdeps/unix/sysv/linux/register-atfork.c (__register_atfork,
+ free_mem): Likewise.
+ (__fork_lock): Change type to int.
+ * sysdeps/unix/sysv/linux/fork.h (__fork_lock): Likewise.
+ * sysdeps/unix/sysv/linux/sem_post.c (__new_sem_post): Pass
+ isem->private ^ FUTEX_PRIVATE_FLAG as second argument to
+ lll_futex_wake.
+ * sysdeps/unix/sysv/linux/sem_timedwait.c (sem_timedwait): Likewise.
+ * sysdeps/unix/sysv/linux/sem_wait.c (__new_sem_wait): Likewise.
+ * sysdeps/unix/sysv/linux/lowlevellock.c (__lll_lock_wait_private):
+ New function.
+ (__lll_lock_wait, __lll_timedlock_wait): Add private argument and
+ pass it through to lll_futex_*wait, only compile in when
+ IS_IN_libpthread.
+ * sysdeps/unix/sysv/linux/lowlevelrobustlock.c
+ (__lll_robust_lock_wait, __lll_robust_timedlock_wait): Add private
+ argument and pass it through to lll_futex_*wait.
+ * sysdeps/unix/sysv/linux/alpha/lowlevellock.h: Renamed all
+ lll_mutex_* resp. lll_robust_mutex_* macros to lll_* resp.
+ lll_robust_*. Renamed all __lll_mutex_* resp. __lll_robust_mutex_*
+ inline functions to __lll_* resp. __lll_robust_*.
+ (LLL_MUTEX_LOCK_INITIALIZER): Remove.
+ (lll_mutex_dead): Add private argument.
+ (__lll_lock_wait_private): New prototype.
+ (__lll_lock_wait, __lll_robust_lock_wait, __lll_lock_timedwait,
+ __lll_robust_lock_timedwait): Add private argument to prototypes.
+ (__lll_lock): Add private argument, if it is constant LLL_PRIVATE,
+ call __lll_lock_wait_private, otherwise pass private to
+ __lll_lock_wait.
+ (__lll_robust_lock, __lll_cond_lock, __lll_timedlock,
+ __lll_robust_timedlock): Add private argument, pass it to
+ __lll_*wait functions.
+ (__lll_unlock): Add private argument, if it is constant LLL_PRIVATE,
+ call __lll_unlock_wake_private, otherwise pass private to
+ __lll_unlock_wake.
+ (__lll_robust_unlock): Add private argument, pass it to
+ __lll_robust_unlock_wake.
+ (lll_lock, lll_robust_lock, lll_cond_lock, lll_timedlock,
+ lll_robust_timedlock, lll_unlock, lll_robust_unlock): Add private
+ argument, pass it through to __lll_* inline function.
+ (__lll_mutex_unlock_force, lll_mutex_unlock_force): Remove.
+ (lll_lock_t): Remove.
+ (__lll_cond_wait, __lll_cond_timedwait, __lll_cond_wake,
+ __lll_cond_broadcast, lll_cond_wait, lll_cond_timedwait,
+ lll_cond_wake, lll_cond_broadcast): Remove.
+ * sysdeps/unix/sysv/linux/ia64/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/s390/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h: Allow including
+ the header from assembler. Renamed all lll_mutex_* resp.
+ lll_robust_mutex_* macros to lll_* resp. lll_robust_*.
+ (LOCK, FUTEX_CMP_REQUEUE, FUTEX_WAKE_OP,
+ FUTEX_OP_CLEAR_WAKE_IF_GT_ONE): Define.
+ (LLL_MUTEX_LOCK_INITIALIZER, LLL_MUTEX_LOCK_INITIALIZER_LOCKED,
+ LLL_MUTEX_LOCK_INITIALIZER_WAITERS): Remove.
+ (__lll_mutex_lock_wait, __lll_mutex_timedlock_wait,
+ __lll_mutex_unlock_wake, __lll_lock_wait, __lll_unlock_wake):
+ Remove prototype.
+ (__lll_trylock_asm, __lll_lock_asm_start, __lll_unlock_asm): Define.
+ (lll_robust_trylock, lll_cond_trylock): Use LLL_LOCK_INITIALIZER*
+ rather than LLL_MUTEX_LOCK_INITIALIZER* macros.
+ (lll_trylock): Likewise, use __lll_trylock_asm, pass
+ MULTIPLE_THREADS_OFFSET as another asm operand.
+ (lll_lock): Add private argument, use __lll_lock_asm_start, pass
+ MULTIPLE_THREADS_OFFSET as last asm operand, call
+ __lll_lock_wait_private if private is constant LLL_PRIVATE,
+ otherwise pass private as another argument to __lll_lock_wait.
+ (lll_robust_lock, lll_cond_lock, lll_robust_cond_lock,
+ lll_timedlock, lll_robust_timedlock): Add private argument, pass
+ private as another argument to __lll_*lock_wait call.
+ (lll_unlock): Add private argument, use __lll_unlock_asm, pass
+ MULTIPLE_THREADS_OFFSET as another asm operand, call
+ __lll_unlock_wake_private if private is constant LLL_PRIVATE,
+ otherwise pass private as another argument to __lll_unlock_wake.
+ (lll_robust_unlock): Add private argument, pass private as another
+ argument to __lll_unlock_wake.
+ (lll_robust_dead): Add private argument, use __lll_private_flag
+ macro.
+ (lll_islocked): Use LLL_LOCK_INITIALIZER instead of
+ LLL_MUTEX_LOCK_INITIALIZER.
+ (lll_lock_t): Remove.
+ (LLL_LOCK_INITIALIZER_WAITERS): Define.
+ (__lll_cond_wait, __lll_cond_timedwait, __lll_cond_wake,
+ __lll_cond_broadcast, lll_cond_wait, lll_cond_timedwait,
+ lll_cond_wake, lll_cond_broadcast): Remove.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S: Revert
+ 2007-05-2{3,9} changes.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S: Include
+ kernel-features.h and lowlevellock.h.
+ (LOAD_PRIVATE_FUTEX_WAIT): Define.
+ (LOAD_FUTEX_WAIT): Rewritten.
+ (LOCK, SYS_gettimeofday, SYS_futex, FUTEX_WAIT, FUTEX_WAKE): Don't
+ define.
+ (__lll_lock_wait_private, __lll_unlock_wake_private): New functions.
+ (__lll_mutex_lock_wait): Rename to ...
+ (__lll_lock_wait): ... this. Take futex addr from %edx instead of
+ %ecx, %ecx is now private argument. Don't compile in for libc.so.
+ (__lll_mutex_timedlock_wait): Rename to ...
+ (__lll_timedlock_wait): ... this. Use __NR_gettimeofday. %esi
+ contains private argument. Don't compile in for libc.so.
+ (__lll_mutex_unlock_wake): Rename to ...
+ (__lll_unlock_wake): ... this. %ecx contains private argument.
+ Don't compile in for libc.so.
+ (__lll_timedwait_tid): Use __NR_gettimeofday.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevelrobustlock.S: Include
+ kernel-features.h and lowlevellock.h.
+ (LOAD_FUTEX_WAIT): Define.
+ (LOCK, SYS_gettimeofday, SYS_futex, FUTEX_WAIT, FUTEX_WAKE): Don't
+ define.
+ (__lll_robust_mutex_lock_wait): Rename to ...
+ (__lll_robust_lock_wait): ... this. Futex addr is now in %edx
+ argument, %ecx argument contains private. Use LOAD_FUTEX_WAIT
+ macro.
+ (__lll_robust_mutex_timedlock_wait): Rename to ...
+ (__lll_robust_timedlock_wait): ... this. Use __NR_gettimeofday.
+ %esi argument contains private, use LOAD_FUTEX_WAIT macro.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_barrier_wait.S: Include
+ lowlevellock.h.
+ (SYS_futex, FUTEX_WAIT, FUTEX_WAKE, LOCK): Don't define.
+ (pthread_barrier_wait): Rename __lll_mutex_* to __lll_*, pass
+ PRIVATE(%ebx) ^ LLL_SHARED as private argument in %ecx to
+ __lll_lock_wait and __lll_unlock_wake, pass MUTEX(%ebx) address
+ to __lll_lock_wait in %edx.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S:
+ Include lowlevellock.h and pthread-errnos.h.
+ (SYS_futex, FUTEX_WAIT, FUTEX_WAKE, FUTEX_REQUEUE,
+ FUTEX_CMP_REQUEUE, EINVAL, LOCK): Don't define.
+ (__pthread_cond_broadcast): Rename __lll_mutex_* to __lll_*, pass
+ cond_lock address in %edx rather than %ecx to __lll_lock_wait,
+ pass LLL_SHARED in %ecx to both __lll_lock_wait and
+ __lll_unlock_wake.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S:
+ Include lowlevellock.h and pthread-errnos.h.
+ (SYS_futex, FUTEX_WAIT, FUTEX_WAKE, FUTEX_WAKE_OP,
+ FUTEX_OP_CLEAR_WAKE_IF_GT_ONE, EINVAL, LOCK): Don't define.
+ (__pthread_cond_signal): Rename __lll_mutex_* to __lll_*, pass
+ cond_lock address in %edx rather than %ecx to __lll_lock_wait,
+ pass LLL_SHARED in %ecx to both __lll_lock_wait and
+ __lll_unlock_wake.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S:
+ Include lowlevellock.h.
+ (SYS_futex, SYS_gettimeofday, FUTEX_WAIT, FUTEX_WAKE, LOCK):
+ Don't define.
+ (__pthread_cond_timedwait): Rename __lll_mutex_* to __lll_*, pass
+ cond_lock address in %edx rather than %ecx to __lll_lock_wait,
+ pass LLL_SHARED in %ecx to both __lll_lock_wait and
+ __lll_unlock_wake. Use __NR_gettimeofday.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S:
+ Include lowlevellock.h.
+ (SYS_futex, FUTEX_WAIT, FUTEX_WAKE, LOCK): Don't define.
+ (__pthread_cond_wait, __condvar_w_cleanup): Rename __lll_mutex_*
+ to __lll_*, pass cond_lock address in %edx rather than %ecx to
+ __lll_lock_wait, pass LLL_SHARED in %ecx to both __lll_lock_wait
+ and __lll_unlock_wake.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S:
+ Include lowlevellock.h.
+ (SYS_futex, FUTEX_WAIT, FUTEX_WAKE, LOCK): Don't define.
+ (__pthread_rwlock_rdlock): Rename __lll_mutex_* to __lll_*, pass
+ MUTEX(%ebx) address in %edx rather than %ecx to
+ __lll_lock_wait, pass PSHARED(%ebx) in %ecx to both __lll_lock_wait
+ and __lll_unlock_wake. Move return value from %ecx to %edx
+ register.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S:
+ Include lowlevellock.h.
+ (SYS_futex, SYS_gettimeofday, FUTEX_WAIT, FUTEX_WAKE, LOCK):
+ Don't define.
+ (__pthread_rwlock_wrlock): Rename __lll_mutex_* to __lll_*, pass
+ MUTEX(%ebp) address in %edx rather than %ecx to
+ __lll_lock_wait, pass PSHARED(%ebp) in %ecx to both __lll_lock_wait
+ and __lll_unlock_wake. Move return value from %ecx to %edx
+ register. Use __NR_gettimeofday.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S:
+ Include lowlevellock.h.
+ (SYS_futex, SYS_gettimeofday, FUTEX_WAIT, FUTEX_WAKE, LOCK):
+ Don't define.
+ (__pthread_rwlock_wrlock): Rename __lll_mutex_* to __lll_*, pass
+ MUTEX(%ebp) address in %edx rather than %ecx to
+ __lll_lock_wait, pass PSHARED(%ebp) in %ecx to both __lll_lock_wait
+ and __lll_unlock_wake. Move return value from %ecx to %edx
+ register. Use __NR_gettimeofday.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_unlock.S:
+ Include lowlevellock.h.
+ (SYS_futex, FUTEX_WAIT, FUTEX_WAKE, LOCK): Don't define.
+ (__pthread_rwlock_unlock): Rename __lll_mutex_* to __lll_*, pass
+ MUTEX(%edi) address in %edx rather than %ecx to
+ __lll_lock_wait, pass PSHARED(%edi) in %ecx to both __lll_lock_wait
+ and __lll_unlock_wake.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S:
+ Include lowlevellock.h.
+ (SYS_futex, FUTEX_WAIT, FUTEX_WAKE, LOCK): Don't define.
+ (__pthread_rwlock_wrlock): Rename __lll_mutex_* to __lll_*, pass
+ MUTEX(%ebx) address in %edx rather than %ecx to
+ __lll_lock_wait, pass PSHARED(%ebx) in %ecx to both __lll_lock_wait
+ and __lll_unlock_wake. Move return value from %ecx to %edx
+ register.
+ * sysdeps/unix/sysv/linux/i386/pthread_once.S: Include
+ lowlevellock.h.
+ (LOCK, SYS_futex, FUTEX_WAIT, FUTEX_WAKE, FUTEX_PRIVATE_FLAG): Don't
+ define.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_post.S: Include lowlevellock.h.
+ (LOCK, SYS_futex, FUTEX_WAKE): Don't define.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S: Include
+ lowlevellock.h.
+ (LOCK, SYS_futex, SYS_gettimeofday, FUTEX_WAIT): Don't define.
+ (sem_timedwait): Use __NR_gettimeofday.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_trywait.S: Include
+ lowlevellock.h.
+ (LOCK): Don't define.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_wait.S: Include
+ lowlevellock.h.
+ (LOCK, SYS_futex, FUTEX_WAIT): Don't define.
+ * sysdeps/unix/sysv/linux/powerpc/sem_post.c: Wake only when there
+ are waiters.
+ * sysdeps/unix/sysv/linux/x86_64/libc-lowlevellock.S: Revert
+ 2007-05-2{3,9} changes.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.S: Include
+ kernel-features.h and lowlevellock.h.
+ (LOAD_PRIVATE_FUTEX_WAIT): Define.
+ (LOAD_FUTEX_WAIT): Rewritten.
+ (LOCK, SYS_futex, FUTEX_WAIT, FUTEX_WAKE): Don't define.
+ (__lll_lock_wait_private, __lll_unlock_wake_private): New functions.
+ (__lll_mutex_lock_wait): Rename to ...
+ (__lll_lock_wait): ... this. %esi is now private argument.
+ Don't compile in for libc.so.
+ (__lll_mutex_timedlock_wait): Rename to ...
+ (__lll_timedlock_wait): ... this. %esi contains private argument.
+ Don't compile in for libc.so.
+ (__lll_mutex_unlock_wake): Rename to ...
+ (__lll_unlock_wake): ... this. %esi contains private argument.
+ Don't compile in for libc.so.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S: Include
+ kernel-features.h and lowlevellock.h.
+ (LOAD_FUTEX_WAIT): Define.
+ (LOCK, SYS_futex, FUTEX_WAIT, FUTEX_WAKE): Don't define.
+ (__lll_robust_mutex_lock_wait): Rename to ...
+ (__lll_robust_lock_wait): ... this. %esi argument contains private.
+ Use LOAD_FUTEX_WAIT macro.
+ (__lll_robust_mutex_timedlock_wait): Rename to ...
+ (__lll_robust_timedlock_wait): ... this. %esi argument contains
+ private, use LOAD_FUTEX_WAIT macro.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S: Include
+ lowlevellock.h.
+ (SYS_futex, FUTEX_WAIT, FUTEX_WAKE, LOCK): Don't define.
+ (pthread_barrier_wait): Rename __lll_mutex_* to __lll_*, pass
+ PRIVATE(%rdi) ^ LLL_SHARED as private argument in %esi to
+ __lll_lock_wait and __lll_unlock_wake.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S:
+ Include lowlevellock.h and pthread-errnos.h.
+ (SYS_futex, FUTEX_WAIT, FUTEX_WAKE, FUTEX_REQUEUE,
+ FUTEX_CMP_REQUEUE, EINVAL, LOCK): Don't define.
+ (__pthread_cond_broadcast): Rename __lll_mutex_* to __lll_*,
+ pass LLL_SHARED in %esi to both __lll_lock_wait and
+ __lll_unlock_wake.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S:
+ Include lowlevellock.h and pthread-errnos.h.
+ (SYS_futex, FUTEX_WAIT, FUTEX_WAKE, FUTEX_WAKE_OP,
+ FUTEX_OP_CLEAR_WAKE_IF_GT_ONE, EINVAL, LOCK): Don't define.
+ (__pthread_cond_signal): Rename __lll_mutex_* to __lll_*,
+ pass LLL_SHARED in %esi to both __lll_lock_wait and
+ __lll_unlock_wake.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:
+ Include lowlevellock.h.
+ (SYS_futex, FUTEX_WAIT, FUTEX_WAKE, LOCK): Don't define.
+ (__pthread_cond_timedwait): Rename __lll_mutex_* to __lll_*,
+ pass LLL_SHARED in %esi to both __lll_lock_wait and
+ __lll_unlock_wake.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:
+ Include lowlevellock.h.
+ (SYS_futex, FUTEX_WAIT, FUTEX_WAKE, LOCK): Don't define.
+ (__pthread_cond_wait, __condvar_cleanup): Rename __lll_mutex_*
+ to __lll_*, pass LLL_SHARED in %esi to both __lll_lock_wait
+ and __lll_unlock_wake.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S:
+ Include lowlevellock.h.
+ (SYS_futex, FUTEX_WAIT, FUTEX_WAKE, FUTEX_PRIVATE_FLAG, LOCK):
+ Don't define.
+ (__pthread_rwlock_rdlock): Rename __lll_mutex_* to __lll_*,
+ pass PSHARED(%rdi) in %esi to both __lll_lock_wait
+ and __lll_unlock_wake.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S:
+ Include lowlevellock.h.
+ (SYS_futex, FUTEX_WAIT, FUTEX_WAKE, FUTEX_PRIVATE_FLAG, LOCK):
+ Don't define.
+ (__pthread_rwlock_wrlock): Rename __lll_mutex_* to __lll_*,
+ pass PSHARED(%rdi) in %esi to both __lll_lock_wait
+ and __lll_unlock_wake.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S:
+ Include lowlevellock.h.
+ (SYS_futex, FUTEX_WAIT, FUTEX_WAKE, FUTEX_PRIVATE_FLAG, LOCK):
+ Don't define.
+ (__pthread_rwlock_wrlock): Rename __lll_mutex_* to __lll_*,
+ pass PSHARED(%rdi) in %esi to both __lll_lock_wait
+ and __lll_unlock_wake.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S:
+ Include lowlevellock.h.
+ (SYS_futex, FUTEX_WAIT, FUTEX_WAKE, FUTEX_PRIVATE_FLAG, LOCK):
+ Don't define.
+ (__pthread_rwlock_unlock): Rename __lll_mutex_* to __lll_*,
+ pass PSHARED(%rdi) in %esi to both __lll_lock_wait
+ and __lll_unlock_wake.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S:
+ Include lowlevellock.h.
+ (SYS_futex, FUTEX_WAIT, FUTEX_WAKE, FUTEX_PRIVATE_FLAG, LOCK):
+ Don't define.
+ (__pthread_rwlock_wrlock): Rename __lll_mutex_* to __lll_*,
+ pass PSHARED(%rdi) in %ecx to both __lll_lock_wait
+ and __lll_unlock_wake.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_once.S: Include
+ lowlevellock.h.
+ (LOCK, SYS_futex, FUTEX_WAIT, FUTEX_WAKE, FUTEX_PRIVATE_FLAG): Don't
+ define.
+ * sysdeps/unix/sysv/linux/x86_64/sem_post.S: Include lowlevellock.h.
+ (LOCK, SYS_futex, FUTEX_WAKE): Don't define.
+ * sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S: Include
+ lowlevellock.h.
+ (LOCK, SYS_futex, FUTEX_WAIT): Don't define.
+ * sysdeps/unix/sysv/linux/x86_64/sem_trywait.S: Include
+ lowlevellock.h.
+ (LOCK): Don't define.
+ * sysdeps/unix/sysv/linux/x86_64/sem_wait.S: Include
+ lowlevellock.h.
+ (LOCK, SYS_futex, FUTEX_WAIT): Don't define.
+ * sysdeps/unix/sysv/linux/sparc/internaltypes.h: New file.
+ * sysdeps/unix/sysv/linux/sparc/pthread_barrier_destroy.c: New file.
+ * sysdeps/unix/sysv/linux/sparc/pthread_barrier_init.c: New file.
+ * sysdeps/unix/sysv/linux/sparc/pthread_barrier_wait.c: New file.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/lowlevellock.c
+ (__lll_lock_wait_private): New function.
+ (__lll_lock_wait, __lll_timedlock_wait): Add private argument, pass
+ it to lll_futex_*wait. Don't compile in for libc.so.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/pthread_barrier_init.c:
+ Remove.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/pthread_barrier_wait.c
+ (struct sparc_pthread_barrier): Remove.
+ (pthread_barrier_wait): Use union sparc_pthread_barrier instead of
+ struct sparc_pthread_barrier. Pass
+ ibarrier->s.pshared ? LLL_SHARED : LLL_PRIVATE to lll_{,un}lock
+ and lll_futex_wait macros.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/pthread_barrier_init.c:
+ Remove.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/pthread_barrier_wait.c:
+ Include sparc pthread_barrier_wait.c instead of generic one.
+
+2007-07-30 Jakub Jelinek <jakub@redhat.com>
+
+ * tst-rwlock14.c (do_test): Avoid warnings on 32-bit arches.
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S
+ (pthread_rwlock_timedrdlock): Copy futex retval to %esi rather than
+ %ecx.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S
+ (pthread_rwlock_timedwrlock): Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_unlock.S
+ (__pthread_rwlock_unlock): Fix MUTEX != 0 args to __lll_*.
+
+2007-07-31 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/sparc/tls.h (tcbhead_t): Add private_futex field.
+
+2007-07-26 Jakub Jelinek <jakub@redhat.com>
+
+ * tst-locale2.c (useless): Add return statement.
+
+2007-07-24 Jakub Jelinek <jakub@redhat.com>
+
+ * allocatestack.c (__nptl_setxid, __wait_lookup_done): Replace
+ lll_private_futex_* (*) with lll_futex_* (*, LLL_PRIVATE).
+ * pthread_create.c (start_thread): Likewise.
+ * init.c (sighandler_setxid): Likewise.
+ * sysdeps/alpha/tls.h (THREAD_GSCOPE_RESET_FLAG): Likewise.
+ * sysdeps/ia64/tls.h (THREAD_GSCOPE_RESET_FLAG): Likewise.
+ * sysdeps/i386/tls.h (THREAD_GSCOPE_RESET_FLAG): Likewise.
+ * sysdeps/s390/tls.h (THREAD_GSCOPE_RESET_FLAG): Likewise.
+ * sysdeps/powerpc/tls.h (THREAD_GSCOPE_RESET_FLAG): Likewise.
+ * sysdeps/x86_64/tls.h (THREAD_GSCOPE_RESET_FLAG): Likewise.
+ * sysdeps/sparc/tls.h (THREAD_GSCOPE_RESET_FLAG): Likewise.
+ * sysdeps/sh/tls.h (THREAD_GSCOPE_RESET_FLAG): Likewise.
+ * sysdeps/pthread/aio_misc.h (AIO_MISC_NOTIFY, AIO_MISC_WAIT):
+ Likewise.
+ * sysdeps/pthread/gai_misc.h (GAI_MISC_NOTIFY, GAI_MISC_WAIT):
+ Likewise.
+ * sysdeps/unix/sysv/linux/unregister-atfork.c (__unregister_atfork):
+ Likewise.
+ * sysdeps/unix/sysv/linux/rtld-lowlevel.h (__rtld_waitzero,
+ __rtld_notify): Likewise.
+ * sysdeps/unix/sysv/linux/fork.c (__libc_fork): Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/pthread_once.c (clear_once_control,
+ __pthread_once): Likewise.
+ * sysdeps/unix/sysv/linux/alpha/pthread_once.c (clear_once_control,
+ __pthread_once): Add LLL_PRIVATE as last argument to lll_futex_*.
+ * sysdeps/unix/sysv/linux/alpha/lowlevellock.h (FUTEX_PRIVATE_FLAG,
+ LLL_PRIVATE, LLL_SHARED, __lll_private_flag): Define.
+ (lll_futex_wait): Add private argument, define as wrapper around
+ lll_futex_timed_wait.
+ (lll_futex_timed_wait, lll_futex_wake): Add private argument,
+ use __lll_private_flag macro.
+ (lll_robust_mutex_dead, __lll_mutex_unlock, __lll_robust_mutex_unlock,
+ __lll_mutex_unlock_force): Pass LLL_SHARED as last arg to lll_futex_*.
+ * sysdeps/unix/sysv/linux/ia64/pthread_once.c (clear_once_control,
+ __pthread_once): Add LLL_PRIVATE as last argument to lll_futex_*.
+ * sysdeps/unix/sysv/linux/ia64/lowlevellock.h (FUTEX_PRIVATE_FLAG,
+ LLL_PRIVATE, LLL_SHARED, __lll_private_flag): Define.
+ (lll_futex_wait): Add private argument, define as wrapper around
+ lll_futex_timed_wait.
+ (lll_futex_timed_wait, lll_futex_wake): Add private argument,
+ use __lll_private_flag macro.
+ (__lll_mutex_unlock, __lll_robust_mutex_unlock, lll_wait_tid,
+ __lll_mutex_unlock_force): Pass LLL_SHARED as last arg to lll_futex_*.
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h (__lll_private_flag):
+ Define.
+ (lll_futex_timed_wait, lll_futex_wake): Use it.
+ (lll_private_futex_wait, lll_private_futex_timed_wait,
+ lll_private_futex_wake): Removed.
+ * sysdeps/unix/sysv/linux/s390/pthread_once.c (clear_once_control,
+ __pthread_once): Add LLL_PRIVATE as last argument to lll_futex_*.
+ * sysdeps/unix/sysv/linux/s390/lowlevellock.h (FUTEX_PRIVATE_FLAG,
+ LLL_PRIVATE, LLL_SHARED, __lll_private_flag): Define.
+ (lll_futex_wait): Add private argument, define as wrapper around
+ lll_futex_timed_wait.
+ (lll_futex_timed_wait, lll_futex_wake): Add private argument,
+ use __lll_private_flag macro.
+ (lll_robust_mutex_dead, __lll_mutex_unlock, __lll_robust_mutex_unlock,
+ lll_wait_tid, __lll_mutex_unlock_force): Pass LLL_SHARED as last arg
+ to lll_futex_*.
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h
+ (lll_private_futex_wait, lll_private_futex_timed_wait,
+ lll_private_futex_wake): Removed.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h (__lll_private_flag):
+ Fix !__ASSUME_PRIVATE_FUTEX non-constant private case.
+ (lll_private_futex_wait, lll_private_futex_timed_wait,
+ lll_private_futex_wake): Removed.
+ * sysdeps/unix/sysv/linux/sparc/pthread_once.c (clear_once_control,
+ __pthread_once): Add LLL_PRIVATE as last argument to lll_futex_*.
+ * sysdeps/unix/sysv/linux/sparc/lowlevellock.h (FUTEX_PRIVATE_FLAG,
+ LLL_PRIVATE, LLL_SHARED, __lll_private_flag): Define.
+ (lll_futex_wait): Add private argument, define as wrapper around
+ lll_futex_timed_wait.
+ (lll_futex_timed_wait, lll_futex_wake): Add private argument,
+ use __lll_private_flag macro.
+ (lll_robust_mutex_dead, __lll_mutex_unlock, __lll_robust_mutex_unlock,
+ lll_wait_tid, __lll_mutex_unlock_force): Pass LLL_SHARED as last arg
+ to lll_futex_*.
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.h (__lll_private_flag):
+ Define.
+ (lll_futex_timed_wait, lll_futex_wake): Use it.
+ (lll_private_futex_wait, lll_private_futex_timed_wait,
+ lll_private_futex_wake): Removed.
+
+2007-07-27 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/sparc/tls.h (tcbhead_t): Move gscope_flag to the end
+ of the structure for sparc32.
+
+2007-07-26 Aurelien Jarno <aurelien@aurel32.net>
+
+ * sysdeps/sparc/tls.h (tcbhead_t): Add gscope_flag.
+
+2007-07-23 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S: Fix
+ code used when private futexes are assumed.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S:
+ Likewise.
+
+2007-07-23 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h
+ (__lll_private_flag): Define.
+ (lll_futex_wait): Define as a wrapper around lll_futex_timed_wait.
+ (lll_futex_timed_wait, lll_futex_wake, lll_futex_wake_unlock): Use
+ __lll_private_flag.
+ (lll_private_futex_wait, lll_private_futex_timedwait,
+ lll_private_futex_wake): Define as wrapper around non-_private
+ macros.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
+ (__lll_private_flag): Define.
+ (lll_futex_timed_wait, lll_futex_wake): Use __lll_private_flag.
+ (lll_private_futex_wait, lll_private_futex_timedwait,
+ lll_private_futex_wake): Define as wrapper around non-_private
+ macros.
+
+2007-07-10 Steven Munroe <sjmunroe@us.ibm.com>
+
+ * pthread_rwlock_rdlock.c (__pthread_rwlock_rdlock): Add LLL_SHARED
+ parameter to lll_futex_wait call.
+ * pthread_rwlock_wrlock.c (__pthread_rwlock_wrlock): Likewise.
+
+ * sysdeps/unix/sysv/linux/powerpc/pthread_once.c (__pthread_once):
+ Replace lll_futex_wait with lll_private_futex_wait.
+ * sysdeps/unix/sysv/linux/powerpc/sem_post.c (__new_sem_post):
+ Add LLL_SHARED parameter to lll_futex_wake().
+
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h: Define LLL_PRIVATE
+ LLL_SHARED, lll_private_futex_wait, lll_private_futex_timed_wait and
+ lll_private_futex_wake.
+ (lll_futex_wait): Add private parameter. Adjust FUTEX_PRIVATE_FLAG
+ bit from private parm before syscall.
+ (lll_futex_timed_wait): Likewise.
+ (lll_futex_wake): Likewise.
+ (lll_futex_wake_unlock): Likewise.
+ (lll_mutex_unlock): Add LLL_SHARED parm to lll_futex_wake call.
+ (lll_robust_mutex_unlock): Likewise.
+ (lll_mutex_unlock_force): Likewise.
+ (lll_wait_tid): Add LLL_SHARED parm to lll_futex_wait call.
+
+2007-07-23 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S: Fix
+ compilation when unconditionally using private futexes.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S: Likewise.
+
+2007-07-17 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/pthread/bits/stdio-lock.h (_IO_acquire_lock_clear_flags2):
+ Define.
+
+2007-07-06 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/sh/tls.h: Include stdlib.h, list.h, sysdep.h and
+ kernel-features.h.
+
+2007-05-16 Roland McGrath <roland@redhat.com>
+
+ * init.c (__nptl_initial_report_events): New variable.
+ (__pthread_initialize_minimal_internal): Initialize pd->report_events
+ to that.
+
+2007-06-22 Jakub Jelinek <jakub@redhat.com>
+
+ * pthread_getattr_np.c (pthread_getattr_np): Clear cpuset and
+ cpusetsize if pthread_getaffinity_np failed with ENOSYS.
+
+2007-06-19 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/rtld-lowlevel.h: Remove mrlock
+ implementation.
+
+2007-06-18 Ulrich Drepper <drepper@redhat.com>
+
+ * pthreadP.h: Define PTHREAD_MUTEX_TYPE.
+ * phtread_mutex_lock.c: Use PTHREAD_MUTEX_TYPE.
+ * pthread_mutex_timedlock.c: Likewise.
+ * pthread_mutex_trylock.c: Likewise.
+ * pthread_mutex_unlock.c: Likewise.
+
+2007-06-17 Andreas Schwab <schwab@suse.de>
+
+ * sysdeps/pthread/pt-initfini.c: Tell gcc about the nonstandard
+ sections.
+
+2007-06-17 Ulrich Drepper <drepper@redhat.com>
+
+ * allocatestack.c (allocate_stack): Make code compile if
+ __ASSUME_PRIVATE_FUTEX is set.
+
+2007-06-17 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_rdlock.S:
+ (__pthread_rwlock_rdlock): Don't use non SH-3/4 instruction.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_wrlock.S:
+ (__pthread_rwlock_wrlock): Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedrdlock.S:
+ (pthread_rwlock_timedrdlock): Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedwrlock.S:
+ (pthread_rwlock_timedwrlock): Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_unlock.S:
+ (__pthread_rwlock_unlock): Likewise.
+
+2007-06-10 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/sh/tcb-offsets.sym: Add PRIVATE_FUTEX.
+ * sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h: Include endian.h.
+ Split __flags into __flags, __shared, __pad1 and __pad2.
+ * sysdeps/unix/sysv/linux/sh/libc-lowlevellock.S: Use private
+ futexes if they are available.
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.S: Adjust so that change
+ in libc-lowlevellock.S allow using private futexes.
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.h: Define
+ FUTEX_PRIVATE_FLAG. Add additional parameter to lll_futex_wait,
+ lll_futex_timed_wait and lll_futex_wake. Change lll_futex_wait
+ to call lll_futex_timed_wait. Add lll_private_futex_wait,
+ lll_private_futex_timed_wait and lll_private_futex_wake.
+ (lll_robust_mutex_unlock): Fix typo.
+ * sysdeps/unix/sysv/linux/sh/pthread_barrier_wait.S: Use private
+ field in futex command setup.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S: Use
+ COND_NWAITERS_SHIFT instead of COND_CLOCK_BITS.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_once.S: Use private futexes
+ if they are available. Remove clear_once_control.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_rdlock.S: Use private
+ futexes if they are available.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedrdlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedwrlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_unlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_wrlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/sem_post.S: Add private futex support.
+ Wake only when there are waiters.
+ * sysdeps/unix/sysv/linux/sh/sem_wait.S: Add private futex
+ support. Indicate that there are waiters. Remove unnecessary
+ extra cancellation test.
+ * sysdeps/unix/sysv/linux/sh/sem_timedwait.S: Likewise. Removed
+ left-over duplication of __sem_wait_cleanup.
+
+2007-06-07 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Add additional
+ parameter to lll_futex_wait, lll_futex_timed_wait, and
+ lll_futex_wake. Change lll_futex_wait to call lll_futex_timed_wait.
+ Add lll_private_futex_wait, lll_private_futex_timed_wait, and
+ lll_private_futex_wake.
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h: Likewise.
+ * allocatestack.c: Adjust use of lll_futex_* macros.
+ * init.c: Likewise.
+ * lowlevellock.h: Likewise.
+ * pthread_barrier_wait.c: Likewise.
+ * pthread_cond_broadcast.c: Likewise.
+ * pthread_cond_destroy.c: Likewise.
+ * pthread_cond_signal.c: Likewise.
+ * pthread_cond_timedwait.c: Likewise.
+ * pthread_cond_wait.c: Likewise.
+ * pthread_create.c: Likewise.
+ * pthread_mutex_lock.c: Likewise.
+ * pthread_mutex_setprioceiling.c: Likewise.
+ * pthread_mutex_timedlock.c: Likewise.
+ * pthread_mutex_unlock.c: Likewise.
+ * pthread_rwlock_timedrdlock.c: Likewise.
+ * pthread_rwlock_timedwrlock.c: Likewise.
+ * pthread_rwlock_unlock.c: Likewise.
+ * sysdeps/alpha/tls.h: Likewise.
+ * sysdeps/i386/tls.h: Likewise.
+ * sysdeps/ia64/tls.h: Likewise.
+ * sysdeps/powerpc/tls.h: Likewise.
+ * sysdeps/pthread/aio_misc.h: Likewise.
+ * sysdeps/pthread/gai_misc.h: Likewise.
+ * sysdeps/s390/tls.h: Likewise.
+ * sysdeps/sh/tls.h: Likewise.
+ * sysdeps/sparc/tls.h: Likewise.
+ * sysdeps/unix/sysv/linux/fork.c: Likewise.
+ * sysdeps/unix/sysv/linux/lowlevellock.c: Likewise.
+ * sysdeps/unix/sysv/linux/lowlevelrobustlock.c: Likewise.
+ * sysdeps/unix/sysv/linux/rtld-lowlevel.h: Likewise.
+ * sysdeps/unix/sysv/linux/sem_post.c: Likewise.
+ * sysdeps/unix/sysv/linux/sem_timedwait.c: Likewise.
+ * sysdeps/unix/sysv/linux/sem_wait.c: Likewise.
+ * sysdeps/unix/sysv/linux/unregister-atfork.c: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/pthread_once.c: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/pthread_barrier_wait.c:
+ Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sem_post.c: Likewise.
+ * sysdeps/x86_64/tls.h: Likewise.
+
+2007-05-29 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_getattr_np.c: No need to install a cancellation handler,
+ this is no cancellation point.
+ * pthread_getschedparam.c: Likewise.
+ * pthread_setschedparam.c: Likewise.
+ * pthread_setschedprio.c: Likewise.
+ * sysdeps/unix/sysv/linux/lowlevellock.c: Remove all traces of
+ lll_unlock_wake_cb.
+ * sysdeps/unix/sysv/linux/alpha/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/s390/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/lowlevellock.c: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Likewise.
+
+ * sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S: Checking
+ whether there are more than one thread makes no sense here since
+ we only call the slow path if the locks are taken.
+ * sysdeps/unix/sysv/linux/x86_64/libc-lowlevellock.S: Likewise.
+
+ * sysdeps/unix/sysv/linux/internaltypes.h: Introduce
+ COND_NWAITERS_SHIFT.
+ * pthread_cond_destroy.c: Use COND_NWAITERS_SHIFT instead of
+ COND_CLOCK_BITS.
+ * pthread_cond_init.c: Likewise.
+ * pthread_cond_timedwait.c: Likewise.
+ * pthread_cond_wait.c: Likewise.
+ * pthread_condattr_getclock.c: Likewise.
+ * pthread_condattr_setclock.c: Likewise.
+ * sysdeps/unix/sysv/linux/lowlevelcond.sym: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Likewise.
+
+2007-05-28 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstacksize.c: Include
+ unistd.h.
+
+ * sysdeps/i386/tls.h (THREAD_GSCOPE_RESET_FLAG): Use explicit
+ insn suffix.
+ (THREAD_GSCOPE_GET_FLAG): Remove.
+ * sysdeps/x86_64/tls.h (THREAD_GSCOPE_GET_FLAG): Remove.
+ * allocatestack.c (__wait_lookup_done): Revert 2007-05-24
+ changes.
+ * sysdeps/powerpc/tls.h (tcbhead_t): Remove gscope_flag.
+ (THREAD_GSCOPE_GET_FLAG): Remove.
+ (THREAD_GSCOPE_RESET_FLAG): Use THREAD_SELF->header.gscope_flag
+ instead of THREAD_GSCOPE_GET_FLAG.
+ (THREAD_GSCOPE_SET_FLAG): Likewise. Add atomic_write_barrier after
+ it.
+ * sysdeps/s390/tls.h (THREAD_GSCOPE_FLAG_UNUSED,
+ THREAD_GSCOPE_FLAG_USED, THREAD_GSCOPE_FLAG_WAIT,
+ THREAD_GSCOPE_RESET_FLAG, THREAD_GSCOPE_SET_FLAG,
+ THREAD_GSCOPE_WAIT): Define.
+ * sysdeps/sparc/tls.h (THREAD_GSCOPE_FLAG_UNUSED,
+ THREAD_GSCOPE_FLAG_USED, THREAD_GSCOPE_FLAG_WAIT,
+ THREAD_GSCOPE_RESET_FLAG, THREAD_GSCOPE_SET_FLAG,
+ THREAD_GSCOPE_WAIT): Define.
+ * sysdeps/sh/tls.h (THREAD_GSCOPE_FLAG_UNUSED,
+ THREAD_GSCOPE_FLAG_USED, THREAD_GSCOPE_FLAG_WAIT,
+ THREAD_GSCOPE_RESET_FLAG, THREAD_GSCOPE_SET_FLAG,
+ THREAD_GSCOPE_WAIT): Define.
+ * sysdeps/ia64/tls.h (THREAD_GSCOPE_FLAG_UNUSED,
+ THREAD_GSCOPE_FLAG_USED, THREAD_GSCOPE_FLAG_WAIT,
+ THREAD_GSCOPE_RESET_FLAG, THREAD_GSCOPE_SET_FLAG,
+ THREAD_GSCOPE_WAIT): Define.
+
+2007-05-24 Richard Henderson <rth@redhat.com>
+
+ * descr.h (struct pthread): Add header.gscope_flag.
+ * sysdeps/alpha/tls.h (THREAD_GSCOPE_FLAG_UNUSED,
+ THREAD_GSCOPE_FLAG_USED, THREAD_GSCOPE_FLAG_WAIT,
+ THREAD_GSCOPE_RESET_FLAG, THREAD_GSCOPE_SET_FLAG,
+ THREAD_GSCOPE_WAIT): Define.
+
+2007-05-27 Ulrich Drepper <drepper@redhat.com>
+
+ * init.c: Make it compile with older kernel headers.
+
+ * tst-initializers1.c: Show through exit code which test failed.
+
+ * pthread_rwlock_init.c: Also initialize __shared field.
+ * sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h: Split __flags
+ element in rwlock structure into four byte elements. One of them is
+ the new __shared element.
+ * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h [__WORDSIZE=32]:
+ Likewise.
+ [__WORDSIZE=64]: Renamed __pad1 element int rwlock structure to
+ __shared, adjust names of other padding elements.
+ * sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h: Likewise.
+ * sysdeps/pthread/pthread.h: Adjust rwlock initializers.
+ * sysdeps/unix/sysv/linux/lowlevelrwlock.sym: Add PSHARED.
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h: Define
+ FUTEX_PRIVATE_FLAG.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S: Change main
+ futex to use private operations if possible.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_unlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S: Likewise.
+
+2007-05-26 Ulrich Drepper <drepper@redhat.com>
+
+ * pthreadP.h (PTHREAD_RWLOCK_PREFER_READER_P): Define.
+ * pthread_rwlock_rdlock.c: Use PTHREAD_RWLOCK_PREFER_READER_P.
+ * pthread_rwlock_timedrdlock.c: Likewise.
+ * pthread_rwlock_tryrdlock.c: Likewise.
+
+ * sysdeps/unix/sysv/linux/x86_64/sem_trywait.S (sem_trywait): Tiny
+ optimization.
+
+ * sysdeps/unix/sysv/linux/sem_wait.c: Add missing break.
+ * sysdeps/unix/sysv/linux/sem_timedwait.c: Removed left-over
+ duplication of __sem_wait_cleanup.
+
+ * allocatestack.c: Revert last change.
+ * init.c: Likewise.
+ * sysdeps/i386/tls.h: Likewise.
+ * sysdeps/x86_64/tls.h: Likewise.
+ * descr.h [TLS_DTV_AT_TP] (struct pthread): Add private_futex field to
+ header structure.
+ * sysdeps/powerpc/tcb-offsets.sym: Add PRIVATE_FUTEX_OFFSET.
+
+ * sysdeps/unix/sysv/linux/internaltypes.h (struct pthread_barrier):
+ Add private field.
+ * sysdeps/unix/sysv/linux/lowlevelbarrier.sym: Add PRIVATE definition.
+ * pthread_barrier_init.c: Set private flag if pshared and private
+ futexes are supported.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_barrier_wait.S: Use
+ private field in futex command setup.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S: Likewise.
+
+2007-05-25 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/sem_post.S: Add private futex
+ support.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sem_post.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sem_wait.S: Likewise.
+
+ * semaphoreP.h: Declare __old_sem_init and __old_sem_wait.
+ * sem_init.c (__new_sem_init): Rewrite to initialize all three
+ fields in the structure.
+ (__old_sem_init): New function.
+ * sem_open.c: Initialize all fields of the structure.
+ * sem_getvalue.c: Adjust for renamed element.
+ * sysdeps/unix/sysv/linux/Makefile [subdir=nptl]
+ (gen-as-const-headers): Add structsem.sym.
+ * sysdeps/unix/sysv/linux/structsem.sym: New file.
+ * sysdeps/unix/sysv/linux/internaltypes.h: Rename struct sem to
+ struct new_sem. Add struct old_sem.
+ * sysdeps/unix/sysv/linux/sem_post.c: Wake only when there are waiters.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_post.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sem_post.S: Likewise.
+ * sysdeps/unix/sysv/linux/sem_wait.c: Indicate that there are waiters.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sem_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/sem_timedwait.c: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S: Likewise.
+ * Makefile (tests): Add tst-sem10, tst-sem11, tst-sem12.
+ * tst-sem10.c: New file.
+ * tst-sem11.c: New file.
+ * tst-sem12.c: New file.
+ * tst-typesizes.c: Test struct new_sem and struct old_sem instead
+ of struct sem.
+
+2007-05-25 Ulrich Drepper <drepper@redhat.com>
+ Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S (sem_timedwait):
+ Move __pthread_enable_asynccancel right before futex syscall.
+ * sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S (sem_timedwait):
+ Likewise.
+
+2007-05-24 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/i386/tls.h (THREAD_SET_PRIVATE_FUTEX,
+ THREAD_COPY_PRIVATE_FUTEX): Define.
+ * sysdeps/x86_64/tls.h (THREAD_SET_PRIVATE_FUTEX,
+ THREAD_COPY_PRIVATE_FUTEX): Define.
+ * allocatestack.c (allocate_stack): Use THREAD_COPY_PRIVATE_FUTEX.
+ * init.c (__pthread_initialize_minimal_internal): Use
+ THREAD_SET_PRIVATE_FUTEX.
+
+ * sysdeps/powerpc/tls.h (tcbhead_t): Add gscope_flag.
+ (THREAD_GSCOPE_FLAG_UNUSED, THREAD_GSCOPE_FLAG_USED,
+ THREAD_GSCOPE_FLAG_WAIT): Define.
+ (THREAD_GSCOPE_GET_FLAG, THREAD_GSCOPE_SET_FLAG,
+ THREAD_GSCOPE_RESET_FLAG, THREAD_GSCOPE_WAIT): Define.
+ * sysdeps/i386/tls.h (THREAD_GSCOPE_WAIT): Don't use
+ PTR_DEMANGLE.
+ (THREAD_GSCOPE_GET_FLAG): Define.
+ * sysdeps/x86_64/tls.h (THREAD_GSCOPE_GET_FLAG): Define.
+ * allocatestack.c (__wait_lookup_done): Use THREAD_GSCOPE_GET_FLAG
+ instead of ->header.gscope_flag directly.
+
+2007-05-23 Ulrich Drepper <drepper@redhat.com>
+
+ * init.c (__pthread_initialize_minimal_internal): Check whether
+ private futexes are available.
+ * allocatestack.c (allocate_stack): Copy private_futex field from
+ current thread into the new stack.
+ * sysdeps/unix/sysv/linux/x86_64/libc-lowlevellock.S: Use private
+ futexes if they are available.
+ * sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S: Likewise
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.S: Adjust so that change
+ in libc-lowlevellock.S allow using private futexes.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Define
+ FUTEX_PRIVATE_FLAG.
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_once.S: Use private futexes
+ if they are available.
+ * sysdeps/unix/sysv/linux/i386/pthread_once.S: Likewise.
+ * sysdeps/x86_64/tcb-offsets.sym: Add PRIVATE_FUTEX.
+ * sysdeps/i386/tcb-offsets.sym: Likewise.
+ * sysdeps/x86_64/tls.h (tcbhead_t): Add private_futex field.
+ * sysdeps/i386/tls.h (tcbhead_t): Likewise.
+
+2007-05-21 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/pthread-functions.h (struct pthread_functions):
+ Remove ptr_wait_lookup_done again.
+ * init.c (pthread_functions): Don't add .ptr_wait_lookup_done here.
+ (__pthread_initialize_minimal_internal): Initialize
+ _dl_wait_lookup_done pointer in _rtld_global directly.
+ * sysdeps/unix/sysv/linux/libc_pthread_init.c (__libc_pthread_init):
+ Remove code to code _dl_wait_lookup_done.
+ * sysdeps/x86_64/tls.h (THREAD_GSCOPE_WAIT): The pointer is not
+ encrypted for now.
+
+2007-05-21 Jakub Jelinek <jakub@redhat.com>
+
+ * tst-robust9.c (do_test): Don't fail if ENABLE_PI and
+ pthread_mutex_init failed with ENOTSUP.
+
+2007-05-19 Ulrich Drepper <drepper@redhat.com>
+
+ * allocatestack.c (__wait_lookup_done): New function.
+ * sysdeps/pthread/pthread-functions.h (struct pthread_functions):
+ Add ptr_wait_lookup_done.
+ * init.c (pthread_functions): Initialize .ptr_wait_lookup_done.
+ * pthreadP.h: Declare __wait_lookup_done.
+ * sysdeps/i386/tls.h (tcbhead_t): Add gscope_flag.
+ Define macros to implement reference handling of global scope.
+ * sysdeps/x86_64/tls.h: Likewise.
+ * sysdeps/unix/sysv/linux/libc_pthread_init.c (__libc_pthread_init):
+ Initialize GL(dl_wait_lookup_done).
+
+2007-05-17 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #4512]
+ * pthread_mutex_lock.c: Preserve FUTEX_WAITERS bit when dead owner
+ is detected.
+ * pthread_mutex_timedlock.c: Likewise.
+ * pthread_mutex_trylock.c: Likewise.
+ Patch in part by Atsushi Nemoto <anemo@mba.ocn.ne.jp>.
+
+ * Makefile (tests): Add tst-robust9 and tst-robustpi9.
+ * tst-robust9.c: New file.
+ * tst-robustpi9.c: New file.
+
+ * sysdeps/unix/sysv/linux/sem_wait.c (__new_sem_wait): Remove
+ unnecessary extra cancellation test.
+
+2007-05-14 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/sem_wait.S: Remove unnecessary
+ extra cancellation test.
+ * sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S: Likewise.
+
+2007-05-10 Ulrich Drepper <drepper@redhat.com>
+
+ * descr.h (struct pthread): Rearrange members to fill hole in
+ 64-bit layout.
+
+ * sysdeps/unix/sysv/linux/pthread_setaffinity.c
+ (__pthread_setaffinity_new): If syscall was successful and
+ RESET_VGETCPU_CACHE is defined, use it before returning.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_setaffinity.c: New file.
+
+2007-05-10 Jakub Jelinek <jakub@redhat.com>
+
+ [BZ #4455]
+ * tst-align2.c: Include stackinfo.h.
+ * tst-getpid1.c: Likewise.
+
+2007-05-02 Carlos O'Donell <carlos@systemhalted.org>
+
+ [BZ #4455]
+ * tst-align2.c (do_test): Add _STACK_GROWS_UP case.
+ * tst-getpid1.c (do_test): Likewise.
+
+ [BZ #4456]
+ * allocatestack.c (change_stack_perm): Add _STACK_GROWS_UP case.
+ (allocate_stack): Likewise.
+
+2007-05-07 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/lowlevelrobustlock.c
+ (__lll_robust_lock_wait): Fix race caused by reloading of futex value.
+ (__lll_robust_timedlock_wait): Likewise.
+ Reported by Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>.
+
+2007-05-06 Mike Frysinger <vapier@gentoo.org>
+
+ [BZ #4465]
+ * tst-cancel-wrappers.sh: Set C["fdatasync"] to 1.
+ * tst-cancel4.c (tf_fdatasync): New test.
+
+2007-04-27 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #4392]
+ * pthread_mutex_trylock.c (__pthread_mutex_trylock): Treat error
+ check mutexes like normal mutexes.
+
+ [BZ #4306]
+ * sysdeps/unix/sysv/linux/timer_create.c (timer_create):
+ Initialize the whole sigevent structure to appease valgrind.
+
+2007-04-25 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/x86_64/tls.h (tcbhead_t): Add vgetcpu_cache.
+ * sysdeps/x86_64/tcb-offsets.sym: Add VGETCPU_CACHE_OFFSET.
+
+2007-04-06 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-locale1.c: Avoid warnings.
+ * tst-locale2.c: Likewise.
+
+2007-03-19 Steven Munroe <sjmunroe@us.ibm.com>
+
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h
+ (__lll_robust_trylock): Add MUTEX_HINT_ACQ to lwarx instruction.
+
+2007-03-16 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/pthread/bits/libc-lock.h: Use __extern_inline and
+ __extern_always_inline where appropriate.
+ * sysdeps/pthread/pthread.h: Likewise.
+
+2007-03-13 Richard Henderson <rth@redhat.com>
+
+ * sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h (PSEUDO): Use two
+ separate cfi regions for the two subsections.
+
+2007-02-25 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/fork.c (__libc_fork): Reset refcntr in
+ new thread, don't just decrement it.
+ Patch by Suzuki K P <suzuki@in.ibm.com>.
+
+2007-02-21 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/pthread-functions.h: Correct last patch, correct
+ PTHFCT_CALL definition.
+
+2007-02-18 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/pthread-functions.h: If PTR_DEMANGLE is not
+ available, don't use it.
+
+2007-02-09 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
+ (__lll_mutex_timedlock_wait): Use correct pointer when we don't
+ call into the kernel to delay.
+
+2007-01-18 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-initializers1.c: We want to test the initializers as seen
+ outside of libc, so undefined _LIBC.
+
+ * pthread_join.c (cleanup): Avoid warning.
+
+2007-01-17 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
+ (__lll_timedwait_tid): Add unwind info.
+
+ * sysdeps/unix/sysv/linux/libc_pthread_init.c: Don't just copy the
+ function table, mangle the pointers.
+ * sysdeps/pthread/pthread-functions.h: Define PTHFCT_CALL.
+ * forward.c: Use PTHFCT_CALL and __libc_pthread_functions_init.
+ * sysdeps/pthread/bits/libc-lock.h: When using __libc_pthread_functions
+ demangle pointers before use.
+ * sysdeps/unix/sysv/linux/s390/jmp-unwind.c: Use PTHFCT_CALL to
+ demangle pointer.
+ * sysdeps/unix/sysv/linux/jmp-unwind.c: Likewise.
+ * sysdeps/pthread/setxid.h: Likewise.
+
+2007-01-12 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-rwlock7.c: Show some more information in case of correct
+ behavior.
+
+2007-01-11 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
+ (lll_futex_timed_wait): Undo part of last change, don't negate
+ return value.
+
+2007-01-10 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Cleanups. Define
+ FUTEX_CMP_REQUEUE and lll_futex_requeue.
+
+2006-12-28 David S. Miller <davem@davemloft.net>
+
+ * shlib-versions: Fix sparc64 linux target specification.
+
+2007-01-10 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/pthread_barrier_wait.c:
+ Adjust include path for pthread_barrier_wait.c move.
+
+2006-12-21 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/pthread_kill.c (pthread_kill): Make sure
+ tid isn't reread from pd->tid in between ESRCH test and the syscall.
+
+2006-12-06 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h (PSEUDO): Handle
+ 6 argument cancellable syscalls.
+ (STM_6, LM_6, LR7_0, LR7_1, LR7_2, LR7_3, LR7_4, LR7_5, LR7_6): Define.
+ * sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h (PSEUDO): Handle
+ 6 argument cancellable syscalls.
+ (STM_6, LM_6, LR7_0, LR7_1, LR7_2, LR7_3, LR7_4, LR7_5, LR7_6): Define.
+
+2006-12-09 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/rtld-lowlevel.h
+ (__rtld_mrlock_initialize): Add missing closing parenthesis.
+
+2006-10-30 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/ia64/pthread_spin_unlock.c (pthread_spin_unlock): Use
+ __sync_lock_release instead of __sync_lock_release_si.
+
+2006-10-29 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/sysdep-cancel.h (RTLD_SINGLE_THREAD_P):
+ Define.
+ (SINGLE_THREAD_P): Define to 1 if IS_IN_rtld.
+ * sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/sh/sysdep-cancel.h: Likewise.
+
+2006-10-27 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/pthread_barrier_wait.c: Move to...
+ * pthread_barrier_wait.c: ...here.
+ * sysdeps/pthread/pthread_cond_broadcast.c: Move to...
+ * pthread_cond_broadcast.c: ...here.
+ * sysdeps/pthread/pthread_cond_signal.c: Move to...
+ * pthread_cond_signal.c: ...here.
+ * sysdeps/pthread/pthread_cond_timedwait.c: Move to...
+ * pthread_cond_timedwait.c: ...here.
+ * sysdeps/pthread/pthread_cond_wait.c: Move to...
+ * pthread_cond_wait.c: ...here.
+ * sysdeps/pthread/pthread_once.c: Move to...
+ * pthread_once.c: ...here.
+ * sysdeps/pthread/pthread_rwlock_rdlock.c: Move to...
+ * pthread_rwlock_rdlock.c: ...here.
+ * sysdeps/pthread/pthread_rwlock_timedrdlock.c: Move to...
+ * pthread_rwlock_timedrdlock.c: ...here.
+ * sysdeps/pthread/pthread_rwlock_timedwrlock.c: Move to...
+ * pthread_rwlock_timedwrlock.c: ...here.
+ * sysdeps/pthread/pthread_rwlock_unlock.c: Move to...
+ * pthread_rwlock_unlock.c: ...here.
+ * sysdeps/pthread/pthread_rwlock_wrlock.c: Move to...
+ * pthread_rwlock_wrlock.c: ...here.
+ * sysdeps/pthread/pthread_spin_destroy.c: Move to...
+ * pthread_spin_destroy.c: ...here.
+ * sysdeps/pthread/pthread_spin_init.c: Move to...
+ * pthread_spin_init.c: ...here.
+ * sysdeps/pthread/pthread_spin_unlock.c: Move to...
+ * pthread_spin_unlock.c: ...here.
+ * sysdeps/pthread/pthread_getcpuclockid.c: Move to...
+ * pthread_getcpuclockid.c: ...here.
+
+ * init.c: USE_TLS support is now always enabled.
+ * tst-tls5.h: Likewise.
+ * sysdeps/alpha/tls.h: Likewise.
+ * sysdeps/i386/tls.h: Likewise.
+ * sysdeps/ia64/tls.h: Likewise.
+ * sysdeps/powerpc/tls.h: Likewise.
+ * sysdeps/s390/tls.h: Likewise.
+ * sysdeps/sh/tls.h: Likewise.
+ * sysdeps/sparc/tls.h: Likewise.
+ * sysdeps/x86_64/tls.h: Likewise.
+
+2006-10-27 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/rtld-lowlevel.h (__rtld_mrlock_lock,
+ __rtld_mrlock_change): Update oldval if atomic compare and exchange
+ failed.
+
+ * sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h (SINGLE_THREAD_P):
+ Define to THREAD_SELF->header.multiple_threads.
+ * sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h (SINGLE_THREAD_P):
+ Likewise.
+ * sysdeps/unix/sysv/linux/i386/sysdep-cancel.h (SINGLE_THREAD_P):
+ Likewise.
+ * sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h
+ (SINGLE_THREAD_P): Likewise.
+ * sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h
+ (SINGLE_THREAD_P): Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h
+ (SINGLE_THREAD_P): Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h
+ (SINGLE_THREAD_P): Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h (SINGLE_THREAD_P):
+ Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h
+ (SINGLE_THREAD_P): Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h
+ (SINGLE_THREAD_P): Likewise.
+ * sysdeps/unix/sysv/linux/sh/sysdep-cancel.h (SINGLE_THREAD_P):
+ Likewise.
+
+2006-10-26 Jakub Jelinek <jakub@redhat.com>
+
+ * pthread_attr_setstacksize.c (NEW_VERNUM): Define to GLIBC_2_3_3
+ by default rather than 2_3_3.
+
+2006-10-17 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/rtld-lowlevel.h (__rtld_mrlock_lock,
+ __rtld_mrlock_unlock, __rtld_mrlock_change, __rtld_mrlock_done): Use
+ atomic_* instead of catomic_* macros.
+
+2006-10-12 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #3285]
+ * sysdeps/unix/sysv/linux/bits/local_lim.h: Add SEM_VALUE_MAX.
+ * sysdeps/unix/sysv/linux/powerpc/bits/local_lim.h: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/bits/local_lim.h: Likewise.
+ * sysdeps/unix/sysv/linux/alpha/bits/local_lim.h: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/bits/local_lim.h: Likewise.
+ * sysdeps/unix/sysv/linux/i386/bits/semaphore.h: Remove SEM_VALUE_MAX.
+ * sysdeps/unix/sysv/linux/powerpc/bits/semaphore.h: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/bits/semaphore.h: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/bits/semaphore.h: Likewise.
+ * sysdeps/unix/sysv/linux/alpha/bits/semaphore.h: Likewise.
+ * sysdeps/unix/sysv/linux/sh/bits/semaphore.h: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/bits/semaphore.h: Likewise.
+ * sysdeps/unix/sysv/linux/s390/bits/semaphore.h: Likewise.
+
+2006-10-11 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/sysdep-cancel.h: Add support for
+ cancelable syscalls with six parameters.
+
+ * sysdeps/unix/sysv/linux/rtld-lowlevel.h: Use catomic_*
+ operations instead of atomic_*.
+
+2006-10-09 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/rtld-lowlevel.h: New file..
+
+2006-10-07 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/powerpc/bits/local_lim.h: New file.
+ * sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstack.c: New file.
+ * sysdeps/unix/sysv/linux/powerpc/pthread_attr_setstacksize.c:
+ New file.
+ * pthread_attr_setstack.c: Allow overwriting the version number of the
+ new symbol.
+ * pthread_attr_setstacksize.c: Likewise.
+ (__old_pthread_attr_setstacksize): If STACKSIZE_ADJUST is defined use
+ it.
+ * sysdeps/unix/sysv/linux/powerpc/Versions (libpthread): Add
+ pthread_attr_setstack and pthread_attr_setstacksize to GLIBC_2.6.
+
+2006-09-24 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #3251]
+ * descr.h (ENQUEUE_MUTEX_BOTH): Add cast to avoid warning.
+ Patch by Petr Baudis.
+
+2006-09-18 Jakub Jelinek <jakub@redhat.com>
+
+ * tst-kill4.c (do_test): Explicitly set tf thread's stack size.
+
+ * tst-cancel2.c (tf): Loop as long as something was written.
+
+2006-09-12 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_broadcast.S: For PI
+ mutexes wake all mutexes.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S: Don't increment
+ WAKEUP_SEQ if this would increase the value beyond TOTAL_SEQ.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S: Likewise.
+
+2006-09-12 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-cond22.c (tf): Slight changes to the pthread_cond_wait use
+ to guarantee the thread is always canceled.
+
+2006-09-08 Jakub Jelinek <jakub@redhat.com>
+
+ * tst-cond22.c: Include pthread.h instead of pthreadP.h.
+ Include stdlib.h.
+ * sysdeps/pthread/pthread_cond_wait.c (__condvar_cleanup): Only
+ increase FUTEX if increasing WAKEUP_SEQ. Fix comment typo.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Likewise.
+
+2006-09-08 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #3123]
+ * sysdeps/pthread/pthread_cond_wait.c (__condvar_cleanup): Don't
+ increment WAKEUP_SEQ if this would increase the value beyond TOTAL_SEQ.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Likewise.
+ * Makefile (tests): Add tst-cond22.
+ * tst-cond22.c: New file.
+
+2006-09-05 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #3124]
+ * descr.h (struct pthread): Add parent_cancelhandling.
+ * sysdeps/pthread/createthread.c (create_thread): Pass parent
+ cancelhandling value to child.
+ * pthread_create.c (start_thread): If parent thread was canceled
+ reset the SIGCANCEL mask.
+ * Makefile (tests): Add tst-cancel25.
+ * tst-cancel25.c: New file.
+
+2006-09-05 Jakub Jelinek <jakub@redhat.com>
+ Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/gai_misc.h (GAI_MISC_NOTIFY): Don't decrement
+ counterp if it is already zero.
+ * sysdeps/pthread/aio_misc.h (AIO_MISC_NOTIFY): Likewise..
+
+2006-03-04 Jakub Jelinek <jakub@redhat.com>
+ Roland McGrath <roland@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h
+ (LLL_STUB_UNWIND_INFO_START, LLL_STUB_UNWIND_INFO_END,
+ LLL_STUB_UNWIND_INFO_3, LLL_STUB_UNWIND_INFO_4): Define.
+ (lll_mutex_lock, lll_robust_mutex_lock, lll_mutex_cond_lock,
+ lll_robust_mutex_cond_lock, lll_mutex_timedlock,
+ lll_robust_mutex_timedlock, lll_mutex_unlock,
+ lll_robust_mutex_unlock, lll_lock, lll_unlock): Use them.
+ Add _L_*_ symbols around the subsection.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S: Add unwind info.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevelrobustlock.S: Likewise.
+
+2006-03-03 Jakub Jelinek <jakub@redhat.com>
+ Roland McGrath <roland@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
+ (LLL_STUB_UNWIND_INFO_START, LLL_STUB_UNWIND_INFO_END,
+ LLL_STUB_UNWIND_INFO_5, LLL_STUB_UNWIND_INFO_6): Define.
+ (lll_mutex_lock, lll_robust_mutex_lock, lll_mutex_cond_lock,
+ lll_robust_mutex_cond_lock, lll_mutex_timedlock,
+ lll_robust_mutex_timedlock, lll_mutex_unlock,
+ lll_robust_mutex_unlock, lll_lock, lll_unlock): Use them.
+ Add _L_*_ symbols around the subsection.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.S: Add unwind info.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S: Likewise.
+
+2006-08-31 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_rwlock_trywrlock.c (__pthread_rwlock_trywrlock): Undo last
+ change because it can disturb too much existing code. If real hard
+ reader preference is needed we'll introduce another type.
+ * sysdeps/pthread/pthread_rwlock_timedwrlock.c
+ (pthread_rwlock_timedwrlock): Likewise.
+ * sysdeps/pthread/pthread_rwlock_wrlock.c (__pthread_rwlock_wrlock):
+ Likewise.
+
+2006-08-30 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_rwlock_trywrlock.c (__pthread_rwlock_trywrlock): Respect
+ reader preference.
+ * sysdeps/pthread/pthread_rwlock_timedwrlock.c
+ (pthread_rwlock_timedwrlock): Likewise.
+ * sysdeps/pthread/pthread_rwlock_wrlock.c (__pthread_rwlock_wrlock):
+ Likewise.
+
+2006-08-25 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/libc_pthread_init.c (freeres_libpthread):
+ Only define ifdef SHARED.
+
+2006-08-23 Ulrich Drepper <drepper@redhat.com>
+
+ * allocatestack.c (queue_stack): Move freeing of surplus stacks to...
+ (free_stacks): ...here.
+ (__free_stack_cache): New function.
+ * pthreadP.h: Declare __free_stack_cache.
+ * sysdeps/pthread/pthread-functions.h (pthread_functions): Add
+ ptr_freeres.
+ * init.c (pthread_functions): Initialize ptr_freeres.
+ * sysdeps/unix/sysv/linux/libc_pthread_init.c (freeres_libptread):
+ New freeres function.
+
+2006-07-30 Joseph S. Myers <joseph@codesourcery.com>
+
+ [BZ #3018]
+ * Makefile (extra-objs): Add modules to extra-test-objs instead.
+
+2006-08-20 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/bits/posix_opt.h: Define
+ _XOPEN_REALTIME_THREADS.
+
+2006-08-15 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/clock_settime.c (INTERNAL_VSYSCALL): Use
+ HAVE_CLOCK_GETRES_VSYSCALL as guard macro rather than
+ HAVE_CLOCK_GETTIME_VSYSCALL.
+ (maybe_syscall_settime_cpu): Use plain INTERNAL_VSYSCALL here.
+
+2006-08-14 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/bits/posix_opt.h
+ (_POSIX_THREAD_PRIO_PROTECT): Define to 200112L.
+ * descr.h (struct priority_protection_data): New type.
+ (struct pthread): Add tpp field.
+ * pthreadP.h (PTHREAD_MUTEX_PP_NORMAL_NP,
+ PTHREAD_MUTEX_PP_RECURSIVE_NP, PTHREAD_MUTEX_PP_ERRORCHECK_NP,
+ PTHREAD_MUTEX_PP_ADAPTIVE_NP): New enum values.
+ * pthread_mutex_init.c (__pthread_mutex_init): Handle non-robust
+ TPP mutexes.
+ * pthread_mutex_lock.c (__pthread_mutex_lock): Handle TPP mutexes.
+ * pthread_mutex_trylock.c (__pthread_mutex_trylock): Likewise.
+ * pthread_mutex_timedlock.c (pthread_mutex_timedlock): Likewise.
+ * pthread_mutex_unlock.c (__pthread_mutex_unlock_usercnt): Likewise.
+ * tpp.c: New file.
+ * pthread_setschedparam.c (__pthread_setschedparam): Handle priority
+ boosted by TPP.
+ * pthread_setschedprio.c (pthread_setschedprio): Likewise.
+ * pthread_mutexattr_getprioceiling.c
+ (pthread_mutexattr_getprioceiling): If ceiling is 0, ensure it is
+ in the SCHED_FIFO priority range.
+ * pthread_mutexattr_setprioceiling.c
+ (pthread_mutexattr_setprioceiling): Fix prioceiling validation.
+ * pthread_mutex_getprioceiling.c (pthread_mutex_getprioceiling): Fail
+ if mutex is not TPP. Ceiling is now in __data.__lock.
+ * pthread_mutex_setprioceiling.c: Include stdbool.h.
+ (pthread_mutex_setprioceiling): Fix prioceiling validation. Ceiling
+ is now in __data.__lock. Add locking.
+ * pthread_create.c (__free_tcb): Free pd->tpp structure.
+ * Makefile (libpthread-routines): Add tpp.
+ (xtests): Add tst-mutexpp1, tst-mutexpp6 and tst-mutexpp10.
+ * tst-tpp.h: New file.
+ * tst-mutexpp1.c: New file.
+ * tst-mutexpp6.c: New file.
+ * tst-mutexpp10.c: New file.
+ * tst-mutex1.c (TEST_FUNCTION): Don't redefine if already defined.
+ * tst-mutex6.c (TEST_FUNCTION): Likewise.
+
+2006-08-12 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #2843]
+ * pthread_join.c (pthread_join): Account for self being canceled
+ when checking for deadlocks.
+ * tst-join5.c: Cleanups. Allow to be used in tst-join6.
+ (tf1): Don't print anything after pthread_join returns, this would be
+ another cancellation point.
+ (tf2): Likewise.
+ * tst-join6.c: New file.
+ * Makefile (tests): Add tst-join6.
+
+2006-08-03 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #2892]
+ * pthread_setspecific.c (__pthread_setspecific): Check
+ out-of-range index before checking for unused key.
+
+ * sysdeps/pthread/gai_misc.h: New file.
+
+2006-08-01 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/smp.h: New file. Old Linux-specific
+ file. Don't use sysctl.
+ * sysdeps/unix/sysv/linux/smp.h: Always assume SMP. Archs can
+ overwrite the file if this is likely not true.
+
+2006-07-31 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * allocatestack.c (__reclaim_stacks): Reset the PID on cached stacks.
+ * Makefile (tests): Add tst-getpid3.
+ * tst-getpid3.c: New file.
+
+2006-07-30 Roland McGrath <roland@redhat.com>
+
+ * Makefile (libpthread-routines): Add ptw-sigsuspend.
+
+ * sysdeps/unix/sysv/linux/i386/not-cancel.h
+ (pause_not_cancel): New macro.
+ (nanosleep_not_cancel): New macro.
+ (sigsuspend_not_cancel): New macro.
+ * pthread_mutex_timedlock.c (pthread_mutex_timedlock): Use
+ nanosleep_not_cancel macro from <not-cancel.h>.
+ * pthread_mutex_lock.c (__pthread_mutex_lock): Use pause_not_cancel
+ macro from <not-cancel.h>.
+
+2006-07-28 Ulrich Drepper <drepper@redhat.com>
+ Jakub Jelinek <jakub@redhat.com>
+
+ * descr.h: Change ENQUEUE_MUTEX and DEQUEUE_MUTEX for bit 0
+ notification of PI mutex. Add ENQUEUE_MUTEX_PI.
+ * pthreadP.h: Define PTHREAD_MUTEX_PI_* macros for PI mutex types.
+ * pthread_mutex_setprioceilining.c: Adjust for mutex type name change.
+ * pthread_mutex_init.c: Add support for priority inheritance mutex.
+ * pthread_mutex_lock.c: Likewise.
+ * pthread_mutex_timedlock.c: Likewise.
+ * pthread_mutex_trylock.c: Likewise.
+ * pthread_mutex_unlock.c: Likewise.
+ * sysdeps/pthread/pthread_cond_broadcast.c: For PI mutexes wake
+ all mutexes.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.c: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.c: Likewise.
+ * sysdeps/unix/sysv/linux/pthread-pi-defines.sym: New file.
+ * sysdeps/unix/sysv/linux/Makefile (gen-as-const-header): Add
+ pthread-pi-defines.sym.
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h: Define FUTEX_LOCK_PI,
+ FUTEX_UNLOCK_PI, and FUTEX_TRYLOCK_PI.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/alpha/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/s390/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/bits/posix_opt.h: Define
+ _POSIX_THREAD_PRIO_INHERIT to 200112L.
+ * tst-mutex1.c: Adjust to allow use in PI mutex test.
+ * tst-mutex2.c: Likewise.
+ * tst-mutex3.c: Likewise.
+ * tst-mutex4.c: Likewise.
+ * tst-mutex5.c: Likewise.
+ * tst-mutex6.c: Likewise.
+ * tst-mutex7.c: Likewise.
+ * tst-mutex7a.c: Likewise.
+ * tst-mutex8.c: Likewise.
+ * tst-mutex9.c: Likewise.
+ * tst-robust1.c: Likewise.
+ * tst-robust7.c: Likewise.
+ * tst-robust8.c: Likewise.
+ * tst-mutexpi1.c: New file.
+ * tst-mutexpi2.c: New file.
+ * tst-mutexpi3.c: New file.
+ * tst-mutexpi4.c: New file.
+ * tst-mutexpi5.c: New file.
+ * tst-mutexpi6.c: New file.
+ * tst-mutexpi7.c: New file.
+ * tst-mutexpi7a.c: New file.
+ * tst-mutexpi8.c: New file.
+ * tst-mutexpi9.c: New file.
+ * tst-robust1.c: New file.
+ * tst-robust2.c: New file.
+ * tst-robust3.c: New file.
+ * tst-robust4.c: New file.
+ * tst-robust5.c: New file.
+ * tst-robust6.c: New file.
+ * tst-robust7.c: New file.
+ * tst-robust8.c: New file.
+ * Makefile (tests): Add the new tests.
+
+ * pthread_create.c (start_thread): Add some casts to avoid warnings.
+ * pthread_mutex_destroy.c: Remove unneeded label.
+
+2006-07-01 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_mutex_init.c (__pthread_mutex_init): Move some
+ computations to compile time.
+
+2006-06-04 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/pthread.h: Add pthread_equal inline version.
+
+2006-05-15 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/fork.h: Mark __fork_handlers as hidden.
+
+2006-05-11 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_key_create.c (__pthread_key_create): Do away with
+ __pthread_keys_lock.
+
+ * sysdeps/unix/sysv/linux/pthread_setaffinity.c
+ (__kernel_cpumask_size): Mark as hidden.
+ * sysdeps/unix/sysv/linux/pthread_attr_setaffinity.c: Likewise.
+
+ * sem_open.c (__sem_mappings_lock): Mark as hidden.
+ * semaphoreP.h (__sem_mappings_lock): Likewise.
+
+2006-05-10 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_atfork.c: Mark __dso_handle as hidden.
+
+2006-05-09 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #2644]
+ * sysdeps/pthread/unwind-forcedunwind.c: Different solution for
+ the reload problem. Change the one path in pthread_cancel_init
+ which causes the problem. Force gcc to reload. Simplify callers.
+ * sysdeps/unix/sysv/linux/ia64/unwind-forcedunwind.c
+ (_Unwind_GetBSP): Undo last patch.
+
+2006-05-07 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/ia64/unwind-forcedunwind.c: Make sure the
+ function pointer is reloaded after pthread_cancel_init calls.
+
+ [BZ #2644]
+ * sysdeps/pthread/unwind-forcedunwind.c: Make sure functions
+ pointers are reloaded after pthread_cancel_init calls.
+
+2006-05-01 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/allocalim.h (__libc_use_alloca): Mark with
+ __always_inline.
+
+2006-04-27 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/timer_routines.c (timer_helper_thread):
+ Allocate new object which is passed to timer_sigev_thread so that
+ the timer can be deleted before the new thread is scheduled.
+
+2006-04-26 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/x86_64/tls.h: Include <asm/prctl.h> inside [! __ASSEMBLER__].
+
+2006-04-08 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h: Remove branch predicion
+ suffix for conditional jumps.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_trywait.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_barrier_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_wait.S: Likewise.
+
+ * init.c (sigcancel_handler): Compare with correct PID even if the
+ thread is in the middle of a fork call.
+ (sighandler_setxid): Likewise.
+ Reported by Suzuki K P <suzuki@in.ibm.com> .
+
+2006-04-07 Jakub Jelinek <jakub@redhat.com>
+
+ * pthreadP.h (FUTEX_TID_MASK): Sync with kernel.
+
+2006-04-06 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_getattr_np.c (pthread_getattr_np): Close fp if getrlimit
+ fails [Coverity CID 105].
+
+2006-04-05 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/pthread.h: Add nonnull attributes.
+
+2006-04-03 Steven Munroe <sjmunroe@us.ibm.com>
+
+ [BZ #2505]
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h [_ARCH_PWR4]:
+ Define __lll_rel_instr using lwsync.
+
+2006-03-27 Ulrich Drepper <drepper@redhat.com>
+
+ * allocatestack.c (allocate_stack): Always initialize robust_head.
+ * descr.h: Define struct robust_list_head.
+ (struct pthread): Use robust_list_head in robust mutex list definition.
+ Adjust ENQUEUE_MUTEX and DEQUEUE_MUTEX.
+ * init.c [!__ASSUME_SET_ROBUST_LIST] (__set_robust_list_avail): Define.
+ (__pthread_initialize_minimal_internal): Register robust_list with
+ the kernel.
+ * pthreadP.h: Remove PRIVATE_ from PTHREAD_MUTEX_ROBUST_* names.
+ Declare __set_robust_list_avail.
+ * pthread_create.c (start_thread): Register robust_list of new thread.
+ [!__ASSUME_SET_ROBUST_LIST]: If robust_list is not empty wake up
+ waiters.
+ * pthread_mutex_destroy.c: For robust mutexes don't look at the
+ number of users, it's unreliable.
+ * pthread_mutex_init.c: Allow use of pshared robust mutexes if
+ set_robust_list syscall is available.
+ * pthread_mutex_consistent.c: Adjust for PTHREAD_MUTEX_ROBUST_* rename.
+ * pthread_mutex_lock.c: Simplify robust mutex code a bit.
+ Set robust_head.list_op_pending before trying to lock a robust mutex.
+ * pthread_mutex_timedlock.c: Likewise.
+ * pthread_mutex_trylock.c: Likewise.
+ * pthread_mutex_unlock.c: Likewise for unlocking.
+ * Makefile (tests): Add tst-robust8.
+ * tst-robust8.c: New file.
+
+2006-03-08 Andreas Schwab <schwab@suse.de>
+
+ * sysdeps/unix/sysv/linux/ia64/dl-sysdep.h
+ (DL_SYSINFO_IMPLEMENTATION): Add missing newline.
+
+2006-03-05 Roland McGrath <roland@redhat.com>
+
+ * configure (libc_add_on): Disable add-on when $add_ons_automatic = yes
+ and $config_os doesn't match *linux*.
+
+2006-03-05 David S. Miller <davem@sunset.davemloft.net>
+
+ * sysdeps/unix/sysv/linux/sparc/sparc32/pt-vfork.S:
+ Use __syscall_error.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc64/pt-vfork.S: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/Makefile: New file.
+
+2006-03-02 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/aio_misc.h: Various cleanups.
+
+2006-03-01 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
+ (__lll_robust_lock_wait): Also set FUTEX_WAITERS bit if we got the
+ mutex.
+ (__lll_robust_timedlock_wait): Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevelrobustlock.S
+ (__lll_robust_lock_wait): Likewise.
+ (__lll_robust_timedlock_wait): Likewise.
+ * sysdeps/unix/sysv/linux/lowlevelrobustlock.c
+ (__lll_robust_lock_wait): Likewise.
+ (__lll_robust_timedlock_wait): Likewise.
+
+2006-03-01 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/sparc/lowlevellock.h (lll_robust_mutex_dead,
+ lll_robust_mutex_trylock, lll_robust_mutex_lock,
+ lll_robust_mutex_cond_lock, lll_robust_mutex_timedlock,
+ lll_robust_mutex_unlock): Define.
+ (__lll_robust_lock_wait, __lll_robust_timedlock_wait): New prototypes.
+
+2006-02-28 H.J. Lu <hongjiu.lu@intel.com>
+
+ * sysdeps/unix/sysv/linux/ia64/clone2.S: Include <clone2.S>
+ instead of <clone.S>.
+
+2006-02-27 Jakub Jelinek <jakub@redhat.com>
+
+ * Makefile (libpthread-routines): Add
+ pthread_mutexattr_[sg]etprotocol, pthread_mutexattr_[sg]etprioceiling
+ and pthread_mutex_[sg]etprioceiling.
+ * Versions (GLIBC_2.4): Export pthread_mutexattr_getprotocol,
+ pthread_mutexattr_setprotocol, pthread_mutexattr_getprioceiling,
+ pthread_mutexattr_setprioceiling, pthread_mutex_getprioceiling and
+ pthread_mutex_setprioceiling.
+ * sysdeps/pthread/pthread.h (PTHREAD_PRIO_NONE, PTHREAD_PRIO_INHERIT,
+ PTHREAD_PRIO_PROTECT): New enum values.
+ (pthread_mutexattr_getprotocol, pthread_mutexattr_setprotocol,
+ pthread_mutexattr_getprioceiling, pthread_mutexattr_setprioceiling,
+ pthread_mutex_getprioceiling, pthread_mutex_setprioceiling): New
+ prototypes.
+ * pthreadP.h (PTHREAD_MUTEX_PRIO_INHERIT_PRIVATE_NP,
+ PTHREAD_MUTEX_PRIO_PROTECT_PRIVATE_NP): New enum values.
+ (PTHREAD_MUTEX_PRIO_CEILING_SHIFT, PTHREAD_MUTEX_PRIO_CEILING_MASK):
+ Define.
+ (PTHREAD_MUTEXATTR_PROTOCOL_SHIFT, PTHREAD_MUTEXATTR_PROTOCOL_MASK,
+ PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT,
+ PTHREAD_MUTEXATTR_PRIO_CEILING_MASK): Define.
+ (PTHREAD_MUTEXATTR_FLAG_BITS): Or in PTHREAD_MUTEXATTR_PROTOCOL_MASK
+ and PTHREAD_MUTEXATTR_PRIO_CEILING_MASK.
+ * pthread_mutex_init.c (__pthread_mutex_init): For the time being
+ return ENOTSUP for PTHREAD_PRIO_INHERIT or PTHREAD_PRIO_PROTECT
+ protocol mutexes.
+ * pthread_mutex_getprioceiling.c: New file.
+ * pthread_mutex_setprioceiling.c: New file.
+ * pthread_mutexattr_getprioceiling.c: New file.
+ * pthread_mutexattr_setprioceiling.c: New file.
+ * pthread_mutexattr_getprotocol.c: New file.
+ * pthread_mutexattr_setprotocol.c: New file.
+
+2006-02-27 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/unix/sysv/linux/aio_misc.h: Include <limits.h>.
+
+2006-02-27 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/pthread/Subdirs: List nptl here too.
+ * configure (libc_add_on_canonical): New variable.
+
+ * sysdeps/unix/sysv/linux/sh/sh4/lowlevellock.h: Use #include_next.
+
+ * sysdeps/unix/sysv/linux/sleep.c: Use #include_next after #include of
+ self to get main source tree's file.
+ * sysdeps/unix/sysv/linux/alpha/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/vfork.S: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/clone2.S: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/s390/s390-32/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/s390/s390-64/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc64/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/clone.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/vfork.S: Likewise.
+
+ * Makefile: Use $(sysdirs) in vpath directive.
+
+ * sysdeps/pthread/Makefile (CFLAGS-libc-start.c): Variable removed.
+ (CPPFLAGS-timer_routines.c): Likewise.
+
+ * Makeconfig (includes): Variable removed.
+
+2006-02-26 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/generic/pt-raise.c: Moved to ...
+ * pt-raise.c: ... here.
+ * sysdeps/generic/lowlevellock.h: Moved to ...
+ * lowlevellock.h: ... here.
+
+2006-02-23 Roland McGrath <roland@redhat.com>
+
+ * descr.h (struct pthread): Add final member `end_padding'.
+ (PTHREAD_STRUCT_END_PADDING): Use it.
+
+2006-02-20 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/mips: Directory removed, saved in ports repository.
+ * sysdeps/unix/sysv/linux/mips: Likewise.
+
+2006-02-18 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-robust1.c: Add second mutex to check that the mutex list is
+ handled correctly.
+
+2006-02-17 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/alpha/lowlevellock.h (lll_robust_mutex_dead,
+ lll_robust_mutex_trylock, lll_robust_mutex_lock,
+ lll_robust_mutex_cond_lock, lll_robust_mutex_timedlock,
+ lll_robust_mutex_unlock): New macros.
+ (__lll_robust_lock_wait, __lll_robust_timedlock_wait): New prototypes.
+ * sysdeps/unix/sysv/linux/s390/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/lowlevelrobustlock.c: New file.
+
+2006-02-17 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.h: Add lll_robust_mutex_*
+ definitions.
+ * sysdeps/unix/sysv/linux/sh/lowlevelrobustlock.S: New file.
+
+2006-02-17 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
+ (lll_robust_mutex_unlock): Avoid unnecessary wakeups.
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h
+ (lll_robust_mutex_unlock): Likewise.
+
+2006-02-13 Jakub Jelinek <jakub@redhat.com>
+
+ * descr.h [!__PTHREAD_MUTEX_HAVE_PREV] (DEQUEUE_MUTEX):
+ Set robust_list.__next rather than robust_list.
+ * sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h
+ (__pthread_list_t): New typedef.
+ (pthread_mutex_t): Replace __next and __prev fields with __list.
+ * sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h
+ (__pthread_list_t): New typedef.
+ (pthread_mutex_t): Replace __next and __prev fields with __list.
+ * sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h
+ (__pthread_list_t, __pthread_slist_t): New typedefs.
+ (pthread_mutex_t): Replace __next and __prev fields with __list.
+ * sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h
+ (__pthread_list_t, __pthread_slist_t): New typedefs.
+ (pthread_mutex_t): Replace __next and __prev fields with __list.
+ * sysdeps/unix/sysv/linux/sparc/bits/pthreadtypes.h
+ (__pthread_list_t, __pthread_slist_t): New typedefs.
+ (pthread_mutex_t): Replace __next and __prev fields with __list.
+ * sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h
+ (__pthread_slist_t): New typedef.
+ (pthread_mutex_t): Replace __next field with __list.
+
+2006-02-15 Ulrich Drepper <drepper@redhat.com>
+
+ * pthreadP.h: Define PTHREAD_MUTEX_INCONSISTENT instead of
+ PTHREAD_MUTEX_OWNERDEAD.
+ (PTHREAD_MUTEX_ROBUST_PRIVATE_NP): Define as 16, not 256.
+ Define FUTEX_WAITERS, FUTEX_OWNER_DIED, FUTEX_TID_MASK.
+ * Makefile (libpthread-routines): Add lowlevelrobustlock.
+ * pthread_create.c (start_thread): Very much simplify robust_list loop.
+ * pthread_mutex_consistent.c: Inconsistent mutex have __owner now set
+ to PTHREAD_MUTEX_INCONSISTENT.
+ * pthread_mutex_destroy.c: Allow destroying of inconsistent mutexes.
+ * pthread_mutex_lock.c: Reimplement robust mutex handling.
+ * pthread_mutex_trylock.c: Likewise.
+ * pthread_mutex_timedlock.c: Likewise.
+ * pthread_mutex_unlock.c: Likewise.
+ * sysdeps/unix/sysv/linux/pthread_mutex_cond_lock.c: Likewise.
+ * sysdeps/unix/sysv/linux/Makefile (gen-as-const-headers): Add
+ lowlevelrobustlock.sym.
+ * sysdeps/unix/sysv/linux/lowlevelrobustlock.sym: New file.
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h: Add lll_robust_mutex_*
+ definitions.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevelrobustlock.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i586/lowlevelrobustlock.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i686/lowlevelrobustlock.S: New file.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S: New file.
+
+2006-02-12 Ulrich Drepper <drepper@redhat.com>
+
+ * allocatestack.c (allocate_stack): Initialize robust_list.
+ * init.c (__pthread_initialize_minimal_internal): Likewise.
+ * descr.h (struct xid_command): Pretty printing.
+ (struct pthread): Use __pthread_list_t or __pthread_slist_t for
+ robust_list. Adjust macros.
+ * pthread_create.c (start_thread): Adjust robust_list handling.
+ * phtread_mutex_unlock.c: Don't allow unlocking from any thread
+ but the owner for all robust mutex types.
+ * sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h: Define
+ __pthread_list_t and __pthread_slist_t. Use them in pthread_mutex_t.
+ * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h: Likewise.
+ * sysdeps/pthread/pthread.h: Adjust mutex initializers.
+
+ * sysdeps/unix/sysv/linux/i386/not-cancel.h: Define openat_not_cancel,
+ openat_not_cancel_3, openat64_not_cancel, and openat64_not_cancel_3.
+
+2006-02-08 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h (lll_futex_wait,
+ lll_futex_timedwait, lll_wait_tid): Add "memory" clobber.
+
+2006-01-20 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.h (lll_futex_wait):
+ Return status.
+ (lll_futex_timed_wait): Define.
+
+2006-01-19 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-cancel4.c: Test ppoll.
+
+2006-01-18 Andreas Jaeger <aj@suse.de>
+
+ [BZ #2167]
+ * sysdeps/unix/sysv/linux/mips/bits/pthreadtypes.h
+ (pthread_mutex_t): Follow changes for other archs. Based on patch
+ by Jim Gifford <patches@jg555.com>.
+
+2006-01-13 Richard Henderson <rth@redhat.com>
+
+ * sysdeps/alpha/tls.h (tcbhead_t): Rename member to __private.
+
+2006-01-10 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/alpha/jmpbuf-unwind.h: File moved to main source tree.
+ * sysdeps/i386/jmpbuf-unwind.h: Likewise.
+ * sysdeps/mips/jmpbuf-unwind.h: Likewise.
+ * sysdeps/powerpc/jmpbuf-unwind.h: Likewise.
+ * sysdeps/s390/jmpbuf-unwind.h: Likewise.
+ * sysdeps/sh/jmpbuf-unwind.h: Likewise.
+ * sysdeps/sparc/sparc32/jmpbuf-unwind.h: Likewise.
+ * sysdeps/sparc/sparc64/jmpbuf-unwind.h: Likewise.
+ * sysdeps/x86_64/jmpbuf-unwind.h: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/jmpbuf-unwind.h: Likewise.
+
+2006-01-09 Roland McGrath <roland@redhat.com>
+
+ * tst-initializers1-c89.c: New file.
+ * tst-initializers1-c99.c: New file.
+ * tst-initializers1-gnu89.c: New file.
+ * tst-initializers1-gnu99.c: New file.
+ * Makefile (tests): Add them.
+ (CFLAGS-tst-initializers1-c89.c): New variable.
+ (CFLAGS-tst-initializers1-c99.c): New variable.
+ (CFLAGS-tst-initializers1-gnu89.c): New variable.
+ (CFLAGS-tst-initializers1-gnu99.c): New variable.
+
+ * sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h (pthread_mutex_t):
+ Use __extension__ on anonymous union definition.
+ * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/bits/pthreadtypes.h: Likewise.
+
+2006-01-08 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h (pthread_mutex_t):
+ Don't give the union a name because it changes the mangled name.
+ Instead name the struct for __data.
+ * sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h (pthread_mutex_t):
+ Likewise.
+ * sysdeps/unix/sysv/linux/sparc/bits/pthreadtypes.h (pthread_mutex_t):
+ Likewise.
+
+2006-01-09 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/sparc/sparc64/jmpbuf-unwind.h (_JMPBUF_UNWINDS_ADJ): Add
+ stack bias to mc_ftp field.
+
+2006-01-07 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/aio_misc.h (AIO_MISC_WAIT): Work around gcc
+ being too clever and reloading the futex value where it shouldn't.
+
+2006-01-06 Ulrich Drepper <drepper@redhat.com>
+
+ * descr.h [!__PTHREAD_MUTEX_HAVE_PREV] (DEQUEUE_MUTEX): Use
+ correct type.
+
+2006-01-06 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h (PSEUDO):
+ Add cfi directives.
+
+2006-01-06 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/ia64/tls.h (tcbhead_t): Rename private member to __private.
+ * sysdeps/ia64/tcb-offsets.sym: Adjust for private->__private
+ rename in tcbhead_t.
+
+ * sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h (pthread_mutex_t):
+ Don't give the union a name because it changes the mangled name.
+ Instead name the struct for __data.
+ * sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h: Likewise.
+ * pthread_create.c (start_thread): Adjust robust mutex free loop.
+ * descr.h (ENQUEUE_MUTEX, DEQUEUE_MUTEX): Adjust.
+
+2006-01-05 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h (lll_futex_wait):
+ Return status.
+ (lll_futex_timed_wait): Define.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Likewise.
+ * sysdeps/pthread/aio_misc.h: New file.
+
+2006-01-03 Joseph S. Myers <joseph@codesourcery.com>
+
+ * Makefile ($(objpfx)$(multidir)): Use mkdir -p.
+
+2006-01-03 Steven Munroe <sjmunroe@us.ibm.com>
+
+ * sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h
+ (PSEUDO): Remove redundant cfi_startproc and cfi_endproc directives.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h: Likewise.
+
+2006-01-04 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-cancel24.cc: Use C headers instead of C++ headers.
+
+2006-01-03 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/sparc/lowlevellock.h: Remove #error for
+ sparc-linux configured glibc.
+ (lll_futex_wake_unlock): Define to 1 for sparc-linux configured glibc.
+ (__lll_mutex_trylock, __lll_mutex_cond_trylock, __lll_mutex_lock,
+ __lll_mutex_cond_lock, __lll_mutex_timedlock): Use
+ atomic_compare_and_exchange_val_24_acq instead of
+ atomic_compare_and_exchange_val_acq.
+ (lll_mutex_unlock, lll_mutex_unlock_force): Use atomic_exchange_24_rel
+ instead of atomic_exchange_rel.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/lowlevellock.c: New file.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/pthread_barrier_init.c: New
+ file.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/pthread_barrier_wait.c: New
+ file.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sem_init.c: New file.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sem_post.c: New file.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sem_timedwait.c: New file.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sem_trywait.c: New file.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sem_wait.c: New file.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/pthread_barrier_init.c:
+ New file.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/pthread_barrier_wait.c:
+ New file.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/sem_init.c: New file.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/sem_post.c: New file.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/sem_timedwait.c: New
+ file.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/sem_trywait.c: New
+ file.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/sem_wait.c: New file.
+
+2006-01-03 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/pthread.h [__WORDSIZE==64]: Don't use cast in
+ mutex initializers.
+
+2006-01-02 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/sparc/tls.h (tcbhead_t): Add pointer_guard field.
+ (THREAD_GET_POINTER_GUARD, THREAD_SET_POINTER_GUARD,
+ THREAD_COPY_POINTER_GUARD): Define.
+ * sysdeps/sparc/tcb-offsets.sym (POINTER_GUARD): Define.
+ * sysdeps/sparc/sparc64/jmpbuf-unwind.h: Revert 2005-12-27 changes.
+
+2006-01-01 Ulrich Drepper <drepper@redhat.com>
+
+ * version.c: Update copyright year.
+
+2005-12-29 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/unix/sysv/linux/sh/sysdep-cancel.h: Remove explicit
+ .eh_frame section, use cfi_* directives.
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.S: Add cfi instrumentation.
+
+2005-12-30 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/ia64/jmpbuf-unwind.h: Undo last change for
+ now.
+
+2005-12-29 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/sigaction.c: Removed.
+ * sigaction.c: New file.
+ * sysdeps/unix/sysv/linux/Makefile: Define CFLAGS-sigaction.c.
+
+2005-12-28 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (tests): Add tst-signal7.
+ * tst-signal7.c: New file.
+
+2005-12-27 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/x86_64/jmpbuf-unwind.h (_jmpbuf_sp): New inline function.
+ (_JMPBUF_UNWINDS_ADJ): Use it, to PTR_DEMANGLE before comparison.
+ * sysdeps/alpha/jmpbuf-unwind.h: Likewise.
+ * sysdeps/i386/jmpbuf-unwind.h: Likewise.
+ * sysdeps/mips/jmpbuf-unwind.h: Likewise.
+ * sysdeps/powerpc/jmpbuf-unwind.h: Likewise.
+ * sysdeps/s390/jmpbuf-unwind.h: Likewise.
+ * sysdeps/sh/jmpbuf-unwind.h: Likewise.
+ * sysdeps/sparc/sparc32/jmpbuf-unwind.h: Likewise.
+ * sysdeps/sparc/sparc64/jmpbuf-unwind.h: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/jmpbuf-unwind.h: Likewise.
+
+2005-12-27 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h: Add __next
+ and __prev field to pthread_mutex_t.
+ * sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h: Add __next field
+ to pthread_mutex_t.
+
+2005-12-26 Ulrich Drepper <drepper@redhat.com>
+
+ * pthreadP.h: Define PTHREAD_MUTEX_ROBUST_PRIVATE_NP,
+ PTHREAD_MUTEX_ROBUST_PRIVATE_RECURSIVE_NP,
+ PTHREAD_MUTEX_ROBUST_PRIVATE_ERRORCHECK_NP,
+ PTHREAD_MUTEX_ROBUST_PRIVATE_ADAPTIVE_NP,
+ PTHREAD_MUTEXATTR_FLAG_ROBUST, PTHREAD_MUTEXATTR_FLAG_PSHARED,
+ and PTHREAD_MUTEXATTR_FLAG_BITS.
+ * descr.h (struct pthread): Add robust_list field and define
+ ENQUEUE_MUTEX and DEQUEUE_MUTEX macros.
+ * pthread_mutexattr_getrobust.c: New file.
+ * pthread_mutexattr_setrobust.c: New file.
+ * pthread_mutex_consistent.c: New file.
+ * sysdeps/pthread/pthread.h: Declare pthread_mutexattr_getrobust,
+ pthread_mutexattr_setrobust, and pthread_mutex_consistent.
+ Define PTHREAD_MUTEX_STALLED_NP and PTHREAD_MUTEX_ROBUST_NP.
+ Adjust pthread_mutex_t initializers.
+ * nptl/sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h: Add __next
+ field to pthread_mutex_t.
+ * nptl/sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h: Add __next
+ and __prev field to pthread_mutex_t.
+ * Versions [GLIBC_2.4]: Export pthread_mutexattr_getrobust_np,
+ pthread_mutexattr_setrobust_np, and pthread_mutex_consistent_np.
+ * pthread_mutexattr_getpshared.c: Use PTHREAD_MUTEXATTR_FLAG_PSHARED
+ and PTHREAD_MUTEXATTR_FLAG_BITS macros instead of magic numbers.
+ * pthread_mutexattr_gettype.c: Likewise.
+ * pthread_mutexattr_setpshared.c: Likewise.
+ * pthread_mutexattr_settype.c: Likewise.
+ * pthread_mutex_init.c: Reject robust+pshared attribute for now.
+ Initialize mutex kind according to robust flag.
+ * pthread_mutex_lock.c: Implement local robust mutex.
+ * pthread_mutex_timedlock.c: Likewise.
+ * pthread_mutex_trylock.c: Likewise.
+ * pthread_mutex_unlock.c: Likewise.
+ * pthread_create.c (start_thread): Mark robust mutexes which remained
+ locked as dead.
+ * tst-robust1.c: New file.
+ * tst-robust2.c: New file.
+ * tst-robust3.c: New file.
+ * tst-robust4.c: New file.
+ * tst-robust5.c: New file.
+ * tst-robust6.c: New file.
+ * tst-robust7.c: New file.
+ * Makefile (libpthread-routines): Add pthread_mutexattr_getrobust,
+ pthread_mutexattr_setrobust, and pthread_mutex_consistent.
+ (tests): Add tst-robust1, tst-robust2, tst-robust3, tst-robust4,
+ tst-robust5, tst-robust6, and tst-robust7.
+
+ * tst-typesizes.c: New file.
+ * Makefile (tests): Add tst-typesizes.
+
+ * tst-once3.c: More debug output.
+
+2005-12-24 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_mutex_trylock.c (__pthread_mutex_trylock): Add break
+ missing after last change.
+
+ * version.c: Update copyright year.
+
+2005-12-23 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_mutex_destroy.c: Set mutex type to an invalid value.
+ * pthread_mutex_lock.c: Return EINVAL for invalid mutex type.
+ * pthread_mutex_trylock.c: Likewise.
+ * pthread_mutex_timedlock.c: Likewise.
+ * pthread_mutex_unlock.c: Likewise.
+
+2005-12-22 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/pthread/sigaction.c: Use "" instead of <> to include self,
+ so that #include_next's search location is not reset to the -I..
+ directory where <nptl/...> can be found.
+
+2005-12-22 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #1913]
+ * sysdeps/unix/sysv/linux/i386/i486/sem_wait.S (__new_sem_wait):
+ Fix unwind info. Remove useless branch prediction prefix.
+ * tst-cancel24.cc: New file.
+ * Makefile: Add rules to build and run tst-cancel24.
+
+2005-12-21 Roland McGrath <roland@redhat.com>
+
+ * libc-cancellation.c: Use <> rather than "" #includes.
+ * pt-cleanup.c: Likewise.
+ * pthread_create.c: Likewise.
+ * pthread_join.c: Likewise.
+ * pthread_timedjoin.c: Likewise.
+ * pthread_tryjoin.c: Likewise.
+ * sysdeps/unix/sysv/linux/libc_pthread_init.c: Likewise.
+ * sysdeps/unix/sysv/linux/register-atfork.c: Likewise.
+ * sysdeps/unix/sysv/linux/unregister-atfork.c: Likewise.
+ * unwind.c: Likewise.
+
+2005-12-19 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/sh/tcb-offsets.sym: Add POINTER_GUARD.
+ * sysdeps/sh/tls.h (tcbhead_t): Remove private and add pointer_guard.
+ (THREAD_GET_POINTER_GUARD, THREAD_SET_POINTER_GUARD,
+ THREAD_COPY_POINTER_GUARD): Define.
+
+2005-12-19 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/ia64/tls.h (TLS_PRE_TCB_SIZE): Make room for 2 uintptr_t's
+ rather than one.
+ (THREAD_GET_POINTER_GUARD, THREAD_SET_POINTER_GUARD,
+ THREAD_COPY_POINTER_GUARD): Define.
+ * sysdeps/powerpc/tcb-offsets.sym (POINTER_GUARD): Add.
+ * sysdeps/powerpc/tls.h (tcbhead_t): Add pointer_guard field.
+ (THREAD_GET_POINTER_GUARD, THREAD_SET_POINTER_GUARD,
+ THREAD_COPY_POINTER_GUARD): Define.
+ * sysdeps/s390/tcb-offsets.sym (STACK_GUARD): Add.
+ * sysdeps/s390/tls.h (THREAD_GET_POINTER_GUARD,
+ THREAD_SET_POINTER_GUARD, THREAD_COPY_POINTER_GUARD): Define.
+ * sysdeps/unix/sysv/linux/ia64/__ia64_longjmp.S (__ia64_longjmp):
+ Use PTR_DEMANGLE for B0 if defined.
+
+2005-12-17 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_create.c (__pthread_create_2_1): Use
+ THREAD_COPY_POINTER_GUARD if available.
+ * sysdeps/i386/tcb-offsets.sym: Add POINTER_GUARD.
+ * sysdeps/x86_64/tcb-offsets.sym: Likewise.
+ * sysdeps/i386/tls.h (tcbhead_t): Add pointer_guard.
+ Define THREAD_SET_POINTER_GUARD and THREAD_COPY_POINTER_GUARD.
+ * sysdeps/x86_64/tls.h: Likewise.
+
+2005-12-15 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/unix/sysv/linux/mq_notify.c: Don't use sysdeps/generic.
+
+2005-12-13 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/sigfillset.c: Adjust for files moved out of
+ sysdeps/generic.
+ * errno-loc.c: New file.
+
+2005-12-12 Roland McGrath <roland@redhat.com>
+
+ * init.c (__pthread_initialize_minimal_internal): Do __static_tls_size
+ adjustments before choosing stack size. Update minimum stack size
+ calculation to match allocate_stack change.
+
+2005-12-12 Ulrich Drepper <drepper@redhat.com>
+
+ * allocatestack.c (allocate_stack): Don't demand that there is an
+ additional full page available on the stack beside guard, TLS, the
+ minimum stack.
+
+2005-11-24 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h
+ (__cleanup_fct_attribute): Use __regparm__ not regparm.
+
+ * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h: When
+ compiling 32-bit code we must define __cleanup_fct_attribute.
+
+005-11-24 Jakub Jelinek <jakub@redhat.com>
+
+ [BZ #1920]
+ * sysdeps/pthread/pthread.h (__pthread_unwind_next): Use
+ __attribute__ instead of __attribute.
+ * sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h
+ (__cleanup_fct_attribute): Likewise.
+
+2005-11-17 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/pthread/unwind-forcedunwind.c (pthread_cancel_init): Put
+ a write barrier before writing libgcc_s_getcfa.
+
+2005-11-06 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/configure: Removed.
+
+2005-11-05 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/ia64/pt-initfini.c: Remove trace of
+ optional init_array/fini_array support.
+
+2005-10-24 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/sem_trywait.S: Remove unnecessary
+ versioned_symbol use.
+
+2005-10-16 Roland McGrath <roland@redhat.com>
+
+ * init.c (__pthread_initialize_minimal_internal): Even when using a
+ compile-time default stack size, apply the minimum that allocate_stack
+ will require, and round up to page size.
+
+2005-10-10 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * Makefile ($(test-modules)): Remove static pattern rule.
+
+2005-10-14 Jakub Jelinek <jakub@redhat.com>
+ Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_once.S: Fix stack
+ alignment in callback function.
+ * Makefile: Add rules to build and run tst-align3.
+ * tst-align3.c: New file.
+
+2005-10-03 Jakub Jelinek <jakub@redhat.com>
+
+ * allocatestack.c (setxid_signal_thread): Add
+ INTERNAL_SYSCALL_DECL (err).
+
+2005-10-02 Jakub Jelinek <jakub@redhat.com>
+
+ * allocatestack.c (setxid_signal_thread): Need to use
+ atomic_compare_and_exchange_bool_acq.
+
+2005-10-01 Ulrich Drepper <drepper@redhat.com>
+ Jakub Jelinek <jakub@redhat.com>
+
+ * descr.h: Define SETXID_BIT and SETXID_BITMASK. Adjust
+ CANCEL_RESTMASK.
+ (struct pthread): Move specific_used field to avoid padding.
+ Add setxid_futex field.
+ * init.c (sighandler_setxid): Reset setxid flag and release the
+ setxid futex.
+ * allocatestack.c (setxid_signal_thread): New function. Broken
+ out of the bodies of the two loops in __nptl_setxid. For undetached
+ threads check whether they are exiting and if yes, don't send a signal.
+ (__nptl_setxid): Simplify loops by using setxid_signal_thread.
+ * pthread_create.c (start_thread): For undetached threads, check
+ whether setxid bit is set. If yes, wait until signal has been
+ processed.
+
+ * allocatestack.c (STACK_VARIABLES): Initialize them.
+ * pthread_create.c (__pthread_create_2_1): Initialize pd.
+
+2004-09-02 Jakub Jelinek <jakub@redhat.com>
+
+ * pthread_cond_destroy.c (__pthread_cond_destroy): If there are
+ waiters, awake all waiters on the associated mutex.
+
+2005-09-22 Roland McGrath <roland@redhat.com>
+
+ * perf.c [__x86_64__] (HP_TIMING_NOW): New macro (copied from
+ ../sysdeps/x86_64/hp-timing.h).
+
+2005-08-29 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h (FUTEX_WAKE_OP,
+ FUTEX_OP_CLEAR_WAKE_IF_GT_ONE): Define.
+ (lll_futex_wake_unlock): Define.
+ * sysdeps/unix/sysv/linux/alpha/lowlevellock.h (FUTEX_WAKE_OP,
+ FUTEX_OP_CLEAR_WAKE_IF_GT_ONE): Define.
+ (lll_futex_wake_unlock): Define.
+ * sysdeps/unix/sysv/linux/ia64/lowlevellock.h (FUTEX_WAKE_OP,
+ FUTEX_OP_CLEAR_WAKE_IF_GT_ONE): Define.
+ (lll_futex_wake_unlock): Define.
+ * sysdeps/unix/sysv/linux/s390/lowlevellock.h (FUTEX_WAKE_OP,
+ FUTEX_OP_CLEAR_WAKE_IF_GT_ONE): Define.
+ (lll_futex_wake_unlock): Define.
+ * sysdeps/unix/sysv/linux/sparc/lowlevellock.h (FUTEX_WAKE_OP,
+ FUTEX_OP_CLEAR_WAKE_IF_GT_ONE): Define.
+ (lll_futex_wake_unlock): Define.
+ * sysdeps/pthread/pthread_cond_signal.c (__pthread_cond_signal): Use
+ lll_futex_wake_unlock.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S
+ (FUTEX_WAKE_OP, FUTEX_OP_CLEAR_WAKE_IF_GT_ONE): Define.
+ (__pthread_cond_signal): Use FUTEX_WAKE_OP.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
+ (FUTEX_WAKE_OP, FUTEX_OP_CLEAR_WAKE_IF_GT_ONE): Define.
+ (__pthread_cond_signal): Use FUTEX_WAKE_OP.
+
+2005-09-05 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.S (__lll_mutex_lock_wait):
+ Fix typo in register name.
+
+2005-08-23 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/timer_routines.c (timer_helper_thread):
+ Use __sigfillset. Document that sigfillset does the right thing wrt
+ to SIGSETXID.
+
+2005-07-11 Jakub Jelinek <jakub@redhat.com>
+
+ [BZ #1102]
+ * sysdeps/pthread/pthread.h (PTHREAD_MUTEX_INITIALIZER,
+ PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP,
+ PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP,
+ PTHREAD_MUTEX_ADAPTIVE_NP, PTHREAD_RWLOCK_INITIALIZER,
+ PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP,
+ PTHREAD_COND_INITIALIZER): Supply zeros for all fields
+ in the structure.
+ * Makefile (tests): Add tst-initializers1.
+ (CFLAGS-tst-initializers1.c): Set.
+ * tst-initializers1.c: New test.
+
+2005-07-11 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h (pthread_rwlock_t):
+ Make sure __flags are located at offset 48 from the start of the
+ structure.
+
+2005-07-02 Roland McGrath <roland@redhat.com>
+
+ * Makeconfig: Comment fix.
+
+2005-07-05 Jakub Jelinek <jakub@redhat.com>
+
+ * descr.h (PTHREAD_STRUCT_END_PADDING): Define.
+ * sysdeps/ia64/tls.h (TLS_PRE_TCB_SIZE): If PTHREAD_STRUCT_END_PADDING
+ is smaller than 8 bytes, increase TLS_PRE_TCB_SIZE by 16 bytes.
+ (THREAD_SYSINFO, THREAD_SELF, DB_THREAD_SELF): Don't assume
+ TLS_PRE_TCB_SIZE is sizeof (struct pthread).
+ (THREAD_SET_STACK_GUARD, THREAD_COPY_STACK_GUARD): Define.
+ * sysdeps/ia64/tcb-offsets.sym (PID, TID, MULTIPLE_THREADS_OFFSET):
+ Use TLS_PRE_TCB_SIZE instead of sizeof (struct pthread).
+ * sysdeps/unix/sysv/linux/ia64/createthread.c (TLS_VALUE): Don't
+ assume TLS_PRE_TCB_SIZE is sizeof (struct pthread).
+
+2005-06-25 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/i386/tls.h (tcbhead_t): Add stack_guard field.
+ (THREAD_SET_STACK_GUARD, THREAD_COPY_STACK_GUARD): Define.
+ * sysdeps/x86_64/tls.h (tcbhead_t): Add sysinfo and stack_guard
+ fields.
+ (THREAD_SET_STACK_GUARD, THREAD_COPY_STACK_GUARD): Define.
+ * sysdeps/s390/tls.h (tcbhead_t): Add stack_guard
+ field. Put in sysinfo field unconditionally.
+ (THREAD_SET_STACK_GUARD, THREAD_COPY_STACK_GUARD): Define.
+ * sysdeps/powerpc/tls.h (tcbhead_t): Add stack_guard field.
+ (THREAD_SET_STACK_GUARD, THREAD_COPY_STACK_GUARD): Define.
+ * sysdeps/sparc/tls.h (tcbhead_t): Add sysinfo and stack_guard
+ fields.
+ (THREAD_SET_STACK_GUARD, THREAD_COPY_STACK_GUARD): Define.
+ * pthread_create.c (__pthread_create_2_1): Use
+ THREAD_COPY_STACK_GUARD macro.
+ * Makefile: Add rules to build and run tst-stackguard1{,-static}
+ tests.
+ * tst-stackguard1.c: New file.
+ * tst-stackguard1-static.c: New file.
+
+2005-06-14 Alan Modra <amodra@bigpond.net.au>
+
+ * sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h (PSEUDO):
+ Invoke CGOTSETUP and CGOTRESTORE.
+ (CGOTSETUP, CGOTRESTORE): Define.
+
+2005-05-29 Richard Henderson <rth@redhat.com>
+
+ * tst-cancel4.c (WRITE_BUFFER_SIZE): New.
+ (tf_write, tf_writev): Use it.
+ (do_test): Use socketpair instead of pipe. Set SO_SNDBUF to
+ the system minimum.
+
+2005-05-23 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h
+ [IS_IN_librt] (CENABLE, CDISABLE): Use JUMPTARGET instead of
+ __librt_*_asynccancel@local.
+
+2005-05-17 Alan Modra <amodra@bigpond.net.au>
+
+ * sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h: Delete
+ all occurrences of JUMPTARGET. Instead append @local to labels.
+
+2005-05-20 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/i386/tls.h (TLS_INIT_TCB_SIZE, TLS_INIT_TCB_ALIGN): Define to
+ size/alignment of struct pthread rather than tcbhead_t.
+ * sysdeps/x86_64/tls.h (TLS_INIT_TCB_SIZE, TLS_INIT_TCB_ALIGN):
+ Likewise.
+ * sysdeps/s390/tls.h (TLS_INIT_TCB_SIZE, TLS_INIT_TCB_ALIGN):
+ Likewise.
+ * sysdeps/sparc/tls.h (TLS_INIT_TCB_SIZE, TLS_INIT_TCB_ALIGN):
+ Likewise.
+
+2005-05-19 Richard Henderson <rth@redhat.com>
+
+ * sysdeps/ia64/pthread_spin_lock.c (pthread_spin_lock): Use
+ __sync_val_compare_and_swap, not explicit _si variant.
+ * sysdeps/ia64/pthread_spin_trylock.c (pthread_spin_trylock): Likewise.
+
+2005-05-03 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #915]
+ * sysdeps/pthread/pthread.h: Avoid empty initializers.
+
+2005-05-03 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/sysdep-cancel.h: Remove explicit
+ .eh_frame section, use cfi_* directives.
+
+2005-04-27 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/pthread_getcpuclockid.c: Use <> instead
+ of "" includes.
+
+2005-04-27 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #1075]
+ * tst-cancel17.c (do_test): Add arbitrary factor to make sure
+ aio_write blocks.
+
+2005-04-27 Roland McGrath <roland@redhat.com>
+
+ * Makefile (tests): Remove tst-clock2.
+
+ * sysdeps/unix/sysv/linux/timer_create.c (timer_create): Handle
+ CLOCK_PROCESS_CPUTIME_ID and CLOCK_PROCESS_THREAD_ID specially,
+ translating to the kernel clockid_t for our own process/thread clock.
+
+ * sysdeps/unix/sysv/linux/pthread_getcpuclockid.c: New file.
+
+2005-04-15 Jakub Jelinek <jakub@redhat.com>
+
+ * old_pthread_cond_init.c: Include <errno.h>.
+ (__pthread_cond_init_2_0): Fail with EINVAL if COND_ATTR is
+ process shared or uses clock other than CLOCK_REALTIME.
+ * pthread_cond_init.c (__pthread_cond_init): Remove bogus comment.
+
+2005-04-13 David S. Miller <davem@davemloft.net>
+
+ * sysdeps/sparc/sparc64/jmpbuf-unwind.h: New file.
+ * sysdeps/sparc/sparc64/clone.S: New file.
+
+2005-04-05 Jakub Jelinek <jakub@redhat.com>
+
+ [BZ #1102]
+ * sysdeps/pthread/pthread.h (__pthread_cleanup_routine): Use
+ __inline instead of inline.
+ * sysdeps/pthread/bits/libc-lock.h (__libc_cleanup_routine): Likewise.
+
+2005-03-31 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S: Use
+ functionally equivalent, but shorter instructions.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sem_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_once.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sem_post.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S: Likewise.
+
+2005-03-28 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * sysdeps/mips/Makefile: New file.
+ * sysdeps/mips/nptl-sysdep.S: New file.
+ * sysdeps/mips/tcb-offsets.sym: New file.
+ * sysdeps/mips/pthread_spin_lock.S: New file.
+ * sysdeps/mips/pthread_spin_trylock.S: New file.
+ * sysdeps/mips/pthreaddef.h: New file.
+ * sysdeps/mips/tls.h: New file.
+ * sysdeps/mips/jmpbuf-unwind.h: New file.
+ * sysdeps/unix/sysv/linux/mips/lowlevellock.h: New file.
+ * sysdeps/unix/sysv/linux/mips/bits/pthreadtypes.h: New file.
+ * sysdeps/unix/sysv/linux/mips/bits/semaphore.h: New file.
+ * sysdeps/unix/sysv/linux/mips/pthread_once.c: New file.
+ * sysdeps/unix/sysv/linux/mips/fork.c: New file.
+ * sysdeps/unix/sysv/linux/mips/pt-vfork.S: New file.
+ * sysdeps/unix/sysv/linux/mips/vfork.S: New file.
+ * sysdeps/unix/sysv/linux/mips/clone.S: New file.
+ * sysdeps/unix/sysv/linux/mips/createthread.c: New file.
+ * sysdeps/unix/sysv/linux/mips/sysdep-cancel.h: New file.
+
+2005-03-23 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #1112]
+ * pthread_create.c (__pthread_create_2_1): Rename syscall error
+ variable to scerr.
+
+2005-03-10 Jakub Jelinek <jakub@redhat.com>
+
+ * tst-getpid1.c (do_test): Align stack passed to clone{2,}.
+
+2005-02-25 Roland McGrath <roland@redhat.com>
+
+ * alloca_cutoff.c: Correct license text.
+ * tst-unload.c: Likewise.
+ * sysdeps/pthread/allocalim.h: Likewise.
+ * sysdeps/pthread/pt-initfini.c: Likewise.
+ * sysdeps/pthread/bits/libc-lock.h: Likewise.
+ * sysdeps/pthread/bits/sigthread.h: Likewise.
+ * sysdeps/unix/sysv/linux/bits/local_lim.h: Likewise.
+ * sysdeps/unix/sysv/linux/bits/posix_opt.h: Likewise.
+
+2005-02-16 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/pthread/pthread-functions.h (struct pthread_functions):
+ Use unsigned int * for ptr_nthreads.
+
+2005-02-14 Alan Modra <amodra@bigpond.net.au>
+
+ [BZ #721]
+ * sysdeps/powerpc/tcb-offsets.sym (thread_offsetof): Redefine to suit
+ gcc4.
+
+2005-02-07 Richard Henderson <rth@redhat.com>
+
+ [BZ #787]
+ * sysdeps/pthread/pthread.h (__sigsetjmp): Use pointer as first
+ argument.
+
+2004-11-03 Marcus Brinkmann <marcus@gnu.org>
+
+ * sysdeps/generic/lowlevellock.h (__generic_mutex_unlock): Fix
+ order of arguments in invocation of atomic_add_zero.
+
+2005-01-26 Jakub Jelinek <jakub@redhat.com>
+
+ [BZ #737]
+ * sysdeps/unix/sysv/linux/i386/i486/sem_trywait.S (__new_sem_trywait):
+ Use direct %gs segment access or, if NO_TLS_DIRECT_SEG_REFS,
+ at least gotntpoff relocation and addition.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S (sem_timedwait):
+ Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_post.S (__new_sem_post):
+ Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_wait.S (__new_sem_wait):
+ Likewise.
+
+2005-01-06 Ulrich Drepper <drepper@redhat.com>
+
+ * allocatestack.c (init_one_static_tls): Adjust initialization of DTV
+ entry for static tls deallocation fix.
+ * sysdeps/alpha/tls.h (dtv_t): Change pointer type to be struct which
+ also contains information whether the memory pointed to is static
+ TLS or not.
+ * sysdeps/i386/tls.h: Likewise.
+ * sysdeps/ia64/tls.h: Likewise.
+ * sysdeps/powerpc/tls.h: Likewise.
+ * sysdeps/s390/tls.h: Likewise.
+ * sysdeps/sh/tls.h: Likewise.
+ * sysdeps/sparc/tls.h: Likewise.
+ * sysdeps/x86_64/tls.h: Likewise.
+
+2004-12-27 Ulrich Drepper <drepper@redhat.com>
+
+ * init.c (__pthread_initialize_minimal_internal): Use __sigemptyset.
+
+2004-12-21 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/i386/tls.h (CALL_THREAD_FCT): Maintain 16 byte alignment of
+ %esp.
+ * Makefile (tests): Add tst-align2.
+ * tst-align2.c: New test.
+ * sysdeps/i386/Makefile (CFLAGS-tst-align{,2}.c): Add
+ -mpreferred-stack-boundary=4.
+
+2004-12-18 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/unix/sysv/linux/powerpc/powerpc64/bits/local_lim.h:
+ New file removed withdrawn for the moment.
+
+2004-12-17 Richard Henderson <rth@redhat.com>
+
+ * sysdeps/unix/sysv/linux/alpha/clone.S: New file.
+ * sysdeps/alpha/tcb-offsets.sym (TID_OFFSET): New.
+
+2004-12-16 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/powerpc/powerpc64/bits/local_lim.h: New file.
+ Increased PTHREAD_STACK_MIN.
+
+ * tst-context1.c (stacks): Use bigger stack size.
+
+2004-12-16 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/sparc/sparc32/clone.S: New file.
+ * sysdeps/sparc/tcb-offsets.sym: Add TID.
+
+2004-12-15 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/s390/s390-32/clone.S: New file.
+ * sysdeps/unix/sysv/linux/s390/s390-64/clone.S: New file.
+ * sysdeps/s390/tcb-offsets.sym (TID): Add.
+
+2004-12-15 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S: New file.
+
+2004-12-14 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/powerpc/tcb-offsets.sym: Add TID.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S: New file.
+
+ * tst-getpid1.c: If child crashes, report this first. Print which
+ signal.
+
+2004-12-09 Ulrich Drepper <drepper@redhat.com>
+
+ * init.c (__pthread_initialize_minimal_internal): Also unblock
+ SIGSETXID.
+
+2004-12-01 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/bits/posix_opt.h (_POSIX_CPUTIME,
+ _POSIX_THREAD_CPUTIME): Define to 0.
+ * sysdeps/pthread/timer_create.c (timer_create): Remove unused code
+ handling CLOCK_PROCESS_CPUTIME_ID and CLOCK_THREAD_CPUTIME_ID.
+ * sysdeps/pthread/timer_routines.c (__timer_signal_thread_pclk,
+ __timer_signal_thread_tclk): Remove.
+ (init_module): Remove their initialization.
+ (thread_cleanup): Remove their cleanup assertions.
+ * sysdeps/pthread/posix-timer.h (__timer_signal_thread_pclk,
+ __timer_signal_thread_tclk): Remove.
+ * sysdeps/unix/sysv/linux/i386/bits/posix_opt.h: Removed.
+ * sysdeps/unix/sysv/linux/ia64/bits/posix_opt.h: Removed.
+ * sysdeps/unix/sysv/linux/x86_64/bits/posix_opt.h: Removed.
+
+2004-12-07 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/ia64/tcb-offsets.sym (TID): Add.
+ * sysdeps/unix/sysv/linux/ia64/clone2.S: New file.
+
+ * Makefile (tests): Add tst-getpid2.
+ * tst-getpid1.c (TEST_CLONE_FLAGS): Define.
+ (do_test): Use it. Use __clone2 instead of clone on ia64.
+ * tst-getpid2.c: New test.
+
+2004-12-07 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/unix/sysv/linux/sh/clone.S: New file.
+
+2004-12-04 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (tests): Add tst-getpid1.
+ * tst-getpid1.c: New file.
+ * sysdeps/unix/sysv/linux/i386/clone.S: New file.
+ * sysdeps/unix/sysv/linux/x86_64/clone.S: New file.
+
+2004-12-02 Roland McGrath <roland@redhat.com>
+
+ * Makefile (libpthread-nonshared): Variable removed.
+ ($(objpfx)libpthread_nonshared.a): Target removed.
+ ($(inst_libdir)/libpthread_nonshared.a): Likewise.
+ These are now handled by generic magic from
+ libpthread-static-only-routines being set.
+
+2004-11-27 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/bits/posix_opt.h (_POSIX_PRIORITIZED_IO,
+ _POSIX2_CHAR_TERM, _POSIX_THREAD_PRIO_INHERIT,
+ _POSIX_THREAD_PRIO_PROTECT): Define.
+ * sysdeps/unix/sysv/linux/i386/bits/posix_opt.h: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/bits/posix_opt.h: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/bits/posix_opt.h: Likewise.
+
+2004-11-26 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/bits/posix_opt.h (_POSIX_ADVISORY_INFO,
+ _POSIX_SPORADIC_SERVER, _POSIX_THREAD_SPORADIC_SERVER, _POSIX_TRACE,
+ _POSIX_TRACE_EVENT_FILTER, _POSIX_TRACE_INHERIT, _POSIX_TRACE_LOG,
+ _POSIX_TYPED_MEMORY_OBJECTS, _POSIX_IPV6, _POSIX_RAW_SOCKETS): Define.
+ * sysdeps/unix/sysv/linux/i386/bits/posix_opt.h: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/bits/posix_opt.h: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/bits/posix_opt.h: Likewise.
+
+2004-11-24 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/x86_64/Makefile [nptl]: Define CFLAGS-pthread_create.c.
+
+ * Makefile (libpthread-routines): Add pthread_setschedprio.
+ * Versions [libpthread, GLIBC_2.3.4]: Add pthread_setschedprio.
+ * sysdeps/pthread/pthread.h: Declare pthread_setschedprio.
+ * pthread_setschedprio.c: New file.
+
+2004-11-20 Jakub Jelinek <jakub@redhat.com>
+
+ * pthread_create.c (pthread_cancel): Add PTHREAD_STATIC_FN_REQUIRE.
+ * pthread_cancel.c (pthread_create): Likewise.
+
+ * Makefile (libpthread-routines): Add vars.
+ * sysdeps/pthread/createthread.c (__pthread_multiple_threads): Remove.
+ * init.c (__default_stacksize, __is_smp): Remove.
+ * vars.c: New file.
+ * pthreadP.h (__find_thread_by_id): If !SHARED, add weak_function
+ and define a wrapper macro.
+ (PTHREAD_STATIC_FN_REQUIRE): Define.
+ * allocatestack.c (__find_thread_by_id): Undefine.
+ * pthread_create (__pthread_keys): Remove.
+ (pthread_mutex_lock, pthread_mutex_unlock, pthread_once,
+ pthread_key_create, pthread_setspecific, pthread_getspecific): Add
+ PTHREAD_STATIC_FN_REQUIRE.
+
+2004-11-18 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/sh/tls.h (DB_THREAD_SELF): Set the correct bias
+ parameter to REGISTER macro.
+
+2004-11-17 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/unix/sysv/linux/timer_routines.c (__start_helper_thread):
+ Make sure SIGCANCEL is blocked as well.
+
+2004-11-10 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/pthread/setxid.h: New file.
+ * sysdeps/pthread/pthread-functions.h (HAVE_PTR__NPTL_SETXID): Remove.
+ (struct xid_command): Add forward decl.
+ (struct pthread_functions): Change return type of __nptl_setxid hook
+ to int.
+ * pthreadP.h (__nptl_setxid): Change return type to int.
+ * allocatestack.c (__nptl_setxid): Call INTERNAL_SYSCALL_NCS in the
+ calling thread, return its return value and set errno on failure.
+ * descr.h (struct xid_command): Change id type to long array.
+
+ * Makefile: Add rules to build and test tst-setuid1 and
+ tst-setuid1-static.
+ * tst-setuid1.c: New test.
+ * tst-setuid1-static.c: New test.
+
+2004-11-10 Jakub Jelinek <jakub@redhat.com>
+
+ * Makefile (tests): Add tst-exit3.
+ * tst-exit3.c: New test.
+
+2004-11-09 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (tests): Add tst-exit2.
+ * tst-exit2.c: New file.
+
+2004-11-09 Roland McGrath <roland@redhat.com>
+
+ [BZ #530]
+ * sysdeps/pthread/createthread.c (do_clone): Increment __nptl_nthreads
+ here, before calling clone.
+ * pthread_create.c (start_thread): Don't do it here.
+
+2004-11-02 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/smp.h: Include <errno.h>.
+
+2004-10-29 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/unix/sysv/linux/sh/sem_timedwait.S (sem_timedwait):
+ Set ETIMEDOUT to errno when time is up. Tweak to avoid
+ assembler warning.
+
+2004-10-28 Jakub Jelinek <jakub@redhat.com>
+
+ * pthread_create.c (__pthread_create_2_1): Avoid leaking stacks
+ if sched_priority is not between minprio and maxprio.
+
+2004-10-25 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S
+ (__pthread_cond_timedwait): Use clock_gettime syscall if exists.
+
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.S
+ (__lll_mutex_timedlock_wait): Fix a bad branch condition.
+
+2004-10-24 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/smp.h (is_smp_system): Use
+ not-cancelable I/O functions.
+
+2004-10-21 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.S
+ (__lll_mutex_timedlock_wait): If woken but cannot get the lock,
+ make sure 2 is stored in the futex and we looked at the old value.
+ Fix a few other problems to return the correct value.
+
+2004-10-14 Richard Henderson <rth@redhat.com>
+
+ * sysdeps/alpha/tcb-offsets.sym (thread_offsetof): Redefine to
+ make gcc4 happy.
+
+2004-10-06 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/jmp-unwind.c: Include pthreadP.h instead
+ of pthread-functions.h and pthreaddef.h.
+ * sysdeps/unix/sysv/linux/s390/jmp-unwind.c: Likewise.
+
+ * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h (pthread_cond_t):
+ Change __data.__nwaiters from int to unsigned int.
+
+ * tst-clock2.c (do_test): Don't fail if _POSIX_THREAD_CPUTIME == 0 and
+ sysconf (_SC_THREAD_CPUTIME) returns negative value.
+
+ * allocatestack.c (__find_thread_by_id): Move attribute_hidden
+ before return type.
+
+ * sysdeps/s390/jmpbuf-unwind.h: Include bits/wordsize.h.
+ (JMPBUF_CFA_UNWINDS_ADJ): Subtract 96 resp. 160 bytes from CFA.
+
+2004-10-06 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-cancel4.c (tf_msgrcv): Check for failure in msgget. If the
+ test fails, remove message queue.
+ (tf_msgsnd): Likewise.
+
+2004-10-05 Jakub Jelinek <jakub@redhat.com>
+
+ * tst-clock1.c: Change #ifdef to #if defined.
+ * tst-clock2.c: Likewise.
+ * tst-cond11.c: Likewise.
+
+ * sysdeps/pthread/timer_create.c (timer_create): Use
+ defined _POSIX_CPUTIME && _POSIX_CPUTIME >= 0 instead of
+ defined CLOCK_PROCESS_CPUTIME_ID #ifs and similarly for
+ THREAD_CPUTIME.
+
+2004-10-05 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/bits/posix_opt.h (_POSIX_CPUTIME,
+ _POSIX_THREAD_CPUTIME): Define to 0.
+
+2004-10-04 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/bits/posix_opt.h: Define _POSIX_CPUTIME
+ and _POSIX_THREAD_CPUTIME to zero.
+ * sysdeps/unix/sysv/linux/ia64/bits/posix_opt.h: Likewise.
+ * tst-barrier2.c: Fix testing for POSIX feature.
+ * tst-clock1.c: Likewise.
+ * tst-clock2.c: Likewise.
+ * tst-cond11.c: Likewise.
+ * tst-cond4.c: Likewise.
+ * tst-cond6.c: Likewise.
+ * tst-flock2.c: Likewise.
+ * tst-mutex4.c: Likewise.
+ * tst-mutex9.c: Likewise.
+ * tst-rwlock12.c: Likewise.
+ * tst-rwlock4.c: Likewise.
+ * tst-signal1.c: Likewise.
+ * tst-spin2.c: Likewise.
+ * sysdeps/pthread/posix-timer.h: Likewise.
+ * sysdeps/pthread/timer_create.c: Likewise.
+ * sysdeps/pthread/timer_routines.c: Likewise.
+
+2004-10-01 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
+ (__lll_mutex_timedlock_wait): Address futex correctly.
+
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S
+ (__lll_mutex_timedlock_wait): If woken but cannot get the lock,
+ make sure 2 is stored in the futex and we looked at the old value.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
+ (__lll_mutex_timedlock_wait): Likewise. Fix a few other problems
+ which might very well made the code not working at all before.
+ [BZ #417]
+
+2004-09-28 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/pthread_kill.c (__pthread_kill): Don't
+ allow SIGSETXID to be sent.
+ * sysdeps/pthread/sigaction.c (__sigaction): Don't allow action
+ for SIGSETXID to be defined.
+ * sysdeps/pthread/pthread_sigmask.c (pthread_sigmask): Make sure
+ SIGSETXID cannot be blocked.
+
+ * sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h (pthread_cond_t):
+ Add __extension__ to long long types.
+ * sysdeps/unix/sysv/linux/sparc/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h: Likewise.
+
+2004-09-25 Ulrich Drepper <drepper@redhat.com>
+
+ * descr.h (struct pthread): Add stopped_start field.
+ * sysdeps/pthread/createthread.c (create_thread): Set
+ start_stopped flag in descriptor for new thread appropriately.
+ * pthread_create.c (start_thread): Only take lock to be stopped on
+ startup if stopped_start flag says so.
+
+2004-09-24 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_create.c (__pthread_create_2_1): Remember whether thread
+ is created detached and if yes, do not try to free the stack in case
+ the thread creation failed.
+ * sysdeps/pthread/createthread.c (do_clone): Free stack here if clone
+ call fails. Don't depend on INTERNAL_SYSCALL_ERRNO return zero in
+ case there has been no error. [BZ #405]
+
+ * pthread_create.c (start_thread): Don't wait for scheduler data
+ etc to be set at the beginning of the function. The cancellation
+ infrastructure must have been set up. And enable async
+ cancellation before potentially going to sleep. [BZ #401]
+
+2004-09-20 Ulrich Drepper <drepper@redhat.com>
+
+ * Versions: Remove exports for pthread_set*id_np functions.
+ * sysdeps/pthread/pthread.h: Remove pthread_set*id_np prototypes
+ for now.
+ * Makefile: Don't build pthread_set*id code for now.
+
+2004-09-19 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/allocrtsig.c: Allocate second signal for
+ internal use.
+ * allocatestack.c (__nptl_setxid): New function.
+ * descr.h (struct xid_command): Define type.
+ * init.c (pthread_functions): Add ptr__nptl_setxid initialization.
+ (sighandler_setxid): New function.
+ (__pthread_initialize_minimal): Register sighandler_setxid for
+ SIGCANCEL.
+ * pt-allocrtsig.c: Update comment.
+ * pthreadP.h: Define SIGSETXID. Declare __xidcmd variable.
+ Declare __nptl_setxid.
+ * sysdeps/pthread/pthread-functions.h: Add ptr__nptl_setxid.
+ * sysdeps/pthread/pthread.h: Declare pthread_setgid_np,
+ pthread_setuid_np, pthread_setegid_np, pthread_seteuid_np,
+ pthread_setregid_np, pthread_setreuid_np, pthread_setresgid_np,
+ and pthread_setresuid_np.
+ * pthread_setgid_np.c: New file.
+ * pthread_setuid_np.c: New file.
+ * pthread_setegid_np.c: New file.
+ * pthread_seteuid_np.c: New file.
+ * pthread_setregid_np.c: New file.
+ * pthread_setreuid_np.c: New file.
+ * pthread_setresgid_np.c: New file.
+ * pthread_setresuid_np.c: New file.
+ * Versions [libpthread, GLIBC_2.3.4]: Add pthread_setgid_np,
+ pthread_setuid_np, pthread_setegid_np, pthread_seteuid_np,
+ pthread_setregid_np, pthread_setreuid_np, pthread_setresgid_np,
+ and pthread_setresuid_np.
+ * Makefile (libpthread-routines): Add pthread_setuid, pthread_seteuid,
+ pthread_setreuid, pthread_setresuid, pthread_setgid, pthread_setegid,
+ pthread_setregid, and pthread_setresgid.
+
+2004-09-18 Ulrich Drepper <drepper@redhat.com>
+
+ * allocatestack.c (allocate_stack): Return EAGAIN instead of
+ ENOMEM when out of memory.
+
+2004-09-10 Roland McGrath <roland@redhat.com>
+
+ [BZ #379]
+ * allocatestack.c (allocate_stack): Remove [__ASSUME_CLONE_STOPPED]
+ code, since we don't try to use the broken CLONE_STOPPED any more.
+ * pthread_create.c (start_thread): Likewise.
+
+2004-09-15 Richard Henderson <rth@redhat.com>
+
+ * sysdeps/unix/sysv/linux/alpha/vfork.S: Use libc_hidden_def.
+
+2004-09-01 David Mosberger <davidm@hpl.hp.com>
+
+ * sysdeps/unix/sysv/linux/ia64/jmpbuf-unwind.h
+ (__libc_unwind_longjmp): Delete macro and declare as function.
+ * sysdeps/unix/sysv/linux/ia64/Makefile (sysdep_routines): Mention
+ __ia64_longjmp, sigstack_longjmp, and __sigstack_longjmp for
+ nptl directory.
+ * sysdeps/unix/sysv/linux/ia64/__ia64_longjmp.S: New file.
+ * sysdeps/unix/sysv/linux/ia64/__sigstack_longjmp.c: New file.
+ * sysdeps/unix/sysv/linux/ia64/unwind_longjmp.c: New file.
+
+2004-09-12 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/pthread.h: Make rwlock prototypes available also
+ for __USE_XOPEN2K.
+ * sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h: Define rwlock
+ types also for __USE_XOPEN2K.
+ * sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h: Likewise.
+ [BZ #320]
+
+2004-09-08 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/pthread.h
+ (PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP): Make safe for C++.
+ (PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP): Likewise.
+ (PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP): Likewise.
+ (PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP): Likewise.
+ [BZ #375]
+
+2004-09-07 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h: Allow
+ PSEUDO to be used with . prefix.
+
+ * sysdeps/unix/sysv/linux/alpha/pthread_once.c (__pthread_once):
+ Use atomic_increment instead of atomic_exchange_and_add.
+ * sysdeps/unix/sysv/linux/sparc/pthread_once.c (__pthread_once):
+ Likewise.
+ * sysdeps/unix/sysv/linux/ia64/pthread_once.c (__pthread_once):
+ Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/pthread_once.c (__pthread_once):
+ Likewise.
+
+ * allocatestack.c (allocate_stack): Use atomic_increment_val
+ instead of atomic_exchange_and_add.
+ * sysdeps/unix/sysv/linux/sem_post.c (__new_sem_post): Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/sem_post.c (__new_sem_post):
+ Likewise.
+ * sysdeps/pthread/pthread_barrier_wait.c (pthread_barrier_wait):
+ Likewise.
+
+ * sysdeps/pthread/pthread.h (pthread_once): Remove __THROW since
+ the initialization function might throw.
+
+2005-09-05 Richard Henderson <rth@redhat.com>
+
+ * sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h (SINGLE_THREAD_P):
+ Move definition inside libpthread, libc, librt check. Provide
+ definition for rtld.
+
+2004-09-02 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/alpha/jmpbuf-unwind.h: Define __libc_unwind_longjmp.
+ * sysdeps/i386/jmpbuf-unwind.h: Likewise
+ * sysdeps/powerpc/jmpbuf-unwind.h: Likewise.
+ * sysdeps/s390/jmpbuf-unwind.h: Likewise.
+ * sysdeps/sh/jmpbuf-unwind.h: Likewise.
+ * sysdeps/sparc/sparc32/jmpbuf-unwind.h: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/jmpbuf-unwind.h: Likewise.
+ * sysdeps/x86_64/jmpbuf-unwind.h: Likewise.
+ * unwind.c: Use it.
+
+ * sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h (pthread_cond_t):
+ Rename __data.__clock to __data.__nwaiters, make it unsigned int.
+ * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h (pthread_cond_t):
+ Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S:
+ Decrement __nwaiters. If pthread_cond_destroy has been called and
+ this is the last waiter, signal pthread_cond_destroy caller and
+ avoid using the pthread_cond_t structure after unlock.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Likewise.
+ Read clock type from the least significant bits of __nwaiters instead
+ of __clock.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/internaltypes.h: Define COND_CLOCK_BITS.
+
+2004-08-31 Jakub Jelinek <jakub@redhat.com>
+
+ [BZ #342]
+ * Makefile (tests): Add tst-cond20 and tst-cond21.
+ * tst-cond20.c: New test.
+ * tst-cond21.c: New test.
+ * sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h
+ (pthread_cond_t): Rename __data.__clock to __data.__nwaiters, make
+ it unsigned int.
+ * sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h (pthread_cond_t):
+ Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h
+ (pthread_cond_t): Likewise.
+ * sysdeps/unix/sysv/linux/sparc/bits/pthreadtypes.h (pthread_cond_t):
+ Likewise.
+ * sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h (pthread_cond_t):
+ Likewise.
+ * sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h (pthread_cond_t):
+ Likewise.
+ * sysdeps/unix/sysv/linux/lowlevelcond.sym (cond_clock): Remove.
+ (cond_nwaiters): New.
+ (clock_bits): New.
+ * pthread_cond_destroy.c (__pthread_cond_destroy): Return EBUSY
+ if there are waiters not signalled yet.
+ Wait until all already signalled waiters wake up.
+ * sysdeps/pthread/pthread_cond_wait.c (__condvar_cleanup): Decrement
+ __nwaiters. If pthread_cond_destroy has been called and this is the
+ last waiter, signal pthread_cond_destroy caller and avoid using
+ the pthread_cond_t structure after unlock.
+ (__pthread_cond_wait): Increment __nwaiters in the beginning,
+ decrement it when leaving. If pthread_cond_destroy has been called
+ and this is the last waiter, signal pthread_cond_destroy caller.
+ * sysdeps/pthread/pthread_cond_timedwait.c (__pthread_cond_timedwait):
+ Likewise. Read clock type from the least significant bits of
+ __nwaiters instead of __clock.
+ * pthread_condattr_setclock.c (pthread_condattr_setclock): Check
+ whether clock ID can be encoded in COND_CLOCK_BITS bits.
+ * pthread_condattr_getclock.c (pthread_condattr_getclock): Decode
+ clock type just from the last COND_CLOCK_BITS bits of value.
+ * pthread_cond_init.c (__pthread_cond_init): Initialize __nwaiters
+ instead of __clock, just from second bit of condattr's value.
+
+2004-08-30 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h: Include
+ bits/wordsize.h. Make the header match i386 header when __WORDSIZE
+ != 64.
+ * sysdeps/unix/sysv/linux/x86_64/bits/semaphore.h: Likewise.
+
+2004-08-15 Roland McGrath <roland@frob.com>
+
+ * pthread_atfork.c: Update copyright terms including special exception
+ for these trivial files, which are statically linked into executables
+ that use dynamic linking for the significant library code.
+
+2004-08-09 Jakub Jelinek <jakub@redhat.com>
+
+ * DESIGN-rwlock.txt: Add decreasing of nr_readers_queued to
+ pthread_rwlock_rdlock.
+ * sysdeps/pthread/pthread_rwlock_rdlock (__pthread_rwlock_rdlock):
+ Decrease __nr_readers_queued after reacquiring lock.
+ * sysdeps/pthread/pthread_rwlock_timedrdlock
+ (pthread_rwlock_timedrdlock): Likewise.
+ Reported by Bob Cook <bobcook47@hotmail.com>.
+
+2004-08-11 Jakub Jelinek <jakub@redhat.com>
+
+ * tst-rwlock14.c (tf): Read main thread handle from *ARG
+ before pthread_barrier_wait.
+
+2004-08-07 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S:
+ Remove unnecessary exception handling data.
+
+2004-07-23 Jakub Jelinek <jakub@redhat.com>
+
+ [BZ #284]
+ * sysdeps/pthread/pthread.h (pthread_getcpuclockid): Use __clockid_t
+ instead of clockid_t.
+
+2004-07-21 Roland McGrath <roland@redhat.com>
+
+ * Makefile ($(objpfx)multidir.mk): Use $(make-target-directory).
+
+2004-07-19 Roland McGrath <roland@redhat.com>
+
+ * tst-cancel4.c (tf_waitid): Use WEXITED flag bit if available.
+
+2004-07-02 Roland McGrath <roland@redhat.com>
+
+ * configure: Don't exit.
+
+2004-07-14 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S
+ (__pthread_cond_timedwait): Check for invalid nanosecond in
+ timeout value.
+
+2004-07-07 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile: Add rules to build and run tst-fini1.
+ * tst-fini1.c: New file.
+ * tst-fini1mod.c: New file.
+
+2004-07-05 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/sysdep-cancel.h: Define NO_CANCELLATION
+ if no cancellation support is needed.
+ * sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/sh/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h: Likewise.
+
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h: Define __NR_futex
+ only if not already defined.
+
+2004-07-05 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h (lll_unlock): Use
+ constraint "m" instead of "0" for futex.
+
+ * shlib-versions: Add powerpc64-.*-linux.*.
+
+2004-07-04 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
+ (pthread_rwlock_timedrdlock): Use cmpq instead of cmpl to check
+ for valid tv_nsec.
+ * tst-rwlock14.c (do_test): Test for invalid tv_nsec equal to
+ 1 billion and 64-bit tv_nsec which is valid when truncated to 32
+ bits.
+
+2004-06-29 Roland McGrath <roland@redhat.com>
+
+ * Banner: NPTL no longer has its own version number.
+ * Makefile (nptl-version): Variable removed.
+ * sysdeps/pthread/Makefile (CFLAGS-confstr.c): Set LIBPTHREAD_VERSION
+ using $(version), the glibc version number.
+
+2004-06-29 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/unix/sysv/linux/sh/pthread_once.S (__pthread_once):
+ Fix branch offset for a PLT entry.
+ * sysdeps/unix/sysv/linux/sh/sem_post.S (__new_sem_post):
+ Likewise.
+ * sysdeps/unix/sysv/linux/sh/sem_timedwait.S (sem_timedwait):
+ Likewise.
+ * sysdeps/unix/sysv/linux/sh/sem_trywait.S (__new_sem_trywait):
+ Likewise.
+ * sysdeps/unix/sysv/linux/sh/sem_wait.S (__new_sem_wait):
+ Likewise.
+
+2004-06-28 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/alpha/tcb-offsets.sym (MULTIPLE_THREADS_OFFSET): Define
+ unconditionally.
+
+2004-06-28 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/pthread/pthread_rwlock_timedwrlock.c
+ (pthread_rwlock_timedwrlock): Return EINVAL if tv_nsec is negative,
+ instead of tv_sec.
+ * sysdeps/pthread/pthread_rwlock_timedrdlock.c
+ (pthread_rwlock_timedrdlock): Likewise.
+
+2004-06-22 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/s390/lowlevellock.h (lll_futex_requeue):
+ Set __r7 to val, not mutex.
+
+2004-06-27 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile: Add rules to build tst-rwlock14.
+ * tst-rwlock14.c: New file.
+
+2004-06-24 Boris Hu <boris.hu@intel.com>
+
+ * sysdeps/pthread/pthread_rwlock_timedrdlock.c: Add timeout validation
+ check.
+ * sysdeps/pthread/pthread_rwlock_timedwrlock.c: Likewise.
+
+2004-06-19 Andreas Jaeger <aj@suse.de>
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Fix
+ assembler in last patch.
+
+2004-06-17 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/pthread_cond_timedwait.c
+ (__pthread_cond_timedwait): Also check for negativ nanoseconds.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S
+ (__pthread_cond_timedwait): Check for invalid nanosecond in
+ timeout value.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Likewise.
+ * tst-cond19.c: New file.
+ * Makefile: Add rules to build and run tst-cond19.
+
+2004-06-15 Steven Munroe <sjmunroe@us.ibm.com>
+
+ * tst-context1.c (GUARD_PATTERN): Defined.
+ (tst_context_t): Define struct containing ucontext_t & guard words.
+ (ctx): Declare as an array of tst_context_t.
+ (fct): Verify uc_link & guard words are still valid.
+ (tf): Initialize guard words in ctx. Adjust ctx refs for new struct.
+
+2004-06-13 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h (pthread_cond_t):
+ Add __data.__futex field, reshuffle __data.__clock.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_signal.S
+ (__pthread_cond_signal): Increment __futex at the same time as
+ __wakeup_seq or __total_seq. Pass address of __futex instead of
+ address of low 32-bits of __wakeup_seq to futex syscall.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S
+ (__pthread_cond_wait): Likewise. Pass __futex value from before
+ releasing internal lock to FUTEX_WAIT.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S
+ (__pthread_cond_timedwait): Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_broadcast.S
+ (FUTEX_CMP_REQUEUE): Define.
+ (__pthread_cond_broadcast): Set __futex to 2 * __total_seq.
+ Use FUTEX_CMP_REQUEUE operation instead of FUTEX_REQUEUE.
+ Pass __futex value from before the unlock and __futex address instead
+ of address of low 32-bits of __wakeup_seq to futex syscall.
+ Fallback to FUTEX_WAKE all on any errors.
+
+2004-06-08 Jakub Jelinek <jakub@redhat.com>
+
+ * pthread_mutexattr_getpshared.c (pthread_mutex_getpshared): Fix
+ comment typo.
+ * pthread_mutexattr_gettype.c (pthread_mutexattr_gettype): Likewise.
+ * pthread_mutexattr_init.c (__pthread_mutexattr_init): Likewise.
+ * pthread_mutexattr_settype.c (__pthread_mutexattr_settype): Likewise.
+ * pthread_mutexattr_setpshared.c (pthread_mutexattr_setpshared):
+ Likewise. Reported by Bob Cook <bobcook47@hotmail.com>.
+
+2004-06-11 Martin Schwidefsky <schwidefsky@de.ibm.com>
+
+ * sysdeps/unix/sysv/linux/s390/lowlevellock.h (lll_compare_and_swap):
+ Add memory clobber to inline assembly.
+ (__lll_mutex_trylock): Likewise.
+ (__lll_mutex_cond_trylock): Likewise.
+
+2004-06-07 Martin Schwidefsky <schwidefsky@de.ibm.com>
+
+ * sysdeps/unix/sysv/linux/s390/lowlevellock.h (lll_futex_requeue):
+ Pass val argument as 6th system call argument in %r7.
+
+2004-05-21 Jakub Jelinek <jakub@redhat.com>
+
+ * Makefile (tests): Add tst-cond16.
+ * sysdeps/unix/sysv/linux/lowlevelcond.sym (cond_futex): Add.
+ * pthread_cond_init.c (__pthread_cond_init): Clear __data.__futex.
+ * sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h (pthread_cond_t):
+ Add __data.__futex field, reshuffle __data.__clock.
+ * sysdeps/unix/sysv/linux/i386/pthread_cond_signal.S
+ (__pthread_cond_signal): Increment __futex at the same time as
+ __wakeup_seq or __total_seq. Pass address of __futex instead of
+ address of low 32-bits of __wakeup_seq to futex syscall.
+ * sysdeps/unix/sysv/linux/i386/pthread_cond_wait.S
+ (__pthread_cond_wait): Likewise. Pass __futex value from before
+ releasing internal lock to FUTEX_WAIT.
+ * sysdeps/unix/sysv/linux/i386/pthread_cond_timedwait.S
+ (__pthread_cond_timedwait): Likewise.
+ * sysdeps/unix/sysv/linux/i386/pthread_cond_broadcast.S
+ (FUTEX_CMP_REQUEUE): Define.
+ (__pthread_cond_broadcast): Set __futex to 2 * __total_seq.
+ Use FUTEX_CMP_REQUEUE operation instead of FUTEX_REQUEUE.
+ Pass __futex value from before the unlock and __futex address instead
+ of address of low 32-bits of __wakeup_seq to futex syscall.
+ Fallback to FUTEX_WAKE all on any errors.
+ * sysdeps/unix/sysv/linux/alpha/lowlevellock.h (FUTEX_CMP_REQUEUE):
+ Define.
+ (lll_futex_requeue): Add val argument, use FUTEX_CMP_REQUEUE
+ internally. Return non-zero if error, zero if success.
+ * sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h (pthread_cond_t):
+ Add __data.__futex field, reshuffle __data.__clock.
+ * sysdeps/unix/sysv/linux/s390/lowlevellock.h (FUTEX_CMP_REQUEUE):
+ Define.
+ (lll_futex_requeue): Add val argument, return 1 unconditionally
+ for the time being.
+ * sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h (pthread_cond_t):
+ Add __data.__futex field, reshuffle __data.__clock.
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h (FUTEX_CMP_REQUEUE):
+ Define.
+ (lll_futex_requeue): Add val argument, use FUTEX_CMP_REQUEUE
+ internally. Return non-zero if error, zero if success.
+ * sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h
+ (pthread_cond_t): Add __data.__futex field, reshuffle __data.__clock.
+ * sysdeps/unix/sysv/linux/sparc/lowlevellock.h (FUTEX_CMP_REQUEUE):
+ Define.
+ (lll_futex_requeue): Add val argument, use FUTEX_CMP_REQUEUE
+ internally. Return non-zero if error, zero if success.
+ * sysdeps/unix/sysv/linux/sparc/bits/pthreadtypes.h (pthread_cond_t):
+ Add __data.__futex field, reshuffle __data.__clock.
+ * sysdeps/unix/sysv/linux/ia64/lowlevellock.h (FUTEX_CMP_REQUEUE):
+ Define.
+ (lll_futex_requeue): Add val argument, use FUTEX_CMP_REQUEUE
+ internally. Return non-zero if error, zero if success.
+ * sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h (pthread_cond_t):
+ Add __data.__futex field, reshuffle __data.__clock.
+ * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h (pthread_cond_t):
+ Add __data.__futex field, reshuffle __data.__clock.
+ * sysdeps/pthread/pthread_cond_signal.c (__pthread_cond_signal):
+ Increment __futex at the same time as __wakeup_seq or __total_seq.
+ Pass address of __futex instead of address of low 32-bits of
+ __wakeup_seq to futex syscall.
+ * sysdeps/pthread/pthread_cond_wait.c (__pthread_cond_wait): Likewise.
+ Pass __futex value from before releasing internal lock
+ to FUTEX_WAIT.
+ * sysdeps/pthread/pthread_cond_timedwait.c (__pthread_cond_timedwait):
+ Likewise. Avoid unnecessary shadowing of variables.
+ * sysdeps/pthread/pthread_cond_broadcast.c (__pthread_cond_broadcast):
+ Set __futex to 2 * __total_seq. Pass __futex value from before the
+ unlock and __futex address instead of address of low 32-bits of
+ __wakeup_seq to futex_requeue macro, adjust for new return value
+ meaning.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
+ (__pthread_cond_signal): Increment __futex at the same time as
+ __wakeup_seq or __total_seq. Pass address of __futex instead of
+ address of low 32-bits of __wakeup_seq to futex syscall.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
+ (__pthread_cond_wait): Likewise. Pass __futex value from before
+ releasing internal lock to FUTEX_WAIT.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
+ (__pthread_cond_timedwait): Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
+ (FUTEX_CMP_REQUEUE): Define.
+ (__pthread_cond_broadcast): Set __futex to 2 * __total_seq.
+ Use FUTEX_CMP_REQUEUE operation instead of FUTEX_REQUEUE.
+ Pass __futex value from before the unlock and __futex address instead
+ of address of low 32-bits of __wakeup_seq to futex syscall.
+ Fallback to FUTEX_WAKE all on any errors.
+
+2004-06-03 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.h (lll_mutex_lock):
+ Add nop to align the end of critical section.
+ (lll_mutex_cond_lock, lll_mutex_timedlock): Likewise.
+
+2004-06-01 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h (pthread_cond_t):
+ Add __broadcast_seq field.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_broadcast.S: Mark
+ all waiters as woken with woken_seq and bump broadcast counter.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S: Use new
+ __broadcast_seq. Increment __woken_seq correctly when cleanuped.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S: Likewise.
+ Comment typo fixes. Avoid returning -ETIMEDOUT.
+
+2004-06-01 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S
+ (__condvar_tw_cleanup): Fix access to saved broadcast_seq value.
+ Reported by Kaz Kojima.
+
+2004-05-25 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/aio_misc.h: New file.
+
+2004-05-21 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/pthread/pthread_cond_wait.c (__pthread_cond_wait): Compare
+ __broadcast_seq with bc_seq after acquiring internal lock instead of
+ before it.
+
+2004-05-18 Jakub Jelinek <jakub@redhat.com>
+
+ * Makefile (.NOTPARALLEL): Only serialize make check/xcheck, not
+ compilation.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S
+ (__pthread_cond_timedwait): Avoid returning -ETIMEDOUT.
+ * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h
+ (pthread_cond_t): Add __data.__broadcast_seq field.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
+ (FRAME_SIZE): Define.
+ (__pthread_cond_timedwait): Use it. Store/check broadcast_seq.
+ Comment typo fixes.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S (FRAME_SIZE):
+ Define.
+ (__pthread_cond_wait): Use it. Store/check broadcast_seq. Comment
+ typo fixes.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
+ (__pthread_cond_broadcast): Increment broadcast_seq. Comment typo
+ fixes.
+
+2004-05-18 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/lowlevelcond.sym: Add broadcast_seq entry.
+ * sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h (pthread_cond_t):
+ Add __broadcast_seq field.
+ * sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S: Mark
+ all waiters as woken with woken_seq and bump broadcast counter.
+ * sysdeps/pthread/pthread_cond_broadcast.c: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Use new
+ __broadcast_seq field.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Likewise.
+ * sysdeps/pthread/pthread_cond_wait.c: Likewise.
+ * sysdeps/pthread/pthread_cond_timedwait.c: Likewise.
+ * pthread_cond_init.c: Initialize __broadcast_seq field.
+ * Makefile (tests): Add tst-cond17 and tst-cond18.
+ Add .NOTPARALLEL goal.
+ * tst-cond16.c: New file. From Jakub.
+ * tst-cond17.c: New file. From Jakub.
+ * tst-cond18.c: New file. From Jakub.
+
+2004-05-16 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S: Correct some
+ unwind info.
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S:
+ Parametrize frame size. Correct some unwind info.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Likewise.
+
+2004-05-04 Jakub Jelinek <jakub@redhat.com>
+
+ * tst-stack3.c: Note testing functionality beyond POSIX.
+
+2004-05-04 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h (USE___THREAD):
+ Change conditional from ifdef to if.
+
+2004-04-23 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h (SYSDEP_CANCEL_ERRNO,
+ SYSDEP_CANCEL_ERROR): Define.
+ (PSEUDO): Use it.
+
+2004-05-01 Jakub Jelinek <jakub@redhat.com>
+
+ * Versions (libpthread): Remove __pthread_cleanup_upto@@GLIBC_PRIVATE.
+
+2004-04-20 Jakub Jelinek <jakub@redhat.com>
+
+ * sem_unlink.c (sem_unlink): Change EPERM into EACCES.
+
+2004-04-19 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/unix/sysv/linux/sh/sem_timedwait.S: Add frame info.
+ Use HIDDEN_JUMPTARGET to jump to __pthread_unwind.
+ * sysdeps/unix/sysv/linux/sh/sem_wait.S: Remove unneeded frame
+ info. Use HIDDEN_JUMPTARGET to jump to __pthread_unwind.
+
+2004-04-19 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/timer_routines.c: Make sure helper
+ thread has all signals blocked.
+
+2004-04-18 Andreas Jaeger <aj@suse.de>
+
+ * sysdeps/unix/sysv/linux/x86_64/bits/semaphore.h
+ (SEM_VALUE_MAX): Add missing brace.
+
+2004-04-17 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/pthread/Makefile (tests): Add tst-mqueue8x
+ in rt subdir.
+ (CFLAGS-tst-mqueue8x.c): Add -fexceptions.
+ * sysdeps/pthread/tst-mqueue8x.c: New test.
+ * tst-cancel4.c: Update comment about message queues.
+
+ * sysdeps/pthread/timer_gettime.c (timer_gettime): For expired timer
+ return it_value { 0, 0 }.
+ * sysdeps/pthread/timer_create.c (timer_create): Handle SIGEV_NONE
+ like SIGEV_SIGNAL.
+ * sysdeps/pthread/timer_routines.c (thread_expire_timer): Remove
+ assertion for SIGEV_NONE.
+ (thread_attr_compare): Compare all attributes, not just a partial
+ subset.
+
+2004-04-17 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/mq_notify.c: Include stdlib.h.
+
+2004-04-17 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/alpha/bits/semaphore.h (SEM_VALUE_MAX):
+ Just use a plain number.
+ * sysdeps/unix/sysv/linux/i386/bits/semaphore.h: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/bits/semaphore.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/bits/semaphore.h: Likewise.
+ * sysdeps/unix/sysv/linux/s390/bits/semaphore.h: Likewise.
+ * sysdeps/unix/sysv/linux/sh/bits/semaphore.h: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/bits/semaphore.h: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/bits/semaphore.h: Likewise.
+
+2004-04-16 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S: Remove unneeded
+ frame info.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S: Likewise.
+
+2004-04-15 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/timer_routines.c: Include errno.h.
+ (timer_helper_thread): Use inline rt_sigtimedwait syscall instead
+ of calling sigwaitinfo.
+
+2004-04-16 Ulrich Drepper <drepper@redhat.com>
+
+ * allocatestack.c (allocate_stack): Set reported_guardsize
+ unconditionally.
+ * pthread_getattr_np.c (pthread_getattr_np): Use
+ reported_guardsize instead of guardsize.
+ * descr.h (struct pthread): Add reported_guardsize field.
+
+2004-04-13 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/mq_notify.c: Shut up GCC warning.
+
+2004-04-12 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/mq-notify.c: New file.
+
+2004-04-08 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/bits/local_lim.h (MQ_PRIO_MAX): Define.
+ * sysdeps/unix/sysv/linux/alpha/bits/local_lim.h (MQ_PRIO_MAX): Define.
+ * sysdeps/unix/sysv/linux/ia64/bits/local_lim.h (MQ_PRIO_MAX): Define.
+ * sysdeps/unix/sysv/linux/sparc/bits/local_lim.h (MQ_PRIO_MAX): Define.
+ * sysdeps/unix/sysv/linux/bits/posix_opt.h (_POSIX_MESSAGE_PASSING):
+ Define.
+ * sysdeps/unix/sysv/linux/i386/bits/posix_opt.h
+ (_POSIX_MESSAGE_PASSING): Define.
+ * sysdeps/unix/sysv/linux/ia64/bits/posix_opt.h
+ (_POSIX_MESSAGE_PASSING): Define.
+ * sysdeps/unix/sysv/linux/x86_64/bits/posix_opt.h
+ (_POSIX_MESSAGE_PASSING): Define.
+
+2004-04-04 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-context1.c (fct): Check whether correct stack is used.
+
+2004-04-03 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h: Never use
+ matching constraints for asm mem parameters.
+
+ * tst-clock2.c (tf): Don't define unless needed.
+
+2004-03-30 H.J. Lu <hongjiu.lu@intel.com>
+
+ * Makefile (link-libc-static): Use $(static-gnulib) instead of
+ $(gnulib).
+
+2004-03-30 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/pthread-functions.h: Add ptr__nptl_deallocate_tsd.
+ * init.c (pthread_functions): Add ptr__nptl_deallocate_tsd.
+ * pthreadP.h: Declare __nptl_deallocate_tsd.
+ * pthread_create.c (deallocate_tsd): Remove to __nptl_deallocate_tsd.
+ Adjust caller.
+
+ * Makefile (tests): Add tst-tsd5.
+ * tst-tsd5.c: New file.
+
+2004-03-29 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/pthread_attr_setaffinity.c
+ (__pthread_attr_setaffinity_old): Prepend GLIBC_ to version names
+ is SHLIB_COMPAT check.
+ * sysdeps/unix/sysv/linux/pthread_attr_getaffinity.c
+ (__pthread_attr_getaffinity_old): Likewise.
+ * sysdeps/unix/sysv/linux/pthread_getaffinity.c
+ (__pthread_getaffinity_old): Likewise.
+ * sysdeps/unix/sysv/linux/pthread_setaffinity.c
+ (__pthread_setaffinity_old): Likewise.
+
+2004-03-26 Ulrich Drepper <drepper@redhat.com>
+
+ * allocatestack.c (_make_stacks_executable): Call
+ _dl_make_stack_executable first.
+
+2004-03-24 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/i386/pthread_spin_lock.c (pthread_spin_lock): Use "m"
+ constraint instead of "0".
+
+2004-03-24 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h
+ (lll_mutex_cond_trylock): Define as wrapper around __lll_cond_trylock.
+
+ * sysdeps/unix/sysv/linux/getpid.c (really_getpid): Reorganize
+ code to avoid warning.
+
+2004-03-24 Andreas Jaeger <aj@suse.de>
+
+ * sysdeps/unix/sysv/linux/pthread_attr_setaffinity.c
+ (__pthread_attr_setaffinity_old): Remove const.
+
+2004-03-23 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/smp.h: New file.
+ * sysdeps/unix/sysv/linux/sh/smp.h: New file.
+ * init.c: Define __is_smp.
+ (__pthread_initialize_minimal_internal): Call is_smp_system to
+ initialize __is_smp.
+ * pthreadP.h: Declare __is_smp.
+ Define MAX_ADAPTIVE_COUNT is necessary.
+ * pthread_mutex_init.c: Add comment regarding __spins field.
+ * pthread_mutex_lock.c: Implement adaptive mutex type.
+ * pthread_mutex_timedlock.c: Likewise.
+ * sysdeps/unix/sysv/linux/pthread_mutex_cond_lock.c: Likewise.
+ * sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h (pthread_mutex_t):
+ Add __spins field.
+ * sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h: Define
+ lll_mutex_cond_trylock.
+ * sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h: Likewise.
+ Define BUSY_WAIT_NOP.
+ * sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h: Likewise.
+
+ * tst-mutex5.c: Add support for testing adaptive mutexes.
+ * tst-mutex7.c: Likewise.
+ * tst-mutex5a.c: New file.
+ * tst-mutex7a.c: New file.
+ * Makefile (tests): Add tst-mutex5a and tst-mutex7a.
+
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
+ (__lll_mutex_timedlock_wait): Preserve r8 and r9 since the
+ vgettimeofday call might destroy the content.
+
+ * sysdeps/ia64/pthread_spin_lock.c (pthread_spin_lock): Use hint
+ @pause in the loop.
+
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h (lll_mutex_trylock):
+ No need to restrict type of ret. Make it int. Add comment.
+
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h (lll_mutex_trylock):
+ Remove unnecessary setne instruction.
+
+2004-03-22 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/pthread_getaffinity.c
+ (__pthread_getaffinity_new): Use INT_MAX instead of UINT_MAX.
+ * pthread_getattr_np.c (pthread_getattr_np): Double size every cycle.
+ If realloc fails, break out of the loop.
+
+2004-03-20 Andreas Jaeger <aj@suse.de>
+
+ * sysdeps/unix/sysv/linux/pthread_setaffinity.c
+ (__pthread_setaffinity_old): Fix interface.
+ * sysdeps/unix/sysv/linux/pthread_getaffinity.c
+ (__pthread_getaffinity_old): Likewise.
+
+ * sysdeps/unix/sysv/linux/pthread_setaffinity.c
+ (__pthread_setaffinity_new): Remove duplicate declaration.
+
+2004-03-20 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/unix/sysv/linux/sh/sysdep-cancel.h (CENABLE): Save
+ the return value to a safe register.
+ (CDISABLE): Set the function argument correctly.
+
+2004-03-17 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/unix/sysv/linux/sh/lowlevel-atomic.h (XCHG): Define.
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.S (__lll_mutex_lock_wait):
+ Rewrite so that only one locked memory operation per round is needed.
+ * sysdeps/unix/sysv/linux/sh/pthread_barrier_wait.S
+ (pthread_barrier_wait): After wakeup, release lock only when the
+ last thread stopped using the barrier object.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S
+ (__pthread_cond_wait): Don't store mutex address if the current
+ value is ~0l. Add correct cleanup support and unwind info.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_broadcast.S
+ (__pthread_cond_broadcast): Don't use requeue for pshared condvars.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_signal.S: Update comment.
+ * sysdeps/unix/sysv/linux/sh/pthread_once.S (__pthread_once):
+ Add correct cleanup support and unwind info.
+ * sysdeps/unix/sysv/linux/sh/sem_wait.S (__new_sem_wait): Likewise.
+ * sysdeps/unix/sysv/linux/sh/sysdep-cancel.h: Add unwind
+ information for syscall wrappers.
+
+2004-03-18 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/internaltypes.h (struct pthread_attr): Add
+ cpusetsize field, remove next.
+ * sysdeps/pthread/pthread.h (pthread_getaffinity_np): Add new second
+ parameter for size of the CPU set.
+ (pthread_setaffinity_np): Likewise.
+ (pthread_attr_getaffinity_np): Likewise.
+ (pthread_attr_setaffinity_np): Likewise.
+ * sysdeps/unix/sysv/linux/pthread_attr_getaffinity.c: Implement
+ interface change, keep compatibility code.
+ * sysdeps/unix/sysv/linux/pthread_attr_setaffinity.c: Likewise.
+ * sysdeps/unix/sysv/linux/pthread_getaffinity.c: Likewise.
+ * sysdeps/unix/sysv/linux/pthread_setaffinity.c: Likewise.
+ * pthreadP.h: Remove hidden_proto for pthread_getaffinity_np. Declare
+ __pthread_getaffinity_np.
+ * Versions: Add version for changed interfaces.
+ * tst-attr3.c: Adjust test for interface change.
+ * pthread_getattr_np.c: Query the kernel about the affinity mask with
+ increasing buffer sizes.
+ * pthread_attr_destroy.c: Remove unused list handling.
+ * pthread_attr_init.c: Likewise.
+
+2004-03-17 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/unix/sysv/linux/timer_create.c (timer_create): Pass missing
+ first argument to clock_getres so we ever enable kernel timers.
+
+2004-03-15 Ulrich Weigand <uweigand@de.ibm.com>
+
+ * init.c (nptl_version): Add __attribute_used__ to nptl_version.
+
+2004-03-12 Richard Henderson <rth@redhat.com>
+
+ * sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h: Propagate
+ oldvalue from CENABLE to CDISABLE.
+
+2004-03-12 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/bits/local_lim.h: Define HOST_NAME_MAX.
+ * sysdeps/unix/sysv/linux/alpha/bits/local_lim.h: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/bits/local_lim.h: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/bits/local_lim.h: Likewise.
+
+2004-03-11 Richard Henderson <rth@redhat.com>
+
+ * sysdeps/alpha/tcb-offsets.sym (PID_OFFSET): New.
+ * sysdeps/unix/sysv/linux/alpha/pt-vfork.S: Save/restore PID.
+ * sysdeps/unix/sysv/linux/alpha/vfork.S: New file.
+
+2004-03-11 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/s390/s390-64/vfork.S (__vfork): Use jgnl
+ instead of jnl instruction to jump to SYSCALL_ERROR_LABEL.
+ * sysdeps/unix/sysv/linux/s390/s390-64/pt-vfork.S (__vfork): Likewise.
+
+2004-03-11 Jakub Jelinek <jakub@redhat.com>
+
+ * forward.c (__pthread_cond_broadcast_2_0,
+ __pthread_cond_destroy_2_0, __pthread_cond_init_2_0,
+ __pthread_cond_signal_2_0, __pthread_cond_wait_2_0,
+ __pthread_cond_timedwait_2_0): Use return 0 as defaction instead of 0.
+
+2004-03-11 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/sh/tcb-offsets.sym: Add PID.
+ * sysdeps/unix/sysv/linux/sh/pt-vfork.S: Properly handle PID cache.
+ * sysdeps/unix/sysv/linux/sh/vfork.S: New file.
+
+2004-03-10 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S: No need to
+ include <sysdep-cancel.h>, vfork is no cancellation point.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc64/pt-vfork.S: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc32/pt-vfork.S: Likewise.
+
+2004-03-10 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/s390/s390-32/vfork.S (__vfork): Add
+ libc_hidden_def.
+ * sysdeps/unix/sysv/linux/s390/s390-64/vfork.S (__vfork): Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S (__vfork):
+ Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S (__vfork):
+ Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S (__vfork): Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S (__vfork): Likewise.
+ * sysdeps/unix/sysv/linux/ia64/pt-vfork.S: Include tcb-offsets.h.
+ * sysdeps/unix/sysv/linux/ia64/vfork.S (__vfork): Use DO_CALL instead
+ of DO_CALL_VIA_BREAK. Work around a gas problem.
+
+ * sysdeps/unix/sysv/linux/powerpc/pt-vfork.S: Remove.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S: New file.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc32/pt-vfork.S: New file.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S: New file.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc64/pt-vfork.S: New file.
+ * sysdeps/powerpc/tcb-offsets.sym: Add PID.
+
+ * sysdeps/unix/sysv/linux/ia64/pt-vfork.S (__vfork): Don't use
+ a local register for saving old PID. Negate PID in parent upon exit.
+
+ * sysdeps/unix/sysv/linux/s390/s390-32/pt-vfork.S: Include
+ tcb-offsets.h.
+ (__vfork): Negate PID if non-zero and set to INT_MIN if zero
+ before syscall, set to the old value in the parent afterwards.
+ * sysdeps/unix/sysv/linux/s390/s390-32/vfork.S: New file.
+ * sysdeps/unix/sysv/linux/s390/s390-64/pt-vfork.S: Include
+ tcb-offsets.h.
+ (__vfork): Negate PID if non-zero and set to INT_MIN if zero
+ before syscall, set to the old value in the parent afterwards.
+ * sysdeps/unix/sysv/linux/s390/s390-64/vfork.S: New file.
+ * sysdeps/s390/tcb-offsets.sym: Add PID.
+
+ * sysdeps/unix/sysv/linux/sparc/pt-vfork.S: Remove.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S: New file.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/pt-vfork.S: New file.
+ * sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S: New file.
+ * sysdeps/unix/sysv/linux/sparc/sparc64/pt-vfork.S: New file.
+ * sysdeps/sparc/tcb-offsets.sym: Add PID.
+
+2004-03-10 Andreas Schwab <schwab@suse.de>
+
+ * sysdeps/ia64/tcb-offsets.sym: Add PID.
+ * sysdeps/unix/sysv/linux/ia64/vfork.S: New file.
+ * sysdeps/unix/sysv/linux/ia64/pt-vfork.S: Properly handle PID cache.
+
+2004-03-09 Jakub Jelinek <jakub@redhat.com>
+
+ * tst-cancel20.c (do_one_test): Clear in_sh_body first.
+ * tst-cancel21.c (do_one_test): Likewise.
+ Reported by Gordon Jin <gordon.jin@intel.com>.
+
+2004-02-09 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/vfork.S (SAVE_PID): Negate PID
+ if non-zero and set to INT_MIN if zero.
+ * sysdeps/unix/sysv/linux/x86_64/vfork.S (SAVE_PID): Likewise.
+ * sysdeps/unix/sysv/linux/i386/pt-vfork.S: Include tcb-offsets.h.
+ (SAVE_PID, RESTORE_PID): Define.
+ (__vfork): Use it.
+ * sysdeps/unix/sysv/linux/x86_64/pt-vfork.S: Include tcb-offsets.h.
+ Use relative path to avoid including NPTL i386/vfork.S.
+ (SAVE_PID, RESTORE_PID): Define.
+ * sysdeps/unix/sysv/linux/raise.c: Include limits.h.
+ (raise): Handle THREAD_SELF->pid INT_MIN the same as 0.
+ * Makefile (tests): Add tst-vfork1, tst-vfork2, tst-vfork1x and
+ tst-vfork2x.
+ (tests-reverse): Add tst-vfork1x and tst-vfork2x.
+ * tst-vfork1.c: New test.
+ * tst-vfork2.c: New test.
+ * tst-vfork1x.c: New test.
+ * tst-vfork2x.c: New test.
+
+2004-03-08 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/i386/tcb-offsets.sym: Add PID.
+ * sysdeps/x86_64/tcb-offsets.sym: Likewise.
+ * sysdeps/unix/sysv/linux/i386/vfork.S: New file.
+ * sysdeps/unix/sysv/linux/x86_64/vfork.S: New file.
+
+2004-03-08 Steven Munroe <sjmunroe@us.ibm.com>
+
+ * sysdeps/unix/sysv/linux/powerpc/Versions: Remove leading tabs.
+
+2004-03-08 H.J. Lu <hongjiu.lu@intel.com>
+
+ * sysdeps/s390/tls.h (INIT_SYSINFO): _dl_sysinfo is now in
+ _rtld_global_ro.
+
+2004-03-07 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/ia64/tls.h (INIT_SYSINFO): _dl_sysinfo is now in
+ _rtld_global_ro.
+
+ * tst-once4.c: Remove unnecessary macro definition.
+
+ * tst-mutex7.c (do_test): Limit thread stack size.
+ * tst-once2.c (do_test): Likewise.
+ * tst-tls3.c (do_test): Likewise.
+ * tst-tls1.c (do_test): Likewise.
+ * tst-signal3.c (do_test): Likewise.
+ * tst-kill6.c (do_test): Likewise.
+ * tst-key4.c (do_test): Likewise.
+ * tst-join4.c (do_test): Likewise.
+ * tst-fork1.c (do_test): Likewise.
+ * tst-context1.c (do_test): Likewise.
+ * tst-cond2.c (do_test): Likewise.
+ * tst-cond10.c (do_test): Likewise.
+ * tst-clock2.c (do_test): Likewise.
+ * tst-cancel10.c (do_test): Likewise.
+ * tst-basic2.c (do_test): Likewise.
+ * tst-barrier4.c (do_test): Likewise.
+
+2004-03-05 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/i386/tls.h: Use GLRO instead of GL where appropriate.
+
+2004-03-01 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S
+ (__pthread_cond_timedwait): Optimize wakeup test.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S
+ (__pthread_cond_wait): Likewise.
+ * sysdeps/pthread/pthread_cond_wait.c (__pthread_cond_wait): Likewise.
+ * sysdeps/pthread/pthread_cond_timedwait.c (__pthread_cond_timedwait):
+ Likewise.
+
+2004-02-29 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S
+ (__lll_mutex_lock_wait): Optimize a bit more. Just one copy of
+ the atomic instruction needed.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
+ (__lll_mutex_lock_wait): Likewise.
+
+2004-02-28 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (tests): Add tst-cond14 and tst-cond15.
+ * tst-cond14.c: New file.
+ * tst-cond15.c: New file.
+
+2004-02-27 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/createthread.c (create_thread): Remove use of
+ CLONE_STOPPED. We cannot use SIGCONT which means CLONE_STOPPED
+ needs to be implemented differently to be useful.
+
+2004-02-26 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_attr_setschedparam.c: Don't test priority against limits
+ here. Set ATTR_FLAG_SCHED_SET flag.
+ * pthread_attr_setschedpolicy.c: Set ATTR_FLAG_POLICY_SET flag.
+ * pthread_create.c (__pthread_create_2_1): Copy scheduling attributes
+ from parent thread to child. If attribute is used and scheduling
+ parameters are not inherited, copy parameters from attribute or
+ compute them. Check priority value.
+ * pthread_getschedparam.c: If the parameters aren't known yet get
+ them from the kernel.
+ * pthread_setschedparam.c: Set ATTR_FLAG_SCHED_SET and
+ ATTR_FLAG_POLICY_SET flag for thread.
+ * sysdeps/unix/sysv/linux/internaltypes.h: Define ATTR_FLAG_SCHED_SET
+ and ATTR_FLAG_POLICY_SET.
+
+ * sysdeps/pthread/createthread.c: Use tgkill if possible.
+
+ * pthread_attr_getstackaddr.c (__pthread_attr_getstackaddr): Don't
+ fail if stack address hasn't been set. Just return 0.
+
+2004-02-25 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (tests-nolibpthread): Add tst-unload. Don't link with
+ libpthread for the files in this list.
+ (CFLAGS-tst-unload): Removed.
+ * tst-unload.c (do_test): Don't use complete path for
+ LIBPHREAD_SO.
+
+ * Makefile: Define sonames for tst-tls5mod, tst-_res1mod1, and
+ tst-_res1mod2.
+
+2004-02-22 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S
+ (__lll_mutex_lock_wait): Rewrite so that only one locked memory
+ operation per round is needed.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
+ (__lll_mutex_lock_wait): Likewise.
+
+2004-02-20 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-cancel9.c (cleanup): Don't print to stderr.
+
+2004-02-20 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/sh/jmpbuf-unwind.h (_JMPBUF_UNWINDS_ADJ): Fix variable name.
+
+2004-02-20 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h
+ (__syscall_error_handler2): Call CDISABLE.
+ * sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h
+ (__syscall_error_handler2): Call CDISABLE.
+
+ * sysdeps/pthread/pthread_barrier_wait.c (pthread_barrier_wait):
+ Release lock before the loop, don't reacquire it.
+
+ * sysdeps/unix/sysv/linux/ia64/dl-sysdep.h (DL_ARGV_NOT_RELRO): Define.
+
+2004-02-19 Andreas Schwab <schwab@suse.de>
+
+ * sysdeps/pthread/pthread_barrier_wait.c (pthread_barrier_wait):
+ Fix last change.
+
+2004-02-18 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_barrier_wait.S
+ (pthread_barrier_wait): After wakeup, release lock only when the
+ last thread stopped using the barrier object.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S
+ (pthread_barrier_wait): Likewise.
+ * sysdeps/pthread/pthread_barrier_wait.c (pthread_barrier_wait):
+ Likewise.
+ * Makefile (tests): Add tst-barrier4.
+ * tst-barrier4.c: New file.
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S
+ (__pthread_cond_timedwait): Perform timeout test while holding
+ internal lock to prevent wakeup race.
+ Patch by Dinakar Guniguntala <dgunigun@in.ibm.com>.
+ * sysdeps/pthread/pthread_cond_timedwait.c
+ (__pthread_cond_timedwait): Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
+ (__pthread_cond_timedwait): Likewise.
+
+2004-02-18 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S
+ (__pthread_rwlock_unlock): Access WRITER as 32-bit value.
+ * Makefile (tests): Add tst-rwlock13.
+ * tst-rwlock13.c: New test.
+
+2004-02-16 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S
+ (__condvar_tw_cleanup): Little optimization.
+ Patch by Dinakar Guniguntala <dgunigun@in.ibm.com>.
+
+2004-02-16 Steven Munroe <sjmunroe@us.ibm.com>
+
+ * sysdeps/unix/sysv/linux/powerpc/pt-longjmp.c: Replace libc with
+ libpthread as "lib" parameter to SHLIB_COMPAT.
+ (__novmx_siglongjmp): Fix typo in function name.
+ (__novmx_longjmp): Fix typo in function name.
+
+2004-02-13 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/pthread_cond_wait.c (__pthread_cond_wait): Add a
+ __builtin_expect.
+
+ * sysdeps/generic/pt-longjmp.c: Moved to...
+ * sysdeps/pthread/pt-longjmp.c: ...here. New file.
+
+2004-01-29 Steven Munroe <sjmunroe@us.ibm.com>
+
+ * Makefile (libpthread-routines): Add pt-cleanup.
+ * pt-longjmp.c: Removed.
+ * pt-cleanup.c: Copied __pthread_cleanup_upto to here. New file.
+ * sysdeps/generic/pt-longjmp.c: Copied longjmp to here. New file.
+ * sysdeps/unix/sysv/linux/powerpc/Versions: New file.
+ Version longjmp, siglongjmp for GLIBC_2.3.4.
+ * sysdeps/unix/sysv/linux/powerpc/pt-longjmp.c: New File.
+
+2004-02-13 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/pthread_cond_timedwait.c
+ (__pthread_cond_timedwait): Optimize. Drop internal lock earlier.
+ Reuse code. Add __builtin_expects.
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S
+ (__pthread_cond_timedwait): Get internal lock in case timeout has
+ passed before the futex syscall.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Likewise.
+
+2004-01-20 Ulrich Drepper <drepper@redhat.com>
+
+ * allocatestack.c: Pretty printing.
+
+ * sysdeps/pthread/createthread.c (create_thread): Don't add
+ CLONE_DETACHED bit if it is not necessary.
+
+2004-01-16 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_getattr_np.c: Include ldsodefs.h.
+
+2004-01-16 Richard Henderson <rth@redhat.com>
+
+ * allocatestack.c: Don't declare __libc_stack_end.
+ * init.c (__pthread_initialize_minimal_internal): Likewise.
+ * pthread_getattr_np.c (pthread_getattr_np): Likewise.
+
+2004-01-15 Richard Henderson <rth@redhat.com>
+
+ * sysdeps/alpha/tls.h (tcbhead_t): Add private.
+ (TLS_INIT_TCB_SIZE, TLS_INIT_TCB_ALIGN, TLS_TCB_SIZE,
+ TLS_PRE_TCB_SIZE, TLS_TCB_ALIGN, INSTALL_DTV, INSTALL_NEW_DTV,
+ GET_DTV, THREAD_DTV, THREAD_SELF, DB_THREAD_SELF): Match ia64.
+ (TLS_TCB_OFFSET, THREAD_ID, NO_TLS_OFFSET): Remove.
+ (THREAD_GETMEM, THREAD_GETMEM_NC): Simplify.
+ (THREAD_SETMEM, THREAD_SETMEM_NC): Likewise.
+ * sysdeps/unix/sysv/linux/alpha/createthread.c (TLS_VALUE): Match ia64.
+
+2004-01-14 Ulrich Drepper <drepper@redhat.com>
+
+ * init.c (pthread_functions): Make array const.
+
+2004-01-13 Ulrich Drepper <drepper@redhat.com>
+
+ * allocatestack.c (__make_stacks_executable): Change interface.
+ Check parameters. Pass parameter on to libc counterpart.
+ * pthreadP.h: Change declaration.
+
+2004-01-13 Richard Henderson <rth@redhat.com>
+
+ * pthread_attr_setstack.c (__old_pthread_attr_setstack): Use
+ prototype form.
+ * pthread_attr_setstacksize.c (__old_pthread_attr_setstacksize):
+ Likewise.
+
+ * sysdeps/alpha/Makefile: New file.
+ * sysdeps/alpha/tcb-offsets.sym: New file.
+ * sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h (SINGLE_THREAD_P):
+ Use MULTIPLE_THREADS_OFFSET to implement !libpthread !libc version.
+
+ * sysdeps/unix/sysv/linux/alpha/lowlevellock.h: Rewrite based
+ on powerpc version.
+
+2004-01-08 Jakub Jelinek <jakub@redhat.com>
+
+ * Makefile (tests): Add tst-backtrace1.
+ * tst-backtrace1.c: New test.
+
+2003-12-11 Ulrich Weigand <uweigand@de.ibm.com>
+
+ * sysdeps/alpha/tls.h (DB_THREAD_SELF): Pass bit size of thread
+ register as second parameter to the REGISTER macro.
+ * sysdeps/ia64/tls.h (DB_THREAD_SELF): Likewise.
+ * sysdeps/powerpc/tls.h (DB_THREAD_SELF): Likewise.
+ * sysdeps/sh/tls.h (DB_THREAD_SELF): Likewise.
+ * sysdeps/sparc/tls.h (DB_THREAD_SELF): Likewise.
+ * sysdeps/s390/tls.h (DB_THREAD_SELF): Pass __WORDSIZE as bit size
+ of thread register as second parameter to REGISTER macro in 64 case.
+
+2004-01-03 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/Makefile (CFLAGS-getpid.c): Removed.
+ (CFLAGS-getpid.o): Defined.
+ (CFLAGS-getpid.os): Defined.
+
+2003-12-31 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_getattr_np.c (pthread_getattr_np): Make sure stack info
+ returned for main thread does not overlap with any other VMA.
+ Patch by Jakub Jelinek.
+
+2003-12-29 Jakub Jelinek <jakub@redhat.com>
+
+ * tst-raise1.c: Include stdio.h.
+
+2003-12-23 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/raise.c (raise): Protect pid = selftid
+ setting with __ASSUME_TGKILL || defined __NR_tgkill.
+ If pid is 0, set it to selftid.
+ * sysdeps/unix/sysv/linux/getpid.c (really_getpid): Make inline.
+ Don't set self->pid but self->tid. If self->pid == 0 and self->tid
+ != 0, return self->tid without doing a syscall.
+ * descr.h (struct pthread): Move pid field after tid.
+
+ * Makefile (tests): Add tst-raise1.
+ * tst-raise1.c: New file.
+
+2003-12-23 Roland McGrath <roland@redhat.com>
+
+ * tst-oddstacklimit.c: New file.
+ * Makefile (tests): Add it.
+ (tst-oddstacklimit-ENV): New variable.
+
+ * init.c (__pthread_initialize_minimal_internal): Round stack rlimit
+ value up to page size for __default_stacksize.
+
+2003-12-21 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (tests): Add tst-eintr5.
+ * tst-eintr5.c: New file.
+
+ * eintr.c (eintr_source): Prevent sending signal to self.
+
+ * tst-eintr2.c (tf1): Improve error message.
+
+2003-12-20 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/Makefile (CFLAGS-getpid.c): Define.
+ * sysdeps/unix/sysv/linux/getpid.c: New file.
+ * pthread_cancel.c: Add comment explaining use of PID field.
+ * sysdeps/unix/sysv/linux/pthread_kill.c: Likewise.
+ * pthread_getattr_np.c: Use abs() when comparing PID and TID fields.
+ * sysdeps/unix/sysv/linux/fork.c: Negate PID field of parent
+ temporarily to signal the field must not be relied on and updated
+ by getpid().
+ * sysdeps/unix/sysv/linux/pt-raise.c: Handle case where PID is
+ temporarily negative.
+ * sysdeps/unix/sysv/linux/raise.c: Likewise.
+
+2003-12-19 Ulrich Drepper <drepper@redhat.com>
+
+ * eintr.c (setup_eintr): Add new parameter. Pass to thread function.
+ (eintr_source): If ARG != NULL, use pthread_kill.
+ * tst-eintr1.c: Adjust for this change.
+ * tst-eintr2.c: Likewise.
+ * Makefile (tests): Add tst-eintr3 and tst-eintr4.
+ * tst-eintr3.c: New file.
+ * tst-eintr4.c: New file.
+
+2003-12-19 Jakub Jelinek <jakub@redhat.com>
+
+ * libc-cancellation.c (__libc_enable_asynccancel): Don't cancel
+ if CANCELSTATE_BITMASK is set.
+ * sysdeps/pthread/librt-cancellation.c (__librt_enable_asynccancel):
+ Likewise.
+
+ * Makefile (tests): Add tst-cancel22 and tst-cancel23.
+ (tests-reverse): Add tst-cancel23.
+ * tst-cancel22.c: New test.
+ * tst-cancel23.c: New test.
+
+2003-12-18 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-eintr1.c: Better error messages.
+
+ * Makefile (tests): Add tst-eintr2.
+ * tst-eintr2.c: New file.
+
+2003-12-18 Jakub Jelinek <jakub@redhat.com>
+
+ * Makefile (tests): Add tst-cancel21 and tst-cancelx21.
+ (CFLAGS-tst-cancelx21.c): Set.
+ * tst-cancel21.c: New test.
+ * tst-cancelx21.c: New test.
+
+ * unwind.c (FRAME_LEFT): Add adj argument. Subtract it from each
+ comparison operand.
+ (unwind_stop): Use _JMPBUF_CFA_UNWINDS_ADJ macro instead of
+ _JMPBUF_CFA_UNWINDS. Adjust FRAME_LEFT invocations.
+ * pt-longjmp.c: Include jmpbuf-unwind.h.
+ (__pthread_cleanup_upto): Use _JMPBUF_UNWINDS_ADJ macro instead of
+ _JMPBUF_UNWINDS. Adjust compared pointers.
+ * init.c (__pthread_initialize_minimal_internal): Initialize
+ pd->stackblock_size.
+ * sysdeps/pthread/jmpbuf-unwind.h: Removed.
+ * sysdeps/alpha/jmpbuf-unwind.h: New file.
+ * sysdeps/i386/jmpbuf-unwind.h: New file.
+ * sysdeps/powerpc/jmpbuf-unwind.h: New file.
+ * sysdeps/s390/jmpbuf-unwind.h: New file.
+ * sysdeps/sh/jmpbuf-unwind.h: New file.
+ * sysdeps/sparc/sparc32/jmpbuf-unwind.h: New file.
+ * sysdeps/x86_64/jmpbuf-unwind.h: New file.
+ * sysdeps/unix/sysv/linux/ia64/jmpbuf-unwind.h: Include stdint.h.
+ (_JMPBUF_CFA_UNWINDS): Remove.
+ (_JMPBUF_CFA_UNWINDS_ADJ, _JMPBUF_UNWINDS_ADJ): Define.
+
+2003-12-12 Jakub Jelinek <jakub@redhat.com>
+
+ * Makefile (tests): Add tst-cancel20 and tst-cancelx20.
+ (CFLAGS-tst-cancelx20.c): Set.
+ * tst-cancel20.c: New test.
+ * tst-cancelx20.c: New test.
+
+2003-12-17 Ulrich Drepper <drepper@redhat.com>
+
+ * init.c (__pthread_initialize_minimal_internal): Don't treat
+ architectures with separate register stack special here when
+ computing default stack size.
+
+2003-12-17 Roland McGrath <roland@redhat.com>
+
+ * Makefile (tst-cancelx7-ARGS): New variable.
+ Reportd by Greg Schafer <gschafer@zip.com.au>.
+
+2003-12-17 Jakub Jelinek <jakub@redhat.com>
+
+ * Makefile (tests): Add tst-stack3. Depend on $(objpfx)tst-stack3-mem.
+ (generated): Add tst-stack3.mtrace and tst-stack3-mem.
+ (tst-stack3-ENV): Set.
+ ($(objpfx)tst-stack3-mem): New.
+ * tst-stack3.c: New test.
+
+2003-12-10 David Mosberger <davidm@hpl.hp.com>
+
+ * sysdeps/unix/sysv/linux/ia64/pt-initfini.c (_init_EPILOG_BEGINS):
+ Add unwind directives. Drop unused .regstk directive.
+ (_fini_EPILOG_BEGINS): Add unwind directives.
+
+2003-12-11 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h (lll_futex_wait):
+ Assume parameter is a pointer.
+ (lll_futex_wake): Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h (lll_futex_wait):
+ Likewise.
+ (lll_futex_wake): Likewise.
+ Reported by Boris Hu.
+ * sysdeps/unix/sysv/linux/unregister-atfork.c
+ (__unregister_atfork): Pass pointer to refcntr to lll_futex_wait.
+
+ * sysdeps/unix/sysv/linux/sem_wait.c (__new_sem_wait): Simplify a bit.
+
+2003-12-10 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/bits/libc-lock.h (__rtld_lock_initialize): Define.
+ * sysdeps/unix/sysv/linux/fork.c (__libc_fork): Call
+ __rtld_lock_initialize for ld.so lock.
+ Patch in part by Adam Li <adam.li@intel.com>.
+
+2003-12-02 David Mosberger <davidm@hpl.hp.com>
+
+ * Makefile (link-libc-static): Remove -lgcc_eh---it's already mentioned
+ in $(gnulib). Also, remove stale comment.
+
+2003-11-12 David Mosberger <davidm@hpl.hp.com>
+
+ * sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h (PSEUDO): Take
+ advantage of new syscall stub and optimize accordingly.
+
+ * sysdeps/unix/sysv/linux/ia64/lowlevellock.h (__NR_futex): Rename
+ from SYS_futex, to match expectations of
+ sysdep.h:DO_INLINE_SYSCALL.
+ (lll_futex_clobbers): Remove.
+ (lll_futex_timed_wait): Rewrite in terms of DO_INLINE_SYSCALL.
+ (lll_futex_wake): Likewise.
+ (lll_futex_requeue): Likewise.
+ (__lll_mutex_trylock): Rewrite to a macro, so we can include this
+ file before DO_INLINE_SYSCALL is defined (proposed by Jakub
+ Jelinek).
+ (__lll_mutex_lock): Likewise.
+ (__lll_mutex_cond_lock): Likewise.
+ (__lll_mutex_timed_lock): Likewise.
+ (__lll_mutex_unlock): Likewise.
+ (__lll_mutex_unlock_force): Likewise.
+
+ * sysdeps/ia64/tls.h: Move declaration of __thread_self up so it
+ comes before the include of <sysdep.h>.
+ (THREAD_SELF_SYSINFO): New macro.
+ (THREAD_SYSINFO): Likewise.
+ (INIT_SYSINFO): New macro.
+ (TLS_INIT_TP): Call INIT_SYSINFO.
+
+ * sysdeps/ia64/tcb-offsets.sym: Add SYSINFO_OFFSET.
+
+ * sysdeps/pthread/createthread.c (create_thread): Use
+ THREAD_SELF_SYSINFO and THREAD_SYSINFO instead of open code.
+ * allocatestack.c (allocate_stack): Use THREAD_SYSINFO and
+ THREAD_SELF_SYSINFO instead of open code.
+ * sysdeps/i386/tls.h (THREAD_SELF_SYSINFO): New macro.
+ (THREAD_SYSINFO): Likewise.
+
+ * sysdeps/unix/sysv/linux/ia64/dl-sysdep.h: New file.
+
+ * sysdeps/unix/sysv/linux/ia64/pt-vfork.S: Work around gas problem.
+
+2003-12-06 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/ia64/pt-initfini.c: Use .init_array
+ instead of .init. Patch by David Mosberger.
+
+2003-11-30 Thorsten Kukuk <kukuk@suse.de>
+
+ * sysdeps/pthread/configure.in: Remove broken declaration in C
+ cleanup handling check.
+
+2003-11-30 Andreas Jaeger <aj@suse.de>
+
+ * Makefile (CFLAGS-pt-initfini.s): Add $(fno_unit_at_a_time).
+ * sysdeps/unix/sysv/linux/x86_64/Makefile (CFLAGS-pt-initfini.s):
+ Likewise.
+
+2003-11-27 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/internaltypes.h (ATTR_FLAG_OLDATTR): Define.
+ * pthread_attr_destroy.c: Include shlib-compat.h.
+ (__pthread_attr_destroy): Return immediately if ATTR_FLAG_OLDATTR
+ is set in iattr->flags.
+ * pthread_attr_init.c (__pthread_attr_init_2_0): Set ATTR_FLAG_OLDATTR.
+
+2003-11-21 Jakub Jelinek <jakub@redhat.com>
+
+ * Makefile (distribute): Add tst-cleanup4aux.c.
+
+ * tst-cond12.c (prepare): Add prototype. Move after test-skeleton.c
+ include.
+
+2003-11-21 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-cond12.c (do_test): If USE_COND_SIGNAL is defined, use
+ pthread_cond_signal.
+
+ * sysdeps/pthread/pthread_cond_wait.c (__pthread_cond_wait): Don't
+ store mutex address if the current value is ~0l.
+ * sysdeps/pthread/pthread_cond_timedwait.c
+ (__pthread_cond_timedwait): Likewise.
+ * sysdeps/pthread/pthread_cond_broadcast.c
+ (__pthread_cond_broadcast): Don't use requeue for pshared
+ condvars.
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
+ (__pthread_cond_wait): Don't store mutex address if the current
+ value is ~0l.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
+ (__pthread_cond_timedwait): Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
+ (__pthread_cond_broadcast): Don't use requeue for pshared
+ condvars.
+
+ * pthread_cond_init.c (__pthread_cond_init): Initialize __mutex
+ element with ~0l for pshared condvars, with NULL otherwise.
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S
+ (__pthread_cond_wait): Don't store mutex address if the current
+ value is ~0l.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S
+ (__pthread_cond_timedwait): Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S
+ (__pthread_cond_broadcast): Don't use requeue for pshared
+ condvars.
+
+ * Makefile: Add rules to build and run tst-cond12 and tst-cond13.
+ * tst-cond12.c: New file.
+ * tst-cond13.c: New file.
+
+2003-11-17 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/configure.in: Make missing forced unwind support
+ fatal.
+
+2003-11-11 Ulrich Drepper <drepper@redhat.com>
+
+ * pthreadP.h: Don't declare __pthread_unwind as weak inside libpthread.
+
+2003-11-06 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile: Add magic to clean up correctly.
+
+2003-11-05 Jakub Jelinek <jakub@redhat.com>
+
+ * unwind.c (FRAME_LEFT): Define.
+ (unwind_stop): Handle old style cleanups here.
+ (__pthread_unwind): Handle old style cleanups only if
+ !HAVE_FORCED_UNWIND.
+ * Makefile (tests): Add tst-cleanup4 and tst-cleanupx4.
+ (CFLAGS-tst-cleanupx4.c): Add -fexceptions.
+ ($(objpfx)tst-cleanup4): Depend on $(objpfx)tst-cleanup4aux.o.
+ ($(objpfx)tst-cleanupx4): Likewise.
+ * tst-cleanup4.c: New test.
+ * tst-cleanup4aux.c: New.
+ * tst-cleanupx4.c: New test.
+
+2003-11-04 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/bits/stdio-lock.h: Use lll_*lock instead of
+ lll_mutex_*lock macros to skip atomic operations on some archs.
+
+2003-11-03 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/tst-timer.c (main): Initialize
+ sigev2.sigev_value as well.
+
+2003-10-15 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/pthread/configure.in: Barf if visibility attribute support
+ is missing.
+ * sysdeps/pthread/configure: Regenerated.
+
+2003-10-09 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.h: Completely revamp the
+ locking macros. No distinction between normal and mutex locking
+ anymore.
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.S: Rewrite mutex locking.
+ Merge bits from lowlevelmutex.S we still need.
+ * sysdeps/unix/sysv/linux/sh/libc-lowlevelmutex.S: Remove.
+ * sysdeps/unix/sysv/linux/sh/lowlevelmutex.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/not-cancel.h: New file.
+ * sysdeps/unix/sysv/linux/sh/pthread_barrier_wait.S: Adjust for
+ new mutex implementation.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_broadcast.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_signal.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_rdlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedrdlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedwrlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_unlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_wrlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/sysdep-cancel.h (PSEUDO): Also defined
+ symbol for entry point to avoid cancellation.
+
+2003-10-07 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/sysdep-cancel.h: Backout 2003-10-02
+ changes.
+ (SAVE_OLDTYPE_0): Fix a typo.
+
+2003-10-03 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/pthread_once.S (__pthread_once):
+ Check __sigsetjmp return value. Reported by Daniel Jacobowitz.
+
+2003-10-02 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/sysdep-cancel.h (DOCARGS_1): Use
+ correct offset.
+
+2003-10-02 Jakub Jelinek <jakub@redhat.com>
+
+ * Makefile (tests): Add tst-cancel19.
+ * tst-cancel19.c: New test.
+
+2003-10-02 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/sysdep-cancel.h: Fix saving and
+ restoring of the old cancellation type.
+
+2003-09-30 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/pthread/malloc-machine.h: Remove misleading comment.
+
+2003-09-27 Wolfram Gloger <wg@malloc.de>
+
+ * sysdeps/pthread/malloc-machine.h: New file
+
+2003-09-24 Roland McGrath <roland@redhat.com>
+
+ * allocatestack.c (__make_stacks_executable): Don't ignore return
+ value from _dl_make_stack_executable.
+
+2003-09-24 Ulrich Drepper <drepper@redhat.com>
+
+ * allocatestack.c (__make_stacks_executable): Also change
+ permission of the currently unused stacks.
+
+ * allocatestack.c (change_stack_perm): Split out from
+ __make_stacks_executable.
+ (allocate_stack): If the required permission changed between the time
+ we started preparing the stack and queueing it, change the permission.
+ (__make_stacks_executable): Call change_stack_perm.
+
+ * Makefile: Build tst-execstack-mod locally.
+ * tst-execstack-mod.c: New file.
+
+2003-09-23 Jakub Jelinek <jakub@redhat.com>
+
+ * Makefile (tests): Only add tst-execstack if have-z-execstack is yes.
+
+2003-09-23 Roland McGrath <roland@redhat.com>
+
+ * tst-execstack.c: New file.
+ * Makefile (tests): Add it.
+ ($(objpfx)tst-execstack, $(objpfx)tst-execstack.out): New targets.
+ (LDFLAGS-tst-execstack): New variable.
+
+ * allocatestack.c (allocate_stack): Use GL(dl_stack_flags) to decide
+ whether to use PROT_EXEC for stack mmap.
+ (__make_stacks_executable): New function.
+ * pthreadP.h: Declare it.
+ * init.c (__pthread_initialize_minimal_internal): Set
+ GL(dl_make_stack_executable_hook) to that.
+
+2003-09-22 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Adjust for latest
+ recommendation from AMD re avoidance of lock prefix.
+
+2003-09-22 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/lowlevellock.c (__lll_timedlock_wait): Use
+ lll_futex_timed_wait instead of lll_futex_wait.
+ * sysdeps/unix/sysv/linux/s390/lowlevellock.c: Removed.
+ * sysdeps/unix/sysv/linux/s390/lowlevelmutex.c: Removed.
+ * sysdeps/unix/sysv/linux/s390/libc-lowlevellock.c: Removed.
+ * sysdeps/unix/sysv/linux/s390/libc-lowlevelmutex.c: Removed.
+ * sysdeps/unix/sysv/linux/s390/sem_trywait.c: Removed.
+ * sysdeps/unix/sysv/linux/s390/sem_wait.c: Removed.
+ * sysdeps/unix/sysv/linux/s390/sem_post.c: Removed.
+ * sysdeps/unix/sysv/linux/s390/sem_timedwait.c: Removed.
+ * sysdeps/unix/sysv/linux/s390/lowlevellock.h: Include atomic.h.
+ Completely revamp the locking macros. No distinction between
+ normal and mutex locking anymore.
+ * sysdeps/unix/sysv/linux/sparc/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/lowlevellock.h (__lll_lock_wait,
+ __lll_lock_timedwait): Fix prototypes.
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h (__lll_lock_wait,
+ __lll_lock_timedwait): Likewise.
+ (lll_mutex_lock, lll_mutex_cond_lock): Use _val instead of _bool
+ macros, add __builtin_expect.
+ (lll_mutex_timedlock): Likewise. Fix return value.
+ * sysdeps/unix/sysv/linux/i386/i486/libc-lowlevelmutex.S: Removed.
+ * sysdeps/unix/sysv/linux/i386/i586/libc-lowlevelmutex.S: Removed.
+ * sysdeps/unix/sysv/linux/i386/i586/lowlevelmutex.S: Removed.
+ * sysdeps/unix/sysv/linux/i386/i686/libc-lowlevelmutex.S: Removed.
+ * sysdeps/unix/sysv/linux/i386/i686/lowlevelmutex.S: Removed.
+ * sysdeps/unix/sysv/linux/x86_64/libc-lowlevelmutex.S: Removed.
+ * sysdeps/unix/sysv/linux/lowlevelmutex.c: Removed.
+ * sysdeps/unix/sysv/linux/libc-lowlevelmutex.c: Removed.
+
+2003-09-22 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S
+ (__lll_mutex_lock_wait): Minor optimization to avoid one atomic
+ operation if possible.
+
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Don't play tricks
+ like jumping over the lock prefix.
+
+2003-09-21 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h: Completely revamp the
+ locking macros. No distinction between normal and mutex locking
+ anymore.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S: Rewrite mutex
+ locking. Merge bits from lowlevelmutex.S we still need.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.S: Likewise.
+ * sysdeps/unix/sysv/linux/lowlevellock.c: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevelmutex.S: Removed.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevelmutex.S: Removed.
+ * Makefile (routines): Remove libc-lowlevelmutex.
+ (libpthread-rountines): Remove lowlevelmutex.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_barrier_wait.S: Adjust
+ for new mutex implementation.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_unlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S: Likewise
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S: Likewise.
+ Don't use requeue.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S: Likewise.
+ * sysdeps/pthread/pthread_cond_signal.c: Don't use requeue.
+
+2003-09-20 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h: Don't match memory
+ in parameters of asm with output parameters.
+
+ * pthread_mutex_unlock.c (__pthread_mutex_unlock_usercnt): Change
+ type of DECR parameter to int.
+ * pthreadP.h: Adjust prototype of __pthread_mutex_unlock_usercnt.
+
+2003-09-18 Jakub Jelinek <jakub@redhat.com>
+
+ * tst-attr3.c (tf, do_test): Print stack start/end/size and
+ guardsize for each thread.
+
+2003-09-17 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/pthread/pthread.h (pthread_getattr_np): Clarify usage.
+ * sysdeps/unix/sysv/linux/pthread_attr_setaffinity.c
+ (pthread_attr_setaffinity_np): Handle cpuset == NULL.
+
+ * sysdeps/unix/sysv/linux/pthread_attr_getaffinity.c
+ (pthread_attr_getaffinity_np): Don't segfault if iattr->cpuset is
+ NULL.
+ * pthread_getattr_np.c: Set cpuset using pthread_getaffinity_np.
+ * pthreadP.h (pthread_getaffinity_np): Add hidden_proto.
+ * sysdeps/unix/sysv/linux/pthread_getaffinity.c
+ (pthread_getaffinity_np): Add hidden_def.
+
+ * Makefile (tests): Add tst-attr3.
+ * tst-attr3.c: New test.
+
+ * sysdeps/i386/Makefile (CFLAGS-tst-align.c): Remove.
+
+2003-09-15 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/i386/Makefile (CFLAGS-pthread_create.c,
+ CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
+
+2003-09-17 Jakub Jelinek <jakub@redhat.com>
+
+ * Makefile (CFLAGS-tst-align.c): Add $(stack-align-test-flags).
+ * tst-align.c: Include tst-stack-align.h.
+ (tf, do_test): Use TEST_STACK_ALIGN macro.
+
+2003-09-17 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_attr_init.c (__pthread_attr_init_2_0): Remove unused
+ variable.
+
+2003-09-16 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_getattr_np.c (pthread_getattr_np): Correctly fill in the
+ stack-related values for the initial thread.
+
+2003-09-15 Jakub Jelinek <jakub@redhat.com>
+
+ * Makefile (CFLAGS-pthread_once.c): Add $(uses-callbacks).
+
+2003-09-11 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_mutex_lock.c: Minor code rearrangements.
+
+2003-09-05 Roland McGrath <roland@redhat.com>
+
+ * pthread_create.c (__pthread_pthread_sizeof_descr): Removed.
+ Instead, include ../nptl_db/db_info.c to do its magic.
+ * pthread_key_create.c (__pthread_pthread_keys_max): Removed.
+ (__pthread_pthread_key_2ndlevel_size): Likewise.
+ * sysdeps/alpha/tls.h (DB_THREAD_SELF): New macro.
+ * sysdeps/i386/tls.h (DB_THREAD_SELF): New macro.
+ * sysdeps/ia64/tls.h (DB_THREAD_SELF): New macro.
+ * sysdeps/powerpc/tls.h (DB_THREAD_SELF): New macro.
+ * sysdeps/s390/tls.h (DB_THREAD_SELF): New macro.
+ * sysdeps/sh/tls.h (DB_THREAD_SELF): New macro.
+ * sysdeps/sparc/tls.h (DB_THREAD_SELF): New macro.
+ * sysdeps/x86_64/tls.h (DB_THREAD_SELF): New macro.
+ * sysdeps/alpha/td_ta_map_lwp2thr.c: File removed.
+ * sysdeps/generic/td_ta_map_lwp2thr.c: File removed.
+ * sysdeps/i386/td_ta_map_lwp2thr.c: File removed.
+ * sysdeps/ia64/td_ta_map_lwp2thr.c: File removed.
+ * sysdeps/powerpc/td_ta_map_lwp2thr.c: File removed.
+ * sysdeps/s390/td_ta_map_lwp2thr.c: File removed.
+ * sysdeps/sh/td_ta_map_lwp2thr.c: File removed.
+ * sysdeps/sparc/td_ta_map_lwp2thr.c: File removed.
+ * sysdeps/x86_64/td_ta_map_lwp2thr.c: File removed.
+
+2003-09-08 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h: Change type
+ of pthread_t to be compatible with LT.
+ * sysdeps/unix/sysv/linux/sparc/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h: Likewise.
+
+2003-09-04 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/not-cancel.h (fcntl_not_cancel): Define.
+
+2003-09-04 Jakub Jelinek <jakub@redhat.com>
+
+ * unwind-forcedunwind.c: Move to...
+ * sysdeps/pthread/unwind-forcedunwind.c: ...here.
+ (pthread_cancel_init): Use ARCH_CANCEL_INIT if defined.
+ * sysdeps/pthread/jmpbuf-unwind.h: New file.
+ * sysdeps/unix/sysv/linux/ia64/unwind-forcedunwind.c: New file.
+ * sysdeps/unix/sysv/linux/ia64/jmpbuf-unwind.h: New file.
+ * unwind.c: Include jmpbuf-unwind.h.
+ (unwind_stop): Use _JMPBUF_CFA_UNWINDS macro.
+
+2003-09-02 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/ia64/bits/local_lim.h: New file.
+ * sysdeps/unix/sysv/linux/ia64/Versions (libpthread): Export
+ pthread_attr_setstack and pthread_attr_setstacksize @@GLIBC_2.3.3.
+ * sysdeps/unix/sysv/linux/alpha/bits/local_lim.h: New file.
+ * sysdeps/unix/sysv/linux/alpha/Versions: New file.
+ * sysdeps/unix/sysv/linux/sparc/bits/local_lim.h: New file.
+ * sysdeps/unix/sysv/linux/sparc/Versions: New file.
+ * pthread_attr_setstack.c (__old_pthread_attr_setstack): New function.
+ (pthread_attr_setstack): If PTHREAD_STACK_MIN != 16384, export
+ as @@GLIBC_2.3.2 and also export compatibility @GLIBC_2.2.
+ * pthread_attr_setstacksize.c (__old_pthread_attr_setstacksize): New
+ function.
+ (pthread_attr_setstacksize): If PTHREAD_STACK_MIN != 16384, export
+ as @@GLIBC_2.3.2 and also export compatibility @GLIBC_2.1.
+ * Makefile (tests): Add tst-stack2.
+ * tst-stack2.c: New test.
+ * tst-stack1.c: Include limits.h and sys/param.h.
+ (do_test): Set size to MAX (4 * getpagesize (), PTHREAD_STACK_MIN).
+
+ * pthread_condattr_setpshared.c: Include errno.h.
+ (pthread_condattr_setpshared): Return EINVAL if pshared
+ is neither PTHREAD_PROCESS_PRIVATE nor PTHREAD_PROCESS_SHARED.
+
+ * sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h (PSEUDO): Also
+ defined symbol for entry point to avoid cancellation.
+ * sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h (PSEUDO):
+ Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h (PSEUDO):
+ Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h (PSEUDO):
+ Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h (PSEUDO):
+ Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h (PSEUDO):
+ Likewise.
+ * sysdeps/unix/sysv/linux/i386/not-cancel.h (__open_nocancel,
+ __close_nocancel, __read_nocancel, __write_nocancel,
+ __waitpid_nocancel): Add attribute_hidden. If not in libc.so,
+ libpthread.so or librt.so, define to corresponding function
+ without _nocancel suffix.
+ * sysdeps/unix/sysv/linux/s390/not-cancel.h: New file.
+ * sysdeps/unix/sysv/linux/powerpc/not-cancel.h: New file.
+ * sysdeps/unix/sysv/linux/sparc/not-cancel.h: New file.
+
+ * sysdeps/unix/sysv/linux/x86_64/not-cancel.h: Fix a typo.
+
+2003-09-02 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/not-cancel.h: New file.
+ * sysdeps/unix/sysv/linux/x86_64/not-cancel.h: New file.
+
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h: Make sure the code
+ in subsections has a symbol associated with it.
+
+ * sysdeps/unix/sysv/linux/i386/sysdep-cancel.h (PSEUDO): Also
+ defined symbol for entry point to avoid cancellation.
+ * sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h (PSEUDO): Likewise.
+
+2003-09-01 Jakub Jelinek <jakub@redhat.com>
+
+ * Makefile (tests): Add tst-tls5.
+ (module-names): Add tst-tls5mod{,a,b,c,d,e,f}.
+ ($(objpfx)tst-tls5mod{,a,b,c,d,e,f}.so-no-z-defs): Set to yes.
+ ($(objpfx)tst-tls5): New.
+ ($(objpfx)tst-tls6.out): Likewise.
+ (tests): Depend on $(objpfx)tst-tls6.out.
+ * tst-tls3.c: Include stdint.h and pthreaddef.h.
+ (do_test): Check pthread_self () return value alignment.
+ * tst-tls3mod.c: Include stdint.h and pthreaddef.h.
+ (tf): Check pthread_self () return value alignment.
+ * tst-tls5.c: New test.
+ * tst-tls5.h: New.
+ * tst-tls5mod.c: New.
+ * tst-tls5moda.c: New.
+ * tst-tls5modb.c: New.
+ * tst-tls5modc.c: New.
+ * tst-tls5modd.c: New.
+ * tst-tls5mode.c: New.
+ * tst-tls5modf.c: New.
+ * tst-tls6.sh: New test.
+
+ * sysdeps/pthread/pthread-functions.h (struct pthread_functions): Add
+ ptr___pthread_cond_timedwait and ptr___pthread_cond_timedwait_2_0.
+ * init.c (pthread_functions): Initialize them.
+ * forward.c (pthread_cond_timedwait@GLIBC_2.0,
+ pthread_cond_timedwait@@GLIBC_2.3.2): New forwards.
+ * Versions (libc): Export pthread_cond_timedwait@GLIBC_2.0,
+ pthread_cond_timedwait@@GLIBC_2.3.2.
+
+2003-09-01 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/alpha/timer_create.c: New file.
+ * sysdeps/unix/sysv/linux/alpha/timer_delete.c: New file.
+ * sysdeps/unix/sysv/linux/alpha/timer_getoverr.c: New file.
+ * sysdeps/unix/sysv/linux/alpha/timer_gettime.c: New file.
+ * sysdeps/unix/sysv/linux/alpha/timer_settime.c: New file.
+ * sysdeps/unix/sysv/linux/alpha/Versions: New file.
+
+ * sysdeps/unix/sysv/linux/alpha/aio_cancel.c: New file.
+
+ * sysdeps/unix/sysv/linux/ia64/bits/posix_opt.h: Define
+ _POSIX_THREAD_PRIORITY_SCHEDULING.
+ * sysdeps/unix/sysv/linux/x86_64/bits/posix_opt.h: Likewise.
+
+2003-08-31 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/bits/stdio-lock.h (_IO_acquire_lock): Avoid
+ nested function, use static inline function from libio.h.
+ Code by Richard Henderson.
+
+ * sysdeps/pthread/bits/libc-lock.h: Mark pthread_setcancelstate as
+ weak.
+
+2003-08-30 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/sparc/sparc64/Versions: New file.
+ * sysdeps/unix/sysv/linux/sparc/sparc64/timer_create.c: New file.
+ * sysdeps/unix/sysv/linux/sparc/sparc64/timer_delete.c: New file.
+ * sysdeps/unix/sysv/linux/sparc/sparc64/timer_getoverr.c: New file.
+ * sysdeps/unix/sysv/linux/sparc/sparc64/timer_gettime.c: New file.
+ * sysdeps/unix/sysv/linux/sparc/sparc64/timer_settime.c: New file.
+ * sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h: New file.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h: New file.
+ * sysdeps/unix/sysv/linux/sparc/bits/pthreadtypes.h: New file.
+ * sysdeps/unix/sysv/linux/sparc/bits/semaphore.h: New file.
+ * sysdeps/unix/sysv/linux/sparc/lowlevellock.h: New file.
+ * sysdeps/unix/sysv/linux/sparc/pthread_once.c: New file.
+ * sysdeps/unix/sysv/linux/sparc/pt-vfork.S: New file.
+ * sysdeps/unix/sysv/linux/sparc/fork.c: New file.
+ * sysdeps/unix/sysv/linux/sparc/aio_cancel.c: New file.
+ * sysdeps/sparc/sparc32/sparcv9/pthread_spin_lock.c: New file.
+ * sysdeps/sparc/sparc32/sparcv9/pthread_spin_trylock.c: New file.
+ * sysdeps/sparc/sparc32/sparcv9/pthread_spin_unlock.c: New file.
+ * sysdeps/sparc/sparc32/pthread_spin_lock.c: New file.
+ * sysdeps/sparc/sparc32/pthread_spin_trylock.c: New file.
+ * sysdeps/sparc/sparc32/pthreaddef.h: New file.
+ * sysdeps/sparc/sparc64/pthread_spin_lock.c: New file.
+ * sysdeps/sparc/sparc64/pthread_spin_trylock.c: New file.
+ * sysdeps/sparc/sparc64/pthread_spin_unlock.c: New file.
+ * sysdeps/sparc/sparc64/pthreaddef.h: New file.
+ * sysdeps/sparc/tls.h: New file.
+ * sysdeps/sparc/tcb-offsets.sym: New file.
+ * sysdeps/sparc/Makefile: New file.
+ * sysdeps/sparc/td_ta_map_lwp2thr.c: New file.
+ * init.c [__sparc__] (__NR_set_tid_address): Define.
+
+2003-08-29 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/pthread/bits/stdio-lock.h (_IO_acquire_lock,
+ _IO_release_lock): Define.
+
+2003-08-29 Jakub Jelinek <jakuB@redhat.com>
+
+ * tst-cancel4.c (tf_sigwait, tf_sigwaitinfo, tf_sigtimedwait): Add
+ sigemptyset before sigaddset. Reported by jreiser@BitWagon.com.
+
+2003-08-27 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/pthread.h (pthread_exit): Remove __THROW.
+ (__pthread_cleanup_class): Add missing return types of member
+ functions.
+
+2003-08-26 Steven Munroe <sjmunroe@us.ibm.com>
+
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h
+ (lll_mutex_unlock_force): Add memory barrier between store and futex
+ syscall.
+
+2003-08-25 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-cancel4.c (do_test): Also unlink tempfname and remove
+ tempmsg in first loop.
+
+2003-08-18 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/bits/posix_opt.h: Define
+ _POSIX_THREAD_PRIORITY_SCHEDULING.
+ * sysdeps/unix/sysv/linux/i386/bits/posix_opt.h: Likewise.
+
+2003-08-07 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/pthread/bits/libc-lock.h [_LIBC && SHARED]
+ (__rtld_lock_default_lock_recursive,
+ __rtld_lock_default_unlock_recursive): Define.
+ [_LIBC && SHARED] (__rtld_lock_lock_recursive,
+ __rtld_lock_unlock_recursive): Define using
+ GL(_dl_rtld_*lock_recursive).
+ * init.c (__pthread_initialize_minimal_internal): Initialize
+ _dl_rtld_lock_recursive and _dl_rtld_unlock_recursive.
+ Lock GL(_dl_load_lock) the same number of times as
+ GL(_dl_load_lock) using non-mt implementation was nested.
+
+ * pthreadP.h (__pthread_cleanup_upto): Add hidden_proto.
+ * pt-longjmp.c (__pthread_cleanup_upto): Add hidden_def.
+
+2003-08-06 Jakub Jelinek <jakub@redhat.com>
+
+ * tst-cancel17.c (do_test): Make len2 maximum of page size and
+ PIPE_BUF.
+
+2003-08-07 Jakub Jelinek <jakub@redhat.com>
+
+ * pthread_create.c (__pthread_create_2_0): Clear new_attr.cpuset.
+
+2003-08-03 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/pthread/createthread.c (do_clone): Move error handling
+ to first syscall error check. Move syscall error check for tkill
+ into __ASSUME_CLONE_STOPPED #ifdef.
+
+2003-08-02 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/createthread.c (do_clone): If __ASSUME_CLONE_STOPPED
+ is not defined, do explicit synchronization.
+ (create_thread): Do not lock pd->lock here. If __ASSUME_CLONE_STOPPED
+ is not defined also unlock pd->lock for non-debugging case in case
+ it is necessary.
+ * pthread_create.c (start_thread): Always get and release pd->lock
+ if __ASSUME_CLONE_STOPPED is not defined.
+ (start_thread_debug): Removed. Adjust users.
+ * allocatestack.c (allocate_stack): Always initialize lock if
+ __ASSUME_CLONE_STOPPED is not defined.
+ * Makefile (tests): Add tst-sched1.
+ * tst-sched1.c: New file.
+
+ * sysdeps/pthread/createthread.c (do_clone): Only use
+ sched_setschduler and pass correct parameters.
+
+2003-07-31 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/pthread/pthread.h (pthread_attr_setstackaddr,
+ pthread_attr_setstacksize): Change PTHREAD_STACK_SIZE to
+ PTHREAD_STACK_MIN in comments.
+
+2003-07-31 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/pthread/pthread_cond_timedwait.c (__pthread_cond_timedwait):
+ Shut up warnings if INTERNAL_SYSCALL_ERROR_P does not use its first
+ argument.
+ * sysdeps/unix/sysv/linux/timer_create.c (timer_create): Likewise.
+ * pthread_condattr_setclock.c (pthread_condattr_setclock): Likewise.
+ * sysdeps/unix/sysv/linux/s390/jmp-unwind.c: Include pthreaddef.h.
+ (__pthread_cleanup_upto): Fix prototype.
+ (_longjmp_unwind): Adjust caller.
+ * sysdeps/unix/sysv/linux/s390/lowlevellock.h (__lll_mutex_timedlock):
+ Change second argument to const struct pointer.
+ * tst-sem8.c (main): Remove unused s2 and s3 variables.
+ * tst-sem9.c (main): Likewise.
+ * unwind.c: Include string.h for strlen prototype.
+
+2003-07-31 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S
+ (__pthread_cond_timedwait): Don't use cmov unless HAVE_CMOV is defined.
+ * sysdeps/unix/sysv/linux/i386/i686/pthread_cond_timedwait.S:
+ Define HAVE_CMOV.
+ Patch by Nicholas Miell <nmiell@attbi.com>.
+
+2003-07-30 Jakub Jelinek <jakub@redhat.com>
+
+ * init.c (__pthread_initialize_minimal_internal): Initialize
+ GL(dl_init_static_tls).
+ * pthreadP.h (__pthread_init_static_tls): New prototype.
+ * allocatestack.c (init_one_static_tls, __pthread_init_static_tls):
+ New functions.
+ * Makefile (tests): Add tst-tls4.
+ (modules-names): Add tst-tls4moda and tst-tls4modb.
+ ($(objpfx)tst-tls4): Link against libdl and libpthread.
+ ($(objpfx)tst-tls4.out): Depend on tst-tls4moda.so and
+ tst-tls4modb.so.
+ * tst-tls4.c: New file.
+ * tst-tls4moda.c: New file.
+ * tst-tls4modb.c: New file.
+
+2003-06-19 Daniel Jacobowitz <drow@mvista.com>
+
+ * sysdeps/pthread/timer_create.c (timer_create): Call timer_delref
+ before __timer_dealloc.
+ * sysdeps/pthread/timer_routines.c (__timer_thread_find_matching):
+ Don't call list_unlink.
+
+2003-07-29 Roland McGrath <roland@redhat.com>
+
+ * Makefile [$(build-shared) = yes] (tests): Depend on $(test-modules).
+
+2003-07-25 Jakub Jelinek <jakub@redhat.com>
+
+ * tst-cancel17.c (do_test): Check if aio_cancel failed.
+ Don't reuse struct aiocb A if it failed.
+ Write fpathconf (fds[1], _PC_PIPE_BUF) + 2 bytes using aio_write,
+ not just one byte, as that does not block.
+
+2003-07-22 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/pthread/unwind-resume.c: New file.
+ * sysdeps/pthread/Makefile (routines, shared-only-routines): Add
+ unwind-resume in csu subdir.
+ (CFLAGS-unwind-resume.c, CFLAGS-rt-unwind-resume.c): Compile with
+ exceptions.
+ (librt-sysdep_routines, librt-shared-only-routines): Add
+ rt-unwind-resume.
+ * sysdeps/pthread/rt-unwind-resume.c: New file.
+ * unwind-forcedunwind.c: New file.
+ * Makefile (libpthread-routines): Add unwind-forcedunwind.
+ (libpthread-shared-only-routines): Likewise.
+ (CFLAGS-unwind-forcedunwind.c): Compile with exceptions.
+ * pthreadP.h (pthread_cancel_init): New prototype.
+ * pthread_cancel.c (pthread_cancel): Call pthread_cancel_init.
+
+ * sysdeps/pthread/createthread.c (do_thread, create_thread): Make
+ attr argument const struct pthread_attr *.
+
+ * res.c (__res_state): Return __resp.
+ * descr.h: Include resolv.h.
+ (struct pthread): Add res field.
+ * pthread_create.c: Include resolv.h.
+ (start_thread): Initialize __resp.
+ * Makefile (tests): Add tst-_res1.
+ (module-names): Add tst-_res1mod1, tst-_res1mod2.
+ ($(objpfx)tst-_res1mod2.so): Depend on $(objpfx)tst-_res1mod1.so.
+ ($(objpfx)tst-_res1): Depend on $(objpfx)tst-_res1mod2.so and
+ libpthread.
+ * tst-_res1.c: New file.
+ * tst-_res1mod1.c: New file.
+ * tst-_res1mod2.c: New file.
+
+2003-07-21 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/createthread.c: Don't define CLONE_STOPPED.
+
+ * Makefile: Define various *-no-z-defs variables for test DSOs
+ which has undefined symbols.
+
+2003-07-21 Steven Munroe <sjmunroe@us.ibm.com>
+
+ * sysdeps/unix/sysv/linux/powerpc/pthread_once.c (__pthread_once):
+ Retry if the stwcx fails to store once_control.
+
+2003-07-20 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (libpthread-routines): Add pthread_attr_getaffinity and
+ pthread_attr_setaffinity.
+ * Versions [libpthread] (GLIBC_2.3.3): Likewise.
+ * sysdeps/unix/sysv/linux/pthread_attr_getaffinity.c: New file.
+ * sysdeps/unix/sysv/linux/pthread_attr_setaffinity.c: New file.
+ * pthread_attr_destroy.c: Free cpuset element if allocated.
+ * pthread_create.c: Pass iattr as additional parameter to
+ create_thread.
+ * sysdeps/pthread/createthread.c: If attribute is provided and
+ a new thread is created with affinity set or scheduling parameters,
+ start thread with CLONE_STOPPED.
+ * sysdeps/pthread/pthread.h: Declare pthread_attr_getaffinity and
+ pthread_attr_setaffinity.
+ * sysdeps/unix/sysv/linux/internaltypes.h (struct pthread_attr): Add
+ cpuset element.
+
+2003-07-15 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-tcancel-wrappers.sh: lseek and llseek are not cancellation points.
+
+2003-07-14 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/configure.in: Require CFI directives also for
+ ppc and s390.
+
+2003-07-15 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h (PSEUDO):
+ Add cfi directives.
+
+2003-07-12 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/sh/tcb-offsets.sym: Add RESULT, TID, CANCELHANDLING and
+ CLEANUP_JMP_BUF.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S: Use more
+ registers as variables. Call __pthread_mutex_unlock_usercnt.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_rdlock.S: Store TID
+ not self pointer in __writer. Compare with TID to determine
+ deadlocks.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_wrlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedrdlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedwrlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/sh/sem_wait.S: Add cancellation support.
+ * sysdeps/unix/sysv/linux/sh/sem_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/sysdep-cancel.h: Define all the nice
+ macros also when compiling librt.
+
+2003-07-11 Jakub Jelinek <jakub@redhat.com>
+
+ * Makefile (CFLAGS-pthread_once.c): Add -fexceptions
+ -fasynchronous-unwind-tables.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h
+ (PSEUDO): Add cfi directives.
+ * sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h (PSEUDO):
+ Likewise.
+ * sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h (PSEUDO):
+ Likewise.
+
+2003-07-08 Jakub Jelinek <jakub@redhat.com>
+
+ * pthreadP.h (__pthread_unwind_next, __pthread_register_cancel,
+ __pthread_unregister_cancel): Add prototypes and hidden_proto.
+ * unwind.c (__pthread_unwind_next): Add hidden_def.
+ * cleanup.c (__pthread_register_cancel, __pthread_unregister_cancel):
+ Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_wait.S (__new_sem_wait):
+ Use HIDDEN_JUMPTARGET to jump to __pthread_unwind.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S (sem_timedwait):
+ Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sem_wait.S (sem_wait): Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S (sem_timedwait):
+ Likewise.
+ * sysdeps/unix/sysv/linux/i386/pthread_once.S (__pthread_once): Use
+ HIDDEN_JUMPTARGET to call __pthread_register_cancel,
+ __pthread_unregister_cancel and __pthread_unwind_next.
+
+2003-07-04 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h (PSEUDO): Use
+ different symbol for the cancellation syscall wrapper and
+ non-cancellation syscall wrapper.
+ (PSEUDO_END): Define.
+
+2003-07-05 Richard Henderson <rth@redhat.com>
+
+ * sysdeps/alpha/elf/pt-initfini.c: Avoid .ent/.end.
+ * sysdeps/unix/sysv/linux/alpha/lowlevellock.h (lll_futex_wait,
+ lll_futex_timed_wait, lll_futex_wake, lll_futex_requeue): On success
+ return actual return value from the syscall, not 0.
+
+2003-07-07 Ulrich Drepper <drepper@redhat.com>
+
+ * descr.h (struct pthread): Add pid field.
+ * allocatestack.c (allocate_stack): Initialize pid field in descriptor.
+ (__reclaim_stacks): Likewise.
+ * init.c (sigcancel_handler): If __ASSUME_CORRECT_SI_PID is defined
+ also check for PID of the signal source.
+ (__pthread_initialize_minimal_internal): Also initialize pid field
+ of initial thread's descriptor.
+ * pthread_cancel.c: Use tgkill instead of tkill if possible.
+ * sysdeps/unix/sysv/linux/fork.c: Likewise.
+ * sysdeps/unix/sysv/linux/pt-raise.c: Likewise.
+ * sysdeps/unix/sysv/linux/pthread_kill.c: Likewise.
+ * sysdeps/unix/sysv/linux/raise.c: Likewise.
+
+2003-07-05 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/bits/libc-lock.h (__libc_cleanup_push): Renamed.
+ Fix use of parameter.
+ (__libc_cleanup_pop): Likewise.
+
+2003-07-04 Ulrich Drepper <drepper@redhat.com>
+
+ * init.c (sigcancel_handler): Change parameters to match handler
+ for SA_SIGACTION. Check signal number and code to recognize
+ invalid invocations.
+
+2003-07-03 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/ia64/td_ta_map_lwp2thr.c (td_ta_map_lwp2thr):
+ Apply sizeof (struct pthread) bias to r13 value.
+
+2003-07-03 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/configure.in: Require CFI directives.
+
+ * sysdeps/pthread/librt-cancellation.c (__pthread_unwind): Remove
+ definition.
+ * pthreadP.h (__pthread_unwind): Add hidden_proto if used in
+ libpthread compilation.
+ * unwind.c (__pthread_unwind): Add hidden_def.
+ * Versions (libpthread) [GLIBC_PRIVATE]: Add __pthread_unwind.
+
+2003-07-01 Ulrich Drepper <drepper@redhat.com>
+
+ * libc-cancellation.c (__libc_cleanup_routine): Define.
+ * sysdeps/pthread/bits/libc-lock.h (__pthread_cleanup_push): Define.
+ (__pthread_cleanup_pop): Define.
+
+2003-07-01 Richard Henderson <rth@redhat.com>
+
+ * sysdeps/alpha/elf/pt-initfini.c: New file.
+ * sysdeps/alpha/pthread_spin_lock.S: New file.
+ * sysdeps/alpha/pthread_spin_trylock.S: New file.
+ * sysdeps/alpha/pthreaddef.h: New file.
+ * sysdeps/alpha/td_ta_map_lwp2thr.c: New file.
+ * sysdeps/alpha/tls.h: New file.
+ * sysdeps/unix/sysv/linux/alpha/Makefile: New file.
+ * sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h: New file.
+ * sysdeps/unix/sysv/linux/alpha/bits/semaphore.h: New file.
+ * sysdeps/unix/sysv/linux/alpha/createthread.c: New file.
+ * sysdeps/unix/sysv/linux/alpha/fork.c: New file.
+ * sysdeps/unix/sysv/linux/alpha/lowlevellock.h: New file.
+ * sysdeps/unix/sysv/linux/alpha/pt-vfork.S: New file.
+ * sysdeps/unix/sysv/linux/alpha/pthread_once.c: New file.
+ * sysdeps/unix/sysv/linux/alpha/sem_post.c: New file.
+ * sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h: New file.
+
+2003-07-01 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_once.S: Add correct
+ cleanup support and unwind info.
+
+2003-06-30 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/pthread_once.S (__pthread_once):
+ Use correct cleanup handler registration. Add unwind info.
+ * sysdeps/unix/sysv/linux/unwindbuf.sym: New file.
+ * sysdeps/unix/sysv/linux/Makefile: Add rule to build unwindbuf.h.
+ * tst-once3.c: Add cleanup handler and check it is called.
+ * tst-once4.c: Likewise.
+ * tst-oncex3.c: New file.
+ * tst-oncex4.c: New file.
+ * Makefile: Add rules to build and run tst-oncex3 and tst-oncex4.
+
+2003-06-29 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/configure.in: Check for C cleanup handling in gcc.
+
+2003-06-27 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-cancel4.c (tf_msgrcv): Use IPC_PRIVATE in msgget call.
+ (tf_msgsnd): Likewise.
+
+ * tst-cancel4.c (tf_msgrcv): Strengthen test against valid
+ premature returns a bit more.
+
+2003-06-26 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/librt-cancellation.c: Move __pthread_unwind
+ definition to the front.
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Rename
+ the cleanup functions to make the names unique. Fix dwarf opcode
+ un unwind table.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Rename cleanup
+ functions to make the names unique. Fix CFA offset for two blocks.
+
+2003-06-25 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/pthread.h (class __pthread_cleanup_class): Add
+ missing closing braces.
+ Patch by Christophe Saout <christophe@saout.de>.
+
+2003-06-24 Roland McGrath <roland@redhat.com>
+
+ * pthread_mutex_trylock.c (__pthread_mutex_trylock): Typo fix.
+
+2003-06-24 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/ia64/bits/posix_opt.h: New file.
+ * sysdeps/unix/sysv/linux/x86_64/bits/posix_opt.h: New file.
+
+ * pthreadP.h: Declare __find_thread_by_id.
+ * allocatestack.c [HP_TIMING_AVAIL]: Define __find_thread_by_id.
+ * pthread_clock_gettime.c: Allow using other thread's clock.
+ * pthread_clock_settime.c: Likewise.
+ * sysdeps/pthread/pthread_getcpuclockid.c: Likewise.
+ * Makefile: Add rules to build and run tst-clock2.
+ * tst-clock2.c: New file.
+
+2003-06-23 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Rewrite
+ to use exception-based cleanup handler.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Likewise.
+
+ * tst-cond8.c (ch): Announce that we are done.
+
+ * pthreadP.h (__pthread_mutex_cond_lock): Mark with internal_function.
+
+ * tst-cancel17.c (tf): Retry aio_suspend in case of EINTR.
+ Also test aio_suspend with timeout value.
+
+2003-06-22 Ulrich Drepper <drepper@redhat.com>
+
+ * pthreadP.h: Mark __pthread_mutex_unlock_usercnt also hidden.
+ * pthread_mutex_unlock.c (__pthread_mutex_unlock_usercnt): Add
+ attribute_hidden.
+
+ * pthreadP.h (__pthread_mutex_init_internal): Mark hidden.
+ (__pthread_mutex_lock_internal): Likewise.
+ (__pthread_mutex_unlock_internal): Likewise.
+ (__pthread_mutex_unlock_usercnt): Declare.
+ * pthread_mutex_destroy.c: Always fail if used in any way.
+ * pthread_mutex_init.c: Update comment.
+ * pthread_mutex_lock.c: If NO_INCR is not defined adjust __nusers.
+ * pthread_mutex_timedlock.c: Adjust __nusers.
+ * pthread_mutex_trylock.c: Adjust __nusers.
+ * pthread_mutex_unlock.c: Old code is in __pthread_mutex_unlock_usercnt
+ and public interfaces are wrapper with pass additional parameter.
+ __pthread_mutex_unlock_usercnt does not adjust __nusers if second
+ parameter zero.
+ * tst-mutex8.c: New file.
+ * Makefile (tests): Add tst-mutex8.
+ * sysdeps/pthread/pthread_cond_timedwait.c: Call
+ __pthread_mutex_unlock_usercnt.
+ * sysdeps/pthread/pthread_cond_wait.c: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/pthread_mutex_cond_lock.c: Define NO_INCR.
+ * sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h (pthread_mutex_t):
+ Add __nusers.
+ * sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h: Likewise.
+
+ * pthread_mutex_lock.c: Don't store THREAD_ID in __owner, use TID.
+ * pthread_mutex_timedlock.c: Likewise.
+ * pthread_mutex_trylock.c: Adjust __nusers.
+ * pthread_mutex_unlock.c: Compare with TID not THREAD_ID.
+ * tst-mutex9.c: New file.
+ * Makefile (tests): Add tst-mutex9.
+ * sysdeps/i386/tls.h: Remove THREAD_ID definition.
+ * sysdeps/ia64/tls.h: Likewise.
+ * sysdeps/powerpc/tls.h: Likewise.
+ * sysdeps/s390/tls.h: Likewise.
+ * sysdeps/sh/tls.h: Likewise.
+ * sysdeps/x86_64/tls.h: Likewise.
+ * sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h (pthread_mutex_t):
+ Change type of __owner.
+ * sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h: Likewise.
+
+2003-06-19 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/ia64/sem_post.c: Move to...
+ * sysdeps/unix/sysv/linux/sem_post.c: ...here.
+
+ * sysdeps/unix/sysv/linux/sem_post.c: Move to...
+ * sysdeps/unix/sysv/linux/powerpc/sem_post.c: ... here. Pass nr + 1
+ instead of nr to lll_futex_wake. Only set errno and return -1
+ if err < 0.
+
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h (lll_futex_wait,
+ lll_futex_timed_wait, lll_futex_wake, lll_futex_requeue): On success
+ return actual return value from the syscall, not 0.
+
+2003-06-18 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-cancel4.c (tf_msgsnd): Don't always use 100 as the type,
+ find a random value.
+ (tf_msgrcv): Likewise. Also don't report msgrcv returns if
+ errno==EIDRM.
+
+ * sysdeps/unix/sysv/linux/timer_settime.c: Add prototype for
+ compat_timer_settime.
+ * sysdeps/unix/sysv/linux/timer_gettime.c: Add prototype for
+ compat_timer_gettime.
+ * sysdeps/unix/sysv/linux/timer_getoverr.c: Add prototype for
+ compat_timer_getoverrun.
+ * sysdeps/unix/sysv/linux/timer_delete.c: Add prototype for
+ compat_timer_delete.
+
+ * pthread_mutex_destroy.c (__pthread_mutex_destroy): For
+ error-checking mutex detect busy mutexes.
+
+2003-06-17 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h (lll_mutex_lock):
+ Add ax to clobber list.
+ (lll_mutex_cond_lock): Likewise.
+ (lll_mutex_unlock): Likewise.
+ (lll_lock): Likewise.
+ (lll_unlock): Likewise.
+
+ * Makefile: Add rules to build and run tst-cancel18 and tst-cancelx18.
+ * tst-cancel18.c: New file.
+ * tst-cancelx18.c: New file.
+
+ * tst-cancel4.c: Test connect, creat, msgrcv, msgsnd, sendmsg, sendto,
+ and tcdrain.
+
+ * Makefile: Add rules to build and run tst-cancel17 and tst-cancel17x.
+ * tst-cancel17.c: New file.
+ * tst-cancelx17.c: New file.
+
+ * sysdeps/unix/sysv/linux/sigtimedwait.c: New file.
+ * sysdeps/unix/sysv/linux/sigwait.c: New file.
+ * sysdeps/unix/sysv/linux/sigwaitinfo.c: New file.
+
+ * tst-cancel4.c: Test open, close, pread, pwrite, fsync, and msync.
+
+2003-06-16 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/pthread/createthread.c (create_thread): Set
+ header.multiple_threads unconditionally.
+ * allocatestack.c (allocate_stack): Likewise.
+ * descr.h (struct pthread): Add header.multiple_threads
+ unconditionally.
+ * sysdeps/unix/sysv/linux/i386/sysdep-cancel.h (CENABLE, CDISABLE):
+ Define for librt. #error if neither libpthread, libc nor librt.
+ * sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h (CENABLE, CDISABLE):
+ Likewise.
+ * sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h (CENABLE,
+ CDISABLE): Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h (CENABLE,
+ CDISABLE): Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h (CENABLE,
+ CDISABLE): Likewise.
+ * sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h (CENABLE,
+ CDISABLE): Likewise. Access header.multiple_threads outside of
+ libc and libpthread.
+ * sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h (CENABLE, CDISABLE):
+ Likewise.
+ * sysdeps/x86_64/tls.h (tcbhead_t): Add multiple_threads.
+ * sysdeps/x86_64/tcb-offsets.sym (MULTIPLE_THREADS_OFFSET): Define.
+
+2003-06-17 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-cancel4.c: Add tests for the socket and signal functions, pause.
+ Also test early cancellation before the thread reaches the cancellation
+ point.
+
+ * Makefile: Compile forward.c with exceptions.
+
+ * sysdeps/unix/sysv/linux/sleep.c: New file.
+
+2003-06-16 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile: Add CFLAGS definition to compile function wrappers
+ duplicated from libc with exceptions.
+ * tst-cancel4.c: Also check cancellation handlers.
+
+ * Makefile: Add rules to build and run tst-cancel16 and
+ tst-cancelx16. Add missing CFLAGS definitions.
+ * tst-cancel16.c: New file.
+ * tst-cancelx16.c: New file.
+
+2003-06-15 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/dl-sysdep.h
+ (DL_SYSINFO_IMPLEMENTATION): Use CFI opcodes.
+ * sysdeps/unix/sysv/linux/i386/i686/dl-sysdep.h
+ (DL_SYSINFO_IMPLEMENTATION): Likewise.
+
+ * pthreadP.h (LIBC_CANCEL_ASYNC): Also define for librt.
+ (LIBC_CANCEL_RESET): Likewise.
+ Declare __librt_enable_asynccancel and __librt_disable_asynccancel.
+ * sysdeps/pthread/Makefile (librt-sysdep_routines): Add
+ librt-cancellation.
+ (CFLAGS-libcrt-cancellation.c): Define.
+ * sysdeps/pthread/librt-cancellation.c: New file.
+ * sysdeps/unix/sysv/linux/i386/sysdep-cancel.h: Define all the nice
+ macros also when compiling librt.
+ * sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/sh/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h: Likewise.
+
+ * sysdeps/unix/sysv/linux/timer_create.c: Add prototype for
+ compat_timer_create.
+
+2003-06-14 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/posix-timer.h (timespec_compare): Always inline.
+
+ * sysdeps/unix/sysv/linux/fork.h: Add libc_hidden_proto for
+ __register_atfork.
+ * sysdeps/unix/sysv/linux/register-atfork.c (__register_atfork):
+ Add libc_hidden_def.
+
+2003-06-13 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/x86_64/td_ta_map_lwp2thr.c (td_ta_map_lwp2thr): Pass FS
+ constant from <sys/reg.h> to ps_get_thread_area, not register contents.
+
+2003-06-11 Ulrich Drepper <drepper@redhat.com>
+
+ * allocatestack.c (queue_stack): Always inline.
+ * ptreadhP.h (__do_cancel): Likewise.
+
+2003-06-10 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/s390/sem_timedwait.c (sem_timedwait): Fix
+ a typo.
+
+2003-06-10 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S
+ (__pthread_cond_signal): Remove incorrect second addition for
+ cond_lock!=0.
+
+2003-06-09 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S
+ (__pthread_cond_signal): Use correct futex pointer in
+ __lll_mutex_lock_wait call.
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S
+ (__pthread_cond_signal): Some more tweaks to handle cond_lock!=0.
+
+2003-06-08 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/s390/sem_wait.c (__new_sem_wait): Make
+ cancelable.
+ * sysdeps/unix/sysv/linux/s390/sem_timedwait.c (sem_timedwait):
+ Likewise.
+
+ * sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h: Remove
+ hand-written CFI generation code. Since ENTRY/END also initiated
+ CFI frames this caused two CFI sets to be generated.
+
+2003-06-07 Ulrich Drepper <drepper@redhat.com>
+
+ * cleanup_routine.c: New file.
+ * Versions (libpthread) [GLIBC_2.3.3]: Add __pthread_cleanup_routine.
+ * sysdeps/pthread/pthread.h: Add support for fully exception-based
+ cleanup handling.
+ * Makefile (libpthread-routines): Add cleanup_routine.
+ Add more CFLAGS variables to compile with exceptions. Add comments
+ why which file needs unwind tables.
+ (tests) [have-forced-unwind==yes]: Add tst-cancelx* and tst-cleanupx*
+ tests.
+ * tst-cancelx1.c: New file.
+ * tst-cancelx2.c: New file.
+ * tst-cancelx3.c: New file.
+ * tst-cancelx4.c: New file.
+ * tst-cancelx5.c: New file.
+ * tst-cancelx6.c: New file.
+ * tst-cancelx7.c: New file.
+ * tst-cancelx8.c: New file.
+ * tst-cancelx9.c: New file.
+ * tst-cancelx10.c: New file.
+ * tst-cancelx11.c: New file.
+ * tst-cancelx12.c: New file.
+ * tst-cancelx13.c: New file.
+ * tst-cancelx14.c: New file.
+ * tst-cancelx15.c: New file.
+ * tst-cleanupx0.c: New file.
+ * tst-cleanupx0.expect: New file.
+ * tst-cleanupx1.c: New file.
+ * tst-cleanupx2.c: New file.
+ * tst-cleanupx3.c: New file.
+
+ * tst-cleanup0.c: Make standard compliant.
+ * tst-cleanup1.c: Likewise.
+
+ * sysdeps/unix/sysv/linux/sem_timedwait.c: Add cancellation support.
+ * sysdeps/unix/sysv/linux/sem_wait.c: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sem_wait.S: Likewise.
+ * sysdeps/i386/tcb-offsets.sym: Add RESULT, CANCELHANDLING, and
+ CLEANUP_JMP_BUF.
+ * sysdeps/x86_64/tcb-offsets.sym: Likewise.
+ * tst-cancel12.c: New file.
+ * tst-cancel13.c: New file.
+ * tst-cancel14.c: New file.
+ * tst-cancel15.c: New file.
+ * Makefile (tests): Add tst-cancel12, tst-cancel13, tst-cancel14,
+ and tst-cancel15.
+
+ * tst-cancel1.c: Add some comments.
+
+ * sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S: Compute relative
+ timeout correctly.
+
+2003-06-06 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (CFLAGS-pthread_cancel.c): Define.
+
+2003-06-05 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h (pthread_rwlock_t):
+ Change type of __writer element to int.
+ * sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h: Likewise.
+ * sysdeps/i386/tcb-offsets.sym: Replace SELF entry with TID entry.
+ * sysdeps/x86_64/tcb-offsets.sym: Likewise.
+ * pthread_rwlock_trywrlock.c: Store TID not self pointer in __writer.
+ Compare with TID to determine deadlocks.
+ * sysdeps/pthread/pthread_rwlock_rdlock.c: Likewise.
+ * sysdeps/pthread/pthread_rwlock_timedrdlock.c: Likewise.
+ * sysdeps/pthread/pthread_rwlock_timedwrlock.: Likewise.
+ * sysdeps/pthread/pthread_rwlock_wrlock.c: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S: Likewise.
+ * Makefile (tests): Add tst-rwlock12.
+ * tst-rwlock12.c: New file.
+
+2003-06-05 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/lowlevellock.c (__lll_lock_wait,
+ __lll_timedlock_wait, lll_unlock_wake_cb, __lll_timedwait_tid):
+ Remove bogus hidden_proto.
+ * sysdeps/unix/sysv/linux/s390/libc-lowlevellock.c (___lll_lock):
+ Likewise.
+ * sysdeps/unix/sysv/linux/s390/lowlevellock.c (___lll_lock,
+ lll_unlock_wake_cb, ___lll_timedwait_tid): Likewise.
+ * sysdeps/unix/sysv/linux/s390/lowlevelmutex.c (___lll_mutex_lock,
+ ___lll_mutex_timedlock): Likewise.
+
+2003-06-04 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S
+ (__pthread_cond_signal): Add some code to eventually handle
+ cond_lock!=0.
+
+2003-06-01 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (tests): Add tst-exec4.
+ (tst-exec4-ARGS): Define.
+ * tst-exec4.c: New file.
+
+2003-05-31 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/lowlevellock.c (__lll_timedlock_wait):
+ Also fail if tv_nsec < 0.
+ (__lll_timedwait_tid): Likewise.
+ * sysdeps/unix/sysv/linux/sem_timedwait.c (sem_timedwait): Likewise.
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h (lll_timedwait_tid):
+ Likewise.
+ * sysdeps/unix/sysv/linux/s390/lowlevellock.c (___lll_timedwait_tid):
+ Likewise.
+ * sysdeps/unix/sysv/linux/s390/lowlevelmutex.c (__lll_mutex_timedlock):
+ Likewise.
+ * sysdeps/unix/sysv/linux/s390/sem_timedwait.c (sem_timedwait):
+ Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h (lll_timedwait_tid):
+ Likewise.
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.h (lll_timedwait_tid):
+ Likewise.
+
+ * Makefile (tests): Add tst-sem8 and tst-sem9.
+ * tst-sem8.c: New file.
+ * tst-sem9.c: New file.
+ * sem_open.c: Fix creation of in_use record if the file exists but
+ no internal record.
+
+ * posix-timer.h: Remove old, unused timer_id2ptr and timer_ptr2id
+ definitions.
+
+ * sysdeps/pthread/timer_create.c (timer_create): In case
+ evp==NULL, assign timer ID to sival_ptr.
+
+ * descr.h (struct pthread_unwind_buf): Change type of prev element to
+ struct pthread_unwind_buf *.
+ (struct pthread): Likewise for cleanup_jmp_buf element.
+
+ * cleanup.c (__pthread_register_cancel): Add cast to avoid warning.
+ * cleanup_defer.c (__pthread_register_cancel_defer): Likewise.
+ * unwind.c (__pthread_unwind_next): Likewise.
+
+2003-05-30 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/ia64/lowlevellock.h
+ (lll_futex_timed_wait): Use int for futex value parameter.
+ (lll_futex_wake): Likewise.
+ (lll_futex_requeue): Likewise.
+
+ * sysdeps/unix/sysv/linux/lowlevellock.c (__lll_lock_wait):
+ Replace one memory operation with one register operation.
+
+ * tst-join4.c (do_test): Fix error message.
+
+ * tst-rwlock6.c (do_test): Use correct format specifier.
+
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevelmutex.S
+ (__lll_mutex_lock_wait): Replace one memory operation with one
+ register operation.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevelmutex.S
+ (__lll_mutex_lock_wait): Likewise.
+
+ * sysdeps/unix/sysv/linux/ia64/lowlevellock.h
+ (__lll_mutex_cond_lock): Add one to value parameter of
+ __lll_lock_wait to reflect reality in the futex syscall.
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h
+ (lll_mutex_cond_lock): Likewise.
+
+2003-05-30 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/s390/lowlevellock.h (__lll_mutex_cond_lock):
+ New function.
+ (lll_mutex_cond_lock): Define.
+
+2003-05-29 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (tests): Add tst-signal6.
+ * tst-signal6.c: New file.
+
+ * sysdeps/unix/sysv/linux/s390/lowlevellock.h
+ (__lll_mutex_unlock_force): New function
+ (lll_mutex_unlock_force): Use __lll_mutex_unlock_force.
+
+ * sysdeps/unix/sysv/linux/ia64/lowlevellock.h
+ (__lll_mutex_unlock_force): New function.
+ (lll_mutex_unlock_force): Use __lll_mutex_unlock_force.
+
+ * tst-rwlock7.c (do_test): Use correct format specifier.
+
+ * sysdeps/unix/sysv/linux/ia64/lowlevellock.h (lll_futex_requeue):
+ Find break parameter in correct asm argument.
+
+2003-05-27 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/ia64/lowlevellock.h (lll_futex_clobbers):
+ Remove out4.
+ (lll_futex_requeue): Fix __o3 constraint, return negative errno if
+ error occured.
+ * sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h (pthread_cond_t):
+ Add __mutex.
+ * sysdeps/unix/sysv/linux/s390/lowlevellock.h (FUTEX_REQUEUE,
+ lll_futex_requeue, lll_mutex_unlock_force): Define.
+
+2003-05-30 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h
+ (pthread_cond_t): Add __mutex.
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h (FUTEX_REQUEUE,
+ lll_futex_requeue, lll_mutex_unlock_force): Define.
+
+2003-05-28 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/sh/tcb-offsets.sym: Define MUTEX_FUTEX.
+ * sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h (pthread_cond_t):
+ Add __mutex field.
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.h (SYSCALL_WITH_INST_PAD):
+ Define.
+ (lll_futex_wait, lll_futex_wake): Define.
+ * sysdeps/unix/sysv/linux/sh/sh4/lowlevellock.h: New file.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_broadcast.S: Try using
+ FUTEX_REQUEUE instead of FUTEX_WAIT.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_signal.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S: Remember
+ mutex which was used in condvar structure. Call
+ __pthread_mutex_cond_lock instead of __pthread_mutex_lock_internal.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S: Likewise.
+
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_rdlock.S: Don't
+ include tcb-offsets.h. Read wakeup value in locked region.
+ Use the value of gbr register as THREAD_ID.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_wrlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedrdlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedwrlock.S: Likewise.
+
+ * sysdeps/unix/sysv/linux/sh/sem_trywait.S: Remove futex related
+ macros.
+
+2003-05-28 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/pthread_cond_broadcast.c
+ (__pthread_cond_broadcast): Fix typo: MAX_INT -> INT_MAX.
+
+2003-05-26 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S: Fix
+ typo in register name.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S: Use parameters
+ correctly. Actually use requeue. Little optimization.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Store
+ mutex address early. Handle cancellation state as 32-bit value.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Likewise.
+ Remove unnecessary label.
+
+2003-05-25 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/pthread_cond_broadcast.c: Try using FUTEX_REQUEUE
+ instead of FUTEX_WAIT.
+ * sysdeps/pthread/pthread_cond_signal.c: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S: Likewise.
+ * sysdeps/pthread/pthread_cond_timedwait.c: Remember mutex which was
+ used in condvar structure. Call __pthread_mutex_cond_lock instead
+ of __pthread_mutex_lock_internal.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Likewise.
+ * sysdeps/pthread/pthread_cond_wait.c: Likewise.
+ (__condvar_cleanup): Always call __pthread_mutex_cond_lock.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/Makefile (libpthread-sysdep_routines):
+ Add pthread_mutex_cond_lock.
+ * sysdeps/unix/sysv/linux/lowlevelcond.sym: Add dep_mutex.
+ * sysdeps/unix/sysv/linux/pthread_cond_mutex_lock.c: New file.
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h: Define
+ lll_mutex_cond_lock.
+ * sysdeps/unix/sysv/linux/ia64/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h (pthread_cond_t):
+ Add __mutex field.
+ * sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h: Likewise.
+
+ * sysdeps/i386/tcb-offsets.sym: Define MUTEX_FUTEX.
+ * sysdeps/x86_64/tcb-offsets.sym: Likewise.
+
+ * pthreadP.h: Declare __pthread_mutex_cond_lock.
+ * pthread_mutex_lock.c: Define LLL_MUTEX_LOCK if not already defined.
+ Use it instead of lll_mutex_lock. If __pthread_mutex_lock is a
+ macro don't define aliases.
+
+ * cancellation.c: Remove __pthread_enable_asynccancel_2.
+ * pthreadP.h: Remove declaration of __pthread_enable_asynccancel_2.
+ * sysdeps/pthread/pthread_cond_timedwait.c: Use
+ __pthread_enable_asynccancel instead of __pthread_enable_asynccancel_2.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Likewise.
+ * sysdeps/pthread/pthread_cond_wait.c: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Likewise.
+
+2003-05-17 Ulrich Drepper <drepper@redhat.com>
+
+ * sem_open.c: Fix one endless loop. Implement correct semantics
+ wrt opening the same semaphore more then once.
+ * sem_close.c: Adjust for sem_open change.
+ * semaphoreP.h: Include <semaphore.h>. Define struct inuse_sem.
+ Declare __sem_mappings, __sem_mappings_lock, __sem_search.
+ * Makefile (tests): Add tst-sem7.
+ * tst-sem7.c: New file.
+
+2003-05-16 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/unix/sysv/linux/register-atfork.c (libc_freeres_fn): Fix
+ uninitialized variable braino.
+
+2003-05-16 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/timer_gettime.c (timer_gettime): Correct
+ test for syscall availability.
+
+ * sysdeps/unix/sysv/linux/timer_settime.c (timer_settime): Set
+ __no_posix_timers to -1 if the syscalls don't exist.
+
+ * pthread_join.c (pthread_join): Set tid field of the joined
+ thread to -1. This isn't necessary but helps to recognize some
+ error conditions with almost no cost.
+
+ * allocatestack.c (FREE_P): Also negative values indicate an
+ unused stack.
+
+ * unwind.c: Include <unistd.h>.
+
+2003-05-14 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile ($(objpfx)$(multidir)): Add rule to create the directory.
+
+2003-05-14 Jakub Jelinek <jakub@redhat.com>
+
+ * Makefile (crti-objs, crtn-objs): New variables.
+ (omit-deps, extra-objs): Add crtn.
+ ($(objpfx)libpthread.so): Depend on both crti and crtn
+ and links to them in multidir.
+ ($(objpfx)crtn.S, $(objpfx)crtn.o): New rules.
+
+2003-05-12 Steven Munroe <sjmunroe@us.ibm.com>
+
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h
+ (lll_mutex_unlock): Use atomic_exchange_rel.
+
+2003-05-11 Ulrich Drepper <drepper@redhat.com>
+
+ * cond-perf.c (cons): Add missing locking around setting of alldone.
+
+2003-05-10 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/sem_trywait.S: Remove futex
+ related macros.
+ * sysdeps/unix/sysv/linux/x86_64/sem_trywait.S: Likewise.
+
+2003-05-09 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-sem6.c: New file.
+ * Makefile (tests): Add tst-sem6.
+
+ * sysdeps/unix/sysv/linux/ia64/lowlevellock.h (___lll_mutex_unlock):
+ Use atomic_exchange_rel instead of atomic_exchange.
+ * sysdeps/unix/sysv/linux/lowlevellock.c (lll_unlock_wake_cb):
+ Likewise.
+
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h: Improve quality of
+ code for lll_futex_wait and lll_futex_wake in static apps. Use
+ vsyscall is possible.
+
+ * sysdeps/unix/sysv/linux/pthread_getaffinity.c: New file.
+ * sysdeps/unix/sysv/linux/pthread_setaffinity.c: New file.
+ * sysdeps/pthread/pthread.h: Declare pthread_getaffinity_np and
+ pthread_setaffinity_np.
+ * Versions [libpthread] (GLIBC_2.3.3): Add pthread_getaffinity_np
+ and pthread_setaffinity_np.
+ * Makefile (libpthread-routines): Add pthread_getaffinity and
+ pthread_setaffinity.
+
+ * allocatestack.c (allocate_stack): If ARCH_RETRY_MMAP is defined,
+ use it in case mmap to allocate the stack fails.
+ * sysdeps/unix/sysv/linux/x86_64/Makefile: Don't define
+ ARCH_MAP_FLAGS here.
+ * sysdeps/x86_64/pthreaddef.h: Define ARCH_MAP_FLAGS and
+ ARCH_RETRY_MMAP.
+
+2003-05-08 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/fork.c: Complete rewrite of the atfork
+ handler implementation. It is now lockless in fork().
+ * sysdeps/unix/sysv/linux/register-atfork.c: Likewise.
+ * sysdeps/unix/sysv/linux/unregister-atfork.c: Likewise.
+ * sysdeps/unix/sysv/linux/fork.h: Don't include <link.h>. Don't
+ declare the __fork_*_lists.
+ (struct fork_handler): Include pointers to all three functions.
+ Add next, refcntr and need_signal elements.
+ (__fork_handlers): New declaration.
+ (__register_atfork_malloc): Remove declaration.
+ (HAVE_register_atfork_malloc): Remove definition.
+ * sysdeps/unix/sysv/linux/libc_pthread_init.c: Remove
+ __pthread_child_handler variable.
+ (__libc_pthread_init): Use __register_atfork instead of explicitly
+ adding to the list.
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h: Define lll_futex_wait
+ and lll_futex_wake.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Likewise.
+
+ * unwind.c (unwind_cleanup): Print error message and then abort. This
+ function must never be reached.
+
+ * cond-perf.c: New file.
+
+2003-05-05 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/i386/tls.h (TLS_INIT_TP): Include \n in error message.
+
+2003-05-04 Roland McGrath <roland@redhat.com>
+
+ * Makefile ($(objpfx)../libc.so): New target.
+
+2003-05-02 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h
+ (pthread_condattr_t): Size is only an int, don't use long for
+ alignment.
+ (pthread_mutexattr_t): Likewise.
+ * sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h: Likewise.
+
+2003-05-01 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/i386/tls.h: Define THREAD_ID.
+ * sysdeps/ia64/tls.h: Likewise.
+ * sysdeps/powerpc/tls.h: Likewise.
+ * sysdeps/s390/tls.h: Likewise.
+ * sysdeps/sh/tls.h: Likewise.
+ * sysdeps/x86_64/tls.h: Likewise.
+ * pthread_mutex_lock.c: Use THREAD_ID instead of THREAD_SELF to
+ record ownership.
+ * pthread_mutex_timedlock.c: Likewise.
+ * pthread_mutex_trylock.c: Likewise.
+ * pthread_mutex_unlock.c: Likewise.
+ * pthread_rwlock_trywrlock.c: Likewise.
+ * sysdeps/pthread/pthread_rwlocklock_rdlock.c: Likewise.
+ * sysdeps/pthread/pthread_rwlock_timedrdlock.c: Likewise.
+ * sysdeps/pthread/pthread_rwlock_timedwrlock.c: Likewise.
+ * sysdeps/pthread/pthread_rwlock_wrlock.c: Likewise.
+
+ * sysdeps/pthread/createthread.c (create_thread): Use CLONE_SYSVSEM
+ flag.
+
+2003-04-29 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h
+ (__SIZEOF_PTHREAD_COND_T): Define to 48.
+ (pthread_rwlock_t): Add 16 bytes of pad instead of 8 before __flags.
+ * sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h (pthread_cond_t):
+ Make __align long long instead of long.
+ (pthread_rwlock_t): Formatting.
+ * sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h
+ (pthread_rwlock_t): Formatting.
+ * sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h
+ (pthread_cond_t): Make __align long long instead of long.
+ (pthread_rwlock_t): Move __flags field to the same position as in
+ linuxthreads.
+
+2003-04-30 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-rwlock6.c (do_test): Use correct printf format specifiers.
+ * tst-rwlock7.c (do_test): Likewise.
+
+2003-04-26 Roland McGrath <roland@redhat.com>
+
+ * Makefile ($(test-modules)): Depend on $(common-objpfx)shlib.lds.
+
+2003-04-22 Jakub Jelinek <jakub@redhat.com>
+
+ * allocatestack.c (TLS_TPADJ): Add TLS_PRE_TCB_SIZE instead of
+ sizeof (struct pthread).
+ (allocate_stack): Subtract TLS_PRE_TCB_SIZE bytes instead of
+ 1 struct pthread.
+ * sysdeps/powerpc/tls.h (TLS_INIT_TCB_SIZE, TLS_TCB_SIZE): Define
+ to 0.
+ (TLS_INIT_TCB_ALIGN, TLS_TCB_ALIGN): Define to alignment of
+ struct pthread.
+ (TLS_PRE_TCB_SIZE): Increase to cover tcbhead_t preceeded by pad
+ to 32-bit bytes.
+ (INSTALL_DTV, GET_DTV, THREAD_DTV): tcbhead_t is immediately before
+ tcbp.
+ (TLS_INIT_TP, THREAD_SELF, INIT_THREAD_SELF): Don't add TLS_TCB_SIZE
+ unneccessarily.
+ (NO_TLS_OFFSET): Define.
+ * sysdeps/unix/sysv/linux/powerpc/createthread.c (TLS_VALUE): Don't
+ add TLS_TCB_SIZE unnecessarily.
+
+2003-04-22 Roland McGrath <roland@redhat.com>
+
+ * Makeconfig (shared-thread-library): Reverse link order to work
+ around linker bug.
+
+2003-04-22 Ulrich Drepper <drepper@redhat.com>
+
+ * semaphore.h: Fix typo in comment.
+
+2003-04-21 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/sigfillset.c: New file.
+
+ * init.c (__pthread_initialize_minimal): Don't block SIGTIMER.
+ * pthreadP.h: Make SIGTIMER and SIGCANCEL the same.
+ * sysdeps/pthread/pthread_sigmask.c: Remove handling of SIGTIMER.
+ * sysdeps/pthread/sigaction.c: Likewise.
+ * sysdeps/pthread/sigprocmask.c: New file.
+ * sysdeps/unix/sysv/linux/allocrtsig.c (current_rtmin): Define as
+ __SIGRTMIN+1.
+ * sysdeps/unix/sysv/linux/timer_routines.c (timer_helper_thread):
+ Block SIGTIMER. Also handle SI_TKILL events and terminate thread
+ in this case.
+
+2003-04-19 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/dl-sysdep.h
+ (DL_SYSINFO_IMPLEMENTATION): Add .eh_frame information.
+
+ * sysdeps/unix/sysv/linux/unregister-atfork.c
+ (__unregister_atfork): Don't free memory not allocated dynamically.
+
+ * semaphore.h: Remove __THROW marker from cancellation points.
+ * nptl/sysdeps/pthread/pthread.h: Likewise.
+
+2003-04-18 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/pthread.h: Don't mark pthread_testcancel,
+ pthread_cancel, pthread_setcancelstate, and pthread_setcanceltype with
+ __THROW.
+
+2003-04-16 Jakub Jelinek <jakub@redhat.com>
+
+ * tst-cancel4.c (do_test): Use %zd instead of %d when printing cnt.
+
+2003-04-15 Roland McGrath <roland@redhat.com>
+
+ * forward.c (__pthread_unwind): Tweak to avoid warning.
+
+2003-04-15 Ulrich Drepper <drepper@redhat.com>
+
+ * pthreadP.h: Move THREAD_ATOMIC_* replacements to the top.
+
+2003-04-14 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Don't
+ overflow CFA advance instructions.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Likewise.
+
+2003-04-14 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/i386/tls.h: Rename LOCK to LOCK_PREFIX.
+ * sysdeps/i386/pthread_spin_lock.c: Likewise.
+ * sysdeps/x86_64/tls.h: Likewise. Define LOCK_PREFIX if not already
+ defined.
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Use
+ DW_CFA_advance_loc2 for .Laddl-.Lsubl.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Use
+ DW_CFA_advance_loc for .Laddl-.Lsubl.
+
+2003-04-13 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/sysdep-cancel.h: Don't use
+ position-independent unwind data for static libraries.
+ Add missing unwind info. Add comments.
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Add unwind info.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Likewise.
+
+2003-04-12 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile: Make sure all cancellation points are compiled with
+ exception and asynchronous unwind tables.
+
+ * sysdeps/x86_64/tls.h (THREAD_SETMEM): Word around compiler bug
+ which mishandles loading of global object addresses in PIC.
+ (THREAD_SETMEM_NC): Likewise.
+
+2003-04-11 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread.h: Define new data structure for cleanup buffer. Declare
+ new cleanup handler interfaces.
+ * descr.h: Include <unwind.h> if necessary. Define pthread_unwind_buf.
+ (struct pthread): Add cleanup_jmp_buf pointer. Define
+ HAVE_CLEANUP_JMP_BUF and not HAVE_CANCELBUF.
+ * pthreadP.h: Declare __pthread_unwind. Define __do_cancel to use
+ it. Declare old cleanup handler installation functions.
+ * cleanup.c: Rewrite. Install handler for unwind-based cleanup
+ handling.
+ * cleanup_defer.c: Likewise.
+ * cleanup_compat.c: New file. Old cleanup code.
+ * cleanup_def_compat.c: New file. Old cleanup code.
+ * pthread_create.c (start_thread): Initialize cleanup_jmp_buf element
+ if own thread descriptor.
+ * unwind.c: New file.
+ * forward.c: Add __pthread_unwind.
+ * init.c (pthread_functions): Add __pthread_unwind.
+ * sysdeps/pthread/pthread-functions.s (struct pthread_functions):
+ Add ptr___pthread_unwind.
+ * Versions [GLIBC_2.3.3] (libpthread): Export new cleanup handling
+ and unwind function.
+ * Makefile (libpthread-routines): Add cleanup_compat,
+ cleanup_def_compat, and unwind. Define CFLAGS to enable unwind
+ table generation if necessary.
+ * version.c: Record whether unwind support is compiled in.
+ * sysdeps/pthread/configure.in: Add checks for unwind unterfaces.
+ * sysdeps/pthread/bits/libc-lock.h: Add prototypes of the old cleanup
+ handler interfaces.
+ * sysdeps/unix/sysv/linux/i386/sysdep-cancel.h: Add quite a bit of
+ complication to generate unwind information for syscall wrappers.
+ * sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h: Likewise.
+ * sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h: Define
+ __cleanup_fct_attribute.
+
+ * Makefile: Add rules to build and run tst-cleanup0.
+ * tst-cleanup0.c: New file.
+ * tst-cleanup0.expect: New file.
+
+ * pthread_create.c (deallocate_tsd): Don't take parameter. Adjust
+ caller. Optimize to avoid often unecessary local variable.
+
+2003-04-11 Roland McGrath <roland@redhat.com>
+
+ * Makefile ($(objpfx)multidir.mk): New target, generated makefile that
+ sets variable `multidir'; include that.
+ (generated): Add it.
+ ($(objpfx)$(multidir)/crti.o): New target.
+ [$(multidir) != .] (generated-dirs, extra-objs, omit-deps): Add it.
+
+2003-04-11 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-attr2.c (do_test): Add cast to avoid warning.
+ * tst-mutex4.c (do_test): Likewise.
+
+2003-04-10 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/fork.c (__libc_fork): Reset CPU clocks
+ in child.
+
+2003-04-09 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (tests): Add tst-detach1.
+ * tst-detach1.c: New file.
+
+2003-04-08 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/pthread.h: Remove duplicate
+ pthread_cleanup_{push,pop} definitions.
+
+ * tst-barrier2.c: Eliminate warnings.
+ * tst-cancel4.c: Likewise.
+ * tst-cond4.c: Likewise.
+ * tst-cond6.c: Likewise.
+ * tst-detach1.c: Likewise.
+ * tst-rwlock4.c: Likewise.
+ * tst-rwlock6.c: Likewise.
+ * tst-rwlock7.c: Likewise.
+ * tst-sem3.c: Likewise.
+ * tst-spin2.c: Likewise.
+ * tst-umask1.c: Likewise.
+
+2003-04-07 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_detach.c (pthread_detach): Fix test for invalid TID.
+
+2003-04-06 Ulrich Drepper <drepper@redhat.com>
+
+ * descr.h (struct pthread): Move cancelhandling member to the front.
+
+2003-04-05 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/register-atfork.c: Define malloc_prepare,
+ malloc_parent, and malloc_child statically.
+ (__register_atfork_malloc): New function.
+ (free_mem): Don't free any of the malloc_* variables on the list.
+ * sysdeps/unix/sysv/linux/fork.h: Declare __register_atfork_malloc.
+ Define HAVE_register_atfork_malloc.
+
+2003-04-04 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/createthread.c (create_thread): Add some more
+ comments explaining when to set multiple_threads and when not.
+
+ * pthreadP.h: Define THREAD_ATOMIC_CMPXCHG_VAL and
+ THREAD_ATOMIC_BIT_SET if not already defined.
+ * sysdeps/i386/tls.h: Define THREAD_ATOMIC_CMPXCHG_VAL and
+ THREAD_ATOMIC_BIT_SET:
+ * sysdeps/x86_64/tls.h: Likewise.
+ * cleanup_defer.c (_pthread_cleanup_push_defer): Rewrite to use
+ THREAD_ATOMIC_CMPXCHG_VAL.
+ (_pthread_cleanup_pop_restore): Likewise.
+ * cancellation.c (__pthread_enable_asynccancel): Likewise.
+ (__pthread_enable_asynccancel_2): Likewise.
+ (__pthread_disable_asynccancel): Likewise.
+ * libc-cancellation.c (__libc_enable_asynccancel): Likewise.
+ (__libc_disable_asynccancel): Likewise.
+ * init.c (sigcancel_handler): Likewise.
+ * pthread_setcancelstate.c (__pthread_setcancelstate): Likewise.
+ * pthread_setcanceltype.c (__pthread_setcanceltype): Likewise.
+
+2003-04-03 Ulrich Drepper <drepper@redhat.com>
+
+ * init.c (sigcancel_handler): Don't set EXITING_BIT here.
+ * libc-cancellation.c (__libc_enable_asynccancel): Likewise.
+ * pthreadP.h (__do_cancel): Set EXITING_BIT here.
+ * Makefile (tests): Add tst-cancel11.
+ * tst-cancel11.c: New file.
+
+2003-04-01 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_create.c (deallocate_tsd): Clear/free memory after the last
+ round, not the first. Use specific_used flag instead of local
+ found_nonzero variable. Use THREAD_[SG]ETMEM where possible.
+ (__free_tcb): Don't call deallocate_tsd here.
+ (start_thread): Call deallocate_tsd here.
+ * pthread_setspecific.c: Set specific_used flag really only when
+ needed.
+ * Makefile (tests): Add tst-tsd3.c and tst-tsd4.
+ * tst-tsd3.c: New file.
+ * tst-tsd4.c: New file.
+
+2003-03-31 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/ia64/lowlevellock.h (__lll_mutex_lock):
+ Use atomic_exchange_and_add instead of __lll_add.
+ (__lll_mutex_timedlock): Likewise.
+ Patch by Ian Wienand.
+
+2003-03-24 Steven Munroe <sjmunroe@us.ibm.com>
+
+ * sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h
+ (SINGLE_THREAD_P): Fix typo.
+ * tst-cancel-wrappers.sh: Handle '.'ed symbols.
+
+2003-03-31 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (tests): Add tst-align.
+ * tst-align.c: New file.
+ * sysdeps/i386/Makefile: Define CFLAGS-tst-align.
+
+ * sysdeps/i386/tls.h (CALL_THREAD_FCT): Align stack of called
+ function correctly.
+
+ * tst-tsd2.c: Add casts to avoid warnings.
+
+2003-03-30 Ulrich Drepper <drepper@redhat.com>
+
+ * descr.h (struct pthread): Move most often used elements to the front.
+
+2003-03-29 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (libpthread-routines): Add pthread_atfork.
+ (libpthread-static-only-routines): Add pthread_atfork.
+
+2003-03-28 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/sh/tls.h: Include nptl/descr.h after the definition
+ of TLS_DTV_AT_TP.
+ (INSTALL_DTV): Add parens.
+ (THREAD_GETMEM, THREAD_GETMEM_NC, THREAD_SETMEM, THREAD_SETMEM_NC):
+ Use passed descr instead of THREAD_SELF.
+ * sysdeps/unix/sysv/linux/sh/lowlevelmutex.S
+ (__lll_mutex_timedlock_wait): Correct expected value after
+ spurious wakeup.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_broadcast.S:
+ Release lock before waking up the waiters.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S: Correct exit
+ criteria. Reorderstruct passed to cleanup handler. Fix
+ handling of cancellation and failung pthread_mutex_unlock call.
+ Use __pthread_enable_asynccancel_2 instead of
+ __pthread_enable_asynccancel.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S: Likewise.
+ Return result of lock re-get if it fails.
+ * sysdeps/unix/sysv/linux/sh/pthread_once.S: Fix wrong argument
+ for __pthread_cleanup_push.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_rdlock.S: Fix
+ completely broken rwlock implementation.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_wrlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedrdlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedwrlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_unlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_wrlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/sem_post.S: Fix error value. Use
+ versioned_symbol macro.
+ * sysdeps/unix/sysv/linux/sh/sem_trywait.S: Use versioned_symbol macro.
+ * sysdeps/unix/sysv/linux/sh/sem_wait.S: Likewise.
+
+2003-03-27 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/kernel-posix-timers.h: Don't declare
+ __timer_helper_thread. Declare __start_helper_thread, __helper_once,
+ and __helper_tid.
+ (struct timer): Remove th and bar field.
+ * sysdeps/unix/sysv/linux/timer_create.c (timer_create): Remove
+ debugging code. Create only one helper thread.
+ * sysdeps/unix/sysv/linux/timer_delete.c (timer_delete): Don't kill
+ helper thread.
+ * sysdeps/unix/sysv/linux/timer_routines.c (timer_helper_thread):
+ Renamed. Define statically. Use thread info from siginfo.
+ (__helper_once): New variable.
+ (__helper_tid): New variable.
+ (__reset_helper_control): New function.
+ (__start_helper_thread): New function.
+
+ * pthread_create.c (start_thread): Don't use setjmp inside
+ __builtin_expect to work around gcc bug.
+
+ * sysdeps/unix/sysv/linux/timer_delete.c (timer_delete): Even if
+ timer_delete syscall fails, but not with ENOSYS, set
+ __no_posix_timers.
+
+ * sysdeps/unix/sysv/linux/timer_settime.c [!__ASSUME_POSIX_TIMERS]
+ (timer_settime): Fix typo.
+ * sysdeps/unix/sysv/linux/timer_getoverr.c
+ [!__ASSUME_POSIX_TIMERS] (timer_getoverrun): Likewise.
+
+2003-03-27 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Fix
+ offset of cleanupbuf.__prev.
+
+2003-03-26 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/timer_getoverr.c: Fix typo in name
+ of included file.
+
+2003-03-26 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/timer_create.c (timer_create): If EVP ==
+ NULL provide default definition to syscall.
+
+2003-03-25 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/pthread/posix-timer.h (TIMER_MAX): Define if not defined.
+ (timer_id2ptr): Fix typo.
+
+2003-03-25 Ulrich Drepper <drepper@redhat.com>
+
+ * pthreadP.h: Define SIGCANCEL and SIGTIMER.
+ * sysdeps/i386/pthreaddef.h: Remove SIGCANCEL definition.
+ * sysdeps/ia64/pthreaddef.h: Likewise.
+ * sysdeps/powerpc/pthreaddef.h: Likewise.
+ * sysdeps/s390/pthreaddef.h: Likewise.
+ * sysdeps/sh/pthreaddef.h: Likewise.
+ * sysdeps/x86_64/pthreaddef.h: Likewise.
+ * init.c (__pthread_initialize_minimal): Block SIGTIMER.
+ * sysdeps/pthread/sigaction.c: Also prevent SIGTIMER handler from
+ being changed.
+ * sysdeps/pthread/pthread_sigmask.c (pthread_sigmask): Make sure
+ SIGTIMER is not unblocked.
+ * sysdeps/unix/sysv/linux/allocrtsig.c (current_rtmin): One more
+ RT signal taken.
+ * sysdeps/unix/sysv/linux/pthread_kill.c: Do not allow SIGTIMER to
+ be send.
+ * sysdeps/pthread/posix-timer.h (timer_id2ptr, timer_ptr2id): Just
+ pass pointer through as ID.
+ * sysdeps/unix/sysv/linux/bits/local_lim.h (TIMER_MAX): Removed.
+ * sysdeps/unix/sysv/linux/kernel-posix-timers.h: New file.
+ * sysdeps/unix/sysv/linux/timer_create.c: New file.
+ * sysdeps/unix/sysv/linux/timer_delete.c: New file.
+ * sysdeps/unix/sysv/linux/timer_getoverr.c: New file.
+ * sysdeps/unix/sysv/linux/timer_gettime.c: New file.
+ * sysdeps/unix/sysv/linux/timer_routines.c: New file.
+ * sysdeps/unix/sysv/linux/timer_settime.c: New file.
+ * sysdeps/unix/sysv/linux/ia64/Versions: New file.
+ * sysdeps/unix/sysv/linux/ia64/timer_create.c: New file.
+ * sysdeps/unix/sysv/linux/ia64/timer_delete.c: New file.
+ * sysdeps/unix/sysv/linux/ia64/timer_getoverr.c: New file.
+ * sysdeps/unix/sysv/linux/ia64/timer_gettime.c: New file.
+ * sysdeps/unix/sysv/linux/ia64/timer_settime.c: New file.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc64/Versions: New file.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_create.c: New file.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_delete.c: New file.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_getoverr.c: New file.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_gettime.c: New file.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_settime.c: New file.
+ * sysdeps/unix/sysv/linux/s390/s390-64/Versions: New file.
+ * sysdeps/unix/sysv/linux/s390/s390-64/timer_create.c: New file.
+ * sysdeps/unix/sysv/linux/s390/s390-64/timer_delete.c: New file.
+ * sysdeps/unix/sysv/linux/s390/s390-64/timer_getoverr.c: New file.
+ * sysdeps/unix/sysv/linux/s390/s390-64/timer_gettime.c: New file.
+ * sysdeps/unix/sysv/linux/s390/s390-64/timer_settime.c: New file.
+ * sysdeps/unix/sysv/linux/x86_64/Versions: New file.
+ * sysdeps/unix/sysv/linux/x86_64/compat-timer.h: New file.
+ * sysdeps/unix/sysv/linux/x86_64/timer_create.c: New file.
+ * sysdeps/unix/sysv/linux/x86_64/timer_delete.c: New file.
+ * sysdeps/unix/sysv/linux/x86_64/timer_getoverr.c: New file.
+ * sysdeps/unix/sysv/linux/x86_64/timer_gettime.c: New file.
+ * sysdeps/unix/sysv/linux/x86_64/timer_settime.c: New file.
+
+ * pthreadP.h: Remove FRAME_LEFT definition.
+ * cleanup.c (_pthread_cleanup_push): Don't check for reference to
+ already left frame. Programs which have this problem are not POSIX
+ compliant.
+ * cleanup_defer.c (_pthread_cleanup_push_defer): Likewise.
+
+2003-03-24 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/tst-timer.c: Check return values of the
+ functions we test.
+
+2003-03-23 Roland McGrath <roland@redhat.com>
+
+ * tst-tls3.c (do_test) [! HAVE___THREAD]: Don't test anything.
+ * tst-tls3mod.c: Likewise.
+ * tst-tls1.c: Likewise.
+ * tst-tls2.c: Likewise.
+
+ * tst-mutex5.c (do_test): Unlock before destroy, otherwise we invoke
+ undefined behavior.
+
+ * tst-join5.c (tf1, tf2): Add a cast.
+
+ * Makeconfig (includes): Append -I$(..)nptl to this variable.
+
+ * tst-barrier2.c (do_test) [! _POSIX_THREAD_PROCESS_SHARED]:
+ Don't test anything.
+ * tst-cond4.c: Likewise.
+ * tst-cond6.c: Likewise.
+ * tst-flock2.c: Likewise.
+ * tst-mutex4.c: Likewise.
+ * tst-rwlock4.c: Likewise.
+ * tst-signal1.c: Likewise.
+ * tst-spin2.c: Likewise.
+ * tst-cond11.c [! _POSIX_CLOCK_SELECTION]: Likewise.
+
+ * tst-mutex4.c: Use test-skeleton.c.
+ * tst-spin2.c: Likewise.
+ * tst-sysconf.c: Likewise.
+ * tst-barrier2.c: Likewise.
+ * tst-cond4.c: Likewise.
+ * tst-cond6.c: Likewise.
+ * tst-rwlock4.c: Likewise.
+ * tst-unload.c: Likewise.
+ * tst-flock2.c (do_test): Use return instead of exit.
+
+2003-03-22 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/fork.c (__fork): Add libc_hidden_def.
+
+2003-03-21 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/ia64/lowlevellock.h
+ (__lll_mutex_trylock): Use atomic_compare_and_exchange_val_acq
+ instead of __lll_compare_and_swap.
+ * sysdeps/unix/sysv/linux/ia64/pthread_once.c (__pthread_once):
+ Likewise.
+ Removed definition if __lll_compare_and_swap.
+
+ * cancellation.c: Adjust for new form of compare&exchange macros.
+ * cleanup_defer.c: Likewise.
+ * init.c: Likewise.
+ * libc-cancellation.c: Likewise.
+ * old_pthread_cond_broadcast.c: Likewise.
+ * old_pthread_cond_signal.c: Likewise.
+ * old_pthread_cond_timedwait.c: Likewise.
+ * old_pthread_cond_wait.c: Likewise.
+ * pthread_cancel.c: Likewise.
+ * pthread_create.c: Likewise.
+ * pthread_detach.c: Likewise.
+ * pthread_join.c: Likewise.
+ * pthread_key_delete.c: Likewise.
+ * pthread_setcancelstate.c: Likewise.
+ * pthread_setcanceltype.c: Likewise.
+ * pthread_timedjoin.c: Likewise.
+ * pthread_tryjoin.c: Likewise.
+ * sysdeps/pthread/createthread.c: Likewise.
+
+2003-03-20 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/ia64/lowlevellock.h: Include <atomic.h>.
+ Remove __lll_add, __lll_dec_if_positive, and __lll_test_and_set
+ definitions. Replace uses with calls to atomic_* functions.
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/lowlevellock.c: Replace __lll_add and
+ __lll_test_and_set calls with atomic_exchange_and_add and
+ atomic_exchange calls respectively.
+ * sysdeps/unix/sysv/linux/sem_post.c: Likewise.
+ * sysdeps/unix/sysv/linux/sem_timedwait.c: Likewise.
+ * sysdeps/unix/sysv/linux/sem_trywait.c: Likewise.
+ * sysdeps/unix/sysv/linux/sem_wait.c: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/pthread_once.c: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/sem_port.c: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/pthread_once.c: Likewise.
+
+ * allocatestack.c (allocate_stack): Assume atomic_exchange_and_add
+ returns the old value.
+
+2003-03-20 Martin Schwidefsky <sky@mschwid3.boeblingen.de.ibm.com>
+
+ * sysdeps/s390/pthread_spin_lock.c (pthread_spin_lock): Use type
+ int for variable OLDVAL and correct inline assembler contraint.
+ * sysdeps/s390/pthread_spin_trylock.c (pthread_spin_trylock): Use
+ type int for variable OLD.
+
+ * sysdeps/s390/tls.h (TLS_MULTIPLE_THREADS_IN_TCB): Define it
+ only for s390-32.
+ * sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h
+ (SINGLE_THREAD_P): Use global variable __local_multiple_threads
+ instead of multiple_threads field in the TCB.
+
+2003-03-19 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/i386/i686/bits/atomic.h: Removed.
+ * sysdeps/i386/i586/bits/atomic.h: Removed.
+ * sysdeps/i386/i486/bits/atomic.h: Removed. Moved to glibc.
+ * sysdeps/x86_64/bits/atomic.h: Removed. Moved to glibc.
+ * sysdeps/s390/bits/atomic.h: Removed. Moved to glibc.
+ * sysdeps/sh/bits/atomic.h: Removed. Moved to glibc.
+ * sysdeps/ia64/bits/atomic.h: Removed. Moved to glibc.
+ * sysdeps/powerpc/bits/atomic.h: Removed. Moved to glibc.
+ * atomic.h: Removed. Moved to glibc.
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Add
+ support for clock selection.
+
+ * sysdeps/pthread/pthread_cond_broadcast.c: Release lock before
+ signalling waiters.
+
+2003-03-18 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h (__lll_test_and_set):
+ Add __lll_rel_instr first. Add memory clobber.
+ (lll_mutex_unlock): Use __lll_test_and_set.
+ From Paul Mackerras <paulus@samba.org>.
+
+ * sysdeps/powerpc/tls.h (TLS_MULTIPLE_THREADS_IN_TCB): Define
+ unconditionally.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h
+ (SINGLE_THREAD_P): Add `header.' prefix.
+ From Paul Mackerras <paulus@samba.org>.
+
+ * Versions (libpthread: GLIBC_2.3.2): Move pthread_tryjoin_np and
+ pthread_timedjoin_np to ...
+ (libpthread: GLIBC_2.3.3): ... here.
+ (libpthread: GLIBC_2.2): Move pthread_barrierattr_getpshared there too.
+
+ * sysdeps/pthread/pthread_cond_timedwait.c (__pthread_cond_timedwait):
+ Avoid shadowing VAL variable.
+
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h (__lll_test_and_set):
+ New macro.
+
+2003-03-18 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (tests): Add tst-cond11.
+ * tst-cond11.c: New file.
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Reorder
+ struct passed to cleanup handler to eliminate one more
+ instruction.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Likewise.
+
+ * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h
+ (pthrad_cond_t): Replace __unused field with __clock.
+
+ * sysdeps/pthread/pthread_cond_wait.c: Release condvar lock before
+ waken all waiters in cleanup handler.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Likewise.
+
+ * pthread_condattr_getclock.c: New file.
+ * pthread_condattr_setclock.c: New file.
+ * sysdeps/pthread/pthread.h: Declare these new functions.
+ * Versions [GLIBC_2.3.3] (libpthread): Add the new functions.
+ * Makefile (libpthread-routines): Add the new functions.
+ * sysdeps/unix/sysv/linux/internaltypes.h (struct pthread_condattr):
+ Renamed field to value. Document use of the bits.
+ * pthread_condattr_getpshared.c: Adjust for struct pthread_condattr
+ change.
+ * pthread_condattr_setpshared.c: Likewise.
+ * pthread_cond_init.c (__pthread_cond_init): Initialized __clock field.
+ * sysdeps/unix/sysv/linux/lowlevelcond.sym: Add cond_clock symbol.
+ * sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h (pthread_cond_t):
+ Add __clock field.
+ * sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S:
+ Implement clock selection.
+ * sysdeps/pthread/pthread_cond_timedwait.c: Likewise.
+ * pthread-errnos.sym: Add ENOSYS.
+ * sysdeps/unix/sysv/linux/bits/posix_opt.h: Define
+ _POSIX_CLOCK_SELECTION.
+ * sysdeps/unix/sysv/linux/i386/bits/posix_opt.h: Likewise.
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Remove
+ invalid .size directive.
+
+2003-03-17 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/unix/sysv/linux/lowlevellock.c (__lll_lock_wait):
+ Formatting tweaks.
+
+2003-03-17 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/ia64/pthread_once.c: Use __builtin_expect.
+ Use __lll_add instead of spelling it out. Use protected symbol names.
+ * sysdeps/unix/sysv/linux/ia64/sem_post.c: Use __builtin_expect.
+ Use __lll_add.
+ * sysdeps/unix/sysv/linux/ia64/lowlevellock.h (__lll_compare_and_swap):
+ Renamed from lll_compare_and_swap. Use new name where necessary.
+ (__lll_add): Defined.
+ (__lll_dec_if_positive): Defined.
+ (__lll_test_and_set): Defined.
+ * sysdeps/ia64/pthread_spin_init.c: Removed.
+ * sysdeps/unix/sysv/linux/ia64/lowlevelmutex.c: Removed.
+ * sysdeps/unix/sysv/linux/ia64/sem_trywait.c: Removed.
+ * sysdeps/unix/sysv/linux/ia64/sem_wait.c: Removed.
+ * sysdeps/unix/sysv/linux/ia64/lowlevellock.c: Removed.
+ * sysdeps/unix/sysv/linux/ia64/libc-lowlevellock.c: Removed.
+ * sysdeps/unix/sysv/linux/ia64/libc-lowlevelmutex.c: Removed.
+ * sysdeps/unix/sysv/linux/ia64/sem_timedwait.c: Removed.
+ * sysdeps/ia64/bits/atomic.h: Add __builtin_expect where appropriate.
+ * sysdeps/ia64/pthread_spin_unlock.c (pthread_spin_unlock): Use
+ __sync_lock_release_si.
+ Patch by Jakub Jelinek.
+
+ * sysdeps/unix/sysv/linux/lowlevellock.c (__lll_timedlock_wait):
+ Fix timeout handling.
+ (__lll_timedwait_tid): Likewise.
+ (lll_unlock_wake_cb): Wake up other waiters if necessary.
+ Patch by Jakub Jelinek.
+
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h: Pretty printing.
+
+2003-03-17 Roland McGrath <roland@redhat.com>
+
+ PowerPC port contributed by Paul Mackerras <paulus@samba.org>.
+ * sysdeps/pthread/pthread_spin_init.c: New file.
+ * sysdeps/pthread/pthread_spin_unlock.c: New file.
+ * sysdeps/powerpc/Makefile: New file.
+ * sysdeps/powerpc/pthread_spin_lock.c: New file.
+ * sysdeps/powerpc/pthread_spin_trylock.c: New file.
+ * sysdeps/powerpc/pthreaddef.h: New file.
+ * sysdeps/powerpc/tcb-offsets.sym: New file.
+ * sysdeps/powerpc/td_ta_map_lwp2thr.c: New file.
+ * sysdeps/powerpc/tls.h: New file.
+ * sysdeps/powerpc/bits/atomic.h: New file.
+ * sysdeps/unix/sysv/linux/libc-lowlevelmutex.c: New file.
+ * sysdeps/unix/sysv/linux/libc-lowlevellock.c: New file.
+ * sysdeps/unix/sysv/linux/lowlevellock.c: New file.
+
+ * sysdeps/unix/sysv/linux/lowlevelmutex.c: New file.
+ * sysdeps/unix/sysv/linux/sem_post.c: New file.
+ * sysdeps/unix/sysv/linux/sem_timedwait.c: New file.
+ * sysdeps/unix/sysv/linux/sem_trywait.c: New file.
+ * sysdeps/unix/sysv/linux/sem_wait.c: New file.
+ * sysdeps/unix/sysv/linux/powerpc/Makefile: New file.
+ * sysdeps/unix/sysv/linux/powerpc/createthread.c: New file.
+ * sysdeps/unix/sysv/linux/powerpc/fork.c: New file.
+ * sysdeps/unix/sysv/linux/powerpc/lowlevellock.h: New file.
+ * sysdeps/unix/sysv/linux/powerpc/pt-vfork.S: New file.
+ * sysdeps/unix/sysv/linux/powerpc/pthread_once.c: New file.
+ * sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h: New file.
+ * sysdeps/unix/sysv/linux/powerpc/bits/semaphore.h: New file.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h: New file.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h: New file.
+
+ * sysdeps/unix/sysv/linux/ia64/lowlevellock.c: Use __gettimeofday,
+ not gettimeofday.
+ * sysdeps/unix/sysv/linux/ia64/lowlevelmutex.c: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/sem_timedwait.c: Likewise.
+ * sysdeps/unix/sysv/linux/s390/lowlevellock.c: Likewise.
+ * sysdeps/unix/sysv/linux/s390/lowlevelmutex.c: Likewise.
+ * sysdeps/unix/sysv/linux/s390/sem_timedwait.c: Likewise.
+
+2003-03-17 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/pthread_cond_wait.c: Correct exit criteria.
+ * sysdeps/pthread/pthread_cond_timedwait.c: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Likewise.
+ Patch by Ewald Snel <ewald@rambo.its.tudelft.nl>.
+
+2003-03-16 Roland McGrath <roland@redhat.com>
+
+ * tst-fork4.c: Include <string.h>.
+ * tst-signal2.c: Likewise.
+ * tst-mutex5.c (do_test): exit -> return.
+ * tst-mutex2.c: Include <stdlib.h>.
+
+2003-03-16 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevelmutex.S
+ (__lll_mutex_timedlock_wait): Correct expected value after
+ spurious wakeup. Otherwise we would never wait again.
+
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Work around red
+ zone versus inline asm stupidity. Use correct instructions.
+
+ * tst-rwlock6.c: Add some more status output.
+
+2003-03-15 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/pthread/configure.in: New file.
+ * sysdeps/pthread/configure: New file (generated).
+
+2003-03-15 Ulrich Drepper <drepper@redhat.com>
+
+ * allocatestack.c (allocate_stack): Store the exact stack size of
+ user allocated stacks.
+
+2003-03-15 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h
+ (SINGLE_THREAD): Use `header' prefix instead of `header.data'.
+ * sysdeps/sh/tcb-offsets.sym (MULTIPLE_THREADS_OFFSET): Likewise.
+ * sysdeps/sh/tls.h (TLS_MULTIPLE_THREADS_IN_TCB): Define.
+ * sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h (SINGLE_THREAD_P):
+ Use `header.' prefix.
+ * sysdeps/ia64/tcb-offsets.sym (MULTIPLE_THREADS_OFFSET): Likewise.
+
+2003-03-15 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/x86_64/pthreaddef.h (CURRENT_STACK_FRAME): Don't use
+ __builtin_frame_address, use stack pointer.
+
+ * sysdeps/unix/sysv/linux/jmp-unwind.c: Use CURRENT_STACK_FRAME
+ instead of __builtin_frame_pointer.
+
+2003-03-14 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-basic1.c (do_test): Add cast to avoid warning.
+ * tst-basic2.c (do_test): Likewise.
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_once.S: Use correct
+ amount of stack correction.
+
+ * tst-fork4.c: Use test-skeleton.c.
+
+2003-03-14 Roland McGrath <roland@redhat.com>
+
+ * init.c: Fix typo "#eli" for "#else".
+
+2003-03-14 Steven Munroe <sjmunroe@us.ibm.com>
+
+ * allocatestack.c (__stack_user): Use hidden_data_def.
+ * pthread_create.c (__pthread_keys): Likewise.
+
+ * init.c [__powerpc__] (__NR_set_tid_address): Define it.
+
+2003-03-14 Roland McGrath <roland@redhat.com>
+
+ * tst-fork4.c: New file.
+ * Makefile (tests): Add it.
+
+ * descr.h (struct pthread): Move the union out of [!TLS_DTV_AT_TP], so
+ we always define the padding space.
+ [!TLS_DTV_AT_TP]: Give tcbhead_t field a name, `header', since GCC
+ stopped supporting its own extensions fully.
+ [TLS_MULTIPLE_THREADS_IN_TCB]: Put `multiple_threads' inside a wrapper
+ struct also called `header', so `header.multiple_threads' is the field
+ name to use on all machines.
+ * allocatestack.c (allocate_stack): Use `header.' prefix.
+ * sysdeps/pthread/createthread.c (create_thread): Likewise.
+ * pthread_create.c (__pthread_create_2_1): Likewise.
+ * sysdeps/i386/tls.h (INSTALL_NEW_DTV, THREAD_DTV): Likewise.
+ (THREAD_SELF): Likewise.
+ * sysdeps/x86_64/tls.h: Likewise.
+ * sysdeps/unix/sysv/linux/i386/sysdep-cancel.h
+ (SINGLE_THREAD_P): Likewise.
+ * sysdeps/unix/sysv/linux/sh/sysdep-cancel.h
+ (SINGLE_THREAD_P): Likewise.
+ * sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h
+ (SINGLE_THREAD_P): Likewise.
+
+ * sysdeps/s390/td_ta_map_lwp2thr.c (td_ta_map_lwp2thr): Use REGS[18]
+ value directly.
+
+2003-03-14 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_create.c (start_thread): Use CALL_THREAD_FCT if defined.
+ * sysdeps/i386/tls.h: Define CALL_THREAD_FCT.
+
+ * pthread_create.c (start_thread): setjmp is expected to return 0.
+
+ * sysdeps/x86_64/tls.h (THREAD_GETMEM): Mark asms volatile.
+ (THREAD_GETMEM_NC): Likewise.
+
+2003-03-13 Ulrich Drepper <drepper@redhat.com>
+
+ * allocatestack.c (allocate_stack): If MULTI_PAGE_ALIASING is defined
+ and the size of the stack which must be allocated is a multiple,
+ allocate one more page.
+ * sysdeps/i386/i686/Makefile: Don't define COLORING_INCREMENT, but
+ MULTI_PAGE_ALIASING.
+
+2003-03-13 Roland McGrath <roland@redhat.com>
+
+ * pthread_create.c (start_thread): Set EXITING_BIT after the
+ event-reporting (and destructors), not before.
+
+2003-03-13 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/ia64/lowlevellock.h (lll_futex_timed_wait,
+ lll_futex_wake): Declare register variables as long int instead of
+ unsigned long int. Patch by Ian Wienand <ianw@gelato.unsw.edu.au>.
+ Make syscall arguments clobbered by the syscall.
+ (lll_futex_wait): Define using lll_futex_timed_wait.
+
+ * sysdeps/ia64/td_ta_map_lwp2thr.c (td_ta_map_lwp2thr): Cast regs[13]
+ to void *.
+
+ * sysdeps/unix/sysv/linux/fork.c (__libc_fork): Only declare and set
+ PPID if [! NDEBUG].
+
+ * allocatestack.c (nptl_ncreated): Only declare if
+ COLORING_INCREMENT != 0.
+
+ * pthreadP.h (__pthread_enable_asynccancel_2): New prototype.
+ (__libc_enable_asynccancel_2): Remove prototype.
+
+ * sysdeps/unix/sysv/linux/ia64/fork.c (ARCH_FORK): Swap ptid and
+ ctid to match kernel.
+
+2003-03-12 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/Makefile (sysdep_routines): Add
+ libc_multiple_threads.
+ * sysdeps/unix/sysv/linux/libc_pthread_init.c: Move definition of
+ __libc_multiple_threads to...
+ * sysdeps/unix/sysv/linux/libc_multiple_threads.c: ...here. New file.
+
+ * sysdeps/unix/sysv/linux/x86_64/sem_post.S: Remove unnecessary
+ versioning.
+ * sysdeps/unix/sysv/linux/x86_64/sem_trywait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sem_wait.S: Likewise.
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_once.S
+ (__pthread_once_internal): Define.
+
+ * sysdeps/unix/sysv/linux/i386/i486/sem_post.S: Use shlib-compat.h
+ macros instead of .symver directly.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_trywait.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_wait.S: Likewise.
+
+ * sysdeps/x86_64/tls.h [__ASSEMBLER__]: Include tcb-offsets.h.
+ * sysdeps/x86_64/tcb-offsets.sym: New file.
+ * sysdeps/x86_64/Makefile: New file.
+
+ * sysdeps/i386/tcb-offsets.sym: Add SELF.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S: Use SELF
+ to access own pthread_t in TCB.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S: Likewise.
+
+2003-03-12 Roland McGrath <roland@redhat.com>
+
+ * pthread-errnos.sym: New file.
+ * Makefile (gen-as-const-headers): New variable, list that file.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_wait.S: Include generated
+ header <pthread-errnos.h> instead of defining errno values here.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_trywait.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_post.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevelmutex.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sem_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sem_trywait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sem_post.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevelmutex.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/sem_trywait.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/sem_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/sem_post.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/sem_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_wrlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedwrlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedrdlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_rdlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/lowlevelmutex.S: Likewise.
+ * sysdeps/i386/i486/pthread_spin_trylock.S: Likewise.
+ * sysdeps/x86_64/pthread_spin_trylock.S: Likewise.
+ * sysdeps/sh/pthread_spin_trylock.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S: Likewise.
+
+ * sysdeps/unix/sysv/linux/fork.c: Add an assert to check that
+ CLONE_CHILD_SETTID worked.
+
+2003-03-12 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S: New
+ file.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S: New
+ file.
+
+ * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h
+ (pthread_cond_t): Add padding.
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S: New file.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S: New file.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S: New file.
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S
+ (__pthread_rwlock_timedwrlock): Add missing opcode suffix.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S
+ (__pthread_rwlock_timedrdlock): Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S
+ (__pthread_rwlock_wrlock): Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S
+ (__pthread_rwlock_rdlock): Likewise.
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: New file.
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Return
+ result of lock re-get if it fails.
+
+2003-03-11 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.S: Fix asm syntax.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevelmutex.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_once.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sem_post.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sem_trywait.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sem_wait.S: Likewise.
+
+ * sysdeps/x86_64/tls.h (THREAD_SELF, THREAD_GETMEM, THREAD_GETMEM_NC,
+ THREAD_SETMEM, THREAD_SETMEM_NC): Correct asm syntax.
+
+ * allocatestack.c [! TLS_MULTIPLE_THREADS_IN_TCB] (allocate_stack):
+ Initialize *__libc_multiple_threads_ptr not __libc_multiple_threads.
+ * sysdeps/pthread/createthread.c [! TLS_MULTIPLE_THREADS_IN_TCB]
+ (create_thread): Likewise.
+ Define __pthread_multiple_threads and __libc_multiple_threads_ptr.
+ * init.c (__pthread_initialize_minimal_internal): Initialize
+ __libc_multiple_threads_ptr if necessary.
+ * pthreadP.h: Adjust prototype for __libc_pthread_init. Declare
+ __pthread_multiple_threads and __libc_multiple_threads_ptr.
+ * sysdeps/unix/sysv/linux/libc_pthread_init.c: Define
+ __libc_multiple_threads.
+ (__libc_pthread_init): Return pointer to __libc_pthread_init if
+ necessary.
+
+ * sysdeps/i386/tls.h (THREAD_SETMEM): Fix one-byte variant.
+ (THREAD_SETMEM_NC): Likewise.
+
+ * sysdeps/x86_64/pthread_spin_trylock.c: Removed.
+ * sysdeps/x86_64/pthread_spin_trylock.S: New file.
+ * sysdeps/x86_64/pthread_spin_unlock.c: Removed.
+ * sysdeps/x86_64/pthread_spin_unlock.S: New file.
+
+ * sysdeps/i386/i486/pthread_spin_trylock.S (pthread_spin_trylock):
+ Eliminate one entire instruction.
+
+ * cancellation.c (__pthread_enable_asynccancel_2): New function.
+ * pthreadP.h: Declare __pthread_enable_asynccancel_2.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S
+ (__pthread_cond_timedwait): Use __pthread_enable_asynccancel_2
+ instead of __pthread_enable_asynccancel.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S
+ (__pthread_cond_wait): Likewise.
+ * sysdeps/pthread/pthread_cond_timedwait.c
+ (__pthread_cond_timedwait): Likewise.
+ * sysdeps/pthread/pthread_cond_wait.c (__pthread_cond_wait): Likewise.
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S
+ (__condvar_cleanup): Wake up all waiters in case we got signaled
+ after being woken up but before disabling asynchronous
+ cancellation.
+ * sysdeps/pthread/pthread_cond_wait.c (__condvar_cleanup): Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
+ (__condvar_cleanup): Likewise.
+
+ * init.c (__NR_set_tid_address): If already defined, don't redefine.
+ Make it an error if architecture has no #if case. Add x86-64.
+
+ * sysdeps/unix/sysv/linux/x86_64/Makefile: Add flags for
+ pt-initfini.s generation.
+
+ * sysdeps/x86_64/tls.h: Include <asm/prctl.h>.
+ (TLS_INIT_TP): Fix typo.
+
+2003-03-11 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/ia64/bits/atomic.h (atomic_exchange_and_add): Swap 2nd and
+ 3rd argument of __arch_compare_and_exchange_{32,64}_val_acq.
+
+ * sysdeps/unix/sysv/linux/ia64/sem_post.c: Include semaphore.h.
+ * sysdeps/unix/sysv/linux/ia64/sem_timedwait.c: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/sem_trywait.c: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/sem_wait.c: Likewise.
+ * sysdeps/unix/sysv/linux/s390/sem_post.c: Likewise.
+ * sysdeps/unix/sysv/linux/s390/sem_timedwait.c: Likewise.
+ * sysdeps/unix/sysv/linux/s390/sem_trywait.c: Likewise.
+ * sysdeps/unix/sysv/linux/s390/sem_wait.c: Likewise.
+
+2003-03-11 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/pthread_cond_timedwait.c
+ (__pthread_cond_timedwait): Return the result of the final
+ locking. If it succeeds, the regular function return value.
+
+ * sysdeps/pthread/pthread_cond_wait.c (__pthread_cond_wait):
+ Return result of the final locking.
+ * version.c (__nptl_main): Work around problems with the strange
+ INTERNAL_SYSCALL macro on ppc32.
+ * init.c (__pthread_initialize_minimal_internal): Unblock
+ SIGCANCEL in case the parent blocked it.
+ Reported by Paul Mackerras <paulus@samba.org>.
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S: New file.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S: New file.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: New file.
+
+2003-03-11 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/pthread/pthread_cond_timedwait.c
+ (__pthread_cond_timedwait): Unlock and fail if
+ __pthread_mutex_unlock_internal failed.
+
+ * sysdeps/pthread/createthread.c (ARCH_CLONE): Define if not defined.
+ (create_thread): Only assert PD->tcb != NULL under [TLS_TCB_AT_TP].
+ Use ARCH_CLONE.
+ * allocatestack.c (ALLOCATE_STACK_PARMS): New macro.
+ [NEED_SEPARATE_REGISTER_STACK] (STACK_VARIABLES,
+ STACK_VARIABLES_ARGS, STACK_VARIABLES_PARMS, ALLOCATE_STACK_PARMS,
+ ALLOCATE_STACK): New macros.
+ (TLS_TPADJ): New macro.
+ (get_cached_stack, queue_stack, __deallocate_stack): Use TLS_TPADJ.
+ (allocate_stack): Handle TLS_DTV_AT_TP and
+ NEED_SEPARATE_REGISTER_STACK. Use TLS_TPADJ.
+ * pthread_create.c (__pthread_create_2_1) [! TLS_TCB_AT_TP]:
+ Don't set PD->self.
+ * init.c [__ia64__] (__NR_set_tid_address): Define.
+
+ * sysdeps/unix/sysv/linux/ia64/bits/pthreadtypes.h: New file.
+ * sysdeps/unix/sysv/linux/ia64/bits/semaphore.h: New file.
+ * sysdeps/unix/sysv/linux/ia64/fork.c: New file.
+ * sysdeps/unix/sysv/linux/ia64/createthread.c: New file.
+ * sysdeps/unix/sysv/linux/ia64/libc-lowlevellock.c: New file.
+ * sysdeps/unix/sysv/linux/ia64/libc-lowlevelmutex.c: New file.
+ * sysdeps/unix/sysv/linux/ia64/lowlevellock.c: New file.
+ * sysdeps/unix/sysv/linux/ia64/lowlevellock.h: New file.
+ * sysdeps/unix/sysv/linux/ia64/lowlevelmutex.c: New file.
+ * sysdeps/unix/sysv/linux/ia64/pt-initfini.c: New file.
+ * sysdeps/unix/sysv/linux/ia64/pt-vfork.S: New file.
+ * sysdeps/unix/sysv/linux/ia64/pthread_once.c: New file.
+ * sysdeps/unix/sysv/linux/ia64/sem_post.c: New file.
+ * sysdeps/unix/sysv/linux/ia64/sem_timedwait.c: New file.
+ * sysdeps/unix/sysv/linux/ia64/sem_trywait.c: New file.
+ * sysdeps/unix/sysv/linux/ia64/sem_wait.c: New file.
+ * sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h: New file.
+ * sysdeps/ia64/bits/atomic.h: New file.
+ * sysdeps/ia64/Makefile: New file.
+ * sysdeps/ia64/pthread_spin_init.c: New file.
+ * sysdeps/ia64/pthread_spin_lock.c: New file.
+ * sysdeps/ia64/pthread_spin_trylock.c: New file.
+ * sysdeps/ia64/pthread_spin_unlock.c: New file.
+ * sysdeps/ia64/pthreaddef.h: New file.
+ * sysdeps/ia64/tcb-offsets.sym: New file.
+ * sysdeps/ia64/td_ta_map_lwp2thr.c: New file.
+ * sysdeps/ia64/tls.h: New file.
+
+ * sysdeps/s390/pthreaddef.h (__exit_thread_inline): Pass 1 argument
+ to syscall instead of no arguments.
+
+2003-03-10 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/sem_post.S: New file.
+ * sysdeps/unix/sysv/linux/x86_64/sem_trywait.S: New file.
+ * sysdeps/unix/sysv/linux/x86_64/sem_wait.S: New file.
+ * sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S: New file.
+
+ * sysdeps/unix/sysv/linux/i386/i486/sem_post.S: Fix error value in
+ unused code.
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S: New file
+
+ * sysdeps/unix/sysv/linux/Makefile (gen-as-const-headers): Add
+ lowlevelbarrier.sym.
+ * sysdeps/unix/sysv/linux/lowlevelbarrier.sym: New file.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_barrier_wait.S:
+ Include lowlevelbarrier.h and don't define offsets locally.
+ * sysdeps/unix/sysv/linux/sh/pthread_barrier_wait.S: Likewise.
+
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
+ (__lll_mutex_lock_wait): Reverse order of first two parameters.
+ (__lll_mutex_timedlock_wait): Likewise.
+ (lll_mutex_lock): Adjust asm for that.
+ (lll_mutex_timedlock): Likewise. Mark cx, cc, r10 as clobbered.
+ (lll_lock): Adjust asm for operand order change.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevelmutex.S: New file.
+ * sysdeps/unix/sysv/linux/x86_64/libc-lowlevelmutex.S: New file.
+
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h (__lll_lock_wait):
+ Reverse order of parameters.
+ (__lll_timedwait_tid): Remove regparms attribute.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.S: New file.
+ * sysdeps/unix/sysv/linux/x86_64/libc-lowlevellock.S: New file.
+
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S
+ (__lll_timedwait_tid): Remove one unnecessary instruction.
+
+ * sysdeps/unix/sysv/linux/sh/lowlevelmutex.S: Define
+ __lll_mutex_timedlock_wait only for NOT_IN_libc.
+ * sysdeps/unix/sysv/linux/sh/libc-lowlevelmutex.S: Include
+ lowlevelmutex.S.
+
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.S: Define
+ lll_unlock_wake_cb, __lll_wait_tid, and __lll_timedwait_tid only
+ for NOT_IN_libc.
+ * sysdeps/unix/sysv/linux/sh/libc-lowlevellock.S: Include
+ lowlevellock.S.
+
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevelmutex.S: Don't define
+ LOCK is already defined. Don't define __lll_mutex_timedlock_wait
+ for libc.so.
+ * sysdeps/unix/sysv/linux/i386/i486/libc-lowlevelmutex.S: Only
+ define LOCK here (if UP is not defined). The actual code is in
+ lowlevelmutex.S.
+
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S: Don't define
+ LOCK is already defined. Don't define lll_unlock_wake_cb and
+ __lll_timedwait_tid for libc.so.
+ * sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S: Only
+ define LOCK here (if UP is not defined). The actual code is in
+ lowlevellock.S.
+
+ * sysdeps/unix/sysv/linux/i386/lowlevelsem.h: Not needed anymore.
+ * sysdeps/unix/sysv/linux/s390/lowlevelsem.h: Likewise.
+ * sysdeps/unix/sysv/linux/s390/sem_post.c: Include lowlevellock.h
+ instead of lowlevelsem.h.
+ * sysdeps/unix/sysv/linux/s390/sem_timedwait.c: Likewise.
+ * sysdeps/unix/sysv/linux/s390/sem_trywait.c: Likewise.
+ * sysdeps/unix/sysv/linux/s390/sem_wait.c: Likewise.
+
+ * sysdeps/unix/sysv/linux/Makefile (gen-as-const-headers): Add
+ lowlevelrwlock.sym.
+ * sysdeps/unix/sysv/linux/lowlevelrwlock.sym: New file.
+ * sysdeps/unix/sysv/linux/i386/lowlevelrwlock.h: Removed.
+ * sysdeps/unix/sysv/linux/sh/lowlevelrwlock.h: Removed.
+
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h (lll_trylock): Fix
+ register loading.
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h (lll_trylock): Undo
+ last changed. D'oh.
+
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: New file.
+
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h: Remove declaration
+ of __libc_locking_needed.
+ (lll_trylock): Initialize %eax to zero.
+
+ * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h: Update
+ pthread_cond_t definition.
+
+2003-03-10 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/unix/sysv/linux/lowlevelcond.sym: New file.
+ * sysdeps/unix/sysv/linux/Makefile (gen-as-const-headers): Add it.
+ * sysdeps/unix/sysv/linux/sh/lowlevelcond.h: File removed.
+ * sysdeps/unix/sysv/linux/i386/lowlevelcond.h: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevelcond.h: Likewise.
+
+ * allocatestack.c (allocate_stack) [!TLS_MULTIPLE_THREADS_IN_TCB]:
+ Instead of setting PD->multiple_threads, set globals
+ __pthread_multiple_threads and __libc_multiple_threads.
+ * sysdeps/pthread/createthread.c (create_thread): Likewise.
+ * sysdeps/i386/tls.h (TLS_MULTIPLE_THREADS_IN_TCB): Define it.
+ * sysdeps/s390/tls.h (TLS_MULTIPLE_THREADS_IN_TCB): Likewise.
+
+ * descr.h (struct pthread): Conditionalize first member on
+ [!TLS_DTV_AT_TP]. Replace the `header' member with an anonymous union
+ containing an anonymous tcbhead_t. Move `list' member out.
+ [TLS_MULTIPLE_THREADS_IN_TCB]: Define a `multiple_threads' member.
+ * allocatestack.c: Remove use of `header.data.' prefix.
+ * pthread_create.c: Likewise.
+ * init.c (__pthread_initialize_minimal_internal): Likewise.
+ * sysdeps/pthread/createthread.c (create_thread): Likewise.
+ * sysdeps/i386/tls.h (INSTALL_DTV): Add parens.
+ (THREAD_SELF, THREAD_DTV, INSTALL_NEW_DTV): No `header.data.' prefix.
+ * sysdeps/x86_64/tls.h: Likewise.
+ * sysdeps/unix/sysv/linux/i386/sysdep-cancel.h
+ (SINGLE_THREAD_P): Likewise.
+ * sysdeps/unix/sysv/linux/sh/sysdep-cancel.h
+ (SINGLE_THREAD_P): Likewise.
+ * sysdeps/i386/tls.h (tcbhead_t): Remove `list' member.
+ * sysdeps/s390/tls.h (tcbhead_t): Likewise.
+
+2003-03-09 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/lowlevelcond.h: New file.
+
+ * sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h: New file.
+ * sysdeps/unix/sysv/linux/x86_64/fork.c: New file.
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_once.S: Fix many
+ leftovers from the ia32 code.
+
+ * sysdeps/unix/sysv/linux/i386/pthread_once.S: Remove unneccessary
+ memory load.
+ (clear_once_control): Don't load %esi.
+
+ * sysdeps/x86_64/tls.h: Remove all traces of segment descriptor
+ handling.
+
+ * sysdeps/unix/sysv/linux/x86_64/fork.c: New file.
+
+ * sysdeps/unix/sysv/linux/s390/createthread.c: Moved to...
+ * sysdeps/unix/sysv/linux/createthread.c: ...here.
+
+ * Makefile (tests): Add tst-cond10.
+ * tst-cond10.c: New file.
+
+2003-03-08 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-tls2.c (do_test): Add TEMP_FAILURE_RETRY around sem_wait call.
+ * tst-signal3.c (do_test): Likewise.
+ * tst-sem5.c (do_test): Likewise.
+ * tst-kill6.c (do_test): Likewise.
+ * tst-tls3.c (do_test): Likewise. Include <errno.h>.
+
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h: Use add/sub instead
+ of inc/dec.
+ * sysdeps/unix/sysv/linux/i386/lowlevelsem.h: Likewise.
+ * sysdeps/unix/sysv/linux/i386/pthread_once.S: Likewise
+ * sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_post.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_unlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_barrier_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevelmutex.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S: Likewise.
+
+ * allocatestack.c (allocate_stack): If mprotect() fails free the
+ TLS memory.
+
+2003-03-07 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/i386/i486/bits/atomic.h: Fix a few unused definitions.
+
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h: Remove all trace of
+ lll_wake_tid. This was used only to work around kernel limits in
+ the early days.
+ * sysdeps/unix/sysv/linux/s390/lowlevellock.h: Likewise.
+ * sysdeps/unix/sysv/linux/sh/libc-lowlevellock.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.S: Likewise.
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.h: Likewise.
+
+ * init.c (__static_tls_align_m1): Renamed from __static_tls_align.
+ (__pthread_initialize_minimal_internal): Change initialization of
+ __static_tls_align_m1 appropriately.
+ * pthreadP.h (__static_tls_align_m1): Renamed from
+ __static_tls_align.
+ * allocatestack.c (allocate_stack): Use __static_tls_align_m1
+ instead of __static_tls_align-1.
+
+2003-03-04 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/x86_64/Makefile: New file.
+
+ * pthread_create.c: Define __pthread_keys using nocommon
+ attribute, not by placing it explicitly in bss.
+ Remove DEFINE_DEALLOC definition. Not needed anymore.
+
+ * allocatestack.c: Define ARCH_MAP_FLAGS if not already defined.
+ Use it in mmap call to allocate stacks.
+
+ * sysdeps/pthread/createthread.c (create_thread): Fix comment.
+
+ * pthread_create.c (start_thread): Use THREAD_SETMEM to store
+ result of the thread function.
+
+2003-03-03 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/s390/dl-sysdep.h: Removed. The generic
+ version is just fine.
+
+ * sysdeps/unix/sysv/linux/libc_pthread_init.c
+ (__pthread_child_handler): Renamed from pthread_child_handler,
+ exported, and marked hidden. Change all users.
+ * sysdeps/unix/sysv/linux/register-atfork.c (free_mem): Do not
+ free __pthread_child_handler from child list.
+
+2003-03-03 Martin Schwidefsky <schwidefsky@de.ibm.com>
+
+ * atomic.h (atomic_exchange_and_add): Return newval, not oldval.
+
+ * sysdeps/pthread/pthread_cond_timedwait.c (__pthread_cond_timedwait):
+ Fix handling of cancellation and failing pthread_mutex_unlock call.
+ * sysdeps/pthread/pthread_cond_wait.c (__condvar_cleanup): Likewise.
+ (__pthread_cond_wait): Likewise.
+
+ * sysdeps/pthread/pthread_rwlock_timedrdlock.c
+ (pthread_rwlock_timedrdlock): Fix clobber of result variable by
+ lll_futex_timed_wait call.
+ * sysdeps/pthread/pthread_rwlock_timedwrlock.c
+ (pthread_rwlock_timedwrlock): Likewise.
+
+ * sysdeps/unix/sysv/linux/s390/libc-lowlevellock.c (___lll_lock):
+ Don't define lll_unlock_wake_cb and ___lll_timedwait_tid in libc.so.
+ * sysdeps/unix/sysv/linux/s390/lowlevellock.c: Remove XXX comments.
+
+ * sysdeps/unix/sysv/linux/s390/sem_post.c (__new_sem_post): Fix
+ check of lll_futex_wake return value.
+
+2003-03-03 Roland McGrath <roland@redhat.com>
+
+ * forward.c: Fix typo in __pthread_attr_init_2_0 compat_symbol decl.
+
+ * sysdeps/pthread/pthread-functions.h (struct pthread_functions):
+ Argument to ptr___pthread_cleanup_upto is __jmp_buf, not jmp_buf.
+ * sysdeps/unix/sysv/linux/jmp-unwind.c: Likewise.
+
+2003-03-02 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/timer_create.c (timer_create): Return correct
+ error for CPU clocks.
+
+ * sysdeps/unix/sysv/linux/bits/posix_opt.h: Define
+ _POSIX_MONOTONIC_CLOCK.
+ * sysdeps/unix/sysv/linux/i386/bits/posix_opt.h: Likewise.
+
+ * tst-cancel4.c (tf_sleep): Lower sleep time a bit to not upset
+ recent kernels.
+
+2003-03-01 Ulrich Drepper <drepper@redhat.com>
+
+ * descr.h (struct pthread): Move cleanup field to the front.
+
+2003-03-01 Roland McGrath <roland@redhat.com>
+
+ * sem_open.c (sem_open): Braino fix.
+
+2003-03-01 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/i386/tcb-offsets.sym: Add CLEANUP and CLEANUP_PREV.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Inline
+ __pthread_cleanup_pop functionality.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Likewise.
+
+ * descr.h (struct pthread): Move tid field to the front now that
+ it is often used.
+
+ * sysdeps/unix/sysv/linux/i386/i486/libc-lowlevelmutex.S
+ (__lll_mutex_timedlock_wait): Remove.
+ (__lll_mutex_unlock_wake): Don't save, load, and restore %esi.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevelmutex.S
+ (__lll_mutex_unlock_wake): Don't save, load, and restore %esi.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S
+ (lll_unlock_wake_cb): Don't save and restore %esi.
+ (__lll_unlock_wake): Add alignment. Don't save, load, and restore
+ %esi.
+ (__lll_timedwait_tid): Add alignment.
+ * sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S
+ (__lll_unlock_wake): Add alignment. Don't save, load, and restore
+ %esi.
+ (__lll_timedwait_tid): Removed.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S
+ (__pthread_cond_broadcast): Don't save, load, and restore %esi.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_barrier_wait.S
+ (pthread_barrier_wait): Don't save, load, and restore %esi for
+ last thread.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S
+ (__pthread_cond_signal): Don't save, load, and restore %esi.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_unlock.S
+ (__pthread_rwlock_unlock): Don't save, load, and restore %esi.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_post.S (__new_sem_post):
+ Don't save, load, and restore %esi.
+
+2003-02-27 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S:
+ Release lock before waking up the waiters.
+
+ * tst-exit1.c (do_test): Don't start more than one thread in parallel.
+
+ * tst-rwlock9.c (writer_thread): Correct adding TIMEOUT.
+ (reader_thread): Likewise.
+
+ * sysdeps/pthread/pthread_rwlock_unlock.c
+ (__pthread_rwlock_unlock): Release internal lock early. Don't try
+ to wake up readers if there are none.
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_unlock.S:
+ Release internal lock before wake threads.
+
+2003-02-26 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (tests): Add tst-rwlock10 and tst-rwlock11.
+ * tst-rwlock8.c: Initialize lock with INIT. Allow INIT to be
+ predefined.
+ * tst-rwlock9.c: Likewise.
+ * tst-rwlock10.c: New file.
+ * tst-rwlock11.c: New file.
+
+ * Makefile (tests): Add tst-dlsym1.
+ * tst-dlsym1.c: New file.
+
+ * init.c (__pthread_initialize_minimal_internal): Set
+ GL(dl_error_catch_tsd) to __libc_dl_error_tsd.
+ * Versions (libc:GLIBC_PRIVATE): Export __libc_dl_error_tsd.
+
+2003-02-24 Ulrich Drepper <drepper@redhat.com>
+
+ * sem_open.c (sem_open): Fix handling of O_CREAT without O_EXCL.
+
+ * tst-cond2.c: Fix sychronization with child.
+
+ * tst-rwlock8.c (reader_thread): Remove unused variable.
+
+ * Makefile: Add rules to build and run tst-tls3.
+ * tst-tls3.c: New file.
+ * tst-tls3mod.c: New file.
+
+ * Makefile (tests): Add tst-rwlock8 and tst-rwlock9.
+ * tst-rwlock8.c: New file.
+ * tst-rwlock9.c: New file.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S: Fix
+ complete broken rwlock implementation.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S:
+ Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_unlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S: Likewise.
+ * sysdeps/pthread/pthread_rwlock_rdlock.c: Likewise.
+ * sysdeps/pthread/pthread_rwlock_timedrdlock.c: Likewise.
+ * sysdeps/pthread/pthread_rwlock_timedwrlock.c: Likewise.
+ * sysdeps/pthread/pthread_rwlock_unlock.c: Likewise.
+ * sysdeps/pthread/pthread_rwlock_wrlock.c: Likewise.
+
+2003-02-23 Roland McGrath <roland@redhat.com>
+
+ * Makefile (nptl-version): Change regexp so case sensitivity is ok.
+
+2003-02-23 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (tests): Add tst-context1.
+ * tst-context1.c: New file.
+
+ * Makefile (tests): Add tst-tls1 and tst-tls2.
+ * tst-tls1.c: New file.
+ * tst-tls2.c: New file.
+
+ * libc-cancellation.c (__libc_enable_asynccancel): Correct test
+ for failed cmpxchg.
+
+ * pthread_create.c (start_thread): Set EXITING_BIT early.
+
+ * sysdeps/i386/tls.h (THREAD_GETMEM): Mark asm as volatile.
+ (THREAD_GETMEM_NC): Likewise.
+
+2003-02-22 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_barrier_wait.S: Shave
+ off 3 more bytes by using offset-less instructions when possible.
+
+ * Makefile: Add dependency for $(objpfx)version.d.
+
+ * eintr.c (eintr_source): Add unnecessary return but the compiler
+ insists.
+
+ * tst-kill3.c: Include <unistd.h>.
+
+2003-02-21 Roland McGrath <roland@redhat.com>
+
+ * pthread_create.c (start_thread): Call __libc_thread_freeres.
+
+2003-02-21 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (tests): Add tst-eintr1.
+ (distribute): Add eintr.c.
+ * tst-eintr1.c: New file.
+ * eintr.c: New file.
+
+ * pthread_cancel.c (pthread_cancel): Use tkill directly.
+
+ * sysdeps/unix/sysv/linux/pthread_kill.c (__pthread_kill):
+ Disallow sending SIGCANCEL.
+
+ * Makefile (tests): Remove tst-basic7. Add tst-kill1, tst-kill2,
+ tst-kill3, tst-kill4, tst-kill5, tst-kill6.
+ * tst-kill1.c: New file.
+ * tst-kill2.c: New file.
+ * tst-kill3.c: New file.
+ * tst-kill5.c: New file.
+ * tst-kill6.c: New file.
+ * tst-basic7.c: Renamed to...
+ * tst-kill4.c: ...this.
+
+2003-02-21 Roland McGrath <roland@redhat.com>
+
+ * Makefile (install-lib-ldscripts): New variable.
+
+2003-02-21 Ulrich Drepper <drepper@redhat.com>
+
+ * pthreadP.h: Define INVALID_TD_P and INVALID_NOT_TERMINATED_TD_P.
+ * pthread_cancel.c: Use INVALID_TD_P.
+ * pthread_detach.c: Likewise.
+ * pthread_getschedparam.c: Likewise.
+ * pthread_setschedparam.c: Likewise.
+ * sysdeps/pthread/pthread_getcpuclockid.c: Likewise.
+ * sysdeps/unix/sysv/linux/pthread_kill.c: Likewise.
+ * pthread_join.c: Use INVALID_NOT_TERMINATED_TD_P.
+ * pthread_timedjoin.c: Likewise.
+
+ * tst-basic7.c: Include <signal.h>.
+
+ * pthread_join.c (pthread_join): Limited checking for invalid
+ descriptors.
+ * pthread_timedjoin.c (pthread_timedjoin_np): Likewise.
+
+2003-02-20 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_create.c (deallocate_tsd): Reset found_nonzero at the
+ beginning of the loop. Clear the entire first block of TSD.
+ * Makefile (tests): Add tst-key4.
+ * tst-key4.c: New file.
+
+2003-02-18 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (tests): Add tst-basic7.
+ * tst-basic7.c: New file.
+
+ * pthread_create.c (deallocate_tsd): Mark as internal_function.
+ Add some more __builtin_expect.
+
+ * pthreadP.h: Define dummy version of DEBUGGING_P.
+
+2003-02-17 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/bits/posix_opt.h: Remnove
+ _POSIX_THREAD_PRIORITY_SCHEDULING.
+ * sysdeps/unix/sysv/linux/i386/bits/posix_opt.h: Remove
+ _XOPEN_REALTIME_THREADS.
+ * sysdeps/unix/sysv/linux/bits/posix_opt.h: Likewise.
+
+ * sysdeps/unix/sysv/linux/pthread_kill.c (__pthread_kill): The
+ kernel returns EINVAL for PID <= 0, work around it.
+
+ * Makefile (tests): Add tst-signal5.
+ * tst-signal5.c: New file.
+
+ * sysdeps/unix/sysv/linux/bits/local_lim.h: Define TTY_NAME_MAX
+ and LOGIN_NAME_MAX.
+
+ * tst-cancel1.c (tf): Block all signals.
+
+ * Makefile (tests): Add tst-basic6.
+ * tst-basic6.c: New file.
+
+ * tst-basic1.c: Add test for process ID.
+
+ * Makefile (tests): Add tst-cancel10.
+ * tst-cancel10.c: New file.
+
+ * Makefile (tests): Add tst-signal4.
+ * tst-signal4.c: New file.
+
+ * sysdeps/pthread/pthread_sigmask.c (pthread_sigmask): Use
+ __sigismember instead of sigismember. Add __builtin_expect.
+
+2003-02-16 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-attr1.c (do_test): Add tests for pthread_setcanceltype,
+ pthread_setcancelstate, and pthread_rwlock_setpshared.
+
+ * tst-cancel7.c (do_test): Make sure the pid file exists before
+ canceling the thread.
+
+ * tst-rwlock6.c: More pthread_rwlock_timedwrlock and
+ pthread_rwlock_timedrdlock tests.
+ * tst-rwlock7.c: More pthread_rwlock_timedwrlock tests.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S:
+ Check for invalid tv_nsec field.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S:
+ Likewise.
+
+ * pthread_mutex_trylock.c (__pthread_mutex_trylock): Protect
+ recursive mutex of overflow.
+
+ * tst-attr1.c (do_test): Add test for pthread_mutexattr_setpshared.
+
+ * libc-cancellation.c (__libc_enable_asynccancel): Rewrite to avoid
+ going into an endless loop.
+ * Makefile (tests): Add tst-cancel9.
+ * tst-cancel9.c: New file.
+
+ * pthread_cancel.c (pthread_cancel): Use the result of __pthread_kill.
+
+2003-02-15 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-mutex5.c (do_test): Add more timedlock tests.
+
+ * tst-mutex2.c: Tests of trylock and unlock with ERROR mutexes.
+ * tst-mutex3.c (do_test): Add tests for trylock with RECURSIVE mutexes.
+
+ * sysdeps/unix/sysv/linux/pthread_kill.c (__pthread_kill): Don't
+ use INLINE_SYSCALL. Error number is returned, not -1.
+
+ * pthreadP.h: Mark declarations of __find_in_stack_list, __free_tcb,
+ and __deallocate_stack with internal_function.
+ * pthread_create.c: Adjust definitions appropriately.
+ * allocatestack.c: Likewise.
+
+ * pthread_join.c: Add one more __builtin_expect.
+ * pthread_timedjoin.c: Likewise.
+
+ * pthread_getspecific.c (__pthread_getspecific): Clear data->data
+ not data of sequence number does not match.
+ Add one __builtin_expect.
+
+ * Makefile (tests): Add tst-clock1.
+ * tst-clock1.c: New file.
+
+ * pthread_setconcurrency.c (pthread_setconcurrency): Fail for
+ negative arguments.
+ * Makefile (tests): Add tst-basic5.
+ * tst-basic5.c: New file.
+
+2003-02-14 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (tests): Add tst-basic4.
+ * tst-basic4.c: New file.
+
+ * pthreadP.h: Add declaraction for __nptl_nthreads.
+ * pthread_create.c: Define __nptl_nthreads
+ (start_thread): Increment __nptl_nthreads at beginning. Decrement
+ after thread is done. If then zero, call exit(0).
+ * sysdeps/pthread/pthread-functions.h (struct pthread_functions):
+ Add ptr_nthreads. Define HAVE_PTR_NTHREADS.
+ * init.c (pthread_functions): Initialize ptr_nthreads.
+ * allocatestack.c (nptl_nthreads): Remove definition and all uses.
+ (__reclaim_stacks): Decrement __nptl_nthreads.
+ * sysdeps/pthread/Makefile [$(subdir)==csu] (CFLAGS-libc-start.c):
+ Define.
+ * Makefile (tests): Add tst-basic3.
+ * tst-basic3.c: New file.
+
+ * descr.h: Define CANCELING_BIT and CANCELING_BITMASK. Introduce
+ after CANCELTYPE_BIT, move the other bits up. Update CANCEL_RESTMASK.
+ * init.c (sigcancel_handler): Also set CANCELING_BITMASK bit in newval.
+ * pthread_cancel.c (pthread_cancel): Likewise. Also set CANCELING_BIT
+ if asynchronous canceling is enabled.
+ * pthread_join.c (pthread_join): When recognizing circular joins,
+ take into account the other thread might be already canceled.
+ * Makefile (tests): Add tst-join5.
+ * tst-join5.c: New file.
+
+ * Makefile (tests): Add tst-join4.
+ * tst-join4.c: New file.
+
+2003-02-13 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-cond4.c (main): Add test of pthread_attr_getpshared.
+
+2003-02-13 Martin Schwidefsky <schwidefsky@de.ibm.com>
+
+ * sysdeps/s390/tls.h (THREAD_GETMEM, THREAD_GETMEM_NC, THREAD_SETMEM,
+ THREAD_SETMEM_NC): Use passed descr instead of THREAD_SELF.
+ * sysdeps/unix/sysv/linux/s390/jmp-unwind.c (_longjmp_unwind): Avoid
+ warning.
+ * sysdeps/unix/sysv/linux/s390/lowlevellock.c: Include <sys/time.h>
+ to avoid warning.
+ * sysdeps/unix/sysv/linux/s390/sem_post.c (__new_sem_post): Return
+ error if lll_futex_wake failed.
+
+2003-02-13 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Fix
+ handling of cancellation and failung pthread_mutex_unlock call.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Likewise.
+ * Makefile (tests): Add tst-cond8 and tst-cond9.
+ * tst-cond8.c: New file.
+ * tst-cond9.c: New file.
+
+ * tst-cond7.c (do_test): Unlock the mutex before canceling the thread.
+
+ * sysdeps/pthread/pthread.h: Add missing initializers. Protect
+ non-standard initializers with __USE_GNU.
+
+ * Makefile (tests): Add tst-cleanup3.
+ * tst-cleanup3.c: New file.
+
+2003-02-12 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (tests): Add tst-attr1 and tst-attr2.
+ * tst-attr1.c: New file.
+ * tst-attr2.c: New file.
+
+ * Makefile: Add rules to build and run tst-atfork2 test.
+ * tst-atfork2.c: New file.
+ * tst-atfork2mod.c: New file.
+
+ * sysdeps/unix/sysv/linux/unregister-atfork.c
+ (__unregister_atfork): Free the memory allocated for the handlers
+ after removing them from the lists.
+
+ * sysdeps/unix/sysv/linux/register-atfork.c: Define memeory
+ cleanup function.
+
+ * tst-atfork1.c (do_test): Wait for the child we forked.
+ Report error in child.
+
+ * sysdeps/unix/sysv/linux/fork.c (__libc_fork): Fix comment.
+
+ * sysdeps/pthread/Makefile: Define CFLAGS-confstr.c.
+
+2003-02-10 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (tests): Add tst-cancel8.
+ * tst-cancel8.c: New file.
+
+ * sysdeps/unix/sysv/linux/i386/pthread_once.S (clear_once_control): Fix
+ clearing of control variable.
+ * Makefile (tests): Add tst-once3 and tst-once4.
+ * tst-once3.c: New file.
+ * tst-once4.c: New file.
+
+2003-02-08 kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * sysdeps/sh/Makefile: New file.
+ * sysdeps/sh/bits/atomic.h: New file.
+ * sysdeps/sh/pthread_spin_init.c: New file.
+ * sysdeps/sh/pthread_spin_lock.c: New file.
+ * sysdeps/sh/pthread_spin_trylock.S: New file.
+ * sysdeps/sh/pthread_spin_unlock.S: New file.
+ * sysdeps/sh/pthreaddef.h: New file.
+ * sysdeps/sh/tcb-offsets.sym: New file.
+ * sysdeps/sh/td_ta_map_lwp2thr.c: New file.
+ * sysdeps/sh/tls.h: New file.
+ * sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h: New file.
+ * sysdeps/unix/sysv/linux/sh/bits/semaphore.h: New file.
+ * sysdeps/unix/sysv/linux/sh/createthread.c: New file.
+ * sysdeps/unix/sysv/linux/sh/fork.c: New file.
+ * sysdeps/unix/sysv/linux/sh/libc-lowlevellock.S: New file.
+ * sysdeps/unix/sysv/linux/sh/libc-lowlevelmutex.S: New file.
+ * sysdeps/unix/sysv/linux/sh/lowlevel-atomic.h: New file.
+ * sysdeps/unix/sysv/linux/sh/lowlevelcond.h: New file.
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.S: New file.
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.h: New file.
+ * sysdeps/unix/sysv/linux/sh/lowlevelmutex.S: New file.
+ * sysdeps/unix/sysv/linux/sh/lowlevelrwlock.h: New file.
+ * sysdeps/unix/sysv/linux/sh/pt-initfini.c: New file.
+ * sysdeps/unix/sysv/linux/sh/pt-vfork.S: New file.
+ * sysdeps/unix/sysv/linux/sh/pthread_barrier_wait.S: New file.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_broadcast.S: New file.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_signal.S: New file.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S: New file.
+ * sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S: New file.
+ * sysdeps/unix/sysv/linux/sh/pthread_once.S: New file.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_rdlock.S: New file.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedrdlock.S: New file.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedwrlock.S: New file.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_unlock.S: New file.
+ * sysdeps/unix/sysv/linux/sh/pthread_rwlock_wrlock.S: New file.
+ * sysdeps/unix/sysv/linux/sh/sem_post.S: New file.
+ * sysdeps/unix/sysv/linux/sh/sem_timedwait.S: New file.
+ * sysdeps/unix/sysv/linux/sh/sem_trywait.S: New file.
+ * sysdeps/unix/sysv/linux/sh/sem_wait.S: New file.
+ * sysdeps/unix/sysv/linux/sh/sysdep-cancel.h: New file.
+
+2003-02-08 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-cond2.c: Rearrange code to not rely on behavior undefined
+ according to POSIX.
+
+ * tst-basic2.c (do_test): Lock mutex before creating the thread.
+
+2003-02-07 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/x86_64/tls.h: Remove unnecessary macros, left over from x86.
+ (TLS_GET_FS): New #define.
+ (TLS_SET_FS): New #define.
+ Correct value of __NR_set_thread_area.
+
+ * sysdeps/x86_64/td_ta_map_lwp2thr.c: New file.
+
+2003-02-06 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (tests): Add tst-popen1.
+ * tst-popen1.c: New file.
+
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Remove wrong
+ but inactive generalization.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S: Likewise.
+ Minor optimization, remove one instruction.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S: Likewise.
+
+2003-02-04 Martin Schwidefsky <schwidefsky@de.ibm.com>
+
+ * sysdeps/unix/sysv/linux/s390/fork.c: Correct order of parameters.
+
+2003-01-31 Martin Schwidefsky <schwidefsky@de.ibm.com>
+
+ * init.c (__NR_set_tid_address): Add #ifdef for s390.
+ * sysdeps/pthread/pthread_barrier_wait.c: New file.
+ * sysdeps/pthread/pthread_cond_broadcast.c: New file.
+ * sysdeps/pthread/pthread_cond_signal.c: New file.
+ * sysdeps/pthread/pthread_cond_timedwait.c: New file.
+ * sysdeps/pthread/pthread_cond_wait.c: New file.
+ * sysdeps/pthread/pthread_rwlock_rdlock.c: New file.
+ * sysdeps/pthread/pthread_rwlock_timedrdlock.c: New file.
+ * sysdeps/pthread/pthread_rwlock_timedwrlock.c: New file.
+ * sysdeps/pthread/pthread_rwlock_unlock.c: New file.
+ * sysdeps/pthread/pthread_rwlock_wrlock.c: New file.
+ * sysdeps/s390/Makefile: New file.
+ * sysdeps/s390/bits/atomic.h: New file.
+ * sysdeps/s390/pthread_spin_init.c: New file.
+ * sysdeps/s390/pthread_spin_lock.c: New file.
+ * sysdeps/s390/pthread_spin_trylock.c: New file.
+ * sysdeps/s390/pthread_spin_unlock.c: New file.
+ * sysdeps/s390/pthreaddef.h: New file.
+ * sysdeps/s390/tcb-offsets.sym: New file.
+ * sysdeps/s390/td_ta_map_lwp2thr.c: New file.
+ * sysdeps/s390/tls.h: New file.
+ * sysdeps/unix/sysv/linux/s390/bits/pthreadtypes.h: New file.
+ * sysdeps/unix/sysv/linux/s390/bits/semaphore.h: New file.
+ * sysdeps/unix/sysv/linux/s390/createthread.c: New file.
+ * sysdeps/unix/sysv/linux/s390/dl-sysdep.h: New file.
+ * sysdeps/unix/sysv/linux/s390/fork.c: New file.
+ * sysdeps/unix/sysv/linux/s390/jmp-unwind.c: New file.
+ * sysdeps/unix/sysv/linux/s390/libc-lowlevellock.c: New file.
+ * sysdeps/unix/sysv/linux/s390/libc-lowlevelmutex.c: New file.
+ * sysdeps/unix/sysv/linux/s390/lowlevellock.c: New file.
+ * sysdeps/unix/sysv/linux/s390/lowlevellock.h: New file.
+ * sysdeps/unix/sysv/linux/s390/lowlevelmutex.c: New file.
+ * sysdeps/unix/sysv/linux/s390/lowlevelsem.h: New file.
+ * sysdeps/unix/sysv/linux/s390/pthread_once.c: New file.
+ * sysdeps/unix/sysv/linux/s390/s390-32/pt-initfini.c: New file.
+ * sysdeps/unix/sysv/linux/s390/s390-32/pt-vfork.S: New file.
+ * sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h: New file.
+ * sysdeps/unix/sysv/linux/s390/s390-64/pt-initfini.c: New file.
+ * sysdeps/unix/sysv/linux/s390/s390-64/pt-vfork.S: New file.
+ * sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h: New file.
+ * sysdeps/unix/sysv/linux/s390/sem_post.c: New file.
+ * sysdeps/unix/sysv/linux/s390/sem_timedwait.c: New file.
+ * sysdeps/unix/sysv/linux/s390/libc-lowlevellock.c: New file.
+ * sysdeps/unix/sysv/linux/s390/sem_wait.c: New file.
+
+2003-02-04 Ulrich Drepper <drepper@redhat.com>
+
+ * atomic.h: Add a couple more default implementations.
+ (atomic_compare_and_exchange_acq): Use
+ __arch_compare_and_exchange_32_acq in return value definition. It
+ always exists.
+ (atomic_bit_set): Renamed from atomic_set_bit.
+ Add missing atomic_ prefixes.
+
+ * sysdeps/pthread/bits/libc-lock.h (__libc_once): In case no
+ thread library is available, use correct value to mark initialized
+ once variable.
+
+2003-02-03 Ulrich Drepper <drepper@redhat.com>
+
+ * allocatestack.c (allocate_stack): Use __getpagesize instead of
+ __sysconf to determine pagesize.
+
+ * pthread_create.c: Include <atomic.h>.
+ * allocatestack.c (allocate_stack): Implement coloring of the
+ allocated stack memory. Rename pagesize to pagesize_m1. It's the
+ size minus one. Adjust users.
+ * sysdeps/i386/i686/Makefile: New file.
+
+2003-02-02 Ulrich Drepper <drepper@redhat.com>
+
+ * allocatestack.c: Improve comment throughout the file.
+
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S
+ (__lll_lock_wait): Add branch prediction.
+ * sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S
+ (__lll_lock_wait): Likewise.
+ (lll_unlock_wake_cb): Removed.
+
+2003-01-31 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/bits/posix_opt.h: Remove
+ _POSIX_THREAD_PRIORITY_SCHEDULING.
+
+2003-01-30 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/pthread/pthread-functions.h (struct pthread_functions):
+ Fix return type of ptr___pthread_getspecific.
+
+2003-01-29 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (tests): Add tst-umask1.
+ (tst-umask1-ARGS): Define.
+ * tst-umask1.c: New file.
+
+2003-01-28 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (libpthread-routines): Remove lowlevelrwlock. Add
+ pthread_rwlock_rdlock, pthread_rwlock_timedrdlock,
+ pthread_rwlock_wrlock, pthread_rwlock_timedwrlock, and
+ pthread_rwlock_unlock.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevelrwlock.S: Removed
+ * sysdeps/unix/sysv/linux/i386/i586/lowlevelrwlock.S: Removed
+ * sysdeps/unix/sysv/linux/i386/i686/lowlevelrwlock.S: Removed
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S:
+ New file.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S:
+ New file.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_unlock.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i586/pthread_rwlock_rdlock.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i586/pthread_rwlock_timedrdlock.S:
+ New file.
+ * sysdeps/unix/sysv/linux/i386/i586/pthread_rwlock_wrlock.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i586/pthread_rwlock_timedwrlock.S:
+ New file.
+ * sysdeps/unix/sysv/linux/i386/i586/pthread_rwlock_unlock.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i686/pthread_rwlock_rdlock.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i686/pthread_rwlock_timedrdlock.S:
+ New file.
+ * sysdeps/unix/sysv/linux/i386/i686/pthread_rwlock_wrlock.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i686/pthread_rwlock_timedwrlock.S:
+ New file.
+ * sysdeps/unix/sysv/linux/i386/i686/pthread_rwlock_unlock.S: New file.
+
+ * Makefile (libpthread-routines): Remove lowlevelcond and
+ lowlevelsem. Add sem_wait, sem_trywait, sem_timedwait, sem_post,
+ pthread_cond_wait, pthread_cond_timedwait, pthread_cond_signal,
+ and pthread_cond_broadcast.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevelsem.S: Removed
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevelcond.S: Removed
+ * sysdeps/unix/sysv/linux/i386/i586/lowlevelsem.S: Removed
+ * sysdeps/unix/sysv/linux/i386/i586/lowlevelcond.S: Removed
+ * sysdeps/unix/sysv/linux/i386/i686/lowlevelsem.S: Removed
+ * sysdeps/unix/sysv/linux/i386/i686/lowlevelcond.S: Removed
+ * sysdeps/unix/sysv/linux/i386/i486/sem_wait.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_trywait.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_post.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i586/sem_wait.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i586/sem_trywait.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i586/sem_timedwait.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i586/sem_post.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i586/pthread_cond_wait.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i586/pthread_cond_timedwait.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i586/pthread_cond_signal.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i586/pthread_cond_broadcast.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i686/sem_wait.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i686/sem_trywait.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i686/sem_timedwait.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i686/sem_post.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i686/pthread_cond_wait.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i686/pthread_cond_timedwait.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i686/pthread_cond_signal.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i686/pthread_cond_broadcast.S: New file.
+ * sysdeps/unix/sysv/linux/i386/lowlevelcond.h: New file.
+
+ * sysdeps/unix/sysv/linux/i386/createthread.c: Define
+ PREPARE_CREATE and TLS_VALUE with x86-specific bits. All the rest
+ of the code is moved to ...
+ * sysdeps/pthread/createthread.c: ...here. New file.
+
+2003-01-27 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevelsem.S
+ (__new_sem_post): Clear %eax before returning.
+ Reported by MAEDA Naoaki <maeda.naoaki@jp.fujitsu.com>.
+
+ * Makefile (tests): Add tst-cleanup2.
+ * tst-cleanup2.c: New file.
+
+ * sysdeps/pthread/bits/libc-lock.h (__libc_cleanup_region_start):
+ Interpret first parameter correctly.
+
+2003-01-17 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (headers): Add bits/semaphore.h.
+
+2003-01-16 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/i386/tls.h (INIT_SYSINFO): Initialize _head->sysinfo even
+ if not SHARED.
+
+2003-01-14 Ulrich Drepper <drepper@redhat.com>
+
+ * sem_open.c (sem_open): Return SEM_FAILED if existing semaphore
+ must be used and mapping failed.
+ Reported by Luke Elliott <luke.elliott@activfinancial.com>.
+
+ * Makefile (CFLAGS-pthread_self.os): Define this, not
+ CFLAGS-pthread_self.c.
+
+2003-01-13 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S: Don't export
+ lll_unlock_wake_cb.
+
+ * Makefile (libpthread-routines): Add version. Add rules to build
+ version.os and banner.h.
+ * version.c: New file.
+
+2003-01-13 Jakub Jelinek <jakub@redhat.com>
+
+ * pthread_mutex_lock.c (__pthread_mutex_lock_internal): Make
+ the alias unconditional.
+ * pthread_mutex_unlock.c (__pthread_mutex_unlock_internal): Likewise.
+
+2003-01-13 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (CFLAGS-pthread_self.c): New definition.
+
+2003-01-06 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/pthread/pthread_sigmask.c (pthread_sigmask): Add
+ INTERNAL_SYSCALL_DECL, add err argument to INTERNAL_SYSCALL* macros.
+ * sysdeps/unix/sysv/linux/raise.c (raise): Likewise.
+ * init.c (__pthread_initialize_minimal_internal): Likewise.
+
+2003-01-07 Jakub Jelinek <jakub@redhat.com>
+
+ * pthreadP.h (__pthread_cond_timedwait): Add prototype.
+
+ * sysdeps/unix/sysv/linux/i386/dl-sysdep.h
+ (RTLD_CORRECT_DYNAMIC_WEAK): Remove.
+ (DL_SYSINFO_IMPLEMENTATION): Change into .text section and back.
+ * sysdeps/unix/sysv/linux/i386/i686/dl-sysdep.h
+ (RTLD_CORRECT_DYNAMIC_WEAK): Remove.
+ (DL_SYSINFO_IMPLEMENTATION): Change into .text section and back.
+
+2003-01-06 Jakub Jelinek <jakub@redhat.com>
+
+ * pthreadP.h (LIBC_CANCEL_HANDLED): Define.
+ * pt-system.c (LIBC_CANCEL_HANDLED): Add.
+ * tst-cancel-wrappers.sh: Remove all exceptions.
+
+2003-01-05 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-cancel-wrappers.sh: Invoke gawk not awk since we use GNU awk
+ features. Reported by Marijn Ros <marijn@mad.scientist.com>.
+
+ * sysdeps/unix/sysv/linux/jmp-unwind.c: Include <pthread-functions.h>.
+ Use __libc_pthread_functions array if SHARED.
+
+ * pthreadP.h: Move pthread_cond_2_0_t definition to...
+ * sysdeps/unix/sysv/linux/internaltypes.h: ...here.
+
+ * sysdeps/pthread/bits/libc-lock.h (__libc_ptf_call): New #define.
+ (__libc_rwlock_rdlock, __libc_rwlock_wrlock, __libc_rwlock_unlock,
+ __libc_key_create, __libc_getspecific, __libc_setspecific): Use
+ __libc_ptf_call instead of __libc_maybe_call.
+ (PTF): New #define.
+ (__libc_cleanup_region_start): Wrap function name with PTF call.
+ (__libc_cleanup_region_end): Likewise.
+ (__libc_cleanup_end): Likewise.
+
+ * pthread_getspecific.c: Add __pthread_getspecific_internal alias.
+ * pthread_setspecific.c: Add __pthread_setspecific_internal alias.
+ * pthread_key_create.c: Add __pthread_key_create_internal alias.
+ * pthreadP.h: Add prototypes.
+
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevelrwlock.S: Add
+ __pthread_rwlock_rdlock, __pthread_rwlock_wrlock, and
+ __pthread_rwlock_unlock aliases.
+ * pthreadP.h: Add prototypes for new aliases.
+
+ * pthreadP.h (struct pthead_functions): Moved to...
+ * sysdeps/pthread/pthread-functions.h: ...here. New file.
+ * init.c (pthread_functions): Add initializers for new elements.
+
+ * cleanup_defer.c: Add __pthread_cleanup_push_defer and
+ __pthread_cleanup_pop_restore aliases.
+ * pthreadP.h: Add prototypes.
+
+ * cleanup.c: Rename _GI_pthread_cleanup_push to __pthread_cleanup_push
+ and _GI_pthread_cleanup_pop to __pthread_cleanup_pop.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevelcond.S: Adjust caller.
+ * sysdeps/unix/sysv/linux/i386/pthread_once.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/pthread_once.S: Likewise.
+ * pthreadP.h: Adjust prototypes and callers.
+
+2003-01-04 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (tests): Add tst-cancel7.
+ (tst-cancel7-ARGS): New variable.
+ * tst-cancel7.c: New file.
+
+ * old_pthread_cond_broadcast.c: Optimize initialization a bit to work
+ around gcc defficiencies.
+ * old_pthread_cond_signal.c: Likewise.
+ * old_pthread_cond_timedwait.c: Likewise.
+ * old_pthread_cond_wait.c: Likewise.
+
+ * pthreadP.h (pthread_cond_2_0_t): Remove unneeded lock element.
+
+2003-01-03 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (tests): Add tst-cond7.
+ * tst-cond7.c: New file.
+
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevelcond.S
+ (condvar_cleanup): Get condvar address from the right place.
+
+ * atomic.h: Correct definitions of atomic_full_barrier,
+ atomic_read_barrier, atomic_write_barrier.
+
+ * old_pthread_cond_broadcast.c: Make memory allocate and initialization
+ race-free.
+ * old_pthread_cond_signal.c: Likewise.
+ * old_pthread_cond_timedwait.c: Likewise.
+ * old_pthread_cond_wait.c: Likewise.
+
+2003-01-03 Jakub Jelinek <jakub@redhat.com>
+
+ * Makefile ($(objpfx)libpthread.so): Depend on ld.so.
+
+2003-01-03 Ulrich Drepper <drepper@redhat.com>
+
+ * pthreadP.h (pthread_cond_2_0_t): New type.
+ (struct pthread_functions): Use new type for 2.0 condvar callbacks.
+ Use new type for the 2.0 condvar function prototypes.
+ * forward.c: Use pthread_cond_2_0_t for 2.0 condvar functions.
+ * old_pthread_cond_init.c: Use pthread_cond_2_0_t for condvar
+ parameter.
+ * old_pthread_cond_destroy.c: Likewise.
+ * old_pthread_cond_broadcast.c: Likewise. Lock appropriately.
+ * old_pthread_cond_signal.c: Likewise.
+ * old_pthread_cond_timedwait.c: Likewise.
+ * old_pthread_cond_wait.c: Likewise.
+
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevelcond.S
+ (__pthread_cond_wait): Don't save cancellation mode and seq value
+ in same location.
+
+ * herrno.c (__h_errno_location): Don't define as weak.
+
+2003-01-02 Jakub Jelinek <jakub@redhat.com>
+
+ * Versions [libc] (GLIBC_2.3.2): Export pthread_cond_broadcast,
+ pthread_cond_destroy, pthread_cond_init, pthread_cond_signal
+ and pthread_cond_wait.
+ * old_pthread_cond_broadcast.c (__old_pthread_cond_broadcast):
+ Renamed to...
+ (__pthread_cond_broadcast_2_0): ... this.
+ * old_pthread_cond_destroy.c (__old_pthread_cond_destroy):
+ Renamed to...
+ (__pthread_cond_destroy_2_0): ... this.
+ * old_pthread_cond_init.c (__old_pthread_cond_init):
+ Renamed to...
+ (__pthread_cond_init_2_0): ... this.
+ * old_pthread_cond_signal.c (__old_pthread_cond_signal):
+ Renamed to...
+ (__pthread_cond_signal_2_0): ... this.
+ * old_pthread_cond_wait.c (__old_pthread_cond_wait):
+ Renamed to...
+ (__pthread_cond_wait_2_0): ... this.
+ * pthread_cond_destroy.c: Include shlib-compat.h.
+ (pthread_cond_destroy): Change strong_alias into versioned_symbol.
+ * pthread_cond_init.c: Include shlib-compat.h.
+ (pthread_cond_init): Change strong_alias into versioned_symbol.
+ * pthreadP.h (struct pthread_functions): Rename ptr_pthread_cond_*
+ fields to ptr___pthread_cond_* and add ptr___pthread_cond_*_2_0
+ fields.
+ (__pthread_cond_broadcast_2_0, __pthread_cond_destroy_2_0,
+ __pthread_cond_init_2_0, __pthread_cond_signal_2_0,
+ __pthread_cond_wait_2_0): New prototypes.
+ (__old_pthread_cond_broadcast, __old_pthread_cond_destroy,
+ __old_pthread_cond_init, __old_pthread_cond_signal,
+ __old_pthread_cond_wait): Removed.
+ * init.c: Include shlib-compat.h.
+ (pthread_functions): Guard ptr___pthread_attr_init_2_0
+ initialization with SHLIB_COMPAT (GLIBC_2_0, GLIBC_2_1).
+ Rename ptr_pthread_cond_* to ptr___pthread_cond_*, initialize
+ ptr___pthread_cond_*_2_0 fields.
+ * forward.c: Export both pthread_cond_*@@GLIBC_2.3.2 and
+ pthread_cond_*@GLIBC_2.0 compatibility symbols.
+
+ * sysdeps/pthread/sigaction.c (SIGCANCEL): Only define if
+ LIBC_SIGACTION was not yet defined.
+ [!defined LIBC_SIGACTION]: Define LIBC_SIGACTION, #include self.
+ [!defined LIBC_SIGACTION] (__sigaction): New function and
+ libc_hidden_weak.
+ [!defined LIBC_SIGACTION] (sigaction): New weak_alias.
+ [defined LIBC_SIGACTION]: #include_next <sigaction.c>.
+
+2003-01-02 Jakub Jelinek <jakub@redhat.com>
+
+ * Makefile (CFLAGS-pthread_atfork.c): Add -DNOT_IN_libc.
+
+2003-01-02 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h (pthread_cond_t):
+ New, larger type definition.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevelcond.S: New condvar
+ implementation.
+ * Versions [libpthread]: Add definitions for new pthread_cond_*
+ interfaces for version GLIBC_2.3.2.
+ * pthread_cond_init.c: Update initialization for new type definition.
+ * Makefile (libpthread-routines): Remove pthread_cond_wait,
+ pthread_cond_timedwait, pthread_cond_signal, and
+ pthread_cond_broadcast. Add old_pthread_cond_init,
+ old_pthread_cond_destroy, old_pthread_cond_wait,
+ old_pthread_cond_timedwait, old_pthread_cond_signal, and
+ old_pthread_cond_broadcast.
+ * old_pthread_cond_broadcast.c: New file.
+ * old_pthread_cond_destroy.c: New file.
+ * old_pthread_cond_init.c: New file.
+ * old_pthread_cond_signal.c: New file.
+ * old_pthread_cond_timedwait.c: New file.
+ * old_pthread_cond_wait.c: New file.
+ * pthreadP.h: Add prototypes for the compatibility interfaces.
+
+ * pthread_cond_destroy.c: Don't include <errno.h>.
+
+2003-01-01 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevelrwlock.S: Avoid
+ unnecessary zero offset when addressing MUTEX.
+
+2002-12-31 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/fork.h: Add libc_hidden_proto for
+ __register_atfork.
+ * sysdeps/unix/sysv/linux/register-atfork.c: Add libc_hidden_def
+ for __register_atfork.
+
+2002-12-31 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/sysdep-cancel.h: Use __ASSEMBLER__
+ instead of ASSEMBLER test macro.
+
+ * sysdeps/unix/sysv/linux/allocrtsig.c (__libc_current_sigrtmin,
+ __libc_current_sigrtmax): Add libc_hidden_def.
+
+ * sysdeps/pthread/list.h: Remove assert.h include.
+
+2002-12-31 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/pt-initfini.c (call_initialize_minimal): Use
+ __pthread_initialize_minimal_internal not
+ __pthread_initialize_minimal.
+
+2002-12-30 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/pt-initfini.c (call_initialize_minimal): Mark
+ __pthread_initialize_minimal as hidden.
+
+ * init.c (__pthread_initialize_minimal_internal): Don't mark as
+ constructor.
+
+2002-12-31 Jakub Jelinek <jakub@redhat.com>
+
+ * Makefile ($(inst_libdir)/libpthread.so): Depend on
+ $(common-objpfx)format.lds, include that into the output script.
+ Fix comment.
+ (extra-B-pthread.so): Change linuxthreads/ into nptl/.
+
+2002-12-28 Andreas Jaeger <aj@suse.de>
+
+ * sysdeps/unix/sysv/linux/xstatconv.c (xstat_conv): Adjust for
+ nsec resolution changes.
+ (xstat64_conv): Likewise.
+ (xstat32_conv): Likewise.
+ * sysdeps/unix/sysv/linux/kernel_stat.h: Add nsec resolution for
+ struct kernel_stat.
+ * sysdeps/unix/sysv/linux/bits/stat.h: Add nsec resolution for
+ structs stat and stat64.
+ * time/time.h (__timespec_defined): Define for __USE_MISC.
+ * io/sys/stat.h [__USE_MISC]: Define __need_timespec for struct stat.
+
+2002-12-30 Jakub Jelinek <jakub@redhat.com>
+
+ * forward.c (FORWARD2): Renamed from FORWARD3. Remove unused export
+ argument.
+ (pthread_attr_init_2_0, pthread_attr_init_2_1): Use FORWARD macro.
+ (pthread_exit): Use strong_alias to avoid warnings.
+ * pthreadP.h (struct pthread_functions): Rename ptr_pthread_exit
+ and ptr_pthread_attr_init_2_* to ptr___pthread_exit and
+ ptr___pthread_attr_init_2_*.
+ * init.c (pthread_functions): Adjust.
+
+2002-12-29 Ulrich Drepper <drepper@redhat.com>
+
+ * forward.c: Make all functions available by default again. It
+ caused too much trouble.
+
+ * pt-siglongjmp.c: Removed.
+
+2002-12-28 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/i386/tls.h: Include tcb-offsets.h in assembler.
+ (SYSINFO_OFFSET, MULTIPLE_THREADS_OFFSET): Remove.
+ * sysdeps/i386/Makefile: New file.
+ * sysdeps/i386/tcb-offsets.sym: New file.
+ * sysdeps/pthread/tcb-offsets.h: New file.
+ * sysdeps/unix/sysv/linux/libc_pthread_init.c (__libc_pthread_init):
+ Remove MULTIPLE_THREADS_OFFSET and SYSINFO_OFFSET checks.
+
+ * sysdeps/unix/sysv/linux/Versions [libc] (GLIBC_PRIVATE): Move
+ __register_atfork...
+ (GLIBC_2.3.2): ...here.
+
+2002-12-28 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/pthread.h: Mark pthread_attr_getstackaddr and
+ pthread_attr_setstackaddr with __attribute_deprecated__.
+
+2002-12-27 Jakub Jelinek <jakub@redhat.com>
+
+ * pt-system.c (system): Remove cancellation handling.
+ * tst-cancel-wrappers.sh: Allow pt-system.o* to not use the
+ cancellation routines.
+
+2002-12-28 Ulrich Drepper <drepper@redhat.com>
+
+ * descr.h: Include <dl-sysdep.h>.
+ (struct pthread): Move header.data.list to the back of the struct.
+ * sysdeps/i386/tls.h (tcbhead_t): Move list to the back of the struct.
+ (MULTIPLE_THREADS_OFFSET): Adjust offset.
+ (SYSINFO_OFFSEET): Likewise.
+
+2002-12-27 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i686/dl-sysdep.h (USE_DL_SYSINFO):
+ Define.
+ (DL_SYSINFO_DEFAULT): Cast to uintptr_t to avoid warnings.
+ * sysdeps/unix/sysv/linux/i386/dl-sysdep.h (NEED_DL_SYSINFO,
+ DL_SYSINFO_DEFAULT, DL_SYSINFO_IMPLEMENTATION): Define.
+ (USE_DL_SYSINFO): Undef.
+
+2002-12-22 Jakub Jelinek <jakub@redhat.com>
+
+ * Makefile (tests-reverse): Use $(objpfx)../libc.so instead of
+ $(common-objpfx)libc.so.
+ * tst-cancel4.c (tf_write, tf_writev): Increase buf sizes so that
+ it is bigger than pipe buffer size even on arches with bigger
+ page size.
+ (tf_usleep): Cast usleep argument to useconds_t to avoid warnings.
+
+2002-12-25 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevelsem.S: Implement
+ correct errno access for case that USE___THREAD is not defined.
+
+2002-12-24 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/dl-sysdep.h: Add missing #endif.
+ Patch by Marijn Ros <marijn@mad.scientist.com>.
+
+2002-12-22 Roland McGrath <roland@redhat.com>
+
+ * Makefile (omit-deps): Add $(unix-syscalls:%=ptw-%).
+
+2002-12-20 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/bits/stdio-lock.h (_IO_lock_inexpensive): Define.
+
+2002-12-19 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/dl-sysdep.h: Don't define
+ NEED_DL_SYSINFO since no processor < i686 had the sysenter opcode.
+ * sysdeps/unix/sysv/linux/i386/i686/dl-sysdep.h: New file.
+
+ * sysdeps/unix/sysv/linux/i386/pthread_once.S: Use ENTER_KERNEL instead
+ of int $0x80.
+ * sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/libc-lowlevelmutex.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevelcond.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevelmutex.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevelrwlock.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevelsem.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_barrier_wait.S: Likewise.
+
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h: Add support for using
+ sysenter.
+ * sysdeps/unix/sysv/linux/i386/lowlevelsem.h: Likewise.
+
+ * sysdeps/i386/tls.h: Unconditionally include <dl-sysdep.h>.
+
+ * allocatestack.c (allocate_stack) [NEED_DL_SYSINFO]: Set sysinfo
+ in new TCB.
+ * sysdeps/unix/sysv/linux/i386/createthread.c (create_thread): Check
+ that sysinfo is properly initialized.
+ * sysdeps/unix/sysv/linux/i386/dl-sysdep.h: Define RTLD_PRIVATE_ERRNO
+ to 1 only for ld.so.
+
+ * sysdeps/unix/sysv/linux/i386/dl-sysdep.h: Define
+ RTLD_CORRECT_DYNAMIC_WEAK.
+
+2002-12-19 Jakub Jelinek <jakub@redhat.com>
+
+ * forward.c (pthread_attr_init_2_0, pthread_attr_init_2_1):
+ Use return 0 as 6th argument to FORWARD4.
+ * pthread_equal.c: Include pthreadP.h instead of pthread.h.
+
+2002-12-18 Ulrich Drepper <drepper@redhat.com>
+
+ * descr.h (struct pthread) [NEED_DL_SYSINFO]: Add sysinfo member.
+ * sysdeps/i386/tls.h (tcbhead_t): Add sysinfo member.
+ Define SYSINFO_OFFSEET if NEED_DL_SYSINFO is defined.
+ (INIT_SYSINFO): New #define.
+ (TLS_TP_INIT): Use INIT_SYSINFO.
+ * sysdeps/unix/sysv/linux/libc_pthread_init.c (__libc_pthread_init):
+ At test to make sure SYSINFO_OFFSET value is correct.
+ * sysdeps/unix/sysv/linux/i386/dl-sysdep.h: New file.
+
+2002-12-18 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/pthread/flockfile.c (flockfile): Change into weak alias.
+ * sysdeps/unix/sysv/linux/raise.c (gsignal): Add weak alias to raise.
+ * Versions [libc: GLIBC_2.0]: Add pthread_attr_init.
+ [libpthread: GLIBC_2.1]: Remove __pthread_rwlock_init,
+ __pthread_rwlock_destroy, __pthread_rwlock_rdlock,
+ __pthread_rwlock_wrlock, __pthread_rwlock_unlock,
+ __pthread_rwlock_tryrdlock and __pthread_rwlock_trywrlock.
+
+2002-12-18 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/sysdep-cancel.h: Use ENTER_KERNEL
+ macro instead of using int $0x80 directly.
+
+ * sysdeps/pthread/bits/stdio-lock.h: New file.
+ * sysdeps/unix/sysv/linux/i386/i486/libc-lowlevelmutex.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i586/libc-lowlevelmutex.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i686/libc-lowlevelmutex.S: New file.
+ * Makefile (routines): Add libc-lowlevelmutex.
+
+ * sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S: Remove
+ __i686.get_pc_thunk.dx.
+
+2002-12-17 Jakub Jelinek <jakub@redhat.com>
+
+ * Makefile (libpthread-shared-only-routines): Add pt-allocrtsig.
+ (tests): Depend on $(objpfx)tst-cancel-wrappers.out.
+ ($(objpfx)tst-cancel-wrappers.out): New rule.
+ * tst-cancel-wrappers.sh: New test.
+ * tst-locale1.c: Include signal.h.
+ (uselocale): Test static linking of __libc_current_sigrt*.
+
+2002-12-17 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (tests): Add tst-cancel6.
+ * tst-cancel6.c: New file
+
+2002-12-17 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/sysdep-cancel.h (SINGLE_THREAD_P):
+ Define meaningfully for assembler as well.
+ * pthreadP.h (struct pthread_functions): Remove
+ ptr_pthread_attr_init field. Add ptr_pthread_attr_init_2_0
+ and ptr_pthread_attr_init_2_1 fields.
+ * init.c (pthread_functions): Initialize ptr_pthread_attr_init_2_0
+ and ptr_pthread_attr_init_2_1 instead of ptr_pthread_attr_init.
+ * forward.c (FORWARD4): Renamed from FORWARD3. Add export argument.
+ (FORWARD3): Define using FORWARD4.
+ (pthread_attr_init): Provide both @GLIBC_2.0 and @@GLIBC_2.1
+ versions.
+ * pt-system.c: Remove duplicate stdlib.h include.
+
+2002-12-16 Ulrich Drepper <drepper@redhat.com>
+
+ * sem_init.c: Define sem_init@GLIBC_2.0.
+ * sem_destroy.c: Define sem_destroy@GLIBC_2.0.
+ * sem_getvalue.c: Define sem_getvalue@GLIBC_2.0.
+
+ * flockfile.c: Moved to...
+ * sysdeps/pthread/flockfile.c: ...here. New file.
+ * funlockfile.c: Moved to...
+ * sysdeps/pthread/funlockfile.c: ...here. New file.
+ * ftrylockfile.c: Moved to...
+ * sysdeps/pthread/ftrylockfile.c: ...here. New file.
+
+2002-12-16 Jakub Jelinek <jakub@redhat.com>
+
+ * libc-cancellation.c: Guard both function with
+ #if !defined NOT_IN_libc.
+ * Makefile (libpthread-routines): Use ptw-, not pt- prefix for the
+ automatically provided pthread wrappers.
+ * pthreadP.h (LIBC_CANCEL_ASYNC, LIBC_CANCEL_RESET): Define to
+ CANCEL_* if IS_IN_libpthread and to dummy versions if not in libc
+ nor in libpthread.
+ * pt-open.c: Removed.
+ * pt-fcntl.c: Removed.
+ * pt-fsync.c: Removed.
+ * pt-lseek.c: Removed.
+ * pt-msgrcv.c: Removed.
+ * pt-msgsnd.c: Removed.
+ * pt-msync.c: Removed.
+ * pt-nanosleep.c: Removed.
+ * pt-open64.c: Removed.
+ * pt-pause.c: Removed.
+ * pt-pread.c: Removed.
+ * pt-pread64.c: Removed.
+ * pt-pwrite.c: Removed.
+ * pt-pwrite64.c: Removed.
+ * pt-read.c: Removed.
+ * pt-recv.c: Removed.
+ * pt-recvfrom.c: Removed.
+ * pt-recvmsg.c: Removed.
+ * pt-send.c: Removed.
+ * pt-sendto.c: Removed.
+ * pt-sigtimedwait.c: Removed.
+ * pt-sigwait.c: Removed.
+ * pt-wait.c: Removed.
+ * pt-waitpid.c: Removed.
+ * pt-write.c: Removed.
+ * pt-accept.c: Removed.
+ * pt-close.c: Removed.
+ * pt-connect.c: Removed.
+ * pt-lseek64.c: Removed.
+ * pt-sendmsg.c: Removed.
+ * pt-tcdrain.c: Removed.
+
+2002-12-15 Ulrich Drepper <drepper@redhat.com>
+
+ * init.c (__pthread_initialize_minimal_internal): Renamed from
+ __pthread_initialize_minimal. Make old name an alias. This
+ converts a normal relocation into a relative relocation.
+
+ * pt-fcntl.c (__fcntl): Use fcntl64 syscall, not fcntl.
+
+ * Versions [libpthread: GLIBC_2.3.2]: Remove creat, poll, pselect,
+ readv, select, sigpause, sigsuspend, sigwaitinfo, waitid, writev.
+ * Makefile (libpthread-routines): Remove pt-creat, pt-poll,
+ pt-pselect, pt-readv, pt-select, pt-sigpause, pt-sigsuspend,
+ pt-sigwaitinfo, pt-waitid, and pt-writev.
+ * pt-creat.c: Removed.
+ * pt-poll.c: Removed.
+ * pt-pselect.c: Removed.
+ * pt-readv.c: Removed.
+ * pt-select.c: Removed.
+ * pt-sigpause.c: Removed.
+ * pt-sigsuspend.c: Removed.
+ * pt-sigwaitinfo.c: Removed.
+ * pt-waitid.c: Removed.
+ * pt-writev.c: Removed.
+
+ * init.c (pthread_functions): New variable.
+ (__pthread_initialize_minimal): Pass pointer to pthread_functions
+ (or NULL) to __libc_pthread_init.
+ * forward.c: Rewrite to use __libc:pthread_functions array to get
+ function addresses.
+ * sysdeps/unix/sysv/linux/fork.h: Remove __libc_pthread_init
+ prototype.
+ * sysdeps/unix/sysv/linux/libc_pthread_init.c (__libc_pthread_init):
+ Take new parameter. Copy content of variable pointed to by it
+ to __libc_pthread_init.
+
+ * pthreadP.h (struct pthread_functions): New type.
+ (__libc_pthread_init): Declare.
+
+ * pthread_attr_destroy.c: Add namespace protected alias.
+ * pthread_attr_getdetachstate.c: Likewise.
+ * pthread_attr_getinheritsched.c: Likewise.
+ * pthread_attr_getschedparam.c: Likewise.
+ * pthread_attr_getschedpolicy.c: Likewise.
+ * pthread_attr_getscope.c: Likewise.
+ * pthread_attr_setdetachstate.c: Likewise.
+ * pthread_attr_setinheritsched.c: Likewise.
+ * pthread_attr_setschedparam.c: Likewise.
+ * pthread_attr_setschedpolicy.c: Likewise.
+ * pthread_attr_setscope.c: Likewise.
+ * pthread_cond_broadcast.c: Likewise.
+ * pthread_cond_destroy.c: Likewise.
+ * pthread_cond_init.c: Likewise.
+ * pthread_cond_signal.c: Likewise.
+ * pthread_cond_wait.c: Likewise.
+ * pthread_condattr_destroy.c: Likewise.
+ * pthread_condattr_init.c: Likewise.
+ * pthread_equal.c: Likewise.
+ * pthread_exit.c: Likewise.
+ * pthread_getschedparam.c: Likewise.
+ * pthread_self.c: Likewise.
+ * pthread_setcancelstate.c: Likewise.
+ * pthread_setschedparam.c: Likewise.
+ * pthread_mutex_destroy.c: Likewise.
+ * pthread_mutex_init.c: Likewise.
+ * pthreadP.h: Add prototypes for the aliases.
+
+ * sysdeps/unix/sysv/linux/i386/createthread.c (create_thread): Set
+ multiple_threads member in correct TCB to 1.
+
+ * sysdeps/unix/sysv/linux/i386/sysdep-cancel.h: Define
+ SINGLE_THREAD_P. If in libc or libpthread examine multiple_thread
+ member of thread descriptor, otherwise return unconditionally 1.
+
+2002-12-14 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/pt-socket.S: Changes folded into the
+ regular Linux version. Remove file.
+ * sysdeps/unix/sysv/linux/connect.S: Likewise. Remove file.
+ * sysdeps/unix/sysv/linux/llseek.c: Likewise. Remove file.
+ * sysdeps/unix/sysv/linux/msgrcv.c: Likewise. Remove file.
+ * sysdeps/unix/sysv/linux/msgsnd.c: Likewise. Remove file.
+ * sysdeps/unix/sysv/linux/open64.c: Likewise. Remove file.
+ * sysdeps/unix/sysv/linux/poll.c: Likewise. Remove file.
+ * sysdeps/unix/sysv/linux/pread.c: Likewise. Remove file.
+ * sysdeps/unix/sysv/linux/pread64.c: Likewise. Remove file.
+ * sysdeps/unix/sysv/linux/pselect.c: Likewise. Remove file.
+ * sysdeps/unix/sysv/linux/pwrite.c: Likewise. Remove file.
+ * sysdeps/unix/sysv/linux/pwrite64.c: Likewise. Remove file.
+ * sysdeps/unix/sysv/linux/readv.c: Likewise. Remove file.
+ * sysdeps/unix/sysv/linux/recv.S: Likewise. Remove file.
+ * sysdeps/unix/sysv/linux/recvfrom.S: Likewise. Remove file.
+ * sysdeps/unix/sysv/linux/recvmsg.S: Likewise. Remove file.
+ * sysdeps/unix/sysv/linux/send.S: Likewise. Remove file.
+ * sysdeps/unix/sysv/linux/sendmsg.S: Likewise. Remove file.
+ * sysdeps/unix/sysv/linux/sendto.S: Likewise. Remove file.
+ * sysdeps/unix/sysv/linux/sigpause.c: Likewise. Remove file.
+ * sysdeps/unix/sysv/linux/sigsuspend.c: Likewise. Remove file.
+ * sysdeps/unix/sysv/linux/sigtimedwait.c: Likewise. Remove file.
+ * sysdeps/unix/sysv/linux/sigwait.c: Likewise. Remove file.
+ * sysdeps/unix/sysv/linux/sigwaitinfo.c: Likewise. Remove file.
+ * sysdeps/unix/sysv/linux/system.c: Likewise. Remove file.
+ * sysdeps/unix/sysv/linux/tcdrain.c: Likewise. Remove file.
+ * sysdeps/unix/sysv/linux/wait.c: Likewise. Remove file.
+ * sysdeps/unix/sysv/linux/waitid.c: Likewise. Remove file.
+ * sysdeps/unix/sysv/linux/waitpid.c: Likewise. Remove file.
+ * sysdeps/unix/sysv/linux/writev.c: Likewise. Remove file.
+ * sysdeps/unix/sysv/linux/i386/fcntl.c: Likewise. Remove file.
+
+2002-12-14 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/sysdep-cancel.h: New file.
+ * sysdeps/unix/sysv/linux/open.c: Removed.
+ * sysdeps/unix/sysv/linux/fsync.c: Removed.
+ * sysdeps/unix/sysv/linux/lseek.c: Removed.
+ * sysdeps/unix/sysv/linux/msync.c: Removed.
+ * sysdeps/unix/sysv/linux/read.c: Removed.
+ * sysdeps/unix/sysv/linux/close.c: Removed.
+ * sysdeps/unix/sysv/linux/creat.c: Removed.
+ * sysdeps/unix/sysv/linux/nanosleep.c: Removed.
+ * sysdeps/unix/sysv/linux/pause.c: Removed.
+ * sysdeps/unix/sysv/linux/select.c: Removed.
+ * sysdeps/unix/sysv/linux/write.c: Removed.
+
+2002-12-14 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/pt-socket.S: Check multiple_threads
+ element in TCB to see whether locking is needed.
+
+ * sysdeps/unix/sysv/linux/libc_pthread_init.c: Check that
+ MULTIPLE_THREADS_OFFSET value is correct.
+
+ * sysdeps/unix/sysv/linux/close.c: New file.
+ * sysdeps/unix/sysv/linux/connect.S: New file.
+ * sysdeps/unix/sysv/linux/creat.c: New file.
+ * sysdeps/unix/sysv/linux/fsync.c: New file.
+ * sysdeps/unix/sysv/linux/llseek.c: New file.
+ * sysdeps/unix/sysv/linux/lseek.c: New file.
+ * sysdeps/unix/sysv/linux/msgrcv.c: New file.
+ * sysdeps/unix/sysv/linux/msgsnd.c: New file.
+ * sysdeps/unix/sysv/linux/msync.c: New file.
+ * sysdeps/unix/sysv/linux/nanosleep.c: New file.
+ * sysdeps/unix/sysv/linux/open.c: New file.
+ * sysdeps/unix/sysv/linux/open64.c: New file.
+ * sysdeps/unix/sysv/linux/pause.c: New file.
+ * sysdeps/unix/sysv/linux/poll.c: New file.
+ * sysdeps/unix/sysv/linux/pread.c: New file.
+ * sysdeps/unix/sysv/linux/pread64.c: New file.
+ * sysdeps/unix/sysv/linux/pselect.c: New file.
+ * sysdeps/unix/sysv/linux/pwrite.c: New file.
+ * sysdeps/unix/sysv/linux/pwrite64.c: New file.
+ * sysdeps/unix/sysv/linux/readv.c: New file.
+ * sysdeps/unix/sysv/linux/recv.S: New file.
+ * sysdeps/unix/sysv/linux/recvfrom.S: New file.
+ * sysdeps/unix/sysv/linux/recvmsg.S: New file.
+ * sysdeps/unix/sysv/linux/select.c: New file.
+ * sysdeps/unix/sysv/linux/send.S: New file.
+ * sysdeps/unix/sysv/linux/sendmsg.S: New file.
+ * sysdeps/unix/sysv/linux/sendto.S: New file.
+ * sysdeps/unix/sysv/linux/sigpause.c: New file.
+ * sysdeps/unix/sysv/linux/sigsuspend.c: New file.
+ * sysdeps/unix/sysv/linux/sigtimedwait.c: New file.
+ * sysdeps/unix/sysv/linux/sigwait.c: New file.
+ * sysdeps/unix/sysv/linux/sigwaitinfo.c: New file.
+ * sysdeps/unix/sysv/linux/system.c: New file.
+ * sysdeps/unix/sysv/linux/tcdrain.c: New file.
+ * sysdeps/unix/sysv/linux/wait.c: New file.
+ * sysdeps/unix/sysv/linux/waitid.c: New file.
+ * sysdeps/unix/sysv/linux/waitpid.c: New file.
+ * sysdeps/unix/sysv/linux/writev.c: New file.
+ * sysdeps/unix/sysv/linux/i386/fcntl.c: New file.
+
+ * pt-readv.c: Fix comment.
+
+2002-12-14 Jakub Jelinek <jakub@redhat.com>
+
+ * tst-cleanup1.c: Include stdlib.h.
+
+ * tst-cancel5.c: New test.
+ * Makefile (tests): Add tst-cancel5.
+ (tst-cancel5): Link against libc.so libpthread.so in that order.
+
+2002-12-13 Ulrich Drepper <drepper@redhat.com>
+
+ * forward.c (test_loaded): Prevent recursive calls.
+
+ * Makefile (routines): Add libc-cancellation.
+ * libc-cancellation.c: New file.
+ * descr.h (struct pthread): Add multiple_threads field.
+ * allocatestack.c (allocate_stack): Initialize multiple_header field of
+ new thread descriptor to 1.
+ * sysdeps/unix/sysv/linux/i386/createthread.c (create_thread):
+ Initialize multiple_thread field after successful thread creation.
+ * cancellation.c (__do_cancel): Move to pthreadP.h.
+ (__pthread_enable_asynccancel): Remove parameter from __do_cancel call.
+ (__pthread_disable_asynccancel): Add internal_function attribute.
+ * init.c (sigcancel_handler): Remove parameter from __do_cancel call.
+ * pthread_setcancelstate.c: Likewise.
+ * pthread_setcanceltype.c: Likewise.
+ * pthread_exit.c: Likewise.
+ * pthreadP.h (CANCELLATION_P): Likewise.
+ (__do_cancel): Define as static inline.
+ (LIBC_CANCEL_ASYNC, LIBC_CANCEL_RESET): New #defines.
+ (__libc_enable_asynccancel, __libc_disable_asynccancel): New
+ declarations.
+ * sysdeps/i386/tls.h (tcbhead_t): Add list and multiple_threads
+ fields. Define MULTIPLE_THREADS_OFFSET.
+ * sysdeps/pthread/bits/libc-lock.h: Remove __libc_locking_needed
+ declaration.
+ * sysdeps/unix/sysv/linux/accept.S: New file.
+ * sysdeps/unix/sysv/linux/read.c: New file.
+ * sysdeps/unix/sysv/linux/write.c: New file.
+ * sysdeps/unix/sysv/linux/i386/pt-socket.S: New file.
+ * sysdeps/unix/sysv/linux/libc_pthread_init.c: Remove definition and
+ initialization of __libc_locking_needed.
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h: Don't use
+ __libc_locking_needed, use multiple_threads field in TCB.
+ * sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S: Likewise.
+
+2002-12-12 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i686/libc-lowlevellock.S: Use i486
+ version.
+ * sysdeps/unix/sysv/linux/i386/i586/libc-lowlevellock.S: Likewise.
+
+ * sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S: Correct
+ access to __libc_locking_needed for PIC.
+
+2002-12-12 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/pthread/bits/libc-lock.h (__libc_locking_needed): Only
+ declare for libc.so.
+ (__libc_lock_init, __libc_lock_init_recursive): Change into comma
+ expression.
+ (__libc_lock_lock): Put into statement expression.
+ (__libc_lock_unlock): Remove trailing semicolon.
+ * sysdeps/unix/sysv/linux/fork.h (__libc_pthread_init): Fix typo.
+
+2002-12-12 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h: Use asm operand with
+ "m" constraint to refer to __libc_locking_needed. Declare it here.
+
+2002-12-12 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/fork-gen.c: Renamed to...
+ * sysdeps/unix/sysv/linux/libc_pthread_init.c: ...this.
+ Initialize __libc_locking_needed.
+ * init.c (__pthread_initialize_minimal): Call __libc_pthread_init
+ instead of __register_pthread_fork_handler.
+ * sysdeps/pthread/bits/libc-lock.h: Declare __libc_locking_needed.
+ * sysdeps/unix/sysv/linux/Makefile (sysdep_routimes): Replace
+ fork-gen with libc_pthread_init.
+ * sysdeps/unix/sysv/linux/Versions: Use __libc_pthread_init instead
+ of __register_pthread_fork_handler.
+ * sysdeps/unix/sysv/linux/fork.h: Declare __libc_pthread_init instead
+ of __register_pthread_fork_handler.
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h: Use
+ __libc_locking_needed to determine whether lock prefix can be avoided.
+ * sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S: Likewise.
+
+2002-12-11 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (tests): Add tst-cleanup1.
+ * tst-cleanup1.c: New file.
+ * cancellation.c (__cleanup_thread): Removed.
+ (__do_cancel): Remove call to __cleanup_thread.
+ * pthreadP.h: Remove __cleanup_thread prorotype.
+
+ * sysdeps/pthread/bits/libc-lock.h (__libc_cleanup_region_start):
+ Remember function and argument even if cancellation handler
+ function is not available.
+ (__libc_cleanup_region_end): Execute registered function directly if
+ pthread functions are not available.
+ (__libc_cleanup_end): Likewise.
+
+ * init.c (__pthread_initialize_minimal): Fix initialization in
+ static lib by preventing gcc from being too clever.
+
+2002-12-10 Ulrich Drepper <drepper@redhat.com>
+
+ * init.c (__pthread_initialize_minimal): Remove unneccesary
+ sigaddset call.
+
+ * Makefile (tests): We can run tst-locale2 now.
+
+2002-12-09 Ulrich Drepper <drepper@redhat.com>
+
+ * Versions: Remove duplicated sigwait entry.
+
+2002-12-08 Ulrich Drepper <drepper@redhat.com>
+
+ * pthreadP.h: Enable pthread_cleanup_{push,pop} optimizations only
+ inside libpthread.
+
+ * pt-fcntl.c (__fcntl): Initialize oldtype to avoid warning.
+
+ * pthreadP.h: Declare __pthread_enable_asynccancel and
+ __pthread_disable_asynccancel.
+ (CANCEL_ASYNC): Use __pthread_enable_asynccancel.
+ (CANCEL_RESET): Use __pthread_disable_asynccancel.
+ * cancellation.c (__pthread_enable_asynccancel): New function.
+ (__pthread_disable_asynccancel): New function.
+ * pt-accept.c: Adjust for CANCEL_ASYNC and CANCEL_RESET change.
+ * pt-close.c: Likewise.
+ * pt-connect.c: Likewise.
+ * pt-creat.c: Likewise.
+ * pt-fcntl.c: Likewise.
+ * pt-fsync.c: Likewise.
+ * pt-lseek.c: Likewise.
+ * pt-lseek64.c: Likewise.
+ * pt-msgrcv.c: Likewise.
+ * pt-msgsnd.c: Likewise.
+ * pt-msync.c: Likewise.
+ * pt-nanosleep.c: Likewise.
+ * pt-open.c: Likewise.
+ * pt-open64.c: Likewise.
+ * pt-pause.c: Likewise.
+ * pt-poll.c: Likewise.
+ * pt-pread.c: Likewise.
+ * pt-pread64.c: Likewise.
+ * pt-pselect.c: Likewise.
+ * pt-pwrite.c: Likewise.
+ * pt-pwrite64.c: Likewise.
+ * pt-read.c: Likewise.
+ * pt-readv.c: Likewise.
+ * pt-recv.c: Likewise.
+ * pt-recvfrom.c: Likewise.
+ * pt-recvmsg.c: Likewise.
+ * pt-select.c: Likewise.
+ * pt-send.c: Likewise.
+ * pt-sendmsg.c: Likewise.
+ * pt-sendto.c: Likewise.
+ * pt-sigpause.c: Likewise.
+ * pt-sigsuspend.c: Likewise.
+ * pt-sigtimedwait.c: Likewise.
+ * pt-sigwait.c: Likewise.
+ * pt-sigwaitinfo.c: Likewise.
+ * pt-system.c: Likewise.
+ * pt-tcdrain.c: Likewise.
+ * pt-wait.c: Likewise.
+ * pt-waitid.c: Likewise.
+ * pt-waitpid.c: Likewise.
+ * pt-write.c: Likewise.
+ * pt-writev.c: Likewise.
+ * pthread_join.c: Likewise.
+ * pthread_timedjoin.c: Likewise.
+
+ * pt-sigpause.c (sigsuspend): Call __sigsuspend.
+ (__xpg_sigpause): New function.
+ * Versions (libpthread:GLIBC_2.3.2): Add __xpg_sigpause.
+
+2002-12-07 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (CFLAGS-ftrylockfile.c): Add -D_IO_MTSAFE_IO.
+
+ * cleanup.c: Move declarations of _GI_pthread_cleanup_push and
+ _GI_pthread_cleanup_pop to pthreadP.h.
+
+ * ftrylockfile.c: Use _IO_lock_trylock instead of
+ pthread_mutex_trylock.
+
+ * pthreadP.h (CANCEL_ASYNC): Use __pthread_setcanceltype.
+ (CANCEL_RESET): Likewise.
+ (__pthread_setcanceltype_): Declare.
+ (__pthread_mutex_lock_internal): Declare.
+ (__pthread_mutex_unlock_internal): Declare.
+ (__pthread_once_internal): Declare.
+ (pthread_cleanup_push): Redefine using _GI_pthread_cleanup_push.
+ (pthread_cleanup_pop): Redefine using _GI_pthread_cleanup_pop.
+
+ * pthread_cond_timedwait.c: Use INTUSE is calls to pthread_mutex_lock
+ and pthread_mutex_unlock.
+ * pthread_cond_wait.c: Likewise.
+ * pthread_mutex_lock.c: Use INTDEF to define alias if needed.
+ * pthread_mutex_unlock.c: Likewise.
+
+ * pthread_setcanceltype.c: Add additional alias
+ __pthread_setcanceltype.
+
+ * sem_unlink.c (sem_unlink): Use __pthread_once with INTDEF.
+ * sem_open.c (sem_open): Likewise.
+ Use __libc_open, __libc_write, and __libc_close instead of
+ open, write, and close respectively.
+
+ * sysdeps/pthread/bits/libc-lock.h (__libc_lock_trylock_internal):
+ Rewrite as statement expression since it must return a value.
+
+ * pthread_cancel.c: Use __pthread_kill instead of pthread_kill.
+ * sysdeps/unix/sysv/linux/pthread_kill.c: Define additional alias
+ __pthread_kill.
+
+ * sysdeps/unix/sysv/linux/i386/pthread_once.S: Define additional
+ alias __pthread_once_internal.
+
+ * sysdeps/unix/sysv/linux/raise.c: Use libc_hidden_def for raise.
+
+2002-12-06 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (tests): Add tst-stdio1 and tst-stdio2.
+ * tst-stdio1.c: New file.
+ * tst-stdio2.c: New file.
+
+ * init.c (__pthread_initialize_minimal): Correct INIT_LIST_HEAD use.
+
+ * Makefile (tests): Comment out tst-locale2 for now.
+ (CFLAGS-flockfile.c, CFLAGS-funlockfile.c): Define to -D_IO_MTSAFE_IO.
+
+ * sysdeps/unix/sysv/linux/Makefile: Define CFLAGS-fork.c to
+ -D_IO_MTSAFE_IO.
+ * sysdeps/unix/sysv/linux/fork.c: Include <bits/stdio-lock.h>.
+ Use _IO_lock_init instead of explicit assignment.
+
+ * sysdeps/pthread/bits/libc-lock.h: Define __rtld_lock_* macros.
+ Define __libc_lock_* and __libc_lock_recursive macros with
+ lowlevellock macros, not pthread mutexes.
+
+ * flockfile.c: Include <bits/stdio-lock.h>. Use _IO_lock_lock instead
+ of pthread_mutex_lock.
+ * funlockfile.c: Include <bits/stdio-lock.h>. Use _IO_lock_unlock
+ instead of pthread_mutex_unlock.
+
+2002-12-06 Roland McGrath <roland@redhat.com>
+
+ * allocatestack.c (__stack_user): Use uninitialized defn.
+ * init.c (__pthread_initialize_minimal): Initialize it here.
+
+2002-12-05 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/i386/tls.h (TLS_INIT_TP): Make it return zero or an error
+ string.
+ * sysdeps/x86_64/tls.h (TLS_INIT_TP): Likewise.
+
+ * sysdeps/unix/sysv/linux/i386/createthread.c (create_thread): Add
+ missing & here too.
+
+2002-12-05 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/Makefile (sysdep_routines): Remove
+ lowlevellock.
+ * sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i586/libc-lowlevellock.S: New file.
+ * sysdeps/unix/sysv/linux/i386/i686/libc-lowlevellock.S: New file.
+ * sysdeps/pthread/bits/libc-lock.h: Use lowlevellock implementation
+ for __libc_lock_* macros.
+ * Makefile (routines): Add libc-lowlevellock.
+
+2002-10-09 Roland McGrath <roland@redhat.com>
+
+ * sysdeps/pthread/bits/libc-lock.h (__libc_maybe_call): New macro.
+ Under [__PIC__], call the function via the pointer fetched for
+ comparison rather than a call by name that uses the PLT.
+ (__libc_lock_init, __libc_rwlock_init, __libc_lock_fini)
+ (__libc_rwlock_fini, __libc_lock_lock, __libc_rwlock_rdlock)
+ (__libc_rwlock_wrlock, __libc_lock_trylock, __libc_rwlock_tryrdlock)
+ (__libc_rwlock_trywrlock, __libc_lock_unlock, __libc_rwlock_unlock)
+ (__libc_key_create, __libc_getspecific, __libc_setspecific): Use it.
+
+2002-12-04 Roland McGrath <roland@redhat.com>
+
+ * forward.c (pthread_self): Use FORWARD3 macro to correct return type.
+
+ * sysdeps/i386/td_ta_map_lwp2thr.c: Moved from ../nptl_db.
+ * sysdeps/generic/td_ta_map_lwp2thr.c: New file.
+
+ * pthread_create.c (start_thread): Add missing & on __nptl_last_event.
+
+2002-12-04 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h: Make pthread_t
+ a completely opaque, non-integer type.
+ * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h: Likewise.
+
+2002-12-05 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/i386/tls.h: Include stdlib.h.
+ * sysdeps/x86_64/tls.h: Likewise.
+
+2002-12-04 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (tests): Add tst-locale2.
+ (tests-static): Likewise.
+ * tst-locale2.c: New file.
+
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h: Mark asms as
+ volatile and add memory clobbers to lock operations.
+
+2002-12-03 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/i386/i686/bits/atomic.h: Use i486 version.
+ * sysdeps/i386/i486/bits/atomic.h: New file.
+ * sysdeps/i386/i586/bits/atomic.h: New file.
+ * sysdeps/i386/i686/pthread_spin_trylock.S: Define HAVE_CMOV and
+ include i486 version.
+ * sysdeps/i386/i486/pthread_spin_trylock.S: New file.
+ * sysdeps/i386/i586/pthread_spin_trylock.S: New file.
+ Patch by Marijn Ros <marijn@mad.scientist.com>.
+
+ * allocatestack.c (get_cached_stack): Don't crash if we first
+ found a stack with a larger size then needed.
+ Reported by Hui Huang <hui.huang@sun.com>.
+
+ * Makefile (tests): Add tst-sysconf.
+ * tst-sysconf.c: New file.
+
+ * sysdeps/unix/sysv/linux/bits/local_lim.h: Undefine
+ PTHREAD_THREADS_MAX.
+
+2002-12-02 Roland McGrath <roland@redhat.com>
+
+ * pthreadP.h (__stack_user, __nptl_create_event, __nptl_death_event):
+ Declare using hidden_proto instead of attribute_hidden, so there are
+ non-.hidden static symbols for gdb to find.
+ (__pthread_keys): Likewise.
+ * events.c (__nptl_create_event, __nptl_death_event): Add hidden_def.
+ * allocatestack.c (__stack_user): Likewise.
+ * pthread_create.c (__pthread_keys): Likewise.
+ (__nptl_threads_events, __nptl_last_event): Make these static instead
+ of hidden.
+ * pthread_key_create.c (__pthread_pthread_keys_max,
+ __pthread_pthread_key_2ndlevel_size): Renamed from __linuxthreads_*.
+
+2002-12-02 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (tests): Add tst-locale1. If buid-static is yes link
+ statically.
+ * tst-locale1.c: New file.
+
+ * pthread_cond_timedwait.c: Include <stdlib.h>.
+
+ * Makefile (tests): Add tst-fork2 and tst-fork3.
+ * tst-fork2.c: New file.
+ * tst-fork3.c: New file.
+
+2002-11-28 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/bits/posix_opt.h: New file.
+
+ * sysdeps/unix/sysv/linux/bits/posix_opt.h: Define macros which
+ require it to 200112L.
+
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevelrwlock.S: Use cmov
+ instruction only if HAVE_CMOV is defined.
+ * sysdeps/unix/sysv/linux/i386/i686/lowlevelrwlock.S: Define HAVE_CMOV.
+
+ * sysdeps/unix/sysv/linux/x86_64/bits/semaphore.h: New file.
+
+ * sysdeps/unix/sysv/linux/x86_64/pthread_once.S: New file.
+
+ * sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h: New file.
+
+ * sysdeps/unix/sysv/linux/x86_64/pt-vfork.S: New file.
+
+2002-11-27 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/x86_64/bits/atomic.h: New file.
+
+ * sysdeps/i386/i686/bits/atomic.h: Fix asm syntax for 8- and
+ 16-bit operations.
+
+ * sysdeps/unix/sysv/linux/raise.c (raise): Use INTERNAL_SYSCALL if
+ possible since gettid cannot fail.
+
+ * sysdeps/x86_64/pthreaddef.h: New file.
+
+ * sysdeps/i386/pthreaddef.h (gettid): Removed.
+
+ * sysdeps/x86_64/pthread_spin_init.c: New file.
+ * sysdeps/x86_64/pthread_spin_lock.c: New file.
+ * sysdeps/x86_64/pthread_spin_trylock.c: New file.
+ * sysdeps/x86_64/pthread_spin_unlock.c: New file.
+
+ * sysdeps/i386/i686/pthread_spin_trylock.S (pthread_spin_trylock):
+ Add missing lock prefix. Minute optimization.
+
+ * tst-spin2.c (main): Also check successful trylock call.
+
+ * sysdeps/pthread/pthread_sigmask.c (pthread_sigmask): Use correct
+ syscall. Fix typo in case INTERNAL_SYSCALL is not used.
+
+ * sysdeps/i386/pthread_spin_destroy.c: Moved to...
+ * sysdeps/pthread/pthread_spin_destroy.c: ...here. New file.
+
+ * sysdeps/i386/pthread_sigmask.c: Removed. Use the generic code.
+ * sysdeps/pthread/pthread_sigmask.c (pthread_sigmask): Return correct
+ value in case of an error. Add support for INTERNAL_SYSCALL.
+
+ * sysdeps/i386/pthread_sigmask.c (pthread_sigmask): Return correct
+ value in case of an error.
+
+ * sysdeps/x86_64/tls.h: New file.
+
+2002-11-26 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/i386/tls.h (THREAD_GETMEM_NC): Change interface. It now
+ takes the array member name and the index as parameters.
+ (THREAD_SETMEM_NC): Likewise.
+ * pthread_getspecific.c: Use new THREAD_GETMEM_NC interface.
+ * pthread_setspecific.c: Use new THREAD_GETMEM_NC and THREAD_SETMEM_NC
+ interfaces.
+
+ * sysdeps/i386/tls.h (THREAD_SETMEM): Use size of member element
+ to decide which code to use.
+ (THREAD_SETMEM_NC): Likewise.
+
+ * allocatestack.c (queue_stack): Don't remove stack from list here.
+ Do it in the caller. Correct condition to prematurely terminate
+ loop to free stacks.
+ (__deallocate_stack): Remove stack from list here.
+
+2002-11-26 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (tests): Add tst-stack1.
+ * tst-stack1.c: New file.
+
+ * allocatestack.c (allocate_stack): Initialize the TCB on a user
+ provided stack.
+
+ * pthread_attr_getstack.c: Return bottom of the thread area.
+
+2002-11-25 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (libpthread-routines): Add pt-allocrtsig and
+ pthread_kill_other_threads.
+ * pt-allocrtsig.c: New file.
+ * pthread_kill_other_threads.c: New file.
+ * sysdeps/unix/sysv/linux/allocrtsig.c: Add additional aliases for
+ all three functions.
+ * sysdeps/unix/sysv/linux/Makefile (sysdep_routines): Remove
+ allocrtsig.
+ * sysdeps/unix/sysv/linux/Versions (libc:GLIBC_PRIVATE): Export
+ __libc_current_sigrtmin_private, __libc_current_sigrtmax_private,
+ and __libc_allocate_rtsig_private.
+ * Versions (libpthread): Export pthread_kill_other_threads_np,
+ __libc_current_sigrtmin, and __libc_current_sigrtmax.
+
+2002-11-24 Ulrich Drepper <drepper@redhat.com>
+
+ * allocatestack.c (allocate_stack): stackaddr in attribute points to
+ the end of the stack. Adjust computations.
+ When mprotect call fails dequeue stack and free it.
+ * pthread_attr_setstack.c: Store top of the stack in stackaddr
+ attribute.
+ * pthread_getattr_np.c: Likewise.
+
+ * descr.h (IS_DETACHED): Add some more parenthesis to prevent
+ surprises.
+
+2002-11-23 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/pthread/pthread.h (pthread_self): __THROW must come before
+ attribute definitions. Patch by Luca Barbieri <ldb@ldb.ods.org>.
+
+2002-11-22 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_getspecific.c: Optimize access to first 2nd-level array.
+ * pthread_setspecific.c: Likewise.
+
+2002-11-21 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/createthread.c: Remove CLONE_ flags
+ definitions. Get them from the official place.
+ * sysdeps/unix/sysv/linux/i386/fork.c: Likewise.
+
+ * sysdeps/unix/sysv/linux/i386/createthread.c: Update CLONE_* flags.
+ Use new CLONE_ flags in clone() calls.
+
+ * sysdeps/unix/sysv/linux/fork.c: Use ARCH_FORK to actually fork.
+ * sysdeps/unix/sysv/linux/i386/fork.c: New file.
+
+ * Versions: Add pthread_* functions for libc.
+ * forward.c: New file.
+
+ * sysdeps/pthread/Makefile (libpthread-sysdeps_routines): Add
+ errno-loc.
+ * herrno.c: New file.
+ * res.c: New file.
+
+ * Makefile (libpthread-routines): Remove sem_post, sem_wait,
+ sem_trywait, and sem_timedwait. Add herrno and res.
+ * sem_init.c: Don't initialize lock and waiters members.
+ * sem_open.c: Likewise.
+ * sem_post.c: Removed.
+ * sem_wait.c: Removed.
+ * sem_trywait.c: Removed.
+ * sem_timedwait.c: Removed.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevelsem.S: Complete rewrite.
+ Includes full implementations of sem_post, sem_wait, sem_trywait,
+ and sem_timedwait.
+ * sysdeps/unix/sysv/linux/i386/lowlevelsem.h (lll_sem_post): Adjust
+ for new implementation.
+ * sysdeps/unix/sysv/linux/internaltypes.h (struct sem): Remove lock
+ and waiters fields.
+
+ * tst-sem3.c: Improve error message.
+ * tst-signal3.c: Likewise.
+
+ * init.c (__pthread_initialize_minimal): Use set_tid_address syscall
+ to tell the kernel about the termination futex and to initialize tid
+ member. Don't initialize main_thread.
+ * descr.h (struct pthread): Remove main_thread member.
+ * cancelllation.c (__do_cancel): Remove code handling main thread.
+ The main thread is not special anymore.
+
+ * allocatestack.c (__reclaim_stacks): Mark stacks as unused. Add
+ size of the stacks to stack_cache_actsize.
+
+ * pt-readv.c: Add missing "defined".
+ * pt-sigwait.c: Likewise.
+ * pt-writev.c: Likewise.
+
+2002-11-09 Ulrich Drepper <drepper@redhat.com>
+
+ * Versions: Export __connect from libpthread.
+ Patch by Luca Barbieri <ldb@ldb.ods.org>.
+
+ * Makefile (libpthread-routines): Add pt-raise.
+ * sysdeps/unix/sysv/linux/raise.c: New file.
+ * sysdeps/unix/sysv/linux/pt-raise.c: New file.
+ * sysdeps/generic/pt-raise.c: New file.
+
+ * pthread_cond_init.c: Initialize all data elements of the condvar
+ structure. Patch by Luca Barbieri <ldb@ldb.ods.org>.
+
+ * pthread_attr_init.c: Actually implement 2.0 compatibility version.
+ * pthread_create.c: Likewise.
+
+ * Makefile (tests): Add tst-key1, tst-key2, tst-key3.
+ * tst-key1.c: New file.
+ * tst-key2.c: New file.
+ * tst-key3.c: New file.
+
+ * Versions: Export pthread_detach for version GLIBC_2.0.
+ Reported by Saurabh Desai <sdesai@austin.ibm.com>.
+
+2002-11-08 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_key_create.c: Terminate search after an unused key was found.
+ Patch by Luca Barbieri <ldb@ldb.ods.org>.
+
+ * sysdeps/unix/sysv/linux/i386/pthread_once.S: Return zero.
+ Patch by Luca Barbieri <ldb@ldb.ods.org>.
+
+2002-10-10 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevelsem.S: Use slow generic
+ dynamic lookup for errno in PIC.
+
+ * allocatestack.c (get_cached_stack): Rearrange code slightly to
+ release the stack lock as soon as possible.
+ Call _dl_allocate_tls_init for TCB from the cache to re-initialize
+ the static TLS block.
+ (allocate_stack): Call _dl_allocate_tls_init for user-provided stack.
+
+ * cancellation.c: Renamed from cancellation.c.
+ * Makefile: Adjust accordingly.
+ * pthreadP.h (CANCELLATION_P): Renamed from CANCELATION_P.
+ * cleanup_defer.c: Use CANCELLATION_P.
+ * pthread_testcancel.c: Likewise.
+ * descr.h: Fix spelling in comments.
+ * init.c: Likewise.
+ * pthread_getattr_np.c: Likewise.
+ * pthread_getschedparam.c: Likewise.
+ * pthread_setschedparam.c: Likewise.
+ * Versions: Likewise.
+
+ * pt-pselect.c: New file.
+ * Makefile (libpthread-routines): Add pt-pselect.
+ * Versions: Add pselect.
+
+ * tst-cancel4.c: New file.
+ * Makefile (tests): Add tst-cancel4.
+
+2002-10-09 Ulrich Drepper <drepper@redhat.com>
+
+ * pthread_mutex_lock.c: Always record lock ownership.
+ * pthread_mutex_timedlock.c: Likewise.
+ * pthread_mutex_trylock.c: Likewise.
+
+ * pt-readv.c: New file.
+ * pt-writev.c: New file.
+ * pt-creat.c: New file.
+ * pt-msgrcv.c: New file.
+ * pt-msgsnd.c: New file.
+ * pt-poll.c: New file.
+ * pt-select.c: New file.
+ * pt-sigpause.c: New file.
+ * pt-sigsuspend.c: New file.
+ * pt-sigwait.c: New file.
+ * pt-sigwaitinfo.c: New file.
+ * pt-waitid.c: New file.
+ * Makefile (libpthread-routines): Add pt-readv, pt-writev, pt-creat,
+ pt-msgrcv, pt-msgsnd, pt-poll, pt-select, pt-sigpause, pt-sigsuspend,
+ pt-sigwait, pt-sigwaitinfo, and pt-waitid.
+ * Versions: Add all the new functions.
+
+ * tst-exit1.c: New file.
+ * Makefile (tests): Add tst-exit1.
+
+ * sem_timedwait.c: Minor optimization for more optimal fastpath.
+
+2002-10-08 Ulrich Drepper <drepper@redhat.com>
+
+ * pt-fcntl.c: Only enable asynchronous cancellation for F_SETLKW.
+
+ * pthread_join.c: Enable asynchronous cancellation around lll_wait_tid
+ call. pthread_join is an official cancellation point.
+ * pthread_timedjoin.c: Likewise.
+
+ * pthread_cond_wait.c: Revert order in which internal lock are dropped
+ and the condvar's mutex are retrieved.
+ * pthread_cond_timedwait.c: Likewise.
+ Reported by dice@saros.East.Sun.COM.
+
+2002-10-07 Ulrich Drepper <drepper@redhat.com>
+
+ * pthreadP.h: Cut out all type definitions and move them...
+ * sysdeps/unix/sysv/linux/internaltypes.h: ...here. New file.
+ * pthreadP.h: Include <internaltypes.h>.
+
+ * sysdeps/unix/sysv/linux/i386/lowlevelsem.h (lll_sem_post): Little
+ performance tweaks.
+
+ * sem_trywait.c: Shuffle #includes around to get right order.
+ * sem_timedwait.c: Likewise.
+ * sem_post.c: Likewise.
+ * sem_wait.c: Likewise.
+
+ * nptl 0.3 released.
+
+ * Makefile (tests): Add tst-signal3.
+ * tst-signal3.c: New file.
+
+2002-10-05 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/sysv/linux/i386/lowlevelsem.h: Tell the compiler that
+ the asms modify the sem object.
+ (__lll_sem_timedwait): Now takes struct sem* as first parameter.
+
+ * sysdeps/unix/sysv/linux/i386/bits/semaphore.h (sem_t): Don't expose
+ the actual members.
+ * pthreadP.h (struct sem): New type. Actual semaphore type.
+ * semaphoreP.h: Include pthreadP.h.
+ * sem_getvalue.c: Adjust to sem_t change.
+ * sem_init.c: Likewise.
+ * sem_open.c: Likewise.
+ * sem_post.c: Likewise.
+ * sem_timedwait.c: Likewise.
+ * sem_trywait.c: Likewise.
+ * sem_wait.c: Likewise.
+
+2002-10-04 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (tests): Add tst-basic2, tst-exec1, tst-exec3, tst-exec3.
+ * tst-basic2.c: New file.
+ * tst-exec1.c: New file.
+ * tst-exec2.c: New file.
+ * tst-exec3.c: New file.
+
+ * tst-fork1.c: Remove extra */.
+
+ * nptl 0.2 released. The API for IA-32 is complete.
diff --git a/libpthread/nptl/DESIGN-barrier.txt b/libpthread/nptl/DESIGN-barrier.txt
new file mode 100644
index 000000000..23463c6b7
--- /dev/null
+++ b/libpthread/nptl/DESIGN-barrier.txt
@@ -0,0 +1,44 @@
+Barriers pseudocode
+===================
+
+ int pthread_barrier_wait(barrier_t *barrier);
+
+struct barrier_t {
+
+ unsigned int lock:
+ - internal mutex
+
+ unsigned int left;
+ - current barrier count, # of threads still needed.
+
+ unsigned int init_count;
+ - number of threads needed for the barrier to continue.
+
+ unsigned int curr_event;
+ - generation count
+}
+
+pthread_barrier_wait(barrier_t *barrier)
+{
+ unsigned int event;
+ result = 0;
+
+ lll_lock(barrier->lock);
+ if (!--barrier->left) {
+ barrier->curr_event++;
+ futex_wake(&barrier->curr_event, INT_MAX)
+
+ result = BARRIER_SERIAL_THREAD;
+ } else {
+ event = barrier->curr_event;
+ lll_unlock(barrier->lock);
+ do {
+ futex_wait(&barrier->curr_event, event)
+ } while (event == barrier->curr_event);
+ }
+
+ if (atomic_increment_val (barrier->left) == barrier->init_count)
+ lll_unlock(barrier->lock);
+
+ return result;
+}
diff --git a/libpthread/nptl/DESIGN-condvar.txt b/libpthread/nptl/DESIGN-condvar.txt
new file mode 100644
index 000000000..4845251c7
--- /dev/null
+++ b/libpthread/nptl/DESIGN-condvar.txt
@@ -0,0 +1,134 @@
+Conditional Variable pseudocode.
+================================
+
+ int pthread_cond_timedwait (pthread_cond_t *cv, pthread_mutex_t *mutex);
+ int pthread_cond_signal (pthread_cond_t *cv);
+ int pthread_cond_broadcast (pthread_cond_t *cv);
+
+struct pthread_cond_t {
+
+ unsigned int cond_lock;
+
+ internal mutex
+
+ uint64_t total_seq;
+
+ Total number of threads using the conditional variable.
+
+ uint64_t wakeup_seq;
+
+ sequence number for next wakeup.
+
+ uint64_t woken_seq;
+
+ sequence number of last woken thread.
+
+ uint32_t broadcast_seq;
+
+}
+
+
+struct cv_data {
+
+ pthread_cond_t *cv;
+
+ uint32_t bc_seq
+
+}
+
+
+
+cleanup_handler(cv_data)
+{
+ cv = cv_data->cv;
+ lll_lock(cv->lock);
+
+ if (cv_data->bc_seq == cv->broadcast_seq) {
+ ++cv->wakeup_seq;
+ ++cv->woken_seq;
+ }
+
+ /* make sure no signal gets lost. */
+ FUTEX_WAKE(cv->wakeup_seq, ALL);
+
+ lll_unlock(cv->lock);
+}
+
+
+cond_timedwait(cv, mutex, timeout):
+{
+ lll_lock(cv->lock);
+ mutex_unlock(mutex);
+
+ cleanup_push
+
+ ++cv->total_seq;
+ val = seq = cv->wakeup_seq;
+ cv_data.bc = cv->broadcast_seq;
+ cv_data.cv = cv;
+
+ while (1) {
+
+ lll_unlock(cv->lock);
+
+ enable_async(&cv_data);
+
+ ret = FUTEX_WAIT(cv->wakeup_seq, val, timeout);
+
+ restore_async
+
+ lll_lock(cv->lock);
+
+ if (bc != cv->broadcast_seq)
+ goto bc_out;
+
+ val = cv->wakeup_seq;
+
+ if (val != seq && cv->woken_seq != val) {
+ ret = 0;
+ break;
+ }
+
+ if (ret == TIMEDOUT) {
+ ++cv->wakeup_seq;
+ break;
+ }
+ }
+
+ ++cv->woken_seq;
+
+ bc_out:
+ lll_unlock(cv->lock);
+
+ cleanup_pop
+
+ mutex_lock(mutex);
+
+ return ret;
+}
+
+cond_signal(cv)
+{
+ lll_lock(cv->lock);
+
+ if (cv->total_seq > cv->wakeup_seq) {
+ ++cv->wakeup_seq;
+ FUTEX_WAKE(cv->wakeup_seq, 1);
+ }
+
+ lll_unlock(cv->lock);
+}
+
+cond_broadcast(cv)
+{
+ lll_lock(cv->lock);
+
+ if (cv->total_seq > cv->wakeup_seq) {
+ cv->wakeup_seq = cv->total_seq;
+ cv->woken_seq = cv->total_seq;
+ ++cv->broadcast_seq;
+ FUTEX_WAKE(cv->wakeup_seq, ALL);
+ }
+
+ lll_unlock(cv->lock);
+}
diff --git a/libpthread/nptl/DESIGN-rwlock.txt b/libpthread/nptl/DESIGN-rwlock.txt
new file mode 100644
index 000000000..810d1b8f3
--- /dev/null
+++ b/libpthread/nptl/DESIGN-rwlock.txt
@@ -0,0 +1,113 @@
+Reader Writer Locks pseudocode
+==============================
+
+ pthread_rwlock_rdlock(pthread_rwlock_t *rwlock);
+ pthread_rwlock_unlock(pthread_rwlock_t *rwlock);
+ pthread_rwlock_wrlock(pthread_rwlock_t *rwlock);
+
+struct pthread_rwlock_t {
+
+ unsigned int lock:
+ - internal mutex
+
+ unsigned int writers_preferred;
+ - locking mode: 0 recursive, readers preferred
+ 1 nonrecursive, writers preferred
+
+ unsigned int readers;
+ - number of read-only references various threads have
+
+ pthread_t writer;
+ - descriptor of the writer or 0
+
+ unsigned int readers_wakeup;
+ - 'all readers should wake up' futex.
+
+ unsigned int writer_wakeup;
+ - 'one writer should wake up' futex.
+
+ unsigned int nr_readers_queued;
+ - number of readers queued up.
+
+ unsigned int nr_writers_queued;
+ - number of writers queued up.
+}
+
+pthread_rwlock_rdlock(pthread_rwlock_t *rwlock)
+{
+ lll_lock(rwlock->lock);
+ for (;;) {
+ if (!rwlock->writer && (!rwlock->nr_writers_queued ||
+ !rwlock->writers_preferred))
+ break;
+
+ rwlock->nr_readers_queued++;
+ val = rwlock->readers_wakeup;
+ lll_unlock(rwlock->lock);
+
+ futex_wait(&rwlock->readers_wakeup, val)
+
+ lll_lock(rwlock->lock);
+ rwlock->nr_readers_queued--;
+ }
+ rwlock->readers++;
+ lll_unlock(rwlock->lock);
+}
+
+pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock)
+{
+ int result = EBUSY;
+ lll_lock(rwlock->lock);
+ if (!rwlock->writer && (!rwlock->nr_writers_queued ||
+ !rwlock->writers_preferred))
+ rwlock->readers++;
+ lll_unlock(rwlock->lock);
+ return result;
+}
+
+pthread_rwlock_wrlock(pthread_rwlock_t *rwlock)
+{
+ lll_lock(rwlock->lock);
+ for (;;) {
+ if (!rwlock->writer && !rwlock->readers)
+ break;
+
+ rwlock->nr_writers_queued++;
+ val = rwlock->writer_wakeup;
+ lll_unlock(rwlock->lock);
+
+ futex_wait(&rwlock->writer_wakeup, val);
+
+ lll_lock(rwlock->lock);
+ rwlock->nr_writers_queued--;
+ }
+ rwlock->writer = pthread_self();
+ lll_unlock(rwlock->lock);
+}
+
+pthread_rwlock_unlock(pthread_rwlock_t *rwlock)
+{
+ lll_lock(rwlock->lock);
+
+ if (rwlock->writer)
+ rwlock->writer = 0;
+ else
+ rwlock->readers--;
+
+ if (!rwlock->readers) {
+ if (rwlock->nr_writers_queued) {
+ ++rwlock->writer_wakeup;
+ lll_unlock(rwlock->lock);
+ futex_wake(&rwlock->writer_wakeup, 1);
+ return;
+ } else
+ if (rwlock->nr_readers_queued) {
+ ++rwlock->readers_wakeup;
+ lll_unlock(rwlock->lock);
+ futex_wake(&rwlock->readers_wakeup, MAX_INT);
+ return;
+ }
+ }
+
+ lll_unlock(rwlock->lock);
+}
diff --git a/libpthread/nptl/DESIGN-sem.txt b/libpthread/nptl/DESIGN-sem.txt
new file mode 100644
index 000000000..17eb0c11c
--- /dev/null
+++ b/libpthread/nptl/DESIGN-sem.txt
@@ -0,0 +1,46 @@
+Semaphores pseudocode
+==============================
+
+ int sem_wait(sem_t * sem);
+ int sem_trywait(sem_t * sem);
+ int sem_post(sem_t * sem);
+ int sem_getvalue(sem_t * sem, int * sval);
+
+struct sem_t {
+
+ unsigned int count;
+ - current semaphore count, also used as a futex
+}
+
+sem_wait(sem_t *sem)
+{
+ for (;;) {
+
+ if (atomic_decrement_if_positive(sem->count))
+ break;
+
+ futex_wait(&sem->count, 0)
+ }
+}
+
+sem_post(sem_t *sem)
+{
+ n = atomic_increment(sem->count);
+ // Pass the new value of sem->count
+ futex_wake(&sem->count, n + 1);
+}
+
+sem_trywait(sem_t *sem)
+{
+ if (atomic_decrement_if_positive(sem->count)) {
+ return 0;
+ } else {
+ return EAGAIN;
+ }
+}
+
+sem_getvalue(sem_t *sem, int *sval)
+{
+ *sval = sem->count;
+ read_barrier();
+}
diff --git a/libpthread/nptl/Makefile b/libpthread/nptl/Makefile
new file mode 100644
index 000000000..f9100219a
--- /dev/null
+++ b/libpthread/nptl/Makefile
@@ -0,0 +1,13 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+top_srcdir=../../
+top_builddir=../../
+include $(top_builddir)Rules.mak
+all: libs
+include Makefile.in
+include $(top_srcdir)Makerules
diff --git a/libpthread/nptl/Makefile.in b/libpthread/nptl/Makefile.in
new file mode 100644
index 000000000..8261fced8
--- /dev/null
+++ b/libpthread/nptl/Makefile.in
@@ -0,0 +1,252 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2005-2006 Steven J. Hill <sjhill@realitydiluted.com>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+subdirs += libpthread/nptl
+
+libpthread_DIR = $(top_srcdir)libpthread/nptl
+libpthread_OUT = $(top_builddir)libpthread/nptl
+
+include $(libpthread_DIR)/sysdeps/Makefile.in
+
+libc-shared-routines-y = forward.c libc-cancellation.c
+libc-static-routines-y = alloca_cutoff.c libc-cancellation.c
+libpthread-shared-only-routines-y = version.c
+libpthread-static-only-routines-y = pthread_atfork.c
+libpthread-routines- += $(notdir $(wildcard $(libpthread_DIR)/gen_*.c)) # dummy generated files
+libpthread-routines- += allocatestack.c # dummy included by pthread_create.c
+libpthread-routines- += pthread_mutex_getprioceiling.c pthread_mutex_setprioceiling.c # XXX: delete those or use them!
+libpthread-routines-$(UCLIBC_HAS_RESOLVER_SUPPORT) += res.c
+libpthread-routines-$(UCLIBC_SUSV4_LEGACY) += pthread_getconcurrency.c \
+ pthread_setconcurrency.c
+libpthread_CSRC = $(filter-out $(libpthread-routines-) \
+ $(libc-shared-routines-y) \
+ $(libc-static-routines-y) \
+ $(libpthread-shared-only-routines-y) \
+ $(libpthread-static-only-routines-y) \
+ $(notdir $(libpthread_OBJS:.o=.c)), \
+ $(notdir $(wildcard $(libpthread_DIR)/*.c)))
+
+libpthread_OBJS += $(addprefix $(libpthread_OUT)/,$(libpthread_CSRC:.c=.o))
+libpthread-so-y += $(addprefix $(libpthread_OUT)/,$(libpthread-shared-only-routines-y:.c=.oS))
+libpthread-so-y += $(libpthread_OBJS:.o=.oS)
+libpthread-nonshared-y := $(addprefix $(libpthread_OUT)/,$(libpthread-static-only-routines-y:.c=.oS))
+libpthread-static-y := $(addprefix $(libpthread_OUT)/,$(libpthread-static-only-routines-y:.c=.o))
+libpthread-static-y += $(libpthread_OBJS)
+ifeq ($(DOPIC),y)
+libpthread-a-y := $(libpthread-static-y:.o=.os)
+else
+libpthread-a-y := $(libpthread-static-y)
+endif
+
+libc-shared-routines-y := $(filter-out $(notdir $(libpthread_libc_OBJS:.o=.c)), $(libc-shared-routines-y))
+libc-static-routines-y := $(filter-out $(notdir $(libpthread_libc_OBJS:.o=.c)), $(libc-static-routines-y))
+libc-shared-routines-y := $(addprefix $(libpthread_OUT)/,$(libc-shared-routines-y:.c=.oS))
+libc-static-routines-y := $(addprefix $(libpthread_OUT)/,$(libc-static-routines-y:.c=.o))
+libc-shared-y += $(libc-shared-routines-y) $(libpthread_libc_OBJS:.o=.oS)
+ifeq ($(DOPIC),y)
+libc-static-y += $(libc-static-routines-y:.o=.os) $(libpthread_libc_a_OBJS:.o=.os) $(libpthread_ld_tls_COBJ:.o=.os)
+else
+libc-static-y += $(libc-static-routines-y) $(libpthread_libc_a_OBJS) $(libpthread_ld_tls_COBJ)
+endif
+
+librt-pt-routines-y := $(patsubst %.c,$(libpthread_pthread_OUT)/%.o,$(filter-out $(notdir $(libpthread_librt_OBJS:.o=.c)), $(librt-pt-routines-y)))
+librt-pt-shared-only-routines-y := $(patsubst %.c,$(libpthread_pthread_OUT)/%.o,$(filter-out $(notdir $(libpthread_librt_OBJS:.o=.c)), $(librt-pt-shared-only-routines-y)))
+librt_OBJS = $(libpthread_librt_OBJS) $(librt-pt-routines-y)
+ifeq ($(DOPIC),y)
+librt-a-y += $(librt_OBJS:.o=.os)
+else
+librt-a-y += $(librt_OBJS)
+endif
+librt-so-y += $(librt_OBJS:.o=.oS) $(librt-pt-shared-only-routines-y:.o=.oS)
+
+ifeq ($(UCLIBC_CTOR_DTOR),y)
+START_FILE-libpthread.so := $(top_builddir)libpthread/nptl/sysdeps/pthread/pt-crti.o
+END_FILE-libpthread.so := $(top_builddir)libpthread/nptl/sysdeps/pthread/pt-crtn.o
+LDFLAGS-libpthread.so += -nostartfiles
+$(top_builddir)lib/libpthread.so: | $(START_FILE-libpthread.so) $(END_FILE-libpthread.so)
+endif
+
+libpthread_FULL_NAME := libpthread-$(VERSION).so
+lib-a-$(UCLIBC_HAS_THREADS) += $(top_builddir)lib/libpthread.a
+lib-so-$(UCLIBC_HAS_THREADS) += $(top_builddir)lib/libpthread.so
+
+$(top_builddir)lib/libpthread.so: $(libpthread_OUT)/libpthread_so.a $(libc.depend) $(libdl.depend) $(top_builddir)lib/libpthread_nonshared.a
+ $(call link.so,$(libpthread_FULL_NAME),$(ABI_VERSION))
+ $(Q)cat $(top_srcdir)extra/scripts/format.lds > $@.tmp
+ $(Q)echo "GROUP ( $(notdir $@).$(ABI_VERSION) libpthread_nonshared.a )" >> $@.tmp
+ $(Q)mv $@.tmp $@
+
+ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
+$(libpthread_OUT)/libpthread_so.a: STRIP_FLAGS:=$(STRIP_FLAGS:-x=-X --strip-debug)
+endif
+$(libpthread_OUT)/libpthread_so.a: $(libpthread-so-y)
+ $(Q)$(RM) $@
+ $(do_ar)
+
+$(top_builddir)lib/libpthread.a: $(libpthread-a-y)
+ $(Q)$(INSTALL) -d $(dir $@)
+ $(Q)$(RM) $@
+ $(do_ar)
+
+$(libpthread_OUT)/pthread-errnos.h: $(top_srcdir)extra/scripts/gen-as-const.awk
+$(libpthread_OUT)/pthread-errnos.h: $(libpthread_DIR)/pthread-errnos.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_THREADS_NATIVE) += $(libpthread_OUT)/pthread-errnos.h
+
+headers-$(UCLIBC_HAS_THREADS_NATIVE) += $(nptl_headers_bootstrap)
+
+libpthread_H := $(addprefix $(top_builddir)include/,semaphore.h)
+libpthread_include_H := $(addprefix $(top_builddir)include/,pthread.h)
+libpthread_include_BITS_H := $(addprefix $(top_builddir)include/bits/,libc-lock.h stdio-lock.h)
+libpthread_include_STD_IMPL_OS_ARCH_BITS_H := $(addprefix $(top_builddir)include/bits/,pthreadtypes.h semaphore.h)
+
+$(libpthread_include_STD_IMPL_OS_ARCH_BITS_H): $(top_builddir)include/bits/%:
+ $(do_ln) $(call rel_srcdir)$(PTDIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH)/bits/$(@F) $@
+$(libpthread_include_BITS_H): $(top_builddir)include/bits/%:
+ $(do_ln) $(call rel_srcdir)$(PTDIR)/sysdeps/pthread/bits/$(@F) $@
+$(libpthread_include_H): $(top_builddir)include/%:
+ $(do_ln) $(call rel_srcdir)$(PTDIR)/sysdeps/pthread/$(@F) $@
+$(libpthread_H): $(top_builddir)include/%:
+ $(do_ln) $(call rel_srcdir)$(PTDIR)/$(@F) $@
+
+nptl_headers_bootstrap = $(libpthread_H) $(libpthread_include_H) $(libpthread_include_BITS_H) $(libpthread_include_STD_IMPL_OS_ARCH_BITS_H)
+
+objclean-y += CLEAN_libpthread/nptl
+headers_clean-y += HEADERCLEAN_libpthread/nptl
+
+HEADERCLEAN_libpthread/nptl:
+ $(do_rm) $(nptl_headers_bootstrap) \
+ $(libpthread_OUT)/pthread-errnos.h
+
+CLEAN_libpthread/nptl:
+ $(do_rm) $(addprefix $(libpthread_OUT)/*., o os oS a)
+
+ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
+LDFLAGS-libpthread.so += $(LDFLAGS_NOSTRIP) -Wl,-z,defs
+else
+LDFLAGS-libpthread.so += $(LDFLAGS)
+endif
+
+LDFLAGS-libpthread.so += $(top_builddir)lib/$(UCLIBC_LDSO_NAME)-$(VERSION).so $(top_builddir)lib/libdl-$(VERSION).so \
+ -Wl,-z,nodelete,-z,initfirst,-init=$(SYMBOL_PREFIX)__pthread_initialize_minimal_internal
+
+LIBS-libpthread.so := $(LIBS)
+
+CFLAGS-dir_nptl := -DNOT_IN_libc -DIS_IN_libpthread
+CFLAGS-libpthread/nptl := $(CFLAGS-dir_nptl) $(SSP_ALL_CFLAGS)
+
+# Since cancellation handling is in large parts handled using exceptions
+# we have to compile some files with exception handling enabled, some
+# even with asynchronous unwind tables.
+
+# init.c contains sigcancel_handler().
+CFLAGS-init.c = -fexceptions -fasynchronous-unwind-tables
+# The unwind code itself,
+CFLAGS-unwind.c = -fexceptions
+CFLAGS-unwind-forcedunwind.c = -fexceptions -fasynchronous-unwind-tables
+
+# The following three functions must be async-cancel safe.
+CFLAGS-pthread_cancel.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-pthread_setcancelstate.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-pthread_setcanceltype.c = -fexceptions -fasynchronous-unwind-tables
+
+# These are internal functions which similar functionality as setcancelstate
+# and setcanceltype.
+CFLAGS-cancellation.c = -fasynchronous-unwind-tables
+CFLAGS-libc-cancellation.c = -fasynchronous-unwind-tables
+
+# Calling pthread_exit() must cause the registered cancel handlers to
+# be executed. Therefore exceptions have to be thrown through this
+# function.
+CFLAGS-pthread_exit.c = -fexceptions
+
+# Among others, __pthread_unwind is forwarded. This function must handle
+# exceptions.
+CFLAGS-forward.c = -fexceptions
+
+# The following are cancellation points. Some of the functions can
+# block and therefore temporarily enable asynchronous cancellation.
+# Those must be compiled asynchronous unwind tables.
+CFLAGS-pthread_testcancel.c = -fexceptions
+CFLAGS-pthread_join.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-pthread_timedjoin.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-pthread_once.c = $(uses-callbacks) -fexceptions \
+ -fasynchronous-unwind-tables
+CFLAGS-pthread_cond_wait.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-pthread_cond_timedwait.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-sem_wait.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-sem_timedwait.c = -fexceptions -fasynchronous-unwind-tables
+
+# These are the function wrappers we have to duplicate here.
+CFLAGS-accept.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-clock_nanosleep.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-close.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-connect.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-creat.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-fdatasync.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-fsync.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-lockf.c = -fexceptions
+CFLAGS-msgrcv.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-msgsnd.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-msync.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-nanosleep.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-open64.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-open.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-pause.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-poll.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-ppoll.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-pread_write.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-pselect.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-read.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-readv.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-recv.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-recvfrom.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-recvmsg.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-__rt_sigtimedwait.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-__rt_sigwaitinfo.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-select.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-send.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-sendmsg.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-sendto.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-sigpause.c = -fexceptions
+CFLAGS-sigsuspend.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-sigtimedwait.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-sigwait.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-sigwaitinfo.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-__syscall_fcntl64.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-__syscall_fcntl.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-tcdrain.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-usleep.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-wait4.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-wait.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-waitid.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-waitpid.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-write.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-writev.c = -fexceptions -fasynchronous-unwind-tables
+
+CFLAGS-pt-system.c = -fexceptions -I$(top_srcdir)libc/stdlib
+
+#
+# The rest of this file is uClibc specific.
+#
+CFLAGS-pthread_barrier_init.c = -D_GNU_SOURCE
+CFLAGS-pthread_barrier_destroy.c = -D_GNU_SOURCE
+CFLAGS-pthread_barrierattr_init.c = -D_GNU_SOURCE
+CFLAGS-pthread_barrierattr_destroy.c = -D_GNU_SOURCE
+CFLAGS-pthread_barrierattr_getpshared.c = -D_GNU_SOURCE
+CFLAGS-pthread_barrierattr_setpshared.c = -D_GNU_SOURCE
+CFLAGS-sem_open.c = -D_GNU_SOURCE
+
+CFLAGS-OMIT-alloca_cutoff.c = $(CFLAGS-dir_nptl)
+CFLAGS-OMIT-forward.c = $(CFLAGS-dir_nptl)
+CFLAGS-OMIT-libc-lowlevelock.c = $(CFLAGS-dir_nptl)
+CFLAGS-OMIT-libc-cancellation.c = $(CFLAGS-dir_nptl)
diff --git a/libpthread/nptl/README.NPTL b/libpthread/nptl/README.NPTL
new file mode 100644
index 000000000..7e50984cb
--- /dev/null
+++ b/libpthread/nptl/README.NPTL
@@ -0,0 +1,307 @@
+The base NPTL code for uClibc is from the glibc project located at
+<http://sourceware.org/glibc/>. The starting version was the HEAD of
+the glibc CVS repository dated 2005-05-06. Important changes from
+glibc will continue to be brought in as necessary until the version
+for uClibc is standing on its own. All of the files were originally
+brought over verbatim with no modifications. Obviously, these will
+undergo any necessary changes needed for integration into uClibc.
+Additionally (or subtractingly), the files and directories below
+were removed and not imported.
+
+-- Steven J. Hill <sjhill@realitydiluted.com> on 2005-05-06
+
+
+nptl/Makeconfig
+nptl/configure
+nptl/shlib-versions
+nptl/sysdeps/generic
+nptl/sysdeps/ia64
+nptl/sysdeps/pthread/Makefile
+nptl/sysdeps/pthread/Subdirs
+nptl/sysdeps/pthread/allocalim.h
+nptl/sysdeps/pthread/configure
+nptl/sysdeps/pthread/configure.in
+nptl/sysdeps/pthread/createthread.c
+nptl/sysdeps/pthread/flockfile.c
+nptl/sysdeps/pthread/ftrylockfile.c
+nptl/sysdeps/pthread/funlockfile.c
+nptl/sysdeps/pthread/librt-cancellation.c
+nptl/sysdeps/pthread/list.h
+nptl/sysdeps/pthread/malloc-machine.h
+nptl/sysdeps/pthread/posix-timer.h
+nptl/sysdeps/pthread/pt-initfini.c
+nptl/sysdeps/pthread/pt-longjmp.c
+nptl/sysdeps/pthread/pthread-functions.h
+nptl/sysdeps/pthread/pthread.h
+nptl/sysdeps/pthread/pthread_barrier_wait.c
+nptl/sysdeps/pthread/pthread_cond_broadcast.c
+nptl/sysdeps/pthread/pthread_cond_signal.c
+nptl/sysdeps/pthread/pthread_cond_timedwait.c
+nptl/sysdeps/pthread/pthread_cond_wait.c
+nptl/sysdeps/pthread/pthread_getcpuclockid.c
+nptl/sysdeps/pthread/pthread_once.c
+nptl/sysdeps/pthread/pthread_rwlock_rdlock.c
+nptl/sysdeps/pthread/pthread_rwlock_timedrdlock.c
+nptl/sysdeps/pthread/pthread_rwlock_timedwrlock.c
+nptl/sysdeps/pthread/pthread_rwlock_unlock.c
+nptl/sysdeps/pthread/pthread_rwlock_wrlock.c
+nptl/sysdeps/pthread/pthread_sigmask.c
+nptl/sysdeps/pthread/pthread_spin_destroy.c
+nptl/sysdeps/pthread/pthread_spin_init.c
+nptl/sysdeps/pthread/pthread_spin_unlock.c
+nptl/sysdeps/pthread/rt-unwind-resume.c
+nptl/sysdeps/pthread/setxid.h
+nptl/sysdeps/pthread/sigaction.c
+nptl/sysdeps/pthread/sigfillset.c
+nptl/sysdeps/pthread/sigprocmask.c
+nptl/sysdeps/pthread/tcb-offsets.h
+nptl/sysdeps/pthread/timer_create.c
+nptl/sysdeps/pthread/timer_delete.c
+nptl/sysdeps/pthread/timer_getoverr.c
+nptl/sysdeps/pthread/timer_gettime.c
+nptl/sysdeps/pthread/timer_routines.c
+nptl/sysdeps/pthread/timer_settime.c
+nptl/sysdeps/pthread/tst-mqueue8x.c
+nptl/sysdeps/pthread/tst-timer.c
+nptl/sysdeps/pthread/unwind-forcedunwind.c
+nptl/sysdeps/pthread/unwind-resume.c
+nptl/sysdeps/s390
+nptl/sysdeps/unix
+nptl/tst-_res1.c
+nptl/tst-_res1mod1.c
+nptl/tst-_res1mod2.c
+nptl/tst-align.c
+nptl/tst-align2.c
+nptl/tst-atfork1.c
+nptl/tst-atfork2.c
+nptl/tst-atfork2mod.c
+nptl/tst-attr1.c
+nptl/tst-attr2.c
+nptl/tst-attr3.c
+nptl/tst-backtrace1.c
+nptl/tst-barrier1.c
+nptl/tst-barrier2.c
+nptl/tst-barrier3.c
+nptl/tst-barrier4.c
+nptl/tst-basic1.c
+nptl/tst-basic2.c
+nptl/tst-basic3.c
+nptl/tst-basic4.c
+nptl/tst-basic5.c
+nptl/tst-basic6.c
+nptl/tst-cancel-wrappers.sh
+nptl/tst-cancel1.c
+nptl/tst-cancel10.c
+nptl/tst-cancel11.c
+nptl/tst-cancel12.c
+nptl/tst-cancel13.c
+nptl/tst-cancel14.c
+nptl/tst-cancel15.c
+nptl/tst-cancel16.c
+nptl/tst-cancel17.c
+nptl/tst-cancel18.c
+nptl/tst-cancel19.c
+nptl/tst-cancel2.c
+nptl/tst-cancel20.c
+nptl/tst-cancel21.c
+nptl/tst-cancel22.c
+nptl/tst-cancel23.c
+nptl/tst-cancel3.c
+nptl/tst-cancel4.c
+nptl/tst-cancel5.c
+nptl/tst-cancel6.c
+nptl/tst-cancel7.c
+nptl/tst-cancel8.c
+nptl/tst-cancel9.c
+nptl/tst-cancelx1.c
+nptl/tst-cancelx10.c
+nptl/tst-cancelx11.c
+nptl/tst-cancelx12.c
+nptl/tst-cancelx13.c
+nptl/tst-cancelx14.c
+nptl/tst-cancelx15.c
+nptl/tst-cancelx16.c
+nptl/tst-cancelx17.c
+nptl/tst-cancelx18.c
+nptl/tst-cancelx2.c
+nptl/tst-cancelx20.c
+nptl/tst-cancelx21.c
+nptl/tst-cancelx3.c
+nptl/tst-cancelx4.c
+nptl/tst-cancelx5.c
+nptl/tst-cancelx6.c
+nptl/tst-cancelx7.c
+nptl/tst-cancelx8.c
+nptl/tst-cancelx9.c
+nptl/tst-cleanup0.c
+nptl/tst-cleanup0.expect
+nptl/tst-cleanup1.c
+nptl/tst-cleanup2.c
+nptl/tst-cleanup3.c
+nptl/tst-cleanup4.c
+nptl/tst-cleanup4aux.c
+nptl/tst-cleanupx0.c
+nptl/tst-cleanupx0.expect
+nptl/tst-cleanupx1.c
+nptl/tst-cleanupx2.c
+nptl/tst-cleanupx3.c
+nptl/tst-cleanupx4.c
+nptl/tst-clock1.c
+nptl/tst-clock2.c
+nptl/tst-cond1.c
+nptl/tst-cond10.c
+nptl/tst-cond11.c
+nptl/tst-cond12.c
+nptl/tst-cond13.c
+nptl/tst-cond14.c
+nptl/tst-cond15.c
+nptl/tst-cond16.c
+nptl/tst-cond17.c
+nptl/tst-cond18.c
+nptl/tst-cond19.c
+nptl/tst-cond2.c
+nptl/tst-cond20.c
+nptl/tst-cond21.c
+nptl/tst-cond3.c
+nptl/tst-cond4.c
+nptl/tst-cond5.c
+nptl/tst-cond6.c
+nptl/tst-cond7.c
+nptl/tst-cond8.c
+nptl/tst-cond9.c
+nptl/tst-context1.c
+nptl/tst-detach1.c
+nptl/tst-dlsym1.c
+nptl/tst-eintr1.c
+nptl/tst-eintr2.c
+nptl/tst-eintr3.c
+nptl/tst-eintr4.c
+nptl/tst-eintr5.c
+nptl/tst-exec1.c
+nptl/tst-exec2.c
+nptl/tst-exec3.c
+nptl/tst-exec4.c
+nptl/tst-execstack-mod.c
+nptl/tst-execstack.c
+nptl/tst-exit1.c
+nptl/tst-exit2.c
+nptl/tst-exit3.c
+nptl/tst-fini1.c
+nptl/tst-fini1mod.c
+nptl/tst-flock1.c
+nptl/tst-flock2.c
+nptl/tst-fork1.c
+nptl/tst-fork2.c
+nptl/tst-fork3.c
+nptl/tst-fork4.c
+nptl/tst-getpid1.c
+nptl/tst-getpid2.c
+nptl/tst-join1.c
+nptl/tst-join2.c
+nptl/tst-join3.c
+nptl/tst-join4.c
+nptl/tst-join5.c
+nptl/tst-key1.c
+nptl/tst-key2.c
+nptl/tst-key3.c
+nptl/tst-key4.c
+nptl/tst-kill1.c
+nptl/tst-kill2.c
+nptl/tst-kill3.c
+nptl/tst-kill4.c
+nptl/tst-kill5.c
+nptl/tst-kill6.c
+nptl/tst-locale1.c
+nptl/tst-locale2.c
+nptl/tst-mutex1.c
+nptl/tst-mutex2.c
+nptl/tst-mutex3.c
+nptl/tst-mutex4.c
+nptl/tst-mutex5.c
+nptl/tst-mutex5a.c
+nptl/tst-mutex6.c
+nptl/tst-mutex7.c
+nptl/tst-mutex7a.c
+nptl/tst-mutex8.c
+nptl/tst-mutex9.c
+nptl/tst-oddstacklimit.c
+nptl/tst-once1.c
+nptl/tst-once2.c
+nptl/tst-once3.c
+nptl/tst-once4.c
+nptl/tst-oncex3.c
+nptl/tst-oncex4.c
+nptl/tst-popen1.c
+nptl/tst-raise1.c
+nptl/tst-rwlock1.c
+nptl/tst-rwlock10.c
+nptl/tst-rwlock11.c
+nptl/tst-rwlock12.c
+nptl/tst-rwlock13.c
+nptl/tst-rwlock14.c
+nptl/tst-rwlock2.c
+nptl/tst-rwlock3.c
+nptl/tst-rwlock4.c
+nptl/tst-rwlock5.c
+nptl/tst-rwlock6.c
+nptl/tst-rwlock7.c
+nptl/tst-rwlock8.c
+nptl/tst-rwlock9.c
+nptl/tst-sched1.c
+nptl/tst-sem1.c
+nptl/tst-sem2.c
+nptl/tst-sem3.c
+nptl/tst-sem4.c
+nptl/tst-sem5.c
+nptl/tst-sem6.c
+nptl/tst-sem7.c
+nptl/tst-sem8.c
+nptl/tst-sem9.c
+nptl/tst-setuid1-static.c
+nptl/tst-setuid1.c
+nptl/tst-signal1.c
+nptl/tst-signal2.c
+nptl/tst-signal3.c
+nptl/tst-signal4.c
+nptl/tst-signal5.c
+nptl/tst-signal6.c
+nptl/tst-spin1.c
+nptl/tst-spin2.c
+nptl/tst-spin3.c
+nptl/tst-stack1.c
+nptl/tst-stack2.c
+nptl/tst-stack3.c
+nptl/tst-stdio1.c
+nptl/tst-stdio2.c
+nptl/tst-sysconf.c
+nptl/tst-tls1.c
+nptl/tst-tls2.c
+nptl/tst-tls3.c
+nptl/tst-tls3mod.c
+nptl/tst-tls4.c
+nptl/tst-tls4moda.c
+nptl/tst-tls4modb.c
+nptl/tst-tls5.c
+nptl/tst-tls5.h
+nptl/tst-tls5mod.c
+nptl/tst-tls5moda.c
+nptl/tst-tls5modb.c
+nptl/tst-tls5modc.c
+nptl/tst-tls5modd.c
+nptl/tst-tls5mode.c
+nptl/tst-tls5modf.c
+nptl/tst-tls6.sh
+nptl/tst-tsd1.c
+nptl/tst-tsd2.c
+nptl/tst-tsd3.c
+nptl/tst-tsd4.c
+nptl/tst-tsd5.c
+nptl/tst-umask1.c
+nptl/tst-unload.c
+nptl/tst-vfork1.c
+nptl/tst-vfork1x.c
+nptl/tst-vfork2.c
+nptl/tst-vfork2x.c
+nptl/version.c
+nptl_db/ChangeLog
+nptl_db/shlib-versions
diff --git a/libpthread/nptl/TODO b/libpthread/nptl/TODO
new file mode 100644
index 000000000..70b8fe4f7
--- /dev/null
+++ b/libpthread/nptl/TODO
@@ -0,0 +1,31 @@
+- we should probably extend pthread_mutexattr_t with a field to create a
+ single linked list of all instances. This requires changing the
+ pthread_mutexattr_* functions.
+
+
+- a new attribute for mutexes: number of times we spin before calling
+sys_futex
+
+- for adaptive mutexes: when releasing, determine whether somebody spins.
+If yes, for a short time release lock. If someone else locks no wakeup
+syscall needed.
+
+
+
+- test with threaded process terminating and semadj (?) being applied
+ only after all threads are gone
+
+
+
+- semaphore changes:
+
+ - sem_post should only wake one thread and only when the state of
+ the semaphore changed from 0 to 1
+
+ this also requires that sem_wait and sem_timedwait don't drop the
+ post if they get canceled.
+
+ - possibly add counter field. This requires reviving the
+ differences between old and new semaphose funtions. The old ones
+ stay as they are now. The new once can use an additional field
+ wich is the counter for the number of waiters
diff --git a/libpthread/nptl/TODO-kernel b/libpthread/nptl/TODO-kernel
new file mode 100644
index 000000000..ad6d2a4b5
--- /dev/null
+++ b/libpthread/nptl/TODO-kernel
@@ -0,0 +1,20 @@
+- setuid/setgid must effect process
+ + test syscalls (getuid) afterwards
+ + test core file content
+
+ + use UID/GID in access(2), chmod(2), chown(2), link(2)
+
+- nice level is process property
+
+- rlimit should be process-wide and SIGXCPU should be sent if all threads
+ together exceed the limit
+
+- getrusage() must return resource utilization for the process
+
+
+
+The following are possible optimizations and in no way required:
+
+
+- the scheduler should be thread group-aware, i.e., it has to give time to
+ the thread group not proportional to the number of threads.
diff --git a/libpthread/nptl/TODO-testing b/libpthread/nptl/TODO-testing
new file mode 100644
index 000000000..e076e5624
--- /dev/null
+++ b/libpthread/nptl/TODO-testing
@@ -0,0 +1,20 @@
+pthread_attr_setguardsize
+
+ test effectiveness
+
+pthread_attr_[sg]etschedparam
+
+ what to test?
+
+pthread_attr_[sg]etstack
+
+ some more tests needed
+
+pthread_getcpuclockid
+
+ check that value is reset -> rt subdir
+
+pthread_getschedparam
+pthread_setschedparam
+
+ what to test?
diff --git a/libpthread/nptl/alloca_cutoff.c b/libpthread/nptl/alloca_cutoff.c
new file mode 100644
index 000000000..86d1e2900
--- /dev/null
+++ b/libpthread/nptl/alloca_cutoff.c
@@ -0,0 +1,35 @@
+/* Determine whether block of given size can be allocated on the stack or not.
+ Copyright (C) 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; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <alloca.h>
+#include <stdlib.h>
+#include <sys/param.h>
+#include <pthreadP.h>
+
+
+int
+__libc_alloca_cutoff (size_t size)
+{
+ return size <= (MIN (__MAX_ALLOCA_CUTOFF,
+ THREAD_GETMEM (THREAD_SELF, stackblock_size) / 4
+ /* The main thread, before the thread library is
+ initialized, has zero in the stackblock_size
+ element. Since it is the main thread we can
+ assume the maximum available stack space. */
+ ?: __MAX_ALLOCA_CUTOFF * 4));
+}
diff --git a/libpthread/nptl/allocatestack.c b/libpthread/nptl/allocatestack.c
new file mode 100644
index 000000000..bf9925253
--- /dev/null
+++ b/libpthread/nptl/allocatestack.c
@@ -0,0 +1,1220 @@
+/* Copyright (C) 2002-2007, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <assert.h>
+#include <errno.h>
+#include <signal.h>
+#include <stdint.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/param.h>
+#include <tls.h>
+#include <lowlevellock.h>
+#include <link.h>
+#include <bits/kernel-features.h>
+
+
+#ifndef NEED_SEPARATE_REGISTER_STACK
+
+/* Most architectures have exactly one stack pointer. Some have more. */
+# define STACK_VARIABLES void *stackaddr = NULL
+
+/* How to pass the values to the 'create_thread' function. */
+# define STACK_VARIABLES_ARGS stackaddr
+
+/* How to declare function which gets there parameters. */
+# define STACK_VARIABLES_PARMS void *stackaddr
+
+/* How to declare allocate_stack. */
+# define ALLOCATE_STACK_PARMS void **stack
+
+/* This is how the function is called. We do it this way to allow
+ other variants of the function to have more parameters. */
+# define ALLOCATE_STACK(attr, pd) allocate_stack (attr, pd, &stackaddr)
+
+#else
+
+/* We need two stacks. The kernel will place them but we have to tell
+ the kernel about the size of the reserved address space. */
+# define STACK_VARIABLES void *stackaddr = NULL; size_t stacksize = 0
+
+/* How to pass the values to the 'create_thread' function. */
+# define STACK_VARIABLES_ARGS stackaddr, stacksize
+
+/* How to declare function which gets there parameters. */
+# define STACK_VARIABLES_PARMS void *stackaddr, size_t stacksize
+
+/* How to declare allocate_stack. */
+# define ALLOCATE_STACK_PARMS void **stack, size_t *stacksize
+
+/* This is how the function is called. We do it this way to allow
+ other variants of the function to have more parameters. */
+# define ALLOCATE_STACK(attr, pd) \
+ allocate_stack (attr, pd, &stackaddr, &stacksize)
+
+#endif
+
+
+/* Default alignment of stack. */
+#ifndef STACK_ALIGN
+# define STACK_ALIGN __alignof__ (long double)
+#endif
+
+/* Default value for minimal stack size after allocating thread
+ descriptor and guard. */
+#ifndef MINIMAL_REST_STACK
+# define MINIMAL_REST_STACK 4096
+#endif
+
+
+/* Newer kernels have the MAP_STACK flag to indicate a mapping is used for
+ a stack. Use it when possible. */
+#ifndef MAP_STACK
+# define MAP_STACK 0
+#endif
+
+/* This yields the pointer that TLS support code calls the thread pointer. */
+#if defined(TLS_TCB_AT_TP)
+# define TLS_TPADJ(pd) (pd)
+#elif defined(TLS_DTV_AT_TP)
+# define TLS_TPADJ(pd) ((struct pthread *)((char *) (pd) + TLS_PRE_TCB_SIZE))
+#endif
+
+/* Cache handling for not-yet free stacks. */
+
+/*
+ Maximum size in kB of cache. GNU libc default is 40MiB
+ embedded systems don't have enough ram for big dirty stack caches,
+ reduce it to 16MiB. 4 does not work, f.e. tst-kill4 segfaults.
+*/
+static size_t stack_cache_maxsize = 16 * 1024 * 1024;
+static size_t stack_cache_actsize;
+
+/* Mutex protecting this variable. */
+static int stack_cache_lock = LLL_LOCK_INITIALIZER;
+
+/* List of queued stack frames. */
+static LIST_HEAD (stack_cache);
+
+/* List of the stacks in use. */
+static LIST_HEAD (stack_used);
+
+/* We need to record what list operations we are going to do so that,
+ in case of an asynchronous interruption due to a fork() call, we
+ can correct for the work. */
+static uintptr_t in_flight_stack;
+
+/* List of the threads with user provided stacks in use. No need to
+ initialize this, since it's done in __pthread_initialize_minimal. */
+list_t __stack_user __attribute__ ((nocommon));
+hidden_data_def (__stack_user)
+
+#if defined COLORING_INCREMENT && COLORING_INCREMENT != 0
+/* Number of threads created. */
+static unsigned int nptl_ncreated;
+#endif
+
+
+/* Check whether the stack is still used or not. */
+#define FREE_P(descr) ((descr)->tid <= 0)
+
+
+static void
+stack_list_del (list_t *elem)
+{
+ in_flight_stack = (uintptr_t) elem;
+
+ atomic_write_barrier ();
+
+ list_del (elem);
+
+ atomic_write_barrier ();
+
+ in_flight_stack = 0;
+}
+
+
+static void
+stack_list_add (list_t *elem, list_t *list)
+{
+ in_flight_stack = (uintptr_t) elem | 1;
+
+ atomic_write_barrier ();
+
+ list_add (elem, list);
+
+ atomic_write_barrier ();
+
+ in_flight_stack = 0;
+}
+
+
+/* We create a double linked list of all cache entries. Double linked
+ because this allows removing entries from the end. */
+
+
+/* Get a stack frame from the cache. We have to match by size since
+ some blocks might be too small or far too large. */
+static struct pthread *
+get_cached_stack (size_t *sizep, void **memp)
+{
+ size_t size = *sizep;
+ struct pthread *result = NULL;
+ list_t *entry;
+
+ lll_lock (stack_cache_lock, LLL_PRIVATE);
+
+ /* Search the cache for a matching entry. We search for the
+ smallest stack which has at least the required size. Note that
+ in normal situations the size of all allocated stacks is the
+ same. As the very least there are only a few different sizes.
+ Therefore this loop will exit early most of the time with an
+ exact match. */
+ list_for_each (entry, &stack_cache)
+ {
+ struct pthread *curr;
+
+ curr = list_entry (entry, struct pthread, list);
+ if (FREE_P (curr) && curr->stackblock_size >= size)
+ {
+ if (curr->stackblock_size == size)
+ {
+ result = curr;
+ break;
+ }
+
+ if (result == NULL
+ || result->stackblock_size > curr->stackblock_size)
+ result = curr;
+ }
+ }
+
+ if (__builtin_expect (result == NULL, 0)
+ /* Make sure the size difference is not too excessive. In that
+ case we do not use the block. */
+ || __builtin_expect (result->stackblock_size > 4 * size, 0))
+ {
+ /* Release the lock. */
+ lll_unlock (stack_cache_lock, LLL_PRIVATE);
+
+ return NULL;
+ }
+
+ /* Dequeue the entry. */
+ stack_list_del (&result->list);
+
+ /* And add to the list of stacks in use. */
+ stack_list_add (&result->list, &stack_used);
+
+ /* And decrease the cache size. */
+ stack_cache_actsize -= result->stackblock_size;
+
+ /* Release the lock early. */
+ lll_unlock (stack_cache_lock, LLL_PRIVATE);
+
+ /* Report size and location of the stack to the caller. */
+ *sizep = result->stackblock_size;
+ *memp = result->stackblock;
+
+ /* Cancellation handling is back to the default. */
+ result->cancelhandling = 0;
+ result->cleanup = NULL;
+
+ /* No pending event. */
+ result->nextevent = NULL;
+
+ /* Clear the DTV. */
+ dtv_t *dtv = GET_DTV (TLS_TPADJ (result));
+ memset (dtv, '\0', (dtv[-1].counter + 1) * sizeof (dtv_t));
+
+ /* Re-initialize the TLS. */
+ _dl_allocate_tls_init (TLS_TPADJ (result));
+
+ return result;
+}
+
+
+/* Free stacks until cache size is lower than LIMIT. */
+void
+__free_stacks (size_t limit)
+{
+ /* We reduce the size of the cache. Remove the last entries until
+ the size is below the limit. */
+ list_t *entry;
+ list_t *prev;
+
+ /* Search from the end of the list. */
+ list_for_each_prev_safe (entry, prev, &stack_cache)
+ {
+ struct pthread *curr;
+
+ curr = list_entry (entry, struct pthread, list);
+ if (FREE_P (curr))
+ {
+ /* Unlink the block. */
+ stack_list_del (entry);
+
+ /* Account for the freed memory. */
+ stack_cache_actsize -= curr->stackblock_size;
+
+ /* Free the memory associated with the ELF TLS. */
+ _dl_deallocate_tls (TLS_TPADJ (curr), false);
+
+ /* Remove this block. This should never fail. If it does
+ something is really wrong. */
+ if (munmap (curr->stackblock, curr->stackblock_size) != 0)
+ abort ();
+
+ /* Maybe we have freed enough. */
+ if (stack_cache_actsize <= limit)
+ break;
+ }
+ }
+}
+
+
+/* Add a stack frame which is not used anymore to the stack. Must be
+ called with the cache lock held. */
+static inline void
+__attribute ((always_inline))
+queue_stack (struct pthread *stack)
+{
+ /* We unconditionally add the stack to the list. The memory may
+ still be in use but it will not be reused until the kernel marks
+ the stack as not used anymore. */
+ stack_list_add (&stack->list, &stack_cache);
+
+ stack_cache_actsize += stack->stackblock_size;
+ if (__builtin_expect (stack_cache_actsize > stack_cache_maxsize, 0))
+ __free_stacks (stack_cache_maxsize);
+}
+
+
+static int
+internal_function
+change_stack_perm (struct pthread *pd
+#ifdef NEED_SEPARATE_REGISTER_STACK
+ , size_t pagemask
+#endif
+ )
+{
+#ifdef NEED_SEPARATE_REGISTER_STACK
+ void *stack = (pd->stackblock
+ + (((((pd->stackblock_size - pd->guardsize) / 2)
+ & pagemask) + pd->guardsize) & pagemask));
+ size_t len = pd->stackblock + pd->stackblock_size - stack;
+#elif defined _STACK_GROWS_DOWN
+ void *stack = pd->stackblock + pd->guardsize;
+ size_t len = pd->stackblock_size - pd->guardsize;
+#elif defined _STACK_GROWS_UP
+ void *stack = pd->stackblock;
+ size_t len = (uintptr_t) pd - pd->guardsize - (uintptr_t) pd->stackblock;
+#else
+# error "Define either _STACK_GROWS_DOWN or _STACK_GROWS_UP"
+#endif
+ if (mprotect (stack, len, PROT_READ | PROT_WRITE | PROT_EXEC) != 0)
+ return errno;
+
+ return 0;
+}
+
+
+static int
+allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
+ ALLOCATE_STACK_PARMS)
+{
+ struct pthread *pd;
+ size_t size;
+ size_t pagesize_m1 = __getpagesize () - 1;
+ void *stacktop;
+
+ assert (attr != NULL);
+ assert (powerof2 (pagesize_m1 + 1));
+ assert (TCB_ALIGNMENT >= STACK_ALIGN);
+
+ /* Get the stack size from the attribute if it is set. Otherwise we
+ use the default we determined at start time. */
+ size = attr->stacksize ?: __default_stacksize;
+
+ /* Get memory for the stack. */
+ if (__builtin_expect (attr->flags & ATTR_FLAG_STACKADDR, 0))
+ {
+ uintptr_t adj;
+
+ /* If the user also specified the size of the stack make sure it
+ is large enough. */
+ if (attr->stacksize != 0
+ && attr->stacksize < (__static_tls_size + MINIMAL_REST_STACK))
+ return EINVAL;
+
+ /* Adjust stack size for alignment of the TLS block. */
+#if defined(TLS_TCB_AT_TP)
+ adj = ((uintptr_t) attr->stackaddr - TLS_TCB_SIZE)
+ & __static_tls_align_m1;
+ assert (size > adj + TLS_TCB_SIZE);
+#elif defined(TLS_DTV_AT_TP)
+ adj = ((uintptr_t) attr->stackaddr - __static_tls_size)
+ & __static_tls_align_m1;
+ assert (size > adj);
+#endif
+
+ /* The user provided some memory. Let's hope it matches the
+ size... We do not allocate guard pages if the user provided
+ the stack. It is the user's responsibility to do this if it
+ is wanted. */
+#if defined(TLS_TCB_AT_TP)
+ pd = (struct pthread *) ((uintptr_t) attr->stackaddr
+ - TLS_TCB_SIZE - adj);
+#elif defined(TLS_DTV_AT_TP)
+ pd = (struct pthread *) (((uintptr_t) attr->stackaddr
+ - __static_tls_size - adj)
+ - TLS_PRE_TCB_SIZE);
+#endif
+
+ /* The user provided stack memory needs to be cleared. */
+ memset (pd, '\0', sizeof (struct pthread));
+
+ /* The first TSD block is included in the TCB. */
+ pd->specific[0] = pd->specific_1stblock;
+
+ /* Remember the stack-related values. */
+ pd->stackblock = (char *) attr->stackaddr - size;
+ pd->stackblock_size = size;
+
+ /* This is a user-provided stack. It will not be queued in the
+ stack cache nor will the memory (except the TLS memory) be freed. */
+ pd->user_stack = true;
+
+ /* This is at least the second thread. */
+ pd->header.multiple_threads = 1;
+#ifndef TLS_MULTIPLE_THREADS_IN_TCB
+ __pthread_multiple_threads = *__libc_multiple_threads_ptr = 1;
+#endif
+
+#ifndef __ASSUME_PRIVATE_FUTEX
+ /* The thread must know when private futexes are supported. */
+ pd->header.private_futex = THREAD_GETMEM (THREAD_SELF,
+ header.private_futex);
+#endif
+
+#ifdef NEED_DL_SYSINFO
+ /* Copy the sysinfo value from the parent. */
+ THREAD_SYSINFO(pd) = THREAD_SELF_SYSINFO;
+#endif
+
+ /* The process ID is also the same as that of the caller. */
+ pd->pid = THREAD_GETMEM (THREAD_SELF, pid);
+
+ /* Allocate the DTV for this thread. */
+ if (_dl_allocate_tls (TLS_TPADJ (pd)) == NULL)
+ {
+ /* Something went wrong. */
+ assert (errno == ENOMEM);
+ return EAGAIN;
+ }
+
+
+ /* Prepare to modify global data. */
+ lll_lock (stack_cache_lock, LLL_PRIVATE);
+
+ /* And add to the list of stacks in use. */
+ list_add (&pd->list, &__stack_user);
+
+ lll_unlock (stack_cache_lock, LLL_PRIVATE);
+ }
+ else
+ {
+ /* Allocate some anonymous memory. If possible use the cache. */
+ size_t guardsize;
+ size_t reqsize;
+ void *mem = 0;
+ const int prot = (PROT_READ | PROT_WRITE);
+
+#if defined COLORING_INCREMENT && COLORING_INCREMENT != 0
+ /* Add one more page for stack coloring. Don't do it for stacks
+ with 16 times pagesize or larger. This might just cause
+ unnecessary misalignment. */
+ if (size <= 16 * pagesize_m1)
+ size += pagesize_m1 + 1;
+#endif
+
+ /* Adjust the stack size for alignment. */
+ size &= ~__static_tls_align_m1;
+ assert (size != 0);
+
+ /* Make sure the size of the stack is enough for the guard and
+ eventually the thread descriptor. */
+ guardsize = (attr->guardsize + pagesize_m1) & ~pagesize_m1;
+ if (__builtin_expect (size < ((guardsize + __static_tls_size
+ + MINIMAL_REST_STACK + pagesize_m1)
+ & ~pagesize_m1),
+ 0))
+ /* The stack is too small (or the guard too large). */
+ return EINVAL;
+
+ /* Try to get a stack from the cache. */
+ reqsize = size;
+ pd = get_cached_stack (&size, &mem);
+ if (pd == NULL)
+ {
+ /* To avoid aliasing effects on a larger scale than pages we
+ adjust the allocated stack size if necessary. This way
+ allocations directly following each other will not have
+ aliasing problems. */
+#if defined MULTI_PAGE_ALIASING && MULTI_PAGE_ALIASING != 0
+ if ((size % MULTI_PAGE_ALIASING) == 0)
+ size += pagesize_m1 + 1;
+#endif
+
+ mem = mmap (NULL, size, prot,
+ MAP_PRIVATE | MAP_ANONYMOUS | MAP_STACK, -1, 0);
+
+ if (__builtin_expect (mem == MAP_FAILED, 0))
+ {
+ if (errno == ENOMEM)
+ __set_errno (EAGAIN);
+
+ return errno;
+ }
+
+ /* SIZE is guaranteed to be greater than zero.
+ So we can never get a null pointer back from mmap. */
+ assert (mem != NULL);
+
+#if defined COLORING_INCREMENT && COLORING_INCREMENT != 0
+ /* Atomically increment NCREATED. */
+ unsigned int ncreated = atomic_increment_val (&nptl_ncreated);
+
+ /* We chose the offset for coloring by incrementing it for
+ every new thread by a fixed amount. The offset used
+ module the page size. Even if coloring would be better
+ relative to higher alignment values it makes no sense to
+ do it since the mmap() interface does not allow us to
+ specify any alignment for the returned memory block. */
+ size_t coloring = (ncreated * COLORING_INCREMENT) & pagesize_m1;
+
+ /* Make sure the coloring offsets does not disturb the alignment
+ of the TCB and static TLS block. */
+ if (__builtin_expect ((coloring & __static_tls_align_m1) != 0, 0))
+ coloring = (((coloring + __static_tls_align_m1)
+ & ~(__static_tls_align_m1))
+ & ~pagesize_m1);
+#else
+ /* Unless specified we do not make any adjustments. */
+# define coloring 0
+#endif
+
+ /* Place the thread descriptor at the end of the stack. */
+#if defined(TLS_TCB_AT_TP)
+ pd = (struct pthread *) ((char *) mem + size - coloring) - 1;
+#elif defined(TLS_DTV_AT_TP)
+ pd = (struct pthread *) ((((uintptr_t) mem + size - coloring
+ - __static_tls_size)
+ & ~__static_tls_align_m1)
+ - TLS_PRE_TCB_SIZE);
+#endif
+
+ /* Remember the stack-related values. */
+ pd->stackblock = mem;
+ pd->stackblock_size = size;
+
+ /* We allocated the first block thread-specific data array.
+ This address will not change for the lifetime of this
+ descriptor. */
+ pd->specific[0] = pd->specific_1stblock;
+
+ /* This is at least the second thread. */
+ pd->header.multiple_threads = 1;
+#ifndef TLS_MULTIPLE_THREADS_IN_TCB
+ __pthread_multiple_threads = *__libc_multiple_threads_ptr = 1;
+#endif
+
+#ifndef __ASSUME_PRIVATE_FUTEX
+ /* The thread must know when private futexes are supported. */
+ pd->header.private_futex = THREAD_GETMEM (THREAD_SELF,
+ header.private_futex);
+#endif
+
+#ifdef NEED_DL_SYSINFO
+ /* Copy the sysinfo value from the parent. */
+ THREAD_SYSINFO(pd) = THREAD_SELF_SYSINFO;
+#endif
+
+ /* The process ID is also the same as that of the caller. */
+ pd->pid = THREAD_GETMEM (THREAD_SELF, pid);
+
+ /* Allocate the DTV for this thread. */
+ if (_dl_allocate_tls (TLS_TPADJ (pd)) == NULL)
+ {
+ /* Something went wrong. */
+ assert (errno == ENOMEM);
+
+ /* Free the stack memory we just allocated. */
+ (void) munmap (mem, size);
+
+ return EAGAIN;
+ }
+
+
+ /* Prepare to modify global data. */
+ lll_lock (stack_cache_lock, LLL_PRIVATE);
+
+ /* And add to the list of stacks in use. */
+ stack_list_add (&pd->list, &stack_used);
+
+ lll_unlock (stack_cache_lock, LLL_PRIVATE);
+
+
+ /* Note that all of the stack and the thread descriptor is
+ zeroed. This means we do not have to initialize fields
+ with initial value zero. This is specifically true for
+ the 'tid' field which is always set back to zero once the
+ stack is not used anymore and for the 'guardsize' field
+ which will be read next. */
+ }
+
+ /* Create or resize the guard area if necessary. */
+ if (__builtin_expect (guardsize > pd->guardsize, 0))
+ {
+#ifdef NEED_SEPARATE_REGISTER_STACK
+ char *guard = mem + (((size - guardsize) / 2) & ~pagesize_m1);
+#elif defined _STACK_GROWS_DOWN
+ char *guard = mem;
+#elif defined _STACK_GROWS_UP
+ char *guard = (char *) (((uintptr_t) pd - guardsize) & ~pagesize_m1);
+#endif
+ if (mprotect (guard, guardsize, PROT_NONE) != 0)
+ {
+ int err;
+ mprot_error:
+ err = errno;
+
+ lll_lock (stack_cache_lock, LLL_PRIVATE);
+
+ /* Remove the thread from the list. */
+ stack_list_del (&pd->list);
+
+ lll_unlock (stack_cache_lock, LLL_PRIVATE);
+
+ /* Get rid of the TLS block we allocated. */
+ _dl_deallocate_tls (TLS_TPADJ (pd), false);
+
+ /* Free the stack memory regardless of whether the size
+ of the cache is over the limit or not. If this piece
+ of memory caused problems we better do not use it
+ anymore. Uh, and we ignore possible errors. There
+ is nothing we could do. */
+ (void) munmap (mem, size);
+
+ return err;
+ }
+
+ pd->guardsize = guardsize;
+ }
+ else if (__builtin_expect (pd->guardsize - guardsize > size - reqsize,
+ 0))
+ {
+ /* The old guard area is too large. */
+
+#ifdef NEED_SEPARATE_REGISTER_STACK
+ char *guard = mem + (((size - guardsize) / 2) & ~pagesize_m1);
+ char *oldguard = mem + (((size - pd->guardsize) / 2) & ~pagesize_m1);
+
+ if (oldguard < guard
+ && mprotect (oldguard, guard - oldguard, prot) != 0)
+ goto mprot_error;
+
+ if (mprotect (guard + guardsize,
+ oldguard + pd->guardsize - guard - guardsize,
+ prot) != 0)
+ goto mprot_error;
+#elif defined _STACK_GROWS_DOWN
+ if (mprotect ((char *) mem + guardsize, pd->guardsize - guardsize,
+ prot) != 0)
+ goto mprot_error;
+#elif defined _STACK_GROWS_UP
+ if (mprotect ((char *) (((uintptr_t) pd - pd->guardsize) & ~pagesize_m1),
+ pd->guardsize - guardsize, prot) != 0)
+ goto mprot_error;
+#endif
+
+ pd->guardsize = guardsize;
+ }
+ /* The pthread_getattr_np() calls need to get passed the size
+ requested in the attribute, regardless of how large the
+ actually used guardsize is. */
+ pd->reported_guardsize = guardsize;
+ }
+
+ /* Initialize the lock. We have to do this unconditionally since the
+ stillborn thread could be canceled while the lock is taken. */
+ pd->lock = LLL_LOCK_INITIALIZER;
+
+ /* The robust mutex lists also need to be initialized
+ unconditionally because the cleanup for the previous stack owner
+ might have happened in the kernel. */
+ pd->robust_head.futex_offset = (offsetof (pthread_mutex_t, __data.__lock)
+ - offsetof (pthread_mutex_t,
+ __data.__list.__next));
+ pd->robust_head.list_op_pending = NULL;
+#ifdef __PTHREAD_MUTEX_HAVE_PREV
+ pd->robust_prev = &pd->robust_head;
+#endif
+ pd->robust_head.list = &pd->robust_head;
+
+ /* We place the thread descriptor at the end of the stack. */
+ *pdp = pd;
+
+#if defined(TLS_TCB_AT_TP)
+ /* The stack begins before the TCB and the static TLS block. */
+ stacktop = ((char *) (pd + 1) - __static_tls_size);
+#elif defined(TLS_DTV_AT_TP)
+ stacktop = (char *) (pd - 1);
+#endif
+
+#ifdef NEED_SEPARATE_REGISTER_STACK
+ *stack = pd->stackblock;
+ *stacksize = stacktop - *stack;
+#elif defined _STACK_GROWS_DOWN
+ *stack = stacktop;
+#elif defined _STACK_GROWS_UP
+ *stack = pd->stackblock;
+ assert (*stack > 0);
+#endif
+
+ return 0;
+}
+
+
+void
+internal_function
+__deallocate_stack (struct pthread *pd)
+{
+ lll_lock (stack_cache_lock, LLL_PRIVATE);
+
+ /* Remove the thread from the list of threads with user defined
+ stacks. */
+ stack_list_del (&pd->list);
+
+ /* Not much to do. Just free the mmap()ed memory. Note that we do
+ not reset the 'used' flag in the 'tid' field. This is done by
+ the kernel. If no thread has been created yet this field is
+ still zero. */
+ if (__builtin_expect (! pd->user_stack, 1))
+ (void) queue_stack (pd);
+ else
+ /* Free the memory associated with the ELF TLS. */
+ _dl_deallocate_tls (TLS_TPADJ (pd), false);
+
+ lll_unlock (stack_cache_lock, LLL_PRIVATE);
+}
+
+
+int
+internal_function
+__make_stacks_executable (void **stack_endp)
+{
+ /* First the main thread's stack. */
+ int err = EPERM;
+ if (err != 0)
+ return err;
+
+#ifdef NEED_SEPARATE_REGISTER_STACK
+ const size_t pagemask = ~(__getpagesize () - 1);
+#endif
+
+ lll_lock (stack_cache_lock, LLL_PRIVATE);
+
+ list_t *runp;
+ list_for_each (runp, &stack_used)
+ {
+ err = change_stack_perm (list_entry (runp, struct pthread, list)
+#ifdef NEED_SEPARATE_REGISTER_STACK
+ , pagemask
+#endif
+ );
+ if (err != 0)
+ break;
+ }
+
+ /* Also change the permission for the currently unused stacks. This
+ might be wasted time but better spend it here than adding a check
+ in the fast path. */
+ if (err == 0)
+ list_for_each (runp, &stack_cache)
+ {
+ err = change_stack_perm (list_entry (runp, struct pthread, list)
+#ifdef NEED_SEPARATE_REGISTER_STACK
+ , pagemask
+#endif
+ );
+ if (err != 0)
+ break;
+ }
+
+ lll_unlock (stack_cache_lock, LLL_PRIVATE);
+
+ return err;
+}
+
+
+/* In case of a fork() call the memory allocation in the child will be
+ the same but only one thread is running. All stacks except that of
+ the one running thread are not used anymore. We have to recycle
+ them. */
+void
+__reclaim_stacks (void)
+{
+ struct pthread *self = (struct pthread *) THREAD_SELF;
+
+ /* No locking necessary. The caller is the only stack in use. But
+ we have to be aware that we might have interrupted a list
+ operation. */
+
+ if (in_flight_stack != 0)
+ {
+ bool add_p = in_flight_stack & 1;
+ list_t *elem = (list_t *)(uintptr_t)(in_flight_stack & ~UINTMAX_C (1));
+
+ if (add_p)
+ {
+ /* We always add at the beginning of the list. So in this
+ case we only need to check the beginning of these lists. */
+ int check_list (list_t *l)
+ {
+ if (l->next->prev != l)
+ {
+ assert (l->next->prev == elem);
+
+ elem->next = l->next;
+ elem->prev = l;
+ l->next = elem;
+
+ return 1;
+ }
+
+ return 0;
+ }
+
+ if (check_list (&stack_used) == 0)
+ (void) check_list (&stack_cache);
+ }
+ else
+ {
+ /* We can simply always replay the delete operation. */
+ elem->next->prev = elem->prev;
+ elem->prev->next = elem->next;
+ }
+ }
+
+ /* Mark all stacks except the still running one as free. */
+ list_t *runp;
+ list_for_each (runp, &stack_used)
+ {
+ struct pthread *curp = list_entry (runp, struct pthread, list);
+ if (curp != self)
+ {
+ /* This marks the stack as free. */
+ curp->tid = 0;
+
+ /* The PID field must be initialized for the new process. */
+ curp->pid = self->pid;
+
+ /* Account for the size of the stack. */
+ stack_cache_actsize += curp->stackblock_size;
+
+ if (curp->specific_used)
+ {
+ /* Clear the thread-specific data. */
+ memset (curp->specific_1stblock, '\0',
+ sizeof (curp->specific_1stblock));
+
+ curp->specific_used = false;
+
+ size_t cnt;
+ for (cnt = 1; cnt < PTHREAD_KEY_1STLEVEL_SIZE; ++cnt)
+ if (curp->specific[cnt] != NULL)
+ {
+ memset (curp->specific[cnt], '\0',
+ sizeof (curp->specific_1stblock));
+
+ /* We have allocated the block which we do not
+ free here so re-set the bit. */
+ curp->specific_used = true;
+ }
+ }
+ }
+ }
+
+ /* Reset the PIDs in any cached stacks. */
+ list_for_each (runp, &stack_cache)
+ {
+ struct pthread *curp = list_entry (runp, struct pthread, list);
+ curp->pid = self->pid;
+ }
+
+ /* Add the stack of all running threads to the cache. */
+ list_splice (&stack_used, &stack_cache);
+
+ /* Remove the entry for the current thread to from the cache list
+ and add it to the list of running threads. Which of the two
+ lists is decided by the user_stack flag. */
+ stack_list_del (&self->list);
+
+ /* Re-initialize the lists for all the threads. */
+ INIT_LIST_HEAD (&stack_used);
+ INIT_LIST_HEAD (&__stack_user);
+
+ if (__builtin_expect (THREAD_GETMEM (self, user_stack), 0))
+ list_add (&self->list, &__stack_user);
+ else
+ list_add (&self->list, &stack_used);
+
+ /* There is one thread running. */
+ __nptl_nthreads = 1;
+
+ in_flight_stack = 0;
+
+ /* Initialize the lock. */
+ stack_cache_lock = LLL_LOCK_INITIALIZER;
+}
+
+
+#if HP_TIMING_AVAIL
+# undef __find_thread_by_id
+/* Find a thread given the thread ID. */
+attribute_hidden
+struct pthread *
+__find_thread_by_id (pid_t tid)
+{
+ struct pthread *result = NULL;
+
+ lll_lock (stack_cache_lock, LLL_PRIVATE);
+
+ /* Iterate over the list with system-allocated threads first. */
+ list_t *runp;
+ list_for_each (runp, &stack_used)
+ {
+ struct pthread *curp;
+
+ curp = list_entry (runp, struct pthread, list);
+
+ if (curp->tid == tid)
+ {
+ result = curp;
+ goto out;
+ }
+ }
+
+ /* Now the list with threads using user-allocated stacks. */
+ list_for_each (runp, &__stack_user)
+ {
+ struct pthread *curp;
+
+ curp = list_entry (runp, struct pthread, list);
+
+ if (curp->tid == tid)
+ {
+ result = curp;
+ goto out;
+ }
+ }
+
+ out:
+ lll_unlock (stack_cache_lock, LLL_PRIVATE);
+
+ return result;
+}
+#endif
+
+
+static void
+internal_function
+setxid_mark_thread (struct xid_command *cmdp, struct pthread *t)
+{
+ int ch;
+
+ /* Don't let the thread exit before the setxid handler runs. */
+ t->setxid_futex = 0;
+
+ do
+ {
+ ch = t->cancelhandling;
+
+ /* If the thread is exiting right now, ignore it. */
+ if ((ch & EXITING_BITMASK) != 0)
+ return;
+ }
+ while (atomic_compare_and_exchange_bool_acq (&t->cancelhandling,
+ ch | SETXID_BITMASK, ch));
+}
+
+
+static void
+internal_function
+setxid_unmark_thread (struct xid_command *cmdp, struct pthread *t)
+{
+ int ch;
+
+ do
+ {
+ ch = t->cancelhandling;
+ if ((ch & SETXID_BITMASK) == 0)
+ return;
+ }
+ while (atomic_compare_and_exchange_bool_acq (&t->cancelhandling,
+ ch & ~SETXID_BITMASK, ch));
+
+ /* Release the futex just in case. */
+ t->setxid_futex = 1;
+ lll_futex_wake (&t->setxid_futex, 1, LLL_PRIVATE);
+}
+
+
+static int
+internal_function
+setxid_signal_thread (struct xid_command *cmdp, struct pthread *t)
+{
+ if ((t->cancelhandling & SETXID_BITMASK) == 0)
+ return 0;
+
+ int val;
+ INTERNAL_SYSCALL_DECL (err);
+#if defined (__ASSUME_TGKILL) && __ASSUME_TGKILL
+ val = INTERNAL_SYSCALL (tgkill, err, 3, THREAD_GETMEM (THREAD_SELF, pid),
+ t->tid, SIGSETXID);
+#else
+# ifdef __NR_tgkill
+ val = INTERNAL_SYSCALL (tgkill, err, 3, THREAD_GETMEM (THREAD_SELF, pid),
+ t->tid, SIGSETXID);
+ if (INTERNAL_SYSCALL_ERROR_P (val, err)
+ && INTERNAL_SYSCALL_ERRNO (val, err) == ENOSYS)
+# endif
+ val = INTERNAL_SYSCALL (tkill, err, 2, t->tid, SIGSETXID);
+#endif
+
+ /* If this failed, it must have had not started yet or else exited. */
+ if (!INTERNAL_SYSCALL_ERROR_P (val, err))
+ {
+ atomic_increment (&cmdp->cntr);
+ return 1;
+ }
+ else
+ return 0;
+}
+
+
+int
+attribute_hidden
+__nptl_setxid (struct xid_command *cmdp)
+{
+ int signalled;
+ int result;
+ lll_lock (stack_cache_lock, LLL_PRIVATE);
+
+ __xidcmd = cmdp;
+ cmdp->cntr = 0;
+
+ struct pthread *self = THREAD_SELF;
+
+ /* Iterate over the list with system-allocated threads first. */
+ list_t *runp;
+ list_for_each (runp, &stack_used)
+ {
+ struct pthread *t = list_entry (runp, struct pthread, list);
+ if (t == self)
+ continue;
+
+ setxid_mark_thread (cmdp, t);
+ }
+
+ /* Now the list with threads using user-allocated stacks. */
+ list_for_each (runp, &__stack_user)
+ {
+ struct pthread *t = list_entry (runp, struct pthread, list);
+ if (t == self)
+ continue;
+
+ setxid_mark_thread (cmdp, t);
+ }
+
+ /* Iterate until we don't succeed in signalling anyone. That means
+ we have gotten all running threads, and their children will be
+ automatically correct once started. */
+ do
+ {
+ signalled = 0;
+
+ list_for_each (runp, &stack_used)
+ {
+ struct pthread *t = list_entry (runp, struct pthread, list);
+ if (t == self)
+ continue;
+
+ signalled += setxid_signal_thread (cmdp, t);
+ }
+
+ list_for_each (runp, &__stack_user)
+ {
+ struct pthread *t = list_entry (runp, struct pthread, list);
+ if (t == self)
+ continue;
+
+ signalled += setxid_signal_thread (cmdp, t);
+ }
+
+ int cur = cmdp->cntr;
+ while (cur != 0)
+ {
+ lll_futex_wait (&cmdp->cntr, cur, LLL_PRIVATE);
+ cur = cmdp->cntr;
+ }
+ }
+ while (signalled != 0);
+
+ /* Clean up flags, so that no thread blocks during exit waiting
+ for a signal which will never come. */
+ list_for_each (runp, &stack_used)
+ {
+ struct pthread *t = list_entry (runp, struct pthread, list);
+ if (t == self)
+ continue;
+
+ setxid_unmark_thread (cmdp, t);
+ }
+
+ list_for_each (runp, &__stack_user)
+ {
+ struct pthread *t = list_entry (runp, struct pthread, list);
+ if (t == self)
+ continue;
+
+ setxid_unmark_thread (cmdp, t);
+ }
+
+ /* This must be last, otherwise the current thread might not have
+ permissions to send SIGSETXID syscall to the other threads. */
+ INTERNAL_SYSCALL_DECL (err);
+ result = INTERNAL_SYSCALL_NCS (cmdp->syscall_no, err, 3,
+ cmdp->id[0], cmdp->id[1], cmdp->id[2]);
+ if (INTERNAL_SYSCALL_ERROR_P (result, err))
+ {
+ __set_errno (INTERNAL_SYSCALL_ERRNO (result, err));
+ result = -1;
+ }
+
+ lll_unlock (stack_cache_lock, LLL_PRIVATE);
+ return result;
+}
+
+static inline void __attribute__((always_inline))
+init_one_static_tls (struct pthread *curp, struct link_map *map)
+{
+ dtv_t *dtv = GET_DTV (TLS_TPADJ (curp));
+# if defined(TLS_TCB_AT_TP)
+ void *dest = (char *) curp - map->l_tls_offset;
+# elif defined(TLS_DTV_AT_TP)
+ void *dest = (char *) curp + map->l_tls_offset + TLS_PRE_TCB_SIZE;
+# else
+# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
+# endif
+
+ /* Fill in the DTV slot so that a later LD/GD access will find it. */
+ dtv[map->l_tls_modid].pointer.val = dest;
+ dtv[map->l_tls_modid].pointer.is_static = true;
+
+ /* Initialize the memory. */
+ memset (mempcpy (dest, map->l_tls_initimage, map->l_tls_initimage_size),
+ '\0', map->l_tls_blocksize - map->l_tls_initimage_size);
+}
+
+void
+attribute_hidden
+__pthread_init_static_tls (struct link_map *map)
+{
+ lll_lock (stack_cache_lock, LLL_PRIVATE);
+
+ /* Iterate over the list with system-allocated threads first. */
+ list_t *runp;
+ list_for_each (runp, &stack_used)
+ init_one_static_tls (list_entry (runp, struct pthread, list), map);
+
+ /* Now the list with threads using user-allocated stacks. */
+ list_for_each (runp, &__stack_user)
+ init_one_static_tls (list_entry (runp, struct pthread, list), map);
+
+ lll_unlock (stack_cache_lock, LLL_PRIVATE);
+}
+
+
+void
+attribute_hidden
+__wait_lookup_done (void)
+{
+ lll_lock (stack_cache_lock, LLL_PRIVATE);
+
+ struct pthread *self = THREAD_SELF;
+
+ /* Iterate over the list with system-allocated threads first. */
+ list_t *runp;
+ list_for_each (runp, &stack_used)
+ {
+ struct pthread *t = list_entry (runp, struct pthread, list);
+ if (t == self || t->header.gscope_flag == THREAD_GSCOPE_FLAG_UNUSED)
+ continue;
+
+ int *const gscope_flagp = &t->header.gscope_flag;
+
+ /* We have to wait until this thread is done with the global
+ scope. First tell the thread that we are waiting and
+ possibly have to be woken. */
+ if (atomic_compare_and_exchange_bool_acq (gscope_flagp,
+ THREAD_GSCOPE_FLAG_WAIT,
+ THREAD_GSCOPE_FLAG_USED))
+ continue;
+
+ do
+ lll_futex_wait (gscope_flagp, THREAD_GSCOPE_FLAG_WAIT, LLL_PRIVATE);
+ while (*gscope_flagp == THREAD_GSCOPE_FLAG_WAIT);
+ }
+
+ /* Now the list with threads using user-allocated stacks. */
+ list_for_each (runp, &__stack_user)
+ {
+ struct pthread *t = list_entry (runp, struct pthread, list);
+ if (t == self || t->header.gscope_flag == THREAD_GSCOPE_FLAG_UNUSED)
+ continue;
+
+ int *const gscope_flagp = &t->header.gscope_flag;
+
+ /* We have to wait until this thread is done with the global
+ scope. First tell the thread that we are waiting and
+ possibly have to be woken. */
+ if (atomic_compare_and_exchange_bool_acq (gscope_flagp,
+ THREAD_GSCOPE_FLAG_WAIT,
+ THREAD_GSCOPE_FLAG_USED))
+ continue;
+
+ do
+ lll_futex_wait (gscope_flagp, THREAD_GSCOPE_FLAG_WAIT, LLL_PRIVATE);
+ while (*gscope_flagp == THREAD_GSCOPE_FLAG_WAIT);
+ }
+
+ lll_unlock (stack_cache_lock, LLL_PRIVATE);
+}
diff --git a/libpthread/nptl/banner.h b/libpthread/nptl/banner.h
new file mode 100644
index 000000000..9982f4287
--- /dev/null
+++ b/libpthread/nptl/banner.h
@@ -0,0 +1 @@
+"Native POSIX Threads Library by Ulrich Drepper et al, uClibc port by Steven Hill\n"
diff --git a/libpthread/nptl/cancellation.c b/libpthread/nptl/cancellation.c
new file mode 100644
index 000000000..c908262f9
--- /dev/null
+++ b/libpthread/nptl/cancellation.c
@@ -0,0 +1,99 @@
+/* Copyright (C) 2002, 2003, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <setjmp.h>
+#include <stdlib.h>
+#include "pthreadP.h"
+
+
+/* The next two functions are similar to pthread_setcanceltype() but
+ more specialized for the use in the cancelable functions like write().
+ They do not need to check parameters etc. */
+int
+attribute_hidden
+__pthread_enable_asynccancel (void)
+{
+ struct pthread *self = THREAD_SELF;
+ int oldval = THREAD_GETMEM (self, cancelhandling);
+
+ while (1)
+ {
+ int newval = oldval | CANCELTYPE_BITMASK;
+
+ if (newval == oldval)
+ break;
+
+ int curval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling, newval,
+ oldval);
+ if (__builtin_expect (curval == oldval, 1))
+ {
+ if (CANCEL_ENABLED_AND_CANCELED_AND_ASYNCHRONOUS (newval))
+ {
+ THREAD_SETMEM (self, result, PTHREAD_CANCELED);
+ __do_cancel ();
+ }
+
+ break;
+ }
+
+ /* Prepare the next round. */
+ oldval = curval;
+ }
+
+ return oldval;
+}
+
+
+void
+internal_function attribute_hidden
+__pthread_disable_asynccancel (int oldtype)
+{
+ /* If asynchronous cancellation was enabled before we do not have
+ anything to do. */
+ if (oldtype & CANCELTYPE_BITMASK)
+ return;
+
+ struct pthread *self = THREAD_SELF;
+ int newval;
+
+ int oldval = THREAD_GETMEM (self, cancelhandling);
+
+ while (1)
+ {
+ newval = oldval & ~CANCELTYPE_BITMASK;
+
+ int curval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling, newval,
+ oldval);
+ if (__builtin_expect (curval == oldval, 1))
+ break;
+
+ /* Prepare the next round. */
+ oldval = curval;
+ }
+
+ /* We cannot return when we are being canceled. Upon return the
+ thread might be things which would have to be undone. The
+ following loop should loop until the cancellation signal is
+ delivered. */
+ while (__builtin_expect ((newval & (CANCELING_BITMASK | CANCELED_BITMASK))
+ == CANCELING_BITMASK, 0))
+ {
+ lll_futex_wait (&self->cancelhandling, newval, LLL_PRIVATE);
+ newval = THREAD_GETMEM (self, cancelhandling);
+ }
+}
diff --git a/libpthread/nptl/cleanup.c b/libpthread/nptl/cleanup.c
new file mode 100644
index 000000000..2092200f7
--- /dev/null
+++ b/libpthread/nptl/cleanup.c
@@ -0,0 +1,48 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <stdlib.h>
+#include "pthreadP.h"
+
+
+void
+__cleanup_fct_attribute
+__pthread_register_cancel (__pthread_unwind_buf_t *buf)
+{
+ struct pthread_unwind_buf *ibuf = (struct pthread_unwind_buf *) buf;
+ struct pthread *self = THREAD_SELF;
+
+ /* Store old info. */
+ ibuf->priv.data.prev = THREAD_GETMEM (self, cleanup_jmp_buf);
+ ibuf->priv.data.cleanup = THREAD_GETMEM (self, cleanup);
+
+ /* Store the new cleanup handler info. */
+ THREAD_SETMEM (self, cleanup_jmp_buf, (struct pthread_unwind_buf *) buf);
+}
+hidden_def (__pthread_register_cancel)
+
+
+void
+__cleanup_fct_attribute
+__pthread_unregister_cancel (__pthread_unwind_buf_t *buf)
+{
+ struct pthread_unwind_buf *ibuf = (struct pthread_unwind_buf *) buf;
+
+ THREAD_SETMEM (THREAD_SELF, cleanup_jmp_buf, ibuf->priv.data.prev);
+}
+hidden_def (__pthread_unregister_cancel)
diff --git a/libpthread/nptl/cleanup_compat.c b/libpthread/nptl/cleanup_compat.c
new file mode 100644
index 000000000..21eac5971
--- /dev/null
+++ b/libpthread/nptl/cleanup_compat.c
@@ -0,0 +1,54 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <stdlib.h>
+#include "pthreadP.h"
+
+
+void
+_pthread_cleanup_push (
+ struct _pthread_cleanup_buffer *buffer,
+ void (*routine) (void *),
+ void *arg)
+{
+ struct pthread *self = THREAD_SELF;
+
+ buffer->__routine = routine;
+ buffer->__arg = arg;
+ buffer->__prev = THREAD_GETMEM (self, cleanup);
+
+ THREAD_SETMEM (self, cleanup, buffer);
+}
+strong_alias (_pthread_cleanup_push, __pthread_cleanup_push)
+
+
+void
+_pthread_cleanup_pop (
+ struct _pthread_cleanup_buffer *buffer,
+ int execute)
+{
+ struct pthread *self __attribute ((unused)) = THREAD_SELF;
+
+ THREAD_SETMEM (self, cleanup, buffer->__prev);
+
+ /* If necessary call the cleanup routine after we removed the
+ current cleanup block from the list. */
+ if (execute)
+ buffer->__routine (buffer->__arg);
+}
+strong_alias (_pthread_cleanup_pop, __pthread_cleanup_pop)
diff --git a/libpthread/nptl/cleanup_defer.c b/libpthread/nptl/cleanup_defer.c
new file mode 100644
index 000000000..4a228d458
--- /dev/null
+++ b/libpthread/nptl/cleanup_defer.c
@@ -0,0 +1,91 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <stdlib.h>
+#include "pthreadP.h"
+
+
+void
+__cleanup_fct_attribute
+__pthread_register_cancel_defer (__pthread_unwind_buf_t *buf)
+{
+ struct pthread_unwind_buf *ibuf = (struct pthread_unwind_buf *) buf;
+ struct pthread *self = THREAD_SELF;
+
+ /* Store old info. */
+ ibuf->priv.data.prev = THREAD_GETMEM (self, cleanup_jmp_buf);
+ ibuf->priv.data.cleanup = THREAD_GETMEM (self, cleanup);
+
+ int cancelhandling = THREAD_GETMEM (self, cancelhandling);
+
+ /* Disable asynchronous cancellation for now. */
+ if (__builtin_expect (cancelhandling & CANCELTYPE_BITMASK, 0))
+ while (1)
+ {
+ int curval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling,
+ cancelhandling
+ & ~CANCELTYPE_BITMASK,
+ cancelhandling);
+ if (__builtin_expect (curval == cancelhandling, 1))
+ /* Successfully replaced the value. */
+ break;
+
+ /* Prepare for the next round. */
+ cancelhandling = curval;
+ }
+
+ ibuf->priv.data.canceltype = (cancelhandling & CANCELTYPE_BITMASK
+ ? PTHREAD_CANCEL_ASYNCHRONOUS
+ : PTHREAD_CANCEL_DEFERRED);
+
+ /* Store the new cleanup handler info. */
+ THREAD_SETMEM (self, cleanup_jmp_buf, (struct pthread_unwind_buf *) buf);
+}
+
+
+void
+__cleanup_fct_attribute
+__pthread_unregister_cancel_restore (__pthread_unwind_buf_t *buf)
+{
+ struct pthread *self = THREAD_SELF;
+ struct pthread_unwind_buf *ibuf = (struct pthread_unwind_buf *) buf;
+
+ THREAD_SETMEM (self, cleanup_jmp_buf, ibuf->priv.data.prev);
+
+ int cancelhandling;
+ if (ibuf->priv.data.canceltype != PTHREAD_CANCEL_DEFERRED
+ && ((cancelhandling = THREAD_GETMEM (self, cancelhandling))
+ & CANCELTYPE_BITMASK) == 0)
+ {
+ while (1)
+ {
+ int curval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling,
+ cancelhandling
+ | CANCELTYPE_BITMASK,
+ cancelhandling);
+ if (__builtin_expect (curval == cancelhandling, 1))
+ /* Successfully replaced the value. */
+ break;
+
+ /* Prepare for the next round. */
+ cancelhandling = curval;
+ }
+
+ CANCELLATION_P (self);
+ }
+}
diff --git a/libpthread/nptl/cleanup_defer_compat.c b/libpthread/nptl/cleanup_defer_compat.c
new file mode 100644
index 000000000..ba15c7983
--- /dev/null
+++ b/libpthread/nptl/cleanup_defer_compat.c
@@ -0,0 +1,99 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 "pthreadP.h"
+
+
+void
+attribute_protected
+__pthread_cleanup_push_defer (
+ struct _pthread_cleanup_buffer *buffer,
+ void (*routine) (void *),
+ void *arg)
+{
+ struct pthread *self = THREAD_SELF;
+
+ buffer->__routine = routine;
+ buffer->__arg = arg;
+ buffer->__prev = THREAD_GETMEM (self, cleanup);
+
+ int cancelhandling = THREAD_GETMEM (self, cancelhandling);
+
+ /* Disable asynchronous cancellation for now. */
+ if (__builtin_expect (cancelhandling & CANCELTYPE_BITMASK, 0))
+ while (1)
+ {
+ int curval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling,
+ cancelhandling
+ & ~CANCELTYPE_BITMASK,
+ cancelhandling);
+ if (__builtin_expect (curval == cancelhandling, 1))
+ /* Successfully replaced the value. */
+ break;
+
+ /* Prepare for the next round. */
+ cancelhandling = curval;
+ }
+
+ buffer->__canceltype = (cancelhandling & CANCELTYPE_BITMASK
+ ? PTHREAD_CANCEL_ASYNCHRONOUS
+ : PTHREAD_CANCEL_DEFERRED);
+
+ THREAD_SETMEM (self, cleanup, buffer);
+}
+strong_alias (__pthread_cleanup_push_defer, _pthread_cleanup_push_defer)
+
+
+void
+attribute_protected
+__pthread_cleanup_pop_restore (
+ struct _pthread_cleanup_buffer *buffer,
+ int execute)
+{
+ struct pthread *self = THREAD_SELF;
+
+ THREAD_SETMEM (self, cleanup, buffer->__prev);
+
+ int cancelhandling;
+ if (__builtin_expect (buffer->__canceltype != PTHREAD_CANCEL_DEFERRED, 0)
+ && ((cancelhandling = THREAD_GETMEM (self, cancelhandling))
+ & CANCELTYPE_BITMASK) == 0)
+ {
+ while (1)
+ {
+ int curval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling,
+ cancelhandling
+ | CANCELTYPE_BITMASK,
+ cancelhandling);
+ if (__builtin_expect (curval == cancelhandling, 1))
+ /* Successfully replaced the value. */
+ break;
+
+ /* Prepare for the next round. */
+ cancelhandling = curval;
+ }
+
+ CANCELLATION_P (self);
+ }
+
+ /* If necessary call the cleanup routine after we removed the
+ current cleanup block from the list. */
+ if (execute)
+ buffer->__routine (buffer->__arg);
+}
+strong_alias (__pthread_cleanup_pop_restore, _pthread_cleanup_pop_restore)
diff --git a/libpthread/nptl/cleanup_routine.c b/libpthread/nptl/cleanup_routine.c
new file mode 100644
index 000000000..8cd562955
--- /dev/null
+++ b/libpthread/nptl/cleanup_routine.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 2003 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 <pthread.h>
+
+void __pthread_cleanup_routine (struct __pthread_cleanup_frame *f);
+void
+__pthread_cleanup_routine (struct __pthread_cleanup_frame *f)
+{
+ if (f->__do_it)
+ f->__cancel_routine (f->__cancel_arg);
+}
diff --git a/libpthread/nptl/descr.h b/libpthread/nptl/descr.h
new file mode 100644
index 000000000..3fda681b8
--- /dev/null
+++ b/libpthread/nptl/descr.h
@@ -0,0 +1,376 @@
+/* Copyright (C) 2002-2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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/>. */
+
+#ifndef _DESCR_H
+#define _DESCR_H 1
+
+#include <limits.h>
+#include <sched.h>
+#include <setjmp.h>
+#include <stdbool.h>
+#include <sys/types.h>
+#include <hp-timing.h>
+#include <list.h>
+#include <lowlevellock.h>
+#include <pthreaddef.h>
+#include "../nptl_db/thread_db.h"
+#include <tls.h>
+#ifdef HAVE_FORCED_UNWIND
+# include <unwind.h>
+#endif
+#define __need_res_state
+#include <resolv.h>
+#include <bits/kernel-features.h>
+#include "uClibc-glue.h"
+
+#ifndef TCB_ALIGNMENT
+# define TCB_ALIGNMENT sizeof (double)
+#endif
+
+
+/* We keep thread specific data in a special data structure, a two-level
+ array. The top-level array contains pointers to dynamically allocated
+ arrays of a certain number of data pointers. So we can implement a
+ sparse array. Each dynamic second-level array has
+ PTHREAD_KEY_2NDLEVEL_SIZE
+ entries. This value shouldn't be too large. */
+#define PTHREAD_KEY_2NDLEVEL_SIZE 32
+
+/* We need to address PTHREAD_KEYS_MAX key with PTHREAD_KEY_2NDLEVEL_SIZE
+ keys in each subarray. */
+#define PTHREAD_KEY_1STLEVEL_SIZE \
+ ((PTHREAD_KEYS_MAX + PTHREAD_KEY_2NDLEVEL_SIZE - 1) \
+ / PTHREAD_KEY_2NDLEVEL_SIZE)
+
+
+
+
+/* Internal version of the buffer to store cancellation handler
+ information. */
+struct pthread_unwind_buf
+{
+ struct
+ {
+ __jmp_buf jmp_buf;
+ int mask_was_saved;
+ } cancel_jmp_buf[1];
+
+ union
+ {
+ /* This is the placeholder of the public version. */
+ void *pad[4];
+
+ struct
+ {
+ /* Pointer to the previous cleanup buffer. */
+ struct pthread_unwind_buf *prev;
+
+ /* Backward compatibility: state of the old-style cleanup
+ handler at the time of the previous new-style cleanup handler
+ installment. */
+ struct _pthread_cleanup_buffer *cleanup;
+
+ /* Cancellation type before the push call. */
+ int canceltype;
+ } data;
+ } priv;
+};
+
+
+/* Opcodes and data types for communication with the signal handler to
+ change user/group IDs. */
+struct xid_command
+{
+ int syscall_no;
+ long int id[3];
+ volatile int cntr;
+};
+
+
+/* Data structure used by the kernel to find robust futexes. */
+struct robust_list_head
+{
+ void *list;
+ long int futex_offset;
+ void *list_op_pending;
+};
+
+
+/* Data strcture used to handle thread priority protection. */
+struct priority_protection_data
+{
+ int priomax;
+ unsigned int priomap[];
+};
+
+
+/* Thread descriptor data structure. */
+struct pthread
+{
+ union
+ {
+#if !defined(TLS_DTV_AT_TP)
+ /* This overlaps the TCB as used for TLS without threads (see tls.h). */
+ tcbhead_t header;
+#else
+ struct
+ {
+ int multiple_threads;
+ int gscope_flag;
+# ifndef __ASSUME_PRIVATE_FUTEX
+ int private_futex;
+# endif
+ } header;
+#endif
+
+ /* This extra padding has no special purpose, and this structure layout
+ is private and subject to change without affecting the official ABI.
+ We just have it here in case it might be convenient for some
+ implementation-specific instrumentation hack or suchlike. */
+ void *__padding[24];
+ };
+
+ /* This descriptor's link on the `stack_used' or `__stack_user' list. */
+ list_t list;
+
+ /* Thread ID - which is also a 'is this thread descriptor (and
+ therefore stack) used' flag. */
+ pid_t tid;
+
+ /* Process ID - thread group ID in kernel speak. */
+ pid_t pid;
+
+ /* List of robust mutexes the thread is holding. */
+#ifdef __PTHREAD_MUTEX_HAVE_PREV
+ void *robust_prev;
+ struct robust_list_head robust_head;
+
+ /* The list above is strange. It is basically a double linked list
+ but the pointer to the next/previous element of the list points
+ in the middle of the object, the __next element. Whenever
+ casting to __pthread_list_t we need to adjust the pointer
+ first. */
+# define QUEUE_PTR_ADJUST (offsetof (__pthread_list_t, __next))
+
+# define ENQUEUE_MUTEX_BOTH(mutex, val) \
+ do { \
+ __pthread_list_t *next = (__pthread_list_t *) \
+ ((((uintptr_t) THREAD_GETMEM (THREAD_SELF, robust_head.list)) & ~1ul) \
+ - QUEUE_PTR_ADJUST); \
+ next->__prev = (void *) &mutex->__data.__list.__next; \
+ mutex->__data.__list.__next = THREAD_GETMEM (THREAD_SELF, \
+ robust_head.list); \
+ mutex->__data.__list.__prev = (void *) &THREAD_SELF->robust_head; \
+ THREAD_SETMEM (THREAD_SELF, robust_head.list, \
+ (void *) (((uintptr_t) &mutex->__data.__list.__next) \
+ | val)); \
+ } while (0)
+# define DEQUEUE_MUTEX(mutex) \
+ do { \
+ __pthread_list_t *next = (__pthread_list_t *) \
+ ((char *) (((uintptr_t) mutex->__data.__list.__next) & ~1ul) \
+ - QUEUE_PTR_ADJUST); \
+ next->__prev = mutex->__data.__list.__prev; \
+ __pthread_list_t *prev = (__pthread_list_t *) \
+ ((char *) (((uintptr_t) mutex->__data.__list.__prev) & ~1ul) \
+ - QUEUE_PTR_ADJUST); \
+ prev->__next = mutex->__data.__list.__next; \
+ mutex->__data.__list.__prev = NULL; \
+ mutex->__data.__list.__next = NULL; \
+ } while (0)
+#else
+ union
+ {
+ __pthread_slist_t robust_list;
+ struct robust_list_head robust_head;
+ };
+
+# define ENQUEUE_MUTEX_BOTH(mutex, val) \
+ do { \
+ mutex->__data.__list.__next \
+ = THREAD_GETMEM (THREAD_SELF, robust_list.__next); \
+ THREAD_SETMEM (THREAD_SELF, robust_list.__next, \
+ (void *) (((uintptr_t) &mutex->__data.__list) | val)); \
+ } while (0)
+# define DEQUEUE_MUTEX(mutex) \
+ do { \
+ __pthread_slist_t *runp = (__pthread_slist_t *) \
+ (((uintptr_t) THREAD_GETMEM (THREAD_SELF, robust_list.__next)) & ~1ul); \
+ if (runp == &mutex->__data.__list) \
+ THREAD_SETMEM (THREAD_SELF, robust_list.__next, runp->__next); \
+ else \
+ { \
+ __pthread_slist_t *next = (__pthread_slist_t *) \
+ (((uintptr_t) runp->__next) & ~1ul); \
+ while (next != &mutex->__data.__list) \
+ { \
+ runp = next; \
+ next = (__pthread_slist_t *) (((uintptr_t) runp->__next) & ~1ul); \
+ } \
+ \
+ runp->__next = next->__next; \
+ mutex->__data.__list.__next = NULL; \
+ } \
+ } while (0)
+#endif
+#define ENQUEUE_MUTEX(mutex) ENQUEUE_MUTEX_BOTH (mutex, 0)
+#define ENQUEUE_MUTEX_PI(mutex) ENQUEUE_MUTEX_BOTH (mutex, 1)
+
+ /* List of cleanup buffers. */
+ struct _pthread_cleanup_buffer *cleanup;
+
+ /* Unwind information. */
+ struct pthread_unwind_buf *cleanup_jmp_buf;
+#define HAVE_CLEANUP_JMP_BUF
+
+ /* Flags determining processing of cancellation. */
+ int cancelhandling;
+ /* Bit set if cancellation is disabled. */
+#define CANCELSTATE_BIT 0
+#define CANCELSTATE_BITMASK (0x01 << CANCELSTATE_BIT)
+ /* Bit set if asynchronous cancellation mode is selected. */
+#define CANCELTYPE_BIT 1
+#define CANCELTYPE_BITMASK (0x01 << CANCELTYPE_BIT)
+ /* Bit set if canceling has been initiated. */
+#define CANCELING_BIT 2
+#define CANCELING_BITMASK (0x01 << CANCELING_BIT)
+ /* Bit set if canceled. */
+#define CANCELED_BIT 3
+#define CANCELED_BITMASK (0x01 << CANCELED_BIT)
+ /* Bit set if thread is exiting. */
+#define EXITING_BIT 4
+#define EXITING_BITMASK (0x01 << EXITING_BIT)
+ /* Bit set if thread terminated and TCB is freed. */
+#define TERMINATED_BIT 5
+#define TERMINATED_BITMASK (0x01 << TERMINATED_BIT)
+ /* Bit set if thread is supposed to change XID. */
+#define SETXID_BIT 6
+#define SETXID_BITMASK (0x01 << SETXID_BIT)
+ /* Mask for the rest. Helps the compiler to optimize. */
+#define CANCEL_RESTMASK 0xffffff80
+
+#define CANCEL_ENABLED_AND_CANCELED(value) \
+ (((value) & (CANCELSTATE_BITMASK | CANCELED_BITMASK | EXITING_BITMASK \
+ | CANCEL_RESTMASK | TERMINATED_BITMASK)) == CANCELED_BITMASK)
+#define CANCEL_ENABLED_AND_CANCELED_AND_ASYNCHRONOUS(value) \
+ (((value) & (CANCELSTATE_BITMASK | CANCELTYPE_BITMASK | CANCELED_BITMASK \
+ | EXITING_BITMASK | CANCEL_RESTMASK | TERMINATED_BITMASK)) \
+ == (CANCELTYPE_BITMASK | CANCELED_BITMASK))
+
+ /* Flags. Including those copied from the thread attribute. */
+ int flags;
+
+ /* We allocate one block of references here. This should be enough
+ to avoid allocating any memory dynamically for most applications. */
+ struct pthread_key_data
+ {
+ /* Sequence number. We use uintptr_t to not require padding on
+ 32- and 64-bit machines. On 64-bit machines it helps to avoid
+ wrapping, too. */
+ uintptr_t seq;
+
+ /* Data pointer. */
+ void *data;
+ } specific_1stblock[PTHREAD_KEY_2NDLEVEL_SIZE];
+
+ /* Two-level array for the thread-specific data. */
+ struct pthread_key_data *specific[PTHREAD_KEY_1STLEVEL_SIZE];
+
+ /* Flag which is set when specific data is set. */
+ bool specific_used;
+
+ /* True if events must be reported. */
+ bool report_events;
+
+ /* True if the user provided the stack. */
+ bool user_stack;
+
+ /* True if thread must stop at startup time. */
+ bool stopped_start;
+
+ /* The parent's cancel handling at the time of the pthread_create
+ call. This might be needed to undo the effects of a cancellation. */
+ int parent_cancelhandling;
+
+ /* Lock to synchronize access to the descriptor. */
+ int lock;
+
+ /* Lock for synchronizing setxid calls. */
+ int setxid_futex;
+
+#if HP_TIMING_AVAIL
+ /* Offset of the CPU clock at start thread start time. */
+ hp_timing_t cpuclock_offset;
+#endif
+
+ /* If the thread waits to join another one the ID of the latter is
+ stored here.
+
+ In case a thread is detached this field contains a pointer of the
+ TCB if the thread itself. This is something which cannot happen
+ in normal operation. */
+ struct pthread *joinid;
+ /* Check whether a thread is detached. */
+#define IS_DETACHED(pd) ((pd)->joinid == (pd))
+
+ /* The result of the thread function. */
+ void *result;
+
+ /* Scheduling parameters for the new thread. */
+ struct sched_param schedparam;
+ int schedpolicy;
+
+ /* Start position of the code to be executed and the argument passed
+ to the function. */
+ void *(*start_routine) (void *);
+ void *arg;
+
+ /* Debug state. */
+ td_eventbuf_t eventbuf;
+ /* Next descriptor with a pending event. */
+ struct pthread *nextevent;
+
+#ifdef HAVE_FORCED_UNWIND
+ /* Machine-specific unwind info. */
+ struct _Unwind_Exception exc;
+#endif
+
+ /* If nonzero pointer to area allocated for the stack and its
+ size. */
+ void *stackblock;
+ size_t stackblock_size;
+ /* Size of the included guard area. */
+ size_t guardsize;
+ /* This is what the user specified and what we will report. */
+ size_t reported_guardsize;
+
+ /* Thread Priority Protection data. */
+ struct priority_protection_data *tpp;
+
+ /* Resolver state. */
+ struct __res_state res;
+
+ /* This member must be last. */
+ char end_padding[];
+
+#define PTHREAD_STRUCT_END_PADDING \
+ (sizeof (struct pthread) - offsetof (struct pthread, end_padding))
+} __attribute ((aligned (TCB_ALIGNMENT)));
+
+
+#endif /* descr.h */
diff --git a/libpthread/nptl/errno_location.c b/libpthread/nptl/errno_location.c
new file mode 100644
index 000000000..74589389b
--- /dev/null
+++ b/libpthread/nptl/errno_location.c
@@ -0,0 +1 @@
+#include <libc/misc/internals/__errno_location.c>
diff --git a/libpthread/nptl/events.c b/libpthread/nptl/events.c
new file mode 100644
index 000000000..d75b8e659
--- /dev/null
+++ b/libpthread/nptl/events.c
@@ -0,0 +1,33 @@
+/* Event functions used while debugging.
+ Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ 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 functions contained here do nothing, they just return. */
+
+#include "pthreadP.h"
+
+void
+__nptl_create_event (void)
+{
+}
+hidden_def (__nptl_create_event)
+
+void
+__nptl_death_event (void)
+{
+}
+hidden_def (__nptl_death_event)
diff --git a/libpthread/nptl/forward.c b/libpthread/nptl/forward.c
new file mode 100644
index 000000000..076d43711
--- /dev/null
+++ b/libpthread/nptl/forward.c
@@ -0,0 +1,169 @@
+/* Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <dlfcn.h>
+#include <pthreadP.h>
+#include <signal.h>
+#include <stdlib.h>
+
+#include <atomic.h>
+#include <sysdep.h>
+
+
+/* Pointers to the libc functions. */
+struct pthread_functions __libc_pthread_functions attribute_hidden;
+int __libc_pthread_functions_init attribute_hidden;
+
+
+#define FORWARD2(name, rettype, decl, params, defaction) \
+rettype \
+name decl \
+{ \
+ if (!__libc_pthread_functions_init) { \
+ defaction; \
+ } else { \
+ return PTHFCT_CALL (ptr_##name, params); \
+ } \
+}
+
+#define FORWARD(name, decl, params, defretval) \
+ FORWARD2 (name, int, decl, params, return defretval)
+
+
+FORWARD (pthread_attr_destroy, (pthread_attr_t *attr), (attr), 0)
+
+FORWARD (__pthread_attr_init_2_1, (pthread_attr_t *attr), (attr), 0)
+weak_alias(__pthread_attr_init_2_1, pthread_attr_init)
+
+FORWARD (pthread_attr_getdetachstate,
+ (const pthread_attr_t *attr, int *detachstate), (attr, detachstate),
+ 0)
+FORWARD (pthread_attr_setdetachstate, (pthread_attr_t *attr, int detachstate),
+ (attr, detachstate), 0)
+
+FORWARD (pthread_attr_getinheritsched,
+ (const pthread_attr_t *attr, int *inherit), (attr, inherit), 0)
+FORWARD (pthread_attr_setinheritsched, (pthread_attr_t *attr, int inherit),
+ (attr, inherit), 0)
+
+FORWARD (pthread_attr_getschedparam,
+ (const pthread_attr_t *attr, struct sched_param *param),
+ (attr, param), 0)
+FORWARD (pthread_attr_setschedparam,
+ (pthread_attr_t *attr, const struct sched_param *param),
+ (attr, param), 0)
+
+FORWARD (pthread_attr_getschedpolicy,
+ (const pthread_attr_t *attr, int *policy), (attr, policy), 0)
+FORWARD (pthread_attr_setschedpolicy, (pthread_attr_t *attr, int policy),
+ (attr, policy), 0)
+
+FORWARD (pthread_attr_getscope,
+ (const pthread_attr_t *attr, int *scope), (attr, scope), 0)
+FORWARD (pthread_attr_setscope, (pthread_attr_t *attr, int scope),
+ (attr, scope), 0)
+
+
+FORWARD (pthread_condattr_destroy, (pthread_condattr_t *attr), (attr), 0)
+FORWARD (pthread_condattr_init, (pthread_condattr_t *attr), (attr), 0)
+
+FORWARD (__pthread_cond_broadcast, (pthread_cond_t *cond), (cond), 0)
+weak_alias(__pthread_cond_broadcast, pthread_cond_broadcast)
+
+FORWARD (__pthread_cond_destroy, (pthread_cond_t *cond), (cond), 0)
+weak_alias(__pthread_cond_destroy, pthread_cond_destroy)
+
+FORWARD (__pthread_cond_init,
+ (pthread_cond_t *cond, const pthread_condattr_t *cond_attr),
+ (cond, cond_attr), 0)
+weak_alias(__pthread_cond_init, pthread_cond_init)
+
+FORWARD (__pthread_cond_signal, (pthread_cond_t *cond), (cond), 0)
+weak_alias(__pthread_cond_signal, pthread_cond_signal)
+
+FORWARD (__pthread_cond_wait, (pthread_cond_t *cond, pthread_mutex_t *mutex),
+ (cond, mutex), 0)
+weak_alias(__pthread_cond_wait, pthread_cond_wait)
+
+FORWARD (__pthread_cond_timedwait,
+ (pthread_cond_t *cond, pthread_mutex_t *mutex,
+ const struct timespec *abstime), (cond, mutex, abstime), 0)
+weak_alias(__pthread_cond_timedwait, pthread_cond_timedwait)
+
+
+FORWARD (pthread_equal, (pthread_t thread1, pthread_t thread2),
+ (thread1, thread2), 1)
+
+
+/* Use an alias to avoid warning, as pthread_exit is declared noreturn. */
+FORWARD2 (__pthread_exit, void, (void *retval), (retval), exit (EXIT_SUCCESS))
+strong_alias (__pthread_exit, pthread_exit);
+
+
+FORWARD (pthread_getschedparam,
+ (pthread_t target_thread, int *policy, struct sched_param *param),
+ (target_thread, policy, param), 0)
+FORWARD (pthread_setschedparam,
+ (pthread_t target_thread, int policy,
+ const struct sched_param *param), (target_thread, policy, param), 0)
+
+
+FORWARD (pthread_mutex_destroy, (pthread_mutex_t *mutex), (mutex), 0)
+
+FORWARD (pthread_mutex_init,
+ (pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr),
+ (mutex, mutexattr), 0)
+
+FORWARD (pthread_mutex_lock, (pthread_mutex_t *mutex), (mutex), 0)
+weak_alias (pthread_mutex_lock, __pthread_mutex_lock)
+
+FORWARD (pthread_mutex_unlock, (pthread_mutex_t *mutex), (mutex), 0)
+weak_alias (pthread_mutex_unlock, __pthread_mutex_unlock)
+
+FORWARD2 (pthread_self, pthread_t, (void), (), return 0)
+
+
+FORWARD (pthread_setcancelstate, (int state, int *oldstate), (state, oldstate),
+ 0)
+
+FORWARD (pthread_setcanceltype, (int type, int *oldtype), (type, oldtype), 0)
+
+#define return /* value is void */
+FORWARD2(_pthread_cleanup_push_defer,
+ void, (struct _pthread_cleanup_buffer *buffer, void (*routine)(void *), void *arg),
+ (buffer, routine, arg),
+ { buffer->__routine = routine; buffer->__arg = arg; });
+
+FORWARD2(_pthread_cleanup_pop_restore,
+ void, (struct _pthread_cleanup_buffer *buffer, int execute),
+ (buffer, execute),
+ if (execute) { buffer->__routine(buffer->__arg); });
+
+FORWARD2(__pthread_unwind,
+ void attribute_hidden __attribute ((noreturn)) __cleanup_fct_attribute,
+ (__pthread_unwind_buf_t *buf), (buf), {
+ /* We cannot call abort() here. */
+ INTERNAL_SYSCALL_DECL (err);
+ INTERNAL_SYSCALL (kill, err, 1, SIGKILL);
+#if __GNUC_PREREQ(4, 5)
+ __builtin_unreachable();
+#else
+ while(1);
+#endif
+ })
+#undef return
diff --git a/libpthread/nptl/herrno.c b/libpthread/nptl/herrno.c
new file mode 100644
index 000000000..c0488e4f6
--- /dev/null
+++ b/libpthread/nptl/herrno.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 1996,97,98,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/>. */
+
+#include <features.h>
+#include <netdb.h>
+#undef h_errno
+
+#include <tls.h>
+
+/* We need to have the error status variable of the resolver
+ accessible in the libc. */
+extern __thread int h_errno;
+
+
+/* When threaded, h_errno may be a per-thread variable. */
+int *
+__h_errno_location (void)
+{
+ return &h_errno;
+}
diff --git a/libpthread/nptl/init.c b/libpthread/nptl/init.c
new file mode 100644
index 000000000..eb84d6edd
--- /dev/null
+++ b/libpthread/nptl/init.c
@@ -0,0 +1,431 @@
+/* Copyright (C) 2002-2007, 2008, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <assert.h>
+#include <errno.h>
+#include <limits.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/param.h>
+#include <sys/resource.h>
+#include <pthreadP.h>
+#include <atomic.h>
+#include <ldsodefs.h>
+#include <tls.h>
+#include <fork.h>
+#include <version.h>
+#include <smp.h>
+#include <lowlevellock.h>
+#include <bits/kernel-features.h>
+#include <stdio.h>
+
+/* Size and alignment of static TLS block. */
+size_t __static_tls_size;
+size_t __static_tls_align_m1;
+
+#ifndef __ASSUME_SET_ROBUST_LIST
+/* Negative if we do not have the system call and we can use it. */
+int __set_robust_list_avail;
+# define set_robust_list_not_avail() \
+ __set_robust_list_avail = -1
+#else
+# define set_robust_list_not_avail() do { } while (0)
+#endif
+
+#ifndef __ASSUME_FUTEX_CLOCK_REALTIME
+/* Nonzero if we do not have FUTEX_CLOCK_REALTIME. */
+int __have_futex_clock_realtime;
+# define __set_futex_clock_realtime() \
+ __have_futex_clock_realtime = 1
+#else
+#define __set_futex_clock_realtime() do { } while (0)
+#endif
+
+/* Version of the library, used in libthread_db to detect mismatches. */
+static const char nptl_version[] __attribute_used__ = VERSION;
+
+#ifdef SHARED
+static void nptl_freeres (void);
+
+static const struct pthread_functions pthread_functions =
+ {
+ .ptr_pthread_attr_destroy = __pthread_attr_destroy,
+ .ptr___pthread_attr_init_2_1 = __pthread_attr_init_2_1,
+ .ptr_pthread_attr_getdetachstate = __pthread_attr_getdetachstate,
+ .ptr_pthread_attr_setdetachstate = __pthread_attr_setdetachstate,
+ .ptr_pthread_attr_getinheritsched = __pthread_attr_getinheritsched,
+ .ptr_pthread_attr_setinheritsched = __pthread_attr_setinheritsched,
+ .ptr_pthread_attr_getschedparam = __pthread_attr_getschedparam,
+ .ptr_pthread_attr_setschedparam = __pthread_attr_setschedparam,
+ .ptr_pthread_attr_getschedpolicy = __pthread_attr_getschedpolicy,
+ .ptr_pthread_attr_setschedpolicy = __pthread_attr_setschedpolicy,
+ .ptr_pthread_attr_getscope = __pthread_attr_getscope,
+ .ptr_pthread_attr_setscope = __pthread_attr_setscope,
+ .ptr_pthread_condattr_destroy = __pthread_condattr_destroy,
+ .ptr_pthread_condattr_init = __pthread_condattr_init,
+ .ptr___pthread_cond_broadcast = __pthread_cond_broadcast,
+ .ptr___pthread_cond_destroy = __pthread_cond_destroy,
+ .ptr___pthread_cond_init = __pthread_cond_init,
+ .ptr___pthread_cond_signal = __pthread_cond_signal,
+ .ptr___pthread_cond_wait = __pthread_cond_wait,
+ .ptr___pthread_cond_timedwait = __pthread_cond_timedwait,
+ .ptr_pthread_equal = __pthread_equal,
+ .ptr___pthread_exit = __pthread_exit,
+ .ptr_pthread_getschedparam = __pthread_getschedparam,
+ .ptr_pthread_setschedparam = __pthread_setschedparam,
+ .ptr_pthread_mutex_destroy = INTUSE(__pthread_mutex_destroy),
+ .ptr_pthread_mutex_init = INTUSE(__pthread_mutex_init),
+ .ptr_pthread_mutex_lock = INTUSE(__pthread_mutex_lock),
+ .ptr_pthread_mutex_unlock = INTUSE(__pthread_mutex_unlock),
+ .ptr_pthread_self = __pthread_self,
+ .ptr_pthread_setcancelstate = __pthread_setcancelstate,
+ .ptr_pthread_setcanceltype = __pthread_setcanceltype,
+ .ptr___pthread_cleanup_upto = __pthread_cleanup_upto,
+ .ptr___pthread_once = __pthread_once_internal,
+ .ptr___pthread_rwlock_rdlock = __pthread_rwlock_rdlock_internal,
+ .ptr___pthread_rwlock_wrlock = __pthread_rwlock_wrlock_internal,
+ .ptr___pthread_rwlock_unlock = __pthread_rwlock_unlock_internal,
+ .ptr___pthread_key_create = __pthread_key_create_internal,
+ .ptr___pthread_getspecific = __pthread_getspecific_internal,
+ .ptr___pthread_setspecific = __pthread_setspecific_internal,
+ .ptr__pthread_cleanup_push_defer = __pthread_cleanup_push_defer,
+ .ptr__pthread_cleanup_pop_restore = __pthread_cleanup_pop_restore,
+ .ptr_nthreads = &__nptl_nthreads,
+ .ptr___pthread_unwind = &__pthread_unwind,
+ .ptr__nptl_deallocate_tsd = __nptl_deallocate_tsd,
+ .ptr__nptl_setxid = __nptl_setxid,
+ /* For now only the stack cache needs to be freed. */
+ .ptr_freeres = nptl_freeres
+ };
+# define ptr_pthread_functions &pthread_functions
+#else
+# define ptr_pthread_functions NULL
+#endif
+
+
+#ifdef SHARED
+/* This function is called indirectly from the freeres code in libc. */
+static void
+__libc_freeres_fn_section
+nptl_freeres (void)
+{
+ __unwind_freeres ();
+ __free_stacks (0);
+}
+#endif
+
+
+/* For asynchronous cancellation we use a signal. This is the handler. */
+static void
+sigcancel_handler (int sig, siginfo_t *si, void *ctx)
+{
+#ifdef __ASSUME_CORRECT_SI_PID
+ /* Determine the process ID. It might be negative if the thread is
+ in the middle of a fork() call. */
+ pid_t pid = THREAD_GETMEM (THREAD_SELF, pid);
+ if (__builtin_expect (pid < 0, 0))
+ pid = -pid;
+#endif
+
+ /* Safety check. It would be possible to call this function for
+ other signals and send a signal from another process. This is not
+ correct and might even be a security problem. Try to catch as
+ many incorrect invocations as possible. */
+ if (sig != SIGCANCEL
+#ifdef __ASSUME_CORRECT_SI_PID
+ /* Kernels before 2.5.75 stored the thread ID and not the process
+ ID in si_pid so we skip this test. */
+ || si->si_pid != pid
+#endif
+ || si->si_code != SI_TKILL)
+ return;
+
+ struct pthread *self = THREAD_SELF;
+
+ int oldval = THREAD_GETMEM (self, cancelhandling);
+ while (1)
+ {
+ /* We are canceled now. When canceled by another thread this flag
+ is already set but if the signal is directly send (internally or
+ from another process) is has to be done here. */
+ int newval = oldval | CANCELING_BITMASK | CANCELED_BITMASK;
+
+ if (oldval == newval || (oldval & EXITING_BITMASK) != 0)
+ /* Already canceled or exiting. */
+ break;
+
+ int curval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling, newval,
+ oldval);
+ if (curval == oldval)
+ {
+ /* Set the return value. */
+ THREAD_SETMEM (self, result, PTHREAD_CANCELED);
+
+ /* Make sure asynchronous cancellation is still enabled. */
+ if ((newval & CANCELTYPE_BITMASK) != 0)
+ /* Run the registered destructors and terminate the thread. */
+ __do_cancel ();
+
+ break;
+ }
+
+ oldval = curval;
+ }
+}
+
+
+struct xid_command *__xidcmd attribute_hidden;
+
+/* For asynchronous cancellation we use a signal. This is the handler. */
+static void
+sighandler_setxid (int sig, siginfo_t *si, void *ctx)
+{
+#ifdef __ASSUME_CORRECT_SI_PID
+ /* Determine the process ID. It might be negative if the thread is
+ in the middle of a fork() call. */
+ pid_t pid = THREAD_GETMEM (THREAD_SELF, pid);
+ if (__builtin_expect (pid < 0, 0))
+ pid = -pid;
+#endif
+
+ /* Safety check. It would be possible to call this function for
+ other signals and send a signal from another process. This is not
+ correct and might even be a security problem. Try to catch as
+ many incorrect invocations as possible. */
+ if (sig != SIGSETXID
+#ifdef __ASSUME_CORRECT_SI_PID
+ /* Kernels before 2.5.75 stored the thread ID and not the process
+ ID in si_pid so we skip this test. */
+ || si->si_pid != pid
+#endif
+ || si->si_code != SI_TKILL)
+ return;
+
+ INTERNAL_SYSCALL_DECL (err);
+ INTERNAL_SYSCALL_NCS (__xidcmd->syscall_no, err, 3, __xidcmd->id[0],
+ __xidcmd->id[1], __xidcmd->id[2]);
+
+ /* Reset the SETXID flag. */
+ struct pthread *self = THREAD_SELF;
+ int flags, newval;
+ do
+ {
+ flags = THREAD_GETMEM (self, cancelhandling);
+ newval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling,
+ flags & ~SETXID_BITMASK, flags);
+ }
+ while (flags != newval);
+
+ /* And release the futex. */
+ self->setxid_futex = 1;
+ lll_futex_wake (&self->setxid_futex, 1, LLL_PRIVATE);
+
+ if (atomic_decrement_val (&__xidcmd->cntr) == 0)
+ lll_futex_wake (&__xidcmd->cntr, 1, LLL_PRIVATE);
+}
+
+
+/* When using __thread for this, we do it in libc so as not
+ to give libpthread its own TLS segment just for this. */
+extern void **__libc_dl_error_tsd (void) __attribute__ ((const));
+
+
+/* This can be set by the debugger before initialization is complete. */
+static bool __nptl_initial_report_events __attribute_used__;
+
+void __pthread_initialize_minimal_internal (void) attribute_hidden;
+void
+__pthread_initialize_minimal_internal (void)
+{
+ static int initialized = 0;
+
+ if (initialized)
+ return;
+ initialized = 1;
+
+ /* Minimal initialization of the thread descriptor. */
+ struct pthread *pd = THREAD_SELF;
+ INTERNAL_SYSCALL_DECL (err);
+ pd->pid = pd->tid = INTERNAL_SYSCALL (set_tid_address, err, 1, &pd->tid);
+ THREAD_SETMEM (pd, specific[0], &pd->specific_1stblock[0]);
+ THREAD_SETMEM (pd, user_stack, true);
+ if (LLL_LOCK_INITIALIZER != 0)
+ THREAD_SETMEM (pd, lock, LLL_LOCK_INITIALIZER);
+#if HP_TIMING_AVAIL
+ THREAD_SETMEM (pd, cpuclock_offset, GL(dl_cpuclock_offset));
+#endif
+
+ /* Initialize the robust mutex data. */
+#ifdef __PTHREAD_MUTEX_HAVE_PREV
+ pd->robust_prev = &pd->robust_head;
+#endif
+ pd->robust_head.list = &pd->robust_head;
+#ifdef __NR_set_robust_list
+ pd->robust_head.futex_offset = (offsetof (pthread_mutex_t, __data.__lock)
+ - offsetof (pthread_mutex_t,
+ __data.__list.__next));
+ int res = INTERNAL_SYSCALL (set_robust_list, err, 2, &pd->robust_head,
+ sizeof (struct robust_list_head));
+ if (INTERNAL_SYSCALL_ERROR_P (res, err))
+#endif
+ set_robust_list_not_avail ();
+
+#ifndef __ASSUME_PRIVATE_FUTEX
+ /* Private futexes are always used (at least internally) so that
+ doing the test once this early is beneficial. */
+ {
+ int word = 0;
+ word = INTERNAL_SYSCALL (futex, err, 3, &word,
+ FUTEX_WAKE | FUTEX_PRIVATE_FLAG, 1);
+ if (!INTERNAL_SYSCALL_ERROR_P (word, err))
+ THREAD_SETMEM (pd, header.private_futex, FUTEX_PRIVATE_FLAG);
+ }
+
+ /* Private futexes have been introduced earlier than the
+ FUTEX_CLOCK_REALTIME flag. We don't have to run the test if we
+ know the former are not supported. This also means we know the
+ kernel will return ENOSYS for unknown operations. */
+ if (THREAD_GETMEM (pd, header.private_futex) != 0)
+#endif
+#ifndef __ASSUME_FUTEX_CLOCK_REALTIME
+ {
+ int word = 0;
+ /* NB: the syscall actually takes six parameters. The last is the
+ bit mask. But since we will not actually wait at all the value
+ is irrelevant. Given that passing six parameters is difficult
+ on some architectures we just pass whatever random value the
+ calling convention calls for to the kernel. It causes no harm. */
+ word = INTERNAL_SYSCALL (futex, err, 5, &word,
+ FUTEX_WAIT_BITSET | FUTEX_CLOCK_REALTIME
+ | FUTEX_PRIVATE_FLAG, 1, NULL, 0);
+ assert (INTERNAL_SYSCALL_ERROR_P (word, err));
+ if (INTERNAL_SYSCALL_ERRNO (word, err) != ENOSYS)
+ __set_futex_clock_realtime ();
+ }
+#endif
+
+ /* Set initial thread's stack block from 0 up to __libc_stack_end.
+ It will be bigger than it actually is, but for unwind.c/pt-longjmp.c
+ purposes this is good enough. */
+ THREAD_SETMEM (pd, stackblock_size, (size_t) __libc_stack_end);
+
+ /* Initialize the list of all running threads with the main thread. */
+ INIT_LIST_HEAD (&__stack_user);
+ list_add (&pd->list, &__stack_user);
+
+ /* Before initializing __stack_user, the debugger could not find us and
+ had to set __nptl_initial_report_events. Propagate its setting. */
+ THREAD_SETMEM (pd, report_events, __nptl_initial_report_events);
+
+ /* Install the cancellation signal handler. If for some reason we
+ cannot install the handler we do not abort. Maybe we should, but
+ it is only asynchronous cancellation which is affected. */
+ struct sigaction sa;
+ sa.sa_sigaction = sigcancel_handler;
+ sa.sa_flags = SA_SIGINFO;
+ __sigemptyset (&sa.sa_mask);
+
+ (void) __libc_sigaction (SIGCANCEL, &sa, NULL);
+
+ /* Install the handle to change the threads' uid/gid. */
+ sa.sa_sigaction = sighandler_setxid;
+ sa.sa_flags = SA_SIGINFO | SA_RESTART;
+
+ (void) __libc_sigaction (SIGSETXID, &sa, NULL);
+
+ /* The parent process might have left the signals blocked. Just in
+ case, unblock it. We reuse the signal mask in the sigaction
+ structure. It is already cleared. */
+ __sigaddset (&sa.sa_mask, SIGCANCEL);
+ __sigaddset (&sa.sa_mask, SIGSETXID);
+ (void) INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_UNBLOCK, &sa.sa_mask,
+ NULL, _NSIG / 8);
+
+ /* Get the size of the static and alignment requirements for the TLS
+ block. */
+ size_t static_tls_align;
+ _dl_get_tls_static_info (&__static_tls_size, &static_tls_align);
+
+ /* Make sure the size takes all the alignments into account. */
+ if (STACK_ALIGN > static_tls_align)
+ static_tls_align = STACK_ALIGN;
+ __static_tls_align_m1 = static_tls_align - 1;
+
+ __static_tls_size = roundup (__static_tls_size, static_tls_align);
+
+ /* Determine the default allowed stack size. This is the size used
+ in case the user does not specify one. */
+ struct rlimit limit;
+ if (getrlimit (RLIMIT_STACK, &limit) != 0
+ || limit.rlim_cur == RLIM_INFINITY)
+ /* The system limit is not usable. Use an architecture-specific
+ default. */
+ limit.rlim_cur = ARCH_STACK_DEFAULT_SIZE;
+ else if (limit.rlim_cur < PTHREAD_STACK_MIN)
+ /* The system limit is unusably small.
+ Use the minimal size acceptable. */
+ limit.rlim_cur = PTHREAD_STACK_MIN;
+
+ /* Do not exceed architecture specific default */
+ if (limit.rlim_cur > ARCH_STACK_DEFAULT_SIZE)
+ limit.rlim_cur = ARCH_STACK_DEFAULT_SIZE;
+
+ /* Make sure it meets the minimum size that allocate_stack
+ (allocatestack.c) will demand, which depends on the page size. */
+ const uintptr_t pagesz = sysconf (_SC_PAGESIZE);
+ const size_t minstack = pagesz + __static_tls_size + MINIMAL_REST_STACK;
+ if (limit.rlim_cur < minstack)
+ limit.rlim_cur = minstack;
+
+ /* Round the resource limit up to page size. */
+ limit.rlim_cur = (limit.rlim_cur + pagesz - 1) & -pagesz;
+ __default_stacksize = limit.rlim_cur;
+
+#ifdef SHARED
+ /* Transfer the old value from the dynamic linker's internal location. */
+ *__libc_dl_error_tsd () = *(*GL(dl_error_catch_tsd)) ();
+ GL(dl_error_catch_tsd) = &__libc_dl_error_tsd;
+
+#endif
+
+ GL(dl_init_static_tls) = &__pthread_init_static_tls;
+
+ /* Register the fork generation counter with the libc. */
+#ifndef TLS_MULTIPLE_THREADS_IN_TCB
+ __libc_multiple_threads_ptr =
+#endif
+ __libc_pthread_init (&__fork_generation, __reclaim_stacks,
+ ptr_pthread_functions);
+
+ /* Determine whether the machine is SMP or not. */
+ __is_smp = is_smp_system ();
+
+ /* uClibc-specific stdio initialization for threads. */
+ {
+ FILE *fp;
+ _stdio_user_locking = 0; /* 2 if threading not initialized */
+ for (fp = _stdio_openlist; fp != NULL; fp = fp->__nextopen) {
+ if (fp->__user_locking != 1) {
+ fp->__user_locking = 0;
+ }
+ }
+ }
+}
+strong_alias (__pthread_initialize_minimal_internal,
+ __pthread_initialize_minimal)
diff --git a/libpthread/nptl/libc-cancellation.c b/libpthread/nptl/libc-cancellation.c
new file mode 100644
index 000000000..8f31b5f9e
--- /dev/null
+++ b/libpthread/nptl/libc-cancellation.c
@@ -0,0 +1,24 @@
+/* Copyright (C) 2002, 2003, 2005, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 "pthreadP.h"
+
+
+#define __pthread_enable_asynccancel __libc_enable_asynccancel
+#define __pthread_disable_asynccancel __libc_disable_asynccancel
+#include "cancellation.c"
diff --git a/libpthread/nptl/linux_fsinfo.h b/libpthread/nptl/linux_fsinfo.h
new file mode 100644
index 000000000..8537581a2
--- /dev/null
+++ b/libpthread/nptl/linux_fsinfo.h
@@ -0,0 +1,152 @@
+/* Constants from kernel header for various FSes.
+ Copyright (C) 1998,1999,2000,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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _LINUX_FSINFO_H
+#define _LINUX_FSINFO_H 1
+
+/* These definitions come from the kernel headers. But we cannot
+ include the headers here because of type clashes. If new
+ filesystem types will become available we have to add the
+ appropriate definitions here.*/
+
+/* Constants that identify the `adfs' filesystem. */
+#define ADFS_SUPER_MAGIC 0xadf5
+
+/* Constants that identify the `affs' filesystem. */
+#define AFFS_SUPER_MAGIC 0xadff
+
+/* Constants that identify the `autofs' filesystem. */
+#define AUTOFS_SUPER_MAGIC 0x187
+
+/* Constants that identify the `bfs' filesystem. */
+#define BFS_MAGIC 0x1BADFACE
+
+/* Constants that identify the `coda' filesystem. */
+#define CODA_SUPER_MAGIC 0x73757245
+
+/* Constants that identify the `coherent' filesystem. */
+#define COH_SUPER_MAGIC 0x012ff7b7
+
+/* Constant that identifies the `ramfs' filesystem. */
+#define CRAMFS_MAGIC 0x28cd3d45
+
+/* Constant that identifies the `devfs' filesystem. */
+#define DEVFS_SUPER_MAGIC 0x1373
+
+/* Constant that identifies the `devpts' filesystem. */
+#define DEVPTS_SUPER_MAGIC 0x1cd1
+
+/* Constant that identifies the `efs' filesystem. */
+#define EFS_SUPER_MAGIC 0x414A53
+#define EFS_MAGIC 0x072959
+
+/* Constant that identifies the `ext2' and `ext3' filesystems. */
+#define EXT2_SUPER_MAGIC 0xef53
+
+/* Constant that identifies the `hpfs' filesystem. */
+#define HPFS_SUPER_MAGIC 0xf995e849
+
+/* Constant that identifies the `iso9660' filesystem. */
+#define ISOFS_SUPER_MAGIC 0x9660
+
+/* Constant that identifies the `jffs' filesystem. */
+#define JFFS_SUPER_MAGIC 0x07c0
+
+/* Constant that identifies the `jffs2' filesystem. */
+#define JFFS2_SUPER_MAGIC 0x72b6
+
+/* Constant that identifies the `jfs' filesystem. */
+#define JFS_SUPER_MAGIC 0x3153464a
+
+/* Constants that identify the `minix2' filesystem. */
+#define MINIX2_SUPER_MAGIC 0x2468
+#define MINIX2_SUPER_MAGIC2 0x2478
+
+/* Constants that identify the `minix' filesystem. */
+#define MINIX_SUPER_MAGIC 0x137f
+#define MINIX_SUPER_MAGIC2 0x138F
+
+/* Constants that identify the `msdos' filesystem. */
+#define MSDOS_SUPER_MAGIC 0x4d44
+
+/* Constants that identify the `ncp' filesystem. */
+#define NCP_SUPER_MAGIC 0x564c
+
+/* Constants that identify the `nfs' filesystem. */
+#define NFS_SUPER_MAGIC 0x6969
+
+/* Constants that identify the `ntfs' filesystem. */
+#define NTFS_SUPER_MAGIC 0x5346544e
+
+/* Constants that identify the `proc' filesystem. */
+#define PROC_SUPER_MAGIC 0x9fa0
+
+/* Constant that identifies the `usbdevfs' filesystem. */
+#define USBDEVFS_SUPER_MAGIC 0x9fa2
+
+/* Constants that identify the `qnx4' filesystem. */
+#define QNX4_SUPER_MAGIC 0x002f
+
+/* Constants that identify the `reiser' filesystem. */
+#define REISERFS_SUPER_MAGIC 0x52654973
+
+/* Constant that identifies the `romfs' filesystem. */
+#define ROMFS_SUPER_MAGIC 0x7275
+
+/* Constants that identify the `smb' filesystem. */
+#define SMB_SUPER_MAGIC 0x517b
+
+/* Constants that identify the `sysV' filesystem. */
+#define SYSV2_SUPER_MAGIC 0x012ff7b6
+#define SYSV4_SUPER_MAGIC 0x012ff7b5
+
+/* Constants that identify the `udf' filesystem. */
+#define UDF_SUPER_MAGIC 0x15013346
+
+/* Constants that identify the `ufs' filesystem. */
+#define UFS_MAGIC 0x00011954
+#define UFS_CIGAM 0x54190100 /* byteswapped MAGIC */
+
+/* Constants that identify the `xenix' filesystem. */
+#define XENIX_SUPER_MAGIC 0x012ff7b4
+
+/* Constant that identifies the `shm' filesystem. */
+#define SHMFS_SUPER_MAGIC 0x01021994
+
+/* Constants that identify the `xfs' filesystem. */
+#define XFS_SUPER_MAGIC 0x58465342
+
+/* Constants that identify the `vxfs' filesystem. */
+#define VXFS_SUPER_MAGIC 0xa501fcf5
+
+/* Maximum link counts. */
+#define COH_LINK_MAX 10000
+#define EXT2_LINK_MAX 32000
+#define MINIX2_LINK_MAX 65530
+#define MINIX_LINK_MAX 250
+#define REISERFS_LINK_MAX 64535
+#define SYSV_LINK_MAX 126 /* 127? 251? */
+#define UFS_LINK_MAX EXT2_LINK_MAX
+#define XENIX_LINK_MAX 126 /* ?? */
+#define XFS_LINK_MAX 2147483647
+
+/* The Linux kernel header mentioned this as a kind of generic value. */
+#define LINUX_LINK_MAX 127
+
+
+#endif /* linux_fsinfo.h */
diff --git a/libpthread/nptl/pt-cleanup.c b/libpthread/nptl/pt-cleanup.c
new file mode 100644
index 000000000..d4029d5fc
--- /dev/null
+++ b/libpthread/nptl/pt-cleanup.c
@@ -0,0 +1,63 @@
+/* Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <setjmp.h>
+#include <stdlib.h>
+#include "pthreadP.h"
+#include <jmpbuf-unwind.h>
+
+void
+/*does not apply due to hidden_proto(): attribute_protected*/
+__pthread_cleanup_upto (__jmp_buf target, char *targetframe)
+{
+ struct pthread *self = THREAD_SELF;
+ struct _pthread_cleanup_buffer *cbuf;
+
+ /* Adjust all pointers used in comparisons, so that top of thread's
+ stack is at the top of address space. Without that, things break
+ if stack is allocated above the main stack. */
+ uintptr_t adj = (uintptr_t) self->stackblock + self->stackblock_size;
+ uintptr_t targetframe_adj = (uintptr_t) targetframe - adj;
+
+ for (cbuf = THREAD_GETMEM (self, cleanup);
+ cbuf != NULL && _JMPBUF_UNWINDS_ADJ (target, cbuf, adj);
+ cbuf = cbuf->__prev)
+ {
+#ifdef _STACK_GROWS_DOWN
+ if ((uintptr_t) cbuf - adj <= targetframe_adj)
+ {
+ cbuf = NULL;
+ break;
+ }
+#elif defined _STACK_GROWS_UP
+ if ((uintptr_t) cbuf - adj >= targetframe_adj)
+ {
+ cbuf = NULL;
+ break;
+ }
+#else
+# error "Define either _STACK_GROWS_DOWN or _STACK_GROWS_UP"
+#endif
+
+ /* Call the cleanup code. */
+ cbuf->__routine (cbuf->__arg);
+ }
+
+ THREAD_SETMEM (self, cleanup, cbuf);
+}
+hidden_def (__pthread_cleanup_upto)
diff --git a/libpthread/nptl/pt-system.c b/libpthread/nptl/pt-system.c
new file mode 100644
index 000000000..31567f064
--- /dev/null
+++ b/libpthread/nptl/pt-system.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <stdlib.h>
+#include <sysdep.h>
+#include "pthreadP.h"
+
+extern __typeof(system) __libc_system;
+#include <system.c>
+
+
+int
+system (const char *line)
+{
+ return __libc_system (line);
+}
+
+/* __libc_system in libc.so handles cancellation. */
+LIBC_CANCEL_HANDLED ();
diff --git a/libpthread/nptl/pthread-errnos.sym b/libpthread/nptl/pthread-errnos.sym
new file mode 100644
index 000000000..0975b7a37
--- /dev/null
+++ b/libpthread/nptl/pthread-errnos.sym
@@ -0,0 +1,13 @@
+#include <errno.h>
+
+-- These errno codes are used by some assembly code.
+
+EAGAIN EAGAIN
+EBUSY EBUSY
+EDEADLK EDEADLK
+EINTR EINTR
+EINVAL EINVAL
+ENOSYS ENOSYS
+EOVERFLOW EOVERFLOW
+ETIMEDOUT ETIMEDOUT
+EWOULDBLOCK EWOULDBLOCK
diff --git a/libpthread/nptl/pthreadP.h b/libpthread/nptl/pthreadP.h
new file mode 100644
index 000000000..f46dd40d5
--- /dev/null
+++ b/libpthread/nptl/pthreadP.h
@@ -0,0 +1,602 @@
+/* Copyright (C) 2002-2007, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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/>. */
+
+#ifndef _PTHREADP_H
+#define _PTHREADP_H 1
+
+#include <pthread.h>
+#include <setjmp.h>
+#include <stdbool.h>
+#include <sys/syscall.h>
+#include "descr.h"
+#include <tls.h>
+#include <lowlevellock.h>
+#include <bits/stackinfo.h>
+#include <internaltypes.h>
+#include <pthread-functions.h>
+#include <atomic.h>
+#include <bits/kernel-features.h>
+
+
+/* Atomic operations on TLS memory. */
+#ifndef THREAD_ATOMIC_CMPXCHG_VAL
+# define THREAD_ATOMIC_CMPXCHG_VAL(descr, member, new, old) \
+ atomic_compare_and_exchange_val_acq (&(descr)->member, new, old)
+#endif
+
+#ifndef THREAD_ATOMIC_BIT_SET
+# define THREAD_ATOMIC_BIT_SET(descr, member, bit) \
+ atomic_bit_set (&(descr)->member, bit)
+#endif
+
+
+/* Adaptive mutex definitions. */
+#ifndef MAX_ADAPTIVE_COUNT
+# define MAX_ADAPTIVE_COUNT 100
+#endif
+
+
+/* Magic cookie representing robust mutex with dead owner. */
+#define PTHREAD_MUTEX_INCONSISTENT INT_MAX
+/* Magic cookie representing not recoverable robust mutex. */
+#define PTHREAD_MUTEX_NOTRECOVERABLE (INT_MAX - 1)
+
+
+/* Internal mutex type value. */
+enum
+{
+ PTHREAD_MUTEX_KIND_MASK_NP = 3,
+ PTHREAD_MUTEX_ROBUST_NORMAL_NP = 16,
+ PTHREAD_MUTEX_ROBUST_RECURSIVE_NP
+ = PTHREAD_MUTEX_ROBUST_NORMAL_NP | PTHREAD_MUTEX_RECURSIVE_NP,
+ PTHREAD_MUTEX_ROBUST_ERRORCHECK_NP
+ = PTHREAD_MUTEX_ROBUST_NORMAL_NP | PTHREAD_MUTEX_ERRORCHECK_NP,
+ PTHREAD_MUTEX_ROBUST_ADAPTIVE_NP
+ = PTHREAD_MUTEX_ROBUST_NORMAL_NP | PTHREAD_MUTEX_ADAPTIVE_NP,
+ PTHREAD_MUTEX_PRIO_INHERIT_NP = 32,
+ PTHREAD_MUTEX_PI_NORMAL_NP
+ = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_NORMAL,
+ PTHREAD_MUTEX_PI_RECURSIVE_NP
+ = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_RECURSIVE_NP,
+ PTHREAD_MUTEX_PI_ERRORCHECK_NP
+ = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ERRORCHECK_NP,
+ PTHREAD_MUTEX_PI_ADAPTIVE_NP
+ = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ADAPTIVE_NP,
+ PTHREAD_MUTEX_PI_ROBUST_NORMAL_NP
+ = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ROBUST_NORMAL_NP,
+ PTHREAD_MUTEX_PI_ROBUST_RECURSIVE_NP
+ = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ROBUST_RECURSIVE_NP,
+ PTHREAD_MUTEX_PI_ROBUST_ERRORCHECK_NP
+ = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ROBUST_ERRORCHECK_NP,
+ PTHREAD_MUTEX_PI_ROBUST_ADAPTIVE_NP
+ = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ROBUST_ADAPTIVE_NP,
+ PTHREAD_MUTEX_PRIO_PROTECT_NP = 64,
+ PTHREAD_MUTEX_PP_NORMAL_NP
+ = PTHREAD_MUTEX_PRIO_PROTECT_NP | PTHREAD_MUTEX_NORMAL,
+ PTHREAD_MUTEX_PP_RECURSIVE_NP
+ = PTHREAD_MUTEX_PRIO_PROTECT_NP | PTHREAD_MUTEX_RECURSIVE_NP,
+ PTHREAD_MUTEX_PP_ERRORCHECK_NP
+ = PTHREAD_MUTEX_PRIO_PROTECT_NP | PTHREAD_MUTEX_ERRORCHECK_NP,
+ PTHREAD_MUTEX_PP_ADAPTIVE_NP
+ = PTHREAD_MUTEX_PRIO_PROTECT_NP | PTHREAD_MUTEX_ADAPTIVE_NP
+};
+#define PTHREAD_MUTEX_PSHARED_BIT 128
+
+#define PTHREAD_MUTEX_TYPE(m) \
+ ((m)->__data.__kind & 127)
+
+#if LLL_PRIVATE == 0 && LLL_SHARED == 128
+# define PTHREAD_MUTEX_PSHARED(m) \
+ ((m)->__data.__kind & 128)
+#else
+# define PTHREAD_MUTEX_PSHARED(m) \
+ (((m)->__data.__kind & 128) ? LLL_SHARED : LLL_PRIVATE)
+#endif
+
+/* The kernel when waking robust mutexes on exit never uses
+ FUTEX_PRIVATE_FLAG FUTEX_WAKE. */
+#define PTHREAD_ROBUST_MUTEX_PSHARED(m) LLL_SHARED
+
+/* Ceiling in __data.__lock. __data.__lock is signed, so don't
+ use the MSB bit in there, but in the mask also include that bit,
+ so that the compiler can optimize & PTHREAD_MUTEX_PRIO_CEILING_MASK
+ masking if the value is then shifted down by
+ PTHREAD_MUTEX_PRIO_CEILING_SHIFT. */
+#define PTHREAD_MUTEX_PRIO_CEILING_SHIFT 19
+#define PTHREAD_MUTEX_PRIO_CEILING_MASK 0xfff80000
+
+
+/* Flags in mutex attr. */
+#define PTHREAD_MUTEXATTR_PROTOCOL_SHIFT 28
+#define PTHREAD_MUTEXATTR_PROTOCOL_MASK 0x30000000
+#define PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT 12
+#define PTHREAD_MUTEXATTR_PRIO_CEILING_MASK 0x00fff000
+#define PTHREAD_MUTEXATTR_FLAG_ROBUST 0x40000000
+#define PTHREAD_MUTEXATTR_FLAG_PSHARED 0x80000000
+#define PTHREAD_MUTEXATTR_FLAG_BITS \
+ (PTHREAD_MUTEXATTR_FLAG_ROBUST | PTHREAD_MUTEXATTR_FLAG_PSHARED \
+ | PTHREAD_MUTEXATTR_PROTOCOL_MASK | PTHREAD_MUTEXATTR_PRIO_CEILING_MASK)
+
+
+/* Check whether rwlock prefers readers. */
+#define PTHREAD_RWLOCK_PREFER_READER_P(rwlock) \
+ ((rwlock)->__data.__flags == 0)
+
+
+/* Bits used in robust mutex implementation. */
+#define FUTEX_WAITERS 0x80000000
+#define FUTEX_OWNER_DIED 0x40000000
+#define FUTEX_TID_MASK 0x3fffffff
+
+
+/* Internal variables. */
+
+
+/* Default stack size. */
+extern size_t __default_stacksize attribute_hidden;
+
+/* Size and alignment of static TLS block. */
+extern size_t __static_tls_size attribute_hidden;
+extern size_t __static_tls_align_m1 attribute_hidden;
+
+/* Flag whether the machine is SMP or not. */
+extern int __is_smp attribute_hidden;
+
+/* Thread descriptor handling. */
+extern list_t __stack_user;
+hidden_proto (__stack_user)
+
+/* Attribute handling. */
+extern struct pthread_attr *__attr_list attribute_hidden;
+extern int __attr_list_lock attribute_hidden;
+
+/* First available RT signal. */
+extern int __current_sigrtmin attribute_hidden;
+/* Last available RT signal. */
+extern int __current_sigrtmax attribute_hidden;
+
+/* Concurrency handling. */
+extern int __concurrency_level attribute_hidden;
+
+/* Thread-local data key handling. */
+extern struct pthread_key_struct __pthread_keys[PTHREAD_KEYS_MAX];
+hidden_proto (__pthread_keys)
+
+/* Number of threads running. */
+extern unsigned int __nptl_nthreads
+#ifdef SHARED
+ attribute_hidden
+#else
+ __attribute ((weak))
+#endif
+ ;
+
+#ifndef __ASSUME_SET_ROBUST_LIST
+/* Negative if we do not have the system call and we can use it. */
+extern int __set_robust_list_avail attribute_hidden;
+#endif
+
+/* Thread Priority Protection. */
+extern int __sched_fifo_min_prio attribute_hidden;
+extern int __sched_fifo_max_prio attribute_hidden;
+extern void __init_sched_fifo_prio (void) attribute_hidden;
+extern int __pthread_tpp_change_priority (int prev_prio, int new_prio)
+ attribute_hidden;
+extern int __pthread_current_priority (void) attribute_hidden;
+
+/* The library can run in debugging mode where it performs a lot more
+ tests. */
+extern int __pthread_debug attribute_hidden;
+/** For now disable debugging support. */
+#if 0
+# define DEBUGGING_P __builtin_expect (__pthread_debug, 0)
+# define INVALID_TD_P(pd) (DEBUGGING_P && __find_in_stack_list (pd) == NULL)
+# define INVALID_NOT_TERMINATED_TD_P(pd) INVALID_TD_P (pd)
+#else
+# define DEBUGGING_P 0
+/* Simplified test. This will not catch all invalid descriptors but
+ is better than nothing. And if the test triggers the thread
+ descriptor is guaranteed to be invalid. */
+# define INVALID_TD_P(pd) __builtin_expect ((pd)->tid <= 0, 0)
+# define INVALID_NOT_TERMINATED_TD_P(pd) __builtin_expect ((pd)->tid < 0, 0)
+#endif
+
+
+/* Cancellation test. */
+#define CANCELLATION_P(self) \
+ do { \
+ cancelhandling = THREAD_GETMEM (self, cancelhandling); \
+ if (CANCEL_ENABLED_AND_CANCELED (cancelhandling)) \
+ { \
+ THREAD_SETMEM (self, result, PTHREAD_CANCELED); \
+ __do_cancel (); \
+ } \
+ } while (0)
+
+
+extern void __pthread_unwind (__pthread_unwind_buf_t *__buf)
+ __cleanup_fct_attribute __attribute ((__noreturn__))
+#if !defined SHARED && !defined IS_IN_libpthread
+ weak_function
+#endif
+ ;
+extern void __pthread_unwind_next (__pthread_unwind_buf_t *__buf)
+ __cleanup_fct_attribute __attribute ((__noreturn__))
+#ifndef SHARED
+ weak_function
+#endif
+ ;
+extern void __pthread_register_cancel (__pthread_unwind_buf_t *__buf)
+ __cleanup_fct_attribute;
+extern void __pthread_unregister_cancel (__pthread_unwind_buf_t *__buf)
+ __cleanup_fct_attribute;
+#if defined NOT_IN_libc && defined IS_IN_libpthread
+hidden_proto (__pthread_unwind)
+hidden_proto (__pthread_unwind_next)
+hidden_proto (__pthread_register_cancel)
+hidden_proto (__pthread_unregister_cancel)
+# ifdef SHARED
+extern void attribute_hidden pthread_cancel_init (void);
+extern void __unwind_freeres (void);
+# endif
+#endif
+
+
+/* Called when a thread reacts on a cancellation request. */
+static inline void
+__attribute ((noreturn, always_inline))
+__do_cancel (void)
+{
+ struct pthread *self = THREAD_SELF;
+
+ /* Make sure we get no more cancellations. */
+ THREAD_ATOMIC_BIT_SET (self, cancelhandling, EXITING_BIT);
+
+ __pthread_unwind ((__pthread_unwind_buf_t *)
+ THREAD_GETMEM (self, cleanup_jmp_buf));
+}
+
+
+/* Set cancellation mode to asynchronous. */
+#define CANCEL_ASYNC() \
+ __pthread_enable_asynccancel ()
+/* Reset to previous cancellation mode. */
+#define CANCEL_RESET(oldtype) \
+ __pthread_disable_asynccancel (oldtype)
+
+#define __LABEL_PREFIX__ __stringify(__USER_LABEL_PREFIX__)
+
+#if !defined NOT_IN_libc
+/* Same as CANCEL_ASYNC, but for use in libc.so. */
+# define LIBC_CANCEL_ASYNC() \
+ __libc_enable_asynccancel ()
+/* Same as CANCEL_RESET, but for use in libc.so. */
+# define LIBC_CANCEL_RESET(oldtype) \
+ __libc_disable_asynccancel (oldtype)
+# define LIBC_CANCEL_HANDLED() \
+ __asm__ (".globl " __LABEL_PREFIX__ "__libc_enable_asynccancel"); \
+ __asm__ (".globl " __LABEL_PREFIX__ "__libc_disable_asynccancel")
+#elif defined NOT_IN_libc && defined IS_IN_libpthread
+# define LIBC_CANCEL_ASYNC() CANCEL_ASYNC ()
+# define LIBC_CANCEL_RESET(val) CANCEL_RESET (val)
+# define LIBC_CANCEL_HANDLED() \
+ __asm__ (".globl " __LABEL_PREFIX__ "__pthread_enable_asynccancel"); \
+ __asm__ (".globl " __LABEL_PREFIX__ "__pthread_disable_asynccancel")
+#elif defined NOT_IN_libc && defined IS_IN_librt
+# define LIBC_CANCEL_ASYNC() \
+ __librt_enable_asynccancel ()
+# define LIBC_CANCEL_RESET(val) \
+ __librt_disable_asynccancel (val)
+# define LIBC_CANCEL_HANDLED() \
+ __asm__ (".globl " __LABEL_PREFIX__ "__librt_enable_asynccancel"); \
+ __asm__ (".globl " __LABEL_PREFIX__ "__librt_disable_asynccancel")
+#else
+# define LIBC_CANCEL_ASYNC() 0 /* Just a dummy value. */
+# define LIBC_CANCEL_RESET(val) ((void)(val)) /* Nothing, but evaluate it. */
+# define LIBC_CANCEL_HANDLED() /* Nothing. */
+#endif
+
+/* The signal used for asynchronous cancellation. */
+#define SIGCANCEL __SIGRTMIN
+
+
+/* Signal needed for the kernel-supported POSIX timer implementation.
+ We can reuse the cancellation signal since we can distinguish
+ cancellation from timer expirations. */
+#define SIGTIMER SIGCANCEL
+
+
+/* Signal used to implement the setuid et.al. functions. */
+#define SIGSETXID (__SIGRTMIN + 1)
+
+/* Used to communicate with signal handler. */
+extern struct xid_command *__xidcmd attribute_hidden;
+
+
+/* Internal prototypes. */
+
+/* Thread list handling. */
+extern struct pthread *__find_in_stack_list (struct pthread *pd)
+ attribute_hidden internal_function;
+
+/* Deallocate a thread's stack after optionally making sure the thread
+ descriptor is still valid. */
+extern void __free_tcb (struct pthread *pd) attribute_hidden internal_function;
+
+/* Free allocated stack. */
+extern void __deallocate_stack (struct pthread *pd)
+ attribute_hidden internal_function;
+
+/* Mark all the stacks except for the current one as available. This
+ function also re-initializes the lock for the stack cache. */
+extern void __reclaim_stacks (void) attribute_hidden;
+
+/* Make all threads's stacks executable. */
+extern int __make_stacks_executable (void **stack_endp)
+ internal_function attribute_hidden;
+
+/* longjmp handling. */
+extern void __pthread_cleanup_upto (__jmp_buf target, char *targetframe);
+#if defined NOT_IN_libc && defined IS_IN_libpthread
+hidden_proto (__pthread_cleanup_upto)
+#endif
+
+
+/* Functions with versioned interfaces. */
+extern int __pthread_create_2_1 (pthread_t *newthread,
+ const pthread_attr_t *attr,
+ void *(*start_routine) (void *), void *arg);
+extern int __pthread_create_2_0 (pthread_t *newthread,
+ const pthread_attr_t *attr,
+ void *(*start_routine) (void *), void *arg);
+extern int __pthread_attr_init_2_1 (pthread_attr_t *attr);
+extern int __pthread_attr_init_2_0 (pthread_attr_t *attr);
+
+
+/* Event handlers for libthread_db interface. */
+extern void __nptl_create_event (void);
+extern void __nptl_death_event (void);
+hidden_proto (__nptl_create_event)
+hidden_proto (__nptl_death_event)
+
+/* Register the generation counter in the libpthread with the libc. */
+#ifdef TLS_MULTIPLE_THREADS_IN_TCB
+extern void __libc_pthread_init (unsigned long int *ptr,
+ void (*reclaim) (void),
+ const struct pthread_functions *functions);
+#else
+extern int *__libc_pthread_init (unsigned long int *ptr,
+ void (*reclaim) (void),
+ const struct pthread_functions *functions);
+
+/* Variable set to a nonzero value if more than one thread runs or ran. */
+extern int __pthread_multiple_threads attribute_hidden;
+/* Pointer to the corresponding variable in libc. */
+extern int *__libc_multiple_threads_ptr attribute_hidden;
+#endif
+
+/* Find a thread given its TID. */
+extern struct pthread *__find_thread_by_id (pid_t tid) attribute_hidden
+#ifdef SHARED
+;
+#else
+weak_function;
+#define __find_thread_by_id(tid) \
+ (__find_thread_by_id ? (__find_thread_by_id) (tid) : (struct pthread *) NULL)
+#endif
+
+extern void __pthread_init_static_tls (struct link_map *) attribute_hidden;
+
+
+/* Namespace save aliases. */
+extern int __pthread_getschedparam (pthread_t thread_id, int *policy,
+ struct sched_param *param);
+extern int __pthread_setschedparam (pthread_t thread_id, int policy,
+ const struct sched_param *param);
+extern int __pthread_setcancelstate (int state, int *oldstate);
+extern int __pthread_mutex_init (pthread_mutex_t *__mutex,
+ const pthread_mutexattr_t *__mutexattr);
+extern int __pthread_mutex_init_internal (pthread_mutex_t *__mutex,
+ const pthread_mutexattr_t *__mutexattr)
+ attribute_hidden;
+extern int __pthread_mutex_destroy (pthread_mutex_t *__mutex);
+extern int __pthread_mutex_destroy_internal (pthread_mutex_t *__mutex)
+ attribute_hidden;
+extern int __pthread_mutex_trylock (pthread_mutex_t *_mutex);
+extern int __pthread_mutex_lock (pthread_mutex_t *__mutex);
+extern int __pthread_mutex_lock_internal (pthread_mutex_t *__mutex)
+ attribute_hidden;
+extern int __pthread_mutex_cond_lock (pthread_mutex_t *__mutex)
+ attribute_hidden internal_function;
+extern void __pthread_mutex_cond_lock_adjust (pthread_mutex_t *__mutex)
+ attribute_hidden internal_function;
+extern int __pthread_mutex_unlock (pthread_mutex_t *__mutex);
+extern int __pthread_mutex_unlock_internal (pthread_mutex_t *__mutex)
+ attribute_hidden;
+extern int __pthread_mutex_unlock_usercnt (pthread_mutex_t *__mutex,
+ int __decr)
+ attribute_hidden internal_function;
+extern int __pthread_mutexattr_init (pthread_mutexattr_t *attr);
+extern int __pthread_mutexattr_destroy (pthread_mutexattr_t *attr);
+extern int __pthread_mutexattr_settype (pthread_mutexattr_t *attr, int kind);
+extern int __pthread_attr_destroy (pthread_attr_t *attr);
+extern int __pthread_attr_getdetachstate (const pthread_attr_t *attr,
+ int *detachstate);
+extern int __pthread_attr_setdetachstate (pthread_attr_t *attr,
+ int detachstate);
+extern int __pthread_attr_getinheritsched (const pthread_attr_t *attr,
+ int *inherit);
+extern int __pthread_attr_setinheritsched (pthread_attr_t *attr, int inherit);
+extern int __pthread_attr_getschedparam (const pthread_attr_t *attr,
+ struct sched_param *param);
+extern int __pthread_attr_setschedparam (pthread_attr_t *attr,
+ const struct sched_param *param);
+extern int __pthread_attr_getschedpolicy (const pthread_attr_t *attr,
+ int *policy);
+extern int __pthread_attr_setschedpolicy (pthread_attr_t *attr, int policy);
+extern int __pthread_attr_getscope (const pthread_attr_t *attr, int *scope);
+extern int __pthread_attr_setscope (pthread_attr_t *attr, int scope);
+extern int __pthread_attr_getstackaddr (const pthread_attr_t *__restrict
+ __attr, void **__restrict __stackaddr);
+extern int __pthread_attr_setstackaddr (pthread_attr_t *__attr,
+ void *__stackaddr);
+extern int __pthread_attr_getstacksize (const pthread_attr_t *__restrict
+ __attr,
+ size_t *__restrict __stacksize);
+extern int __pthread_attr_setstacksize (pthread_attr_t *__attr,
+ size_t __stacksize);
+extern int __pthread_attr_getstack (const pthread_attr_t *__restrict __attr,
+ void **__restrict __stackaddr,
+ size_t *__restrict __stacksize);
+extern int __pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr,
+ size_t __stacksize);
+extern int __pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock,
+ const pthread_rwlockattr_t *__restrict
+ __attr);
+extern int __pthread_rwlock_destroy (pthread_rwlock_t *__rwlock);
+extern int __pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock);
+extern int __pthread_rwlock_rdlock_internal (pthread_rwlock_t *__rwlock);
+extern int __pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock);
+extern int __pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock);
+extern int __pthread_rwlock_wrlock_internal (pthread_rwlock_t *__rwlock);
+extern int __pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock);
+extern int __pthread_rwlock_unlock (pthread_rwlock_t *__rwlock);
+extern int __pthread_rwlock_unlock_internal (pthread_rwlock_t *__rwlock);
+extern int __pthread_cond_broadcast (pthread_cond_t *cond);
+extern int __pthread_cond_destroy (pthread_cond_t *cond);
+extern int __pthread_cond_init (pthread_cond_t *cond,
+ const pthread_condattr_t *cond_attr);
+extern int __pthread_cond_signal (pthread_cond_t *cond);
+extern int __pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex);
+extern int __pthread_cond_timedwait (pthread_cond_t *cond,
+ pthread_mutex_t *mutex,
+ const struct timespec *abstime);
+extern int __pthread_condattr_destroy (pthread_condattr_t *attr);
+extern int __pthread_condattr_init (pthread_condattr_t *attr);
+extern int __pthread_key_create (pthread_key_t *key, void (*destr) (void *));
+extern int __pthread_key_create_internal (pthread_key_t *key,
+ void (*destr) (void *));
+extern void *__pthread_getspecific (pthread_key_t key);
+extern void *__pthread_getspecific_internal (pthread_key_t key);
+extern int __pthread_setspecific (pthread_key_t key, const void *value);
+extern int __pthread_setspecific_internal (pthread_key_t key,
+ const void *value);
+extern int __pthread_once (pthread_once_t *once_control,
+ void (*init_routine) (void));
+extern int __pthread_once_internal (pthread_once_t *once_control,
+ void (*init_routine) (void));
+extern int __pthread_atfork (void (*prepare) (void), void (*parent) (void),
+ void (*child) (void));
+extern pthread_t __pthread_self (void);
+extern int __pthread_equal (pthread_t thread1, pthread_t thread2);
+extern int __pthread_kill (pthread_t threadid, int signo);
+extern void __pthread_exit (void *value);
+extern int __pthread_setcanceltype (int type, int *oldtype);
+extern int __pthread_enable_asynccancel (void) attribute_hidden;
+extern void __pthread_disable_asynccancel (int oldtype)
+ internal_function attribute_hidden;
+
+extern int __pthread_cond_broadcast_2_0 (pthread_cond_2_0_t *cond);
+extern int __pthread_cond_destroy_2_0 (pthread_cond_2_0_t *cond);
+extern int __pthread_cond_init_2_0 (pthread_cond_2_0_t *cond,
+ const pthread_condattr_t *cond_attr);
+extern int __pthread_cond_signal_2_0 (pthread_cond_2_0_t *cond);
+extern int __pthread_cond_timedwait_2_0 (pthread_cond_2_0_t *cond,
+ pthread_mutex_t *mutex,
+ const struct timespec *abstime);
+extern int __pthread_cond_wait_2_0 (pthread_cond_2_0_t *cond,
+ pthread_mutex_t *mutex);
+
+extern int __pthread_getaffinity_np (pthread_t th, size_t cpusetsize,
+ cpu_set_t *cpuset);
+
+/* The two functions are in libc.so and not exported. */
+extern int __libc_enable_asynccancel (void) attribute_hidden;
+extern void __libc_disable_asynccancel (int oldtype)
+ internal_function attribute_hidden;
+
+
+/* The two functions are in librt.so and not exported. */
+extern int __librt_enable_asynccancel (void) attribute_hidden;
+extern void __librt_disable_asynccancel (int oldtype)
+ internal_function attribute_hidden;
+
+#ifdef IS_IN_libpthread
+/* Special versions which use non-exported functions. */
+extern void __pthread_cleanup_push (struct _pthread_cleanup_buffer *buffer,
+ void (*routine) (void *), void *arg)
+ attribute_hidden;
+# undef pthread_cleanup_push
+# define pthread_cleanup_push(routine,arg) \
+ { struct _pthread_cleanup_buffer _buffer; \
+ __pthread_cleanup_push (&_buffer, (routine), (arg));
+
+extern void __pthread_cleanup_pop (struct _pthread_cleanup_buffer *buffer,
+ int execute) attribute_hidden;
+# undef pthread_cleanup_pop
+# define pthread_cleanup_pop(execute) \
+ __pthread_cleanup_pop (&_buffer, (execute)); }
+#endif
+
+extern void __pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *buffer,
+ void (*routine) (void *), void *arg);
+extern void __pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *buffer,
+ int execute);
+
+/* Old cleanup interfaces, still used in libc.so. */
+extern void _pthread_cleanup_push (struct _pthread_cleanup_buffer *buffer,
+ void (*routine) (void *), void *arg);
+extern void _pthread_cleanup_pop (struct _pthread_cleanup_buffer *buffer,
+ int execute);
+extern void _pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *buffer,
+ void (*routine) (void *), void *arg);
+extern void _pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *buffer,
+ int execute);
+
+extern void __nptl_deallocate_tsd (void)
+#ifdef SHARED
+ attribute_hidden
+#else
+ __attribute ((weak))
+#endif
+ ;
+
+extern int __nptl_setxid (struct xid_command *cmdp) attribute_hidden;
+
+extern void __free_stacks (size_t limit) attribute_hidden;
+
+extern void __wait_lookup_done (void) attribute_hidden;
+
+#ifdef SHARED
+# define PTHREAD_STATIC_FN_REQUIRE(name)
+#else
+# define PTHREAD_STATIC_FN_REQUIRE(name) __asm__ (".globl " #name);
+#endif
+
+
+#ifndef __NR_set_robust_list
+/* XXX For the time being... Once we can rely on the kernel headers
+ having the definition remove these lines. */
+# if defined __i386__
+# define __NR_set_robust_list 311
+# elif defined __x86_64__
+# define __NR_set_robust_list 273
+# endif
+#endif
+
+#endif /* pthreadP.h */
diff --git a/libpthread/nptl/pthread_atfork.c b/libpthread/nptl/pthread_atfork.c
new file mode 100644
index 000000000..39ac3e262
--- /dev/null
+++ b/libpthread/nptl/pthread_atfork.c
@@ -0,0 +1,63 @@
+/* Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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.
+
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "pthreadP.h"
+#include <fork.h>
+
+/* This is defined by newer gcc version unique for each module. */
+extern void *__dso_handle __attribute__ ((__weak__,
+ __visibility__ ("hidden")));
+
+
+/* Hide the symbol so that no definition but the one locally in the
+ executable or DSO is used. */
+int
+#ifndef __pthread_atfork
+/* Don't mark the compatibility function as hidden. */
+attribute_hidden
+#endif
+__pthread_atfork (
+ void (*prepare) (void),
+ void (*parent) (void),
+ void (*child) (void))
+{
+ return __register_atfork (prepare, parent, child,
+ &__dso_handle == NULL ? NULL : __dso_handle);
+}
+#ifndef __pthread_atfork
+extern int pthread_atfork (void (*prepare) (void), void (*parent) (void),
+ void (*child) (void)) attribute_hidden;
+strong_alias (__pthread_atfork, pthread_atfork)
+#endif
diff --git a/libpthread/nptl/pthread_attr_destroy.c b/libpthread/nptl/pthread_attr_destroy.c
new file mode 100644
index 000000000..bdf43e662
--- /dev/null
+++ b/libpthread/nptl/pthread_attr_destroy.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <assert.h>
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+#include "pthreadP.h"
+
+int
+attribute_protected
+__pthread_attr_destroy (
+ pthread_attr_t *attr)
+{
+ struct pthread_attr *iattr;
+
+ assert (sizeof (*attr) >= sizeof (struct pthread_attr));
+ iattr = (struct pthread_attr *) attr;
+
+ /* The affinity CPU set might be allocated dynamically. */
+ free (iattr->cpuset);
+
+ return 0;
+}
+strong_alias (__pthread_attr_destroy, pthread_attr_destroy)
diff --git a/libpthread/nptl/pthread_attr_getdetachstate.c b/libpthread/nptl/pthread_attr_getdetachstate.c
new file mode 100644
index 000000000..7d9ff003b
--- /dev/null
+++ b/libpthread/nptl/pthread_attr_getdetachstate.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <assert.h>
+#include "pthreadP.h"
+
+
+int
+attribute_protected
+__pthread_attr_getdetachstate (
+ const pthread_attr_t *attr,
+ int *detachstate)
+{
+ struct pthread_attr *iattr;
+
+ assert (sizeof (*attr) >= sizeof (struct pthread_attr));
+ iattr = (struct pthread_attr *) attr;
+
+ *detachstate = (iattr->flags & ATTR_FLAG_DETACHSTATE
+ ? PTHREAD_CREATE_DETACHED : PTHREAD_CREATE_JOINABLE);
+
+ return 0;
+}
+strong_alias (__pthread_attr_getdetachstate, pthread_attr_getdetachstate)
diff --git a/libpthread/nptl/pthread_attr_getguardsize.c b/libpthread/nptl/pthread_attr_getguardsize.c
new file mode 100644
index 000000000..3fba0b8c5
--- /dev/null
+++ b/libpthread/nptl/pthread_attr_getguardsize.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <assert.h>
+#include "pthreadP.h"
+
+
+int
+pthread_attr_getguardsize (const pthread_attr_t *attr, size_t *guardsize)
+{
+ struct pthread_attr *iattr;
+
+ assert (sizeof (*attr) >= sizeof (struct pthread_attr));
+ iattr = (struct pthread_attr *) attr;
+
+ *guardsize = iattr->guardsize;
+
+ return 0;
+}
diff --git a/libpthread/nptl/pthread_attr_getinheritsched.c b/libpthread/nptl/pthread_attr_getinheritsched.c
new file mode 100644
index 000000000..4af44dd95
--- /dev/null
+++ b/libpthread/nptl/pthread_attr_getinheritsched.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <assert.h>
+#include "pthreadP.h"
+
+
+int
+attribute_protected
+__pthread_attr_getinheritsched (
+ const pthread_attr_t *attr,
+ int *inherit)
+{
+ struct pthread_attr *iattr;
+
+ assert (sizeof (*attr) >= sizeof (struct pthread_attr));
+ iattr = (struct pthread_attr *) attr;
+
+ /* Store the current values. */
+ *inherit = (iattr->flags & ATTR_FLAG_NOTINHERITSCHED
+ ? PTHREAD_EXPLICIT_SCHED : PTHREAD_INHERIT_SCHED);
+
+ return 0;
+}
+strong_alias (__pthread_attr_getinheritsched, pthread_attr_getinheritsched)
diff --git a/libpthread/nptl/pthread_attr_getschedparam.c b/libpthread/nptl/pthread_attr_getschedparam.c
new file mode 100644
index 000000000..dbcecaff6
--- /dev/null
+++ b/libpthread/nptl/pthread_attr_getschedparam.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <assert.h>
+#include <string.h>
+#include "pthreadP.h"
+
+
+int
+attribute_protected
+__pthread_attr_getschedparam (
+ const pthread_attr_t *attr,
+ struct sched_param *param)
+{
+ struct pthread_attr *iattr;
+
+ assert (sizeof (*attr) >= sizeof (struct pthread_attr));
+ iattr = (struct pthread_attr *) attr;
+
+ /* Copy the current values. */
+ memcpy (param, &iattr->schedparam, sizeof (struct sched_param));
+
+ return 0;
+}
+strong_alias (__pthread_attr_getschedparam, pthread_attr_getschedparam)
diff --git a/libpthread/nptl/pthread_attr_getschedpolicy.c b/libpthread/nptl/pthread_attr_getschedpolicy.c
new file mode 100644
index 000000000..23f348ca5
--- /dev/null
+++ b/libpthread/nptl/pthread_attr_getschedpolicy.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <assert.h>
+#include "pthreadP.h"
+
+
+int
+attribute_protected
+__pthread_attr_getschedpolicy (
+ const pthread_attr_t *attr,
+ int *policy)
+{
+ struct pthread_attr *iattr;
+
+ assert (sizeof (*attr) >= sizeof (struct pthread_attr));
+ iattr = (struct pthread_attr *) attr;
+
+ /* Store the current values. */
+ *policy = iattr->schedpolicy;
+
+ return 0;
+}
+strong_alias (__pthread_attr_getschedpolicy, pthread_attr_getschedpolicy)
diff --git a/libpthread/nptl/pthread_attr_getscope.c b/libpthread/nptl/pthread_attr_getscope.c
new file mode 100644
index 000000000..edc5c76b1
--- /dev/null
+++ b/libpthread/nptl/pthread_attr_getscope.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <assert.h>
+#include "pthreadP.h"
+
+
+int
+attribute_protected
+__pthread_attr_getscope (
+ const pthread_attr_t *attr,
+ int *scope)
+{
+ struct pthread_attr *iattr;
+
+ assert (sizeof (*attr) >= sizeof (struct pthread_attr));
+ iattr = (struct pthread_attr *) attr;
+
+ /* Store the current values. */
+ *scope = (iattr->flags & ATTR_FLAG_SCOPEPROCESS
+ ? PTHREAD_SCOPE_PROCESS : PTHREAD_SCOPE_SYSTEM);
+
+ return 0;
+}
+strong_alias (__pthread_attr_getscope, pthread_attr_getscope)
diff --git a/libpthread/nptl/pthread_attr_getstack.c b/libpthread/nptl/pthread_attr_getstack.c
new file mode 100644
index 000000000..27eb7ff65
--- /dev/null
+++ b/libpthread/nptl/pthread_attr_getstack.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <assert.h>
+#include "pthreadP.h"
+
+
+int
+__pthread_attr_getstack (
+ const pthread_attr_t *attr,
+ void **stackaddr,
+ size_t *stacksize)
+{
+ struct pthread_attr *iattr;
+
+ assert (sizeof (*attr) >= sizeof (struct pthread_attr));
+ iattr = (struct pthread_attr *) attr;
+
+ /* Store the result. */
+ *stackaddr = (char *) iattr->stackaddr - iattr->stacksize;
+ *stacksize = iattr->stacksize;
+
+ return 0;
+}
+strong_alias (__pthread_attr_getstack, pthread_attr_getstack)
diff --git a/libpthread/nptl/pthread_attr_getstackaddr.c b/libpthread/nptl/pthread_attr_getstackaddr.c
new file mode 100644
index 000000000..272a4c0b9
--- /dev/null
+++ b/libpthread/nptl/pthread_attr_getstackaddr.c
@@ -0,0 +1,41 @@
+/* Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <assert.h>
+#include <errno.h>
+#include "pthreadP.h"
+
+
+int
+__pthread_attr_getstackaddr (
+ const pthread_attr_t *attr,
+ void **stackaddr)
+{
+ struct pthread_attr *iattr;
+
+ assert (sizeof (*attr) >= sizeof (struct pthread_attr));
+ iattr = (struct pthread_attr *) attr;
+
+ /* Some code assumes this function to work even if no stack address
+ has been set. Let them figure it out for themselves what the
+ value means. Simply store the result. */
+ *stackaddr = iattr->stackaddr;
+
+ return 0;
+}
+strong_alias (__pthread_attr_getstackaddr, pthread_attr_getstackaddr)
diff --git a/libpthread/nptl/pthread_attr_getstacksize.c b/libpthread/nptl/pthread_attr_getstacksize.c
new file mode 100644
index 000000000..5f20dffc5
--- /dev/null
+++ b/libpthread/nptl/pthread_attr_getstacksize.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <assert.h>
+#include "pthreadP.h"
+
+
+int
+__pthread_attr_getstacksize (
+ const pthread_attr_t *attr,
+ size_t *stacksize)
+{
+ struct pthread_attr *iattr;
+
+ assert (sizeof (*attr) >= sizeof (struct pthread_attr));
+ iattr = (struct pthread_attr *) attr;
+
+ /* If the user has not set a stack size we return what the system
+ will use as the default. */
+ *stacksize = iattr->stacksize ?: __default_stacksize;
+
+ return 0;
+}
+strong_alias (__pthread_attr_getstacksize, pthread_attr_getstacksize)
diff --git a/libpthread/nptl/pthread_attr_init.c b/libpthread/nptl/pthread_attr_init.c
new file mode 100644
index 000000000..3e38f37e8
--- /dev/null
+++ b/libpthread/nptl/pthread_attr_init.c
@@ -0,0 +1,50 @@
+/* Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <assert.h>
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+#include "pthreadP.h"
+
+
+struct pthread_attr *__attr_list;
+int __attr_list_lock = LLL_LOCK_INITIALIZER;
+
+
+int
+attribute_protected
+__pthread_attr_init_2_1 (
+ pthread_attr_t *attr)
+{
+ struct pthread_attr *iattr;
+
+ /* Many elements are initialized to zero so let us do it all at
+ once. This also takes care of clearing the bytes which are not
+ internally used. */
+ memset (attr, '\0', __SIZEOF_PTHREAD_ATTR_T);
+
+ assert (sizeof (*attr) >= sizeof (struct pthread_attr));
+ iattr = (struct pthread_attr *) attr;
+
+ /* Default guard size specified by the standard. */
+ iattr->guardsize = getpagesize ();
+
+ return 0;
+}
+weak_alias(__pthread_attr_init_2_1, pthread_attr_init)
diff --git a/libpthread/nptl/pthread_attr_setdetachstate.c b/libpthread/nptl/pthread_attr_setdetachstate.c
new file mode 100644
index 000000000..2ecba26cc
--- /dev/null
+++ b/libpthread/nptl/pthread_attr_setdetachstate.c
@@ -0,0 +1,46 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <assert.h>
+#include <errno.h>
+#include "pthreadP.h"
+
+
+int
+attribute_protected
+__pthread_attr_setdetachstate (pthread_attr_t *attr, int detachstate)
+{
+ struct pthread_attr *iattr;
+
+ assert (sizeof (*attr) >= sizeof (struct pthread_attr));
+ iattr = (struct pthread_attr *) attr;
+
+ /* Catch invalid values. */
+ if (detachstate != PTHREAD_CREATE_DETACHED
+ && __builtin_expect (detachstate != PTHREAD_CREATE_JOINABLE, 0))
+ return EINVAL;
+
+ /* Set the flag. It is nonzero if threads are created detached. */
+ if (detachstate == PTHREAD_CREATE_DETACHED)
+ iattr->flags |= ATTR_FLAG_DETACHSTATE;
+ else
+ iattr->flags &= ~ATTR_FLAG_DETACHSTATE;
+
+ return 0;
+}
+strong_alias (__pthread_attr_setdetachstate, pthread_attr_setdetachstate)
diff --git a/libpthread/nptl/pthread_attr_setguardsize.c b/libpthread/nptl/pthread_attr_setguardsize.c
new file mode 100644
index 000000000..6360b37f7
--- /dev/null
+++ b/libpthread/nptl/pthread_attr_setguardsize.c
@@ -0,0 +1,37 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <assert.h>
+#include "pthreadP.h"
+
+
+int
+pthread_attr_setguardsize (pthread_attr_t* attr, size_t guardsize)
+{
+ struct pthread_attr *iattr;
+
+ assert (sizeof (*attr) >= sizeof (struct pthread_attr));
+ iattr = (struct pthread_attr *) attr;
+
+ /* Note that we don't round the value here. The standard requires
+ that subsequent pthread_attr_getguardsize calls return the value
+ set by the user. */
+ iattr->guardsize = guardsize;
+
+ return 0;
+}
diff --git a/libpthread/nptl/pthread_attr_setinheritsched.c b/libpthread/nptl/pthread_attr_setinheritsched.c
new file mode 100644
index 000000000..aa67abea0
--- /dev/null
+++ b/libpthread/nptl/pthread_attr_setinheritsched.c
@@ -0,0 +1,47 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <assert.h>
+#include <errno.h>
+#include "pthreadP.h"
+
+
+int
+attribute_protected
+__pthread_attr_setinheritsched (
+ pthread_attr_t *attr,
+ int inherit)
+{
+ struct pthread_attr *iattr;
+
+ assert (sizeof (*attr) >= sizeof (struct pthread_attr));
+ iattr = (struct pthread_attr *) attr;
+
+ /* Catch invalid values. */
+ if (inherit != PTHREAD_INHERIT_SCHED && inherit != PTHREAD_EXPLICIT_SCHED)
+ return EINVAL;
+
+ /* Store the new values. */
+ if (inherit != PTHREAD_INHERIT_SCHED)
+ iattr->flags |= ATTR_FLAG_NOTINHERITSCHED;
+ else
+ iattr->flags &= ~ATTR_FLAG_NOTINHERITSCHED;
+
+ return 0;
+}
+strong_alias (__pthread_attr_setinheritsched, pthread_attr_setinheritsched)
diff --git a/libpthread/nptl/pthread_attr_setschedparam.c b/libpthread/nptl/pthread_attr_setschedparam.c
new file mode 100644
index 000000000..4552f2d18
--- /dev/null
+++ b/libpthread/nptl/pthread_attr_setschedparam.c
@@ -0,0 +1,48 @@
+/* Copyright (C) 2002, 2004, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <assert.h>
+#include <errno.h>
+#include <string.h>
+#include "pthreadP.h"
+
+
+int
+attribute_protected
+__pthread_attr_setschedparam (
+ pthread_attr_t *attr,
+ const struct sched_param *param)
+{
+ assert (sizeof (*attr) >= sizeof (struct pthread_attr));
+ struct pthread_attr *iattr = (struct pthread_attr *) attr;
+
+ int min = sched_get_priority_min (iattr->schedpolicy);
+ int max = sched_get_priority_max (iattr->schedpolicy);
+ if (min == -1 || max == -1
+ || param->sched_priority > max || param->sched_priority < min)
+ return EINVAL;
+
+ /* Copy the new values. */
+ memcpy (&iattr->schedparam, param, sizeof (struct sched_param));
+
+ /* Remember we set the value. */
+ iattr->flags |= ATTR_FLAG_SCHED_SET;
+
+ return 0;
+}
+strong_alias (__pthread_attr_setschedparam, pthread_attr_setschedparam)
diff --git a/libpthread/nptl/pthread_attr_setschedpolicy.c b/libpthread/nptl/pthread_attr_setschedpolicy.c
new file mode 100644
index 000000000..df94a4794
--- /dev/null
+++ b/libpthread/nptl/pthread_attr_setschedpolicy.c
@@ -0,0 +1,47 @@
+/* Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <assert.h>
+#include <errno.h>
+#include "pthreadP.h"
+
+
+int
+attribute_protected
+__pthread_attr_setschedpolicy (
+ pthread_attr_t *attr,
+ int policy)
+{
+ struct pthread_attr *iattr;
+
+ assert (sizeof (*attr) >= sizeof (struct pthread_attr));
+ iattr = (struct pthread_attr *) attr;
+
+ /* Catch invalid values. */
+ if (policy != SCHED_OTHER && policy != SCHED_FIFO && policy != SCHED_RR)
+ return EINVAL;
+
+ /* Store the new values. */
+ iattr->schedpolicy = policy;
+
+ /* Remember we set the value. */
+ iattr->flags |= ATTR_FLAG_POLICY_SET;
+
+ return 0;
+}
+strong_alias (__pthread_attr_setschedpolicy, pthread_attr_setschedpolicy)
diff --git a/libpthread/nptl/pthread_attr_setscope.c b/libpthread/nptl/pthread_attr_setscope.c
new file mode 100644
index 000000000..497b97ae1
--- /dev/null
+++ b/libpthread/nptl/pthread_attr_setscope.c
@@ -0,0 +1,51 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <assert.h>
+#include <errno.h>
+#include "pthreadP.h"
+
+
+int
+attribute_protected
+__pthread_attr_setscope (
+ pthread_attr_t *attr,
+ int scope)
+{
+ struct pthread_attr *iattr;
+
+ assert (sizeof (*attr) >= sizeof (struct pthread_attr));
+ iattr = (struct pthread_attr *) attr;
+
+ /* Catch invalid values. */
+ switch (scope)
+ {
+ case PTHREAD_SCOPE_SYSTEM:
+ iattr->flags &= ~ATTR_FLAG_SCOPEPROCESS;
+ break;
+
+ case PTHREAD_SCOPE_PROCESS:
+ return ENOTSUP;
+
+ default:
+ return EINVAL;
+ }
+
+ return 0;
+}
+strong_alias (__pthread_attr_setscope, pthread_attr_setscope)
diff --git a/libpthread/nptl/pthread_attr_setstack.c b/libpthread/nptl/pthread_attr_setstack.c
new file mode 100644
index 000000000..f35ed2ef1
--- /dev/null
+++ b/libpthread/nptl/pthread_attr_setstack.c
@@ -0,0 +1,55 @@
+/* Copyright (C) 2002, 2003, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <assert.h>
+#include <errno.h>
+#include <limits.h>
+#include "pthreadP.h"
+
+
+int
+__pthread_attr_setstack (
+ pthread_attr_t *attr,
+ void *stackaddr,
+ size_t stacksize)
+{
+ struct pthread_attr *iattr;
+
+ assert (sizeof (*attr) >= sizeof (struct pthread_attr));
+ iattr = (struct pthread_attr *) attr;
+
+ /* Catch invalid sizes. */
+ if (stacksize < PTHREAD_STACK_MIN)
+ return EINVAL;
+
+#ifdef EXTRA_PARAM_CHECKS
+ EXTRA_PARAM_CHECKS;
+#endif
+
+ iattr->stacksize = stacksize;
+ iattr->stackaddr = (char *) stackaddr + stacksize;
+ iattr->flags |= ATTR_FLAG_STACKADDR;
+
+ return 0;
+}
+
+#if PTHREAD_STACK_MIN == 16384
+strong_alias(__pthread_attr_setstack, pthread_attr_setstack)
+#else
+weak_alias(__pthread_attr_setstack, pthread_attr_setstack)
+#endif
diff --git a/libpthread/nptl/pthread_attr_setstackaddr.c b/libpthread/nptl/pthread_attr_setstackaddr.c
new file mode 100644
index 000000000..253e8f7bb
--- /dev/null
+++ b/libpthread/nptl/pthread_attr_setstackaddr.c
@@ -0,0 +1,43 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <assert.h>
+#include <errno.h>
+#include "pthreadP.h"
+
+
+int
+__pthread_attr_setstackaddr (
+ pthread_attr_t *attr,
+ void *stackaddr)
+{
+ struct pthread_attr *iattr;
+
+#ifdef EXTRA_PARAM_CHECKS
+ EXTRA_PARAM_CHECKS;
+#endif
+
+ assert (sizeof (*attr) >= sizeof (struct pthread_attr));
+ iattr = (struct pthread_attr *) attr;
+
+ iattr->stackaddr = stackaddr;
+ iattr->flags |= ATTR_FLAG_STACKADDR;
+
+ return 0;
+}
+strong_alias (__pthread_attr_setstackaddr, pthread_attr_setstackaddr)
diff --git a/libpthread/nptl/pthread_attr_setstacksize.c b/libpthread/nptl/pthread_attr_setstacksize.c
new file mode 100644
index 000000000..9f97ccc05
--- /dev/null
+++ b/libpthread/nptl/pthread_attr_setstacksize.c
@@ -0,0 +1,48 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <assert.h>
+#include <errno.h>
+#include <limits.h>
+#include "pthreadP.h"
+
+
+int
+__pthread_attr_setstacksize (
+ pthread_attr_t *attr,
+ size_t stacksize)
+{
+ struct pthread_attr *iattr;
+
+ assert (sizeof (*attr) >= sizeof (struct pthread_attr));
+ iattr = (struct pthread_attr *) attr;
+
+ /* Catch invalid sizes. */
+ if (stacksize < PTHREAD_STACK_MIN)
+ return EINVAL;
+
+ iattr->stacksize = stacksize;
+
+ return 0;
+}
+
+#if PTHREAD_STACK_MIN == 16384
+strong_alias(__pthread_attr_setstacksize, pthread_attr_setstacksize)
+#else
+weak_alias(__pthread_attr_setstacksize, pthread_attr_setstacksize)
+#endif
diff --git a/libpthread/nptl/pthread_barrierattr_destroy.c b/libpthread/nptl/pthread_barrierattr_destroy.c
new file mode 100644
index 000000000..983512b45
--- /dev/null
+++ b/libpthread/nptl/pthread_barrierattr_destroy.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 "pthreadP.h"
+
+
+int
+pthread_barrierattr_destroy (pthread_barrierattr_t *attr)
+{
+ /* Nothing to do. */
+
+ return 0;
+}
diff --git a/libpthread/nptl/pthread_barrierattr_getpshared.c b/libpthread/nptl/pthread_barrierattr_getpshared.c
new file mode 100644
index 000000000..6ee739dee
--- /dev/null
+++ b/libpthread/nptl/pthread_barrierattr_getpshared.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 "pthreadP.h"
+
+
+int
+pthread_barrierattr_getpshared (
+ const pthread_barrierattr_t *attr,
+ int *pshared)
+{
+ *pshared = ((const struct pthread_barrierattr *) attr)->pshared;
+
+ return 0;
+}
diff --git a/libpthread/nptl/pthread_barrierattr_init.c b/libpthread/nptl/pthread_barrierattr_init.c
new file mode 100644
index 000000000..748b4ad29
--- /dev/null
+++ b/libpthread/nptl/pthread_barrierattr_init.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 "pthreadP.h"
+
+
+int
+pthread_barrierattr_init (pthread_barrierattr_t *attr)
+{
+ ((struct pthread_barrierattr *) attr)->pshared = PTHREAD_PROCESS_PRIVATE;
+
+ return 0;
+}
diff --git a/libpthread/nptl/pthread_barrierattr_setpshared.c b/libpthread/nptl/pthread_barrierattr_setpshared.c
new file mode 100644
index 000000000..6dee32df4
--- /dev/null
+++ b/libpthread/nptl/pthread_barrierattr_setpshared.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include "pthreadP.h"
+
+
+int
+pthread_barrierattr_setpshared (
+ pthread_barrierattr_t *attr,
+ int pshared)
+{
+ struct pthread_barrierattr *iattr;
+
+ if (pshared != PTHREAD_PROCESS_PRIVATE
+ && __builtin_expect (pshared != PTHREAD_PROCESS_SHARED, 0))
+ return EINVAL;
+
+ iattr = (struct pthread_barrierattr *) attr;
+
+ iattr->pshared = pshared;
+
+ return 0;
+}
diff --git a/libpthread/nptl/pthread_cancel.c b/libpthread/nptl/pthread_cancel.c
new file mode 100644
index 000000000..a8ba3c8ce
--- /dev/null
+++ b/libpthread/nptl/pthread_cancel.c
@@ -0,0 +1,107 @@
+/* Copyright (C) 2002, 2003, 2004, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <signal.h>
+#include "pthreadP.h"
+#include "atomic.h"
+#include <sysdep.h>
+#include <bits/kernel-features.h>
+
+
+int
+pthread_cancel (
+ pthread_t th)
+{
+ volatile struct pthread *pd = (volatile struct pthread *) th;
+
+ /* Make sure the descriptor is valid. */
+ if (INVALID_TD_P (pd))
+ /* Not a valid thread handle. */
+ return ESRCH;
+
+#ifdef SHARED
+ pthread_cancel_init ();
+#endif
+ int result = 0;
+ int oldval;
+ int newval;
+ do
+ {
+ again:
+ oldval = pd->cancelhandling;
+ newval = oldval | CANCELING_BITMASK | CANCELED_BITMASK;
+
+ /* Avoid doing unnecessary work. The atomic operation can
+ potentially be expensive if the bug has to be locked and
+ remote cache lines have to be invalidated. */
+ if (oldval == newval)
+ break;
+
+ /* If the cancellation is handled asynchronously just send a
+ signal. We avoid this if possible since it's more
+ expensive. */
+ if (CANCEL_ENABLED_AND_CANCELED_AND_ASYNCHRONOUS (newval))
+ {
+ /* Mark the cancellation as "in progress". */
+ if (atomic_compare_and_exchange_bool_acq (&pd->cancelhandling,
+ oldval | CANCELING_BITMASK,
+ oldval))
+ goto again;
+
+ /* The cancellation handler will take care of marking the
+ thread as canceled. */
+ INTERNAL_SYSCALL_DECL (err);
+
+ /* One comment: The PID field in the TCB can temporarily be
+ changed (in fork). But this must not affect this code
+ here. Since this function would have to be called while
+ the thread is executing fork, it would have to happen in
+ a signal handler. But this is no allowed, pthread_cancel
+ is not guaranteed to be async-safe. */
+ int val;
+#if defined(__ASSUME_TGKILL) && __ASSUME_TGKILL
+ val = INTERNAL_SYSCALL (tgkill, err, 3,
+ THREAD_GETMEM (THREAD_SELF, pid), pd->tid,
+ SIGCANCEL);
+#else
+# ifdef __NR_tgkill
+ val = INTERNAL_SYSCALL (tgkill, err, 3,
+ THREAD_GETMEM (THREAD_SELF, pid), pd->tid,
+ SIGCANCEL);
+ if (INTERNAL_SYSCALL_ERROR_P (val, err)
+ && INTERNAL_SYSCALL_ERRNO (val, err) == ENOSYS)
+# endif
+ val = INTERNAL_SYSCALL (tkill, err, 2, pd->tid, SIGCANCEL);
+#endif
+
+ if (INTERNAL_SYSCALL_ERROR_P (val, err))
+ result = INTERNAL_SYSCALL_ERRNO (val, err);
+
+ break;
+ }
+ }
+ /* Mark the thread as canceled. This has to be done
+ atomically since other bits could be modified as well. */
+ while (atomic_compare_and_exchange_bool_acq (&pd->cancelhandling, newval,
+ oldval));
+
+ return result;
+}
+
+PTHREAD_STATIC_FN_REQUIRE (pthread_create)
diff --git a/libpthread/nptl/pthread_clock_gettime.c b/libpthread/nptl/pthread_clock_gettime.c
new file mode 100644
index 000000000..35f8e8a05
--- /dev/null
+++ b/libpthread/nptl/pthread_clock_gettime.c
@@ -0,0 +1,67 @@
+/* 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; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <time.h>
+#include "pthreadP.h"
+
+
+#if HP_TIMING_AVAIL
+int
+__pthread_clock_gettime (clockid_t clock_id, hp_timing_t freq,
+ struct timespec *tp)
+{
+ hp_timing_t tsc;
+
+ /* Get the current counter. */
+ HP_TIMING_NOW (tsc);
+
+ /* This is the ID of the thread we are looking for. */
+ pid_t tid = ((unsigned int) clock_id) >> CLOCK_IDFIELD_SIZE;
+
+ /* Compute the offset since the start time of the process. */
+ if (tid == 0 || tid == THREAD_GETMEM (THREAD_SELF, tid))
+ /* Our own clock. */
+ tsc -= THREAD_GETMEM (THREAD_SELF, cpuclock_offset);
+ else
+ {
+ /* This is more complicated. We have to locate the thread based
+ on the ID. This means walking the list of existing
+ threads. */
+ struct pthread *thread = __find_thread_by_id (tid);
+ if (thread == NULL)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ /* There is a race here. The thread might terminate and the stack
+ become unusable. But this is the user's problem. */
+ tsc -= thread->cpuclock_offset;
+ }
+
+ /* Compute the seconds. */
+ tp->tv_sec = tsc / freq;
+
+ /* And the nanoseconds. This computation should be stable until
+ we get machines with about 16GHz frequency. */
+ tp->tv_nsec = ((tsc % freq) * 1000000000ull) / freq;
+
+ return 0;
+}
+#endif
diff --git a/libpthread/nptl/pthread_clock_settime.c b/libpthread/nptl/pthread_clock_settime.c
new file mode 100644
index 000000000..65aac4f1d
--- /dev/null
+++ b/libpthread/nptl/pthread_clock_settime.c
@@ -0,0 +1,54 @@
+/* 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; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <time.h>
+#include "pthreadP.h"
+
+
+#if HP_TIMING_AVAIL
+int
+__pthread_clock_settime (clockid_t clock_id, hp_timing_t offset)
+{
+ /* This is the ID of the thread we are looking for. */
+ pid_t tid = ((unsigned int) clock_id) >> CLOCK_IDFIELD_SIZE;
+
+ /* Compute the offset since the start time of the process. */
+ if (tid == 0 || tid == THREAD_GETMEM (THREAD_SELF, tid))
+ /* Our own clock. */
+ THREAD_SETMEM (THREAD_SELF, cpuclock_offset, offset);
+ else
+ {
+ /* This is more complicated. We have to locate the thread based
+ on the ID. This means walking the list of existing
+ threads. */
+ struct pthread *thread = __find_thread_by_id (tid);
+ if (thread == NULL)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ /* There is a race here. The thread might terminate and the stack
+ become unusable. But this is the user's problem. */
+ thread->cpuclock_offset = offset;
+ }
+
+ return 0;
+}
+#endif
diff --git a/libpthread/nptl/pthread_cond_destroy.c b/libpthread/nptl/pthread_cond_destroy.c
new file mode 100644
index 000000000..86afddebd
--- /dev/null
+++ b/libpthread/nptl/pthread_cond_destroy.c
@@ -0,0 +1,83 @@
+/* Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include "pthreadP.h"
+
+
+int
+attribute_protected
+__pthread_cond_destroy (
+ pthread_cond_t *cond)
+{
+ int pshared = (cond->__data.__mutex == (void *) ~0l)
+ ? LLL_SHARED : LLL_PRIVATE;
+
+ /* Make sure we are alone. */
+ lll_lock (cond->__data.__lock, pshared);
+
+ if (cond->__data.__total_seq > cond->__data.__wakeup_seq)
+ {
+ /* If there are still some waiters which have not been
+ woken up, this is an application bug. */
+ lll_unlock (cond->__data.__lock, pshared);
+ return EBUSY;
+ }
+
+ /* Tell pthread_cond_*wait that this condvar is being destroyed. */
+ cond->__data.__total_seq = -1ULL;
+
+ /* If there are waiters which have been already signalled or
+ broadcasted, but still are using the pthread_cond_t structure,
+ pthread_cond_destroy needs to wait for them. */
+ unsigned int nwaiters = cond->__data.__nwaiters;
+
+ if (nwaiters >= (1 << COND_NWAITERS_SHIFT))
+ {
+ /* Wake everybody on the associated mutex in case there are
+ threads that have been requeued to it.
+ Without this, pthread_cond_destroy could block potentially
+ for a long time or forever, as it would depend on other
+ thread's using the mutex.
+ When all threads waiting on the mutex are woken up, pthread_cond_wait
+ only waits for threads to acquire and release the internal
+ condvar lock. */
+ if (cond->__data.__mutex != NULL
+ && cond->__data.__mutex != (void *) ~0l)
+ {
+ pthread_mutex_t *mut = (pthread_mutex_t *) cond->__data.__mutex;
+ lll_futex_wake (&mut->__data.__lock, INT_MAX,
+ PTHREAD_MUTEX_PSHARED (mut));
+ }
+
+ do
+ {
+ lll_unlock (cond->__data.__lock, pshared);
+
+ lll_futex_wait (&cond->__data.__nwaiters, nwaiters, pshared);
+
+ lll_lock (cond->__data.__lock, pshared);
+
+ nwaiters = cond->__data.__nwaiters;
+ }
+ while (nwaiters >= (1 << COND_NWAITERS_SHIFT));
+ }
+
+ return 0;
+}
+weak_alias(__pthread_cond_destroy, pthread_cond_destroy)
diff --git a/libpthread/nptl/pthread_cond_init.c b/libpthread/nptl/pthread_cond_init.c
new file mode 100644
index 000000000..21121bd23
--- /dev/null
+++ b/libpthread/nptl/pthread_cond_init.c
@@ -0,0 +1,46 @@
+/* Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 "pthreadP.h"
+
+
+int
+attribute_protected
+__pthread_cond_init (
+ pthread_cond_t *cond,
+ const pthread_condattr_t *cond_attr)
+{
+ struct pthread_condattr *icond_attr = (struct pthread_condattr *) cond_attr;
+
+ cond->__data.__lock = LLL_LOCK_INITIALIZER;
+ cond->__data.__futex = 0;
+ cond->__data.__nwaiters = (icond_attr != NULL
+ ? ((icond_attr->value >> 1)
+ & ((1 << COND_NWAITERS_SHIFT) - 1))
+ : CLOCK_REALTIME);
+ cond->__data.__total_seq = 0;
+ cond->__data.__wakeup_seq = 0;
+ cond->__data.__woken_seq = 0;
+ cond->__data.__mutex = (icond_attr == NULL || (icond_attr->value & 1) == 0
+ ? NULL : (void *) ~0l);
+ cond->__data.__broadcast_seq = 0;
+
+ return 0;
+}
+weak_alias(__pthread_cond_init, pthread_cond_init)
diff --git a/libpthread/nptl/pthread_condattr_destroy.c b/libpthread/nptl/pthread_condattr_destroy.c
new file mode 100644
index 000000000..a16f32c08
--- /dev/null
+++ b/libpthread/nptl/pthread_condattr_destroy.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 "pthreadP.h"
+
+
+int
+attribute_protected
+__pthread_condattr_destroy (pthread_condattr_t *attr)
+{
+ /* Nothing to be done. */
+ return 0;
+}
+strong_alias (__pthread_condattr_destroy, pthread_condattr_destroy)
diff --git a/libpthread/nptl/pthread_condattr_getclock.c b/libpthread/nptl/pthread_condattr_getclock.c
new file mode 100644
index 000000000..c90a44b99
--- /dev/null
+++ b/libpthread/nptl/pthread_condattr_getclock.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 2003, 2004, 2007 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 "pthreadP.h"
+
+
+int
+pthread_condattr_getclock (
+ const pthread_condattr_t *attr,
+ clockid_t *clock_id)
+{
+ *clock_id = (((((const struct pthread_condattr *) attr)->value) >> 1)
+ & ((1 << COND_NWAITERS_SHIFT) - 1));
+ return 0;
+}
diff --git a/libpthread/nptl/pthread_condattr_getpshared.c b/libpthread/nptl/pthread_condattr_getpshared.c
new file mode 100644
index 000000000..b26f30c36
--- /dev/null
+++ b/libpthread/nptl/pthread_condattr_getpshared.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 "pthreadP.h"
+
+
+int
+pthread_condattr_getpshared (
+ const pthread_condattr_t *attr,
+ int *pshared)
+{
+ *pshared = ((const struct pthread_condattr *) attr)->value & 1;
+
+ return 0;
+}
diff --git a/libpthread/nptl/pthread_condattr_init.c b/libpthread/nptl/pthread_condattr_init.c
new file mode 100644
index 000000000..3c1ee7c68
--- /dev/null
+++ b/libpthread/nptl/pthread_condattr_init.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <string.h>
+#include "pthreadP.h"
+
+
+int
+attribute_protected
+__pthread_condattr_init (pthread_condattr_t *attr)
+{
+ memset (attr, '\0', sizeof (*attr));
+
+ return 0;
+}
+strong_alias (__pthread_condattr_init, pthread_condattr_init)
diff --git a/libpthread/nptl/pthread_condattr_setclock.c b/libpthread/nptl/pthread_condattr_setclock.c
new file mode 100644
index 000000000..b2f4aaf29
--- /dev/null
+++ b/libpthread/nptl/pthread_condattr_setclock.c
@@ -0,0 +1,72 @@
+/* Copyright (C) 2003, 2004, 2007, 2008 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 <assert.h>
+#include <errno.h>
+#include <stdbool.h>
+#include <time.h>
+#include <sysdep.h>
+#include "pthreadP.h"
+#include <bits/kernel-features.h>
+
+
+int
+pthread_condattr_setclock (
+ pthread_condattr_t *attr,
+ clockid_t clock_id)
+{
+ /* Only a few clocks are allowed. CLOCK_REALTIME is always allowed.
+ CLOCK_MONOTONIC only if the kernel has the necessary support. */
+ if (clock_id == CLOCK_MONOTONIC)
+ {
+#ifndef __ASSUME_POSIX_TIMERS
+# ifdef __NR_clock_getres
+ /* Check whether the clock is available. */
+ static int avail;
+
+ if (avail == 0)
+ {
+ struct timespec ts;
+
+ INTERNAL_SYSCALL_DECL (err);
+ int val;
+ val = INTERNAL_SYSCALL (clock_getres, err, 2, CLOCK_MONOTONIC, &ts);
+ avail = INTERNAL_SYSCALL_ERROR_P (val, err) ? -1 : 1;
+ }
+
+ if (avail < 0)
+# endif
+ /* Not available. */
+ return EINVAL;
+#endif
+ }
+ else if (clock_id != CLOCK_REALTIME)
+ /* If more clocks are allowed some day the storing of the clock ID
+ in the pthread_cond_t structure needs to be adjusted. */
+ return EINVAL;
+
+ /* Make sure the value fits in the bits we reserved. */
+ assert (clock_id < (1 << COND_NWAITERS_SHIFT));
+
+ int *valuep = &((struct pthread_condattr *) attr)->value;
+
+ *valuep = ((*valuep & ~(((1 << COND_NWAITERS_SHIFT) - 1) << 1))
+ | (clock_id << 1));
+
+ return 0;
+}
diff --git a/libpthread/nptl/pthread_condattr_setpshared.c b/libpthread/nptl/pthread_condattr_setpshared.c
new file mode 100644
index 000000000..bd07ce086
--- /dev/null
+++ b/libpthread/nptl/pthread_condattr_setpshared.c
@@ -0,0 +1,36 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <pthreadP.h>
+
+int
+pthread_condattr_setpshared (
+ pthread_condattr_t *attr,
+ int pshared)
+{
+ if (pshared != PTHREAD_PROCESS_PRIVATE
+ && __builtin_expect (pshared != PTHREAD_PROCESS_SHARED, 0))
+ return EINVAL;
+
+ int *valuep = &((struct pthread_condattr *) attr)->value;
+
+ *valuep = (*valuep & ~1) | (pshared != PTHREAD_PROCESS_PRIVATE);
+
+ return 0;
+}
diff --git a/libpthread/nptl/pthread_create.c b/libpthread/nptl/pthread_create.c
new file mode 100644
index 000000000..d42a6e75b
--- /dev/null
+++ b/libpthread/nptl/pthread_create.c
@@ -0,0 +1,584 @@
+/* Copyright (C) 2002-2007,2008,2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+#include "pthreadP.h"
+#include <hp-timing.h>
+#include <ldsodefs.h>
+#include <atomic.h>
+#include <resolv.h>
+#include <bits/kernel-features.h>
+
+
+/* Local function to start thread and handle cleanup. */
+static int start_thread (void *arg);
+
+
+/* Nozero if debugging mode is enabled. */
+int __pthread_debug;
+
+/* Globally enabled events. */
+static td_thr_events_t __nptl_threads_events __attribute_used__;
+
+/* Pointer to descriptor with the last event. */
+static struct pthread *__nptl_last_event __attribute_used__;
+
+/* Number of threads running. */
+unsigned int __nptl_nthreads = 1;
+
+
+/* Code to allocate and deallocate a stack. */
+#include "allocatestack.c"
+
+/* Code to create the thread. */
+#include <createthread.c>
+
+
+struct pthread *
+internal_function
+__find_in_stack_list (
+ struct pthread *pd)
+{
+ list_t *entry;
+ struct pthread *result = NULL;
+
+ lll_lock (stack_cache_lock, LLL_PRIVATE);
+
+ list_for_each (entry, &stack_used)
+ {
+ struct pthread *curp;
+
+ curp = list_entry (entry, struct pthread, list);
+ if (curp == pd)
+ {
+ result = curp;
+ break;
+ }
+ }
+
+ if (result == NULL)
+ list_for_each (entry, &__stack_user)
+ {
+ struct pthread *curp;
+
+ curp = list_entry (entry, struct pthread, list);
+ if (curp == pd)
+ {
+ result = curp;
+ break;
+ }
+ }
+
+ lll_unlock (stack_cache_lock, LLL_PRIVATE);
+
+ return result;
+}
+
+
+/* Deallocate POSIX thread-local-storage. */
+void
+attribute_hidden
+__nptl_deallocate_tsd (void)
+{
+ struct pthread *self = THREAD_SELF;
+
+ /* Maybe no data was ever allocated. This happens often so we have
+ a flag for this. */
+ if (THREAD_GETMEM (self, specific_used))
+ {
+ size_t round;
+ size_t cnt;
+
+ round = 0;
+ do
+ {
+ size_t idx;
+
+ /* So far no new nonzero data entry. */
+ THREAD_SETMEM (self, specific_used, false);
+
+ for (cnt = idx = 0; cnt < PTHREAD_KEY_1STLEVEL_SIZE; ++cnt)
+ {
+ struct pthread_key_data *level2;
+
+ level2 = THREAD_GETMEM_NC (self, specific, cnt);
+
+ if (level2 != NULL)
+ {
+ size_t inner;
+
+ for (inner = 0; inner < PTHREAD_KEY_2NDLEVEL_SIZE;
+ ++inner, ++idx)
+ {
+ void *data = level2[inner].data;
+
+ if (data != NULL)
+ {
+ /* Always clear the data. */
+ level2[inner].data = NULL;
+
+ /* Make sure the data corresponds to a valid
+ key. This test fails if the key was
+ deallocated and also if it was
+ re-allocated. It is the user's
+ responsibility to free the memory in this
+ case. */
+ if (level2[inner].seq
+ == __pthread_keys[idx].seq
+ /* It is not necessary to register a destructor
+ function. */
+ && __pthread_keys[idx].destr != NULL)
+ /* Call the user-provided destructor. */
+ __pthread_keys[idx].destr (data);
+ }
+ }
+ }
+ else
+ idx += PTHREAD_KEY_1STLEVEL_SIZE;
+ }
+
+ if (THREAD_GETMEM (self, specific_used) == 0)
+ /* No data has been modified. */
+ goto just_free;
+ }
+ /* We only repeat the process a fixed number of times. */
+ while (__builtin_expect (++round < PTHREAD_DESTRUCTOR_ITERATIONS, 0));
+
+ /* Just clear the memory of the first block for reuse. */
+ memset (&THREAD_SELF->specific_1stblock, '\0',
+ sizeof (self->specific_1stblock));
+
+ just_free:
+ /* Free the memory for the other blocks. */
+ for (cnt = 1; cnt < PTHREAD_KEY_1STLEVEL_SIZE; ++cnt)
+ {
+ struct pthread_key_data *level2;
+
+ level2 = THREAD_GETMEM_NC (self, specific, cnt);
+ if (level2 != NULL)
+ {
+ /* The first block is allocated as part of the thread
+ descriptor. */
+ free (level2);
+ THREAD_SETMEM_NC (self, specific, cnt, NULL);
+ }
+ }
+
+ THREAD_SETMEM (self, specific_used, false);
+ }
+}
+
+
+/* Deallocate a thread's stack after optionally making sure the thread
+ descriptor is still valid. */
+void
+internal_function
+__free_tcb (struct pthread *pd)
+{
+ /* The thread is exiting now. */
+ if (__builtin_expect (atomic_bit_test_set (&pd->cancelhandling,
+ TERMINATED_BIT) == 0, 1))
+ {
+ /* Remove the descriptor from the list. */
+ if (DEBUGGING_P && __find_in_stack_list (pd) == NULL)
+ /* Something is really wrong. The descriptor for a still
+ running thread is gone. */
+ abort ();
+
+ /* Free TPP data. */
+ if (__builtin_expect (pd->tpp != NULL, 0))
+ {
+ struct priority_protection_data *tpp = pd->tpp;
+
+ pd->tpp = NULL;
+ free (tpp);
+ }
+
+ /* Queue the stack memory block for reuse and exit the process. The
+ kernel will signal via writing to the address returned by
+ QUEUE-STACK when the stack is available. */
+ __deallocate_stack (pd);
+ }
+}
+
+
+static int
+start_thread (void *arg)
+{
+ struct pthread *pd = (struct pthread *) arg;
+
+#if HP_TIMING_AVAIL
+ /* Remember the time when the thread was started. */
+ hp_timing_t now;
+ HP_TIMING_NOW (now);
+ THREAD_SETMEM (pd, cpuclock_offset, now);
+#endif
+#if defined __UCLIBC_HAS_RESOLVER_SUPPORT__
+ /* Initialize resolver state pointer. */
+ __resp = &pd->res;
+#endif
+#ifdef __NR_set_robust_list
+# ifndef __ASSUME_SET_ROBUST_LIST
+ if (__set_robust_list_avail >= 0)
+# endif
+ {
+ INTERNAL_SYSCALL_DECL (err);
+ /* This call should never fail because the initial call in init.c
+ succeeded. */
+ INTERNAL_SYSCALL (set_robust_list, err, 2, &pd->robust_head,
+ sizeof (struct robust_list_head));
+ }
+#endif
+
+ /* If the parent was running cancellation handlers while creating
+ the thread the new thread inherited the signal mask. Reset the
+ cancellation signal mask. */
+ if (__builtin_expect (pd->parent_cancelhandling & CANCELING_BITMASK, 0))
+ {
+ INTERNAL_SYSCALL_DECL (err);
+ sigset_t mask;
+ __sigemptyset (&mask);
+ __sigaddset (&mask, SIGCANCEL);
+ (void) INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_UNBLOCK, &mask,
+ NULL, _NSIG / 8);
+ }
+
+ /* This is where the try/finally block should be created. For
+ compilers without that support we do use setjmp. */
+ struct pthread_unwind_buf unwind_buf;
+
+ /* No previous handlers. */
+ unwind_buf.priv.data.prev = NULL;
+ unwind_buf.priv.data.cleanup = NULL;
+
+ int not_first_call;
+ not_first_call = setjmp ((struct __jmp_buf_tag *) unwind_buf.cancel_jmp_buf);
+ if (__builtin_expect (! not_first_call, 1))
+ {
+ /* Store the new cleanup handler info. */
+ THREAD_SETMEM (pd, cleanup_jmp_buf, &unwind_buf);
+
+ if (__builtin_expect (pd->stopped_start, 0))
+ {
+ int oldtype = CANCEL_ASYNC ();
+
+ /* Get the lock the parent locked to force synchronization. */
+ lll_lock (pd->lock, LLL_PRIVATE);
+ /* And give it up right away. */
+ lll_unlock (pd->lock, LLL_PRIVATE);
+
+ CANCEL_RESET (oldtype);
+ }
+
+ /* Run the code the user provided. */
+#ifdef CALL_THREAD_FCT
+ THREAD_SETMEM (pd, result, CALL_THREAD_FCT (pd));
+#else
+ THREAD_SETMEM (pd, result, pd->start_routine (pd->arg));
+#endif
+ }
+
+ /* Run the destructor for the thread-local data. */
+ __nptl_deallocate_tsd ();
+
+ /* Clean up any state libc stored in thread-local variables. */
+ /* disable for now
+ __libc_thread_freeres ();
+ */
+ /* If this is the last thread we terminate the process now. We
+ do not notify the debugger, it might just irritate it if there
+ is no thread left. */
+ if (__builtin_expect (atomic_decrement_and_test (&__nptl_nthreads), 0))
+ /* This was the last thread. */
+ exit (0);
+
+ /* Report the death of the thread if this is wanted. */
+ if (__builtin_expect (pd->report_events, 0))
+ {
+ /* See whether TD_DEATH is in any of the mask. */
+ const int idx = __td_eventword (TD_DEATH);
+ const uint32_t mask = __td_eventmask (TD_DEATH);
+
+ if ((mask & (__nptl_threads_events.event_bits[idx]
+ | pd->eventbuf.eventmask.event_bits[idx])) != 0)
+ {
+ /* Yep, we have to signal the death. Add the descriptor to
+ the list but only if it is not already on it. */
+ if (pd->nextevent == NULL)
+ {
+ pd->eventbuf.eventnum = TD_DEATH;
+ pd->eventbuf.eventdata = pd;
+
+ do
+ pd->nextevent = __nptl_last_event;
+ while (atomic_compare_and_exchange_bool_acq (&__nptl_last_event,
+ pd, pd->nextevent));
+ }
+
+ /* Now call the function to signal the event. */
+ __nptl_death_event ();
+ }
+ }
+
+ /* The thread is exiting now. Don't set this bit until after we've hit
+ the event-reporting breakpoint, so that td_thr_get_info on us while at
+ the breakpoint reports TD_THR_RUN state rather than TD_THR_ZOMBIE. */
+ atomic_bit_set (&pd->cancelhandling, EXITING_BIT);
+
+#ifndef __ASSUME_SET_ROBUST_LIST
+ /* If this thread has any robust mutexes locked, handle them now. */
+# if __WORDSIZE == 64
+ void *robust = pd->robust_head.list;
+# else
+ __pthread_slist_t *robust = pd->robust_list.__next;
+# endif
+ /* We let the kernel do the notification if it is able to do so.
+ If we have to do it here there for sure are no PI mutexes involved
+ since the kernel support for them is even more recent. */
+ if (__set_robust_list_avail < 0
+ && __builtin_expect (robust != (void *) &pd->robust_head, 0))
+ {
+ do
+ {
+ struct __pthread_mutex_s *this = (struct __pthread_mutex_s *)
+ ((char *) robust - offsetof (struct __pthread_mutex_s,
+ __list.__next));
+ robust = *((void **) robust);
+
+# ifdef __PTHREAD_MUTEX_HAVE_PREV
+ this->__list.__prev = NULL;
+# endif
+ this->__list.__next = NULL;
+
+ lll_robust_dead (this->__lock, /* XYZ */ LLL_SHARED);
+ }
+ while (robust != (void *) &pd->robust_head);
+ }
+#endif
+
+ /* Mark the memory of the stack as usable to the kernel. We free
+ everything except for the space used for the TCB itself. */
+ size_t pagesize_m1 = __getpagesize () - 1;
+ char *sp = CURRENT_STACK_FRAME;
+#ifdef _STACK_GROWS_DOWN
+ size_t freesize = (sp - (char *) pd->stackblock) & ~pagesize_m1;
+#else
+ size_t freesize = ((char *) pd->stackblock - sp) & ~pagesize_m1;
+#endif
+ assert (freesize < pd->stackblock_size);
+ if (freesize > PTHREAD_STACK_MIN)
+ madvise (pd->stackblock, freesize - PTHREAD_STACK_MIN, MADV_DONTNEED);
+
+ /* If the thread is detached free the TCB. */
+ if (IS_DETACHED (pd))
+ /* Free the TCB. */
+ __free_tcb (pd);
+ else if (__builtin_expect (pd->cancelhandling & SETXID_BITMASK, 0))
+ {
+ /* Some other thread might call any of the setXid functions and expect
+ us to reply. In this case wait until we did that. */
+ do
+ lll_futex_wait (&pd->setxid_futex, 0, LLL_PRIVATE);
+ while (pd->cancelhandling & SETXID_BITMASK);
+
+ /* Reset the value so that the stack can be reused. */
+ pd->setxid_futex = 0;
+ }
+
+ /* We cannot call '_exit' here. '_exit' will terminate the process.
+
+ The 'exit' implementation in the kernel will signal when the
+ process is really dead since 'clone' got passed the CLONE_CLEARTID
+ flag. The 'tid' field in the TCB will be set to zero.
+
+ The exit code is zero since in case all threads exit by calling
+ 'pthread_exit' the exit status must be 0 (zero). */
+ __exit_thread_inline (0);
+
+ /* NOTREACHED */
+ return 0;
+}
+
+
+/* Default thread attributes for the case when the user does not
+ provide any. */
+static const struct pthread_attr default_attr =
+ {
+ /* Just some value > 0 which gets rounded to the nearest page size. */
+ .guardsize = 1,
+ };
+
+
+int
+__pthread_create_2_1 (
+ pthread_t *newthread,
+ const pthread_attr_t *attr,
+ void *(*start_routine) (void *),
+ void *arg)
+{
+ STACK_VARIABLES;
+
+ const struct pthread_attr *iattr = (struct pthread_attr *) attr;
+ if (iattr == NULL)
+ /* Is this the best idea? On NUMA machines this could mean
+ accessing far-away memory. */
+ iattr = &default_attr;
+
+ struct pthread *pd = NULL;
+ int err = ALLOCATE_STACK (iattr, &pd);
+ if (__builtin_expect (err != 0, 0))
+ /* Something went wrong. Maybe a parameter of the attributes is
+ invalid or we could not allocate memory. */
+ return err;
+
+
+ /* Initialize the TCB. All initializations with zero should be
+ performed in 'get_cached_stack'. This way we avoid doing this if
+ the stack freshly allocated with 'mmap'. */
+
+#ifdef TLS_TCB_AT_TP
+ /* Reference to the TCB itself. */
+ pd->header.self = pd;
+
+ /* Self-reference for TLS. */
+ pd->header.tcb = pd;
+#endif
+
+ /* Store the address of the start routine and the parameter. Since
+ we do not start the function directly the stillborn thread will
+ get the information from its thread descriptor. */
+ pd->start_routine = start_routine;
+ pd->arg = arg;
+
+ /* Copy the thread attribute flags. */
+ struct pthread *self = THREAD_SELF;
+ pd->flags = ((iattr->flags & ~(ATTR_FLAG_SCHED_SET | ATTR_FLAG_POLICY_SET))
+ | (self->flags & (ATTR_FLAG_SCHED_SET | ATTR_FLAG_POLICY_SET)));
+
+ /* Initialize the field for the ID of the thread which is waiting
+ for us. This is a self-reference in case the thread is created
+ detached. */
+ pd->joinid = iattr->flags & ATTR_FLAG_DETACHSTATE ? pd : NULL;
+
+ /* The debug events are inherited from the parent. */
+ pd->eventbuf = self->eventbuf;
+
+
+ /* Copy the parent's scheduling parameters. The flags will say what
+ is valid and what is not. */
+ pd->schedpolicy = self->schedpolicy;
+ pd->schedparam = self->schedparam;
+
+ /* Copy the stack guard canary. */
+#ifdef THREAD_COPY_STACK_GUARD
+ THREAD_COPY_STACK_GUARD (pd);
+#endif
+
+ /* Copy the pointer guard value. */
+#ifdef THREAD_COPY_POINTER_GUARD
+ THREAD_COPY_POINTER_GUARD (pd);
+#endif
+
+ /* Determine scheduling parameters for the thread. */
+ if (attr != NULL
+ && __builtin_expect ((iattr->flags & ATTR_FLAG_NOTINHERITSCHED) != 0, 0)
+ && (iattr->flags & (ATTR_FLAG_SCHED_SET | ATTR_FLAG_POLICY_SET)) != 0)
+ {
+ INTERNAL_SYSCALL_DECL (scerr);
+
+ /* Use the scheduling parameters the user provided. */
+ if (iattr->flags & ATTR_FLAG_POLICY_SET)
+ pd->schedpolicy = iattr->schedpolicy;
+ else if ((pd->flags & ATTR_FLAG_POLICY_SET) == 0)
+ {
+ pd->schedpolicy = INTERNAL_SYSCALL (sched_getscheduler, scerr, 1, 0);
+ pd->flags |= ATTR_FLAG_POLICY_SET;
+ }
+
+ if (iattr->flags & ATTR_FLAG_SCHED_SET)
+ memcpy (&pd->schedparam, &iattr->schedparam,
+ sizeof (struct sched_param));
+ else if ((pd->flags & ATTR_FLAG_SCHED_SET) == 0)
+ {
+ INTERNAL_SYSCALL (sched_getparam, scerr, 2, 0, &pd->schedparam);
+ pd->flags |= ATTR_FLAG_SCHED_SET;
+ }
+
+ /* Check for valid priorities. */
+ int minprio = INTERNAL_SYSCALL (sched_get_priority_min, scerr, 1,
+ iattr->schedpolicy);
+ int maxprio = INTERNAL_SYSCALL (sched_get_priority_max, scerr, 1,
+ iattr->schedpolicy);
+ if (pd->schedparam.sched_priority < minprio
+ || pd->schedparam.sched_priority > maxprio)
+ {
+ err = EINVAL;
+ goto errout;
+ }
+ }
+
+ /* Pass the descriptor to the caller. */
+ *newthread = (pthread_t) pd;
+
+ /* Remember whether the thread is detached or not. In case of an
+ error we have to free the stacks of non-detached stillborn
+ threads. */
+ bool is_detached = IS_DETACHED (pd);
+
+ /* Start the thread. */
+ err = create_thread (pd, iattr, STACK_VARIABLES_ARGS);
+ if (err != 0)
+ {
+ /* Something went wrong. Free the resources. */
+ if (!is_detached)
+ {
+ errout:
+ __deallocate_stack (pd);
+ }
+ return err;
+ }
+
+ return 0;
+}
+weak_alias(__pthread_create_2_1, pthread_create)
+
+/* Information for libthread_db. */
+
+#include "../nptl_db/db_info.c"
+
+/* If pthread_create is present, libgcc_eh.a and libsupc++.a expects some other POSIX thread
+ functions to be present as well. */
+PTHREAD_STATIC_FN_REQUIRE (pthread_mutex_lock)
+PTHREAD_STATIC_FN_REQUIRE (pthread_mutex_trylock)
+PTHREAD_STATIC_FN_REQUIRE (pthread_mutex_unlock)
+
+PTHREAD_STATIC_FN_REQUIRE (pthread_once)
+PTHREAD_STATIC_FN_REQUIRE (pthread_cancel)
+
+PTHREAD_STATIC_FN_REQUIRE (pthread_key_create)
+PTHREAD_STATIC_FN_REQUIRE (pthread_key_delete)
+PTHREAD_STATIC_FN_REQUIRE (pthread_setspecific)
+PTHREAD_STATIC_FN_REQUIRE (pthread_getspecific)
+
+/* UCLIBC_MUTEX_xxx macros expects to have these as well */
+PTHREAD_STATIC_FN_REQUIRE (pthread_mutex_init)
+PTHREAD_STATIC_FN_REQUIRE (_pthread_cleanup_push_defer)
+PTHREAD_STATIC_FN_REQUIRE (_pthread_cleanup_pop_restore)
diff --git a/libpthread/nptl/pthread_detach.c b/libpthread/nptl/pthread_detach.c
new file mode 100644
index 000000000..c2651ea6c
--- /dev/null
+++ b/libpthread/nptl/pthread_detach.c
@@ -0,0 +1,55 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include "pthreadP.h"
+#include <atomic.h>
+
+
+int
+pthread_detach (pthread_t th)
+{
+ struct pthread *pd = (struct pthread *) th;
+
+ /* Make sure the descriptor is valid. */
+ if (INVALID_NOT_TERMINATED_TD_P (pd))
+ /* Not a valid thread handle. */
+ return ESRCH;
+
+ int result = 0;
+
+ /* Mark the thread as detached. */
+ if (atomic_compare_and_exchange_bool_acq (&pd->joinid, pd, NULL))
+ {
+ /* There are two possibilities here. First, the thread might
+ already be detached. In this case we return EINVAL.
+ Otherwise there might already be a waiter. The standard does
+ not mention what happens in this case. */
+ if (IS_DETACHED (pd))
+ result = EINVAL;
+ }
+ else
+ /* Check whether the thread terminated meanwhile. In this case we
+ will just free the TCB. */
+ if ((pd->cancelhandling & EXITING_BITMASK) != 0)
+ /* Note that the code in __free_tcb makes sure each thread
+ control block is freed only once. */
+ __free_tcb (pd);
+
+ return result;
+}
diff --git a/libpthread/nptl/pthread_equal.c b/libpthread/nptl/pthread_equal.c
new file mode 100644
index 000000000..50e1a4f26
--- /dev/null
+++ b/libpthread/nptl/pthread_equal.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 "pthreadP.h"
+
+
+int
+attribute_protected
+__pthread_equal (pthread_t thread1, pthread_t thread2)
+{
+ return thread1 == thread2;
+}
+strong_alias (__pthread_equal, pthread_equal)
diff --git a/libpthread/nptl/pthread_exit.c b/libpthread/nptl/pthread_exit.c
new file mode 100644
index 000000000..141ca750d
--- /dev/null
+++ b/libpthread/nptl/pthread_exit.c
@@ -0,0 +1,37 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <stdlib.h>
+#include "pthreadP.h"
+
+
+void
+attribute_protected attribute_noreturn
+__pthread_exit (void* value)
+{
+ THREAD_SETMEM (THREAD_SELF, result, value);
+
+ __do_cancel ();
+}
+strong_alias (__pthread_exit, pthread_exit)
+
+/*
+ * After a thread terminates, __uClibc_main decrements __nptl_nthreads
+ * defined in pthread_create.c.
+ */
+PTHREAD_STATIC_FN_REQUIRE (pthread_create)
diff --git a/libpthread/nptl/pthread_getattr_np.c b/libpthread/nptl/pthread_getattr_np.c
new file mode 100644
index 000000000..6df6c8e95
--- /dev/null
+++ b/libpthread/nptl/pthread_getattr_np.c
@@ -0,0 +1,178 @@
+/* Copyright (C) 2002, 2003, 2004, 2006, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <assert.h>
+#include <errno.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdio_ext.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/resource.h>
+#include "pthreadP.h"
+#include <lowlevellock.h>
+#include <ldsodefs.h>
+
+
+int
+pthread_getattr_np (
+ pthread_t thread_id,
+ pthread_attr_t *attr)
+{
+ struct pthread *thread = (struct pthread *) thread_id;
+ struct pthread_attr *iattr = (struct pthread_attr *) attr;
+ int ret = 0;
+
+ lll_lock (thread->lock, LLL_PRIVATE);
+
+ /* The thread library is responsible for keeping the values in the
+ thread desriptor up-to-date in case the user changes them. */
+ memcpy (&iattr->schedparam, &thread->schedparam,
+ sizeof (struct sched_param));
+ iattr->schedpolicy = thread->schedpolicy;
+
+ /* Clear the flags work. */
+ iattr->flags = thread->flags;
+
+ /* The thread might be detached by now. */
+ if (IS_DETACHED (thread))
+ iattr->flags |= ATTR_FLAG_DETACHSTATE;
+
+ /* This is the guardsize after adjusting it. */
+ iattr->guardsize = thread->reported_guardsize;
+
+ /* The sizes are subject to alignment. */
+ if (__builtin_expect (thread->stackblock != NULL, 1))
+ {
+ iattr->stacksize = thread->stackblock_size;
+ iattr->stackaddr = (char *) thread->stackblock + iattr->stacksize;
+ }
+ else
+ {
+ /* No stack information available. This must be for the initial
+ thread. Get the info in some magical way. */
+ assert (abs (thread->pid) == thread->tid);
+
+ /* Stack size limit. */
+ struct rlimit rl;
+
+ /* The safest way to get the top of the stack is to read
+ /proc/self/maps and locate the line into which
+ __libc_stack_end falls. */
+ FILE *fp = fopen ("/proc/self/maps", "rc");
+ if (fp == NULL)
+ ret = errno;
+ /* We need the limit of the stack in any case. */
+ else
+ {
+ if (getrlimit (RLIMIT_STACK, &rl) != 0)
+ ret = errno;
+ else
+ {
+ /* We need no locking. */
+ __fsetlocking (fp, FSETLOCKING_BYCALLER);
+
+ /* Until we found an entry (which should always be the case)
+ mark the result as a failure. */
+ ret = ENOENT;
+
+ char *line = NULL;
+ size_t linelen = 0;
+ uintptr_t last_to = 0;
+
+ while (! feof_unlocked (fp))
+ {
+ if (getdelim (&line, &linelen, '\n', fp) <= 0)
+ break;
+
+ uintptr_t from;
+ uintptr_t to;
+ if (sscanf (line, "%" SCNxPTR "-%" SCNxPTR, &from, &to) != 2)
+ continue;
+ if (from <= (uintptr_t) __libc_stack_end
+ && (uintptr_t) __libc_stack_end < to)
+ {
+ /* Found the entry. Now we have the info we need. */
+ iattr->stacksize = rl.rlim_cur;
+ iattr->stackaddr = (void *) to;
+
+ /* The limit might be too high. */
+ if ((size_t) iattr->stacksize
+ > (size_t) iattr->stackaddr - last_to)
+ iattr->stacksize = (size_t) iattr->stackaddr - last_to;
+
+ /* We succeed and no need to look further. */
+ ret = 0;
+ break;
+ }
+ last_to = to;
+ }
+
+ free (line);
+ }
+
+ fclose (fp);
+ }
+ }
+
+ iattr->flags |= ATTR_FLAG_STACKADDR;
+
+ if (ret == 0)
+ {
+ size_t size = 16;
+ cpu_set_t *cpuset = NULL;
+
+ do
+ {
+ size <<= 1;
+
+ void *newp = realloc (cpuset, size);
+ if (newp == NULL)
+ {
+ ret = ENOMEM;
+ break;
+ }
+ cpuset = (cpu_set_t *) newp;
+
+ ret = __pthread_getaffinity_np (thread_id, size, cpuset);
+ }
+ /* Pick some ridiculous upper limit. Is 8 million CPUs enough? */
+ while (ret == EINVAL && size < 1024 * 1024);
+
+ if (ret == 0)
+ {
+ iattr->cpuset = cpuset;
+ iattr->cpusetsize = size;
+ }
+ else
+ {
+ free (cpuset);
+ if (ret == ENOSYS)
+ {
+ /* There is no such functionality. */
+ ret = 0;
+ iattr->cpuset = NULL;
+ iattr->cpusetsize = 0;
+ }
+ }
+ }
+
+ lll_unlock (thread->lock, LLL_PRIVATE);
+
+ return ret;
+}
diff --git a/libpthread/nptl/pthread_getconcurrency.c b/libpthread/nptl/pthread_getconcurrency.c
new file mode 100644
index 000000000..fe590cb86
--- /dev/null
+++ b/libpthread/nptl/pthread_getconcurrency.c
@@ -0,0 +1,26 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 "pthreadP.h"
+
+
+int
+pthread_getconcurrency (void)
+{
+ return __concurrency_level;
+}
diff --git a/libpthread/nptl/pthread_getschedparam.c b/libpthread/nptl/pthread_getschedparam.c
new file mode 100644
index 000000000..0652bb472
--- /dev/null
+++ b/libpthread/nptl/pthread_getschedparam.c
@@ -0,0 +1,75 @@
+/* Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <string.h>
+#include "pthreadP.h"
+#include <lowlevellock.h>
+
+
+int
+attribute_protected
+__pthread_getschedparam (
+ pthread_t threadid,
+ int *policy,
+ struct sched_param *param)
+{
+ struct pthread *pd = (struct pthread *) threadid;
+
+ /* Make sure the descriptor is valid. */
+ if (INVALID_TD_P (pd))
+ /* Not a valid thread handle. */
+ return ESRCH;
+
+ int result = 0;
+
+ lll_lock (pd->lock, LLL_PRIVATE);
+
+ /* The library is responsible for maintaining the values at all
+ times. If the user uses a interface other than
+ pthread_setschedparam to modify the scheduler setting it is not
+ the library's problem. In case the descriptor's values have
+ not yet been retrieved do it now. */
+ if ((pd->flags & ATTR_FLAG_SCHED_SET) == 0)
+ {
+ if (sched_getparam (pd->tid, &pd->schedparam) != 0)
+ result = 1;
+ else
+ pd->flags |= ATTR_FLAG_SCHED_SET;
+ }
+
+ if ((pd->flags & ATTR_FLAG_POLICY_SET) == 0)
+ {
+ pd->schedpolicy = sched_getscheduler (pd->tid);
+ if (pd->schedpolicy == -1)
+ result = 1;
+ else
+ pd->flags |= ATTR_FLAG_POLICY_SET;
+ }
+
+ if (result == 0)
+ {
+ *policy = pd->schedpolicy;
+ memcpy (param, &pd->schedparam, sizeof (struct sched_param));
+ }
+
+ lll_unlock (pd->lock, LLL_PRIVATE);
+
+ return result;
+}
+strong_alias (__pthread_getschedparam, pthread_getschedparam)
diff --git a/libpthread/nptl/pthread_getspecific.c b/libpthread/nptl/pthread_getspecific.c
new file mode 100644
index 000000000..8827fe3f2
--- /dev/null
+++ b/libpthread/nptl/pthread_getspecific.c
@@ -0,0 +1,68 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <stdlib.h>
+#include "pthreadP.h"
+
+
+attribute_protected
+void *
+__pthread_getspecific (pthread_key_t key)
+{
+ struct pthread_key_data *data;
+
+ /* Special case access to the first 2nd-level block. This is the
+ usual case. */
+ if (__builtin_expect (key < PTHREAD_KEY_2NDLEVEL_SIZE, 1))
+ data = &THREAD_SELF->specific_1stblock[key];
+ else
+ {
+ /* Verify the key is sane. */
+ if (key >= PTHREAD_KEYS_MAX)
+ /* Not valid. */
+ return NULL;
+
+ unsigned int idx1st = key / PTHREAD_KEY_2NDLEVEL_SIZE;
+ unsigned int idx2nd = key % PTHREAD_KEY_2NDLEVEL_SIZE;
+
+ /* If the sequence number doesn't match or the key cannot be defined
+ for this thread since the second level array is not allocated
+ return NULL, too. */
+ struct pthread_key_data *level2 = THREAD_GETMEM_NC (THREAD_SELF,
+ specific, idx1st);
+ if (level2 == NULL)
+ /* Not allocated, therefore no data. */
+ return NULL;
+
+ /* There is data. */
+ data = &level2[idx2nd];
+ }
+
+ void *result = data->data;
+ if (result != NULL)
+ {
+ uintptr_t seq = data->seq;
+
+ if (__builtin_expect (seq != __pthread_keys[key].seq, 0))
+ result = data->data = NULL;
+ }
+
+ return result;
+}
+strong_alias (__pthread_getspecific, pthread_getspecific)
+strong_alias (__pthread_getspecific, __pthread_getspecific_internal)
diff --git a/libpthread/nptl/pthread_join.c b/libpthread/nptl/pthread_join.c
new file mode 100644
index 000000000..fde755008
--- /dev/null
+++ b/libpthread/nptl/pthread_join.c
@@ -0,0 +1,113 @@
+/* Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <stdlib.h>
+
+#include <atomic.h>
+#include "pthreadP.h"
+
+
+static void
+cleanup (void *arg)
+{
+ /* If we already changed the waiter ID, reset it. The call cannot
+ fail for any reason but the thread not having done that yet so
+ there is no reason for a loop. */
+ (void) atomic_compare_and_exchange_bool_acq ((struct pthread **) arg, NULL,
+ THREAD_SELF);
+}
+
+
+int
+pthread_join (
+ pthread_t threadid,
+ void **thread_return)
+{
+ struct pthread *pd = (struct pthread *) threadid;
+
+ /* Make sure the descriptor is valid. */
+ if (INVALID_NOT_TERMINATED_TD_P (pd))
+ /* Not a valid thread handle. */
+ return ESRCH;
+
+ /* Is the thread joinable?. */
+ if (IS_DETACHED (pd))
+ /* We cannot wait for the thread. */
+ return EINVAL;
+
+ struct pthread *self = THREAD_SELF;
+ int result = 0;
+
+ /* During the wait we change to asynchronous cancellation. If we
+ are canceled the thread we are waiting for must be marked as
+ un-wait-ed for again. */
+ pthread_cleanup_push (cleanup, &pd->joinid);
+
+ /* Switch to asynchronous cancellation. */
+ int oldtype = CANCEL_ASYNC ();
+
+ if ((pd == self
+ || (self->joinid == pd
+ && (pd->cancelhandling
+ & (CANCELING_BITMASK | CANCELED_BITMASK | EXITING_BITMASK
+ | TERMINATED_BITMASK)) == 0))
+ && !CANCEL_ENABLED_AND_CANCELED (self->cancelhandling))
+ /* This is a deadlock situation. The threads are waiting for each
+ other to finish. Note that this is a "may" error. To be 100%
+ sure we catch this error we would have to lock the data
+ structures but it is not necessary. In the unlikely case that
+ two threads are really caught in this situation they will
+ deadlock. It is the programmer's problem to figure this
+ out. */
+ result = EDEADLK;
+ /* Wait for the thread to finish. If it is already locked something
+ is wrong. There can only be one waiter. */
+ else if (__builtin_expect (atomic_compare_and_exchange_bool_acq (&pd->joinid,
+ self,
+ NULL), 0))
+ /* There is already somebody waiting for the thread. */
+ result = EINVAL;
+ else
+ /* Wait for the child. */
+ lll_wait_tid (pd->tid);
+
+
+ /* Restore cancellation mode. */
+ CANCEL_RESET (oldtype);
+
+ /* Remove the handler. */
+ pthread_cleanup_pop (0);
+
+
+ if (__builtin_expect (result == 0, 1))
+ {
+ /* We mark the thread as terminated and as joined. */
+ pd->tid = -1;
+
+ /* Store the return value if the caller is interested. */
+ if (thread_return != NULL)
+ *thread_return = pd->result;
+
+
+ /* Free the TCB. */
+ __free_tcb (pd);
+ }
+
+ return result;
+}
diff --git a/libpthread/nptl/pthread_key_create.c b/libpthread/nptl/pthread_key_create.c
new file mode 100644
index 000000000..6e11bbeae
--- /dev/null
+++ b/libpthread/nptl/pthread_key_create.c
@@ -0,0 +1,55 @@
+/* Copyright (C) 2002, 2003, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include "pthreadP.h"
+#include <atomic.h>
+
+
+int
+attribute_protected
+__pthread_key_create (
+ pthread_key_t *key,
+ void (*destr) (void *))
+{
+ /* Find a slot in __pthread_kyes which is unused. */
+ size_t cnt;
+ for (cnt = 0; cnt < PTHREAD_KEYS_MAX; ++cnt)
+ {
+ uintptr_t seq = __pthread_keys[cnt].seq;
+
+ if (KEY_UNUSED (seq) && KEY_USABLE (seq)
+ /* We found an unused slot. Try to allocate it. */
+ && ! atomic_compare_and_exchange_bool_acq (&__pthread_keys[cnt].seq,
+ seq + 1, seq))
+ {
+ /* Remember the destructor. */
+ __pthread_keys[cnt].destr = destr;
+
+ /* Return the key to the caller. */
+ *key = cnt;
+
+ /* The call succeeded. */
+ return 0;
+ }
+ }
+
+ return EAGAIN;
+}
+strong_alias (__pthread_key_create, pthread_key_create)
+strong_alias (__pthread_key_create, __pthread_key_create_internal)
diff --git a/libpthread/nptl/pthread_key_delete.c b/libpthread/nptl/pthread_key_delete.c
new file mode 100644
index 000000000..388091ec6
--- /dev/null
+++ b/libpthread/nptl/pthread_key_delete.c
@@ -0,0 +1,41 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include "pthreadP.h"
+#include <atomic.h>
+
+
+int
+pthread_key_delete (pthread_key_t key)
+{
+ int result = EINVAL;
+
+ if (__builtin_expect (key < PTHREAD_KEYS_MAX, 1))
+ {
+ unsigned int seq = __pthread_keys[key].seq;
+
+ if (__builtin_expect (! KEY_UNUSED (seq), 1)
+ && ! atomic_compare_and_exchange_bool_acq (&__pthread_keys[key].seq,
+ seq + 1, seq))
+ /* We deleted a valid key. */
+ result = 0;
+ }
+
+ return result;
+}
diff --git a/libpthread/nptl/pthread_kill_other_threads.c b/libpthread/nptl/pthread_kill_other_threads.c
new file mode 100644
index 000000000..87c67ba4c
--- /dev/null
+++ b/libpthread/nptl/pthread_kill_other_threads.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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/>. */
+
+#if 0 /*def SHARED*/
+/* This function does not serve a useful purpose in the thread library
+ implementation anymore. It used to be necessary when then kernel
+ could not shut down "processes" but this is not the case anymore.
+
+ We could theoretically provide an equivalent implementation but
+ this is not necessary since the kernel already does a much better
+ job than we ever could. */
+void
+__pthread_kill_other_threads_np (void)
+{
+}
+#endif
diff --git a/libpthread/nptl/pthread_mutex_consistent.c b/libpthread/nptl/pthread_mutex_consistent.c
new file mode 100644
index 000000000..4da4c131a
--- /dev/null
+++ b/libpthread/nptl/pthread_mutex_consistent.c
@@ -0,0 +1,36 @@
+/* Copyright (C) 2005, 2006, 2010 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <pthreadP.h>
+
+
+int
+pthread_mutex_consistent (
+ pthread_mutex_t *mutex)
+{
+ /* Test whether this is a robust mutex with a dead owner. */
+ if ((mutex->__data.__kind & PTHREAD_MUTEX_ROBUST_NORMAL_NP) == 0
+ || mutex->__data.__owner != PTHREAD_MUTEX_INCONSISTENT)
+ return EINVAL;
+
+ mutex->__data.__owner = THREAD_GETMEM (THREAD_SELF, tid);
+
+ return 0;
+}
+weak_alias (pthread_mutex_consistent, pthread_mutex_consistent_np)
diff --git a/libpthread/nptl/pthread_mutex_destroy.c b/libpthread/nptl/pthread_mutex_destroy.c
new file mode 100644
index 000000000..ac9d40c95
--- /dev/null
+++ b/libpthread/nptl/pthread_mutex_destroy.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include "pthreadP.h"
+
+
+int
+attribute_protected
+__pthread_mutex_destroy (
+ pthread_mutex_t *mutex)
+{
+ if ((mutex->__data.__kind & PTHREAD_MUTEX_ROBUST_NORMAL_NP) == 0
+ && mutex->__data.__nusers != 0)
+ return EBUSY;
+
+ /* Set to an invalid value. */
+ mutex->__data.__kind = -1;
+
+ return 0;
+}
+strong_alias (__pthread_mutex_destroy, pthread_mutex_destroy)
+INTDEF(__pthread_mutex_destroy)
diff --git a/libpthread/nptl/pthread_mutex_getprioceiling.c b/libpthread/nptl/pthread_mutex_getprioceiling.c
new file mode 100644
index 000000000..bfadd553a
--- /dev/null
+++ b/libpthread/nptl/pthread_mutex_getprioceiling.c
@@ -0,0 +1,37 @@
+/* Get current priority ceiling of pthread_mutex_t.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2006.
+
+ 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 <pthreadP.h>
+
+
+int
+pthread_mutex_getprioceiling (mutex, prioceiling)
+ const pthread_mutex_t *mutex;
+ int *prioceiling;
+{
+ if (__builtin_expect ((mutex->__data.__kind
+ & PTHREAD_MUTEX_PRIO_PROTECT_NP) == 0, 0))
+ return EINVAL;
+
+ *prioceiling = (mutex->__data.__lock & PTHREAD_MUTEX_PRIO_CEILING_MASK)
+ >> PTHREAD_MUTEX_PRIO_CEILING_SHIFT;
+
+ return 0;
+}
diff --git a/libpthread/nptl/pthread_mutex_init.c b/libpthread/nptl/pthread_mutex_init.c
new file mode 100644
index 000000000..bf4c4d151
--- /dev/null
+++ b/libpthread/nptl/pthread_mutex_init.c
@@ -0,0 +1,141 @@
+/* Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <assert.h>
+#include <errno.h>
+#include <string.h>
+#include <bits/kernel-features.h>
+#include "pthreadP.h"
+
+static const struct pthread_mutexattr default_attr =
+ {
+ /* Default is a normal mutex, not shared between processes. */
+ .mutexkind = PTHREAD_MUTEX_NORMAL
+ };
+
+
+#ifndef __ASSUME_FUTEX_LOCK_PI
+static int tpi_supported;
+#endif
+
+
+int
+attribute_protected
+__pthread_mutex_init (
+ pthread_mutex_t *mutex,
+ const pthread_mutexattr_t *mutexattr)
+{
+ const struct pthread_mutexattr *imutexattr;
+
+ assert (sizeof (pthread_mutex_t) <= __SIZEOF_PTHREAD_MUTEX_T);
+
+ imutexattr = (const struct pthread_mutexattr *) mutexattr ?: &default_attr;
+
+ /* Sanity checks. */
+ switch (__builtin_expect (imutexattr->mutexkind
+ & PTHREAD_MUTEXATTR_PROTOCOL_MASK,
+ PTHREAD_PRIO_NONE
+ << PTHREAD_MUTEXATTR_PROTOCOL_SHIFT))
+ {
+ case PTHREAD_PRIO_NONE << PTHREAD_MUTEXATTR_PROTOCOL_SHIFT:
+ break;
+
+ case PTHREAD_PRIO_INHERIT << PTHREAD_MUTEXATTR_PROTOCOL_SHIFT:
+#ifndef __ASSUME_FUTEX_LOCK_PI
+ if (__builtin_expect (tpi_supported == 0, 0))
+ {
+ int lock = 0;
+ INTERNAL_SYSCALL_DECL (err);
+ int ret = INTERNAL_SYSCALL (futex, err, 4, &lock, FUTEX_UNLOCK_PI,
+ 0, 0);
+ assert (INTERNAL_SYSCALL_ERROR_P (ret, err));
+ tpi_supported = INTERNAL_SYSCALL_ERRNO (ret, err) == ENOSYS ? -1 : 1;
+ }
+ if (__builtin_expect (tpi_supported < 0, 0))
+ return ENOTSUP;
+#endif
+ break;
+
+ default:
+ /* XXX: For now we don't support robust priority protected mutexes. */
+ if (imutexattr->mutexkind & PTHREAD_MUTEXATTR_FLAG_ROBUST)
+ return ENOTSUP;
+ break;
+ }
+
+ /* Clear the whole variable. */
+ memset (mutex, '\0', __SIZEOF_PTHREAD_MUTEX_T);
+
+ /* Copy the values from the attribute. */
+ mutex->__data.__kind = imutexattr->mutexkind & ~PTHREAD_MUTEXATTR_FLAG_BITS;
+
+ if ((imutexattr->mutexkind & PTHREAD_MUTEXATTR_FLAG_ROBUST) != 0)
+ {
+#ifndef __ASSUME_SET_ROBUST_LIST
+ if ((imutexattr->mutexkind & PTHREAD_MUTEXATTR_FLAG_PSHARED) != 0
+ && __set_robust_list_avail < 0)
+ return ENOTSUP;
+#endif
+
+ mutex->__data.__kind |= PTHREAD_MUTEX_ROBUST_NORMAL_NP;
+ }
+
+ switch (imutexattr->mutexkind & PTHREAD_MUTEXATTR_PROTOCOL_MASK)
+ {
+ case PTHREAD_PRIO_INHERIT << PTHREAD_MUTEXATTR_PROTOCOL_SHIFT:
+ mutex->__data.__kind |= PTHREAD_MUTEX_PRIO_INHERIT_NP;
+ break;
+
+ case PTHREAD_PRIO_PROTECT << PTHREAD_MUTEXATTR_PROTOCOL_SHIFT:
+ mutex->__data.__kind |= PTHREAD_MUTEX_PRIO_PROTECT_NP;
+
+ int ceiling = (imutexattr->mutexkind
+ & PTHREAD_MUTEXATTR_PRIO_CEILING_MASK)
+ >> PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT;
+ if (! ceiling)
+ {
+ if (__sched_fifo_min_prio == -1)
+ __init_sched_fifo_prio ();
+ if (ceiling < __sched_fifo_min_prio)
+ ceiling = __sched_fifo_min_prio;
+ }
+ mutex->__data.__lock = ceiling << PTHREAD_MUTEX_PRIO_CEILING_SHIFT;
+ break;
+
+ default:
+ break;
+ }
+
+ /* The kernel when waking robust mutexes on exit never uses
+ FUTEX_PRIVATE_FLAG FUTEX_WAKE. */
+ if ((imutexattr->mutexkind & (PTHREAD_MUTEXATTR_FLAG_PSHARED
+ | PTHREAD_MUTEXATTR_FLAG_ROBUST)) != 0)
+ mutex->__data.__kind |= PTHREAD_MUTEX_PSHARED_BIT;
+
+ /* Default values: mutex not used yet. */
+ // mutex->__count = 0; already done by memset
+ // mutex->__owner = 0; already done by memset
+ // mutex->__nusers = 0; already done by memset
+ // mutex->__spins = 0; already done by memset
+ // mutex->__next = NULL; already done by memset
+
+ return 0;
+}
+strong_alias (__pthread_mutex_init, pthread_mutex_init)
+INTDEF(__pthread_mutex_init)
diff --git a/libpthread/nptl/pthread_mutex_lock.c b/libpthread/nptl/pthread_mutex_lock.c
new file mode 100644
index 000000000..8353e8cd3
--- /dev/null
+++ b/libpthread/nptl/pthread_mutex_lock.c
@@ -0,0 +1,499 @@
+/* Copyright (C) 2002-2007, 2008, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <assert.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <not-cancel.h>
+#include "pthreadP.h"
+#include <lowlevellock.h>
+
+
+#ifndef LLL_MUTEX_LOCK
+# define LLL_MUTEX_LOCK(mutex) \
+ lll_lock ((mutex)->__data.__lock, PTHREAD_MUTEX_PSHARED (mutex))
+# define LLL_MUTEX_TRYLOCK(mutex) \
+ lll_trylock ((mutex)->__data.__lock)
+# define LLL_ROBUST_MUTEX_LOCK(mutex, id) \
+ lll_robust_lock ((mutex)->__data.__lock, id, \
+ PTHREAD_ROBUST_MUTEX_PSHARED (mutex))
+#endif
+
+
+static int __pthread_mutex_lock_full (pthread_mutex_t *mutex)
+ __attribute_noinline__;
+
+
+int
+#ifdef NO_INCR
+attribute_hidden internal_function
+#else
+attribute_protected
+#endif
+__pthread_mutex_lock (
+ pthread_mutex_t *mutex)
+{
+ assert (sizeof (mutex->__size) >= sizeof (mutex->__data));
+
+ unsigned int type = PTHREAD_MUTEX_TYPE (mutex);
+ if (__builtin_expect (type & ~PTHREAD_MUTEX_KIND_MASK_NP, 0))
+ return __pthread_mutex_lock_full (mutex);
+
+ pid_t id = THREAD_GETMEM (THREAD_SELF, tid);
+
+ if (__builtin_expect (type, PTHREAD_MUTEX_TIMED_NP)
+ == PTHREAD_MUTEX_TIMED_NP)
+ {
+ simple:
+ /* Normal mutex. */
+ LLL_MUTEX_LOCK (mutex);
+ assert (mutex->__data.__owner == 0);
+ }
+ else if (__builtin_expect (type == PTHREAD_MUTEX_RECURSIVE_NP, 1))
+ {
+ /* Recursive mutex. */
+
+ /* Check whether we already hold the mutex. */
+ if (mutex->__data.__owner == id)
+ {
+ /* Just bump the counter. */
+ if (__builtin_expect (mutex->__data.__count + 1 == 0, 0))
+ /* Overflow of the counter. */
+ return EAGAIN;
+
+ ++mutex->__data.__count;
+
+ return 0;
+ }
+
+ /* We have to get the mutex. */
+ LLL_MUTEX_LOCK (mutex);
+
+ assert (mutex->__data.__owner == 0);
+ mutex->__data.__count = 1;
+ }
+ else if (__builtin_expect (type == PTHREAD_MUTEX_ADAPTIVE_NP, 1))
+ {
+ if (! __is_smp)
+ goto simple;
+
+ if (LLL_MUTEX_TRYLOCK (mutex) != 0)
+ {
+ int cnt = 0;
+ int max_cnt = MIN (MAX_ADAPTIVE_COUNT,
+ mutex->__data.__spins * 2 + 10);
+ do
+ {
+ if (cnt++ >= max_cnt)
+ {
+ LLL_MUTEX_LOCK (mutex);
+ break;
+ }
+
+#ifdef BUSY_WAIT_NOP
+ BUSY_WAIT_NOP;
+#endif
+ }
+ while (LLL_MUTEX_TRYLOCK (mutex) != 0);
+
+ mutex->__data.__spins += (cnt - mutex->__data.__spins) / 8;
+ }
+ assert (mutex->__data.__owner == 0);
+ }
+ else
+ {
+ assert (type == PTHREAD_MUTEX_ERRORCHECK_NP);
+ /* Check whether we already hold the mutex. */
+ if (__builtin_expect (mutex->__data.__owner == id, 0))
+ return EDEADLK;
+ goto simple;
+ }
+
+ /* Record the ownership. */
+ mutex->__data.__owner = id;
+#ifndef NO_INCR
+ ++mutex->__data.__nusers;
+#endif
+
+ return 0;
+}
+
+static int
+__pthread_mutex_lock_full (pthread_mutex_t *mutex)
+{
+ int oldval;
+ pid_t id = THREAD_GETMEM (THREAD_SELF, tid);
+
+ switch (PTHREAD_MUTEX_TYPE (mutex))
+ {
+ case PTHREAD_MUTEX_ROBUST_RECURSIVE_NP:
+ case PTHREAD_MUTEX_ROBUST_ERRORCHECK_NP:
+ case PTHREAD_MUTEX_ROBUST_NORMAL_NP:
+ case PTHREAD_MUTEX_ROBUST_ADAPTIVE_NP:
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending,
+ &mutex->__data.__list.__next);
+
+ oldval = mutex->__data.__lock;
+ do
+ {
+ again:
+ if ((oldval & FUTEX_OWNER_DIED) != 0)
+ {
+ /* The previous owner died. Try locking the mutex. */
+ int newval = id;
+#ifdef NO_INCR
+ newval |= FUTEX_WAITERS;
+#else
+ newval |= (oldval & FUTEX_WAITERS);
+#endif
+
+ newval
+ = atomic_compare_and_exchange_val_acq (&mutex->__data.__lock,
+ newval, oldval);
+
+ if (newval != oldval)
+ {
+ oldval = newval;
+ goto again;
+ }
+
+ /* We got the mutex. */
+ mutex->__data.__count = 1;
+ /* But it is inconsistent unless marked otherwise. */
+ mutex->__data.__owner = PTHREAD_MUTEX_INCONSISTENT;
+
+ ENQUEUE_MUTEX (mutex);
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+
+ /* Note that we deliberately exit here. If we fall
+ through to the end of the function __nusers would be
+ incremented which is not correct because the old
+ owner has to be discounted. If we are not supposed
+ to increment __nusers we actually have to decrement
+ it here. */
+#ifdef NO_INCR
+ --mutex->__data.__nusers;
+#endif
+
+ return EOWNERDEAD;
+ }
+
+ /* Check whether we already hold the mutex. */
+ if (__builtin_expect ((oldval & FUTEX_TID_MASK) == id, 0))
+ {
+ int kind = PTHREAD_MUTEX_TYPE (mutex);
+ if (kind == PTHREAD_MUTEX_ROBUST_ERRORCHECK_NP)
+ {
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending,
+ NULL);
+ return EDEADLK;
+ }
+
+ if (kind == PTHREAD_MUTEX_ROBUST_RECURSIVE_NP)
+ {
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending,
+ NULL);
+
+ /* Just bump the counter. */
+ if (__builtin_expect (mutex->__data.__count + 1 == 0, 0))
+ /* Overflow of the counter. */
+ return EAGAIN;
+
+ ++mutex->__data.__count;
+
+ return 0;
+ }
+ }
+
+ oldval = LLL_ROBUST_MUTEX_LOCK (mutex, id);
+
+ if (__builtin_expect (mutex->__data.__owner
+ == PTHREAD_MUTEX_NOTRECOVERABLE, 0))
+ {
+ /* This mutex is now not recoverable. */
+ mutex->__data.__count = 0;
+ lll_unlock (mutex->__data.__lock,
+ PTHREAD_ROBUST_MUTEX_PSHARED (mutex));
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+ return ENOTRECOVERABLE;
+ }
+ }
+ while ((oldval & FUTEX_OWNER_DIED) != 0);
+
+ mutex->__data.__count = 1;
+ ENQUEUE_MUTEX (mutex);
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+ break;
+
+ case PTHREAD_MUTEX_PI_RECURSIVE_NP:
+ case PTHREAD_MUTEX_PI_ERRORCHECK_NP:
+ case PTHREAD_MUTEX_PI_NORMAL_NP:
+ case PTHREAD_MUTEX_PI_ADAPTIVE_NP:
+ case PTHREAD_MUTEX_PI_ROBUST_RECURSIVE_NP:
+ case PTHREAD_MUTEX_PI_ROBUST_ERRORCHECK_NP:
+ case PTHREAD_MUTEX_PI_ROBUST_NORMAL_NP:
+ case PTHREAD_MUTEX_PI_ROBUST_ADAPTIVE_NP:
+ {
+ int kind = mutex->__data.__kind & PTHREAD_MUTEX_KIND_MASK_NP;
+ int robust = mutex->__data.__kind & PTHREAD_MUTEX_ROBUST_NORMAL_NP;
+
+ if (robust)
+ /* Note: robust PI futexes are signaled by setting bit 0. */
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending,
+ (void *) (((uintptr_t) &mutex->__data.__list.__next)
+ | 1));
+
+ oldval = mutex->__data.__lock;
+
+ /* Check whether we already hold the mutex. */
+ if (__builtin_expect ((oldval & FUTEX_TID_MASK) == id, 0))
+ {
+ if (kind == PTHREAD_MUTEX_ERRORCHECK_NP)
+ {
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+ return EDEADLK;
+ }
+
+ if (kind == PTHREAD_MUTEX_RECURSIVE_NP)
+ {
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+
+ /* Just bump the counter. */
+ if (__builtin_expect (mutex->__data.__count + 1 == 0, 0))
+ /* Overflow of the counter. */
+ return EAGAIN;
+
+ ++mutex->__data.__count;
+
+ return 0;
+ }
+ }
+
+ int newval = id;
+#ifdef NO_INCR
+ newval |= FUTEX_WAITERS;
+#endif
+ oldval = atomic_compare_and_exchange_val_acq (&mutex->__data.__lock,
+ newval, 0);
+
+ if (oldval != 0)
+ {
+ /* The mutex is locked. The kernel will now take care of
+ everything. */
+ int private = (robust
+ ? PTHREAD_ROBUST_MUTEX_PSHARED (mutex)
+ : PTHREAD_MUTEX_PSHARED (mutex));
+ INTERNAL_SYSCALL_DECL (__err);
+ int e = INTERNAL_SYSCALL (futex, __err, 4, &mutex->__data.__lock,
+ __lll_private_flag (FUTEX_LOCK_PI,
+ private), 1, 0);
+
+ if (INTERNAL_SYSCALL_ERROR_P (e, __err)
+ && (INTERNAL_SYSCALL_ERRNO (e, __err) == ESRCH
+ || INTERNAL_SYSCALL_ERRNO (e, __err) == EDEADLK))
+ {
+ assert (INTERNAL_SYSCALL_ERRNO (e, __err) != EDEADLK
+ || (kind != PTHREAD_MUTEX_ERRORCHECK_NP
+ && kind != PTHREAD_MUTEX_RECURSIVE_NP));
+ /* ESRCH can happen only for non-robust PI mutexes where
+ the owner of the lock died. */
+ assert (INTERNAL_SYSCALL_ERRNO (e, __err) != ESRCH || !robust);
+
+ /* Delay the thread indefinitely. */
+ while (1)
+ pause_not_cancel ();
+ }
+
+ oldval = mutex->__data.__lock;
+
+ assert (robust || (oldval & FUTEX_OWNER_DIED) == 0);
+ }
+
+ if (__builtin_expect (oldval & FUTEX_OWNER_DIED, 0))
+ {
+ atomic_and (&mutex->__data.__lock, ~FUTEX_OWNER_DIED);
+
+ /* We got the mutex. */
+ mutex->__data.__count = 1;
+ /* But it is inconsistent unless marked otherwise. */
+ mutex->__data.__owner = PTHREAD_MUTEX_INCONSISTENT;
+
+ ENQUEUE_MUTEX_PI (mutex);
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+
+ /* Note that we deliberately exit here. If we fall
+ through to the end of the function __nusers would be
+ incremented which is not correct because the old owner
+ has to be discounted. If we are not supposed to
+ increment __nusers we actually have to decrement it here. */
+#ifdef NO_INCR
+ --mutex->__data.__nusers;
+#endif
+
+ return EOWNERDEAD;
+ }
+
+ if (robust
+ && __builtin_expect (mutex->__data.__owner
+ == PTHREAD_MUTEX_NOTRECOVERABLE, 0))
+ {
+ /* This mutex is now not recoverable. */
+ mutex->__data.__count = 0;
+
+ INTERNAL_SYSCALL_DECL (__err);
+ INTERNAL_SYSCALL (futex, __err, 4, &mutex->__data.__lock,
+ __lll_private_flag (FUTEX_UNLOCK_PI,
+ PTHREAD_ROBUST_MUTEX_PSHARED (mutex)),
+ 0, 0);
+
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+ return ENOTRECOVERABLE;
+ }
+
+ mutex->__data.__count = 1;
+ if (robust)
+ {
+ ENQUEUE_MUTEX_PI (mutex);
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+ }
+ }
+ break;
+
+ case PTHREAD_MUTEX_PP_RECURSIVE_NP:
+ case PTHREAD_MUTEX_PP_ERRORCHECK_NP:
+ case PTHREAD_MUTEX_PP_NORMAL_NP:
+ case PTHREAD_MUTEX_PP_ADAPTIVE_NP:
+ {
+ int kind = mutex->__data.__kind & PTHREAD_MUTEX_KIND_MASK_NP;
+
+ oldval = mutex->__data.__lock;
+
+ /* Check whether we already hold the mutex. */
+ if (mutex->__data.__owner == id)
+ {
+ if (kind == PTHREAD_MUTEX_ERRORCHECK_NP)
+ return EDEADLK;
+
+ if (kind == PTHREAD_MUTEX_RECURSIVE_NP)
+ {
+ /* Just bump the counter. */
+ if (__builtin_expect (mutex->__data.__count + 1 == 0, 0))
+ /* Overflow of the counter. */
+ return EAGAIN;
+
+ ++mutex->__data.__count;
+
+ return 0;
+ }
+ }
+
+ int oldprio = -1, ceilval;
+ do
+ {
+ int ceiling = (oldval & PTHREAD_MUTEX_PRIO_CEILING_MASK)
+ >> PTHREAD_MUTEX_PRIO_CEILING_SHIFT;
+
+ if (__pthread_current_priority () > ceiling)
+ {
+ if (oldprio != -1)
+ __pthread_tpp_change_priority (oldprio, -1);
+ return EINVAL;
+ }
+
+ int retval = __pthread_tpp_change_priority (oldprio, ceiling);
+ if (retval)
+ return retval;
+
+ ceilval = ceiling << PTHREAD_MUTEX_PRIO_CEILING_SHIFT;
+ oldprio = ceiling;
+
+ oldval
+ = atomic_compare_and_exchange_val_acq (&mutex->__data.__lock,
+#ifdef NO_INCR
+ ceilval | 2,
+#else
+ ceilval | 1,
+#endif
+ ceilval);
+
+ if (oldval == ceilval)
+ break;
+
+ do
+ {
+ oldval
+ = atomic_compare_and_exchange_val_acq (&mutex->__data.__lock,
+ ceilval | 2,
+ ceilval | 1);
+
+ if ((oldval & PTHREAD_MUTEX_PRIO_CEILING_MASK) != ceilval)
+ break;
+
+ if (oldval != ceilval)
+ lll_futex_wait (&mutex->__data.__lock, ceilval | 2,
+ PTHREAD_MUTEX_PSHARED (mutex));
+ }
+ while (atomic_compare_and_exchange_val_acq (&mutex->__data.__lock,
+ ceilval | 2, ceilval)
+ != ceilval);
+ }
+ while ((oldval & PTHREAD_MUTEX_PRIO_CEILING_MASK) != ceilval);
+
+ assert (mutex->__data.__owner == 0);
+ mutex->__data.__count = 1;
+ }
+ break;
+
+ default:
+ /* Correct code cannot set any other type. */
+ return EINVAL;
+ }
+
+ /* Record the ownership. */
+ mutex->__data.__owner = id;
+#ifndef NO_INCR
+ ++mutex->__data.__nusers;
+#endif
+
+ return 0;
+}
+#ifndef __pthread_mutex_lock
+strong_alias (__pthread_mutex_lock, pthread_mutex_lock)
+strong_alias (__pthread_mutex_lock, __pthread_mutex_lock_internal)
+#endif
+
+
+#ifdef NO_INCR
+void
+attribute_hidden internal_function
+__pthread_mutex_cond_lock_adjust (
+ pthread_mutex_t *mutex)
+{
+ assert ((mutex->__data.__kind & PTHREAD_MUTEX_PRIO_INHERIT_NP) != 0);
+ assert ((mutex->__data.__kind & PTHREAD_MUTEX_ROBUST_NORMAL_NP) == 0);
+ assert ((mutex->__data.__kind & PTHREAD_MUTEX_PSHARED_BIT) == 0);
+
+ /* Record the ownership. */
+ pid_t id = THREAD_GETMEM (THREAD_SELF, tid);
+ mutex->__data.__owner = id;
+
+ if (mutex->__data.__kind == PTHREAD_MUTEX_PI_RECURSIVE_NP)
+ ++mutex->__data.__count;
+}
+#endif
diff --git a/libpthread/nptl/pthread_mutex_setprioceiling.c b/libpthread/nptl/pthread_mutex_setprioceiling.c
new file mode 100644
index 000000000..a0dcc7896
--- /dev/null
+++ b/libpthread/nptl/pthread_mutex_setprioceiling.c
@@ -0,0 +1,118 @@
+/* Set current priority ceiling of pthread_mutex_t.
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2006.
+
+ 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 <stdbool.h>
+#include <errno.h>
+#include <pthreadP.h>
+
+
+int
+pthread_mutex_setprioceiling (mutex, prioceiling, old_ceiling)
+ pthread_mutex_t *mutex;
+ int prioceiling;
+ int *old_ceiling;
+{
+ /* The low bits of __kind aren't ever changed after pthread_mutex_init,
+ so we don't need a lock yet. */
+ if ((mutex->__data.__kind & PTHREAD_MUTEX_PRIO_PROTECT_NP) == 0)
+ return EINVAL;
+
+ if (__sched_fifo_min_prio == -1)
+ __init_sched_fifo_prio ();
+
+ if (__builtin_expect (prioceiling < __sched_fifo_min_prio, 0)
+ || __builtin_expect (prioceiling > __sched_fifo_max_prio, 0)
+ || __builtin_expect ((prioceiling
+ & (PTHREAD_MUTEXATTR_PRIO_CEILING_MASK
+ >> PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT))
+ != prioceiling, 0))
+ return EINVAL;
+
+ /* Check whether we already hold the mutex. */
+ bool locked = false;
+ int kind = PTHREAD_MUTEX_TYPE (mutex);
+ if (mutex->__data.__owner == THREAD_GETMEM (THREAD_SELF, tid))
+ {
+ if (kind == PTHREAD_MUTEX_PP_ERRORCHECK_NP)
+ return EDEADLK;
+
+ if (kind == PTHREAD_MUTEX_PP_RECURSIVE_NP)
+ locked = true;
+ }
+
+ int oldval = mutex->__data.__lock;
+ if (! locked)
+ do
+ {
+ /* Need to lock the mutex, but without obeying the priority
+ protect protocol. */
+ int ceilval = (oldval & PTHREAD_MUTEX_PRIO_CEILING_MASK);
+
+ oldval = atomic_compare_and_exchange_val_acq (&mutex->__data.__lock,
+ ceilval | 1, ceilval);
+ if (oldval == ceilval)
+ break;
+
+ do
+ {
+ oldval
+ = atomic_compare_and_exchange_val_acq (&mutex->__data.__lock,
+ ceilval | 2,
+ ceilval | 1);
+
+ if ((oldval & PTHREAD_MUTEX_PRIO_CEILING_MASK) != ceilval)
+ break;
+
+ if (oldval != ceilval)
+ lll_futex_wait (&mutex->__data.__lock, ceilval | 2,
+ PTHREAD_MUTEX_PSHARED (mutex));
+ }
+ while (atomic_compare_and_exchange_val_acq (&mutex->__data.__lock,
+ ceilval | 2, ceilval)
+ != ceilval);
+
+ if ((oldval & PTHREAD_MUTEX_PRIO_CEILING_MASK) != ceilval)
+ continue;
+ }
+ while (0);
+
+ int oldprio = (oldval & PTHREAD_MUTEX_PRIO_CEILING_MASK)
+ >> PTHREAD_MUTEX_PRIO_CEILING_SHIFT;
+ if (locked)
+ {
+ int ret = __pthread_tpp_change_priority (oldprio, prioceiling);
+ if (ret)
+ return ret;
+ }
+
+ if (old_ceiling != NULL)
+ *old_ceiling = oldprio;
+
+ int newlock = 0;
+ if (locked)
+ newlock = (mutex->__data.__lock & ~PTHREAD_MUTEX_PRIO_CEILING_MASK);
+ mutex->__data.__lock = newlock
+ | (prioceiling << PTHREAD_MUTEX_PRIO_CEILING_SHIFT);
+ atomic_full_barrier ();
+
+ lll_futex_wake (&mutex->__data.__lock, INT_MAX,
+ PTHREAD_MUTEX_PSHARED (mutex));
+
+ return 0;
+}
diff --git a/libpthread/nptl/pthread_mutex_timedlock.c b/libpthread/nptl/pthread_mutex_timedlock.c
new file mode 100644
index 000000000..f56f6c55e
--- /dev/null
+++ b/libpthread/nptl/pthread_mutex_timedlock.c
@@ -0,0 +1,489 @@
+/* Copyright (C) 2002-2007, 2008 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <assert.h>
+#include <errno.h>
+#include <time.h>
+#include "pthreadP.h"
+#include <lowlevellock.h>
+#include <not-cancel.h>
+
+/* We need to build this function with optimization to avoid
+ * lll_timedlock erroring out with
+ * error: can't find a register in class ‘GENERAL_REGS’ while reloading ‘asm’
+ */
+int
+#ifndef __OPTIMIZE__
+attribute_optimize("Os")
+#endif
+pthread_mutex_timedlock (
+ pthread_mutex_t *mutex,
+ const struct timespec *abstime)
+{
+ int oldval;
+ pid_t id = THREAD_GETMEM (THREAD_SELF, tid);
+ int result = 0;
+
+ /* We must not check ABSTIME here. If the thread does not block
+ abstime must not be checked for a valid value. */
+
+ switch (__builtin_expect (PTHREAD_MUTEX_TYPE (mutex),
+ PTHREAD_MUTEX_TIMED_NP))
+ {
+ /* Recursive mutex. */
+ case PTHREAD_MUTEX_RECURSIVE_NP:
+ /* Check whether we already hold the mutex. */
+ if (mutex->__data.__owner == id)
+ {
+ /* Just bump the counter. */
+ if (__builtin_expect (mutex->__data.__count + 1 == 0, 0))
+ /* Overflow of the counter. */
+ return EAGAIN;
+
+ ++mutex->__data.__count;
+
+ goto out;
+ }
+
+ /* We have to get the mutex. */
+ result = lll_timedlock (mutex->__data.__lock, abstime,
+ PTHREAD_MUTEX_PSHARED (mutex));
+
+ if (result != 0)
+ goto out;
+
+ /* Only locked once so far. */
+ mutex->__data.__count = 1;
+ break;
+
+ /* Error checking mutex. */
+ case PTHREAD_MUTEX_ERRORCHECK_NP:
+ /* Check whether we already hold the mutex. */
+ if (__builtin_expect (mutex->__data.__owner == id, 0))
+ return EDEADLK;
+
+ /* FALLTHROUGH */
+
+ case PTHREAD_MUTEX_TIMED_NP:
+ simple:
+ /* Normal mutex. */
+ result = lll_timedlock (mutex->__data.__lock, abstime,
+ PTHREAD_MUTEX_PSHARED (mutex));
+ break;
+
+ case PTHREAD_MUTEX_ADAPTIVE_NP:
+ if (! __is_smp)
+ goto simple;
+
+ if (lll_trylock (mutex->__data.__lock) != 0)
+ {
+ int cnt = 0;
+ int max_cnt = MIN (MAX_ADAPTIVE_COUNT,
+ mutex->__data.__spins * 2 + 10);
+ do
+ {
+ if (cnt++ >= max_cnt)
+ {
+ result = lll_timedlock (mutex->__data.__lock, abstime,
+ PTHREAD_MUTEX_PSHARED (mutex));
+ break;
+ }
+
+#ifdef BUSY_WAIT_NOP
+ BUSY_WAIT_NOP;
+#endif
+ }
+ while (lll_trylock (mutex->__data.__lock) != 0);
+
+ mutex->__data.__spins += (cnt - mutex->__data.__spins) / 8;
+ }
+ break;
+
+ case PTHREAD_MUTEX_ROBUST_RECURSIVE_NP:
+ case PTHREAD_MUTEX_ROBUST_ERRORCHECK_NP:
+ case PTHREAD_MUTEX_ROBUST_NORMAL_NP:
+ case PTHREAD_MUTEX_ROBUST_ADAPTIVE_NP:
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending,
+ &mutex->__data.__list.__next);
+
+ oldval = mutex->__data.__lock;
+ do
+ {
+ again:
+ if ((oldval & FUTEX_OWNER_DIED) != 0)
+ {
+ /* The previous owner died. Try locking the mutex. */
+ int newval = id | (oldval & FUTEX_WAITERS);
+
+ newval
+ = atomic_compare_and_exchange_val_acq (&mutex->__data.__lock,
+ newval, oldval);
+ if (newval != oldval)
+ {
+ oldval = newval;
+ goto again;
+ }
+
+ /* We got the mutex. */
+ mutex->__data.__count = 1;
+ /* But it is inconsistent unless marked otherwise. */
+ mutex->__data.__owner = PTHREAD_MUTEX_INCONSISTENT;
+
+ ENQUEUE_MUTEX (mutex);
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+
+ /* Note that we deliberately exit here. If we fall
+ through to the end of the function __nusers would be
+ incremented which is not correct because the old
+ owner has to be discounted. */
+ return EOWNERDEAD;
+ }
+
+ /* Check whether we already hold the mutex. */
+ if (__builtin_expect ((oldval & FUTEX_TID_MASK) == id, 0))
+ {
+ int kind = PTHREAD_MUTEX_TYPE (mutex);
+ if (kind == PTHREAD_MUTEX_ROBUST_ERRORCHECK_NP)
+ {
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending,
+ NULL);
+ return EDEADLK;
+ }
+
+ if (kind == PTHREAD_MUTEX_ROBUST_RECURSIVE_NP)
+ {
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending,
+ NULL);
+
+ /* Just bump the counter. */
+ if (__builtin_expect (mutex->__data.__count + 1 == 0, 0))
+ /* Overflow of the counter. */
+ return EAGAIN;
+
+ ++mutex->__data.__count;
+
+ return 0;
+ }
+ }
+
+ result = lll_robust_timedlock (mutex->__data.__lock, abstime, id,
+ PTHREAD_ROBUST_MUTEX_PSHARED (mutex));
+
+ if (__builtin_expect (mutex->__data.__owner
+ == PTHREAD_MUTEX_NOTRECOVERABLE, 0))
+ {
+ /* This mutex is now not recoverable. */
+ mutex->__data.__count = 0;
+ lll_unlock (mutex->__data.__lock,
+ PTHREAD_ROBUST_MUTEX_PSHARED (mutex));
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+ return ENOTRECOVERABLE;
+ }
+
+ if (result == ETIMEDOUT || result == EINVAL)
+ goto out;
+
+ oldval = result;
+ }
+ while ((oldval & FUTEX_OWNER_DIED) != 0);
+
+ mutex->__data.__count = 1;
+ ENQUEUE_MUTEX (mutex);
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+ break;
+
+ case PTHREAD_MUTEX_PI_RECURSIVE_NP:
+ case PTHREAD_MUTEX_PI_ERRORCHECK_NP:
+ case PTHREAD_MUTEX_PI_NORMAL_NP:
+ case PTHREAD_MUTEX_PI_ADAPTIVE_NP:
+ case PTHREAD_MUTEX_PI_ROBUST_RECURSIVE_NP:
+ case PTHREAD_MUTEX_PI_ROBUST_ERRORCHECK_NP:
+ case PTHREAD_MUTEX_PI_ROBUST_NORMAL_NP:
+ case PTHREAD_MUTEX_PI_ROBUST_ADAPTIVE_NP:
+ {
+ int kind = mutex->__data.__kind & PTHREAD_MUTEX_KIND_MASK_NP;
+ int robust = mutex->__data.__kind & PTHREAD_MUTEX_ROBUST_NORMAL_NP;
+
+ if (robust)
+ /* Note: robust PI futexes are signaled by setting bit 0. */
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending,
+ (void *) (((uintptr_t) &mutex->__data.__list.__next)
+ | 1));
+
+ oldval = mutex->__data.__lock;
+
+ /* Check whether we already hold the mutex. */
+ if (__builtin_expect ((oldval & FUTEX_TID_MASK) == id, 0))
+ {
+ if (kind == PTHREAD_MUTEX_ERRORCHECK_NP)
+ {
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+ return EDEADLK;
+ }
+
+ if (kind == PTHREAD_MUTEX_RECURSIVE_NP)
+ {
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+
+ /* Just bump the counter. */
+ if (__builtin_expect (mutex->__data.__count + 1 == 0, 0))
+ /* Overflow of the counter. */
+ return EAGAIN;
+
+ ++mutex->__data.__count;
+
+ return 0;
+ }
+ }
+
+ oldval = atomic_compare_and_exchange_val_acq (&mutex->__data.__lock,
+ id, 0);
+
+ if (oldval != 0)
+ {
+ /* The mutex is locked. The kernel will now take care of
+ everything. The timeout value must be a relative value.
+ Convert it. */
+ int private = (robust
+ ? PTHREAD_ROBUST_MUTEX_PSHARED (mutex)
+ : PTHREAD_MUTEX_PSHARED (mutex));
+ INTERNAL_SYSCALL_DECL (__err);
+
+ int e = INTERNAL_SYSCALL (futex, __err, 4, &mutex->__data.__lock,
+ __lll_private_flag (FUTEX_LOCK_PI,
+ private), 1,
+ abstime);
+ if (INTERNAL_SYSCALL_ERROR_P (e, __err))
+ {
+ if (INTERNAL_SYSCALL_ERRNO (e, __err) == ETIMEDOUT)
+ return ETIMEDOUT;
+
+ if (INTERNAL_SYSCALL_ERRNO (e, __err) == ESRCH
+ || INTERNAL_SYSCALL_ERRNO (e, __err) == EDEADLK)
+ {
+ assert (INTERNAL_SYSCALL_ERRNO (e, __err) != EDEADLK
+ || (kind != PTHREAD_MUTEX_ERRORCHECK_NP
+ && kind != PTHREAD_MUTEX_RECURSIVE_NP));
+ /* ESRCH can happen only for non-robust PI mutexes where
+ the owner of the lock died. */
+ assert (INTERNAL_SYSCALL_ERRNO (e, __err) != ESRCH
+ || !robust);
+
+ /* Delay the thread until the timeout is reached.
+ Then return ETIMEDOUT. */
+ struct timespec reltime;
+ struct timespec now;
+
+ INTERNAL_SYSCALL (clock_gettime, __err, 2, CLOCK_REALTIME,
+ &now);
+ reltime.tv_sec = abstime->tv_sec - now.tv_sec;
+ reltime.tv_nsec = abstime->tv_nsec - now.tv_nsec;
+ if (reltime.tv_nsec < 0)
+ {
+ reltime.tv_nsec += 1000000000;
+ --reltime.tv_sec;
+ }
+ if (reltime.tv_sec >= 0)
+ while (nanosleep_not_cancel (&reltime, &reltime) != 0)
+ continue;
+
+ return ETIMEDOUT;
+ }
+
+ return INTERNAL_SYSCALL_ERRNO (e, __err);
+ }
+
+ oldval = mutex->__data.__lock;
+
+ assert (robust || (oldval & FUTEX_OWNER_DIED) == 0);
+ }
+
+ if (__builtin_expect (oldval & FUTEX_OWNER_DIED, 0))
+ {
+ atomic_and (&mutex->__data.__lock, ~FUTEX_OWNER_DIED);
+
+ /* We got the mutex. */
+ mutex->__data.__count = 1;
+ /* But it is inconsistent unless marked otherwise. */
+ mutex->__data.__owner = PTHREAD_MUTEX_INCONSISTENT;
+
+ ENQUEUE_MUTEX_PI (mutex);
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+
+ /* Note that we deliberately exit here. If we fall
+ through to the end of the function __nusers would be
+ incremented which is not correct because the old owner
+ has to be discounted. */
+ return EOWNERDEAD;
+ }
+
+ if (robust
+ && __builtin_expect (mutex->__data.__owner
+ == PTHREAD_MUTEX_NOTRECOVERABLE, 0))
+ {
+ /* This mutex is now not recoverable. */
+ mutex->__data.__count = 0;
+
+ INTERNAL_SYSCALL_DECL (__err);
+ INTERNAL_SYSCALL (futex, __err, 4, &mutex->__data.__lock,
+ __lll_private_flag (FUTEX_UNLOCK_PI,
+ PTHREAD_ROBUST_MUTEX_PSHARED (mutex)),
+ 0, 0);
+
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+ return ENOTRECOVERABLE;
+ }
+
+ mutex->__data.__count = 1;
+ if (robust)
+ {
+ ENQUEUE_MUTEX_PI (mutex);
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+ }
+ }
+ break;
+
+ case PTHREAD_MUTEX_PP_RECURSIVE_NP:
+ case PTHREAD_MUTEX_PP_ERRORCHECK_NP:
+ case PTHREAD_MUTEX_PP_NORMAL_NP:
+ case PTHREAD_MUTEX_PP_ADAPTIVE_NP:
+ {
+ int kind = mutex->__data.__kind & PTHREAD_MUTEX_KIND_MASK_NP;
+
+ oldval = mutex->__data.__lock;
+
+ /* Check whether we already hold the mutex. */
+ if (mutex->__data.__owner == id)
+ {
+ if (kind == PTHREAD_MUTEX_ERRORCHECK_NP)
+ return EDEADLK;
+
+ if (kind == PTHREAD_MUTEX_RECURSIVE_NP)
+ {
+ /* Just bump the counter. */
+ if (__builtin_expect (mutex->__data.__count + 1 == 0, 0))
+ /* Overflow of the counter. */
+ return EAGAIN;
+
+ ++mutex->__data.__count;
+
+ return 0;
+ }
+ }
+
+ int oldprio = -1, ceilval;
+ do
+ {
+ int ceiling = (oldval & PTHREAD_MUTEX_PRIO_CEILING_MASK)
+ >> PTHREAD_MUTEX_PRIO_CEILING_SHIFT;
+
+ if (__pthread_current_priority () > ceiling)
+ {
+ result = EINVAL;
+ failpp:
+ if (oldprio != -1)
+ __pthread_tpp_change_priority (oldprio, -1);
+ return result;
+ }
+
+ result = __pthread_tpp_change_priority (oldprio, ceiling);
+ if (result)
+ return result;
+
+ ceilval = ceiling << PTHREAD_MUTEX_PRIO_CEILING_SHIFT;
+ oldprio = ceiling;
+
+ oldval
+ = atomic_compare_and_exchange_val_acq (&mutex->__data.__lock,
+ ceilval | 1, ceilval);
+
+ if (oldval == ceilval)
+ break;
+
+ do
+ {
+ oldval
+ = atomic_compare_and_exchange_val_acq (&mutex->__data.__lock,
+ ceilval | 2,
+ ceilval | 1);
+
+ if ((oldval & PTHREAD_MUTEX_PRIO_CEILING_MASK) != ceilval)
+ break;
+
+ if (oldval != ceilval)
+ {
+ /* Reject invalid timeouts. */
+ if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
+ {
+ result = EINVAL;
+ goto failpp;
+ }
+
+ struct timeval tv;
+ struct timespec rt;
+
+ /* Get the current time. */
+ (void) gettimeofday (&tv, NULL);
+
+ /* Compute relative timeout. */
+ rt.tv_sec = abstime->tv_sec - tv.tv_sec;
+ rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+ if (rt.tv_nsec < 0)
+ {
+ rt.tv_nsec += 1000000000;
+ --rt.tv_sec;
+ }
+
+ /* Already timed out? */
+ if (rt.tv_sec < 0)
+ {
+ result = ETIMEDOUT;
+ goto failpp;
+ }
+
+ lll_futex_timed_wait (&mutex->__data.__lock,
+ ceilval | 2, &rt,
+ PTHREAD_MUTEX_PSHARED (mutex));
+ }
+ }
+ while (atomic_compare_and_exchange_val_acq (&mutex->__data.__lock,
+ ceilval | 2, ceilval)
+ != ceilval);
+ }
+ while ((oldval & PTHREAD_MUTEX_PRIO_CEILING_MASK) != ceilval);
+
+ assert (mutex->__data.__owner == 0);
+ mutex->__data.__count = 1;
+ }
+ break;
+
+ default:
+ /* Correct code cannot set any other type. */
+ return EINVAL;
+ }
+
+ if (result == 0)
+ {
+ /* Record the ownership. */
+ mutex->__data.__owner = id;
+ ++mutex->__data.__nusers;
+ }
+
+ out:
+ return result;
+}
diff --git a/libpthread/nptl/pthread_mutex_trylock.c b/libpthread/nptl/pthread_mutex_trylock.c
new file mode 100644
index 000000000..e0d54bda7
--- /dev/null
+++ b/libpthread/nptl/pthread_mutex_trylock.c
@@ -0,0 +1,381 @@
+/* Copyright (C) 2002, 2003, 2005-2007, 2008 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <assert.h>
+#include <errno.h>
+#include <stdlib.h>
+#include "pthreadP.h"
+#include <lowlevellock.h>
+
+
+int
+__pthread_mutex_trylock (
+ pthread_mutex_t *mutex)
+{
+ int oldval;
+ pid_t id = THREAD_GETMEM (THREAD_SELF, tid);
+
+ switch (__builtin_expect (PTHREAD_MUTEX_TYPE (mutex),
+ PTHREAD_MUTEX_TIMED_NP))
+ {
+ /* Recursive mutex. */
+ case PTHREAD_MUTEX_RECURSIVE_NP:
+ /* Check whether we already hold the mutex. */
+ if (mutex->__data.__owner == id)
+ {
+ /* Just bump the counter. */
+ if (__builtin_expect (mutex->__data.__count + 1 == 0, 0))
+ /* Overflow of the counter. */
+ return EAGAIN;
+
+ ++mutex->__data.__count;
+ return 0;
+ }
+
+ if (lll_trylock (mutex->__data.__lock) == 0)
+ {
+ /* Record the ownership. */
+ mutex->__data.__owner = id;
+ mutex->__data.__count = 1;
+ ++mutex->__data.__nusers;
+ return 0;
+ }
+ break;
+
+ case PTHREAD_MUTEX_ERRORCHECK_NP:
+ case PTHREAD_MUTEX_TIMED_NP:
+ case PTHREAD_MUTEX_ADAPTIVE_NP:
+ /* Normal mutex. */
+ if (lll_trylock (mutex->__data.__lock) != 0)
+ break;
+
+ /* Record the ownership. */
+ mutex->__data.__owner = id;
+ ++mutex->__data.__nusers;
+
+ return 0;
+
+ case PTHREAD_MUTEX_ROBUST_RECURSIVE_NP:
+ case PTHREAD_MUTEX_ROBUST_ERRORCHECK_NP:
+ case PTHREAD_MUTEX_ROBUST_NORMAL_NP:
+ case PTHREAD_MUTEX_ROBUST_ADAPTIVE_NP:
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending,
+ &mutex->__data.__list.__next);
+
+ oldval = mutex->__data.__lock;
+ do
+ {
+ again:
+ if ((oldval & FUTEX_OWNER_DIED) != 0)
+ {
+ /* The previous owner died. Try locking the mutex. */
+ int newval = id | (oldval & FUTEX_WAITERS);
+
+ newval
+ = atomic_compare_and_exchange_val_acq (&mutex->__data.__lock,
+ newval, oldval);
+
+ if (newval != oldval)
+ {
+ oldval = newval;
+ goto again;
+ }
+
+ /* We got the mutex. */
+ mutex->__data.__count = 1;
+ /* But it is inconsistent unless marked otherwise. */
+ mutex->__data.__owner = PTHREAD_MUTEX_INCONSISTENT;
+
+ ENQUEUE_MUTEX (mutex);
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+
+ /* Note that we deliberately exist here. If we fall
+ through to the end of the function __nusers would be
+ incremented which is not correct because the old
+ owner has to be discounted. */
+ return EOWNERDEAD;
+ }
+
+ /* Check whether we already hold the mutex. */
+ if (__builtin_expect ((oldval & FUTEX_TID_MASK) == id, 0))
+ {
+ int kind = PTHREAD_MUTEX_TYPE (mutex);
+ if (kind == PTHREAD_MUTEX_ROBUST_ERRORCHECK_NP)
+ {
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending,
+ NULL);
+ return EDEADLK;
+ }
+
+ if (kind == PTHREAD_MUTEX_ROBUST_RECURSIVE_NP)
+ {
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending,
+ NULL);
+
+ /* Just bump the counter. */
+ if (__builtin_expect (mutex->__data.__count + 1 == 0, 0))
+ /* Overflow of the counter. */
+ return EAGAIN;
+
+ ++mutex->__data.__count;
+
+ return 0;
+ }
+ }
+
+ oldval = lll_robust_trylock (mutex->__data.__lock, id);
+ if (oldval != 0 && (oldval & FUTEX_OWNER_DIED) == 0)
+ {
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+
+ return EBUSY;
+ }
+
+ if (__builtin_expect (mutex->__data.__owner
+ == PTHREAD_MUTEX_NOTRECOVERABLE, 0))
+ {
+ /* This mutex is now not recoverable. */
+ mutex->__data.__count = 0;
+ if (oldval == id)
+ lll_unlock (mutex->__data.__lock,
+ PTHREAD_ROBUST_MUTEX_PSHARED (mutex));
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+ return ENOTRECOVERABLE;
+ }
+ }
+ while ((oldval & FUTEX_OWNER_DIED) != 0);
+
+ ENQUEUE_MUTEX (mutex);
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+
+ mutex->__data.__owner = id;
+ ++mutex->__data.__nusers;
+ mutex->__data.__count = 1;
+
+ return 0;
+
+ case PTHREAD_MUTEX_PI_RECURSIVE_NP:
+ case PTHREAD_MUTEX_PI_ERRORCHECK_NP:
+ case PTHREAD_MUTEX_PI_NORMAL_NP:
+ case PTHREAD_MUTEX_PI_ADAPTIVE_NP:
+ case PTHREAD_MUTEX_PI_ROBUST_RECURSIVE_NP:
+ case PTHREAD_MUTEX_PI_ROBUST_ERRORCHECK_NP:
+ case PTHREAD_MUTEX_PI_ROBUST_NORMAL_NP:
+ case PTHREAD_MUTEX_PI_ROBUST_ADAPTIVE_NP:
+ {
+ int kind = mutex->__data.__kind & PTHREAD_MUTEX_KIND_MASK_NP;
+ int robust = mutex->__data.__kind & PTHREAD_MUTEX_ROBUST_NORMAL_NP;
+
+ if (robust)
+ /* Note: robust PI futexes are signaled by setting bit 0. */
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending,
+ (void *) (((uintptr_t) &mutex->__data.__list.__next)
+ | 1));
+
+ oldval = mutex->__data.__lock;
+
+ /* Check whether we already hold the mutex. */
+ if (__builtin_expect ((oldval & FUTEX_TID_MASK) == id, 0))
+ {
+ if (kind == PTHREAD_MUTEX_ERRORCHECK_NP)
+ {
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+ return EDEADLK;
+ }
+
+ if (kind == PTHREAD_MUTEX_RECURSIVE_NP)
+ {
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+
+ /* Just bump the counter. */
+ if (__builtin_expect (mutex->__data.__count + 1 == 0, 0))
+ /* Overflow of the counter. */
+ return EAGAIN;
+
+ ++mutex->__data.__count;
+
+ return 0;
+ }
+ }
+
+ oldval
+ = atomic_compare_and_exchange_val_acq (&mutex->__data.__lock,
+ id, 0);
+
+ if (oldval != 0)
+ {
+ if ((oldval & FUTEX_OWNER_DIED) == 0)
+ {
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+
+ return EBUSY;
+ }
+
+ assert (robust);
+
+ /* The mutex owner died. The kernel will now take care of
+ everything. */
+ int private = (robust
+ ? PTHREAD_ROBUST_MUTEX_PSHARED (mutex)
+ : PTHREAD_MUTEX_PSHARED (mutex));
+ INTERNAL_SYSCALL_DECL (__err);
+ int e = INTERNAL_SYSCALL (futex, __err, 4, &mutex->__data.__lock,
+ __lll_private_flag (FUTEX_TRYLOCK_PI,
+ private), 0, 0);
+
+ if (INTERNAL_SYSCALL_ERROR_P (e, __err)
+ && INTERNAL_SYSCALL_ERRNO (e, __err) == EWOULDBLOCK)
+ {
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+
+ return EBUSY;
+ }
+
+ oldval = mutex->__data.__lock;
+ }
+
+ if (__builtin_expect (oldval & FUTEX_OWNER_DIED, 0))
+ {
+ atomic_and (&mutex->__data.__lock, ~FUTEX_OWNER_DIED);
+
+ /* We got the mutex. */
+ mutex->__data.__count = 1;
+ /* But it is inconsistent unless marked otherwise. */
+ mutex->__data.__owner = PTHREAD_MUTEX_INCONSISTENT;
+
+ ENQUEUE_MUTEX (mutex);
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+
+ /* Note that we deliberately exit here. If we fall
+ through to the end of the function __nusers would be
+ incremented which is not correct because the old owner
+ has to be discounted. */
+ return EOWNERDEAD;
+ }
+
+ if (robust
+ && __builtin_expect (mutex->__data.__owner
+ == PTHREAD_MUTEX_NOTRECOVERABLE, 0))
+ {
+ /* This mutex is now not recoverable. */
+ mutex->__data.__count = 0;
+
+ INTERNAL_SYSCALL_DECL (__err);
+ INTERNAL_SYSCALL (futex, __err, 4, &mutex->__data.__lock,
+ __lll_private_flag (FUTEX_UNLOCK_PI,
+ PTHREAD_ROBUST_MUTEX_PSHARED (mutex)),
+ 0, 0);
+
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+ return ENOTRECOVERABLE;
+ }
+
+ if (robust)
+ {
+ ENQUEUE_MUTEX_PI (mutex);
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+ }
+
+ mutex->__data.__owner = id;
+ ++mutex->__data.__nusers;
+ mutex->__data.__count = 1;
+
+ return 0;
+ }
+
+ case PTHREAD_MUTEX_PP_RECURSIVE_NP:
+ case PTHREAD_MUTEX_PP_ERRORCHECK_NP:
+ case PTHREAD_MUTEX_PP_NORMAL_NP:
+ case PTHREAD_MUTEX_PP_ADAPTIVE_NP:
+ {
+ int kind = mutex->__data.__kind & PTHREAD_MUTEX_KIND_MASK_NP;
+
+ oldval = mutex->__data.__lock;
+
+ /* Check whether we already hold the mutex. */
+ if (mutex->__data.__owner == id)
+ {
+ if (kind == PTHREAD_MUTEX_ERRORCHECK_NP)
+ return EDEADLK;
+
+ if (kind == PTHREAD_MUTEX_RECURSIVE_NP)
+ {
+ /* Just bump the counter. */
+ if (__builtin_expect (mutex->__data.__count + 1 == 0, 0))
+ /* Overflow of the counter. */
+ return EAGAIN;
+
+ ++mutex->__data.__count;
+
+ return 0;
+ }
+ }
+
+ int oldprio = -1, ceilval;
+ do
+ {
+ int ceiling = (oldval & PTHREAD_MUTEX_PRIO_CEILING_MASK)
+ >> PTHREAD_MUTEX_PRIO_CEILING_SHIFT;
+
+ if (__pthread_current_priority () > ceiling)
+ {
+ if (oldprio != -1)
+ __pthread_tpp_change_priority (oldprio, -1);
+ return EINVAL;
+ }
+
+ int retval = __pthread_tpp_change_priority (oldprio, ceiling);
+ if (retval)
+ return retval;
+
+ ceilval = ceiling << PTHREAD_MUTEX_PRIO_CEILING_SHIFT;
+ oldprio = ceiling;
+
+ oldval
+ = atomic_compare_and_exchange_val_acq (&mutex->__data.__lock,
+ ceilval | 1, ceilval);
+
+ if (oldval == ceilval)
+ break;
+ }
+ while ((oldval & PTHREAD_MUTEX_PRIO_CEILING_MASK) != ceilval);
+
+ if (oldval != ceilval)
+ {
+ __pthread_tpp_change_priority (oldprio, -1);
+ break;
+ }
+
+ assert (mutex->__data.__owner == 0);
+ /* Record the ownership. */
+ mutex->__data.__owner = id;
+ ++mutex->__data.__nusers;
+ mutex->__data.__count = 1;
+
+ return 0;
+ }
+ break;
+
+ default:
+ /* Correct code cannot set any other type. */
+ return EINVAL;
+ }
+
+ return EBUSY;
+}
+strong_alias (__pthread_mutex_trylock, pthread_mutex_trylock)
diff --git a/libpthread/nptl/pthread_mutex_unlock.c b/libpthread/nptl/pthread_mutex_unlock.c
new file mode 100644
index 000000000..1123e3c42
--- /dev/null
+++ b/libpthread/nptl/pthread_mutex_unlock.c
@@ -0,0 +1,293 @@
+/* Copyright (C) 2002, 2003, 2005-2008, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <assert.h>
+#include <errno.h>
+#include <stdlib.h>
+#include "pthreadP.h"
+#include <lowlevellock.h>
+
+static int
+internal_function
+__pthread_mutex_unlock_full (pthread_mutex_t *mutex, int decr)
+ __attribute_noinline__;
+
+int
+internal_function attribute_hidden
+__pthread_mutex_unlock_usercnt (
+ pthread_mutex_t *mutex,
+ int decr)
+{
+ int type = PTHREAD_MUTEX_TYPE (mutex);
+ if (__builtin_expect (type & ~PTHREAD_MUTEX_KIND_MASK_NP, 0))
+ return __pthread_mutex_unlock_full (mutex, decr);
+
+ if (__builtin_expect (type, PTHREAD_MUTEX_TIMED_NP)
+ == PTHREAD_MUTEX_TIMED_NP)
+ {
+ /* Always reset the owner field. */
+ normal:
+ mutex->__data.__owner = 0;
+ if (decr)
+ /* One less user. */
+ --mutex->__data.__nusers;
+
+ /* Unlock. */
+ lll_unlock (mutex->__data.__lock, PTHREAD_MUTEX_PSHARED (mutex));
+ return 0;
+ }
+ else if (__builtin_expect (type == PTHREAD_MUTEX_RECURSIVE_NP, 1))
+ {
+ /* Recursive mutex. */
+ if (mutex->__data.__owner != THREAD_GETMEM (THREAD_SELF, tid))
+ return EPERM;
+
+ if (--mutex->__data.__count != 0)
+ /* We still hold the mutex. */
+ return 0;
+ goto normal;
+ }
+ else if (__builtin_expect (type == PTHREAD_MUTEX_ADAPTIVE_NP, 1))
+ goto normal;
+ else
+ {
+ /* Error checking mutex. */
+ assert (type == PTHREAD_MUTEX_ERRORCHECK_NP);
+ if (mutex->__data.__owner != THREAD_GETMEM (THREAD_SELF, tid)
+ || ! lll_islocked (mutex->__data.__lock))
+ return EPERM;
+ goto normal;
+ }
+}
+
+
+static int
+internal_function
+__pthread_mutex_unlock_full (pthread_mutex_t *mutex, int decr)
+{
+ int newowner = 0;
+
+ switch (PTHREAD_MUTEX_TYPE (mutex))
+ {
+ case PTHREAD_MUTEX_ROBUST_RECURSIVE_NP:
+ /* Recursive mutex. */
+ if ((mutex->__data.__lock & FUTEX_TID_MASK)
+ == THREAD_GETMEM (THREAD_SELF, tid)
+ && __builtin_expect (mutex->__data.__owner
+ == PTHREAD_MUTEX_INCONSISTENT, 0))
+ {
+ if (--mutex->__data.__count != 0)
+ /* We still hold the mutex. */
+ return ENOTRECOVERABLE;
+
+ goto notrecoverable;
+ }
+
+ if (mutex->__data.__owner != THREAD_GETMEM (THREAD_SELF, tid))
+ return EPERM;
+
+ if (--mutex->__data.__count != 0)
+ /* We still hold the mutex. */
+ return 0;
+
+ goto robust;
+
+ case PTHREAD_MUTEX_ROBUST_ERRORCHECK_NP:
+ case PTHREAD_MUTEX_ROBUST_NORMAL_NP:
+ case PTHREAD_MUTEX_ROBUST_ADAPTIVE_NP:
+ if ((mutex->__data.__lock & FUTEX_TID_MASK)
+ != THREAD_GETMEM (THREAD_SELF, tid)
+ || ! lll_islocked (mutex->__data.__lock))
+ return EPERM;
+
+ /* If the previous owner died and the caller did not succeed in
+ making the state consistent, mark the mutex as unrecoverable
+ and make all waiters. */
+ if (__builtin_expect (mutex->__data.__owner
+ == PTHREAD_MUTEX_INCONSISTENT, 0))
+ notrecoverable:
+ newowner = PTHREAD_MUTEX_NOTRECOVERABLE;
+
+ robust:
+ /* Remove mutex from the list. */
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending,
+ &mutex->__data.__list.__next);
+ DEQUEUE_MUTEX (mutex);
+
+ mutex->__data.__owner = newowner;
+ if (decr)
+ /* One less user. */
+ --mutex->__data.__nusers;
+
+ /* Unlock. */
+ lll_robust_unlock (mutex->__data.__lock,
+ PTHREAD_ROBUST_MUTEX_PSHARED (mutex));
+
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+ break;
+
+ case PTHREAD_MUTEX_PI_RECURSIVE_NP:
+ /* Recursive mutex. */
+ if (mutex->__data.__owner != THREAD_GETMEM (THREAD_SELF, tid))
+ return EPERM;
+
+ if (--mutex->__data.__count != 0)
+ /* We still hold the mutex. */
+ return 0;
+ goto continue_pi_non_robust;
+
+ case PTHREAD_MUTEX_PI_ROBUST_RECURSIVE_NP:
+ /* Recursive mutex. */
+ if ((mutex->__data.__lock & FUTEX_TID_MASK)
+ == THREAD_GETMEM (THREAD_SELF, tid)
+ && __builtin_expect (mutex->__data.__owner
+ == PTHREAD_MUTEX_INCONSISTENT, 0))
+ {
+ if (--mutex->__data.__count != 0)
+ /* We still hold the mutex. */
+ return ENOTRECOVERABLE;
+
+ goto pi_notrecoverable;
+ }
+
+ if (mutex->__data.__owner != THREAD_GETMEM (THREAD_SELF, tid))
+ return EPERM;
+
+ if (--mutex->__data.__count != 0)
+ /* We still hold the mutex. */
+ return 0;
+
+ goto continue_pi_robust;
+
+ case PTHREAD_MUTEX_PI_ERRORCHECK_NP:
+ case PTHREAD_MUTEX_PI_NORMAL_NP:
+ case PTHREAD_MUTEX_PI_ADAPTIVE_NP:
+ case PTHREAD_MUTEX_PI_ROBUST_ERRORCHECK_NP:
+ case PTHREAD_MUTEX_PI_ROBUST_NORMAL_NP:
+ case PTHREAD_MUTEX_PI_ROBUST_ADAPTIVE_NP:
+ if ((mutex->__data.__lock & FUTEX_TID_MASK)
+ != THREAD_GETMEM (THREAD_SELF, tid)
+ || ! lll_islocked (mutex->__data.__lock))
+ return EPERM;
+
+ /* If the previous owner died and the caller did not succeed in
+ making the state consistent, mark the mutex as unrecoverable
+ and make all waiters. */
+ if ((mutex->__data.__kind & PTHREAD_MUTEX_ROBUST_NORMAL_NP) != 0
+ && __builtin_expect (mutex->__data.__owner
+ == PTHREAD_MUTEX_INCONSISTENT, 0))
+ pi_notrecoverable:
+ newowner = PTHREAD_MUTEX_NOTRECOVERABLE;
+
+ if ((mutex->__data.__kind & PTHREAD_MUTEX_ROBUST_NORMAL_NP) != 0)
+ {
+ continue_pi_robust:
+ /* Remove mutex from the list.
+ Note: robust PI futexes are signaled by setting bit 0. */
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending,
+ (void *) (((uintptr_t) &mutex->__data.__list.__next)
+ | 1));
+ DEQUEUE_MUTEX (mutex);
+ }
+
+ continue_pi_non_robust:
+ mutex->__data.__owner = newowner;
+ if (decr)
+ /* One less user. */
+ --mutex->__data.__nusers;
+
+ /* Unlock. */
+ if ((mutex->__data.__lock & FUTEX_WAITERS) != 0
+ || atomic_compare_and_exchange_bool_rel (&mutex->__data.__lock, 0,
+ THREAD_GETMEM (THREAD_SELF,
+ tid)))
+ {
+ int robust = mutex->__data.__kind & PTHREAD_MUTEX_ROBUST_NORMAL_NP;
+ int private = (robust
+ ? PTHREAD_ROBUST_MUTEX_PSHARED (mutex)
+ : PTHREAD_MUTEX_PSHARED (mutex));
+ INTERNAL_SYSCALL_DECL (__err);
+ INTERNAL_SYSCALL (futex, __err, 2, &mutex->__data.__lock,
+ __lll_private_flag (FUTEX_UNLOCK_PI, private));
+ }
+
+ THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
+ break;
+
+ case PTHREAD_MUTEX_PP_RECURSIVE_NP:
+ /* Recursive mutex. */
+ if (mutex->__data.__owner != THREAD_GETMEM (THREAD_SELF, tid))
+ return EPERM;
+
+ if (--mutex->__data.__count != 0)
+ /* We still hold the mutex. */
+ return 0;
+ goto pp;
+
+ case PTHREAD_MUTEX_PP_ERRORCHECK_NP:
+ /* Error checking mutex. */
+ if (mutex->__data.__owner != THREAD_GETMEM (THREAD_SELF, tid)
+ || (mutex->__data.__lock & ~ PTHREAD_MUTEX_PRIO_CEILING_MASK) == 0)
+ return EPERM;
+ /* FALLTHROUGH */
+
+ case PTHREAD_MUTEX_PP_NORMAL_NP:
+ case PTHREAD_MUTEX_PP_ADAPTIVE_NP:
+ /* Always reset the owner field. */
+ pp:
+ mutex->__data.__owner = 0;
+
+ if (decr)
+ /* One less user. */
+ --mutex->__data.__nusers;
+
+ /* Unlock. */
+ int newval, oldval;
+ do
+ {
+ oldval = mutex->__data.__lock;
+ newval = oldval & PTHREAD_MUTEX_PRIO_CEILING_MASK;
+ }
+ while (atomic_compare_and_exchange_bool_rel (&mutex->__data.__lock,
+ newval, oldval));
+
+ if ((oldval & ~PTHREAD_MUTEX_PRIO_CEILING_MASK) > 1)
+ lll_futex_wake (&mutex->__data.__lock, 1,
+ PTHREAD_MUTEX_PSHARED (mutex));
+
+ int oldprio = newval >> PTHREAD_MUTEX_PRIO_CEILING_SHIFT;
+ return __pthread_tpp_change_priority (oldprio, -1);
+
+ default:
+ /* Correct code cannot set any other type. */
+ return EINVAL;
+ }
+
+ return 0;
+}
+
+
+int
+attribute_protected
+__pthread_mutex_unlock (
+ pthread_mutex_t *mutex)
+{
+ return __pthread_mutex_unlock_usercnt (mutex, 1);
+}
+strong_alias (__pthread_mutex_unlock, pthread_mutex_unlock)
+strong_alias (__pthread_mutex_unlock, __pthread_mutex_unlock_internal)
diff --git a/libpthread/nptl/pthread_mutexattr_destroy.c b/libpthread/nptl/pthread_mutexattr_destroy.c
new file mode 100644
index 000000000..ce4711bd5
--- /dev/null
+++ b/libpthread/nptl/pthread_mutexattr_destroy.c
@@ -0,0 +1,27 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthreadP.h>
+
+
+int
+__pthread_mutexattr_destroy (pthread_mutexattr_t *attr)
+{
+ return 0;
+}
+strong_alias (__pthread_mutexattr_destroy, pthread_mutexattr_destroy)
diff --git a/libpthread/nptl/pthread_mutexattr_getprioceiling.c b/libpthread/nptl/pthread_mutexattr_getprioceiling.c
new file mode 100644
index 000000000..774b951b7
--- /dev/null
+++ b/libpthread/nptl/pthread_mutexattr_getprioceiling.c
@@ -0,0 +1,47 @@
+/* Get priority ceiling setting from pthread_mutexattr_t.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2006.
+
+ 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 <pthreadP.h>
+
+
+int
+pthread_mutexattr_getprioceiling (
+ const pthread_mutexattr_t *attr,
+ int *prioceiling)
+{
+ const struct pthread_mutexattr *iattr;
+ int ceiling;
+
+ iattr = (const struct pthread_mutexattr *) attr;
+
+ ceiling = ((iattr->mutexkind & PTHREAD_MUTEXATTR_PRIO_CEILING_MASK)
+ >> PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT);
+
+ if (! ceiling)
+ {
+ if (__sched_fifo_min_prio == -1)
+ __init_sched_fifo_prio ();
+ if (ceiling < __sched_fifo_min_prio)
+ ceiling = __sched_fifo_min_prio;
+ }
+
+ *prioceiling = ceiling;
+
+ return 0;
+}
diff --git a/libpthread/nptl/pthread_mutexattr_getprotocol.c b/libpthread/nptl/pthread_mutexattr_getprotocol.c
new file mode 100644
index 000000000..fd7f6ea59
--- /dev/null
+++ b/libpthread/nptl/pthread_mutexattr_getprotocol.c
@@ -0,0 +1,36 @@
+/* Get priority protocol setting from pthread_mutexattr_t.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2006.
+
+ 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 <pthreadP.h>
+
+
+int
+pthread_mutexattr_getprotocol (
+ const pthread_mutexattr_t *attr,
+ int *protocol)
+{
+ const struct pthread_mutexattr *iattr;
+
+ iattr = (const struct pthread_mutexattr *) attr;
+
+ *protocol = ((iattr->mutexkind & PTHREAD_MUTEXATTR_PROTOCOL_MASK)
+ >> PTHREAD_MUTEXATTR_PROTOCOL_SHIFT);
+
+ return 0;
+}
diff --git a/libpthread/nptl/pthread_mutexattr_getpshared.c b/libpthread/nptl/pthread_mutexattr_getpshared.c
new file mode 100644
index 000000000..e8ba3f6ca
--- /dev/null
+++ b/libpthread/nptl/pthread_mutexattr_getpshared.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthreadP.h>
+
+
+int
+pthread_mutexattr_getpshared (
+ const pthread_mutexattr_t *attr,
+ int *pshared)
+{
+ const struct pthread_mutexattr *iattr;
+
+ iattr = (const struct pthread_mutexattr *) attr;
+
+ *pshared = ((iattr->mutexkind & PTHREAD_MUTEXATTR_FLAG_PSHARED) != 0
+ ? PTHREAD_PROCESS_SHARED : PTHREAD_PROCESS_PRIVATE);
+
+ return 0;
+}
diff --git a/libpthread/nptl/pthread_mutexattr_getrobust.c b/libpthread/nptl/pthread_mutexattr_getrobust.c
new file mode 100644
index 000000000..8c6c96546
--- /dev/null
+++ b/libpthread/nptl/pthread_mutexattr_getrobust.c
@@ -0,0 +1,36 @@
+/* Copyright (C) 2005, 2010 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthreadP.h>
+
+
+int
+pthread_mutexattr_getrobust (
+ const pthread_mutexattr_t *attr,
+ int *robustness)
+{
+ const struct pthread_mutexattr *iattr;
+
+ iattr = (const struct pthread_mutexattr *) attr;
+
+ *robustness = ((iattr->mutexkind & PTHREAD_MUTEXATTR_FLAG_ROBUST) != 0
+ ? PTHREAD_MUTEX_ROBUST_NP : PTHREAD_MUTEX_STALLED_NP);
+
+ return 0;
+}
+weak_alias (pthread_mutexattr_getrobust, pthread_mutexattr_getrobust_np)
diff --git a/libpthread/nptl/pthread_mutexattr_gettype.c b/libpthread/nptl/pthread_mutexattr_gettype.c
new file mode 100644
index 000000000..8a49626d6
--- /dev/null
+++ b/libpthread/nptl/pthread_mutexattr_gettype.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthreadP.h>
+
+
+int
+pthread_mutexattr_gettype (
+ const pthread_mutexattr_t *attr,
+ int *kind)
+{
+ const struct pthread_mutexattr *iattr;
+
+ iattr = (const struct pthread_mutexattr *) attr;
+
+ *kind = iattr->mutexkind & ~PTHREAD_MUTEXATTR_FLAG_BITS;
+
+ return 0;
+}
+weak_alias (pthread_mutexattr_gettype, pthread_mutexattr_getkind_np)
diff --git a/libpthread/nptl/pthread_mutexattr_init.c b/libpthread/nptl/pthread_mutexattr_init.c
new file mode 100644
index 000000000..1365bf3fe
--- /dev/null
+++ b/libpthread/nptl/pthread_mutexattr_init.c
@@ -0,0 +1,37 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <string.h>
+#include <pthreadP.h>
+
+
+int
+__pthread_mutexattr_init (
+ pthread_mutexattr_t *attr)
+{
+ if (sizeof (struct pthread_mutexattr) != sizeof (pthread_mutexattr_t))
+ memset (attr, '\0', sizeof (*attr));
+
+ /* We use bit 31 to signal whether the mutex is going to be
+ process-shared or not. By default it is zero, i.e., the mutex is
+ not process-shared. */
+ ((struct pthread_mutexattr *) attr)->mutexkind = PTHREAD_MUTEX_NORMAL;
+
+ return 0;
+}
+strong_alias (__pthread_mutexattr_init, pthread_mutexattr_init)
diff --git a/libpthread/nptl/pthread_mutexattr_setprioceiling.c b/libpthread/nptl/pthread_mutexattr_setprioceiling.c
new file mode 100644
index 000000000..b256cad04
--- /dev/null
+++ b/libpthread/nptl/pthread_mutexattr_setprioceiling.c
@@ -0,0 +1,46 @@
+/* Change priority ceiling setting in pthread_mutexattr_t.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2006.
+
+ 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 <pthreadP.h>
+
+
+int
+pthread_mutexattr_setprioceiling (
+ pthread_mutexattr_t *attr,
+ int prioceiling)
+{
+ if (__sched_fifo_min_prio == -1)
+ __init_sched_fifo_prio ();
+
+ if (__builtin_expect (prioceiling < __sched_fifo_min_prio, 0)
+ || __builtin_expect (prioceiling > __sched_fifo_max_prio, 0)
+ || __builtin_expect ((prioceiling
+ & (PTHREAD_MUTEXATTR_PRIO_CEILING_MASK
+ >> PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT))
+ != prioceiling, 0))
+ return EINVAL;
+
+ struct pthread_mutexattr *iattr = (struct pthread_mutexattr *) attr;
+
+ iattr->mutexkind = ((iattr->mutexkind & ~PTHREAD_MUTEXATTR_PRIO_CEILING_MASK)
+ | (prioceiling << PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT));
+
+ return 0;
+}
diff --git a/libpthread/nptl/pthread_mutexattr_setprotocol.c b/libpthread/nptl/pthread_mutexattr_setprotocol.c
new file mode 100644
index 000000000..087358969
--- /dev/null
+++ b/libpthread/nptl/pthread_mutexattr_setprotocol.c
@@ -0,0 +1,40 @@
+/* Change priority protocol setting in pthread_mutexattr_t.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2006.
+
+ 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 <pthreadP.h>
+
+
+int
+pthread_mutexattr_setprotocol (
+ pthread_mutexattr_t *attr,
+ int protocol)
+{
+ if (protocol != PTHREAD_PRIO_NONE
+ && protocol != PTHREAD_PRIO_INHERIT
+ && __builtin_expect (protocol != PTHREAD_PRIO_PROTECT, 0))
+ return EINVAL;
+
+ struct pthread_mutexattr *iattr = (struct pthread_mutexattr *) attr;
+
+ iattr->mutexkind = ((iattr->mutexkind & ~PTHREAD_MUTEXATTR_PROTOCOL_MASK)
+ | (protocol << PTHREAD_MUTEXATTR_PROTOCOL_SHIFT));
+
+ return 0;
+}
diff --git a/libpthread/nptl/pthread_mutexattr_setpshared.c b/libpthread/nptl/pthread_mutexattr_setpshared.c
new file mode 100644
index 000000000..ce39325f5
--- /dev/null
+++ b/libpthread/nptl/pthread_mutexattr_setpshared.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <pthreadP.h>
+
+
+int
+pthread_mutexattr_setpshared (
+ pthread_mutexattr_t *attr,
+ int pshared)
+{
+ struct pthread_mutexattr *iattr;
+
+ if (pshared != PTHREAD_PROCESS_PRIVATE
+ && __builtin_expect (pshared != PTHREAD_PROCESS_SHARED, 0))
+ return EINVAL;
+
+ iattr = (struct pthread_mutexattr *) attr;
+
+ if (pshared == PTHREAD_PROCESS_PRIVATE)
+ iattr->mutexkind &= ~PTHREAD_MUTEXATTR_FLAG_PSHARED;
+ else
+ iattr->mutexkind |= PTHREAD_MUTEXATTR_FLAG_PSHARED;
+
+ return 0;
+}
diff --git a/libpthread/nptl/pthread_mutexattr_setrobust.c b/libpthread/nptl/pthread_mutexattr_setrobust.c
new file mode 100644
index 000000000..0bcbec7a8
--- /dev/null
+++ b/libpthread/nptl/pthread_mutexattr_setrobust.c
@@ -0,0 +1,43 @@
+/* Copyright (C) 2005, 2010 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <pthreadP.h>
+
+
+int
+pthread_mutexattr_setrobust (
+ pthread_mutexattr_t *attr,
+ int robustness)
+{
+ if (robustness != PTHREAD_MUTEX_STALLED_NP
+ && __builtin_expect (robustness != PTHREAD_MUTEX_ROBUST_NP, 0))
+ return EINVAL;
+
+ struct pthread_mutexattr *iattr = (struct pthread_mutexattr *) attr;
+
+ /* We use bit 30 to signal whether the mutex is going to be
+ robust or not. */
+ if (robustness == PTHREAD_MUTEX_STALLED_NP)
+ iattr->mutexkind &= ~PTHREAD_MUTEXATTR_FLAG_ROBUST;
+ else
+ iattr->mutexkind |= PTHREAD_MUTEXATTR_FLAG_ROBUST;
+
+ return 0;
+}
+weak_alias (pthread_mutexattr_setrobust, pthread_mutexattr_setrobust_np)
diff --git a/libpthread/nptl/pthread_mutexattr_settype.c b/libpthread/nptl/pthread_mutexattr_settype.c
new file mode 100644
index 000000000..6c1d40b7d
--- /dev/null
+++ b/libpthread/nptl/pthread_mutexattr_settype.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <pthreadP.h>
+
+
+int
+__pthread_mutexattr_settype (
+ pthread_mutexattr_t *attr,
+ int kind)
+{
+ struct pthread_mutexattr *iattr;
+
+ if (kind < PTHREAD_MUTEX_NORMAL || kind > PTHREAD_MUTEX_ADAPTIVE_NP)
+ return EINVAL;
+
+ iattr = (struct pthread_mutexattr *) attr;
+
+ iattr->mutexkind = (iattr->mutexkind & PTHREAD_MUTEXATTR_FLAG_BITS) | kind;
+
+ return 0;
+}
+weak_alias (__pthread_mutexattr_settype, pthread_mutexattr_setkind_np)
+strong_alias (__pthread_mutexattr_settype, pthread_mutexattr_settype)
diff --git a/libpthread/nptl/pthread_rwlock_destroy.c b/libpthread/nptl/pthread_rwlock_destroy.c
new file mode 100644
index 000000000..07c3b072f
--- /dev/null
+++ b/libpthread/nptl/pthread_rwlock_destroy.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 "pthreadP.h"
+
+
+int
+__pthread_rwlock_destroy (pthread_rwlock_t *rwlock)
+{
+ /* Nothing to be done. For now. */
+ return 0;
+}
+strong_alias (__pthread_rwlock_destroy, pthread_rwlock_destroy)
diff --git a/libpthread/nptl/pthread_rwlock_init.c b/libpthread/nptl/pthread_rwlock_init.c
new file mode 100644
index 000000000..c8fbc796a
--- /dev/null
+++ b/libpthread/nptl/pthread_rwlock_init.c
@@ -0,0 +1,72 @@
+/* Copyright (C) 2002, 2007, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 "pthreadP.h"
+#include <bits/kernel-features.h>
+#include <string.h>
+
+static const struct pthread_rwlockattr default_attr =
+ {
+ .lockkind = PTHREAD_RWLOCK_DEFAULT_NP,
+ .pshared = PTHREAD_PROCESS_PRIVATE
+ };
+
+
+int
+__pthread_rwlock_init (
+ pthread_rwlock_t *rwlock,
+ const pthread_rwlockattr_t *attr)
+{
+ const struct pthread_rwlockattr *iattr;
+
+ iattr = ((const struct pthread_rwlockattr *) attr) ?: &default_attr;
+
+ memset (rwlock, '\0', sizeof (*rwlock));
+
+ rwlock->__data.__flags
+ = iattr->lockkind == PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP;
+
+ /* The __SHARED field is computed to minimize the work that needs to
+ be done while handling the futex. There are two inputs: the
+ availability of private futexes and whether the rwlock is shared
+ or private. Unfortunately the value of a private rwlock is
+ fixed: it must be zero. The PRIVATE_FUTEX flag has the value
+ 0x80 in case private futexes are available and zero otherwise.
+ This leads to the following table:
+
+ | pshared | result
+ | shared private | shared private |
+ ------------+-----------------+-----------------+
+ !avail 0 | 0 0 | 0 0 |
+ avail 0x80 | 0x80 0 | 0 0x80 |
+
+ If the pshared value is in locking functions XORed with avail
+ we get the expected result. */
+#ifdef __ASSUME_PRIVATE_FUTEX
+ rwlock->__data.__shared = (iattr->pshared == PTHREAD_PROCESS_PRIVATE
+ ? 0 : FUTEX_PRIVATE_FLAG);
+#else
+ rwlock->__data.__shared = (iattr->pshared == PTHREAD_PROCESS_PRIVATE
+ ? 0
+ : THREAD_GETMEM (THREAD_SELF,
+ header.private_futex));
+#endif
+
+ return 0;
+}
+strong_alias (__pthread_rwlock_init, pthread_rwlock_init)
diff --git a/libpthread/nptl/pthread_rwlock_tryrdlock.c b/libpthread/nptl/pthread_rwlock_tryrdlock.c
new file mode 100644
index 000000000..5b4cf3722
--- /dev/null
+++ b/libpthread/nptl/pthread_rwlock_tryrdlock.c
@@ -0,0 +1,49 @@
+/* Copyright (C) 2002, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include "pthreadP.h"
+#include <lowlevellock.h>
+
+
+int
+__pthread_rwlock_tryrdlock (
+ pthread_rwlock_t *rwlock)
+{
+ int result = EBUSY;
+
+ lll_lock (rwlock->__data.__lock, rwlock->__data.__shared);
+
+ if (rwlock->__data.__writer == 0
+ && (rwlock->__data.__nr_writers_queued == 0
+ || PTHREAD_RWLOCK_PREFER_READER_P (rwlock)))
+ {
+ if (__builtin_expect (++rwlock->__data.__nr_readers == 0, 0))
+ {
+ --rwlock->__data.__nr_readers;
+ result = EAGAIN;
+ }
+ else
+ result = 0;
+ }
+
+ lll_unlock (rwlock->__data.__lock, rwlock->__data.__shared);
+
+ return result;
+}
+strong_alias (__pthread_rwlock_tryrdlock, pthread_rwlock_tryrdlock)
diff --git a/libpthread/nptl/pthread_rwlock_trywrlock.c b/libpthread/nptl/pthread_rwlock_trywrlock.c
new file mode 100644
index 000000000..73e71a7c3
--- /dev/null
+++ b/libpthread/nptl/pthread_rwlock_trywrlock.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 2002, 2003, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include "pthreadP.h"
+#include <lowlevellock.h>
+
+
+int
+__pthread_rwlock_trywrlock (
+ pthread_rwlock_t *rwlock)
+{
+ int result = EBUSY;
+
+ lll_lock (rwlock->__data.__lock, rwlock->__data.__shared);
+
+ if (rwlock->__data.__writer == 0 && rwlock->__data.__nr_readers == 0)
+ {
+ rwlock->__data.__writer = THREAD_GETMEM (THREAD_SELF, tid);
+ result = 0;
+ }
+
+ lll_unlock (rwlock->__data.__lock, rwlock->__data.__shared);
+
+ return result;
+}
+strong_alias (__pthread_rwlock_trywrlock, pthread_rwlock_trywrlock)
diff --git a/libpthread/nptl/pthread_rwlockattr_destroy.c b/libpthread/nptl/pthread_rwlockattr_destroy.c
new file mode 100644
index 000000000..2c3e2ef55
--- /dev/null
+++ b/libpthread/nptl/pthread_rwlockattr_destroy.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 "pthreadP.h"
+
+
+int
+pthread_rwlockattr_destroy (pthread_rwlockattr_t *attr)
+{
+ /* Nothing to do. For now. */
+
+ return 0;
+}
diff --git a/libpthread/nptl/pthread_rwlockattr_getkind_np.c b/libpthread/nptl/pthread_rwlockattr_getkind_np.c
new file mode 100644
index 000000000..7e46958f9
--- /dev/null
+++ b/libpthread/nptl/pthread_rwlockattr_getkind_np.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 "pthreadP.h"
+
+
+int
+pthread_rwlockattr_getkind_np (
+ const pthread_rwlockattr_t *attr,
+ int *pref)
+{
+ *pref = ((const struct pthread_rwlockattr *) attr)->lockkind;
+
+ return 0;
+}
diff --git a/libpthread/nptl/pthread_rwlockattr_getpshared.c b/libpthread/nptl/pthread_rwlockattr_getpshared.c
new file mode 100644
index 000000000..93667db2f
--- /dev/null
+++ b/libpthread/nptl/pthread_rwlockattr_getpshared.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 "pthreadP.h"
+
+
+int
+pthread_rwlockattr_getpshared (
+ const pthread_rwlockattr_t *attr,
+ int *pshared)
+{
+ *pshared = ((const struct pthread_rwlockattr *) attr)->pshared;
+
+ return 0;
+}
diff --git a/libpthread/nptl/pthread_rwlockattr_init.c b/libpthread/nptl/pthread_rwlockattr_init.c
new file mode 100644
index 000000000..37b7ac72a
--- /dev/null
+++ b/libpthread/nptl/pthread_rwlockattr_init.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 "pthreadP.h"
+
+
+int
+pthread_rwlockattr_init (pthread_rwlockattr_t *attr)
+{
+ struct pthread_rwlockattr *iattr;
+
+ iattr = (struct pthread_rwlockattr *) attr;
+
+ iattr->lockkind = PTHREAD_RWLOCK_DEFAULT_NP;
+ iattr->pshared = PTHREAD_PROCESS_PRIVATE;
+
+ return 0;
+}
diff --git a/libpthread/nptl/pthread_rwlockattr_setkind_np.c b/libpthread/nptl/pthread_rwlockattr_setkind_np.c
new file mode 100644
index 000000000..028eb97f6
--- /dev/null
+++ b/libpthread/nptl/pthread_rwlockattr_setkind_np.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include "pthreadP.h"
+
+
+int
+pthread_rwlockattr_setkind_np (
+ pthread_rwlockattr_t *attr,
+ int pref)
+{
+ struct pthread_rwlockattr *iattr;
+
+ if (pref != PTHREAD_RWLOCK_PREFER_READER_NP
+ && pref != PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP
+ && __builtin_expect (pref != PTHREAD_RWLOCK_PREFER_WRITER_NP, 0))
+ return EINVAL;
+
+ iattr = (struct pthread_rwlockattr *) attr;
+
+ iattr->lockkind = pref;
+
+ return 0;
+}
diff --git a/libpthread/nptl/pthread_rwlockattr_setpshared.c b/libpthread/nptl/pthread_rwlockattr_setpshared.c
new file mode 100644
index 000000000..409f0fd6c
--- /dev/null
+++ b/libpthread/nptl/pthread_rwlockattr_setpshared.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include "pthreadP.h"
+
+
+int
+pthread_rwlockattr_setpshared (
+ pthread_rwlockattr_t *attr,
+ int pshared)
+{
+ struct pthread_rwlockattr *iattr;
+
+ if (pshared != PTHREAD_PROCESS_SHARED
+ && __builtin_expect (pshared != PTHREAD_PROCESS_PRIVATE, 0))
+ return EINVAL;
+
+ iattr = (struct pthread_rwlockattr *) attr;
+
+ iattr->pshared = pshared;
+
+ return 0;
+}
diff --git a/libpthread/nptl/pthread_self.c b/libpthread/nptl/pthread_self.c
new file mode 100644
index 000000000..6864d8804
--- /dev/null
+++ b/libpthread/nptl/pthread_self.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 "pthreadP.h"
+#include <tls.h>
+
+
+pthread_t
+attribute_protected
+__pthread_self (void)
+{
+ return (pthread_t) THREAD_SELF;
+}
+strong_alias (__pthread_self, pthread_self)
diff --git a/libpthread/nptl/pthread_setcancelstate.c b/libpthread/nptl/pthread_setcancelstate.c
new file mode 100644
index 000000000..032d07049
--- /dev/null
+++ b/libpthread/nptl/pthread_setcancelstate.c
@@ -0,0 +1,73 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include "pthreadP.h"
+#include <atomic.h>
+
+
+int
+attribute_protected
+__pthread_setcancelstate (
+ int state,
+ int *oldstate)
+{
+ volatile struct pthread *self;
+
+ if (state < PTHREAD_CANCEL_ENABLE || state > PTHREAD_CANCEL_DISABLE)
+ return EINVAL;
+
+ self = THREAD_SELF;
+
+ int oldval = THREAD_GETMEM (self, cancelhandling);
+ while (1)
+ {
+ int newval = (state == PTHREAD_CANCEL_DISABLE
+ ? oldval | CANCELSTATE_BITMASK
+ : oldval & ~CANCELSTATE_BITMASK);
+
+ /* Store the old value. */
+ if (oldstate != NULL)
+ *oldstate = ((oldval & CANCELSTATE_BITMASK)
+ ? PTHREAD_CANCEL_DISABLE : PTHREAD_CANCEL_ENABLE);
+
+ /* Avoid doing unnecessary work. The atomic operation can
+ potentially be expensive if the memory has to be locked and
+ remote cache lines have to be invalidated. */
+ if (oldval == newval)
+ break;
+
+ /* Update the cancel handling word. This has to be done
+ atomically since other bits could be modified as well. */
+ int curval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling, newval,
+ oldval);
+ if (__builtin_expect (curval == oldval, 1))
+ {
+ if (CANCEL_ENABLED_AND_CANCELED_AND_ASYNCHRONOUS (newval))
+ __do_cancel ();
+
+ break;
+ }
+
+ /* Prepare for the next round. */
+ oldval = curval;
+ }
+
+ return 0;
+}
+strong_alias (__pthread_setcancelstate, pthread_setcancelstate)
diff --git a/libpthread/nptl/pthread_setcanceltype.c b/libpthread/nptl/pthread_setcanceltype.c
new file mode 100644
index 000000000..3ce8e4f61
--- /dev/null
+++ b/libpthread/nptl/pthread_setcanceltype.c
@@ -0,0 +1,76 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include "pthreadP.h"
+#include <atomic.h>
+
+
+int
+attribute_protected
+__pthread_setcanceltype (
+ int type,
+ int *oldtype)
+{
+ volatile struct pthread *self;
+
+ if (type < PTHREAD_CANCEL_DEFERRED || type > PTHREAD_CANCEL_ASYNCHRONOUS)
+ return EINVAL;
+
+ self = THREAD_SELF;
+
+ int oldval = THREAD_GETMEM (self, cancelhandling);
+ while (1)
+ {
+ int newval = (type == PTHREAD_CANCEL_ASYNCHRONOUS
+ ? oldval | CANCELTYPE_BITMASK
+ : oldval & ~CANCELTYPE_BITMASK);
+
+ /* Store the old value. */
+ if (oldtype != NULL)
+ *oldtype = ((oldval & CANCELTYPE_BITMASK)
+ ? PTHREAD_CANCEL_ASYNCHRONOUS : PTHREAD_CANCEL_DEFERRED);
+
+ /* Avoid doing unnecessary work. The atomic operation can
+ potentially be expensive if the memory has to be locked and
+ remote cache lines have to be invalidated. */
+ if (oldval == newval)
+ break;
+
+ /* Update the cancel handling word. This has to be done
+ atomically since other bits could be modified as well. */
+ int curval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling, newval,
+ oldval);
+ if (__builtin_expect (curval == oldval, 1))
+ {
+ if (CANCEL_ENABLED_AND_CANCELED_AND_ASYNCHRONOUS (newval))
+ {
+ THREAD_SETMEM (self, result, PTHREAD_CANCELED);
+ __do_cancel ();
+ }
+
+ break;
+ }
+
+ /* Prepare for the next round. */
+ oldval = curval;
+ }
+
+ return 0;
+}
+strong_alias (__pthread_setcanceltype, pthread_setcanceltype)
diff --git a/libpthread/nptl/pthread_setconcurrency.c b/libpthread/nptl/pthread_setconcurrency.c
new file mode 100644
index 000000000..c17d45901
--- /dev/null
+++ b/libpthread/nptl/pthread_setconcurrency.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include "pthreadP.h"
+
+
+/* Global definition. Needed in pthread_getconcurrency as well. */
+int __concurrency_level;
+
+
+int
+pthread_setconcurrency (int level)
+{
+ if (level < 0)
+ return EINVAL;
+
+ __concurrency_level = level;
+
+ /* XXX For ports which actually need to handle the concurrency level
+ some more code is probably needed here. */
+
+ return 0;
+}
diff --git a/libpthread/nptl/pthread_setegid.c b/libpthread/nptl/pthread_setegid.c
new file mode 100644
index 000000000..9252dfac7
--- /dev/null
+++ b/libpthread/nptl/pthread_setegid.c
@@ -0,0 +1,3 @@
+#define SINGLE_THREAD
+#define setegid pthread_setegid_np
+#include <setegid.c>
diff --git a/libpthread/nptl/pthread_seteuid.c b/libpthread/nptl/pthread_seteuid.c
new file mode 100644
index 000000000..47bb69802
--- /dev/null
+++ b/libpthread/nptl/pthread_seteuid.c
@@ -0,0 +1,3 @@
+#define SINGLE_THREAD
+#define seteuid pthread_seteuid_np
+#include <seteuid.c>
diff --git a/libpthread/nptl/pthread_setgid.c b/libpthread/nptl/pthread_setgid.c
new file mode 100644
index 000000000..b06bffbf3
--- /dev/null
+++ b/libpthread/nptl/pthread_setgid.c
@@ -0,0 +1,3 @@
+#define SINGLE_THREAD
+#define __setgid pthread_setgid_np
+#include <setgid.c>
diff --git a/libpthread/nptl/pthread_setregid.c b/libpthread/nptl/pthread_setregid.c
new file mode 100644
index 000000000..7461d2b7f
--- /dev/null
+++ b/libpthread/nptl/pthread_setregid.c
@@ -0,0 +1,3 @@
+#define SINGLE_THREAD
+#define __setregid pthread_setregid_np
+#include <setregid.c>
diff --git a/libpthread/nptl/pthread_setresgid.c b/libpthread/nptl/pthread_setresgid.c
new file mode 100644
index 000000000..369fae267
--- /dev/null
+++ b/libpthread/nptl/pthread_setresgid.c
@@ -0,0 +1,3 @@
+#define SINGLE_THREAD
+#define __setresgid pthread_setresgid_np
+#include <setresgid.c>
diff --git a/libpthread/nptl/pthread_setresuid.c b/libpthread/nptl/pthread_setresuid.c
new file mode 100644
index 000000000..ac57c0fa8
--- /dev/null
+++ b/libpthread/nptl/pthread_setresuid.c
@@ -0,0 +1,3 @@
+#define SINGLE_THREAD
+#define __setresuid pthread_setresuid_np
+#include <setresuid.c>
diff --git a/libpthread/nptl/pthread_setreuid.c b/libpthread/nptl/pthread_setreuid.c
new file mode 100644
index 000000000..aa804ab01
--- /dev/null
+++ b/libpthread/nptl/pthread_setreuid.c
@@ -0,0 +1,3 @@
+#define SINGLE_THREAD
+#define __setreuid pthread_setreuid_np
+#include <setreuid.c>
diff --git a/libpthread/nptl/pthread_setschedparam.c b/libpthread/nptl/pthread_setschedparam.c
new file mode 100644
index 000000000..f47c872c5
--- /dev/null
+++ b/libpthread/nptl/pthread_setschedparam.c
@@ -0,0 +1,74 @@
+/* Copyright (C) 2002, 2003, 2004, 2006, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <sched.h>
+#include <string.h>
+#include "pthreadP.h"
+#include <lowlevellock.h>
+
+
+int
+attribute_protected
+__pthread_setschedparam (
+ pthread_t threadid,
+ int policy,
+ const struct sched_param *param)
+{
+ struct pthread *pd = (struct pthread *) threadid;
+
+ /* Make sure the descriptor is valid. */
+ if (INVALID_TD_P (pd))
+ /* Not a valid thread handle. */
+ return ESRCH;
+
+ int result = 0;
+
+ lll_lock (pd->lock, LLL_PRIVATE);
+
+ struct sched_param p;
+ const struct sched_param *orig_param = param;
+
+ /* If the thread should have higher priority because of some
+ PTHREAD_PRIO_PROTECT mutexes it holds, adjust the priority. */
+ if (__builtin_expect (pd->tpp != NULL, 0)
+ && pd->tpp->priomax > param->sched_priority)
+ {
+ p = *param;
+ p.sched_priority = pd->tpp->priomax;
+ param = &p;
+ }
+
+ /* Try to set the scheduler information. */
+ if (__builtin_expect (__sched_setscheduler (pd->tid, policy,
+ param) == -1, 0))
+ result = errno;
+ else
+ {
+ /* We succeeded changing the kernel information. Reflect this
+ change in the thread descriptor. */
+ pd->schedpolicy = policy;
+ memcpy (&pd->schedparam, orig_param, sizeof (struct sched_param));
+ pd->flags |= ATTR_FLAG_SCHED_SET | ATTR_FLAG_POLICY_SET;
+ }
+
+ lll_unlock (pd->lock, LLL_PRIVATE);
+
+ return result;
+}
+strong_alias (__pthread_setschedparam, pthread_setschedparam)
diff --git a/libpthread/nptl/pthread_setschedprio.c b/libpthread/nptl/pthread_setschedprio.c
new file mode 100644
index 000000000..48307ad11
--- /dev/null
+++ b/libpthread/nptl/pthread_setschedprio.c
@@ -0,0 +1,65 @@
+/* Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <sched.h>
+#include <string.h>
+#include <sched.h>
+#include "pthreadP.h"
+#include <lowlevellock.h>
+
+
+int
+pthread_setschedprio (
+ pthread_t threadid,
+ int prio)
+{
+ struct pthread *pd = (struct pthread *) threadid;
+
+ /* Make sure the descriptor is valid. */
+ if (INVALID_TD_P (pd))
+ /* Not a valid thread handle. */
+ return ESRCH;
+
+ int result = 0;
+ struct sched_param param;
+ param.sched_priority = prio;
+
+ lll_lock (pd->lock, LLL_PRIVATE);
+
+ /* If the thread should have higher priority because of some
+ PTHREAD_PRIO_PROTECT mutexes it holds, adjust the priority. */
+ if (__builtin_expect (pd->tpp != NULL, 0) && pd->tpp->priomax > prio)
+ param.sched_priority = pd->tpp->priomax;
+
+ /* Try to set the scheduler information. */
+ if (__builtin_expect (sched_setparam (pd->tid, &param) == -1, 0))
+ result = errno;
+ else
+ {
+ /* We succeeded changing the kernel information. Reflect this
+ change in the thread descriptor. */
+ param.sched_priority = prio;
+ memcpy (&pd->schedparam, &param, sizeof (struct sched_param));
+ pd->flags |= ATTR_FLAG_SCHED_SET;
+ }
+
+ lll_unlock (pd->lock, LLL_PRIVATE);
+
+ return result;
+}
diff --git a/libpthread/nptl/pthread_setspecific.c b/libpthread/nptl/pthread_setspecific.c
new file mode 100644
index 000000000..7451599d1
--- /dev/null
+++ b/libpthread/nptl/pthread_setspecific.c
@@ -0,0 +1,96 @@
+/* Copyright (C) 2002, 2003, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <stdlib.h>
+#include "pthreadP.h"
+
+
+int
+attribute_protected
+__pthread_setspecific (
+ pthread_key_t key,
+ const void *value)
+{
+ struct pthread *self;
+ unsigned int idx1st;
+ unsigned int idx2nd;
+ struct pthread_key_data *level2;
+ unsigned int seq;
+
+ self = THREAD_SELF;
+
+ /* Special case access to the first 2nd-level block. This is the
+ usual case. */
+ if (__builtin_expect (key < PTHREAD_KEY_2NDLEVEL_SIZE, 1))
+ {
+ /* Verify the key is sane. */
+ if (KEY_UNUSED ((seq = __pthread_keys[key].seq)))
+ /* Not valid. */
+ return EINVAL;
+
+ level2 = &self->specific_1stblock[key];
+
+ /* Remember that we stored at least one set of data. */
+ if (value != NULL)
+ THREAD_SETMEM (self, specific_used, true);
+ }
+ else
+ {
+ if (key >= PTHREAD_KEYS_MAX
+ || KEY_UNUSED ((seq = __pthread_keys[key].seq)))
+ /* Not valid. */
+ return EINVAL;
+
+ idx1st = key / PTHREAD_KEY_2NDLEVEL_SIZE;
+ idx2nd = key % PTHREAD_KEY_2NDLEVEL_SIZE;
+
+ /* This is the second level array. Allocate it if necessary. */
+ level2 = THREAD_GETMEM_NC (self, specific, idx1st);
+ if (level2 == NULL)
+ {
+ if (value == NULL)
+ /* We don't have to do anything. The value would in any case
+ be NULL. We can save the memory allocation. */
+ return 0;
+
+ level2
+ = (struct pthread_key_data *) calloc (PTHREAD_KEY_2NDLEVEL_SIZE,
+ sizeof (*level2));
+ if (level2 == NULL)
+ return ENOMEM;
+
+ THREAD_SETMEM_NC (self, specific, idx1st, level2);
+ }
+
+ /* Pointer to the right array element. */
+ level2 = &level2[idx2nd];
+
+ /* Remember that we stored at least one set of data. */
+ THREAD_SETMEM (self, specific_used, true);
+ }
+
+ /* Store the data and the sequence number so that we can recognize
+ stale data. */
+ level2->seq = seq;
+ level2->data = (void *) value;
+
+ return 0;
+}
+strong_alias (__pthread_setspecific, pthread_setspecific)
+strong_alias (__pthread_setspecific, __pthread_setspecific_internal)
diff --git a/libpthread/nptl/pthread_setuid.c b/libpthread/nptl/pthread_setuid.c
new file mode 100644
index 000000000..ff949c850
--- /dev/null
+++ b/libpthread/nptl/pthread_setuid.c
@@ -0,0 +1,3 @@
+#define SINGLE_THREAD
+#define __setuid pthread_setuid_np
+#include <setuid.c>
diff --git a/libpthread/nptl/pthread_testcancel.c b/libpthread/nptl/pthread_testcancel.c
new file mode 100644
index 000000000..7ce9e49a7
--- /dev/null
+++ b/libpthread/nptl/pthread_testcancel.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <stdlib.h>
+#include "pthreadP.h"
+
+
+void
+pthread_testcancel (void)
+{
+ int cancelhandling;
+ CANCELLATION_P (THREAD_SELF);
+}
diff --git a/libpthread/nptl/pthread_timedjoin.c b/libpthread/nptl/pthread_timedjoin.c
new file mode 100644
index 000000000..d3d0c26e0
--- /dev/null
+++ b/libpthread/nptl/pthread_timedjoin.c
@@ -0,0 +1,106 @@
+/* Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <stdlib.h>
+#include <atomic.h>
+#include "pthreadP.h"
+
+
+static void
+cleanup (void *arg)
+{
+ *(void **) arg = NULL;
+}
+
+
+int
+pthread_timedjoin_np (
+ pthread_t threadid,
+ void **thread_return,
+ const struct timespec *abstime)
+{
+ struct pthread *self;
+ struct pthread *pd = (struct pthread *) threadid;
+ int result;
+
+ /* Make sure the descriptor is valid. */
+ if (INVALID_NOT_TERMINATED_TD_P (pd))
+ /* Not a valid thread handle. */
+ return ESRCH;
+
+ /* Is the thread joinable?. */
+ if (IS_DETACHED (pd))
+ /* We cannot wait for the thread. */
+ return EINVAL;
+
+ self = THREAD_SELF;
+ if (pd == self || self->joinid == pd)
+ /* This is a deadlock situation. The threads are waiting for each
+ other to finish. Note that this is a "may" error. To be 100%
+ sure we catch this error we would have to lock the data
+ structures but it is not necessary. In the unlikely case that
+ two threads are really caught in this situation they will
+ deadlock. It is the programmer's problem to figure this
+ out. */
+ return EDEADLK;
+
+ /* Wait for the thread to finish. If it is already locked something
+ is wrong. There can only be one waiter. */
+ if (__builtin_expect (atomic_compare_and_exchange_bool_acq (&pd->joinid,
+ self, NULL), 0))
+ /* There is already somebody waiting for the thread. */
+ return EINVAL;
+
+
+ /* During the wait we change to asynchronous cancellation. If we
+ are cancelled the thread we are waiting for must be marked as
+ un-wait-ed for again. */
+ pthread_cleanup_push (cleanup, &pd->joinid);
+
+ /* Switch to asynchronous cancellation. */
+ int oldtype = CANCEL_ASYNC ();
+
+
+ /* Wait for the child. */
+ result = lll_timedwait_tid (pd->tid, abstime);
+
+
+ /* Restore cancellation mode. */
+ CANCEL_RESET (oldtype);
+
+ /* Remove the handler. */
+ pthread_cleanup_pop (0);
+
+
+ /* We might have timed out. */
+ if (result == 0)
+ {
+ /* Store the return value if the caller is interested. */
+ if (thread_return != NULL)
+ *thread_return = pd->result;
+
+
+ /* Free the TCB. */
+ __free_tcb (pd);
+ }
+ else
+ pd->joinid = NULL;
+
+ return result;
+}
diff --git a/libpthread/nptl/pthread_tryjoin.c b/libpthread/nptl/pthread_tryjoin.c
new file mode 100644
index 000000000..a5a13a6e9
--- /dev/null
+++ b/libpthread/nptl/pthread_tryjoin.c
@@ -0,0 +1,74 @@
+/* Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <stdlib.h>
+
+#include <atomic.h>
+#include "pthreadP.h"
+
+
+int
+pthread_tryjoin_np (
+ pthread_t threadid,
+ void **thread_return)
+{
+ struct pthread *self;
+ struct pthread *pd = (struct pthread *) threadid;
+
+ /* Make sure the descriptor is valid. */
+ if (DEBUGGING_P && __find_in_stack_list (pd) == NULL)
+ /* Not a valid thread handle. */
+ return ESRCH;
+
+ /* Is the thread joinable?. */
+ if (IS_DETACHED (pd))
+ /* We cannot wait for the thread. */
+ return EINVAL;
+
+ self = THREAD_SELF;
+ if (pd == self || self->joinid == pd)
+ /* This is a deadlock situation. The threads are waiting for each
+ other to finish. Note that this is a "may" error. To be 100%
+ sure we catch this error we would have to lock the data
+ structures but it is not necessary. In the unlikely case that
+ two threads are really caught in this situation they will
+ deadlock. It is the programmer's problem to figure this
+ out. */
+ return EDEADLK;
+
+ /* Return right away if the thread hasn't terminated yet. */
+ if (pd->tid != 0)
+ return EBUSY;
+
+ /* Wait for the thread to finish. If it is already locked something
+ is wrong. There can only be one waiter. */
+ if (atomic_compare_and_exchange_bool_acq (&pd->joinid, self, NULL))
+ /* There is already somebody waiting for the thread. */
+ return EINVAL;
+
+ /* Store the return value if the caller is interested. */
+ if (thread_return != NULL)
+ *thread_return = pd->result;
+
+
+ /* Free the TCB. */
+ __free_tcb (pd);
+
+ return 0;
+}
diff --git a/libpthread/nptl/res.c b/libpthread/nptl/res.c
new file mode 100644
index 000000000..3ce84ea81
--- /dev/null
+++ b/libpthread/nptl/res.c
@@ -0,0 +1,26 @@
+/* Copyright (C) 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 <features.h>
+#include <tls.h>
+#include <resolv.h>
+
+struct __res_state *
+__res_state (void)
+{
+ return __resp;
+}
diff --git a/libpthread/nptl/sem_close.c b/libpthread/nptl/sem_close.c
new file mode 100644
index 000000000..6819e810b
--- /dev/null
+++ b/libpthread/nptl/sem_close.c
@@ -0,0 +1,80 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <search.h>
+#include <sys/mman.h>
+#include "semaphoreP.h"
+
+
+/* Global variables to parametrize the walk function. This works
+ since we always have to use locks. And we have to use the twalk
+ function since the entries are not sorted wrt the mapping
+ address. */
+static sem_t *the_sem;
+static struct inuse_sem *rec;
+
+static void
+walker (const void *inodep, const VISIT which, const int depth)
+{
+ struct inuse_sem *nodep = *(struct inuse_sem **) inodep;
+
+ if (nodep->sem == the_sem)
+ rec = nodep;
+}
+
+
+int
+sem_close (
+ sem_t *sem)
+{
+ int result = 0;
+
+ /* Get the lock. */
+ lll_lock (__sem_mappings_lock, LLL_PRIVATE);
+
+ /* Locate the entry for the mapping the caller provided. */
+ rec = NULL;
+ the_sem = sem;
+ twalk (__sem_mappings, walker);
+ if (rec != NULL)
+ {
+ /* Check the reference counter. If it is going to be zero, free
+ all the resources. */
+ if (--rec->refcnt == 0)
+ {
+ /* Remove the record from the tree. */
+ (void) tdelete (rec, &__sem_mappings, __sem_search);
+
+ result = munmap (rec->sem, sizeof (sem_t));
+
+ free (rec);
+ }
+ }
+ else
+ {
+ /* This is no valid semaphore. */
+ result = -1;
+ __set_errno (EINVAL);
+ }
+
+ /* Release the lock. */
+ lll_unlock (__sem_mappings_lock, LLL_PRIVATE);
+
+ return result;
+}
diff --git a/libpthread/nptl/sem_destroy.c b/libpthread/nptl/sem_destroy.c
new file mode 100644
index 000000000..5b4ed9375
--- /dev/null
+++ b/libpthread/nptl/sem_destroy.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <semaphore.h>
+#include "semaphoreP.h"
+
+
+int
+sem_destroy (
+ sem_t *sem)
+{
+ /* XXX Check for valid parameter. */
+
+ /* Nothing to do. */
+ return 0;
+}
diff --git a/libpthread/nptl/sem_getvalue.c b/libpthread/nptl/sem_getvalue.c
new file mode 100644
index 000000000..4b2c1980b
--- /dev/null
+++ b/libpthread/nptl/sem_getvalue.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 2002, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <semaphore.h>
+#include "semaphoreP.h"
+
+
+int
+sem_getvalue (
+ sem_t *sem,
+ int *sval)
+{
+ struct new_sem *isem = (struct new_sem *) sem;
+
+ /* XXX Check for valid SEM parameter. */
+
+ *sval = isem->value;
+
+ return 0;
+}
diff --git a/libpthread/nptl/sem_init.c b/libpthread/nptl/sem_init.c
new file mode 100644
index 000000000..e1dc821be
--- /dev/null
+++ b/libpthread/nptl/sem_init.c
@@ -0,0 +1,54 @@
+/* Copyright (C) 2002, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <semaphore.h>
+#include <lowlevellock.h>
+#include "semaphoreP.h"
+#include <bits/kernel-features.h>
+
+
+int
+sem_init (
+ sem_t *sem,
+ int pshared,
+ unsigned int value)
+{
+ /* Parameter sanity check. */
+ if (__builtin_expect (value > SEM_VALUE_MAX, 0))
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ /* Map to the internal type. */
+ struct new_sem *isem = (struct new_sem *) sem;
+
+ /* Use the values the user provided. */
+ isem->value = value;
+#ifdef __ASSUME_PRIVATE_FUTEX
+ isem->private = pshared ? 0 : FUTEX_PRIVATE_FLAG;
+#else
+ isem->private = pshared ? 0 : THREAD_GETMEM (THREAD_SELF,
+ header.private_futex);
+#endif
+
+ isem->nwaiters = 0;
+
+ return 0;
+}
diff --git a/libpthread/nptl/sem_open.c b/libpthread/nptl/sem_open.c
new file mode 100644
index 000000000..5584557ff
--- /dev/null
+++ b/libpthread/nptl/sem_open.c
@@ -0,0 +1,397 @@
+/* Copyright (C) 2002, 2003, 2006, 2007, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <fcntl.h>
+#include <mntent.h>
+#include <paths.h>
+#include <pthread.h>
+#include <search.h>
+#include <semaphore.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/statfs.h>
+#include <linux_fsinfo.h>
+#include "semaphoreP.h"
+#include "../../libc/misc/internals/tempname.h"
+
+
+/* Compatibility defines. */
+#define __endmntent endmntent
+#define __getmntent_r getmntent_r
+#define __setmntent setmntent
+#define __statfs statfs
+#define __libc_close close
+#ifdef __UCLIBC_HAS_LFS__
+# define __libc_open open64
+# define __fxstat64(vers, fd, buf) fstat64(fd, buf)
+#else
+# define __libc_open open
+# define __fxstat64(vers, fd, buf) fstat(fd, buf)
+# define stat64 stat
+#endif
+#define __libc_write write
+
+
+/* Information about the mount point. */
+struct mountpoint_info mountpoint attribute_hidden;
+
+/* This is the default mount point. */
+static const char defaultmount[] = "/dev/shm";
+/* This is the default directory. */
+static const char defaultdir[] = "/dev/shm/sem.";
+
+/* Protect the `mountpoint' variable above. */
+pthread_once_t __namedsem_once attribute_hidden = PTHREAD_ONCE_INIT;
+
+
+/* Determine where the shmfs is mounted (if at all). */
+void
+attribute_hidden
+__where_is_shmfs (void)
+{
+ char buf[512];
+ struct statfs f;
+ struct mntent resmem;
+ struct mntent *mp;
+ FILE *fp;
+
+ /* The canonical place is /dev/shm. This is at least what the
+ documentation tells everybody to do. */
+ if (__statfs (defaultmount, &f) == 0 && f.f_type == SHMFS_SUPER_MAGIC)
+ {
+ /* It is in the normal place. */
+ mountpoint.dir = (char *) defaultdir;
+ mountpoint.dirlen = sizeof (defaultdir) - 1;
+
+ return;
+ }
+
+ /* OK, do it the hard way. Look through the /proc/mounts file and if
+ this does not exist through /etc/fstab to find the mount point. */
+ fp = __setmntent ("/proc/mounts", "r");
+ if (unlikely (fp == NULL))
+ {
+ fp = __setmntent (_PATH_MNTTAB, "r");
+ if (unlikely (fp == NULL))
+ /* There is nothing we can do. Blind guesses are not helpful. */
+ return;
+ }
+
+ /* Now read the entries. */
+ while ((mp = __getmntent_r (fp, &resmem, buf, sizeof buf)) != NULL)
+ /* The original name is "shm" but this got changed in early Linux
+ 2.4.x to "tmpfs". */
+ if (strcmp (mp->mnt_type, "tmpfs") == 0
+ || strcmp (mp->mnt_type, "shm") == 0)
+ {
+ /* Found it. There might be more than one place where the
+ filesystem is mounted but one is enough for us. */
+ size_t namelen;
+
+ /* First make sure this really is the correct entry. At least
+ some versions of the kernel give wrong information because
+ of the implicit mount of the shmfs for SysV IPC. */
+ if (__statfs (mp->mnt_dir, &f) != 0 || f.f_type != SHMFS_SUPER_MAGIC)
+ continue;
+
+ namelen = strlen (mp->mnt_dir);
+
+ if (namelen == 0)
+ /* Hum, maybe some crippled entry. Keep on searching. */
+ continue;
+
+ mountpoint.dir = (char *) malloc (namelen + 4 + 2);
+ if (mountpoint.dir != NULL)
+ {
+ char *cp = mempcpy (mountpoint.dir, mp->mnt_dir, namelen);
+ if (cp[-1] != '/')
+ *cp++ = '/';
+ cp = stpcpy (cp, "sem.");
+ mountpoint.dirlen = cp - mountpoint.dir;
+ }
+
+ break;
+ }
+
+ /* Close the stream. */
+ __endmntent (fp);
+}
+
+
+/* Comparison function for search of existing mapping. */
+int
+attribute_hidden
+__sem_search (const void *a, const void *b)
+{
+ const struct inuse_sem *as = (const struct inuse_sem *) a;
+ const struct inuse_sem *bs = (const struct inuse_sem *) b;
+
+ if (as->ino != bs->ino)
+ /* Cannot return the difference the type is larger than int. */
+ return as->ino < bs->ino ? -1 : (as->ino == bs->ino ? 0 : 1);
+
+ if (as->dev != bs->dev)
+ /* Cannot return the difference the type is larger than int. */
+ return as->dev < bs->dev ? -1 : (as->dev == bs->dev ? 0 : 1);
+
+ return strcmp (as->name, bs->name);
+}
+
+
+/* The search tree for existing mappings. */
+void *__sem_mappings attribute_hidden;
+
+/* Lock to protect the search tree. */
+int __sem_mappings_lock attribute_hidden = LLL_LOCK_INITIALIZER;
+
+
+/* Search for existing mapping and if possible add the one provided. */
+static sem_t *
+check_add_mapping (const char *name, size_t namelen, int fd, sem_t *existing)
+{
+ sem_t *result = SEM_FAILED;
+
+ /* Get the information about the file. */
+ struct stat64 st;
+ if (__fxstat64 (_STAT_VER, fd, &st) == 0)
+ {
+ /* Get the lock. */
+ lll_lock (__sem_mappings_lock, LLL_PRIVATE);
+
+ /* Search for an existing mapping given the information we have. */
+ struct inuse_sem *fake;
+ fake = (struct inuse_sem *) alloca (sizeof (*fake) + namelen);
+ memcpy (fake->name, name, namelen);
+ fake->dev = st.st_dev;
+ fake->ino = st.st_ino;
+
+ struct inuse_sem **foundp = tfind (fake, &__sem_mappings, __sem_search);
+ if (foundp != NULL)
+ {
+ /* There is already a mapping. Use it. */
+ result = (*foundp)->sem;
+ ++(*foundp)->refcnt;
+ }
+ else
+ {
+ /* We haven't found a mapping. Install ione. */
+ struct inuse_sem *newp;
+
+ newp = (struct inuse_sem *) malloc (sizeof (*newp) + namelen);
+ if (newp != NULL)
+ {
+ /* If the caller hasn't provided any map it now. */
+ if (existing == SEM_FAILED)
+ existing = (sem_t *) mmap (NULL, sizeof (sem_t),
+ PROT_READ | PROT_WRITE, MAP_SHARED,
+ fd, 0);
+
+ newp->dev = st.st_dev;
+ newp->ino = st.st_ino;
+ newp->refcnt = 1;
+ newp->sem = existing;
+ memcpy (newp->name, name, namelen);
+
+ /* Insert the new value. */
+ if (existing != MAP_FAILED
+ && tsearch (newp, &__sem_mappings, __sem_search) != NULL)
+ /* Successful. */
+ result = existing;
+ else
+ /* Something went wrong while inserting the new
+ value. We fail completely. */
+ free (newp);
+ }
+ }
+
+ /* Release the lock. */
+ lll_unlock (__sem_mappings_lock, LLL_PRIVATE);
+ }
+
+ if (result != existing && existing != SEM_FAILED && existing != MAP_FAILED)
+ {
+ /* Do not disturb errno. */
+ INTERNAL_SYSCALL_DECL (err);
+ INTERNAL_SYSCALL (munmap, err, 2, existing, sizeof (sem_t));
+ }
+
+ return result;
+}
+
+
+sem_t *
+sem_open (const char *name, int oflag, ...)
+{
+ char *finalname;
+ sem_t *result = SEM_FAILED;
+ int fd;
+
+ /* Determine where the shmfs is mounted. */
+ INTUSE(__pthread_once) (&__namedsem_once, __where_is_shmfs);
+
+ /* If we don't know the mount points there is nothing we can do. Ever. */
+ if (mountpoint.dir == NULL)
+ {
+ __set_errno (ENOSYS);
+ return SEM_FAILED;
+ }
+
+ /* Construct the filename. */
+ while (name[0] == '/')
+ ++name;
+
+ if (name[0] == '\0')
+ {
+ /* The name "/" is not supported. */
+ __set_errno (EINVAL);
+ return SEM_FAILED;
+ }
+ size_t namelen = strlen (name) + 1;
+
+ /* Create the name of the final file. */
+ finalname = (char *) alloca (mountpoint.dirlen + namelen);
+ mempcpy (mempcpy (finalname, mountpoint.dir, mountpoint.dirlen),
+ name, namelen);
+
+ /* If the semaphore object has to exist simply open it. */
+ if ((oflag & O_CREAT) == 0 || (oflag & O_EXCL) == 0)
+ {
+ try_again:
+ fd = __libc_open (finalname,
+ (oflag & ~(O_CREAT|O_ACCMODE)) | O_NOFOLLOW | O_RDWR);
+
+ if (fd == -1)
+ {
+ /* If we are supposed to create the file try this next. */
+ if ((oflag & O_CREAT) != 0 && errno == ENOENT)
+ goto try_create;
+
+ /* Return. errno is already set. */
+ }
+ else
+ /* Check whether we already have this semaphore mapped and
+ create one if necessary. */
+ result = check_add_mapping (name, namelen, fd, SEM_FAILED);
+ }
+ else
+ {
+ /* We have to open a temporary file first since it must have the
+ correct form before we can start using it. */
+ char *tmpfname;
+ mode_t mode;
+ unsigned int value;
+ va_list ap;
+
+ try_create:
+ va_start (ap, oflag);
+
+ mode = va_arg (ap, mode_t);
+ value = va_arg (ap, unsigned int);
+
+ va_end (ap);
+
+ if (value > SEM_VALUE_MAX)
+ {
+ __set_errno (EINVAL);
+ return SEM_FAILED;
+ }
+
+ /* Create the initial file content. */
+ union
+ {
+ sem_t initsem;
+ struct new_sem newsem;
+ } sem;
+
+ sem.newsem.value = value;
+ sem.newsem.private = 0;
+ sem.newsem.nwaiters = 0;
+
+ /* Initialize the remaining bytes as well. */
+ memset ((char *) &sem.initsem + sizeof (struct new_sem), '\0',
+ sizeof (sem_t) - sizeof (struct new_sem));
+
+ tmpfname = (char *) alloca (mountpoint.dirlen + 6 + 1);
+ mempcpy (mempcpy (tmpfname, mountpoint.dir, mountpoint.dirlen),
+ "XXXXXX", 7);
+
+ fd = __gen_tempname (tmpfname, __GT_FILE, 0, 0, mode);
+ if (fd == -1)
+ return SEM_FAILED;
+
+ if (TEMP_FAILURE_RETRY (__libc_write (fd, &sem.initsem, sizeof (sem_t)))
+ == sizeof (sem_t)
+ /* Map the sem_t structure from the file. */
+ && (result = (sem_t *) mmap (NULL, sizeof (sem_t),
+ PROT_READ | PROT_WRITE, MAP_SHARED,
+ fd, 0)) != MAP_FAILED)
+ {
+ /* Create the file. Don't overwrite an existing file. */
+ if (link (tmpfname, finalname) != 0)
+ {
+ /* Undo the mapping. */
+ (void) munmap (result, sizeof (sem_t));
+
+ /* Reinitialize 'result'. */
+ result = SEM_FAILED;
+
+ /* This failed. If O_EXCL is not set and the problem was
+ that the file exists, try again. */
+ if ((oflag & O_EXCL) == 0 && errno == EEXIST)
+ {
+ /* Remove the file. */
+ (void) unlink (tmpfname);
+
+ /* Close the file. */
+ (void) __libc_close (fd);
+
+ goto try_again;
+ }
+ }
+ else
+ /* Insert the mapping into the search tree. This also
+ determines whether another thread sneaked by and already
+ added such a mapping despite the fact that we created it. */
+ result = check_add_mapping (name, namelen, fd, result);
+ }
+
+ /* Now remove the temporary name. This should never fail. If
+ it fails we leak a file name. Better fix the kernel. */
+ (void) unlink (tmpfname);
+ }
+
+ /* Map the mmap error to the error we need. */
+ if (MAP_FAILED != (void *) SEM_FAILED && result == MAP_FAILED)
+ result = SEM_FAILED;
+
+ /* We don't need the file descriptor anymore. */
+ if (fd != -1)
+ {
+ /* Do not disturb errno. */
+ INTERNAL_SYSCALL_DECL (err);
+ INTERNAL_SYSCALL (close, err, 1, fd);
+ }
+
+ return result;
+}
diff --git a/libpthread/nptl/sem_unlink.c b/libpthread/nptl/sem_unlink.c
new file mode 100644
index 000000000..d20df533a
--- /dev/null
+++ b/libpthread/nptl/sem_unlink.c
@@ -0,0 +1,66 @@
+/* Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <semaphore.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include "semaphoreP.h"
+
+
+int
+sem_unlink (
+ const char *name)
+{
+ char *fname;
+ size_t namelen;
+
+ /* Determine where the shmfs is mounted. */
+ INTUSE(__pthread_once) (&__namedsem_once, __where_is_shmfs);
+
+ /* If we don't know the mount points there is nothing we can do. Ever. */
+ if (mountpoint.dir == NULL)
+ {
+ __set_errno (ENOSYS);
+ return -1;
+ }
+
+ /* Construct the filename. */
+ while (name[0] == '/')
+ ++name;
+
+ if (name[0] == '\0')
+ {
+ /* The name "/" is not supported. */
+ __set_errno (ENOENT);
+ return -1;
+ }
+ namelen = strlen (name);
+
+ /* Create the name of the file. */
+ fname = (char *) alloca (mountpoint.dirlen + namelen + 1);
+ mempcpy (mempcpy (fname, mountpoint.dir, mountpoint.dirlen),
+ name, namelen + 1);
+
+ /* Now try removing it. */
+ int ret = unlink (fname);
+ if (ret < 0 && errno == EPERM)
+ __set_errno (EACCES);
+ return ret;
+}
diff --git a/libpthread/nptl/semaphore.h b/libpthread/nptl/semaphore.h
new file mode 100644
index 000000000..c7f195bdf
--- /dev/null
+++ b/libpthread/nptl/semaphore.h
@@ -0,0 +1,78 @@
+/* Copyright (C) 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/>. */
+
+#ifndef _SEMAPHORE_H
+#define _SEMAPHORE_H 1
+
+#include <features.h>
+#include <sys/types.h>
+#ifdef __USE_XOPEN2K
+# define __need_timespec
+# include <time.h>
+#endif
+
+/* Get the definition for sem_t. */
+#include <bits/semaphore.h>
+
+
+__BEGIN_DECLS
+
+/* Initialize semaphore object SEM to VALUE. If PSHARED then share it
+ with other processes. */
+extern int sem_init (sem_t *__sem, int __pshared, unsigned int __value)
+ __THROW;
+/* Free resources associated with semaphore object SEM. */
+extern int sem_destroy (sem_t *__sem) __THROW;
+
+/* Open a named semaphore NAME with open flags OFLAG. */
+extern sem_t *sem_open (const char *__name, int __oflag, ...) __THROW;
+
+/* Close descriptor for named semaphore SEM. */
+extern int sem_close (sem_t *__sem) __THROW;
+
+/* Remove named semaphore NAME. */
+extern int sem_unlink (const char *__name) __THROW;
+
+/* Wait for SEM being posted.
+
+ This function is a cancellation point and therefore not marked with
+ __THROW. */
+extern int sem_wait (sem_t *__sem);
+
+#ifdef __USE_XOPEN2K
+/* Similar to `sem_wait' but wait only until ABSTIME.
+
+ This function is a cancellation point and therefore not marked with
+ __THROW. */
+extern int sem_timedwait (sem_t *__restrict __sem,
+ const struct timespec *__restrict __abstime);
+#endif
+
+/* Test whether SEM is posted. */
+extern int sem_trywait (sem_t *__sem) __THROWNL;
+
+/* Post SEM. */
+extern int sem_post (sem_t *__sem) __THROWNL;
+
+/* Get current value of SEM and store it in *SVAL. */
+extern int sem_getvalue (sem_t *__restrict __sem, int *__restrict __sval)
+ __THROW;
+
+
+__END_DECLS
+
+#endif /* semaphore.h */
diff --git a/libpthread/nptl/semaphoreP.h b/libpthread/nptl/semaphoreP.h
new file mode 100644
index 000000000..e0b79d734
--- /dev/null
+++ b/libpthread/nptl/semaphoreP.h
@@ -0,0 +1,57 @@
+/* Copyright (C) 2002, 2003, 2006, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <semaphore.h>
+#include "pthreadP.h"
+
+
+/* Mount point of the shared memory filesystem. */
+struct mountpoint_info
+{
+ char *dir;
+ size_t dirlen;
+};
+
+/* Keeping track of currently used mappings. */
+struct inuse_sem
+{
+ dev_t dev;
+ ino_t ino;
+ int refcnt;
+ sem_t *sem;
+ char name[0];
+};
+
+
+/* Variables used in multiple interfaces. */
+extern struct mountpoint_info mountpoint attribute_hidden;
+
+extern pthread_once_t __namedsem_once attribute_hidden;
+
+/* The search tree for existing mappings. */
+extern void *__sem_mappings attribute_hidden;
+
+/* Lock to protect the search tree. */
+extern int __sem_mappings_lock attribute_hidden;
+
+
+/* Initializer for mountpoint. */
+extern void __where_is_shmfs (void) attribute_hidden;
+
+/* Comparison function for search in tree with existing mappings. */
+extern int __sem_search (const void *a, const void *b) attribute_hidden;
diff --git a/libpthread/nptl/sysdeps/Makefile b/libpthread/nptl/sysdeps/Makefile
new file mode 100644
index 000000000..4a8f4a072
--- /dev/null
+++ b/libpthread/nptl/sysdeps/Makefile
@@ -0,0 +1,13 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+top_srcdir=../../../
+top_builddir=../../../
+all: objs
+include $(top_builddir)Rules.mak
+include Makefile.in
+include $(top_srcdir)Makerules
diff --git a/libpthread/nptl/sysdeps/Makefile.commonarch b/libpthread/nptl/sysdeps/Makefile.commonarch
new file mode 100644
index 000000000..7f531f542
--- /dev/null
+++ b/libpthread/nptl/sysdeps/Makefile.commonarch
@@ -0,0 +1,64 @@
+# Makefile template to be included by libpthread/nptl/sysdeps/<ARCH>/Makefile.arch
+#
+# Copyright (C) 2010 Erik Andersen <andersen@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+subdirs += libpthread/nptl/sysdeps/$(TARGET_ARCH)
+libpthread_arch_DIR := $(top_srcdir)libpthread/nptl/sysdeps/$(TARGET_ARCH)
+libpthread_arch_OUT := $(top_builddir)libpthread/nptl/sysdeps/$(TARGET_ARCH)
+
+ifneq ($(abspath libpthread/nptl/sysdeps/$(TARGET_ARCH)),$(abspath libpthread/nptl/sysdeps/$(TARGET_ARCH)/$(TARGET_SUBARCH)))
+subdirs += libpthread/nptl/sysdeps/$(TARGET_ARCH)/$(TARGET_SUBARCH)
+libpthread_subarch_DIR := $(libpthread_arch_DIR)/$(TARGET_SUBARCH)
+libpthread_subarch_OUT := $(libpthread_arch_OUT)/$(TARGET_SUBARCH)
+endif
+
+-include $(libpthread_arch_DIR)/Makefile.arch
+libpthread_arch_SSRC := $(filter-out librt-%,$(filter-out libc-%,$(notdir $(wildcard $(libpthread_arch_DIR)/*.S))))
+libpthread_arch_CSRC := $(filter-out librt-%,$(filter-out libc-%,$(notdir $(wildcard $(libpthread_arch_DIR)/*.c))))
+libpthread_arch_CSRC := $(filter-out gen_%,$(libpthread_arch_CSRC))
+
+ifneq ($(TARGET_SUBARCH),)
+libpthread_subarch_SSRC := $(notdir $(wildcard $(libpthread_subarch_DIR)/*.S))
+libpthread_arch_SSRC := $(filter-out $(libpthread_subarch_SSRC),$(libpthread_arch_SSRC))
+libpthread_arch_CSRC := $(filter-out $(libpthread_subarch_SSRC:.S=.c),$(libpthread_arch_CSRC))
+libpthread_subarch_OBJS := $(patsubst %.S,$(libpthread_subarch_OUT)/%.o,$(libpthread_subarch_SSRC))
+endif
+
+libpthread_arch_COBJ = $(patsubst %.c,$(libpthread_arch_OUT)/%.o,$(libpthread_arch_CSRC))
+libpthread_arch_SOBJ = $(patsubst %.S,$(libpthread_arch_OUT)/%.o,$(libpthread_arch_SSRC))
+libpthread_arch_OBJS = $(libpthread_subarch_OBJS) $(libpthread_arch_COBJ) $(libpthread_arch_SOBJ)
+
+libc_arch_COBJ = $(patsubst %.c,$(libpthread_arch_OUT)/%.o,$(libc_arch_CSRC))
+libc_arch_SOBJ = $(patsubst %.c,$(libpthread_arch_OUT)/%.o,$(libc_arch_SSRC))
+libc_arch_OBJS = $(libc_arch_COBJ) $(libc_arch_SOBJ)
+libc_arch_a_COBJ = $(patsubst %.c,$(libpthread_arch_OUT)/%.o,$(libc_arch_a_CSRC))
+libc_arch_a_OBJS = $(libc_arch_a_COBJ)
+
+librt_arch_COBJ = $(patsubst %.c,$(libpthread_arch_OUT)/%.o,$(librt_arch_CSRC))
+librt_arch_SOBJ = $(patsubst %.S,$(libpthread_arch_OUT)/%.o,$(librt_arch_SSRC))
+librt_arch_OBJS = $(librt_arch_COBJ) $(librt_arch_SOBJ)
+
+$(libpthread_arch_OUT)/tcb-offsets.h: $(top_srcdir)extra/scripts/gen-as-const.awk
+$(libpthread_arch_OUT)/tcb-offsets.h: $(libpthread_arch_DIR)/tcb-offsets.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_THREADS_NATIVE) += $(libpthread_arch_OUT)/tcb-offsets.h
+
+objclean-y += CLEAN_$(subst $(top_builddir),,$(libpthread_arch_OUT))
+headers_clean-y+= HEADERCLEAN_$(subst $(top_builddir),,$(libpthread_arch_OUT))
+
+CLEAN_$(subst $(top_builddir),,$(libpthread_arch_OUT)):
+ $(do_rm) $(addprefix $(libpthread_arch_OUT)/*., o os oS)
+HEADERCLEAN_$(subst $(top_builddir),,$(libpthread_arch_OUT)):
+ $(do_rm) $(libpthread_arch_OUT)/tcb-offsets.h
+ifneq ($(TARGET_SUBARCH),)
+objclean-y += CLEAN_$(subst $(top_builddir),,$(libpthread_subarch_OUT))
+CLEAN_$(subst $(top_builddir),,$(libpthread_subarch_OUT)):
+ $(do_rm) $(addprefix $(libpthread_subarch_OUT)/*., o os oS)
+endif
diff --git a/libpthread/nptl/sysdeps/Makefile.in b/libpthread/nptl/sysdeps/Makefile.in
new file mode 100644
index 000000000..5296f4a7b
--- /dev/null
+++ b/libpthread/nptl/sysdeps/Makefile.in
@@ -0,0 +1,29 @@
+# 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.
+#
+
+subdirs += libpthread/nptl/sysdeps
+
+define arch_and_subarch
+ $(addprefix $(1)/,$(notdir $(2))) $(if $(TARGET_SUBARCH),$(addprefix $(1)/$(TARGET_SUBARCH)/,$(notdir $(2))))
+endef
+define base_and_arch_and_subarch
+ $(addprefix $(1)/,$(notdir $(2))) $(addprefix $(1)/$(TARGET_ARCH)/,$(notdir $(2))) $(if $(TARGET_SUBARCH),$(addprefix $(1)/$(TARGET_ARCH)/$(TARGET_SUBARCH)/,$(notdir $(2))))
+endef
+
+include $(libpthread_DIR)/sysdeps/unix/sysv/linux/Makefile.commonarch
+include $(libpthread_DIR)/sysdeps/generic/Makefile.in
+include $(libpthread_DIR)/sysdeps/Makefile.commonarch
+libpthread_generic_libc_a_CSRC := $(filter-out $(notdir $(libc_arch_a_OBJS:.o=.c)),$(libpthread_generic_libc_a_CSRC))
+libpthread_arch_OBJS := $(filter-out $(call base_and_arch_and_subarch,$(libpthread_arch_OUT),$(libpthread_linux_OBJS)),$(libpthread_arch_OBJS))
+include $(libpthread_DIR)/sysdeps/pthread/Makefile.in
+libpthread_pthread_CSRC := $(filter-out $(notdir $(libpthread_linux_OBJS:.o=.c) $(libpthread_arch_OBJS:.o=.c)),$(libpthread_pthread_CSRC))
+libpthread-so-y := $(filter-out $(call base_and_arch_and_subarch,$(libpthread_pthread_OUT),$(libpthread_linux_OBJS) $(libpthread_arch_OBJS)),$(libpthread-so-y))
+
+libpthread_OBJS := $(libpthread_linux_OBJS) $(libpthread_arch_OBJS) $(libpthread_pthread_COBJ)
+libpthread_libc_OBJS = $(libc_linux_OBJS) $(libc_arch_OBJS)
+libpthread_libc_a_OBJS = $(libc_arch_a_OBJS) $(libpthread_generic_libc_a_OBJS)
+libpthread_librt_OBJS = $(librt_linux_OBJS) $(librt_arch_OBJS)
diff --git a/libpthread/nptl/sysdeps/alpha/Makefile b/libpthread/nptl/sysdeps/alpha/Makefile
new file mode 100644
index 000000000..1cb812eda
--- /dev/null
+++ b/libpthread/nptl/sysdeps/alpha/Makefile
@@ -0,0 +1,20 @@
+# Copyright (C) 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; see the file COPYING.LIB. If
+# not, see <http://www.gnu.org/licenses/>.
+
+ifeq ($(subdir),csu)
+gen-as-const-headers += tcb-offsets.sym
+endif
diff --git a/libpthread/nptl/sysdeps/alpha/dl-tls.h b/libpthread/nptl/sysdeps/alpha/dl-tls.h
new file mode 100644
index 000000000..a87f66deb
--- /dev/null
+++ b/libpthread/nptl/sysdeps/alpha/dl-tls.h
@@ -0,0 +1,28 @@
+/* Thread-local storage handling in the ELF dynamic linker. Alpha version.
+ Copyright (C) 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/>. */
+
+
+/* Type used for the representation of TLS information in the GOT. */
+typedef struct
+{
+ unsigned long int ti_module;
+ unsigned long int ti_offset;
+} tls_index;
+
+
+extern void *__tls_get_addr (tls_index *ti);
diff --git a/libpthread/nptl/sysdeps/alpha/elf/pt-initfini.c b/libpthread/nptl/sysdeps/alpha/elf/pt-initfini.c
new file mode 100644
index 000000000..e5e214dfe
--- /dev/null
+++ b/libpthread/nptl/sysdeps/alpha/elf/pt-initfini.c
@@ -0,0 +1,88 @@
+/* Special .init and .fini section support for Alpha. NPTL version.
+ Copyright (C) 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 file is compiled into assembly code which is then munged by a sed
+ script into two files: crti.s and crtn.s.
+
+ * crti.s puts a function prologue at the beginning of the .init and .fini
+ sections and defines global symbols for those addresses, so they can be
+ called as functions.
+
+ * crtn.s puts the corresponding function epilogues in the .init and .fini
+ sections.
+
+ This differs from what would be generated by the generic code in that
+ we save and restore the GP within the function. In order for linker
+ relaxation to work, the value in the GP register on exit from a function
+ must be valid for the function entry point. Normally, a function is
+ contained within one object file and this is not an issue, provided
+ that the function reloads the gp after making any function calls.
+ However, _init and _fini are constructed from pieces of many object
+ files, all of which may have different GP values. So we must reload
+ the GP value from crti.o in crtn.o. */
+
+__asm__ (" \n\
+#include \"defs.h\" \n\
+ \n\
+/*@HEADER_ENDS*/ \n\
+ \n\
+/*@_init_PROLOG_BEGINS*/ \n\
+ .section .init, \"ax\", @progbits \n\
+ .globl _init \n\
+ .type _init,@function \n\
+ .usepv _init,std \n\
+_init: \n\
+ ldgp $29, 0($27) \n\
+ subq $30, 16, $30 \n\
+ stq $26, 0($30) \n\
+ stq $29, 8($30) \n\
+ bsr $26, __pthread_initialize_minimal_internal !samegp \n\
+ .align 3 \n\
+/*@_init_PROLOG_ENDS*/ \n\
+ \n\
+/*@_init_EPILOG_BEGINS*/ \n\
+ .section .init, \"ax\", @progbits \n\
+ ldq $26, 0($30) \n\
+ ldq $29, 8($30) \n\
+ addq $30, 16, $30 \n\
+ ret \n\
+/*@_init_EPILOG_ENDS*/ \n\
+ \n\
+/*@_fini_PROLOG_BEGINS*/ \n\
+ .section .fini, \"ax\", @progbits \n\
+ .globl _fini \n\
+ .type _fini,@function \n\
+ .usepv _fini,std \n\
+_fini: \n\
+ ldgp $29, 0($27) \n\
+ subq $30, 16, $30 \n\
+ stq $26, 0($30) \n\
+ stq $29, 8($30) \n\
+ .align 3 \n\
+/*@_fini_PROLOG_ENDS*/ \n\
+ \n\
+/*@_fini_EPILOG_BEGINS*/ \n\
+ .section .fini, \"ax\", @progbits \n\
+ ldq $26, 0($30) \n\
+ ldq $29, 8($30) \n\
+ addq $30, 16, $30 \n\
+ ret \n\
+/*@_fini_EPILOG_ENDS*/ \n\
+ \n\
+/*@TRAILER_BEGINS*/ \n\
+");
diff --git a/libpthread/nptl/sysdeps/alpha/jmpbuf-unwind.h b/libpthread/nptl/sysdeps/alpha/jmpbuf-unwind.h
new file mode 100644
index 000000000..2f64e7d7c
--- /dev/null
+++ b/libpthread/nptl/sysdeps/alpha/jmpbuf-unwind.h
@@ -0,0 +1,27 @@
+/* Copyright (C) 2003, 2004 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/>. */
+
+#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))
diff --git a/libpthread/nptl/sysdeps/alpha/libc-tls.c b/libpthread/nptl/sysdeps/alpha/libc-tls.c
new file mode 100644
index 000000000..41cc78c59
--- /dev/null
+++ b/libpthread/nptl/sysdeps/alpha/libc-tls.c
@@ -0,0 +1,36 @@
+/* Thread-local storage handling in the ELF dynamic linker. Alpha version.
+ Copyright (C) 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 <sysdeps/generic/libc-tls.c>
+#include <dl-tls.h>
+
+#if USE_TLS
+
+/* On Alpha, linker optimizations are not required, so __tls_get_addr
+ can be called even in statically linked binaries. In this case module
+ must be always 1 and PT_TLS segment exist in the binary, otherwise it
+ would not link. */
+
+void *
+__tls_get_addr (tls_index *ti)
+{
+ dtv_t *dtv = THREAD_DTV ();
+ return (char *) dtv[1].pointer.val + ti->ti_offset;
+}
+
+#endif
diff --git a/libpthread/nptl/sysdeps/alpha/pthread_spin_lock.S b/libpthread/nptl/sysdeps/alpha/pthread_spin_lock.S
new file mode 100644
index 000000000..2dd1e5ddd
--- /dev/null
+++ b/libpthread/nptl/sysdeps/alpha/pthread_spin_lock.S
@@ -0,0 +1,44 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson <rth@twiddle.net>, 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/>. */
+
+
+ .text
+ .align 4
+
+ .globl pthread_spin_lock
+ .ent pthread_spin_lock
+pthread_spin_lock:
+ .frame $sp, 0, $26, 0
+ .prologue 0
+
+0: ldl_l $1, 0($16)
+ lda $2, 1
+ lda $0, 0
+ bne $1, 1f
+
+ stl_c $2, 0($16)
+ beq $2, 1f
+ mb
+ ret
+
+1: ldl $1, 0($16)
+ bne $1, 1b
+ unop
+ br 0b
+
+ .end pthread_spin_lock
diff --git a/libpthread/nptl/sysdeps/alpha/pthread_spin_trylock.S b/libpthread/nptl/sysdeps/alpha/pthread_spin_trylock.S
new file mode 100644
index 000000000..15905be50
--- /dev/null
+++ b/libpthread/nptl/sysdeps/alpha/pthread_spin_trylock.S
@@ -0,0 +1,45 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson <rth@twiddle.net>, 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/>. */
+
+
+#define _ERRNO_H 1
+#include <bits/errno.h>
+
+ .text
+ .align 4
+
+ .globl pthread_spin_trylock
+ .ent pthread_spin_trylock
+pthread_spin_trylock:
+ .frame $sp, 0, $26, 0
+ .prologue 0
+
+0: ldl_l $1, 0($16)
+ lda $2, 1
+ lda $0, EBUSY
+ bne $1, 1f
+
+ stl_c $2, 0($16)
+ beq $2, 2f
+ mb
+ lda $0, 0
+
+1: ret
+2: br 0b
+
+ .end pthread_spin_trylock
diff --git a/libpthread/nptl/sysdeps/alpha/pthreaddef.h b/libpthread/nptl/sysdeps/alpha/pthreaddef.h
new file mode 100644
index 000000000..72a311c33
--- /dev/null
+++ b/libpthread/nptl/sysdeps/alpha/pthreaddef.h
@@ -0,0 +1,37 @@
+/* Copyright (C) 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/>. */
+
+/* Default stack size. */
+#define ARCH_STACK_DEFAULT_SIZE (4 * 1024 * 1024)
+
+/* Required stack pointer alignment at beginning. The ABI requires 16. */
+#define STACK_ALIGN 16
+
+/* Minimal stack size after allocating thread descriptor and guard size. */
+#define MINIMAL_REST_STACK 4096
+
+/* Alignment requirement for TCB. */
+#define TCB_ALIGNMENT 16
+
+/* Location of current stack frame. */
+#define CURRENT_STACK_FRAME __builtin_frame_address (0)
+
+/* XXX Until we have a better place keep the definitions here. */
+
+/* While there is no such syscall. */
+#define __exit_thread_inline(val) \
+ INLINE_SYSCALL (exit, 1, (val))
diff --git a/libpthread/nptl/sysdeps/alpha/tcb-offsets.sym b/libpthread/nptl/sysdeps/alpha/tcb-offsets.sym
new file mode 100644
index 000000000..c21a79104
--- /dev/null
+++ b/libpthread/nptl/sysdeps/alpha/tcb-offsets.sym
@@ -0,0 +1,14 @@
+#include <sysdep.h>
+#include <tls.h>
+
+--
+
+-- Abuse tls.h macros to derive offsets relative to the thread register.
+-- # define __builtin_thread_pointer() ((void *) 0)
+-- # define thread_offsetof(mem) ((void *) &THREAD_SELF->mem - (void *) 0)
+-- Ho hum, this doesn't work in gcc4, so Know Things about THREAD_SELF
+#define thread_offsetof(mem) (long)(offsetof(struct pthread, mem) - sizeof(struct pthread))
+
+MULTIPLE_THREADS_OFFSET thread_offsetof (header.multiple_threads)
+PID_OFFSET thread_offsetof (pid)
+TID_OFFSET thread_offsetof (tid)
diff --git a/libpthread/nptl/sysdeps/alpha/tls.h b/libpthread/nptl/sysdeps/alpha/tls.h
new file mode 100644
index 000000000..96468e06d
--- /dev/null
+++ b/libpthread/nptl/sysdeps/alpha/tls.h
@@ -0,0 +1,126 @@
+/* Definition for thread-local data handling. NPTL/Alpha version.
+ Copyright (C) 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _TLS_H
+#define _TLS_H 1
+
+#ifndef __ASSEMBLER__
+# include <stdbool.h>
+# include <stddef.h>
+# include <stdint.h>
+
+/* Type for the dtv. */
+typedef union dtv
+{
+ size_t counter;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
+} dtv_t;
+
+#else /* __ASSEMBLER__ */
+# include <tcb-offsets.h>
+#endif /* __ASSEMBLER__ */
+
+
+/* We require TLS support in the tools. */
+#ifndef HAVE_TLS_SUPPORT
+# error "TLS support is required."
+#endif
+
+/* Signal that TLS support is available. */
+# define USE_TLS 1
+
+#ifndef __ASSEMBLER__
+
+/* Get system call information. */
+# include <sysdep.h>
+
+/* The TP points to the start of the thread blocks. */
+# define TLS_DTV_AT_TP 1
+
+/* Get the thread descriptor definition. */
+# include <nptl/descr.h>
+
+typedef struct
+{
+ dtv_t *dtv;
+ void *private;
+} tcbhead_t;
+
+/* This is the size of the initial TCB. */
+# define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
+
+/* Alignment requirements for the initial TCB. */
+# define TLS_INIT_TCB_ALIGN 16
+
+/* This is the size of the TCB. */
+# define TLS_TCB_SIZE sizeof (tcbhead_t)
+
+/* This is the size we need before TCB. */
+# define TLS_PRE_TCB_SIZE sizeof (struct pthread)
+
+/* Alignment requirements for the TCB. */
+# define TLS_TCB_ALIGN 16
+
+/* Install the dtv pointer. The pointer passed is to the element with
+ index -1 which contain the length. */
+# define INSTALL_DTV(tcbp, dtvp) \
+ (((tcbhead_t *) (tcbp))->dtv = (dtvp) + 1)
+
+/* Install new dtv for current thread. */
+# define INSTALL_NEW_DTV(dtv) \
+ (THREAD_DTV() = (dtv))
+
+/* Return dtv of given thread descriptor. */
+# define GET_DTV(tcbp) \
+ (((tcbhead_t *) (tcbp))->dtv)
+
+/* Code to initially initialize the thread pointer. This might need
+ special attention since 'errno' is not yet available and if the
+ operation can cause a failure 'errno' must not be touched. */
+# define TLS_INIT_TP(tcbp, secondcall) \
+ (__builtin_set_thread_pointer ((void *)(tcbp)), NULL)
+
+/* Return the address of the dtv for the current thread. */
+# define THREAD_DTV() \
+ (((tcbhead_t *) __builtin_thread_pointer ())->dtv)
+
+/* Return the thread descriptor for the current thread. */
+# define THREAD_SELF \
+ ((struct pthread *)__builtin_thread_pointer () - 1)
+
+/* Magic for libthread_db to know how to do THREAD_SELF. */
+# define DB_THREAD_SELF \
+ REGISTER (64, 64, 32 * 8, -sizeof (struct pthread))
+
+/* Access to data in the thread descriptor is easy. */
+#define THREAD_GETMEM(descr, member) \
+ descr->member
+#define THREAD_GETMEM_NC(descr, member, idx) \
+ descr->member[idx]
+#define THREAD_SETMEM(descr, member, value) \
+ descr->member = (value)
+#define THREAD_SETMEM_NC(descr, member, idx, value) \
+ descr->member[idx] = (value)
+
+#endif /* __ASSEMBLER__ */
+
+#endif /* tls.h */
diff --git a/libpthread/nptl/sysdeps/arc/Makefile.arch b/libpthread/nptl/sysdeps/arc/Makefile.arch
new file mode 100644
index 000000000..08ec7e7d9
--- /dev/null
+++ b/libpthread/nptl/sysdeps/arc/Makefile.arch
@@ -0,0 +1,8 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2005 Steven J. Hill <sjhill@uclibc.org>
+#
+# Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+#
+
+libc_arch_a_CSRC = libc-tls.c
diff --git a/libpthread/nptl/sysdeps/arc/dl-tls.h b/libpthread/nptl/sysdeps/arc/dl-tls.h
new file mode 100644
index 000000000..34e54e4d3
--- /dev/null
+++ b/libpthread/nptl/sysdeps/arc/dl-tls.h
@@ -0,0 +1,28 @@
+/* Thread-local storage handling in the ELF dynamic linker. ARC version.
+ 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/>. */
+
+
+/* Type used for the representation of TLS information in the GOT. */
+typedef struct
+{
+ unsigned long int ti_module;
+ unsigned long int ti_offset;
+} tls_index;
+
+
+extern void *__tls_get_addr (tls_index *ti);
diff --git a/libpthread/nptl/sysdeps/arc/jmpbuf-unwind.h b/libpthread/nptl/sysdeps/arc/jmpbuf-unwind.h
new file mode 100644
index 000000000..11a043b23
--- /dev/null
+++ b/libpthread/nptl/sysdeps/arc/jmpbuf-unwind.h
@@ -0,0 +1,32 @@
+/* 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 <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))
diff --git a/libpthread/nptl/sysdeps/arc/libc-tls.c b/libpthread/nptl/sysdeps/arc/libc-tls.c
new file mode 100644
index 000000000..f53ad112e
--- /dev/null
+++ b/libpthread/nptl/sysdeps/arc/libc-tls.c
@@ -0,0 +1,27 @@
+/*
+ * Thread-local storage handling in statically linked binaries.
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * Based on GNU C Library (file: libc/sysdeps/sh/libc-tls.c)
+ *
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ * Copyright (C) 2010 STMicroelectronics Ltd.
+ *
+ * Author: Filippo Arcidiacono <filippo.arcidiacono@st.com>
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sysdeps/generic/libc-tls.c>
+#include <dl-tls.h>
+
+#if defined(USE_TLS) && USE_TLS
+
+void *
+__tls_get_addr (tls_index *ti)
+{
+ dtv_t *dtv = THREAD_DTV ();
+ return (char *) dtv[1].pointer.val + ti->ti_offset;
+}
+
+#endif
diff --git a/libpthread/nptl/sysdeps/arc/pthread_spin_lock.S b/libpthread/nptl/sysdeps/arc/pthread_spin_lock.S
new file mode 100644
index 000000000..7a5e630b8
--- /dev/null
+++ b/libpthread/nptl/sysdeps/arc/pthread_spin_lock.S
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sysdep.h>
+
+; int pthread_spin_lock(pthread_spinlock_t *lock)
+; 1 - locked, 0 - unlocked
+
+ENTRY(pthread_spin_lock)
+ mov_s r1, 1
+ nop_s
+1:
+ ex r1, [r0]
+ breq r1, 1, 1b
+
+ j.d [blink]
+ mov r0, 0
+END(pthread_spin_lock)
diff --git a/libpthread/nptl/sysdeps/arc/pthread_spin_trylock.S b/libpthread/nptl/sysdeps/arc/pthread_spin_trylock.S
new file mode 100644
index 000000000..25f5421a2
--- /dev/null
+++ b/libpthread/nptl/sysdeps/arc/pthread_spin_trylock.S
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sysdep.h>
+
+#define _ERRNO_H 1
+#include <bits/errno.h>
+
+; int pthread_spin_trylock(pthread_spinlock_t *lock)
+; Return EBUSY is already locked, 0 if not
+
+ENTRY(pthread_spin_trylock)
+ mov_s r1, 1
+ ex r1, [r0]
+ tst r1, r1
+ mov.z r0, 0
+ j.d [blink]
+ mov.nz r0, EBUSY
+
+; slightly faster, but difficult to follow
+; mov_s r1, r0
+; mov_s r0, 1
+; ex r0, [r1]
+; tst r0, r0
+; j.d [blink]
+; mov.nz r0, EBUSY
+
+END(pthread_spin_trylock)
diff --git a/libc/sysdeps/linux/e1/sys/procfs.h b/libpthread/nptl/sysdeps/arc/pthreaddef.h
index 8416b3b58..51625e4e6 100644
--- a/libc/sysdeps/linux/e1/sys/procfs.h
+++ b/libpthread/nptl/sysdeps/arc/pthreaddef.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 1999, 2000, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 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
@@ -16,16 +16,25 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#ifndef _SYS_PROCFS_H
-#define _SYS_PROCFS_H 1
+#include <sysdep.h>
-/* 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.
+/* Default stack size. */
+#define ARCH_STACK_DEFAULT_SIZE (2 * 1024 * 1024)
- 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. */
+/* Required stack pointer alignment at beginning. */
+#define STACK_ALIGN 8
-#endif /* sys/procfs.h */
+/* Minimal stack size after allocating thread descriptor and guard size. */
+#define MINIMAL_REST_STACK 2048
+
+/* Alignment requirement for TCB. */
+#define TCB_ALIGNMENT 8
+
+
+/* Location of current stack frame. */
+#define CURRENT_STACK_FRAME __builtin_frame_address (0)
+
+
+/* XXX Until we have a better place keep the definitions here. */
+#define __exit_thread_inline(val) \
+ INLINE_SYSCALL (exit, 1, (val))
diff --git a/libpthread/nptl/sysdeps/arc/tcb-offsets.sym b/libpthread/nptl/sysdeps/arc/tcb-offsets.sym
new file mode 100644
index 000000000..cbf0ae42c
--- /dev/null
+++ b/libpthread/nptl/sysdeps/arc/tcb-offsets.sym
@@ -0,0 +1,8 @@
+#include <sysdep.h>
+#include <tls.h>
+
+PTHREAD_TID offsetof (struct pthread, tid)
+PTHREAD_PID offsetof (struct pthread, pid)
+MULTIPLE_THREADS_OFFSET offsetof (struct pthread, header.multiple_threads)
+TLS_PRE_TCB_SIZE sizeof (struct pthread)
+TLS_TCB_SIZE sizeof(tcbhead_t)
diff --git a/libpthread/nptl/sysdeps/arc/tls.h b/libpthread/nptl/sysdeps/arc/tls.h
new file mode 100644
index 000000000..4af415a1c
--- /dev/null
+++ b/libpthread/nptl/sysdeps/arc/tls.h
@@ -0,0 +1,163 @@
+/* Definition for thread-local data handling. NPTL/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.
+ */
+
+#ifndef _TLS_H
+#define _TLS_H
+
+#ifndef __ASSEMBLER__
+# include <stdbool.h>
+# include <stddef.h>
+# include <stdint.h>
+# include <stdlib.h>
+# include <list.h>
+# include <sysdep.h>
+# include <bits/kernel-features.h>
+
+/* Type for the dtv. */
+typedef union dtv
+{
+ size_t counter;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
+} dtv_t;
+
+typedef struct
+{
+ dtv_t *dtv;
+ uintptr_t pointer_guard;
+} tcbhead_t;
+
+# define TLS_MULTIPLE_THREADS_IN_TCB 1
+
+#else /* __ASSEMBLER__ */
+# include <tcb-offsets.h>
+
+.macro THREAD_SELF reg
+ # struct pthread is just ahead of TCB
+ sub \reg, r25, TLS_PRE_TCB_SIZE
+.endm
+
+.macro SET_TP tcb
+ mov r25, \tcb
+.endm
+
+#endif /* __ASSEMBLER__ */
+
+
+/* We require TLS support in the tools. */
+#define HAVE_TLS_SUPPORT
+#define HAVE___THREAD 1
+#define HAVE_TLS_MODEL_ATTRIBUTE 1
+/* Signal that TLS support is available. */
+# define USE_TLS 1
+
+#ifndef __ASSEMBLER__
+
+/* Get system call information. */
+# include <sysdep.h>
+
+/* This is the size of the initial TCB. */
+# define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
+
+/* Alignment requirements for the initial TCB. */
+# define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
+
+/* This is the size of the TCB. */
+#ifndef TLS_TCB_SIZE
+# define TLS_TCB_SIZE sizeof (tcbhead_t)
+#endif
+
+/* This is the size we need before TCB. */
+# define TLS_PRE_TCB_SIZE sizeof (struct pthread)
+
+/* Alignment requirements for the TCB. */
+# define TLS_TCB_ALIGN __alignof__ (struct pthread)
+
+/* The TLS blocks start right after the TCB. */
+# define TLS_DTV_AT_TP 1
+
+/* Get the thread descriptor definition. */
+# include <descr.h>
+
+/* Install the dtv pointer. The pointer passed is to the element with
+ index -1 which contain the length. */
+# define INSTALL_DTV(tcbp, dtvp) \
+ ((tcbhead_t *) (tcbp))->dtv = (dtvp) + 1
+
+/* Install new dtv for current thread. */
+# define INSTALL_NEW_DTV(dtv) \
+ (THREAD_DTV() = (dtv))
+
+/* Return dtv of given thread descriptor. */
+# define GET_DTV(tcbp) \
+ (((tcbhead_t *) (tcbp))->dtv)
+
+/* Code to initially initialize the thread pointer. This might need
+ special attention since 'errno' is not yet available and if the
+ operation can cause a failure 'errno' must not be touched. */
+# define TLS_INIT_TP(tcbp, secondcall) \
+ ({ \
+ long result_var; \
+ __builtin_set_thread_pointer(tcbp); \
+ result_var = INTERNAL_SYSCALL (arc_settls, err, 1, (tcbp)); \
+ INTERNAL_SYSCALL_ERROR_P (result_var, err) \
+ ? "unknown error" : NULL; \
+ })
+
+/* Return the address of the dtv for the current thread.
+ TP points to TCB where 1st item is dtv pointer */
+# define THREAD_DTV() \
+ (((tcbhead_t *)__builtin_thread_pointer())->dtv)
+
+/* Return the thread descriptor for the current thread.
+ pthread sits right before TCB */
+# define THREAD_SELF \
+ ((struct pthread *)__builtin_thread_pointer() - 1)
+
+/* Magic for libthread_db to know how to do THREAD_SELF. */
+# define DB_THREAD_SELF \
+ CONST_THREAD_AREA (32, sizeof (struct pthread))
+
+/* Access to data in the thread descriptor is easy. */
+#define THREAD_GETMEM(descr, member) \
+ descr->member
+#define THREAD_GETMEM_NC(descr, member, idx) \
+ descr->member[idx]
+#define THREAD_SETMEM(descr, member, value) \
+ descr->member = (value)
+#define THREAD_SETMEM_NC(descr, member, idx, value) \
+ descr->member[idx] = (value)
+
+/* Get and set the global scope generation counter in struct pthread. */
+#define THREAD_GSCOPE_FLAG_UNUSED 0
+#define THREAD_GSCOPE_FLAG_USED 1
+#define THREAD_GSCOPE_FLAG_WAIT 2
+#define THREAD_GSCOPE_RESET_FLAG() \
+ do \
+ { int __res \
+ = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \
+ THREAD_GSCOPE_FLAG_UNUSED); \
+ if (__res == THREAD_GSCOPE_FLAG_WAIT) \
+ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \
+ } \
+ while (0)
+#define THREAD_GSCOPE_SET_FLAG() \
+ do \
+ { \
+ THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED; \
+ atomic_write_barrier (); \
+ } \
+ while (0)
+#define THREAD_GSCOPE_WAIT() \
+ GL(dl_wait_lookup_done) ()
+
+#endif /* __ASSEMBLER__ */
+
+#endif /* tls.h */
diff --git a/libpthread/nptl/sysdeps/arm/Makefile.arch b/libpthread/nptl/sysdeps/arm/Makefile.arch
new file mode 100644
index 000000000..62a2822df
--- /dev/null
+++ b/libpthread/nptl/sysdeps/arm/Makefile.arch
@@ -0,0 +1,10 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2005 Steven J. Hill <sjhill@uclibc.org>
+# Portions Copyright (C) 2006 CodeSourcery
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+librt_arch_SSRC = aeabi_read_tp.S thumb_atomics.S
+libc_arch_a_CSRC = libc-tls.c
diff --git a/libpthread/nptl/sysdeps/arm/aeabi_read_tp.S b/libpthread/nptl/sysdeps/arm/aeabi_read_tp.S
new file mode 100644
index 000000000..af640d625
--- /dev/null
+++ b/libpthread/nptl/sysdeps/arm/aeabi_read_tp.S
@@ -0,0 +1 @@
+#include <../../../../ldso/ldso/arm/aeabi_read_tp.S>
diff --git a/libpthread/nptl/sysdeps/arm/dl-tls.h b/libpthread/nptl/sysdeps/arm/dl-tls.h
new file mode 100644
index 000000000..a728455e4
--- /dev/null
+++ b/libpthread/nptl/sysdeps/arm/dl-tls.h
@@ -0,0 +1,28 @@
+/* Thread-local storage handling in the ELF dynamic linker. ARM version.
+ 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/>. */
+
+
+/* Type used for the representation of TLS information in the GOT. */
+typedef struct
+{
+ unsigned long int ti_module;
+ unsigned long int ti_offset;
+} tls_index;
+
+
+extern void *__tls_get_addr (tls_index *ti);
diff --git a/libpthread/nptl/sysdeps/arm/jmpbuf-unwind.h b/libpthread/nptl/sysdeps/arm/jmpbuf-unwind.h
new file mode 100644
index 000000000..11a043b23
--- /dev/null
+++ b/libpthread/nptl/sysdeps/arm/jmpbuf-unwind.h
@@ -0,0 +1,32 @@
+/* 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 <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))
diff --git a/libpthread/nptl/sysdeps/arm/libc-tls.c b/libpthread/nptl/sysdeps/arm/libc-tls.c
new file mode 100644
index 000000000..657607281
--- /dev/null
+++ b/libpthread/nptl/sysdeps/arm/libc-tls.c
@@ -0,0 +1,36 @@
+/* Thread-local storage handling in the ELF dynamic linker. ARM version.
+ 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/>. */
+
+#include <sysdeps/generic/libc-tls.c>
+#include <dl-tls.h>
+
+#if defined(USE_TLS) && USE_TLS
+
+/* On ARM, linker optimizations are not required, so __tls_get_addr
+ can be called even in statically linked binaries. In this case module
+ must be always 1 and PT_TLS segment exist in the binary, otherwise it
+ would not link. */
+
+void *
+__tls_get_addr (tls_index *ti)
+{
+ dtv_t *dtv = THREAD_DTV ();
+ return (char *) dtv[1].pointer.val + ti->ti_offset;
+}
+
+#endif
diff --git a/libpthread/nptl/sysdeps/arm/pthread_spin_lock.S b/libpthread/nptl/sysdeps/arm/pthread_spin_lock.S
new file mode 100644
index 000000000..a9c07c87d
--- /dev/null
+++ b/libpthread/nptl/sysdeps/arm/pthread_spin_lock.S
@@ -0,0 +1,30 @@
+/* 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/>. */
+
+#include <sysdep.h>
+
+ .text
+ .align 4
+
+ENTRY (pthread_spin_lock)
+ mov r1, #1
+1: swp r2, r1, [r0]
+ teq r2, #0
+ bne 1b
+ mov r0, #0
+ PSEUDO_RET_NOERRNO
+END (pthread_spin_lock)
diff --git a/libpthread/nptl/sysdeps/arm/pthread_spin_trylock.S b/libpthread/nptl/sysdeps/arm/pthread_spin_trylock.S
new file mode 100644
index 000000000..8ccaffd75
--- /dev/null
+++ b/libpthread/nptl/sysdeps/arm/pthread_spin_trylock.S
@@ -0,0 +1,33 @@
+/* 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/>. */
+
+#define _ERRNO_H 1
+#include <bits/errno.h>
+
+#include <sysdep.h>
+
+ .text
+ .align 4
+
+ENTRY (pthread_spin_trylock)
+ mov r1, #1
+ swp r2, r1, [r0]
+ teq r2, #0
+ moveq r0, #0
+ movne r0, #EBUSY
+ PSEUDO_RET_NOERRNO
+END (pthread_spin_trylock)
diff --git a/libpthread/nptl/sysdeps/arm/pthreaddef.h b/libpthread/nptl/sysdeps/arm/pthreaddef.h
new file mode 100644
index 000000000..a05ac879d
--- /dev/null
+++ b/libpthread/nptl/sysdeps/arm/pthreaddef.h
@@ -0,0 +1,38 @@
+/* Copyright (C) 2002, 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, see
+ <http://www.gnu.org/licenses/>. */
+
+/* Default stack size. */
+#define ARCH_STACK_DEFAULT_SIZE (2 * 1024 * 1024)
+
+/* Required stack pointer alignment at beginning. SSE requires 16
+ bytes. */
+#define STACK_ALIGN 16
+
+/* Minimal stack size after allocating thread descriptor and guard size. */
+#define MINIMAL_REST_STACK 2048
+
+/* Alignment requirement for TCB. */
+#define TCB_ALIGNMENT 16
+
+
+/* Location of current stack frame. */
+#define CURRENT_STACK_FRAME __builtin_frame_address (0)
+
+
+/* XXX Until we have a better place keep the definitions here. */
+#define __exit_thread_inline(val) \
+ INLINE_SYSCALL (exit, 1, (val))
diff --git a/libpthread/nptl/sysdeps/arm/tcb-offsets.sym b/libpthread/nptl/sysdeps/arm/tcb-offsets.sym
new file mode 100644
index 000000000..92cc441d3
--- /dev/null
+++ b/libpthread/nptl/sysdeps/arm/tcb-offsets.sym
@@ -0,0 +1,11 @@
+#include <sysdep.h>
+#include <tls.h>
+
+--
+
+-- Derive offsets relative to the thread register.
+#define thread_offsetof(mem) (long)(offsetof(struct pthread, mem) - sizeof(struct pthread))
+
+MULTIPLE_THREADS_OFFSET thread_offsetof (header.multiple_threads)
+PID_OFFSET thread_offsetof (pid)
+TID_OFFSET thread_offsetof (tid)
diff --git a/libpthread/nptl/sysdeps/arm/thumb_atomics.S b/libpthread/nptl/sysdeps/arm/thumb_atomics.S
new file mode 100644
index 000000000..aaa7a3d8f
--- /dev/null
+++ b/libpthread/nptl/sysdeps/arm/thumb_atomics.S
@@ -0,0 +1 @@
+#include <../../../../ldso/ldso/arm/thumb_atomics.S>
diff --git a/libpthread/nptl/sysdeps/arm/tls.h b/libpthread/nptl/sysdeps/arm/tls.h
new file mode 100644
index 000000000..f32cfc892
--- /dev/null
+++ b/libpthread/nptl/sysdeps/arm/tls.h
@@ -0,0 +1,158 @@
+/* Definition for thread-local data handling. NPTL/ARM version.
+ Copyright (C) 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 _TLS_H
+#define _TLS_H 1
+
+#ifndef __ASSEMBLER__
+
+# include <stdbool.h>
+# include <stddef.h>
+# include <stdint.h>
+
+/* Type for the dtv. */
+typedef union dtv
+{
+ size_t counter;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
+} dtv_t;
+
+#else /* __ASSEMBLER__ */
+# include <tcb-offsets.h>
+#endif /* __ASSEMBLER__ */
+
+
+/* We require TLS support in the tools. */
+#define HAVE_TLS_SUPPORT 1
+#define HAVE_TLS_MODEL_ATTRIBUTE 1
+#define HAVE___THREAD 1
+
+/* Signal that TLS support is available. */
+#define USE_TLS 1
+
+#ifndef __ASSEMBLER__
+
+/* Get system call information. */
+# include <sysdep.h>
+
+/* The TP points to the start of the thread blocks. */
+# define TLS_DTV_AT_TP 1
+
+/* Get the thread descriptor definition. */
+# include <../../descr.h>
+
+typedef struct
+{
+ dtv_t *dtv;
+ void *private;
+} tcbhead_t;
+
+/* This is the size of the initial TCB. */
+# define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
+
+/* Alignment requirements for the initial TCB. */
+# define TLS_INIT_TCB_ALIGN 16
+
+/* This is the size of the TCB. */
+# define TLS_TCB_SIZE sizeof (tcbhead_t)
+
+/* This is the size we need before TCB. */
+# define TLS_PRE_TCB_SIZE sizeof (struct pthread)
+
+/* Alignment requirements for the TCB. */
+# define TLS_TCB_ALIGN 16
+
+/* Install the dtv pointer. The pointer passed is to the element with
+ index -1 which contain the length. */
+# define INSTALL_DTV(tcbp, dtvp) \
+ (((tcbhead_t *) (tcbp))->dtv = (dtvp) + 1)
+
+/* Install new dtv for current thread. */
+# define INSTALL_NEW_DTV(dtv) \
+ (THREAD_DTV() = (dtv))
+
+/* Return dtv of given thread descriptor. */
+# define GET_DTV(tcbp) \
+ (((tcbhead_t *) (tcbp))->dtv)
+
+/* Code to initially initialize the thread pointer. This might need
+ special attention since 'errno' is not yet available and if the
+ operation can cause a failure 'errno' must not be touched. */
+# define TLS_INIT_TP(tcbp, secondcall) \
+ ({ INTERNAL_SYSCALL_DECL (err); \
+ long result_var; \
+ result_var = INTERNAL_SYSCALL_ARM (set_tls, err, 1, (tcbp)); \
+ INTERNAL_SYSCALL_ERROR_P (result_var, err) \
+ ? "unknown error" : NULL; })
+
+/* Return the address of the dtv for the current thread. */
+# define THREAD_DTV() \
+ (((tcbhead_t *) __builtin_thread_pointer ())->dtv)
+
+/* Return the thread descriptor for the current thread. */
+# define THREAD_SELF \
+ ((struct pthread *)__builtin_thread_pointer () - 1)
+
+/* Magic for libthread_db to know how to do THREAD_SELF. */
+# define DB_THREAD_SELF \
+ CONST_THREAD_AREA (32, sizeof (struct pthread))
+
+/* Access to data in the thread descriptor is easy. */
+#define THREAD_GETMEM(descr, member) \
+ descr->member
+#define THREAD_GETMEM_NC(descr, member, idx) \
+ descr->member[idx]
+#define THREAD_SETMEM(descr, member, value) \
+ descr->member = (value)
+#define THREAD_SETMEM_NC(descr, member, idx, value) \
+ descr->member[idx] = (value)
+
+/* Initializing the thread pointer will generate a SIGILL if the syscall
+ is not available. */
+#define TLS_INIT_TP_EXPENSIVE 1
+
+/* Get and set the global scope generation counter in struct pthread. */
+#define THREAD_GSCOPE_FLAG_UNUSED 0
+#define THREAD_GSCOPE_FLAG_USED 1
+#define THREAD_GSCOPE_FLAG_WAIT 2
+#define THREAD_GSCOPE_RESET_FLAG() \
+ do \
+ { int __res \
+ = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \
+ THREAD_GSCOPE_FLAG_UNUSED); \
+ if (__res == THREAD_GSCOPE_FLAG_WAIT) \
+ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \
+ } \
+ while (0)
+#define THREAD_GSCOPE_SET_FLAG() \
+ do \
+ { \
+ THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED; \
+ atomic_write_barrier (); \
+ } \
+ while (0)
+#define THREAD_GSCOPE_WAIT() \
+ GL(dl_wait_lookup_done) ()
+
+#endif /* __ASSEMBLER__ */
+
+#endif /* tls.h */
diff --git a/libpthread/nptl/sysdeps/generic/Makefile b/libpthread/nptl/sysdeps/generic/Makefile
new file mode 100644
index 000000000..582661fde
--- /dev/null
+++ b/libpthread/nptl/sysdeps/generic/Makefile
@@ -0,0 +1,13 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2006 Steven J. Hill <sjhill@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+top_srcdir=../../../../
+top_builddir=../../../../
+all: objs
+include $(top_builddir)Rules.mak
+include Makefile.in
+include $(top_srcdir)Makerules
diff --git a/libpthread/nptl/sysdeps/generic/Makefile.in b/libpthread/nptl/sysdeps/generic/Makefile.in
new file mode 100644
index 000000000..eb656ee17
--- /dev/null
+++ b/libpthread/nptl/sysdeps/generic/Makefile.in
@@ -0,0 +1,25 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2006 Steven J. Hill <sjhill@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+subdirs += libpthread/nptl/sysdeps/generic
+#
+# NOTE: Alpha and MIPS have their own versions of 'libc-tls.c' in
+# their architecture specific directory which will override
+# the one here.
+#
+libpthread_generic_DIR := $(top_srcdir)libpthread/nptl/sysdeps/generic
+libpthread_generic_OUT := $(top_builddir)libpthread/nptl/sysdeps/generic
+
+libpthread_generic_libc_a_CSRC = libc-tls.c
+libpthread_generic_libc_a_COBJ = $(patsubst %.c,$(libpthread_generic_OUT)/%.o,$(libpthread_generic_libc_a_CSRC))
+libpthread_generic_libc_a_OBJS = $(libpthread_generic_libc_a_COBJ)
+libpthread_ld_tls_CSRC = dl-tls.c
+libpthread_ld_tls_COBJ = $(patsubst %.c,$(libpthread_generic_OUT)/%.o,$(libpthread_ld_tls_CSRC))
+
+objclean-y += CLEAN_libpthread/nptl/sysdeps/generic
+
+CLEAN_libpthread/nptl/sysdeps/generic:
+ $(do_rm) $(addprefix $(libpthread_generic_OUT)/*., o os oS)
diff --git a/libpthread/nptl/sysdeps/generic/dl-tls.c b/libpthread/nptl/sysdeps/generic/dl-tls.c
new file mode 100644
index 000000000..10a54211a
--- /dev/null
+++ b/libpthread/nptl/sysdeps/generic/dl-tls.c
@@ -0,0 +1,900 @@
+/* Thread-local storage handling in the ELF dynamic linker. Generic version.
+ 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 SHARED || defined NOT_IN_libc
+# error in buildsystem: This file is for libc.a
+#endif
+#include <libintl.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <sys/param.h>
+#include <tls.h>
+#include <dl-tls.h>
+#include <ldsodefs.h>
+#include <dl-elf.h>
+#include <dl-hash.h>
+
+#include <assert.h>
+#include <link.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdio.h>
+
+#define _dl_malloc malloc
+#define _dl_memset memset
+#define _dl_mempcpy mempcpy
+#define _dl_dprintf fprintf
+#define _dl_debug_file stderr
+#define _dl_exit exit
+
+/* Amount of excess space to allocate in the static TLS area
+ to allow dynamic loading of modules defining IE-model TLS data. */
+# define TLS_STATIC_SURPLUS 64 + DL_NNS * 100
+
+/* Value used for dtv entries for which the allocation is delayed. */
+# define TLS_DTV_UNALLOCATED ((void *) -1l)
+
+
+/* Out-of-memory handler. */
+# ifdef SHARED
+static void
+__attribute__ ((__noreturn__))
+oom (void)
+{
+ do {
+ _dl_dprintf (_dl_debug_file,
+ "cannot allocate thread-local memory: ABORT\n");
+ _dl_exit (127);
+ } while (1);
+}
+# endif
+
+
+void *_dl_memalign(size_t alignment, size_t bytes);
+void *_dl_memalign(size_t alignment, size_t bytes)
+{
+ return _dl_malloc(bytes);
+}
+
+
+/*
+ * We are trying to perform a static TLS relocation in MAP, but it was
+ * dynamically loaded. This can only work if there is enough surplus in
+ * the static TLS area already allocated for each running thread. If this
+ * object's TLS segment is too big to fit, we fail. If it fits,
+ * we set MAP->l_tls_offset and return.
+ * This function intentionally does not return any value but signals error
+ * directly, as static TLS should be rare and code handling it should
+ * not be inlined as much as possible.
+ */
+
+
+void
+internal_function __attribute_noinline__
+_dl_allocate_static_tls (struct link_map *map)
+{
+ /* If the alignment requirements are too high fail. */
+ if (map->l_tls_align > _dl_tls_static_align)
+ {
+fail:
+ _dl_dprintf(_dl_debug_file, "cannot allocate memory in static TLS block");
+ _dl_exit(30);
+ }
+
+# if defined(TLS_TCB_AT_TP)
+ size_t freebytes;
+ size_t n;
+ size_t blsize;
+
+ freebytes = _dl_tls_static_size - _dl_tls_static_used - TLS_TCB_SIZE;
+
+ blsize = map->l_tls_blocksize + map->l_tls_firstbyte_offset;
+ if (freebytes < blsize)
+ goto fail;
+
+ n = (freebytes - blsize) / map->l_tls_align;
+
+ size_t offset = _dl_tls_static_used + (freebytes - n * map->l_tls_align
+ - map->l_tls_firstbyte_offset);
+
+ map->l_tls_offset = _dl_tls_static_used = offset;
+# elif defined(TLS_DTV_AT_TP)
+ size_t used;
+ size_t check;
+
+ size_t offset = roundup (_dl_tls_static_used, map->l_tls_align);
+ used = offset + map->l_tls_blocksize;
+ check = used;
+
+ /* dl_tls_static_used includes the TCB at the beginning. */
+ if (check > _dl_tls_static_size)
+ goto fail;
+
+ map->l_tls_offset = offset;
+ _dl_tls_static_used = used;
+# else
+# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
+# endif
+
+ /*
+ * If the object is not yet relocated we cannot initialize the
+ * static TLS region. Delay it.
+ */
+ if (((struct elf_resolve *) map)->init_flag & RELOCS_DONE)
+ {
+#ifdef SHARED
+ /*
+ * Update the slot information data for at least the generation of
+ * the DSO we are allocating data for.
+ */
+ if (__builtin_expect (THREAD_DTV()[0].counter != _dl_tls_generation, 0))
+ (void) _dl_update_slotinfo (map->l_tls_modid);
+#endif
+ _dl_init_static_tls (map);
+ }
+ else
+ map->l_need_tls_init = 1;
+}
+
+size_t
+internal_function
+_dl_next_tls_modid (void)
+{
+ size_t result;
+
+ if (__builtin_expect (GL(dl_tls_dtv_gaps), false))
+ {
+ size_t disp = 0;
+ struct dtv_slotinfo_list *runp = GL(dl_tls_dtv_slotinfo_list);
+
+ /* Note that this branch will never be executed during program
+ start since there are no gaps at that time. Therefore it
+ does not matter that the dl_tls_dtv_slotinfo is not allocated
+ yet when the function is called for the first times.
+
+ NB: the offset +1 is due to the fact that DTV[0] is used
+ for something else. */
+ result = GL(dl_tls_static_nelem) + 1;
+ if (result <= GL(dl_tls_max_dtv_idx))
+ do
+ {
+ while (result - disp < runp->len)
+ {
+ if (runp->slotinfo[result - disp].map == NULL)
+ break;
+
+ ++result;
+ assert (result <= GL(dl_tls_max_dtv_idx) + 1);
+ }
+
+ if (result - disp < runp->len)
+ break;
+
+ disp += runp->len;
+ }
+ while ((runp = runp->next) != NULL);
+
+ if (result > GL(dl_tls_max_dtv_idx))
+ {
+ /* The new index must indeed be exactly one higher than the
+ previous high. */
+ assert (result == GL(dl_tls_max_dtv_idx) + 1);
+ /* There is no gap anymore. */
+ GL(dl_tls_dtv_gaps) = false;
+
+ goto nogaps;
+ }
+ }
+ else
+ {
+ /* No gaps, allocate a new entry. */
+ nogaps:
+
+ result = ++GL(dl_tls_max_dtv_idx);
+ }
+
+ return result;
+}
+
+
+# ifdef SHARED
+void
+internal_function
+_dl_determine_tlsoffset (void)
+{
+ size_t max_align = TLS_TCB_ALIGN;
+ size_t freetop = 0;
+ size_t freebottom = 0;
+
+ /* The first element of the dtv slot info list is allocated. */
+ assert (GL(dl_tls_dtv_slotinfo_list) != NULL);
+ /* There is at this point only one element in the
+ dl_tls_dtv_slotinfo_list list. */
+ assert (GL(dl_tls_dtv_slotinfo_list)->next == NULL);
+
+ struct dtv_slotinfo *slotinfo = GL(dl_tls_dtv_slotinfo_list)->slotinfo;
+
+ /* Determining the offset of the various parts of the static TLS
+ block has several dependencies. In addition we have to work
+ around bugs in some toolchains.
+
+ Each TLS block from the objects available at link time has a size
+ and an alignment requirement. The GNU ld computes the alignment
+ requirements for the data at the positions *in the file*, though.
+ I.e, it is not simply possible to allocate a block with the size
+ of the TLS program header entry. The data is layed out assuming
+ that the first byte of the TLS block fulfills
+
+ p_vaddr mod p_align == &TLS_BLOCK mod p_align
+
+ This means we have to add artificial padding at the beginning of
+ the TLS block. These bytes are never used for the TLS data in
+ this module but the first byte allocated must be aligned
+ according to mod p_align == 0 so that the first byte of the TLS
+ block is aligned according to p_vaddr mod p_align. This is ugly
+ and the linker can help by computing the offsets in the TLS block
+ assuming the first byte of the TLS block is aligned according to
+ p_align.
+
+ The extra space which might be allocated before the first byte of
+ the TLS block need not go unused. The code below tries to use
+ that memory for the next TLS block. This can work if the total
+ memory requirement for the next TLS block is smaller than the
+ gap. */
+
+# if defined(TLS_TCB_AT_TP)
+ /* We simply start with zero. */
+ size_t offset = 0;
+
+ size_t cnt;
+ for (cnt = 0; slotinfo[cnt].map != NULL; ++cnt)
+ {
+ assert (cnt < GL(dl_tls_dtv_slotinfo_list)->len);
+
+ size_t firstbyte = (-slotinfo[cnt].map->l_tls_firstbyte_offset
+ & (slotinfo[cnt].map->l_tls_align - 1));
+ size_t off;
+ max_align = MAX (max_align, slotinfo[cnt].map->l_tls_align);
+
+ if (freebottom - freetop >= slotinfo[cnt].map->l_tls_blocksize)
+ {
+ off = roundup (freetop + slotinfo[cnt].map->l_tls_blocksize
+ - firstbyte, slotinfo[cnt].map->l_tls_align)
+ + firstbyte;
+ if (off <= freebottom)
+ {
+ freetop = off;
+
+ /* XXX For some architectures we perhaps should store the
+ negative offset. */
+ slotinfo[cnt].map->l_tls_offset = off;
+ continue;
+ }
+ }
+
+ off = roundup (offset + slotinfo[cnt].map->l_tls_blocksize - firstbyte,
+ slotinfo[cnt].map->l_tls_align) + firstbyte;
+ if (off > offset + slotinfo[cnt].map->l_tls_blocksize
+ + (freebottom - freetop))
+ {
+ freetop = offset;
+ freebottom = off - slotinfo[cnt].map->l_tls_blocksize;
+ }
+ offset = off;
+
+ /* XXX For some architectures we perhaps should store the
+ negative offset. */
+ slotinfo[cnt].map->l_tls_offset = off;
+ }
+
+ GL(dl_tls_static_used) = offset;
+ GL(dl_tls_static_size) = (roundup (offset + TLS_STATIC_SURPLUS, max_align)
+ + TLS_TCB_SIZE);
+# elif defined(TLS_DTV_AT_TP)
+ /* The TLS blocks start right after the TCB. */
+ size_t offset = TLS_TCB_SIZE;
+ size_t cnt;
+
+ for (cnt = 0; slotinfo[cnt].map != NULL; ++cnt)
+ {
+ assert (cnt < GL(dl_tls_dtv_slotinfo_list)->len);
+
+ size_t firstbyte = (-slotinfo[cnt].map->l_tls_firstbyte_offset
+ & (slotinfo[cnt].map->l_tls_align - 1));
+ size_t off;
+ max_align = MAX (max_align, slotinfo[cnt].map->l_tls_align);
+
+ if (slotinfo[cnt].map->l_tls_blocksize <= freetop - freebottom)
+ {
+ off = roundup (freebottom, slotinfo[cnt].map->l_tls_align);
+ if (off - freebottom < firstbyte)
+ off += slotinfo[cnt].map->l_tls_align;
+ if (off + slotinfo[cnt].map->l_tls_blocksize - firstbyte <= freetop)
+ {
+ slotinfo[cnt].map->l_tls_offset = off - firstbyte;
+ freebottom = (off + slotinfo[cnt].map->l_tls_blocksize
+ - firstbyte);
+ continue;
+ }
+ }
+
+ off = roundup (offset, slotinfo[cnt].map->l_tls_align);
+ if (off - offset < firstbyte)
+ off += slotinfo[cnt].map->l_tls_align;
+
+ slotinfo[cnt].map->l_tls_offset = off - firstbyte;
+ if (off - firstbyte - offset > freetop - freebottom)
+ {
+ freebottom = offset;
+ freetop = off - firstbyte;
+ }
+
+ offset = off + slotinfo[cnt].map->l_tls_blocksize - firstbyte;
+ }
+
+ GL(dl_tls_static_used) = offset;
+ GL(dl_tls_static_size) = roundup (offset + TLS_STATIC_SURPLUS,
+ TLS_TCB_ALIGN);
+# else
+# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
+# endif
+
+ /* The alignment requirement for the static TLS block. */
+ GL(dl_tls_static_align) = max_align;
+}
+
+
+/* This is called only when the data structure setup was skipped at startup,
+ when there was no need for it then. Now we have dynamically loaded
+ something needing TLS, or libpthread needs it. */
+int
+internal_function
+_dl_tls_setup (void)
+{
+ assert (GL(dl_tls_dtv_slotinfo_list) == NULL);
+ assert (GL(dl_tls_max_dtv_idx) == 0);
+
+ const size_t nelem = 2 + TLS_SLOTINFO_SURPLUS;
+
+ GL(dl_tls_dtv_slotinfo_list)
+ = calloc (1, (sizeof (struct dtv_slotinfo_list)
+ + nelem * sizeof (struct dtv_slotinfo)));
+ if (GL(dl_tls_dtv_slotinfo_list) == NULL)
+ return -1;
+
+ GL(dl_tls_dtv_slotinfo_list)->len = nelem;
+
+ /* Number of elements in the static TLS block. It can't be zero
+ because of various assumptions. The one element is null. */
+ GL(dl_tls_static_nelem) = GL(dl_tls_max_dtv_idx) = 1;
+
+ /* This initializes more variables for us. */
+ _dl_determine_tlsoffset ();
+
+ return 0;
+}
+# endif
+
+static void *
+internal_function
+allocate_dtv (void *result)
+{
+ dtv_t *dtv;
+ size_t dtv_length;
+
+ /* We allocate a few more elements in the dtv than are needed for the
+ initial set of modules. This should avoid in most cases expansions
+ of the dtv. */
+ dtv_length = GL(dl_tls_max_dtv_idx) + DTV_SURPLUS;
+ dtv = calloc (dtv_length + 2, sizeof (dtv_t));
+ if (dtv != NULL)
+ {
+ /* This is the initial length of the dtv. */
+ dtv[0].counter = dtv_length;
+
+ /* The rest of the dtv (including the generation counter) is
+ Initialize with zero to indicate nothing there. */
+
+ /* Add the dtv to the thread data structures. */
+ INSTALL_DTV (result, dtv);
+ }
+ else
+ result = NULL;
+
+ return result;
+}
+
+
+/* Get size and alignment requirements of the static TLS block. */
+void
+internal_function
+_dl_get_tls_static_info (size_t *sizep, size_t *alignp)
+{
+ *sizep = GL(dl_tls_static_size);
+ *alignp = GL(dl_tls_static_align);
+}
+
+
+void *
+internal_function
+_dl_allocate_tls_storage (void)
+{
+ void *result;
+ size_t size = GL(dl_tls_static_size);
+
+# if defined(TLS_DTV_AT_TP)
+ /* Memory layout is:
+ [ TLS_PRE_TCB_SIZE ] [ TLS_TCB_SIZE ] [ TLS blocks ]
+ ^ This should be returned. */
+ size += (TLS_PRE_TCB_SIZE + GL(dl_tls_static_align) - 1)
+ & ~(GL(dl_tls_static_align) - 1);
+# endif
+
+ /* Allocate a correctly aligned chunk of memory. */
+ result = _dl_memalign (GL(dl_tls_static_align), size);
+ if (__builtin_expect (result != NULL, 1))
+ {
+ /* Allocate the DTV. */
+ void *allocated = result;
+
+# if defined(TLS_TCB_AT_TP)
+ /* The TCB follows the TLS blocks. */
+ result = (char *) result + size - TLS_TCB_SIZE;
+
+ /* Clear the TCB data structure. We can't ask the caller (i.e.
+ libpthread) to do it, because we will initialize the DTV et al. */
+ _dl_memset (result, '\0', TLS_TCB_SIZE);
+# elif defined(TLS_DTV_AT_TP)
+ result = (char *) result + size - GL(dl_tls_static_size);
+
+ /* Clear the TCB data structure and TLS_PRE_TCB_SIZE bytes before it.
+ We can't ask the caller (i.e. libpthread) to do it, because we will
+ initialize the DTV et al. */
+ _dl_memset ((char *) result - TLS_PRE_TCB_SIZE, '\0',
+ TLS_PRE_TCB_SIZE + TLS_TCB_SIZE);
+# endif
+
+ result = allocate_dtv (result);
+ if (result == NULL)
+ free (allocated);
+ }
+
+ return result;
+}
+
+
+void *
+internal_function
+_dl_allocate_tls_init (void *result)
+{
+ if (result == NULL)
+ /* The memory allocation failed. */
+ return NULL;
+
+ dtv_t *dtv = GET_DTV (result);
+ struct dtv_slotinfo_list *listp;
+ size_t total = 0;
+ size_t maxgen = 0;
+
+ /* We have to prepare the dtv for all currently loaded modules using
+ TLS. For those which are dynamically loaded we add the values
+ indicating deferred allocation. */
+ listp = GL(dl_tls_dtv_slotinfo_list);
+ while (1)
+ {
+ size_t cnt;
+
+ for (cnt = total == 0 ? 1 : 0; cnt < listp->len; ++cnt)
+ {
+ struct link_map *map;
+ void *dest;
+
+ /* Check for the total number of used slots. */
+ if (total + cnt > GL(dl_tls_max_dtv_idx))
+ break;
+
+ map = listp->slotinfo[cnt].map;
+ if (map == NULL)
+ /* Unused entry. */
+ continue;
+
+ /* Keep track of the maximum generation number. This might
+ not be the generation counter. */
+ maxgen = MAX (maxgen, listp->slotinfo[cnt].gen);
+
+ if (map->l_tls_offset == NO_TLS_OFFSET)
+ {
+ /* For dynamically loaded modules we simply store
+ the value indicating deferred allocation. */
+ dtv[map->l_tls_modid].pointer.val = TLS_DTV_UNALLOCATED;
+ dtv[map->l_tls_modid].pointer.is_static = false;
+ continue;
+ }
+
+ assert (map->l_tls_modid == cnt);
+ assert (map->l_tls_blocksize >= map->l_tls_initimage_size);
+# if defined(TLS_TCB_AT_TP)
+ assert ((size_t) map->l_tls_offset >= map->l_tls_blocksize);
+ dest = (char *) result - map->l_tls_offset;
+# elif defined(TLS_DTV_AT_TP)
+ dest = (char *) result + map->l_tls_offset;
+# else
+# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
+# endif
+
+ /* Copy the initialization image and clear the BSS part. */
+ dtv[map->l_tls_modid].pointer.val = dest;
+ dtv[map->l_tls_modid].pointer.is_static = true;
+ _dl_memset (_dl_mempcpy (dest, map->l_tls_initimage,
+ map->l_tls_initimage_size), '\0',
+ map->l_tls_blocksize - map->l_tls_initimage_size);
+ }
+
+ total += cnt;
+ if (total >= GL(dl_tls_max_dtv_idx))
+ break;
+
+ listp = listp->next;
+ assert (listp != NULL);
+ }
+
+ /* The DTV version is up-to-date now. */
+ dtv[0].counter = maxgen;
+
+ return result;
+}
+
+void *
+internal_function
+_dl_allocate_tls (void *mem)
+{
+ return _dl_allocate_tls_init (mem == NULL
+ ? _dl_allocate_tls_storage ()
+ : allocate_dtv (mem));
+}
+
+
+void
+internal_function
+_dl_deallocate_tls (void *tcb, bool dealloc_tcb)
+{
+ dtv_t *dtv = GET_DTV (tcb);
+ size_t cnt;
+
+ /* We need to free the memory allocated for non-static TLS. */
+ for (cnt = 0; cnt < dtv[-1].counter; ++cnt)
+ if (! dtv[1 + cnt].pointer.is_static
+ && dtv[1 + cnt].pointer.val != TLS_DTV_UNALLOCATED)
+ free (dtv[1 + cnt].pointer.val);
+
+ /* The array starts with dtv[-1]. */
+#ifdef SHARED
+ if (dtv != GL(dl_initial_dtv))
+#endif
+ free (dtv - 1);
+
+ if (dealloc_tcb)
+ {
+# if defined(TLS_TCB_AT_TP)
+ /* The TCB follows the TLS blocks. Back up to free the whole block. */
+ tcb -= GL(dl_tls_static_size) - TLS_TCB_SIZE;
+# elif defined(TLS_DTV_AT_TP)
+ /* Back up the TLS_PRE_TCB_SIZE bytes. */
+ tcb -= (TLS_PRE_TCB_SIZE + GL(dl_tls_static_align) - 1)
+ & ~(GL(dl_tls_static_align) - 1);
+# endif
+ free (tcb);
+ }
+}
+
+
+# ifdef SHARED
+/* The __tls_get_addr function has two basic forms which differ in the
+ arguments. The IA-64 form takes two parameters, the module ID and
+ offset. The form used, among others, on IA-32 takes a reference to
+ a special structure which contain the same information. The second
+ form seems to be more often used (in the moment) so we default to
+ it. Users of the IA-64 form have to provide adequate definitions
+ of the following macros. */
+# ifndef GET_ADDR_ARGS
+# define GET_ADDR_ARGS tls_index *ti
+# endif
+# ifndef GET_ADDR_MODULE
+# define GET_ADDR_MODULE ti->ti_module
+# endif
+# ifndef GET_ADDR_OFFSET
+# define GET_ADDR_OFFSET ti->ti_offset
+# endif
+
+
+static void *
+allocate_and_init (struct link_map *map)
+{
+ void *newp;
+
+ newp = _dl_memalign (map->l_tls_align, map->l_tls_blocksize);
+ if (newp == NULL)
+ oom ();
+
+ /* Initialize the memory. */
+ _dl_memset (_dl_mempcpy (newp, map->l_tls_initimage, map->l_tls_initimage_size),
+ '\0', map->l_tls_blocksize - map->l_tls_initimage_size);
+
+ return newp;
+}
+
+
+struct link_map *
+_dl_update_slotinfo (unsigned long int req_modid)
+{
+ struct link_map *the_map = NULL;
+ dtv_t *dtv = THREAD_DTV ();
+
+ /* The global dl_tls_dtv_slotinfo array contains for each module
+ index the generation counter current when the entry was created.
+ This array never shrinks so that all module indices which were
+ valid at some time can be used to access it. Before the first
+ use of a new module index in this function the array was extended
+ appropriately. Access also does not have to be guarded against
+ modifications of the array. It is assumed that pointer-size
+ values can be read atomically even in SMP environments. It is
+ possible that other threads at the same time dynamically load
+ code and therefore add to the slotinfo list. This is a problem
+ since we must not pick up any information about incomplete work.
+ The solution to this is to ignore all dtv slots which were
+ created after the one we are currently interested. We know that
+ dynamic loading for this module is completed and this is the last
+ load operation we know finished. */
+ unsigned long int idx = req_modid;
+ struct dtv_slotinfo_list *listp = GL(dl_tls_dtv_slotinfo_list);
+
+ while (idx >= listp->len)
+ {
+ idx -= listp->len;
+ listp = listp->next;
+ }
+
+ if (dtv[0].counter < listp->slotinfo[idx].gen)
+ {
+ /* The generation counter for the slot is higher than what the
+ current dtv implements. We have to update the whole dtv but
+ only those entries with a generation counter <= the one for
+ the entry we need. */
+ size_t new_gen = listp->slotinfo[idx].gen;
+ size_t total = 0;
+
+ /* We have to look through the entire dtv slotinfo list. */
+ listp = GL(dl_tls_dtv_slotinfo_list);
+ do
+ {
+ size_t cnt;
+
+ for (cnt = total == 0 ? 1 : 0; cnt < listp->len; ++cnt)
+ {
+ size_t gen = listp->slotinfo[cnt].gen;
+
+ if (gen > new_gen)
+ /* This is a slot for a generation younger than the
+ one we are handling now. It might be incompletely
+ set up so ignore it. */
+ continue;
+
+ /* If the entry is older than the current dtv layout we
+ know we don't have to handle it. */
+ if (gen <= dtv[0].counter)
+ continue;
+
+ /* If there is no map this means the entry is empty. */
+ struct link_map *map = listp->slotinfo[cnt].map;
+ if (map == NULL)
+ {
+ /* If this modid was used at some point the memory
+ might still be allocated. */
+ if (! dtv[total + cnt].pointer.is_static
+ && dtv[total + cnt].pointer.val != TLS_DTV_UNALLOCATED)
+ {
+ free (dtv[total + cnt].pointer.val);
+ dtv[total + cnt].pointer.val = TLS_DTV_UNALLOCATED;
+ }
+
+ continue;
+ }
+
+ /* Check whether the current dtv array is large enough. */
+ size_t modid = map->l_tls_modid;
+ assert (total + cnt == modid);
+ if (dtv[-1].counter < modid)
+ {
+ /* Reallocate the dtv. */
+ dtv_t *newp;
+ size_t newsize = GL(dl_tls_max_dtv_idx) + DTV_SURPLUS;
+ size_t oldsize = dtv[-1].counter;
+
+ assert (map->l_tls_modid <= newsize);
+
+ if (dtv == GL(dl_initial_dtv))
+ {
+ /* This is the initial dtv that was allocated
+ during rtld startup using the dl-minimal.c
+ malloc instead of the real malloc. We can't
+ free it, we have to abandon the old storage. */
+
+ newp = malloc ((2 + newsize) * sizeof (dtv_t));
+ if (newp == NULL)
+ oom ();
+ _dl_memcpy (newp, &dtv[-1], oldsize * sizeof (dtv_t));
+ }
+ else
+ {
+ newp = realloc (&dtv[-1],
+ (2 + newsize) * sizeof (dtv_t));
+ if (newp == NULL)
+ oom ();
+ }
+
+ newp[0].counter = newsize;
+
+ /* Clear the newly allocated part. */
+ _dl_memset (newp + 2 + oldsize, '\0',
+ (newsize - oldsize) * sizeof (dtv_t));
+
+ /* Point dtv to the generation counter. */
+ dtv = &newp[1];
+
+ /* Install this new dtv in the thread data
+ structures. */
+ INSTALL_NEW_DTV (dtv);
+ }
+
+ /* If there is currently memory allocate for this
+ dtv entry free it. */
+ /* XXX Ideally we will at some point create a memory
+ pool. */
+ if (! dtv[modid].pointer.is_static
+ && dtv[modid].pointer.val != TLS_DTV_UNALLOCATED)
+ /* Note that free is called for NULL is well. We
+ deallocate even if it is this dtv entry we are
+ supposed to load. The reason is that we call
+ memalign and not malloc. */
+ free (dtv[modid].pointer.val);
+
+ /* This module is loaded dynamically- We defer memory
+ allocation. */
+ dtv[modid].pointer.is_static = false;
+ dtv[modid].pointer.val = TLS_DTV_UNALLOCATED;
+
+ if (modid == req_modid)
+ the_map = map;
+ }
+
+ total += listp->len;
+ }
+ while ((listp = listp->next) != NULL);
+
+ /* This will be the new maximum generation counter. */
+ dtv[0].counter = new_gen;
+ }
+
+ return the_map;
+}
+
+
+/* The generic dynamic and local dynamic model cannot be used in
+ statically linked applications. */
+void *
+__tls_get_addr (GET_ADDR_ARGS)
+{
+ dtv_t *dtv = THREAD_DTV ();
+ struct link_map *the_map = NULL;
+ void *p;
+
+ if (__builtin_expect (dtv[0].counter != GL(dl_tls_generation), 0))
+ the_map = _dl_update_slotinfo (GET_ADDR_MODULE);
+
+ p = dtv[GET_ADDR_MODULE].pointer.val;
+
+ if (__builtin_expect (p == TLS_DTV_UNALLOCATED, 0))
+ {
+ /* The allocation was deferred. Do it now. */
+ if (the_map == NULL)
+ {
+ /* Find the link map for this module. */
+ size_t idx = GET_ADDR_MODULE;
+ struct dtv_slotinfo_list *listp = GL(dl_tls_dtv_slotinfo_list);
+
+ while (idx >= listp->len)
+ {
+ idx -= listp->len;
+ listp = listp->next;
+ }
+
+ the_map = listp->slotinfo[idx].map;
+ }
+
+ p = dtv[GET_ADDR_MODULE].pointer.val = allocate_and_init (the_map);
+ dtv[GET_ADDR_MODULE].pointer.is_static = false;
+ }
+
+ return (char *) p + GET_ADDR_OFFSET;
+}
+# endif
+
+
+
+void _dl_add_to_slotinfo (struct link_map *l);
+void
+_dl_add_to_slotinfo (struct link_map *l)
+{
+ /* Now that we know the object is loaded successfully add
+ modules containing TLS data to the dtv info table. We
+ might have to increase its size. */
+ struct dtv_slotinfo_list *listp;
+ struct dtv_slotinfo_list *prevp;
+ size_t idx = l->l_tls_modid;
+
+ /* Find the place in the dtv slotinfo list. */
+ listp = GL(dl_tls_dtv_slotinfo_list);
+ prevp = NULL; /* Needed to shut up gcc. */
+ do
+ {
+ /* Does it fit in the array of this list element? */
+ if (idx < listp->len)
+ break;
+ idx -= listp->len;
+ prevp = listp;
+ listp = listp->next;
+ }
+ while (listp != NULL);
+
+ if (listp == NULL)
+ {
+ /* When we come here it means we have to add a new element
+ to the slotinfo list. And the new module must be in
+ the first slot. */
+ assert (idx == 0);
+
+ listp = prevp->next = (struct dtv_slotinfo_list *)
+ malloc (sizeof (struct dtv_slotinfo_list)
+ + TLS_SLOTINFO_SURPLUS * sizeof (struct dtv_slotinfo));
+ if (listp == NULL)
+ {
+ /* We ran out of memory. We will simply fail this
+ call but don't undo anything we did so far. The
+ application will crash or be terminated anyway very
+ soon. */
+
+ /* We have to do this since some entries in the dtv
+ slotinfo array might already point to this
+ generation. */
+ ++GL(dl_tls_generation);
+
+ _dl_dprintf (_dl_debug_file,
+ "cannot create TLS data structures: ABORT\n");
+ _dl_exit (127);
+ }
+
+ listp->len = TLS_SLOTINFO_SURPLUS;
+ listp->next = NULL;
+ _dl_memset (listp->slotinfo, '\0',
+ TLS_SLOTINFO_SURPLUS * sizeof (struct dtv_slotinfo));
+ }
+
+ /* Add the information into the slotinfo data structure. */
+ listp->slotinfo[idx].map = l;
+ listp->slotinfo[idx].gen = GL(dl_tls_generation) + 1;
+}
diff --git a/libpthread/nptl/sysdeps/generic/dl-tls.h b/libpthread/nptl/sysdeps/generic/dl-tls.h
new file mode 100644
index 000000000..7703a9752
--- /dev/null
+++ b/libpthread/nptl/sysdeps/generic/dl-tls.h
@@ -0,0 +1,2 @@
+/* There has to be an architecture specific version of this file. */
+#error "architecture-specific version of <dl-tls.h> missing"
diff --git a/libpthread/nptl/sysdeps/generic/libc-tls.c b/libpthread/nptl/sysdeps/generic/libc-tls.c
new file mode 100644
index 000000000..c7bd34713
--- /dev/null
+++ b/libpthread/nptl/sysdeps/generic/libc-tls.c
@@ -0,0 +1,266 @@
+/* Initialization code for TLS in statically linked application.
+ 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/>. */
+
+#include <errno.h>
+#include <ldsodefs.h>
+#include <tls.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/param.h>
+#include <elf.h>
+#include <link.h>
+#include <string.h>
+#include <stdlib.h>
+
+
+#ifdef SHARED
+ #error makefile bug, this file is for static only
+#endif
+
+#if USE_TLS
+extern ElfW(Phdr) *_dl_phdr;
+extern size_t _dl_phnum;
+
+
+static dtv_t static_dtv[2 + TLS_SLOTINFO_SURPLUS];
+
+
+static struct
+{
+ struct dtv_slotinfo_list si;
+ /* The dtv_slotinfo_list data structure does not include the actual
+ information since it is defined as an array of size zero. We define
+ here the necessary entries. Note that it is not important whether
+ there is padding or not since we will always access the information
+ through the 'si' element. */
+ struct dtv_slotinfo info[2 + TLS_SLOTINFO_SURPLUS];
+} static_slotinfo;
+
+/* Fake link map for the application. */
+static struct link_map static_map;
+
+
+/* Highest dtv index currently needed. */
+size_t _dl_tls_max_dtv_idx;
+/* Flag signalling whether there are gaps in the module ID allocation. */
+bool _dl_tls_dtv_gaps;
+/* Information about the dtv slots. */
+struct dtv_slotinfo_list *_dl_tls_dtv_slotinfo_list;
+/* Number of modules in the static TLS block. */
+size_t _dl_tls_static_nelem;
+/* Size of the static TLS block. */
+size_t _dl_tls_static_size;
+/* Size actually allocated in the static TLS block. */
+size_t _dl_tls_static_used;
+/* Alignment requirement of the static TLS block. */
+size_t _dl_tls_static_align;
+
+/* Generation counter for the dtv. */
+size_t _dl_tls_generation;
+
+
+/* Additional definitions needed by TLS initialization. */
+#ifdef TLS_INIT_HELPER
+TLS_INIT_HELPER
+#endif
+
+static inline void
+init_slotinfo (void)
+{
+ /* Create the slotinfo list. */
+ static_slotinfo.si.len = (((char *) (&static_slotinfo + 1)
+ - (char *) &static_slotinfo.si.slotinfo[0])
+ / sizeof static_slotinfo.si.slotinfo[0]);
+ // static_slotinfo.si.next = NULL; already zero
+
+ /* The slotinfo list. Will be extended by the code doing dynamic
+ linking. */
+ GL(dl_tls_max_dtv_idx) = 1;
+ GL(dl_tls_dtv_slotinfo_list) = &static_slotinfo.si;
+}
+
+static inline void
+init_static_tls (size_t memsz, size_t align)
+{
+ /* That is the size of the TLS memory for this object. The initialized
+ value of _dl_tls_static_size is provided by dl-open.c to request some
+ surplus that permits dynamic loading of modules with IE-model TLS. */
+ GL(dl_tls_static_size) = roundup (memsz + GL(dl_tls_static_size),
+ TLS_TCB_ALIGN);
+ GL(dl_tls_static_used) = memsz;
+ /* The alignment requirement for the static TLS block. */
+ GL(dl_tls_static_align) = align;
+ /* Number of elements in the static TLS block. */
+ GL(dl_tls_static_nelem) = GL(dl_tls_max_dtv_idx);
+}
+
+void __libc_setup_tls (size_t tcbsize, size_t tcbalign);
+void
+__libc_setup_tls (size_t tcbsize, size_t tcbalign)
+{
+ void *tlsblock;
+ size_t memsz = 0;
+ size_t filesz = 0;
+ void *initimage = NULL;
+ size_t align = 0;
+ size_t max_align = tcbalign;
+ size_t tcb_offset;
+ ElfW(Phdr) *phdr;
+
+ /* Look through the TLS segment if there is any. */
+ if (_dl_phdr != NULL)
+ for (phdr = _dl_phdr; phdr < &_dl_phdr[_dl_phnum]; ++phdr)
+ if (phdr->p_type == PT_TLS)
+ {
+ /* Remember the values we need. */
+ memsz = phdr->p_memsz;
+ filesz = phdr->p_filesz;
+ initimage = (void *) phdr->p_vaddr;
+ align = phdr->p_align;
+ if (phdr->p_align > max_align)
+ max_align = phdr->p_align;
+ break;
+ }
+
+ /* We have to set up the TCB block which also (possibly) contains
+ 'errno'. Therefore we avoid 'malloc' which might touch 'errno'.
+ Instead we use 'sbrk' which would only uses 'errno' if it fails.
+ In this case we are right away out of memory and the user gets
+ what she/he deserves.
+
+ The initialized value of _dl_tls_static_size is provided by dl-open.c
+ to request some surplus that permits dynamic loading of modules with
+ IE-model TLS. */
+# if defined(TLS_TCB_AT_TP)
+ tcb_offset = roundup (memsz + GL(dl_tls_static_size), tcbalign);
+ tlsblock = sbrk (tcb_offset + tcbsize + max_align);
+# elif defined(TLS_DTV_AT_TP)
+ tcb_offset = roundup (tcbsize, align ?: 1);
+ tlsblock = sbrk (tcb_offset + memsz + max_align
+ + TLS_PRE_TCB_SIZE + GL(dl_tls_static_size));
+ tlsblock += TLS_PRE_TCB_SIZE;
+# else
+ /* In case a model with a different layout for the TCB and DTV
+ is defined add another #elif here and in the following #ifs. */
+# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
+# endif
+
+ /* Align the TLS block. */
+ tlsblock = (void *) (((uintptr_t) tlsblock + max_align - 1)
+ & ~(max_align - 1));
+
+ /* Initialize the dtv. [0] is the length, [1] the generation counter. */
+ static_dtv[0].counter = (sizeof (static_dtv) / sizeof (static_dtv[0])) - 2;
+ // static_dtv[1].counter = 0; would be needed if not already done
+
+ /* Initialize the TLS block. */
+# if defined(TLS_TCB_AT_TP)
+ static_dtv[2].pointer.val = ((char *) tlsblock + tcb_offset
+ - roundup (memsz, align ?: 1));
+ static_map.l_tls_offset = roundup (memsz, align ?: 1);
+# elif defined(TLS_DTV_AT_TP)
+ static_dtv[2].pointer.val = (char *) tlsblock + tcb_offset;
+ static_map.l_tls_offset = tcb_offset;
+# else
+# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
+# endif
+ static_dtv[2].pointer.is_static = true;
+ /* sbrk gives us zero'd memory, so we don't need to clear the remainder. */
+ memcpy (static_dtv[2].pointer.val, initimage, filesz);
+
+ /* Install the pointer to the dtv. */
+
+ /* Initialize the thread pointer. */
+# if defined(TLS_TCB_AT_TP)
+ INSTALL_DTV ((char *) tlsblock + tcb_offset, static_dtv);
+
+ const char *lossage = TLS_INIT_TP ((char *) tlsblock + tcb_offset, 0);
+# elif defined(TLS_DTV_AT_TP)
+ INSTALL_DTV (tlsblock, static_dtv);
+ const char *lossage = (char *)TLS_INIT_TP (tlsblock, 0);
+# else
+# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
+# endif
+ if (__builtin_expect (lossage != NULL, 0))
+ abort();
+
+ /* We have to create a fake link map which normally would be created
+ by the dynamic linker. It just has to have enough information to
+ make the TLS routines happy. */
+ static_map.l_tls_align = align;
+ static_map.l_tls_blocksize = memsz;
+ static_map.l_tls_initimage = initimage;
+ static_map.l_tls_initimage_size = filesz;
+ static_map.l_tls_modid = 1;
+
+ init_slotinfo ();
+ // static_slotinfo.si.slotinfo[1].gen = 0; already zero
+ static_slotinfo.si.slotinfo[1].map = &static_map;
+
+ memsz = roundup (memsz, align ?: 1);
+
+# if defined(TLS_TCB_AT_TP)
+ memsz += tcbsize;
+# elif defined(TLS_DTV_AT_TP)
+ memsz += tcb_offset;
+# endif
+
+ init_static_tls (memsz, MAX (TLS_TCB_ALIGN, max_align));
+}
+
+/* This is called only when the data structure setup was skipped at startup,
+ when there was no need for it then. Now we have dynamically loaded
+ something needing TLS, or libpthread needs it. */
+int
+internal_function
+_dl_tls_setup (void)
+{
+ init_slotinfo ();
+ init_static_tls (
+# if defined(TLS_TCB_AT_TP)
+ TLS_TCB_SIZE,
+# else
+ 0,
+# endif
+ TLS_TCB_ALIGN);
+ return 0;
+}
+
+extern void __pthread_initialize_minimal(void) __attribute__((weak));
+
+/* This is the minimal initialization function used when libpthread is
+ not used. */
+void
+__attribute__ ((weak))
+__pthread_initialize_minimal (void)
+{
+ __libc_setup_tls (TLS_INIT_TCB_SIZE, TLS_INIT_TCB_ALIGN);
+}
+
+#elif defined NONTLS_INIT_TP
+
+/* This is the minimal initialization function used when libpthread is
+ not used. */
+void
+__attribute__ ((weak))
+__pthread_initialize_minimal (void)
+{
+ NONTLS_INIT_TP;
+}
+
+#endif
diff --git a/libpthread/nptl/sysdeps/generic/lowlevellock.h b/libpthread/nptl/sysdeps/generic/lowlevellock.h
new file mode 100644
index 000000000..cced770d2
--- /dev/null
+++ b/libpthread/nptl/sysdeps/generic/lowlevellock.h
@@ -0,0 +1,83 @@
+/* Low level locking macros used in NPTL implementation. Stub version.
+ Copyright (C) 2002, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <atomic.h>
+
+
+/* Mutex lock counter:
+ bit 31 clear means unlocked;
+ bit 31 set means locked.
+
+ All code that looks at bit 31 first increases the 'number of
+ interested threads' usage counter, which is in bits 0-30.
+
+ All negative mutex values indicate that the mutex is still locked. */
+
+
+static inline void
+__generic_mutex_lock (int *mutex)
+{
+ unsigned int v;
+
+ /* Bit 31 was clear, we got the mutex. (this is the fastpath). */
+ if (atomic_bit_test_set (mutex, 31) == 0)
+ return;
+
+ atomic_increment (mutex);
+
+ while (1)
+ {
+ if (atomic_bit_test_set (mutex, 31) == 0)
+ {
+ atomic_decrement (mutex);
+ return;
+ }
+
+ /* We have to wait now. First make sure the futex value we are
+ monitoring is truly negative (i.e. locked). */
+ v = *mutex;
+ if (v >= 0)
+ continue;
+
+ lll_futex_wait (mutex, v,
+ // XYZ check mutex flag
+ LLL_SHARED);
+ }
+}
+
+
+static inline void
+__generic_mutex_unlock (int *mutex)
+{
+ /* Adding 0x80000000 to the counter results in 0 if and only if
+ there are not other interested threads - we can return (this is
+ the fastpath). */
+ if (atomic_add_zero (mutex, 0x80000000))
+ return;
+
+ /* There are other threads waiting for this mutex, wake one of them
+ up. */
+ lll_futex_wake (mutex, 1,
+ // XYZ check mutex flag
+ LLL_SHARED);
+}
+
+
+#define lll_mutex_lock(futex) __generic_mutex_lock (&(futex))
+#define lll_mutex_unlock(futex) __generic_mutex_unlock (&(futex))
diff --git a/libpthread/nptl/sysdeps/i386/Makefile b/libpthread/nptl/sysdeps/i386/Makefile
new file mode 100644
index 000000000..c7e1247fd
--- /dev/null
+++ b/libpthread/nptl/sysdeps/i386/Makefile
@@ -0,0 +1,26 @@
+# Copyright (C) 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; see the file COPYING.LIB. If
+# not, see <http://www.gnu.org/licenses/>.
+
+ifeq ($(subdir),csu)
+gen-as-const-headers += tcb-offsets.sym
+endif
+
+ifeq ($(subdir),nptl)
+CFLAGS-pthread_create.c += -mpreferred-stack-boundary=4
+CFLAGS-tst-align.c += -mpreferred-stack-boundary=4
+CFLAGS-tst-align2.c += -mpreferred-stack-boundary=4
+endif
diff --git a/libpthread/nptl/sysdeps/i386/Makefile.arch b/libpthread/nptl/sysdeps/i386/Makefile.arch
new file mode 100644
index 000000000..957230384
--- /dev/null
+++ b/libpthread/nptl/sysdeps/i386/Makefile.arch
@@ -0,0 +1,10 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2005 Steven J. Hill <sjhill@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+CFLAGS-pthread_spin_lock.c += -D_GNU_SOURCE
+CFLAGS-pthread_create.c += -mpreferred-stack-boundary=4
+
diff --git a/libpthread/nptl/sysdeps/i386/dl-tls.h b/libpthread/nptl/sysdeps/i386/dl-tls.h
new file mode 100644
index 000000000..32495c1e0
--- /dev/null
+++ b/libpthread/nptl/sysdeps/i386/dl-tls.h
@@ -0,0 +1,61 @@
+/* Thread-local storage handling in the ELF dynamic linker. i386 version.
+ Copyright (C) 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, see
+ <http://www.gnu.org/licenses/>. */
+
+
+/* Type used for the representation of TLS information in the GOT. */
+typedef struct
+{
+ unsigned long int ti_module;
+ unsigned long int ti_offset;
+} tls_index;
+
+
+extern void *__tls_get_addr (tls_index *ti);
+
+#ifdef SHARED
+/* This is the prototype for the GNU version. */
+extern void *___tls_get_addr (tls_index *ti)
+ __attribute__ ((__regparm__ (1)));
+extern void *___tls_get_addr_internal (tls_index *ti)
+ __attribute__ ((__regparm__ (1))) attribute_hidden;
+
+# ifdef IS_IN_rtld
+/* The special thing about the x86 TLS ABI is that we have two
+ variants of the __tls_get_addr function with different calling
+ conventions. The GNU version, which we are mostly concerned here,
+ takes the parameter in a register. The name is changed by adding
+ an additional underscore at the beginning. The Sun version uses
+ the normal calling convention. */
+void *
+__tls_get_addr (tls_index *ti)
+{
+ return ___tls_get_addr_internal (ti);
+}
+
+
+/* Prepare using the definition of __tls_get_addr in the generic
+ version of this file. */
+# define __tls_get_addr __attribute__ ((__regparm__ (1))) ___tls_get_addr
+strong_alias (___tls_get_addr, ___tls_get_addr_internal)
+#else
+
+/* Users should get the better interface. */
+# define __tls_get_addr ___tls_get_addr
+
+# endif
+#endif
diff --git a/libpthread/nptl/sysdeps/i386/i486/pthread_spin_trylock.S b/libpthread/nptl/sysdeps/i386/i486/pthread_spin_trylock.S
new file mode 100644
index 000000000..9c1780282
--- /dev/null
+++ b/libpthread/nptl/sysdeps/i386/i486/pthread_spin_trylock.S
@@ -0,0 +1,46 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread-errnos.h>
+
+
+#ifdef UP
+# define LOCK
+#else
+# define LOCK lock
+#endif
+
+ .globl pthread_spin_trylock
+ .type pthread_spin_trylock,@function
+ .align 16
+pthread_spin_trylock:
+ movl 4(%esp), %edx
+ movl $1, %eax
+ xorl %ecx, %ecx
+ LOCK
+ cmpxchgl %ecx, (%edx)
+ movl $EBUSY, %eax
+#ifdef HAVE_CMOV
+ cmovel %ecx, %eax
+#else
+ jne 0f
+ movl %ecx, %eax
+0:
+#endif
+ ret
+ .size pthread_spin_trylock,.-pthread_spin_trylock
diff --git a/libpthread/nptl/sysdeps/i386/i586/pthread_spin_trylock.S b/libpthread/nptl/sysdeps/i386/i586/pthread_spin_trylock.S
new file mode 100644
index 000000000..a91eb75ef
--- /dev/null
+++ b/libpthread/nptl/sysdeps/i386/i586/pthread_spin_trylock.S
@@ -0,0 +1,19 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 "../i486/pthread_spin_trylock.S"
diff --git a/libpthread/nptl/sysdeps/i386/i686/Makefile b/libpthread/nptl/sysdeps/i386/i686/Makefile
new file mode 100644
index 000000000..010372ebd
--- /dev/null
+++ b/libpthread/nptl/sysdeps/i386/i686/Makefile
@@ -0,0 +1,31 @@
+# Copyright (C) 2003 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+# Contributed by Ulrich Drepper <drepper@redhat.com>, 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; see the file COPYING.LIB. If
+# not, see <http://www.gnu.org/licenses/>.
+
+ifeq ($(subdir),nptl)
+# It turns out that stack coloring is in general not good on P4s. Some
+# applications will benefit. We will probably have a configuration option
+# at some point. Enabling coloring can be done with
+#
+# -DCOLORING_INCREMENT=128
+#
+# What is useful is to avoid the 64k aliasing problem which reliably
+# happens if all stacks use sizes which are a multiple of 64k. Tell
+# the stack allocator to disturb this by allocation one more page if
+# necessary.
+CFLAGS-pthread_create.c += -DMULTI_PAGE_ALIASING=65536
+endif
diff --git a/libpthread/nptl/sysdeps/i386/i686/pthread_spin_trylock.S b/libpthread/nptl/sysdeps/i386/i686/pthread_spin_trylock.S
new file mode 100644
index 000000000..ee051ec37
--- /dev/null
+++ b/libpthread/nptl/sysdeps/i386/i686/pthread_spin_trylock.S
@@ -0,0 +1,20 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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/>. */
+
+#define HAVE_CMOV 1
+#include "../i486/pthread_spin_trylock.S"
diff --git a/libpthread/nptl/sysdeps/i386/i686/tls.h b/libpthread/nptl/sysdeps/i386/i686/tls.h
new file mode 100644
index 000000000..e4ce6ede3
--- /dev/null
+++ b/libpthread/nptl/sysdeps/i386/i686/tls.h
@@ -0,0 +1,35 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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/>. */
+
+#ifndef _TLS_H
+
+/* Additional definitions for <tls.h> on i686 and up. */
+
+
+/* Macros to load from and store into segment registers. We can use
+ the 32-bit instructions. */
+#define TLS_GET_GS() \
+ ({ int __seg; __asm__ ("movl %%gs, %0" : "=q" (__seg)); __seg; })
+#define TLS_SET_GS(val) \
+ __asm__ ("movl %0, %%gs" :: "q" (val))
+
+
+/* Get the full set of definitions. */
+#include "../tls.h"
+
+#endif /* tls.h */
diff --git a/libpthread/nptl/sysdeps/i386/jmpbuf-unwind.h b/libpthread/nptl/sysdeps/i386/jmpbuf-unwind.h
new file mode 100644
index 000000000..2f64e7d7c
--- /dev/null
+++ b/libpthread/nptl/sysdeps/i386/jmpbuf-unwind.h
@@ -0,0 +1,27 @@
+/* Copyright (C) 2003, 2004 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/>. */
+
+#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))
diff --git a/libpthread/nptl/sysdeps/i386/pthread_spin_init.c b/libpthread/nptl/sysdeps/i386/pthread_spin_init.c
new file mode 100644
index 000000000..9462f8d17
--- /dev/null
+++ b/libpthread/nptl/sysdeps/i386/pthread_spin_init.c
@@ -0,0 +1,19 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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/>. */
+
+/* Not needed. pthread_spin_init is an alias for pthread_spin_unlock. */
diff --git a/libpthread/nptl/sysdeps/i386/pthread_spin_lock.c b/libpthread/nptl/sysdeps/i386/pthread_spin_lock.c
new file mode 100644
index 000000000..33d3dc654
--- /dev/null
+++ b/libpthread/nptl/sysdeps/i386/pthread_spin_lock.c
@@ -0,0 +1,48 @@
+/* Copyright (C) 2002,2003,2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 "pthreadP.h"
+
+#ifndef LOCK_PREFIX
+# ifdef UP
+# define LOCK_PREFIX /* nothing */
+# else
+# define LOCK_PREFIX "lock;"
+# endif
+#endif
+
+
+int
+pthread_spin_lock (
+ pthread_spinlock_t *lock)
+{
+ __asm__ ("\n"
+ "1:\t" LOCK_PREFIX "decl %0\n\t"
+ "jne 2f\n\t"
+ ".subsection 1\n\t"
+ ".align 16\n"
+ "2:\trep; nop\n\t"
+ "cmpl $0, %0\n\t"
+ "jg 1b\n\t"
+ "jmp 2b\n\t"
+ ".previous"
+ : "=m" (*lock)
+ : "m" (*lock));
+
+ return 0;
+}
diff --git a/libpthread/nptl/sysdeps/i386/pthread_spin_unlock.S b/libpthread/nptl/sysdeps/i386/pthread_spin_unlock.S
new file mode 100644
index 000000000..9f0aabb39
--- /dev/null
+++ b/libpthread/nptl/sysdeps/i386/pthread_spin_unlock.S
@@ -0,0 +1,31 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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/>. */
+
+ .globl pthread_spin_unlock
+ .type pthread_spin_unlock,@function
+ .align 16
+pthread_spin_unlock:
+ movl 4(%esp), %eax
+ movl $1, (%eax)
+ xorl %eax, %eax
+ ret
+ .size pthread_spin_unlock,.-pthread_spin_unlock
+
+ /* The implementation of pthread_spin_init is identical. */
+ .globl pthread_spin_init
+pthread_spin_init = pthread_spin_unlock
diff --git a/libpthread/nptl/sysdeps/i386/pthreaddef.h b/libpthread/nptl/sysdeps/i386/pthreaddef.h
new file mode 100644
index 000000000..a0659039d
--- /dev/null
+++ b/libpthread/nptl/sysdeps/i386/pthreaddef.h
@@ -0,0 +1,47 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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/>. */
+
+/* Default stack size. */
+#define ARCH_STACK_DEFAULT_SIZE (2 * 1024 * 1024)
+
+/* Required stack pointer alignment at beginning. SSE requires 16
+ bytes. */
+#define STACK_ALIGN 16
+
+/* Minimal stack size after allocating thread descriptor and guard size. */
+#define MINIMAL_REST_STACK 2048
+
+/* Alignment requirement for TCB. */
+#define TCB_ALIGNMENT 16
+
+
+/* Location of current stack frame. */
+#define CURRENT_STACK_FRAME __builtin_frame_address (0)
+
+
+/* XXX Until we have a better place keep the definitions here. */
+
+/* While there is no such syscall. */
+#define __exit_thread_inline(val) \
+ while (1) { \
+ if (__builtin_constant_p (val) && (val) == 0) \
+ __asm__ __volatile__ ("xorl %%ebx, %%ebx; int $0x80" :: "a" (__NR_exit)); \
+ else \
+ __asm__ __volatile__ ("movl %1, %%ebx; int $0x80" \
+ :: "a" (__NR_exit), "r" (val)); \
+ }
diff --git a/libpthread/nptl/sysdeps/i386/tcb-offsets.sym b/libpthread/nptl/sysdeps/i386/tcb-offsets.sym
new file mode 100644
index 000000000..69f9deb36
--- /dev/null
+++ b/libpthread/nptl/sysdeps/i386/tcb-offsets.sym
@@ -0,0 +1,17 @@
+#include <sysdep.h>
+#include <tls.h>
+
+RESULT offsetof (struct pthread, result)
+TID offsetof (struct pthread, tid)
+PID offsetof (struct pthread, pid)
+CANCELHANDLING offsetof (struct pthread, cancelhandling)
+CLEANUP_JMP_BUF offsetof (struct pthread, cleanup_jmp_buf)
+MULTIPLE_THREADS_OFFSET offsetof (tcbhead_t, multiple_threads)
+SYSINFO_OFFSET offsetof (tcbhead_t, sysinfo)
+CLEANUP offsetof (struct pthread, cleanup)
+CLEANUP_PREV offsetof (struct _pthread_cleanup_buffer, __prev)
+MUTEX_FUTEX offsetof (pthread_mutex_t, __data.__lock)
+POINTER_GUARD offsetof (tcbhead_t, pointer_guard)
+#ifndef __ASSUME_PRIVATE_FUTEX
+PRIVATE_FUTEX offsetof (tcbhead_t, private_futex)
+#endif
diff --git a/libpthread/nptl/sysdeps/i386/tls.h b/libpthread/nptl/sysdeps/i386/tls.h
new file mode 100644
index 000000000..f283a40f0
--- /dev/null
+++ b/libpthread/nptl/sysdeps/i386/tls.h
@@ -0,0 +1,479 @@
+/* Definition for thread-local data handling. nptl/i386 version.
+ Copyright (C) 2002-2007, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ 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 _TLS_H
+#define _TLS_H 1
+
+#ifndef __ASSEMBLER__
+# include <stdbool.h>
+# include <stddef.h>
+# include <stdint.h>
+# include <stdlib.h>
+# include <list.h>
+# include <sysdep.h>
+# include <bits/kernel-features.h>
+
+
+/* Type for the dtv. */
+typedef union dtv
+{
+ size_t counter;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
+} dtv_t;
+
+
+typedef struct
+{
+ void *tcb; /* Pointer to the TCB. Not necessarily the
+ thread descriptor used by libpthread. */
+ dtv_t *dtv;
+ void *self; /* Pointer to the thread descriptor. */
+ int multiple_threads;
+ uintptr_t sysinfo;
+ uintptr_t stack_guard;
+ uintptr_t pointer_guard;
+ int gscope_flag;
+#ifndef __ASSUME_PRIVATE_FUTEX
+ int private_futex;
+#else
+ int __unused1;
+#endif
+ /* Reservation of some values for the TM ABI. */
+ void *__private_tm[5];
+} tcbhead_t;
+
+# define TLS_MULTIPLE_THREADS_IN_TCB 1
+
+#else /* __ASSEMBLER__ */
+# include <tcb-offsets.h>
+#endif
+
+
+/* We require TLS support in the tools. */
+#define HAVE_TLS_SUPPORT
+#define HAVE___THREAD 1
+#define HAVE_TLS_MODEL_ATTRIBUTE 1
+
+/* Signal that TLS support is available. */
+#define USE_TLS 1
+
+
+/* Alignment requirement for the stack. For IA-32 this is governed by
+ the SSE memory functions. */
+#define STACK_ALIGN 16
+
+#ifndef __ASSEMBLER__
+/* Get system call information. */
+# include <sysdep.h>
+
+/* The old way: using LDT. */
+
+/* Structure passed to `modify_ldt', 'set_thread_area', and 'clone' calls. */
+struct user_desc
+{
+ unsigned int entry_number;
+ unsigned long int base_addr;
+ unsigned int limit;
+ unsigned int seg_32bit:1;
+ unsigned int contents:2;
+ unsigned int read_exec_only:1;
+ unsigned int limit_in_pages:1;
+ unsigned int seg_not_present:1;
+ unsigned int useable:1;
+ unsigned int empty:25;
+};
+
+/* Initializing bit fields is slow. We speed it up by using a union. */
+union user_desc_init
+{
+ struct user_desc desc;
+ unsigned int vals[4];
+};
+
+
+/* Get the thread descriptor definition. */
+# include <descr.h>
+
+/* This is the size of the initial TCB. Can't be just sizeof (tcbhead_t),
+ because NPTL getpid, __libc_alloca_cutoff etc. need (almost) the whole
+ struct pthread even when not linked with -lpthread. */
+# define TLS_INIT_TCB_SIZE sizeof (struct pthread)
+
+/* Alignment requirements for the initial TCB. */
+# define TLS_INIT_TCB_ALIGN __alignof__ (struct pthread)
+
+/* This is the size of the TCB. */
+# define TLS_TCB_SIZE sizeof (struct pthread)
+
+/* Alignment requirements for the TCB. */
+# define TLS_TCB_ALIGN __alignof__ (struct pthread)
+
+/* The TCB can have any size and the memory following the address the
+ thread pointer points to is unspecified. Allocate the TCB there. */
+# define TLS_TCB_AT_TP 1
+
+
+/* Install the dtv pointer. The pointer passed is to the element with
+ index -1 which contain the length. */
+# define INSTALL_DTV(descr, dtvp) \
+ ((tcbhead_t *) (descr))->dtv = (dtvp) + 1
+
+/* Install new dtv for current thread. */
+# define INSTALL_NEW_DTV(dtvp) \
+ ({ struct pthread *__pd; \
+ THREAD_SETMEM (__pd, header.dtv, (dtvp)); })
+
+/* Return dtv of given thread descriptor. */
+# define GET_DTV(descr) \
+ (((tcbhead_t *) (descr))->dtv)
+
+#define THREAD_SELF_SYSINFO THREAD_GETMEM (THREAD_SELF, header.sysinfo)
+#define THREAD_SYSINFO(pd) ((pd)->header.sysinfo)
+
+/* Macros to load from and store into segment registers. */
+# ifndef TLS_GET_GS
+# define TLS_GET_GS() \
+ ({ int __seg; __asm__ ("movw %%gs, %w0" : "=q" (__seg)); __seg & 0xffff; })
+# endif
+# ifndef TLS_SET_GS
+# define TLS_SET_GS(val) \
+ __asm__ ("movw %w0, %%gs" :: "q" (val))
+# endif
+
+
+# ifndef __NR_set_thread_area
+# define __NR_set_thread_area 243
+# endif
+# ifndef TLS_FLAG_WRITABLE
+# define TLS_FLAG_WRITABLE 0x00000001
+# endif
+
+// XXX Enable for the real world.
+#if 0
+# ifndef __ASSUME_SET_THREAD_AREA
+# error "we need set_thread_area"
+# endif
+#endif
+
+# ifdef __PIC__
+# define TLS_EBX_ARG "r"
+# define TLS_LOAD_EBX "xchgl %3, %%ebx\n\t"
+# else
+# define TLS_EBX_ARG "b"
+# define TLS_LOAD_EBX
+# endif
+
+#if defined NEED_DL_SYSINFO
+# define INIT_SYSINFO \
+ _head->sysinfo = GLRO(dl_sysinfo)
+#else
+# define INIT_SYSINFO
+#endif
+
+#ifndef LOCK_PREFIX
+# ifdef UP
+# define LOCK_PREFIX /* nothing */
+# else
+# define LOCK_PREFIX "lock;"
+# endif
+#endif
+
+/* Code to initially initialize the thread pointer. This might need
+ special attention since 'errno' is not yet available and if the
+ operation can cause a failure 'errno' must not be touched. */
+# define TLS_INIT_TP(thrdescr, secondcall) \
+ ({ void *_thrdescr = (thrdescr); \
+ tcbhead_t *_head = _thrdescr; \
+ union user_desc_init _segdescr; \
+ int _result; \
+ \
+ _head->tcb = _thrdescr; \
+ /* For now the thread descriptor is at the same address. */ \
+ _head->self = _thrdescr; \
+ /* New syscall handling support. */ \
+ INIT_SYSINFO; \
+ \
+ /* The 'entry_number' field. Let the kernel pick a value. */ \
+ if (secondcall) \
+ _segdescr.vals[0] = TLS_GET_GS () >> 3; \
+ else \
+ _segdescr.vals[0] = -1; \
+ /* The 'base_addr' field. Pointer to the TCB. */ \
+ _segdescr.vals[1] = (unsigned long int) _thrdescr; \
+ /* The 'limit' field. We use 4GB which is 0xfffff pages. */ \
+ _segdescr.vals[2] = 0xfffff; \
+ /* Collapsed value of the bitfield: \
+ .seg_32bit = 1 \
+ .contents = 0 \
+ .read_exec_only = 0 \
+ .limit_in_pages = 1 \
+ .seg_not_present = 0 \
+ .useable = 1 */ \
+ _segdescr.vals[3] = 0x51; \
+ \
+ /* Install the TLS. */ \
+ __asm__ __volatile__ (TLS_LOAD_EBX \
+ "int $0x80\n\t" \
+ TLS_LOAD_EBX \
+ : "=a" (_result), "=m" (_segdescr.desc.entry_number) \
+ : "0" (__NR_set_thread_area), \
+ TLS_EBX_ARG (&_segdescr.desc), "m" (_segdescr.desc)); \
+ \
+ if (_result == 0) \
+ /* We know the index in the GDT, now load the segment register. \
+ The use of the GDT is described by the value 3 in the lower \
+ three bits of the segment descriptor value. \
+ \
+ Note that we have to do this even if the numeric value of \
+ the descriptor does not change. Loading the segment register \
+ causes the segment information from the GDT to be loaded \
+ which is necessary since we have changed it. */ \
+ TLS_SET_GS (_segdescr.desc.entry_number * 8 + 3); \
+ \
+ _result == 0 ? NULL \
+ : "set_thread_area failed when setting up thread-local storage\n"; })
+
+
+/* Return the address of the dtv for the current thread. */
+# define THREAD_DTV() \
+ ({ struct pthread *__pd; \
+ THREAD_GETMEM (__pd, header.dtv); })
+
+
+/* Return the thread descriptor for the current thread.
+
+ The contained asm must *not* be marked __volatile__ since otherwise
+ assignments like
+ pthread_descr self = thread_self();
+ do not get optimized away. */
+# define THREAD_SELF \
+ ({ struct pthread *__self; \
+ __asm__ ("movl %%gs:%c1,%0" : "=r" (__self) \
+ : "i" (offsetof (struct pthread, header.self))); \
+ __self;})
+
+/* Magic for libthread_db to know how to do THREAD_SELF. */
+# define DB_THREAD_SELF \
+ REGISTER_THREAD_AREA (32, offsetof (struct user_regs_struct, xgs), 3) \
+ REGISTER_THREAD_AREA (64, 26 * 8, 3) /* x86-64's user_regs_struct->gs */
+
+
+/* Read member of the thread descriptor directly. */
+# define THREAD_GETMEM(descr, member) \
+ ({ __typeof (descr->member) __value; \
+ if (sizeof (__value) == 1) \
+ __asm__ __volatile__ ("movb %%gs:%P2,%b0" \
+ : "=q" (__value) \
+ : "0" (0), "i" (offsetof (struct pthread, member))); \
+ else if (sizeof (__value) == 4) \
+ __asm__ __volatile__ ("movl %%gs:%P1,%0" \
+ : "=r" (__value) \
+ : "i" (offsetof (struct pthread, member))); \
+ else \
+ { \
+ if (sizeof (__value) != 8) \
+ /* There should not be any value with a size other than 1, \
+ 4 or 8. */ \
+ abort (); \
+ \
+ __asm__ __volatile__ ("movl %%gs:%P1,%%eax\n\t" \
+ "movl %%gs:%P2,%%edx" \
+ : "=A" (__value) \
+ : "i" (offsetof (struct pthread, member)), \
+ "i" (offsetof (struct pthread, member) + 4)); \
+ } \
+ __value; })
+
+
+/* Same as THREAD_GETMEM, but the member offset can be non-constant. */
+# define THREAD_GETMEM_NC(descr, member, idx) \
+ ({ __typeof (descr->member[0]) __value; \
+ if (sizeof (__value) == 1) \
+ __asm__ __volatile__ ("movb %%gs:%P2(%3),%b0" \
+ : "=q" (__value) \
+ : "0" (0), "i" (offsetof (struct pthread, member[0])), \
+ "r" (idx)); \
+ else if (sizeof (__value) == 4) \
+ __asm__ __volatile__ ("movl %%gs:%P1(,%2,4),%0" \
+ : "=r" (__value) \
+ : "i" (offsetof (struct pthread, member[0])), \
+ "r" (idx)); \
+ else \
+ { \
+ if (sizeof (__value) != 8) \
+ /* There should not be any value with a size other than 1, \
+ 4 or 8. */ \
+ abort (); \
+ \
+ __asm__ __volatile__ ("movl %%gs:%P1(,%2,8),%%eax\n\t" \
+ "movl %%gs:4+%P1(,%2,8),%%edx" \
+ : "=&A" (__value) \
+ : "i" (offsetof (struct pthread, member[0])), \
+ "r" (idx)); \
+ } \
+ __value; })
+
+
+/* Same as THREAD_SETMEM, but the member offset can be non-constant. */
+# define THREAD_SETMEM(descr, member, value) \
+ ({ if (sizeof (descr->member) == 1) \
+ __asm__ __volatile__ ("movb %b0,%%gs:%P1" : \
+ : "iq" (value), \
+ "i" (offsetof (struct pthread, member))); \
+ else if (sizeof (descr->member) == 4) \
+ __asm__ __volatile__ ("movl %0,%%gs:%P1" : \
+ : "ir" (value), \
+ "i" (offsetof (struct pthread, member))); \
+ else \
+ { \
+ if (sizeof (descr->member) != 8) \
+ /* There should not be any value with a size other than 1, \
+ 4 or 8. */ \
+ abort (); \
+ \
+ __asm__ __volatile__ ("movl %%eax,%%gs:%P1\n\t" \
+ "movl %%edx,%%gs:%P2" : \
+ : "A" (value), \
+ "i" (offsetof (struct pthread, member)), \
+ "i" (offsetof (struct pthread, member) + 4)); \
+ }})
+
+
+/* Set member of the thread descriptor directly. */
+# define THREAD_SETMEM_NC(descr, member, idx, value) \
+ ({ if (sizeof (descr->member[0]) == 1) \
+ __asm__ __volatile__ ("movb %b0,%%gs:%P1(%2)" : \
+ : "iq" (value), \
+ "i" (offsetof (struct pthread, member)), \
+ "r" (idx)); \
+ else if (sizeof (descr->member[0]) == 4) \
+ __asm__ __volatile__ ("movl %0,%%gs:%P1(,%2,4)" : \
+ : "ir" (value), \
+ "i" (offsetof (struct pthread, member)), \
+ "r" (idx)); \
+ else \
+ { \
+ if (sizeof (descr->member[0]) != 8) \
+ /* There should not be any value with a size other than 1, \
+ 4 or 8. */ \
+ abort (); \
+ \
+ __asm__ __volatile__ ("movl %%eax,%%gs:%P1(,%2,8)\n\t" \
+ "movl %%edx,%%gs:4+%P1(,%2,8)" : \
+ : "A" (value), \
+ "i" (offsetof (struct pthread, member)), \
+ "r" (idx)); \
+ }})
+
+
+/* Atomic compare and exchange on TLS, returning old value. */
+#define THREAD_ATOMIC_CMPXCHG_VAL(descr, member, newval, oldval) \
+ ({ __typeof (descr->member) __ret; \
+ __typeof (oldval) __old = (oldval); \
+ if (sizeof (descr->member) == 4) \
+ __asm__ __volatile__ (LOCK_PREFIX "cmpxchgl %2, %%gs:%P3" \
+ : "=a" (__ret) \
+ : "0" (__old), "r" (newval), \
+ "i" (offsetof (struct pthread, member))); \
+ else \
+ /* Not necessary for other sizes in the moment. */ \
+ abort (); \
+ __ret; })
+
+
+/* Atomic logical and. */
+#define THREAD_ATOMIC_AND(descr, member, val) \
+ (void) ({ if (sizeof ((descr)->member) == 4) \
+ __asm__ __volatile__ (LOCK_PREFIX "andl %1, %%gs:%P0" \
+ :: "i" (offsetof (struct pthread, member)), \
+ "ir" (val)); \
+ else \
+ /* Not necessary for other sizes in the moment. */ \
+ abort (); })
+
+
+/* Atomic set bit. */
+#define THREAD_ATOMIC_BIT_SET(descr, member, bit) \
+ (void) ({ if (sizeof ((descr)->member) == 4) \
+ __asm__ __volatile__ (LOCK_PREFIX "orl %1, %%gs:%P0" \
+ :: "i" (offsetof (struct pthread, member)), \
+ "ir" (1 << (bit))); \
+ else \
+ /* Not necessary for other sizes in the moment. */ \
+ abort (); })
+
+
+/* Call the user-provided thread function. */
+#define CALL_THREAD_FCT(descr) \
+ ({ void *__res; \
+ int __ignore1, __ignore2; \
+ __asm__ __volatile__ ("pushl %%eax\n\t" \
+ "pushl %%eax\n\t" \
+ "pushl %%eax\n\t" \
+ "pushl %%gs:%P4\n\t" \
+ "call *%%gs:%P3\n\t" \
+ "addl $16, %%esp" \
+ : "=a" (__res), "=c" (__ignore1), "=d" (__ignore2) \
+ : "i" (offsetof (struct pthread, start_routine)), \
+ "i" (offsetof (struct pthread, arg))); \
+ __res; })
+
+
+/* Set the stack guard field in TCB head. */
+#define THREAD_SET_STACK_GUARD(value) \
+ THREAD_SETMEM (THREAD_SELF, header.stack_guard, value)
+#define THREAD_COPY_STACK_GUARD(descr) \
+ ((descr)->header.stack_guard \
+ = THREAD_GETMEM (THREAD_SELF, header.stack_guard))
+
+
+/* Set the pointer guard field in the TCB head. */
+#define THREAD_SET_POINTER_GUARD(value) \
+ THREAD_SETMEM (THREAD_SELF, header.pointer_guard, value)
+#define THREAD_COPY_POINTER_GUARD(descr) \
+ ((descr)->header.pointer_guard \
+ = THREAD_GETMEM (THREAD_SELF, header.pointer_guard))
+
+
+/* Get and set the global scope generation counter in the TCB head. */
+#define THREAD_GSCOPE_FLAG_UNUSED 0
+#define THREAD_GSCOPE_FLAG_USED 1
+#define THREAD_GSCOPE_FLAG_WAIT 2
+#define THREAD_GSCOPE_RESET_FLAG() \
+ do \
+ { int __res; \
+ __asm__ __volatile__ ("xchgl %0, %%gs:%P1" \
+ : "=r" (__res) \
+ : "i" (offsetof (struct pthread, header.gscope_flag)), \
+ "0" (THREAD_GSCOPE_FLAG_UNUSED)); \
+ if (__res == THREAD_GSCOPE_FLAG_WAIT) \
+ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \
+ } \
+ while (0)
+#define THREAD_GSCOPE_SET_FLAG() \
+ THREAD_SETMEM (THREAD_SELF, header.gscope_flag, THREAD_GSCOPE_FLAG_USED)
+#define THREAD_GSCOPE_WAIT() \
+ GL(dl_wait_lookup_done) ()
+
+#endif /* __ASSEMBLER__ */
+
+#endif /* tls.h */
diff --git a/libpthread/nptl/sysdeps/jmpbuf-unwind.h b/libpthread/nptl/sysdeps/jmpbuf-unwind.h
new file mode 100644
index 000000000..2f64e7d7c
--- /dev/null
+++ b/libpthread/nptl/sysdeps/jmpbuf-unwind.h
@@ -0,0 +1,27 @@
+/* Copyright (C) 2003, 2004 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/>. */
+
+#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))
diff --git a/libpthread/nptl/sysdeps/metag/Makefile.arch b/libpthread/nptl/sysdeps/metag/Makefile.arch
new file mode 100644
index 000000000..ed5b52c5e
--- /dev/null
+++ b/libpthread/nptl/sysdeps/metag/Makefile.arch
@@ -0,0 +1,10 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2005 Steven J. Hill <sjhill@uclibc.org>
+#
+# Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+#
+
+ASFLAGS-pthread_spin_lock.c += -D_GNU_SOURCE
+
+libc_arch_a_CSRC := libc-tls.c
diff --git a/libpthread/nptl/sysdeps/metag/dl-tls.h b/libpthread/nptl/sysdeps/metag/dl-tls.h
new file mode 100644
index 000000000..cba8fcb3b
--- /dev/null
+++ b/libpthread/nptl/sysdeps/metag/dl-tls.h
@@ -0,0 +1,29 @@
+/* Thread-local storage handling in the ELF dynamic linker. Meta version.
+ Copyright (C) 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. */
+
+
+/* Type used for the representation of TLS information in the GOT. */
+typedef struct
+{
+ unsigned long int ti_module;
+ unsigned long int ti_offset;
+} tls_index;
+
+
+extern void *__tls_get_addr (tls_index *ti);
diff --git a/libpthread/nptl/sysdeps/metag/jmpbuf-unwind.h b/libpthread/nptl/sysdeps/metag/jmpbuf-unwind.h
new file mode 100644
index 000000000..eedf79427
--- /dev/null
+++ b/libpthread/nptl/sysdeps/metag/jmpbuf-unwind.h
@@ -0,0 +1,36 @@
+/* Copyright (C) 2003, 2004 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <setjmp.h>
+#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[JB_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)[JB_SP] - (_adj))
+
+#define __libc_unwind_longjmp(buf, val) __libc_longjmp (buf, val)
diff --git a/libpthread/nptl/sysdeps/metag/libc-tls.c b/libpthread/nptl/sysdeps/metag/libc-tls.c
new file mode 100644
index 000000000..abc7c58db
--- /dev/null
+++ b/libpthread/nptl/sysdeps/metag/libc-tls.c
@@ -0,0 +1,33 @@
+/*
+ * Thread-local storage handling in statically linked binaries. Meta version.
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * Based on GNU C Library (file: libc/sysdeps/sh/libc-tls.c)
+ *
+ * Copyright (C) 2010 STMicroelectronics Ltd.
+ * Copyright (C) 2013 Imagination Technologies Ltd.
+ *
+ * Author: Filippo Arcidiacono <filippo.arcidiacono@st.com>
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ *
+ */
+
+#include <sysdeps/generic/libc-tls.c>
+#include <dl-tls.h>
+
+#if defined (USE_TLS) && (USE_TLS)
+
+/* On Meta, linker optimizations are not required, so __tls_get_addr
+ can be called even in statically linked binaries. In this case module
+ must be always 1 and PT_TLS segment exist in the binary, otherwise it
+ would not link. */
+
+void *
+__tls_get_addr (tls_index *ti)
+{
+ dtv_t *dtv = THREAD_DTV ();
+ return (char *) dtv[1].pointer.val + ti->ti_offset;
+}
+
+#endif
diff --git a/libpthread/nptl/sysdeps/metag/metag_load_tp.S b/libpthread/nptl/sysdeps/metag/metag_load_tp.S
new file mode 100644
index 000000000..f17f7decd
--- /dev/null
+++ b/libpthread/nptl/sysdeps/metag/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/e1/bits/wordsize.h b/libpthread/nptl/sysdeps/metag/pthread_spin_init.c
index a56d3ef5c..0a47981aa 100644
--- a/libc/sysdeps/linux/e1/bits/wordsize.h
+++ b/libpthread/nptl/sysdeps/metag/pthread_spin_init.c
@@ -1,8 +1,6 @@
-/* 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) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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
@@ -19,4 +17,4 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#define __WORDSIZE 32
+/* Not needed. pthread_spin_init is an alias for pthread_spin_unlock. */
diff --git a/libpthread/nptl/sysdeps/metag/pthread_spin_lock.S b/libpthread/nptl/sysdeps/metag/pthread_spin_lock.S
new file mode 100644
index 000000000..66e94c7a9
--- /dev/null
+++ b/libpthread/nptl/sysdeps/metag/pthread_spin_lock.S
@@ -0,0 +1,20 @@
+! Copyright (C) 2013 Imagination Technologies Ltd.
+
+! Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+
+ .text
+ .global _pthread_spin_lock
+ .type _pthread_spin_lock,function
+_pthread_spin_lock:
+1: LNKGETD D0Ar2, [D1Ar1]
+ CMP D0Ar2, #0
+ ADD D0Ar2, D0Ar2, #1
+ LNKSETDEQ [D1Ar1], D0Ar2
+ BNE 1b
+ DEFR D0Ar2, TXSTAT
+ ANDT D0Ar2, D0Ar2, #HI(0x3f000000)
+ CMPT D0Ar2, #HI(0x02000000)
+ BNZ 1b
+ MOV D0Re0, #0
+ MOV PC, D1RtP
+ .size _pthread_spin_lock,.-_pthread_spin_lock
diff --git a/libpthread/nptl/sysdeps/metag/pthread_spin_trylock.S b/libpthread/nptl/sysdeps/metag/pthread_spin_trylock.S
new file mode 100644
index 000000000..e0b9b5083
--- /dev/null
+++ b/libpthread/nptl/sysdeps/metag/pthread_spin_trylock.S
@@ -0,0 +1,24 @@
+! Copyright (C) 2013 Imagination Technologies Ltd.
+
+! Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+
+#include <pthread-errnos.h>
+
+ .text
+ .global _pthread_spin_trylock
+ .type _pthread_spin_trylock,function
+_pthread_spin_trylock:
+1: MOVT D0Re0, #HI(#EBUSY)
+ ADD D0Re0, D0Re0, #LO(#EBUSY)
+ LNKGETD D0Ar2, [D1Ar1]
+ CMP D0Ar2, #0
+ ADD D0Ar2, D0Ar2, #1
+ LNKSETDEQ [D1Ar1], D0Ar2
+ BNE 2f
+ DEFR D0Ar2, TXSTAT
+ ANDT D0Ar2, D0Ar2, #HI(0x3f000000)
+ CMPT D0Ar2, #HI(0x02000000)
+ BNZ 1b
+ MOV D0Re0, #0
+2: MOV PC, D1RtP
+ .size _pthread_spin_trylock,.-_pthread_spin_trylock
diff --git a/libpthread/nptl/sysdeps/metag/pthread_spin_unlock.S b/libpthread/nptl/sysdeps/metag/pthread_spin_unlock.S
new file mode 100644
index 000000000..9bd95e675
--- /dev/null
+++ b/libpthread/nptl/sysdeps/metag/pthread_spin_unlock.S
@@ -0,0 +1,16 @@
+! Copyright (C) 2013 Imagination Technologies Ltd.
+
+! Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+
+ .text
+ .global _pthread_spin_unlock
+ .type _pthread_spin_unlock,function
+_pthread_spin_unlock:
+ MOV D0Re0, #0
+ SETD [D1Ar1], D0Re0
+ MOV PC, D1RtP
+ .size _pthread_spin_unlock,.-_pthread_spin_unlock
+
+ /* The implementation of pthread_spin_init is identical. */
+ .global _pthread_spin_init
+_pthread_spin_init = _pthread_spin_unlock
diff --git a/libpthread/nptl/sysdeps/metag/pthreaddef.h b/libpthread/nptl/sysdeps/metag/pthreaddef.h
new file mode 100644
index 000000000..51625e4e6
--- /dev/null
+++ b/libpthread/nptl/sysdeps/metag/pthreaddef.h
@@ -0,0 +1,40 @@
+/* Copyright (C) 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. */
+
+#include <sysdep.h>
+
+/* Default stack size. */
+#define ARCH_STACK_DEFAULT_SIZE (2 * 1024 * 1024)
+
+/* Required stack pointer alignment at beginning. */
+#define STACK_ALIGN 8
+
+/* Minimal stack size after allocating thread descriptor and guard size. */
+#define MINIMAL_REST_STACK 2048
+
+/* Alignment requirement for TCB. */
+#define TCB_ALIGNMENT 8
+
+
+/* Location of current stack frame. */
+#define CURRENT_STACK_FRAME __builtin_frame_address (0)
+
+
+/* XXX Until we have a better place keep the definitions here. */
+#define __exit_thread_inline(val) \
+ INLINE_SYSCALL (exit, 1, (val))
diff --git a/libpthread/nptl/sysdeps/metag/tcb-offsets.sym b/libpthread/nptl/sysdeps/metag/tcb-offsets.sym
new file mode 100644
index 000000000..753b72b2d
--- /dev/null
+++ b/libpthread/nptl/sysdeps/metag/tcb-offsets.sym
@@ -0,0 +1,15 @@
+#include <sysdep.h>
+#include <tls.h>
+
+RESULT offsetof (struct pthread, result)
+TID offsetof (struct pthread, tid)
+PID offsetof (struct pthread, pid)
+CANCELHANDLING offsetof (struct pthread, cancelhandling)
+CLEANUP_JMP_BUF offsetof (struct pthread, cleanup_jmp_buf)
+MULTIPLE_THREADS_OFFSET offsetof (struct pthread, header.multiple_threads)
+TLS_PRE_TCB_SIZE sizeof (struct pthread)
+MUTEX_FUTEX offsetof (pthread_mutex_t, __data.__lock)
+POINTER_GUARD offsetof (tcbhead_t, pointer_guard)
+#ifndef __ASSUME_PRIVATE_FUTEX
+PRIVATE_FUTEX offsetof (struct pthread, header.private_futex)
+#endif
diff --git a/libpthread/nptl/sysdeps/metag/tls.h b/libpthread/nptl/sysdeps/metag/tls.h
new file mode 100644
index 000000000..07702beca
--- /dev/null
+++ b/libpthread/nptl/sysdeps/metag/tls.h
@@ -0,0 +1,163 @@
+/* Definition for thread-local data handling. NPTL/Meta version.
+ Copyright (C) 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _TLS_H
+#define _TLS_H
+
+#ifndef __ASSEMBLER__
+# include <stdbool.h>
+# include <stddef.h>
+# include <stdint.h>
+# include <stdlib.h>
+# include <list.h>
+# include <sysdep.h>
+# include <bits/kernel-features.h>
+
+/* Type for the dtv. */
+typedef union dtv
+{
+ size_t counter;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
+} dtv_t;
+
+typedef struct
+{
+ dtv_t *dtv;
+ uintptr_t pointer_guard;
+} tcbhead_t;
+
+# define TLS_MULTIPLE_THREADS_IN_TCB 1
+
+#else /* __ASSEMBLER__ */
+# include <tcb-offsets.h>
+#endif /* __ASSEMBLER__ */
+
+
+/* We require TLS support in the tools. */
+#define HAVE_TLS_SUPPORT
+#define HAVE___THREAD 1
+#define HAVE_TLS_MODEL_ATTRIBUTE 1
+/* Signal that TLS support is available. */
+# define USE_TLS 1
+
+#ifndef __ASSEMBLER__
+
+/* Get system call information. */
+# include <sysdep.h>
+
+/* This is the size of the initial TCB. */
+# define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
+
+/* Alignment requirements for the initial TCB. */
+# define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
+
+/* This is the size of the TCB. */
+# define TLS_TCB_SIZE sizeof (tcbhead_t)
+
+/* This is the size we need before TCB. */
+# define TLS_PRE_TCB_SIZE sizeof (struct pthread)
+
+/* Alignment requirements for the TCB. */
+# define TLS_TCB_ALIGN __alignof__ (struct pthread)
+
+/* The TLS blocks start right after the TCB. */
+# define TLS_DTV_AT_TP 1
+
+/* Get the thread descriptor definition. */
+# include <descr.h>
+
+/* Install the dtv pointer. The pointer passed is to the element with
+ index -1 which contain the length. */
+# define INSTALL_DTV(tcbp, dtvp) \
+ ((tcbhead_t *) (tcbp))->dtv = (dtvp) + 1
+
+/* Install new dtv for current thread. */
+# define INSTALL_NEW_DTV(dtv) \
+ (((tcbhead_t *)__builtin_thread_pointer ())->dtv = (dtv))
+
+/* Return dtv of given thread descriptor. */
+# define GET_DTV(tcbp) \
+ (((tcbhead_t *) (tcbp))->dtv)
+
+/* Code to initially initialize the thread pointer. This might need
+ special attention since 'errno' is not yet available and if the
+ operation can cause a failure 'errno' must not be touched. */
+# define TLS_INIT_TP(tcbp, secondcall) \
+ ({ INTERNAL_SYSCALL_DECL (err); \
+ long result_var; \
+ result_var = INTERNAL_SYSCALL (metag_set_tls, err, 1, (tcbp)); \
+ INTERNAL_SYSCALL_ERROR_P (result_var, err) \
+ ? "unknown error" : NULL; })
+
+/* Return the address of the dtv for the current thread. */
+# define THREAD_DTV() \
+ (((tcbhead_t *)__builtin_thread_pointer ())->dtv)
+
+/* Return the thread descriptor for the current thread.
+ The contained asm must *not* be marked volatile since otherwise
+ assignments like
+ struct pthread *self = thread_self();
+ do not get optimized away. */
+# define THREAD_SELF \
+ ((struct pthread *)__builtin_thread_pointer () - 1)
+
+/* Magic for libthread_db to know how to do THREAD_SELF. */
+# define DB_THREAD_SELF \
+ CONST_THREAD_AREA (32, sizeof (struct pthread))
+
+/* Access to data in the thread descriptor is easy. */
+#define THREAD_GETMEM(descr, member) \
+ descr->member
+#define THREAD_GETMEM_NC(descr, member, idx) \
+ descr->member[idx]
+#define THREAD_SETMEM(descr, member, value) \
+ descr->member = (value)
+#define THREAD_SETMEM_NC(descr, member, idx, value) \
+ descr->member[idx] = (value)
+
+/* Get and set the global scope generation counter in struct pthread. */
+#define THREAD_GSCOPE_FLAG_UNUSED 0
+#define THREAD_GSCOPE_FLAG_USED 1
+#define THREAD_GSCOPE_FLAG_WAIT 2
+#define THREAD_GSCOPE_RESET_FLAG() \
+ do \
+ { int __res \
+ = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \
+ THREAD_GSCOPE_FLAG_UNUSED); \
+ if (__res == THREAD_GSCOPE_FLAG_WAIT) \
+ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \
+ } \
+ while (0)
+#define THREAD_GSCOPE_SET_FLAG() \
+ do \
+ { \
+ THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED; \
+ atomic_write_barrier (); \
+ } \
+ while (0)
+#define THREAD_GSCOPE_WAIT() \
+ GL(dl_wait_lookup_done) ()
+
+#endif /* __ASSEMBLER__ */
+
+#endif /* tls.h */
diff --git a/libpthread/nptl/sysdeps/mips/Makefile b/libpthread/nptl/sysdeps/mips/Makefile
new file mode 100644
index 000000000..6371d2871
--- /dev/null
+++ b/libpthread/nptl/sysdeps/mips/Makefile
@@ -0,0 +1,13 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2005 Steven J. Hill <sjhill@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+top_srcdir=../../../../
+top_builddir=../../../../
+all: objs
+include $(top_builddir)Rules.mak
+include Makefile.arch
+include $(top_srcdir)Makerules
diff --git a/libpthread/nptl/sysdeps/mips/Makefile.arch b/libpthread/nptl/sysdeps/mips/Makefile.arch
new file mode 100644
index 000000000..10f8abf3b
--- /dev/null
+++ b/libpthread/nptl/sysdeps/mips/Makefile.arch
@@ -0,0 +1,11 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2005 Steven J. Hill <sjhill@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+ASFLAGS-nptl-sysdep.S = -I$(top_srcdir)libc/sysdeps/linux/mips
+
+libc_arch_a_CSRC = libc-tls.c
+
diff --git a/libpthread/nptl/sysdeps/mips/dl-tls.h b/libpthread/nptl/sysdeps/mips/dl-tls.h
new file mode 100644
index 000000000..e26aa388b
--- /dev/null
+++ b/libpthread/nptl/sysdeps/mips/dl-tls.h
@@ -0,0 +1,45 @@
+/* Thread-local storage handling in the ELF dynamic linker. MIPS version.
+ 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/>. */
+
+
+/* Type used for the representation of TLS information in the GOT. */
+typedef struct
+{
+ unsigned long int ti_module;
+ unsigned long int ti_offset;
+} tls_index;
+
+/* The thread pointer points 0x7000 past the first static TLS block. */
+#define TLS_TP_OFFSET 0x7000
+
+/* Dynamic thread vector pointers point 0x8000 past the start of each
+ TLS block. */
+#define TLS_DTV_OFFSET 0x8000
+
+/* Compute the value for a GOTTPREL reloc. */
+#define TLS_TPREL_VALUE(sym_map, sym_val) \
+ ((sym_map)->l_tls_offset + sym_val - TLS_TP_OFFSET)
+
+/* Compute the value for a DTPREL reloc. */
+#define TLS_DTPREL_VALUE(sym_val) \
+ (sym_val - TLS_DTV_OFFSET)
+
+extern void *__tls_get_addr (tls_index *ti);
+
+# define GET_ADDR_OFFSET (ti->ti_offset + TLS_DTV_OFFSET)
+# define __TLS_GET_ADDR(__ti) (__tls_get_addr (__ti) - TLS_DTV_OFFSET)
diff --git a/libpthread/nptl/sysdeps/mips/jmpbuf-unwind.h b/libpthread/nptl/sysdeps/mips/jmpbuf-unwind.h
new file mode 100644
index 000000000..9739efd28
--- /dev/null
+++ b/libpthread/nptl/sysdeps/mips/jmpbuf-unwind.h
@@ -0,0 +1,26 @@
+/* Copyright (C) 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#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)[0].__sp - (_adj))
diff --git a/libpthread/nptl/sysdeps/mips/libc-tls.c b/libpthread/nptl/sysdeps/mips/libc-tls.c
new file mode 100644
index 000000000..d6ac875ce
--- /dev/null
+++ b/libpthread/nptl/sysdeps/mips/libc-tls.c
@@ -0,0 +1,36 @@
+/* Thread-local storage handling in the ELF dynamic linker. MIPS version.
+ 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/>. */
+
+#include <sysdeps/generic/libc-tls.c>
+#include <dl-tls.h>
+
+#if USE_TLS
+
+/* On MIPS, linker optimizations are not required, so __tls_get_addr
+ can be called even in statically linked binaries. In this case module
+ must be always 1 and PT_TLS segment exist in the binary, otherwise it
+ would not link. */
+
+void *
+__tls_get_addr (tls_index *ti)
+{
+ dtv_t *dtv = THREAD_DTV ();
+ return (char *) dtv[1].pointer.val + GET_ADDR_OFFSET;
+}
+
+#endif
diff --git a/libpthread/nptl/sysdeps/mips/nptl-sysdep.S b/libpthread/nptl/sysdeps/mips/nptl-sysdep.S
new file mode 100644
index 000000000..7a4a8d311
--- /dev/null
+++ b/libpthread/nptl/sysdeps/mips/nptl-sysdep.S
@@ -0,0 +1,2 @@
+/* Pull in __syscall_error. */
+#include <syscall_error.S>
diff --git a/libpthread/nptl/sysdeps/mips/pthread_spin_lock.S b/libpthread/nptl/sysdeps/mips/pthread_spin_lock.S
new file mode 100644
index 000000000..01c559c00
--- /dev/null
+++ b/libpthread/nptl/sysdeps/mips/pthread_spin_lock.S
@@ -0,0 +1,37 @@
+/* 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/>. */
+
+#include <sys/asm.h>
+#include <sysdep.h>
+#include <sgidefs.h>
+
+ENTRY (pthread_spin_lock)
+ .set push
+#if _MIPS_SIM == _ABIO32
+ .set mips2
+#endif
+1: ll a2, 0(a0)
+ li a1, 1
+ bnez a2, 1b
+ sc a1, 0(a0)
+ beqz a1, 1b
+ MIPS_SYNC
+ .set pop
+ li v0, 0
+ j ra
+ nop
+END (pthread_spin_lock)
diff --git a/libpthread/nptl/sysdeps/mips/pthread_spin_trylock.S b/libpthread/nptl/sysdeps/mips/pthread_spin_trylock.S
new file mode 100644
index 000000000..2c875457c
--- /dev/null
+++ b/libpthread/nptl/sysdeps/mips/pthread_spin_trylock.S
@@ -0,0 +1,42 @@
+/* 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/>. */
+
+#include <sys/asm.h>
+#include <sysdep.h>
+#define _ERRNO_H 1
+#include <bits/errno.h>
+#include <sgidefs.h>
+
+ENTRY (pthread_spin_trylock)
+ .set push
+#if _MIPS_SIM == _ABIO32
+ .set mips2
+#endif
+ ll a2, 0(a0)
+ li a1, 1
+ bnez a2, 1f
+ sc a1, 0(a0)
+ beqz a1, 1f
+ MIPS_SYNC
+ .set pop
+ li v0, 0
+ j ra
+ nop
+1: li v0, EBUSY
+ j ra
+ nop
+END (pthread_spin_trylock)
diff --git a/libpthread/nptl/sysdeps/mips/pthreaddef.h b/libpthread/nptl/sysdeps/mips/pthreaddef.h
new file mode 100644
index 000000000..692988205
--- /dev/null
+++ b/libpthread/nptl/sysdeps/mips/pthreaddef.h
@@ -0,0 +1,38 @@
+/* Copyright (C) 2002, 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, see
+ <http://www.gnu.org/licenses/>. */
+
+/* Default stack size. */
+#define ARCH_STACK_DEFAULT_SIZE (2 * 1024 * 1024)
+
+/* Required stack pointer alignment at beginning. */
+#define STACK_ALIGN 16
+
+/* Minimal stack size after allocating thread descriptor and guard size. */
+#define MINIMAL_REST_STACK 2048
+
+/* Alignment requirement for TCB. */
+#define TCB_ALIGNMENT 16
+
+
+/* Location of current stack frame. */
+#define CURRENT_STACK_FRAME __builtin_frame_address (0)
+
+
+/* XXX Until we have a better place keep the definitions here. */
+
+#define __exit_thread_inline(val) \
+ INLINE_SYSCALL (exit, 1, (val))
diff --git a/libpthread/nptl/sysdeps/mips/regdef.h b/libpthread/nptl/sysdeps/mips/regdef.h
new file mode 100644
index 000000000..e4ebd9ad1
--- /dev/null
+++ b/libpthread/nptl/sysdeps/mips/regdef.h
@@ -0,0 +1,25 @@
+/* Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ralf Baechle <ralf@gnu.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 _REGDEF_H
+#define _REGDEF_H
+
+#include <sys/regdef.h>
+#include <sys/fpregdef.h>
+
+#endif /* _REGDEF_H */
diff --git a/libpthread/nptl/sysdeps/mips/tcb-offsets.sym b/libpthread/nptl/sysdeps/mips/tcb-offsets.sym
new file mode 100644
index 000000000..e0e71dc43
--- /dev/null
+++ b/libpthread/nptl/sysdeps/mips/tcb-offsets.sym
@@ -0,0 +1,11 @@
+#include <sysdep.h>
+#include <tls.h>
+
+--
+
+-- Abuse tls.h macros to derive offsets relative to the thread register.
+#define thread_offsetof(mem) (long)(offsetof(struct pthread, mem) - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE)
+
+MULTIPLE_THREADS_OFFSET thread_offsetof (header.multiple_threads)
+PID_OFFSET thread_offsetof (pid)
+TID_OFFSET thread_offsetof (tid)
diff --git a/libpthread/nptl/sysdeps/mips/tls.h b/libpthread/nptl/sysdeps/mips/tls.h
new file mode 100644
index 000000000..09baf1292
--- /dev/null
+++ b/libpthread/nptl/sysdeps/mips/tls.h
@@ -0,0 +1,180 @@
+/* Definition for thread-local data handling. NPTL/MIPS version.
+ Copyright (C) 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 _TLS_H
+#define _TLS_H 1
+
+#ifndef __ASSEMBLER__
+# include <stdbool.h>
+# include <stddef.h>
+# include <stdint.h>
+
+/* Type for the dtv. */
+typedef union dtv
+{
+ size_t counter;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
+} dtv_t;
+
+/* Note: rd must be $v1 to be ABI-conformant. */
+# define READ_THREAD_POINTER() \
+ ({ void *__result; \
+ __asm__ __volatile__ (".set\tpush\n\t.set\tmips32r2\n\t" \
+ "rdhwr\t%0, $29\n\t.set\tpop" : "=v" (__result)); \
+ __result; })
+
+#else /* __ASSEMBLER__ */
+# include <tcb-offsets.h>
+
+# define READ_THREAD_POINTER(rd) \
+ .set push; \
+ .set mips32r2; \
+ rdhwr rd, $29; \
+ .set pop
+#endif /* __ASSEMBLER__ */
+
+
+/* We require TLS support in the tools. */
+#define HAVE_TLS_SUPPORT 1
+#define HAVE_TLS_MODEL_ATTRIBUTE 1
+#define HAVE___THREAD 1
+
+/* Signal that TLS support is available. */
+#define USE_TLS 1
+
+#ifndef __ASSEMBLER__
+
+/* Get system call information. */
+# include <sysdep.h>
+
+/* The TP points to the start of the thread blocks. */
+# define TLS_DTV_AT_TP 1
+
+/* Get the thread descriptor definition. */
+#include <../../descr.h>
+
+typedef struct
+{
+ dtv_t *dtv;
+ void *private;
+} tcbhead_t;
+
+/* This is the size of the initial TCB. Because our TCB is before the thread
+ pointer, we don't need this. */
+# define TLS_INIT_TCB_SIZE 0
+
+/* Alignment requirements for the initial TCB. */
+# define TLS_INIT_TCB_ALIGN __alignof__ (struct pthread)
+
+/* This is the size of the TCB. Because our TCB is before the thread
+ pointer, we don't need this. */
+# define TLS_TCB_SIZE 0
+
+/* Alignment requirements for the TCB. */
+# define TLS_TCB_ALIGN __alignof__ (struct pthread)
+
+/* This is the size we need before TCB - actually, it includes the TCB. */
+# define TLS_PRE_TCB_SIZE \
+ (sizeof (struct pthread) \
+ + ((sizeof (tcbhead_t) + TLS_TCB_ALIGN - 1) & ~(TLS_TCB_ALIGN - 1)))
+
+/* The thread pointer (in hardware register $29) points to the end of
+ the TCB + 0x7000, as for PowerPC. The pthread_descr structure is
+ immediately in front of the TCB. */
+# define TLS_TCB_OFFSET 0x7000
+
+/* Install the dtv pointer. The pointer passed is to the element with
+ index -1 which contain the length. */
+# define INSTALL_DTV(tcbp, dtvp) \
+ (((tcbhead_t *) (tcbp))[-1].dtv = (dtvp) + 1)
+
+/* Install new dtv for current thread. */
+# define INSTALL_NEW_DTV(dtv) \
+ (THREAD_DTV() = (dtv))
+
+/* Return dtv of given thread descriptor. */
+# define GET_DTV(tcbp) \
+ (((tcbhead_t *) (tcbp))[-1].dtv)
+
+/* Code to initially initialize the thread pointer. This might need
+ special attention since 'errno' is not yet available and if the
+ operation can cause a failure 'errno' must not be touched. */
+# define TLS_INIT_TP(tcbp, secondcall) \
+ ({ INTERNAL_SYSCALL_DECL (err); \
+ long result_var attribute_unused; \
+ result_var = INTERNAL_SYSCALL (set_thread_area, err, 1, \
+ (char *) (tcbp) + TLS_TCB_OFFSET); \
+ INTERNAL_SYSCALL_ERROR_P (result_var, err) \
+ ? "unknown error" : NULL; })
+
+/* Return the address of the dtv for the current thread. */
+# define THREAD_DTV() \
+ (((tcbhead_t *) (READ_THREAD_POINTER () - TLS_TCB_OFFSET))[-1].dtv)
+
+/* Return the thread descriptor for the current thread. */
+# define THREAD_SELF \
+ ((struct pthread *) (READ_THREAD_POINTER () \
+ - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE))
+
+/* Magic for libthread_db to know how to do THREAD_SELF. */
+# define DB_THREAD_SELF \
+ CONST_THREAD_AREA (32, TLS_TCB_OFFSET + TLS_PRE_TCB_SIZE)
+
+/* Access to data in the thread descriptor is easy. */
+# define THREAD_GETMEM(descr, member) \
+ descr->member
+# define THREAD_GETMEM_NC(descr, member, idx) \
+ descr->member[idx]
+# define THREAD_SETMEM(descr, member, value) \
+ descr->member = (value)
+# define THREAD_SETMEM_NC(descr, member, idx, value) \
+ descr->member[idx] = (value)
+
+/* l_tls_offset == 0 is perfectly valid on MIPS, so we have to use some
+ different value to mean unset l_tls_offset. */
+# define NO_TLS_OFFSET -1
+/* Get and set the global scope generation counter in struct pthread. */
+#define THREAD_GSCOPE_FLAG_UNUSED 0
+#define THREAD_GSCOPE_FLAG_USED 1
+#define THREAD_GSCOPE_FLAG_WAIT 2
+#define THREAD_GSCOPE_RESET_FLAG() \
+ do \
+ { int __res \
+ = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \
+ THREAD_GSCOPE_FLAG_UNUSED); \
+ if (__res == THREAD_GSCOPE_FLAG_WAIT) \
+ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \
+ } \
+ while (0)
+#define THREAD_GSCOPE_SET_FLAG() \
+ do \
+ { \
+ THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED; \
+ atomic_write_barrier (); \
+ } \
+ while (0)
+#define THREAD_GSCOPE_WAIT() \
+ GL(dl_wait_lookup_done) ()
+
+#endif /* __ASSEMBLER__ */
+
+#endif /* tls.h */
diff --git a/libpthread/nptl/sysdeps/powerpc/Makefile.arch b/libpthread/nptl/sysdeps/powerpc/Makefile.arch
new file mode 100644
index 000000000..18ddc28e7
--- /dev/null
+++ b/libpthread/nptl/sysdeps/powerpc/Makefile.arch
@@ -0,0 +1,7 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2009 Bernhard Reutner-Fischer <uclibc@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
diff --git a/libpthread/nptl/sysdeps/powerpc/dl-tls.h b/libpthread/nptl/sysdeps/powerpc/dl-tls.h
new file mode 100644
index 000000000..c322ade60
--- /dev/null
+++ b/libpthread/nptl/sysdeps/powerpc/dl-tls.h
@@ -0,0 +1,48 @@
+/* Thread-local storage handling in the ELF dynamic linker. PowerPC version.
+ Copyright (C) 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/>. */
+
+
+/* Type used for the representation of TLS information in the TOC. */
+typedef struct
+{
+ unsigned long int ti_module;
+ unsigned long int ti_offset;
+} tls_index;
+
+/* The thread pointer points 0x7000 past the first static TLS block. */
+#define TLS_TP_OFFSET 0x7000
+
+/* Dynamic thread vector pointers point 0x8000 past the start of each
+ TLS block. */
+#define TLS_DTV_OFFSET 0x8000
+
+/* Compute the value for a @tprel reloc. */
+#define TLS_TPREL_VALUE(sym_map, sym, reloc) \
+ ((sym_map)->l_tls_offset + (sym)->st_value + (reloc)->r_addend \
+ - TLS_TP_OFFSET)
+
+/* Compute the value for a @dtprel reloc. */
+#define TLS_DTPREL_VALUE(sym, reloc) \
+ ((sym)->st_value + (reloc)->r_addend - TLS_DTV_OFFSET)
+
+#ifdef SHARED
+extern void *__tls_get_addr (tls_index *ti);
+
+# define GET_ADDR_OFFSET (ti->ti_offset + TLS_DTV_OFFSET)
+# define __TLS_GET_ADDR(__ti) (__tls_get_addr (__ti) - TLS_DTV_OFFSET)
+#endif
diff --git a/libpthread/nptl/sysdeps/powerpc/jmpbuf-unwind.h b/libpthread/nptl/sysdeps/powerpc/jmpbuf-unwind.h
new file mode 100644
index 000000000..4a88b04a9
--- /dev/null
+++ b/libpthread/nptl/sysdeps/powerpc/jmpbuf-unwind.h
@@ -0,0 +1,27 @@
+/* Copyright (C) 2003, 2004 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/>. */
+
+#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_GPR1] - (_adj))
diff --git a/libpthread/nptl/sysdeps/powerpc/pthread_spin_lock.c b/libpthread/nptl/sysdeps/powerpc/pthread_spin_lock.c
new file mode 100644
index 000000000..c678ed54f
--- /dev/null
+++ b/libpthread/nptl/sysdeps/powerpc/pthread_spin_lock.c
@@ -0,0 +1,43 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Paul Mackerras <paulus@au.ibm.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 "pthreadP.h"
+
+int
+pthread_spin_lock (pthread_spinlock_t *lock)
+{
+ unsigned int __tmp;
+
+ __asm__ __volatile__ (
+ "1: lwarx %0,0,%1\n"
+ " cmpwi 0,%0,0\n"
+ " bne- 2f\n"
+ " stwcx. %2,0,%1\n"
+ " bne- 2f\n"
+ " isync\n"
+ " .subsection 1\n"
+ "2: lwzx %0,0,%1\n"
+ " cmpwi 0,%0,0\n"
+ " bne 2b\n"
+ " b 1b\n"
+ " .previous"
+ : "=&r" (__tmp)
+ : "r" (lock), "r" (1)
+ : "cr0", "memory");
+ return 0;
+}
diff --git a/libpthread/nptl/sysdeps/powerpc/pthread_spin_trylock.c b/libpthread/nptl/sysdeps/powerpc/pthread_spin_trylock.c
new file mode 100644
index 000000000..7d6c29e24
--- /dev/null
+++ b/libpthread/nptl/sysdeps/powerpc/pthread_spin_trylock.c
@@ -0,0 +1,41 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Paul Mackerras <paulus@au.ibm.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 <errno.h>
+#include "pthreadP.h"
+
+int
+pthread_spin_trylock (pthread_spinlock_t *lock)
+{
+ unsigned int old;
+ int err = EBUSY;
+
+ __asm__ ("1: lwarx %0,0,%2\n"
+ " cmpwi 0,%0,0\n"
+ " bne 2f\n"
+ " stwcx. %3,0,%2\n"
+ " bne- 1b\n"
+ " li %1,0\n"
+ " isync\n"
+ "2: "
+ : "=&r" (old), "=&r" (err)
+ : "r" (lock), "r" (1), "1" (err)
+ : "cr0", "memory");
+
+ return err;
+}
diff --git a/libpthread/nptl/sysdeps/powerpc/pthreaddef.h b/libpthread/nptl/sysdeps/powerpc/pthreaddef.h
new file mode 100644
index 000000000..36bf76404
--- /dev/null
+++ b/libpthread/nptl/sysdeps/powerpc/pthreaddef.h
@@ -0,0 +1,40 @@
+/* Copyright (C) 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/>. */
+
+/* Default stack size. */
+#define ARCH_STACK_DEFAULT_SIZE (4 * 1024 * 1024)
+
+/* Required stack pointer alignment at beginning. The ABI requires 16
+ bytes (for both 32-bit and 64-bit PowerPC). */
+#define STACK_ALIGN 16
+
+/* Minimal stack size after allocating thread descriptor and guard size. */
+#define MINIMAL_REST_STACK 4096
+
+/* Alignment requirement for TCB. */
+#define TCB_ALIGNMENT 16
+
+
+/* Location of current stack frame. */
+#define CURRENT_STACK_FRAME __builtin_frame_address (0)
+
+
+/* XXX Until we have a better place keep the definitions here. */
+
+/* While there is no such syscall. */
+#define __exit_thread_inline(val) \
+ INLINE_SYSCALL (exit, 1, (val))
diff --git a/libpthread/nptl/sysdeps/powerpc/tcb-offsets.sym b/libpthread/nptl/sysdeps/powerpc/tcb-offsets.sym
new file mode 100644
index 000000000..8ac133dfd
--- /dev/null
+++ b/libpthread/nptl/sysdeps/powerpc/tcb-offsets.sym
@@ -0,0 +1,20 @@
+#include <sysdep.h>
+#include <tls.h>
+
+--
+
+-- Abuse tls.h macros to derive offsets relative to the thread register.
+# undef __thread_register
+# define __thread_register ((void *) 0)
+# define thread_offsetof(mem) ((ptrdiff_t) THREAD_SELF + offsetof (struct pthread, mem))
+
+
+#if TLS_MULTIPLE_THREADS_IN_TCB
+MULTIPLE_THREADS_OFFSET thread_offsetof (header.multiple_threads)
+#endif
+PID thread_offsetof (pid)
+TID thread_offsetof (tid)
+POINTER_GUARD (offsetof (tcbhead_t, pointer_guard) - TLS_TCB_OFFSET - sizeof (tcbhead_t))
+#ifndef __ASSUME_PRIVATE_FUTEX
+PRIVATE_FUTEX_OFFSET thread_offsetof (header.private_futex)
+#endif
diff --git a/libpthread/nptl/sysdeps/powerpc/tls.h b/libpthread/nptl/sysdeps/powerpc/tls.h
new file mode 100644
index 000000000..12bcaeecd
--- /dev/null
+++ b/libpthread/nptl/sysdeps/powerpc/tls.h
@@ -0,0 +1,215 @@
+/* Definition for thread-local data handling. NPTL/PowerPC version.
+ Copyright (C) 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _TLS_H
+#define _TLS_H 1
+
+#ifndef __ASSEMBLER__
+# include <stdbool.h>
+# include <stddef.h>
+# include <stdint.h>
+
+/* Type for the dtv. */
+typedef union dtv
+{
+ size_t counter;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
+} dtv_t;
+
+#else /* __ASSEMBLER__ */
+# include <tcb-offsets.h>
+#endif /* __ASSEMBLER__ */
+
+/* We require TLS support in the tools. */
+#define HAVE_TLS_SUPPORT 1
+#define HAVE_TLS_MODEL_ATTRIBUTE 1
+#define HAVE___THREAD 1
+
+/* Signal that TLS support is available. */
+#define USE_TLS 1
+
+/* We require TLS support in the tools. */
+#ifndef HAVE_TLS_SUPPORT
+# error "TLS support is required."
+#endif
+
+/* Signal that TLS support is available. */
+# define USE_TLS 1
+
+#ifndef __ASSEMBLER__
+
+/* Get system call information. */
+# include <sysdep.h>
+
+/* The TP points to the start of the thread blocks. */
+# define TLS_DTV_AT_TP 1
+
+/* We use the multiple_threads field in the pthread struct */
+#define TLS_MULTIPLE_THREADS_IN_TCB 1
+
+/* Get the thread descriptor definition. */
+# include <../../descr.h>
+
+/* The stack_guard is accessed directly by GCC -fstack-protector code,
+ so it is a part of public ABI. The dtv and pointer_guard fields
+ are private. */
+typedef struct
+{
+ uintptr_t pointer_guard;
+ uintptr_t stack_guard;
+ dtv_t *dtv;
+} tcbhead_t;
+
+/* This is the size of the initial TCB. */
+# define TLS_INIT_TCB_SIZE 0
+
+/* Alignment requirements for the initial TCB. */
+# define TLS_INIT_TCB_ALIGN __alignof__ (struct pthread)
+
+/* This is the size of the TCB. */
+# define TLS_TCB_SIZE 0
+
+/* Alignment requirements for the TCB. */
+# define TLS_TCB_ALIGN __alignof__ (struct pthread)
+
+/* This is the size we need before TCB. */
+# define TLS_PRE_TCB_SIZE \
+ (sizeof (struct pthread) \
+ + ((sizeof (tcbhead_t) + TLS_TCB_ALIGN - 1) & ~(TLS_TCB_ALIGN - 1)))
+
+# ifndef __powerpc64__
+/* Register r2 (tp) is reserved by the ABI as "thread pointer". */
+register void *__thread_register __asm__ ("r2");
+# define PT_THREAD_POINTER PT_R2
+# else
+/* Register r13 (tp) is reserved by the ABI as "thread pointer". */
+register void *__thread_register __asm__ ("r13");
+# define PT_THREAD_POINTER PT_R13
+# endif
+
+/* The following assumes that TP (R2 or R13) points to the end of the
+ TCB + 0x7000 (per the ABI). This implies that TCB address is
+ TP - 0x7000. As we define TLS_DTV_AT_TP we can
+ assume that the pthread struct is allocated immediately ahead of the
+ TCB. This implies that the pthread_descr address is
+ TP - (TLS_PRE_TCB_SIZE + 0x7000). */
+# define TLS_TCB_OFFSET 0x7000
+
+/* Install the dtv pointer. The pointer passed is to the element with
+ index -1 which contain the length. */
+# define INSTALL_DTV(tcbp, dtvp) \
+ ((tcbhead_t *) (tcbp))[-1].dtv = dtvp + 1
+
+/* Install new dtv for current thread. */
+# define INSTALL_NEW_DTV(dtv) (THREAD_DTV() = (dtv))
+
+/* Return dtv of given thread descriptor. */
+# define GET_DTV(tcbp) (((tcbhead_t *) (tcbp))[-1].dtv)
+
+/* Code to initially initialize the thread pointer. This might need
+ special attention since 'errno' is not yet available and if the
+ operation can cause a failure 'errno' must not be touched. */
+# define TLS_INIT_TP(tcbp, secondcall) \
+ (__thread_register = (void *) (tcbp) + TLS_TCB_OFFSET, NULL)
+
+/* Return the address of the dtv for the current thread. */
+# define THREAD_DTV() \
+ (((tcbhead_t *) (__thread_register - TLS_TCB_OFFSET))[-1].dtv)
+
+/* Return the thread descriptor for the current thread. */
+# define THREAD_SELF \
+ ((struct pthread *) (__thread_register \
+ - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE))
+
+/* Magic for libthread_db to know how to do THREAD_SELF. */
+# define DB_THREAD_SELF \
+ REGISTER (32, 32, PT_THREAD_POINTER * 4, \
+ - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE) \
+ REGISTER (64, 64, PT_THREAD_POINTER * 8, \
+ - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE)
+
+/* Read member of the thread descriptor directly. */
+# define THREAD_GETMEM(descr, member) ((void)(descr), (THREAD_SELF)->member)
+
+/* Same as THREAD_GETMEM, but the member offset can be non-constant. */
+# define THREAD_GETMEM_NC(descr, member, idx) \
+ ((void)(descr), (THREAD_SELF)->member[idx])
+
+/* Set member of the thread descriptor directly. */
+# define THREAD_SETMEM(descr, member, value) \
+ ((void)(descr), (THREAD_SELF)->member = (value))
+
+/* Same as THREAD_SETMEM, but the member offset can be non-constant. */
+# define THREAD_SETMEM_NC(descr, member, idx, value) \
+ ((void)(descr), (THREAD_SELF)->member[idx] = (value))
+
+/* Set the stack guard field in TCB head. */
+# define THREAD_SET_STACK_GUARD(value) \
+ (((tcbhead_t *) ((char *) __thread_register \
+ - TLS_TCB_OFFSET))[-1].stack_guard = (value))
+# define THREAD_COPY_STACK_GUARD(descr) \
+ (((tcbhead_t *) ((char *) (descr) \
+ + TLS_PRE_TCB_SIZE))[-1].stack_guard \
+ = ((tcbhead_t *) ((char *) __thread_register \
+ - TLS_TCB_OFFSET))[-1].stack_guard)
+
+/* Set the stack guard field in TCB head. */
+# define THREAD_GET_POINTER_GUARD() \
+ (((tcbhead_t *) ((char *) __thread_register \
+ - TLS_TCB_OFFSET))[-1].pointer_guard)
+# define THREAD_SET_POINTER_GUARD(value) \
+ (THREAD_GET_POINTER_GUARD () = (value))
+# define THREAD_COPY_POINTER_GUARD(descr) \
+ (((tcbhead_t *) ((char *) (descr) \
+ + TLS_PRE_TCB_SIZE))[-1].pointer_guard \
+ = THREAD_GET_POINTER_GUARD())
+
+/* l_tls_offset == 0 is perfectly valid on PPC, so we have to use some
+ different value to mean unset l_tls_offset. */
+# define NO_TLS_OFFSET -1
+
+/* Get and set the global scope generation counter in struct pthread. */
+#define THREAD_GSCOPE_FLAG_UNUSED 0
+#define THREAD_GSCOPE_FLAG_USED 1
+#define THREAD_GSCOPE_FLAG_WAIT 2
+#define THREAD_GSCOPE_RESET_FLAG() \
+ do \
+ { int __res \
+ = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \
+ THREAD_GSCOPE_FLAG_UNUSED); \
+ if (__res == THREAD_GSCOPE_FLAG_WAIT) \
+ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \
+ } \
+ while (0)
+#define THREAD_GSCOPE_SET_FLAG() \
+ do \
+ { \
+ THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED; \
+ atomic_write_barrier (); \
+ } \
+ while (0)
+#define THREAD_GSCOPE_WAIT() \
+ GL(dl_wait_lookup_done) ()
+
+#endif /* __ASSEMBLER__ */
+
+#endif /* tls.h */
diff --git a/libpthread/nptl/sysdeps/pthread/Makefile b/libpthread/nptl/sysdeps/pthread/Makefile
new file mode 100644
index 000000000..a30ded527
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/Makefile
@@ -0,0 +1,13 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2005 Steven J. Hill <sjhill@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+top_srcdir=../../../../
+top_builddir=../../../../
+all: objs
+include $(top_builddir)Rules.mak
+include Makefile.in
+include $(top_srcdir)Makerules
diff --git a/libpthread/nptl/sysdeps/pthread/Makefile.in b/libpthread/nptl/sysdeps/pthread/Makefile.in
new file mode 100644
index 000000000..849c75fee
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/Makefile.in
@@ -0,0 +1,106 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2005-2006 Steven J. Hill <sjhill@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+subdirs += libpthread/nptl/sysdeps/pthread
+#
+# NOTE: glibc puts flockfile.c, ftrylockfile.c, funlockfile.c, and
+# pt-longjmp.c in libc and libpthread. For uClibc, they are
+# in libc only.
+#
+libpthread_pthread_DIR = $(top_srcdir)libpthread/nptl/sysdeps/pthread
+libpthread_pthread_OUT = $(top_builddir)libpthread/nptl/sysdeps/pthread
+
+libpthread_pthread_COBJ = $(patsubst %.c,$(libpthread_pthread_OUT)/%.o,$(libpthread_pthread_CSRC))
+libpthread_pthread_CSRC = \
+ pthread_barrier_destroy.c \
+ pthread_barrier_init.c \
+ pthread_barrier_wait.c \
+ pthread_cond_broadcast.c \
+ pthread_cond_signal.c \
+ pthread_cond_timedwait.c \
+ pthread_cond_wait.c \
+ pthread_rwlock_rdlock.c \
+ pthread_rwlock_timedrdlock.c \
+ pthread_rwlock_timedwrlock.c \
+ pthread_rwlock_unlock.c \
+ pthread_rwlock_wrlock.c \
+ pthread_sigmask.c \
+ pthread_spin_destroy.c \
+ pthread_spin_init.c \
+ pthread_spin_unlock.c \
+ pt-longjmp.c \
+ tpp.c
+
+CFLAGS-pthread_barrier_wait.c = -D_GNU_SOURCE
+CFLAGS-pthread_spin_destroy.c = -D_GNU_SOURCE
+CFLAGS-pthread_spin_init.c = -D_GNU_SOURCE
+CFLAGS-pthread_spin_unlock.c = -D_GNU_SOURCE
+CFLAGS-unwind-forcedunwind.c = -fexceptions -fasynchronous-unwind-tables
+
+CFLAGS-OMIT-librt-cancellation.c = -DIS_IN_libpthread
+CFLAGS-OMIT-rt-unwind-resume.c = -DIS_IN_libpthread
+CFLAGS-librt-cancellation.c = -DIS_IN_librt \
+ -fexceptions -fasynchronous-unwind-tables
+CFLAGS-rt-unwind-resume.c = -DIS_IN_librt \
+ -fexceptions -fasynchronous-unwind-tables
+
+libpthread-so-y += $(patsubst %,$(libpthread_pthread_OUT)/%.oS, unwind-forcedunwind)
+
+librt-pt-routines-y = librt-cancellation.c
+librt-pt-shared-only-routines-y = rt-unwind-resume.c
+
+ifeq ($(UCLIBC_CTOR_DTOR),y)
+CFLAGS-OMIT-pt-initfini.c = $(CFLAGS-y-libpthread/nptl/sysdeps/pthread)
+CFLAGS-pt-initfini.c = -S -g0 $(PICFLAG) -fno-inline-functions \
+ $(call check_gcc,-fno-unit-at-a-time,) \
+ $(SSP_DISABLE_FLAGS) \
+ -finhibit-size-directive \
+ -fno-asynchronous-unwind-tables -fno-unwind-tables \
+ $(patsubst -f%,-fno-%,$(call check_gcc,-fexceptions,))
+
+#ASFLAGS += $(PICFLAG) -I$(top_srcdir)include -I$(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)
+ifneq ($(wildcard $(libpthread_pthread_DIR)/../unix/sysv/linux/$(TARGET_ARCH)/pt-initfini.c),)
+PTHREAD_INITFINI := $(libpthread_pthread_DIR)/../unix/sysv/linux/$(TARGET_ARCH)/pt-initfini.c
+else
+PTHREAD_INITFINI := $(libpthread_pthread_DIR)/pt-initfini.c
+endif
+
+ASFLAGS-pt-crti.S = $(PICFLAG)
+ASFLAGS-pt-crtn.S = $(PICFLAG)
+
+$(libpthread_pthread_OUT)/pt-crti.o: $(libpthread_pthread_OUT)/pt-crti.S
+ $(compile.S)
+
+$(libpthread_pthread_OUT)/pt-crtn.o: $(libpthread_pthread_OUT)/pt-crtn.S
+ $(compile.S)
+
+$(libpthread_pthread_OUT)/pt-initfini.s: $(PTHREAD_INITFINI) | $(headers_dep)
+ $(compile.c)
+$(libpthread_pthread_OUT)/defs.h: $(PTHREAD_INITFINI)
+ $(do_sed) -n -e '/@TESTS_BEGIN/,/@TESTS_END/p' $< | \
+ $(AWK) -f $(top_srcdir)extra/scripts/defs.awk > $@.tmp
+ $(Q)mv $@.tmp $@
+
+$(libpthread_pthread_OUT)/pt-crti.S: $(libpthread_pthread_OUT)/pt-initfini.s $(libpthread_pthread_OUT)/defs.h
+ $(do_sed) -n -e '/[ ]*\.file/d' \
+ -e '1,/@HEADER_ENDS/p' \
+ -e '/@_.*_PROLOG_BEGINS/,/@_.*_PROLOG_ENDS/p' \
+ -e '/@TRAILER_BEGINS/,$$p' $< > $@.tmp
+ $(Q)mv $@.tmp $@
+$(libpthread_pthread_OUT)/pt-crtn.S: $(libpthread_pthread_OUT)/pt-initfini.s $(libpthread_pthread_OUT)/defs.h
+ $(do_sed) -n -e '/[ ]*\.file/d' \
+ -e '1,/@HEADER_ENDS/p' \
+ -e '/@_.*_EPILOG_BEGINS/,/@_.*_EPILOG_ENDS/p' \
+ -e '/@TRAILER_BEGINS/,$$p' $< > $@.tmp
+ $(Q)mv $@.tmp $@
+endif
+
+objclean-y += CLEAN_libpthread/nptl/sysdeps/pthread
+
+CLEAN_libpthread/nptl/sysdeps/pthread:
+ $(do_rm) $(addprefix $(libpthread_pthread_OUT)/*., o os oS s S) \
+ $(libpthread_pthread_OUT)/defs.h
diff --git a/libpthread/nptl/sysdeps/pthread/allocalim.h b/libpthread/nptl/sysdeps/pthread/allocalim.h
new file mode 100644
index 000000000..e4901a701
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/allocalim.h
@@ -0,0 +1,29 @@
+/* Determine whether block of given size can be allocated on the stack or not.
+ Copyright (C) 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; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <alloca.h>
+#include <limits.h>
+
+
+extern int
+__always_inline
+__libc_use_alloca (size_t size)
+{
+ return (__builtin_expect (size <= PTHREAD_STACK_MIN / 4, 1)
+ || __libc_alloca_cutoff (size));
+}
diff --git a/libpthread/nptl/sysdeps/pthread/bits/libc-lock.h b/libpthread/nptl/sysdeps/pthread/bits/libc-lock.h
new file mode 100644
index 000000000..633021ab1
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/bits/libc-lock.h
@@ -0,0 +1,583 @@
+/* libc-internal interface for mutex locks. NPTL version.
+ Copyright (C) 1996-2003, 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; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef _BITS_LIBC_LOCK_H
+#define _BITS_LIBC_LOCK_H 1
+
+#include <bits/initspin.h>
+#include <pthread.h>
+#define __need_NULL
+#include <stddef.h>
+
+
+/* Fortunately Linux now has a mean to do locking which is realtime
+ safe without the aid of the thread library. We also need no fancy
+ options like error checking mutexes etc. We only need simple
+ locks, maybe recursive. This can be easily and cheaply implemented
+ using futexes. We will use them everywhere except in ld.so since
+ ld.so might be used on old kernels with a different libc.so. */
+#ifdef _LIBC
+# include <lowlevellock.h>
+# include <tls.h>
+# include <pthread-functions.h>
+#endif
+
+/* Mutex type. */
+#if defined _LIBC || defined _IO_MTSAFE_IO
+# if (defined NOT_IN_libc && !defined IS_IN_libpthread) || !defined _LIBC
+typedef pthread_mutex_t __libc_lock_t;
+typedef struct { pthread_mutex_t mutex; } __libc_lock_recursive_t;
+# else
+typedef int __libc_lock_t;
+typedef struct { int lock; int cnt; void *owner; } __libc_lock_recursive_t;
+# endif
+typedef struct { pthread_mutex_t mutex; } __rtld_lock_recursive_t;
+# ifdef __USE_UNIX98
+typedef pthread_rwlock_t __libc_rwlock_t;
+# else
+typedef struct __libc_rwlock_opaque__ __libc_rwlock_t;
+# endif
+#else
+typedef struct __libc_lock_opaque__ __libc_lock_t;
+typedef struct __libc_lock_recursive_opaque__ __libc_lock_recursive_t;
+typedef struct __libc_rwlock_opaque__ __libc_rwlock_t;
+#endif
+
+/* Type for key to thread-specific data. */
+typedef pthread_key_t __libc_key_t;
+
+# define __libc_freeres_fn_section \
+ __attribute__ ((section ("__libc_freeres_fn")))
+
+
+/* Define a lock variable NAME with storage class CLASS. The lock must be
+ initialized with __libc_lock_init before it can be used (or define it
+ with __libc_lock_define_initialized, below). Use `extern' for CLASS to
+ declare a lock defined in another module. In public structure
+ definitions you must use a pointer to the lock structure (i.e., NAME
+ begins with a `*'), because its storage size will not be known outside
+ of libc. */
+#define __libc_lock_define(CLASS,NAME) \
+ CLASS __libc_lock_t NAME;
+#define __libc_rwlock_define(CLASS,NAME) \
+ CLASS __libc_rwlock_t NAME;
+#define __libc_lock_define_recursive(CLASS,NAME) \
+ CLASS __libc_lock_recursive_t NAME;
+#define __rtld_lock_define_recursive(CLASS,NAME) \
+ CLASS __rtld_lock_recursive_t NAME;
+
+/* Define an initialized lock variable NAME with storage class CLASS.
+
+ For the C library we take a deeper look at the initializer. For
+ this implementation all fields are initialized to zero. Therefore
+ we don't initialize the variable which allows putting it into the
+ BSS section. (Except on PA-RISC and other odd architectures, where
+ initialized locks must be set to one due to the lack of normal
+ atomic operations.) */
+
+#if defined _LIBC && (!defined NOT_IN_libc || defined IS_IN_libpthread)
+# if LLL_LOCK_INITIALIZER == 0
+# define __libc_lock_define_initialized(CLASS,NAME) \
+ CLASS __libc_lock_t NAME;
+# else
+# define __libc_lock_define_initialized(CLASS,NAME) \
+ CLASS __libc_lock_t NAME = LLL_LOCK_INITIALIZER;
+# endif
+#else
+# if __LT_SPINLOCK_INIT == 0
+# define __libc_lock_define_initialized(CLASS,NAME) \
+ CLASS __libc_lock_t NAME;
+# else
+# define __libc_lock_define_initialized(CLASS,NAME) \
+ CLASS __libc_lock_t NAME = PTHREAD_MUTEX_INITIALIZER;
+# endif
+#endif
+
+#define __libc_rwlock_define_initialized(CLASS,NAME) \
+ CLASS __libc_rwlock_t NAME = PTHREAD_RWLOCK_INITIALIZER;
+
+/* Define an initialized recursive lock variable NAME with storage
+ class CLASS. */
+#if defined _LIBC && (!defined NOT_IN_libc || defined IS_IN_libpthread)
+# if LLL_LOCK_INITIALIZER == 0
+# define __libc_lock_define_initialized_recursive(CLASS,NAME) \
+ CLASS __libc_lock_recursive_t NAME;
+# else
+# define __libc_lock_define_initialized_recursive(CLASS,NAME) \
+ CLASS __libc_lock_recursive_t NAME = _LIBC_LOCK_RECURSIVE_INITIALIZER;
+# endif
+# define _LIBC_LOCK_RECURSIVE_INITIALIZER \
+ { LLL_LOCK_INITIALIZER, 0, NULL }
+#else
+# define __libc_lock_define_initialized_recursive(CLASS,NAME) \
+ CLASS __libc_lock_recursive_t NAME = _LIBC_LOCK_RECURSIVE_INITIALIZER;
+# define _LIBC_LOCK_RECURSIVE_INITIALIZER \
+ {PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP}
+#endif
+
+#define __rtld_lock_define_initialized_recursive(CLASS,NAME) \
+ CLASS __rtld_lock_recursive_t NAME = _RTLD_LOCK_RECURSIVE_INITIALIZER;
+#define _RTLD_LOCK_RECURSIVE_INITIALIZER \
+ {PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP}
+
+#define __rtld_lock_initialize(NAME) \
+ (void) ((NAME) = (__rtld_lock_recursive_t) _RTLD_LOCK_RECURSIVE_INITIALIZER)
+
+/* If we check for a weakly referenced symbol and then perform a
+ normal jump to it te code generated for some platforms in case of
+ PIC is unnecessarily slow. What would happen is that the function
+ is first referenced as data and then it is called indirectly
+ through the PLT. We can make this a direct jump. */
+#ifdef __PIC__
+# define __libc_maybe_call(FUNC, ARGS, ELSE) \
+ (__extension__ ({ __typeof (FUNC) *_fn = (FUNC); \
+ _fn != NULL ? (*_fn) ARGS : ELSE; }))
+#else
+# define __libc_maybe_call(FUNC, ARGS, ELSE) \
+ (FUNC != NULL ? FUNC ARGS : ELSE)
+#endif
+
+/* Call thread functions through the function pointer table. */
+#if defined SHARED && !defined NOT_IN_libc
+# define PTFAVAIL(NAME) __libc_pthread_functions_init
+# define __libc_ptf_call(FUNC, ARGS, ELSE) \
+ (__libc_pthread_functions_init ? PTHFCT_CALL (ptr_##FUNC, ARGS) : ELSE)
+# define __libc_ptf_call_always(FUNC, ARGS) \
+ PTHFCT_CALL (ptr_##FUNC, ARGS)
+#else
+# define PTFAVAIL(NAME) (NAME != NULL)
+# define __libc_ptf_call(FUNC, ARGS, ELSE) \
+ __libc_maybe_call (FUNC, ARGS, ELSE)
+# define __libc_ptf_call_always(FUNC, ARGS) \
+ FUNC ARGS
+#endif
+
+
+/* Initialize the named lock variable, leaving it in a consistent, unlocked
+ state. */
+#if defined _LIBC && (!defined NOT_IN_libc || defined IS_IN_libpthread)
+# define __libc_lock_init(NAME) ((void)((NAME) = LLL_LOCK_INITIALIZER))
+#else
+# define __libc_lock_init(NAME) \
+ __libc_maybe_call (__pthread_mutex_init, (&(NAME), NULL), 0)
+#endif
+#if defined SHARED && !defined NOT_IN_libc
+/* ((NAME) = (__libc_rwlock_t) PTHREAD_RWLOCK_INITIALIZER, 0) is
+ inefficient. */
+# define __libc_rwlock_init(NAME) \
+ (__builtin_memset (&(NAME), '\0', sizeof (NAME)), 0)
+#else
+# define __libc_rwlock_init(NAME) \
+ __libc_maybe_call (__pthread_rwlock_init, (&(NAME), NULL), 0)
+#endif
+
+/* Same as last but this time we initialize a recursive mutex. */
+#if defined _LIBC && (!defined NOT_IN_libc || defined IS_IN_libpthread)
+# define __libc_lock_init_recursive(NAME) \
+ ((NAME) = (__libc_lock_recursive_t) _LIBC_LOCK_RECURSIVE_INITIALIZER, 0)
+#else
+# define __libc_lock_init_recursive(NAME) \
+ do { \
+ if (__pthread_mutex_init != NULL) \
+ { \
+ pthread_mutexattr_t __attr; \
+ __pthread_mutexattr_init (&__attr); \
+ __pthread_mutexattr_settype (&__attr, PTHREAD_MUTEX_RECURSIVE_NP); \
+ __pthread_mutex_init (&(NAME).mutex, &__attr); \
+ __pthread_mutexattr_destroy (&__attr); \
+ } \
+ } while (0)
+#endif
+
+#define __rtld_lock_init_recursive(NAME) \
+ do { \
+ if (__pthread_mutex_init != NULL) \
+ { \
+ pthread_mutexattr_t __attr; \
+ __pthread_mutexattr_init (&__attr); \
+ __pthread_mutexattr_settype (&__attr, PTHREAD_MUTEX_RECURSIVE_NP); \
+ __pthread_mutex_init (&(NAME).mutex, &__attr); \
+ __pthread_mutexattr_destroy (&__attr); \
+ } \
+ } while (0)
+
+/* Finalize the named lock variable, which must be locked. It cannot be
+ used again until __libc_lock_init is called again on it. This must be
+ called on a lock variable before the containing storage is reused. */
+#if defined _LIBC && (!defined NOT_IN_libc || defined IS_IN_libpthread)
+# define __libc_lock_fini(NAME) ((void) 0)
+#else
+# define __libc_lock_fini(NAME) \
+ __libc_maybe_call (__pthread_mutex_destroy, (&(NAME)), 0)
+#endif
+#if defined SHARED && !defined NOT_IN_libc
+# define __libc_rwlock_fini(NAME) ((void) 0)
+#else
+# define __libc_rwlock_fini(NAME) \
+ __libc_maybe_call (__pthread_rwlock_destroy, (&(NAME)), 0)
+#endif
+
+/* Finalize recursive named lock. */
+#if defined _LIBC && (!defined NOT_IN_libc || defined IS_IN_libpthread)
+# define __libc_lock_fini_recursive(NAME) ((void) 0)
+#else
+# define __libc_lock_fini_recursive(NAME) \
+ __libc_maybe_call (__pthread_mutex_destroy, (&(NAME)), 0)
+#endif
+
+/* Lock the named lock variable. */
+#if defined _LIBC && (!defined NOT_IN_libc || defined IS_IN_libpthread)
+# define __libc_lock_lock(NAME) \
+ ({ lll_lock (NAME, LLL_PRIVATE); 0; })
+#else
+# define __libc_lock_lock(NAME) \
+ __libc_maybe_call (__pthread_mutex_lock, (&(NAME)), 0)
+#endif
+#define __libc_rwlock_rdlock(NAME) \
+ __libc_ptf_call (__pthread_rwlock_rdlock, (&(NAME)), 0)
+#define __libc_rwlock_wrlock(NAME) \
+ __libc_ptf_call (__pthread_rwlock_wrlock, (&(NAME)), 0)
+
+/* Lock the recursive named lock variable. */
+#if defined _LIBC && (!defined NOT_IN_libc || defined IS_IN_libpthread)
+# define __libc_lock_lock_recursive(NAME) \
+ do { \
+ void *self = THREAD_SELF; \
+ if ((NAME).owner != self) \
+ { \
+ lll_lock ((NAME).lock, LLL_PRIVATE); \
+ (NAME).owner = self; \
+ } \
+ ++(NAME).cnt; \
+ } while (0)
+#else
+# define __libc_lock_lock_recursive(NAME) \
+ __libc_maybe_call (__pthread_mutex_lock, (&(NAME).mutex), 0)
+#endif
+
+/* Try to lock the named lock variable. */
+#if defined _LIBC && (!defined NOT_IN_libc || defined IS_IN_libpthread)
+# define __libc_lock_trylock(NAME) \
+ lll_trylock (NAME)
+#else
+# define __libc_lock_trylock(NAME) \
+ __libc_maybe_call (__pthread_mutex_trylock, (&(NAME)), 0)
+#endif
+#define __libc_rwlock_tryrdlock(NAME) \
+ __libc_maybe_call (__pthread_rwlock_tryrdlock, (&(NAME)), 0)
+#define __libc_rwlock_trywrlock(NAME) \
+ __libc_maybe_call (__pthread_rwlock_trywrlock, (&(NAME)), 0)
+
+/* Try to lock the recursive named lock variable. */
+#if defined _LIBC && (!defined NOT_IN_libc || defined IS_IN_libpthread)
+# define __libc_lock_trylock_recursive(NAME) \
+ ({ \
+ int result = 0; \
+ void *self = THREAD_SELF; \
+ if ((NAME).owner != self) \
+ { \
+ if (lll_trylock ((NAME).lock) == 0) \
+ { \
+ (NAME).owner = self; \
+ (NAME).cnt = 1; \
+ } \
+ else \
+ result = EBUSY; \
+ } \
+ else \
+ ++(NAME).cnt; \
+ result; \
+ })
+#else
+# define __libc_lock_trylock_recursive(NAME) \
+ __libc_maybe_call (__pthread_mutex_trylock, (&(NAME)), 0)
+#endif
+
+#define __rtld_lock_trylock_recursive(NAME) \
+ __libc_maybe_call (__pthread_mutex_trylock, (&(NAME).mutex), 0)
+
+/* Unlock the named lock variable. */
+#if defined _LIBC && (!defined NOT_IN_libc || defined IS_IN_libpthread)
+# define __libc_lock_unlock(NAME) \
+ lll_unlock (NAME, LLL_PRIVATE)
+#else
+# define __libc_lock_unlock(NAME) \
+ __libc_maybe_call (__pthread_mutex_unlock, (&(NAME)), 0)
+#endif
+#define __libc_rwlock_unlock(NAME) \
+ __libc_ptf_call (__pthread_rwlock_unlock, (&(NAME)), 0)
+
+/* Unlock the recursive named lock variable. */
+#if defined _LIBC && (!defined NOT_IN_libc || defined IS_IN_libpthread)
+/* We do no error checking here. */
+# define __libc_lock_unlock_recursive(NAME) \
+ do { \
+ if (--(NAME).cnt == 0) \
+ { \
+ (NAME).owner = NULL; \
+ lll_unlock ((NAME).lock, LLL_PRIVATE); \
+ } \
+ } while (0)
+#else
+# define __libc_lock_unlock_recursive(NAME) \
+ __libc_maybe_call (__pthread_mutex_unlock, (&(NAME)), 0)
+#endif
+
+#if defined _LIBC && defined SHARED
+# define __rtld_lock_default_lock_recursive(lock) \
+ ++((pthread_mutex_t *)(lock))->__data.__count;
+
+# define __rtld_lock_default_unlock_recursive(lock) \
+ --((pthread_mutex_t *)(lock))->__data.__count;
+
+# define __rtld_lock_lock_recursive(NAME) \
+ GL(dl_rtld_lock_recursive) (&(NAME).mutex)
+
+# define __rtld_lock_unlock_recursive(NAME) \
+ GL(dl_rtld_unlock_recursive) (&(NAME).mutex)
+#else
+# define __rtld_lock_lock_recursive(NAME) \
+ __libc_maybe_call (__pthread_mutex_lock, (&(NAME).mutex), 0)
+
+# define __rtld_lock_unlock_recursive(NAME) \
+ __libc_maybe_call (__pthread_mutex_unlock, (&(NAME).mutex), 0)
+#endif
+
+/* Define once control variable. */
+#if PTHREAD_ONCE_INIT == 0
+/* Special case for static variables where we can avoid the initialization
+ if it is zero. */
+# define __libc_once_define(CLASS, NAME) \
+ CLASS pthread_once_t NAME
+#else
+# define __libc_once_define(CLASS, NAME) \
+ CLASS pthread_once_t NAME = PTHREAD_ONCE_INIT
+#endif
+
+/* Call handler iff the first call. */
+#define __libc_once(ONCE_CONTROL, INIT_FUNCTION) \
+ do { \
+ if (PTFAVAIL (__pthread_once)) \
+ __libc_ptf_call_always (__pthread_once, (&(ONCE_CONTROL), \
+ INIT_FUNCTION)); \
+ else if ((ONCE_CONTROL) == PTHREAD_ONCE_INIT) { \
+ INIT_FUNCTION (); \
+ (ONCE_CONTROL) |= 2; \
+ } \
+ } while (0)
+
+
+/* Note that for I/O cleanup handling we are using the old-style
+ cancel handling. It does not have to be integrated with C++ snce
+ no C++ code is called in the middle. The old-style handling is
+ faster and the support is not going away. */
+extern void _pthread_cleanup_push (struct _pthread_cleanup_buffer *buffer,
+ void (*routine) (void *), void *arg);
+extern void _pthread_cleanup_pop (struct _pthread_cleanup_buffer *buffer,
+ int execute);
+extern void _pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *buffer,
+ void (*routine) (void *), void *arg);
+extern void _pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *buffer,
+ int execute);
+
+/* Start critical region with cleanup. */
+#define __libc_cleanup_region_start(DOIT, FCT, ARG) \
+ { struct _pthread_cleanup_buffer _buffer; \
+ int _avail; \
+ if (DOIT) { \
+ _avail = PTFAVAIL (_pthread_cleanup_push_defer); \
+ if (_avail) { \
+ __libc_ptf_call_always (_pthread_cleanup_push_defer, (&_buffer, FCT, \
+ ARG)); \
+ } else { \
+ _buffer.__routine = (FCT); \
+ _buffer.__arg = (ARG); \
+ } \
+ } else { \
+ _avail = 0; \
+ }
+
+/* End critical region with cleanup. */
+#define __libc_cleanup_region_end(DOIT) \
+ if (_avail) { \
+ __libc_ptf_call_always (_pthread_cleanup_pop_restore, (&_buffer, DOIT));\
+ } else if (DOIT) \
+ _buffer.__routine (_buffer.__arg); \
+ }
+
+/* Sometimes we have to exit the block in the middle. */
+#define __libc_cleanup_end(DOIT) \
+ if (_avail) { \
+ __libc_ptf_call_always (_pthread_cleanup_pop_restore, (&_buffer, DOIT));\
+ } else if (DOIT) \
+ _buffer.__routine (_buffer.__arg)
+
+
+/* Normal cleanup handling, based on C cleanup attribute. */
+static inline void
+__libc_cleanup_routine (struct __pthread_cleanup_frame *f)
+{
+ if (f->__do_it)
+ f->__cancel_routine (f->__cancel_arg);
+}
+
+#define __libc_cleanup_push(fct, arg) \
+ do { \
+ struct __pthread_cleanup_frame __clframe \
+ __attribute__ ((__cleanup__ (__libc_cleanup_routine))) \
+ = { .__cancel_routine = (fct), .__cancel_arg = (arg), \
+ .__do_it = 1 };
+
+#define __libc_cleanup_pop(execute) \
+ __clframe.__do_it = (execute); \
+ } while (0)
+
+
+/* Create thread-specific key. */
+#define __libc_key_create(KEY, DESTRUCTOR) \
+ __libc_ptf_call (__pthread_key_create, (KEY, DESTRUCTOR), 1)
+
+/* Get thread-specific data. */
+#define __libc_getspecific(KEY) \
+ __libc_ptf_call (__pthread_getspecific, (KEY), NULL)
+
+/* Set thread-specific data. */
+#define __libc_setspecific(KEY, VALUE) \
+ __libc_ptf_call (__pthread_setspecific, (KEY, VALUE), 0)
+
+/* Register handlers to execute before and after `fork'. Note that the
+ last parameter is NULL. The handlers registered by the libc are
+ never removed so this is OK. */
+#define __libc_atfork(PREPARE, PARENT, CHILD) \
+ __register_atfork (PREPARE, PARENT, CHILD, NULL)
+extern int __register_atfork (void (*__prepare) (void),
+ void (*__parent) (void),
+ void (*__child) (void),
+ void *__dso_handle);
+
+/* Functions that are used by this file and are internal to the GNU C
+ library. */
+
+extern int __pthread_mutex_init (pthread_mutex_t *__mutex,
+ const pthread_mutexattr_t *__mutex_attr);
+
+extern int __pthread_mutex_destroy (pthread_mutex_t *__mutex);
+
+extern int __pthread_mutex_trylock (pthread_mutex_t *__mutex);
+
+extern int __pthread_mutex_lock (pthread_mutex_t *__mutex);
+
+extern int __pthread_mutex_unlock (pthread_mutex_t *__mutex);
+
+extern int __pthread_mutexattr_init (pthread_mutexattr_t *__attr);
+
+extern int __pthread_mutexattr_destroy (pthread_mutexattr_t *__attr);
+
+extern int __pthread_mutexattr_settype (pthread_mutexattr_t *__attr,
+ int __kind);
+
+#ifdef __USE_UNIX98
+extern int __pthread_rwlock_init (pthread_rwlock_t *__rwlock,
+ const pthread_rwlockattr_t *__attr);
+
+extern int __pthread_rwlock_destroy (pthread_rwlock_t *__rwlock);
+
+extern int __pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock);
+
+extern int __pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock);
+
+extern int __pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock);
+
+extern int __pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock);
+
+extern int __pthread_rwlock_unlock (pthread_rwlock_t *__rwlock);
+#endif
+
+extern int __pthread_key_create (pthread_key_t *__key,
+ void (*__destr_function) (void *));
+
+extern int __pthread_setspecific (pthread_key_t __key,
+ const void *__pointer);
+
+extern void *__pthread_getspecific (pthread_key_t __key);
+
+extern int __pthread_once (pthread_once_t *__once_control,
+ void (*__init_routine) (void));
+
+extern int __pthread_atfork (void (*__prepare) (void),
+ void (*__parent) (void),
+ void (*__child) (void));
+
+
+
+/* Make the pthread functions weak so that we can elide them from
+ single-threaded processes. */
+#ifndef __NO_WEAK_PTHREAD_ALIASES
+# ifdef weak_extern
+weak_extern (__pthread_mutex_init)
+weak_extern (__pthread_mutex_destroy)
+weak_extern (__pthread_mutex_lock)
+weak_extern (__pthread_mutex_trylock)
+weak_extern (__pthread_mutex_unlock)
+weak_extern (__pthread_mutexattr_init)
+weak_extern (__pthread_mutexattr_destroy)
+weak_extern (__pthread_mutexattr_settype)
+weak_extern (__pthread_rwlock_init)
+weak_extern (__pthread_rwlock_destroy)
+weak_extern (__pthread_rwlock_rdlock)
+weak_extern (__pthread_rwlock_tryrdlock)
+weak_extern (__pthread_rwlock_wrlock)
+weak_extern (__pthread_rwlock_trywrlock)
+weak_extern (__pthread_rwlock_unlock)
+weak_extern (__pthread_key_create)
+weak_extern (__pthread_setspecific)
+weak_extern (__pthread_getspecific)
+weak_extern (__pthread_once)
+//weak_extern (__pthread_initialize)
+weak_extern (__pthread_atfork)
+weak_extern (_pthread_cleanup_push_defer)
+weak_extern (_pthread_cleanup_pop_restore)
+weak_extern (pthread_setcancelstate)
+# else
+# pragma weak __pthread_mutex_init
+# pragma weak __pthread_mutex_destroy
+# pragma weak __pthread_mutex_lock
+# pragma weak __pthread_mutex_trylock
+# pragma weak __pthread_mutex_unlock
+# pragma weak __pthread_mutexattr_init
+# pragma weak __pthread_mutexattr_destroy
+# pragma weak __pthread_mutexattr_settype
+# pragma weak __pthread_rwlock_destroy
+# pragma weak __pthread_rwlock_rdlock
+# pragma weak __pthread_rwlock_tryrdlock
+# pragma weak __pthread_rwlock_wrlock
+# pragma weak __pthread_rwlock_trywrlock
+# pragma weak __pthread_rwlock_unlock
+# pragma weak __pthread_key_create
+# pragma weak __pthread_setspecific
+# pragma weak __pthread_getspecific
+# pragma weak __pthread_once
+//# pragma weak __pthread_initialize
+# pragma weak __pthread_atfork
+# pragma weak _pthread_cleanup_push_defer
+# pragma weak _pthread_cleanup_pop_restore
+# pragma weak pthread_setcancelstate
+# endif
+#endif
+
+#endif /* bits/libc-lock.h */
diff --git a/libpthread/nptl/sysdeps/pthread/bits/libc-tsd.h b/libpthread/nptl/sysdeps/pthread/bits/libc-tsd.h
new file mode 100644
index 000000000..26891993d
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/bits/libc-tsd.h
@@ -0,0 +1,68 @@
+/* libc-internal interface for thread-specific data. Stub or TLS version.
+ Copyright (C) 1998,2001,02 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 _GENERIC_BITS_LIBC_TSD_H
+#define _GENERIC_BITS_LIBC_TSD_H 1
+
+/* This file defines the following macros for accessing a small fixed
+ set of thread-specific `void *' data used only internally by libc.
+
+ __libc_tsd_define(CLASS, KEY) -- Define or declare a `void *' datum
+ for KEY. CLASS can be `static' for
+ keys used in only one source file,
+ empty for global definitions, or
+ `extern' for global declarations.
+ __libc_tsd_address(KEY) -- Return the `void **' pointing to
+ the current thread's datum for KEY.
+ __libc_tsd_get(KEY) -- Return the `void *' datum for KEY.
+ __libc_tsd_set(KEY, VALUE) -- Set the datum for KEY to VALUE.
+
+ The set of available KEY's will usually be provided as an enum,
+ and contains (at least):
+ _LIBC_TSD_KEY_MALLOC
+ _LIBC_TSD_KEY_DL_ERROR
+ _LIBC_TSD_KEY_RPC_VARS
+ All uses must be the literal _LIBC_TSD_* name in the __libc_tsd_* macros.
+ Some implementations may not provide any enum at all and instead
+ using string pasting in the macros. */
+
+#include <tls.h>
+
+/* When full support for __thread variables is available, this interface is
+ just a trivial wrapper for it. Without TLS, this is the generic/stub
+ implementation for wholly single-threaded systems.
+
+ We don't define an enum for the possible key values, because the KEYs
+ translate directly into variables by macro magic. */
+
+#if USE___THREAD
+# define __libc_tsd_define(CLASS, KEY) \
+ CLASS __thread void *__libc_tsd_##KEY attribute_tls_model_ie;
+
+# define __libc_tsd_address(KEY) (&__libc_tsd_##KEY)
+# define __libc_tsd_get(KEY) (__libc_tsd_##KEY)
+# define __libc_tsd_set(KEY, VALUE) (__libc_tsd_##KEY = (VALUE))
+#else
+# define __libc_tsd_define(CLASS, KEY) CLASS void *__libc_tsd_##KEY##_data;
+
+# define __libc_tsd_address(KEY) (&__libc_tsd_##KEY##_data)
+# define __libc_tsd_get(KEY) (__libc_tsd_##KEY##_data)
+# define __libc_tsd_set(KEY, VALUE) (__libc_tsd_##KEY##_data = (VALUE))
+#endif
+
+#endif /* bits/libc-tsd.h */
diff --git a/libpthread/nptl/sysdeps/pthread/bits/sigthread.h b/libpthread/nptl/sysdeps/pthread/bits/sigthread.h
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/bits/sigthread.h
diff --git a/libpthread/nptl/sysdeps/pthread/bits/stdio-lock.h b/libpthread/nptl/sysdeps/pthread/bits/stdio-lock.h
new file mode 100644
index 000000000..ae39b87f4
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/bits/stdio-lock.h
@@ -0,0 +1,110 @@
+/* Thread package specific definitions of stream lock type. NPTL version.
+ Copyright (C) 2000, 2001, 2002, 2003, 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 _BITS_STDIO_LOCK_H
+#define _BITS_STDIO_LOCK_H 1
+
+#include <bits/libc-lock.h>
+#include <lowlevellock.h>
+
+
+/* The locking here is very inexpensive, even for inlining. */
+#define _IO_lock_inexpensive 1
+
+typedef struct { int lock; int cnt; void *owner; } _IO_lock_t;
+
+#define _IO_lock_initializer { LLL_LOCK_INITIALIZER, 0, NULL }
+
+#define _IO_lock_init(_name) \
+ ((void) ((_name) = (_IO_lock_t) _IO_lock_initializer))
+
+#define _IO_lock_fini(_name) \
+ ((void) 0)
+
+#define _IO_lock_lock(_name) \
+ do { \
+ void *__meself = THREAD_SELF; \
+ if ((_name).owner != __meself) \
+ { \
+ lll_lock ((_name).lock, LLL_PRIVATE); \
+ (_name).owner = __meself; \
+ } \
+ ++(_name).cnt; \
+ } while (0)
+
+#define _IO_lock_trylock(_name) \
+ ({ \
+ int __result = 0; \
+ void *__meself = THREAD_SELF; \
+ if ((_name).owner != __meself) \
+ { \
+ if (lll_trylock ((_name).lock) == 0) \
+ { \
+ (_name).owner = __meself; \
+ (_name).cnt = 1; \
+ } \
+ else \
+ __result = EBUSY; \
+ } \
+ else \
+ ++(_name).cnt; \
+ __result; \
+ })
+
+#define _IO_lock_unlock(_name) \
+ do { \
+ if (--(_name).cnt == 0) \
+ { \
+ (_name).owner = NULL; \
+ lll_unlock ((_name).lock, LLL_PRIVATE); \
+ } \
+ } while (0)
+
+
+
+#define _IO_cleanup_region_start(_fct, _fp) \
+ __libc_cleanup_region_start (((_fp)->_flags & _IO_USER_LOCK) == 0, _fct, _fp)
+#define _IO_cleanup_region_start_noarg(_fct) \
+ __libc_cleanup_region_start (1, _fct, NULL)
+#define _IO_cleanup_region_end(_doit) \
+ __libc_cleanup_region_end (_doit)
+
+#if defined _LIBC && !defined NOT_IN_libc
+
+# ifdef __EXCEPTIONS
+# define _IO_acquire_lock(_fp) \
+ do { \
+ _IO_FILE *_IO_acquire_lock_file \
+ __attribute__((cleanup (_IO_acquire_lock_fct))) \
+ = (_fp); \
+ _IO_flockfile (_IO_acquire_lock_file);
+# define _IO_acquire_lock_clear_flags2(_fp) \
+ do { \
+ _IO_FILE *_IO_acquire_lock_file \
+ __attribute__((cleanup (_IO_acquire_lock_clear_flags2_fct))) \
+ = (_fp); \
+ _IO_flockfile (_IO_acquire_lock_file);
+# else
+# define _IO_acquire_lock(_fp) _IO_acquire_lock_needs_exceptions_enabled
+# define _IO_acquire_lock_clear_flags2(_fp) _IO_acquire_lock (_fp)
+# endif
+# define _IO_release_lock(_fp) ; } while (0)
+
+#endif
+
+#endif /* bits/stdio-lock.h */
diff --git a/libpthread/nptl/sysdeps/pthread/createthread.c b/libpthread/nptl/sysdeps/pthread/createthread.c
new file mode 100644
index 000000000..74146ae95
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/createthread.c
@@ -0,0 +1,256 @@
+/* Copyright (C) 2002-2007, 2008 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <sched.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <atomic.h>
+#include <ldsodefs.h>
+#include <tls.h>
+
+#include <bits/kernel-features.h>
+
+
+#define CLONE_SIGNAL (CLONE_SIGHAND | CLONE_THREAD)
+
+/* Unless otherwise specified, the thread "register" is going to be
+ initialized with a pointer to the TCB. */
+#ifndef TLS_VALUE
+# define TLS_VALUE pd
+#endif
+
+#ifndef ARCH_CLONE
+# define ARCH_CLONE __clone
+#endif
+
+
+#ifndef TLS_MULTIPLE_THREADS_IN_TCB
+/* Pointer to the corresponding variable in libc. */
+int *__libc_multiple_threads_ptr attribute_hidden;
+#endif
+
+
+static int
+do_clone (struct pthread *pd, const struct pthread_attr *attr,
+ int clone_flags, int (*fct) (void *), STACK_VARIABLES_PARMS,
+ int stopped)
+{
+#ifdef PREPARE_CREATE
+ PREPARE_CREATE;
+#endif
+
+ if (__builtin_expect (stopped != 0, 0))
+ /* We make sure the thread does not run far by forcing it to get a
+ lock. We lock it here too so that the new thread cannot continue
+ until we tell it to. */
+ lll_lock (pd->lock, LLL_PRIVATE);
+
+ /* One more thread. We cannot have the thread do this itself, since it
+ might exist but not have been scheduled yet by the time we've returned
+ and need to check the value to behave correctly. We must do it before
+ creating the thread, in case it does get scheduled first and then
+ might mistakenly think it was the only thread. In the failure case,
+ we momentarily store a false value; this doesn't matter because there
+ is no kosher thing a signal handler interrupting us right here can do
+ that cares whether the thread count is correct. */
+ atomic_increment (&__nptl_nthreads);
+
+ if (ARCH_CLONE (fct, STACK_VARIABLES_ARGS, clone_flags,
+ pd, &pd->tid, TLS_VALUE, &pd->tid) == -1)
+ {
+ atomic_decrement (&__nptl_nthreads); /* Oops, we lied for a second. */
+
+ /* Failed. If the thread is detached, remove the TCB here since
+ the caller cannot do this. The caller remembered the thread
+ as detached and cannot reverify that it is not since it must
+ not access the thread descriptor again. */
+ if (IS_DETACHED (pd))
+ __deallocate_stack (pd);
+
+ /* We have to translate error codes. */
+ return errno == ENOMEM ? EAGAIN : errno;
+ }
+
+ /* Now we have the possibility to set scheduling parameters etc. */
+ if (__builtin_expect (stopped != 0, 0))
+ {
+ INTERNAL_SYSCALL_DECL (err);
+ int res = 0;
+
+ /* Set the affinity mask if necessary. */
+ if (attr->cpuset != NULL)
+ {
+ res = INTERNAL_SYSCALL (sched_setaffinity, err, 3, pd->tid,
+ attr->cpusetsize, attr->cpuset);
+
+ if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (res, err), 0))
+ {
+ /* The operation failed. We have to kill the thread. First
+ send it the cancellation signal. */
+ INTERNAL_SYSCALL_DECL (err2);
+ err_out:
+#if defined (__ASSUME_TGKILL) && __ASSUME_TGKILL
+ (void) INTERNAL_SYSCALL (tgkill, err2, 3,
+ THREAD_GETMEM (THREAD_SELF, pid),
+ pd->tid, SIGCANCEL);
+#else
+ (void) INTERNAL_SYSCALL (tkill, err2, 2, pd->tid, SIGCANCEL);
+#endif
+
+ return (INTERNAL_SYSCALL_ERROR_P (res, err)
+ ? INTERNAL_SYSCALL_ERRNO (res, err)
+ : 0);
+ }
+ }
+
+ /* Set the scheduling parameters. */
+ if ((attr->flags & ATTR_FLAG_NOTINHERITSCHED) != 0)
+ {
+ res = INTERNAL_SYSCALL (sched_setscheduler, err, 3, pd->tid,
+ pd->schedpolicy, &pd->schedparam);
+
+ if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (res, err), 0))
+ goto err_out;
+ }
+ }
+
+ /* We now have for sure more than one thread. The main thread might
+ not yet have the flag set. No need to set the global variable
+ again if this is what we use. */
+ THREAD_SETMEM (THREAD_SELF, header.multiple_threads, 1);
+
+ return 0;
+}
+
+
+static int
+create_thread (struct pthread *pd, const struct pthread_attr *attr,
+ STACK_VARIABLES_PARMS)
+{
+#ifdef TLS_TCB_AT_TP
+ assert (pd->header.tcb != NULL);
+#endif
+
+ /* We rely heavily on various flags the CLONE function understands:
+
+ CLONE_VM, CLONE_FS, CLONE_FILES
+ These flags select semantics with shared address space and
+ file descriptors according to what POSIX requires.
+
+ CLONE_SIGNAL
+ This flag selects the POSIX signal semantics.
+
+ CLONE_SETTLS
+ The sixth parameter to CLONE determines the TLS area for the
+ new thread.
+
+ CLONE_PARENT_SETTID
+ The kernels writes the thread ID of the newly created thread
+ into the location pointed to by the fifth parameters to CLONE.
+
+ Note that it would be semantically equivalent to use
+ CLONE_CHILD_SETTID but it is be more expensive in the kernel.
+
+ CLONE_CHILD_CLEARTID
+ The kernels clears the thread ID of a thread that has called
+ sys_exit() in the location pointed to by the seventh parameter
+ to CLONE.
+
+ CLONE_DETACHED
+ No signal is generated if the thread exists and it is
+ automatically reaped.
+
+ The termination signal is chosen to be zero which means no signal
+ is sent. */
+ int clone_flags = (CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGNAL
+ | CLONE_SETTLS | CLONE_PARENT_SETTID
+ | CLONE_CHILD_CLEARTID | CLONE_SYSVSEM
+#if __ASSUME_NO_CLONE_DETACHED == 0
+ | CLONE_DETACHED
+#endif
+ | 0);
+
+ if (__builtin_expect (THREAD_GETMEM (THREAD_SELF, report_events), 0))
+ {
+ /* The parent thread is supposed to report events. Check whether
+ the TD_CREATE event is needed, too. */
+ const int _idx = __td_eventword (TD_CREATE);
+ const uint32_t _mask = __td_eventmask (TD_CREATE);
+
+ if ((_mask & (__nptl_threads_events.event_bits[_idx]
+ | pd->eventbuf.eventmask.event_bits[_idx])) != 0)
+ {
+ /* We always must have the thread start stopped. */
+ pd->stopped_start = true;
+
+ /* Create the thread. We always create the thread stopped
+ so that it does not get far before we tell the debugger. */
+ int res = do_clone (pd, attr, clone_flags, start_thread,
+ STACK_VARIABLES_ARGS, 1);
+ if (res == 0)
+ {
+ /* Now fill in the information about the new thread in
+ the newly created thread's data structure. We cannot let
+ the new thread do this since we don't know whether it was
+ already scheduled when we send the event. */
+ pd->eventbuf.eventnum = TD_CREATE;
+ pd->eventbuf.eventdata = pd;
+
+ /* Enqueue the descriptor. */
+ do
+ pd->nextevent = __nptl_last_event;
+ while (atomic_compare_and_exchange_bool_acq (&__nptl_last_event,
+ pd, pd->nextevent)
+ != 0);
+
+ /* Now call the function which signals the event. */
+ __nptl_create_event ();
+
+ /* And finally restart the new thread. */
+ lll_unlock (pd->lock, LLL_PRIVATE);
+ }
+
+ return res;
+ }
+ }
+
+#ifdef NEED_DL_SYSINFO
+ assert (THREAD_SELF_SYSINFO == THREAD_SYSINFO (pd));
+#endif
+
+ /* Determine whether the newly created threads has to be started
+ stopped since we have to set the scheduling parameters or set the
+ affinity. */
+ bool stopped = false;
+ if (attr != NULL && (attr->cpuset != NULL
+ || (attr->flags & ATTR_FLAG_NOTINHERITSCHED) != 0))
+ stopped = true;
+ pd->stopped_start = stopped;
+ pd->parent_cancelhandling = THREAD_GETMEM (THREAD_SELF, cancelhandling);
+
+ /* Actually create the thread. */
+ int res = do_clone (pd, attr, clone_flags, start_thread,
+ STACK_VARIABLES_ARGS, stopped);
+
+ if (res == 0 && stopped)
+ /* And finally restart the new thread. */
+ lll_unlock (pd->lock, LLL_PRIVATE);
+
+ return res;
+}
diff --git a/libpthread/nptl/sysdeps/pthread/librt-cancellation.c b/libpthread/nptl/sysdeps/pthread/librt-cancellation.c
new file mode 100644
index 000000000..beb84e543
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/librt-cancellation.c
@@ -0,0 +1,24 @@
+/* Copyright (C) 2002, 2003, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 "pthreadP.h"
+
+
+#define __pthread_enable_asynccancel __librt_enable_asynccancel
+#define __pthread_disable_asynccancel __librt_disable_asynccancel
+#include "cancellation.c"
diff --git a/libpthread/nptl/sysdeps/pthread/list.h b/libpthread/nptl/sysdeps/pthread/list.h
new file mode 100644
index 000000000..3a5900bbf
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/list.h
@@ -0,0 +1,102 @@
+/* Copyright (C) 2002, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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/>. */
+
+#ifndef _LIST_H
+#define _LIST_H 1
+
+/* The definitions of this file are adopted from those which can be
+ found in the Linux kernel headers to enable people familiar with
+ the latter find their way in these sources as well. */
+
+
+/* Basic type for the double-link list. */
+typedef struct list_head
+{
+ struct list_head *next;
+ struct list_head *prev;
+} list_t;
+
+
+/* Define a variable with the head and tail of the list. */
+#define LIST_HEAD(name) \
+ list_t name = { &(name), &(name) }
+
+/* Initialize a new list head. */
+#define INIT_LIST_HEAD(ptr) \
+ (ptr)->next = (ptr)->prev = (ptr)
+
+
+/* Add new element at the head of the list. */
+static inline void
+list_add (list_t *newp, list_t *head)
+{
+ newp->next = head->next;
+ newp->prev = head;
+ head->next->prev = newp;
+ head->next = newp;
+}
+
+
+/* Remove element from list. */
+static inline void
+list_del (list_t *elem)
+{
+ elem->next->prev = elem->prev;
+ elem->prev->next = elem->next;
+}
+
+
+/* Join two lists. */
+static inline void
+list_splice (list_t *add, list_t *head)
+{
+ /* Do nothing if the list which gets added is empty. */
+ if (add != add->next)
+ {
+ add->next->prev = head;
+ add->prev->next = head->next;
+ head->next->prev = add->prev;
+ head->next = add->next;
+ }
+}
+
+
+/* Get typed element from list at a given position. */
+#define list_entry(ptr, type, member) \
+ ((type *) ((char *) (ptr) - (unsigned long) (&((type *) 0)->member)))
+
+
+
+/* Iterate forward over the elements of the list. */
+#define list_for_each(pos, head) \
+ for (pos = (head)->next; pos != (head); pos = pos->next)
+
+
+/* Iterate forward over the elements of the list. */
+#define list_for_each_prev(pos, head) \
+ for (pos = (head)->prev; pos != (head); pos = pos->prev)
+
+
+/* Iterate backwards over the elements list. The list elements can be
+ removed from the list while doing this. */
+#define list_for_each_prev_safe(pos, p, head) \
+ for (pos = (head)->prev, p = pos->prev; \
+ pos != (head); \
+ pos = p, p = pos->prev)
+
+#endif /* list.h */
diff --git a/libpthread/nptl/sysdeps/pthread/malloc-machine.h b/libpthread/nptl/sysdeps/pthread/malloc-machine.h
new file mode 100644
index 000000000..99b4999e2
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/malloc-machine.h
@@ -0,0 +1,72 @@
+/* Basic platform-independent macro definitions for mutexes,
+ thread-specific data and parameters for malloc.
+ Copyright (C) 2003, 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
+ 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 _MALLOC_MACHINE_H
+#define _MALLOC_MACHINE_H
+
+#undef thread_atfork_static
+
+#include <atomic.h>
+#include <bits/libc-lock.h>
+
+__libc_lock_define (typedef, mutex_t)
+
+#define mutex_init(m) __libc_lock_init (*(m))
+#define mutex_lock(m) __libc_lock_lock (*(m))
+#define mutex_trylock(m) __libc_lock_trylock (*(m))
+#define mutex_unlock(m) __libc_lock_unlock (*(m))
+
+/* This is defined by newer gcc version unique for each module. */
+extern void *__dso_handle __attribute__ ((__weak__));
+
+#include <fork.h>
+
+#define ATFORK_MEM static struct fork_handler atfork_mem
+
+#ifdef SHARED
+# define thread_atfork(prepare, parent, child) \
+ atfork_mem.prepare_handler = prepare; \
+ atfork_mem.parent_handler = parent; \
+ atfork_mem.child_handler = child; \
+ atfork_mem.dso_handle = __dso_handle; \
+ atfork_mem.refcntr = 1; \
+ __linkin_atfork (&atfork_mem)
+#else
+# define thread_atfork(prepare, parent, child) \
+ atfork_mem.prepare_handler = prepare; \
+ atfork_mem.parent_handler = parent; \
+ atfork_mem.child_handler = child; \
+ atfork_mem.dso_handle = &__dso_handle == NULL ? NULL : __dso_handle; \
+ atfork_mem.refcntr = 1; \
+ __linkin_atfork (&atfork_mem)
+#endif
+
+/* thread specific data for glibc */
+
+#include <bits/libc-tsd.h>
+
+typedef int tsd_key_t[1]; /* no key data structure, libc magic does it */
+__libc_tsd_define (static, void *, MALLOC) /* declaration/common definition */
+#define tsd_key_create(key, destr) ((void) (key))
+#define tsd_setspecific(key, data) __libc_tsd_set (void *, MALLOC, (data))
+#define tsd_getspecific(key, vptr) ((vptr) = __libc_tsd_get (void *, MALLOC))
+
+#include <sysdeps/generic/malloc-machine.h>
+
+#endif /* !defined(_MALLOC_MACHINE_H) */
diff --git a/libpthread/nptl/sysdeps/pthread/posix-timer.h b/libpthread/nptl/sysdeps/pthread/posix-timer.h
new file mode 100644
index 000000000..b1d8efca5
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/posix-timer.h
@@ -0,0 +1,196 @@
+/* Definitions for POSIX timer implementation on top of NPTL.
+ Copyright (C) 2000, 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Kaz Kylheku <kaz@ashi.footprints.net>.
+
+ 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/>. */
+
+#include <limits.h>
+#include <signal.h>
+
+/* Double linked list. */
+struct list_links
+{
+ struct list_links *next;
+ struct list_links *prev;
+};
+
+
+/* Forward declaration. */
+struct timer_node;
+
+
+/* Definitions for an internal thread of the POSIX timer implementation. */
+struct thread_node
+{
+ struct list_links links;
+ pthread_attr_t attr;
+ pthread_t id;
+ unsigned int exists;
+ struct list_links timer_queue;
+ pthread_cond_t cond;
+ struct timer_node *current_timer;
+ pthread_t captured;
+ clockid_t clock_id;
+};
+
+
+/* Internal representation of a timer. */
+struct timer_node
+{
+ struct list_links links;
+ struct sigevent event;
+ clockid_t clock;
+ struct itimerspec value;
+ struct timespec expirytime;
+ pthread_attr_t attr;
+ unsigned int abstime;
+ unsigned int armed;
+ enum {
+ TIMER_FREE, TIMER_INUSE, TIMER_DELETED
+ } inuse;
+ struct thread_node *thread;
+ pid_t creator_pid;
+ int refcount;
+ int overrun_count;
+};
+
+
+/* The limit is not published if we are compiled with kernel timer support.
+ But we still compiled in this implementation with its limit unless built
+ to require the kernel support. */
+#ifndef TIMER_MAX
+# define TIMER_MAX 256
+#endif
+
+/* Static array with the structures for all the timers. */
+extern struct timer_node __timer_array[TIMER_MAX];
+
+/* Global lock to protect operation on the lists. */
+extern pthread_mutex_t __timer_mutex;
+
+/* Variable to protext initialization. */
+extern pthread_once_t __timer_init_once_control;
+
+/* Nonzero if initialization of timer implementation failed. */
+extern int __timer_init_failed;
+
+/* Node for the thread used to deliver signals. */
+extern struct thread_node __timer_signal_thread_rclk;
+
+
+/* Return pointer to timer structure corresponding to ID. */
+#define timer_id2ptr(timerid) ((struct timer_node *) timerid)
+#define timer_ptr2id(timerid) ((void *) timerid)
+
+/* Check whether timer is valid; global mutex must be held. */
+static inline int
+timer_valid (struct timer_node *timer)
+{
+ return timer && timer->inuse == TIMER_INUSE;
+}
+
+/* Timer refcount functions; need global mutex. */
+extern void __timer_dealloc (struct timer_node *timer);
+
+static inline void
+timer_addref (struct timer_node *timer)
+{
+ timer->refcount++;
+}
+
+static inline void
+timer_delref (struct timer_node *timer)
+{
+ if (--timer->refcount == 0)
+ __timer_dealloc (timer);
+}
+
+/* Timespec helper routines. */
+static inline int
+__attribute ((always_inline))
+timespec_compare (const struct timespec *left, const struct timespec *right)
+{
+ if (left->tv_sec < right->tv_sec)
+ return -1;
+ if (left->tv_sec > right->tv_sec)
+ return 1;
+
+ if (left->tv_nsec < right->tv_nsec)
+ return -1;
+ if (left->tv_nsec > right->tv_nsec)
+ return 1;
+
+ return 0;
+}
+
+static inline void
+timespec_add (struct timespec *sum, const struct timespec *left,
+ const struct timespec *right)
+{
+ sum->tv_sec = left->tv_sec + right->tv_sec;
+ sum->tv_nsec = left->tv_nsec + right->tv_nsec;
+
+ if (sum->tv_nsec >= 1000000000)
+ {
+ ++sum->tv_sec;
+ sum->tv_nsec -= 1000000000;
+ }
+}
+
+static inline void
+timespec_sub (struct timespec *diff, const struct timespec *left,
+ const struct timespec *right)
+{
+ diff->tv_sec = left->tv_sec - right->tv_sec;
+ diff->tv_nsec = left->tv_nsec - right->tv_nsec;
+
+ if (diff->tv_nsec < 0)
+ {
+ --diff->tv_sec;
+ diff->tv_nsec += 1000000000;
+ }
+}
+
+
+/* We need one of the list functions in the other modules. */
+static inline void
+list_unlink_ip (struct list_links *list)
+{
+ struct list_links *lnext = list->next, *lprev = list->prev;
+
+ lnext->prev = lprev;
+ lprev->next = lnext;
+
+ /* The suffix ip means idempotent; list_unlink_ip can be called
+ * two or more times on the same node.
+ */
+
+ list->next = list;
+ list->prev = list;
+}
+
+
+/* Functions in the helper file. */
+extern void __timer_mutex_cancel_handler (void *arg);
+extern void __timer_init_once (void);
+extern struct timer_node *__timer_alloc (void);
+extern int __timer_thread_start (struct thread_node *thread);
+extern struct thread_node *__timer_thread_find_matching (const pthread_attr_t *desired_attr, clockid_t);
+extern struct thread_node *__timer_thread_alloc (const pthread_attr_t *desired_attr, clockid_t);
+extern void __timer_thread_dealloc (struct thread_node *thread);
+extern int __timer_thread_queue_timer (struct thread_node *thread,
+ struct timer_node *insert);
+extern void __timer_thread_wakeup (struct thread_node *thread);
diff --git a/libpthread/nptl/sysdeps/pthread/pt-initfini.c b/libpthread/nptl/sysdeps/pthread/pt-initfini.c
new file mode 100644
index 000000000..d9881c7a8
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/pt-initfini.c
@@ -0,0 +1,128 @@
+/* Special .init and .fini section support. Linuxthread version.
+ Copyright (C) 1995,1996,1997,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 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 Library 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 Lesser General 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/>. */
+
+/* This file is compiled into assembly code which is then munged by a sed
+ script into two files: crti.s and crtn.s.
+
+ * crti.s puts a function prologue at the beginning of the
+ .init and .fini sections and defines global symbols for
+ those addresses, so they can be called as functions.
+
+ * crtn.s puts the corresponding function epilogues
+ in the .init and .fini sections. */
+
+#include <stdlib.h>
+
+/* We use embedded asm for .section unconditionally, as this makes it
+ easier to insert the necessary directives into crtn.S. */
+#define SECTION(x) __asm__ (".section " x )
+
+/* Embed an #include to pull in the alignment and .end directives. */
+__asm__ ("\n#include \"defs.h\"");
+__asm__ ("\n#if defined __i686 && defined __ASSEMBLER__");
+__asm__ ("\n#undef __i686");
+__asm__ ("\n#define __i686 __i686");
+__asm__ ("\n#endif");
+
+/* The initial common code ends here. */
+__asm__ ("\n/*@HEADER_ENDS*/");
+
+/* To determine whether we need .end and .align: */
+__asm__ ("\n/*@TESTS_BEGIN*/");
+extern void dummy (void (*foo) (void));
+void
+dummy (void (*foo) (void))
+{
+ if (foo)
+ (*foo) ();
+}
+__asm__ ("\n/*@TESTS_END*/");
+
+/* The beginning of _init: */
+__asm__ ("\n/*@_init_PROLOG_BEGINS*/");
+
+static void
+call_initialize_minimal (void)
+{
+ extern void __pthread_initialize_minimal_internal (void)
+ __attribute ((visibility ("hidden")));
+
+ __pthread_initialize_minimal_internal ();
+}
+
+SECTION (".init");
+extern void __attribute__ ((section (".init"))) _init (void);
+void
+_init (void)
+{
+ /* The very first thing we must do is to set up the registers. */
+ call_initialize_minimal ();
+
+ __asm__ ("ALIGN");
+ __asm__("END_INIT");
+ /* Now the epilog. */
+ __asm__ ("\n/*@_init_PROLOG_ENDS*/");
+ __asm__ ("\n/*@_init_EPILOG_BEGINS*/");
+ SECTION(".init");
+}
+__asm__ ("END_INIT");
+
+/* End of the _init epilog, beginning of the _fini prolog. */
+__asm__ ("\n/*@_init_EPILOG_ENDS*/");
+__asm__ ("\n/*@_fini_PROLOG_BEGINS*/");
+
+SECTION (".fini");
+extern void __attribute__ ((section (".fini"))) _fini (void);
+void
+_fini (void)
+{
+
+ /* End of the _fini prolog. */
+ __asm__ ("ALIGN");
+ __asm__ ("END_FINI");
+ __asm__ ("\n/*@_fini_PROLOG_ENDS*/");
+
+ {
+ /* Let GCC know that _fini is not a leaf function by having a dummy
+ function call here. We arrange for this call to be omitted from
+ either crt file. */
+ extern void i_am_not_a_leaf (void);
+ i_am_not_a_leaf ();
+ }
+
+ /* Beginning of the _fini epilog. */
+ __asm__ ("\n/*@_fini_EPILOG_BEGINS*/");
+ SECTION (".fini");
+}
+__asm__ ("END_FINI");
+
+/* End of the _fini epilog. Any further generated assembly (e.g. .ident)
+ is shared between both crt files. */
+__asm__ ("\n/*@_fini_EPILOG_ENDS*/");
+__asm__ ("\n/*@TRAILER_BEGINS*/");
+
+/* End of file. */
diff --git a/libpthread/nptl/sysdeps/pthread/pt-longjmp.c b/libpthread/nptl/sysdeps/pthread/pt-longjmp.c
new file mode 100644
index 000000000..9fcea0478
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/pt-longjmp.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <setjmp.h>
+#include <stdlib.h>
+#include "pthreadP.h"
+
+extern __typeof(longjmp) __libc_longjmp attribute_noreturn;
+
+void
+longjmp (jmp_buf env, int val)
+{
+ __libc_longjmp (env, val);
+}
+weak_alias (longjmp, siglongjmp)
diff --git a/libpthread/nptl/sysdeps/pthread/pt-sigaction.c b/libpthread/nptl/sysdeps/pthread/pt-sigaction.c
new file mode 100644
index 000000000..43a2da213
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/pt-sigaction.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthreadP.h>
+#include <signal.h>
+
+/* We use the libc implementation but we tell it to not allow
+ SIGCANCEL or SIGTIMER to be handled. */
+
+extern __typeof(sigaction) __libc_sigaction;
+int
+__sigaction (int sig, const struct sigaction *act, struct sigaction *oact)
+{
+ if (unlikely (sig == SIGCANCEL || sig == SIGSETXID))
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ return __libc_sigaction (sig, act, oact);
+}
+libc_hidden_proto(sigaction)
+weak_alias (__sigaction, sigaction)
+libc_hidden_weak(sigaction)
diff --git a/libpthread/nptl/sysdeps/pthread/pthread-functions.h b/libpthread/nptl/sysdeps/pthread/pthread-functions.h
new file mode 100644
index 000000000..119fe6b71
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/pthread-functions.h
@@ -0,0 +1,116 @@
+/* Copyright (C) 2003, 2004, 2005, 2006, 2007 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/>. */
+
+#ifndef _PTHREAD_FUNCTIONS_H
+#define _PTHREAD_FUNCTIONS_H 1
+
+#include <pthread.h>
+#include <setjmp.h>
+#include <internaltypes.h>
+#include <sysdep.h>
+
+struct xid_command;
+
+/* Data type shared with libc. The libc uses it to pass on calls to
+ the thread functions. */
+struct pthread_functions
+{
+ int (*ptr_pthread_attr_destroy) (pthread_attr_t *);
+ int (*ptr___pthread_attr_init_2_0) (pthread_attr_t *);
+ int (*ptr___pthread_attr_init_2_1) (pthread_attr_t *);
+ int (*ptr_pthread_attr_getdetachstate) (const pthread_attr_t *, int *);
+ int (*ptr_pthread_attr_setdetachstate) (pthread_attr_t *, int);
+ int (*ptr_pthread_attr_getinheritsched) (const pthread_attr_t *, int *);
+ int (*ptr_pthread_attr_setinheritsched) (pthread_attr_t *, int);
+ int (*ptr_pthread_attr_getschedparam) (const pthread_attr_t *,
+ struct sched_param *);
+ int (*ptr_pthread_attr_setschedparam) (pthread_attr_t *,
+ const struct sched_param *);
+ int (*ptr_pthread_attr_getschedpolicy) (const pthread_attr_t *, int *);
+ int (*ptr_pthread_attr_setschedpolicy) (pthread_attr_t *, int);
+ int (*ptr_pthread_attr_getscope) (const pthread_attr_t *, int *);
+ int (*ptr_pthread_attr_setscope) (pthread_attr_t *, int);
+ int (*ptr_pthread_condattr_destroy) (pthread_condattr_t *);
+ int (*ptr_pthread_condattr_init) (pthread_condattr_t *);
+ int (*ptr___pthread_cond_broadcast) (pthread_cond_t *);
+ int (*ptr___pthread_cond_destroy) (pthread_cond_t *);
+ int (*ptr___pthread_cond_init) (pthread_cond_t *,
+ const pthread_condattr_t *);
+ int (*ptr___pthread_cond_signal) (pthread_cond_t *);
+ int (*ptr___pthread_cond_wait) (pthread_cond_t *, pthread_mutex_t *);
+ int (*ptr___pthread_cond_timedwait) (pthread_cond_t *, pthread_mutex_t *,
+ const struct timespec *);
+ int (*ptr___pthread_cond_broadcast_2_0) (pthread_cond_2_0_t *);
+ int (*ptr___pthread_cond_destroy_2_0) (pthread_cond_2_0_t *);
+ int (*ptr___pthread_cond_init_2_0) (pthread_cond_2_0_t *,
+ const pthread_condattr_t *);
+ int (*ptr___pthread_cond_signal_2_0) (pthread_cond_2_0_t *);
+ int (*ptr___pthread_cond_wait_2_0) (pthread_cond_2_0_t *, pthread_mutex_t *);
+ int (*ptr___pthread_cond_timedwait_2_0) (pthread_cond_2_0_t *,
+ pthread_mutex_t *,
+ const struct timespec *);
+ int (*ptr_pthread_equal) (pthread_t, pthread_t);
+ void (*ptr___pthread_exit) (void *);
+ int (*ptr_pthread_getschedparam) (pthread_t, int *, struct sched_param *);
+ int (*ptr_pthread_setschedparam) (pthread_t, int,
+ const struct sched_param *);
+ int (*ptr_pthread_mutex_destroy) (pthread_mutex_t *);
+ int (*ptr_pthread_mutex_init) (pthread_mutex_t *,
+ const pthread_mutexattr_t *);
+ int (*ptr_pthread_mutex_lock) (pthread_mutex_t *);
+ int (*ptr_pthread_mutex_unlock) (pthread_mutex_t *);
+ pthread_t (*ptr_pthread_self) (void);
+ int (*ptr_pthread_setcancelstate) (int, int *);
+ int (*ptr_pthread_setcanceltype) (int, int *);
+ void (*ptr___pthread_cleanup_upto) (__jmp_buf, char *);
+ int (*ptr___pthread_once) (pthread_once_t *, void (*) (void));
+ int (*ptr___pthread_rwlock_rdlock) (pthread_rwlock_t *);
+ int (*ptr___pthread_rwlock_wrlock) (pthread_rwlock_t *);
+ int (*ptr___pthread_rwlock_unlock) (pthread_rwlock_t *);
+ int (*ptr___pthread_key_create) (pthread_key_t *, void (*) (void *));
+ void *(*ptr___pthread_getspecific) (pthread_key_t);
+ int (*ptr___pthread_setspecific) (pthread_key_t, const void *);
+ void (*ptr__pthread_cleanup_push_defer) (struct _pthread_cleanup_buffer *,
+ void (*) (void *), void *);
+ void (*ptr__pthread_cleanup_pop_restore) (struct _pthread_cleanup_buffer *,
+ int);
+#define HAVE_PTR_NTHREADS
+ unsigned int *ptr_nthreads;
+ void (*ptr___pthread_unwind) (__pthread_unwind_buf_t *)
+ __attribute ((noreturn)) __cleanup_fct_attribute;
+ void (*ptr__nptl_deallocate_tsd) (void);
+ int (*ptr__nptl_setxid) (struct xid_command *);
+ void (*ptr_freeres) (void);
+};
+
+/* Variable in libc.so. */
+extern struct pthread_functions __libc_pthread_functions attribute_hidden;
+extern int __libc_pthread_functions_init attribute_hidden;
+
+#if 0 /* def PTR_DEMANGLE */ /* we did not mangle, so do not demangle */
+# define PTHFCT_CALL(fct, params) \
+ ({ __typeof (__libc_pthread_functions.fct) __p; \
+ __p = __libc_pthread_functions.fct; \
+ PTR_DEMANGLE (__p); \
+ __p params; })
+#else
+# define PTHFCT_CALL(fct, params) \
+ __libc_pthread_functions.fct params
+#endif
+
+#endif /* pthread-functions.h */
diff --git a/libpthread/nptl/sysdeps/pthread/pthread.h b/libpthread/nptl/sysdeps/pthread/pthread.h
new file mode 100644
index 000000000..4103a06ad
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/pthread.h
@@ -0,0 +1,1138 @@
+/* Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ 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 _PTHREAD_H
+#define _PTHREAD_H 1
+
+#include <features.h>
+#include <endian.h>
+#include <sched.h>
+#include <time.h>
+
+#define __need_sigset_t
+#include <signal.h>
+#include <bits/pthreadtypes.h>
+#include <bits/setjmp.h>
+#include <bits/wordsize.h>
+#if defined _LIBC && ( defined IS_IN_libc || defined NOT_IN_libc )
+#include <bits/uClibc_pthread.h>
+#endif
+
+
+/* Detach state. */
+enum
+{
+ PTHREAD_CREATE_JOINABLE,
+#define PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_JOINABLE
+ PTHREAD_CREATE_DETACHED
+#define PTHREAD_CREATE_DETACHED PTHREAD_CREATE_DETACHED
+};
+
+
+/* Mutex types. */
+enum
+{
+ PTHREAD_MUTEX_TIMED_NP,
+ PTHREAD_MUTEX_RECURSIVE_NP,
+ PTHREAD_MUTEX_ERRORCHECK_NP,
+ PTHREAD_MUTEX_ADAPTIVE_NP
+#if defined __USE_UNIX98 || defined __USE_XOPEN2K8
+ ,
+ PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_TIMED_NP,
+ PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP,
+ PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP,
+ PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL
+#endif
+#ifdef __USE_GNU
+ /* For compatibility. */
+ , PTHREAD_MUTEX_FAST_NP = PTHREAD_MUTEX_TIMED_NP
+#endif
+};
+
+
+#ifdef __USE_XOPEN2K
+/* Robust mutex or not flags. */
+enum
+{
+ PTHREAD_MUTEX_STALLED,
+ PTHREAD_MUTEX_STALLED_NP = PTHREAD_MUTEX_STALLED,
+ PTHREAD_MUTEX_ROBUST,
+ PTHREAD_MUTEX_ROBUST_NP = PTHREAD_MUTEX_ROBUST
+};
+#endif
+
+
+#ifdef __USE_UNIX98
+/* Mutex protocols. */
+enum
+{
+ PTHREAD_PRIO_NONE,
+ PTHREAD_PRIO_INHERIT,
+ PTHREAD_PRIO_PROTECT
+};
+#endif
+
+
+/* Mutex initializers. */
+#if __WORDSIZE == 64
+# define PTHREAD_MUTEX_INITIALIZER \
+ { { 0, 0, 0, 0, 0, 0, { 0, 0 } } }
+# ifdef __USE_GNU
+# define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \
+ { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, 0, { 0, 0 } } }
+# define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \
+ { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, 0, { 0, 0 } } }
+# define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \
+ { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, 0, { 0, 0 } } }
+# endif
+#else
+# define PTHREAD_MUTEX_INITIALIZER \
+ { { 0, 0, 0, 0, 0, { 0 } } }
+# ifdef __USE_GNU
+# define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \
+ { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, 0, { 0 } } }
+# define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \
+ { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, 0, { 0 } } }
+# define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \
+ { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, 0, { 0 } } }
+# endif
+#endif
+
+
+/* Read-write lock types. */
+#if defined __USE_UNIX98 || defined __USE_XOPEN2K
+enum
+{
+ PTHREAD_RWLOCK_PREFER_READER_NP,
+ PTHREAD_RWLOCK_PREFER_WRITER_NP,
+ PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,
+ PTHREAD_RWLOCK_DEFAULT_NP = PTHREAD_RWLOCK_PREFER_READER_NP
+};
+
+/* Read-write lock initializers. */
+# define PTHREAD_RWLOCK_INITIALIZER \
+ { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
+# ifdef __USE_GNU
+# if __WORDSIZE == 64
+# define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \
+ { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
+ PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
+# else
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+# define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \
+ { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP, \
+ 0, 0, 0, 0 } }
+# else
+# define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \
+ { { 0, 0, 0, 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,\
+ 0 } }
+# endif
+# endif
+# endif
+#endif /* Unix98 or XOpen2K */
+
+
+/* Scheduler inheritance. */
+enum
+{
+ PTHREAD_INHERIT_SCHED,
+#define PTHREAD_INHERIT_SCHED PTHREAD_INHERIT_SCHED
+ PTHREAD_EXPLICIT_SCHED
+#define PTHREAD_EXPLICIT_SCHED PTHREAD_EXPLICIT_SCHED
+};
+
+
+/* Scope handling. */
+enum
+{
+ PTHREAD_SCOPE_SYSTEM,
+#define PTHREAD_SCOPE_SYSTEM PTHREAD_SCOPE_SYSTEM
+ PTHREAD_SCOPE_PROCESS
+#define PTHREAD_SCOPE_PROCESS PTHREAD_SCOPE_PROCESS
+};
+
+
+/* Process shared or private flag. */
+enum
+{
+ PTHREAD_PROCESS_PRIVATE,
+#define PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE
+ PTHREAD_PROCESS_SHARED
+#define PTHREAD_PROCESS_SHARED PTHREAD_PROCESS_SHARED
+};
+
+
+
+/* Conditional variable handling. */
+#define PTHREAD_COND_INITIALIZER { { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }
+
+
+/* Cleanup buffers */
+struct _pthread_cleanup_buffer
+{
+ void (*__routine) (void *); /* Function to call. */
+ void *__arg; /* Its argument. */
+ int __canceltype; /* Saved cancellation type. */
+ struct _pthread_cleanup_buffer *__prev; /* Chaining of cleanup functions. */
+};
+
+/* Cancellation */
+enum
+{
+ PTHREAD_CANCEL_ENABLE,
+#define PTHREAD_CANCEL_ENABLE PTHREAD_CANCEL_ENABLE
+ PTHREAD_CANCEL_DISABLE
+#define PTHREAD_CANCEL_DISABLE PTHREAD_CANCEL_DISABLE
+};
+enum
+{
+ PTHREAD_CANCEL_DEFERRED,
+#define PTHREAD_CANCEL_DEFERRED PTHREAD_CANCEL_DEFERRED
+ PTHREAD_CANCEL_ASYNCHRONOUS
+#define PTHREAD_CANCEL_ASYNCHRONOUS PTHREAD_CANCEL_ASYNCHRONOUS
+};
+#define PTHREAD_CANCELED ((void *) -1)
+
+
+/* Single execution handling. */
+#define PTHREAD_ONCE_INIT 0
+
+
+#ifdef __USE_XOPEN2K
+/* Value returned by 'pthread_barrier_wait' for one of the threads after
+ the required number of threads have called this function.
+ -1 is distinct from 0 and all errno constants */
+# define PTHREAD_BARRIER_SERIAL_THREAD -1
+#endif
+
+
+__BEGIN_DECLS
+
+/* Create a new thread, starting with execution of START-ROUTINE
+ getting passed ARG. Creation attributed come from ATTR. The new
+ handle is stored in *NEWTHREAD. */
+extern int pthread_create (pthread_t *__restrict __newthread,
+ const pthread_attr_t *__restrict __attr,
+ void *(*__start_routine) (void *),
+ void *__restrict __arg) __THROWNL __nonnull ((1, 3));
+
+/* Terminate calling thread.
+
+ The registered cleanup handlers are called via exception handling
+ so we cannot mark this function with __THROW.*/
+extern void pthread_exit (void *__retval) __attribute__ ((__noreturn__));
+
+/* Make calling thread wait for termination of the thread TH. The
+ exit status of the thread is stored in *THREAD_RETURN, if THREAD_RETURN
+ is not NULL.
+
+ This function is a cancellation point and therefore not marked with
+ __THROW. */
+extern int pthread_join (pthread_t __th, void **__thread_return);
+
+#ifdef __USE_GNU
+/* Check whether thread TH has terminated. If yes return the status of
+ the thread in *THREAD_RETURN, if THREAD_RETURN is not NULL. */
+extern int pthread_tryjoin_np (pthread_t __th, void **__thread_return) __THROW;
+
+/* Make calling thread wait for termination of the thread TH, but only
+ until TIMEOUT. The exit status of the thread is stored in
+ *THREAD_RETURN, if THREAD_RETURN is not NULL.
+
+ This function is a cancellation point and therefore not marked with
+ __THROW. */
+extern int pthread_timedjoin_np (pthread_t __th, void **__thread_return,
+ const struct timespec *__abstime);
+#endif
+
+/* Indicate that the thread TH is never to be joined with PTHREAD_JOIN.
+ The resources of TH will therefore be freed immediately when it
+ terminates, instead of waiting for another thread to perform PTHREAD_JOIN
+ on it. */
+extern int pthread_detach (pthread_t __th) __THROW;
+
+
+/* Obtain the identifier of the current thread. */
+extern pthread_t pthread_self (void) __THROW __attribute__ ((__const__));
+
+/* Compare two thread identifiers. */
+extern int pthread_equal (pthread_t __thread1, pthread_t __thread2)
+ __THROW __attribute__ ((__const__));
+
+
+/* Thread attribute handling. */
+
+/* Initialize thread attribute *ATTR with default attributes
+ (detachstate is PTHREAD_JOINABLE, scheduling policy is SCHED_OTHER,
+ no user-provided stack). */
+extern int pthread_attr_init (pthread_attr_t *__attr) __THROW __nonnull ((1));
+
+/* Destroy thread attribute *ATTR. */
+extern int pthread_attr_destroy (pthread_attr_t *__attr)
+ __THROW __nonnull ((1));
+
+/* Get detach state attribute. */
+extern int pthread_attr_getdetachstate (const pthread_attr_t *__attr,
+ int *__detachstate)
+ __THROW __nonnull ((1, 2));
+
+/* Set detach state attribute. */
+extern int pthread_attr_setdetachstate (pthread_attr_t *__attr,
+ int __detachstate)
+ __THROW __nonnull ((1));
+
+
+/* Get the size of the guard area created for stack overflow protection. */
+extern int pthread_attr_getguardsize (const pthread_attr_t *__attr,
+ size_t *__guardsize)
+ __THROW __nonnull ((1, 2));
+
+/* Set the size of the guard area created for stack overflow protection. */
+extern int pthread_attr_setguardsize (pthread_attr_t *__attr,
+ size_t __guardsize)
+ __THROW __nonnull ((1));
+
+
+/* Return in *PARAM the scheduling parameters of *ATTR. */
+extern int pthread_attr_getschedparam (const pthread_attr_t *__restrict __attr,
+ struct sched_param *__restrict __param)
+ __THROW __nonnull ((1, 2));
+
+/* Set scheduling parameters (priority, etc) in *ATTR according to PARAM. */
+extern int pthread_attr_setschedparam (pthread_attr_t *__restrict __attr,
+ const struct sched_param *__restrict
+ __param) __THROW __nonnull ((1, 2));
+
+/* Return in *POLICY the scheduling policy of *ATTR. */
+extern int pthread_attr_getschedpolicy (const pthread_attr_t *__restrict
+ __attr, int *__restrict __policy)
+ __THROW __nonnull ((1, 2));
+
+/* Set scheduling policy in *ATTR according to POLICY. */
+extern int pthread_attr_setschedpolicy (pthread_attr_t *__attr, int __policy)
+ __THROW __nonnull ((1));
+
+/* Return in *INHERIT the scheduling inheritance mode of *ATTR. */
+extern int pthread_attr_getinheritsched (const pthread_attr_t *__restrict
+ __attr, int *__restrict __inherit)
+ __THROW __nonnull ((1, 2));
+
+/* Set scheduling inheritance mode in *ATTR according to INHERIT. */
+extern int pthread_attr_setinheritsched (pthread_attr_t *__attr,
+ int __inherit)
+ __THROW __nonnull ((1));
+
+
+/* Return in *SCOPE the scheduling contention scope of *ATTR. */
+extern int pthread_attr_getscope (const pthread_attr_t *__restrict __attr,
+ int *__restrict __scope)
+ __THROW __nonnull ((1, 2));
+
+/* Set scheduling contention scope in *ATTR according to SCOPE. */
+extern int pthread_attr_setscope (pthread_attr_t *__attr, int __scope)
+ __THROW __nonnull ((1));
+
+/* Return the previously set address for the stack. */
+extern int pthread_attr_getstackaddr (const pthread_attr_t *__restrict
+ __attr, void **__restrict __stackaddr)
+ __THROW __nonnull ((1, 2)) __attribute_deprecated__;
+
+/* Set the starting address of the stack of the thread to be created.
+ Depending on whether the stack grows up or down the value must either
+ be higher or lower than all the address in the memory block. The
+ minimal size of the block must be PTHREAD_STACK_MIN. */
+extern int pthread_attr_setstackaddr (pthread_attr_t *__attr,
+ void *__stackaddr)
+ __THROW __nonnull ((1)) __attribute_deprecated__;
+
+/* Return the currently used minimal stack size. */
+extern int pthread_attr_getstacksize (const pthread_attr_t *__restrict
+ __attr, size_t *__restrict __stacksize)
+ __THROW __nonnull ((1, 2));
+
+/* Add information about the minimum stack size needed for the thread
+ to be started. This size must never be less than PTHREAD_STACK_MIN
+ and must also not exceed the system limits. */
+extern int pthread_attr_setstacksize (pthread_attr_t *__attr,
+ size_t __stacksize)
+ __THROW __nonnull ((1));
+
+#ifdef __USE_XOPEN2K
+/* Return the previously set address for the stack. */
+extern int pthread_attr_getstack (const pthread_attr_t *__restrict __attr,
+ void **__restrict __stackaddr,
+ size_t *__restrict __stacksize)
+ __THROW __nonnull ((1, 2, 3));
+
+/* The following two interfaces are intended to replace the last two. They
+ require setting the address as well as the size since only setting the
+ address will make the implementation on some architectures impossible. */
+extern int pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr,
+ size_t __stacksize) __THROW __nonnull ((1));
+#endif
+
+#ifdef __USE_GNU
+/* Thread created with attribute ATTR will be limited to run only on
+ the processors represented in CPUSET. */
+extern int pthread_attr_setaffinity_np (pthread_attr_t *__attr,
+ size_t __cpusetsize,
+ const cpu_set_t *__cpuset)
+ __THROW __nonnull ((1, 3));
+
+/* Get bit set in CPUSET representing the processors threads created with
+ ATTR can run on. */
+extern int pthread_attr_getaffinity_np (const pthread_attr_t *__attr,
+ size_t __cpusetsize,
+ cpu_set_t *__cpuset)
+ __THROW __nonnull ((1, 3));
+
+
+/* Initialize thread attribute *ATTR with attributes corresponding to the
+ already running thread TH. It shall be called on uninitialized ATTR
+ and destroyed with pthread_attr_destroy when no longer needed. */
+extern int pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr)
+ __THROW __nonnull ((2));
+#endif
+
+
+/* Functions for scheduling control. */
+
+/* Set the scheduling parameters for TARGET_THREAD according to POLICY
+ and *PARAM. */
+extern int pthread_setschedparam (pthread_t __target_thread, int __policy,
+ const struct sched_param *__param)
+ __THROW __nonnull ((3));
+
+/* Return in *POLICY and *PARAM the scheduling parameters for TARGET_THREAD. */
+extern int pthread_getschedparam (pthread_t __target_thread,
+ int *__restrict __policy,
+ struct sched_param *__restrict __param)
+ __THROW __nonnull ((2, 3));
+
+/* Set the scheduling priority for TARGET_THREAD. */
+extern int pthread_setschedprio (pthread_t __target_thread, int __prio)
+ __THROW;
+
+
+#if defined __USE_UNIX98 && defined __UCLIBC_SUSV4_LEGACY__
+/* Determine level of concurrency. */
+extern int pthread_getconcurrency (void) __THROW;
+
+/* Set new concurrency level to LEVEL. */
+extern int pthread_setconcurrency (int __level) __THROW;
+#endif
+
+#ifdef __USE_GNU
+/* Yield the processor to another thread or process.
+ This function is similar to the POSIX `sched_yield' function but
+ might be differently implemented in the case of a m-on-n thread
+ implementation. */
+extern int pthread_yield (void) __THROW;
+
+
+/* Limit specified thread TH to run only on the processors represented
+ in CPUSET. */
+extern int pthread_setaffinity_np (pthread_t __th, size_t __cpusetsize,
+ const cpu_set_t *__cpuset)
+ __THROW __nonnull ((3));
+
+/* Get bit set in CPUSET representing the processors TH can run on. */
+extern int pthread_getaffinity_np (pthread_t __th, size_t __cpusetsize,
+ cpu_set_t *__cpuset)
+ __THROW __nonnull ((3));
+#endif
+
+
+/* Functions for handling initialization. */
+
+/* Guarantee that the initialization function INIT_ROUTINE will be called
+ only once, even if pthread_once is executed several times with the
+ same ONCE_CONTROL argument. ONCE_CONTROL must point to a static or
+ extern variable initialized to PTHREAD_ONCE_INIT.
+
+ The initialization functions might throw exception which is why
+ this function is not marked with __THROW. */
+extern int pthread_once (pthread_once_t *__once_control,
+ void (*__init_routine) (void)) __nonnull ((1, 2));
+
+
+/* Functions for handling cancellation.
+
+ Note that these functions are explicitly not marked to not throw an
+ exception in C++ code. If cancellation is implemented by unwinding
+ this is necessary to have the compiler generate the unwind information. */
+
+/* Set cancelability state of current thread to STATE, returning old
+ state in *OLDSTATE if OLDSTATE is not NULL. */
+extern int pthread_setcancelstate (int __state, int *__oldstate);
+
+/* Set cancellation state of current thread to TYPE, returning the old
+ type in *OLDTYPE if OLDTYPE is not NULL. */
+extern int pthread_setcanceltype (int __type, int *__oldtype);
+
+/* Cancel THREAD immediately or at the next possibility. */
+extern int pthread_cancel (pthread_t __th);
+
+/* Test for pending cancellation for the current thread and terminate
+ the thread as per pthread_exit(PTHREAD_CANCELED) if it has been
+ cancelled. */
+extern void pthread_testcancel (void);
+
+
+/* Cancellation handling with integration into exception handling. */
+
+typedef struct
+{
+ struct
+ {
+ __jmp_buf __cancel_jmp_buf;
+ int __mask_was_saved;
+ } __cancel_jmp_buf[1];
+ void *__pad[4];
+} __pthread_unwind_buf_t __attribute__ ((__aligned__));
+
+/* No special attributes by default. */
+#ifndef __cleanup_fct_attribute
+# define __cleanup_fct_attribute
+#endif
+
+
+/* Structure to hold the cleanup handler information. */
+struct __pthread_cleanup_frame
+{
+ void (*__cancel_routine) (void *);
+ void *__cancel_arg;
+ int __do_it;
+ int __cancel_type;
+};
+
+#if defined __GNUC__ && defined __EXCEPTIONS
+# ifdef __cplusplus
+/* Class to handle cancellation handler invocation. */
+class __pthread_cleanup_class
+{
+ void (*__cancel_routine) (void *);
+ void *__cancel_arg;
+ int __do_it;
+ int __cancel_type;
+
+ public:
+ __pthread_cleanup_class (void (*__fct) (void *), void *__arg)
+ : __cancel_routine (__fct), __cancel_arg (__arg), __do_it (1) { }
+ ~__pthread_cleanup_class () { if (__do_it) __cancel_routine (__cancel_arg); }
+ void __setdoit (int __newval) { __do_it = __newval; }
+ void __defer () { pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED,
+ &__cancel_type); }
+ void __restore () const { pthread_setcanceltype (__cancel_type, 0); }
+};
+
+/* Install a cleanup handler: ROUTINE will be called with arguments ARG
+ when the thread is canceled or calls pthread_exit. ROUTINE will also
+ be called with arguments ARG when the matching pthread_cleanup_pop
+ is executed with non-zero EXECUTE argument.
+
+ pthread_cleanup_push and pthread_cleanup_pop are macros and must always
+ be used in matching pairs at the same nesting level of braces. */
+# define pthread_cleanup_push(routine, arg) \
+ do { \
+ __pthread_cleanup_class __clframe (routine, arg)
+
+/* Remove a cleanup handler installed by the matching pthread_cleanup_push.
+ If EXECUTE is non-zero, the handler function is called. */
+# define pthread_cleanup_pop(execute) \
+ __clframe.__setdoit (execute); \
+ } while (0)
+
+# ifdef __USE_GNU
+/* Install a cleanup handler as pthread_cleanup_push does, but also
+ saves the current cancellation type and sets it to deferred
+ cancellation. */
+# define pthread_cleanup_push_defer_np(routine, arg) \
+ do { \
+ __pthread_cleanup_class __clframe (routine, arg); \
+ __clframe.__defer ()
+
+/* Remove a cleanup handler as pthread_cleanup_pop does, but also
+ restores the cancellation type that was in effect when the matching
+ pthread_cleanup_push_defer was called. */
+# define pthread_cleanup_pop_restore_np(execute) \
+ __clframe.__restore (); \
+ __clframe.__setdoit (execute); \
+ } while (0)
+# endif
+# else
+/* Function called to call the cleanup handler. As an extern inline
+ function the compiler is free to decide inlining the change when
+ needed or fall back on the copy which must exist somewhere
+ else. */
+void __pthread_cleanup_routine (struct __pthread_cleanup_frame *__frame);
+__extern_inline void
+__pthread_cleanup_routine (struct __pthread_cleanup_frame *__frame)
+{
+ if (__frame->__do_it)
+ __frame->__cancel_routine (__frame->__cancel_arg);
+}
+
+/* Install a cleanup handler: ROUTINE will be called with arguments ARG
+ when the thread is canceled or calls pthread_exit. ROUTINE will also
+ be called with arguments ARG when the matching pthread_cleanup_pop
+ is executed with non-zero EXECUTE argument.
+
+ pthread_cleanup_push and pthread_cleanup_pop are macros and must always
+ be used in matching pairs at the same nesting level of braces. */
+# define pthread_cleanup_push(routine, arg) \
+ do { \
+ struct __pthread_cleanup_frame __clframe \
+ __attribute__ ((__cleanup__ (__pthread_cleanup_routine))) \
+ = { .__cancel_routine = (routine), .__cancel_arg = (arg), \
+ .__do_it = 1 };
+
+/* Remove a cleanup handler installed by the matching pthread_cleanup_push.
+ If EXECUTE is non-zero, the handler function is called. */
+# define pthread_cleanup_pop(execute) \
+ __clframe.__do_it = (execute); \
+ } while (0)
+
+# ifdef __USE_GNU
+/* Install a cleanup handler as pthread_cleanup_push does, but also
+ saves the current cancellation type and sets it to deferred
+ cancellation. */
+# define pthread_cleanup_push_defer_np(routine, arg) \
+ do { \
+ struct __pthread_cleanup_frame __clframe \
+ __attribute__ ((__cleanup__ (__pthread_cleanup_routine))) \
+ = { .__cancel_routine = (routine), .__cancel_arg = (arg), \
+ .__do_it = 1 }; \
+ (void) pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, \
+ &__clframe.__cancel_type)
+
+/* Remove a cleanup handler as pthread_cleanup_pop does, but also
+ restores the cancellation type that was in effect when the matching
+ pthread_cleanup_push_defer was called. */
+# define pthread_cleanup_pop_restore_np(execute) \
+ (void) pthread_setcanceltype (__clframe.__cancel_type, NULL); \
+ __clframe.__do_it = (execute); \
+ } while (0)
+# endif
+# endif
+#else
+/* Install a cleanup handler: ROUTINE will be called with arguments ARG
+ when the thread is canceled or calls pthread_exit. ROUTINE will also
+ be called with arguments ARG when the matching pthread_cleanup_pop
+ is executed with non-zero EXECUTE argument.
+
+ pthread_cleanup_push and pthread_cleanup_pop are macros and must always
+ be used in matching pairs at the same nesting level of braces. */
+# define pthread_cleanup_push(routine, arg) \
+ do { \
+ __pthread_unwind_buf_t __cancel_buf; \
+ void (*__cancel_routine) (void *) = (routine); \
+ void *__cancel_arg = (arg); \
+ int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) \
+ __cancel_buf.__cancel_jmp_buf, 0); \
+ if (__builtin_expect (__not_first_call, 0)) \
+ { \
+ __cancel_routine (__cancel_arg); \
+ __pthread_unwind_next (&__cancel_buf); \
+ /* NOTREACHED */ \
+ } \
+ \
+ __pthread_register_cancel (&__cancel_buf); \
+ do {
+extern void __pthread_register_cancel (__pthread_unwind_buf_t *__buf)
+ __cleanup_fct_attribute;
+
+/* Remove a cleanup handler installed by the matching pthread_cleanup_push.
+ If EXECUTE is non-zero, the handler function is called. */
+# define pthread_cleanup_pop(execute) \
+ do { } while (0);/* Empty to allow label before pthread_cleanup_pop. */\
+ } while (0); \
+ __pthread_unregister_cancel (&__cancel_buf); \
+ if (execute) \
+ __cancel_routine (__cancel_arg); \
+ } while (0)
+extern void __pthread_unregister_cancel (__pthread_unwind_buf_t *__buf)
+ __cleanup_fct_attribute;
+
+# ifdef __USE_GNU
+/* Install a cleanup handler as pthread_cleanup_push does, but also
+ saves the current cancellation type and sets it to deferred
+ cancellation. */
+# define pthread_cleanup_push_defer_np(routine, arg) \
+ do { \
+ __pthread_unwind_buf_t __cancel_buf; \
+ void (*__cancel_routine) (void *) = (routine); \
+ void *__cancel_arg = (arg); \
+ int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) \
+ __cancel_buf.__cancel_jmp_buf, 0); \
+ if (__builtin_expect (__not_first_call, 0)) \
+ { \
+ __cancel_routine (__cancel_arg); \
+ __pthread_unwind_next (&__cancel_buf); \
+ /* NOTREACHED */ \
+ } \
+ \
+ __pthread_register_cancel_defer (&__cancel_buf); \
+ do {
+extern void __pthread_register_cancel_defer (__pthread_unwind_buf_t *__buf)
+ __cleanup_fct_attribute;
+
+/* Remove a cleanup handler as pthread_cleanup_pop does, but also
+ restores the cancellation type that was in effect when the matching
+ pthread_cleanup_push_defer was called. */
+# define pthread_cleanup_pop_restore_np(execute) \
+ do { } while (0);/* Empty to allow label before pthread_cleanup_pop. */\
+ } while (0); \
+ __pthread_unregister_cancel_restore (&__cancel_buf); \
+ if (execute) \
+ __cancel_routine (__cancel_arg); \
+ } while (0)
+extern void __pthread_unregister_cancel_restore (__pthread_unwind_buf_t *__buf)
+ __cleanup_fct_attribute;
+# endif
+
+/* Internal interface to initiate cleanup. */
+extern void __pthread_unwind_next (__pthread_unwind_buf_t *__buf)
+ __cleanup_fct_attribute __attribute__ ((__noreturn__))
+# ifndef SHARED
+ __attribute__ ((__weak__))
+# endif
+ ;
+#endif
+
+/* Function used in the macros. */
+struct __jmp_buf_tag;
+extern int __sigsetjmp (struct __jmp_buf_tag *__env, int __savemask) __THROWNL;
+
+
+/* Mutex handling. */
+
+/* Initialize a mutex. */
+extern int pthread_mutex_init (pthread_mutex_t *__mutex,
+ const pthread_mutexattr_t *__mutexattr)
+ __THROW __nonnull ((1));
+
+/* Destroy a mutex. */
+extern int pthread_mutex_destroy (pthread_mutex_t *__mutex)
+ __THROW __nonnull ((1));
+
+/* Try locking a mutex. */
+extern int pthread_mutex_trylock (pthread_mutex_t *__mutex)
+ __THROWNL __nonnull ((1));
+
+/* Lock a mutex. */
+extern int pthread_mutex_lock (pthread_mutex_t *__mutex)
+ __THROWNL __nonnull ((1));
+
+#ifdef __USE_XOPEN2K
+/* Wait until lock becomes available, or specified time passes. */
+extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex,
+ const struct timespec *__restrict
+ __abstime) __THROWNL __nonnull ((1, 2));
+#endif
+
+/* Unlock a mutex. */
+extern int pthread_mutex_unlock (pthread_mutex_t *__mutex)
+ __THROWNL __nonnull ((1));
+
+
+/* Get the priority ceiling of MUTEX. */
+extern int pthread_mutex_getprioceiling (const pthread_mutex_t *
+ __restrict __mutex,
+ int *__restrict __prioceiling)
+ __THROW __nonnull ((1, 2));
+
+/* Set the priority ceiling of MUTEX to PRIOCEILING, return old
+ priority ceiling value in *OLD_CEILING. */
+extern int pthread_mutex_setprioceiling (pthread_mutex_t *__restrict __mutex,
+ int __prioceiling,
+ int *__restrict __old_ceiling)
+ __THROW __nonnull ((1, 3));
+
+
+#ifdef __USE_XOPEN2K8
+/* Declare the state protected by MUTEX as consistent. */
+extern int pthread_mutex_consistent (pthread_mutex_t *__mutex)
+ __THROW __nonnull ((1));
+# ifdef __USE_GNU
+extern int pthread_mutex_consistent_np (pthread_mutex_t *__mutex)
+ __THROW __nonnull ((1));
+# endif
+#endif
+
+
+/* Functions for handling mutex attributes. */
+
+/* Initialize mutex attribute object ATTR with default attributes
+ (kind is PTHREAD_MUTEX_TIMED_NP). */
+extern int pthread_mutexattr_init (pthread_mutexattr_t *__attr)
+ __THROW __nonnull ((1));
+
+/* Destroy mutex attribute object ATTR. */
+extern int pthread_mutexattr_destroy (pthread_mutexattr_t *__attr)
+ __THROW __nonnull ((1));
+
+/* Get the process-shared flag of the mutex attribute ATTR. */
+extern int pthread_mutexattr_getpshared (const pthread_mutexattr_t *
+ __restrict __attr,
+ int *__restrict __pshared)
+ __THROW __nonnull ((1, 2));
+
+/* Set the process-shared flag of the mutex attribute ATTR. */
+extern int pthread_mutexattr_setpshared (pthread_mutexattr_t *__attr,
+ int __pshared)
+ __THROW __nonnull ((1));
+
+#if defined __USE_UNIX98 || defined __USE_XOPEN2K8
+/* Return in *KIND the mutex kind attribute in *ATTR. */
+extern int pthread_mutexattr_gettype (const pthread_mutexattr_t *__restrict
+ __attr, int *__restrict __kind)
+ __THROW __nonnull ((1, 2));
+
+/* Set the mutex kind attribute in *ATTR to KIND (either PTHREAD_MUTEX_NORMAL,
+ PTHREAD_MUTEX_RECURSIVE, PTHREAD_MUTEX_ERRORCHECK, or
+ PTHREAD_MUTEX_DEFAULT). */
+extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind)
+ __THROW __nonnull ((1));
+#endif
+
+/* Return in *PROTOCOL the mutex protocol attribute in *ATTR. */
+extern int pthread_mutexattr_getprotocol (const pthread_mutexattr_t *
+ __restrict __attr,
+ int *__restrict __protocol)
+ __THROW __nonnull ((1, 2));
+
+/* Set the mutex protocol attribute in *ATTR to PROTOCOL (either
+ PTHREAD_PRIO_NONE, PTHREAD_PRIO_INHERIT, or PTHREAD_PRIO_PROTECT). */
+extern int pthread_mutexattr_setprotocol (pthread_mutexattr_t *__attr,
+ int __protocol)
+ __THROW __nonnull ((1));
+
+/* Return in *PRIOCEILING the mutex prioceiling attribute in *ATTR. */
+extern int pthread_mutexattr_getprioceiling (const pthread_mutexattr_t *
+ __restrict __attr,
+ int *__restrict __prioceiling)
+ __THROW __nonnull ((1, 2));
+
+/* Set the mutex prioceiling attribute in *ATTR to PRIOCEILING. */
+extern int pthread_mutexattr_setprioceiling (pthread_mutexattr_t *__attr,
+ int __prioceiling)
+ __THROW __nonnull ((1));
+
+#ifdef __USE_XOPEN2K
+/* Get the robustness flag of the mutex attribute ATTR. */
+extern int pthread_mutexattr_getrobust (const pthread_mutexattr_t *__attr,
+ int *__robustness)
+ __THROW __nonnull ((1, 2));
+# ifdef __USE_GNU
+extern int pthread_mutexattr_getrobust_np (const pthread_mutexattr_t *__attr,
+ int *__robustness)
+ __THROW __nonnull ((1, 2));
+# endif
+
+/* Set the robustness flag of the mutex attribute ATTR. */
+extern int pthread_mutexattr_setrobust (pthread_mutexattr_t *__attr,
+ int __robustness)
+ __THROW __nonnull ((1));
+# ifdef __USE_GNU
+extern int pthread_mutexattr_setrobust_np (pthread_mutexattr_t *__attr,
+ int __robustness)
+ __THROW __nonnull ((1));
+# endif
+#endif
+
+
+#if defined __USE_UNIX98 || defined __USE_XOPEN2K
+/* Functions for handling read-write locks. */
+
+/* Initialize read-write lock RWLOCK using attributes ATTR, or use
+ the default values if later is NULL. */
+extern int pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock,
+ const pthread_rwlockattr_t *__restrict
+ __attr) __THROW __nonnull ((1));
+
+/* Destroy read-write lock RWLOCK. */
+extern int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock)
+ __THROW __nonnull ((1));
+
+/* Acquire read lock for RWLOCK. */
+extern int pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock)
+ __THROWNL __nonnull ((1));
+
+/* Try to acquire read lock for RWLOCK. */
+extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock)
+ __THROWNL __nonnull ((1));
+
+# ifdef __USE_XOPEN2K
+/* Try to acquire read lock for RWLOCK or return after specfied time. */
+extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock,
+ const struct timespec *__restrict
+ __abstime) __THROWNL __nonnull ((1, 2));
+# endif
+
+/* Acquire write lock for RWLOCK. */
+extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock)
+ __THROWNL __nonnull ((1));
+
+/* Try to acquire write lock for RWLOCK. */
+extern int pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock)
+ __THROWNL __nonnull ((1));
+
+# ifdef __USE_XOPEN2K
+/* Try to acquire write lock for RWLOCK or return after specfied time. */
+extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock,
+ const struct timespec *__restrict
+ __abstime) __THROWNL __nonnull ((1, 2));
+# endif
+
+/* Unlock RWLOCK. */
+extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock)
+ __THROWNL __nonnull ((1));
+
+
+/* Functions for handling read-write lock attributes. */
+
+/* Initialize attribute object ATTR with default values. */
+extern int pthread_rwlockattr_init (pthread_rwlockattr_t *__attr)
+ __THROW __nonnull ((1));
+
+/* Destroy attribute object ATTR. */
+extern int pthread_rwlockattr_destroy (pthread_rwlockattr_t *__attr)
+ __THROW __nonnull ((1));
+
+/* Return current setting of process-shared attribute of ATTR in PSHARED. */
+extern int pthread_rwlockattr_getpshared (const pthread_rwlockattr_t *
+ __restrict __attr,
+ int *__restrict __pshared)
+ __THROW __nonnull ((1, 2));
+
+/* Set process-shared attribute of ATTR to PSHARED. */
+extern int pthread_rwlockattr_setpshared (pthread_rwlockattr_t *__attr,
+ int __pshared)
+ __THROW __nonnull ((1));
+
+/* Return current setting of reader/writer preference. */
+extern int pthread_rwlockattr_getkind_np (const pthread_rwlockattr_t *
+ __restrict __attr,
+ int *__restrict __pref)
+ __THROW __nonnull ((1, 2));
+
+/* Set reader/write preference. */
+extern int pthread_rwlockattr_setkind_np (pthread_rwlockattr_t *__attr,
+ int __pref) __THROW __nonnull ((1));
+#endif
+
+
+/* Functions for handling conditional variables. */
+
+/* Initialize condition variable COND using attributes ATTR, or use
+ the default values if later is NULL. */
+extern int pthread_cond_init (pthread_cond_t *__restrict __cond,
+ const pthread_condattr_t *__restrict __cond_attr)
+ __THROW __nonnull ((1));
+
+/* Destroy condition variable COND. */
+extern int pthread_cond_destroy (pthread_cond_t *__cond)
+ __THROW __nonnull ((1));
+
+/* Wake up one thread waiting for condition variable COND. */
+extern int pthread_cond_signal (pthread_cond_t *__cond)
+ __THROWNL __nonnull ((1));
+
+/* Wake up all threads waiting for condition variables COND. */
+extern int pthread_cond_broadcast (pthread_cond_t *__cond)
+ __THROWNL __nonnull ((1));
+
+/* Wait for condition variable COND to be signaled or broadcast.
+ MUTEX is assumed to be locked before.
+
+ This function is a cancellation point and therefore not marked with
+ __THROW. */
+extern int pthread_cond_wait (pthread_cond_t *__restrict __cond,
+ pthread_mutex_t *__restrict __mutex)
+ __nonnull ((1, 2));
+
+/* Wait for condition variable COND to be signaled or broadcast until
+ ABSTIME. MUTEX is assumed to be locked before. ABSTIME is an
+ absolute time specification; zero is the beginning of the epoch
+ (00:00:00 GMT, January 1, 1970).
+
+ This function is a cancellation point and therefore not marked with
+ __THROW. */
+extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,
+ pthread_mutex_t *__restrict __mutex,
+ const struct timespec *__restrict __abstime)
+ __nonnull ((1, 2, 3));
+
+/* Functions for handling condition variable attributes. */
+
+/* Initialize condition variable attribute ATTR. */
+extern int pthread_condattr_init (pthread_condattr_t *__attr)
+ __THROW __nonnull ((1));
+
+/* Destroy condition variable attribute ATTR. */
+extern int pthread_condattr_destroy (pthread_condattr_t *__attr)
+ __THROW __nonnull ((1));
+
+/* Get the process-shared flag of the condition variable attribute ATTR. */
+extern int pthread_condattr_getpshared (const pthread_condattr_t *
+ __restrict __attr,
+ int *__restrict __pshared)
+ __THROW __nonnull ((1, 2));
+
+/* Set the process-shared flag of the condition variable attribute ATTR. */
+extern int pthread_condattr_setpshared (pthread_condattr_t *__attr,
+ int __pshared) __THROW __nonnull ((1));
+
+#ifdef __USE_XOPEN2K
+/* Get the clock selected for the condition variable attribute ATTR. */
+extern int pthread_condattr_getclock (const pthread_condattr_t *
+ __restrict __attr,
+ __clockid_t *__restrict __clock_id)
+ __THROW __nonnull ((1, 2));
+
+/* Set the clock selected for the condition variable attribute ATTR. */
+extern int pthread_condattr_setclock (pthread_condattr_t *__attr,
+ __clockid_t __clock_id)
+ __THROW __nonnull ((1));
+#endif
+
+
+#ifdef __USE_XOPEN2K
+/* Functions to handle spinlocks. */
+
+/* Initialize the spinlock LOCK. If PSHARED is nonzero the spinlock can
+ be shared between different processes. */
+extern int pthread_spin_init (pthread_spinlock_t *__lock, int __pshared)
+ __THROW __nonnull ((1));
+
+/* Destroy the spinlock LOCK. */
+extern int pthread_spin_destroy (pthread_spinlock_t *__lock)
+ __THROW __nonnull ((1));
+
+/* Wait until spinlock LOCK is retrieved. */
+extern int pthread_spin_lock (pthread_spinlock_t *__lock)
+ __THROWNL __nonnull ((1));
+
+/* Try to lock spinlock LOCK. */
+extern int pthread_spin_trylock (pthread_spinlock_t *__lock)
+ __THROWNL __nonnull ((1));
+
+/* Release spinlock LOCK. */
+extern int pthread_spin_unlock (pthread_spinlock_t *__lock)
+ __THROWNL __nonnull ((1));
+
+
+/* Functions to handle barriers. */
+
+/* Initialize BARRIER with the attributes in ATTR. The barrier is
+ opened when COUNT waiters arrived. */
+extern int pthread_barrier_init (pthread_barrier_t *__restrict __barrier,
+ const pthread_barrierattr_t *__restrict
+ __attr, unsigned int __count)
+ __THROW __nonnull ((1));
+
+/* Destroy a previously dynamically initialized barrier BARRIER. */
+extern int pthread_barrier_destroy (pthread_barrier_t *__barrier)
+ __THROW __nonnull ((1));
+
+/* Wait on barrier BARRIER. */
+extern int pthread_barrier_wait (pthread_barrier_t *__barrier)
+ __THROWNL __nonnull ((1));
+
+
+/* Initialize barrier attribute ATTR. */
+extern int pthread_barrierattr_init (pthread_barrierattr_t *__attr)
+ __THROW __nonnull ((1));
+
+/* Destroy previously dynamically initialized barrier attribute ATTR. */
+extern int pthread_barrierattr_destroy (pthread_barrierattr_t *__attr)
+ __THROW __nonnull ((1));
+
+/* Get the process-shared flag of the barrier attribute ATTR. */
+extern int pthread_barrierattr_getpshared (const pthread_barrierattr_t *
+ __restrict __attr,
+ int *__restrict __pshared)
+ __THROW __nonnull ((1, 2));
+
+/* Set the process-shared flag of the barrier attribute ATTR. */
+extern int pthread_barrierattr_setpshared (pthread_barrierattr_t *__attr,
+ int __pshared)
+ __THROW __nonnull ((1));
+#endif
+
+
+/* Functions for handling thread-specific data. */
+
+/* Create a key value identifying a location in the thread-specific
+ data area. Each thread maintains a distinct thread-specific data
+ area. DESTR_FUNCTION, if non-NULL, is called with the value
+ associated to that key when the key is destroyed.
+ DESTR_FUNCTION is not called if the value associated is NULL when
+ the key is destroyed. */
+extern int pthread_key_create (pthread_key_t *__key,
+ void (*__destr_function) (void *))
+ __THROW __nonnull ((1));
+
+/* Destroy KEY. */
+extern int pthread_key_delete (pthread_key_t __key) __THROW;
+
+/* Return current value of the thread-specific data slot identified by KEY. */
+extern void *pthread_getspecific (pthread_key_t __key) __THROW;
+
+/* Store POINTER in the thread-specific data slot identified by KEY. */
+extern int pthread_setspecific (pthread_key_t __key,
+ const void *__pointer) __THROW ;
+
+
+#ifdef __USE_XOPEN2K
+/* Get ID of CPU-time clock for thread THREAD_ID. */
+extern int pthread_getcpuclockid (pthread_t __thread_id,
+ __clockid_t *__clock_id)
+ __THROW __nonnull ((2));
+#endif
+
+
+/* Install handlers to be called when a new process is created with FORK.
+ The PREPARE handler is called in the parent process just before performing
+ FORK. The PARENT handler is called in the parent process just after FORK.
+ The CHILD handler is called in the child process. Each of the three
+ handlers can be NULL, meaning that no handler needs to be called at that
+ point.
+ PTHREAD_ATFORK can be called several times, in which case the PREPARE
+ handlers are called in LIFO order (last added with PTHREAD_ATFORK,
+ first called before FORK), and the PARENT and CHILD handlers are called
+ in FIFO (first added, first called). */
+
+extern int pthread_atfork (void (*__prepare) (void),
+ void (*__parent) (void),
+ void (*__child) (void)) __THROW;
+
+
+#ifdef __USE_EXTERN_INLINES
+/* Optimizations. */
+__extern_inline int
+__NTH (pthread_equal (pthread_t __thread1, pthread_t __thread2))
+{
+ return __thread1 == __thread2;
+}
+#endif
+
+__END_DECLS
+
+#endif /* pthread.h */
diff --git a/libpthread/nptl/sysdeps/pthread/pthread_barrier_destroy.c b/libpthread/nptl/sysdeps/pthread/pthread_barrier_destroy.c
new file mode 100644
index 000000000..2ef270bfd
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/pthread_barrier_destroy.c
@@ -0,0 +1,43 @@
+/* Copyright (C) 2002, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include "pthreadP.h"
+#include <lowlevellock.h>
+
+
+int
+pthread_barrier_destroy (
+ pthread_barrier_t *barrier)
+{
+ struct pthread_barrier *ibarrier;
+ int result = EBUSY;
+
+ ibarrier = (struct pthread_barrier *) barrier;
+
+ lll_lock (ibarrier->lock, ibarrier->private ^ FUTEX_PRIVATE_FLAG);
+
+ if (__builtin_expect (ibarrier->left == ibarrier->init_count, 1))
+ /* The barrier is not used anymore. */
+ result = 0;
+ else
+ /* Still used, return with an error. */
+ lll_unlock (ibarrier->lock, ibarrier->private ^ FUTEX_PRIVATE_FLAG);
+
+ return result;
+}
diff --git a/libpthread/nptl/sysdeps/pthread/pthread_barrier_init.c b/libpthread/nptl/sysdeps/pthread/pthread_barrier_init.c
new file mode 100644
index 000000000..be96ca842
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/pthread_barrier_init.c
@@ -0,0 +1,70 @@
+/* Copyright (C) 2002, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include "pthreadP.h"
+#include <lowlevellock.h>
+#include <bits/kernel-features.h>
+
+
+static const struct pthread_barrierattr default_attr =
+ {
+ .pshared = PTHREAD_PROCESS_PRIVATE
+ };
+
+
+int
+pthread_barrier_init (
+ pthread_barrier_t *barrier,
+ const pthread_barrierattr_t *attr,
+ unsigned int count)
+{
+ struct pthread_barrier *ibarrier;
+
+ if (__builtin_expect (count == 0, 0))
+ return EINVAL;
+
+ const struct pthread_barrierattr *iattr
+ = (attr != NULL
+ ? iattr = (struct pthread_barrierattr *) attr
+ : &default_attr);
+
+ if (iattr->pshared != PTHREAD_PROCESS_PRIVATE
+ && __builtin_expect (iattr->pshared != PTHREAD_PROCESS_SHARED, 0))
+ /* Invalid attribute. */
+ return EINVAL;
+
+ ibarrier = (struct pthread_barrier *) barrier;
+
+ /* Initialize the individual fields. */
+ ibarrier->lock = LLL_LOCK_INITIALIZER;
+ ibarrier->left = count;
+ ibarrier->init_count = count;
+ ibarrier->curr_event = 0;
+
+#ifdef __ASSUME_PRIVATE_FUTEX
+ ibarrier->private = (iattr->pshared != PTHREAD_PROCESS_PRIVATE
+ ? 0 : FUTEX_PRIVATE_FLAG);
+#else
+ ibarrier->private = (iattr->pshared != PTHREAD_PROCESS_PRIVATE
+ ? 0 : THREAD_GETMEM (THREAD_SELF,
+ header.private_futex));
+#endif
+
+ return 0;
+}
diff --git a/libpthread/nptl/sysdeps/pthread/pthread_barrier_wait.c b/libpthread/nptl/sysdeps/pthread/pthread_barrier_wait.c
new file mode 100644
index 000000000..9c16c7c08
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/pthread_barrier_wait.c
@@ -0,0 +1,78 @@
+/* Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Martin Schwidefsky <schwidefsky@de.ibm.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 <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <pthreadP.h>
+
+
+/* Wait on barrier. */
+int
+pthread_barrier_wait (
+ pthread_barrier_t *barrier)
+{
+ struct pthread_barrier *ibarrier = (struct pthread_barrier *) barrier;
+ int result = 0;
+
+ /* Make sure we are alone. */
+ lll_lock (ibarrier->lock, ibarrier->private ^ FUTEX_PRIVATE_FLAG);
+
+ /* One more arrival. */
+ --ibarrier->left;
+
+ /* Are these all? */
+ if (ibarrier->left == 0)
+ {
+ /* Yes. Increment the event counter to avoid invalid wake-ups and
+ tell the current waiters that it is their turn. */
+ ++ibarrier->curr_event;
+
+ /* Wake up everybody. */
+ lll_futex_wake (&ibarrier->curr_event, INT_MAX,
+ ibarrier->private ^ FUTEX_PRIVATE_FLAG);
+
+ /* This is the thread which finished the serialization. */
+ result = PTHREAD_BARRIER_SERIAL_THREAD;
+ }
+ else
+ {
+ /* The number of the event we are waiting for. The barrier's event
+ number must be bumped before we continue. */
+ unsigned int event = ibarrier->curr_event;
+
+ /* Before suspending, make the barrier available to others. */
+ lll_unlock (ibarrier->lock, ibarrier->private ^ FUTEX_PRIVATE_FLAG);
+
+ /* Wait for the event counter of the barrier to change. */
+ do
+ lll_futex_wait (&ibarrier->curr_event, event,
+ ibarrier->private ^ FUTEX_PRIVATE_FLAG);
+ while (event == ibarrier->curr_event);
+ }
+
+ /* Make sure the init_count is stored locally or in a register. */
+ unsigned int init_count = ibarrier->init_count;
+
+ /* If this was the last woken thread, unlock. */
+ if (atomic_increment_val (&ibarrier->left) == init_count)
+ /* We are done. */
+ lll_unlock (ibarrier->lock, ibarrier->private ^ FUTEX_PRIVATE_FLAG);
+
+ return result;
+}
diff --git a/libpthread/nptl/sysdeps/pthread/pthread_cond_broadcast.c b/libpthread/nptl/sysdeps/pthread/pthread_cond_broadcast.c
new file mode 100644
index 000000000..b5f925e98
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/pthread_cond_broadcast.c
@@ -0,0 +1,89 @@
+/* Copyright (C) 2003, 2004, 2006, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Martin Schwidefsky <schwidefsky@de.ibm.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 <endian.h>
+#include <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <pthread.h>
+#include <pthreadP.h>
+
+#include <bits/kernel-features.h>
+
+
+int
+attribute_protected
+__pthread_cond_broadcast (
+ pthread_cond_t *cond)
+{
+ int pshared = (cond->__data.__mutex == (void *) ~0l)
+ ? LLL_SHARED : LLL_PRIVATE;
+ /* Make sure we are alone. */
+ lll_lock (cond->__data.__lock, pshared);
+
+ /* Are there any waiters to be woken? */
+ if (cond->__data.__total_seq > cond->__data.__wakeup_seq)
+ {
+ /* Yes. Mark them all as woken. */
+ cond->__data.__wakeup_seq = cond->__data.__total_seq;
+ cond->__data.__woken_seq = cond->__data.__total_seq;
+ cond->__data.__futex = (unsigned int) cond->__data.__total_seq * 2;
+ int futex_val = cond->__data.__futex;
+ /* Signal that a broadcast happened. */
+ ++cond->__data.__broadcast_seq;
+
+ /* We are done. */
+ lll_unlock (cond->__data.__lock, pshared);
+
+ /* Do not use requeue for pshared condvars. */
+ if (cond->__data.__mutex == (void *) ~0l)
+ goto wake_all;
+
+ /* Wake everybody. */
+ pthread_mutex_t *mut = (pthread_mutex_t *) cond->__data.__mutex;
+
+ /* XXX: Kernel so far doesn't support requeue to PI futex. */
+ /* XXX: Kernel so far can only requeue to the same type of futex,
+ in this case private (we don't requeue for pshared condvars). */
+ if (__builtin_expect (mut->__data.__kind
+ & (PTHREAD_MUTEX_PRIO_INHERIT_NP
+ | PTHREAD_MUTEX_PSHARED_BIT), 0))
+ goto wake_all;
+
+ /* lll_futex_requeue returns 0 for success and non-zero
+ for errors. */
+ if (__builtin_expect (lll_futex_requeue (&cond->__data.__futex, 1,
+ INT_MAX, &mut->__data.__lock,
+ futex_val, LLL_PRIVATE), 0))
+ {
+ /* The requeue functionality is not available. */
+ wake_all:
+ lll_futex_wake (&cond->__data.__futex, INT_MAX, pshared);
+ }
+
+ /* That's all. */
+ return 0;
+ }
+
+ /* We are done. */
+ lll_unlock (cond->__data.__lock, pshared);
+
+ return 0;
+}
+
+weak_alias(__pthread_cond_broadcast, pthread_cond_broadcast)
diff --git a/libpthread/nptl/sysdeps/pthread/pthread_cond_signal.c b/libpthread/nptl/sysdeps/pthread/pthread_cond_signal.c
new file mode 100644
index 000000000..cc32314a0
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/pthread_cond_signal.c
@@ -0,0 +1,62 @@
+/* Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Martin Schwidefsky <schwidefsky@de.ibm.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 <endian.h>
+#include <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <pthread.h>
+#include <pthreadP.h>
+
+#include <bits/kernel-features.h>
+
+
+int
+attribute_protected
+__pthread_cond_signal (
+ pthread_cond_t *cond)
+{
+ int pshared = (cond->__data.__mutex == (void *) ~0l)
+ ? LLL_SHARED : LLL_PRIVATE;
+
+ /* Make sure we are alone. */
+ lll_lock (cond->__data.__lock, pshared);
+
+ /* Are there any waiters to be woken? */
+ if (cond->__data.__total_seq > cond->__data.__wakeup_seq)
+ {
+ /* Yes. Mark one of them as woken. */
+ ++cond->__data.__wakeup_seq;
+ ++cond->__data.__futex;
+
+ /* Wake one. */
+ if (! __builtin_expect (lll_futex_wake_unlock (&cond->__data.__futex, 1,
+ 1, &cond->__data.__lock,
+ pshared), 0))
+ return 0;
+
+ lll_futex_wake (&cond->__data.__futex, 1, pshared);
+ }
+
+ /* We are done. */
+ lll_unlock (cond->__data.__lock, pshared);
+
+ return 0;
+}
+
+weak_alias(__pthread_cond_signal, pthread_cond_signal)
diff --git a/libpthread/nptl/sysdeps/pthread/pthread_cond_timedwait.c b/libpthread/nptl/sysdeps/pthread/pthread_cond_timedwait.c
new file mode 100644
index 000000000..f06b69e2f
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/pthread_cond_timedwait.c
@@ -0,0 +1,217 @@
+/* Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Martin Schwidefsky <schwidefsky@de.ibm.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 <endian.h>
+#include <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <pthread.h>
+#include <pthreadP.h>
+#include <bits/kernel-features.h>
+
+
+/* Cleanup handler, defined in pthread_cond_wait.c. */
+extern void __condvar_cleanup (void *arg)
+ __attribute__ ((visibility ("hidden")));
+
+struct _condvar_cleanup_buffer
+{
+ int oldtype;
+ pthread_cond_t *cond;
+ pthread_mutex_t *mutex;
+ unsigned int bc_seq;
+};
+
+int
+attribute_protected
+__pthread_cond_timedwait (
+ pthread_cond_t *cond,
+ pthread_mutex_t *mutex,
+ const struct timespec *abstime)
+{
+ struct _pthread_cleanup_buffer buffer;
+ struct _condvar_cleanup_buffer cbuffer;
+ int result = 0;
+
+ /* Catch invalid parameters. */
+ if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
+ return EINVAL;
+
+ int pshared = (cond->__data.__mutex == (void *) ~0l)
+ ? LLL_SHARED : LLL_PRIVATE;
+
+ /* Make sure we are along. */
+ lll_lock (cond->__data.__lock, pshared);
+
+ /* Now we can release the mutex. */
+ int err = __pthread_mutex_unlock_usercnt (mutex, 0);
+ if (err)
+ {
+ lll_unlock (cond->__data.__lock, pshared);
+ return err;
+ }
+
+ /* We have one new user of the condvar. */
+ ++cond->__data.__total_seq;
+ ++cond->__data.__futex;
+ cond->__data.__nwaiters += 1 << COND_NWAITERS_SHIFT;
+
+ /* Remember the mutex we are using here. If there is already a
+ different address store this is a bad user bug. Do not store
+ anything for pshared condvars. */
+ if (cond->__data.__mutex != (void *) ~0l)
+ cond->__data.__mutex = mutex;
+
+ /* Prepare structure passed to cancellation handler. */
+ cbuffer.cond = cond;
+ cbuffer.mutex = mutex;
+
+ /* Before we block we enable cancellation. Therefore we have to
+ install a cancellation handler. */
+ __pthread_cleanup_push (&buffer, __condvar_cleanup, &cbuffer);
+
+ /* The current values of the wakeup counter. The "woken" counter
+ must exceed this value. */
+ unsigned long long int val;
+ unsigned long long int seq;
+ val = seq = cond->__data.__wakeup_seq;
+ /* Remember the broadcast counter. */
+ cbuffer.bc_seq = cond->__data.__broadcast_seq;
+
+ while (1)
+ {
+ struct timespec rt;
+ {
+#ifdef __NR_clock_gettime
+ INTERNAL_SYSCALL_DECL (err);
+# ifndef __ASSUME_POSIX_TIMERS
+ int ret =
+# endif
+ INTERNAL_SYSCALL (clock_gettime, err, 2,
+ (cond->__data.__nwaiters
+ & ((1 << COND_NWAITERS_SHIFT) - 1)),
+ &rt);
+# ifndef __ASSUME_POSIX_TIMERS
+ if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (ret, err), 0))
+ {
+ struct timeval tv;
+ (void) gettimeofday (&tv, NULL);
+
+ /* Convert the absolute timeout value to a relative timeout. */
+ rt.tv_sec = abstime->tv_sec - tv.tv_sec;
+ rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+ }
+ else
+# endif
+ {
+ /* Convert the absolute timeout value to a relative timeout. */
+ rt.tv_sec = abstime->tv_sec - rt.tv_sec;
+ rt.tv_nsec = abstime->tv_nsec - rt.tv_nsec;
+ }
+#else
+ /* Get the current time. So far we support only one clock. */
+ struct timeval tv;
+ (void) gettimeofday (&tv, NULL);
+
+ /* Convert the absolute timeout value to a relative timeout. */
+ rt.tv_sec = abstime->tv_sec - tv.tv_sec;
+ rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+#endif
+ }
+ if (rt.tv_nsec < 0)
+ {
+ rt.tv_nsec += 1000000000;
+ --rt.tv_sec;
+ }
+ /* Did we already time out? */
+ if (__builtin_expect (rt.tv_sec < 0, 0))
+ {
+ if (cbuffer.bc_seq != cond->__data.__broadcast_seq)
+ goto bc_out;
+
+ goto timeout;
+ }
+
+ unsigned int futex_val = cond->__data.__futex;
+
+ /* Prepare to wait. Release the condvar futex. */
+ lll_unlock (cond->__data.__lock, pshared);
+
+ /* Enable asynchronous cancellation. Required by the standard. */
+ cbuffer.oldtype = __pthread_enable_asynccancel ();
+
+ /* Wait until woken by signal or broadcast. */
+ err = lll_futex_timed_wait (&cond->__data.__futex,
+ futex_val, &rt, pshared);
+
+ /* Disable asynchronous cancellation. */
+ __pthread_disable_asynccancel (cbuffer.oldtype);
+
+ /* We are going to look at shared data again, so get the lock. */
+ lll_lock (cond->__data.__lock, pshared);
+
+ /* If a broadcast happened, we are done. */
+ if (cbuffer.bc_seq != cond->__data.__broadcast_seq)
+ goto bc_out;
+
+ /* Check whether we are eligible for wakeup. */
+ val = cond->__data.__wakeup_seq;
+ if (val != seq && cond->__data.__woken_seq != val)
+ break;
+
+ /* Not woken yet. Maybe the time expired? */
+ if (__builtin_expect (err == -ETIMEDOUT, 0))
+ {
+ timeout:
+ /* Yep. Adjust the counters. */
+ ++cond->__data.__wakeup_seq;
+ ++cond->__data.__futex;
+
+ /* The error value. */
+ result = ETIMEDOUT;
+ break;
+ }
+ }
+
+ /* Another thread woken up. */
+ ++cond->__data.__woken_seq;
+
+ bc_out:
+
+ cond->__data.__nwaiters -= 1 << COND_NWAITERS_SHIFT;
+
+ /* If pthread_cond_destroy was called on this variable already,
+ notify the pthread_cond_destroy caller all waiters have left
+ and it can be successfully destroyed. */
+ if (cond->__data.__total_seq == -1ULL
+ && cond->__data.__nwaiters < (1 << COND_NWAITERS_SHIFT))
+ lll_futex_wake (&cond->__data.__nwaiters, 1, pshared);
+
+ /* We are done with the condvar. */
+ lll_unlock (cond->__data.__lock, pshared);
+
+ /* The cancellation handling is back to normal, remove the handler. */
+ __pthread_cleanup_pop (&buffer, 0);
+
+ /* Get the mutex before returning. */
+ err = __pthread_mutex_cond_lock (mutex);
+
+ return err ?: result;
+}
+
+weak_alias(__pthread_cond_timedwait, pthread_cond_timedwait)
diff --git a/libpthread/nptl/sysdeps/pthread/pthread_cond_wait.c b/libpthread/nptl/sysdeps/pthread/pthread_cond_wait.c
new file mode 100644
index 000000000..c59e110bc
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/pthread_cond_wait.c
@@ -0,0 +1,192 @@
+/* Copyright (C) 2003, 2004, 2006, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Martin Schwidefsky <schwidefsky@de.ibm.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 <endian.h>
+#include <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <pthread.h>
+#include <pthreadP.h>
+
+
+struct _condvar_cleanup_buffer
+{
+ int oldtype;
+ pthread_cond_t *cond;
+ pthread_mutex_t *mutex;
+ unsigned int bc_seq;
+};
+
+
+void
+__attribute__ ((visibility ("hidden")))
+__condvar_cleanup (void *arg)
+{
+ struct _condvar_cleanup_buffer *cbuffer =
+ (struct _condvar_cleanup_buffer *) arg;
+ unsigned int destroying;
+ int pshared = (cbuffer->cond->__data.__mutex == (void *) ~0l)
+ ? LLL_SHARED : LLL_PRIVATE;
+
+ /* We are going to modify shared data. */
+ lll_lock (cbuffer->cond->__data.__lock, pshared);
+
+ if (cbuffer->bc_seq == cbuffer->cond->__data.__broadcast_seq)
+ {
+ /* This thread is not waiting anymore. Adjust the sequence counters
+ appropriately. We do not increment WAKEUP_SEQ if this would
+ bump it over the value of TOTAL_SEQ. This can happen if a thread
+ was woken and then canceled. */
+ if (cbuffer->cond->__data.__wakeup_seq
+ < cbuffer->cond->__data.__total_seq)
+ {
+ ++cbuffer->cond->__data.__wakeup_seq;
+ ++cbuffer->cond->__data.__futex;
+ }
+ ++cbuffer->cond->__data.__woken_seq;
+ }
+
+ cbuffer->cond->__data.__nwaiters -= 1 << COND_NWAITERS_SHIFT;
+
+ /* If pthread_cond_destroy was called on this variable already,
+ notify the pthread_cond_destroy caller all waiters have left
+ and it can be successfully destroyed. */
+ destroying = 0;
+ if (cbuffer->cond->__data.__total_seq == -1ULL
+ && cbuffer->cond->__data.__nwaiters < (1 << COND_NWAITERS_SHIFT))
+ {
+ lll_futex_wake (&cbuffer->cond->__data.__nwaiters, 1, pshared);
+ destroying = 1;
+ }
+
+ /* We are done. */
+ lll_unlock (cbuffer->cond->__data.__lock, pshared);
+
+ /* Wake everybody to make sure no condvar signal gets lost. */
+ if (! destroying)
+ lll_futex_wake (&cbuffer->cond->__data.__futex, INT_MAX, pshared);
+
+ /* Get the mutex before returning unless asynchronous cancellation
+ is in effect. */
+ __pthread_mutex_cond_lock (cbuffer->mutex);
+}
+
+
+int
+attribute_protected
+__pthread_cond_wait (
+ pthread_cond_t *cond,
+ pthread_mutex_t *mutex)
+{
+ struct _pthread_cleanup_buffer buffer;
+ struct _condvar_cleanup_buffer cbuffer;
+ int err;
+ int pshared = (cond->__data.__mutex == (void *) ~0l)
+ ? LLL_SHARED : LLL_PRIVATE;
+
+ /* Make sure we are along. */
+ lll_lock (cond->__data.__lock, pshared);
+
+ /* Now we can release the mutex. */
+ err = __pthread_mutex_unlock_usercnt (mutex, 0);
+ if (__builtin_expect (err, 0))
+ {
+ lll_unlock (cond->__data.__lock, pshared);
+ return err;
+ }
+
+ /* We have one new user of the condvar. */
+ ++cond->__data.__total_seq;
+ ++cond->__data.__futex;
+ cond->__data.__nwaiters += 1 << COND_NWAITERS_SHIFT;
+
+ /* Remember the mutex we are using here. If there is already a
+ different address store this is a bad user bug. Do not store
+ anything for pshared condvars. */
+ if (cond->__data.__mutex != (void *) ~0l)
+ cond->__data.__mutex = mutex;
+
+ /* Prepare structure passed to cancellation handler. */
+ cbuffer.cond = cond;
+ cbuffer.mutex = mutex;
+
+ /* Before we block we enable cancellation. Therefore we have to
+ install a cancellation handler. */
+ __pthread_cleanup_push (&buffer, __condvar_cleanup, &cbuffer);
+
+ /* The current values of the wakeup counter. The "woken" counter
+ must exceed this value. */
+ unsigned long long int val;
+ unsigned long long int seq;
+ val = seq = cond->__data.__wakeup_seq;
+ /* Remember the broadcast counter. */
+ cbuffer.bc_seq = cond->__data.__broadcast_seq;
+
+ do
+ {
+ unsigned int futex_val = cond->__data.__futex;
+
+ /* Prepare to wait. Release the condvar futex. */
+ lll_unlock (cond->__data.__lock, pshared);
+
+ /* Enable asynchronous cancellation. Required by the standard. */
+ cbuffer.oldtype = __pthread_enable_asynccancel ();
+
+ /* Wait until woken by signal or broadcast. */
+ lll_futex_wait (&cond->__data.__futex, futex_val, pshared);
+
+ /* Disable asynchronous cancellation. */
+ __pthread_disable_asynccancel (cbuffer.oldtype);
+
+ /* We are going to look at shared data again, so get the lock. */
+ lll_lock (cond->__data.__lock, pshared);
+
+ /* If a broadcast happened, we are done. */
+ if (cbuffer.bc_seq != cond->__data.__broadcast_seq)
+ goto bc_out;
+
+ /* Check whether we are eligible for wakeup. */
+ val = cond->__data.__wakeup_seq;
+ }
+ while (val == seq || cond->__data.__woken_seq == val);
+
+ /* Another thread woken up. */
+ ++cond->__data.__woken_seq;
+
+ bc_out:
+
+ cond->__data.__nwaiters -= 1 << COND_NWAITERS_SHIFT;
+
+ /* If pthread_cond_destroy was called on this varaible already,
+ notify the pthread_cond_destroy caller all waiters have left
+ and it can be successfully destroyed. */
+ if (cond->__data.__total_seq == -1ULL
+ && cond->__data.__nwaiters < (1 << COND_NWAITERS_SHIFT))
+ lll_futex_wake (&cond->__data.__nwaiters, 1, pshared);
+
+ /* We are done with the condvar. */
+ lll_unlock (cond->__data.__lock, pshared);
+
+ /* The cancellation handling is back to normal, remove the handler. */
+ __pthread_cleanup_pop (&buffer, 0);
+
+ /* Get the mutex before returning. */
+ return __pthread_mutex_cond_lock (mutex);
+}
+
+weak_alias(__pthread_cond_wait, pthread_cond_wait)
diff --git a/libpthread/nptl/sysdeps/pthread/pthread_once.c b/libpthread/nptl/sysdeps/pthread/pthread_once.c
new file mode 100644
index 000000000..d20847181
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/pthread_once.c
@@ -0,0 +1,53 @@
+/* Copyright (C) 2002, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 "pthreadP.h"
+#include <lowlevellock.h>
+
+
+
+static int once_lock = LLL_LOCK_INITIALIZER;
+
+
+int
+__pthread_once (
+ pthread_once_t *once_control,
+ void (*init_routine) (void))
+{
+ /* XXX Depending on whether the LOCK_IN_ONCE_T is defined use a
+ global lock variable or one which is part of the pthread_once_t
+ object. */
+ if (*once_control == PTHREAD_ONCE_INIT)
+ {
+ lll_lock (once_lock, LLL_PRIVATE);
+
+ /* XXX This implementation is not complete. It doesn't take
+ cancellation and fork into account. */
+ if (*once_control == PTHREAD_ONCE_INIT)
+ {
+ init_routine ();
+
+ *once_control = !PTHREAD_ONCE_INIT;
+ }
+
+ lll_unlock (once_lock, LLL_PRIVATE);
+ }
+
+ return 0;
+}
+strong_alias (__pthread_once, pthread_once)
diff --git a/libpthread/nptl/sysdeps/pthread/pthread_rwlock_rdlock.c b/libpthread/nptl/sysdeps/pthread/pthread_rwlock_rdlock.c
new file mode 100644
index 000000000..21bcd6bf3
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/pthread_rwlock_rdlock.c
@@ -0,0 +1,96 @@
+/* Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Martin Schwidefsky <schwidefsky@de.ibm.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 <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <pthread.h>
+#include <pthreadP.h>
+
+
+/* Acquire read lock for RWLOCK. */
+int
+attribute_protected
+__pthread_rwlock_rdlock (
+ pthread_rwlock_t *rwlock)
+{
+ int result = 0;
+
+ /* Make sure we are along. */
+ lll_lock (rwlock->__data.__lock, rwlock->__data.__shared);
+
+ while (1)
+ {
+ /* Get the rwlock if there is no writer... */
+ if (rwlock->__data.__writer == 0
+ /* ...and if either no writer is waiting or we prefer readers. */
+ && (!rwlock->__data.__nr_writers_queued
+ || PTHREAD_RWLOCK_PREFER_READER_P (rwlock)))
+ {
+ /* Increment the reader counter. Avoid overflow. */
+ if (__builtin_expect (++rwlock->__data.__nr_readers == 0, 0))
+ {
+ /* Overflow on number of readers. */
+ --rwlock->__data.__nr_readers;
+ result = EAGAIN;
+ }
+
+ break;
+ }
+
+ /* Make sure we are not holding the rwlock as a writer. This is
+ a deadlock situation we recognize and report. */
+ if (__builtin_expect (rwlock->__data.__writer
+ == THREAD_GETMEM (THREAD_SELF, tid), 0))
+ {
+ result = EDEADLK;
+ break;
+ }
+
+ /* Remember that we are a reader. */
+ if (__builtin_expect (++rwlock->__data.__nr_readers_queued == 0, 0))
+ {
+ /* Overflow on number of queued readers. */
+ --rwlock->__data.__nr_readers_queued;
+ result = EAGAIN;
+ break;
+ }
+
+ int waitval = rwlock->__data.__readers_wakeup;
+
+ /* Free the lock. */
+ lll_unlock (rwlock->__data.__lock, rwlock->__data.__shared);
+
+ /* Wait for the writer to finish. */
+ lll_futex_wait (&rwlock->__data.__readers_wakeup, waitval,
+ rwlock->__data.__shared);
+
+ /* Get the lock. */
+ lll_lock (rwlock->__data.__lock, rwlock->__data.__shared);
+
+ --rwlock->__data.__nr_readers_queued;
+ }
+
+ /* We are done, free the lock. */
+ lll_unlock (rwlock->__data.__lock, rwlock->__data.__shared);
+
+ return result;
+}
+
+weak_alias (__pthread_rwlock_rdlock, pthread_rwlock_rdlock)
+strong_alias (__pthread_rwlock_rdlock, __pthread_rwlock_rdlock_internal)
diff --git a/libpthread/nptl/sysdeps/pthread/pthread_rwlock_timedrdlock.c b/libpthread/nptl/sysdeps/pthread/pthread_rwlock_timedrdlock.c
new file mode 100644
index 000000000..596f5df51
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/pthread_rwlock_timedrdlock.c
@@ -0,0 +1,136 @@
+/* Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Martin Schwidefsky <schwidefsky@de.ibm.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 <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <pthread.h>
+#include <pthreadP.h>
+
+
+/* Try to acquire read lock for RWLOCK or return after specfied time. */
+int
+pthread_rwlock_timedrdlock (
+ pthread_rwlock_t *rwlock,
+ const struct timespec *abstime)
+{
+ int result = 0;
+
+ /* Make sure we are along. */
+ lll_lock(rwlock->__data.__lock, rwlock->__data.__shared);
+
+ while (1)
+ {
+ int err;
+
+ /* Get the rwlock if there is no writer... */
+ if (rwlock->__data.__writer == 0
+ /* ...and if either no writer is waiting or we prefer readers. */
+ && (!rwlock->__data.__nr_writers_queued
+ || PTHREAD_RWLOCK_PREFER_READER_P (rwlock)))
+ {
+ /* Increment the reader counter. Avoid overflow. */
+ if (++rwlock->__data.__nr_readers == 0)
+ {
+ /* Overflow on number of readers. */
+ --rwlock->__data.__nr_readers;
+ result = EAGAIN;
+ }
+
+ break;
+ }
+
+ /* Make sure we are not holding the rwlock as a writer. This is
+ a deadlock situation we recognize and report. */
+ if (__builtin_expect (rwlock->__data.__writer
+ == THREAD_GETMEM (THREAD_SELF, tid), 0))
+ {
+ result = EDEADLK;
+ break;
+ }
+
+ /* Make sure the passed in timeout value is valid. Ideally this
+ test would be executed once. But since it must not be
+ performed if we would not block at all simply moving the test
+ to the front is no option. Replicating all the code is
+ costly while this test is not. */
+ if (__builtin_expect (abstime->tv_nsec >= 1000000000
+ || abstime->tv_nsec < 0, 0))
+ {
+ result = EINVAL;
+ break;
+ }
+
+ /* Get the current time. So far we support only one clock. */
+ struct timeval tv;
+ (void) gettimeofday (&tv, NULL);
+
+ /* Convert the absolute timeout value to a relative timeout. */
+ struct timespec rt;
+ rt.tv_sec = abstime->tv_sec - tv.tv_sec;
+ rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+ if (rt.tv_nsec < 0)
+ {
+ rt.tv_nsec += 1000000000;
+ --rt.tv_sec;
+ }
+ /* Did we already time out? */
+ if (rt.tv_sec < 0)
+ {
+ /* Yep, return with an appropriate error. */
+ result = ETIMEDOUT;
+ break;
+ }
+
+ /* Remember that we are a reader. */
+ if (++rwlock->__data.__nr_readers_queued == 0)
+ {
+ /* Overflow on number of queued readers. */
+ --rwlock->__data.__nr_readers_queued;
+ result = EAGAIN;
+ break;
+ }
+
+ int waitval = rwlock->__data.__readers_wakeup;
+
+ /* Free the lock. */
+ lll_unlock (rwlock->__data.__lock, rwlock->__data.__shared);
+
+ /* Wait for the writer to finish. */
+ err = lll_futex_timed_wait (&rwlock->__data.__readers_wakeup,
+ waitval, &rt, rwlock->__data.__shared);
+
+ /* Get the lock. */
+ lll_lock (rwlock->__data.__lock, rwlock->__data.__shared);
+
+ --rwlock->__data.__nr_readers_queued;
+
+ /* Did the futex call time out? */
+ if (err == -ETIMEDOUT)
+ {
+ /* Yep, report it. */
+ result = ETIMEDOUT;
+ break;
+ }
+ }
+
+ /* We are done, free the lock. */
+ lll_unlock (rwlock->__data.__lock, rwlock->__data.__shared);
+
+ return result;
+}
diff --git a/libpthread/nptl/sysdeps/pthread/pthread_rwlock_timedwrlock.c b/libpthread/nptl/sysdeps/pthread/pthread_rwlock_timedwrlock.c
new file mode 100644
index 000000000..0b04b357a
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/pthread_rwlock_timedwrlock.c
@@ -0,0 +1,126 @@
+/* Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Martin Schwidefsky <schwidefsky@de.ibm.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 <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <pthread.h>
+#include <pthreadP.h>
+
+
+/* Try to acquire write lock for RWLOCK or return after specfied time. */
+int
+pthread_rwlock_timedwrlock (
+ pthread_rwlock_t *rwlock,
+ const struct timespec *abstime)
+{
+ int result = 0;
+
+ /* Make sure we are along. */
+ lll_lock (rwlock->__data.__lock, rwlock->__data.__shared);
+
+ while (1)
+ {
+ int err;
+
+ /* Get the rwlock if there is no writer and no reader. */
+ if (rwlock->__data.__writer == 0 && rwlock->__data.__nr_readers == 0)
+ {
+ /* Mark self as writer. */
+ rwlock->__data.__writer = THREAD_GETMEM (THREAD_SELF, tid);
+ break;
+ }
+
+ /* Make sure we are not holding the rwlock as a writer. This is
+ a deadlock situation we recognize and report. */
+ if (__builtin_expect (rwlock->__data.__writer
+ == THREAD_GETMEM (THREAD_SELF, tid), 0))
+ {
+ result = EDEADLK;
+ break;
+ }
+
+ /* Make sure the passed in timeout value is valid. Ideally this
+ test would be executed once. But since it must not be
+ performed if we would not block at all simply moving the test
+ to the front is no option. Replicating all the code is
+ costly while this test is not. */
+ if (__builtin_expect (abstime->tv_nsec >= 1000000000
+ || abstime->tv_nsec < 0, 0))
+ {
+ result = EINVAL;
+ break;
+ }
+
+ /* Get the current time. So far we support only one clock. */
+ struct timeval tv;
+ (void) gettimeofday (&tv, NULL);
+
+ /* Convert the absolute timeout value to a relative timeout. */
+ struct timespec rt;
+ rt.tv_sec = abstime->tv_sec - tv.tv_sec;
+ rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+ if (rt.tv_nsec < 0)
+ {
+ rt.tv_nsec += 1000000000;
+ --rt.tv_sec;
+ }
+ /* Did we already time out? */
+ if (rt.tv_sec < 0)
+ {
+ result = ETIMEDOUT;
+ break;
+ }
+
+ /* Remember that we are a writer. */
+ if (++rwlock->__data.__nr_writers_queued == 0)
+ {
+ /* Overflow on number of queued writers. */
+ --rwlock->__data.__nr_writers_queued;
+ result = EAGAIN;
+ break;
+ }
+
+ int waitval = rwlock->__data.__writer_wakeup;
+
+ /* Free the lock. */
+ lll_unlock (rwlock->__data.__lock, rwlock->__data.__shared);
+
+ /* Wait for the writer or reader(s) to finish. */
+ err = lll_futex_timed_wait (&rwlock->__data.__writer_wakeup,
+ waitval, &rt, rwlock->__data.__shared);
+
+ /* Get the lock. */
+ lll_lock (rwlock->__data.__lock, rwlock->__data.__shared);
+
+ /* To start over again, remove the thread from the writer list. */
+ --rwlock->__data.__nr_writers_queued;
+
+ /* Did the futex call time out? */
+ if (err == -ETIMEDOUT)
+ {
+ result = ETIMEDOUT;
+ break;
+ }
+ }
+
+ /* We are done, free the lock. */
+ lll_unlock (rwlock->__data.__lock, rwlock->__data.__shared);
+
+ return result;
+}
diff --git a/libpthread/nptl/sysdeps/pthread/pthread_rwlock_unlock.c b/libpthread/nptl/sysdeps/pthread/pthread_rwlock_unlock.c
new file mode 100644
index 000000000..bf24b06d0
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/pthread_rwlock_unlock.c
@@ -0,0 +1,59 @@
+/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Martin Schwidefsky <schwidefsky@de.ibm.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 <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <pthread.h>
+#include <pthreadP.h>
+
+/* Unlock RWLOCK. */
+int
+attribute_protected
+__pthread_rwlock_unlock (pthread_rwlock_t *rwlock)
+{
+ lll_lock (rwlock->__data.__lock, rwlock->__data.__shared);
+ if (rwlock->__data.__writer)
+ rwlock->__data.__writer = 0;
+ else
+ --rwlock->__data.__nr_readers;
+ if (rwlock->__data.__nr_readers == 0)
+ {
+ if (rwlock->__data.__nr_writers_queued)
+ {
+ ++rwlock->__data.__writer_wakeup;
+ lll_unlock (rwlock->__data.__lock, rwlock->__data.__shared);
+ lll_futex_wake (&rwlock->__data.__writer_wakeup, 1,
+ rwlock->__data.__shared);
+ return 0;
+ }
+ else if (rwlock->__data.__nr_readers_queued)
+ {
+ ++rwlock->__data.__readers_wakeup;
+ lll_unlock (rwlock->__data.__lock, rwlock->__data.__shared);
+ lll_futex_wake (&rwlock->__data.__readers_wakeup, INT_MAX,
+ rwlock->__data.__shared);
+ return 0;
+ }
+ }
+ lll_unlock (rwlock->__data.__lock, rwlock->__data.__shared);
+ return 0;
+}
+
+weak_alias (__pthread_rwlock_unlock, pthread_rwlock_unlock)
+strong_alias (__pthread_rwlock_unlock, __pthread_rwlock_unlock_internal)
diff --git a/libpthread/nptl/sysdeps/pthread/pthread_rwlock_wrlock.c b/libpthread/nptl/sysdeps/pthread/pthread_rwlock_wrlock.c
new file mode 100644
index 000000000..710828dc2
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/pthread_rwlock_wrlock.c
@@ -0,0 +1,88 @@
+/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Martin Schwidefsky <schwidefsky@de.ibm.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 <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <pthread.h>
+#include <pthreadP.h>
+
+
+/* Acquire write lock for RWLOCK. */
+int
+attribute_protected
+__pthread_rwlock_wrlock (
+ pthread_rwlock_t *rwlock)
+{
+ int result = 0;
+
+ /* Make sure we are along. */
+ lll_lock (rwlock->__data.__lock, rwlock->__data.__shared);
+
+ while (1)
+ {
+ /* Get the rwlock if there is no writer and no reader. */
+ if (rwlock->__data.__writer == 0 && rwlock->__data.__nr_readers == 0)
+ {
+ /* Mark self as writer. */
+ rwlock->__data.__writer = THREAD_GETMEM (THREAD_SELF, tid);
+ break;
+ }
+
+ /* Make sure we are not holding the rwlock as a writer. This is
+ a deadlock situation we recognize and report. */
+ if (__builtin_expect (rwlock->__data.__writer
+ == THREAD_GETMEM (THREAD_SELF, tid), 0))
+ {
+ result = EDEADLK;
+ break;
+ }
+
+ /* Remember that we are a writer. */
+ if (++rwlock->__data.__nr_writers_queued == 0)
+ {
+ /* Overflow on number of queued writers. */
+ --rwlock->__data.__nr_writers_queued;
+ result = EAGAIN;
+ break;
+ }
+
+ int waitval = rwlock->__data.__writer_wakeup;
+
+ /* Free the lock. */
+ lll_unlock (rwlock->__data.__lock, rwlock->__data.__shared);
+
+ /* Wait for the writer or reader(s) to finish. */
+ lll_futex_wait (&rwlock->__data.__writer_wakeup, waitval,
+ rwlock->__data.__shared);
+
+ /* Get the lock. */
+ lll_lock (rwlock->__data.__lock, rwlock->__data.__shared);
+
+ /* To start over again, remove the thread from the writer list. */
+ --rwlock->__data.__nr_writers_queued;
+ }
+
+ /* We are done, free the lock. */
+ lll_unlock (rwlock->__data.__lock, rwlock->__data.__shared);
+
+ return result;
+}
+
+weak_alias (__pthread_rwlock_wrlock, pthread_rwlock_wrlock)
+strong_alias (__pthread_rwlock_wrlock, __pthread_rwlock_wrlock_internal)
diff --git a/libpthread/nptl/sysdeps/pthread/pthread_sigmask.c b/libpthread/nptl/sysdeps/pthread/pthread_sigmask.c
new file mode 100644
index 000000000..7d43cdfcb
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/pthread_sigmask.c
@@ -0,0 +1,57 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <signal.h>
+#include <pthreadP.h>
+#include <sysdep.h>
+
+
+int
+pthread_sigmask (
+ int how,
+ const sigset_t *newmask,
+ sigset_t *oldmask)
+{
+ sigset_t local_newmask;
+
+ /* The only thing we have to make sure here is that SIGCANCEL and
+ SIGSETXID is not blocked. */
+ if (newmask != NULL
+ && (__builtin_expect (__sigismember (newmask, SIGCANCEL), 0)
+ || __builtin_expect (__sigismember (newmask, SIGSETXID), 0)))
+ {
+ local_newmask = *newmask;
+ __sigdelset (&local_newmask, SIGCANCEL);
+ __sigdelset (&local_newmask, SIGSETXID);
+ newmask = &local_newmask;
+ }
+
+#ifdef INTERNAL_SYSCALL
+ /* We know that realtime signals are available if NPTL is used. */
+ INTERNAL_SYSCALL_DECL (err);
+ int result = INTERNAL_SYSCALL (rt_sigprocmask, err, 4, how, newmask,
+ oldmask, _NSIG / 8);
+
+ return (INTERNAL_SYSCALL_ERROR_P (result, err)
+ ? INTERNAL_SYSCALL_ERRNO (result, err)
+ : 0);
+#else
+ return sigprocmask (how, newmask, oldmask) == -1 ? errno : 0;
+#endif
+}
diff --git a/libpthread/nptl/sysdeps/pthread/pthread_spin_destroy.c b/libpthread/nptl/sysdeps/pthread/pthread_spin_destroy.c
new file mode 100644
index 000000000..5509ba9e7
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/pthread_spin_destroy.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 "pthreadP.h"
+
+
+int
+pthread_spin_destroy (
+ pthread_spinlock_t *lock)
+{
+ /* Nothing to do. */
+ return 0;
+}
diff --git a/libpthread/nptl/sysdeps/pthread/pthread_spin_init.c b/libpthread/nptl/sysdeps/pthread/pthread_spin_init.c
new file mode 100644
index 000000000..031d108f0
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/pthread_spin_init.c
@@ -0,0 +1,27 @@
+/* pthread_spin_init -- initialize a spin lock. Generic version.
+ Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Paul Mackerras <paulus@au.ibm.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 "pthreadP.h"
+
+int
+pthread_spin_init (pthread_spinlock_t *lock, int pshared)
+{
+ *lock = 0;
+ return 0;
+}
diff --git a/libpthread/nptl/sysdeps/pthread/pthread_spin_unlock.c b/libpthread/nptl/sysdeps/pthread/pthread_spin_unlock.c
new file mode 100644
index 000000000..82ba5153f
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/pthread_spin_unlock.c
@@ -0,0 +1,29 @@
+/* pthread_spin_unlock -- unlock a spin lock. Generic version.
+ Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Paul Mackerras <paulus@au.ibm.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 "pthreadP.h"
+#include <atomic.h>
+
+int
+pthread_spin_unlock (pthread_spinlock_t *lock)
+{
+ atomic_full_barrier ();
+ *lock = 0;
+ return 0;
+}
diff --git a/libpthread/nptl/sysdeps/pthread/rt-unwind-resume.c b/libpthread/nptl/sysdeps/pthread/rt-unwind-resume.c
new file mode 100644
index 000000000..743e675d4
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/rt-unwind-resume.c
@@ -0,0 +1 @@
+#include <unwind-resume.c>
diff --git a/libpthread/nptl/sysdeps/pthread/setxid.h b/libpthread/nptl/sysdeps/pthread/setxid.h
new file mode 100644
index 000000000..9331649e4
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/setxid.h
@@ -0,0 +1,62 @@
+/* Copyright (C) 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
+ 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 <pthreadP.h>
+#include <sysdep.h>
+
+#define __SETXID_1(cmd, arg1) \
+ cmd.id[0] = arg1
+#define __SETXID_2(cmd, arg1, arg2) \
+ __SETXID_1 (cmd, arg1); cmd.id[1] = arg2
+#define __SETXID_3(cmd, arg1, arg2, arg3) \
+ __SETXID_2 (cmd, arg1, arg2); cmd.id[2] = arg3
+
+#ifdef SINGLE_THREAD
+# define INLINE_SETXID_SYSCALL(name, nr, args...) \
+ INLINE_SYSCALL (name, nr, args)
+#elif defined SHARED
+# define INLINE_SETXID_SYSCALL(name, nr, args...) \
+ ({ \
+ int __result; \
+ if (__builtin_expect (__libc_pthread_functions_init, 0)) \
+ { \
+ struct xid_command __cmd; \
+ __cmd.syscall_no = __NR_##name; \
+ __SETXID_##nr (__cmd, args); \
+ __result = PTHFCT_CALL (ptr__nptl_setxid, (&__cmd)); \
+ } \
+ else \
+ __result = INLINE_SYSCALL (name, nr, args); \
+ __result; \
+ })
+#else
+# define INLINE_SETXID_SYSCALL(name, nr, args...) \
+ ({ \
+ extern __typeof (__nptl_setxid) __nptl_setxid __attribute__((weak));\
+ int __result; \
+ if (__builtin_expect (__nptl_setxid != NULL, 0)) \
+ { \
+ struct xid_command __cmd; \
+ __cmd.syscall_no = __NR_##name; \
+ __SETXID_##nr (__cmd, args); \
+ __result =__nptl_setxid (&__cmd); \
+ } \
+ else \
+ __result = INLINE_SYSCALL (name, nr, args); \
+ __result; \
+ })
+#endif
diff --git a/libpthread/nptl/sysdeps/pthread/sigfillset.c b/libpthread/nptl/sysdeps/pthread/sigfillset.c
new file mode 100644
index 000000000..d442d6583
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/sigfillset.c
@@ -0,0 +1,20 @@
+/* Copyright (C) 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <pthreadP.h>
+
+#include <../../../../libc/signal/sigfillset.c>
diff --git a/libpthread/nptl/sysdeps/pthread/sigprocmask.c b/libpthread/nptl/sysdeps/pthread/sigprocmask.c
new file mode 100644
index 000000000..246c08d1c
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/sigprocmask.c
@@ -0,0 +1,21 @@
+/* Copyright (C) 1997,1998,1999,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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <pthreadP.h>
+#undef _LARGEFILE64_SOURCE
+
+#include <../../../../libc/sysdeps/linux/common/sigprocmask.c>
diff --git a/libpthread/nptl/sysdeps/pthread/tcb-offsets.h b/libpthread/nptl/sysdeps/pthread/tcb-offsets.h
new file mode 100644
index 000000000..3fe13702e
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/tcb-offsets.h
@@ -0,0 +1 @@
+/* This is overridden by generated tcb-offsets.h on arches which need it. */
diff --git a/libpthread/nptl/sysdeps/pthread/timer_create.c b/libpthread/nptl/sysdeps/pthread/timer_create.c
new file mode 100644
index 000000000..8d7683e41
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/timer_create.c
@@ -0,0 +1,169 @@
+/* Copyright (C) 2000, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Kaz Kylheku <kaz@ashi.footprints.net>.
+
+ 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/>. */
+
+#include <errno.h>
+#include <signal.h>
+#include <pthread.h>
+#include <time.h>
+#include <unistd.h>
+
+#include "posix-timer.h"
+
+
+/* Create new per-process timer using CLOCK. */
+int
+timer_create (
+ clockid_t clock_id,
+ struct sigevent *evp,
+ timer_t *timerid)
+{
+ int retval = -1;
+ struct timer_node *newtimer = NULL;
+ struct thread_node *thread = NULL;
+
+ if (0
+#if defined _POSIX_CPUTIME && _POSIX_CPUTIME >= 0
+ || clock_id == CLOCK_PROCESS_CPUTIME_ID
+#endif
+#if defined _POSIX_THREAD_CPUTIME && _POSIX_THREAD_CPUTIME >= 0
+ || clock_id == CLOCK_THREAD_CPUTIME_ID
+#endif
+ )
+ {
+ /* We don't allow timers for CPU clocks. At least not in the
+ moment. */
+ __set_errno (ENOTSUP);
+ return -1;
+ }
+
+ if (clock_id != CLOCK_REALTIME)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ pthread_once (&__timer_init_once_control, __timer_init_once);
+
+ if (__timer_init_failed)
+ {
+ __set_errno (ENOMEM);
+ return -1;
+ }
+
+ pthread_mutex_lock (&__timer_mutex);
+
+ newtimer = __timer_alloc ();
+ if (__builtin_expect (newtimer == NULL, 0))
+ {
+ __set_errno (EAGAIN);
+ goto unlock_bail;
+ }
+
+ if (evp != NULL)
+ newtimer->event = *evp;
+ else
+ {
+ newtimer->event.sigev_notify = SIGEV_SIGNAL;
+ newtimer->event.sigev_signo = SIGALRM;
+ newtimer->event.sigev_value.sival_ptr = timer_ptr2id (newtimer);
+ newtimer->event.sigev_notify_function = 0;
+ }
+
+ newtimer->event.sigev_notify_attributes = &newtimer->attr;
+ newtimer->creator_pid = getpid ();
+
+ switch (__builtin_expect (newtimer->event.sigev_notify, SIGEV_SIGNAL))
+ {
+ case SIGEV_NONE:
+ case SIGEV_SIGNAL:
+ /* We have a global thread for delivering timed signals.
+ If it is not running, try to start it up. */
+ thread = &__timer_signal_thread_rclk;
+ if (! thread->exists)
+ {
+ if (__builtin_expect (__timer_thread_start (thread),
+ 1) < 0)
+ {
+ __set_errno (EAGAIN);
+ goto unlock_bail;
+ }
+ }
+ break;
+
+ case SIGEV_THREAD:
+ /* Copy over thread attributes or set up default ones. */
+ if (evp->sigev_notify_attributes)
+ newtimer->attr = *(pthread_attr_t *) evp->sigev_notify_attributes;
+ else
+ pthread_attr_init (&newtimer->attr);
+
+ /* Ensure thread attributes call for deatched thread. */
+ pthread_attr_setdetachstate (&newtimer->attr, PTHREAD_CREATE_DETACHED);
+
+ /* Try to find existing thread having the right attributes. */
+ thread = __timer_thread_find_matching (&newtimer->attr, clock_id);
+
+ /* If no existing thread has these attributes, try to allocate one. */
+ if (thread == NULL)
+ thread = __timer_thread_alloc (&newtimer->attr, clock_id);
+
+ /* Out of luck; no threads are available. */
+ if (__builtin_expect (thread == NULL, 0))
+ {
+ __set_errno (EAGAIN);
+ goto unlock_bail;
+ }
+
+ /* If the thread is not running already, try to start it. */
+ if (! thread->exists
+ && __builtin_expect (! __timer_thread_start (thread), 0))
+ {
+ __set_errno (EAGAIN);
+ goto unlock_bail;
+ }
+ break;
+
+ default:
+ __set_errno (EINVAL);
+ goto unlock_bail;
+ }
+
+ newtimer->clock = clock_id;
+ newtimer->abstime = 0;
+ newtimer->armed = 0;
+ newtimer->thread = thread;
+
+ *timerid = timer_ptr2id (newtimer);
+ retval = 0;
+
+ if (__builtin_expect (retval, 0) == -1)
+ {
+ unlock_bail:
+ if (thread != NULL)
+ __timer_thread_dealloc (thread);
+ if (newtimer != NULL)
+ {
+ timer_delref (newtimer);
+ __timer_dealloc (newtimer);
+ }
+ }
+
+ pthread_mutex_unlock (&__timer_mutex);
+
+ return retval;
+}
diff --git a/libpthread/nptl/sysdeps/pthread/timer_delete.c b/libpthread/nptl/sysdeps/pthread/timer_delete.c
new file mode 100644
index 000000000..be8e6c4f6
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/timer_delete.c
@@ -0,0 +1,69 @@
+/* Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Kaz Kylheku <kaz@ashi.footprints.net>.
+
+ 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/>. */
+
+#include <assert.h>
+#include <errno.h>
+#include <pthread.h>
+#include <time.h>
+
+#include "posix-timer.h"
+
+
+/* Delete timer TIMERID. */
+int
+timer_delete (
+ timer_t timerid)
+{
+ struct timer_node *timer;
+ int retval = -1;
+
+ pthread_mutex_lock (&__timer_mutex);
+
+ timer = timer_id2ptr (timerid);
+ if (! timer_valid (timer))
+ /* Invalid timer ID or the timer is not in use. */
+ __set_errno (EINVAL);
+ else
+ {
+ if (timer->armed && timer->thread != NULL)
+ {
+ struct thread_node *thread = timer->thread;
+ assert (thread != NULL);
+
+ /* If thread is cancelled while waiting for handler to terminate,
+ the mutex is unlocked and timer_delete is aborted. */
+ pthread_cleanup_push (__timer_mutex_cancel_handler, &__timer_mutex);
+
+ /* If timer is currently being serviced, wait for it to finish. */
+ while (thread->current_timer == timer)
+ pthread_cond_wait (&thread->cond, &__timer_mutex);
+
+ pthread_cleanup_pop (0);
+ }
+
+ /* Remove timer from whatever queue it may be on and deallocate it. */
+ timer->inuse = TIMER_DELETED;
+ list_unlink_ip (&timer->links);
+ timer_delref (timer);
+ retval = 0;
+ }
+
+ pthread_mutex_unlock (&__timer_mutex);
+
+ return retval;
+}
diff --git a/libpthread/nptl/sysdeps/pthread/timer_getoverr.c b/libpthread/nptl/sysdeps/pthread/timer_getoverr.c
new file mode 100644
index 000000000..6d753e30d
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/timer_getoverr.c
@@ -0,0 +1,44 @@
+/* Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Kaz Kylheku <kaz@ashi.footprints.net>.
+
+ 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/>. */
+
+#include <errno.h>
+#include <pthread.h>
+#include <time.h>
+
+#include "posix-timer.h"
+
+
+/* Get expiration overrun for timer TIMERID. */
+int
+timer_getoverrun (timerid)
+ timer_t timerid;
+{
+ struct timer_node *timer;
+ int retval = -1;
+
+ pthread_mutex_lock (&__timer_mutex);
+
+ if (! timer_valid (timer = timer_id2ptr (timerid)))
+ __set_errno (EINVAL);
+ else
+ retval = timer->overrun_count;
+
+ pthread_mutex_unlock (&__timer_mutex);
+
+ return retval;
+}
diff --git a/libpthread/nptl/sysdeps/pthread/timer_gettime.c b/libpthread/nptl/sysdeps/pthread/timer_gettime.c
new file mode 100644
index 000000000..6bd2b84e2
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/timer_gettime.c
@@ -0,0 +1,76 @@
+/* Copyright (C) 2000, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Kaz Kylheku <kaz@ashi.footprints.net>.
+
+ 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/>. */
+
+#include <errno.h>
+#include <pthread.h>
+#include <time.h>
+
+#include "posix-timer.h"
+
+
+/* Get current value of timer TIMERID and store it in VLAUE. */
+int
+timer_gettime (timerid, value)
+ timer_t timerid;
+ struct itimerspec *value;
+{
+ struct timer_node *timer;
+ struct timespec now, expiry;
+ int retval = -1, armed = 0, valid;
+ clock_t clock = 0;
+
+ pthread_mutex_lock (&__timer_mutex);
+
+ timer = timer_id2ptr (timerid);
+ valid = timer_valid (timer);
+
+ if (valid) {
+ armed = timer->armed;
+ expiry = timer->expirytime;
+ clock = timer->clock;
+ value->it_interval = timer->value.it_interval;
+ }
+
+ pthread_mutex_unlock (&__timer_mutex);
+
+ if (valid)
+ {
+ if (armed)
+ {
+ clock_gettime (clock, &now);
+ if (timespec_compare (&now, &expiry) < 0)
+ timespec_sub (&value->it_value, &expiry, &now);
+ else
+ {
+ value->it_value.tv_sec = 0;
+ value->it_value.tv_nsec = 0;
+ }
+ }
+ else
+ {
+ value->it_value.tv_sec = 0;
+ value->it_value.tv_nsec = 0;
+ }
+
+ retval = 0;
+ }
+ else
+ __set_errno (EINVAL);
+
+ return retval;
+}
diff --git a/libpthread/nptl/sysdeps/pthread/timer_routines.c b/libpthread/nptl/sysdeps/pthread/timer_routines.c
new file mode 100644
index 000000000..f99d7d4dd
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/timer_routines.c
@@ -0,0 +1,577 @@
+/* Helper code for POSIX timer implementation on NPTL.
+ Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Kaz Kylheku <kaz@ashi.footprints.net>.
+
+ 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/>. */
+
+#include <assert.h>
+#include <errno.h>
+#include <pthread.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sysdep.h>
+#include <time.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+
+#include "posix-timer.h"
+#include <pthreadP.h>
+
+
+/* Number of threads used. */
+#define THREAD_MAXNODES 16
+
+/* Array containing the descriptors for the used threads. */
+static struct thread_node thread_array[THREAD_MAXNODES];
+
+/* Static array with the structures for all the timers. */
+struct timer_node __timer_array[TIMER_MAX];
+
+/* Global lock to protect operation on the lists. */
+pthread_mutex_t __timer_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+/* Variable to protext initialization. */
+pthread_once_t __timer_init_once_control = PTHREAD_ONCE_INIT;
+
+/* Nonzero if initialization of timer implementation failed. */
+int __timer_init_failed;
+
+/* Node for the thread used to deliver signals. */
+struct thread_node __timer_signal_thread_rclk;
+
+/* Lists to keep free and used timers and threads. */
+struct list_links timer_free_list;
+struct list_links thread_free_list;
+struct list_links thread_active_list;
+
+
+#ifdef __NR_rt_sigqueueinfo
+extern int __syscall_rt_sigqueueinfo (int, int, siginfo_t *);
+#endif
+
+
+/* List handling functions. */
+static inline void
+list_init (struct list_links *list)
+{
+ list->next = list->prev = list;
+}
+
+static inline void
+list_append (struct list_links *list, struct list_links *newp)
+{
+ newp->prev = list->prev;
+ newp->next = list;
+ list->prev->next = newp;
+ list->prev = newp;
+}
+
+static inline void
+list_insbefore (struct list_links *list, struct list_links *newp)
+{
+ list_append (list, newp);
+}
+
+/*
+ * Like list_unlink_ip, except that calling it on a node that
+ * is already unlinked is disastrous rather than a noop.
+ */
+
+static inline void
+list_unlink (struct list_links *list)
+{
+ struct list_links *lnext = list->next, *lprev = list->prev;
+
+ lnext->prev = lprev;
+ lprev->next = lnext;
+}
+
+static inline struct list_links *
+list_first (struct list_links *list)
+{
+ return list->next;
+}
+
+static inline struct list_links *
+list_null (struct list_links *list)
+{
+ return list;
+}
+
+static inline struct list_links *
+list_next (struct list_links *list)
+{
+ return list->next;
+}
+
+static inline int
+list_isempty (struct list_links *list)
+{
+ return list->next == list;
+}
+
+
+/* Functions build on top of the list functions. */
+static inline struct thread_node *
+thread_links2ptr (struct list_links *list)
+{
+ return (struct thread_node *) ((char *) list
+ - offsetof (struct thread_node, links));
+}
+
+static inline struct timer_node *
+timer_links2ptr (struct list_links *list)
+{
+ return (struct timer_node *) ((char *) list
+ - offsetof (struct timer_node, links));
+}
+
+
+/* Initialize a newly allocated thread structure. */
+static void
+thread_init (struct thread_node *thread, const pthread_attr_t *attr, clockid_t clock_id)
+{
+ if (attr != NULL)
+ thread->attr = *attr;
+ else
+ {
+ pthread_attr_init (&thread->attr);
+ pthread_attr_setdetachstate (&thread->attr, PTHREAD_CREATE_DETACHED);
+ }
+
+ thread->exists = 0;
+ list_init (&thread->timer_queue);
+ pthread_cond_init (&thread->cond, 0);
+ thread->current_timer = 0;
+ thread->captured = pthread_self ();
+ thread->clock_id = clock_id;
+}
+
+
+/* Initialize the global lists, and acquire global resources. Error
+ reporting is done by storing a non-zero value to the global variable
+ timer_init_failed. */
+static void
+init_module (void)
+{
+ int i;
+
+ list_init (&timer_free_list);
+ list_init (&thread_free_list);
+ list_init (&thread_active_list);
+
+ for (i = 0; i < TIMER_MAX; ++i)
+ {
+ list_append (&timer_free_list, &__timer_array[i].links);
+ __timer_array[i].inuse = TIMER_FREE;
+ }
+
+ for (i = 0; i < THREAD_MAXNODES; ++i)
+ list_append (&thread_free_list, &thread_array[i].links);
+
+ thread_init (&__timer_signal_thread_rclk, 0, CLOCK_REALTIME);
+}
+
+
+/* This is a handler executed in a child process after a fork()
+ occurs. It reinitializes the module, resetting all of the data
+ structures to their initial state. The mutex is initialized in
+ case it was locked in the parent process. */
+static void
+reinit_after_fork (void)
+{
+ init_module ();
+ pthread_mutex_init (&__timer_mutex, 0);
+}
+
+
+/* Called once form pthread_once in timer_init. This initializes the
+ module and ensures that reinit_after_fork will be executed in any
+ child process. */
+void
+__timer_init_once (void)
+{
+ init_module ();
+ pthread_atfork (0, 0, reinit_after_fork);
+}
+
+
+/* Deinitialize a thread that is about to be deallocated. */
+static void
+thread_deinit (struct thread_node *thread)
+{
+ assert (list_isempty (&thread->timer_queue));
+ pthread_cond_destroy (&thread->cond);
+}
+
+
+/* Allocate a thread structure from the global free list. Global
+ mutex lock must be held by caller. The thread is moved to
+ the active list. */
+struct thread_node *
+__timer_thread_alloc (const pthread_attr_t *desired_attr, clockid_t clock_id)
+{
+ struct list_links *node = list_first (&thread_free_list);
+
+ if (node != list_null (&thread_free_list))
+ {
+ struct thread_node *thread = thread_links2ptr (node);
+ list_unlink (node);
+ thread_init (thread, desired_attr, clock_id);
+ list_append (&thread_active_list, node);
+ return thread;
+ }
+
+ return 0;
+}
+
+
+/* Return a thread structure to the global free list. Global lock
+ must be held by caller. */
+void
+__timer_thread_dealloc (struct thread_node *thread)
+{
+ thread_deinit (thread);
+ list_unlink (&thread->links);
+ list_append (&thread_free_list, &thread->links);
+}
+
+
+/* Each of our threads which terminates executes this cleanup
+ handler. We never terminate threads ourselves; if a thread gets here
+ it means that the evil application has killed it. If the thread has
+ timers, these require servicing and so we must hire a replacement
+ thread right away. We must also unblock another thread that may
+ have been waiting for this thread to finish servicing a timer (see
+ timer_delete()). */
+
+static void
+thread_cleanup (void *val)
+{
+ if (val != NULL)
+ {
+ struct thread_node *thread = val;
+
+ /* How did the signal thread get killed? */
+ assert (thread != &__timer_signal_thread_rclk);
+
+ pthread_mutex_lock (&__timer_mutex);
+
+ thread->exists = 0;
+
+ /* We are no longer processing a timer event. */
+ thread->current_timer = 0;
+
+ if (list_isempty (&thread->timer_queue))
+ __timer_thread_dealloc (thread);
+ else
+ (void) __timer_thread_start (thread);
+
+ pthread_mutex_unlock (&__timer_mutex);
+
+ /* Unblock potentially blocked timer_delete(). */
+ pthread_cond_broadcast (&thread->cond);
+ }
+}
+
+
+/* Handle a timer which is supposed to go off now. */
+static void
+thread_expire_timer (struct thread_node *self, struct timer_node *timer)
+{
+ self->current_timer = timer; /* Lets timer_delete know timer is running. */
+
+ pthread_mutex_unlock (&__timer_mutex);
+
+ switch (__builtin_expect (timer->event.sigev_notify, SIGEV_SIGNAL))
+ {
+ case SIGEV_NONE:
+ break;
+
+ case SIGEV_SIGNAL:
+#ifdef __NR_rt_sigqueueinfo
+ {
+ 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 = timer->event.sigev_signo;
+ info.si_code = SI_TIMER;
+ info.si_pid = timer->creator_pid;
+ info.si_uid = getuid ();
+ info.si_value = timer->event.sigev_value;
+
+ INLINE_SYSCALL (rt_sigqueueinfo, 3, info.si_pid, info.si_signo, &info);
+ }
+#else
+ if (pthread_kill (self->captured, timer->event.sigev_signo) != 0)
+ {
+ if (pthread_kill (self->id, timer->event.sigev_signo) != 0)
+ abort ();
+ }
+#endif
+ break;
+
+ case SIGEV_THREAD:
+ timer->event.sigev_notify_function (timer->event.sigev_value);
+ break;
+
+ default:
+ assert (! "unknown event");
+ break;
+ }
+
+ pthread_mutex_lock (&__timer_mutex);
+
+ self->current_timer = 0;
+
+ pthread_cond_broadcast (&self->cond);
+}
+
+
+/* Thread function; executed by each timer thread. The job of this
+ function is to wait on the thread's timer queue and expire the
+ timers in chronological order as close to their scheduled time as
+ possible. */
+static void
+__attribute__ ((noreturn))
+thread_func (void *arg)
+{
+ struct thread_node *self = arg;
+
+ /* Register cleanup handler, in case rogue application terminates
+ this thread. (This cannot happen to __timer_signal_thread, which
+ doesn't invoke application callbacks). */
+
+ pthread_cleanup_push (thread_cleanup, self);
+
+ pthread_mutex_lock (&__timer_mutex);
+
+ while (1)
+ {
+ struct list_links *first;
+ struct timer_node *timer = NULL;
+
+ /* While the timer queue is not empty, inspect the first node. */
+ first = list_first (&self->timer_queue);
+ if (first != list_null (&self->timer_queue))
+ {
+ struct timespec now;
+
+ timer = timer_links2ptr (first);
+
+ /* This assumes that the elements of the list of one thread
+ are all for the same clock. */
+ clock_gettime (timer->clock, &now);
+
+ while (1)
+ {
+ /* If the timer is due or overdue, remove it from the queue.
+ If it's a periodic timer, re-compute its new time and
+ requeue it. Either way, perform the timer expiry. */
+ if (timespec_compare (&now, &timer->expirytime) < 0)
+ break;
+
+ list_unlink_ip (first);
+
+ if (__builtin_expect (timer->value.it_interval.tv_sec, 0) != 0
+ || timer->value.it_interval.tv_nsec != 0)
+ {
+ timer->overrun_count = 0;
+ timespec_add (&timer->expirytime, &timer->expirytime,
+ &timer->value.it_interval);
+ while (timespec_compare (&timer->expirytime, &now) < 0)
+ {
+ timespec_add (&timer->expirytime, &timer->expirytime,
+ &timer->value.it_interval);
+ if (timer->overrun_count < DELAYTIMER_MAX)
+ ++timer->overrun_count;
+ }
+ __timer_thread_queue_timer (self, timer);
+ }
+
+ thread_expire_timer (self, timer);
+
+ first = list_first (&self->timer_queue);
+ if (first == list_null (&self->timer_queue))
+ break;
+
+ timer = timer_links2ptr (first);
+ }
+ }
+
+ /* If the queue is not empty, wait until the expiry time of the
+ first node. Otherwise wait indefinitely. Insertions at the
+ head of the queue must wake up the thread by broadcasting
+ this condition variable. */
+ if (timer != NULL)
+ pthread_cond_timedwait (&self->cond, &__timer_mutex,
+ &timer->expirytime);
+ else
+ pthread_cond_wait (&self->cond, &__timer_mutex);
+ }
+ /* This macro will never be executed since the while loop loops
+ forever - but we have to add it for proper nesting. */
+ pthread_cleanup_pop (1);
+}
+
+
+/* Enqueue a timer in wakeup order in the thread's timer queue.
+ Returns 1 if the timer was inserted at the head of the queue,
+ causing the queue's next wakeup time to change. */
+
+int
+__timer_thread_queue_timer (struct thread_node *thread,
+ struct timer_node *insert)
+{
+ struct list_links *iter;
+ int athead = 1;
+
+ for (iter = list_first (&thread->timer_queue);
+ iter != list_null (&thread->timer_queue);
+ iter = list_next (iter))
+ {
+ struct timer_node *timer = timer_links2ptr (iter);
+
+ if (timespec_compare (&insert->expirytime, &timer->expirytime) < 0)
+ break;
+ athead = 0;
+ }
+
+ list_insbefore (iter, &insert->links);
+ return athead;
+}
+
+
+/* Start a thread and associate it with the given thread node. Global
+ lock must be held by caller. */
+int
+__timer_thread_start (struct thread_node *thread)
+{
+ int retval = 1;
+
+ assert (!thread->exists);
+ thread->exists = 1;
+
+ if (pthread_create (&thread->id, &thread->attr,
+ (void *(*) (void *)) thread_func, thread) != 0)
+ {
+ thread->exists = 0;
+ retval = -1;
+ }
+
+ return retval;
+}
+
+
+void
+__timer_thread_wakeup (struct thread_node *thread)
+{
+ pthread_cond_broadcast (&thread->cond);
+}
+
+
+/* Compare two pthread_attr_t thread attributes for exact equality.
+ Returns 1 if they are equal, otherwise zero if they are not equal
+ or contain illegal values. This version is NPTL-specific for
+ performance reason. One could use the access functions to get the
+ values of all the fields of the attribute structure. */
+static int
+thread_attr_compare (const pthread_attr_t *left, const pthread_attr_t *right)
+{
+ struct pthread_attr *ileft = (struct pthread_attr *) left;
+ struct pthread_attr *iright = (struct pthread_attr *) right;
+
+ return (ileft->flags == iright->flags
+ && ileft->schedpolicy == iright->schedpolicy
+ && (ileft->schedparam.sched_priority
+ == iright->schedparam.sched_priority)
+ && ileft->guardsize == iright->guardsize
+ && ileft->stackaddr == iright->stackaddr
+ && ileft->stacksize == iright->stacksize
+ && ((ileft->cpuset == NULL && iright->cpuset == NULL)
+ || (ileft->cpuset != NULL && iright->cpuset != NULL
+ && ileft->cpusetsize == iright->cpusetsize
+ && memcmp (ileft->cpuset, iright->cpuset,
+ ileft->cpusetsize) == 0)));
+}
+
+
+/* Search the list of active threads and find one which has matching
+ attributes. Global mutex lock must be held by caller. */
+struct thread_node *
+__timer_thread_find_matching (const pthread_attr_t *desired_attr,
+ clockid_t desired_clock_id)
+{
+ struct list_links *iter = list_first (&thread_active_list);
+
+ while (iter != list_null (&thread_active_list))
+ {
+ struct thread_node *candidate = thread_links2ptr (iter);
+
+ if (thread_attr_compare (desired_attr, &candidate->attr)
+ && desired_clock_id == candidate->clock_id)
+ return candidate;
+
+ iter = list_next (iter);
+ }
+
+ return NULL;
+}
+
+
+/* Grab a free timer structure from the global free list. The global
+ lock must be held by the caller. */
+struct timer_node *
+__timer_alloc (void)
+{
+ struct list_links *node = list_first (&timer_free_list);
+
+ if (node != list_null (&timer_free_list))
+ {
+ struct timer_node *timer = timer_links2ptr (node);
+ list_unlink_ip (node);
+ timer->inuse = TIMER_INUSE;
+ timer->refcount = 1;
+ return timer;
+ }
+
+ return NULL;
+}
+
+
+/* Return a timer structure to the global free list. The global lock
+ must be held by the caller. */
+void
+__timer_dealloc (struct timer_node *timer)
+{
+ assert (timer->refcount == 0);
+ timer->thread = NULL; /* Break association between timer and thread. */
+ timer->inuse = TIMER_FREE;
+ list_append (&timer_free_list, &timer->links);
+}
+
+
+/* Thread cancellation handler which unlocks a mutex. */
+void
+__timer_mutex_cancel_handler (void *arg)
+{
+ pthread_mutex_unlock (arg);
+}
diff --git a/libpthread/nptl/sysdeps/pthread/timer_settime.c b/libpthread/nptl/sysdeps/pthread/timer_settime.c
new file mode 100644
index 000000000..da0908b0b
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/timer_settime.c
@@ -0,0 +1,136 @@
+/* Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Kaz Kylheku <kaz@ashi.footprints.net>.
+
+ 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/>. */
+
+#include <errno.h>
+#include <pthread.h>
+#include <time.h>
+
+#include "posix-timer.h"
+
+
+/* Set timer TIMERID to VALUE, returning old value in OVLAUE. */
+int
+timer_settime (timerid, flags, value, ovalue)
+ timer_t timerid;
+ int flags;
+ const struct itimerspec *value;
+ struct itimerspec *ovalue;
+{
+ struct timer_node *timer;
+ struct thread_node *thread = NULL;
+ struct timespec now;
+ int have_now = 0, need_wakeup = 0;
+ int retval = -1;
+
+ timer = timer_id2ptr (timerid);
+ if (timer == NULL)
+ {
+ __set_errno (EINVAL);
+ goto bail;
+ }
+
+ if (value->it_interval.tv_nsec < 0
+ || value->it_interval.tv_nsec >= 1000000000
+ || value->it_value.tv_nsec < 0
+ || value->it_value.tv_nsec >= 1000000000)
+ {
+ __set_errno (EINVAL);
+ goto bail;
+ }
+
+ /* Will need to know current time since this is a relative timer;
+ might as well make the system call outside of the lock now! */
+
+ if ((flags & TIMER_ABSTIME) == 0)
+ {
+ clock_gettime (timer->clock, &now);
+ have_now = 1;
+ }
+
+ pthread_mutex_lock (&__timer_mutex);
+ timer_addref (timer);
+
+ /* One final check of timer validity; this one is possible only
+ until we have the mutex, because it accesses the inuse flag. */
+
+ if (! timer_valid(timer))
+ {
+ __set_errno (EINVAL);
+ goto unlock_bail;
+ }
+
+ if (ovalue != NULL)
+ {
+ ovalue->it_interval = timer->value.it_interval;
+
+ if (timer->armed)
+ {
+ if (! have_now)
+ {
+ pthread_mutex_unlock (&__timer_mutex);
+ clock_gettime (timer->clock, &now);
+ have_now = 1;
+ pthread_mutex_lock (&__timer_mutex);
+ timer_addref (timer);
+ }
+
+ timespec_sub (&ovalue->it_value, &timer->expirytime, &now);
+ }
+ else
+ {
+ ovalue->it_value.tv_sec = 0;
+ ovalue->it_value.tv_nsec = 0;
+ }
+ }
+
+ timer->value = *value;
+
+ list_unlink_ip (&timer->links);
+ timer->armed = 0;
+
+ thread = timer->thread;
+
+ /* A value of { 0, 0 } causes the timer to be stopped. */
+ if (value->it_value.tv_sec != 0
+ || __builtin_expect (value->it_value.tv_nsec != 0, 1))
+ {
+ if ((flags & TIMER_ABSTIME) != 0)
+ /* The user specified the expiration time. */
+ timer->expirytime = value->it_value;
+ else
+ timespec_add (&timer->expirytime, &now, &value->it_value);
+
+ /* Only need to wake up the thread if timer is inserted
+ at the head of the queue. */
+ if (thread != NULL)
+ need_wakeup = __timer_thread_queue_timer (thread, timer);
+ timer->armed = 1;
+ }
+
+ retval = 0;
+
+unlock_bail:
+ timer_delref (timer);
+ pthread_mutex_unlock (&__timer_mutex);
+
+bail:
+ if (thread != NULL && need_wakeup)
+ __timer_thread_wakeup (thread);
+
+ return retval;
+}
diff --git a/libpthread/nptl/sysdeps/pthread/tpp.c b/libpthread/nptl/sysdeps/pthread/tpp.c
new file mode 100644
index 000000000..41fc1524e
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/tpp.c
@@ -0,0 +1,171 @@
+/* Thread Priority Protect helpers.
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2006.
+
+ 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 <assert.h>
+#include <atomic.h>
+#include <errno.h>
+#include <pthreadP.h>
+#include <sched.h>
+#include <stdlib.h>
+#include "uClibc-glue.h"
+
+int __sched_fifo_min_prio = -1;
+int __sched_fifo_max_prio = -1;
+
+void
+__init_sched_fifo_prio (void)
+{
+ __sched_fifo_max_prio = sched_get_priority_max (SCHED_FIFO);
+ atomic_write_barrier ();
+ __sched_fifo_min_prio = sched_get_priority_min (SCHED_FIFO);
+}
+
+int
+__pthread_tpp_change_priority (int previous_prio, int new_prio)
+{
+ struct pthread *self = THREAD_SELF;
+ struct priority_protection_data *tpp = THREAD_GETMEM (self, tpp);
+
+ if (tpp == NULL)
+ {
+ if (__sched_fifo_min_prio == -1)
+ __init_sched_fifo_prio ();
+
+ size_t size = sizeof *tpp;
+ size += (__sched_fifo_max_prio - __sched_fifo_min_prio + 1)
+ * sizeof (tpp->priomap[0]);
+ tpp = calloc (size, 1);
+ if (tpp == NULL)
+ return ENOMEM;
+ tpp->priomax = __sched_fifo_min_prio - 1;
+ THREAD_SETMEM (self, tpp, tpp);
+ }
+
+ assert (new_prio == -1
+ || (new_prio >= __sched_fifo_min_prio
+ && new_prio <= __sched_fifo_max_prio));
+ assert (previous_prio == -1
+ || (previous_prio >= __sched_fifo_min_prio
+ && previous_prio <= __sched_fifo_max_prio));
+
+ int priomax = tpp->priomax;
+ int newpriomax = priomax;
+ if (new_prio != -1)
+ {
+ if (tpp->priomap[new_prio - __sched_fifo_min_prio] + 1 == 0)
+ return EAGAIN;
+ ++tpp->priomap[new_prio - __sched_fifo_min_prio];
+ if (new_prio > priomax)
+ newpriomax = new_prio;
+ }
+
+ if (previous_prio != -1)
+ {
+ if (--tpp->priomap[previous_prio - __sched_fifo_min_prio] == 0
+ && priomax == previous_prio
+ && previous_prio > new_prio)
+ {
+ int i;
+ for (i = previous_prio - 1; i >= __sched_fifo_min_prio; --i)
+ if (tpp->priomap[i - __sched_fifo_min_prio])
+ break;
+ newpriomax = i;
+ }
+ }
+
+ if (priomax == newpriomax)
+ return 0;
+
+ lll_lock (self->lock, LLL_PRIVATE);
+
+ tpp->priomax = newpriomax;
+
+ int result = 0;
+
+ if ((self->flags & ATTR_FLAG_SCHED_SET) == 0)
+ {
+ if (__sched_getparam (self->tid, &self->schedparam) != 0)
+ result = errno;
+ else
+ self->flags |= ATTR_FLAG_SCHED_SET;
+ }
+
+ if ((self->flags & ATTR_FLAG_POLICY_SET) == 0)
+ {
+ self->schedpolicy = __sched_getscheduler (self->tid);
+ if (self->schedpolicy == -1)
+ result = errno;
+ else
+ self->flags |= ATTR_FLAG_POLICY_SET;
+ }
+
+ if (result == 0)
+ {
+ struct sched_param sp = self->schedparam;
+ if (sp.sched_priority < newpriomax || sp.sched_priority < priomax)
+ {
+ if (sp.sched_priority < newpriomax)
+ sp.sched_priority = newpriomax;
+
+ if (__sched_setscheduler (self->tid, self->schedpolicy, &sp) < 0)
+ result = errno;
+ }
+ }
+
+ lll_unlock (self->lock, LLL_PRIVATE);
+
+ return result;
+}
+
+int
+__pthread_current_priority (void)
+{
+ struct pthread *self = THREAD_SELF;
+ if ((self->flags & (ATTR_FLAG_POLICY_SET | ATTR_FLAG_SCHED_SET))
+ == (ATTR_FLAG_POLICY_SET | ATTR_FLAG_SCHED_SET))
+ return self->schedparam.sched_priority;
+
+ int result = 0;
+
+ lll_lock (self->lock, LLL_PRIVATE);
+
+ if ((self->flags & ATTR_FLAG_SCHED_SET) == 0)
+ {
+ if (__sched_getparam (self->tid, &self->schedparam) != 0)
+ result = -1;
+ else
+ self->flags |= ATTR_FLAG_SCHED_SET;
+ }
+
+ if ((self->flags & ATTR_FLAG_POLICY_SET) == 0)
+ {
+ self->schedpolicy = __sched_getscheduler (self->tid);
+ if (self->schedpolicy == -1)
+ result = -1;
+ else
+ self->flags |= ATTR_FLAG_POLICY_SET;
+ }
+
+ if (result != -1)
+ result = self->schedparam.sched_priority;
+
+ lll_unlock (self->lock, LLL_PRIVATE);
+
+ return result;
+}
diff --git a/libpthread/nptl/sysdeps/pthread/uClibc-glue.h b/libpthread/nptl/sysdeps/pthread/uClibc-glue.h
new file mode 100644
index 000000000..b957dedc9
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/uClibc-glue.h
@@ -0,0 +1,47 @@
+#ifndef _UCLIBC_GLUE_H
+#define _UCLIBC_GLUE_H 1
+
+#include <features.h>
+#include <sys/cdefs.h>
+#include <bits/uClibc_page.h>
+
+#ifdef IS_IN_libpthread
+#include <bits/kernel-features.h>
+
+#ifndef __GLIBC_HAVE_LONG_LONG
+# define __GLIBC_HAVE_LONG_LONG
+#endif
+
+#define __getpagesize getpagesize
+#define __sched_get_priority_max sched_get_priority_max
+#define __sched_get_priority_min sched_get_priority_min
+#define __sched_getscheduler sched_getscheduler
+#define __sched_setscheduler sched_setscheduler
+#define __sched_getparam sched_getparam
+#define __getpid getpid
+#define __gettimeofday gettimeofday
+#define __poll poll
+#define __sysctl sysctl
+#define __open open
+#define __read read
+#define __close close
+#define __on_exit on_exit
+#define __libc_current_sigrtmin_private __libc_current_sigrtmin
+#define __clone clone
+
+extern void *__libc_stack_end;
+extern int __cxa_atexit (void (*func) (void *), void *arg, void *d);
+
+#endif /* IS_IN_libpthread */
+
+#ifdef __UCLIBC_HAS_XLOCALE__
+# define __uselocale(x) uselocale(x)
+#else
+# define __uselocale(x) ((void)0)
+#endif
+
+/* Use a funky version in a probably vein attempt at preventing gdb
+ * from dlopen()'ing glibc's libthread_db library... */
+#define VERSION __stringify(__UCLIBC_MAJOR__) "." __stringify(__UCLIBC_MINOR__) "." __stringify(__UCLIBC_SUBLEVEL__)
+
+#endif
diff --git a/libpthread/nptl/sysdeps/pthread/unwind-forcedunwind.c b/libpthread/nptl/sysdeps/pthread/unwind-forcedunwind.c
new file mode 100644
index 000000000..6936a896e
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/unwind-forcedunwind.c
@@ -0,0 +1,155 @@
+/* Copyright (C) 2003, 2005, 2006, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@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; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <dlfcn.h>
+#include <stdio.h>
+#include <unwind.h>
+#include <pthreadP.h>
+#include <sysdep.h>
+#include <libgcc_s.h>
+
+#define __libc_dlopen(x) dlopen(x, (RTLD_LOCAL | RTLD_LAZY))
+#define __libc_dlsym dlsym
+#define __libc_dlclose dlclose
+
+static void *libgcc_s_handle;
+static void (*libgcc_s_resume) (struct _Unwind_Exception *exc);
+static _Unwind_Reason_Code (*libgcc_s_personality)
+ (int, _Unwind_Action, _Unwind_Exception_Class, struct _Unwind_Exception *,
+ struct _Unwind_Context *);
+static _Unwind_Reason_Code (*libgcc_s_forcedunwind)
+ (struct _Unwind_Exception *, _Unwind_Stop_Fn, void *);
+static _Unwind_Word (*libgcc_s_getcfa) (struct _Unwind_Context *);
+
+void
+__attribute_noinline__
+pthread_cancel_init (void)
+{
+ void *resume;
+ void *personality;
+ void *forcedunwind;
+ void *getcfa;
+ void *handle;
+
+ if (__builtin_expect (libgcc_s_handle != NULL, 1))
+ {
+ /* Force gcc to reload all values. */
+ __asm__ __volatile__ ("" ::: "memory");
+ return;
+ }
+
+ handle = __libc_dlopen (LIBGCC_S_SO);
+
+ if (handle == NULL
+ || (resume = __libc_dlsym (handle, "_Unwind_Resume")) == NULL
+ || (personality = __libc_dlsym (handle, "__gcc_personality_v0")) == NULL
+ || (forcedunwind = __libc_dlsym (handle, "_Unwind_ForcedUnwind"))
+ == NULL
+ || (getcfa = __libc_dlsym (handle, "_Unwind_GetCFA")) == NULL
+#ifdef ARCH_CANCEL_INIT
+ || ARCH_CANCEL_INIT (handle)
+#endif
+ )
+ {
+ printf (LIBGCC_S_SO " must be installed for pthread_cancel to work\n");
+ abort();
+ }
+
+ PTR_MANGLE (resume);
+ libgcc_s_resume = resume;
+ PTR_MANGLE (personality);
+ libgcc_s_personality = personality;
+ PTR_MANGLE (forcedunwind);
+ libgcc_s_forcedunwind = forcedunwind;
+ PTR_MANGLE (getcfa);
+ libgcc_s_getcfa = getcfa;
+ /* Make sure libgcc_s_handle is written last. Otherwise,
+ pthread_cancel_init might return early even when the pointer the
+ caller is interested in is not initialized yet. */
+ atomic_write_barrier ();
+ libgcc_s_handle = handle;
+}
+
+void
+__libc_freeres_fn_section
+__unwind_freeres (void)
+{
+ void *handle = libgcc_s_handle;
+ if (handle != NULL)
+ {
+ libgcc_s_handle = NULL;
+ __libc_dlclose (handle);
+ }
+}
+
+void
+_Unwind_Resume (struct _Unwind_Exception *exc)
+{
+ if (__builtin_expect (libgcc_s_handle == NULL, 0))
+ pthread_cancel_init ();
+
+ void (*resume) (struct _Unwind_Exception *exc) = libgcc_s_resume;
+ PTR_DEMANGLE (resume);
+ resume (exc);
+}
+
+_Unwind_Reason_Code
+__gcc_personality_v0 (int version, _Unwind_Action actions,
+ _Unwind_Exception_Class exception_class,
+ struct _Unwind_Exception *ue_header,
+ struct _Unwind_Context *context);
+_Unwind_Reason_Code
+__gcc_personality_v0 (int version, _Unwind_Action actions,
+ _Unwind_Exception_Class exception_class,
+ struct _Unwind_Exception *ue_header,
+ struct _Unwind_Context *context)
+{
+ if (__builtin_expect (libgcc_s_handle == NULL, 0))
+ pthread_cancel_init ();
+
+ _Unwind_Reason_Code (*personality)
+ (int, _Unwind_Action, _Unwind_Exception_Class, struct _Unwind_Exception *,
+ struct _Unwind_Context *) = libgcc_s_personality;
+ PTR_DEMANGLE (personality);
+ return personality (version, actions, exception_class, ue_header, context);
+}
+
+_Unwind_Reason_Code
+_Unwind_ForcedUnwind (struct _Unwind_Exception *exc, _Unwind_Stop_Fn stop,
+ void *stop_argument)
+{
+ if (__builtin_expect (libgcc_s_handle == NULL, 0))
+ pthread_cancel_init ();
+
+ _Unwind_Reason_Code (*forcedunwind)
+ (struct _Unwind_Exception *, _Unwind_Stop_Fn, void *)
+ = libgcc_s_forcedunwind;
+ PTR_DEMANGLE (forcedunwind);
+ return forcedunwind (exc, stop, stop_argument);
+}
+
+_Unwind_Word
+_Unwind_GetCFA (struct _Unwind_Context *context)
+{
+ if (__builtin_expect (libgcc_s_handle == NULL, 0))
+ pthread_cancel_init ();
+
+ _Unwind_Word (*getcfa) (struct _Unwind_Context *) = libgcc_s_getcfa;
+ PTR_DEMANGLE (getcfa);
+ return getcfa (context);
+}
diff --git a/libpthread/nptl/sysdeps/pthread/unwind-resume.c b/libpthread/nptl/sysdeps/pthread/unwind-resume.c
new file mode 100644
index 000000000..3c1ce0793
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread/unwind-resume.c
@@ -0,0 +1,80 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@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; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unwind.h>
+#include <libgcc_s.h>
+
+#define __libc_dlopen(x) dlopen(x, (RTLD_LOCAL | RTLD_LAZY))
+#define __libc_dlsym dlsym
+#define __libc_dlclose dlclose
+
+static void (*libgcc_s_resume) (struct _Unwind_Exception *exc);
+static _Unwind_Reason_Code (*libgcc_s_personality)
+ (int, _Unwind_Action, _Unwind_Exception_Class, struct _Unwind_Exception *,
+ struct _Unwind_Context *);
+
+extern
+void abort(void);
+
+static void
+init (void)
+{
+ void *resume, *personality;
+ void *handle;
+ resume = personality = NULL;
+ handle = dlopen (LIBGCC_S_SO, (RTLD_LOCAL | RTLD_LAZY));
+
+ if (handle == NULL
+ || (resume = dlsym (handle, "_Unwind_Resume")) == NULL
+ || (personality = dlsym (handle, "__gcc_personality_v0")) == NULL)
+ {
+ printf (LIBGCC_S_SO " must be installed for pthread_cancel to work\n");
+ abort();
+ }
+
+ libgcc_s_resume = resume;
+ libgcc_s_personality = personality;
+}
+
+void
+_Unwind_Resume (struct _Unwind_Exception *exc)
+{
+ if (__builtin_expect (libgcc_s_resume == NULL, 0))
+ init ();
+ libgcc_s_resume (exc);
+}
+
+_Unwind_Reason_Code
+__gcc_personality_v0 (int version, _Unwind_Action actions,
+ _Unwind_Exception_Class exception_class,
+ struct _Unwind_Exception *ue_header,
+ struct _Unwind_Context *context);
+_Unwind_Reason_Code
+__gcc_personality_v0 (int version, _Unwind_Action actions,
+ _Unwind_Exception_Class exception_class,
+ struct _Unwind_Exception *ue_header,
+ struct _Unwind_Context *context)
+{
+ if (__builtin_expect (libgcc_s_personality == NULL, 0))
+ init ();
+ return libgcc_s_personality (version, actions, exception_class,
+ ue_header, context);
+}
diff --git a/libpthread/nptl/sysdeps/pthread_spin_lock.c b/libpthread/nptl/sysdeps/pthread_spin_lock.c
new file mode 100644
index 000000000..2dfcd3c24
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread_spin_lock.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 2003 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/>. */
+
+#include "pthreadP.h"
+
+int
+pthread_spin_lock (pthread_spinlock_t *lock)
+{
+ __asm__ __volatile__
+ ("1: ldstub [%0], %%g2\n"
+ " orcc %%g2, 0x0, %%g0\n"
+ " bne,a 2f\n"
+ " ldub [%0], %%g2\n"
+ ".subsection 2\n"
+ "2: orcc %%g2, 0x0, %%g0\n"
+ " bne,a 2b\n"
+ " ldub [%0], %%g2\n"
+ " b,a 1b\n"
+ ".previous"
+ : /* no outputs */
+ : "r" (lock)
+ : "g2", "memory", "cc");
+ return 0;
+}
diff --git a/libpthread/nptl/sysdeps/pthread_spin_trylock.c b/libpthread/nptl/sysdeps/pthread_spin_trylock.c
new file mode 100644
index 000000000..c1b7b2397
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthread_spin_trylock.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 2003 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/>. */
+
+#include <errno.h>
+#include "pthreadP.h"
+
+int
+pthread_spin_trylock (pthread_spinlock_t *lock)
+{
+ int res;
+ __asm__ __volatile__ ("ldstub [%1], %0" : "=r" (res) : "r" (lock) : "memory");
+ return res == 0 ? 0 : EBUSY;
+}
diff --git a/libpthread/nptl/sysdeps/pthreaddef.h b/libpthread/nptl/sysdeps/pthreaddef.h
new file mode 100644
index 000000000..435fedcf3
--- /dev/null
+++ b/libpthread/nptl/sysdeps/pthreaddef.h
@@ -0,0 +1,39 @@
+/* Copyright (C) 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/>. */
+
+/* Default stack size. */
+#define ARCH_STACK_DEFAULT_SIZE (2 * 1024 * 1024)
+
+/* Required stack pointer alignment at beginning. */
+#define STACK_ALIGN 16
+
+/* Minimal stack size after allocating thread descriptor and guard size. */
+#define MINIMAL_REST_STACK 2048
+
+/* Alignment requirement for TCB. */
+#define TCB_ALIGNMENT 16
+
+
+/* Location of current stack frame. */
+#define CURRENT_STACK_FRAME (stack_pointer + (2 * 64))
+register char *stack_pointer __asm__("%sp");
+
+/* XXX Until we have a better place keep the definitions here. */
+
+/* While there is no such syscall. */
+#define __exit_thread_inline(val) \
+ INLINE_SYSCALL (exit, 1, (val))
diff --git a/libpthread/nptl/sysdeps/sh/Makefile b/libpthread/nptl/sysdeps/sh/Makefile
new file mode 100644
index 000000000..81bddf688
--- /dev/null
+++ b/libpthread/nptl/sysdeps/sh/Makefile
@@ -0,0 +1,3 @@
+ifeq ($(subdir),csu)
+gen-as-const-headers += tcb-offsets.sym
+endif
diff --git a/libpthread/nptl/sysdeps/sh/Makefile.arch b/libpthread/nptl/sysdeps/sh/Makefile.arch
new file mode 100644
index 000000000..b50dd51e0
--- /dev/null
+++ b/libpthread/nptl/sysdeps/sh/Makefile.arch
@@ -0,0 +1,10 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2005 Steven J. Hill <sjhill@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+CFLAGS-pthread_spin_lock.c += -D_GNU_SOURCE
+
+libc_arch_a_CSRC := libc-tls.c
diff --git a/libpthread/nptl/sysdeps/sh/dl-tls.h b/libpthread/nptl/sysdeps/sh/dl-tls.h
new file mode 100644
index 000000000..f5f90beaf
--- /dev/null
+++ b/libpthread/nptl/sysdeps/sh/dl-tls.h
@@ -0,0 +1,28 @@
+/* Thread-local storage handling in the ELF dynamic linker. SH version.
+ Copyright (C) 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/>. */
+
+
+/* Type used for the representation of TLS information in the GOT. */
+typedef struct
+{
+ unsigned long int ti_module;
+ unsigned long int ti_offset;
+} tls_index;
+
+
+extern void *__tls_get_addr (tls_index *ti);
diff --git a/libpthread/nptl/sysdeps/sh/jmpbuf-unwind.h b/libpthread/nptl/sysdeps/sh/jmpbuf-unwind.h
new file mode 100644
index 000000000..2f7f8526a
--- /dev/null
+++ b/libpthread/nptl/sysdeps/sh/jmpbuf-unwind.h
@@ -0,0 +1,27 @@
+/* Copyright (C) 2003, 2004 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/>. */
+
+#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)[0].__regs[7] - (adj))
diff --git a/libpthread/nptl/sysdeps/sh/libc-tls.c b/libpthread/nptl/sysdeps/sh/libc-tls.c
new file mode 100644
index 000000000..7b3389503
--- /dev/null
+++ b/libpthread/nptl/sysdeps/sh/libc-tls.c
@@ -0,0 +1,31 @@
+/*
+ * Thread-local storage handling in statically linked binaries. SH version.
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * Based on GNU C Library (file: libc/sysdeps/sh/libc-tls.c)
+ *
+ * Copyright (C) 2010 STMicroelectronics Ltd.
+ * Author: Filippo Arcidiacono <filippo.arcidiacono@st.com>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ *
+ */
+
+#include <sysdeps/generic/libc-tls.c>
+#include <dl-tls.h>
+
+#if defined (USE_TLS) && (USE_TLS)
+
+/* On SH, linker optimizations are not required, so __tls_get_addr
+ can be called even in statically linked binaries. In this case module
+ must be always 1 and PT_TLS segment exist in the binary, otherwise it
+ would not link. */
+
+void *
+__tls_get_addr (tls_index *ti)
+{
+ dtv_t *dtv = THREAD_DTV ();
+ return (char *) dtv[1].pointer.val + ti->ti_offset;
+}
+
+#endif
diff --git a/libpthread/nptl/sysdeps/sh/pthread_spin_init.c b/libpthread/nptl/sysdeps/sh/pthread_spin_init.c
new file mode 100644
index 000000000..9462f8d17
--- /dev/null
+++ b/libpthread/nptl/sysdeps/sh/pthread_spin_init.c
@@ -0,0 +1,19 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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/>. */
+
+/* Not needed. pthread_spin_init is an alias for pthread_spin_unlock. */
diff --git a/libpthread/nptl/sysdeps/sh/pthread_spin_lock.c b/libpthread/nptl/sysdeps/sh/pthread_spin_lock.c
new file mode 100644
index 000000000..bf9898202
--- /dev/null
+++ b/libpthread/nptl/sysdeps/sh/pthread_spin_lock.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 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 "pthreadP.h"
+
+int
+pthread_spin_lock (pthread_spinlock_t *lock)
+{
+ unsigned int val;
+
+ do
+ __asm__ __volatile__ ("tas.b @%1; movt %0"
+ : "=&r" (val)
+ : "r" (lock)
+ : "memory");
+ while (val == 0);
+
+ return 0;
+}
diff --git a/libpthread/nptl/sysdeps/sh/pthread_spin_trylock.S b/libpthread/nptl/sysdeps/sh/pthread_spin_trylock.S
new file mode 100644
index 000000000..fe29c89df
--- /dev/null
+++ b/libpthread/nptl/sysdeps/sh/pthread_spin_trylock.S
@@ -0,0 +1,31 @@
+/* Copyright (C) 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 <pthread-errnos.h>
+
+ .globl pthread_spin_trylock
+ .type pthread_spin_trylock,@function
+ .align 5
+pthread_spin_trylock:
+ tas.b @r4
+ bf/s 1f
+ mov #EBUSY, r0
+ mov #0, r0
+1:
+ rts
+ nop
+ .size pthread_spin_trylock,.-pthread_spin_trylock
diff --git a/libpthread/nptl/sysdeps/sh/pthread_spin_unlock.S b/libpthread/nptl/sysdeps/sh/pthread_spin_unlock.S
new file mode 100644
index 000000000..689b77584
--- /dev/null
+++ b/libpthread/nptl/sysdeps/sh/pthread_spin_unlock.S
@@ -0,0 +1,29 @@
+/* Copyright (C) 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/>. */
+
+ .globl pthread_spin_unlock
+ .type pthread_spin_unlock,@function
+ .align 5
+pthread_spin_unlock:
+ mov #0,r0
+ rts
+ mov.l r0,@r4
+ .size pthread_spin_unlock,.-pthread_spin_unlock
+
+ /* The implementation of pthread_spin_init is identical. */
+ .globl pthread_spin_init
+pthread_spin_init = pthread_spin_unlock
diff --git a/libpthread/nptl/sysdeps/sh/pthreaddef.h b/libpthread/nptl/sysdeps/sh/pthreaddef.h
new file mode 100644
index 000000000..fc3ae6029
--- /dev/null
+++ b/libpthread/nptl/sysdeps/sh/pthreaddef.h
@@ -0,0 +1,48 @@
+/* Copyright (C) 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 <sysdep.h>
+
+/* Default stack size. */
+#define ARCH_STACK_DEFAULT_SIZE (2 * 1024 * 1024)
+
+/* Required stack pointer alignment at beginning. */
+#define STACK_ALIGN 8
+
+/* Minimal stack size after allocating thread descriptor and guard size. */
+#define MINIMAL_REST_STACK 2048
+
+/* Alignment requirement for TCB. */
+#define TCB_ALIGNMENT 8
+
+
+/* Location of current stack frame. */
+#define CURRENT_STACK_FRAME __builtin_frame_address (0)
+
+
+/* XXX Until we have a better place keep the definitions here. */
+
+/* While there is no such syscall. */
+#define __exit_thread_inline(val) \
+ while (1) { \
+ if (__builtin_constant_p (val) && (val) == 0) \
+ __asm__ __volatile__ ("mov #0,r4; mov %0,r3; trapa #0x11\n\t" SYSCALL_INST_PAD \
+ :: "i" (__NR_exit)); \
+ else \
+ __asm__ __volatile__ ("mov %1,r4; mov %0,r3; trapa #0x11\n\t" SYSCALL_INST_PAD \
+ :: "i" (__NR_exit), "r" (val)); \
+ }
diff --git a/libpthread/nptl/sysdeps/sh/tcb-offsets.sym b/libpthread/nptl/sysdeps/sh/tcb-offsets.sym
new file mode 100644
index 000000000..753b72b2d
--- /dev/null
+++ b/libpthread/nptl/sysdeps/sh/tcb-offsets.sym
@@ -0,0 +1,15 @@
+#include <sysdep.h>
+#include <tls.h>
+
+RESULT offsetof (struct pthread, result)
+TID offsetof (struct pthread, tid)
+PID offsetof (struct pthread, pid)
+CANCELHANDLING offsetof (struct pthread, cancelhandling)
+CLEANUP_JMP_BUF offsetof (struct pthread, cleanup_jmp_buf)
+MULTIPLE_THREADS_OFFSET offsetof (struct pthread, header.multiple_threads)
+TLS_PRE_TCB_SIZE sizeof (struct pthread)
+MUTEX_FUTEX offsetof (pthread_mutex_t, __data.__lock)
+POINTER_GUARD offsetof (tcbhead_t, pointer_guard)
+#ifndef __ASSUME_PRIVATE_FUTEX
+PRIVATE_FUTEX offsetof (struct pthread, header.private_futex)
+#endif
diff --git a/libpthread/nptl/sysdeps/sh/tls.h b/libpthread/nptl/sysdeps/sh/tls.h
new file mode 100644
index 000000000..721429394
--- /dev/null
+++ b/libpthread/nptl/sysdeps/sh/tls.h
@@ -0,0 +1,181 @@
+/* Definition for thread-local data handling. NPTL/SH version.
+ Copyright (C) 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _TLS_H
+#define _TLS_H
+
+#ifndef __ASSEMBLER__
+# include <stdbool.h>
+# include <stddef.h>
+# include <stdint.h>
+# include <stdlib.h>
+# include <list.h>
+# include <sysdep.h>
+# include <bits/kernel-features.h>
+
+/* Type for the dtv. */
+typedef union dtv
+{
+ size_t counter;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
+} dtv_t;
+
+typedef struct
+{
+ dtv_t *dtv;
+ uintptr_t pointer_guard;
+} tcbhead_t;
+
+# define TLS_MULTIPLE_THREADS_IN_TCB 1
+
+#else /* __ASSEMBLER__ */
+# include <tcb-offsets.h>
+#endif /* __ASSEMBLER__ */
+
+
+/* We require TLS support in the tools. */
+#define HAVE_TLS_SUPPORT
+#define HAVE___THREAD 1
+#define HAVE_TLS_MODEL_ATTRIBUTE 1
+/* Signal that TLS support is available. */
+# define USE_TLS 1
+
+#ifndef __ASSEMBLER__
+
+/* Get system call information. */
+# include <sysdep.h>
+
+/* This is the size of the initial TCB. */
+# define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
+
+/* Alignment requirements for the initial TCB. */
+# define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
+
+/* This is the size of the TCB. */
+# define TLS_TCB_SIZE sizeof (tcbhead_t)
+
+/* This is the size we need before TCB. */
+# define TLS_PRE_TCB_SIZE sizeof (struct pthread)
+
+/* Alignment requirements for the TCB. */
+# define TLS_TCB_ALIGN __alignof__ (struct pthread)
+
+/* The TLS blocks start right after the TCB. */
+# define TLS_DTV_AT_TP 1
+
+/* Get the thread descriptor definition. */
+# include <descr.h>
+
+/* Install the dtv pointer. The pointer passed is to the element with
+ index -1 which contain the length. */
+# define INSTALL_DTV(tcbp, dtvp) \
+ ((tcbhead_t *) (tcbp))->dtv = (dtvp) + 1
+
+/* Install new dtv for current thread. */
+# define INSTALL_NEW_DTV(dtv) \
+ ({ tcbhead_t *__tcbp; \
+ __asm__ __volatile__ ("stc gbr,%0" : "=r" (__tcbp)); \
+ __tcbp->dtv = (dtv);})
+
+/* Return dtv of given thread descriptor. */
+# define GET_DTV(tcbp) \
+ (((tcbhead_t *) (tcbp))->dtv)
+
+/* Code to initially initialize the thread pointer. This might need
+ special attention since 'errno' is not yet available and if the
+ operation can cause a failure 'errno' must not be touched. */
+# define TLS_INIT_TP(tcbp, secondcall) \
+ ({ __asm__ __volatile__ ("ldc %0,gbr" : : "r" (tcbp)); 0; })
+
+/* Return the address of the dtv for the current thread. */
+# define THREAD_DTV() \
+ ({ tcbhead_t *__tcbp; \
+ __asm__ __volatile__ ("stc gbr,%0" : "=r" (__tcbp)); \
+ __tcbp->dtv;})
+
+/* Return the thread descriptor for the current thread.
+ The contained asm must *not* be marked volatile since otherwise
+ assignments like
+ struct pthread *self = thread_self();
+ do not get optimized away. */
+# define THREAD_SELF \
+ ({ struct pthread *__self; \
+ __asm__ ("stc gbr,%0" : "=r" (__self)); \
+ __self - 1;})
+
+/* Magic for libthread_db to know how to do THREAD_SELF. */
+# define DB_THREAD_SELF \
+ REGISTER (32, 32, REG_GBR * 4, -sizeof (struct pthread))
+
+/* Read member of the thread descriptor directly. */
+# define THREAD_GETMEM(descr, member) (descr->member)
+
+/* Same as THREAD_GETMEM, but the member offset can be non-constant. */
+# define THREAD_GETMEM_NC(descr, member, idx) (descr->member[idx])
+
+/* Set member of the thread descriptor directly. */
+# define THREAD_SETMEM(descr, member, value) \
+ descr->member = (value)
+
+/* Same as THREAD_SETMEM, but the member offset can be non-constant. */
+# define THREAD_SETMEM_NC(descr, member, idx, value) \
+ descr->member[idx] = (value)
+
+#define THREAD_GET_POINTER_GUARD() \
+ ({ tcbhead_t *__tcbp; \
+ __asm__ __volatile__ ("stc gbr,%0" : "=r" (__tcbp)); \
+ __tcbp->pointer_guard;})
+ #define THREAD_SET_POINTER_GUARD(value) \
+ ({ tcbhead_t *__tcbp; \
+ __asm__ __volatile__ ("stc gbr,%0" : "=r" (__tcbp)); \
+ __tcbp->pointer_guard = (value);})
+#define THREAD_COPY_POINTER_GUARD(descr) \
+ ({ tcbhead_t *__tcbp; \
+ __asm__ __volatile__ ("stc gbr,%0" : "=r" (__tcbp)); \
+ ((tcbhead_t *) (descr + 1))->pointer_guard = __tcbp->pointer_guard;})
+
+/* Get and set the global scope generation counter in struct pthread. */
+#define THREAD_GSCOPE_FLAG_UNUSED 0
+#define THREAD_GSCOPE_FLAG_USED 1
+#define THREAD_GSCOPE_FLAG_WAIT 2
+#define THREAD_GSCOPE_RESET_FLAG() \
+ do \
+ { int __res \
+ = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \
+ THREAD_GSCOPE_FLAG_UNUSED); \
+ if (__res == THREAD_GSCOPE_FLAG_WAIT) \
+ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \
+ } \
+ while (0)
+#define THREAD_GSCOPE_SET_FLAG() \
+ do \
+ { \
+ THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED; \
+ atomic_write_barrier (); \
+ } \
+ while (0)
+#define THREAD_GSCOPE_WAIT() \
+ GL(dl_wait_lookup_done) ()
+
+#endif /* __ASSEMBLER__ */
+
+#endif /* tls.h */
diff --git a/libpthread/nptl/sysdeps/sparc/Makefile b/libpthread/nptl/sysdeps/sparc/Makefile
new file mode 100644
index 000000000..81bddf688
--- /dev/null
+++ b/libpthread/nptl/sysdeps/sparc/Makefile
@@ -0,0 +1,3 @@
+ifeq ($(subdir),csu)
+gen-as-const-headers += tcb-offsets.sym
+endif
diff --git a/libpthread/nptl/sysdeps/sparc/Makefile.arch b/libpthread/nptl/sysdeps/sparc/Makefile.arch
new file mode 100644
index 000000000..f9662c60c
--- /dev/null
+++ b/libpthread/nptl/sysdeps/sparc/Makefile.arch
@@ -0,0 +1,8 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2005 Steven J. Hill <sjhill@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+CFLAGS-pthread_spin_lock.c += -D_GNU_SOURCE
diff --git a/libpthread/nptl/sysdeps/sparc/dl-tls.h b/libpthread/nptl/sysdeps/sparc/dl-tls.h
new file mode 100644
index 000000000..7d9e8f0f7
--- /dev/null
+++ b/libpthread/nptl/sysdeps/sparc/dl-tls.h
@@ -0,0 +1,28 @@
+/* Thread-local storage handling in the ELF dynamic linker. SPARC version.
+ Copyright (C) 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/>. */
+
+
+/* Type used for the representation of TLS information in the GOT. */
+typedef struct
+{
+ unsigned long int ti_module;
+ unsigned long int ti_offset;
+} tls_index;
+
+
+extern void *__tls_get_addr (tls_index *ti);
diff --git a/libpthread/nptl/sysdeps/sparc/jmpbuf-unwind.h b/libpthread/nptl/sysdeps/sparc/jmpbuf-unwind.h
new file mode 100644
index 000000000..2f64e7d7c
--- /dev/null
+++ b/libpthread/nptl/sysdeps/sparc/jmpbuf-unwind.h
@@ -0,0 +1,27 @@
+/* Copyright (C) 2003, 2004 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/>. */
+
+#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))
diff --git a/libpthread/nptl/sysdeps/sparc/pthread_spin_lock.c b/libpthread/nptl/sysdeps/sparc/pthread_spin_lock.c
new file mode 100644
index 000000000..2dfcd3c24
--- /dev/null
+++ b/libpthread/nptl/sysdeps/sparc/pthread_spin_lock.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 2003 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/>. */
+
+#include "pthreadP.h"
+
+int
+pthread_spin_lock (pthread_spinlock_t *lock)
+{
+ __asm__ __volatile__
+ ("1: ldstub [%0], %%g2\n"
+ " orcc %%g2, 0x0, %%g0\n"
+ " bne,a 2f\n"
+ " ldub [%0], %%g2\n"
+ ".subsection 2\n"
+ "2: orcc %%g2, 0x0, %%g0\n"
+ " bne,a 2b\n"
+ " ldub [%0], %%g2\n"
+ " b,a 1b\n"
+ ".previous"
+ : /* no outputs */
+ : "r" (lock)
+ : "g2", "memory", "cc");
+ return 0;
+}
diff --git a/libpthread/nptl/sysdeps/sparc/pthread_spin_trylock.c b/libpthread/nptl/sysdeps/sparc/pthread_spin_trylock.c
new file mode 100644
index 000000000..c1b7b2397
--- /dev/null
+++ b/libpthread/nptl/sysdeps/sparc/pthread_spin_trylock.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 2003 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/>. */
+
+#include <errno.h>
+#include "pthreadP.h"
+
+int
+pthread_spin_trylock (pthread_spinlock_t *lock)
+{
+ int res;
+ __asm__ __volatile__ ("ldstub [%1], %0" : "=r" (res) : "r" (lock) : "memory");
+ return res == 0 ? 0 : EBUSY;
+}
diff --git a/libpthread/nptl/sysdeps/sparc/pthreaddef.h b/libpthread/nptl/sysdeps/sparc/pthreaddef.h
new file mode 100644
index 000000000..435fedcf3
--- /dev/null
+++ b/libpthread/nptl/sysdeps/sparc/pthreaddef.h
@@ -0,0 +1,39 @@
+/* Copyright (C) 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/>. */
+
+/* Default stack size. */
+#define ARCH_STACK_DEFAULT_SIZE (2 * 1024 * 1024)
+
+/* Required stack pointer alignment at beginning. */
+#define STACK_ALIGN 16
+
+/* Minimal stack size after allocating thread descriptor and guard size. */
+#define MINIMAL_REST_STACK 2048
+
+/* Alignment requirement for TCB. */
+#define TCB_ALIGNMENT 16
+
+
+/* Location of current stack frame. */
+#define CURRENT_STACK_FRAME (stack_pointer + (2 * 64))
+register char *stack_pointer __asm__("%sp");
+
+/* XXX Until we have a better place keep the definitions here. */
+
+/* While there is no such syscall. */
+#define __exit_thread_inline(val) \
+ INLINE_SYSCALL (exit, 1, (val))
diff --git a/libpthread/nptl/sysdeps/sparc/tcb-offsets.sym b/libpthread/nptl/sysdeps/sparc/tcb-offsets.sym
new file mode 100644
index 000000000..923af8a5b
--- /dev/null
+++ b/libpthread/nptl/sysdeps/sparc/tcb-offsets.sym
@@ -0,0 +1,7 @@
+#include <sysdep.h>
+#include <tls.h>
+
+MULTIPLE_THREADS_OFFSET offsetof (tcbhead_t, multiple_threads)
+POINTER_GUARD offsetof (tcbhead_t, pointer_guard)
+PID offsetof (struct pthread, pid)
+TID offsetof (struct pthread, tid)
diff --git a/libpthread/nptl/sysdeps/sparc/tls.h b/libpthread/nptl/sysdeps/sparc/tls.h
new file mode 100644
index 000000000..0fdfff328
--- /dev/null
+++ b/libpthread/nptl/sysdeps/sparc/tls.h
@@ -0,0 +1,180 @@
+/* Definitions for thread-local data handling. NPTL/sparc version.
+ Copyright (C) 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _TLS_H
+#define _TLS_H
+
+#ifndef __ASSEMBLER__
+# include <stdbool.h>
+# include <stddef.h>
+# include <stdint.h>
+# include <stdlib.h>
+# include <list.h>
+# include <bits/kernel-features.h>
+
+/* Type for the dtv. */
+typedef union dtv
+{
+ size_t counter;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
+} dtv_t;
+
+typedef struct
+{
+ void *tcb; /* Pointer to the TCB. Not necessary the
+ thread descriptor used by libpthread. */
+ dtv_t *dtv;
+ void *self;
+ int multiple_threads;
+#if __WORDSIZE == 64
+ int gscope_flag;
+#endif
+ uintptr_t sysinfo;
+ uintptr_t stack_guard;
+ uintptr_t pointer_guard;
+#if __WORDSIZE != 64
+ int gscope_flag;
+#endif
+#ifndef __ASSUME_PRIVATE_FUTEX
+ int private_futex;
+#endif
+} tcbhead_t;
+
+#else /* __ASSEMBLER__ */
+# include <tcb-offsets.h>
+#endif /* __ASSEMBLER__ */
+
+/* We require TLS support in the tools. */
+#define HAVE_TLS_SUPPORT
+#define HAVE___THREAD 1
+#define HAVE_TLS_MODEL_ATTRIBUTE 1
+
+/* Signal that TLS support is available. */
+#define USE_TLS 1
+
+#ifndef __ASSEMBLER__
+/* Get system call information. */
+# include <sysdep.h>
+
+/* Get the thread descriptor definition. */
+# include <descr.h>
+
+register struct pthread *__thread_self __asm__("%g7");
+
+/* This is the size of the initial TCB. Can't be just sizeof (tcbhead_t),
+ because NPTL getpid, __libc_alloca_cutoff etc. need (almost) the whole
+ struct pthread even when not linked with -lpthread. */
+# define TLS_INIT_TCB_SIZE sizeof (struct pthread)
+
+/* Alignment requirements for the initial TCB. */
+# define TLS_INIT_TCB_ALIGN __alignof__ (struct pthread)
+
+/* This is the size of the TCB. */
+# define TLS_TCB_SIZE sizeof (struct pthread)
+
+/* Alignment requirements for the TCB. */
+# define TLS_TCB_ALIGN __alignof__ (struct pthread)
+
+/* The TCB can have any size and the memory following the address the
+ thread pointer points to is unspecified. Allocate the TCB there. */
+# define TLS_TCB_AT_TP 1
+
+/* Install the dtv pointer. The pointer passed is to the element with
+ index -1 which contain the length. */
+# define INSTALL_DTV(descr, dtvp) \
+ ((tcbhead_t *) (descr))->dtv = (dtvp) + 1
+
+/* Install new dtv for current thread. */
+# define INSTALL_NEW_DTV(DTV) \
+ (((tcbhead_t *) __thread_self)->dtv = (DTV))
+
+/* Return dtv of given thread descriptor. */
+# define GET_DTV(descr) \
+ (((tcbhead_t *) (descr))->dtv)
+
+/* Code to initially initialize the thread pointer. */
+# define TLS_INIT_TP(descr, secondcall) \
+ (__thread_self = (__typeof (__thread_self)) (descr), NULL)
+
+/* Return the address of the dtv for the current thread. */
+# define THREAD_DTV() \
+ (((tcbhead_t *) __thread_self)->dtv)
+
+/* Return the thread descriptor for the current thread. */
+#define THREAD_SELF __thread_self
+
+/* Magic for libthread_db to know how to do THREAD_SELF. */
+# define DB_THREAD_SELF_INCLUDE <sys/ucontext.h>
+# define DB_THREAD_SELF \
+ REGISTER (32, 32, REG_G7 * 4, 0) REGISTER (64, 64, REG_G7 * 8, 0)
+
+/* Access to data in the thread descriptor is easy. */
+#define THREAD_GETMEM(descr, member) \
+ descr->member
+#define THREAD_GETMEM_NC(descr, member, idx) \
+ descr->member[idx]
+#define THREAD_SETMEM(descr, member, value) \
+ descr->member = (value)
+#define THREAD_SETMEM_NC(descr, member, idx, value) \
+ descr->member[idx] = (value)
+
+/* Set the stack guard field in TCB head. */
+#define THREAD_SET_STACK_GUARD(value) \
+ THREAD_SETMEM (THREAD_SELF, header.stack_guard, value)
+# define THREAD_COPY_STACK_GUARD(descr) \
+ ((descr)->header.stack_guard \
+ = THREAD_GETMEM (THREAD_SELF, header.stack_guard))
+
+/* Get/set the stack guard field in TCB head. */
+#define THREAD_GET_POINTER_GUARD() \
+ THREAD_GETMEM (THREAD_SELF, header.pointer_guard)
+#define THREAD_SET_POINTER_GUARD(value) \
+ THREAD_SETMEM (THREAD_SELF, header.pointer_guard, value)
+# define THREAD_COPY_POINTER_GUARD(descr) \
+ ((descr)->header.pointer_guard = THREAD_GET_POINTER_GUARD ())
+
+/* Get and set the global scope generation counter in struct pthread. */
+#define THREAD_GSCOPE_FLAG_UNUSED 0
+#define THREAD_GSCOPE_FLAG_USED 1
+#define THREAD_GSCOPE_FLAG_WAIT 2
+#define THREAD_GSCOPE_RESET_FLAG() \
+ do \
+ { int __res \
+ = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \
+ THREAD_GSCOPE_FLAG_UNUSED); \
+ if (__res == THREAD_GSCOPE_FLAG_WAIT) \
+ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \
+ } \
+ while (0)
+#define THREAD_GSCOPE_SET_FLAG() \
+ do \
+ { \
+ THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED; \
+ atomic_write_barrier (); \
+ } \
+ while (0)
+#define THREAD_GSCOPE_WAIT() \
+ GL(dl_wait_lookup_done) ()
+
+#endif /* !ASSEMBLER */
+
+#endif /* tls.h */
diff --git a/libpthread/nptl/sysdeps/unix/Makefile b/libpthread/nptl/sysdeps/unix/Makefile
new file mode 100644
index 000000000..3ed177ae2
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/Makefile
@@ -0,0 +1,13 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+top_srcdir=../../../../
+top_builddir=../../../../
+all: objs
+include $(top_builddir)Rules.mak
+include Makefile.in
+include $(top_srcdir)Makerules
diff --git a/libpthread/nptl/sysdeps/unix/Makefile.in b/libpthread/nptl/sysdeps/unix/Makefile.in
new file mode 100644
index 000000000..c2c9bcd36
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/Makefile.in
@@ -0,0 +1,8 @@
+# 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.
+#
+
+subdirs += libpthread/nptl/sysdeps/unix
diff --git a/libpthread/nptl/sysdeps/unix/sysv/Makefile b/libpthread/nptl/sysdeps/unix/sysv/Makefile
new file mode 100644
index 000000000..64f51c8dd
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/Makefile
@@ -0,0 +1,13 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+top_srcdir=../../../../../
+top_builddir=../../../../../
+all: objs
+include $(top_builddir)Rules.mak
+include Makefile.in
+include $(top_srcdir)Makerules
diff --git a/libpthread/nptl/sysdeps/unix/sysv/Makefile.in b/libpthread/nptl/sysdeps/unix/sysv/Makefile.in
new file mode 100644
index 000000000..832561646
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/Makefile.in
@@ -0,0 +1,8 @@
+# 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.
+#
+
+subdirs += libpthread/nptl/sysdeps/unix/sysv
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile b/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile
new file mode 100644
index 000000000..930ff5654
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile
@@ -0,0 +1,13 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2005 Steven J. Hill <sjhill@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+top_srcdir=../../../../../../
+top_builddir=../../../../../../
+all: objs
+include $(top_builddir)Rules.mak
+include Makefile.commonarch
+include $(top_srcdir)Makerules
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile.commonarch b/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile.commonarch
new file mode 100644
index 000000000..4e147734c
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile.commonarch
@@ -0,0 +1,169 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2006 Steven J. Hill <sjhill@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+subdirs += libpthread/nptl/sysdeps/unix/sysv/linux \
+ libpthread/nptl/sysdeps/unix/sysv/linux/$(TARGET_ARCH)
+ifneq ($(abspath libpthread/nptl/sysdeps/unix/sysv/linux/$(TARGET_ARCH)),$(abspath libpthread/nptl/sysdeps/unix/sysv/linux/$(TARGET_ARCH)/$(TARGET_SUBARCH)))
+subdirs += libpthread/nptl/sysdeps/unix/sysv/linux/$(TARGET_ARCH)/$(TARGET_SUBARCH)
+endif
+
+libpthread_linux_DIR := $(top_srcdir)libpthread/nptl/sysdeps/unix/sysv/linux
+libpthread_linux_OUT := $(top_builddir)libpthread/nptl/sysdeps/unix/sysv/linux
+libpthread_linux_arch_DIR := $(libpthread_linux_DIR)/$(TARGET_ARCH)
+libpthread_linux_arch_OUT := $(libpthread_linux_OUT)/$(TARGET_ARCH)
+
+libc_linux_CSRC :=
+libpthread_linux_CSRC :=
+librt_linux_CSRC :=
+
+-include $(libpthread_linux_arch_DIR)/Makefile.arch
+
+ifneq ($(TARGET_SUBARCH),)
+libpthread_linux_subarch_DIR := $(libpthread_linux_arch_DIR)/$(TARGET_SUBARCH)
+libpthread_linux_subarch_OUT := $(libpthread_linux_arch_OUT)/$(TARGET_SUBARCH)
+
+libpthread_linux_subarch_SSRC := $(notdir $(wildcard $(libpthread_linux_subarch_DIR)/*.S))
+libc_linux_subarch_SSRC := $(notdir $(wildcard $(libpthread_linux_subarch_DIR)/libc-*.S))
+librt_linux_subarch_SSRC := $(notdir $(wildcard $(libpthread_linux_subarch_DIR)/librt-*.S))
+ifneq ($(libc_linux_subarch_SSRC)$(librt_linux_subarch_SSRC),)
+libpthread_linux_subarch_SSRC := $(filter-out $(libc_linux_subarch_SSRC) $(librt_linux_subarch_SSRC),$(libpthread_linux_subarch_SSRC))
+libc_linux_arch_CSRC := $(filter-out $(libc_linux_subarch_SSRC:.S=.c),$(libc_linux_arch_CSRC))
+libc_linux_arch_SSRC := $(filter-out $(libc_linux_subarch_SSRC),$(libc_linux_arch_SSRC))
+endif
+ifneq ($(libpthread_linux_subarch_SSRC),)
+libpthread_linux_arch_SSRC := $(filter-out $(libpthread_linux_subarch_SSRC),$(libpthread_linux_arch_SSRC))
+libpthread_linux_arch_CSRC := $(filter-out $(libpthread_linux_subarch_SSRC:.S=.c),$(libpthread_linux_arch_CSRC))
+endif
+ifneq ($(librt_linux_subarch_SSRC),)
+librt_linux_arch_SSRC := $(filter-out $(librt_linux_subarch_SSRC),$(librt_linux_arch_SSRC))
+librt_linux_arch_CSRC := $(filter-out $(librt_linux_subarch_SSRC:.S=.c),$(librt_linux_arch_CSRC))
+endif
+libpthread_linux_subarch_SOBJ = $(patsubst %.S,$(libpthread_linux_subarch_OUT)/%.o,$(libpthread_linux_subarch_SSRC))
+libc_linux_subarch_SOBJ := $(patsubst %.S,$(libpthread_linux_subarch_OUT)/%.o,$(libc_linux_subarch_SSRC))
+librt_linux_subarch_SOBJ := $(patsubst %.S,$(libpthread_linux_subarch_OUT)/%.o,$(librt_linux_subarch_SSRC))
+endif
+
+libpthread_linux_arch_SOBJ = $(patsubst %.S,$(libpthread_linux_arch_OUT)/%.o,$(libpthread_linux_arch_SSRC))
+libpthread_linux_arch_COBJ = $(patsubst %.c,$(libpthread_linux_arch_OUT)/%.o,$(libpthread_linux_arch_CSRC))
+libpthread_linux_arch_OBJS := $(libpthread_linux_subarch_SOBJ) $(libpthread_linux_arch_SOBJ) $(libpthread_linux_arch_COBJ)
+libc_linux_arch_SOBJ = $(patsubst %.S,$(libpthread_linux_arch_OUT)/%.o,$(libc_linux_arch_SSRC))
+libc_linux_arch_COBJ = $(patsubst %.c,$(libpthread_linux_arch_OUT)/%.o,$(libc_linux_arch_CSRC))
+libc_linux_arch_OBJS := $(libc_linux_subarch_SOBJ) $(libc_linux_arch_SOBJ) $(libc_linux_arch_COBJ)
+librt_linux_arch_SOBJ = $(patsubst %.S,$(libpthread_linux_arch_OUT)/%.o,$(librt_linux_arch_SSRC))
+librt_linux_arch_COBJ = $(patsubst %.c,$(libpthread_linux_arch_OUT)/%.o,$(librt_linux_arch_CSRC))
+librt_linux_arch_OBJS := $(librt_linux_subarch_SOBJ) $(librt_linux_arch_SOBJ) $(librt_linux_arch_COBJ)
+
+libpthread_linux_CSRC += pthread_attr_getaffinity.c pthread_attr_setaffinity.c \
+ pthread_getaffinity.c pthread_setaffinity.c \
+ pthread_getcpuclockid.c pthread_kill.c \
+ pthread_mutex_cond_lock.c pthread_yield.c \
+ sem_post.c sem_timedwait.c sem_trywait.c sem_wait.c \
+ pt-tempname.c \
+ pthread_sigqueue.c \
+ lowlevellock.c lowlevelrobustlock.c
+# pt-sleep.c pt-fork.c sigtimedwait.c sigwaitinfo.c sigwait.c
+
+libpthread_linux_SSRC := #ptw-close.S ptw-open.S ptw-waitid.S ptw-waidpid.S ptw-write.S
+
+libc_linux_CSRC += libc_pthread_init.c libc_multiple_threads.c \
+ register-atfork.c unregister-atfork.c getpid.c \
+ raise.c jmp-unwind.c libc-lowlevellock.c
+ #sleep.c
+
+librt_linux_CSRC += mq_notify.c timer_create.c timer_delete.c \
+ timer_getoverr.c timer_gettime.c timer_routines.c \
+ timer_settime.c
+
+# These provide both a cancellable and a not cancellable implementation
+libc_linux_SSRC = #close.S open.S write.S read.S waitpid.S
+libc_linux_SSRC := $(filter-out $(libc_linux_arch_SSRC-OMIT),$(libc_linux_SSRC))
+
+libpthread_linux_CSRC := $(filter-out $(notdir $(libpthread_linux_arch_OBJS:.o=.c)),$(libpthread_linux_CSRC))
+libpthread_linux_SSRC := $(filter-out $(notdir $(libpthread_linux_arch_OBJS:.o=.S)),$(libpthread_linux_SSRC))
+libc_linux_SSRC := $(filter-out $(notdir $(libc_linux_arch_OBJS:.o=.S)),$(libc_linux_SSRC))
+libc_linux_CSRC := $(filter-out $(notdir $(libc_linux_arch_OBJS:.o=.c)),$(libc_linux_CSRC))
+librt_linux_SSRC := $(filter-out $(notdir $(librt_linux_arch_OBJS:.o=.S)),$(librt_linux_SSRC))
+librt_linux_CSRC := $(filter-out $(notdir $(librt_linux_arch_OBJS:.o=.c)),$(librt_linux_CSRC))
+
+libpthread_linux_OBJS = $(libpthread_linux_arch_OBJS)
+libpthread_linux_OBJS += $(patsubst %.c,$(libpthread_linux_OUT)/%.o,$(libpthread_linux_CSRC))
+libpthread_linux_OBJS += $(patsubst %.S,$(libpthread_linux_OUT)/%.o,$(libpthread_linux_SSRC))
+ifneq ($(libpthread_linux_OMIT_OBJS),)
+libpthread_linux_OBJS := $(filter-out $(libpthread_linux_OMIT_OBJS),$(libpthread_linux_OBJS))
+endif
+
+libpthread-a-y += $(if $(DOPIC),$(libpthread_linux_OBJS:.o=.os),$(libpthread_linux_OBJS))
+libpthread-so-y += $(libpthread_linux_OBJS:.o=.oS)
+libpthread-so-y += $(libpthread_linux_OUT)/pt-raise.oS
+#libpthread-nomulti-y += $(libpthread_linux_OBJS)
+
+libc_linux_OBJS := $(libc_linux_arch_OBJS)
+libc_linux_OBJS += $(patsubst %.c,$(libpthread_linux_OUT)/%.o,$(libc_linux_CSRC))
+libc_linux_OBJS += $(patsubst %.S,$(libpthread_linux_OUT)/%.o,$(libc_linux_SSRC))
+ifneq ($(libc_linux_OMIT_OBJS),)
+libc_linux_OBJS := $(filter-out $(libc_linux_OMIT_OBJS),$(libc_linux_OBJS))
+endif
+
+libc-static-y += $(libc_linux_OBJS)
+libc-shared-y += $(libc_linux_OBJS:.o=.oS)
+#libc-nomulti-y += $(libc_linux_OBJS)
+
+librt_linux_OBJS := $(librt_linux_arch_OBJS)
+librt_linux_OBJS += $(patsubst %.c,$(libpthread_linux_OUT)/%.o,$(librt_linux_CSRC))
+librt_linux_OBJS += $(patsubst %.S,$(libpthread_linux_OUT)/%.o,$(librt_linux_SSRC))
+
+objclean-y += CLEAN_libpthread/nptl/sysdeps/unix/sysv/linux
+headers_clean-y += HEADERCLEAN_libpthread/nptl/sysdeps/unix/sysv/linux
+
+CFLAGS-pthread_getcpuclockid.c = -I$(top_srcdir)librt
+CFLAGS-pt-pread_pwrite.c = -I$(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH) \
+ -I$(top_srcdir)libc/sysdeps/linux/common
+CFLAGS-mq_notify.c = -I$(top_srcdir)librt
+CFLAGS-timer_create.c = -I$(top_srcdir)librt
+CFLAGS-timer_delete.c = -I$(top_srcdir)librt
+CFLAGS-timer_getoverr.c = -I$(top_srcdir)librt
+CFLAGS-timer_gettime.c = -I$(top_srcdir)librt
+CFLAGS-timer_routines.c = -I$(top_srcdir)librt
+CFLAGS-timer_settime.c = -I$(top_srcdir)librt
+
+ifneq ($(UCLIBC_HAS_BACKTRACE),)
+CFLAGS-raise.c = -fasynchronous-unwind-tables
+endif
+
+PTHREAD_LINUX_SYM := $(notdir $(wildcard $(libpthread_linux_DIR)/*.sym))
+PTHREAD_LINUX_SYM_H := $(addprefix $(libpthread_linux_OUT)/,$(PTHREAD_LINUX_SYM:.sym=.h))
+
+$(PTHREAD_LINUX_SYM_H): $(top_srcdir)extra/scripts/gen-as-const.awk
+$(PTHREAD_LINUX_SYM_H): $(libpthread_linux_OUT)/%.h: $(libpthread_linux_DIR)/%.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_THREADS_NATIVE) += $(PTHREAD_LINUX_SYM_H)
+
+HEADERS_BITS_PTHREAD := $(notdir $(wildcard $(libpthread_linux_DIR)/bits/*.h))
+ALL_HEADERS_BITS_PTHREAD := $(addprefix $(top_builddir)include/bits/,$(HEADERS_BITS_PTHREAD))
+
+$(ALL_HEADERS_BITS_PTHREAD): $(top_builddir)include/bits/%: | $(top_builddir)include/bits
+ $(do_ln) $(call rel_srcdir)$(libpthread_linux_DIR)/bits/$(@F) $@
+
+HEADERCLEAN_libpthread/nptl/sysdeps/unix/sysv/linux:
+ $(do_rm) $(PTHREAD_LINUX_SYM_H)
+
+CLEAN_libpthread/nptl/sysdeps/unix/sysv/linux:
+ $(do_rm) $(addprefix $(libpthread_linux_OUT)/*., o os oS)
+
+objclean-y+=CLEAN_libpthread/nptl/sysdeps/unix/sysv/linux/$(TARGET_ARCH)
+CLEAN_libpthread/nptl/sysdeps/unix/sysv/linux/$(TARGET_ARCH):
+ $(do_rm) $(addprefix $(libpthread_linux_arch_OUT)/*., o os oS)
+ifneq ($(TARGET_SUBARCH),)
+objclean-y+=CLEAN_libpthread/nptl/sysdeps/unix/sysv/linux/$(TARGET_ARCH)/$(TARGET_SUBARCH)
+CLEAN_libpthread/nptl/sysdeps/unix/sysv/linux/$(TARGET_ARCH)/$(TARGET_SUBARCH):
+ $(do_rm) $(addprefix $(libpthread_linux_subarch_OUT)/*., o os oS)
+endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/__syscall_error.c b/libpthread/nptl/sysdeps/unix/sysv/linux/__syscall_error.c
new file mode 100644
index 000000000..5e109a83b
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/__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, 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/libpthread/nptl/sysdeps/unix/sysv/linux/accept.S b/libpthread/nptl/sysdeps/unix/sysv/linux/accept.S
new file mode 100644
index 000000000..529763d80
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/accept.S
@@ -0,0 +1,12 @@
+#include <sysdep-cancel.h>
+#ifndef __NR_accept
+#error Missing definition of NR_accept needed for cancellation.
+#endif
+PSEUDO (__libc_accept, accept, 3)
+ret
+PSEUDO_END(__libc_accept)
+libc_hidden_def (__libc_accept)
+weak_alias (__libc_accept, __accept)
+libc_hidden_weak (__accept)
+weak_alias (__libc_accept, accept)
+libc_hidden_weak (accept)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/Makefile b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/Makefile
new file mode 100644
index 000000000..8c8084079
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/Makefile
@@ -0,0 +1,2 @@
+# pull in __syscall_error routine, __sigprocmask, __syscall_rt_sigaction
+libpthread-routines += ptw-sysdep ptw-sigprocmask ptw-rt_sigaction
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/bits/local_lim.h b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/bits/local_lim.h
new file mode 100644
index 000000000..263dc0aff
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/bits/local_lim.h
@@ -0,0 +1,99 @@
+/* Minimum guaranteed maximum values for system limits. Linux/Alpha 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/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h
new file mode 100644
index 000000000..c5330e130
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h
@@ -0,0 +1,167 @@
+/* Machine-specific pthread type layouts. Alpha version.
+ Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _BITS_PTHREADTYPES_H
+#define _BITS_PTHREADTYPES_H 1
+
+#define __SIZEOF_PTHREAD_ATTR_T 56
+#define __SIZEOF_PTHREAD_MUTEX_T 40
+#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
+#define __SIZEOF_PTHREAD_COND_T 48
+#define __SIZEOF_PTHREAD_CONDATTR_T 4
+#define __SIZEOF_PTHREAD_RWLOCK_T 56
+#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
+#define __SIZEOF_PTHREAD_BARRIER_T 32
+#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
+
+
+/* Thread identifiers. The structure of the attribute type is
+ deliberately not exposed. */
+typedef unsigned long int pthread_t;
+
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_ATTR_T];
+ long int __align;
+} pthread_attr_t;
+
+
+typedef struct __pthread_internal_list
+{
+ struct __pthread_internal_list *__prev;
+ struct __pthread_internal_list *__next;
+} __pthread_list_t;
+
+
+/* Data structures for mutex handling. The structure of the attribute
+ type is deliberately not exposed. */
+typedef union
+{
+ struct __pthread_mutex_s
+ {
+ int __lock;
+ unsigned int __count;
+ int __owner;
+ unsigned int __nusers;
+ /* KIND must stay at this position in the structure to maintain
+ binary compatibility. */
+ int __kind;
+ int __spins;
+ __pthread_list_t __list;
+#define __PTHREAD_MUTEX_HAVE_PREV 1
+ } __data;
+ char __size[__SIZEOF_PTHREAD_MUTEX_T];
+ long int __align;
+} pthread_mutex_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
+ int __align;
+} pthread_mutexattr_t;
+
+
+/* Data structure for conditional variable handling. The structure of
+ the attribute type is deliberately not exposed. */
+typedef union
+{
+ struct
+ {
+ int __lock;
+ unsigned int __futex;
+ __extension__ unsigned long long int __total_seq;
+ __extension__ unsigned long long int __wakeup_seq;
+ __extension__ unsigned long long int __woken_seq;
+ void *__mutex;
+ unsigned int __nwaiters;
+ unsigned int __broadcast_seq;
+ } __data;
+ char __size[__SIZEOF_PTHREAD_COND_T];
+ __extension__ long long int __align;
+} pthread_cond_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_CONDATTR_T];
+ int __align;
+} pthread_condattr_t;
+
+
+/* Keys for thread-specific data */
+typedef unsigned int pthread_key_t;
+
+
+/* Once-only execution */
+typedef int pthread_once_t;
+
+
+#if defined __USE_UNIX98 || defined __USE_XOPEN2K
+/* Data structure for read-write lock variable handling. The
+ structure of the attribute type is deliberately not exposed. */
+typedef union
+{
+ struct
+ {
+ int __lock;
+ unsigned int __nr_readers;
+ unsigned int __readers_wakeup;
+ unsigned int __writer_wakeup;
+ unsigned int __nr_readers_queued;
+ unsigned int __nr_writers_queued;
+ int __writer;
+ int __shared;
+ unsigned long int __pad1;
+ unsigned long int __pad2;
+ /* FLAGS must stay at this position in the structure to maintain
+ binary compatibility. */
+ unsigned int __flags;
+ } __data;
+ char __size[__SIZEOF_PTHREAD_RWLOCK_T];
+ long int __align;
+} pthread_rwlock_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
+ long int __align;
+} pthread_rwlockattr_t;
+#endif
+
+
+#ifdef __USE_XOPEN2K
+/* POSIX spinlock data type. */
+typedef volatile int pthread_spinlock_t;
+
+/* POSIX barriers data type. The structure of the type is
+ deliberately not exposed. */
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_BARRIER_T];
+ long int __align;
+} pthread_barrier_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];
+ int __align;
+} pthread_barrierattr_t;
+#endif
+
+
+#endif /* bits/pthreadtypes.h */
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/bits/semaphore.h b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/bits/semaphore.h
new file mode 100644
index 000000000..2a0a5a16e
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/bits/semaphore.h
@@ -0,0 +1,33 @@
+/* Machine-specific POSIX semaphore type layouts. Alpha version.
+ Copyright (C) 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 _SEMAPHORE_H
+# error "Never use <bits/semaphore.h> directly; include <semaphore.h> instead."
+#endif
+
+# define __SIZEOF_SEM_T 32
+
+/* Value returned if `sem_open' failed. */
+#define SEM_FAILED ((sem_t *) 0)
+
+
+typedef union
+{
+ char __size[__SIZEOF_SEM_T];
+ long int __align;
+} sem_t;
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/clone.S b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/clone.S
new file mode 100644
index 000000000..eea1cbeed
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/clone.S
@@ -0,0 +1,2 @@
+#define RESET_PID
+#include <sysdeps/unix/sysv/linux/alpha/clone.S>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/createthread.c b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/createthread.c
new file mode 100644
index 000000000..340edf456
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/createthread.c
@@ -0,0 +1,22 @@
+/* Copyright (C) 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/>. */
+
+/* Value passed to 'clone' for initialization of the thread register. */
+#define TLS_VALUE (pd + 1)
+
+/* Get the real implementation. */
+#include <sysdeps/pthread/createthread.c>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/fork.c b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/fork.c
new file mode 100644
index 000000000..3c4c02890
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/fork.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 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 <sched.h>
+#include <signal.h>
+#include <sysdep.h>
+#include <tls.h>
+
+
+#define ARCH_FORK() \
+ INLINE_SYSCALL (clone, 5, \
+ CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID | SIGCHLD, \
+ NULL, NULL, &THREAD_SELF->tid, NULL)
+
+#include "../fork.c"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/lowlevellock.h b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/lowlevellock.h
new file mode 100644
index 000000000..b09340f22
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/lowlevellock.h
@@ -0,0 +1,283 @@
+/* Copyright (C) 2003, 2004, 2006, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef _LOWLEVELLOCK_H
+#define _LOWLEVELLOCK_H 1
+
+#include <time.h>
+#include <sys/param.h>
+#include <bits/pthreadtypes.h>
+#include <atomic.h>
+#include <sysdep.h>
+#include <bits/kernel-features.h>
+
+
+#define FUTEX_WAIT 0
+#define FUTEX_WAKE 1
+#define FUTEX_REQUEUE 3
+#define FUTEX_CMP_REQUEUE 4
+#define FUTEX_WAKE_OP 5
+#define FUTEX_OP_CLEAR_WAKE_IF_GT_ONE ((4 << 24) | 1)
+#define FUTEX_LOCK_PI 6
+#define FUTEX_UNLOCK_PI 7
+#define FUTEX_TRYLOCK_PI 8
+#define FUTEX_WAIT_BITSET 9
+#define FUTEX_WAKE_BITSET 10
+#define FUTEX_PRIVATE_FLAG 128
+#define FUTEX_CLOCK_REALTIME 256
+
+#define FUTEX_BITSET_MATCH_ANY 0xffffffff
+
+/* Values for 'private' parameter of locking macros. Yes, the
+ definition seems to be backwards. But it is not. The bit will be
+ reversed before passing to the system call. */
+#define LLL_PRIVATE 0
+#define LLL_SHARED FUTEX_PRIVATE_FLAG
+
+
+#if !defined NOT_IN_libc || defined IS_IN_rtld
+/* In libc.so or ld.so all futexes are private. */
+# ifdef __ASSUME_PRIVATE_FUTEX
+# define __lll_private_flag(fl, private) \
+ ((fl) | FUTEX_PRIVATE_FLAG)
+# else
+# define __lll_private_flag(fl, private) \
+ ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex))
+# endif
+#else
+# ifdef __ASSUME_PRIVATE_FUTEX
+# define __lll_private_flag(fl, private) \
+ (((fl) | FUTEX_PRIVATE_FLAG) ^ (private))
+# else
+# define __lll_private_flag(fl, private) \
+ (__builtin_constant_p (private) \
+ ? ((private) == 0 \
+ ? ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex)) \
+ : (fl)) \
+ : ((fl) | (((private) ^ FUTEX_PRIVATE_FLAG) \
+ & THREAD_GETMEM (THREAD_SELF, header.private_futex))))
+# endif
+#endif
+
+
+#define lll_futex_wait(futexp, val, private) \
+ lll_futex_timed_wait (futexp, val, NULL, private)
+
+#define lll_futex_timed_wait(futexp, val, timespec, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 4, (futexp), \
+ __lll_private_flag (FUTEX_WAIT, private), \
+ (val), (timespec)); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err)? -__ret : __ret; \
+ })
+
+#define lll_futex_wake(futexp, nr, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 4, (futexp), \
+ __lll_private_flag (FUTEX_WAKE, private), \
+ (nr), 0); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err)? -__ret : __ret; \
+ })
+
+#define lll_robust_dead(futexv, private) \
+ do \
+ { \
+ int *__futexp = &(futexv); \
+ atomic_or (__futexp, FUTEX_OWNER_DIED); \
+ lll_futex_wake (__futexp, 1, private); \
+ } \
+ while (0)
+
+/* Returns non-zero if error happened, zero if success. */
+#define lll_futex_requeue(futexp, nr_wake, nr_move, mutex, val, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 6, (futexp), \
+ __lll_private_flag (FUTEX_CMP_REQUEUE, private),\
+ (nr_wake), (nr_move), (mutex), (val)); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
+ })
+
+/* Returns non-zero if error happened, zero if success. */
+#define lll_futex_wake_unlock(futexp, nr_wake, nr_wake2, futexp2, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 6, (futexp), \
+ __lll_private_flag (FUTEX_WAKE_OP, private), \
+ (nr_wake), (nr_wake2), (futexp2), \
+ FUTEX_OP_CLEAR_WAKE_IF_GT_ONE); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
+ })
+
+
+
+
+static inline int __attribute__((always_inline))
+__lll_trylock(int *futex)
+{
+ return atomic_compare_and_exchange_val_acq (futex, 1, 0) != 0;
+}
+#define lll_trylock(lock) __lll_trylock (&(lock))
+
+
+static inline int __attribute__((always_inline))
+__lll_cond_trylock(int *futex)
+{
+ return atomic_compare_and_exchange_val_acq (futex, 2, 0) != 0;
+}
+#define lll_cond_trylock(lock) __lll_cond_trylock (&(lock))
+
+
+static inline int __attribute__((always_inline))
+__lll_robust_trylock(int *futex, int id)
+{
+ return atomic_compare_and_exchange_val_acq (futex, id, 0) != 0;
+}
+#define lll_robust_trylock(lock, id) \
+ __lll_robust_trylock (&(lock), id)
+
+extern void __lll_lock_wait_private (int *futex) attribute_hidden;
+extern void __lll_lock_wait (int *futex, int private) attribute_hidden;
+extern int __lll_robust_lock_wait (int *futex, int private) attribute_hidden;
+
+static inline void __attribute__((always_inline))
+__lll_lock(int *futex, int private)
+{
+ if (atomic_compare_and_exchange_bool_acq (futex, 1, 0) != 0)
+ {
+ if (__builtin_constant_p (private) && private == LLL_PRIVATE)
+ __lll_lock_wait_private (futex);
+ else
+ __lll_lock_wait (futex, private);
+ }
+}
+#define lll_lock(futex, private) __lll_lock (&(futex), private)
+
+
+static inline int __attribute__ ((always_inline))
+__lll_robust_lock (int *futex, int id, int private)
+{
+ int result = 0;
+ if (atomic_compare_and_exchange_bool_acq (futex, id, 0) != 0)
+ result = __lll_robust_lock_wait (futex, private);
+ return result;
+}
+#define lll_robust_lock(futex, id, private) \
+ __lll_robust_lock (&(futex), id, private)
+
+
+static inline void __attribute__ ((always_inline))
+__lll_cond_lock (int *futex, int private)
+{
+ if (atomic_compare_and_exchange_bool_acq (futex, 2, 0) != 0)
+ __lll_lock_wait (futex, private);
+}
+#define lll_cond_lock(futex, private) __lll_cond_lock (&(futex), private)
+
+
+#define lll_robust_cond_lock(futex, id, private) \
+ __lll_robust_lock (&(futex), (id) | FUTEX_WAITERS, private)
+
+
+extern int __lll_timedlock_wait (int *futex, const struct timespec *,
+ int private) attribute_hidden;
+extern int __lll_robust_timedlock_wait (int *futex, const struct timespec *,
+ int private) attribute_hidden;
+
+static inline int __attribute__ ((always_inline))
+__lll_timedlock (int *futex, const struct timespec *abstime, int private)
+{
+ int result = 0;
+ if (atomic_compare_and_exchange_bool_acq (futex, 1, 0) != 0)
+ result = __lll_timedlock_wait (futex, abstime, private);
+ return result;
+}
+#define lll_timedlock(futex, abstime, private) \
+ __lll_timedlock (&(futex), abstime, private)
+
+
+static inline int __attribute__ ((always_inline))
+__lll_robust_timedlock (int *futex, const struct timespec *abstime,
+ int id, int private)
+{
+ int result = 0;
+ if (atomic_compare_and_exchange_bool_acq (futex, id, 0) != 0)
+ result = __lll_robust_timedlock_wait (futex, abstime, private);
+ return result;
+}
+#define lll_robust_timedlock(futex, abstime, id, private) \
+ __lll_robust_timedlock (&(futex), abstime, id, private)
+
+
+#define __lll_unlock(futex, private) \
+ (void) \
+ ({ int *__futex = (futex); \
+ int __oldval = atomic_exchange_rel (__futex, 0); \
+ if (__builtin_expect (__oldval > 1, 0)) \
+ lll_futex_wake (__futex, 1, private); \
+ })
+#define lll_unlock(futex, private) __lll_unlock(&(futex), private)
+
+
+#define __lll_robust_unlock(futex, private) \
+ (void) \
+ ({ int *__futex = (futex); \
+ int __oldval = atomic_exchange_rel (__futex, 0); \
+ if (__builtin_expect (__oldval & FUTEX_WAITERS, 0)) \
+ lll_futex_wake (__futex, 1, private); \
+ })
+#define lll_robust_unlock(futex, private) \
+ __lll_robust_unlock(&(futex), private)
+
+
+#define lll_islocked(futex) \
+ (futex != 0)
+
+/* Initializers for lock. */
+#define LLL_LOCK_INITIALIZER (0)
+#define LLL_LOCK_INITIALIZER_LOCKED (1)
+
+
+/* The kernel notifies a process which uses CLONE_CLEARTID via futex
+ wakeup when the clone terminates. The memory location contains the
+ thread ID while the clone is running and is reset to zero
+ afterwards. */
+#define lll_wait_tid(tid) \
+ do { \
+ __typeof (tid) __tid; \
+ while ((__tid = (tid)) != 0) \
+ lll_futex_wait (&(tid), __tid, LLL_SHARED); \
+ } while (0)
+
+extern int __lll_timedwait_tid (int *, const struct timespec *)
+ attribute_hidden;
+
+#define lll_timedwait_tid(tid, abstime) \
+ ({ \
+ int __res = 0; \
+ if ((tid) != 0) \
+ __res = __lll_timedwait_tid (&(tid), (abstime)); \
+ __res; \
+ })
+
+#endif /* lowlevellock.h */
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/pthread_once.c b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/pthread_once.c
new file mode 100644
index 000000000..8a0faaf89
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/pthread_once.c
@@ -0,0 +1,96 @@
+/* Copyright (C) 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
+ 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 "pthreadP.h"
+#include <lowlevellock.h>
+
+
+unsigned long int __fork_generation attribute_hidden;
+
+static void
+clear_once_control (void *arg)
+{
+ pthread_once_t *once_control = (pthread_once_t *) arg;
+
+ *once_control = 0;
+ lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE);
+}
+
+int
+attribute_protected
+__pthread_once (pthread_once_t *once_control, void (*init_routine) (void))
+{
+ for (;;)
+ {
+ int oldval;
+ int newval;
+ int tmp;
+
+ /* Pseudo code:
+ newval = __fork_generation | 1;
+ oldval = *once_control;
+ if ((oldval & 2) == 0)
+ *once_control = newval;
+ Do this atomically.
+ */
+ newval = __fork_generation | 1;
+ __asm__ __volatile__ (
+ "1: ldl_l %0, %2\n"
+ " and %0, 2, %1\n"
+ " bne %1, 2f\n"
+ " mov %3, %1\n"
+ " stl_c %1, %2\n"
+ " beq %1, 1b\n"
+ "2: mb"
+ : "=&r" (oldval), "=&r" (tmp), "=m" (*once_control)
+ : "r" (newval), "m" (*once_control));
+
+ /* Check if the initializer has already been done. */
+ if ((oldval & 2) != 0)
+ return 0;
+
+ /* Check if another thread already runs the initializer. */
+ if ((oldval & 1) == 0)
+ break;
+
+ /* Check whether the initializer execution was interrupted by a fork. */
+ if (oldval != newval)
+ break;
+
+ /* Same generation, some other thread was faster. Wait. */
+ lll_futex_wait (once_control, oldval, LLL_PRIVATE);
+ }
+
+ /* This thread is the first here. Do the initialization.
+ Register a cleanup handler so that in case the thread gets
+ interrupted the initialization can be restarted. */
+ pthread_cleanup_push (clear_once_control, once_control);
+
+ init_routine ();
+
+ pthread_cleanup_pop (0);
+
+ /* Add one to *once_control to take the bottom 2 bits from 01 to 10. */
+ atomic_increment (once_control);
+
+ /* Wake up all other threads. */
+ lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE);
+
+ return 0;
+}
+weak_alias (__pthread_once, pthread_once)
+strong_alias (__pthread_once, __pthread_once_internal)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/sem_post.c b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/sem_post.c
new file mode 100644
index 000000000..27fd817e6
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/sem_post.c
@@ -0,0 +1,5 @@
+/* ??? This is an ass-backwards way to do this. We should simply define
+ the acquire/release semantics of atomic_exchange_and_add. And even if
+ we don't do this, we should be using atomic_full_barrier or otherwise. */
+#define __lll_rel_instr "mb"
+#include "../sem_post.c"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h
new file mode 100644
index 000000000..51f1bd42a
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h
@@ -0,0 +1,176 @@
+/* Copyright (C) 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/>. */
+
+#include <sysdep.h>
+#include <tls.h>
+#ifndef __ASSEMBLER__
+# include <nptl/pthreadP.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+# ifdef PROF
+# define PSEUDO_PROF \
+ .set noat; \
+ lda AT, _mcount; \
+ jsr AT, (AT), _mcount; \
+ .set at
+# else
+# define PSEUDO_PROF
+# endif
+
+/* ??? Assumes that nothing comes between PSEUDO and PSEUDO_END
+ besides "ret". */
+
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .globl name; \
+ .align 4; \
+ .type name, @function; \
+ .usepv name, std; \
+ cfi_startproc; \
+__LABEL(name) \
+ ldgp gp, 0(pv); \
+ PSEUDO_PROF; \
+ PSEUDO_PREPARE_ARGS \
+ SINGLE_THREAD_P(t0); \
+ bne t0, $pseudo_cancel; \
+ lda v0, SYS_ify(syscall_name); \
+ call_pal PAL_callsys; \
+ bne a3, SYSCALL_ERROR_LABEL; \
+__LABEL($pseudo_ret) \
+ .subsection 2; \
+ cfi_startproc; \
+__LABEL($pseudo_cancel) \
+ subq sp, 64, sp; \
+ cfi_def_cfa_offset(64); \
+ stq ra, 0(sp); \
+ cfi_offset(ra, -64); \
+ SAVE_ARGS_##args; \
+ CENABLE; \
+ LOAD_ARGS_##args; \
+ /* Save the CENABLE return value in RA. That register \
+ is preserved across syscall and the real return \
+ address is saved on the stack. */ \
+ mov v0, ra; \
+ lda v0, SYS_ify(syscall_name); \
+ call_pal PAL_callsys; \
+ stq v0, 8(sp); \
+ mov ra, a0; \
+ bne a3, $multi_error; \
+ CDISABLE; \
+ ldq ra, 0(sp); \
+ ldq v0, 8(sp); \
+ addq sp, 64, sp; \
+ cfi_remember_state; \
+ cfi_restore(ra); \
+ cfi_def_cfa_offset(0); \
+ ret; \
+ cfi_restore_state; \
+__LABEL($multi_error) \
+ CDISABLE; \
+ ldq ra, 0(sp); \
+ ldq v0, 8(sp); \
+ addq sp, 64, sp; \
+ cfi_restore(ra); \
+ cfi_def_cfa_offset(0); \
+__LABEL($syscall_error) \
+ SYSCALL_ERROR_HANDLER; \
+ cfi_endproc; \
+ .previous
+
+# undef PSEUDO_END
+# define PSEUDO_END(sym) \
+ cfi_endproc; \
+ .subsection 2; \
+ .size sym, .-sym
+
+# define SAVE_ARGS_0 /* Nothing. */
+# define SAVE_ARGS_1 SAVE_ARGS_0; stq a0, 8(sp)
+# define SAVE_ARGS_2 SAVE_ARGS_1; stq a1, 16(sp)
+# define SAVE_ARGS_3 SAVE_ARGS_2; stq a2, 24(sp)
+# define SAVE_ARGS_4 SAVE_ARGS_3; stq a3, 32(sp)
+# define SAVE_ARGS_5 SAVE_ARGS_4; stq a4, 40(sp)
+# define SAVE_ARGS_6 SAVE_ARGS_5; stq a5, 48(sp)
+
+# define LOAD_ARGS_0 /* Nothing. */
+# define LOAD_ARGS_1 LOAD_ARGS_0; ldq a0, 8(sp)
+# define LOAD_ARGS_2 LOAD_ARGS_1; ldq a1, 16(sp)
+# define LOAD_ARGS_3 LOAD_ARGS_2; ldq a2, 24(sp)
+# define LOAD_ARGS_4 LOAD_ARGS_3; ldq a3, 32(sp)
+# define LOAD_ARGS_5 LOAD_ARGS_4; ldq a4, 40(sp)
+# define LOAD_ARGS_6 LOAD_ARGS_5; ldq a5, 48(sp)
+
+# ifdef IS_IN_libpthread
+# define __local_enable_asynccancel __pthread_enable_asynccancel
+# define __local_disable_asynccancel __pthread_disable_asynccancel
+# define __local_multiple_threads __pthread_multiple_threads
+# elif !defined NOT_IN_libc
+# define __local_enable_asynccancel __libc_enable_asynccancel
+# define __local_disable_asynccancel __libc_disable_asynccancel
+# define __local_multiple_threads __libc_multiple_threads
+# elif defined IS_IN_librt
+# define __local_enable_asynccancel __librt_enable_asynccancel
+# define __local_disable_asynccancel __librt_disable_asynccancel
+# else
+# error Unsupported library
+# endif
+
+# ifdef __PIC__
+# define CENABLE bsr ra, __local_enable_asynccancel !samegp
+# define CDISABLE bsr ra, __local_disable_asynccancel !samegp
+# else
+# define CENABLE jsr ra, __local_enable_asynccancel; ldgp ra, 0(gp)
+# define CDISABLE jsr ra, __local_disable_asynccancel; ldgp ra, 0(gp)
+# endif
+
+# if defined IS_IN_libpthread || !defined NOT_IN_libc
+# ifndef __ASSEMBLER__
+extern int __local_multiple_threads attribute_hidden;
+# define SINGLE_THREAD_P \
+ __builtin_expect (__local_multiple_threads == 0, 1)
+# elif defined(__PIC__)
+# define SINGLE_THREAD_P(reg) ldl reg, __local_multiple_threads(gp) !gprel
+# else
+# define SINGLE_THREAD_P(reg) \
+ ldah reg, __local_multiple_threads(gp) !gprelhigh; \
+ ldl reg, __local_multiple_threads(reg) !gprellow
+# endif
+# else
+# ifndef __ASSEMBLER__
+# define SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+# else
+# define SINGLE_THREAD_P(reg) \
+ call_pal PAL_rduniq; \
+ ldl reg, MULTIPLE_THREADS_OFFSET($0)
+# endif
+# endif
+
+#else
+
+# define SINGLE_THREAD_P (1)
+# define NO_CANCELLATION 1
+
+#endif
+
+#ifndef __ASSEMBLER__
+# define RTLD_SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/timer_create.c b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/timer_create.c
new file mode 100644
index 000000000..172223af3
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/timer_create.c
@@ -0,0 +1 @@
+#include "../x86_64/timer_create.c"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/timer_delete.c b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/timer_delete.c
new file mode 100644
index 000000000..537516e0a
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/timer_delete.c
@@ -0,0 +1 @@
+#include "../x86_64/timer_delete.c"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/timer_getoverr.c b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/timer_getoverr.c
new file mode 100644
index 000000000..3f21a73c9
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/timer_getoverr.c
@@ -0,0 +1 @@
+#include "../x86_64/timer_getoverr.c"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/timer_gettime.c b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/timer_gettime.c
new file mode 100644
index 000000000..a50143adc
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/timer_gettime.c
@@ -0,0 +1 @@
+#include "../x86_64/timer_gettime.c"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/timer_settime.c b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/timer_settime.c
new file mode 100644
index 000000000..37baeffac
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/timer_settime.c
@@ -0,0 +1 @@
+#include "../x86_64/timer_settime.c"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/vfork.S
new file mode 100644
index 000000000..664cac494
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/vfork.S
@@ -0,0 +1,45 @@
+/* Copyright (C) 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/>. */
+
+#include <sysdep.h>
+#include <tcb-offsets.h>
+
+#undef PSEUDO_PREPARE_ARGS
+#define PSEUDO_PREPARE_ARGS \
+ /* Load the current cached pid value across the vfork. */ \
+ rduniq; \
+ ldl a2, PID_OFFSET(v0); \
+ mov v0, a1; \
+ /* If the cached value is initialized (nonzero), then write \
+ back its negation, or INT_MIN, to indicate that the pid \
+ value is uninitialized in the the child, and in the window \
+ between here and the point at which we restore the value. */ \
+ ldah t0, -0x8000; \
+ negl a2, t1; \
+ cmovne a2, t1, t0; \
+ stl t0, PID_OFFSET(v0);
+
+PSEUDO (__vfork, vfork, 0)
+
+ /* If we're back in the parent, restore the saved pid. */
+ beq v0, 1f
+ stl a2, PID_OFFSET(a1)
+1: ret
+
+PSEUDO_END (__vfork)
+libc_hidden_def (__vfork)
+weak_alias (__vfork, vfork)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arc/Makefile b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/Makefile
new file mode 100644
index 000000000..729adf6f9
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/Makefile
@@ -0,0 +1,13 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2005 Steven J. Hill <sjhill@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/libpthread/nptl/sysdeps/unix/sysv/linux/arc/Makefile.arch b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/Makefile.arch
new file mode 100644
index 000000000..3b9db6a61
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/Makefile.arch
@@ -0,0 +1,15 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2006 Steven J. Hill <sjhill@uclibc.org>
+#
+# Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+#
+
+libpthread_linux_arch_SSRC =
+libpthread_linux_arch_CSRC = pthread_once.c lowlevellock.c \
+ pt-__syscall_rt_sigaction.c pt-__syscall_error.c
+
+libc_linux_arch_CSRC = fork.c libc-lowlevellock.c
+libc_linux_arch_SSRC = clone.S vfork.S
+libc_linux_arch_SSRC-OMIT = waitpid.S
+
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arc/bits/pthreadtypes.h b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/bits/pthreadtypes.h
new file mode 100644
index 000000000..e1b115c8c
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/bits/pthreadtypes.h
@@ -0,0 +1,181 @@
+/* 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 _BITS_PTHREADTYPES_H
+#define _BITS_PTHREADTYPES_H 1
+
+#include <endian.h>
+
+#define __SIZEOF_PTHREAD_ATTR_T 36
+#define __SIZEOF_PTHREAD_MUTEX_T 24
+#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
+#define __SIZEOF_PTHREAD_COND_T 48
+#define __SIZEOF_PTHREAD_COND_COMPAT_T 12
+#define __SIZEOF_PTHREAD_CONDATTR_T 4
+#define __SIZEOF_PTHREAD_RWLOCK_T 32
+#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
+#define __SIZEOF_PTHREAD_BARRIER_T 20
+#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
+
+
+/* Thread identifiers. The structure of the attribute type is not
+ exposed on purpose. */
+typedef unsigned long int pthread_t;
+
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_ATTR_T];
+ long int __align;
+} pthread_attr_t;
+
+
+typedef struct __pthread_internal_slist
+{
+ struct __pthread_internal_slist *__next;
+} __pthread_slist_t;
+
+
+/* Data structures for mutex handling. The structure of the attribute
+ type is not exposed on purpose. */
+typedef union
+{
+ struct __pthread_mutex_s
+ {
+ int __lock;
+ unsigned int __count;
+ int __owner;
+ /* KIND must stay at this position in the structure to maintain
+ binary compatibility. */
+ int __kind;
+ unsigned int __nusers;
+ __extension__ union
+ {
+ int __spins;
+ __pthread_slist_t __list;
+ };
+ } __data;
+ char __size[__SIZEOF_PTHREAD_MUTEX_T];
+ long int __align;
+} pthread_mutex_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
+ long int __align;
+} pthread_mutexattr_t;
+
+
+/* Data structure for conditional variable handling. The structure of
+ the attribute type is not exposed on purpose. */
+typedef union
+{
+ struct
+ {
+ int __lock;
+ unsigned int __futex;
+ __extension__ unsigned long long int __total_seq;
+ __extension__ unsigned long long int __wakeup_seq;
+ __extension__ unsigned long long int __woken_seq;
+ void *__mutex;
+ unsigned int __nwaiters;
+ unsigned int __broadcast_seq;
+ } __data;
+ char __size[__SIZEOF_PTHREAD_COND_T];
+ __extension__ long long int __align;
+} pthread_cond_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_CONDATTR_T];
+ long int __align;
+} pthread_condattr_t;
+
+
+/* Keys for thread-specific data */
+typedef unsigned int pthread_key_t;
+
+
+/* Once-only execution */
+typedef int pthread_once_t;
+
+
+#if defined __USE_UNIX98 || defined __USE_XOPEN2K
+/* Data structure for read-write lock variable handling. The
+ structure of the attribute type is not exposed on purpose. */
+typedef union
+{
+ struct
+ {
+ int __lock;
+ unsigned int __nr_readers;
+ unsigned int __readers_wakeup;
+ unsigned int __writer_wakeup;
+ unsigned int __nr_readers_queued;
+ unsigned int __nr_writers_queued;
+#if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned char __pad1;
+ unsigned char __pad2;
+ unsigned char __shared;
+ /* FLAGS must stay at this position in the structure to maintain
+ binary compatibility. */
+ unsigned char __flags;
+#else
+ /* FLAGS must stay at this position in the structure to maintain
+ binary compatibility. */
+ unsigned char __flags;
+ unsigned char __shared;
+ unsigned char __pad1;
+ unsigned char __pad2;
+#endif
+ int __writer;
+ } __data;
+ char __size[__SIZEOF_PTHREAD_RWLOCK_T];
+ long int __align;
+} pthread_rwlock_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
+ long int __align;
+} pthread_rwlockattr_t;
+#endif
+
+
+#ifdef __USE_XOPEN2K
+/* POSIX spinlock data type. */
+typedef volatile int pthread_spinlock_t;
+
+
+/* POSIX barriers data type. The structure of the type is
+ deliberately not exposed. */
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_BARRIER_T];
+ long int __align;
+} pthread_barrier_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];
+ int __align;
+} pthread_barrierattr_t;
+#endif
+
+
+#endif /* bits/pthreadtypes.h */
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arc/bits/semaphore.h b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/bits/semaphore.h
new file mode 100644
index 000000000..dadfac2af
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/bits/semaphore.h
@@ -0,0 +1,35 @@
+/* Copyright (C) 2002, 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., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SEMAPHORE_H
+# error "Never use <bits/semaphore.h> directly; include <semaphore.h> instead."
+#endif
+
+
+#define __SIZEOF_SEM_T 16
+
+
+/* Value returned if `sem_open' failed. */
+#define SEM_FAILED ((sem_t *) 0)
+
+
+typedef union
+{
+ char __size[__SIZEOF_SEM_T];
+ long int __align;
+} sem_t;
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arc/clone.S b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/clone.S
new file mode 100644
index 000000000..5fd1de3c2
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/clone.S
@@ -0,0 +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.
+ */
+
+#define RESET_PID
+#include <tls.h>
+#include <tcb-offsets.h>
+#include "../../../../../../../libc/sysdeps/linux/arc/clone.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arc/createthread.c b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/createthread.c
new file mode 100644
index 000000000..78719015f
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/createthread.c
@@ -0,0 +1,25 @@
+/* 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* Internal clone callers pass struct pthread, but thread TP register
+ * needs to point to TLS block (struct tcbhead) which is right after */
+
+#define TLS_VALUE (pd + 1)
+
+/* Get the real implementation. */
+#include <sysdeps/pthread/createthread.c>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arc/fork.c b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/fork.c
new file mode 100644
index 000000000..2578af6f4
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/fork.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Phil Blundell <pb@nexus.co.uk>, 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 <sched.h>
+#include <signal.h>
+#include <sysdep.h>
+#include <tls.h>
+
+
+#define ARCH_FORK() \
+ INLINE_SYSCALL (clone, 5, \
+ CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID | SIGCHLD, \
+ NULL, NULL, NULL, &THREAD_SELF->tid)
+
+#include "../fork.c"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arc/libc-lowlevellock.c b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/libc-lowlevellock.c
new file mode 100644
index 000000000..b19282281
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/libc-lowlevellock.c
@@ -0,0 +1,21 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Paul Mackerras <paulus@au.ibm.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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* No difference to lowlevellock.c, except we lose a couple of functions. */
+#include "lowlevellock.c"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arc/lowlevellock.c b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/lowlevellock.c
new file mode 100644
index 000000000..fd39fe907
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/lowlevellock.c
@@ -0,0 +1,128 @@
+/* low level locking for pthread library. Generic futex-using version.
+ Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Paul Mackerras <paulus@au.ibm.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 <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <sys/time.h>
+#include <tls.h>
+#include <tcb-offsets.h>
+
+void
+#ifndef IS_IN_libpthread
+weak_function
+#endif
+__lll_lock_wait_private (int *futex)
+{
+ if (*futex == 2)
+ lll_futex_wait (futex, 2, LLL_PRIVATE);
+
+ while (atomic_exchange_acq (futex, 2) != 0)
+ lll_futex_wait (futex, 2, LLL_PRIVATE);
+}
+
+
+/* These functions don't get included in libc.so */
+#ifdef IS_IN_libpthread
+void
+__lll_lock_wait (int *futex, int private)
+{
+ if (*futex == 2)
+ lll_futex_wait (futex, 2, private);
+
+ while (atomic_exchange_acq (futex, 2) != 0)
+ lll_futex_wait (futex, 2, private);
+}
+
+
+int
+__lll_timedlock_wait (int *futex, const struct timespec *abstime, int private)
+{
+ /* Reject invalid timeouts. */
+ if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
+ return EINVAL;
+
+ /* Try locking. */
+ while (atomic_exchange_acq (futex, 2) != 0)
+ {
+ struct timeval tv;
+
+ /* Get the current time. */
+ (void) gettimeofday (&tv, NULL);
+
+ /* Compute relative timeout. */
+ struct timespec rt;
+ rt.tv_sec = abstime->tv_sec - tv.tv_sec;
+ rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+ if (rt.tv_nsec < 0)
+ {
+ rt.tv_nsec += 1000000000;
+ --rt.tv_sec;
+ }
+
+ if (rt.tv_sec < 0)
+ return ETIMEDOUT;
+
+ /* Wait. */
+ lll_futex_timed_wait (futex, 2, &rt, private);
+ }
+
+ return 0;
+}
+
+
+int
+__lll_timedwait_tid (int *tidp, const struct timespec *abstime)
+{
+ int tid;
+
+ if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
+ return EINVAL;
+
+ /* Repeat until thread terminated. */
+ while ((tid = *tidp) != 0)
+ {
+ struct timeval tv;
+ struct timespec rt;
+
+ /* Get the current time. */
+ (void) __gettimeofday (&tv, NULL);
+
+ /* Compute relative timeout. */
+ rt.tv_sec = abstime->tv_sec - tv.tv_sec;
+ rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+ if (rt.tv_nsec < 0)
+ {
+ rt.tv_nsec += 1000000000;
+ --rt.tv_sec;
+ }
+
+ /* Already timed out? */
+ if (rt.tv_sec < 0)
+ return ETIMEDOUT;
+
+ /* Wait until thread terminates. The kernel so far does not use
+ the private futex operations for this. */
+ if (lll_futex_timed_wait (tidp, tid, &rt, LLL_SHARED) == -ETIMEDOUT)
+ return ETIMEDOUT;
+ }
+
+ return 0;
+}
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arc/lowlevellock.h b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/lowlevellock.h
new file mode 100644
index 000000000..99ada5d50
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/lowlevellock.h
@@ -0,0 +1,279 @@
+/* Copyright (C) 2005, 2006, 2007, 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
+ 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 _LOWLEVELLOCK_H
+#define _LOWLEVELLOCK_H 1
+
+#include <time.h>
+#include <sys/param.h>
+#include <bits/pthreadtypes.h>
+#include <atomic.h>
+#include <sysdep.h>
+#include <bits/kernel-features.h>
+
+#define FUTEX_WAIT 0
+#define FUTEX_WAKE 1
+#define FUTEX_REQUEUE 3
+#define FUTEX_CMP_REQUEUE 4
+#define FUTEX_WAKE_OP 5
+#define FUTEX_OP_CLEAR_WAKE_IF_GT_ONE ((4 << 24) | 1)
+#define FUTEX_LOCK_PI 6
+#define FUTEX_UNLOCK_PI 7
+#define FUTEX_TRYLOCK_PI 8
+#define FUTEX_WAIT_BITSET 9
+#define FUTEX_WAKE_BITSET 10
+#define FUTEX_PRIVATE_FLAG 128
+#define FUTEX_CLOCK_REALTIME 256
+
+#define FUTEX_BITSET_MATCH_ANY 0xffffffff
+
+/* Values for 'private' parameter of locking macros. Yes, the
+ definition seems to be backwards. But it is not. The bit will be
+ reversed before passing to the system call. */
+#define LLL_PRIVATE 0
+#define LLL_SHARED FUTEX_PRIVATE_FLAG
+
+
+#if !defined NOT_IN_libc || defined IS_IN_rtld
+/* In libc.so or ld.so all futexes are private. */
+# ifdef __ASSUME_PRIVATE_FUTEX
+# define __lll_private_flag(fl, private) \
+ ((fl) | FUTEX_PRIVATE_FLAG)
+# else
+# define __lll_private_flag(fl, private) \
+ ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex))
+# endif
+#else
+# ifdef __ASSUME_PRIVATE_FUTEX
+# define __lll_private_flag(fl, private) \
+ (((fl) | FUTEX_PRIVATE_FLAG) ^ (private))
+# else
+# define __lll_private_flag(fl, private) \
+ (__builtin_constant_p (private) \
+ ? ((private) == 0 \
+ ? ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex)) \
+ : (fl)) \
+ : ((fl) | (((private) ^ FUTEX_PRIVATE_FLAG) \
+ & THREAD_GETMEM (THREAD_SELF, header.private_futex))))
+# endif
+#endif
+
+
+#define lll_futex_wait(futexp, val, private) \
+ lll_futex_timed_wait(futexp, val, NULL, private)
+
+#define lll_futex_timed_wait(futexp, val, timespec, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 4, (futexp), \
+ __lll_private_flag (FUTEX_WAIT, private), \
+ (val), (timespec)); \
+ __ret; \
+ })
+
+#define lll_futex_wake(futexp, nr, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 4, (futexp), \
+ __lll_private_flag (FUTEX_WAKE, private), \
+ (nr), 0); \
+ __ret; \
+ })
+
+#define lll_robust_dead(futexv, private) \
+ do \
+ { \
+ int *__futexp = &(futexv); \
+ atomic_or (__futexp, FUTEX_OWNER_DIED); \
+ lll_futex_wake (__futexp, 1, private); \
+ } \
+ while (0)
+
+/* Returns non-zero if error happened, zero if success. */
+#define lll_futex_requeue(futexp, nr_wake, nr_move, mutex, val, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 6, (futexp), \
+ __lll_private_flag (FUTEX_CMP_REQUEUE, private),\
+ (nr_wake), (nr_move), (mutex), (val)); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
+ })
+
+
+/* Returns non-zero if error happened, zero if success. */
+#define lll_futex_wake_unlock(futexp, nr_wake, nr_wake2, futexp2, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 6, (futexp), \
+ __lll_private_flag (FUTEX_WAKE_OP, private), \
+ (nr_wake), (nr_wake2), (futexp2), \
+ FUTEX_OP_CLEAR_WAKE_IF_GT_ONE); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
+ })
+
+
+#define lll_trylock(lock) \
+ atomic_compare_and_exchange_val_acq(&(lock), 1, 0)
+
+#define lll_cond_trylock(lock) \
+ atomic_compare_and_exchange_val_acq(&(lock), 2, 0)
+
+#define __lll_robust_trylock(futex, id) \
+ (atomic_compare_and_exchange_val_acq (futex, id, 0) != 0)
+#define lll_robust_trylock(lock, id) \
+ __lll_robust_trylock (&(lock), id)
+
+extern void __lll_lock_wait_private (int *futex) attribute_hidden;
+extern void __lll_lock_wait (int *futex, int private) attribute_hidden;
+extern int __lll_robust_lock_wait (int *futex, int private) attribute_hidden;
+
+#define __lll_lock(futex, private) \
+ ((void) ({ \
+ int *__futex = (futex); \
+ if (unlikely(atomic_compare_and_exchange_val_acq (__futex, 1, 0))) \
+ { \
+ if (__builtin_constant_p (private) && (private) == LLL_PRIVATE) \
+ __lll_lock_wait_private (__futex); \
+ else \
+ __lll_lock_wait (__futex, private); \
+ } \
+ }))
+#define lll_lock(futex, private) __lll_lock (&(futex), private)
+
+
+#define __lll_robust_lock(futex, id, private) \
+ ({ \
+ int *__futex = (futex); \
+ int __val = 0; \
+ \
+ if (unlikely(atomic_compare_and_exchange_bool_acq (__futex, id, 0))) \
+ __val = __lll_robust_lock_wait (__futex, private); \
+ __val; \
+ })
+#define lll_robust_lock(futex, id, private) \
+ __lll_robust_lock (&(futex), id, private)
+
+
+#define __lll_cond_lock(futex, private) \
+ ((void) ({ \
+ int *__futex = (futex); \
+ if (unlikely(atomic_exchange_acq (__futex, 2))) \
+ __lll_lock_wait (__futex, private); \
+ }))
+#define lll_cond_lock(futex, private) __lll_cond_lock (&(futex), private)
+
+
+#define lll_robust_cond_lock(futex, id, private) \
+ __lll_robust_lock (&(futex), (id) | FUTEX_WAITERS, private)
+
+
+extern int __lll_timedlock_wait (int *futex, const struct timespec *,
+ int private) attribute_hidden;
+extern int __lll_robust_timedlock_wait (int *futex, const struct timespec *,
+ int private) attribute_hidden;
+
+#define __lll_timedlock(futex, abstime, private) \
+ ({ \
+ int *__futex = (futex); \
+ int __val = 0; \
+ \
+ if (unlikely(atomic_exchange_acq (__futex, 1))) \
+ __val = __lll_timedlock_wait (__futex, abstime, private); \
+ __val; \
+ })
+#define lll_timedlock(futex, abstime, private) \
+ __lll_timedlock (&(futex), abstime, private)
+
+
+#define __lll_robust_timedlock(futex, abstime, id, private) \
+ ({ \
+ int *__futex = (futex); \
+ int __val = 0; \
+ \
+ if (unlikely(atomic_compare_and_exchange_bool_acq (__futex, id, 0))) \
+ __val = __lll_robust_timedlock_wait (__futex, abstime, private); \
+ __val; \
+ })
+#define lll_robust_timedlock(futex, abstime, id, private) \
+ __lll_robust_timedlock (&(futex), abstime, id, private)
+
+
+#define __lll_unlock(futex, private) \
+ (void) \
+ ({ int *__futex = (futex); \
+ int __oldval = atomic_exchange_rel (__futex, 0); \
+ if (unlikely(__oldval > 1)) \
+ lll_futex_wake (__futex, 1, private); \
+ })
+#define lll_unlock(futex, private) __lll_unlock(&(futex), private)
+
+
+#define __lll_robust_unlock(futex, private) \
+ (void) \
+ ({ int *__futex = (futex); \
+ int __oldval = atomic_exchange_rel (__futex, 0); \
+ if (unlikely(__oldval & FUTEX_WAITERS)) \
+ lll_futex_wake (__futex, 1, private); \
+ })
+#define lll_robust_unlock(futex, private) \
+ __lll_robust_unlock(&(futex), private)
+
+
+#define lll_islocked(futex) \
+ (futex != 0)
+
+
+/* Our internal lock implementation is identical to the binary-compatible
+ mutex implementation. */
+
+/* Initializers for lock. */
+#define LLL_LOCK_INITIALIZER (0)
+#define LLL_LOCK_INITIALIZER_LOCKED (1)
+
+/* The states of a lock are:
+ 0 - untaken
+ 1 - taken by one user
+ >1 - taken by more users */
+
+/* The kernel notifies a process which uses CLONE_CLEARTID via futex
+ wakeup when the clone terminates. The memory location contains the
+ thread ID while the clone is running and is reset to zero
+ afterwards. */
+#define lll_wait_tid(tid) \
+ do { \
+ __typeof (tid) __tid; \
+ while ((__tid = (tid)) != 0) \
+ lll_futex_wait (&(tid), __tid, LLL_SHARED);\
+ } while (0)
+
+extern int __lll_timedwait_tid (int *, const struct timespec *)
+ attribute_hidden;
+
+#define lll_timedwait_tid(tid, abstime) \
+ ({ \
+ int __res = 0; \
+ if ((tid) != 0) \
+ __res = __lll_timedwait_tid (&(tid), (abstime)); \
+ __res; \
+ })
+
+#endif /* lowlevellock.h */
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arc/pt-__syscall_error.c b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/pt-__syscall_error.c
new file mode 100644
index 000000000..8002e65c3
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/pt-__syscall_error.c
@@ -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.
+ */
+
+#include <../../../../../../../libc/sysdeps/linux/arc/__syscall_error.c>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arc/pt-__syscall_rt_sigaction.c b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/pt-__syscall_rt_sigaction.c
new file mode 100644
index 000000000..967dad1b0
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/pt-__syscall_rt_sigaction.c
@@ -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.
+ */
+
+/*
+ * ARC syscall ABI only has __NR_rt_sigaction, thus vanilla sigaction does
+ * some SA_RESTORER tricks before calling __syscall_rt_sigaction.
+ * However including that file here causes a redefinition of __libc_sigaction
+ * in static links involving pthreads
+ */
+//#include <../../../../../../../libc/sysdeps/linux/arc/sigaction.c>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arc/pt-gettimeofday.c b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/pt-gettimeofday.c
new file mode 100644
index 000000000..d9fc3531f
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/pt-gettimeofday.c
@@ -0,0 +1,11 @@
+/*
+ * 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/time.h>
+
+int gettimeofday (struct timeval *, struct timezone *) attribute_hidden;
+_syscall2(int, gettimeofday, struct timeval *, tv, struct timezone *, tz);
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arc/pthread_once.c b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/pthread_once.c
new file mode 100644
index 000000000..e977a7d0c
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/pthread_once.c
@@ -0,0 +1,100 @@
+/* Copyright (C) 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include "pthreadP.h"
+#include <lowlevellock.h>
+
+unsigned long int __fork_generation attribute_hidden;
+
+static void
+clear_once_control (void *arg)
+{
+ pthread_once_t *once_control = (pthread_once_t *) arg;
+
+ *once_control = 0;
+ lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE);
+}
+
+int
+attribute_protected
+__pthread_once (pthread_once_t *once_control, void (*init_routine) (void))
+{
+ for (;;)
+ {
+ int oldval;
+ int newval;
+
+ /* Pseudo code:
+ newval = __fork_generation | 1;
+ oldval = *once_control;
+ if ((oldval & 2) == 0)
+ *once_control = newval;
+ Do this atomically.
+ */
+ do
+ {
+ newval = __fork_generation | 1;
+ oldval = *once_control;
+ if (oldval & 2)
+ break;
+ } while (atomic_compare_and_exchange_val_acq (once_control, newval, oldval) != oldval);
+
+ /* Check if the initializer has already been done. */
+ if ((oldval & 2) != 0)
+ return 0;
+
+ /* Check if another thread already runs the initializer. */
+ if ((oldval & 1) == 0)
+ break;
+
+ /* Check whether the initializer execution was interrupted by a fork. */
+ if (oldval != newval)
+ break;
+
+ /* Same generation, some other thread was faster. Wait. */
+ lll_futex_wait (once_control, oldval, LLL_PRIVATE);
+ }
+
+ /* This thread is the first here. Do the initialization.
+ Register a cleanup handler so that in case the thread gets
+ interrupted the initialization can be restarted. */
+ pthread_cleanup_push (clear_once_control, once_control);
+
+ init_routine ();
+
+ pthread_cleanup_pop (0);
+
+ /* Say that the initialisation is done. */
+ *once_control = __fork_generation | 2;
+
+ /* Wake up all other threads. */
+ lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE);
+
+ return 0;
+}
+weak_alias (__pthread_once, pthread_once)
+strong_alias (__pthread_once, __pthread_once_internal)
+
+#if defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__PIC__)
+/* When statically linked, if pthread_create is used, this file
+ will be brought in. The exception handling code in GCC assumes
+ that if pthread_create is available, so are these. */
+const void *include_pthread_getspecific attribute_hidden = pthread_getspecific;
+const void *include_pthread_setspecific attribute_hidden = pthread_setspecific;
+const void *include_pthread_key_create attribute_hidden = pthread_key_create;
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arc/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/sysdep-cancel.h
new file mode 100644
index 000000000..cddd754a8
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/sysdep-cancel.h
@@ -0,0 +1,115 @@
+/*
+ * 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 <tls.h>
+#include <sysdep.h>
+#ifndef __ASSEMBLER__
+# include <pthreadP.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+#ifdef __ASSEMBLER__
+
+#undef ret
+#define ret
+
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, nargs) \
+ /* vanilla version */ ` \
+ ENTRY(name##_nocancel) ` \
+ DO_CALL (__NR_##syscall_name) ` \
+ jls [blink] ` \
+ b __syscall_error@plt ` \
+ END(name##_nocancel) ` \
+ /* thread cancellation variant */ ` \
+ ENTRY(name) ` \
+ SINGLE_THREAD_P ` \
+ bz name##_nocancel ` \
+ DOCARGS_##nargs /* stash syscall args */ ` \
+ CENABLE /* call enable_asynccancel */ ` \
+ mov r9, r0 /* Safe-keep mask */ ` \
+ UNDOCARGS_##nargs /* restore syscall args */ ` \
+ DO_CALL (__NR_##syscall_name) ` \
+ push r0 /* save syscall return value */ ` \
+ mov r0, r9 /* prep mask for disable_asynccancel */ ` \
+ CDISABLE ` \
+ pop r0 /* get syscall ret value back */ ` \
+ cmp r0, -1024 ` \
+ jls [blink] ` \
+ b __syscall_error@plt ` \
+ END(name)
+
+#undef PSEUDO_END
+#define PSEUDO_END(name) \
+
+# ifdef IS_IN_libpthread
+# define CENABLE bl __pthread_enable_asynccancel
+# define CDISABLE bl __pthread_disable_asynccancel
+# define __local_multiple_threads __pthread_multiple_threads
+# elif !defined NOT_IN_libc
+# define CENABLE bl __libc_enable_asynccancel
+# define CDISABLE bl __libc_disable_asynccancel
+# define __local_multiple_threads __libc_multiple_threads
+# elif defined IS_IN_librt
+# define CENABLE bl __librt_enable_asynccancel
+# define CDISABLE bl __librt_disable_asynccancel
+# else
+# error Unsupported library
+# endif
+
+#define DO_CALL(num) \
+ mov r8, num ` \
+ ARC_TRAP_INSN ` \
+ cmp r0, -1024
+
+.macro push reg
+ st.a \reg, [sp, -4]
+.endm
+
+.macro pop reg
+ ld.ab \reg, [sp, 4]
+.endm
+
+#define DOCARGS_0 push blink
+#define UNDOCARGS_0 pop blink
+
+#define DOCARGS_1 DOCARGS_0` push r0
+#define UNDOCARGS_1 pop r0` UNDOCARGS_0
+
+#define DOCARGS_2 DOCARGS_1` push r1
+#define UNDOCARGS_2 pop r1` UNDOCARGS_1
+
+#define DOCARGS_3 DOCARGS_2` push r2
+#define UNDOCARGS_3 pop r2` UNDOCARGS_2
+
+#define DOCARGS_4 DOCARGS_3` push r3
+#define UNDOCARGS_4 pop r3` UNDOCARGS_3
+
+#define DOCARGS_5 DOCARGS_4` push r4
+#define UNDOCARGS_5 pop r4` UNDOCARGS_4
+
+#define DOCARGS_6 DOCARGS_5` push r5
+#define UNDOCARGS_6 pop r5` UNDOCARGS_5
+
+#define DOCARGS_7 DOCARGS_6` push r6
+#define UNDOCARGS_7 pop r6` UNDOCARGS_6
+
+# define SINGLE_THREAD_P \
+ THREAD_SELF r1 ` \
+ ld r2, [r1, MULTIPLE_THREADS_OFFSET]` \
+ cmp r2, 0
+
+/* ld r2, [r1, -TLS_PRE_TCB_SIZE + MULTIPLE_THREADS_OFFSET] */
+#else /* !__ASSEMBLER__ */
+
+/* TBD: Can use @__local_multiple_threads for libc/libpthread like ARM */
+# define SINGLE_THREAD_P \
+ likely(THREAD_GETMEM (THREAD_SELF, header.multiple_threads) == 0)
+
+#endif /* __ASSEMBLER__ */
+
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arc/vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/vfork.S
new file mode 100644
index 000000000..d29e05a8a
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/vfork.S
@@ -0,0 +1,11 @@
+/*
+ * 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 SAVE_PID
+#define RESTORE_PID
+#include <tls.h>
+#include <tcb-offsets.h>
+#include "../../../../../../../libc/sysdeps/linux/arc/vfork.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/Makefile b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/Makefile
new file mode 100644
index 000000000..43a6fad84
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/Makefile
@@ -0,0 +1,13 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2005 Steven J. Hill <sjhill@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+top_srcdir=../../../../../../../
+top_builddir=../../../../../../../
+all: objs
+include $(top_builddir)Rules.mak
+include Makefile.arch
+include $(top_srcdir)Makerules
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/Makefile.arch b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/Makefile.arch
new file mode 100644
index 000000000..5522ce349
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/Makefile.arch
@@ -0,0 +1,23 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2006 Steven J. Hill <sjhill@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+libpthread_linux_arch_SSRC =
+libpthread_linux_arch_CSRC = pthread_once.c \
+ pt-__syscall_rt_sigaction.c pt-__syscall_error.c \
+ lowlevellock.c
+
+libc_linux_arch_CSRC = fork.c libc-lowlevellock.c
+libc_linux_arch_SSRC = clone.S vfork.S
+libc_linux_arch_SSRC-OMIT = waitpid.S
+
+# We always compile it in arm mode because of SAVE_PID macro
+# This macro should be alternatively implemented in THUMB
+# assembly.
+ASFLAGS-pt-vfork.S = -marm
+CFLAGS-OMIT-pt-vfork.S = -mthumb
+ASFLAGS-vfork.S = -marm
+CFLAGS-OMIT-vfork.S = -mthumb
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/bits/pthreadtypes.h b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/bits/pthreadtypes.h
new file mode 100644
index 000000000..ae0d79f5d
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/bits/pthreadtypes.h
@@ -0,0 +1,180 @@
+/* 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _BITS_PTHREADTYPES_H
+#define _BITS_PTHREADTYPES_H 1
+
+#include <endian.h>
+
+#define __SIZEOF_PTHREAD_ATTR_T 36
+#define __SIZEOF_PTHREAD_MUTEX_T 24
+#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
+#define __SIZEOF_PTHREAD_COND_T 48
+#define __SIZEOF_PTHREAD_COND_COMPAT_T 12
+#define __SIZEOF_PTHREAD_CONDATTR_T 4
+#define __SIZEOF_PTHREAD_RWLOCK_T 32
+#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
+#define __SIZEOF_PTHREAD_BARRIER_T 20
+#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
+
+
+/* Thread identifiers. The structure of the attribute type is not
+ exposed on purpose. */
+typedef unsigned long int pthread_t;
+
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_ATTR_T];
+ long int __align;
+} pthread_attr_t;
+
+
+typedef struct __pthread_internal_slist
+{
+ struct __pthread_internal_slist *__next;
+} __pthread_slist_t;
+
+
+/* Data structures for mutex handling. The structure of the attribute
+ type is not exposed on purpose. */
+typedef union
+{
+ struct __pthread_mutex_s
+ {
+ int __lock;
+ unsigned int __count;
+ int __owner;
+ /* KIND must stay at this position in the structure to maintain
+ binary compatibility. */
+ int __kind;
+ unsigned int __nusers;
+ __extension__ union
+ {
+ int __spins;
+ __pthread_slist_t __list;
+ };
+ } __data;
+ char __size[__SIZEOF_PTHREAD_MUTEX_T];
+ long int __align;
+} pthread_mutex_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
+ long int __align;
+} pthread_mutexattr_t;
+
+
+/* Data structure for conditional variable handling. The structure of
+ the attribute type is not exposed on purpose. */
+typedef union
+{
+ struct
+ {
+ int __lock;
+ unsigned int __futex;
+ __extension__ unsigned long long int __total_seq;
+ __extension__ unsigned long long int __wakeup_seq;
+ __extension__ unsigned long long int __woken_seq;
+ void *__mutex;
+ unsigned int __nwaiters;
+ unsigned int __broadcast_seq;
+ } __data;
+ char __size[__SIZEOF_PTHREAD_COND_T];
+ __extension__ long long int __align;
+} pthread_cond_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_CONDATTR_T];
+ long int __align;
+} pthread_condattr_t;
+
+
+/* Keys for thread-specific data */
+typedef unsigned int pthread_key_t;
+
+
+/* Once-only execution */
+typedef int pthread_once_t;
+
+
+#if defined __USE_UNIX98 || defined __USE_XOPEN2K
+/* Data structure for read-write lock variable handling. The
+ structure of the attribute type is not exposed on purpose. */
+typedef union
+{
+ struct
+ {
+ int __lock;
+ unsigned int __nr_readers;
+ unsigned int __readers_wakeup;
+ unsigned int __writer_wakeup;
+ unsigned int __nr_readers_queued;
+ unsigned int __nr_writers_queued;
+#if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned char __pad1;
+ unsigned char __pad2;
+ unsigned char __shared;
+ /* FLAGS must stay at this position in the structure to maintain
+ binary compatibility. */
+ unsigned char __flags;
+#else
+ /* FLAGS must stay at this position in the structure to maintain
+ binary compatibility. */
+ unsigned char __flags;
+ unsigned char __shared;
+ unsigned char __pad1;
+ unsigned char __pad2;
+#endif
+ int __writer;
+ } __data;
+ char __size[__SIZEOF_PTHREAD_RWLOCK_T];
+ long int __align;
+} pthread_rwlock_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
+ long int __align;
+} pthread_rwlockattr_t;
+#endif
+
+
+#ifdef __USE_XOPEN2K
+/* POSIX spinlock data type. */
+typedef volatile int pthread_spinlock_t;
+
+
+/* POSIX barriers data type. The structure of the type is
+ deliberately not exposed. */
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_BARRIER_T];
+ long int __align;
+} pthread_barrier_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];
+ int __align;
+} pthread_barrierattr_t;
+#endif
+
+
+#endif /* bits/pthreadtypes.h */
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/bits/semaphore.h b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/bits/semaphore.h
new file mode 100644
index 000000000..e68fbcc35
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/bits/semaphore.h
@@ -0,0 +1,34 @@
+/* Copyright (C) 2002, 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 _SEMAPHORE_H
+# error "Never use <bits/semaphore.h> directly; include <semaphore.h> instead."
+#endif
+
+
+#define __SIZEOF_SEM_T 16
+
+
+/* Value returned if `sem_open' failed. */
+#define SEM_FAILED ((sem_t *) 0)
+
+
+typedef union
+{
+ char __size[__SIZEOF_SEM_T];
+ long int __align;
+} sem_t;
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/clone.S b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/clone.S
new file mode 100644
index 000000000..23227eb24
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/clone.S
@@ -0,0 +1,3 @@
+#define RESET_PID
+#include <tcb-offsets.h>
+#include "../../../../../../../libc/sysdeps/linux/arm/clone.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/createthread.c b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/createthread.c
new file mode 100644
index 000000000..10a9ac39f
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/createthread.c
@@ -0,0 +1,22 @@
+/* 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/>. */
+
+/* Value passed to 'clone' for initialization of the thread register. */
+#define TLS_VALUE (pd + 1)
+
+/* Get the real implementation. */
+#include <sysdeps/pthread/createthread.c>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/fork.c b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/fork.c
new file mode 100644
index 000000000..2578af6f4
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/fork.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Phil Blundell <pb@nexus.co.uk>, 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 <sched.h>
+#include <signal.h>
+#include <sysdep.h>
+#include <tls.h>
+
+
+#define ARCH_FORK() \
+ INLINE_SYSCALL (clone, 5, \
+ CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID | SIGCHLD, \
+ NULL, NULL, NULL, &THREAD_SELF->tid)
+
+#include "../fork.c"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/libc-lowlevellock.c b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/libc-lowlevellock.c
new file mode 100644
index 000000000..28672a65f
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/libc-lowlevellock.c
@@ -0,0 +1,20 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Paul Mackerras <paulus@au.ibm.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/>. */
+
+/* No difference to lowlevellock.c, except we lose a couple of functions. */
+#include "lowlevellock.c"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/lowlevellock.c b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/lowlevellock.c
new file mode 100644
index 000000000..cd4213573
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/lowlevellock.c
@@ -0,0 +1,136 @@
+/* low level locking for pthread library. Generic futex-using version.
+ Copyright (C) 2003, 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/>. */
+
+#include <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <sys/time.h>
+#include <tls.h>
+
+void
+#ifndef IS_IN_libpthread
+weak_function
+#endif
+__lll_lock_wait_private (int *futex)
+{
+ do
+ {
+ int oldval = atomic_compare_and_exchange_val_acq (futex, 2, 1);
+ if (oldval != 0)
+ lll_futex_wait (futex, 2, LLL_PRIVATE);
+ }
+ while (atomic_compare_and_exchange_bool_acq (futex, 2, 0) != 0);
+}
+
+
+/* These functions don't get included in libc.so */
+#ifdef IS_IN_libpthread
+void
+__lll_lock_wait (int *futex, int private)
+{
+ do
+ {
+ int oldval = atomic_compare_and_exchange_val_acq (futex, 2, 1);
+ if (oldval != 0)
+ lll_futex_wait (futex, 2, private);
+ }
+ while (atomic_compare_and_exchange_bool_acq (futex, 2, 0) != 0);
+}
+
+
+int
+__lll_timedlock_wait (int *futex, const struct timespec *abstime, int private)
+{
+ struct timespec rt;
+
+ /* Reject invalid timeouts. */
+ if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
+ return EINVAL;
+
+ /* Upgrade the lock. */
+ if (atomic_exchange_acq (futex, 2) == 0)
+ return 0;
+
+ do
+ {
+ struct timeval tv;
+
+ /* Get the current time. */
+ (void) gettimeofday (&tv, NULL);
+
+ /* Compute relative timeout. */
+ rt.tv_sec = abstime->tv_sec - tv.tv_sec;
+ rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+ if (rt.tv_nsec < 0)
+ {
+ rt.tv_nsec += 1000000000;
+ --rt.tv_sec;
+ }
+
+ /* Already timed out? */
+ if (rt.tv_sec < 0)
+ return ETIMEDOUT;
+
+ // XYZ: Lost the lock to check whether it was private.
+ lll_futex_timed_wait (futex, 2, &rt, private);
+ }
+ while (atomic_compare_and_exchange_bool_acq (futex, 2, 0) != 0);
+
+ return 0;
+}
+
+
+int
+__lll_timedwait_tid (int *tidp, const struct timespec *abstime)
+{
+ int tid;
+
+ if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
+ return EINVAL;
+
+ /* Repeat until thread terminated. */
+ while ((tid = *tidp) != 0)
+ {
+ struct timeval tv;
+ struct timespec rt;
+
+ /* Get the current time. */
+ (void) gettimeofday (&tv, NULL);
+
+ /* Compute relative timeout. */
+ rt.tv_sec = abstime->tv_sec - tv.tv_sec;
+ rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+ if (rt.tv_nsec < 0)
+ {
+ rt.tv_nsec += 1000000000;
+ --rt.tv_sec;
+ }
+
+ /* Already timed out? */
+ if (rt.tv_sec < 0)
+ return ETIMEDOUT;
+
+ /* Wait until thread terminates. */
+ // XYZ: Lost the lock to check whether it was private.
+ if (lll_futex_timed_wait (tidp, tid, &rt, LLL_SHARED) == -ETIMEDOUT)
+ return ETIMEDOUT;
+ }
+
+ return 0;
+}
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/lowlevellock.h b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/lowlevellock.h
new file mode 100644
index 000000000..116a8c272
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/lowlevellock.h
@@ -0,0 +1,281 @@
+/* Copyright (C) 2005, 2006, 2007, 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
+ 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 _LOWLEVELLOCK_H
+#define _LOWLEVELLOCK_H 1
+
+#include <time.h>
+#include <sys/param.h>
+#include <bits/pthreadtypes.h>
+#include <atomic.h>
+#include <sysdep.h>
+#include <bits/kernel-features.h>
+
+#define FUTEX_WAIT 0
+#define FUTEX_WAKE 1
+#define FUTEX_REQUEUE 3
+#define FUTEX_CMP_REQUEUE 4
+#define FUTEX_WAKE_OP 5
+#define FUTEX_OP_CLEAR_WAKE_IF_GT_ONE ((4 << 24) | 1)
+#define FUTEX_LOCK_PI 6
+#define FUTEX_UNLOCK_PI 7
+#define FUTEX_TRYLOCK_PI 8
+#define FUTEX_WAIT_BITSET 9
+#define FUTEX_WAKE_BITSET 10
+#define FUTEX_PRIVATE_FLAG 128
+#define FUTEX_CLOCK_REALTIME 256
+
+#define FUTEX_BITSET_MATCH_ANY 0xffffffff
+
+/* Values for 'private' parameter of locking macros. Yes, the
+ definition seems to be backwards. But it is not. The bit will be
+ reversed before passing to the system call. */
+#define LLL_PRIVATE 0
+#define LLL_SHARED FUTEX_PRIVATE_FLAG
+
+
+#if !defined NOT_IN_libc || defined IS_IN_rtld
+/* In libc.so or ld.so all futexes are private. */
+# ifdef __ASSUME_PRIVATE_FUTEX
+# define __lll_private_flag(fl, private) \
+ ((fl) | FUTEX_PRIVATE_FLAG)
+# else
+# define __lll_private_flag(fl, private) \
+ ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex))
+# endif
+#else
+# ifdef __ASSUME_PRIVATE_FUTEX
+# define __lll_private_flag(fl, private) \
+ (((fl) | FUTEX_PRIVATE_FLAG) ^ (private))
+# else
+# define __lll_private_flag(fl, private) \
+ (__builtin_constant_p (private) \
+ ? ((private) == 0 \
+ ? ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex)) \
+ : (fl)) \
+ : ((fl) | (((private) ^ FUTEX_PRIVATE_FLAG) \
+ & THREAD_GETMEM (THREAD_SELF, header.private_futex))))
+# endif
+#endif
+
+
+#define lll_futex_wait(futexp, val, private) \
+ lll_futex_timed_wait(futexp, val, NULL, private)
+
+#define lll_futex_timed_wait(futexp, val, timespec, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 4, (futexp), \
+ __lll_private_flag (FUTEX_WAIT, private), \
+ (val), (timespec)); \
+ __ret; \
+ })
+
+#define lll_futex_wake(futexp, nr, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 4, (futexp), \
+ __lll_private_flag (FUTEX_WAKE, private), \
+ (nr), 0); \
+ __ret; \
+ })
+
+#define lll_robust_dead(futexv, private) \
+ do \
+ { \
+ int *__futexp = &(futexv); \
+ atomic_or (__futexp, FUTEX_OWNER_DIED); \
+ lll_futex_wake (__futexp, 1, private); \
+ } \
+ while (0)
+
+/* Returns non-zero if error happened, zero if success. */
+#define lll_futex_requeue(futexp, nr_wake, nr_move, mutex, val, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 6, (futexp), \
+ __lll_private_flag (FUTEX_CMP_REQUEUE, private),\
+ (nr_wake), (nr_move), (mutex), (val)); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
+ })
+
+
+/* Returns non-zero if error happened, zero if success. */
+#define lll_futex_wake_unlock(futexp, nr_wake, nr_wake2, futexp2, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 6, (futexp), \
+ __lll_private_flag (FUTEX_WAKE_OP, private), \
+ (nr_wake), (nr_wake2), (futexp2), \
+ FUTEX_OP_CLEAR_WAKE_IF_GT_ONE); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
+ })
+
+
+#define lll_trylock(lock) \
+ atomic_compare_and_exchange_val_acq(&(lock), 1, 0)
+
+#define lll_cond_trylock(lock) \
+ atomic_compare_and_exchange_val_acq(&(lock), 2, 0)
+
+#define __lll_robust_trylock(futex, id) \
+ (atomic_compare_and_exchange_val_acq (futex, id, 0) != 0)
+#define lll_robust_trylock(lock, id) \
+ __lll_robust_trylock (&(lock), id)
+
+extern void __lll_lock_wait_private (int *futex) attribute_hidden;
+extern void __lll_lock_wait (int *futex, int private) attribute_hidden;
+extern int __lll_robust_lock_wait (int *futex, int private) attribute_hidden;
+
+#define __lll_lock(futex, private) \
+ ((void) ({ \
+ int *__futex = (futex); \
+ if (__builtin_expect (atomic_compare_and_exchange_val_acq (__futex, \
+ 1, 0), 0)) \
+ { \
+ if (__builtin_constant_p (private) && (private) == LLL_PRIVATE) \
+ __lll_lock_wait_private (__futex); \
+ else \
+ __lll_lock_wait (__futex, private); \
+ } \
+ }))
+#define lll_lock(futex, private) __lll_lock (&(futex), private)
+
+
+#define __lll_robust_lock(futex, id, private) \
+ ({ \
+ int *__futex = (futex); \
+ int __val = 0; \
+ \
+ if (__builtin_expect (atomic_compare_and_exchange_bool_acq (__futex, id, \
+ 0), 0)) \
+ __val = __lll_robust_lock_wait (__futex, private); \
+ __val; \
+ })
+#define lll_robust_lock(futex, id, private) \
+ __lll_robust_lock (&(futex), id, private)
+
+
+#define __lll_cond_lock(futex, private) \
+ ((void) ({ \
+ int *__futex = (futex); \
+ if (__builtin_expect (atomic_exchange_acq (__futex, 2), 0)) \
+ __lll_lock_wait (__futex, private); \
+ }))
+#define lll_cond_lock(futex, private) __lll_cond_lock (&(futex), private)
+
+
+#define lll_robust_cond_lock(futex, id, private) \
+ __lll_robust_lock (&(futex), (id) | FUTEX_WAITERS, private)
+
+
+extern int __lll_timedlock_wait (int *futex, const struct timespec *,
+ int private) attribute_hidden;
+extern int __lll_robust_timedlock_wait (int *futex, const struct timespec *,
+ int private) attribute_hidden;
+
+#define __lll_timedlock(futex, abstime, private) \
+ ({ \
+ int *__futex = (futex); \
+ int __val = 0; \
+ \
+ if (__builtin_expect (atomic_exchange_acq (__futex, 1), 0)) \
+ __val = __lll_timedlock_wait (__futex, abstime, private); \
+ __val; \
+ })
+#define lll_timedlock(futex, abstime, private) \
+ __lll_timedlock (&(futex), abstime, private)
+
+
+#define __lll_robust_timedlock(futex, abstime, id, private) \
+ ({ \
+ int *__futex = (futex); \
+ int __val = 0; \
+ \
+ if (__builtin_expect (atomic_compare_and_exchange_bool_acq (__futex, id, \
+ 0), 0)) \
+ __val = __lll_robust_timedlock_wait (__futex, abstime, private); \
+ __val; \
+ })
+#define lll_robust_timedlock(futex, abstime, id, private) \
+ __lll_robust_timedlock (&(futex), abstime, id, private)
+
+
+#define __lll_unlock(futex, private) \
+ (void) \
+ ({ int *__futex = (futex); \
+ int __oldval = atomic_exchange_rel (__futex, 0); \
+ if (__builtin_expect (__oldval > 1, 0)) \
+ lll_futex_wake (__futex, 1, private); \
+ })
+#define lll_unlock(futex, private) __lll_unlock(&(futex), private)
+
+
+#define __lll_robust_unlock(futex, private) \
+ (void) \
+ ({ int *__futex = (futex); \
+ int __oldval = atomic_exchange_rel (__futex, 0); \
+ if (__builtin_expect (__oldval & FUTEX_WAITERS, 0)) \
+ lll_futex_wake (__futex, 1, private); \
+ })
+#define lll_robust_unlock(futex, private) \
+ __lll_robust_unlock(&(futex), private)
+
+
+#define lll_islocked(futex) \
+ (futex != 0)
+
+
+/* Our internal lock implementation is identical to the binary-compatible
+ mutex implementation. */
+
+/* Initializers for lock. */
+#define LLL_LOCK_INITIALIZER (0)
+#define LLL_LOCK_INITIALIZER_LOCKED (1)
+
+/* The states of a lock are:
+ 0 - untaken
+ 1 - taken by one user
+ >1 - taken by more users */
+
+/* The kernel notifies a process which uses CLONE_CLEARTID via futex
+ wakeup when the clone terminates. The memory location contains the
+ thread ID while the clone is running and is reset to zero
+ afterwards. */
+#define lll_wait_tid(tid) \
+ do { \
+ __typeof (tid) __tid; \
+ while ((__tid = (tid)) != 0) \
+ lll_futex_wait (&(tid), __tid, LLL_SHARED);\
+ } while (0)
+
+extern int __lll_timedwait_tid (int *, const struct timespec *)
+ attribute_hidden;
+
+#define lll_timedwait_tid(tid, abstime) \
+ ({ \
+ int __res = 0; \
+ if ((tid) != 0) \
+ __res = __lll_timedwait_tid (&(tid), (abstime)); \
+ __res; \
+ })
+
+#endif /* lowlevellock.h */
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/pt-__syscall_error.c b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/pt-__syscall_error.c
new file mode 100644
index 000000000..5a48a9b2e
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/pt-__syscall_error.c
@@ -0,0 +1 @@
+#include <../../../../../../../libc/sysdeps/linux/arm/__syscall_error.c>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/pt-__syscall_rt_sigaction.c b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/pt-__syscall_rt_sigaction.c
new file mode 100644
index 000000000..50137c84a
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/pt-__syscall_rt_sigaction.c
@@ -0,0 +1 @@
+#include <../../../../../../../libc/sysdeps/linux/common/__syscall_rt_sigaction.c>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/pt-gettimeofday.c b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/pt-gettimeofday.c
new file mode 100644
index 000000000..79faf54bf
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/pt-gettimeofday.c
@@ -0,0 +1,5 @@
+#include <sys/syscall.h>
+#include <sys/time.h>
+
+int gettimeofday (struct timeval *, struct timezone *) attribute_hidden;
+_syscall2(int, gettimeofday, struct timeval *, tv, struct timezone *, tz)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/pthread_once.c b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/pthread_once.c
new file mode 100644
index 000000000..10781db21
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/pthread_once.c
@@ -0,0 +1,99 @@
+/* Copyright (C) 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/>. */
+
+#include "pthreadP.h"
+#include <lowlevellock.h>
+
+unsigned long int __fork_generation attribute_hidden;
+
+static void
+clear_once_control (void *arg)
+{
+ pthread_once_t *once_control = (pthread_once_t *) arg;
+
+ *once_control = 0;
+ lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE);
+}
+
+int
+attribute_protected
+__pthread_once (pthread_once_t *once_control, void (*init_routine) (void))
+{
+ for (;;)
+ {
+ int oldval;
+ int newval;
+
+ /* Pseudo code:
+ newval = __fork_generation | 1;
+ oldval = *once_control;
+ if ((oldval & 2) == 0)
+ *once_control = newval;
+ Do this atomically.
+ */
+ do
+ {
+ newval = __fork_generation | 1;
+ oldval = *once_control;
+ if (oldval & 2)
+ break;
+ } while (atomic_compare_and_exchange_val_acq (once_control, newval, oldval) != oldval);
+
+ /* Check if the initializer has already been done. */
+ if ((oldval & 2) != 0)
+ return 0;
+
+ /* Check if another thread already runs the initializer. */
+ if ((oldval & 1) == 0)
+ break;
+
+ /* Check whether the initializer execution was interrupted by a fork. */
+ if (oldval != newval)
+ break;
+
+ /* Same generation, some other thread was faster. Wait. */
+ lll_futex_wait (once_control, oldval, LLL_PRIVATE);
+ }
+
+ /* This thread is the first here. Do the initialization.
+ Register a cleanup handler so that in case the thread gets
+ interrupted the initialization can be restarted. */
+ pthread_cleanup_push (clear_once_control, once_control);
+
+ init_routine ();
+
+ pthread_cleanup_pop (0);
+
+ /* Say that the initialisation is done. */
+ *once_control = __fork_generation | 2;
+
+ /* Wake up all other threads. */
+ lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE);
+
+ return 0;
+}
+weak_alias (__pthread_once, pthread_once)
+strong_alias (__pthread_once, __pthread_once_internal)
+
+#if defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__PIC__)
+/* When statically linked, if pthread_create is used, this file
+ will be brought in. The exception handling code in GCC assumes
+ that if pthread_create is available, so are these. */
+const void *include_pthread_getspecific attribute_hidden = pthread_getspecific;
+const void *include_pthread_setspecific attribute_hidden = pthread_setspecific;
+const void *include_pthread_key_create attribute_hidden = pthread_key_create;
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h
new file mode 100644
index 000000000..6f683ab72
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h
@@ -0,0 +1,253 @@
+/* Copyright (C) 2003, 2004, 2005, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ 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 <tcb-offsets.h>
+#ifndef __ASSEMBLER__
+# include <pthreadP.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+/* NOTE: We do mark syscalls with unwind annotations, for the benefit of
+ cancellation; but they're really only accurate at the point of the
+ syscall. The ARM unwind directives are not rich enough without adding
+ a custom personality function. */
+
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .section ".text"; \
+ PSEUDO_PROLOGUE; \
+ .type __##syscall_name##_nocancel,%function; \
+ .globl __##syscall_name##_nocancel; \
+ __##syscall_name##_nocancel: \
+ cfi_sections(.debug_frame); \
+ cfi_startproc; \
+ DO_CALL (syscall_name, args); \
+ PSEUDO_RET; \
+ cfi_endproc; \
+ .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
+ ENTRY (name); \
+ SINGLE_THREAD_P; \
+ DOARGS_##args; \
+ bne .Lpseudo_cancel; \
+ cfi_remember_state; \
+ DO_CALL (syscall_name, 0); \
+ UNDOARGS_##args; \
+ cmn r0, $4096; \
+ PSEUDO_RET; \
+ cfi_restore_state; \
+ .Lpseudo_cancel: \
+ .fnstart; \
+ DOCARGS_##args; /* save syscall args etc. around CENABLE. */ \
+ CENABLE; \
+ mov ip, r0; /* put mask in safe place. */ \
+ UNDOCARGS_##args; /* restore syscall args. */ \
+ ldr r7, =SYS_ify (syscall_name); \
+ swi 0x0; /* do the call. */ \
+ .fnend; /* Past here we can't easily unwind. */ \
+ mov r7, r0; /* save syscall return value. */ \
+ mov r0, ip; /* get mask back. */ \
+ CDISABLE; \
+ mov r0, r7; /* retrieve return value. */ \
+ RESTORE_LR_##args; \
+ UNDOARGS_##args; \
+ cmn r0, $4096
+
+/* DOARGS pushes four bytes on the stack for five arguments, eight bytes for
+ six arguments, and nothing for fewer. In order to preserve doubleword
+ alignment, sometimes we must save an extra register. */
+
+# define RESTART_UNWIND \
+ .fnend; \
+ .fnstart; \
+ .save {r7, lr}
+
+# define DOCARGS_0 \
+ stmfd sp!, {r7, lr}; \
+ cfi_adjust_cfa_offset (8); \
+ cfi_rel_offset (r7, 0); \
+ cfi_rel_offset (lr, 4); \
+ .save {r7, lr}
+# define UNDOCARGS_0
+# define RESTORE_LR_0 \
+ ldmfd sp!, {r7, lr}; \
+ cfi_adjust_cfa_offset (-8); \
+ cfi_restore (r7); \
+ cfi_restore (lr)
+
+# define DOCARGS_1 \
+ stmfd sp!, {r0, r1, r7, lr}; \
+ cfi_adjust_cfa_offset (16); \
+ cfi_rel_offset (r7, 8); \
+ cfi_rel_offset (lr, 12); \
+ .save {r7, lr}; \
+ .pad #8
+# define UNDOCARGS_1 \
+ ldr r0, [sp], #8; \
+ cfi_adjust_cfa_offset (-8); \
+ RESTART_UNWIND
+# define RESTORE_LR_1 \
+ RESTORE_LR_0
+
+# define DOCARGS_2 \
+ stmfd sp!, {r0, r1, r7, lr}; \
+ cfi_adjust_cfa_offset (16); \
+ cfi_rel_offset (r7, 8); \
+ cfi_rel_offset (lr, 12); \
+ .save {r7, lr}; \
+ .pad #8
+# define UNDOCARGS_2 \
+ ldmfd sp!, {r0, r1}; \
+ cfi_adjust_cfa_offset (-8); \
+ RESTART_UNWIND
+# define RESTORE_LR_2 \
+ RESTORE_LR_0
+
+# define DOCARGS_3 \
+ stmfd sp!, {r0, r1, r2, r3, r7, lr}; \
+ cfi_adjust_cfa_offset (24); \
+ cfi_rel_offset (r7, 16); \
+ cfi_rel_offset (lr, 20); \
+ .save {r7, lr}; \
+ .pad #16
+# define UNDOCARGS_3 \
+ ldmfd sp!, {r0, r1, r2, r3}; \
+ cfi_adjust_cfa_offset (-16); \
+ RESTART_UNWIND
+# define RESTORE_LR_3 \
+ RESTORE_LR_0
+
+# define DOCARGS_4 \
+ stmfd sp!, {r0, r1, r2, r3, r7, lr}; \
+ cfi_adjust_cfa_offset (24); \
+ cfi_rel_offset (r7, 16); \
+ cfi_rel_offset (lr, 20); \
+ .save {r7, lr}; \
+ .pad #16
+# define UNDOCARGS_4 \
+ ldmfd sp!, {r0, r1, r2, r3}; \
+ cfi_adjust_cfa_offset (-16); \
+ RESTART_UNWIND
+# define RESTORE_LR_4 \
+ RESTORE_LR_0
+
+/* r4 is only stmfd'ed for correct stack alignment. */
+# define DOCARGS_5 \
+ .save {r4}; \
+ stmfd sp!, {r0, r1, r2, r3, r4, r7, lr}; \
+ cfi_adjust_cfa_offset (28); \
+ cfi_rel_offset (r7, 20); \
+ cfi_rel_offset (lr, 24); \
+ .save {r7, lr}; \
+ .pad #20
+# define UNDOCARGS_5 \
+ ldmfd sp!, {r0, r1, r2, r3}; \
+ cfi_adjust_cfa_offset (-16); \
+ .fnend; \
+ .fnstart; \
+ .save {r4}; \
+ .save {r7, lr}; \
+ .pad #4
+# define RESTORE_LR_5 \
+ ldmfd sp!, {r4, r7, lr}; \
+ cfi_adjust_cfa_offset (-12); \
+ /* r4 will be marked as restored later. */ \
+ cfi_restore (r7); \
+ cfi_restore (lr)
+
+# define DOCARGS_6 \
+ .save {r4, r5}; \
+ stmfd sp!, {r0, r1, r2, r3, r7, lr}; \
+ cfi_adjust_cfa_offset (24); \
+ cfi_rel_offset (r7, 16); \
+ cfi_rel_offset (lr, 20); \
+ .save {r7, lr}; \
+ .pad #16
+# define UNDOCARGS_6 \
+ ldmfd sp!, {r0, r1, r2, r3}; \
+ cfi_adjust_cfa_offset (-16); \
+ .fnend; \
+ .fnstart; \
+ .save {r4, r5}; \
+ .save {r7, lr}
+# define RESTORE_LR_6 \
+ RESTORE_LR_0
+
+# ifdef IS_IN_libpthread
+# define CENABLE bl PLTJMP(__pthread_enable_asynccancel)
+# define CDISABLE bl PLTJMP(__pthread_disable_asynccancel)
+# define __local_multiple_threads __pthread_multiple_threads
+# elif !defined NOT_IN_libc
+# define CENABLE bl PLTJMP(__libc_enable_asynccancel)
+# define CDISABLE bl PLTJMP(__libc_disable_asynccancel)
+# define __local_multiple_threads __libc_multiple_threads
+# elif defined IS_IN_librt
+# define CENABLE bl PLTJMP(__librt_enable_asynccancel)
+# define CDISABLE bl PLTJMP(__librt_disable_asynccancel)
+# else
+# error Unsupported library
+# endif
+
+# if defined IS_IN_libpthread || !defined NOT_IN_libc
+# ifndef __ASSEMBLER__
+extern int __local_multiple_threads attribute_hidden;
+# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
+# else
+# define SINGLE_THREAD_P \
+ ldr ip, 1b; \
+2: \
+ ldr ip, [pc, ip]; \
+ teq ip, #0;
+# define PSEUDO_PROLOGUE \
+ 1: .word __local_multiple_threads - 2f - 8;
+# endif
+# else
+/* There is no __local_multiple_threads for librt, so use the TCB. */
+# ifndef __ASSEMBLER__
+# define SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+# else
+# define PSEUDO_PROLOGUE
+# define SINGLE_THREAD_P \
+ stmfd sp!, {r0, lr}; \
+ cfi_adjust_cfa_offset (8); \
+ cfi_rel_offset (lr, 4); \
+ bl __aeabi_read_tp; \
+ ldr ip, [r0, #MULTIPLE_THREADS_OFFSET]; \
+ ldmfd sp!, {r0, lr}; \
+ cfi_adjust_cfa_offset (-8); \
+ cfi_restore (lr); \
+ teq ip, #0
+# define SINGLE_THREAD_P_PIC(x) SINGLE_THREAD_P
+# endif
+# endif
+
+#elif !defined __ASSEMBLER__
+
+/* For rtld, et cetera. */
+# define SINGLE_THREAD_P 1
+# define NO_CANCELLATION 1
+
+#endif
+
+#ifndef __ASSEMBLER__
+# define RTLD_SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind-forcedunwind.c b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind-forcedunwind.c
new file mode 100644
index 000000000..a6a0515ff
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind-forcedunwind.c
@@ -0,0 +1,177 @@
+/* Copyright (C) 2003, 2005, 2007, 2009, 2010 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@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; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <dlfcn.h>
+#include <stdio.h>
+#include <unwind.h>
+#include <pthreadP.h>
+
+#define __libc_dlopen(x) dlopen(x, (RTLD_LOCAL | RTLD_LAZY))
+#define __libc_dlsym dlsym
+#define __libc_dlclose dlclose
+#define __libc_fatal(x) {/*write(STDERR_FILENO, x, strlen(x));*/ abort();}
+
+static void *libgcc_s_handle;
+static void (*libgcc_s_resume) (struct _Unwind_Exception *exc)
+ __attribute_used__;
+static _Unwind_Reason_Code (*libgcc_s_personality)
+ (_Unwind_State, struct _Unwind_Exception *, struct _Unwind_Context *);
+static _Unwind_Reason_Code (*libgcc_s_forcedunwind)
+ (struct _Unwind_Exception *, _Unwind_Stop_Fn, void *);
+static _Unwind_Word (*libgcc_s_getcfa) (struct _Unwind_Context *);
+
+void
+__attribute_noinline__
+pthread_cancel_init (void)
+{
+ void *resume, *personality, *forcedunwind, *getcfa;
+ void *handle;
+
+ if (__builtin_expect (libgcc_s_handle != NULL, 1))
+ {
+ /* Force gcc to reload all values. */
+ __asm__ __volatile__ ("" ::: "memory");
+ return;
+ }
+
+ handle = __libc_dlopen ("libgcc_s.so.1");
+
+ if (handle == NULL
+ || (resume = __libc_dlsym (handle, "_Unwind_Resume")) == NULL
+ || (personality = __libc_dlsym (handle, "__gcc_personality_v0")) == NULL
+ || (forcedunwind = __libc_dlsym (handle, "_Unwind_ForcedUnwind"))
+ == NULL
+ || (getcfa = __libc_dlsym (handle, "_Unwind_GetCFA")) == NULL
+#ifdef ARCH_CANCEL_INIT
+ || ARCH_CANCEL_INIT (handle)
+#endif
+ )
+ __libc_fatal ("libgcc_s.so.1 must be installed for pthread_cancel to work\n");
+
+ libgcc_s_resume = resume;
+ libgcc_s_personality = personality;
+ libgcc_s_forcedunwind = forcedunwind;
+ libgcc_s_getcfa = getcfa;
+ /* Make sure libgcc_s_getcfa is written last. Otherwise,
+ pthread_cancel_init might return early even when the pointer the
+ caller is interested in is not initialized yet. */
+ atomic_write_barrier ();
+ libgcc_s_handle = handle;
+}
+
+void
+__libc_freeres_fn_section
+__unwind_freeres (void)
+{
+ void *handle = libgcc_s_handle;
+ if (handle != NULL)
+ {
+ libgcc_s_handle = NULL;
+ __libc_dlclose (handle);
+ }
+}
+
+#ifdef __thumb__
+void
+_Unwind_Resume (struct _Unwind_Exception *exc)
+{
+ if (__builtin_expect (libgcc_s_resume == NULL, 0))
+ pthread_cancel_init ();
+
+ libgcc_s_resume (exc);
+}
+
+#else
+/* It's vitally important that _Unwind_Resume not have a stack frame; the
+ ARM unwinder relies on register state at entrance. So we write this in
+ assembly. */
+
+__asm__ (
+" .globl _Unwind_Resume\n"
+" .type _Unwind_Resume, %function\n"
+"_Unwind_Resume:\n"
+" .cfi_sections .debug_frame\n"
+" " CFI_STARTPROC "\n"
+" stmfd sp!, {r4, r5, r6, lr}\n"
+" " CFI_ADJUST_CFA_OFFSET (16)" \n"
+" " CFI_REL_OFFSET (r4, 0) "\n"
+" " CFI_REL_OFFSET (r5, 4) "\n"
+" " CFI_REL_OFFSET (r6, 8) "\n"
+" " CFI_REL_OFFSET (lr, 12) "\n"
+" " CFI_REMEMBER_STATE "\n"
+" ldr r4, 1f\n"
+" ldr r5, 2f\n"
+"3: add r4, pc, r4\n"
+" ldr r3, [r4, r5]\n"
+" mov r6, r0\n"
+" cmp r3, #0\n"
+" beq 4f\n"
+"5: mov r0, r6\n"
+" ldmfd sp!, {r4, r5, r6, lr}\n"
+" " CFI_ADJUST_CFA_OFFSET (-16) "\n"
+" " CFI_RESTORE (r4) "\n"
+" " CFI_RESTORE (r5) "\n"
+" " CFI_RESTORE (r6) "\n"
+" " CFI_RESTORE (lr) "\n"
+" bx r3\n"
+" " CFI_RESTORE_STATE "\n"
+"4: bl pthread_cancel_init\n"
+" ldr r3, [r4, r5]\n"
+" b 5b\n"
+" " CFI_ENDPROC "\n"
+" .align 2\n"
+#ifdef __thumb2__
+"1: .word _GLOBAL_OFFSET_TABLE_ - 3b - 4\n"
+#else
+"1: .word _GLOBAL_OFFSET_TABLE_ - 3b - 8\n"
+#endif
+"2: .word libgcc_s_resume(GOTOFF)\n"
+" .size _Unwind_Resume, .-_Unwind_Resume\n"
+);
+
+#endif
+
+_Unwind_Reason_Code
+__gcc_personality_v0 (_Unwind_State state,
+ struct _Unwind_Exception *ue_header,
+ struct _Unwind_Context *context)
+{
+ if (__builtin_expect (libgcc_s_personality == NULL, 0))
+ pthread_cancel_init ();
+
+ return libgcc_s_personality (state, ue_header, context);
+}
+
+_Unwind_Reason_Code
+_Unwind_ForcedUnwind (struct _Unwind_Exception *exc, _Unwind_Stop_Fn stop,
+ void *stop_argument)
+{
+ if (__builtin_expect (libgcc_s_forcedunwind == NULL, 0))
+ pthread_cancel_init ();
+
+ return libgcc_s_forcedunwind (exc, stop, stop_argument);
+}
+
+_Unwind_Word
+_Unwind_GetCFA (struct _Unwind_Context *context)
+{
+ if (__builtin_expect (libgcc_s_getcfa == NULL, 0))
+ pthread_cancel_init ();
+
+ return libgcc_s_getcfa (context);
+}
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind-resume.c b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind-resume.c
new file mode 100644
index 000000000..e2e2e0be3
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind-resume.c
@@ -0,0 +1,116 @@
+/* Copyright (C) 2003, 2005, 2010 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@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; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <dlfcn.h>
+#include <stdio.h>
+#include <unwind.h>
+
+#define __libc_dlopen(x) dlopen(x, (RTLD_LOCAL | RTLD_LAZY))
+#define __libc_dlsym dlsym
+#define __libc_dlclose dlclose
+#define __libc_fatal(x) {/*write(STDERR_FILENO, x, strlen(x));*/ abort();}
+
+static void (*libgcc_s_resume) (struct _Unwind_Exception *exc)
+ __attribute_used__;
+static _Unwind_Reason_Code (*libgcc_s_personality)
+ (_Unwind_State, struct _Unwind_Exception *, struct _Unwind_Context *);
+
+static void init (void) __attribute_used__;
+
+static void
+init (void)
+{
+ void *resume, *personality;
+ void *handle;
+
+ handle = __libc_dlopen ("libgcc_s.so.1");
+
+ if (handle == NULL
+ || (resume = __libc_dlsym (handle, "_Unwind_Resume")) == NULL
+ || (personality = __libc_dlsym (handle, "__gcc_personality_v0")) == NULL)
+ __libc_fatal ("libgcc_s.so.1 must be installed for pthread_cancel to work\n");
+
+ libgcc_s_resume = resume;
+ libgcc_s_personality = personality;
+}
+#ifdef __thumb__
+void
+_Unwind_Resume (struct _Unwind_Exception *exc)
+{
+ if (__builtin_expect (libgcc_s_resume == NULL, 0))
+ init ();
+ libgcc_s_resume (exc);
+}
+#else
+/* It's vitally important that _Unwind_Resume not have a stack frame; the
+ ARM unwinder relies on register state at entrance. So we write this in
+ assembly. */
+
+__asm__ (
+" .globl _Unwind_Resume\n"
+" .type _Unwind_Resume, %function\n"
+"_Unwind_Resume:\n"
+" " CFI_SECTIONS (.debug_frame) "\n"
+" " CFI_STARTPROC "\n"
+" stmfd sp!, {r4, r5, r6, lr}\n"
+" " CFI_ADJUST_CFA_OFFSET (16)" \n"
+" " CFI_REL_OFFSET (r4, 0) "\n"
+" " CFI_REL_OFFSET (r5, 4) "\n"
+" " CFI_REL_OFFSET (r6, 8) "\n"
+" " CFI_REL_OFFSET (lr, 12) "\n"
+" " CFI_REMEMBER_STATE "\n"
+" ldr r4, 1f\n"
+" ldr r5, 2f\n"
+"3: add r4, pc, r4\n"
+" ldr r3, [r4, r5]\n"
+" mov r6, r0\n"
+" cmp r3, #0\n"
+" beq 4f\n"
+"5: mov r0, r6\n"
+" ldmfd sp!, {r4, r5, r6, lr}\n"
+" " CFI_ADJUST_CFA_OFFSET (-16) "\n"
+" " CFI_RESTORE (r4) "\n"
+" " CFI_RESTORE (r5) "\n"
+" " CFI_RESTORE (r6) "\n"
+" " CFI_RESTORE (lr) "\n"
+" bx r3\n"
+" " CFI_RESTORE_STATE "\n"
+"4: bl init\n"
+" ldr r3, [r4, r5]\n"
+" b 5b\n"
+" " CFI_ENDPROC "\n"
+" .align 2\n"
+#ifdef __thumb2__
+"1: .word _GLOBAL_OFFSET_TABLE_ - 3b - 4\n"
+#else
+"1: .word _GLOBAL_OFFSET_TABLE_ - 3b - 8\n"
+#endif
+"2: .word libgcc_s_resume(GOTOFF)\n"
+" .size _Unwind_Resume, .-_Unwind_Resume\n"
+);
+#endif
+
+_Unwind_Reason_Code
+__gcc_personality_v0 (_Unwind_State state,
+ struct _Unwind_Exception *ue_header,
+ struct _Unwind_Context *context)
+{
+ if (__builtin_expect (libgcc_s_personality == NULL, 0))
+ init ();
+ return libgcc_s_personality (state, ue_header, context);
+}
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/vfork.S
new file mode 100644
index 000000000..b9e8cf846
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/vfork.S
@@ -0,0 +1,38 @@
+/* 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/>. */
+
+#include <tcb-offsets.h>
+
+/* Save the PID value. */
+#define SAVE_PID \
+ str lr, [sp, #-4]!; /* Save LR. */ \
+ mov r0, #0xffff0fff; /* Point to the high page. */ \
+ mov lr, pc; /* Save our return address. */ \
+ sub pc, r0, #31; /* Jump to the TLS entry. */ \
+ ldr lr, [sp], #4; /* Restore LR. */ \
+ mov r2, r0; /* Save the TLS addr in r2. */ \
+ ldr r3, [r2, #PID_OFFSET]; /* Load the saved PID. */ \
+ rsbs r0, r3, #0; /* Negate it. */ \
+ moveq r0, #0x80000000; /* Use 0x80000000 if it was 0. */ \
+ str r0, [r2, #PID_OFFSET] /* Store the temporary PID. */
+
+/* Restore the old PID value in the parent. */
+#define RESTORE_PID \
+ cmp r0, #0; /* If we are the parent... */ \
+ strne r3, [r2, #PID_OFFSET] /* ... restore the saved PID. */
+
+#include "../../../../../../../libc/sysdeps/linux/arm/vfork.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/bits/local_lim.h b/libpthread/nptl/sysdeps/unix/sysv/linux/bits/local_lim.h
new file mode 100644
index 000000000..710de1d98
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/bits/local_lim.h
@@ -0,0 +1,99 @@
+/* Minimum guaranteed maximum values for system limits. Linux 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 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. We are free to choose a reasonable value. */
+#define PTHREAD_STACK_MIN 16384
+
+/* 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/libpthread/nptl/sysdeps/unix/sysv/linux/bits/posix_opt.h b/libpthread/nptl/sysdeps/unix/sysv/linux/bits/posix_opt.h
new file mode 100644
index 000000000..c92bd7246
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/bits/posix_opt.h
@@ -0,0 +1,203 @@
+/* Define POSIX options for Linux.
+ 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
+ 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/>. */
+
+#ifndef _BITS_POSIX_OPT_H
+#define _BITS_POSIX_OPT_H 1
+
+/* Job control is supported. */
+#define _POSIX_JOB_CONTROL 1
+
+/* Processes have a saved set-user-ID and a saved set-group-ID. */
+#define _POSIX_SAVED_IDS 1
+
+/* Priority scheduling is supported. */
+#define _POSIX_PRIORITY_SCHEDULING 200809L
+
+/* Synchronizing file data is supported. */
+#define _POSIX_SYNCHRONIZED_IO 200809L
+
+/* The fsync function is present. */
+#define _POSIX_FSYNC 200809L
+
+/* Mapping of files to memory is supported. */
+#define _POSIX_MAPPED_FILES 200809L
+
+/* Locking of all memory is supported. */
+#define _POSIX_MEMLOCK 200809L
+
+/* Locking of ranges of memory is supported. */
+#define _POSIX_MEMLOCK_RANGE 200809L
+
+/* Setting of memory protections is supported. */
+#define _POSIX_MEMORY_PROTECTION 200809L
+
+/* 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. */
+#define _POSIX_VDISABLE '\0'
+
+/* Filenames are not silently truncated. */
+#define _POSIX_NO_TRUNC 1
+
+/* 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 200809L
+
+/* We have the reentrant functions described in POSIX. */
+#define _POSIX_REENTRANT_FUNCTIONS 1
+#define _POSIX_THREAD_SAFE_FUNCTIONS 200809L
+
+/* We provide priority scheduling for threads. */
+#define _POSIX_THREAD_PRIORITY_SCHEDULING 200809L
+
+/* We support user-defined stack sizes. */
+#define _POSIX_THREAD_ATTR_STACKSIZE 200809L
+
+/* We support user-defined stacks. */
+#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
+
+#ifdef __UCLIBC_HAS_REALTIME__
+/* We support POSIX.1b semaphores. */
+#define _POSIX_SEMAPHORES 200809L
+#endif
+
+/* Real-time signals are supported. */
+#define _POSIX_REALTIME_SIGNALS 200809L
+
+/* We support asynchronous I/O. */
+#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 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 200809L
+
+/* CPU-time clocks support needs to be checked at runtime. */
+#define _POSIX_CPUTIME 0
+
+/* Clock support in threads must be also checked at runtime. */
+#define _POSIX_THREAD_CPUTIME 0
+
+#ifdef __UCLIBC_HAS_REGEX__
+/* GNU libc provides regular expression handling. */
+#define _POSIX_REGEXP 1
+#endif
+
+/* Reader/Writer locks are available. */
+#define _POSIX_READER_WRITER_LOCKS 200809L
+
+/* We have a POSIX shell. */
+#define _POSIX_SHELL 1
+
+/* We support the Timeouts option. */
+#define _POSIX_TIMEOUTS 200809L
+
+/* We support spinlocks. */
+#define _POSIX_SPIN_LOCKS 200809L
+
+#if 0 /* no support in uClibc (yet) */
+/* The `spawn' function family is supported. */
+#define _POSIX_SPAWN 200809L
+#endif
+
+/* We have POSIX timers. */
+#define _POSIX_TIMERS 200809L
+
+/* The barrier functions are available. */
+#define _POSIX_BARRIERS 200809L
+
+/* POSIX message queues are available. */
+#define _POSIX_MESSAGE_PASSING 200809L
+
+/* Thread process-shared synchronization is supported. */
+#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 200809L
+
+/* Advisory information interfaces are available. */
+#define _POSIX_ADVISORY_INFO 200809L
+
+#ifdef __UCLIBC_HAS_IPV6__
+/* IPv6 support is available. */
+#define _POSIX_IPV6 200809L
+#endif
+
+#ifdef __UCLIBC_HAS_SOCKET__
+/* Raw socket support is available. */
+#define _POSIX_RAW_SOCKETS 200809L
+#endif
+
+/* We have at least one terminal. */
+#define _POSIX2_CHAR_TERM 200809L
+
+/* Neither process nor thread sporadic server interfaces is available. */
+#define _POSIX_SPORADIC_SERVER -1
+#define _POSIX_THREAD_SPORADIC_SERVER -1
+
+/* trace.h is not available. */
+#define _POSIX_TRACE -1
+#define _POSIX_TRACE_EVENT_FILTER -1
+#define _POSIX_TRACE_INHERIT -1
+#define _POSIX_TRACE_LOG -1
+
+/* Typed memory objects are not available. */
+#define _POSIX_TYPED_MEMORY_OBJECTS -1
+
+#endif /* bits/posix_opt.h */
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/close.S b/libpthread/nptl/sysdeps/unix/sysv/linux/close.S
new file mode 100644
index 000000000..cf50a1eae
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/close.S
@@ -0,0 +1,21 @@
+#include <sysdep-cancel.h>
+
+/*
+extern int __close_nocancel (int) attribute_hidden;
+*/
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+
+PSEUDO (__libc_close, close, 1)
+ret
+PSEUDO_END(__libc_close)
+
+libc_hidden_def (__close_nocancel)
+libc_hidden_def (__libc_close)
+weak_alias (__libc_close, __close)
+libc_hidden_weak (__close)
+weak_alias (__libc_close, close)
+libc_hidden_weak (close)
+
+
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/connect.S b/libpthread/nptl/sysdeps/unix/sysv/linux/connect.S
new file mode 100644
index 000000000..441843fa0
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/connect.S
@@ -0,0 +1,12 @@
+#include <sysdep-cancel.h>
+#ifndef __NR_connect
+#error Missing definition of NR_connect needed for cancellation.
+#endif
+PSEUDO (__libc_connect, connect, 3)
+ret
+PSEUDO_END(__libc_connect)
+libc_hidden_def (__libc_connect)
+weak_alias (__libc_connect, __connect)
+libc_hidden_weak (__connect)
+weak_alias (__libc_connect, connect)
+libc_hidden_weak (connect)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/creat.S b/libpthread/nptl/sysdeps/unix/sysv/linux/creat.S
new file mode 100644
index 000000000..cd0e1b879
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/creat.S
@@ -0,0 +1,7 @@
+#include <sysdep-cancel.h>
+PSEUDO (__libc_creat, creat, 2)
+ret
+PSEUDO_END(__libc_creat)
+libc_hidden_def (__libc_creat)
+weak_alias (__libc_creat, creat)
+libc_hidden_weak (creat)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/createthread.c b/libpthread/nptl/sysdeps/unix/sysv/linux/createthread.c
new file mode 100644
index 000000000..398d04584
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/createthread.c
@@ -0,0 +1,23 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Martin Schwidefsky <schwidefsky@de.ibm.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/>. */
+
+/* Value passed to 'clone' for initialization of the thread register. */
+#define TLS_VALUE pd
+
+/* Get the real implementation. */
+#include <sysdeps/pthread/createthread.c>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/exit-thread.S b/libpthread/nptl/sysdeps/unix/sysv/linux/exit-thread.S
new file mode 100644
index 000000000..a4a7d5d16
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/exit-thread.S
@@ -0,0 +1,22 @@
+/* Copyright (C) 1991,92,97,99,2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ 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>
+
+PSEUDO (__exit_thread, exit, 1)
+ /* Shouldn't get here. */
+PSEUDO_END(__exit_thread)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/fork.c b/libpthread/nptl/sysdeps/unix/sysv/linux/fork.c
new file mode 100644
index 000000000..af4041031
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/fork.c
@@ -0,0 +1,231 @@
+/* Copyright (C) 2002, 2003, 2007, 2008 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <assert.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sysdep.h>
+#include <tls.h>
+#include "fork.h"
+#include <hp-timing.h>
+#include <ldsodefs.h>
+#include <atomic.h>
+#include <errno.h>
+
+unsigned long int *__fork_generation_pointer;
+
+
+
+/* The single linked list of all currently registered for handlers. */
+struct fork_handler *__fork_handlers;
+
+
+static void
+fresetlockfiles (void)
+{
+ FILE *fp;
+#ifdef __USE_STDIO_FUTEXES__
+ for (fp = _stdio_openlist; fp != NULL; fp = fp->__nextopen)
+ STDIO_INIT_MUTEX(fp->__lock);
+#else
+ pthread_mutexattr_t attr;
+
+ pthread_mutexattr_init(&attr);
+ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
+
+ for (fp = _stdio_openlist; fp != NULL; fp = fp->__nextopen)
+ pthread_mutex_init(&fp->__lock, &attr);
+
+ pthread_mutexattr_destroy(&attr);
+#endif
+}
+
+pid_t
+#if defined __arm__ && defined __thumb__ && __GNUC_PREREQ (4,6)
+/* GCC PR target/53735
+ * In thumb1 we run out of registers when compiling with Os so relax that
+ * to have more registers available for spilling by using O2 here.
+ */
+attribute_optimize("O2")
+#endif
+fork (void)
+{
+ pid_t pid;
+ struct used_handler
+ {
+ struct fork_handler *handler;
+ struct used_handler *next;
+ } *allp = NULL;
+
+ /* Run all the registered preparation handlers. In reverse order.
+ While doing this we build up a list of all the entries. */
+ struct fork_handler *runp;
+ while ((runp = __fork_handlers) != NULL)
+ {
+ /* Make sure we read from the current RUNP pointer. */
+ atomic_full_barrier ();
+
+ unsigned int oldval = runp->refcntr;
+
+ if (oldval == 0)
+ /* This means some other thread removed the list just after
+ the pointer has been loaded. Try again. Either the list
+ is empty or we can retry it. */
+ continue;
+
+ /* Bump the reference counter. */
+ if (atomic_compare_and_exchange_bool_acq (&__fork_handlers->refcntr,
+ oldval + 1, oldval))
+ /* The value changed, try again. */
+ continue;
+
+ /* We bumped the reference counter for the first entry in the
+ list. That means that none of the following entries will
+ just go away. The unloading code works in the order of the
+ list.
+
+ While executing the registered handlers we are building a
+ list of all the entries so that we can go backward later on. */
+ while (1)
+ {
+ /* Execute the handler if there is one. */
+ if (runp->prepare_handler != NULL)
+ runp->prepare_handler ();
+
+ /* Create a new element for the list. */
+ struct used_handler *newp
+ = (struct used_handler *) alloca (sizeof (*newp));
+ newp->handler = runp;
+ newp->next = allp;
+ allp = newp;
+
+ /* Advance to the next handler. */
+ runp = runp->next;
+ if (runp == NULL)
+ break;
+
+ /* Bump the reference counter for the next entry. */
+ atomic_increment (&runp->refcntr);
+ }
+
+ /* We are done. */
+ break;
+ }
+
+ __UCLIBC_IO_MUTEX_LOCK_CANCEL_UNSAFE(_stdio_openlist_add_lock);
+
+#ifndef NDEBUG
+ pid_t ppid = THREAD_GETMEM (THREAD_SELF, tid);
+#endif
+
+ /* We need to prevent the getpid() code to update the PID field so
+ that, if a signal arrives in the child very early and the signal
+ handler uses getpid(), the value returned is correct. */
+ pid_t parentpid = THREAD_GETMEM (THREAD_SELF, pid);
+ THREAD_SETMEM (THREAD_SELF, pid, -parentpid);
+
+#ifdef ARCH_FORK
+ pid = ARCH_FORK ();
+#else
+# error "ARCH_FORK must be defined so that the CLONE_SETTID flag is used"
+ pid = INLINE_SYSCALL (fork, 0);
+#endif
+
+
+ if (pid == 0)
+ {
+ struct pthread *self = THREAD_SELF;
+
+ assert (THREAD_GETMEM (self, tid) != ppid);
+
+ if (__fork_generation_pointer != NULL)
+ *__fork_generation_pointer += 4;
+
+ /* Adjust the PID field for the new process. */
+ THREAD_SETMEM (self, pid, THREAD_GETMEM (self, tid));
+
+#if HP_TIMING_AVAIL
+ /* The CPU clock of the thread and process have to be set to zero. */
+ hp_timing_t now;
+ HP_TIMING_NOW (now);
+ THREAD_SETMEM (self, cpuclock_offset, now);
+ GL(dl_cpuclock_offset) = now;
+#endif
+
+ /* Reset the file list. These are recursive mutexes. */
+ fresetlockfiles ();
+
+ /* Reset locks in the I/O code. */
+ STDIO_INIT_MUTEX(_stdio_openlist_add_lock);
+
+ /* XXX reset any locks in dynamic loader */
+
+ /* Run the handlers registered for the child. */
+ while (allp != NULL)
+ {
+ if (allp->handler->child_handler != NULL)
+ allp->handler->child_handler ();
+
+ /* Note that we do not have to wake any possible waiter.
+ This is the only thread in the new process. The count
+ may have been bumped up by other threads doing a fork.
+ We reset it to 1, to avoid waiting for non-existing
+ thread(s) to release the count. */
+ allp->handler->refcntr = 1;
+
+ /* XXX We could at this point look through the object pool
+ and mark all objects not on the __fork_handlers list as
+ unused. This is necessary in case the fork() happened
+ while another thread called dlclose() and that call had
+ to create a new list. */
+
+ allp = allp->next;
+ }
+
+ /* Initialize the fork lock. */
+ __fork_lock = LLL_LOCK_INITIALIZER;
+ }
+ else
+ {
+ assert (THREAD_GETMEM (THREAD_SELF, tid) == ppid);
+
+ /* Restore the PID value. */
+ THREAD_SETMEM (THREAD_SELF, pid, parentpid);
+
+ /* We execute this even if the 'fork' call failed. */
+ __UCLIBC_IO_MUTEX_UNLOCK_CANCEL_UNSAFE(_stdio_openlist_add_lock);
+
+ /* Run the handlers registered for the parent. */
+ while (allp != NULL)
+ {
+ if (allp->handler->parent_handler != NULL)
+ allp->handler->parent_handler ();
+
+ if (atomic_decrement_and_test (&allp->handler->refcntr)
+ && allp->handler->need_signal)
+ lll_futex_wake (allp->handler->refcntr, 1, LLL_PRIVATE);
+
+ allp = allp->next;
+ }
+ }
+
+ return pid;
+}
+libc_hidden_def(fork)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/fork.h b/libpthread/nptl/sysdeps/unix/sysv/linux/fork.h
new file mode 100644
index 000000000..dadd0dfee
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/fork.h
@@ -0,0 +1,59 @@
+/* Copyright (C) 2002, 2003, 2006, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <lowlevellock.h>
+
+/* The fork generation counter, defined in libpthread. */
+extern unsigned long int __fork_generation attribute_hidden;
+
+/* Pointer to the fork generation counter in the thread library. */
+extern unsigned long int *__fork_generation_pointer attribute_hidden;
+
+/* Lock to protect allocation and deallocation of fork handlers. */
+extern int __fork_lock attribute_hidden;
+
+/* Elements of the fork handler lists. */
+struct fork_handler
+{
+ struct fork_handler *next;
+ void (*prepare_handler) (void);
+ void (*parent_handler) (void);
+ void (*child_handler) (void);
+ void *dso_handle;
+ unsigned int refcntr;
+ int need_signal;
+};
+
+/* The single linked list of all currently registered for handlers. */
+extern struct fork_handler *__fork_handlers attribute_hidden;
+
+
+/* Function to call to unregister fork handlers. */
+extern void __unregister_atfork (void *dso_handle) attribute_hidden;
+#define UNREGISTER_ATFORK(dso_handle) __unregister_atfork (dso_handle)
+
+
+/* C library side function to register new fork handlers. */
+extern int __register_atfork (void (*__prepare) (void),
+ void (*__parent) (void),
+ void (*__child) (void),
+ void *dso_handle);
+libc_hidden_proto (__register_atfork)
+
+/* Add a new element to the fork list. */
+extern void __linkin_atfork (struct fork_handler *newp) attribute_hidden;
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/getpid.c b/libpthread/nptl/sysdeps/unix/sysv/linux/getpid.c
new file mode 100644
index 000000000..24abccc93
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/getpid.c
@@ -0,0 +1,69 @@
+/* Copyright (C) 2003, 2004 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 <unistd.h>
+#include <tls.h>
+#include <sysdep.h>
+
+#ifdef __NR_getxpid
+# undef __NR_getpid
+# define __NR_getpid __NR_getxpid
+#endif
+
+#ifndef NOT_IN_libc
+static inline __attribute__((always_inline)) pid_t really_getpid (pid_t oldval);
+
+static inline __attribute__((always_inline)) pid_t
+really_getpid (pid_t oldval)
+{
+ if (__builtin_expect (oldval == 0, 1))
+ {
+ pid_t selftid = THREAD_GETMEM (THREAD_SELF, tid);
+ if (__builtin_expect (selftid != 0, 1))
+ return selftid;
+ }
+
+ INTERNAL_SYSCALL_DECL (err);
+ pid_t result = INTERNAL_SYSCALL (getpid, err, 0);
+
+ /* We do not set the PID field in the TID here since we might be
+ called from a signal handler while the thread executes fork. */
+ if (oldval == 0)
+ THREAD_SETMEM (THREAD_SELF, tid, result);
+ return result;
+}
+#endif
+
+static pid_t
+__getpid (void)
+{
+#ifdef NOT_IN_libc
+ INTERNAL_SYSCALL_DECL (err);
+ pid_t result = INTERNAL_SYSCALL (getpid, err, 0);
+#else
+ pid_t result = THREAD_GETMEM (THREAD_SELF, pid);
+ if (__builtin_expect (result <= 0, 0))
+ result = really_getpid (result);
+#endif
+ return result;
+}
+weak_alias(__getpid, getpid)
+libc_hidden_weak(getpid)
+#if !defined NOT_IN_libc && !defined __NR_getppid
+strong_alias(getpid,getppid)
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/Makefile b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/Makefile
new file mode 100644
index 000000000..43a6fad84
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/Makefile
@@ -0,0 +1,13 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2005 Steven J. Hill <sjhill@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+top_srcdir=../../../../../../../
+top_builddir=../../../../../../../
+all: objs
+include $(top_builddir)Rules.mak
+include Makefile.arch
+include $(top_srcdir)Makerules
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/Makefile.arch b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/Makefile.arch
new file mode 100644
index 000000000..9dc878c4c
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/Makefile.arch
@@ -0,0 +1,15 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2006 Steven J. Hill <sjhill@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+libpthread_linux_arch_SSRC = clone.S pthread_spin_unlock.S pthread_once.S
+libpthread_linux_arch_CSRC = pthread_spin_init.c pt-__syscall_error.c
+
+libc_linux_arch_CSRC = fork.c
+libc_linux_arch_SSRC = clone.S vfork.S
+
+ASFLAGS += -DUSE___THREAD
+
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h
new file mode 100644
index 000000000..74359ff6c
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h
@@ -0,0 +1,172 @@
+/* Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _BITS_PTHREADTYPES_H
+#define _BITS_PTHREADTYPES_H 1
+
+#define __SIZEOF_PTHREAD_ATTR_T 36
+#define __SIZEOF_PTHREAD_MUTEX_T 24
+#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
+#define __SIZEOF_PTHREAD_COND_T 48
+#define __SIZEOF_PTHREAD_COND_COMPAT_T 12
+#define __SIZEOF_PTHREAD_CONDATTR_T 4
+#define __SIZEOF_PTHREAD_RWLOCK_T 32
+#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
+#define __SIZEOF_PTHREAD_BARRIER_T 20
+#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
+
+
+/* Thread identifiers. The structure of the attribute type is not
+ exposed on purpose. */
+typedef unsigned long int pthread_t;
+
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_ATTR_T];
+ long int __align;
+} pthread_attr_t;
+
+
+typedef struct __pthread_internal_slist
+{
+ struct __pthread_internal_slist *__next;
+} __pthread_slist_t;
+
+
+/* Data structures for mutex handling. The structure of the attribute
+ type is not exposed on purpose. */
+typedef union
+{
+ struct __pthread_mutex_s
+ {
+ int __lock;
+ unsigned int __count;
+ int __owner;
+ /* KIND must stay at this position in the structure to maintain
+ binary compatibility. */
+ int __kind;
+ unsigned int __nusers;
+ __extension__ union
+ {
+ int __spins;
+ __pthread_slist_t __list;
+ };
+ } __data;
+ char __size[__SIZEOF_PTHREAD_MUTEX_T];
+ long int __align;
+} pthread_mutex_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
+ long int __align;
+} pthread_mutexattr_t;
+
+
+/* Data structure for conditional variable handling. The structure of
+ the attribute type is not exposed on purpose. */
+typedef union
+{
+ struct
+ {
+ int __lock;
+ unsigned int __futex;
+ __extension__ unsigned long long int __total_seq;
+ __extension__ unsigned long long int __wakeup_seq;
+ __extension__ unsigned long long int __woken_seq;
+ void *__mutex;
+ unsigned int __nwaiters;
+ unsigned int __broadcast_seq;
+ } __data;
+ char __size[__SIZEOF_PTHREAD_COND_T];
+ __extension__ long long int __align;
+} pthread_cond_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_CONDATTR_T];
+ long int __align;
+} pthread_condattr_t;
+
+
+/* Keys for thread-specific data */
+typedef unsigned int pthread_key_t;
+
+
+/* Once-only execution */
+typedef int pthread_once_t;
+
+
+#if defined __USE_UNIX98 || defined __USE_XOPEN2K
+/* Data structure for read-write lock variable handling. The
+ structure of the attribute type is not exposed on purpose. */
+typedef union
+{
+ struct
+ {
+ int __lock;
+ unsigned int __nr_readers;
+ unsigned int __readers_wakeup;
+ unsigned int __writer_wakeup;
+ unsigned int __nr_readers_queued;
+ unsigned int __nr_writers_queued;
+ /* FLAGS must stay at this position in the structure to maintain
+ binary compatibility. */
+ unsigned char __flags;
+ unsigned char __shared;
+ unsigned char __pad1;
+ unsigned char __pad2;
+ int __writer;
+ } __data;
+ char __size[__SIZEOF_PTHREAD_RWLOCK_T];
+ long int __align;
+} pthread_rwlock_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
+ long int __align;
+} pthread_rwlockattr_t;
+#endif
+
+
+#ifdef __USE_XOPEN2K
+/* POSIX spinlock data type. */
+typedef volatile int pthread_spinlock_t;
+
+
+/* POSIX barriers data type. The structure of the type is
+ deliberately not exposed. */
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_BARRIER_T];
+ long int __align;
+} pthread_barrier_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];
+ int __align;
+} pthread_barrierattr_t;
+#endif
+
+
+/* Extra attributes for the cleanup functions. */
+#define __cleanup_fct_attribute __attribute__ ((__regparm__ (1)))
+
+#endif /* bits/pthreadtypes.h */
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/bits/semaphore.h b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/bits/semaphore.h
new file mode 100644
index 000000000..9da293aa7
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/bits/semaphore.h
@@ -0,0 +1,35 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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/>. */
+
+#ifndef _SEMAPHORE_H
+# error "Never use <bits/semaphore.h> directly; include <semaphore.h> instead."
+#endif
+
+
+#define __SIZEOF_SEM_T 16
+
+
+/* Value returned if `sem_open' failed. */
+#define SEM_FAILED ((sem_t *) 0)
+
+
+typedef union
+{
+ char __size[__SIZEOF_SEM_T];
+ long int __align;
+} sem_t;
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/clone.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/clone.S
new file mode 100644
index 000000000..9c7c46467
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/clone.S
@@ -0,0 +1,2 @@
+#define RESET_PID
+#include <libc/sysdeps/linux/i386/clone.S>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/createthread.c b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/createthread.c
new file mode 100644
index 000000000..e64c3271b
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/createthread.c
@@ -0,0 +1,48 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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/>. */
+
+/* The "thread register" gets initialized from a segment descriptor.
+ Initialize such a descriptor first. */
+#define PREPARE_CREATE \
+ union user_desc_init desc; \
+ \
+ /* Describe the thread-local storage segment. */ \
+ \
+ /* The 'entry_number' field. The first three bits of the segment \
+ register value select the GDT, ignore them. We get the index \
+ from the value of the %gs register in the current thread. */ \
+ desc.vals[0] = TLS_GET_GS () >> 3; \
+ /* The 'base_addr' field. Pointer to the TCB. */ \
+ desc.vals[1] = (unsigned long int) pd; \
+ /* The 'limit' field. We use 4GB which is 0xfffff pages. */ \
+ desc.vals[2] = 0xfffff; \
+ /* Collapsed value of the bitfield: \
+ .seg_32bit = 1 \
+ .contents = 0 \
+ .read_exec_only = 0 \
+ .limit_in_pages = 1 \
+ .seg_not_present = 0 \
+ .useable = 1 */ \
+ desc.vals[3] = 0x51
+
+/* Value passed to 'clone' for initialization of the thread register. */
+#define TLS_VALUE &desc.desc
+
+
+/* Get the real implementation. */
+#include <sysdeps/pthread/createthread.c>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/fork.c b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/fork.c
new file mode 100644
index 000000000..e7a41d8b7
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/fork.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <sched.h>
+#include <signal.h>
+#include <sysdep.h>
+#include <tls.h>
+
+
+#define ARCH_FORK() \
+ INLINE_SYSCALL (clone, 5, \
+ CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID | SIGCHLD, 0, \
+ NULL, NULL, &THREAD_SELF->tid)
+
+#include "../fork.c"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S
new file mode 100644
index 000000000..74dda472f
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S
@@ -0,0 +1,19 @@
+/* Copyright (C) 2002, 2003, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 "lowlevellock.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S
new file mode 100644
index 000000000..ff9a7847f
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S
@@ -0,0 +1,464 @@
+/* Copyright (C) 2002-2004, 2006, 2007, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread-errnos.h>
+#include <bits/kernel-features.h>
+#include <lowlevellock.h>
+#include <tcb-offsets.h>
+
+ .text
+
+#ifdef __ASSUME_PRIVATE_FUTEX
+# define LOAD_PRIVATE_FUTEX_WAIT(reg) \
+ movl $(FUTEX_WAIT | FUTEX_PRIVATE_FLAG), reg
+# define LOAD_PRIVATE_FUTEX_WAKE(reg) \
+ movl $(FUTEX_WAKE | FUTEX_PRIVATE_FLAG), reg
+# define LOAD_FUTEX_WAIT(reg) \
+ xorl $(FUTEX_WAIT | FUTEX_PRIVATE_FLAG), reg
+# define LOAD_FUTEX_WAIT_ABS(reg) \
+ xorl $(FUTEX_WAIT_BITSET | FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME), reg
+# define LOAD_FUTEX_WAKE(reg) \
+ xorl $(FUTEX_WAKE | FUTEX_PRIVATE_FLAG), reg
+#else
+# if FUTEX_WAIT == 0
+# define LOAD_PRIVATE_FUTEX_WAIT(reg) \
+ movl %gs:PRIVATE_FUTEX, reg
+# else
+# define LOAD_PRIVATE_FUTEX_WAIT(reg) \
+ movl %gs:PRIVATE_FUTEX, reg ; \
+ orl $FUTEX_WAIT, reg
+# endif
+# define LOAD_PRIVATE_FUTEX_WAKE(reg) \
+ movl %gs:PRIVATE_FUTEX, reg ; \
+ orl $FUTEX_WAKE, reg
+# if FUTEX_WAIT == 0
+# define LOAD_FUTEX_WAIT(reg) \
+ xorl $FUTEX_PRIVATE_FLAG, reg ; \
+ andl %gs:PRIVATE_FUTEX, reg
+# else
+# define LOAD_FUTEX_WAIT(reg) \
+ xorl $FUTEX_PRIVATE_FLAG, reg ; \
+ andl %gs:PRIVATE_FUTEX, reg ; \
+ orl $FUTEX_WAIT, reg
+# endif
+# define LOAD_FUTEX_WAIT_ABS(reg) \
+ xorl $FUTEX_PRIVATE_FLAG, reg ; \
+ andl %gs:PRIVATE_FUTEX, reg ; \
+ orl $FUTEX_WAIT_BITSET | FUTEX_CLOCK_REALTIME, reg
+# define LOAD_FUTEX_WAKE(reg) \
+ xorl $FUTEX_PRIVATE_FLAG, reg ; \
+ andl %gs:PRIVATE_FUTEX, reg ; \
+ orl $FUTEX_WAKE, reg
+#endif
+
+ .globl __lll_lock_wait_private
+ .type __lll_lock_wait_private,@function
+ .hidden __lll_lock_wait_private
+#ifndef IS_IN_libpthread
+ .weak __lll_lock_wait_private
+#endif
+ .align 16
+__lll_lock_wait_private:
+ cfi_startproc
+ pushl %edx
+ cfi_adjust_cfa_offset(4)
+ pushl %ebx
+ cfi_adjust_cfa_offset(4)
+ pushl %esi
+ cfi_adjust_cfa_offset(4)
+ cfi_offset(%edx, -8)
+ cfi_offset(%ebx, -12)
+ cfi_offset(%esi, -16)
+
+ movl $2, %edx
+ movl %ecx, %ebx
+ xorl %esi, %esi /* No timeout. */
+ LOAD_PRIVATE_FUTEX_WAIT (%ecx)
+
+ cmpl %edx, %eax /* NB: %edx == 2 */
+ jne 2f
+
+1: movl $SYS_futex, %eax
+ ENTER_KERNEL
+
+2: movl %edx, %eax
+ xchgl %eax, (%ebx) /* NB: lock is implied */
+
+ testl %eax, %eax
+ jnz 1b
+
+ popl %esi
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%esi)
+ popl %ebx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebx)
+ popl %edx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%edx)
+ ret
+ cfi_endproc
+ .size __lll_lock_wait_private,.-__lll_lock_wait_private
+
+#ifdef NOT_IN_libc
+ .globl __lll_lock_wait
+ .type __lll_lock_wait,@function
+ .hidden __lll_lock_wait
+ .align 16
+__lll_lock_wait:
+ cfi_startproc
+ pushl %edx
+ cfi_adjust_cfa_offset(4)
+ pushl %ebx
+ cfi_adjust_cfa_offset(4)
+ pushl %esi
+ cfi_adjust_cfa_offset(4)
+ cfi_offset(%edx, -8)
+ cfi_offset(%ebx, -12)
+ cfi_offset(%esi, -16)
+
+ movl %edx, %ebx
+ movl $2, %edx
+ xorl %esi, %esi /* No timeout. */
+ LOAD_FUTEX_WAIT (%ecx)
+
+ cmpl %edx, %eax /* NB: %edx == 2 */
+ jne 2f
+
+1: movl $SYS_futex, %eax
+ ENTER_KERNEL
+
+2: movl %edx, %eax
+ xchgl %eax, (%ebx) /* NB: lock is implied */
+
+ testl %eax, %eax
+ jnz 1b
+
+ popl %esi
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%esi)
+ popl %ebx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebx)
+ popl %edx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%edx)
+ ret
+ cfi_endproc
+ .size __lll_lock_wait,.-__lll_lock_wait
+
+ /* %ecx: futex
+ %esi: flags
+ %edx: timeout
+ %eax: futex value
+ */
+ .globl __lll_timedlock_wait
+ .type __lll_timedlock_wait,@function
+ .hidden __lll_timedlock_wait
+ .align 16
+__lll_timedlock_wait:
+ cfi_startproc
+ pushl %ebp
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset(%ebp, 0)
+ pushl %ebx
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset(%ebx, 0)
+
+# ifndef __ASSUME_FUTEX_CLOCK_REALTIME
+# ifdef __PIC__
+ LOAD_PIC_REG (bx)
+ cmpl $0, __have_futex_clock_realtime@GOTOFF(%ebx)
+# else
+ cmpl $0, __have_futex_clock_realtime
+# endif
+ je .Lreltmo
+# endif
+
+ movl %ecx, %ebx
+ movl %esi, %ecx
+ movl %edx, %esi
+ movl $0xffffffff, %ebp
+ LOAD_FUTEX_WAIT_ABS (%ecx)
+
+ movl $2, %edx
+ cmpl %edx, %eax
+ jne 2f
+
+1: movl $SYS_futex, %eax
+ movl $2, %edx
+ ENTER_KERNEL
+
+2: xchgl %edx, (%ebx) /* NB: lock is implied */
+
+ testl %edx, %edx
+ jz 3f
+
+ cmpl $-ETIMEDOUT, %eax
+ je 4f
+ cmpl $-EINVAL, %eax
+ jne 1b
+4: movl %eax, %edx
+ negl %edx
+
+3: movl %edx, %eax
+7: popl %ebx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebx)
+ popl %ebp
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebp)
+ ret
+
+# ifndef __ASSUME_FUTEX_CLOCK_REALTIME
+.Lreltmo:
+ /* Check for a valid timeout value. */
+ cmpl $1000000000, 4(%edx)
+ jae 3f
+
+ pushl %esi
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset(%esi, 0)
+ pushl %edi
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset(%edi, 0)
+
+ /* Stack frame for the timespec and timeval structs. */
+ subl $8, %esp
+ cfi_adjust_cfa_offset(8)
+
+ movl %ecx, %ebp
+ movl %edx, %edi
+
+ movl $2, %edx
+ xchgl %edx, (%ebp)
+
+ test %edx, %edx
+ je 6f
+
+1:
+ /* Get current time. */
+ movl %esp, %ebx
+ xorl %ecx, %ecx
+ movl $__NR_gettimeofday, %eax
+ ENTER_KERNEL
+
+ /* Compute relative timeout. */
+ movl 4(%esp), %eax
+ movl $1000, %edx
+ mul %edx /* Milli seconds to nano seconds. */
+ movl (%edi), %ecx
+ movl 4(%edi), %edx
+ subl (%esp), %ecx
+ subl %eax, %edx
+ jns 4f
+ addl $1000000000, %edx
+ subl $1, %ecx
+4: testl %ecx, %ecx
+ js 2f /* Time is already up. */
+
+ /* Store relative timeout. */
+ movl %ecx, (%esp)
+ movl %edx, 4(%esp)
+
+ /* Futex call. */
+ movl %ebp, %ebx
+ movl $2, %edx
+ movl %esp, %esi
+ movl 16(%esp), %ecx
+ LOAD_FUTEX_WAIT (%ecx)
+ movl $SYS_futex, %eax
+ ENTER_KERNEL
+
+ /* NB: %edx == 2 */
+ xchgl %edx, (%ebp)
+
+ testl %edx, %edx
+ je 6f
+
+ cmpl $-ETIMEDOUT, %eax
+ jne 1b
+2: movl $ETIMEDOUT, %edx
+
+6: addl $8, %esp
+ cfi_adjust_cfa_offset(-8)
+ popl %edi
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%edi)
+ popl %esi
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%esi)
+7: popl %ebx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebx)
+ popl %ebp
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebp)
+ movl %edx, %eax
+ ret
+
+3: movl $EINVAL, %edx
+ jmp 7b
+# endif
+ cfi_endproc
+ .size __lll_timedlock_wait,.-__lll_timedlock_wait
+#endif
+
+ .globl __lll_unlock_wake_private
+ .type __lll_unlock_wake_private,@function
+ .hidden __lll_unlock_wake_private
+#ifndef IS_IN_libpthread
+ .weak __lll_unlock_wake_private
+#endif
+ .align 16
+__lll_unlock_wake_private:
+ cfi_startproc
+ pushl %ebx
+ cfi_adjust_cfa_offset(4)
+ pushl %ecx
+ cfi_adjust_cfa_offset(4)
+ pushl %edx
+ cfi_adjust_cfa_offset(4)
+ cfi_offset(%ebx, -8)
+ cfi_offset(%ecx, -12)
+ cfi_offset(%edx, -16)
+
+ movl %eax, %ebx
+ movl $0, (%eax)
+ LOAD_PRIVATE_FUTEX_WAKE (%ecx)
+ movl $1, %edx /* Wake one thread. */
+ movl $SYS_futex, %eax
+ ENTER_KERNEL
+
+ popl %edx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%edx)
+ popl %ecx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ecx)
+ popl %ebx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebx)
+ ret
+ cfi_endproc
+ .size __lll_unlock_wake_private,.-__lll_unlock_wake_private
+
+#ifdef NOT_IN_libc
+ .globl __lll_unlock_wake
+ .type __lll_unlock_wake,@function
+ .hidden __lll_unlock_wake
+ .align 16
+__lll_unlock_wake:
+ cfi_startproc
+ pushl %ebx
+ cfi_adjust_cfa_offset(4)
+ pushl %ecx
+ cfi_adjust_cfa_offset(4)
+ pushl %edx
+ cfi_adjust_cfa_offset(4)
+ cfi_offset(%ebx, -8)
+ cfi_offset(%ecx, -12)
+ cfi_offset(%edx, -16)
+
+ movl %eax, %ebx
+ movl $0, (%eax)
+ LOAD_FUTEX_WAKE (%ecx)
+ movl $1, %edx /* Wake one thread. */
+ movl $SYS_futex, %eax
+ ENTER_KERNEL
+
+ popl %edx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%edx)
+ popl %ecx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ecx)
+ popl %ebx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebx)
+ ret
+ cfi_endproc
+ .size __lll_unlock_wake,.-__lll_unlock_wake
+
+ .globl __lll_timedwait_tid
+ .type __lll_timedwait_tid,@function
+ .hidden __lll_timedwait_tid
+ .align 16
+__lll_timedwait_tid:
+ pushl %edi
+ pushl %esi
+ pushl %ebx
+ pushl %ebp
+
+ movl %eax, %ebp
+ movl %edx, %edi
+ subl $8, %esp
+
+ /* Get current time. */
+2: movl %esp, %ebx
+ xorl %ecx, %ecx
+ movl $__NR_gettimeofday, %eax
+ ENTER_KERNEL
+
+ /* Compute relative timeout. */
+ movl 4(%esp), %eax
+ movl $1000, %edx
+ mul %edx /* Milli seconds to nano seconds. */
+ movl (%edi), %ecx
+ movl 4(%edi), %edx
+ subl (%esp), %ecx
+ subl %eax, %edx
+ jns 5f
+ addl $1000000000, %edx
+ subl $1, %ecx
+5: testl %ecx, %ecx
+ js 6f /* Time is already up. */
+
+ movl %ecx, (%esp) /* Store relative timeout. */
+ movl %edx, 4(%esp)
+
+ movl (%ebp), %edx
+ testl %edx, %edx
+ jz 4f
+
+ movl %esp, %esi
+ /* XXX The kernel so far uses global futex for the wakeup at
+ all times. */
+ xorl %ecx, %ecx /* movl $FUTEX_WAIT, %ecx */
+ movl %ebp, %ebx
+ movl $SYS_futex, %eax
+ ENTER_KERNEL
+
+ cmpl $0, (%ebx)
+ jne 1f
+4: xorl %eax, %eax
+
+3: addl $8, %esp
+ popl %ebp
+ popl %ebx
+ popl %esi
+ popl %edi
+ ret
+
+1: cmpl $-ETIMEDOUT, %eax
+ jne 2b
+6: movl $ETIMEDOUT, %eax
+ jmp 3b
+ .size __lll_timedwait_tid,.-__lll_timedwait_tid
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevelrobustlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevelrobustlock.S
new file mode 100644
index 000000000..7196d40e4
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevelrobustlock.S
@@ -0,0 +1,233 @@
+/* Copyright (C) 2002, 2003, 2004, 2006, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread-errnos.h>
+#include <lowlevellock.h>
+#include <lowlevelrobustlock.h>
+#include <bits/kernel-features.h>
+#include <tls.h>
+
+ .text
+
+#define FUTEX_WAITERS 0x80000000
+#define FUTEX_OWNER_DIED 0x40000000
+
+#ifdef __ASSUME_PRIVATE_FUTEX
+# define LOAD_FUTEX_WAIT(reg) \
+ xorl $(FUTEX_WAIT | FUTEX_PRIVATE_FLAG), reg
+#else
+# if FUTEX_WAIT == 0
+# define LOAD_FUTEX_WAIT(reg) \
+ xorl $FUTEX_PRIVATE_FLAG, reg ; \
+ andl %gs:PRIVATE_FUTEX, reg
+# else
+# define LOAD_FUTEX_WAIT(reg) \
+ xorl $FUTEX_PRIVATE_FLAG, reg ; \
+ andl %gs:PRIVATE_FUTEX, reg ; \
+ orl $FUTEX_WAIT, reg
+# endif
+#endif
+
+ .globl __lll_robust_lock_wait
+ .type __lll_robust_lock_wait,@function
+ .hidden __lll_robust_lock_wait
+ .align 16
+__lll_robust_lock_wait:
+ cfi_startproc
+ pushl %edx
+ cfi_adjust_cfa_offset(4)
+ pushl %ebx
+ cfi_adjust_cfa_offset(4)
+ pushl %esi
+ cfi_adjust_cfa_offset(4)
+ cfi_offset(%edx, -8)
+ cfi_offset(%ebx, -12)
+ cfi_offset(%esi, -16)
+
+ movl %edx, %ebx
+ xorl %esi, %esi /* No timeout. */
+ LOAD_FUTEX_WAIT (%ecx)
+
+4: movl %eax, %edx
+ orl $FUTEX_WAITERS, %edx
+
+ testl $FUTEX_OWNER_DIED, %eax
+ jnz 3f
+
+ cmpl %edx, %eax /* NB: %edx == 2 */
+ je 1f
+
+ LOCK
+ cmpxchgl %edx, (%ebx)
+ jnz 2f
+
+1: movl $SYS_futex, %eax
+ ENTER_KERNEL
+
+ movl (%ebx), %eax
+
+2: test %eax, %eax
+ jne 4b
+
+ movl %gs:TID, %edx
+ orl $FUTEX_WAITERS, %edx
+ LOCK
+ cmpxchgl %edx, (%ebx)
+ jnz 4b
+ /* NB: %eax == 0 */
+
+3: popl %esi
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%esi)
+ popl %ebx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebx)
+ popl %edx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%edx)
+ ret
+ cfi_endproc
+ .size __lll_robust_lock_wait,.-__lll_robust_lock_wait
+
+
+ .globl __lll_robust_timedlock_wait
+ .type __lll_robust_timedlock_wait,@function
+ .hidden __lll_robust_timedlock_wait
+ .align 16
+__lll_robust_timedlock_wait:
+ cfi_startproc
+ /* Check for a valid timeout value. */
+ cmpl $1000000000, 4(%edx)
+ jae 3f
+
+ pushl %edi
+ cfi_adjust_cfa_offset(4)
+ pushl %esi
+ cfi_adjust_cfa_offset(4)
+ pushl %ebx
+ cfi_adjust_cfa_offset(4)
+ pushl %ebp
+ cfi_adjust_cfa_offset(4)
+ cfi_offset(%edi, -8)
+ cfi_offset(%esi, -12)
+ cfi_offset(%ebx, -16)
+ cfi_offset(%ebp, -20)
+
+ /* Stack frame for the timespec and timeval structs. */
+ subl $12, %esp
+ cfi_adjust_cfa_offset(12)
+
+ movl %ecx, %ebp
+ movl %edx, %edi
+
+1: movl %eax, 8(%esp)
+
+ /* Get current time. */
+ movl %esp, %ebx
+ xorl %ecx, %ecx
+ movl $__NR_gettimeofday, %eax
+ ENTER_KERNEL
+
+ /* Compute relative timeout. */
+ movl 4(%esp), %eax
+ movl $1000, %edx
+ mul %edx /* Milli seconds to nano seconds. */
+ movl (%edi), %ecx
+ movl 4(%edi), %edx
+ subl (%esp), %ecx
+ subl %eax, %edx
+ jns 4f
+ addl $1000000000, %edx
+ subl $1, %ecx
+4: testl %ecx, %ecx
+ js 8f /* Time is already up. */
+
+ /* Store relative timeout. */
+ movl %ecx, (%esp)
+ movl %edx, 4(%esp)
+
+ movl %ebp, %ebx
+
+ movl 8(%esp), %edx
+ movl %edx, %eax
+ orl $FUTEX_WAITERS, %edx
+
+ testl $FUTEX_OWNER_DIED, %eax
+ jnz 6f
+
+ cmpl %eax, %edx
+ je 2f
+
+ LOCK
+ cmpxchgl %edx, (%ebx)
+ movl $0, %ecx /* Must use mov to avoid changing cc. */
+ jnz 5f
+
+2:
+ /* Futex call. */
+ movl %esp, %esi
+ movl 20(%esp), %ecx
+ LOAD_FUTEX_WAIT (%ecx)
+ movl $SYS_futex, %eax
+ ENTER_KERNEL
+ movl %eax, %ecx
+
+ movl (%ebx), %eax
+
+5: testl %eax, %eax
+ jne 7f
+
+ movl %gs:TID, %edx
+ orl $FUTEX_WAITERS, %edx
+ LOCK
+ cmpxchgl %edx, (%ebx)
+ jnz 7f
+
+6: addl $12, %esp
+ cfi_adjust_cfa_offset(-12)
+ popl %ebp
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebp)
+ popl %ebx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebx)
+ popl %esi
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%esi)
+ popl %edi
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%edi)
+ ret
+
+3: movl $EINVAL, %eax
+ ret
+
+ cfi_adjust_cfa_offset(28)
+ cfi_offset(%edi, -8)
+ cfi_offset(%esi, -12)
+ cfi_offset(%ebx, -16)
+ cfi_offset(%ebp, -20)
+ /* Check whether the time expired. */
+7: cmpl $-ETIMEDOUT, %ecx
+ jne 1b
+
+8: movl $ETIMEDOUT, %eax
+ jmp 6b
+ cfi_endproc
+ .size __lll_robust_timedlock_wait,.-__lll_robust_timedlock_wait
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_barrier_wait.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_barrier_wait.S
new file mode 100644
index 000000000..5443a3805
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_barrier_wait.S
@@ -0,0 +1,186 @@
+/* Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <lowlevellock.h>
+#include <lowlevelbarrier.h>
+
+ .text
+
+ .globl pthread_barrier_wait
+ .type pthread_barrier_wait,@function
+ .align 16
+pthread_barrier_wait:
+ cfi_startproc
+ pushl %ebx
+ cfi_adjust_cfa_offset(4)
+ cfi_offset(%ebx, -8)
+
+ movl 8(%esp), %ebx
+
+ /* Get the mutex. */
+ movl $1, %edx
+ xorl %eax, %eax
+ LOCK
+ cmpxchgl %edx, MUTEX(%ebx)
+ jnz 1f
+
+ /* One less waiter. If this was the last one needed wake
+ everybody. */
+2: subl $1, LEFT(%ebx)
+ je 3f
+
+ /* There are more threads to come. */
+ pushl %esi
+ cfi_adjust_cfa_offset(4)
+ cfi_offset(%esi, -12)
+
+#if CURR_EVENT == 0
+ movl (%ebx), %edx
+#else
+ movl CURR_EVENT(%ebx), %edx
+#endif
+
+ /* Release the mutex. */
+ LOCK
+ subl $1, MUTEX(%ebx)
+ jne 6f
+
+ /* Wait for the remaining threads. The call will return immediately
+ if the CURR_EVENT memory has meanwhile been changed. */
+7:
+#if FUTEX_WAIT == 0
+ movl PRIVATE(%ebx), %ecx
+#else
+ movl $FUTEX_WAIT, %ecx
+ orl PRIVATE(%ebx), %ecx
+#endif
+ xorl %esi, %esi
+8: movl $SYS_futex, %eax
+ ENTER_KERNEL
+
+ /* Don't return on spurious wakeups. The syscall does not change
+ any register except %eax so there is no need to reload any of
+ them. */
+#if CURR_EVENT == 0
+ cmpl %edx, (%ebx)
+#else
+ cmpl %edx, CURR_EVENT(%ebx)
+#endif
+ je 8b
+
+ /* Increment LEFT. If this brings the count back to the
+ initial count unlock the object. */
+ movl $1, %edx
+ movl INIT_COUNT(%ebx), %ecx
+ LOCK
+ xaddl %edx, LEFT(%ebx)
+ subl $1, %ecx
+ cmpl %ecx, %edx
+ jne 10f
+
+ /* Release the mutex. We cannot release the lock before
+ waking the waiting threads since otherwise a new thread might
+ arrive and gets waken up, too. */
+ LOCK
+ subl $1, MUTEX(%ebx)
+ jne 9f
+
+ /* Note: %esi is still zero. */
+10: movl %esi, %eax /* != PTHREAD_BARRIER_SERIAL_THREAD */
+
+ popl %esi
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%esi)
+ popl %ebx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebx)
+ ret
+
+ cfi_adjust_cfa_offset(4)
+ cfi_offset(%ebx, -8)
+
+ /* The necessary number of threads arrived. */
+3:
+#if CURR_EVENT == 0
+ addl $1, (%ebx)
+#else
+ addl $1, CURR_EVENT(%ebx)
+#endif
+
+ /* Wake up all waiters. The count is a signed number in the kernel
+ so 0x7fffffff is the highest value. */
+ movl $0x7fffffff, %edx
+ movl $FUTEX_WAKE, %ecx
+ orl PRIVATE(%ebx), %ecx
+ movl $SYS_futex, %eax
+ ENTER_KERNEL
+
+ /* Increment LEFT. If this brings the count back to the
+ initial count unlock the object. */
+ movl $1, %edx
+ movl INIT_COUNT(%ebx), %ecx
+ LOCK
+ xaddl %edx, LEFT(%ebx)
+ subl $1, %ecx
+ cmpl %ecx, %edx
+ jne 5f
+
+ /* Release the mutex. We cannot release the lock before
+ waking the waiting threads since otherwise a new thread might
+ arrive and gets waken up, too. */
+ LOCK
+ subl $1, MUTEX(%ebx)
+ jne 4f
+
+5: orl $-1, %eax /* == PTHREAD_BARRIER_SERIAL_THREAD */
+
+ popl %ebx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebx)
+ ret
+
+ cfi_adjust_cfa_offset(4)
+ cfi_offset(%ebx, -8)
+1: movl PRIVATE(%ebx), %ecx
+ leal MUTEX(%ebx), %edx
+ xorl $LLL_SHARED, %ecx
+ call __lll_lock_wait
+ jmp 2b
+
+4: movl PRIVATE(%ebx), %ecx
+ leal MUTEX(%ebx), %eax
+ xorl $LLL_SHARED, %ecx
+ call __lll_unlock_wake
+ jmp 5b
+
+ cfi_adjust_cfa_offset(4)
+ cfi_offset(%esi, -12)
+6: movl PRIVATE(%ebx), %ecx
+ leal MUTEX(%ebx), %eax
+ xorl $LLL_SHARED, %ecx
+ call __lll_unlock_wake
+ jmp 7b
+
+9: movl PRIVATE(%ebx), %ecx
+ leal MUTEX(%ebx), %eax
+ xorl $LLL_SHARED, %ecx
+ call __lll_unlock_wake
+ jmp 10b
+ cfi_endproc
+ .size pthread_barrier_wait,.-pthread_barrier_wait
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S
new file mode 100644
index 000000000..d53aa7282
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S
@@ -0,0 +1,238 @@
+/* Copyright (C) 2002,2003,2004,2006,2007,2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <lowlevellock.h>
+#include <lowlevelcond.h>
+#include <bits/kernel-features.h>
+#include <pthread-pi-defines.h>
+#include <pthread-errnos.h>
+#include <tls.h>
+
+ .text
+
+ /* int pthread_cond_broadcast (pthread_cond_t *cond) */
+ .globl __pthread_cond_broadcast
+ .type __pthread_cond_broadcast, @function
+ .protected __pthread_cond_broadcast
+ .align 16
+__pthread_cond_broadcast:
+ cfi_startproc
+ pushl %ebx
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset(%ebx, 0)
+ pushl %esi
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset(%esi, 0)
+ pushl %edi
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset(%edi, 0)
+ pushl %ebp
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset(%ebp, 0)
+ cfi_remember_state
+
+ movl 20(%esp), %ebx
+
+ /* Get internal lock. */
+ movl $1, %edx
+ xorl %eax, %eax
+ LOCK
+#if cond_lock == 0
+ cmpxchgl %edx, (%ebx)
+#else
+ cmpxchgl %edx, cond_lock(%ebx)
+#endif
+ jnz 1f
+
+2: addl $cond_futex, %ebx
+ movl total_seq+4-cond_futex(%ebx), %eax
+ movl total_seq-cond_futex(%ebx), %ebp
+ cmpl wakeup_seq+4-cond_futex(%ebx), %eax
+ ja 3f
+ jb 4f
+ cmpl wakeup_seq-cond_futex(%ebx), %ebp
+ jna 4f
+
+ /* Cause all currently waiting threads to recognize they are
+ woken up. */
+3: movl %ebp, wakeup_seq-cond_futex(%ebx)
+ movl %eax, wakeup_seq-cond_futex+4(%ebx)
+ movl %ebp, woken_seq-cond_futex(%ebx)
+ movl %eax, woken_seq-cond_futex+4(%ebx)
+ addl %ebp, %ebp
+ addl $1, broadcast_seq-cond_futex(%ebx)
+ movl %ebp, (%ebx)
+
+ /* Get the address of the mutex used. */
+ movl dep_mutex-cond_futex(%ebx), %edi
+
+ /* Unlock. */
+ LOCK
+ subl $1, cond_lock-cond_futex(%ebx)
+ jne 7f
+
+ /* Don't use requeue for pshared condvars. */
+8: cmpl $-1, %edi
+ je 9f
+
+ /* Do not use requeue for pshared condvars. */
+ testl $PS_BIT, MUTEX_KIND(%edi)
+ jne 9f
+
+ /* Requeue to a non-robust PI mutex if the PI bit is set and
+ the robust bit is not set. */
+ movl MUTEX_KIND(%edi), %eax
+ andl $(ROBUST_BIT|PI_BIT), %eax
+ cmpl $PI_BIT, %eax
+ je 81f
+
+ /* Wake up all threads. */
+#ifdef __ASSUME_PRIVATE_FUTEX
+ movl $(FUTEX_CMP_REQUEUE|FUTEX_PRIVATE_FLAG), %ecx
+#else
+ movl %gs:PRIVATE_FUTEX, %ecx
+ orl $FUTEX_CMP_REQUEUE, %ecx
+#endif
+ movl $SYS_futex, %eax
+ movl $0x7fffffff, %esi
+ movl $1, %edx
+ /* Get the address of the futex involved. */
+# if MUTEX_FUTEX != 0
+ addl $MUTEX_FUTEX, %edi
+# endif
+/* FIXME: Until Ingo fixes 4G/4G vDSO, 6 arg syscalls are broken for sysenter.
+ ENTER_KERNEL */
+ int $0x80
+
+ /* For any kind of error, which mainly is EAGAIN, we try again
+ with WAKE. The general test also covers running on old
+ kernels. */
+ cmpl $0xfffff001, %eax
+ jae 9f
+
+6: xorl %eax, %eax
+ popl %ebp
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebp)
+ popl %edi
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%edi)
+ popl %esi
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%esi)
+ popl %ebx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebx)
+ ret
+
+ cfi_restore_state
+
+81: movl $(FUTEX_CMP_REQUEUE_PI|FUTEX_PRIVATE_FLAG), %ecx
+ movl $SYS_futex, %eax
+ movl $0x7fffffff, %esi
+ movl $1, %edx
+ /* Get the address of the futex involved. */
+# if MUTEX_FUTEX != 0
+ addl $MUTEX_FUTEX, %edi
+# endif
+ int $0x80
+
+ /* For any kind of error, which mainly is EAGAIN, we try again
+ with WAKE. The general test also covers running on old
+ kernels. */
+ cmpl $0xfffff001, %eax
+ jb 6b
+ jmp 9f
+
+ /* Initial locking failed. */
+1:
+#if cond_lock == 0
+ movl %ebx, %edx
+#else
+ leal cond_lock(%ebx), %edx
+#endif
+#if (LLL_SHARED-LLL_PRIVATE) > 255
+ xorl %ecx, %ecx
+#endif
+ cmpl $-1, dep_mutex(%ebx)
+ setne %cl
+ subl $1, %ecx
+ andl $(LLL_SHARED-LLL_PRIVATE), %ecx
+#if LLL_PRIVATE != 0
+ addl $LLL_PRIVATE, %ecx
+#endif
+ call __lll_lock_wait
+ jmp 2b
+
+ .align 16
+ /* Unlock. */
+4: LOCK
+ subl $1, cond_lock-cond_futex(%ebx)
+ je 6b
+
+ /* Unlock in loop requires wakeup. */
+5: leal cond_lock-cond_futex(%ebx), %eax
+#if (LLL_SHARED-LLL_PRIVATE) > 255
+ xorl %ecx, %ecx
+#endif
+ cmpl $-1, dep_mutex-cond_futex(%ebx)
+ setne %cl
+ subl $1, %ecx
+ andl $(LLL_SHARED-LLL_PRIVATE), %ecx
+#if LLL_PRIVATE != 0
+ addl $LLL_PRIVATE, %ecx
+#endif
+ call __lll_unlock_wake
+ jmp 6b
+
+ /* Unlock in loop requires wakeup. */
+7: leal cond_lock-cond_futex(%ebx), %eax
+#if (LLL_SHARED-LLL_PRIVATE) > 255
+ xorl %ecx, %ecx
+#endif
+ cmpl $-1, dep_mutex-cond_futex(%ebx)
+ setne %cl
+ subl $1, %ecx
+ andl $(LLL_SHARED-LLL_PRIVATE), %ecx
+#if LLL_PRIVATE != 0
+ addl $LLL_PRIVATE, %ecx
+#endif
+ call __lll_unlock_wake
+ jmp 8b
+
+9: /* The futex requeue functionality is not available. */
+ movl $0x7fffffff, %edx
+#if FUTEX_PRIVATE_FLAG > 255
+ xorl %ecx, %ecx
+#endif
+ cmpl $-1, dep_mutex-cond_futex(%ebx)
+ sete %cl
+ subl $1, %ecx
+#ifdef __ASSUME_PRIVATE_FUTEX
+ andl $FUTEX_PRIVATE_FLAG, %ecx
+#else
+ andl %gs:PRIVATE_FUTEX, %ecx
+#endif
+ addl $FUTEX_WAKE, %ecx
+ movl $SYS_futex, %eax
+ ENTER_KERNEL
+ jmp 6b
+ cfi_endproc
+ .size __pthread_cond_broadcast, .-__pthread_cond_broadcast
+weak_alias(__pthread_cond_broadcast, pthread_cond_broadcast)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S
new file mode 100644
index 000000000..d831a6bf5
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S
@@ -0,0 +1,215 @@
+/* Copyright (C) 2002,2003,2004,2005,2007,2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <lowlevellock.h>
+#include <lowlevelcond.h>
+#include <bits/kernel-features.h>
+#include <pthread-pi-defines.h>
+#include <pthread-errnos.h>
+#include <tls.h>
+
+
+ .text
+
+ /* int pthread_cond_signal (pthread_cond_t *cond) */
+ .globl __pthread_cond_signal
+ .type __pthread_cond_signal, @function
+ .protected __pthread_cond_signal
+ .align 16
+__pthread_cond_signal:
+
+ cfi_startproc
+ pushl %ebx
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset(%ebx, 0)
+ pushl %edi
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset(%edi, 0)
+ cfi_remember_state
+
+ movl 12(%esp), %edi
+
+ /* Get internal lock. */
+ movl $1, %edx
+ xorl %eax, %eax
+ LOCK
+#if cond_lock == 0
+ cmpxchgl %edx, (%edi)
+#else
+ cmpxchgl %edx, cond_lock(%edi)
+#endif
+ jnz 1f
+
+2: leal cond_futex(%edi), %ebx
+ movl total_seq+4(%edi), %eax
+ movl total_seq(%edi), %ecx
+ cmpl wakeup_seq+4(%edi), %eax
+#if cond_lock != 0
+ /* Must use leal to preserve the flags. */
+ leal cond_lock(%edi), %edi
+#endif
+ ja 3f
+ jb 4f
+ cmpl wakeup_seq-cond_futex(%ebx), %ecx
+ jbe 4f
+
+ /* Bump the wakeup number. */
+3: addl $1, wakeup_seq-cond_futex(%ebx)
+ adcl $0, wakeup_seq-cond_futex+4(%ebx)
+ addl $1, (%ebx)
+
+ /* Wake up one thread. */
+ pushl %esi
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset(%esi, 0)
+ pushl %ebp
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset(%ebp, 0)
+
+#if FUTEX_PRIVATE_FLAG > 255
+ xorl %ecx, %ecx
+#endif
+ cmpl $-1, dep_mutex-cond_futex(%ebx)
+ sete %cl
+ je 8f
+
+ movl dep_mutex-cond_futex(%ebx), %edx
+ /* Requeue to a non-robust PI mutex if the PI bit is set and
+ the robust bit is not set. */
+ movl MUTEX_KIND(%edx), %eax
+ andl $(ROBUST_BIT|PI_BIT), %eax
+ cmpl $PI_BIT, %eax
+ je 9f
+
+8: subl $1, %ecx
+#ifdef __ASSUME_PRIVATE_FUTEX
+ andl $FUTEX_PRIVATE_FLAG, %ecx
+#else
+ andl %gs:PRIVATE_FUTEX, %ecx
+#endif
+ addl $FUTEX_WAKE_OP, %ecx
+ movl $SYS_futex, %eax
+ movl $1, %edx
+ movl $1, %esi
+ movl $FUTEX_OP_CLEAR_WAKE_IF_GT_ONE, %ebp
+ /* FIXME: Until Ingo fixes 4G/4G vDSO, 6 arg syscalls are broken for
+ sysenter.
+ ENTER_KERNEL */
+ int $0x80
+ popl %ebp
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebp)
+ popl %esi
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%esi)
+
+ /* For any kind of error, we try again with WAKE.
+ The general test also covers running on old kernels. */
+ cmpl $-4095, %eax
+ jae 7f
+
+6: xorl %eax, %eax
+ popl %edi
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%edi)
+ popl %ebx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebx)
+ ret
+
+ cfi_restore_state
+
+9: movl $(FUTEX_CMP_REQUEUE_PI|FUTEX_PRIVATE_FLAG), %ecx
+ movl $SYS_futex, %eax
+ movl $1, %edx
+ xorl %esi, %esi
+ movl dep_mutex-cond_futex(%ebx), %edi
+ movl (%ebx), %ebp
+ /* FIXME: Until Ingo fixes 4G/4G vDSO, 6 arg syscalls are broken for
+ sysenter.
+ ENTER_KERNEL */
+ int $0x80
+ popl %ebp
+ popl %esi
+
+ leal -cond_futex(%ebx), %edi
+
+ /* For any kind of error, we try again with WAKE.
+ The general test also covers running on old kernels. */
+ cmpl $-4095, %eax
+ jb 4f
+
+7:
+#ifdef __ASSUME_PRIVATE_FUTEX
+ andl $FUTEX_PRIVATE_FLAG, %ecx
+#else
+ andl %gs:PRIVATE_FUTEX, %ecx
+#endif
+ orl $FUTEX_WAKE, %ecx
+
+ xorl $(FUTEX_WAKE ^ FUTEX_WAKE_OP), %ecx
+ movl $SYS_futex, %eax
+ /* %edx should be 1 already from $FUTEX_WAKE_OP syscall.
+ movl $1, %edx */
+ ENTER_KERNEL
+
+ /* Unlock. Note that at this point %edi always points to
+ cond_lock. */
+4: LOCK
+ subl $1, (%edi)
+ je 6b
+
+ /* Unlock in loop requires wakeup. */
+5: movl %edi, %eax
+#if (LLL_SHARED-LLL_PRIVATE) > 255
+ xorl %ecx, %ecx
+#endif
+ cmpl $-1, dep_mutex-cond_futex(%ebx)
+ setne %cl
+ subl $1, %ecx
+ andl $(LLL_SHARED-LLL_PRIVATE), %ecx
+#if LLL_PRIVATE != 0
+ addl $LLL_PRIVATE, %ecx
+#endif
+ call __lll_unlock_wake
+ jmp 6b
+
+ /* Initial locking failed. */
+1:
+#if cond_lock == 0
+ movl %edi, %edx
+#else
+ leal cond_lock(%edi), %edx
+#endif
+#if (LLL_SHARED-LLL_PRIVATE) > 255
+ xorl %ecx, %ecx
+#endif
+ cmpl $-1, dep_mutex(%edi)
+ setne %cl
+ subl $1, %ecx
+ andl $(LLL_SHARED-LLL_PRIVATE), %ecx
+#if LLL_PRIVATE != 0
+ addl $LLL_PRIVATE, %ecx
+#endif
+ call __lll_lock_wait
+ jmp 2b
+
+ cfi_endproc
+ .size __pthread_cond_signal, .-__pthread_cond_signal
+weak_alias(__pthread_cond_signal, pthread_cond_signal)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S
new file mode 100644
index 000000000..fd388f993
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S
@@ -0,0 +1,698 @@
+/* Copyright (C) 2002-2004,2006-2007,2009,2010 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <lowlevellock.h>
+#include <lowlevelcond.h>
+#include <pthread-errnos.h>
+#include <pthread-pi-defines.h>
+#include <bits/kernel-features.h>
+#include <tcb-offsets.h>
+
+
+ .text
+
+/* int pthread_cond_timedwait (pthread_cond_t *cond, pthread_mutex_t *mutex,
+ const struct timespec *abstime) */
+ .globl __pthread_cond_timedwait
+ .type __pthread_cond_timedwait, @function
+ .protected __pthread_cond_timedwait
+ .align 16
+__pthread_cond_timedwait:
+.LSTARTCODE:
+ cfi_startproc
+#ifdef SHARED
+ cfi_personality(DW_EH_PE_pcrel | DW_EH_PE_sdata4 | DW_EH_PE_indirect,
+ DW.ref.__gcc_personality_v0)
+ cfi_lsda(DW_EH_PE_pcrel | DW_EH_PE_sdata4, .LexceptSTART)
+#else
+ cfi_personality(DW_EH_PE_udata4, __gcc_personality_v0)
+ cfi_lsda(DW_EH_PE_udata4, .LexceptSTART)
+#endif
+
+ pushl %ebp
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset(%ebp, 0)
+ pushl %edi
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset(%edi, 0)
+ pushl %esi
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset(%esi, 0)
+ pushl %ebx
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset(%ebx, 0)
+
+ movl 20(%esp), %ebx
+ movl 28(%esp), %ebp
+
+ cmpl $1000000000, 4(%ebp)
+ movl $EINVAL, %eax
+ jae 18f
+
+ /* Get internal lock. */
+ movl $1, %edx
+ xorl %eax, %eax
+ LOCK
+#if cond_lock == 0
+ cmpxchgl %edx, (%ebx)
+#else
+ cmpxchgl %edx, cond_lock(%ebx)
+#endif
+ jnz 1f
+
+ /* Store the reference to the mutex. If there is already a
+ different value in there this is a bad user bug. */
+2: cmpl $-1, dep_mutex(%ebx)
+ movl 24(%esp), %eax
+ je 17f
+ movl %eax, dep_mutex(%ebx)
+
+ /* Unlock the mutex. */
+17: xorl %edx, %edx
+ call __pthread_mutex_unlock_usercnt
+
+ testl %eax, %eax
+ jne 16f
+
+ addl $1, total_seq(%ebx)
+ adcl $0, total_seq+4(%ebx)
+ addl $1, cond_futex(%ebx)
+ addl $(1 << nwaiters_shift), cond_nwaiters(%ebx)
+
+#define FRAME_SIZE 32
+ subl $FRAME_SIZE, %esp
+ cfi_adjust_cfa_offset(FRAME_SIZE)
+ cfi_remember_state
+
+ /* Get and store current wakeup_seq value. */
+ movl wakeup_seq(%ebx), %edi
+ movl wakeup_seq+4(%ebx), %edx
+ movl broadcast_seq(%ebx), %eax
+ movl %edi, 12(%esp)
+ movl %edx, 16(%esp)
+ movl %eax, 20(%esp)
+
+ /* Reset the pi-requeued flag. */
+8: movl $0, 24(%esp)
+ /* Get the current time. */
+ movl %ebx, %edx
+#ifdef __NR_clock_gettime
+ /* Get the clock number. */
+ movl cond_nwaiters(%ebx), %ebx
+ andl $((1 << nwaiters_shift) - 1), %ebx
+ /* Only clocks 0 and 1 are allowed so far. Both are handled in the
+ kernel. */
+ leal 4(%esp), %ecx
+ movl $__NR_clock_gettime, %eax
+ ENTER_KERNEL
+# ifndef __ASSUME_POSIX_TIMERS
+ cmpl $-ENOSYS, %eax
+ je 19f
+# endif
+ movl %edx, %ebx
+
+ /* Compute relative timeout. */
+ movl (%ebp), %ecx
+ movl 4(%ebp), %edx
+ subl 4(%esp), %ecx
+ subl 8(%esp), %edx
+#else
+ /* Get the current time. */
+ leal 4(%esp), %ebx
+ xorl %ecx, %ecx
+ movl $__NR_gettimeofday, %eax
+ ENTER_KERNEL
+ movl %edx, %ebx
+
+ /* Compute relative timeout. */
+ movl 8(%esp), %eax
+ movl $1000, %edx
+ mul %edx /* Milli seconds to nano seconds. */
+ movl (%ebp), %ecx
+ movl 4(%ebp), %edx
+ subl 4(%esp), %ecx
+ subl %eax, %edx
+#endif
+ jns 12f
+ addl $1000000000, %edx
+ subl $1, %ecx
+12: testl %ecx, %ecx
+ movl $-ETIMEDOUT, %esi
+ js 6f
+
+ /* Store relative timeout. */
+21: movl %ecx, 4(%esp)
+ movl %edx, 8(%esp)
+
+ movl cond_futex(%ebx), %edi
+ movl %edi, 28(%esp)
+
+ /* Unlock. */
+ LOCK
+#if cond_lock == 0
+ subl $1, (%ebx)
+#else
+ subl $1, cond_lock(%ebx)
+#endif
+ jne 3f
+
+.LcleanupSTART:
+4: call __pthread_enable_asynccancel
+ movl %eax, (%esp)
+
+#if FUTEX_PRIVATE_FLAG > 255
+ xorl %ecx, %ecx
+#endif
+ cmpl $-1, dep_mutex(%ebx)
+ sete %cl
+ je 40f
+
+ movl dep_mutex(%ebx), %edi
+ /* Requeue to a non-robust PI mutex if the PI bit is set and
+ the robust bit is not set. */
+ movl MUTEX_KIND(%edi), %eax
+ andl $(ROBUST_BIT|PI_BIT), %eax
+ cmpl $PI_BIT, %eax
+ jne 40f
+
+ movl $(FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG), %ecx
+ /* The following only works like this because we only support
+ two clocks, represented using a single bit. */
+ testl $1, cond_nwaiters(%ebx)
+ /* XXX Need to implement using sete instead of a jump. */
+ jne 42f
+ orl $FUTEX_CLOCK_REALTIME, %ecx
+
+ /* Requeue-PI uses absolute timeout */
+42: leal (%ebp), %esi
+ movl 28(%esp), %edx
+ addl $cond_futex, %ebx
+ movl $SYS_futex, %eax
+ ENTER_KERNEL
+ subl $cond_futex, %ebx
+ movl %eax, %esi
+ /* Set the pi-requeued flag only if the kernel has returned 0. The
+ kernel does not hold the mutex on ETIMEDOUT or any other error. */
+ cmpl $0, %eax
+ sete 24(%esp)
+ je 41f
+
+ /* Normal and PI futexes dont mix. Use normal futex functions only
+ if the kernel does not support the PI futex functions. */
+ cmpl $-ENOSYS, %eax
+ jne 41f
+ xorl %ecx, %ecx
+
+40: subl $1, %ecx
+#ifdef __ASSUME_PRIVATE_FUTEX
+ andl $FUTEX_PRIVATE_FLAG, %ecx
+#else
+ andl %gs:PRIVATE_FUTEX, %ecx
+#endif
+#if FUTEX_WAIT != 0
+ addl $FUTEX_WAIT, %ecx
+#endif
+ leal 4(%esp), %esi
+ movl 28(%esp), %edx
+ addl $cond_futex, %ebx
+.Ladd_cond_futex:
+ movl $SYS_futex, %eax
+ ENTER_KERNEL
+ subl $cond_futex, %ebx
+.Lsub_cond_futex:
+ movl %eax, %esi
+
+41: movl (%esp), %eax
+ call __pthread_disable_asynccancel
+.LcleanupEND:
+
+ /* Lock. */
+ movl $1, %edx
+ xorl %eax, %eax
+ LOCK
+#if cond_lock == 0
+ cmpxchgl %edx, (%ebx)
+#else
+ cmpxchgl %edx, cond_lock(%ebx)
+#endif
+ jnz 5f
+
+6: movl broadcast_seq(%ebx), %eax
+ cmpl 20(%esp), %eax
+ jne 23f
+
+ movl woken_seq(%ebx), %eax
+ movl woken_seq+4(%ebx), %ecx
+
+ movl wakeup_seq(%ebx), %edi
+ movl wakeup_seq+4(%ebx), %edx
+
+ cmpl 16(%esp), %edx
+ jne 7f
+ cmpl 12(%esp), %edi
+ je 15f
+
+7: cmpl %ecx, %edx
+ jne 9f
+ cmp %eax, %edi
+ jne 9f
+
+15: cmpl $-ETIMEDOUT, %esi
+ jne 8b
+
+ addl $1, wakeup_seq(%ebx)
+ adcl $0, wakeup_seq+4(%ebx)
+ addl $1, cond_futex(%ebx)
+ movl $ETIMEDOUT, %esi
+ jmp 14f
+
+23: xorl %esi, %esi
+ jmp 24f
+
+9: xorl %esi, %esi
+14: addl $1, woken_seq(%ebx)
+ adcl $0, woken_seq+4(%ebx)
+
+24: subl $(1 << nwaiters_shift), cond_nwaiters(%ebx)
+
+ /* Wake up a thread which wants to destroy the condvar object. */
+ movl total_seq(%ebx), %eax
+ andl total_seq+4(%ebx), %eax
+ cmpl $0xffffffff, %eax
+ jne 25f
+ movl cond_nwaiters(%ebx), %eax
+ andl $~((1 << nwaiters_shift) - 1), %eax
+ jne 25f
+
+ addl $cond_nwaiters, %ebx
+ movl $SYS_futex, %eax
+#if FUTEX_PRIVATE_FLAG > 255
+ xorl %ecx, %ecx
+#endif
+ cmpl $-1, dep_mutex-cond_nwaiters(%ebx)
+ sete %cl
+ subl $1, %ecx
+#ifdef __ASSUME_PRIVATE_FUTEX
+ andl $FUTEX_PRIVATE_FLAG, %ecx
+#else
+ andl %gs:PRIVATE_FUTEX, %ecx
+#endif
+ addl $FUTEX_WAKE, %ecx
+ movl $1, %edx
+ ENTER_KERNEL
+ subl $cond_nwaiters, %ebx
+
+25: LOCK
+#if cond_lock == 0
+ subl $1, (%ebx)
+#else
+ subl $1, cond_lock(%ebx)
+#endif
+ jne 10f
+
+11: movl 24+FRAME_SIZE(%esp), %eax
+ /* With requeue_pi, the mutex lock is held in the kernel. */
+ movl 24(%esp), %ecx
+ testl %ecx, %ecx
+ jnz 27f
+
+ call __pthread_mutex_cond_lock
+26: addl $FRAME_SIZE, %esp
+ cfi_adjust_cfa_offset(-FRAME_SIZE);
+
+ /* We return the result of the mutex_lock operation if it failed. */
+ testl %eax, %eax
+#ifdef HAVE_CMOV
+ cmovel %esi, %eax
+#else
+ jne 22f
+ movl %esi, %eax
+22:
+#endif
+
+18: popl %ebx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebx)
+ popl %esi
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%esi)
+ popl %edi
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%edi)
+ popl %ebp
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebp)
+
+ ret
+
+ cfi_restore_state
+
+27: call __pthread_mutex_cond_lock_adjust
+ xorl %eax, %eax
+ jmp 26b
+
+ cfi_adjust_cfa_offset(-FRAME_SIZE);
+ /* Initial locking failed. */
+1:
+#if cond_lock == 0
+ movl %ebx, %edx
+#else
+ leal cond_lock(%ebx), %edx
+#endif
+#if (LLL_SHARED-LLL_PRIVATE) > 255
+ xorl %ecx, %ecx
+#endif
+ cmpl $-1, dep_mutex(%ebx)
+ setne %cl
+ subl $1, %ecx
+ andl $(LLL_SHARED-LLL_PRIVATE), %ecx
+#if LLL_PRIVATE != 0
+ addl $LLL_PRIVATE, %ecx
+#endif
+ call __lll_lock_wait
+ jmp 2b
+
+ /* The initial unlocking of the mutex failed. */
+16:
+ LOCK
+#if cond_lock == 0
+ subl $1, (%ebx)
+#else
+ subl $1, cond_lock(%ebx)
+#endif
+ jne 18b
+
+ movl %eax, %esi
+#if cond_lock == 0
+ movl %ebx, %eax
+#else
+ leal cond_lock(%ebx), %eax
+#endif
+#if (LLL_SHARED-LLL_PRIVATE) > 255
+ xorl %ecx, %ecx
+#endif
+ cmpl $-1, dep_mutex(%ebx)
+ setne %cl
+ subl $1, %ecx
+ andl $(LLL_SHARED-LLL_PRIVATE), %ecx
+#if LLL_PRIVATE != 0
+ addl $LLL_PRIVATE, %ecx
+#endif
+ call __lll_unlock_wake
+
+ movl %esi, %eax
+ jmp 18b
+
+ cfi_adjust_cfa_offset(FRAME_SIZE)
+
+ /* Unlock in loop requires wakeup. */
+3:
+#if cond_lock == 0
+ movl %ebx, %eax
+#else
+ leal cond_lock(%ebx), %eax
+#endif
+#if (LLL_SHARED-LLL_PRIVATE) > 255
+ xorl %ecx, %ecx
+#endif
+ cmpl $-1, dep_mutex(%ebx)
+ setne %cl
+ subl $1, %ecx
+ andl $(LLL_SHARED-LLL_PRIVATE), %ecx
+#if LLL_PRIVATE != 0
+ addl $LLL_PRIVATE, %ecx
+#endif
+ call __lll_unlock_wake
+ jmp 4b
+
+ /* Locking in loop failed. */
+5:
+#if cond_lock == 0
+ movl %ebx, %edx
+#else
+ leal cond_lock(%ebx), %edx
+#endif
+#if (LLL_SHARED-LLL_PRIVATE) > 255
+ xorl %ecx, %ecx
+#endif
+ cmpl $-1, dep_mutex(%ebx)
+ setne %cl
+ subl $1, %ecx
+ andl $(LLL_SHARED-LLL_PRIVATE), %ecx
+#if LLL_PRIVATE != 0
+ addl $LLL_PRIVATE, %ecx
+#endif
+ call __lll_lock_wait
+ jmp 6b
+
+ /* Unlock after loop requires wakeup. */
+10:
+#if cond_lock == 0
+ movl %ebx, %eax
+#else
+ leal cond_lock(%ebx), %eax
+#endif
+#if (LLL_SHARED-LLL_PRIVATE) > 255
+ xorl %ecx, %ecx
+#endif
+ cmpl $-1, dep_mutex(%ebx)
+ setne %cl
+ subl $1, %ecx
+ andl $(LLL_SHARED-LLL_PRIVATE), %ecx
+#if LLL_PRIVATE != 0
+ addl $LLL_PRIVATE, %ecx
+#endif
+ call __lll_unlock_wake
+ jmp 11b
+
+#if defined __NR_clock_gettime && !defined __ASSUME_POSIX_TIMERS
+ /* clock_gettime not available. */
+19: leal 4(%esp), %ebx
+ xorl %ecx, %ecx
+ movl $__NR_gettimeofday, %eax
+ ENTER_KERNEL
+ movl %edx, %ebx
+
+ /* Compute relative timeout. */
+ movl 8(%esp), %eax
+ movl $1000, %edx
+ mul %edx /* Milli seconds to nano seconds. */
+ movl (%ebp), %ecx
+ movl 4(%ebp), %edx
+ subl 4(%esp), %ecx
+ subl %eax, %edx
+ jns 20f
+ addl $1000000000, %edx
+ subl $1, %ecx
+20: testl %ecx, %ecx
+ movl $-ETIMEDOUT, %esi
+ js 6b
+ jmp 21b
+#endif
+ .size __pthread_cond_timedwait, .-__pthread_cond_timedwait
+weak_alias(__pthread_cond_timedwait, pthread_cond_timedwait)
+
+
+ .type __condvar_tw_cleanup2, @function
+__condvar_tw_cleanup2:
+ subl $cond_futex, %ebx
+ .size __condvar_tw_cleanup2, .-__condvar_tw_cleanup2
+ .type __condvar_tw_cleanup, @function
+__condvar_tw_cleanup:
+ movl %eax, %esi
+
+ /* Get internal lock. */
+ movl $1, %edx
+ xorl %eax, %eax
+ LOCK
+#if cond_lock == 0
+ cmpxchgl %edx, (%ebx)
+#else
+ cmpxchgl %edx, cond_lock(%ebx)
+#endif
+ jz 1f
+
+#if cond_lock == 0
+ movl %ebx, %edx
+#else
+ leal cond_lock(%ebx), %edx
+#endif
+#if (LLL_SHARED-LLL_PRIVATE) > 255
+ xorl %ecx, %ecx
+#endif
+ cmpl $-1, dep_mutex(%ebx)
+ setne %cl
+ subl $1, %ecx
+ andl $(LLL_SHARED-LLL_PRIVATE), %ecx
+#if LLL_PRIVATE != 0
+ addl $LLL_PRIVATE, %ecx
+#endif
+ call __lll_lock_wait
+
+1: movl broadcast_seq(%ebx), %eax
+ cmpl 20(%esp), %eax
+ jne 3f
+
+ /* We increment the wakeup_seq counter only if it is lower than
+ total_seq. If this is not the case the thread was woken and
+ then canceled. In this case we ignore the signal. */
+ movl total_seq(%ebx), %eax
+ movl total_seq+4(%ebx), %edi
+ cmpl wakeup_seq+4(%ebx), %edi
+ jb 6f
+ ja 7f
+ cmpl wakeup_seq(%ebx), %eax
+ jbe 7f
+
+6: addl $1, wakeup_seq(%ebx)
+ adcl $0, wakeup_seq+4(%ebx)
+ addl $1, cond_futex(%ebx)
+
+7: addl $1, woken_seq(%ebx)
+ adcl $0, woken_seq+4(%ebx)
+
+3: subl $(1 << nwaiters_shift), cond_nwaiters(%ebx)
+
+ /* Wake up a thread which wants to destroy the condvar object. */
+ xorl %edi, %edi
+ movl total_seq(%ebx), %eax
+ andl total_seq+4(%ebx), %eax
+ cmpl $0xffffffff, %eax
+ jne 4f
+ movl cond_nwaiters(%ebx), %eax
+ andl $~((1 << nwaiters_shift) - 1), %eax
+ jne 4f
+
+ addl $cond_nwaiters, %ebx
+ movl $SYS_futex, %eax
+#if FUTEX_PRIVATE_FLAG > 255
+ xorl %ecx, %ecx
+#endif
+ cmpl $-1, dep_mutex-cond_nwaiters(%ebx)
+ sete %cl
+ subl $1, %ecx
+#ifdef __ASSUME_PRIVATE_FUTEX
+ andl $FUTEX_PRIVATE_FLAG, %ecx
+#else
+ andl %gs:PRIVATE_FUTEX, %ecx
+#endif
+ addl $FUTEX_WAKE, %ecx
+ movl $1, %edx
+ ENTER_KERNEL
+ subl $cond_nwaiters, %ebx
+ movl $1, %edi
+
+4: LOCK
+#if cond_lock == 0
+ subl $1, (%ebx)
+#else
+ subl $1, cond_lock(%ebx)
+#endif
+ je 2f
+
+#if cond_lock == 0
+ movl %ebx, %eax
+#else
+ leal cond_lock(%ebx), %eax
+#endif
+#if (LLL_SHARED-LLL_PRIVATE) > 255
+ xorl %ecx, %ecx
+#endif
+ cmpl $-1, dep_mutex(%ebx)
+ setne %cl
+ subl $1, %ecx
+ andl $(LLL_SHARED-LLL_PRIVATE), %ecx
+#if LLL_PRIVATE != 0
+ addl $LLL_PRIVATE, %ecx
+#endif
+ call __lll_unlock_wake
+
+ /* Wake up all waiters to make sure no signal gets lost. */
+2: testl %edi, %edi
+ jnz 5f
+ addl $cond_futex, %ebx
+#if FUTEX_PRIVATE_FLAG > 255
+ xorl %ecx, %ecx
+#endif
+ cmpl $-1, dep_mutex-cond_futex(%ebx)
+ sete %cl
+ subl $1, %ecx
+#ifdef __ASSUME_PRIVATE_FUTEX
+ andl $FUTEX_PRIVATE_FLAG, %ecx
+#else
+ andl %gs:PRIVATE_FUTEX, %ecx
+#endif
+ addl $FUTEX_WAKE, %ecx
+ movl $SYS_futex, %eax
+ movl $0x7fffffff, %edx
+ ENTER_KERNEL
+
+5: movl 24+FRAME_SIZE(%esp), %eax
+ call __pthread_mutex_cond_lock
+
+ movl %esi, (%esp)
+.LcallUR:
+#ifdef __PIC__
+ call __i686.get_pc_thunk.bx
+ addl $_GLOBAL_OFFSET_TABLE_, %ebx
+#endif
+ call _Unwind_Resume@PLT
+ hlt
+.LENDCODE:
+ cfi_endproc
+ .size __condvar_tw_cleanup, .-__condvar_tw_cleanup
+
+
+ .section .gcc_except_table,"a",@progbits
+.LexceptSTART:
+ .byte DW_EH_PE_omit # @LPStart format (omit)
+ .byte DW_EH_PE_omit # @TType format (omit)
+ .byte DW_EH_PE_sdata4 # call-site format
+ # DW_EH_PE_sdata4
+ .uleb128 .Lcstend-.Lcstbegin
+.Lcstbegin:
+ .long .LcleanupSTART-.LSTARTCODE
+ .long .Ladd_cond_futex-.LcleanupSTART
+ .long __condvar_tw_cleanup-.LSTARTCODE
+ .uleb128 0
+ .long .Ladd_cond_futex-.LSTARTCODE
+ .long .Lsub_cond_futex-.Ladd_cond_futex
+ .long __condvar_tw_cleanup2-.LSTARTCODE
+ .uleb128 0
+ .long .Lsub_cond_futex-.LSTARTCODE
+ .long .LcleanupEND-.Lsub_cond_futex
+ .long __condvar_tw_cleanup-.LSTARTCODE
+ .uleb128 0
+ .long .LcallUR-.LSTARTCODE
+ .long .LENDCODE-.LcallUR
+ .long 0
+ .uleb128 0
+.Lcstend:
+
+
+#ifdef SHARED
+ .hidden DW.ref.__gcc_personality_v0
+ .weak DW.ref.__gcc_personality_v0
+ .section .gnu.linkonce.d.DW.ref.__gcc_personality_v0,"aw",@progbits
+ .align 4
+ .type DW.ref.__gcc_personality_v0, @object
+ .size DW.ref.__gcc_personality_v0, 4
+DW.ref.__gcc_personality_v0:
+ .long __gcc_personality_v0
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S
new file mode 100644
index 000000000..90f19800d
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S
@@ -0,0 +1,594 @@
+/* Copyright (C) 2002-2004,2006-2007,2009,2010 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <lowlevellock.h>
+#include <lowlevelcond.h>
+#include <tcb-offsets.h>
+#include <pthread-errnos.h>
+#include <pthread-pi-defines.h>
+#include <bits/kernel-features.h>
+
+
+ .text
+
+/* int pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex) */
+ .globl __pthread_cond_wait
+ .type __pthread_cond_wait, @function
+ .protected __pthread_cond_wait
+ .align 16
+__pthread_cond_wait:
+.LSTARTCODE:
+ cfi_startproc
+#ifdef SHARED
+ cfi_personality(DW_EH_PE_pcrel | DW_EH_PE_sdata4 | DW_EH_PE_indirect,
+ DW.ref.__gcc_personality_v0)
+ cfi_lsda(DW_EH_PE_pcrel | DW_EH_PE_sdata4, .LexceptSTART)
+#else
+ cfi_personality(DW_EH_PE_udata4, __gcc_personality_v0)
+ cfi_lsda(DW_EH_PE_udata4, .LexceptSTART)
+#endif
+
+ pushl %ebp
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset(%ebp, 0)
+ pushl %edi
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset(%edi, 0)
+ pushl %esi
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset(%esi, 0)
+ pushl %ebx
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset(%ebx, 0)
+
+ xorl %esi, %esi
+ movl 20(%esp), %ebx
+
+ /* Get internal lock. */
+ movl $1, %edx
+ xorl %eax, %eax
+ LOCK
+#if cond_lock == 0
+ cmpxchgl %edx, (%ebx)
+#else
+ cmpxchgl %edx, cond_lock(%ebx)
+#endif
+ jnz 1f
+
+ /* Store the reference to the mutex. If there is already a
+ different value in there this is a bad user bug. */
+2: cmpl $-1, dep_mutex(%ebx)
+ movl 24(%esp), %eax
+ je 15f
+ movl %eax, dep_mutex(%ebx)
+
+ /* Unlock the mutex. */
+15: xorl %edx, %edx
+ call __pthread_mutex_unlock_usercnt
+
+ testl %eax, %eax
+ jne 12f
+
+ addl $1, total_seq(%ebx)
+ adcl $0, total_seq+4(%ebx)
+ addl $1, cond_futex(%ebx)
+ addl $(1 << nwaiters_shift), cond_nwaiters(%ebx)
+
+#define FRAME_SIZE 20
+ subl $FRAME_SIZE, %esp
+ cfi_adjust_cfa_offset(FRAME_SIZE)
+ cfi_remember_state
+
+ /* Get and store current wakeup_seq value. */
+ movl wakeup_seq(%ebx), %edi
+ movl wakeup_seq+4(%ebx), %edx
+ movl broadcast_seq(%ebx), %eax
+ movl %edi, 4(%esp)
+ movl %edx, 8(%esp)
+ movl %eax, 12(%esp)
+
+ /* Reset the pi-requeued flag. */
+8: movl $0, 16(%esp)
+ movl cond_futex(%ebx), %ebp
+
+ /* Unlock. */
+ LOCK
+#if cond_lock == 0
+ subl $1, (%ebx)
+#else
+ subl $1, cond_lock(%ebx)
+#endif
+ jne 3f
+
+.LcleanupSTART:
+4: call __pthread_enable_asynccancel
+ movl %eax, (%esp)
+
+ xorl %ecx, %ecx
+ cmpl $-1, dep_mutex(%ebx)
+ sete %cl
+ je 18f
+
+ movl dep_mutex(%ebx), %edi
+ /* Requeue to a non-robust PI mutex if the PI bit is set and
+ the robust bit is not set. */
+ movl MUTEX_KIND(%edi), %eax
+ andl $(ROBUST_BIT|PI_BIT), %eax
+ cmpl $PI_BIT, %eax
+ jne 18f
+
+ movl $(FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG), %ecx
+ movl %ebp, %edx
+ xorl %esi, %esi
+ addl $cond_futex, %ebx
+ movl $SYS_futex, %eax
+ ENTER_KERNEL
+ subl $cond_futex, %ebx
+ /* Set the pi-requeued flag only if the kernel has returned 0. The
+ kernel does not hold the mutex on error. */
+ cmpl $0, %eax
+ sete 16(%esp)
+ je 19f
+
+ /* Normal and PI futexes dont mix. Use normal futex functions only
+ if the kernel does not support the PI futex functions. */
+ cmpl $-ENOSYS, %eax
+ jne 19f
+ xorl %ecx, %ecx
+
+18: subl $1, %ecx
+#ifdef __ASSUME_PRIVATE_FUTEX
+ andl $FUTEX_PRIVATE_FLAG, %ecx
+#else
+ andl %gs:PRIVATE_FUTEX, %ecx
+#endif
+#if FUTEX_WAIT != 0
+ addl $FUTEX_WAIT, %ecx
+#endif
+ movl %ebp, %edx
+ addl $cond_futex, %ebx
+.Ladd_cond_futex:
+ movl $SYS_futex, %eax
+ ENTER_KERNEL
+ subl $cond_futex, %ebx
+.Lsub_cond_futex:
+
+19: movl (%esp), %eax
+ call __pthread_disable_asynccancel
+.LcleanupEND:
+
+ /* Lock. */
+ movl $1, %edx
+ xorl %eax, %eax
+ LOCK
+#if cond_lock == 0
+ cmpxchgl %edx, (%ebx)
+#else
+ cmpxchgl %edx, cond_lock(%ebx)
+#endif
+ jnz 5f
+
+6: movl broadcast_seq(%ebx), %eax
+ cmpl 12(%esp), %eax
+ jne 16f
+
+ movl woken_seq(%ebx), %eax
+ movl woken_seq+4(%ebx), %ecx
+
+ movl wakeup_seq(%ebx), %edi
+ movl wakeup_seq+4(%ebx), %edx
+
+ cmpl 8(%esp), %edx
+ jne 7f
+ cmpl 4(%esp), %edi
+ je 8b
+
+7: cmpl %ecx, %edx
+ jne 9f
+ cmp %eax, %edi
+ je 8b
+
+9: addl $1, woken_seq(%ebx)
+ adcl $0, woken_seq+4(%ebx)
+
+ /* Unlock */
+16: subl $(1 << nwaiters_shift), cond_nwaiters(%ebx)
+
+ /* Wake up a thread which wants to destroy the condvar object. */
+ movl total_seq(%ebx), %eax
+ andl total_seq+4(%ebx), %eax
+ cmpl $0xffffffff, %eax
+ jne 17f
+ movl cond_nwaiters(%ebx), %eax
+ andl $~((1 << nwaiters_shift) - 1), %eax
+ jne 17f
+
+ addl $cond_nwaiters, %ebx
+ movl $SYS_futex, %eax
+#if FUTEX_PRIVATE_FLAG > 255
+ xorl %ecx, %ecx
+#endif
+ cmpl $-1, dep_mutex-cond_nwaiters(%ebx)
+ sete %cl
+ subl $1, %ecx
+#ifdef __ASSUME_PRIVATE_FUTEX
+ andl $FUTEX_PRIVATE_FLAG, %ecx
+#else
+ andl %gs:PRIVATE_FUTEX, %ecx
+#endif
+ addl $FUTEX_WAKE, %ecx
+ movl $1, %edx
+ ENTER_KERNEL
+ subl $cond_nwaiters, %ebx
+
+17: LOCK
+#if cond_lock == 0
+ subl $1, (%ebx)
+#else
+ subl $1, cond_lock(%ebx)
+#endif
+ jne 10f
+
+ /* With requeue_pi, the mutex lock is held in the kernel. */
+11: movl 24+FRAME_SIZE(%esp), %eax
+ movl 16(%esp), %ecx
+ testl %ecx, %ecx
+ jnz 21f
+
+ call __pthread_mutex_cond_lock
+20: addl $FRAME_SIZE, %esp
+ cfi_adjust_cfa_offset(-FRAME_SIZE);
+
+14: popl %ebx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebx)
+ popl %esi
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%esi)
+ popl %edi
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%edi)
+ popl %ebp
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebp)
+
+ /* We return the result of the mutex_lock operation. */
+ ret
+
+ cfi_restore_state
+
+21: call __pthread_mutex_cond_lock_adjust
+ xorl %eax, %eax
+ jmp 20b
+
+ cfi_adjust_cfa_offset(-FRAME_SIZE);
+ /* Initial locking failed. */
+1:
+#if cond_lock == 0
+ movl %ebx, %edx
+#else
+ leal cond_lock(%ebx), %edx
+#endif
+#if (LLL_SHARED-LLL_PRIVATE) > 255
+ xorl %ecx, %ecx
+#endif
+ cmpl $-1, dep_mutex(%ebx)
+ setne %cl
+ subl $1, %ecx
+ andl $(LLL_SHARED-LLL_PRIVATE), %ecx
+#if LLL_PRIVATE != 0
+ addl $LLL_PRIVATE, %ecx
+#endif
+ call __lll_lock_wait
+ jmp 2b
+
+ /* The initial unlocking of the mutex failed. */
+12:
+ LOCK
+#if cond_lock == 0
+ subl $1, (%ebx)
+#else
+ subl $1, cond_lock(%ebx)
+#endif
+ jne 14b
+
+ movl %eax, %esi
+#if cond_lock == 0
+ movl %ebx, %eax
+#else
+ leal cond_lock(%ebx), %eax
+#endif
+#if (LLL_SHARED-LLL_PRIVATE) > 255
+ xorl %ecx, %ecx
+#endif
+ cmpl $-1, dep_mutex(%ebx)
+ setne %cl
+ subl $1, %ecx
+ andl $(LLL_SHARED-LLL_PRIVATE), %ecx
+#if LLL_PRIVATE != 0
+ addl $LLL_PRIVATE, %ecx
+#endif
+ call __lll_unlock_wake
+
+ movl %esi, %eax
+ jmp 14b
+
+ cfi_adjust_cfa_offset(FRAME_SIZE)
+
+ /* Unlock in loop requires wakeup. */
+3:
+#if cond_lock == 0
+ movl %ebx, %eax
+#else
+ leal cond_lock(%ebx), %eax
+#endif
+#if (LLL_SHARED-LLL_PRIVATE) > 255
+ xorl %ecx, %ecx
+#endif
+ cmpl $-1, dep_mutex(%ebx)
+ setne %cl
+ subl $1, %ecx
+ andl $(LLL_SHARED-LLL_PRIVATE), %ecx
+#if LLL_PRIVATE != 0
+ addl $LLL_PRIVATE, %ecx
+#endif
+ call __lll_unlock_wake
+ jmp 4b
+
+ /* Locking in loop failed. */
+5:
+#if cond_lock == 0
+ movl %ebx, %edx
+#else
+ leal cond_lock(%ebx), %edx
+#endif
+#if (LLL_SHARED-LLL_PRIVATE) > 255
+ xorl %ecx, %ecx
+#endif
+ cmpl $-1, dep_mutex(%ebx)
+ setne %cl
+ subl $1, %ecx
+ andl $(LLL_SHARED-LLL_PRIVATE), %ecx
+#if LLL_PRIVATE != 0
+ addl $LLL_PRIVATE, %ecx
+#endif
+ call __lll_lock_wait
+ jmp 6b
+
+ /* Unlock after loop requires wakeup. */
+10:
+#if cond_lock == 0
+ movl %ebx, %eax
+#else
+ leal cond_lock(%ebx), %eax
+#endif
+#if (LLL_SHARED-LLL_PRIVATE) > 255
+ xorl %ecx, %ecx
+#endif
+ cmpl $-1, dep_mutex(%ebx)
+ setne %cl
+ subl $1, %ecx
+ andl $(LLL_SHARED-LLL_PRIVATE), %ecx
+#if LLL_PRIVATE != 0
+ addl $LLL_PRIVATE, %ecx
+#endif
+ call __lll_unlock_wake
+ jmp 11b
+ .size __pthread_cond_wait, .-__pthread_cond_wait
+weak_alias(__pthread_cond_wait, pthread_cond_wait)
+
+
+ .type __condvar_w_cleanup2, @function
+__condvar_w_cleanup2:
+ subl $cond_futex, %ebx
+ .size __condvar_w_cleanup2, .-__condvar_w_cleanup2
+.LSbl4:
+ .type __condvar_w_cleanup, @function
+__condvar_w_cleanup:
+ movl %eax, %esi
+
+ /* Get internal lock. */
+ movl $1, %edx
+ xorl %eax, %eax
+ LOCK
+#if cond_lock == 0
+ cmpxchgl %edx, (%ebx)
+#else
+ cmpxchgl %edx, cond_lock(%ebx)
+#endif
+ jz 1f
+
+#if cond_lock == 0
+ movl %ebx, %edx
+#else
+ leal cond_lock(%ebx), %edx
+#endif
+#if (LLL_SHARED-LLL_PRIVATE) > 255
+ xorl %ecx, %ecx
+#endif
+ cmpl $-1, dep_mutex(%ebx)
+ setne %cl
+ subl $1, %ecx
+ andl $(LLL_SHARED-LLL_PRIVATE), %ecx
+#if LLL_PRIVATE != 0
+ addl $LLL_PRIVATE, %ecx
+#endif
+ call __lll_lock_wait
+
+1: movl broadcast_seq(%ebx), %eax
+ cmpl 12(%esp), %eax
+ jne 3f
+
+ /* We increment the wakeup_seq counter only if it is lower than
+ total_seq. If this is not the case the thread was woken and
+ then canceled. In this case we ignore the signal. */
+ movl total_seq(%ebx), %eax
+ movl total_seq+4(%ebx), %edi
+ cmpl wakeup_seq+4(%ebx), %edi
+ jb 6f
+ ja 7f
+ cmpl wakeup_seq(%ebx), %eax
+ jbe 7f
+
+6: addl $1, wakeup_seq(%ebx)
+ adcl $0, wakeup_seq+4(%ebx)
+ addl $1, cond_futex(%ebx)
+
+7: addl $1, woken_seq(%ebx)
+ adcl $0, woken_seq+4(%ebx)
+
+3: subl $(1 << nwaiters_shift), cond_nwaiters(%ebx)
+
+ /* Wake up a thread which wants to destroy the condvar object. */
+ xorl %edi, %edi
+ movl total_seq(%ebx), %eax
+ andl total_seq+4(%ebx), %eax
+ cmpl $0xffffffff, %eax
+ jne 4f
+ movl cond_nwaiters(%ebx), %eax
+ andl $~((1 << nwaiters_shift) - 1), %eax
+ jne 4f
+
+ addl $cond_nwaiters, %ebx
+ movl $SYS_futex, %eax
+#if FUTEX_PRIVATE_FLAG > 255
+ xorl %ecx, %ecx
+#endif
+ cmpl $-1, dep_mutex-cond_nwaiters(%ebx)
+ sete %cl
+ subl $1, %ecx
+#ifdef __ASSUME_PRIVATE_FUTEX
+ andl $FUTEX_PRIVATE_FLAG, %ecx
+#else
+ andl %gs:PRIVATE_FUTEX, %ecx
+#endif
+ addl $FUTEX_WAKE, %ecx
+ movl $1, %edx
+ ENTER_KERNEL
+ subl $cond_nwaiters, %ebx
+ movl $1, %edi
+
+4: LOCK
+#if cond_lock == 0
+ subl $1, (%ebx)
+#else
+ subl $1, cond_lock(%ebx)
+#endif
+ je 2f
+
+#if cond_lock == 0
+ movl %ebx, %eax
+#else
+ leal cond_lock(%ebx), %eax
+#endif
+#if (LLL_SHARED-LLL_PRIVATE) > 255
+ xorl %ecx, %ecx
+#endif
+ cmpl $-1, dep_mutex(%ebx)
+ setne %cl
+ subl $1, %ecx
+ andl $(LLL_SHARED-LLL_PRIVATE), %ecx
+#if LLL_PRIVATE != 0
+ addl $LLL_PRIVATE, %ecx
+#endif
+ call __lll_unlock_wake
+
+ /* Wake up all waiters to make sure no signal gets lost. */
+2: testl %edi, %edi
+ jnz 5f
+ addl $cond_futex, %ebx
+#if FUTEX_PRIVATE_FLAG > 255
+ xorl %ecx, %ecx
+#endif
+ cmpl $-1, dep_mutex-cond_futex(%ebx)
+ sete %cl
+ subl $1, %ecx
+#ifdef __ASSUME_PRIVATE_FUTEX
+ andl $FUTEX_PRIVATE_FLAG, %ecx
+#else
+ andl %gs:PRIVATE_FUTEX, %ecx
+#endif
+ addl $FUTEX_WAKE, %ecx
+ movl $SYS_futex, %eax
+ movl $0x7fffffff, %edx
+ ENTER_KERNEL
+
+5: movl 24+FRAME_SIZE(%esp), %eax
+ call __pthread_mutex_cond_lock
+
+ movl %esi, (%esp)
+.LcallUR:
+#ifdef __PIC__
+ call __i686.get_pc_thunk.bx
+ addl $_GLOBAL_OFFSET_TABLE_, %ebx
+#endif
+ call _Unwind_Resume@PLT
+ hlt
+.LENDCODE:
+ cfi_endproc
+ .size __condvar_w_cleanup, .-__condvar_w_cleanup
+
+
+ .section .gcc_except_table,"a",@progbits
+.LexceptSTART:
+ .byte DW_EH_PE_omit # @LPStart format (omit)
+ .byte DW_EH_PE_omit # @TType format (omit)
+ .byte DW_EH_PE_sdata4 # call-site format
+ # DW_EH_PE_sdata4
+ .uleb128 .Lcstend-.Lcstbegin
+.Lcstbegin:
+ .long .LcleanupSTART-.LSTARTCODE
+ .long .Ladd_cond_futex-.LcleanupSTART
+ .long __condvar_w_cleanup-.LSTARTCODE
+ .uleb128 0
+ .long .Ladd_cond_futex-.LSTARTCODE
+ .long .Lsub_cond_futex-.Ladd_cond_futex
+ .long __condvar_w_cleanup2-.LSTARTCODE
+ .uleb128 0
+ .long .Lsub_cond_futex-.LSTARTCODE
+ .long .LcleanupEND-.Lsub_cond_futex
+ .long __condvar_w_cleanup-.LSTARTCODE
+ .uleb128 0
+ .long .LcallUR-.LSTARTCODE
+ .long .LENDCODE-.LcallUR
+ .long 0
+ .uleb128 0
+.Lcstend:
+
+#ifdef __PIC__
+ .section .gnu.linkonce.t.__i686.get_pc_thunk.bx,"ax",@progbits
+ .globl __i686.get_pc_thunk.bx
+ .hidden __i686.get_pc_thunk.bx
+ .type __i686.get_pc_thunk.bx,@function
+__i686.get_pc_thunk.bx:
+ movl (%esp), %ebx;
+ ret
+ .size __i686.get_pc_thunk.bx,.-__i686.get_pc_thunk.bx
+#endif
+
+#ifdef SHARED
+ .hidden DW.ref.__gcc_personality_v0
+ .weak DW.ref.__gcc_personality_v0
+ .section .gnu.linkonce.d.DW.ref.__gcc_personality_v0,"aw",@progbits
+ .align 4
+ .type DW.ref.__gcc_personality_v0, @object
+ .size DW.ref.__gcc_personality_v0, 4
+DW.ref.__gcc_personality_v0:
+ .long __gcc_personality_v0
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S
new file mode 100644
index 000000000..23efa55da
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S
@@ -0,0 +1,194 @@
+/* Copyright (C) 2002, 2003, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <lowlevellock.h>
+#include <lowlevelrwlock.h>
+#include <pthread-errnos.h>
+#include <bits/kernel-features.h>
+#include <tls.h>
+
+
+ .text
+
+ .globl __pthread_rwlock_rdlock
+ .type __pthread_rwlock_rdlock,@function
+ .protected __pthread_rwlock_rdlock
+ .align 16
+__pthread_rwlock_rdlock:
+ cfi_startproc
+ pushl %esi
+ cfi_adjust_cfa_offset(4)
+ pushl %ebx
+ cfi_adjust_cfa_offset(4)
+ cfi_offset(%esi, -8)
+ cfi_offset(%ebx, -12)
+
+ xorl %esi, %esi
+ movl 12(%esp), %ebx
+
+ /* Get the lock. */
+ movl $1, %edx
+ xorl %eax, %eax
+ LOCK
+#if MUTEX == 0
+ cmpxchgl %edx, (%ebx)
+#else
+ cmpxchgl %edx, MUTEX(%ebx)
+#endif
+ jnz 1f
+
+2: movl WRITER(%ebx), %eax
+ testl %eax, %eax
+ jne 14f
+ cmpl $0, WRITERS_QUEUED(%ebx)
+ je 5f
+ cmpb $0, FLAGS(%ebx)
+ je 5f
+
+3: addl $1, READERS_QUEUED(%ebx)
+ je 4f
+
+ movl READERS_WAKEUP(%ebx), %edx
+
+ LOCK
+#if MUTEX == 0
+ subl $1, (%ebx)
+#else
+ subl $1, MUTEX(%ebx)
+#endif
+ jne 10f
+
+11:
+#ifdef __ASSUME_PRIVATE_FUTEX
+ movzbl PSHARED(%ebx), %ecx
+ xorl $FUTEX_PRIVATE_FLAG|FUTEX_WAIT, %ecx
+#else
+ movzbl PSHARED(%ebx), %ecx
+# if FUTEX_WAIT != 0
+ orl $FUTEX_WAIT, %ecx
+# endif
+ xorl %gs:PRIVATE_FUTEX, %ecx
+#endif
+ addl $READERS_WAKEUP, %ebx
+ movl $SYS_futex, %eax
+ ENTER_KERNEL
+
+ subl $READERS_WAKEUP, %ebx
+
+ /* Reget the lock. */
+ movl $1, %edx
+ xorl %eax, %eax
+ LOCK
+#if MUTEX == 0
+ cmpxchgl %edx, (%ebx)
+#else
+ cmpxchgl %edx, MUTEX(%ebx)
+#endif
+ jnz 12f
+
+13: subl $1, READERS_QUEUED(%ebx)
+ jmp 2b
+
+5: xorl %edx, %edx
+ addl $1, NR_READERS(%ebx)
+ je 8f
+9: LOCK
+#if MUTEX == 0
+ subl $1, (%ebx)
+#else
+ subl $1, MUTEX(%ebx)
+#endif
+ jne 6f
+7:
+
+ movl %edx, %eax
+ popl %ebx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebx)
+ popl %esi
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%esi)
+ ret
+
+ cfi_adjust_cfa_offset(8)
+ cfi_offset(%esi, -8)
+ cfi_offset(%ebx, -12)
+1:
+#if MUTEX == 0
+ movl %ebx, %edx
+#else
+ leal MUTEX(%ebx), %edx
+#endif
+ movzbl PSHARED(%ebx), %ecx
+ call __lll_lock_wait
+ jmp 2b
+
+14: cmpl %gs:TID, %eax
+ jne 3b
+ /* Deadlock detected. */
+ movl $EDEADLK, %edx
+ jmp 9b
+
+6:
+#if MUTEX == 0
+ movl %ebx, %eax
+#else
+ leal MUTEX(%ebx), %eax
+#endif
+ movzbl PSHARED(%ebx), %ecx
+ call __lll_unlock_wake
+ jmp 7b
+
+ /* Overflow. */
+8: subl $1, NR_READERS(%ebx)
+ movl $EAGAIN, %edx
+ jmp 9b
+
+ /* Overflow. */
+4: subl $1, READERS_QUEUED(%ebx)
+ movl $EAGAIN, %edx
+ jmp 9b
+
+10:
+#if MUTEX == 0
+ movl %ebx, %eax
+#else
+ leal MUTEX(%ebx), %eax
+#endif
+ movzbl PSHARED(%ebx), %ecx
+ call __lll_unlock_wake
+ jmp 11b
+
+12:
+#if MUTEX == 0
+ movl %ebx, %edx
+#else
+ leal MUTEX(%ebx), %edx
+#endif
+ movzbl PSHARED(%ebx), %ecx
+ call __lll_lock_wait
+ jmp 13b
+ cfi_endproc
+ .size __pthread_rwlock_rdlock,.-__pthread_rwlock_rdlock
+
+ .globl pthread_rwlock_rdlock
+pthread_rwlock_rdlock = __pthread_rwlock_rdlock
+
+ .globl __pthread_rwlock_rdlock_internal
+__pthread_rwlock_rdlock_internal = __pthread_rwlock_rdlock
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S
new file mode 100644
index 000000000..89baa00ec
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S
@@ -0,0 +1,244 @@
+/* Copyright (C) 2002, 2003, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <lowlevellock.h>
+#include <lowlevelrwlock.h>
+#include <pthread-errnos.h>
+#include <bits/kernel-features.h>
+#include <tls.h>
+
+
+ .text
+
+ .globl pthread_rwlock_timedrdlock
+ .type pthread_rwlock_timedrdlock,@function
+ .align 16
+pthread_rwlock_timedrdlock:
+ cfi_startproc
+ pushl %esi
+ cfi_adjust_cfa_offset(4)
+ pushl %edi
+ cfi_adjust_cfa_offset(4)
+ pushl %ebx
+ cfi_adjust_cfa_offset(4)
+ pushl %ebp
+ cfi_adjust_cfa_offset(4)
+ cfi_offset(%esi, -8)
+ cfi_offset(%edi, -12)
+ cfi_offset(%ebx, -16)
+ cfi_offset(%ebp, -20)
+ subl $8, %esp
+ cfi_adjust_cfa_offset(8)
+
+ movl 28(%esp), %ebp
+ movl 32(%esp), %edi
+
+ /* Get the lock. */
+ movl $1, %edx
+ xorl %eax, %eax
+ LOCK
+#if MUTEX == 0
+ cmpxchgl %edx, (%ebp)
+#else
+ cmpxchgl %edx, MUTEX(%ebp)
+#endif
+ jnz 1f
+
+2: movl WRITER(%ebp), %eax
+ testl %eax, %eax
+ jne 14f
+ cmpl $0, WRITERS_QUEUED(%ebp)
+ je 5f
+ cmpb $0, FLAGS(%ebp)
+ je 5f
+
+ /* Check the value of the timeout parameter. */
+3: cmpl $1000000000, 4(%edi)
+ jae 19f
+
+ addl $1, READERS_QUEUED(%ebp)
+ je 4f
+
+ movl READERS_WAKEUP(%ebp), %esi
+
+ LOCK
+#if MUTEX == 0
+ subl $1, (%ebp)
+#else
+ subl $1, MUTEX(%ebp)
+#endif
+ jne 10f
+
+ /* Get current time. */
+11: movl %esp, %ebx
+ xorl %ecx, %ecx
+ movl $__NR_gettimeofday, %eax
+ ENTER_KERNEL
+
+ /* Compute relative timeout. */
+ movl 4(%esp), %eax
+ movl $1000, %edx
+ mul %edx /* Milli seconds to nano seconds. */
+ movl (%edi), %ecx
+ movl 4(%edi), %edx
+ subl (%esp), %ecx
+ subl %eax, %edx
+ jns 15f
+ addl $1000000000, %edx
+ subl $1, %ecx
+15: testl %ecx, %ecx
+ js 16f /* Time is already up. */
+
+ /* Futex call. */
+ movl %ecx, (%esp) /* Store relative timeout. */
+ movl %edx, 4(%esp)
+
+ movl %esi, %edx
+#ifdef __ASSUME_PRIVATE_FUTEX
+ movzbl PSHARED(%ebp), %ecx
+ xorl $FUTEX_PRIVATE_FLAG|FUTEX_WAIT, %ecx
+#else
+ movzbl PSHARED(%ebp), %ecx
+# if FUTEX_WAIT != 0
+ orl $FUTEX_WAIT, %ecx
+# endif
+ xorl %gs:PRIVATE_FUTEX, %ecx
+#endif
+ movl %esp, %esi
+ leal READERS_WAKEUP(%ebp), %ebx
+ movl $SYS_futex, %eax
+ ENTER_KERNEL
+ movl %eax, %esi
+17:
+
+ /* Reget the lock. */
+ movl $1, %edx
+ xorl %eax, %eax
+ LOCK
+#if MUTEX == 0
+ cmpxchgl %edx, (%ebp)
+#else
+ cmpxchgl %edx, MUTEX(%ebp)
+#endif
+ jnz 12f
+
+13: subl $1, READERS_QUEUED(%ebp)
+ cmpl $-ETIMEDOUT, %esi
+ jne 2b
+
+18: movl $ETIMEDOUT, %edx
+ jmp 9f
+
+
+5: xorl %edx, %edx
+ addl $1, NR_READERS(%ebp)
+ je 8f
+9: LOCK
+#if MUTEX == 0
+ subl $1, (%ebp)
+#else
+ subl $1, MUTEX(%ebp)
+#endif
+ jne 6f
+
+7: movl %edx, %eax
+
+ addl $8, %esp
+ cfi_adjust_cfa_offset(-8)
+ popl %ebp
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebp)
+ popl %ebx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebx)
+ popl %edi
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%edi)
+ popl %esi
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%esi)
+ ret
+
+ cfi_adjust_cfa_offset(24)
+ cfi_offset(%esi, -8)
+ cfi_offset(%edi, -12)
+ cfi_offset(%ebx, -16)
+ cfi_offset(%ebp, -20)
+1:
+#if MUTEX == 0
+ movl %ebp, %edx
+#else
+ leal MUTEX(%ebp), %edx
+#endif
+ movzbl PSHARED(%ebp), %ecx
+ call __lll_lock_wait
+ jmp 2b
+
+14: cmpl %gs:TID, %eax
+ jne 3b
+ movl $EDEADLK, %edx
+ jmp 9b
+
+6:
+#if MUTEX == 0
+ movl %ebp, %eax
+#else
+ leal MUTEX(%ebp), %eax
+#endif
+ movzbl PSHARED(%ebp), %ecx
+ call __lll_unlock_wake
+ jmp 7b
+
+ /* Overflow. */
+8: subl $1, NR_READERS(%ebp)
+ movl $EAGAIN, %edx
+ jmp 9b
+
+ /* Overflow. */
+4: subl $1, READERS_QUEUED(%ebp)
+ movl $EAGAIN, %edx
+ jmp 9b
+
+10:
+#if MUTEX == 0
+ movl %ebp, %eax
+#else
+ leal MUTEX(%ebp), %eax
+#endif
+ movzbl PSHARED(%ebp), %ecx
+ call __lll_unlock_wake
+ jmp 11b
+
+12:
+#if MUTEX == 0
+ movl %ebp, %edx
+#else
+ leal MUTEX(%ebp), %edx
+#endif
+ movzbl PSHARED(%ebp), %ecx
+ call __lll_lock_wait
+ jmp 13b
+
+16: movl $-ETIMEDOUT, %esi
+ jmp 17b
+
+19: movl $EINVAL, %edx
+ jmp 9b
+ cfi_endproc
+ .size pthread_rwlock_timedrdlock,.-pthread_rwlock_timedrdlock
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S
new file mode 100644
index 000000000..146a8a881
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S
@@ -0,0 +1,237 @@
+/* Copyright (C) 2002, 2003, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <lowlevellock.h>
+#include <lowlevelrwlock.h>
+#include <pthread-errnos.h>
+#include <bits/kernel-features.h>
+#include <tls.h>
+
+
+ .text
+
+ .globl pthread_rwlock_timedwrlock
+ .type pthread_rwlock_timedwrlock,@function
+ .align 16
+pthread_rwlock_timedwrlock:
+ cfi_startproc
+ pushl %esi
+ cfi_adjust_cfa_offset(4)
+ pushl %edi
+ cfi_adjust_cfa_offset(4)
+ pushl %ebx
+ cfi_adjust_cfa_offset(4)
+ pushl %ebp
+ cfi_adjust_cfa_offset(4)
+ cfi_offset(%esi, -8)
+ cfi_offset(%edi, -12)
+ cfi_offset(%ebx, -16)
+ cfi_offset(%ebp, -20)
+ subl $8, %esp
+ cfi_adjust_cfa_offset(8)
+
+ movl 28(%esp), %ebp
+ movl 32(%esp), %edi
+
+ /* Get the lock. */
+ movl $1, %edx
+ xorl %eax, %eax
+ LOCK
+#if MUTEX == 0
+ cmpxchgl %edx, (%ebp)
+#else
+ cmpxchgl %edx, MUTEX(%ebp)
+#endif
+ jnz 1f
+
+2: movl WRITER(%ebp), %eax
+ testl %eax, %eax
+ jne 14f
+ cmpl $0, NR_READERS(%ebp)
+ je 5f
+
+ /* Check the value of the timeout parameter. */
+3: cmpl $1000000000, 4(%edi)
+ jae 19f
+
+ addl $1, WRITERS_QUEUED(%ebp)
+ je 4f
+
+ movl WRITERS_WAKEUP(%ebp), %esi
+
+ LOCK
+#if MUTEX == 0
+ subl $1, (%ebp)
+#else
+ subl $1, MUTEX(%ebp)
+#endif
+ jne 10f
+
+ /* Get current time. */
+11: movl %esp, %ebx
+ xorl %ecx, %ecx
+ movl $__NR_gettimeofday, %eax
+ ENTER_KERNEL
+
+ /* Compute relative timeout. */
+ movl 4(%esp), %eax
+ movl $1000, %edx
+ mul %edx /* Milli seconds to nano seconds. */
+ movl (%edi), %ecx
+ movl 4(%edi), %edx
+ subl (%esp), %ecx
+ subl %eax, %edx
+ jns 15f
+ addl $1000000000, %edx
+ subl $1, %ecx
+15: testl %ecx, %ecx
+ js 16f /* Time is already up. */
+
+ /* Futex call. */
+ movl %ecx, (%esp) /* Store relative timeout. */
+ movl %edx, 4(%esp)
+
+ movl %esi, %edx
+#ifdef __ASSUME_PRIVATE_FUTEX
+ movzbl PSHARED(%ebp), %ecx
+ xorl $FUTEX_PRIVATE_FLAG|FUTEX_WAIT, %ecx
+#else
+ movzbl PSHARED(%ebp), %ecx
+# if FUTEX_WAIT != 0
+ orl $FUTEX_WAIT, %ecx
+# endif
+ xorl %gs:PRIVATE_FUTEX, %ecx
+#endif
+ movl %esp, %esi
+ leal WRITERS_WAKEUP(%ebp), %ebx
+ movl $SYS_futex, %eax
+ ENTER_KERNEL
+ movl %eax, %esi
+17:
+
+ /* Reget the lock. */
+ movl $1, %edx
+ xorl %eax, %eax
+ LOCK
+#if MUTEX == 0
+ cmpxchgl %edx, (%ebp)
+#else
+ cmpxchgl %edx, MUTEX(%ebp)
+#endif
+ jnz 12f
+
+13: subl $1, WRITERS_QUEUED(%ebp)
+ cmpl $-ETIMEDOUT, %esi
+ jne 2b
+
+18: movl $ETIMEDOUT, %edx
+ jmp 9f
+
+
+5: xorl %edx, %edx
+ movl %gs:TID, %eax
+ movl %eax, WRITER(%ebp)
+9: LOCK
+#if MUTEX == 0
+ subl $1, (%ebp)
+#else
+ subl $1, MUTEX(%ebp)
+#endif
+ jne 6f
+
+7: movl %edx, %eax
+
+ addl $8, %esp
+ cfi_adjust_cfa_offset(-8)
+ popl %ebp
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebp)
+ popl %ebx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebx)
+ popl %edi
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%edi)
+ popl %esi
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%esi)
+ ret
+
+ cfi_adjust_cfa_offset(24)
+ cfi_offset(%esi, -8)
+ cfi_offset(%edi, -12)
+ cfi_offset(%ebx, -16)
+ cfi_offset(%ebp, -20)
+1:
+#if MUTEX == 0
+ movl %ebp, %edx
+#else
+ leal MUTEX(%ebp), %edx
+#endif
+ movzbl PSHARED(%ebp), %ecx
+ call __lll_lock_wait
+ jmp 2b
+
+14: cmpl %gs:TID, %eax
+ jne 3b
+20: movl $EDEADLK, %edx
+ jmp 9b
+
+6:
+#if MUTEX == 0
+ movl %ebp, %eax
+#else
+ leal MUTEX(%ebp), %eax
+#endif
+ movzbl PSHARED(%ebp), %ecx
+ call __lll_unlock_wake
+ jmp 7b
+
+ /* Overflow. */
+4: subl $1, WRITERS_QUEUED(%ebp)
+ movl $EAGAIN, %edx
+ jmp 9b
+
+10:
+#if MUTEX == 0
+ movl %ebp, %eax
+#else
+ leal MUTEX(%ebp), %eax
+#endif
+ movzbl PSHARED(%ebp), %ecx
+ call __lll_unlock_wake
+ jmp 11b
+
+12:
+#if MUTEX == 0
+ movl %ebp, %edx
+#else
+ leal MUTEX(%ebp), %edx
+#endif
+ movzbl PSHARED(%ebp), %ecx
+ call __lll_lock_wait
+ jmp 13b
+
+16: movl $-ETIMEDOUT, %esi
+ jmp 17b
+
+19: movl $EINVAL, %edx
+ jmp 9b
+ cfi_endproc
+ .size pthread_rwlock_timedwrlock,.-pthread_rwlock_timedwrlock
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_unlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_unlock.S
new file mode 100644
index 000000000..ec3314770
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_unlock.S
@@ -0,0 +1,156 @@
+/* Copyright (C) 2002, 2003, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <lowlevellock.h>
+#include <lowlevelrwlock.h>
+#include <bits/kernel-features.h>
+#include <tls.h>
+
+
+ .text
+
+ .globl __pthread_rwlock_unlock
+ .type __pthread_rwlock_unlock,@function
+ .protected __pthread_rwlock_unlock
+ .align 16
+__pthread_rwlock_unlock:
+ cfi_startproc
+ pushl %ebx
+ cfi_adjust_cfa_offset(4)
+ pushl %edi
+ cfi_adjust_cfa_offset(4)
+ cfi_offset(%ebx, -8)
+ cfi_offset(%edi, -12)
+
+ movl 12(%esp), %edi
+
+ /* Get the lock. */
+ movl $1, %edx
+ xorl %eax, %eax
+ LOCK
+#if MUTEX == 0
+ cmpxchgl %edx, (%edi)
+#else
+ cmpxchgl %edx, MUTEX(%edi)
+#endif
+ jnz 1f
+
+2: cmpl $0, WRITER(%edi)
+ jne 5f
+ subl $1, NR_READERS(%edi)
+ jnz 6f
+
+5: movl $0, WRITER(%edi)
+
+ movl $1, %edx
+ leal WRITERS_WAKEUP(%edi), %ebx
+ cmpl $0, WRITERS_QUEUED(%edi)
+ jne 0f
+
+ /* If also no readers waiting nothing to do. */
+ cmpl $0, READERS_QUEUED(%edi)
+ je 6f
+
+ movl $0x7fffffff, %edx
+ leal READERS_WAKEUP(%edi), %ebx
+
+0: addl $1, (%ebx)
+ LOCK
+#if MUTEX == 0
+ subl $1, (%edi)
+#else
+ subl $1, MUTEX(%edi)
+#endif
+ jne 7f
+
+8:
+#ifdef __ASSUME_PRIVATE_FUTEX
+ movzbl PSHARED(%edi), %ecx
+ xorl $FUTEX_PRIVATE_FLAG|FUTEX_WAKE, %ecx
+#else
+ movzbl PSHARED(%edi), %ecx
+ orl $FUTEX_WAKE, %ecx
+ xorl %gs:PRIVATE_FUTEX, %ecx
+#endif
+ movl $SYS_futex, %eax
+ ENTER_KERNEL
+
+ xorl %eax, %eax
+ popl %edi
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%edi)
+ popl %ebx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebx)
+ ret
+
+ cfi_adjust_cfa_offset(8)
+ cfi_offset(%ebx, -8)
+ cfi_offset(%edi, -12)
+ .align 16
+6: LOCK
+#if MUTEX == 0
+ subl $1, (%edi)
+#else
+ subl $1, MUTEX(%edi)
+#endif
+ jne 3f
+
+4: xorl %eax, %eax
+ popl %edi
+ popl %ebx
+ ret
+
+1:
+#if MUTEX == 0
+ movl %edi, %edx
+#else
+ leal MUTEX(%edi), %edx
+#endif
+ movzbl PSHARED(%edi), %ecx
+ call __lll_lock_wait
+ jmp 2b
+
+3:
+#if MUTEX == 0
+ movl %edi, %eax
+#else
+ leal MUTEX(%edi), %eax
+#endif
+ movzbl PSHARED(%edi), %ecx
+ call __lll_unlock_wake
+ jmp 4b
+
+7:
+#if MUTEX == 0
+ movl %edi, %eax
+#else
+ leal MUTEX(%edi), %eax
+#endif
+ movzbl PSHARED(%edi), %ecx
+ call __lll_unlock_wake
+ jmp 8b
+ cfi_endproc
+ .size __pthread_rwlock_unlock,.-__pthread_rwlock_unlock
+
+ .globl pthread_rwlock_unlock
+pthread_rwlock_unlock = __pthread_rwlock_unlock
+
+ .globl __pthread_rwlock_unlock_internal
+__pthread_rwlock_unlock_internal = __pthread_rwlock_unlock
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S
new file mode 100644
index 000000000..c0fc69119
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S
@@ -0,0 +1,185 @@
+/* Copyright (C) 2002, 2003, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <lowlevellock.h>
+#include <lowlevelrwlock.h>
+#include <pthread-errnos.h>
+#include <bits/kernel-features.h>
+#include <tls.h>
+
+
+ .text
+
+ .globl __pthread_rwlock_wrlock
+ .type __pthread_rwlock_wrlock,@function
+ .protected __pthread_rwlock_wrlock
+ .align 16
+__pthread_rwlock_wrlock:
+ cfi_startproc
+ pushl %esi
+ cfi_adjust_cfa_offset(4)
+ pushl %ebx
+ cfi_adjust_cfa_offset(4)
+ cfi_offset(%esi, -8)
+ cfi_offset(%ebx, -12)
+
+ xorl %esi, %esi
+ movl 12(%esp), %ebx
+
+ /* Get the lock. */
+ movl $1, %edx
+ xorl %eax, %eax
+ LOCK
+#if MUTEX == 0
+ cmpxchgl %edx, (%ebx)
+#else
+ cmpxchgl %edx, MUTEX(%ebx)
+#endif
+ jnz 1f
+
+2: movl WRITER(%ebx), %eax
+ testl %eax, %eax
+ jne 14f
+ cmpl $0, NR_READERS(%ebx)
+ je 5f
+
+3: addl $1, WRITERS_QUEUED(%ebx)
+ je 4f
+
+ movl WRITERS_WAKEUP(%ebx), %edx
+
+ LOCK
+#if MUTEX == 0
+ subl $1, (%ebx)
+#else
+ subl $1, MUTEX(%ebx)
+#endif
+ jne 10f
+
+11:
+#ifdef __ASSUME_PRIVATE_FUTEX
+ movzbl PSHARED(%ebx), %ecx
+ xorl $FUTEX_PRIVATE_FLAG|FUTEX_WAIT, %ecx
+#else
+ movzbl PSHARED(%ebx), %ecx
+# if FUTEX_WAIT != 0
+ orl $FUTEX_WAIT, %ecx
+# endif
+ xorl %gs:PRIVATE_FUTEX, %ecx
+#endif
+ addl $WRITERS_WAKEUP, %ebx
+ movl $SYS_futex, %eax
+ ENTER_KERNEL
+
+ subl $WRITERS_WAKEUP, %ebx
+
+ /* Reget the lock. */
+ movl $1, %edx
+ xorl %eax, %eax
+ LOCK
+#if MUTEX == 0
+ cmpxchgl %edx, (%ebx)
+#else
+ cmpxchgl %edx, MUTEX(%ebx)
+#endif
+ jnz 12f
+
+13: subl $1, WRITERS_QUEUED(%ebx)
+ jmp 2b
+
+5: xorl %edx, %edx
+ movl %gs:TID, %eax
+ movl %eax, WRITER(%ebx)
+9: LOCK
+#if MUTEX == 0
+ subl $1, (%ebx)
+#else
+ subl $1, MUTEX(%ebx)
+#endif
+ jne 6f
+7:
+
+ movl %edx, %eax
+ popl %ebx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebx)
+ popl %esi
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%esi)
+ ret
+
+ cfi_adjust_cfa_offset(8)
+ cfi_offset(%esi, -8)
+ cfi_offset(%ebx, -12)
+1:
+#if MUTEX == 0
+ movl %ebx, %edx
+#else
+ leal MUTEX(%ebx), %edx
+#endif
+ movzbl PSHARED(%ebx), %ecx
+ call __lll_lock_wait
+ jmp 2b
+
+14: cmpl %gs:TID , %eax
+ jne 3b
+ movl $EDEADLK, %edx
+ jmp 9b
+
+6:
+#if MUTEX == 0
+ movl %ebx, %eax
+#else
+ leal MUTEX(%ebx), %eax
+#endif
+ movzbl PSHARED(%ebx), %ecx
+ call __lll_unlock_wake
+ jmp 7b
+
+4: subl $1, WRITERS_QUEUED(%ebx)
+ movl $EAGAIN, %edx
+ jmp 9b
+
+10:
+#if MUTEX == 0
+ movl %ebx, %eax
+#else
+ leal MUTEX(%ebx), %eax
+#endif
+ movzbl PSHARED(%ebx), %ecx
+ call __lll_unlock_wake
+ jmp 11b
+
+12:
+#if MUTEX == 0
+ movl %ebx, %edx
+#else
+ leal MUTEX(%ebx), %edx
+#endif
+ movzbl PSHARED(%ebx), %ecx
+ call __lll_lock_wait
+ jmp 13b
+ cfi_endproc
+ .size __pthread_rwlock_wrlock,.-__pthread_rwlock_wrlock
+
+ .globl pthread_rwlock_wrlock
+pthread_rwlock_wrlock = __pthread_rwlock_wrlock
+
+ .globl __pthread_rwlock_wrlock_internal
+__pthread_rwlock_wrlock_internal = __pthread_rwlock_wrlock
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_post.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_post.S
new file mode 100644
index 000000000..2d7394d84
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_post.S
@@ -0,0 +1,139 @@
+/* Copyright (C) 2002, 2003, 2005, 2007, 2008 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread-errnos.h>
+#include <structsem.h>
+#include <lowlevellock.h>
+
+
+ .text
+
+ .globl sem_post
+ .type sem_post,@function
+ .align 16
+sem_post:
+ cfi_startproc
+ pushl %ebx
+ cfi_adjust_cfa_offset(4)
+ cfi_offset(%ebx, -8)
+
+ movl 8(%esp), %ebx
+
+#if VALUE == 0
+ movl (%ebx), %eax
+#else
+ movl VALUE(%ebx), %eax
+#endif
+0: cmpl $SEM_VALUE_MAX, %eax
+ je 3f
+ leal 1(%eax), %edx
+ LOCK
+#if VALUE == 0
+ cmpxchgl %edx, (%ebx)
+#else
+ cmpxchgl %edx, VALUE(%ebx)
+#endif
+ jnz 0b
+
+ cmpl $0, NWAITERS(%ebx)
+ je 2f
+
+ movl $FUTEX_WAKE, %ecx
+ orl PRIVATE(%ebx), %ecx
+ movl $1, %edx
+ movl $SYS_futex, %eax
+ ENTER_KERNEL
+
+ testl %eax, %eax
+ js 1f
+
+2: xorl %eax, %eax
+ popl %ebx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebx)
+ ret
+
+ cfi_adjust_cfa_offset(4)
+ cfi_offset(%ebx, -8)
+1:
+#ifdef __PIC__
+ call __x86.get_pc_thunk.bx
+#else
+ movl $4f, %ebx
+4:
+#endif
+ addl $_GLOBAL_OFFSET_TABLE_, %ebx
+#if USE___THREAD
+# ifdef NO_TLS_DIRECT_SEG_REFS
+ movl errno@gotntpoff(%ebx), %edx
+ addl %gs:0, %edx
+ movl $EINVAL, (%edx)
+# else
+ movl errno@gotntpoff(%ebx), %edx
+ movl $EINVAL, %gs:(%edx)
+# endif
+#else
+ call __errno_location@plt
+ movl $EINVAL, (%eax)
+#endif
+
+ orl $-1, %eax
+ popl %ebx
+ ret
+
+3:
+#ifdef __PIC__
+ call __x86.get_pc_thunk.bx
+#else
+ movl $5f, %ebx
+5:
+#endif
+ addl $_GLOBAL_OFFSET_TABLE_, %ebx
+#if USE___THREAD
+# ifdef NO_TLS_DIRECT_SEG_REFS
+ movl errno@gotntpoff(%ebx), %edx
+ addl %gs:0, %edx
+ movl $EOVERFLOW, (%edx)
+# else
+ movl errno@gotntpoff(%ebx), %edx
+ movl $EOVERFLOW, %gs:(%edx)
+# endif
+#else
+ call __errno_location@plt
+ movl $EOVERFLOW, (%eax)
+#endif
+
+ orl $-1, %eax
+ popl %ebx
+ cfi_adjust_cfa_offset(-4)
+ cfi_restore(%ebx)
+ ret
+ cfi_endproc
+ .size sem_post,.-sem_post
+
+#ifdef __PIC__
+ .section .gnu.linkonce.t.__x86.get_pc_thunk.bx,"ax",@progbits
+ .globl __x86.get_pc_thunk.bx
+ .hidden __x86.get_pc_thunk.bx
+ .type __x86.get_pc_thunk.bx,@function
+__x86.get_pc_thunk.bx:
+ movl (%esp), %ebx;
+ ret
+ .size __x86.get_pc_thunk.bx,.-__x86.get_pc_thunk.bx
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S
new file mode 100644
index 000000000..6d6968100
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S
@@ -0,0 +1,328 @@
+/* Copyright (C) 2002, 2003, 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread-errnos.h>
+#include <structsem.h>
+#include <lowlevellock.h>
+
+
+#if VALUE != 0
+# error "code needs to be rewritten for VALUE != 0"
+#endif
+
+
+ .text
+
+ .globl sem_timedwait
+ .type sem_timedwait,@function
+ .align 16
+sem_timedwait:
+.LSTARTCODE:
+ movl 4(%esp), %ecx
+
+ movl (%ecx), %eax
+2: testl %eax, %eax
+ je 1f
+
+ leal -1(%eax), %edx
+ LOCK
+ cmpxchgl %edx, (%ecx)
+ jne 2b
+
+ xorl %eax, %eax
+ ret
+
+ /* Check whether the timeout value is valid. */
+1: pushl %esi
+.Lpush_esi:
+ pushl %edi
+.Lpush_edi:
+ pushl %ebx
+.Lpush_ebx:
+ subl $12, %esp
+.Lsub_esp:
+
+ movl 32(%esp), %edi
+
+ /* Check for invalid nanosecond field. */
+ cmpl $1000000000, 4(%edi)
+ movl $EINVAL, %esi
+ jae 6f
+
+ LOCK
+ incl NWAITERS(%ecx)
+
+7: xorl %ecx, %ecx
+ movl %esp, %ebx
+ movl %ecx, %edx
+ movl $__NR_gettimeofday, %eax
+ ENTER_KERNEL
+
+ /* Compute relative timeout. */
+ movl 4(%esp), %eax
+ movl $1000, %edx
+ mul %edx /* Milli seconds to nano seconds. */
+ movl (%edi), %ecx
+ movl 4(%edi), %edx
+ subl (%esp), %ecx
+ subl %eax, %edx
+ jns 5f
+ addl $1000000000, %edx
+ subl $1, %ecx
+5: testl %ecx, %ecx
+ movl $ETIMEDOUT, %esi
+ js 6f /* Time is already up. */
+
+ movl %ecx, (%esp) /* Store relative timeout. */
+ movl %edx, 4(%esp)
+
+.LcleanupSTART:
+ call __pthread_enable_asynccancel
+ movl %eax, 8(%esp)
+
+ movl 28(%esp), %ebx /* Load semaphore address. */
+#if FUTEX_WAIT == 0
+ movl PRIVATE(%ebx), %ecx
+#else
+ movl $FUTEX_WAIT, %ecx
+ orl PRIVATE(%ebx), %ecx
+#endif
+ movl %esp, %esi
+ xorl %edx, %edx
+ movl $SYS_futex, %eax
+ ENTER_KERNEL
+ movl %eax, %esi
+
+ movl 8(%esp), %eax
+ call __pthread_disable_asynccancel
+.LcleanupEND:
+
+ testl %esi, %esi
+ je 9f
+ cmpl $-EWOULDBLOCK, %esi
+ jne 3f
+
+9: movl (%ebx), %eax
+8: testl %eax, %eax
+ je 7b
+
+ leal -1(%eax), %ecx
+ LOCK
+ cmpxchgl %ecx, (%ebx)
+ jne 8b
+
+ xorl %eax, %eax
+
+ LOCK
+ decl NWAITERS(%ebx)
+
+10: addl $12, %esp
+.Ladd_esp:
+ popl %ebx
+.Lpop_ebx:
+ popl %edi
+.Lpop_edi:
+ popl %esi
+.Lpop_esi:
+ ret
+
+.Lafter_ret:
+3: negl %esi
+6:
+#ifdef __PIC__
+ call __x86.get_pc_thunk.bx
+#else
+ movl $4f, %ebx
+4:
+#endif
+ addl $_GLOBAL_OFFSET_TABLE_, %ebx
+#if USE___THREAD
+# ifdef NO_TLS_DIRECT_SEG_REFS
+ movl errno@gotntpoff(%ebx), %edx
+ addl %gs:0, %edx
+ movl %esi, (%edx)
+# else
+ movl errno@gotntpoff(%ebx), %edx
+ movl %esi, %gs:(%edx)
+# endif
+#else
+ call __errno_location@plt
+ movl %esi, (%eax)
+#endif
+
+ movl 28(%esp), %ebx /* Load semaphore address. */
+ orl $-1, %eax
+ jmp 10b
+ .size sem_timedwait,.-sem_timedwait
+
+
+ .type sem_wait_cleanup,@function
+sem_wait_cleanup:
+ LOCK
+ decl NWAITERS(%ebx)
+ movl %eax, (%esp)
+.LcallUR:
+ call _Unwind_Resume@PLT
+ hlt
+.LENDCODE:
+ .size sem_wait_cleanup,.-sem_wait_cleanup
+
+
+ .section .gcc_except_table,"a",@progbits
+.LexceptSTART:
+ .byte 0xff # @LPStart format (omit)
+ .byte 0xff # @TType format (omit)
+ .byte 0x01 # call-site format
+ # DW_EH_PE_uleb128
+ .uleb128 .Lcstend-.Lcstbegin
+.Lcstbegin:
+ .uleb128 .LcleanupSTART-.LSTARTCODE
+ .uleb128 .LcleanupEND-.LcleanupSTART
+ .uleb128 sem_wait_cleanup-.LSTARTCODE
+ .uleb128 0
+ .uleb128 .LcallUR-.LSTARTCODE
+ .uleb128 .LENDCODE-.LcallUR
+ .uleb128 0
+ .uleb128 0
+.Lcstend:
+
+
+ .section .eh_frame,"a",@progbits
+.LSTARTFRAME:
+ .long .LENDCIE-.LSTARTCIE # Length of the CIE.
+.LSTARTCIE:
+ .long 0 # CIE ID.
+ .byte 1 # Version number.
+#ifdef SHARED
+ .string "zPLR" # NUL-terminated augmentation
+ # string.
+#else
+ .string "zPL" # NUL-terminated augmentation
+ # string.
+#endif
+ .uleb128 1 # Code alignment factor.
+ .sleb128 -4 # Data alignment factor.
+ .byte 8 # Return address register
+ # column.
+#ifdef SHARED
+ .uleb128 7 # Augmentation value length.
+ .byte 0x9b # Personality: DW_EH_PE_pcrel
+ # + DW_EH_PE_sdata4
+ # + DW_EH_PE_indirect
+ .long DW.ref.__gcc_personality_v0-.
+ .byte 0x1b # LSDA Encoding: DW_EH_PE_pcrel
+ # + DW_EH_PE_sdata4.
+ .byte 0x1b # FDE Encoding: DW_EH_PE_pcrel
+ # + DW_EH_PE_sdata4.
+#else
+ .uleb128 6 # Augmentation value length.
+ .byte 0x0 # Personality: absolute
+ .long __gcc_personality_v0
+ .byte 0x0 # LSDA Encoding: absolute
+#endif
+ .byte 0x0c # DW_CFA_def_cfa
+ .uleb128 4
+ .uleb128 4
+ .byte 0x88 # DW_CFA_offset, column 0x10
+ .uleb128 1
+ .align 4
+.LENDCIE:
+
+ .long .LENDFDE-.LSTARTFDE # Length of the FDE.
+.LSTARTFDE:
+ .long .LSTARTFDE-.LSTARTFRAME # CIE pointer.
+#ifdef SHARED
+ .long .LSTARTCODE-. # PC-relative start address
+ # of the code.
+#else
+ .long .LSTARTCODE # Start address of the code.
+#endif
+ .long .LENDCODE-.LSTARTCODE # Length of the code.
+ .uleb128 4 # Augmentation size
+#ifdef SHARED
+ .long .LexceptSTART-.
+#else
+ .long .LexceptSTART
+#endif
+
+ .byte 4 # DW_CFA_advance_loc4
+ .long .Lpush_esi-.LSTARTCODE
+ .byte 14 # DW_CFA_def_cfa_offset
+ .uleb128 8
+ .byte 0x86 # DW_CFA_offset %esi
+ .uleb128 2
+ .byte 4 # DW_CFA_advance_loc4
+ .long .Lpush_edi-.Lpush_esi
+ .byte 14 # DW_CFA_def_cfa_offset
+ .uleb128 12
+ .byte 0x87 # DW_CFA_offset %edi
+ .uleb128 3
+ .byte 4 # DW_CFA_advance_loc4
+ .long .Lpush_ebx-.Lpush_edi
+ .byte 14 # DW_CFA_def_cfa_offset
+ .uleb128 16
+ .byte 0x83 # DW_CFA_offset %ebx
+ .uleb128 4
+ .byte 4 # DW_CFA_advance_loc4
+ .long .Lsub_esp-.Lpush_ebx
+ .byte 14 # DW_CFA_def_cfa_offset
+ .uleb128 28
+ .byte 4 # DW_CFA_advance_loc4
+ .long .Ladd_esp-.Lsub_esp
+ .byte 14 # DW_CFA_def_cfa_offset
+ .uleb128 16
+ .byte 4 # DW_CFA_advance_loc4
+ .long .Lpop_ebx-.Ladd_esp
+ .byte 14 # DW_CFA_def_cfa_offset
+ .uleb128 12
+ .byte 0xc3 # DW_CFA_restore %ebx
+ .byte 4 # DW_CFA_advance_loc4
+ .long .Lpop_edi-.Lpop_ebx
+ .byte 14 # DW_CFA_def_cfa_offset
+ .uleb128 8
+ .byte 0xc7 # DW_CFA_restore %edi
+ .byte 4 # DW_CFA_advance_loc4
+ .long .Lpop_esi-.Lpop_edi
+ .byte 14 # DW_CFA_def_cfa_offset
+ .uleb128 4
+ .byte 0xc6 # DW_CFA_restore %esi
+ .byte 4 # DW_CFA_advance_loc4
+ .long .Lafter_ret-.Lpop_esi
+ .byte 14 # DW_CFA_def_cfa_offset
+ .uleb128 28
+ .byte 0x86 # DW_CFA_offset %esi
+ .uleb128 2
+ .byte 0x87 # DW_CFA_offset %edi
+ .uleb128 3
+ .byte 0x83 # DW_CFA_offset %ebx
+ .uleb128 4
+ .align 4
+.LENDFDE:
+
+
+#ifdef SHARED
+ .hidden DW.ref.__gcc_personality_v0
+ .weak DW.ref.__gcc_personality_v0
+ .section .gnu.linkonce.d.DW.ref.__gcc_personality_v0,"aw",@progbits
+ .align 4
+ .type DW.ref.__gcc_personality_v0, @object
+ .size DW.ref.__gcc_personality_v0, 4
+DW.ref.__gcc_personality_v0:
+ .long __gcc_personality_v0
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_trywait.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_trywait.S
new file mode 100644
index 000000000..befa0c912
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_trywait.S
@@ -0,0 +1,76 @@
+/* Copyright (C) 2002, 2003, 2005, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread-errnos.h>
+#include <lowlevellock.h>
+
+ .text
+
+ .globl sem_trywait
+ .type sem_trywait,@function
+ .align 16
+sem_trywait:
+ movl 4(%esp), %ecx
+
+ movl (%ecx), %eax
+2: testl %eax, %eax
+ jz 1f
+
+ leal -1(%eax), %edx
+ LOCK
+ cmpxchgl %edx, (%ecx)
+ jne 2b
+ xorl %eax, %eax
+ ret
+
+1:
+#ifdef __PIC__
+ call __x86.get_pc_thunk.cx
+#else
+ movl $3f, %ecx
+3:
+#endif
+ addl $_GLOBAL_OFFSET_TABLE_, %ecx
+#if USE___THREAD
+# ifdef NO_TLS_DIRECT_SEG_REFS
+ movl errno@gotntpoff(%ecx), %edx
+ addl %gs:0, %edx
+ movl $EAGAIN, (%edx)
+# else
+ movl errno@gotntpoff(%ecx), %edx
+ movl $EAGAIN, %gs:(%edx)
+# endif
+#else
+ call __errno_location@plt
+ movl $EAGAIN, (%eax)
+#endif
+ orl $-1, %eax
+ ret
+ .size sem_trywait,.-sem_trywait
+
+#ifdef __PIC__
+ .section .gnu.linkonce.t.__x86.get_pc_thunk.cx,"ax",@progbits
+ .globl __x86.get_pc_thunk.cx
+ .hidden __x86.get_pc_thunk.cx
+ .type __x86.get_pc_thunk.cx,@function
+__x86.get_pc_thunk.cx:
+ movl (%esp), %ecx;
+ ret
+ .size __x86.get_pc_thunk.cx,.-__x86.get_pc_thunk.cx
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_wait.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_wait.S
new file mode 100644
index 000000000..5f568976d
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i486/sem_wait.S
@@ -0,0 +1,267 @@
+/* Copyright (C) 2002, 2003, 2005, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread-errnos.h>
+#include <structsem.h>
+#include <lowlevellock.h>
+
+
+#if VALUE != 0
+# error "code needs to be rewritten for VALUE != 0"
+#endif
+
+ .text
+
+ .globl sem_wait
+ .type sem_wait,@function
+ .align 16
+sem_wait:
+.LSTARTCODE:
+ pushl %ebx
+.Lpush_ebx:
+ pushl %esi
+.Lpush_esi:
+ subl $4, %esp
+.Lsub_esp:
+
+ movl 16(%esp), %ebx
+
+ movl (%ebx), %eax
+2: testl %eax, %eax
+ je 1f
+
+ leal -1(%eax), %edx
+ LOCK
+ cmpxchgl %edx, (%ebx)
+ jne 2b
+7: xorl %eax, %eax
+
+9: movl 4(%esp), %esi
+ movl 8(%esp), %ebx
+ addl $12, %esp
+.Ladd_esp:
+ ret
+
+.Lafter_ret:
+1: LOCK
+ incl NWAITERS(%ebx)
+
+.LcleanupSTART:
+6: call __pthread_enable_asynccancel
+ movl %eax, (%esp)
+
+#if FUTEX_WAIT == 0
+ movl PRIVATE(%ebx), %ecx
+#else
+ movl $FUTEX_WAIT, %ecx
+ orl PRIVATE(%ebx), %ecx
+#endif
+ xorl %esi, %esi
+ xorl %edx, %edx
+ movl $SYS_futex, %eax
+ ENTER_KERNEL
+ movl %eax, %esi
+
+ movl (%esp), %eax
+ call __pthread_disable_asynccancel
+.LcleanupEND:
+
+ testl %esi, %esi
+ je 3f
+ cmpl $-EWOULDBLOCK, %esi
+ jne 4f
+
+3:
+ movl (%ebx), %eax
+5: testl %eax, %eax
+ je 6b
+
+ leal -1(%eax), %edx
+ LOCK
+ cmpxchgl %edx, (%ebx)
+ jne 5b
+
+ LOCK
+ decl NWAITERS(%ebx)
+ jmp 7b
+
+4: LOCK
+ decl NWAITERS(%ebx)
+
+ negl %esi
+#ifdef __PIC__
+ call __x86.get_pc_thunk.bx
+#else
+ movl $8f, %ebx
+8:
+#endif
+ addl $_GLOBAL_OFFSET_TABLE_, %ebx
+#if USE___THREAD
+# ifdef NO_TLS_DIRECT_SEG_REFS
+ movl errno@gotntpoff(%ebx), %edx
+ addl %gs:0, %edx
+ movl %esi, (%edx)
+# else
+ movl errno@gotntpoff(%ebx), %edx
+ movl %esi, %gs:(%edx)
+# endif
+#else
+ call __errno_location@plt
+ movl %esi, (%eax)
+#endif
+ orl $-1, %eax
+
+ jmp 9b
+ .size sem_wait,.-sem_wait
+
+
+ .type sem_wait_cleanup,@function
+sem_wait_cleanup:
+ LOCK
+ decl NWAITERS(%ebx)
+ movl %eax, (%esp)
+.LcallUR:
+ call _Unwind_Resume@PLT
+ hlt
+.LENDCODE:
+ .size sem_wait_cleanup,.-sem_wait_cleanup
+
+
+ .section .gcc_except_table,"a",@progbits
+.LexceptSTART:
+ .byte 0xff # @LPStart format (omit)
+ .byte 0xff # @TType format (omit)
+ .byte 0x01 # call-site format
+ # DW_EH_PE_uleb128
+ .uleb128 .Lcstend-.Lcstbegin
+.Lcstbegin:
+ .uleb128 .LcleanupSTART-.LSTARTCODE
+ .uleb128 .LcleanupEND-.LcleanupSTART
+ .uleb128 sem_wait_cleanup-.LSTARTCODE
+ .uleb128 0
+ .uleb128 .LcallUR-.LSTARTCODE
+ .uleb128 .LENDCODE-.LcallUR
+ .uleb128 0
+ .uleb128 0
+.Lcstend:
+
+
+ .section .eh_frame,"a",@progbits
+.LSTARTFRAME:
+ .long .LENDCIE-.LSTARTCIE # Length of the CIE.
+.LSTARTCIE:
+ .long 0 # CIE ID.
+ .byte 1 # Version number.
+#ifdef SHARED
+ .string "zPLR" # NUL-terminated augmentation
+ # string.
+#else
+ .string "zPL" # NUL-terminated augmentation
+ # string.
+#endif
+ .uleb128 1 # Code alignment factor.
+ .sleb128 -4 # Data alignment factor.
+ .byte 8 # Return address register
+ # column.
+#ifdef SHARED
+ .uleb128 7 # Augmentation value length.
+ .byte 0x9b # Personality: DW_EH_PE_pcrel
+ # + DW_EH_PE_sdata4
+ # + DW_EH_PE_indirect
+ .long DW.ref.__gcc_personality_v0-.
+ .byte 0x1b # LSDA Encoding: DW_EH_PE_pcrel
+ # + DW_EH_PE_sdata4.
+ .byte 0x1b # FDE Encoding: DW_EH_PE_pcrel
+ # + DW_EH_PE_sdata4.
+#else
+ .uleb128 6 # Augmentation value length.
+ .byte 0x0 # Personality: absolute
+ .long __gcc_personality_v0
+ .byte 0x0 # LSDA Encoding: absolute
+#endif
+ .byte 0x0c # DW_CFA_def_cfa
+ .uleb128 4
+ .uleb128 4
+ .byte 0x88 # DW_CFA_offset, column 0x10
+ .uleb128 1
+ .align 4
+.LENDCIE:
+
+ .long .LENDFDE-.LSTARTFDE # Length of the FDE.
+.LSTARTFDE:
+ .long .LSTARTFDE-.LSTARTFRAME # CIE pointer.
+#ifdef SHARED
+ .long .LSTARTCODE-. # PC-relative start address
+ # of the code.
+#else
+ .long .LSTARTCODE # Start address of the code.
+#endif
+ .long .LENDCODE-.LSTARTCODE # Length of the code.
+ .uleb128 4 # Augmentation size
+#ifdef SHARED
+ .long .LexceptSTART-.
+#else
+ .long .LexceptSTART
+#endif
+
+ .byte 4 # DW_CFA_advance_loc4
+ .long .Lpush_ebx-.LSTARTCODE
+ .byte 14 # DW_CFA_def_cfa_offset
+ .uleb128 8
+ .byte 0x83 # DW_CFA_offset %ebx
+ .uleb128 2
+ .byte 4 # DW_CFA_advance_loc4
+ .long .Lpush_esi-.Lpush_ebx
+ .byte 14 # DW_CFA_def_cfa_offset
+ .uleb128 12
+ .byte 0x86 # DW_CFA_offset %esi
+ .uleb128 3
+ .byte 4 # DW_CFA_advance_loc4
+ .long .Lsub_esp-.Lpush_esi
+ .byte 14 # DW_CFA_def_cfa_offset
+ .uleb128 16
+ .byte 4 # DW_CFA_advance_loc4
+ .long .Ladd_esp-.Lsub_esp
+ .byte 14 # DW_CFA_def_cfa_offset
+ .uleb128 4
+ .byte 0xc3 # DW_CFA_restore %ebx
+ .byte 0xc6 # DW_CFA_restore %esi
+ .byte 4 # DW_CFA_advance_loc4
+ .long .Lafter_ret-.Ladd_esp
+ .byte 14 # DW_CFA_def_cfa_offset
+ .uleb128 16
+ .byte 0x83 # DW_CFA_offset %ebx
+ .uleb128 2
+ .byte 0x86 # DW_CFA_offset %esi
+ .uleb128 3
+ .align 4
+.LENDFDE:
+
+
+#ifdef SHARED
+ .hidden DW.ref.__gcc_personality_v0
+ .weak DW.ref.__gcc_personality_v0
+ .section .gnu.linkonce.d.DW.ref.__gcc_personality_v0,"aw",@progbits
+ .align 4
+ .type DW.ref.__gcc_personality_v0, @object
+ .size DW.ref.__gcc_personality_v0, 4
+DW.ref.__gcc_personality_v0:
+ .long __gcc_personality_v0
+#endif
+
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/libc-lowlevellock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/libc-lowlevellock.S
new file mode 100644
index 000000000..f567c1d6d
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/libc-lowlevellock.S
@@ -0,0 +1 @@
+#include "../i486/libc-lowlevellock.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/lowlevellock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/lowlevellock.S
new file mode 100644
index 000000000..59194c712
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/lowlevellock.S
@@ -0,0 +1,19 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 "../i486/lowlevellock.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/lowlevelrobustlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/lowlevelrobustlock.S
new file mode 100644
index 000000000..6103f2ee4
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/lowlevelrobustlock.S
@@ -0,0 +1,19 @@
+/* Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 "../i486/lowlevelrobustlock.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_barrier_wait.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_barrier_wait.S
new file mode 100644
index 000000000..d22c72467
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_barrier_wait.S
@@ -0,0 +1,19 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 "../i486/pthread_barrier_wait.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_cond_broadcast.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_cond_broadcast.S
new file mode 100644
index 000000000..4d459716b
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_cond_broadcast.S
@@ -0,0 +1,19 @@
+/* Copyright (C) 2003 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 "../i486/pthread_cond_broadcast.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_cond_signal.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_cond_signal.S
new file mode 100644
index 000000000..36634766c
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_cond_signal.S
@@ -0,0 +1,19 @@
+/* Copyright (C) 2003 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 "../i486/pthread_cond_signal.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_cond_timedwait.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_cond_timedwait.S
new file mode 100644
index 000000000..673d873de
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_cond_timedwait.S
@@ -0,0 +1,19 @@
+/* Copyright (C) 2003 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 "../i486/pthread_cond_timedwait.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_cond_wait.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_cond_wait.S
new file mode 100644
index 000000000..d3e1549cd
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_cond_wait.S
@@ -0,0 +1,19 @@
+/* Copyright (C) 2003 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 "../i486/pthread_cond_wait.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_rwlock_rdlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_rwlock_rdlock.S
new file mode 100644
index 000000000..688541a62
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_rwlock_rdlock.S
@@ -0,0 +1,19 @@
+/* Copyright (C) 2003 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 "../i486/pthread_rwlock_rdlock.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_rwlock_timedrdlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_rwlock_timedrdlock.S
new file mode 100644
index 000000000..353c28535
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_rwlock_timedrdlock.S
@@ -0,0 +1,19 @@
+/* Copyright (C) 2003 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 "../i486/pthread_rwlock_timedrdlock.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_rwlock_timedwrlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_rwlock_timedwrlock.S
new file mode 100644
index 000000000..515da0a4f
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_rwlock_timedwrlock.S
@@ -0,0 +1,19 @@
+/* Copyright (C) 2003 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 "../i486/pthread_rwlock_timedwrlock.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_rwlock_unlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_rwlock_unlock.S
new file mode 100644
index 000000000..9d8acc4f3
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_rwlock_unlock.S
@@ -0,0 +1,19 @@
+/* Copyright (C) 2003 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 "../i486/pthread_rwlock_unlock.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_rwlock_wrlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_rwlock_wrlock.S
new file mode 100644
index 000000000..79ee12dde
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/pthread_rwlock_wrlock.S
@@ -0,0 +1,19 @@
+/* Copyright (C) 2003 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 "../i486/pthread_rwlock_wrlock.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/sem_post.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/sem_post.S
new file mode 100644
index 000000000..5e7a41926
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/sem_post.S
@@ -0,0 +1,19 @@
+/* Copyright (C) 2003 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 "../i486/sem_post.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/sem_timedwait.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/sem_timedwait.S
new file mode 100644
index 000000000..ad941ce9a
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/sem_timedwait.S
@@ -0,0 +1,19 @@
+/* Copyright (C) 2003 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 "../i486/sem_timedwait.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/sem_trywait.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/sem_trywait.S
new file mode 100644
index 000000000..4044a723c
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/sem_trywait.S
@@ -0,0 +1,19 @@
+/* Copyright (C) 2003 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 "../i486/sem_trywait.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/sem_wait.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/sem_wait.S
new file mode 100644
index 000000000..6f130d3d0
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i586/sem_wait.S
@@ -0,0 +1,19 @@
+/* Copyright (C) 2003 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 "../i486/sem_wait.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/libc-lowlevellock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/libc-lowlevellock.S
new file mode 100644
index 000000000..f567c1d6d
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/libc-lowlevellock.S
@@ -0,0 +1 @@
+#include "../i486/libc-lowlevellock.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/lowlevellock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/lowlevellock.S
new file mode 100644
index 000000000..59194c712
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/lowlevellock.S
@@ -0,0 +1,19 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 "../i486/lowlevellock.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/lowlevelrobustlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/lowlevelrobustlock.S
new file mode 100644
index 000000000..6103f2ee4
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/lowlevelrobustlock.S
@@ -0,0 +1,19 @@
+/* Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 "../i486/lowlevelrobustlock.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_barrier_wait.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_barrier_wait.S
new file mode 100644
index 000000000..d22c72467
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_barrier_wait.S
@@ -0,0 +1,19 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 "../i486/pthread_barrier_wait.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_cond_broadcast.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_cond_broadcast.S
new file mode 100644
index 000000000..4d459716b
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_cond_broadcast.S
@@ -0,0 +1,19 @@
+/* Copyright (C) 2003 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 "../i486/pthread_cond_broadcast.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_cond_signal.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_cond_signal.S
new file mode 100644
index 000000000..36634766c
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_cond_signal.S
@@ -0,0 +1,19 @@
+/* Copyright (C) 2003 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 "../i486/pthread_cond_signal.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_cond_timedwait.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_cond_timedwait.S
new file mode 100644
index 000000000..3f67df1fc
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_cond_timedwait.S
@@ -0,0 +1,20 @@
+/* Copyright (C) 2003 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/>. */
+
+#define HAVE_CMOV 1
+#include "../i486/pthread_cond_timedwait.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_cond_wait.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_cond_wait.S
new file mode 100644
index 000000000..d3e1549cd
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_cond_wait.S
@@ -0,0 +1,19 @@
+/* Copyright (C) 2003 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 "../i486/pthread_cond_wait.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_rwlock_rdlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_rwlock_rdlock.S
new file mode 100644
index 000000000..688541a62
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_rwlock_rdlock.S
@@ -0,0 +1,19 @@
+/* Copyright (C) 2003 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 "../i486/pthread_rwlock_rdlock.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_rwlock_timedrdlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_rwlock_timedrdlock.S
new file mode 100644
index 000000000..353c28535
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_rwlock_timedrdlock.S
@@ -0,0 +1,19 @@
+/* Copyright (C) 2003 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 "../i486/pthread_rwlock_timedrdlock.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_rwlock_timedwrlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_rwlock_timedwrlock.S
new file mode 100644
index 000000000..515da0a4f
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_rwlock_timedwrlock.S
@@ -0,0 +1,19 @@
+/* Copyright (C) 2003 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 "../i486/pthread_rwlock_timedwrlock.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_rwlock_unlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_rwlock_unlock.S
new file mode 100644
index 000000000..39f88ff68
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_rwlock_unlock.S
@@ -0,0 +1,20 @@
+/* Copyright (C) 2003 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/>. */
+
+#define HAVE_CMOV 1
+#include "../i486/pthread_rwlock_unlock.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_rwlock_wrlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_rwlock_wrlock.S
new file mode 100644
index 000000000..79ee12dde
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/pthread_rwlock_wrlock.S
@@ -0,0 +1,19 @@
+/* Copyright (C) 2003 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 "../i486/pthread_rwlock_wrlock.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/sem_post.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/sem_post.S
new file mode 100644
index 000000000..5e7a41926
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/sem_post.S
@@ -0,0 +1,19 @@
+/* Copyright (C) 2003 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 "../i486/sem_post.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/sem_timedwait.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/sem_timedwait.S
new file mode 100644
index 000000000..ad941ce9a
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/sem_timedwait.S
@@ -0,0 +1,19 @@
+/* Copyright (C) 2003 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 "../i486/sem_timedwait.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/sem_trywait.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/sem_trywait.S
new file mode 100644
index 000000000..4044a723c
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/sem_trywait.S
@@ -0,0 +1,19 @@
+/* Copyright (C) 2003 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 "../i486/sem_trywait.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/sem_wait.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/sem_wait.S
new file mode 100644
index 000000000..6f130d3d0
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/i686/sem_wait.S
@@ -0,0 +1,19 @@
+/* Copyright (C) 2003 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 "../i486/sem_wait.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/lowlevellock.h b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/lowlevellock.h
new file mode 100644
index 000000000..d27ef2b68
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/lowlevellock.h
@@ -0,0 +1,584 @@
+/* Copyright (C) 2002-2004, 2006-2008, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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/>. */
+
+#ifndef _LOWLEVELLOCK_H
+#define _LOWLEVELLOCK_H 1
+
+#ifndef __ASSEMBLER__
+# include <time.h>
+# include <sys/param.h>
+# include <bits/pthreadtypes.h>
+# include <bits/kernel-features.h>
+# include <tcb-offsets.h>
+# include <atomic.h>
+
+# ifndef LOCK_INSTR
+# ifdef UP
+# define LOCK_INSTR /* nothing */
+# else
+# define LOCK_INSTR "lock;"
+# endif
+# endif
+#else
+# ifndef LOCK
+# ifdef UP
+# define LOCK
+# else
+# define LOCK lock
+# endif
+# endif
+#endif
+
+#define FUTEX_WAIT 0
+#define FUTEX_WAKE 1
+#define FUTEX_CMP_REQUEUE 4
+#define FUTEX_WAKE_OP 5
+#define FUTEX_LOCK_PI 6
+#define FUTEX_UNLOCK_PI 7
+#define FUTEX_TRYLOCK_PI 8
+#define FUTEX_WAIT_BITSET 9
+#define FUTEX_WAKE_BITSET 10
+#define FUTEX_WAIT_REQUEUE_PI 11
+#define FUTEX_CMP_REQUEUE_PI 12
+#define FUTEX_PRIVATE_FLAG 128
+#define FUTEX_CLOCK_REALTIME 256
+
+#define FUTEX_BITSET_MATCH_ANY 0xffffffff
+
+#define FUTEX_OP_CLEAR_WAKE_IF_GT_ONE ((4 << 24) | 1)
+
+/* Values for 'private' parameter of locking macros. Yes, the
+ definition seems to be backwards. But it is not. The bit will be
+ reversed before passing to the system call. */
+#define LLL_PRIVATE 0
+#define LLL_SHARED FUTEX_PRIVATE_FLAG
+
+
+#if !defined NOT_IN_libc || defined IS_IN_rtld
+/* In libc.so or ld.so all futexes are private. */
+# ifdef __ASSUME_PRIVATE_FUTEX
+# define __lll_private_flag(fl, private) \
+ ((fl) | FUTEX_PRIVATE_FLAG)
+# else
+# define __lll_private_flag(fl, private) \
+ ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex))
+# endif
+#else
+# ifdef __ASSUME_PRIVATE_FUTEX
+# define __lll_private_flag(fl, private) \
+ (((fl) | FUTEX_PRIVATE_FLAG) ^ (private))
+# else
+# define __lll_private_flag(fl, private) \
+ (__builtin_constant_p (private) \
+ ? ((private) == 0 \
+ ? ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex)) \
+ : (fl)) \
+ : ({ unsigned int __fl = ((private) ^ FUTEX_PRIVATE_FLAG); \
+ __asm__ ("andl %%gs:%P1, %0" : "+r" (__fl) \
+ : "i" (offsetof (struct pthread, header.private_futex))); \
+ __fl | (fl); }))
+# endif
+#endif
+
+#ifndef __ASSEMBLER__
+
+/* Initializer for compatibility lock. */
+#define LLL_LOCK_INITIALIZER (0)
+#define LLL_LOCK_INITIALIZER_LOCKED (1)
+#define LLL_LOCK_INITIALIZER_WAITERS (2)
+
+
+#ifdef __PIC__
+# define LLL_EBX_LOAD "xchgl %2, %%ebx\n"
+# define LLL_EBX_REG "D"
+#else
+# define LLL_EBX_LOAD
+# define LLL_EBX_REG "b"
+#endif
+
+#ifdef I386_USE_SYSENTER
+# ifdef SHARED
+# define LLL_ENTER_KERNEL "call *%%gs:%P6\n\t"
+# else
+# define LLL_ENTER_KERNEL "call *_dl_sysinfo\n\t"
+# endif
+#else
+# define LLL_ENTER_KERNEL "int $0x80\n\t"
+#endif
+
+/* Delay in spinlock loop. */
+#define BUSY_WAIT_NOP __asm__ ("rep; nop")
+
+
+#define LLL_STUB_UNWIND_INFO_START \
+ ".section .eh_frame,\"a\",@progbits\n" \
+"5:\t" ".long 7f-6f # Length of Common Information Entry\n" \
+"6:\t" ".long 0x0 # CIE Identifier Tag\n\t" \
+ ".byte 0x1 # CIE Version\n\t" \
+ ".ascii \"zR\\0\" # CIE Augmentation\n\t" \
+ ".uleb128 0x1 # CIE Code Alignment Factor\n\t" \
+ ".sleb128 -4 # CIE Data Alignment Factor\n\t" \
+ ".byte 0x8 # CIE RA Column\n\t" \
+ ".uleb128 0x1 # Augmentation size\n\t" \
+ ".byte 0x1b # FDE Encoding (pcrel sdata4)\n\t" \
+ ".byte 0xc # DW_CFA_def_cfa\n\t" \
+ ".uleb128 0x4\n\t" \
+ ".uleb128 0x0\n\t" \
+ ".align 4\n" \
+"7:\t" ".long 17f-8f # FDE Length\n" \
+"8:\t" ".long 8b-5b # FDE CIE offset\n\t" \
+ ".long 1b-. # FDE initial location\n\t" \
+ ".long 4b-1b # FDE address range\n\t" \
+ ".uleb128 0x0 # Augmentation size\n\t" \
+ ".byte 0x16 # DW_CFA_val_expression\n\t" \
+ ".uleb128 0x8\n\t" \
+ ".uleb128 10f-9f\n" \
+"9:\t" ".byte 0x78 # DW_OP_breg8\n\t" \
+ ".sleb128 3b-1b\n"
+#define LLL_STUB_UNWIND_INFO_END \
+ ".byte 0x16 # DW_CFA_val_expression\n\t" \
+ ".uleb128 0x8\n\t" \
+ ".uleb128 12f-11f\n" \
+"11:\t" ".byte 0x78 # DW_OP_breg8\n\t" \
+ ".sleb128 3b-2b\n" \
+"12:\t" ".byte 0x40 + (3b-2b-1) # DW_CFA_advance_loc\n\t" \
+ ".byte 0x16 # DW_CFA_val_expression\n\t" \
+ ".uleb128 0x8\n\t" \
+ ".uleb128 16f-13f\n" \
+"13:\t" ".byte 0x78 # DW_OP_breg8\n\t" \
+ ".sleb128 15f-14f\n\t" \
+ ".byte 0x0d # DW_OP_const4s\n" \
+"14:\t" ".4byte 3b-.\n\t" \
+ ".byte 0x1c # DW_OP_minus\n\t" \
+ ".byte 0x0d # DW_OP_const4s\n" \
+"15:\t" ".4byte 18f-.\n\t" \
+ ".byte 0x22 # DW_OP_plus\n" \
+"16:\t" ".align 4\n" \
+"17:\t" ".previous\n"
+
+/* Unwind info for
+ 1: lea ..., ...
+ 2: call ...
+ 3: jmp 18f
+ 4:
+ snippet. */
+#define LLL_STUB_UNWIND_INFO_3 \
+LLL_STUB_UNWIND_INFO_START \
+"10:\t" ".byte 0x40 + (2b-1b) # DW_CFA_advance_loc\n\t" \
+LLL_STUB_UNWIND_INFO_END
+
+/* Unwind info for
+ 1: lea ..., ...
+ 0: movl ..., ...
+ 2: call ...
+ 3: jmp 18f
+ 4:
+ snippet. */
+#define LLL_STUB_UNWIND_INFO_4 \
+LLL_STUB_UNWIND_INFO_START \
+"10:\t" ".byte 0x40 + (0b-1b) # DW_CFA_advance_loc\n\t" \
+ ".byte 0x16 # DW_CFA_val_expression\n\t" \
+ ".uleb128 0x8\n\t" \
+ ".uleb128 20f-19f\n" \
+"19:\t" ".byte 0x78 # DW_OP_breg8\n\t" \
+ ".sleb128 3b-0b\n" \
+"20:\t" ".byte 0x40 + (2b-0b) # DW_CFA_advance_loc\n\t" \
+LLL_STUB_UNWIND_INFO_END
+
+
+#define lll_futex_wait(futex, val, private) \
+ lll_futex_timed_wait (futex, val, NULL, private)
+
+
+#define lll_futex_timed_wait(futex, val, timeout, private) \
+ ({ \
+ int __status; \
+ register __typeof (val) _val __asm__ ("edx") = (val); \
+ __asm__ __volatile__ (LLL_EBX_LOAD \
+ LLL_ENTER_KERNEL \
+ LLL_EBX_LOAD \
+ : "=a" (__status) \
+ : "0" (SYS_futex), LLL_EBX_REG (futex), "S" (timeout), \
+ "c" (__lll_private_flag (FUTEX_WAIT, private)), \
+ "d" (_val), "i" (offsetof (tcbhead_t, sysinfo)) \
+ : "memory"); \
+ __status; \
+ })
+
+
+#define lll_futex_wake(futex, nr, private) \
+ do { \
+ int __ignore; \
+ register __typeof (nr) _nr __asm__ ("edx") = (nr); \
+ __asm__ __volatile__ (LLL_EBX_LOAD \
+ LLL_ENTER_KERNEL \
+ LLL_EBX_LOAD \
+ : "=a" (__ignore) \
+ : "0" (SYS_futex), LLL_EBX_REG (futex), \
+ "c" (__lll_private_flag (FUTEX_WAKE, private)), \
+ "d" (_nr), \
+ "i" (0) /* phony, to align next arg's number */, \
+ "i" (offsetof (tcbhead_t, sysinfo))); \
+ } while (0)
+
+
+/* NB: in the lll_trylock macro we simply return the value in %eax
+ after the cmpxchg instruction. In case the operation succeded this
+ value is zero. In case the operation failed, the cmpxchg instruction
+ has loaded the current value of the memory work which is guaranteed
+ to be nonzero. */
+#if defined NOT_IN_libc || defined UP
+# define __lll_trylock_asm LOCK_INSTR "cmpxchgl %2, %1"
+#else
+# define __lll_trylock_asm "cmpl $0, %%gs:%P5\n\t" \
+ "je 0f\n\t" \
+ "lock\n" \
+ "0:\tcmpxchgl %2, %1"
+#endif
+
+#define lll_trylock(futex) \
+ ({ int ret; \
+ __asm__ __volatile__ (__lll_trylock_asm \
+ : "=a" (ret), "=m" (futex) \
+ : "r" (LLL_LOCK_INITIALIZER_LOCKED), "m" (futex), \
+ "0" (LLL_LOCK_INITIALIZER), \
+ "i" (MULTIPLE_THREADS_OFFSET) \
+ : "memory"); \
+ ret; })
+
+#define lll_robust_trylock(futex, id) \
+ ({ int ret; \
+ __asm__ __volatile__ (LOCK_INSTR "cmpxchgl %2, %1" \
+ : "=a" (ret), "=m" (futex) \
+ : "r" (id), "m" (futex), \
+ "0" (LLL_LOCK_INITIALIZER) \
+ : "memory"); \
+ ret; })
+
+
+#define lll_cond_trylock(futex) \
+ ({ int ret; \
+ __asm__ __volatile__ (LOCK_INSTR "cmpxchgl %2, %1" \
+ : "=a" (ret), "=m" (futex) \
+ : "r" (LLL_LOCK_INITIALIZER_WAITERS), \
+ "m" (futex), "0" (LLL_LOCK_INITIALIZER) \
+ : "memory"); \
+ ret; })
+
+#if defined NOT_IN_libc || defined UP
+# define __lll_lock_asm_start LOCK_INSTR "cmpxchgl %1, %2\n\t"
+#else
+# define __lll_lock_asm_start "cmpl $0, %%gs:%P6\n\t" \
+ "je 0f\n\t" \
+ "lock\n" \
+ "0:\tcmpxchgl %1, %2\n\t"
+#endif
+
+#define lll_lock(futex, private) \
+ (void) \
+ ({ int ignore1, ignore2; \
+ if (__builtin_constant_p (private) && (private) == LLL_PRIVATE) \
+ __asm__ __volatile__ (__lll_lock_asm_start \
+ "jnz _L_lock_%=\n\t" \
+ ".subsection 1\n\t" \
+ ".type _L_lock_%=,@function\n" \
+ "_L_lock_%=:\n" \
+ "1:\tleal %2, %%ecx\n" \
+ "2:\tcall __lll_lock_wait_private\n" \
+ "3:\tjmp 18f\n" \
+ "4:\t.size _L_lock_%=, 4b-1b\n\t" \
+ ".previous\n" \
+ LLL_STUB_UNWIND_INFO_3 \
+ "18:" \
+ : "=a" (ignore1), "=c" (ignore2), "=m" (futex) \
+ : "0" (0), "1" (1), "m" (futex), \
+ "i" (MULTIPLE_THREADS_OFFSET) \
+ : "memory"); \
+ else \
+ { \
+ int ignore3; \
+ __asm__ __volatile__ (__lll_lock_asm_start \
+ "jnz _L_lock_%=\n\t" \
+ ".subsection 1\n\t" \
+ ".type _L_lock_%=,@function\n" \
+ "_L_lock_%=:\n" \
+ "1:\tleal %2, %%edx\n" \
+ "0:\tmovl %8, %%ecx\n" \
+ "2:\tcall __lll_lock_wait\n" \
+ "3:\tjmp 18f\n" \
+ "4:\t.size _L_lock_%=, 4b-1b\n\t" \
+ ".previous\n" \
+ LLL_STUB_UNWIND_INFO_4 \
+ "18:" \
+ : "=a" (ignore1), "=c" (ignore2), \
+ "=m" (futex), "=&d" (ignore3) \
+ : "1" (1), "m" (futex), \
+ "i" (MULTIPLE_THREADS_OFFSET), "0" (0), \
+ "g" ((int) (private)) \
+ : "memory"); \
+ } \
+ })
+
+#define lll_robust_lock(futex, id, private) \
+ ({ int __ret, ignore1, ignore2; \
+ __asm__ __volatile__ (LOCK_INSTR "cmpxchgl %1, %2\n\t" \
+ "jnz _L_robust_lock_%=\n\t" \
+ ".subsection 1\n\t" \
+ ".type _L_robust_lock_%=,@function\n" \
+ "_L_robust_lock_%=:\n" \
+ "1:\tleal %2, %%edx\n" \
+ "0:\tmovl %7, %%ecx\n" \
+ "2:\tcall __lll_robust_lock_wait\n" \
+ "3:\tjmp 18f\n" \
+ "4:\t.size _L_robust_lock_%=, 4b-1b\n\t" \
+ ".previous\n" \
+ LLL_STUB_UNWIND_INFO_4 \
+ "18:" \
+ : "=a" (__ret), "=c" (ignore1), "=m" (futex), \
+ "=&d" (ignore2) \
+ : "0" (0), "1" (id), "m" (futex), "g" ((int) (private))\
+ : "memory"); \
+ __ret; })
+
+
+/* Special version of lll_lock which causes the unlock function to
+ always wakeup waiters. */
+#define lll_cond_lock(futex, private) \
+ (void) \
+ ({ int ignore1, ignore2, ignore3; \
+ __asm__ __volatile__ (LOCK_INSTR "cmpxchgl %1, %2\n\t" \
+ "jnz _L_cond_lock_%=\n\t" \
+ ".subsection 1\n\t" \
+ ".type _L_cond_lock_%=,@function\n" \
+ "_L_cond_lock_%=:\n" \
+ "1:\tleal %2, %%edx\n" \
+ "0:\tmovl %7, %%ecx\n" \
+ "2:\tcall __lll_lock_wait\n" \
+ "3:\tjmp 18f\n" \
+ "4:\t.size _L_cond_lock_%=, 4b-1b\n\t" \
+ ".previous\n" \
+ LLL_STUB_UNWIND_INFO_4 \
+ "18:" \
+ : "=a" (ignore1), "=c" (ignore2), "=m" (futex), \
+ "=&d" (ignore3) \
+ : "0" (0), "1" (2), "m" (futex), "g" ((int) (private))\
+ : "memory"); \
+ })
+
+
+#define lll_robust_cond_lock(futex, id, private) \
+ ({ int __ret, ignore1, ignore2; \
+ __asm__ __volatile__ (LOCK_INSTR "cmpxchgl %1, %2\n\t" \
+ "jnz _L_robust_cond_lock_%=\n\t" \
+ ".subsection 1\n\t" \
+ ".type _L_robust_cond_lock_%=,@function\n" \
+ "_L_robust_cond_lock_%=:\n" \
+ "1:\tleal %2, %%edx\n" \
+ "0:\tmovl %7, %%ecx\n" \
+ "2:\tcall __lll_robust_lock_wait\n" \
+ "3:\tjmp 18f\n" \
+ "4:\t.size _L_robust_cond_lock_%=, 4b-1b\n\t" \
+ ".previous\n" \
+ LLL_STUB_UNWIND_INFO_4 \
+ "18:" \
+ : "=a" (__ret), "=c" (ignore1), "=m" (futex), \
+ "=&d" (ignore2) \
+ : "0" (0), "1" (id | FUTEX_WAITERS), "m" (futex), \
+ "g" ((int) (private)) \
+ : "memory"); \
+ __ret; })
+
+
+#define lll_timedlock(futex, timeout, private) \
+ ({ int __ret, ignore1, ignore2, ignore3; \
+ __asm__ __volatile__ (LOCK_INSTR "cmpxchgl %1, %3\n\t" \
+ "jnz _L_timedlock_%=\n\t" \
+ ".subsection 1\n\t" \
+ ".type _L_timedlock_%=,@function\n" \
+ "_L_timedlock_%=:\n" \
+ "1:\tleal %3, %%ecx\n" \
+ "0:\tmovl %8, %%edx\n" \
+ "2:\tcall __lll_timedlock_wait\n" \
+ "3:\tjmp 18f\n" \
+ "4:\t.size _L_timedlock_%=, 4b-1b\n\t" \
+ ".previous\n" \
+ LLL_STUB_UNWIND_INFO_4 \
+ "18:" \
+ : "=a" (__ret), "=c" (ignore1), "=&d" (ignore2), \
+ "=m" (futex), "=S" (ignore3) \
+ : "0" (0), "1" (1), "m" (futex), "m" (timeout), \
+ "4" ((int) (private)) \
+ : "memory"); \
+ __ret; })
+
+
+#define lll_robust_timedlock(futex, timeout, id, private) \
+ ({ int __ret, ignore1, ignore2, ignore3; \
+ __asm__ __volatile__ (LOCK_INSTR "cmpxchgl %1, %3\n\t" \
+ "jnz _L_robust_timedlock_%=\n\t" \
+ ".subsection 1\n\t" \
+ ".type _L_robust_timedlock_%=,@function\n" \
+ "_L_robust_timedlock_%=:\n" \
+ "1:\tleal %3, %%ecx\n" \
+ "0:\tmovl %8, %%edx\n" \
+ "2:\tcall __lll_robust_timedlock_wait\n" \
+ "3:\tjmp 18f\n" \
+ "4:\t.size _L_robust_timedlock_%=, 4b-1b\n\t" \
+ ".previous\n" \
+ LLL_STUB_UNWIND_INFO_4 \
+ "18:" \
+ : "=a" (__ret), "=c" (ignore1), "=&d" (ignore2), \
+ "=m" (futex), "=S" (ignore3) \
+ : "0" (0), "1" (id), "m" (futex), "m" (timeout), \
+ "4" ((int) (private)) \
+ : "memory"); \
+ __ret; })
+
+#if defined NOT_IN_libc || defined UP
+# define __lll_unlock_asm LOCK_INSTR "subl $1, %0\n\t"
+#else
+# define __lll_unlock_asm "cmpl $0, %%gs:%P3\n\t" \
+ "je 0f\n\t" \
+ "lock\n" \
+ "0:\tsubl $1,%0\n\t"
+#endif
+
+#define lll_unlock(futex, private) \
+ (void) \
+ ({ int ignore; \
+ if (__builtin_constant_p (private) && (private) == LLL_PRIVATE) \
+ __asm__ __volatile__ (__lll_unlock_asm \
+ "jne _L_unlock_%=\n\t" \
+ ".subsection 1\n\t" \
+ ".type _L_unlock_%=,@function\n" \
+ "_L_unlock_%=:\n" \
+ "1:\tleal %0, %%eax\n" \
+ "2:\tcall __lll_unlock_wake_private\n" \
+ "3:\tjmp 18f\n" \
+ "4:\t.size _L_unlock_%=, 4b-1b\n\t" \
+ ".previous\n" \
+ LLL_STUB_UNWIND_INFO_3 \
+ "18:" \
+ : "=m" (futex), "=&a" (ignore) \
+ : "m" (futex), "i" (MULTIPLE_THREADS_OFFSET) \
+ : "memory"); \
+ else \
+ { \
+ int ignore2; \
+ __asm__ __volatile__ (__lll_unlock_asm \
+ "jne _L_unlock_%=\n\t" \
+ ".subsection 1\n\t" \
+ ".type _L_unlock_%=,@function\n" \
+ "_L_unlock_%=:\n" \
+ "1:\tleal %0, %%eax\n" \
+ "0:\tmovl %5, %%ecx\n" \
+ "2:\tcall __lll_unlock_wake\n" \
+ "3:\tjmp 18f\n" \
+ "4:\t.size _L_unlock_%=, 4b-1b\n\t" \
+ ".previous\n" \
+ LLL_STUB_UNWIND_INFO_4 \
+ "18:" \
+ : "=m" (futex), "=&a" (ignore), "=&c" (ignore2) \
+ : "i" (MULTIPLE_THREADS_OFFSET), "m" (futex), \
+ "g" ((int) (private)) \
+ : "memory"); \
+ } \
+ })
+
+#define lll_robust_unlock(futex, private) \
+ (void) \
+ ({ int ignore, ignore2; \
+ __asm__ __volatile__ (LOCK_INSTR "andl %3, %0\n\t" \
+ "jne _L_robust_unlock_%=\n\t" \
+ ".subsection 1\n\t" \
+ ".type _L_robust_unlock_%=,@function\n" \
+ "_L_robust_unlock_%=:\n\t" \
+ "1:\tleal %0, %%eax\n" \
+ "0:\tmovl %5, %%ecx\n" \
+ "2:\tcall __lll_unlock_wake\n" \
+ "3:\tjmp 18f\n" \
+ "4:\t.size _L_robust_unlock_%=, 4b-1b\n\t" \
+ ".previous\n" \
+ LLL_STUB_UNWIND_INFO_4 \
+ "18:" \
+ : "=m" (futex), "=&a" (ignore), "=&c" (ignore2) \
+ : "i" (FUTEX_WAITERS), "m" (futex), \
+ "g" ((int) (private)) \
+ : "memory"); \
+ })
+
+
+#define lll_robust_dead(futex, private) \
+ (void) \
+ ({ int __ignore; \
+ register int _nr __asm__ ("edx") = 1; \
+ __asm__ __volatile__ (LOCK_INSTR "orl %5, (%2)\n\t" \
+ LLL_EBX_LOAD \
+ LLL_ENTER_KERNEL \
+ LLL_EBX_LOAD \
+ : "=a" (__ignore) \
+ : "0" (SYS_futex), LLL_EBX_REG (&(futex)), \
+ "c" (__lll_private_flag (FUTEX_WAKE, private)), \
+ "d" (_nr), "i" (FUTEX_OWNER_DIED), \
+ "i" (offsetof (tcbhead_t, sysinfo))); \
+ })
+
+#define lll_islocked(futex) \
+ (futex != LLL_LOCK_INITIALIZER)
+
+/* The kernel notifies a process with uses CLONE_CLEARTID via futex
+ wakeup when the clone terminates. The memory location contains the
+ thread ID while the clone is running and is reset to zero
+ afterwards.
+
+ The macro parameter must not have any side effect. */
+#define lll_wait_tid(tid) \
+ do { \
+ int __ignore; \
+ register __typeof (tid) _tid __asm__ ("edx") = (tid); \
+ if (_tid != 0) \
+ __asm__ __volatile__ (LLL_EBX_LOAD \
+ "1:\tmovl %1, %%eax\n\t" \
+ LLL_ENTER_KERNEL \
+ "cmpl $0, (%%ebx)\n\t" \
+ "jne 1b\n\t" \
+ LLL_EBX_LOAD \
+ : "=&a" (__ignore) \
+ : "i" (SYS_futex), LLL_EBX_REG (&tid), "S" (0), \
+ "c" (FUTEX_WAIT), "d" (_tid), \
+ "i" (offsetof (tcbhead_t, sysinfo)) \
+ : "memory"); \
+ } while (0)
+
+extern int __lll_timedwait_tid (int *tid, const struct timespec *abstime)
+ __attribute__ ((regparm (2))) attribute_hidden;
+#define lll_timedwait_tid(tid, abstime) \
+ ({ \
+ int __ret = 0; \
+ if (tid != 0) \
+ { \
+ if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) \
+ __ret = EINVAL; \
+ else \
+ __ret = __lll_timedwait_tid (&tid, abstime); \
+ } \
+ __ret; })
+
+#endif /* !__ASSEMBLER__ */
+
+#endif /* lowlevellock.h */
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/pt-__syscall_error.c b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/pt-__syscall_error.c
new file mode 100644
index 000000000..620640ad6
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/pt-__syscall_error.c
@@ -0,0 +1 @@
+#include <../../../../../../../libc/sysdeps/linux/i386/__syscall_error.c>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/pthread_once.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/pthread_once.S
new file mode 100644
index 000000000..1d1c2bab3
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/pthread_once.S
@@ -0,0 +1,196 @@
+/* Copyright (C) 2002, 2003, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <unwindbuf.h>
+#include <sysdep.h>
+#include <bits/kernel-features.h>
+#include <lowlevellock.h>
+#include <tls.h>
+
+
+ .comm __fork_generation, 4, 4
+
+ .text
+
+
+ .globl __pthread_once
+ .type __pthread_once,@function
+ .protected __pthread_once
+ .align 16
+ cfi_startproc
+__pthread_once:
+ movl 4(%esp), %ecx
+ testl $2, (%ecx)
+ jz 1f
+ xorl %eax, %eax
+ ret
+
+1: pushl %ebx
+ cfi_adjust_cfa_offset (4)
+ cfi_rel_offset (3, 0)
+ pushl %esi
+ cfi_adjust_cfa_offset (4)
+ cfi_rel_offset (6, 0)
+ movl %ecx, %ebx
+ xorl %esi, %esi
+
+ /* Not yet initialized or initialization in progress.
+ Get the fork generation counter now. */
+6: movl (%ebx), %eax
+#ifdef __PIC__
+ call __x86.get_pc_thunk.cx
+ addl $_GLOBAL_OFFSET_TABLE_, %ecx
+#endif
+
+5: movl %eax, %edx
+
+ testl $2, %eax
+ jnz 4f
+
+ andl $3, %edx
+#ifdef __PIC__
+ orl __fork_generation@GOTOFF(%ecx), %edx
+#else
+ orl __fork_generation, %edx
+#endif
+ orl $1, %edx
+
+ LOCK
+ cmpxchgl %edx, (%ebx)
+ jnz 5b
+
+ /* Check whether another thread already runs the initializer. */
+ testl $1, %eax
+ jz 3f /* No -> do it. */
+
+ /* Check whether the initializer execution was interrupted
+ by a fork. */
+ xorl %edx, %eax
+ testl $0xfffffffc, %eax
+ jnz 3f /* Different for generation -> run initializer. */
+
+ /* Somebody else got here first. Wait. */
+#ifdef __ASSUME_PRIVATE_FUTEX
+ movl $FUTEX_WAIT|FUTEX_PRIVATE_FLAG, %ecx
+#else
+# if FUTEX_WAIT == 0
+ movl %gs:PRIVATE_FUTEX, %ecx
+# else
+ movl $FUTEX_WAIT, %ecx
+ orl %gs:PRIVATE_FUTEX, %ecx
+# endif
+#endif
+ movl $SYS_futex, %eax
+ ENTER_KERNEL
+ jmp 6b
+
+3: /* Call the initializer function after setting up the
+ cancellation handler. Note that it is not possible here
+ to use the unwind-based cleanup handling. This would require
+ that the user-provided function and all the code it calls
+ is compiled with exceptions. Unfortunately this cannot be
+ guaranteed. */
+ subl $UNWINDBUFSIZE+8, %esp
+ cfi_adjust_cfa_offset (UNWINDBUFSIZE+8)
+ movl %ecx, %ebx /* PIC register value. */
+
+ leal 8+UWJMPBUF(%esp), %eax
+ movl $0, 4(%esp)
+ movl %eax, (%esp)
+ call __sigsetjmp@PLT
+ testl %eax, %eax
+ jne 7f
+
+ leal 8(%esp), %eax
+ call HIDDEN_JUMPTARGET(__pthread_register_cancel)
+
+ /* Call the user-provided initialization function. */
+ call *24+UNWINDBUFSIZE(%esp)
+
+ /* Pop the cleanup handler. */
+ leal 8(%esp), %eax
+ call HIDDEN_JUMPTARGET(__pthread_unregister_cancel)
+ addl $UNWINDBUFSIZE+8, %esp
+ cfi_adjust_cfa_offset (-UNWINDBUFSIZE-8)
+
+ /* Sucessful run of the initializer. Signal that we are done. */
+ movl 12(%esp), %ebx
+ LOCK
+ addl $1, (%ebx)
+
+ /* Wake up all other threads. */
+ movl $0x7fffffff, %edx
+#ifdef __ASSUME_PRIVATE_FUTEX
+ movl $FUTEX_WAKE|FUTEX_PRIVATE_FLAG, %ecx
+#else
+ movl $FUTEX_WAKE, %ecx
+ orl %gs:PRIVATE_FUTEX, %ecx
+#endif
+ movl $SYS_futex, %eax
+ ENTER_KERNEL
+
+4: popl %esi
+ cfi_adjust_cfa_offset (-4)
+ cfi_restore (6)
+ popl %ebx
+ cfi_adjust_cfa_offset (-4)
+ cfi_restore (3)
+ xorl %eax, %eax
+ ret
+
+7: /* __sigsetjmp returned for the second time. */
+ movl 20+UNWINDBUFSIZE(%esp), %ebx
+ cfi_adjust_cfa_offset (UNWINDBUFSIZE+16)
+ cfi_offset (3, -8)
+ cfi_offset (6, -12)
+ movl $0, (%ebx)
+
+ movl $0x7fffffff, %edx
+#ifdef __ASSUME_PRIVATE_FUTEX
+ movl $FUTEX_WAKE|FUTEX_PRIVATE_FLAG, %ecx
+#else
+ movl $FUTEX_WAKE, %ecx
+ orl %gs:PRIVATE_FUTEX, %ecx
+#endif
+ movl $SYS_futex, %eax
+ ENTER_KERNEL
+
+ leal 8(%esp), %eax
+ call HIDDEN_JUMPTARGET (__pthread_unwind_next)
+ /* NOTREACHED */
+ hlt
+ cfi_endproc
+ .size __pthread_once,.-__pthread_once
+
+ .globl __pthread_once_internal
+__pthread_once_internal = __pthread_once
+
+ .globl pthread_once
+pthread_once = __pthread_once
+
+
+#ifdef __PIC__
+ .section .gnu.linkonce.t.__x86.get_pc_thunk.cx,"ax",@progbits
+ .globl __x86.get_pc_thunk.cx
+ .hidden __x86.get_pc_thunk.cx
+ .type __x86.get_pc_thunk.cx,@function
+__x86.get_pc_thunk.cx:
+ movl (%esp), %ecx;
+ ret
+ .size __x86.get_pc_thunk.cx,.-__x86.get_pc_thunk.cx
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/pthread_spin_init.c b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/pthread_spin_init.c
new file mode 100644
index 000000000..d36e5373d
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/pthread_spin_init.c
@@ -0,0 +1 @@
+#include <sysdeps/i386/pthread_spin_init.c>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/pthread_spin_unlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/pthread_spin_unlock.S
new file mode 100644
index 000000000..8bae0fd31
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/pthread_spin_unlock.S
@@ -0,0 +1 @@
+#include <sysdeps/i386/pthread_spin_unlock.S>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/smp.h b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/smp.h
new file mode 100644
index 000000000..2ed2cab8e
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/smp.h
@@ -0,0 +1,55 @@
+/* Determine whether the host has multiple processors. Linux version.
+ Copyright (C) 1996, 2002, 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 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/>. */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/utsname.h>
+#include <not-cancel.h>
+
+/* Test whether the machine has more than one processor. This is not the
+ best test but good enough. More complicated tests would require `malloc'
+ which is not available at that time. */
+static inline int
+is_smp_system (void)
+{
+ union
+ {
+ struct utsname uts;
+ char buf[512];
+ } u;
+ char *cp;
+
+ /* Try reading the number using `sysctl' first. */
+ if (uname (&u.uts) == 0)
+ cp = u.uts.version;
+ else
+ {
+ /* This was not successful. Now try reading the /proc filesystem. */
+ int fd = open_not_cancel_2 ("/proc/sys/kernel/version", O_RDONLY);
+ if (__builtin_expect (fd, 0) == -1
+ || read_not_cancel (fd, u.buf, sizeof (u.buf)) <= 0)
+ /* This also didn't work. We give up and say it's a UP machine. */
+ u.buf[0] = '\0';
+
+ close_not_cancel_no_status (fd);
+ cp = u.buf;
+ }
+
+ return strstr (cp, "SMP") != NULL;
+}
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h
new file mode 100644
index 000000000..b0eb02600
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h
@@ -0,0 +1,154 @@
+/* Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 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 <tls.h>
+#ifndef __ASSEMBLER__
+# include <pthreadP.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .text; \
+ ENTRY (name) \
+ cmpl $0, %gs:MULTIPLE_THREADS_OFFSET; \
+ jne L(pseudo_cancel); \
+ .type __##syscall_name##_nocancel,@function; \
+ .globl __##syscall_name##_nocancel; \
+ __##syscall_name##_nocancel: \
+ DO_CALL (syscall_name, args); \
+ cmpl $-4095, %eax; \
+ jae SYSCALL_ERROR_LABEL; \
+ ret; \
+ .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
+ L(pseudo_cancel): \
+ CENABLE \
+ SAVE_OLDTYPE_##args \
+ PUSHCARGS_##args \
+ DOCARGS_##args \
+ movl $SYS_ify (syscall_name), %eax; \
+ ENTER_KERNEL; \
+ POPCARGS_##args; \
+ POPSTATE_##args \
+ cmpl $-4095, %eax; \
+ jae SYSCALL_ERROR_LABEL; \
+ L(pseudo_end):
+
+# define SAVE_OLDTYPE_0 movl %eax, %ecx;
+# define SAVE_OLDTYPE_1 SAVE_OLDTYPE_0
+# define SAVE_OLDTYPE_2 pushl %eax; cfi_adjust_cfa_offset (4);
+# define SAVE_OLDTYPE_3 SAVE_OLDTYPE_2
+# define SAVE_OLDTYPE_4 SAVE_OLDTYPE_2
+# define SAVE_OLDTYPE_5 SAVE_OLDTYPE_2
+# define SAVE_OLDTYPE_6 SAVE_OLDTYPE_2
+
+# define PUSHCARGS_0 /* No arguments to push. */
+# define DOCARGS_0 /* No arguments to frob. */
+# define POPCARGS_0 /* No arguments to pop. */
+# define _PUSHCARGS_0 /* No arguments to push. */
+# define _POPCARGS_0 /* No arguments to pop. */
+
+# define PUSHCARGS_1 movl %ebx, %edx; cfi_register (ebx, edx); PUSHCARGS_0
+# define DOCARGS_1 _DOARGS_1 (4)
+# define POPCARGS_1 POPCARGS_0; movl %edx, %ebx; cfi_restore (ebx);
+# define _PUSHCARGS_1 pushl %ebx; cfi_adjust_cfa_offset (4); \
+ cfi_rel_offset (ebx, 0); _PUSHCARGS_0
+# define _POPCARGS_1 _POPCARGS_0; popl %ebx; \
+ cfi_adjust_cfa_offset (-4); cfi_restore (ebx);
+
+# define PUSHCARGS_2 PUSHCARGS_1
+# define DOCARGS_2 _DOARGS_2 (12)
+# define POPCARGS_2 POPCARGS_1
+# define _PUSHCARGS_2 _PUSHCARGS_1
+# define _POPCARGS_2 _POPCARGS_1
+
+# define PUSHCARGS_3 _PUSHCARGS_2
+# define DOCARGS_3 _DOARGS_3 (20)
+# define POPCARGS_3 _POPCARGS_3
+# define _PUSHCARGS_3 _PUSHCARGS_2
+# define _POPCARGS_3 _POPCARGS_2
+
+# define PUSHCARGS_4 _PUSHCARGS_4
+# define DOCARGS_4 _DOARGS_4 (28)
+# define POPCARGS_4 _POPCARGS_4
+# define _PUSHCARGS_4 pushl %esi; cfi_adjust_cfa_offset (4); \
+ cfi_rel_offset (esi, 0); _PUSHCARGS_3
+# define _POPCARGS_4 _POPCARGS_3; popl %esi; \
+ cfi_adjust_cfa_offset (-4); cfi_restore (esi);
+
+# define PUSHCARGS_5 _PUSHCARGS_5
+# define DOCARGS_5 _DOARGS_5 (36)
+# define POPCARGS_5 _POPCARGS_5
+# define _PUSHCARGS_5 pushl %edi; cfi_adjust_cfa_offset (4); \
+ cfi_rel_offset (edi, 0); _PUSHCARGS_4
+# define _POPCARGS_5 _POPCARGS_4; popl %edi; \
+ cfi_adjust_cfa_offset (-4); cfi_restore (edi);
+
+# define PUSHCARGS_6 _PUSHCARGS_6
+# define DOCARGS_6 _DOARGS_6 (44)
+# define POPCARGS_6 _POPCARGS_6
+# define _PUSHCARGS_6 pushl %ebp; cfi_adjust_cfa_offset (4); \
+ cfi_rel_offset (ebp, 0); _PUSHCARGS_5
+# define _POPCARGS_6 _POPCARGS_5; popl %ebp; \
+ cfi_adjust_cfa_offset (-4); cfi_restore (ebp);
+
+# ifdef IS_IN_libpthread
+# define CENABLE call __pthread_enable_asynccancel;
+# define CDISABLE call __pthread_disable_asynccancel
+# elif !defined NOT_IN_libc
+# define CENABLE call __libc_enable_asynccancel;
+# define CDISABLE call __libc_disable_asynccancel
+# elif defined IS_IN_librt
+# define CENABLE call __librt_enable_asynccancel;
+# define CDISABLE call __librt_disable_asynccancel
+# else
+# error Unsupported library
+# endif
+# define POPSTATE_0 \
+ pushl %eax; cfi_adjust_cfa_offset (4); movl %ecx, %eax; \
+ CDISABLE; popl %eax; cfi_adjust_cfa_offset (-4);
+# define POPSTATE_1 POPSTATE_0
+# define POPSTATE_2 xchgl (%esp), %eax; CDISABLE; popl %eax; \
+ cfi_adjust_cfa_offset (-4);
+# define POPSTATE_3 POPSTATE_2
+# define POPSTATE_4 POPSTATE_3
+# define POPSTATE_5 POPSTATE_4
+# define POPSTATE_6 POPSTATE_5
+
+# ifndef __ASSEMBLER__
+# define SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+# else
+# define SINGLE_THREAD_P cmpl $0, %gs:MULTIPLE_THREADS_OFFSET
+# endif
+
+#elif !defined __ASSEMBLER__
+
+# define SINGLE_THREAD_P (1)
+# define NO_CANCELLATION 1
+
+#endif
+
+#ifndef __ASSEMBLER__
+# define RTLD_SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/vfork.S
new file mode 100644
index 000000000..074f0f046
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/vfork.S
@@ -0,0 +1,37 @@
+/* Copyright (C) 1999,2002,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/>. */
+
+#include <tcb-offsets.h>
+
+/* Save the PID value. */
+#define SAVE_PID \
+ movl %gs:PID, %edx; \
+ movl %edx, %eax; \
+ negl %eax; \
+ jne 1f; \
+ movl $0x80000000, %eax; \
+1: movl %eax, %gs:PID
+
+/* Restore the old PID value in the parent. */
+#define RESTORE_PID \
+ testl %eax, %eax; \
+ je 1f; \
+ movl %edx, %gs:PID; \
+1:
+
+
+#include <libc/sysdeps/linux/i386/vfork.S>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/internaltypes.h b/libpthread/nptl/sysdeps/unix/sysv/linux/internaltypes.h
new file mode 100644
index 000000000..1305030c5
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/internaltypes.h
@@ -0,0 +1,161 @@
+/* Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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/>. */
+
+#ifndef _INTERNALTYPES_H
+#define _INTERNALTYPES_H 1
+
+#include <stdint.h>
+#include <sched.h>
+
+struct pthread_attr
+{
+ /* Scheduler parameters and priority. */
+ struct sched_param schedparam;
+ int schedpolicy;
+ /* Various flags like detachstate, scope, etc. */
+ int flags;
+ /* Size of guard area. */
+ size_t guardsize;
+ /* Stack handling. */
+ void *stackaddr;
+ size_t stacksize;
+ /* Affinity map. */
+ cpu_set_t *cpuset;
+ size_t cpusetsize;
+};
+
+#define ATTR_FLAG_DETACHSTATE 0x0001
+#define ATTR_FLAG_NOTINHERITSCHED 0x0002
+#define ATTR_FLAG_SCOPEPROCESS 0x0004
+#define ATTR_FLAG_STACKADDR 0x0008
+#define ATTR_FLAG_OLDATTR 0x0010
+#define ATTR_FLAG_SCHED_SET 0x0020
+#define ATTR_FLAG_POLICY_SET 0x0040
+
+
+/* Mutex attribute data structure. */
+struct pthread_mutexattr
+{
+ /* Identifier for the kind of mutex.
+
+ Bit 31 is set if the mutex is to be shared between processes.
+
+ Bit 0 to 30 contain one of the PTHREAD_MUTEX_ values to identify
+ the type of the mutex. */
+ int mutexkind;
+};
+
+
+/* Conditional variable attribute data structure. */
+struct pthread_condattr
+{
+ /* Combination of values:
+
+ Bit 0 : flag whether coditional variable will be shareable between
+ processes.
+
+ Bit 1-7: clock ID. */
+ int value;
+};
+
+
+/* The __NWAITERS field is used as a counter and to house the number
+ of bits for other purposes. COND_CLOCK_BITS is the number
+ of bits needed to represent the ID of the clock. COND_NWAITERS_SHIFT
+ is the number of bits reserved for other purposes like the clock. */
+#define COND_CLOCK_BITS 1
+#define COND_NWAITERS_SHIFT 1
+
+
+/* Read-write lock variable attribute data structure. */
+struct pthread_rwlockattr
+{
+ int lockkind;
+ int pshared;
+};
+
+
+/* Barrier data structure. */
+struct pthread_barrier
+{
+ unsigned int curr_event;
+ int lock;
+ unsigned int left;
+ unsigned int init_count;
+ int private;
+};
+
+
+/* Barrier variable attribute data structure. */
+struct pthread_barrierattr
+{
+ int pshared;
+};
+
+
+/* Thread-local data handling. */
+struct pthread_key_struct
+{
+ /* Sequence numbers. Even numbers indicated vacant entries. Note
+ that zero is even. We use uintptr_t to not require padding on
+ 32- and 64-bit machines. On 64-bit machines it helps to avoid
+ wrapping, too. */
+ uintptr_t seq;
+
+ /* Destructor for the data. */
+ void (*destr) (void *);
+};
+
+/* Check whether an entry is unused. */
+#define KEY_UNUSED(p) (((p) & 1) == 0)
+/* Check whether a key is usable. We cannot reuse an allocated key if
+ the sequence counter would overflow after the next destroy call.
+ This would mean that we potentially free memory for a key with the
+ same sequence. This is *very* unlikely to happen, A program would
+ have to create and destroy a key 2^31 times (on 32-bit platforms,
+ on 64-bit platforms that would be 2^63). If it should happen we
+ simply don't use this specific key anymore. */
+#define KEY_USABLE(p) (((uintptr_t) (p)) < ((uintptr_t) ((p) + 2)))
+
+
+/* Handling of read-write lock data. */
+// XXX For now there is only one flag. Maybe more in future.
+#define RWLOCK_RECURSIVE(rwlock) ((rwlock)->__data.__flags != 0)
+
+
+/* Semaphore variable structure. */
+struct new_sem
+{
+ unsigned int value;
+ int private;
+ unsigned long int nwaiters;
+};
+
+struct old_sem
+{
+ unsigned int value;
+};
+
+
+/* Compatibility type for old conditional variable interfaces. */
+typedef struct
+{
+ pthread_cond_t *cond;
+} pthread_cond_2_0_t;
+
+#endif /* internaltypes.h */
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/jmp-unwind.c b/libpthread/nptl/sysdeps/unix/sysv/linux/jmp-unwind.c
new file mode 100644
index 000000000..67587f489
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/jmp-unwind.c
@@ -0,0 +1,39 @@
+/* Clean up stack frames unwound by longjmp. Linux version.
+ Copyright (C) 1995, 1997, 2002, 2003, 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 <setjmp.h>
+#include <stddef.h>
+#include <pthreadP.h>
+
+extern void __pthread_cleanup_upto (__jmp_buf env, char *targetframe);
+#pragma weak __pthread_cleanup_upto
+
+
+void
+_longjmp_unwind (jmp_buf env, int val)
+{
+#ifdef SHARED
+ if (__libc_pthread_functions_init)
+ PTHFCT_CALL (ptr___pthread_cleanup_upto, (env->__jmpbuf,
+ CURRENT_STACK_FRAME));
+#else
+ if (__pthread_cleanup_upto != NULL)
+ __pthread_cleanup_upto (env->__jmpbuf, CURRENT_STACK_FRAME);
+#endif
+}
+libc_hidden_def(_longjmp_unwind)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/kernel-posix-timers.h b/libpthread/nptl/sysdeps/unix/sysv/linux/kernel-posix-timers.h
new file mode 100644
index 000000000..9be630268
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/kernel-posix-timers.h
@@ -0,0 +1 @@
+#include <../../../../../../librt/kernel-posix-timers.h>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/libc-lowlevellock.c b/libpthread/nptl/sysdeps/unix/sysv/linux/libc-lowlevellock.c
new file mode 100644
index 000000000..28672a65f
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/libc-lowlevellock.c
@@ -0,0 +1,20 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Paul Mackerras <paulus@au.ibm.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/>. */
+
+/* No difference to lowlevellock.c, except we lose a couple of functions. */
+#include "lowlevellock.c"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/libc_multiple_threads.c b/libpthread/nptl/sysdeps/unix/sysv/linux/libc_multiple_threads.c
new file mode 100644
index 000000000..7fffb0d80
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/libc_multiple_threads.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthreadP.h>
+
+#ifndef NOT_IN_libc
+# ifndef TLS_MULTIPLE_THREADS_IN_TCB
+int __libc_multiple_threads attribute_hidden;
+# endif
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/libc_pthread_init.c b/libpthread/nptl/sysdeps/unix/sysv/linux/libc_pthread_init.c
new file mode 100644
index 000000000..cc8d39090
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/libc_pthread_init.c
@@ -0,0 +1,73 @@
+/* Copyright (C) 2002,2003,2005,2006,2007,2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <unistd.h>
+#include <list.h>
+#include <fork.h>
+#include <dl-sysdep.h>
+#include <tls.h>
+#include <string.h>
+#include <pthreadP.h>
+#include <bits/libc-lock.h>
+#include <sysdep.h>
+#include <ldsodefs.h>
+
+
+#ifdef TLS_MULTIPLE_THREADS_IN_TCB
+void
+#else
+extern int __libc_multiple_threads attribute_hidden;
+
+int *
+#endif
+__libc_pthread_init (
+ unsigned long int *ptr,
+ void (*reclaim) (void),
+ const struct pthread_functions *functions)
+{
+ /* Remember the pointer to the generation counter in libpthread. */
+ __fork_generation_pointer = ptr;
+
+ /* Called by a child after fork. */
+ __register_atfork (NULL, NULL, reclaim, NULL);
+
+#ifdef SHARED
+ /* We copy the content of the variable pointed to by the FUNCTIONS
+ parameter to one in libc.so since this means access to the array
+ can be done with one memory access instead of two.
+ */
+ memcpy (&__libc_pthread_functions, functions,
+ sizeof (__libc_pthread_functions));
+ __libc_pthread_functions_init = 1;
+#endif
+
+#ifndef TLS_MULTIPLE_THREADS_IN_TCB
+ return &__libc_multiple_threads;
+#endif
+}
+
+#ifdef SHARED
+#if 0
+void
+libc_freeres_fn (freeres_libptread)
+{
+ if (__libc_pthread_functions_init)
+ PTHFCT_CALL (ptr_freeres, ());
+}
+#endif
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/lowlevelbarrier.sym b/libpthread/nptl/sysdeps/unix/sysv/linux/lowlevelbarrier.sym
new file mode 100644
index 000000000..cfe22b089
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/lowlevelbarrier.sym
@@ -0,0 +1,12 @@
+#include <stddef.h>
+#include <sched.h>
+#include <bits/pthreadtypes.h>
+#include "internaltypes.h"
+
+--
+
+CURR_EVENT offsetof (struct pthread_barrier, curr_event)
+MUTEX offsetof (struct pthread_barrier, lock)
+LEFT offsetof (struct pthread_barrier, left)
+INIT_COUNT offsetof (struct pthread_barrier, init_count)
+PRIVATE offsetof (struct pthread_barrier, private)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/lowlevelcond.sym b/libpthread/nptl/sysdeps/unix/sysv/linux/lowlevelcond.sym
new file mode 100644
index 000000000..18e1adad4
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/lowlevelcond.sym
@@ -0,0 +1,16 @@
+#include <stddef.h>
+#include <sched.h>
+#include <bits/pthreadtypes.h>
+#include <internaltypes.h>
+
+--
+
+cond_lock offsetof (pthread_cond_t, __data.__lock)
+cond_futex offsetof (pthread_cond_t, __data.__futex)
+cond_nwaiters offsetof (pthread_cond_t, __data.__nwaiters)
+total_seq offsetof (pthread_cond_t, __data.__total_seq)
+wakeup_seq offsetof (pthread_cond_t, __data.__wakeup_seq)
+woken_seq offsetof (pthread_cond_t, __data.__woken_seq)
+dep_mutex offsetof (pthread_cond_t, __data.__mutex)
+broadcast_seq offsetof (pthread_cond_t, __data.__broadcast_seq)
+nwaiters_shift COND_NWAITERS_SHIFT
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/lowlevellock.c b/libpthread/nptl/sysdeps/unix/sysv/linux/lowlevellock.c
new file mode 100644
index 000000000..75369bd70
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/lowlevellock.c
@@ -0,0 +1,127 @@
+/* low level locking for pthread library. Generic futex-using version.
+ Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Paul Mackerras <paulus@au.ibm.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 <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <sys/time.h>
+#include <tls.h>
+
+void
+#ifndef IS_IN_libpthread
+weak_function
+#endif
+__lll_lock_wait_private (int *futex)
+{
+ if (*futex == 2)
+ lll_futex_wait (futex, 2, LLL_PRIVATE);
+
+ while (atomic_exchange_acq (futex, 2) != 0)
+ lll_futex_wait (futex, 2, LLL_PRIVATE);
+}
+
+
+/* These functions don't get included in libc.so */
+#ifdef IS_IN_libpthread
+void
+__lll_lock_wait (int *futex, int private)
+{
+ if (*futex == 2)
+ lll_futex_wait (futex, 2, private);
+
+ while (atomic_exchange_acq (futex, 2) != 0)
+ lll_futex_wait (futex, 2, private);
+}
+
+
+int
+__lll_timedlock_wait (int *futex, const struct timespec *abstime, int private)
+{
+ /* Reject invalid timeouts. */
+ if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
+ return EINVAL;
+
+ /* Try locking. */
+ while (atomic_exchange_acq (futex, 2) != 0)
+ {
+ struct timeval tv;
+
+ /* Get the current time. */
+ (void) gettimeofday (&tv, NULL);
+
+ /* Compute relative timeout. */
+ struct timespec rt;
+ rt.tv_sec = abstime->tv_sec - tv.tv_sec;
+ rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+ if (rt.tv_nsec < 0)
+ {
+ rt.tv_nsec += 1000000000;
+ --rt.tv_sec;
+ }
+
+ if (rt.tv_sec < 0)
+ return ETIMEDOUT;
+
+ /* Wait. */
+ lll_futex_timed_wait (futex, 2, &rt, private);
+ }
+
+ return 0;
+}
+
+
+int
+__lll_timedwait_tid (int *tidp, const struct timespec *abstime)
+{
+ int tid;
+
+ if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
+ return EINVAL;
+
+ /* Repeat until thread terminated. */
+ while ((tid = *tidp) != 0)
+ {
+ struct timeval tv;
+ struct timespec rt;
+
+ /* Get the current time. */
+ (void) __gettimeofday (&tv, NULL);
+
+ /* Compute relative timeout. */
+ rt.tv_sec = abstime->tv_sec - tv.tv_sec;
+ rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+ if (rt.tv_nsec < 0)
+ {
+ rt.tv_nsec += 1000000000;
+ --rt.tv_sec;
+ }
+
+ /* Already timed out? */
+ if (rt.tv_sec < 0)
+ return ETIMEDOUT;
+
+ /* Wait until thread terminates. The kernel so far does not use
+ the private futex operations for this. */
+ if (lll_futex_timed_wait (tidp, tid, &rt, LLL_SHARED) == -ETIMEDOUT)
+ return ETIMEDOUT;
+ }
+
+ return 0;
+}
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c b/libpthread/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c
new file mode 100644
index 000000000..7b4e84343
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.c
@@ -0,0 +1,113 @@
+/* Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2006.
+
+ 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 <sysdep.h>
+#include <lowlevellock.h>
+#include <sys/time.h>
+#include <pthreadP.h>
+
+
+int
+__lll_robust_lock_wait (int *futex, int private)
+{
+ int oldval = *futex;
+ int tid = THREAD_GETMEM (THREAD_SELF, tid);
+
+ /* If the futex changed meanwhile try locking again. */
+ if (oldval == 0)
+ goto try;
+
+ do
+ {
+ if (__builtin_expect (oldval & FUTEX_OWNER_DIED, 0))
+ return oldval;
+
+ int newval = oldval | FUTEX_WAITERS;
+ if (oldval != newval
+ && atomic_compare_and_exchange_bool_acq (futex, newval, oldval))
+ continue;
+
+ lll_futex_wait (futex, newval, private);
+
+ try:
+ ;
+ }
+ while ((oldval = atomic_compare_and_exchange_val_acq (futex,
+ tid | FUTEX_WAITERS,
+ 0)) != 0);
+ return 0;
+}
+
+
+int
+__lll_robust_timedlock_wait (int *futex, const struct timespec *abstime,
+ int private)
+{
+ /* Reject invalid timeouts. */
+ if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
+ return EINVAL;
+
+ int tid = THREAD_GETMEM (THREAD_SELF, tid);
+ int oldval = *futex;
+
+ /* If the futex changed meanwhile try locking again. */
+ if (oldval == 0)
+ goto try;
+
+ do
+ {
+ struct timeval tv;
+ struct timespec rt;
+
+ /* Get the current time. */
+ (void) __gettimeofday (&tv, NULL);
+
+ /* Compute relative timeout. */
+ rt.tv_sec = abstime->tv_sec - tv.tv_sec;
+ rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+ if (rt.tv_nsec < 0)
+ {
+ rt.tv_nsec += 1000000000;
+ --rt.tv_sec;
+ }
+
+ /* Already timed out? */
+ if (rt.tv_sec < 0)
+ return ETIMEDOUT;
+
+ /* Wait. */
+ if (__builtin_expect (oldval & FUTEX_OWNER_DIED, 0))
+ return oldval;
+
+ int newval = oldval | FUTEX_WAITERS;
+ if (oldval != newval
+ && atomic_compare_and_exchange_bool_acq (futex, newval, oldval))
+ continue;
+
+ lll_futex_timed_wait (futex, newval, &rt, private);
+
+ try:
+ ;
+ }
+ while ((oldval = atomic_compare_and_exchange_val_acq (futex,
+ tid | FUTEX_WAITERS,
+ 0)) != 0);
+
+ return 0;
+}
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.sym b/libpthread/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.sym
new file mode 100644
index 000000000..2f1e9da52
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/lowlevelrobustlock.sym
@@ -0,0 +1,6 @@
+#include <stddef.h>
+#include <pthreadP.h>
+
+--
+
+TID offsetof (struct pthread, tid)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/lowlevelrwlock.sym b/libpthread/nptl/sysdeps/unix/sysv/linux/lowlevelrwlock.sym
new file mode 100644
index 000000000..f50b25bfb
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/lowlevelrwlock.sym
@@ -0,0 +1,16 @@
+#include <stddef.h>
+#include <stdio.h>
+#include <bits/pthreadtypes.h>
+#include <bits/wordsize.h>
+
+--
+
+MUTEX offsetof (pthread_rwlock_t, __data.__lock)
+NR_READERS offsetof (pthread_rwlock_t, __data.__nr_readers)
+READERS_WAKEUP offsetof (pthread_rwlock_t, __data.__readers_wakeup)
+WRITERS_WAKEUP offsetof (pthread_rwlock_t, __data.__writer_wakeup)
+READERS_QUEUED offsetof (pthread_rwlock_t, __data.__nr_readers_queued)
+WRITERS_QUEUED offsetof (pthread_rwlock_t, __data.__nr_writers_queued)
+FLAGS offsetof (pthread_rwlock_t, __data.__flags)
+WRITER offsetof (pthread_rwlock_t, __data.__writer)
+PSHARED offsetof (pthread_rwlock_t, __data.__shared)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/lseek.S b/libpthread/nptl/sysdeps/unix/sysv/linux/lseek.S
new file mode 100644
index 000000000..70a920ba1
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/lseek.S
@@ -0,0 +1,7 @@
+#include <sysdep-cancel.h>
+PSEUDO (__libc_lseek, lseek, 3)
+ret
+PSEUDO_END (__libc_lseek)
+libc_hidden_def (__libc_lseek)
+weak_alias (__libc_lseek, lseek)
+libc_hidden_weak (lseek)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/metag/Makefile b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/Makefile
new file mode 100644
index 000000000..729adf6f9
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/Makefile
@@ -0,0 +1,13 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2005 Steven J. Hill <sjhill@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/libpthread/nptl/sysdeps/unix/sysv/linux/metag/Makefile.arch b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/Makefile.arch
new file mode 100644
index 000000000..ddc768085
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/Makefile.arch
@@ -0,0 +1,18 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2006 Steven J. Hill <sjhill@uclibc.org>
+#
+# Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+#
+
+libpthread_linux_arch_SSRC =
+libpthread_linux_arch_CSRC = pthread_once.c \
+ pt-__syscall_rt_sigaction.c pt-__syscall_error.c \
+ lowlevellock.c
+
+libc_linux_arch_CSRC = fork.c libc-lowlevellock.c
+libc_linux_arch_SSRC = clone.S vfork.S
+libc_linux_arch_SSRC-OMIT = waitpid.S
+
+CFLAGS += $(SSP_ALL_CFLAGS)
+
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/metag/bits/pthreadtypes.h b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/bits/pthreadtypes.h
new file mode 100644
index 000000000..e1b115c8c
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/bits/pthreadtypes.h
@@ -0,0 +1,181 @@
+/* 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 _BITS_PTHREADTYPES_H
+#define _BITS_PTHREADTYPES_H 1
+
+#include <endian.h>
+
+#define __SIZEOF_PTHREAD_ATTR_T 36
+#define __SIZEOF_PTHREAD_MUTEX_T 24
+#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
+#define __SIZEOF_PTHREAD_COND_T 48
+#define __SIZEOF_PTHREAD_COND_COMPAT_T 12
+#define __SIZEOF_PTHREAD_CONDATTR_T 4
+#define __SIZEOF_PTHREAD_RWLOCK_T 32
+#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
+#define __SIZEOF_PTHREAD_BARRIER_T 20
+#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
+
+
+/* Thread identifiers. The structure of the attribute type is not
+ exposed on purpose. */
+typedef unsigned long int pthread_t;
+
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_ATTR_T];
+ long int __align;
+} pthread_attr_t;
+
+
+typedef struct __pthread_internal_slist
+{
+ struct __pthread_internal_slist *__next;
+} __pthread_slist_t;
+
+
+/* Data structures for mutex handling. The structure of the attribute
+ type is not exposed on purpose. */
+typedef union
+{
+ struct __pthread_mutex_s
+ {
+ int __lock;
+ unsigned int __count;
+ int __owner;
+ /* KIND must stay at this position in the structure to maintain
+ binary compatibility. */
+ int __kind;
+ unsigned int __nusers;
+ __extension__ union
+ {
+ int __spins;
+ __pthread_slist_t __list;
+ };
+ } __data;
+ char __size[__SIZEOF_PTHREAD_MUTEX_T];
+ long int __align;
+} pthread_mutex_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
+ long int __align;
+} pthread_mutexattr_t;
+
+
+/* Data structure for conditional variable handling. The structure of
+ the attribute type is not exposed on purpose. */
+typedef union
+{
+ struct
+ {
+ int __lock;
+ unsigned int __futex;
+ __extension__ unsigned long long int __total_seq;
+ __extension__ unsigned long long int __wakeup_seq;
+ __extension__ unsigned long long int __woken_seq;
+ void *__mutex;
+ unsigned int __nwaiters;
+ unsigned int __broadcast_seq;
+ } __data;
+ char __size[__SIZEOF_PTHREAD_COND_T];
+ __extension__ long long int __align;
+} pthread_cond_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_CONDATTR_T];
+ long int __align;
+} pthread_condattr_t;
+
+
+/* Keys for thread-specific data */
+typedef unsigned int pthread_key_t;
+
+
+/* Once-only execution */
+typedef int pthread_once_t;
+
+
+#if defined __USE_UNIX98 || defined __USE_XOPEN2K
+/* Data structure for read-write lock variable handling. The
+ structure of the attribute type is not exposed on purpose. */
+typedef union
+{
+ struct
+ {
+ int __lock;
+ unsigned int __nr_readers;
+ unsigned int __readers_wakeup;
+ unsigned int __writer_wakeup;
+ unsigned int __nr_readers_queued;
+ unsigned int __nr_writers_queued;
+#if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned char __pad1;
+ unsigned char __pad2;
+ unsigned char __shared;
+ /* FLAGS must stay at this position in the structure to maintain
+ binary compatibility. */
+ unsigned char __flags;
+#else
+ /* FLAGS must stay at this position in the structure to maintain
+ binary compatibility. */
+ unsigned char __flags;
+ unsigned char __shared;
+ unsigned char __pad1;
+ unsigned char __pad2;
+#endif
+ int __writer;
+ } __data;
+ char __size[__SIZEOF_PTHREAD_RWLOCK_T];
+ long int __align;
+} pthread_rwlock_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
+ long int __align;
+} pthread_rwlockattr_t;
+#endif
+
+
+#ifdef __USE_XOPEN2K
+/* POSIX spinlock data type. */
+typedef volatile int pthread_spinlock_t;
+
+
+/* POSIX barriers data type. The structure of the type is
+ deliberately not exposed. */
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_BARRIER_T];
+ long int __align;
+} pthread_barrier_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];
+ int __align;
+} pthread_barrierattr_t;
+#endif
+
+
+#endif /* bits/pthreadtypes.h */
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/metag/bits/semaphore.h b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/bits/semaphore.h
new file mode 100644
index 000000000..dadfac2af
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/bits/semaphore.h
@@ -0,0 +1,35 @@
+/* Copyright (C) 2002, 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., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SEMAPHORE_H
+# error "Never use <bits/semaphore.h> directly; include <semaphore.h> instead."
+#endif
+
+
+#define __SIZEOF_SEM_T 16
+
+
+/* Value returned if `sem_open' failed. */
+#define SEM_FAILED ((sem_t *) 0)
+
+
+typedef union
+{
+ char __size[__SIZEOF_SEM_T];
+ long int __align;
+} sem_t;
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/metag/clone.S b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/clone.S
new file mode 100644
index 000000000..f5c5c7c5d
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/clone.S
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2013 Imagination Technologies Ltd.
+ *
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+#define RESET_PID
+#include <tcb-offsets.h>
+#include "../../../../../../../libc/sysdeps/linux/metag/clone.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/metag/createthread.c b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/createthread.c
new file mode 100644
index 000000000..2d4355980
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/createthread.c
@@ -0,0 +1,23 @@
+/* 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* Value passed to 'clone' for initialization of the thread register. */
+#define TLS_VALUE (pd + 1)
+
+/* Get the real implementation. */
+#include <sysdeps/pthread/createthread.c>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/metag/fork.c b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/fork.c
new file mode 100644
index 000000000..41776f9bc
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/fork.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Phil Blundell <pb@nexus.co.uk>, 2005
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sched.h>
+#include <signal.h>
+#include <sysdep.h>
+#include <tls.h>
+
+
+#define ARCH_FORK() \
+ INLINE_SYSCALL (clone, 5, \
+ CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID | SIGCHLD, \
+ NULL, NULL, &THREAD_SELF->tid, NULL)
+
+#include "../fork.c"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/metag/libc-lowlevellock.c b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/libc-lowlevellock.c
new file mode 100644
index 000000000..b19282281
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/libc-lowlevellock.c
@@ -0,0 +1,21 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Paul Mackerras <paulus@au.ibm.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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* No difference to lowlevellock.c, except we lose a couple of functions. */
+#include "lowlevellock.c"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/metag/lowlevellock.c b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/lowlevellock.c
new file mode 100644
index 000000000..960e02941
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/lowlevellock.c
@@ -0,0 +1,137 @@
+/* low level locking for pthread library. Generic futex-using version.
+ Copyright (C) 2003, 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., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <sys/time.h>
+#include <tls.h>
+
+void
+#ifndef IS_IN_libpthread
+weak_function
+#endif
+__lll_lock_wait_private (int *futex)
+{
+ do
+ {
+ int oldval = atomic_compare_and_exchange_val_acq (futex, 2, 1);
+ if (oldval != 0)
+ lll_futex_wait (futex, 2, LLL_PRIVATE);
+ }
+ while (atomic_compare_and_exchange_bool_acq (futex, 2, 0) != 0);
+}
+
+
+/* These functions don't get included in libc.so */
+#ifdef IS_IN_libpthread
+void
+__lll_lock_wait (int *futex, int private)
+{
+ do
+ {
+ int oldval = atomic_compare_and_exchange_val_acq (futex, 2, 1);
+ if (oldval != 0)
+ lll_futex_wait (futex, 2, private);
+ }
+ while (atomic_compare_and_exchange_bool_acq (futex, 2, 0) != 0);
+}
+
+
+int
+__lll_timedlock_wait (int *futex, const struct timespec *abstime, int private)
+{
+ struct timespec rt;
+
+ /* Reject invalid timeouts. */
+ if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
+ return EINVAL;
+
+ /* Upgrade the lock. */
+ if (atomic_exchange_acq (futex, 2) == 0)
+ return 0;
+
+ do
+ {
+ struct timeval tv;
+
+ /* Get the current time. */
+ (void) gettimeofday (&tv, NULL);
+
+ /* Compute relative timeout. */
+ rt.tv_sec = abstime->tv_sec - tv.tv_sec;
+ rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+ if (rt.tv_nsec < 0)
+ {
+ rt.tv_nsec += 1000000000;
+ --rt.tv_sec;
+ }
+
+ /* Already timed out? */
+ if (rt.tv_sec < 0)
+ return ETIMEDOUT;
+
+ // XYZ: Lost the lock to check whether it was private.
+ lll_futex_timed_wait (futex, 2, &rt, private);
+ }
+ while (atomic_compare_and_exchange_bool_acq (futex, 2, 0) != 0);
+
+ return 0;
+}
+
+
+int
+__lll_timedwait_tid (int *tidp, const struct timespec *abstime)
+{
+ int tid;
+
+ if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
+ return EINVAL;
+
+ /* Repeat until thread terminated. */
+ while ((tid = *tidp) != 0)
+ {
+ struct timeval tv;
+ struct timespec rt;
+
+ /* Get the current time. */
+ (void) gettimeofday (&tv, NULL);
+
+ /* Compute relative timeout. */
+ rt.tv_sec = abstime->tv_sec - tv.tv_sec;
+ rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+ if (rt.tv_nsec < 0)
+ {
+ rt.tv_nsec += 1000000000;
+ --rt.tv_sec;
+ }
+
+ /* Already timed out? */
+ if (rt.tv_sec < 0)
+ return ETIMEDOUT;
+
+ /* Wait until thread terminates. */
+ // XYZ: Lost the lock to check whether it was private.
+ if (lll_futex_timed_wait (tidp, tid, &rt, LLL_SHARED) == -ETIMEDOUT)
+ return ETIMEDOUT;
+ }
+
+ return 0;
+}
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/metag/lowlevellock.h b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/lowlevellock.h
new file mode 100644
index 000000000..99ada5d50
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/lowlevellock.h
@@ -0,0 +1,279 @@
+/* Copyright (C) 2005, 2006, 2007, 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
+ 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 _LOWLEVELLOCK_H
+#define _LOWLEVELLOCK_H 1
+
+#include <time.h>
+#include <sys/param.h>
+#include <bits/pthreadtypes.h>
+#include <atomic.h>
+#include <sysdep.h>
+#include <bits/kernel-features.h>
+
+#define FUTEX_WAIT 0
+#define FUTEX_WAKE 1
+#define FUTEX_REQUEUE 3
+#define FUTEX_CMP_REQUEUE 4
+#define FUTEX_WAKE_OP 5
+#define FUTEX_OP_CLEAR_WAKE_IF_GT_ONE ((4 << 24) | 1)
+#define FUTEX_LOCK_PI 6
+#define FUTEX_UNLOCK_PI 7
+#define FUTEX_TRYLOCK_PI 8
+#define FUTEX_WAIT_BITSET 9
+#define FUTEX_WAKE_BITSET 10
+#define FUTEX_PRIVATE_FLAG 128
+#define FUTEX_CLOCK_REALTIME 256
+
+#define FUTEX_BITSET_MATCH_ANY 0xffffffff
+
+/* Values for 'private' parameter of locking macros. Yes, the
+ definition seems to be backwards. But it is not. The bit will be
+ reversed before passing to the system call. */
+#define LLL_PRIVATE 0
+#define LLL_SHARED FUTEX_PRIVATE_FLAG
+
+
+#if !defined NOT_IN_libc || defined IS_IN_rtld
+/* In libc.so or ld.so all futexes are private. */
+# ifdef __ASSUME_PRIVATE_FUTEX
+# define __lll_private_flag(fl, private) \
+ ((fl) | FUTEX_PRIVATE_FLAG)
+# else
+# define __lll_private_flag(fl, private) \
+ ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex))
+# endif
+#else
+# ifdef __ASSUME_PRIVATE_FUTEX
+# define __lll_private_flag(fl, private) \
+ (((fl) | FUTEX_PRIVATE_FLAG) ^ (private))
+# else
+# define __lll_private_flag(fl, private) \
+ (__builtin_constant_p (private) \
+ ? ((private) == 0 \
+ ? ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex)) \
+ : (fl)) \
+ : ((fl) | (((private) ^ FUTEX_PRIVATE_FLAG) \
+ & THREAD_GETMEM (THREAD_SELF, header.private_futex))))
+# endif
+#endif
+
+
+#define lll_futex_wait(futexp, val, private) \
+ lll_futex_timed_wait(futexp, val, NULL, private)
+
+#define lll_futex_timed_wait(futexp, val, timespec, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 4, (futexp), \
+ __lll_private_flag (FUTEX_WAIT, private), \
+ (val), (timespec)); \
+ __ret; \
+ })
+
+#define lll_futex_wake(futexp, nr, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 4, (futexp), \
+ __lll_private_flag (FUTEX_WAKE, private), \
+ (nr), 0); \
+ __ret; \
+ })
+
+#define lll_robust_dead(futexv, private) \
+ do \
+ { \
+ int *__futexp = &(futexv); \
+ atomic_or (__futexp, FUTEX_OWNER_DIED); \
+ lll_futex_wake (__futexp, 1, private); \
+ } \
+ while (0)
+
+/* Returns non-zero if error happened, zero if success. */
+#define lll_futex_requeue(futexp, nr_wake, nr_move, mutex, val, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 6, (futexp), \
+ __lll_private_flag (FUTEX_CMP_REQUEUE, private),\
+ (nr_wake), (nr_move), (mutex), (val)); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
+ })
+
+
+/* Returns non-zero if error happened, zero if success. */
+#define lll_futex_wake_unlock(futexp, nr_wake, nr_wake2, futexp2, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 6, (futexp), \
+ __lll_private_flag (FUTEX_WAKE_OP, private), \
+ (nr_wake), (nr_wake2), (futexp2), \
+ FUTEX_OP_CLEAR_WAKE_IF_GT_ONE); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
+ })
+
+
+#define lll_trylock(lock) \
+ atomic_compare_and_exchange_val_acq(&(lock), 1, 0)
+
+#define lll_cond_trylock(lock) \
+ atomic_compare_and_exchange_val_acq(&(lock), 2, 0)
+
+#define __lll_robust_trylock(futex, id) \
+ (atomic_compare_and_exchange_val_acq (futex, id, 0) != 0)
+#define lll_robust_trylock(lock, id) \
+ __lll_robust_trylock (&(lock), id)
+
+extern void __lll_lock_wait_private (int *futex) attribute_hidden;
+extern void __lll_lock_wait (int *futex, int private) attribute_hidden;
+extern int __lll_robust_lock_wait (int *futex, int private) attribute_hidden;
+
+#define __lll_lock(futex, private) \
+ ((void) ({ \
+ int *__futex = (futex); \
+ if (unlikely(atomic_compare_and_exchange_val_acq (__futex, 1, 0))) \
+ { \
+ if (__builtin_constant_p (private) && (private) == LLL_PRIVATE) \
+ __lll_lock_wait_private (__futex); \
+ else \
+ __lll_lock_wait (__futex, private); \
+ } \
+ }))
+#define lll_lock(futex, private) __lll_lock (&(futex), private)
+
+
+#define __lll_robust_lock(futex, id, private) \
+ ({ \
+ int *__futex = (futex); \
+ int __val = 0; \
+ \
+ if (unlikely(atomic_compare_and_exchange_bool_acq (__futex, id, 0))) \
+ __val = __lll_robust_lock_wait (__futex, private); \
+ __val; \
+ })
+#define lll_robust_lock(futex, id, private) \
+ __lll_robust_lock (&(futex), id, private)
+
+
+#define __lll_cond_lock(futex, private) \
+ ((void) ({ \
+ int *__futex = (futex); \
+ if (unlikely(atomic_exchange_acq (__futex, 2))) \
+ __lll_lock_wait (__futex, private); \
+ }))
+#define lll_cond_lock(futex, private) __lll_cond_lock (&(futex), private)
+
+
+#define lll_robust_cond_lock(futex, id, private) \
+ __lll_robust_lock (&(futex), (id) | FUTEX_WAITERS, private)
+
+
+extern int __lll_timedlock_wait (int *futex, const struct timespec *,
+ int private) attribute_hidden;
+extern int __lll_robust_timedlock_wait (int *futex, const struct timespec *,
+ int private) attribute_hidden;
+
+#define __lll_timedlock(futex, abstime, private) \
+ ({ \
+ int *__futex = (futex); \
+ int __val = 0; \
+ \
+ if (unlikely(atomic_exchange_acq (__futex, 1))) \
+ __val = __lll_timedlock_wait (__futex, abstime, private); \
+ __val; \
+ })
+#define lll_timedlock(futex, abstime, private) \
+ __lll_timedlock (&(futex), abstime, private)
+
+
+#define __lll_robust_timedlock(futex, abstime, id, private) \
+ ({ \
+ int *__futex = (futex); \
+ int __val = 0; \
+ \
+ if (unlikely(atomic_compare_and_exchange_bool_acq (__futex, id, 0))) \
+ __val = __lll_robust_timedlock_wait (__futex, abstime, private); \
+ __val; \
+ })
+#define lll_robust_timedlock(futex, abstime, id, private) \
+ __lll_robust_timedlock (&(futex), abstime, id, private)
+
+
+#define __lll_unlock(futex, private) \
+ (void) \
+ ({ int *__futex = (futex); \
+ int __oldval = atomic_exchange_rel (__futex, 0); \
+ if (unlikely(__oldval > 1)) \
+ lll_futex_wake (__futex, 1, private); \
+ })
+#define lll_unlock(futex, private) __lll_unlock(&(futex), private)
+
+
+#define __lll_robust_unlock(futex, private) \
+ (void) \
+ ({ int *__futex = (futex); \
+ int __oldval = atomic_exchange_rel (__futex, 0); \
+ if (unlikely(__oldval & FUTEX_WAITERS)) \
+ lll_futex_wake (__futex, 1, private); \
+ })
+#define lll_robust_unlock(futex, private) \
+ __lll_robust_unlock(&(futex), private)
+
+
+#define lll_islocked(futex) \
+ (futex != 0)
+
+
+/* Our internal lock implementation is identical to the binary-compatible
+ mutex implementation. */
+
+/* Initializers for lock. */
+#define LLL_LOCK_INITIALIZER (0)
+#define LLL_LOCK_INITIALIZER_LOCKED (1)
+
+/* The states of a lock are:
+ 0 - untaken
+ 1 - taken by one user
+ >1 - taken by more users */
+
+/* The kernel notifies a process which uses CLONE_CLEARTID via futex
+ wakeup when the clone terminates. The memory location contains the
+ thread ID while the clone is running and is reset to zero
+ afterwards. */
+#define lll_wait_tid(tid) \
+ do { \
+ __typeof (tid) __tid; \
+ while ((__tid = (tid)) != 0) \
+ lll_futex_wait (&(tid), __tid, LLL_SHARED);\
+ } while (0)
+
+extern int __lll_timedwait_tid (int *, const struct timespec *)
+ attribute_hidden;
+
+#define lll_timedwait_tid(tid, abstime) \
+ ({ \
+ int __res = 0; \
+ if ((tid) != 0) \
+ __res = __lll_timedwait_tid (&(tid), (abstime)); \
+ __res; \
+ })
+
+#endif /* lowlevellock.h */
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/metag/pt-__syscall_error.c b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/pt-__syscall_error.c
new file mode 100644
index 000000000..8f97734e5
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/pt-__syscall_error.c
@@ -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 <../../../../../../../libc/sysdeps/linux/metag/__syscall_error.c>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/metag/pt-__syscall_rt_sigaction.c b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/pt-__syscall_rt_sigaction.c
new file mode 100644
index 000000000..18769cac7
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/pt-__syscall_rt_sigaction.c
@@ -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 <../../../../../../../libc/sysdeps/linux/common/__syscall_rt_sigaction.c>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/metag/pt-gettimeofday.c b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/pt-gettimeofday.c
new file mode 100644
index 000000000..4dcb8b564
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/pt-gettimeofday.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 <sys/syscall.h>
+#include <sys/time.h>
+
+int gettimeofday (struct timeval *, struct timezone *) attribute_hidden;
+_syscall2(int, gettimeofday, struct timeval *, tv, struct timezone *, tz);
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/metag/pthread_once.c b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/pthread_once.c
new file mode 100644
index 000000000..e977a7d0c
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/pthread_once.c
@@ -0,0 +1,100 @@
+/* Copyright (C) 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include "pthreadP.h"
+#include <lowlevellock.h>
+
+unsigned long int __fork_generation attribute_hidden;
+
+static void
+clear_once_control (void *arg)
+{
+ pthread_once_t *once_control = (pthread_once_t *) arg;
+
+ *once_control = 0;
+ lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE);
+}
+
+int
+attribute_protected
+__pthread_once (pthread_once_t *once_control, void (*init_routine) (void))
+{
+ for (;;)
+ {
+ int oldval;
+ int newval;
+
+ /* Pseudo code:
+ newval = __fork_generation | 1;
+ oldval = *once_control;
+ if ((oldval & 2) == 0)
+ *once_control = newval;
+ Do this atomically.
+ */
+ do
+ {
+ newval = __fork_generation | 1;
+ oldval = *once_control;
+ if (oldval & 2)
+ break;
+ } while (atomic_compare_and_exchange_val_acq (once_control, newval, oldval) != oldval);
+
+ /* Check if the initializer has already been done. */
+ if ((oldval & 2) != 0)
+ return 0;
+
+ /* Check if another thread already runs the initializer. */
+ if ((oldval & 1) == 0)
+ break;
+
+ /* Check whether the initializer execution was interrupted by a fork. */
+ if (oldval != newval)
+ break;
+
+ /* Same generation, some other thread was faster. Wait. */
+ lll_futex_wait (once_control, oldval, LLL_PRIVATE);
+ }
+
+ /* This thread is the first here. Do the initialization.
+ Register a cleanup handler so that in case the thread gets
+ interrupted the initialization can be restarted. */
+ pthread_cleanup_push (clear_once_control, once_control);
+
+ init_routine ();
+
+ pthread_cleanup_pop (0);
+
+ /* Say that the initialisation is done. */
+ *once_control = __fork_generation | 2;
+
+ /* Wake up all other threads. */
+ lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE);
+
+ return 0;
+}
+weak_alias (__pthread_once, pthread_once)
+strong_alias (__pthread_once, __pthread_once_internal)
+
+#if defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__PIC__)
+/* When statically linked, if pthread_create is used, this file
+ will be brought in. The exception handling code in GCC assumes
+ that if pthread_create is available, so are these. */
+const void *include_pthread_getspecific attribute_hidden = pthread_getspecific;
+const void *include_pthread_setspecific attribute_hidden = pthread_setspecific;
+const void *include_pthread_key_create attribute_hidden = pthread_key_create;
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/metag/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/sysdep-cancel.h
new file mode 100644
index 000000000..0be330b73
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/sysdep-cancel.h
@@ -0,0 +1,152 @@
+/* Copyright (C) 2003, 2004, 2005, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ 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 <tls.h>
+#include <sysdep.h>
+#ifndef __ASSEMBLER__
+# include <pthreadP.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+/* NOTE: We do mark syscalls with unwind annotations, for the benefit of
+ cancellation; but they're really only accurate at the point of the
+ syscall. The ARM unwind directives are not rich enough without adding
+ a custom personality function. */
+
+#ifdef __ASSEMBLER__
+#undef ret
+#define ret \
+ CMP D0Re0, #-4095; \
+ MOVLO PC, D1RtP; \
+ MOV D1Ar1, D0Re0; \
+ B SYSCALL_ERROR;
+#endif /* __ASSEMBLER__ */
+
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .section ".text"; \
+ .type ___##syscall_name##_nocancel,%function; \
+ .globl ___##syscall_name##_nocancel; \
+ ___##syscall_name##_nocancel: \
+ cfi_startproc; \
+ DO_CALL (syscall_name, args); \
+ MOV PC, D1RtP; \
+ cfi_endproc; \
+ .size ___##syscall_name##_nocancel,.-___##syscall_name##_nocancel; \
+ .globl _##name; \
+ .type _##name, @function; \
+name##: \
+_##name##: \
+ DOCARGS_##args; \
+ SINGLE_THREAD_P; \
+ UNDOCARGS_##args; \
+ BNE .Lpseudo_cancel; \
+ cfi_remember_state; \
+ DO_CALL (syscall_name, 0); \
+ ret \
+ cfi_restore_state; \
+ .Lpseudo_cancel: \
+ MSETL [A0StP++], D0FrT, D0.5; \
+ DOCARGS_##args; /* save syscall args etc. around CENABLE. */ \
+ CENABLE; \
+ MOV D0FrT, D0Re0; /* put mask in safe place. */ \
+ UNDOCARGS_##args; /* restore syscall args. */ \
+ DO_CALL(syscall_name, 0); /* do the call. */ \
+ MOV D0.5, D0Re0; /* save syscall return value. */ \
+ MOV D1Ar1, D0FrT; /* get mask back. */ \
+ CDISABLE; \
+ MOV D0Re0, D0.5; /* retrieve return value. */ \
+ GETL D0.5, D1.5, [--A0StP]; \
+ GETL D0FrT, D1RtP, [--A0StP];
+
+# define DOCARGS_0
+# define UNDOCARGS_0
+
+# define DOCARGS_1 \
+ SETL [A0StP++], D1Ar1, D0Ar2
+# define UNDOCARGS_1 \
+ GETL D1Ar1, D0Ar2, [--A0StP]
+
+# define DOCARGS_2 DOCARGS_1
+
+# define UNDOCARGS_2 UNDOCARGS_2
+
+# define DOCARGS_3 \
+ MSETL [A0StP++], D1Ar1, D1Ar3
+
+# define UNDOCARGS_3 \
+ GETL D1Ar1, D0Ar2, [--A0StP]; \
+ GETL D1Ar3, D0Ar4, [--A0StP]
+
+# define DOCARGS_4 DOCARGS_3
+# define UNDOCARGS_4 UNDOCARGS_3
+
+# define DOCARGS_5 \
+ MSETL [A0StP++], D1Ar1, D1Ar3, D1Ar5
+# define UNDOCARGS_5 \
+ GETL D1Ar1, D0Ar2, [--A0StP]; \
+ GETL D1Ar3, D0Ar4, [--A0StP]; \
+ GETL D1Ar5, D0Ar6, [--A0StP]
+
+# define DOCARGS_6 DOCARGS_5
+# define UNDOCARGS_6 UNDOCARGS_5
+
+# ifdef IS_IN_libpthread
+# define CENABLE CALLR D1RtP, ___pthread_enable_asynccancel@PLT
+# define CDISABLE CALLR D1RtP, ___pthread_disable_asynccancel@PLT
+# define __local_multiple_threads __pthread_multiple_threads
+# elif !defined NOT_IN_libc
+# define CENABLE CALLR D1RtP, ___libc_enable_asynccancel@PLT
+# define CDISABLE CALLR D1RtP, ___libc_disable_asynccancel@PLT
+# define __local_multiple_threads __libc_multiple_threads
+# elif defined IS_IN_librt
+# define CENABLE CALLR D1RtP, ___librt_enable_asynccancel@PLT
+# define CDISABLE CALLR D1RtP, ___librt_disable_asynccancel@PLT
+# else
+# error Unsupported library
+# endif
+
+#ifndef __ASSEMBLER__
+# define SINGLE_THREAD_P \
+ likely(THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0)
+#else
+# define SINGLE_THREAD_P \
+ SETL [A0StP++], D0FrT, D1RtP; \
+ CALLR D1RtP, ___metag_load_tp@PLT; \
+ SUB D0Re0, D0Re0, #TLS_PRE_TCB_SIZE; \
+ GETD D0Re0, [D0Re0 + #MULTIPLE_THREADS_OFFSET]; \
+ CMP D0Re0, #0; \
+ GETL D0FrT, D1RtP, [--A0StP]
+#endif
+
+
+#elif !defined __ASSEMBLER__
+
+/* For rtld, et cetera. */
+# define SINGLE_THREAD_P 1
+# define NO_CANCELLATION 1
+
+#endif
+
+#ifndef __ASSEMBLER__
+# define RTLD_SINGLE_THREAD_P \
+ likely(THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0)
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/metag/vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/vfork.S
new file mode 100644
index 000000000..51fcfbbe4
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/vfork.S
@@ -0,0 +1,56 @@
+/* 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <tcb-offsets.h>
+#include <asm/unistd.h>
+
+#ifdef __PIC__
+#define __VFORK_METAG_LOAD_TP ___metag_load_tp@PLT
+#else
+#define __VFORK_METAG_LOAD_TP ___metag_load_tp
+#endif
+
+/* Save the PID value. */
+#define SAVE_PID \
+ SETL [A0StP++], D0FrT, D1RtP; \
+ CALLR D1RtP, __VFORK_METAG_LOAD_TP; \
+ SUB D0Re0, D0Re0, #TLS_PRE_TCB_SIZE; \
+ GETD D0FrT, [D0Re0 + #PID]; \
+ NEGS D0FrT, D0FrT; \
+ BNZ 1f; \
+ MOVT D0FrT, #0x8000; \
+1: SETD [D0Re0 + #PID], D0FrT; \
+ GETL D0FrT, D1RtP, [--A0StP];
+
+#define RESTORE_PID \
+ CMP D0Re0, #0; \
+ BEQ 1f; \
+ MSETL [A0StP++], D0Re0, D0FrT; \
+ CALLR D1RtP, __VFORK_METAG_LOAD_TP; \
+ SUB D0Re0, D0Re0, #TLS_PRE_TCB_SIZE; \
+ GETD D0FrT, [D0Re0 + #PID]; \
+ NEG D0FrT, D0FrT; \
+ MOVT D1Re0, #0x8000; \
+ CMP D0FrT, D1Re0; \
+ XOREQ D0FrT, D0FrT, D0FrT; \
+ SETD [D0Re0 + #PID], D0FrT; \
+ GETL D0FrT, D1RtP, [--A0StP]; \
+ GETL D0Re0, D1Re0, [--A0StP]; \
+1:
+
+#include <../../../../../../../libc/sysdeps/linux/metag/vfork.S>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/mips/Makefile b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/Makefile
new file mode 100644
index 000000000..43a6fad84
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/Makefile
@@ -0,0 +1,13 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2005 Steven J. Hill <sjhill@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+top_srcdir=../../../../../../../
+top_builddir=../../../../../../../
+all: objs
+include $(top_builddir)Rules.mak
+include Makefile.arch
+include $(top_srcdir)Makerules
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/mips/Makefile.arch b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/Makefile.arch
new file mode 100644
index 000000000..f87dedca4
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/Makefile.arch
@@ -0,0 +1,17 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2006 Steven J. Hill <sjhill@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+libpthread_linux_arch_SSRC = clone.S
+libpthread_linux_arch_CSRC = pthread_once.c pt-__syscall_rt_sigaction.c
+
+libc_linux_arch_CSRC = fork.c
+libc_linux_arch_SSRC = clone.S vfork.S
+ifneq ($(CONFIG_MIPS_O32_ABI),y)
+libc_linux_arch_SSRC-OMIT = waitpid.S
+endif
+ASFLAGS += -DUSE___THREAD
+
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/mips/bits/pthreadtypes.h b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/bits/pthreadtypes.h
new file mode 100644
index 000000000..cf098d750
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/bits/pthreadtypes.h
@@ -0,0 +1,229 @@
+/* Machine-specific pthread type layouts. MIPS version.
+ 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/>. */
+
+#ifndef _BITS_PTHREADTYPES_H
+#define _BITS_PTHREADTYPES_H 1
+
+#include <endian.h>
+#include <sgidefs.h>
+
+#if _MIPS_SIM == _ABI64
+# define __SIZEOF_PTHREAD_ATTR_T 56
+# define __SIZEOF_PTHREAD_MUTEX_T 40
+# define __SIZEOF_PTHREAD_MUTEXATTR_T 4
+# define __SIZEOF_PTHREAD_COND_T 48
+# define __SIZEOF_PTHREAD_CONDATTR_T 4
+# define __SIZEOF_PTHREAD_RWLOCK_T 56
+# define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
+# define __SIZEOF_PTHREAD_BARRIER_T 32
+# define __SIZEOF_PTHREAD_BARRIERATTR_T 4
+#else
+# define __SIZEOF_PTHREAD_ATTR_T 36
+# define __SIZEOF_PTHREAD_MUTEX_T 24
+# define __SIZEOF_PTHREAD_MUTEXATTR_T 4
+# define __SIZEOF_PTHREAD_COND_T 48
+# define __SIZEOF_PTHREAD_CONDATTR_T 4
+# define __SIZEOF_PTHREAD_RWLOCK_T 32
+# define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
+# define __SIZEOF_PTHREAD_BARRIER_T 20
+# define __SIZEOF_PTHREAD_BARRIERATTR_T 4
+#endif
+
+
+/* Thread identifiers. The structure of the attribute type is
+ deliberately not exposed. */
+typedef unsigned long int pthread_t;
+
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_ATTR_T];
+ long int __align;
+} pthread_attr_t;
+
+
+#if _MIPS_SIM == _ABI64
+typedef struct __pthread_internal_list
+{
+ struct __pthread_internal_list *__prev;
+ struct __pthread_internal_list *__next;
+} __pthread_list_t;
+#else
+typedef struct __pthread_internal_slist
+{
+ struct __pthread_internal_slist *__next;
+} __pthread_slist_t;
+#endif
+
+
+/* Data structures for mutex handling. The structure of the attribute
+ type is deliberately not exposed. */
+typedef union
+{
+ struct __pthread_mutex_s
+ {
+ int __lock;
+ unsigned int __count;
+ int __owner;
+#if _MIPS_SIM == _ABI64
+ unsigned int __nusers;
+#endif
+ /* KIND must stay at this position in the structure to maintain
+ binary compatibility. */
+ int __kind;
+#if _MIPS_SIM == _ABI64
+ int __spins;
+ __pthread_list_t __list;
+# define __PTHREAD_MUTEX_HAVE_PREV 1
+#else
+ unsigned int __nusers;
+ __extension__ union
+ {
+ int __spins;
+ __pthread_slist_t __list;
+ };
+#endif
+ } __data;
+ char __size[__SIZEOF_PTHREAD_MUTEX_T];
+ long int __align;
+} pthread_mutex_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
+ int __align;
+} pthread_mutexattr_t;
+
+
+/* Data structure for conditional variable handling. The structure of
+ the attribute type is deliberately not exposed. */
+typedef union
+{
+ struct
+ {
+ int __lock;
+ unsigned int __futex;
+ __extension__ unsigned long long int __total_seq;
+ __extension__ unsigned long long int __wakeup_seq;
+ __extension__ unsigned long long int __woken_seq;
+ void *__mutex;
+ unsigned int __nwaiters;
+ unsigned int __broadcast_seq;
+ } __data;
+ char __size[__SIZEOF_PTHREAD_COND_T];
+ __extension__ long long int __align;
+} pthread_cond_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_CONDATTR_T];
+ int __align;
+} pthread_condattr_t;
+
+
+/* Keys for thread-specific data */
+typedef unsigned int pthread_key_t;
+
+
+/* Once-only execution */
+typedef int pthread_once_t;
+
+
+#if defined __USE_UNIX98 || defined __USE_XOPEN2K
+/* Data structure for read-write lock variable handling. The
+ structure of the attribute type is deliberately not exposed. */
+typedef union
+{
+# if _MIPS_SIM == _ABI64
+ struct
+ {
+ int __lock;
+ unsigned int __nr_readers;
+ unsigned int __readers_wakeup;
+ unsigned int __writer_wakeup;
+ unsigned int __nr_readers_queued;
+ unsigned int __nr_writers_queued;
+ int __writer;
+ int __shared;
+ unsigned long int __pad1;
+ unsigned long int __pad2;
+ /* FLAGS must stay at this position in the structure to maintain
+ binary compatibility. */
+ unsigned int __flags;
+ } __data;
+# else
+ struct
+ {
+ int __lock;
+ unsigned int __nr_readers;
+ unsigned int __readers_wakeup;
+ unsigned int __writer_wakeup;
+ unsigned int __nr_readers_queued;
+ unsigned int __nr_writers_queued;
+#if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned char __pad1;
+ unsigned char __pad2;
+ unsigned char __shared;
+ /* FLAGS must stay at this position in the structure to maintain
+ binary compatibility. */
+ unsigned char __flags;
+#else
+ /* FLAGS must stay at this position in the structure to maintain
+ binary compatibility. */
+ unsigned char __flags;
+ unsigned char __shared;
+ unsigned char __pad1;
+ unsigned char __pad2;
+#endif
+ int __writer;
+ } __data;
+# endif
+ char __size[__SIZEOF_PTHREAD_RWLOCK_T];
+ long int __align;
+} pthread_rwlock_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
+ long int __align;
+} pthread_rwlockattr_t;
+#endif
+
+
+#ifdef __USE_XOPEN2K
+/* POSIX spinlock data type. */
+typedef volatile int pthread_spinlock_t;
+
+
+/* POSIX barriers data type. The structure of the type is
+ deliberately not exposed. */
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_BARRIER_T];
+ long int __align;
+} pthread_barrier_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];
+ int __align;
+} pthread_barrierattr_t;
+#endif
+
+
+#endif /* bits/pthreadtypes.h */
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/mips/bits/semaphore.h b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/bits/semaphore.h
new file mode 100644
index 000000000..e250843e6
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/bits/semaphore.h
@@ -0,0 +1,36 @@
+/* Copyright (C) 2002, 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 _SEMAPHORE_H
+# error "Never use <bits/semaphore.h> directly; include <semaphore.h> instead."
+#endif
+
+#if _MIPS_SIM == _ABI64
+# define __SIZEOF_SEM_T 32
+#else
+# define __SIZEOF_SEM_T 16
+#endif
+
+/* Value returned if `sem_open' failed. */
+#define SEM_FAILED ((sem_t *) 0)
+
+
+typedef union
+{
+ char __size[__SIZEOF_SEM_T];
+ long int __align;
+} sem_t;
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/mips/clone.S b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/clone.S
new file mode 100644
index 000000000..858877f07
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/clone.S
@@ -0,0 +1,2 @@
+#define RESET_PID
+#include <libc/sysdeps/linux/mips/clone.S>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/mips/createthread.c b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/createthread.c
new file mode 100644
index 000000000..3079007c7
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/createthread.c
@@ -0,0 +1,23 @@
+/* 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/>. */
+
+/* Value passed to 'clone' for initialization of the thread register. */
+#define TLS_VALUE ((void *) (pd) \
+ + TLS_TCB_OFFSET + TLS_PRE_TCB_SIZE)
+
+/* Get the real implementation. */
+#include <sysdeps/pthread/createthread.c>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/mips/fork.c b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/fork.c
new file mode 100644
index 000000000..06b7e1c69
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/fork.c
@@ -0,0 +1 @@
+#include "../i386/fork.c"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/mips/lowlevellock.h b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/lowlevellock.h
new file mode 100644
index 000000000..450a286b4
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/lowlevellock.h
@@ -0,0 +1,294 @@
+/* Copyright (C) 2003, 2004, 2005, 2006, 2007, 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
+ 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 _LOWLEVELLOCK_H
+#define _LOWLEVELLOCK_H 1
+
+#include <time.h>
+#include <sys/param.h>
+#include <bits/pthreadtypes.h>
+#include <atomic.h>
+#include <sysdep.h>
+#include <bits/kernel-features.h>
+
+#define FUTEX_WAIT 0
+#define FUTEX_WAKE 1
+#define FUTEX_REQUEUE 3
+#define FUTEX_CMP_REQUEUE 4
+#define FUTEX_WAKE_OP 5
+#define FUTEX_OP_CLEAR_WAKE_IF_GT_ONE ((4 << 24) | 1)
+#define FUTEX_LOCK_PI 6
+#define FUTEX_UNLOCK_PI 7
+#define FUTEX_TRYLOCK_PI 8
+#define FUTEX_WAIT_BITSET 9
+#define FUTEX_WAKE_BITSET 10
+#define FUTEX_PRIVATE_FLAG 128
+#define FUTEX_CLOCK_REALTIME 256
+
+#define FUTEX_BITSET_MATCH_ANY 0xffffffff
+
+/* Values for 'private' parameter of locking macros. Yes, the
+ definition seems to be backwards. But it is not. The bit will be
+ reversed before passing to the system call. */
+#define LLL_PRIVATE 0
+#define LLL_SHARED FUTEX_PRIVATE_FLAG
+
+
+#if !defined NOT_IN_libc || defined IS_IN_rtld
+/* In libc.so or ld.so all futexes are private. */
+# ifdef __ASSUME_PRIVATE_FUTEX
+# define __lll_private_flag(fl, private) \
+ ((fl) | FUTEX_PRIVATE_FLAG)
+# else
+# define __lll_private_flag(fl, private) \
+ ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex))
+# endif
+#else
+# ifdef __ASSUME_PRIVATE_FUTEX
+# define __lll_private_flag(fl, private) \
+ (((fl) | FUTEX_PRIVATE_FLAG) ^ (private))
+# else
+# define __lll_private_flag(fl, private) \
+ (__builtin_constant_p (private) \
+ ? ((private) == 0 \
+ ? ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex)) \
+ : (fl)) \
+ : ((fl) | (((private) ^ FUTEX_PRIVATE_FLAG) \
+ & THREAD_GETMEM (THREAD_SELF, header.private_futex))))
+# endif
+#endif
+
+
+#define lll_futex_wait(futexp, val, private) \
+ lll_futex_timed_wait(futexp, val, NULL, private)
+
+#define lll_futex_timed_wait(futexp, val, timespec, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret attribute_unused; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 4, (long) (futexp), \
+ __lll_private_flag (FUTEX_WAIT, private), \
+ (val), (timespec)); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err) ? -__ret : __ret; \
+ })
+
+#define lll_futex_wake(futexp, nr, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret attribute_unused; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 4, (long) (futexp), \
+ __lll_private_flag (FUTEX_WAKE, private), \
+ (nr), 0); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err) ? -__ret : __ret; \
+ })
+
+#define lll_robust_dead(futexv, private) \
+ do \
+ { \
+ int *__futexp = &(futexv); \
+ atomic_or (__futexp, FUTEX_OWNER_DIED); \
+ lll_futex_wake (__futexp, 1, private); \
+ } \
+ while (0)
+
+/* Returns non-zero if error happened, zero if success. */
+#define lll_futex_requeue(futexp, nr_wake, nr_move, mutex, val, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret attribute_unused; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 6, (long) (futexp), \
+ __lll_private_flag (FUTEX_CMP_REQUEUE, private),\
+ (nr_wake), (nr_move), (mutex), (val)); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
+ })
+
+/* Returns non-zero if error happened, zero if success. */
+#define lll_futex_wake_unlock(futexp, nr_wake, nr_wake2, futexp2, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret attribute_unused; \
+ \
+ __ret = INTERNAL_SYSCALL (futex, __err, 6, (futexp), \
+ __lll_private_flag (FUTEX_WAKE_OP, private), \
+ (nr_wake), (nr_wake2), (futexp2), \
+ FUTEX_OP_CLEAR_WAKE_IF_GT_ONE); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
+ })
+
+static inline int __attribute__((always_inline))
+__lll_trylock(int *futex)
+{
+ return atomic_compare_and_exchange_val_acq (futex, 1, 0) != 0;
+}
+#define lll_trylock(lock) __lll_trylock (&(lock))
+
+
+static inline int __attribute__((always_inline))
+__lll_cond_trylock(int *futex)
+{
+ return atomic_compare_and_exchange_val_acq (futex, 2, 0) != 0;
+}
+#define lll_cond_trylock(lock) __lll_cond_trylock (&(lock))
+
+
+static inline int __attribute__((always_inline))
+__lll_robust_trylock(int *futex, int id)
+{
+ return atomic_compare_and_exchange_val_acq (futex, id, 0) != 0;
+}
+#define lll_robust_trylock(lock, id) \
+ __lll_robust_trylock (&(lock), id)
+
+extern void __lll_lock_wait_private (int *futex) attribute_hidden;
+extern void __lll_lock_wait (int *futex, int private) attribute_hidden;
+extern int __lll_robust_lock_wait (int *futex, int private) attribute_hidden;
+
+#define __lll_lock(futex, private) \
+ ((void) ({ \
+ int *__futex = (futex); \
+ if (__builtin_expect (atomic_compare_and_exchange_bool_acq (__futex, \
+ 1, 0), 0)) \
+ { \
+ if (__builtin_constant_p (private) && (private) == LLL_PRIVATE) \
+ __lll_lock_wait_private (__futex); \
+ else \
+ __lll_lock_wait (__futex, private); \
+ } \
+ }))
+#define lll_lock(futex, private) __lll_lock (&(futex), private)
+
+
+#define __lll_robust_lock(futex, id, private) \
+ ({ \
+ int *__futex = (futex); \
+ int __val = 0; \
+ \
+ if (__builtin_expect (atomic_compare_and_exchange_bool_acq (__futex, id, \
+ 0), 0)) \
+ __val = __lll_robust_lock_wait (__futex, private); \
+ __val; \
+ })
+#define lll_robust_lock(futex, id, private) \
+ __lll_robust_lock (&(futex), id, private)
+
+
+static inline void __attribute__ ((always_inline))
+__lll_cond_lock (int *futex, int private)
+{
+ if (atomic_compare_and_exchange_bool_acq (futex, 2, 0) != 0)
+ __lll_lock_wait (futex, private);
+}
+#define lll_cond_lock(futex, private) __lll_cond_lock (&(futex), private)
+
+
+#define lll_robust_cond_lock(futex, id, private) \
+ __lll_robust_lock (&(futex), (id) | FUTEX_WAITERS, private)
+
+
+extern int __lll_timedlock_wait (int *futex, const struct timespec *,
+ int private) attribute_hidden;
+extern int __lll_robust_timedlock_wait (int *futex, const struct timespec *,
+ int private) attribute_hidden;
+
+static inline int __attribute__ ((always_inline))
+__lll_timedlock (int *futex, const struct timespec *abstime, int private)
+{
+ int result = 0;
+ if (atomic_compare_and_exchange_bool_acq (futex, 1, 0) != 0)
+ result = __lll_timedlock_wait (futex, abstime, private);
+ return result;
+}
+#define lll_timedlock(futex, abstime, private) \
+ __lll_timedlock (&(futex), abstime, private)
+
+
+static inline int __attribute__ ((always_inline))
+__lll_robust_timedlock (int *futex, const struct timespec *abstime,
+ int id, int private)
+{
+ int result = 0;
+ if (atomic_compare_and_exchange_bool_acq (futex, id, 0) != 0)
+ result = __lll_robust_timedlock_wait (futex, abstime, private);
+ return result;
+}
+#define lll_robust_timedlock(futex, abstime, id, private) \
+ __lll_robust_timedlock (&(futex), abstime, id, private)
+
+
+#define __lll_unlock(futex, private) \
+ ((void) ({ \
+ int *__futex = (futex); \
+ int __val = atomic_exchange_rel (__futex, 0); \
+ \
+ if (__builtin_expect (__val > 1, 0)) \
+ lll_futex_wake (__futex, 1, private); \
+ }))
+#define lll_unlock(futex, private) __lll_unlock(&(futex), private)
+
+
+#define __lll_robust_unlock(futex, private) \
+ ((void) ({ \
+ int *__futex = (futex); \
+ int __val = atomic_exchange_rel (__futex, 0); \
+ \
+ if (__builtin_expect (__val & FUTEX_WAITERS, 0)) \
+ lll_futex_wake (__futex, 1, private); \
+ }))
+#define lll_robust_unlock(futex, private) \
+ __lll_robust_unlock(&(futex), private)
+
+
+#define lll_islocked(futex) \
+ (futex != 0)
+
+
+/* Our internal lock implementation is identical to the binary-compatible
+ mutex implementation. */
+
+/* Initializers for lock. */
+#define LLL_LOCK_INITIALIZER (0)
+#define LLL_LOCK_INITIALIZER_LOCKED (1)
+
+/* The states of a lock are:
+ 0 - untaken
+ 1 - taken by one user
+ >1 - taken by more users */
+
+/* The kernel notifies a process which uses CLONE_CLEARTID via futex
+ wakeup when the clone terminates. The memory location contains the
+ thread ID while the clone is running and is reset to zero
+ afterwards. */
+#define lll_wait_tid(tid) \
+ do { \
+ __typeof (tid) __tid; \
+ while ((__tid = (tid)) != 0) \
+ lll_futex_wait (&(tid), __tid, LLL_SHARED); \
+ } while (0)
+
+extern int __lll_timedwait_tid (int *, const struct timespec *)
+ attribute_hidden;
+
+#define lll_timedwait_tid(tid, abstime) \
+ ({ \
+ int __res = 0; \
+ if ((tid) != 0) \
+ __res = __lll_timedwait_tid (&(tid), (abstime)); \
+ __res; \
+ })
+
+#endif /* lowlevellock.h */
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/mips/pt-__syscall_rt_sigaction.c b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/pt-__syscall_rt_sigaction.c
new file mode 100644
index 000000000..50137c84a
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/pt-__syscall_rt_sigaction.c
@@ -0,0 +1 @@
+#include <../../../../../../../libc/sysdeps/linux/common/__syscall_rt_sigaction.c>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/mips/pt-clone.S b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/pt-clone.S
new file mode 100644
index 000000000..add405523
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/pt-clone.S
@@ -0,0 +1,2 @@
+#define RESET_PID
+#include <../../../../../../../libc/sysdeps/linux/mips/clone.S>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/mips/pthread_once.c b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/pthread_once.c
new file mode 100644
index 000000000..7cf918e0d
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/pthread_once.c
@@ -0,0 +1,92 @@
+/* Copyright (C) 2003, 2004, 2005 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/>. */
+
+#include "pthreadP.h"
+#include <lowlevellock.h>
+
+
+unsigned long int __fork_generation attribute_hidden;
+
+
+static void
+clear_once_control (void *arg)
+{
+ pthread_once_t *once_control = (pthread_once_t *) arg;
+
+ *once_control = 0;
+ lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE);
+}
+
+
+int
+attribute_protected
+__pthread_once (pthread_once_t *once_control, void (*init_routine) (void))
+{
+ while (1)
+ {
+ int oldval, val, newval;
+
+ val = *once_control;
+ do
+ {
+ /* Check if the initialized has already been done. */
+ if ((val & 2) != 0)
+ return 0;
+
+ oldval = val;
+ newval = (oldval & 3) | __fork_generation | 1;
+ val = atomic_compare_and_exchange_val_acq (once_control, newval,
+ oldval);
+ }
+ while (__builtin_expect (val != oldval, 0));
+
+ /* Check if another thread already runs the initializer. */
+ if ((oldval & 1) != 0)
+ {
+ /* Check whether the initializer execution was interrupted
+ by a fork. */
+ if (((oldval ^ newval) & -4) == 0)
+ {
+ /* Same generation, some other thread was faster. Wait. */
+ lll_futex_wait (once_control, newval, LLL_PRIVATE);
+ continue;
+ }
+ }
+
+ /* This thread is the first here. Do the initialization.
+ Register a cleanup handler so that in case the thread gets
+ interrupted the initialization can be restarted. */
+ pthread_cleanup_push (clear_once_control, once_control);
+
+ init_routine ();
+
+ pthread_cleanup_pop (0);
+
+
+ /* Add one to *once_control. */
+ atomic_increment (once_control);
+
+ /* Wake up all other threads. */
+ lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE);
+ break;
+ }
+
+ return 0;
+}
+weak_alias (__pthread_once, pthread_once)
+strong_alias (__pthread_once, __pthread_once_internal)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h
new file mode 100644
index 000000000..1750f059a
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h
@@ -0,0 +1,187 @@
+/* Copyright (C) 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/>. */
+
+#include <sysdep.h>
+#include <tls.h>
+#ifndef __ASSEMBLER__
+# include <pthreadP.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+# ifdef __PIC__
+# define PSEUDO_CPLOAD .cpload t9;
+# define PSEUDO_ERRJMP move a0, v0; la t9, __syscall_error; jr t9;
+# define PSEUDO_SAVEGP sw gp, 32(sp); cfi_rel_offset (gp, 32);
+# define PSEUDO_LOADGP lw gp, 32(sp);
+# else
+# define PSEUDO_CPLOAD
+# define PSEUDO_ERRJMP move a0, v0; j __syscall_error;
+# define PSEUDO_SAVEGP
+# define PSEUDO_LOADGP
+# endif
+
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .align 2; \
+ L(pseudo_start): \
+ cfi_startproc; \
+ 99: PSEUDO_ERRJMP \
+ .type __##syscall_name##_nocancel, @function; \
+ .globl __##syscall_name##_nocancel; \
+ __##syscall_name##_nocancel: \
+ .set noreorder; \
+ PSEUDO_CPLOAD \
+ li v0, SYS_ify(syscall_name); \
+ syscall; \
+ .set reorder; \
+ bne a3, zero, 99b; \
+ ret; \
+ .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
+ ENTRY (name) \
+ .set noreorder; \
+ PSEUDO_CPLOAD \
+ .set reorder; \
+ SINGLE_THREAD_P(v1); \
+ bne zero, v1, L(pseudo_cancel); \
+ .set noreorder; \
+ li v0, SYS_ify(syscall_name); \
+ syscall; \
+ .set reorder; \
+ bne a3, zero, 99b; \
+ ret; \
+ L(pseudo_cancel): \
+ SAVESTK_##args; \
+ sw ra, 28(sp); \
+ cfi_rel_offset (ra, 28); \
+ PSEUDO_SAVEGP \
+ PUSHARGS_##args; /* save syscall args */ \
+ CENABLE; \
+ PSEUDO_LOADGP \
+ sw v0, 44(sp); /* save mask */ \
+ POPARGS_##args; /* restore syscall args */ \
+ .set noreorder; \
+ li v0, SYS_ify (syscall_name); \
+ syscall; \
+ .set reorder; \
+ sw v0, 36(sp); /* save syscall result */ \
+ sw a3, 40(sp); /* save syscall error flag */ \
+ lw a0, 44(sp); /* pass mask as arg1 */ \
+ CDISABLE; \
+ PSEUDO_LOADGP \
+ lw v0, 36(sp); /* restore syscall result */ \
+ lw a3, 40(sp); /* restore syscall error flag */ \
+ lw ra, 28(sp); /* restore return address */ \
+ .set noreorder; \
+ bne a3, zero, 99b; \
+ RESTORESTK; \
+ L(pseudo_end): \
+ .set reorder;
+
+# undef PSEUDO_END
+# define PSEUDO_END(sym) cfi_endproc; .end sym; .size sym,.-sym
+
+# define PUSHARGS_0 /* nothing to do */
+# define PUSHARGS_1 PUSHARGS_0 sw a0, 0(sp); cfi_rel_offset (a0, 0);
+# define PUSHARGS_2 PUSHARGS_1 sw a1, 4(sp); cfi_rel_offset (a1, 4);
+# define PUSHARGS_3 PUSHARGS_2 sw a2, 8(sp); cfi_rel_offset (a2, 8);
+# define PUSHARGS_4 PUSHARGS_3 sw a3, 12(sp); cfi_rel_offset (a3, 12);
+# define PUSHARGS_5 PUSHARGS_4 /* handled by SAVESTK_## */
+# define PUSHARGS_6 PUSHARGS_5
+# define PUSHARGS_7 PUSHARGS_6
+
+# define POPARGS_0 /* nothing to do */
+# define POPARGS_1 POPARGS_0 lw a0, 0(sp);
+# define POPARGS_2 POPARGS_1 lw a1, 4(sp);
+# define POPARGS_3 POPARGS_2 lw a2, 8(sp);
+# define POPARGS_4 POPARGS_3 lw a3, 12(sp);
+# define POPARGS_5 POPARGS_4 /* args already in new stackframe */
+# define POPARGS_6 POPARGS_5
+# define POPARGS_7 POPARGS_6
+
+
+# define STKSPACE 48
+# define SAVESTK_0 subu sp, STKSPACE; cfi_adjust_cfa_offset(STKSPACE)
+# define SAVESTK_1 SAVESTK_0
+# define SAVESTK_2 SAVESTK_1
+# define SAVESTK_3 SAVESTK_2
+# define SAVESTK_4 SAVESTK_3
+# define SAVESTK_5 lw t0, 16(sp); \
+ SAVESTK_0; \
+ sw t0, 16(sp)
+
+# define SAVESTK_6 lw t0, 16(sp); \
+ lw t1, 20(sp); \
+ SAVESTK_0; \
+ sw t0, 16(sp); \
+ sw t1, 20(sp)
+
+# define SAVESTK_7 lw t0, 16(sp); \
+ lw t1, 20(sp); \
+ lw t2, 24(sp); \
+ SAVESTK_0; \
+ sw t0, 16(sp); \
+ sw t1, 20(sp); \
+ sw t2, 24(sp)
+
+# define RESTORESTK addu sp, STKSPACE; cfi_adjust_cfa_offset(-STKSPACE)
+
+
+# ifdef __PIC__
+/* We use jalr rather than jal. This means that the assembler will not
+ automatically restore $gp (in case libc has multiple GOTs) so we must
+ do it manually - which we have to do anyway since we don't use .cprestore.
+ It also shuts up the assembler warning about not using .cprestore. */
+# define PSEUDO_JMP(sym) la t9, sym; jalr t9;
+# else
+# define PSEUDO_JMP(sym) jal sym;
+# endif
+
+# ifdef IS_IN_libpthread
+# define CENABLE PSEUDO_JMP (__pthread_enable_asynccancel)
+# define CDISABLE PSEUDO_JMP (__pthread_disable_asynccancel)
+# elif defined IS_IN_librt
+# define CENABLE PSEUDO_JMP (__librt_enable_asynccancel)
+# define CDISABLE PSEUDO_JMP (__librt_disable_asynccancel)
+# else
+# define CENABLE PSEUDO_JMP (__libc_enable_asynccancel)
+# define CDISABLE PSEUDO_JMP (__libc_disable_asynccancel)
+# endif
+
+# ifndef __ASSEMBLER__
+# define SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) \
+ == 0, 1)
+# else
+# define SINGLE_THREAD_P(reg) \
+ READ_THREAD_POINTER(reg); \
+ lw reg, MULTIPLE_THREADS_OFFSET(reg)
+#endif
+
+#elif !defined __ASSEMBLER__
+
+# define SINGLE_THREAD_P 1
+# define NO_CANCELLATION 1
+
+#endif
+
+#ifndef __ASSEMBLER__
+# define RTLD_SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/mips/vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/vfork.S
new file mode 100644
index 000000000..a23d99cfa
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/vfork.S
@@ -0,0 +1,42 @@
+/* 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 <features.h>
+#include <tls.h>
+
+/* Save the PID value. */
+#define SAVE_PID \
+ READ_THREAD_POINTER(v1); /* Get the thread pointer. */ \
+ lw a2, PID_OFFSET(v1); /* Load the saved PID. */ \
+ subu a2, $0, a2; /* Negate it. */ \
+ bnez a2, 1f; /* If it was zero... */ \
+ lui a2, 0x8000; /* use 0x80000000 instead. */ \
+1: sw a2, PID_OFFSET(v1); /* Store the temporary PID. */
+
+/* Restore the old PID value in the parent. */
+#define RESTORE_PID \
+ beqz v0, 1f; /* If we are the parent... */ \
+ READ_THREAD_POINTER(v1); /* Get the thread pointer. */ \
+ lw a2, PID_OFFSET(v1); /* Load the saved PID. */ \
+ subu a2, $0, a2; /* Re-negate it. */ \
+ lui a0, 0x8000; /* Load 0x80000000... */ \
+ bne a2, a0, 2f; /* ... compare against it... */ \
+ li a2, 0; /* ... use 0 instead. */ \
+2: sw a2, PID_OFFSET(v1); /* Restore the PID. */ \
+1:
+
+#include <../../../../../../../libc/sysdeps/linux/mips/vfork.S>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/mq_notify.c b/libpthread/nptl/sysdeps/unix/sysv/linux/mq_notify.c
new file mode 100644
index 000000000..d82daa7ea
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/mq_notify.c
@@ -0,0 +1,285 @@
+/* Copyright (C) 2004, 2005, 2008 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contribute by Ulrich Drepper <drepper@redhat.com>, 2004.
+
+ 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 <assert.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <mqueue.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sysdep.h>
+#include <unistd.h>
+#include <sys/socket.h>
+#include <not-cancel.h>
+#include <bits/kernel-features.h>
+
+
+#ifdef __NR_mq_notify
+
+/* Defined in the kernel headers: */
+#define NOTIFY_COOKIE_LEN 32 /* Length of the cookie used. */
+#define NOTIFY_WOKENUP 1 /* Code for notifcation. */
+#define NOTIFY_REMOVED 2 /* Code for closed message queue
+ of de-notifcation. */
+
+
+/* Data structure for the queued notification requests. */
+union notify_data
+{
+ struct
+ {
+ void (*fct) (union sigval); /* The function to run. */
+ union sigval param; /* The parameter to pass. */
+ pthread_attr_t *attr; /* Attributes to create the thread with. */
+ /* NB: on 64-bit machines the struct as a size of 24 bytes. Which means
+ byte 31 can still be used for returning the status. */
+ };
+ char raw[NOTIFY_COOKIE_LEN];
+};
+
+
+/* Keep track of the initialization. */
+static pthread_once_t once = PTHREAD_ONCE_INIT;
+
+
+/* The netlink socket. */
+static int netlink_socket = -1;
+
+
+/* Barrier used to make sure data passed to the new thread is not
+ resused by the parent. */
+static pthread_barrier_t notify_barrier;
+
+
+/* Modify the signal mask. We move this into a separate function so
+ that the stack space needed for sigset_t is not deducted from what
+ the thread can use. */
+static int
+__attribute__ ((noinline))
+change_sigmask (int how, sigset_t *oss)
+{
+ sigset_t ss;
+ sigfillset (&ss);
+ return pthread_sigmask (how, &ss, oss);
+}
+
+
+/* The function used for the notification. */
+static void *
+notification_function (void *arg)
+{
+ /* Copy the function and parameter so that the parent thread can go
+ on with its life. */
+ volatile union notify_data *data = (volatile union notify_data *) arg;
+ void (*fct) (union sigval) = data->fct;
+ union sigval param = data->param;
+
+ /* Let the parent go. */
+ (void) pthread_barrier_wait (&notify_barrier);
+
+ /* Make the thread detached. */
+ (void) pthread_detach (pthread_self ());
+
+ /* The parent thread has all signals blocked. This is probably a
+ bit surprising for this thread. So we unblock all of them. */
+ (void) change_sigmask (SIG_UNBLOCK, NULL);
+
+ /* Now run the user code. */
+ fct (param);
+
+ /* And we are done. */
+ return NULL;
+}
+
+
+/* Helper thread. */
+static void *
+helper_thread (void *arg)
+{
+ while (1)
+ {
+ union notify_data data;
+
+ ssize_t n = recv (netlink_socket, &data, sizeof (data),
+ MSG_NOSIGNAL | MSG_WAITALL);
+ if (n < NOTIFY_COOKIE_LEN)
+ continue;
+
+ if (data.raw[NOTIFY_COOKIE_LEN - 1] == NOTIFY_WOKENUP)
+ {
+ /* Just create the thread as instructed. There is no way to
+ report a problem with creating a thread. */
+ pthread_t th;
+ if (__builtin_expect (pthread_create (&th, data.attr,
+ notification_function, &data)
+ == 0, 0))
+ /* Since we passed a pointer to DATA to the new thread we have
+ to wait until it is done with it. */
+ (void) pthread_barrier_wait (&notify_barrier);
+ }
+ else if (data.raw[NOTIFY_COOKIE_LEN - 1] == NOTIFY_REMOVED)
+ /* The only state we keep is the copy of the thread attributes. */
+ free (data.attr);
+ }
+ return NULL;
+}
+
+
+static void
+reset_once (void)
+{
+ once = PTHREAD_ONCE_INIT;
+}
+
+
+static void
+init_mq_netlink (void)
+{
+ /* This code might be called a second time after fork(). The file
+ descriptor is inherited from the parent. */
+ if (netlink_socket == -1)
+ {
+ /* Just a normal netlink socket, not bound. */
+ netlink_socket = socket (AF_NETLINK, SOCK_RAW, 0);
+ /* No need to do more if we have no socket. */
+ if (netlink_socket == -1)
+ return;
+
+ /* Make sure the descriptor is closed on exec. */
+ if (fcntl (netlink_socket, F_SETFD, FD_CLOEXEC) != 0)
+ goto errout;
+ }
+
+ int err = 1;
+
+ /* Initialize the barrier. */
+ if (__builtin_expect (pthread_barrier_init (&notify_barrier, NULL, 2) == 0,
+ 0))
+ {
+ /* Create the helper thread. */
+ pthread_attr_t attr;
+ (void) pthread_attr_init (&attr);
+ (void) pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
+ /* We do not need much stack space, the bare minimum will be enough. */
+ (void) pthread_attr_setstacksize (&attr, PTHREAD_STACK_MIN);
+
+ /* Temporarily block all signals so that the newly created
+ thread inherits the mask. */
+ sigset_t oss;
+ int have_no_oss = change_sigmask (SIG_BLOCK, &oss);
+
+ pthread_t th;
+ err = pthread_create (&th, &attr, helper_thread, NULL);
+
+ /* Reset the signal mask. */
+ if (!have_no_oss)
+ pthread_sigmask (SIG_SETMASK, &oss, NULL);
+
+ (void) pthread_attr_destroy (&attr);
+
+ if (err == 0)
+ {
+ static int added_atfork;
+
+ if (added_atfork == 0
+ && pthread_atfork (NULL, NULL, reset_once) != 0)
+ {
+ /* The child thread will call recv() which is a
+ cancellation point. */
+ (void) pthread_cancel (th);
+ err = 1;
+ }
+ else
+ added_atfork = 1;
+ }
+ }
+
+ if (err != 0)
+ {
+ errout:
+ close_not_cancel_no_status (netlink_socket);
+ netlink_socket = -1;
+ }
+}
+
+
+/* Register notification upon message arrival to an empty message queue
+ MQDES. */
+int
+mq_notify (mqd_t mqdes, const struct sigevent *notification)
+{
+ /* Make sure the type is correctly defined. */
+ assert (sizeof (union notify_data) == NOTIFY_COOKIE_LEN);
+
+ /* Special treatment needed for SIGEV_THREAD. */
+ if (notification == NULL || notification->sigev_notify != SIGEV_THREAD)
+ return INLINE_SYSCALL (mq_notify, 2, mqdes, notification);
+
+ /* The kernel cannot directly start threads. This will have to be
+ done at userlevel. Since we cannot start threads from signal
+ handlers we have to create a dedicated thread which waits for
+ notifications for arriving messages and creates threads in
+ response. */
+
+ /* Initialize only once. */
+ pthread_once (&once, init_mq_netlink);
+
+ /* If we cannot create the netlink socket we cannot provide
+ SIGEV_THREAD support. */
+ if (__builtin_expect (netlink_socket == -1, 0))
+ {
+ __set_errno (ENOSYS);
+ return -1;
+ }
+
+ /* Create the cookie. It will hold almost all the state. */
+ union notify_data data;
+ memset (&data, '\0', sizeof (data));
+ data.fct = notification->sigev_notify_function;
+ data.param = notification->sigev_value;
+
+ if (notification->sigev_notify_attributes != NULL)
+ {
+ /* The thread attribute has to be allocated separately. */
+ data.attr = (pthread_attr_t *) malloc (sizeof (pthread_attr_t));
+ if (data.attr == NULL)
+ return -1;
+
+ memcpy (data.attr, notification->sigev_notify_attributes,
+ sizeof (pthread_attr_t));
+ }
+
+ /* Construct the new request. */
+ struct sigevent se;
+ se.sigev_notify = SIGEV_THREAD;
+ se.sigev_signo = netlink_socket;
+ se.sigev_value.sival_ptr = &data;
+
+ /* Tell the kernel. */
+ int retval = INLINE_SYSCALL (mq_notify, 2, mqdes, &se);
+
+ /* If it failed, free the allocated memory. */
+ if (__builtin_expect (retval != 0, 0))
+ free (data.attr);
+
+ return retval;
+}
+
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/msync.S b/libpthread/nptl/sysdeps/unix/sysv/linux/msync.S
new file mode 100644
index 000000000..074a0d717
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/msync.S
@@ -0,0 +1,7 @@
+#include <sysdep-cancel.h>
+PSEUDO (__libc_msync, msync, 3)
+ret
+PSEUDO_END(__libc_msync)
+libc_hidden_def (__libc_msync)
+weak_alias (__libc_msync, msync)
+libc_hidden_weak (msync)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/nanosleep.S b/libpthread/nptl/sysdeps/unix/sysv/linux/nanosleep.S
new file mode 100644
index 000000000..71efe32f9
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/nanosleep.S
@@ -0,0 +1,9 @@
+#include <sysdep-cancel.h>
+PSEUDO (__libc_nanosleep, nanosleep, 3)
+ret
+PSEUDO_END (__libc_nanosleep)
+libc_hidden_def (__libc_nanosleep)
+weak_alias (__libc_nanosleep, __nanosleep)
+libc_hidden_weak (__nanosleep)
+weak_alias (__libc_nanosleep, nanosleep)
+libc_hidden_weak (nanosleep)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/not-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/not-cancel.h
new file mode 100644
index 000000000..bbdb0739c
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/not-cancel.h
@@ -0,0 +1,113 @@
+/* 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>
+
+/* 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
+
+/* 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)
+
+/* 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))
+
+/* Uncancelable write. */
+#define write_not_cancel(fd, buf, n) \
+ INLINE_SYSCALL (write, 3, (fd), (buf), (n))
+
+/* 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)
+
+/* Uncancelable waitpid. */
+#ifdef __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
+
+/* Uncancelable pause. */
+#ifdef __NR_pause
+# define pause_not_cancel() \
+ INLINE_SYSCALL (pause, 0)
+#else
+# 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
+
+/* Uncancelable sigsuspend. */
+#define sigsuspend_not_cancel(set) \
+ __sigsuspend_nocancel (set)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/open.S b/libpthread/nptl/sysdeps/unix/sysv/linux/open.S
new file mode 100644
index 000000000..486686a22
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/open.S
@@ -0,0 +1,21 @@
+#include <sysdep-cancel.h>
+
+/*
+extern int __open_nocancel (const char *, int, ...) attribute_hidden;
+*/
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+PSEUDO (__libc_open, open, 3)
+ret
+PSEUDO_END(__libc_open)
+
+libc_hidden_def (__open_nocancel)
+libc_hidden_def (__libc_open)
+weak_alias (__libc_open, __open)
+libc_hidden_weak (__open)
+weak_alias (__libc_open, open)
+libc_hidden_weak (open)
+
+
+
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pause.S b/libpthread/nptl/sysdeps/unix/sysv/linux/pause.S
new file mode 100644
index 000000000..3841018a8
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pause.S
@@ -0,0 +1,7 @@
+#include <sysdep-cancel.h>
+PSEUDO (__libc_pause, pause, 0)
+ret
+PSEUDO_END (__libc_pause)
+libc_hidden_def (__libc_pause)
+weak_alias (__libc_pause, pause)
+libc_hidden_weak (pause)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/Makefile b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/Makefile
new file mode 100644
index 000000000..421a62b3d
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/Makefile
@@ -0,0 +1,13 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2009 Bernhard Reutner-Fischer <uclibc@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+top_srcdir=../../../../../../../
+top_builddir=../../../../../../../
+all: objs
+include $(top_builddir)Rules.mak
+include Makefile.arch
+include $(top_srcdir)Makerules
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/Makefile.arch b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/Makefile.arch
new file mode 100644
index 000000000..df4bb6963
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/Makefile.arch
@@ -0,0 +1,18 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2009 Bernhard Reutner-Fischer <uclibc@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+libpthread_linux_arch_SSRC =
+libpthread_linux_arch_CSRC = pthread_once.c pt-__syscall_error.c
+
+libc_linux_arch_CSRC = fork.c
+libc_linux_arch_SSRC = clone.S vfork.S
+
+# powerpc32's PSEUDO_RET needs __syscall_error@local
+librt_linux_arch_CSRC = pt-__syscall_error.c
+
+ASFLAGS += -DUSE___THREAD
+
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h
new file mode 100644
index 000000000..b7c62f411
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h
@@ -0,0 +1,220 @@
+/* Machine-specific pthread type layouts. PowerPC version.
+ Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Paul Mackerras <paulus@au.ibm.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_PTHREADTYPES_H
+#define _BITS_PTHREADTYPES_H 1
+
+#include <bits/wordsize.h>
+
+#if __WORDSIZE == 64
+# define __SIZEOF_PTHREAD_ATTR_T 56
+# define __SIZEOF_PTHREAD_MUTEX_T 40
+# define __SIZEOF_PTHREAD_MUTEXATTR_T 4
+# define __SIZEOF_PTHREAD_COND_T 48
+# define __SIZEOF_PTHREAD_CONDATTR_T 4
+# define __SIZEOF_PTHREAD_RWLOCK_T 56
+# define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
+# define __SIZEOF_PTHREAD_BARRIER_T 32
+# define __SIZEOF_PTHREAD_BARRIERATTR_T 4
+#else
+# define __SIZEOF_PTHREAD_ATTR_T 36
+# define __SIZEOF_PTHREAD_MUTEX_T 24
+# define __SIZEOF_PTHREAD_MUTEXATTR_T 4
+# define __SIZEOF_PTHREAD_COND_T 48
+# define __SIZEOF_PTHREAD_CONDATTR_T 4
+# define __SIZEOF_PTHREAD_RWLOCK_T 32
+# define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
+# define __SIZEOF_PTHREAD_BARRIER_T 20
+# define __SIZEOF_PTHREAD_BARRIERATTR_T 4
+#endif
+
+
+/* Thread identifiers. The structure of the attribute type is
+ deliberately not exposed. */
+typedef unsigned long int pthread_t;
+
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_ATTR_T];
+ long int __align;
+} pthread_attr_t;
+
+
+#if __WORDSIZE == 64
+typedef struct __pthread_internal_list
+{
+ struct __pthread_internal_list *__prev;
+ struct __pthread_internal_list *__next;
+} __pthread_list_t;
+#else
+typedef struct __pthread_internal_slist
+{
+ struct __pthread_internal_slist *__next;
+} __pthread_slist_t;
+#endif
+
+
+/* Data structures for mutex handling. The structure of the attribute
+ type is deliberately not exposed. */
+typedef union
+{
+ struct __pthread_mutex_s
+ {
+ int __lock;
+ unsigned int __count;
+ int __owner;
+#if __WORDSIZE == 64
+ unsigned int __nusers;
+#endif
+ /* KIND must stay at this position in the structure to maintain
+ binary compatibility. */
+ int __kind;
+#if __WORDSIZE == 64
+ int __spins;
+ __pthread_list_t __list;
+# define __PTHREAD_MUTEX_HAVE_PREV 1
+#else
+ unsigned int __nusers;
+ __extension__ union
+ {
+ int __spins;
+ __pthread_slist_t __list;
+ };
+#endif
+ } __data;
+ char __size[__SIZEOF_PTHREAD_MUTEX_T];
+ long int __align;
+} pthread_mutex_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
+ int __align;
+} pthread_mutexattr_t;
+
+
+/* Data structure for conditional variable handling. The structure of
+ the attribute type is deliberately not exposed. */
+typedef union
+{
+ struct
+ {
+ int __lock;
+ unsigned int __futex;
+ __extension__ unsigned long long int __total_seq;
+ __extension__ unsigned long long int __wakeup_seq;
+ __extension__ unsigned long long int __woken_seq;
+ void *__mutex;
+ unsigned int __nwaiters;
+ unsigned int __broadcast_seq;
+ } __data;
+ char __size[__SIZEOF_PTHREAD_COND_T];
+ __extension__ long long int __align;
+} pthread_cond_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_CONDATTR_T];
+ int __align;
+} pthread_condattr_t;
+
+
+/* Keys for thread-specific data */
+typedef unsigned int pthread_key_t;
+
+
+/* Once-only execution */
+typedef int pthread_once_t;
+
+
+#if defined __USE_UNIX98 || defined __USE_XOPEN2K
+/* Data structure for read-write lock variable handling. The
+ structure of the attribute type is deliberately not exposed. */
+typedef union
+{
+# if __WORDSIZE == 64
+ struct
+ {
+ int __lock;
+ unsigned int __nr_readers;
+ unsigned int __readers_wakeup;
+ unsigned int __writer_wakeup;
+ unsigned int __nr_readers_queued;
+ unsigned int __nr_writers_queued;
+ int __writer;
+ int __shared;
+ unsigned long int __pad1;
+ unsigned long int __pad2;
+ /* FLAGS must stay at this position in the structure to maintain
+ binary compatibility. */
+ unsigned int __flags;
+ } __data;
+# else
+ struct
+ {
+ int __lock;
+ unsigned int __nr_readers;
+ unsigned int __readers_wakeup;
+ unsigned int __writer_wakeup;
+ unsigned int __nr_readers_queued;
+ unsigned int __nr_writers_queued;
+ unsigned char __pad1;
+ unsigned char __pad2;
+ unsigned char __shared;
+ /* FLAGS must stay at this position in the structure to maintain
+ binary compatibility. */
+ unsigned char __flags;
+ int __writer;
+ } __data;
+# endif
+ char __size[__SIZEOF_PTHREAD_RWLOCK_T];
+ long int __align;
+} pthread_rwlock_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
+ long int __align;
+} pthread_rwlockattr_t;
+#endif
+
+
+#ifdef __USE_XOPEN2K
+/* POSIX spinlock data type. */
+typedef volatile int pthread_spinlock_t;
+
+
+/* POSIX barriers data type. The structure of the type is
+ deliberately not exposed. */
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_BARRIER_T];
+ long int __align;
+} pthread_barrier_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];
+ int __align;
+} pthread_barrierattr_t;
+#endif
+
+
+#endif /* bits/pthreadtypes.h */
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/bits/semaphore.h b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/bits/semaphore.h
new file mode 100644
index 000000000..a174923e2
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/bits/semaphore.h
@@ -0,0 +1,40 @@
+/* Machine-specific POSIX semaphore type layouts. PowerPC version.
+ Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Paul Mackerras <paulus@au.ibm.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 _SEMAPHORE_H
+# error "Never use <bits/semaphore.h> directly; include <semaphore.h> instead."
+#endif
+
+#include <bits/wordsize.h>
+
+#if __WORDSIZE == 64
+# define __SIZEOF_SEM_T 32
+#else
+# define __SIZEOF_SEM_T 16
+#endif
+
+/* Value returned if `sem_open' failed. */
+#define SEM_FAILED ((sem_t *) 0)
+
+
+typedef union
+{
+ char __size[__SIZEOF_SEM_T];
+ long int __align;
+} sem_t;
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/clone.S b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/clone.S
new file mode 100644
index 000000000..91c939e57
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/clone.S
@@ -0,0 +1,5 @@
+#if defined __powerpc64__
+# include "powerpc64/clone.S"
+#else
+# include "powerpc32/clone.S"
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/createthread.c b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/createthread.c
new file mode 100644
index 000000000..c820194ae
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/createthread.c
@@ -0,0 +1,24 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Paul Mackerras <paulus@au.ibm.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/>. */
+
+/* Value passed to 'clone' for initialization of the thread register. */
+#define TLS_VALUE ((void *) (pd) \
+ + TLS_TCB_OFFSET + TLS_PRE_TCB_SIZE)
+
+/* Get the real implementation. */
+#include <sysdeps/pthread/createthread.c>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/fork.c b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/fork.c
new file mode 100644
index 000000000..06b7e1c69
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/fork.c
@@ -0,0 +1 @@
+#include "../i386/fork.c"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h
new file mode 100644
index 000000000..a04916815
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h
@@ -0,0 +1,314 @@
+/* Copyright (C) 2003, 2004, 2006-2008, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Paul Mackerras <paulus@au.ibm.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 _LOWLEVELLOCK_H
+#define _LOWLEVELLOCK_H 1
+
+#include <time.h>
+#include <sys/param.h>
+#include <bits/pthreadtypes.h>
+#include <atomic.h>
+#include <bits/kernel-features.h>
+#include <sysdep.h>
+
+#ifndef __NR_futex
+# define __NR_futex 221
+#endif
+#define FUTEX_WAIT 0
+#define FUTEX_WAKE 1
+#define FUTEX_REQUEUE 3
+#define FUTEX_CMP_REQUEUE 4
+#define FUTEX_WAKE_OP 5
+#define FUTEX_OP_CLEAR_WAKE_IF_GT_ONE ((4 << 24) | 1)
+#define FUTEX_LOCK_PI 6
+#define FUTEX_UNLOCK_PI 7
+#define FUTEX_TRYLOCK_PI 8
+#define FUTEX_WAIT_BITSET 9
+#define FUTEX_WAKE_BITSET 10
+#define FUTEX_PRIVATE_FLAG 128
+#define FUTEX_CLOCK_REALTIME 256
+
+#define FUTEX_BITSET_MATCH_ANY 0xffffffff
+
+/* Values for 'private' parameter of locking macros. Yes, the
+ definition seems to be backwards. But it is not. The bit will be
+ reversed before passing to the system call. */
+#define LLL_PRIVATE 0
+#define LLL_SHARED FUTEX_PRIVATE_FLAG
+
+#if !defined NOT_IN_libc || defined IS_IN_rtld
+/* In libc.so or ld.so all futexes are private. */
+# ifdef __ASSUME_PRIVATE_FUTEX
+# define __lll_private_flag(fl, private) \
+ ((fl) | FUTEX_PRIVATE_FLAG)
+# else
+# define __lll_private_flag(fl, private) \
+ ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex))
+# endif
+#else
+# ifdef __ASSUME_PRIVATE_FUTEX
+# define __lll_private_flag(fl, private) \
+ (((fl) | FUTEX_PRIVATE_FLAG) ^ (private))
+# else
+# define __lll_private_flag(fl, private) \
+ (__builtin_constant_p (private) \
+ ? ((private) == 0 \
+ ? ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex)) \
+ : (fl)) \
+ : ((fl) | (((private) ^ FUTEX_PRIVATE_FLAG) \
+ & THREAD_GETMEM (THREAD_SELF, header.private_futex))))
+# endif
+#endif
+
+#define lll_futex_wait(futexp, val, private) \
+ lll_futex_timed_wait (futexp, val, NULL, private)
+
+#define lll_futex_timed_wait(futexp, val, timespec, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ \
+ __ret = INTERNAL_SYSCALL (futex, __err, 4, (futexp), \
+ __lll_private_flag (FUTEX_WAIT, private), \
+ (val), (timespec)); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err) ? -__ret : __ret; \
+ })
+
+#define lll_futex_wake(futexp, nr, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ \
+ __ret = INTERNAL_SYSCALL (futex, __err, 4, (futexp), \
+ __lll_private_flag (FUTEX_WAKE, private), \
+ (nr), 0); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err) ? -__ret : __ret; \
+ })
+
+#define lll_robust_dead(futexv, private) \
+ do \
+ { \
+ INTERNAL_SYSCALL_DECL (__err); \
+ int *__futexp = &(futexv); \
+ \
+ atomic_or (__futexp, FUTEX_OWNER_DIED); \
+ INTERNAL_SYSCALL (futex, __err, 4, __futexp, \
+ __lll_private_flag (FUTEX_WAKE, private), 1, 0); \
+ } \
+ while (0)
+
+/* Returns non-zero if error happened, zero if success. */
+#define lll_futex_requeue(futexp, nr_wake, nr_move, mutex, val, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ \
+ __ret = INTERNAL_SYSCALL (futex, __err, 6, (futexp), \
+ __lll_private_flag (FUTEX_CMP_REQUEUE, private),\
+ (nr_wake), (nr_move), (mutex), (val)); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
+ })
+
+/* Returns non-zero if error happened, zero if success. */
+#define lll_futex_wake_unlock(futexp, nr_wake, nr_wake2, futexp2, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ \
+ __ret = INTERNAL_SYSCALL (futex, __err, 6, (futexp), \
+ __lll_private_flag (FUTEX_WAKE_OP, private), \
+ (nr_wake), (nr_wake2), (futexp2), \
+ FUTEX_OP_CLEAR_WAKE_IF_GT_ONE); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
+ })
+
+
+#ifdef UP
+# define __lll_acq_instr ""
+# define __lll_rel_instr ""
+#else
+# define __lll_acq_instr "isync"
+# 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 __lll_rel_instr "lwsync"
+# 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 __lll_rel_instr "sync"
+# endif
+#endif
+
+/* Set *futex to ID if it is 0, atomically. Returns the old value */
+#define __lll_robust_trylock(futex, id) \
+ ({ int __val; \
+ __asm__ __volatile__ ("1: lwarx %0,0,%2" MUTEX_HINT_ACQ "\n" \
+ " cmpwi 0,%0,0\n" \
+ " bne 2f\n" \
+ " stwcx. %3,0,%2\n" \
+ " bne- 1b\n" \
+ "2: " __lll_acq_instr \
+ : "=&r" (__val), "=m" (*futex) \
+ : "r" (futex), "r" (id), "m" (*futex) \
+ : "cr0", "memory"); \
+ __val; \
+ })
+
+#define lll_robust_trylock(lock, id) __lll_robust_trylock (&(lock), id)
+
+/* Set *futex to 1 if it is 0, atomically. Returns the old value */
+#define __lll_trylock(futex) __lll_robust_trylock (futex, 1)
+
+#define lll_trylock(lock) __lll_trylock (&(lock))
+
+/* Set *futex to 2 if it is 0, atomically. Returns the old value */
+#define __lll_cond_trylock(futex) __lll_robust_trylock (futex, 2)
+
+#define lll_cond_trylock(lock) __lll_cond_trylock (&(lock))
+
+
+extern void __lll_lock_wait_private (int *futex) attribute_hidden;
+extern void __lll_lock_wait (int *futex, int private) attribute_hidden;
+extern int __lll_robust_lock_wait (int *futex, int private) attribute_hidden;
+
+#define lll_lock(lock, private) \
+ (void) ({ \
+ int *__futex = &(lock); \
+ if (__builtin_expect (atomic_compare_and_exchange_val_acq (__futex, 1, 0),\
+ 0) != 0) \
+ { \
+ if (__builtin_constant_p (private) && (private) == LLL_PRIVATE) \
+ __lll_lock_wait_private (__futex); \
+ else \
+ __lll_lock_wait (__futex, private); \
+ } \
+ })
+
+#define lll_robust_lock(lock, id, private) \
+ ({ \
+ int *__futex = &(lock); \
+ int __val = 0; \
+ if (__builtin_expect (atomic_compare_and_exchange_bool_acq (__futex, id, \
+ 0), 0)) \
+ __val = __lll_robust_lock_wait (__futex, private); \
+ __val; \
+ })
+
+#define lll_cond_lock(lock, private) \
+ (void) ({ \
+ int *__futex = &(lock); \
+ if (__builtin_expect (atomic_compare_and_exchange_val_acq (__futex, 2, 0),\
+ 0) != 0) \
+ __lll_lock_wait (__futex, private); \
+ })
+
+#define lll_robust_cond_lock(lock, id, private) \
+ ({ \
+ int *__futex = &(lock); \
+ int __val = 0; \
+ int __id = id | FUTEX_WAITERS; \
+ if (__builtin_expect (atomic_compare_and_exchange_bool_acq (__futex, __id,\
+ 0), 0)) \
+ __val = __lll_robust_lock_wait (__futex, private); \
+ __val; \
+ })
+
+
+extern int __lll_timedlock_wait
+ (int *futex, const struct timespec *, int private) attribute_hidden;
+extern int __lll_robust_timedlock_wait
+ (int *futex, const struct timespec *, int private) attribute_hidden;
+
+#define lll_timedlock(lock, abstime, private) \
+ ({ \
+ int *__futex = &(lock); \
+ int __val = 0; \
+ if (__builtin_expect (atomic_compare_and_exchange_val_acq (__futex, 1, 0),\
+ 0) != 0) \
+ __val = __lll_timedlock_wait (__futex, abstime, private); \
+ __val; \
+ })
+
+#define lll_robust_timedlock(lock, abstime, id, private) \
+ ({ \
+ int *__futex = &(lock); \
+ int __val = 0; \
+ if (__builtin_expect (atomic_compare_and_exchange_bool_acq (__futex, id, \
+ 0), 0)) \
+ __val = __lll_robust_timedlock_wait (__futex, abstime, private); \
+ __val; \
+ })
+
+#define lll_unlock(lock, private) \
+ ((void) ({ \
+ int *__futex = &(lock); \
+ int __val = atomic_exchange_rel (__futex, 0); \
+ if (__builtin_expect (__val > 1, 0)) \
+ lll_futex_wake (__futex, 1, private); \
+ }))
+
+#define lll_robust_unlock(lock, private) \
+ ((void) ({ \
+ int *__futex = &(lock); \
+ int __val = atomic_exchange_rel (__futex, 0); \
+ if (__builtin_expect (__val & FUTEX_WAITERS, 0)) \
+ lll_futex_wake (__futex, 1, private); \
+ }))
+
+#define lll_islocked(futex) \
+ (futex != 0)
+
+
+/* Initializers for lock. */
+#define LLL_LOCK_INITIALIZER (0)
+#define LLL_LOCK_INITIALIZER_LOCKED (1)
+
+/* The states of a lock are:
+ 0 - untaken
+ 1 - taken by one user
+ >1 - taken by more users */
+
+/* The kernel notifies a process which uses CLONE_CLEARTID via futex
+ wakeup when the clone terminates. The memory location contains the
+ thread ID while the clone is running and is reset to zero
+ afterwards. */
+#define lll_wait_tid(tid) \
+ do { \
+ __typeof (tid) __tid; \
+ while ((__tid = (tid)) != 0) \
+ lll_futex_wait (&(tid), __tid, LLL_SHARED); \
+ } while (0)
+
+extern int __lll_timedwait_tid (int *, const struct timespec *)
+ attribute_hidden;
+
+#define lll_timedwait_tid(tid, abstime) \
+ ({ \
+ int __res = 0; \
+ if ((tid) != 0) \
+ __res = __lll_timedwait_tid (&(tid), (abstime)); \
+ __res; \
+ })
+
+#endif /* lowlevellock.h */
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S
new file mode 100644
index 000000000..675a997e9
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S
@@ -0,0 +1,9 @@
+/* We want an #include_next, but we are the main source file.
+ So, #include ourselves and in that incarnation we can use #include_next. */
+#ifndef INCLUDED_SELF
+# define INCLUDED_SELF
+# include <clone.S>
+#else
+# define RESET_PID
+# include_next <clone.S>
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h
new file mode 100644
index 000000000..c163dcdba
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h
@@ -0,0 +1,118 @@
+/* Cancellable system call stubs. Linux/PowerPC version.
+ Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Franz Sirl <Franz.Sirl-kernel@lauterbach.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 <sysdep.h>
+#include <tls.h>
+#ifndef __ASSEMBLER__
+# include <pthreadP.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .section ".text"; \
+ ENTRY (name) \
+ SINGLE_THREAD_P; \
+ bne- .Lpseudo_cancel; \
+ .type __##syscall_name##_nocancel,@function; \
+ .globl __##syscall_name##_nocancel; \
+ __##syscall_name##_nocancel: \
+ DO_CALL (SYS_ify (syscall_name)); \
+ PSEUDO_RET; \
+ .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
+ .Lpseudo_cancel: \
+ stwu 1,-48(1); \
+ cfi_adjust_cfa_offset (48); \
+ mflr 9; \
+ stw 9,52(1); \
+ cfi_offset (lr, 4); \
+ DOCARGS_##args; /* save syscall args around CENABLE. */ \
+ CENABLE; \
+ stw 3,16(1); /* store CENABLE return value (MASK). */ \
+ UNDOCARGS_##args; /* restore syscall args. */ \
+ DO_CALL (SYS_ify (syscall_name)); \
+ mfcr 0; /* save CR/R3 around CDISABLE. */ \
+ stw 3,8(1); \
+ stw 0,12(1); \
+ lwz 3,16(1); /* pass MASK to CDISABLE. */ \
+ CDISABLE; \
+ lwz 4,52(1); \
+ lwz 0,12(1); /* restore CR/R3. */ \
+ lwz 3,8(1); \
+ mtlr 4; \
+ mtcr 0; \
+ addi 1,1,48;
+
+# define DOCARGS_0
+# define UNDOCARGS_0
+
+# define DOCARGS_1 stw 3,20(1); DOCARGS_0
+# define UNDOCARGS_1 lwz 3,20(1); UNDOCARGS_0
+
+# define DOCARGS_2 stw 4,24(1); DOCARGS_1
+# define UNDOCARGS_2 lwz 4,24(1); UNDOCARGS_1
+
+# define DOCARGS_3 stw 5,28(1); DOCARGS_2
+# define UNDOCARGS_3 lwz 5,28(1); UNDOCARGS_2
+
+# define DOCARGS_4 stw 6,32(1); DOCARGS_3
+# define UNDOCARGS_4 lwz 6,32(1); UNDOCARGS_3
+
+# define DOCARGS_5 stw 7,36(1); DOCARGS_4
+# define UNDOCARGS_5 lwz 7,36(1); UNDOCARGS_4
+
+# define DOCARGS_6 stw 8,40(1); DOCARGS_5
+# define UNDOCARGS_6 lwz 8,40(1); UNDOCARGS_5
+
+# ifdef IS_IN_libpthread
+# define CENABLE bl __pthread_enable_asynccancel@local
+# define CDISABLE bl __pthread_disable_asynccancel@local
+# elif !defined NOT_IN_libc
+# define CENABLE bl __libc_enable_asynccancel@local
+# define CDISABLE bl __libc_disable_asynccancel@local
+# elif defined IS_IN_librt
+# define CENABLE bl __librt_enable_asynccancel@local
+# define CDISABLE bl __librt_disable_asynccancel@local
+# else
+# error Unsupported library
+# endif
+
+# ifndef __ASSEMBLER__
+# define SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+# else
+# define SINGLE_THREAD_P \
+ lwz 10,MULTIPLE_THREADS_OFFSET(2); \
+ cmpwi 10,0
+# endif
+
+#elif !defined __ASSEMBLER__
+
+# define SINGLE_THREAD_P (1)
+# define NO_CANCELLATION 1
+
+#endif
+
+#ifndef __ASSEMBLER__
+# define RTLD_SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+#endif
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-64/vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S
index 199f0017f..28c59fd2e 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-64/vfork.S
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S
@@ -1,6 +1,6 @@
-/* Copyright (C) 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.
- Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
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,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/>. */
-#include <sysdep-cancel.h>
+#include <sysdep.h>
#define _ERRNO_H 1
#include <bits/errno.h>
+#include <bits/kernel-features.h>
+#include <tcb-offsets.h>
/* Clone the calling process, but without copying the whole address space.
The calling process is suspended until the new process exits or is
@@ -27,28 +28,30 @@
and the process ID of the new process to the old process. */
ENTRY (__vfork)
-#ifdef SHARED
- larl %r1,__libc_pthread_functions
- lg %r1,0(%r1)
-#else
- .weak pthread_create
- larl %r1,pthread_create
-#endif
- ltgr %r1,%r1
- jgne HIDDEN_JUMPTARGET(__fork)
-
- /* Do vfork system call. */
- svc SYS_ify (vfork)
-
- /* Check for error. */
- lghi %r4,-4095
- clgr %r2,%r4
- jgnl SYSCALL_ERROR_LABEL
-
- /* Normal return. */
- br %r14
-PSEUDO_END(__vfork)
-
+ lwz 0,PID(2)
+ cmpwi 0,0,0
+ neg 0,0
+ bne- 0,1f
+ lis 0,0x8000
+1: stw 0,PID(2)
+
+ DO_CALL (SYS_ify (vfork))
+
+ cmpwi 1,3,0
+ beqlr- 1
+
+ lwz 0,PID(2)
+ /* Cannot use clrlwi. here, because cr0 needs to be preserved
+ until PSEUDO_RET. */
+ clrlwi 4,0,1
+ cmpwi 1,4,0
+ beq- 1,1f
+ neg 4,0
+1: stw 4,PID(2)
+
+ PSEUDO_RET
+
+PSEUDO_END (__vfork)
libc_hidden_def (__vfork)
-
weak_alias (__vfork, vfork)
+libc_hidden_weak(vfork)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S
new file mode 100644
index 000000000..675a997e9
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S
@@ -0,0 +1,9 @@
+/* We want an #include_next, but we are the main source file.
+ So, #include ourselves and in that incarnation we can use #include_next. */
+#ifndef INCLUDED_SELF
+# define INCLUDED_SELF
+# include <clone.S>
+#else
+# define RESET_PID
+# include_next <clone.S>
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h
new file mode 100644
index 000000000..534281acc
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h
@@ -0,0 +1,120 @@
+/* Cancellable system call stubs. Linux/PowerPC64 version.
+ Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Franz Sirl <Franz.Sirl-kernel@lauterbach.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 <sysdep.h>
+#include <tls.h>
+#ifndef __ASSEMBLER__
+# include <pthreadP.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+# define DASHDASHPFX(str) __##str
+
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .section ".text"; \
+ ENTRY (name) \
+ SINGLE_THREAD_P; \
+ bne- .Lpseudo_cancel; \
+ .type DASHDASHPFX(syscall_name##_nocancel),@function; \
+ .globl DASHDASHPFX(syscall_name##_nocancel); \
+ DASHDASHPFX(syscall_name##_nocancel): \
+ DO_CALL (SYS_ify (syscall_name)); \
+ PSEUDO_RET; \
+ .size DASHDASHPFX(syscall_name##_nocancel),.-DASHDASHPFX(syscall_name##_nocancel); \
+ .Lpseudo_cancel: \
+ stdu 1,-128(1); \
+ cfi_adjust_cfa_offset (128); \
+ mflr 9; \
+ std 9,128+16(1); \
+ cfi_offset (lr, 16); \
+ DOCARGS_##args; /* save syscall args around CENABLE. */ \
+ CENABLE; \
+ std 3,72(1); /* store CENABLE return value (MASK). */ \
+ UNDOCARGS_##args; /* restore syscall args. */ \
+ DO_CALL (SYS_ify (syscall_name)); \
+ mfcr 0; /* save CR/R3 around CDISABLE. */ \
+ std 3,64(1); \
+ std 0,8(1); \
+ ld 3,72(1); /* pass MASK to CDISABLE. */ \
+ CDISABLE; \
+ ld 9,128+16(1); \
+ ld 0,8(1); /* restore CR/R3. */ \
+ ld 3,64(1); \
+ mtlr 9; \
+ mtcr 0; \
+ addi 1,1,128;
+
+# define DOCARGS_0
+# define UNDOCARGS_0
+
+# define DOCARGS_1 std 3,80(1); DOCARGS_0
+# define UNDOCARGS_1 ld 3,80(1); UNDOCARGS_0
+
+# define DOCARGS_2 std 4,88(1); DOCARGS_1
+# define UNDOCARGS_2 ld 4,88(1); UNDOCARGS_1
+
+# define DOCARGS_3 std 5,96(1); DOCARGS_2
+# define UNDOCARGS_3 ld 5,96(1); UNDOCARGS_2
+
+# define DOCARGS_4 std 6,104(1); DOCARGS_3
+# define UNDOCARGS_4 ld 6,104(1); UNDOCARGS_3
+
+# define DOCARGS_5 std 7,112(1); DOCARGS_4
+# define UNDOCARGS_5 ld 7,112(1); UNDOCARGS_4
+
+# define DOCARGS_6 std 8,120(1); DOCARGS_5
+# define UNDOCARGS_6 ld 8,120(1); UNDOCARGS_5
+
+# ifdef IS_IN_libpthread
+# define CENABLE bl JUMPTARGET(__pthread_enable_asynccancel)
+# define CDISABLE bl JUMPTARGET(__pthread_disable_asynccancel)
+# elif !defined NOT_IN_libc
+# define CENABLE bl JUMPTARGET(__libc_enable_asynccancel)
+# define CDISABLE bl JUMPTARGET(__libc_disable_asynccancel)
+# elif defined IS_IN_librt
+# define CENABLE bl JUMPTARGET(__librt_enable_asynccancel)
+# define CDISABLE bl JUMPTARGET(__librt_disable_asynccancel)
+# else
+# error Unsupported library
+# endif
+
+# ifndef __ASSEMBLER__
+# define SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+# else
+# define SINGLE_THREAD_P \
+ lwz 10,MULTIPLE_THREADS_OFFSET(13); \
+ cmpwi 10,0
+# endif
+
+#elif !defined __ASSEMBLER__
+
+# define SINGLE_THREAD_P (1)
+# define NO_CANCELLATION 1
+
+#endif
+
+#ifndef __ASSEMBLER__
+# define RTLD_SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_create.c b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_create.c
new file mode 100644
index 000000000..172223af3
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_create.c
@@ -0,0 +1 @@
+#include "../x86_64/timer_create.c"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_delete.c b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_delete.c
new file mode 100644
index 000000000..537516e0a
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_delete.c
@@ -0,0 +1 @@
+#include "../x86_64/timer_delete.c"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_getoverr.c b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_getoverr.c
new file mode 100644
index 000000000..3f21a73c9
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_getoverr.c
@@ -0,0 +1 @@
+#include "../x86_64/timer_getoverr.c"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_gettime.c b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_gettime.c
new file mode 100644
index 000000000..a50143adc
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_gettime.c
@@ -0,0 +1 @@
+#include "../x86_64/timer_gettime.c"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_settime.c b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_settime.c
new file mode 100644
index 000000000..37baeffac
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/timer_settime.c
@@ -0,0 +1 @@
+#include "../x86_64/timer_settime.c"
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-32/vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S
index 6dfeca86d..a86ab527c 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-32/vfork.S
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S
@@ -1,6 +1,6 @@
-/* Copyright (C) 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.
- Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
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,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/>. */
-#include <sysdep-cancel.h>
+#include <sysdep.h>
#define _ERRNO_H 1
#include <bits/errno.h>
+#include <bits/kernel-features.h>
+#include <tcb-offsets.h>
/* Clone the calling process, but without copying the whole address space.
The calling process is suspended until the new process exits or is
@@ -27,43 +28,29 @@
and the process ID of the new process to the old process. */
ENTRY (__vfork)
- basr %r1,0
-0:
-#ifdef SHARED
- al %r1,4f-0b(%r1)
- l %r1,0(%r1)
- ltr %r1,%r1
-#else
- icm %r1,15,4f-0b(%r1)
-#endif
- jne 1f
+ lwz 0,PID(13)
+ cmpwi 0,0,0
+ neg 0,0
+ bne- 0,1f
+ lis 0,0x8000
+1: stw 0,PID(13)
- /* Do vfork system call. */
- svc SYS_ify (vfork)
+ DO_CALL (SYS_ify (vfork))
- /* Check for error. */
- lhi %r4,-4095
- clr %r2,%r4
- jnl SYSCALL_ERROR_LABEL
+ cmpwi 1,3,0
+ beqlr- 1
- /* Normal return. */
- br %r14
-1:
- basr %r1,0
-2:
- al %r1,3f-2b(%r1)
- br %r1
-3:
- .long HIDDEN_JUMPTARGET(__fork)-2b
-4:
-#ifdef SHARED
- .long __libc_pthread_functions-0b
-#else
- .weak pthread_create
- .long pthread_create
-#endif
-PSEUDO_END(__vfork)
+ lwz 0,PID(13)
+ clrlwi 4,0,1
+ cmpwi 1,4,0
+ beq- 1,1f
+ neg 4,0
+1: stw 4,PID(13)
-libc_hidden_def (__vfork)
+ PSEUDO_RET
+PSEUDO_END (__vfork)
+libc_hidden_def (__vfork)
weak_alias (__vfork, vfork)
+libc_hidden_weak(vfork)
+
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/pt-__syscall_error.c b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/pt-__syscall_error.c
new file mode 100644
index 000000000..2a402e5af
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/pt-__syscall_error.c
@@ -0,0 +1 @@
+#include <../../../../../../../libc/sysdeps/linux/powerpc/__syscall_error.c>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/pt-longjmp.c b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/pt-longjmp.c
new file mode 100644
index 000000000..d1b82afca
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/pt-longjmp.c
@@ -0,0 +1,36 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <setjmp.h>
+#include <stdlib.h>
+#include <bits/wordsize.h>
+#include "pthreadP.h"
+
+void
+__vmx_longjmp (jmp_buf env, int val)
+{
+ __libc_longjmp (env, val);
+}
+
+void
+__vmx_siglongjmp (jmp_buf env, int val)
+{
+ __libc_siglongjmp (env, val);
+}
+weak_alias(__vmx_longjmp, longjmp)
+weak_alias(__vmx_siglongjmp, siglongjmp)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_once.c b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_once.c
new file mode 100644
index 000000000..8e6edcbf9
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_once.c
@@ -0,0 +1,100 @@
+/* Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Paul Mackerras <paulus@au.ibm.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 "pthreadP.h"
+#include <lowlevellock.h>
+
+
+unsigned long int __fork_generation attribute_hidden;
+
+
+static void
+clear_once_control (void *arg)
+{
+ pthread_once_t *once_control = (pthread_once_t *) arg;
+
+ *once_control = 0;
+ lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE);
+}
+
+
+int
+attribute_protected
+__pthread_once (pthread_once_t *once_control, void (*init_routine) (void))
+{
+ for (;;)
+ {
+ int oldval;
+ int newval;
+ int tmp;
+
+ /* Pseudo code:
+ newval = __fork_generation | 1;
+ oldval = *once_control;
+ if ((oldval & 2) == 0)
+ *once_control = newval;
+ Do this atomically.
+ */
+ newval = __fork_generation | 1;
+ __asm__ __volatile__ ("1: lwarx %0,0,%3\n"
+ " andi. %1,%0,2\n"
+ " bne 2f\n"
+ " stwcx. %4,0,%3\n"
+ " bne 1b\n"
+ "2: isync"
+ : "=&r" (oldval), "=&r" (tmp), "=m" (*once_control)
+ : "r" (once_control), "r" (newval), "m" (*once_control)
+ : "cr0");
+
+ /* Check if the initializer has already been done. */
+ if ((oldval & 2) != 0)
+ return 0;
+
+ /* Check if another thread already runs the initializer. */
+ if ((oldval & 1) == 0)
+ break;
+
+ /* Check whether the initializer execution was interrupted by a fork. */
+ if (oldval != newval)
+ break;
+
+ /* Same generation, some other thread was faster. Wait. */
+ lll_futex_wait (once_control, oldval, LLL_PRIVATE);
+ }
+
+
+ /* This thread is the first here. Do the initialization.
+ Register a cleanup handler so that in case the thread gets
+ interrupted the initialization can be restarted. */
+ pthread_cleanup_push (clear_once_control, once_control);
+
+ init_routine ();
+
+ pthread_cleanup_pop (0);
+
+
+ /* Add one to *once_control to take the bottom 2 bits from 01 to 10. */
+ atomic_increment (once_control);
+
+ /* Wake up all other threads. */
+ lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE);
+
+ return 0;
+}
+weak_alias (__pthread_once, pthread_once)
+strong_alias (__pthread_once, __pthread_once_internal)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_spin_unlock.c b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_spin_unlock.c
new file mode 100644
index 000000000..0132f9cdc
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/pthread_spin_unlock.c
@@ -0,0 +1,28 @@
+/* pthread_spin_unlock -- unlock a spin lock. PowerPC version.
+ 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 "pthreadP.h"
+#include <lowlevellock.h>
+
+int
+pthread_spin_unlock (pthread_spinlock_t *lock)
+{
+ __asm__ __volatile__ (__lll_rel_instr ::: "memory");
+ *lock = 0;
+ return 0;
+}
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/sem_post.c b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/sem_post.c
new file mode 100644
index 000000000..d79bd1c93
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/sem_post.c
@@ -0,0 +1,45 @@
+/* sem_post -- post to a POSIX semaphore. Powerpc version.
+ Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Paul Mackerras <paulus@au.ibm.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 <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <internaltypes.h>
+#include <semaphore.h>
+
+int
+sem_post (sem_t *sem)
+{
+ struct new_sem *isem = (struct new_sem *) sem;
+
+ __asm__ __volatile__ (__lll_rel_instr ::: "memory");
+ atomic_increment (&isem->value);
+ __asm__ __volatile__ (__lll_acq_instr ::: "memory");
+ if (isem->nwaiters > 0)
+ {
+ int err = lll_futex_wake (&isem->value, 1,
+ isem->private ^ FUTEX_PRIVATE_FLAG);
+ if (__builtin_expect (err, 0) < 0)
+ {
+ __set_errno (-err);
+ return -1;
+ }
+ }
+ return 0;
+}
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h
new file mode 100644
index 000000000..dab7e0beb
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h
@@ -0,0 +1,5 @@
+#if defined(__powerpc64__)
+#include "powerpc64/sysdep-cancel.h"
+#else
+#include "powerpc32/sysdep-cancel.h"
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/vfork.S
new file mode 100644
index 000000000..27d29020e
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/vfork.S
@@ -0,0 +1,5 @@
+#if defined __powerpc64__
+# include "powerpc64/vfork.S"
+#else
+# include "powerpc32/vfork.S"
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-accept.S b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-accept.S
new file mode 100644
index 000000000..24062101d
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-accept.S
@@ -0,0 +1,12 @@
+#include <sysdep-cancel.h>
+#ifndef __NR_accept
+#error Missing definition of NR_accept needed for cancellation.
+#endif
+PSEUDO (__libc_accept, accept, 3)
+ret
+PSEUDO_END(__libc_accept)
+libpthread_hidden_def (__libc_accept)
+weak_alias (__libc_accept, __accept)
+libpthread_hidden_weak (__accept)
+weak_alias (__libc_accept, accept)
+libpthread_hidden_weak (accept)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-close.S b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-close.S
new file mode 100644
index 000000000..ab32ca598
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-close.S
@@ -0,0 +1,9 @@
+#include <sysdep-cancel.h>
+PSEUDO (__libc_close, close, 1)
+ret
+PSEUDO_END (__libc_close)
+libpthread_hidden_def (__libc_close)
+weak_alias (__libc_close, __close)
+libpthread_hidden_weak (__close)
+weak_alias (__libc_close, close)
+libpthread_hidden_weak (close)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-connect.S b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-connect.S
new file mode 100644
index 000000000..b5124f8ec
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-connect.S
@@ -0,0 +1,12 @@
+#include <sysdep-cancel.h>
+#ifndef __NR_connect
+#error Missing definition of NR_connect needed for cancellation.
+#endif
+PSEUDO (__libc_connect, connect, 3)
+ret
+PSEUDO_END(__libc_connect)
+libpthread_hidden_def (__libc_connect)
+weak_alias (__libc_connect, __connect)
+libpthread_hidden_weak (__connect)
+weak_alias (__libc_connect, connect)
+libpthread_hidden_weak (connect)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-fcntl.c b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-fcntl.c
new file mode 100644
index 000000000..0a8fd3cc2
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-fcntl.c
@@ -0,0 +1 @@
+#include <../../../../../../libc/sysdeps/linux/common/__syscall_fcntl.c>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-fork.c b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-fork.c
new file mode 100644
index 000000000..69839cb5f
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-fork.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <unistd.h>
+
+#if 0
+static pid_t
+__fork (void)
+{
+ return __libc_fork ();
+}
+strong_alias (__fork, fork)
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-fsync.c b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-fsync.c
new file mode 100644
index 000000000..6ec4821c7
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-fsync.c
@@ -0,0 +1,2 @@
+#include <pthreadP.h>
+#include <../../../../../../libc/sysdeps/linux/common/fsync.c>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-llseek.c b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-llseek.c
new file mode 100644
index 000000000..1d0d57870
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-llseek.c
@@ -0,0 +1,3 @@
+#include <pthreadP.h>
+#define libc_hidden libpthread_hidden
+#include <../../../../../../libc/sysdeps/linux/common/llseek.c>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-lseek.S b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-lseek.S
new file mode 100644
index 000000000..4db71722a
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-lseek.S
@@ -0,0 +1,7 @@
+#include <sysdep-cancel.h>
+PSEUDO (__libc_lseek, lseek, 3)
+ret
+PSEUDO_END (__libc_lseek)
+libpthread_hidden_def (__libc_lseek)
+weak_alias (__libc_lseek, lseek)
+libpthread_hidden_weak (lseek)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-msgrcv.c b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-msgrcv.c
new file mode 100644
index 000000000..3bb9d53df
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-msgrcv.c
@@ -0,0 +1,2 @@
+#define L_msgrcv
+#include <../../../../../../libc/misc/sysvipc/msgq.c>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-msgsnd.c b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-msgsnd.c
new file mode 100644
index 000000000..1566f65f4
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-msgsnd.c
@@ -0,0 +1,2 @@
+#define L_msgsnd
+#include <../../../../../../libc/misc/sysvipc/msgq.c>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-msync.S b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-msync.S
new file mode 100644
index 000000000..640270ad9
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-msync.S
@@ -0,0 +1,7 @@
+#include <sysdep-cancel.h>
+PSEUDO (__libc_msync, msync, 3)
+ret
+PSEUDO_END(__libc_msync)
+libpthread_hidden_def (__libc_msync)
+weak_alias (__libc_msync, msync)
+libpthread_hidden_weak (msync)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-nanosleep.S b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-nanosleep.S
new file mode 100644
index 000000000..08d8f0150
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-nanosleep.S
@@ -0,0 +1,9 @@
+#include <sysdep-cancel.h>
+PSEUDO (__libc_nanosleep, nanosleep, 3)
+ret
+PSEUDO_END (__libc_nanosleep)
+libpthread_hidden_def (__libc_nanosleep)
+weak_alias (__libc_nanosleep, __nanosleep)
+libpthread_hidden_weak (__nanosleep)
+weak_alias (__libc_nanosleep, nanosleep)
+libpthread_hidden_weak (nanosleep)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-open.S b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-open.S
new file mode 100644
index 000000000..39ed92cc7
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-open.S
@@ -0,0 +1,9 @@
+#include <sysdep-cancel.h>
+PSEUDO (__libc_open, open, 3)
+ret
+PSEUDO_END (__libc_open)
+libpthread_hidden_def (__libc_open)
+weak_alias (__libc_open, __open)
+libpthread_hidden_weak (__open)
+weak_alias (__libc_open, open)
+libpthread_hidden_weak (open)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-open64.c b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-open64.c
new file mode 100644
index 000000000..2029539a7
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-open64.c
@@ -0,0 +1 @@
+#include <../../../../../../libc/sysdeps/linux/common/open64.c>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-pause.S b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-pause.S
new file mode 100644
index 000000000..c6cb57180
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-pause.S
@@ -0,0 +1,7 @@
+#include <sysdep-cancel.h>
+PSEUDO (__libc_pause, pause, 0)
+ret
+PSEUDO_END (__libc_pause)
+libpthread_hidden_def (__libc_pause)
+weak_alias (__libc_pause, pause)
+libpthread_hidden_weak (pause)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-pread_pwrite.c b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-pread_pwrite.c
new file mode 100644
index 000000000..f32c0a670
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-pread_pwrite.c
@@ -0,0 +1 @@
+#include "pread_write.c"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-raise.c b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-raise.c
new file mode 100644
index 000000000..6784b1b58
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-raise.c
@@ -0,0 +1,51 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <signal.h>
+#include <sysdep.h>
+#include <tls.h>
+#include <bits/kernel-features.h>
+
+
+int
+raise (
+ int sig)
+{
+#if (defined(__ASSUME_TGKILL) && __ASSUME_TGKILL) || defined __NR_tgkill
+ /* raise is an async-safe function. It could be called while the
+ fork function temporarily invalidated the PID field. Adjust for
+ that. */
+ pid_t pid = THREAD_GETMEM (THREAD_SELF, pid);
+ if (__builtin_expect (pid < 0, 0))
+ pid = -pid;
+#endif
+
+#if defined(__ASSUME_TGKILL) && __ASSUME_TGKILL
+ return INLINE_SYSCALL (tgkill, 3, pid, THREAD_GETMEM (THREAD_SELF, tid),
+ sig);
+#else
+# ifdef __NR_tgkill
+ int res = INLINE_SYSCALL (tgkill, 3, pid, THREAD_GETMEM (THREAD_SELF, tid),
+ sig);
+ if (res != -1 || errno != ENOSYS)
+ return res;
+# endif
+ return INLINE_SYSCALL (tkill, 2, THREAD_GETMEM (THREAD_SELF, tid), sig);
+#endif
+}
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-read.S b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-read.S
new file mode 100644
index 000000000..623ba27a8
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-read.S
@@ -0,0 +1,9 @@
+#include <sysdep-cancel.h>
+PSEUDO (__libc_read, read, 3)
+ret
+PSEUDO_END (__libc_read)
+libpthread_hidden_def (__libc_read)
+weak_alias (__libc_read, __read)
+libpthread_hidden_weak (__read)
+weak_alias (__libc_read, read)
+libpthread_hidden_weak (read)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-recv.S b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-recv.S
new file mode 100644
index 000000000..6d2e3c2d6
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-recv.S
@@ -0,0 +1,12 @@
+#include <sysdep-cancel.h>
+#ifndef __NR_recv
+#error Missing definition of NR_recv needed for cancellation.
+#endif
+PSEUDO (__libc_recv, recv, 4)
+ret
+PSEUDO_END(__libc_recv)
+libpthread_hidden_def (__libc_recv)
+weak_alias (__libc_recv, __recv)
+libpthread_hidden_weak (__recv)
+weak_alias (__libc_recv, recv)
+libpthread_hidden_weak (recv)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-recvfrom.S b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-recvfrom.S
new file mode 100644
index 000000000..96aeeaa3d
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-recvfrom.S
@@ -0,0 +1,12 @@
+#include <sysdep-cancel.h>
+#ifndef __NR_recvfrom
+#error Missing definition of NR_recvfrom needed for cancellation.
+#endif
+PSEUDO (__libc_recvfrom, recvfrom, 6)
+ret
+PSEUDO_END(__libc_recvfrom)
+libpthread_hidden_def (__libc_recvfrom)
+weak_alias (__libc_recvfrom, __recvfrom)
+libpthread_hidden_weak (__recvfrom)
+weak_alias (__libc_recvfrom, recvfrom)
+libpthread_hidden_weak (recvfrom)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-recvmsg.S b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-recvmsg.S
new file mode 100644
index 000000000..f7161e47c
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-recvmsg.S
@@ -0,0 +1,12 @@
+#include <sysdep-cancel.h>
+#ifndef __NR_recvmsg
+#error Missing definition of NR_recvmsg needed for cancellation.
+#endif
+PSEUDO (__libc_recvmsg, recvmsg, 3)
+ret
+PSEUDO_END(__libc_recvmsg)
+libpthread_hidden_def (__libc_recvmsg)
+weak_alias (__libc_recvmsg, __recvmsg)
+libpthread_hidden_weak (__recvmsg)
+weak_alias (__libc_recvmsg, recvmsg)
+libpthread_hidden_weak (recvmsg)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-send.S b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-send.S
new file mode 100644
index 000000000..76bed39ec
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-send.S
@@ -0,0 +1,12 @@
+#include <sysdep-cancel.h>
+#ifndef __NR_send
+#error Missing definition of NR_send needed for cancellation.
+#endif
+PSEUDO (__libc_send, send, 4)
+ret
+PSEUDO_END (__libc_send)
+libpthread_hidden_def (__libc_send)
+weak_alias (__libc_send, __send)
+libpthread_hidden_weak (__send)
+weak_alias (__libc_send, send)
+libpthread_hidden_weak (send)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-sendmsg.S b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-sendmsg.S
new file mode 100644
index 000000000..d17096eae
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-sendmsg.S
@@ -0,0 +1,12 @@
+#include <sysdep-cancel.h>
+#ifndef __NR_sendmsg
+#error Missing definition of NR_sendmsg needed for cancellation.
+#endif
+PSEUDO (__libc_sendmsg, sendmsg, 3)
+ret
+PSEUDO_END(__libc_sendmsg)
+libpthread_hidden_def (__libc_sendmsg)
+weak_alias (__libc_sendmsg, __sendmsg)
+libpthread_hidden_weak (__sendmsg)
+weak_alias (__libc_sendmsg, sendmsg)
+libpthread_hidden_weak (sendmsg)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-sendto.S b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-sendto.S
new file mode 100644
index 000000000..d07a71f8a
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-sendto.S
@@ -0,0 +1,12 @@
+#include <sysdep-cancel.h>
+#ifndef __NR_sendto
+#error Missing definition of NR_sendto needed for cancellation.
+#endif
+PSEUDO (__libc_sendto, sendto, 6)
+ret
+PSEUDO_END(__libc_sendto)
+libpthread_hidden_def (__libc_sendto)
+weak_alias (__libc_sendto, __sendto)
+libpthread_hidden_weak (__sendto)
+weak_alias (__libc_sendto, sendto)
+libpthread_hidden_weak (sendto)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-sigwait.c b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-sigwait.c
new file mode 100644
index 000000000..bde0a9292
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-sigwait.c
@@ -0,0 +1,2 @@
+#include <pthreadP.h>
+#include "../../../../../../libc/signal/sigwait.c"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-sleep.c b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-sleep.c
new file mode 100644
index 000000000..9e948adce
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-sleep.c
@@ -0,0 +1,2 @@
+#include <pthreadP.h>
+#include <../../../../../../libc/unistd/sleep.c>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-tcdrain.c b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-tcdrain.c
new file mode 100644
index 000000000..07c1f8233
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-tcdrain.c
@@ -0,0 +1 @@
+#include <../../../../../../libc/termios/tcdrain.c>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-tempname.c b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-tempname.c
new file mode 100644
index 000000000..bfb810290
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-tempname.c
@@ -0,0 +1 @@
+#include <../../../../../../libc/misc/internals/tempname.c>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-wait.c b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-wait.c
new file mode 100644
index 000000000..a05c3eb49
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-wait.c
@@ -0,0 +1,2 @@
+#include <pthreadP.h>
+#include <../../../../../../libc/sysdeps/linux/common/wait.c>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-waitpid.c b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-waitpid.c
new file mode 100644
index 000000000..8461c3ff2
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-waitpid.c
@@ -0,0 +1 @@
+#include <../../../../../../libc/sysdeps/linux/common/waitpid.c>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-write.S b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-write.S
new file mode 100644
index 000000000..6bc666779
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-write.S
@@ -0,0 +1,9 @@
+#include <sysdep-cancel.h>
+PSEUDO (__libc_write, write, 3)
+ret
+PSEUDO_END (__libc_write)
+libpthread_hidden_def (__libc_write)
+weak_alias (__libc_write, __write)
+libpthread_hidden_weak (__write)
+weak_alias (__libc_write, write)
+libpthread_hidden_weak (write)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pthread-pi-defines.sym b/libpthread/nptl/sysdeps/unix/sysv/linux/pthread-pi-defines.sym
new file mode 100644
index 000000000..46fbd0de7
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pthread-pi-defines.sym
@@ -0,0 +1,8 @@
+#include <pthreadP.h>
+
+-- These PI macros are used by assembly code.
+
+MUTEX_KIND offsetof (pthread_mutex_t, __data.__kind)
+ROBUST_BIT PTHREAD_MUTEX_ROBUST_NORMAL_NP
+PI_BIT PTHREAD_MUTEX_PRIO_INHERIT_NP
+PS_BIT PTHREAD_MUTEX_PSHARED_BIT
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_attr_getaffinity.c b/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_attr_getaffinity.c
new file mode 100644
index 000000000..b1051cf80
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_attr_getaffinity.c
@@ -0,0 +1,54 @@
+/* Copyright (C) 2003, 2004 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 <assert.h>
+#include <errno.h>
+#include <pthreadP.h>
+#include <string.h>
+#include <sysdep.h>
+#include <sys/types.h>
+
+
+int
+pthread_attr_getaffinity_np(const pthread_attr_t *attr, size_t cpusetsize,
+ cpu_set_t *cpuset)
+{
+ const struct pthread_attr *iattr;
+
+ assert (sizeof (*attr) >= sizeof (struct pthread_attr));
+ iattr = (const struct pthread_attr *) attr;
+
+ if (iattr->cpuset != NULL)
+ {
+ /* Check whether there are any bits set beyond the limits
+ the user requested. */
+ size_t cnt;
+ for (cnt = cpusetsize; cnt < iattr->cpusetsize; ++cnt)
+ if (((char *) iattr->cpuset)[cnt] != 0)
+ return EINVAL;
+
+ void *p = mempcpy (cpuset, iattr->cpuset, iattr->cpusetsize);
+ if (cpusetsize > iattr->cpusetsize)
+ memset (p, '\0', cpusetsize - iattr->cpusetsize);
+ }
+ else
+ /* We have no information. */
+ memset (cpuset, -1, cpusetsize);
+
+ return 0;
+}
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_attr_setaffinity.c b/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_attr_setaffinity.c
new file mode 100644
index 000000000..bee957576
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_attr_setaffinity.c
@@ -0,0 +1,80 @@
+/* Copyright (C) 2003, 2004, 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 <assert.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <string.h>
+#include <pthreadP.h>
+
+
+/* Defined in pthread_setaffinity.c. */
+extern size_t __kernel_cpumask_size attribute_hidden;
+extern int __determine_cpumask_size (pid_t tid);
+libpthread_hidden_proto(__determine_cpumask_size)
+
+int
+pthread_attr_setaffinity_np (pthread_attr_t *attr, size_t cpusetsize,
+ const cpu_set_t *cpuset)
+{
+ struct pthread_attr *iattr;
+
+ assert (sizeof (*attr) >= sizeof (struct pthread_attr));
+ iattr = (struct pthread_attr *) attr;
+
+ if (cpuset == NULL || cpusetsize == 0)
+ {
+ free (iattr->cpuset);
+ iattr->cpuset = NULL;
+ iattr->cpusetsize = 0;
+ }
+ else
+ {
+ if (__kernel_cpumask_size == 0)
+ {
+ int res = __determine_cpumask_size (THREAD_SELF->tid);
+ if (res != 0)
+ /* Some serious problem. */
+ return res;
+ }
+
+ /* Check whether the new bitmask has any bit set beyond the
+ last one the kernel accepts. */
+ size_t cnt;
+ for (cnt = __kernel_cpumask_size; cnt < cpusetsize; ++cnt)
+ if (((char *) cpuset)[cnt] != '\0')
+ /* Found a nonzero byte. This means the user request cannot be
+ fulfilled. */
+ return EINVAL;
+
+ if (iattr->cpusetsize != cpusetsize)
+ {
+ void *newp = (cpu_set_t *) realloc (iattr->cpuset, cpusetsize);
+ if (newp == NULL)
+ return ENOMEM;
+
+ iattr->cpuset = newp;
+ iattr->cpusetsize = cpusetsize;
+ }
+
+ memcpy (iattr->cpuset, cpuset, cpusetsize);
+ }
+
+ return 0;
+}
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_getaffinity.c b/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_getaffinity.c
new file mode 100644
index 000000000..57a903a60
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_getaffinity.c
@@ -0,0 +1,45 @@
+/* Copyright (C) 2003, 2004 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 <errno.h>
+#include <limits.h>
+#include <pthreadP.h>
+#include <string.h>
+#include <sysdep.h>
+#include <sys/param.h>
+#include <sys/types.h>
+
+
+int
+__pthread_getaffinity_np (pthread_t th, size_t cpusetsize, cpu_set_t *cpuset)
+{
+ const struct pthread *pd = (const struct pthread *) th;
+
+ INTERNAL_SYSCALL_DECL (err);
+ int res = INTERNAL_SYSCALL (sched_getaffinity, err, 3, pd->tid,
+ MIN (INT_MAX, cpusetsize), cpuset);
+ if (INTERNAL_SYSCALL_ERROR_P (res, err))
+ return INTERNAL_SYSCALL_ERRNO (res, err);
+
+ /* Clean the rest of the memory the kernel didn't do. */
+ memset ((char *) cpuset + res, '\0', cpusetsize - res);
+
+ return 0;
+}
+strong_alias(__pthread_getaffinity_np, pthread_getaffinity_np)
+
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_getcpuclockid.c b/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_getcpuclockid.c
new file mode 100644
index 000000000..ca3570f5f
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_getcpuclockid.c
@@ -0,0 +1,56 @@
+/* Copyright (C) 2000, 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; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <pthreadP.h>
+#include <sys/time.h>
+#include <tls.h>
+
+
+int
+pthread_getcpuclockid (
+ pthread_t threadid,
+ clockid_t *clockid)
+{
+ struct pthread *pd = (struct pthread *) threadid;
+
+ /* Make sure the descriptor is valid. */
+ if (INVALID_TD_P (pd))
+ /* Not a valid thread handle. */
+ return ESRCH;
+
+#ifdef CLOCK_THREAD_CPUTIME_ID
+ /* We need to store the thread ID in the CLOCKID variable together
+ with a number identifying the clock. We reserve the low 3 bits
+ for the clock ID and the rest for the thread ID. This is
+ problematic if the thread ID is too large. But 29 bits should be
+ fine.
+
+ If some day more clock IDs are needed the ID part can be
+ enlarged. The IDs are entirely internal. */
+ if (pd->tid >= 1 << (8 * sizeof (*clockid) - CLOCK_IDFIELD_SIZE))
+ return ERANGE;
+
+ /* Store the number. */
+ *clockid = CLOCK_THREAD_CPUTIME_ID | (pd->tid << CLOCK_IDFIELD_SIZE);
+
+ return 0;
+#else
+ /* We don't have a timer for that. */
+ return ENOENT;
+#endif
+}
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_kill.c b/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_kill.c
new file mode 100644
index 000000000..5bc6e0651
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_kill.c
@@ -0,0 +1,77 @@
+/* Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <signal.h>
+#include <pthreadP.h>
+#include <tls.h>
+#include <sysdep.h>
+#include <bits/kernel-features.h>
+
+
+int
+__pthread_kill (
+ pthread_t threadid,
+ int signo)
+{
+ struct pthread *pd = (struct pthread *) threadid;
+
+ /* Make sure the descriptor is valid. */
+ if (DEBUGGING_P && INVALID_TD_P (pd))
+ /* Not a valid thread handle. */
+ return ESRCH;
+
+ /* Force load of pd->tid into local variable or register. Otherwise
+ if a thread exits between ESRCH test and tgkill, we might return
+ EINVAL, because pd->tid would be cleared by the kernel. */
+ pid_t tid = atomic_forced_read (pd->tid);
+ if (__builtin_expect (tid <= 0, 0))
+ /* Not a valid thread handle. */
+ return ESRCH;
+
+ /* Disallow sending the signal we use for cancellation, timers, for
+ for the setxid implementation. */
+ if (signo == SIGCANCEL || signo == SIGTIMER || signo == SIGSETXID)
+ return EINVAL;
+
+ /* We have a special syscall to do the work. */
+ INTERNAL_SYSCALL_DECL (err);
+
+ /* One comment: The PID field in the TCB can temporarily be changed
+ (in fork). But this must not affect this code here. Since this
+ function would have to be called while the thread is executing
+ fork, it would have to happen in a signal handler. But this is
+ no allowed, pthread_kill is not guaranteed to be async-safe. */
+ int val;
+#if defined(__ASSUME_TGKILL) && __ASSUME_TGKILL
+ val = INTERNAL_SYSCALL (tgkill, err, 3, THREAD_GETMEM (THREAD_SELF, pid),
+ tid, signo);
+#else
+# ifdef __NR_tgkill
+ val = INTERNAL_SYSCALL (tgkill, err, 3, THREAD_GETMEM (THREAD_SELF, pid),
+ tid, signo);
+ if (INTERNAL_SYSCALL_ERROR_P (val, err)
+ && INTERNAL_SYSCALL_ERRNO (val, err) == ENOSYS)
+# endif
+ val = INTERNAL_SYSCALL (tkill, err, 2, tid, signo);
+#endif
+
+ return (INTERNAL_SYSCALL_ERROR_P (val, err)
+ ? INTERNAL_SYSCALL_ERRNO (val, err) : 0);
+}
+strong_alias (__pthread_kill, pthread_kill)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_mutex_cond_lock.c b/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_mutex_cond_lock.c
new file mode 100644
index 000000000..804bfab44
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_mutex_cond_lock.c
@@ -0,0 +1,14 @@
+#include <pthreadP.h>
+
+#define LLL_MUTEX_LOCK(mutex) \
+ lll_cond_lock ((mutex)->__data.__lock, PTHREAD_MUTEX_PSHARED (mutex))
+#define LLL_MUTEX_TRYLOCK(mutex) \
+ lll_cond_trylock ((mutex)->__data.__lock)
+#define LLL_ROBUST_MUTEX_LOCK(mutex, id) \
+ lll_robust_cond_lock ((mutex)->__data.__lock, id, \
+ PTHREAD_ROBUST_MUTEX_PSHARED (mutex))
+#define __pthread_mutex_lock __pthread_mutex_cond_lock
+#define __pthread_mutex_lock_full __pthread_mutex_cond_lock_full
+#define NO_INCR
+
+#include <pthread_mutex_lock.c>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_setaffinity.c b/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_setaffinity.c
new file mode 100644
index 000000000..3589b8efd
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_setaffinity.c
@@ -0,0 +1,91 @@
+/* Copyright (C) 2003, 2004, 2006, 2007 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 <alloca.h>
+#include <errno.h>
+#include <pthreadP.h>
+#include <sysdep.h>
+#include <sys/types.h>
+
+
+size_t __kernel_cpumask_size attribute_hidden;
+
+
+/* Determine the current affinity. As a side affect we learn
+ about the size of the cpumask_t in the kernel. */
+extern int __determine_cpumask_size (pid_t tid);
+libpthread_hidden_proto(__determine_cpumask_size)
+int __determine_cpumask_size (pid_t tid)
+{
+ INTERNAL_SYSCALL_DECL (err);
+ int res;
+
+ size_t psize = 128;
+ void *p = alloca (psize);
+
+ while (res = INTERNAL_SYSCALL (sched_getaffinity, err, 3, tid, psize, p),
+ INTERNAL_SYSCALL_ERROR_P (res, err)
+ && INTERNAL_SYSCALL_ERRNO (res, err) == EINVAL)
+ p = extend_alloca (p, psize, 2 * psize);
+
+ if (res == 0 || INTERNAL_SYSCALL_ERROR_P (res, err))
+ return INTERNAL_SYSCALL_ERRNO (res, err);
+
+ __kernel_cpumask_size = res;
+
+ return 0;
+}
+libpthread_hidden_def(__determine_cpumask_size)
+
+int
+pthread_setaffinity_np (pthread_t th, size_t cpusetsize,
+ const cpu_set_t *cpuset)
+{
+ const struct pthread *pd = (const struct pthread *) th;
+
+ INTERNAL_SYSCALL_DECL (err);
+ int res;
+
+ if (__builtin_expect (__kernel_cpumask_size == 0, 0))
+ {
+ res = __determine_cpumask_size (pd->tid);
+ if (res != 0)
+ return res;
+ }
+
+ /* We now know the size of the kernel cpumask_t. Make sure the user
+ does not request to set a bit beyond that. */
+ size_t cnt;
+ for (cnt = __kernel_cpumask_size; cnt < cpusetsize; ++cnt)
+ if (((char *) cpuset)[cnt] != '\0')
+ /* Found a nonzero byte. This means the user request cannot be
+ fulfilled. */
+ return EINVAL;
+
+ res = INTERNAL_SYSCALL (sched_setaffinity, err, 3, pd->tid, cpusetsize,
+ cpuset);
+
+#ifdef RESET_VGETCPU_CACHE
+ if (!INTERNAL_SYSCALL_ERROR_P (res, err))
+ RESET_VGETCPU_CACHE ();
+#endif
+
+ return (INTERNAL_SYSCALL_ERROR_P (res, err)
+ ? INTERNAL_SYSCALL_ERRNO (res, err)
+ : 0);
+}
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_sigqueue.c b/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_sigqueue.c
new file mode 100644
index 000000000..2b7fa1471
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_sigqueue.c
@@ -0,0 +1,82 @@
+/* Copyright (C) 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2009.
+
+ 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 <signal.h>
+#include <string.h>
+#include <unistd.h>
+#include <pthreadP.h>
+#include <tls.h>
+#include <sysdep.h>
+#include <bits/kernel-features.h>
+
+
+int
+pthread_sigqueue (
+ pthread_t threadid,
+ int signo,
+ const union sigval value)
+{
+#ifdef __NR_rt_tgsigqueueinfo
+ struct pthread *pd = (struct pthread *) threadid;
+
+ /* Make sure the descriptor is valid. */
+ if (DEBUGGING_P && INVALID_TD_P (pd))
+ /* Not a valid thread handle. */
+ return ESRCH;
+
+ /* Force load of pd->tid into local variable or register. Otherwise
+ if a thread exits between ESRCH test and tgkill, we might return
+ EINVAL, because pd->tid would be cleared by the kernel. */
+ pid_t tid = atomic_forced_read (pd->tid);
+ if (__builtin_expect (tid <= 0, 0))
+ /* Not a valid thread handle. */
+ return ESRCH;
+
+ /* Disallow sending the signal we use for cancellation, timers, for
+ for the setxid implementation. */
+ if (signo == SIGCANCEL || signo == SIGTIMER || signo == SIGSETXID)
+ return EINVAL;
+
+ /* Set up the siginfo_t structure. */
+ siginfo_t info;
+ memset (&info, '\0', sizeof (siginfo_t));
+ info.si_signo = signo;
+ info.si_code = SI_QUEUE;
+ info.si_pid = THREAD_GETMEM (THREAD_SELF, pid);
+ info.si_uid = getuid ();
+ info.si_value = value;
+
+ /* We have a special syscall to do the work. */
+ INTERNAL_SYSCALL_DECL (err);
+
+ /* One comment: The PID field in the TCB can temporarily be changed
+ (in fork). But this must not affect this code here. Since this
+ function would have to be called while the thread is executing
+ fork, it would have to happen in a signal handler. But this is
+ no allowed, pthread_sigqueue is not guaranteed to be async-safe. */
+ int val = INTERNAL_SYSCALL (rt_tgsigqueueinfo, err, 4,
+ THREAD_GETMEM (THREAD_SELF, pid),
+ tid, signo, &info);
+
+ return (INTERNAL_SYSCALL_ERROR_P (val, err)
+ ? INTERNAL_SYSCALL_ERRNO (val, err) : 0);
+#else
+ return ENOSYS;
+#endif
+}
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_yield.c b/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_yield.c
new file mode 100644
index 000000000..e36b2a63e
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_yield.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread.h>
+#include <sched.h>
+
+
+/* With the 1-on-1 model we implement this function is equivalent to
+ the 'sched_yield' function. */
+int
+pthread_yield (void)
+{
+ return sched_yield ();
+}
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/raise.c b/libpthread/nptl/sysdeps/unix/sysv/linux/raise.c
new file mode 100644
index 000000000..8aa4830c0
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/raise.c
@@ -0,0 +1,73 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <limits.h>
+#include <signal.h>
+#include <sysdep.h>
+#include <pthreadP.h>
+#include <bits/kernel-features.h>
+
+
+int
+raise (
+ int sig)
+{
+ struct pthread *pd = THREAD_SELF;
+#if (defined(__ASSUME_TGKILL) && __ASSUME_TGKILL) || defined __NR_tgkill
+ pid_t pid = THREAD_GETMEM (pd, pid);
+#endif
+ pid_t selftid = THREAD_GETMEM (pd, tid);
+ if (selftid == 0)
+ {
+ /* This system call is not supposed to fail. */
+#ifdef INTERNAL_SYSCALL
+ INTERNAL_SYSCALL_DECL (err);
+ selftid = INTERNAL_SYSCALL (gettid, err, 0);
+#else
+ selftid = INLINE_SYSCALL (gettid, 0);
+#endif
+ THREAD_SETMEM (pd, tid, selftid);
+
+#if (defined(__ASSUME_TGKILL) && __ASSUME_TGKILL) || defined __NR_tgkill
+ /* We do not set the PID field in the TID here since we might be
+ called from a signal handler while the thread executes fork. */
+ pid = selftid;
+#endif
+ }
+#if (defined(__ASSUME_TGKILL) && __ASSUME_TGKILL) || defined __NR_tgkill
+ else
+ /* raise is an async-safe function. It could be called while the
+ fork/vfork function temporarily invalidated the PID field. Adjust for
+ that. */
+ if (__builtin_expect (pid <= 0, 0))
+ pid = (pid & INT_MAX) == 0 ? selftid : -pid;
+#endif
+
+#if defined(__ASSUME_TGKILL) && __ASSUME_TGKILL
+ return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
+#else
+# ifdef __NR_tgkill
+ int res = INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
+ if (res != -1 || errno != ENOSYS)
+ return res;
+# endif
+ return INLINE_SYSCALL (tkill, 2, selftid, sig);
+#endif
+}
+libc_hidden_def (raise)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/read.S b/libpthread/nptl/sysdeps/unix/sysv/linux/read.S
new file mode 100644
index 000000000..d3adfa84c
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/read.S
@@ -0,0 +1,19 @@
+#include <sysdep-cancel.h>
+
+/*
+extern int __read_nocancel (int, void *, size_t) attribute_hidden;
+*/
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+PSEUDO (__libc_read, read, 3)
+ret
+PSEUDO_END(__libc_read)
+
+libc_hidden_def (__read_nocancel)
+libc_hidden_def (__libc_read)
+weak_alias (__libc_read, __read)
+libc_hidden_weak (__read)
+weak_alias (__libc_read, read)
+libc_hidden_weak (read)
+
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/recv.S b/libpthread/nptl/sysdeps/unix/sysv/linux/recv.S
new file mode 100644
index 000000000..95fa6516e
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/recv.S
@@ -0,0 +1,12 @@
+#include <sysdep-cancel.h>
+#ifndef __NR_recv
+#error Missing definition of NR_recv needed for cancellation.
+#endif
+PSEUDO (__libc_recv, recv, 4)
+ret
+PSEUDO_END(__libc_recv)
+libc_hidden_def (__libc_recv)
+weak_alias (__libc_recv, __recv)
+libc_hidden_weak (__recv)
+weak_alias (__libc_recv, recv)
+libc_hidden_weak (recv)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/recvfrom.S b/libpthread/nptl/sysdeps/unix/sysv/linux/recvfrom.S
new file mode 100644
index 000000000..d9cc1e9b4
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/recvfrom.S
@@ -0,0 +1,12 @@
+#include <sysdep-cancel.h>
+#ifndef __NR_recvfrom
+#error Missing definition of NR_recvfrom needed for cancellation.
+#endif
+PSEUDO (__libc_recvfrom, recvfrom, 6)
+ret
+PSEUDO_END(__libc_recvfrom)
+libc_hidden_def (__libc_recvfrom)
+weak_alias (__libc_recvfrom, __recvfrom)
+libc_hidden_weak (__recvfrom)
+weak_alias (__libc_recvfrom, recvfrom)
+libc_hidden_weak (recvfrom)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/recvmsg.S b/libpthread/nptl/sysdeps/unix/sysv/linux/recvmsg.S
new file mode 100644
index 000000000..c761b907c
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/recvmsg.S
@@ -0,0 +1,12 @@
+#include <sysdep-cancel.h>
+#ifndef __NR_recvmsg
+#error Missing definition of NR_recvmsg needed for cancellation.
+#endif
+PSEUDO (__libc_recvmsg, recvmsg, 3)
+ret
+PSEUDO_END(__libc_recvmsg)
+libc_hidden_def (__libc_recvmsg)
+weak_alias (__libc_recvmsg, __recvmsg)
+libc_hidden_weak (__recvmsg)
+weak_alias (__libc_recvmsg, recvmsg)
+libc_hidden_weak (recvmsg)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/register-atfork.c b/libpthread/nptl/sysdeps/unix/sysv/linux/register-atfork.c
new file mode 100644
index 000000000..b745f9d71
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/register-atfork.c
@@ -0,0 +1,148 @@
+/* Copyright (C) 2002, 2003, 2005, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fork.h>
+#include <atomic.h>
+#include <tls.h>
+
+
+/* Lock to protect allocation and deallocation of fork handlers. */
+int __fork_lock = LLL_LOCK_INITIALIZER;
+
+
+/* Number of pre-allocated handler entries. */
+#define NHANDLER 48
+
+/* Memory pool for fork handler structures. */
+static struct fork_handler_pool
+{
+ struct fork_handler_pool *next;
+ struct fork_handler mem[NHANDLER];
+} fork_handler_pool;
+
+
+static struct fork_handler *
+fork_handler_alloc (void)
+{
+ struct fork_handler_pool *runp = &fork_handler_pool;
+ struct fork_handler *result = NULL;
+ unsigned int i;
+
+ do
+ {
+ /* Search for an empty entry. */
+ for (i = 0; i < NHANDLER; ++i)
+ if (runp->mem[i].refcntr == 0)
+ goto found;
+ }
+ while ((runp = runp->next) != NULL);
+
+ /* We have to allocate a new entry. */
+ runp = (struct fork_handler_pool *) calloc (1, sizeof (*runp));
+ if (runp != NULL)
+ {
+ /* Enqueue the new memory pool into the list. */
+ runp->next = fork_handler_pool.next;
+ fork_handler_pool.next = runp;
+
+ /* We use the last entry on the page. This means when we start
+ searching from the front the next time we will find the first
+ entry unused. */
+ i = NHANDLER - 1;
+
+ found:
+ result = &runp->mem[i];
+ result->refcntr = 1;
+ result->need_signal = 0;
+ }
+
+ return result;
+}
+
+
+int
+__register_atfork (
+ void (*prepare) (void),
+ void (*parent) (void),
+ void (*child) (void),
+ void *dso_handle)
+{
+ /* Get the lock to not conflict with other allocations. */
+ lll_lock (__fork_lock, LLL_PRIVATE);
+
+ struct fork_handler *newp = fork_handler_alloc ();
+
+ if (newp != NULL)
+ {
+ /* Initialize the new record. */
+ newp->prepare_handler = prepare;
+ newp->parent_handler = parent;
+ newp->child_handler = child;
+ newp->dso_handle = dso_handle;
+
+ __linkin_atfork (newp);
+ }
+
+ /* Release the lock. */
+ lll_unlock (__fork_lock, LLL_PRIVATE);
+
+ return newp == NULL ? ENOMEM : 0;
+}
+libc_hidden_def (__register_atfork)
+
+
+void
+attribute_hidden
+__linkin_atfork (struct fork_handler *newp)
+{
+ do
+ newp->next = __fork_handlers;
+ while (catomic_compare_and_exchange_bool_acq (&__fork_handlers,
+ newp, newp->next) != 0);
+}
+
+#if 0
+libc_freeres_fn (free_mem)
+{
+ /* Get the lock to not conflict with running forks. */
+ lll_lock (__fork_lock, LLL_PRIVATE);
+
+ /* No more fork handlers. */
+ __fork_handlers = NULL;
+
+ /* Free eventually alloated memory blocks for the object pool. */
+ struct fork_handler_pool *runp = fork_handler_pool.next;
+
+ memset (&fork_handler_pool, '\0', sizeof (fork_handler_pool));
+
+ /* Release the lock. */
+ lll_unlock (__fork_lock, LLL_PRIVATE);
+
+ /* We can free the memory after releasing the lock. */
+ while (runp != NULL)
+ {
+ struct fork_handler_pool *oldp = runp;
+ runp = runp->next;
+ free (oldp);
+ }
+}
+#endif
+
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sem_post.c b/libpthread/nptl/sysdeps/unix/sysv/linux/sem_post.c
new file mode 100644
index 000000000..384b4a49b
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sem_post.c
@@ -0,0 +1,56 @@
+/* sem_post -- post to a POSIX semaphore. Generic futex-using version.
+ Copyright (C) 2003, 2004, 2007, 2008 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/>. */
+
+#include <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <internaltypes.h>
+#include <semaphore.h>
+#include <tls.h>
+
+int
+sem_post (sem_t *sem)
+{
+ struct new_sem *isem = (struct new_sem *) sem;
+
+ __typeof (isem->value) cur;
+ do
+ {
+ cur = isem->value;
+ if (isem->value == SEM_VALUE_MAX)
+ {
+ __set_errno (EOVERFLOW);
+ return -1;
+ }
+ }
+ while (atomic_compare_and_exchange_bool_acq (&isem->value, cur + 1, cur));
+
+ atomic_full_barrier ();
+ if (isem->nwaiters > 0)
+ {
+ int err = lll_futex_wake (&isem->value, 1,
+ isem->private ^ FUTEX_PRIVATE_FLAG);
+ if (__builtin_expect (err, 0) < 0)
+ {
+ __set_errno (-err);
+ return -1;
+ }
+ }
+ return 0;
+}
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sem_timedwait.c b/libpthread/nptl/sysdeps/unix/sysv/linux/sem_timedwait.c
new file mode 100644
index 000000000..8c3ef47c5
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sem_timedwait.c
@@ -0,0 +1,110 @@
+/* sem_timedwait -- wait on a semaphore. Generic futex-using version.
+ Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Paul Mackerras <paulus@au.ibm.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 <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <internaltypes.h>
+#include <semaphore.h>
+
+#include <pthreadP.h>
+
+
+extern void __sem_wait_cleanup (void *arg) attribute_hidden;
+
+
+int
+sem_timedwait (sem_t *sem, const struct timespec *abstime)
+{
+ struct new_sem *isem = (struct new_sem *) sem;
+ int err;
+
+ if (atomic_decrement_if_positive (&isem->value) > 0)
+ return 0;
+
+ if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ atomic_increment (&isem->nwaiters);
+
+ pthread_cleanup_push (__sem_wait_cleanup, isem);
+
+ while (1)
+ {
+ struct timeval tv;
+ struct timespec rt;
+ int sec, nsec;
+
+ /* Get the current time. */
+ __gettimeofday (&tv, NULL);
+
+ /* Compute relative timeout. */
+ sec = abstime->tv_sec - tv.tv_sec;
+ nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+ if (nsec < 0)
+ {
+ nsec += 1000000000;
+ --sec;
+ }
+
+ /* Already timed out? */
+ err = -ETIMEDOUT;
+ if (sec < 0)
+ {
+ __set_errno (ETIMEDOUT);
+ err = -1;
+ break;
+ }
+
+ /* Do wait. */
+ rt.tv_sec = sec;
+ rt.tv_nsec = nsec;
+
+ /* Enable asynchronous cancellation. Required by the standard. */
+ int oldtype = __pthread_enable_asynccancel ();
+
+ err = lll_futex_timed_wait (&isem->value, 0, &rt,
+ isem->private ^ FUTEX_PRIVATE_FLAG);
+
+ /* Disable asynchronous cancellation. */
+ __pthread_disable_asynccancel (oldtype);
+
+ if (err != 0 && err != -EWOULDBLOCK)
+ {
+ __set_errno (-err);
+ err = -1;
+ break;
+ }
+
+ if (atomic_decrement_if_positive (&isem->value) > 0)
+ {
+ err = 0;
+ break;
+ }
+ }
+
+ pthread_cleanup_pop (0);
+
+ atomic_decrement (&isem->nwaiters);
+
+ return err;
+}
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sem_trywait.c b/libpthread/nptl/sysdeps/unix/sysv/linux/sem_trywait.c
new file mode 100644
index 000000000..1b7c514a2
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sem_trywait.c
@@ -0,0 +1,42 @@
+/* sem_trywait -- wait on a semaphore. Generic futex-using version.
+ Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Paul Mackerras <paulus@au.ibm.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 <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <internaltypes.h>
+#include <semaphore.h>
+
+
+int
+sem_trywait (sem_t *sem)
+{
+ int *futex = (int *) sem;
+ int val;
+
+ if (*futex > 0)
+ {
+ val = atomic_decrement_if_positive (futex);
+ if (val > 0)
+ return 0;
+ }
+
+ __set_errno (EAGAIN);
+ return -1;
+}
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sem_wait.c b/libpthread/nptl/sysdeps/unix/sysv/linux/sem_wait.c
new file mode 100644
index 000000000..014800dd8
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sem_wait.c
@@ -0,0 +1,82 @@
+/* sem_wait -- wait on a semaphore. Generic futex-using version.
+ Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Paul Mackerras <paulus@au.ibm.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 <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <internaltypes.h>
+#include <semaphore.h>
+
+#include <pthreadP.h>
+
+
+void
+attribute_hidden
+__sem_wait_cleanup (void *arg)
+{
+ struct new_sem *isem = (struct new_sem *) arg;
+
+ atomic_decrement (&isem->nwaiters);
+}
+
+
+int
+sem_wait (sem_t *sem)
+{
+ struct new_sem *isem = (struct new_sem *) sem;
+ int err;
+
+ if (atomic_decrement_if_positive (&isem->value) > 0)
+ return 0;
+
+ atomic_increment (&isem->nwaiters);
+
+ pthread_cleanup_push (__sem_wait_cleanup, isem);
+
+ while (1)
+ {
+ /* Enable asynchronous cancellation. Required by the standard. */
+ int oldtype = __pthread_enable_asynccancel ();
+
+ err = lll_futex_wait (&isem->value, 0,
+ isem->private ^ FUTEX_PRIVATE_FLAG);
+
+ /* Disable asynchronous cancellation. */
+ __pthread_disable_asynccancel (oldtype);
+
+ if (err != 0 && err != -EWOULDBLOCK)
+ {
+ __set_errno (-err);
+ err = -1;
+ break;
+ }
+
+ if (atomic_decrement_if_positive (&isem->value) > 0)
+ {
+ err = 0;
+ break;
+ }
+ }
+
+ pthread_cleanup_pop (0);
+
+ atomic_decrement (&isem->nwaiters);
+
+ return err;
+}
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/send.S b/libpthread/nptl/sysdeps/unix/sysv/linux/send.S
new file mode 100644
index 000000000..eb744c712
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/send.S
@@ -0,0 +1,12 @@
+#include <sysdep-cancel.h>
+#ifndef __NR_send
+#error Missing definition of NR_send needed for cancellation.
+#endif
+PSEUDO (__libc_send, send, 4)
+ret
+PSEUDO_END (__libc_send)
+libc_hidden_def (__libc_send)
+weak_alias (__libc_send, __send)
+libc_hidden_weak (__send)
+weak_alias (__libc_send, send)
+libc_hidden_weak (send)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sendmsg.S b/libpthread/nptl/sysdeps/unix/sysv/linux/sendmsg.S
new file mode 100644
index 000000000..4c41e01c1
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sendmsg.S
@@ -0,0 +1,12 @@
+#include <sysdep-cancel.h>
+#ifndef __NR_sendmsg
+#error Missing definition of NR_sendmsg needed for cancellation.
+#endif
+PSEUDO (__libc_sendmsg, sendmsg, 3)
+ret
+PSEUDO_END(__libc_sendmsg)
+libc_hidden_def (__libc_sendmsg)
+weak_alias (__libc_sendmsg, __sendmsg)
+libc_hidden_weak (__sendmsg)
+weak_alias (__libc_sendmsg, sendmsg)
+libc_hidden_weak (sendmsg)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sendto.S b/libpthread/nptl/sysdeps/unix/sysv/linux/sendto.S
new file mode 100644
index 000000000..7cb5278e9
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sendto.S
@@ -0,0 +1,12 @@
+#include <sysdep-cancel.h>
+#ifndef __NR_sendto
+#error Missing definition of NR_sendto needed for cancellation.
+#endif
+PSEUDO (__libc_sendto, sendto, 6)
+ret
+PSEUDO_END(__libc_sendto)
+libc_hidden_def (__libc_sendto)
+weak_alias (__libc_sendto, __sendto)
+libc_hidden_weak (__sendto)
+weak_alias (__libc_sendto, sendto)
+libc_hidden_weak (sendto)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/Makefile b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/Makefile
new file mode 100644
index 000000000..43a6fad84
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/Makefile
@@ -0,0 +1,13 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2005 Steven J. Hill <sjhill@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+top_srcdir=../../../../../../../
+top_builddir=../../../../../../../
+all: objs
+include $(top_builddir)Rules.mak
+include Makefile.arch
+include $(top_srcdir)Makerules
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/Makefile.arch b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/Makefile.arch
new file mode 100644
index 000000000..908d9e15d
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/Makefile.arch
@@ -0,0 +1,19 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2006 Steven J. Hill <sjhill@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+libpthread_linux_arch_SSRC = pthread_once.S pthread_rwlock_wrlock.S \
+ pthread_rwlock_rdlock.S pthread_rwlock_unlock.S \
+ lowlevellock.S lowlevelrobustlock.S pthread_barrier_wait.S \
+ pthread_cond_broadcast.S pthread_cond_signal.S \
+ pthread_rwlock_timedwrlock.S pthread_rwlock_timedrdlock.S \
+ sem_post.S sem_timedwait.S sem_trywait.S sem_wait.S
+
+libc_linux_arch_CSRC = fork.c
+libc_linux_arch_SSRC = libc-lowlevellock.S clone.S vfork.S
+
+ASFLAGS += -DUSE___THREAD
+
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h
new file mode 100644
index 000000000..150ae740f
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h
@@ -0,0 +1,182 @@
+/* Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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/>. */
+
+#ifndef _BITS_PTHREADTYPES_H
+#define _BITS_PTHREADTYPES_H 1
+
+#include <endian.h>
+
+#define __SIZEOF_PTHREAD_ATTR_T 36
+#define __SIZEOF_PTHREAD_MUTEX_T 24
+#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
+#define __SIZEOF_PTHREAD_COND_T 48
+#define __SIZEOF_PTHREAD_COND_COMPAT_T 12
+#define __SIZEOF_PTHREAD_CONDATTR_T 4
+#define __SIZEOF_PTHREAD_RWLOCK_T 32
+#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
+#define __SIZEOF_PTHREAD_BARRIER_T 20
+#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
+
+
+/* Thread identifiers. The structure of the attribute type is not
+ exposed on purpose. */
+typedef unsigned long int pthread_t;
+
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_ATTR_T];
+ long int __align;
+} pthread_attr_t;
+
+
+typedef struct __pthread_internal_slist
+{
+ struct __pthread_internal_slist *__next;
+} __pthread_slist_t;
+
+
+/* Data structures for mutex handling. The structure of the attribute
+ type is not exposed on purpose. */
+typedef union
+{
+ struct __pthread_mutex_s
+ {
+ int __lock;
+ unsigned int __count;
+ int __owner;
+ /* KIND must stay at this position in the structure to maintain
+ binary compatibility. */
+ int __kind;
+ unsigned int __nusers;
+ __extension__ union
+ {
+ int __spins;
+ __pthread_slist_t __list;
+ };
+ } __data;
+ char __size[__SIZEOF_PTHREAD_MUTEX_T];
+ long int __align;
+} pthread_mutex_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
+ long int __align;
+} pthread_mutexattr_t;
+
+
+/* Data structure for conditional variable handling. The structure of
+ the attribute type is not exposed on purpose. */
+typedef union
+{
+ struct
+ {
+ int __lock;
+ unsigned int __futex;
+ __extension__ unsigned long long int __total_seq;
+ __extension__ unsigned long long int __wakeup_seq;
+ __extension__ unsigned long long int __woken_seq;
+ void *__mutex;
+ unsigned int __nwaiters;
+ unsigned int __broadcast_seq;
+ } __data;
+ char __size[__SIZEOF_PTHREAD_COND_T];
+ __extension__ long long int __align;
+} pthread_cond_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_CONDATTR_T];
+ long int __align;
+} pthread_condattr_t;
+
+
+/* Keys for thread-specific data */
+typedef unsigned int pthread_key_t;
+
+
+/* Once-only execution */
+typedef int pthread_once_t;
+
+
+#if defined __USE_UNIX98 || defined __USE_XOPEN2K
+/* Data structure for read-write lock variable handling. The
+ structure of the attribute type is not exposed on purpose. */
+typedef union
+{
+ struct
+ {
+ int __lock;
+ unsigned int __nr_readers;
+ unsigned int __readers_wakeup;
+ unsigned int __writer_wakeup;
+ unsigned int __nr_readers_queued;
+ unsigned int __nr_writers_queued;
+#if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned char __pad1;
+ unsigned char __pad2;
+ unsigned char __shared;
+ /* FLAGS must stay at this position in the structure to maintain
+ binary compatibility. */
+ unsigned char __flags;
+#else
+ /* FLAGS must stay at this position in the structure to maintain
+ binary compatibility. */
+ unsigned char __flags;
+ unsigned char __shared;
+ unsigned char __pad1;
+ unsigned char __pad2;
+#endif
+ pthread_t __writer;
+ } __data;
+ char __size[__SIZEOF_PTHREAD_RWLOCK_T];
+ long int __align;
+} pthread_rwlock_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
+ long int __align;
+} pthread_rwlockattr_t;
+#endif
+
+
+#ifdef __USE_XOPEN2K
+/* POSIX spinlock data type. */
+typedef volatile int pthread_spinlock_t;
+
+
+/* POSIX barriers data type. The structure of the type is
+ deliberately not exposed. */
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_BARRIER_T];
+ long int __align;
+} pthread_barrier_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];
+ int __align;
+} pthread_barrierattr_t;
+#endif
+
+
+#endif /* bits/pthreadtypes.h */
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/bits/semaphore.h b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/bits/semaphore.h
new file mode 100644
index 000000000..9da293aa7
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/bits/semaphore.h
@@ -0,0 +1,35 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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/>. */
+
+#ifndef _SEMAPHORE_H
+# error "Never use <bits/semaphore.h> directly; include <semaphore.h> instead."
+#endif
+
+
+#define __SIZEOF_SEM_T 16
+
+
+/* Value returned if `sem_open' failed. */
+#define SEM_FAILED ((sem_t *) 0)
+
+
+typedef union
+{
+ char __size[__SIZEOF_SEM_T];
+ long int __align;
+} sem_t;
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/clone.S b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/clone.S
new file mode 100644
index 000000000..918d57926
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/clone.S
@@ -0,0 +1,2 @@
+#define RESET_PID
+#include <libc/sysdeps/linux/sh/clone.S>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/createthread.c b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/createthread.c
new file mode 100644
index 000000000..1f1518f85
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/createthread.c
@@ -0,0 +1,23 @@
+/* Copyright (C) 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/>. */
+
+/* Value passed to 'clone' for initialization of the thread register. */
+#define TLS_VALUE (pd + 1)
+
+
+/* Get the real implementation. */
+#include <sysdeps/pthread/createthread.c>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/fork.c b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/fork.c
new file mode 100644
index 000000000..605a6d58f
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/fork.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 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 <sched.h>
+#include <signal.h>
+#include <sysdep.h>
+#include <tls.h>
+
+/* TLS pointer argument is passed as the 5-th argument. */
+#define ARCH_FORK() \
+ INLINE_SYSCALL (clone, 5, \
+ CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID | SIGCHLD, 0, \
+ NULL, &THREAD_SELF->tid, NULL)
+
+#include "../fork.c"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/libc-lowlevellock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/libc-lowlevellock.S
new file mode 100644
index 000000000..3214c2988
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/libc-lowlevellock.S
@@ -0,0 +1,18 @@
+/* Copyright (C) 2003, 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 "lowlevellock.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevel-atomic.h b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevel-atomic.h
new file mode 100644
index 000000000..939fb0cb6
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevel-atomic.h
@@ -0,0 +1,80 @@
+/* Copyright (C) 2003, 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 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__
+
+#define _IMP1 #1
+#define _IMM1 #-1
+#define _IMM4 #-4
+#define _IMM6 #-6
+#define _IMM8 #-8
+
+#define INC(mem, reg) \
+ .align 2; \
+ mova 99f, r0; \
+ mov r15, r1; \
+ mov _IMM6, r15; \
+98: mov.l mem, reg; \
+ add _IMP1, reg; \
+ mov.l reg, mem; \
+99: mov r1, r15
+
+#define DEC(mem, reg) \
+ .align 2; \
+ mova 99f, r0; \
+ mov r15, r1; \
+ mov _IMM6, r15; \
+98: mov.l mem, reg; \
+ add _IMM1, reg; \
+ mov.l reg, mem; \
+99: mov r1, r15
+
+#define XADD(reg, mem, old, tmp) \
+ .align 2; \
+ mova 99f, r0; \
+ nop; \
+ mov r15, r1; \
+ mov _IMM8, r15; \
+98: mov.l mem, old; \
+ mov reg, tmp; \
+ add old, tmp; \
+ mov.l tmp, mem; \
+99: mov r1, r15
+
+#define XCHG(reg, mem, old) \
+ .align 2; \
+ mova 99f, r0; \
+ nop; \
+ mov r15, r1; \
+ mov _IMM4, r15; \
+98: mov.l mem, old; \
+ mov.l reg, mem; \
+99: mov r1, r15
+
+#define CMPXCHG(reg, mem, new, old) \
+ .align 2; \
+ mova 99f, r0; \
+ nop; \
+ mov r15, r1; \
+ mov _IMM8, r15; \
+98: mov.l mem, old; \
+ cmp/eq old, reg; \
+ bf 99f; \
+ mov.l new, mem; \
+99: mov r1, r15
+
+#endif /* __ASSEMBLER__ */
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.S
new file mode 100644
index 000000000..9af4ea4ca
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.S
@@ -0,0 +1,545 @@
+/* Copyright (C) 2003, 2004, 2005, 2007, 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
+ 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 <pthread-errnos.h>
+#include <bits/kernel-features.h>
+#include <lowlevellock.h>
+#include <tcb-offsets.h>
+#include "lowlevel-atomic.h"
+
+ .text
+
+#ifdef __ASSUME_PRIVATE_FUTEX
+# define LOAD_PRIVATE_FUTEX_WAIT(reg,tmp,tmp2) \
+ mov #(FUTEX_WAIT | FUTEX_PRIVATE_FLAG), reg; \
+ extu.b reg, reg
+# define LOAD_PRIVATE_FUTEX_WAKE(reg,tmp,tmp2) \
+ mov #(FUTEX_WAKE | FUTEX_PRIVATE_FLAG), reg; \
+ extu.b reg, reg
+# define LOAD_FUTEX_WAIT(reg,tmp,tmp2) \
+ mov #(FUTEX_WAIT | FUTEX_PRIVATE_FLAG), tmp; \
+ extu.b tmp, tmp; \
+ xor tmp, reg
+# define LOAD_FUTEX_WAIT_ABS(reg,tmp,tmp2) \
+ mov #(FUTEX_WAIT_BITSET | FUTEX_PRIVATE_FLAG), tmp; \
+ extu.b tmp, tmp; \
+ mov #(FUTEX_CLOCK_REALTIME >> 8), tmp2; \
+ swap.b tmp2, tmp2; \
+ or tmp2, tmp; \
+ xor tmp, reg
+# define LOAD_FUTEX_WAKE(reg,tmp,tmp2) \
+ mov #(FUTEX_WAKE | FUTEX_PRIVATE_FLAG), tmp; \
+ extu.b tmp, tmp; \
+ xor tmp, reg
+#else
+# if FUTEX_WAIT == 0
+# define LOAD_PRIVATE_FUTEX_WAIT(reg,tmp,tmp2) \
+ stc gbr, tmp ; \
+ mov.w 99f, reg ; \
+ add reg, tmp ; \
+ bra 98f ; \
+ mov.l @tmp, reg ; \
+99: .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE ; \
+98:
+# else
+# define LOAD_PRIVATE_FUTEX_WAIT(reg,tmp,tmp2) \
+ stc gbr, tmp ; \
+ mov.w 99f, reg ; \
+ add reg, tmp ; \
+ mov.l @tmp, reg ; \
+ bra 98f ; \
+ mov #FUTEX_WAIT, tmp ; \
+99: .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE ; \
+98: or tmp, reg
+# endif
+# define LOAD_PRIVATE_FUTEX_WAKE(reg,tmp,tmp2) \
+ stc gbr, tmp ; \
+ mov.w 99f, reg ; \
+ add reg, tmp ; \
+ mov.l @tmp, reg ; \
+ bra 98f ; \
+ mov #FUTEX_WAKE, tmp ; \
+99: .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE ; \
+98: or tmp, reg
+# if FUTEX_WAIT == 0
+# define LOAD_FUTEX_WAIT(reg,tmp,tmp2) \
+ stc gbr, tmp ; \
+ mov.w 99f, tmp2 ; \
+ add tmp2, tmp ; \
+ mov.l @tmp, tmp2 ; \
+ bra 98f ; \
+ mov #FUTEX_PRIVATE_FLAG, tmp ; \
+99: .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE ; \
+98: extu.b tmp, tmp ; \
+ xor tmp, reg ; \
+ and tmp2, reg
+# else
+# define LOAD_FUTEX_WAIT(reg,tmp,tmp2) \
+ stc gbr, tmp ; \
+ mov.w 99f, tmp2 ; \
+ add tmp2, tmp ; \
+ mov.l @tmp, tmp2 ; \
+ bra 98f ; \
+ mov #FUTEX_PRIVATE_FLAG, tmp ; \
+99: .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE ; \
+98: extu.b tmp, tmp ; \
+ xor tmp, reg ; \
+ and tmp2, reg ; \
+ mov #FUTEX_WAIT, tmp ; \
+ or tmp, reg
+# endif
+# define LOAD_FUTEX_WAIT_ABS(reg,tmp,tmp2) \
+ stc gbr, tmp ; \
+ mov.w 99f, tmp2 ; \
+ add tmp2, tmp ; \
+ mov.l @tmp, tmp2 ; \
+ bra 98f ; \
+ mov #FUTEX_PRIVATE_FLAG, tmp ; \
+99: .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE ; \
+98: extu.b tmp, tmp ; \
+ xor tmp, reg ; \
+ and tmp2, reg ; \
+ mov #FUTEX_WAIT_BITSET, tmp ; \
+ mov #(FUTEX_CLOCK_REALTIME >> 8), tmp2; \
+ swap.b tmp2, tmp2; \
+ or tmp2, tmp; \
+ or tmp, reg
+# define LOAD_FUTEX_WAKE(reg,tmp,tmp2) \
+ stc gbr, tmp ; \
+ mov.w 99f, tmp2 ; \
+ add tmp2, tmp ; \
+ mov.l @tmp, tmp2 ; \
+ bra 98f ; \
+ mov #FUTEX_PRIVATE_FLAG, tmp ; \
+99: .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE ; \
+98: extu.b tmp, tmp ; \
+ xor tmp, reg ; \
+ and tmp2, reg ; \
+ mov #FUTEX_WAKE, tmp ; \
+ or tmp, reg
+#endif
+
+ .globl __lll_lock_wait_private
+ .type __lll_lock_wait_private,@function
+ .hidden __lll_lock_wait_private
+#ifndef IS_IN_libpthread
+ .weak __lll_lock_wait_private
+#endif
+ .align 5
+ cfi_startproc
+__lll_lock_wait_private:
+ mov.l r8, @-r15
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset (r8, 0)
+ mov r4, r6
+ mov r5, r8
+ mov #0, r7 /* No timeout. */
+ LOAD_PRIVATE_FUTEX_WAIT (r5, r0, r1)
+
+ mov #2, r4
+ cmp/eq r4, r6
+ bf 2f
+
+1:
+ mov r8, r4
+ mov #SYS_futex, r3
+ extu.b r3, r3
+ trapa #0x14
+ SYSCALL_INST_PAD
+
+2:
+ mov #2, r6
+ XCHG (r6, @r8, r2)
+ tst r2, r2
+ bf 1b
+
+ mov.l @r15+, r8
+ rts
+ mov r2, r0
+ cfi_endproc
+ .size __lll_lock_wait_private,.-__lll_lock_wait_private
+
+#ifdef NOT_IN_libc
+ .globl __lll_lock_wait
+ .type __lll_lock_wait,@function
+ .hidden __lll_lock_wait
+ .align 5
+ cfi_startproc
+__lll_lock_wait:
+ mov.l r9, @-r15
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset (r9, 0)
+ mov.l r8, @-r15
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset (r8, 0)
+ mov r6, r9
+ mov r4, r6
+ mov r5, r8
+ mov #0, r7 /* No timeout. */
+ mov r9, r5
+ LOAD_FUTEX_WAIT (r5, r0, r1)
+
+ mov #2, r4
+ cmp/eq r4, r6
+ bf 2f
+
+1:
+ mov r8, r4
+ mov #SYS_futex, r3
+ extu.b r3, r3
+ trapa #0x14
+ SYSCALL_INST_PAD
+
+2:
+ mov #2, r6
+ XCHG (r6, @r8, r2)
+ tst r2, r2
+ bf 1b
+
+ mov.l @r15+, r8
+ mov.l @r15+, r9
+ ret
+ mov r2, r0
+ cfi_endproc
+ .size __lll_lock_wait,.-__lll_lock_wait
+
+ /* r5 (r8): futex
+ r7 (r11): flags
+ r6 (r9): timeout
+ r4 (r10): futex value
+ */
+ .globl __lll_timedlock_wait
+ .type __lll_timedlock_wait,@function
+ .hidden __lll_timedlock_wait
+ .align 5
+ cfi_startproc
+__lll_timedlock_wait:
+ mov.l r12, @-r15
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset (r12, 0)
+
+# ifndef __ASSUME_FUTEX_CLOCK_REALTIME
+ mov.l .Lhave, r1
+# ifdef __PIC__
+ mova .Lgot, r0
+ mov.l .Lgot, r12
+ add r0, r12
+ add r12, r1
+# endif
+ mov.l @r1, r0
+ tst r0, r0
+ bt .Lreltmo
+# endif
+
+ mov r4, r2
+ mov r5, r4
+ mov r7, r5
+ mov r6, r7
+ LOAD_FUTEX_WAIT_ABS (r5, r0, r1)
+
+ mov #2, r6
+ cmp/eq r6, r2
+ bf/s 2f
+ mov r6, r2
+
+1:
+ mov #2, r6
+ mov #-1, r1
+ mov #SYS_futex, r3
+ extu.b r3, r3
+ trapa #0x16
+ SYSCALL_INST_PAD
+ mov r0, r6
+
+2:
+ XCHG (r2, @r4, r3) /* NB: lock is implied */
+
+ tst r3, r3
+ bt/s 3f
+ mov r6, r0
+
+ cmp/eq #-ETIMEDOUT, r0
+ bt 4f
+ cmp/eq #-EINVAL, r0
+ bf 1b
+4:
+ neg r0, r3
+3:
+ mov r3, r0
+ rts
+ mov.l @r15+, r12
+
+ .align 2
+# ifndef __ASSUME_FUTEX_CLOCK_REALTIME
+# ifdef __PIC__
+.Lgot:
+ .long _GLOBAL_OFFSET_TABLE_
+.Lhave:
+ .long __have_futex_clock_realtime@GOTOFF
+# else
+.Lhave:
+ .long __have_futex_clock_realtime
+# endif
+
+.Lreltmo:
+ /* Check for a valid timeout value. */
+ mov.l @(4,r6), r1
+ mov.l .L1g, r0
+ cmp/hs r0, r1
+ bt 3f
+
+ mov.l r11, @-r15
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset (r11, 0)
+ mov.l r10, @-r15
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset (r10, 0)
+ mov.l r9, @-r15
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset (r9, 0)
+ mov.l r8, @-r15
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset (r8, 0)
+ mov r7, r11
+ mov r4, r10
+ mov r6, r9
+ mov r5, r8
+
+ /* Stack frame for the timespec and timeval structs. */
+ add #-8, r15
+ cfi_adjust_cfa_offset(8)
+
+ mov #2, r2
+ XCHG (r2, @r8, r3)
+
+ tst r3, r3
+ bt 6f
+
+1:
+ /* Get current time. */
+ mov r15, r4
+ mov #0, r5
+ mov #__NR_gettimeofday, r3
+ trapa #0x12
+ SYSCALL_INST_PAD
+
+ /* Compute relative timeout. */
+ mov.l @(4,r15), r0
+ mov.w .L1k, r1
+ dmulu.l r0, r1 /* Micro seconds to nano seconds. */
+ mov.l @r9, r2
+ mov.l @(4,r9), r3
+ mov.l @r15, r0
+ sts macl, r1
+ sub r0, r2
+ clrt
+ subc r1, r3
+ bf 4f
+ mov.l .L1g, r1
+ add r1, r3
+ add #-1, r2
+4:
+ cmp/pz r2
+ bf 2f /* Time is already up. */
+
+ mov.l r2, @r15 /* Store relative timeout. */
+ mov.l r3, @(4,r15)
+
+ mov r8, r4
+ mov r11, r5
+ LOAD_FUTEX_WAIT (r5, r0, r1)
+ mov r10, r6
+ mov r15, r7
+ mov #SYS_futex, r3
+ extu.b r3, r3
+ trapa #0x14
+ SYSCALL_INST_PAD
+ mov r0, r5
+
+ mov #2, r2
+ XCHG (r2, @r8, r3)
+
+ tst r3, r3
+ bt/s 6f
+ mov #-ETIMEDOUT, r1
+ cmp/eq r5, r1
+ bf 1b
+
+2: mov #ETIMEDOUT, r3
+
+6:
+ mov r3, r0
+ add #8, r15
+ mov.l @r15+, r8
+ mov.l @r15+, r9
+ mov.l @r15+, r10
+ mov.l @r15+, r11
+ rts
+ mov.l @r15+, r12
+
+3:
+ mov.l @r15+, r12
+ rts
+ mov #EINVAL, r0
+# endif
+ cfi_endproc
+
+.L1k:
+ .word 1000
+ .align 2
+.L1g:
+ .long 1000000000
+
+ .size __lll_timedlock_wait,.-__lll_timedlock_wait
+#endif
+
+ .globl __lll_unlock_wake_private
+ .type __lll_unlock_wake_private,@function
+ .hidden __lll_unlock_wake_private
+#ifndef IS_IN_libpthread
+ .weak __lll_unlock_wake_private
+#endif
+ .align 5
+ cfi_startproc
+__lll_unlock_wake_private:
+ LOAD_PRIVATE_FUTEX_WAKE (r5, r0, r1)
+ mov #1, r6 /* Wake one thread. */
+ mov #0, r7
+ mov.l r7, @r4 /* Stores 0. */
+ mov #SYS_futex, r3
+ extu.b r3, r3
+ trapa #0x14
+ SYSCALL_INST_PAD
+ rts
+ nop
+ cfi_endproc
+ .size __lll_unlock_wake_private,.-__lll_unlock_wake_private
+
+#ifdef NOT_IN_libc
+ .globl __lll_unlock_wake
+ .type __lll_unlock_wake,@function
+ .hidden __lll_unlock_wake
+ .align 5
+ cfi_startproc
+__lll_unlock_wake:
+ LOAD_FUTEX_WAKE (r5, r0, r1)
+ mov #1, r6 /* Wake one thread. */
+ mov #0, r7
+ mov.l r7, @r4 /* Stores 0. */
+ mov #SYS_futex, r3
+ extu.b r3, r3
+ trapa #0x14
+ SYSCALL_INST_PAD
+ rts
+ nop
+ cfi_endproc
+ .size __lll_unlock_wake,.-__lll_unlock_wake
+
+ .globl __lll_timedwait_tid
+ .type __lll_timedwait_tid,@function
+ .hidden __lll_timedwait_tid
+ .align 5
+ cfi_startproc
+__lll_timedwait_tid:
+ mov.l r9, @-r15
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset (r9, 0)
+ mov.l r8, @-r15
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset (r8, 0)
+ mov r4, r8
+ mov r5, r9
+
+ /* Stack frame for the timespec and timeval structs. */
+ add #-8, r15
+ cfi_adjust_cfa_offset(8)
+
+2:
+ /* Get current time. */
+ mov r15, r4
+ mov #0, r5
+ mov #__NR_gettimeofday, r3
+ trapa #0x12
+ SYSCALL_INST_PAD
+
+ /* Compute relative timeout. */
+ mov.l @(4,r15), r0
+ mov.w .L1k2, r1
+ dmulu.l r0, r1 /* Micro seconds to nano seconds. */
+ mov.l @r9, r2
+ mov.l @(4,r9), r3
+ mov.l @r15, r0
+ sts macl, r1
+ sub r0, r2
+ clrt
+ subc r1, r3
+ bf 5f
+ mov.l .L1g2, r1
+ add r1, r3
+ add #-1, r2
+5:
+ cmp/pz r2
+ bf 6f /* Time is already up. */
+
+ mov.l r2, @r15 /* Store relative timeout. */
+ mov.l r3, @(4,r15)
+
+ mov.l @r8, r2
+ tst r2, r2
+ bt 4f
+
+ mov r8, r4
+ /* XXX The kernel so far uses global futex for the wakeup at
+ all times. */
+ mov #0, r5
+ extu.b r5, r5
+ mov r2, r6
+ mov r15, r7
+ mov #SYS_futex, r3
+ extu.b r3, r3
+ trapa #0x14
+ SYSCALL_INST_PAD
+
+ mov.l @r8, r2
+ tst r2, r2
+ bf 1f
+4:
+ mov #0, r0
+3:
+ add #8, r15
+ mov.l @r15+, r8
+ rts
+ mov.l @r15+, r9
+1:
+ /* Check whether the time expired. */
+ mov #-ETIMEDOUT, r1
+ cmp/eq r0, r1
+ bf 2b
+6:
+ bra 3b
+ mov #ETIMEDOUT, r0
+ cfi_endproc
+
+.L1k2:
+ .word 1000
+ .align 2
+.L1g2:
+ .long 1000000000
+ .size __lll_timedwait_tid,.-__lll_timedwait_tid
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h
new file mode 100644
index 000000000..a9652bbb1
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.h
@@ -0,0 +1,419 @@
+/* Copyright (C) 2003, 2004, 2006, 2007, 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
+ 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 _LOWLEVELLOCK_H
+#define _LOWLEVELLOCK_H 1
+
+#ifndef __ASSEMBLER__
+#include <time.h>
+#include <sys/param.h>
+#include <bits/pthreadtypes.h>
+#include <bits/kernel-features.h>
+#endif
+
+#define FUTEX_WAIT 0
+#define FUTEX_WAKE 1
+#define FUTEX_CMP_REQUEUE 4
+#define FUTEX_WAKE_OP 5
+#define FUTEX_LOCK_PI 6
+#define FUTEX_UNLOCK_PI 7
+#define FUTEX_TRYLOCK_PI 8
+#define FUTEX_WAIT_BITSET 9
+#define FUTEX_WAKE_BITSET 10
+#define FUTEX_PRIVATE_FLAG 128
+#define FUTEX_CLOCK_REALTIME 256
+
+#define FUTEX_BITSET_MATCH_ANY 0xffffffff
+
+#define FUTEX_OP_CLEAR_WAKE_IF_GT_ONE ((4 << 24) | 1)
+
+/* Values for 'private' parameter of locking macros. Yes, the
+ definition seems to be backwards. But it is not. The bit will be
+ reversed before passing to the system call. */
+#define LLL_PRIVATE 0
+#define LLL_SHARED FUTEX_PRIVATE_FLAG
+
+
+#if !defined NOT_IN_libc || defined IS_IN_rtld
+/* In libc.so or ld.so all futexes are private. */
+# ifdef __ASSUME_PRIVATE_FUTEX
+# define __lll_private_flag(fl, private) \
+ ((fl) | FUTEX_PRIVATE_FLAG)
+# else
+# define __lll_private_flag(fl, private) \
+ ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex))
+# endif
+#else
+# ifdef __ASSUME_PRIVATE_FUTEX
+# define __lll_private_flag(fl, private) \
+ (((fl) | FUTEX_PRIVATE_FLAG) ^ (private))
+# else
+# define __lll_private_flag(fl, private) \
+ (__builtin_constant_p (private) \
+ ? ((private) == 0 \
+ ? ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex)) \
+ : (fl)) \
+ : ((fl) | (((private) ^ FUTEX_PRIVATE_FLAG) \
+ & THREAD_GETMEM (THREAD_SELF, header.private_futex))))
+# endif
+#endif
+
+#ifndef __ASSEMBLER__
+
+/* Initializer for compatibility lock. */
+#define LLL_LOCK_INITIALIZER (0)
+#define LLL_LOCK_INITIALIZER_LOCKED (1)
+#define LLL_LOCK_INITIALIZER_WAITERS (2)
+
+extern int __lll_lock_wait_private (int val, int *__futex)
+ attribute_hidden;
+extern int __lll_lock_wait (int val, int *__futex, int private)
+ attribute_hidden;
+extern int __lll_timedlock_wait (int val, int *__futex,
+ const struct timespec *abstime, int private)
+ attribute_hidden;
+extern int __lll_robust_lock_wait (int val, int *__futex, int private)
+ attribute_hidden;
+extern int __lll_robust_timedlock_wait (int val, int *__futex,
+ const struct timespec *abstime,
+ int private)
+ attribute_hidden;
+extern int __lll_unlock_wake_private (int *__futex) attribute_hidden;
+extern int __lll_unlock_wake (int *__futex, int private) attribute_hidden;
+
+#define lll_trylock(futex) \
+ ({ unsigned char __ret; \
+ __asm__ __volatile__ ("\
+ .align 2\n\
+ mova 1f,r0\n\
+ nop\n\
+ mov r15,r1\n\
+ mov #-8,r15\n\
+ 0: mov.l @%1,r2\n\
+ cmp/eq r2,%3\n\
+ bf 1f\n\
+ mov.l %2,@%1\n\
+ 1: mov r1,r15\n\
+ mov #-1,%0\n\
+ negc %0,%0"\
+ : "=r" (__ret) \
+ : "r" (&(futex)), \
+ "r" (LLL_LOCK_INITIALIZER_LOCKED), \
+ "r" (LLL_LOCK_INITIALIZER) \
+ : "r0", "r1", "r2", "t", "memory"); \
+ __ret; })
+
+#define lll_robust_trylock(futex, id) \
+ ({ unsigned char __ret; \
+ __asm__ __volatile__ ("\
+ .align 2\n\
+ mova 1f,r0\n\
+ nop\n\
+ mov r15,r1\n\
+ mov #-8,r15\n\
+ 0: mov.l @%1,r2\n\
+ cmp/eq r2,%3\n\
+ bf 1f\n\
+ mov.l %2,@%1\n\
+ 1: mov r1,r15\n\
+ mov #-1,%0\n\
+ negc %0,%0"\
+ : "=r" (__ret) \
+ : "r" (&(futex)), \
+ "r" (id), \
+ "r" (LLL_LOCK_INITIALIZER) \
+ : "r0", "r1", "r2", "t", "memory"); \
+ __ret; })
+
+#define lll_cond_trylock(futex) \
+ ({ unsigned char __ret; \
+ __asm__ __volatile__ ("\
+ .align 2\n\
+ mova 1f,r0\n\
+ nop\n\
+ mov r15,r1\n\
+ mov #-8,r15\n\
+ 0: mov.l @%1,r2\n\
+ cmp/eq r2,%3\n\
+ bf 1f\n\
+ mov.l %2,@%1\n\
+ 1: mov r1,r15\n\
+ mov #-1,%0\n\
+ negc %0,%0"\
+ : "=r" (__ret) \
+ : "r" (&(futex)), \
+ "r" (LLL_LOCK_INITIALIZER_WAITERS), \
+ "r" (LLL_LOCK_INITIALIZER) \
+ : "r0", "r1", "r2", "t", "memory"); \
+ __ret; })
+
+#define lll_lock(futex, private) \
+ (void) ({ int __ret, *__futex = &(futex); \
+ __asm__ __volatile__ ("\
+ .align 2\n\
+ mova 1f,r0\n\
+ nop\n\
+ mov r15,r1\n\
+ mov #-8,r15\n\
+ 0: mov.l @%2,%0\n\
+ tst %0,%0\n\
+ bf 1f\n\
+ mov.l %1,@%2\n\
+ 1: mov r1,r15"\
+ : "=&r" (__ret) : "r" (1), "r" (__futex) \
+ : "r0", "r1", "t", "memory"); \
+ if (__ret) \
+ { \
+ if (__builtin_constant_p (private) \
+ && (private) == LLL_PRIVATE) \
+ __lll_lock_wait_private (__ret, __futex); \
+ else \
+ __lll_lock_wait (__ret, __futex, (private)); \
+ } \
+ })
+
+#define lll_robust_lock(futex, id, private) \
+ ({ int __ret, *__futex = &(futex); \
+ __asm__ __volatile__ ("\
+ .align 2\n\
+ mova 1f,r0\n\
+ nop\n\
+ mov r15,r1\n\
+ mov #-8,r15\n\
+ 0: mov.l @%2,%0\n\
+ tst %0,%0\n\
+ bf 1f\n\
+ mov.l %1,@%2\n\
+ 1: mov r1,r15"\
+ : "=&r" (__ret) : "r" (id), "r" (__futex) \
+ : "r0", "r1", "t", "memory"); \
+ if (__ret) \
+ __ret = __lll_robust_lock_wait (__ret, __futex, private); \
+ __ret; })
+
+/* Special version of lll_mutex_lock which causes the unlock function to
+ always wakeup waiters. */
+#define lll_cond_lock(futex, private) \
+ (void) ({ int __ret, *__futex = &(futex); \
+ __asm__ __volatile__ ("\
+ .align 2\n\
+ mova 1f,r0\n\
+ nop\n\
+ mov r15,r1\n\
+ mov #-8,r15\n\
+ 0: mov.l @%2,%0\n\
+ tst %0,%0\n\
+ bf 1f\n\
+ mov.l %1,@%2\n\
+ 1: mov r1,r15"\
+ : "=&r" (__ret) : "r" (2), "r" (__futex) \
+ : "r0", "r1", "t", "memory"); \
+ if (__ret) \
+ __lll_lock_wait (__ret, __futex, private); })
+
+#define lll_robust_cond_lock(futex, id, private) \
+ ({ int __ret, *__futex = &(futex); \
+ __asm__ __volatile__ ("\
+ .align 2\n\
+ mova 1f,r0\n\
+ nop\n\
+ mov r15,r1\n\
+ mov #-8,r15\n\
+ 0: mov.l @%2,%0\n\
+ tst %0,%0\n\
+ bf 1f\n\
+ mov.l %1,@%2\n\
+ 1: mov r1,r15"\
+ : "=&r" (__ret) : "r" (id | FUTEX_WAITERS), "r" (__futex) \
+ : "r0", "r1", "t", "memory"); \
+ if (__ret) \
+ __ret = __lll_robust_lock_wait (__ret, __futex, private); \
+ __ret; })
+
+#define lll_timedlock(futex, timeout, private) \
+ ({ int __ret, *__futex = &(futex); \
+ __asm__ __volatile__ ("\
+ .align 2\n\
+ mova 1f,r0\n\
+ nop\n\
+ mov r15,r1\n\
+ mov #-8,r15\n\
+ 0: mov.l @%2,%0\n\
+ tst %0,%0\n\
+ bf 1f\n\
+ mov.l %1,@%2\n\
+ 1: mov r1,r15"\
+ : "=&r" (__ret) : "r" (1), "r" (__futex) \
+ : "r0", "r1", "t", "memory"); \
+ if (__ret) \
+ __ret = __lll_timedlock_wait (__ret, __futex, timeout, private); \
+ __ret; })
+
+#define lll_robust_timedlock(futex, timeout, id, private) \
+ ({ int __ret, *__futex = &(futex); \
+ __asm__ __volatile__ ("\
+ .align 2\n\
+ mova 1f,r0\n\
+ nop\n\
+ mov r15,r1\n\
+ mov #-8,r15\n\
+ 0: mov.l @%2,%0\n\
+ tst %0,%0\n\
+ bf 1f\n\
+ mov.l %1,@%2\n\
+ 1: mov r1,r15"\
+ : "=&r" (__ret) : "r" (id), "r" (__futex) \
+ : "r0", "r1", "t", "memory"); \
+ if (__ret) \
+ __ret = __lll_robust_timedlock_wait (__ret, __futex, \
+ timeout, private); \
+ __ret; })
+
+#define lll_unlock(futex, private) \
+ (void) ({ int __ret, *__futex = &(futex); \
+ __asm__ __volatile__ ("\
+ .align 2\n\
+ mova 1f,r0\n\
+ mov r15,r1\n\
+ mov #-6,r15\n\
+ 0: mov.l @%1,%0\n\
+ add #-1,%0\n\
+ mov.l %0,@%1\n\
+ 1: mov r1,r15"\
+ : "=&r" (__ret) : "r" (__futex) \
+ : "r0", "r1", "memory"); \
+ if (__ret) \
+ { \
+ if (__builtin_constant_p (private) \
+ && (private) == LLL_PRIVATE) \
+ __lll_unlock_wake_private (__futex); \
+ else \
+ __lll_unlock_wake (__futex, (private)); \
+ } \
+ })
+
+#define lll_robust_unlock(futex, private) \
+ (void) ({ int __ret, *__futex = &(futex); \
+ __asm__ __volatile__ ("\
+ .align 2\n\
+ mova 1f,r0\n\
+ mov r15,r1\n\
+ mov #-6,r15\n\
+ 0: mov.l @%1,%0\n\
+ and %2,%0\n\
+ mov.l %0,@%1\n\
+ 1: mov r1,r15"\
+ : "=&r" (__ret) : "r" (__futex), "r" (FUTEX_WAITERS) \
+ : "r0", "r1", "memory"); \
+ if (__ret) \
+ __lll_unlock_wake (__futex, private); })
+
+#define lll_robust_dead(futex, private) \
+ (void) ({ int __ignore, *__futex = &(futex); \
+ __asm__ __volatile__ ("\
+ .align 2\n\
+ mova 1f,r0\n\
+ mov r15,r1\n\
+ mov #-6,r15\n\
+ 0: mov.l @%1,%0\n\
+ or %2,%0\n\
+ mov.l %0,@%1\n\
+ 1: mov r1,r15"\
+ : "=&r" (__ignore) : "r" (__futex), "r" (FUTEX_OWNER_DIED) \
+ : "r0", "r1", "memory"); \
+ lll_futex_wake (__futex, 1, private); })
+
+# ifdef NEED_SYSCALL_INST_PAD
+# define SYSCALL_WITH_INST_PAD "\
+ trapa #0x14; or r0,r0; or r0,r0; or r0,r0; or r0,r0; or r0,r0"
+# else
+# define SYSCALL_WITH_INST_PAD "\
+ trapa #0x14"
+# endif
+
+#define lll_futex_wait(futex, val, private) \
+ lll_futex_timed_wait (futex, val, NULL, private)
+
+
+#define lll_futex_timed_wait(futex, val, timeout, private) \
+ ({ \
+ int __status; \
+ register unsigned long __r3 __asm__ ("r3") = SYS_futex; \
+ register unsigned long __r4 __asm__ ("r4") = (unsigned long) (futex); \
+ register unsigned long __r5 __asm__ ("r5") \
+ = __lll_private_flag (FUTEX_WAIT, private); \
+ register unsigned long __r6 __asm__ ("r6") = (unsigned long) (val); \
+ register unsigned long __r7 __asm__ ("r7") = (unsigned long) (timeout); \
+ __asm__ __volatile__ (SYSCALL_WITH_INST_PAD \
+ : "=z" (__status) \
+ : "r" (__r3), "r" (__r4), "r" (__r5), \
+ "r" (__r6), "r" (__r7) \
+ : "memory", "t"); \
+ __status; \
+ })
+
+
+#define lll_futex_wake(futex, nr, private) \
+ do { \
+ int __ignore; \
+ register unsigned long __r3 __asm__ ("r3") = SYS_futex; \
+ register unsigned long __r4 __asm__ ("r4") = (unsigned long) (futex); \
+ register unsigned long __r5 __asm__ ("r5") \
+ = __lll_private_flag (FUTEX_WAKE, private); \
+ register unsigned long __r6 __asm__ ("r6") = (unsigned long) (nr); \
+ register unsigned long __r7 __asm__ ("r7") = 0; \
+ __asm__ __volatile__ (SYSCALL_WITH_INST_PAD \
+ : "=z" (__ignore) \
+ : "r" (__r3), "r" (__r4), "r" (__r5), \
+ "r" (__r6), "r" (__r7) \
+ : "memory", "t"); \
+ } while (0)
+
+
+#define lll_islocked(futex) \
+ (futex != LLL_LOCK_INITIALIZER)
+
+/* The kernel notifies a process with uses CLONE_CLEARTID via futex
+ wakeup when the clone terminates. The memory location contains the
+ thread ID while the clone is running and is reset to zero
+ afterwards. */
+
+#define lll_wait_tid(tid) \
+ do { \
+ __typeof (tid) __tid; \
+ while ((__tid = (tid)) != 0) \
+ lll_futex_wait (&(tid), __tid, LLL_SHARED); \
+ } while (0)
+
+extern int __lll_timedwait_tid (int *tid, const struct timespec *abstime)
+ attribute_hidden;
+#define lll_timedwait_tid(tid, abstime) \
+ ({ \
+ int __ret = 0; \
+ if (tid != 0) \
+ { \
+ if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) \
+ __ret = EINVAL; \
+ else \
+ __ret = __lll_timedwait_tid (&tid, abstime); \
+ } \
+ __ret; })
+
+#endif /* !__ASSEMBLER__ */
+
+#endif /* lowlevellock.h */
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevelrobustlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevelrobustlock.S
new file mode 100644
index 000000000..7ec8e1ab7
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/lowlevelrobustlock.S
@@ -0,0 +1,264 @@
+/* Copyright (C) 2003, 2004, 2005, 2006, 2007
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#include <pthread-errnos.h>
+#include <lowlevellock.h>
+#include <lowlevelrobustlock.h>
+#include <bits/kernel-features.h>
+#include <tcb-offsets.h>
+#include "lowlevel-atomic.h"
+
+ .text
+
+#define FUTEX_WAITERS 0x80000000
+#define FUTEX_OWNER_DIED 0x40000000
+
+#ifdef __ASSUME_PRIVATE_FUTEX
+# define LOAD_FUTEX_WAIT(reg,tmp,tmp2) \
+ mov #(FUTEX_WAIT | FUTEX_PRIVATE_FLAG), tmp; \
+ extu.b tmp, tmp; \
+ xor tmp, reg
+#else
+# if FUTEX_WAIT == 0
+# define LOAD_FUTEX_WAIT(reg,tmp,tmp2) \
+ stc gbr, tmp ; \
+ mov.w 99f, tmp2 ; \
+ add tmp2, tmp ; \
+ mov.l @tmp, tmp2 ; \
+ bra 98f ; \
+ mov #FUTEX_PRIVATE_FLAG, tmp ; \
+99: .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE ; \
+98: extu.b tmp, tmp ; \
+ xor tmp, reg ; \
+ and tmp2, reg
+# else
+# define LOAD_FUTEX_WAIT(reg,tmp,tmp2) \
+ stc gbr, tmp ; \
+ mov.w 99f, tmp2 ; \
+ add tmp2, tmp ; \
+ mov.l @tmp, tmp2 ; \
+ bra 98f ; \
+ mov #FUTEX_PRIVATE_FLAG, tmp ; \
+99: .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE ; \
+98: extu.b tmp, tmp ; \
+ xor tmp, reg ; \
+ and tmp2, reg ; \
+ mov #FUTEX_WAIT, tmp ; \
+ or tmp, reg
+# endif
+#endif
+
+ .globl __lll_robust_lock_wait
+ .type __lll_robust_lock_wait,@function
+ .hidden __lll_robust_lock_wait
+ .align 5
+ cfi_startproc
+__lll_robust_lock_wait:
+ mov.l r8, @-r15
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset (r8, 0)
+ mov r5, r8
+ mov #0, r7 /* No timeout. */
+ mov r6, r5
+ LOAD_FUTEX_WAIT (r5, r0, r1)
+
+4:
+ mov r4, r6
+ mov.l .L_FUTEX_WAITERS, r0
+ or r0, r6
+ shlr r0 /* r0 = FUTEX_OWNER_DIED */
+ tst r0, r4
+ bf/s 3f
+ cmp/eq r4, r6
+ bt 1f
+
+ CMPXCHG (r4, @r8, r6, r2)
+ bf 2f
+
+1:
+ mov r8, r4
+ mov #SYS_futex, r3
+ extu.b r3, r3
+ trapa #0x14
+ SYSCALL_INST_PAD
+
+ mov.l @r8, r2
+
+2:
+ tst r2, r2
+ bf/s 4b
+ mov r2, r4
+
+ stc gbr, r1
+ mov.w .Ltidoff, r2
+ add r2, r1
+ mov.l @r1, r6
+ mov #0, r3
+ CMPXCHG (r3, @r8, r6, r4)
+ bf 4b
+ mov #0, r4
+
+3:
+ mov.l @r15+, r8
+ ret
+ mov r4, r0
+ cfi_endproc
+ .align 2
+.L_FUTEX_WAITERS:
+ .long FUTEX_WAITERS
+.Ltidoff:
+ .word TID - TLS_PRE_TCB_SIZE
+ .size __lll_robust_lock_wait,.-__lll_robust_lock_wait
+
+
+ .globl __lll_robust_timedlock_wait
+ .type __lll_robust_timedlock_wait,@function
+ .hidden __lll_robust_timedlock_wait
+ .align 5
+ cfi_startproc
+__lll_robust_timedlock_wait:
+ /* Check for a valid timeout value. */
+ mov.l @(4,r6), r1
+ mov.l .L1g, r0
+ cmp/hs r0, r1
+ bt 3f
+
+ mov.l r11, @-r15
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset (r11, 0)
+ mov.l r10, @-r15
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset (r10, 0)
+ mov.l r9, @-r15
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset (r9, 0)
+ mov.l r8, @-r15
+ cfi_adjust_cfa_offset(4)
+ cfi_rel_offset (r8, 0)
+ mov r7, r11
+ mov r4, r10
+ mov r6, r9
+ mov r5, r8
+
+ /* Stack frame for the timespec and timeval structs. */
+ add #-8, r15
+ cfi_adjust_cfa_offset(8)
+
+1:
+ /* Get current time. */
+ mov r15, r4
+ mov #0, r5
+ mov #__NR_gettimeofday, r3
+ trapa #0x12
+ SYSCALL_INST_PAD
+
+ /* Compute relative timeout. */
+ mov.l @(4,r15), r0
+ mov.w .L1k, r1
+ dmulu.l r0, r1 /* Micro seconds to nano seconds. */
+ mov.l @r9, r2
+ mov.l @(4,r9), r3
+ mov.l @r15, r0
+ sts macl, r1
+ sub r0, r2
+ clrt
+ subc r1, r3
+ bf 4f
+ mov.l .L1g, r1
+ add r1, r3
+ add #-1, r2
+4:
+ cmp/pz r2
+ bf 8f /* Time is already up. */
+
+ mov.l r2, @r15 /* Store relative timeout. */
+ mov.l r3, @(4,r15)
+
+ mov r10, r6
+ mov.l .L_FUTEX_WAITERS2, r0
+ or r0, r6
+ shlr r0 /* r0 = FUTEX_OWNER_DIED */
+ tst r0, r4
+ bf/s 6f
+ cmp/eq r4, r6
+ bt 2f
+
+ CMPXCHG (r4, @r8, r6, r2)
+ bf/s 5f
+ mov #0, r5
+
+2:
+ mov r8, r4
+ mov r11, r5
+ LOAD_FUTEX_WAIT (r5, r0, r1)
+ mov r10, r6
+ mov r15, r7
+ mov #SYS_futex, r3
+ extu.b r3, r3
+ trapa #0x14
+ SYSCALL_INST_PAD
+ mov r0, r5
+
+ mov.l @r8, r2
+
+5:
+ tst r2, r2
+ bf/s 7f
+ mov r2, r10
+
+ stc gbr, r1
+ mov.w .Ltidoff2, r2
+ add r2, r1
+ mov.l @r1, r4
+ mov #0, r3
+ CMPXCHG (r3, @r8, r4, r10)
+ bf 7f
+ mov #0, r0
+
+6:
+ add #8, r15
+ mov.l @r15+, r8
+ mov.l @r15+, r9
+ mov.l @r15+, r10
+ rts
+ mov.l @r15+, r11
+
+7:
+ /* Check whether the time expired. */
+ mov #-ETIMEDOUT, r1
+ cmp/eq r5, r1
+ bf 1b
+
+8:
+ bra 6b
+ mov #ETIMEDOUT, r0
+3:
+ rts
+ mov #EINVAL, r0
+ cfi_endproc
+ .align 2
+.L_FUTEX_WAITERS2:
+ .long FUTEX_WAITERS
+.L1g:
+ .long 1000000000
+.Ltidoff2:
+ .word TID - TLS_PRE_TCB_SIZE
+.L1k:
+ .word 1000
+ .size __lll_robust_timedlock_wait,.-__lll_robust_timedlock_wait
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pt-initfini.c b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pt-initfini.c
new file mode 100644
index 000000000..71fef93d3
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pt-initfini.c
@@ -0,0 +1,125 @@
+/* Special .init and .fini section support for SH. NPTL version.
+ Copyright (C) 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 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.
+
+ In addition to the permissions in the GNU Library 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 Library 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 Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ see <http://www.gnu.org/licenses/>. */
+
+/* This file is compiled into assembly code which is then munged by a sed
+ script into two files: crti.s and crtn.s.
+
+ * crti.s puts a function prologue at the beginning of the
+ .init and .fini sections and defines global symbols for
+ those addresses, so they can be called as functions.
+
+ * crtn.s puts the corresponding function epilogues
+ in the .init and .fini sections. */
+
+__asm__ ("\n\
+\n\
+#include \"defs.h\"\n\
+\n\
+/*@HEADER_ENDS*/\n\
+\n\
+/*@TESTS_BEGIN*/\n\
+\n\
+/*@TESTS_END*/\n\
+\n\
+/*@_init_PROLOG_BEGINS*/\n\
+ .section .init\n\
+ .align 5\n\
+ .global _init\n\
+ .type _init,@function\n\
+_init:\n\
+ mov.l r12,@-r15\n\
+ mov.l r14,@-r15\n\
+ sts.l pr,@-r15\n\
+ mova .L22,r0\n\
+ mov.l .L22,r12\n\
+ add r0,r12\n\
+ mova .L24,r0\n\
+ mov.l .L24,r1\n\
+ add r0,r1\n\
+ jsr @r1\n\
+ mov r15,r14\n\
+ bra 1f\n\
+ nop\n\
+ .align 2\n\
+.L22:\n\
+ .long _GLOBAL_OFFSET_TABLE_\n\
+.L24:\n\
+ .long __pthread_initialize_minimal_internal@PLT\n\
+1:\n\
+ ALIGN\n\
+ END_INIT\n\
+\n\
+/*@_init_PROLOG_ENDS*/\n\
+\n\
+/*@_init_EPILOG_BEGINS*/\n\
+ .section .init\n\
+ mov r14,r15\n\
+ lds.l @r15+,pr\n\
+ mov.l @r15+,r14\n\
+ rts \n\
+ mov.l @r15+,r12\n\
+ END_INIT\n\
+ \n\
+/*@_init_EPILOG_ENDS*/\n\
+\n\
+/*@_fini_PROLOG_BEGINS*/\n\
+ .section .fini\n\
+ .align 5\n\
+ .global _fini\n\
+ .type _fini,@function\n\
+_fini:\n\
+ mov.l r12,@-r15\n\
+ mov.l r14,@-r15\n\
+ sts.l pr,@-r15\n\
+ mova .L27,r0\n\
+ mov.l .L27,r12\n\
+ add r0,r12\n\
+ mov r15,r14\n\
+ ALIGN\n\
+ END_FINI\n\
+ bra 1f\n\
+ nop\n\
+ .align 2\n\
+.L27:\n\
+ .long _GLOBAL_OFFSET_TABLE_\n\
+1:\n\
+/*@_fini_PROLOG_ENDS*/\n\
+\n\
+/*@_fini_EPILOG_BEGINS*/\n\
+ .section .fini\n\
+ mov r14,r15\n\
+ lds.l @r15+,pr\n\
+ mov.l @r15+,r14\n\
+ rts \n\
+ mov.l @r15+,r12\n\
+\n\
+ END_FINI\n\
+ \n\
+/*@_fini_EPILOG_ENDS*/\n\
+\n\
+/*@TRAILER_BEGINS*/\n\
+");
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_barrier_wait.S b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_barrier_wait.S
new file mode 100644
index 000000000..58a9cdef5
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_barrier_wait.S
@@ -0,0 +1,215 @@
+/* Copyright (C) 2003, 2004, 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
+ 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 <lowlevellock.h>
+#include <lowlevelbarrier.h>
+#include "lowlevel-atomic.h"
+
+ .text
+
+ .globl pthread_barrier_wait
+ .type pthread_barrier_wait,@function
+ .align 5
+pthread_barrier_wait:
+ mov.l r9, @-r15
+ mov.l r8, @-r15
+ sts.l pr, @-r15
+ mov r4, r8
+
+ /* Get the mutex. */
+ mov #0, r3
+ mov #1, r4
+ CMPXCHG (r3, @(MUTEX,r8), r4, r2)
+ bf 1f
+
+ /* One less waiter. If this was the last one needed wake
+ everybody. */
+2:
+ mov.l @(LEFT,r8), r0
+ add #-1, r0
+ mov.l r0, @(LEFT,r8)
+ tst r0, r0
+ bt 3f
+
+ /* There are more threads to come. */
+ mov.l @(CURR_EVENT,r8), r6
+
+ /* Release the mutex. */
+ DEC (@(MUTEX,r8), r2)
+ tst r2, r2
+ bf 6f
+7:
+ /* Wait for the remaining threads. The call will return immediately
+ if the CURR_EVENT memory has meanwhile been changed. */
+ mov r8, r4
+#if CURR_EVENT != 0
+ add #CURR_EVENT, r4
+#endif
+#if FUTEX_WAIT == 0
+ mov.l @(PRIVATE,r8), r5
+#else
+ mov #FUTEX_WAIT, r5
+ mov.l @(PRIVATE,r8), r0
+ or r0, r5
+#endif
+ mov #0, r7
+8:
+ mov #SYS_futex, r3
+ extu.b r3, r3
+ trapa #0x14
+ SYSCALL_INST_PAD
+
+ /* Don't return on spurious wakeups. The syscall does not change
+ any register except r0 so there is no need to reload any of
+ them. */
+ mov.l @(CURR_EVENT,r8), r0
+ cmp/eq r0, r6
+ bt 8b
+
+ /* Increment LEFT. If this brings the count back to the
+ initial count unlock the object. */
+ mov #1, r3
+ mov.l @(INIT_COUNT,r8), r4
+ XADD (r3, @(LEFT,r8), r2, r5)
+ add #-1, r4
+ cmp/eq r2, r4
+ bf 10f
+
+ /* Release the mutex. We cannot release the lock before
+ waking the waiting threads since otherwise a new thread might
+ arrive and gets waken up, too. */
+ DEC (@(MUTEX,r8), r2)
+ tst r2, r2
+ bf 9f
+
+10:
+ mov #0, r0 /* != PTHREAD_BARRIER_SERIAL_THREAD */
+ lds.l @r15+, pr
+ mov.l @r15+, r8
+ rts
+ mov.l @r15+, r9
+
+3:
+ /* The necessary number of threads arrived. */
+ mov.l @(CURR_EVENT,r8), r1
+ add #1, r1
+ mov.l r1, @(CURR_EVENT,r8)
+
+ /* Wake up all waiters. The count is a signed number in the kernel
+ so 0x7fffffff is the highest value. */
+ mov.l .Lall, r6
+ mov r8, r4
+#if CURR_EVENT != 0
+ add #CURR_EVENT, r4
+#endif
+ mov #0, r7
+ mov #FUTEX_WAKE, r5
+ mov.l @(PRIVATE,r8), r0
+ or r0, r5
+ mov #SYS_futex, r3
+ extu.b r3, r3
+ trapa #0x14
+ SYSCALL_INST_PAD
+
+ /* Increment LEFT. If this brings the count back to the
+ initial count unlock the object. */
+ mov #1, r3
+ mov.l @(INIT_COUNT,r8), r4
+ XADD (r3, @(LEFT,r8), r2, r5)
+ add #-1, r4
+ cmp/eq r2, r4
+ bf 5f
+
+ /* Release the mutex. */
+ DEC (@(MUTEX,r8), r2)
+ tst r2, r2
+ bf 4f
+5:
+ mov #-1, r0 /* == PTHREAD_BARRIER_SERIAL_THREAD */
+ lds.l @r15+, pr
+ mov.l @r15+, r8
+ rts
+ mov.l @r15+, r9
+
+1:
+ mov.l @(PRIVATE,r8), r6
+ mov #LLL_SHARED, r0
+ extu.b r0, r0
+ xor r0, r6
+ mov r2, r4
+ mov r8, r5
+ mov.l .Lwait0, r1
+ bsrf r1
+ add #MUTEX, r5
+.Lwait0b:
+ bra 2b
+ nop
+
+4:
+ mov.l @(PRIVATE,r8), r5
+ mov #LLL_SHARED, r0
+ extu.b r0, r0
+ xor r0, r5
+ mov r8, r4
+ mov.l .Lwake0, r1
+ bsrf r1
+ add #MUTEX, r4
+.Lwake0b:
+ bra 5b
+ nop
+
+6:
+ mov r6, r9
+ mov.l @(PRIVATE,r8), r5
+ mov #LLL_SHARED, r0
+ extu.b r0, r0
+ xor r0, r5
+ mov r8, r4
+ mov.l .Lwake1, r1
+ bsrf r1
+ add #MUTEX, r4
+.Lwake1b:
+ bra 7b
+ mov r9, r6
+
+9:
+ mov r6, r9
+ mov.l @(PRIVATE,r8), r5
+ mov #LLL_SHARED, r0
+ extu.b r0, r0
+ xor r0, r5
+ mov r8, r4
+ mov.l .Lwake2, r1
+ bsrf r1
+ add #MUTEX, r4
+.Lwake2b:
+ bra 10b
+ mov r9, r6
+
+ .align 2
+.Lall:
+ .long 0x7fffffff
+.Lwait0:
+ .long __lll_lock_wait-.Lwait0b
+.Lwake0:
+ .long __lll_unlock_wake-.Lwake0b
+.Lwake1:
+ .long __lll_unlock_wake-.Lwake1b
+.Lwake2:
+ .long __lll_unlock_wake-.Lwake2b
+ .size pthread_barrier_wait,.-pthread_barrier_wait
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_broadcast.S b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_broadcast.S
new file mode 100644
index 000000000..ca0fe7966
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_broadcast.S
@@ -0,0 +1,262 @@
+/* Copyright (C) 2003, 2004, 2006, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <lowlevelcond.h>
+#include <bits/kernel-features.h>
+#include <pthread-pi-defines.h>
+#include <pthread-errnos.h>
+#include <tcb-offsets.h>
+#include "lowlevel-atomic.h"
+
+ .text
+
+ /* int pthread_cond_broadcast (pthread_cond_t *cond) */
+ .globl __pthread_cond_broadcast
+ .type __pthread_cond_broadcast, @function
+ .protected __pthread_cond_broadcast
+ .align 5
+__pthread_cond_broadcast:
+ mov.l r10, @-r15
+ mov.l r9, @-r15
+ mov.l r8, @-r15
+ sts.l pr, @-r15
+ mov r4, r8
+
+ /* Get internal lock. */
+ mov #0, r3
+ mov #1, r4
+#if cond_lock != 0
+ CMPXCHG (r3, @(cond_lock,r8), r4, r2)
+#else
+ CMPXCHG (r3, @r8, r4, r2)
+#endif
+ bf 1f
+2:
+ mov.l @(total_seq+4,r8),r0
+ mov.l @(total_seq,r8),r1
+ mov.l @(wakeup_seq+4,r8), r2
+ cmp/hi r2, r0
+ bt 3f
+ cmp/hi r0, r2
+ bt 4f
+ mov.l @(wakeup_seq,r8), r2
+ cmp/hi r2, r1
+ bf 4f
+
+3:
+ /* Cause all currently waiting threads to recognize they are
+ woken up. */
+ mov.l r1, @(wakeup_seq,r8)
+ mov.l r0, @(wakeup_seq+4,r8)
+ mov.l r1, @(woken_seq,r8)
+ mov.l r0, @(woken_seq+4,r8)
+ mov.l @(broadcast_seq,r8), r2
+ add #1, r2
+ mov.l r2, @(broadcast_seq,r8)
+ add r1, r1
+ mov r1, r10
+ mov.l r10, @(cond_futex,r8)
+
+ /* Get the address of the mutex used. */
+ mov.l @(dep_mutex,r8), r9
+
+ /* Unlock. */
+#if cond_lock != 0
+ DEC (@(cond_lock,r8), r2)
+#else
+ DEC (@r8, r2)
+#endif
+ tst r2, r2
+ bf 7f
+
+8:
+ /* Don't use requeue for pshared condvars. */
+ mov #-1, r0
+ cmp/eq r0, r9
+ mov r8, r4
+ bt/s 9f
+ add #cond_futex, r4
+
+ /* XXX: The kernel only supports FUTEX_CMP_REQUEUE to the same
+ type of futex (private resp. shared). */
+ mov.l @(MUTEX_KIND,r9), r0
+ tst #(PI_BIT|PS_BIT), r0
+ bf 9f
+
+ /* Wake up all threads. */
+#ifdef __ASSUME_PRIVATE_FUTEX
+ mov #(FUTEX_CMP_REQUEUE|FUTEX_PRIVATE_FLAG), r5
+ extu.b r5, r5
+#else
+ stc gbr, r1
+ mov.w .Lpfoff, r2
+ add r2, r1
+ mov.l @r1, r5
+ mov #FUTEX_CMP_REQUEUE, r0
+ or r0, r5
+#endif
+ mov #1, r6
+ mov #-1, r7
+ shlr r7 /* r7 = 0x7fffffff */
+ mov r9, r0
+# if MUTEX_FUTEX != 0
+ add #MUTEX_FUTEX, r0
+# endif
+ mov r10, r1
+ mov #SYS_futex, r3
+ extu.b r3, r3
+ trapa #0x16
+ SYSCALL_INST_PAD
+
+ /* For any kind of error, which mainly is EAGAIN, we try again
+ with WAKE. The general test also covers running on old
+ kernels. */
+ mov r0, r1
+ mov #-12, r2
+ shad r2, r1
+ not r1, r1
+ tst r1, r1
+ mov r8, r4
+ bt/s 9f
+ add #cond_futex, r4
+
+10:
+ mov #0, r0
+ lds.l @r15+, pr
+ mov.l @r15+, r8
+ mov.l @r15+, r9
+ rts
+ mov.l @r15+, r10
+
+4:
+ /* Unlock. */
+#if cond_lock != 0
+ DEC (@(cond_lock,r8), r2)
+#else
+ DEC (@r8, r2)
+#endif
+ tst r2, r2
+ bf 5f
+6:
+ mov #0, r0
+ lds.l @r15+, pr
+ mov.l @r15+, r8
+ mov.l @r15+, r9
+ rts
+ mov.l @r15+, r10
+
+1:
+ /* Initial locking failed. */
+ mov r8, r5
+#if cond_lock != 0
+ add #cond_lock, r5
+#endif
+ mov.l @(dep_mutex,r8), r0
+ cmp/eq #-1, r0
+ bf/s 99f
+ mov #LLL_PRIVATE, r6
+ mov #LLL_SHARED, r6
+99:
+ extu.b r6, r6
+ mov.l .Lwait5, r1
+ bsrf r1
+ mov r2, r4
+.Lwait5b:
+ bra 2b
+ nop
+
+5:
+ /* Unlock in loop requires wakeup. */
+ mov r8, r4
+#if cond_lock != 0
+ add #cond_lock, r4
+#endif
+ mov.l @(dep_mutex,r8), r0
+ cmp/eq #-1, r0
+ bf/s 99f
+ mov #LLL_PRIVATE, r5
+ mov #LLL_SHARED, r5
+99:
+ mov.l .Lwake5, r1
+ bsrf r1
+ extu.b r5, r5
+.Lwake5b:
+ bra 6b
+ nop
+
+7:
+ /* Unlock in loop requires wakeup. */
+ mov r8, r4
+#if cond_lock != 0
+ add #cond_lock, r4
+#endif
+ mov #-1, r0
+ cmp/eq r0, r9
+ bf/s 99f
+ mov #LLL_PRIVATE, r5
+ mov #LLL_SHARED, r5
+99:
+ mov.l .Lwake6, r1
+ bsrf r1
+ extu.b r5, r5
+.Lwake6b:
+ bra 8b
+ nop
+
+9:
+ mov #-1, r0
+ cmp/eq r0, r9
+ bt/s 99f
+ mov #FUTEX_WAKE, r5
+#ifdef __ASSUME_PRIVATE_FUTEX
+ mov #(FUTEX_WAKE|FUTEX_PRIVATE_FLAG), r5
+ extu.b r5, r5
+#else
+ stc gbr, r1
+ mov.w .Lpfoff, r2
+ add r2, r1
+ mov.l @r1, r5
+ mov #FUTEX_WAKE, r0
+ or r0, r5
+#endif
+99:
+ mov #-1, r6
+ shlr r6 /* r6 = 0x7fffffff */
+ mov #0, r7
+ mov #SYS_futex, r3
+ extu.b r3, r3
+ trapa #0x14
+ SYSCALL_INST_PAD
+ bra 10b
+ nop
+
+#ifndef __ASSUME_PRIVATE_FUTEX
+.Lpfoff:
+ .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE
+#endif
+
+ .align 2
+.Lwait5:
+ .long __lll_lock_wait-.Lwait5b
+.Lwake5:
+ .long __lll_unlock_wake-.Lwake5b
+.Lwake6:
+ .long __lll_unlock_wake-.Lwake6b
+ .size __pthread_cond_broadcast, .-__pthread_cond_broadcast
+weak_alias (__pthread_cond_broadcast, pthread_cond_broadcast)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_signal.S b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_signal.S
new file mode 100644
index 000000000..8a9bb0b65
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_signal.S
@@ -0,0 +1,189 @@
+/* Copyright (C) 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
+ 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 <lowlevellock.h>
+#include <lowlevelcond.h>
+#include <bits/kernel-features.h>
+#include <pthread-errnos.h>
+#include <tcb-offsets.h>
+#include "lowlevel-atomic.h"
+
+ .text
+
+ /* int pthread_cond_signal (pthread_cond_t *cond) */
+ .globl __pthread_cond_signal
+ .type __pthread_cond_signal, @function
+ .protected __pthread_cond_signal
+ .align 5
+__pthread_cond_signal:
+ mov.l r8, @-r15
+ sts.l pr, @-r15
+ mov r4, r8
+
+ /* Get internal lock. */
+ mov #0, r3
+ mov #1, r4
+#if cond_lock != 0
+ CMPXCHG (r3, @(cond_lock,r8), r4, r2)
+#else
+ CMPXCHG (r3, @r8, r4, r2)
+#endif
+ bf 1f
+2:
+ mov.l @(total_seq+4,r8),r0
+ mov.l @(total_seq,r8),r1
+ mov.l @(wakeup_seq+4,r8), r2
+ cmp/hi r2, r0
+ bt 3f
+ cmp/hi r0, r2
+ bt 4f
+ mov.l @(wakeup_seq,r8), r2
+ cmp/hi r2, r1
+ bf 4f
+
+3:
+ /* Bump the wakeup number. */
+ mov #1, r2
+ mov #0, r3
+ clrt
+ mov.l @(wakeup_seq,r8),r0
+ mov.l @(wakeup_seq+4,r8),r1
+ addc r2, r0
+ addc r3, r1
+ mov.l r0,@(wakeup_seq,r8)
+ mov.l r1,@(wakeup_seq+4,r8)
+ mov.l @(cond_futex,r8),r0
+ add r2, r0
+ mov.l r0,@(cond_futex,r8)
+
+ /* Wake up one thread. */
+ mov r8, r4
+ add #cond_futex, r4
+ mov.l @(dep_mutex,r8), r0
+ cmp/eq #-1, r0
+ bt/s 99f
+ mov #FUTEX_WAKE_OP, r5
+#ifdef __ASSUME_PRIVATE_FUTEX
+ mov #(FUTEX_WAKE_OP|FUTEX_PRIVATE_FLAG), r5
+ extu.b r5, r5
+#else
+ stc gbr, r1
+ mov.w .Lpfoff, r2
+ add r2, r1
+ mov.l @r1, r5
+ mov #FUTEX_WAKE_OP, r0
+ or r0, r5
+#endif
+99:
+ mov #1, r6
+ mov #0, r7
+ mov r8, r0
+ add #cond_lock, r0
+ mov.l .Lfutexop, r1
+ mov #SYS_futex, r3
+ extu.b r3, r3
+ trapa #0x14
+ SYSCALL_INST_PAD
+
+ /* For any kind of error, we try again with WAKE.
+ The general test also covers running on old kernels. */
+ mov r0, r1
+ mov #-12, r2
+ shad r2, r1
+ not r1, r1
+ tst r1, r1
+ bt 7f
+
+6:
+ mov #0, r0
+ lds.l @r15+, pr
+ rts
+ mov.l @r15+, r8
+
+#ifndef __ASSUME_PRIVATE_FUTEX
+.Lpfoff:
+ .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE
+#endif
+ .align 2
+.Lfutexop:
+ .long FUTEX_OP_CLEAR_WAKE_IF_GT_ONE
+
+7:
+ /* r5 should be either FUTEX_WAKE_OP or
+ FUTEX_WAKE_OP|FUTEX_PRIVATE_FLAG from the previous syscall. */
+ mov #(FUTEX_WAKE ^ FUTEX_WAKE_OP), r0
+ xor r0, r5
+ trapa #0x14
+ SYSCALL_INST_PAD
+
+4:
+ /* Unlock. */
+#if cond_lock != 0
+ DEC (@(cond_lock,r8), r2)
+#else
+ DEC (@r8, r2)
+#endif
+ tst r2, r2
+ bt 6b
+
+5:
+ /* Unlock in loop requires wakeup. */
+ mov r8, r4
+#if cond_lock != 0
+ add #cond_lock, r4
+#endif
+ mov.l @(dep_mutex,r8), r0
+ cmp/eq #-1, r0
+ bf/s 99f
+ mov #LLL_PRIVATE, r5
+ mov #LLL_SHARED, r5
+99:
+ mov.l .Lwake4, r1
+ bsrf r1
+ extu.b r5, r5
+.Lwake4b:
+ bra 6b
+ nop
+
+1:
+ /* Initial locking failed. */
+ mov r8, r5
+#if cond_lock != 0
+ add #cond_lock, r5
+#endif
+ mov.l @(dep_mutex,r8), r0
+ cmp/eq #-1, r0
+ bf/s 99f
+ mov #LLL_PRIVATE, r6
+ mov #LLL_SHARED, r6
+99:
+ extu.b r6, r6
+ mov.l .Lwait4, r1
+ bsrf r1
+ mov r2, r4
+.Lwait4b:
+ bra 2b
+ nop
+
+ .align 2
+.Lwait4:
+ .long __lll_lock_wait-.Lwait4b
+.Lwake4:
+ .long __lll_unlock_wake-.Lwake4b
+ .size __pthread_cond_signal, .-__pthread_cond_signal
+weak_alias (__pthread_cond_signal, pthread_cond_signal)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S
new file mode 100644
index 000000000..0f79e1821
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S
@@ -0,0 +1,860 @@
+/* Copyright (C) 2003, 2004, 2006, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <lowlevelcond.h>
+#include <pthread-errnos.h>
+#include <bits/kernel-features.h>
+#include <tcb-offsets.h>
+#include "lowlevel-atomic.h"
+
+ .text
+
+/* int pthread_cond_timedwait (pthread_cond_t *cond, pthread_mutex_t *mutex,
+ const struct timespec *abstime) */
+ .globl __pthread_cond_timedwait
+ .type __pthread_cond_timedwait, @function
+ .protected __pthread_cond_timedwait
+ .align 5
+__pthread_cond_timedwait:
+.LSTARTCODE:
+ mov.l r8, @-r15
+.Lpush_r8:
+ mov.l r9, @-r15
+.Lpush_r9:
+ mov.l r10, @-r15
+.Lpush_r10:
+ mov.l r11, @-r15
+.Lpush_r11:
+ mov.l r12, @-r15
+.Lpush_r12:
+ mov.l r13, @-r15
+.Lpush_r13:
+ sts.l pr, @-r15
+.Lpush_pr:
+ add #-64, r15
+.Lalloc:
+ mov r4, r8
+ mov r5, r9
+ mov r6, r13
+#ifdef __PIC__
+ mova .Lgot0, r0
+ mov.l .Lgot0, r12
+ add r0, r12
+#endif
+
+ mov.l @(4,r13), r0
+ mov.l .L1g, r1
+ cmp/hs r1, r0
+ bf 0f
+ bra 18f
+ mov #EINVAL, r0
+0:
+ /* Get internal lock. */
+ mov #0, r3
+ mov #1, r4
+#if cond_lock != 0
+ CMPXCHG (r3, @(cond_lock,r8), r4, r2)
+#else
+ CMPXCHG (r3, @r8, r4, r2)
+#endif
+ bt 2f
+ bra 1f
+ nop
+#ifdef __PIC__
+ .align 2
+.Lgot0:
+ .long _GLOBAL_OFFSET_TABLE_
+#endif
+
+2:
+ /* Store the reference to the mutex. If there is already a
+ different value in there this is a bad user bug. */
+ mov.l @(dep_mutex,r8),r0
+ cmp/eq #-1, r0
+ bt 17f
+ mov.l r9, @(dep_mutex,r8)
+
+17:
+ /* Unlock the mutex. */
+ mov.l .Lmunlock1, r1
+ mov #0, r5
+ bsrf r1
+ mov r9, r4
+.Lmunlock1b:
+
+ tst r0, r0
+ bt 0f
+ bra 16f
+ nop
+0:
+ mov #1, r2
+ mov #0, r3
+
+ clrt
+ mov.l @(total_seq,r8),r0
+ mov.l @(total_seq+4,r8),r1
+ addc r2, r0
+ addc r3, r1
+ mov.l r0,@(total_seq,r8)
+ mov.l r1,@(total_seq+4,r8)
+ mov.l @(cond_futex,r8), r0
+ add r2, r0
+ mov.l r0, @(cond_futex,r8)
+ mov #(1 << nwaiters_shift), r2
+ mov.l @(cond_nwaiters,r8), r0
+ add r2, r0
+ mov.l r0, @(cond_nwaiters,r8)
+
+ /* Get and store current wakeup_seq value. */
+ mov.l @(wakeup_seq,r8), r10
+ mov.l @(wakeup_seq+4,r8), r11
+ mov.l @(broadcast_seq,r8), r0
+ mov.l r0, @(4,r15)
+
+8:
+ /* Get current time. */
+#ifdef __NR_clock_gettime
+ /* Get the clock number. */
+ mov.l @(cond_nwaiters,r8), r4
+ mov #((1 << nwaiters_shift) - 1), r0
+ and r0, r4
+ /* Only clocks 0 and 1 are allowed. Both are handled in the
+ kernel. */
+ mov r15, r5
+ add #16, r5
+ mov.w .L__NR_clock_gettime, r3
+ trapa #0x12
+ SYSCALL_INST_PAD
+# ifndef __ASSUME_POSIX_TIMERS
+ cmp/eq #-ENOSYS, r0
+ bt 19f
+# endif
+
+ /* Compute relative timeout. */
+ mov.l @r13, r2
+ mov.l @(4,r13), r3
+ mov.l @(16,r15), r0
+ bra 0f
+ mov.l @(20,r15), r1
+.L__NR_clock_gettime:
+ .word __NR_clock_gettime
+
+# ifndef __ASSUME_POSIX_TIMERS
+19:
+ mov r15, r4
+ add #16, r4
+ mov #0, r5
+ mov #__NR_gettimeofday, r3
+ trapa #0x12
+ SYSCALL_INST_PAD
+
+ /* Compute relative timeout. */
+ mov.l @(20,r15), r0
+ mov.w .L1k, r1
+ dmulu.l r0, r1 /* Micro seconds to nano seconds. */
+ mov.l @r13, r2
+ mov.l @(4,r13), r3
+ mov.l @(16,r15), r0
+ sts macl, r1
+#endif
+0:
+#else
+ mov r15, r4
+ add #16, r4
+ mov #0, r5
+ mov #__NR_gettimeofday, r3
+ trapa #0x12
+ SYSCALL_INST_PAD
+
+ /* Compute relative timeout. */
+ mov.l @(20,r15), r0
+ mov.w .L1k, r1
+ dmulu.l r0, r1 /* Micro seconds to nano seconds. */
+ mov.l @r13, r2
+ mov.l @(4,r13), r3
+ mov.l @(16,r15), r0
+ sts macl, r1
+#endif
+ sub r0, r2
+ clrt
+ subc r1, r3
+ bf 12f
+ mov.l .L1g, r1
+ add r1, r3
+ add #-1, r2
+12:
+ mov #-ETIMEDOUT, r1
+ mov.l r1, @(12,r15)
+ cmp/pz r2
+ bf 6f /* Time is already up. */
+
+ /* Store relative timeout. */
+ mov.l r2, @(16,r15)
+ mov.l r3, @(20,r15)
+ mov.l @(cond_futex,r8), r1
+ mov.l r1, @(8,r15)
+
+ /* Unlock. */
+#if cond_lock != 0
+ DEC (@(cond_lock,r8), r2)
+#else
+ DEC (@r8, r2)
+#endif
+ tst r2, r2
+ bt 4f
+ bra 3f
+ nop
+4:
+.LcleanupSTART:
+ mov.l .Lenable1, r1
+ bsrf r1
+ nop
+.Lenable1b:
+ mov.l r0, @r15
+
+ mov r15, r7
+ add #16, r7
+ mov.l @(dep_mutex,r8), r0
+ cmp/eq #-1, r0
+ bt/s 99f
+ mov #FUTEX_WAIT, r5
+#ifdef __ASSUME_PRIVATE_FUTEX
+ mov #(FUTEX_WAIT|FUTEX_PRIVATE_FLAG), r5
+ extu.b r5, r5
+#else
+ stc gbr, r1
+ mov.w .Lpfoff, r2
+ add r2, r1
+ mov.l @r1, r5
+ mov #FUTEX_WAIT, r0
+ or r0, r5
+#endif
+99:
+ mov.l @(8,r15), r6
+ mov r8, r4
+ add #cond_futex, r4
+ mov #SYS_futex, r3
+ extu.b r3, r3
+ trapa #0x14
+ SYSCALL_INST_PAD
+ mov.l r0, @(12,r15)
+
+ mov.l .Ldisable1, r1
+ bsrf r1
+ mov.l @r15, r4
+.Ldisable1b:
+.LcleanupEND:
+
+ /* Lock. */
+ mov #0, r3
+ mov #1, r4
+#if cond_lock != 0
+ CMPXCHG (r3, @(cond_lock,r8), r4, r2)
+#else
+ CMPXCHG (r3, @r8, r4, r2)
+#endif
+ bf 5f
+6:
+ mov.l @(broadcast_seq,r8), r0
+ mov.l @(4,r15), r1
+ cmp/eq r0, r1
+ bf 23f
+
+ mov.l @(woken_seq,r8), r0
+ mov.l @(woken_seq+4,r8), r1
+
+ mov.l @(wakeup_seq,r8), r2
+ mov.l @(wakeup_seq+4,r8), r3
+
+ cmp/eq r3, r11
+ bf 7f
+ cmp/eq r2, r10
+ bt 15f
+7:
+ cmp/eq r1, r3
+ bf 9f
+ cmp/eq r0, r2
+ bf 9f
+15:
+ mov.l @(12,r15),r0
+ cmp/eq #-ETIMEDOUT, r0
+ bf 8b
+
+ mov #1, r2
+ mov #0, r3
+
+ clrt
+ mov.l @(wakeup_seq,r8),r0
+ mov.l @(wakeup_seq+4,r8),r1
+ addc r2, r0
+ addc r3, r1
+ mov.l r0,@(wakeup_seq,r8)
+ mov.l r1,@(wakeup_seq+4,r8)
+ mov.l @(cond_futex,r8),r0
+ add r2, r0
+ mov.l r0,@(cond_futex,r8)
+ mov #ETIMEDOUT, r0
+ bra 14f
+ mov.l r0, @(24,r15)
+
+23:
+ mov #0, r0
+ bra 24f
+ mov.l r0, @(24,r15)
+
+9:
+ mov #0, r0
+ mov.l r0, @(24,r15)
+14:
+ mov #1, r2
+ mov #0, r3
+
+ clrt
+ mov.l @(woken_seq,r8),r0
+ mov.l @(woken_seq+4,r8),r1
+ addc r2, r0
+ addc r3, r1
+ mov.l r0,@(woken_seq,r8)
+ mov.l r1,@(woken_seq+4,r8)
+
+24:
+ mov #(1 << nwaiters_shift), r2
+ mov.l @(cond_nwaiters,r8),r0
+ sub r2, r0
+ mov.l r0,@(cond_nwaiters,r8)
+
+ /* Wake up a thread which wants to destroy the condvar object. */
+ mov.l @(total_seq,r8),r0
+ mov.l @(total_seq+4,r8),r1
+ and r1, r0
+ not r0, r0
+ cmp/eq #0, r0
+ bf/s 25f
+ mov #((1 << nwaiters_shift) - 1), r1
+ not r1, r1
+ mov.l @(cond_nwaiters,r8),r0
+ tst r1, r0
+ bf 25f
+
+ mov r8, r4
+ add #cond_nwaiters, r4
+ mov.l @(dep_mutex,r8), r0
+ cmp/eq #-1, r0
+ bt/s 99f
+ mov #FUTEX_WAKE, r5
+#ifdef __ASSUME_PRIVATE_FUTEX
+ mov #(FUTEX_WAKE|FUTEX_PRIVATE_FLAG), r5
+ extu.b r5, r5
+#else
+ stc gbr, r1
+ mov.w .Lpfoff, r2
+ add r2, r1
+ mov.l @r1, r5
+ mov #FUTEX_WAKE, r0
+ or r0, r5
+#endif
+99:
+ mov #1, r6
+ mov #0, r7
+ mov #SYS_futex, r3
+ extu.b r3, r3
+ trapa #0x14
+ SYSCALL_INST_PAD
+
+25:
+#if cond_lock != 0
+ DEC (@(cond_lock,r8), r2)
+#else
+ DEC (@r8, r2)
+#endif
+ tst r2, r2
+ bf 10f
+
+11:
+ mov r9, r4
+ mov.l .Lmlocki1, r1
+ bsrf r1
+ nop
+.Lmlocki1b:
+
+ /* We return the result of the mutex_lock operation if it failed. */
+ tst r0, r0
+ bf 18f
+ mov.l @(24,r15), r0
+
+18:
+ add #64, r15
+ lds.l @r15+, pr
+ mov.l @r15+, r13
+ mov.l @r15+, r12
+ mov.l @r15+, r11
+ mov.l @r15+, r10
+ mov.l @r15+, r9
+ rts
+ mov.l @r15+, r8
+
+#ifndef __ASSUME_PRIVATE_FUTEX
+.Lpfoff:
+ .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE
+#endif
+.L1k:
+ .word 1000
+ .align 2
+.Lmunlock1:
+ .long __pthread_mutex_unlock_usercnt-.Lmunlock1b
+.Lenable1:
+ .long __pthread_enable_asynccancel-.Lenable1b
+.Ldisable1:
+ .long __pthread_disable_asynccancel-.Ldisable1b
+.Lmlocki1:
+ .long __pthread_mutex_cond_lock-.Lmlocki1b
+.L1g:
+ .long 1000000000
+
+1:
+ /* Initial locking failed. */
+ mov r8, r5
+#if cond_lock != 0
+ add #cond_lock, r5
+#endif
+ mov.l @(dep_mutex,r8), r0
+ cmp/eq #-1, r0
+ bf/s 99f
+ mov #LLL_PRIVATE, r6
+ mov #LLL_SHARED, r6
+99:
+ extu.b r6, r6
+ mov.l .Lwait2, r1
+ bsrf r1
+ mov r2, r4
+.Lwait2b:
+ bra 2b
+ nop
+
+3:
+ /* Unlock in loop requires wakeup. */
+ mov r8, r4
+#if cond_lock != 0
+ add #cond_lock, r4
+#endif
+ mov.l @(dep_mutex,r8), r0
+ cmp/eq #-1, r0
+ bf/s 99f
+ mov #LLL_PRIVATE, r5
+ mov #LLL_SHARED, r5
+99:
+ mov.l .Lmwait2, r1
+ bsrf r1
+ extu.b r5, r5
+.Lmwait2b:
+ bra 4b
+ nop
+
+5:
+ /* Locking in loop failed. */
+ mov r8, r5
+#if cond_lock != 0
+ add #cond_lock, r5
+#endif
+ mov.l @(dep_mutex,r8), r0
+ cmp/eq #-1, r0
+ bf/s 99f
+ mov #LLL_PRIVATE, r6
+ mov #LLL_SHARED, r6
+99:
+ extu.b r6, r6
+ mov.l .Lwait3, r1
+ bsrf r1
+ mov r2, r4
+.Lwait3b:
+ bra 6b
+ nop
+
+10:
+ /* Unlock after loop requires wakeup. */
+ mov r8, r4
+#if cond_lock != 0
+ add #cond_lock, r4
+#endif
+ mov.l @(dep_mutex,r8), r0
+ cmp/eq #-1, r0
+ bf/s 99f
+ mov #LLL_PRIVATE, r5
+ mov #LLL_SHARED, r5
+99:
+ mov.l .Lmwait3, r1
+ bsrf r1
+ extu.b r5, r5
+.Lmwait3b:
+ bra 11b
+ nop
+
+16:
+ /* The initial unlocking of the mutex failed. */
+ mov.l r0, @(24,r15)
+#if cond_lock != 0
+ DEC (@(cond_lock,r8), r2)
+#else
+ DEC (@r8, r2)
+#endif
+ tst r2, r2
+ bf 17f
+
+ mov r8, r4
+#if cond_lock != 0
+ add #cond_lock, r4
+#endif
+ mov.l @(dep_mutex,r8), r0
+ cmp/eq #-1, r0
+ bf/s 99f
+ mov #LLL_PRIVATE, r5
+ mov #LLL_SHARED, r5
+99:
+ mov.l .Lmwait4, r1
+ bsrf r1
+ extu.b r5, r5
+.Lmwait4b:
+17:
+ bra 18b
+ mov.l @(24,r15), r0
+
+ .align 2
+.Lwait2:
+ .long __lll_lock_wait-.Lwait2b
+.Lmwait2:
+ .long __lll_unlock_wake-.Lmwait2b
+.Lwait3:
+ .long __lll_lock_wait-.Lwait3b
+.Lmwait3:
+ .long __lll_unlock_wake-.Lmwait3b
+.Lmwait4:
+ .long __lll_unlock_wake-.Lmwait4b
+ .size __pthread_cond_timedwait, .-__pthread_cond_timedwait
+weak_alias (__pthread_cond_timedwait, pthread_cond_timedwait)
+
+
+ .type __condvar_tw_cleanup, @function
+__condvar_tw_cleanup:
+ mov r4, r11
+
+ /* Get internal lock. */
+ mov #0, r3
+ mov #1, r4
+#if cond_lock != 0
+ CMPXCHG (r3, @(cond_lock,r8), r4, r2)
+#else
+ CMPXCHG (r3, @r8, r4, r2)
+#endif
+ bt 1f
+ nop
+
+ mov r8, r5
+#if cond_lock != 0
+ add #cond_lock, r5
+#endif
+ mov.l @(dep_mutex,r8), r0
+ cmp/eq #-1, r0
+ bf/s 99f
+ mov #LLL_PRIVATE, r6
+ mov #LLL_SHARED, r6
+99:
+ extu.b r6, r6
+ mov.l .Lwait5, r1
+ bsrf r1
+ mov r2, r4
+.Lwait5b:
+
+1:
+ mov.l @(broadcast_seq,r8), r0
+ mov.l @(4,r15), r1
+ cmp/eq r0, r1
+ bf 3f
+
+ mov #1, r2
+ mov #0, r3
+
+ /* We increment the wakeup_seq counter only if it is lower than
+ total_seq. If this is not the case the thread was woken and
+ then canceled. In this case we ignore the signal. */
+ mov.l @(total_seq+4,r8), r0
+ mov.l @(wakeup_seq+4,r8), r1
+ cmp/hi r1, r0
+ bt/s 6f
+ cmp/hi r0, r1
+ bt 7f
+ mov.l @(total_seq,r8), r0
+ mov.l @(wakeup_seq,r8), r1
+ cmp/hs r0, r1
+ bt 7f
+
+6:
+ clrt
+ mov.l @(wakeup_seq,r8),r0
+ mov.l @(wakeup_seq+4,r8),r1
+ addc r2, r0
+ addc r3, r1
+ mov.l r0,@(wakeup_seq,r8)
+ mov.l r1,@(wakeup_seq+4,r8)
+ mov.l @(cond_futex,r8),r0
+ add r2, r0
+ mov.l r0,@(cond_futex,r8)
+
+7:
+ clrt
+ mov.l @(woken_seq,r8),r0
+ mov.l @(woken_seq+4,r8),r1
+ addc r2, r0
+ addc r3, r1
+ mov.l r0,@(woken_seq,r8)
+ mov.l r1,@(woken_seq+4,r8)
+
+3:
+ mov #(1 << nwaiters_shift), r2
+ mov.l @(cond_nwaiters,r8),r0
+ sub r2, r0
+ mov.l r0,@(cond_nwaiters,r8)
+
+ /* Wake up a thread which wants to destroy the condvar object. */
+ mov #0, r10
+ mov.l @(total_seq,r8),r0
+ mov.l @(total_seq+4,r8),r1
+ and r1, r0
+ not r0, r0
+ cmp/eq #0, r0
+ bf/s 4f
+ mov #((1 << nwaiters_shift) - 1), r1
+ not r1, r1
+ mov.l @(cond_nwaiters,r8),r0
+ tst r1, r0
+ bf 4f
+
+ mov r8, r4
+ add #cond_nwaiters, r4
+ mov #FUTEX_WAKE, r5
+ mov #1, r6
+ mov #0, r7
+ mov #SYS_futex, r3
+ extu.b r3, r3
+ trapa #0x14
+ SYSCALL_INST_PAD
+ mov #1, r10
+
+4:
+#if cond_lock != 0
+ DEC (@(cond_lock,r8), r2)
+#else
+ DEC (@r8, r2)
+#endif
+ tst r2, r2
+ bt 2f
+
+ mov r8, r4
+#if cond_lock != 0
+ add #cond_lock, r4
+#endif
+ mov.l @(dep_mutex,r8), r0
+ cmp/eq #-1, r0
+ bf/s 99f
+ mov #LLL_PRIVATE, r5
+ mov #LLL_SHARED, r5
+99:
+ mov.l .Lmwait5, r1
+ bsrf r1
+ extu.b r5, r5
+.Lmwait5b:
+
+2:
+ /* Wake up all waiters to make sure no signal gets lost. */
+ tst r10, r10
+ bf/s 5f
+ mov r8, r4
+ add #cond_futex, r4
+ mov #FUTEX_WAKE, r5
+ mov #-1, r6
+ shlr r6 /* r6 = 0x7fffffff */
+ mov #0, r7
+ mov #SYS_futex, r3
+ extu.b r3, r3
+ trapa #0x14
+ SYSCALL_INST_PAD
+
+5:
+ mov.l .Lmlocki5, r1
+ bsrf r1
+ mov r9, r4
+.Lmlocki5b:
+
+.LcallUR:
+ mov.l .Lresume, r1
+#ifdef __PIC__
+ add r12, r1
+#endif
+ jsr @r1
+ mov r11, r4
+ sleep
+
+ .align 2
+.Lwait5:
+ .long __lll_lock_wait-.Lwait5b
+.Lmwait5:
+ .long __lll_unlock_wake-.Lmwait5b
+.Lmlocki5:
+ .long __pthread_mutex_cond_lock-.Lmlocki5b
+.Lresume:
+#ifdef __PIC__
+ .long _Unwind_Resume@GOTOFF
+#else
+ .long _Unwind_Resume
+#endif
+.LENDCODE:
+ .size __condvar_tw_cleanup, .-__condvar_tw_cleanup
+
+
+ .section .gcc_except_table,"a",@progbits
+.LexceptSTART:
+ .byte 0xff ! @LPStart format (omit)
+ .byte 0xff ! @TType format (omit)
+ .byte 0x0b ! call-site format
+ ! DW_EH_PE_sdata4
+ .uleb128 .Lcstend-.Lcstbegin
+.Lcstbegin:
+ .ualong .LcleanupSTART-.LSTARTCODE
+ .ualong .LcleanupEND-.LcleanupSTART
+ .ualong __condvar_tw_cleanup-.LSTARTCODE
+ .uleb128 0
+ .ualong .LcallUR-.LSTARTCODE
+ .ualong .LENDCODE-.LcallUR
+ .ualong 0
+ .uleb128 0
+.Lcstend:
+
+ .section .eh_frame,"a",@progbits
+.LSTARTFRAME:
+ .ualong .LENDCIE-.LSTARTCIE ! Length of the CIE.
+.LSTARTCIE:
+ .ualong 0 ! CIE ID.
+ .byte 1 ! Version number.
+#ifdef SHARED
+ .string "zPLR" ! NUL-terminated augmentation
+ ! string.
+#else
+ .string "zPL" ! NUL-terminated augmentation
+ ! string.
+#endif
+ .uleb128 1 ! Code alignment factor.
+ .sleb128 -4 ! Data alignment factor.
+ .byte 0x11 ! Return address register
+ ! column.
+#ifdef SHARED
+ .uleb128 7 ! Augmentation value length.
+ .byte 0x9b ! Personality: DW_EH_PE_pcrel
+ ! + DW_EH_PE_sdata4
+ ! + DW_EH_PE_indirect
+ .ualong DW.ref.__gcc_personality_v0-.
+ .byte 0x1b ! LSDA Encoding: DW_EH_PE_pcrel
+ ! + DW_EH_PE_sdata4.
+ .byte 0x1b ! FDE Encoding: DW_EH_PE_pcrel
+ ! + DW_EH_PE_sdata4.
+#else
+ .uleb128 6 ! Augmentation value length.
+ .byte 0x0 ! Personality: absolute
+ .ualong __gcc_personality_v0
+ .byte 0x0 ! LSDA Encoding: absolute
+#endif
+ .byte 0x0c ! DW_CFA_def_cfa
+ .uleb128 0xf
+ .uleb128 0
+ .align 2
+.LENDCIE:
+
+ .ualong .LENDFDE-.LSTARTFDE ! Length of the FDE.
+.LSTARTFDE:
+ .ualong .LSTARTFDE-.LSTARTFRAME ! CIE pointer.
+#ifdef SHARED
+ .ualong .LSTARTCODE-. ! PC-relative start address
+ ! of the code.
+#else
+ .ualong .LSTARTCODE ! Start address of the code.
+#endif
+ .ualong .LENDCODE-.LSTARTCODE ! Length of the code.
+ .uleb128 4 ! Augmentation size
+#ifdef SHARED
+ .ualong .LexceptSTART-.
+#else
+ .ualong .LexceptSTART
+#endif
+ .byte 0x4
+ .ualong .Lpush_r8-.LSTARTCODE
+ .byte 0xe
+ .uleb128 4
+ .byte 0x88
+ .uleb128 1
+ .byte 0x4
+ .ualong .Lpush_r9-.Lpush_r8
+ .byte 0xe
+ .uleb128 8
+ .byte 0x89
+ .uleb128 2
+ .byte 0x4
+ .ualong .Lpush_r10-.Lpush_r9
+ .byte 0xe
+ .uleb128 12
+ .byte 0x8a
+ .uleb128 3
+ .byte 0x4
+ .ualong .Lpush_r11-.Lpush_r10
+ .byte 0xe
+ .uleb128 16
+ .byte 0x8b
+ .uleb128 4
+ .byte 0x4
+ .ualong .Lpush_r12-.Lpush_r11
+ .byte 0xe
+ .uleb128 20
+ .byte 0x8c
+ .uleb128 5
+ .byte 0x4
+ .ualong .Lpush_r13-.Lpush_r12
+ .byte 0xe
+ .uleb128 24
+ .byte 0x8d
+ .uleb128 6
+ .byte 0x4
+ .ualong .Lpush_pr-.Lpush_r13
+ .byte 0xe
+ .uleb128 28
+ .byte 0x91
+ .uleb128 7
+ .byte 0x4
+ .ualong .Lalloc-.Lpush_pr
+ .byte 0xe
+ .uleb128 92
+ .align 2
+.LENDFDE:
+
+#ifdef SHARED
+ .hidden DW.ref.__gcc_personality_v0
+ .weak DW.ref.__gcc_personality_v0
+ .section .gnu.linkonce.d.DW.ref.__gcc_personality_v0,"aw",@progbits
+ .align 4
+ .type DW.ref.__gcc_personality_v0, @object
+ .size DW.ref.__gcc_personality_v0, 4
+DW.ref.__gcc_personality_v0:
+ .long __gcc_personality_v0
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S
new file mode 100644
index 000000000..e1c5c41ba
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S
@@ -0,0 +1,753 @@
+/* Copyright (C) 2003, 2004, 2006, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <lowlevelcond.h>
+#include <tcb-offsets.h>
+#include <bits/kernel-features.h>
+#include "lowlevel-atomic.h"
+
+ .text
+
+/* int pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex) */
+ .globl __pthread_cond_wait
+ .type __pthread_cond_wait, @function
+ .protected __pthread_cond_wait
+ .align 5
+__pthread_cond_wait:
+.LSTARTCODE:
+ mov.l r8, @-r15
+.Lpush_r8:
+ mov.l r9, @-r15
+.Lpush_r9:
+ mov.l r10, @-r15
+.Lpush_r10:
+ mov.l r11, @-r15
+.Lpush_r11:
+ mov.l r12, @-r15
+.Lpush_r12:
+ sts.l pr, @-r15
+.Lpush_pr:
+ add #-48, r15
+.Lalloc:
+ mov r4, r8
+ mov r5, r9
+#ifdef __PIC__
+ mova .Lgot0, r0
+ mov.l .Lgot0, r12
+ add r0, r12
+#endif
+
+ /* Get internal lock. */
+ mov #0, r3
+ mov #1, r4
+#if cond_lock != 0
+ CMPXCHG (r3, @(cond_lock,r8), r4, r2)
+#else
+ CMPXCHG (r3, @r8, r4, r2)
+#endif
+ bt 2f
+ bra 1f
+ nop
+#ifdef __PIC__
+ .align 2
+.Lgot0:
+ .long _GLOBAL_OFFSET_TABLE_
+#endif
+
+2:
+ /* Store the reference to the mutex. If there is already a
+ different value in there this is a bad user bug. */
+ mov.l @(dep_mutex,r8),r0
+ cmp/eq #-1, r0
+ bt 15f
+ mov.l r9, @(dep_mutex,r8)
+
+15:
+ /* Unlock the mutex. */
+ mov.l .Lmunlock0, r1
+ mov #0, r5
+ bsrf r1
+ mov r9, r4
+.Lmunlock0b:
+
+ tst r0, r0
+ bt 0f
+ bra 12f
+ nop
+0:
+ mov #1, r2
+ mov #0, r3
+
+ clrt
+ mov.l @(total_seq,r8),r0
+ mov.l @(total_seq+4,r8),r1
+ addc r2, r0
+ addc r3, r1
+ mov.l r0,@(total_seq,r8)
+ mov.l r1,@(total_seq+4,r8)
+ mov.l @(cond_futex,r8),r0
+ add r2, r0
+ mov.l r0,@(cond_futex,r8)
+ mov #(1 << nwaiters_shift), r2
+ mov.l @(cond_nwaiters,r8), r0
+ add r2, r0
+ mov.l r0, @(cond_nwaiters,r8)
+
+ /* Get and store current wakeup_seq value. */
+ mov.l @(wakeup_seq,r8), r10
+ mov.l @(wakeup_seq+4,r8), r11
+ mov.l @(broadcast_seq,r8), r0
+ mov.l r0, @(4,r15)
+
+8:
+ mov.l @(cond_futex,r8),r0
+ mov.l r0, @(8,r15)
+
+ /* Unlock. */
+#if cond_lock != 0
+ DEC (@(cond_lock,r8), r2)
+#else
+ DEC (@r8, r2)
+#endif
+ tst r2, r2
+ bf 3f
+4:
+.LcleanupSTART:
+ mov.l .Lenable0, r1
+ bsrf r1
+ nop
+.Lenable0b:
+ mov.l r0, @r15
+
+ mov #0, r7
+ mov.l @(dep_mutex,r8), r0
+ cmp/eq #-1, r0
+ bt/s 99f
+ mov #FUTEX_WAIT, r5
+#ifdef __ASSUME_PRIVATE_FUTEX
+ mov #(FUTEX_WAIT|FUTEX_PRIVATE_FLAG), r5
+ extu.b r5, r5
+#else
+ stc gbr, r1
+ mov.w .Lpfoff0, r2
+ add r2, r1
+ mov.l @r1, r5
+ mov #FUTEX_WAIT, r0
+ or r0, r5
+#endif
+99:
+ mov.l @(8,r15), r6
+ mov r8, r4
+ add #cond_futex, r4
+ mov #SYS_futex, r3
+ extu.b r3, r3
+ trapa #0x14
+ SYSCALL_INST_PAD
+
+ mov.l .Ldisable0, r1
+ bsrf r1
+ mov.l @r15, r4
+.Ldisable0b:
+.LcleanupEND:
+
+ /* Lock. */
+ mov #0, r3
+ mov #1, r4
+#if cond_lock != 0
+ CMPXCHG (r3, @(cond_lock,r8), r4, r2)
+#else
+ CMPXCHG (r3, @r8, r4, r2)
+#endif
+ bf 5f
+6:
+ mov.l @(broadcast_seq,r8), r0
+ mov.l @(4,r15), r1
+ cmp/eq r0, r1
+ bf 16f
+
+ mov.l @(woken_seq,r8), r0
+ mov.l @(woken_seq+4,r8), r1
+
+ mov.l @(wakeup_seq,r8), r2
+ mov.l @(wakeup_seq+4,r8), r3
+
+ cmp/eq r3, r11
+ bf 7f
+ cmp/eq r2, r10
+ bt 8b
+7:
+ cmp/eq r1, r3
+ bf 9f
+ cmp/eq r0, r2
+ bt 8b
+9:
+ mov #1, r2
+ mov #0, r3
+
+ clrt
+ mov.l @(woken_seq,r8),r0
+ mov.l @(woken_seq+4,r8),r1
+ addc r2, r0
+ addc r3, r1
+ mov.l r0,@(woken_seq,r8)
+ mov.l r1,@(woken_seq+4,r8)
+
+16:
+ mov #(1 << nwaiters_shift), r2
+ mov.l @(cond_nwaiters,r8),r0
+ sub r2, r0
+ mov.l r0,@(cond_nwaiters,r8)
+
+ /* Wake up a thread which wants to destroy the condvar object. */
+ mov.l @(total_seq,r8),r0
+ mov.l @(total_seq+4,r8),r1
+ and r1, r0
+ not r0, r0
+ cmp/eq #0, r0
+ bf/s 17f
+ mov #((1 << nwaiters_shift) - 1), r1
+ not r1, r1
+ mov.l @(cond_nwaiters,r8),r0
+ tst r1, r0
+ bf 17f
+
+ mov r8, r4
+ add #cond_nwaiters, r4
+ mov.l @(dep_mutex,r8), r0
+ cmp/eq #-1, r0
+ bt/s 99f
+ mov #FUTEX_WAKE, r5
+#ifdef __ASSUME_PRIVATE_FUTEX
+ mov #(FUTEX_WAKE|FUTEX_PRIVATE_FLAG), r5
+ extu.b r5, r5
+#else
+ stc gbr, r1
+ mov.w .Lpfoff0, r2
+ add r2, r1
+ mov.l @r1, r5
+ mov #FUTEX_WAKE, r0
+ or r0, r5
+#endif
+99:
+ mov #1, r6
+ mov #0, r7
+ mov #SYS_futex, r3
+ extu.b r3, r3
+ trapa #0x14
+ SYSCALL_INST_PAD
+
+17:
+#if cond_lock != 0
+ DEC (@(cond_lock,r8), r2)
+#else
+ DEC (@r8, r2)
+#endif
+ tst r2, r2
+ bf 10f
+
+11:
+ mov.l .Lmlocki0, r1
+ bsrf r1
+ mov r9, r4
+.Lmlocki0b:
+ /* We return the result of the mutex_lock operation. */
+
+14:
+ add #48, r15
+ lds.l @r15+, pr
+ mov.l @r15+, r12
+ mov.l @r15+, r11
+ mov.l @r15+, r10
+ mov.l @r15+, r9
+ rts
+ mov.l @r15+, r8
+
+#ifndef __ASSUME_PRIVATE_FUTEX
+.Lpfoff0:
+ .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE
+#endif
+ .align 2
+.Lmunlock0:
+ .long __pthread_mutex_unlock_usercnt-.Lmunlock0b
+.Lenable0:
+ .long __pthread_enable_asynccancel-.Lenable0b
+.Ldisable0:
+ .long __pthread_disable_asynccancel-.Ldisable0b
+.Lmlocki0:
+ .long __pthread_mutex_cond_lock-.Lmlocki0b
+
+1:
+ /* Initial locking failed. */
+ mov r8, r5
+#if cond_lock != 0
+ add #cond_lock, r5
+#endif
+ mov.l @(dep_mutex,r8), r0
+ cmp/eq #-1, r0
+ bf/s 99f
+ mov #LLL_PRIVATE, r6
+ mov #LLL_SHARED, r6
+99:
+ extu.b r6, r6
+ mov.l .Lwait0, r1
+ bsrf r1
+ mov r2, r4
+.Lwait0b:
+ bra 2b
+ nop
+3:
+ /* Unlock in loop requires waekup. */
+ mov r8, r4
+#if cond_lock != 0
+ add #cond_lock, r4
+#endif
+ mov.l @(dep_mutex,r8), r0
+ cmp/eq #-1, r0
+ bf/s 99f
+ mov #LLL_PRIVATE, r5
+ mov #LLL_SHARED, r5
+99:
+ mov.l .Lwake0, r1
+ bsrf r1
+ extu.b r5, r5
+.Lwake0b:
+ bra 4b
+ nop
+
+5:
+ /* Locking in loop failed. */
+ mov r8, r5
+#if cond_lock != 0
+ add #cond_lock, r5
+#endif
+ mov.l @(dep_mutex,r8), r0
+ cmp/eq #-1, r0
+ bf/s 99f
+ mov #LLL_PRIVATE, r6
+ mov #LLL_SHARED, r6
+99:
+ extu.b r6, r6
+ mov.l .Lwait1, r1
+ bsrf r1
+ mov r2, r4
+.Lwait1b:
+ bra 6b
+ nop
+
+10:
+ /* Unlock after loop requires wakeup. */
+ mov r8, r4
+#if cond_lock != 0
+ add #cond_lock, r4
+#endif
+ mov.l @(dep_mutex,r8), r0
+ cmp/eq #-1, r0
+ bf/s 99f
+ mov #LLL_PRIVATE, r5
+ mov #LLL_SHARED, r5
+99:
+ mov.l .Lwake1, r1
+ bsrf r1
+ extu.b r5, r5
+.Lwake1b:
+ bra 11b
+ nop
+
+12:
+ /* The initial unlocking of the mutex failed. */
+ mov.l r0, @(12,r15)
+#if cond_lock != 0
+ DEC (@(cond_lock,r8), r2)
+#else
+ DEC (@r8, r2)
+#endif
+ tst r2, r2
+ bf 13f
+
+ mov r8, r4
+#if cond_lock != 0
+ add #cond_lock, r4
+#endif
+ mov.l @(dep_mutex,r8), r0
+ cmp/eq #-1, r0
+ bf/s 99f
+ mov #LLL_PRIVATE, r5
+ mov #LLL_SHARED, r5
+99:
+ mov.l .Lwake2, r1
+ bsrf r1
+ extu.b r5, r5
+.Lwake2b:
+
+13:
+ bra 14b
+ mov.l @(12,r15), r0
+
+ .align 2
+.Lwait0:
+ .long __lll_lock_wait-.Lwait0b
+.Lwake0:
+ .long __lll_unlock_wake-.Lwake0b
+.Lwait1:
+ .long __lll_lock_wait-.Lwait1b
+.Lwake1:
+ .long __lll_unlock_wake-.Lwake1b
+.Lwake2:
+ .long __lll_unlock_wake-.Lwake2b
+ .size __pthread_cond_wait, .-__pthread_cond_wait
+weak_alias (__pthread_cond_wait, pthread_cond_wait)
+
+
+ .type __condvar_w_cleanup, @function
+__condvar_w_cleanup:
+ mov r4, r11
+
+ /* Get internal lock. */
+ mov #0, r3
+ mov #1, r4
+#if cond_lock != 0
+ CMPXCHG (r3, @(cond_lock,r8), r4, r2)
+#else
+ CMPXCHG (r3, @r8, r4, r2)
+#endif
+ bt 1f
+ nop
+
+ mov r8, r5
+#if cond_lock != 0
+ add #cond_lock, r5
+#endif
+ mov.l @(dep_mutex,r8), r0
+ cmp/eq #-1, r0
+ bf/s 99f
+ mov #LLL_PRIVATE, r6
+ mov #LLL_SHARED, r6
+99:
+ extu.b r6, r6
+ mov.l .Lwait3, r1
+ bsrf r1
+ mov r2, r4
+.Lwait3b:
+
+1:
+ mov.l @(broadcast_seq,r8), r0
+ mov.l @(4,r15), r1
+ cmp/eq r0, r1
+ bf 3f
+
+ mov #1, r2
+ mov #0, r3
+
+ /* We increment the wakeup_seq counter only if it is lower than
+ total_seq. If this is not the case the thread was woken and
+ then canceled. In this case we ignore the signal. */
+ mov.l @(total_seq+4,r8), r0
+ mov.l @(wakeup_seq+4,r8), r1
+ cmp/hi r1, r0
+ bt/s 6f
+ cmp/hi r0, r1
+ bt 7f
+ mov.l @(total_seq,r8), r0
+ mov.l @(wakeup_seq,r8), r1
+ cmp/hs r0, r1
+ bt 7f
+
+6:
+ clrt
+ mov.l @(wakeup_seq,r8),r0
+ mov.l @(wakeup_seq+4,r8),r1
+ addc r2, r0
+ addc r3, r1
+ mov.l r0,@(wakeup_seq,r8)
+ mov.l r1,@(wakeup_seq+4,r8)
+ mov.l @(cond_futex,r8),r0
+ add r2, r0
+ mov.l r0,@(cond_futex,r8)
+
+7:
+ clrt
+ mov.l @(woken_seq,r8),r0
+ mov.l @(woken_seq+4,r8),r1
+ addc r2, r0
+ addc r3, r1
+ mov.l r0,@(woken_seq,r8)
+ mov.l r1,@(woken_seq+4,r8)
+
+3:
+ mov #(1 << nwaiters_shift), r2
+ mov.l @(cond_nwaiters,r8),r0
+ sub r2, r0
+ mov.l r0,@(cond_nwaiters,r8)
+
+ /* Wake up a thread which wants to destroy the condvar object. */
+ mov #0, r10
+ mov.l @(total_seq,r8),r0
+ mov.l @(total_seq+4,r8),r1
+ and r1, r0
+ not r0, r0
+ cmp/eq #0, r0
+ bf/s 4f
+ mov #((1 << nwaiters_shift) - 1), r1
+ not r1, r1
+ mov.l @(cond_nwaiters,r8),r0
+ tst r1, r0
+ bf 4f
+
+ mov r8, r4
+ add #cond_nwaiters, r4
+ mov.l @(dep_mutex,r8), r0
+ cmp/eq #-1, r0
+ bt/s 99f
+ mov #FUTEX_WAKE, r5
+#ifdef __ASSUME_PRIVATE_FUTEX
+ mov #(FUTEX_WAKE|FUTEX_PRIVATE_FLAG), r5
+ extu.b r5, r5
+#else
+ stc gbr, r1
+ mov.w .Lpfoff1, r2
+ add r2, r1
+ mov.l @r1, r5
+ mov #FUTEX_WAKE, r0
+ or r0, r5
+#endif
+99:
+ mov #1, r6
+ mov #0, r7
+ mov #SYS_futex, r3
+ extu.b r3, r3
+ trapa #0x14
+ SYSCALL_INST_PAD
+ mov #1, r10
+
+4:
+#if cond_lock != 0
+ DEC (@(cond_lock,r8), r2)
+#else
+ DEC (@r8, r2)
+#endif
+ tst r2, r2
+ bt 2f
+
+ mov r8, r4
+#if cond_lock != 0
+ add #cond_lock, r4
+#endif
+ mov.l @(dep_mutex,r8), r0
+ cmp/eq #-1, r0
+ bf/s 99f
+ mov #LLL_PRIVATE, r5
+ mov #LLL_SHARED, r5
+99:
+ mov.l .Lwake3, r1
+ bsrf r1
+ extu.b r5, r5
+.Lwake3b:
+
+2:
+ /* Wake up all waiters to make sure no signal gets lost. */
+ tst r10, r10
+ bf/s 5f
+ mov r8, r4
+ add #cond_futex, r4
+ mov.l @(dep_mutex,r8), r0
+ cmp/eq #-1, r0
+ bt/s 99f
+ mov #FUTEX_WAKE, r5
+#ifdef __ASSUME_PRIVATE_FUTEX
+ mov #(FUTEX_WAKE|FUTEX_PRIVATE_FLAG), r5
+ extu.b r5, r5
+#else
+ stc gbr, r1
+ mov.w .Lpfoff1, r2
+ add r2, r1
+ mov.l @r1, r5
+ mov #FUTEX_WAKE, r0
+ or r0, r5
+#endif
+99:
+ mov #-1, r6
+ shlr r6 /* r6 = 0x7fffffff */
+ mov #0, r7
+ mov #SYS_futex, r3
+ extu.b r3, r3
+ trapa #0x14
+ SYSCALL_INST_PAD
+
+5:
+ mov.l .Lmlocki3, r1
+ bsrf r1
+ mov r9, r4
+.Lmlocki3b:
+
+.LcallUR:
+ mov.l .Lresume, r1
+#ifdef __PIC__
+ add r12, r1
+#endif
+ jsr @r1
+ mov r11, r4
+ sleep
+
+#ifndef __ASSUME_PRIVATE_FUTEX
+.Lpfoff1:
+ .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE
+#endif
+ .align 2
+.Lwait3:
+ .long __lll_lock_wait-.Lwait3b
+.Lwake3:
+ .long __lll_unlock_wake-.Lwake3b
+.Lmlocki3:
+ .long __pthread_mutex_cond_lock-.Lmlocki3b
+.Lresume:
+#ifdef __PIC__
+ .long _Unwind_Resume@GOTOFF
+#else
+ .long _Unwind_Resume
+#endif
+.LENDCODE:
+ .size __condvar_w_cleanup, .-__condvar_w_cleanup
+
+
+ .section .gcc_except_table,"a",@progbits
+.LexceptSTART:
+ .byte 0xff ! @LPStart format (omit)
+ .byte 0xff ! @TType format (omit)
+ .byte 0x0b ! call-site format
+ ! DW_EH_PE_sdata4
+ .uleb128 .Lcstend-.Lcstbegin
+.Lcstbegin:
+ .ualong .LcleanupSTART-.LSTARTCODE
+ .ualong .LcleanupEND-.LcleanupSTART
+ .ualong __condvar_w_cleanup-.LSTARTCODE
+ .uleb128 0
+ .ualong .LcallUR-.LSTARTCODE
+ .ualong .LENDCODE-.LcallUR
+ .ualong 0
+ .uleb128 0
+.Lcstend:
+
+ .section .eh_frame,"a",@progbits
+.LSTARTFRAME:
+ .ualong .LENDCIE-.LSTARTCIE ! Length of the CIE.
+.LSTARTCIE:
+ .ualong 0 ! CIE ID.
+ .byte 1 ! Version number.
+#ifdef SHARED
+ .string "zPLR" ! NUL-terminated augmentation
+ ! string.
+#else
+ .string "zPL" ! NUL-terminated augmentation
+ ! string.
+#endif
+ .uleb128 1 ! Code alignment factor.
+ .sleb128 -4 ! Data alignment factor.
+ .byte 0x11 ! Return address register
+ ! column.
+#ifdef SHARED
+ .uleb128 7 ! Augmentation value length.
+ .byte 0x9b ! Personality: DW_EH_PE_pcrel
+ ! + DW_EH_PE_sdata4
+ ! + DW_EH_PE_indirect
+ .ualong DW.ref.__gcc_personality_v0-.
+ .byte 0x1b ! LSDA Encoding: DW_EH_PE_pcrel
+ ! + DW_EH_PE_sdata4.
+ .byte 0x1b ! FDE Encoding: DW_EH_PE_pcrel
+ ! + DW_EH_PE_sdata4.
+#else
+ .uleb128 6 ! Augmentation value length.
+ .byte 0x0 ! Personality: absolute
+ .ualong __gcc_personality_v0
+ .byte 0x0 ! LSDA Encoding: absolute
+#endif
+ .byte 0x0c ! DW_CFA_def_cfa
+ .uleb128 0xf
+ .uleb128 0
+ .align 2
+.LENDCIE:
+
+ .ualong .LENDFDE-.LSTARTFDE ! Length of the FDE.
+.LSTARTFDE:
+ .ualong .LSTARTFDE-.LSTARTFRAME ! CIE pointer.
+#ifdef SHARED
+ .ualong .LSTARTCODE-. ! PC-relative start address
+ ! of the code.
+#else
+ .ualong .LSTARTCODE ! Start address of the code.
+#endif
+ .ualong .LENDCODE-.LSTARTCODE ! Length of the code.
+ .uleb128 4 ! Augmentation size
+#ifdef SHARED
+ .ualong .LexceptSTART-.
+#else
+ .ualong .LexceptSTART
+#endif
+ .byte 0x4
+ .ualong .Lpush_r8-.LSTARTCODE
+ .byte 0xe
+ .uleb128 4
+ .byte 0x88
+ .uleb128 1
+ .byte 0x4
+ .ualong .Lpush_r9-.Lpush_r8
+ .byte 0xe
+ .uleb128 8
+ .byte 0x89
+ .uleb128 2
+ .byte 0x4
+ .ualong .Lpush_r10-.Lpush_r9
+ .byte 0xe
+ .uleb128 12
+ .byte 0x8a
+ .uleb128 3
+ .byte 0x4
+ .ualong .Lpush_r11-.Lpush_r10
+ .byte 0xe
+ .uleb128 16
+ .byte 0x8b
+ .uleb128 4
+ .byte 0x4
+ .ualong .Lpush_r12-.Lpush_r11
+ .byte 0xe
+ .uleb128 20
+ .byte 0x8c
+ .uleb128 5
+ .byte 0x4
+ .ualong .Lpush_pr-.Lpush_r12
+ .byte 0xe
+ .uleb128 24
+ .byte 0x91
+ .uleb128 6
+ .byte 0x4
+ .ualong .Lalloc-.Lpush_pr
+ .byte 0xe
+ .uleb128 72
+ .align 2
+.LENDFDE:
+
+#ifdef SHARED
+ .hidden DW.ref.__gcc_personality_v0
+ .weak DW.ref.__gcc_personality_v0
+ .section .gnu.linkonce.d.DW.ref.__gcc_personality_v0,"aw",@progbits
+ .align 4
+ .type DW.ref.__gcc_personality_v0, @object
+ .size DW.ref.__gcc_personality_v0, 4
+DW.ref.__gcc_personality_v0:
+ .long __gcc_personality_v0
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_once.S b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_once.S
new file mode 100644
index 000000000..b03173d82
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_once.S
@@ -0,0 +1,262 @@
+/* Copyright (C) 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
+ 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 <unwindbuf.h>
+#include <sysdep.h>
+#include <bits/kernel-features.h>
+#include <lowlevellock.h>
+#include <tcb-offsets.h>
+#include "lowlevel-atomic.h"
+
+
+ .comm __fork_generation, 4, 4
+
+ .text
+ .globl __pthread_once
+ .type __pthread_once,@function
+ .protected __pthread_once
+ .align 5
+ cfi_startproc
+__pthread_once:
+ mov.l @r4, r0
+ tst #2, r0
+ bt 1f
+ rts
+ mov #0, r0
+
+1:
+ mov.l r12, @-r15
+ cfi_adjust_cfa_offset (4)
+ cfi_rel_offset (r12, 0)
+ mov.l r9, @-r15
+ cfi_adjust_cfa_offset (4)
+ cfi_rel_offset (r9, 0)
+ mov.l r8, @-r15
+ cfi_adjust_cfa_offset (4)
+ cfi_rel_offset (r8, 0)
+ sts.l pr, @-r15
+ cfi_adjust_cfa_offset (4)
+ cfi_rel_offset (pr, 0)
+ mov r5, r8
+ mov r4, r9
+
+ /* Not yet initialized or initialization in progress.
+ Get the fork generation counter now. */
+6:
+ mov.l @r4, r1
+ mova .Lgot, r0
+ mov.l .Lgot, r12
+ add r0, r12
+
+5:
+ mov r1, r0
+
+ tst #2, r0
+ bf 4f
+
+ and #3, r0
+ mov.l .Lfgen, r2
+#ifdef __PIC__
+ add r12, r2
+#endif
+ mov.l @r2, r3
+ or r3, r0
+ or #1, r0
+ mov r0, r3
+ mov r1, r5
+
+ CMPXCHG (r5, @r4, r3, r2)
+ bf 5b
+
+ /* Check whether another thread already runs the initializer. */
+ mov r2, r0
+ tst #1, r0
+ bt 3f /* No -> do it. */
+
+ /* Check whether the initializer execution was interrupted
+ by a fork. */
+ xor r3, r0
+ mov #-4, r1 /* -4 = 0xfffffffc */
+ tst r1, r0
+ bf 3f /* Different for generation -> run initializer. */
+
+ /* Somebody else got here first. Wait. */
+#ifdef __ASSUME_PRIVATE_FUTEX
+ mov #(FUTEX_PRIVATE_FLAG|FUTEX_WAIT), r5
+ extu.b r5, r5
+#else
+ stc gbr, r1
+ mov.w .Lpfoff, r2
+ add r2, r1
+ mov.l @r1, r5
+# if FUTEX_WAIT != 0
+ mov #FUTEX_WAIT, r0
+ or r0, r5
+# endif
+#endif
+ mov r3, r6
+ mov #0, r7
+ mov #SYS_futex, r3
+ extu.b r3, r3
+ trapa #0x14
+ SYSCALL_INST_PAD
+ bra 6b
+ nop
+
+ .align 2
+.Lgot:
+ .long _GLOBAL_OFFSET_TABLE_
+#ifdef __PIC__
+.Lfgen:
+ .long __fork_generation@GOTOFF
+#else
+.Lfgen:
+ .long __fork_generation
+#endif
+
+3:
+ /* Call the initializer function after setting up the
+ cancellation handler. Note that it is not possible here
+ to use the unwind-based cleanup handling. This would require
+ that the user-provided function and all the code it calls
+ is compiled with exceptions. Unfortunately this cannot be
+ guaranteed. */
+ add #-UNWINDBUFSIZE, r15
+ cfi_adjust_cfa_offset (UNWINDBUFSIZE)
+
+ mov.l .Lsigsetjmp, r1
+ mov #UWJMPBUF, r4
+ add r15, r4
+ bsrf r1
+ mov #0, r5
+.Lsigsetjmp0:
+ tst r0, r0
+ bf 7f
+
+ mov.l .Lcpush, r1
+ bsrf r1
+ mov r15, r4
+.Lcpush0:
+
+ /* Call the user-provided initialization function. */
+ jsr @r8
+ nop
+
+ /* Pop the cleanup handler. */
+ mov.l .Lcpop, r1
+ bsrf r1
+ mov r15, r4
+.Lcpop0:
+
+ add #UNWINDBUFSIZE, r15
+ cfi_adjust_cfa_offset (-UNWINDBUFSIZE)
+
+ /* Sucessful run of the initializer. Signal that we are done. */
+ INC (@r9, r2)
+ /* Wake up all other threads. */
+ mov r9, r4
+#ifdef __ASSUME_PRIVATE_FUTEX
+ mov #(FUTEX_PRIVATE_FLAG|FUTEX_WAKE), r5
+ extu.b r5, r5
+#else
+ stc gbr, r1
+ mov.w .Lpfoff, r2
+ add r2, r1
+ mov.l @r1, r5
+ mov #FUTEX_WAKE, r0
+ or r0, r5
+#endif
+ mov #-1, r6
+ shlr r6 /* r6 = 0x7fffffff */
+ mov #0, r7
+ mov #SYS_futex, r3
+ extu.b r3, r3
+ trapa #0x14
+ SYSCALL_INST_PAD
+
+4:
+ lds.l @r15+, pr
+ cfi_adjust_cfa_offset (-4)
+ cfi_restore (pr)
+ mov.l @r15+, r8
+ cfi_adjust_cfa_offset (-4)
+ cfi_restore (r8)
+ mov.l @r15+, r9
+ cfi_adjust_cfa_offset (-4)
+ cfi_restore (r9)
+ mov.l @r15+, r12
+ cfi_adjust_cfa_offset (-4)
+ cfi_restore (r12)
+ rts
+ mov #0, r0
+
+7:
+ /* __sigsetjmp returned for the second time. */
+ cfi_adjust_cfa_offset (UNWINDBUFSIZE+16)
+ cfi_offset (r12, -4)
+ cfi_offset (r9, -8)
+ cfi_offset (r8, -12)
+ cfi_offset (pr, -16)
+ mov #0, r7
+ mov.l r7, @r9
+ mov r9, r4
+#ifdef __ASSUME_PRIVATE_FUTEX
+ mov #(FUTEX_PRIVATE_FLAG|FUTEX_WAKE), r5
+#else
+ stc gbr, r1
+ mov.w .Lpfoff, r2
+ add r2, r1
+ mov.l @r1, r5
+ mov #FUTEX_WAKE, r0
+ or r0, r5
+#endif
+ extu.b r5, r5
+ mov #-1, r6
+ shlr r6 /* r6 = 0x7fffffff */
+ mov #SYS_futex, r3
+ extu.b r3, r3
+ trapa #0x14
+ SYSCALL_INST_PAD
+
+ mov.l .Lunext, r1
+ bsrf r1
+ mov r15, r4
+.Lunext0:
+ /* NOTREACHED */
+ sleep
+ cfi_endproc
+
+#ifndef __ASSUME_PRIVATE_FUTEX
+.Lpfoff:
+ .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE
+#endif
+ .align 2
+.Lsigsetjmp:
+ .long __sigsetjmp@PLT-(.Lsigsetjmp0-.)
+.Lcpush:
+ .long HIDDEN_JUMPTARGET(__pthread_register_cancel)-.Lcpush0
+.Lcpop:
+ .long HIDDEN_JUMPTARGET(__pthread_unregister_cancel)-.Lcpop0
+.Lunext:
+ .long HIDDEN_JUMPTARGET(__pthread_unwind_next)-.Lunext0
+ .size __pthread_once,.-__pthread_once
+
+ .globl __pthread_once_internal
+__pthread_once_internal = __pthread_once
+
+ .globl pthread_once
+pthread_once = __pthread_once
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_rdlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_rdlock.S
new file mode 100644
index 000000000..f1efab181
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_rdlock.S
@@ -0,0 +1,254 @@
+/* Copyright (C) 2003, 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 <sysdep.h>
+#include <lowlevellock.h>
+#include <lowlevelrwlock.h>
+#include <pthread-errnos.h>
+#include <tcb-offsets.h>
+#include <bits/kernel-features.h>
+#include "lowlevel-atomic.h"
+
+
+ .text
+
+ .globl __pthread_rwlock_rdlock
+ .type __pthread_rwlock_rdlock,@function
+ .protected __pthread_rwlock_rdlock
+ .align 5
+__pthread_rwlock_rdlock:
+ mov.l r12, @-r15
+ mov.l r9, @-r15
+ mov.l r8, @-r15
+ sts.l pr, @-r15
+ mov r4, r8
+
+ /* Get the lock. */
+ mov #0, r3
+ mov #1, r4
+#if MUTEX == 0
+ CMPXCHG (r3, @r8, r4, r2)
+#else
+ CMPXCHG (r3, @(MUTEX,r8), r4, r2)
+#endif
+ bf 1f
+2:
+ mov.l @(WRITER,r8), r0
+ tst r0, r0
+ bf 14f
+ mov.l @(WRITERS_QUEUED,r8), r0
+ tst r0, r0
+ bt 5f
+ mov #FLAGS, r0
+ mov.b @(r0,r8), r0
+ tst r0, r0
+ bt 5f
+3:
+ mov.l @(READERS_QUEUED,r8), r0
+ add #1, r0
+ mov.l r0, @(READERS_QUEUED,r8)
+ tst r0, r0
+ bt 4f
+
+ mov.l @(READERS_WAKEUP,r8), r9
+
+#if MUTEX == 0
+ DEC (@r8, r2)
+#else
+ DEC (@(MUTEX,r8), r2)
+#endif
+ tst r2, r2
+ bf 10f
+11:
+#ifdef __ASSUME_PRIVATE_FUTEX
+ mov #PSHARED, r0
+ mov.b @(r0,r8), r5
+ mov #(FUTEX_PRIVATE_FLAG|FUTEX_WAIT), r0
+ xor r0, r5
+ extu.b r5, r5
+#else
+ mov #PSHARED, r0
+ mov.b @(r0,r8), r5
+ extu.b r5, r5
+# if FUTEX_WAIT != 0
+ mov #FUTEX_WAIT, r0
+ or r0, r5
+# endif
+ stc gbr, r1
+ mov.w .Lpfoff, r2
+ add r2, r1
+ mov.l @r1, r0
+ xor r0, r5
+#endif
+ mov r8, r4
+ add #READERS_WAKEUP, r4
+ mov r9, r6
+ mov #0, r7
+ mov #SYS_futex, r3
+ extu.b r3, r3
+ trapa #0x14
+ SYSCALL_INST_PAD
+
+ /* Reget the lock. */
+ mov #0, r3
+ mov #1, r4
+#if MUTEX == 0
+ CMPXCHG (r3, @r8, r4, r2)
+#else
+ CMPXCHG (r3, @(MUTEX,r8), r4, r2)
+#endif
+ bf 12f
+13:
+ mov.l @(READERS_QUEUED,r8), r0
+ add #-1, r0
+ bra 2b
+ mov.l r0, @(READERS_QUEUED,r8)
+
+5:
+ mov #0, r3
+ mov.l @(NR_READERS,r8), r0
+ add #1, r0
+ mov.l r0, @(NR_READERS,r8)
+ tst r0, r0
+ bt 8f
+
+9:
+#if MUTEX == 0
+ DEC (@r8, r2)
+#else
+ DEC (@(MUTEX,r8), r2)
+#endif
+ tst r2, r2
+ bf 6f
+7:
+ lds.l @r15+, pr
+ mov.l @r15+, r8
+ mov.l @r15+, r9
+ mov.l @r15+, r12
+ rts
+ mov r3, r0
+
+#ifndef __ASSUME_PRIVATE_FUTEX
+.Lpfoff:
+ .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE
+#endif
+
+1:
+ mov r8, r5
+#if MUTEX != 0
+ add #MUTEX, r5
+#endif
+ mov #PSHARED, r0
+ mov.b @(r0,r8), r6
+ extu.b r6, r6
+ mov.l .Lwait0, r1
+ bsrf r1
+ mov r2, r4
+.Lwait0b:
+ bra 2b
+ nop
+14:
+ stc gbr, r1
+ mov.w .Ltidoff, r2
+ add r2, r1
+ mov.l @r1, r1
+ cmp/eq r1, r0
+ bf 3b
+ /* Deadlock detected. */
+ bra 9b
+ mov #EDEADLK, r3
+
+.Ltidoff:
+ .word TID - TLS_PRE_TCB_SIZE
+
+6:
+ mov r8, r4
+#if MUTEX != 0
+ add #MUTEX, r4
+#endif
+ mov #PSHARED, r0
+ mov.b @(r0,r8), r5
+ extu.b r5, r5
+ mov.l .Lwake0, r1
+ bsrf r1
+ nop
+.Lwake0b:
+ bra 7b
+ mov #0, r3
+
+8:
+ /* Overflow. */
+ mov.l @(NR_READERS,r8), r1
+ add #-1, r1
+ mov.l r1, @(NR_READERS,r8)
+ bra 9b
+ mov #EAGAIN, r3
+
+4:
+ /* Overflow. */
+ mov.l @(READERS_QUEUED,r8), r1
+ add #-1, r1
+ mov.l r1, @(READERS_QUEUED,r8)
+ bra 9b
+ mov #EAGAIN, r3
+
+10:
+ mov r8, r4
+#if MUTEX != 0
+ add #MUTEX, r4
+#endif
+ mov #PSHARED, r0
+ mov.b @(r0,r8), r5
+ extu.b r5, r5
+ mov.l .Lwake1, r1
+ bsrf r1
+ nop
+.Lwake1b:
+ bra 11b
+ nop
+
+12:
+ mov r8, r5
+#if MUTEX != 0
+ add #MUTEX, r5
+#endif
+ mov #PSHARED, r0
+ mov.b @(r0,r8), r6
+ extu.b r6, r6
+ mov.l .Lwait1, r1
+ bsrf r1
+ mov r2, r4
+.Lwait1b:
+ bra 13b
+ nop
+
+ .align 2
+.Lwait0:
+ .long __lll_lock_wait-.Lwait0b
+.Lwake0:
+ .long __lll_unlock_wake-.Lwake0b
+.Lwait1:
+ .long __lll_lock_wait-.Lwait1b
+.Lwake1:
+ .long __lll_unlock_wake-.Lwake1b
+ .size __pthread_rwlock_rdlock,.-__pthread_rwlock_rdlock
+
+ .globl pthread_rwlock_rdlock
+pthread_rwlock_rdlock = __pthread_rwlock_rdlock
+
+ .globl __pthread_rwlock_rdlock_internal
+__pthread_rwlock_rdlock_internal = __pthread_rwlock_rdlock
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedrdlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedrdlock.S
new file mode 100644
index 000000000..122e6199d
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedrdlock.S
@@ -0,0 +1,313 @@
+/* Copyright (C) 2003, 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
+ 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 <lowlevellock.h>
+#include <lowlevelrwlock.h>
+#include <pthread-errnos.h>
+#include <tcb-offsets.h>
+#include <bits/kernel-features.h>
+#include "lowlevel-atomic.h"
+
+
+ .text
+
+ .globl pthread_rwlock_timedrdlock
+ .type pthread_rwlock_timedrdlock,@function
+ .align 5
+pthread_rwlock_timedrdlock:
+ mov.l r12, @-r15
+ mov.l r10, @-r15
+ mov.l r9, @-r15
+ mov.l r8, @-r15
+ sts.l pr, @-r15
+ add #-8, r15
+ mov r4, r8
+ mov r5, r9
+
+ /* Get the lock. */
+ mov #0, r3
+ mov #1, r4
+#if MUTEX == 0
+ CMPXCHG (r3, @r8, r4, r2)
+#else
+ CMPXCHG (r3, @(MUTEX,r8), r4, r2)
+#endif
+ bf 1f
+2:
+ mov.l @(WRITER,r8), r0
+ tst r0, r0
+ bf 14f
+ mov.l @(WRITERS_QUEUED,r8), r0
+ tst r0, r0
+ bt 5f
+ mov #FLAGS, r0
+ mov.b @(r0,r8), r0
+ tst r0, r0
+ bt 5f
+3:
+ /* Check the value of the timeout parameter. */
+ mov.l .L1g0, r1
+ mov.l @(4,r9), r0
+ cmp/hs r1, r0
+ bt 19f
+
+ mov.l @(READERS_QUEUED,r8), r0
+ add #1, r0
+ mov.l r0, @(READERS_QUEUED,r8)
+ tst r0, r0
+ bt 4f
+
+ mov.l @(READERS_WAKEUP,r8), r10
+
+#if MUTEX == 0
+ DEC (@r8, r2)
+#else
+ DEC (@(MUTEX,r8), r2)
+#endif
+ tst r2, r2
+ bf 10f
+
+11:
+ /* Get current time. */
+ mov r15, r4
+ mov #0, r5
+ mov #__NR_gettimeofday, r3
+ trapa #0x12
+ SYSCALL_INST_PAD
+
+ mov.l @(4,r15), r0
+ mov.w .L1k0, r1
+ dmulu.l r0, r1 /* Milli seconds to nano seconds. */
+ mov.l @r9, r2
+ mov.l @(4,r9), r3
+ mov.l @r15, r0
+ sts macl, r1
+ sub r0, r2
+ clrt
+ subc r1, r3
+ bf 15f
+ mov.l .L1g0, r1
+ add r1, r3
+ add #-1, r2
+15:
+ cmp/pz r2
+ bf 16f /* Time is already up. */
+
+ /* Store relative timeout. */
+ mov.l r2, @r15
+ mov.l r3, @(4,r15)
+
+ /* Futex call. */
+ mov r15, r7
+#ifdef __ASSUME_PRIVATE_FUTEX
+ mov #PSHARED, r0
+ mov.b @(r0,r8), r5
+ mov #(FUTEX_PRIVATE_FLAG|FUTEX_WAIT), r0
+ xor r0, r5
+ extu.b r5, r5
+#else
+ mov #PSHARED, r0
+ mov.b @(r0,r8), r5
+ extu.b r5, r5
+# if FUTEX_WAIT != 0
+ mov #FUTEX_WAIT, r0
+ or r0, r5
+# endif
+ stc gbr, r1
+ mov.w .Lpfoff, r2
+ add r2, r1
+ mov.l @r1, r0
+ xor r0, r5
+#endif
+ mov r10, r6
+ mov r8, r4
+ add #READERS_WAKEUP, r4
+ mov #SYS_futex, r3
+ extu.b r3, r3
+ trapa #0x14
+ SYSCALL_INST_PAD
+ mov r0, r3
+
+17:
+ /* Reget the lock. */
+ mov #0, r5
+ mov #1, r4
+#if MUTEX == 0
+ CMPXCHG (r5, @r8, r4, r2)
+#else
+ CMPXCHG (r5, @(MUTEX,r8), r4, r2)
+#endif
+ bf 12f
+
+13:
+ mov.l @(READERS_QUEUED,r8), r0
+ add #-1, r0
+ mov.l r0, @(READERS_QUEUED,r8)
+ mov #-ETIMEDOUT, r0
+ cmp/eq r0, r3
+ bf 2b
+
+18:
+ bra 9f
+ mov #ETIMEDOUT, r3
+
+5:
+ mov #0, r3
+ mov.l @(NR_READERS,r8), r0
+ add #1, r0
+ mov.l r0, @(NR_READERS,r8)
+ tst r0, r0
+ bt 8f
+
+9:
+#if MUTEX == 0
+ DEC (@r8, r2)
+#else
+ DEC (@(MUTEX,r8), r2)
+#endif
+ tst r2, r2
+ bf 6f
+7:
+ add #8,r15
+ lds.l @r15+, pr
+ mov.l @r15+, r8
+ mov.l @r15+, r9
+ mov.l @r15+, r10
+ mov.l @r15+, r12
+ rts
+ mov r3, r0
+
+#ifndef __ASSUME_PRIVATE_FUTEX
+.Lpfoff:
+ .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE
+#endif
+ .align 2
+.L1k0:
+ .long 1000
+.L1g0:
+ .long 1000000000
+
+1:
+ mov r8, r5
+#if MUTEX != 0
+ add #MUTEX, r5
+#endif
+ mov #PSHARED, r0
+ mov.b @(r0,r8), r6
+ extu.b r6, r6
+ mov.l .Lwait2, r1
+ bsrf r1
+ mov r2, r4
+.Lwait2b:
+ bra 2b
+ nop
+14:
+ stc gbr, r1
+ mov.w .Ltidoff, r2
+ add r2, r1
+ mov.l @r1, r1
+ cmp/eq r1, r0
+ bf 3b
+ /* Deadlock detected. */
+ bra 9b
+ mov #EDEADLK, r3
+
+.Ltidoff:
+ .word TID - TLS_PRE_TCB_SIZE
+
+6:
+ mov r3, r10
+ mov r8, r4
+#if MUTEX != 0
+ add #MUTEX, r4
+#endif
+ mov #PSHARED, r0
+ mov.b @(r0,r8), r5
+ extu.b r5, r5
+ mov.l .Lwake2, r1
+ bsrf r1
+ nop
+.Lwake2b:
+ bra 7b
+ mov r10, r3
+
+8:
+ /* Overflow. */
+ mov.l @(NR_READERS,r8), r1
+ add #-1, r1
+ mov.l r1, @(NR_READERS,r8)
+ bra 9b
+ mov #EAGAIN, r3
+
+4:
+ /* Overflow. */
+ mov.l @(READERS_QUEUED,r8), r1
+ add #-1, r1
+ mov.l r1, @(READERS_QUEUED,r8)
+ bra 9b
+ mov #EAGAIN, r3
+
+10:
+ mov r8, r4
+#if MUTEX != 0
+ add #MUTEX, r4
+#endif
+ mov #PSHARED, r0
+ mov.b @(r0,r8), r5
+ extu.b r5, r5
+ mov.l .Lwake3, r1
+ bsrf r1
+ nop
+.Lwake3b:
+ bra 11b
+ nop
+
+12:
+ mov r3, r10
+ mov r8, r5
+#if MUTEX != 0
+ add #MUTEX, r5
+#endif
+ mov #PSHARED, r0
+ mov.b @(r0,r8), r6
+ extu.b r6, r6
+ mov.l .Lwait3, r1
+ bsrf r1
+ mov r2, r4
+.Lwait3b:
+ bra 13b
+ mov r10, r3
+
+16:
+ bra 17b
+ mov #-ETIMEDOUT, r3
+
+19:
+ bra 9b
+ mov #EINVAL, r3
+
+ .align 2
+.Lwait2:
+ .long __lll_lock_wait-.Lwait2b
+.Lwake2:
+ .long __lll_unlock_wake-.Lwake2b
+.Lwait3:
+ .long __lll_lock_wait-.Lwait3b
+.Lwake3:
+ .long __lll_unlock_wake-.Lwake3b
+ .size pthread_rwlock_timedrdlock,.-pthread_rwlock_timedrdlock
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedwrlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedwrlock.S
new file mode 100644
index 000000000..174165d14
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedwrlock.S
@@ -0,0 +1,297 @@
+/* Copyright (C) 2003, 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
+ 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 <lowlevellock.h>
+#include <lowlevelrwlock.h>
+#include <pthread-errnos.h>
+#include <tcb-offsets.h>
+#include <bits/kernel-features.h>
+#include "lowlevel-atomic.h"
+
+
+ .text
+
+ .globl pthread_rwlock_timedwrlock
+ .type pthread_rwlock_timedwrlock,@function
+ .align 5
+pthread_rwlock_timedwrlock:
+ mov.l r12, @-r15
+ mov.l r10, @-r15
+ mov.l r9, @-r15
+ mov.l r8, @-r15
+ sts.l pr, @-r15
+ add #-8, r15
+ mov r4, r8
+ mov r5, r9
+
+ /* Get the lock. */
+ mov #0, r3
+ mov #1, r4
+#if MUTEX == 0
+ CMPXCHG (r3, @r8, r4, r2)
+#else
+ CMPXCHG (r3, @(MUTEX,r8), r4, r2)
+#endif
+ bf 1f
+2:
+ mov.l @(WRITER,r8), r0
+ tst r0, r0
+ bf 14f
+ mov.l @(NR_READERS,r8), r0
+ tst r0, r0
+ bt 5f
+3:
+ /* Check the value of the timeout parameter. */
+ mov.l .L1g1, r1
+ mov.l @(4,r9), r0
+ cmp/hs r1, r0
+ bt 19f
+
+ mov.l @(WRITERS_QUEUED,r8), r0
+ add #1, r0
+ mov.l r0, @(WRITERS_QUEUED,r8)
+ tst r0, r0
+ bt 4f
+
+ mov.l @(WRITERS_WAKEUP,r8), r10
+
+#if MUTEX == 0
+ DEC (@r8, r2)
+#else
+ DEC (@(MUTEX,r8), r2)
+#endif
+ tst r2, r2
+ bf 10f
+
+11:
+ /* Get current time. */
+ mov r15, r4
+ mov #0, r5
+ mov #__NR_gettimeofday, r3
+ trapa #0x12
+ SYSCALL_INST_PAD
+
+ mov.l @(4,r15), r0
+ mov.w .L1k1, r1
+ dmulu.l r0, r1 /* Milli seconds to nano seconds. */
+ mov.l @r9, r2
+ mov.l @(4,r9), r3
+ mov.l @r15, r0
+ sts macl, r1
+ sub r0, r2
+ clrt
+ subc r1, r3
+ bf 15f
+ mov.l .L1g1, r1
+ add r1, r3
+ add #-1, r2
+15:
+ cmp/pz r2
+ bf 16f /* Time is already up. */
+
+ /* Store relative timeout. */
+ mov.l r2, @r15
+ mov.l r3, @(4,r15)
+
+ /* Futex call. */
+ mov r15, r7
+#ifdef __ASSUME_PRIVATE_FUTEX
+ mov #PSHARED, r0
+ mov.b @(r0,r8), r5
+ mov #(FUTEX_PRIVATE_FLAG|FUTEX_WAIT), r0
+ xor r0, r5
+ extu.b r5, r5
+#else
+ mov #PSHARED, r0
+ mov.b @(r0,r8), r5
+ extu.b r5, r5
+# if FUTEX_WAIT != 0
+ mov #FUTEX_WAIT, r0
+ or r0, r5
+# endif
+ stc gbr, r1
+ mov.w .Lpfoff, r2
+ add r2, r1
+ mov.l @r1, r0
+ xor r0, r5
+#endif
+ mov r10, r6
+ mov r8, r4
+ add #WRITERS_WAKEUP, r4
+ mov #SYS_futex, r3
+ extu.b r3, r3
+ trapa #0x14
+ SYSCALL_INST_PAD
+ mov r0, r3
+
+17:
+ /* Reget the lock. */
+ mov #0, r5
+ mov #1, r4
+#if MUTEX == 0
+ CMPXCHG (r5, @r8, r4, r2)
+#else
+ CMPXCHG (r5, @(MUTEX,r8), r4, r2)
+#endif
+ bf 12f
+
+13:
+ mov.l @(WRITERS_QUEUED,r8), r0
+ add #-1, r0
+ mov.l r0, @(WRITERS_QUEUED,r8)
+ mov #-ETIMEDOUT, r0
+ cmp/eq r0, r3
+ bf 2b
+
+18:
+ bra 9f
+ mov #ETIMEDOUT, r3
+
+19:
+ bra 9f
+ mov #EINVAL, r3
+
+5:
+ mov #0, r3
+ stc gbr, r0
+ mov.w .Ltidoff, r1
+ mov.l @(r0,r1), r0
+ mov.l r0, @(WRITER,r8)
+9:
+#if MUTEX == 0
+ DEC (@r8, r2)
+#else
+ DEC (@(MUTEX,r8), r2)
+#endif
+ tst r2, r2
+ bf 6f
+7:
+ add #8,r15
+ lds.l @r15+, pr
+ mov.l @r15+, r8
+ mov.l @r15+, r9
+ mov.l @r15+, r10
+ mov.l @r15+, r12
+ rts
+ mov r3, r0
+
+#ifndef __ASSUME_PRIVATE_FUTEX
+.Lpfoff:
+ .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE
+#endif
+.L1k1:
+ .word 1000
+ .align 2
+.L1g1:
+ .long 1000000000
+
+1:
+ mov r8, r5
+#if MUTEX != 0
+ add #MUTEX, r5
+#endif
+ mov #PSHARED, r0
+ mov.b @(r0,r8), r6
+ extu.b r6, r6
+ mov.l .Lwait6, r1
+ bsrf r1
+ mov r2, r4
+.Lwait6b:
+ bra 2b
+ nop
+14:
+ stc gbr, r1
+ mov.w .Ltidoff, r2
+ add r2, r1
+ mov.l @r1, r1
+ cmp/eq r1, r0
+ bf 3b
+ bra 9b
+ mov #EDEADLK, r3
+6:
+ mov r3, r10
+ mov r8, r4
+#if MUTEX != 0
+ add #MUTEX, r4
+#endif
+ mov #PSHARED, r0
+ mov.b @(r0,r8), r5
+ extu.b r5, r5
+ mov.l .Lwake6, r1
+ bsrf r1
+ nop
+.Lwake6b:
+ bra 7b
+ mov r10, r3
+
+.Ltidoff:
+ .word TID - TLS_PRE_TCB_SIZE
+
+4:
+ /* Overflow. */
+ mov.l @(WRITERS_QUEUED,r8), r1
+ add #-1, r1
+ mov.l r1, @(WRITERS_QUEUED,r8)
+ bra 9b
+ mov #EAGAIN, r3
+
+10:
+ mov r8, r4
+#if MUTEX != 0
+ add #MUTEX, r4
+#endif
+ mov #PSHARED, r0
+ mov.b @(r0,r8), r5
+ extu.b r5, r5
+ mov.l .Lwake7, r1
+ bsrf r1
+ nop
+.Lwake7b:
+ bra 11b
+ nop
+
+12:
+ mov r3, r10
+ mov r8, r5
+#if MUTEX != 0
+ add #MUTEX, r5
+#endif
+ mov #PSHARED, r0
+ mov.b @(r0,r8), r6
+ extu.b r6, r6
+ mov.l .Lwait7, r1
+ bsrf r1
+ mov r2, r4
+.Lwait7b:
+ bra 13b
+ mov r10, r3
+
+16:
+ bra 17b
+ mov #-ETIMEDOUT, r3
+
+ .align 2
+.Lwait6:
+ .long __lll_lock_wait-.Lwait6b
+.Lwake6:
+ .long __lll_unlock_wake-.Lwake6b
+.Lwait7:
+ .long __lll_lock_wait-.Lwait7b
+.Lwake7:
+ .long __lll_unlock_wake-.Lwake7b
+ .size pthread_rwlock_timedwrlock,.-pthread_rwlock_timedwrlock
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_unlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_unlock.S
new file mode 100644
index 000000000..ad492aad9
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_unlock.S
@@ -0,0 +1,198 @@
+/* Copyright (C) 2003, 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 <sysdep.h>
+#include <lowlevellock.h>
+#include <lowlevelrwlock.h>
+#include <bits/kernel-features.h>
+#include <tcb-offsets.h>
+#include "lowlevel-atomic.h"
+
+
+ .text
+
+ .globl __pthread_rwlock_unlock
+ .type __pthread_rwlock_unlock,@function
+ .protected __pthread_rwlock_unlock
+ .align 5
+__pthread_rwlock_unlock:
+ mov.l r12, @-r15
+ mov.l r8, @-r15
+ sts.l pr, @-r15
+ mov r4, r8
+
+ /* Get the lock. */
+ mov #0, r3
+ mov #1, r4
+#if MUTEX == 0
+ CMPXCHG (r3, @r8, r4, r2)
+#else
+ CMPXCHG (r3, @(MUTEX,r8), r4, r2)
+#endif
+ bf 1f
+2:
+ mov.l @(WRITER,r8), r0
+ tst r0, r0
+ bf 5f
+ mov.l @(NR_READERS,r8), r0
+ add #-1, r0
+ mov.l r0, @(NR_READERS,r8)
+ tst r0, r0
+ bf 6f
+5:
+ mov #0, r0
+ mov.l r0, @(WRITER,r8)
+ mov #1, r6
+ mov r8, r4
+ add #WRITERS_WAKEUP, r4
+ mov.l @(WRITERS_QUEUED,r8), r0
+ tst r0, r0
+ bf 0f
+
+ /* If also no readers waiting nothing to do. */
+ mov.l @(READERS_QUEUED,r8), r0
+ tst r0, r0
+ bt 6f
+
+ mov #-1, r6
+ shlr r6 /* r6 = 0x7fffffff */
+ mov r8, r4
+ add #READERS_WAKEUP, r4
+
+0:
+ mov.l @r4, r0
+ add #1, r0
+ mov.l r0, @r4
+#if MUTEX == 0
+ DEC (@r8, r2)
+#else
+ DEC (@(MUTEX,r8), r2)
+#endif
+ tst r2, r2
+ bf 7f
+
+8:
+#ifdef __ASSUME_PRIVATE_FUTEX
+ mov #PSHARED, r0
+ mov.b @(r0,r8), r5
+ mov #(FUTEX_PRIVATE_FLAG|FUTEX_WAKE), r0
+ xor r0, r5
+ extu.b r5, r5
+#else
+ mov #PSHARED, r0
+ mov.b @(r0,r8), r5
+ extu.b r5, r5
+ mov #FUTEX_WAKE, r0
+ or r0, r5
+ stc gbr, r1
+ mov.w .Lpfoff, r2
+ add r2, r1
+ mov.l @r1, r0
+ xor r0, r5
+#endif
+ mov #SYS_futex, r3
+ mov #0, r7
+ extu.b r3, r3
+ trapa #0x14
+ SYSCALL_INST_PAD
+
+ lds.l @r15+, pr
+ mov.l @r15+, r8
+ mov.l @r15+, r12
+ rts
+ mov #0, r0
+6:
+#if MUTEX == 0
+ DEC (@r8, r2)
+#else
+ DEC (@(MUTEX,r8), r2)
+#endif
+ tst r2, r2
+ bf 3f
+4:
+ lds.l @r15+, pr
+ mov.l @r15+, r8
+ mov.l @r15+, r12
+ rts
+ mov #0, r0
+
+1:
+ mov r8, r5
+#if MUTEX != 0
+ add #MUTEX, r5
+#endif
+ mov #PSHARED, r0
+ mov.b @(r0,r8), r6
+ extu.b r6, r6
+ mov.l .Lwait8, r1
+ bsrf r1
+ mov r2, r4
+.Lwait8b:
+ bra 2b
+ nop
+3:
+ mov r8, r4
+#if MUTEX != 0
+ add #MUTEX, r4
+#endif
+ mov #PSHARED, r0
+ mov.b @(r0,r8), r5
+ extu.b r5, r5
+ mov.l .Lwake8, r1
+ bsrf r1
+ nop
+.Lwake8b:
+ bra 4b
+ nop
+
+7:
+ mov.l r4, @-r15
+ mov.l r6, @-r15
+ mov r8, r4
+#if MUTEX != 0
+ add #MUTEX, r4
+#endif
+ mov #PSHARED, r0
+ mov.b @(r0,r8), r5
+ extu.b r5, r5
+ mov.l .Lwake9, r1
+ bsrf r1
+ nop
+.Lwake9b:
+
+ mov.l @r15+, r6
+ bra 8b
+ mov.l @r15+, r4
+
+#ifndef __ASSUME_PRIVATE_FUTEX
+.Lpfoff:
+ .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE
+#endif
+ .align 2
+.Lwait8:
+ .long __lll_lock_wait-.Lwait8b
+.Lwake8:
+ .long __lll_unlock_wake-.Lwake8b
+.Lwake9:
+ .long __lll_unlock_wake-.Lwake9b
+ .size __pthread_rwlock_unlock,.-__pthread_rwlock_unlock
+
+ .globl pthread_rwlock_unlock
+pthread_rwlock_unlock = __pthread_rwlock_unlock
+
+ .globl __pthread_rwlock_unlock_internal
+__pthread_rwlock_unlock_internal = __pthread_rwlock_unlock
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_wrlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_wrlock.S
new file mode 100644
index 000000000..ee28fcea9
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_wrlock.S
@@ -0,0 +1,234 @@
+/* Copyright (C) 2003, 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 <sysdep.h>
+#include <lowlevellock.h>
+#include <lowlevelrwlock.h>
+#include <pthread-errnos.h>
+#include <tcb-offsets.h>
+#include <bits/kernel-features.h>
+#include "lowlevel-atomic.h"
+
+
+ .text
+
+ .globl __pthread_rwlock_wrlock
+ .type __pthread_rwlock_wrlock,@function
+ .protected __pthread_rwlock_wrlock
+ .align 5
+__pthread_rwlock_wrlock:
+ mov.l r12, @-r15
+ mov.l r9, @-r15
+ mov.l r8, @-r15
+ sts.l pr, @-r15
+ mov r4, r8
+
+ /* Get the lock. */
+ mov #0, r3
+ mov #1, r4
+#if MUTEX == 0
+ CMPXCHG (r3, @r8, r4, r2)
+#else
+ CMPXCHG (r3, @(MUTEX,r8), r4, r2)
+#endif
+ bf 1f
+2:
+ mov.l @(WRITER,r8), r0
+ tst r0, r0
+ bf 14f
+ mov.l @(NR_READERS,r8), r0
+ tst r0, r0
+ bt 5f
+3:
+ mov.l @(WRITERS_QUEUED,r8), r0
+ add #1, r0
+ mov.l r0, @(WRITERS_QUEUED,r8)
+ tst r0, r0
+ bt 4f
+
+ mov.l @(WRITERS_WAKEUP,r8), r9
+
+#if MUTEX == 0
+ DEC (@r8, r2)
+#else
+ DEC (@(MUTEX,r8), r2)
+#endif
+ tst r2, r2
+ bf 10f
+11:
+ mov r8, r4
+ add #WRITERS_WAKEUP, r4
+#ifdef __ASSUME_PRIVATE_FUTEX
+ mov #PSHARED, r0
+ mov.b @(r0,r8), r5
+ mov #(FUTEX_PRIVATE_FLAG|FUTEX_WAIT), r0
+ xor r0, r5
+ extu.b r5, r5
+#else
+ mov #PSHARED, r0
+ mov.b @(r0,r8), r5
+ extu.b r5, r5
+# if FUTEX_WAIT != 0
+ mov #FUTEX_WAIT, r0
+ or r0, r5
+# endif
+ stc gbr, r1
+ mov.w .Lpfoff, r2
+ add r2, r1
+ mov.l @r1, r0
+ xor r0, r5
+#endif
+ mov r9, r6
+ mov #0, r7
+ mov #SYS_futex, r3
+ extu.b r3, r3
+ trapa #0x14
+ SYSCALL_INST_PAD
+
+ /* Reget the lock. */
+ mov #0, r3
+ mov #1, r4
+#if MUTEX == 0
+ CMPXCHG (r3, @r8, r4, r2)
+#else
+ CMPXCHG (r3, @(MUTEX,r8), r4, r2)
+#endif
+ bf 12f
+13:
+ mov.l @(WRITERS_QUEUED,r8), r0
+ add #-1, r0
+ bra 2b
+ mov.l r0, @(WRITERS_QUEUED,r8)
+
+5:
+ mov #0, r3
+ stc gbr, r0
+ mov.w .Ltidoff, r1
+ mov.l @(r0,r1), r0
+ mov.l r0, @(WRITER,r8)
+9:
+#if MUTEX == 0
+ DEC (@r8, r2)
+#else
+ DEC (@(MUTEX,r8), r2)
+#endif
+ tst r2, r2
+ bf 6f
+7:
+ lds.l @r15+, pr
+ mov.l @r15+, r8
+ mov.l @r15+, r9
+ mov.l @r15+, r12
+ rts
+ mov r3, r0
+
+1:
+ mov r8, r5
+#if MUTEX != 0
+ add #MUTEX, r5
+#endif
+ mov #PSHARED, r0
+ mov.b @(r0,r8), r6
+ extu.b r6, r6
+ mov.l .Lwait4, r1
+ bsrf r1
+ mov r2, r4
+.Lwait4b:
+ bra 2b
+ nop
+14:
+ stc gbr, r1
+ mov.w .Ltidoff, r2
+ add r2, r1
+ mov.l @r1, r1
+ cmp/eq r1, r0
+ bf 3b
+ bra 9b
+ mov #EDEADLK, r3
+6:
+ mov r8, r4
+#if MUTEX != 0
+ add #MUTEX, r4
+#endif
+ mov #PSHARED, r0
+ mov.b @(r0,r8), r5
+ extu.b r5, r5
+ mov.l .Lwake4, r1
+ bsrf r1
+ nop
+.Lwake4b:
+ bra 7b
+ mov #0, r3
+
+#ifndef __ASSUME_PRIVATE_FUTEX
+.Lpfoff:
+ .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE
+#endif
+.Ltidoff:
+ .word TID - TLS_PRE_TCB_SIZE
+
+4:
+ mov.l @(WRITERS_QUEUED,r8), r1
+ add #-1, r1
+ mov.l r1, @(WRITERS_QUEUED,r8)
+ bra 9b
+ mov #EAGAIN, r3
+
+10:
+ mov r8, r4
+#if MUTEX != 0
+ add #MUTEX, r4
+#endif
+ mov #PSHARED, r0
+ mov.b @(r0,r8), r5
+ extu.b r5, r5
+ mov.l .Lwake5, r1
+ bsrf r1
+ nop
+.Lwake5b:
+ bra 11b
+ nop
+
+12:
+ mov r8, r5
+#if MUTEX != 0
+ add #MUTEX, r5
+#endif
+ mov #PSHARED, r0
+ mov.b @(r0,r8), r6
+ extu.b r6, r6
+ mov.l .Lwait5, r1
+ bsrf r1
+ mov r2, r4
+.Lwait5b:
+ bra 13b
+ nop
+
+ .align 2
+.Lwait4:
+ .long __lll_lock_wait-.Lwait4b
+.Lwake4:
+ .long __lll_unlock_wake-.Lwake4b
+.Lwait5:
+ .long __lll_lock_wait-.Lwait5b
+.Lwake5:
+ .long __lll_unlock_wake-.Lwake5b
+ .globl pthread_rwlock_wrlock
+pthread_rwlock_wrlock = __pthread_rwlock_wrlock
+
+ .globl __pthread_rwlock_wrlock_internal
+__pthread_rwlock_wrlock_internal = __pthread_rwlock_wrlock
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/sem_post.S b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/sem_post.S
new file mode 100644
index 000000000..290209b7b
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/sem_post.S
@@ -0,0 +1,108 @@
+/* Copyright (C) 2003, 2004, 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
+ 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 <pthread-errnos.h>
+#include <structsem.h>
+#include <lowlevellock.h>
+#include "lowlevel-atomic.h"
+
+
+ .text
+
+ .globl sem_post
+ .type sem_post,@function
+ .align 5
+sem_post:
+ mov.l @(VALUE,r4), r2
+0:
+ mov.l .Lmax, r1
+ cmp/eq r1, r2
+ bt/s 3f
+ mov r2, r3
+ mov r3, r5
+ add #1, r5
+ CMPXCHG (r3, @(VALUE,r4), r5, r2)
+ bf 0b
+ mov.l @(NWAITERS,r4), r2
+ tst r2, r2
+ bt 2f
+ mov #FUTEX_WAKE, r5
+ mov.l @(PRIVATE,r4), r1
+ or r1, r5
+ mov #1, r6
+ mov #0, r7
+ mov #SYS_futex, r3
+ extu.b r3, r3
+ trapa #0x14
+ SYSCALL_INST_PAD
+
+ cmp/pz r0
+ bf 1f
+2:
+ rts
+ mov #0, r0
+
+1:
+ bra 4f
+ mov #EINVAL, r2
+
+3:
+ mov #EOVERFLOW, r2
+4:
+ mov.l r12, @-r15
+ mov.l r8, @-r15
+ sts.l pr, @-r15
+ mova .Lgot3, r0
+ mov.l .Lgot3, r12
+ add r0, r12
+
+#if USE___THREAD
+ mov.l .Lerrno3, r0
+ stc gbr, r1
+ mov.l @(r0, r12), r0
+ bra .Lexit
+ add r1, r0
+ .align 2
+.Lerrno3:
+ .long errno@GOTTPOFF
+.Lexit:
+ mov.l r2, @r0
+#else
+ mov r2, r8
+ mov.l .Lerrloc3, r1
+ bsrf r1
+ nop
+.Lerrloc3b:
+ mov r8, @r0
+#endif
+ lds.l @r15+, pr
+ mov.l @r15+, r8
+ mov.l @r15+, r12
+ rts
+ mov #-1, r0
+
+ .align 2
+.Lmax:
+ .long SEM_VALUE_MAX
+.Lgot3:
+ .long _GLOBAL_OFFSET_TABLE_
+#if !USE___THREAD
+.Lerrloc3:
+ .long __errno_location@PLT-(.Lerrloc3b-.)
+#endif
+ .size sem_post,.-sem_post
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/sem_timedwait.S b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/sem_timedwait.S
new file mode 100644
index 000000000..f8e801306
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/sem_timedwait.S
@@ -0,0 +1,357 @@
+/* Copyright (C) 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
+ 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 <pthread-errnos.h>
+#include <tcb-offsets.h>
+#include <structsem.h>
+#include <lowlevellock.h>
+#include "lowlevel-atomic.h"
+
+
+#if VALUE != 0
+# error "code needs to be rewritten for VALUE != 0"
+#endif
+
+ .text
+
+ .globl sem_timedwait
+ .type sem_timedwait,@function
+ .align 5
+sem_timedwait:
+.LSTARTCODE:
+ mov.l @r4, r0
+2:
+ tst r0, r0
+ bt 1f
+ mov r0, r3
+ mov r0, r6
+ add #-1, r3
+ CMPXCHG (r6, @r4, r3, r2)
+ bf/s 2b
+ mov r2, r0
+ rts
+ mov #0, r0
+
+1:
+ /* Check whether the timeout value is valid. */
+ mov.l r8, @-r15
+.Lpush_r8:
+ mov.l r9, @-r15
+.Lpush_r9:
+ mov.l r10, @-r15
+.Lpush_r10:
+ mov.l r12, @-r15
+.Lpush_r12:
+ sts.l pr, @-r15
+.Lpush_pr:
+ add #-8, r15
+.Lalloc:
+ mov r4, r8
+ mov r5, r9
+
+ /* Check for invalid nanosecond field. */
+ mov.l @(4,r9), r0
+ mov.l .L1g, r1
+ cmp/hs r1, r0
+ bt/s 6f
+ mov #EINVAL, r0
+ INC (@(NWAITERS,r8),r2)
+
+7:
+ /* Compute relative timeout. */
+ mov r15, r4
+ mov #0, r5
+ mov #__NR_gettimeofday, r3
+ trapa #0x12
+ SYSCALL_INST_PAD
+
+ mov.l @(4,r15), r0
+ mov.w .L1k, r1
+ dmulu.l r0, r1 /* Milli seconds to nano seconds. */
+ mov.l @r9, r2
+ mov.l @(4,r9), r3
+ mov.l @r15, r0
+ sts macl, r1
+ sub r0, r2
+ clrt
+ subc r1, r3
+ bf 5f
+ mov.l .L1g, r1
+ add r1, r3
+ add #-1, r2
+5:
+ cmp/pz r2
+ bf/s 6f /* Time is already up. */
+ mov #ETIMEDOUT, r0
+
+ /* Store relative timeout. */
+ mov.l r2, @r15
+ mov.l r3, @(4,r15)
+
+.LcleanupSTART:
+ mov.l .Lenable0, r1
+ bsrf r1
+ nop
+.Lenable0b:
+ mov r0, r10
+
+ mov r8, r4
+#if FUTEX_WAIT == 0
+ mov.l @(PRIVATE,r8), r5
+#else
+ mov.l @(PRIVATE,r8), r5
+ mov #FUTEX_WAIT, r0
+ or r0, r5
+#endif
+ mov #0, r6
+ mov r15, r7
+ mov #SYS_futex, r3
+ extu.b r3, r3
+ trapa #0x14
+ SYSCALL_INST_PAD
+
+ mov.l .Ldisable0, r1
+ mov r10, r4
+ bsrf r1
+ mov r0, r10
+.Ldisable0b:
+ mov r10, r0
+.LcleanupEND:
+
+ tst r0, r0
+ bt 9f
+ cmp/eq #-EWOULDBLOCK, r0
+ bf 3f
+9:
+ mov.l @r8, r0
+8:
+ tst r0, r0
+ bt 7b
+
+ mov r0, r3
+ mov r0, r4
+ add #-1, r3
+ CMPXCHG (r4, @r8, r3, r2)
+ bf/s 8b
+ mov r2, r0
+
+ DEC (@(NWAITERS,r8), r2)
+ mov #0, r0
+
+10:
+ add #8, r15
+ lds.l @r15+, pr
+ mov.l @r15+, r12
+ mov.l @r15+, r10
+ mov.l @r15+, r9
+ mov.l @r15+, r8
+ rts
+ nop
+
+3:
+ neg r0, r0
+6:
+ mov r0, r10
+ mova .Lgot2, r0
+ mov.l .Lgot2, r12
+ add r0, r12
+
+#if USE___THREAD
+ mov.l .Lerrno2, r0
+ stc gbr, r1
+ mov.l @(r0, r12), r0
+ bra .Lexit
+ add r1, r0
+ .align 2
+.Lerrno2:
+ .long errno@GOTTPOFF
+.Lexit:
+#else
+ mov.l .Lerrloc2, r1
+ bsrf r1
+ nop
+.Lerrloc2b:
+#endif
+ mov.l r10, @r0
+ DEC (@(NWAITERS,r8), r2)
+ bra 10b
+ mov #-1, r0
+
+.L1k:
+ .word 1000
+ .align 2
+.L1g:
+ .long 1000000000
+.Lgot2:
+ .long _GLOBAL_OFFSET_TABLE_
+#if !USE___THREAD
+.Lerrloc2:
+ .long __errno_location@PLT-(.Lerrloc2b-.)
+#endif
+.Lenable0:
+ .long __pthread_enable_asynccancel-.Lenable0b
+.Ldisable0:
+ .long __pthread_disable_asynccancel-.Ldisable0b
+ .size sem_timedwait,.-sem_timedwait
+
+ .type sem_wait_cleanup,@function
+sem_wait_cleanup:
+ DEC (@(NWAITERS,r8), r2)
+.LcallUR:
+ mov.l .Lresume, r1
+#ifdef __PIC__
+ add r12, r1
+#endif
+ jsr @r1
+ nop
+ sleep
+
+ .align 2
+.Lresume:
+#ifdef __PIC__
+ .long _Unwind_Resume@GOTOFF
+#else
+ .long _Unwind_Resume
+#endif
+.LENDCODE:
+ .size sem_wait_cleanup,.-sem_wait_cleanup
+
+
+ .section .gcc_except_table,"a",@progbits
+.LexceptSTART:
+ .byte 0xff ! @LPStart format (omit)
+ .byte 0xff ! @TType format (omit)
+ .byte 0x01 ! call-site format
+ ! DW_EH_PE_uleb128
+ .uleb128 .Lcstend-.Lcstbegin
+.Lcstbegin:
+ .uleb128 .LcleanupSTART-.LSTARTCODE
+ .uleb128 .LcleanupEND-.LcleanupSTART
+ .uleb128 sem_wait_cleanup-.LSTARTCODE
+ .uleb128 0
+ .uleb128 .LcallUR-.LSTARTCODE
+ .uleb128 .LENDCODE-.LcallUR
+ .uleb128 0
+ .uleb128 0
+.Lcstend:
+
+
+ .section .eh_frame,"a",@progbits
+.LSTARTFRAME:
+ .ualong .LENDCIE-.LSTARTCIE ! Length of the CIE.
+.LSTARTCIE:
+ .ualong 0 ! CIE ID.
+ .byte 1 ! Version number.
+#ifdef SHARED
+ .string "zPLR" ! NUL-terminated augmentation
+ ! string.
+#else
+ .string "zPL" ! NUL-terminated augmentation
+ ! string.
+#endif
+ .uleb128 1 ! Code alignment factor.
+ .sleb128 -4 ! Data alignment factor.
+ .byte 0x11 ! Return address register
+ ! column.
+#ifdef SHARED
+ .uleb128 7 ! Augmentation value length.
+ .byte 0x9b ! Personality: DW_EH_PE_pcrel
+ ! + DW_EH_PE_sdata4
+ ! + DW_EH_PE_indirect
+ .ualong DW.ref.__gcc_personality_v0-.
+ .byte 0x1b ! LSDA Encoding: DW_EH_PE_pcrel
+ ! + DW_EH_PE_sdata4.
+ .byte 0x1b ! FDE Encoding: DW_EH_PE_pcrel
+ ! + DW_EH_PE_sdata4.
+#else
+ .uleb128 6 ! Augmentation value length.
+ .byte 0x0 ! Personality: absolute
+ .ualong __gcc_personality_v0
+ .byte 0x0 ! LSDA Encoding: absolute
+#endif
+ .byte 0x0c ! DW_CFA_def_cfa
+ .uleb128 0xf
+ .uleb128 0
+ .align 4
+.LENDCIE:
+
+ .ualong .LENDFDE-.LSTARTFDE ! Length of the FDE.
+.LSTARTFDE:
+ .ualong .LSTARTFDE-.LSTARTFRAME ! CIE pointer.
+#ifdef SHARED
+ .ualong .LSTARTCODE-. ! PC-relative start address
+ ! of the code.
+#else
+ .ualong .LSTARTCODE ! Start address of the code.
+#endif
+ .ualong .LENDCODE-.LSTARTCODE ! Length of the code.
+ .uleb128 4 ! Augmentation size
+#ifdef SHARED
+ .ualong .LexceptSTART-.
+#else
+ .ualong .LexceptSTART
+#endif
+
+ .byte 4 ! DW_CFA_advance_loc4
+ .ualong .Lpush_r8-.LSTARTCODE
+ .byte 14 ! DW_CFA_def_cfa_offset
+ .uleb128 4
+ .byte 0x88 ! DW_CFA_offset r8
+ .uleb128 1
+ .byte 4 ! DW_CFA_advance_loc4
+ .ualong .Lpush_r9-.Lpush_r8
+ .byte 14 ! DW_CFA_def_cfa_offset
+ .uleb128 8
+ .byte 0x89 ! DW_CFA_offset r9
+ .uleb128 2
+ .byte 4 ! DW_CFA_advance_loc4
+ .ualong .Lpush_r10-.Lpush_r9
+ .byte 14 ! DW_CFA_def_cfa_offset
+ .uleb128 12
+ .byte 0x8a ! DW_CFA_offset r10
+ .uleb128 3
+ .byte 4 ! DW_CFA_advance_loc4
+ .ualong .Lpush_r12-.Lpush_r10
+ .byte 14 ! DW_CFA_def_cfa_offset
+ .uleb128 16
+ .byte 0x8c ! DW_CFA_offset r12
+ .uleb128 4
+ .byte 4 ! DW_CFA_advance_loc4
+ .ualong .Lpush_pr-.Lpush_r12
+ .byte 14 ! DW_CFA_def_cfa_offset
+ .uleb128 20
+ .byte 0x91 ! DW_CFA_offset pr
+ .uleb128 5
+ .byte 4 ! DW_CFA_advance_loc4
+ .ualong .Lalloc-.Lpush_pr
+ .byte 14 ! DW_CFA_def_cfa_offset
+ .uleb128 28
+ .align 4
+.LENDFDE:
+
+
+#ifdef SHARED
+ .hidden DW.ref.__gcc_personality_v0
+ .weak DW.ref.__gcc_personality_v0
+ .section .gnu.linkonce.d.DW.ref.__gcc_personality_v0,"aw",@progbits
+ .align 4
+ .type DW.ref.__gcc_personality_v0, @object
+ .size DW.ref.__gcc_personality_v0, 4
+DW.ref.__gcc_personality_v0:
+ .long __gcc_personality_v0
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/sem_trywait.S b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/sem_trywait.S
new file mode 100644
index 000000000..8e84f2589
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/sem_trywait.S
@@ -0,0 +1,88 @@
+/* Copyright (C) 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
+ 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 <pthread-errnos.h>
+#include <lowlevellock.h>
+#include "lowlevel-atomic.h"
+
+
+ .text
+
+ .globl sem_trywait
+ .type sem_trywait,@function
+ .align 5
+sem_trywait:
+ mov.l r12, @-r15
+ mov.l r8, @-r15
+ sts.l pr, @-r15
+ mov r4, r8
+ mov.l @r8, r0
+2:
+ tst r0, r0
+ bt 1f
+
+ mov r0, r3
+ mov r0, r4
+ add #-1, r3
+ CMPXCHG (r4, @r8, r3, r2)
+ bf/s 2b
+ mov r2, r0
+
+ lds.l @r15+, pr
+ mov.l @r15+, r8
+ mov.l @r15+, r12
+ rts
+ mov #0, r0
+
+1:
+ mov #EAGAIN, r8
+ mova .Lgot1, r0
+ mov.l .Lgot1, r12
+ add r0, r12
+
+#if USE___THREAD
+ mov.l .Lerrno1, r0
+ stc gbr, r1
+ mov.l @(r0, r12), r0
+ bra .Lexit
+ add r1, r0
+ .align 2
+.Lerrno1:
+ .long errno@GOTTPOFF
+.Lexit:
+#else
+ mov.l .Lerrloc1, r1
+ bsrf r1
+ nop
+.Lerrloc1b:
+#endif
+ mov.l r8, @r0
+ lds.l @r15+, pr
+ mov.l @r15+, r8
+ mov.l @r15+, r12
+ rts
+ mov #-1, r0
+
+ .align 2
+.Lgot1:
+ .long _GLOBAL_OFFSET_TABLE_
+#if !USE___THREAD
+.Lerrloc1:
+ .long __errno_location@PLT-(.Lerrloc1b-.)
+#endif
+ .size sem_trywait,.-sem_trywait
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/sem_wait.S b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/sem_wait.S
new file mode 100644
index 000000000..b8c25092a
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/sem_wait.S
@@ -0,0 +1,301 @@
+/* Copyright (C) 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
+ 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 <pthread-errnos.h>
+#include <tcb-offsets.h>
+#include <structsem.h>
+#include <lowlevellock.h>
+#include "lowlevel-atomic.h"
+
+
+#if VALUE != 0
+# error "code needs to be rewritten for VALUE != 0"
+#endif
+
+ .text
+
+ .globl sem_wait
+ .type sem_wait,@function
+ .align 5
+sem_wait:
+.LSTARTCODE:
+ mov.l r8, @-r15
+.Lpush_r8:
+ mov.l r10, @-r15
+.Lpush_r10:
+ mov.l r12, @-r15
+.Lpush_r12:
+ sts.l pr, @-r15
+.Lpush_pr:
+ mov r4, r8
+
+ mov.l @r8, r0
+2:
+ tst r0, r0
+ bt 1f
+ mov r0, r3
+ mov r0, r4
+ add #-1, r3
+ CMPXCHG (r4, @r8, r3, r2)
+ bf/s 2b
+ mov r2, r0
+7:
+ mov #0, r0
+9:
+ lds.l @r15+, pr
+ mov.l @r15+, r12
+ mov.l @r15+, r10
+ rts
+ mov.l @r15+, r8
+
+.Lafter_ret:
+1:
+ INC (@(NWAITERS,r8),r2)
+
+.LcleanupSTART:
+6:
+ mov.l .Lenable0, r1
+ bsrf r1
+ nop
+.Lenable0b:
+ mov r0, r10
+
+ mov r8, r4
+#if FUTEX_WAIT == 0
+ mov.l @(PRIVATE,r8), r5
+#else
+ mov.l @(PRIVATE,r8), r5
+ mov #FUTEX_WAIT, r0
+ or r0, r5
+#endif
+ mov #0, r6
+ mov #0, r7
+ mov #SYS_futex, r3
+ extu.b r3, r3
+ trapa #0x14
+ SYSCALL_INST_PAD
+
+ mov.l .Ldisable0, r1
+ mov r10, r4
+ bsrf r1
+ mov r0, r10
+.Ldisable0b:
+ mov r10, r0
+.LcleanupEND:
+
+ tst r0, r0
+ bt 3f
+ cmp/eq #-EWOULDBLOCK, r0
+ bf 4f
+
+3:
+ mov.l @r8, r0
+5:
+ tst r0, r0
+ bt 6b
+
+ mov r0, r3
+ mov r0, r4
+ add #-1, r3
+ CMPXCHG (r4, @r8, r3, r2)
+ bf/s 5b
+ mov r2, r0
+
+ DEC (@(NWAITERS,r8), r2)
+ bra 7b
+ nop
+
+4:
+ neg r0, r0
+ mov r0, r4
+ DEC (@(NWAITERS,r8), r2)
+ mov r4, r8
+ mova .Lgot0, r0
+ mov.l .Lgot0, r12
+ add r0, r12
+
+#if USE___THREAD
+ mov.l .Lerrno0, r0
+ stc gbr, r1
+ mov.l @(r0, r12), r0
+ bra .Lexit
+ add r1, r0
+ .align 2
+.Lerrno0:
+ .long errno@GOTTPOFF
+.Lexit:
+#else
+ mov.l .Lerrloc0, r1
+ bsrf r1
+ nop
+.Lerrloc0b:
+#endif
+ mov.l r8, @r0
+ bra 9b
+ mov #-1, r0
+
+ .align 2
+.Lgot0:
+ .long _GLOBAL_OFFSET_TABLE_
+#if !USE___THREAD
+.Lerrloc0:
+ .long __errno_location@PLT-(.Lerrloc0b-.)
+#endif
+.Lenable0:
+ .long __pthread_enable_asynccancel-.Lenable0b
+.Ldisable0:
+ .long __pthread_disable_asynccancel-.Ldisable0b
+ .size sem_wait,.-sem_wait
+
+
+ .type sem_wait_cleanup,@function
+sem_wait_cleanup:
+ DEC (@(NWAITERS,r8), r2)
+.LcallUR:
+ mov.l .Lresume, r1
+#ifdef __PIC__
+ add r12, r1
+#endif
+ jsr @r1
+ nop
+ sleep
+
+ .align 2
+.Lresume:
+#ifdef __PIC__
+ .long _Unwind_Resume@GOTOFF
+#else
+ .long _Unwind_Resume
+#endif
+.LENDCODE:
+ .size sem_wait_cleanup,.-sem_wait_cleanup
+
+
+ .section .gcc_except_table,"a",@progbits
+.LexceptSTART:
+ .byte 0xff ! @LPStart format (omit)
+ .byte 0xff ! @TType format (omit)
+ .byte 0x01 ! call-site format
+ ! DW_EH_PE_uleb128
+ .uleb128 .Lcstend-.Lcstbegin
+.Lcstbegin:
+ .uleb128 .LcleanupSTART-.LSTARTCODE
+ .uleb128 .LcleanupEND-.LcleanupSTART
+ .uleb128 sem_wait_cleanup-.LSTARTCODE
+ .uleb128 0
+ .uleb128 .LcallUR-.LSTARTCODE
+ .uleb128 .LENDCODE-.LcallUR
+ .uleb128 0
+ .uleb128 0
+.Lcstend:
+
+
+ .section .eh_frame,"a",@progbits
+.LSTARTFRAME:
+ .ualong .LENDCIE-.LSTARTCIE ! Length of the CIE.
+.LSTARTCIE:
+ .ualong 0 ! CIE ID.
+ .byte 1 ! Version number.
+#ifdef SHARED
+ .string "zPLR" ! NUL-terminated augmentation
+ ! string.
+#else
+ .string "zPL" ! NUL-terminated augmentation
+ ! string.
+#endif
+ .uleb128 1 ! Code alignment factor.
+ .sleb128 -4 ! Data alignment factor.
+ .byte 0x11 ! Return address register
+ ! column.
+#ifdef SHARED
+ .uleb128 7 ! Augmentation value length.
+ .byte 0x9b ! Personality: DW_EH_PE_pcrel
+ ! + DW_EH_PE_sdata4
+ ! + DW_EH_PE_indirect
+ .ualong DW.ref.__gcc_personality_v0-.
+ .byte 0x1b ! LSDA Encoding: DW_EH_PE_pcrel
+ ! + DW_EH_PE_sdata4.
+ .byte 0x1b ! FDE Encoding: DW_EH_PE_pcrel
+ ! + DW_EH_PE_sdata4.
+#else
+ .uleb128 6 ! Augmentation value length.
+ .byte 0x0 ! Personality: absolute
+ .ualong __gcc_personality_v0
+ .byte 0x0 ! LSDA Encoding: absolute
+#endif
+ .byte 0x0c ! DW_CFA_def_cfa
+ .uleb128 0xf
+ .uleb128 0
+ .align 4
+.LENDCIE:
+
+ .ualong .LENDFDE-.LSTARTFDE ! Length of the FDE.
+.LSTARTFDE:
+ .ualong .LSTARTFDE-.LSTARTFRAME ! CIE pointer.
+#ifdef SHARED
+ .ualong .LSTARTCODE-. ! PC-relative start address
+ ! of the code.
+#else
+ .ualong .LSTARTCODE ! Start address of the code.
+#endif
+ .ualong .LENDCODE-.LSTARTCODE ! Length of the code.
+ .uleb128 4 ! Augmentation size
+#ifdef SHARED
+ .ualong .LexceptSTART-.
+#else
+ .ualong .LexceptSTART
+#endif
+
+ .byte 4 ! DW_CFA_advance_loc4
+ .ualong .Lpush_r8-.LSTARTCODE
+ .byte 14 ! DW_CFA_def_cfa_offset
+ .uleb128 4
+ .byte 0x88 ! DW_CFA_offset r8
+ .uleb128 1
+ .byte 4 ! DW_CFA_advance_loc4
+ .ualong .Lpush_r10-.Lpush_r8
+ .byte 14 ! DW_CFA_def_cfa_offset
+ .uleb128 8
+ .byte 0x8a ! DW_CFA_offset r10
+ .uleb128 2
+ .byte 4 ! DW_CFA_advance_loc4
+ .ualong .Lpush_r12-.Lpush_r10
+ .byte 14 ! DW_CFA_def_cfa_offset
+ .uleb128 12
+ .byte 0x8c ! DW_CFA_offset r12
+ .uleb128 3
+ .byte 4 ! DW_CFA_advance_loc4
+ .ualong .Lpush_pr-.Lpush_r12
+ .byte 14 ! DW_CFA_def_cfa_offset
+ .uleb128 16
+ .byte 0x91 ! DW_CFA_offset pr
+ .uleb128 4
+ .align 4
+.LENDFDE:
+
+
+#ifdef SHARED
+ .hidden DW.ref.__gcc_personality_v0
+ .weak DW.ref.__gcc_personality_v0
+ .section .gnu.linkonce.d.DW.ref.__gcc_personality_v0,"aw",@progbits
+ .align 4
+ .type DW.ref.__gcc_personality_v0, @object
+ .size DW.ref.__gcc_personality_v0, 4
+DW.ref.__gcc_personality_v0:
+ .long __gcc_personality_v0
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/sh4/lowlevellock.h b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/sh4/lowlevellock.h
new file mode 100644
index 000000000..8cdcac556
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/sh4/lowlevellock.h
@@ -0,0 +1,4 @@
+/* 4 instruction cycles not accessing cache and TLB are needed after
+ trapa instruction to avoid an SH-4 silicon bug. */
+#define NEED_SYSCALL_INST_PAD
+#include <sysdeps/unix/sysv/linux/sh/lowlevellock.h>
diff --git a/libc/sysdeps/linux/vax/bits/wordsize.h b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/smp.h
index 62dad0c71..b0504db5f 100644
--- a/libc/sysdeps/linux/vax/bits/wordsize.h
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/smp.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1999 Free Software Foundation, Inc.
+/* Determine whether the host has multiple processors. SH version.
+ Copyright (C) 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
@@ -13,7 +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/>. */
-#define __WORDSIZE 32
+static inline int
+is_smp_system (void)
+{
+ return 0;
+}
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h
new file mode 100644
index 000000000..f64c24f90
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h
@@ -0,0 +1,168 @@
+/* Copyright (C) 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/>. */
+
+#include <tls.h>
+#include <sysdep.h>
+#ifndef __ASSEMBLER__
+# include <pthreadP.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+# define _IMM12 #-12
+# define _IMM16 #-16
+# define _IMP16 #16
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .text; \
+ ENTRY (name); \
+ .Lpseudo_start: \
+ SINGLE_THREAD_P; \
+ bf .Lpseudo_cancel; \
+ .type __##syscall_name##_nocancel,@function; \
+ .globl __##syscall_name##_nocancel; \
+ __##syscall_name##_nocancel: \
+ DO_CALL (syscall_name, args); \
+ mov r0,r1; \
+ mov _IMM12,r2; \
+ shad r2,r1; \
+ not r1,r1; \
+ tst r1,r1; \
+ bt .Lsyscall_error; \
+ bra .Lpseudo_end; \
+ nop; \
+ .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
+ .Lpseudo_cancel: \
+ sts.l pr,@-r15; \
+ cfi_adjust_cfa_offset (4); \
+ cfi_rel_offset (pr, 0); \
+ add _IMM16,r15; \
+ cfi_adjust_cfa_offset (16); \
+ SAVE_ARGS_##args; \
+ CENABLE; \
+ LOAD_ARGS_##args; \
+ add _IMP16,r15; \
+ cfi_adjust_cfa_offset (-16); \
+ lds.l @r15+,pr; \
+ cfi_adjust_cfa_offset (-4); \
+ cfi_restore (pr); \
+ DO_CALL(syscall_name, args); \
+ SYSCALL_INST_PAD; \
+ sts.l pr,@-r15; \
+ cfi_adjust_cfa_offset (4); \
+ cfi_rel_offset (pr, 0); \
+ mov.l r0,@-r15; \
+ cfi_adjust_cfa_offset (4); \
+ cfi_rel_offset (r0, 0); \
+ CDISABLE; \
+ mov.l @r15+,r0; \
+ cfi_adjust_cfa_offset (-4); \
+ lds.l @r15+,pr; \
+ cfi_adjust_cfa_offset (-4); \
+ cfi_restore (pr); \
+ mov r0,r1; \
+ mov _IMM12,r2; \
+ shad r2,r1; \
+ not r1,r1; \
+ tst r1,r1; \
+ bf .Lpseudo_end; \
+ .Lsyscall_error: \
+ SYSCALL_ERROR_HANDLER; \
+ .Lpseudo_end:
+
+# undef PSEUDO_END
+# define PSEUDO_END(sym) \
+ END (sym)
+
+# define SAVE_ARGS_0 /* Nothing. */
+# define SAVE_ARGS_1 SAVE_ARGS_0; mov.l r4,@(0,r15); cfi_offset (r4,-4)
+# define SAVE_ARGS_2 SAVE_ARGS_1; mov.l r5,@(4,r15); cfi_offset (r5,-8)
+# define SAVE_ARGS_3 SAVE_ARGS_2; mov.l r6,@(8,r15); cfi_offset (r6,-12)
+# define SAVE_ARGS_4 SAVE_ARGS_3; mov.l r7,@(12,r15); cfi_offset (r7,-16)
+# define SAVE_ARGS_5 SAVE_ARGS_4
+# define SAVE_ARGS_6 SAVE_ARGS_5
+
+# define LOAD_ARGS_0 /* Nothing. */
+# define LOAD_ARGS_1 LOAD_ARGS_0; mov.l @(0,r15),r4
+# define LOAD_ARGS_2 LOAD_ARGS_1; mov.l @(4,r15),r5
+# define LOAD_ARGS_3 LOAD_ARGS_2; mov.l @(8,r15),r6
+# define LOAD_ARGS_4 LOAD_ARGS_3; mov.l @(12,r15),r7
+# define LOAD_ARGS_5 LOAD_ARGS_4
+# define LOAD_ARGS_6 LOAD_ARGS_5
+
+# ifdef IS_IN_libpthread
+# define __local_enable_asynccancel __pthread_enable_asynccancel
+# define __local_disable_asynccancel __pthread_disable_asynccancel
+# elif !defined NOT_IN_libc
+# define __local_enable_asynccancel __libc_enable_asynccancel
+# define __local_disable_asynccancel __libc_disable_asynccancel
+# elif defined IS_IN_librt
+# define __local_enable_asynccancel __librt_enable_asynccancel
+# define __local_disable_asynccancel __librt_disable_asynccancel
+# else
+# error Unsupported library
+# endif
+
+# define CENABLE \
+ mov.l 1f,r0; \
+ bsrf r0; \
+ nop; \
+ 0: bra 2f; \
+ mov r0,r2; \
+ .align 2; \
+ 1: .long __local_enable_asynccancel - 0b; \
+ 2:
+
+# define CDISABLE \
+ mov.l 1f,r0; \
+ bsrf r0; \
+ mov r2,r4; \
+ 0: bra 2f; \
+ nop; \
+ .align 2; \
+ 1: .long __local_disable_asynccancel - 0b; \
+ 2:
+
+# ifndef __ASSEMBLER__
+# define SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+# else
+# define SINGLE_THREAD_P \
+ stc gbr,r0; \
+ mov.w 0f,r1; \
+ sub r1,r0; \
+ mov.l @(MULTIPLE_THREADS_OFFSET,r0),r0; \
+ bra 1f; \
+ tst r0,r0; \
+ 0: .word TLS_PRE_TCB_SIZE; \
+ 1:
+
+# endif
+
+#elif !defined __ASSEMBLER__
+
+# define SINGLE_THREAD_P (1)
+# define NO_CANCELLATION 1
+
+#endif
+
+#ifndef __ASSEMBLER__
+# define RTLD_SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/vfork.S
new file mode 100644
index 000000000..5ea1bc120
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/vfork.S
@@ -0,0 +1,70 @@
+/* Copyright (C) 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/>. */
+
+#include <sysdep.h>
+#define _ERRNO_H 1
+#include <bits/errno.h>
+#include <tcb-offsets.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. */
+
+ENTRY (__vfork)
+ /* Save the PID value. */
+ stc gbr, r2
+ mov.w .L2, r0
+ mov.l @(r0,r2), r4
+ neg r4, r1
+ tst r1, r1
+ bf 1f
+ mov #1, r1
+ rotr r1
+1:
+ mov.l r1, @(r0,r2)
+
+ mov.w .L1, r3
+ trapa #0x10
+ mov r0, r1
+
+ /* Restore the old PID value in the parent. */
+ tst r0, r0
+ bt.s 2f
+ stc gbr, r2
+ mov.w .L2, r0
+ mov.l r4, @(r0,r2)
+ mov r1, r0
+2:
+ mov #-12, r2
+ shad r2, r1
+ not r1, r1 // r1=0 means r0 = -1 to -4095
+ tst r1, r1 // i.e. error in linux
+ bf .Lpseudo_end
+ SYSCALL_ERROR_HANDLER
+.Lpseudo_end:
+ rts
+ nop
+.L1:
+ .word __NR_vfork
+.L2:
+ .word PID - TLS_PRE_TCB_SIZE
+ .align 2
+PSEUDO_END (__vfork)
+hidden_def (vfork)
+
+weak_alias (__vfork, vfork)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sigtimedwait.c b/libpthread/nptl/sysdeps/unix/sysv/linux/sigtimedwait.c
new file mode 100644
index 000000000..4cd5f5498
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sigtimedwait.c
@@ -0,0 +1,87 @@
+/* Copyright (C) 1997,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 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 <pthreadP.h>
+#include <errno.h>
+#include <signal.h>
+#include <string.h>
+
+#include <sysdep-cancel.h>
+#include <sys/syscall.h>
+
+#ifdef __NR_rt_sigtimedwait
+
+static int
+do_sigtimedwait (const sigset_t *set, siginfo_t *info,
+ const struct timespec *timeout)
+{
+#ifdef SIGCANCEL
+ sigset_t tmpset;
+ if (set != NULL
+ && (__builtin_expect (__sigismember (set, SIGCANCEL), 0)
+# ifdef SIGSETXID
+ || __builtin_expect (__sigismember (set, SIGSETXID), 0)
+# 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
+
+ /* XXX The size argument hopefully will have to be changed to the
+ real size of the user-level sigset_t. */
+ int result = INLINE_SYSCALL (rt_sigtimedwait, 4, set,
+ info, timeout, _NSIG / 8);
+
+ /* 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;
+}
+
+
+/* Return any pending signal or wait for one for the given time. */
+int
+__sigtimedwait (const sigset_t *set, siginfo_t *info,
+ const struct timespec *timeout)
+{
+ if (SINGLE_THREAD_P)
+ return do_sigtimedwait (set, info, timeout);
+
+ int oldtype = LIBC_CANCEL_ASYNC ();
+
+ /* XXX The size argument hopefully will have to be changed to the
+ real size of the user-level sigset_t. */
+ int result = do_sigtimedwait (set, info, timeout);
+
+ LIBC_CANCEL_RESET (oldtype);
+
+ return result;
+}
+weak_alias (__sigtimedwait, sigtimedwait)
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sigwait.c b/libpthread/nptl/sysdeps/unix/sysv/linux/sigwait.c
new file mode 100644
index 000000000..bde0a9292
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sigwait.c
@@ -0,0 +1,2 @@
+#include <pthreadP.h>
+#include "../../../../../../libc/signal/sigwait.c"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sigwaitinfo.c b/libpthread/nptl/sysdeps/unix/sysv/linux/sigwaitinfo.c
new file mode 100644
index 000000000..3ad330d21
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sigwaitinfo.c
@@ -0,0 +1,87 @@
+/* Copyright (C) 1997,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 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 <pthreadP.h>
+#include <errno.h>
+#include <signal.h>
+#define __need_NULL
+#include <stddef.h>
+#include <string.h>
+
+#include <sysdep-cancel.h>
+#include <sys/syscall.h>
+
+#ifdef __NR_rt_sigtimedwait
+
+static int
+do_sigwaitinfo (const sigset_t *set, siginfo_t *info)
+{
+#ifdef SIGCANCEL
+ sigset_t tmpset;
+ if (set != NULL
+ && (__builtin_expect (__sigismember (set, SIGCANCEL), 0)
+# ifdef SIGSETXID
+ || __builtin_expect (__sigismember (set, SIGSETXID), 0)
+# 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
+
+ /* XXX The size argument hopefully will have to be changed to the
+ real size of the user-level sigset_t. */
+ int result = INLINE_SYSCALL (rt_sigtimedwait, 4, set,
+ info, NULL, _NSIG / 8);
+
+ /* 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;
+}
+
+
+/* Return any pending signal or wait for one for the given time. */
+int
+__sigwaitinfo (const sigset_t *set, siginfo_t *info)
+{
+ if (SINGLE_THREAD_P)
+ return do_sigwaitinfo (set, info);
+
+ int oldtype = LIBC_CANCEL_ASYNC ();
+
+ /* XXX The size argument hopefully will have to be changed to the
+ real size of the user-level sigset_t. */
+ int result = do_sigwaitinfo (set, info);
+
+ LIBC_CANCEL_RESET (oldtype);
+
+ return result;
+}
+weak_alias (__sigwaitinfo, sigwaitinfo)
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sleep.c b/libpthread/nptl/sysdeps/unix/sysv/linux/sleep.c
new file mode 100644
index 000000000..9e948adce
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sleep.c
@@ -0,0 +1,2 @@
+#include <pthreadP.h>
+#include <../../../../../../libc/unistd/sleep.c>
diff --git a/libc/misc/pthread/unlock.c b/libpthread/nptl/sysdeps/unix/sysv/linux/smp.h
index 04de0df58..38b49554d 100644
--- a/libc/misc/pthread/unlock.c
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/smp.h
@@ -1,5 +1,5 @@
-/* The weak pthread functions for Linux.
- Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
+/* Determine whether the host has multiple processors. Linux version.
+ Copyright (C) 1996, 2002, 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
@@ -14,14 +14,14 @@
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 <pthread.h>
-#include <bits/uClibc_mutex.h>
-
-void attribute_hidden __uclibc_mutex_unlock (void *arg)
+/* Test whether the machine has more than one processor. This is not the
+ best test but good enough. More complicated tests would require `malloc'
+ which is not available at that time. */
+static inline int
+is_smp_system (void)
{
- pthread_mutex_t *__mutex = (pthread_mutex_t *)arg;
- __pthread_mutex_unlock(__mutex);
+ /* Assume all machines are SMP and/or CMT and/or SMT. */
+ return 1;
}
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/Makefile b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/Makefile
new file mode 100644
index 000000000..43a6fad84
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/Makefile
@@ -0,0 +1,13 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2005 Steven J. Hill <sjhill@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+top_srcdir=../../../../../../../
+top_builddir=../../../../../../../
+all: objs
+include $(top_builddir)Rules.mak
+include Makefile.arch
+include $(top_srcdir)Makerules
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/Makefile.arch b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/Makefile.arch
new file mode 100644
index 000000000..01a9e879a
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/Makefile.arch
@@ -0,0 +1,19 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2006 Steven J. Hill <sjhill@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+libpthread_linux_arch_SSRC = clone.S
+libpthread_linux_arch_CSRC = pthread_once.c lowlevellock.c \
+ pthread_barrier_init.c pthread_barrier_wait.c pthread_barrier_destroy.c \
+ pt-__syscall_error.c
+
+libc_linux_arch_CSRC = fork.c libc-lowlevellock.c
+libc_linux_arch_SSRC = clone.S vfork.S
+
+librt_linux_arch_CSRC = pt-__syscall_error.c
+
+ASFLAGS += -DUSE___THREAD
+
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/bits/local_lim.h b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/bits/local_lim.h
new file mode 100644
index 000000000..4e7c9b60d
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/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/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/bits/pthreadtypes.h b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/bits/pthreadtypes.h
new file mode 100644
index 000000000..6b432c41c
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/bits/pthreadtypes.h
@@ -0,0 +1,220 @@
+/* Machine-specific pthread type layouts. SPARC version.
+ Copyright (C) 2003, 2004, 2005, 2006, 2007 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_PTHREADTYPES_H
+#define _BITS_PTHREADTYPES_H 1
+
+#include <bits/wordsize.h>
+
+#if __WORDSIZE == 64
+# define __SIZEOF_PTHREAD_ATTR_T 56
+# define __SIZEOF_PTHREAD_MUTEX_T 40
+# define __SIZEOF_PTHREAD_MUTEXATTR_T 4
+# define __SIZEOF_PTHREAD_COND_T 48
+# define __SIZEOF_PTHREAD_CONDATTR_T 4
+# define __SIZEOF_PTHREAD_RWLOCK_T 56
+# define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
+# define __SIZEOF_PTHREAD_BARRIER_T 32
+# define __SIZEOF_PTHREAD_BARRIERATTR_T 4
+#else
+# define __SIZEOF_PTHREAD_ATTR_T 36
+# define __SIZEOF_PTHREAD_MUTEX_T 24
+# define __SIZEOF_PTHREAD_MUTEXATTR_T 4
+# define __SIZEOF_PTHREAD_COND_T 48
+# define __SIZEOF_PTHREAD_CONDATTR_T 4
+# define __SIZEOF_PTHREAD_RWLOCK_T 32
+# define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
+# define __SIZEOF_PTHREAD_BARRIER_T 20
+# define __SIZEOF_PTHREAD_BARRIERATTR_T 4
+#endif
+
+
+/* Thread identifiers. The structure of the attribute type is
+ deliberately not exposed. */
+typedef unsigned long int pthread_t;
+
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_ATTR_T];
+ long int __align;
+} pthread_attr_t;
+
+
+#if __WORDSIZE == 64
+typedef struct __pthread_internal_list
+{
+ struct __pthread_internal_list *__prev;
+ struct __pthread_internal_list *__next;
+} __pthread_list_t;
+#else
+typedef struct __pthread_internal_slist
+{
+ struct __pthread_internal_slist *__next;
+} __pthread_slist_t;
+#endif
+
+
+/* Data structures for mutex handling. The structure of the attribute
+ type is deliberately not exposed. */
+typedef union
+{
+ struct __pthread_mutex_s
+ {
+ int __lock;
+ unsigned int __count;
+ int __owner;
+#if __WORDSIZE == 64
+ unsigned int __nusers;
+#endif
+ /* KIND must stay at this position in the structure to maintain
+ binary compatibility. */
+ int __kind;
+#if __WORDSIZE == 64
+ int __spins;
+ __pthread_list_t __list;
+# define __PTHREAD_MUTEX_HAVE_PREV 1
+#else
+ unsigned int __nusers;
+ __extension__ union
+ {
+ int __spins;
+ __pthread_slist_t __list;
+ };
+#endif
+ } __data;
+ char __size[__SIZEOF_PTHREAD_MUTEX_T];
+ long int __align;
+} pthread_mutex_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
+ int __align;
+} pthread_mutexattr_t;
+
+
+/* Data structure for conditional variable handling. The structure of
+ the attribute type is deliberately not exposed. */
+typedef union
+{
+ struct
+ {
+ int __lock;
+ unsigned int __futex;
+ __extension__ unsigned long long int __total_seq;
+ __extension__ unsigned long long int __wakeup_seq;
+ __extension__ unsigned long long int __woken_seq;
+ void *__mutex;
+ unsigned int __nwaiters;
+ unsigned int __broadcast_seq;
+ } __data;
+ char __size[__SIZEOF_PTHREAD_COND_T];
+ __extension__ long long int __align;
+} pthread_cond_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_CONDATTR_T];
+ int __align;
+} pthread_condattr_t;
+
+
+/* Keys for thread-specific data */
+typedef unsigned int pthread_key_t;
+
+
+/* Once-only execution */
+typedef int pthread_once_t;
+
+
+#if defined __USE_UNIX98 || defined __USE_XOPEN2K
+/* Data structure for read-write lock variable handling. The
+ structure of the attribute type is deliberately not exposed. */
+typedef union
+{
+# if __WORDSIZE == 64
+ struct
+ {
+ int __lock;
+ unsigned int __nr_readers;
+ unsigned int __readers_wakeup;
+ unsigned int __writer_wakeup;
+ unsigned int __nr_readers_queued;
+ unsigned int __nr_writers_queued;
+ int __writer;
+ int __shared;
+ unsigned long int __pad1;
+ unsigned long int __pad2;
+ /* FLAGS must stay at this position in the structure to maintain
+ binary compatibility. */
+ unsigned int __flags;
+ } __data;
+# else
+ struct
+ {
+ int __lock;
+ unsigned int __nr_readers;
+ unsigned int __readers_wakeup;
+ unsigned int __writer_wakeup;
+ unsigned int __nr_readers_queued;
+ unsigned int __nr_writers_queued;
+ unsigned char __pad1;
+ unsigned char __pad2;
+ unsigned char __shared;
+ /* FLAGS must stay at this position in the structure to maintain
+ binary compatibility. */
+ unsigned char __flags;
+ int __writer;
+ } __data;
+# endif
+ char __size[__SIZEOF_PTHREAD_RWLOCK_T];
+ long int __align;
+} pthread_rwlock_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
+ long int __align;
+} pthread_rwlockattr_t;
+#endif
+
+
+#ifdef __USE_XOPEN2K
+/* POSIX spinlock data type. */
+typedef volatile int pthread_spinlock_t;
+
+
+/* POSIX barriers data type. The structure of the type is
+ deliberately not exposed. */
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_BARRIER_T];
+ long int __align;
+} pthread_barrier_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];
+ int __align;
+} pthread_barrierattr_t;
+#endif
+
+
+#endif /* bits/pthreadtypes.h */
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/bits/semaphore.h b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/bits/semaphore.h
new file mode 100644
index 000000000..5dccd665d
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/bits/semaphore.h
@@ -0,0 +1,40 @@
+/* Machine-specific POSIX semaphore type layouts. SPARC version.
+ Copyright (C) 2003 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 _SEMAPHORE_H
+# error "Never use <bits/semaphore.h> directly; include <semaphore.h> instead."
+#endif
+
+#include <bits/wordsize.h>
+
+#if __WORDSIZE == 64
+# define __SIZEOF_SEM_T 32
+#else
+# define __SIZEOF_SEM_T 16
+#endif
+
+/* Value returned if `sem_open' failed. */
+#define SEM_FAILED ((sem_t *) 0)
+
+
+typedef union
+{
+ char __size[__SIZEOF_SEM_T];
+ long int __align;
+} sem_t;
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/clone.S b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/clone.S
new file mode 100644
index 000000000..a6142aafe
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/clone.S
@@ -0,0 +1,2 @@
+#define RESET_PID
+#include <libc/sysdeps/linux/sparc/clone.S>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/fork.c b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/fork.c
new file mode 100644
index 000000000..fce81c8d5
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/fork.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 2003 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/>. */
+
+#include <sched.h>
+#include <signal.h>
+#include <sysdep.h>
+#include <tls.h>
+
+#define ARCH_FORK() \
+ INLINE_CLONE_SYSCALL (CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID | SIGCHLD, \
+ 0, NULL, NULL, &THREAD_SELF->tid)
+
+#include "../fork.c"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/internaltypes.h b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/internaltypes.h
new file mode 100644
index 000000000..4f400a3fe
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/internaltypes.h
@@ -0,0 +1,34 @@
+#ifndef _INTERNALTYPES_H
+#include "../internaltypes.h"
+
+union sparc_pthread_barrier
+{
+ struct pthread_barrier b;
+ struct sparc_pthread_barrier_s
+ {
+ unsigned int curr_event;
+ int lock;
+ unsigned int left;
+ unsigned int init_count;
+ unsigned char left_lock;
+ unsigned char pshared;
+ } s;
+};
+
+struct sparc_new_sem
+{
+ unsigned int value;
+ unsigned char lock;
+ unsigned char private;
+ unsigned char pad[2];
+ unsigned long int nwaiters;
+};
+
+struct sparc_old_sem
+{
+ unsigned int value;
+ unsigned char lock;
+ unsigned char private;
+};
+
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/libc-lowlevellock.c b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/libc-lowlevellock.c
new file mode 100644
index 000000000..28672a65f
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/libc-lowlevellock.c
@@ -0,0 +1,20 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Paul Mackerras <paulus@au.ibm.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/>. */
+
+/* No difference to lowlevellock.c, except we lose a couple of functions. */
+#include "lowlevellock.c"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/lowlevellock.c b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/lowlevellock.c
new file mode 100644
index 000000000..35c678eb2
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/lowlevellock.c
@@ -0,0 +1,135 @@
+/* low level locking for pthread library. SPARC version.
+ Copyright (C) 2003, 2006, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Paul Mackerras <paulus@au.ibm.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 <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <sys/time.h>
+#include <tls.h>
+
+
+void
+#ifndef IS_IN_libpthread
+weak_function
+#endif
+__lll_lock_wait_private (int *futex)
+{
+ do
+ {
+ int oldval = atomic_compare_and_exchange_val_24_acq (futex, 2, 1);
+ if (oldval != 0)
+ lll_futex_wait (futex, 2, LLL_PRIVATE);
+ }
+ while (atomic_compare_and_exchange_val_24_acq (futex, 2, 0) != 0);
+}
+
+
+/* These functions don't get included in libc.so */
+#ifdef IS_IN_libpthread
+void
+__lll_lock_wait (int *futex, int private)
+{
+ do
+ {
+ int oldval = atomic_compare_and_exchange_val_24_acq (futex, 2, 1);
+ if (oldval != 0)
+ lll_futex_wait (futex, 2, private);
+ }
+ while (atomic_compare_and_exchange_val_24_acq (futex, 2, 0) != 0);
+}
+
+
+int
+__lll_timedlock_wait (int *futex, const struct timespec *abstime, int private)
+{
+ /* Reject invalid timeouts. */
+ if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
+ return EINVAL;
+
+ do
+ {
+ struct timeval tv;
+ struct timespec rt;
+
+ /* Get the current time. */
+ (void) gettimeofday (&tv, NULL);
+
+ /* Compute relative timeout. */
+ rt.tv_sec = abstime->tv_sec - tv.tv_sec;
+ rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+ if (rt.tv_nsec < 0)
+ {
+ rt.tv_nsec += 1000000000;
+ --rt.tv_sec;
+ }
+
+ /* Already timed out? */
+ if (rt.tv_sec < 0)
+ return ETIMEDOUT;
+
+ /* Wait. */
+ int oldval = atomic_compare_and_exchange_val_24_acq (futex, 2, 1);
+ if (oldval != 0)
+ lll_futex_timed_wait (futex, 2, &rt, private);
+ }
+ while (atomic_compare_and_exchange_val_24_acq (futex, 2, 0) != 0);
+
+ return 0;
+}
+
+
+int
+__lll_timedwait_tid (int *tidp, const struct timespec *abstime)
+{
+ int tid;
+
+ if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
+ return EINVAL;
+
+ /* Repeat until thread terminated. */
+ while ((tid = *tidp) != 0)
+ {
+ struct timeval tv;
+ struct timespec rt;
+
+ /* Get the current time. */
+ (void) gettimeofday (&tv, NULL);
+
+ /* Compute relative timeout. */
+ rt.tv_sec = abstime->tv_sec - tv.tv_sec;
+ rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+ if (rt.tv_nsec < 0)
+ {
+ rt.tv_nsec += 1000000000;
+ --rt.tv_sec;
+ }
+
+ /* Already timed out? */
+ if (rt.tv_sec < 0)
+ return ETIMEDOUT;
+
+ /* Wait until thread terminates. The kernel so far does not use
+ the private futex operations for this. */
+ if (lll_futex_timed_wait (tidp, tid, &rt, LLL_SHARED) == -ETIMEDOUT)
+ return ETIMEDOUT;
+ }
+
+ return 0;
+}
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/lowlevellock.h b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/lowlevellock.h
new file mode 100644
index 000000000..a4475f53d
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/lowlevellock.h
@@ -0,0 +1,296 @@
+/* Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009
+ 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; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef _LOWLEVELLOCK_H
+#define _LOWLEVELLOCK_H 1
+
+#include <time.h>
+#include <sys/param.h>
+#include <bits/pthreadtypes.h>
+#include <atomic.h>
+#include <sysdep.h>
+#include <bits/kernel-features.h>
+
+
+#define FUTEX_WAIT 0
+#define FUTEX_WAKE 1
+#define FUTEX_REQUEUE 3
+#define FUTEX_CMP_REQUEUE 4
+#define FUTEX_WAKE_OP 5
+#define FUTEX_OP_CLEAR_WAKE_IF_GT_ONE ((4 << 24) | 1)
+#define FUTEX_LOCK_PI 6
+#define FUTEX_UNLOCK_PI 7
+#define FUTEX_TRYLOCK_PI 8
+#define FUTEX_WAIT_BITSET 9
+#define FUTEX_WAKE_BITSET 10
+#define FUTEX_PRIVATE_FLAG 128
+#define FUTEX_CLOCK_REALTIME 256
+
+#define FUTEX_BITSET_MATCH_ANY 0xffffffff
+
+
+/* Values for 'private' parameter of locking macros. Yes, the
+ definition seems to be backwards. But it is not. The bit will be
+ reversed before passing to the system call. */
+#define LLL_PRIVATE 0
+#define LLL_SHARED FUTEX_PRIVATE_FLAG
+
+
+#if !defined NOT_IN_libc || defined IS_IN_rtld
+/* In libc.so or ld.so all futexes are private. */
+# ifdef __ASSUME_PRIVATE_FUTEX
+# define __lll_private_flag(fl, private) \
+ ((fl) | FUTEX_PRIVATE_FLAG)
+# else
+# define __lll_private_flag(fl, private) \
+ ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex))
+# endif
+#else
+# ifdef __ASSUME_PRIVATE_FUTEX
+# define __lll_private_flag(fl, private) \
+ (((fl) | FUTEX_PRIVATE_FLAG) ^ (private))
+# else
+# define __lll_private_flag(fl, private) \
+ (__builtin_constant_p (private) \
+ ? ((private) == 0 \
+ ? ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex)) \
+ : (fl)) \
+ : ((fl) | (((private) ^ FUTEX_PRIVATE_FLAG) \
+ & THREAD_GETMEM (THREAD_SELF, header.private_futex))))
+# endif
+#endif
+
+
+#define lll_futex_wait(futexp, val, private) \
+ lll_futex_timed_wait (futexp, val, NULL, private)
+
+#define lll_futex_timed_wait(futexp, val, timespec, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ \
+ __ret = INTERNAL_SYSCALL (futex, __err, 4, (futexp), \
+ __lll_private_flag (FUTEX_WAIT, private), \
+ (val), (timespec)); \
+ __ret; \
+ })
+
+#define lll_futex_wake(futexp, nr, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ \
+ __ret = INTERNAL_SYSCALL (futex, __err, 4, (futexp), \
+ __lll_private_flag (FUTEX_WAKE, private), \
+ (nr), 0); \
+ __ret; \
+ })
+
+/* Returns non-zero if error happened, zero if success. */
+#define lll_futex_requeue(futexp, nr_wake, nr_move, mutex, val, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ \
+ __ret = INTERNAL_SYSCALL (futex, __err, 6, (futexp), \
+ __lll_private_flag (FUTEX_CMP_REQUEUE, private),\
+ (nr_wake), (nr_move), (mutex), (val)); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
+ })
+
+#define lll_robust_dead(futexv, private) \
+ do \
+ { \
+ int *__futexp = &(futexv); \
+ atomic_or (__futexp, FUTEX_OWNER_DIED); \
+ lll_futex_wake (__futexp, 1, private); \
+ } \
+ while (0)
+
+/* Returns non-zero if error happened, zero if success. */
+#ifdef __sparc32_atomic_do_lock
+/* Avoid FUTEX_WAKE_OP if supporting pre-v9 CPUs. */
+# define lll_futex_wake_unlock(futexp, nr_wake, nr_wake2, futexp2, private) 1
+#else
+# define lll_futex_wake_unlock(futexp, nr_wake, nr_wake2, futexp2, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ \
+ __ret = INTERNAL_SYSCALL (futex, __err, 6, (futexp), \
+ __lll_private_flag (FUTEX_WAKE_OP, private), \
+ (nr_wake), (nr_wake2), (futexp2), \
+ FUTEX_OP_CLEAR_WAKE_IF_GT_ONE); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
+ })
+#endif
+
+static inline int
+__attribute__ ((always_inline))
+__lll_trylock (int *futex)
+{
+ return atomic_compare_and_exchange_val_24_acq (futex, 1, 0) != 0;
+}
+#define lll_trylock(futex) __lll_trylock (&(futex))
+
+static inline int
+__attribute__ ((always_inline))
+__lll_cond_trylock (int *futex)
+{
+ return atomic_compare_and_exchange_val_24_acq (futex, 2, 0) != 0;
+}
+#define lll_cond_trylock(futex) __lll_cond_trylock (&(futex))
+
+static inline int
+__attribute__ ((always_inline))
+__lll_robust_trylock (int *futex, int id)
+{
+ return atomic_compare_and_exchange_val_acq (futex, id, 0) != 0;
+}
+#define lll_robust_trylock(futex, id) \
+ __lll_robust_trylock (&(futex), id)
+
+
+extern void __lll_lock_wait_private (int *futex) attribute_hidden;
+extern void __lll_lock_wait (int *futex, int private) attribute_hidden;
+extern int __lll_robust_lock_wait (int *futex, int private) attribute_hidden;
+
+static inline void
+__attribute__ ((always_inline))
+__lll_lock (int *futex, int private)
+{
+ int val = atomic_compare_and_exchange_val_24_acq (futex, 1, 0);
+
+ if (__builtin_expect (val != 0, 0))
+ {
+ if (__builtin_constant_p (private) && private == LLL_PRIVATE)
+ __lll_lock_wait_private (futex);
+ else
+ __lll_lock_wait (futex, private);
+ }
+}
+#define lll_lock(futex, private) __lll_lock (&(futex), private)
+
+static inline int
+__attribute__ ((always_inline))
+__lll_robust_lock (int *futex, int id, int private)
+{
+ int result = 0;
+ if (atomic_compare_and_exchange_bool_acq (futex, id, 0) != 0)
+ result = __lll_robust_lock_wait (futex, private);
+ return result;
+}
+#define lll_robust_lock(futex, id, private) \
+ __lll_robust_lock (&(futex), id, private)
+
+static inline void
+__attribute__ ((always_inline))
+__lll_cond_lock (int *futex, int private)
+{
+ int val = atomic_compare_and_exchange_val_24_acq (futex, 2, 0);
+
+ if (__builtin_expect (val != 0, 0))
+ __lll_lock_wait (futex, private);
+}
+#define lll_cond_lock(futex, private) __lll_cond_lock (&(futex), private)
+
+#define lll_robust_cond_lock(futex, id, private) \
+ __lll_robust_lock (&(futex), (id) | FUTEX_WAITERS, private)
+
+
+extern int __lll_timedlock_wait (int *futex, const struct timespec *,
+ int private) attribute_hidden;
+extern int __lll_robust_timedlock_wait (int *futex, const struct timespec *,
+ int private) attribute_hidden;
+
+static inline int
+__attribute__ ((always_inline))
+__lll_timedlock (int *futex, const struct timespec *abstime, int private)
+{
+ int val = atomic_compare_and_exchange_val_24_acq (futex, 1, 0);
+ int result = 0;
+
+ if (__builtin_expect (val != 0, 0))
+ result = __lll_timedlock_wait (futex, abstime, private);
+ return result;
+}
+#define lll_timedlock(futex, abstime, private) \
+ __lll_timedlock (&(futex), abstime, private)
+
+static inline int
+__attribute__ ((always_inline))
+__lll_robust_timedlock (int *futex, const struct timespec *abstime,
+ int id, int private)
+{
+ int result = 0;
+ if (atomic_compare_and_exchange_bool_acq (futex, id, 0) != 0)
+ result = __lll_robust_timedlock_wait (futex, abstime, private);
+ return result;
+}
+#define lll_robust_timedlock(futex, abstime, id, private) \
+ __lll_robust_timedlock (&(futex), abstime, id, private)
+
+#define lll_unlock(lock, private) \
+ ((void) ({ \
+ int *__futex = &(lock); \
+ int __val = atomic_exchange_24_rel (__futex, 0); \
+ if (__builtin_expect (__val > 1, 0)) \
+ lll_futex_wake (__futex, 1, private); \
+ }))
+
+#define lll_robust_unlock(lock, private) \
+ ((void) ({ \
+ int *__futex = &(lock); \
+ int __val = atomic_exchange_rel (__futex, 0); \
+ if (__builtin_expect (__val & FUTEX_WAITERS, 0)) \
+ lll_futex_wake (__futex, 1, private); \
+ }))
+
+#define lll_islocked(futex) \
+ (futex != 0)
+
+/* Initializers for lock. */
+#define LLL_LOCK_INITIALIZER (0)
+#define LLL_LOCK_INITIALIZER_LOCKED (1)
+
+/* The kernel notifies a process with uses CLONE_CLEARTID via futex
+ wakeup when the clone terminates. The memory location contains the
+ thread ID while the clone is running and is reset to zero
+ afterwards. */
+#define lll_wait_tid(tid) \
+ do \
+ { \
+ __typeof (tid) __tid; \
+ while ((__tid = (tid)) != 0) \
+ lll_futex_wait (&(tid), __tid, LLL_SHARED); \
+ } \
+ while (0)
+
+extern int __lll_timedwait_tid (int *, const struct timespec *)
+ attribute_hidden;
+
+#define lll_timedwait_tid(tid, abstime) \
+ ({ \
+ int __res = 0; \
+ if ((tid) != 0) \
+ __res = __lll_timedwait_tid (&(tid), (abstime)); \
+ __res; \
+ })
+
+#endif /* lowlevellock.h */
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/pt-__syscall_error.c b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/pt-__syscall_error.c
new file mode 100644
index 000000000..872e4eff6
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/pt-__syscall_error.c
@@ -0,0 +1 @@
+#include <../../../../../../../libc/sysdeps/linux/sparc/__syscall_error.c>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/pthread_barrier_destroy.c b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/pthread_barrier_destroy.c
new file mode 100644
index 000000000..f07c8c7ae
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/pthread_barrier_destroy.c
@@ -0,0 +1,44 @@
+/* Copyright (C) 2002, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include "pthreadP.h"
+#include <lowlevellock.h>
+
+int
+pthread_barrier_destroy (
+ pthread_barrier_t *barrier)
+{
+ union sparc_pthread_barrier *ibarrier;
+ int result = EBUSY;
+
+ ibarrier = (union sparc_pthread_barrier *) barrier;
+
+ int private = ibarrier->s.pshared ? LLL_SHARED : LLL_PRIVATE;
+
+ lll_lock (ibarrier->b.lock, private);
+
+ if (__builtin_expect (ibarrier->b.left == ibarrier->b.init_count, 1))
+ /* The barrier is not used anymore. */
+ result = 0;
+ else
+ /* Still used, return with an error. */
+ lll_unlock (ibarrier->b.lock, private);
+
+ return result;
+}
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/pthread_barrier_init.c b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/pthread_barrier_init.c
new file mode 100644
index 000000000..1ecc6d0ea
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/pthread_barrier_init.c
@@ -0,0 +1,54 @@
+/* Copyright (C) 2002, 2006, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include "pthreadP.h"
+#include <lowlevellock.h>
+
+int
+pthread_barrier_init (
+ pthread_barrier_t *barrier,
+ const pthread_barrierattr_t *attr,
+ unsigned int count)
+{
+ union sparc_pthread_barrier *ibarrier;
+
+ if (__builtin_expect (count == 0, 0))
+ return EINVAL;
+
+ struct pthread_barrierattr *iattr = (struct pthread_barrierattr *) attr;
+ if (iattr != NULL)
+ {
+ if (iattr->pshared != PTHREAD_PROCESS_PRIVATE
+ && __builtin_expect (iattr->pshared != PTHREAD_PROCESS_SHARED, 0))
+ /* Invalid attribute. */
+ return EINVAL;
+ }
+
+ ibarrier = (union sparc_pthread_barrier *) barrier;
+
+ /* Initialize the individual fields. */
+ ibarrier->b.lock = LLL_LOCK_INITIALIZER;
+ ibarrier->b.left = count;
+ ibarrier->b.init_count = count;
+ ibarrier->b.curr_event = 0;
+ ibarrier->s.left_lock = 0;
+ ibarrier->s.pshared = (iattr && iattr->pshared == PTHREAD_PROCESS_SHARED);
+
+ return 0;
+}
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/pthread_barrier_wait.c b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/pthread_barrier_wait.c
new file mode 100644
index 000000000..169f6e784
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/pthread_barrier_wait.c
@@ -0,0 +1,93 @@
+/* Copyright (C) 2003, 2004, 2006, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Martin Schwidefsky <schwidefsky@de.ibm.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 <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <pthreadP.h>
+
+/* Wait on barrier. */
+int
+pthread_barrier_wait (
+ pthread_barrier_t *barrier)
+{
+ union sparc_pthread_barrier *ibarrier
+ = (union sparc_pthread_barrier *) barrier;
+ int result = 0;
+ int private = ibarrier->s.pshared ? LLL_SHARED : LLL_PRIVATE;
+
+ /* Make sure we are alone. */
+ lll_lock (ibarrier->b.lock, private);
+
+ /* One more arrival. */
+ --ibarrier->b.left;
+
+ /* Are these all? */
+ if (ibarrier->b.left == 0)
+ {
+ /* Yes. Increment the event counter to avoid invalid wake-ups and
+ tell the current waiters that it is their turn. */
+ ++ibarrier->b.curr_event;
+
+ /* Wake up everybody. */
+ lll_futex_wake (&ibarrier->b.curr_event, INT_MAX, private);
+
+ /* This is the thread which finished the serialization. */
+ result = PTHREAD_BARRIER_SERIAL_THREAD;
+ }
+ else
+ {
+ /* The number of the event we are waiting for. The barrier's event
+ number must be bumped before we continue. */
+ unsigned int event = ibarrier->b.curr_event;
+
+ /* Before suspending, make the barrier available to others. */
+ lll_unlock (ibarrier->b.lock, private);
+
+ /* Wait for the event counter of the barrier to change. */
+ do
+ lll_futex_wait (&ibarrier->b.curr_event, event, private);
+ while (event == ibarrier->b.curr_event);
+ }
+
+ /* Make sure the init_count is stored locally or in a register. */
+ unsigned int init_count = ibarrier->b.init_count;
+
+ /* If this was the last woken thread, unlock. */
+ if (__atomic_is_v9 || ibarrier->s.pshared == 0)
+ {
+ if (atomic_increment_val (&ibarrier->b.left) == init_count)
+ /* We are done. */
+ lll_unlock (ibarrier->b.lock, private);
+ }
+ else
+ {
+ unsigned int left;
+ /* Slightly more complicated. On pre-v9 CPUs, atomic_increment_val
+ is only atomic for threads within the same process, not for
+ multiple processes. */
+ __sparc32_atomic_do_lock24 (&ibarrier->s.left_lock);
+ left = ++ibarrier->b.left;
+ __sparc32_atomic_do_unlock24 (&ibarrier->s.left_lock);
+ if (left == init_count)
+ /* We are done. */
+ lll_unlock (ibarrier->b.lock, private);
+ }
+
+ return result;
+}
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/pthread_once.c b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/pthread_once.c
new file mode 100644
index 000000000..9e9bcd699
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/pthread_once.c
@@ -0,0 +1,94 @@
+/* Copyright (C) 2003, 2004, 2007 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/>. */
+
+#include "pthreadP.h"
+#include <lowlevellock.h>
+
+
+unsigned long int __fork_generation attribute_hidden;
+
+
+static void
+clear_once_control (void *arg)
+{
+ pthread_once_t *once_control = (pthread_once_t *) arg;
+
+ *once_control = 0;
+ lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE);
+}
+
+
+int
+attribute_protected
+__pthread_once (once_control, init_routine)
+ pthread_once_t *once_control;
+ void (*init_routine) (void);
+{
+ while (1)
+ {
+ int oldval, val, newval;
+
+ val = *once_control;
+ do
+ {
+ /* Check if the initialized has already been done. */
+ if ((val & 2) != 0)
+ return 0;
+
+ oldval = val;
+ newval = (oldval & 3) | __fork_generation | 1;
+ val = atomic_compare_and_exchange_val_acq (once_control, newval,
+ oldval);
+ }
+ while (__builtin_expect (val != oldval, 0));
+
+ /* Check if another thread already runs the initializer. */
+ if ((oldval & 1) != 0)
+ {
+ /* Check whether the initializer execution was interrupted
+ by a fork. */
+ if (((oldval ^ newval) & -4) == 0)
+ {
+ /* Same generation, some other thread was faster. Wait. */
+ lll_futex_wait (once_control, newval, LLL_PRIVATE);
+ continue;
+ }
+ }
+
+ /* This thread is the first here. Do the initialization.
+ Register a cleanup handler so that in case the thread gets
+ interrupted the initialization can be restarted. */
+ pthread_cleanup_push (clear_once_control, once_control);
+
+ init_routine ();
+
+ pthread_cleanup_pop (0);
+
+
+ /* Add one to *once_control. */
+ atomic_increment (once_control);
+
+ /* Wake up all other threads. */
+ lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE);
+ break;
+ }
+
+ return 0;
+}
+weak_alias (__pthread_once, pthread_once)
+strong_alias (__pthread_once, __pthread_once_internal)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/sem_init.c b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/sem_init.c
new file mode 100644
index 000000000..6fc432e4d
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/sem_init.c
@@ -0,0 +1,54 @@
+/* Copyright (C) 2002, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <string.h>
+#include <semaphore.h>
+#include <lowlevellock.h>
+#include "semaphoreP.h"
+#include <bits/kernel-features.h>
+
+
+int
+sem_init (sem, pshared, value)
+ sem_t *sem;
+ int pshared;
+ unsigned int value;
+{
+ /* Parameter sanity check. */
+ if (__builtin_expect (value > SEM_VALUE_MAX, 0))
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ /* Map to the internal type. */
+ struct sparc_new_sem *isem = (struct sparc_new_sem *) sem;
+
+ /* Use the values the user provided. */
+ memset (isem, '\0', sizeof (*isem));
+ isem->value = value;
+#ifdef __ASSUME_PRIVATE_FUTEX
+ isem->private = pshared ? 0 : FUTEX_PRIVATE_FLAG;
+#else
+ isem->private = pshared ? 0 : THREAD_GETMEM (THREAD_SELF,
+ header.private_futex);
+#endif
+
+ return 0;
+}
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/sem_post.c b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/sem_post.c
new file mode 100644
index 000000000..8da419348
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/sem_post.c
@@ -0,0 +1,52 @@
+/* sem_post -- post to a POSIX semaphore. SPARC version.
+ Copyright (C) 2003, 2004, 2006, 2007 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/>. */
+
+#include <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <internaltypes.h>
+#include <semaphore.h>
+
+int
+sem_post (sem_t *sem)
+{
+ struct sparc_new_sem *isem = (struct sparc_new_sem *) sem;
+ int nr;
+
+ if (__atomic_is_v9)
+ nr = atomic_increment_val (&isem->value);
+ else
+ {
+ __sparc32_atomic_do_lock24 (&isem->lock);
+ nr = ++(isem->value);
+ __sparc32_atomic_do_unlock24 (&isem->lock);
+ }
+ atomic_full_barrier ();
+ if (isem->nwaiters > 0)
+ {
+ int err = lll_futex_wake (&isem->value, 1,
+ isem->private ^ FUTEX_PRIVATE_FLAG);
+ if (__builtin_expect (err, 0) < 0)
+ {
+ __set_errno (-err);
+ return -1;
+ }
+ }
+ return 0;
+}
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/sem_timedwait.c b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/sem_timedwait.c
new file mode 100644
index 000000000..64c9abfc7
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/sem_timedwait.c
@@ -0,0 +1,147 @@
+/* sem_timedwait -- wait on a semaphore. SPARC version.
+ Copyright (C) 2003, 2006, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Paul Mackerras <paulus@au.ibm.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 <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <internaltypes.h>
+#include <semaphore.h>
+
+#include <pthreadP.h>
+
+
+extern void __sem_wait_cleanup (void *arg) attribute_hidden;
+
+
+int
+sem_timedwait (sem_t *sem, const struct timespec *abstime)
+{
+ struct sparc_new_sem *isem = (struct sparc_new_sem *) sem;
+ int err;
+ int val;
+
+ if (__atomic_is_v9)
+ val = atomic_decrement_if_positive (&isem->value);
+ else
+ {
+ __sparc32_atomic_do_lock24 (&isem->lock);
+ val = isem->value;
+ if (val > 0)
+ isem->value = val - 1;
+ __sparc32_atomic_do_unlock24 (&isem->lock);
+ }
+
+ if (val > 0)
+ return 0;
+
+ if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ if (__atomic_is_v9)
+ atomic_increment (&isem->nwaiters);
+ else
+ {
+ __sparc32_atomic_do_lock24 (&isem->lock);
+ isem->nwaiters++;
+ __sparc32_atomic_do_unlock24 (&isem->lock);
+ }
+
+ pthread_cleanup_push (__sem_wait_cleanup, isem);
+
+ while (1)
+ {
+ struct timeval tv;
+ struct timespec rt;
+ int sec, nsec;
+
+ /* Get the current time. */
+ __gettimeofday (&tv, NULL);
+
+ /* Compute relative timeout. */
+ sec = abstime->tv_sec - tv.tv_sec;
+ nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+ if (nsec < 0)
+ {
+ nsec += 1000000000;
+ --sec;
+ }
+
+ /* Already timed out? */
+ err = -ETIMEDOUT;
+ if (sec < 0)
+ {
+ __set_errno (ETIMEDOUT);
+ err = -1;
+ break;
+ }
+
+ /* Do wait. */
+ rt.tv_sec = sec;
+ rt.tv_nsec = nsec;
+
+ /* Enable asynchronous cancellation. Required by the standard. */
+ int oldtype = __pthread_enable_asynccancel ();
+
+ err = lll_futex_timed_wait (&isem->value, 0, &rt,
+ isem->private ^ FUTEX_PRIVATE_FLAG);
+
+ /* Disable asynchronous cancellation. */
+ __pthread_disable_asynccancel (oldtype);
+
+ if (err != 0 && err != -EWOULDBLOCK)
+ {
+ __set_errno (-err);
+ err = -1;
+ break;
+ }
+
+ if (__atomic_is_v9)
+ val = atomic_decrement_if_positive (&isem->value);
+ else
+ {
+ __sparc32_atomic_do_lock24 (&isem->lock);
+ val = isem->value;
+ if (val > 0)
+ isem->value = val - 1;
+ __sparc32_atomic_do_unlock24 (&isem->lock);
+ }
+
+ if (val > 0)
+ {
+ err = 0;
+ break;
+ }
+ }
+
+ pthread_cleanup_pop (0);
+
+ if (__atomic_is_v9)
+ atomic_decrement (&isem->nwaiters);
+ else
+ {
+ __sparc32_atomic_do_lock24 (&isem->lock);
+ isem->nwaiters--;
+ __sparc32_atomic_do_unlock24 (&isem->lock);
+ }
+
+ return err;
+}
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/sem_trywait.c b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/sem_trywait.c
new file mode 100644
index 000000000..36e859ba4
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/sem_trywait.c
@@ -0,0 +1,51 @@
+/* sem_trywait -- wait on a semaphore. SPARC version.
+ Copyright (C) 2003, 2006, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Paul Mackerras <paulus@au.ibm.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 <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <internaltypes.h>
+#include <semaphore.h>
+
+
+int
+sem_trywait (sem_t *sem)
+{
+ struct sparc_old_sem *isem = (struct sparc_old_sem *) sem;
+ int val;
+
+ if (isem->value > 0)
+ {
+ if (__atomic_is_v9)
+ val = atomic_decrement_if_positive (&isem->value);
+ else
+ {
+ __sparc32_atomic_do_lock24 (&isem->lock);
+ val = isem->value;
+ if (val > 0)
+ isem->value = val - 1;
+ __sparc32_atomic_do_unlock24 (&isem->lock);
+ }
+ if (val > 0)
+ return 0;
+ }
+
+ __set_errno (EAGAIN);
+ return -1;
+}
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/sem_wait.c b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/sem_wait.c
new file mode 100644
index 000000000..5d887ab89
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/sem_wait.c
@@ -0,0 +1,124 @@
+/* sem_wait -- wait on a semaphore. Generic futex-using version.
+ Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Paul Mackerras <paulus@au.ibm.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 <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <internaltypes.h>
+#include <semaphore.h>
+
+#include <pthreadP.h>
+
+
+void
+attribute_hidden
+__sem_wait_cleanup (void *arg)
+{
+ struct sparc_new_sem *isem = (struct sparc_new_sem *) arg;
+
+ if (__atomic_is_v9)
+ atomic_decrement (&isem->nwaiters);
+ else
+ {
+ __sparc32_atomic_do_lock24 (&isem->lock);
+ isem->nwaiters--;
+ __sparc32_atomic_do_unlock24 (&isem->lock);
+ }
+}
+
+
+int
+sem_wait (sem_t *sem)
+{
+ struct sparc_new_sem *isem = (struct sparc_new_sem *) sem;
+ int err;
+ int val;
+
+ if (__atomic_is_v9)
+ val = atomic_decrement_if_positive (&isem->value);
+ else
+ {
+ __sparc32_atomic_do_lock24 (&isem->lock);
+ val = isem->value;
+ if (val > 0)
+ isem->value = val - 1;
+ else
+ isem->nwaiters++;
+ __sparc32_atomic_do_unlock24 (&isem->lock);
+ }
+
+ if (val > 0)
+ return 0;
+
+ if (__atomic_is_v9)
+ atomic_increment (&isem->nwaiters);
+ else
+ /* Already done above while still holding isem->lock. */;
+
+ pthread_cleanup_push (__sem_wait_cleanup, isem);
+
+ while (1)
+ {
+ /* Enable asynchronous cancellation. Required by the standard. */
+ int oldtype = __pthread_enable_asynccancel ();
+
+ err = lll_futex_wait (&isem->value, 0,
+ isem->private ^ FUTEX_PRIVATE_FLAG);
+
+ /* Disable asynchronous cancellation. */
+ __pthread_disable_asynccancel (oldtype);
+
+ if (err != 0 && err != -EWOULDBLOCK)
+ {
+ __set_errno (-err);
+ err = -1;
+ break;
+ }
+
+ if (__atomic_is_v9)
+ val = atomic_decrement_if_positive (&isem->value);
+ else
+ {
+ __sparc32_atomic_do_lock24 (&isem->lock);
+ val = isem->value;
+ if (val > 0)
+ isem->value = val - 1;
+ __sparc32_atomic_do_unlock24 (&isem->lock);
+ }
+
+ if (val > 0)
+ {
+ err = 0;
+ break;
+ }
+ }
+
+ pthread_cleanup_pop (0);
+
+ if (__atomic_is_v9)
+ atomic_decrement (&isem->nwaiters);
+ else
+ {
+ __sparc32_atomic_do_lock24 (&isem->lock);
+ isem->nwaiters--;
+ __sparc32_atomic_do_unlock24 (&isem->lock);
+ }
+
+ return err;
+}
diff --git a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h
index 80834292e..b61ca7b52 100644
--- a/libpthread/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jakub@redhat.com>, 2002.
@@ -13,58 +13,60 @@
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 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>
#include <tls.h>
+#include <sysdep.h>
#ifndef __ASSEMBLER__
-# include <linuxthreads/internals.h>
+# include <pthreadP.h>
#endif
#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
# undef PSEUDO
-# define PSEUDO(name, syscall_name, args) \
- .text; \
-ENTRY(name) \
- ld [%g7 + MULTIPLE_THREADS_OFFSET], %g1; \
- brnz,pn %g1, 1f; \
- mov SYS_ify(syscall_name), %g1; \
- ta 0x6d; \
- bcs,pn %xcc, __syscall_error_handler; \
- nop; \
- .subsection 2; \
-1: save %sp, -192, %sp; \
- CENABLE; \
- nop; \
- mov %o0, %l0; \
- COPY_ARGS_##args \
- mov SYS_ify(syscall_name), %g1; \
- ta 0x6d; \
- bcs,pn %xcc, __syscall_error_handler2; \
- mov %o0, %l1; \
- CDISABLE; \
- mov %l0, %o0; \
- jmpl %i7 + 8, %g0; \
- restore %g0, %l1, %o0; \
- .previous; \
- SYSCALL_ERROR_HANDLER \
- SYSCALL_ERROR_HANDLER2
+# define PSEUDO(name, syscall_name, args) \
+ .text; \
+ .globl __syscall_error; \
+ENTRY(name) \
+ ld [%g7 + MULTIPLE_THREADS_OFFSET], %g1;\
+ cmp %g1, 0; \
+ bne 1f; \
+.type __##syscall_name##_nocancel,@function; \
+.globl __##syscall_name##_nocancel; \
+__##syscall_name##_nocancel: \
+ mov SYS_ify(syscall_name), %g1; \
+ ta 0x10; \
+ bcc 8f; \
+ mov %o7, %g1; \
+ call __syscall_error; \
+ mov %g1, %o7; \
+8: jmpl %o7 + 8, %g0; \
+ nop; \
+.size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel;\
+1: save %sp, -96, %sp; \
+ cfi_def_cfa_register(%fp); \
+ cfi_window_save; \
+ cfi_register(%o7, %i7); \
+ CENABLE; \
+ nop; \
+ mov %o0, %l0; \
+ COPY_ARGS_##args \
+ mov SYS_ify(syscall_name), %g1; \
+ ta 0x10; \
+ bcc 1f; \
+ mov %o0, %l1; \
+ CDISABLE; \
+ mov %l0, %o0; \
+ call __syscall_error; \
+ mov %l1, %o0; \
+ b 2f; \
+ mov -1, %l1; \
+1: CDISABLE; \
+ mov %l0, %o0; \
+2: jmpl %i7 + 8, %g0; \
+ restore %g0, %l1, %o0;
-#define SYSCALL_ERROR_HANDLER2 \
-SYSCALL_ERROR_HANDLER_ENTRY(__syscall_error_handler2) \
- .global __errno_location; \
- .type __errno_location,@function; \
- CDISABLE; \
- mov %l0, %o0; \
- call __errno_location; \
- nop; \
- st %l1, [%o0]; \
- jmpl %i7 + 8, %g0; \
- restore %g0, -1, %o0; \
- .previous;
# ifdef IS_IN_libpthread
# define CENABLE call __pthread_enable_asynccancel
@@ -72,9 +74,11 @@ SYSCALL_ERROR_HANDLER_ENTRY(__syscall_error_handler2) \
# elif !defined NOT_IN_libc
# define CENABLE call __libc_enable_asynccancel
# define CDISABLE call __libc_disable_asynccancel
-# else
+# elif defined IS_IN_librt
# define CENABLE call __librt_enable_asynccancel
# define CDISABLE call __librt_disable_asynccancel
+# else
+# error Unsupported library
# endif
#define COPY_ARGS_0 /* Nothing */
@@ -88,14 +92,20 @@ SYSCALL_ERROR_HANDLER_ENTRY(__syscall_error_handler2) \
# ifndef __ASSEMBLER__
# define SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, \
- p_header.data.multiple_threads) == 0, 1)
+ header.multiple_threads) == 0, 1)
# else
# define SINGLE_THREAD_P ld [%g7 + MULTIPLE_THREADS_OFFSET], %g1
# endif
#elif !defined __ASSEMBLER__
-/* This code should never be used but we define it anyhow. */
# define SINGLE_THREAD_P (1)
+# define NO_CANCELLATION 1
#endif
+
+#ifndef __ASSEMBLER__
+# define RTLD_SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/vfork.S
new file mode 100644
index 000000000..71f0662a2
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/vfork.S
@@ -0,0 +1,48 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
+
+ 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 <tcb-offsets.h>
+
+ .text
+ .globl __syscall_error
+ENTRY(__vfork)
+ ld [%g7 + PID], %o5
+ cmp %o5, 0
+ bne 1f
+ sub %g0, %o5, %o4
+ sethi %hi(0x80000000), %o4
+1: st %o4, [%g7 + PID]
+
+ LOADSYSCALL(vfork)
+ ta 0x10
+ bcc 2f
+ mov %o7, %g1
+ st %o5, [%g7 + PID]
+ call __syscall_error
+ mov %g1, %o7
+2: sub %o1, 1, %o1
+ andcc %o0, %o1, %o0
+ bne,a 1f
+ st %o5, [%g7 + PID]
+1: retl
+ nop
+END(__vfork)
+
+libc_hidden_def (vfork)
+weak_alias (__vfork, vfork)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/structsem.sym b/libpthread/nptl/sysdeps/unix/sysv/linux/structsem.sym
new file mode 100644
index 000000000..0e2a15f2b
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/structsem.sym
@@ -0,0 +1,12 @@
+#include <limits.h>
+#include <stddef.h>
+#include <sched.h>
+#include <bits/pthreadtypes.h>
+#include "internaltypes.h"
+
+--
+
+VALUE offsetof (struct new_sem, value)
+PRIVATE offsetof (struct new_sem, private)
+NWAITERS offsetof (struct new_sem, nwaiters)
+SEM_VALUE_MAX SEM_VALUE_MAX
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/timer_create.c b/libpthread/nptl/sysdeps/unix/sysv/linux/timer_create.c
new file mode 100644
index 000000000..93e4e6070
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/timer_create.c
@@ -0,0 +1,242 @@
+/* Copyright (C) 2003,2004, 2007, 2009 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; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <sysdep.h>
+#include <bits/kernel-features.h>
+#include <internaltypes.h>
+#include <pthreadP.h>
+#include "kernel-posix-timers.h"
+#include "kernel-posix-cpu-timers.h"
+
+
+#ifdef __NR_timer_create
+# ifndef __ASSUME_POSIX_TIMERS
+static int compat_timer_create (clockid_t clock_id, struct sigevent *evp,
+ timer_t *timerid);
+# define timer_create static compat_timer_create
+# include <nptl/sysdeps/pthread/timer_create.c>
+# undef timer_create
+
+/* Nonzero if the system calls are not available. */
+int __no_posix_timers attribute_hidden;
+# endif
+
+# ifdef timer_create_alias
+# define timer_create timer_create_alias
+# endif
+
+
+int
+timer_create (
+ clockid_t clock_id,
+ struct sigevent *evp,
+ timer_t *timerid)
+{
+# undef timer_create
+# ifndef __ASSUME_POSIX_TIMERS
+ if (__no_posix_timers >= 0)
+# endif
+ {
+ clockid_t syscall_clockid = (clock_id == CLOCK_PROCESS_CPUTIME_ID
+ ? MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED)
+ : clock_id == CLOCK_THREAD_CPUTIME_ID
+ ? MAKE_THREAD_CPUCLOCK (0, CPUCLOCK_SCHED)
+ : clock_id);
+
+ /* If the user wants notification via a thread we need to handle
+ this special. */
+ if (evp == NULL
+ || __builtin_expect (evp->sigev_notify != SIGEV_THREAD, 1))
+ {
+ struct sigevent local_evp;
+
+ /* We avoid allocating too much memory by basically
+ using struct timer as a derived class with the
+ first two elements being in the superclass. We only
+ need these two elements here. */
+ struct timer *newp = (struct timer *) malloc (offsetof (struct timer,
+ thrfunc));
+ if (newp == NULL)
+ /* No more memory. */
+ return -1;
+
+ if (evp == NULL)
+ {
+ /* The kernel has to pass up the timer ID which is a
+ userlevel object. Therefore we cannot leave it up to
+ the kernel to determine it. */
+ local_evp.sigev_notify = SIGEV_SIGNAL;
+ local_evp.sigev_signo = SIGALRM;
+ local_evp.sigev_value.sival_ptr = newp;
+
+ evp = &local_evp;
+ }
+
+ kernel_timer_t ktimerid;
+ int retval = INLINE_SYSCALL (timer_create, 3, syscall_clockid, evp,
+ &ktimerid);
+
+# ifndef __ASSUME_POSIX_TIMERS
+ if (retval != -1 || errno != ENOSYS)
+# endif
+ {
+# ifndef __ASSUME_POSIX_TIMERS
+ __no_posix_timers = 1;
+# endif
+
+ if (retval != -1)
+ {
+ newp->sigev_notify = (evp != NULL
+ ? evp->sigev_notify : SIGEV_SIGNAL);
+ newp->ktimerid = ktimerid;
+
+ *timerid = (timer_t) newp;
+ }
+ else
+ {
+ /* Cannot allocate the timer, fail. */
+ free (newp);
+ retval = -1;
+ }
+
+ return retval;
+ }
+
+ free (newp);
+
+# ifndef __ASSUME_POSIX_TIMERS
+ /* When we come here the syscall does not exist. Make sure we
+ do not try to use it again. */
+ __no_posix_timers = -1;
+# endif
+ }
+ else
+ {
+# ifndef __ASSUME_POSIX_TIMERS
+ /* Make sure we have the necessary kernel support. */
+ if (__no_posix_timers == 0)
+ {
+ INTERNAL_SYSCALL_DECL (err);
+ struct timespec ts;
+ int res;
+ res = INTERNAL_SYSCALL (clock_getres, err, 2,
+ CLOCK_REALTIME, &ts);
+ __no_posix_timers = (INTERNAL_SYSCALL_ERROR_P (res, err)
+ ? -1 : 1);
+ }
+
+ if (__no_posix_timers > 0)
+# endif
+ {
+ /* Create the helper thread. */
+ pthread_once (&__helper_once, __start_helper_thread);
+ if (__helper_tid == 0)
+ {
+ /* No resources to start the helper thread. */
+ __set_errno (EAGAIN);
+ return -1;
+ }
+
+ struct timer *newp;
+ newp = (struct timer *) malloc (sizeof (struct timer));
+ if (newp == NULL)
+ return -1;
+
+ /* Copy the thread parameters the user provided. */
+ newp->sival = evp->sigev_value;
+ newp->thrfunc = evp->sigev_notify_function;
+ newp->sigev_notify = SIGEV_THREAD;
+
+ /* We cannot simply copy the thread attributes since the
+ implementation might keep internal information for
+ each instance. */
+ (void) pthread_attr_init (&newp->attr);
+ if (evp->sigev_notify_attributes != NULL)
+ {
+ struct pthread_attr *nattr;
+ struct pthread_attr *oattr;
+
+ nattr = (struct pthread_attr *) &newp->attr;
+ oattr = (struct pthread_attr *) evp->sigev_notify_attributes;
+
+ nattr->schedparam = oattr->schedparam;
+ nattr->schedpolicy = oattr->schedpolicy;
+ nattr->flags = oattr->flags;
+ nattr->guardsize = oattr->guardsize;
+ nattr->stackaddr = oattr->stackaddr;
+ nattr->stacksize = oattr->stacksize;
+ }
+
+ /* In any case set the detach flag. */
+ (void) pthread_attr_setdetachstate (&newp->attr,
+ PTHREAD_CREATE_DETACHED);
+
+ /* Create the event structure for the kernel timer. */
+ struct sigevent sev =
+ { .sigev_value.sival_ptr = newp,
+ .sigev_signo = SIGTIMER,
+ .sigev_notify = SIGEV_SIGNAL | SIGEV_THREAD_ID,
+ ._sigev_un = { ._pad = { [0] = __helper_tid } } };
+
+ /* Create the timer. */
+ INTERNAL_SYSCALL_DECL (err);
+ int res;
+ res = INTERNAL_SYSCALL (timer_create, err, 3,
+ syscall_clockid, &sev, &newp->ktimerid);
+ if (! INTERNAL_SYSCALL_ERROR_P (res, err))
+ {
+ /* Add to the queue of active timers with thread
+ delivery. */
+ pthread_mutex_lock (&__active_timer_sigev_thread_lock);
+ newp->next = __active_timer_sigev_thread;
+ __active_timer_sigev_thread = newp;
+ pthread_mutex_unlock (&__active_timer_sigev_thread_lock);
+
+ *timerid = (timer_t) newp;
+ return 0;
+ }
+
+ /* Free the resources. */
+ free (newp);
+
+ __set_errno (INTERNAL_SYSCALL_ERRNO (res, err));
+
+ return -1;
+ }
+ }
+ }
+
+# ifndef __ASSUME_POSIX_TIMERS
+ /* Compatibility code. */
+ return compat_timer_create (clock_id, evp, timerid);
+# endif
+}
+#else
+# ifdef timer_create_alias
+# define timer_create timer_create_alias
+# endif
+/* The new system calls are not available. Use the userlevel
+ implementation. */
+# include <nptl/sysdeps/pthread/timer_create.c>
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/timer_delete.c b/libpthread/nptl/sysdeps/unix/sysv/linux/timer_delete.c
new file mode 100644
index 000000000..df5cc3a33
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/timer_delete.c
@@ -0,0 +1,114 @@
+/* Copyright (C) 2003, 2007 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; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <time.h>
+#include <sysdep.h>
+#include <bits/kernel-features.h>
+#include "kernel-posix-timers.h"
+
+
+#ifdef __NR_timer_delete
+# ifndef __ASSUME_POSIX_TIMERS
+static int compat_timer_delete (timer_t timerid);
+# define timer_delete static compat_timer_delete
+# include <nptl/sysdeps/pthread/timer_delete.c>
+# undef timer_delete
+# endif
+
+# ifdef timer_delete_alias
+# define timer_delete timer_delete_alias
+# endif
+
+
+int
+timer_delete (
+ timer_t timerid)
+{
+# undef timer_delete
+# ifndef __ASSUME_POSIX_TIMERS
+ if (__no_posix_timers >= 0)
+# endif
+ {
+ struct timer *kt = (struct timer *) timerid;
+
+ /* Delete the kernel timer object. */
+ int res = INLINE_SYSCALL (timer_delete, 1, kt->ktimerid);
+
+ if (res == 0)
+ {
+ if (kt->sigev_notify == SIGEV_THREAD)
+ {
+ /* Remove the timer from the list. */
+ pthread_mutex_lock (&__active_timer_sigev_thread_lock);
+ if (__active_timer_sigev_thread == kt)
+ __active_timer_sigev_thread = kt->next;
+ else
+ {
+ struct timer *prevp = __active_timer_sigev_thread;
+ while (prevp->next != NULL)
+ if (prevp->next == kt)
+ {
+ prevp->next = kt->next;
+ break;
+ }
+ else
+ prevp = prevp->next;
+ }
+ pthread_mutex_unlock (&__active_timer_sigev_thread_lock);
+ }
+
+# ifndef __ASSUME_POSIX_TIMERS
+ /* We know the syscall support is available. */
+ __no_posix_timers = 1;
+# endif
+
+ /* Free the memory. */
+ (void) free (kt);
+
+ return 0;
+ }
+
+ /* The kernel timer is not known or something else bad happened.
+ Return the error. */
+# ifndef __ASSUME_POSIX_TIMERS
+ if (errno != ENOSYS)
+ {
+ __no_posix_timers = 1;
+# endif
+ return -1;
+# ifndef __ASSUME_POSIX_TIMERS
+ }
+
+ __no_posix_timers = -1;
+# endif
+ }
+
+# ifndef __ASSUME_POSIX_TIMERS
+ return compat_timer_delete (timerid);
+# endif
+}
+#else
+# ifdef timer_delete_alias
+# define timer_delete timer_delete_alias
+# endif
+/* The new system calls are not available. Use the userlevel
+ implementation. */
+# include <nptl/sysdeps/pthread/timer_delete.c>
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/timer_getoverr.c b/libpthread/nptl/sysdeps/unix/sysv/linux/timer_getoverr.c
new file mode 100644
index 000000000..ab0e35d48
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/timer_getoverr.c
@@ -0,0 +1,80 @@
+/* Copyright (C) 2003 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; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <time.h>
+#include <sysdep.h>
+#include <bits/kernel-features.h>
+#include "kernel-posix-timers.h"
+
+
+#ifdef __NR_timer_getoverrun
+# ifndef __ASSUME_POSIX_TIMERS
+static int compat_timer_getoverrun (timer_t timerid);
+# define timer_getoverrun static compat_timer_getoverrun
+# include <nptl/sysdeps/pthread/timer_getoverr.c>
+# undef timer_getoverrun
+# endif
+
+# ifdef timer_getoverrun_alias
+# define timer_getoverrun timer_getoverrun_alias
+# endif
+
+
+int
+timer_getoverrun (
+ timer_t timerid)
+{
+# undef timer_getoverrun
+# ifndef __ASSUME_POSIX_TIMERS
+ if (__no_posix_timers >= 0)
+# endif
+ {
+ struct timer *kt = (struct timer *) timerid;
+
+ /* Get the information from the kernel. */
+ int res = INLINE_SYSCALL (timer_getoverrun, 1, kt->ktimerid);
+
+# ifndef __ASSUME_POSIX_TIMERS
+ if (res != -1 || errno != ENOSYS)
+ {
+ /* We know the syscall support is available. */
+ __no_posix_timers = 1;
+# endif
+ return res;
+# ifndef __ASSUME_POSIX_TIMERS
+ }
+# endif
+
+# ifndef __ASSUME_POSIX_TIMERS
+ __no_posix_timers = -1;
+# endif
+ }
+
+# ifndef __ASSUME_POSIX_TIMERS
+ return compat_timer_getoverrun (timerid);
+# endif
+}
+#else
+# ifdef timer_getoverrun_alias
+# define timer_getoverrun timer_getoverrun_alias
+# endif
+/* The new system calls are not available. Use the userlevel
+ implementation. */
+# include <nptl/sysdeps/pthread/timer_getoverr.c>
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/timer_gettime.c b/libpthread/nptl/sysdeps/unix/sysv/linux/timer_gettime.c
new file mode 100644
index 000000000..699874f3f
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/timer_gettime.c
@@ -0,0 +1,82 @@
+/* Copyright (C) 2003 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; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <time.h>
+#include <sysdep.h>
+#include <bits/kernel-features.h>
+#include "kernel-posix-timers.h"
+
+
+#ifdef __NR_timer_gettime
+# ifndef __ASSUME_POSIX_TIMERS
+static int compat_timer_gettime (timer_t timerid, struct itimerspec *value);
+# define timer_gettime static compat_timer_gettime
+# include <nptl/sysdeps/pthread/timer_gettime.c>
+# undef timer_gettime
+# endif
+
+# ifdef timer_gettime_alias
+# define timer_gettime timer_gettime_alias
+# endif
+
+
+int
+timer_gettime (
+ timer_t timerid,
+ struct itimerspec *value)
+{
+# undef timer_gettime
+# ifndef __ASSUME_POSIX_TIMERS
+ if (__no_posix_timers >= 0)
+# endif
+ {
+ struct timer *kt = (struct timer *) timerid;
+
+ /* Delete the kernel timer object. */
+ int res = INLINE_SYSCALL (timer_gettime, 2, kt->ktimerid, value);
+
+# ifndef __ASSUME_POSIX_TIMERS
+ if (res != -1 || errno != ENOSYS)
+ {
+ /* We know the syscall support is available. */
+ __no_posix_timers = 1;
+# endif
+ return res;
+# ifndef __ASSUME_POSIX_TIMERS
+ }
+# endif
+
+# ifndef __ASSUME_POSIX_TIMERS
+ __no_posix_timers = -1;
+# endif
+ }
+
+# ifndef __ASSUME_POSIX_TIMERS
+ return compat_timer_gettime (timerid, value);
+# endif
+}
+#else
+# ifdef timer_gettime_alias
+# define timer_gettime timer_gettime_alias
+# endif
+/* The new system calls are not available. Use the userlevel
+ implementation. */
+# include <nptl/sysdeps/pthread/timer_gettime.c>
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/timer_routines.c b/libpthread/nptl/sysdeps/unix/sysv/linux/timer_routines.c
new file mode 100644
index 000000000..514913317
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/timer_routines.c
@@ -0,0 +1,203 @@
+/* Copyright (C) 2003, 2004, 2005, 2006, 2007 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; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <stdbool.h>
+#include <sysdep.h>
+#include <bits/kernel-features.h>
+#include <pthreadP.h>
+#include "kernel-posix-timers.h"
+
+
+/* List of active SIGEV_THREAD timers. */
+struct timer *__active_timer_sigev_thread;
+/* Lock for the __active_timer_sigev_thread. */
+pthread_mutex_t __active_timer_sigev_thread_lock = PTHREAD_MUTEX_INITIALIZER;
+
+
+struct thread_start_data
+{
+ void (*thrfunc) (sigval_t);
+ sigval_t sival;
+};
+
+
+#ifdef __NR_timer_create
+/* Helper thread to call the user-provided function. */
+static void *
+timer_sigev_thread (void *arg)
+{
+ /* The parent thread has all signals blocked. This is a bit
+ surprising for user code, although valid. We unblock all
+ signals. */
+ sigset_t ss;
+ __sigemptyset (&ss);
+ INTERNAL_SYSCALL_DECL (err);
+ INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_SETMASK, &ss, NULL, _NSIG / 8);
+
+ struct thread_start_data *td = (struct thread_start_data *) arg;
+
+ void (*thrfunc) (sigval_t) = td->thrfunc;
+ sigval_t sival = td->sival;
+
+ /* The TD object was allocated in timer_helper_thread. */
+ free (td);
+
+ /* Call the user-provided function. */
+ thrfunc (sival);
+
+ return NULL;
+}
+
+
+/* Helper function to support starting threads for SIGEV_THREAD. */
+static attribute_noreturn void *
+timer_helper_thread (void *arg)
+{
+ /* Wait for the SIGTIMER signal, allowing the setXid signal, and
+ none else. */
+ sigset_t ss;
+ __sigemptyset (&ss);
+ __sigaddset (&ss, SIGTIMER);
+
+ /* Endless loop of waiting for signals. The loop is only ended when
+ the thread is canceled. */
+ while (1)
+ {
+ siginfo_t si;
+
+ /* sigwaitinfo cannot be used here, since it deletes
+ SIGCANCEL == SIGTIMER from the set. */
+
+ int oldtype = LIBC_CANCEL_ASYNC ();
+
+ /* XXX The size argument hopefully will have to be changed to the
+ real size of the user-level sigset_t. */
+ int result = INLINE_SYSCALL (rt_sigtimedwait, 4, &ss, &si, NULL,
+ _NSIG / 8);
+
+ LIBC_CANCEL_RESET (oldtype);
+
+ if (result > 0)
+ {
+ if (si.si_code == SI_TIMER)
+ {
+ struct timer *tk = (struct timer *) si.si_ptr;
+
+ /* Check the timer is still used and will not go away
+ while we are reading the values here. */
+ pthread_mutex_lock (&__active_timer_sigev_thread_lock);
+
+ struct timer *runp = __active_timer_sigev_thread;
+ while (runp != NULL)
+ if (runp == tk)
+ break;
+ else
+ runp = runp->next;
+
+ if (runp != NULL)
+ {
+ struct thread_start_data *td = malloc (sizeof (*td));
+
+ /* There is not much we can do if the allocation fails. */
+ if (td != NULL)
+ {
+ /* This is the signal we are waiting for. */
+ td->thrfunc = tk->thrfunc;
+ td->sival = tk->sival;
+
+ pthread_t th;
+ (void) pthread_create (&th, &tk->attr,
+ timer_sigev_thread, td);
+ }
+ }
+
+ pthread_mutex_unlock (&__active_timer_sigev_thread_lock);
+ }
+ else if (si.si_code == SI_TKILL)
+ /* The thread is canceled. */
+ pthread_exit (NULL);
+ }
+ }
+}
+
+
+/* Control variable for helper thread creation. */
+pthread_once_t __helper_once attribute_hidden;
+
+
+/* TID of the helper thread. */
+pid_t __helper_tid attribute_hidden;
+
+
+/* Reset variables so that after a fork a new helper thread gets started. */
+static void
+reset_helper_control (void)
+{
+ __helper_once = PTHREAD_ONCE_INIT;
+ __helper_tid = 0;
+}
+
+
+void
+attribute_hidden
+__start_helper_thread (void)
+{
+ /* The helper thread needs only very little resources
+ and should go away automatically when canceled. */
+ pthread_attr_t attr;
+ (void) pthread_attr_init (&attr);
+ (void) pthread_attr_setstacksize (&attr, PTHREAD_STACK_MIN);
+
+ /* Block all signals in the helper thread but SIGSETXID. To do this
+ thoroughly we temporarily have to block all signals here. The
+ helper can lose wakeups if SIGCANCEL is not blocked throughout,
+ but sigfillset omits it SIGSETXID. So, we add SIGCANCEL back
+ explicitly here. */
+ sigset_t ss;
+ sigset_t oss;
+ sigfillset (&ss);
+ __sigaddset (&ss, SIGCANCEL);
+ INTERNAL_SYSCALL_DECL (err);
+ INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_SETMASK, &ss, &oss, _NSIG / 8);
+
+ /* Create the helper thread for this timer. */
+ pthread_t th;
+ int res = pthread_create (&th, &attr, timer_helper_thread, NULL);
+ if (res == 0)
+ /* We managed to start the helper thread. */
+ __helper_tid = ((struct pthread *) th)->tid;
+
+ /* Restore the signal mask. */
+ INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_SETMASK, &oss, NULL,
+ _NSIG / 8);
+
+ /* No need for the attribute anymore. */
+ (void) pthread_attr_destroy (&attr);
+
+ /* We have to make sure that after fork()ing a new helper thread can
+ be created. */
+ pthread_atfork (NULL, NULL, reset_helper_control);
+}
+#endif
+
+#ifndef __ASSUME_POSIX_TIMERS
+# include <nptl/sysdeps/pthread/timer_routines.c>
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/timer_settime.c b/libpthread/nptl/sysdeps/unix/sysv/linux/timer_settime.c
new file mode 100644
index 000000000..81a0fa568
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/timer_settime.c
@@ -0,0 +1,87 @@
+/* Copyright (C) 2003 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; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <time.h>
+#include <sysdep.h>
+#include <bits/kernel-features.h>
+#include "kernel-posix-timers.h"
+
+
+#ifdef __NR_timer_settime
+# ifndef __ASSUME_POSIX_TIMERS
+static int compat_timer_settime (timer_t timerid, int flags,
+ const struct itimerspec *value,
+ struct itimerspec *ovalue);
+# define timer_settime static compat_timer_settime
+# include <nptl/sysdeps/pthread/timer_settime.c>
+# undef timer_settime
+# endif
+
+# ifdef timer_settime_alias
+# define timer_settime timer_settime_alias
+# endif
+
+
+int
+timer_settime (
+ timer_t timerid,
+ int flags,
+ const struct itimerspec *value,
+ struct itimerspec *ovalue)
+{
+# undef timer_settime
+# ifndef __ASSUME_POSIX_TIMERS
+ if (__no_posix_timers >= 0)
+# endif
+ {
+ struct timer *kt = (struct timer *) timerid;
+
+ /* Delete the kernel timer object. */
+ int res = INLINE_SYSCALL (timer_settime, 4, kt->ktimerid, flags,
+ value, ovalue);
+
+# ifndef __ASSUME_POSIX_TIMERS
+ if (res != -1 || errno != ENOSYS)
+ {
+ /* We know the syscall support is available. */
+ __no_posix_timers = 1;
+# endif
+ return res;
+# ifndef __ASSUME_POSIX_TIMERS
+ }
+# endif
+
+# ifndef __ASSUME_POSIX_TIMERS
+ __no_posix_timers = -1;
+# endif
+ }
+
+# ifndef __ASSUME_POSIX_TIMERS
+ return compat_timer_settime (timerid, flags, value, ovalue);
+# endif
+}
+#else
+# ifdef timer_settime_alias
+# define timer_settime timer_settime_alias
+# endif
+/* The new system calls are not available. Use the userlevel
+ implementation. */
+# include <nptl/sysdeps/pthread/timer_settime.c>
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/unregister-atfork.c b/libpthread/nptl/sysdeps/unix/sysv/linux/unregister-atfork.c
new file mode 100644
index 000000000..69e26210f
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/unregister-atfork.c
@@ -0,0 +1,122 @@
+/* Copyright (C) 2002, 2003, 2005, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <stdlib.h>
+#include <fork.h>
+#include <atomic.h>
+#include <tls.h>
+
+
+void
+__unregister_atfork (
+ void *dso_handle)
+{
+ /* Check whether there is any entry in the list which we have to
+ remove. It is likely that this is not the case so don't bother
+ getting the lock.
+
+ We do not worry about other threads adding entries for this DSO
+ right this moment. If this happens this is a race and we can do
+ whatever we please. The program will crash anyway seen. */
+ struct fork_handler *runp = __fork_handlers;
+ struct fork_handler *lastp = NULL;
+
+ while (runp != NULL)
+ if (runp->dso_handle == dso_handle)
+ break;
+ else
+ {
+ lastp = runp;
+ runp = runp->next;
+ }
+
+ if (runp == NULL)
+ /* Nothing to do. */
+ return;
+
+ /* Get the lock to not conflict with additions or deletions. Note
+ that there couldn't have been another thread deleting something.
+ The __unregister_atfork function is only called from the
+ dlclose() code which itself serializes the operations. */
+ lll_lock (__fork_lock, LLL_PRIVATE);
+
+ /* We have to create a new list with all the entries we don't remove. */
+ struct deleted_handler
+ {
+ struct fork_handler *handler;
+ struct deleted_handler *next;
+ } *deleted = NULL;
+
+ /* Remove the entries for the DSO which is unloaded from the list.
+ It's a single linked list so readers are. */
+ do
+ {
+ again:
+ if (runp->dso_handle == dso_handle)
+ {
+ if (lastp == NULL)
+ {
+ /* We have to use an atomic operation here because
+ __linkin_atfork also uses one. */
+ if (catomic_compare_and_exchange_bool_acq (&__fork_handlers,
+ runp->next, runp)
+ != 0)
+ {
+ runp = __fork_handlers;
+ goto again;
+ }
+ }
+ else
+ lastp->next = runp->next;
+
+ /* We cannot overwrite the ->next element now. Put the deleted
+ entries in a separate list. */
+ struct deleted_handler *newp = alloca (sizeof (*newp));
+ newp->handler = runp;
+ newp->next = deleted;
+ deleted = newp;
+ }
+ else
+ lastp = runp;
+
+ runp = runp->next;
+ }
+ while (runp != NULL);
+
+ /* Release the lock. */
+ lll_unlock (__fork_lock, LLL_PRIVATE);
+
+ /* Walk the list of all entries which have to be deleted. */
+ while (deleted != NULL)
+ {
+ /* We need to be informed by possible current users. */
+ deleted->handler->need_signal = 1;
+ /* Make sure this gets written out first. */
+ atomic_write_barrier ();
+
+ /* Decrement the reference counter. If it does not reach zero
+ wait for the last user. */
+ atomic_decrement (&deleted->handler->refcntr);
+ unsigned int val;
+ while ((val = deleted->handler->refcntr) != 0)
+ lll_futex_wait (&deleted->handler->refcntr, val, LLL_PRIVATE);
+
+ deleted = deleted->next;
+ }
+}
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/unwindbuf.sym b/libpthread/nptl/sysdeps/unix/sysv/linux/unwindbuf.sym
new file mode 100644
index 000000000..8044b4078
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/unwindbuf.sym
@@ -0,0 +1,7 @@
+#include <pthread.h>
+#include <stddef.h>
+
+--
+
+UNWINDBUFSIZE sizeof (__pthread_unwind_buf_t)
+UWJMPBUF offsetof (__pthread_unwind_buf_t, __cancel_jmp_buf)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/waitpid.S b/libpthread/nptl/sysdeps/unix/sysv/linux/waitpid.S
new file mode 100644
index 000000000..52abb27f0
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/waitpid.S
@@ -0,0 +1,23 @@
+#include <sysdep-cancel.h>
+
+#ifndef __NR_waitpid
+#error Makefile error: No NR_waitpid on this arch
+#endif
+
+/*
+extern pid_t __waitpid_nocancel (pid_t, int *, int) attribute_hidden;
+*/
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+
+PSEUDO (__waitpid, waitpid, 3)
+ret
+PSEUDO_END(__waitpid)
+
+libc_hidden_def (__waitpid)
+weak_alias (__waitpid, waitpid)
+libc_hidden_weak (waitpid)
+weak_alias (__waitpid, __libc_waitpid)
+libc_hidden_weak (__libc_waitpid)
+
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/write.S b/libpthread/nptl/sysdeps/unix/sysv/linux/write.S
new file mode 100644
index 000000000..43de3320d
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/write.S
@@ -0,0 +1,19 @@
+#include <sysdep-cancel.h>
+
+/*
+extern int __write_nocancel (int, const void *, size_t) attribute_hidden;
+*/
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+PSEUDO (__libc_write, write, 3)
+ret
+PSEUDO_END(__libc_write)
+
+libc_hidden_def (__write_nocancel)
+libc_hidden_def (__libc_write)
+weak_alias (__libc_write, __write)
+libc_hidden_weak (__write)
+weak_alias (__libc_write, write)
+libc_hidden_weak (write)
+
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/Makefile b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/Makefile
new file mode 100644
index 000000000..43a6fad84
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/Makefile
@@ -0,0 +1,13 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2005 Steven J. Hill <sjhill@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+top_srcdir=../../../../../../../
+top_builddir=../../../../../../../
+all: objs
+include $(top_builddir)Rules.mak
+include Makefile.arch
+include $(top_srcdir)Makerules
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/Makefile.arch b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/Makefile.arch
new file mode 100644
index 000000000..af1416485
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/Makefile.arch
@@ -0,0 +1,22 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2006 Steven J. Hill <sjhill@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+libpthread_linux_arch_SSRC = clone.S pthread_once.S \
+ lowlevellock.S pthread_barrier_wait.S pthread_cond_signal.S pthread_cond_broadcast.S \
+ sem_post.S sem_timedwait.S lowlevelrobustlock.S \
+ sem_trywait.S sem_wait.S pthread_rwlock_rdlock.S pthread_rwlock_wrlock.S \
+ pthread_rwlock_timedrdlock.S pthread_rwlock_timedwrlock.S pthread_rwlock_unlock.S \
+ pthread_spin_unlock.S cancellation.S pthread_cond_timedwait.S pthread_cond_wait.S
+libpthread_linux_arch_CSRC = pthread_spin_init.c pt-__syscall_error.c
+
+libc_linux_arch_CSRC = fork.c
+libc_linux_arch_SSRC = clone.S vfork.S libc-cancellation.S libc-lowlevellock.S
+libc_linux_arch_SSRC-OMIT = waitpid.S
+librt_linux_arch_SSRC = librt-cancellation.S
+
+ASFLAGS += -DUSE___THREAD
+
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h
new file mode 100644
index 000000000..76b0b523e
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h
@@ -0,0 +1,224 @@
+/* Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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/>. */
+
+#ifndef _BITS_PTHREADTYPES_H
+#define _BITS_PTHREADTYPES_H 1
+
+#include <bits/wordsize.h>
+
+#if __WORDSIZE == 64
+# define __SIZEOF_PTHREAD_ATTR_T 56
+# define __SIZEOF_PTHREAD_MUTEX_T 40
+# define __SIZEOF_PTHREAD_MUTEXATTR_T 4
+# define __SIZEOF_PTHREAD_COND_T 48
+# define __SIZEOF_PTHREAD_CONDATTR_T 4
+# define __SIZEOF_PTHREAD_RWLOCK_T 56
+# define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
+# define __SIZEOF_PTHREAD_BARRIER_T 32
+# define __SIZEOF_PTHREAD_BARRIERATTR_T 4
+#else
+# define __SIZEOF_PTHREAD_ATTR_T 36
+# define __SIZEOF_PTHREAD_MUTEX_T 24
+# define __SIZEOF_PTHREAD_MUTEXATTR_T 4
+# define __SIZEOF_PTHREAD_COND_T 48
+# define __SIZEOF_PTHREAD_CONDATTR_T 4
+# define __SIZEOF_PTHREAD_RWLOCK_T 32
+# define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
+# define __SIZEOF_PTHREAD_BARRIER_T 20
+# define __SIZEOF_PTHREAD_BARRIERATTR_T 4
+#endif
+
+
+/* Thread identifiers. The structure of the attribute type is not
+ exposed on purpose. */
+typedef unsigned long int pthread_t;
+
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_ATTR_T];
+ long int __align;
+} pthread_attr_t;
+
+
+#if __WORDSIZE == 64
+typedef struct __pthread_internal_list
+{
+ struct __pthread_internal_list *__prev;
+ struct __pthread_internal_list *__next;
+} __pthread_list_t;
+#else
+typedef struct __pthread_internal_slist
+{
+ struct __pthread_internal_slist *__next;
+} __pthread_slist_t;
+#endif
+
+
+/* Data structures for mutex handling. The structure of the attribute
+ type is not exposed on purpose. */
+typedef union
+{
+ struct __pthread_mutex_s
+ {
+ int __lock;
+ unsigned int __count;
+ int __owner;
+#if __WORDSIZE == 64
+ unsigned int __nusers;
+#endif
+ /* KIND must stay at this position in the structure to maintain
+ binary compatibility. */
+ int __kind;
+#if __WORDSIZE == 64
+ int __spins;
+ __pthread_list_t __list;
+# define __PTHREAD_MUTEX_HAVE_PREV 1
+#else
+ unsigned int __nusers;
+ __extension__ union
+ {
+ int __spins;
+ __pthread_slist_t __list;
+ };
+#endif
+ } __data;
+ char __size[__SIZEOF_PTHREAD_MUTEX_T];
+ long int __align;
+} pthread_mutex_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
+ int __align;
+} pthread_mutexattr_t;
+
+
+/* Data structure for conditional variable handling. The structure of
+ the attribute type is not exposed on purpose. */
+typedef union
+{
+ struct
+ {
+ int __lock;
+ unsigned int __futex;
+ __extension__ unsigned long long int __total_seq;
+ __extension__ unsigned long long int __wakeup_seq;
+ __extension__ unsigned long long int __woken_seq;
+ void *__mutex;
+ unsigned int __nwaiters;
+ unsigned int __broadcast_seq;
+ } __data;
+ char __size[__SIZEOF_PTHREAD_COND_T];
+ __extension__ long long int __align;
+} pthread_cond_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_CONDATTR_T];
+ int __align;
+} pthread_condattr_t;
+
+
+/* Keys for thread-specific data */
+typedef unsigned int pthread_key_t;
+
+
+/* Once-only execution */
+typedef int pthread_once_t;
+
+
+#if defined __USE_UNIX98 || defined __USE_XOPEN2K
+/* Data structure for read-write lock variable handling. The
+ structure of the attribute type is not exposed on purpose. */
+typedef union
+{
+# if __WORDSIZE == 64
+ struct
+ {
+ int __lock;
+ unsigned int __nr_readers;
+ unsigned int __readers_wakeup;
+ unsigned int __writer_wakeup;
+ unsigned int __nr_readers_queued;
+ unsigned int __nr_writers_queued;
+ int __writer;
+ int __shared;
+ unsigned long int __pad1;
+ unsigned long int __pad2;
+ /* FLAGS must stay at this position in the structure to maintain
+ binary compatibility. */
+ unsigned int __flags;
+ } __data;
+# else
+ struct
+ {
+ int __lock;
+ unsigned int __nr_readers;
+ unsigned int __readers_wakeup;
+ unsigned int __writer_wakeup;
+ unsigned int __nr_readers_queued;
+ unsigned int __nr_writers_queued;
+ /* FLAGS must stay at this position in the structure to maintain
+ binary compatibility. */
+ unsigned char __flags;
+ unsigned char __shared;
+ unsigned char __pad1;
+ unsigned char __pad2;
+ int __writer;
+ } __data;
+# endif
+ char __size[__SIZEOF_PTHREAD_RWLOCK_T];
+ long int __align;
+} pthread_rwlock_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
+ long int __align;
+} pthread_rwlockattr_t;
+#endif
+
+
+#ifdef __USE_XOPEN2K
+/* POSIX spinlock data type. */
+typedef volatile int pthread_spinlock_t;
+
+
+/* POSIX barriers data type. The structure of the type is
+ deliberately not exposed. */
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_BARRIER_T];
+ long int __align;
+} pthread_barrier_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];
+ int __align;
+} pthread_barrierattr_t;
+#endif
+
+
+#if __WORDSIZE == 32
+/* Extra attributes for the cleanup functions. */
+# define __cleanup_fct_attribute __attribute__ ((__regparm__ (1)))
+#endif
+
+#endif /* bits/pthreadtypes.h */
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/bits/semaphore.h b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/bits/semaphore.h
new file mode 100644
index 000000000..662af9899
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/bits/semaphore.h
@@ -0,0 +1,40 @@
+/* Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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/>. */
+
+#ifndef _SEMAPHORE_H
+# error "Never use <bits/semaphore.h> directly; include <semaphore.h> instead."
+#endif
+
+#include <bits/wordsize.h>
+
+#if __WORDSIZE == 64
+# define __SIZEOF_SEM_T 32
+#else
+# define __SIZEOF_SEM_T 16
+#endif
+
+
+/* Value returned if `sem_open' failed. */
+#define SEM_FAILED ((sem_t *) 0)
+
+
+typedef union
+{
+ char __size[__SIZEOF_SEM_T];
+ long int __align;
+} sem_t;
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S
new file mode 100644
index 000000000..4b81653b6
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S
@@ -0,0 +1,115 @@
+/* Copyright (C) 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2009.
+
+ 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 <tcb-offsets.h>
+#include <bits/kernel-features.h>
+#include "lowlevellock.h"
+
+#ifdef IS_IN_libpthread
+# ifdef SHARED
+# define __pthread_unwind __GI___pthread_unwind
+# endif
+#else
+# ifndef SHARED
+ .weak __pthread_unwind
+# endif
+#endif
+
+
+#ifdef __ASSUME_PRIVATE_FUTEX
+# define LOAD_PRIVATE_FUTEX_WAIT(reg) \
+ movl $(FUTEX_WAIT | FUTEX_PRIVATE_FLAG), reg
+#else
+# if FUTEX_WAIT == 0
+# define LOAD_PRIVATE_FUTEX_WAIT(reg) \
+ movl %fs:PRIVATE_FUTEX, reg
+# else
+# define LOAD_PRIVATE_FUTEX_WAIT(reg) \
+ movl %fs:PRIVATE_FUTEX, reg ; \
+ orl $FUTEX_WAIT, reg
+# endif
+#endif
+
+/* It is crucial that the functions in this file don't modify registers
+ other than %rax and %r11. The syscall wrapper code depends on this
+ because it doesn't explicitly save the other registers which hold
+ relevant values. */
+ .text
+
+ .hidden __pthread_enable_asynccancel
+ENTRY(__pthread_enable_asynccancel)
+ movl %fs:CANCELHANDLING, %eax
+2: movl %eax, %r11d
+ orl $TCB_CANCELTYPE_BITMASK, %r11d
+ cmpl %eax, %r11d
+ je 1f
+
+ lock
+ cmpxchgl %r11d, %fs:CANCELHANDLING
+ jnz 2b
+
+ andl $(TCB_CANCELSTATE_BITMASK|TCB_CANCELTYPE_BITMASK|TCB_CANCELED_BITMASK|TCB_EXITING_BITMASK|TCB_CANCEL_RESTMASK|TCB_TERMINATED_BITMASK), %r11d
+ cmpl $(TCB_CANCELTYPE_BITMASK|TCB_CANCELED_BITMASK), %r11d
+ je 3f
+
+1: ret
+
+3: movq $TCB_PTHREAD_CANCELED, %fs:RESULT
+ lock
+ orl $TCB_EXITING_BITMASK, %fs:CANCELHANDLING
+ movq %fs:CLEANUP_JMP_BUF, %rdi
+#ifdef SHARED
+ call __pthread_unwind@PLT
+#else
+ call __pthread_unwind
+#endif
+ hlt
+END(__pthread_enable_asynccancel)
+
+
+ .hidden __pthread_disable_asynccancel
+ENTRY(__pthread_disable_asynccancel)
+ testl $TCB_CANCELTYPE_BITMASK, %edi
+ jnz 1f
+
+ movl %fs:CANCELHANDLING, %eax
+2: movl %eax, %r11d
+ andl $~TCB_CANCELTYPE_BITMASK, %r11d
+ lock
+ cmpxchgl %r11d, %fs:CANCELHANDLING
+ jnz 2b
+
+ movl %r11d, %eax
+3: andl $(TCB_CANCELING_BITMASK|TCB_CANCELED_BITMASK), %eax
+ cmpl $TCB_CANCELING_BITMASK, %eax
+ je 4f
+1: ret
+
+ /* Performance doesn't matter in this loop. We will
+ delay until the thread is canceled. And we will unlikely
+ enter the loop twice. */
+4: movq %fs:0, %rdi
+ movl $__NR_futex, %eax
+ xorq %r10, %r10
+ addq $CANCELHANDLING, %rdi
+ LOAD_PRIVATE_FUTEX_WAIT (%esi)
+ syscall
+ movl %fs:CANCELHANDLING, %eax
+ jmp 3b
+END(__pthread_disable_asynccancel)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/clone.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/clone.S
new file mode 100644
index 000000000..efbaee3d1
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/clone.S
@@ -0,0 +1,3 @@
+#include <tcb-offsets.h>
+#define RESET_PID
+#include <libc/sysdeps/linux/x86_64/clone.S>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/compat-timer.h b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/compat-timer.h
new file mode 100644
index 000000000..be5b2a62d
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/compat-timer.h
@@ -0,0 +1,45 @@
+/* Copyright (C) 2003 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; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <signal.h>
+#include <time.h>
+#include <sys/types.h>
+
+#define OLD_TIMER_MAX 256
+
+extern timer_t __compat_timer_list[OLD_TIMER_MAX] attribute_hidden;
+
+
+extern int __timer_create_new (clockid_t clock_id, struct sigevent *evp,
+ timer_t *timerid);
+extern int __timer_delete_new (timer_t timerid);
+extern int __timer_getoverrun_new (timer_t timerid);
+extern int __timer_gettime_new (timer_t timerid, struct itimerspec *value);
+extern int __timer_settime_new (timer_t timerid, int flags,
+ const struct itimerspec *value,
+ struct itimerspec *ovalue);
+
+
+extern int __timer_create_old (clockid_t clock_id, struct sigevent *evp,
+ int *timerid);
+extern int __timer_delete_old (int timerid);
+extern int __timer_getoverrun_old (int timerid);
+extern int __timer_gettime_old (int timerid, struct itimerspec *value);
+extern int __timer_settime_old (int timerid, int flags,
+ const struct itimerspec *value,
+ struct itimerspec *ovalue);
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/fork.c b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/fork.c
new file mode 100644
index 000000000..dedbabdee
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/fork.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 2003 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 <sched.h>
+#include <signal.h>
+#include <sysdep.h>
+#include <tls.h>
+
+
+#define ARCH_FORK() \
+ INLINE_SYSCALL (clone, 4, \
+ CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID | SIGCHLD, 0, \
+ NULL, &THREAD_SELF->tid)
+
+#include "../fork.c"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/libc-cancellation.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/libc-cancellation.S
new file mode 100644
index 000000000..1c4fc73d0
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/libc-cancellation.S
@@ -0,0 +1,21 @@
+/* Copyright (C) 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2009.
+
+ 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 __pthread_enable_asynccancel __libc_enable_asynccancel
+#define __pthread_disable_asynccancel __libc_disable_asynccancel
+#include "cancellation.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/libc-lowlevellock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/libc-lowlevellock.S
new file mode 100644
index 000000000..74dda472f
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/libc-lowlevellock.S
@@ -0,0 +1,19 @@
+/* Copyright (C) 2002, 2003, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 "lowlevellock.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/librt-cancellation.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/librt-cancellation.S
new file mode 100644
index 000000000..47d7dce2e
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/librt-cancellation.S
@@ -0,0 +1,21 @@
+/* Copyright (C) 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2009.
+
+ 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 __pthread_enable_asynccancel __librt_enable_asynccancel
+#define __pthread_disable_asynccancel __librt_disable_asynccancel
+#include "cancellation.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
new file mode 100644
index 000000000..894c6833b
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
@@ -0,0 +1,462 @@
+/* Copyright (C) 2002-2006, 2007, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread-errnos.h>
+#include <bits/kernel-features.h>
+#include <lowlevellock.h>
+#include <tcb-offsets.h>
+
+ .text
+
+#ifdef __ASSUME_PRIVATE_FUTEX
+# define LOAD_PRIVATE_FUTEX_WAIT(reg) \
+ movl $(FUTEX_WAIT | FUTEX_PRIVATE_FLAG), reg
+# define LOAD_PRIVATE_FUTEX_WAKE(reg) \
+ movl $(FUTEX_WAKE | FUTEX_PRIVATE_FLAG), reg
+# define LOAD_FUTEX_WAIT(reg) \
+ xorl $(FUTEX_WAIT | FUTEX_PRIVATE_FLAG), reg
+# define LOAD_FUTEX_WAIT_ABS(reg) \
+ xorl $(FUTEX_WAIT_BITSET | FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME), reg
+# define LOAD_FUTEX_WAKE(reg) \
+ xorl $(FUTEX_WAKE | FUTEX_PRIVATE_FLAG), reg
+#else
+# if FUTEX_WAIT == 0
+# define LOAD_PRIVATE_FUTEX_WAIT(reg) \
+ movl %fs:PRIVATE_FUTEX, reg
+# else
+# define LOAD_PRIVATE_FUTEX_WAIT(reg) \
+ movl %fs:PRIVATE_FUTEX, reg ; \
+ orl $FUTEX_WAIT, reg
+# endif
+# define LOAD_PRIVATE_FUTEX_WAKE(reg) \
+ movl %fs:PRIVATE_FUTEX, reg ; \
+ orl $FUTEX_WAKE, reg
+# if FUTEX_WAIT == 0
+# define LOAD_FUTEX_WAIT(reg) \
+ xorl $FUTEX_PRIVATE_FLAG, reg ; \
+ andl %fs:PRIVATE_FUTEX, reg
+# else
+# define LOAD_FUTEX_WAIT(reg) \
+ xorl $FUTEX_PRIVATE_FLAG, reg ; \
+ andl %fs:PRIVATE_FUTEX, reg ; \
+ orl $FUTEX_WAIT, reg
+# endif
+# define LOAD_FUTEX_WAIT_ABS(reg) \
+ xorl $FUTEX_PRIVATE_FLAG, reg ; \
+ andl %fs:PRIVATE_FUTEX, reg ; \
+ orl $FUTEX_WAIT_BITSET | FUTEX_CLOCK_REALTIME, reg
+# define LOAD_FUTEX_WAKE(reg) \
+ xorl $FUTEX_PRIVATE_FLAG, reg ; \
+ andl %fs:PRIVATE_FUTEX, reg ; \
+ orl $FUTEX_WAKE, reg
+#endif
+
+
+/* For the calculation see asm/vsyscall.h. */
+#define VSYSCALL_ADDR_vgettimeofday 0xffffffffff600000
+
+
+ .globl __lll_lock_wait_private
+ .type __lll_lock_wait_private,@function
+ .hidden __lll_lock_wait_private
+#ifndef IS_IN_libpthread
+ .weak __lll_lock_wait_private
+#endif
+ .align 16
+__lll_lock_wait_private:
+ cfi_startproc
+ pushq %r10
+ cfi_adjust_cfa_offset(8)
+ pushq %rdx
+ cfi_adjust_cfa_offset(8)
+ cfi_offset(%r10, -16)
+ cfi_offset(%rdx, -24)
+ xorq %r10, %r10 /* No timeout. */
+ movl $2, %edx
+ LOAD_PRIVATE_FUTEX_WAIT (%esi)
+
+ cmpl %edx, %eax /* NB: %edx == 2 */
+ jne 2f
+
+1: movl $SYS_futex, %eax
+ syscall
+
+2: movl %edx, %eax
+ xchgl %eax, (%rdi) /* NB: lock is implied */
+
+ testl %eax, %eax
+ jnz 1b
+
+ popq %rdx
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%rdx)
+ popq %r10
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r10)
+ retq
+ cfi_endproc
+ .size __lll_lock_wait_private,.-__lll_lock_wait_private
+
+#ifdef NOT_IN_libc
+ .globl __lll_lock_wait
+ .type __lll_lock_wait,@function
+ .hidden __lll_lock_wait
+ .align 16
+__lll_lock_wait:
+ cfi_startproc
+ pushq %r10
+ cfi_adjust_cfa_offset(8)
+ pushq %rdx
+ cfi_adjust_cfa_offset(8)
+ cfi_offset(%r10, -16)
+ cfi_offset(%rdx, -24)
+ xorq %r10, %r10 /* No timeout. */
+ movl $2, %edx
+ LOAD_FUTEX_WAIT (%esi)
+
+ cmpl %edx, %eax /* NB: %edx == 2 */
+ jne 2f
+
+1: movl $SYS_futex, %eax
+ syscall
+
+2: movl %edx, %eax
+ xchgl %eax, (%rdi) /* NB: lock is implied */
+
+ testl %eax, %eax
+ jnz 1b
+
+ popq %rdx
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%rdx)
+ popq %r10
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r10)
+ retq
+ cfi_endproc
+ .size __lll_lock_wait,.-__lll_lock_wait
+
+ /* %rdi: futex
+ %rsi: flags
+ %rdx: timeout
+ %eax: futex value
+ */
+ .globl __lll_timedlock_wait
+ .type __lll_timedlock_wait,@function
+ .hidden __lll_timedlock_wait
+ .align 16
+__lll_timedlock_wait:
+ cfi_startproc
+# ifndef __ASSUME_FUTEX_CLOCK_REALTIME
+# ifdef __PIC__
+ cmpl $0, __have_futex_clock_realtime@GOTOFF(%rip)
+# else
+ cmpl $0, __have_futex_clock_realtime
+# endif
+ je .Lreltmo
+# endif
+
+ pushq %r9
+ cfi_adjust_cfa_offset(8)
+ cfi_rel_offset(%r9, 0)
+ movq %rdx, %r10
+ movl $0xffffffff, %r9d
+ LOAD_FUTEX_WAIT_ABS (%esi)
+
+ movl $2, %edx
+ cmpl %edx, %eax
+ jne 2f
+
+1: movl $SYS_futex, %eax
+ movl $2, %edx
+ syscall
+
+2: xchgl %edx, (%rdi) /* NB: lock is implied */
+
+ testl %edx, %edx
+ jz 3f
+
+ cmpl $-ETIMEDOUT, %eax
+ je 4f
+ cmpl $-EINVAL, %eax
+ jne 1b
+4: movl %eax, %edx
+ negl %edx
+
+3: movl %edx, %eax
+ popq %r9
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r9)
+ retq
+
+# ifndef __ASSUME_FUTEX_CLOCK_REALTIME
+.Lreltmo:
+ /* Check for a valid timeout value. */
+ cmpq $1000000000, 8(%rdx)
+ jae 3f
+
+ pushq %r8
+ cfi_adjust_cfa_offset(8)
+ pushq %r9
+ cfi_adjust_cfa_offset(8)
+ pushq %r12
+ cfi_adjust_cfa_offset(8)
+ pushq %r13
+ cfi_adjust_cfa_offset(8)
+ pushq %r14
+ cfi_adjust_cfa_offset(8)
+ cfi_offset(%r8, -16)
+ cfi_offset(%r9, -24)
+ cfi_offset(%r12, -32)
+ cfi_offset(%r13, -40)
+ cfi_offset(%r14, -48)
+ pushq %rsi
+ cfi_adjust_cfa_offset(8)
+
+ /* Stack frame for the timespec and timeval structs. */
+ subq $24, %rsp
+ cfi_adjust_cfa_offset(24)
+
+ movq %rdi, %r12
+ movq %rdx, %r13
+
+ movl $2, %edx
+ xchgl %edx, (%r12)
+
+ testl %edx, %edx
+ je 6f
+
+1:
+ /* Get current time. */
+ movq %rsp, %rdi
+ xorl %esi, %esi
+ movq $VSYSCALL_ADDR_vgettimeofday, %rax
+ /* This is a regular function call, all caller-save registers
+ might be clobbered. */
+ callq *%rax
+
+ /* Compute relative timeout. */
+ movq 8(%rsp), %rax
+ movl $1000, %edi
+ mul %rdi /* Milli seconds to nano seconds. */
+ movq (%r13), %rdi
+ movq 8(%r13), %rsi
+ subq (%rsp), %rdi
+ subq %rax, %rsi
+ jns 4f
+ addq $1000000000, %rsi
+ decq %rdi
+4: testq %rdi, %rdi
+ js 2f /* Time is already up. */
+
+ /* Store relative timeout. */
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+
+ /* Futex call. */
+ movl $2, %edx
+ movl $1, %eax
+ movq %rsp, %r10
+ movl 24(%rsp), %esi
+ LOAD_FUTEX_WAIT (%esi)
+ movq %r12, %rdi
+ movl $SYS_futex, %eax
+ syscall
+
+ /* NB: %edx == 2 */
+ xchgl %edx, (%r12)
+
+ testl %edx, %edx
+ je 6f
+
+ cmpl $-ETIMEDOUT, %eax
+ jne 1b
+2: movl $ETIMEDOUT, %edx
+
+6: addq $32, %rsp
+ cfi_adjust_cfa_offset(-32)
+ popq %r14
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r14)
+ popq %r13
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r13)
+ popq %r12
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r12)
+ popq %r9
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r9)
+ popq %r8
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r8)
+ movl %edx, %eax
+ retq
+
+3: movl $EINVAL, %eax
+ retq
+# endif
+ cfi_endproc
+ .size __lll_timedlock_wait,.-__lll_timedlock_wait
+#endif
+
+
+ .globl __lll_unlock_wake_private
+ .type __lll_unlock_wake_private,@function
+ .hidden __lll_unlock_wake_private
+#ifndef IS_IN_libpthread
+ .weak __lll_unlock_wake_private
+#endif
+ .align 16
+__lll_unlock_wake_private:
+ cfi_startproc
+ pushq %rsi
+ cfi_adjust_cfa_offset(8)
+ pushq %rdx
+ cfi_adjust_cfa_offset(8)
+ cfi_offset(%rsi, -16)
+ cfi_offset(%rdx, -24)
+
+ movl $0, (%rdi)
+ LOAD_PRIVATE_FUTEX_WAKE (%esi)
+ movl $1, %edx /* Wake one thread. */
+ movl $SYS_futex, %eax
+ syscall
+
+ popq %rdx
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%rdx)
+ popq %rsi
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%rsi)
+ retq
+ cfi_endproc
+ .size __lll_unlock_wake_private,.-__lll_unlock_wake_private
+
+#ifdef NOT_IN_libc
+ .globl __lll_unlock_wake
+ .type __lll_unlock_wake,@function
+ .hidden __lll_unlock_wake
+ .align 16
+__lll_unlock_wake:
+ cfi_startproc
+ pushq %rsi
+ cfi_adjust_cfa_offset(8)
+ pushq %rdx
+ cfi_adjust_cfa_offset(8)
+ cfi_offset(%rsi, -16)
+ cfi_offset(%rdx, -24)
+
+ movl $0, (%rdi)
+ LOAD_FUTEX_WAKE (%esi)
+ movl $1, %edx /* Wake one thread. */
+ movl $SYS_futex, %eax
+ syscall
+
+ popq %rdx
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%rdx)
+ popq %rsi
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%rsi)
+ retq
+ cfi_endproc
+ .size __lll_unlock_wake,.-__lll_unlock_wake
+
+ .globl __lll_timedwait_tid
+ .type __lll_timedwait_tid,@function
+ .hidden __lll_timedwait_tid
+ .align 16
+__lll_timedwait_tid:
+ cfi_startproc
+ pushq %r12
+ cfi_adjust_cfa_offset(8)
+ pushq %r13
+ cfi_adjust_cfa_offset(8)
+ cfi_offset(%r12, -16)
+ cfi_offset(%r13, -24)
+
+ movq %rdi, %r12
+ movq %rsi, %r13
+
+ subq $16, %rsp
+ cfi_adjust_cfa_offset(16)
+
+ /* Get current time. */
+2: movq %rsp, %rdi
+ xorl %esi, %esi
+ movq $VSYSCALL_ADDR_vgettimeofday, %rax
+ callq *%rax
+
+ /* Compute relative timeout. */
+ movq 8(%rsp), %rax
+ movl $1000, %edi
+ mul %rdi /* Milli seconds to nano seconds. */
+ movq (%r13), %rdi
+ movq 8(%r13), %rsi
+ subq (%rsp), %rdi
+ subq %rax, %rsi
+ jns 5f
+ addq $1000000000, %rsi
+ decq %rdi
+5: testq %rdi, %rdi
+ js 6f /* Time is already up. */
+
+ movq %rdi, (%rsp) /* Store relative timeout. */
+ movq %rsi, 8(%rsp)
+
+ movl (%r12), %edx
+ testl %edx, %edx
+ jz 4f
+
+ movq %rsp, %r10
+ /* XXX The kernel so far uses global futex for the wakeup at
+ all times. */
+#if FUTEX_WAIT == 0
+ xorl %esi, %esi
+#else
+ movl $FUTEX_WAIT, %esi
+#endif
+ movq %r12, %rdi
+ movl $SYS_futex, %eax
+ syscall
+
+ cmpl $0, (%rdi)
+ jne 1f
+4: xorl %eax, %eax
+
+8: addq $16, %rsp
+ cfi_adjust_cfa_offset(-16)
+ popq %r13
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r13)
+ popq %r12
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r12)
+ retq
+
+ cfi_adjust_cfa_offset(32)
+1: cmpq $-ETIMEDOUT, %rax
+ jne 2b
+
+6: movl $ETIMEDOUT, %eax
+ jmp 8b
+ cfi_endproc
+ .size __lll_timedwait_tid,.-__lll_timedwait_tid
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
new file mode 100644
index 000000000..c0e8c0303
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
@@ -0,0 +1,597 @@
+/* Copyright (C) 2002-2004, 2006-2008, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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/>. */
+
+#ifndef _LOWLEVELLOCK_H
+#define _LOWLEVELLOCK_H 1
+
+#ifndef __ASSEMBLER__
+# include <time.h>
+# include <sys/param.h>
+# include <bits/pthreadtypes.h>
+# include <bits/kernel-features.h>
+# include <tcb-offsets.h>
+
+# ifndef LOCK_INSTR
+# ifdef UP
+# define LOCK_INSTR /* nothing */
+# else
+# define LOCK_INSTR "lock;"
+# endif
+# endif
+#else
+# ifndef LOCK
+# ifdef UP
+# define LOCK
+# else
+# define LOCK lock
+# endif
+# endif
+#endif
+
+#define FUTEX_WAIT 0
+#define FUTEX_WAKE 1
+#define FUTEX_CMP_REQUEUE 4
+#define FUTEX_WAKE_OP 5
+#define FUTEX_LOCK_PI 6
+#define FUTEX_UNLOCK_PI 7
+#define FUTEX_TRYLOCK_PI 8
+#define FUTEX_WAIT_BITSET 9
+#define FUTEX_WAKE_BITSET 10
+#define FUTEX_WAIT_REQUEUE_PI 11
+#define FUTEX_CMP_REQUEUE_PI 12
+#define FUTEX_PRIVATE_FLAG 128
+#define FUTEX_CLOCK_REALTIME 256
+
+#define FUTEX_BITSET_MATCH_ANY 0xffffffff
+
+#define FUTEX_OP_CLEAR_WAKE_IF_GT_ONE ((4 << 24) | 1)
+
+/* Values for 'private' parameter of locking macros. Yes, the
+ definition seems to be backwards. But it is not. The bit will be
+ reversed before passing to the system call. */
+#define LLL_PRIVATE 0
+#define LLL_SHARED FUTEX_PRIVATE_FLAG
+
+#ifndef __ASSEMBLER__
+
+#if !defined NOT_IN_libc || defined IS_IN_rtld
+/* In libc.so or ld.so all futexes are private. */
+# ifdef __ASSUME_PRIVATE_FUTEX
+# define __lll_private_flag(fl, private) \
+ ((fl) | FUTEX_PRIVATE_FLAG)
+# else
+# define __lll_private_flag(fl, private) \
+ ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex))
+# endif
+#else
+# ifdef __ASSUME_PRIVATE_FUTEX
+# define __lll_private_flag(fl, private) \
+ (((fl) | FUTEX_PRIVATE_FLAG) ^ (private))
+# else
+# define __lll_private_flag(fl, private) \
+ (__builtin_constant_p (private) \
+ ? ((private) == 0 \
+ ? ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex)) \
+ : (fl)) \
+ : ({ unsigned int __fl = ((private) ^ FUTEX_PRIVATE_FLAG); \
+ __asm__ ("andl %%fs:%P1, %0" : "+r" (__fl) \
+ : "i" (offsetof (struct pthread, header.private_futex))); \
+ __fl | (fl); }))
+# endif
+#endif
+
+/* Initializer for lock. */
+#define LLL_LOCK_INITIALIZER (0)
+#define LLL_LOCK_INITIALIZER_LOCKED (1)
+#define LLL_LOCK_INITIALIZER_WAITERS (2)
+
+/* Delay in spinlock loop. */
+#define BUSY_WAIT_NOP __asm__ ("rep; nop")
+
+
+#define LLL_STUB_UNWIND_INFO_START \
+ ".section .eh_frame,\"a\",@progbits\n" \
+"7:\t" ".long 9f-8f # Length of Common Information Entry\n" \
+"8:\t" ".long 0x0 # CIE Identifier Tag\n\t" \
+ ".byte 0x1 # CIE Version\n\t" \
+ ".ascii \"zR\\0\" # CIE Augmentation\n\t" \
+ ".uleb128 0x1 # CIE Code Alignment Factor\n\t" \
+ ".sleb128 -8 # CIE Data Alignment Factor\n\t" \
+ ".byte 0x10 # CIE RA Column\n\t" \
+ ".uleb128 0x1 # Augmentation size\n\t" \
+ ".byte 0x1b # FDE Encoding (pcrel sdata4)\n\t" \
+ ".byte 0x12 # DW_CFA_def_cfa_sf\n\t" \
+ ".uleb128 0x7\n\t" \
+ ".sleb128 16\n\t" \
+ ".align 8\n" \
+"9:\t" ".long 23f-10f # FDE Length\n" \
+"10:\t" ".long 10b-7b # FDE CIE offset\n\t" \
+ ".long 1b-. # FDE initial location\n\t" \
+ ".long 6b-1b # FDE address range\n\t" \
+ ".uleb128 0x0 # Augmentation size\n\t" \
+ ".byte 0x16 # DW_CFA_val_expression\n\t" \
+ ".uleb128 0x10\n\t" \
+ ".uleb128 12f-11f\n" \
+"11:\t" ".byte 0x80 # DW_OP_breg16\n\t" \
+ ".sleb128 4b-1b\n"
+#define LLL_STUB_UNWIND_INFO_END \
+ ".byte 0x16 # DW_CFA_val_expression\n\t" \
+ ".uleb128 0x10\n\t" \
+ ".uleb128 14f-13f\n" \
+"13:\t" ".byte 0x80 # DW_OP_breg16\n\t" \
+ ".sleb128 4b-2b\n" \
+"14:\t" ".byte 0x40 + (3b-2b) # DW_CFA_advance_loc\n\t" \
+ ".byte 0x0e # DW_CFA_def_cfa_offset\n\t" \
+ ".uleb128 0\n\t" \
+ ".byte 0x16 # DW_CFA_val_expression\n\t" \
+ ".uleb128 0x10\n\t" \
+ ".uleb128 16f-15f\n" \
+"15:\t" ".byte 0x80 # DW_OP_breg16\n\t" \
+ ".sleb128 4b-3b\n" \
+"16:\t" ".byte 0x40 + (4b-3b-1) # DW_CFA_advance_loc\n\t" \
+ ".byte 0x0e # DW_CFA_def_cfa_offset\n\t" \
+ ".uleb128 128\n\t" \
+ ".byte 0x16 # DW_CFA_val_expression\n\t" \
+ ".uleb128 0x10\n\t" \
+ ".uleb128 20f-17f\n" \
+"17:\t" ".byte 0x80 # DW_OP_breg16\n\t" \
+ ".sleb128 19f-18f\n\t" \
+ ".byte 0x0d # DW_OP_const4s\n" \
+"18:\t" ".4byte 4b-.\n\t" \
+ ".byte 0x1c # DW_OP_minus\n\t" \
+ ".byte 0x0d # DW_OP_const4s\n" \
+"19:\t" ".4byte 24f-.\n\t" \
+ ".byte 0x22 # DW_OP_plus\n" \
+"20:\t" ".byte 0x40 + (5b-4b+1) # DW_CFA_advance_loc\n\t" \
+ ".byte 0x13 # DW_CFA_def_cfa_offset_sf\n\t" \
+ ".sleb128 16\n\t" \
+ ".byte 0x16 # DW_CFA_val_expression\n\t" \
+ ".uleb128 0x10\n\t" \
+ ".uleb128 22f-21f\n" \
+"21:\t" ".byte 0x80 # DW_OP_breg16\n\t" \
+ ".sleb128 4b-5b\n" \
+"22:\t" ".align 8\n" \
+"23:\t" ".previous\n"
+
+/* Unwind info for
+ 1: leaq ..., %rdi
+ 2: subq $128, %rsp
+ 3: callq ...
+ 4: addq $128, %rsp
+ 5: jmp 24f
+ 6:
+ snippet. */
+#define LLL_STUB_UNWIND_INFO_5 \
+LLL_STUB_UNWIND_INFO_START \
+"12:\t" ".byte 0x40 + (2b-1b) # DW_CFA_advance_loc\n\t" \
+LLL_STUB_UNWIND_INFO_END
+
+/* Unwind info for
+ 1: leaq ..., %rdi
+ 0: movq ..., %rdx
+ 2: subq $128, %rsp
+ 3: callq ...
+ 4: addq $128, %rsp
+ 5: jmp 24f
+ 6:
+ snippet. */
+#define LLL_STUB_UNWIND_INFO_6 \
+LLL_STUB_UNWIND_INFO_START \
+"12:\t" ".byte 0x40 + (0b-1b) # DW_CFA_advance_loc\n\t" \
+ ".byte 0x16 # DW_CFA_val_expression\n\t" \
+ ".uleb128 0x10\n\t" \
+ ".uleb128 26f-25f\n" \
+"25:\t" ".byte 0x80 # DW_OP_breg16\n\t" \
+ ".sleb128 4b-0b\n" \
+"26:\t" ".byte 0x40 + (2b-0b) # DW_CFA_advance_loc\n\t" \
+LLL_STUB_UNWIND_INFO_END
+
+
+#define lll_futex_wait(futex, val, private) \
+ lll_futex_timed_wait(futex, val, NULL, private)
+
+
+#define lll_futex_timed_wait(futex, val, timeout, private) \
+ ({ \
+ register const struct timespec *__to __asm__ ("r10") = timeout; \
+ int __status; \
+ register __typeof (val) _val __asm__ ("edx") = (val); \
+ __asm__ __volatile__ ("syscall" \
+ : "=a" (__status) \
+ : "0" (SYS_futex), "D" (futex), \
+ "S" (__lll_private_flag (FUTEX_WAIT, private)), \
+ "d" (_val), "r" (__to) \
+ : "memory", "cc", "r11", "cx"); \
+ __status; \
+ })
+
+
+#define lll_futex_wake(futex, nr, private) \
+ do { \
+ int __ignore; \
+ register __typeof (nr) _nr __asm__ ("edx") = (nr); \
+ __asm__ __volatile__ ("syscall" \
+ : "=a" (__ignore) \
+ : "0" (SYS_futex), "D" (futex), \
+ "S" (__lll_private_flag (FUTEX_WAKE, private)), \
+ "d" (_nr) \
+ : "memory", "cc", "r10", "r11", "cx"); \
+ } while (0)
+
+
+/* NB: in the lll_trylock macro we simply return the value in %eax
+ after the cmpxchg instruction. In case the operation succeded this
+ value is zero. In case the operation failed, the cmpxchg instruction
+ has loaded the current value of the memory work which is guaranteed
+ to be nonzero. */
+#if defined NOT_IN_libc || defined UP
+# define __lll_trylock_asm LOCK_INSTR "cmpxchgl %2, %1"
+#else
+# define __lll_trylock_asm "cmpl $0, __libc_multiple_threads(%%rip)\n\t" \
+ "je 0f\n\t" \
+ "lock; cmpxchgl %2, %1\n\t" \
+ "jmp 1f\n\t" \
+ "0:\tcmpxchgl %2, %1\n\t" \
+ "1:"
+#endif
+
+#define lll_trylock(futex) \
+ ({ int ret; \
+ __asm__ __volatile__ (__lll_trylock_asm \
+ : "=a" (ret), "=m" (futex) \
+ : "r" (LLL_LOCK_INITIALIZER_LOCKED), "m" (futex), \
+ "0" (LLL_LOCK_INITIALIZER) \
+ : "memory"); \
+ ret; })
+
+#define lll_robust_trylock(futex, id) \
+ ({ int ret; \
+ __asm__ __volatile__ (LOCK_INSTR "cmpxchgl %2, %1" \
+ : "=a" (ret), "=m" (futex) \
+ : "r" (id), "m" (futex), "0" (LLL_LOCK_INITIALIZER) \
+ : "memory"); \
+ ret; })
+
+#define lll_cond_trylock(futex) \
+ ({ int ret; \
+ __asm__ __volatile__ (LOCK_INSTR "cmpxchgl %2, %1" \
+ : "=a" (ret), "=m" (futex) \
+ : "r" (LLL_LOCK_INITIALIZER_WAITERS), \
+ "m" (futex), "0" (LLL_LOCK_INITIALIZER) \
+ : "memory"); \
+ ret; })
+
+#if defined NOT_IN_libc || defined UP
+# define __lll_lock_asm_start LOCK_INSTR "cmpxchgl %4, %2\n\t" \
+ "jnz 1f\n\t"
+#else
+# define __lll_lock_asm_start "cmpl $0, __libc_multiple_threads(%%rip)\n\t" \
+ "je 0f\n\t" \
+ "lock; cmpxchgl %4, %2\n\t" \
+ "jnz 1f\n\t" \
+ "jmp 24f\n" \
+ "0:\tcmpxchgl %4, %2\n\t" \
+ "jnz 1f\n\t"
+#endif
+
+#define lll_lock(futex, private) \
+ (void) \
+ ({ int ignore1, ignore2, ignore3; \
+ if (__builtin_constant_p (private) && (private) == LLL_PRIVATE) \
+ __asm__ __volatile__ (__lll_lock_asm_start \
+ ".subsection 1\n\t" \
+ ".type _L_lock_%=, @function\n" \
+ "_L_lock_%=:\n" \
+ "1:\tleaq %2, %%rdi\n" \
+ "2:\tsubq $128, %%rsp\n" \
+ "3:\tcallq __lll_lock_wait_private\n" \
+ "4:\taddq $128, %%rsp\n" \
+ "5:\tjmp 24f\n" \
+ "6:\t.size _L_lock_%=, 6b-1b\n\t" \
+ ".previous\n" \
+ LLL_STUB_UNWIND_INFO_5 \
+ "24:" \
+ : "=S" (ignore1), "=&D" (ignore2), "=m" (futex), \
+ "=a" (ignore3) \
+ : "0" (1), "m" (futex), "3" (0) \
+ : "cx", "r11", "cc", "memory"); \
+ else \
+ __asm__ __volatile__ (__lll_lock_asm_start \
+ ".subsection 1\n\t" \
+ ".type _L_lock_%=, @function\n" \
+ "_L_lock_%=:\n" \
+ "1:\tleaq %2, %%rdi\n" \
+ "2:\tsubq $128, %%rsp\n" \
+ "3:\tcallq __lll_lock_wait\n" \
+ "4:\taddq $128, %%rsp\n" \
+ "5:\tjmp 24f\n" \
+ "6:\t.size _L_lock_%=, 6b-1b\n\t" \
+ ".previous\n" \
+ LLL_STUB_UNWIND_INFO_5 \
+ "24:" \
+ : "=S" (ignore1), "=D" (ignore2), "=m" (futex), \
+ "=a" (ignore3) \
+ : "1" (1), "m" (futex), "3" (0), "0" (private) \
+ : "cx", "r11", "cc", "memory"); \
+ }) \
+
+#define lll_robust_lock(futex, id, private) \
+ ({ int __ret, ignore1, ignore2; \
+ __asm__ __volatile__ (LOCK_INSTR "cmpxchgl %4, %2\n\t" \
+ "jnz 1f\n\t" \
+ ".subsection 1\n\t" \
+ ".type _L_robust_lock_%=, @function\n" \
+ "_L_robust_lock_%=:\n" \
+ "1:\tleaq %2, %%rdi\n" \
+ "2:\tsubq $128, %%rsp\n" \
+ "3:\tcallq __lll_robust_lock_wait\n" \
+ "4:\taddq $128, %%rsp\n" \
+ "5:\tjmp 24f\n" \
+ "6:\t.size _L_robust_lock_%=, 6b-1b\n\t" \
+ ".previous\n" \
+ LLL_STUB_UNWIND_INFO_5 \
+ "24:" \
+ : "=S" (ignore1), "=D" (ignore2), "=m" (futex), \
+ "=a" (__ret) \
+ : "1" (id), "m" (futex), "3" (0), "0" (private) \
+ : "cx", "r11", "cc", "memory"); \
+ __ret; })
+
+#define lll_cond_lock(futex, private) \
+ (void) \
+ ({ int ignore1, ignore2, ignore3; \
+ __asm__ __volatile__ (LOCK_INSTR "cmpxchgl %4, %2\n\t" \
+ "jnz 1f\n\t" \
+ ".subsection 1\n\t" \
+ ".type _L_cond_lock_%=, @function\n" \
+ "_L_cond_lock_%=:\n" \
+ "1:\tleaq %2, %%rdi\n" \
+ "2:\tsubq $128, %%rsp\n" \
+ "3:\tcallq __lll_lock_wait\n" \
+ "4:\taddq $128, %%rsp\n" \
+ "5:\tjmp 24f\n" \
+ "6:\t.size _L_cond_lock_%=, 6b-1b\n\t" \
+ ".previous\n" \
+ LLL_STUB_UNWIND_INFO_5 \
+ "24:" \
+ : "=S" (ignore1), "=D" (ignore2), "=m" (futex), \
+ "=a" (ignore3) \
+ : "1" (2), "m" (futex), "3" (0), "0" (private) \
+ : "cx", "r11", "cc", "memory"); \
+ })
+
+#define lll_robust_cond_lock(futex, id, private) \
+ ({ int __ret, ignore1, ignore2; \
+ __asm__ __volatile__ (LOCK_INSTR "cmpxchgl %4, %2\n\t" \
+ "jnz 1f\n\t" \
+ ".subsection 1\n\t" \
+ ".type _L_robust_cond_lock_%=, @function\n" \
+ "_L_robust_cond_lock_%=:\n" \
+ "1:\tleaq %2, %%rdi\n" \
+ "2:\tsubq $128, %%rsp\n" \
+ "3:\tcallq __lll_robust_lock_wait\n" \
+ "4:\taddq $128, %%rsp\n" \
+ "5:\tjmp 24f\n" \
+ "6:\t.size _L_robust_cond_lock_%=, 6b-1b\n\t" \
+ ".previous\n" \
+ LLL_STUB_UNWIND_INFO_5 \
+ "24:" \
+ : "=S" (ignore1), "=D" (ignore2), "=m" (futex), \
+ "=a" (__ret) \
+ : "1" (id | FUTEX_WAITERS), "m" (futex), "3" (0), \
+ "0" (private) \
+ : "cx", "r11", "cc", "memory"); \
+ __ret; })
+
+#define lll_timedlock(futex, timeout, private) \
+ ({ int __ret, ignore1, ignore2, ignore3; \
+ __asm__ __volatile__ (LOCK_INSTR "cmpxchgl %1, %4\n\t" \
+ "jnz 1f\n\t" \
+ ".subsection 1\n\t" \
+ ".type _L_timedlock_%=, @function\n" \
+ "_L_timedlock_%=:\n" \
+ "1:\tleaq %4, %%rdi\n" \
+ "0:\tmovq %8, %%rdx\n" \
+ "2:\tsubq $128, %%rsp\n" \
+ "3:\tcallq __lll_timedlock_wait\n" \
+ "4:\taddq $128, %%rsp\n" \
+ "5:\tjmp 24f\n" \
+ "6:\t.size _L_timedlock_%=, 6b-1b\n\t" \
+ ".previous\n" \
+ LLL_STUB_UNWIND_INFO_6 \
+ "24:" \
+ : "=a" (__ret), "=D" (ignore1), "=S" (ignore2), \
+ "=&d" (ignore3), "=m" (futex) \
+ : "0" (0), "1" (1), "m" (futex), "m" (timeout), \
+ "2" (private) \
+ : "memory", "cx", "cc", "r10", "r11"); \
+ __ret; })
+
+#define lll_robust_timedlock(futex, timeout, id, private) \
+ ({ int __ret, ignore1, ignore2, ignore3; \
+ __asm__ __volatile__ (LOCK_INSTR "cmpxchgl %1, %4\n\t" \
+ "jnz 1f\n\t" \
+ ".subsection 1\n\t" \
+ ".type _L_robust_timedlock_%=, @function\n" \
+ "_L_robust_timedlock_%=:\n" \
+ "1:\tleaq %4, %%rdi\n" \
+ "0:\tmovq %8, %%rdx\n" \
+ "2:\tsubq $128, %%rsp\n" \
+ "3:\tcallq __lll_robust_timedlock_wait\n" \
+ "4:\taddq $128, %%rsp\n" \
+ "5:\tjmp 24f\n" \
+ "6:\t.size _L_robust_timedlock_%=, 6b-1b\n\t" \
+ ".previous\n" \
+ LLL_STUB_UNWIND_INFO_6 \
+ "24:" \
+ : "=a" (__ret), "=D" (ignore1), "=S" (ignore2), \
+ "=&d" (ignore3), "=m" (futex) \
+ : "0" (0), "1" (id), "m" (futex), "m" (timeout), \
+ "2" (private) \
+ : "memory", "cx", "cc", "r10", "r11"); \
+ __ret; })
+
+#if defined NOT_IN_libc || defined UP
+# define __lll_unlock_asm_start LOCK_INSTR "decl %0\n\t" \
+ "jne 1f\n\t"
+#else
+# define __lll_unlock_asm_start "cmpl $0, __libc_multiple_threads(%%rip)\n\t" \
+ "je 0f\n\t" \
+ "lock; decl %0\n\t" \
+ "jne 1f\n\t" \
+ "jmp 24f\n\t" \
+ "0:\tdecl %0\n\t" \
+ "jne 1f\n\t"
+#endif
+
+#define lll_unlock(futex, private) \
+ (void) \
+ ({ int ignore; \
+ if (__builtin_constant_p (private) && (private) == LLL_PRIVATE) \
+ __asm__ __volatile__ (__lll_unlock_asm_start \
+ ".subsection 1\n\t" \
+ ".type _L_unlock_%=, @function\n" \
+ "_L_unlock_%=:\n" \
+ "1:\tleaq %0, %%rdi\n" \
+ "2:\tsubq $128, %%rsp\n" \
+ "3:\tcallq __lll_unlock_wake_private\n" \
+ "4:\taddq $128, %%rsp\n" \
+ "5:\tjmp 24f\n" \
+ "6:\t.size _L_unlock_%=, 6b-1b\n\t" \
+ ".previous\n" \
+ LLL_STUB_UNWIND_INFO_5 \
+ "24:" \
+ : "=m" (futex), "=&D" (ignore) \
+ : "m" (futex) \
+ : "ax", "cx", "r11", "cc", "memory"); \
+ else \
+ __asm__ __volatile__ (__lll_unlock_asm_start \
+ ".subsection 1\n\t" \
+ ".type _L_unlock_%=, @function\n" \
+ "_L_unlock_%=:\n" \
+ "1:\tleaq %0, %%rdi\n" \
+ "2:\tsubq $128, %%rsp\n" \
+ "3:\tcallq __lll_unlock_wake\n" \
+ "4:\taddq $128, %%rsp\n" \
+ "5:\tjmp 24f\n" \
+ "6:\t.size _L_unlock_%=, 6b-1b\n\t" \
+ ".previous\n" \
+ LLL_STUB_UNWIND_INFO_5 \
+ "24:" \
+ : "=m" (futex), "=&D" (ignore) \
+ : "m" (futex), "S" (private) \
+ : "ax", "cx", "r11", "cc", "memory"); \
+ })
+
+#define lll_robust_unlock(futex, private) \
+ do \
+ { \
+ int ignore; \
+ __asm__ __volatile__ (LOCK_INSTR "andl %2, %0\n\t" \
+ "jne 1f\n\t" \
+ ".subsection 1\n\t" \
+ ".type _L_robust_unlock_%=, @function\n" \
+ "_L_robust_unlock_%=:\n" \
+ "1:\tleaq %0, %%rdi\n" \
+ "2:\tsubq $128, %%rsp\n" \
+ "3:\tcallq __lll_unlock_wake\n" \
+ "4:\taddq $128, %%rsp\n" \
+ "5:\tjmp 24f\n" \
+ "6:\t.size _L_robust_unlock_%=, 6b-1b\n\t" \
+ ".previous\n" \
+ LLL_STUB_UNWIND_INFO_5 \
+ "24:" \
+ : "=m" (futex), "=&D" (ignore) \
+ : "i" (FUTEX_WAITERS), "m" (futex), \
+ "S" (private) \
+ : "ax", "cx", "r11", "cc", "memory"); \
+ } \
+ while (0)
+
+#define lll_robust_dead(futex, private) \
+ do \
+ { \
+ int ignore; \
+ __asm__ __volatile__ (LOCK_INSTR "orl %3, (%2)\n\t" \
+ "syscall" \
+ : "=m" (futex), "=a" (ignore) \
+ : "D" (&(futex)), "i" (FUTEX_OWNER_DIED), \
+ "S" (__lll_private_flag (FUTEX_WAKE, private)), \
+ "1" (__NR_futex), "d" (1) \
+ : "cx", "r11", "cc", "memory"); \
+ } \
+ while (0)
+
+/* Returns non-zero if error happened, zero if success. */
+#define lll_futex_requeue(ftx, nr_wake, nr_move, mutex, val, private) \
+ ({ int __res; \
+ register int __nr_move __asm__ ("r10") = nr_move; \
+ register void *__mutex __asm__ ("r8") = mutex; \
+ register int __val __asm__ ("r9") = val; \
+ __asm__ __volatile__ ("syscall" \
+ : "=a" (__res) \
+ : "0" (__NR_futex), "D" ((void *) ftx), \
+ "S" (__lll_private_flag (FUTEX_CMP_REQUEUE, \
+ private)), "d" (nr_wake), \
+ "r" (__nr_move), "r" (__mutex), "r" (__val) \
+ : "cx", "r11", "cc", "memory"); \
+ __res < 0; })
+
+#define lll_islocked(futex) \
+ (futex != LLL_LOCK_INITIALIZER)
+
+
+/* The kernel notifies a process with uses CLONE_CLEARTID via futex
+ wakeup when the clone terminates. The memory location contains the
+ thread ID while the clone is running and is reset to zero
+ afterwards.
+
+ The macro parameter must not have any side effect. */
+#define lll_wait_tid(tid) \
+ do { \
+ int __ignore; \
+ register __typeof (tid) _tid __asm__ ("edx") = (tid); \
+ if (_tid != 0) \
+ __asm__ __volatile__ ("xorq %%r10, %%r10\n\t" \
+ "1:\tmovq %2, %%rax\n\t" \
+ "syscall\n\t" \
+ "cmpl $0, (%%rdi)\n\t" \
+ "jne 1b" \
+ : "=&a" (__ignore) \
+ : "S" (FUTEX_WAIT), "i" (SYS_futex), "D" (&tid), \
+ "d" (_tid) \
+ : "memory", "cc", "r10", "r11", "cx"); \
+ } while (0)
+
+extern int __lll_timedwait_tid (int *tid, const struct timespec *abstime)
+ attribute_hidden;
+#define lll_timedwait_tid(tid, abstime) \
+ ({ \
+ int __ret = 0; \
+ if (tid != 0) \
+ { \
+ if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) \
+ __ret = EINVAL; \
+ else \
+ __ret = __lll_timedwait_tid (&tid, abstime); \
+ } \
+ __ret; })
+
+#endif /* !__ASSEMBLER__ */
+
+#endif /* lowlevellock.h */
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
new file mode 100644
index 000000000..fc6fd2d4a
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
@@ -0,0 +1,305 @@
+/* Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2009
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread-errnos.h>
+#include <lowlevellock.h>
+#include <lowlevelrobustlock.h>
+#include <bits/kernel-features.h>
+
+ .text
+
+#define FUTEX_WAITERS 0x80000000
+#define FUTEX_OWNER_DIED 0x40000000
+
+#ifdef __ASSUME_PRIVATE_FUTEX
+# define LOAD_FUTEX_WAIT(reg) \
+ xorl $(FUTEX_WAIT | FUTEX_PRIVATE_FLAG), reg
+# define LOAD_FUTEX_WAIT_ABS(reg) \
+ xorl $(FUTEX_WAIT_BITSET | FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME), reg
+#else
+# if FUTEX_WAIT == 0
+# define LOAD_FUTEX_WAIT(reg) \
+ xorl $FUTEX_PRIVATE_FLAG, reg ; \
+ andl %fs:PRIVATE_FUTEX, reg
+# else
+# define LOAD_FUTEX_WAIT(reg) \
+ xorl $FUTEX_PRIVATE_FLAG, reg ; \
+ andl %fs:PRIVATE_FUTEX, reg ; \
+ orl $FUTEX_WAIT, reg
+# endif
+# define LOAD_FUTEX_WAIT_ABS(reg) \
+ xorl $FUTEX_PRIVATE_FLAG, reg ; \
+ andl %fs:PRIVATE_FUTEX, reg ; \
+ orl $FUTEX_WAIT_BITSET | FUTEX_CLOCK_REALTIME, reg
+#endif
+
+/* For the calculation see asm/vsyscall.h. */
+#define VSYSCALL_ADDR_vgettimeofday 0xffffffffff600000
+
+
+ .globl __lll_robust_lock_wait
+ .type __lll_robust_lock_wait,@function
+ .hidden __lll_robust_lock_wait
+ .align 16
+__lll_robust_lock_wait:
+ cfi_startproc
+ pushq %r10
+ cfi_adjust_cfa_offset(8)
+ pushq %rdx
+ cfi_adjust_cfa_offset(8)
+ cfi_offset(%r10, -16)
+ cfi_offset(%rdx, -24)
+
+ xorq %r10, %r10 /* No timeout. */
+ LOAD_FUTEX_WAIT (%esi)
+
+4: movl %eax, %edx
+ orl $FUTEX_WAITERS, %edx
+
+ testl $FUTEX_OWNER_DIED, %eax
+ jnz 3f
+
+ cmpl %edx, %eax
+ je 1f
+
+ LOCK
+ cmpxchgl %edx, (%rdi)
+ jnz 2f
+
+1: movl $SYS_futex, %eax
+ syscall
+
+ movl (%rdi), %eax
+
+2: testl %eax, %eax
+ jne 4b
+
+ movl %fs:TID, %edx
+ orl $FUTEX_WAITERS, %edx
+ LOCK
+ cmpxchgl %edx, (%rdi)
+ jnz 4b
+ /* NB: %rax == 0 */
+
+3: popq %rdx
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%rdx)
+ popq %r10
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r10)
+ retq
+ cfi_endproc
+ .size __lll_robust_lock_wait,.-__lll_robust_lock_wait
+
+
+ .globl __lll_robust_timedlock_wait
+ .type __lll_robust_timedlock_wait,@function
+ .hidden __lll_robust_timedlock_wait
+ .align 16
+__lll_robust_timedlock_wait:
+ cfi_startproc
+# ifndef __ASSUME_FUTEX_CLOCK_REALTIME
+# ifdef __PIC__
+ cmpl $0, __have_futex_clock_realtime@GOTOFF(%rip)
+# else
+ cmpl $0, __have_futex_clock_realtime
+# endif
+ je .Lreltmo
+# endif
+
+ pushq %r9
+ cfi_adjust_cfa_offset(8)
+ cfi_rel_offset(%r9, 0)
+ movq %rdx, %r10
+ movl $0xffffffff, %r9d
+ LOAD_FUTEX_WAIT_ABS (%esi)
+
+1: testl $FUTEX_OWNER_DIED, %eax
+ jnz 3f
+
+ movl %eax, %edx
+ orl $FUTEX_WAITERS, %edx
+
+ cmpl %eax, %edx
+ je 5f
+
+ LOCK
+ cmpxchgl %edx, (%rdi)
+ movq $0, %rcx /* Must use mov to avoid changing cc. */
+ jnz 6f
+
+5: movl $SYS_futex, %eax
+ syscall
+ movl %eax, %ecx
+
+ movl (%rdi), %eax
+
+6: testl %eax, %eax
+ jne 2f
+
+ movl %fs:TID, %edx
+ orl $FUTEX_WAITERS, %edx
+ LOCK
+ cmpxchgl %edx, (%rdi)
+ jnz 2f
+
+3: popq %r9
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r9)
+ retq
+
+ cfi_adjust_cfa_offset(8)
+ cfi_rel_offset(%r9, 0)
+ /* Check whether the time expired. */
+2: cmpl $-ETIMEDOUT, %ecx
+ je 4f
+ cmpl $-EINVAL, %ecx
+ jne 1b
+
+4: movl %ecx, %eax
+ negl %eax
+ jmp 3b
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r9)
+
+
+# ifndef __ASSUME_FUTEX_CLOCK_REALTIME
+.Lreltmo:
+ /* Check for a valid timeout value. */
+ cmpq $1000000000, 8(%rdx)
+ jae 3f
+
+ pushq %r8
+ cfi_adjust_cfa_offset(8)
+ pushq %r9
+ cfi_adjust_cfa_offset(8)
+ pushq %r12
+ cfi_adjust_cfa_offset(8)
+ pushq %r13
+ cfi_adjust_cfa_offset(8)
+ cfi_offset(%r8, -16)
+ cfi_offset(%r9, -24)
+ cfi_offset(%r12, -32)
+ cfi_offset(%r13, -40)
+ pushq %rsi
+ cfi_adjust_cfa_offset(8)
+
+ /* Stack frame for the timespec and timeval structs. */
+ subq $32, %rsp
+ cfi_adjust_cfa_offset(32)
+
+ movq %rdi, %r12
+ movq %rdx, %r13
+
+1: movq %rax, 16(%rsp)
+
+ /* Get current time. */
+ movq %rsp, %rdi
+ xorl %esi, %esi
+ movq $VSYSCALL_ADDR_vgettimeofday, %rax
+ /* This is a regular function call, all caller-save registers
+ might be clobbered. */
+ callq *%rax
+
+ /* Compute relative timeout. */
+ movq 8(%rsp), %rax
+ movl $1000, %edi
+ mul %rdi /* Milli seconds to nano seconds. */
+ movq (%r13), %rdi
+ movq 8(%r13), %rsi
+ subq (%rsp), %rdi
+ subq %rax, %rsi
+ jns 4f
+ addq $1000000000, %rsi
+ decq %rdi
+4: testq %rdi, %rdi
+ js 8f /* Time is already up. */
+
+ /* Futex call. */
+ movq %rdi, (%rsp) /* Store relative timeout. */
+ movq %rsi, 8(%rsp)
+
+ movq 16(%rsp), %rdx
+ movl %edx, %eax
+ orl $FUTEX_WAITERS, %edx
+
+ testl $FUTEX_OWNER_DIED, %eax
+ jnz 6f
+
+ cmpl %eax, %edx
+ je 2f
+
+ LOCK
+ cmpxchgl %edx, (%r12)
+ movq $0, %rcx /* Must use mov to avoid changing cc. */
+ jnz 5f
+
+2: movq %rsp, %r10
+ movl 32(%rsp), %esi
+ LOAD_FUTEX_WAIT (%esi)
+ movq %r12, %rdi
+ movl $SYS_futex, %eax
+ syscall
+ movq %rax, %rcx
+
+ movl (%r12), %eax
+
+5: testl %eax, %eax
+ jne 7f
+
+ movl %fs:TID, %edx
+ orl $FUTEX_WAITERS, %edx
+ LOCK
+ cmpxchgl %edx, (%r12)
+ jnz 7f
+
+6: addq $40, %rsp
+ cfi_adjust_cfa_offset(-40)
+ popq %r13
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r13)
+ popq %r12
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r12)
+ popq %r9
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r9)
+ popq %r8
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r8)
+ retq
+
+3: movl $EINVAL, %eax
+ retq
+
+ cfi_adjust_cfa_offset(72)
+ cfi_offset(%r8, -16)
+ cfi_offset(%r9, -24)
+ cfi_offset(%r12, -32)
+ cfi_offset(%r13, -40)
+ /* Check whether the time expired. */
+7: cmpl $-ETIMEDOUT, %ecx
+ jne 1b
+
+8: movl $ETIMEDOUT, %eax
+ jmp 6b
+#endif
+ cfi_endproc
+ .size __lll_robust_timedlock_wait,.-__lll_robust_timedlock_wait
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pt-__syscall_error.c b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pt-__syscall_error.c
new file mode 100644
index 000000000..2ab81490c
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pt-__syscall_error.c
@@ -0,0 +1 @@
+#include <../../../../../../../libc/sysdeps/linux/x86_64/__syscall_error.c>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S
new file mode 100644
index 000000000..61c2f547e
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S
@@ -0,0 +1,160 @@
+/* Copyright (C) 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <lowlevellock.h>
+#include <lowlevelbarrier.h>
+
+
+ .text
+
+ .globl pthread_barrier_wait
+ .type pthread_barrier_wait,@function
+ .align 16
+pthread_barrier_wait:
+ /* Get the mutex. */
+ xorl %eax, %eax
+ movl $1, %esi
+ LOCK
+ cmpxchgl %esi, MUTEX(%rdi)
+ jnz 1f
+
+ /* One less waiter. If this was the last one needed wake
+ everybody. */
+2: decl LEFT(%rdi)
+ je 3f
+
+ /* There are more threads to come. */
+#if CURR_EVENT == 0
+ movl (%rdi), %edx
+#else
+ movl CURR_EVENT(%rdi), %edx
+#endif
+
+ /* Release the mutex. */
+ LOCK
+ decl MUTEX(%rdi)
+ jne 6f
+
+ /* Wait for the remaining threads. The call will return immediately
+ if the CURR_EVENT memory has meanwhile been changed. */
+7:
+#if FUTEX_WAIT == 0
+ movl PRIVATE(%rdi), %esi
+#else
+ movl $FUTEX_WAIT, %esi
+ orl PRIVATE(%rdi), %esi
+#endif
+ xorq %r10, %r10
+8: movl $SYS_futex, %eax
+ syscall
+
+ /* Don't return on spurious wakeups. The syscall does not change
+ any register except %eax so there is no need to reload any of
+ them. */
+#if CURR_EVENT == 0
+ cmpl %edx, (%rdi)
+#else
+ cmpl %edx, CURR_EVENT(%rdi)
+#endif
+ je 8b
+
+ /* Increment LEFT. If this brings the count back to the
+ initial count unlock the object. */
+ movl $1, %edx
+ movl INIT_COUNT(%rdi), %eax
+ LOCK
+ xaddl %edx, LEFT(%rdi)
+ subl $1, %eax
+ cmpl %eax, %edx
+ jne,pt 10f
+
+ /* Release the mutex. We cannot release the lock before
+ waking the waiting threads since otherwise a new thread might
+ arrive and gets waken up, too. */
+ LOCK
+ decl MUTEX(%rdi)
+ jne 9f
+
+10: xorl %eax, %eax /* != PTHREAD_BARRIER_SERIAL_THREAD */
+
+ retq
+
+ /* The necessary number of threads arrived. */
+3:
+#if CURR_EVENT == 0
+ incl (%rdi)
+#else
+ incl CURR_EVENT(%rdi)
+#endif
+
+ /* Wake up all waiters. The count is a signed number in the kernel
+ so 0x7fffffff is the highest value. */
+ movl $0x7fffffff, %edx
+ movl $FUTEX_WAKE, %esi
+ orl PRIVATE(%rdi), %esi
+ movl $SYS_futex, %eax
+ syscall
+
+ /* Increment LEFT. If this brings the count back to the
+ initial count unlock the object. */
+ movl $1, %edx
+ movl INIT_COUNT(%rdi), %eax
+ LOCK
+ xaddl %edx, LEFT(%rdi)
+ subl $1, %eax
+ cmpl %eax, %edx
+ jne,pt 5f
+
+ /* Release the mutex. We cannot release the lock before
+ waking the waiting threads since otherwise a new thread might
+ arrive and gets waken up, too. */
+ LOCK
+ decl MUTEX(%rdi)
+ jne 4f
+
+5: orl $-1, %eax /* == PTHREAD_BARRIER_SERIAL_THREAD */
+
+ retq
+
+1: movl PRIVATE(%rdi), %esi
+ addq $MUTEX, %rdi
+ xorl $LLL_SHARED, %esi
+ callq __lll_lock_wait
+ subq $MUTEX, %rdi
+ jmp 2b
+
+4: movl PRIVATE(%rdi), %esi
+ addq $MUTEX, %rdi
+ xorl $LLL_SHARED, %esi
+ callq __lll_unlock_wake
+ jmp 5b
+
+6: movl PRIVATE(%rdi), %esi
+ addq $MUTEX, %rdi
+ xorl $LLL_SHARED, %esi
+ callq __lll_unlock_wake
+ subq $MUTEX, %rdi
+ jmp 7b
+
+9: movl PRIVATE(%rdi), %esi
+ addq $MUTEX, %rdi
+ xorl $LLL_SHARED, %esi
+ callq __lll_unlock_wake
+ jmp 10b
+ .size pthread_barrier_wait,.-pthread_barrier_wait
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
new file mode 100644
index 000000000..988e103b8
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
@@ -0,0 +1,177 @@
+/* Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2009
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <lowlevellock.h>
+#include <lowlevelcond.h>
+#include <bits/kernel-features.h>
+#include <pthread-pi-defines.h>
+#include <pthread-errnos.h>
+
+
+ .text
+
+ /* int pthread_cond_broadcast (pthread_cond_t *cond) */
+ .globl __pthread_cond_broadcast
+ .type __pthread_cond_broadcast, @function
+ .protected __pthread_cond_broadcast
+ .align 16
+__pthread_cond_broadcast:
+
+ /* Get internal lock. */
+ movl $1, %esi
+ xorl %eax, %eax
+ LOCK
+#if cond_lock == 0
+ cmpxchgl %esi, (%rdi)
+#else
+ cmpxchgl %esi, cond_lock(%rdi)
+#endif
+ jnz 1f
+
+2: addq $cond_futex, %rdi
+ movq total_seq-cond_futex(%rdi), %r9
+ cmpq wakeup_seq-cond_futex(%rdi), %r9
+ jna 4f
+
+ /* Cause all currently waiting threads to recognize they are
+ woken up. */
+ movq %r9, wakeup_seq-cond_futex(%rdi)
+ movq %r9, woken_seq-cond_futex(%rdi)
+ addq %r9, %r9
+ movl %r9d, (%rdi)
+ incl broadcast_seq-cond_futex(%rdi)
+
+ /* Get the address of the mutex used. */
+ movq dep_mutex-cond_futex(%rdi), %r8
+
+ /* Unlock. */
+ LOCK
+ decl cond_lock-cond_futex(%rdi)
+ jne 7f
+
+8: cmpq $-1, %r8
+ je 9f
+
+ /* Do not use requeue for pshared condvars. */
+ testl $PS_BIT, MUTEX_KIND(%r8)
+ jne 9f
+
+ /* Requeue to a PI mutex if the PI bit is set. */
+ movl MUTEX_KIND(%r8), %eax
+ andl $(ROBUST_BIT|PI_BIT), %eax
+ cmpl $PI_BIT, %eax
+ je 81f
+
+ /* Wake up all threads. */
+#ifdef __ASSUME_PRIVATE_FUTEX
+ movl $(FUTEX_CMP_REQUEUE|FUTEX_PRIVATE_FLAG), %esi
+#else
+ movl %fs:PRIVATE_FUTEX, %esi
+ orl $FUTEX_CMP_REQUEUE, %esi
+#endif
+ movl $SYS_futex, %eax
+ movl $1, %edx
+ movl $0x7fffffff, %r10d
+ syscall
+
+ /* For any kind of error, which mainly is EAGAIN, we try again
+ with WAKE. The general test also covers running on old
+ kernels. */
+ cmpq $-4095, %rax
+ jae 9f
+
+10: xorl %eax, %eax
+ retq
+
+ /* Wake up all threads. */
+81: movl $(FUTEX_CMP_REQUEUE_PI|FUTEX_PRIVATE_FLAG), %esi
+ movl $SYS_futex, %eax
+ movl $1, %edx
+ movl $0x7fffffff, %r10d
+ syscall
+
+ /* For any kind of error, which mainly is EAGAIN, we try again
+ with WAKE. The general test also covers running on old
+ kernels. */
+ cmpq $-4095, %rax
+ jb 10b
+ jmp 9f
+
+ .align 16
+ /* Unlock. */
+4: LOCK
+ decl cond_lock-cond_futex(%rdi)
+ jne 5f
+
+6: xorl %eax, %eax
+ retq
+
+ /* Initial locking failed. */
+1:
+#if cond_lock != 0
+ addq $cond_lock, %rdi
+#endif
+ cmpq $-1, dep_mutex-cond_lock(%rdi)
+ movl $LLL_PRIVATE, %eax
+ movl $LLL_SHARED, %esi
+ cmovne %eax, %esi
+ callq __lll_lock_wait
+#if cond_lock != 0
+ subq $cond_lock, %rdi
+#endif
+ jmp 2b
+
+ /* Unlock in loop requires wakeup. */
+5: addq $cond_lock-cond_futex, %rdi
+ cmpq $-1, dep_mutex-cond_lock(%rdi)
+ movl $LLL_PRIVATE, %eax
+ movl $LLL_SHARED, %esi
+ cmovne %eax, %esi
+ callq __lll_unlock_wake
+ jmp 6b
+
+ /* Unlock in loop requires wakeup. */
+7: addq $cond_lock-cond_futex, %rdi
+ cmpq $-1, %r8
+ movl $LLL_PRIVATE, %eax
+ movl $LLL_SHARED, %esi
+ cmovne %eax, %esi
+ callq __lll_unlock_wake
+ subq $cond_lock-cond_futex, %rdi
+ jmp 8b
+
+9: /* The futex requeue functionality is not available. */
+ cmpq $-1, %r8
+ movl $0x7fffffff, %edx
+#ifdef __ASSUME_PRIVATE_FUTEX
+ movl $FUTEX_WAKE, %eax
+ movl $(FUTEX_WAKE|FUTEX_PRIVATE_FLAG), %esi
+ cmove %eax, %esi
+#else
+ movl $0, %eax
+ movl %fs:PRIVATE_FUTEX, %esi
+ cmove %eax, %esi
+ orl $FUTEX_WAKE, %esi
+#endif
+ movl $SYS_futex, %eax
+ syscall
+ jmp 10b
+ .size __pthread_cond_broadcast, .-__pthread_cond_broadcast
+weak_alias(__pthread_cond_broadcast, pthread_cond_broadcast)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
new file mode 100644
index 000000000..c893069f1
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
@@ -0,0 +1,160 @@
+/* Copyright (C) 2002-2005, 2007, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <lowlevellock.h>
+#include <lowlevelcond.h>
+#include <pthread-pi-defines.h>
+#include <bits/kernel-features.h>
+#include <pthread-errnos.h>
+
+
+ .text
+
+ /* int pthread_cond_signal (pthread_cond_t *cond) */
+ .globl __pthread_cond_signal
+ .type __pthread_cond_signal, @function
+ .protected __pthread_cond_signal
+ .align 16
+__pthread_cond_signal:
+
+ /* Get internal lock. */
+ movq %rdi, %r8
+ movl $1, %esi
+ xorl %eax, %eax
+ LOCK
+#if cond_lock == 0
+ cmpxchgl %esi, (%rdi)
+#else
+ cmpxchgl %esi, cond_lock(%rdi)
+#endif
+ jnz 1f
+
+2: addq $cond_futex, %rdi
+ movq total_seq(%r8), %rcx
+ cmpq wakeup_seq(%r8), %rcx
+ jbe 4f
+
+ /* Bump the wakeup number. */
+ addq $1, wakeup_seq(%r8)
+ addl $1, (%rdi)
+
+ /* Wake up one thread. */
+ cmpq $-1, dep_mutex(%r8)
+ movl $FUTEX_WAKE_OP, %esi
+ movl $1, %edx
+ movl $SYS_futex, %eax
+ je 8f
+
+ /* Get the address of the mutex used. */
+ movq dep_mutex(%r8), %rcx
+ movl MUTEX_KIND(%rcx), %r11d
+ andl $(ROBUST_BIT|PI_BIT), %r11d
+ cmpl $PI_BIT, %r11d
+ je 9f
+
+#ifdef __ASSUME_PRIVATE_FUTEX
+ movl $(FUTEX_WAKE_OP|FUTEX_PRIVATE_FLAG), %esi
+#else
+ orl %fs:PRIVATE_FUTEX, %esi
+#endif
+
+8: movl $1, %r10d
+#if cond_lock != 0
+ addq $cond_lock, %r8
+#endif
+ movl $FUTEX_OP_CLEAR_WAKE_IF_GT_ONE, %r9d
+ syscall
+#if cond_lock != 0
+ subq $cond_lock, %r8
+#endif
+ /* For any kind of error, we try again with WAKE.
+ The general test also covers running on old kernels. */
+ cmpq $-4095, %rax
+ jae 7f
+
+ xorl %eax, %eax
+ retq
+
+ /* Wake up one thread and requeue none in the PI Mutex case. */
+9: movl $(FUTEX_CMP_REQUEUE_PI|FUTEX_PRIVATE_FLAG), %esi
+ movq %rcx, %r8
+ xorq %r10, %r10
+ movl (%rdi), %r9d // XXX Can this be right?
+ syscall
+
+ leaq -cond_futex(%rdi), %r8
+
+ /* For any kind of error, we try again with WAKE.
+ The general test also covers running on old kernels. */
+ cmpq $-4095, %rax
+ jb 4f
+
+7:
+#ifdef __ASSUME_PRIVATE_FUTEX
+ andl $FUTEX_PRIVATE_FLAG, %esi
+#else
+ andl %fs:PRIVATE_FUTEX, %esi
+#endif
+ orl $FUTEX_WAKE, %esi
+ movl $SYS_futex, %eax
+ /* %rdx should be 1 already from $FUTEX_WAKE_OP syscall.
+ movl $1, %edx */
+ syscall
+
+ /* Unlock. */
+4: LOCK
+#if cond_lock == 0
+ decl (%r8)
+#else
+ decl cond_lock(%r8)
+#endif
+ jne 5f
+
+6: xorl %eax, %eax
+ retq
+
+ /* Initial locking failed. */
+1:
+#if cond_lock != 0
+ addq $cond_lock, %rdi
+#endif
+ cmpq $-1, dep_mutex-cond_lock(%rdi)
+ movl $LLL_PRIVATE, %eax
+ movl $LLL_SHARED, %esi
+ cmovne %eax, %esi
+ callq __lll_lock_wait
+#if cond_lock != 0
+ subq $cond_lock, %rdi
+#endif
+ jmp 2b
+
+ /* Unlock in loop requires wakeup. */
+5:
+ movq %r8, %rdi
+#if cond_lock != 0
+ addq $cond_lock, %rdi
+#endif
+ cmpq $-1, dep_mutex-cond_lock(%rdi)
+ movl $LLL_PRIVATE, %eax
+ movl $LLL_SHARED, %esi
+ cmovne %eax, %esi
+ callq __lll_unlock_wake
+ jmp 6b
+ .size __pthread_cond_signal, .-__pthread_cond_signal
+weak_alias(__pthread_cond_signal, pthread_cond_signal)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
new file mode 100644
index 000000000..31e5ef5c9
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
@@ -0,0 +1,795 @@
+/* Copyright (C) 2002-2005, 2007, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <lowlevellock.h>
+#include <lowlevelcond.h>
+#include <pthread-pi-defines.h>
+#include <pthread-errnos.h>
+#include <bits/kernel-features.h>
+#include <tcb-offsets.h>
+
+/* For the calculation see asm/vsyscall.h. */
+#define VSYSCALL_ADDR_vgettimeofday 0xffffffffff600000
+
+
+ .text
+
+
+/* int pthread_cond_timedwait (pthread_cond_t *cond, pthread_mutex_t *mutex,
+ const struct timespec *abstime) */
+ .globl __pthread_cond_timedwait
+ .type __pthread_cond_timedwait, @function
+ .protected __pthread_cond_timedwait
+ .align 16
+__pthread_cond_timedwait:
+.LSTARTCODE:
+ cfi_startproc
+
+ pushq %r12
+ cfi_adjust_cfa_offset(8)
+ cfi_rel_offset(%r12, 0)
+ pushq %r13
+ cfi_adjust_cfa_offset(8)
+ cfi_rel_offset(%r13, 0)
+ pushq %r14
+ cfi_adjust_cfa_offset(8)
+ cfi_rel_offset(%r14, 0)
+ pushq %r15
+ cfi_adjust_cfa_offset(8)
+ cfi_rel_offset(%r15, 0)
+#ifdef __ASSUME_FUTEX_CLOCK_REALTIME
+# define FRAME_SIZE 32
+#else
+# define FRAME_SIZE 48
+#endif
+ subq $FRAME_SIZE, %rsp
+ cfi_adjust_cfa_offset(FRAME_SIZE)
+ cfi_remember_state
+
+ cmpq $1000000000, 8(%rdx)
+ movl $EINVAL, %eax
+ jae 48f
+
+ /* Stack frame:
+
+ rsp + 48
+ +--------------------------+
+ rsp + 32 | timeout value |
+ +--------------------------+
+ rsp + 24 | old wake_seq value |
+ +--------------------------+
+ rsp + 16 | mutex pointer |
+ +--------------------------+
+ rsp + 8 | condvar pointer |
+ +--------------------------+
+ rsp + 4 | old broadcast_seq value |
+ +--------------------------+
+ rsp + 0 | old cancellation mode |
+ +--------------------------+
+ */
+
+ cmpq $-1, dep_mutex(%rdi)
+
+ /* Prepare structure passed to cancellation handler. */
+ movq %rdi, 8(%rsp)
+ movq %rsi, 16(%rsp)
+ movq %rdx, %r13
+
+ je 22f
+ movq %rsi, dep_mutex(%rdi)
+
+22:
+#ifndef __ASSUME_FUTEX_CLOCK_REALTIME
+# ifdef __PIC__
+ cmpl $0, __have_futex_clock_realtime@GOTOFF(%rip)
+# else
+ cmpl $0, __have_futex_clock_realtime
+# endif
+ je .Lreltmo
+#endif
+
+ /* Get internal lock. */
+ movl $1, %esi
+ xorl %eax, %eax
+ LOCK
+#if cond_lock == 0
+ cmpxchgl %esi, (%rdi)
+#else
+ cmpxchgl %esi, cond_lock(%rdi)
+#endif
+ jnz 31f
+
+ /* Unlock the mutex. */
+32: movq 16(%rsp), %rdi
+ xorl %esi, %esi
+ callq __pthread_mutex_unlock_usercnt
+
+ testl %eax, %eax
+ jne 46f
+
+ movq 8(%rsp), %rdi
+ incq total_seq(%rdi)
+ incl cond_futex(%rdi)
+ addl $(1 << nwaiters_shift), cond_nwaiters(%rdi)
+
+ /* Get and store current wakeup_seq value. */
+ movq 8(%rsp), %rdi
+ movq wakeup_seq(%rdi), %r9
+ movl broadcast_seq(%rdi), %edx
+ movq %r9, 24(%rsp)
+ movl %edx, 4(%rsp)
+
+38: movl cond_futex(%rdi), %r12d
+
+ /* Unlock. */
+ LOCK
+#if cond_lock == 0
+ decl (%rdi)
+#else
+ decl cond_lock(%rdi)
+#endif
+ jne 33f
+
+.LcleanupSTART1:
+34: callq __pthread_enable_asynccancel
+ movl %eax, (%rsp)
+
+ movq %r13, %r10
+ movl $FUTEX_WAIT_BITSET, %esi
+ cmpq $-1, dep_mutex(%rdi)
+ je 60f
+
+ movq dep_mutex(%rdi), %r8
+ /* Requeue to a non-robust PI mutex if the PI bit is set and
+ the robust bit is not set. */
+ movl MUTEX_KIND(%r8), %eax
+ andl $(ROBUST_BIT|PI_BIT), %eax
+ cmpl $PI_BIT, %eax
+ jne 61f
+
+ movl $(FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG), %esi
+ xorl %eax, %eax
+ /* The following only works like this because we only support
+ two clocks, represented using a single bit. */
+ testl $1, cond_nwaiters(%rdi)
+ movl $FUTEX_CLOCK_REALTIME, %edx
+ cmove %edx, %eax
+ orl %eax, %esi
+ movq %r12, %rdx
+ addq $cond_futex, %rdi
+ movl $SYS_futex, %eax
+ syscall
+
+ movl $1, %r15d
+#ifdef __ASSUME_REQUEUE_PI
+ jmp 62f
+#else
+ cmpq $-4095, %rax
+ jnae 62f
+
+ subq $cond_futex, %rdi
+#endif
+
+61: movl $(FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG), %esi
+60: xorl %r15d, %r15d
+ xorl %eax, %eax
+ /* The following only works like this because we only support
+ two clocks, represented using a single bit. */
+ testl $1, cond_nwaiters(%rdi)
+ movl $FUTEX_CLOCK_REALTIME, %edx
+ movl $0xffffffff, %r9d
+ cmove %edx, %eax
+ orl %eax, %esi
+ movq %r12, %rdx
+ addq $cond_futex, %rdi
+ movl $SYS_futex, %eax
+ syscall
+62: movq %rax, %r14
+
+ movl (%rsp), %edi
+ callq __pthread_disable_asynccancel
+.LcleanupEND1:
+
+ /* Lock. */
+ movq 8(%rsp), %rdi
+ movl $1, %esi
+ xorl %eax, %eax
+ LOCK
+#if cond_lock == 0
+ cmpxchgl %esi, (%rdi)
+#else
+ cmpxchgl %esi, cond_lock(%rdi)
+#endif
+ jne 35f
+
+36: movl broadcast_seq(%rdi), %edx
+
+ movq woken_seq(%rdi), %rax
+
+ movq wakeup_seq(%rdi), %r9
+
+ cmpl 4(%rsp), %edx
+ jne 53f
+
+ cmpq 24(%rsp), %r9
+ jbe 45f
+
+ cmpq %rax, %r9
+ ja 39f
+
+45: cmpq $-ETIMEDOUT, %r14
+ jne 38b
+
+99: incq wakeup_seq(%rdi)
+ incl cond_futex(%rdi)
+ movl $ETIMEDOUT, %r14d
+ jmp 44f
+
+53: xorq %r14, %r14
+ jmp 54f
+
+39: xorq %r14, %r14
+44: incq woken_seq(%rdi)
+
+54: subl $(1 << nwaiters_shift), cond_nwaiters(%rdi)
+
+ /* Wake up a thread which wants to destroy the condvar object. */
+ cmpq $0xffffffffffffffff, total_seq(%rdi)
+ jne 55f
+ movl cond_nwaiters(%rdi), %eax
+ andl $~((1 << nwaiters_shift) - 1), %eax
+ jne 55f
+
+ addq $cond_nwaiters, %rdi
+ cmpq $-1, dep_mutex-cond_nwaiters(%rdi)
+ movl $1, %edx
+#ifdef __ASSUME_PRIVATE_FUTEX
+ movl $FUTEX_WAKE, %eax
+ movl $(FUTEX_WAKE|FUTEX_PRIVATE_FLAG), %esi
+ cmove %eax, %esi
+#else
+ movl $0, %eax
+ movl %fs:PRIVATE_FUTEX, %esi
+ cmove %eax, %esi
+ orl $FUTEX_WAKE, %esi
+#endif
+ movl $SYS_futex, %eax
+ syscall
+ subq $cond_nwaiters, %rdi
+
+55: LOCK
+#if cond_lock == 0
+ decl (%rdi)
+#else
+ decl cond_lock(%rdi)
+#endif
+ jne 40f
+
+ /* If requeue_pi is used the kernel performs the locking of the
+ mutex. */
+41: movq 16(%rsp), %rdi
+ testl %r15d, %r15d
+ jnz 64f
+
+ callq __pthread_mutex_cond_lock
+
+63: testq %rax, %rax
+ cmoveq %r14, %rax
+
+48: addq $FRAME_SIZE, %rsp
+ cfi_adjust_cfa_offset(-FRAME_SIZE)
+ popq %r15
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r15)
+ popq %r14
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r14)
+ popq %r13
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r13)
+ popq %r12
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r12)
+
+ retq
+
+ cfi_restore_state
+
+64: callq __pthread_mutex_cond_lock_adjust
+ movq %r14, %rax
+ jmp 48b
+
+ /* Initial locking failed. */
+31:
+#if cond_lock != 0
+ addq $cond_lock, %rdi
+#endif
+ cmpq $-1, dep_mutex-cond_lock(%rdi)
+ movl $LLL_PRIVATE, %eax
+ movl $LLL_SHARED, %esi
+ cmovne %eax, %esi
+ callq __lll_lock_wait
+ jmp 32b
+
+ /* Unlock in loop requires wakeup. */
+33:
+#if cond_lock != 0
+ addq $cond_lock, %rdi
+#endif
+ cmpq $-1, dep_mutex-cond_lock(%rdi)
+ movl $LLL_PRIVATE, %eax
+ movl $LLL_SHARED, %esi
+ cmovne %eax, %esi
+ callq __lll_unlock_wake
+ jmp 34b
+
+ /* Locking in loop failed. */
+35:
+#if cond_lock != 0
+ addq $cond_lock, %rdi
+#endif
+ cmpq $-1, dep_mutex-cond_lock(%rdi)
+ movl $LLL_PRIVATE, %eax
+ movl $LLL_SHARED, %esi
+ cmovne %eax, %esi
+ callq __lll_lock_wait
+#if cond_lock != 0
+ subq $cond_lock, %rdi
+#endif
+ jmp 36b
+
+ /* Unlock after loop requires wakeup. */
+40:
+#if cond_lock != 0
+ addq $cond_lock, %rdi
+#endif
+ cmpq $-1, dep_mutex-cond_lock(%rdi)
+ movl $LLL_PRIVATE, %eax
+ movl $LLL_SHARED, %esi
+ cmovne %eax, %esi
+ callq __lll_unlock_wake
+ jmp 41b
+
+ /* The initial unlocking of the mutex failed. */
+46: movq 8(%rsp), %rdi
+ movq %rax, (%rsp)
+ LOCK
+#if cond_lock == 0
+ decl (%rdi)
+#else
+ decl cond_lock(%rdi)
+#endif
+ jne 47f
+
+#if cond_lock != 0
+ addq $cond_lock, %rdi
+#endif
+ cmpq $-1, dep_mutex-cond_lock(%rdi)
+ movl $LLL_PRIVATE, %eax
+ movl $LLL_SHARED, %esi
+ cmovne %eax, %esi
+ callq __lll_unlock_wake
+
+47: movq (%rsp), %rax
+ jmp 48b
+
+
+#ifndef __ASSUME_FUTEX_CLOCK_REALTIME
+.Lreltmo:
+ xorl %r15d, %r15d
+
+ /* Get internal lock. */
+ movl $1, %esi
+ xorl %eax, %eax
+ LOCK
+# if cond_lock == 0
+ cmpxchgl %esi, (%rdi)
+# else
+ cmpxchgl %esi, cond_lock(%rdi)
+# endif
+ jnz 1f
+
+ /* Unlock the mutex. */
+2: movq 16(%rsp), %rdi
+ xorl %esi, %esi
+ callq __pthread_mutex_unlock_usercnt
+
+ testl %eax, %eax
+ jne 46b
+
+ movq 8(%rsp), %rdi
+ incq total_seq(%rdi)
+ incl cond_futex(%rdi)
+ addl $(1 << nwaiters_shift), cond_nwaiters(%rdi)
+
+ /* Get and store current wakeup_seq value. */
+ movq 8(%rsp), %rdi
+ movq wakeup_seq(%rdi), %r9
+ movl broadcast_seq(%rdi), %edx
+ movq %r9, 24(%rsp)
+ movl %edx, 4(%rsp)
+
+ /* Get the current time. */
+8:
+# ifdef __NR_clock_gettime
+ /* Get the clock number. Note that the field in the condvar
+ structure stores the number minus 1. */
+ movq 8(%rsp), %rdi
+ movl cond_nwaiters(%rdi), %edi
+ andl $((1 << nwaiters_shift) - 1), %edi
+ /* Only clocks 0 and 1 are allowed so far. Both are handled in the
+ kernel. */
+ leaq 32(%rsp), %rsi
+26: movl $__NR_clock_gettime, %eax
+ syscall
+27:
+# ifndef __ASSUME_POSIX_TIMERS
+ cmpq $-ENOSYS, %rax
+ je 19f
+# endif
+
+ /* Compute relative timeout. */
+ movq (%r13), %rcx
+ movq 8(%r13), %rdx
+ subq 32(%rsp), %rcx
+ subq 40(%rsp), %rdx
+# else
+ leaq 24(%rsp), %rdi
+ xorl %esi, %esi
+ movq $VSYSCALL_ADDR_vgettimeofday, %rax
+ callq *%rax
+
+ /* Compute relative timeout. */
+ movq 40(%rsp), %rax
+ movl $1000, %edx
+ mul %rdx /* Milli seconds to nano seconds. */
+ movq (%r13), %rcx
+ movq 8(%r13), %rdx
+ subq 32(%rsp), %rcx
+ subq %rax, %rdx
+# endif
+ jns 12f
+ addq $1000000000, %rdx
+ decq %rcx
+12: testq %rcx, %rcx
+ movq 8(%rsp), %rdi
+ movq $-ETIMEDOUT, %r14
+ js 6f
+
+ /* Store relative timeout. */
+21: movq %rcx, 32(%rsp)
+ movq %rdx, 40(%rsp)
+
+ movl cond_futex(%rdi), %r12d
+
+ /* Unlock. */
+ LOCK
+# if cond_lock == 0
+ decl (%rdi)
+# else
+ decl cond_lock(%rdi)
+# endif
+ jne 3f
+
+.LcleanupSTART2:
+4: callq __pthread_enable_asynccancel
+ movl %eax, (%rsp)
+
+ leaq 32(%rsp), %r10
+ cmpq $-1, dep_mutex(%rdi)
+ movq %r12, %rdx
+# ifdef __ASSUME_PRIVATE_FUTEX
+ movl $FUTEX_WAIT, %eax
+ movl $(FUTEX_WAIT|FUTEX_PRIVATE_FLAG), %esi
+ cmove %eax, %esi
+# else
+ movl $0, %eax
+ movl %fs:PRIVATE_FUTEX, %esi
+ cmove %eax, %esi
+# if FUTEX_WAIT != 0
+ orl $FUTEX_WAIT, %esi
+# endif
+# endif
+ addq $cond_futex, %rdi
+ movl $SYS_futex, %eax
+ syscall
+ movq %rax, %r14
+
+ movl (%rsp), %edi
+ callq __pthread_disable_asynccancel
+.LcleanupEND2:
+
+ /* Lock. */
+ movq 8(%rsp), %rdi
+ movl $1, %esi
+ xorl %eax, %eax
+ LOCK
+# if cond_lock == 0
+ cmpxchgl %esi, (%rdi)
+# else
+ cmpxchgl %esi, cond_lock(%rdi)
+# endif
+ jne 5f
+
+6: movl broadcast_seq(%rdi), %edx
+
+ movq woken_seq(%rdi), %rax
+
+ movq wakeup_seq(%rdi), %r9
+
+ cmpl 4(%rsp), %edx
+ jne 53b
+
+ cmpq 24(%rsp), %r9
+ jbe 15f
+
+ cmpq %rax, %r9
+ ja 39b
+
+15: cmpq $-ETIMEDOUT, %r14
+ jne 8b
+
+ jmp 99b
+
+ /* Initial locking failed. */
+1:
+# if cond_lock != 0
+ addq $cond_lock, %rdi
+# endif
+ cmpq $-1, dep_mutex-cond_lock(%rdi)
+ movl $LLL_PRIVATE, %eax
+ movl $LLL_SHARED, %esi
+ cmovne %eax, %esi
+ callq __lll_lock_wait
+ jmp 2b
+
+ /* Unlock in loop requires wakeup. */
+3:
+# if cond_lock != 0
+ addq $cond_lock, %rdi
+# endif
+ cmpq $-1, dep_mutex-cond_lock(%rdi)
+ movl $LLL_PRIVATE, %eax
+ movl $LLL_SHARED, %esi
+ cmovne %eax, %esi
+ callq __lll_unlock_wake
+ jmp 4b
+
+ /* Locking in loop failed. */
+5:
+# if cond_lock != 0
+ addq $cond_lock, %rdi
+# endif
+ cmpq $-1, dep_mutex-cond_lock(%rdi)
+ movl $LLL_PRIVATE, %eax
+ movl $LLL_SHARED, %esi
+ cmovne %eax, %esi
+ callq __lll_lock_wait
+# if cond_lock != 0
+ subq $cond_lock, %rdi
+# endif
+ jmp 6b
+
+# if defined __NR_clock_gettime && !defined __ASSUME_POSIX_TIMERS
+ /* clock_gettime not available. */
+19: leaq 32(%rsp), %rdi
+ xorl %esi, %esi
+ movq $VSYSCALL_ADDR_vgettimeofday, %rax
+ callq *%rax
+
+ /* Compute relative timeout. */
+ movq 40(%rsp), %rax
+ movl $1000, %edx
+ mul %rdx /* Milli seconds to nano seconds. */
+ movq (%r13), %rcx
+ movq 8(%r13), %rdx
+ subq 32(%rsp), %rcx
+ subq %rax, %rdx
+ jns 20f
+ addq $1000000000, %rdx
+ decq %rcx
+20: testq %rcx, %rcx
+ movq 8(%rsp), %rdi
+ movq $-ETIMEDOUT, %r14
+ js 6b
+ jmp 21b
+# endif
+#endif
+ .size __pthread_cond_timedwait, .-__pthread_cond_timedwait
+weak_alias(__pthread_cond_timedwait, pthread_cond_timedwait)
+
+
+ .align 16
+ .type __condvar_cleanup2, @function
+__condvar_cleanup2:
+ /* Stack frame:
+
+ rsp + 72
+ +--------------------------+
+ rsp + 64 | %r12 |
+ +--------------------------+
+ rsp + 56 | %r13 |
+ +--------------------------+
+ rsp + 48 | %r14 |
+ +--------------------------+
+ rsp + 24 | unused |
+ +--------------------------+
+ rsp + 16 | mutex pointer |
+ +--------------------------+
+ rsp + 8 | condvar pointer |
+ +--------------------------+
+ rsp + 4 | old broadcast_seq value |
+ +--------------------------+
+ rsp + 0 | old cancellation mode |
+ +--------------------------+
+ */
+
+ movq %rax, 24(%rsp)
+
+ /* Get internal lock. */
+ movq 8(%rsp), %rdi
+ movl $1, %esi
+ xorl %eax, %eax
+ LOCK
+#if cond_lock == 0
+ cmpxchgl %esi, (%rdi)
+#else
+ cmpxchgl %esi, cond_lock(%rdi)
+#endif
+ jz 1f
+
+#if cond_lock != 0
+ addq $cond_lock, %rdi
+#endif
+ cmpq $-1, dep_mutex-cond_lock(%rdi)
+ movl $LLL_PRIVATE, %eax
+ movl $LLL_SHARED, %esi
+ cmovne %eax, %esi
+ callq __lll_lock_wait
+#if cond_lock != 0
+ subq $cond_lock, %rdi
+#endif
+
+1: movl broadcast_seq(%rdi), %edx
+ cmpl 4(%rsp), %edx
+ jne 3f
+
+ /* We increment the wakeup_seq counter only if it is lower than
+ total_seq. If this is not the case the thread was woken and
+ then canceled. In this case we ignore the signal. */
+ movq total_seq(%rdi), %rax
+ cmpq wakeup_seq(%rdi), %rax
+ jbe 6f
+ incq wakeup_seq(%rdi)
+ incl cond_futex(%rdi)
+6: incq woken_seq(%rdi)
+
+3: subl $(1 << nwaiters_shift), cond_nwaiters(%rdi)
+
+ /* Wake up a thread which wants to destroy the condvar object. */
+ xorq %r12, %r12
+ cmpq $0xffffffffffffffff, total_seq(%rdi)
+ jne 4f
+ movl cond_nwaiters(%rdi), %eax
+ andl $~((1 << nwaiters_shift) - 1), %eax
+ jne 4f
+
+ cmpq $-1, dep_mutex(%rdi)
+ leaq cond_nwaiters(%rdi), %rdi
+ movl $1, %edx
+#ifdef __ASSUME_PRIVATE_FUTEX
+ movl $FUTEX_WAKE, %eax
+ movl $(FUTEX_WAKE|FUTEX_PRIVATE_FLAG), %esi
+ cmove %eax, %esi
+#else
+ movl $0, %eax
+ movl %fs:PRIVATE_FUTEX, %esi
+ cmove %eax, %esi
+ orl $FUTEX_WAKE, %esi
+#endif
+ movl $SYS_futex, %eax
+ syscall
+ subq $cond_nwaiters, %rdi
+ movl $1, %r12d
+
+4: LOCK
+#if cond_lock == 0
+ decl (%rdi)
+#else
+ decl cond_lock(%rdi)
+#endif
+ je 2f
+#if cond_lock != 0
+ addq $cond_lock, %rdi
+#endif
+ cmpq $-1, dep_mutex-cond_lock(%rdi)
+ movl $LLL_PRIVATE, %eax
+ movl $LLL_SHARED, %esi
+ cmovne %eax, %esi
+ callq __lll_unlock_wake
+
+ /* Wake up all waiters to make sure no signal gets lost. */
+2: testq %r12, %r12
+ jnz 5f
+ addq $cond_futex, %rdi
+ cmpq $-1, dep_mutex-cond_futex(%rdi)
+ movl $0x7fffffff, %edx
+#ifdef __ASSUME_PRIVATE_FUTEX
+ movl $FUTEX_WAKE, %eax
+ movl $(FUTEX_WAKE|FUTEX_PRIVATE_FLAG), %esi
+ cmove %eax, %esi
+#else
+ movl $0, %eax
+ movl %fs:PRIVATE_FUTEX, %esi
+ cmove %eax, %esi
+ orl $FUTEX_WAKE, %esi
+#endif
+ movl $SYS_futex, %eax
+ syscall
+
+5: movq 16(%rsp), %rdi
+ callq __pthread_mutex_cond_lock
+
+ movq 24(%rsp), %rdi
+ movq FRAME_SIZE(%rsp), %r15
+ movq FRAME_SIZE+8(%rsp), %r14
+ movq FRAME_SIZE+16(%rsp), %r13
+ movq FRAME_SIZE+24(%rsp), %r12
+.LcallUR:
+ call _Unwind_Resume@PLT
+ hlt
+.LENDCODE:
+ cfi_endproc
+ .size __condvar_cleanup2, .-__condvar_cleanup2
+
+
+ .section .gcc_except_table,"a",@progbits
+.LexceptSTART:
+ .byte DW_EH_PE_omit # @LPStart format
+ .byte DW_EH_PE_omit # @TType format
+ .byte DW_EH_PE_uleb128 # call-site format
+ .uleb128 .Lcstend-.Lcstbegin
+.Lcstbegin:
+ .uleb128 .LcleanupSTART1-.LSTARTCODE
+ .uleb128 .LcleanupEND1-.LcleanupSTART1
+ .uleb128 __condvar_cleanup2-.LSTARTCODE
+ .uleb128 0
+#ifndef __ASSUME_FUTEX_CLOCK_REALTIME
+ .uleb128 .LcleanupSTART2-.LSTARTCODE
+ .uleb128 .LcleanupEND2-.LcleanupSTART2
+ .uleb128 __condvar_cleanup2-.LSTARTCODE
+ .uleb128 0
+#endif
+ .uleb128 .LcallUR-.LSTARTCODE
+ .uleb128 .LENDCODE-.LcallUR
+ .uleb128 0
+ .uleb128 0
+.Lcstend:
+
+
+#ifdef SHARED
+ .hidden DW.ref.__gcc_personality_v0
+ .weak DW.ref.__gcc_personality_v0
+ .section .gnu.linkonce.d.DW.ref.__gcc_personality_v0,"aw",@progbits
+ .align 8
+ .type DW.ref.__gcc_personality_v0, @object
+ .size DW.ref.__gcc_personality_v0, 8
+DW.ref.__gcc_personality_v0:
+ .quad __gcc_personality_v0
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
new file mode 100644
index 000000000..bea7bc443
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
@@ -0,0 +1,486 @@
+/* Copyright (C) 2002-2007, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <lowlevellock.h>
+#include <lowlevelcond.h>
+#include <tcb-offsets.h>
+#include <pthread-pi-defines.h>
+
+#include <bits/kernel-features.h>
+
+
+ .text
+
+/* int pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex) */
+ .globl __pthread_cond_wait
+ .type __pthread_cond_wait, @function
+ .protected __pthread_cond_wait
+ .align 16
+__pthread_cond_wait:
+.LSTARTCODE:
+ cfi_startproc
+
+#define FRAME_SIZE 32
+ leaq -FRAME_SIZE(%rsp), %rsp
+ cfi_adjust_cfa_offset(FRAME_SIZE)
+
+ /* Stack frame:
+
+ rsp + 32
+ +--------------------------+
+ rsp + 24 | old wake_seq value |
+ +--------------------------+
+ rsp + 16 | mutex pointer |
+ +--------------------------+
+ rsp + 8 | condvar pointer |
+ +--------------------------+
+ rsp + 4 | old broadcast_seq value |
+ +--------------------------+
+ rsp + 0 | old cancellation mode |
+ +--------------------------+
+ */
+
+ cmpq $-1, dep_mutex(%rdi)
+
+ /* Prepare structure passed to cancellation handler. */
+ movq %rdi, 8(%rsp)
+ movq %rsi, 16(%rsp)
+
+ je 15f
+ movq %rsi, dep_mutex(%rdi)
+
+ /* Get internal lock. */
+15: movl $1, %esi
+ xorl %eax, %eax
+ LOCK
+#if cond_lock == 0
+ cmpxchgl %esi, (%rdi)
+#else
+ cmpxchgl %esi, cond_lock(%rdi)
+#endif
+ jne 1f
+
+ /* Unlock the mutex. */
+2: movq 16(%rsp), %rdi
+ xorl %esi, %esi
+ callq __pthread_mutex_unlock_usercnt
+
+ testl %eax, %eax
+ jne 12f
+
+ movq 8(%rsp), %rdi
+ incq total_seq(%rdi)
+ incl cond_futex(%rdi)
+ addl $(1 << nwaiters_shift), cond_nwaiters(%rdi)
+
+ /* Get and store current wakeup_seq value. */
+ movq 8(%rsp), %rdi
+ movq wakeup_seq(%rdi), %r9
+ movl broadcast_seq(%rdi), %edx
+ movq %r9, 24(%rsp)
+ movl %edx, 4(%rsp)
+
+ /* Unlock. */
+8: movl cond_futex(%rdi), %edx
+ LOCK
+#if cond_lock == 0
+ decl (%rdi)
+#else
+ decl cond_lock(%rdi)
+#endif
+ jne 3f
+
+.LcleanupSTART:
+4: callq __pthread_enable_asynccancel
+ movl %eax, (%rsp)
+
+ xorq %r10, %r10
+ cmpq $-1, dep_mutex(%rdi)
+ leaq cond_futex(%rdi), %rdi
+ movl $FUTEX_WAIT, %esi
+ je 60f
+
+ movq dep_mutex-cond_futex(%rdi), %r8
+ /* Requeue to a non-robust PI mutex if the PI bit is set and
+ the robust bit is not set. */
+ movl MUTEX_KIND(%r8), %eax
+ andl $(ROBUST_BIT|PI_BIT), %eax
+ cmpl $PI_BIT, %eax
+ jne 61f
+
+ movl $(FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG), %esi
+ movl $SYS_futex, %eax
+ syscall
+
+ movl $1, %r8d
+#ifdef __ASSUME_REQUEUE_PI
+ jmp 62f
+#else
+ cmpq $-4095, %rax
+ jnae 62f
+
+# ifndef __ASSUME_PRIVATE_FUTEX
+ movl $FUTEX_WAIT, %esi
+# endif
+#endif
+
+61:
+#ifdef __ASSUME_PRIVATE_FUTEX
+ movl $(FUTEX_WAIT|FUTEX_PRIVATE_FLAG), %esi
+#else
+ orl %fs:PRIVATE_FUTEX, %esi
+#endif
+60: xorl %r8d, %r8d
+ movl $SYS_futex, %eax
+ syscall
+
+62: movl (%rsp), %edi
+ callq __pthread_disable_asynccancel
+.LcleanupEND:
+
+ /* Lock. */
+ movq 8(%rsp), %rdi
+ movl $1, %esi
+ xorl %eax, %eax
+ LOCK
+#if cond_lock == 0
+ cmpxchgl %esi, (%rdi)
+#else
+ cmpxchgl %esi, cond_lock(%rdi)
+#endif
+ jnz 5f
+
+6: movl broadcast_seq(%rdi), %edx
+
+ movq woken_seq(%rdi), %rax
+
+ movq wakeup_seq(%rdi), %r9
+
+ cmpl 4(%rsp), %edx
+ jne 16f
+
+ cmpq 24(%rsp), %r9
+ jbe 8b
+
+ cmpq %rax, %r9
+ jna 8b
+
+ incq woken_seq(%rdi)
+
+ /* Unlock */
+16: subl $(1 << nwaiters_shift), cond_nwaiters(%rdi)
+
+ /* Wake up a thread which wants to destroy the condvar object. */
+ cmpq $0xffffffffffffffff, total_seq(%rdi)
+ jne 17f
+ movl cond_nwaiters(%rdi), %eax
+ andl $~((1 << nwaiters_shift) - 1), %eax
+ jne 17f
+
+ addq $cond_nwaiters, %rdi
+ cmpq $-1, dep_mutex-cond_nwaiters(%rdi)
+ movl $1, %edx
+#ifdef __ASSUME_PRIVATE_FUTEX
+ movl $FUTEX_WAKE, %eax
+ movl $(FUTEX_WAKE|FUTEX_PRIVATE_FLAG), %esi
+ cmove %eax, %esi
+#else
+ movl $0, %eax
+ movl %fs:PRIVATE_FUTEX, %esi
+ cmove %eax, %esi
+ orl $FUTEX_WAKE, %esi
+#endif
+ movl $SYS_futex, %eax
+ syscall
+ subq $cond_nwaiters, %rdi
+
+17: LOCK
+#if cond_lock == 0
+ decl (%rdi)
+#else
+ decl cond_lock(%rdi)
+#endif
+ jne 10f
+
+ /* If requeue_pi is used the kernel performs the locking of the
+ mutex. */
+11: movq 16(%rsp), %rdi
+ testl %r8d, %r8d
+ jnz 18f
+
+ callq __pthread_mutex_cond_lock
+
+14: leaq FRAME_SIZE(%rsp), %rsp
+ cfi_adjust_cfa_offset(-FRAME_SIZE)
+
+ /* We return the result of the mutex_lock operation. */
+ retq
+
+ cfi_adjust_cfa_offset(FRAME_SIZE)
+
+18: callq __pthread_mutex_cond_lock_adjust
+ xorl %eax, %eax
+ jmp 14b
+
+ /* Initial locking failed. */
+1:
+#if cond_lock != 0
+ addq $cond_lock, %rdi
+#endif
+ cmpq $-1, dep_mutex-cond_lock(%rdi)
+ movl $LLL_PRIVATE, %eax
+ movl $LLL_SHARED, %esi
+ cmovne %eax, %esi
+ callq __lll_lock_wait
+ jmp 2b
+
+ /* Unlock in loop requires wakeup. */
+3:
+#if cond_lock != 0
+ addq $cond_lock, %rdi
+#endif
+ cmpq $-1, dep_mutex-cond_lock(%rdi)
+ movl $LLL_PRIVATE, %eax
+ movl $LLL_SHARED, %esi
+ cmovne %eax, %esi
+ /* The call preserves %rdx. */
+ callq __lll_unlock_wake
+#if cond_lock != 0
+ subq $cond_lock, %rdi
+#endif
+ jmp 4b
+
+ /* Locking in loop failed. */
+5:
+#if cond_lock != 0
+ addq $cond_lock, %rdi
+#endif
+ cmpq $-1, dep_mutex-cond_lock(%rdi)
+ movl $LLL_PRIVATE, %eax
+ movl $LLL_SHARED, %esi
+ cmovne %eax, %esi
+ callq __lll_lock_wait
+#if cond_lock != 0
+ subq $cond_lock, %rdi
+#endif
+ jmp 6b
+
+ /* Unlock after loop requires wakeup. */
+10:
+#if cond_lock != 0
+ addq $cond_lock, %rdi
+#endif
+ cmpq $-1, dep_mutex-cond_lock(%rdi)
+ movl $LLL_PRIVATE, %eax
+ movl $LLL_SHARED, %esi
+ cmovne %eax, %esi
+ callq __lll_unlock_wake
+ jmp 11b
+
+ /* The initial unlocking of the mutex failed. */
+12: movq %rax, %r10
+ movq 8(%rsp), %rdi
+ LOCK
+#if cond_lock == 0
+ decl (%rdi)
+#else
+ decl cond_lock(%rdi)
+#endif
+ je 13f
+
+#if cond_lock != 0
+ addq $cond_lock, %rdi
+#endif
+ cmpq $-1, dep_mutex-cond_lock(%rdi)
+ movl $LLL_PRIVATE, %eax
+ movl $LLL_SHARED, %esi
+ cmovne %eax, %esi
+ callq __lll_unlock_wake
+
+13: movq %r10, %rax
+ jmp 14b
+ .size __pthread_cond_wait, .-__pthread_cond_wait
+weak_alias(__pthread_cond_wait, pthread_cond_wait)
+
+
+ .align 16
+ .type __condvar_cleanup1, @function
+ .globl __condvar_cleanup1
+ .hidden __condvar_cleanup1
+__condvar_cleanup1:
+ /* Stack frame:
+
+ rsp + 32
+ +--------------------------+
+ rsp + 24 | unused |
+ +--------------------------+
+ rsp + 16 | mutex pointer |
+ +--------------------------+
+ rsp + 8 | condvar pointer |
+ +--------------------------+
+ rsp + 4 | old broadcast_seq value |
+ +--------------------------+
+ rsp + 0 | old cancellation mode |
+ +--------------------------+
+ */
+
+ movq %rax, 24(%rsp)
+
+ /* Get internal lock. */
+ movq 8(%rsp), %rdi
+ movl $1, %esi
+ xorl %eax, %eax
+ LOCK
+#if cond_lock == 0
+ cmpxchgl %esi, (%rdi)
+#else
+ cmpxchgl %esi, cond_lock(%rdi)
+#endif
+ jz 1f
+
+#if cond_lock != 0
+ addq $cond_lock, %rdi
+#endif
+ cmpq $-1, dep_mutex-cond_lock(%rdi)
+ movl $LLL_PRIVATE, %eax
+ movl $LLL_SHARED, %esi
+ cmovne %eax, %esi
+ callq __lll_lock_wait
+#if cond_lock != 0
+ subq $cond_lock, %rdi
+#endif
+
+1: movl broadcast_seq(%rdi), %edx
+ cmpl 4(%rsp), %edx
+ jne 3f
+
+ /* We increment the wakeup_seq counter only if it is lower than
+ total_seq. If this is not the case the thread was woken and
+ then canceled. In this case we ignore the signal. */
+ movq total_seq(%rdi), %rax
+ cmpq wakeup_seq(%rdi), %rax
+ jbe 6f
+ incq wakeup_seq(%rdi)
+ incl cond_futex(%rdi)
+6: incq woken_seq(%rdi)
+
+3: subl $(1 << nwaiters_shift), cond_nwaiters(%rdi)
+
+ /* Wake up a thread which wants to destroy the condvar object. */
+ xorl %ecx, %ecx
+ cmpq $0xffffffffffffffff, total_seq(%rdi)
+ jne 4f
+ movl cond_nwaiters(%rdi), %eax
+ andl $~((1 << nwaiters_shift) - 1), %eax
+ jne 4f
+
+ cmpq $-1, dep_mutex(%rdi)
+ leaq cond_nwaiters(%rdi), %rdi
+ movl $1, %edx
+#ifdef __ASSUME_PRIVATE_FUTEX
+ movl $FUTEX_WAKE, %eax
+ movl $(FUTEX_WAKE|FUTEX_PRIVATE_FLAG), %esi
+ cmove %eax, %esi
+#else
+ movl $0, %eax
+ movl %fs:PRIVATE_FUTEX, %esi
+ cmove %eax, %esi
+ orl $FUTEX_WAKE, %esi
+#endif
+ movl $SYS_futex, %eax
+ syscall
+ subq $cond_nwaiters, %rdi
+ movl $1, %ecx
+
+4: LOCK
+#if cond_lock == 0
+ decl (%rdi)
+#else
+ decl cond_lock(%rdi)
+#endif
+ je 2f
+#if cond_lock != 0
+ addq $cond_lock, %rdi
+#endif
+ cmpq $-1, dep_mutex-cond_lock(%rdi)
+ movl $LLL_PRIVATE, %eax
+ movl $LLL_SHARED, %esi
+ cmovne %eax, %esi
+ /* The call preserves %rcx. */
+ callq __lll_unlock_wake
+
+ /* Wake up all waiters to make sure no signal gets lost. */
+2: testl %ecx, %ecx
+ jnz 5f
+ addq $cond_futex, %rdi
+ cmpq $-1, dep_mutex-cond_futex(%rdi)
+ movl $0x7fffffff, %edx
+#ifdef __ASSUME_PRIVATE_FUTEX
+ movl $FUTEX_WAKE, %eax
+ movl $(FUTEX_WAKE|FUTEX_PRIVATE_FLAG), %esi
+ cmove %eax, %esi
+#else
+ movl $0, %eax
+ movl %fs:PRIVATE_FUTEX, %esi
+ cmove %eax, %esi
+ orl $FUTEX_WAKE, %esi
+#endif
+ movl $SYS_futex, %eax
+ syscall
+
+5: movq 16(%rsp), %rdi
+ callq __pthread_mutex_cond_lock
+
+ movq 24(%rsp), %rdi
+.LcallUR:
+ call _Unwind_Resume@PLT
+ hlt
+.LENDCODE:
+ cfi_endproc
+ .size __condvar_cleanup1, .-__condvar_cleanup1
+
+
+ .section .gcc_except_table,"a",@progbits
+.LexceptSTART:
+ .byte DW_EH_PE_omit # @LPStart format
+ .byte DW_EH_PE_omit # @TType format
+ .byte DW_EH_PE_uleb128 # call-site format
+ .uleb128 .Lcstend-.Lcstbegin
+.Lcstbegin:
+ .uleb128 .LcleanupSTART-.LSTARTCODE
+ .uleb128 .LcleanupEND-.LcleanupSTART
+ .uleb128 __condvar_cleanup1-.LSTARTCODE
+ .uleb128 0
+ .uleb128 .LcallUR-.LSTARTCODE
+ .uleb128 .LENDCODE-.LcallUR
+ .uleb128 0
+ .uleb128 0
+.Lcstend:
+
+
+#ifdef SHARED
+ .hidden DW.ref.__gcc_personality_v0
+ .weak DW.ref.__gcc_personality_v0
+ .section .gnu.linkonce.d.DW.ref.__gcc_personality_v0,"aw",@progbits
+ .align 8
+ .type DW.ref.__gcc_personality_v0, @object
+ .size DW.ref.__gcc_personality_v0, 8
+DW.ref.__gcc_personality_v0:
+ .quad __gcc_personality_v0
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S
new file mode 100644
index 000000000..955df28c6
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S
@@ -0,0 +1,189 @@
+/* Copyright (C) 2002, 2003, 2005, 2007, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <bits/kernel-features.h>
+#include <tcb-offsets.h>
+#include <lowlevellock.h>
+
+
+ .comm __fork_generation, 4, 4
+
+ .text
+
+
+ .globl __pthread_once
+ .type __pthread_once,@function
+ .protected __pthread_once
+ .align 16
+__pthread_once:
+.LSTARTCODE:
+ cfi_startproc
+ testl $2, (%rdi)
+ jz 1f
+ xorl %eax, %eax
+ retq
+
+ /* Preserve the function pointer. */
+1: pushq %rsi
+ cfi_adjust_cfa_offset(8)
+ xorq %r10, %r10
+
+ /* Not yet initialized or initialization in progress.
+ Get the fork generation counter now. */
+6: movl (%rdi), %eax
+
+5: movl %eax, %edx
+
+ testl $2, %eax
+ jnz 4f
+
+ andl $3, %edx
+ orl __fork_generation(%rip), %edx
+ orl $1, %edx
+
+ LOCK
+ cmpxchgl %edx, (%rdi)
+ jnz 5b
+
+ /* Check whether another thread already runs the initializer. */
+ testl $1, %eax
+ jz 3f /* No -> do it. */
+
+ /* Check whether the initializer execution was interrupted
+ by a fork. */
+ xorl %edx, %eax
+ testl $0xfffffffc, %eax
+ jnz 3f /* Different for generation -> run initializer. */
+
+ /* Somebody else got here first. Wait. */
+#ifdef __ASSUME_PRIVATE_FUTEX
+ movl $FUTEX_WAIT|FUTEX_PRIVATE_FLAG, %esi
+#else
+# if FUTEX_WAIT == 0
+ movl %fs:PRIVATE_FUTEX, %esi
+# else
+ movl $FUTEX_WAIT, %esi
+ orl %fs:PRIVATE_FUTEX, %esi
+# endif
+#endif
+ movl $SYS_futex, %eax
+ syscall
+ jmp 6b
+
+ /* Preserve the pointer to the control variable. */
+3: pushq %rdi
+ cfi_adjust_cfa_offset(8)
+ pushq %rdi
+ cfi_adjust_cfa_offset(8)
+
+.LcleanupSTART:
+ callq *16(%rsp)
+.LcleanupEND:
+
+ /* Get the control variable address back. */
+ popq %rdi
+ cfi_adjust_cfa_offset(-8)
+
+ /* Sucessful run of the initializer. Signal that we are done. */
+ LOCK
+ incl (%rdi)
+
+ addq $8, %rsp
+ cfi_adjust_cfa_offset(-8)
+
+ /* Wake up all other threads. */
+ movl $0x7fffffff, %edx
+#ifdef __ASSUME_PRIVATE_FUTEX
+ movl $FUTEX_WAKE|FUTEX_PRIVATE_FLAG, %esi
+#else
+ movl $FUTEX_WAKE, %esi
+ orl %fs:PRIVATE_FUTEX, %esi
+#endif
+ movl $SYS_futex, %eax
+ syscall
+
+4: addq $8, %rsp
+ cfi_adjust_cfa_offset(-8)
+ xorl %eax, %eax
+ retq
+ .size __pthread_once,.-__pthread_once
+
+
+ .globl __pthread_once_internal
+__pthread_once_internal = __pthread_once
+
+ .globl pthread_once
+pthread_once = __pthread_once
+
+
+ .type clear_once_control,@function
+ .align 16
+clear_once_control:
+ cfi_adjust_cfa_offset(3 * 8)
+ movq (%rsp), %rdi
+ movq %rax, %r8
+ movl $0, (%rdi)
+
+ movl $0x7fffffff, %edx
+#ifdef __ASSUME_PRIVATE_FUTEX
+ movl $FUTEX_WAKE|FUTEX_PRIVATE_FLAG, %esi
+#else
+ movl $FUTEX_WAKE, %esi
+ orl %fs:PRIVATE_FUTEX, %esi
+#endif
+ movl $SYS_futex, %eax
+ syscall
+
+ movq %r8, %rdi
+.LcallUR:
+ call _Unwind_Resume@PLT
+ hlt
+.LENDCODE:
+ cfi_endproc
+ .size clear_once_control,.-clear_once_control
+
+
+ .section .gcc_except_table,"a",@progbits
+.LexceptSTART:
+ .byte DW_EH_PE_omit # @LPStart format
+ .byte DW_EH_PE_omit # @TType format
+ .byte DW_EH_PE_uleb128 # call-site format
+ .uleb128 .Lcstend-.Lcstbegin
+.Lcstbegin:
+ .uleb128 .LcleanupSTART-.LSTARTCODE
+ .uleb128 .LcleanupEND-.LcleanupSTART
+ .uleb128 clear_once_control-.LSTARTCODE
+ .uleb128 0
+ .uleb128 .LcallUR-.LSTARTCODE
+ .uleb128 .LENDCODE-.LcallUR
+ .uleb128 0
+ .uleb128 0
+.Lcstend:
+
+
+#ifdef SHARED
+ .hidden DW.ref.__gcc_personality_v0
+ .weak DW.ref.__gcc_personality_v0
+ .section .gnu.linkonce.d.DW.ref.__gcc_personality_v0,"aw",@progbits
+ .align 8
+ .type DW.ref.__gcc_personality_v0, @object
+ .size DW.ref.__gcc_personality_v0, 8
+DW.ref.__gcc_personality_v0:
+ .quad __gcc_personality_v0
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S
new file mode 100644
index 000000000..6fd700823
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S
@@ -0,0 +1,179 @@
+/* Copyright (C) 2002, 2003, 2005, 2007, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <lowlevellock.h>
+#include <lowlevelrwlock.h>
+#include <pthread-errnos.h>
+#include <bits/kernel-features.h>
+#include <tcb-offsets.h>
+
+
+ .text
+
+ .globl __pthread_rwlock_rdlock
+ .type __pthread_rwlock_rdlock,@function
+ .protected __pthread_rwlock_rdlock
+ .align 16
+__pthread_rwlock_rdlock:
+ cfi_startproc
+ xorq %r10, %r10
+
+ /* Get the lock. */
+ movl $1, %esi
+ xorl %eax, %eax
+ LOCK
+#if MUTEX == 0
+ cmpxchgl %esi, (%rdi)
+#else
+ cmpxchgl %esi, MUTEX(%rdi)
+#endif
+ jnz 1f
+
+2: movl WRITER(%rdi), %eax
+ testl %eax, %eax
+ jne 14f
+ cmpl $0, WRITERS_QUEUED(%rdi)
+ je 5f
+ cmpl $0, FLAGS(%rdi)
+ je 5f
+
+3: incl READERS_QUEUED(%rdi)
+ je 4f
+
+ movl READERS_WAKEUP(%rdi), %edx
+
+ LOCK
+#if MUTEX == 0
+ decl (%rdi)
+#else
+ decl MUTEX(%rdi)
+#endif
+ jne 10f
+
+11:
+#ifdef __ASSUME_PRIVATE_FUTEX
+ movl $FUTEX_PRIVATE_FLAG|FUTEX_WAIT, %esi
+ xorl PSHARED(%rdi), %esi
+#else
+# if FUTEX_WAIT == 0
+ movl PSHARED(%rdi), %esi
+# else
+ movl $FUTEX_WAIT, %esi
+ orl PSHARED(%rdi), %esi
+# endif
+ xorl %fs:PRIVATE_FUTEX, %esi
+#endif
+ addq $READERS_WAKEUP, %rdi
+ movl $SYS_futex, %eax
+ syscall
+
+ subq $READERS_WAKEUP, %rdi
+
+ /* Reget the lock. */
+ movl $1, %esi
+ xorl %eax, %eax
+ LOCK
+#if MUTEX == 0
+ cmpxchgl %esi, (%rdi)
+#else
+ cmpxchgl %esi, MUTEX(%rdi)
+#endif
+ jnz 12f
+
+13: decl READERS_QUEUED(%rdi)
+ jmp 2b
+
+5: xorl %edx, %edx
+ incl NR_READERS(%rdi)
+ je 8f
+9: LOCK
+#if MUTEX == 0
+ decl (%rdi)
+#else
+ decl MUTEX(%rdi)
+#endif
+ jne 6f
+7:
+
+ movq %rdx, %rax
+ retq
+
+1: movl PSHARED(%rdi), %esi
+#if MUTEX != 0
+ addq $MUTEX, %rdi
+#endif
+ callq __lll_lock_wait
+#if MUTEX != 0
+ subq $MUTEX, %rdi
+#endif
+ jmp 2b
+
+14: cmpl %fs:TID, %eax
+ jne 3b
+ /* Deadlock detected. */
+ movl $EDEADLK, %edx
+ jmp 9b
+
+6: movl PSHARED(%rdi), %esi
+#if MUTEX != 0
+ addq $MUTEX, %rdi
+#endif
+ callq __lll_unlock_wake
+#if MUTEX != 0
+ subq $MUTEX, %rdi
+#endif
+ jmp 7b
+
+ /* Overflow. */
+8: decl NR_READERS(%rdi)
+ movl $EAGAIN, %edx
+ jmp 9b
+
+ /* Overflow. */
+4: decl READERS_QUEUED(%rdi)
+ movl $EAGAIN, %edx
+ jmp 9b
+
+10: movl PSHARED(%rdi), %esi
+#if MUTEX != 0
+ addq $MUTEX, %rdi
+#endif
+ callq __lll_unlock_wake
+#if MUTEX != 0
+ subq $MUTEX, %rdi
+#endif
+ jmp 11b
+
+12: movl PSHARED(%rdi), %esi
+#if MUTEX == 0
+ addq $MUTEX, %rdi
+#endif
+ callq __lll_lock_wait
+#if MUTEX != 0
+ subq $MUTEX, %rdi
+#endif
+ jmp 13b
+ cfi_endproc
+ .size __pthread_rwlock_rdlock,.-__pthread_rwlock_rdlock
+
+ .globl pthread_rwlock_rdlock
+pthread_rwlock_rdlock = __pthread_rwlock_rdlock
+
+ .globl __pthread_rwlock_rdlock_internal
+__pthread_rwlock_rdlock_internal = __pthread_rwlock_rdlock
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
new file mode 100644
index 000000000..4e8e96783
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
@@ -0,0 +1,275 @@
+/* Copyright (C) 2002-2005, 2007, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <lowlevellock.h>
+#include <lowlevelrwlock.h>
+#include <pthread-errnos.h>
+#include <bits/kernel-features.h>
+#include <tcb-offsets.h>
+
+
+/* For the calculation see asm/vsyscall.h. */
+#define VSYSCALL_ADDR_vgettimeofday 0xffffffffff600000
+
+ .text
+
+ .globl pthread_rwlock_timedrdlock
+ .type pthread_rwlock_timedrdlock,@function
+ .align 16
+pthread_rwlock_timedrdlock:
+ cfi_startproc
+ pushq %r12
+ cfi_adjust_cfa_offset(8)
+ cfi_rel_offset(%r12, 0)
+ pushq %r13
+ cfi_adjust_cfa_offset(8)
+ cfi_rel_offset(%r13, 0)
+#ifdef __ASSUME_FUTEX_CLOCK_REALTIME
+# define VALREG %edx
+#else
+ pushq %r14
+ cfi_adjust_cfa_offset(8)
+ cfi_rel_offset(%r14, 0)
+
+ subq $16, %rsp
+ cfi_adjust_cfa_offset(16)
+# define VALREG %r14d
+#endif
+
+ movq %rdi, %r12
+ movq %rsi, %r13
+
+ /* Get the lock. */
+ movl $1, %esi
+ xorl %eax, %eax
+ LOCK
+#if MUTEX == 0
+ cmpxchgl %esi, (%rdi)
+#else
+ cmpxchgl %esi, MUTEX(%rdi)
+#endif
+ jnz 1f
+
+2: movl WRITER(%r12), %eax
+ testl %eax, %eax
+ jne 14f
+ cmpl $0, WRITERS_QUEUED(%r12)
+ je 5f
+ cmpl $0, FLAGS(%r12)
+ je 5f
+
+ /* Check the value of the timeout parameter. */
+3: cmpq $1000000000, 8(%r13)
+ jae 19f
+
+ incl READERS_QUEUED(%r12)
+ je 4f
+
+ movl READERS_WAKEUP(%r12), VALREG
+
+ /* Unlock. */
+ LOCK
+#if MUTEX == 0
+ decl (%r12)
+#else
+ decl MUTEX(%r12)
+#endif
+ jne 10f
+
+11:
+#ifndef __ASSUME_FUTEX_CLOCK_REALTIME
+# ifdef __PIC__
+ cmpl $0, __have_futex_clock_realtime@GOTOFF(%rip)
+# else
+ cmpl $0, __have_futex_clock_realtime
+# endif
+ je .Lreltmo
+#endif
+
+ movl $FUTEX_PRIVATE_FLAG|FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, %esi
+ xorl PSHARED(%r12), %esi
+ movq %r13, %r10
+ movl $0xffffffff, %r9d
+#ifndef __ASSUME_FUTEX_CLOCK_REALTIME
+ movl %r14d, %edx
+#endif
+21: leaq READERS_WAKEUP(%r12), %rdi
+ movl $SYS_futex, %eax
+ syscall
+ movq %rax, %rdx
+
+#ifndef __ASSUME_FUTEX_CLOCK_REALTIME
+ .subsection 2
+.Lreltmo:
+ /* Get current time. */
+ movq %rsp, %rdi
+ xorl %esi, %esi
+ movq $VSYSCALL_ADDR_vgettimeofday, %rax
+ callq *%rax
+
+ /* Compute relative timeout. */
+ movq 8(%rsp), %rax
+ movl $1000, %edi
+ mul %rdi /* Milli seconds to nano seconds. */
+ movq (%r13), %rcx
+ movq 8(%r13), %rdi
+ subq (%rsp), %rcx
+ subq %rax, %rdi
+ jns 15f
+ addq $1000000000, %rdi
+ decq %rcx
+15: testq %rcx, %rcx
+ js 16f /* Time is already up. */
+
+ /* Futex call. */
+ movq %rcx, (%rsp) /* Store relative timeout. */
+ movq %rdi, 8(%rsp)
+
+# ifdef __ASSUME_PRIVATE_FUTEX
+ movl $FUTEX_PRIVATE_FLAG|FUTEX_WAIT, %esi
+ xorl PSHARED(%r12), %esi
+# else
+# if FUTEX_WAIT == 0
+ movl PSHARED(%r12), %esi
+# else
+ movl $FUTEX_WAIT, %esi
+ orl PSHARED(%r12), %esi
+# endif
+ xorl %fs:PRIVATE_FUTEX, %esi
+# endif
+ movq %rsp, %r10
+ movl %r14d, %edx
+
+ jmp 21b
+ .previous
+#endif
+
+17: /* Reget the lock. */
+ movl $1, %esi
+ xorl %eax, %eax
+ LOCK
+#if MUTEX == 0
+ cmpxchgl %esi, (%r12)
+#else
+ cmpxchgl %esi, MUTEX(%r12)
+#endif
+ jnz 12f
+
+13: decl READERS_QUEUED(%r12)
+ cmpq $-ETIMEDOUT, %rdx
+ jne 2b
+
+18: movl $ETIMEDOUT, %edx
+ jmp 9f
+
+
+5: xorl %edx, %edx
+ incl NR_READERS(%r12)
+ je 8f
+9: LOCK
+#if MUTEX == 0
+ decl (%r12)
+#else
+ decl MUTEX(%r12)
+#endif
+ jne 6f
+
+7: movq %rdx, %rax
+
+#ifndef __ASSUME_FUTEX_CLOCK_REALTIME
+ addq $16, %rsp
+ cfi_adjust_cfa_offset(-16)
+ popq %r14
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r14)
+#endif
+ popq %r13
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r13)
+ popq %r12
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r12)
+ retq
+
+#ifdef __ASSUME_PRIVATE_FUTEX
+ cfi_adjust_cfa_offset(16)
+ cfi_rel_offset(%r12, 8)
+ cfi_rel_offset(%r13, 0)
+#else
+ cfi_adjust_cfa_offset(40)
+ cfi_offset(%r12, -16)
+ cfi_offset(%r13, -24)
+ cfi_offset(%r14, -32)
+#endif
+1: movl PSHARED(%rdi), %esi
+#if MUTEX != 0
+ addq $MUTEX, %rdi
+#endif
+ callq __lll_lock_wait
+ jmp 2b
+
+14: cmpl %fs:TID, %eax
+ jne 3b
+ movl $EDEADLK, %edx
+ jmp 9b
+
+6: movl PSHARED(%r12), %esi
+#if MUTEX == 0
+ movq %r12, %rdi
+#else
+ leal MUTEX(%r12), %rdi
+#endif
+ callq __lll_unlock_wake
+ jmp 7b
+
+ /* Overflow. */
+8: decl NR_READERS(%r12)
+ movl $EAGAIN, %edx
+ jmp 9b
+
+ /* Overflow. */
+4: decl READERS_QUEUED(%r12)
+ movl $EAGAIN, %edx
+ jmp 9b
+
+10: movl PSHARED(%r12), %esi
+#if MUTEX == 0
+ movq %r12, %rdi
+#else
+ leaq MUTEX(%r12), %rdi
+#endif
+ callq __lll_unlock_wake
+ jmp 11b
+
+12: movl PSHARED(%r12), %esi
+#if MUTEX == 0
+ movq %r12, %rdi
+#else
+ leaq MUTEX(%r12), %rdi
+#endif
+ callq __lll_lock_wait
+ jmp 13b
+
+16: movq $-ETIMEDOUT, %rdx
+ jmp 17b
+
+19: movl $EINVAL, %edx
+ jmp 9b
+ cfi_endproc
+ .size pthread_rwlock_timedrdlock,.-pthread_rwlock_timedrdlock
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
new file mode 100644
index 000000000..6479a7a63
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
@@ -0,0 +1,267 @@
+/* Copyright (C) 2002, 2003, 2005, 2007, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <lowlevellock.h>
+#include <lowlevelrwlock.h>
+#include <pthread-errnos.h>
+#include <bits/kernel-features.h>
+#include <tcb-offsets.h>
+
+
+/* For the calculation see asm/vsyscall.h. */
+#define VSYSCALL_ADDR_vgettimeofday 0xffffffffff600000
+
+ .text
+
+ .globl pthread_rwlock_timedwrlock
+ .type pthread_rwlock_timedwrlock,@function
+ .align 16
+pthread_rwlock_timedwrlock:
+ cfi_startproc
+ pushq %r12
+ cfi_adjust_cfa_offset(8)
+ cfi_rel_offset(%r12, 0)
+ pushq %r13
+ cfi_adjust_cfa_offset(8)
+ cfi_rel_offset(%r13, 0)
+#ifdef __ASSUME_FUTEX_CLOCK_REALTIME
+# define VALREG %edx
+#else
+ pushq %r14
+ cfi_adjust_cfa_offset(8)
+ cfi_rel_offset(%r14, 0)
+
+ subq $16, %rsp
+ cfi_adjust_cfa_offset(16)
+# define VALREG %r14d
+#endif
+
+ movq %rdi, %r12
+ movq %rsi, %r13
+
+ /* Get the lock. */
+ movl $1, %esi
+ xorl %eax, %eax
+ LOCK
+#if MUTEX == 0
+ cmpxchgl %esi, (%rdi)
+#else
+ cmpxchgl %esi, MUTEX(%rdi)
+#endif
+ jnz 1f
+
+2: movl WRITER(%r12), %eax
+ testl %eax, %eax
+ jne 14f
+ cmpl $0, NR_READERS(%r12)
+ je 5f
+
+ /* Check the value of the timeout parameter. */
+3: cmpq $1000000000, 8(%r13)
+ jae 19f
+
+ incl WRITERS_QUEUED(%r12)
+ je 4f
+
+ movl WRITERS_WAKEUP(%r12), VALREG
+
+ LOCK
+#if MUTEX == 0
+ decl (%r12)
+#else
+ decl MUTEX(%r12)
+#endif
+ jne 10f
+
+11:
+#ifndef __ASSUME_FUTEX_CLOCK_REALTIME
+# ifdef __PIC__
+ cmpl $0, __have_futex_clock_realtime@GOTOFF(%rip)
+# else
+ cmpl $0, __have_futex_clock_realtime
+# endif
+ je .Lreltmo
+#endif
+
+ movl $FUTEX_PRIVATE_FLAG|FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, %esi
+ xorl PSHARED(%r12), %esi
+ movq %r13, %r10
+ movl $0xffffffff, %r9d
+#ifndef __ASSUME_FUTEX_CLOCK_REALTIME
+ movl %r14d, %edx
+#endif
+21: leaq WRITERS_WAKEUP(%r12), %rdi
+ movl $SYS_futex, %eax
+ syscall
+ movq %rax, %rdx
+
+#ifndef __ASSUME_FUTEX_CLOCK_REALTIME
+ .subsection 2
+.Lreltmo:
+ /* Get current time. */
+ movq %rsp, %rdi
+ xorl %esi, %esi
+ movq $VSYSCALL_ADDR_vgettimeofday, %rax
+ callq *%rax
+
+ /* Compute relative timeout. */
+ movq 8(%rsp), %rax
+ movl $1000, %edi
+ mul %rdi /* Milli seconds to nano seconds. */
+ movq (%r13), %rcx
+ movq 8(%r13), %rdi
+ subq (%rsp), %rcx
+ subq %rax, %rdi
+ jns 15f
+ addq $1000000000, %rdi
+ decq %rcx
+15: testq %rcx, %rcx
+ js 16f /* Time is already up. */
+
+ /* Futex call. */
+ movq %rcx, (%rsp) /* Store relative timeout. */
+ movq %rdi, 8(%rsp)
+
+# ifdef __ASSUME_PRIVATE_FUTEX
+ movl $FUTEX_PRIVATE_FLAG|FUTEX_WAIT, %esi
+ xorl PSHARED(%r12), %esi
+# else
+# if FUTEX_WAIT == 0
+ movl PSHARED(%r12), %esi
+# else
+ movl $FUTEX_WAIT, %esi
+ orl PSHARED(%r12), %esi
+# endif
+ xorl %fs:PRIVATE_FUTEX, %esi
+# endif
+ movq %rsp, %r10
+ movl %r14d, %edx
+
+ jmp 21b
+ .previous
+#endif
+
+17: /* Reget the lock. */
+ movl $1, %esi
+ xorl %eax, %eax
+ LOCK
+#if MUTEX == 0
+ cmpxchgl %esi, (%r12)
+#else
+ cmpxchgl %esi, MUTEX(%r12)
+#endif
+ jnz 12f
+
+13: decl WRITERS_QUEUED(%r12)
+ cmpq $-ETIMEDOUT, %rdx
+ jne 2b
+
+18: movl $ETIMEDOUT, %edx
+ jmp 9f
+
+
+5: xorl %edx, %edx
+ movl %fs:TID, %eax
+ movl %eax, WRITER(%r12)
+9: LOCK
+#if MUTEX == 0
+ decl (%r12)
+#else
+ decl MUTEX(%r12)
+#endif
+ jne 6f
+
+7: movq %rdx, %rax
+
+#ifndef __ASSUME_PRIVATE_FUTEX
+ addq $16, %rsp
+ cfi_adjust_cfa_offset(-16)
+ popq %r14
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r14)
+#endif
+ popq %r13
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r13)
+ popq %r12
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r12)
+ retq
+
+#ifdef __ASSUME_PRIVATE_FUTEX
+ cfi_adjust_cfa_offset(16)
+ cfi_rel_offset(%r12, 8)
+ cfi_rel_offset(%r13, 0)
+#else
+ cfi_adjust_cfa_offset(40)
+ cfi_offset(%r12, -16)
+ cfi_offset(%r13, -24)
+ cfi_offset(%r14, -32)
+#endif
+1: movl PSHARED(%rdi), %esi
+#if MUTEX != 0
+ addq $MUTEX, %rdi
+#endif
+ callq __lll_lock_wait
+ jmp 2b
+
+14: cmpl %fs:TID, %eax
+ jne 3b
+20: movl $EDEADLK, %edx
+ jmp 9b
+
+6: movl PSHARED(%r12), %esi
+#if MUTEX == 0
+ movq %r12, %rdi
+#else
+ leal MUTEX(%r12), %rdi
+#endif
+ callq __lll_unlock_wake
+ jmp 7b
+
+ /* Overflow. */
+4: decl WRITERS_QUEUED(%r12)
+ movl $EAGAIN, %edx
+ jmp 9b
+
+10: movl PSHARED(%r12), %esi
+#if MUTEX == 0
+ movq %r12, %rdi
+#else
+ leaq MUTEX(%r12), %rdi
+#endif
+ callq __lll_unlock_wake
+ jmp 11b
+
+12: movl PSHARED(%r12), %esi
+#if MUTEX == 0
+ movq %r12, %rdi
+#else
+ leaq MUTEX(%r12), %rdi
+#endif
+ callq __lll_lock_wait
+ jmp 13b
+
+16: movq $-ETIMEDOUT, %rdx
+ jmp 17b
+
+19: movl $EINVAL, %edx
+ jmp 9b
+ cfi_endproc
+ .size pthread_rwlock_timedwrlock,.-pthread_rwlock_timedwrlock
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S
new file mode 100644
index 000000000..303cba07a
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S
@@ -0,0 +1,130 @@
+/* Copyright (C) 2002, 2003, 2005, 2007, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <lowlevellock.h>
+#include <lowlevelrwlock.h>
+#include <bits/kernel-features.h>
+
+
+ .text
+
+ .globl __pthread_rwlock_unlock
+ .type __pthread_rwlock_unlock,@function
+ .protected __pthread_rwlock_unlock
+ .align 16
+__pthread_rwlock_unlock:
+ cfi_startproc
+ /* Get the lock. */
+ movl $1, %esi
+ xorl %eax, %eax
+ LOCK
+#if MUTEX == 0
+ cmpxchgl %esi, (%rdi)
+#else
+ cmpxchgl %esi, MUTEX(%rdi)
+#endif
+ jnz 1f
+
+2: cmpl $0, WRITER(%rdi)
+ jne 5f
+ decl NR_READERS(%rdi)
+ jnz 6f
+
+5: movl $0, WRITER(%rdi)
+
+ movl $1, %edx
+ leaq WRITERS_WAKEUP(%rdi), %r10
+ cmpl $0, WRITERS_QUEUED(%rdi)
+ jne 0f
+
+ /* If also no readers waiting nothing to do. */
+ cmpl $0, READERS_QUEUED(%rdi)
+ je 6f
+
+ movl $0x7fffffff, %edx
+ leaq READERS_WAKEUP(%rdi), %r10
+
+0: incl (%r10)
+ LOCK
+#if MUTEX == 0
+ decl (%rdi)
+#else
+ decl MUTEX(%rdi)
+#endif
+ jne 7f
+
+8:
+#ifdef __ASSUME_PRIVATE_FUTEX
+ movl $FUTEX_PRIVATE_FLAG|FUTEX_WAKE, %esi
+ xorl PSHARED(%rdi), %esi
+#else
+ movl $FUTEX_WAKE, %esi
+ orl PSHARED(%rdi), %esi
+ xorl %fs:PRIVATE_FUTEX, %esi
+#endif
+ movl $SYS_futex, %eax
+ movq %r10, %rdi
+ syscall
+
+ xorl %eax, %eax
+ retq
+
+ .align 16
+6: LOCK
+#if MUTEX == 0
+ decl (%rdi)
+#else
+ decl MUTEX(%rdi)
+#endif
+ jne 3f
+
+4: xorl %eax, %eax
+ retq
+
+1: movl PSHARED(%rdi), %esi
+#if MUTEX != 0
+ addq $MUTEX, %rdi
+#endif
+ callq __lll_lock_wait
+#if MUTEX != 0
+ subq $MUTEX, %rdi
+#endif
+ jmp 2b
+
+3: movl PSHARED(%rdi), %esi
+#if MUTEX != 0
+ addq $MUTEX, %rdi
+#endif
+ callq __lll_unlock_wake
+ jmp 4b
+
+7: movl PSHARED(%rdi), %esi
+#if MUTEX != 0
+ addq $MUTEX, %rdi
+#endif
+ callq __lll_unlock_wake
+ jmp 8b
+ cfi_endproc
+ .size __pthread_rwlock_unlock,.-__pthread_rwlock_unlock
+
+ .globl pthread_rwlock_unlock
+pthread_rwlock_unlock = __pthread_rwlock_unlock
+
+ .globl __pthread_rwlock_unlock_internal
+__pthread_rwlock_unlock_internal = __pthread_rwlock_unlock
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S
new file mode 100644
index 000000000..7c5d6a892
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S
@@ -0,0 +1,167 @@
+/* Copyright (C) 2002, 2003, 2005, 2007, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <lowlevellock.h>
+#include <lowlevelrwlock.h>
+#include <pthread-errnos.h>
+#include <bits/kernel-features.h>
+#include <tcb-offsets.h>
+
+
+ .text
+
+ .globl __pthread_rwlock_wrlock
+ .type __pthread_rwlock_wrlock,@function
+ .protected __pthread_rwlock_wrlock
+ .align 16
+__pthread_rwlock_wrlock:
+ cfi_startproc
+ xorq %r10, %r10
+
+ /* Get the lock. */
+ movl $1, %esi
+ xorl %eax, %eax
+ LOCK
+#if MUTEX == 0
+ cmpxchgl %esi, (%rdi)
+#else
+ cmpxchgl %esi, MUTEX(%rdi)
+#endif
+ jnz 1f
+
+2: movl WRITER(%rdi), %eax
+ testl %eax, %eax
+ jne 14f
+ cmpl $0, NR_READERS(%rdi)
+ je 5f
+
+3: incl WRITERS_QUEUED(%rdi)
+ je 4f
+
+ movl WRITERS_WAKEUP(%rdi), %edx
+
+ LOCK
+#if MUTEX == 0
+ decl (%rdi)
+#else
+ decl MUTEX(%rdi)
+#endif
+ jne 10f
+
+11:
+#ifdef __ASSUME_PRIVATE_FUTEX
+ movl $FUTEX_PRIVATE_FLAG|FUTEX_WAIT, %esi
+ xorl PSHARED(%rdi), %esi
+#else
+# if FUTEX_WAIT == 0
+ movl PSHARED(%rdi), %esi
+# else
+ movl $FUTEX_WAIT, %esi
+ orl PSHARED(%rdi), %esi
+# endif
+ xorl %fs:PRIVATE_FUTEX, %esi
+#endif
+ addq $WRITERS_WAKEUP, %rdi
+ movl $SYS_futex, %eax
+ syscall
+
+ subq $WRITERS_WAKEUP, %rdi
+
+ /* Reget the lock. */
+ movl $1, %esi
+ xorl %eax, %eax
+ LOCK
+#if MUTEX == 0
+ cmpxchgl %esi, (%rdi)
+#else
+ cmpxchgl %esi, MUTEX(%rdi)
+#endif
+ jnz 12f
+
+13: decl WRITERS_QUEUED(%rdi)
+ jmp 2b
+
+5: xorl %edx, %edx
+ movl %fs:TID, %eax
+ movl %eax, WRITER(%rdi)
+9: LOCK
+#if MUTEX == 0
+ decl (%rdi)
+#else
+ decl MUTEX(%rdi)
+#endif
+ jne 6f
+7:
+
+ movq %rdx, %rax
+ retq
+
+1: movl PSHARED(%rdi), %esi
+#if MUTEX != 0
+ addq $MUTEX, %rdi
+#endif
+ callq __lll_lock_wait
+#if MUTEX != 0
+ subq $MUTEX, %rdi
+#endif
+ jmp 2b
+
+14: cmpl %fs:TID, %eax
+ jne 3b
+ movl $EDEADLK, %edx
+ jmp 9b
+
+6: movl PSHARED(%rdi), %esi
+#if MUTEX != 0
+ addq $MUTEX, %rdi
+#endif
+ callq __lll_unlock_wake
+ jmp 7b
+
+4: decl WRITERS_QUEUED(%rdi)
+ movl $EAGAIN, %edx
+ jmp 9b
+
+10: movl PSHARED(%rdi), %esi
+#if MUTEX != 0
+ addq $MUTEX, %rdi
+#endif
+ callq __lll_unlock_wake
+#if MUTEX != 0
+ subq $MUTEX, %rdi
+#endif
+ jmp 11b
+
+12: movl PSHARED(%rdi), %esi
+#if MUTEX != 0
+ addq $MUTEX, %rdi
+#endif
+ callq __lll_lock_wait
+#if MUTEX != 0
+ subq $MUTEX, %rdi
+#endif
+ jmp 13b
+ cfi_endproc
+ .size __pthread_rwlock_wrlock,.-__pthread_rwlock_wrlock
+
+ .globl pthread_rwlock_wrlock
+pthread_rwlock_wrlock = __pthread_rwlock_wrlock
+
+ .globl __pthread_rwlock_wrlock_internal
+__pthread_rwlock_wrlock_internal = __pthread_rwlock_wrlock
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_setaffinity.c b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_setaffinity.c
new file mode 100644
index 000000000..e60113a76
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_setaffinity.c
@@ -0,0 +1,14 @@
+#include <tls.h>
+
+#define RESET_VGETCPU_CACHE() \
+ do { \
+ __asm__ __volatile__ ("movl %0, %%fs:%P1\n\t" \
+ "movl %0, %%fs:%P2" \
+ : \
+ : "ir" (0), "i" (offsetof (struct pthread, \
+ header.vgetcpu_cache[0])), \
+ "i" (offsetof (struct pthread, \
+ header.vgetcpu_cache[1]))); \
+ } while (0)
+
+#include "../pthread_setaffinity.c"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_spin_init.c b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_spin_init.c
new file mode 100644
index 000000000..483de8cac
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_spin_init.c
@@ -0,0 +1 @@
+#include <sysdeps/x86_64/pthread_spin_init.c>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_spin_unlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_spin_unlock.S
new file mode 100644
index 000000000..e8e2ba262
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_spin_unlock.S
@@ -0,0 +1 @@
+#include <sysdeps/x86_64/pthread_spin_unlock.S>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S
new file mode 100644
index 000000000..36865d5aa
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S
@@ -0,0 +1,88 @@
+/* Copyright (C) 2002, 2003, 2005, 2007, 2008 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <lowlevellock.h>
+#include <pthread-errnos.h>
+#include <structsem.h>
+
+
+ .text
+
+ .globl sem_post
+ .type sem_post,@function
+ .align 16
+sem_post:
+#if VALUE == 0
+ movl (%rdi), %eax
+#else
+ movl VALUE(%rdi), %eax
+#endif
+0: cmpl $SEM_VALUE_MAX, %eax
+ je 3f
+ leal 1(%rax), %esi
+ LOCK
+#if VALUE == 0
+ cmpxchgl %esi, (%rdi)
+#else
+ cmpxchgl %esi, VALUE(%rdi)
+#endif
+ jnz 0b
+
+ cmpq $0, NWAITERS(%rdi)
+ je 2f
+
+ movl $SYS_futex, %eax
+ movl $FUTEX_WAKE, %esi
+ orl PRIVATE(%rdi), %esi
+ movl $1, %edx
+ syscall
+
+ testq %rax, %rax
+ js 1f
+
+2: xorl %eax, %eax
+ retq
+
+1:
+#if USE___THREAD
+ movl $EINVAL, %eax
+#else
+ callq __errno_location@plt
+ movl $EINVAL, %edx
+#endif
+ jmp 4f
+
+3:
+#if USE___THREAD
+ movl $EOVERFLOW, %eax
+#else
+ callq __errno_location@plt
+ movl $EOVERFLOW, %edx
+#endif
+
+4:
+#if USE___THREAD
+ movq errno@gottpoff(%rip), %rdx
+ movl %eax, %fs:(%rdx)
+#else
+ movl %edx, (%rax)
+#endif
+ orl $-1, %eax
+ retq
+ .size sem_post,.-sem_post
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S
new file mode 100644
index 000000000..688aeaa33
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S
@@ -0,0 +1,378 @@
+/* Copyright (C) 2002, 2003, 2005, 2007, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <bits/kernel-features.h>
+#include <lowlevellock.h>
+#include <pthread-errnos.h>
+#include <structsem.h>
+
+
+/* For the calculation see asm/vsyscall.h. */
+#define VSYSCALL_ADDR_vgettimeofday 0xffffffffff600000
+
+ .text
+
+ .globl sem_timedwait
+ .type sem_timedwait,@function
+ .align 16
+sem_timedwait:
+.LSTARTCODE:
+ cfi_startproc
+#if VALUE == 0
+ movl (%rdi), %eax
+#else
+ movl VALUE(%rdi), %eax
+#endif
+2: testl %eax, %eax
+ je 1f
+
+ leaq -1(%rax), %rdx
+ LOCK
+#if VALUE == 0
+ cmpxchgl %edx, (%rdi)
+#else
+ cmpxchgl %edx, VALUE(%rdi)
+#endif
+ jne 2b
+
+ xorl %eax, %eax
+ retq
+
+ /* Check whether the timeout value is valid. */
+1: cmpq $1000000000, 8(%rsi)
+ jae 6f
+
+#ifndef __ASSUME_FUTEX_CLOCK_REALTIME
+# ifdef __PIC__
+ cmpl $0, __have_futex_clock_realtime@GOTOFF(%rip)
+# else
+ cmpl $0, __have_futex_clock_realtime
+# endif
+ je .Lreltmo
+#endif
+
+ /* This push is only needed to store the sem_t pointer for the
+ exception handler. */
+ pushq %rdi
+ cfi_adjust_cfa_offset(8)
+
+ movq %rsi, %r10
+
+ LOCK
+ addq $1, NWAITERS(%rdi)
+
+.LcleanupSTART:
+13: call __pthread_enable_asynccancel
+ movl %eax, %r8d
+
+#if VALUE != 0
+ leaq VALUE(%rdi), %rdi
+#endif
+ movl $0xffffffff, %r9d
+ movl $FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, %esi
+ orl PRIVATE(%rdi), %esi
+ movl $SYS_futex, %eax
+ xorl %edx, %edx
+ syscall
+ movq %rax, %r9
+#if VALUE != 0
+ leaq -VALUE(%rdi), %rdi
+#endif
+
+ xchgq %r8, %rdi
+ call __pthread_disable_asynccancel
+.LcleanupEND:
+ movq %r8, %rdi
+
+ testq %r9, %r9
+ je 11f
+ cmpq $-EWOULDBLOCK, %r9
+ jne 3f
+
+11:
+#if VALUE == 0
+ movl (%rdi), %eax
+#else
+ movl VALUE(%rdi), %eax
+#endif
+14: testl %eax, %eax
+ je 13b
+
+ leaq -1(%rax), %rcx
+ LOCK
+#if VALUE == 0
+ cmpxchgl %ecx, (%rdi)
+#else
+ cmpxchgl %ecx, VALUE(%rdi)
+#endif
+ jne 14b
+
+ xorl %eax, %eax
+
+15: LOCK
+ subq $1, NWAITERS(%rdi)
+
+ leaq 8(%rsp), %rsp
+ cfi_adjust_cfa_offset(-8)
+ retq
+
+ cfi_adjust_cfa_offset(8)
+3: negq %r9
+#if USE___THREAD
+ movq errno@gottpoff(%rip), %rdx
+ movl %r9d, %fs:(%rdx)
+#else
+ callq __errno_location@plt
+ movl %r9d, (%rax)
+#endif
+
+ orl $-1, %eax
+ jmp 15b
+
+ cfi_adjust_cfa_offset(-8)
+6:
+#if USE___THREAD
+ movq errno@gottpoff(%rip), %rdx
+ movl $EINVAL, %fs:(%rdx)
+#else
+ callq __errno_location@plt
+ movl $EINVAL, (%rax)
+#endif
+
+ orl $-1, %eax
+
+ retq
+
+#ifndef __ASSUME_FUTEX_CLOCK_REALTIME
+.Lreltmo:
+ pushq %r12
+ cfi_adjust_cfa_offset(8)
+ cfi_rel_offset(%r12, 0)
+ pushq %r13
+ cfi_adjust_cfa_offset(8)
+ cfi_rel_offset(%r13, 0)
+ pushq %r14
+ cfi_adjust_cfa_offset(8)
+ cfi_rel_offset(%r14, 0)
+
+#ifdef __ASSUME_FUTEX_CLOCK_REALTIME
+# define STACKFRAME 8
+#else
+# define STACKFRAME 24
+#endif
+ subq $STACKFRAME, %rsp
+ cfi_adjust_cfa_offset(STACKFRAME)
+
+ movq %rdi, %r12
+ movq %rsi, %r13
+
+ LOCK
+ addq $1, NWAITERS(%r12)
+
+7: xorl %esi, %esi
+ movq %rsp, %rdi
+ movq $VSYSCALL_ADDR_vgettimeofday, %rax
+ callq *%rax
+
+ /* Compute relative timeout. */
+ movq 8(%rsp), %rax
+ movl $1000, %edi
+ mul %rdi /* Milli seconds to nano seconds. */
+ movq (%r13), %rdi
+ movq 8(%r13), %rsi
+ subq (%rsp), %rdi
+ subq %rax, %rsi
+ jns 5f
+ addq $1000000000, %rsi
+ decq %rdi
+5: testq %rdi, %rdi
+ movl $ETIMEDOUT, %r14d
+ js 36f /* Time is already up. */
+
+ movq %rdi, (%rsp) /* Store relative timeout. */
+ movq %rsi, 8(%rsp)
+
+.LcleanupSTART2:
+ call __pthread_enable_asynccancel
+ movl %eax, 16(%rsp)
+
+ movq %rsp, %r10
+# if VALUE == 0
+ movq %r12, %rdi
+# else
+ leaq VALUE(%r12), %rdi
+# endif
+# if FUTEX_WAIT == 0
+ movl PRIVATE(%rdi), %esi
+# else
+ movl $FUTEX_WAIT, %esi
+ orl PRIVATE(%rdi), %esi
+# endif
+ movl $SYS_futex, %eax
+ xorl %edx, %edx
+ syscall
+ movq %rax, %r14
+
+ movl 16(%rsp), %edi
+ call __pthread_disable_asynccancel
+.LcleanupEND2:
+
+ testq %r14, %r14
+ je 9f
+ cmpq $-EWOULDBLOCK, %r14
+ jne 33f
+
+9:
+# if VALUE == 0
+ movl (%r12), %eax
+# else
+ movl VALUE(%r12), %eax
+# endif
+8: testl %eax, %eax
+ je 7b
+
+ leaq -1(%rax), %rcx
+ LOCK
+# if VALUE == 0
+ cmpxchgl %ecx, (%r12)
+# else
+ cmpxchgl %ecx, VALUE(%r12)
+# endif
+ jne 8b
+
+ xorl %eax, %eax
+
+45: LOCK
+ subq $1, NWAITERS(%r12)
+
+ addq $STACKFRAME, %rsp
+ cfi_adjust_cfa_offset(-STACKFRAME)
+ popq %r14
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r14)
+ popq %r13
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r13)
+ popq %r12
+ cfi_adjust_cfa_offset(-8)
+ cfi_restore(%r12)
+ retq
+
+ cfi_adjust_cfa_offset(STACKFRAME + 3 * 8)
+ cfi_rel_offset(%r12, STACKFRAME + 2 * 8)
+ cfi_rel_offset(%r13, STACKFRAME + 1 * 8)
+ cfi_rel_offset(%r14, STACKFRAME)
+33: negq %r14
+36:
+#if USE___THREAD
+ movq errno@gottpoff(%rip), %rdx
+ movl %r14d, %fs:(%rdx)
+#else
+ callq __errno_location@plt
+ movl %r14d, (%rax)
+#endif
+
+ orl $-1, %eax
+ jmp 45b
+#endif
+ cfi_endproc
+ .size sem_timedwait,.-sem_timedwait
+
+
+ .type sem_timedwait_cleanup,@function
+sem_timedwait_cleanup:
+ cfi_startproc
+ cfi_adjust_cfa_offset(8)
+
+ movq (%rsp), %rdi
+ LOCK
+ subq $1, NWAITERS(%rdi)
+ movq %rax, %rdi
+.LcallUR:
+ call _Unwind_Resume@PLT
+ hlt
+.LENDCODE:
+ cfi_endproc
+ .size sem_timedwait_cleanup,.-sem_timedwait_cleanup
+
+
+#ifndef __ASSUME_FUTEX_CLOCK_REALTIME
+ .type sem_timedwait_cleanup2,@function
+sem_timedwait_cleanup2:
+ cfi_startproc
+ cfi_adjust_cfa_offset(STACKFRAME + 3 * 8)
+ cfi_rel_offset(%r12, STACKFRAME + 2 * 8)
+ cfi_rel_offset(%r13, STACKFRAME + 1 * 8)
+ cfi_rel_offset(%r14, STACKFRAME)
+
+ LOCK
+ subq $1, NWAITERS(%r12)
+ movq %rax, %rdi
+ movq STACKFRAME(%rsp), %r14
+ movq STACKFRAME+8(%rsp), %r13
+ movq STACKFRAME+16(%rsp), %r12
+.LcallUR2:
+ call _Unwind_Resume@PLT
+ hlt
+.LENDCODE2:
+ cfi_endproc
+ .size sem_timedwait_cleanup2,.-sem_timedwait_cleanup2
+#endif
+
+
+ .section .gcc_except_table,"a",@progbits
+.LexceptSTART:
+ .byte DW_EH_PE_omit # @LPStart format
+ .byte DW_EH_PE_omit # @TType format
+ .byte DW_EH_PE_uleb128 # call-site format
+ .uleb128 .Lcstend-.Lcstbegin
+.Lcstbegin:
+ .uleb128 .LcleanupSTART-.LSTARTCODE
+ .uleb128 .LcleanupEND-.LcleanupSTART
+ .uleb128 sem_timedwait_cleanup-.LSTARTCODE
+ .uleb128 0
+#ifndef __ASSUME_FUTEX_CLOCK_REALTIME
+ .uleb128 .LcleanupSTART2-.LSTARTCODE
+ .uleb128 .LcleanupEND2-.LcleanupSTART2
+ .uleb128 sem_timedwait_cleanup2-.LSTARTCODE
+ .uleb128 0
+#endif
+ .uleb128 .LcallUR-.LSTARTCODE
+ .uleb128 .LENDCODE-.LcallUR
+ .uleb128 0
+ .uleb128 0
+#ifndef __ASSUME_FUTEX_CLOCK_REALTIME
+ .uleb128 .LcallUR2-.LSTARTCODE
+ .uleb128 .LENDCODE2-.LcallUR2
+ .uleb128 0
+ .uleb128 0
+#endif
+.Lcstend:
+
+
+#ifdef SHARED
+ .hidden DW.ref.__gcc_personality_v0
+ .weak DW.ref.__gcc_personality_v0
+ .section .gnu.linkonce.d.DW.ref.__gcc_personality_v0,"aw",@progbits
+ .align 8
+ .type DW.ref.__gcc_personality_v0, @object
+ .size DW.ref.__gcc_personality_v0, 8
+DW.ref.__gcc_personality_v0:
+ .quad __gcc_personality_v0
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/sem_trywait.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/sem_trywait.S
new file mode 100644
index 000000000..f6b99c145
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/sem_trywait.S
@@ -0,0 +1,51 @@
+/* Copyright (C) 2002, 2003, 2005, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <lowlevellock.h>
+#include <pthread-errnos.h>
+
+ .text
+
+ .globl sem_trywait
+ .type sem_trywait,@function
+ .align 16
+sem_trywait:
+ movl (%rdi), %eax
+2: testl %eax, %eax
+ jz 1f
+
+ leal -1(%rax), %edx
+ LOCK
+ cmpxchgl %edx, (%rdi)
+ jne 2b
+
+ xorl %eax, %eax
+ retq
+
+1:
+#if USE___THREAD
+ movq errno@gottpoff(%rip), %rdx
+ movl $EAGAIN, %fs:(%rdx)
+#else
+ callq __errno_location@plt
+ movl $EAGAIN, (%rax)
+#endif
+ orl $-1, %eax
+ retq
+ .size sem_trywait,.-sem_trywait
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S
new file mode 100644
index 000000000..61e82299b
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S
@@ -0,0 +1,173 @@
+/* Copyright (C) 2002, 2003, 2005, 2007, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <lowlevellock.h>
+#include <pthread-errnos.h>
+#include <structsem.h>
+
+
+ .text
+
+ .globl sem_wait
+ .type sem_wait,@function
+ .align 16
+sem_wait:
+.LSTARTCODE:
+ cfi_startproc
+
+#if VALUE == 0
+ movl (%rdi), %eax
+#else
+ movl VALUE(%rdi), %eax
+#endif
+2: testl %eax, %eax
+ je 1f
+
+ leal -1(%rax), %edx
+ LOCK
+#if VALUE == 0
+ cmpxchgl %edx, (%rdi)
+#else
+ cmpxchgl %edx, VALUE(%rdi)
+#endif
+ jne 2b
+
+ xorl %eax, %eax
+ retq
+
+ /* This push is only needed to store the sem_t pointer for the
+ exception handler. */
+1: pushq %rdi
+ cfi_adjust_cfa_offset(8)
+
+ LOCK
+ addq $1, NWAITERS(%rdi)
+
+.LcleanupSTART:
+6: call __pthread_enable_asynccancel
+ movl %eax, %r8d
+
+ xorq %r10, %r10
+ movl $SYS_futex, %eax
+#if FUTEX_WAIT == 0
+ movl PRIVATE(%rdi), %esi
+#else
+ movl $FUTEX_WAIT, %esi
+ orl PRIVATE(%rdi), %esi
+#endif
+ xorl %edx, %edx
+ syscall
+ movq %rax, %rcx
+
+ xchgq %r8, %rdi
+ call __pthread_disable_asynccancel
+.LcleanupEND:
+ movq %r8, %rdi
+
+ testq %rcx, %rcx
+ je 3f
+ cmpq $-EWOULDBLOCK, %rcx
+ jne 4f
+
+3:
+#if VALUE == 0
+ movl (%rdi), %eax
+#else
+ movl VALUE(%rdi), %eax
+#endif
+5: testl %eax, %eax
+ je 6b
+
+ leal -1(%rax), %edx
+ LOCK
+#if VALUE == 0
+ cmpxchgl %edx, (%rdi)
+#else
+ cmpxchgl %edx, VALUE(%rdi)
+#endif
+ jne 5b
+
+ xorl %eax, %eax
+
+9: LOCK
+ subq $1, NWAITERS(%rdi)
+
+ leaq 8(%rsp), %rsp
+ cfi_adjust_cfa_offset(-8)
+
+ retq
+
+ cfi_adjust_cfa_offset(8)
+4: negq %rcx
+#if USE___THREAD
+ movq errno@gottpoff(%rip), %rdx
+ movl %ecx, %fs:(%rdx)
+#else
+# error "not supported. %rcx and %rdi must be preserved"
+ callq __errno_location@plt
+ movl %ecx, (%rax)
+#endif
+ orl $-1, %eax
+
+ jmp 9b
+ .size sem_wait,.-sem_wait
+
+
+ .type sem_wait_cleanup,@function
+sem_wait_cleanup:
+ movq (%rsp), %rdi
+ LOCK
+ subq $1, NWAITERS(%rdi)
+ movq %rax, %rdi
+.LcallUR:
+ call _Unwind_Resume@PLT
+ hlt
+.LENDCODE:
+ cfi_endproc
+ .size sem_wait_cleanup,.-sem_wait_cleanup
+
+
+ .section .gcc_except_table,"a",@progbits
+.LexceptSTART:
+ .byte DW_EH_PE_omit # @LPStart format
+ .byte DW_EH_PE_omit # @TType format
+ .byte DW_EH_PE_uleb128 # call-site format
+ .uleb128 .Lcstend-.Lcstbegin
+.Lcstbegin:
+ .uleb128 .LcleanupSTART-.LSTARTCODE
+ .uleb128 .LcleanupEND-.LcleanupSTART
+ .uleb128 sem_wait_cleanup-.LSTARTCODE
+ .uleb128 0
+ .uleb128 .LcallUR-.LSTARTCODE
+ .uleb128 .LENDCODE-.LcallUR
+ .uleb128 0
+ .uleb128 0
+.Lcstend:
+
+
+#ifdef SHARED
+ .hidden DW.ref.__gcc_personality_v0
+ .weak DW.ref.__gcc_personality_v0
+ .section .gnu.linkonce.d.DW.ref.__gcc_personality_v0,"aw",@progbits
+ .align 8
+ .type DW.ref.__gcc_personality_v0, @object
+ .size DW.ref.__gcc_personality_v0, 8
+DW.ref.__gcc_personality_v0:
+ .quad __gcc_personality_v0
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h
new file mode 100644
index 000000000..6e8041738
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h
@@ -0,0 +1,110 @@
+/* Copyright (C) 2002-2006, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 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 <tls.h>
+#ifndef __ASSEMBLER__
+# include <pthreadP.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+/* The code to disable cancellation depends on the fact that the called
+ functions are special. They don't modify registers other than %rax
+ and %r11 if they return. Therefore we don't have to preserve other
+ registers around these calls. */
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .text; \
+ ENTRY (name) \
+ SINGLE_THREAD_P; \
+ jne L(pseudo_cancel); \
+ .type __##syscall_name##_nocancel,@function; \
+ .globl __##syscall_name##_nocancel; \
+ __##syscall_name##_nocancel: \
+ DO_CALL (syscall_name, args); \
+ cmpq $-4095, %rax; \
+ jae SYSCALL_ERROR_LABEL; \
+ ret; \
+ .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
+ L(pseudo_cancel): \
+ /* We always have to align the stack before calling a function. */ \
+ subq $8, %rsp; cfi_adjust_cfa_offset (8); \
+ CENABLE \
+ /* The return value from CENABLE is argument for CDISABLE. */ \
+ movq %rax, (%rsp); \
+ DO_CALL (syscall_name, args); \
+ movq (%rsp), %rdi; \
+ /* Save %rax since it's the error code from the syscall. */ \
+ movq %rax, %rdx; \
+ CDISABLE \
+ movq %rdx, %rax; \
+ addq $8,%rsp; cfi_adjust_cfa_offset (-8); \
+ cmpq $-4095, %rax; \
+ jae SYSCALL_ERROR_LABEL; \
+ L(pseudo_end):
+
+
+# ifdef IS_IN_libpthread
+# define CENABLE call __pthread_enable_asynccancel;
+# define CDISABLE call __pthread_disable_asynccancel;
+# define __local_multiple_threads __pthread_multiple_threads
+# elif !defined NOT_IN_libc
+# define CENABLE call __libc_enable_asynccancel;
+# define CDISABLE call __libc_disable_asynccancel;
+# define __local_multiple_threads __libc_multiple_threads
+# elif defined IS_IN_librt
+# define CENABLE call __librt_enable_asynccancel;
+# define CDISABLE call __librt_disable_asynccancel;
+# else
+# error Unsupported library
+# endif
+
+# if defined IS_IN_libpthread || !defined NOT_IN_libc
+# ifndef __ASSEMBLER__
+extern int __local_multiple_threads attribute_hidden;
+# define SINGLE_THREAD_P \
+ __builtin_expect (__local_multiple_threads == 0, 1)
+# else
+# define SINGLE_THREAD_P cmpl $0, __local_multiple_threads(%rip)
+# endif
+
+# else
+
+# ifndef __ASSEMBLER__
+# define SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+# else
+# define SINGLE_THREAD_P cmpl $0, %fs:MULTIPLE_THREADS_OFFSET
+# endif
+
+# endif
+
+#elif !defined __ASSEMBLER__
+
+# define SINGLE_THREAD_P (1)
+# define NO_CANCELLATION 1
+
+#endif
+
+#ifndef __ASSEMBLER__
+# define RTLD_SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/vfork.S
new file mode 100644
index 000000000..f3280b8cc
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/vfork.S
@@ -0,0 +1,42 @@
+/* Copyright (C) 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/>. */
+
+/* We want an #include_next, but we are the main source file.
+ So, #include ourselves and in that incarnation we can use #include_next. */
+#ifndef INCLUDED_SELF
+# define INCLUDED_SELF
+# include <vfork.S>
+#else
+
+# include <tcb-offsets.h>
+
+# define SAVE_PID \
+ movl %fs:PID, %esi; \
+ movl $0x80000000, %ecx; \
+ movl %esi, %edx; \
+ negl %edx; \
+ cmove %ecx, %edx; \
+ movl %edx, %fs:PID
+
+# define RESTORE_PID \
+ testq %rax, %rax; \
+ je 1f; \
+ movl %esi, %fs:PID; \
+1:
+
+# include_next <vfork.S>
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/Makefile.arch b/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/Makefile.arch
new file mode 100644
index 000000000..8ebe28773
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/Makefile.arch
@@ -0,0 +1,15 @@
+# uClibc-ng project
+# Licensed under the LGPL v2.1, see the file COPYING and LICENSE.
+
+libc_linux_arch_CSRC = fork.c
+libc_linux_arch_SSRC = clone.S vfork.S
+libpthread_linux_arch_CSRC = pthread_once.c
+libpthread_linux_arch_SSRC =
+
+CFLAGS-OMIT-fork.c = -DNOT_IN_libc -DIS_IN_libpthread
+ASFLAGS-pt-vfork.S = -DNOT_IN_libc -DIS_IN_libpthread -D_LIBC_REENTRANT
+
+ASFLAGS-clone.S = -D_LIBC_REENTRANT
+ASFLAGS-vfork.S = -D_LIBC_REENTRANT
+ASFLAGS-syscall.S = -D_LIBC_REENTRANT
+ASFLAGS-mmap.S = -D_LIBC_REENTRANT
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/bits/pthreadtypes.h b/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/bits/pthreadtypes.h
new file mode 100644
index 000000000..5e4402088
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/bits/pthreadtypes.h
@@ -0,0 +1,184 @@
+/* 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 _BITS_PTHREADTYPES_H
+#define _BITS_PTHREADTYPES_H 1
+
+#include <endian.h>
+
+#define __SIZEOF_PTHREAD_ATTR_T 36
+#define __SIZEOF_PTHREAD_MUTEX_T 24
+#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
+#define __SIZEOF_PTHREAD_COND_T 48
+#define __SIZEOF_PTHREAD_COND_COMPAT_T 12
+#define __SIZEOF_PTHREAD_CONDATTR_T 4
+#define __SIZEOF_PTHREAD_RWLOCK_T 32
+#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
+#define __SIZEOF_PTHREAD_BARRIER_T 20
+#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
+
+
+/* Thread identifiers. The structure of the attribute type is not
+ exposed on purpose. */
+typedef unsigned long int pthread_t;
+
+
+union pthread_attr_t
+{
+ char __size[__SIZEOF_PTHREAD_ATTR_T];
+ long int __align;
+};
+#ifndef __have_pthread_attr_t
+typedef union pthread_attr_t pthread_attr_t;
+# define __have_pthread_attr_t 1
+#endif
+
+
+typedef struct __pthread_internal_slist
+{
+ struct __pthread_internal_slist *__next;
+} __pthread_slist_t;
+
+
+/* Data structures for mutex handling. The structure of the attribute
+ type is not exposed on purpose. */
+typedef union
+{
+ struct __pthread_mutex_s
+ {
+ int __lock;
+ unsigned int __count;
+ int __owner;
+ /* KIND must stay at this position in the structure to maintain
+ binary compatibility. */
+ int __kind;
+ unsigned int __nusers;
+ __extension__ union
+ {
+ int __spins;
+ __pthread_slist_t __list;
+ };
+ } __data;
+ char __size[__SIZEOF_PTHREAD_MUTEX_T];
+ long int __align;
+} pthread_mutex_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
+ long int __align;
+} pthread_mutexattr_t;
+
+
+/* Data structure for conditional variable handling. The structure of
+ the attribute type is not exposed on purpose. */
+typedef union
+{
+ struct
+ {
+ int __lock;
+ unsigned int __futex;
+ __extension__ unsigned long long int __total_seq;
+ __extension__ unsigned long long int __wakeup_seq;
+ __extension__ unsigned long long int __woken_seq;
+ void *__mutex;
+ unsigned int __nwaiters;
+ unsigned int __broadcast_seq;
+ } __data;
+ char __size[__SIZEOF_PTHREAD_COND_T];
+ __extension__ long long int __align;
+} pthread_cond_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_CONDATTR_T];
+ long int __align;
+} pthread_condattr_t;
+
+
+/* Keys for thread-specific data */
+typedef unsigned int pthread_key_t;
+
+
+/* Once-only execution */
+typedef int pthread_once_t;
+
+
+#if defined __USE_UNIX98 || defined __USE_XOPEN2K
+/* Data structure for read-write lock variable handling. The
+ structure of the attribute type is not exposed on purpose. */
+typedef union
+{
+ struct
+ {
+ int __lock;
+ unsigned int __nr_readers;
+ unsigned int __readers_wakeup;
+ unsigned int __writer_wakeup;
+ unsigned int __nr_readers_queued;
+ unsigned int __nr_writers_queued;
+#if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned char __pad1;
+ unsigned char __pad2;
+ unsigned char __shared;
+ /* FLAGS must stay at this position in the structure to maintain
+ binary compatibility. */
+ unsigned char __flags;
+#else
+ /* FLAGS must stay at this position in the structure to maintain
+ binary compatibility. */
+ unsigned char __flags;
+ unsigned char __shared;
+ unsigned char __pad1;
+ unsigned char __pad2;
+#endif
+ int __writer;
+ } __data;
+ char __size[__SIZEOF_PTHREAD_RWLOCK_T];
+ long int __align;
+} pthread_rwlock_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
+ long int __align;
+} pthread_rwlockattr_t;
+#endif
+
+
+#ifdef __USE_XOPEN2K
+/* POSIX spinlock data type. */
+typedef volatile int pthread_spinlock_t;
+
+
+/* POSIX barriers data type. The structure of the type is
+ deliberately not exposed. */
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_BARRIER_T];
+ long int __align;
+} pthread_barrier_t;
+
+typedef union
+{
+ char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];
+ int __align;
+} pthread_barrierattr_t;
+#endif
+
+
+#endif /* bits/pthreadtypes.h */
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/bits/semaphore.h b/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/bits/semaphore.h
new file mode 100644
index 000000000..8845cf009
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/bits/semaphore.h
@@ -0,0 +1,35 @@
+/* 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SEMAPHORE_H
+# error "Never use <bits/semaphore.h> directly; include <semaphore.h> instead."
+#endif
+
+
+#define __SIZEOF_SEM_T 16
+
+
+/* Value returned if `sem_open' failed. */
+#define SEM_FAILED ((sem_t *) 0)
+
+
+typedef union
+{
+ char __size[__SIZEOF_SEM_T];
+ long int __align;
+} sem_t;
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/clone.S b/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/clone.S
new file mode 100644
index 000000000..539b9ef38
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/clone.S
@@ -0,0 +1,3 @@
+#define RESET_PID
+#include <tcb-offsets.h>
+#include <libc/sysdeps/linux/xtensa/clone.S>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/createthread.c b/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/createthread.c
new file mode 100644
index 000000000..2bb96e91a
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/createthread.c
@@ -0,0 +1,24 @@
+/* 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* Value passed to 'clone' for initialization of the thread register. */
+#define TLS_VALUE (pd + 1)
+
+
+/* Get the real implementation. */
+#include <sysdeps/pthread/createthread.c>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/fork.c b/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/fork.c
new file mode 100644
index 000000000..ba5c700da
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/fork.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 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/>. */
+
+#include <sched.h>
+#include <signal.h>
+#include <sysdep.h>
+#include <tls.h>
+
+
+#define ARCH_FORK() \
+ INLINE_SYSCALL (clone, 5, \
+ CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID | SIGCHLD, 0, \
+ NULL, NULL, &THREAD_SELF->tid)
+
+#include "../fork.c"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/lowlevellock.c b/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/lowlevellock.c
new file mode 100644
index 000000000..756f39fd4
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/lowlevellock.c
@@ -0,0 +1,132 @@
+/* low level locking for pthread library. Generic futex-using version.
+ Copyright (C) 2003-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/>. */
+
+#include <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <sys/time.h>
+
+void
+__lll_lock_wait_private (int *futex)
+{
+ do
+ {
+ int oldval = atomic_compare_and_exchange_val_acq (futex, 2, 1);
+ if (oldval != 0)
+ lll_futex_wait (futex, 2, LLL_PRIVATE);
+ }
+ while (atomic_compare_and_exchange_bool_acq (futex, 2, 0) != 0);
+}
+
+
+/* These functions don't get included in libc.so */
+#ifdef IS_IN_libpthread
+void
+__lll_lock_wait (int *futex, int private)
+{
+ do
+ {
+ int oldval = atomic_compare_and_exchange_val_acq (futex, 2, 1);
+ if (oldval != 0)
+ lll_futex_wait (futex, 2, private);
+ }
+ while (atomic_compare_and_exchange_bool_acq (futex, 2, 0) != 0);
+}
+
+
+int
+__lll_timedlock_wait (int *futex, const struct timespec *abstime, int private)
+{
+ struct timespec rt;
+
+ /* Reject invalid timeouts. */
+ if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
+ return EINVAL;
+
+ /* Upgrade the lock. */
+ if (atomic_exchange_acq (futex, 2) == 0)
+ return 0;
+
+ do
+ {
+ struct timeval tv;
+
+ /* Get the current time. */
+ (void) __gettimeofday (&tv, NULL);
+
+ /* Compute relative timeout. */
+ rt.tv_sec = abstime->tv_sec - tv.tv_sec;
+ rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+ if (rt.tv_nsec < 0)
+ {
+ rt.tv_nsec += 1000000000;
+ --rt.tv_sec;
+ }
+
+ /* Already timed out? */
+ if (rt.tv_sec < 0)
+ return ETIMEDOUT;
+
+ // XYZ: Lost the lock to check whether it was private.
+ lll_futex_timed_wait (futex, 2, &rt, private);
+ }
+ while (atomic_compare_and_exchange_bool_acq (futex, 2, 0) != 0);
+
+ return 0;
+}
+
+
+int
+__lll_timedwait_tid (int *tidp, const struct timespec *abstime)
+{
+ int tid;
+
+ if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
+ return EINVAL;
+
+ /* Repeat until thread terminated. */
+ while ((tid = *tidp) != 0)
+ {
+ struct timeval tv;
+ struct timespec rt;
+
+ /* Get the current time. */
+ (void) __gettimeofday (&tv, NULL);
+
+ /* Compute relative timeout. */
+ rt.tv_sec = abstime->tv_sec - tv.tv_sec;
+ rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+ if (rt.tv_nsec < 0)
+ {
+ rt.tv_nsec += 1000000000;
+ --rt.tv_sec;
+ }
+
+ /* Already timed out? */
+ if (rt.tv_sec < 0)
+ return ETIMEDOUT;
+
+ /* Wait until thread terminates. */
+ // XYZ: Lost the lock to check whether it was private.
+ if (lll_futex_timed_wait (tidp, tid, &rt, LLL_SHARED) == -ETIMEDOUT)
+ return ETIMEDOUT;
+ }
+
+ return 0;
+}
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/lowlevellock.h b/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/lowlevellock.h
new file mode 100644
index 000000000..abe6e9c37
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/lowlevellock.h
@@ -0,0 +1,293 @@
+/* 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
+ 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 _LOWLEVELLOCK_H
+#define _LOWLEVELLOCK_H 1
+
+#include <time.h>
+#include <sys/param.h>
+#include <bits/pthreadtypes.h>
+#include <atomic.h>
+#include <sysdep.h>
+#include <bits/kernel-features.h>
+
+#define FUTEX_WAIT 0
+#define FUTEX_WAKE 1
+#define FUTEX_REQUEUE 3
+#define FUTEX_CMP_REQUEUE 4
+#define FUTEX_WAKE_OP 5
+#define FUTEX_OP_CLEAR_WAKE_IF_GT_ONE ((4 << 24) | 1)
+#define FUTEX_LOCK_PI 6
+#define FUTEX_UNLOCK_PI 7
+#define FUTEX_TRYLOCK_PI 8
+#define FUTEX_WAIT_BITSET 9
+#define FUTEX_WAKE_BITSET 10
+#define FUTEX_PRIVATE_FLAG 128
+#define FUTEX_CLOCK_REALTIME 256
+
+#define FUTEX_BITSET_MATCH_ANY 0xffffffff
+
+/* Values for 'private' parameter of locking macros. Yes, the
+ definition seems to be backwards. But it is not. The bit will be
+ reversed before passing to the system call. */
+#define LLL_PRIVATE 0
+#define LLL_SHARED FUTEX_PRIVATE_FLAG
+
+
+#if !defined NOT_IN_libc || defined IS_IN_rtld
+/* In libc.so or ld.so all futexes are private. */
+# ifdef __ASSUME_PRIVATE_FUTEX
+# define __lll_private_flag(fl, private) \
+ ((fl) | FUTEX_PRIVATE_FLAG)
+# else
+# define __lll_private_flag(fl, private) \
+ ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex))
+# endif
+#else
+# ifdef __ASSUME_PRIVATE_FUTEX
+# define __lll_private_flag(fl, private) \
+ (((fl) | FUTEX_PRIVATE_FLAG) ^ (private))
+# else
+# define __lll_private_flag(fl, private) \
+ (__builtin_constant_p (private) \
+ ? ((private) == 0 \
+ ? ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex)) \
+ : (fl)) \
+ : ((fl) | (((private) ^ FUTEX_PRIVATE_FLAG) \
+ & THREAD_GETMEM (THREAD_SELF, header.private_futex))))
+# endif
+#endif
+
+
+#define lll_futex_wait(futexp, val, private) \
+ lll_futex_timed_wait(futexp, val, NULL, private)
+
+#define lll_futex_timed_wait(futexp, val, timespec, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 4, (futexp), \
+ __lll_private_flag (FUTEX_WAIT, private), \
+ (val), (timespec)); \
+ __ret; \
+ })
+
+#define lll_futex_timed_wait_bitset(futexp, val, timespec, clockbit, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ int __op = FUTEX_WAIT_BITSET | clockbit; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 6, (futexp), \
+ __lll_private_flag (__op, private), \
+ (val), (timespec), NULL /* Unused. */, \
+ FUTEX_BITSET_MATCH_ANY); \
+ __ret; \
+ })
+
+#define lll_futex_wake(futexp, nr, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 4, (futexp), \
+ __lll_private_flag (FUTEX_WAKE, private), \
+ (nr), 0); \
+ __ret; \
+ })
+
+#define lll_robust_dead(futexv, private) \
+ do \
+ { \
+ int *__futexp = &(futexv); \
+ atomic_or (__futexp, FUTEX_OWNER_DIED); \
+ lll_futex_wake (__futexp, 1, private); \
+ } \
+ while (0)
+
+/* Returns non-zero if error happened, zero if success. */
+#define lll_futex_requeue(futexp, nr_wake, nr_move, mutex, val, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 6, (futexp), \
+ __lll_private_flag (FUTEX_CMP_REQUEUE, private),\
+ (nr_wake), (nr_move), (mutex), (val)); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
+ })
+
+
+/* Returns non-zero if error happened, zero if success. */
+#define lll_futex_wake_unlock(futexp, nr_wake, nr_wake2, futexp2, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 6, (futexp), \
+ __lll_private_flag (FUTEX_WAKE_OP, private), \
+ (nr_wake), (nr_wake2), (futexp2), \
+ FUTEX_OP_CLEAR_WAKE_IF_GT_ONE); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
+ })
+
+
+#define lll_trylock(lock) \
+ atomic_compare_and_exchange_val_acq(&(lock), 1, 0)
+
+#define lll_cond_trylock(lock) \
+ atomic_compare_and_exchange_val_acq(&(lock), 2, 0)
+
+#define __lll_robust_trylock(futex, id) \
+ (atomic_compare_and_exchange_val_acq (futex, id, 0) != 0)
+#define lll_robust_trylock(lock, id) \
+ __lll_robust_trylock (&(lock), id)
+
+extern void __lll_lock_wait_private (int *futex) attribute_hidden;
+extern void __lll_lock_wait (int *futex, int private) attribute_hidden;
+extern int __lll_robust_lock_wait (int *futex, int private) attribute_hidden;
+
+#define __lll_lock(futex, private) \
+ ((void) ({ \
+ int *__futex = (futex); \
+ if (__builtin_expect (atomic_compare_and_exchange_val_acq (__futex, \
+ 1, 0), 0)) \
+ { \
+ if (__builtin_constant_p (private) && (private) == LLL_PRIVATE) \
+ __lll_lock_wait_private (__futex); \
+ else \
+ __lll_lock_wait (__futex, private); \
+ } \
+ }))
+#define lll_lock(futex, private) __lll_lock (&(futex), private)
+
+
+#define __lll_robust_lock(futex, id, private) \
+ ({ \
+ int *__futex = (futex); \
+ int __val = 0; \
+ \
+ if (__builtin_expect (atomic_compare_and_exchange_bool_acq (__futex, id, \
+ 0), 0)) \
+ __val = __lll_robust_lock_wait (__futex, private); \
+ __val; \
+ })
+#define lll_robust_lock(futex, id, private) \
+ __lll_robust_lock (&(futex), id, private)
+
+
+#define __lll_cond_lock(futex, private) \
+ ((void) ({ \
+ int *__futex = (futex); \
+ if (__builtin_expect (atomic_exchange_acq (__futex, 2), 0)) \
+ __lll_lock_wait (__futex, private); \
+ }))
+#define lll_cond_lock(futex, private) __lll_cond_lock (&(futex), private)
+
+
+#define lll_robust_cond_lock(futex, id, private) \
+ __lll_robust_lock (&(futex), (id) | FUTEX_WAITERS, private)
+
+
+extern int __lll_timedlock_wait (int *futex, const struct timespec *,
+ int private) attribute_hidden;
+extern int __lll_robust_timedlock_wait (int *futex, const struct timespec *,
+ int private) attribute_hidden;
+
+#define __lll_timedlock(futex, abstime, private) \
+ ({ \
+ int *__futex = (futex); \
+ int __val = 0; \
+ \
+ if (__builtin_expect (atomic_exchange_acq (__futex, 1), 0)) \
+ __val = __lll_timedlock_wait (__futex, abstime, private); \
+ __val; \
+ })
+#define lll_timedlock(futex, abstime, private) \
+ __lll_timedlock (&(futex), abstime, private)
+
+
+#define __lll_robust_timedlock(futex, abstime, id, private) \
+ ({ \
+ int *__futex = (futex); \
+ int __val = 0; \
+ \
+ if (__builtin_expect (atomic_compare_and_exchange_bool_acq (__futex, id, \
+ 0), 0)) \
+ __val = __lll_robust_timedlock_wait (__futex, abstime, private); \
+ __val; \
+ })
+#define lll_robust_timedlock(futex, abstime, id, private) \
+ __lll_robust_timedlock (&(futex), abstime, id, private)
+
+
+#define __lll_unlock(futex, private) \
+ (void) \
+ ({ int *__futex = (futex); \
+ int __oldval = atomic_exchange_rel (__futex, 0); \
+ if (__builtin_expect (__oldval > 1, 0)) \
+ lll_futex_wake (__futex, 1, private); \
+ })
+#define lll_unlock(futex, private) __lll_unlock(&(futex), private)
+
+
+#define __lll_robust_unlock(futex, private) \
+ (void) \
+ ({ int *__futex = (futex); \
+ int __oldval = atomic_exchange_rel (__futex, 0); \
+ if (__builtin_expect (__oldval & FUTEX_WAITERS, 0)) \
+ lll_futex_wake (__futex, 1, private); \
+ })
+#define lll_robust_unlock(futex, private) \
+ __lll_robust_unlock(&(futex), private)
+
+
+#define lll_islocked(futex) \
+ (futex != 0)
+
+
+/* Our internal lock implementation is identical to the binary-compatible
+ mutex implementation. */
+
+/* Initializers for lock. */
+#define LLL_LOCK_INITIALIZER (0)
+#define LLL_LOCK_INITIALIZER_LOCKED (1)
+
+/* The states of a lock are:
+ 0 - untaken
+ 1 - taken by one user
+ >1 - taken by more users */
+
+/* The kernel notifies a process which uses CLONE_CHILD_CLEARTID via futex
+ wakeup when the clone terminates. The memory location contains the
+ thread ID while the clone is running and is reset to zero
+ afterwards. */
+#define lll_wait_tid(tid) \
+ do { \
+ __typeof (tid) __tid; \
+ while ((__tid = (tid)) != 0) \
+ lll_futex_wait (&(tid), __tid, LLL_SHARED);\
+ } while (0)
+
+extern int __lll_timedwait_tid (int *, const struct timespec *)
+ attribute_hidden;
+
+#define lll_timedwait_tid(tid, abstime) \
+ ({ \
+ int __res = 0; \
+ if ((tid) != 0) \
+ __res = __lll_timedwait_tid (&(tid), (abstime)); \
+ __res; \
+ })
+
+#endif /* lowlevellock.h */
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/pt-initfini.c b/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/pt-initfini.c
new file mode 100644
index 000000000..4e6d26e81
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/pt-initfini.c
@@ -0,0 +1,134 @@
+/* Special .init and .fini section support. Linuxthread version.
+ Copyright (C) 1995,1996,1997,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 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 Library 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 Lesser General 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/>. */
+
+/* This file is compiled into assembly code which is then munged by a sed
+ script into two files: crti.s and crtn.s.
+
+ * crti.s puts a function prologue at the beginning of the
+ .init and .fini sections and defines global symbols for
+ those addresses, so they can be called as functions.
+
+ * crtn.s puts the corresponding function epilogues
+ in the .init and .fini sections. */
+
+#include <stdlib.h>
+
+/* We use embedded asm for .section unconditionally, as this makes it
+ easier to insert the necessary directives into crtn.S. */
+#define SECTION(x) __asm__ (".section " x )
+
+/* Embed an #include to pull in the alignment and .end directives. */
+__asm__ ("\n#include \"defs.h\"");
+__asm__ ("\n#if defined __i686 && defined __ASSEMBLER__");
+__asm__ ("\n#undef __i686");
+__asm__ ("\n#define __i686 __i686");
+__asm__ ("\n#endif");
+
+/* The initial common code ends here. */
+__asm__ ("\n/*@HEADER_ENDS*/");
+
+/* To determine whether we need .end and .align: */
+__asm__ ("\n/*@TESTS_BEGIN*/");
+extern void dummy (void (*foo) (void));
+void
+dummy (void (*foo) (void))
+{
+ if (foo)
+ (*foo) ();
+}
+__asm__ ("\n/*@TESTS_END*/");
+
+/* The beginning of _init: */
+__asm__ ("\n/*@_init_PROLOG_BEGINS*/");
+
+static void
+call_initialize_minimal (void)
+{
+ extern void __pthread_initialize_minimal_internal (void)
+ __attribute ((visibility ("hidden")));
+
+ __pthread_initialize_minimal_internal ();
+}
+
+SECTION (".init");
+extern void __attribute__ ((section (".init"))) _init (void);
+void
+_init (void)
+{
+ /* The very first thing we must do is to set up the registers. */
+ call_initialize_minimal ();
+
+ __asm__ ("ALIGN");
+ __asm__("END_INIT");
+ /* Now the epilog. */
+ __asm__ ("\n/*@_init_PROLOG_ENDS*/");
+ __asm__ ("\n/*@_init_EPILOG_BEGINS*/");
+ SECTION(".init");
+}
+__asm__ ("END_INIT");
+
+/* End of the _init epilog, beginning of the _fini prolog. */
+__asm__ ("\n/*@_init_EPILOG_ENDS*/");
+__asm__ ("\n/*@_fini_PROLOG_BEGINS*/");
+
+SECTION (".fini");
+extern void __attribute__ ((section (".fini"))) _fini (void);
+void
+_fini (void)
+{
+
+ /* End of the _fini prolog. */
+ __asm__ ("ALIGN");
+ __asm__ ("END_FINI");
+ __asm__ ("\n/*@_fini_PROLOG_ENDS*/");
+
+ /* Xtensa: It doesn't really matter whether GCC thinks this is a leaf
+ function or not, and the scripts that are supposed to remove the
+ call don't catch the literal, resulting in an undefined symbol
+ reference. */
+#if 0
+ {
+ /* Let GCC know that _fini is not a leaf function by having a dummy
+ function call here. We arrange for this call to be omitted from
+ either crt file. */
+ extern void i_am_not_a_leaf (void);
+ i_am_not_a_leaf ();
+ }
+#endif
+
+ /* Beginning of the _fini epilog. */
+ __asm__ ("\n/*@_fini_EPILOG_BEGINS*/");
+ SECTION (".fini");
+}
+__asm__ ("END_FINI");
+
+/* End of the _fini epilog. Any further generated assembly (e.g. .ident)
+ is shared between both crt files. */
+__asm__ ("\n/*@_fini_EPILOG_ENDS*/");
+__asm__ ("\n/*@TRAILER_BEGINS*/");
+
+/* End of file. */
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/pthread_once.c b/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/pthread_once.c
new file mode 100644
index 000000000..46085d3b5
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/pthread_once.c
@@ -0,0 +1,89 @@
+/* Copyright (C) 2004-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/>. */
+
+#include "pthreadP.h"
+#include <lowlevellock.h>
+
+unsigned long int __fork_generation attribute_hidden;
+
+static void
+clear_once_control (void *arg)
+{
+ pthread_once_t *once_control = (pthread_once_t *) arg;
+
+ *once_control = 0;
+ lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE);
+}
+
+int
+__pthread_once (pthread_once_t *once_control, void (*init_routine) (void))
+{
+ for (;;)
+ {
+ int oldval;
+ int newval;
+
+ /* Pseudo code:
+ newval = __fork_generation | 1;
+ oldval = *once_control;
+ if ((oldval & 2) == 0)
+ *once_control = newval;
+ Do this atomically.
+ */
+ do
+ {
+ newval = __fork_generation | 1;
+ oldval = *once_control;
+ if (oldval & 2)
+ break;
+ } while (atomic_compare_and_exchange_val_acq (once_control, newval, oldval) != oldval);
+
+ /* Check if the initializer has already been done. */
+ if ((oldval & 2) != 0)
+ return 0;
+
+ /* Check if another thread already runs the initializer. */
+ if ((oldval & 1) == 0)
+ break;
+
+ /* Check whether the initializer execution was interrupted by a fork. */
+ if (oldval != newval)
+ break;
+
+ /* Same generation, some other thread was faster. Wait. */
+ lll_futex_wait (once_control, oldval, LLL_PRIVATE);
+ }
+
+ /* This thread is the first here. Do the initialization.
+ Register a cleanup handler so that in case the thread gets
+ interrupted the initialization can be restarted. */
+ pthread_cleanup_push (clear_once_control, once_control);
+
+ init_routine ();
+
+ pthread_cleanup_pop (0);
+
+ /* Say that the initialisation is done. */
+ *once_control = __fork_generation | 2;
+
+ /* Wake up all other threads. */
+ lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE);
+
+ return 0;
+}
+weak_alias (__pthread_once, pthread_once)
+strong_alias (__pthread_once, __pthread_once_internal)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/sysdep-cancel.h
new file mode 100644
index 000000000..be1b5abf9
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/sysdep-cancel.h
@@ -0,0 +1,172 @@
+/* Copyright (C) 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. */
+
+#include <sysdep.h>
+#include <tls.h>
+/* #include <pt-machine.h> */
+#ifndef __ASSEMBLER__
+# include <pthreadP.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+
+#ifdef __ASSEMBLER__
+#if defined(__XTENSA_WINDOWED_ABI__)
+/* CENABLE/CDISABLE in PSEUDO below use call8, stack frame size must be
+ * at least 32.
+ */
+#if FRAMESIZE < 32
+#undef FRAMESIZE
+#define FRAMESIZE 32
+#endif
+
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .text; \
+ ENTRY (name) \
+ SINGLE_THREAD_P(a15); \
+ bnez a15, .Lpseudo_cancel; \
+ DO_CALL (syscall_name, args); \
+ bgez a2, .Lpseudo_done; \
+ movi a4, -4095; \
+ blt a2, a4, .Lpseudo_done; \
+ j SYSCALL_ERROR_LABEL; \
+ .Lpseudo_done: \
+ retw; \
+ .Lpseudo_cancel: \
+ /* The syscall args are in a2...a7; no need to save */ \
+ CENABLE; \
+ /* The return value is in a10 and preserved across the syscall */ \
+ DO_CALL (syscall_name, args); \
+ CDISABLE; \
+ bgez a2, .Lpseudo_end; \
+ movi a4, -4095; \
+ blt a2, a4, .Lpseudo_end; \
+ j SYSCALL_ERROR_LABEL; \
+ .Lpseudo_end:
+
+# define CENABLE movi a8, CENABLE_FUNC; \
+ callx8 a8
+# define CDISABLE movi a8, CDISABLE_FUNC; \
+ callx8 a8
+#elif defined(__XTENSA_CALL0_ABI__)
+
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .text; \
+ ENTRY (name) \
+ SINGLE_THREAD_P(a10); \
+ bnez a10, .Lpseudo_cancel; \
+ DO_CALL (syscall_name, args); \
+ bgez a2, .Lpseudo_done; \
+ movi a4, -4095; \
+ blt a2, a4, .Lpseudo_done; \
+ j SYSCALL_ERROR_LABEL; \
+ .Lpseudo_done: \
+ ret; \
+ .Lpseudo_cancel: \
+ addi a1, a1, -32; \
+ /* The syscall args are in a2...a7; save them */ \
+ s32i a0, a1, 0; \
+ s32i a2, a1, 4; \
+ s32i a3, a1, 8; \
+ s32i a4, a1, 12; \
+ s32i a5, a1, 16; \
+ s32i a6, a1, 20; \
+ s32i a7, a1, 24; \
+ CENABLE; \
+ /* Move return value to a10 preserved across the syscall */ \
+ mov a10, a2; \
+ l32i a2, a1, 4; \
+ l32i a3, a1, 8; \
+ l32i a4, a1, 12; \
+ l32i a5, a1, 16; \
+ l32i a6, a1, 20; \
+ l32i a7, a1, 24; \
+ DO_CALL (syscall_name, args); \
+ s32i a2, a1, 4; \
+ mov a2, a10; \
+ CDISABLE; \
+ l32i a2, a1, 4; \
+ l32i a0, a1, 0; \
+ addi a1, a1, 32; \
+ bgez a2, .Lpseudo_end; \
+ movi a4, -4095; \
+ blt a2, a4, .Lpseudo_end; \
+ j SYSCALL_ERROR_LABEL; \
+ .Lpseudo_end:
+
+# define CENABLE movi a0, CENABLE_FUNC; \
+ callx0 a0
+# define CDISABLE movi a0, CDISABLE_FUNC; \
+ callx0 a0
+#else
+#error Unsupported Xtensa ABI
+#endif
+#endif
+
+# ifdef IS_IN_libpthread
+# define CENABLE_FUNC __pthread_enable_asynccancel
+# define CDISABLE_FUNC __pthread_disable_asynccancel
+# define __local_multiple_threads __pthread_multiple_threads
+# elif !defined NOT_IN_libc
+# define CENABLE_FUNC __libc_enable_asynccancel
+# define CDISABLE_FUNC __libc_disable_asynccancel
+# define __local_multiple_threads __libc_multiple_threads
+# elif defined IS_IN_librt
+# define CENABLE_FUNC __librt_enable_asynccancel
+# define CDISABLE_FUNC __librt_disable_asynccancel
+# else
+# error Unsupported library
+# endif
+
+# if defined IS_IN_libpthread || !defined NOT_IN_libc
+# ifndef __ASSEMBLER__
+extern int __local_multiple_threads attribute_hidden;
+# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
+# else
+# define SINGLE_THREAD_P(reg) movi reg, __local_multiple_threads; \
+ l32i reg, reg, 0;
+# endif
+
+# else
+# ifndef __ASSEMBLER__
+# define SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+# else
+# define SINGLE_THREAD_P(reg) \
+ rur reg, threadptr; \
+ l32i reg, reg, MULTIPLE_THREADS_OFFSET;
+# endif
+# endif
+
+#else
+
+/* This code should never be used but we define it anyhow. */
+# define SINGLE_THREAD_P (1)
+# define NO_CANCELLATION 1
+
+#endif
+
+
+#ifndef __ASSEMBLER__
+# define RTLD_SINGLE_THREAD_P \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
+#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/vfork.S
new file mode 100644
index 000000000..46eb76dd6
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/vfork.S
@@ -0,0 +1,59 @@
+/* Copyright (C) 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/>. */
+
+#include <tls.h>
+
+/*
+ Save the PID value, save 0x80000000 if PID was 0.
+ Registers a2 and a3 are available; ar should return the PID and as threadptr
+ */
+
+#define SAVE_PID(pid,tp,ar,as) \
+ rur tp, threadptr; \
+ movi ar, TLS_PRE_TCB_SIZE; \
+ sub tp, tp, ar; \
+ l32i pid, tp, PID; \
+ neg ar, pid; \
+ movi as, 0x80000000; \
+ moveqz ar, as, ar; \
+ s32i ar, tp, PID; \
+
+/*
+ Restore the PID value, restore to 0 if saved value was 0x80000000
+ Return value from the syscall is in a2.
+ */
+#define RESTORE_PID(pid,tp,res) \
+ beqz res, 1f; \
+ s32i pid, tp, PID; \
+1:
+
+/*
+ Special version for call12, where we don't have enough registers
+ available to preserve the original PID.
+ */
+#define RESTORE_PID12(ar, as, at) \
+ rur as, threadptr; \
+ movi ar, TLS_PRE_TCB_SIZE; \
+ sub as, as, ar; \
+ l32i ar, as, PID; \
+ movi at, 0x80000000; \
+ sub at, at, ar; \
+ neg ar, ar; \
+ moveqz ar, at, at; \
+ s32i ar, as, PID;
+
+#include <libc/sysdeps/linux/xtensa/vfork.S>
diff --git a/libpthread/nptl/sysdeps/x86_64/Makefile.arch b/libpthread/nptl/sysdeps/x86_64/Makefile.arch
new file mode 100644
index 000000000..cf6f1c224
--- /dev/null
+++ b/libpthread/nptl/sysdeps/x86_64/Makefile.arch
@@ -0,0 +1,10 @@
+# Makefile for uClibc NPTL
+#
+# Copyright (C) 2005 Steven J. Hill <sjhill@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+CFLAGS-pthread_spin_lock.c += -D_GNU_SOURCE
+
+
diff --git a/libpthread/nptl/sysdeps/x86_64/dl-tls.h b/libpthread/nptl/sysdeps/x86_64/dl-tls.h
new file mode 100644
index 000000000..d6c338cda
--- /dev/null
+++ b/libpthread/nptl/sysdeps/x86_64/dl-tls.h
@@ -0,0 +1,28 @@
+/* Thread-local storage handling in the ELF dynamic linker. x86-64 version.
+ Copyright (C) 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/>. */
+
+
+/* Type used for the representation of TLS information in the GOT. */
+typedef struct
+{
+ unsigned long int ti_module;
+ unsigned long int ti_offset;
+} tls_index;
+
+
+extern void *__tls_get_addr (tls_index *ti);
diff --git a/libpthread/nptl/sysdeps/x86_64/jmpbuf-unwind.h b/libpthread/nptl/sysdeps/x86_64/jmpbuf-unwind.h
new file mode 100644
index 000000000..304bf85e5
--- /dev/null
+++ b/libpthread/nptl/sysdeps/x86_64/jmpbuf-unwind.h
@@ -0,0 +1,27 @@
+/* Copyright (C) 2003, 2004 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/>. */
+
+#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_RSP] - (_adj))
diff --git a/libpthread/nptl/sysdeps/x86_64/pthread_spin_init.c b/libpthread/nptl/sysdeps/x86_64/pthread_spin_init.c
new file mode 100644
index 000000000..55696204c
--- /dev/null
+++ b/libpthread/nptl/sysdeps/x86_64/pthread_spin_init.c
@@ -0,0 +1 @@
+#include "../i386/pthread_spin_init.c"
diff --git a/libpthread/nptl/sysdeps/x86_64/pthread_spin_lock.c b/libpthread/nptl/sysdeps/x86_64/pthread_spin_lock.c
new file mode 100644
index 000000000..7cf0e0ecc
--- /dev/null
+++ b/libpthread/nptl/sysdeps/x86_64/pthread_spin_lock.c
@@ -0,0 +1 @@
+#include "../i386/pthread_spin_lock.c"
diff --git a/libpthread/nptl/sysdeps/x86_64/pthread_spin_trylock.S b/libpthread/nptl/sysdeps/x86_64/pthread_spin_trylock.S
new file mode 100644
index 000000000..2bf8711b7
--- /dev/null
+++ b/libpthread/nptl/sysdeps/x86_64/pthread_spin_trylock.S
@@ -0,0 +1,39 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread-errnos.h>
+
+
+#ifdef UP
+# define LOCK
+#else
+# define LOCK lock
+#endif
+
+ .globl pthread_spin_trylock
+ .type pthread_spin_trylock,@function
+ .align 16
+pthread_spin_trylock:
+ movl $1, %eax
+ xorl %ecx, %ecx
+ LOCK
+ cmpxchgl %ecx, (%rdi)
+ movl $EBUSY, %eax
+ cmovel %ecx, %eax
+ retq
+ .size pthread_spin_trylock,.-pthread_spin_trylock
diff --git a/libpthread/nptl/sysdeps/x86_64/pthread_spin_unlock.S b/libpthread/nptl/sysdeps/x86_64/pthread_spin_unlock.S
new file mode 100644
index 000000000..89f8f0f33
--- /dev/null
+++ b/libpthread/nptl/sysdeps/x86_64/pthread_spin_unlock.S
@@ -0,0 +1,30 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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/>. */
+
+ .globl pthread_spin_unlock
+ .type pthread_spin_unlock,@function
+ .align 16
+pthread_spin_unlock:
+ movl $1, (%rdi)
+ xorl %eax, %eax
+ retq
+ .size pthread_spin_unlock,.-pthread_spin_unlock
+
+ /* The implementation of pthread_spin_init is identical. */
+ .globl pthread_spin_init
+pthread_spin_init = pthread_spin_unlock
diff --git a/libpthread/nptl/sysdeps/x86_64/pthreaddef.h b/libpthread/nptl/sysdeps/x86_64/pthreaddef.h
new file mode 100644
index 000000000..2b2285285
--- /dev/null
+++ b/libpthread/nptl/sysdeps/x86_64/pthreaddef.h
@@ -0,0 +1,42 @@
+/* Copyright (C) 2002, 2003, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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/>. */
+
+/* Default stack size. */
+#define ARCH_STACK_DEFAULT_SIZE (2 * 1024 * 1024)
+
+/* Required stack pointer alignment at beginning. SSE requires 16
+ bytes. */
+#define STACK_ALIGN 16
+
+/* Minimal stack size after allocating thread descriptor and guard size. */
+#define MINIMAL_REST_STACK 2048
+
+/* Alignment requirement for TCB. */
+#define TCB_ALIGNMENT 16
+
+
+/* Location of current stack frame. The frame pointer is not usable. */
+#define CURRENT_STACK_FRAME \
+ ({ char *frame; __asm__ ("movq %%rsp, %0" : "=r" (frame)); frame; })
+
+
+/* XXX Until we have a better place keep the definitions here. */
+
+/* While there is no such syscall. */
+#define __exit_thread_inline(val) \
+ __asm__ __volatile__ ("syscall" :: "a" (__NR_exit), "D" (val))
diff --git a/libpthread/nptl/sysdeps/x86_64/tcb-offsets.sym b/libpthread/nptl/sysdeps/x86_64/tcb-offsets.sym
new file mode 100644
index 000000000..cf863752e
--- /dev/null
+++ b/libpthread/nptl/sysdeps/x86_64/tcb-offsets.sym
@@ -0,0 +1,28 @@
+#include <sysdep.h>
+#include <tls.h>
+
+RESULT offsetof (struct pthread, result)
+TID offsetof (struct pthread, tid)
+PID offsetof (struct pthread, pid)
+CANCELHANDLING offsetof (struct pthread, cancelhandling)
+CLEANUP_JMP_BUF offsetof (struct pthread, cleanup_jmp_buf)
+CLEANUP offsetof (struct pthread, cleanup)
+CLEANUP_PREV offsetof (struct _pthread_cleanup_buffer, __prev)
+MUTEX_FUTEX offsetof (pthread_mutex_t, __data.__lock)
+MULTIPLE_THREADS_OFFSET offsetof (tcbhead_t, multiple_threads)
+POINTER_GUARD offsetof (tcbhead_t, pointer_guard)
+VGETCPU_CACHE_OFFSET offsetof (tcbhead_t, vgetcpu_cache)
+#ifndef __ASSUME_PRIVATE_FUTEX
+PRIVATE_FUTEX offsetof (tcbhead_t, private_futex)
+#endif
+RTLD_SAVESPACE_SSE offsetof (tcbhead_t, rtld_savespace_sse)
+
+-- Not strictly offsets, but these values are also used in the TCB.
+TCB_CANCELSTATE_BITMASK CANCELSTATE_BITMASK
+TCB_CANCELTYPE_BITMASK CANCELTYPE_BITMASK
+TCB_CANCELING_BITMASK CANCELING_BITMASK
+TCB_CANCELED_BITMASK CANCELED_BITMASK
+TCB_EXITING_BITMASK EXITING_BITMASK
+TCB_CANCEL_RESTMASK CANCEL_RESTMASK
+TCB_TERMINATED_BITMASK TERMINATED_BITMASK
+TCB_PTHREAD_CANCELED PTHREAD_CANCELED
diff --git a/libpthread/nptl/sysdeps/x86_64/tls.h b/libpthread/nptl/sysdeps/x86_64/tls.h
new file mode 100644
index 000000000..b450c1745
--- /dev/null
+++ b/libpthread/nptl/sysdeps/x86_64/tls.h
@@ -0,0 +1,437 @@
+/* Definition for thread-local data handling. nptl/x86_64 version.
+ Copyright (C) 2002-2007, 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
+ 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 _TLS_H
+#define _TLS_H 1
+
+#ifndef __ASSEMBLER__
+# include <asm/prctl.h> /* For ARCH_SET_FS. */
+# include <stdbool.h>
+# include <stddef.h>
+# include <stdint.h>
+# include <stdlib.h>
+# include <sysdep.h>
+# include <bits/kernel-features.h>
+# include <bits/wordsize.h>
+# include <xmmintrin.h>
+
+
+/* Type for the dtv. */
+typedef union dtv
+{
+ size_t counter;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
+} dtv_t;
+
+
+typedef struct
+{
+ void *tcb; /* Pointer to the TCB. Not necessarily the
+ thread descriptor used by libpthread. */
+ dtv_t *dtv;
+ void *self; /* Pointer to the thread descriptor. */
+ int multiple_threads;
+ int gscope_flag;
+ uintptr_t sysinfo;
+ uintptr_t stack_guard;
+ uintptr_t pointer_guard;
+ unsigned long int vgetcpu_cache[2];
+# ifndef __ASSUME_PRIVATE_FUTEX
+ int private_futex;
+# else
+ int __unused1;
+# endif
+# if __WORDSIZE == 64
+ int rtld_must_xmm_save;
+# endif
+ /* Reservation of some values for the TM ABI. */
+ void *__private_tm[5];
+# if __WORDSIZE == 64
+ long int __unused2;
+ /* Have space for the post-AVX register size. */
+ __m128 rtld_savespace_sse[8][4];
+
+ void *__padding[8];
+# endif
+} tcbhead_t;
+
+#else /* __ASSEMBLER__ */
+# include <tcb-offsets.h>
+#endif
+
+
+/* We require TLS support in the tools. */
+#define HAVE_TLS_SUPPORT 1
+#define HAVE___THREAD 1
+#define HAVE_TLS_MODEL_ATTRIBUTE 1
+
+/* Signal that TLS support is available. */
+#define USE_TLS 1
+
+/* Alignment requirement for the stack. */
+#define STACK_ALIGN 16
+
+
+#ifndef __ASSEMBLER__
+/* Get system call information. */
+# include <sysdep.h>
+
+
+/* Get the thread descriptor definition. */
+# include <descr.h>
+
+#ifndef LOCK_PREFIX
+# ifdef UP
+# define LOCK_PREFIX /* nothing */
+# else
+# define LOCK_PREFIX "lock;"
+# endif
+#endif
+
+/* This is the size of the initial TCB. Can't be just sizeof (tcbhead_t),
+ because NPTL getpid, __libc_alloca_cutoff etc. need (almost) the whole
+ struct pthread even when not linked with -lpthread. */
+# define TLS_INIT_TCB_SIZE sizeof (struct pthread)
+
+/* Alignment requirements for the initial TCB. */
+# define TLS_INIT_TCB_ALIGN __alignof__ (struct pthread)
+
+/* This is the size of the TCB. */
+# define TLS_TCB_SIZE sizeof (struct pthread)
+
+/* Alignment requirements for the TCB. */
+//# define TLS_TCB_ALIGN __alignof__ (struct pthread)
+// Normally the above would be correct But we have to store post-AVX
+// vector registers in the TCB and we want the storage to be aligned.
+// unfortunately there isn't yet a type for these values and hence no
+// 32-byte alignment requirement. Make this explicit, for now.
+# define TLS_TCB_ALIGN 32
+
+/* The TCB can have any size and the memory following the address the
+ thread pointer points to is unspecified. Allocate the TCB there. */
+# define TLS_TCB_AT_TP 1
+
+
+/* Install the dtv pointer. The pointer passed is to the element with
+ index -1 which contain the length. */
+# define INSTALL_DTV(descr, dtvp) \
+ ((tcbhead_t *) (descr))->dtv = (dtvp) + 1
+
+/* Install new dtv for current thread. */
+# define INSTALL_NEW_DTV(dtvp) \
+ ({ struct pthread *__pd; \
+ THREAD_SETMEM (__pd, header.dtv, (dtvp)); })
+
+/* Return dtv of given thread descriptor. */
+# define GET_DTV(descr) \
+ (((tcbhead_t *) (descr))->dtv)
+
+
+/* Macros to load from and store into segment registers. */
+# define TLS_GET_FS() \
+ ({ int __seg; __asm__ ("movl %%fs, %0" : "=q" (__seg)); __seg; })
+# define TLS_SET_FS(val) \
+ __asm__ ("movl %0, %%fs" :: "q" (val))
+
+
+/* Code to initially initialize the thread pointer. This might need
+ special attention since 'errno' is not yet available and if the
+ operation can cause a failure 'errno' must not be touched.
+
+ We have to make the syscall for both uses of the macro since the
+ address might be (and probably is) different. */
+# define TLS_INIT_TP(thrdescr, secondcall) \
+ ({ void *_thrdescr = (thrdescr); \
+ tcbhead_t *_head = _thrdescr; \
+ int _result; \
+ \
+ _head->tcb = _thrdescr; \
+ /* For now the thread descriptor is at the same address. */ \
+ _head->self = _thrdescr; \
+ \
+ /* It is a simple syscall to set the %fs value for the thread. */ \
+ __asm__ __volatile__ ("syscall" \
+ : "=a" (_result) \
+ : "0" ((unsigned long int) __NR_arch_prctl), \
+ "D" ((unsigned long int) ARCH_SET_FS), \
+ "S" (_thrdescr) \
+ : "memory", "cc", "r11", "cx"); \
+ \
+ _result ? "cannot set %fs base address for thread-local storage" : 0; \
+ })
+
+
+/* Return the address of the dtv for the current thread. */
+# define THREAD_DTV() \
+ ({ struct pthread *__pd; \
+ THREAD_GETMEM (__pd, header.dtv); })
+
+
+/* Return the thread descriptor for the current thread.
+
+ The contained asm must *not* be marked __volatile__ since otherwise
+ assignments like
+ pthread_descr self = thread_self();
+ do not get optimized away. */
+# define THREAD_SELF \
+ ({ struct pthread *__self; \
+ __asm__ ("movq %%fs:%c1,%q0" : "=r" (__self) \
+ : "i" (offsetof (struct pthread, header.self))); \
+ __self;})
+
+/* Magic for libthread_db to know how to do THREAD_SELF. */
+# define DB_THREAD_SELF_INCLUDE <sys/reg.h> /* For the FS constant. */
+# define DB_THREAD_SELF CONST_THREAD_AREA (64, FS)
+
+/* Read member of the thread descriptor directly. */
+# define THREAD_GETMEM(descr, member) \
+ ({ __typeof (descr->member) __value; \
+ if (sizeof (__value) == 1) \
+ __asm__ __volatile__ ("movb %%fs:%P2,%b0" \
+ : "=q" (__value) \
+ : "0" (0), "i" (offsetof (struct pthread, member))); \
+ else if (sizeof (__value) == 4) \
+ __asm__ __volatile__ ("movl %%fs:%P1,%0" \
+ : "=r" (__value) \
+ : "i" (offsetof (struct pthread, member))); \
+ else \
+ { \
+ if (sizeof (__value) != 8) \
+ /* There should not be any value with a size other than 1, \
+ 4 or 8. */ \
+ abort (); \
+ \
+ __asm__ __volatile__ ("movq %%fs:%P1,%q0" \
+ : "=r" (__value) \
+ : "i" (offsetof (struct pthread, member))); \
+ } \
+ __value; })
+
+
+/* Same as THREAD_GETMEM, but the member offset can be non-constant. */
+# define THREAD_GETMEM_NC(descr, member, idx) \
+ ({ __typeof (descr->member[0]) __value; \
+ if (sizeof (__value) == 1) \
+ __asm__ __volatile__ ("movb %%fs:%P2(%q3),%b0" \
+ : "=q" (__value) \
+ : "0" (0), "i" (offsetof (struct pthread, member[0])), \
+ "r" (idx)); \
+ else if (sizeof (__value) == 4) \
+ __asm__ __volatile__ ("movl %%fs:%P1(,%q2,4),%0" \
+ : "=r" (__value) \
+ : "i" (offsetof (struct pthread, member[0])), "r" (idx));\
+ else \
+ { \
+ if (sizeof (__value) != 8) \
+ /* There should not be any value with a size other than 1, \
+ 4 or 8. */ \
+ abort (); \
+ \
+ __asm__ __volatile__ ("movq %%fs:%P1(,%q2,8),%q0" \
+ : "=r" (__value) \
+ : "i" (offsetof (struct pthread, member[0])), \
+ "r" (idx)); \
+ } \
+ __value; })
+
+
+/* Loading addresses of objects on x86-64 needs to be treated special
+ when generating PIC code. */
+#ifdef __pic__
+# define IMM_MODE "nr"
+#else
+# define IMM_MODE "ir"
+#endif
+
+
+/* Same as THREAD_SETMEM, but the member offset can be non-constant. */
+# define THREAD_SETMEM(descr, member, value) \
+ ({ if (sizeof (descr->member) == 1) \
+ __asm__ __volatile__ ("movb %b0,%%fs:%P1" : \
+ : "iq" (value), \
+ "i" (offsetof (struct pthread, member))); \
+ else if (sizeof (descr->member) == 4) \
+ __asm__ __volatile__ ("movl %0,%%fs:%P1" : \
+ : IMM_MODE (value), \
+ "i" (offsetof (struct pthread, member))); \
+ else \
+ { \
+ if (sizeof (descr->member) != 8) \
+ /* There should not be any value with a size other than 1, \
+ 4 or 8. */ \
+ abort (); \
+ \
+ __asm__ __volatile__ ("movq %q0,%%fs:%P1" : \
+ : IMM_MODE ((unsigned long int) value), \
+ "i" (offsetof (struct pthread, member))); \
+ }})
+
+
+/* Set member of the thread descriptor directly. */
+# define THREAD_SETMEM_NC(descr, member, idx, value) \
+ ({ if (sizeof (descr->member[0]) == 1) \
+ __asm__ __volatile__ ("movb %b0,%%fs:%P1(%q2)" : \
+ : "iq" (value), \
+ "i" (offsetof (struct pthread, member[0])), \
+ "r" (idx)); \
+ else if (sizeof (descr->member[0]) == 4) \
+ __asm__ __volatile__ ("movl %0,%%fs:%P1(,%q2,4)" : \
+ : IMM_MODE (value), \
+ "i" (offsetof (struct pthread, member[0])), \
+ "r" (idx)); \
+ else \
+ { \
+ if (sizeof (descr->member[0]) != 8) \
+ /* There should not be any value with a size other than 1, \
+ 4 or 8. */ \
+ abort (); \
+ \
+ __asm__ __volatile__ ("movq %q0,%%fs:%P1(,%q2,8)" : \
+ : IMM_MODE ((unsigned long int) value), \
+ "i" (offsetof (struct pthread, member[0])), \
+ "r" (idx)); \
+ }})
+
+
+/* Atomic compare and exchange on TLS, returning old value. */
+# define THREAD_ATOMIC_CMPXCHG_VAL(descr, member, newval, oldval) \
+ ({ __typeof (descr->member) __ret; \
+ __typeof (oldval) __old = (oldval); \
+ if (sizeof (descr->member) == 4) \
+ __asm__ __volatile__ (LOCK_PREFIX "cmpxchgl %2, %%fs:%P3" \
+ : "=a" (__ret) \
+ : "0" (__old), "r" (newval), \
+ "i" (offsetof (struct pthread, member))); \
+ else \
+ /* Not necessary for other sizes in the moment. */ \
+ abort (); \
+ __ret; })
+
+
+/* Atomic logical and. */
+# define THREAD_ATOMIC_AND(descr, member, val) \
+ (void) ({ if (sizeof ((descr)->member) == 4) \
+ __asm__ __volatile__ (LOCK_PREFIX "andl %1, %%fs:%P0" \
+ :: "i" (offsetof (struct pthread, member)), \
+ "ir" (val)); \
+ else \
+ /* Not necessary for other sizes in the moment. */ \
+ abort (); })
+
+
+/* Atomic set bit. */
+# define THREAD_ATOMIC_BIT_SET(descr, member, bit) \
+ (void) ({ if (sizeof ((descr)->member) == 4) \
+ __asm__ __volatile__ (LOCK_PREFIX "orl %1, %%fs:%P0" \
+ :: "i" (offsetof (struct pthread, member)), \
+ "ir" (1 << (bit))); \
+ else \
+ /* Not necessary for other sizes in the moment. */ \
+ abort (); })
+
+
+# define CALL_THREAD_FCT(descr) \
+ ({ void *__res; \
+ __asm__ __volatile__ ("movq %%fs:%P2, %%rdi\n\t" \
+ "callq *%%fs:%P1" \
+ : "=a" (__res) \
+ : "i" (offsetof (struct pthread, start_routine)), \
+ "i" (offsetof (struct pthread, arg)) \
+ : "di", "si", "cx", "dx", "r8", "r9", "r10", "r11", \
+ "memory", "cc"); \
+ __res; })
+
+
+/* Set the stack guard field in TCB head. */
+# define THREAD_SET_STACK_GUARD(value) \
+ THREAD_SETMEM (THREAD_SELF, header.stack_guard, value)
+# define THREAD_COPY_STACK_GUARD(descr) \
+ ((descr)->header.stack_guard \
+ = THREAD_GETMEM (THREAD_SELF, header.stack_guard))
+
+
+/* Set the pointer guard field in the TCB head. */
+# define THREAD_SET_POINTER_GUARD(value) \
+ THREAD_SETMEM (THREAD_SELF, header.pointer_guard, value)
+# define THREAD_COPY_POINTER_GUARD(descr) \
+ ((descr)->header.pointer_guard \
+ = THREAD_GETMEM (THREAD_SELF, header.pointer_guard))
+
+
+/* Get and set the global scope generation counter in the TCB head. */
+# define THREAD_GSCOPE_FLAG_UNUSED 0
+# define THREAD_GSCOPE_FLAG_USED 1
+# define THREAD_GSCOPE_FLAG_WAIT 2
+# define THREAD_GSCOPE_RESET_FLAG() \
+ do \
+ { int __res; \
+ __asm__ __volatile__ ("xchgl %0, %%fs:%P1" \
+ : "=r" (__res) \
+ : "i" (offsetof (struct pthread, header.gscope_flag)), \
+ "0" (THREAD_GSCOPE_FLAG_UNUSED)); \
+ if (__res == THREAD_GSCOPE_FLAG_WAIT) \
+ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \
+ } \
+ while (0)
+# define THREAD_GSCOPE_SET_FLAG() \
+ THREAD_SETMEM (THREAD_SELF, header.gscope_flag, THREAD_GSCOPE_FLAG_USED)
+# define THREAD_GSCOPE_WAIT() \
+ GL(dl_wait_lookup_done) ()
+
+
+# ifdef SHARED
+/* Defined in dl-trampoline.S. */
+extern void _dl_x86_64_save_sse (void);
+extern void _dl_x86_64_restore_sse (void);
+
+# define RTLD_CHECK_FOREIGN_CALL \
+ (THREAD_GETMEM (THREAD_SELF, header.rtld_must_xmm_save) != 0)
+
+/* NB: Don't use the xchg operation because that would imply a lock
+ prefix which is expensive and unnecessary. The cache line is also
+ not contested at all. */
+# define RTLD_ENABLE_FOREIGN_CALL \
+ int old_rtld_must_xmm_save = THREAD_GETMEM (THREAD_SELF, \
+ header.rtld_must_xmm_save); \
+ THREAD_SETMEM (THREAD_SELF, header.rtld_must_xmm_save, 1)
+
+# define RTLD_PREPARE_FOREIGN_CALL \
+ do if (THREAD_GETMEM (THREAD_SELF, header.rtld_must_xmm_save)) \
+ { \
+ _dl_x86_64_save_sse (); \
+ THREAD_SETMEM (THREAD_SELF, header.rtld_must_xmm_save, 0); \
+ } \
+ while (0)
+
+# define RTLD_FINALIZE_FOREIGN_CALL \
+ do { \
+ if (THREAD_GETMEM (THREAD_SELF, header.rtld_must_xmm_save) == 0) \
+ _dl_x86_64_restore_sse (); \
+ THREAD_SETMEM (THREAD_SELF, header.rtld_must_xmm_save, \
+ old_rtld_must_xmm_save); \
+ } while (0)
+# endif
+
+
+#endif /* __ASSEMBLER__ */
+
+#endif /* tls.h */
diff --git a/libpthread/nptl/sysdeps/xtensa/Makefile.arch b/libpthread/nptl/sysdeps/xtensa/Makefile.arch
new file mode 100644
index 000000000..5bbd409c6
--- /dev/null
+++ b/libpthread/nptl/sysdeps/xtensa/Makefile.arch
@@ -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, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+CFLAGS-pt-raise.c = -DNOT_IN_libc -DIS_IN_libpthread
+
+ASFLAGS-dl-tlsdesc.S = -DNOT_IN_libc=1
+ASFLAGS-pthread_spin_lock.S = -DNOT_IN_libc -DIS_IN_libpthread
+ASFLAGS-pthread_spin_trylock.S = -DNOT_IN_libc -DIS_IN_libpthread
+ASFLAGS-nptl-sysdep.S = -DNOT_IN_libc -DIS_IN_libpthread \
+ -D_LIBC_REENTRANT \
+ -I$(top_srcdir)libc/sysdeps/linux/xtensa
+
+libc_arch_a_CSRC = libc-tls.c
+librt_arch_a_SSRC = dl-tlsdesc.S
+
+CFLAGS-gen_tlsdesc.c = -S
+$(libpthread_arch_OUT)/gen_tlsdesc.c: $(libpthread_arch_DIR)/tlsdesc.sym | $(libpthread_arch_OUT)
+ $(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
+$(libpthread_arch_OUT)/gen_tlsdesc.s: $(libpthread_arch_OUT)/gen_tlsdesc.c | headers
+ $(compile.c)
+libpthread-generated-y += $(libpthread_arch_OUT)/gen_tlsdesc.s
+$(libpthread_arch_OUT)/tlsdesc.h: $(libpthread_arch_OUT)/gen_tlsdesc.s
+ $(do_sed) $(PTHREAD_GENERATE_MANGLE) $< > $@
+ @if test ! -s $@ ; then rm -f $@ ; false ; fi
+pregen-headers-$(UCLIBC_HAS_THREADS_NATIVE) += $(libpthread_arch_OUT)/tlsdesc.h
diff --git a/libpthread/nptl/sysdeps/xtensa/dl-tls.h b/libpthread/nptl/sysdeps/xtensa/dl-tls.h
new file mode 100644
index 000000000..29008dbb9
--- /dev/null
+++ b/libpthread/nptl/sysdeps/xtensa/dl-tls.h
@@ -0,0 +1,58 @@
+/* Thread-local storage handling in the ELF dynamic linker. Xtensa version.
+ Copyright (C) 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _XTENSA_DL_TLS_H
+#define _XTENSA_DL_TLS_H 1
+
+/* Type used for the representation of TLS information in the GOT. */
+typedef struct
+{
+ unsigned long int ti_module;
+ unsigned long int ti_offset;
+} tls_index;
+
+extern void *__tls_get_addr (tls_index *ti);
+
+/* Type used to represent a TLS descriptor. */
+struct tlsdesc
+{
+ union
+ {
+ void *pointer;
+ long value;
+ } argument;
+ ptrdiff_t (*entry)(struct tlsdesc *);
+};
+
+/* Type used as the argument in a TLS descriptor for a symbol that
+ needs dynamic TLS offsets. */
+struct tlsdesc_dynamic_arg
+{
+ tls_index tlsinfo;
+ size_t gen_count;
+};
+
+extern ptrdiff_t attribute_hidden
+ _dl_tlsdesc_return(struct tlsdesc_dynamic_arg *);
+
+extern void *_dl_make_tlsdesc_dynamic (struct link_map *map, size_t ti_offset);
+extern ptrdiff_t attribute_hidden
+ _dl_tlsdesc_dynamic(struct tlsdesc_dynamic_arg *);
+
+#endif
diff --git a/libpthread/nptl/sysdeps/xtensa/jmpbuf-unwind.h b/libpthread/nptl/sysdeps/xtensa/jmpbuf-unwind.h
new file mode 100644
index 000000000..bda498b8a
--- /dev/null
+++ b/libpthread/nptl/sysdeps/xtensa/jmpbuf-unwind.h
@@ -0,0 +1,32 @@
+/* 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 <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[JB_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)[JB_SP] - (_adj))
diff --git a/libpthread/nptl/sysdeps/xtensa/libc-tls.c b/libpthread/nptl/sysdeps/xtensa/libc-tls.c
new file mode 100644
index 000000000..80494c56f
--- /dev/null
+++ b/libpthread/nptl/sysdeps/xtensa/libc-tls.c
@@ -0,0 +1,36 @@
+/* Thread-local storage handling in the ELF dynamic linker. Xtensa version.
+ 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/>. */
+
+#include <sysdeps/generic/libc-tls.c>
+#include <dl-tls.h>
+
+#if defined(USE_TLS) && USE_TLS
+
+/* On Xtensa, linker optimizations are not required, so __tls_get_addr
+ can be called even in statically linked binaries. In this case module
+ must be always 1 and PT_TLS segment exist in the binary, otherwise it
+ would not link. */
+
+void *
+__tls_get_addr (tls_index *ti)
+{
+ dtv_t *dtv = THREAD_DTV ();
+ return (char *) dtv[1].pointer.val + ti->ti_offset;
+}
+
+#endif
diff --git a/libpthread/nptl/sysdeps/xtensa/pthread_spin_lock.S b/libpthread/nptl/sysdeps/xtensa/pthread_spin_lock.S
new file mode 100644
index 000000000..10b1c00f5
--- /dev/null
+++ b/libpthread/nptl/sysdeps/xtensa/pthread_spin_lock.S
@@ -0,0 +1,33 @@
+/* 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+ .text
+ENTRY (pthread_spin_lock)
+
+ movi a3, 0
+ wsr a3, scompare1
+ movi a3, 1
+1: s32c1i a3, a2, 0
+ bnez a3, 1b
+ movi a2, 0
+
+ abi_ret
+
+END (pthread_spin_lock)
diff --git a/libpthread/nptl/sysdeps/xtensa/pthread_spin_trylock.S b/libpthread/nptl/sysdeps/xtensa/pthread_spin_trylock.S
new file mode 100644
index 000000000..4742bdb1c
--- /dev/null
+++ b/libpthread/nptl/sysdeps/xtensa/pthread_spin_trylock.S
@@ -0,0 +1,35 @@
+/* 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define _ERRNO_H 1
+#include <bits/errno.h>
+#include <sysdep.h>
+
+ .text
+ENTRY (pthread_spin_trylock)
+
+ movi a3, 0
+ wsr a3, scompare1
+ movi a3, 1
+ s32c1i a3, a2, 0
+ movi a2, EBUSY
+ moveqz a2, a3, a3
+
+ abi_ret
+
+END (pthread_spin_trylock)
diff --git a/libc/sysdeps/linux/mips/readahead.c b/libpthread/nptl/sysdeps/xtensa/pthreaddef.h
index 9157c2762..e72b4bc58 100644
--- a/libc/sysdeps/linux/mips/readahead.c
+++ b/libpthread/nptl/sysdeps/xtensa/pthreaddef.h
@@ -1,5 +1,4 @@
-/* Provide kernel hint to read ahead.
- Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 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
@@ -17,25 +16,24 @@
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
+/* Default stack size. */
+#define ARCH_STACK_DEFAULT_SIZE (2 * 1024 * 1024)
+
+/* Required stack pointer alignment at beginning. */
+#define STACK_ALIGN 16
+
+/* Minimal stack size after allocating thread descriptor and guard size. */
+#define MINIMAL_REST_STACK 2048
+
+/* Alignment requirement for TCB. */
+#define TCB_ALIGNMENT 16
+
+
+/* Location of current stack frame. */
+#define CURRENT_STACK_FRAME __builtin_frame_address (0)
+
+
+/* XXX Until we have a better place keep the definitions here. */
+
+#define __exit_thread_inline(val) \
+ INLINE_SYSCALL (exit, 1, (val))
diff --git a/libpthread/nptl/sysdeps/xtensa/tcb-offsets.sym b/libpthread/nptl/sysdeps/xtensa/tcb-offsets.sym
new file mode 100644
index 000000000..4c8687647
--- /dev/null
+++ b/libpthread/nptl/sysdeps/xtensa/tcb-offsets.sym
@@ -0,0 +1,7 @@
+#include <sysdep.h>
+#include <tls.h>
+
+TLS_PRE_TCB_SIZE sizeof (struct pthread)
+MULTIPLE_THREADS_OFFSET offsetof (struct pthread, header.multiple_threads)
+PID offsetof (struct pthread, pid)
+TID offsetof (struct pthread, tid)
diff --git a/libpthread/nptl/sysdeps/xtensa/tls.h b/libpthread/nptl/sysdeps/xtensa/tls.h
new file mode 100644
index 000000000..f0cb27c01
--- /dev/null
+++ b/libpthread/nptl/sysdeps/xtensa/tls.h
@@ -0,0 +1,159 @@
+/* Definition for thread-local data handling. NPTL/Xtensa version.
+ 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _TLS_H
+#define _TLS_H
+
+#ifndef __ASSEMBLER__
+
+# include <stdbool.h>
+# include <stddef.h>
+# include <stdint.h>
+
+/* Type for the dtv. */
+typedef union dtv
+{
+ size_t counter;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
+} dtv_t;
+
+
+#else /* __ASSEMBLER__ */
+# include <tcb-offsets.h>
+#endif /* __ASSEMBLER__ */
+
+/* We require TLS support in the tools. */
+#define HAVE_TLS_SUPPORT 1
+#define HAVE_TLS_MODEL_ATTRIBUTE 1
+#define HAVE___THREAD 1
+
+/* Signal that TLS support is available. */
+#define USE_TLS 1
+
+#ifndef __ASSEMBLER__
+
+/* Get system call information. */
+# include <sysdep.h>
+
+/* The TLS blocks start right after the TCB. */
+# define TLS_DTV_AT_TP 1
+
+/* Get the thread descriptor definition. */
+# include <../../descr.h>
+
+typedef struct
+{
+ dtv_t *dtv;
+ void *private;
+} tcbhead_t;
+
+/* This is the size of the initial TCB. */
+# define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
+
+/* Alignment requirements for the initial TCB. */
+# define TLS_INIT_TCB_ALIGN 16
+
+/* This is the size of the TCB. */
+# define TLS_TCB_SIZE sizeof (tcbhead_t)
+
+/* This is the size we need before TCB. */
+# define TLS_PRE_TCB_SIZE sizeof (struct pthread)
+
+/* Alignment requirements for the TCB. */
+# define TLS_TCB_ALIGN 16
+
+
+/* Install the dtv pointer. The pointer passed is to the element with
+ index -1 which contain the length. */
+# define INSTALL_DTV(tcbp, dtvp) \
+ (((tcbhead_t *) (tcbp))->dtv = (dtvp) + 1)
+
+/* Install new dtv for current thread. */
+# define INSTALL_NEW_DTV(dtv) \
+ ({ tcbhead_t *__tcbp; \
+ __asm__ __volatile__ ("rur %0, threadptr" : "=r" (__tcbp)); \
+ __tcbp->dtv = (dtv); }) \
+
+/* Return dtv of given thread descriptor. */
+# define GET_DTV(tcbp) \
+ (((tcbhead_t *) (tcbp))->dtv)
+
+/* Code to initially initialize the thread pointer. This might need
+ special attention since 'errno' is not yet available and if the
+ operation can cause a failure 'errno' must not be touched. */
+# define TLS_INIT_TP(tcbp, secondcall) \
+ ({ __asm__ __volatile__ ("wur %0, threadptr" : : "r" (tcbp)); 0; })
+
+/* Return the address of the dtv for the current thread. */
+# define THREAD_DTV() \
+ ({ tcbhead_t *__tcbp; \
+ __asm__ __volatile__ ("rur %0, threadptr" : "=r" (__tcbp)); \
+ __tcbp->dtv; })
+
+/* Return the thread descriptor for the current thread. */
+# define THREAD_SELF \
+ ({ struct pthread *__self; \
+ __asm__ ("rur %0, threadptr" : "=r" (__self)); \
+ __self - 1; })
+
+/* Magic for libthread_db to know how to do THREAD_SELF. */
+# define DB_THREAD_SELF \
+ CONST_THREAD_AREA (32, sizeof (struct pthread))
+
+/* Access to data in the thread descriptor is easy. */
+#define THREAD_GETMEM(descr, member) \
+ descr->member
+#define THREAD_GETMEM_NC(descr, member, idx) \
+ descr->member[idx]
+#define THREAD_SETMEM(descr, member, value) \
+ descr->member = (value)
+#define THREAD_SETMEM_NC(descr, member, idx, value) \
+ descr->member[idx] = (value)
+
+/* Get and set the global scope generation counter in struct pthread. */
+#define THREAD_GSCOPE_FLAG_UNUSED 0
+#define THREAD_GSCOPE_FLAG_USED 1
+#define THREAD_GSCOPE_FLAG_WAIT 2
+#define THREAD_GSCOPE_RESET_FLAG() \
+ do \
+ { int __res \
+ = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \
+ THREAD_GSCOPE_FLAG_UNUSED); \
+ if (__res == THREAD_GSCOPE_FLAG_WAIT) \
+ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \
+ } \
+ while (0)
+#define THREAD_GSCOPE_SET_FLAG() \
+ do \
+ { \
+ THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED; \
+ atomic_write_barrier (); \
+ } \
+ while (0)
+
+#define THREAD_GSCOPE_WAIT() \
+ GL(dl_wait_lookup_done) ()
+
+#endif /* __ASSEMBLER__ */
+
+#endif /* tls.h */
diff --git a/libpthread/nptl/sysdeps/xtensa/tlsdesc.sym b/libpthread/nptl/sysdeps/xtensa/tlsdesc.sym
new file mode 100644
index 000000000..b18bf5fb9
--- /dev/null
+++ b/libpthread/nptl/sysdeps/xtensa/tlsdesc.sym
@@ -0,0 +1,10 @@
+#include <stddef.h>
+#include <sysdep.h>
+#include <tls.h>
+#include <link.h>
+#include <dl-tls.h>
+
+TLSDESC_ARG offsetof(struct tlsdesc, argument)
+TLSDESC_GEN_COUNT offsetof(struct tlsdesc_dynamic_arg, gen_count)
+TLSDESC_MODID offsetof(struct tlsdesc_dynamic_arg, tlsinfo.ti_module)
+TLSDESC_MODOFF offsetof(struct tlsdesc_dynamic_arg, tlsinfo.ti_offset)
diff --git a/libpthread/nptl/unwind.c b/libpthread/nptl/unwind.c
new file mode 100644
index 000000000..cc174320d
--- /dev/null
+++ b/libpthread/nptl/unwind.c
@@ -0,0 +1,179 @@
+/* Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>
+ and Richard Henderson <rth@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 <setjmp.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include "pthreadP.h"
+#include <jmpbuf-unwind.h>
+
+#ifdef HAVE_FORCED_UNWIND
+
+#ifdef _STACK_GROWS_DOWN
+# define FRAME_LEFT(frame, other, adj) \
+ ((uintptr_t) frame - adj >= (uintptr_t) other - adj)
+#elif defined _STACK_GROWS_UP
+# define FRAME_LEFT(frame, other, adj) \
+ ((uintptr_t) frame - adj <= (uintptr_t) other - adj)
+#else
+# error "Define either _STACK_GROWS_DOWN or _STACK_GROWS_UP"
+#endif
+
+static _Unwind_Reason_Code
+unwind_stop (int version, _Unwind_Action actions,
+ _Unwind_Exception_Class exc_class,
+ struct _Unwind_Exception *exc_obj,
+ struct _Unwind_Context *context, void *stop_parameter)
+{
+ struct pthread_unwind_buf *buf = stop_parameter;
+ struct pthread *self = THREAD_SELF;
+ struct _pthread_cleanup_buffer *curp = THREAD_GETMEM (self, cleanup);
+ int do_longjump = 0;
+
+ /* Adjust all pointers used in comparisons, so that top of thread's
+ stack is at the top of address space. Without that, things break
+ if stack is allocated above the main stack. */
+ uintptr_t adj = (uintptr_t) self->stackblock + self->stackblock_size;
+
+ /* Do longjmp if we're at "end of stack", aka "end of unwind data".
+ We assume there are only C frame without unwind data in between
+ here and the jmp_buf target. Otherwise simply note that the CFA
+ of a function is NOT within it's stack frame; it's the SP of the
+ previous frame. */
+ if ((actions & _UA_END_OF_STACK)
+ || ! _JMPBUF_CFA_UNWINDS_ADJ (buf->cancel_jmp_buf[0].jmp_buf, context,
+ adj))
+ do_longjump = 1;
+
+ if (__builtin_expect (curp != NULL, 0))
+ {
+ /* Handle the compatibility stuff. Execute all handlers
+ registered with the old method which would be unwound by this
+ step. */
+ struct _pthread_cleanup_buffer *oldp = buf->priv.data.cleanup;
+ void *cfa = (void *) _Unwind_GetCFA (context);
+
+ if (curp != oldp && (do_longjump || FRAME_LEFT (cfa, curp, adj)))
+ {
+ do
+ {
+ /* Pointer to the next element. */
+ struct _pthread_cleanup_buffer *nextp = curp->__prev;
+
+ /* Call the handler. */
+ curp->__routine (curp->__arg);
+
+ /* To the next. */
+ curp = nextp;
+ }
+ while (curp != oldp
+ && (do_longjump || FRAME_LEFT (cfa, curp, adj)));
+
+ /* Mark the current element as handled. */
+ THREAD_SETMEM (self, cleanup, curp);
+ }
+ }
+
+ if (do_longjump)
+ __libc_unwind_longjmp ((struct __jmp_buf_tag *) buf->cancel_jmp_buf, 1);
+
+ return _URC_NO_REASON;
+}
+
+
+static attribute_noreturn void
+unwind_cleanup (_Unwind_Reason_Code reason, struct _Unwind_Exception *exc)
+{
+ /* When we get here a C++ catch block didn't rethrow the object. We
+ cannot handle this case and therefore abort. */
+# define STR_N_LEN(str) str, strlen (str)
+ INTERNAL_SYSCALL_DECL (err);
+ INTERNAL_SYSCALL (write, err, 3, STDERR_FILENO,
+ STR_N_LEN ("FATAL: exception not rethrown\n"));
+ abort ();
+}
+
+#endif /* have forced unwind */
+
+
+void
+/*does not apply due to hidden_proto(): attribute_protected*/
+__cleanup_fct_attribute __attribute ((noreturn))
+#if !defined SHARED && !defined IS_IN_libpthread
+weak_function
+#endif
+__pthread_unwind (__pthread_unwind_buf_t *buf)
+{
+ struct pthread_unwind_buf *ibuf = (struct pthread_unwind_buf *) buf;
+ struct pthread *self = THREAD_SELF;
+
+#ifdef HAVE_FORCED_UNWIND
+ /* This is not a catchable exception, so don't provide any details about
+ the exception type. We do need to initialize the field though. */
+ THREAD_SETMEM (self, exc.exception_class, 0);
+ THREAD_SETMEM (self, exc.exception_cleanup, unwind_cleanup);
+
+ _Unwind_ForcedUnwind (&self->exc, unwind_stop, ibuf);
+#else
+ /* Handle the compatibility stuff first. Execute all handlers
+ registered with the old method. We don't execute them in order,
+ instead, they will run first. */
+ struct _pthread_cleanup_buffer *oldp = ibuf->priv.data.cleanup;
+ struct _pthread_cleanup_buffer *curp = THREAD_GETMEM (self, cleanup);
+
+ if (curp != oldp)
+ {
+ do
+ {
+ /* Pointer to the next element. */
+ struct _pthread_cleanup_buffer *nextp = curp->__prev;
+
+ /* Call the handler. */
+ curp->__routine (curp->__arg);
+
+ /* To the next. */
+ curp = nextp;
+ }
+ while (curp != oldp);
+
+ /* Mark the current element as handled. */
+ THREAD_SETMEM (self, cleanup, curp);
+ }
+
+ /* We simply jump to the registered setjmp buffer. */
+ __libc_unwind_longjmp ((struct __jmp_buf_tag *) ibuf->cancel_jmp_buf, 1);
+#endif
+ /* NOTREACHED */
+
+ /* We better do not get here. */
+ abort ();
+}
+hidden_def (__pthread_unwind)
+
+
+void
+__cleanup_fct_attribute __attribute ((noreturn))
+__pthread_unwind_next (__pthread_unwind_buf_t *buf)
+{
+ struct pthread_unwind_buf *ibuf = (struct pthread_unwind_buf *) buf;
+
+ __pthread_unwind ((__pthread_unwind_buf_t *) ibuf->priv.data.prev);
+}
+hidden_def (__pthread_unwind_next)
diff --git a/libpthread/nptl/vars.c b/libpthread/nptl/vars.c
new file mode 100644
index 000000000..8f3023cfc
--- /dev/null
+++ b/libpthread/nptl/vars.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 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/>. */
+
+#include <pthreadP.h>
+#include <stdlib.h>
+#include <tls.h>
+#include <unistd.h>
+
+/* Default stack size. */
+size_t __default_stacksize attribute_hidden
+#ifdef SHARED
+;
+#else
+ = PTHREAD_STACK_MIN;
+#endif
+
+/* Flag whether the machine is SMP or not. */
+int __is_smp attribute_hidden;
+
+#ifndef TLS_MULTIPLE_THREADS_IN_TCB
+/* Variable set to a nonzero value if more than one thread runs or ran. */
+int __pthread_multiple_threads attribute_hidden;
+#endif
+
+/* Table of the key information. */
+struct pthread_key_struct __pthread_keys[PTHREAD_KEYS_MAX]
+ __attribute__ ((nocommon));
+hidden_data_def (__pthread_keys)
diff --git a/libpthread/nptl/version.c b/libpthread/nptl/version.c
new file mode 100644
index 000000000..da05a7f40
--- /dev/null
+++ b/libpthread/nptl/version.c
@@ -0,0 +1,44 @@
+/* Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <unistd.h>
+#include <sysdep.h>
+
+
+static const char banner[] =
+#include "banner.h"
+"Copyright (C) 2006 Free Software Foundation, Inc.\n\
+This is free software; see the source for copying conditions.\n\
+There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A\n\
+PARTICULAR PURPOSE.\n"
+#ifdef HAVE_FORCED_UNWIND
+"Forced unwind support included.\n"
+#endif
+;
+
+
+extern void __nptl_main (void) __attribute__ ((noreturn));
+void
+__nptl_main (void)
+{
+ INTERNAL_SYSCALL_DECL (err);
+ INTERNAL_SYSCALL (write, err, 3, STDOUT_FILENO, (const char *) banner,
+ sizeof banner - 1);
+
+ _exit (0);
+}
diff --git a/libpthread/nptl/version.h b/libpthread/nptl/version.h
new file mode 100644
index 000000000..f294f5c97
--- /dev/null
+++ b/libpthread/nptl/version.h
@@ -0,0 +1 @@
+#define VERSION __stringify(__UCLIBC_MAJOR__) "." __stringify(__UCLIBC_MINOR__) "." __stringify(__UCLIBC_SUBLEVEL__)
diff --git a/libpthread/nptl_db/ChangeLog b/libpthread/nptl_db/ChangeLog
new file mode 100644
index 000000000..92021cbfb
--- /dev/null
+++ b/libpthread/nptl_db/ChangeLog
@@ -0,0 +1,230 @@
+2007-05-16 Roland McGrath <roland@redhat.com>
+
+ * td_thr_get_info.c: Fake the results for TH->th_unique == 0.
+ * td_thr_validate.c: Likewise.
+ * td_thr_setgregs.c: Likewise.
+ * td_thr_setfpregs.c: Likewise.
+ * td_thr_getgregs.c: Likewise.
+ * td_thr_getfpregs.c: Likewise.
+ * td_thr_tlsbase.c: Likewise.
+
+ * structs.def: Add DB_VARIABLE (__nptl_initial_report_events).
+ * db_info.c: Add necessary declaration.
+ * td_thr_event_enable.c: Set __nptl_initial_report_events too.
+
+ * td_ta_thr_iter.c (iterate_thread_list): Make FAKE_EMPTY bool.
+ Use th_unique=0 in fake descriptor before initialization.
+
+ * td_ta_map_lwp2thr.c (__td_ta_lookup_th_unique): New function, broken
+ out of ...
+ (td_ta_map_lwp2thr): ... here, call it. But don't before __stack_user
+ is initialized, then fake a handle with th_unique=0.
+ * thread_dbP.h: Declare it.
+
+2004-09-09 Roland McGrath <roland@redhat.com>
+
+ * td_ta_map_lwp2thr.c (td_ta_map_lwp2thr): Don't abort if inferior's
+ descriptor is bogus.
+
+2004-05-27 Roland McGrath <roland@redhat.com>
+
+ * td_thr_validate.c: When we find no threads and the inferior appears
+ uninitialized, validate the main thread as a special case.
+
+2004-05-01 Jakub Jelinek <jakub@redhat.com>
+
+ * thread_dbP.h (LOG): Use write instead of __libc_write.
+
+2004-04-03 Ulrich Drepper <drepper@redhat.com>
+
+ * td_ta_set_event.c (td_ta_set_event): Initialize copy to avoid
+ warnings.
+
+ * td_ta_thr_iter.c (td_ta_thr_iter): Initialize list to avoid warning.
+ * td_ta_clear_event.c (td_ta_clear_event): Initialize eventmask to
+ avoid warning.
+ * td_ta_set_event.c (td_ta_set_event): Likewise.
+
+2004-03-24 Roland McGrath <roland@redhat.com>
+
+ * fetch-value.c (_td_locate_field): Cast DB_DESC_OFFSET to int32_t.
+ * thread_dbP.h (DB_DESC_OFFSET): Remove cast from definition.
+
+2004-03-13 Jakub Jelinek <jakub@redhat.com>
+
+ * db_info.c: Don't use TLS_TP_OFFSET in the #if, but
+ TLS_TCB_SIZE == 0 ?: in the DESC macro.
+
+2004-03-12 Roland McGrath <roland@redhat.com>
+
+ * db_info.c [TLS_DTV_AT_TP && TLS_TP_OFFSET > 0]
+ (_thread_db_pthread_dtvp): Define differently for this case (PowerPC).
+
+2003-12-11 Ulrich Weigand <uweigand@de.ibm.com>
+
+ * db_info.c (REGISTER): Add bit size of thread register as second
+ parameter to REGISTER macro.
+
+2003-12-02 Roland McGrath <roland@redhat.com>
+
+ * thread_dbP.h (DB_FUNCTION): New macro.
+ * structs.def: Use it for __nptl_create_event and __nptl_death_event.
+ * db_info.c (DB_FUNCTION): New macro.
+ * td_symbol_list.c (DB_FUNCTION): New macro, prepend "." to symbol
+ name under [HAVE_ASM_GLOBAL_DOT_NAME].
+ (td_lookup) [HAVE_ASM_GLOBAL_DOT_NAME]: If lookup fails with PS_NOSYM
+ and name starts with a dot, try it without the dot.
+
+2003-09-08 Roland McGrath <roland@redhat.com>
+
+ * td_thr_get_info.c (td_thr_get_info): Cast th_unique to thread_t.
+
+2003-08-22 Roland McGrath <roland@redhat.com>
+
+ * fetch-value.c (_td_check_sizeof, _td_locate_field): Return
+ TD_NOCAPAB for PS_NOSYM, instead of vanilla TD_ERR.
+ * td_thr_tls_get_addr.c (td_thr_tls_get_addr): Return TD_NOAPLIC when
+ DB_GET_FIELD returns TD_NOCAPAB.
+
+ * thread_db.h (td_thr_tls_get_addr): Use psaddr_t in signature.
+ * structs.def [USE_TLS]: Add DB_STRUCT_FIELD (link_map, l_tls_modid).
+ * db_info.c (link_map): Typedef it.
+ * td_thr_tls_get_addr.c (td_thr_tls_get_addr): Rewritten.
+
+2003-08-14 Roland McGrath <roland@redhat.com>
+
+ * thread_dbP.h: Mostly rewritten with many new macros and decls.
+ * td_ta_new.c (td_ta_new): Don't cache a lot of symbol values.
+ * structs.def: New file.
+ * db_info.c: New file.
+ * td_symbol_list.c (symbol_list_arr): Define with structs.def macros.
+ * td_ta_clear_event.c: Rewritten.
+ * td_ta_event_addr.c: Rewritten.
+ * td_ta_event_getmsg.c: Rewritten.
+ * td_ta_get_nthreads.c: Rewritten.
+ * td_ta_map_lwp2thr.c: New file.
+ * td_ta_set_event.c: Rewritten.
+ * td_ta_thr_iter.c: Rewritten.
+ * td_ta_tsd_iter.c: Rewritten.
+ * td_thr_clear_event.c: Rewritten.
+ * td_thr_event_enable.c: Rewritten.
+ * td_thr_event_getmsg.c: Rewritten.
+ * td_thr_get_info.c: Rewritten.
+ * td_thr_getfpregs.c: Rewritten.
+ * td_thr_getgregs.c: Rewritten.
+ * td_thr_set_event.c: Rewritten.
+ * td_thr_setfpregs.c: Rewritten.
+ * td_thr_setgregs.c: Rewritten.
+ * td_thr_tlsbase.c: Rewritten.
+ * td_thr_tsd.c: Rewritten.
+ * td_thr_validate.c: Rewritten.
+ * Makefile (distribute): Add them.
+ * fetch-value.c: New file.
+ * Makefile (libthread_db-routines): Add it.
+
+ * thread_db.h (td_err_e): Comment fix.
+
+2003-08-05 Roland McGrath <roland@redhat.com>
+
+ * thread_dbP.h (td_lookup): Add attribute_hidden to decl.
+
+2003-08-04 Roland McGrath <roland@redhat.com>
+
+ * td_ta_clear_event.c (td_ta_clear_event): Fix sizes in ps_* calls.
+
+2003-06-23 Roland McGrath <roland@redhat.com>
+
+ * proc_service.h: Cosmetic and comment fixes.
+
+2003-06-19 Roland McGrath <roland@redhat.com>
+
+ * td_thr_event_enable.c (td_thr_event_enable): Use proper type `bool'
+ for value written into inferior's `report_events'.
+
+2003-03-18 Roland McGrath <roland@redhat.com>
+
+ * td_thr_event_getmsg.c (td_thr_event_getmsg): Splice the thread out
+ of the ->nextevent linkage.
+
+ * td_ta_event_getmsg.c (td_ta_event_getmsg): Runtime error instead of
+ assert for reading TD_EVENT_NONE. Clear the event buffer after
+ reading it. Add a sanity check for foo->nextevent = foo.
+
+2003-03-15 Roland McGrath <roland@redhat.com>
+
+ * thread_db.h (td_err_e): Add TD_NOTLS and TD_TLSDEFER.
+ (td_thr_tlsbase): Declare it.
+ * td_thr_tlsbase.c: New file.
+ * Makefile (libthread_db-routines): Add it.
+ * Versions (libthread_db: GLIBC_2.3.3): New set, add td_thr_tlsbase.
+ * td_thr_tls_get_addr.c (td_thr_tls_get_addr): Use td_thr_tlsbase.
+
+2003-03-14 Roland McGrath <roland@redhat.com>
+
+ * td_thr_tls_get_addr.c (td_thr_tls_get_addr): Use `header.' prefix.
+
+2003-03-10 Roland McGrath <roland@redhat.com>
+
+ * td_ta_thr_iter.c (iterate_thread_list): Don't use `header.data.'
+ prefix for `struct pthread' members.
+ * td_thr_validate.c (check_thread_list): Likewise.
+ * td_thr_tls_get_addr.c (td_thr_tls_get_addr): Likewise.
+
+2003-03-03 Roland McGrath <roland@redhat.com>
+
+ * td_thr_tls_get_addr.c (td_thr_tls_get_addr): Handle TLS_DTV_AT_TP.
+
+2003-02-15 Ulrich Drepper <drepper@redhat.com>
+
+ * td_symbol_list.c: New symbol name for SYM_PTHREAD_NTHREADS.
+
+2003-01-07 Jakub Jelinek <jakub@redhat.com>
+
+ * td_ta_event_getmsg.c: Include assert.h.
+
+-2003-01-05 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (libthread_db.so-no-z-defs): Define.
+
+2003-01-03 Roland McGrath <roland@redhat.com>
+
+ * td_thr_setgregs.c (td_thr_setgregs): *_BIT -> *_BITMASK
+ * td_thr_setfpregs.c (td_thr_setfpregs): Likewise.
+ * td_thr_get_info.c (td_thr_get_info): Likewise.
+ * td_thr_getgregs.c (td_thr_getgregs): Likewise.
+ * td_thr_getfpregs.c (td_thr_getfpregs): Likewise.
+ * td_ta_thr_iter.c (iterate_thread_list): Likewise.
+
+2002-12-12 Roland McGrath <roland@redhat.com>
+
+ * td_ta_thr_iter.c (iterate_thread_list): Handle special case of
+ uninitialized __stack_user (zeros), hard-wire just the main thread.
+
+ * td_thr_get_info.c (td_thr_get_info): Fix ti_lid initialization.
+
+2002-12-06 Roland McGrath <roland@redhat.com>
+
+ * td_ta_event_getmsg.c (td_ta_event_getmsg): Write the NEXT pointer
+ into the inferior's __pthread_last_event variable, not a word from
+ an inferior address used in the parent. Pass the address of a
+ null word to ps_pdwrite, not a null pointer.
+
+2002-12-04 Roland McGrath <roland@redhat.com>
+
+ * td_thr_get_info.c (td_thr_get_info): ti_tid is pthread_t, not a PID.
+
+ * thread_db.h (td_thrinfo_t): Comment fix.
+
+ * td_ta_map_lwp2thr.c: Moved to ../nptl/sysdeps/i386/.
+
+2002-12-04 Ulrich Drepper <drepper@redhat.com>
+
+ * td_ta_thr_iter.c (iterate_thread_list): At end of iteration read
+ pointer to the next element from inferior.
+
+2002-12-02 Roland McGrath <roland@redhat.com>
+
+ * td_symbol_list.c (symbol_list_arr): pthread_keys -> __pthread_keys
+
+ * td_ta_map_lwp2thr.c (td_ta_map_lwp2thr): Fetch inferior registers to
+ see its %gs value, not our own.
diff --git a/libpthread/nptl_db/Makefile b/libpthread/nptl_db/Makefile
new file mode 100644
index 000000000..f9100219a
--- /dev/null
+++ b/libpthread/nptl_db/Makefile
@@ -0,0 +1,13 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+top_srcdir=../../
+top_builddir=../../
+include $(top_builddir)Rules.mak
+all: libs
+include Makefile.in
+include $(top_srcdir)Makerules
diff --git a/libpthread/nptl_db/Makefile.in b/libpthread/nptl_db/Makefile.in
new file mode 100644
index 000000000..5a493d8b7
--- /dev/null
+++ b/libpthread/nptl_db/Makefile.in
@@ -0,0 +1,74 @@
+# 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.
+#
+
+subdirs += libpthread/nptl_db
+
+# Get the thread include dependencies and shared object name
+CFLAGS-libpthread/nptl_db := -DNOT_IN_libc \
+ -DLIBPTHREAD_SO="\"libpthread.so.$(ABI_VERSION)\"" \
+ -std=gnu99 -D_GNU_SOURCE \
+ -I$(top_srcdir)libpthread/nptl \
+ -I$(top_srcdir)ldso/include
+
+LDFLAGS-libthread_db.so := $(LDFLAGS_NOSTRIP) $(if $(call check_ld,--warn-unresolved-symbols),-Wl$(comma)--warn-unresolved-symbols)
+LIBS-libthread_db.so := $(LIBS)
+
+libthread_db_FULL_NAME := libthread_db-$(VERSION).so
+
+libthread_db_DIR := $(top_srcdir)libpthread/nptl_db
+libthread_db_OUT := $(top_builddir)libpthread/nptl_db
+
+libthread_db_SRC := $(notdir $(wildcard $(libthread_db_DIR)/td_*.c) \
+ $(libthread_db_DIR)/fetch-value.c)
+ifeq ($(UCLIBC_SUSV4_LEGACY),)
+libthread_db_SRC := $(filter-out td_ta_setconcurrency.c,$(libthread_db_SRC))
+endif
+
+libthread_db_OBJ := $(addprefix $(libthread_db_OUT)/,$(libthread_db_SRC:.c=.o))
+
+libthread_db-so-y := $(libthread_db_OBJ:.o=.oS)
+ifeq ($(DOPIC),y)
+libthread_db-a-y := $(libthread_db-so-y)
+else
+libthread_db-a-y := $(libthread_db_OBJ)
+endif
+
+libthread_db-multi-y := $(addprefix $(libthread_db_DIR)/,$(libthread_db_SRC))
+
+lib-a-$(PTHREADS_DEBUG_SUPPORT) += $(top_builddir)lib/libthread_db.a
+lib-so-$(PTHREADS_DEBUG_SUPPORT) += $(top_builddir)lib/libthread_db.so
+objclean-y += CLEAN_libpthread/nptl_db
+headers-$(PTHREADS_DEBUG_SUPPORT) += $(nptl_db_headers)
+headers_clean-y += HEADERCLEAN_libpthread/nptl_db
+
+ifeq ($(DOPIC),y)
+$(top_builddir)lib/libthread_db.so: $(top_builddir)lib/libthread_db.a $(libc.depend)
+else
+$(top_builddir)lib/libthread_db.so: $(libthread_db_OUT)/libthread_db_so.a $(libc.depend)
+endif
+ $(call link.so,$(libthread_db_FULL_NAME),1)
+
+$(libthread_db_OUT)/libthread_db_so.a: $(libthread_db-so-y)
+ $(Q)$(RM) $@
+ $(do_strip)
+ $(do_ar)
+
+$(top_builddir)lib/libthread_db.a: $(libthread_db-a-y) | $(top_builddir)lib
+ $(Q)$(RM) $@
+ $(do_strip)
+ $(do_ar)
+
+$(top_builddir)include/thread_db.h:
+ $(do_ln) $(call rel_srcdir)$(PTDIR)_db/$(@F) $@
+
+nptl_db_headers:= $(top_builddir)include/thread_db.h
+
+HEADERCLEAN_libpthread/nptl_db:
+ $(do_rm) $(nptl_db_headers)
+
+CLEAN_libpthread/nptl_db:
+ $(do_rm) $(addprefix $(libthread_db_OUT)/*., o oS a)
diff --git a/libpthread/nptl_db/db_info.c b/libpthread/nptl_db/db_info.c
new file mode 100644
index 000000000..159a027da
--- /dev/null
+++ b/libpthread/nptl_db/db_info.c
@@ -0,0 +1,104 @@
+/* This file is included by pthread_create.c to define in libpthread
+ all the magic symbols required by libthread_db.
+
+ Copyright (C) 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
+ 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 "thread_dbP.h"
+#include <tls.h>
+
+typedef struct pthread pthread;
+typedef struct pthread_key_struct pthread_key_struct;
+typedef struct pthread_key_data pthread_key_data;
+typedef struct
+{
+ struct pthread_key_data data[PTHREAD_KEY_2NDLEVEL_SIZE];
+}
+pthread_key_data_level2;
+
+typedef struct
+{
+ union dtv dtv[UINT32_MAX / 2 / sizeof (union dtv)]; /* No constant bound. */
+} dtv;
+
+typedef struct link_map link_map;
+
+/* Actually static in nptl/init.c, but we only need it for typeof. */
+extern bool __nptl_initial_report_events;
+
+#define schedparam_sched_priority schedparam.sched_priority
+
+#define eventbuf_eventmask eventbuf.eventmask
+#define eventbuf_eventmask_event_bits eventbuf.eventmask.event_bits
+
+#define DESC(name, offset, obj) \
+ DB_DEFINE_DESC (name, 8 * sizeof (obj), 1, offset);
+#define ARRAY_DESC(name, offset, obj) \
+ DB_DEFINE_DESC (name, \
+ 8 * sizeof (obj)[0], sizeof (obj) / sizeof (obj)[0], \
+ offset);
+
+#if defined(TLS_TCB_AT_TP)
+# define dtvp header.dtv
+#elif defined(TLS_DTV_AT_TP)
+/* Special case hack. If TLS_TCB_SIZE == 0 (on PowerPC), there is no TCB
+ containing the DTV at the TP, but actually the TCB lies behind the TP,
+ i.e. at the very end of the area covered by TLS_PRE_TCB_SIZE. */
+DESC (_thread_db_pthread_dtvp,
+ TLS_PRE_TCB_SIZE + offsetof (tcbhead_t, dtv)
+ - (TLS_TCB_SIZE == 0 ? sizeof (tcbhead_t) : 0), union dtv *)
+#endif
+
+
+#define DB_STRUCT(type) \
+ const uint32_t _thread_db_sizeof_##type = sizeof (type);
+#define DB_STRUCT_FIELD(type, field) \
+ DESC (_thread_db_##type##_##field, \
+ offsetof (type, field), ((type *) 0)->field)
+#define DB_STRUCT_ARRAY_FIELD(type, field) \
+ ARRAY_DESC (_thread_db_##type##_##field, \
+ offsetof (type, field), ((type *) 0)->field)
+#define DB_VARIABLE(name) DESC (_thread_db_##name, 0, name)
+#define DB_ARRAY_VARIABLE(name) ARRAY_DESC (_thread_db_##name, 0, name)
+#define DB_SYMBOL(name) /* Nothing. */
+#define DB_FUNCTION(name) /* Nothing. */
+#include "structs.def"
+#undef DB_STRUCT
+#undef DB_STRUCT_FIELD
+#undef DB_SYMBOL
+#undef DB_FUNCTION
+#undef DB_VARIABLE
+#undef DESC
+
+
+
+#ifdef DB_THREAD_SELF
+# ifdef DB_THREAD_SELF_INCLUDE
+# include DB_THREAD_SELF_INCLUDE
+# endif
+
+/* This macro is defined in the machine's tls.h using the three below. */
+# define CONST_THREAD_AREA(bits, value) \
+ const uint32_t _thread_db_const_thread_area = (value);
+# define REGISTER_THREAD_AREA(bits, regofs, scale) \
+ DB_DEFINE_DESC (_thread_db_register##bits##_thread_area, \
+ bits, (scale), (regofs));
+# define REGISTER(bits, size, regofs, bias) \
+ DB_DEFINE_DESC (_thread_db_register##bits, size, (uint32_t)(bias), (regofs));
+
+DB_THREAD_SELF
+#endif
diff --git a/libpthread/nptl_db/fetch-value.c b/libpthread/nptl_db/fetch-value.c
new file mode 100644
index 000000000..2c03609c8
--- /dev/null
+++ b/libpthread/nptl_db/fetch-value.c
@@ -0,0 +1,283 @@
+/* Helper routines for libthread_db.
+ Copyright (C) 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "thread_dbP.h"
+#include <byteswap.h>
+#include <assert.h>
+
+td_err_e
+_td_check_sizeof (td_thragent_t *ta, uint32_t *sizep, int sizep_name)
+{
+ if (*sizep == 0)
+ {
+ psaddr_t descptr;
+ ps_err_e err = td_lookup (ta->ph, sizep_name, &descptr);
+ if (err == PS_NOSYM)
+ return TD_NOCAPAB;
+ if (err == PS_OK)
+ err = ps_pdread (ta->ph, descptr, sizep, sizeof *sizep);
+ if (err != PS_OK)
+ return TD_ERR;
+ if (*sizep & 0xff000000U)
+ *sizep = bswap_32 (*sizep);
+ }
+ return TD_OK;
+}
+
+td_err_e
+_td_locate_field (td_thragent_t *ta,
+ db_desc_t desc, int descriptor_name,
+ psaddr_t idx, psaddr_t *address)
+{
+ uint32_t elemsize;
+
+ if (DB_DESC_SIZE (desc) == 0)
+ {
+ /* Read the information about this field from the inferior. */
+ psaddr_t descptr;
+ ps_err_e err = td_lookup (ta->ph, descriptor_name, &descptr);
+ if (err == PS_NOSYM)
+ return TD_NOCAPAB;
+ if (err == PS_OK)
+ err = ps_pdread (ta->ph, descptr, desc, DB_SIZEOF_DESC);
+ if (err != PS_OK)
+ return TD_ERR;
+ if (DB_DESC_SIZE (desc) == 0)
+ return TD_DBERR;
+ if (DB_DESC_SIZE (desc) & 0xff000000U)
+ {
+ /* Byte-swap these words, though we leave the size word
+ in native order as the handy way to distinguish. */
+ DB_DESC_OFFSET (desc) = bswap_32 (DB_DESC_OFFSET (desc));
+ DB_DESC_NELEM (desc) = bswap_32 (DB_DESC_NELEM (desc));
+ }
+ }
+
+ if (idx != 0 && idx - (psaddr_t) 0 > DB_DESC_NELEM (desc))
+ /* This is an internal indicator to callers with nonzero IDX
+ that the IDX value is too big. */
+ return TD_NOAPLIC;
+
+ elemsize = DB_DESC_SIZE (desc);
+ if (elemsize & 0xff000000U)
+ elemsize = bswap_32 (elemsize);
+
+ *address += (int32_t) DB_DESC_OFFSET (desc);
+ *address += (elemsize / 8 * (idx - (psaddr_t) 0));
+ return TD_OK;
+}
+
+td_err_e
+_td_fetch_value (td_thragent_t *ta,
+ db_desc_t desc, int descriptor_name,
+ psaddr_t idx, psaddr_t address,
+ psaddr_t *result)
+{
+ ps_err_e err;
+ td_err_e terr = _td_locate_field (ta, desc, descriptor_name, idx, &address);
+ if (terr != TD_OK)
+ return terr;
+
+ if (DB_DESC_SIZE (desc) == 8 || DB_DESC_SIZE (desc) == bswap_32 (8))
+ {
+ uint8_t value;
+ err = ps_pdread (ta->ph, address, &value, sizeof value);
+ *result = (psaddr_t) 0 + value;
+ }
+ else if (DB_DESC_SIZE (desc) == 32)
+ {
+ uint32_t value;
+ err = ps_pdread (ta->ph, address, &value, sizeof value);
+ *result = (psaddr_t) 0 + value;
+ }
+ else if (DB_DESC_SIZE (desc) == 64)
+ {
+ uint64_t value;
+ if (sizeof (psaddr_t) < 8)
+ return TD_NOCAPAB;
+ err = ps_pdread (ta->ph, address, &value, sizeof value);
+ *result = (psaddr_t) 0 + value;
+ }
+ else if (DB_DESC_SIZE (desc) == bswap_32 (32))
+ {
+ uint32_t value;
+ err = ps_pdread (ta->ph, address, &value, sizeof value);
+ value = bswap_32 (value);
+ *result = (psaddr_t) 0 + value;
+ }
+ else if (DB_DESC_SIZE (desc) == bswap_32 (64))
+ {
+ uint64_t value;
+ if (sizeof (psaddr_t) < 8)
+ return TD_NOCAPAB;
+ err = ps_pdread (ta->ph, address, &value, sizeof value);
+ value = bswap_64 (value);
+ *result = (psaddr_t) 0 + value;
+ }
+ else
+ return TD_DBERR;
+
+ return err == PS_OK ? TD_OK : TD_ERR;
+}
+
+
+td_err_e
+_td_store_value (td_thragent_t *ta,
+ uint32_t desc[2], int descriptor_name, psaddr_t idx,
+ psaddr_t address, psaddr_t widened_value)
+{
+ ps_err_e err;
+ td_err_e terr = _td_locate_field (ta, desc, descriptor_name, idx, &address);
+ if (terr != TD_OK)
+ return terr;
+
+ if (DB_DESC_SIZE (desc) == 8 || DB_DESC_SIZE (desc) == bswap_32 (8))
+ {
+ uint8_t value = widened_value - (psaddr_t) 0;
+ err = ps_pdwrite (ta->ph, address, &value, sizeof value);
+ }
+ else if (DB_DESC_SIZE (desc) == 32)
+ {
+ uint32_t value = widened_value - (psaddr_t) 0;
+ err = ps_pdwrite (ta->ph, address, &value, sizeof value);
+ }
+ else if (DB_DESC_SIZE (desc) == 64)
+ {
+ uint64_t value = widened_value - (psaddr_t) 0;
+ if (sizeof (psaddr_t) < 8)
+ return TD_NOCAPAB;
+ err = ps_pdwrite (ta->ph, address, &value, sizeof value);
+ }
+ else if (DB_DESC_SIZE (desc) == bswap_32 (32))
+ {
+ uint32_t value = widened_value - (psaddr_t) 0;
+ value = bswap_32 (value);
+ err = ps_pdwrite (ta->ph, address, &value, sizeof value);
+ }
+ else if (DB_DESC_SIZE (desc) == bswap_32 (64))
+ {
+ uint64_t value = widened_value - (psaddr_t) 0;
+ if (sizeof (psaddr_t) < 8)
+ return TD_NOCAPAB;
+ value = bswap_64 (value);
+ err = ps_pdwrite (ta->ph, address, &value, sizeof value);
+ }
+ else
+ return TD_DBERR;
+
+ return err == PS_OK ? TD_OK : TD_ERR;
+}
+
+td_err_e
+_td_fetch_value_local (td_thragent_t *ta,
+ db_desc_t desc, int descriptor_name, psaddr_t idx,
+ void *address,
+ psaddr_t *result)
+{
+ td_err_e terr = _td_locate_field (ta, desc, descriptor_name, idx, &address);
+ if (terr != TD_OK)
+ return terr;
+
+ if (DB_DESC_SIZE (desc) == 8 || DB_DESC_SIZE (desc) == bswap_32 (8))
+ {
+ uint8_t value;
+ memcpy (&value, address, sizeof value);
+ *result = (psaddr_t) 0 + value;
+ }
+ else if (DB_DESC_SIZE (desc) == 32)
+ {
+ uint32_t value;
+ memcpy (&value, address, sizeof value);
+ *result = (psaddr_t) 0 + value;
+ }
+ else if (DB_DESC_SIZE (desc) == 64)
+ {
+ uint64_t value;
+ if (sizeof (psaddr_t) < 8)
+ return TD_NOCAPAB;
+ memcpy (&value, address, sizeof value);
+ *result = (psaddr_t) 0 + value;
+ }
+ else if (DB_DESC_SIZE (desc) == bswap_32 (32))
+ {
+ uint32_t value;
+ memcpy (&value, address, sizeof value);
+ value = bswap_32 (value);
+ *result = (psaddr_t) 0 + value;
+ }
+ else if (DB_DESC_SIZE (desc) == bswap_32 (64))
+ {
+ uint64_t value;
+ if (sizeof (psaddr_t) < 8)
+ return TD_NOCAPAB;
+ memcpy (&value, address, sizeof value);
+ value = bswap_64 (value);
+ *result = (psaddr_t) 0 + value;
+ }
+ else
+ return TD_DBERR;
+
+ return TD_OK;
+}
+
+
+td_err_e
+_td_store_value_local (td_thragent_t *ta,
+ uint32_t desc[2], int descriptor_name, psaddr_t idx,
+ void *address, psaddr_t widened_value)
+{
+ td_err_e terr = _td_locate_field (ta, desc, descriptor_name, idx, &address);
+ if (terr != TD_OK)
+ return terr;
+
+ if (DB_DESC_SIZE (desc) == 8 || DB_DESC_SIZE (desc) == bswap_32 (8))
+ {
+ uint8_t value = widened_value - (psaddr_t) 0;
+ memcpy (address, &value, sizeof value);
+ }
+ else if (DB_DESC_SIZE (desc) == 32)
+ {
+ uint32_t value = widened_value - (psaddr_t) 0;
+ memcpy (address, &value, sizeof value);
+ }
+ else if (DB_DESC_SIZE (desc) == 64)
+ {
+ uint64_t value = widened_value - (psaddr_t) 0;
+ if (sizeof (psaddr_t) < 8)
+ return TD_NOCAPAB;
+ memcpy (address, &value, sizeof value);
+ }
+ else if (DB_DESC_SIZE (desc) == bswap_32 (32))
+ {
+ uint32_t value = widened_value - (psaddr_t) 0;
+ value = bswap_32 (value);
+ memcpy (address, &value, sizeof value);
+ }
+ else if (DB_DESC_SIZE (desc) == bswap_32 (64))
+ {
+ uint64_t value = widened_value - (psaddr_t) 0;
+ if (sizeof (psaddr_t) < 8)
+ return TD_NOCAPAB;
+ value = bswap_64 (value);
+ memcpy (address, &value, sizeof value);
+ }
+ else
+ return TD_DBERR;
+
+ return TD_OK;
+}
diff --git a/libpthread/nptl_db/proc_service.h b/libpthread/nptl_db/proc_service.h
new file mode 100644
index 000000000..d12e56d96
--- /dev/null
+++ b/libpthread/nptl_db/proc_service.h
@@ -0,0 +1,86 @@
+/* Callback interface for libthread_db, functions users must define.
+ Copyright (C) 1999,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/>. */
+
+/* The definitions in this file must correspond to those in the debugger. */
+#include <sys/procfs.h>
+
+/* Functions in this interface return one of these status codes. */
+typedef enum
+{
+ PS_OK, /* Generic "call succeeded". */
+ PS_ERR, /* Generic error. */
+ PS_BADPID, /* Bad process handle. */
+ PS_BADLID, /* Bad LWP identifier. */
+ PS_BADADDR, /* Bad address. */
+ PS_NOSYM, /* Could not find given symbol. */
+ PS_NOFREGS /* FPU register set not available for given LWP. */
+} ps_err_e;
+
+
+/* This type is opaque in this interface.
+ It's defined by the user of libthread_db. */
+struct ps_prochandle;
+
+
+/* Read or write process memory at the given address. */
+extern ps_err_e ps_pdread (struct ps_prochandle *,
+ psaddr_t, void *, size_t);
+extern ps_err_e ps_pdwrite (struct ps_prochandle *,
+ psaddr_t, const void *, size_t);
+extern ps_err_e ps_ptread (struct ps_prochandle *,
+ psaddr_t, void *, size_t);
+extern ps_err_e ps_ptwrite (struct ps_prochandle *,
+ psaddr_t, const void *, size_t);
+
+
+/* Get and set the given LWP's general or FPU register set. */
+extern ps_err_e ps_lgetregs (struct ps_prochandle *,
+ lwpid_t, prgregset_t);
+extern ps_err_e ps_lsetregs (struct ps_prochandle *,
+ lwpid_t, const prgregset_t);
+extern ps_err_e ps_lgetfpregs (struct ps_prochandle *,
+ lwpid_t, prfpregset_t *);
+extern ps_err_e ps_lsetfpregs (struct ps_prochandle *,
+ lwpid_t, const prfpregset_t *);
+
+/* Return the PID of the process. */
+extern pid_t ps_getpid (struct ps_prochandle *);
+
+/* Fetch the special per-thread address associated with the given LWP.
+ This call is only used on a few platforms (most use a normal register).
+ The meaning of the `int' parameter is machine-dependent. */
+extern ps_err_e ps_get_thread_area (const struct ps_prochandle *,
+ lwpid_t, int, psaddr_t *);
+
+
+/* Look up the named symbol in the named DSO in the symbol tables
+ associated with the process being debugged, filling in *SYM_ADDR
+ with the corresponding run-time address. */
+extern ps_err_e ps_pglobal_lookup (struct ps_prochandle *,
+ const char *object_name,
+ const char *sym_name,
+ psaddr_t *sym_addr);
+
+
+/* Stop or continue the entire process. */
+extern ps_err_e ps_pstop (const struct ps_prochandle *);
+extern ps_err_e ps_pcontinue (const struct ps_prochandle *);
+
+/* Stop or continue the given LWP alone. */
+extern ps_err_e ps_lstop (const struct ps_prochandle *, lwpid_t);
+extern ps_err_e ps_lcontinue (const struct ps_prochandle *, lwpid_t);
diff --git a/libpthread/nptl_db/structs.def b/libpthread/nptl_db/structs.def
new file mode 100644
index 000000000..bb571d45c
--- /dev/null
+++ b/libpthread/nptl_db/structs.def
@@ -0,0 +1,88 @@
+/* List of types and symbols in libpthread examined by libthread_db.
+ Copyright (C) 2003, 2006, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ 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 DB_STRUCT_ARRAY_FIELD
+# define DB_STRUCT_ARRAY_FIELD(type, field) DB_STRUCT_FIELD (type, field)
+# define DB_ARRAY_VARIABLE(name) DB_VARIABLE (name)
+# define STRUCTS_DEF_DEFAULTS 1
+#endif
+
+DB_STRUCT (pthread)
+DB_STRUCT_FIELD (pthread, list)
+DB_STRUCT_FIELD (pthread, report_events)
+DB_STRUCT_FIELD (pthread, tid)
+DB_STRUCT_FIELD (pthread, start_routine)
+DB_STRUCT_FIELD (pthread, cancelhandling)
+DB_STRUCT_FIELD (pthread, schedpolicy)
+DB_STRUCT_FIELD (pthread, schedparam_sched_priority)
+DB_STRUCT_FIELD (pthread, specific)
+DB_STRUCT_FIELD (pthread, eventbuf)
+DB_STRUCT_FIELD (pthread, eventbuf_eventmask)
+DB_STRUCT_ARRAY_FIELD (pthread, eventbuf_eventmask_event_bits)
+DB_STRUCT_FIELD (pthread, nextevent)
+
+DB_STRUCT (list_t)
+DB_STRUCT_FIELD (list_t, next)
+DB_STRUCT_FIELD (list_t, prev)
+
+DB_STRUCT (td_thr_events_t)
+DB_STRUCT_ARRAY_FIELD (td_thr_events_t, event_bits)
+
+DB_STRUCT (td_eventbuf_t)
+DB_STRUCT_FIELD (td_eventbuf_t, eventnum)
+DB_STRUCT_FIELD (td_eventbuf_t, eventdata)
+
+DB_SYMBOL (stack_used)
+DB_SYMBOL (__stack_user)
+DB_SYMBOL (nptl_version)
+DB_FUNCTION (__nptl_create_event)
+DB_FUNCTION (__nptl_death_event)
+DB_SYMBOL (__nptl_threads_events)
+DB_VARIABLE (__nptl_nthreads)
+DB_VARIABLE (__nptl_last_event)
+DB_VARIABLE (__nptl_initial_report_events)
+
+DB_ARRAY_VARIABLE (__pthread_keys)
+DB_STRUCT (pthread_key_struct)
+DB_STRUCT_FIELD (pthread_key_struct, seq)
+DB_STRUCT_FIELD (pthread_key_struct, destr)
+
+DB_STRUCT (pthread_key_data)
+DB_STRUCT_FIELD (pthread_key_data, seq)
+DB_STRUCT_FIELD (pthread_key_data, data)
+DB_STRUCT (pthread_key_data_level2)
+DB_STRUCT_ARRAY_FIELD (pthread_key_data_level2, data)
+
+#if USE_TLS
+DB_STRUCT_FIELD (link_map, l_tls_modid)
+#endif
+
+#if !defined IS_IN_libpthread || USE_TLS
+DB_STRUCT_ARRAY_FIELD (dtv, dtv)
+# define pointer_val pointer.val /* Field of anonymous struct in dtv_t. */
+DB_STRUCT_FIELD (dtv_t, pointer_val)
+#endif
+#if !defined IS_IN_libpthread || (defined TLS_TCB_AT_TP && TLS_TCB_AT_TP)
+DB_STRUCT_FIELD (pthread, dtvp)
+#endif
+
+#ifdef STRUCTS_DEF_DEFAULTS
+# undef DB_STRUCT_ARRAY_FIELD
+# undef DB_ARRAY_VARIABLE
+# undef STRUCTS_DEF_DEFAULTS
+#endif
diff --git a/libpthread/nptl_db/td_init.c b/libpthread/nptl_db/td_init.c
new file mode 100644
index 000000000..65ad4edb6
--- /dev/null
+++ b/libpthread/nptl_db/td_init.c
@@ -0,0 +1,31 @@
+/* Initialization function of thread debugger support library.
+ Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 "thread_dbP.h"
+
+int __td_debug;
+
+
+td_err_e
+td_init (void)
+{
+ /* XXX We have to figure out what has to be done. */
+ LOG ("td_init");
+ return TD_OK;
+}
diff --git a/libpthread/nptl_db/td_log.c b/libpthread/nptl_db/td_log.c
new file mode 100644
index 000000000..d9b94d2bf
--- /dev/null
+++ b/libpthread/nptl_db/td_log.c
@@ -0,0 +1,31 @@
+/* Noop, left for historical reasons.
+ Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 "thread_dbP.h"
+
+
+td_err_e
+td_log (void)
+{
+ /* This interface is deprecated in the Sun interface. We provide it
+ for compatibility but don't do anything ourself. We might in
+ future do some logging if this seems reasonable. */
+ LOG ("td_log");
+ return TD_OK;
+}
diff --git a/libpthread/nptl_db/td_symbol_list.c b/libpthread/nptl_db/td_symbol_list.c
new file mode 100644
index 000000000..fc5ee7cc5
--- /dev/null
+++ b/libpthread/nptl_db/td_symbol_list.c
@@ -0,0 +1,70 @@
+/* Return list of symbols the library can request.
+ Copyright (C) 2001, 2002, 2003 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 <assert.h>
+#ifndef __UCLIBC__
+#include <gnu/lib-names.h>
+#endif
+#include "thread_dbP.h"
+
+static const char *symbol_list_arr[] =
+{
+# define DB_STRUCT(type) \
+ [SYM_SIZEOF_##type] = "_thread_db_sizeof_" #type,
+# define DB_STRUCT_FIELD(type, field) \
+ [SYM_##type##_FIELD_##field] = "_thread_db_" #type "_" #field,
+# define DB_SYMBOL(name) \
+ [SYM_##name] = #name,
+# define DB_FUNCTION(name) \
+ [SYM_##name] = #name,
+# define DB_VARIABLE(name) \
+ [SYM_##name] = #name, \
+ [SYM_DESC_##name] = "_thread_db_" #name,
+# include "structs.def"
+# undef DB_STRUCT
+# undef DB_FUNCTION
+# undef DB_SYMBOL
+# undef DB_VARIABLE
+
+ [SYM_TH_UNIQUE_CONST_THREAD_AREA] = "_thread_db_const_thread_area",
+ [SYM_TH_UNIQUE_REGISTER64] = "_thread_db_register64",
+ [SYM_TH_UNIQUE_REGISTER32] = "_thread_db_register32",
+ [SYM_TH_UNIQUE_REGISTER32_THREAD_AREA] = "_thread_db_register32_thread_area",
+ [SYM_TH_UNIQUE_REGISTER64_THREAD_AREA] = "_thread_db_register64_thread_area",
+
+ [SYM_NUM_MESSAGES] = NULL
+};
+
+
+const char **
+td_symbol_list (void)
+{
+ return symbol_list_arr;
+}
+
+
+ps_err_e
+td_lookup (struct ps_prochandle *ps, int idx, psaddr_t *sym_addr)
+{
+ ps_err_e result;
+ assert (idx >= 0 && idx < SYM_NUM_MESSAGES);
+ result = ps_pglobal_lookup (ps, LIBPTHREAD_SO, symbol_list_arr[idx],
+ sym_addr);
+ return result;
+}
diff --git a/libpthread/nptl_db/td_ta_clear_event.c b/libpthread/nptl_db/td_ta_clear_event.c
new file mode 100644
index 000000000..74d22f964
--- /dev/null
+++ b/libpthread/nptl_db/td_ta_clear_event.c
@@ -0,0 +1,76 @@
+/* Globally disable events.
+ Copyright (C) 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 "thread_dbP.h"
+
+
+td_err_e
+td_ta_clear_event (const td_thragent_t *ta_arg, td_thr_events_t *event)
+{
+ td_thragent_t *const ta = (td_thragent_t *) ta_arg;
+ td_err_e err;
+ psaddr_t eventmask = 0;
+ void *copy = NULL;
+
+ LOG ("td_ta_clear_event");
+
+ /* Test whether the TA parameter is ok. */
+ if (! ta_ok (ta))
+ return TD_BADTA;
+
+ /* Fetch the old event mask from the inferior and modify it in place. */
+ err = DB_GET_SYMBOL (eventmask, ta, __nptl_threads_events);
+ if (err == TD_OK)
+ err = DB_GET_STRUCT (copy, ta, eventmask, td_thr_events_t);
+ if (err == TD_OK)
+ {
+ uint32_t idx;
+ for (idx = 0; idx < TD_EVENTSIZE; ++idx)
+ {
+ psaddr_t word;
+ uint32_t mask;
+ err = DB_GET_FIELD_LOCAL (word, ta, copy,
+ td_thr_events_t, event_bits, idx);
+ if (err != TD_OK)
+ break;
+ mask = (uintptr_t) word;
+ mask &= ~event->event_bits[idx];
+ word = (psaddr_t) (uintptr_t) mask;
+ err = DB_PUT_FIELD_LOCAL (ta, copy,
+ td_thr_events_t, event_bits, idx, word);
+ if (err != TD_OK)
+ break;
+ }
+ if (err == TD_NOAPLIC)
+ {
+ err = TD_OK;
+ while (idx < TD_EVENTSIZE)
+ if (event->event_bits[idx++] != 0)
+ {
+ err = TD_NOEVENT;
+ break;
+ }
+ }
+ if (err == TD_OK)
+ /* Now write it back to the inferior. */
+ err = DB_PUT_STRUCT (ta, eventmask, td_thr_events_t, copy);
+ }
+
+ return err;
+}
diff --git a/libpthread/nptl_db/td_ta_delete.c b/libpthread/nptl_db/td_ta_delete.c
new file mode 100644
index 000000000..e269f78bf
--- /dev/null
+++ b/libpthread/nptl_db/td_ta_delete.c
@@ -0,0 +1,41 @@
+/* Detach to target process.
+ Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 <stdlib.h>
+
+#include "thread_dbP.h"
+
+
+td_err_e
+td_ta_delete (td_thragent_t *ta)
+{
+ LOG ("td_ta_delete");
+
+ /* Safety check. Note that the test will also fail for TA == NULL. */
+ if (!ta_ok (ta))
+ return TD_BADTA;
+
+ /* Remove the handle from the list. */
+ list_del (&ta->list);
+
+ /* The handle was allocated in `td_ta_new'. */
+ free (ta);
+
+ return TD_OK;
+}
diff --git a/libpthread/nptl_db/td_ta_enable_stats.c b/libpthread/nptl_db/td_ta_enable_stats.c
new file mode 100644
index 000000000..2e036df82
--- /dev/null
+++ b/libpthread/nptl_db/td_ta_enable_stats.c
@@ -0,0 +1,34 @@
+/* Enable collection of statistics for process.
+ Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 "thread_dbP.h"
+
+
+td_err_e
+td_ta_enable_stats (const td_thragent_t *ta, int enable)
+{
+ /* XXX We have to figure out what has to be done. */
+ LOG ("td_ta_enable_stats");
+
+ /* Test whether the TA parameter is ok. */
+ if (! ta_ok (ta))
+ return TD_BADTA;
+
+ return TD_OK;
+}
diff --git a/libpthread/nptl_db/td_ta_event_addr.c b/libpthread/nptl_db/td_ta_event_addr.c
new file mode 100644
index 000000000..d1ed276ce
--- /dev/null
+++ b/libpthread/nptl_db/td_ta_event_addr.c
@@ -0,0 +1,60 @@
+/* Get event address.
+ Copyright (C) 1999,2001,2002,2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 "thread_dbP.h"
+
+
+td_err_e
+td_ta_event_addr (const td_thragent_t *ta_arg,
+ td_event_e event, td_notify_t *addr)
+{
+ td_thragent_t *const ta = (td_thragent_t *) ta_arg;
+ td_err_e err;
+ psaddr_t taddr = NULL;
+
+ LOG ("td_ta_event_addr");
+
+ /* Test whether the TA parameter is ok. */
+ if (! ta_ok (ta))
+ return TD_BADTA;
+
+ switch (event)
+ {
+ case TD_CREATE:
+ err = DB_GET_SYMBOL (taddr, ta, __nptl_create_event);
+ break;
+
+ case TD_DEATH:
+ err = DB_GET_SYMBOL (taddr, ta, __nptl_death_event);
+ break;
+
+ default:
+ /* Event cannot be handled. */
+ return TD_NOEVENT;
+ }
+
+ if (err == TD_OK)
+ {
+ /* Success, we got the address. */
+ addr->type = NOTIFY_BPT;
+ addr->u.bptaddr = taddr;
+ }
+
+ return err;
+}
diff --git a/libpthread/nptl_db/td_ta_event_getmsg.c b/libpthread/nptl_db/td_ta_event_getmsg.c
new file mode 100644
index 000000000..8ce232142
--- /dev/null
+++ b/libpthread/nptl_db/td_ta_event_getmsg.c
@@ -0,0 +1,104 @@
+/* Retrieve event.
+ Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 <stddef.h>
+#include <string.h>
+
+#include "thread_dbP.h"
+
+
+td_err_e
+td_ta_event_getmsg (const td_thragent_t *ta_arg, td_event_msg_t *msg)
+{
+ td_thragent_t *const ta = (td_thragent_t *) ta_arg;
+ td_err_e err;
+ psaddr_t eventbuf, eventnum, eventdata;
+ psaddr_t thp, next;
+ void *copy = NULL;
+
+ /* XXX I cannot think of another way but using a static variable. */
+ /* XXX Use at least __thread once it is possible. */
+ static td_thrhandle_t th;
+
+ LOG ("td_thr_event_getmsg");
+
+ /* Test whether the TA parameter is ok. */
+ if (! ta_ok (ta))
+ return TD_BADTA;
+
+ /* Get the pointer to the thread descriptor with the last event. */
+ err = DB_GET_VALUE (thp, ta, __nptl_last_event, 0);
+ if (err != TD_OK)
+ return err;
+
+ if (thp == 0)
+ /* Nothing waiting. */
+ return TD_NOMSG;
+
+ /* Copy the event message buffer in from the inferior. */
+ err = DB_GET_FIELD_ADDRESS (eventbuf, ta, thp, pthread, eventbuf, 0);
+ if (err == TD_OK)
+ err = DB_GET_STRUCT (copy, ta, eventbuf, td_eventbuf_t);
+ if (err != TD_OK)
+ return err;
+
+ /* Read the event details from the target thread. */
+ err = DB_GET_FIELD_LOCAL (eventnum, ta, copy, td_eventbuf_t, eventnum, 0);
+ if (err != TD_OK)
+ return err;
+ /* If the structure is on the list there better be an event recorded. */
+ if ((int) (uintptr_t) eventnum == TD_EVENT_NONE)
+ return TD_DBERR;
+
+ /* Fill the user's data structure. */
+ err = DB_GET_FIELD_LOCAL (eventdata, ta, copy, td_eventbuf_t, eventdata, 0);
+ if (err != TD_OK)
+ return err;
+
+ /* Generate the thread descriptor. */
+ th.th_ta_p = (td_thragent_t *) ta;
+ th.th_unique = thp;
+
+ /* Fill the user's data structure. */
+ msg->msg.data = (uintptr_t) eventdata;
+ msg->event = (uintptr_t) eventnum;
+ msg->th_p = &th;
+
+ /* And clear the event message in the target. */
+ memset (copy, 0, ta->ta_sizeof_td_eventbuf_t);
+ err = DB_PUT_STRUCT (ta, eventbuf, td_eventbuf_t, copy);
+ if (err != TD_OK)
+ return err;
+
+ /* Get the pointer to the next descriptor with an event. */
+ err = DB_GET_FIELD (next, ta, thp, pthread, nextevent, 0);
+ if (err != TD_OK)
+ return err;
+
+ /* Store the pointer in the list head variable. */
+ err = DB_PUT_VALUE (ta, __nptl_last_event, 0, next);
+ if (err != TD_OK)
+ return err;
+
+ if (next != 0)
+ /* Clear the next pointer in the current descriptor. */
+ err = DB_PUT_FIELD (ta, thp, pthread, nextevent, 0, 0);
+
+ return err;
+}
diff --git a/libpthread/nptl_db/td_ta_get_nthreads.c b/libpthread/nptl_db/td_ta_get_nthreads.c
new file mode 100644
index 000000000..a5b15ca50
--- /dev/null
+++ b/libpthread/nptl_db/td_ta_get_nthreads.c
@@ -0,0 +1,41 @@
+/* Get the number of threads in the process.
+ Copyright (C) 1999,2001,2002,2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 "thread_dbP.h"
+
+td_err_e
+td_ta_get_nthreads (const td_thragent_t *ta_arg, int *np)
+{
+ td_thragent_t *const ta = (td_thragent_t *) ta_arg;
+ td_err_e err;
+ psaddr_t n;
+
+ LOG ("td_ta_get_nthreads");
+
+ /* Test whether the TA parameter is ok. */
+ if (! ta_ok (ta))
+ return TD_BADTA;
+
+ /* Access the variable in the inferior that tells us. */
+ err = DB_GET_VALUE (n, ta, __nptl_nthreads, 0);
+ if (err == TD_OK)
+ *np = (uintptr_t) n;
+
+ return err;
+}
diff --git a/libpthread/nptl_db/td_ta_get_ph.c b/libpthread/nptl_db/td_ta_get_ph.c
new file mode 100644
index 000000000..508706e56
--- /dev/null
+++ b/libpthread/nptl_db/td_ta_get_ph.c
@@ -0,0 +1,35 @@
+/* Get external process handle.
+ Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 "thread_dbP.h"
+
+
+td_err_e
+td_ta_get_ph (const td_thragent_t *ta, struct ps_prochandle **ph)
+{
+ LOG ("td_ta_get_ph");
+
+ /* Test whether the TA parameter is ok. */
+ if (! ta_ok (ta))
+ return TD_BADTA;
+
+ *ph = ta->ph;
+
+ return TD_OK;
+}
diff --git a/libpthread/nptl_db/td_ta_get_stats.c b/libpthread/nptl_db/td_ta_get_stats.c
new file mode 100644
index 000000000..847a50cf4
--- /dev/null
+++ b/libpthread/nptl_db/td_ta_get_stats.c
@@ -0,0 +1,34 @@
+/* Retrieve statistics for process.
+ Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 "thread_dbP.h"
+
+
+td_err_e
+td_ta_get_stats (const td_thragent_t *ta, td_ta_stats_t *statsp)
+{
+ /* XXX We have to figure out what has to be done. */
+ LOG ("td_ta_get_stats");
+
+ /* Test whether the TA parameter is ok. */
+ if (! ta_ok (ta))
+ return TD_BADTA;
+
+ return TD_OK;
+}
diff --git a/libpthread/nptl_db/td_ta_map_id2thr.c b/libpthread/nptl_db/td_ta_map_id2thr.c
new file mode 100644
index 000000000..c4d2751fb
--- /dev/null
+++ b/libpthread/nptl_db/td_ta_map_id2thr.c
@@ -0,0 +1,37 @@
+/* Map thread ID to thread handle.
+ Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 "thread_dbP.h"
+
+
+td_err_e
+td_ta_map_id2thr (const td_thragent_t *ta, pthread_t pt, td_thrhandle_t *th)
+{
+ LOG ("td_ta_map_id2thr");
+
+ /* Test whether the TA parameter is ok. */
+ if (! ta_ok (ta))
+ return TD_BADTA;
+
+ /* Create the `td_thrhandle_t' object. */
+ th->th_ta_p = (td_thragent_t *) ta;
+ th->th_unique = (psaddr_t) pt;
+
+ return TD_OK;
+}
diff --git a/libpthread/nptl_db/td_ta_map_lwp2thr.c b/libpthread/nptl_db/td_ta_map_lwp2thr.c
new file mode 100644
index 000000000..6b4382fbd
--- /dev/null
+++ b/libpthread/nptl_db/td_ta_map_lwp2thr.c
@@ -0,0 +1,208 @@
+/* Which thread is running on an LWP?
+ Copyright (C) 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
+ 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 "thread_dbP.h"
+#include <stdlib.h>
+#include <byteswap.h>
+#include <sys/procfs.h>
+
+
+td_err_e
+__td_ta_lookup_th_unique (const td_thragent_t *ta_arg,
+ lwpid_t lwpid, td_thrhandle_t *th)
+{
+ td_thragent_t *const ta = (td_thragent_t *) ta_arg;
+ ps_err_e err;
+ td_err_e terr;
+ prgregset_t regs;
+ psaddr_t addr;
+
+ LOG ("td_ta_map_lwp2thr");
+
+ /* Test whether the TA parameter is ok. */
+ if (! ta_ok (ta))
+ return TD_BADTA;
+
+ if (ta->ta_howto == ta_howto_unknown)
+ {
+ /* We need to read in from the inferior the instructions what to do. */
+ psaddr_t howto;
+
+ err = td_lookup (ta->ph, SYM_TH_UNIQUE_CONST_THREAD_AREA, &howto);
+ if (err == PS_OK)
+ {
+ err = ps_pdread (ta->ph, howto,
+ &ta->ta_howto_data.const_thread_area,
+ sizeof ta->ta_howto_data.const_thread_area);
+ if (err != PS_OK)
+ return TD_ERR;
+ ta->ta_howto = ta_howto_const_thread_area;
+ if (ta->ta_howto_data.const_thread_area & 0xff000000U)
+ ta->ta_howto_data.const_thread_area
+ = bswap_32 (ta->ta_howto_data.const_thread_area);
+ }
+ else
+ {
+ switch (sizeof (regs[0]))
+ {
+ case 8:
+ err = td_lookup (ta->ph, SYM_TH_UNIQUE_REGISTER64, &howto);
+ if (err == PS_OK)
+ ta->ta_howto = ta_howto_reg;
+ else if (err == PS_NOSYM)
+ {
+ err = td_lookup (ta->ph,
+ SYM_TH_UNIQUE_REGISTER64_THREAD_AREA,
+ &howto);
+ if (err == PS_OK)
+ ta->ta_howto = ta_howto_reg_thread_area;
+ }
+ break;
+
+ case 4:
+ err = td_lookup (ta->ph, SYM_TH_UNIQUE_REGISTER32, &howto);
+ if (err == PS_OK)
+ ta->ta_howto = ta_howto_reg;
+ else if (err == PS_NOSYM)
+ {
+ err = td_lookup (ta->ph,
+ SYM_TH_UNIQUE_REGISTER32_THREAD_AREA,
+ &howto);
+ if (err == PS_OK)
+ ta->ta_howto = ta_howto_reg_thread_area;
+ }
+ break;
+
+ default:
+ abort ();
+ return TD_DBERR;
+ }
+
+ if (err != PS_OK)
+ return TD_DBERR;
+
+ /* For either of these methods we read in the same descriptor. */
+ err = ps_pdread (ta->ph, howto,
+ ta->ta_howto_data.reg, DB_SIZEOF_DESC);
+ if (err != PS_OK)
+ return TD_ERR;
+ if (DB_DESC_SIZE (ta->ta_howto_data.reg) == 0)
+ return TD_DBERR;
+ if (DB_DESC_SIZE (ta->ta_howto_data.reg) & 0xff000000U)
+ {
+ /* Byte-swap these words, though we leave the size word
+ in native order as the handy way to distinguish. */
+ DB_DESC_OFFSET (ta->ta_howto_data.reg)
+ = bswap_32 (DB_DESC_OFFSET (ta->ta_howto_data.reg));
+ DB_DESC_NELEM (ta->ta_howto_data.reg)
+ = bswap_32 (DB_DESC_NELEM (ta->ta_howto_data.reg));
+ }
+ }
+ }
+
+ switch (ta->ta_howto)
+ {
+ default:
+ return TD_DBERR;
+
+ case ta_howto_reg:
+ /* On most machines, we are just looking at a register. */
+ if (ps_lgetregs (ta->ph, lwpid, regs) != PS_OK)
+ return TD_ERR;
+ terr = _td_fetch_value_local (ta, ta->ta_howto_data.reg, -1,
+ 0, regs, &addr);
+ if (terr != TD_OK)
+ return terr;
+
+ /* In this descriptor the nelem word is overloaded as the bias. */
+ addr += (int32_t) DB_DESC_NELEM (ta->ta_howto_data.reg);
+ th->th_unique = addr;
+ break;
+
+ case ta_howto_const_thread_area:
+ /* Some hosts don't have this call and this case won't be used. */
+# pragma weak ps_get_thread_area
+ if (&ps_get_thread_area == NULL)
+ return TD_NOCAPAB;
+
+ /* A la x86-64, there is a magic index for get_thread_area. */
+ if (ps_get_thread_area (ta->ph, lwpid,
+ ta->ta_howto_data.const_thread_area,
+ &th->th_unique) != PS_OK)
+ return TD_ERR; /* XXX Other error value? */
+ break;
+
+ case ta_howto_reg_thread_area:
+ if (&ps_get_thread_area == NULL)
+ return TD_NOCAPAB;
+
+ /* A la i386, a register holds the index for get_thread_area. */
+ if (ps_lgetregs (ta->ph, lwpid, regs) != PS_OK)
+ return TD_ERR;
+ terr = _td_fetch_value_local (ta, ta->ta_howto_data.reg_thread_area,
+ -1, 0, regs, &addr);
+ if (terr != TD_OK)
+ return terr;
+ /* In this descriptor the nelem word is overloaded as scale factor. */
+ if (ps_get_thread_area
+ (ta->ph, lwpid,
+ ((addr - (psaddr_t) 0)
+ >> DB_DESC_NELEM (ta->ta_howto_data.reg_thread_area)),
+ &th->th_unique) != PS_OK)
+ return TD_ERR; /* XXX Other error value? */
+ break;
+ }
+
+ /* Found it. Now complete the `td_thrhandle_t' object. */
+ th->th_ta_p = ta;
+
+ return TD_OK;
+}
+
+td_err_e
+td_ta_map_lwp2thr (const td_thragent_t *ta_arg,
+ lwpid_t lwpid, td_thrhandle_t *th)
+{
+ td_thragent_t *const ta = (td_thragent_t *) ta_arg;
+
+ /* We cannot rely on thread registers and such information at all
+ before __pthread_initialize_minimal has gotten far enough. They
+ sometimes contain garbage that would confuse us, left by the kernel
+ at exec. So if it looks like initialization is incomplete, we only
+ fake a special descriptor for the initial thread. */
+
+ psaddr_t list;
+ td_err_e err = DB_GET_SYMBOL (list, ta, __stack_user);
+ if (err != TD_OK)
+ return err;
+
+ err = DB_GET_FIELD (list, ta, list, list_t, next, 0);
+ if (err != TD_OK)
+ return err;
+
+ if (list == 0)
+ {
+ if (ps_getpid (ta->ph) != lwpid)
+ return TD_ERR;
+ th->th_ta_p = ta;
+ th->th_unique = 0;
+ return TD_OK;
+ }
+
+ return __td_ta_lookup_th_unique (ta_arg, lwpid, th);
+}
diff --git a/libpthread/nptl_db/td_ta_new.c b/libpthread/nptl_db/td_ta_new.c
new file mode 100644
index 000000000..1c0d942c1
--- /dev/null
+++ b/libpthread/nptl_db/td_ta_new.c
@@ -0,0 +1,64 @@
+/* Attach to target process.
+ Copyright (C) 1999,2001,2002,2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <version.h>
+
+#include "thread_dbP.h"
+
+
+/* Datatype for the list of known thread agents. Normally there will
+ be exactly one so we don't spend much though on making it fast. */
+LIST_HEAD (__td_agent_list);
+
+
+td_err_e
+td_ta_new (struct ps_prochandle *ps, td_thragent_t **ta)
+{
+ psaddr_t versaddr;
+ char versbuf[sizeof (VERSION)];
+
+ LOG ("td_ta_new");
+
+ /* Check whether the versions match. */
+ if (td_lookup (ps, SYM_nptl_version, &versaddr) != PS_OK)
+ return TD_NOLIBTHREAD;
+ if (ps_pdread (ps, versaddr, versbuf, sizeof (versbuf)) != PS_OK)
+ return TD_ERR;
+
+ if (memcmp (versbuf, VERSION, sizeof VERSION) != 0)
+ /* Not the right version. */
+ return TD_VERSION;
+
+ /* Fill in the appropriate information. */
+ *ta = (td_thragent_t *) calloc (1, sizeof (td_thragent_t));
+ if (*ta == NULL)
+ return TD_MALLOC;
+
+ /* Store the proc handle which we will pass to the callback functions
+ back into the debugger. */
+ (*ta)->ph = ps;
+
+ /* Now add the new agent descriptor to the list. */
+ list_add (&(*ta)->list, &__td_agent_list);
+
+ return TD_OK;
+}
diff --git a/libpthread/nptl_db/td_ta_reset_stats.c b/libpthread/nptl_db/td_ta_reset_stats.c
new file mode 100644
index 000000000..69a626f4d
--- /dev/null
+++ b/libpthread/nptl_db/td_ta_reset_stats.c
@@ -0,0 +1,34 @@
+/* Reset statistics.
+ Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 "thread_dbP.h"
+
+
+td_err_e
+td_ta_reset_stats (const td_thragent_t *ta)
+{
+ /* XXX We have to figure out what has to be done. */
+ LOG ("td_ta_reset_stats");
+
+ /* Test whether the TA parameter is ok. */
+ if (! ta_ok (ta))
+ return TD_BADTA;
+
+ return TD_OK;
+}
diff --git a/libpthread/nptl_db/td_ta_set_event.c b/libpthread/nptl_db/td_ta_set_event.c
new file mode 100644
index 000000000..940b34725
--- /dev/null
+++ b/libpthread/nptl_db/td_ta_set_event.c
@@ -0,0 +1,76 @@
+/* Globally enable events.
+ Copyright (C) 1999,2001,2002,2003,2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 "thread_dbP.h"
+
+
+td_err_e
+td_ta_set_event (const td_thragent_t *ta_arg, td_thr_events_t *event)
+{
+ td_thragent_t *const ta = (td_thragent_t *) ta_arg;
+ td_err_e err;
+ psaddr_t eventmask = 0;
+ void *copy = NULL;
+
+ LOG ("td_ta_set_event");
+
+ /* Test whether the TA parameter is ok. */
+ if (! ta_ok (ta))
+ return TD_BADTA;
+
+ /* Fetch the old event mask from the inferior and modify it in place. */
+ err = DB_GET_SYMBOL (eventmask, ta, __nptl_threads_events);
+ if (err == TD_OK)
+ err = DB_GET_STRUCT (copy, ta, eventmask, td_thr_events_t);
+ if (err == TD_OK)
+ {
+ uint32_t idx;
+ for (idx = 0; idx < TD_EVENTSIZE; ++idx)
+ {
+ psaddr_t word;
+ uint32_t mask;
+ err = DB_GET_FIELD_LOCAL (word, ta, copy,
+ td_thr_events_t, event_bits, idx);
+ if (err != TD_OK)
+ break;
+ mask = (uintptr_t) word;
+ mask |= event->event_bits[idx];
+ word = (psaddr_t) (uintptr_t) mask;
+ err = DB_PUT_FIELD_LOCAL (ta, copy,
+ td_thr_events_t, event_bits, idx, word);
+ if (err != TD_OK)
+ break;
+ }
+ if (err == TD_NOAPLIC)
+ {
+ err = TD_OK;
+ while (idx < TD_EVENTSIZE)
+ if (event->event_bits[idx++] != 0)
+ {
+ err = TD_NOEVENT;
+ break;
+ }
+ }
+ if (err == TD_OK)
+ /* Now write it back to the inferior. */
+ err = DB_PUT_STRUCT (ta, eventmask, td_thr_events_t, copy);
+ }
+
+ return err;
+}
diff --git a/libpthread/nptl_db/td_ta_setconcurrency.c b/libpthread/nptl_db/td_ta_setconcurrency.c
new file mode 100644
index 000000000..29799a368
--- /dev/null
+++ b/libpthread/nptl_db/td_ta_setconcurrency.c
@@ -0,0 +1,34 @@
+/* Set suggested concurrency level for process.
+ Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 "thread_dbP.h"
+
+
+td_err_e
+td_ta_setconcurrency (const td_thragent_t *ta, int level)
+{
+ /* This is something LinuxThreads does not need to support. */
+ LOG ("td_ta_setconcurrency");
+
+ /* Test whether the TA parameter is ok. */
+ if (! ta_ok (ta))
+ return TD_BADTA;
+
+ return TD_NOCAPAB;
+}
diff --git a/libpthread/nptl_db/td_ta_thr_iter.c b/libpthread/nptl_db/td_ta_thr_iter.c
new file mode 100644
index 000000000..0f1b2bfd2
--- /dev/null
+++ b/libpthread/nptl_db/td_ta_thr_iter.c
@@ -0,0 +1,150 @@
+/* Iterate over a process's threads.
+ Copyright (C) 1999,2000,2001,2002,2003,2004,2007
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 "thread_dbP.h"
+
+
+static td_err_e
+iterate_thread_list (td_thragent_t *ta, td_thr_iter_f *callback,
+ void *cbdata_p, td_thr_state_e state, int ti_pri,
+ psaddr_t head, bool fake_empty)
+{
+ td_err_e err;
+ psaddr_t next, ofs;
+ void *copy;
+
+ /* Test the state.
+ XXX This is incomplete. Normally this test should be in the loop. */
+ if (state != TD_THR_ANY_STATE)
+ return TD_OK;
+
+ err = DB_GET_FIELD (next, ta, head, list_t, next, 0);
+ if (err != TD_OK)
+ return err;
+
+ if (next == 0 && fake_empty)
+ {
+ /* __pthread_initialize_minimal has not run. There is just the main
+ thread to return. We cannot rely on its thread register. They
+ sometimes contain garbage that would confuse us, left by the
+ kernel at exec. So if it looks like initialization is incomplete,
+ we only fake a special descriptor for the initial thread. */
+ td_thrhandle_t th = { ta, 0 };
+ return callback (&th, cbdata_p) != 0 ? TD_DBERR : TD_OK;
+ }
+
+ /* Cache the offset from struct pthread to its list_t member. */
+ err = DB_GET_FIELD_ADDRESS (ofs, ta, 0, pthread, list, 0);
+ if (err != TD_OK)
+ return err;
+
+ if (ta->ta_sizeof_pthread == 0)
+ {
+ err = _td_check_sizeof (ta, &ta->ta_sizeof_pthread, SYM_SIZEOF_pthread);
+ if (err != TD_OK)
+ return err;
+ }
+ copy = __alloca (ta->ta_sizeof_pthread);
+
+ while (next != head)
+ {
+ psaddr_t addr, schedpolicy, schedprio;
+
+ addr = next - (ofs - (psaddr_t) 0);
+ if (next == 0 || addr == 0) /* Sanity check. */
+ return TD_DBERR;
+
+ /* Copy the whole descriptor in once so we can access the several
+ fields locally. Excess copying in one go is much better than
+ multiple ps_pdread calls. */
+ if (ps_pdread (ta->ph, addr, copy, ta->ta_sizeof_pthread) != PS_OK)
+ return TD_ERR;
+
+ err = DB_GET_FIELD_LOCAL (schedpolicy, ta, copy, pthread,
+ schedpolicy, 0);
+ if (err != TD_OK)
+ break;
+ err = DB_GET_FIELD_LOCAL (schedprio, ta, copy, pthread,
+ schedparam_sched_priority, 0);
+ if (err != TD_OK)
+ break;
+
+ /* Now test whether this thread matches the specified conditions. */
+
+ /* Only if the priority level is as high or higher. */
+ int descr_pri = ((uintptr_t) schedpolicy == SCHED_OTHER
+ ? 0 : (uintptr_t) schedprio);
+ if (descr_pri >= ti_pri)
+ {
+ /* Yep, it matches. Call the callback function. */
+ td_thrhandle_t th;
+ th.th_ta_p = (td_thragent_t *) ta;
+ th.th_unique = addr;
+ if (callback (&th, cbdata_p) != 0)
+ return TD_DBERR;
+ }
+
+ /* Get the pointer to the next element. */
+ err = DB_GET_FIELD_LOCAL (next, ta, copy + (ofs - (psaddr_t) 0), list_t,
+ next, 0);
+ if (err != TD_OK)
+ break;
+ }
+
+ return err;
+}
+
+
+td_err_e
+td_ta_thr_iter (const td_thragent_t *ta_arg, td_thr_iter_f *callback,
+ void *cbdata_p, td_thr_state_e state, int ti_pri,
+ sigset_t *ti_sigmask_p, unsigned int ti_user_flags)
+{
+ td_thragent_t *const ta = (td_thragent_t *) ta_arg;
+ td_err_e err;
+ psaddr_t list = 0;
+
+ LOG ("td_ta_thr_iter");
+
+ /* Test whether the TA parameter is ok. */
+ if (! ta_ok (ta))
+ return TD_BADTA;
+
+ /* The thread library keeps two lists for the running threads. One
+ list contains the thread which are using user-provided stacks
+ (this includes the main thread) and the other includes the
+ threads for which the thread library allocated the stacks. We
+ have to iterate over both lists separately. We start with the
+ list of threads with user-defined stacks. */
+
+ err = DB_GET_SYMBOL (list, ta, __stack_user);
+ if (err == TD_OK)
+ err = iterate_thread_list (ta, callback, cbdata_p, state, ti_pri,
+ list, true);
+
+ /* And the threads with stacks allocated by the implementation. */
+ if (err == TD_OK)
+ err = DB_GET_SYMBOL (list, ta, stack_used);
+ if (err == TD_OK)
+ err = iterate_thread_list (ta, callback, cbdata_p, state, ti_pri,
+ list, false);
+
+ return err;
+}
diff --git a/libpthread/nptl_db/td_ta_tsd_iter.c b/libpthread/nptl_db/td_ta_tsd_iter.c
new file mode 100644
index 000000000..767af9adf
--- /dev/null
+++ b/libpthread/nptl_db/td_ta_tsd_iter.c
@@ -0,0 +1,80 @@
+/* Iterate over a process's thread-specific data.
+ Copyright (C) 1999,2000,2001,2002,2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 "thread_dbP.h"
+#include <alloca.h>
+
+td_err_e
+td_ta_tsd_iter (const td_thragent_t *ta_arg, td_key_iter_f *callback,
+ void *cbdata_p)
+{
+ td_thragent_t *const ta = (td_thragent_t *) ta_arg;
+ td_err_e err;
+ void *keys;
+ size_t keys_nb, keys_elemsize;
+ psaddr_t addr;
+ uint32_t idx;
+
+ LOG ("td_ta_tsd_iter");
+
+ /* Test whether the TA parameter is ok. */
+ if (! ta_ok (ta))
+ return TD_BADTA;
+
+ /* This makes sure we have the size information on hand. */
+ addr = 0;
+ err = _td_locate_field (ta,
+ ta->ta_var___pthread_keys, SYM_DESC___pthread_keys,
+ (psaddr_t) 0 + 1, &addr);
+ if (err != TD_OK)
+ return err;
+
+ /* Now copy in the entire array of key descriptors. */
+ keys_elemsize = (addr - (psaddr_t) 0) / 8;
+ keys_nb = keys_elemsize * DB_DESC_NELEM (ta->ta_var___pthread_keys);
+ keys = __alloca (keys_nb);
+ err = DB_GET_SYMBOL (addr, ta, __pthread_keys);
+ if (err != TD_OK)
+ return err;
+ if (ps_pdread (ta->ph, addr, keys, keys_nb) != PS_OK)
+ return TD_ERR;
+
+ /* Now get all descriptors, one after the other. */
+ for (idx = 0; idx < DB_DESC_NELEM (ta->ta_var___pthread_keys); ++idx)
+ {
+ psaddr_t seq, destr;
+ err = DB_GET_FIELD_LOCAL (seq, ta, keys, pthread_key_struct, seq, 0);
+ if (err != TD_OK)
+ return err;
+ if (((uintptr_t) seq) & 1)
+ {
+ err = DB_GET_FIELD_LOCAL (destr, ta, keys, pthread_key_struct,
+ destr, 0);
+ if (err != TD_OK)
+ return err;
+ /* Return with an error if the callback returns a nonzero value. */
+ if (callback ((thread_key_t) idx, destr, cbdata_p) != 0)
+ return TD_DBERR;
+ }
+ /* Advance to the next element in the copied array. */
+ keys += keys_elemsize;
+ }
+
+ return TD_OK;
+}
diff --git a/libpthread/nptl_db/td_thr_clear_event.c b/libpthread/nptl_db/td_thr_clear_event.c
new file mode 100644
index 000000000..73d9aa43a
--- /dev/null
+++ b/libpthread/nptl_db/td_thr_clear_event.c
@@ -0,0 +1,74 @@
+/* Disable specific event for thread.
+ Copyright (C) 1999,2001,2002,2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 <stddef.h>
+
+#include "thread_dbP.h"
+
+
+td_err_e
+td_thr_clear_event (const td_thrhandle_t *th, td_thr_events_t *event)
+{
+ td_err_e err;
+ psaddr_t eventmask;
+ void *copy = NULL;
+
+ LOG ("td_thr_clear_event");
+
+ /* Fetch the old event mask from the inferior and modify it in place. */
+ err = DB_GET_FIELD_ADDRESS (eventmask, th->th_ta_p,
+ th->th_unique, pthread, eventbuf_eventmask, 0);
+ if (err == TD_OK)
+ err = DB_GET_STRUCT (copy, th->th_ta_p, eventmask, td_thr_events_t);
+ if (err == TD_OK)
+ {
+ uint32_t idx;
+ for (idx = 0; idx < TD_EVENTSIZE; ++idx)
+ {
+ psaddr_t word;
+ uint32_t mask;
+ err = DB_GET_FIELD_LOCAL (word, th->th_ta_p, copy,
+ td_thr_events_t, event_bits, idx);
+ if (err != TD_OK)
+ break;
+ mask = (uintptr_t) word;
+ mask &= ~event->event_bits[idx];
+ word = (psaddr_t) (uintptr_t) mask;
+ err = DB_PUT_FIELD_LOCAL (th->th_ta_p, copy,
+ td_thr_events_t, event_bits, idx, word);
+ if (err != TD_OK)
+ break;
+ }
+ if (err == TD_NOAPLIC)
+ {
+ err = TD_OK;
+ while (idx < TD_EVENTSIZE)
+ if (event->event_bits[idx++] != 0)
+ {
+ err = TD_NOEVENT;
+ break;
+ }
+ }
+ if (err == TD_OK)
+ /* Now write it back to the inferior. */
+ err = DB_PUT_STRUCT (th->th_ta_p, eventmask, td_thr_events_t, copy);
+ }
+
+ return err;
+}
diff --git a/libpthread/nptl_db/td_thr_dbresume.c b/libpthread/nptl_db/td_thr_dbresume.c
new file mode 100644
index 000000000..f42a0af57
--- /dev/null
+++ b/libpthread/nptl_db/td_thr_dbresume.c
@@ -0,0 +1,29 @@
+/* Resume execution of given thread.
+ Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 "thread_dbP.h"
+
+
+td_err_e
+td_thr_dbresume (const td_thrhandle_t *th)
+{
+ /* XXX We have to figure out what has to be done. */
+ LOG ("td_thr_dbresume");
+ return TD_NOCAPAB;
+}
diff --git a/libpthread/nptl_db/td_thr_dbsuspend.c b/libpthread/nptl_db/td_thr_dbsuspend.c
new file mode 100644
index 000000000..b504fa583
--- /dev/null
+++ b/libpthread/nptl_db/td_thr_dbsuspend.c
@@ -0,0 +1,29 @@
+/* Suspend execution of given thread.
+ Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 "thread_dbP.h"
+
+
+td_err_e
+td_thr_dbsuspend (const td_thrhandle_t *th)
+{
+ /* XXX We have to figure out what has to be done. */
+ LOG ("td_thr_dbsuspend");
+ return TD_NOCAPAB;
+}
diff --git a/libpthread/nptl_db/td_thr_event_enable.c b/libpthread/nptl_db/td_thr_event_enable.c
new file mode 100644
index 000000000..fd9458011
--- /dev/null
+++ b/libpthread/nptl_db/td_thr_event_enable.c
@@ -0,0 +1,49 @@
+/* Enable event process-wide.
+ Copyright (C) 1999, 2001, 2002, 2003, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 "thread_dbP.h"
+
+
+td_err_e
+td_thr_event_enable (const td_thrhandle_t *th, int onoff)
+{
+ LOG ("td_thr_event_enable");
+
+ if (th->th_unique != 0)
+ {
+ /* Write the new value into the thread data structure. */
+ td_err_e err = DB_PUT_FIELD (th->th_ta_p, th->th_unique, pthread,
+ report_events, 0,
+ (psaddr_t) 0 + (onoff != 0));
+ if (err != TD_OK)
+ return err;
+
+ /* Just in case we are in the window between initializing __stack_user
+ and copying from __nptl_initial_report_events, we set it too.
+ It doesn't hurt to do this for non-initial threads, since it
+ won't be consulted again anyway. It would take another fetch
+ to get the tid and determine this isn't the initial thread,
+ so just do it always. */
+ }
+
+ /* We are faking it for the initial thread before its thread
+ descriptor is set up. */
+ return DB_PUT_VALUE (th->th_ta_p, __nptl_initial_report_events, 0,
+ (psaddr_t) 0 + (onoff != 0));
+}
diff --git a/libpthread/nptl_db/td_thr_event_getmsg.c b/libpthread/nptl_db/td_thr_event_getmsg.c
new file mode 100644
index 000000000..dab85e70d
--- /dev/null
+++ b/libpthread/nptl_db/td_thr_event_getmsg.c
@@ -0,0 +1,118 @@
+/* Retrieve event.
+ Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 "thread_dbP.h"
+#include <assert.h>
+
+
+td_err_e
+td_thr_event_getmsg (const td_thrhandle_t *th, td_event_msg_t *msg)
+{
+ td_err_e err;
+ psaddr_t eventbuf, eventnum, eventdata;
+ psaddr_t thp, prevp;
+ void *copy = NULL;
+
+ LOG ("td_thr_event_getmsg");
+
+ /* Copy the event message buffer in from the inferior. */
+ err = DB_GET_FIELD_ADDRESS (eventbuf, th->th_ta_p, th->th_unique, pthread,
+ eventbuf, 0);
+ if (err == TD_OK)
+ err = DB_GET_STRUCT (copy, th->th_ta_p, eventbuf, td_eventbuf_t);
+ if (err != TD_OK)
+ return err;
+
+ /* Check whether an event occurred. */
+ err = DB_GET_FIELD_LOCAL (eventnum, th->th_ta_p, copy,
+ td_eventbuf_t, eventnum, 0);
+ if (err != TD_OK)
+ return err;
+ if ((int) (uintptr_t) eventnum == TD_EVENT_NONE)
+ /* Nothing. */
+ return TD_NOMSG;
+
+ /* Fill the user's data structure. */
+ err = DB_GET_FIELD_LOCAL (eventdata, th->th_ta_p, copy,
+ td_eventbuf_t, eventdata, 0);
+ if (err != TD_OK)
+ return err;
+
+ msg->msg.data = (uintptr_t) eventdata;
+ msg->event = (uintptr_t) eventnum;
+ msg->th_p = th;
+
+ /* And clear the event message in the target. */
+ memset (copy, 0, th->th_ta_p->ta_sizeof_td_eventbuf_t);
+ err = DB_PUT_STRUCT (th->th_ta_p, eventbuf, td_eventbuf_t, copy);
+ if (err != TD_OK)
+ return err;
+
+ /* Get the pointer to the thread descriptor with the last event.
+ If it doesn't match TH, then walk down the list until we find it.
+ We must splice it out of the list so that there is no dangling
+ pointer to it later when it dies. */
+ err = DB_GET_SYMBOL (prevp, th->th_ta_p, __nptl_last_event);
+ if (err != TD_OK)
+ return err;
+ err = DB_GET_VALUE (thp, th->th_ta_p, __nptl_last_event, 0);
+ if (err != TD_OK)
+ return err;
+
+ while (thp != 0)
+ {
+ psaddr_t next;
+ err = DB_GET_FIELD (next, th->th_ta_p, th->th_unique, pthread,
+ nextevent, 0);
+ if (err != TD_OK)
+ return err;
+
+ if (next == thp)
+ return TD_DBERR;
+
+ if (thp == th->th_unique)
+ {
+ /* PREVP points at this thread, splice it out. */
+ psaddr_t next_nextp;
+ err = DB_GET_FIELD_ADDRESS (next_nextp, th->th_ta_p, next, pthread,
+ nextevent, 0);
+ assert (err == TD_OK); /* We used this field before. */
+ if (prevp == next_nextp)
+ return TD_DBERR;
+
+ err = _td_store_value (th->th_ta_p,
+ th->th_ta_p->ta_var___nptl_last_event, -1,
+ 0, prevp, next);
+ if (err != TD_OK)
+ return err;
+
+ /* Now clear this thread's own next pointer so it's not dangling
+ when the thread resumes and then chains on for its next event. */
+ return DB_PUT_FIELD (th->th_ta_p, thp, pthread, nextevent, 0, 0);
+ }
+
+ err = DB_GET_FIELD_ADDRESS (prevp, th->th_ta_p, thp, pthread,
+ nextevent, 0);
+ assert (err == TD_OK); /* We used this field before. */
+ thp = next;
+ }
+
+ /* Ack! This should not happen. */
+ return TD_DBERR;
+}
diff --git a/libpthread/nptl_db/td_thr_get_info.c b/libpthread/nptl_db/td_thr_get_info.c
new file mode 100644
index 000000000..27d5d706b
--- /dev/null
+++ b/libpthread/nptl_db/td_thr_get_info.c
@@ -0,0 +1,124 @@
+/* Get thread information.
+ Copyright (C) 1999,2000,2001,2002,2003,2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 <stddef.h>
+#include <string.h>
+#include "thread_dbP.h"
+
+
+td_err_e
+td_thr_get_info (const td_thrhandle_t *th, td_thrinfo_t *infop)
+{
+ td_err_e err;
+ void *copy;
+ psaddr_t tls, schedpolicy, schedprio, cancelhandling, tid, report_events;
+
+ LOG ("td_thr_get_info");
+
+ if (th->th_unique == 0)
+ {
+ /* Special case for the main thread before initialization. */
+ copy = NULL;
+ tls = 0;
+ cancelhandling = 0;
+ schedprio = 0;
+ tid = 0;
+ err = DB_GET_VALUE (report_events, th->th_ta_p,
+ __nptl_initial_report_events, 0);
+ }
+ else
+ {
+ /* Copy the whole descriptor in once so we can access the several
+ fields locally. Excess copying in one go is much better than
+ multiple ps_pdread calls. */
+ err = DB_GET_STRUCT (copy, th->th_ta_p, th->th_unique, pthread);
+ if (err != TD_OK)
+ return err;
+
+ err = DB_GET_FIELD_ADDRESS (tls, th->th_ta_p, th->th_unique,
+ pthread, specific, 0);
+ if (err != TD_OK)
+ return err;
+
+ err = DB_GET_FIELD_LOCAL (schedpolicy, th->th_ta_p, copy, pthread,
+ schedpolicy, 0);
+ if (err != TD_OK)
+ return err;
+ err = DB_GET_FIELD_LOCAL (schedprio, th->th_ta_p, copy, pthread,
+ schedparam_sched_priority, 0);
+ if (err != TD_OK)
+ return err;
+ err = DB_GET_FIELD_LOCAL (tid, th->th_ta_p, copy, pthread, tid, 0);
+ if (err != TD_OK)
+ return err;
+ err = DB_GET_FIELD_LOCAL (cancelhandling, th->th_ta_p, copy, pthread,
+ cancelhandling, 0);
+ if (err != TD_OK)
+ return err;
+ err = DB_GET_FIELD_LOCAL (report_events, th->th_ta_p, copy, pthread,
+ report_events, 0);
+ }
+ if (err != TD_OK)
+ return err;
+
+ /* Fill in information. Clear first to provide reproducable
+ results for the fields we do not fill in. */
+ memset (infop, '\0', sizeof (td_thrinfo_t));
+
+ infop->ti_tid = (thread_t) th->th_unique;
+ infop->ti_tls = (char *) tls;
+ infop->ti_pri = ((uintptr_t) schedpolicy == SCHED_OTHER
+ ? 0 : (uintptr_t) schedprio);
+ infop->ti_type = TD_THR_USER;
+
+ if ((((int) (uintptr_t) cancelhandling) & EXITING_BITMASK) == 0)
+ /* XXX For now there is no way to get more information. */
+ infop->ti_state = TD_THR_ACTIVE;
+ else if ((((int) (uintptr_t) cancelhandling) & TERMINATED_BITMASK) == 0)
+ infop->ti_state = TD_THR_ZOMBIE;
+ else
+ infop->ti_state = TD_THR_UNKNOWN;
+
+ /* Initialization which are the same in both cases. */
+ infop->ti_ta_p = th->th_ta_p;
+ infop->ti_lid = tid == 0 ? ps_getpid (th->th_ta_p->ph) : (uintptr_t) tid;
+ infop->ti_traceme = report_events != 0;
+
+ if (copy != NULL)
+ err = DB_GET_FIELD_LOCAL (infop->ti_startfunc, th->th_ta_p, copy, pthread,
+ start_routine, 0);
+ if (copy != NULL && err == TD_OK)
+ {
+ uint32_t idx;
+ for (idx = 0; idx < TD_EVENTSIZE; ++idx)
+ {
+ psaddr_t word;
+ err = DB_GET_FIELD_LOCAL (word, th->th_ta_p, copy, pthread,
+ eventbuf_eventmask_event_bits, idx);
+ if (err != TD_OK)
+ break;
+ infop->ti_events.event_bits[idx] = (uintptr_t) word;
+ }
+ if (err == TD_NOAPLIC)
+ memset (&infop->ti_events.event_bits[idx], 0,
+ (TD_EVENTSIZE - idx) * sizeof infop->ti_events.event_bits[0]);
+ }
+
+ return err;
+}
diff --git a/libpthread/nptl_db/td_thr_getfpregs.c b/libpthread/nptl_db/td_thr_getfpregs.c
new file mode 100644
index 000000000..4f4742a3e
--- /dev/null
+++ b/libpthread/nptl_db/td_thr_getfpregs.c
@@ -0,0 +1,57 @@
+/* Get a thread's floating-point register set.
+ Copyright (C) 1999, 2001, 2002, 2003, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 "thread_dbP.h"
+
+
+td_err_e
+td_thr_getfpregs (const td_thrhandle_t *th, prfpregset_t *regset)
+{
+ psaddr_t cancelhandling, tid;
+ td_err_e err;
+
+ LOG ("td_thr_getfpregs");
+
+ if (th->th_unique == 0)
+ /* Special case for the main thread before initialization. */
+ return ps_lgetfpregs (th->th_ta_p->ph, ps_getpid (th->th_ta_p->ph),
+ regset) != PS_OK ? TD_ERR : TD_OK;
+
+ /* We have to get the state and the PID for this thread. */
+ err = DB_GET_FIELD (cancelhandling, th->th_ta_p, th->th_unique, pthread,
+ cancelhandling, 0);
+ if (err != TD_OK)
+ return err;
+
+ /* If the thread already terminated we return all zeroes. */
+ if (((int) (uintptr_t) cancelhandling) & TERMINATED_BITMASK)
+ memset (regset, '\0', sizeof (*regset));
+ /* Otherwise get the register content through the callback. */
+ else
+ {
+ err = DB_GET_FIELD (tid, th->th_ta_p, th->th_unique, pthread, tid, 0);
+ if (err != TD_OK)
+ return err;
+
+ if (ps_lgetfpregs (th->th_ta_p->ph, (uintptr_t) tid, regset) != PS_OK)
+ return TD_ERR;
+ }
+
+ return TD_OK;
+}
diff --git a/libpthread/nptl_db/td_thr_getgregs.c b/libpthread/nptl_db/td_thr_getgregs.c
new file mode 100644
index 000000000..d5f0f61a8
--- /dev/null
+++ b/libpthread/nptl_db/td_thr_getgregs.c
@@ -0,0 +1,57 @@
+/* Get a thread's general register set.
+ Copyright (C) 1999, 2000, 2001, 2002, 2003, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 "thread_dbP.h"
+
+
+td_err_e
+td_thr_getgregs (const td_thrhandle_t *th, prgregset_t regset)
+{
+ psaddr_t cancelhandling, tid;
+ td_err_e err;
+
+ LOG ("td_thr_getgregs");
+
+ if (th->th_unique == 0)
+ /* Special case for the main thread before initialization. */
+ return ps_lgetregs (th->th_ta_p->ph, ps_getpid (th->th_ta_p->ph),
+ regset) != PS_OK ? TD_ERR : TD_OK;
+
+ /* We have to get the state and the PID for this thread. */
+ err = DB_GET_FIELD (cancelhandling, th->th_ta_p, th->th_unique, pthread,
+ cancelhandling, 0);
+ if (err != TD_OK)
+ return err;
+
+ /* If the thread already terminated we return all zeroes. */
+ if (((int) (uintptr_t) cancelhandling) & TERMINATED_BITMASK)
+ memset (regset, '\0', sizeof (*regset));
+ /* Otherwise get the register content through the callback. */
+ else
+ {
+ err = DB_GET_FIELD (tid, th->th_ta_p, th->th_unique, pthread, tid, 0);
+ if (err != TD_OK)
+ return err;
+
+ if (ps_lgetregs (th->th_ta_p->ph, (uintptr_t) tid, regset) != PS_OK)
+ return TD_ERR;
+ }
+
+ return TD_OK;
+}
diff --git a/libpthread/nptl_db/td_thr_getxregs.c b/libpthread/nptl_db/td_thr_getxregs.c
new file mode 100644
index 000000000..fedb6f757
--- /dev/null
+++ b/libpthread/nptl_db/td_thr_getxregs.c
@@ -0,0 +1,29 @@
+/* Get a thread's extra state register set.
+ Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 "thread_dbP.h"
+
+
+td_err_e
+td_thr_getxregs (const td_thrhandle_t *th, void *xregs)
+{
+ /* XXX This might be platform specific. */
+ LOG ("td_thr_getxregs");
+ return TD_NOXREGS;
+}
diff --git a/libpthread/nptl_db/td_thr_getxregsize.c b/libpthread/nptl_db/td_thr_getxregsize.c
new file mode 100644
index 000000000..f8acd65f8
--- /dev/null
+++ b/libpthread/nptl_db/td_thr_getxregsize.c
@@ -0,0 +1,29 @@
+/* Get the size of the extra state register set for this architecture.
+ Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 "thread_dbP.h"
+
+
+td_err_e
+td_thr_getxregsize (const td_thrhandle_t *th, int *sizep)
+{
+ /* XXX This might be platform specific. */
+ LOG ("td_thr_getxregsize");
+ return TD_NOXREGS;
+}
diff --git a/libpthread/nptl_db/td_thr_set_event.c b/libpthread/nptl_db/td_thr_set_event.c
new file mode 100644
index 000000000..e62a0e0bd
--- /dev/null
+++ b/libpthread/nptl_db/td_thr_set_event.c
@@ -0,0 +1,74 @@
+/* Enable specific event for thread.
+ Copyright (C) 1999,2001,2002,2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 <stddef.h>
+
+#include "thread_dbP.h"
+
+
+td_err_e
+td_thr_set_event (const td_thrhandle_t *th, td_thr_events_t *event)
+{
+ td_err_e err;
+ psaddr_t eventmask;
+ void *copy = NULL;
+
+ LOG ("td_thr_set_event");
+
+ /* Fetch the old event mask from the inferior and modify it in place. */
+ err = DB_GET_FIELD_ADDRESS (eventmask, th->th_ta_p,
+ th->th_unique, pthread, eventbuf_eventmask, 0);
+ if (err == TD_OK)
+ err = DB_GET_STRUCT (copy, th->th_ta_p, eventmask, td_thr_events_t);
+ if (err == TD_OK)
+ {
+ uint32_t idx;
+ for (idx = 0; idx < TD_EVENTSIZE; ++idx)
+ {
+ psaddr_t word;
+ uint32_t mask;
+ err = DB_GET_FIELD_LOCAL (word, th->th_ta_p, copy,
+ td_thr_events_t, event_bits, idx);
+ if (err != TD_OK)
+ break;
+ mask = (uintptr_t) word;
+ mask |= event->event_bits[idx];
+ word = (psaddr_t) (uintptr_t) mask;
+ err = DB_PUT_FIELD_LOCAL (th->th_ta_p, copy,
+ td_thr_events_t, event_bits, idx, word);
+ if (err != TD_OK)
+ break;
+ }
+ if (err == TD_NOAPLIC)
+ {
+ err = TD_OK;
+ while (idx < TD_EVENTSIZE)
+ if (event->event_bits[idx++] != 0)
+ {
+ err = TD_NOEVENT;
+ break;
+ }
+ }
+ if (err == TD_OK)
+ /* Now write it back to the inferior. */
+ err = DB_PUT_STRUCT (th->th_ta_p, eventmask, td_thr_events_t, copy);
+ }
+
+ return err;
+}
diff --git a/libpthread/nptl_db/td_thr_setfpregs.c b/libpthread/nptl_db/td_thr_setfpregs.c
new file mode 100644
index 000000000..3154953fe
--- /dev/null
+++ b/libpthread/nptl_db/td_thr_setfpregs.c
@@ -0,0 +1,54 @@
+/* Set a thread's floating-point register set.
+ Copyright (C) 1999, 2001, 2002, 2003, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 "thread_dbP.h"
+
+
+td_err_e
+td_thr_setfpregs (const td_thrhandle_t *th, const prfpregset_t *fpregs)
+{
+ psaddr_t cancelhandling, tid;
+ td_err_e err;
+
+ LOG ("td_thr_setfpregs");
+
+ if (th->th_unique == 0)
+ /* Special case for the main thread before initialization. */
+ return ps_lsetfpregs (th->th_ta_p->ph, ps_getpid (th->th_ta_p->ph),
+ fpregs) != PS_OK ? TD_ERR : TD_OK;
+
+ /* We have to get the state and the PID for this thread. */
+ err = DB_GET_FIELD (cancelhandling, th->th_ta_p, th->th_unique, pthread,
+ cancelhandling, 0);
+ if (err != TD_OK)
+ return err;
+
+ /* Only set the registers if the thread hasn't yet terminated. */
+ if ((((int) (uintptr_t) cancelhandling) & TERMINATED_BITMASK) == 0)
+ {
+ err = DB_GET_FIELD (tid, th->th_ta_p, th->th_unique, pthread, tid, 0);
+ if (err != TD_OK)
+ return err;
+
+ if (ps_lsetfpregs (th->th_ta_p->ph, (uintptr_t) tid, fpregs) != PS_OK)
+ return TD_ERR;
+ }
+
+ return TD_OK;
+}
diff --git a/libpthread/nptl_db/td_thr_setgregs.c b/libpthread/nptl_db/td_thr_setgregs.c
new file mode 100644
index 000000000..5945dea90
--- /dev/null
+++ b/libpthread/nptl_db/td_thr_setgregs.c
@@ -0,0 +1,54 @@
+/* Set a thread's general register set.
+ Copyright (C) 1999, 2001, 2002, 2003, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 "thread_dbP.h"
+
+
+td_err_e
+td_thr_setgregs (const td_thrhandle_t *th, prgregset_t gregs)
+{
+ psaddr_t cancelhandling, tid;
+ td_err_e err;
+
+ LOG ("td_thr_setgregs");
+
+ if (th->th_unique == 0)
+ /* Special case for the main thread before initialization. */
+ return ps_lsetregs (th->th_ta_p->ph, ps_getpid (th->th_ta_p->ph),
+ gregs) != PS_OK ? TD_ERR : TD_OK;
+
+ /* We have to get the state and the PID for this thread. */
+ err = DB_GET_FIELD (cancelhandling, th->th_ta_p, th->th_unique, pthread,
+ cancelhandling, 0);
+ if (err != TD_OK)
+ return err;
+
+ /* Only set the registers if the thread hasn't yet terminated. */
+ if ((((int) (uintptr_t) cancelhandling) & TERMINATED_BITMASK) == 0)
+ {
+ err = DB_GET_FIELD (tid, th->th_ta_p, th->th_unique, pthread, tid, 0);
+ if (err != TD_OK)
+ return err;
+
+ if (ps_lsetregs (th->th_ta_p->ph, tid - (psaddr_t) 0, gregs) != PS_OK)
+ return TD_ERR;
+ }
+
+ return TD_OK;
+}
diff --git a/libpthread/nptl_db/td_thr_setprio.c b/libpthread/nptl_db/td_thr_setprio.c
new file mode 100644
index 000000000..e0ea470df
--- /dev/null
+++ b/libpthread/nptl_db/td_thr_setprio.c
@@ -0,0 +1,29 @@
+/* Set a thread's priority.
+ Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 "thread_dbP.h"
+
+
+td_err_e
+td_thr_setprio (const td_thrhandle_t *th, int prio)
+{
+ /* XXX We have to figure out what has to be done. */
+ LOG ("td_thr_setprio");
+ return TD_OK;
+}
diff --git a/libpthread/nptl_db/td_thr_setsigpending.c b/libpthread/nptl_db/td_thr_setsigpending.c
new file mode 100644
index 000000000..292441641
--- /dev/null
+++ b/libpthread/nptl_db/td_thr_setsigpending.c
@@ -0,0 +1,30 @@
+/* Raise a signal for a thread.
+ Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 "thread_dbP.h"
+
+
+td_err_e
+td_thr_setsigpending (const td_thrhandle_t *th, unsigned char n,
+ const sigset_t *ss)
+{
+ /* XXX We have to figure out what has to be done. */
+ LOG ("td_thr_setsigpending");
+ return TD_OK;
+}
diff --git a/libpthread/nptl_db/td_thr_setxregs.c b/libpthread/nptl_db/td_thr_setxregs.c
new file mode 100644
index 000000000..faff5c9ac
--- /dev/null
+++ b/libpthread/nptl_db/td_thr_setxregs.c
@@ -0,0 +1,29 @@
+/* Set a thread's extra state register set.
+ Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 "thread_dbP.h"
+
+
+td_err_e
+td_thr_setxregs (const td_thrhandle_t *ta, const void *addr)
+{
+ /* XXX This might have to be platform specific. */
+ LOG ("td_thr_setxregs");
+ return TD_NOXREGS;
+}
diff --git a/libpthread/nptl_db/td_thr_sigsetmask.c b/libpthread/nptl_db/td_thr_sigsetmask.c
new file mode 100644
index 000000000..399e38791
--- /dev/null
+++ b/libpthread/nptl_db/td_thr_sigsetmask.c
@@ -0,0 +1,29 @@
+/* Set a thread's signal mask.
+ Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 "thread_dbP.h"
+
+
+td_err_e
+td_thr_sigsetmask (const td_thrhandle_t *th, const sigset_t *ss)
+{
+ /* XXX We have to figure out what has to be done. */
+ LOG ("td_thr_sigsetmask");
+ return TD_OK;
+}
diff --git a/libpthread/nptl_db/td_thr_tls_get_addr.c b/libpthread/nptl_db/td_thr_tls_get_addr.c
new file mode 100644
index 000000000..1f4bc5996
--- /dev/null
+++ b/libpthread/nptl_db/td_thr_tls_get_addr.c
@@ -0,0 +1,42 @@
+/* Get address of thread local variable.
+ Copyright (C) 2002,2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 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 <link.h>
+#include "thread_dbP.h"
+
+td_err_e
+td_thr_tls_get_addr (const td_thrhandle_t *th,
+ psaddr_t map_address, size_t offset, psaddr_t *address)
+{
+ td_err_e err;
+ psaddr_t modid;
+
+ /* Get the TLS module ID from the `struct link_map' in the inferior. */
+ err = DB_GET_FIELD (modid, th->th_ta_p, map_address, link_map,
+ l_tls_modid, 0);
+ if (err == TD_NOCAPAB)
+ return TD_NOAPLIC;
+ if (err == TD_OK)
+ {
+ err = td_thr_tlsbase (th, (uintptr_t) modid, address);
+ if (err == TD_OK)
+ *address += offset;
+ }
+ return err;
+}
diff --git a/libpthread/nptl_db/td_thr_tlsbase.c b/libpthread/nptl_db/td_thr_tlsbase.c
new file mode 100644
index 000000000..9f98bd9ae
--- /dev/null
+++ b/libpthread/nptl_db/td_thr_tlsbase.c
@@ -0,0 +1,75 @@
+/* Locate TLS data for a thread.
+ Copyright (C) 2003, 2006, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ 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 "thread_dbP.h"
+
+td_err_e
+td_thr_tlsbase (const td_thrhandle_t *th,
+ unsigned long int modid,
+ psaddr_t *base)
+{
+ td_err_e err;
+ psaddr_t dtv, dtvslot, dtvptr;
+
+ if (modid < 1)
+ return TD_NOTLS;
+
+ psaddr_t pd = th->th_unique;
+ if (pd == 0)
+ {
+ /* This is the fake handle for the main thread before libpthread
+ initialization. We are using 0 for its th_unique because we can't
+ trust that its thread register has been initialized. But we need
+ a real pointer to have any TLS access work. In case of dlopen'd
+ libpthread, initialization might not be for quite some time. So
+ try looking up the thread register now. Worst case, it's nonzero
+ uninitialized garbage and we get bogus results for TLS access
+ attempted too early. Tough. */
+
+ td_thrhandle_t main_th;
+ err = __td_ta_lookup_th_unique (th->th_ta_p, ps_getpid (th->th_ta_p->ph),
+ &main_th);
+ if (err == 0)
+ pd = main_th.th_unique;
+ if (pd == 0)
+ return TD_TLSDEFER;
+ }
+
+ /* Get the DTV pointer from the thread descriptor. */
+ err = DB_GET_FIELD (dtv, th->th_ta_p, pd, pthread, dtvp, 0);
+ if (err != TD_OK)
+ return err;
+
+ /* Find the corresponding entry in the DTV. */
+ err = DB_GET_FIELD_ADDRESS (dtvslot, th->th_ta_p, dtv, dtv, dtv, modid);
+ if (err != TD_OK)
+ return err;
+
+ /* Extract the TLS block address from that DTV slot. */
+ err = DB_GET_FIELD (dtvptr, th->th_ta_p, dtvslot, dtv_t, pointer_val, 0);
+ if (err != TD_OK)
+ return err;
+
+ /* It could be that the memory for this module is not allocated for
+ the given thread. */
+ if ((uintptr_t) dtvptr & 1)
+ return TD_TLSDEFER;
+
+ *base = dtvptr;
+ return TD_OK;
+}
diff --git a/libpthread/nptl_db/td_thr_tsd.c b/libpthread/nptl_db/td_thr_tsd.c
new file mode 100644
index 000000000..a60ec9d4f
--- /dev/null
+++ b/libpthread/nptl_db/td_thr_tsd.c
@@ -0,0 +1,95 @@
+/* Get a thread-specific data pointer for a thread.
+ Copyright (C) 1999,2001,2002,2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 "thread_dbP.h"
+
+
+td_err_e
+td_thr_tsd (const td_thrhandle_t *th, const thread_key_t tk, void **data)
+{
+ td_err_e err;
+ psaddr_t tk_seq, level1, level2, seq, value;
+ void *copy;
+ uint32_t pthread_key_2ndlevel_size, idx1st, idx2nd;
+
+ LOG ("td_thr_tsd");
+
+ /* Get the key entry. */
+ err = DB_GET_VALUE (tk_seq, th->th_ta_p, __pthread_keys, tk);
+ if (err == TD_NOAPLIC)
+ return TD_BADKEY;
+ if (err != TD_OK)
+ return err;
+
+ /* Fail if this key is not at all used. */
+ if (((uintptr_t) tk_seq & 1) == 0)
+ return TD_BADKEY;
+
+ /* This makes sure we have the size information on hand. */
+ err = DB_GET_FIELD_ADDRESS (level2, th->th_ta_p, 0, pthread_key_data_level2,
+ data, 1);
+ if (err != TD_OK)
+ return err;
+
+ /* Compute the indeces. */
+ pthread_key_2ndlevel_size
+ = DB_DESC_NELEM (th->th_ta_p->ta_field_pthread_key_data_level2_data);
+ idx1st = tk / pthread_key_2ndlevel_size;
+ idx2nd = tk % pthread_key_2ndlevel_size;
+
+ /* Now fetch the first level pointer. */
+ err = DB_GET_FIELD (level1, th->th_ta_p, th->th_unique, pthread,
+ specific, idx1st);
+ if (err == TD_NOAPLIC)
+ return TD_DBERR;
+ if (err != TD_OK)
+ return err;
+
+ /* Check the pointer to the second level array. */
+ if (level1 == 0)
+ return TD_NOTSD;
+
+ /* Locate the element within the second level array. */
+ err = DB_GET_FIELD_ADDRESS (level2, th->th_ta_p,
+ level1, pthread_key_data_level2, data, idx2nd);
+ if (err == TD_NOAPLIC)
+ return TD_DBERR;
+ if (err != TD_OK)
+ return err;
+
+ /* Now copy in that whole structure. */
+ err = DB_GET_STRUCT (copy, th->th_ta_p, level2, pthread_key_data);
+ if (err != TD_OK)
+ return err;
+
+ /* Check whether the data is valid. */
+ err = DB_GET_FIELD_LOCAL (seq, th->th_ta_p, copy, pthread_key_data, seq, 0);
+ if (err != TD_OK)
+ return err;
+ if (seq != tk_seq)
+ return TD_NOTSD;
+
+ /* Finally, fetch the value. */
+ err = DB_GET_FIELD_LOCAL (value, th->th_ta_p, copy, pthread_key_data,
+ data, 0);
+ if (err == TD_OK)
+ *data = value;
+
+ return err;
+}
diff --git a/libpthread/nptl_db/td_thr_validate.c b/libpthread/nptl_db/td_thr_validate.c
new file mode 100644
index 000000000..1b96b5156
--- /dev/null
+++ b/libpthread/nptl_db/td_thr_validate.c
@@ -0,0 +1,84 @@
+/* Validate a thread handle.
+ Copyright (C) 1999,2001,2002,2003,2004,2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@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
+ 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 "thread_dbP.h"
+#include <stdbool.h>
+
+static td_err_e
+check_thread_list (const td_thrhandle_t *th, psaddr_t head, bool *uninit)
+{
+ td_err_e err;
+ psaddr_t next, ofs;
+
+ err = DB_GET_FIELD (next, th->th_ta_p, head, list_t, next, 0);
+ if (err == TD_OK)
+ {
+ if (next == 0)
+ {
+ *uninit = true;
+ return TD_NOTHR;
+ }
+ err = DB_GET_FIELD_ADDRESS (ofs, th->th_ta_p, 0, pthread, list, 0);
+ }
+
+ while (err == TD_OK)
+ {
+ if (next == head)
+ return TD_NOTHR;
+
+ if (next - (ofs - (psaddr_t) 0) == th->th_unique)
+ return TD_OK;
+
+ err = DB_GET_FIELD (next, th->th_ta_p, next, list_t, next, 0);
+ }
+
+ return err;
+}
+
+
+td_err_e
+td_thr_validate (const td_thrhandle_t *th)
+{
+ td_err_e err;
+ psaddr_t list = NULL;
+
+ LOG ("td_thr_validate");
+
+ /* First check the list with threads using user allocated stacks. */
+ bool uninit = false;
+ err = DB_GET_SYMBOL (list, th->th_ta_p, __stack_user);
+ if (err == TD_OK)
+ err = check_thread_list (th, list, &uninit);
+
+ /* If our thread is not on this list search the list with stack
+ using implementation allocated stacks. */
+ if (err == TD_NOTHR)
+ {
+ err = DB_GET_SYMBOL (list, th->th_ta_p, stack_used);
+ if (err == TD_OK)
+ err = check_thread_list (th, list, &uninit);
+
+ if (err == TD_NOTHR && uninit && th->th_unique == 0)
+ /* __pthread_initialize_minimal has not run yet.
+ There is only the special case thread handle. */
+ err = TD_OK;
+ }
+
+ return err;
+}
diff --git a/libpthread/nptl_db/thread_db.h b/libpthread/nptl_db/thread_db.h
new file mode 100644
index 000000000..27ea69af8
--- /dev/null
+++ b/libpthread/nptl_db/thread_db.h
@@ -0,0 +1,458 @@
+/* thread_db.h -- interface to libthread_db.so library for debugging -lpthread
+ Copyright (C) 1999,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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _THREAD_DB_H
+#define _THREAD_DB_H 1
+
+/* This is the debugger interface for the NPTL library. It is
+ modelled closely after the interface with same names in Solaris
+ with the goal to share the same code in the debugger. */
+#include <pthread.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <sys/procfs.h>
+
+
+/* Error codes of the library. */
+typedef enum
+{
+ TD_OK, /* No error. */
+ TD_ERR, /* No further specified error. */
+ TD_NOTHR, /* No matching thread found. */
+ TD_NOSV, /* No matching synchronization handle found. */
+ TD_NOLWP, /* No matching light-weighted process found. */
+ TD_BADPH, /* Invalid process handle. */
+ TD_BADTH, /* Invalid thread handle. */
+ TD_BADSH, /* Invalid synchronization handle. */
+ TD_BADTA, /* Invalid thread agent. */
+ TD_BADKEY, /* Invalid key. */
+ TD_NOMSG, /* No event available. */
+ TD_NOFPREGS, /* No floating-point register content available. */
+ TD_NOLIBTHREAD, /* Application not linked with thread library. */
+ TD_NOEVENT, /* Requested event is not supported. */
+ TD_NOCAPAB, /* Capability not available. */
+ TD_DBERR, /* Internal debug library error. */
+ TD_NOAPLIC, /* Operation is not applicable. */
+ TD_NOTSD, /* No thread-specific data available. */
+ TD_MALLOC, /* Out of memory. */
+ TD_PARTIALREG, /* Not entire register set was read or written. */
+ TD_NOXREGS, /* X register set not available for given thread. */
+ TD_TLSDEFER, /* Thread has not yet allocated TLS for given module. */
+ TD_NOTALLOC = TD_TLSDEFER,
+ TD_VERSION, /* Version if libpthread and libthread_db do not match. */
+ TD_NOTLS /* There is no TLS segment in the given module. */
+} td_err_e;
+
+
+/* Possible thread states. TD_THR_ANY_STATE is a pseudo-state used to
+ select threads regardless of state in td_ta_thr_iter(). */
+typedef enum
+{
+ TD_THR_ANY_STATE,
+ TD_THR_UNKNOWN,
+ TD_THR_STOPPED,
+ TD_THR_RUN,
+ TD_THR_ACTIVE,
+ TD_THR_ZOMBIE,
+ TD_THR_SLEEP,
+ TD_THR_STOPPED_ASLEEP
+} td_thr_state_e;
+
+/* Thread type: user or system. TD_THR_ANY_TYPE is a pseudo-type used
+ to select threads regardless of type in td_ta_thr_iter(). */
+typedef enum
+{
+ TD_THR_ANY_TYPE,
+ TD_THR_USER,
+ TD_THR_SYSTEM
+} td_thr_type_e;
+
+
+/* Types of the debugging library. */
+
+/* Handle for a process. This type is opaque. */
+typedef struct td_thragent td_thragent_t;
+
+/* The actual thread handle type. This is also opaque. */
+typedef struct td_thrhandle
+{
+ td_thragent_t *th_ta_p;
+ psaddr_t th_unique;
+} td_thrhandle_t;
+
+
+/* Forward declaration of a type defined by and for the dynamic linker. */
+struct link_map;
+
+
+/* Flags for `td_ta_thr_iter'. */
+#define TD_THR_ANY_USER_FLAGS 0xffffffff
+#define TD_THR_LOWEST_PRIORITY -20
+#define TD_SIGNO_MASK NULL
+
+
+#define TD_EVENTSIZE 2
+#define BT_UISHIFT 5 /* log base 2 of BT_NBIPUI, to extract word index */
+#define BT_NBIPUI (1 << BT_UISHIFT) /* n bits per uint */
+#define BT_UIMASK (BT_NBIPUI - 1) /* to extract bit index */
+
+/* Bitmask of enabled events. */
+typedef struct td_thr_events
+{
+ uint32_t event_bits[TD_EVENTSIZE];
+} td_thr_events_t;
+
+/* Event set manipulation macros. */
+#define __td_eventmask(n) \
+ (UINT32_C (1) << (((n) - 1) & BT_UIMASK))
+#define __td_eventword(n) \
+ ((UINT32_C ((n) - 1)) >> BT_UISHIFT)
+
+#define td_event_emptyset(setp) \
+ do { \
+ int __i; \
+ for (__i = TD_EVENTSIZE; __i > 0; --__i) \
+ (setp)->event_bits[__i - 1] = 0; \
+ } while (0)
+
+#define td_event_fillset(setp) \
+ do { \
+ int __i; \
+ for (__i = TD_EVENTSIZE; __i > 0; --__i) \
+ (setp)->event_bits[__i - 1] = UINT32_C (0xffffffff); \
+ } while (0)
+
+#define td_event_addset(setp, n) \
+ (((setp)->event_bits[__td_eventword (n)]) |= __td_eventmask (n))
+#define td_event_delset(setp, n) \
+ (((setp)->event_bits[__td_eventword (n)]) &= ~__td_eventmask (n))
+#define td_eventismember(setp, n) \
+ (__td_eventmask (n) & ((setp)->event_bits[__td_eventword (n)]))
+#if TD_EVENTSIZE == 2
+# define td_eventisempty(setp) \
+ (!((setp)->event_bits[0]) && !((setp)->event_bits[1]))
+#else
+# error "td_eventisempty must be changed to match TD_EVENTSIZE"
+#endif
+
+/* Events reportable by the thread implementation. */
+typedef enum
+{
+ TD_ALL_EVENTS, /* Pseudo-event number. */
+ TD_EVENT_NONE = TD_ALL_EVENTS, /* Depends on context. */
+ TD_READY, /* Is executable now. */
+ TD_SLEEP, /* Blocked in a synchronization obj. */
+ TD_SWITCHTO, /* Now assigned to a process. */
+ TD_SWITCHFROM, /* Not anymore assigned to a process. */
+ TD_LOCK_TRY, /* Trying to get an unavailable lock. */
+ TD_CATCHSIG, /* Signal posted to the thread. */
+ TD_IDLE, /* Process getting idle. */
+ TD_CREATE, /* New thread created. */
+ TD_DEATH, /* Thread terminated. */
+ TD_PREEMPT, /* Preempted. */
+ TD_PRI_INHERIT, /* Inherited elevated priority. */
+ TD_REAP, /* Reaped. */
+ TD_CONCURRENCY, /* Number of processes changing. */
+ TD_TIMEOUT, /* Conditional variable wait timed out. */
+ TD_MIN_EVENT_NUM = TD_READY,
+ TD_MAX_EVENT_NUM = TD_TIMEOUT,
+ TD_EVENTS_ENABLE = 31 /* Event reporting enabled. */
+} td_event_e;
+
+/* Values representing the different ways events are reported. */
+typedef enum
+{
+ NOTIFY_BPT, /* User must insert breakpoint at u.bptaddr. */
+ NOTIFY_AUTOBPT, /* Breakpoint at u.bptaddr is automatically
+ inserted. */
+ NOTIFY_SYSCALL /* System call u.syscallno will be invoked. */
+} td_notify_e;
+
+/* Description how event type is reported. */
+typedef struct td_notify
+{
+ td_notify_e type; /* Way the event is reported. */
+ union
+ {
+ psaddr_t bptaddr; /* Address of breakpoint. */
+ int syscallno; /* Number of system call used. */
+ } u;
+} td_notify_t;
+
+/* Structure used to report event. */
+typedef struct td_event_msg
+{
+ td_event_e event; /* Event type being reported. */
+ const td_thrhandle_t *th_p; /* Thread reporting the event. */
+ union
+ {
+# if 0
+ td_synchandle_t *sh; /* Handle of synchronization object. */
+#endif
+ uintptr_t data; /* Event specific data. */
+ } msg;
+} td_event_msg_t;
+
+/* Structure containing event data available in each thread structure. */
+typedef struct
+{
+ td_thr_events_t eventmask; /* Mask of enabled events. */
+ td_event_e eventnum; /* Number of last event. */
+ void *eventdata; /* Data associated with event. */
+} td_eventbuf_t;
+
+
+/* Gathered statistics about the process. */
+typedef struct td_ta_stats
+{
+ int nthreads; /* Total number of threads in use. */
+ int r_concurrency; /* Concurrency level requested by user. */
+ int nrunnable_num; /* Average runnable threads, numerator. */
+ int nrunnable_den; /* Average runnable threads, denominator. */
+ int a_concurrency_num; /* Achieved concurrency level, numerator. */
+ int a_concurrency_den; /* Achieved concurrency level, denominator. */
+ int nlwps_num; /* Average number of processes in use,
+ numerator. */
+ int nlwps_den; /* Average number of processes in use,
+ denominator. */
+ int nidle_num; /* Average number of idling processes,
+ numerator. */
+ int nidle_den; /* Average number of idling processes,
+ denominator. */
+} td_ta_stats_t;
+
+
+/* Since Sun's library is based on Solaris threads we have to define a few
+ types to map them to POSIX threads. */
+typedef pthread_t thread_t;
+typedef pthread_key_t thread_key_t;
+
+
+/* Callback for iteration over threads. */
+typedef int td_thr_iter_f (const td_thrhandle_t *, void *);
+
+/* Callback for iteration over thread local data. */
+typedef int td_key_iter_f (thread_key_t, void (*) (void *), void *);
+
+
+
+/* Forward declaration. This has to be defined by the user. */
+struct ps_prochandle;
+
+
+/* Information about the thread. */
+typedef struct td_thrinfo
+{
+ td_thragent_t *ti_ta_p; /* Process handle. */
+ unsigned int ti_user_flags; /* Unused. */
+ thread_t ti_tid; /* Thread ID returned by
+ pthread_create(). */
+ char *ti_tls; /* Pointer to thread-local data. */
+ psaddr_t ti_startfunc; /* Start function passed to
+ pthread_create(). */
+ psaddr_t ti_stkbase; /* Base of thread's stack. */
+ long int ti_stksize; /* Size of thread's stack. */
+ psaddr_t ti_ro_area; /* Unused. */
+ int ti_ro_size; /* Unused. */
+ td_thr_state_e ti_state; /* Thread state. */
+ unsigned char ti_db_suspended; /* Nonzero if suspended by debugger. */
+ td_thr_type_e ti_type; /* Type of the thread (system vs
+ user thread). */
+ intptr_t ti_pc; /* Unused. */
+ intptr_t ti_sp; /* Unused. */
+ short int ti_flags; /* Unused. */
+ int ti_pri; /* Thread priority. */
+ lwpid_t ti_lid; /* Kernel PID for this thread. */
+ sigset_t ti_sigmask; /* Signal mask. */
+ unsigned char ti_traceme; /* Nonzero if event reporting
+ enabled. */
+ unsigned char ti_preemptflag; /* Unused. */
+ unsigned char ti_pirecflag; /* Unused. */
+ sigset_t ti_pending; /* Set of pending signals. */
+ td_thr_events_t ti_events; /* Set of enabled events. */
+} td_thrinfo_t;
+
+
+
+/* Prototypes for exported library functions. */
+
+/* Initialize the thread debug support library. */
+extern td_err_e td_init (void);
+
+/* Historical relict. Should not be used anymore. */
+extern td_err_e td_log (void);
+
+/* Return list of symbols the library can request. */
+extern const char **td_symbol_list (void);
+
+/* Generate new thread debug library handle for process PS. */
+extern td_err_e td_ta_new (struct ps_prochandle *__ps, td_thragent_t **__ta);
+
+/* Free resources allocated for TA. */
+extern td_err_e td_ta_delete (td_thragent_t *__ta);
+
+/* Get number of currently running threads in process associated with TA. */
+extern td_err_e td_ta_get_nthreads (const td_thragent_t *__ta, int *__np);
+
+/* Return process handle passed in `td_ta_new' for process associated with
+ TA. */
+extern td_err_e td_ta_get_ph (const td_thragent_t *__ta,
+ struct ps_prochandle **__ph);
+
+/* Map thread library handle PT to thread debug library handle for process
+ associated with TA and store result in *TH. */
+extern td_err_e td_ta_map_id2thr (const td_thragent_t *__ta, pthread_t __pt,
+ td_thrhandle_t *__th);
+
+/* Map process ID LWPID to thread debug library handle for process
+ associated with TA and store result in *TH. */
+extern td_err_e td_ta_map_lwp2thr (const td_thragent_t *__ta, lwpid_t __lwpid,
+ td_thrhandle_t *__th);
+
+
+/* Call for each thread in a process associated with TA the callback function
+ CALLBACK. */
+extern td_err_e td_ta_thr_iter (const td_thragent_t *__ta,
+ td_thr_iter_f *__callback, void *__cbdata_p,
+ td_thr_state_e __state, int __ti_pri,
+ sigset_t *__ti_sigmask_p,
+ unsigned int __ti_user_flags);
+
+/* Call for each defined thread local data entry the callback function KI. */
+extern td_err_e td_ta_tsd_iter (const td_thragent_t *__ta, td_key_iter_f *__ki,
+ void *__p);
+
+
+/* Get event address for EVENT. */
+extern td_err_e td_ta_event_addr (const td_thragent_t *__ta,
+ td_event_e __event, td_notify_t *__ptr);
+
+/* Enable EVENT in global mask. */
+extern td_err_e td_ta_set_event (const td_thragent_t *__ta,
+ td_thr_events_t *__event);
+
+/* Disable EVENT in global mask. */
+extern td_err_e td_ta_clear_event (const td_thragent_t *__ta,
+ td_thr_events_t *__event);
+
+/* Return information about last event. */
+extern td_err_e td_ta_event_getmsg (const td_thragent_t *__ta,
+ td_event_msg_t *__msg);
+
+#ifdef __UCLIBC_SUSV4_LEGACY__
+/* Set suggested concurrency level for process associated with TA. */
+extern td_err_e td_ta_setconcurrency (const td_thragent_t *__ta, int __level);
+#endif
+
+/* Enable collecting statistics for process associated with TA. */
+extern td_err_e td_ta_enable_stats (const td_thragent_t *__ta, int __enable);
+
+/* Reset statistics. */
+extern td_err_e td_ta_reset_stats (const td_thragent_t *__ta);
+
+/* Retrieve statistics from process associated with TA. */
+extern td_err_e td_ta_get_stats (const td_thragent_t *__ta,
+ td_ta_stats_t *__statsp);
+
+
+/* Validate that TH is a thread handle. */
+extern td_err_e td_thr_validate (const td_thrhandle_t *__th);
+
+/* Return information about thread TH. */
+extern td_err_e td_thr_get_info (const td_thrhandle_t *__th,
+ td_thrinfo_t *__infop);
+
+/* Retrieve floating-point register contents of process running thread TH. */
+extern td_err_e td_thr_getfpregs (const td_thrhandle_t *__th,
+ prfpregset_t *__regset);
+
+/* Retrieve general register contents of process running thread TH. */
+extern td_err_e td_thr_getgregs (const td_thrhandle_t *__th,
+ prgregset_t __gregs);
+
+/* Retrieve extended register contents of process running thread TH. */
+extern td_err_e td_thr_getxregs (const td_thrhandle_t *__th, void *__xregs);
+
+/* Get size of extended register set of process running thread TH. */
+extern td_err_e td_thr_getxregsize (const td_thrhandle_t *__th, int *__sizep);
+
+/* Set floating-point register contents of process running thread TH. */
+extern td_err_e td_thr_setfpregs (const td_thrhandle_t *__th,
+ const prfpregset_t *__fpregs);
+
+/* Set general register contents of process running thread TH. */
+extern td_err_e td_thr_setgregs (const td_thrhandle_t *__th,
+ prgregset_t __gregs);
+
+/* Set extended register contents of process running thread TH. */
+extern td_err_e td_thr_setxregs (const td_thrhandle_t *__th,
+ const void *__addr);
+
+
+/* Get address of the given module's TLS storage area for the given thread. */
+extern td_err_e td_thr_tlsbase (const td_thrhandle_t *__th,
+ unsigned long int __modid,
+ psaddr_t *__base);
+
+/* Get address of thread local variable. */
+extern td_err_e td_thr_tls_get_addr (const td_thrhandle_t *__th,
+ psaddr_t __map_address, size_t __offset,
+ psaddr_t *__address);
+
+
+/* Enable reporting for EVENT for thread TH. */
+extern td_err_e td_thr_event_enable (const td_thrhandle_t *__th, int __event);
+
+/* Enable EVENT for thread TH. */
+extern td_err_e td_thr_set_event (const td_thrhandle_t *__th,
+ td_thr_events_t *__event);
+
+/* Disable EVENT for thread TH. */
+extern td_err_e td_thr_clear_event (const td_thrhandle_t *__th,
+ td_thr_events_t *__event);
+
+/* Get event message for thread TH. */
+extern td_err_e td_thr_event_getmsg (const td_thrhandle_t *__th,
+ td_event_msg_t *__msg);
+
+
+/* Set priority of thread TH. */
+extern td_err_e td_thr_setprio (const td_thrhandle_t *__th, int __prio);
+
+
+/* Set pending signals for thread TH. */
+extern td_err_e td_thr_setsigpending (const td_thrhandle_t *__th,
+ unsigned char __n, const sigset_t *__ss);
+
+/* Set signal mask for thread TH. */
+extern td_err_e td_thr_sigsetmask (const td_thrhandle_t *__th,
+ const sigset_t *__ss);
+
+
+/* Return thread local data associated with key TK in thread TH. */
+extern td_err_e td_thr_tsd (const td_thrhandle_t *__th,
+ const thread_key_t __tk, void **__data);
+
+
+/* Suspend execution of thread TH. */
+extern td_err_e td_thr_dbsuspend (const td_thrhandle_t *__th);
+
+/* Resume execution of thread TH. */
+extern td_err_e td_thr_dbresume (const td_thrhandle_t *__th);
+
+#endif /* thread_db.h */
diff --git a/libpthread/nptl_db/thread_dbP.h b/libpthread/nptl_db/thread_dbP.h
new file mode 100644
index 000000000..b8399f758
--- /dev/null
+++ b/libpthread/nptl_db/thread_dbP.h
@@ -0,0 +1,260 @@
+/* Private header for thread debug library
+ Copyright (C) 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
+ 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 _THREAD_DBP_H
+#define _THREAD_DBP_H 1
+
+#include <stdbool.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <assert.h>
+#include "proc_service.h"
+#include "thread_db.h"
+#include "../nptl/pthreadP.h" /* This is for *_BITMASK only. */
+
+#ifdef __UCLIBC__
+#define __alloca alloca
+#endif
+
+/* Indeces for the symbol names. */
+enum
+ {
+# define DB_STRUCT(type) SYM_SIZEOF_##type,
+# define DB_STRUCT_FIELD(type, field) SYM_##type##_FIELD_##field,
+# define DB_SYMBOL(name) SYM_##name,
+# define DB_FUNCTION(name) SYM_##name,
+# define DB_VARIABLE(name) SYM_##name, SYM_DESC_##name,
+# include "structs.def"
+# undef DB_STRUCT
+# undef DB_STRUCT_FIELD
+# undef DB_SYMBOL
+# undef DB_FUNCTION
+# undef DB_VARIABLE
+
+ SYM_TH_UNIQUE_CONST_THREAD_AREA,
+ SYM_TH_UNIQUE_REGISTER64,
+ SYM_TH_UNIQUE_REGISTER32,
+ SYM_TH_UNIQUE_REGISTER64_THREAD_AREA,
+ SYM_TH_UNIQUE_REGISTER32_THREAD_AREA,
+
+ SYM_NUM_MESSAGES
+ };
+
+
+/* Comment out the following for less verbose output. */
+#ifndef NDEBUG
+# define LOG(c) if (__td_debug) write (2, c "\n", strlen (c "\n"))
+extern int __td_debug attribute_hidden;
+#else
+# define LOG(c)
+#endif
+
+
+#define DB_DESC_SIZE(desc) ((desc)[0])
+#define DB_DESC_NELEM(desc) ((desc)[1])
+#define DB_DESC_OFFSET(desc) ((desc)[2])
+#define DB_SIZEOF_DESC (3 * sizeof (uint32_t))
+#define DB_DEFINE_DESC(name, size, nelem, offset) \
+ const uint32_t name[3] = { (size), (nelem), (offset) }
+typedef uint32_t db_desc_t[3];
+
+
+/* Handle for a process. This type is opaque. */
+struct td_thragent
+{
+ /* Chain on the list of all agent structures. */
+ list_t list;
+
+ /* Delivered by the debugger and we have to pass it back in the
+ proc callbacks. */
+ struct ps_prochandle *ph;
+
+ /* Cached values read from the inferior. */
+# define DB_STRUCT(type) \
+ uint32_t ta_sizeof_##type;
+# define DB_STRUCT_FIELD(type, field) \
+ db_desc_t ta_field_##type##_##field;
+# define DB_SYMBOL(name) \
+ psaddr_t ta_addr_##name;
+# define DB_FUNCTION(name) \
+ psaddr_t ta_addr_##name;
+# define DB_VARIABLE(name) \
+ psaddr_t ta_addr_##name; \
+ db_desc_t ta_var_##name;
+# include "structs.def"
+# undef DB_STRUCT
+# undef DB_STRUCT_FIELD
+# undef DB_FUNCTION
+# undef DB_SYMBOL
+# undef DB_VARIABLE
+
+ /* The method of locating a thread's th_unique value. */
+ enum
+ {
+ ta_howto_unknown,
+ ta_howto_reg,
+ ta_howto_reg_thread_area,
+ ta_howto_const_thread_area
+ } ta_howto;
+ union
+ {
+ uint32_t const_thread_area; /* Constant argument to ps_get_thread_area. */
+ /* These are as if the descriptor of the field in prregset_t,
+ but DB_DESC_NELEM is overloaded as follows: */
+ db_desc_t reg; /* Signed bias applied to register value. */
+ db_desc_t reg_thread_area; /* Bits to scale down register value. */
+ } ta_howto_data;
+};
+
+
+/* List of all known descriptors. */
+extern list_t __td_agent_list attribute_hidden;
+
+
+/* Function used to test for correct thread agent pointer. */
+static inline bool
+ta_ok (const td_thragent_t *ta)
+{
+ list_t *runp;
+
+ list_for_each (runp, &__td_agent_list)
+ if (list_entry (runp, td_thragent_t, list) == ta)
+ return true;
+
+ return false;
+}
+
+
+/* Internal wrapper around ps_pglobal_lookup. */
+extern ps_err_e td_lookup (struct ps_prochandle *ps,
+ int idx, psaddr_t *sym_addr) attribute_hidden;
+
+
+
+
+/* Store in psaddr_t VAR the address of inferior's symbol NAME. */
+#define DB_GET_SYMBOL(var, ta, name) \
+ (((ta)->ta_addr_##name == 0 \
+ && td_lookup ((ta)->ph, SYM_##name, &(ta)->ta_addr_##name) != PS_OK) \
+ ? TD_ERR : ((var) = (ta)->ta_addr_##name, TD_OK))
+
+/* Store in psaddr_t VAR the value of ((TYPE) PTR)->FIELD[IDX] in the inferior.
+ A target field smaller than psaddr_t is zero-extended. */
+#define DB_GET_FIELD(var, ta, ptr, type, field, idx) \
+ _td_fetch_value ((ta), (ta)->ta_field_##type##_##field, \
+ SYM_##type##_FIELD_##field, \
+ (psaddr_t) 0 + (idx), (ptr), &(var))
+
+#define DB_GET_FIELD_ADDRESS(var, ta, ptr, type, field, idx) \
+ ((var) = (ptr), _td_locate_field ((ta), (ta)->ta_field_##type##_##field, \
+ SYM_##type##_FIELD_##field, \
+ (psaddr_t) 0 + (idx), &(var)))
+
+extern td_err_e _td_locate_field (td_thragent_t *ta,
+ db_desc_t desc, int descriptor_name,
+ psaddr_t idx,
+ psaddr_t *address) attribute_hidden;
+
+
+/* Like DB_GET_FIELD, but PTR is a local pointer to a structure that
+ has already been copied in from the inferior. */
+#define DB_GET_FIELD_LOCAL(var, ta, ptr, type, field, idx) \
+ _td_fetch_value_local ((ta), (ta)->ta_field_##type##_##field, \
+ SYM_##type##_FIELD_##field, \
+ (psaddr_t) 0 + (idx), (ptr), &(var))
+
+/* Store in psaddr_t VAR the value of variable NAME[IDX] in the inferior.
+ A target value smaller than psaddr_t is zero-extended. */
+#define DB_GET_VALUE(var, ta, name, idx) \
+ (((ta)->ta_addr_##name == 0 \
+ && td_lookup ((ta)->ph, SYM_##name, &(ta)->ta_addr_##name) != PS_OK) \
+ ? TD_ERR \
+ : _td_fetch_value ((ta), (ta)->ta_var_##name, SYM_DESC_##name, \
+ (psaddr_t) 0 + (idx), (ta)->ta_addr_##name, &(var)))
+
+/* Helper functions for those. */
+extern td_err_e _td_fetch_value (td_thragent_t *ta,
+ db_desc_t field, int descriptor_name,
+ psaddr_t idx, psaddr_t address,
+ psaddr_t *result) attribute_hidden;
+extern td_err_e _td_fetch_value_local (td_thragent_t *ta,
+ db_desc_t field,
+ int descriptor_name,
+ psaddr_t idx, void *address,
+ psaddr_t *result) attribute_hidden;
+
+/* Store psaddr_t VALUE in ((TYPE) PTR)->FIELD[IDX] in the inferior.
+ A target field smaller than psaddr_t is zero-extended. */
+#define DB_PUT_FIELD(ta, ptr, type, field, idx, value) \
+ _td_store_value ((ta), (ta)->ta_field_##type##_##field, \
+ SYM_##type##_FIELD_##field, \
+ (psaddr_t) 0 + (idx), (ptr), (value))
+
+#define DB_PUT_FIELD_LOCAL(ta, ptr, type, field, idx, value) \
+ _td_store_value_local ((ta), (ta)->ta_field_##type##_##field, \
+ SYM_##type##_FIELD_##field, \
+ (psaddr_t) 0 + (idx), (ptr), (value))
+
+/* Store psaddr_t VALUE in variable NAME[IDX] in the inferior.
+ A target field smaller than psaddr_t is zero-extended. */
+#define DB_PUT_VALUE(ta, name, idx, value) \
+ (((ta)->ta_addr_##name == 0 \
+ && td_lookup ((ta)->ph, SYM_##name, &(ta)->ta_addr_##name) != PS_OK) \
+ ? TD_ERR \
+ : _td_store_value ((ta), (ta)->ta_var_##name, SYM_DESC_##name, \
+ (psaddr_t) 0 + (idx), (ta)->ta_addr_##name, (value)))
+
+/* Helper functions for those. */
+extern td_err_e _td_store_value (td_thragent_t *ta,
+ db_desc_t field, int descriptor_name,
+ psaddr_t idx, psaddr_t address,
+ psaddr_t value) attribute_hidden;
+extern td_err_e _td_store_value_local (td_thragent_t *ta,
+ db_desc_t field, int descriptor_name,
+ psaddr_t idx, void *address,
+ psaddr_t value) attribute_hidden;
+
+#define DB_GET_STRUCT(var, ta, ptr, type) \
+ ({ td_err_e _err = TD_OK; \
+ if ((ta)->ta_sizeof_##type == 0) \
+ _err = _td_check_sizeof ((ta), &(ta)->ta_sizeof_##type, \
+ SYM_SIZEOF_##type); \
+ if (_err == TD_OK) \
+ _err = ps_pdread ((ta)->ph, (ptr), \
+ (var) = __alloca ((ta)->ta_sizeof_##type), \
+ (ta)->ta_sizeof_##type) \
+ == PS_OK ? TD_OK : TD_ERR; \
+ else \
+ (var) = NULL; \
+ _err; \
+ })
+#define DB_PUT_STRUCT(ta, ptr, type, copy) \
+ ({ assert ((ta)->ta_sizeof_##type != 0); \
+ ps_pdwrite ((ta)->ph, (ptr), (copy), (ta)->ta_sizeof_##type) \
+ == PS_OK ? TD_OK : TD_ERR; \
+ })
+
+extern td_err_e _td_check_sizeof (td_thragent_t *ta, uint32_t *sizep,
+ int sizep_name) attribute_hidden;
+
+extern td_err_e __td_ta_lookup_th_unique (const td_thragent_t *ta,
+ lwpid_t lwpid, td_thrhandle_t *th);
+
+#endif /* thread_dbP.h */
diff --git a/libresolv/Makefile.in b/libresolv/Makefile.in
index cfcb9d78b..fa3c34138 100644
--- a/libresolv/Makefile.in
+++ b/libresolv/Makefile.in
@@ -1,13 +1,16 @@
# Makefile for uClibc
#
-# Copyright (C) 2000-2005 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.
#
+subdirs += libresolv
+
CFLAGS-libresolv := -DNOT_IN_libc -DIS_IN_libresolv $(SSP_ALL_CFLAGS)
-LDFLAGS-libresolv.so := $(LDFLAGS)
+LDFLAGS-$(UCLIBC_FORMAT_DSBT_ELF)-libresolv.so := -Wl,--dsbt-index=7
+LDFLAGS-libresolv.so := $(LDFLAGS) $(call link.asneeded,-lc)
LIBS-libresolv.so := $(LIBS)
@@ -26,16 +29,16 @@ libresolv-a-y := $(libresolv_OBJ)
endif
libresolv-so-y := $(libresolv_OBJ:.o=.os)
-lib-a-y += $(top_builddir)lib/libresolv.a
-lib-so-y += $(top_builddir)lib/libresolv.so
-objclean-y += libresolv_clean
+lib-a-$(UCLIBC_HAS_LIBRESOLV_STUB) += $(top_builddir)lib/libresolv.a
+lib-so-$(UCLIBC_HAS_LIBRESOLV_STUB) += $(top_builddir)lib/libresolv.so
+objclean-y += CLEAN_libresolv
ifeq ($(DOPIC),y)
$(top_builddir)lib/libresolv.so: $(top_builddir)lib/libresolv.a $(libc.depend)
else
$(top_builddir)lib/libresolv.so: $(libresolv_OUT)/libresolv_so.a $(libc.depend)
endif
- $(call link.so,$(libresolv_FULL_NAME),$(MAJOR_VERSION))
+ $(call link.so,$(libresolv_FULL_NAME),$(ABI_VERSION))
$(libresolv_OUT)/libresolv_so.a: $(libresolv-so-y)
$(Q)$(RM) $@
@@ -46,5 +49,5 @@ $(top_builddir)lib/libresolv.a: $(libresolv-a-y)
$(Q)$(RM) $@
$(do_ar)
-libresolv_clean:
- $(RM) $(libresolv_OUT)/*.{o,os,a}
+CLEAN_libresolv:
+ $(do_rm) $(addprefix $(libresolv_OUT)/*., o os a)
diff --git a/libresolv/resolv.c b/libresolv/resolv.c
index 38b10ff21..431996962 100644
--- a/libresolv/resolv.c
+++ b/libresolv/resolv.c
@@ -7,8 +7,6 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#include <features.h>
-
void __stub1(void);
void __stub1(void)
{
diff --git a/librt/Makefile.in b/librt/Makefile.in
index 19b779551..1536a5cb9 100644
--- a/librt/Makefile.in
+++ b/librt/Makefile.in
@@ -1,53 +1,88 @@
# Makefile for uClibc
#
-# Copyright (C) 2000-2005 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.
#
+subdirs += librt
+
CFLAGS-librt := -DNOT_IN_libc -DIS_IN_librt $(SSP_ALL_CFLAGS)
+LDFLAGS-$(UCLIBC_FORMAT_DSBT_ELF)-librt.so := -Wl,--dsbt-index=9
LDFLAGS-librt.so := $(LDFLAGS)
-
LIBS-librt.so := $(LIBS)
+ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
+LIBS-librt.so += $(top_builddir)lib/libpthread.so \
+ $(CC_FLAG_ASNEEDED) $(top_builddir)lib/libdl.so $(CC_FLAG_NO_ASNEEDED)
+endif
librt_FULL_NAME := librt-$(VERSION).so
librt_DIR := $(top_srcdir)librt
librt_OUT := $(top_builddir)librt
-ifeq ($(UCLIBC_HAS_REALTIME),y)
-librt_SRC := $(wildcard $(librt_DIR)/*.c)
-librt_OBJ := $(patsubst $(librt_DIR)/%.c,$(librt_OUT)/%.o,$(librt_SRC))
+librt_SRC := $(notdir $(wildcard $(librt_DIR)/*.c))
+librt_filter_SRC :=
+ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
+librt_filter_SRC += mq_notify.c timer_create.c timer_delete.c \
+ timer_getoverr.c timer_gettime.c timer_settime.c
+# these should really be guarded by ADVANCED_REALTIME, we use them in mq_send.c/mq_receive.c
+librt_SSRC := $(wildcard $(librt_DIR)/*.S)
+else
+librt_filter_SRC += clock_nanosleep.c clock_getcpuclockid.c clock_gettime.c
+librt_SSRC :=
+endif
+
+librt_filter_SRC += $(if $(UCLIBC_HAS_ADVANCED_REALTIME),, \
+ spawn.c \
+ spawn_faction_addclose.c \
+ spawn_faction_adddup2.c \
+ spawn_faction_addopen.c \
+ spawn_faction_init.c)
+
+librt_filter_SRC += $(if $(UCLIBC_HAS_STUBS),,rt_stubs.c)
+librt_filter_SRC += $(if $(HAS_NO_THREADS),dso_handle.c)
+
+librt_SRC := $(filter-out $(librt_filter_SRC),$(librt_SRC))
+librt_OBJ := $(patsubst %.c,$(librt_OUT)/%.o,$(librt_SRC))
+librt_OBJ += $(patsubst $(librt_DIR)/%.S,$(librt_OUT)/%.o,$(librt_SSRC))
+
+ASFLAGS-mq_timedreceive.S = -D_LIBC_REENTRANT
+ASFLAGS-mq_timedsend.S = -D_LIBC_REENTRANT
ifeq ($(DOPIC),y)
librt-a-y += $(librt_OBJ:.o=.os)
else
librt-a-y += $(librt_OBJ)
endif
-librt-so-y += $(librt_OBJ:.o=.os)
+librt-so-y += $(librt_OBJ:.o=.oS)
+ifeq ($(UCLIBC_HAS_REALTIME),y)
lib-a-y += $(top_builddir)lib/librt.a
lib-so-y += $(top_builddir)lib/librt.so
endif
-ifeq ($(DOPIC),y)
-$(top_builddir)lib/librt.so: $(top_builddir)lib/librt.a $(libc.depend)
+librt-dep-y := $(libc.depend)
+librt-dep-$(UCLIBC_HAS_THREADS_NATIVE) += $(libpthread.depend) $(libdl.depend)
+
+# for NPTL we need SHARED regardless of DOPIC
+ifeq ($(if $(UCLIBC_HAS_THREADS_NATIVE),,$(DOPIC)),y)
+$(top_builddir)lib/librt.so: $(top_builddir)lib/librt.a $(librt-dep-y)
else
-$(top_builddir)lib/librt.so: $(librt_OUT)/librt_so.a $(libc.depend)
+$(top_builddir)lib/librt.so: $(librt_OUT)/librt_so.a $(librt-dep-y)
endif
- $(call link.so,$(librt_FULL_NAME),$(MAJOR_VERSION))
+ $(call link.so,$(librt_FULL_NAME),$(ABI_VERSION))
$(librt_OUT)/librt_so.a: $(librt-so-y)
$(Q)$(RM) $@
$(do_ar)
$(top_builddir)lib/librt.a: $(librt-a-y)
- $(Q)$(INSTALL) -d $(dir $@)
$(Q)$(RM) $@
$(do_ar)
-objclean-y += librt_clean
+objclean-y += CLEAN_librt
-librt_clean:
- $(RM) $(librt_OUT)/*.{o,os,a}
+CLEAN_librt:
+ $(do_rm) $(addprefix $(librt_OUT)/*., o os oS a)
diff --git a/librt/clock_getcpuclockid.c b/librt/clock_getcpuclockid.c
new file mode 100644
index 000000000..b6142a78a
--- /dev/null
+++ b/librt/clock_getcpuclockid.c
@@ -0,0 +1,103 @@
+/* clock_getcpuclockid -- Get a clockid_t for process CPU time. Linux version.
+ Copyright (C) 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/>. */
+
+#include <errno.h>
+#include <time.h>
+#include <sysdep.h>
+#include <unistd.h>
+#include <bits/kernel-features.h>
+#include "kernel-posix-cpu-timers.h"
+
+#ifndef HAS_CPUCLOCK
+# define HAS_CPUCLOCK 1
+#endif
+
+int
+clock_getcpuclockid (pid_t pid, clockid_t *clock_id)
+{
+#ifdef __NR_clock_getres
+ /* The clockid_t value is a simple computation from the PID.
+ But we do a clock_getres call to validate it. */
+
+ const clockid_t pidclock = MAKE_PROCESS_CPUCLOCK (pid, CPUCLOCK_SCHED);
+
+# if !(__ASSUME_POSIX_CPU_TIMERS > 0)
+ extern int __libc_missing_posix_cpu_timers attribute_hidden;
+# if !(__ASSUME_POSIX_TIMERS > 0)
+ extern int __libc_missing_posix_timers attribute_hidden;
+ if (__libc_missing_posix_timers && !__libc_missing_posix_cpu_timers)
+ __libc_missing_posix_cpu_timers = 1;
+# endif
+ if (!__libc_missing_posix_cpu_timers)
+# endif
+ {
+ INTERNAL_SYSCALL_DECL (err);
+ int r = INTERNAL_SYSCALL (clock_getres, err, 2, pidclock, NULL);
+ if (!INTERNAL_SYSCALL_ERROR_P (r, err))
+ {
+ *clock_id = pidclock;
+ return 0;
+ }
+
+# if !(__ASSUME_POSIX_TIMERS > 0)
+ if (INTERNAL_SYSCALL_ERRNO (r, err) == ENOSYS)
+ {
+ /* The kernel doesn't support these calls at all. */
+ __libc_missing_posix_timers = 1;
+ __libc_missing_posix_cpu_timers = 1;
+ }
+ else
+# endif
+ if (INTERNAL_SYSCALL_ERRNO (r, err) == EINVAL)
+ {
+# if !(__ASSUME_POSIX_CPU_TIMERS > 0)
+ if (pidclock == MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED)
+ || INTERNAL_SYSCALL_ERROR_P (INTERNAL_SYSCALL
+ (clock_getres, err, 2,
+ MAKE_PROCESS_CPUCLOCK
+ (0, CPUCLOCK_SCHED), NULL),
+ err))
+ /* The kernel doesn't support these clocks at all. */
+ __libc_missing_posix_cpu_timers = 1;
+ else
+# endif
+ /* The clock_getres system call checked the PID for us. */
+ return ESRCH;
+ }
+ else
+ return INTERNAL_SYSCALL_ERRNO (r, err);
+ }
+#endif
+
+ /* We don't allow any process ID but our own. */
+ if (pid != 0 && pid != getpid ())
+ return EPERM;
+
+#ifdef CLOCK_PROCESS_CPUTIME_ID
+ if (HAS_CPUCLOCK)
+ {
+ /* Store the number. */
+ *clock_id = CLOCK_PROCESS_CPUTIME_ID;
+
+ return 0;
+ }
+#endif
+
+ /* We don't have a timer for that. */
+ return ENOENT;
+}
diff --git a/librt/clock_gettime.c b/librt/clock_gettime.c
new file mode 100644
index 000000000..e61616314
--- /dev/null
+++ b/librt/clock_gettime.c
@@ -0,0 +1,299 @@
+/* clock_gettime -- Get current time from a POSIX clockid_t. Linux version.
+ Copyright (C) 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#include <errno.h>
+#include <time.h>
+#include "kernel-posix-cpu-timers.h"
+#include <bits/kernel-features.h>
+
+
+#define SYSCALL_GETTIME \
+ retval = INLINE_SYSCALL (clock_gettime, 2, clock_id, tp); \
+ break
+
+#ifdef __ASSUME_POSIX_TIMERS
+
+/* This means the REALTIME and MONOTONIC clock are definitely
+ supported in the kernel. */
+# define SYSDEP_GETTIME \
+ SYSDEP_GETTIME_CPUTIME \
+ case CLOCK_REALTIME: \
+ case CLOCK_MONOTONIC: \
+ SYSCALL_GETTIME
+
+# define __libc_missing_posix_timers 0
+#elif defined __NR_clock_gettime
+/* Is the syscall known to exist? */
+int __libc_missing_posix_timers attribute_hidden;
+
+static inline int
+maybe_syscall_gettime (clockid_t clock_id, struct timespec *tp)
+{
+ int e = EINVAL;
+
+ if (!__libc_missing_posix_timers)
+ {
+ INTERNAL_SYSCALL_DECL (err);
+ int r = INTERNAL_SYSCALL (clock_gettime, err, 2, clock_id, tp);
+ if (!INTERNAL_SYSCALL_ERROR_P (r, err))
+ return 0;
+
+ e = INTERNAL_SYSCALL_ERRNO (r, err);
+ if (e == ENOSYS)
+ {
+ __libc_missing_posix_timers = 1;
+ e = EINVAL;
+ }
+ }
+
+ return e;
+}
+
+/* The REALTIME and MONOTONIC clock might be available. Try the
+ syscall first. */
+# define SYSDEP_GETTIME \
+ SYSDEP_GETTIME_CPUTIME \
+ case CLOCK_REALTIME: \
+ case CLOCK_MONOTONIC: \
+ retval = maybe_syscall_gettime (clock_id, tp); \
+ if (retval == 0) \
+ break; \
+ /* Fallback code. */ \
+ if (retval == EINVAL && clock_id == CLOCK_REALTIME) \
+ retval = realtime_gettime (tp); \
+ else \
+ { \
+ __set_errno (retval); \
+ retval = -1; \
+ } \
+ break;
+#endif
+
+#ifdef __NR_clock_gettime
+/* We handled the REALTIME clock here. */
+# define HANDLED_REALTIME 1
+# define HANDLED_CPUTIME 1
+
+# if __ASSUME_POSIX_CPU_TIMERS > 0
+
+# define SYSDEP_GETTIME_CPU SYSCALL_GETTIME
+# define SYSDEP_GETTIME_CPUTIME /* Default catches them too. */
+
+# else
+
+int __libc_missing_posix_cpu_timers attribute_hidden;
+
+static int
+maybe_syscall_gettime_cpu (clockid_t clock_id, struct timespec *tp)
+{
+ int e = EINVAL;
+
+ if (!__libc_missing_posix_cpu_timers)
+ {
+ INTERNAL_SYSCALL_DECL (err);
+ int r = INTERNAL_SYSCALL (clock_gettime, err, 2, clock_id, tp);
+ if (!INTERNAL_SYSCALL_ERROR_P (r, err))
+ return 0;
+
+ e = INTERNAL_SYSCALL_ERRNO (r, err);
+# ifndef __ASSUME_POSIX_TIMERS
+ if (e == ENOSYS)
+ {
+ __libc_missing_posix_timers = 1;
+ __libc_missing_posix_cpu_timers = 1;
+ e = EINVAL;
+ }
+ else
+# endif
+ {
+ if (e == EINVAL)
+ {
+ /* Check whether the kernel supports CPU clocks at all.
+ If not, record it for the future. */
+ r = INTERNAL_SYSCALL (clock_getres, err, 2,
+ MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED),
+ NULL);
+ if (INTERNAL_SYSCALL_ERROR_P (r, err))
+ __libc_missing_posix_cpu_timers = 1;
+ }
+ }
+ }
+
+ return e;
+}
+
+# define SYSDEP_GETTIME_CPU \
+ retval = maybe_syscall_gettime_cpu (clock_id, tp); \
+ if (retval == 0) \
+ break; \
+ if (retval != EINVAL || !__libc_missing_posix_cpu_timers) \
+ { \
+ __set_errno (retval); \
+ retval = -1; \
+ break; \
+ } \
+ retval = -1 /* Otherwise continue on to the HP_TIMING version. */;
+
+static inline int
+maybe_syscall_gettime_cputime (clockid_t clock_id, struct timespec *tp)
+{
+ return maybe_syscall_gettime_cpu
+ (clock_id == CLOCK_THREAD_CPUTIME_ID
+ ? MAKE_THREAD_CPUCLOCK (0, CPUCLOCK_SCHED)
+ : MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED),
+ tp);
+}
+
+# define SYSDEP_GETTIME_CPUTIME \
+ case CLOCK_PROCESS_CPUTIME_ID: \
+ case CLOCK_THREAD_CPUTIME_ID: \
+ retval = maybe_syscall_gettime_cputime (clock_id, tp); \
+ if (retval == 0) \
+ break; \
+ if (retval != EINVAL || !__libc_missing_posix_cpu_timers) \
+ { \
+ __set_errno (retval); \
+ retval = -1; \
+ break; \
+ } \
+ retval = hp_timing_gettime (clock_id, tp); \
+ break;
+# if !HP_TIMING_AVAIL
+# define hp_timing_gettime(clock_id, tp) (__set_errno (EINVAL), -1)
+# endif
+
+# endif
+#endif
+
+#include <errno.h>
+#include <stdint.h>
+#include <time.h>
+#include <sys/time.h>
+#include <ldsodefs.h>
+
+
+#if HP_TIMING_AVAIL
+/* Clock frequency of the processor. We make it a 64-bit variable
+ because some jokers are already playing with processors with more
+ than 4GHz. */
+static hp_timing_t freq;
+
+
+/* This function is defined in the thread library. */
+extern int __pthread_clock_gettime (clockid_t clock_id, hp_timing_t freq,
+ struct timespec *tp)
+ __attribute__ ((__weak__));
+
+static int
+hp_timing_gettime (clockid_t clock_id, struct timespec *tp)
+{
+ hp_timing_t tsc;
+
+ if (__builtin_expect (freq == 0, 0))
+ {
+ /* This can only happen if we haven't initialized the `freq'
+ variable yet. Do this now. We don't have to protect this
+ code against multiple execution since all of them should
+ lead to the same result. */
+ freq = __get_clockfreq ();
+ if (__builtin_expect (freq == 0, 0))
+ /* Something went wrong. */
+ return -1;
+ }
+
+ if (clock_id != CLOCK_PROCESS_CPUTIME_ID
+ && __pthread_clock_gettime != NULL)
+ return __pthread_clock_gettime (clock_id, freq, tp);
+
+ /* Get the current counter. */
+ HP_TIMING_NOW (tsc);
+
+ /* Compute the offset since the start time of the process. */
+ tsc -= GL(dl_cpuclock_offset);
+
+ /* Compute the seconds. */
+ tp->tv_sec = tsc / freq;
+
+ /* And the nanoseconds. This computation should be stable until
+ we get machines with about 16GHz frequency. */
+ tp->tv_nsec = ((tsc % freq) * UINT64_C (1000000000)) / freq;
+
+ return 0;
+}
+#endif
+
+
+static inline int
+realtime_gettime (struct timespec *tp)
+{
+ struct timeval tv;
+ int retval = gettimeofday (&tv, NULL);
+ if (retval == 0)
+ /* Convert into `timespec'. */
+ TIMEVAL_TO_TIMESPEC (&tv, tp);
+ return retval;
+}
+
+librt_hidden_proto (clock_gettime)
+/* Get current value of CLOCK and store it in TP. */
+int
+clock_gettime (clockid_t clock_id, struct timespec *tp)
+{
+ int retval = -1;
+#ifndef HANDLED_REALTIME
+ struct timeval tv;
+#endif
+
+ switch (clock_id)
+ {
+#ifdef SYSDEP_GETTIME
+ SYSDEP_GETTIME;
+#endif
+
+#ifndef HANDLED_REALTIME
+ case CLOCK_REALTIME:
+ retval = gettimeofday (&tv, NULL);
+ if (retval == 0)
+ TIMEVAL_TO_TIMESPEC (&tv, tp);
+ break;
+#endif
+
+ default:
+#ifdef SYSDEP_GETTIME_CPU
+ SYSDEP_GETTIME_CPU;
+#endif
+#if HP_TIMING_AVAIL
+ if ((clock_id & ((1 << CLOCK_IDFIELD_SIZE) - 1))
+ == CLOCK_THREAD_CPUTIME_ID)
+ retval = hp_timing_gettime (clock_id, tp);
+ else
+#endif
+ __set_errno (EINVAL);
+ break;
+
+#if HP_TIMING_AVAIL && !defined HANDLED_CPUTIME
+ case CLOCK_PROCESS_CPUTIME_ID:
+ retval = hp_timing_gettime (clock_id, tp);
+ break;
+#endif
+ }
+
+ return retval;
+}
+librt_hidden_def (clock_gettime)
diff --git a/librt/clock_nanosleep.c b/librt/clock_nanosleep.c
new file mode 100644
index 000000000..235e8b563
--- /dev/null
+++ b/librt/clock_nanosleep.c
@@ -0,0 +1,95 @@
+/* Copyright (C) 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/>. */
+
+#include <time.h>
+#include <errno.h>
+
+#include <sysdep-cancel.h>
+#include <bits/kernel-features.h>
+#include "kernel-posix-cpu-timers.h"
+
+
+#ifdef __ASSUME_POSIX_TIMERS
+/* We can simply use the syscall. The CPU clocks are not supported
+ with this function. */
+int
+clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req,
+ struct timespec *rem)
+{
+ INTERNAL_SYSCALL_DECL (err);
+ int r;
+
+ if (clock_id == CLOCK_THREAD_CPUTIME_ID)
+ return EINVAL;
+ if (clock_id == CLOCK_PROCESS_CPUTIME_ID)
+ clock_id = MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED);
+
+ if (SINGLE_THREAD_P)
+ r = INTERNAL_SYSCALL (clock_nanosleep, err, 4, clock_id, flags, req, rem);
+ else
+ {
+ int oldstate = LIBC_CANCEL_ASYNC ();
+
+ r = INTERNAL_SYSCALL (clock_nanosleep, err, 4, clock_id, flags, req,
+ rem);
+
+ LIBC_CANCEL_RESET (oldstate);
+ }
+
+ return (INTERNAL_SYSCALL_ERROR_P (r, err)
+ ? INTERNAL_SYSCALL_ERRNO (r, err) : 0);
+}
+
+#else
+# ifdef __NR_clock_nanosleep
+/* Is the syscall known to exist? */
+extern int __libc_missing_posix_timers attribute_hidden;
+
+/* The REALTIME and MONOTONIC clock might be available. Try the
+ syscall first. */
+# define SYSDEP_NANOSLEEP \
+ if (!__libc_missing_posix_timers) \
+ { \
+ clockid_t syscall_clockid; \
+ INTERNAL_SYSCALL_DECL (err); \
+ \
+ if (clock_id == CLOCK_THREAD_CPUTIME_ID) \
+ return EINVAL; \
+ if (clock_id == CLOCK_PROCESS_CPUTIME_ID) \
+ syscall_clockid = MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED); \
+ else \
+ syscall_clockid = clock_id; \
+ \
+ int oldstate = LIBC_CANCEL_ASYNC (); \
+ \
+ int r = INTERNAL_SYSCALL (clock_nanosleep, err, 4, \
+ syscall_clockid, flags, req, rem); \
+ \
+ LIBC_CANCEL_RESET (oldstate); \
+ \
+ if (!INTERNAL_SYSCALL_ERROR_P (r, err)) \
+ return 0; \
+ \
+ if (INTERNAL_SYSCALL_ERRNO (r, err) != ENOSYS) \
+ return INTERNAL_SYSCALL_ERRNO (r, err); \
+ \
+ __libc_missing_posix_timers = 1; \
+ }
+# endif
+
+# include <sysdeps/unix/clock_nanosleep.c>
+#endif
diff --git a/librt/dso_handle.c b/librt/dso_handle.c
new file mode 100644
index 000000000..633907103
--- /dev/null
+++ b/librt/dso_handle.c
@@ -0,0 +1,5 @@
+/* Copyright (C) 2015 Bernhard Reutner-Fischer
+ * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+ */
+
+const void *const __dso_handle attribute_hidden = &__dso_handle;
diff --git a/librt/kernel-posix-cpu-timers.h b/librt/kernel-posix-cpu-timers.h
new file mode 100644
index 000000000..164a90dde
--- /dev/null
+++ b/librt/kernel-posix-cpu-timers.h
@@ -0,0 +1,18 @@
+/* Parameters for the Linux kernel ABI for CPU clocks. */
+
+#define CPUCLOCK_PID(clock) ((pid_t) ~((clock) >> 3))
+#define CPUCLOCK_PERTHREAD(clock) \
+ (((clock) & (clockid_t) CPUCLOCK_PERTHREAD_MASK) != 0)
+#define CPUCLOCK_PID_MASK 7
+#define CPUCLOCK_PERTHREAD_MASK 4
+#define CPUCLOCK_WHICH(clock) ((clock) & (clockid_t) CPUCLOCK_CLOCK_MASK)
+#define CPUCLOCK_CLOCK_MASK 3
+#define CPUCLOCK_PROF 0
+#define CPUCLOCK_VIRT 1
+#define CPUCLOCK_SCHED 2
+#define CPUCLOCK_MAX 3
+
+#define MAKE_PROCESS_CPUCLOCK(pid, clock) \
+ ((~(clockid_t) (pid) << 3) | (clockid_t) (clock))
+#define MAKE_THREAD_CPUCLOCK(tid, clock) \
+ MAKE_PROCESS_CPUCLOCK((tid), (clock) | CPUCLOCK_PERTHREAD_MASK)
diff --git a/librt/kernel-posix-timers.h b/librt/kernel-posix-timers.h
index bf246c925..f8bfdc2ae 100644
--- a/librt/kernel-posix-timers.h
+++ b/librt/kernel-posix-timers.h
@@ -10,6 +10,25 @@
#include <pthread.h>
#endif
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+/* Nonzero if the system calls are not available. */
+extern int __no_posix_timers attribute_hidden;
+
+/* Callback to start helper thread. */
+extern void __start_helper_thread (void) attribute_hidden;
+
+/* Control variable for helper thread creation. */
+extern pthread_once_t __helper_once attribute_hidden;
+
+/* TID of the helper thread. */
+extern pid_t __helper_tid attribute_hidden;
+
+/* List of active SIGEV_THREAD timers. */
+extern struct timer *__active_timer_sigev_thread attribute_hidden;
+/* Lock for the __active_timer_sigev_thread. */
+extern pthread_mutex_t __active_timer_sigev_thread_lock attribute_hidden;
+#endif
+
/* Type of timers in the kernel */
typedef int kernel_timer_t;
@@ -33,4 +52,7 @@ struct timer {
#ifdef __UCLIBC_HAS_THREADS__
pthread_attr_t attr;
#endif
+
+ /* Next element in list of active SIGEV_THREAD timers. */
+ struct timer *next;
};
diff --git a/librt/mq_receive.c b/librt/mq_receive.c
index 3da88f391..2be1c1a98 100644
--- a/librt/mq_receive.c
+++ b/librt/mq_receive.c
@@ -2,20 +2,28 @@
* mq_receive.c - functions for receiving from message queue.
*/
-#include <errno.h>
-#include <stddef.h>
#include <sys/syscall.h>
+
+#ifdef __NR_mq_timedreceive
+
+#include <stddef.h>
#include <mqueue.h>
-#warning FIXME: hard dependency on ADVANCED REALTIME feature
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+# ifndef __UCLIBC_HAS_ADVANCED_REALTIME__
+extern ssize_t mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len,
+ unsigned int *msg_prio,
+ const struct timespec *abs_timeout);
+# endif
librt_hidden_proto(mq_timedreceive)
-#ifdef __NR_mq_timedreceive
-#define __NR___syscall_mq_timedreceive __NR_mq_timedreceive
-static __inline__ _syscall5(int, __syscall_mq_timedreceive, int, mqdes,
- char *, msg_ptr, size_t, msg_len, unsigned int *,
- msg_prio, const void *, abs_timeout);
-#endif
+#else
+
+# define __NR___syscall_mq_timedreceive __NR_mq_timedreceive
+static _syscall5(int, __syscall_mq_timedreceive, int, mqdes,
+ char *, msg_ptr, size_t, msg_len, unsigned int *,
+ msg_prio, const void *, abs_timeout)
+# ifdef __UCLIBC_HAS_ADVANCED_REALTIME__
/*
* Receive the oldest from highest priority messages.
* Stop waiting if abs_timeout expires.
@@ -24,20 +32,22 @@ ssize_t mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len,
unsigned int *msg_prio,
const struct timespec *abs_timeout)
{
-#ifdef __NR_mq_timedreceive
return __syscall_mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio,
abs_timeout);
-#else
- errno = ENOSYS;
- return -1;
-#endif
}
+# endif
-librt_hidden_def(mq_timedreceive)
+#endif
/* Receive the oldest from highest priority messages */
ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len,
unsigned int *msg_prio)
{
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
return mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, NULL);
+#else
+ return __syscall_mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, NULL);
+#endif
}
+
+#endif
diff --git a/librt/mq_send.c b/librt/mq_send.c
index 446ecc89a..5e50d1a19 100644
--- a/librt/mq_send.c
+++ b/librt/mq_send.c
@@ -2,20 +2,27 @@
* mq_send.c - functions for sending to message queue.
*/
-#include <errno.h>
-#include <stddef.h>
#include <sys/syscall.h>
+
+#ifdef __NR_mq_timedsend
+
+#include <stddef.h>
#include <mqueue.h>
-#warning FIXME: hard dependency on ADVANCED REALTIME feature
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+# ifndef __UCLIBC_HAS_ADVANCED_REALTIME__
+extern int mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
+ unsigned int msg_prio, const struct timespec *abs_timeout);
+# endif
librt_hidden_proto(mq_timedsend)
-#ifdef __NR_mq_timedsend
-#define __NR___syscall_mq_timedsend __NR_mq_timedsend
-static __inline__ _syscall5(int, __syscall_mq_timedsend, int, mqdes,
- const char *, msg_ptr, size_t, msg_len, unsigned int,
- msg_prio, const void *, abs_timeout);
-#endif
+#else
+
+# define __NR___syscall_mq_timedsend __NR_mq_timedsend
+static _syscall5(int, __syscall_mq_timedsend, int, mqdes,
+ const char *, msg_ptr, size_t, msg_len, unsigned int,
+ msg_prio, const void *, abs_timeout)
+# ifdef __UCLIBC_HAS_ADVANCED_REALTIME__
/*
* Add a message to queue. If O_NONBLOCK is set and queue is full, wait
* for sufficient room in the queue until abs_timeout expires.
@@ -23,20 +30,21 @@ static __inline__ _syscall5(int, __syscall_mq_timedsend, int, mqdes,
int mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
unsigned int msg_prio, const struct timespec *abs_timeout)
{
-#ifdef __NR_mq_timedsend
return __syscall_mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio,
abs_timeout);
-#else
- errno = ENOSYS;
- return -1;
-#endif
}
-
-librt_hidden_def(mq_timedsend)
+# endif
+#endif
/* Add a message to queue */
int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
unsigned int msg_prio)
{
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
return mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, NULL);
+#else
+ return __syscall_mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, NULL);
+#endif
}
+
+#endif
diff --git a/librt/mq_timedreceive.S b/librt/mq_timedreceive.S
new file mode 100644
index 000000000..00fecac03
--- /dev/null
+++ b/librt/mq_timedreceive.S
@@ -0,0 +1,8 @@
+#include <sysdep-cancel.h>
+#ifndef __NR_mq_timedreceive
+#error Missing definition of NR_timedreceive needed for cancellation.
+#endif
+PSEUDO(mq_timedreceive, mq_timedreceive, 5)
+ret_ERRVAL
+PSEUDO_END(mq_timedreceive)
+librt_hidden_def(mq_timedreceive)
diff --git a/librt/mq_timedsend.S b/librt/mq_timedsend.S
new file mode 100644
index 000000000..ee8d48334
--- /dev/null
+++ b/librt/mq_timedsend.S
@@ -0,0 +1,8 @@
+#include <sysdep-cancel.h>
+#ifndef __NR_mq_timedsend
+#error Missing definition of NR_timedsend needed for cancellation.
+#endif
+PSEUDO(mq_timedsend, mq_timedsend, 5)
+ret_ERRVAL
+PSEUDO_END(mq_timedsend)
+librt_hidden_def(mq_timedsend)
diff --git a/librt/rt_stubs.c b/librt/rt_stubs.c
new file mode 100644
index 000000000..a2b84e62a
--- /dev/null
+++ b/librt/rt_stubs.c
@@ -0,0 +1,40 @@
+/*
+ * system call not available stub
+ * based on libc's stubs.c
+ *
+ * Copyright (C) 2009 Analog Devices Inc.
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <errno.h>
+#include <sys/syscall.h>
+
+#ifdef __UCLIBC_HAS_STUBS__
+
+static int rt_enosys_stub(void) __attribute_used__;
+static int rt_enosys_stub(void)
+{
+ __set_errno(ENOSYS);
+ return -1;
+}
+
+#define make_stub(stub) \
+ link_warning(stub, #stub ": this function is not implemented") \
+ strong_alias(rt_enosys_stub, stub)
+
+#ifndef __NR_mq_timedreceive
+make_stub(mq_receive)
+# ifdef __UCLIBC_HAS_ADVANCED_REALTIME__
+make_stub(mq_timedreceive)
+# endif
+#endif
+
+#ifndef __NR_mq_timedsend
+make_stub(mq_send)
+# ifdef __UCLIBC_HAS_ADVANCED_REALTIME__
+make_stub(mq_timedsend)
+# endif
+#endif
+
+#endif
diff --git a/librt/shm.c b/librt/shm.c
new file mode 100644
index 000000000..40e69fa2e
--- /dev/null
+++ b/librt/shm.c
@@ -0,0 +1,102 @@
+/* Copyright (C) 2009 Bernhard Reutner-Fischer <uclibc@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <features.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+
+#ifndef _PATH_SHM
+#define _PATH_SHM "/dev/shm/"
+#endif
+
+#ifndef NAME_MAX
+#define NAME_MAX 255
+#endif
+
+/* Get name of dummy shm operation handle.
+ * Returns a malloc'ed buffer containing the OS specific path
+ * to the shm filename or NULL upon failure.
+ */
+static __attribute_noinline__ char* get_shm_name(const char *name) __nonnull((1));
+static char* get_shm_name(const char *name)
+{
+ char *path;
+ int i;
+
+ /* Skip leading slashes */
+ while (*name == '/')
+ ++name;
+#ifdef __USE_GNU
+ i = asprintf(&path, _PATH_SHM "%s", name);
+ if (i < 0)
+ return NULL;
+#else
+ path = malloc(NAME_MAX);
+ if (path == NULL)
+ return NULL;
+ i = snprintf(path, NAME_MAX, _PATH_SHM "%s", name);
+ if (i < 0) {
+ free(path);
+ return NULL;
+ } else if (i >= NAME_MAX) {
+ free(path);
+ __set_errno(ENAMETOOLONG);
+ return NULL;
+ }
+#endif
+ return path;
+}
+
+int shm_open(const char *name, int oflag, mode_t mode)
+{
+ int fd;
+ char *shm_name = get_shm_name(name);
+
+ /* Stripped multiple '/' from start; may have set errno properly */
+ if (shm_name == NULL)
+ return -1;
+ /* The FD_CLOEXEC file descriptor flag associated with the new
+ * file descriptor is set. */
+#ifdef O_CLOEXEC
+ /* Just open it with CLOEXEC set, for brevity */
+ fd = open(shm_name, oflag | O_CLOEXEC, mode);
+#else
+ fd = open(shm_name, oflag, mode);
+ if (fd >= 0) {
+ fcntl(fd, F_SETFD, FD_CLOEXEC);
+ /* thus far, {G,S}ETFD only has this single flag,
+ * and setting it never fails.
+ *int fdflags = fcntl(fd, F_GETFD);
+ *if (fdflags >= 0)
+ * fdflags = fcntl(fd, F_SETFD, fdflags | FD_CLOEXEC);
+ *if (fdflags < 0) {
+ * close(fd);
+ * fd = -1;
+ *}
+ */
+ }
+#endif
+ free(shm_name); /* doesn't affect errno */
+ return fd;
+}
+
+int shm_unlink(const char *name)
+{
+ char *shm_name = get_shm_name(name);
+ int ret;
+
+ /* Stripped multiple '/' from start; may have set errno properly */
+ if (shm_name == NULL)
+ return -1;
+ ret = unlink(shm_name);
+ free(shm_name); /* doesn't affect errno */
+ return ret;
+}
diff --git a/librt/spawn.c b/librt/spawn.c
new file mode 100644
index 000000000..07d40193c
--- /dev/null
+++ b/librt/spawn.c
@@ -0,0 +1,266 @@
+/* Copyright (C) 2000, 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 <errno.h>
+#include <alloca.h>
+#include <unistd.h>
+#include <signal.h>
+#include <stdbool.h>
+#include <fcntl.h>
+
+#include <sys/resource.h>
+#include <not-cancel.h>
+
+#include <spawn.h>
+#include "spawn_int.h"
+
+/* The Unix standard contains a long explanation of the way to signal
+ an error after the fork() was successful. Since no new wait status
+ was wanted there is no way to signal an error using one of the
+ available methods. The committee chose to signal an error by a
+ normal program exit with the exit code 127. */
+#define SPAWN_ERROR 127
+
+/* Execute file actions.
+ * Returns true on error.
+ */
+inline static bool execute_file_actions(const posix_spawn_file_actions_t *fa)
+{
+ struct rlimit64 fdlimit;
+ bool have_fdlimit = false;
+ int cnt;
+
+ for (cnt = 0; cnt < fa->__used; ++cnt) {
+ struct __spawn_action *action = &fa->__actions[cnt];
+
+ switch (action->tag) {
+ case spawn_do_close:
+ if (close_not_cancel(action->action.close_action.fd) != 0) {
+ if (!have_fdlimit) {
+ getrlimit64(RLIMIT_NOFILE, &fdlimit);
+ have_fdlimit = true;
+ }
+
+ /* Only signal errors for file descriptors out of range. */
+ if (0 > action->action.close_action.fd
+ || action->action.close_action.fd >= fdlimit.rlim_cur)
+ /* Signal the error. */
+ return true;
+ }
+ break;
+
+ case spawn_do_open:;
+ int new_fd = open_not_cancel(action->action.open_action.path,
+ action->action.open_action.oflag
+ | O_LARGEFILE,
+ action->action.open_action.mode);
+
+ if (new_fd == -1)
+ return true;
+
+ /* Make sure the desired file descriptor is used. */
+ if (new_fd != action->action.open_action.fd) {
+ if (dup2(new_fd, action->action.open_action.fd)
+ != action->action.open_action.fd)
+ return true;
+
+ if (close_not_cancel(new_fd) != 0)
+ return true;
+ }
+ break;
+
+ case spawn_do_dup2:
+ if (dup2(action->action.dup2_action.fd,
+ action->action.dup2_action.newfd)
+ != action->action.dup2_action.newfd)
+ return true;
+ break;
+ }
+ }
+
+ return false;
+}
+
+#define DANGEROUS (POSIX_SPAWN_SETSIGMASK \
+ | POSIX_SPAWN_SETSIGDEF \
+ | POSIX_SPAWN_SETSCHEDPARAM \
+ | POSIX_SPAWN_SETSCHEDULER \
+ | POSIX_SPAWN_SETPGROUP \
+ | POSIX_SPAWN_RESETIDS)
+inline static bool is_vfork_safe(short int flags)
+{
+ return ((flags & POSIX_SPAWN_USEVFORK) || !(flags & DANGEROUS));
+}
+
+
+/* Spawn a new process executing PATH with the attributes describes in *ATTRP.
+ Before running the process perform the actions described in FILE-ACTIONS. */
+static int
+__spawni(pid_t *pid, const char *file,
+ const posix_spawn_file_actions_t *fa,
+ const posix_spawnattr_t *attrp, char *const argv[],
+ char *const envp[], const char *path)
+{
+ short int flags = attrp ? attrp->__flags : 0;
+
+ pid_t new_pid;
+ if (is_vfork_safe(flags) && !fa)
+ new_pid = vfork();
+ else {
+#ifdef __ARCH_USE_MMU__
+ new_pid = fork();
+#else
+ return ENOSYS;
+#endif
+ }
+
+ if (new_pid) {
+ if (new_pid < 0)
+ return errno;
+
+ if (pid)
+ *pid = new_pid;
+
+ return 0;
+ }
+
+ if (flags & POSIX_SPAWN_SETSIGMASK) {
+ if (sigprocmask(SIG_SETMASK, &attrp->__ss, NULL) != 0)
+ goto error;
+ }
+
+ if (flags & POSIX_SPAWN_SETSIGDEF) {
+ /* We have to iterate over all signals. This could possibly be
+ done better but it requires system specific solutions since
+ the sigset_t data type can be very different on different
+ architectures. */
+ struct sigaction sa;
+ int sig;
+
+ memset(&sa, 0, sizeof(sa));
+ sa.sa_handler = SIG_DFL;
+
+ for (sig = 1; sig <= _NSIG; ++sig) {
+ if (sigismember(&attrp->__sd, sig)) {
+ if (sigaction(sig, &sa, NULL) != 0)
+ goto error;
+ }
+ }
+ }
+
+ if (flags & POSIX_SPAWN_SETSCHEDULER) {
+ if (sched_setscheduler(0, attrp->__policy, &attrp->__sp) == -1)
+ goto error;
+ } else if (flags & POSIX_SPAWN_SETSCHEDPARAM) {
+ if (sched_setparam(0, &attrp->__sp) == -1)
+ goto error;
+ }
+
+ if (flags & POSIX_SPAWN_SETPGROUP) {
+ if (setpgid(0, attrp->__pgrp) != 0)
+ goto error;
+ }
+
+ if (flags & POSIX_SPAWN_RESETIDS) {
+ if (seteuid(getuid()) || setegid(getgid()))
+ goto error;
+ }
+
+ if (fa && execute_file_actions(fa))
+ goto error;
+
+ if (!path || strchr(file, '/')) {
+ execve(file, argv, envp);
+ goto error;
+ }
+
+
+ char *name;
+ {
+ size_t filelen = strlen(file) + 1;
+ size_t pathlen = strlen(path) + 1;
+ name = alloca(pathlen + filelen);
+
+ /* Copy the file name at the top. */
+ name = (char *) memcpy(name + pathlen, file, filelen);
+
+ /* And add the slash. */
+ *--name = '/';
+ }
+
+ char *p;
+ do {
+ char *startp;
+ p = strchrnul(path, ':');
+
+ /* Two adjacent colons, or a colon at the beginning or the end
+ of `PATH' means to search the current directory. */
+ if (p == path)
+ startp = name + 1;
+ else
+ startp = (char *) memcpy(name - (p - path), path, p - path);
+
+ execve(startp, argv, envp);
+
+ switch (errno) {
+ case EACCES:
+ case ENOENT:
+ case ESTALE:
+ case ENOTDIR:
+ /* Those errors indicate the file is missing or not
+ executable by us, in which case we want to just try
+ the next path directory. */
+ break;
+ default:
+ /* Some other error means we found an executable file,
+ but something went wrong executing it; return the
+ error to our caller. */
+ goto error;
+ }
+
+ path = p;
+ } while (*p++ != '\0');
+
+error:
+ _exit(SPAWN_ERROR);
+}
+
+/* Spawn a new process executing PATH with the attributes describes in *ATTRP.
+ Before running the process perform the actions described in FILE-ACTIONS. */
+int posix_spawn (pid_t *pid, const char *path,
+ const posix_spawn_file_actions_t *fa,
+ const posix_spawnattr_t *attrp, char *const argv[],
+ char *const envp[])
+{
+ return __spawni(pid, path, fa, attrp, argv, envp, NULL);
+}
+
+/* Spawn a new process executing FILE with the attributes describes in *ATTRP.
+ Before running the process perform the actions described in FILE-ACTIONS. */
+int
+posix_spawnp(pid_t *pid, const char *file,
+ const posix_spawn_file_actions_t *fa,
+ const posix_spawnattr_t *attrp, char *const argv[],
+ char *const envp[])
+{
+ const char *path = getenv("PATH");
+
+ if (!path)
+ path = ":/bin:/usr/bin";
+
+ return __spawni(pid, file, fa, attrp, argv, envp, path);
+}
diff --git a/librt/spawn_faction_addclose.c b/librt/spawn_faction_addclose.c
new file mode 100644
index 000000000..b418f962f
--- /dev/null
+++ b/librt/spawn_faction_addclose.c
@@ -0,0 +1,51 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <spawn.h>
+#include <unistd.h>
+
+#include "spawn_int.h"
+
+/* Add an action to FILE-ACTIONS which tells the implementation to call
+ `close' for the given file descriptor during the `spawn' call. */
+int
+posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *file_actions,
+ int fd)
+{
+ int maxfd = sysconf(_SC_OPEN_MAX);
+ struct __spawn_action *rec;
+
+ /* Test for the validity of the file descriptor. */
+ if (fd < 0 || fd >= maxfd)
+ return EBADF;
+
+ /* Allocate more memory if needed. */
+ if (file_actions->__used == file_actions->__allocated
+ && __posix_spawn_file_actions_realloc(file_actions) != 0)
+ /* This can only mean we ran out of memory. */
+ return ENOMEM;
+
+ /* Add the new value. */
+ rec = &file_actions->__actions[file_actions->__used];
+ rec->tag = spawn_do_close;
+ rec->action.open_action.fd = fd;
+
+ /* Account for the new entry. */
+ ++file_actions->__used;
+ return 0;
+}
diff --git a/librt/spawn_faction_adddup2.c b/librt/spawn_faction_adddup2.c
new file mode 100644
index 000000000..6d7331326
--- /dev/null
+++ b/librt/spawn_faction_adddup2.c
@@ -0,0 +1,52 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <spawn.h>
+#include <unistd.h>
+
+#include "spawn_int.h"
+
+/* Add an action to FILE-ACTIONS which tells the implementation to call
+ `dup2' for the given file descriptors during the `spawn' call. */
+int
+posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *file_actions,
+ int fd, int newfd)
+{
+ int maxfd = sysconf(_SC_OPEN_MAX);
+ struct __spawn_action *rec;
+
+ /* Test for the validity of the file descriptor. */
+ if (fd < 0 || newfd < 0 || fd >= maxfd || newfd >= maxfd)
+ return EBADF;
+
+ /* Allocate more memory if needed. */
+ if (file_actions->__used == file_actions->__allocated
+ && __posix_spawn_file_actions_realloc (file_actions) != 0)
+ /* This can only mean we ran out of memory. */
+ return ENOMEM;
+
+ /* Add the new value. */
+ rec = &file_actions->__actions[file_actions->__used];
+ rec->tag = spawn_do_dup2;
+ rec->action.dup2_action.fd = fd;
+ rec->action.dup2_action.newfd = newfd;
+
+ /* Account for the new entry. */
+ ++file_actions->__used;
+ return 0;
+}
diff --git a/librt/spawn_faction_addopen.c b/librt/spawn_faction_addopen.c
new file mode 100644
index 000000000..285ca715e
--- /dev/null
+++ b/librt/spawn_faction_addopen.c
@@ -0,0 +1,55 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <spawn.h>
+#include <unistd.h>
+
+#include "spawn_int.h"
+
+/* Add an action to FILE-ACTIONS which tells the implementation to call
+ `open' for the given file during the `spawn' call. */
+int
+posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *file_actions,
+ int fd, const char *path, int oflag,
+ mode_t mode)
+{
+ int maxfd = sysconf(_SC_OPEN_MAX);
+ struct __spawn_action *rec;
+
+ /* Test for the validity of the file descriptor. */
+ if (fd < 0 || fd >= maxfd)
+ return EBADF;
+
+ /* Allocate more memory if needed. */
+ if (file_actions->__used == file_actions->__allocated
+ && __posix_spawn_file_actions_realloc (file_actions) != 0)
+ /* This can only mean we ran out of memory. */
+ return ENOMEM;
+
+ /* Add the new value. */
+ rec = &file_actions->__actions[file_actions->__used];
+ rec->tag = spawn_do_open;
+ rec->action.open_action.fd = fd;
+ rec->action.open_action.path = path;
+ rec->action.open_action.oflag = oflag;
+ rec->action.open_action.mode = mode;
+
+ /* Account for the new entry. */
+ ++file_actions->__used;
+ return 0;
+}
diff --git a/librt/spawn_faction_init.c b/librt/spawn_faction_init.c
new file mode 100644
index 000000000..fb398a566
--- /dev/null
+++ b/librt/spawn_faction_init.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <spawn.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "spawn_int.h"
+
+
+/* Function used to increase the size of the allocated array. This
+ function is called from the `add'-functions. */
+int
+__posix_spawn_file_actions_realloc(posix_spawn_file_actions_t *file_actions)
+{
+ int newalloc = file_actions->__allocated + 8;
+ void *newmem = realloc(file_actions->__actions,
+ newalloc * sizeof(struct __spawn_action));
+
+ if (newmem == NULL)
+ /* Not enough memory. */
+ return ENOMEM;
+
+ file_actions->__actions = (struct __spawn_action *)newmem;
+ file_actions->__allocated = newalloc;
+ return 0;
+}
diff --git a/librt/spawn_int.h b/librt/spawn_int.h
new file mode 100644
index 000000000..1d990fc33
--- /dev/null
+++ b/librt/spawn_int.h
@@ -0,0 +1,35 @@
+/* Data structure to contain the action information. */
+struct __spawn_action {
+ enum {
+ spawn_do_close,
+ spawn_do_dup2,
+ spawn_do_open
+ } tag;
+
+ union {
+ struct {
+ int fd;
+ } close_action;
+ struct {
+ int fd;
+ int newfd;
+ } dup2_action;
+ struct {
+ int fd;
+ const char *path;
+ int oflag;
+ mode_t mode;
+ } open_action;
+ } action;
+};
+
+int __posix_spawn_file_actions_realloc(posix_spawn_file_actions_t *fa);
+
+/* handle !LFS */
+#ifndef __UCLIBC_HAS_LFS__
+# define rlimit64 rlimit
+# define getrlimit64 getrlimit
+#endif
+#ifndef O_LARGEFILE
+# define O_LARGEFILE 0
+#endif
diff --git a/librt/timer_create.c b/librt/timer_create.c
index 9298a37c7..f52a36ff9 100644
--- a/librt/timer_create.c
+++ b/librt/timer_create.c
@@ -2,6 +2,7 @@
* timer_create.c - create a per-process timer.
*/
+#include <stddef.h>
#include <errno.h>
#include <signal.h>
#include <stdlib.h>
@@ -13,10 +14,6 @@
#ifdef __NR_timer_create
-#ifndef offsetof
-# define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
-#endif
-
#define __NR___syscall_timer_create __NR_timer_create
static __inline__ _syscall3(int, __syscall_timer_create, clockid_t, clock_id,
struct sigevent *, evp, kernel_timer_t *, ktimerid);
diff --git a/libuargp/Makefile b/libuargp/Makefile
new file mode 100644
index 000000000..45acdd9aa
--- /dev/null
+++ b/libuargp/Makefile
@@ -0,0 +1,14 @@
+# Makefile for uClibc (libuargp)
+#
+# Copyright (C) 2010 STMicroelectronics Ltd
+# Author(s): Filippo Arcidiacono <filippo.arcidiacono at st.com>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+top_srcdir=../
+top_builddir=../
+include $(top_builddir)Rules.mak
+all: libs
+include Makefile.in
+include $(top_srcdir)Makerules
diff --git a/libuargp/Makefile.in b/libuargp/Makefile.in
new file mode 100644
index 000000000..1498abb69
--- /dev/null
+++ b/libuargp/Makefile.in
@@ -0,0 +1,73 @@
+# Makefile for uClibc (libuargp)
+#
+# Copyright (C) 2009, 2010 STMicroelectronics Ltd.
+# Author(s): Salvatore Cro <salvatore.cro at st.com>
+# - First implementation, embedded into libc
+# Filippo Arcidiacono <filippo.arcidiacono at st.com>
+# - Reworked for stand-alone libuargp implementation
+
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+CFLAGS-libuargp := -DNOT_IN_libc -DIS_IN_libuargp $(SSP_ALL_CFLAGS)
+
+LDFLAGS-libuargp.so := $(LDFLAGS)
+
+LIBS-libuargp.so := $(LIBS)
+
+libuargp_FULL_NAME := libuargp-$(VERSION).so
+
+libuargp_DIR := $(top_srcdir)libuargp
+libuargp_OUT := $(top_builddir)libuargp
+
+libuargp_SRC-y :=
+libuargp_SRC-$(UCLIBC_HAS_ARGP) := $(addsuffix .c,$(addprefix argp-, ba \
+ eexst fmtstream fs-xinl help parse pv pvh xinl))
+
+CFLAGS-argp-xinl.c = -fgnu89-inline
+
+libuargp_SRC := $(addprefix $(libuargp_DIR)/,$(libuargp_SRC-y))
+libuargp_OBJ := $(patsubst $(libuargp_DIR)/%.c,$(libuargp_OUT)/%.o,$(libuargp_SRC))
+
+libuargp_SRCS := $(libuargp_SRC)
+libuargp_OBJS := $(libuargp_OBJ)
+
+ifeq ($(DOPIC),y)
+libuargp-a-y := $(libuargp_OBJS:.o=.os)
+else
+libuargp-a-y := $(libuargp_OBJS)
+endif
+libuargp-so-y := $(libuargp_OBJS:.o=.os)
+
+lib-a-$(UCLIBC_HAS_ARGP) += $(top_builddir)lib/libuargp.a
+lib-so-$(UCLIBC_HAS_ARGP) += $(top_builddir)lib/libuargp.so
+
+objclean-y += CLEAN_libuargp
+
+ifeq ($(DOMULTI),n)
+ifeq ($(DOPIC),y)
+$(top_builddir)lib/libuargp.so: $(top_builddir)lib/libuargp.a $(libc.depend)
+else
+$(top_builddir)lib/libuargp.so: $(libuargp_OUT)/libuargp_so.a $(libc.depend)
+endif
+ $(call link.so,$(libuargp_FULL_NAME),$(MAJOR_VERSION))
+else
+$(top_builddir)lib/libuargp.so: $(libuargp_OUT)/libuargp.oS $(libc.depend)
+ $(call linkm.so,$(libuargp_FULL_NAME),$(MAJOR_VERSION))
+endif
+
+$(libuargp_OUT)/libuargp_so.a: $(libuargp-so-y)
+ $(Q)$(RM) $@
+ $(do_ar)
+
+$(libuargp_OUT)/libuargp.oS: $(libuargp_SRCS)
+ $(Q)$(RM) $@
+ $(compile-m)
+
+$(top_builddir)lib/libuargp.a: $(libuargp-a-y)
+ $(Q)$(INSTALL) -d $(dir $@)
+ $(Q)$(RM) $@
+ $(do_ar)
+
+CLEAN_libuargp:
+ $(do_rm) $(addprefix $(libuargp_OUT)/*., o os oS a)
diff --git a/libuargp/argp-ba.c b/libuargp/argp-ba.c
new file mode 100644
index 000000000..3522b029b
--- /dev/null
+++ b/libuargp/argp-ba.c
@@ -0,0 +1,26 @@
+/* Default definition for ARGP_PROGRAM_BUG_ADDRESS.
+ Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Miles Bader <miles at gnu.ai.mit.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. */
+
+/* If set by the user program, it should point to string that is the
+ bug-reporting address for the program. It will be printed by argp_help if
+ the ARGP_HELP_BUG_ADDR flag is set (as it is by various standard help
+ messages), embedded in a sentence that says something like `Report bugs to
+ ADDR.'. */
+const char *argp_program_bug_address;
diff --git a/libuargp/argp-eexst.c b/libuargp/argp-eexst.c
new file mode 100644
index 000000000..445b68d1f
--- /dev/null
+++ b/libuargp/argp-eexst.c
@@ -0,0 +1,32 @@
+/* Default definition for ARGP_ERR_EXIT_STATUS
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Miles Bader <miles at gnu.ai.mit.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. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <sysexits.h>
+
+#include <argp.h>
+
+/* The exit status that argp will use when exiting due to a parsing error.
+ If not defined or set by the user program, this defaults to EX_USAGE from
+ <sysexits.h>. */
+error_t argp_err_exit_status = EX_USAGE;
diff --git a/libuargp/argp-fmtstream.c b/libuargp/argp-fmtstream.c
new file mode 100644
index 000000000..75227f93c
--- /dev/null
+++ b/libuargp/argp-fmtstream.c
@@ -0,0 +1,439 @@
+/* Word-wrapping and line-truncating streams
+ Copyright (C) 1997-1999,2001,2002,2003,2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Miles Bader <miles at gnu.ai.mit.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.
+
+ Modified for uClibc by: Salvatore Cro <salvatore.cro at st.com>
+*/
+
+/* This package emulates glibc `line_wrap_stream' semantics for systems that
+ don't have that. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <ctype.h>
+
+#include "argp-fmtstream.h"
+
+#ifndef ARGP_FMTSTREAM_USE_LINEWRAP
+
+#ifndef isblank
+#define isblank(ch) ((ch)==' ' || (ch)=='\t')
+#endif
+
+#if defined _LIBC && defined USE_IN_LIBIO
+# include <wchar.h>
+# include <libio/libioP.h>
+# define __vsnprintf(s, l, f, a) _IO_vsnprintf (s, l, f, a)
+#else
+# define __vsnprintf(s, l, f, a) vsnprintf (s, l, f, a)
+#endif
+
+#define INIT_BUF_SIZE 200
+#define PRINTF_SIZE_GUESS 150
+
+/* Return an argp_fmtstream that outputs to STREAM, and which prefixes lines
+ written on it with LMARGIN spaces and limits them to RMARGIN columns
+ total. If WMARGIN >= 0, words that extend past RMARGIN are wrapped by
+ replacing the whitespace before them with a newline and WMARGIN spaces.
+ Otherwise, chars beyond RMARGIN are simply dropped until a newline.
+ Returns NULL if there was an error. */
+argp_fmtstream_t
+__argp_make_fmtstream (FILE *stream,
+ size_t lmargin, size_t rmargin, ssize_t wmargin)
+{
+ argp_fmtstream_t fs;
+
+ fs = (struct argp_fmtstream *) malloc (sizeof (struct argp_fmtstream));
+ if (fs != NULL)
+ {
+ fs->stream = stream;
+
+ fs->lmargin = lmargin;
+ fs->rmargin = rmargin;
+ fs->wmargin = wmargin;
+ fs->point_col = 0;
+ fs->point_offs = 0;
+
+ fs->buf = (char *) malloc (INIT_BUF_SIZE);
+ if (! fs->buf)
+ {
+ free (fs);
+ fs = 0;
+ }
+ else
+ {
+ fs->p = fs->buf;
+ fs->end = fs->buf + INIT_BUF_SIZE;
+ }
+ }
+
+ return fs;
+}
+#if 0
+/* Not exported. */
+#ifdef weak_alias
+weak_alias (__argp_make_fmtstream, argp_make_fmtstream)
+#endif
+#endif
+
+/* Flush FS to its stream, and free it (but don't close the stream). */
+void
+__argp_fmtstream_free (argp_fmtstream_t fs)
+{
+ __argp_fmtstream_update (fs);
+ if (fs->p > fs->buf)
+ {
+#ifdef USE_IN_LIBIO
+ __fxprintf (fs->stream, "%.*s", (int) (fs->p - fs->buf), fs->buf);
+#else
+ fwrite_unlocked (fs->buf, 1, fs->p - fs->buf, fs->stream);
+#endif
+ }
+ free (fs->buf);
+ free (fs);
+}
+#if 0
+/* Not exported. */
+#ifdef weak_alias
+weak_alias (__argp_fmtstream_free, argp_fmtstream_free)
+#endif
+#endif
+
+/* Process FS's buffer so that line wrapping is done from POINT_OFFS to the
+ end of its buffer. This code is mostly from glibc stdio/linewrap.c. */
+void
+__argp_fmtstream_update (argp_fmtstream_t fs)
+{
+ char *buf, *nl;
+ size_t len;
+
+ /* Scan the buffer for newlines. */
+ buf = fs->buf + fs->point_offs;
+ while (buf < fs->p)
+ {
+ size_t r;
+
+ if (fs->point_col == 0 && fs->lmargin != 0)
+ {
+ /* We are starting a new line. Print spaces to the left margin. */
+ const size_t pad = fs->lmargin;
+ if (fs->p + pad < fs->end)
+ {
+ /* We can fit in them in the buffer by moving the
+ buffer text up and filling in the beginning. */
+ memmove (buf + pad, buf, fs->p - buf);
+ fs->p += pad; /* Compensate for bigger buffer. */
+ memset (buf, ' ', pad); /* Fill in the spaces. */
+ buf += pad; /* Don't bother searching them. */
+ }
+ else
+ {
+ /* No buffer space for spaces. Must flush. */
+ size_t i;
+ for (i = 0; i < pad; i++)
+ {
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (fs->stream, 0) > 0)
+ putwc_unlocked (L' ', fs->stream);
+ else
+#endif
+ putc_unlocked (' ', fs->stream);
+ }
+ }
+ fs->point_col = pad;
+ }
+
+ len = fs->p - buf;
+ nl = memchr (buf, '\n', len);
+
+ if (fs->point_col < 0)
+ fs->point_col = 0;
+
+ if (!nl)
+ {
+ /* The buffer ends in a partial line. */
+
+ if (fs->point_col + len < fs->rmargin)
+ {
+ /* The remaining buffer text is a partial line and fits
+ within the maximum line width. Advance point for the
+ characters to be written and stop scanning. */
+ fs->point_col += len;
+ break;
+ }
+ else
+ /* Set the end-of-line pointer for the code below to
+ the end of the buffer. */
+ nl = fs->p;
+ }
+ else if (fs->point_col + (nl - buf) < (ssize_t) fs->rmargin)
+ {
+ /* The buffer contains a full line that fits within the maximum
+ line width. Reset point and scan the next line. */
+ fs->point_col = 0;
+ buf = nl + 1;
+ continue;
+ }
+
+ /* This line is too long. */
+ r = fs->rmargin - 1;
+
+ if (fs->wmargin < 0)
+ {
+ /* Truncate the line by overwriting the excess with the
+ newline and anything after it in the buffer. */
+ if (nl < fs->p)
+ {
+ memmove (buf + (r - fs->point_col), nl, fs->p - nl);
+ fs->p -= buf + (r - fs->point_col) - nl;
+ /* Reset point for the next line and start scanning it. */
+ fs->point_col = 0;
+ buf += r + 1; /* Skip full line plus \n. */
+ }
+ else
+ {
+ /* The buffer ends with a partial line that is beyond the
+ maximum line width. Advance point for the characters
+ written, and discard those past the max from the buffer. */
+ fs->point_col += len;
+ fs->p -= fs->point_col - r;
+ break;
+ }
+ }
+ else
+ {
+ /* Do word wrap. Go to the column just past the maximum line
+ width and scan back for the beginning of the word there.
+ Then insert a line break. */
+
+ char *p, *nextline;
+ int i;
+
+ p = buf + (r + 1 - fs->point_col);
+ while (p >= buf && !isblank (*p))
+ --p;
+ nextline = p + 1; /* This will begin the next line. */
+
+ if (nextline > buf)
+ {
+ /* Swallow separating blanks. */
+ if (p >= buf)
+ do
+ --p;
+ while (p >= buf && isblank (*p));
+ nl = p + 1; /* The newline will replace the first blank. */
+ }
+ else
+ {
+ /* A single word that is greater than the maximum line width.
+ Oh well. Put it on an overlong line by itself. */
+ p = buf + (r + 1 - fs->point_col);
+ /* Find the end of the long word. */
+ do
+ ++p;
+ while (p < nl && !isblank (*p));
+ if (p == nl)
+ {
+ /* It already ends a line. No fussing required. */
+ fs->point_col = 0;
+ buf = nl + 1;
+ continue;
+ }
+ /* We will move the newline to replace the first blank. */
+ nl = p;
+ /* Swallow separating blanks. */
+ do
+ ++p;
+ while (isblank (*p));
+ /* The next line will start here. */
+ nextline = p;
+ }
+
+ /* Note: There are a bunch of tests below for
+ NEXTLINE == BUF + LEN + 1; this case is where NL happens to fall
+ at the end of the buffer, and NEXTLINE is in fact empty (and so
+ we need not be careful to maintain its contents). */
+
+ if ((nextline == buf + len + 1
+ ? fs->end - nl < fs->wmargin + 1
+ : nextline - (nl + 1) < fs->wmargin)
+ && fs->p > nextline)
+ {
+ /* The margin needs more blanks than we removed. */
+ if (fs->end - fs->p > fs->wmargin + 1)
+ /* Make some space for them. */
+ {
+ size_t mv = fs->p - nextline;
+ memmove (nl + 1 + fs->wmargin, nextline, mv);
+ nextline = nl + 1 + fs->wmargin;
+ len = nextline + mv - buf;
+ *nl++ = '\n';
+ }
+ else
+ /* Output the first line so we can use the space. */
+ {
+#if defined _LIBC && defined USE_IN_LIBIO
+ __fxprintf (fs->stream, "%.*s\n",
+ (int) (nl - fs->buf), fs->buf);
+#else
+ if (nl > fs->buf)
+ fwrite_unlocked (fs->buf, 1, nl - fs->buf, fs->stream);
+ putc_unlocked ('\n', fs->stream);
+#endif
+
+ len += buf - fs->buf;
+ nl = buf = fs->buf;
+ }
+ }
+ else
+ /* We can fit the newline and blanks in before
+ the next word. */
+ *nl++ = '\n';
+
+ if (nextline - nl >= fs->wmargin
+ || (nextline == buf + len + 1 && fs->end - nextline >= fs->wmargin))
+ /* Add blanks up to the wrap margin column. */
+ for (i = 0; i < fs->wmargin; ++i)
+ *nl++ = ' ';
+ else
+ for (i = 0; i < fs->wmargin; ++i)
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (fs->stream, 0) > 0)
+ putwc_unlocked (L' ', fs->stream);
+ else
+#endif
+ putc_unlocked (' ', fs->stream);
+
+ /* Copy the tail of the original buffer into the current buffer
+ position. */
+ if (nl < nextline)
+ memmove (nl, nextline, buf + len - nextline);
+ len -= nextline - buf;
+
+ /* Continue the scan on the remaining lines in the buffer. */
+ buf = nl;
+
+ /* Restore bufp to include all the remaining text. */
+ fs->p = nl + len;
+
+ /* Reset the counter of what has been output this line. If wmargin
+ is 0, we want to avoid the lmargin getting added, so we set
+ point_col to a magic value of -1 in that case. */
+ fs->point_col = fs->wmargin ? fs->wmargin : -1;
+ }
+ }
+
+ /* Remember that we've scanned as far as the end of the buffer. */
+ fs->point_offs = fs->p - fs->buf;
+}
+
+/* Ensure that FS has space for AMOUNT more bytes in its buffer, either by
+ growing the buffer, or by flushing it. True is returned iff we succeed. */
+int
+__argp_fmtstream_ensure (struct argp_fmtstream *fs, size_t amount)
+{
+ if ((size_t) (fs->end - fs->p) < amount)
+ {
+ ssize_t wrote;
+
+ /* Flush FS's buffer. */
+ __argp_fmtstream_update (fs);
+
+#if defined _LIBC && defined USE_IN_LIBIO
+ __fxprintf (fs->stream, "%.*s", (int) (fs->p - fs->buf), fs->buf);
+ wrote = fs->p - fs->buf;
+#else
+ wrote = fwrite_unlocked (fs->buf, 1, fs->p - fs->buf, fs->stream);
+#endif
+ if (wrote == fs->p - fs->buf)
+ {
+ fs->p = fs->buf;
+ fs->point_offs = 0;
+ }
+ else
+ {
+ fs->p -= wrote;
+ fs->point_offs -= wrote;
+ memmove (fs->buf, fs->buf + wrote, fs->p - fs->buf);
+ return 0;
+ }
+
+ if ((size_t) (fs->end - fs->buf) < amount)
+ /* Gotta grow the buffer. */
+ {
+ size_t old_size = fs->end - fs->buf;
+ size_t new_size = old_size + amount;
+ char *new_buf;
+
+ if (new_size < old_size || ! (new_buf = realloc (fs->buf, new_size)))
+ {
+ __set_errno (ENOMEM);
+ return 0;
+ }
+
+ fs->buf = new_buf;
+ fs->end = new_buf + new_size;
+ fs->p = fs->buf;
+ }
+ }
+
+ return 1;
+}
+
+ssize_t
+__argp_fmtstream_printf (struct argp_fmtstream *fs, const char *fmt, ...)
+{
+ int out;
+ size_t avail;
+ size_t size_guess = PRINTF_SIZE_GUESS; /* How much space to reserve. */
+
+ do
+ {
+ va_list args;
+
+ if (! __argp_fmtstream_ensure (fs, size_guess))
+ return -1;
+
+ va_start (args, fmt);
+ avail = fs->end - fs->p;
+ out = __vsnprintf (fs->p, avail, fmt, args);
+ va_end (args);
+ if ((size_t) out >= avail)
+ size_guess = out + 1;
+ }
+ while ((size_t) out >= avail);
+
+ fs->p += out;
+
+ return out;
+}
+#if 0
+/* Not exported. */
+#ifdef weak_alias
+weak_alias (__argp_fmtstream_printf, argp_fmtstream_printf)
+#endif
+#endif
+
+#endif /* !ARGP_FMTSTREAM_USE_LINEWRAP */
diff --git a/libuargp/argp-fmtstream.h b/libuargp/argp-fmtstream.h
new file mode 100644
index 000000000..ca7c83402
--- /dev/null
+++ b/libuargp/argp-fmtstream.h
@@ -0,0 +1,314 @@
+/* Word-wrapping and line-truncating streams.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Miles Bader <miles at gnu.ai.mit.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.
+
+ Modified for uClibc by: Salvatore Cro <salvatore.cro at st.com>
+*/
+
+/* This package emulates glibc `line_wrap_stream' semantics for systems that
+ don't have that. If the system does have it, it is just a wrapper for
+ that. This header file is only used internally while compiling argp, and
+ shouldn't be installed. */
+
+#ifndef _ARGP_FMTSTREAM_H
+#define _ARGP_FMTSTREAM_H
+
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#ifndef __attribute__
+/* This feature is available in gcc versions 2.5 and later. */
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || defined(__STRICT_ANSI__)
+# define __attribute__(Spec) /* empty */
+# endif
+/* The __-protected variants of `format' and `printf' attributes
+ are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) || defined(__STRICT_ANSI__)
+# define __format__ format
+# define __printf__ printf
+# endif
+#endif
+
+#if 0 /* uClibc: disabled */
+#if (_LIBC - 0 && !defined (USE_IN_LIBIO)) \
+ || (defined (__GNU_LIBRARY__) && defined (HAVE_LINEWRAP_H))
+/* line_wrap_stream is available, so use that. */
+#define ARGP_FMTSTREAM_USE_LINEWRAP
+#endif
+#else
+/* line_wrap stream NOT available */
+# undef ARGP_FMTSTREAM_USE_LINEWRAP
+#endif
+
+#ifdef ARGP_FMTSTREAM_USE_LINEWRAP
+/* Just be a simple wrapper for line_wrap_stream; the semantics are
+ *slightly* different, as line_wrap_stream doesn't actually make a new
+ object, it just modifies the given stream (reversibly) to do
+ line-wrapping. Since we control who uses this code, it doesn't matter. */
+
+#include <linewrap.h>
+
+typedef FILE *argp_fmtstream_t;
+
+#define argp_make_fmtstream line_wrap_stream
+#define __argp_make_fmtstream line_wrap_stream
+#define argp_fmtstream_free line_unwrap_stream
+#define __argp_fmtstream_free line_unwrap_stream
+
+#define __argp_fmtstream_putc(fs,ch) putc(ch,fs)
+#define argp_fmtstream_putc(fs,ch) putc(ch,fs)
+#define __argp_fmtstream_puts(fs,str) fputs(str,fs)
+#define argp_fmtstream_puts(fs,str) fputs(str,fs)
+#define __argp_fmtstream_write(fs,str,len) fwrite(str,1,len,fs)
+#define argp_fmtstream_write(fs,str,len) fwrite(str,1,len,fs)
+#define __argp_fmtstream_printf fprintf
+#define argp_fmtstream_printf fprintf
+
+#define __argp_fmtstream_lmargin line_wrap_lmargin
+#define argp_fmtstream_lmargin line_wrap_lmargin
+#define __argp_fmtstream_set_lmargin line_wrap_set_lmargin
+#define argp_fmtstream_set_lmargin line_wrap_set_lmargin
+#define __argp_fmtstream_rmargin line_wrap_rmargin
+#define argp_fmtstream_rmargin line_wrap_rmargin
+#define __argp_fmtstream_set_rmargin line_wrap_set_rmargin
+#define argp_fmtstream_set_rmargin line_wrap_set_rmargin
+#define __argp_fmtstream_wmargin line_wrap_wmargin
+#define argp_fmtstream_wmargin line_wrap_wmargin
+#define __argp_fmtstream_set_wmargin line_wrap_set_wmargin
+#define argp_fmtstream_set_wmargin line_wrap_set_wmargin
+#define __argp_fmtstream_point line_wrap_point
+#define argp_fmtstream_point line_wrap_point
+
+#else /* !ARGP_FMTSTREAM_USE_LINEWRAP */
+/* Guess we have to define our own version. */
+
+#ifndef __const
+#define __const const
+#endif
+
+struct argp_fmtstream
+{
+ FILE *stream; /* The stream we're outputting to. */
+
+ size_t lmargin, rmargin; /* Left and right margins. */
+ ssize_t wmargin; /* Margin to wrap to, or -1 to truncate. */
+
+ /* Point in buffer to which we've processed for wrapping, but not output. */
+ size_t point_offs;
+ /* Output column at POINT_OFFS, or -1 meaning 0 but don't add lmargin. */
+ ssize_t point_col;
+
+ char *buf; /* Output buffer. */
+ char *p; /* Current end of text in BUF. */
+ char *end; /* Absolute end of BUF. */
+};
+
+typedef struct argp_fmtstream *argp_fmtstream_t;
+
+/* Return an argp_fmtstream that outputs to STREAM, and which prefixes lines
+ written on it with LMARGIN spaces and limits them to RMARGIN columns
+ total. If WMARGIN >= 0, words that extend past RMARGIN are wrapped by
+ replacing the whitespace before them with a newline and WMARGIN spaces.
+ Otherwise, chars beyond RMARGIN are simply dropped until a newline.
+ Returns NULL if there was an error. */
+extern argp_fmtstream_t __argp_make_fmtstream (FILE *__stream,
+ size_t __lmargin,
+ size_t __rmargin,
+ ssize_t __wmargin);
+extern argp_fmtstream_t argp_make_fmtstream (FILE *__stream,
+ size_t __lmargin,
+ size_t __rmargin,
+ ssize_t __wmargin);
+
+/* Flush __FS to its stream, and free it (but don't close the stream). */
+extern void __argp_fmtstream_free (argp_fmtstream_t __fs);
+extern void argp_fmtstream_free (argp_fmtstream_t __fs);
+
+extern ssize_t __argp_fmtstream_printf (argp_fmtstream_t __fs,
+ __const char *__fmt, ...)
+ __attribute__ ((__format__ (printf, 2, 3)));
+extern ssize_t argp_fmtstream_printf (argp_fmtstream_t __fs,
+ __const char *__fmt, ...)
+ __attribute__ ((__format__ (printf, 2, 3)));
+
+extern int __argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch);
+extern int argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch);
+
+extern int __argp_fmtstream_puts (argp_fmtstream_t __fs, __const char *__str);
+extern int argp_fmtstream_puts (argp_fmtstream_t __fs, __const char *__str);
+
+extern size_t __argp_fmtstream_write (argp_fmtstream_t __fs,
+ __const char *__str, size_t __len);
+extern size_t argp_fmtstream_write (argp_fmtstream_t __fs,
+ __const char *__str, size_t __len);
+
+/* Access macros for various bits of state. */
+#define argp_fmtstream_lmargin(__fs) ((__fs)->lmargin)
+#define argp_fmtstream_rmargin(__fs) ((__fs)->rmargin)
+#define argp_fmtstream_wmargin(__fs) ((__fs)->wmargin)
+#define __argp_fmtstream_lmargin argp_fmtstream_lmargin
+#define __argp_fmtstream_rmargin argp_fmtstream_rmargin
+#define __argp_fmtstream_wmargin argp_fmtstream_wmargin
+
+/* Set __FS's left margin to LMARGIN and return the old value. */
+extern size_t argp_fmtstream_set_lmargin (argp_fmtstream_t __fs,
+ size_t __lmargin);
+extern size_t __argp_fmtstream_set_lmargin (argp_fmtstream_t __fs,
+ size_t __lmargin);
+
+/* Set __FS's right margin to __RMARGIN and return the old value. */
+extern size_t argp_fmtstream_set_rmargin (argp_fmtstream_t __fs,
+ size_t __rmargin);
+extern size_t __argp_fmtstream_set_rmargin (argp_fmtstream_t __fs,
+ size_t __rmargin);
+
+/* Set __FS's wrap margin to __WMARGIN and return the old value. */
+extern size_t argp_fmtstream_set_wmargin (argp_fmtstream_t __fs,
+ size_t __wmargin);
+extern size_t __argp_fmtstream_set_wmargin (argp_fmtstream_t __fs,
+ size_t __wmargin);
+
+/* Return the column number of the current output point in __FS. */
+extern size_t argp_fmtstream_point (argp_fmtstream_t __fs);
+extern size_t __argp_fmtstream_point (argp_fmtstream_t __fs);
+
+/* Internal routines. */
+extern void _argp_fmtstream_update (argp_fmtstream_t __fs);
+extern void __argp_fmtstream_update (argp_fmtstream_t __fs);
+extern int _argp_fmtstream_ensure (argp_fmtstream_t __fs, size_t __amount);
+extern int __argp_fmtstream_ensure (argp_fmtstream_t __fs, size_t __amount);
+
+#ifdef __OPTIMIZE__
+/* Inline versions of above routines. */
+
+#if !_LIBC
+#define __argp_fmtstream_putc argp_fmtstream_putc
+#define __argp_fmtstream_puts argp_fmtstream_puts
+#define __argp_fmtstream_write argp_fmtstream_write
+#define __argp_fmtstream_set_lmargin argp_fmtstream_set_lmargin
+#define __argp_fmtstream_set_rmargin argp_fmtstream_set_rmargin
+#define __argp_fmtstream_set_wmargin argp_fmtstream_set_wmargin
+#define __argp_fmtstream_point argp_fmtstream_point
+#define __argp_fmtstream_update _argp_fmtstream_update
+#define __argp_fmtstream_ensure _argp_fmtstream_ensure
+#endif
+
+#ifndef ARGP_FS_EI
+#define ARGP_FS_EI __extern_inline
+#endif
+
+ARGP_FS_EI size_t
+__argp_fmtstream_write (argp_fmtstream_t __fs,
+ __const char *__str, size_t __len)
+{
+ if (__fs->p + __len <= __fs->end || __argp_fmtstream_ensure (__fs, __len))
+ {
+ memcpy (__fs->p, __str, __len);
+ __fs->p += __len;
+ return __len;
+ }
+ else
+ return 0;
+}
+
+ARGP_FS_EI int
+__argp_fmtstream_puts (argp_fmtstream_t __fs, __const char *__str)
+{
+ size_t __len = strlen (__str);
+ if (__len)
+ {
+ size_t __wrote = __argp_fmtstream_write (__fs, __str, __len);
+ return __wrote == __len ? 0 : -1;
+ }
+ else
+ return 0;
+}
+
+ARGP_FS_EI int
+__argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch)
+{
+ if (__fs->p < __fs->end || __argp_fmtstream_ensure (__fs, 1))
+ return *__fs->p++ = __ch;
+ else
+ return EOF;
+}
+
+/* Set __FS's left margin to __LMARGIN and return the old value. */
+ARGP_FS_EI size_t
+__argp_fmtstream_set_lmargin (argp_fmtstream_t __fs, size_t __lmargin)
+{
+ size_t __old;
+ if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
+ __argp_fmtstream_update (__fs);
+ __old = __fs->lmargin;
+ __fs->lmargin = __lmargin;
+ return __old;
+}
+
+/* Set __FS's right margin to __RMARGIN and return the old value. */
+ARGP_FS_EI size_t
+__argp_fmtstream_set_rmargin (argp_fmtstream_t __fs, size_t __rmargin)
+{
+ size_t __old;
+ if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
+ __argp_fmtstream_update (__fs);
+ __old = __fs->rmargin;
+ __fs->rmargin = __rmargin;
+ return __old;
+}
+
+/* Set FS's wrap margin to __WMARGIN and return the old value. */
+ARGP_FS_EI size_t
+__argp_fmtstream_set_wmargin (argp_fmtstream_t __fs, size_t __wmargin)
+{
+ size_t __old;
+ if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
+ __argp_fmtstream_update (__fs);
+ __old = __fs->wmargin;
+ __fs->wmargin = __wmargin;
+ return __old;
+}
+
+/* Return the column number of the current output point in __FS. */
+ARGP_FS_EI size_t
+__argp_fmtstream_point (argp_fmtstream_t __fs)
+{
+ if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
+ __argp_fmtstream_update (__fs);
+ return __fs->point_col >= 0 ? __fs->point_col : 0;
+}
+
+#if !_LIBC
+#undef __argp_fmtstream_putc
+#undef __argp_fmtstream_puts
+#undef __argp_fmtstream_write
+#undef __argp_fmtstream_set_lmargin
+#undef __argp_fmtstream_set_rmargin
+#undef __argp_fmtstream_set_wmargin
+#undef __argp_fmtstream_point
+#undef __argp_fmtstream_update
+#undef __argp_fmtstream_ensure
+#endif
+
+#endif /* __OPTIMIZE__ */
+
+#endif /* ARGP_FMTSTREAM_USE_LINEWRAP */
+
+#endif /* argp-fmtstream.h */
diff --git a/libuargp/argp-fs-xinl.c b/libuargp/argp-fs-xinl.c
new file mode 100644
index 000000000..473cbbd9c
--- /dev/null
+++ b/libuargp/argp-fs-xinl.c
@@ -0,0 +1,44 @@
+/* Real definitions for extern inline functions in argp-fmtstream.h
+ Copyright (C) 1997, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Miles Bader <miles at gnu.ai.mit.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. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#define ARGP_FS_EI
+#undef __OPTIMIZE__
+#define __OPTIMIZE__ 1
+#include "argp-fmtstream.h"
+
+#if 0
+/* Not exported. */
+/* Add weak aliases. */
+#if _LIBC - 0 && !defined (ARGP_FMTSTREAM_USE_LINEWRAP) && defined (weak_alias)
+
+weak_alias (__argp_fmtstream_putc, argp_fmtstream_putc)
+weak_alias (__argp_fmtstream_puts, argp_fmtstream_puts)
+weak_alias (__argp_fmtstream_write, argp_fmtstream_write)
+weak_alias (__argp_fmtstream_set_lmargin, argp_fmtstream_set_lmargin)
+weak_alias (__argp_fmtstream_set_rmargin, argp_fmtstream_set_rmargin)
+weak_alias (__argp_fmtstream_set_wmargin, argp_fmtstream_set_wmargin)
+weak_alias (__argp_fmtstream_point, argp_fmtstream_point)
+
+#endif
+#endif
diff --git a/libuargp/argp-help.c b/libuargp/argp-help.c
new file mode 100644
index 000000000..58a5e6e16
--- /dev/null
+++ b/libuargp/argp-help.c
@@ -0,0 +1,1882 @@
+/* Hierarchial argument parsing help output
+ Copyright (C) 1995-2003, 2004, 2005, 2006, 2007
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Miles Bader <miles at gnu.ai.mit.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.
+
+ Modified for uClibc by: Salvatore Cro <salvatore.cro at st.com>
+*/
+
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+/* AIX requires this to be the first thing in the file. */
+#ifndef __GNUC__
+# if HAVE_ALLOCA_H || defined _LIBC
+# include <alloca.h>
+# else
+# ifdef _AIX
+#pragma alloca
+# else
+# ifndef alloca /* predefined by HP cc +Olibcalls */
+char *alloca ();
+# endif
+# endif
+# endif
+#endif
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <stdarg.h>
+#include <ctype.h>
+#include <limits.h>
+#ifdef _LIBC
+# include <wchar.h>
+#endif
+
+#include <features.h>
+#ifndef _
+/* This is for other GNU distributions with internationalized messages. */
+# if (defined HAVE_LIBINTL_H || defined _LIBC) && defined __UCLIBC_HAS_GETTEXT_AWARENESS__
+# include <libintl.h>
+# ifdef _LIBC
+# undef dgettext
+# define dgettext(domain, msgid) \
+ INTUSE(__dcgettext) (domain, msgid, LC_MESSAGES)
+# endif
+# else
+# define dgettext(domain, msgid) (msgid)
+# endif
+#endif
+
+#ifndef _LIBC
+# if HAVE_STRERROR_R
+# if !HAVE_DECL_STRERROR_R
+char *strerror_r (int errnum, char *buf, size_t buflen);
+# endif
+# else
+# if !HAVE_DECL_STRERROR
+char *strerror (int errnum);
+# endif
+# endif
+#endif
+
+#include <argp.h>
+#include "argp-fmtstream.h"
+#include <stdbool.h>
+#include <stdint.h>
+
+#ifndef SIZE_MAX
+# define SIZE_MAX ((size_t) -1)
+#endif
+
+/* User-selectable (using an environment variable) formatting parameters.
+
+ These may be specified in an environment variable called `ARGP_HELP_FMT',
+ with a contents like: VAR1=VAL1,VAR2=VAL2,BOOLVAR2,no-BOOLVAR2
+ Where VALn must be a positive integer. The list of variables is in the
+ UPARAM_NAMES vector, below. */
+
+/* Default parameters. */
+#define DUP_ARGS 0 /* True if option argument can be duplicated. */
+#define DUP_ARGS_NOTE 1 /* True to print a note about duplicate args. */
+#define SHORT_OPT_COL 2 /* column in which short options start */
+#define LONG_OPT_COL 6 /* column in which long options start */
+#define DOC_OPT_COL 2 /* column in which doc options start */
+#define OPT_DOC_COL 29 /* column in which option text starts */
+#define HEADER_COL 1 /* column in which group headers are printed */
+#define USAGE_INDENT 12 /* indentation of wrapped usage lines */
+#define RMARGIN 79 /* right margin used for wrapping */
+
+/* User-selectable (using an environment variable) formatting parameters.
+ They must all be of type `int' for the parsing code to work. */
+struct uparams
+{
+ /* If true, arguments for an option are shown with both short and long
+ options, even when a given option has both, e.g. `-x ARG, --longx=ARG'.
+ If false, then if an option has both, the argument is only shown with
+ the long one, e.g., `-x, --longx=ARG', and a message indicating that
+ this really means both is printed below the options. */
+ int dup_args;
+
+ /* This is true if when DUP_ARGS is false, and some duplicate arguments have
+ been suppressed, an explanatory message should be printed. */
+ int dup_args_note;
+
+ /* Various output columns. */
+ int short_opt_col;
+ int long_opt_col;
+ int doc_opt_col;
+ int opt_doc_col;
+ int header_col;
+ int usage_indent;
+ int rmargin;
+};
+
+/* This is a global variable, as user options are only ever read once. */
+static struct uparams uparams = {
+ DUP_ARGS, DUP_ARGS_NOTE,
+ SHORT_OPT_COL, LONG_OPT_COL, DOC_OPT_COL, OPT_DOC_COL, HEADER_COL,
+ USAGE_INDENT, RMARGIN
+};
+
+/* A particular uparam, and what the user name is. */
+struct uparam_name
+{
+ const char name[14]; /* User name. */
+ bool is_bool; /* Whether it's `boolean'. */
+ uint8_t uparams_offs; /* Location of the (int) field in UPARAMS. */
+};
+
+/* The name-field mappings we know about. */
+static const struct uparam_name uparam_names[] =
+{
+ { "dup-args", true, offsetof (struct uparams, dup_args) },
+ { "dup-args-note", true, offsetof (struct uparams, dup_args_note) },
+ { "short-opt-col", false, offsetof (struct uparams, short_opt_col) },
+ { "long-opt-col", false, offsetof (struct uparams, long_opt_col) },
+ { "doc-opt-col", false, offsetof (struct uparams, doc_opt_col) },
+ { "opt-doc-col", false, offsetof (struct uparams, opt_doc_col) },
+ { "header-col", false, offsetof (struct uparams, header_col) },
+ { "usage-indent", false, offsetof (struct uparams, usage_indent) },
+ { "rmargin", false, offsetof (struct uparams, rmargin) }
+};
+#define nuparam_names (sizeof (uparam_names) / sizeof (uparam_names[0]))
+
+/* Read user options from the environment, and fill in UPARAMS appropiately. */
+static void
+fill_in_uparams (const struct argp_state *state)
+{
+ const char *var = getenv ("ARGP_HELP_FMT");
+
+#define SKIPWS(p) do { while (isspace (*p)) p++; } while (0);
+
+ if (var)
+ /* Parse var. */
+ while (*var)
+ {
+ SKIPWS (var);
+
+ if (isalpha (*var))
+ {
+ size_t var_len;
+ const struct uparam_name *un;
+ int unspec = 0, val = 0;
+ const char *arg = var;
+
+ while (isalnum (*arg) || *arg == '-' || *arg == '_')
+ arg++;
+ var_len = arg - var;
+
+ SKIPWS (arg);
+
+ if (*arg == '\0' || *arg == ',')
+ unspec = 1;
+ else if (*arg == '=')
+ {
+ arg++;
+ SKIPWS (arg);
+ }
+
+ if (unspec)
+ {
+ if (var[0] == 'n' && var[1] == 'o' && var[2] == '-')
+ {
+ val = 0;
+ var += 3;
+ var_len -= 3;
+ }
+ else
+ val = 1;
+ }
+ else if (isdigit (*arg))
+ {
+ val = atoi (arg);
+ while (isdigit (*arg))
+ arg++;
+ SKIPWS (arg);
+ }
+
+ un = uparam_names;
+ size_t u;
+ for (u = 0; u < nuparam_names; ++un, ++u)
+ if (strlen (un->name) == var_len
+ && strncmp (var, un->name, var_len) == 0)
+ {
+ if (unspec && !un->is_bool)
+ argp_failure (state, 0, 0,
+ dgettext (state == NULL ? NULL
+ : state->root_argp->argp_domain,
+ "\
+%.*s: ARGP_HELP_FMT parameter requires a value"),
+ (int) var_len, var);
+ else
+ *(int *)((char *)&uparams + un->uparams_offs) = val;
+ break;
+ }
+ if (u == nuparam_names)
+ argp_failure (state, 0, 0,
+ dgettext (state == NULL ? NULL
+ : state->root_argp->argp_domain, "\
+%.*s: Unknown ARGP_HELP_FMT parameter"),
+ (int) var_len, var);
+
+ var = arg;
+ if (*var == ',')
+ var++;
+ }
+ else if (*var)
+ {
+ argp_failure (state, 0, 0,
+ dgettext (state == NULL ? NULL
+ : state->root_argp->argp_domain,
+ "Garbage in ARGP_HELP_FMT: %s"), var);
+ break;
+ }
+ }
+}
+
+/* Returns true if OPT hasn't been marked invisible. Visibility only affects
+ whether OPT is displayed or used in sorting, not option shadowing. */
+#define ovisible(opt) (! ((opt)->flags & OPTION_HIDDEN))
+
+/* Returns true if OPT is an alias for an earlier option. */
+#define oalias(opt) ((opt)->flags & OPTION_ALIAS)
+
+/* Returns true if OPT is an documentation-only entry. */
+#define odoc(opt) ((opt)->flags & OPTION_DOC)
+
+/* Returns true if OPT is the end-of-list marker for a list of options. */
+#define oend(opt) __option_is_end (opt)
+
+/* Returns true if OPT has a short option. */
+#define oshort(opt) __option_is_short (opt)
+
+/*
+ The help format for a particular option is like:
+
+ -xARG, -yARG, --long1=ARG, --long2=ARG Documentation...
+
+ Where ARG will be omitted if there's no argument, for this option, or
+ will be surrounded by "[" and "]" appropiately if the argument is
+ optional. The documentation string is word-wrapped appropiately, and if
+ the list of options is long enough, it will be started on a separate line.
+ If there are no short options for a given option, the first long option is
+ indented slighly in a way that's supposed to make most long options appear
+ to be in a separate column.
+
+ For example, the following output (from ps):
+
+ -p PID, --pid=PID List the process PID
+ --pgrp=PGRP List processes in the process group PGRP
+ -P, -x, --no-parent Include processes without parents
+ -Q, --all-fields Don't elide unusable fields (normally if there's
+ some reason ps can't print a field for any
+ process, it's removed from the output entirely)
+ -r, --reverse, --gratuitously-long-reverse-option
+ Reverse the order of any sort
+ --session[=SID] Add the processes from the session SID (which
+ defaults to the sid of the current process)
+
+ Here are some more options:
+ -f ZOT, --foonly=ZOT Glork a foonly
+ -z, --zaza Snit a zar
+
+ -?, --help Give this help list
+ --usage Give a short usage message
+ -V, --version Print program version
+
+ The struct argp_option array for the above could look like:
+
+ {
+ {"pid", 'p', "PID", 0, "List the process PID"},
+ {"pgrp", OPT_PGRP, "PGRP", 0, "List processes in the process group PGRP"},
+ {"no-parent", 'P', 0, 0, "Include processes without parents"},
+ {0, 'x', 0, OPTION_ALIAS},
+ {"all-fields",'Q', 0, 0, "Don't elide unusable fields (normally"
+ " if there's some reason ps can't"
+ " print a field for any process, it's"
+ " removed from the output entirely)" },
+ {"reverse", 'r', 0, 0, "Reverse the order of any sort"},
+ {"gratuitously-long-reverse-option", 0, 0, OPTION_ALIAS},
+ {"session", OPT_SESS, "SID", OPTION_ARG_OPTIONAL,
+ "Add the processes from the session"
+ " SID (which defaults to the sid of"
+ " the current process)" },
+
+ {0,0,0,0, "Here are some more options:"},
+ {"foonly", 'f', "ZOT", 0, "Glork a foonly"},
+ {"zaza", 'z', 0, 0, "Snit a zar"},
+
+ {0}
+ }
+
+ Note that the last three options are automatically supplied by argp_parse,
+ unless you tell it not to with ARGP_NO_HELP.
+
+*/
+
+/* Returns true if CH occurs between BEG and END. */
+static int
+find_char (char ch, char *beg, char *end)
+{
+ while (beg < end)
+ if (*beg == ch)
+ return 1;
+ else
+ beg++;
+ return 0;
+}
+
+struct hol_cluster; /* fwd decl */
+
+struct hol_entry
+{
+ /* First option. */
+ const struct argp_option *opt;
+ /* Number of options (including aliases). */
+ unsigned num;
+
+ /* A pointers into the HOL's short_options field, to the first short option
+ letter for this entry. The order of the characters following this point
+ corresponds to the order of options pointed to by OPT, and there are at
+ most NUM. A short option recorded in a option following OPT is only
+ valid if it occurs in the right place in SHORT_OPTIONS (otherwise it's
+ probably been shadowed by some other entry). */
+ char *short_options;
+
+ /* Entries are sorted by their group first, in the order:
+ 1, 2, ..., n, 0, -m, ..., -2, -1
+ and then alphabetically within each group. The default is 0. */
+ int group;
+
+ /* The cluster of options this entry belongs to, or 0 if none. */
+ struct hol_cluster *cluster;
+
+ /* The argp from which this option came. */
+ const struct argp *argp;
+};
+
+/* A cluster of entries to reflect the argp tree structure. */
+struct hol_cluster
+{
+ /* A descriptive header printed before options in this cluster. */
+ const char *header;
+
+ /* Used to order clusters within the same group with the same parent,
+ according to the order in which they occurred in the parent argp's child
+ list. */
+ int index;
+
+ /* How to sort this cluster with respect to options and other clusters at the
+ same depth (clusters always follow options in the same group). */
+ int group;
+
+ /* The cluster to which this cluster belongs, or 0 if it's at the base
+ level. */
+ struct hol_cluster *parent;
+
+ /* The argp from which this cluster is (eventually) derived. */
+ const struct argp *argp;
+
+ /* The distance this cluster is from the root. */
+ int depth;
+
+ /* Clusters in a given hol are kept in a linked list, to make freeing them
+ possible. */
+ struct hol_cluster *next;
+};
+
+/* A list of options for help. */
+struct hol
+{
+ /* An array of hol_entry's. */
+ struct hol_entry *entries;
+ /* The number of entries in this hol. If this field is zero, the others
+ are undefined. */
+ unsigned num_entries;
+
+ /* A string containing all short options in this HOL. Each entry contains
+ pointers into this string, so the order can't be messed with blindly. */
+ char *short_options;
+
+ /* Clusters of entries in this hol. */
+ struct hol_cluster *clusters;
+};
+
+/* Create a struct hol from the options in ARGP. CLUSTER is the
+ hol_cluster in which these entries occur, or 0, if at the root. */
+static struct hol *
+make_hol (const struct argp *argp, struct hol_cluster *cluster)
+{
+ char *so;
+ const struct argp_option *o;
+ const struct argp_option *opts = argp->options;
+ struct hol_entry *entry;
+ unsigned num_short_options = 0;
+ struct hol *hol = malloc (sizeof (struct hol));
+
+ assert (hol);
+
+ hol->num_entries = 0;
+ hol->clusters = 0;
+
+ if (opts)
+ {
+ int cur_group = 0;
+
+ /* The first option must not be an alias. */
+ assert (! oalias (opts));
+
+ /* Calculate the space needed. */
+ for (o = opts; ! oend (o); o++)
+ {
+ if (! oalias (o))
+ hol->num_entries++;
+ if (oshort (o))
+ num_short_options++; /* This is an upper bound. */
+ }
+
+ hol->entries = malloc (sizeof (struct hol_entry) * hol->num_entries);
+ hol->short_options = malloc (num_short_options + 1);
+
+ assert (hol->entries && hol->short_options);
+#if SIZE_MAX <= UINT_MAX
+ assert (hol->num_entries <= SIZE_MAX / sizeof (struct hol_entry));
+#endif
+
+ /* Fill in the entries. */
+ so = hol->short_options;
+ for (o = opts, entry = hol->entries; ! oend (o); entry++)
+ {
+ entry->opt = o;
+ entry->num = 0;
+ entry->short_options = so;
+ entry->group = cur_group =
+ o->group
+ ? o->group
+ : ((!o->name && !o->key)
+ ? cur_group + 1
+ : cur_group);
+ entry->cluster = cluster;
+ entry->argp = argp;
+
+ do
+ {
+ entry->num++;
+ if (oshort (o) && ! find_char (o->key, hol->short_options, so))
+ /* O has a valid short option which hasn't already been used.*/
+ *so++ = o->key;
+ o++;
+ }
+ while (! oend (o) && oalias (o));
+ }
+ *so = '\0'; /* null terminated so we can find the length */
+ }
+
+ return hol;
+}
+
+/* Add a new cluster to HOL, with the given GROUP and HEADER (taken from the
+ associated argp child list entry), INDEX, and PARENT, and return a pointer
+ to it. ARGP is the argp that this cluster results from. */
+static struct hol_cluster *
+hol_add_cluster (struct hol *hol, int group, const char *header, int index,
+ struct hol_cluster *parent, const struct argp *argp)
+{
+ struct hol_cluster *cl = malloc (sizeof (struct hol_cluster));
+ if (cl)
+ {
+ cl->group = group;
+ cl->header = header;
+
+ cl->index = index;
+ cl->parent = parent;
+ cl->argp = argp;
+ cl->depth = parent ? parent->depth + 1 : 0;
+
+ cl->next = hol->clusters;
+ hol->clusters = cl;
+ }
+ return cl;
+}
+
+/* Free HOL and any resources it uses. */
+static void
+hol_free (struct hol *hol)
+{
+ struct hol_cluster *cl = hol->clusters;
+
+ while (cl)
+ {
+ struct hol_cluster *next = cl->next;
+ free (cl);
+ cl = next;
+ }
+
+ if (hol->num_entries > 0)
+ {
+ free (hol->entries);
+ free (hol->short_options);
+ }
+
+ free (hol);
+}
+
+static int
+hol_entry_short_iterate (const struct hol_entry *entry,
+ int (*func)(const struct argp_option *opt,
+ const struct argp_option *real,
+ const char *domain, void *cookie),
+ const char *domain, void *cookie)
+{
+ unsigned nopts;
+ int val = 0;
+ const struct argp_option *opt, *real = entry->opt;
+ char *so = entry->short_options;
+
+ for (opt = real, nopts = entry->num; nopts > 0 && !val; opt++, nopts--)
+ if (oshort (opt) && *so == opt->key)
+ {
+ if (!oalias (opt))
+ real = opt;
+ if (ovisible (opt))
+ val = (*func)(opt, real, domain, cookie);
+ so++;
+ }
+
+ return val;
+}
+
+static __inline__ int
+__attribute__ ((always_inline))
+hol_entry_long_iterate (const struct hol_entry *entry,
+ int (*func)(const struct argp_option *opt,
+ const struct argp_option *real,
+ const char *domain, void *cookie),
+ const char *domain, void *cookie)
+{
+ unsigned nopts;
+ int val = 0;
+ const struct argp_option *opt, *real = entry->opt;
+
+ for (opt = real, nopts = entry->num; nopts > 0 && !val; opt++, nopts--)
+ if (opt->name)
+ {
+ if (!oalias (opt))
+ real = opt;
+ if (ovisible (opt))
+ val = (*func)(opt, real, domain, cookie);
+ }
+
+ return val;
+}
+
+/* Iterator that returns true for the first short option. */
+static __inline__ int
+until_short (const struct argp_option *opt, const struct argp_option *real,
+ const char *domain, void *cookie)
+{
+ return oshort (opt) ? opt->key : 0;
+}
+
+/* Returns the first valid short option in ENTRY, or 0 if there is none. */
+static char
+hol_entry_first_short (const struct hol_entry *entry)
+{
+ return hol_entry_short_iterate (entry, until_short,
+ entry->argp->argp_domain, 0);
+}
+
+/* Returns the first valid long option in ENTRY, or 0 if there is none. */
+static const char *
+hol_entry_first_long (const struct hol_entry *entry)
+{
+ const struct argp_option *opt;
+ unsigned num;
+ for (opt = entry->opt, num = entry->num; num > 0; opt++, num--)
+ if (opt->name && ovisible (opt))
+ return opt->name;
+ return 0;
+}
+
+/* Returns the entry in HOL with the long option name NAME, or 0 if there is
+ none. */
+static struct hol_entry *
+hol_find_entry (struct hol *hol, const char *name)
+{
+ struct hol_entry *entry = hol->entries;
+ unsigned num_entries = hol->num_entries;
+
+ while (num_entries-- > 0)
+ {
+ const struct argp_option *opt = entry->opt;
+ unsigned num_opts = entry->num;
+
+ while (num_opts-- > 0)
+ if (opt->name && ovisible (opt) && strcmp (opt->name, name) == 0)
+ return entry;
+ else
+ opt++;
+
+ entry++;
+ }
+
+ return 0;
+}
+
+/* If an entry with the long option NAME occurs in HOL, set it's special
+ sort position to GROUP. */
+static void
+hol_set_group (struct hol *hol, const char *name, int group)
+{
+ struct hol_entry *entry = hol_find_entry (hol, name);
+ if (entry)
+ entry->group = group;
+}
+
+/* Order by group: 0, 1, 2, ..., n, -m, ..., -2, -1.
+ EQ is what to return if GROUP1 and GROUP2 are the same. */
+static int
+group_cmp (int group1, int group2, int eq)
+{
+ if (group1 == group2)
+ return eq;
+ else if ((group1 < 0 && group2 < 0) || (group1 >= 0 && group2 >= 0))
+ return group1 - group2;
+ else
+ return group2 - group1;
+}
+
+/* Compare clusters CL1 & CL2 by the order that they should appear in
+ output. */
+static int
+hol_cluster_cmp (const struct hol_cluster *cl1, const struct hol_cluster *cl2)
+{
+ /* If one cluster is deeper than the other, use its ancestor at the same
+ level, so that finding the common ancestor is straightforward. */
+ while (cl1->depth > cl2->depth)
+ cl1 = cl1->parent;
+ while (cl2->depth > cl1->depth)
+ cl2 = cl2->parent;
+
+ /* Now reduce both clusters to their ancestors at the point where both have
+ a common parent; these can be directly compared. */
+ while (cl1->parent != cl2->parent)
+ cl1 = cl1->parent, cl2 = cl2->parent;
+
+ return group_cmp (cl1->group, cl2->group, cl2->index - cl1->index);
+}
+
+/* Return the ancestor of CL that's just below the root (i.e., has a parent
+ of 0). */
+static struct hol_cluster *
+hol_cluster_base (struct hol_cluster *cl)
+{
+ while (cl->parent)
+ cl = cl->parent;
+ return cl;
+}
+
+/* Return true if CL1 is a child of CL2. */
+static int
+hol_cluster_is_child (const struct hol_cluster *cl1,
+ const struct hol_cluster *cl2)
+{
+ while (cl1 && cl1 != cl2)
+ cl1 = cl1->parent;
+ return cl1 == cl2;
+}
+
+/* Given the name of a OPTION_DOC option, modifies NAME to start at the tail
+ that should be used for comparisons, and returns true iff it should be
+ treated as a non-option. */
+static int
+canon_doc_option (const char **name)
+{
+ int non_opt;
+ /* Skip initial whitespace. */
+ while (isspace (**name))
+ (*name)++;
+ /* Decide whether this looks like an option (leading `-') or not. */
+ non_opt = (**name != '-');
+ /* Skip until part of name used for sorting. */
+ while (**name && !isalnum (**name))
+ (*name)++;
+ return non_opt;
+}
+
+/* Order ENTRY1 & ENTRY2 by the order which they should appear in a help
+ listing. */
+static int
+hol_entry_cmp (const struct hol_entry *entry1,
+ const struct hol_entry *entry2)
+{
+ /* The group numbers by which the entries should be ordered; if either is
+ in a cluster, then this is just the group within the cluster. */
+ int group1 = entry1->group, group2 = entry2->group;
+
+ if (entry1->cluster != entry2->cluster)
+ {
+ /* The entries are not within the same cluster, so we can't compare them
+ directly, we have to use the appropiate clustering level too. */
+ if (! entry1->cluster)
+ /* ENTRY1 is at the `base level', not in a cluster, so we have to
+ compare it's group number with that of the base cluster in which
+ ENTRY2 resides. Note that if they're in the same group, the
+ clustered option always comes laster. */
+ return group_cmp (group1, hol_cluster_base (entry2->cluster)->group, -1);
+ else if (! entry2->cluster)
+ /* Likewise, but ENTRY2's not in a cluster. */
+ return group_cmp (hol_cluster_base (entry1->cluster)->group, group2, 1);
+ else
+ /* Both entries are in clusters, we can just compare the clusters. */
+ return hol_cluster_cmp (entry1->cluster, entry2->cluster);
+ }
+ else if (group1 == group2)
+ /* The entries are both in the same cluster and group, so compare them
+ alphabetically. */
+ {
+ int short1 = hol_entry_first_short (entry1);
+ int short2 = hol_entry_first_short (entry2);
+ int doc1 = odoc (entry1->opt);
+ int doc2 = odoc (entry2->opt);
+ const char *long1 = hol_entry_first_long (entry1);
+ const char *long2 = hol_entry_first_long (entry2);
+
+ if (doc1)
+ doc1 = long1 != NULL && canon_doc_option (&long1);
+ if (doc2)
+ doc2 = long2 != NULL && canon_doc_option (&long2);
+
+ if (doc1 != doc2)
+ /* `documentation' options always follow normal options (or
+ documentation options that *look* like normal options). */
+ return doc1 - doc2;
+ else if (!short1 && !short2 && long1 && long2)
+ /* Only long options. */
+ return strcasecmp (long1, long2);
+ else
+ /* Compare short/short, long/short, short/long, using the first
+ character of long options. Entries without *any* valid
+ options (such as options with OPTION_HIDDEN set) will be put
+ first, but as they're not displayed, it doesn't matter where
+ they are. */
+ {
+ char first1 = short1 ? short1 : long1 ? *long1 : 0;
+ char first2 = short2 ? short2 : long2 ? *long2 : 0;
+#ifdef _tolower
+ int lower_cmp = _tolower (first1) - _tolower (first2);
+#else
+ int lower_cmp = tolower (first1) - tolower (first2);
+#endif
+ /* Compare ignoring case, except when the options are both the
+ same letter, in which case lower-case always comes first. */
+ return lower_cmp ? lower_cmp : first2 - first1;
+ }
+ }
+ else
+ /* Within the same cluster, but not the same group, so just compare
+ groups. */
+ return group_cmp (group1, group2, 0);
+}
+
+/* Version of hol_entry_cmp with correct signature for qsort. */
+static int
+hol_entry_qcmp (const void *entry1_v, const void *entry2_v)
+{
+ return hol_entry_cmp (entry1_v, entry2_v);
+}
+
+/* Sort HOL by group and alphabetically by option name (with short options
+ taking precedence over long). Since the sorting is for display purposes
+ only, the shadowing of options isn't effected. */
+static void
+hol_sort (struct hol *hol)
+{
+ if (hol->num_entries > 0)
+ qsort (hol->entries, hol->num_entries, sizeof (struct hol_entry),
+ hol_entry_qcmp);
+}
+
+/* Append MORE to HOL, destroying MORE in the process. Options in HOL shadow
+ any in MORE with the same name. */
+static void
+hol_append (struct hol *hol, struct hol *more)
+{
+ struct hol_cluster **cl_end = &hol->clusters;
+
+ /* Steal MORE's cluster list, and add it to the end of HOL's. */
+ while (*cl_end)
+ cl_end = &(*cl_end)->next;
+ *cl_end = more->clusters;
+ more->clusters = 0;
+
+ /* Merge entries. */
+ if (more->num_entries > 0)
+ {
+ if (hol->num_entries == 0)
+ {
+ hol->num_entries = more->num_entries;
+ hol->entries = more->entries;
+ hol->short_options = more->short_options;
+ more->num_entries = 0; /* Mark MORE's fields as invalid. */
+ }
+ else
+ /* Append the entries in MORE to those in HOL, taking care to only add
+ non-shadowed SHORT_OPTIONS values. */
+ {
+ unsigned left;
+ char *so, *more_so;
+ struct hol_entry *e;
+ unsigned num_entries = hol->num_entries + more->num_entries;
+ struct hol_entry *entries =
+ malloc (num_entries * sizeof (struct hol_entry));
+ unsigned hol_so_len = strlen (hol->short_options);
+ char *short_options =
+ malloc (hol_so_len + strlen (more->short_options) + 1);
+
+ assert (entries && short_options);
+#if SIZE_MAX <= UINT_MAX
+ assert (num_entries <= SIZE_MAX / sizeof (struct hol_entry));
+#endif
+
+ mempcpy (mempcpy (entries, hol->entries,
+ hol->num_entries * sizeof (struct hol_entry)),
+ more->entries,
+ more->num_entries * sizeof (struct hol_entry));
+
+ mempcpy (short_options, hol->short_options, hol_so_len);
+
+ /* Fix up the short options pointers from HOL. */
+ for (e = entries, left = hol->num_entries; left > 0; e++, left--)
+ e->short_options += (short_options - hol->short_options);
+
+ /* Now add the short options from MORE, fixing up its entries
+ too. */
+ so = short_options + hol_so_len;
+ more_so = more->short_options;
+ for (left = more->num_entries; left > 0; e++, left--)
+ {
+ int opts_left;
+ const struct argp_option *opt;
+
+ e->short_options = so;
+
+ for (opts_left = e->num, opt = e->opt; opts_left; opt++, opts_left--)
+ {
+ int ch = *more_so;
+ if (oshort (opt) && ch == opt->key)
+ /* The next short option in MORE_SO, CH, is from OPT. */
+ {
+ if (! find_char (ch, short_options,
+ short_options + hol_so_len))
+ /* The short option CH isn't shadowed by HOL's options,
+ so add it to the sum. */
+ *so++ = ch;
+ more_so++;
+ }
+ }
+ }
+
+ *so = '\0';
+
+ free (hol->entries);
+ free (hol->short_options);
+
+ hol->entries = entries;
+ hol->num_entries = num_entries;
+ hol->short_options = short_options;
+ }
+ }
+
+ hol_free (more);
+}
+
+/* Inserts enough spaces to make sure STREAM is at column COL. */
+static void
+indent_to (argp_fmtstream_t stream, unsigned col)
+{
+ int needed = col - __argp_fmtstream_point (stream);
+ while (needed-- > 0)
+ __argp_fmtstream_putc (stream, ' ');
+}
+
+/* Output to STREAM either a space, or a newline if there isn't room for at
+ least ENSURE characters before the right margin. */
+static void
+space (argp_fmtstream_t stream, size_t ensure)
+{
+ if (__argp_fmtstream_point (stream) + ensure
+ >= __argp_fmtstream_rmargin (stream))
+ __argp_fmtstream_putc (stream, '\n');
+ else
+ __argp_fmtstream_putc (stream, ' ');
+}
+
+/* If the option REAL has an argument, we print it in using the printf
+ format REQ_FMT or OPT_FMT depending on whether it's a required or
+ optional argument. */
+static void
+arg (const struct argp_option *real, const char *req_fmt, const char *opt_fmt,
+ const char *domain, argp_fmtstream_t stream)
+{
+ if (real->arg)
+ {
+ if (real->flags & OPTION_ARG_OPTIONAL)
+ __argp_fmtstream_printf (stream, opt_fmt,
+ dgettext (domain, real->arg));
+ else
+ __argp_fmtstream_printf (stream, req_fmt,
+ dgettext (domain, real->arg));
+ }
+}
+
+/* Helper functions for hol_entry_help. */
+
+/* State used during the execution of hol_help. */
+struct hol_help_state
+{
+ /* PREV_ENTRY should contain the previous entry printed, or 0. */
+ struct hol_entry *prev_entry;
+
+ /* If an entry is in a different group from the previous one, and SEP_GROUPS
+ is true, then a blank line will be printed before any output. */
+ int sep_groups;
+
+ /* True if a duplicate option argument was suppressed (only ever set if
+ UPARAMS.dup_args is false). */
+ int suppressed_dup_arg;
+};
+
+/* Some state used while printing a help entry (used to communicate with
+ helper functions). See the doc for hol_entry_help for more info, as most
+ of the fields are copied from its arguments. */
+struct pentry_state
+{
+ const struct hol_entry *entry;
+ argp_fmtstream_t stream;
+ struct hol_help_state *hhstate;
+
+ /* True if nothing's been printed so far. */
+ int first;
+
+ /* If non-zero, the state that was used to print this help. */
+ const struct argp_state *state;
+};
+
+/* If a user doc filter should be applied to DOC, do so. */
+static const char *
+filter_doc (const char *doc, int key, const struct argp *argp,
+ const struct argp_state *state)
+{
+ if (argp && argp->help_filter)
+ /* We must apply a user filter to this output. */
+ {
+ void *input = __argp_input (argp, state);
+ return (*argp->help_filter) (key, doc, input);
+ }
+ else
+ /* No filter. */
+ return doc;
+}
+
+/* Prints STR as a header line, with the margin lines set appropiately, and
+ notes the fact that groups should be separated with a blank line. ARGP is
+ the argp that should dictate any user doc filtering to take place. Note
+ that the previous wrap margin isn't restored, but the left margin is reset
+ to 0. */
+static void
+print_header (const char *str, const struct argp *argp,
+ struct pentry_state *pest)
+{
+ const char *tstr = dgettext (argp->argp_domain, str);
+ const char *fstr = filter_doc (tstr, ARGP_KEY_HELP_HEADER, argp, pest->state);
+
+ if (fstr)
+ {
+ if (*fstr)
+ {
+ if (pest->hhstate->prev_entry)
+ /* Precede with a blank line. */
+ __argp_fmtstream_putc (pest->stream, '\n');
+ indent_to (pest->stream, uparams.header_col);
+ __argp_fmtstream_set_lmargin (pest->stream, uparams.header_col);
+ __argp_fmtstream_set_wmargin (pest->stream, uparams.header_col);
+ __argp_fmtstream_puts (pest->stream, fstr);
+ __argp_fmtstream_set_lmargin (pest->stream, 0);
+ __argp_fmtstream_putc (pest->stream, '\n');
+ }
+
+ pest->hhstate->sep_groups = 1; /* Separate subsequent groups. */
+ }
+
+ if (fstr != tstr)
+ free ((char *) fstr);
+}
+
+/* Inserts a comma if this isn't the first item on the line, and then makes
+ sure we're at least to column COL. If this *is* the first item on a line,
+ prints any pending whitespace/headers that should precede this line. Also
+ clears FIRST. */
+static void
+comma (unsigned col, struct pentry_state *pest)
+{
+ if (pest->first)
+ {
+ const struct hol_entry *pe = pest->hhstate->prev_entry;
+ const struct hol_cluster *cl = pest->entry->cluster;
+
+ if (pest->hhstate->sep_groups && pe && pest->entry->group != pe->group)
+ __argp_fmtstream_putc (pest->stream, '\n');
+
+ if (cl && cl->header && *cl->header
+ && (!pe
+ || (pe->cluster != cl
+ && !hol_cluster_is_child (pe->cluster, cl))))
+ /* If we're changing clusters, then this must be the start of the
+ ENTRY's cluster unless that is an ancestor of the previous one
+ (in which case we had just popped into a sub-cluster for a bit).
+ If so, then print the cluster's header line. */
+ {
+ int old_wm = __argp_fmtstream_wmargin (pest->stream);
+ print_header (cl->header, cl->argp, pest);
+ __argp_fmtstream_set_wmargin (pest->stream, old_wm);
+ }
+
+ pest->first = 0;
+ }
+ else
+ __argp_fmtstream_puts (pest->stream, ", ");
+
+ indent_to (pest->stream, col);
+}
+
+/* Print help for ENTRY to STREAM. */
+static void
+hol_entry_help (struct hol_entry *entry, const struct argp_state *state,
+ argp_fmtstream_t stream, struct hol_help_state *hhstate)
+{
+ unsigned num;
+ const struct argp_option *real = entry->opt, *opt;
+ char *so = entry->short_options;
+ int have_long_opt = 0; /* We have any long options. */
+ /* Saved margins. */
+ int old_lm = __argp_fmtstream_set_lmargin (stream, 0);
+ int old_wm = __argp_fmtstream_wmargin (stream);
+ /* PEST is a state block holding some of our variables that we'd like to
+ share with helper functions. */
+ struct pentry_state pest = { entry, stream, hhstate, 1, state };
+
+ if (! odoc (real))
+ for (opt = real, num = entry->num; num > 0; opt++, num--)
+ if (opt->name && ovisible (opt))
+ {
+ have_long_opt = 1;
+ break;
+ }
+
+ /* First emit short options. */
+ __argp_fmtstream_set_wmargin (stream, uparams.short_opt_col); /* For truly bizarre cases. */
+ for (opt = real, num = entry->num; num > 0; opt++, num--)
+ if (oshort (opt) && opt->key == *so)
+ /* OPT has a valid (non shadowed) short option. */
+ {
+ if (ovisible (opt))
+ {
+ comma (uparams.short_opt_col, &pest);
+ __argp_fmtstream_putc (stream, '-');
+ __argp_fmtstream_putc (stream, *so);
+ if (!have_long_opt || uparams.dup_args)
+ arg (real, " %s", "[%s]",
+ state == NULL ? NULL : state->root_argp->argp_domain,
+ stream);
+ else if (real->arg)
+ hhstate->suppressed_dup_arg = 1;
+ }
+ so++;
+ }
+
+ /* Now, long options. */
+ if (odoc (real))
+ /* A `documentation' option. */
+ {
+ __argp_fmtstream_set_wmargin (stream, uparams.doc_opt_col);
+ for (opt = real, num = entry->num; num > 0; opt++, num--)
+ if (opt->name && ovisible (opt))
+ {
+ comma (uparams.doc_opt_col, &pest);
+ /* Calling gettext here isn't quite right, since sorting will
+ have been done on the original; but documentation options
+ should be pretty rare anyway... */
+ __argp_fmtstream_puts (stream,
+ dgettext (state == NULL ? NULL
+ : state->root_argp->argp_domain,
+ opt->name));
+ }
+ }
+ else
+ /* A real long option. */
+ {
+ __argp_fmtstream_set_wmargin (stream, uparams.long_opt_col);
+ for (opt = real, num = entry->num; num > 0; opt++, num--)
+ if (opt->name && ovisible (opt))
+ {
+ comma (uparams.long_opt_col, &pest);
+ __argp_fmtstream_printf (stream, "--%s", opt->name);
+ arg (real, "=%s", "[=%s]",
+ state == NULL ? NULL : state->root_argp->argp_domain, stream);
+ }
+ }
+
+ /* Next, documentation strings. */
+ __argp_fmtstream_set_lmargin (stream, 0);
+
+ if (pest.first)
+ {
+ /* Didn't print any switches, what's up? */
+ if (!oshort (real) && !real->name)
+ /* This is a group header, print it nicely. */
+ print_header (real->doc, entry->argp, &pest);
+ else
+ /* Just a totally shadowed option or null header; print nothing. */
+ goto cleanup; /* Just return, after cleaning up. */
+ }
+ else
+ {
+ const char *tstr = real->doc ? dgettext (state == NULL ? NULL
+ : state->root_argp->argp_domain,
+ real->doc) : 0;
+ const char *fstr = filter_doc (tstr, real->key, entry->argp, state);
+ if (fstr && *fstr)
+ {
+ unsigned int col = __argp_fmtstream_point (stream);
+
+ __argp_fmtstream_set_lmargin (stream, uparams.opt_doc_col);
+ __argp_fmtstream_set_wmargin (stream, uparams.opt_doc_col);
+
+ if (col > (unsigned int) (uparams.opt_doc_col + 3))
+ __argp_fmtstream_putc (stream, '\n');
+ else if (col >= (unsigned int) uparams.opt_doc_col)
+ __argp_fmtstream_puts (stream, " ");
+ else
+ indent_to (stream, uparams.opt_doc_col);
+
+ __argp_fmtstream_puts (stream, fstr);
+ }
+ if (fstr && fstr != tstr)
+ free ((char *) fstr);
+
+ /* Reset the left margin. */
+ __argp_fmtstream_set_lmargin (stream, 0);
+ __argp_fmtstream_putc (stream, '\n');
+ }
+
+ hhstate->prev_entry = entry;
+
+cleanup:
+ __argp_fmtstream_set_lmargin (stream, old_lm);
+ __argp_fmtstream_set_wmargin (stream, old_wm);
+}
+
+/* Output a long help message about the options in HOL to STREAM. */
+static void
+hol_help (struct hol *hol, const struct argp_state *state,
+ argp_fmtstream_t stream)
+{
+ unsigned num;
+ struct hol_entry *entry;
+ struct hol_help_state hhstate = { 0, 0, 0 };
+
+ for (entry = hol->entries, num = hol->num_entries; num > 0; entry++, num--)
+ hol_entry_help (entry, state, stream, &hhstate);
+
+ if (hhstate.suppressed_dup_arg && uparams.dup_args_note)
+ {
+ const char *tstr = dgettext (state == NULL ? NULL
+ : state->root_argp->argp_domain, "\
+Mandatory or optional arguments to long options are also mandatory or \
+optional for any corresponding short options.");
+ const char *fstr = filter_doc (tstr, ARGP_KEY_HELP_DUP_ARGS_NOTE,
+ state ? state->root_argp : 0, state);
+ if (fstr && *fstr)
+ {
+ __argp_fmtstream_putc (stream, '\n');
+ __argp_fmtstream_puts (stream, fstr);
+ __argp_fmtstream_putc (stream, '\n');
+ }
+ if (fstr && fstr != tstr)
+ free ((char *) fstr);
+ }
+}
+
+/* Helper functions for hol_usage. */
+
+/* If OPT is a short option without an arg, append its key to the string
+ pointer pointer to by COOKIE, and advance the pointer. */
+static int
+add_argless_short_opt (const struct argp_option *opt,
+ const struct argp_option *real,
+ const char *domain, void *cookie)
+{
+ char **snao_end = cookie;
+ if (!(opt->arg || real->arg)
+ && !((opt->flags | real->flags) & OPTION_NO_USAGE))
+ *(*snao_end)++ = opt->key;
+ return 0;
+}
+
+/* If OPT is a short option with an arg, output a usage entry for it to the
+ stream pointed at by COOKIE. */
+static int
+usage_argful_short_opt (const struct argp_option *opt,
+ const struct argp_option *real,
+ const char *domain, void *cookie)
+{
+ argp_fmtstream_t stream = cookie;
+ const char *arg = opt->arg;
+ int flags = opt->flags | real->flags;
+
+ if (! arg)
+ arg = real->arg;
+
+ if (arg && !(flags & OPTION_NO_USAGE))
+ {
+ arg = dgettext (domain, arg);
+
+ if (flags & OPTION_ARG_OPTIONAL)
+ __argp_fmtstream_printf (stream, " [-%c[%s]]", opt->key, arg);
+ else
+ {
+ /* Manually do line wrapping so that it (probably) won't
+ get wrapped at the embedded space. */
+ space (stream, 6 + strlen (arg));
+ __argp_fmtstream_printf (stream, "[-%c %s]", opt->key, arg);
+ }
+ }
+
+ return 0;
+}
+
+/* Output a usage entry for the long option opt to the stream pointed at by
+ COOKIE. */
+static int
+usage_long_opt (const struct argp_option *opt,
+ const struct argp_option *real,
+ const char *domain, void *cookie)
+{
+ argp_fmtstream_t stream = cookie;
+ const char *arg = opt->arg;
+ int flags = opt->flags | real->flags;
+
+ if (! arg)
+ arg = real->arg;
+
+ if (! (flags & OPTION_NO_USAGE))
+ {
+ if (arg)
+ {
+ arg = dgettext (domain, arg);
+ if (flags & OPTION_ARG_OPTIONAL)
+ __argp_fmtstream_printf (stream, " [--%s[=%s]]", opt->name, arg);
+ else
+ __argp_fmtstream_printf (stream, " [--%s=%s]", opt->name, arg);
+ }
+ else
+ __argp_fmtstream_printf (stream, " [--%s]", opt->name);
+ }
+
+ return 0;
+}
+
+/* Print a short usage description for the arguments in HOL to STREAM. */
+static void
+hol_usage (struct hol *hol, argp_fmtstream_t stream)
+{
+ if (hol->num_entries > 0)
+ {
+ unsigned nentries;
+ struct hol_entry *entry;
+ char *short_no_arg_opts = alloca (strlen (hol->short_options) + 1);
+ char *snao_end = short_no_arg_opts;
+
+ /* First we put a list of short options without arguments. */
+ for (entry = hol->entries, nentries = hol->num_entries
+ ; nentries > 0
+ ; entry++, nentries--)
+ hol_entry_short_iterate (entry, add_argless_short_opt,
+ entry->argp->argp_domain, &snao_end);
+ if (snao_end > short_no_arg_opts)
+ {
+ *snao_end++ = 0;
+ __argp_fmtstream_printf (stream, " [-%s]", short_no_arg_opts);
+ }
+
+ /* Now a list of short options *with* arguments. */
+ for (entry = hol->entries, nentries = hol->num_entries
+ ; nentries > 0
+ ; entry++, nentries--)
+ hol_entry_short_iterate (entry, usage_argful_short_opt,
+ entry->argp->argp_domain, stream);
+
+ /* Finally, a list of long options (whew!). */
+ for (entry = hol->entries, nentries = hol->num_entries
+ ; nentries > 0
+ ; entry++, nentries--)
+ hol_entry_long_iterate (entry, usage_long_opt,
+ entry->argp->argp_domain, stream);
+ }
+}
+
+/* Make a HOL containing all levels of options in ARGP. CLUSTER is the
+ cluster in which ARGP's entries should be clustered, or 0. */
+static struct hol *
+argp_hol (const struct argp *argp, struct hol_cluster *cluster)
+{
+ const struct argp_child *child = argp->children;
+ struct hol *hol = make_hol (argp, cluster);
+ if (child)
+ while (child->argp)
+ {
+ struct hol_cluster *child_cluster =
+ ((child->group || child->header)
+ /* Put CHILD->argp within its own cluster. */
+ ? hol_add_cluster (hol, child->group, child->header,
+ child - argp->children, cluster, argp)
+ /* Just merge it into the parent's cluster. */
+ : cluster);
+ hol_append (hol, argp_hol (child->argp, child_cluster)) ;
+ child++;
+ }
+ return hol;
+}
+
+/* Calculate how many different levels with alternative args strings exist in
+ ARGP. */
+static size_t
+argp_args_levels (const struct argp *argp)
+{
+ size_t levels = 0;
+ const struct argp_child *child = argp->children;
+
+ if (argp->args_doc && strchr (argp->args_doc, '\n'))
+ levels++;
+
+ if (child)
+ while (child->argp)
+ levels += argp_args_levels ((child++)->argp);
+
+ return levels;
+}
+
+/* Print all the non-option args documented in ARGP to STREAM. Any output is
+ preceded by a space. LEVELS is a pointer to a byte vector the length
+ returned by argp_args_levels; it should be initialized to zero, and
+ updated by this routine for the next call if ADVANCE is true. True is
+ returned as long as there are more patterns to output. */
+static int
+argp_args_usage (const struct argp *argp, const struct argp_state *state,
+ char **levels, int advance, argp_fmtstream_t stream)
+{
+ char *our_level = *levels;
+ int multiple = 0;
+ const struct argp_child *child = argp->children;
+ const char *tdoc = dgettext (argp->argp_domain, argp->args_doc), *nl = 0;
+ const char *fdoc = filter_doc (tdoc, ARGP_KEY_HELP_ARGS_DOC, argp, state);
+
+ if (fdoc)
+ {
+ const char *cp = fdoc;
+ nl = strchrnul (cp, '\n');
+ if (*nl != '\0')
+ /* This is a `multi-level' args doc; advance to the correct position
+ as determined by our state in LEVELS, and update LEVELS. */
+ {
+ int i;
+ multiple = 1;
+ for (i = 0; i < *our_level; i++)
+ cp = nl + 1, nl = strchrnul (cp, '\n');
+ (*levels)++;
+ }
+
+ /* Manually do line wrapping so that it (probably) won't get wrapped at
+ any embedded spaces. */
+ space (stream, 1 + nl - cp);
+
+ __argp_fmtstream_write (stream, cp, nl - cp);
+ }
+ if (fdoc && fdoc != tdoc)
+ free ((char *)fdoc); /* Free user's modified doc string. */
+
+ if (child)
+ while (child->argp)
+ advance = !argp_args_usage ((child++)->argp, state, levels, advance, stream);
+
+ if (advance && multiple)
+ {
+ /* Need to increment our level. */
+ if (*nl)
+ /* There's more we can do here. */
+ {
+ (*our_level)++;
+ advance = 0; /* Our parent shouldn't advance also. */
+ }
+ else if (*our_level > 0)
+ /* We had multiple levels, but used them up; reset to zero. */
+ *our_level = 0;
+ }
+
+ return !advance;
+}
+
+/* Print the documentation for ARGP to STREAM; if POST is false, then
+ everything preceeding a `\v' character in the documentation strings (or
+ the whole string, for those with none) is printed, otherwise, everything
+ following the `\v' character (nothing for strings without). Each separate
+ bit of documentation is separated a blank line, and if PRE_BLANK is true,
+ then the first is as well. If FIRST_ONLY is true, only the first
+ occurrence is output. Returns true if anything was output. */
+static int
+argp_doc (const struct argp *argp, const struct argp_state *state,
+ int post, int pre_blank, int first_only,
+ argp_fmtstream_t stream)
+{
+ const char *text;
+ const char *inp_text;
+ void *input = 0;
+ int anything = 0;
+ size_t inp_text_limit = 0;
+ const char *doc = dgettext (argp->argp_domain, argp->doc);
+ const struct argp_child *child = argp->children;
+
+ if (doc)
+ {
+ char *vt = strchr (doc, '\v');
+ inp_text = post ? (vt ? vt + 1 : 0) : doc;
+ inp_text_limit = (!post && vt) ? (vt - doc) : 0;
+ }
+ else
+ inp_text = 0;
+
+ if (argp->help_filter)
+ /* We have to filter the doc strings. */
+ {
+ if (inp_text_limit)
+ /* Copy INP_TEXT so that it's nul-terminated. */
+ inp_text = strndup (inp_text, inp_text_limit);
+ input = __argp_input (argp, state);
+ text =
+ (*argp->help_filter) (post
+ ? ARGP_KEY_HELP_POST_DOC
+ : ARGP_KEY_HELP_PRE_DOC,
+ inp_text, input);
+ }
+ else
+ text = (const char *) inp_text;
+
+ if (text)
+ {
+ if (pre_blank)
+ __argp_fmtstream_putc (stream, '\n');
+
+ if (text == inp_text && inp_text_limit)
+ __argp_fmtstream_write (stream, inp_text, inp_text_limit);
+ else
+ __argp_fmtstream_puts (stream, text);
+
+ if (__argp_fmtstream_point (stream) > __argp_fmtstream_lmargin (stream))
+ __argp_fmtstream_putc (stream, '\n');
+
+ anything = 1;
+ }
+
+ if (text && text != inp_text)
+ free ((char *) text); /* Free TEXT returned from the help filter. */
+ if (inp_text && inp_text_limit && argp->help_filter)
+ free ((char *) inp_text); /* We copied INP_TEXT, so free it now. */
+
+ if (post && argp->help_filter)
+ /* Now see if we have to output a ARGP_KEY_HELP_EXTRA text. */
+ {
+ text = (*argp->help_filter) (ARGP_KEY_HELP_EXTRA, 0, input);
+ if (text)
+ {
+ if (anything || pre_blank)
+ __argp_fmtstream_putc (stream, '\n');
+ __argp_fmtstream_puts (stream, text);
+ free ((char *) text);
+ if (__argp_fmtstream_point (stream)
+ > __argp_fmtstream_lmargin (stream))
+ __argp_fmtstream_putc (stream, '\n');
+ anything = 1;
+ }
+ }
+
+ if (child)
+ while (child->argp && !(first_only && anything))
+ anything |=
+ argp_doc ((child++)->argp, state,
+ post, anything || pre_blank, first_only,
+ stream);
+
+ return anything;
+}
+
+/* Output a usage message for ARGP to STREAM. If called from
+ argp_state_help, STATE is the relevent parsing state. FLAGS are from the
+ set ARGP_HELP_*. NAME is what to use wherever a `program name' is
+ needed. */
+static void
+_help (const struct argp *argp, const struct argp_state *state, FILE *stream,
+ unsigned flags, char *name)
+{
+ int anything = 0; /* Whether we've output anything. */
+ struct hol *hol = 0;
+ argp_fmtstream_t fs;
+
+ if (! stream)
+ return;
+
+#if _LIBC || (HAVE_FLOCKFILE && HAVE_FUNLOCKFILE)
+ flockfile (stream);
+#endif
+
+ fill_in_uparams (state);
+
+ fs = __argp_make_fmtstream (stream, 0, uparams.rmargin, 0);
+ if (! fs)
+ {
+#if _LIBC || (HAVE_FLOCKFILE && HAVE_FUNLOCKFILE)
+ funlockfile (stream);
+#endif
+ return;
+ }
+
+ if (flags & (ARGP_HELP_USAGE | ARGP_HELP_SHORT_USAGE | ARGP_HELP_LONG))
+ {
+ hol = argp_hol (argp, 0);
+
+ /* If present, these options always come last. */
+ hol_set_group (hol, "help", -1);
+ hol_set_group (hol, "version", -1);
+
+ hol_sort (hol);
+ }
+
+ if (flags & (ARGP_HELP_USAGE | ARGP_HELP_SHORT_USAGE))
+ /* Print a short `Usage:' message. */
+ {
+ int first_pattern = 1, more_patterns;
+ size_t num_pattern_levels = argp_args_levels (argp);
+ char *pattern_levels = alloca (num_pattern_levels);
+
+ memset (pattern_levels, 0, num_pattern_levels);
+
+ do
+ {
+ int old_lm;
+ int old_wm = __argp_fmtstream_set_wmargin (fs, uparams.usage_indent);
+ char *levels = pattern_levels;
+
+ if (first_pattern)
+ __argp_fmtstream_printf (fs, "%s %s",
+ dgettext (argp->argp_domain, "Usage:"),
+ name);
+ else
+ __argp_fmtstream_printf (fs, "%s %s",
+ dgettext (argp->argp_domain, " or: "),
+ name);
+
+ /* We set the lmargin as well as the wmargin, because hol_usage
+ manually wraps options with newline to avoid annoying breaks. */
+ old_lm = __argp_fmtstream_set_lmargin (fs, uparams.usage_indent);
+
+ if (flags & ARGP_HELP_SHORT_USAGE)
+ /* Just show where the options go. */
+ {
+ if (hol->num_entries > 0)
+ __argp_fmtstream_puts (fs, dgettext (argp->argp_domain,
+ " [OPTION...]"));
+ }
+ else
+ /* Actually print the options. */
+ {
+ hol_usage (hol, fs);
+ flags |= ARGP_HELP_SHORT_USAGE; /* But only do so once. */
+ }
+
+ more_patterns = argp_args_usage (argp, state, &levels, 1, fs);
+
+ __argp_fmtstream_set_wmargin (fs, old_wm);
+ __argp_fmtstream_set_lmargin (fs, old_lm);
+
+ __argp_fmtstream_putc (fs, '\n');
+ anything = 1;
+
+ first_pattern = 0;
+ }
+ while (more_patterns);
+ }
+
+ if (flags & ARGP_HELP_PRE_DOC)
+ anything |= argp_doc (argp, state, 0, 0, 1, fs);
+
+ if (flags & ARGP_HELP_SEE)
+ {
+ __argp_fmtstream_printf (fs, dgettext (argp->argp_domain, "\
+Try `%s --help' or `%s --usage' for more information.\n"),
+ name, name);
+ anything = 1;
+ }
+
+ if (flags & ARGP_HELP_LONG)
+ /* Print a long, detailed help message. */
+ {
+ /* Print info about all the options. */
+ if (hol->num_entries > 0)
+ {
+ if (anything)
+ __argp_fmtstream_putc (fs, '\n');
+ hol_help (hol, state, fs);
+ anything = 1;
+ }
+ }
+
+ if (flags & ARGP_HELP_POST_DOC)
+ /* Print any documentation strings at the end. */
+ anything |= argp_doc (argp, state, 1, anything, 0, fs);
+
+ if ((flags & ARGP_HELP_BUG_ADDR) && argp_program_bug_address)
+ {
+ if (anything)
+ __argp_fmtstream_putc (fs, '\n');
+ __argp_fmtstream_printf (fs, dgettext (argp->argp_domain,
+ "Report bugs to %s.\n"),
+ argp_program_bug_address);
+ anything = 1;
+ }
+
+#if _LIBC || (HAVE_FLOCKFILE && HAVE_FUNLOCKFILE)
+ funlockfile (stream);
+#endif
+
+ if (hol)
+ hol_free (hol);
+
+ __argp_fmtstream_free (fs);
+}
+
+/* Output a usage message for ARGP to STREAM. FLAGS are from the set
+ ARGP_HELP_*. NAME is what to use wherever a `program name' is needed. */
+void argp_help (const struct argp *argp, FILE *stream,
+ unsigned flags, char *name)
+{
+ _help (argp, 0, stream, flags, name);
+}
+
+char *
+__argp_short_program_name (void)
+{
+# ifdef __UCLIBC_HAS_PROGRAM_INVOCATION_NAME__
+/*
+ * uClibc provides both program_invocation_name and
+ * program_invocation_short_name
+ */
+ return (char *) program_invocation_short_name;
+# else
+ /* FIXME: What now? Miles suggests that it is better to use NULL,
+ but currently the value is passed on directly to fputs_unlocked,
+ so that requires more changes. */
+# if __GNUC__
+# warning No reasonable value to return
+# endif /* __GNUC__ */
+ return "";
+# endif
+}
+
+/* Output, if appropriate, a usage message for STATE to STREAM. FLAGS are
+ from the set ARGP_HELP_*. */
+void
+argp_state_help (const struct argp_state *state, FILE *stream, unsigned flags)
+{
+ if ((!state || ! (state->flags & ARGP_NO_ERRS)) && stream)
+ {
+ if (state && (state->flags & ARGP_LONG_ONLY))
+ flags |= ARGP_HELP_LONG_ONLY;
+
+ _help (state ? state->root_argp : 0, state, stream, flags,
+ state ? state->name : __argp_short_program_name ());
+
+ if (!state || ! (state->flags & ARGP_NO_EXIT))
+ {
+ if (flags & ARGP_HELP_EXIT_ERR)
+ exit (argp_err_exit_status);
+ if (flags & ARGP_HELP_EXIT_OK)
+ exit (0);
+ }
+ }
+}
+
+/* If appropriate, print the printf string FMT and following args, preceded
+ by the program name and `:', to stderr, and followed by a `Try ... --help'
+ message, then exit (1). */
+void
+argp_error (const struct argp_state *state, const char *fmt, ...)
+{
+ if (!state || !(state->flags & ARGP_NO_ERRS))
+ {
+ FILE *stream = state ? state->err_stream : stderr;
+
+ if (stream)
+ {
+ va_list ap;
+
+#if _LIBC || (HAVE_FLOCKFILE && HAVE_FUNLOCKFILE)
+ flockfile (stream);
+#endif
+
+ va_start (ap, fmt);
+
+#if defined _LIBC && defined USE_IN_LIBIO
+ char *buf;
+
+ if (_IO_vasprintf (&buf, fmt, ap) < 0)
+ buf = NULL;
+
+ __fxprintf (stream, "%s: %s\n",
+ state ? state->name : __argp_short_program_name (), buf);
+
+ free (buf);
+#else
+ fputs_unlocked (state ? state->name : __argp_short_program_name (),
+ stream);
+ putc_unlocked (':', stream);
+ putc_unlocked (' ', stream);
+
+ vfprintf (stream, fmt, ap);
+
+ putc_unlocked ('\n', stream);
+#endif
+
+ argp_state_help (state, stream, ARGP_HELP_STD_ERR);
+
+ va_end (ap);
+
+#if _LIBC || (HAVE_FLOCKFILE && HAVE_FUNLOCKFILE)
+ funlockfile (stream);
+#endif
+ }
+ }
+}
+
+/* Similar to the standard gnu error-reporting function error(), but will
+ respect the ARGP_NO_EXIT and ARGP_NO_ERRS flags in STATE, and will print
+ to STATE->err_stream. This is useful for argument parsing code that is
+ shared between program startup (when exiting is desired) and runtime
+ option parsing (when typically an error code is returned instead). The
+ difference between this function and argp_error is that the latter is for
+ *parsing errors*, and the former is for other problems that occur during
+ parsing but don't reflect a (syntactic) problem with the input. */
+void
+argp_failure (const struct argp_state *state, int status, int errnum,
+ const char *fmt, ...)
+{
+ if (!state || !(state->flags & ARGP_NO_ERRS))
+ {
+ FILE *stream = state ? state->err_stream : stderr;
+
+ if (stream)
+ {
+#if _LIBC || (HAVE_FLOCKFILE && HAVE_FUNLOCKFILE)
+ flockfile (stream);
+#endif
+
+#if defined _LIBC && defined USE_IN_LIBIO
+ __fxprintf (stream, "%s",
+ state ? state->name : __argp_short_program_name ());
+#else
+ fputs_unlocked (state ? state->name : __argp_short_program_name (),
+ stream);
+#endif
+
+ if (fmt)
+ {
+ va_list ap;
+
+ va_start (ap, fmt);
+#if defined _LIBC && defined USE_IN_LIBIO
+ char *buf;
+
+ if (_IO_vasprintf (&buf, fmt, ap) < 0)
+ buf = NULL;
+
+ __fxprintf (stream, ": %s", buf);
+
+ free (buf);
+#else
+ putc_unlocked (':', stream);
+ putc_unlocked (' ', stream);
+
+ vfprintf (stream, fmt, ap);
+#endif
+
+ va_end (ap);
+ }
+
+ if (errnum)
+ {
+#if (defined _LIBC && defined USE_IN_LIBIO) || defined HAVE_STRERROR_R
+ char buf[200];
+#endif
+#if defined _LIBC && defined USE_IN_LIBIO
+ __fxprintf (stream, ": %s",
+ strerror_r (errnum, buf, sizeof (buf)));
+#else
+ putc_unlocked (':', stream);
+ putc_unlocked (' ', stream);
+# ifdef HAVE_STRERROR_R
+ fputs (strerror_r (errnum, buf, sizeof (buf)), stream);
+# else
+ fputs (strerror (errnum), stream);
+# endif
+#endif
+ }
+
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stream, 0) > 0)
+ putwc_unlocked (L'\n', stream);
+ else
+#endif
+ putc_unlocked ('\n', stream);
+
+#if _LIBC || (HAVE_FLOCKFILE && HAVE_FUNLOCKFILE)
+ funlockfile (stream);
+#endif
+
+ if (status && (!state || !(state->flags & ARGP_NO_EXIT)))
+ exit (status);
+ }
+ }
+}
diff --git a/libuargp/argp-parse.c b/libuargp/argp-parse.c
new file mode 100644
index 000000000..86b2b24ee
--- /dev/null
+++ b/libuargp/argp-parse.c
@@ -0,0 +1,949 @@
+/* Hierarchial argument parsing, layered over getopt
+ Copyright (C) 1995-2000, 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Miles Bader <miles at gnu.ai.mit.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.
+
+ Modified for uClibc by: Salvatore Cro <salvatore.cro at st.com>
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+/* AIX requires this to be the first thing in the file. */
+#ifndef __GNUC__
+# if HAVE_ALLOCA_H || defined _LIBC
+# include <alloca.h>
+# else
+# ifdef _AIX
+#pragma alloca
+# else
+# ifndef alloca /* predefined by HP cc +Olibcalls */
+char *alloca ();
+# endif
+# endif
+# endif
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <limits.h>
+#include <getopt.h>
+#include <bits/getopt_int.h>
+
+#include <features.h>
+#ifndef _
+/* This is for other GNU distributions with internationalized messages.
+ When compiling libc, the _ macro is predefined. */
+# if (defined HAVE_LIBINTL_H || defined _LIBC) && defined __UCLIBC_HAS_GETTEXT_AWARENESS__
+# include <libintl.h>
+# ifdef _LIBC
+# undef dgettext
+# define dgettext(domain, msgid) \
+ INTUSE(__dcgettext) (domain, msgid, LC_MESSAGES)
+# endif
+# else
+# define dgettext(domain, msgid) (msgid)
+# define gettext(msgid) (msgid)
+# endif
+#endif
+#ifndef N_
+# define N_(msgid) (msgid)
+#endif
+
+#include <argp.h>
+
+/* Getopt return values. */
+#define KEY_END (-1) /* The end of the options. */
+#define KEY_ARG 1 /* A non-option argument. */
+#define KEY_ERR '?' /* An error parsing the options. */
+
+/* The meta-argument used to prevent any further arguments being interpreted
+ as options. */
+#define QUOTE "--"
+
+/* The number of bits we steal in a long-option value for our own use. */
+#define GROUP_BITS CHAR_BIT
+
+/* The number of bits available for the user value. */
+#define USER_BITS ((sizeof ((struct option *)0)->val * CHAR_BIT) - GROUP_BITS)
+#define USER_MASK ((1 << USER_BITS) - 1)
+
+/* EZ alias for ARGP_ERR_UNKNOWN. */
+#define EBADKEY ARGP_ERR_UNKNOWN
+
+/* Default options. */
+
+/* When argp is given the --HANG switch, _ARGP_HANG is set and argp will sleep
+ for one second intervals, decrementing _ARGP_HANG until it's zero. Thus
+ you can force the program to continue by attaching a debugger and setting
+ it to 0 yourself. */
+static volatile int _argp_hang;
+
+#define OPT_PROGNAME -2
+#define OPT_USAGE -3
+#define OPT_HANG -4
+
+static const struct argp_option argp_default_options[] =
+{
+ {"help", '?', 0, 0, N_("Give this help list"), -1},
+ {"usage", OPT_USAGE, 0, 0, N_("Give a short usage message")},
+ {"program-name",OPT_PROGNAME,"NAME", OPTION_HIDDEN, N_("Set the program name")},
+ {"HANG", OPT_HANG, "SECS", OPTION_ARG_OPTIONAL | OPTION_HIDDEN,
+ N_("Hang for SECS seconds (default 3600)")},
+ {0, 0}
+};
+
+static error_t
+argp_default_parser (int key, char *arg, struct argp_state *state)
+{
+ switch (key)
+ {
+ case '?':
+ argp_state_help (state, state->out_stream, ARGP_HELP_STD_HELP);
+ break;
+ case OPT_USAGE:
+ argp_state_help (state, state->out_stream,
+ ARGP_HELP_USAGE | ARGP_HELP_EXIT_OK);
+ break;
+
+ case OPT_PROGNAME: /* Set the program name. */
+#if defined _LIBC || HAVE_DECL_PROGRAM_INVOCATION_NAME
+ program_invocation_name = arg;
+#endif
+ /* [Note that some systems only have PROGRAM_INVOCATION_SHORT_NAME (aka
+ __PROGNAME), in which case, PROGRAM_INVOCATION_NAME is just defined
+ to be that, so we have to be a bit careful here.] */
+
+ /* Update what we use for messages. */
+ state->name = strrchr (arg, '/');
+ if (state->name)
+ state->name++;
+ else
+ state->name = arg;
+
+#if defined _LIBC || HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
+ program_invocation_short_name = state->name;
+#endif
+
+ if ((state->flags & (ARGP_PARSE_ARGV0 | ARGP_NO_ERRS))
+ == ARGP_PARSE_ARGV0)
+ /* Update what getopt uses too. */
+ state->argv[0] = arg;
+
+ break;
+
+ case OPT_HANG:
+ _argp_hang = atoi (arg ? arg : "3600");
+ while (_argp_hang-- > 0)
+ sleep (1);
+ break;
+
+ default:
+ return EBADKEY;
+ }
+ return 0;
+}
+
+static const struct argp argp_default_argp =
+ {argp_default_options, &argp_default_parser, NULL, NULL, NULL, NULL, "libc"};
+
+
+static const struct argp_option argp_version_options[] =
+{
+ {"version", 'V', 0, 0, N_("Print program version"), -1},
+ {0, 0}
+};
+
+static error_t
+argp_version_parser (int key, char *arg, struct argp_state *state)
+{
+ switch (key)
+ {
+ case 'V':
+ if (argp_program_version_hook)
+ (*argp_program_version_hook) (state->out_stream, state);
+ else if (argp_program_version)
+ fprintf (state->out_stream, "%s\n", argp_program_version);
+ else
+ argp_error (state, dgettext (state->root_argp->argp_domain,
+ "(PROGRAM ERROR) No version known!?"));
+ if (! (state->flags & ARGP_NO_EXIT))
+ exit (0);
+ break;
+ default:
+ return EBADKEY;
+ }
+ return 0;
+}
+
+static const struct argp argp_version_argp =
+ {argp_version_options, &argp_version_parser, NULL, NULL, NULL, NULL, "libc"};
+
+/* Returns the offset into the getopt long options array LONG_OPTIONS of a
+ long option with called NAME, or -1 if none is found. Passing NULL as
+ NAME will return the number of options. */
+static int
+find_long_option (struct option *long_options, const char *name)
+{
+ struct option *l = long_options;
+ while (l->name != NULL)
+ if (name != NULL && strcmp (l->name, name) == 0)
+ return l - long_options;
+ else
+ l++;
+ if (name == NULL)
+ return l - long_options;
+ else
+ return -1;
+}
+
+
+/* The state of a `group' during parsing. Each group corresponds to a
+ particular argp structure from the tree of such descending from the top
+ level argp passed to argp_parse. */
+struct group
+{
+ /* This group's parsing function. */
+ argp_parser_t parser;
+
+ /* Which argp this group is from. */
+ const struct argp *argp;
+
+ /* Points to the point in SHORT_OPTS corresponding to the end of the short
+ options for this group. We use it to determine from which group a
+ particular short options is from. */
+ char *short_end;
+
+ /* The number of non-option args sucessfully handled by this parser. */
+ unsigned args_processed;
+
+ /* This group's parser's parent's group. */
+ struct group *parent;
+ unsigned parent_index; /* And the our position in the parent. */
+
+ /* These fields are swapped into and out of the state structure when
+ calling this group's parser. */
+ void *input, **child_inputs;
+ void *hook;
+};
+
+/* Call GROUP's parser with KEY and ARG, swapping any group-specific info
+ from STATE before calling, and back into state afterwards. If GROUP has
+ no parser, EBADKEY is returned. */
+static error_t
+group_parse (struct group *group, struct argp_state *state, int key, char *arg)
+{
+ if (group->parser)
+ {
+ error_t err;
+ state->hook = group->hook;
+ state->input = group->input;
+ state->child_inputs = group->child_inputs;
+ state->arg_num = group->args_processed;
+ err = (*group->parser)(key, arg, state);
+ group->hook = state->hook;
+ return err;
+ }
+ else
+ return EBADKEY;
+}
+
+struct parser
+{
+ const struct argp *argp;
+
+ /* SHORT_OPTS is the getopt short options string for the union of all the
+ groups of options. */
+ char *short_opts;
+ /* LONG_OPTS is the array of getop long option structures for the union of
+ all the groups of options. */
+ struct option *long_opts;
+ /* OPT_DATA is the getopt data used for the re-entrant getopt. */
+ struct _getopt_data opt_data;
+
+ /* States of the various parsing groups. */
+ struct group *groups;
+ /* The end of the GROUPS array. */
+ struct group *egroup;
+ /* An vector containing storage for the CHILD_INPUTS field in all groups. */
+ void **child_inputs;
+
+ /* True if we think using getopt is still useful; if false, then
+ remaining arguments are just passed verbatim with ARGP_KEY_ARG. This is
+ cleared whenever getopt returns KEY_END, but may be set again if the user
+ moves the next argument pointer backwards. */
+ int try_getopt;
+
+ /* State block supplied to parsing routines. */
+ struct argp_state state;
+
+ /* Memory used by this parser. */
+ void *storage;
+};
+
+/* The next usable entries in the various parser tables being filled in by
+ convert_options. */
+struct parser_convert_state
+{
+ struct parser *parser;
+ char *short_end;
+ struct option *long_end;
+ void **child_inputs_end;
+};
+
+/* Converts all options in ARGP (which is put in GROUP) and ancestors
+ into getopt options stored in SHORT_OPTS and LONG_OPTS; SHORT_END and
+ CVT->LONG_END are the points at which new options are added. Returns the
+ next unused group entry. CVT holds state used during the conversion. */
+static struct group *
+convert_options (const struct argp *argp,
+ struct group *parent, unsigned parent_index,
+ struct group *group, struct parser_convert_state *cvt)
+{
+ /* REAL is the most recent non-alias value of OPT. */
+ const struct argp_option *real = argp->options;
+ const struct argp_child *children = argp->children;
+
+ if (real || argp->parser)
+ {
+ const struct argp_option *opt;
+
+ if (real)
+ for (opt = real; !__option_is_end (opt); opt++)
+ {
+ if (! (opt->flags & OPTION_ALIAS))
+ /* OPT isn't an alias, so we can use values from it. */
+ real = opt;
+
+ if (! (real->flags & OPTION_DOC))
+ /* A real option (not just documentation). */
+ {
+ if (__option_is_short (opt))
+ /* OPT can be used as a short option. */
+ {
+ *cvt->short_end++ = opt->key;
+ if (real->arg)
+ {
+ *cvt->short_end++ = ':';
+ if (real->flags & OPTION_ARG_OPTIONAL)
+ *cvt->short_end++ = ':';
+ }
+ *cvt->short_end = '\0'; /* keep 0 terminated */
+ }
+
+ if (opt->name
+ && find_long_option (cvt->parser->long_opts, opt->name) < 0)
+ /* OPT can be used as a long option. */
+ {
+ cvt->long_end->name = opt->name;
+ cvt->long_end->has_arg =
+ (real->arg
+ ? (real->flags & OPTION_ARG_OPTIONAL
+ ? optional_argument
+ : required_argument)
+ : no_argument);
+ cvt->long_end->flag = 0;
+ /* we add a disambiguating code to all the user's
+ values (which is removed before we actually call
+ the function to parse the value); this means that
+ the user loses use of the high 8 bits in all his
+ values (the sign of the lower bits is preserved
+ however)... */
+ cvt->long_end->val =
+ ((opt->key | real->key) & USER_MASK)
+ + (((group - cvt->parser->groups) + 1) << USER_BITS);
+
+ /* Keep the LONG_OPTS list terminated. */
+ (++cvt->long_end)->name = NULL;
+ }
+ }
+ }
+
+ group->parser = argp->parser;
+ group->argp = argp;
+ group->short_end = cvt->short_end;
+ group->args_processed = 0;
+ group->parent = parent;
+ group->parent_index = parent_index;
+ group->input = 0;
+ group->hook = 0;
+ group->child_inputs = 0;
+
+ if (children)
+ /* Assign GROUP's CHILD_INPUTS field some space from
+ CVT->child_inputs_end.*/
+ {
+ unsigned num_children = 0;
+ while (children[num_children].argp)
+ num_children++;
+ group->child_inputs = cvt->child_inputs_end;
+ cvt->child_inputs_end += num_children;
+ }
+
+ parent = group++;
+ }
+ else
+ parent = 0;
+
+ if (children)
+ {
+ unsigned index = 0;
+ while (children->argp)
+ group =
+ convert_options (children++->argp, parent, index++, group, cvt);
+ }
+
+ return group;
+}
+
+/* Find the merged set of getopt options, with keys appropiately prefixed. */
+static void
+parser_convert (struct parser *parser, const struct argp *argp, int flags)
+{
+ struct parser_convert_state cvt;
+
+ cvt.parser = parser;
+ cvt.short_end = parser->short_opts;
+ cvt.long_end = parser->long_opts;
+ cvt.child_inputs_end = parser->child_inputs;
+
+ if (flags & ARGP_IN_ORDER)
+ *cvt.short_end++ = '-';
+ else if (flags & ARGP_NO_ARGS)
+ *cvt.short_end++ = '+';
+ *cvt.short_end = '\0';
+
+ cvt.long_end->name = NULL;
+
+ parser->argp = argp;
+
+ if (argp)
+ parser->egroup = convert_options (argp, 0, 0, parser->groups, &cvt);
+ else
+ parser->egroup = parser->groups; /* No parsers at all! */
+}
+
+/* Lengths of various parser fields which we will allocated. */
+struct parser_sizes
+{
+ size_t short_len; /* Getopt short options string. */
+ size_t long_len; /* Getopt long options vector. */
+ size_t num_groups; /* Group structures we allocate. */
+ size_t num_child_inputs; /* Child input slots. */
+};
+
+/* For ARGP, increments the NUM_GROUPS field in SZS by the total number of
+ argp structures descended from it, and the SHORT_LEN & LONG_LEN fields by
+ the maximum lengths of the resulting merged getopt short options string and
+ long-options array, respectively. */
+static void
+calc_sizes (const struct argp *argp, struct parser_sizes *szs)
+{
+ const struct argp_child *child = argp->children;
+ const struct argp_option *opt = argp->options;
+
+ if (opt || argp->parser)
+ {
+ szs->num_groups++;
+ if (opt)
+ {
+ int num_opts = 0;
+ while (!__option_is_end (opt++))
+ num_opts++;
+ szs->short_len += num_opts * 3; /* opt + up to 2 `:'s */
+ szs->long_len += num_opts;
+ }
+ }
+
+ if (child)
+ while (child->argp)
+ {
+ calc_sizes ((child++)->argp, szs);
+ szs->num_child_inputs++;
+ }
+}
+
+
+extern char * __argp_short_program_name (void);
+/* Initializes PARSER to parse ARGP in a manner described by FLAGS. */
+static error_t
+parser_init (struct parser *parser, const struct argp *argp,
+ int argc, char **argv, int flags, void *input)
+{
+ error_t err = 0;
+ struct group *group;
+ struct parser_sizes szs;
+ struct _getopt_data opt_data = _GETOPT_DATA_INITIALIZER;
+
+ szs.short_len = (flags & ARGP_NO_ARGS) ? 0 : 1;
+ szs.long_len = 0;
+ szs.num_groups = 0;
+ szs.num_child_inputs = 0;
+
+ if (argp)
+ calc_sizes (argp, &szs);
+
+ /* Lengths of the various bits of storage used by PARSER. */
+#define GLEN (szs.num_groups + 1) * sizeof (struct group)
+#define CLEN (szs.num_child_inputs * sizeof (void *))
+#define LLEN ((szs.long_len + 1) * sizeof (struct option))
+#define SLEN (szs.short_len + 1)
+
+ parser->storage = malloc (GLEN + CLEN + LLEN + SLEN);
+ if (! parser->storage)
+ return ENOMEM;
+
+ parser->groups = parser->storage;
+ parser->child_inputs = parser->storage + GLEN;
+ parser->long_opts = parser->storage + GLEN + CLEN;
+ parser->short_opts = parser->storage + GLEN + CLEN + LLEN;
+ parser->opt_data = opt_data;
+
+ memset (parser->child_inputs, 0, szs.num_child_inputs * sizeof (void *));
+ parser_convert (parser, argp, flags);
+
+ memset (&parser->state, 0, sizeof (struct argp_state));
+ parser->state.root_argp = parser->argp;
+ parser->state.argc = argc;
+ parser->state.argv = argv;
+ parser->state.flags = flags;
+ parser->state.err_stream = stderr;
+ parser->state.out_stream = stdout;
+ parser->state.next = 0; /* Tell getopt to initialize. */
+ parser->state.pstate = parser;
+
+ parser->try_getopt = 1;
+
+ /* Call each parser for the first time, giving it a chance to propagate
+ values to child parsers. */
+ if (parser->groups < parser->egroup)
+ parser->groups->input = input;
+ for (group = parser->groups;
+ group < parser->egroup && (!err || err == EBADKEY);
+ group++)
+ {
+ if (group->parent)
+ /* If a child parser, get the initial input value from the parent. */
+ group->input = group->parent->child_inputs[group->parent_index];
+
+ if (!group->parser
+ && group->argp->children && group->argp->children->argp)
+ /* For the special case where no parsing function is supplied for an
+ argp, propagate its input to its first child, if any (this just
+ makes very simple wrapper argps more convenient). */
+ group->child_inputs[0] = group->input;
+
+ err = group_parse (group, &parser->state, ARGP_KEY_INIT, 0);
+ }
+ if (err == EBADKEY)
+ err = 0; /* Some parser didn't understand. */
+
+ if (err)
+ return err;
+
+ if (parser->state.flags & ARGP_NO_ERRS)
+ {
+ parser->opt_data.opterr = 0;
+ if (parser->state.flags & ARGP_PARSE_ARGV0)
+ /* getopt always skips ARGV[0], so we have to fake it out. As long
+ as OPTERR is 0, then it shouldn't actually try to access it. */
+ parser->state.argv--, parser->state.argc++;
+ }
+ else
+ parser->opt_data.opterr = 1; /* Print error messages. */
+
+ if (parser->state.argv == argv && argv[0])
+ /* There's an argv[0]; use it for messages. */
+ {
+ char *short_name = strrchr (argv[0], '/');
+ parser->state.name = short_name ? short_name + 1 : argv[0];
+ }
+ else
+ parser->state.name = __argp_short_program_name ();
+
+ return 0;
+}
+
+/* Free any storage consumed by PARSER (but not PARSER itself). */
+static error_t
+parser_finalize (struct parser *parser,
+ error_t err, int arg_ebadkey, int *end_index)
+{
+ struct group *group;
+
+ if (err == EBADKEY && arg_ebadkey)
+ /* Suppress errors generated by unparsed arguments. */
+ err = 0;
+
+ if (! err)
+ {
+ if (parser->state.next == parser->state.argc)
+ /* We successfully parsed all arguments! Call all the parsers again,
+ just a few more times... */
+ {
+ for (group = parser->groups;
+ group < parser->egroup && (!err || err==EBADKEY);
+ group++)
+ if (group->args_processed == 0)
+ err = group_parse (group, &parser->state, ARGP_KEY_NO_ARGS, 0);
+ for (group = parser->egroup - 1;
+ group >= parser->groups && (!err || err==EBADKEY);
+ group--)
+ err = group_parse (group, &parser->state, ARGP_KEY_END, 0);
+
+ if (err == EBADKEY)
+ err = 0; /* Some parser didn't understand. */
+
+ /* Tell the user that all arguments are parsed. */
+ if (end_index)
+ *end_index = parser->state.next;
+ }
+ else if (end_index)
+ /* Return any remaining arguments to the user. */
+ *end_index = parser->state.next;
+ else
+ /* No way to return the remaining arguments, they must be bogus. */
+ {
+ if (!(parser->state.flags & ARGP_NO_ERRS)
+ && parser->state.err_stream)
+ fprintf (parser->state.err_stream,
+ dgettext (parser->argp->argp_domain,
+ "%s: Too many arguments\n"),
+ parser->state.name);
+ err = EBADKEY;
+ }
+ }
+
+ /* Okay, we're all done, with either an error or success; call the parsers
+ to indicate which one. */
+
+ if (err)
+ {
+ /* Maybe print an error message. */
+ if (err == EBADKEY)
+ /* An appropriate message describing what the error was should have
+ been printed earlier. */
+ argp_state_help (&parser->state, parser->state.err_stream,
+ ARGP_HELP_STD_ERR);
+
+ /* Since we didn't exit, give each parser an error indication. */
+ for (group = parser->groups; group < parser->egroup; group++)
+ group_parse (group, &parser->state, ARGP_KEY_ERROR, 0);
+ }
+ else
+ /* Notify parsers of success, and propagate back values from parsers. */
+ {
+ /* We pass over the groups in reverse order so that child groups are
+ given a chance to do there processing before passing back a value to
+ the parent. */
+ for (group = parser->egroup - 1
+ ; group >= parser->groups && (!err || err == EBADKEY)
+ ; group--)
+ err = group_parse (group, &parser->state, ARGP_KEY_SUCCESS, 0);
+ if (err == EBADKEY)
+ err = 0; /* Some parser didn't understand. */
+ }
+
+ /* Call parsers once more, to do any final cleanup. Errors are ignored. */
+ for (group = parser->egroup - 1; group >= parser->groups; group--)
+ group_parse (group, &parser->state, ARGP_KEY_FINI, 0);
+
+ if (err == EBADKEY)
+ err = EINVAL;
+
+ free (parser->storage);
+
+ return err;
+}
+
+/* Call the user parsers to parse the non-option argument VAL, at the current
+ position, returning any error. The state NEXT pointer is assumed to have
+ been adjusted (by getopt) to point after this argument; this function will
+ adjust it correctly to reflect however many args actually end up being
+ consumed. */
+static error_t
+parser_parse_arg (struct parser *parser, char *val)
+{
+ /* Save the starting value of NEXT, first adjusting it so that the arg
+ we're parsing is again the front of the arg vector. */
+ int index = --parser->state.next;
+ error_t err = EBADKEY;
+ struct group *group;
+ int key = 0; /* Which of ARGP_KEY_ARG[S] we used. */
+
+ /* Try to parse the argument in each parser. */
+ for (group = parser->groups
+ ; group < parser->egroup && err == EBADKEY
+ ; group++)
+ {
+ parser->state.next++; /* For ARGP_KEY_ARG, consume the arg. */
+ key = ARGP_KEY_ARG;
+ err = group_parse (group, &parser->state, key, val);
+
+ if (err == EBADKEY)
+ /* This parser doesn't like ARGP_KEY_ARG; try ARGP_KEY_ARGS instead. */
+ {
+ parser->state.next--; /* For ARGP_KEY_ARGS, put back the arg. */
+ key = ARGP_KEY_ARGS;
+ err = group_parse (group, &parser->state, key, 0);
+ }
+ }
+
+ if (! err)
+ {
+ if (key == ARGP_KEY_ARGS)
+ /* The default for ARGP_KEY_ARGS is to assume that if NEXT isn't
+ changed by the user, *all* arguments should be considered
+ consumed. */
+ parser->state.next = parser->state.argc;
+
+ if (parser->state.next > index)
+ /* Remember that we successfully processed a non-option
+ argument -- but only if the user hasn't gotten tricky and set
+ the clock back. */
+ (--group)->args_processed += (parser->state.next - index);
+ else
+ /* The user wants to reparse some args, give getopt another try. */
+ parser->try_getopt = 1;
+ }
+
+ return err;
+}
+
+/* Call the user parsers to parse the option OPT, with argument VAL, at the
+ current position, returning any error. */
+static error_t
+parser_parse_opt (struct parser *parser, int opt, char *val)
+{
+ /* The group key encoded in the high bits; 0 for short opts or
+ group_number + 1 for long opts. */
+ int group_key = opt >> USER_BITS;
+ error_t err = EBADKEY;
+
+ if (group_key == 0)
+ /* A short option. By comparing OPT's position in SHORT_OPTS to the
+ various starting positions in each group's SHORT_END field, we can
+ determine which group OPT came from. */
+ {
+ struct group *group;
+ char *short_index = strchr (parser->short_opts, opt);
+
+ if (short_index)
+ for (group = parser->groups; group < parser->egroup; group++)
+ if (group->short_end > short_index)
+ {
+ err = group_parse (group, &parser->state, opt,
+ parser->opt_data.optarg);
+ break;
+ }
+ }
+ else
+ /* A long option. We use shifts instead of masking for extracting
+ the user value in order to preserve the sign. */
+ err =
+ group_parse (&parser->groups[group_key - 1], &parser->state,
+ (opt << GROUP_BITS) >> GROUP_BITS,
+ parser->opt_data.optarg);
+
+ if (err == EBADKEY)
+ /* At least currently, an option not recognized is an error in the
+ parser, because we pre-compute which parser is supposed to deal
+ with each option. */
+ {
+ static const char bad_key_err[] =
+ N_("(PROGRAM ERROR) Option should have been recognized!?");
+ if (group_key == 0)
+ argp_error (&parser->state, "-%c: %s", opt,
+ dgettext (parser->argp->argp_domain, bad_key_err));
+ else
+ {
+ struct option *long_opt = parser->long_opts;
+ while (long_opt->val != opt && long_opt->name)
+ long_opt++;
+ argp_error (&parser->state, "--%s: %s",
+ long_opt->name ? long_opt->name : "???",
+ dgettext (parser->argp->argp_domain, bad_key_err));
+ }
+ }
+
+ return err;
+}
+
+/* Parse the next argument in PARSER (as indicated by PARSER->state.next).
+ Any error from the parsers is returned, and *ARGP_EBADKEY indicates
+ whether a value of EBADKEY is due to an unrecognized argument (which is
+ generally not fatal). */
+static error_t
+parser_parse_next (struct parser *parser, int *arg_ebadkey)
+{
+ int opt;
+ error_t err = 0;
+
+ if (parser->state.quoted && parser->state.next < parser->state.quoted)
+ /* The next argument pointer has been moved to before the quoted
+ region, so pretend we never saw the quoting `--', and give getopt
+ another chance. If the user hasn't removed it, getopt will just
+ process it again. */
+ parser->state.quoted = 0;
+
+ if (parser->try_getopt && !parser->state.quoted)
+ /* Give getopt a chance to parse this. */
+ {
+ /* Put it back in OPTIND for getopt. */
+ parser->opt_data.optind = parser->state.next;
+ /* Distinguish KEY_ERR from a real option. */
+ parser->opt_data.optopt = KEY_END;
+ if (parser->state.flags & ARGP_LONG_ONLY)
+ opt = _getopt_long_only_r (parser->state.argc, parser->state.argv,
+ parser->short_opts, parser->long_opts, 0,
+ &parser->opt_data);
+ else
+ opt = _getopt_long_r (parser->state.argc, parser->state.argv,
+ parser->short_opts, parser->long_opts, 0,
+ &parser->opt_data);
+ /* And see what getopt did. */
+ parser->state.next = parser->opt_data.optind;
+
+ if (opt == KEY_END)
+ /* Getopt says there are no more options, so stop using
+ getopt; we'll continue if necessary on our own. */
+ {
+ parser->try_getopt = 0;
+ if (parser->state.next > 1
+ && strcmp (parser->state.argv[parser->state.next - 1], QUOTE)
+ == 0)
+ /* Not only is this the end of the options, but it's a
+ `quoted' region, which may have args that *look* like
+ options, so we definitely shouldn't try to use getopt past
+ here, whatever happens. */
+ parser->state.quoted = parser->state.next;
+ }
+ else if (opt == KEY_ERR && parser->opt_data.optopt != KEY_END)
+ /* KEY_ERR can have the same value as a valid user short
+ option, but in the case of a real error, getopt sets OPTOPT
+ to the offending character, which can never be KEY_END. */
+ {
+ *arg_ebadkey = 0;
+ return EBADKEY;
+ }
+ }
+ else
+ opt = KEY_END;
+
+ if (opt == KEY_END)
+ {
+ /* We're past what getopt considers the options. */
+ if (parser->state.next >= parser->state.argc
+ || (parser->state.flags & ARGP_NO_ARGS))
+ /* Indicate that we're done. */
+ {
+ *arg_ebadkey = 1;
+ return EBADKEY;
+ }
+ else
+ /* A non-option arg; simulate what getopt might have done. */
+ {
+ opt = KEY_ARG;
+ parser->opt_data.optarg = parser->state.argv[parser->state.next++];
+ }
+ }
+
+ if (opt == KEY_ARG)
+ /* A non-option argument; try each parser in turn. */
+ err = parser_parse_arg (parser, parser->opt_data.optarg);
+ else
+ err = parser_parse_opt (parser, opt, parser->opt_data.optarg);
+
+ if (err == EBADKEY)
+ *arg_ebadkey = (opt == KEY_END || opt == KEY_ARG);
+
+ return err;
+}
+
+/* Parse the options strings in ARGC & ARGV according to the argp in ARGP.
+ FLAGS is one of the ARGP_ flags above. If END_INDEX is non-NULL, the
+ index in ARGV of the first unparsed option is returned in it. If an
+ unknown option is present, EINVAL is returned; if some parser routine
+ returned a non-zero value, it is returned; otherwise 0 is returned. */
+error_t
+argp_parse (const struct argp *argp, int argc, char **argv, unsigned flags,
+ int *end_index, void *input)
+{
+ error_t err;
+ struct parser parser;
+
+ /* If true, then err == EBADKEY is a result of a non-option argument failing
+ to be parsed (which in some cases isn't actually an error). */
+ int arg_ebadkey = 0;
+
+ if (! (flags & ARGP_NO_HELP))
+ /* Add our own options. */
+ {
+ struct argp_child *child = alloca (4 * sizeof (struct argp_child));
+ struct argp *top_argp = alloca (sizeof (struct argp));
+
+ /* TOP_ARGP has no options, it just serves to group the user & default
+ argps. */
+ memset (top_argp, 0, sizeof (*top_argp));
+ top_argp->children = child;
+
+ memset (child, 0, 4 * sizeof (struct argp_child));
+
+ if (argp)
+ (child++)->argp = argp;
+ (child++)->argp = &argp_default_argp;
+ if (argp_program_version || argp_program_version_hook)
+ (child++)->argp = &argp_version_argp;
+ child->argp = 0;
+
+ argp = top_argp;
+ }
+
+ /* Construct a parser for these arguments. */
+ err = parser_init (&parser, argp, argc, argv, flags, input);
+
+ if (! err)
+ /* Parse! */
+ {
+ while (! err)
+ err = parser_parse_next (&parser, &arg_ebadkey);
+ err = parser_finalize (&parser, err, arg_ebadkey, end_index);
+ }
+
+ return err;
+}
+
+/* Return the input field for ARGP in the parser corresponding to STATE; used
+ by the help routines. */
+void *
+__argp_input (const struct argp *argp, const struct argp_state *state)
+{
+ if (state)
+ {
+ struct group *group;
+ struct parser *parser = state->pstate;
+
+ for (group = parser->groups; group < parser->egroup; group++)
+ if (group->argp == argp)
+ return group->input;
+ }
+
+ return 0;
+}
diff --git a/libuargp/argp-pv.c b/libuargp/argp-pv.c
new file mode 100644
index 000000000..f1227b577
--- /dev/null
+++ b/libuargp/argp-pv.c
@@ -0,0 +1,25 @@
+/* Default definition for ARGP_PROGRAM_VERSION.
+ Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Miles Bader <miles at gnu.ai.mit.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. */
+
+/* If set by the user program to a non-zero value, then a default option
+ --version is added (unless the ARGP_NO_HELP flag is used), which will
+ print this this string followed by a newline and exit (unless the
+ ARGP_NO_EXIT flag is used). Overridden by ARGP_PROGRAM_VERSION_HOOK. */
+const char *argp_program_version;
diff --git a/libuargp/argp-pvh.c b/libuargp/argp-pvh.c
new file mode 100644
index 000000000..1f1d962b8
--- /dev/null
+++ b/libuargp/argp-pvh.c
@@ -0,0 +1,32 @@
+/* Default definition for ARGP_PROGRAM_VERSION_HOOK.
+ Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Miles Bader <miles at gnu.ai.mit.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. */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <argp.h>
+
+/* If set by the user program to a non-zero value, then a default option
+ --version is added (unless the ARGP_NO_HELP flag is used), which calls
+ this function with a stream to print the version to and a pointer to the
+ current parsing state, and then exits (unless the ARGP_NO_EXIT flag is
+ used). This variable takes precedent over ARGP_PROGRAM_VERSION. */
+void (*argp_program_version_hook) (FILE *stream, struct argp_state *state);
diff --git a/libuargp/argp-xinl.c b/libuargp/argp-xinl.c
new file mode 100644
index 000000000..f1d30002a
--- /dev/null
+++ b/libuargp/argp-xinl.c
@@ -0,0 +1,35 @@
+/* Real definitions for extern inline functions in argp.h
+ Copyright (C) 1997, 1998, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Miles Bader <miles at gnu.ai.mit.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. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if defined _LIBC || defined HAVE_FEATURES_H
+# include <features.h>
+#endif
+
+#ifndef __USE_EXTERN_INLINES
+# define __USE_EXTERN_INLINES 1
+#endif
+#define ARGP_EI
+#undef __OPTIMIZE__
+#define __OPTIMIZE__ 1
+#include <argp.h>
diff --git a/libubacktrace/Makefile b/libubacktrace/Makefile
new file mode 100644
index 000000000..0f746383c
--- /dev/null
+++ b/libubacktrace/Makefile
@@ -0,0 +1,14 @@
+# Makefile for uClibc (libubacktrace)
+#
+# Copyright (C) 2010 STMicroelectronics Ltd
+# Author(s): Carmelo Amoroso <carmelo.amoroso@st.com>
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+top_srcdir=../
+top_builddir=../
+include $(top_builddir)Rules.mak
+all: libs
+include Makefile.in
+include $(top_srcdir)Makerules
diff --git a/libubacktrace/Makefile.in b/libubacktrace/Makefile.in
new file mode 100644
index 000000000..311f1e31c
--- /dev/null
+++ b/libubacktrace/Makefile.in
@@ -0,0 +1,84 @@
+# Makefile for uClibc (libubacktrace)
+#
+# Copyright (C) 2010 STMicroelectronics Ltd
+# Author: Carmelo Amoroso <carmelo.amoroso@st.com>
+
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+subdirs += libubacktrace libubacktrace/$(TARGET_ARCH)
+
+CFLAGS-libubacktrace := -DNOT_IN_libc -DIS_IN_libubacktrace $(SSP_ALL_CFLAGS)
+
+LDFLAGS-libubacktrace.so := $(LDFLAGS) $(top_builddir)lib/libdl-$(VERSION).so
+
+LIBS-libubacktrace.so := $(LIBS)
+
+libubacktrace_FULL_NAME := libubacktrace-$(VERSION).so
+
+libubacktrace_DIR := $(top_srcdir)libubacktrace
+libubacktrace_OUT := $(top_builddir)libubacktrace
+
+libubacktrace_ARCH_DIR:=$(libubacktrace_DIR)/$(TARGET_ARCH)
+libubacktrace_ARCH_OUT:=$(libubacktrace_OUT)/$(TARGET_ARCH)
+
+-include $(libubacktrace_ARCH_DIR)/Makefile.arch
+
+libubacktrace_SRC-y :=
+libubacktrace_SRC-$(UCLIBC_HAS_BACKTRACE) := backtracesyms.c backtracesymsfd.c
+libubacktrace_SRC_SHARED-$(UCLIBC_HAS_BACKTRACE) := backtrace.c
+
+# remove generic sources, if arch specific version is present
+ifneq ($(strip $(libubacktrace_ARCH_SRC-y)),)
+libubacktrace_SRC-y := $(filter-out $(notdir $(libubacktrace_ARCH_SRC-y)),$(libubacktrace_SRC-y))
+libubacktrace_SRC_SHARED-y := $(filter-out $(notdir $(libubacktrace_ARCH_SRC-y)),$(libubacktrace_SRC_SHARED-y))
+endif
+
+# -fasynchronous-unwind-tables is required for backtrace to work using dwarf2
+CFLAGS-backtrace.c := -fasynchronous-unwind-tables
+
+libubacktrace_SRCS := $(patsubst %.c,$(libubacktrace_DIR)/%.c,$(libubacktrace_SRC-y))
+libubacktrace_OBJS := $(patsubst $(libubacktrace_DIR)/%.c,$(libubacktrace_OUT)/%.o,$(libubacktrace_SRCS))
+
+libubacktrace_SHARED_SRCS := $(patsubst %.c,$(libubacktrace_DIR)/%.c,$(libubacktrace_SRC_SHARED-y))
+libubacktrace_SHARED_OBJS := $(patsubst $(libubacktrace_DIR)/%.c,$(libubacktrace_OUT)/%.o,$(libubacktrace_SHARED_SRCS))
+
+libubacktrace-shared-y := $(libubacktrace_SHARED_OBJS:.o=.oS)
+libubacktrace-static-y := $(libubacktrace_SHARED_OBJS)
+
+ifeq ($(DOPIC),y)
+libubacktrace-a-y += $(libubacktrace_OBJS:.o=.os) $(libubacktrace-static-y:.o=.os)
+else
+libubacktrace-a-y += $(libubacktrace_OBJS) $(libubacktrace-static-y)
+endif
+libubacktrace-so-y += $(libubacktrace_OBJS:.o=.os) $(libubacktrace-shared-y)
+
+
+lib-a-$(UCLIBC_HAS_BACKTRACE) += $(top_builddir)lib/libubacktrace.a
+lib-so-$(UCLIBC_HAS_BACKTRACE) += $(top_builddir)lib/libubacktrace.so
+
+objclean-y += CLEAN_libubacktrace
+
+ifeq ($(DOMULTI),n)
+$(top_builddir)lib/libubacktrace.so: $(libubacktrace_OUT)/libubacktrace_so.a $(libdl.depend)
+ $(call link.so,$(libubacktrace_FULL_NAME),$(ABI_VERSION))
+else
+$(top_builddir)lib/libubacktrace.so: $(libubacktrace_OUT)/libubacktrace.oS | $(libdl.depend)
+ $(call linkm.so,$(libubacktrace_FULL_NAME),$(ABI_VERSION))
+endif
+
+$(libubacktrace_OUT)/libubacktrace_so.a: $(libubacktrace-so-y)
+ $(Q)$(RM) $@
+ $(do_ar)
+
+$(libubacktrace_OUT)/libubacktrace.oS: $(libubacktrace_SRCS) $(libubacktrace_ARCH_SRCS) $(libubacktrace_SHARED_SRCS)
+ $(Q)$(RM) $@
+ $(compile-m)
+
+$(top_builddir)lib/libubacktrace.a: $(libubacktrace-a-y)
+ $(Q)$(INSTALL) -d $(dir $@)
+ $(Q)$(RM) $@
+ $(do_ar)
+
+CLEAN_libubacktrace:
+ $(do_rm) $(addprefix $(libubacktrace_OUT)/*., o os oS a)
diff --git a/libubacktrace/arm/Makefile.arch b/libubacktrace/arm/Makefile.arch
new file mode 100644
index 000000000..b3fb500e2
--- /dev/null
+++ b/libubacktrace/arm/Makefile.arch
@@ -0,0 +1,17 @@
+# Makefile for uClibc (libubacktrace)
+#
+# Author: Khem Raj <raj.khem@gmail.com>
+
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+libubacktrace_ARCH_SRC-$(UCLIBC_HAS_BACKTRACE) := backtrace.c
+libubacktrace_ARCH_SRCS := $(addprefix $(libubacktrace_ARCH_DIR)/,$(libubacktrace_ARCH_SRC-y))
+libubacktrace_ARCH_OBJS := $(patsubst $(libubacktrace_ARCH_DIR)/%.c,$(libubacktrace_ARCH_OUT)/%.o,$(libubacktrace_ARCH_SRCS))
+
+ifeq ($(DOPIC),y)
+libubacktrace-a-y+=$(libubacktrace_ARCH_OBJS:.o=.os)
+else
+libubacktrace-a-y+=$(libubacktrace_ARCH_OBJS)
+endif
+libubacktrace-so-y+=$(libubacktrace_ARCH_OBJS:.o=.oS)
diff --git a/libubacktrace/arm/backtrace.c b/libubacktrace/arm/backtrace.c
new file mode 100644
index 000000000..55689a741
--- /dev/null
+++ b/libubacktrace/arm/backtrace.c
@@ -0,0 +1,98 @@
+/*
+ * Perform stack unwinding by using the _Unwind_Backtrace.
+ *
+ * User application that wants to use backtrace needs to be
+ * compiled with -fasynchronous-unwid-tables option and -rdynamic i
+ * to get full symbols printed.
+ *
+ * Author(s): Khem Raj <raj.khem@gmail.com>
+ * - ARM specific implementation of backtrace
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ *
+ */
+
+#include <libgcc_s.h>
+#include <execinfo.h>
+#include <dlfcn.h>
+#include <stdlib.h>
+#include <unwind.h>
+#include <assert.h>
+#include <stdio.h>
+
+struct trace_arg
+{
+ void **array;
+ int cnt, size;
+};
+
+#ifdef SHARED
+static _Unwind_Reason_Code (*unwind_backtrace) (_Unwind_Trace_Fn, void *);
+static _Unwind_VRS_Result (*unwind_vrs_get) (_Unwind_Context *,
+ _Unwind_VRS_RegClass,
+ _uw,
+ _Unwind_VRS_DataRepresentation,
+ void *);
+
+static void backtrace_init (void)
+{
+ void *handle = dlopen (LIBGCC_S_SO, RTLD_LAZY);
+ if (handle == NULL
+ || ((unwind_backtrace = dlsym (handle, "_Unwind_Backtrace")) == NULL)
+ || ((unwind_vrs_get = dlsym (handle, "_Unwind_VRS_Get")) == NULL)) {
+ printf(LIBGCC_S_SO " must be installed for backtrace to work\n");
+ abort();
+ }
+}
+#else
+# define unwind_backtrace _Unwind_Backtrace
+# define unwind_vrs_get _Unwind_VRS_Get
+#endif
+/* This function is identical to "_Unwind_GetGR", except that it uses
+ "unwind_vrs_get" instead of "_Unwind_VRS_Get". */
+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;
+}
+
+/* This macro is identical to the _Unwind_GetIP macro, except that it
+ uses "unwind_getgr" instead of "_Unwind_GetGR". */
+#define unwind_getip(context) \
+ (unwind_getgr (context, 15) & ~(_Unwind_Word)1)
+
+static _Unwind_Reason_Code
+backtrace_helper (struct _Unwind_Context *ctx, void *a)
+{
+ struct trace_arg *arg = a;
+
+ assert (unwind_getip(ctx) != NULL);
+
+ /* We are first called with address in the __backtrace function. Skip it. */
+ if (arg->cnt != -1)
+ arg->array[arg->cnt] = (void *) unwind_getip (ctx);
+ if (++arg->cnt == arg->size)
+ return _URC_END_OF_STACK;
+ return _URC_NO_REASON;
+}
+
+/*
+ * Perform stack unwinding by using the _Unwind_Backtrace.
+ *
+ */
+int backtrace (void **array, int size)
+{
+ struct trace_arg arg = { .array = array, .size = size, .cnt = -1 };
+
+#ifdef SHARED
+ if (unwind_backtrace == NULL)
+ backtrace_init();
+#endif
+
+ if (size >= 1)
+ unwind_backtrace (backtrace_helper, &arg);
+
+ return arg.cnt != -1 ? arg.cnt : 0;
+}
diff --git a/libubacktrace/backtrace.c b/libubacktrace/backtrace.c
new file mode 100644
index 000000000..08a7010e7
--- /dev/null
+++ b/libubacktrace/backtrace.c
@@ -0,0 +1,89 @@
+/*
+ * Perform stack unwinding by using the _Unwind_Backtrace.
+ *
+ * User application that wants to use backtrace needs to be
+ * compiled with -fasynchronous-unwind-tables option and -rdynamic to get full
+ * symbols printed.
+ *
+ * Copyright (C) 2009, 2010 STMicroelectronics Ltd.
+ *
+ * Author(s): Giuseppe Cavallaro <peppe.cavallaro@st.com>
+ * - Initial implementation for glibc
+ *
+ * Author(s): Carmelo Amoroso <carmelo.amoroso@st.com>
+ * - Reworked for uClibc
+ * - use dlsym/dlopen from libdl
+ * - rewrite initialisation to not use libc_once
+ * - make it available in static link too
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ *
+ */
+
+#include <libgcc_s.h>
+#include <execinfo.h>
+#include <dlfcn.h>
+#include <stdlib.h>
+#include <unwind.h>
+#include <assert.h>
+#include <stdio.h>
+
+struct trace_arg
+{
+ void **array;
+ int cnt, size;
+};
+
+#ifdef SHARED
+static _Unwind_Reason_Code (*unwind_backtrace) (_Unwind_Trace_Fn, void *);
+static _Unwind_Ptr (*unwind_getip) (struct _Unwind_Context *);
+
+static void backtrace_init (void)
+{
+ void *handle = dlopen (LIBGCC_S_SO, RTLD_LAZY);
+
+ if (handle == NULL
+ || ((unwind_backtrace = dlsym (handle, "_Unwind_Backtrace")) == NULL)
+ || ((unwind_getip = dlsym (handle, "_Unwind_GetIP")) == NULL)) {
+ printf(LIBGCC_S_SO " must be installed for backtrace to work\n");
+ abort();
+ }
+}
+#else
+# define unwind_backtrace _Unwind_Backtrace
+# define unwind_getip _Unwind_GetIP
+#endif
+
+static _Unwind_Reason_Code
+backtrace_helper (struct _Unwind_Context *ctx, void *a)
+{
+ struct trace_arg *arg = a;
+
+ assert (unwind_getip != NULL);
+
+ /* We are first called with address in the __backtrace function. Skip it. */
+ if (arg->cnt != -1)
+ arg->array[arg->cnt] = (void *) unwind_getip (ctx);
+ if (++arg->cnt == arg->size)
+ return _URC_END_OF_STACK;
+ return _URC_NO_REASON;
+}
+
+/*
+ * Perform stack unwinding by using the _Unwind_Backtrace.
+ *
+ */
+int backtrace (void **array, int size)
+{
+ struct trace_arg arg = { .array = array, .size = size, .cnt = -1 };
+
+#ifdef SHARED
+ if (unwind_backtrace == NULL)
+ backtrace_init();
+#endif
+
+ if (size >= 1)
+ unwind_backtrace (backtrace_helper, &arg);
+
+ return arg.cnt != -1 ? arg.cnt : 0;
+}
diff --git a/libubacktrace/backtracesyms.c b/libubacktrace/backtracesyms.c
new file mode 100644
index 000000000..10384dcd2
--- /dev/null
+++ b/libubacktrace/backtracesyms.c
@@ -0,0 +1,104 @@
+/* Return list with names for address in backtrace.
+ Copyright (C) 1998,1999,2000,2001,2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 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; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>.
+
+ Based on glibc/sysdeps/generic/elf/backtracesyms.c
+
+ Copyright (C) 2010 STMicroelectronics Ltd
+ Author(s): Carmelo Amoroso <carmelo.amoroso@st.com>
+ * Modified to work with uClibc
+ - updated headers inclusion
+ - updated formatting and style
+ - updated to use dladdr from libdl */
+
+#include <execinfo.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <dlfcn.h>
+#include <link.h> /* required for __ELF_NATIVE_CLASS */
+
+#if __ELF_NATIVE_CLASS == 32
+# define WORD_WIDTH 8
+#else
+/* We assyme 64bits. */
+# define WORD_WIDTH 16
+#endif
+
+
+char ** backtrace_symbols (void *const *array, int size)
+{
+ Dl_info info[size];
+ int status[size];
+ int cnt;
+ size_t total = 0;
+ char **result;
+
+ /* Fill in the information we can get from `dladdr'. */
+ for (cnt = 0; cnt < size; ++cnt) {
+ status[cnt] = dladdr (array[cnt], &info[cnt]);
+ if (status[cnt] && info[cnt].dli_fname &&
+ info[cnt].dli_fname[0] != '\0')
+ /*
+ * We have some info, compute the length of the string which will be
+ * "<file-name>(<sym-name>) [+offset].
+ */
+ total += (strlen (info[cnt].dli_fname ?: "") +
+ (info[cnt].dli_sname ?
+ strlen (info[cnt].dli_sname) + 3 + WORD_WIDTH + 3 : 1)
+ + WORD_WIDTH + 5);
+ else
+ total += 5 + WORD_WIDTH;
+ }
+
+ /* Allocate memory for the result. */
+ result = (char **) malloc (size * sizeof (char *) + total);
+ if (result != NULL) {
+ char *last = (char *) (result + size);
+ for (cnt = 0; cnt < size; ++cnt) {
+ result[cnt] = last;
+
+ if (status[cnt] && info[cnt].dli_fname
+ && info[cnt].dli_fname[0] != '\0') {
+
+ char buf[20];
+
+ if (array[cnt] >= (void *) info[cnt].dli_saddr)
+ sprintf (buf, "+%#lx",
+ (unsigned long)(array[cnt] - info[cnt].dli_saddr));
+ else
+ sprintf (buf, "-%#lx",
+ (unsigned long)(info[cnt].dli_saddr - array[cnt]));
+
+ last += 1 + sprintf (last, "%s%s%s%s%s[%p]",
+ info[cnt].dli_fname ?: "",
+ info[cnt].dli_sname ? "(" : "",
+ info[cnt].dli_sname ?: "",
+ info[cnt].dli_sname ? buf : "",
+ info[cnt].dli_sname ? ") " : " ",
+ array[cnt]);
+ } else
+ last += 1 + sprintf (last, "[%p]", array[cnt]);
+ }
+ assert (last <= (char *) result + size * sizeof (char *) + total);
+ }
+
+ return result;
+}
diff --git a/libubacktrace/backtracesymsfd.c b/libubacktrace/backtracesymsfd.c
new file mode 100644
index 000000000..498caa5c5
--- /dev/null
+++ b/libubacktrace/backtracesymsfd.c
@@ -0,0 +1,115 @@
+/* Write formatted list with names for addresses in backtrace to a file.
+ Copyright (C) 1998, 2000, 2003, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 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; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>.
+
+ Based on glibc/sysdeps/generic/elf/backtracesymsfd.c
+
+ Copyright (C) 2010 STMicroelectronics Ltd
+ Author(s): Carmelo Amoroso <carmelo.amoroso@st.com>
+ * Modified to work with uClibc
+ - updated headers inclusion
+ - updated formatting and style
+ - updated to use dladdr from libdl
+ - updated to use snprintf instead of _itoa_word */
+
+#include <execinfo.h>
+#include <string.h>
+#include <sys/uio.h>
+#include <dlfcn.h>
+#include <stdio.h>
+#include <link.h> /* required for __ELF_NATIVE_CLASS */
+
+#if __ELF_NATIVE_CLASS == 32
+# define WORD_WIDTH 8
+#else
+/* We assyme 64bits. */
+# define WORD_WIDTH 16
+#endif
+
+#define BUF_SIZE (WORD_WIDTH + 1)
+
+void backtrace_symbols_fd (void *const *array, int size, int fd)
+{
+ struct iovec iov[9];
+ int cnt;
+
+ for (cnt = 0; cnt < size; ++cnt) {
+ char buf[BUF_SIZE];
+ Dl_info info;
+ size_t last = 0;
+ size_t len = 0;
+
+ memset(buf, 0, sizeof(buf));
+ if (dladdr (array[cnt], &info)
+ && info.dli_fname && info.dli_fname[0] != '\0') {
+ /* Name of the file. */
+ iov[0].iov_base = (void *) info.dli_fname;
+ iov[0].iov_len = strlen (info.dli_fname);
+ last = 1;
+
+ /* Symbol name. */
+ if (info.dli_sname != NULL) {
+ char buf2[BUF_SIZE];
+ memset(buf2, 0, sizeof(buf2));
+ size_t diff;
+
+ iov[1].iov_base = (void *) "(";
+ iov[1].iov_len = 1;
+ iov[2].iov_base = (void *) info.dli_sname;
+ iov[2].iov_len = strlen (info.dli_sname);
+
+ if (array[cnt] >= (void *) info.dli_saddr) {
+ iov[3].iov_base = (void *) "+0x";
+ diff = array[cnt] - info.dli_saddr;
+ } else {
+ iov[3].iov_base = (void *) "-0x";
+ diff = info.dli_saddr - array[cnt];
+ }
+
+ iov[3].iov_len = 3;
+
+ /* convert diff to a string in hex format */
+ len = snprintf(buf2, sizeof(buf2), "%lx", (unsigned long) diff);
+ iov[4].iov_base = buf2;
+ iov[4].iov_len = len;
+
+ iov[5].iov_base = (void *) ")";
+ iov[5].iov_len = 1;
+
+ last = 6;
+ }
+ }
+
+ iov[last].iov_base = (void *) "[0x";
+ iov[last].iov_len = 3;
+ ++last;
+
+ /* convert array[cnt] to a string in hex format */
+ len = snprintf(buf, sizeof(buf), "%lx", (unsigned long) array[cnt]);
+ iov[last].iov_base = buf;
+ iov[last].iov_len = len;
+
+ ++last;
+
+ iov[last].iov_base = (void *) "]\n";
+ iov[last].iov_len = 2;
+ ++last;
+
+ writev (fd, iov, last);
+ }
+}
diff --git a/libutil/Makefile.in b/libutil/Makefile.in
index ef3169906..98b178ef9 100644
--- a/libutil/Makefile.in
+++ b/libutil/Makefile.in
@@ -1,12 +1,15 @@
# 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.
#
+subdirs += libutil
+
CFLAGS-libutil := -DNOT_IN_libc -DIS_IN_libutil $(SSP_ALL_CFLAGS)
+LDFLAGS-$(UCLIBC_FORMAT_DSBT_ELF)-libutil.so := -Wl,--dsbt-index=8
LDFLAGS-libutil.so := $(LDFLAGS)
LIBS-libutil.so := $(LIBS)
@@ -24,6 +27,14 @@ ifneq ($(UCLIBC_HAS_PTY),y)
libutil_SRC := $(filter-out $(libutil_DIR)/openpty.c $(libutil_DIR)/forkpty.c \
,$(libutil_SRC))
endif
+ifeq ($(UCLIBC_HAS_UTMP)$(UCLIBC_HAS_UTMPX),)
+libutil_SRC := $(filter-out \
+ $(libutil_DIR)/logwtmp.c \
+ $(libutil_DIR)/login.c \
+ $(libutil_DIR)/logout.c \
+ ,$(libutil_SRC))
+endif
+
libutil_OBJ := $(patsubst $(libutil_DIR)/%.c,$(libutil_OUT)/%.o,$(libutil_SRC))
ifeq ($(DOPIC),y)
@@ -33,9 +44,9 @@ libutil-a-y := $(libutil_OBJ)
endif
libutil-so-y := $(libutil_OBJ:.o=.os)
-lib-a-y += $(top_builddir)lib/libutil.a
-lib-so-y += $(top_builddir)lib/libutil.so
-objclean-y += libutil_clean
+lib-a-$(UCLIBC_HAS_LIBUTIL) += $(top_builddir)lib/libutil.a
+lib-so-$(UCLIBC_HAS_LIBUTIL) += $(top_builddir)lib/libutil.so
+objclean-y += CLEAN_libutil
ifeq ($(DOMULTI),n)
ifeq ($(DOPIC),y)
@@ -43,10 +54,10 @@ $(top_builddir)lib/libutil.so: $(top_builddir)lib/libutil.a $(libc.depend)
else
$(top_builddir)lib/libutil.so: $(libutil_OUT)/libutil_so.a $(libc.depend)
endif
- $(call link.so,$(libutil_FULL_NAME),$(MAJOR_VERSION))
+ $(call link.so,$(libutil_FULL_NAME),$(ABI_VERSION))
else
$(top_builddir)lib/libutil.so: $(libutil_OUT)/libutil.oS | $(libc.depend)
- $(call linkm.so,$(libutil_FULL_NAME),$(MAJOR_VERSION))
+ $(call linkm.so,$(libutil_FULL_NAME),$(ABI_VERSION))
endif
$(libutil_OUT)/libutil_so.a: $(libutil-so-y)
@@ -62,5 +73,5 @@ $(top_builddir)lib/libutil.a: $(libutil-a-y)
$(Q)$(RM) $@
$(do_ar)
-libutil_clean:
- $(RM) $(libutil_OUT)/*.{o,os,oS,a}
+CLEAN_libutil:
+ $(do_rm) $(addprefix $(libutil_OUT)/*., o os oS a)
diff --git a/libutil/forkpty.c b/libutil/forkpty.c
index 61e85929a..24643330c 100644
--- a/libutil/forkpty.c
+++ b/libutil/forkpty.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 <sys/types.h>
#include <termios.h>
@@ -23,9 +22,6 @@
#include <utmp.h>
#include <pty.h>
-libutil_hidden_proto(openpty)
-libutil_hidden_proto(login_tty)
-
int
forkpty (int *amaster, char *name, struct termios *termp, struct winsize *winp)
{
diff --git a/libutil/login.c b/libutil/login.c
index bd1dd29ee..971997d4a 100644
--- a/libutil/login.c
+++ b/libutil/login.c
@@ -3,23 +3,58 @@
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
-#include <utmp.h>
+#include "internal/utmp.h"
-/* Write the given entry into utmp and wtmp. */
-void login (const struct utmp *entry)
+/* Write the given entry into utmp and wtmp.
+ * Note: the match in utmp is done against ut_id field,
+ * which is NOT set by this function - caller must set it.
+ */
+void login(const struct utmp *entry)
{
- struct utmp copy = *entry;
+ struct UT copy;
+ char tty_name[sizeof(copy.ut_line) + 6];
+ int fd;
- utmpname(_PATH_UTMP);
- setutent();
+// Manpage:
+// login() takes the argument ut struct, fills the field ut->ut_type
+// (if there is such a field) with the value USER_PROCESS,
+// and fills the field ut->ut_pid (if there is such a field)
+// with the process ID of the calling process.
+ copy = *((const struct UT *)(entry));
#if _HAVE_UT_TYPE - 0
- copy.ut_type = USER_PROCESS;
+ copy.ut_type = USER_PROCESS;
#endif
#if _HAVE_UT_PID - 0
- copy.ut_pid = getpid();
+ copy.ut_pid = getpid();
#endif
- strncpy (copy.ut_line, entry->ut_line, UT_LINESIZE);
- pututline(entry);
- endutent();
-}
+// Then it tries to fill the field ut->ut_line. It takes the first of stdin,
+// stdout, stderr that is a tty, and stores the corresponding pathname minus
+// a possible leading /dev/ into this field, and then writes the struct
+// to the utmp file. On the other hand, if no tty name was found,
+// this field is filled with "???" and the struct is not written
+// to the utmp file.
+ fd = 0;
+ while (fd != 3 && ttyname_r(fd, tty_name, sizeof(tty_name)) != 0)
+ fd++;
+ if (fd != 3) {
+ if (strncmp(tty_name, "/dev/", 5) == 0)
+ strncpy(copy.ut_line, tty_name + 5, sizeof(copy.ut_line)-1);
+ else
+ strncpy(copy.ut_line, tty_name, sizeof(copy.ut_line)-1);
+ copy.ut_line[sizeof(copy.ut_line)-1] = '\0';
+
+ /* utmpname(_PATH_UTMP); - why?
+ * this makes it impossible for caller to use other file!
+ * Does any standard or historical precedent says this must be done? */
+ setutent();
+ /* Replaces record with matching ut_id, or appends new one: */
+ pututline(&copy);
+ endutent();
+ } else {
+ strncpy(copy.ut_line, "???", sizeof(copy.ut_line));
+ }
+
+// After this, the struct is written to the wtmp file.
+ updwtmp(_PATH_WTMP, &copy);
+}
diff --git a/libutil/login_tty.c b/libutil/login_tty.c
index 3979adcec..366585834 100644
--- a/libutil/login_tty.c
+++ b/libutil/login_tty.c
@@ -36,7 +36,6 @@
#include <fcntl.h>
#include <utmp.h>
-libutil_hidden_proto(login_tty)
int login_tty(int fd)
{
(void) setsid();
diff --git a/libutil/logout.c b/libutil/logout.c
index e6d9565ab..0181e23aa 100644
--- a/libutil/logout.c
+++ b/libutil/logout.c
@@ -13,25 +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/>. */
#include <errno.h>
#include <string.h>
-#include <utmp.h>
#include <sys/time.h>
+#include "internal/utmp.h"
int
logout (const char *line)
{
- struct utmp tmp;
- struct utmp *ut;
+ struct UT tmp;
+ struct UT *ut;
int result = 0;
- /* Tell that we want to use the UTMP file. */
- if (utmpname (_PATH_UTMP) == -1)
- return 0;
+ /* if (utmpname (_PATH_UTMP) == -1) return 0; - why?
+ * this makes it impossible for caller to use other file!
+ * Does any standard or historical precedent says this must be done? */
/* Open UTMP file. */
setutent ();
@@ -43,7 +42,7 @@ logout (const char *line)
strncpy (tmp.ut_line, line, sizeof tmp.ut_line);
/* Read the record. */
- if( (ut = getutline(&tmp)) )
+ if ((ut = getutline(&tmp)) != NULL)
{
/* Clear information about who & from where. */
memset (ut->ut_name, 0, sizeof ut->ut_name);
@@ -51,15 +50,15 @@ logout (const char *line)
memset (ut->ut_host, 0, sizeof ut->ut_host);
#endif
#if _HAVE_UT_TV - 0
-# if !defined __WORDSIZE_COMPAT32 || __WORDSIZE_COMPAT32 == 0
+# if !defined __WORDSIZE_TIME64_COMPAT32
gettimeofday (&ut->ut_tv, NULL);
# else
- {
- struct timeval tv;
- gettimeofday (&tv, NULL);
- ut->ut_tv.tv_sec = tv.tv_sec;
- ut->ut_tv.tv_usec = tv.tv_usec;
- }
+ {
+ struct timeval tv;
+ gettimeofday (&tv, NULL);
+ ut->ut_tv.tv_sec = tv.tv_sec;
+ ut->ut_tv.tv_usec = tv.tv_usec;
+ }
# endif
#else
time (&ut->ut_time);
diff --git a/libutil/logwtmp.c b/libutil/logwtmp.c
index 0845b5038..99b772fc4 100644
--- a/libutil/logwtmp.c
+++ b/libutil/logwtmp.c
@@ -9,48 +9,30 @@
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
-#include <utmp.h>
#include <fcntl.h>
#include <sys/file.h>
+#include "internal/utmp.h"
-
-void logwtmp (const char *line, const char *name, const char *host)
+void logwtmp(const char *line, const char *name, const char *host)
{
- struct utmp lutmp;
- memset (&(lutmp), 0, sizeof (struct utmp));
+ struct UT lutmp;
+ memset(&lutmp, 0, sizeof(lutmp));
- lutmp.ut_type = (name && *name)? USER_PROCESS : DEAD_PROCESS;
+ lutmp.ut_type = (name && *name) ? USER_PROCESS : DEAD_PROCESS;
lutmp.ut_pid = getpid();
strncpy(lutmp.ut_line, line, sizeof(lutmp.ut_line)-1);
strncpy(lutmp.ut_name, name, sizeof(lutmp.ut_name)-1);
strncpy(lutmp.ut_host, host, sizeof(lutmp.ut_host)-1);
-#if !defined __WORDSIZE_COMPAT32 || __WORDSIZE_COMPAT32 == 0
- gettimeofday(&(lutmp.ut_tv), NULL);
+#if !defined __WORDSIZE_TIME64_COMPAT32
+ gettimeofday(&lutmp.ut_tv, NULL);
#else
{
struct timeval tv;
- gettimeofday (&tv, NULL);
+ gettimeofday(&tv, NULL);
lutmp.ut_tv.tv_sec = tv.tv_sec;
lutmp.ut_tv.tv_usec = tv.tv_usec;
}
#endif
- updwtmp(_PATH_WTMP, &(lutmp));
+ updwtmp(_PATH_WTMP, &lutmp);
}
-
-#if 0
-/* This is enabled in uClibc/libc/misc/utmp/wtent.c */
-extern void updwtmp(const char *wtmp_file, const struct utmp *lutmp)
-{
- int fd;
-
- fd = open(wtmp_file, O_APPEND | O_WRONLY, 0);
- if (fd >= 0) {
- if (lockf(fd, F_LOCK, 0)==0) {
- write(fd, (const char *) lutmp, sizeof(struct utmp));
- lockf(fd, F_ULOCK, 0);
- close(fd);
- }
- }
-}
-#endif
diff --git a/libutil/openpty.c b/libutil/openpty.c
index 5f58476e9..848dc8d38 100644
--- a/libutil/openpty.c
+++ b/libutil/openpty.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 <fcntl.h>
@@ -85,7 +84,6 @@ pts_name (int fd, char **pts, size_t buf_len)
/* Create pseudo tty master slave pair and set terminal attributes
according to TERMP and WINP. Return handles for both ends in
AMASTER and ASLAVE, and return the name of the slave end in NAME. */
-libutil_hidden_proto(openpty)
int
openpty (int *amaster, int *aslave, char *name, struct termios *termp,
struct winsize *winp)
diff --git a/test/.gitignore b/test/.gitignore
new file mode 100644
index 000000000..0d19285e9
--- /dev/null
+++ b/test/.gitignore
@@ -0,0 +1,334 @@
+#
+# Never ignore these
+#
+!.gitignore
+#
+# Generated files
+#
+*.out
+#
+# Executable test
+#
+*_glibc
+argp/argp-ex[1-4]
+argp/argp-test
+argp/bug-argp1
+argp/tst-argp[12]
+args/arg_test
+assert/assert
+crypt/crypt
+crypt/md5c-test
+crypt/sha256c-test
+crypt/sha512c-test
+ctype/ctype
+dlopen/dladdr
+dlopen/dlafk
+dlopen/dlstatic
+dlopen/dltest
+dlopen/dltest2
+dlopen/dlundef
+dlopen/libafk.so
+dlopen/libafk-temp.so
+dlopen/libA.so
+dlopen/libB.so
+dlopen/libC.so
+dlopen/libstatic.so
+dlopen/libtest[123].so
+dlopen/libtest.so
+dlopen/libundef.so
+dlopen/test[1-3]
+dlopen/testscope
+inet/bug-if1
+inet/gethost_r-align
+inet/gethostid
+inet/getnetent
+inet/if_nameindex
+inet/tst-aton
+inet/tst-ether_aton
+inet/tst-ethers
+inet/tst-ethers-line
+inet/tst-network
+inet/tst-ntoa
+inet/tst-res
+inet/tst-sock-nonblock
+librt/shmtest
+locale/bug-iconv-trans
+locale/bug-usesetlocale
+locale/C
+locale/collate-test
+locale/dump-ctype
+locale/gen-unicode-ctype
+locale/show-ucs-data
+locale/tst-digits
+locale/tst-langinfo
+locale/tst-mbswcs[1-6]
+locale/tst_nl_langinfo
+locale/tst-numeric
+locale/tst-setlocale
+locale/tst-sscanf
+locale/tst-trans
+locale/tst-wctype
+locale/tst-xlocale1
+locale/tst-xlocale2
+locale/xfrm-test
+locale-mbwc/tst_iswalnum
+locale-mbwc/tst_iswalpha
+locale-mbwc/tst_iswcntrl
+locale-mbwc/tst_iswctype
+locale-mbwc/tst_iswdigit
+locale-mbwc/tst_iswgraph
+locale-mbwc/tst_iswlower
+locale-mbwc/tst_iswprint
+locale-mbwc/tst_iswpunct
+locale-mbwc/tst_iswspace
+locale-mbwc/tst_iswupper
+locale-mbwc/tst_iswxdigit
+locale-mbwc/tst_mblen
+locale-mbwc/tst_mbrlen
+locale-mbwc/tst_mbrtowc
+locale-mbwc/tst_mbsrtowcs
+locale-mbwc/tst_mbstowcs
+locale-mbwc/tst_mbtowc
+locale-mbwc/tst_strcoll
+locale-mbwc/tst_strxfrm
+locale-mbwc/tst_swscanf
+locale-mbwc/tst_towctrans
+locale-mbwc/tst_towlower
+locale-mbwc/tst_towupper
+locale-mbwc/tst_wcrtomb
+locale-mbwc/tst_wcscat
+locale-mbwc/tst_wcschr
+locale-mbwc/tst_wcscmp
+locale-mbwc/tst_wcscoll
+locale-mbwc/tst_wcscpy
+locale-mbwc/tst_wcscspn
+locale-mbwc/tst_wcslen
+locale-mbwc/tst_wcsncat
+locale-mbwc/tst_wcsncmp
+locale-mbwc/tst_wcsncpy
+locale-mbwc/tst_wcspbrk
+locale-mbwc/tst_wcsrtombs
+locale-mbwc/tst_wcsspn
+locale-mbwc/tst_wcsstr
+locale-mbwc/tst_wcstod
+locale-mbwc/tst_wcstok
+locale-mbwc/tst_wcstombs
+locale-mbwc/tst_wcswidth
+locale-mbwc/tst_wcsxfrm
+locale-mbwc/tst_wctob
+locale-mbwc/tst_wctomb
+locale-mbwc/tst_wctrans
+locale-mbwc/tst_wctype
+locale-mbwc/tst_wcwidth
+locale-mbwc/tst2_mbrtowc
+malloc/malloc
+malloc/mallocbug
+malloc/malloc-standard-alignment
+malloc/realloc0
+malloc/realloc-can-shrink
+malloc/testmalloc
+malloc/tst-[cmv]alloc
+malloc/tst-mallocfork
+malloc/tst-mcheck
+malloc/tst-obstack
+math/basic-test
+math/compile_test
+math/c99_test
+math/ilogb
+math/libm-test-ulps.h
+math/libm-test.c
+math/rint
+math/signgam
+math/test-double
+math/test-ildoubl
+math/test-ldouble
+math/test-float
+math/test-fpucw
+math/test-idouble
+math/test-ifloat
+math/tst-definitions
+misc/bug-glob2
+misc/bug-readdir1
+misc/dirent
+misc/dirent64
+misc/fdopen
+misc/opendir-tst1
+misc/popen
+misc/seek
+misc/sem
+misc/stdarg
+misc/tst-inotify
+misc/tst-scandir
+misc/tst-seekdir
+misc/tst-statfs
+misc/tst-statvfs
+misc/tst-utmp
+misc/tst-utmpx
+mmap/mmap
+mmap/mmap2
+mmap/mmap64
+nptl/tst-align
+nptl/tst-align2
+nptl/tst-align3
+nptl/tst-atfork1
+nptl/tst-attr[1-3]
+nptl/tst-barrier[1-4]
+nptl/tst-basic[1-7]
+nptl/tst-cancel[1-9]
+nptl/tst-cancelx[2-4]
+nptl/tst-cancelx[6-9]
+nptl/tst-cancelx1[0-8]
+nptl/tst-cancelx2[0-1]
+nptl/tst-cancel[1-3][0-9]
+nptl/tst-cleanup[0-4]
+nptl/tst-cleanupx[0-4]
+nptl/tst-clock
+nptl/tst-clock[12]
+nptl/tst-clock_nanosleep
+nptl/tst-cond[1-9]
+nptl/tst-cond[1-2][0-9]
+nptl/tst-cpuclock[12]
+nptl/tst-cputimer[1-3]
+nptl/tst-detach1
+nptl/tst-dlsym1
+nptl/tst-eintr[1-5]
+nptl/tst-exec[2-4]
+nptl/tst-exit[1-3]
+nptl/tst-fini1
+nptl/tst-fini1mod.so
+nptl/tst-flock[1-2]
+nptl/tst-fork[1-4]
+nptl/tst-getpid[1-3]
+nptl/tst-initializers1
+nptl/tst-initializers1-c[89]9
+nptl/tst-initializers1-gnu[89]9
+nptl/tst-join[1-6]
+nptl/tst-key[1-4]
+nptl/tst-kill[1-6]
+nptl/tst-mqueue[1-9]
+nptl/tst-mutex[1-9]
+nptl/tst-mutex[57]a
+nptl/tst-once[1-4]
+nptl/tst-oncex[3-4]
+nptl/tst-popen1
+nptl/tst-oddstacklimit
+nptl/tst-raise1
+nptl/tst-rwlock[1-9]
+nptl/tst-rwlock1[0-4]
+nptl/tst-rwlock2a
+nptl/tst-sched1
+nptl/tst-sem[1-9]
+nptl/tst-sem1[0-2]
+nptl/tst-signal[1-7]
+nptl/tst-spin[1-3]
+nptl/tst-stack[12]
+nptl/tst-stdio[12]
+nptl/tst-sysconf
+nptl/tst-timer[2-5]
+nptl/tst-tls[1-5]
+nptl/tst-tls4mod.so
+nptl/tst-tls?mod[a-f].so
+nptl/tst-tls4modb.so
+nptl/tst-tls[35]mod.so
+nptl/tst-tls6.sh
+nptl/tst-tsd[1-6]
+nptl/tst-typesizes
+nptl/tst-umask1
+nptl/tst-unload
+nptl/tst-vfork[12]x
+pthread/cancellation-points
+pthread/ex[1-7]
+pthread/tst-too-many-cleanups
+pwd_grp/getgroups
+pwd_grp/grcat
+pwd_grp/pwcat
+pwd_grp/test_grp
+pwd_grp/test_pwd
+regex/testregex
+regex/tst-regex2
+regex/tst-regexloc
+rpc/getrpcent
+rpc/getrpcent_r
+setjmp/bug269-setjmp
+setjmp/jmpbug
+setjmp/sigjmpbug
+setjmp/tst-setjmp
+setjmp/tst-vfork-longjmp
+signal/sigchld
+signal/signal
+signal/tst-raise
+signal/tst-signal
+signal/tst-signalfd
+signal/tst-sigset
+signal/tst-sigsimple
+silly/hello
+silly/tiny
+silly/tst-atomic
+silly/tst-atomic-long
+stat/memcmp-stat
+stat/stat
+stat/stat64
+stat/stat-loop256
+stdio/64bit
+stdio/fclose-loop
+stdlib/ptytest
+stdlib/qsort
+stdlib/testarc4random
+stdlib/testatexit
+stdlib/test-canon
+stdlib/test-canon2
+stdlib/test-mkostemp-O_CLOEXEC
+stdlib/test-mkostemp-child
+stdlib/teston_exit
+stdlib/teststrtol
+stdlib/teststrtoq
+string/bug-strcoll1
+string/bug-strncat1
+string/bug-strpbrk1
+string/bug-strspn1
+string/stratcliff
+string/testcopy
+string/tester
+string/test-ffs
+string/tst-bswap
+string/tst-inlcall
+string/tst-strlen
+string/tst-strtok
+string/tst-strxfrm
+termios/termios
+time/clocktest
+time/test_time
+time/tst-ctime
+time/tst-ftime_l
+time/tst-futimens1
+time/tst-mktime
+time/tst-mktime3
+time/tst-strptime2
+time/tst-timerfd
+time/tst_wcsftime
+tls/tst-tls[1-9]
+tls/tst-tls1[0-8]
+tls/tst-tls-at-ctor
+tls/tst-tlsmod[1-9].so
+tls/tst-tlsmod1[0-9].so
+tls/tst-tlsmod1[0-9][ab].so
+tls/tst-tlsmod1[78]a[0-9].so
+tls/tst-tlsmod1[78]a1[0-9].so
+tls/tst-tlsmod-at-ctor.so
+unistd/clone
+unistd/errno
+unistd/exec-null
+unistd/fork
+unistd/getconf
+unistd/getconf.c
+unistd/getcwd
+unistd/getopt
+unistd/getopt_long
+unistd/tstgetopt
+unistd/tst-fallocate
+unistd/tst-fallocate64
+unistd/tst-posix_fallocate
+unistd/tst-posix_fallocate64
+unistd/tst-preadwrite
+unistd/tst-preadwrite64
+unistd/vfork
diff --git a/test/Makefile b/test/Makefile
index f38427e41..138308e73 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -5,6 +5,7 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
+top_srcdir=../
top_builddir=../
include Rules.mak
@@ -17,34 +18,49 @@ endif
ifneq ($(findstring -static,$(LDFLAGS)),)
DIRS := $(filter-out dlopen,$(DIRS))
endif
-ifneq ($(UCLIBC_HAS_THREADS),y)
+ifneq ($(UCLIBC_HAS_THREADS)$(ARCH_USE_MMU),yy)
DIRS := $(filter-out pthread,$(DIRS))
endif
+ifneq ($(UCLIBC_HAS_FLOATS),y)
+ DIRS := $(filter-out math,$(DIRS))
+endif
ifneq ($(UCLIBC_HAS_FULL_RPC),y)
DIRS := $(filter-out rpc,$(DIRS))
endif
ifneq ($(UCLIBC_HAS_REGEX),y)
DIRS := $(filter-out regex,$(DIRS))
endif
+ifneq ($(UCLIBC_HAS_THREADS_NATIVE),y)
+ DIRS := $(filter-out tls nptl,$(DIRS))
+endif
ifneq ($(UCLIBC_HAS_WCHAR),y)
DIRS := $(filter-out locale-mbwc,$(DIRS))
endif
ifneq ($(UCLIBC_HAS_LOCALE),y)
DIRS := $(filter-out locale,$(DIRS))
endif
-ifeq ($(UCLIBC_HAS_CRYPT_STUB),y)
+ifneq ($(UCLIBC_HAS_CRYPT_IMPL),y)
DIRS := $(filter-out crypt,$(DIRS))
endif
ifeq ($(HAS_NO_THREADS),y)
DIRS := $(filter-out pthread,$(DIRS))
endif
-DIRS := $(filter-out math,$(DIRS))
+ifneq ($(UCLIBC_HAS_ARGP),y)
+ DIRS := $(filter-out argp,$(DIRS))
+endif
test check all: run
run: subdirs_run
-compile: subdirs_compile
+gen:
+ -rm -f $(top_builddir)/test/uclibcng-testrunner.in
+ $(MAKE) run UCLIBCNG_GENERATE_TESTRUNNER=1
+
+compile: $(top_builddir)$(LOCAL_INSTALL_PATH) subdirs_compile
+
+$(top_builddir)$(LOCAL_INSTALL_PATH):
+ $(Q)$(MAKE) -C $(top_builddir) $(LOCAL_INSTALL_PATH)
tags:
ctags -R
@@ -57,13 +73,17 @@ subdirs_run: $(patsubst %, _dirrun_%, $(DIRS))
subdirs_clean: $(patsubst %, _dirclean_%, $(ALL_SUBDIRS))
$(patsubst %, _dir_%, $(DIRS)) : dummy
- $(Q)$(MAKE) -C $(patsubst _dir_%, %, $@)
+ $(Q)$(MAKE) -C $(patsubst _dir_%, %, $@) \
+ KCONFIG_CONFIG=$(KCONFIG_CONFIG)
$(patsubst %, _dirrun_%, $(DIRS)) : dummy
- $(Q)$(MAKE) -C $(patsubst _dirrun_%, %, $@) run
+ $(Q)$(MAKE) -C $(patsubst _dirrun_%, %, $@) run \
+ UCLIBCNG_TEST_SUBDIR=$(strip $(patsubst _dirrun_%, %, $@)) \
+ KCONFIG_CONFIG=$(KCONFIG_CONFIG)
$(patsubst %, _dircompile_%, $(DIRS)) : dummy
- $(Q)$(MAKE) -C $(patsubst _dircompile_%, %, $@) compile
+ $(Q)$(MAKE) -C $(patsubst _dircompile_%, %, $@) compile \
+ KCONFIG_CONFIG=$(KCONFIG_CONFIG)
$(patsubst %, _dirclean_%, $(ALL_SUBDIRS)) : dummy
$(Q)$(MAKE) -C $(patsubst _dirclean_%, %, $@) clean
diff --git a/test/README b/test/README
index b59945c54..723ce6e43 100644
--- a/test/README
+++ b/test/README
@@ -5,13 +5,11 @@ Following make targets are avaialable
make compile
-This will compile and link the tests
+This will compile and link the tests.
make run
-This will check for binaries if they are not there it
-will call 'compile' target then it will execute all the
-tests.
+This will execute all the tests.
make check
make all
@@ -19,32 +17,53 @@ make all
This will build and run tests.
The following make variables may help you in testing:
+
- UCLIBC_ONLY - only run tests against uClibc
- GLIBC_ONLY - only run tests against glibc
- V / VERBOSE - run tests with a lot of output
- - TEST_INSTALLED_UCLIBC - Test installed libraries
+ - TEST_INSTALLED_UCLIBC - Test installed libraries
under /lib and /usr/lib.
+ - TIMEOUTFACTOR=nn - increase test timeout nn times.
+ At least REGEX_OLD + regex/tst-regex2 needs it increased.
+
So, to just run the uClibc tests, try this:
make check UCLIBC_ONLY=1
+You can pass the following 2 environment variables to "make run":
+ - make run SIMULATOR_uclibc=qemu-sh4 SIMULATOR_glibc=qemu-x86_64
+
+If you need to test just a subset of all test, delete subdirectories
+you do not need.
+
+As of 2009-07, build machinery does not track dependencies on uclibc.
+If you edit a header and re-run "make compile", it does not re-install it
+into ../install_dir. If you delete ../install_dir, "make compile"
+rebuilds uclibc as needed and re-installs ../install_dir,
+but still does not rebuild testcases.
+(You can work around it by "touch */*.c" for now).
+
----------------
For: Developer
----------------
The structure of this test system is:
- test/ toplevel dir containing common test code
- test/Rules.mak Common build code
- test/Test.mak Runtime test make code
- test/subdir/ code specific to a subsystem is stored in a subdir
- test/subdir/Makefile describe the tests to run
- test/subdir/*.c the tests
-
-Each subdir Makefile must include the toplevel Test.mak file. Before doing so,
-you may define the TESTS and TESTS_DISABLED variables. If you do not, TESTS
-is built automatically based upon all the .c files in the subdir.
+ test/ toplevel dir containing common test code
+ test/Rules.mak Common build code
+ test/Test.mak Runtime test make code
+ test/subdir/ code specific to a subsystem is stored in a subdir
+ test/subdir/Makefile.in describe the tests to run
+ test/subdir/Makefile test entry point, includes needed upper-level
+ makefiles plus Makefile.in
+ test/subdir/*.c the tests
+
+Each subdir has a Makefile (same for any subdir) that must include in strict order:
+ - the upper-level Rules.mak file
+ - the Makefile.in
+ - the upper-level Test.mak file
+Makefile.in may be used to define the TESTS and TESTS_DISABLED variables.
+If you do not, TESTS is built automatically based upon all the .c files in the subdir.
TESTS := foo
TESTS_DISABLED := bar
-include ../Test.mak
Each test must use a similar .c name; so the "foo" test needs a "foo.c".
Additionally, the following options further control specific test behavior:
@@ -57,10 +76,11 @@ WRAPPER_foo := execute stuff just before test
Or to control all tests in a subdir:
EXTRA_CLEAN := extra files to remove in the clean target
+EXTRA_DIRS := extra directories to remove in the clean target
EXTRA_CFLAGS := -DFOO
EXTRA_LDFLAGS := -lpthread
-OPTS :=
-WRAPPER :=
+OPTS :=
+WRAPPER :=
If you want to compare the output of a test with known good output, then just
create a local file named "foo.out.good" and the output generated by the test
diff --git a/test/Rules.mak b/test/Rules.mak
index b74d941b6..9416a0cb4 100644
--- a/test/Rules.mak
+++ b/test/Rules.mak
@@ -5,23 +5,37 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-#
-# Note: This does not read the top level Rules.mak file
-#
+.SUFFIXES:
top_builddir ?= ../
+abs_top_builddir ?= $(shell cd $(top_builddir); pwd)/
TESTDIR=$(top_builddir)test/
-include $(top_builddir)/Rules.mak
-ifndef TEST_INSTALLED_UCLIBC
+include $(top_srcdir)Rules.mak
+ifeq ($(filter $(clean_targets) CLEAN_%,$(MAKECMDGOALS)),)
+ifeq ($(HAVE_DOT_CONFIG),)
+$(error no HAVE_DOT_CONFIG, failed to read .config)
+endif
+endif
+
ifdef UCLIBC_LDSO
ifeq (,$(findstring /,$(UCLIBC_LDSO)))
-UCLIBC_LDSO := $(top_builddir)lib/$(UCLIBC_LDSO)
+UCLIBC_LDSO := $(UCLIBC_LDSO)
+else
+UCLIBC_LDSO := $(notdir $(UCLIBC_LDSO))
+endif
+else
+UCLIBC_LDSO := $(notdir $(firstword $(wildcard $(top_builddir)lib/ld*)))
endif
+ifndef TEST_INSTALLED_UCLIBC
+ifeq ($(LDSO_SAFE_RUNPATH),y)
+UCLIBC_PATH := $(abs_top_builddir)lib
else
-UCLIBC_LDSO := $(firstword $(wildcard $(top_builddir)lib/ld*))
+UCLIBC_PATH := $(top_builddir)lib
endif
+else
+UCLIBC_PATH := $(RUNTIME_PREFIX)$(MULTILIB_DIR)
endif
#--------------------------------------------------------
# Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
@@ -31,11 +45,11 @@ export LC_ALL
ifeq ($(strip $(TARGET_ARCH)),)
TARGET_ARCH:=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \
-e 's/i.86/i386/' \
- -e 's/sparc.*/sparc/' \
- -e 's/arm.*/arm/g' \
+ -e 's/sun.*/sparc/' -e 's/sparc.*/sparc/' \
+ -e 's/sa110/arm/' -e 's/arm.*/arm/g' \
-e 's/m68k.*/m68k/' \
+ -e 's/parisc.*/hppa/' \
-e 's/ppc/powerpc/g' \
- -e 's/v850.*/v850/g' \
-e 's/sh[234]/sh/' \
-e 's/mips.*/mips/' \
-e 's/cris.*/cris/' \
@@ -44,84 +58,72 @@ TARGET_ARCH:=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \
endif
export TARGET_ARCH
+RM_R = $(Q)$(RM) -r
+LN_S = $(Q)$(LN) -fs
-#--------------------------------------------------------
-# If you are running a cross compiler, you will want to set 'CROSS'
-# to something more interesting... Target architecture is determined
-# by asking the CC compiler what arch it compiles things for, so unless
-# your compiler is broken, you should not need to specify TARGET_ARCH
-#
-# Most people will set this stuff on the command line, i.e.
-# make CROSS=mipsel-linux-
-# will build uClibc for 'mipsel'.
-
-CROSS = $(subst ",, $(strip $(CROSS_COMPILER_PREFIX)))
-CC = $(CROSS)gcc
-RM = rm -f
-
-# Select the compiler needed to build binaries for your development system
-HOSTCC = gcc
-
-
-#--------------------------------------------------------
-# A nifty macro to make testing gcc features easier
-check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
- then echo "$(1)"; else echo "$(2)"; fi)
-
-# use '-Os' optimization if available, else use -O2, allow Config to override
-# Override optimization settings when debugging
-ifeq ($(DODEBUG),y)
-OPTIMIZATION = -O0
+ifneq ($(KERNEL_HEADERS),)
+ifeq ($(patsubst /%,/,$(KERNEL_HEADERS)),/)
+# Absolute path in KERNEL_HEADERS
+KERNEL_INCLUDES += -I$(KERNEL_HEADERS)
else
-OPTIMIZATION += $(call check_gcc,-Os,-O2)
+# Relative path in KERNEL_HEADERS
+KERNEL_INCLUDES += -I$(top_builddir)$(KERNEL_HEADERS)
+endif
endif
-XWARNINGS := $(subst ",, $(strip $(WARNINGS))) -Wstrict-prototypes
-XARCH_CFLAGS := $(subst ",, $(strip $(ARCH_CFLAGS))) $(CPU_CFLAGS)
-XCOMMON_CFLAGS := -D_GNU_SOURCE -I$(top_builddir)test
-CFLAGS := $(XWARNINGS) $(OPTIMIZATION) $(XCOMMON_CFLAGS) $(XARCH_CFLAGS) -nostdinc -I$(top_builddir)$(LOCAL_INSTALL_PATH)/usr/include
+XCOMMON_CFLAGS := -I$(top_builddir)test -D_GNU_SOURCE
+XWARNINGS += $(CFLAG_-Wstrict-prototypes)
+CFLAGS := -nostdinc -I$(top_builddir)$(LOCAL_INSTALL_PATH)/usr/include
+CFLAGS += $(XCOMMON_CFLAGS) $(KERNEL_INCLUDES) $(CC_INC)
+CFLAGS += $(OPTIMIZATION) $(CPU_CFLAGS) $(XWARNINGS)
-CC_IPREFIX:=$(shell $(CC) --print-file-name=include)
-CFLAGS += -I$(dir $(CC_IPREFIX))/include-fixed -I$(CC_IPREFIX)
+$(eval $(call check-gcc-var,-Wno-missing-field-initializers))
+CFLAGS += $(CFLAG_-Wno-missing-field-initializers)
-HOST_CFLAGS += $(XWARNINGS) $(OPTIMIZATION) $(XCOMMON_CFLAGS)
+# Can't add $(OPTIMIZATION) here, it may be target-specific.
+# Just adding -Os for now.
+HOST_CFLAGS += $(XCOMMON_CFLAGS) -Os $(XWARNINGS) -std=gnu99
-LDFLAGS := $(CPU_LDFLAGS)
+LDFLAGS := $(CPU_LDFLAGS-y) -Wl,-z,now
ifeq ($(DODEBUG),y)
CFLAGS += -g
HOST_CFLAGS += -g
- LDFLAGS += -g
- HOST_LDFLAGS += -g
-else
- LDFLAGS += -s
- HOST_LDFLAGS += -s
+ LDFLAGS += -Wl,-g
+ HOST_LDFLAGS += -Wl,-g
endif
-ifneq ($(strip $(HAVE_SHARED)),y)
- LDFLAGS += -static
- HOST_LDFLAGS += -static
+ifeq ($(DOSTRIP),y)
+ LDFLAGS += -Wl,-s
+ HOST_LDFLAGS += -Wl,-s
endif
-LDFLAGS += -B$(top_builddir)lib -Wl,-rpath,$(top_builddir)lib -Wl,-rpath-link,$(top_builddir)lib
-UCLIBC_LDSO_ABSPATH=$(shell pwd)
-ifdef TEST_INSTALLED_UCLIBC
-LDFLAGS += -Wl,-rpath,./
-UCLIBC_LDSO_ABSPATH=$(SHARED_LIB_LOADER_PREFIX)
+ifneq ($(HAVE_SHARED),y)
+ LDFLAGS += -Wl,-static -static-libgcc
+endif
+
+ifndef TEST_INSTALLED_UCLIBC
+LDFLAGS += -B$(UCLIBC_PATH) -Wl,-rpath,$(UCLIBC_PATH):$(shell pwd) -Wl,-rpath-link,$(UCLIBC_PATH):$(shell pwd)
+else
+LDFLAGS += -Wl,-rpath,$(shell pwd)
endif
ifeq ($(findstring -static,$(LDFLAGS)),)
- LDFLAGS += -Wl,--dynamic-linker,$(UCLIBC_LDSO_ABSPATH)/$(UCLIBC_LDSO)
+LDFLAGS += -Wl,--dynamic-linker,$(UCLIBC_PATH)/$(UCLIBC_LDSO)
endif
ifeq ($(LDSO_GNU_HASH_SUPPORT),y)
# Check for binutils support is done on root Rules.mak
-LDFLAGS += -Wl,${LDFLAGS_GNUHASH}
+LDFLAGS += $(CFLAG_-Wl--hash-style=gnu)
endif
+ifneq ($(strip $(UCLIBC_EXTRA_CFLAGS)),"")
+CFLAGS += $(call qstrip,$(UCLIBC_EXTRA_CFLAGS))
+endif
+ifneq ($(strip $(UCLIBC_EXTRA_LDFLAGS)),"")
+LDFLAGS += $(call qstrip,$(UCLIBC_EXTRA_LDFLAGS))
+endif
-# Filter output
-MAKEFLAGS += --no-print-directory
-ifneq ($(findstring s,$(MAKEFLAGS)),)
+ifneq ($(findstring -s,$(MAKEFLAGS)),)
DISP := sil
Q := @
SCAT := -@true
@@ -136,12 +138,15 @@ Q := @
SCAT := -@true
endif
endif
+ifneq ($(Q),)
+MAKEFLAGS += --no-print-directory
+endif
banner := ---------------------------------
pur_showclean = echo " "CLEAN $(notdir $(CURDIR))
pur_showdiff = echo " "TEST_DIFF $(notdir $(CURDIR))/
pur_showlink = echo " "TEST_LINK $(notdir $(CURDIR))/ $@
-pur_showtest = echo " "TEST_EXEC $(notdir $(CURDIR))/ $(patsubst %.exe,%,$@)
+pur_showtest = echo " "TEST_EXEC $(notdir $(CURDIR))/ $(@:.exe=)
sil_showclean =
sil_showdiff = true
sil_showlink = true
@@ -149,7 +154,7 @@ sil_showtest = true
ver_showclean =
ver_showdiff = true echo
ver_showlink = true echo
-ver_showtest = printf "\n$(banner)\nTEST $(notdir $(PWD))/ $(patsubst %.exe,%,$@)\n$(banner)\n"
+ver_showtest = printf "\n$(banner)\nTEST $(notdir $(CURDIR))/ $(@:.exe=)\n$(banner)\n"
do_showclean = $($(DISP)_showclean)
do_showdiff = $($(DISP)_showdiff)
do_showlink = $($(DISP)_showlink)
diff --git a/test/Test.mak b/test/Test.mak
index af415aa9e..c1b34a7f9 100644
--- a/test/Test.mak
+++ b/test/Test.mak
@@ -4,6 +4,8 @@
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+shellescape='$(subst ','\'',$(1))'
+
ifeq ($(TESTS),)
TESTS := $(patsubst %.c,%,$(wildcard *.c))
endif
@@ -14,15 +16,16 @@ ifeq ($(SHELL_TESTS),)
SHELL_TESTS := $(patsubst %.sh,shell_%,$(wildcard *.sh))
endif
-ifneq ($(filter-out test,$(TESTS)),$(TESTS))
+ifneq ($(filter-out test,$(strip $(TESTS))),$(strip $(TESTS)))
$(error Sanity check: cannot have a test named "test.c")
endif
-top_builddir = ../../
-include ../Rules.mak
-
U_TARGETS := $(TESTS)
-G_TARGETS := $(patsubst %,%_glibc,$(U_TARGETS))
+G_TARGETS := $(addsuffix _glibc,$(U_TARGETS))
+
+ifneq ($(GLIBC_TESTS_DISABLED),)
+G_TARGETS := $(filter-out $(GLIBC_TESTS_DISABLED),$(G_TARGETS))
+endif
ifeq ($(GLIBC_ONLY),)
TARGETS += $(U_TARGETS)
@@ -32,85 +35,121 @@ TARGETS += $(G_TARGETS)
endif
CLEAN_TARGETS := $(U_TARGETS) $(G_TARGETS)
+CLEAN_TARGETS += $(TESTS_DISABLED) $(addsuffix _glibc,$(TESTS_DISABLED)) $(GLIBC_TESTS_DISABLED)
COMPILE_TARGETS := $(TARGETS)
-RUN_TARGETS := $(patsubst %,%.exe,$(TARGETS))
+# We sort the targets so uClibc and host-libc tests are run adjacent
+RUN_TARGETS := $(sort $(addsuffix .exe,$(TARGETS)))
+COMPILE_TARGETS := $(sort $(COMPILE_TARGETS))
+# provide build rules even for disabled tests:
+U_TARGETS += $(TESTS_DISABLED)
+G_TARGETS += $(addsuffix _glibc,$(TESTS_DISABLED)) $(GLIBC_TESTS_DISABLED)
TARGETS += $(SHELL_TESTS)
+CFLAGS += $(CFLAGS_$(notdir $(CURDIR)))
+ifeq (1,$(UCLIBCNG_GENERATE_TESTRUNNER))
+UCLIBCNG_TEST_SUBDIR ?= $(patsubst $(realpath $(TESTDIR))/%,%,$(CURDIR))
+endif
define binary_name
$(patsubst %.exe,%,$@)
endef
+define tst_src_name
+$(patsubst %_glibc,%,$(binary_name))
+endef
define diff_test
$(Q)\
- for x in "$(binary_name).out" "$(patsubst %_glibc,%,$(binary_name)).out" ; do \
+ for x in "$(binary_name).out" "$(tst_src_name).out" ; do \
test -e "$$x.good" && $(do_showdiff) "$(binary_name).out" "$$x.good" && exec diff -u "$(binary_name).out" "$$x.good" ; \
done ; \
true
endef
define uclibc_glibc_diff_test
$(Q)\
- test -z "$(DODIFF_$(patsubst %_glibc,%,$(binary_name)))" && exec true ; \
+ test -z "$(DODIFF_$(tst_src_name))" && exec true ; \
uclibc_out="$(binary_name).out" ; \
- glibc_out="$(patsubst %_glibc,%,$(binary_name)).out" ; \
+ glibc_out="$(tst_src_name).out" ; \
$(do_showdiff) $$uclibc_out $$glibc_out ; \
exec diff -u "$$uclibc_out" "$$glibc_out"
endef
define exec_test
$(showtest)
$(Q)\
- $(WRAPPER) $(WRAPPER_$(patsubst %_glibc,%,$(binary_name))) \
- ./$(binary_name) $(OPTS) $(OPTS_$(patsubst %_glibc,%,$(binary_name))) &> "$(binary_name).out" ; \
+ $(SIMULATOR) $(WRAPPER) $(WRAPPER_$(tst_src_name)) \
+ ./$(binary_name) $(OPTS) $(OPTS_$(tst_src_name)) > "$(binary_name).out" 2>&1 ; \
ret=$$? ; \
- expected_ret="$(RET_$(patsubst %_glibc,%,$(binary_name)))" ; \
+ expected_ret="$(RET_$(tst_src_name))" ; \
test -z "$$expected_ret" && export expected_ret=0 ; \
if ! test $$ret -eq $$expected_ret ; then \
echo "ret == $$ret ; expected_ret == $$expected_ret" ; \
+ echo "The output of the failed test is:"; \
+ cat "$(binary_name).out"; \
exit 1 ; \
fi
$(SCAT) "$(binary_name).out"
endef
test check all: run
-run: $(RUN_TARGETS) compile
+run: $(RUN_TARGETS)
-$(RUN_TARGETS): $(TARGETS)
+$(addsuffix .exe,$(U_TARGETS)): SIMULATOR:=$(SIMULATOR_uclibc)
+$(addsuffix .exe,$(G_TARGETS)): SIMULATOR:=$(SIMULATOR_glibc)
+$(RUN_TARGETS):
+ifeq (1,$(UCLIBCNG_GENERATE_TESTRUNNER))
+ $(Q)\
+ expected_ret="$(RET_$(tst_src_name))"; echo \
+ "$${expected_ret:-0}" \
+ $(call shellescape,$(tst_src_name)) \
+ $(call shellescape,$(binary_name)) \
+ $(call shellescape,$(UCLIBCNG_TEST_SUBDIR)) \
+ $(call shellescape,$(WRAPPER) $(WRAPPER_$(tst_src_name)) ./$(binary_name) $(OPTS) $(OPTS_$(tst_src_name))) \
+ >>$(top_builddir)/test/uclibcng-testrunner.in
+else
$(exec_test)
$(diff_test)
ifeq ($(UCLIBC_ONLY),)
$(uclibc_glibc_diff_test)
endif
+endif
compile: $(COMPILE_TARGETS)
-G_TARGET_SRCS := $(patsubst %,%.c,$(G_TARGETS))
-U_TARGET_SRCS := $(patsubst %,%.c,$(U_TARGETS))
+G_TARGET_SRCS := $(addsuffix .c,$(G_TARGETS))
+U_TARGET_SRCS := $(addsuffix .c,$(U_TARGETS))
-$(MAKE_SRCS): Makefile $(TESTDIR)Makefile $(TESTDIR)Rules.mak $(TESTDIR)Test.mak
+MAKE_SRCS := Makefile $(TESTDIR)Makefile $(TESTDIR)Rules.mak $(TESTDIR)Test.mak
$(U_TARGETS): $(U_TARGET_SRCS) $(MAKE_SRCS)
$(showlink)
- $(Q)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -c $@.c -o $@.o
- $(Q)$(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LDFLAGS) $(LDFLAGS_$@)
+ $(Q)$(CC) $(filter-out $(CFLAGS-OMIT-$@),$(CFLAGS)) $(EXTRA_CFLAGS) $(CFLAGS_$(notdir $(CURDIR))) $(CFLAGS_$@) -c $@.c -o $@.o
+ $(Q)$(CC) $(filter-out $(LDFLAGS-OMIT-$@),$(LDFLAGS)) $@.o -o $@ $(EXTRA_LDFLAGS) $(LDFLAGS_$@)
$(G_TARGETS): $(U_TARGET_SRCS) $(MAKE_SRCS)
$(showlink)
- $(Q)$(HOSTCC) $(HOST_CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(patsubst %_glibc,%,$@)) -c $(patsubst %_glibc,%,$@).c -o $@.o
- $(Q)$(HOSTCC) $(HOST_LDFLAGS) $@.o -o $@ $(EXTRA_LDFLAGS) $(LDFLAGS_$(patsubst %_glibc,%,$@))
+ $(Q)$(HOSTCC) $(filter-out $(HOST_CFLAGS-OMIT-$(patsubst %_glibc,%,$@)),$(HOST_CFLAGS)) \
+ $(CFLAGS_$(notdir $(CURDIR))) $(CFLAGS_$(patsubst %_glibc,%,$@)) \
+ -c $(patsubst %_glibc,%,$@).c -o $@.o
+ $(Q)$(HOSTCC) $(filter-out $(LDFLAGS-OMIT-$(patsubst %_glibc,%,$@)),$(HOST_LDFLAGS)) \
+ $@.o -o $@ $(EXTRA_LDFLAGS) $(LDFLAGS_$(patsubst %_glibc,%,$@)) $(LDFLAGS_$@)
shell_%:
$(showtest)
+ $(Q)$(if $(PRE_RUN_$(@)),$(PRE_RUN_$(@)))
$(Q)$(SHELL) $(patsubst shell_%,%.sh,$(binary_name))
+ $(Q)$(if $(POST_RUN_$(@)),$(POST_RUN_$(@)))
%.so: %.c
$(showlink)
$(Q)$(CC) \
- $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(patsubst %_glibc,%,$@)) \
+ $(filter-out $(CFLAGS-OMIT-$<),$(CFLAGS)) $(EXTRA_CFLAGS) \
+ $(CFLAGS_$(patsubst %_glibc,%,$@)) \
-fPIC -shared $< -o $@ -Wl,-soname,$@ \
- $(LDFLAGS) $(EXTRA_LIBS) $(LDFLAGS_$(patsubst %_glibc,%,$@))
+ $(filter-out $(LDFLAGS-OMIT-$<),$(LDFLAGS)) $(EXTRA_LIBS) \
+ $(LDFLAGS_$(patsubst %_glibc,%,$@))
clean:
$(showclean)
$(Q)$(RM) *.a *.o *.so *~ core *.out *.gdb $(CLEAN_TARGETS) $(EXTRA_CLEAN)
+ $(Q)$(RM_R) $(EXTRA_DIRS)
.PHONY: all check clean test run compile
diff --git a/test/argp/Makefile b/test/argp/Makefile
new file mode 100644
index 000000000..fcb5a8328
--- /dev/null
+++ b/test/argp/Makefile
@@ -0,0 +1,8 @@
+# uClibc argp tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+top_builddir=../../
+top_srcdir=../../
+include ../Rules.mak
+-include Makefile.in
+include ../Test.mak
diff --git a/test/argp/Makefile.in b/test/argp/Makefile.in
new file mode 100644
index 000000000..d81b3595b
--- /dev/null
+++ b/test/argp/Makefile.in
@@ -0,0 +1,12 @@
+# uClibc argp tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+TESTS := $(addprefix argp-, ex1 ex2 ex3 ex4 test) \
+ bug-argp1 tst-argp1 tst-argp2
+
+EXTRA_LDFLAGS = -luargp
+
+OPTS_argp-ex3 = ARG1 ARG2
+OPTS_argp-ex4 = ARG1 string1 string2 string3
+OPTS_bug-argp1 = -- --help
+
diff --git a/test/argp/argp-ex1.c b/test/argp/argp-ex1.c
new file mode 100644
index 000000000..7bb5f2241
--- /dev/null
+++ b/test/argp/argp-ex1.c
@@ -0,0 +1,15 @@
+/* Argp example #1 -- a minimal program using argp */
+
+/* This is (probably) the smallest possible program that
+ uses argp. It won't do much except give an error
+ messages and exit when there are any arguments, and print
+ a (rather pointless) messages for --help. */
+
+#include <stdlib.h>
+#include <argp.h>
+
+int main (int argc, char **argv)
+{
+ argp_parse (0, argc, argv, 0, 0, 0);
+ exit (0);
+}
diff --git a/test/argp/argp-ex2.c b/test/argp/argp-ex2.c
new file mode 100644
index 000000000..c49fbaca9
--- /dev/null
+++ b/test/argp/argp-ex2.c
@@ -0,0 +1,45 @@
+/* Argp example #2 -- a pretty minimal program using argp */
+
+/* This program doesn't use any options or arguments, but uses
+ argp to be compliant with the GNU standard command line
+ format.
+
+ In addition to making sure no arguments are given, and
+ implementing a --help option, this example will have a
+ --version option, and will put the given documentation string
+ and bug address in the --help output, as per GNU standards.
+
+ The variable ARGP contains the argument parser specification;
+ adding fields to this structure is the way most parameters are
+ passed to argp_parse (the first three fields are usually used,
+ but not in this small program). There are also two global
+ variables that argp knows about defined here,
+ ARGP_PROGRAM_VERSION and ARGP_PROGRAM_BUG_ADDRESS (they are
+ global variables because they will almost always be constant
+ for a given program, even if it uses different argument
+ parsers for various tasks). */
+
+#include <stdlib.h>
+#include <argp.h>
+
+const char *argp_program_version =
+ "argp-ex2 1.0";
+const char *argp_program_bug_address =
+ "<bug-gnu-utils@@gnu.org>";
+
+/* Program documentation. */
+static char doc[] =
+ "Argp example #2 -- a pretty minimal program using argp";
+
+/* Our argument parser. The @code{options}, @code{parser}, and
+ @code{args_doc} fields are zero because we have neither options or
+ arguments; @code{doc} and @code{argp_program_bug_address} will be
+ used in the output for @samp{--help}, and the @samp{--version}
+ option will print out @code{argp_program_version}. */
+static struct argp argp = { 0, 0, 0, doc };
+
+int main (int argc, char **argv)
+{
+ argp_parse (&argp, argc, argv, 0, 0, 0);
+ exit (0);
+}
diff --git a/test/argp/argp-ex3.c b/test/argp/argp-ex3.c
new file mode 100644
index 000000000..24d5c501a
--- /dev/null
+++ b/test/argp/argp-ex3.c
@@ -0,0 +1,153 @@
+/* Argp example #3 -- a program with options and arguments using argp */
+
+/* This program uses the same features as example 2, and uses options and
+ arguments.
+
+ We now use the first four fields in ARGP, so here's a description of them:
+ OPTIONS -- A pointer to a vector of struct argp_option (see below)
+ PARSER -- A function to parse a single option, called by argp
+ ARGS_DOC -- A string describing how the non-option arguments should look
+ DOC -- A descriptive string about this program; if it contains a
+ vertical tab character (\v), the part after it will be
+ printed *following* the options
+
+ The function PARSER takes the following arguments:
+ KEY -- An integer specifying which option this is (taken
+ from the KEY field in each struct argp_option), or
+ a special key specifying something else; the only
+ special keys we use here are ARGP_KEY_ARG, meaning
+ a non-option argument, and ARGP_KEY_END, meaning
+ that all arguments have been parsed
+ ARG -- For an option KEY, the string value of its
+ argument, or NULL if it has none
+ STATE-- A pointer to a struct argp_state, containing
+ various useful information about the parsing state; used here
+ are the INPUT field, which reflects the INPUT argument to
+ argp_parse, and the ARG_NUM field, which is the number of the
+ current non-option argument being parsed
+ It should return either 0, meaning success, ARGP_ERR_UNKNOWN, meaning the
+ given KEY wasn't recognized, or an errno value indicating some other
+ error.
+
+ Note that in this example, main uses a structure to communicate with the
+ parse_opt function, a pointer to which it passes in the INPUT argument to
+ argp_parse. Of course, it's also possible to use global variables
+ instead, but this is somewhat more flexible.
+
+ The OPTIONS field contains a pointer to a vector of struct argp_option's;
+ that structure has the following fields (if you assign your option
+ structures using array initialization like this example, unspecified
+ fields will be defaulted to 0, and need not be specified):
+ NAME -- The name of this option's long option (may be zero)
+ KEY -- The KEY to pass to the PARSER function when parsing this option,
+ *and* the name of this option's short option, if it is a
+ printable ascii character
+ ARG -- The name of this option's argument, if any
+ FLAGS -- Flags describing this option; some of them are:
+ OPTION_ARG_OPTIONAL -- The argument to this option is optional
+ OPTION_ALIAS -- This option is an alias for the
+ previous option
+ OPTION_HIDDEN -- Don't show this option in --help output
+ DOC -- A documentation string for this option, shown in --help output
+
+ An options vector should be terminated by an option with all fields zero. */
+
+#include <stdlib.h>
+#include <argp.h>
+
+const char *argp_program_version =
+ "argp-ex3 1.0";
+const char *argp_program_bug_address =
+ "<bug-gnu-utils@@gnu.org>";
+
+/* Program documentation. */
+static char doc[] =
+ "Argp example #3 -- a program with options and arguments using argp";
+
+/* A description of the arguments we accept. */
+static char args_doc[] = "ARG1 ARG2";
+
+/* The options we understand. */
+static struct argp_option options[] = {
+ {"verbose", 'v', 0, 0, "Produce verbose output" },
+ {"quiet", 'q', 0, 0, "Don't produce any output" },
+ {"silent", 's', 0, OPTION_ALIAS },
+ {"output", 'o', "FILE", 0,
+ "Output to FILE instead of standard output" },
+ { 0 }
+};
+
+/* Used by @code{main} to communicate with @code{parse_opt}. */
+struct arguments
+{
+ char *args[2]; /* @var{arg1} & @var{arg2} */
+ int silent, verbose;
+ char *output_file;
+};
+
+/* Parse a single option. */
+static error_t
+parse_opt (int key, char *arg, struct argp_state *state)
+{
+ /* Get the @var{input} argument from @code{argp_parse}, which we
+ know is a pointer to our arguments structure. */
+ struct arguments *arguments = state->input;
+
+ switch (key)
+ {
+ case 'q': case 's':
+ arguments->silent = 1;
+ break;
+ case 'v':
+ arguments->verbose = 1;
+ break;
+ case 'o':
+ arguments->output_file = arg;
+ break;
+
+ case ARGP_KEY_ARG:
+ if (state->arg_num >= 2)
+ /* Too many arguments. */
+ argp_usage (state);
+
+ arguments->args[state->arg_num] = arg;
+
+ break;
+
+ case ARGP_KEY_END:
+ if (state->arg_num < 2)
+ /* Not enough arguments. */
+ argp_usage (state);
+ break;
+
+ default:
+ return ARGP_ERR_UNKNOWN;
+ }
+ return 0;
+}
+
+/* Our argp parser. */
+static struct argp argp = { options, parse_opt, args_doc, doc };
+
+int main (int argc, char **argv)
+{
+ struct arguments arguments;
+
+ /* Default values. */
+ arguments.silent = 0;
+ arguments.verbose = 0;
+ arguments.output_file = "-";
+
+ /* Parse our arguments; every option seen by @code{parse_opt} will
+ be reflected in @code{arguments}. */
+ argp_parse (&argp, argc, argv, 0, 0, &arguments);
+
+ printf ("ARG1 = %s\nARG2 = %s\nOUTPUT_FILE = %s\n"
+ "VERBOSE = %s\nSILENT = %s\n",
+ arguments.args[0], arguments.args[1],
+ arguments.output_file,
+ arguments.verbose ? "yes" : "no",
+ arguments.silent ? "yes" : "no");
+
+ exit (0);
+}
diff --git a/test/argp/argp-ex4.c b/test/argp/argp-ex4.c
new file mode 100644
index 000000000..c77c7ef02
--- /dev/null
+++ b/test/argp/argp-ex4.c
@@ -0,0 +1,167 @@
+/* Argp example #4 -- a program with somewhat more complicated options */
+
+/* This program uses the same features as example 3, but has more
+ options, and somewhat more structure in the -help output. It
+ also shows how you can `steal' the remainder of the input
+ arguments past a certain point, for programs that accept a
+ list of items. It also shows the special argp KEY value
+ ARGP_KEY_NO_ARGS, which is only given if no non-option
+ arguments were supplied to the program.
+
+ For structuring the help output, two features are used,
+ *headers* which are entries in the options vector with the
+ first four fields being zero, and a two part documentation
+ string (in the variable DOC), which allows documentation both
+ before and after the options; the two parts of DOC are
+ separated by a vertical-tab character ('\v', or '\013'). By
+ convention, the documentation before the options is just a
+ short string saying what the program does, and that afterwards
+ is longer, describing the behavior in more detail. All
+ documentation strings are automatically filled for output,
+ although newlines may be included to force a line break at a
+ particular point. All documentation strings are also passed to
+ the `gettext' function, for possible translation into the
+ current locale. */
+
+#include <stdlib.h>
+#include <error.h>
+#include <argp.h>
+
+const char *argp_program_version =
+ "argp-ex4 1.0";
+const char *argp_program_bug_address =
+ "<bug-gnu-utils@@prep.ai.mit.edu>";
+
+/* Program documentation. */
+static char doc[] =
+ "Argp example #4 -- a program with somewhat more complicated\
+options\
+\vThis part of the documentation comes *after* the options;\
+ note that the text is automatically filled, but it's possible\
+ to force a line-break, e.g.\n<-- here.";
+
+/* A description of the arguments we accept. */
+static char args_doc[] = "ARG1 [STRING...]";
+
+/* Keys for options without short-options. */
+#define OPT_ABORT 1 /* --abort */
+
+/* The options we understand. */
+static struct argp_option options[] = {
+ {"verbose", 'v', 0, 0, "Produce verbose output" },
+ {"quiet", 'q', 0, 0, "Don't produce any output" },
+ {"silent", 's', 0, OPTION_ALIAS },
+ {"output", 'o', "FILE", 0,
+ "Output to FILE instead of standard output" },
+
+ {0,0,0,0, "The following options should be grouped together:" },
+ {"repeat", 'r', "COUNT", OPTION_ARG_OPTIONAL,
+ "Repeat the output COUNT (default 10) times"},
+ {"abort", OPT_ABORT, 0, 0, "Abort before showing any output"},
+
+ { 0 }
+};
+
+/* Used by @code{main} to communicate with @code{parse_opt}. */
+struct arguments
+{
+ char *arg1; /* @var{arg1} */
+ char **strings; /* [@var{string}@dots{}] */
+ int silent, verbose, abort; /* @samp{-s}, @samp{-v}, @samp{--abort} */
+ char *output_file; /* @var{file} arg to @samp{--output} */
+ int repeat_count; /* @var{count} arg to @samp{--repeat} */
+};
+
+/* Parse a single option. */
+static error_t
+parse_opt (int key, char *arg, struct argp_state *state)
+{
+ /* Get the @code{input} argument from @code{argp_parse}, which we
+ know is a pointer to our arguments structure. */
+ struct arguments *arguments = state->input;
+
+ switch (key)
+ {
+ case 'q': case 's':
+ arguments->silent = 1;
+ break;
+ case 'v':
+ arguments->verbose = 1;
+ break;
+ case 'o':
+ arguments->output_file = arg;
+ break;
+ case 'r':
+ arguments->repeat_count = arg ? atoi (arg) : 10;
+ break;
+ case OPT_ABORT:
+ arguments->abort = 1;
+ break;
+
+ case ARGP_KEY_NO_ARGS:
+ argp_usage (state);
+
+ case ARGP_KEY_ARG:
+ /* Here we know that @code{state->arg_num == 0}, since we
+ force argument parsing to end before any more arguments can
+ get here. */
+ arguments->arg1 = arg;
+
+ /* Now we consume all the rest of the arguments.
+ @code{state->next} is the index in @code{state->argv} of the
+ next argument to be parsed, which is the first @var{string}
+ we're interested in, so we can just use
+ @code{&state->argv[state->next]} as the value for
+ arguments->strings.
+
+ @emph{In addition}, by setting @code{state->next} to the end
+ of the arguments, we can force argp to stop parsing here and
+ return. */
+ arguments->strings = &state->argv[state->next];
+ state->next = state->argc;
+
+ break;
+
+ default:
+ return ARGP_ERR_UNKNOWN;
+ }
+ return 0;
+}
+
+/* Our argp parser. */
+static struct argp argp = { options, parse_opt, args_doc, doc };
+
+int main (int argc, char **argv)
+{
+ int i, j;
+ struct arguments arguments;
+
+ /* Default values. */
+ arguments.silent = 0;
+ arguments.verbose = 0;
+ arguments.output_file = "-";
+ arguments.repeat_count = 1;
+ arguments.abort = 0;
+
+ /* Parse our arguments; every option seen by @code{parse_opt} will be
+ reflected in @code{arguments}. */
+ argp_parse (&argp, argc, argv, 0, 0, &arguments);
+
+ if (arguments.abort)
+ error (10, 0, "ABORTED");
+
+ for (i = 0; i < arguments.repeat_count; i++)
+ {
+ printf ("ARG1 = %s\n", arguments.arg1);
+ printf ("STRINGS = ");
+ for (j = 0; arguments.strings[j]; j++)
+ printf (j == 0 ? "%s" : ", %s", arguments.strings[j]);
+ printf ("\n");
+ printf ("OUTPUT_FILE = %s\nVERBOSE = %s\nSILENT = %s\n",
+ arguments.output_file,
+ arguments.verbose ? "yes" : "no",
+ arguments.silent ? "yes" : "no");
+ }
+
+ exit (0);
+}
diff --git a/test/argp/argp-test.c b/test/argp/argp-test.c
new file mode 100644
index 000000000..b3d573bae
--- /dev/null
+++ b/test/argp/argp-test.c
@@ -0,0 +1,209 @@
+/* Test program for argp argument parser
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Miles Bader <miles at gnu.ai.mit.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. */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <time.h>
+#include <string.h>
+#include <argp.h>
+
+const char *argp_program_version = "argp-test 1.0";
+
+struct argp_option sub_options[] =
+{
+ {"subopt1", 's', 0, 0, "Nested option 1"},
+ {"subopt2", 'S', 0, 0, "Nested option 2"},
+
+ { 0, 0, 0, 0, "Some more nested options:", 10},
+ {"subopt3", 'p', 0, 0, "Nested option 3"},
+
+ {"subopt4", 'q', 0, 0, "Nested option 4", 1},
+
+ {0}
+};
+
+static const char sub_args_doc[] = "STRING...\n-";
+static const char sub_doc[] = "\vThis is the doc string from the sub-arg-parser.";
+
+static error_t
+sub_parse_opt (int key, char *arg, struct argp_state *state)
+{
+ switch (key)
+ {
+ case ARGP_KEY_NO_ARGS:
+ printf ("NO SUB ARGS\n");
+ break;
+ case ARGP_KEY_ARG:
+ printf ("SUB ARG: %s\n", arg);
+ break;
+
+ case 's' : case 'S': case 'p': case 'q':
+ printf ("SUB KEY %c\n", key);
+ break;
+
+ default:
+ return ARGP_ERR_UNKNOWN;
+ }
+ return 0;
+}
+
+static char *
+sub_help_filter (int key, const char *text, void *input)
+{
+ if (key == ARGP_KEY_HELP_EXTRA)
+ return strdup ("This is some extra text from the sub parser (note that it \
+is preceded by a blank line).");
+ else
+ return (char *)text;
+}
+
+static struct argp sub_argp = {
+ sub_options, sub_parse_opt, sub_args_doc, sub_doc, 0, sub_help_filter
+};
+
+/* Structure used to communicate with the parsing functions. */
+struct params
+{
+ unsigned foonly; /* Value parsed for foonly. */
+ unsigned foonly_default; /* Default value for it. */
+};
+
+#define OPT_PGRP 1
+#define OPT_SESS 2
+
+struct argp_option options[] =
+{
+ {"pid", 'p', "PID", 0, "List the process PID"},
+ {"pgrp", OPT_PGRP,"PGRP",0, "List processes in the process group PGRP"},
+ {"no-parent", 'P', 0, 0, "Include processes without parents"},
+ {0, 'x', 0, OPTION_ALIAS},
+ {"all-fields",'Q', 0, 0, "Don't elide unusable fields (normally"
+ " if there's some reason ps can't"
+ " print a field for any process, it's"
+ " removed from the output entirely)" },
+ {"reverse", 'r', 0, 0, "Reverse the order of any sort"},
+ {"gratuitously-long-reverse-option", 0, 0, OPTION_ALIAS},
+ {"session", OPT_SESS,"SID", OPTION_ARG_OPTIONAL,
+ "Add the processes from the session"
+ " SID (which defaults to the sid of"
+ " the current process)" },
+
+ {0,0,0,0, "Here are some more options:"},
+ {"foonly", 'f', "ZOT", OPTION_ARG_OPTIONAL, "Glork a foonly"},
+ {"zaza", 'z', 0, 0, "Snit a zar"},
+
+ {0}
+};
+
+static const char args_doc[] = "STRING";
+static const char doc[] = "Test program for argp."
+ "\vThis doc string comes after the options."
+ "\nHey! Some manual formatting!"
+ "\nThe current time is: %s";
+
+static void
+popt (int key, char *arg)
+{
+ char buf[10];
+ if (isprint (key))
+ sprintf (buf, "%c", key);
+ else
+ sprintf (buf, "%d", key);
+ if (arg)
+ printf ("KEY %s: %s\n", buf, arg);
+ else
+ printf ("KEY %s\n", buf);
+}
+
+static error_t
+parse_opt (int key, char *arg, struct argp_state *state)
+{
+ struct params *params = state->input;
+
+ switch (key)
+ {
+ case ARGP_KEY_NO_ARGS:
+ printf ("NO ARGS\n");
+ break;
+
+ case ARGP_KEY_ARG:
+ if (state->arg_num > 0)
+ return ARGP_ERR_UNKNOWN; /* Leave it for the sub-arg parser. */
+ printf ("ARG: %s\n", arg);
+ break;
+
+ case 'f':
+ if (arg)
+ params->foonly = atoi (arg);
+ else
+ params->foonly = params->foonly_default;
+ popt (key, arg);
+ break;
+
+ case 'p': case 'P': case OPT_PGRP: case 'x': case 'Q':
+ case 'r': case OPT_SESS: case 'z':
+ popt (key, arg);
+ break;
+
+ default:
+ return ARGP_ERR_UNKNOWN;
+ }
+ return 0;
+}
+
+static char *
+help_filter (int key, const char *text, void *input)
+{
+ char *new_text;
+ struct params *params = input;
+
+ if (key == ARGP_KEY_HELP_POST_DOC && text)
+ {
+ time_t now = time (0);
+ asprintf (&new_text, text, ctime (&now));
+ }
+ else if (key == 'f')
+ /* Show the default for the --foonly option. */
+ asprintf (&new_text, "%s (ZOT defaults to %x)",
+ text, params->foonly_default);
+ else
+ new_text = (char *)text;
+
+ return new_text;
+}
+
+static struct argp_child argp_children[] = { { &sub_argp }, { 0 } };
+static struct argp argp = {
+ options, parse_opt, args_doc, doc, argp_children, help_filter
+};
+
+int
+main (int argc, char **argv)
+{
+ struct params params;
+ params.foonly = 0;
+ params.foonly_default = random ();
+ argp_parse (&argp, argc, argv, 0, 0, &params);
+ printf ("After parsing: foonly = %x\n", params.foonly);
+ return 0;
+}
diff --git a/test/argp/bug-argp1.c b/test/argp/bug-argp1.c
new file mode 100644
index 000000000..a28cf4b9c
--- /dev/null
+++ b/test/argp/bug-argp1.c
@@ -0,0 +1,26 @@
+#include <argp.h>
+
+
+static const struct argp_option test_options[] =
+{
+ { NULL, 'a', NULL, OPTION_DOC, NULL },
+ { NULL, 'b', NULL, OPTION_DOC, NULL },
+ { NULL, 0, NULL, 0, NULL }
+};
+
+static struct argp test_argp =
+{
+ test_options
+};
+
+
+static int
+do_test (int argc, char *argv[])
+{
+ int i;
+ argp_parse (&test_argp, argc, argv, 0, &i, NULL);
+ return 0;
+}
+
+#define TEST_FUNCTION do_test (argc, argv)
+#include "../test-skeleton.c"
diff --git a/test/argp/tst-argp1.c b/test/argp/tst-argp1.c
new file mode 100644
index 000000000..827daca6f
--- /dev/null
+++ b/test/argp/tst-argp1.c
@@ -0,0 +1,118 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper at redhat.com>, 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <argp.h>
+
+
+
+
+#define OPT_TO_THREAD 300
+#define OPT_TO_PROCESS 301
+#define OPT_SYNC_SIGNAL 302
+#define OPT_SYNC_JOIN 303
+#define OPT_TOPLEVEL 304
+
+
+static const struct argp_option test_options[] =
+ {
+ { NULL, 0, NULL, 0, "\
+This is a test for threads so we allow ther user to selection the number of \
+threads which are used at any one time. Independently the total number of \
+rounds can be selected. This is the total number of threads which will have \
+run when the process terminates:" },
+ { "threads", 't', "NUMBER", 0, "Number of threads used at once" },
+ { "starts", 's', "NUMBER", 0, "Total number of working threads" },
+ { "toplevel", OPT_TOPLEVEL, "NUMBER", 0,
+ "Number of toplevel threads which start the other threads; this \
+implies --sync-join" },
+
+ { NULL, 0, NULL, 0, "\
+Each thread can do one of two things: sleep or do work. The latter is 100% \
+CPU bound. The work load is the probability a thread does work. All values \
+from zero to 100 (inclusive) are valid. How often each thread repeats this \
+can be determined by the number of rounds. The work cost determines how long \
+each work session (not sleeping) takes. If it is zero a thread would \
+effectively nothing. By setting the number of rounds to zero the thread \
+does no work at all and pure thread creation times can be measured." },
+ { "workload", 'w', "PERCENT", 0, "Percentage of time spent working" },
+ { "workcost", 'c', "NUMBER", 0,
+ "Factor in the cost of each round of working" },
+ { "rounds", 'r', "NUMBER", 0, "Number of rounds each thread runs" },
+
+ { NULL, 0, NULL, 0, "\
+There are a number of different methods how thread creation can be \
+synchronized. Synchronization is necessary since the number of concurrently \
+running threads is limited." },
+ { "sync-signal", OPT_SYNC_SIGNAL, NULL, 0,
+ "Synchronize using a signal (default)" },
+ { "sync-join", OPT_SYNC_JOIN, NULL, 0, "Synchronize using pthread_join" },
+
+ { NULL, 0, NULL, 0, "\
+One parameter for each threads execution is the size of the stack. If this \
+parameter is not used the system's default stack size is used. If many \
+threads are used the stack size should be chosen quite small." },
+ { "stacksize", 'S', "BYTES", 0, "Size of threads stack" },
+ { "guardsize", 'g', "BYTES", 0,
+ "Size of stack guard area; must fit into the stack" },
+
+ { NULL, 0, NULL, 0, "Signal options:" },
+ { "to-thread", OPT_TO_THREAD, NULL, 0, "Send signal to main thread" },
+ { "to-process", OPT_TO_PROCESS, NULL, 0,
+ "Send signal to process (default)" },
+
+ { NULL, 0, NULL, 0, "Administrative options:" },
+ { "progress", 'p', NULL, 0, "Show signs of progress" },
+ { "timing", 'T', NULL, 0,
+ "Measure time from startup to the last thread finishing" },
+ { NULL, 0, NULL, 0, NULL }
+ };
+
+/* Prototype for option handler. */
+static error_t parse_opt (int key, char *arg, struct argp_state *state);
+
+/* Data structure to communicate with argp functions. */
+static struct argp argp =
+{
+ test_options, parse_opt
+};
+
+
+static int
+do_test (void)
+{
+ int argc = 2;
+ char *argv[3] = { (char *) "tst-argp1", (char *) "--help", NULL };
+ int remaining;
+
+ /* Parse and process arguments. */
+ argp_parse (&argp, argc, argv, 0, &remaining, NULL);
+
+ return 0;
+}
+
+
+/* Handle program arguments. */
+static error_t
+parse_opt (int key, char *arg, struct argp_state *state)
+{
+ return ARGP_ERR_UNKNOWN;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/argp/tst-argp2.c b/test/argp/tst-argp2.c
new file mode 100644
index 000000000..705cdcaa9
--- /dev/null
+++ b/test/argp/tst-argp2.c
@@ -0,0 +1,101 @@
+/* Copyright (C) 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub at redhat.com>, 2007.
+
+ 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 <argp.h>
+
+static const struct argp_option opt1[] =
+ {
+ { "opt1", '1', "NUMBER", 0, "Option 1" },
+ { NULL, 0, NULL, 0, NULL }
+ };
+
+static const struct argp_option opt2[] =
+ {
+ { "opt2", '2', "NUMBER", 0, "Option 2" },
+ { NULL, 0, NULL, 0, NULL }
+ };
+
+static const struct argp_option opt3[] =
+ {
+ { "opt3", '3', "NUMBER", 0, "Option 3" },
+ { NULL, 0, NULL, 0, NULL }
+ };
+
+static const struct argp_option opt4[] =
+ {
+ { "opt4", '4', "NUMBER", 0, "Option 4" },
+ { NULL, 0, NULL, 0, NULL }
+ };
+
+static const struct argp_option opt5[] =
+ {
+ { "opt5", '5', "NUMBER", 0, "Option 5" },
+ { NULL, 0, NULL, 0, NULL }
+ };
+
+static struct argp argp5 =
+ {
+ opt5, NULL, "args doc5", "doc5", NULL, NULL, NULL
+ };
+
+static struct argp argp4 =
+ {
+ opt4, NULL, "args doc4", "doc4", NULL, NULL, NULL
+ };
+
+static struct argp argp3 =
+ {
+ opt3, NULL, "args doc3", "doc3", NULL, NULL, NULL
+ };
+
+static struct argp_child children2[] =
+ {
+ { &argp4, 0, "child3", 3 },
+ { &argp5, 0, "child4", 4 },
+ { NULL, 0, NULL, 0 }
+ };
+
+static struct argp argp2 =
+ {
+ opt2, NULL, "args doc2", "doc2", children2, NULL, NULL
+ };
+
+static struct argp_child children1[] =
+ {
+ { &argp2, 0, "child1", 1 },
+ { &argp3, 0, "child2", 2 },
+ { NULL, 0, NULL, 0 }
+ };
+
+static struct argp argp1 =
+ {
+ opt1, NULL, "args doc1", "doc1", children1, NULL, NULL
+ };
+
+
+static int
+do_test (void)
+{
+ argp_help (&argp1, stdout, ARGP_HELP_LONG, (char *) "tst-argp2");
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/args/Makefile b/test/args/Makefile
index 7ba8a31b4..0ae3f010b 100644
--- a/test/args/Makefile
+++ b/test/args/Makefile
@@ -1,11 +1,8 @@
# uClibc args tests
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+top_builddir=../../
+top_srcdir=../../
+include ../Rules.mak
+-include Makefile.in
include ../Test.mak
-
-OPTS_arg_test = a b c d e f g h
-WRAPPER_arg_test = \
- env -i \
- ENVVAR=123 \
- SOMETHING=sldajfasdf \
- BLAHBLAH=" hi hi "
diff --git a/test/args/Makefile.in b/test/args/Makefile.in
new file mode 100644
index 000000000..f4edab454
--- /dev/null
+++ b/test/args/Makefile.in
@@ -0,0 +1,9 @@
+# uClibc args tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+OPTS_arg_test = a b c d e f g h
+WRAPPER_arg_test = \
+ env -i \
+ ENVVAR=123 \
+ SOMETHING=sldajfasdf \
+ BLAHBLAH=" hi hi "
diff --git a/test/assert/Makefile b/test/assert/Makefile
index 1c557fc84..841a4dace 100644
--- a/test/assert/Makefile
+++ b/test/assert/Makefile
@@ -1,7 +1,8 @@
# uClibc assert tests
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+top_builddir=../../
+top_srcdir=../../
+include ../Rules.mak
+-include Makefile.in
include ../Test.mak
-
-RET_assert := 134
-WRAPPER_assert := trap ":" ABRT ;
diff --git a/test/assert/Makefile.in b/test/assert/Makefile.in
new file mode 100644
index 000000000..3f4fb4dfe
--- /dev/null
+++ b/test/assert/Makefile.in
@@ -0,0 +1,6 @@
+# uClibc assert tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+RET_assert := 134
+WRAPPER_assert := trap ":" ABRT ;
+CFLAGS_assert := -fPIC
diff --git a/test/build/Makefile b/test/build/Makefile
index eb65c2ad3..ce74a8a7a 100644
--- a/test/build/Makefile
+++ b/test/build/Makefile
@@ -1,4 +1,8 @@
# uClibc build tests
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+top_builddir=../../
+top_srcdir=../../
+include ../Rules.mak
+-include Makefile.in
include ../Test.mak
diff --git a/test/build/check_config_options.sh b/test/build/check_config_options.sh
index 086131f38..086131f38 100644..100755
--- a/test/build/check_config_options.sh
+++ b/test/build/check_config_options.sh
diff --git a/test/crypt/Makefile b/test/crypt/Makefile
index 11d420d9e..25b0f3c86 100644
--- a/test/crypt/Makefile
+++ b/test/crypt/Makefile
@@ -1,8 +1,8 @@
# uClibc crypt tests
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+top_builddir=../../
+top_srcdir=../../
+include ../Rules.mak
+-include Makefile.in
include ../Test.mak
-
-EXTRA_LDFLAGS := -lcrypt
-
-OPTS_crypt = < crypt.input
diff --git a/test/crypt/Makefile.in b/test/crypt/Makefile.in
new file mode 100644
index 000000000..f85221947
--- /dev/null
+++ b/test/crypt/Makefile.in
@@ -0,0 +1,15 @@
+# uClibc crypt tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+EXTRA_LDFLAGS := -lcrypt
+
+OPTS_crypt = < crypt.input
+
+ifneq ($(UCLIBC_HAS_SHA512_CRYPT_IMPL),y)
+TESTS_DISABLED += sha512c-test
+endif
+ifneq ($(UCLIBC_HAS_SHA256_CRYPT_IMPL),y)
+TESTS_DISABLED += sha256c-test
+endif
+
+WRAPPER := env TIMEOUTFACTOR=50
diff --git a/test/crypt/crypt.c b/test/crypt/crypt.c
index 34d7e4158..786464710 100644
--- a/test/crypt/crypt.c
+++ b/test/crypt/crypt.c
@@ -10,18 +10,10 @@
#include <stdlib.h>
#include "crypt.h"
-int totfails = 0;
-
-#if __STDC__ - 0
-int main (int argc, char *argv[]);
-void get8 (char *cp);
-void put8 (char *cp);
-void good_bye (void) __attribute__ ((noreturn));
-#else
-void get8(), put8();
-#endif
-
-void good_bye ()
+static int totfails = 0;
+
+static void good_bye (void) __attribute__ ((noreturn));
+static void good_bye (void)
{
if(totfails == 0) {
printf("Passed DES validation suite\n");
@@ -32,10 +24,33 @@ void good_bye ()
}
}
-int
-main(argc, argv)
- int argc;
- char *argv[];
+static void get8(char *cp)
+{
+ int i,j,t;
+
+ for(i=0;i<8;i++){
+ scanf("%2x",&t);
+ if(feof(stdin))
+ good_bye();
+ for(j=0; j<8 ; j++) {
+ *cp++ = (t & (0x01 << (7-j))) != 0;
+ }
+ }
+}
+
+static void put8(char *cp)
+{
+ int i,j,t;
+
+ for(i=0;i<8;i++){
+ t = 0;
+ for(j = 0; j<8; j++)
+ t = (t<<1) | *cp++;
+ printf("%02x", t);
+ }
+}
+
+int main(void)
{
char key[64],plain[64],cipher[64],answer[64];
int i;
@@ -58,9 +73,10 @@ main(argc, argv)
cipher[i] = plain[i];
encrypt(cipher, 0);
- for(i=0;i<64;i++)
+ for(i=0;i<64;i++) {
if(cipher[i] != answer[i])
break;
+ }
fail = 0;
if(i != 64){
printf(" Encrypt FAIL");
@@ -83,31 +99,5 @@ main(argc, argv)
}
good_bye();
}
-void
-get8(cp)
-char *cp;
-{
- int i,j,t;
- for(i=0;i<8;i++){
- scanf("%2x",&t);
- if(feof(stdin))
- good_bye();
- for(j=0; j<8 ; j++) {
- *cp++ = (t & (0x01 << (7-j))) != 0;
- }
- }
-}
-void
-put8(cp)
-char *cp;
-{
- int i,j,t;
- for(i=0;i<8;i++){
- t = 0;
- for(j = 0; j<8; j++)
- t = (t<<1) | *cp++;
- printf("%02x", t);
- }
-}
diff --git a/test/crypt/sha256c-test.c b/test/crypt/sha256c-test.c
new file mode 100644
index 000000000..357f0d8b7
--- /dev/null
+++ b/test/crypt/sha256c-test.c
@@ -0,0 +1,62 @@
+#include <crypt.h>
+#include <stdio.h>
+#include <string.h>
+
+static const struct
+{
+ const char *salt;
+ const char *input;
+ const char *expected;
+} tests[] =
+{
+ { "$5$saltstring", "Hello world!",
+ "$5$saltstring$5B8vYYiY.CVt1RlTTf8KbXBH3hsxY/GNooZaBBGWEc5" },
+ { "$5$rounds=10000$saltstringsaltstring", "Hello world!",
+ "$5$rounds=10000$saltstringsaltst$3xv.VbSHBb41AL9AvLeujZkZRBAwqFMz2."
+ "opqey6IcA" },
+ { "$5$rounds=5000$toolongsaltstring", "This is just a test",
+ "$5$rounds=5000$toolongsaltstrin$Un/5jzAHMgOGZ5.mWJpuVolil07guHPvOW8"
+ "mGRcvxa5" },
+ { "$5$rounds=1400$anotherlongsaltstring",
+ "a very much longer text to encrypt. This one even stretches over more"
+ "than one line.",
+ "$5$rounds=1400$anotherlongsalts$Rx.j8H.h8HjEDGomFU8bDkXm3XIUnzyxf12"
+ "oP84Bnq1" },
+ { "$5$rounds=77777$short",
+ "we have a short salt string but not a short password",
+ "$5$rounds=77777$short$JiO1O3ZpDAxGJeaDIuqCoEFysAe1mZNJRs3pw0KQRd/" },
+ { "$5$rounds=123456$asaltof16chars..", "a short string",
+ "$5$rounds=123456$asaltof16chars..$gP3VQ/6X7UUEW3HkBn2w1/Ptq2jxPyzV/"
+ "cZKmF/wJvD" },
+ { "$5$rounds=10$roundstoolow", "the minimum number is still observed",
+ "$5$rounds=1000$roundstoolow$yfvwcWrQ8l/K0DAWyuPMDNHpIVlTQebY9l/gL97"
+ "2bIC" },
+};
+#define ntests (sizeof (tests) / sizeof (tests[0]))
+
+
+
+static int
+do_test (void)
+{
+ int result = 0;
+ int i;
+
+ for (i = 0; i < ntests; ++i)
+ {
+ char *cp = crypt (tests[i].input, tests[i].salt);
+
+ if (strcmp (cp, tests[i].expected) != 0)
+ {
+ printf ("test %d: expected \"%s\", got \"%s\"\n",
+ i, tests[i].expected, cp);
+ result = 1;
+ }
+ }
+
+ return result;
+}
+
+#define TIMEOUT 6
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/crypt/sha512c-test.c b/test/crypt/sha512c-test.c
new file mode 100644
index 000000000..c829242e2
--- /dev/null
+++ b/test/crypt/sha512c-test.c
@@ -0,0 +1,63 @@
+#include <crypt.h>
+#include <stdio.h>
+#include <string.h>
+
+static const struct
+{
+ const char *salt;
+ const char *input;
+ const char *expected;
+} tests[] =
+{
+ { "$6$saltstring", "Hello world!",
+ "$6$saltstring$svn8UoSVapNtMuq1ukKS4tPQd8iKwSMHWjl/O817G3uBnIFNjnQJu"
+ "esI68u4OTLiBFdcbYEdFCoEOfaS35inz1" },
+ { "$6$rounds=10000$saltstringsaltstring", "Hello world!",
+ "$6$rounds=10000$saltstringsaltst$OW1/O6BYHV6BcXZu8QVeXbDWra3Oeqh0sb"
+ "HbbMCVNSnCM/UrjmM0Dp8vOuZeHBy/YTBmSK6H9qs/y3RnOaw5v." },
+ { "$6$rounds=5000$toolongsaltstring", "This is just a test",
+ "$6$rounds=5000$toolongsaltstrin$lQ8jolhgVRVhY4b5pZKaysCLi0QBxGoNeKQ"
+ "zQ3glMhwllF7oGDZxUhx1yxdYcz/e1JSbq3y6JMxxl8audkUEm0" },
+ { "$6$rounds=1400$anotherlongsaltstring",
+ "a very much longer text to encrypt. This one even stretches over more"
+ "than one line.",
+ "$6$rounds=1400$anotherlongsalts$POfYwTEok97VWcjxIiSOjiykti.o/pQs.wP"
+ "vMxQ6Fm7I6IoYN3CmLs66x9t0oSwbtEW7o7UmJEiDwGqd8p4ur1" },
+ { "$6$rounds=77777$short",
+ "we have a short salt string but not a short password",
+ "$6$rounds=77777$short$WuQyW2YR.hBNpjjRhpYD/ifIw05xdfeEyQoMxIXbkvr0g"
+ "ge1a1x3yRULJ5CCaUeOxFmtlcGZelFl5CxtgfiAc0" },
+ { "$6$rounds=123456$asaltof16chars..", "a short string",
+ "$6$rounds=123456$asaltof16chars..$BtCwjqMJGx5hrJhZywWvt0RLE8uZ4oPwc"
+ "elCjmw2kSYu.Ec6ycULevoBK25fs2xXgMNrCzIMVcgEJAstJeonj1" },
+ { "$6$rounds=10$roundstoolow", "the minimum number is still observed",
+ "$6$rounds=1000$roundstoolow$kUMsbe306n21p9R.FRkW3IGn.S9NPN0x50YhH1x"
+ "hLsPuWGsUSklZt58jaTfF4ZEQpyUNGc0dqbpBYYBaHHrsX." },
+};
+#define ntests (sizeof (tests) / sizeof (tests[0]))
+
+
+static int
+do_test (void)
+{
+ int result = 0;
+ int i;
+
+ for (i = 0; i < ntests; ++i)
+ {
+ char *cp = crypt (tests[i].input, tests[i].salt);
+
+ if (strcmp (cp, tests[i].expected) != 0)
+ {
+ printf ("test %d: expected \"%s\", got \"%s\"\n",
+ i, tests[i].expected, cp);
+ result = 1;
+ }
+ }
+
+ return result;
+}
+
+#define TIMEOUT 6
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/ctype/Makefile b/test/ctype/Makefile
index d2b7bc5de..99dbdbc9c 100644
--- a/test/ctype/Makefile
+++ b/test/ctype/Makefile
@@ -1,6 +1,8 @@
# uClibc ctype tests
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-TESTS := ctype
-
+top_builddir=../../
+top_srcdir=../../
+include ../Rules.mak
+-include Makefile.in
include ../Test.mak
diff --git a/test/ctype/Makefile.in b/test/ctype/Makefile.in
new file mode 100644
index 000000000..041e85176
--- /dev/null
+++ b/test/ctype/Makefile.in
@@ -0,0 +1,5 @@
+# uClibc ctype tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+TESTS := ctype
+CFLAGS_ctype = -fPIC
diff --git a/test/ctype/ctype.c b/test/ctype/ctype.c
index 352b2d2c8..f38f722b2 100644
--- a/test/ctype/ctype.c
+++ b/test/ctype/ctype.c
@@ -56,6 +56,7 @@ int main( int argc, char **argv)
+#ifdef __UCLIBC_SUSV4_LEGACY__
/* isascii() */
{
int buffer[]={ 'a', 'z', 'A', 'Z', '\n', -1};
@@ -71,6 +72,7 @@ int main( int argc, char **argv)
TEST( isascii(c)==0);
}
}
+#endif
/* iscntrl() */
diff --git a/test/dlopen/Makefile b/test/dlopen/Makefile
index b59c3e2d2..d5be53c6a 100644
--- a/test/dlopen/Makefile
+++ b/test/dlopen/Makefile
@@ -1,40 +1,8 @@
# uClibc dlopen tests
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-# rules need a little love to work with glibc ...
-export UCLIBC_ONLY := 1
-
-TESTS := dltest dltest2 dlstatic test1 test2 test3 dlundef dlafk dladdr
-
+top_builddir=../../
+top_srcdir=../../
+include ../Rules.mak
+-include Makefile.in
include ../Test.mak
-
-CFLAGS_dltest := -DLIBNAME="\"./libtest.so\""
-CFLAGS_dltest2 := -DLIBNAME="\"./libtest3.so\""
-
-LDFLAGS_dlstatic := -ldl
-LDFLAGS_dltest := -ldl -lpthread
-LDFLAGS_dltest2 := -ldl -lpthread
-LDFLAGS_dlundef := -ldl
-LDFLAGS_dlafk := -ldl ./libafk.so -Wl,-rpath,.
-LDFLAGS_test1 := -ldl
-LDFLAGS_test2 := -ldl
-LDFLAGS_test3 := -ldl ./libtest1.so ./libtest2.so -Wl,-rpath,.
-LDFLAGS_dladdr := -ldl
-
-DEBUG_LIBS := X
-WRAPPER := env $(DEBUG_LIBS)=all LD_LIBRARY_PATH="$$PWD:.:$(LD_LIBRARY_PATH)"
-
-dltest: libtest.so
-dltest2: libtest3.so
-dlstatic: libstatic.so
-dlundef: libundef.so
-dlafk: libafk.so
-libafk.so: libafk-temp.so
-LDFLAGS_libafk.so := ./libafk-temp.so -Wl,-rpath,.
-test1: libtest1.so
-test2: libtest1.so libtest2.so
-test3: libtest1.so libtest2.so
-libtest1.so: libtest2.so
-LDFLAGS_libtest1.so := ./libtest2.so -Wl,-rpath,.
-LDFLAGS_libtest2.so := -Wl,-rpath,.
-LDFLAGS_libtest3.so := -lpthread -Wl,-rpath,.
diff --git a/test/dlopen/Makefile.in b/test/dlopen/Makefile.in
new file mode 100644
index 000000000..0bed0f749
--- /dev/null
+++ b/test/dlopen/Makefile.in
@@ -0,0 +1,82 @@
+# uClibc dlopen tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+# rules need a little love to work with glibc ...
+export UCLIBC_ONLY := 1
+
+TESTS := dltest dltest2 dlstatic test1 test2 test3 dlundef dlafk dladdr \
+ testscope nodelete tst-origin
+
+ifneq ($(HAVE_SHARED),y)
+TESTS_DISABLED := test3
+LDFLAGS_libtest.so := -lpthread
+endif
+
+CFLAGS_dltest := -DLIBNAME="\"./libtest.so\""
+CFLAGS_dltest2 := -DLIBNAME="\"./libtest3.so\""
+
+LDFLAGS_dlstatic := -ldl
+LDFLAGS_dltest := -ldl
+LDFLAGS_dltest2 := -ldl
+LDFLAGS_dlundef := -ldl
+LDFLAGS_dlafk := -ldl ./libafk.so -Wl,-rpath,.
+LDFLAGS_test1 := -ldl
+LDFLAGS_test2 := -ldl
+LDFLAGS_test3 := -ldl ./libtest1.so ./libtest2.so -Wl,-rpath,.
+LDFLAGS_dladdr := -ldl
+LDFLAGS_testscope:= -ldl
+LDFLAGS_tst-origin:= -ldl -Wl,-rpath,\$$ORIGIN/testlib
+
+DEBUG_LIBS := X
+WRAPPER := env $(DEBUG_LIBS)=all LD_LIBRARY_PATH="$$PWD:.:$(LD_LIBRARY_PATH)"
+
+testlib:
+ @mkdir $@
+
+testlib/libtest31.so: libtest3.so | testlib
+ @cp $^ $@
+
+EXTRA_DIRS := testlib
+
+# Build libC.so without -mprefergot compilation flag to force a
+# R_SH_JMP_SLOT relocation instead of R_SH_GLOB_DAT for _libC_fini. This is
+# needed to resolve the _libC_fini symbol when used (by libC.so destructor),
+# whereas with GLOB_DAT relocation the resolution happens in the GOT entry
+# when the libC is loaded, for the same reason remove also the "-z now"
+# linker flag.
+# These are needed to spot the issue test case want raise.
+
+ifeq ($(TARGET_ARCH),sh)
+CFLAGS-OMIT-libC.c = -mprefergot
+endif
+LDFLAGS-OMIT-libC.c = -Wl,-z,now
+
+dltest: libtest.so
+dltest2: libtest3.so
+dlstatic: libstatic.so
+dlundef: libundef.so
+dlafk: libafk.so
+testscope:libA.so
+libafk.so: libafk-temp.so
+LDFLAGS_libafk.so := ./libafk-temp.so -Wl,-rpath,.
+test1: libtest1.so
+test2: libtest1.so libtest2.so
+test3: libtest1.so libtest2.so
+tst-origin: testlib/libtest31.so
+libtest1.so: libtest2.so
+libB.so: libC.so
+libA.so: libB.so
+LDFLAGS_libtest.so := -lpthread
+LDFLAGS_libtest1.so := ./libtest2.so -Wl,-rpath,.
+LDFLAGS_libtest2.so := -Wl,-rpath,.
+LDFLAGS_libtest3.so := -lpthread -Wl,-rpath,.
+LDFLAGS_libC.so := -ldl
+LDFLAGS_libB.so := ./libC.so -Wl,-rpath,.
+LDFLAGS_libA.so := ./libB.so -Wl,-rpath,.
+
+nodelete: nodelmod1.so nodelmod2.so nodelmod3.so
+nodelmod3.so: nodelmod4.so
+LDFLAGS_nodelete := -rdynamic -ldl
+LDFLAGS_nodelmod1.so := -Wl,-z,nodelete
+LDFLAGS_nodelmod3.so := ./nodelmod4.so
+LDFLAGS_nodelmod4.so := -Wl,-z,nodelete
diff --git a/test/dlopen/dltest.c b/test/dlopen/dltest.c
index 6bec6e00e..b5fa1cdd7 100644
--- a/test/dlopen/dltest.c
+++ b/test/dlopen/dltest.c
@@ -25,7 +25,7 @@ int main(int argc, char **argv)
}
mydltest(&value1, &value2);
- printf("dltest: __pthread_once=%p\n", value1);
+ printf("dltest: pthread_once=%p\n", value1);
printf("dltest: pthread_self=%p\n", value2);
if (value1 == value2) {
ret = EXIT_FAILURE;
diff --git a/test/dlopen/libA.c b/test/dlopen/libA.c
new file mode 100644
index 000000000..13b83dcec
--- /dev/null
+++ b/test/dlopen/libA.c
@@ -0,0 +1,7 @@
+extern void libB_func(void);
+
+void libA_func(void);
+void libA_func(void)
+{
+ libB_func();
+}
diff --git a/test/dlopen/libB.c b/test/dlopen/libB.c
new file mode 100644
index 000000000..9b9fff41c
--- /dev/null
+++ b/test/dlopen/libB.c
@@ -0,0 +1,7 @@
+extern void libC_func(void);
+
+void libB_func(void);
+void libB_func(void)
+{
+ libC_func();
+}
diff --git a/test/dlopen/libC.c b/test/dlopen/libC.c
new file mode 100644
index 000000000..84cbbef3d
--- /dev/null
+++ b/test/dlopen/libC.c
@@ -0,0 +1,30 @@
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define LIBNAME "libB.so"
+void _libC_fini(void);
+void _libC_fini(void)
+{
+ printf("libC_fini():finish - atexit()\n");
+}
+
+void libC_fini(void);
+void libC_fini(void)
+{
+ _libC_fini();
+}
+
+void libC_func(void);
+void libC_func(void)
+{
+ void *libB;
+
+ libB = dlopen(LIBNAME, RTLD_LAZY);
+ if (!libB) {
+ fprintf(stderr, "Could not open ./%s: %s\n", LIBNAME, dlerror());
+ exit(1);
+ }
+
+ atexit(libC_fini);
+}
diff --git a/test/dlopen/libtest.c b/test/dlopen/libtest.c
index a306e4bf7..3fd137f06 100644
--- a/test/dlopen/libtest.c
+++ b/test/dlopen/libtest.c
@@ -2,12 +2,10 @@
#include <pthread.h>
#include <stdint.h>
-extern int __pthread_once(void);
-
void dltest(uint32_t **value1, uint32_t **value2);
void dltest(uint32_t **value1, uint32_t **value2)
{
- *value1 = (uint32_t *) __pthread_once;
+ *value1 = (uint32_t *) pthread_once;
*value2 = (uint32_t *) pthread_self;
}
diff --git a/test/dlopen/nodelete.c b/test/dlopen/nodelete.c
new file mode 100644
index 000000000..07ff96136
--- /dev/null
+++ b/test/dlopen/nodelete.c
@@ -0,0 +1,205 @@
+#include <dlfcn.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static sigjmp_buf jmpbuf;
+
+
+int fini_ran;
+
+
+static void
+__attribute__ ((noreturn))
+handler (int sig)
+{
+ siglongjmp (jmpbuf, 1);
+}
+
+
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+ /* We are testing the two possibilities to mark an object as not deletable:
+ - marked on the linker commandline with `-z nodelete'
+ - with the RTLD_NODELETE flag at dlopen()-time.
+
+ The test we are performing should be safe. We are loading the objects,
+ get the address of variables in the respective object, unload the object
+ and then try to read the variable. If the object is unloaded this
+ should lead to an segmentation fault. */
+ void *p;
+ struct sigaction sa;
+
+ sa.sa_handler = handler;
+ sigfillset (&sa.sa_mask);
+ sa.sa_flags = SA_RESTART;
+
+ if (sigaction (SIGSEGV, &sa, NULL) == -1)
+ puts ("cannot install signal handler: %m");
+
+ p = dlopen ("nodelmod1.so", RTLD_LAZY);
+ if (p == NULL)
+ {
+ printf ("failed to load \"nodelmod1.so\": %s\n", dlerror ());
+ exit (1);
+ }
+ else
+ {
+ int *varp;
+
+ varp = dlsym (p, "var1");
+ if (varp == NULL)
+ {
+ puts ("failed to get address of \"var1\" in \"nodelmod1.so\"");
+ exit (1);
+ }
+ else
+ {
+ *varp = 20000720;
+
+ /* Now close the object. */
+ fini_ran = 0;
+ if (dlclose (p) != 0)
+ {
+ puts ("failed to close \"nodelmod1.so\"");
+ exit (1);
+ }
+ else if (! sigsetjmp (jmpbuf, 1))
+ {
+ /* Access the variable again. */
+ if (*varp != 20000720)
+ {
+ puts ("\"var1\" value not correct");
+ exit (1);
+ }
+ else if (fini_ran != 0)
+ {
+ puts ("destructor of \"nodelmod1.so\" ran");
+ exit (1);
+ }
+ else
+ puts ("-z nodelete test succeeded");
+ }
+ else
+ {
+ /* We caught an segmentation fault. */
+ puts ("\"nodelmod1.so\" got deleted!");
+ exit (1);
+ }
+ }
+ }
+
+ p = dlopen ("nodelmod2.so", RTLD_LAZY | RTLD_NODELETE);
+ if (p == NULL)
+ {
+ printf ("failed to load \"nodelmod2.so\": %s\n", dlerror ());
+ exit (1);
+ }
+ else
+ {
+ int *varp;
+
+ varp = dlsym (p, "var2");
+ if (varp == NULL)
+ {
+ puts ("failed to get address of \"var2\" in \"nodelmod2.so\"");
+ exit (1);
+ }
+ else
+ {
+ *varp = 42;
+
+ /* Now close the object. */
+ fini_ran = 0;
+ if (dlclose (p) != 0)
+ {
+ puts ("failed to close \"nodelmod2.so\"");
+ exit (1);
+ }
+ else if (! sigsetjmp (jmpbuf, 1))
+ {
+ /* Access the variable again. */
+ if (*varp != 42)
+ {
+ puts ("\"var2\" value not correct");
+ exit (1);
+ }
+ else if (fini_ran != 0)
+ {
+ puts ("destructor of \"nodelmod2.so\" ran");
+ exit (1);
+ }
+ else
+ puts ("RTLD_NODELETE test succeeded");
+ }
+ else
+ {
+ /* We caught an segmentation fault. */
+ puts ("\"nodelmod2.so\" got deleted!");
+ exit (1);
+ }
+ }
+ }
+
+ p = dlopen ("nodelmod3.so", RTLD_LAZY);
+ if (p == NULL)
+ {
+ printf ("failed to load \"nodelmod3.so\": %s\n", dlerror ());
+ exit (1);
+ }
+ else
+ {
+ int *(*fctp) (void);
+
+ fctp = dlsym (p, "addr");
+ if (fctp == NULL)
+ {
+ puts ("failed to get address of \"addr\" in \"nodelmod3.so\"");
+ exit (1);
+ }
+ else
+ {
+ int *varp = fctp ();
+
+ *varp = -1;
+
+ /* Now close the object. */
+ fini_ran = 0;
+ if (dlclose (p) != 0)
+ {
+ puts ("failed to close \"nodelmod3.so\"");
+ exit (1);
+ }
+ else if (! sigsetjmp (jmpbuf, 1))
+ {
+ /* Access the variable again. */
+ if (*varp != -1)
+ {
+ puts ("\"var_in_mod4\" value not correct");
+ exit (1);
+ }
+ else if (fini_ran != 0)
+ {
+ puts ("destructor of \"nodelmod4.so\" ran");
+ exit (1);
+ }
+ else
+ puts ("-z nodelete in dependency succeeded");
+ }
+ else
+ {
+ /* We caught an segmentation fault. */
+ puts ("\"nodelmod4.so\" got deleted!");
+ exit (1);
+ }
+ }
+ }
+
+ return 0;
+}
+
+#include "../test-skeleton.c"
diff --git a/test/dlopen/nodelmod1.c b/test/dlopen/nodelmod1.c
new file mode 100644
index 000000000..51be080af
--- /dev/null
+++ b/test/dlopen/nodelmod1.c
@@ -0,0 +1,10 @@
+extern int fini_ran;
+
+int var1 = 42;
+
+static void
+__attribute__ ((__destructor__))
+destr (void)
+{
+ fini_ran = 1;
+}
diff --git a/test/dlopen/nodelmod2.c b/test/dlopen/nodelmod2.c
new file mode 100644
index 000000000..ff2ffc2fc
--- /dev/null
+++ b/test/dlopen/nodelmod2.c
@@ -0,0 +1,10 @@
+extern int fini_ran;
+
+int var2 = 100;
+
+static void
+__attribute__ ((__destructor__))
+destr (void)
+{
+ fini_ran = 1;
+}
diff --git a/test/dlopen/nodelmod3.c b/test/dlopen/nodelmod3.c
new file mode 100644
index 000000000..817c94db6
--- /dev/null
+++ b/test/dlopen/nodelmod3.c
@@ -0,0 +1,8 @@
+extern int var_in_mod4;
+extern int *addr (void);
+
+int *
+addr (void)
+{
+ return &var_in_mod4;
+}
diff --git a/test/dlopen/nodelmod4.c b/test/dlopen/nodelmod4.c
new file mode 100644
index 000000000..d7fa89396
--- /dev/null
+++ b/test/dlopen/nodelmod4.c
@@ -0,0 +1,10 @@
+extern int fini_ran;
+
+int var_in_mod4 = 99;
+
+static void
+__attribute__ ((__destructor__))
+destr (void)
+{
+ fini_ran = 1;
+}
diff --git a/test/dlopen/testscope.c b/test/dlopen/testscope.c
new file mode 100644
index 000000000..90e079885
--- /dev/null
+++ b/test/dlopen/testscope.c
@@ -0,0 +1,29 @@
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define LIBNAME "libA.so"
+int main(int argc, char **argv)
+{
+ void *libA;
+ void (*libAfn)(void);
+ char *error;
+
+ libA = dlopen(LIBNAME, RTLD_LAZY);
+ if (!libA) {
+ fprintf(stderr, "Could not open ./%s: %s\n", LIBNAME, dlerror());
+ exit(1);
+ }
+
+ libAfn = dlsym(libA, "libA_func");
+ if ((error = dlerror()) != NULL) {
+ fprintf(stderr, "Could not locate symbol 'libA_func': %s\n", error);
+ exit(1);
+ }
+
+ libAfn();
+
+ dlclose(libA);
+
+ return EXIT_SUCCESS;
+}
diff --git a/test/dlopen/tst-origin.c b/test/dlopen/tst-origin.c
new file mode 100644
index 000000000..a12be415b
--- /dev/null
+++ b/test/dlopen/tst-origin.c
@@ -0,0 +1,37 @@
+#include <fcntl.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <dlfcn.h>
+
+#ifdef __UCLIBC__
+extern void _dlinfo(void);
+#endif
+
+int main(int argc, char **argv) {
+ void *h1, *h2;
+ int (*mydltest)(const char *s);
+ char *error;
+
+ h1 = dlopen ("libtest31.so", RTLD_LAZY);
+ if (!h1) {
+ fprintf(stderr, "Could not open libtest31.so: %s\n", dlerror());
+ exit(1);
+ }
+
+ h2 = dlopen ("libtest31.so", RTLD_NOLOAD);
+ if (!h2) {
+ fprintf(stderr, "Could not open libtest31.so(RTLD_NOLOAD): %s\n", dlerror());
+ exit(1);
+ }
+
+ mydltest = dlsym(h1, "dltest");
+ if ((error = dlerror()) != NULL) {
+ fprintf(stderr, "Could not locate symbol 'dltest': %s\n", error);
+ exit(1);
+ }
+
+ dlclose(h2);
+ dlclose(h1);
+
+ return EXIT_SUCCESS;
+}
diff --git a/test/inet/Makefile b/test/inet/Makefile
index 91927e42e..b294ea6b5 100644
--- a/test/inet/Makefile
+++ b/test/inet/Makefile
@@ -1,4 +1,8 @@
# uClibc inet tests
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+top_builddir=../../
+top_srcdir=../../
+include ../Rules.mak
+-include Makefile.in
include ../Test.mak
diff --git a/test/inet/Makefile.in b/test/inet/Makefile.in
new file mode 100644
index 000000000..1cede4761
--- /dev/null
+++ b/test/inet/Makefile.in
@@ -0,0 +1,21 @@
+# uClibc inet tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+ifeq ($(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6),)
+TESTS_DISABLED := bug-if1 gethost_r-align gethostid if_nameindex tst-aton \
+ tst-network tst-ntoa test-ifaddrs
+endif
+
+ifeq ($(UCLIBC_HAS_SOCKET)$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6),)
+TESTS_DISABLED += tst-ether_aton tst-ethers tst-ethers-line
+endif
+
+ifeq ($(UCLIBC_HAS_RESOLVER_SUPPORT),)
+TESTS_DISABLED += tst-res
+else
+LDFLAGS_tst-res_glibc := -lresolv # assume it's glibc or somebody with that lib
+endif
+
+CFLAGS_bug-if1 = -fPIC
+CFLAGS_tst-sock-nonblock = -fPIC
+CFLAGS_tst-ifaddrs = -fPIC
diff --git a/test/inet/bug-if1.c b/test/inet/bug-if1.c
index 6bcd175eb..ea84a6850 100644
--- a/test/inet/bug-if1.c
+++ b/test/inet/bug-if1.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 <limits.h>
diff --git a/test/inet/gethost.c b/test/inet/gethost.c
new file mode 100644
index 000000000..77467e9e3
--- /dev/null
+++ b/test/inet/gethost.c
@@ -0,0 +1,40 @@
+#include <errno.h>
+#include <netdb.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <arpa/inet.h>
+#include <sys/socket.h>
+
+int main(void)
+{
+ in_addr_t addr = inet_addr("127.0.0.1");
+ struct hostent *hent;
+
+ hent = gethostent();
+ if (hent == NULL) {
+ printf("gethostent(%d):%s\n", errno, hstrerror(h_errno));
+ exit(1);
+ }
+
+ hent = gethostbyname("localhost");
+ if (hent == NULL) {
+ printf("gethostbyname(%d):%s\n", errno, hstrerror(h_errno));
+ exit(1);
+ }
+
+ hent = gethostbyname2("localhost", AF_INET);
+ if (hent == NULL) {
+ printf("gethostbyname2(%d):%s\n", errno, hstrerror(h_errno));
+ exit(1);
+ }
+
+ hent = gethostbyaddr(&addr, sizeof(addr), AF_INET);
+ if (hent == NULL) {
+ printf("gethostbyaddr(%d):%s\n", errno, hstrerror(h_errno));
+ exit(1);
+ }
+
+ return 0;
+}
+
diff --git a/test/inet/gethostid.c b/test/inet/gethostid.c
new file mode 100644
index 000000000..1b9af86b7
--- /dev/null
+++ b/test/inet/gethostid.c
@@ -0,0 +1,6 @@
+#include <unistd.h>
+#include <stdio.h>
+int main(void) {
+ printf("hostid=%ld\n", gethostid());
+ return 0;
+}
diff --git a/test/inet/getnetent.c b/test/inet/getnetent.c
new file mode 100644
index 000000000..1f55e4388
--- /dev/null
+++ b/test/inet/getnetent.c
@@ -0,0 +1,17 @@
+#include <stdio.h>
+#include <netdb.h>
+int main(void)
+{
+ struct netent *net;
+ setnetent(0);
+ while ((net = getnetent())) {
+ while (net->n_net && !((net->n_net >> 24) & 0xff)) {
+ net->n_net <<= 8;
+ }
+ printf("%u.%u.%u.%u\n",
+ (net->n_net >> 24) & 0xff, (net->n_net >> 16) & 0xff,
+ (net->n_net >> 8) & 0xff, net->n_net & 0xff);
+ }
+ endnetent();
+ return 0;
+}
diff --git a/test/inet/tst-ether_aton.c b/test/inet/tst-ether_aton.c
new file mode 100644
index 000000000..67cb43540
--- /dev/null
+++ b/test/inet/tst-ether_aton.c
@@ -0,0 +1,46 @@
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <netinet/ether.h>
+
+static struct tests
+{
+ const char *input;
+ int valid;
+ uint8_t result[6];
+} tests[] =
+{
+ { "", 0, {0, 0, 0, 0, 0, 0} },
+ { "AB:CD:EF:01:23:45", 1, {171, 205, 239, 1, 35, 69} },
+ { "\022B:BB:BB:BB:BB:BB", 0, {0, 0, 0, 0, 0, 0} }
+};
+
+
+int
+main (int argc, char *argv[])
+{
+ int result = 0;
+ size_t cnt;
+
+ for (cnt = 0; cnt < sizeof (tests) / sizeof (tests[0]); ++cnt)
+ {
+ struct ether_addr *addr;
+
+ if (!!(addr = ether_aton (tests[cnt].input)) != tests[cnt].valid)
+ {
+ if (tests[cnt].valid)
+ printf ("\"%s\" not seen as valid MAC address\n", tests[cnt].input);
+ else
+ printf ("\"%s\" seen as valid MAC address\n", tests[cnt].input);
+ result = 1;
+ }
+ else if (tests[cnt].valid
+ && memcmp(addr, &tests[cnt].result, sizeof(struct ether_addr)))
+ {
+ printf ("\"%s\" not converted correctly\n", tests[cnt].input);
+ result = 1;
+ }
+ }
+
+ return result;
+}
diff --git a/test/inet/tst-ifaddrs.c b/test/inet/tst-ifaddrs.c
new file mode 100644
index 000000000..6e6c01570
--- /dev/null
+++ b/test/inet/tst-ifaddrs.c
@@ -0,0 +1,99 @@
+/* Test listing of network interface addresses.
+ Copyright (C) 2002-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 <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ifaddrs.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+static int failures;
+
+static const char *
+addr_string (struct sockaddr *sa, char *buf, size_t size)
+{
+ if (sa == NULL)
+ return "<none>";
+
+ switch (sa->sa_family)
+ {
+ case AF_INET:
+ return inet_ntop (AF_INET, &((struct sockaddr_in *) sa)->sin_addr,
+ buf, size);
+ case AF_INET6:
+ return inet_ntop (AF_INET6, &((struct sockaddr_in6 *) sa)->sin6_addr,
+ buf, size);
+#ifdef AF_LINK
+ case AF_LINK:
+ return "<link>";
+#endif
+ case AF_UNSPEC:
+ return "---";
+
+#ifdef AF_PACKET
+ case AF_PACKET:
+ return "<packet>";
+#endif
+
+ default:
+ ++failures;
+ printf ("sa_family=%d %08x\n", sa->sa_family,
+ *(int*)&((struct sockaddr_in *) sa)->sin_addr.s_addr);
+ return "<unexpected sockaddr family>";
+ }
+}
+
+
+static int
+do_test (void)
+{
+ struct ifaddrs *ifaces, *ifa;
+
+ if (getifaddrs (&ifaces) < 0)
+ {
+ if (errno != ENOSYS)
+ {
+ printf ("Couldn't get any interfaces: %s.\n", strerror (errno));
+ exit (1);
+ }
+ /* The function is simply not implemented. */
+ exit (0);
+ }
+
+ puts ("\
+Name Flags Address Netmask Broadcast/Destination");
+
+ for (ifa = ifaces; ifa != NULL; ifa = ifa->ifa_next)
+ {
+ char abuf[64], mbuf[64], dbuf[64];
+ printf ("%-15s%#.4x %-15s %-15s %-15s\n",
+ ifa->ifa_name, ifa->ifa_flags,
+ addr_string (ifa->ifa_addr, abuf, sizeof (abuf)),
+ addr_string (ifa->ifa_netmask, mbuf, sizeof (mbuf)),
+ addr_string (ifa->ifa_broadaddr, dbuf, sizeof (dbuf)));
+ }
+
+ freeifaddrs (ifaces);
+
+ return failures ? 1 : 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/inet/tst-network.c b/test/inet/tst-network.c
index 259863733..c6089aa6c 100644
--- a/test/inet/tst-network.c
+++ b/test/inet/tst-network.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/>. */
#include <stdio.h>
#include <sys/socket.h>
diff --git a/test/inet/tst-res.c b/test/inet/tst-res.c
new file mode 100644
index 000000000..b65f30fd6
--- /dev/null
+++ b/test/inet/tst-res.c
@@ -0,0 +1,44 @@
+#include <stdlib.h>
+#include <assert.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <arpa/nameser.h>
+#include <resolv.h>
+#include <netdb.h>
+
+int main(int argc, char **argv)
+{
+ int r;
+ struct __res_state state;
+
+ r = res_ninit(&state);
+ if (r) {
+ herror("ninit");
+ abort();
+ }
+ r = res_init();
+ if (r) {
+ herror("init");
+ abort();
+ }
+
+#ifdef __UCLIBC_HAS_BSD_RES_CLOSE__
+ res_close();
+#endif
+#ifdef __UCLIBC__
+ /* assume there is at least one resolver configured */
+ assert (state._u._ext.nscount > 0);
+#else
+ assert (state._u._ext.nscount == 0);
+#endif
+ assert (state.options & RES_INIT);
+ res_nclose(&state);
+#ifdef __UCLIBC__
+ /* We wipe the whole thing */
+ assert ((state.options & RES_INIT) == 0);
+#endif
+ assert (state._u._ext.nscount == 0);
+
+ return 0;
+}
+
diff --git a/test/inet/tst-sock-nonblock.c b/test/inet/tst-sock-nonblock.c
new file mode 100644
index 000000000..54a7ee28a
--- /dev/null
+++ b/test/inet/tst-sock-nonblock.c
@@ -0,0 +1,53 @@
+/* vi: set sw=4 ts=4 sts=4: */
+/*
+ * Nonblocking socket test for uClibc
+ * Copyright (C) 2012 by Kevin Cernekee <cernekee@gmail.com>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+#include <error.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <sys/fcntl.h>
+
+static int
+do_test(void)
+{
+ int fd, ret, result = 0;
+ struct sockaddr_un sa;
+ char buf;
+
+ fd = socket(AF_UNIX, SOCK_DGRAM | SOCK_NONBLOCK, 0);
+ if (fd < 0) {
+ perror("socket()");
+ result = 1;
+ }
+
+ memset(&sa, 0, sizeof(sa));
+ sa.sun_family = AF_UNIX;
+ strcpy(sa.sun_path, "socktest");
+ unlink("socktest");
+ if (bind(fd, (const struct sockaddr *)&sa, sizeof(sa)) < 0) {
+ perror("bind()");
+ result = 1;
+ }
+
+ ret = read(fd, &buf, sizeof(buf));
+ if (ret != -1 || errno != EAGAIN) {
+ error(0, 0, "Nonblocking read returned %d", ret);
+ result = 1;
+ }
+
+ return result;
+}
+
+#define TIMEOUT 5
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/librt/Makefile b/test/librt/Makefile
new file mode 100644
index 000000000..1021afe9c
--- /dev/null
+++ b/test/librt/Makefile
@@ -0,0 +1,8 @@
+# uClibc shm tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+top_builddir=../../
+top_srcdir=../../
+include ../Rules.mak
+-include Makefile.in
+include ../Test.mak
diff --git a/test/librt/Makefile.in b/test/librt/Makefile.in
new file mode 100644
index 000000000..f25522cbe
--- /dev/null
+++ b/test/librt/Makefile.in
@@ -0,0 +1,8 @@
+# uClibc shm tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+LDFLAGS_shmtest := -lrt
+
+ifeq ($(ARCH_USE_MMU),)
+TESTS_DISABLED := shmtest
+endif
diff --git a/test/librt/shmtest.c b/test/librt/shmtest.c
new file mode 100644
index 000000000..a14302d09
--- /dev/null
+++ b/test/librt/shmtest.c
@@ -0,0 +1,104 @@
+/* Copyright (C) 2009 Mikael Lund Jepsen <mlj@iccc.dk>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+
+char shared_name[] = "/sharetest";
+int test_data[11] = {0,1,2,3,4,5,6,7,8,9,10};
+
+int main(void) {
+ int pfds[2];
+ pid_t pid;
+ int fd;
+ int test_data_fails = 0;
+ char *ptest_data;
+ unsigned int i;
+ char buf[30];
+ int rv;
+
+ pipe(pfds);
+
+ switch(pid = fork()) {
+ case -1:
+ perror("fork");
+ exit(1); /* parent exits */
+
+ case 0:
+ /* Child */
+
+ /* wait for parent */
+ read(pfds[0], buf, 5);
+
+ fd = shm_open(shared_name, O_RDWR, DEFFILEMODE);
+ if (fd == -1) {
+ perror("CHILD - shm_open(existing):");
+ exit(1);
+ } else {
+ ptest_data = mmap(0, sizeof(test_data), PROT_READ + PROT_WRITE, MAP_SHARED, fd, 0);
+ if (ptest_data != MAP_FAILED) {
+ for (i=0; i < ARRAY_SIZE(test_data); i++) {
+ if (ptest_data[i] != test_data[i]) {
+ printf("%-40s: Offset %d, local %d, shm %d\n", "Compare memory error", i, test_data[i], ptest_data[i]);
+ test_data_fails++;
+ }
+ }
+ if (test_data_fails == 0)
+ printf("%-40s: %s\n", "Compare memory", "Success");
+
+ munmap(ptest_data, sizeof(test_data));
+ }
+ }
+ exit(0);
+
+ default:
+ /* Parent */
+ fd = shm_open(shared_name, O_RDWR+O_CREAT+O_EXCL, DEFFILEMODE );
+ if (fd == -1) {
+ perror("PARENT - shm_open(create):");
+ } else {
+ if ((ftruncate(fd, sizeof(test_data))) == -1)
+ {
+ printf("%-40s: %s", "ftruncate", strerror(errno));
+ shm_unlink(shared_name);
+ return 0;
+ }
+
+ ptest_data = mmap(0, sizeof(test_data), PROT_READ + PROT_WRITE, MAP_SHARED, fd, 0);
+ if (ptest_data == MAP_FAILED)
+ {
+ perror("PARENT - mmap:");
+ if (shm_unlink(shared_name) == -1) {
+ perror("PARENT - shm_unlink:");
+ }
+ return 0;
+ }
+ for (i=0; i < ARRAY_SIZE(test_data); i++)
+ ptest_data[i] = test_data[i];
+
+ /* signal child */
+ write(pfds[1], "rdy", 5);
+ /* wait for child */
+ wait(&rv);
+
+ /* Cleanup */
+ munmap(ptest_data, sizeof(test_data));
+ if (shm_unlink(shared_name) == -1) {
+ perror("PARENT - shm_unlink:");
+ }
+ }
+ }
+ return 0;
+}
diff --git a/test/locale-mbwc/Makefile b/test/locale-mbwc/Makefile
index 8f5a2dba8..263f325b9 100644
--- a/test/locale-mbwc/Makefile
+++ b/test/locale-mbwc/Makefile
@@ -1,29 +1,8 @@
# uClibc locale tests
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-# tst_mbtowc tst_strcoll tst_strfmon tst_strxfrm \
-
-TESTS := tst_iswalnum tst_iswalpha tst_iswcntrl \
- tst_iswctype tst_iswdigit tst_iswgraph \
- tst_iswlower tst_iswprint tst_iswpunct \
- tst_iswspace tst_iswupper tst_iswxdigit \
- tst_mblen tst_mbrlen tst_mbrtowc tst_mbsrtowcs \
- tst_mbstowcs tst_mbtowc tst_strcoll tst_strxfrm \
- tst_swscanf tst_towctrans tst_towlower \
- tst_towupper tst_wcrtomb tst_wcscat tst_wcschr \
- tst_wcscmp tst_wcscoll tst_wcscpy tst_wcscspn \
- tst_wcslen tst_wcsncat tst_wcsncmp tst_wcsncpy \
- tst_wcspbrk tst_wcsrtombs tst_wcsspn tst_wcsstr \
- tst_wcstod tst_wcstok tst_wcstombs tst_wcswidth \
- tst_wcsxfrm tst_wctob tst_wctomb tst_wctrans \
- tst_wctype tst_wcwidth tst_strfmon
-
-
-# NOTE: For now disabled tst_strfmon to avoid build failure.
-TESTS_DISABLED := tst_strfmon
+top_builddir=../../
+top_srcdir=../../
+include ../Rules.mak
+-include Makefile.in
include ../Test.mak
-
-DODIFF_rint := 1
-
-EXTRA_CFLAGS := -D__USE_GNU -fno-builtin
-
diff --git a/test/locale-mbwc/Makefile.in b/test/locale-mbwc/Makefile.in
new file mode 100644
index 000000000..d6a84f234
--- /dev/null
+++ b/test/locale-mbwc/Makefile.in
@@ -0,0 +1,31 @@
+# uClibc locale tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+# tst_mbtowc tst_strcoll tst_strfmon tst_strxfrm \
+
+TESTS := tst_iswalnum tst_iswalpha tst_iswcntrl \
+ tst_iswctype tst_iswdigit tst_iswgraph \
+ tst_iswlower tst_iswprint tst_iswpunct \
+ tst_iswspace tst_iswupper tst_iswxdigit \
+ tst_mblen tst_mbrlen tst_mbrtowc tst_mbsrtowcs \
+ tst_mbstowcs tst_mbtowc tst_strcoll tst_strxfrm \
+ tst_swscanf tst_towctrans tst_towlower \
+ tst_towupper tst_wcrtomb tst_wcscat tst_wcschr \
+ tst_wcscmp tst_wcscoll tst_wcscpy tst_wcscspn \
+ tst_wcslen tst_wcsncat tst_wcsncmp tst_wcsncpy \
+ tst_wcspbrk tst_wcsrtombs tst_wcsspn tst_wcsstr \
+ tst_wcstod tst_wcstok tst_wcstombs tst_wcswidth \
+ tst_wcsxfrm tst_wctob tst_wctomb tst_wctrans \
+ tst_wctype tst_wcwidth tst_strfmon \
+ tst2_mbrtowc
+
+# NOTE: For now disabled tst_strfmon to avoid build failure.
+TESTS_DISABLED := tst_strfmon
+
+ifneq ($(UCLIBC_HAS_FLOATS),y)
+TESTS_DISABLED += tst_swscanf tst_wcstod
+endif
+
+DODIFF_rint := 1
+
+EXTRA_CFLAGS := -D__USE_GNU -fno-builtin -fPIC
+
diff --git a/test/locale-mbwc/dat_iswctype.c b/test/locale-mbwc/dat_iswctype.c
index 6448b328f..0dcf1824e 100644
--- a/test/locale-mbwc/dat_iswctype.c
+++ b/test/locale-mbwc/dat_iswctype.c
@@ -240,7 +240,7 @@ TST_ISWCTYPE tst_iswctype_loc [] = {
{ { 0x007B, "cntrl" }, { 0,1,0 } },
{ { 0x007E, "cntrl" }, { 0,1,0 } },
{ { 0x007F, "cntrl" }, { 0,0,0 } },
- { { 0x0080, "cntrl" }, { 0,0,0 } },
+ { { 0x0080, "cntrl" }, { 0,1,0 } },
{ { 0x0000, "digit" }, { 0,1,0 } },
{ { 0x001F, "digit" }, { 0,1,0 } },
{ { 0x0020, "digit" }, { 0,1,0 } },
diff --git a/test/locale-mbwc/tst2_mbrtowc.c b/test/locale-mbwc/tst2_mbrtowc.c
new file mode 100644
index 000000000..92e12838c
--- /dev/null
+++ b/test/locale-mbwc/tst2_mbrtowc.c
@@ -0,0 +1,21 @@
+#include <wchar.h>
+#include <assert.h>
+#include <stdlib.h>
+
+/* bugs.uclibc.org/1471 : make sure output is 0 */
+static int
+do_test(void)
+{
+ wchar_t output;
+ int result;
+
+ output = L'A'; /* anything other than 0 will do... */
+ result = mbrtowc (&output, "", 1, 0);
+
+ assert (result == 0);
+ assert (output == 0);
+
+ return EXIT_SUCCESS;
+}
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/locale-mbwc/tst_funcs.h b/test/locale-mbwc/tst_funcs.h
index 552bed2f9..4bd0fb1ab 100644
--- a/test/locale-mbwc/tst_funcs.h
+++ b/test/locale-mbwc/tst_funcs.h
@@ -95,6 +95,7 @@ extern int result (FILE * fp, char res, const char *func, const char *loc,
for (loc = 0; strcmp (TST_HEAD (o_func).locale, TST_LOC_end); ++loc)
+#ifdef __UCLIBC_HAS_LOCALE__
#define TST_HEAD_LOCALE(ofunc, s_func) \
func_id = TST_HEAD (ofunc).func_id; \
locale = TST_HEAD (ofunc).locale; \
@@ -106,6 +107,29 @@ extern int result (FILE * fp, char res, const char *func, const char *loc,
++err_count; \
continue; \
}
+#else
+#define TST_HEAD_LOCALE(ofunc, s_func) \
+ func_id = TST_HEAD (ofunc).func_id; \
+ locale = TST_HEAD (ofunc).locale; \
+ if (strcmp(locale, "C") == 0) \
+ { \
+ if (setlocale (LC_ALL, locale) == NULL) \
+ { \
+ fprintf (stderr, "Warning : can't set locale: %s\nskipping ...\n", \
+ locale); \
+ result (fp, C_LOCALES, s_func, locale, 0, 0, 0, "can't set locale"); \
+ ++err_count; \
+ continue; \
+ } \
+ } \
+ else \
+ { \
+ fprintf (stderr, "Warning : locale %s unsupported\n\n", \
+ locale); \
+ result (fp, C_LOCALES, s_func, locale, 0, 0, 0, "unsupported"); \
+ continue; \
+ }
+#endif
#define TST_DO_REC(ofunc) \
for (rec=0; !TST_IS_LAST (ofunc); ++rec)
diff --git a/test/locale/Makefile b/test/locale/Makefile
index 0ab07f7aa..263f325b9 100644
--- a/test/locale/Makefile
+++ b/test/locale/Makefile
@@ -1,31 +1,8 @@
# uClibc locale tests
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-# tst_mbtowc tst_strcoll tst_strfmon tst_strxfrm \
-
-TESTS := bug-iconv-trans bug-usesetlocale collate-test dump-ctype \
- gen-unicode-ctype show-ucs-data tst-ctype \
- tst-digits tst-fmon tst-langinfo tst-leaks tst-mbswcs1 \
- tst-mbswcs2 tst-mbswcs3 tst-mbswcs4 tst-mbswcs5 tst-mbswcs6 \
- tst_nl_langinfo tst-numeric tst-rpmatch tst-setlocale \
- tst-sscanf tst-strfmon1 tst-trans tst-wctype tst-xlocale1 \
- tst-xlocale2 xfrm-test
-
-
-# NOTE: For now disabled some tests that are known not build
-TESTS_DISABLED := tst-ctype tst-fmon tst-leaks tst-rpmatch tst-strfmon1
-
-ifneq ($(UCLIBC_HAS_XLOCALE),y)
-TESTS_DISABLED += bug-usesetlocale tst-xlocale1 tst-xlocale2 xfrm-test tst-C-locale
-endif
+top_builddir=../../
+top_srcdir=../../
+include ../Rules.mak
+-include Makefile.in
include ../Test.mak
-
-DODIFF_rint := 1
-
-EXTRA_CFLAGS := -D__USE_GNU -fno-builtin
-
-OPTS_dump-ctype = C
-OPTS_tst-ctype = < tst-ctype-de_DE.ISO-8859-1.in
-OPTS_tst-langinfo = < tst-langinfo.input
-
-EXTRA_CLEAN := C
diff --git a/test/locale/Makefile.in b/test/locale/Makefile.in
new file mode 100644
index 000000000..806ea2866
--- /dev/null
+++ b/test/locale/Makefile.in
@@ -0,0 +1,31 @@
+# uClibc locale tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+# tst_mbtowc tst_strcoll tst_strfmon tst_strxfrm \
+
+TESTS := bug-iconv-trans bug-usesetlocale collate-test dump-ctype \
+ gen-unicode-ctype show-ucs-data tst-ctype \
+ tst-digits tst-fmon tst-langinfo tst-leaks tst-mbswcs1 \
+ tst-mbswcs2 tst-mbswcs3 tst-mbswcs4 tst-mbswcs5 tst-mbswcs6 \
+ tst_nl_langinfo tst-numeric tst-rpmatch tst-setlocale \
+ tst-sscanf tst-strfmon1 tst-trans tst-wctype tst-xlocale1 \
+ tst-xlocale2 xfrm-test
+
+
+# NOTE: For now disabled some tests that are known not build
+TESTS_DISABLED := tst-ctype tst-fmon tst-leaks tst-rpmatch tst-strfmon1
+
+ifneq ($(UCLIBC_HAS_XLOCALE),y)
+TESTS_DISABLED += bug-usesetlocale tst-xlocale1 tst-xlocale2 xfrm-test tst-C-locale
+endif
+
+DODIFF_rint := 1
+
+EXTRA_CFLAGS := -D__USE_GNU -fno-builtin
+
+OPTS_dump-ctype = C
+OPTS_tst-ctype = < tst-ctype-de_DE.ISO-8859-1.in
+OPTS_tst-langinfo = < tst-langinfo.input
+
+CFLAGS_tst-sscanf = -fPIC
+
+EXTRA_DIRS := C
diff --git a/test/locale/collate-test.c b/test/locale/collate-test.c
index e8f43218f..a84974cef 100644
--- a/test/locale/collate-test.c
+++ b/test/locale/collate-test.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/>. */
#include <ctype.h>
#include <error.h>
diff --git a/test/locale/dump-ctype.c b/test/locale/dump-ctype.c
index a1f24c656..6cf96d81d 100644
--- a/test/locale/dump-ctype.c
+++ b/test/locale/dump-ctype.c
@@ -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/>. */
/* Usage example:
$ dump-ctype de_DE.UTF-8
diff --git a/test/locale/gen-unicode-ctype.c b/test/locale/gen-unicode-ctype.c
index 849f272ed..0c74e6a7e 100644
--- a/test/locale/gen-unicode-ctype.c
+++ b/test/locale/gen-unicode-ctype.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/>. */
/* Usage example:
$ gen-unicode /usr/local/share/Unidata/UnicodeData.txt 3.1
diff --git a/test/locale/tst-C-locale.c b/test/locale/tst-C-locale.c
index c568cf404..282d53aac 100644
--- a/test/locale/tst-C-locale.c
+++ b/test/locale/tst-C-locale.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/>. */
#include <ctype.h>
#include <langinfo.h>
diff --git a/test/locale/tst-ctype.c b/test/locale/tst-ctype.c
index c03c2dab3..d61739851 100644
--- a/test/locale/tst-ctype.c
+++ b/test/locale/tst-ctype.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 <ctype.h>
#include <locale.h>
diff --git a/test/locale/tst-digits.c b/test/locale/tst-digits.c
index 8414a4b51..16cf2114e 100644
--- a/test/locale/tst-digits.c
+++ b/test/locale/tst-digits.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 <ctype.h>
#include <langinfo.h>
diff --git a/test/locale/tst-fmon.c b/test/locale/tst-fmon.c
index 11093ce6c..bcdd2d03e 100644
--- a/test/locale/tst-fmon.c
+++ b/test/locale/tst-fmon.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/>. */
#include <stdio.h>
#include <locale.h>
diff --git a/test/locale/tst-langinfo.c b/test/locale/tst-langinfo.c
index e95f0da53..aca8239bf 100644
--- a/test/locale/tst-langinfo.c
+++ b/test/locale/tst-langinfo.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/>. */
#include <langinfo.h>
#include <locale.h>
diff --git a/test/locale/tst-langinfo.input b/test/locale/tst-langinfo.input
index 0a05ab862..8f1861b22 100644
--- a/test/locale/tst-langinfo.input
+++ b/test/locale/tst-langinfo.input
@@ -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; see the file COPYING.LIB. If
+# not, see <http://www.gnu.org/licenses/>.
# Run the test program.
diff --git a/test/locale/tst-mbswcs1.c b/test/locale/tst-mbswcs1.c
index fb2ea84cd..6681ccc9e 100644
--- a/test/locale/tst-mbswcs1.c
+++ b/test/locale/tst-mbswcs1.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/>. */
#include <stdio.h>
#include <string.h>
diff --git a/test/locale/tst-mbswcs2.c b/test/locale/tst-mbswcs2.c
index 49f13cc87..042069f82 100644
--- a/test/locale/tst-mbswcs2.c
+++ b/test/locale/tst-mbswcs2.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/>. */
#include <stdio.h>
#include <string.h>
diff --git a/test/locale/tst-mbswcs3.c b/test/locale/tst-mbswcs3.c
index 0c4af4c14..73bb59af0 100644
--- a/test/locale/tst-mbswcs3.c
+++ b/test/locale/tst-mbswcs3.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/>. */
#include <stdio.h>
#include <string.h>
diff --git a/test/locale/tst-mbswcs4.c b/test/locale/tst-mbswcs4.c
index e02b67569..872040138 100644
--- a/test/locale/tst-mbswcs4.c
+++ b/test/locale/tst-mbswcs4.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 <stdio.h>
#include <string.h>
diff --git a/test/locale/tst-mbswcs5.c b/test/locale/tst-mbswcs5.c
index 7cab97e72..efb6dda89 100644
--- a/test/locale/tst-mbswcs5.c
+++ b/test/locale/tst-mbswcs5.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/>. */
#include <stdio.h>
#include <string.h>
diff --git a/test/locale/tst-mbswcs6.c b/test/locale/tst-mbswcs6.c
index eb383ac87..4bbb961d5 100644
--- a/test/locale/tst-mbswcs6.c
+++ b/test/locale/tst-mbswcs6.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/>. */
#include <errno.h>
#include <locale.h>
diff --git a/test/locale/tst-numeric.c b/test/locale/tst-numeric.c
index 9d3c91d15..a7911f1b2 100644
--- a/test/locale/tst-numeric.c
+++ b/test/locale/tst-numeric.c
@@ -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/>. */
#include <stdio.h>
#include <locale.h>
diff --git a/test/locale/tst-rpmatch.c b/test/locale/tst-rpmatch.c
index d751a43bf..91e23650b 100644
--- a/test/locale/tst-rpmatch.c
+++ b/test/locale/tst-rpmatch.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/>. */
#include <locale.h>
#include <stdio.h>
diff --git a/test/locale/tst-trans.c b/test/locale/tst-trans.c
index 034a36216..081a9aaaf 100644
--- a/test/locale/tst-trans.c
+++ b/test/locale/tst-trans.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/>. */
#include <locale.h>
#include <stdio.h>
diff --git a/test/locale/tst-wctype.c b/test/locale/tst-wctype.c
index 8fd8ce518..21ebd9294 100644
--- a/test/locale/tst-wctype.c
+++ b/test/locale/tst-wctype.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/>. */
#include <error.h>
#include <locale.h>
diff --git a/test/locale/xfrm-test.c b/test/locale/xfrm-test.c
index 199bb6b5a..1ab087440 100644
--- a/test/locale/xfrm-test.c
+++ b/test/locale/xfrm-test.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/>. */
#include <ctype.h>
#include <error.h>
diff --git a/test/malloc/Makefile b/test/malloc/Makefile
index 3e92e6cdb..97c424be6 100644
--- a/test/malloc/Makefile
+++ b/test/malloc/Makefile
@@ -1,6 +1,8 @@
# uClibc malloc tests
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-TESTS_DISABLED := time_malloc
-
+top_builddir=../../
+top_srcdir=../../
+include ../Rules.mak
+-include Makefile.in
include ../Test.mak
diff --git a/test/malloc/Makefile.in b/test/malloc/Makefile.in
new file mode 100644
index 000000000..9e7cac9f0
--- /dev/null
+++ b/test/malloc/Makefile.in
@@ -0,0 +1,18 @@
+# uClibc malloc tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+TESTS_DISABLED := time_malloc
+
+ifneq ($(UCLIBC_SUSV2_LEGACY),y)
+TESTS_DISABLED += tst-valloc
+endif
+
+ifneq ($(UCLIBC_HAS_OBSTACK),y)
+TESTS_DISABLED += tst-obstack
+endif
+
+ifneq ($(MALLOC_STANDARD),y)
+TESTS_DISABLED += tst-asprintf
+endif
+
+CFLAGS_tst-mallocfork = -fPIC
diff --git a/test/malloc/tst-asprintf.c b/test/malloc/tst-asprintf.c
new file mode 100644
index 000000000..d4c3f7676
--- /dev/null
+++ b/test/malloc/tst-asprintf.c
@@ -0,0 +1,27 @@
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <malloc.h>
+
+static void my_stats(void)
+{
+ malloc_stats();
+ fprintf(stderr, "\n");
+}
+
+int main(int argc, char *argv[])
+{
+ char *a, *b;
+
+ my_stats();
+ asprintf(&b, "asdsadasd %ssdf\n", "AAAA");
+ my_stats();
+ asprintf(&a, "asdsadasd %ssdf\n", "AAAA");
+ my_stats();
+ free(a);
+ free(b);
+ my_stats();
+
+ return 0;
+}
diff --git a/test/malloc/tst-calloc.c b/test/malloc/tst-calloc.c
index b3594c937..b7b6d2bd2 100644
--- a/test/malloc/tst-calloc.c
+++ b/test/malloc/tst-calloc.c
@@ -13,17 +13,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 <error.h>
#include <limits.h>
#include <malloc.h>
#include <stdlib.h>
#include <stdio.h>
+static int errors = 0;
/* Number of samples per size. */
#define N 50000
@@ -46,10 +45,11 @@ fixed_test (int size)
for (j = 0; j < size; ++j)
{
- if (ptrs[i][j] != '\0')
- error (EXIT_FAILURE, 0,
- "byte not cleared (size %d, element %d, byte %d)",
+ if (ptrs[i][j] != '\0') {
+ ++errors;
+ printf("byte not cleared (size %d, element %d, byte %d)",
size, i, j);
+ }
ptrs[i][j] = '\xff';
}
}
@@ -79,10 +79,11 @@ random_test (void)
for (j = 0; j < size; ++j)
{
- if (ptrs[i][j] != '\0')
- error (EXIT_FAILURE, 0,
- "byte not cleared (size %d, element %d, byte %d)",
+ if (ptrs[i][j] != '\0') {
+ ++errors;
+ printf("byte not cleared (size %d, element %d, byte %d)",
size, i, j);
+ }
ptrs[i][j] = '\xff';
}
}
@@ -122,5 +123,5 @@ main (void)
null_test ();
- return 0;
+ return errors != 0;
}
diff --git a/test/malloc/tst-malloc.c b/test/malloc/tst-malloc.c
index 468e1d4ba..2d3bcce17 100644
--- a/test/malloc/tst-malloc.c
+++ b/test/malloc/tst-malloc.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 <malloc.h>
diff --git a/test/malloc/tst-mcheck.c b/test/malloc/tst-mcheck.c
index af72c042b..9297d7994 100644
--- a/test/malloc/tst-mcheck.c
+++ b/test/malloc/tst-mcheck.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 <stdio.h>
diff --git a/test/malloc/tst-obstack.c b/test/malloc/tst-obstack.c
index 769697f18..1841946c3 100644
--- a/test/malloc/tst-obstack.c
+++ b/test/malloc/tst-obstack.c
@@ -1,4 +1,8 @@
-/* Test case by Alexandre Duret-Lutz <duret_g@epita.fr>. */
+/* Test case by Alexandre Duret-Lutz <duret_g@epita.fr>.
+ * test_obstack_printf() added by Anthony G. Basile <blueness.gentoo.org>.
+ */
+
+#include <features.h>
#include <obstack.h>
#include <stdint.h>
#include <stdio.h>
@@ -26,7 +30,7 @@ verbose_free (void *buf)
}
int
-main (void)
+test_obstack_alloc (void)
{
int result = 0;
int align = 2;
@@ -62,3 +66,39 @@ main (void)
return result;
}
+
+int
+test_obstack_printf (void)
+{
+ int result = 0;
+ int n;
+ char *s;
+ struct obstack ob;
+
+ obstack_init (&ob);
+
+ n = obstack_printf (&ob, "%s%d%c", "testing 1 ... 2 ... ", 3, '\n');
+ result |= (n != 22);
+ printf("obstack_printf => %d\n", n);
+
+ n = obstack_printf (&ob, "%s%d%c", "testing 3 ... 2 ... ", 1, '\0');
+ result |= (n != 22);
+ printf("obstack_printf => %d\n", n);
+
+ s = obstack_finish (&ob);
+ printf("obstack_printf => %s\n", s);
+ obstack_free (&ob, NULL);
+
+ return result;
+}
+
+int
+main (void)
+{
+ int result = 0;
+
+ result |= test_obstack_alloc();
+ result |= test_obstack_printf();
+
+ return result;
+}
diff --git a/test/math/Makefile b/test/math/Makefile
index e65f1700e..6194efa07 100644
--- a/test/math/Makefile
+++ b/test/math/Makefile
@@ -1,26 +1,8 @@
# uClibc math tests
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-TESTS := basic-test rint tst-definitions test-fpucw
-# test-double test-idouble
-# test-float test-ifloat
-# test-ldouble test-ildouble
-
+top_builddir=../../
+top_srcdir=../../
+include ../Rules.mak
+-include Makefile.in
include ../Test.mak
-
-DODIFF_rint := 1
-
-# NOTE: For basic-test we must disable the floating point optimization.
-# Only for sh architecture because in the other architecture are disabled.
-ifeq ($(TARGET_ARCH),sh)
-CFLAGS_basic-test := -mieee
-endif
-EXTRA_CFLAGS := -DNO_LONG_DOUBLE -fno-builtin
-EXTRA_LDFLAGS := -lm
-
-PERL := /usr/bin/perl
-ulps-file := $(firstword $(wildcard $(config-sysdirs:%=$(..)%/libm-test-ulps)))
-libm-test.c: $(ulps-file) libm-test.inc gen-libm-test.pl
- $(Q)$(PERL) ./gen-libm-test.pl -u $< ./libm-test.inc -o "." 2>&1 > /dev/null
-EXTRA_CLEAN := libm-test.c libm-test-ulps.h
-$(TARGETS): libm-test.c
diff --git a/test/math/Makefile.in b/test/math/Makefile.in
new file mode 100644
index 000000000..387400151
--- /dev/null
+++ b/test/math/Makefile.in
@@ -0,0 +1,46 @@
+# uClibc math tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+# libm-test.c is a generated file used by the tests internally so skip it
+TESTS_DISABLED := libm-test
+
+# gamma (removed from TESTS, need to add "small errors are ok" machinery there)
+TESTS_DISABLED += gamma
+ifeq ($(UCLIBC_HAS_LONG_DOUBLE_MATH),)
+TESTS_DISABLED += test-ldouble test-ildoubl compile_test c99_test
+CFLAGS_basic-test := -DNO_LONG_DOUBLE
+endif
+ifeq ($(DO_C99_MATH),)
+TESTS_DISABLED += test-float test-ifloat test-double test-idouble rint signgam ilogb
+endif
+ifeq ($(UCLIBC_HAS_FPU),)
+TESTS_DISABLED += test-fpucw
+endif
+
+DODIFF_rint := 1
+DODIFF_signgam := 1
+
+# NOTE: For basic-test we must disable the floating point optimization.
+# Only for sh architecture because in the other architecture are disabled.
+ifeq ($(TARGET_ARCH),sh)
+CFLAGS_basic-test += -mieee
+endif
+EXTRA_CFLAGS := -fno-builtin
+EXTRA_LDFLAGS := -lm
+
+PERL := perl
+
+MDEPS := $(wildcard test-*.c)
+$(MDEPS): libm-test.c
+
+ULP_SUFFIX :=
+ifeq ($(TARGET_ARCH),mips)
+ULP_SUFFIX:=$(if $(CONFIG_MIPS_N64_ABI),64,32)
+endif
+
+TARGET_ULP := $(if $(wildcard libm-test-ulps-$(TARGET_ARCH)$(ULP_SUFFIX)),$(TARGET_ARCH)$(ULP_SUFFIX),generic)
+
+libm-test.c: libm-test-ulps-$(TARGET_ULP) libm-test.inc gen-libm-test.pl
+ $(Q)$(PERL) ./gen-libm-test.pl -u libm-test-ulps-$(TARGET_ULP) ./libm-test.inc -o "." 2>&1 > /dev/null
+
+EXTRA_CLEAN := libm-test.c libm-test-ulps.h
diff --git a/test/math/basic-test.c b/test/math/basic-test.c
index e42c01457..d073abb0f 100644
--- a/test/math/basic-test.c
+++ b/test/math/basic-test.c
@@ -13,9 +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 _ISOC99_SOURCE
#include <math.h>
#include <float.h>
@@ -63,11 +64,6 @@ NAME (void) \
check (#FLOAT " !isnan (1)", !(isnan (one_var))); \
check (#FLOAT " !isnan (inf)", !(isnan (Inf_var))); \
\
- check (#FLOAT " inf == inf", Inf_var == Inf_var); \
- check (#FLOAT " -inf == -inf", -Inf_var == -Inf_var); \
- check (#FLOAT " inf != -inf", Inf_var != -Inf_var); \
- check (#FLOAT " NaN != NaN", NaN_var != NaN_var); \
- \
/* \
the same tests but this time with NAN from <bits/nan.h> \
NAN is a double const \
@@ -76,7 +72,6 @@ NAME (void) \
check (#FLOAT " isnan (-NAN)", isnan (-NAN)); \
check (#FLOAT " !isinf (NAN)", !(isinf (NAN))); \
check (#FLOAT " !isinf (-NAN)", !(isinf (-NAN))); \
- check (#FLOAT " NAN != NAN", NAN != NAN); \
\
/* \
And again with the value returned by the `nan' function. \
@@ -87,6 +82,48 @@ NAME (void) \
check (#FLOAT " !isinf (-NAN)", !(isinf (-NANFUNC ("")))); \
check (#FLOAT " NAN != NAN", NANFUNC ("") != NANFUNC ("")); \
\
+ /* test if HUGE_VALx is ok */ \
+ x1 = HUGEVAL; \
+ check (#FLOAT " isinf (HUGE_VALx) == +1", isinf (x1) == +1); \
+ x1 = - HUGEVAL; \
+ check (#FLOAT " isinf (-HUGE_VALx) == -1", isinf (x1) == -1); \
+}
+#ifndef DO_C99_MATH
+# undef TEST_FUNC
+# define TEST_FUNC(NAME, FLOAT, NANFUNC, EPSILON, HUGEVAL) \
+static void \
+NAME(void) \
+{ /* nothing */ }
+#endif
+
+#define TEST_VAL(NAME, FLOAT, NANFUNC, EPSILON, HUGEVAL) \
+static void \
+NAME (void) \
+{ \
+ /* Variables are declared volatile to forbid some compiler \
+ optimizations. */ \
+ volatile FLOAT Inf_var, NaN_var, zero_var, one_var; \
+ FLOAT x1, x2; \
+ \
+ zero_var = 0.0; \
+ one_var = 1.0; \
+ NaN_var = zero_var/zero_var; \
+ Inf_var = one_var / zero_var; \
+ \
+ (void) &zero_var; \
+ (void) &one_var; \
+ (void) &NaN_var; \
+ (void) &Inf_var; \
+ \
+ \
+ check (#FLOAT " inf == inf", Inf_var == Inf_var); \
+ check (#FLOAT " -inf == -inf", -Inf_var == -Inf_var); \
+ check (#FLOAT " inf != -inf", Inf_var != -Inf_var); \
+ check (#FLOAT " NaN != NaN", NaN_var != NaN_var); \
+ \
+ check (#FLOAT " NAN != NAN", NAN != NAN); \
+ \
+ \
/* test if EPSILON is ok */ \
x1 = 1.0; \
x2 = x1 + EPSILON; \
@@ -96,27 +133,28 @@ NAME (void) \
x2 = x1 - EPSILON; \
check (#FLOAT " 1 != 1-EPSILON", x1 != x2); \
\
- /* test if HUGE_VALx is ok */ \
- x1 = HUGEVAL; \
- check (#FLOAT " isinf (HUGE_VALx) == +1", isinf (x1) == +1); \
- x1 = - HUGEVAL; \
- check (#FLOAT " isinf (-HUGE_VALx) == -1", isinf (x1) == -1); \
}
-TEST_FUNC (float_test, float, nanf, FLT_EPSILON, HUGE_VALF)
-TEST_FUNC (double_test, double, nan, DBL_EPSILON, HUGE_VAL)
+TEST_VAL (float_test_value, float, nanf, FLT_EPSILON, HUGE_VALF)
+TEST_FUNC (float_test_call, float, nanf, FLT_EPSILON, HUGE_VALF)
+TEST_VAL (double_test_value, double, nan, DBL_EPSILON, HUGE_VAL)
+TEST_FUNC (double_test_call, double, nan, DBL_EPSILON, HUGE_VAL)
#ifndef NO_LONG_DOUBLE
-TEST_FUNC (ldouble_test, long double, nanl, LDBL_EPSILON, HUGE_VALL)
+TEST_VAL (ldouble_test_value, long double, nanl, LDBL_EPSILON, HUGE_VALL)
+TEST_FUNC (ldouble_test_call, long double, nanl, LDBL_EPSILON, HUGE_VALL)
#endif
int
main (void)
{
- float_test ();
- double_test ();
+ float_test_value ();
+ float_test_call ();
+ double_test_value ();
+ double_test_call ();
#ifndef NO_LONG_DOUBLE
- ldouble_test ();
+ ldouble_test_value ();
+ ldouble_test_call ();
#endif
return errors != 0;
diff --git a/test/math/c99_test.c b/test/math/c99_test.c
new file mode 100644
index 000000000..73382e41b
--- /dev/null
+++ b/test/math/c99_test.c
@@ -0,0 +1,116 @@
+#include <math.h>
+#include <float.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <limits.h>
+#include <stdio.h>
+
+#define check_d1(func, param, expected) \
+do { \
+ int err; hex_union ur; hex_union up; \
+ double result = func(param); up.f = param; ur.f = result; \
+ errors += (err = (result != (expected))); \
+ err \
+ ? printf("FAIL: %s(%g/"HEXFMT")=%g/"HEXFMT" (expected %g)\n", \
+ #func, (double)(param), (long long)up.hex, result, (long long)ur.hex, (double)(expected)) \
+ : printf("PASS: %s(%g)=%g\n", #func, (double)(param), result); \
+} while (0)
+
+#define check_i1(func, param, expected) \
+do { \
+ int err; hex_union up; \
+ long long result = func(param); up.f = param; \
+ errors += (err = (result != (expected))); \
+ err \
+ ? printf("FAIL: %s(%g/"HEXFMT")=%lld/%llu (expected %llu)\n", \
+ #func, (double)(param), (long long)up.hex, result, result, (long long)(expected)) \
+ : printf("PASS: %s(%g)=%lld/%llu\n", #func, (double)(param), result, result); \
+} while (0)
+
+#define HEXFMT "%08llx"
+typedef union {
+ double f;
+ uint64_t hex;
+} hex_union;
+
+double zero = 0.0;
+double minus_zero = 0.0;
+double nan_value = 0.0;
+int errors = 0;
+
+int main(void)
+{
+ nan_value /= nan_value;
+ minus_zero = copysign(zero, -1.0);
+
+ check_i1(isfinite, 1.0, 1);
+ check_i1(isfinite, 2.0, 1);
+ check_i1(isfinite, 3.0, 1);
+ check_i1(isfinite, DBL_MAX, 1);
+ check_i1(isfinite, FLT_MAX, 1);
+ check_i1(isfinite, HUGE_VAL, 0);
+ check_i1(isfinite, HUGE_VALF, 0);
+ check_i1(isfinite, HUGE_VALL, 0);
+ check_i1(isfinite, nan_value, 0);
+ check_i1(isfinite, nan_value, 0);
+ check_i1(isfinite, nan_value, 0);
+
+ check_i1(isnan, 1.0, 0);
+ check_i1(isnan, 2.0, 0);
+ check_i1(isnan, 3.0, 0);
+ check_i1(isnan, DBL_MAX, 0);
+ check_i1(isnan, FLT_MAX, 0);
+ check_i1(isnan, HUGE_VAL, 0);
+ check_i1(isnan, HUGE_VALF, 0);
+ check_i1(isnan, HUGE_VALL, 0);
+ check_i1(isnan, (float)HUGE_VALL, 0);
+ check_i1(isnan, nan_value, 1);
+ check_i1(isnan, nan_value, 1);
+ check_i1(isnan, nan_value, 1);
+
+ check_i1(isinf, 1.0, 0);
+ check_i1(isinf, 2.0, 0);
+ check_i1(isinf, 3.0, 0);
+ check_i1(isinf, DBL_MAX, 0);
+ check_i1(isinf, FLT_MAX, 0);
+ check_i1(isinf, (float)DBL_MAX, 1);
+ check_i1(isinf, HUGE_VAL, 1);
+ check_i1(isinf, HUGE_VALF, 1);
+ check_i1(isinf, HUGE_VALL, 1);
+ check_i1(isinf, (float)HUGE_VALL, 1);
+ check_i1(isinf, nan_value, 0);
+ check_i1(isinf, nan_value, 0);
+ check_i1(isinf, nan_value, 0);
+
+ check_i1(fpclassify, minus_zero, FP_ZERO);
+ check_i1(fpclassify, 0.0, FP_ZERO);
+ check_i1(fpclassify, 1.0, FP_NORMAL);
+ check_i1(fpclassify, 2.0, FP_NORMAL);
+ check_i1(fpclassify, 3.0, FP_NORMAL);
+ check_i1(fpclassify, DBL_MIN/1.01, FP_SUBNORMAL);
+ check_i1(fpclassify, DBL_MIN, FP_NORMAL);
+ check_i1(fpclassify, DBL_MAX, FP_NORMAL);
+ check_i1(fpclassify, FLT_MAX, FP_NORMAL);
+ check_i1(fpclassify, DBL_MAX, FP_NORMAL);
+ check_i1(fpclassify, DBL_MAX*1.01, FP_INFINITE);
+ check_i1(fpclassify, HUGE_VAL, FP_INFINITE);
+ check_i1(fpclassify, HUGE_VALF, FP_INFINITE);
+ check_i1(fpclassify, HUGE_VALL, FP_INFINITE);
+ check_i1(fpclassify, (float)HUGE_VALL, FP_INFINITE);
+ check_i1(fpclassify, nan_value, FP_NAN);
+ check_i1(fpclassify, nan_value, FP_NAN);
+ check_i1(fpclassify, nan_value, FP_NAN);
+
+ check_i1(!!signbit, -1.0, 1);
+ check_i1(!!signbit, minus_zero, 1);
+ check_i1(!!signbit, 0.0, 0);
+ check_i1(!!signbit, HUGE_VAL, 0);
+ check_i1(!!signbit, HUGE_VALF, 0);
+ check_i1(!!signbit, HUGE_VALL, 0);
+ check_i1(!!signbit, -HUGE_VAL, 1);
+ check_i1(!!signbit, -HUGE_VALF, 1);
+ check_i1(!!signbit, -HUGE_VALL, 1);
+
+ printf("Errors: %d\n", errors);
+ return errors;
+}
diff --git a/test/math/compile_test.c b/test/math/compile_test.c
new file mode 100644
index 000000000..aedfde601
--- /dev/null
+++ b/test/math/compile_test.c
@@ -0,0 +1,141 @@
+#include <math.h>
+
+static int testf(float float_x, long double long_double_x, /*float complex float_complex_x,*/ int int_x, long long_x)
+{
+int r = 0;
+r += acosf(float_x);
+r += acoshf(float_x);
+r += asinf(float_x);
+r += asinhf(float_x);
+r += atan2f(float_x, float_x);
+r += atanf(float_x);
+r += atanhf(float_x);
+/*r += cargf(float_complex_x); - will fight with complex numbers later */
+r += cbrtf(float_x);
+r += ceilf(float_x);
+r += copysignf(float_x, float_x);
+r += cosf(float_x);
+r += coshf(float_x);
+r += erfcf(float_x);
+r += erff(float_x);
+r += exp2f(float_x);
+r += expf(float_x);
+r += expm1f(float_x);
+r += fabsf(float_x);
+r += fdimf(float_x, float_x);
+r += floorf(float_x);
+r += fmaf(float_x, float_x, float_x);
+r += fmaxf(float_x, float_x);
+r += fminf(float_x, float_x);
+r += fmodf(float_x, float_x);
+r += frexpf(float_x, &int_x);
+r += gammaf(float_x);
+r += hypotf(float_x, float_x);
+r += ilogbf(float_x);
+r += ldexpf(float_x, int_x);
+r += lgammaf(float_x);
+r += llrintf(float_x);
+r += llroundf(float_x);
+r += log10f(float_x);
+r += log1pf(float_x);
+r += log2f(float_x);
+r += logbf(float_x);
+r += logf(float_x);
+r += lrintf(float_x);
+r += lroundf(float_x);
+r += modff(float_x, &float_x);
+r += nearbyintf(float_x);
+r += nexttowardf(float_x, long_double_x);
+r += powf(float_x, float_x);
+r += remainderf(float_x, float_x);
+r += remquof(float_x, float_x, &int_x);
+r += rintf(float_x);
+r += roundf(float_x);
+#ifdef __UCLIBC_SUSV3_LEGACY__
+r += scalbf(float_x, float_x);
+#endif
+r += scalblnf(float_x, long_x);
+r += scalbnf(float_x, int_x);
+r += significandf(float_x);
+r += sinf(float_x);
+r += sinhf(float_x);
+r += sqrtf(float_x);
+r += tanf(float_x);
+r += tanhf(float_x);
+r += tgammaf(float_x);
+r += truncf(float_x);
+return r;
+}
+
+static int testl(long double long_double_x, int int_x, long long_x)
+{
+int r = 0;
+r += __finitel(long_double_x);
+r += __fpclassifyl(long_double_x);
+r += __isinfl(long_double_x);
+r += __isnanl(long_double_x);
+r += __signbitl(long_double_x);
+r += acoshl(long_double_x);
+r += acosl(long_double_x);
+r += asinhl(long_double_x);
+r += asinl(long_double_x);
+r += atan2l(long_double_x, long_double_x);
+r += atanhl(long_double_x);
+r += atanl(long_double_x);
+r += cbrtl(long_double_x);
+r += ceill(long_double_x);
+r += copysignl(long_double_x, long_double_x);
+r += coshl(long_double_x);
+r += cosl(long_double_x);
+r += erfcl(long_double_x);
+r += erfl(long_double_x);
+r += exp2l(long_double_x);
+r += expl(long_double_x);
+r += expm1l(long_double_x);
+r += fabsl(long_double_x);
+r += fdiml(long_double_x, long_double_x);
+r += floorl(long_double_x);
+r += fmal(long_double_x, long_double_x, long_double_x);
+r += fmaxl(long_double_x, long_double_x);
+r += fminl(long_double_x, long_double_x);
+r += fmodl(long_double_x, long_double_x);
+r += frexpl(long_double_x, &int_x);
+r += hypotl(long_double_x, long_double_x);
+r += ilogbl(long_double_x);
+r += ldexpl(long_double_x, int_x);
+r += lgammal(long_double_x);
+r += llrintl(long_double_x);
+r += llroundl(long_double_x);
+r += log10l(long_double_x);
+r += log1pl(long_double_x);
+r += log2l(long_double_x);
+r += logbl(long_double_x);
+r += logl(long_double_x);
+r += lrintl(long_double_x);
+r += lroundl(long_double_x);
+r += modfl(long_double_x, &long_double_x);
+r += nearbyintl(long_double_x);
+r += nextafterl(long_double_x, long_double_x);
+r += nexttowardl(long_double_x, long_double_x);
+r += powl(long_double_x, long_double_x);
+r += remainderl(long_double_x, long_double_x);
+r += remquol(long_double_x, long_double_x, &int_x);
+r += rintl(long_double_x);
+r += roundl(long_double_x);
+r += scalblnl(long_double_x, long_x);
+r += scalbnl(long_double_x, int_x);
+r += sinhl(long_double_x);
+r += sinl(long_double_x);
+r += sqrtl(long_double_x);
+r += tanhl(long_double_x);
+r += tanl(long_double_x);
+r += tgammal(long_double_x);
+r += truncl(long_double_x);
+return r;
+}
+
+int main(int argc, char **argv)
+{
+ /* Always 0 but gcc hopefully won't be able to notice */
+ return 5 & ((long)&testf) & ((long)&testl) & 2;
+}
diff --git a/test/math/gamma.c b/test/math/gamma.c
new file mode 100644
index 000000000..69c10afa4
--- /dev/null
+++ b/test/math/gamma.c
@@ -0,0 +1,73 @@
+#include <math.h>
+#include <float.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdio.h>
+
+#define check_d1(func, param, expected) \
+do { \
+ int err; hex_union ur; hex_union up; \
+ double result = func(param); up.f = param; ur.f = result; \
+ errors += (err = (result != (expected))); \
+ err \
+ ? printf("FAIL: %s(%g/"HEXFMT")=%g/"HEXFMT" (expected %g)\n", \
+ #func, (double)(param), (long long)up.hex, result, (long long)ur.hex, (double)(expected)) \
+ : printf("PASS: %s(%g)=%g\n", #func, (double)(param), result); \
+} while (0)
+
+#define HEXFMT "%08llx"
+typedef union {
+ double f;
+ uint64_t hex;
+} hex_union;
+double result;
+
+#define M_2_SQRT_PIl 3.5449077018110320545963349666822903L /* 2 sqrt (M_PIl) */
+#define M_SQRT_PIl 1.7724538509055160272981674833411451L /* sqrt (M_PIl) */
+
+double zero = 0.0;
+double minus_zero = 0.0;
+double nan_value = 0.0;
+int errors = 0;
+
+int main(void)
+{
+ nan_value /= nan_value;
+ minus_zero = copysign(zero, -1.0);
+
+ //check_d1(tgamma, HUGE_VAL, NAN);
+ //check_d1(tgamma, negative_integer, NAN);
+ check_d1(tgamma, 0.0, HUGE_VAL); /* pole */
+ check_d1(tgamma, minus_zero, -HUGE_VAL); /* pole */
+ check_d1(tgamma, DBL_MAX/2, HUGE_VAL); /* overflow to inf */
+ check_d1(tgamma, DBL_MAX, HUGE_VAL); /* overflow to inf */
+ check_d1(tgamma, HUGE_VAL, HUGE_VAL); /* overflow to inf */
+ check_d1(tgamma, 7, 2*3*4*5*6); /* normal value */
+ check_d1(tgamma, -0.5, -M_2_SQRT_PIl); /* normal value (testing negative points) */
+
+ check_d1(lgamma, -HUGE_VAL, HUGE_VAL);
+ //check_d1(lgamma, HUGE_VAL, NAN);
+ check_d1(lgamma, 0.0, HUGE_VAL); /* pole */
+ check_d1(lgamma, minus_zero, HUGE_VAL); /* pole */
+ check_d1(lgamma, 1.0, 0.0);
+ check_d1(lgamma, 2.0, 0.0);
+ check_d1(lgamma, DBL_MAX/2, HUGE_VAL); /* overflow to inf */
+ check_d1(lgamma, DBL_MAX, HUGE_VAL); /* overflow to inf */
+ check_d1(lgamma, HUGE_VAL, HUGE_VAL); /* overflow to inf */
+ check_d1(lgamma, 7, log(2*3*4*5*6)); /* normal value */
+
+ /* In glibc, gamma == lgamma. (In BSD, it's == tgamma */
+ check_d1(gamma, -HUGE_VAL, HUGE_VAL);
+ //check_d1(gamma, HUGE_VAL, NAN);
+ check_d1(gamma, 0.0, HUGE_VAL); /* pole */
+ check_d1(gamma, minus_zero, HUGE_VAL); /* pole */
+ check_d1(gamma, 1.0, 0.0);
+ check_d1(gamma, 2.0, 0.0);
+ check_d1(gamma, DBL_MAX/2, HUGE_VAL); /* overflow to inf */
+ check_d1(gamma, DBL_MAX, HUGE_VAL); /* overflow to inf */
+ check_d1(gamma, HUGE_VAL, HUGE_VAL); /* overflow to inf */
+ check_d1(gamma, 7, log(2*3*4*5*6)); /* normal value */
+
+ printf("Errors: %d\n", errors);
+ return errors;
+}
diff --git a/test/math/gen-libm-test.pl b/test/math/gen-libm-test.pl
index 26f819a88..118f352fa 100755
--- a/test/math/gen-libm-test.pl
+++ b/test/math/gen-libm-test.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
# Copyright (C) 1999 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# Contributed by Andreas Jaeger <aj@suse.de>, 1999.
@@ -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; see the file COPYING.LIB. If
+# not, see <http://www.gnu.org/licenses/>.
# This file needs to be tidied up
# Note that functions and tests share the same namespace.
diff --git a/test/math/ilogb.c b/test/math/ilogb.c
new file mode 100644
index 000000000..041e66b0e
--- /dev/null
+++ b/test/math/ilogb.c
@@ -0,0 +1,52 @@
+#include <math.h>
+#include <float.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <limits.h>
+#include <stdio.h>
+
+#define check_d1(func, param, expected) \
+do { \
+ int err; hex_union ur; hex_union up; \
+ double result = func(param); up.f = param; ur.f = result; \
+ errors += (err = (result != (expected))); \
+ err \
+ ? printf("FAIL: %s(%g/"HEXFMT")=%g/"HEXFMT" (expected %g)\n", \
+ #func, (double)(param), (long long)up.hex, result, (long long)ur.hex, (double)(expected)) \
+ : printf("PASS: %s(%g)=%g\n", #func, (double)(param), result); \
+} while (0)
+
+#define check_i1(func, param, expected) \
+do { \
+ int err; hex_union up; \
+ long long result = func(param); up.f = param; \
+ errors += (err = (result != (expected))); \
+ err \
+ ? printf("FAIL: %s(%g/"HEXFMT")=%lld/%llu (expected %llu)\n", \
+ #func, (double)(param), (long long)up.hex, result, result, (long long)(expected)) \
+ : printf("PASS: %s(%g)=%lld/%llu\n", #func, (double)(param), result, result); \
+} while (0)
+
+#define HEXFMT "%08llx"
+typedef union {
+ double f;
+ uint64_t hex;
+} hex_union;
+
+double nan_value = 0.0;
+int errors = 0;
+
+int main(void)
+{
+ nan_value /= nan_value;
+
+ check_i1(ilogb, 0.0, FP_ILOGB0);
+ check_i1(ilogb, HUGE_VAL, INT_MAX);
+ check_i1(ilogb, nan_value, FP_ILOGBNAN);
+ check_i1(ilogbf, 0.0, FP_ILOGB0);
+ check_i1(ilogbf, HUGE_VALF, INT_MAX);
+ check_i1(ilogbf, nan_value, FP_ILOGBNAN);
+
+ printf("Errors: %d\n", errors);
+ return errors;
+}
diff --git a/test/math/libm-test-ulps-arc b/test/math/libm-test-ulps-arc
new file mode 100644
index 000000000..7139447dc
--- /dev/null
+++ b/test/math/libm-test-ulps-arc
@@ -0,0 +1,144 @@
+# Begin of automatic generation
+
+# cos
+Test "cos (M_PI_6l * 2.0) == 0.5":
+idouble: 1
+Test "cos (M_PI_6l * 4.0) == -0.5":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+# erf
+Test "erf (0.75) == 0.711155633653515131598937834591410777":
+double: 1
+idouble: 1
+Test "erf (1.25) == 0.922900128256458230136523481197281140":
+double: 1
+idouble: 1
+
+# erfc
+Test "erfc (4.125) == 0.542340079956506600531223408575531062e-8":
+double: 1
+idouble: 1
+
+# exp
+Test "exp (1) == e":
+double: 1
+idouble: 1
+
+# expm1
+Test "expm1 (0.75) == 1.11700001661267466854536981983709561":
+double: 1
+idouble: 1
+
+# hypot
+Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+
+# lgamma
+Test "lgamma (0.7) == 0.260867246531666514385732417016759578":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# log10
+Test "log10 (0.75) == -0.124938736608299953132449886193870744":
+double: 1
+idouble: 1
+Test "log10 (e) == log10(e)":
+float: 1
+ifloat: 1
+
+# tgamma
+Test "tgamma (-0.5) == -2 sqrt (pi)":
+double: 1
+idouble: 1
+Test "tgamma (0.7) == 1.29805533264755778568117117915281162":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# Maximal error of functions:
+Function: "cos":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: "erf":
+double: 1
+idouble: 1
+
+Function: "erfc":
+double: 1
+idouble: 1
+
+Function: "exp":
+double: 1
+idouble: 1
+
+Function: "expm1":
+double: 1
+idouble: 1
+
+Function: "hypot":
+float: 1
+ifloat: 1
+
+Function: "lgamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "log":
+float: 1
+ifloat: 1
+
+Function: "log10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "tan":
+double: 1
+idouble: 1
+
+Function: "tgamma":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# end of automatic generation
diff --git a/test/math/libm-test-ulps-arm b/test/math/libm-test-ulps-arm
new file mode 100644
index 000000000..8528e81b4
--- /dev/null
+++ b/test/math/libm-test-ulps-arm
@@ -0,0 +1,4989 @@
+# Begin of automatic generation
+
+# acos_downward
+Test "acos_downward (-0)":
+float: 1
+ifloat: 1
+Test "acos_downward (-0.5)":
+double: 1
+idouble: 1
+Test "acos_downward (-1)":
+float: 1
+ifloat: 1
+Test "acos_downward (0)":
+float: 1
+ifloat: 1
+Test "acos_downward (0.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# acos_towardzero
+Test "acos_towardzero (-0)":
+float: 1
+ifloat: 1
+Test "acos_towardzero (-0.5)":
+double: 1
+idouble: 1
+Test "acos_towardzero (-1)":
+float: 1
+ifloat: 1
+Test "acos_towardzero (0)":
+float: 1
+ifloat: 1
+Test "acos_towardzero (0.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# asin_downward
+Test "asin_downward (-0.5)":
+double: 1
+idouble: 1
+Test "asin_downward (0.5)":
+double: 1
+idouble: 1
+Test "asin_downward (1.0)":
+float: 1
+ifloat: 1
+
+# asin_towardzero
+Test "asin_towardzero (-0.5)":
+double: 1
+idouble: 1
+Test "asin_towardzero (-1.0)":
+float: 1
+ifloat: 1
+Test "asin_towardzero (0.5)":
+double: 1
+idouble: 1
+Test "asin_towardzero (1.0)":
+float: 1
+ifloat: 1
+
+# asin_upward
+Test "asin_upward (-1.0)":
+float: 1
+ifloat: 1
+
+# atan2
+Test "atan2 (-0.75, -1.0)":
+float: 1
+ifloat: 1
+Test "atan2 (-max_value, -min_value)":
+float: 1
+ifloat: 1
+Test "atan2 (0.75, -1.0)":
+float: 1
+ifloat: 1
+Test "atan2 (1.390625, 0.9296875)":
+float: 1
+ifloat: 1
+
+# atanh
+Test "atanh (0.75)":
+float: 1
+ifloat: 1
+
+# cacos
+Test "Imaginary part of: cacos (+0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (+0 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacos (+0 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (+0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (+0 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacos (+0 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (-0.25 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0.25 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0.25 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0.25 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0.5 + 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0.5 + 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0.5 + 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0.5 + 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (-0.5 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0.5 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0.5 - 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0.5 - 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0.5 - 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0.5 - 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (-0.5 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0.5 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0x0.fffffffffffff8p0 + 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0x0.fffffffffffff8p0 - 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0x0.ffffffp0 + 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cacos (-0x0.ffffffp0 - 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cacos (-0x1.000002p0 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.000002p0 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.fp-10 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-10 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (-0x1.fp-100 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.fp-100 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-100 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.fp-100 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.fp-1000 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-1000 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-1025 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-1025 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-1025 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-1025 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (-0x1.fp-129 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.fp-129 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-129 + 0x0.ffffffp0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-129 + 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-129 + 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-129 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-129 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.fp-129 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-129 + 1.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.fp-129 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (-0x1.fp-129 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.fp-129 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-129 - 0x0.ffffffp0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-129 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-129 - 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-129 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-129 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.fp-129 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-129 - 1.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.fp-129 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (-0x1.fp-30 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.fp-30 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-30 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.fp-30 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-105 + 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-105 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-105 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-105 + 0x1p-105 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-105 - 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-105 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-105 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-105 - 0x1p-105 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-112 + 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-112 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-112 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-112 + 0x1p-112 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-112 - 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-112 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-112 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-112 - 0x1p-112 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-23 + 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-23 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-23 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-23 + 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (-0x1p-23 + 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-23 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-23 - 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-23 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-23 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-23 - 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (-0x1p-23 - 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-23 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-52 + 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-52 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-52 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-52 + 0x1p-52 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-52 - 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-52 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-52 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-52 - 0x1p-52 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-63 + 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-63 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-63 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-63 + 0x1p-63 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-63 - 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-63 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-63 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-63 - 0x1p-63 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-1.0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-1.0 + 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-1.0 + 0x1p50 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-1.0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-1.0 - 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-1.0 - 0x1p50 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-2 - 3 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0.25 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0.25 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (0.5 + +0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 + 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 + 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0.5 + 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 + 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0.5 + 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 + 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0.5 + 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0.5 + 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 + 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 + 0x1p-63 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0.5 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 - 0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 - 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 - 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0.5 - 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 - 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0.5 - 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 - 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0.5 - 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0.5 - 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 - 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 - 0x1p-63 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0.5 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x0.fffffffffffff8p0 + 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x0.fffffffffffff8p0 - 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0x0.ffffffp0 + 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (0x0.ffffffp0 + 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (0x0.ffffffp0 + 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cacos (0x0.ffffffp0 + 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Real part of: cacos (0x0.ffffffp0 - 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (0x0.ffffffp0 - 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (0x0.ffffffp0 - 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cacos (0x0.ffffffp0 - 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Real part of: cacos (0x1.0000000000001p0 + 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0x1.0000000000001p0 - 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0x1.000002p0 + 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cacos (0x1.000002p0 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (0x1.000002p0 - 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cacos (0x1.000002p0 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1.fp-10 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x1.fp-10 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x1.fp-100 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1.fp-100 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1.fp-1000 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x1.fp-1000 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x1.fp-1025 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x1.fp-1025 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x1.fp-1025 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x1.fp-1025 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x1.fp-129 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1.fp-129 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1.fp-129 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x1.fp-129 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1.fp-129 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1.fp-129 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x1.fp-30 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1.fp-30 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1.fp1023 + 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x1.fp127 + 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x1p-105 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1p-105 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1p-112 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1p-112 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1p-23 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1p-23 + 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x1p-23 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1p-23 - 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x1p-52 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1p-52 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1p-63 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1p-63 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (1.0 + 0.25 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (1.0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (1.0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (1.0 + 0x1.fp-10 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cacos (1.0 + 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (1.0 - 0.25 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (1.0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (1.0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (1.0 - 0x1.fp-10 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cacos (1.0 - 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+
+# cacosh
+Test "Real part of: cacosh (+0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (+0 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: cacosh (+0 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (+0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (+0 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: cacosh (+0 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: cacosh (-0 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: cacosh (-0 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0.25 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0.25 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: cacosh (-0.25 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0.25 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: cacosh (-0.5 + 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0.5 + 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0.5 + 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0.5 + 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0.5 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (-0.5 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0.5 - 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0.5 - 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0.5 - 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0.5 - 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0.5 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (-0.5 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x0.fffffffffffff8p0 + 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0x0.fffffffffffff8p0 - 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0x0.ffffffp0 + 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Real part of: cacosh (-0x0.ffffffp0 - 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Real part of: cacosh (-0x1.000002p0 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1.000002p0 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1.fp-10 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0x1.fp-10 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0x1.fp-100 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-100 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1.fp-100 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-100 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1.fp-1000 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0x1.fp-1000 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0x1.fp-1025 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0x1.fp-1025 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0x1.fp-1025 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0x1.fp-1025 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0x1.fp-129 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 + 0x0.ffffffp0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 + 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 + 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1.fp-129 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1.fp-129 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 + 1.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1.fp-129 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 - 0x0.ffffffp0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 - 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1.fp-129 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1.fp-129 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 - 1.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1.fp-30 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-30 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1.fp-30 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-30 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-105 + 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-105 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-105 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-105 + 0x1p-105 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-105 - 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-105 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-105 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-105 - 0x1p-105 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-112 + 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-112 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-112 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-112 + 0x1p-112 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-112 - 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-112 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-112 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-112 - 0x1p-112 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-23 + 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-23 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-23 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-23 + 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (-0x1p-23 + 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-23 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-23 - 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-23 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-23 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-23 - 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (-0x1p-23 - 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-23 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-52 + 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-52 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-52 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-52 + 0x1p-52 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-52 - 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-52 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-52 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-52 - 0x1p-52 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-63 + 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-63 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-63 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-63 + 0x1p-63 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-63 - 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-63 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-63 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-63 - 0x1p-63 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-1.0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-1.0 + 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-1.0 + 0x1p50 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-1.0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-1.0 - 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-1.0 - 0x1p50 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-2 - 3 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (0.25 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (0.25 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (0.5 + +0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0.5 + 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0.5 + 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0.5 + 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0.5 + 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0.5 + 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0.5 + 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0.5 + 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0.5 + 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0.5 + 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0.5 + 0x1p-63 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0.5 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0.5 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (0.5 - 0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0.5 - 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0.5 - 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0.5 - 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0.5 - 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0.5 - 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0.5 - 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0.5 - 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0.5 - 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0.5 - 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0.5 - 0x1p-63 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0.5 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0.5 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (0x0.fffffffffffff8p0 + 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x0.fffffffffffff8p0 - 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0x0.ffffffp0 + 0.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (0x0.ffffffp0 + 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (0x0.ffffffp0 + 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cacosh (0x0.ffffffp0 + 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cacosh (0x0.ffffffp0 - 0.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (0x0.ffffffp0 - 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (0x0.ffffffp0 - 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cacosh (0x0.ffffffp0 - 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cacosh (0x1.0000000000001p0 + 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0x1.0000000000001p0 - 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x1.000002p0 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (0x1.000002p0 + 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Real part of: cacosh (0x1.000002p0 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (0x1.000002p0 - 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Real part of: cacosh (0x1.fp-10 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x1.fp-10 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x1.fp-100 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1.fp-100 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1.fp-1000 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x1.fp-1000 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x1.fp-1025 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x1.fp-1025 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x1.fp-1025 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x1.fp-1025 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x1.fp-129 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1.fp-129 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1.fp-129 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x1.fp-129 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1.fp-129 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1.fp-129 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x1.fp-30 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1.fp-30 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1.fp1023 + 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x1.fp127 + 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x1p-105 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1p-105 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1p-112 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1p-112 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1p-23 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1p-23 + 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x1p-23 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1p-23 - 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x1p-52 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1p-52 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1p-63 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1p-63 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (1.0 + 0.25 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (1.0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (1.0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (1.0 + 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (1.0 + 0x1.fp-10 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cacosh (1.0 - 0.25 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (1.0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (1.0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (1.0 - 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (1.0 - 0x1.fp-10 i)":
+float: 2
+ifloat: 2
+
+# casin
+Test "Imaginary part of: casin (+0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (+0 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (+0 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (+0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (+0 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (+0 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0.25 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0.25 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0.5 + 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0.5 + 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0.5 + 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0.5 + 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0.5 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0.5 - 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0.5 - 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0.5 - 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0.5 - 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0.5 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0x0.fffffffffffff8p0 + 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0x0.fffffffffffff8p0 - 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0x0.ffffffp0 + 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: casin (-0x0.ffffffp0 - 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: casin (-0x1.000002p0 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1.000002p0 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casin (-0x1.fp-10 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1.fp-10 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casin (-0x1.fp-10 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1.fp-10 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0x1.fp-100 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1.fp-100 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1.fp-1000 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0x1.fp-1000 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0x1.fp-1025 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0x1.fp-1025 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0x1.fp-1025 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0x1.fp-1025 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0x1.fp-129 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1.fp-129 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1.fp-129 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0x1.fp-129 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1.fp-129 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1.fp-129 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0x1.fp-30 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1.fp-30 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1p-105 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1p-105 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1p-112 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1p-112 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casin (-0x1p-23 + 0.5 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1p-23 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1p-23 + 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casin (-0x1p-23 + 0x1.000002p0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casin (-0x1p-23 - 0.5 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1p-23 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1p-23 - 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casin (-0x1p-23 - 0x1.000002p0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1p-52 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1p-52 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1p-63 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1p-63 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casin (-1.0 + 0.25 i)":
+double: 1
+idouble: 1
+Test "Real part of: casin (-1.0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-1.0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-1.0 + 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casin (-1.0 - 0.25 i)":
+double: 1
+idouble: 1
+Test "Real part of: casin (-1.0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-1.0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-1.0 - 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0.25 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0.25 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0.5 + 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0.5 + 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0.5 + 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0.5 + 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0.5 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0.5 - 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0.5 - 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0.5 - 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0.5 - 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0.5 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casin (0.75 + 1.25 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x0.fffffffffffff8p0 + 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0x0.fffffffffffff8p0 - 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0x0.ffffffp0 + 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: casin (0x0.ffffffp0 - 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: casin (0x1.000002p0 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1.000002p0 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casin (0x1.fp-10 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1.fp-10 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casin (0x1.fp-10 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1.fp-10 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0x1.fp-100 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1.fp-100 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1.fp-1000 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0x1.fp-1000 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0x1.fp-1025 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0x1.fp-1025 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0x1.fp-1025 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0x1.fp-1025 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0x1.fp-129 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1.fp-129 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1.fp-129 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0x1.fp-129 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1.fp-129 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1.fp-129 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0x1.fp-30 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1.fp-30 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1.fp1023 + 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0x1.fp127 + 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0x1p-105 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1p-105 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1p-112 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1p-112 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casin (0x1p-23 + 0.5 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1p-23 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1p-23 + 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casin (0x1p-23 + 0x1.000002p0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casin (0x1p-23 - 0.5 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1p-23 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1p-23 - 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casin (0x1p-23 - 0x1.000002p0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1p-52 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1p-52 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1p-63 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1p-63 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casin (1.0 + 0.25 i)":
+double: 1
+idouble: 1
+Test "Real part of: casin (1.0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (1.0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (1.0 + 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casin (1.0 - 0.25 i)":
+double: 1
+idouble: 1
+Test "Real part of: casin (1.0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (1.0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (1.0 - 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+
+# casinh
+Test "Imaginary part of: casinh (-0.25 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casinh (-0.25 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-0.5 + +0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 + 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 + 0x1p-105 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 + 0x1p-112 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (-0.5 + 0x1p-23 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 + 0x1p-52 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 + 0x1p-63 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (-0.5 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 - 0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 - 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 - 0x1p-105 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 - 0x1p-112 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (-0.5 - 0x1p-23 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 - 0x1p-52 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 - 0x1p-63 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (-0.5 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0x0.ffffffp0 + 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-0x0.ffffffp0 - 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casinh (-0x1.000002p0 + 0x1p-23 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casinh (-0x1.000002p0 - 0x1p-23 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (-0x1.fp-10 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0x1.fp-10 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0x1.fp-129 + 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-0x1.fp-129 - 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-0x1p-105 + 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-0x1p-105 - 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-0x1p-112 + 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-0x1p-112 - 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-0x1p-23 + 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-0x1p-23 + 0x0.ffffffp0 i)":
+float: 2
+ifloat: 2
+Test "Real part of: casinh (-0x1p-23 + 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0x1p-23 - 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-0x1p-23 - 0x0.ffffffp0 i)":
+float: 2
+ifloat: 2
+Test "Real part of: casinh (-0x1p-23 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0x1p-52 + 0x0.fffffffffffff8p0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-0x1p-52 - 0x0.fffffffffffff8p0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-1.0 + +0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (-1.0 + 0.25 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-1.0 + 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-1.0 + 0x1.fp-10 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casinh (-1.0 + 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-1.0 + 0x1.fp-100 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (-1.0 + 0x1.fp-1000 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-1.0 + 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-1.0 + 0x1.fp-129 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (-1.0 + 0x1.fp-30 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (-1.0 - 0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (-1.0 - 0.25 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-1.0 - 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-1.0 - 0x1.fp-10 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casinh (-1.0 - 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-1.0 - 0x1.fp-100 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (-1.0 - 0x1.fp-1000 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-1.0 - 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-1.0 - 0x1.fp-129 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (-1.0 - 0x1.fp-30 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (-1.5 + +0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-1.5 + 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-1.5 + 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-1.5 - 0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-1.5 - 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-1.5 - 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casinh (0.25 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casinh (0.25 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (0.5 + +0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 + 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 + 0x1p-105 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 + 0x1p-112 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (0.5 + 0x1p-23 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 + 0x1p-52 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 + 0x1p-63 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (0.5 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 - 0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 - 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 - 0x1p-105 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 - 0x1p-112 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (0.5 - 0x1p-23 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 - 0x1p-52 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 - 0x1p-63 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (0.5 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.75 + 1.25 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (0.75 + 1.25 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (0x0.ffffffp0 + 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (0x0.ffffffp0 - 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casinh (0x1.000002p0 + 0x1p-23 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casinh (0x1.000002p0 - 0x1p-23 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (0x1.fp-10 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0x1.fp-10 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0x1.fp-129 + 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (0x1.fp-129 - 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (0x1.fp1023 + 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (0x1.fp127 + 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (0x1p-105 + 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (0x1p-105 - 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (0x1p-112 + 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (0x1p-112 - 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (0x1p-23 + 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (0x1p-23 + 0x0.ffffffp0 i)":
+float: 2
+ifloat: 2
+Test "Real part of: casinh (0x1p-23 + 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0x1p-23 - 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (0x1p-23 - 0x0.ffffffp0 i)":
+float: 2
+ifloat: 2
+Test "Real part of: casinh (0x1p-23 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0x1p-52 + 0x0.fffffffffffff8p0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (0x1p-52 - 0x0.fffffffffffff8p0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (1.0 + +0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (1.0 + 0.25 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (1.0 + 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (1.0 + 0x1.fp-10 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casinh (1.0 + 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (1.0 + 0x1.fp-100 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (1.0 + 0x1.fp-1000 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (1.0 + 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (1.0 + 0x1.fp-129 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (1.0 + 0x1.fp-30 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (1.0 - 0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (1.0 - 0.25 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (1.0 - 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (1.0 - 0x1.fp-10 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casinh (1.0 - 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (1.0 - 0x1.fp-100 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (1.0 - 0x1.fp-1000 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (1.0 - 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (1.0 - 0x1.fp-129 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (1.0 - 0x1.fp-30 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (1.5 + +0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (1.5 + 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (1.5 + 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (1.5 - 0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (1.5 - 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (1.5 - 0x1.fp-129 i)":
+double: 1
+idouble: 1
+
+# catan
+Test "Imaginary part of: catan (-0x0.fffffffffffff8p0 + 0x1p-27 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (-0x0.ffffffp0 + 0x1p-13 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: catan (-0x1.0000000000001p0 - 0x1p-27 i)":
+double: 1
+idouble: 1
+Test "Real part of: catan (-0x1.000002p0 + 0x1p-126 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (-0x1.000002p0 + 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (-0x1.000002p0 - 0x1p-126 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (-0x1.000002p0 - 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (-0x1.000002p0 - 0x1p-13 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (-0x1.fp1023 + 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (-0x1.fp1023 - 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (-0x1.fp127 + 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (-0x1.fp127 - 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (-0x1p-1020 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (-0x1p-1020 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: catan (-0x1p-13 + 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (-0x1p-13 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (-0x1p-13 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (-0x1p-13 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (-0x1p-13 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (-0x1p-54 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (-0x1p-54 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (-0x1p-57 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (-0x1p-57 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (-1.0 + 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (-1.0 - 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (-2 - 3 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: catan (0x0.fffffffffffff8p0 + 0x1p-27 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (0x0.ffffffp0 + 0x1p-13 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: catan (0x1.0000000000001p0 - 0x1p-27 i)":
+double: 1
+idouble: 1
+Test "Real part of: catan (0x1.000002p0 + 0x1p-126 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (0x1.000002p0 + 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (0x1.000002p0 - 0x1p-126 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (0x1.000002p0 - 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (0x1.000002p0 - 0x1p-13 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (0x1.fp1023 + 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (0x1.fp1023 - 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (0x1.fp127 + 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (0x1.fp127 - 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (0x1p-1020 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (0x1p-1020 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: catan (0x1p-13 + 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (0x1p-13 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (0x1p-13 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (0x1p-13 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (0x1p-13 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (0x1p-54 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (0x1p-54 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (0x1p-57 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (0x1p-57 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (1.0 + 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (1.0 - 0x1p-13 i)":
+float: 1
+ifloat: 1
+
+# catanh
+Test "Real part of: catanh (-0x1.000002p0 + 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catanh (-0x1.000002p0 + 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (-0x1.000002p0 - 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catanh (-0x1.000002p0 - 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (-0x1.fp1023 + 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Real part of: catanh (-0x1.fp1023 - 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Real part of: catanh (-0x1.fp127 + 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Real part of: catanh (-0x1.fp127 - 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (-0x1p-126 + 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catanh (-0x1p-126 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (-0x1p-13 + 0x1.000002p0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (-0x1p-13 + 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catanh (-0x1p-13 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (-0x1p-13 - 0x1.000002p0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (-0x1p-13 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catanh (-0x1p-13 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (-0x1p-27 + 0x1.0000000000001p0 i)":
+double: 1
+idouble: 1
+Test "Real part of: catanh (-0x1p-27 - 0x1.0000000000001p0 i)":
+double: 1
+idouble: 1
+Test "Real part of: catanh (-1.0 + 0x1p-1020 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (-1.0 + 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (-1.0 + 0x1p-54 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (-1.0 + 0x1p-57 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (-1.0 - 0x1p-1020 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (-1.0 - 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (-1.0 - 0x1p-54 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (-1.0 - 0x1p-57 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (-2 - 3 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (0x1.000002p0 + 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catanh (0x1.000002p0 - 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (0x1.fp1023 + 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Real part of: catanh (0x1.fp1023 - 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Real part of: catanh (0x1.fp127 + 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Real part of: catanh (0x1.fp127 - 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (0x1p-126 + 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catanh (0x1p-126 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (0x1p-13 + 0x0.ffffffp0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: catanh (0x1p-13 + 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catanh (0x1p-13 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (0x1p-13 - 0x0.ffffffp0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: catanh (0x1p-13 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catanh (0x1p-13 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (0x1p-27 + 0x0.fffffffffffff8p0 i)":
+double: 1
+idouble: 1
+Test "Real part of: catanh (0x1p-27 - 0x0.fffffffffffff8p0 i)":
+double: 1
+idouble: 1
+Test "Real part of: catanh (1.0 + 0x1p-1020 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (1.0 + 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (1.0 + 0x1p-54 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (1.0 + 0x1p-57 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (1.0 - 0x1p-1020 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (1.0 - 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (1.0 - 0x1p-54 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (1.0 - 0x1p-57 i)":
+float: 1
+ifloat: 1
+
+# cbrt
+Test "cbrt (-27.0)":
+double: 1
+idouble: 1
+Test "cbrt (0.75)":
+double: 1
+idouble: 1
+Test "cbrt (0.9921875)":
+double: 1
+idouble: 1
+
+# ccos
+Test "Imaginary part of: ccos (-0.75 + 710.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: ccos (-0.75 + 89.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccos (-0.75 - 710.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: ccos (-0.75 - 89.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccos (-2 - 3 i)":
+float: 1
+ifloat: 1
+Test "Real part of: ccos (0.75 + 1.25 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccos (0.75 + 1.25 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccos (0.75 + 710.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: ccos (0.75 + 89.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccos (0.75 - 710.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: ccos (0.75 - 89.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccos (0x1p-1074 + 1440 i)":
+double: 1
+idouble: 1
+
+# ccosh
+Test "Real part of: ccosh (-2 - 3 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (-2 - 3 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (-710.5 + 0.75 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: ccosh (-710.5 - 0.75 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: ccosh (-89.5 + 0.75 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (-89.5 - 0.75 i)":
+float: 1
+ifloat: 1
+Test "Real part of: ccosh (0.75 + 1.25 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (0.75 + 1.25 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (1440 + 0x1p-1074 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: ccosh (710.5 + 0.75 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: ccosh (710.5 - 0.75 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: ccosh (89.5 + 0.75 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (89.5 - 0.75 i)":
+float: 1
+ifloat: 1
+
+# cexp
+Test "Imaginary part of: cexp (-2.0 - 3.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cexp (-95 + 0.75 i)":
+double: 1
+idouble: 1
+Test "Real part of: cexp (0.75 + 1.25 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cexp (1440 + 0x1p-1074 i)":
+double: 1
+idouble: 1
+Test "Real part of: cexp (50 + 0x1p127 i)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "Imaginary part of: cexp (50 + 0x1p127 i)":
+double: 1
+idouble: 1
+Test "Real part of: cexp (500 + 0x1p1023 i)":
+double: 1
+idouble: 1
+Test "Real part of: cexp (709.8125 + 0.75 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cexp (709.8125 + 0.75 i)":
+double: 1
+idouble: 1
+Test "Real part of: cexp (88.75 + 0.75 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cexp (88.75 + 0.75 i)":
+float: 2
+ifloat: 2
+
+# clog
+Test "Real part of: clog (-0x1.0000000123456p0 + 0x1.2345678p-1000 i)":
+double: 1
+idouble: 1
+Test "Real part of: clog (-0x1.0000000123456p0 + 0x1.2345678p-30 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog (-0x1.234566p-40 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog (-0x1.fp+127 + 0x1p-149 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog (-0x1.fp+127 - 0x1p-149 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog (-0x1p-149 + 0x1.fp+127 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog (-0x1p-149 + 0x1.fp+127 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog (-0x1p-149 - 0x1.fp+127 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog (-0x1p-149 - 0x1.fp+127 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog (0x0.ffffffp0 + 0x0.ffffffp-100 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog (0x1.000566p0 + 0x1.234p-10 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog (0x1.fp+127 + 0x1p-149 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog (0x1.fp+127 - 0x1p-149 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog (0x1p-1074 + 0x1p-1074 i)":
+double: 1
+idouble: 1
+Test "Real part of: clog (0x1p-147 + 0x1p-147 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog (0x1p-149 + 0x1.fp+127 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog (0x1p-149 - 0x1.fp+127 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog (0x2818p-15 + 0x798fp-15 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog (1.0 + 0x1.234566p-10 i)":
+float: 1
+ifloat: 1
+
+# clog10
+Test "Imaginary part of: clog10 (-0 + inf i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-0 - inf i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: clog10 (-0x1.0000000123456p0 + 0x1.2345678p-1000 i)":
+double: 2
+idouble: 2
+Test "Imaginary part of: clog10 (-0x1.0000000123456p0 + 0x1.2345678p-1000 i)":
+double: 1
+idouble: 1
+Test "Real part of: clog10 (-0x1.0000000123456p0 + 0x1.2345678p-30 i)":
+double: 2
+idouble: 2
+Test "Imaginary part of: clog10 (-0x1.0000000123456p0 + 0x1.2345678p-30 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-0x1.fp+1023 + 0x1p-1074 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-0x1.fp+1023 - 0x1p-1074 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-0x1.fp+127 + 0x1p-149 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-0x1.fp+127 - 0x1p-149 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-0x1p-1074 + 0x1.fp+1023 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-0x1p-1074 - 0x1.fp+1023 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-0x1p-149 + 0x1.fp+127 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-0x1p-149 - 0x1.fp+127 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-1.0 + 0x1.234566p-20 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-2 - 3 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-3 + inf i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-3 - inf i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 1 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + inf i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-inf - 0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 1 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 + inf i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 - inf i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: clog10 (0x0.fffffffffffff8p0 + 0x0.fffffffffffff8p-1000 i)":
+double: 1
+idouble: 1
+Test "Real part of: clog10 (0x0.ffffffp0 + 0x0.ffffffp-100 i)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "Real part of: clog10 (0x1.000566p0 + 0x1.234p-10 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1.000566p0 + 0x1.234p-10 i)":
+double: 1
+idouble: 1
+Test "Real part of: clog10 (0x1.000566p0 + 0x1.234p-100 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1.234566p-30 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1.234566p-50 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1.234566p-60 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1.fffffep+127 + 0x1.fffffep+127 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: clog10 (0x1.fffffep+127 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1.fffffffffffffp+1023 + 0x1.fffffffffffffp+1023 i)":
+double: 1
+idouble: 1
+Test "Real part of: clog10 (0x10673dd0f2481p-51 + 0x7ef1d17cefbd2p-51 i)":
+double: 1
+idouble: 1
+Test "Real part of: clog10 (0x1367a310575591p-54 + 0x3cfcc0a0541f60p-54 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x1367a310575591p-54 + 0x3cfcc0a0541f60p-54 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x164c74eea876p-45 + 0x16f393482f77p-45 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x1a6p-10 + 0x3a5p-10 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x1p-1073 + 0x1p-1073 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x1p-1074 + 0x1.fp+1023 i)":
+double: 1
+idouble: 1
+Test "Real part of: clog10 (0x1p-1074 + 0x1p-1074 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x1p-1074 + 0x1p-1074 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x1p-1074 - 0x1.fp+1023 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x1p-147 + 0x1p-147 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1p-149 + 0x1.fp+127 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1p-149 + 0x1p-149 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1p-149 - 0x1.fp+127 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1p-509 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x1p-510 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x1p-511 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x1p-61 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1p-62 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1p-63 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: clog10 (0x2818p-15 + 0x798fp-15 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x2818p-15 + 0x798fp-15 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog10 (0x2dd46725bp-35 + 0x7783a1284p-35 i)":
+double: 1
+idouble: 1
+Test "Real part of: clog10 (0x2ede88p-23 + 0x771c3fp-23 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x2ede88p-23 + 0x771c3fp-23 i)":
+double: 1
+idouble: 1
+Test "Real part of: clog10 (0x4447d7175p-35 + 0x6c445e00ap-35 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x5b06b680ea2ccp-52 + 0xef452b965da9fp-52 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x9b57bp-20 + 0xcb7b4p-20 i)":
+double: 1
+idouble: 1
+Test "Real part of: clog10 (0xf2p-10 + 0x3e3p-10 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0xf2p-10 + 0x3e3p-10 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0xfe961079616p-45 + 0x1bc37e09e6d1p-45 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (1.0 + 0x1.234566p-10 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (3 + inf i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 - inf i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf + inf i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf - inf i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# cos
+Test "cos (0x1p+120)":
+float: 1
+ifloat: 1
+Test "cos (0x1p+127)":
+float: 1
+ifloat: 1
+Test "cos (M_PI_6l * 2.0) == 0.5":
+double: 1
+idouble: 1
+ifloat: 1
+Test "cos (M_PI_6l * 4.0) == -0.5":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+# cos_downward
+Test "cos_downward (1)":
+float: 1
+ifloat: 1
+Test "cos_downward (2)":
+float: 1
+ifloat: 1
+Test "cos_downward (3)":
+float: 1
+ifloat: 1
+Test "cos_downward (4)":
+float: 1
+ifloat: 1
+Test "cos_downward (5)":
+float: 1
+ifloat: 1
+Test "cos_downward (7)":
+float: 1
+ifloat: 1
+Test "cos_downward (8)":
+float: 1
+ifloat: 1
+
+# cos_tonearest
+Test "cos_tonearest (7)":
+float: 1
+ifloat: 1
+
+# cos_towardzero
+Test "cos_towardzero (2)":
+float: 1
+ifloat: 1
+Test "cos_towardzero (3)":
+float: 1
+ifloat: 1
+Test "cos_towardzero (5)":
+float: 1
+ifloat: 1
+Test "cos_towardzero (7)":
+float: 1
+ifloat: 1
+Test "cos_towardzero (8)":
+float: 1
+ifloat: 1
+
+# cos_upward
+Test "cos_upward (10)":
+float: 1
+ifloat: 1
+Test "cos_upward (6)":
+float: 1
+ifloat: 1
+Test "cos_upward (7)":
+float: 1
+ifloat: 1
+Test "cos_upward (9)":
+float: 2
+ifloat: 2
+
+# cosh_downward
+Test "cosh_downward (22)":
+float: 1
+ifloat: 1
+Test "cosh_downward (23)":
+float: 1
+ifloat: 1
+Test "cosh_downward (24)":
+float: 1
+ifloat: 1
+
+# cosh_towardzero
+Test "cosh_towardzero (22)":
+float: 1
+ifloat: 1
+Test "cosh_towardzero (23)":
+float: 1
+ifloat: 1
+Test "cosh_towardzero (24)":
+float: 1
+ifloat: 1
+
+# cpow
+Test "Real part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i)":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i)":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+Test "Real part of: cpow (2 + 3 i, 4 + 0 i)":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i)":
+float: 2
+ifloat: 2
+
+# csin
+Test "Real part of: csin (-0.75 + 710.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: csin (-0.75 + 89.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: csin (-0.75 - 710.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: csin (-0.75 - 89.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: csin (0.75 + 710.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: csin (0.75 + 89.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: csin (0.75 - 710.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: csin (0.75 - 89.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: csin (0x1p-1074 + 1440 i)":
+double: 1
+idouble: 1
+
+# csinh
+Test "Imaginary part of: csinh (-2 - 3 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: csinh (-710.5 + 0.75 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: csinh (-710.5 - 0.75 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: csinh (-89.5 + 0.75 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csinh (-89.5 - 0.75 i)":
+float: 1
+ifloat: 1
+Test "Real part of: csinh (0.75 + 1.25 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csinh (0.75 + 1.25 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csinh (1440 + 0x1p-1074 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: csinh (710.5 + 0.75 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: csinh (710.5 - 0.75 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: csinh (89.5 + 0.75 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csinh (89.5 - 0.75 i)":
+float: 1
+ifloat: 1
+
+# csqrt
+Test "Real part of: csqrt (-0x1.000002p-126 - 0x1.000002p-126 i)":
+double: 1
+idouble: 1
+Test "Real part of: csqrt (-2 + 3 i)":
+float: 1
+ifloat: 1
+Test "Real part of: csqrt (-2 - 3 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csqrt (0x1.000002p-126 + 0x1.000002p-126 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: csqrt (0x1.fffffep+127 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: csqrt (0x1.fffffffffffffp+1023 + 0x1.fffffffffffffp+1023 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: csqrt (0x1.fffffffffffffp+1023 + 0x1.fffffffffffffp+1023 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: csqrt (0x1.fffffffffffffp+1023 + 0x1p+1023 i)":
+double: 1
+idouble: 1
+
+# ctan
+Test "Real part of: ctan (-2 - 3 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ctan (-2 - 3 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: ctan (0.75 + 1.25 i)":
+double: 1
+idouble: 1
+Test "Real part of: ctan (0x1p1023 + 1 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: ctan (0x1p127 + 1 i)":
+double: 1
+idouble: 1
+Test "Real part of: ctan (0x3.243f6cp-1 + 0 i)":
+float: 1
+ifloat: 1
+
+# ctan_downward
+Test "Real part of: ctan_downward (0x1.921fb6p+0 + 0x1p-149 i)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "Imaginary part of: ctan_downward (0x1.921fb6p+0 + 0x1p-149 i)":
+float: 1
+ifloat: 1
+
+# ctan_tonearest
+Test "Real part of: ctan_tonearest (0x1.921fb6p+0 + 0x1p-149 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ctan_tonearest (0x1.921fb6p+0 + 0x1p-149 i)":
+float: 1
+ifloat: 1
+
+# ctan_towardzero
+Test "Real part of: ctan_towardzero (0x1.921fb6p+0 + 0x1p-149 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ctan_towardzero (0x1.921fb6p+0 + 0x1p-149 i)":
+float: 1
+ifloat: 1
+
+# ctan_upward
+Test "Real part of: ctan_upward (0x1.921fb54442d18p+0 + 0x1p-1074 i)":
+double: 1
+idouble: 1
+Test "Real part of: ctan_upward (0x1.921fb6p+0 + 0x1p-149 i)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "Imaginary part of: ctan_upward (0x1.921fb6p+0 + 0x1p-149 i)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# ctanh
+Test "Real part of: ctanh (-2 - 3 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ctanh (-2 - 3 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ctanh (0 + 0x3.243f6cp-1 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ctanh (0 + pi/4 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: ctanh (0.75 + 1.25 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ctanh (0.75 + 1.25 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: ctanh (1 + 0x1p1023 i)":
+double: 1
+idouble: 1
+Test "Real part of: ctanh (1 + 0x1p127 i)":
+double: 1
+idouble: 1
+
+# ctanh_downward
+Test "Real part of: ctanh_downward (0x1p-149 + 0x1.921fb6p+0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ctanh_downward (0x1p-149 + 0x1.921fb6p+0 i)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+# ctanh_tonearest
+Test "Real part of: ctanh_tonearest (0x1p-149 + 0x1.921fb6p+0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ctanh_tonearest (0x1p-149 + 0x1.921fb6p+0 i)":
+float: 1
+ifloat: 1
+
+# ctanh_towardzero
+Test "Real part of: ctanh_towardzero (0x1p-149 + 0x1.921fb6p+0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ctanh_towardzero (0x1p-149 + 0x1.921fb6p+0 i)":
+float: 1
+ifloat: 1
+
+# ctanh_upward
+Test "Imaginary part of: ctanh_upward (0x1p-1074 + 0x1.921fb54442d18p+0 i)":
+double: 1
+idouble: 1
+Test "Real part of: ctanh_upward (0x1p-149 + 0x1.921fb6p+0 i)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "Imaginary part of: ctanh_upward (0x1p-149 + 0x1.921fb6p+0 i)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+# erf
+Test "erf (0.75) == 0.711155633653515131598937834591410777":
+double: 1
+idouble: 1
+Test "erf (1.25) == 0.922900128256458230136523481197281140":
+double: 1
+idouble: 1
+
+# erfc
+Test "erfc (0x1.f7303cp+1)":
+double: 1
+idouble: 1
+Test "erfc (0x1.ffa002p+2)":
+float: 1
+ifloat: 1
+Test "erfc (2.0)":
+double: 1
+idouble: 1
+Test "erfc (4.125) == 0.542340079956506600531223408575531062e-8":
+double: 1
+idouble: 1
+
+# exp
+Test "exp (1) == e":
+double: 1
+idouble: 1
+
+# exp10
+Test "exp10 (-1)":
+double: 1
+idouble: 1
+Test "exp10 (-305)":
+double: 1
+idouble: 1
+Test "exp10 (-36)":
+double: 1
+idouble: 1
+Test "exp10 (3)":
+double: 1
+idouble: 1
+Test "exp10 (36)":
+double: 1
+idouble: 1
+
+# exp_downward
+Test "exp_downward (2)":
+float: 1
+ifloat: 1
+Test "exp_downward (3)":
+float: 1
+ifloat: 1
+
+# exp_towardzero
+Test "exp_towardzero (2)":
+float: 1
+ifloat: 1
+Test "exp_towardzero (3)":
+float: 1
+ifloat: 1
+
+# exp_upward
+Test "exp_upward (1)":
+float: 1
+ifloat: 1
+
+# expm1
+Test "expm1 (0.75) == 1.11700001661267466854536981983709561":
+double: 1
+idouble: 1
+Test "expm1 (1)":
+float: 1
+ifloat: 1
+Test "expm1 (500.0)":
+double: 1
+idouble: 1
+
+# gamma
+Test "gamma (0.7)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "gamma (1.2)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# hypot
+Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+
+# j0
+Test "j0 (-4.0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (0.75)":
+float: 1
+ifloat: 1
+Test "j0 (0x1.d7ce3ap+107)":
+float: 2
+ifloat: 2
+Test "j0 (10.0)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "j0 (2.0)":
+float: 2
+ifloat: 2
+Test "j0 (4.0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (8.0)":
+float: 1
+ifloat: 1
+
+# j1
+Test "j1 (0x1.3ffp+74)":
+double: 1
+idouble: 1
+Test "j1 (0x1.ff00000000002p+840)":
+double: 1
+idouble: 1
+Test "j1 (10.0)":
+float: 2
+ifloat: 2
+Test "j1 (2.0)":
+double: 1
+idouble: 1
+Test "j1 (8.0)":
+double: 1
+idouble: 1
+
+# jn
+Test "jn (0, -4.0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 0.75)":
+float: 1
+ifloat: 1
+Test "jn (0, 10.0)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "jn (0, 2.0)":
+float: 2
+ifloat: 2
+Test "jn (0, 4.0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 8.0)":
+float: 1
+ifloat: 1
+Test "jn (1, 10.0)":
+float: 2
+ifloat: 2
+Test "jn (1, 2.0)":
+double: 1
+idouble: 1
+Test "jn (1, 8.0)":
+double: 1
+idouble: 1
+Test "jn (10, 0.125)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (10, 0.75)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (10, 10.0)":
+double: 4
+float: 3
+idouble: 4
+ifloat: 3
+Test "jn (10, 2.0)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "jn (2, 0x1.ffff62p+99)":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+Test "jn (2, 2.4048255576957729)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "jn (3, 0.125)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 0.75)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 10.0)":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "jn (3, 2.0)":
+float: 1
+ifloat: 1
+Test "jn (3, 2.4048255576957729)":
+double: 3
+idouble: 3
+Test "jn (4, 2.4048255576957729)":
+double: 1
+idouble: 1
+Test "jn (5, 2.4048255576957729)":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "jn (6, 2.4048255576957729)":
+double: 4
+float: 3
+idouble: 4
+ifloat: 3
+Test "jn (7, 2.4048255576957729)":
+double: 3
+float: 5
+idouble: 3
+ifloat: 5
+Test "jn (8, 2.4048255576957729)":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+Test "jn (9, 2.4048255576957729)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# lgamma
+Test "lgamma (0.7) == 0.260867246531666514385732417016759578":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# log10
+Test "log10 (0.75) == -0.124938736608299953132449886193870744":
+double: 1
+idouble: 1
+Test "log10 (e) == log10(e)":
+float: 1
+ifloat: 1
+
+# log1p
+Test "log1p (-0.25)":
+float: 1
+ifloat: 1
+
+# pow
+Test "pow (0x0.ffffffp0, -0x1p24)":
+float: 1
+ifloat: 1
+Test "pow (0x0.ffffffp0, 0x1p24)":
+float: 1
+ifloat: 1
+Test "pow (0x1.000002p0, 0x1p24)":
+float: 1
+ifloat: 1
+
+# pow10
+Test "pow10 (-1)":
+double: 1
+idouble: 1
+Test "pow10 (-305)":
+double: 1
+idouble: 1
+Test "pow10 (-36)":
+double: 1
+idouble: 1
+Test "pow10 (3)":
+double: 1
+idouble: 1
+Test "pow10 (36)":
+double: 1
+idouble: 1
+
+# pow_downward
+Test "pow_downward (1.5, 1.03125)":
+float: 1
+ifloat: 1
+
+# pow_towardzero
+Test "pow_towardzero (1.5, 1.03125)":
+float: 1
+ifloat: 1
+
+# pow_upward
+Test "pow_upward (1.0625, 1.125)":
+float: 1
+ifloat: 1
+
+# sin_downward
+Test "sin_downward (10)":
+float: 1
+ifloat: 1
+Test "sin_downward (3)":
+float: 1
+ifloat: 1
+Test "sin_downward (5)":
+float: 1
+ifloat: 1
+Test "sin_downward (6)":
+float: 1
+ifloat: 1
+
+# sin_tonearest
+Test "sin_tonearest (1)":
+float: 1
+ifloat: 1
+
+# sin_towardzero
+Test "sin_towardzero (1)":
+float: 1
+ifloat: 1
+Test "sin_towardzero (10)":
+float: 1
+ifloat: 1
+Test "sin_towardzero (4)":
+float: 1
+ifloat: 1
+Test "sin_towardzero (5)":
+float: 1
+ifloat: 1
+Test "sin_towardzero (9)":
+float: 1
+ifloat: 1
+
+# sin_upward
+Test "sin_upward (1)":
+float: 1
+ifloat: 1
+Test "sin_upward (2)":
+float: 2
+ifloat: 2
+Test "sin_upward (4)":
+float: 1
+ifloat: 1
+Test "sin_upward (9)":
+float: 1
+ifloat: 1
+
+# sincos
+Test "sincos (0x1p+120) extra output 2":
+float: 1
+ifloat: 1
+Test "sincos (0x1p+127) extra output 2":
+float: 1
+ifloat: 1
+Test "sincos (M_PI_6l*2.0) extra output 1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (M_PI_6l*2.0) extra output 2":
+double: 1
+idouble: 1
+Test "sincos (pi/6) extra output 2":
+float: 1
+ifloat: 1
+
+# sinh_downward
+Test "sinh_downward (22)":
+float: 1
+ifloat: 1
+Test "sinh_downward (23)":
+float: 1
+ifloat: 1
+Test "sinh_downward (24)":
+float: 1
+ifloat: 1
+
+# sinh_towardzero
+Test "sinh_towardzero (22)":
+float: 1
+ifloat: 1
+Test "sinh_towardzero (23)":
+float: 1
+ifloat: 1
+Test "sinh_towardzero (24)":
+float: 1
+ifloat: 1
+
+# tan_downward
+Test "tan_downward (1)":
+float: 1
+ifloat: 1
+Test "tan_downward (10)":
+float: 1
+ifloat: 1
+Test "tan_downward (2)":
+float: 1
+ifloat: 1
+Test "tan_downward (6)":
+float: 1
+ifloat: 1
+Test "tan_downward (8)":
+float: 1
+ifloat: 1
+Test "tan_downward (9)":
+float: 1
+ifloat: 1
+
+# tan_towardzero
+Test "tan_towardzero (10)":
+float: 1
+ifloat: 1
+Test "tan_towardzero (3)":
+float: 1
+ifloat: 1
+Test "tan_towardzero (4)":
+float: 1
+ifloat: 1
+Test "tan_towardzero (5)":
+float: 1
+ifloat: 1
+Test "tan_towardzero (9)":
+float: 1
+ifloat: 1
+
+# tan_upward
+Test "tan_upward (1)":
+float: 1
+ifloat: 1
+Test "tan_upward (10)":
+float: 1
+ifloat: 1
+Test "tan_upward (3)":
+float: 1
+ifloat: 1
+Test "tan_upward (5)":
+float: 1
+ifloat: 1
+
+# tgamma
+Test "tgamma (-0.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (-0.5) == -2 sqrt (pi)":
+double: 1
+idouble: 1
+Test "tgamma (-0x0.fffffffffffff8p0)":
+double: 1
+idouble: 1
+Test "tgamma (-0x0.ffffffp0)":
+float: 1
+ifloat: 1
+Test "tgamma (-0x1.000002p0)":
+double: 2
+idouble: 2
+Test "tgamma (-0x1.0a32a2p+5)":
+float: 2
+ifloat: 2
+Test "tgamma (-0x13.ffffep0)":
+float: 2
+ifloat: 2
+Test "tgamma (-0x14.000000000001p0)":
+double: 1
+idouble: 1
+Test "tgamma (-0x14.00002p0)":
+float: 1
+ifloat: 1
+Test "tgamma (-0x1d.ffffep0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (-0x1e.000000000001p0)":
+double: 3
+idouble: 3
+Test "tgamma (-0x1e.00002p0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (-0x2.0000000000002p0)":
+double: 1
+idouble: 1
+Test "tgamma (-0x2.000004p0)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "tgamma (-0x2.fffffcp0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (-0x27.fffffffffffep0)":
+double: 1
+idouble: 1
+Test "tgamma (-0x28.000000000002p0)":
+double: 1
+idouble: 1
+Test "tgamma (-0x28.00004p0)":
+double: 2
+idouble: 2
+Test "tgamma (-0x29.00004p0)":
+double: 1
+idouble: 1
+Test "tgamma (-0x29.ffffcp0)":
+double: 1
+idouble: 1
+Test "tgamma (-0x3.000004p0)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "tgamma (-0x3.fffffcp0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (-0x3.ffffffffffffep0)":
+double: 2
+idouble: 2
+Test "tgamma (-0x31.fffffffffffep0)":
+double: 3
+idouble: 3
+Test "tgamma (-0x4.000008p0)":
+float: 1
+ifloat: 1
+Test "tgamma (-0x4.fffff8p0)":
+double: 1
+idouble: 1
+Test "tgamma (-0x4.ffffffffffffcp0)":
+double: 1
+idouble: 1
+Test "tgamma (-0x5.000008p0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (-0x5.ffffffffffffcp0)":
+double: 1
+idouble: 1
+Test "tgamma (-0x6.000008p0)":
+float: 2
+ifloat: 2
+Test "tgamma (-0x6.fffff8p0)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "tgamma (-0x6.ffffffffffffcp0)":
+double: 4
+idouble: 4
+Test "tgamma (-0x63.fffffffffffcp0)":
+double: 2
+idouble: 2
+Test "tgamma (-0x64.000000000004p0)":
+double: 1
+idouble: 1
+Test "tgamma (-0x7.0000000000004p0)":
+double: 3
+idouble: 3
+Test "tgamma (-0x7.000008p0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (-0x7.fffff8p0)":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "tgamma (-0x7.ffffffffffffcp0)":
+double: 3
+idouble: 3
+Test "tgamma (-0x8.00001p0)":
+double: 2
+idouble: 2
+Test "tgamma (-0x9.ffffffffffff8p0)":
+double: 1
+idouble: 1
+Test "tgamma (-0x9.fffffp0)":
+float: 1
+ifloat: 1
+Test "tgamma (-0x96.000000000008p0)":
+double: 1
+idouble: 1
+Test "tgamma (-0xa.00001p0)":
+double: 1
+idouble: 1
+Test "tgamma (-2.5)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "tgamma (-3.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (-4.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (-5.5)":
+double: 1
+idouble: 1
+Test "tgamma (-6.5)":
+float: 1
+ifloat: 1
+Test "tgamma (-7.5)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "tgamma (-8.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (-9.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (0.5)":
+float: 1
+ifloat: 1
+Test "tgamma (0.7)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (0.7) == 1.29805533264755778568117117915281162":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (0x1.fffffep0)":
+float: 1
+ifloat: 1
+Test "tgamma (0x1.fffffffffffffp0)":
+double: 1
+idouble: 1
+Test "tgamma (0x1p-24)":
+float: 1
+ifloat: 1
+Test "tgamma (0x1p-53)":
+double: 1
+idouble: 1
+Test "tgamma (0x2.30a43cp+4)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "tgamma (0x2.fffffcp0)":
+float: 3
+ifloat: 3
+Test "tgamma (0x3.fffffcp0)":
+float: 1
+ifloat: 1
+Test "tgamma (0x3.ffffffffffffep0)":
+double: 1
+idouble: 1
+Test "tgamma (0x4.0000000000004p0)":
+double: 1
+idouble: 1
+Test "tgamma (0x4.ffffffffffffcp0)":
+double: 1
+idouble: 1
+Test "tgamma (0x5.0000000000004p0)":
+double: 1
+idouble: 1
+Test "tgamma (0x5.000008p0)":
+float: 2
+ifloat: 2
+Test "tgamma (0x5.fffff8p0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (0x6.0000000000004p0)":
+double: 1
+idouble: 1
+Test "tgamma (0x6.000008p0)":
+float: 2
+ifloat: 2
+Test "tgamma (0x6.fffff8p0)":
+double: 1
+idouble: 1
+Test "tgamma (0x6.ffffffffffffcp0)":
+double: 4
+idouble: 4
+Test "tgamma (0x7.0000000000004p0)":
+double: 4
+idouble: 4
+Test "tgamma (0x7.000008p0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (0x7.fffff8p0)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "tgamma (0x7.ffffffffffffcp0)":
+double: 2
+idouble: 2
+Test "tgamma (0x8.00001p0)":
+double: 2
+idouble: 2
+Test "tgamma (0xa.b9fd72b0fb238p+4)":
+double: 1
+idouble: 1
+Test "tgamma (10)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (18.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (19.5)":
+double: 2
+idouble: 2
+Test "tgamma (2.5)":
+float: 2
+ifloat: 2
+Test "tgamma (23.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (29.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (3)":
+float: 1
+ifloat: 1
+Test "tgamma (3.5)":
+float: 2
+ifloat: 2
+Test "tgamma (30.5)":
+float: 1
+ifloat: 1
+Test "tgamma (33.5)":
+float: 1
+ifloat: 1
+Test "tgamma (34.5)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "tgamma (4)":
+float: 1
+ifloat: 1
+Test "tgamma (4.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (6)":
+float: 1
+ifloat: 1
+Test "tgamma (6.5)":
+float: 1
+ifloat: 1
+Test "tgamma (7)":
+double: 1
+idouble: 1
+Test "tgamma (7.5)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "tgamma (8)":
+double: 1
+idouble: 1
+Test "tgamma (8.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (9)":
+double: 1
+idouble: 1
+Test "tgamma (9.5)":
+double: 1
+idouble: 1
+
+# y0
+Test "y0 (0x1.3ffp+74)":
+double: 1
+idouble: 1
+Test "y0 (0x1.ff00000000002p+840)":
+double: 1
+idouble: 1
+Test "y0 (0x1p-10)":
+double: 1
+idouble: 1
+Test "y0 (0x1p-110)":
+double: 1
+idouble: 1
+Test "y0 (0x1p-20)":
+float: 1
+ifloat: 1
+Test "y0 (0x1p-30)":
+float: 1
+ifloat: 1
+Test "y0 (0x1p-40)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "y0 (0x1p-50)":
+float: 1
+ifloat: 1
+Test "y0 (0x1p-70)":
+double: 1
+idouble: 1
+Test "y0 (0x1p-80)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "y0 (1.0)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (1.5)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (10.0)":
+float: 1
+ifloat: 1
+Test "y0 (8.0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# y1
+Test "y1 (0.125)":
+double: 1
+idouble: 1
+Test "y1 (0x1.27e204p+99)":
+double: 1
+idouble: 1
+Test "y1 (0x1p-10)":
+double: 1
+idouble: 1
+Test "y1 (1.5)":
+float: 1
+ifloat: 1
+Test "y1 (10.0)":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "y1 (2.0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "y1 (8.0)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# yn
+Test "yn (0, 1.0)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 1.5)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 10.0)":
+float: 1
+ifloat: 1
+Test "yn (0, 8.0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (1, 0.125)":
+double: 1
+idouble: 1
+Test "yn (1, 1.5)":
+float: 1
+ifloat: 1
+Test "yn (1, 10.0)":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "yn (1, 2.0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (1, 8.0)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "yn (10, 0.125)":
+double: 1
+idouble: 1
+Test "yn (10, 0.75)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (10, 1.0)":
+double: 1
+idouble: 1
+Test "yn (10, 10.0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (10, 2.0)":
+double: 2
+idouble: 2
+Test "yn (3, 0.125)":
+double: 1
+idouble: 1
+Test "yn (3, 0.75)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 10.0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 2.0)":
+double: 1
+idouble: 1
+
+# Maximal error of functions:
+Function: "acos_downward":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "acos_towardzero":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "asin_downward":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "asin_towardzero":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "asin_upward":
+float: 1
+ifloat: 1
+
+Function: "atan2":
+float: 1
+ifloat: 1
+
+Function: "atanh":
+float: 1
+ifloat: 1
+
+Function: Real part of "cacos":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Imaginary part of "cacos":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Real part of "cacosh":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Imaginary part of "cacosh":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Real part of "casin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "casin":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Real part of "casinh":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Imaginary part of "casinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "catan":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "catan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "catanh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "catanh":
+float: 1
+ifloat: 1
+
+Function: "cbrt":
+double: 1
+idouble: 1
+
+Function: Real part of "ccos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "cexp":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: Imaginary part of "cexp":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Real part of "clog":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "clog":
+float: 1
+ifloat: 1
+
+Function: Real part of "clog10":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: Imaginary part of "clog10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "cos":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: "cos_downward":
+float: 1
+ifloat: 1
+
+Function: "cos_tonearest":
+float: 1
+ifloat: 1
+
+Function: "cos_towardzero":
+float: 1
+ifloat: 1
+
+Function: "cos_upward":
+float: 2
+ifloat: 2
+
+Function: "cosh_downward":
+float: 1
+ifloat: 1
+
+Function: "cosh_towardzero":
+float: 1
+ifloat: 1
+
+Function: Real part of "cpow":
+double: 2
+float: 4
+idouble: 2
+ifloat: 4
+
+Function: Imaginary part of "cpow":
+float: 2
+ifloat: 2
+
+Function: Real part of "csin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "csinh":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "csqrt":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "csqrt":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "ctan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ctan":
+double: 1
+idouble: 1
+
+Function: Real part of "ctan_downward":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: Imaginary part of "ctan_downward":
+float: 1
+ifloat: 1
+
+Function: Real part of "ctan_tonearest":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "ctan_tonearest":
+float: 1
+ifloat: 1
+
+Function: Real part of "ctan_towardzero":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "ctan_towardzero":
+float: 1
+ifloat: 1
+
+Function: Real part of "ctan_upward":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: Imaginary part of "ctan_upward":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Real part of "ctanh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ctanh":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Real part of "ctanh_downward":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "ctanh_downward":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: Real part of "ctanh_tonearest":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "ctanh_tonearest":
+float: 1
+ifloat: 1
+
+Function: Real part of "ctanh_towardzero":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "ctanh_towardzero":
+float: 1
+ifloat: 1
+
+Function: Real part of "ctanh_upward":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Imaginary part of "ctanh_upward":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: "erf":
+double: 1
+idouble: 1
+
+Function: "erfc":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "exp":
+double: 1
+idouble: 1
+
+Function: "exp10":
+double: 1
+idouble: 1
+
+Function: "exp_downward":
+float: 1
+ifloat: 1
+
+Function: "exp_towardzero":
+float: 1
+ifloat: 1
+
+Function: "exp_upward":
+float: 1
+ifloat: 1
+
+Function: "expm1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "gamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "hypot":
+float: 1
+ifloat: 1
+
+Function: "j0":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: "j1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "jn":
+double: 4
+float: 5
+idouble: 4
+ifloat: 5
+
+Function: "lgamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "log":
+float: 1
+ifloat: 1
+
+Function: "log10":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "log1p":
+float: 1
+ifloat: 1
+
+Function: "pow":
+float: 1
+ifloat: 1
+
+Function: "pow10":
+double: 1
+idouble: 1
+
+Function: "pow_downward":
+float: 1
+ifloat: 1
+
+Function: "pow_towardzero":
+float: 1
+ifloat: 1
+
+Function: "pow_upward":
+float: 1
+ifloat: 1
+
+Function: "sin_downward":
+float: 1
+ifloat: 1
+
+Function: "sin_tonearest":
+float: 1
+ifloat: 1
+
+Function: "sin_towardzero":
+float: 1
+ifloat: 1
+
+Function: "sin_upward":
+float: 2
+ifloat: 2
+
+Function: "sincos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "sinh_downward":
+float: 1
+ifloat: 1
+
+Function: "sinh_towardzero":
+float: 1
+ifloat: 1
+
+Function: "tan":
+double: 1
+idouble: 1
+
+Function: "tan_downward":
+float: 1
+ifloat: 1
+
+Function: "tan_towardzero":
+float: 1
+ifloat: 1
+
+Function: "tan_upward":
+float: 1
+ifloat: 1
+
+Function: "tgamma":
+double: 4
+float: 3
+idouble: 4
+ifloat: 3
+
+Function: "y0":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: "y1":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+
+Function: "yn":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+
+# end of automatic generation
diff --git a/test/math/libm-test-ulps-cris b/test/math/libm-test-ulps-cris
new file mode 100644
index 000000000..46b2ac559
--- /dev/null
+++ b/test/math/libm-test-ulps-cris
@@ -0,0 +1,145 @@
+# Begin of automatic generation
+
+# cos
+Test "cos (M_PI_6l * 2.0) == 0.5":
+double: 1
+idouble: 1
+Test "cos (M_PI_6l * 4.0) == -0.5":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+# erf
+Test "erf (0.75) == 0.711155633653515131598937834591410777":
+double: 1
+idouble: 1
+Test "erf (1.25) == 0.922900128256458230136523481197281140":
+double: 1
+idouble: 1
+
+# erfc
+Test "erfc (4.125) == 0.542340079956506600531223408575531062e-8":
+double: 1
+idouble: 1
+
+# exp
+Test "exp (1) == e":
+double: 1
+idouble: 1
+
+# expm1
+Test "expm1 (0.75) == 1.11700001661267466854536981983709561":
+double: 1
+idouble: 1
+
+# hypot
+Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+
+# lgamma
+Test "lgamma (0.7) == 0.260867246531666514385732417016759578":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# log10
+Test "log10 (0.75) == -0.124938736608299953132449886193870744":
+double: 1
+idouble: 1
+Test "log10 (e) == log10(e)":
+float: 1
+ifloat: 1
+
+# tgamma
+Test "tgamma (-0.5) == -2 sqrt (pi)":
+double: 1
+idouble: 1
+Test "tgamma (0.7) == 1.29805533264755778568117117915281162":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# Maximal error of functions:
+Function: "cos":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: "erf":
+double: 1
+idouble: 1
+
+Function: "erfc":
+double: 1
+idouble: 1
+
+Function: "exp":
+double: 1
+idouble: 1
+
+Function: "expm1":
+double: 1
+idouble: 1
+
+Function: "hypot":
+float: 1
+ifloat: 1
+
+Function: "lgamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "log":
+float: 1
+ifloat: 1
+
+Function: "log10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "tan":
+double: 1
+idouble: 1
+
+Function: "tgamma":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# end of automatic generation
diff --git a/test/math/libm-test-ulps-generic b/test/math/libm-test-ulps-generic
new file mode 100644
index 000000000..7cfa1f828
--- /dev/null
+++ b/test/math/libm-test-ulps-generic
@@ -0,0 +1,5 @@
+# File with deltas for math/libm-test
+# This file is the fallback and contains
+# no data
+# You can create a new file with e.g. `test-double -u'
+# followed by `gen-libm-test.pl -u ULPs -n'.
diff --git a/test/math/libm-test-ulps-i386 b/test/math/libm-test-ulps-i386
new file mode 100644
index 000000000..a6fd6ac24
--- /dev/null
+++ b/test/math/libm-test-ulps-i386
@@ -0,0 +1,1261 @@
+# Begin of automatic generation
+
+# acos
+Test "acos (0.75) == 0.722734247813415611178377352641333362":
+ildouble: 1
+ldouble: 1
+
+# asin
+Test "asin (-0.5) == -pi/6":
+ildouble: 1
+ldouble: 1
+Test "asin (-1.0) == -pi/2":
+ildouble: 1
+ldouble: 1
+Test "asin (0.5) == pi/6":
+ildouble: 1
+ldouble: 1
+Test "asin (0.75) == 0.848062078981481008052944338998418080":
+ildouble: 1
+ldouble: 1
+Test "asin (1.0) == pi/2":
+ildouble: 1
+ldouble: 1
+
+# atanh
+Test "atanh (0.75) == 0.972955074527656652552676371721589865":
+ildouble: 2
+ldouble: 1
+
+# cacos
+Test "Imaginary part of: cacos (0.75 + 1.25 i) == 1.11752014915610270578240049553777969 - 1.13239363160530819522266333696834467 i":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+# cacosh
+Test "Real part of: cacosh (-2 - 3 i) == 1.9833870299165354323470769028940395 - 2.1414491111159960199416055713254211 i":
+double: 1
+float: 9
+idouble: 1
+ifloat: 9
+ildouble: 6
+ldouble: 6
+Test "Imaginary part of: cacosh (-2 - 3 i) == 1.9833870299165354323470769028940395 - 2.1414491111159960199416055713254211 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0.75 + 1.25 i) == 1.13239363160530819522266333696834467 + 1.11752014915610270578240049553777969 i":
+ildouble: 1
+ldouble: 1
+
+# casin
+Test "Real part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+# casinh
+Test "Real part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+ildouble: 5
+ldouble: 5
+Test "Imaginary part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+ildouble: 5
+ldouble: 5
+Test "Real part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# catan
+Test "Imaginary part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# catanh
+Test "Real part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+double: 1
+idouble: 1
+
+# cbrt
+Test "cbrt (-27.0) == -3.0":
+ildouble: 1
+ldouble: 1
+Test "cbrt (0.75) == 0.908560296416069829445605878163630251":
+ildouble: 1
+ldouble: 1
+
+# ccos
+Test "Imaginary part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+ildouble: 1
+ldouble: 1
+
+# ccosh
+Test "Imaginary part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# cexp
+Test "Real part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+ildouble: 1
+ldouble: 1
+
+# clog
+Test "Real part of: clog (0.75 + 1.25 i) == 0.376885901188190075998919126749298416 + 1.03037682652431246378774332703115153 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# clog10
+Test "Imaginary part of: clog10 (-0 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-0 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (-3 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-3 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 0 i) == inf + pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 1 i) == inf + pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + inf i) == inf + 3/4 pi*log10(e) i":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-inf - 0 i) == inf - pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 1 i) == inf - pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (3 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf + inf i) == inf + pi/4*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf - inf i) == inf - pi/4*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# cos
+Test "cos (M_PI_6l * 2.0) == 0.5":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "cos (M_PI_6l * 4.0) == -0.5":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "cos (pi/2) == 0":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# cosh
+Test "cosh (0.75) == 1.29468328467684468784170818539018176":
+ildouble: 1
+
+# cpow
+Test "Real part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i":
+float: 3
+ifloat: 3
+ildouble: 6
+ldouble: 6
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 0.0 i) == 0.75 + 1.25 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 1.0 + 0.0 i) == 0.75 + 1.25 i":
+float: 1
+ifloat: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i) == 0.0846958290317209430433805274189191353 + 0.513285749182902449043287190519090481 i":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+ildouble: 3
+ldouble: 3
+Test "Real part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+ildouble: 1
+ldouble: 1
+
+# csin
+Test "Real part of: csin (0.75 + 1.25 i) == 1.28722291002649188575873510790565441 + 1.17210635989270256101081285116138863 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csin (0.75 + 1.25 i) == 1.28722291002649188575873510790565441 + 1.17210635989270256101081285116138863 i":
+float: 1
+ifloat: 1
+
+# csinh
+Test "Real part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Real part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+
+# ctan
+Test "Real part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+double: 1
+idouble: 1
+ildouble: 439
+ldouble: 439
+Test "Imaginary part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Real part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+
+# ctanh
+Test "Real part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+ildouble: 5
+ldouble: 5
+Test "Imaginary part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+float: 1
+ifloat: 1
+ildouble: 25
+ldouble: 25
+Test "Imaginary part of: ctanh (0 + pi/4 i) == 0.0 + 1.0 i":
+float: 1
+ifloat: 1
+Test "Real part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# erf
+Test "erf (1.25) == 0.922900128256458230136523481197281140":
+double: 1
+idouble: 1
+
+# erfc
+Test "erfc (0.75) == 0.288844366346484868401062165408589223":
+float: 1
+ifloat: 1
+Test "erfc (1.25) == 0.0770998717435417698634765188027188596":
+ildouble: 1
+ldouble: 1
+Test "erfc (2.0) == 0.00467773498104726583793074363274707139":
+double: 1
+idouble: 1
+Test "erfc (4.125) == 0.542340079956506600531223408575531062e-8":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+# exp
+Test "exp (0.75) == 2.11700001661267466854536981983709561":
+ildouble: 1
+Test "exp (1000.0) == 0.197007111401704699388887935224332313e435":
+ildouble: 754
+Test "exp (50.0) == 5184705528587072464087.45332293348538":
+ildouble: 16
+
+# exp10
+Test "exp10 (-1) == 0.1":
+ildouble: 1
+ldouble: 1
+Test "exp10 (0.75) == 5.62341325190349080394951039776481231":
+ildouble: 2
+ldouble: 2
+Test "exp10 (3) == 1000":
+ildouble: 8
+ldouble: 8
+
+# expm1
+Test "expm1 (1) == M_El - 1.0":
+ildouble: 1
+
+# gamma
+Test "gamma (-0.5) == log(2*sqrt(pi))":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+# hypot
+Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+
+# j0
+Test "j0 (-4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "j0 (10.0) == -0.245935764451348335197760862485328754":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "j0 (2.0) == 0.223890779141235668051827454649948626":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "j0 (8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+
+# j1
+Test "j1 (0.75) == 0.349243602174862192523281016426251335":
+double: 1
+idouble: 1
+Test "j1 (10.0) == 0.0434727461688614366697487680258592883":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "j1 (2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "j1 (8.0) == 0.234636346853914624381276651590454612":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# jn
+Test "jn (0, -4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "jn (0, 10.0) == -0.245935764451348335197760862485328754":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "jn (0, 2.0) == 0.223890779141235668051827454649948626":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "jn (0, 8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+Test "jn (1, 0.75) == 0.349243602174862192523281016426251335":
+double: 1
+idouble: 1
+Test "jn (1, 10.0) == 0.0434727461688614366697487680258592883":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (1, 2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "jn (1, 8.0) == 0.234636346853914624381276651590454612":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (10, -1.0) == 0.263061512368745320699785368779050294e-9":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (10, 0.125) == 0.250543369809369890173993791865771547e-18":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (10, 0.75) == 0.149621713117596814698712483621682835e-10":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "jn (10, 1.0) == 0.263061512368745320699785368779050294e-9":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (10, 10.0) == 0.207486106633358857697278723518753428":
+double: 5
+float: 2
+idouble: 5
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "jn (10, 2.0) == 0.251538628271673670963516093751820639e-6":
+double: 2
+idouble: 2
+ildouble: 1
+ldouble: 1
+Test "jn (3, -1.0) == -0.0195633539826684059189053216217515083":
+ildouble: 1
+ldouble: 1
+Test "jn (3, 0.75) == 0.848438342327410884392755236884386804e-2":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 1.0) == 0.0195633539826684059189053216217515083":
+ildouble: 1
+ldouble: 1
+Test "jn (3, 10.0) == 0.0583793793051868123429354784103409563":
+double: 5
+float: 2
+idouble: 5
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "jn (3, 2.0) == 0.128943249474402051098793332969239835":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+# lgamma
+Test "lgamma (-0.5) == log(2*sqrt(pi))":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "lgamma (0.7) == 0.260867246531666514385732417016759578":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# log
+Test "log (e) == 1":
+float: 1
+ifloat: 1
+
+# log10
+Test "log10 (0.75) == -0.124938736608299953132449886193870744":
+ildouble: 1
+ldouble: 1
+Test "log10 (e) == log10(e)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# sincos
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in sin_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "sincos (pi/2, &sin_res, &cos_res) puts 0 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# sin
+Test "sin (0.80190127184058835) == 0.71867942238767868":
+double: 1
+idouble: 1
+
+# sinh
+Test "sinh (0.75) == 0.822316731935829980703661634446913849":
+double: 1
+ildouble: 1
+
+# tan
+Test "tan (pi/4) == 1":
+double: 1
+idouble: 1
+
+# tgamma
+Test "tgamma (-0.5) == -2 sqrt (pi)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (0.5) == sqrt (pi)":
+float: 1
+ifloat: 1
+Test "tgamma (0.7) == 1.29805533264755778568117117915281162":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (4) == 6":
+ildouble: 1
+ldouble: 1
+
+# y0
+Test "y0 (0.125) == -1.38968062514384052915582277745018693":
+ildouble: 1
+ldouble: 1
+Test "y0 (0.75) == -0.137172769385772397522814379396581855":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "y0 (1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "y0 (1.5) == 0.382448923797758843955068554978089862":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "y0 (10.0) == 0.0556711672835993914244598774101900481":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "y0 (8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# y1
+Test "y1 (0.125) == -5.19993611253477499595928744876579921":
+ildouble: 1
+ldouble: 1
+Test "y1 (1.0) == -0.781212821300288716547150000047964821":
+double: 1
+idouble: 1
+Test "y1 (10.0) == 0.249015424206953883923283474663222803":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+Test "y1 (2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "y1 (8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# yn
+Test "yn (0, 0.125) == -1.38968062514384052915582277745018693":
+ildouble: 1
+ldouble: 1
+Test "yn (0, 0.75) == -0.137172769385772397522814379396581855":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (0, 1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (0, 1.5) == 0.382448923797758843955068554978089862":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (0, 10.0) == 0.0556711672835993914244598774101900481":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (0, 8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (1, 0.125) == -5.19993611253477499595928744876579921":
+ildouble: 1
+ldouble: 1
+Test "yn (1, 1.0) == -0.781212821300288716547150000047964821":
+double: 1
+idouble: 1
+Test "yn (1, 10.0) == 0.249015424206953883923283474663222803":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+Test "yn (1, 2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "yn (1, 8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "yn (10, 0.125) == -127057845771019398.252538486899753195":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "yn (10, 0.75) == -2133501638.90573424452445412893839236":
+float: 1
+ifloat: 1
+ildouble: 4
+ldouble: 4
+Test "yn (10, 1.0) == -121618014.278689189288130426667971145":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "yn (10, 10.0) == -0.359814152183402722051986577343560609":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+Test "yn (10, 2.0) == -129184.542208039282635913145923304214":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+Test "yn (3, 0.125) == -2612.69757350066712600220955744091741":
+ildouble: 1
+ldouble: 1
+Test "yn (3, 0.75) == -12.9877176234475433186319774484809207":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "yn (3, 10.0) == -0.251362657183837329779204747654240998":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 2.0) == -1.12778377684042778608158395773179238":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# Maximal error of functions:
+Function: "acos":
+ildouble: 622
+ldouble: 622
+
+Function: "asin":
+ildouble: 1
+ldouble: 1
+
+Function: "atanh":
+ildouble: 2
+ldouble: 1
+
+Function: Imaginary part of "cacos":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "cacosh":
+double: 1
+float: 9
+idouble: 1
+ifloat: 9
+ildouble: 6
+ldouble: 6
+
+Function: Imaginary part of "cacosh":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "casin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Imaginary part of "casin":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "casinh":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+ildouble: 5
+ldouble: 5
+
+Function: Imaginary part of "casinh":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+ildouble: 5
+ldouble: 5
+
+Function: Imaginary part of "catan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "catanh":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "cbrt":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ccos":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ccos":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "cexp":
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "cexp":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "clog":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "clog10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "clog10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "cos":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "cosh":
+ildouble: 1
+
+Function: Real part of "cpow":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+ildouble: 763
+ldouble: 763
+
+Function: Imaginary part of "cpow":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "csin":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csin":
+float: 1
+ifloat: 1
+
+Function: Real part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "ctan":
+double: 1
+idouble: 1
+ildouble: 439
+ldouble: 439
+
+Function: Imaginary part of "ctan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+
+Function: Real part of "ctanh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 5
+ldouble: 5
+
+Function: Imaginary part of "ctanh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 25
+ldouble: 25
+
+Function: "erf":
+double: 1
+idouble: 1
+
+Function: "erfc":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "exp":
+ildouble: 754
+
+Function: "exp10":
+ildouble: 8
+ldouble: 8
+
+Function: "expm1":
+ildouble: 1
+
+Function: "gamma":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: "hypot":
+float: 1
+ifloat: 1
+
+Function: "j0":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "j1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "jn":
+double: 5
+float: 2
+idouble: 5
+ifloat: 2
+ildouble: 2
+ldouble: 2
+
+Function: "lgamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "log":
+float: 1
+ifloat: 1
+
+Function: "log10":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "sincos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "sin":
+double: 1
+idouble: 1
+
+Function: "sinh":
+double: 1
+ildouble: 1
+
+Function: "tan":
+double: 1
+idouble: 1
+
+Function: "tgamma":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "y0":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "y1":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "yn":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+ildouble: 4
+ldouble: 4
+
+# end of automatic generation
diff --git a/test/math/libm-test-ulps-ia64 b/test/math/libm-test-ulps-ia64
new file mode 100644
index 000000000..c5a2a0854
--- /dev/null
+++ b/test/math/libm-test-ulps-ia64
@@ -0,0 +1,1146 @@
+# Begin of automatic generation
+
+# cacos
+Test "Imaginary part of: cacos (0.75 + 1.25 i) == 1.11752014915610270578240049553777969 - 1.13239363160530819522266333696834467 i":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+# cacosh
+Test "Real part of: cacosh (-2 - 3 i) == 1.9833870299165354323470769028940395 - 2.1414491111159960199416055713254211 i":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+ildouble: 7
+ldouble: 7
+Test "Imaginary part of: cacosh (-2 - 3 i) == 1.9833870299165354323470769028940395 - 2.1414491111159960199416055713254211 i":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+# casin
+Test "Real part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+# casinh
+Test "Real part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+ildouble: 5
+ldouble: 5
+Test "Imaginary part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+ildouble: 5
+ldouble: 5
+Test "Real part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# catan
+Test "Imaginary part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# catanh
+Test "Real part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+double: 4
+idouble: 4
+ildouble: 1
+ldouble: 1
+Test "Real part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+double: 1
+idouble: 1
+
+# ccos
+Test "Imaginary part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+ildouble: 1
+ldouble: 1
+
+# ccosh
+Test "Imaginary part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+float: 1
+ifloat: 1
+
+# cexp
+Test "Imaginary part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+float: 1
+ifloat: 1
+Test "Real part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+ildouble: 1
+ldouble: 1
+
+# clog
+Test "Real part of: clog (0.75 + 1.25 i) == 0.376885901188190075998919126749298416 + 1.03037682652431246378774332703115153 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# clog10
+Test "Imaginary part of: clog10 (-0 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-0 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (-3 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-3 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 0 i) == inf + pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 1 i) == inf + pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + inf i) == inf + 3/4 pi*log10(e) i":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-inf - 0 i) == inf - pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 1 i) == inf - pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (3 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf + inf i) == inf + pi/4*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf - inf i) == inf - pi/4*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# cos
+Test "cos (0.80190127184058835) == 0.69534156199418473":
+double: 1
+idouble: 1
+Test "cos (M_PI_6l * 2.0) == 0.5":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "cos (M_PI_6l * 4.0) == -0.5":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "cos (pi/2) == 0":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# cpow
+Test "Real part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+ildouble: 6
+ldouble: 6
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 0.0 i) == 0.75 + 1.25 i":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i) == 0.0846958290317209430433805274189191353 + 0.513285749182902449043287190519090481 i":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+ildouble: 3
+ldouble: 3
+Test "Real part of: cpow (2 + 0 i, 10 + 0 i) == 1024.0 + 0.0 i":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+float: 2
+ifloat: 2
+ildouble: 4
+ldouble: 4
+Test "Imaginary part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+ildouble: 1
+ldouble: 1
+
+# csin
+Test "Real part of: csin (0.75 + 1.25 i) == 1.28722291002649188575873510790565441 + 1.17210635989270256101081285116138863 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csin (0.75 + 1.25 i) == 1.28722291002649188575873510790565441 + 1.17210635989270256101081285116138863 i":
+float: 1
+ifloat: 1
+
+# csinh
+Test "Real part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Real part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+
+# csqrt
+Test "Real part of: csqrt (-2 + 3 i) == 0.89597747612983812471573375529004348 + 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+Test "Real part of: csqrt (-2 - 3 i) == 0.89597747612983812471573375529004348 - 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+
+# ctan
+Test "Real part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# ctanh
+Test "Real part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+float: 1
+ifloat: 1
+ildouble: 24
+ldouble: 24
+Test "Imaginary part of: ctanh (0 + pi/4 i) == 0.0 + 1.0 i":
+float: 1
+ifloat: 1
+Test "Real part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+# erf
+Test "erf (1.25) == 0.922900128256458230136523481197281140":
+double: 1
+idouble: 1
+
+# erfc
+Test "erfc (0.75) == 0.288844366346484868401062165408589223":
+float: 1
+ifloat: 1
+Test "erfc (1.25) == 0.0770998717435417698634765188027188596":
+ildouble: 1
+ldouble: 1
+Test "erfc (2.0) == 0.00467773498104726583793074363274707139":
+double: 1
+idouble: 1
+Test "erfc (4.125) == 0.542340079956506600531223408575531062e-8":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+# exp10
+Test "exp10 (-1) == 0.1":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "exp10 (0.75) == 5.62341325190349080394951039776481231":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "exp10 (3) == 1000":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+ildouble: 3
+ldouble: 3
+
+# expm1
+Test "expm1 (1) == M_El - 1.0":
+ildouble: 1
+ldouble: 1
+
+# gamma
+Test "gamma (-0.5) == log(2*sqrt(pi))":
+ildouble: 1
+ldouble: 1
+
+# hypot
+Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+
+# j0
+Test "j0 (-4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "j0 (10.0) == -0.245935764451348335197760862485328754":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "j0 (2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+Test "j0 (4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "j0 (8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+
+# j1
+Test "j1 (10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "j1 (2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "j1 (8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+
+# jn
+Test "jn (0, -4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "jn (0, 10.0) == -0.245935764451348335197760862485328754":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (0, 2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+Test "jn (0, 4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "jn (0, 8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+Test "jn (1, 10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "jn (1, 2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "jn (1, 8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+Test "jn (10, -1.0) == 0.263061512368745320699785368779050294e-9":
+ildouble: 1
+ldouble: 1
+Test "jn (10, 0.125) == 0.250543369809369890173993791865771547e-18":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (10, 0.75) == 0.149621713117596814698712483621682835e-10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "jn (10, 1.0) == 0.263061512368745320699785368779050294e-9":
+ildouble: 1
+ldouble: 1
+Test "jn (10, 10.0) == 0.207486106633358857697278723518753428":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "jn (10, 2.0) == 0.251538628271673670963516093751820639e-6":
+float: 4
+ifloat: 4
+ildouble: 1
+ldouble: 1
+Test "jn (3, -1.0) == -0.0195633539826684059189053216217515083":
+ildouble: 1
+ldouble: 1
+Test "jn (3, 0.125) == 0.406503832554912875023029337653442868e-4":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 0.75) == 0.848438342327410884392755236884386804e-2":
+double: 1
+idouble: 1
+Test "jn (3, 1.0) == 0.0195633539826684059189053216217515083":
+ildouble: 1
+ldouble: 1
+Test "jn (3, 10.0) == 0.0583793793051868123429354784103409563":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "jn (3, 2.0) == 0.128943249474402051098793332969239835":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# lgamma
+Test "lgamma (-0.5) == log(2*sqrt(pi))":
+ildouble: 1
+ldouble: 1
+Test "lgamma (0.7) == 0.260867246531666514385732417016759578":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# log
+Test "log (e) == 1":
+float: 1
+ifloat: 1
+
+# log10
+Test "log10 (e) == log10(e)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# sincos
+Test "sincos (0.80190127184058835, &sin_res, &cos_res) puts 0.69534156199418473 in cos_res":
+double: 1
+idouble: 1
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in sin_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "sincos (pi/2, &sin_res, &cos_res) puts 0 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# tan
+Test "tan (pi/4) == 1":
+double: 1
+idouble: 1
+
+# tgamma
+Test "tgamma (-0.5) == -2 sqrt (pi)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (0.5) == sqrt (pi)":
+float: 1
+ifloat: 1
+Test "tgamma (0.7) == 1.29805533264755778568117117915281162":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# y0
+Test "y0 (0.125) == -1.38968062514384052915582277745018693":
+ildouble: 1
+ldouble: 1
+Test "y0 (1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "y0 (1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (10.0) == 0.0556711672835993914244598774101900481":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "y0 (2.0) == 0.510375672649745119596606592727157873":
+double: 1
+idouble: 1
+Test "y0 (8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# y1
+Test "y1 (0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "y1 (10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "y1 (1.5) == -0.412308626973911295952829820633445323";
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "y1 (2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "y1 (8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# yn
+Test "yn (0, 0.125) == -1.38968062514384052915582277745018693":
+ildouble: 1
+ldouble: 1
+Test "yn (0, 1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (0, 1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 10.0) == 0.0556711672835993914244598774101900481":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (0, 2.0) == 0.510375672649745119596606592727157873":
+double: 1
+idouble: 1
+Test "yn (0, 8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (1, 0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "yn (1, 10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "yn (1, 1.5) == -0.412308626973911295952829820633445323";
+float: 1
+ifloat: 1
+ldouble: 1
+ildouble: 1
+Test "yn (1, 2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (1, 8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "yn (10, 0.125) == -127057845771019398.252538486899753195":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+Test "yn (10, 0.75) == -2133501638.90573424452445412893839236":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "yn (10, 1.0) == -121618014.278689189288130426667971145":
+float: 2
+ifloat: 2
+Test "yn (10, 10.0) == -0.359814152183402722051986577343560609":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+Test "yn (10, 2.0) == -129184.542208039282635913145923304214":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "yn (3, 0.125) == -2612.69757350066712600220955744091741":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "yn (3, 0.75) == -12.9877176234475433186319774484809207":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (3, 10.0) == -0.251362657183837329779204747654240998":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 2.0) == -1.12778377684042778608158395773179238":
+double: 1
+idouble: 1
+
+# Maximal error of functions:
+Function: Imaginary part of "cacos":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "cacosh":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+ildouble: 7
+ldouble: 7
+
+Function: Imaginary part of "cacosh":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "casin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Imaginary part of "casin":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "casinh":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+ildouble: 5
+ldouble: 5
+
+Function: Imaginary part of "casinh":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+ildouble: 5
+ldouble: 5
+
+Function: Imaginary part of "catan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "catanh":
+double: 4
+idouble: 4
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ccos":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ccos":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "cexp":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "cexp":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "clog":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "clog10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "clog10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "cos":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "cpow":
+double: 2
+float: 5
+idouble: 2
+ifloat: 5
+ildouble: 6
+ldouble: 6
+
+Function: Imaginary part of "cpow":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+ildouble: 4
+ldouble: 4
+
+Function: Real part of "csin":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csin":
+float: 1
+ifloat: 1
+
+Function: Real part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "csqrt":
+float: 1
+ifloat: 1
+
+Function: Real part of "ctan":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+
+Function: Imaginary part of "ctan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ctanh":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ctanh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 24
+ldouble: 24
+
+Function: "erf":
+double: 1
+idouble: 1
+
+Function: "erfc":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "exp10":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+ildouble: 3
+ldouble: 3
+
+Function: "expm1":
+ildouble: 1
+ldouble: 1
+
+Function: "gamma":
+ildouble: 1
+ldouble: 1
+
+Function: "hypot":
+float: 1
+ifloat: 1
+
+Function: "j0":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+ildouble: 2
+ldouble: 2
+
+Function: "j1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "jn":
+double: 3
+float: 4
+idouble: 3
+ifloat: 4
+ildouble: 2
+ldouble: 2
+
+Function: "lgamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "log":
+float: 1
+ifloat: 1
+
+Function: "log10":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "sincos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "tan":
+double: 1
+idouble: 1
+
+Function: "tgamma":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "y0":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "y1":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "yn":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+ildouble: 2
+ldouble: 2
+
+# end of automatic generation
diff --git a/test/math/libm-test-ulps-mips32 b/test/math/libm-test-ulps-mips32
new file mode 100644
index 000000000..7a421bfed
--- /dev/null
+++ b/test/math/libm-test-ulps-mips32
@@ -0,0 +1,4966 @@
+# Begin of automatic generation
+
+# acos_downward
+Test "acos_downward (-0)":
+float: 1
+ifloat: 1
+Test "acos_downward (-0.5)":
+double: 1
+idouble: 1
+Test "acos_downward (-1)":
+float: 1
+ifloat: 1
+Test "acos_downward (0)":
+float: 1
+ifloat: 1
+Test "acos_downward (0.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# acos_towardzero
+Test "acos_towardzero (-0)":
+float: 1
+ifloat: 1
+Test "acos_towardzero (-0.5)":
+double: 1
+idouble: 1
+Test "acos_towardzero (-1)":
+float: 1
+ifloat: 1
+Test "acos_towardzero (0)":
+float: 1
+ifloat: 1
+Test "acos_towardzero (0.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# asin_downward
+Test "asin_downward (-0.5)":
+double: 1
+idouble: 1
+Test "asin_downward (0.5)":
+double: 1
+idouble: 1
+Test "asin_downward (1.0)":
+float: 1
+ifloat: 1
+
+# asin_towardzero
+Test "asin_towardzero (-0.5)":
+double: 1
+idouble: 1
+Test "asin_towardzero (-1.0)":
+float: 1
+ifloat: 1
+Test "asin_towardzero (0.5)":
+double: 1
+idouble: 1
+Test "asin_towardzero (1.0)":
+float: 1
+ifloat: 1
+
+# asin_upward
+Test "asin_upward (-1.0)":
+float: 1
+ifloat: 1
+
+# atan2
+Test "atan2 (-0.75, -1.0)":
+float: 1
+ifloat: 1
+Test "atan2 (-max_value, -min_value)":
+float: 1
+ifloat: 1
+Test "atan2 (0.75, -1.0)":
+float: 1
+ifloat: 1
+Test "atan2 (1.390625, 0.9296875)":
+float: 1
+ifloat: 1
+
+# atanh
+Test "atanh (0.75)":
+float: 1
+ifloat: 1
+
+# cacos
+Test "Imaginary part of: cacos (+0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (+0 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacos (+0 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (+0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (+0 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacos (+0 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (-0.25 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0.25 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0.25 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0.25 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0.5 + 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0.5 + 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0.5 + 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0.5 + 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (-0.5 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0.5 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0.5 - 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0.5 - 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0.5 - 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0.5 - 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (-0.5 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0.5 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0x0.fffffffffffff8p0 + 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0x0.fffffffffffff8p0 - 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0x0.ffffffp0 + 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cacos (-0x0.ffffffp0 - 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cacos (-0x1.000002p0 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.000002p0 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.fp-10 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-10 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (-0x1.fp-100 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.fp-100 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-100 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.fp-100 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.fp-1000 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-1000 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-1025 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-1025 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-1025 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-1025 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (-0x1.fp-129 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.fp-129 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-129 + 0x0.ffffffp0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-129 + 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-129 + 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-129 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-129 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.fp-129 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-129 + 1.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.fp-129 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (-0x1.fp-129 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.fp-129 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-129 - 0x0.ffffffp0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-129 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-129 - 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-129 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-129 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.fp-129 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-129 - 1.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.fp-129 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (-0x1.fp-30 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.fp-30 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-30 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.fp-30 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-105 + 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-105 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-105 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-105 + 0x1p-105 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-105 - 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-105 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-105 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-105 - 0x1p-105 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-112 + 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-112 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-112 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-112 + 0x1p-112 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-112 - 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-112 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-112 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-112 - 0x1p-112 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-23 + 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-23 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-23 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-23 + 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (-0x1p-23 + 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-23 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-23 - 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-23 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-23 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-23 - 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (-0x1p-23 - 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-23 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-52 + 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-52 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-52 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-52 + 0x1p-52 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-52 - 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-52 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-52 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-52 - 0x1p-52 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-63 + 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-63 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-63 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-63 + 0x1p-63 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-63 - 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-63 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-63 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-63 - 0x1p-63 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-1.0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-1.0 + 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-1.0 + 0x1p50 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-1.0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-1.0 - 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-1.0 - 0x1p50 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-2 - 3 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0.25 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0.25 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (0.5 + +0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 + 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 + 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0.5 + 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 + 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0.5 + 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 + 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0.5 + 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0.5 + 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 + 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 + 0x1p-63 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0.5 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 - 0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 - 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 - 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0.5 - 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 - 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0.5 - 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 - 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0.5 - 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0.5 - 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 - 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 - 0x1p-63 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0.5 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x0.fffffffffffff8p0 + 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x0.fffffffffffff8p0 - 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0x0.ffffffp0 + 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (0x0.ffffffp0 + 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (0x0.ffffffp0 + 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cacos (0x0.ffffffp0 + 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Real part of: cacos (0x0.ffffffp0 - 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (0x0.ffffffp0 - 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (0x0.ffffffp0 - 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cacos (0x0.ffffffp0 - 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Real part of: cacos (0x1.0000000000001p0 + 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0x1.0000000000001p0 - 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0x1.000002p0 + 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cacos (0x1.000002p0 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (0x1.000002p0 - 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cacos (0x1.000002p0 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1.fp-10 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x1.fp-10 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x1.fp-100 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1.fp-100 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1.fp-1000 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x1.fp-1000 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x1.fp-1025 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x1.fp-1025 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x1.fp-1025 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x1.fp-1025 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x1.fp-129 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1.fp-129 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1.fp-129 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x1.fp-129 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1.fp-129 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1.fp-129 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x1.fp-30 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1.fp-30 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1.fp1023 + 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x1.fp127 + 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x1p-105 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1p-105 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1p-112 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1p-112 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1p-23 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1p-23 + 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x1p-23 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1p-23 - 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x1p-52 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1p-52 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1p-63 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1p-63 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (1.0 + 0.25 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (1.0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (1.0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (1.0 + 0x1.fp-10 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cacos (1.0 + 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (1.0 - 0.25 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (1.0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (1.0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (1.0 - 0x1.fp-10 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cacos (1.0 - 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+
+# cacosh
+Test "Real part of: cacosh (+0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (+0 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: cacosh (+0 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (+0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (+0 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: cacosh (+0 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: cacosh (-0 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: cacosh (-0 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0.25 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0.25 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: cacosh (-0.25 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0.25 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: cacosh (-0.5 + 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0.5 + 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0.5 + 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0.5 + 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0.5 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (-0.5 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0.5 - 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0.5 - 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0.5 - 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0.5 - 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0.5 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (-0.5 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x0.fffffffffffff8p0 + 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0x0.fffffffffffff8p0 - 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0x0.ffffffp0 + 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Real part of: cacosh (-0x0.ffffffp0 - 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Real part of: cacosh (-0x1.000002p0 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1.000002p0 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1.fp-10 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0x1.fp-10 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0x1.fp-100 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-100 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1.fp-100 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-100 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1.fp-1000 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0x1.fp-1000 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0x1.fp-1025 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0x1.fp-1025 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0x1.fp-1025 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0x1.fp-1025 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0x1.fp-129 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 + 0x0.ffffffp0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 + 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 + 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1.fp-129 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1.fp-129 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 + 1.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1.fp-129 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 - 0x0.ffffffp0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 - 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1.fp-129 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1.fp-129 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 - 1.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1.fp-30 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-30 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1.fp-30 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-30 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-105 + 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-105 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-105 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-105 + 0x1p-105 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-105 - 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-105 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-105 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-105 - 0x1p-105 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-112 + 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-112 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-112 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-112 + 0x1p-112 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-112 - 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-112 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-112 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-112 - 0x1p-112 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-23 + 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-23 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-23 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-23 + 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (-0x1p-23 + 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-23 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-23 - 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-23 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-23 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-23 - 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (-0x1p-23 - 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-23 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-52 + 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-52 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-52 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-52 + 0x1p-52 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-52 - 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-52 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-52 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-52 - 0x1p-52 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-63 + 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-63 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-63 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-63 + 0x1p-63 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-63 - 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-63 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-63 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-63 - 0x1p-63 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-1.0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-1.0 + 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-1.0 + 0x1p50 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-1.0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-1.0 - 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-1.0 - 0x1p50 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-2 - 3 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (0.25 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (0.25 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (0.5 + +0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0.5 + 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0.5 + 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0.5 + 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0.5 + 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0.5 + 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0.5 + 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0.5 + 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0.5 + 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0.5 + 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0.5 + 0x1p-63 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0.5 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0.5 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (0.5 - 0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0.5 - 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0.5 - 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0.5 - 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0.5 - 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0.5 - 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0.5 - 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0.5 - 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0.5 - 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0.5 - 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0.5 - 0x1p-63 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0.5 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0.5 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (0x0.fffffffffffff8p0 + 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x0.fffffffffffff8p0 - 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0x0.ffffffp0 + 0.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (0x0.ffffffp0 + 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (0x0.ffffffp0 + 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cacosh (0x0.ffffffp0 + 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cacosh (0x0.ffffffp0 - 0.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (0x0.ffffffp0 - 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (0x0.ffffffp0 - 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cacosh (0x0.ffffffp0 - 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cacosh (0x1.0000000000001p0 + 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0x1.0000000000001p0 - 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x1.000002p0 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (0x1.000002p0 + 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Real part of: cacosh (0x1.000002p0 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (0x1.000002p0 - 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Real part of: cacosh (0x1.fp-10 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x1.fp-10 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x1.fp-100 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1.fp-100 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1.fp-1000 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x1.fp-1000 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x1.fp-1025 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x1.fp-1025 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x1.fp-1025 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x1.fp-1025 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x1.fp-129 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1.fp-129 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1.fp-129 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x1.fp-129 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1.fp-129 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1.fp-129 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x1.fp-30 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1.fp-30 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1.fp1023 + 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x1.fp127 + 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x1p-105 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1p-105 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1p-112 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1p-112 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1p-23 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1p-23 + 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x1p-23 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1p-23 - 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x1p-52 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1p-52 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1p-63 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1p-63 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (1.0 + 0.25 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (1.0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (1.0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (1.0 + 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (1.0 + 0x1.fp-10 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cacosh (1.0 - 0.25 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (1.0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (1.0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (1.0 - 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (1.0 - 0x1.fp-10 i)":
+float: 2
+ifloat: 2
+
+# casin
+Test "Imaginary part of: casin (+0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (+0 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (+0 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (+0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (+0 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (+0 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0.25 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0.25 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0.5 + 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0.5 + 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0.5 + 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0.5 + 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0.5 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0.5 - 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0.5 - 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0.5 - 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0.5 - 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0.5 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0x0.fffffffffffff8p0 + 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0x0.fffffffffffff8p0 - 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0x0.ffffffp0 + 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: casin (-0x0.ffffffp0 - 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: casin (-0x1.000002p0 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1.000002p0 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casin (-0x1.fp-10 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1.fp-10 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casin (-0x1.fp-10 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1.fp-10 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0x1.fp-100 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1.fp-100 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1.fp-1000 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0x1.fp-1000 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0x1.fp-1025 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0x1.fp-1025 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0x1.fp-1025 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0x1.fp-1025 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0x1.fp-129 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1.fp-129 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1.fp-129 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0x1.fp-129 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1.fp-129 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1.fp-129 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0x1.fp-30 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1.fp-30 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1p-105 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1p-105 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1p-112 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1p-112 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casin (-0x1p-23 + 0.5 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1p-23 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1p-23 + 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casin (-0x1p-23 + 0x1.000002p0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casin (-0x1p-23 - 0.5 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1p-23 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1p-23 - 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casin (-0x1p-23 - 0x1.000002p0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1p-52 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1p-52 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1p-63 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1p-63 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casin (-1.0 + 0.25 i)":
+double: 1
+idouble: 1
+Test "Real part of: casin (-1.0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-1.0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-1.0 + 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casin (-1.0 - 0.25 i)":
+double: 1
+idouble: 1
+Test "Real part of: casin (-1.0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-1.0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-1.0 - 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0.25 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0.25 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0.5 + 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0.5 + 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0.5 + 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0.5 + 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0.5 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0.5 - 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0.5 - 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0.5 - 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0.5 - 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0.5 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casin (0.75 + 1.25 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x0.fffffffffffff8p0 + 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0x0.fffffffffffff8p0 - 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0x0.ffffffp0 + 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: casin (0x0.ffffffp0 - 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: casin (0x1.000002p0 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1.000002p0 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casin (0x1.fp-10 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1.fp-10 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casin (0x1.fp-10 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1.fp-10 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0x1.fp-100 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1.fp-100 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1.fp-1000 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0x1.fp-1000 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0x1.fp-1025 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0x1.fp-1025 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0x1.fp-1025 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0x1.fp-1025 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0x1.fp-129 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1.fp-129 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1.fp-129 + 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0x1.fp-129 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1.fp-129 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1.fp-129 - 1.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0x1.fp-30 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1.fp-30 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1.fp1023 + 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0x1.fp127 + 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0x1p-105 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1p-105 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1p-112 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1p-112 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casin (0x1p-23 + 0.5 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1p-23 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1p-23 + 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casin (0x1p-23 + 0x1.000002p0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casin (0x1p-23 - 0.5 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1p-23 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1p-23 - 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casin (0x1p-23 - 0x1.000002p0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1p-52 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1p-52 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1p-63 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1p-63 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casin (1.0 + 0.25 i)":
+double: 1
+idouble: 1
+Test "Real part of: casin (1.0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (1.0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (1.0 + 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casin (1.0 - 0.25 i)":
+double: 1
+idouble: 1
+Test "Real part of: casin (1.0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (1.0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (1.0 - 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+
+# casinh
+Test "Imaginary part of: casinh (-0.25 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casinh (-0.25 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-0.5 + +0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 + 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 + 0x1p-105 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 + 0x1p-112 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (-0.5 + 0x1p-23 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 + 0x1p-52 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 + 0x1p-63 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (-0.5 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 - 0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 - 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 - 0x1p-105 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 - 0x1p-112 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (-0.5 - 0x1p-23 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 - 0x1p-52 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 - 0x1p-63 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (-0.5 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0x0.ffffffp0 + 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-0x0.ffffffp0 - 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casinh (-0x1.000002p0 + 0x1p-23 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casinh (-0x1.000002p0 - 0x1p-23 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (-0x1.fp-10 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0x1.fp-10 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0x1.fp-129 + 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-0x1.fp-129 - 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-0x1p-105 + 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-0x1p-105 - 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-0x1p-112 + 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-0x1p-112 - 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-0x1p-23 + 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-0x1p-23 + 0x0.ffffffp0 i)":
+float: 2
+ifloat: 2
+Test "Real part of: casinh (-0x1p-23 + 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0x1p-23 - 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-0x1p-23 - 0x0.ffffffp0 i)":
+float: 2
+ifloat: 2
+Test "Real part of: casinh (-0x1p-23 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0x1p-52 + 0x0.fffffffffffff8p0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-0x1p-52 - 0x0.fffffffffffff8p0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-1.0 + +0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (-1.0 + 0.25 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-1.0 + 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-1.0 + 0x1.fp-10 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casinh (-1.0 + 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-1.0 + 0x1.fp-100 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (-1.0 + 0x1.fp-1000 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-1.0 + 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-1.0 + 0x1.fp-129 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (-1.0 + 0x1.fp-30 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (-1.0 - 0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (-1.0 - 0.25 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-1.0 - 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-1.0 - 0x1.fp-10 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casinh (-1.0 - 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-1.0 - 0x1.fp-100 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (-1.0 - 0x1.fp-1000 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-1.0 - 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-1.0 - 0x1.fp-129 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (-1.0 - 0x1.fp-30 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (-1.5 + +0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-1.5 + 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-1.5 + 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-1.5 - 0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-1.5 - 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-1.5 - 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casinh (0.25 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casinh (0.25 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (0.5 + +0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 + 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 + 0x1p-105 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 + 0x1p-112 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (0.5 + 0x1p-23 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 + 0x1p-52 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 + 0x1p-63 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (0.5 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 - 0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 - 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 - 0x1p-105 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 - 0x1p-112 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (0.5 - 0x1p-23 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 - 0x1p-52 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 - 0x1p-63 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (0.5 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.75 + 1.25 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (0.75 + 1.25 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (0x0.ffffffp0 + 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (0x0.ffffffp0 - 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casinh (0x1.000002p0 + 0x1p-23 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casinh (0x1.000002p0 - 0x1p-23 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (0x1.fp-10 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0x1.fp-10 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0x1.fp-129 + 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (0x1.fp-129 - 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (0x1.fp1023 + 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (0x1.fp127 + 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (0x1p-105 + 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (0x1p-105 - 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (0x1p-112 + 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (0x1p-112 - 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (0x1p-23 + 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (0x1p-23 + 0x0.ffffffp0 i)":
+float: 2
+ifloat: 2
+Test "Real part of: casinh (0x1p-23 + 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0x1p-23 - 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (0x1p-23 - 0x0.ffffffp0 i)":
+float: 2
+ifloat: 2
+Test "Real part of: casinh (0x1p-23 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0x1p-52 + 0x0.fffffffffffff8p0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (0x1p-52 - 0x0.fffffffffffff8p0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (1.0 + +0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (1.0 + 0.25 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (1.0 + 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (1.0 + 0x1.fp-10 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casinh (1.0 + 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (1.0 + 0x1.fp-100 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (1.0 + 0x1.fp-1000 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (1.0 + 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (1.0 + 0x1.fp-129 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (1.0 + 0x1.fp-30 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (1.0 - 0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (1.0 - 0.25 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (1.0 - 0.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (1.0 - 0x1.fp-10 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casinh (1.0 - 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (1.0 - 0x1.fp-100 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (1.0 - 0x1.fp-1000 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (1.0 - 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (1.0 - 0x1.fp-129 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (1.0 - 0x1.fp-30 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casinh (1.5 + +0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (1.5 + 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (1.5 + 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (1.5 - 0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (1.5 - 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (1.5 - 0x1.fp-129 i)":
+double: 1
+idouble: 1
+
+# catan
+Test "Imaginary part of: catan (-0x0.fffffffffffff8p0 + 0x1p-27 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (-0x0.ffffffp0 + 0x1p-13 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: catan (-0x1.0000000000001p0 - 0x1p-27 i)":
+double: 1
+idouble: 1
+Test "Real part of: catan (-0x1.000002p0 + 0x1p-126 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (-0x1.000002p0 + 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (-0x1.000002p0 - 0x1p-126 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (-0x1.000002p0 - 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (-0x1.000002p0 - 0x1p-13 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (-0x1.fp1023 + 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (-0x1.fp1023 - 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (-0x1.fp127 + 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (-0x1.fp127 - 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (-0x1p-1020 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (-0x1p-1020 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: catan (-0x1p-13 + 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (-0x1p-13 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (-0x1p-13 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (-0x1p-13 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (-0x1p-13 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (-0x1p-54 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (-0x1p-54 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (-0x1p-57 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (-0x1p-57 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (-1.0 + 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (-1.0 - 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (-2 - 3 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: catan (0x0.fffffffffffff8p0 + 0x1p-27 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (0x0.ffffffp0 + 0x1p-13 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: catan (0x1.0000000000001p0 - 0x1p-27 i)":
+double: 1
+idouble: 1
+Test "Real part of: catan (0x1.000002p0 + 0x1p-126 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (0x1.000002p0 + 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (0x1.000002p0 - 0x1p-126 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (0x1.000002p0 - 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (0x1.000002p0 - 0x1p-13 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (0x1.fp1023 + 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (0x1.fp1023 - 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (0x1.fp127 + 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (0x1.fp127 - 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (0x1p-1020 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (0x1p-1020 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: catan (0x1p-13 + 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (0x1p-13 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (0x1p-13 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (0x1p-13 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (0x1p-13 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (0x1p-54 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (0x1p-54 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (0x1p-57 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (0x1p-57 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (1.0 + 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (1.0 - 0x1p-13 i)":
+float: 1
+ifloat: 1
+
+# catanh
+Test "Real part of: catanh (-0x1.000002p0 + 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catanh (-0x1.000002p0 + 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (-0x1.000002p0 - 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catanh (-0x1.000002p0 - 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (-0x1.fp1023 + 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Real part of: catanh (-0x1.fp1023 - 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Real part of: catanh (-0x1.fp127 + 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Real part of: catanh (-0x1.fp127 - 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (-0x1p-126 + 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catanh (-0x1p-126 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (-0x1p-13 + 0x1.000002p0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (-0x1p-13 + 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catanh (-0x1p-13 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (-0x1p-13 - 0x1.000002p0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (-0x1p-13 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catanh (-0x1p-13 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (-0x1p-27 + 0x1.0000000000001p0 i)":
+double: 1
+idouble: 1
+Test "Real part of: catanh (-0x1p-27 - 0x1.0000000000001p0 i)":
+double: 1
+idouble: 1
+Test "Real part of: catanh (-1.0 + 0x1p-1020 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (-1.0 + 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (-1.0 + 0x1p-54 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (-1.0 + 0x1p-57 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (-1.0 - 0x1p-1020 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (-1.0 - 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (-1.0 - 0x1p-54 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (-1.0 - 0x1p-57 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (-2 - 3 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (0x1.000002p0 + 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catanh (0x1.000002p0 - 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (0x1.fp1023 + 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Real part of: catanh (0x1.fp1023 - 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Real part of: catanh (0x1.fp127 + 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Real part of: catanh (0x1.fp127 - 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (0x1p-126 + 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catanh (0x1p-126 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (0x1p-13 + 0x0.ffffffp0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: catanh (0x1p-13 + 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catanh (0x1p-13 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (0x1p-13 - 0x0.ffffffp0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: catanh (0x1p-13 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catanh (0x1p-13 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (0x1p-27 + 0x0.fffffffffffff8p0 i)":
+double: 1
+idouble: 1
+Test "Real part of: catanh (0x1p-27 - 0x0.fffffffffffff8p0 i)":
+double: 1
+idouble: 1
+Test "Real part of: catanh (1.0 + 0x1p-1020 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (1.0 + 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (1.0 + 0x1p-54 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (1.0 + 0x1p-57 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (1.0 - 0x1p-1020 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (1.0 - 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (1.0 - 0x1p-54 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (1.0 - 0x1p-57 i)":
+float: 1
+ifloat: 1
+
+# cbrt
+Test "cbrt (-27.0)":
+double: 1
+idouble: 1
+Test "cbrt (0.75)":
+double: 1
+idouble: 1
+Test "cbrt (0.9921875)":
+double: 1
+idouble: 1
+
+# ccos
+Test "Imaginary part of: ccos (-0.75 + 710.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: ccos (-0.75 + 89.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccos (-0.75 - 710.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: ccos (-0.75 - 89.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccos (-2 - 3 i)":
+float: 1
+ifloat: 1
+Test "Real part of: ccos (0.75 + 1.25 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccos (0.75 + 1.25 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccos (0.75 + 710.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: ccos (0.75 + 89.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccos (0.75 - 710.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: ccos (0.75 - 89.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccos (0x1p-1074 + 1440 i)":
+double: 1
+idouble: 1
+
+# ccosh
+Test "Real part of: ccosh (-2 - 3 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (-2 - 3 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (-710.5 + 0.75 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: ccosh (-710.5 - 0.75 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: ccosh (-89.5 + 0.75 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (-89.5 - 0.75 i)":
+float: 1
+ifloat: 1
+Test "Real part of: ccosh (0.75 + 1.25 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (0.75 + 1.25 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (1440 + 0x1p-1074 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: ccosh (710.5 + 0.75 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: ccosh (710.5 - 0.75 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: ccosh (89.5 + 0.75 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (89.5 - 0.75 i)":
+float: 1
+ifloat: 1
+
+# cexp
+Test "Imaginary part of: cexp (-2.0 - 3.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cexp (-95 + 0.75 i)":
+double: 1
+idouble: 1
+Test "Real part of: cexp (0.75 + 1.25 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cexp (1440 + 0x1p-1074 i)":
+double: 1
+idouble: 1
+Test "Real part of: cexp (50 + 0x1p127 i)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "Imaginary part of: cexp (50 + 0x1p127 i)":
+double: 1
+idouble: 1
+Test "Real part of: cexp (500 + 0x1p1023 i)":
+double: 1
+idouble: 1
+Test "Real part of: cexp (709.8125 + 0.75 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cexp (709.8125 + 0.75 i)":
+double: 1
+idouble: 1
+Test "Real part of: cexp (88.75 + 0.75 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cexp (88.75 + 0.75 i)":
+float: 2
+ifloat: 2
+
+# clog
+Test "Real part of: clog (-0x1.0000000123456p0 + 0x1.2345678p-1000 i)":
+double: 1
+idouble: 1
+Test "Real part of: clog (-0x1.0000000123456p0 + 0x1.2345678p-30 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog (-0x1.234566p-40 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog (-0x1.fp+127 + 0x1p-149 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog (-0x1.fp+127 - 0x1p-149 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog (-0x1p-149 + 0x1.fp+127 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog (-0x1p-149 + 0x1.fp+127 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog (-0x1p-149 - 0x1.fp+127 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog (-0x1p-149 - 0x1.fp+127 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog (0x0.ffffffp0 + 0x0.ffffffp-100 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog (0x1.000566p0 + 0x1.234p-10 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog (0x1.fp+127 + 0x1p-149 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog (0x1.fp+127 - 0x1p-149 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog (0x1p-1074 + 0x1p-1074 i)":
+double: 1
+idouble: 1
+Test "Real part of: clog (0x1p-147 + 0x1p-147 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog (0x1p-149 + 0x1.fp+127 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog (0x1p-149 - 0x1.fp+127 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog (0x2818p-15 + 0x798fp-15 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog (1.0 + 0x1.234566p-10 i)":
+float: 1
+ifloat: 1
+
+# clog10
+Test "Imaginary part of: clog10 (-0 + inf i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-0 - inf i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: clog10 (-0x1.0000000123456p0 + 0x1.2345678p-1000 i)":
+double: 2
+idouble: 2
+Test "Imaginary part of: clog10 (-0x1.0000000123456p0 + 0x1.2345678p-1000 i)":
+double: 1
+idouble: 1
+Test "Real part of: clog10 (-0x1.0000000123456p0 + 0x1.2345678p-30 i)":
+double: 2
+idouble: 2
+Test "Imaginary part of: clog10 (-0x1.0000000123456p0 + 0x1.2345678p-30 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-0x1.fp+1023 + 0x1p-1074 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-0x1.fp+1023 - 0x1p-1074 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-0x1.fp+127 + 0x1p-149 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-0x1.fp+127 - 0x1p-149 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-0x1p-1074 + 0x1.fp+1023 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-0x1p-1074 - 0x1.fp+1023 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-0x1p-149 + 0x1.fp+127 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-0x1p-149 - 0x1.fp+127 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-1.0 + 0x1.234566p-20 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-2 - 3 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-3 + inf i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-3 - inf i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 1 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + inf i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-inf - 0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 1 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 + inf i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 - inf i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: clog10 (0x0.fffffffffffff8p0 + 0x0.fffffffffffff8p-1000 i)":
+double: 1
+idouble: 1
+Test "Real part of: clog10 (0x0.ffffffp0 + 0x0.ffffffp-100 i)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "Real part of: clog10 (0x1.000566p0 + 0x1.234p-10 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1.000566p0 + 0x1.234p-10 i)":
+double: 1
+idouble: 1
+Test "Real part of: clog10 (0x1.000566p0 + 0x1.234p-100 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1.234566p-30 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1.234566p-50 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1.234566p-60 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1.fffffep+127 + 0x1.fffffep+127 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: clog10 (0x1.fffffep+127 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1.fffffffffffffp+1023 + 0x1.fffffffffffffp+1023 i)":
+double: 1
+idouble: 1
+Test "Real part of: clog10 (0x10673dd0f2481p-51 + 0x7ef1d17cefbd2p-51 i)":
+double: 1
+idouble: 1
+Test "Real part of: clog10 (0x1367a310575591p-54 + 0x3cfcc0a0541f60p-54 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x1367a310575591p-54 + 0x3cfcc0a0541f60p-54 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x164c74eea876p-45 + 0x16f393482f77p-45 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x1a6p-10 + 0x3a5p-10 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x1p-1073 + 0x1p-1073 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x1p-1074 + 0x1.fp+1023 i)":
+double: 1
+idouble: 1
+Test "Real part of: clog10 (0x1p-1074 + 0x1p-1074 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x1p-1074 + 0x1p-1074 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x1p-1074 - 0x1.fp+1023 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x1p-147 + 0x1p-147 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1p-149 + 0x1.fp+127 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1p-149 + 0x1p-149 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1p-149 - 0x1.fp+127 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1p-509 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x1p-510 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x1p-511 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x1p-61 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1p-62 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1p-63 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: clog10 (0x2818p-15 + 0x798fp-15 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x2818p-15 + 0x798fp-15 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog10 (0x2dd46725bp-35 + 0x7783a1284p-35 i)":
+double: 1
+idouble: 1
+Test "Real part of: clog10 (0x2ede88p-23 + 0x771c3fp-23 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x2ede88p-23 + 0x771c3fp-23 i)":
+double: 1
+idouble: 1
+Test "Real part of: clog10 (0x4447d7175p-35 + 0x6c445e00ap-35 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x5b06b680ea2ccp-52 + 0xef452b965da9fp-52 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x9b57bp-20 + 0xcb7b4p-20 i)":
+double: 1
+idouble: 1
+Test "Real part of: clog10 (0xf2p-10 + 0x3e3p-10 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0xf2p-10 + 0x3e3p-10 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0xfe961079616p-45 + 0x1bc37e09e6d1p-45 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (1.0 + 0x1.234566p-10 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (3 + inf i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 - inf i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf + inf i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf - inf i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# cos
+Test "cos (0x1p+120)":
+float: 1
+ifloat: 1
+Test "cos (0x1p+127)":
+float: 1
+ifloat: 1
+Test "cos (M_PI_6l * 2.0)":
+double: 1
+idouble: 1
+Test "cos (M_PI_6l * 4.0)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+# cos_downward
+Test "cos_downward (1)":
+float: 1
+ifloat: 1
+Test "cos_downward (2)":
+float: 1
+ifloat: 1
+Test "cos_downward (3)":
+float: 1
+ifloat: 1
+Test "cos_downward (4)":
+float: 1
+ifloat: 1
+Test "cos_downward (5)":
+float: 1
+ifloat: 1
+Test "cos_downward (7)":
+float: 1
+ifloat: 1
+Test "cos_downward (8)":
+float: 1
+ifloat: 1
+
+# cos_tonearest
+Test "cos_tonearest (7)":
+float: 1
+ifloat: 1
+
+# cos_towardzero
+Test "cos_towardzero (2)":
+float: 1
+ifloat: 1
+Test "cos_towardzero (3)":
+float: 1
+ifloat: 1
+Test "cos_towardzero (5)":
+float: 1
+ifloat: 1
+Test "cos_towardzero (7)":
+float: 1
+ifloat: 1
+Test "cos_towardzero (8)":
+float: 1
+ifloat: 1
+
+# cos_upward
+Test "cos_upward (10)":
+float: 1
+ifloat: 1
+Test "cos_upward (6)":
+float: 1
+ifloat: 1
+Test "cos_upward (7)":
+float: 1
+ifloat: 1
+Test "cos_upward (9)":
+float: 2
+ifloat: 2
+
+# cosh_downward
+Test "cosh_downward (22)":
+float: 1
+ifloat: 1
+Test "cosh_downward (23)":
+float: 1
+ifloat: 1
+Test "cosh_downward (24)":
+float: 1
+ifloat: 1
+
+# cosh_towardzero
+Test "cosh_towardzero (22)":
+float: 1
+ifloat: 1
+Test "cosh_towardzero (23)":
+float: 1
+ifloat: 1
+Test "cosh_towardzero (24)":
+float: 1
+ifloat: 1
+
+# cpow
+Test "Real part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i)":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i)":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+Test "Real part of: cpow (2 + 3 i, 4 + 0 i)":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i)":
+float: 2
+ifloat: 2
+
+# csin
+Test "Real part of: csin (-0.75 + 710.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: csin (-0.75 + 89.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: csin (-0.75 - 710.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: csin (-0.75 - 89.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: csin (0.75 + 710.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: csin (0.75 + 89.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: csin (0.75 - 710.5 i)":
+double: 1
+idouble: 1
+Test "Real part of: csin (0.75 - 89.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: csin (0x1p-1074 + 1440 i)":
+double: 1
+idouble: 1
+
+# csinh
+Test "Imaginary part of: csinh (-2 - 3 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: csinh (-710.5 + 0.75 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: csinh (-710.5 - 0.75 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: csinh (-89.5 + 0.75 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csinh (-89.5 - 0.75 i)":
+float: 1
+ifloat: 1
+Test "Real part of: csinh (0.75 + 1.25 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csinh (0.75 + 1.25 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csinh (1440 + 0x1p-1074 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: csinh (710.5 + 0.75 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: csinh (710.5 - 0.75 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: csinh (89.5 + 0.75 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csinh (89.5 - 0.75 i)":
+float: 1
+ifloat: 1
+
+# csqrt
+Test "Real part of: csqrt (-0x1.000002p-126 - 0x1.000002p-126 i)":
+double: 1
+idouble: 1
+Test "Real part of: csqrt (-2 + 3 i)":
+float: 1
+ifloat: 1
+Test "Real part of: csqrt (-2 - 3 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csqrt (0x1.000002p-126 + 0x1.000002p-126 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: csqrt (0x1.fffffep+127 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: csqrt (0x1.fffffffffffffp+1023 + 0x1.fffffffffffffp+1023 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: csqrt (0x1.fffffffffffffp+1023 + 0x1.fffffffffffffp+1023 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: csqrt (0x1.fffffffffffffp+1023 + 0x1p+1023 i)":
+double: 1
+idouble: 1
+
+# ctan
+Test "Real part of: ctan (-2 - 3 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ctan (-2 - 3 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: ctan (0.75 + 1.25 i)":
+double: 1
+idouble: 1
+Test "Real part of: ctan (0x1p1023 + 1 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: ctan (0x1p127 + 1 i)":
+double: 1
+idouble: 1
+Test "Real part of: ctan (0x3.243f6cp-1 + 0 i)":
+float: 1
+ifloat: 1
+
+# ctan_downward
+Test "Real part of: ctan_downward (0x1.921fb6p+0 + 0x1p-149 i)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "Imaginary part of: ctan_downward (0x1.921fb6p+0 + 0x1p-149 i)":
+float: 1
+ifloat: 1
+
+# ctan_tonearest
+Test "Real part of: ctan_tonearest (0x1.921fb6p+0 + 0x1p-149 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ctan_tonearest (0x1.921fb6p+0 + 0x1p-149 i)":
+float: 1
+ifloat: 1
+
+# ctan_towardzero
+Test "Real part of: ctan_towardzero (0x1.921fb6p+0 + 0x1p-149 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ctan_towardzero (0x1.921fb6p+0 + 0x1p-149 i)":
+float: 1
+ifloat: 1
+
+# ctan_upward
+Test "Real part of: ctan_upward (0x1.921fb54442d18p+0 + 0x1p-1074 i)":
+double: 1
+idouble: 1
+Test "Real part of: ctan_upward (0x1.921fb6p+0 + 0x1p-149 i)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "Imaginary part of: ctan_upward (0x1.921fb6p+0 + 0x1p-149 i)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# ctanh
+Test "Real part of: ctanh (-2 - 3 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ctanh (-2 - 3 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ctanh (0 + 0x3.243f6cp-1 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ctanh (0 + pi/4 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: ctanh (0.75 + 1.25 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ctanh (0.75 + 1.25 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: ctanh (1 + 0x1p1023 i)":
+double: 1
+idouble: 1
+Test "Real part of: ctanh (1 + 0x1p127 i)":
+double: 1
+idouble: 1
+
+# ctanh_downward
+Test "Real part of: ctanh_downward (0x1p-149 + 0x1.921fb6p+0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ctanh_downward (0x1p-149 + 0x1.921fb6p+0 i)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+# ctanh_tonearest
+Test "Real part of: ctanh_tonearest (0x1p-149 + 0x1.921fb6p+0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ctanh_tonearest (0x1p-149 + 0x1.921fb6p+0 i)":
+float: 1
+ifloat: 1
+
+# ctanh_towardzero
+Test "Real part of: ctanh_towardzero (0x1p-149 + 0x1.921fb6p+0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ctanh_towardzero (0x1p-149 + 0x1.921fb6p+0 i)":
+float: 1
+ifloat: 1
+
+# ctanh_upward
+Test "Imaginary part of: ctanh_upward (0x1p-1074 + 0x1.921fb54442d18p+0 i)":
+double: 1
+idouble: 1
+Test "Real part of: ctanh_upward (0x1p-149 + 0x1.921fb6p+0 i)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "Imaginary part of: ctanh_upward (0x1p-149 + 0x1.921fb6p+0 i)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+# erf
+Test "erf (1.25)":
+double: 1
+idouble: 1
+
+# erfc
+Test "erfc (0x1.f7303cp+1)":
+double: 1
+idouble: 1
+Test "erfc (0x1.ffa002p+2)":
+float: 1
+ifloat: 1
+Test "erfc (2.0)":
+double: 1
+idouble: 1
+Test "erfc (4.125)":
+double: 1
+idouble: 1
+
+# exp10
+Test "exp10 (-1)":
+double: 1
+idouble: 1
+Test "exp10 (-305)":
+double: 1
+idouble: 1
+Test "exp10 (-36)":
+double: 1
+idouble: 1
+Test "exp10 (3)":
+double: 1
+idouble: 1
+Test "exp10 (36)":
+double: 1
+idouble: 1
+
+# exp_downward
+Test "exp_downward (2)":
+float: 1
+ifloat: 1
+Test "exp_downward (3)":
+float: 1
+ifloat: 1
+
+# exp_towardzero
+Test "exp_towardzero (2)":
+float: 1
+ifloat: 1
+Test "exp_towardzero (3)":
+float: 1
+ifloat: 1
+
+# exp_upward
+Test "exp_upward (1)":
+float: 1
+ifloat: 1
+
+# expm1
+Test "expm1 (0.75)":
+double: 1
+idouble: 1
+Test "expm1 (1)":
+float: 1
+ifloat: 1
+Test "expm1 (500.0)":
+double: 1
+idouble: 1
+
+# gamma
+Test "gamma (0.7)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "gamma (1.2)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# hypot
+Test "hypot (-0.7, -12.4)":
+float: 1
+ifloat: 1
+Test "hypot (-0.7, 12.4)":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, -0.7)":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, 0.7)":
+float: 1
+ifloat: 1
+Test "hypot (0.7, -12.4)":
+float: 1
+ifloat: 1
+Test "hypot (0.7, 12.4)":
+float: 1
+ifloat: 1
+Test "hypot (12.4, -0.7)":
+float: 1
+ifloat: 1
+Test "hypot (12.4, 0.7)":
+float: 1
+ifloat: 1
+
+# j0
+Test "j0 (-4.0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (0.75)":
+float: 1
+ifloat: 1
+Test "j0 (0x1.d7ce3ap+107)":
+float: 2
+ifloat: 2
+Test "j0 (10.0)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "j0 (2.0)":
+float: 2
+ifloat: 2
+Test "j0 (4.0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (8.0)":
+float: 1
+ifloat: 1
+
+# j1
+Test "j1 (0x1.3ffp+74)":
+double: 1
+idouble: 1
+Test "j1 (0x1.ff00000000002p+840)":
+double: 1
+idouble: 1
+Test "j1 (10.0)":
+float: 2
+ifloat: 2
+Test "j1 (2.0)":
+double: 1
+idouble: 1
+Test "j1 (8.0)":
+double: 1
+idouble: 1
+
+# jn
+Test "jn (0, -4.0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 0.75)":
+float: 1
+ifloat: 1
+Test "jn (0, 10.0)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "jn (0, 2.0)":
+float: 2
+ifloat: 2
+Test "jn (0, 4.0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 8.0)":
+float: 1
+ifloat: 1
+Test "jn (1, 10.0)":
+float: 2
+ifloat: 2
+Test "jn (1, 2.0)":
+double: 1
+idouble: 1
+Test "jn (1, 8.0)":
+double: 1
+idouble: 1
+Test "jn (10, 0.125)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (10, 0.75)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (10, 10.0)":
+double: 4
+float: 3
+idouble: 4
+ifloat: 3
+Test "jn (10, 2.0)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "jn (2, 0x1.ffff62p+99)":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+Test "jn (2, 2.4048255576957729)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "jn (3, 0.125)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 0.75)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 10.0)":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "jn (3, 2.0)":
+float: 1
+ifloat: 1
+Test "jn (3, 2.4048255576957729)":
+double: 3
+idouble: 3
+Test "jn (4, 2.4048255576957729)":
+double: 1
+idouble: 1
+Test "jn (5, 2.4048255576957729)":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "jn (6, 2.4048255576957729)":
+double: 4
+float: 3
+idouble: 4
+ifloat: 3
+Test "jn (7, 2.4048255576957729)":
+double: 3
+float: 5
+idouble: 3
+ifloat: 5
+Test "jn (8, 2.4048255576957729)":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+Test "jn (9, 2.4048255576957729)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# lgamma
+Test "lgamma (0.7)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "lgamma (1.2)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# log10
+Test "log10 (0.75)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "log10 (e)":
+float: 1
+ifloat: 1
+
+# log1p
+Test "log1p (-0.25)":
+float: 1
+ifloat: 1
+
+# pow
+Test "pow (0x0.ffffffp0, -0x1p24)":
+float: 1
+ifloat: 1
+Test "pow (0x0.ffffffp0, 0x1p24)":
+float: 1
+ifloat: 1
+Test "pow (0x1.000002p0, 0x1p24)":
+float: 1
+ifloat: 1
+
+# pow10
+Test "pow10 (-1)":
+double: 1
+idouble: 1
+Test "pow10 (-305)":
+double: 1
+idouble: 1
+Test "pow10 (-36)":
+double: 1
+idouble: 1
+Test "pow10 (3)":
+double: 1
+idouble: 1
+Test "pow10 (36)":
+double: 1
+idouble: 1
+
+# pow_downward
+Test "pow_downward (1.5, 1.03125)":
+float: 1
+ifloat: 1
+
+# pow_towardzero
+Test "pow_towardzero (1.5, 1.03125)":
+float: 1
+ifloat: 1
+
+# pow_upward
+Test "pow_upward (1.0625, 1.125)":
+float: 1
+ifloat: 1
+
+# sin_downward
+Test "sin_downward (10)":
+float: 1
+ifloat: 1
+Test "sin_downward (3)":
+float: 1
+ifloat: 1
+Test "sin_downward (5)":
+float: 1
+ifloat: 1
+Test "sin_downward (6)":
+float: 1
+ifloat: 1
+
+# sin_tonearest
+Test "sin_tonearest (1)":
+float: 1
+ifloat: 1
+
+# sin_towardzero
+Test "sin_towardzero (1)":
+float: 1
+ifloat: 1
+Test "sin_towardzero (10)":
+float: 1
+ifloat: 1
+Test "sin_towardzero (4)":
+float: 1
+ifloat: 1
+Test "sin_towardzero (5)":
+float: 1
+ifloat: 1
+Test "sin_towardzero (9)":
+float: 1
+ifloat: 1
+
+# sin_upward
+Test "sin_upward (1)":
+float: 1
+ifloat: 1
+Test "sin_upward (2)":
+float: 2
+ifloat: 2
+Test "sin_upward (4)":
+float: 1
+ifloat: 1
+Test "sin_upward (9)":
+float: 1
+ifloat: 1
+
+# sincos
+Test "sincos (0x1p+120) extra output 2":
+float: 1
+ifloat: 1
+Test "sincos (0x1p+127) extra output 2":
+float: 1
+ifloat: 1
+Test "sincos (M_PI_6l*2.0) extra output 1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (M_PI_6l*2.0) extra output 2":
+double: 1
+idouble: 1
+Test "sincos (pi/6) extra output 2":
+float: 1
+ifloat: 1
+
+# sinh_downward
+Test "sinh_downward (22)":
+float: 1
+ifloat: 1
+Test "sinh_downward (23)":
+float: 1
+ifloat: 1
+Test "sinh_downward (24)":
+float: 1
+ifloat: 1
+
+# sinh_towardzero
+Test "sinh_towardzero (22)":
+float: 1
+ifloat: 1
+Test "sinh_towardzero (23)":
+float: 1
+ifloat: 1
+Test "sinh_towardzero (24)":
+float: 1
+ifloat: 1
+
+# tan_downward
+Test "tan_downward (1)":
+float: 1
+ifloat: 1
+Test "tan_downward (10)":
+float: 1
+ifloat: 1
+Test "tan_downward (2)":
+float: 1
+ifloat: 1
+Test "tan_downward (6)":
+float: 1
+ifloat: 1
+Test "tan_downward (8)":
+float: 1
+ifloat: 1
+Test "tan_downward (9)":
+float: 1
+ifloat: 1
+
+# tan_towardzero
+Test "tan_towardzero (10)":
+float: 1
+ifloat: 1
+Test "tan_towardzero (3)":
+float: 1
+ifloat: 1
+Test "tan_towardzero (4)":
+float: 1
+ifloat: 1
+Test "tan_towardzero (5)":
+float: 1
+ifloat: 1
+Test "tan_towardzero (9)":
+float: 1
+ifloat: 1
+
+# tan_upward
+Test "tan_upward (1)":
+float: 1
+ifloat: 1
+Test "tan_upward (10)":
+float: 1
+ifloat: 1
+Test "tan_upward (3)":
+float: 1
+ifloat: 1
+Test "tan_upward (5)":
+float: 1
+ifloat: 1
+
+# tgamma
+Test "tgamma (-0.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (-0x0.fffffffffffff8p0)":
+double: 1
+idouble: 1
+Test "tgamma (-0x0.ffffffp0)":
+float: 1
+ifloat: 1
+Test "tgamma (-0x1.000002p0)":
+double: 2
+idouble: 2
+Test "tgamma (-0x1.0a32a2p+5)":
+float: 2
+ifloat: 2
+Test "tgamma (-0x13.ffffep0)":
+float: 2
+ifloat: 2
+Test "tgamma (-0x14.000000000001p0)":
+double: 1
+idouble: 1
+Test "tgamma (-0x14.00002p0)":
+float: 1
+ifloat: 1
+Test "tgamma (-0x1d.ffffep0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (-0x1e.000000000001p0)":
+double: 3
+idouble: 3
+Test "tgamma (-0x1e.00002p0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (-0x2.0000000000002p0)":
+double: 1
+idouble: 1
+Test "tgamma (-0x2.000004p0)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "tgamma (-0x2.fffffcp0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (-0x27.fffffffffffep0)":
+double: 1
+idouble: 1
+Test "tgamma (-0x28.000000000002p0)":
+double: 1
+idouble: 1
+Test "tgamma (-0x28.00004p0)":
+double: 2
+idouble: 2
+Test "tgamma (-0x29.00004p0)":
+double: 1
+idouble: 1
+Test "tgamma (-0x29.ffffcp0)":
+double: 1
+idouble: 1
+Test "tgamma (-0x3.000004p0)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "tgamma (-0x3.fffffcp0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (-0x3.ffffffffffffep0)":
+double: 2
+idouble: 2
+Test "tgamma (-0x31.fffffffffffep0)":
+double: 3
+idouble: 3
+Test "tgamma (-0x4.000008p0)":
+float: 1
+ifloat: 1
+Test "tgamma (-0x4.fffff8p0)":
+double: 1
+idouble: 1
+Test "tgamma (-0x4.ffffffffffffcp0)":
+double: 1
+idouble: 1
+Test "tgamma (-0x5.000008p0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (-0x5.ffffffffffffcp0)":
+double: 1
+idouble: 1
+Test "tgamma (-0x6.000008p0)":
+float: 2
+ifloat: 2
+Test "tgamma (-0x6.fffff8p0)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "tgamma (-0x6.ffffffffffffcp0)":
+double: 4
+idouble: 4
+Test "tgamma (-0x63.fffffffffffcp0)":
+double: 2
+idouble: 2
+Test "tgamma (-0x64.000000000004p0)":
+double: 1
+idouble: 1
+Test "tgamma (-0x7.0000000000004p0)":
+double: 3
+idouble: 3
+Test "tgamma (-0x7.000008p0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (-0x7.fffff8p0)":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "tgamma (-0x7.ffffffffffffcp0)":
+double: 3
+idouble: 3
+Test "tgamma (-0x8.00001p0)":
+double: 2
+idouble: 2
+Test "tgamma (-0x9.ffffffffffff8p0)":
+double: 1
+idouble: 1
+Test "tgamma (-0x9.fffffp0)":
+float: 1
+ifloat: 1
+Test "tgamma (-0x96.000000000008p0)":
+double: 1
+idouble: 1
+Test "tgamma (-0xa.00001p0)":
+double: 1
+idouble: 1
+Test "tgamma (-2.5)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "tgamma (-3.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (-4.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (-5.5)":
+double: 1
+idouble: 1
+Test "tgamma (-6.5)":
+float: 1
+ifloat: 1
+Test "tgamma (-7.5)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "tgamma (-8.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (-9.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (0.5)":
+float: 1
+ifloat: 1
+Test "tgamma (0.7)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (0x1.fffffep0)":
+float: 1
+ifloat: 1
+Test "tgamma (0x1.fffffffffffffp0)":
+double: 1
+idouble: 1
+Test "tgamma (0x1p-24)":
+float: 1
+ifloat: 1
+Test "tgamma (0x1p-53)":
+double: 1
+idouble: 1
+Test "tgamma (0x2.30a43cp+4)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "tgamma (0x2.fffffcp0)":
+float: 3
+ifloat: 3
+Test "tgamma (0x3.fffffcp0)":
+float: 1
+ifloat: 1
+Test "tgamma (0x3.ffffffffffffep0)":
+double: 1
+idouble: 1
+Test "tgamma (0x4.0000000000004p0)":
+double: 1
+idouble: 1
+Test "tgamma (0x4.ffffffffffffcp0)":
+double: 1
+idouble: 1
+Test "tgamma (0x5.0000000000004p0)":
+double: 1
+idouble: 1
+Test "tgamma (0x5.000008p0)":
+float: 2
+ifloat: 2
+Test "tgamma (0x5.fffff8p0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (0x6.0000000000004p0)":
+double: 1
+idouble: 1
+Test "tgamma (0x6.000008p0)":
+float: 2
+ifloat: 2
+Test "tgamma (0x6.fffff8p0)":
+double: 1
+idouble: 1
+Test "tgamma (0x6.ffffffffffffcp0)":
+double: 4
+idouble: 4
+Test "tgamma (0x7.0000000000004p0)":
+double: 4
+idouble: 4
+Test "tgamma (0x7.000008p0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (0x7.fffff8p0)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "tgamma (0x7.ffffffffffffcp0)":
+double: 2
+idouble: 2
+Test "tgamma (0x8.00001p0)":
+double: 2
+idouble: 2
+Test "tgamma (0xa.b9fd72b0fb238p+4)":
+double: 1
+idouble: 1
+Test "tgamma (10)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (18.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (19.5)":
+double: 2
+idouble: 2
+Test "tgamma (2.5)":
+float: 2
+ifloat: 2
+Test "tgamma (23.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (29.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (3)":
+float: 1
+ifloat: 1
+Test "tgamma (3.5)":
+float: 2
+ifloat: 2
+Test "tgamma (30.5)":
+float: 1
+ifloat: 1
+Test "tgamma (33.5)":
+float: 1
+ifloat: 1
+Test "tgamma (34.5)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "tgamma (4)":
+float: 1
+ifloat: 1
+Test "tgamma (4.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (6)":
+float: 1
+ifloat: 1
+Test "tgamma (6.5)":
+float: 1
+ifloat: 1
+Test "tgamma (7)":
+double: 1
+idouble: 1
+Test "tgamma (7.5)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "tgamma (8)":
+double: 1
+idouble: 1
+Test "tgamma (8.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (9)":
+double: 1
+idouble: 1
+Test "tgamma (9.5)":
+double: 1
+idouble: 1
+
+# y0
+Test "y0 (0x1.3ffp+74)":
+double: 1
+idouble: 1
+Test "y0 (0x1.ff00000000002p+840)":
+double: 1
+idouble: 1
+Test "y0 (0x1p-10)":
+double: 1
+idouble: 1
+Test "y0 (0x1p-110)":
+double: 1
+idouble: 1
+Test "y0 (0x1p-20)":
+float: 1
+ifloat: 1
+Test "y0 (0x1p-30)":
+float: 1
+ifloat: 1
+Test "y0 (0x1p-40)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "y0 (0x1p-50)":
+float: 1
+ifloat: 1
+Test "y0 (0x1p-70)":
+double: 1
+idouble: 1
+Test "y0 (0x1p-80)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "y0 (1.0)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (1.5)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (10.0)":
+float: 1
+ifloat: 1
+Test "y0 (8.0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# y1
+Test "y1 (0.125)":
+double: 1
+idouble: 1
+Test "y1 (0x1.27e204p+99)":
+double: 1
+idouble: 1
+Test "y1 (0x1p-10)":
+double: 1
+idouble: 1
+Test "y1 (1.5)":
+float: 1
+ifloat: 1
+Test "y1 (10.0)":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "y1 (2.0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "y1 (8.0)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# yn
+Test "yn (0, 1.0)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 1.5)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 10.0)":
+float: 1
+ifloat: 1
+Test "yn (0, 8.0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (1, 0.125)":
+double: 1
+idouble: 1
+Test "yn (1, 1.5)":
+float: 1
+ifloat: 1
+Test "yn (1, 10.0)":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "yn (1, 2.0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (1, 8.0)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "yn (10, 0.125)":
+double: 1
+idouble: 1
+Test "yn (10, 0.75)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (10, 1.0)":
+double: 1
+idouble: 1
+Test "yn (10, 10.0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (10, 2.0)":
+double: 2
+idouble: 2
+Test "yn (3, 0.125)":
+double: 1
+idouble: 1
+Test "yn (3, 0.75)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 10.0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 2.0)":
+double: 1
+idouble: 1
+
+# Maximal error of functions:
+Function: "acos_downward":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "acos_towardzero":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "asin_downward":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "asin_towardzero":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "asin_upward":
+float: 1
+ifloat: 1
+
+Function: "atan2":
+float: 1
+ifloat: 1
+
+Function: "atanh":
+float: 1
+ifloat: 1
+
+Function: Real part of "cacos":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Imaginary part of "cacos":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Real part of "cacosh":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Imaginary part of "cacosh":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Real part of "casin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "casin":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Real part of "casinh":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Imaginary part of "casinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "catan":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "catan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "catanh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "catanh":
+float: 1
+ifloat: 1
+
+Function: "cbrt":
+double: 1
+idouble: 1
+
+Function: Real part of "ccos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "cexp":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: Imaginary part of "cexp":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Real part of "clog":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "clog":
+float: 1
+ifloat: 1
+
+Function: Real part of "clog10":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: Imaginary part of "clog10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "cos":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: "cos_downward":
+float: 1
+ifloat: 1
+
+Function: "cos_tonearest":
+float: 1
+ifloat: 1
+
+Function: "cos_towardzero":
+float: 1
+ifloat: 1
+
+Function: "cos_upward":
+float: 2
+ifloat: 2
+
+Function: "cosh_downward":
+float: 1
+ifloat: 1
+
+Function: "cosh_towardzero":
+float: 1
+ifloat: 1
+
+Function: Real part of "cpow":
+double: 2
+float: 4
+idouble: 2
+ifloat: 4
+
+Function: Imaginary part of "cpow":
+float: 2
+ifloat: 2
+
+Function: Real part of "csin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "csinh":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "csqrt":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "csqrt":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "ctan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ctan":
+double: 1
+idouble: 1
+
+Function: Real part of "ctan_downward":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: Imaginary part of "ctan_downward":
+float: 1
+ifloat: 1
+
+Function: Real part of "ctan_tonearest":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "ctan_tonearest":
+float: 1
+ifloat: 1
+
+Function: Real part of "ctan_towardzero":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "ctan_towardzero":
+float: 1
+ifloat: 1
+
+Function: Real part of "ctan_upward":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: Imaginary part of "ctan_upward":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Real part of "ctanh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ctanh":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Real part of "ctanh_downward":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "ctanh_downward":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: Real part of "ctanh_tonearest":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "ctanh_tonearest":
+float: 1
+ifloat: 1
+
+Function: Real part of "ctanh_towardzero":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "ctanh_towardzero":
+float: 1
+ifloat: 1
+
+Function: Real part of "ctanh_upward":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Imaginary part of "ctanh_upward":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: "erf":
+double: 1
+idouble: 1
+
+Function: "erfc":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "exp10":
+double: 1
+idouble: 1
+
+Function: "exp_downward":
+float: 1
+ifloat: 1
+
+Function: "exp_towardzero":
+float: 1
+ifloat: 1
+
+Function: "exp_upward":
+float: 1
+ifloat: 1
+
+Function: "expm1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "gamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "hypot":
+float: 1
+ifloat: 1
+
+Function: "j0":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: "j1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "jn":
+double: 4
+float: 5
+idouble: 4
+ifloat: 5
+
+Function: "lgamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "log10":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "log1p":
+float: 1
+ifloat: 1
+
+Function: "pow":
+float: 1
+ifloat: 1
+
+Function: "pow10":
+double: 1
+idouble: 1
+
+Function: "pow_downward":
+float: 1
+ifloat: 1
+
+Function: "pow_towardzero":
+float: 1
+ifloat: 1
+
+Function: "pow_upward":
+float: 1
+ifloat: 1
+
+Function: "sin_downward":
+float: 1
+ifloat: 1
+
+Function: "sin_tonearest":
+float: 1
+ifloat: 1
+
+Function: "sin_towardzero":
+float: 1
+ifloat: 1
+
+Function: "sin_upward":
+float: 2
+ifloat: 2
+
+Function: "sincos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "sinh_downward":
+float: 1
+ifloat: 1
+
+Function: "sinh_towardzero":
+float: 1
+ifloat: 1
+
+Function: "tan":
+double: 1
+idouble: 1
+
+Function: "tan_downward":
+float: 1
+ifloat: 1
+
+Function: "tan_towardzero":
+float: 1
+ifloat: 1
+
+Function: "tan_upward":
+float: 1
+ifloat: 1
+
+Function: "tgamma":
+double: 4
+float: 3
+idouble: 4
+ifloat: 3
+
+Function: "y0":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: "y1":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+
+Function: "yn":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+
+# end of automatic generation
diff --git a/test/math/libm-test-ulps-mips64 b/test/math/libm-test-ulps-mips64
new file mode 100644
index 000000000..dc065e563
--- /dev/null
+++ b/test/math/libm-test-ulps-mips64
@@ -0,0 +1,9633 @@
+# Begin of automatic generation
+
+# acos_downward
+Test "acos_downward (-0)":
+float: 1
+ifloat: 1
+Test "acos_downward (-0.5)":
+double: 1
+idouble: 1
+Test "acos_downward (-1)":
+float: 1
+ifloat: 1
+Test "acos_downward (0)":
+float: 1
+ifloat: 1
+Test "acos_downward (0.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# acos_towardzero
+Test "acos_towardzero (-0)":
+float: 1
+ifloat: 1
+Test "acos_towardzero (-0.5)":
+double: 1
+idouble: 1
+Test "acos_towardzero (-1)":
+float: 1
+ifloat: 1
+Test "acos_towardzero (0)":
+float: 1
+ifloat: 1
+Test "acos_towardzero (0.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# asin_downward
+Test "asin_downward (-0.5)":
+double: 1
+idouble: 1
+Test "asin_downward (0.5)":
+double: 1
+idouble: 1
+Test "asin_downward (1.0)":
+float: 1
+ifloat: 1
+
+# asin_towardzero
+Test "asin_towardzero (-0.5)":
+double: 1
+idouble: 1
+Test "asin_towardzero (-1.0)":
+float: 1
+ifloat: 1
+Test "asin_towardzero (0.5)":
+double: 1
+idouble: 1
+Test "asin_towardzero (1.0)":
+float: 1
+ifloat: 1
+
+# asin_upward
+Test "asin_upward (-1.0)":
+float: 1
+ifloat: 1
+
+# atan2
+Test "atan2 (-0.00756827042671106339, -.001792735857538728036)":
+ildouble: 1
+ldouble: 1
+Test "atan2 (-0.75, -1.0)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "atan2 (-max_value, -min_value)":
+float: 1
+ifloat: 1
+Test "atan2 (0.75, -1.0)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "atan2 (1.390625, 0.9296875)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# atanh
+Test "atanh (0.75)":
+float: 1
+ifloat: 1
+
+# cacos
+Test "Imaginary part of: cacos (+0 + 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (+0 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (+0 + 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (+0 - 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (+0 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (+0 - 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0 + 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0 + 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0 - 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0 - 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0.0 + 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0.0 + 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0.0 + 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0.0 + 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0.0 + 0x1.0000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0.0 - 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0.0 - 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0.0 - 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0.0 - 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0.0 - 0x1.0000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0.25 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0.25 + 1.0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0.25 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0.25 - 1.0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0.5 + +0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0.5 + 0x1.fp-1025 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0.5 + 0x1.fp-129 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0.5 + 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (-0.5 + 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0.5 + 0x1p-105 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0.5 + 0x1p-105 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0.5 + 0x1p-112 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0.5 + 0x1p-112 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0.5 + 0x1p-23 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0.5 + 0x1p-52 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0.5 + 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0.5 + 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0.5 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0.5 + 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0.5 - 0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0.5 - 0x1.fp-1025 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0.5 - 0x1.fp-129 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0.5 - 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (-0.5 - 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0.5 - 0x1p-105 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0.5 - 0x1p-105 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0.5 - 0x1p-112 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0.5 - 0x1p-112 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0.5 - 0x1p-23 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0.5 - 0x1p-52 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0.5 - 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0.5 - 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0.5 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0.5 - 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x0.fffffffffffff8p0 + 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0x0.fffffffffffff8p0 - 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0x0.ffffffffffffffffffffffffffcp0 + 0x1p-105 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x0.ffffffffffffffffffffffffffcp0 - 0x1p-105 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x0.ffffffffffffffffp0 + 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x0.ffffffffffffffffp0 - 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x0.ffffffp0 + 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cacos (-0x0.ffffffp0 - 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cacos (-0x1.0000000000000000000000000001p0 + 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1.0000000000000000000000000001p0 + 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1.0000000000000000000000000001p0 + 0x1p-113 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1.0000000000000000000000000001p0 - 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1.0000000000000000000000000001p0 - 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1.0000000000000000000000000001p0 - 0x1p-113 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1.000002p0 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1.000002p0 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-10 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-10 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (-0x1.fp-100 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.fp-100 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0x1.fp-100 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.fp-100 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-1000 + 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-1000 - 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-10000 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-10000 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-1025 + 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-1025 + 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-1025 + 0x1.0000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-1025 + 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-1025 + 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-1025 - 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-1025 - 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-1025 - 0x1.0000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-1025 - 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-1025 - 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0x1.fp-129 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.fp-129 + 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0x1.fp-129 + 0x0.ffffffp0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-129 + 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-129 + 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-129 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-129 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.fp-129 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0x1.fp-129 + 1.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.fp-129 + 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0x1.fp-129 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.fp-129 - 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0x1.fp-129 - 0x0.ffffffp0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-129 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-129 - 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-129 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1.fp-129 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.fp-129 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0x1.fp-129 - 1.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.fp-129 - 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-16385 + 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-16385 + 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-16385 + 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-16385 + 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-16385 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-16385 + 1.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-16385 - 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-16385 - 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-16385 - 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-16385 - 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-16385 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1.fp-16385 - 1.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0x1.fp-30 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.fp-30 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0x1.fp-30 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1.fp-30 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0x1p-105 + 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-105 + 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1p-105 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-105 + 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0x1p-105 + 0x1p-105 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-105 - 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-105 - 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1p-105 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-105 - 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0x1p-105 - 0x1p-105 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-112 + 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-112 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-112 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-112 + 0x1p-112 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-112 - 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-112 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-112 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-112 - 0x1p-112 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-113 + 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1p-113 + 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0x1p-113 - 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1p-113 - 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0x1p-23 + 0.0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0x1p-23 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-23 + 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: cacos (-0x1p-23 + 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (-0x1p-23 + 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0x1p-23 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0x1p-23 - 0.0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0x1p-23 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-23 - 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: cacos (-0x1p-23 - 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (-0x1p-23 - 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0x1p-23 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0x1p-52 + 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-52 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-52 + 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0x1p-52 + 0x1p-52 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-52 - 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-52 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-52 - 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0x1p-52 - 0x1p-52 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-63 + 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-63 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-63 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-63 + 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1p-63 + 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0x1p-63 + 0x1p-63 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-63 - 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (-0x1p-63 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-63 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p-63 - 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1p-63 - 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-0x1p-63 - 0x1p-63 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-0x1p500 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1p500 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1p5000 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-0x1p5000 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-1.0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-1.0 + 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-1.0 + 0x1.fp-30 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-1.0 + 0x1p50 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-1.0 + 0x1p500 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-1.0 + 0x1p5000 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-1.0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-1.0 - 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-1.0 - 0x1.fp-30 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-1.0 - 0x1p50 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (-1.0 - 0x1p500 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (-1.0 - 0x1p5000 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (-2 - 3 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0.0 + 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0.0 + 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0.0 + 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0.0 + 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0.0 + 0x1.0000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0.0 - 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0.0 - 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0.0 - 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0.0 - 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0.0 - 0x1.0000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0.25 + 1.0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0.25 - 1.0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (0.5 + +0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 + 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 + 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0.5 + 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 + 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0.5 + 0x1p-105 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (0.5 + 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0.5 + 0x1p-112 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0.5 + 0x1p-23 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (0.5 + 0x1p-52 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (0.5 + 0x1p-63 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0.5 + 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (0.5 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0.5 + 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (0.5 - 0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 - 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 - 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0.5 - 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0.5 - 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0.5 - 0x1p-105 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (0.5 - 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0.5 - 0x1p-112 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0.5 - 0x1p-23 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (0.5 - 0x1p-52 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (0.5 - 0x1p-63 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0.5 - 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (0.5 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0.5 - 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x0.fffffffffffff8p0 + 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x0.fffffffffffff8p0 - 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0x0.ffffffffffffffffffffffffffcp0 + 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (0x0.ffffffffffffffffffffffffffcp0 + 0x1.fp-1025 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x0.ffffffffffffffffffffffffffcp0 + 0x1p-105 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (0x0.ffffffffffffffffffffffffffcp0 - 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (0x0.ffffffffffffffffffffffffffcp0 - 0x1.fp-1025 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x0.ffffffffffffffffffffffffffcp0 - 0x1p-105 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (0x0.ffffffffffffffffffffffffffff8p0 + 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (0x0.ffffffffffffffffffffffffffff8p0 + 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (0x0.ffffffffffffffffffffffffffff8p0 - 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (0x0.ffffffffffffffffffffffffffff8p0 - 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x0.ffffffffffffffffp0 + 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x0.ffffffffffffffffp0 - 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (0x0.ffffffp0 + 0.0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (0x0.ffffffp0 + 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (0x0.ffffffp0 + 0x1p-23 i)":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x0.ffffffp0 + 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Real part of: cacos (0x0.ffffffp0 - 0.0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (0x0.ffffffp0 - 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (0x0.ffffffp0 - 0x1p-23 i)":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x0.ffffffp0 - 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cacos (0x1.0000000000000000000000000001p0 + 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (0x1.0000000000000000000000000001p0 + 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.0000000000000000000000000001p0 + 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.0000000000000000000000000001p0 + 0x1p-113 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.0000000000000000000000000001p0 - 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (0x1.0000000000000000000000000001p0 - 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.0000000000000000000000000001p0 - 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.0000000000000000000000000001p0 - 0x1p-113 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (0x1.0000000000000002p0 + 0x1p-63 i)":
+ildouble: 2
+ldouble: 2
+Test "Real part of: cacos (0x1.0000000000000002p0 - 0x1p-63 i)":
+ildouble: 2
+ldouble: 2
+Test "Real part of: cacos (0x1.0000000000001p0 + 0x1p-52 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (0x1.0000000000001p0 - 0x1p-52 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (0x1.000002p0 + 0x1p-23 i)":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.000002p0 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (0x1.000002p0 - 0x1p-23 i)":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.000002p0 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-10 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x1.fp-10 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0x1.fp-100 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-100 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (0x1.fp-100 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-100 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-1000 + 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-1000 - 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-10000 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-10000 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-1025 + 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-1025 + 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-1025 + 0x1.0000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-1025 + 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-1025 + 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-1025 - 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-1025 - 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-1025 - 0x1.0000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-1025 - 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-1025 - 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-129 + 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-129 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-129 + 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-129 - 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-129 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-129 - 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-16385 + 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-16385 + 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-16385 + 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-16385 + 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-16385 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-16385 + 1.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-16385 - 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-16385 - 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-16385 - 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-16385 - 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-16385 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-16385 - 1.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-30 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp-30 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1.fp1023 + 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x1.fp127 + 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacos (0x1.fp16383 + 0x1.fp16383 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1p-105 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (0x1p-105 + 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1p-105 + 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1p-105 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (0x1p-105 - 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1p-105 - 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1p-112 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (0x1p-112 + 0x0.ffffffffffffffffffffffffffff8p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1p-112 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (0x1p-112 - 0x0.ffffffffffffffffffffffffffff8p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1p-113 + 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1p-113 - 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1p-23 + 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: cacos (0x1p-23 + 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0x1p-23 + 0x1.000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1p-23 - 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: cacos (0x1p-23 - 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (0x1p-23 - 0x1.000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (0x1p-52 + 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1p-52 + 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (0x1p-52 + 0x0.fffffffffffff8p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (0x1p-52 - 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1p-52 - 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (0x1p-52 - 0x0.fffffffffffff8p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (0x1p-63 + 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1p-63 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1p-63 + 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1p-63 + 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (0x1p-63 - 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1p-63 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0x1p-63 - 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1p-63 - 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1p500 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1p500 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1p5000 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (0x1p5000 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (1.0 + 0.25 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (1.0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (1.0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (1.0 + 0x1.fp-10 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cacos (1.0 + 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (1.0 + 0x1.fp-100 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (1.0 + 0x1.fp-30 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (1.0 + 0x1p500 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (1.0 + 0x1p5000 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (1.0 - 0.25 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacos (1.0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacos (1.0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacos (1.0 - 0x1.fp-10 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cacos (1.0 - 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacos (1.0 - 0x1.fp-100 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (1.0 - 0x1.fp-30 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (1.0 - 0x1p500 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacos (1.0 - 0x1p5000 i)":
+ildouble: 1
+ldouble: 1
+
+# cacosh
+Test "Real part of: cacosh (+0 + 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (+0 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (+0 + 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (+0 - 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (+0 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (+0 - 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0 + 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0 + 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0 - 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0 - 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0.0 + 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0.0 + 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0.0 + 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0.0 + 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0.0 + 0x1.0000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0.0 - 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0.0 - 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0.0 - 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0.0 - 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0.0 - 0x1.0000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0.25 + 1.0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0.25 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: cacosh (-0.25 - 1.0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0.25 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0.5 + +0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0.5 + 0x1.fp-1025 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0.5 + 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (-0.5 + 0x1.fp-129 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0.5 + 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0.5 + 0x1p-105 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0.5 + 0x1p-105 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0.5 + 0x1p-112 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0.5 + 0x1p-112 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0.5 + 0x1p-23 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0.5 + 0x1p-52 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0.5 + 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0.5 + 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0.5 + 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0.5 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0.5 - 0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0.5 - 0x1.fp-1025 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0.5 - 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (-0.5 - 0x1.fp-129 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0.5 - 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0.5 - 0x1p-105 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0.5 - 0x1p-105 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0.5 - 0x1p-112 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0.5 - 0x1p-112 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0.5 - 0x1p-23 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0.5 - 0x1p-52 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0.5 - 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0.5 - 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0.5 - 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0.5 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x0.fffffffffffff8p0 + 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0x0.fffffffffffff8p0 - 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0x0.ffffffffffffffffffffffffffcp0 + 0x1p-105 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x0.ffffffffffffffffffffffffffcp0 - 0x1p-105 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x0.ffffffffffffffffp0 + 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x0.ffffffffffffffffp0 - 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x0.ffffffp0 + 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Real part of: cacosh (-0x0.ffffffp0 - 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Real part of: cacosh (-0x1.0000000000000000000000000001p0 + 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1.0000000000000000000000000001p0 + 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1.0000000000000000000000000001p0 + 0x1p-113 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1.0000000000000000000000000001p0 - 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1.0000000000000000000000000001p0 - 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1.0000000000000000000000000001p0 - 0x1p-113 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1.000002p0 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1.000002p0 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1.fp-10 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0x1.fp-10 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (-0x1.fp-100 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0x1.fp-100 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1.fp-100 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0x1.fp-100 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1.fp-1000 + 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1.fp-1000 - 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1.fp-10000 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1.fp-10000 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1.fp-1025 + 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1.fp-1025 + 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1.fp-1025 + 0x1.0000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1.fp-1025 + 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1.fp-1025 + 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1.fp-1025 - 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1.fp-1025 - 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1.fp-1025 - 0x1.0000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1.fp-1025 - 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1.fp-1025 - 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1.fp-129 + 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 + 0x0.ffffffp0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 + 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 + 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1.fp-129 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1.fp-129 + 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 + 1.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1.fp-129 - 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 - 0x0.ffffffp0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 - 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1.fp-129 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1.fp-129 - 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0x1.fp-129 - 1.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1.fp-16385 + 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1.fp-16385 + 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1.fp-16385 + 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1.fp-16385 + 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1.fp-16385 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1.fp-16385 + 1.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1.fp-16385 - 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1.fp-16385 - 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1.fp-16385 - 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1.fp-16385 - 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1.fp-16385 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1.fp-16385 - 1.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1.fp-30 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0x1.fp-30 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1.fp-30 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0x1.fp-30 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-105 + 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-105 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-105 + 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1p-105 + 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0x1p-105 + 0x1p-105 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-105 - 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-105 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-105 - 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1p-105 - 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0x1p-105 - 0x1p-105 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-112 + 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-112 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-112 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-112 + 0x1p-112 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-112 - 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-112 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-112 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-112 - 0x1p-112 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-113 + 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0x1p-113 + 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1p-113 - 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0x1p-113 - 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0x1p-23 + 0.0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1p-23 + 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: cacosh (-0x1p-23 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-23 + 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (-0x1p-23 + 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0x1p-23 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0x1p-23 - 0.0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1p-23 - 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: cacosh (-0x1p-23 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-23 - 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (-0x1p-23 - 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0x1p-23 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0x1p-52 + 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-52 + 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0x1p-52 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-52 + 0x1p-52 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-52 - 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-52 - 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0x1p-52 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-52 - 0x1p-52 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-63 + 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-63 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-63 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-63 + 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1p-63 + 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0x1p-63 + 0x1p-63 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-63 - 0.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-63 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (-0x1p-63 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p-63 - 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1p-63 - 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-0x1p-63 - 0x1p-63 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-0x1p500 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1p500 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1p5000 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-0x1p5000 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-1.0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-1.0 + 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-1.0 + 0x1.fp-30 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-1.0 + 0x1p50 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-1.0 + 0x1p500 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-1.0 + 0x1p5000 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-1.0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-1.0 - 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-1.0 - 0x1.fp-30 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-1.0 - 0x1p50 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (-1.0 - 0x1p500 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (-1.0 - 0x1p5000 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (-2 - 3 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0.0 + 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0.0 + 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0.0 + 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0.0 + 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0.0 + 0x1.0000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0.0 - 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0.0 - 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0.0 - 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0.0 - 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0.0 - 0x1.0000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0.25 + 1.0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0.25 - 1.0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0.5 + +0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0.5 + 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0.5 + 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0.5 + 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0.5 + 0x1p-105 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0.5 + 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0.5 + 0x1p-112 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0.5 + 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0.5 + 0x1p-23 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0.5 + 0x1p-52 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0.5 + 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0.5 + 0x1p-63 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0.5 + 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0.5 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (0.5 - 0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0.5 - 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0.5 - 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0.5 - 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0.5 - 0x1p-105 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0.5 - 0x1p-105 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0.5 - 0x1p-112 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0.5 - 0x1p-112 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0.5 - 0x1p-23 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0.5 - 0x1p-52 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0.5 - 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0.5 - 0x1p-63 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0.5 - 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0.5 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (0x0.fffffffffffff8p0 + 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x0.fffffffffffff8p0 - 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0x0.ffffffffffffffffffffffffffcp0 + 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0x0.ffffffffffffffffffffffffffcp0 + 0x1.fp-1025 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x0.ffffffffffffffffffffffffffcp0 + 0x1p-105 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0x0.ffffffffffffffffffffffffffcp0 - 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0x0.ffffffffffffffffffffffffffcp0 - 0x1.fp-1025 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x0.ffffffffffffffffffffffffffcp0 - 0x1p-105 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0x0.ffffffffffffffffffffffffffff8p0 + 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0x0.ffffffffffffffffffffffffffff8p0 + 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0x0.ffffffffffffffffffffffffffff8p0 - 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0x0.ffffffffffffffffffffffffffff8p0 - 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x0.ffffffffffffffffp0 + 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x0.ffffffffffffffffp0 - 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0x0.ffffffp0 + 0.0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0x0.ffffffp0 + 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x0.ffffffp0 + 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cacosh (0x0.ffffffp0 + 0x1p-23 i)":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0x0.ffffffp0 - 0.0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0x0.ffffffp0 - 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x0.ffffffp0 - 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cacosh (0x0.ffffffp0 - 0x1p-23 i)":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.0000000000000000000000000001p0 + 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.0000000000000000000000000001p0 + 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0x1.0000000000000000000000000001p0 + 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.0000000000000000000000000001p0 + 0x1p-113 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.0000000000000000000000000001p0 - 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.0000000000000000000000000001p0 - 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0x1.0000000000000000000000000001p0 - 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.0000000000000000000000000001p0 - 0x1p-113 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0x1.0000000000000002p0 + 0x1p-63 i)":
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: cacosh (0x1.0000000000000002p0 - 0x1p-63 i)":
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: cacosh (0x1.0000000000001p0 + 0x1p-52 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0x1.0000000000001p0 - 0x1p-52 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.000002p0 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0x1.000002p0 + 0x1p-23 i)":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.000002p0 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0x1.000002p0 - 0x1p-23 i)":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-10 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x1.fp-10 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x1.fp-100 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0x1.fp-100 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-100 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0x1.fp-100 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-1000 + 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-1000 - 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-10000 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-10000 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-1025 + 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-1025 + 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-1025 + 0x1.0000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-1025 + 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-1025 + 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-1025 - 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-1025 - 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-1025 - 0x1.0000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-1025 - 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-1025 - 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-129 + 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-129 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-129 + 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-129 - 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-129 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-129 - 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-16385 + 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-16385 + 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-16385 + 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-16385 + 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-16385 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-16385 + 1.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-16385 - 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-16385 - 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-16385 - 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-16385 - 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-16385 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-16385 - 1.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-30 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp-30 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1.fp1023 + 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x1.fp127 + 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (0x1.fp16383 + 0x1.fp16383 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1p-105 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1p-105 + 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0x1p-105 + 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1p-105 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (0x1p-105 - 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0x1p-105 - 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1p-112 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (0x1p-112 + 0x0.ffffffffffffffffffffffffffff8p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1p-112 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (0x1p-112 - 0x0.ffffffffffffffffffffffffffff8p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1p-113 + 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1p-113 - 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1p-23 + 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Real part of: cacosh (0x1p-23 + 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0x1p-23 + 0x1.000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1p-23 - 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Real part of: cacosh (0x1p-23 - 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cacosh (0x1p-23 - 0x1.000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1p-52 + 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0x1p-52 + 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0x1p-52 + 0x0.fffffffffffff8p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1p-52 - 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0x1p-52 - 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (0x1p-52 - 0x0.fffffffffffff8p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1p-63 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (0x1p-63 + 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1p-63 + 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1p-63 + 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1p-63 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (0x1p-63 - 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1p-63 - 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1p-63 - 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1p500 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1p500 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1p5000 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0x1p5000 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (1.0 + 0.25 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (1.0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (1.0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (1.0 + 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (1.0 + 0x1.fp-10 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cacosh (1.0 + 0x1.fp-100 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (1.0 + 0x1.fp-30 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (1.0 + 0x1p500 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (1.0 + 0x1p5000 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (1.0 - 0.25 i)":
+double: 1
+idouble: 1
+Test "Real part of: cacosh (1.0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cacosh (1.0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: cacosh (1.0 - 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cacosh (1.0 - 0x1.fp-10 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cacosh (1.0 - 0x1.fp-100 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (1.0 - 0x1.fp-30 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (1.0 - 0x1p500 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (1.0 - 0x1p5000 i)":
+ildouble: 1
+ldouble: 1
+
+# casin
+Test "Imaginary part of: casin (+0 + 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (+0 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (+0 + 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (+0 - 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (+0 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (+0 - 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0 + 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0 + 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0 - 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0 - 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0.0 + 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0.0 + 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0.0 + 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0.0 + 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0.0 + 0x1.0000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0.0 - 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0.0 - 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0.0 - 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0.0 - 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0.0 - 0x1.0000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0.25 + 1.0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0.25 - 1.0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0.5 + 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0.5 + 0x1p-105 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-0.5 + 0x1p-112 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0.5 + 0x1p-112 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-0.5 + 0x1p-23 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0.5 + 0x1p-23 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0.5 + 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-0.5 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0.5 + 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0.5 - 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0.5 - 0x1p-105 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-0.5 - 0x1p-112 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0.5 - 0x1p-112 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-0.5 - 0x1p-23 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0.5 - 0x1p-23 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0.5 - 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-0.5 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0.5 - 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-0x0.fffffffffffff8p0 + 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-0x0.fffffffffffff8p0 + 0x1.fp-1025 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x0.fffffffffffff8p0 + 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Real part of: casin (-0x0.fffffffffffff8p0 - 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-0x0.fffffffffffff8p0 - 0x1.fp-1025 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x0.fffffffffffff8p0 - 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Real part of: casin (-0x0.ffffffffffffffffffffffffffcp0 + 0x1p-105 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x0.ffffffffffffffffffffffffffcp0 + 0x1p-105 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-0x0.ffffffffffffffffffffffffffcp0 - 0x1p-105 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x0.ffffffffffffffffffffffffffcp0 - 0x1p-105 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-0x0.ffffffffffffffffffffffffffff8p0 + 0x1p-112 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-0x0.ffffffffffffffffffffffffffff8p0 - 0x1p-112 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-0x0.ffffffffffffffffp0 + 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-0x0.ffffffffffffffffp0 + 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x0.ffffffffffffffffp0 + 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-0x0.ffffffffffffffffp0 - 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-0x0.ffffffffffffffffp0 - 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x0.ffffffffffffffffp0 - 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-0x0.ffffffp0 + 0x1p-23 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x0.ffffffp0 + 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Real part of: casin (-0x0.ffffffp0 - 0x1p-23 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x0.ffffffp0 - 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: casin (-0x1.0000000000000000000000000001p0 + 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.0000000000000000000000000001p0 + 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.0000000000000000000000000001p0 + 0x1p-113 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.0000000000000000000000000001p0 - 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.0000000000000000000000000001p0 - 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.0000000000000000000000000001p0 - 0x1p-113 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.000002p0 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.000002p0 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-0x1.fp-10 + 1.0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-10 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casin (-0x1.fp-10 - 1.0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-10 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (-0x1.fp-100 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-100 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-1000 + 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-1000 - 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-10000 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-10000 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-1025 + 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-0x1.fp-1025 + 0x0.fffffffffffff8p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-1025 + 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-1025 + 0x1.0000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-1025 + 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-1025 + 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-1025 - 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-0x1.fp-1025 - 0x0.fffffffffffff8p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-1025 - 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-1025 - 0x1.0000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-1025 - 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-1025 - 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-129 + 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-129 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-129 + 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-129 - 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-129 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-129 - 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-16385 + 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-16385 + 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-16385 + 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-16385 + 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-16385 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-16385 + 1.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-16385 - 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-16385 - 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-16385 - 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-16385 - 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-16385 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-16385 - 1.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-0x1.fp-30 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-30 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-0x1.fp-30 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1.fp-30 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1p-105 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1p-105 + 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1p-105 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1p-105 - 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1p-112 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1p-112 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casin (-0x1p-113 + 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1p-113 + 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-0x1p-113 - 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1p-113 - 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-0x1p-23 + 0.5 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: casin (-0x1p-23 + 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: casin (-0x1p-23 + 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casin (-0x1p-23 + 0x1.000002p0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-0x1p-23 - 0.5 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: casin (-0x1p-23 - 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: casin (-0x1p-23 - 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casin (-0x1p-23 - 0x1.000002p0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-0x1p-52 + 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1p-52 + 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-0x1p-52 + 0x1.0000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-0x1p-52 - 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1p-52 - 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-0x1p-52 - 0x1.0000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1p-63 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1p-63 + 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-0x1p-63 + 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1p-63 + 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1p-63 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-0x1p-63 - 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-0x1p-63 - 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1p-63 - 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1p500 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1p500 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1p5000 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-0x1p5000 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-1.0 + 0.25 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-1.0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-1.0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-1.0 + 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-1.0 + 0x1.fp-129 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-1.0 + 0x1.fp-30 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-1.0 + 0x1p500 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-1.0 + 0x1p5000 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-1.0 - 0.25 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-1.0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-1.0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (-1.0 - 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (-1.0 - 0x1.fp-129 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-1.0 - 0x1.fp-30 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-1.0 - 0x1p500 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (-1.0 - 0x1p5000 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0.0 + 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0.0 + 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0.0 + 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0.0 + 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0.0 + 0x1.0000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0.0 - 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0.0 - 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0.0 - 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0.0 - 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0.0 - 0x1.0000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0.25 + 1.0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0.25 - 1.0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0.5 + 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0.5 + 0x1p-105 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (0.5 + 0x1p-112 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0.5 + 0x1p-112 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (0.5 + 0x1p-23 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0.5 + 0x1p-23 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0.5 + 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (0.5 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0.5 + 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0.5 - 0x1.fp-129 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0.5 - 0x1p-105 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (0.5 - 0x1p-112 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0.5 - 0x1p-112 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (0.5 - 0x1p-23 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0.5 - 0x1p-23 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0.5 - 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (0.5 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0.5 - 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (0.75 + 1.25 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: casin (0x0.fffffffffffff8p0 + 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (0x0.fffffffffffff8p0 + 0x1.fp-1025 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x0.fffffffffffff8p0 + 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Real part of: casin (0x0.fffffffffffff8p0 - 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (0x0.fffffffffffff8p0 - 0x1.fp-1025 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x0.fffffffffffff8p0 - 0x1p-52 i)":
+double: 1
+idouble: 1
+Test "Real part of: casin (0x0.ffffffffffffffffffffffffffcp0 + 0x1p-105 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x0.ffffffffffffffffffffffffffcp0 + 0x1p-105 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (0x0.ffffffffffffffffffffffffffcp0 - 0x1p-105 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x0.ffffffffffffffffffffffffffcp0 - 0x1p-105 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (0x0.ffffffffffffffffffffffffffff8p0 + 0x1p-112 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (0x0.ffffffffffffffffffffffffffff8p0 - 0x1p-112 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (0x0.ffffffffffffffffp0 + 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (0x0.ffffffffffffffffp0 + 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x0.ffffffffffffffffp0 + 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (0x0.ffffffffffffffffp0 - 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (0x0.ffffffffffffffffp0 - 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x0.ffffffffffffffffp0 - 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (0x0.ffffffp0 + 0x1p-23 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x0.ffffffp0 + 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Real part of: casin (0x0.ffffffp0 - 0x1p-23 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x0.ffffffp0 - 0x1p-23 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: casin (0x1.0000000000000000000000000001p0 + 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.0000000000000000000000000001p0 + 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.0000000000000000000000000001p0 + 0x1p-113 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.0000000000000000000000000001p0 - 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.0000000000000000000000000001p0 - 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.0000000000000000000000000001p0 - 0x1p-113 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.000002p0 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.000002p0 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (0x1.fp-10 + 1.0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-10 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casin (0x1.fp-10 - 1.0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-10 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0x1.fp-100 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-100 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-1000 + 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-1000 - 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-10000 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-10000 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-1025 + 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (0x1.fp-1025 + 0x0.fffffffffffff8p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-1025 + 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-1025 + 0x1.0000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-1025 + 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-1025 + 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-1025 - 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (0x1.fp-1025 - 0x0.fffffffffffff8p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-1025 - 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-1025 - 0x1.0000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-1025 - 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-1025 - 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-129 + 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-129 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-129 + 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-129 - 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-129 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-129 - 1.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-16385 + 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-16385 + 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-16385 + 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-16385 + 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-16385 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-16385 + 1.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-16385 - 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-16385 - 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-16385 - 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-16385 - 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-16385 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-16385 - 1.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (0x1.fp-30 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-30 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (0x1.fp-30 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp-30 - 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1.fp1023 + 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0x1.fp127 + 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casin (0x1.fp16383 + 0x1.fp16383 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1p-105 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1p-105 + 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1p-105 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1p-105 - 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1p-112 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1p-112 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casin (0x1p-113 + 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1p-113 + 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (0x1p-113 - 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1p-113 - 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (0x1p-23 + 0.5 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: casin (0x1p-23 + 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: casin (0x1p-23 + 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casin (0x1p-23 + 0x1.000002p0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (0x1p-23 - 0.5 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: casin (0x1p-23 - 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: casin (0x1p-23 - 0x0.ffffffp0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casin (0x1p-23 - 0x1.000002p0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (0x1p-52 + 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1p-52 + 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (0x1p-52 + 0x1.0000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (0x1p-52 - 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1p-52 - 0.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (0x1p-52 - 0x1.0000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1p-63 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1p-63 + 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (0x1p-63 + 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1p-63 + 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1p-63 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (0x1p-63 - 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (0x1p-63 - 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1p-63 - 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1p500 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1p500 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1p5000 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (0x1p5000 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (1.0 + 0.25 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (1.0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (1.0 + 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (1.0 + 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (1.0 + 0x1.fp-129 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (1.0 + 0x1.fp-30 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (1.0 + 0x1p500 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (1.0 + 0x1p5000 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (1.0 - 0.25 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (1.0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (1.0 - 0.5 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casin (1.0 - 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (1.0 - 0x1.fp-129 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (1.0 - 0x1.fp-30 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (1.0 - 0x1p500 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casin (1.0 - 0x1p5000 i)":
+ildouble: 1
+ldouble: 1
+
+# casinh
+Test "Imaginary part of: casinh (-0.0 + 0x0.fffffffffffff8p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (-0.0 + 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0.0 + 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (-0.0 - 0x0.fffffffffffff8p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (-0.0 - 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0.0 - 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (-0.25 + 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (-0.25 - 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0.5 + +0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0.5 + 0x1.fp-1025 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0.5 + 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0.5 + 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0.5 + 0x1p-105 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 + 0x1p-112 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: casinh (-0.5 + 0x1p-23 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Real part of: casinh (-0.5 + 0x1p-52 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (-0.5 + 0x1p-52 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0.5 + 0x1p-63 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (-0.5 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 - 0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0.5 - 0x1.fp-1025 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0.5 - 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0.5 - 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0.5 - 0x1p-105 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 - 0x1p-112 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: casinh (-0.5 - 0x1p-23 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Real part of: casinh (-0.5 - 0x1p-52 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (-0.5 - 0x1p-52 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0.5 - 0x1p-63 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (-0.5 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (-0.5 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (-0x0.fffffffffffff8p0 + 0x1.fp-1025 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (-0x0.fffffffffffff8p0 - 0x1.fp-1025 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x0.ffffffffffffffffffffffffffcp0 + 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x0.ffffffffffffffffffffffffffcp0 + 0x1.fp-1025 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x0.ffffffffffffffffffffffffffcp0 + 0x1p-105 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x0.ffffffffffffffffffffffffffcp0 - 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x0.ffffffffffffffffffffffffffcp0 - 0x1.fp-1025 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x0.ffffffffffffffffffffffffffcp0 - 0x1p-105 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x0.ffffffffffffffffp0 + 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x0.ffffffffffffffffp0 + 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x0.ffffffffffffffffp0 + 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x0.ffffffffffffffffp0 - 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x0.ffffffffffffffffp0 - 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x0.ffffffffffffffffp0 - 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x0.ffffffp0 + 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-0x0.ffffffp0 - 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-0x1.0000000000000000000000000001p0 + 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1.0000000000000000000000000001p0 + 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1.0000000000000000000000000001p0 + 0x1p-113 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (-0x1.0000000000000000000000000001p0 + 0x1p-113 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1.0000000000000000000000000001p0 - 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1.0000000000000000000000000001p0 - 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1.0000000000000000000000000001p0 - 0x1p-113 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (-0x1.0000000000000000000000000001p0 - 0x1p-113 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1.0000000000000002p0 + 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1.0000000000000002p0 + 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1.0000000000000002p0 + 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (-0x1.0000000000000002p0 + 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1.0000000000000002p0 - 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1.0000000000000002p0 - 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1.0000000000000002p0 - 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (-0x1.0000000000000002p0 - 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1.0000000000001p0 + 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1.0000000000001p0 + 0x1.fp-1025 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (-0x1.0000000000001p0 + 0x1p-52 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1.0000000000001p0 - 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1.0000000000001p0 - 0x1.fp-1025 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (-0x1.0000000000001p0 - 0x1p-52 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (-0x1.000002p0 + 0x1p-23 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (-0x1.000002p0 - 0x1p-23 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1.fp-10 + 1.0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1.fp-10 - 1.0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (-0x1.fp-1025 + 0x0.fffffffffffff8p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (-0x1.fp-1025 - 0x0.fffffffffffff8p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1.fp-129 + 0.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casinh (-0x1.fp-129 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1.fp-129 - 0.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casinh (-0x1.fp-129 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (-0x1.fp-16385 + 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1.fp-16385 + 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (-0x1.fp-16385 - 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1.fp-16385 - 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1.fp-30 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1.fp-30 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1p-105 + 0.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1p-105 + 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (-0x1p-105 + 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1p-105 - 0.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1p-105 - 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (-0x1p-105 - 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1p-112 + 0.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (-0x1p-112 + 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (-0x1p-112 + 0x0.ffffffffffffffffffffffffffff8p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1p-112 - 0.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (-0x1p-112 - 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (-0x1p-112 - 0x0.ffffffffffffffffffffffffffff8p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1p-113 + 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1p-113 - 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1p-23 + 0.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (-0x1p-23 + 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1p-23 + 0x0.ffffffp0 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: casinh (-0x1p-23 + 0x0.ffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1p-23 + 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1p-23 - 0.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (-0x1p-23 - 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1p-23 - 0x0.ffffffp0 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: casinh (-0x1p-23 - 0x0.ffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1p-23 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1p-52 + 0x0.fffffffffffff8p0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-0x1p-52 - 0x0.fffffffffffff8p0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (-0x1p-63 + 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1p-63 + 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1p-63 - 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1p-63 - 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1p500 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1p500 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1p5000 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-0x1p5000 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-1.0 + +0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-1.0 + 0.25 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-1.0 + 0.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (-1.0 + 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-1.0 + 0x1.fp-10 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casinh (-1.0 + 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-1.0 + 0x1.fp-100 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-1.0 + 0x1.fp-1000 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-1.0 + 0x1.fp-10000 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-1.0 + 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-1.0 + 0x1.fp-129 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-1.0 + 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-1.0 + 0x1.fp-30 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (-1.0 + 0x1.fp-30 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-1.0 + 0x1p500 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-1.0 + 0x1p5000 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-1.0 - 0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-1.0 - 0.25 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-1.0 - 0.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (-1.0 - 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-1.0 - 0x1.fp-10 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casinh (-1.0 - 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-1.0 - 0x1.fp-100 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-1.0 - 0x1.fp-1000 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-1.0 - 0x1.fp-10000 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-1.0 - 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-1.0 - 0x1.fp-129 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-1.0 - 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-1.0 - 0x1.fp-30 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (-1.0 - 0x1.fp-30 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-1.0 - 0x1p500 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-1.0 - 0x1p5000 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-1.5 + +0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-1.5 + 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-1.5 + 0x1.fp-129 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-1.5 + 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-1.5 - 0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-1.5 - 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-1.5 - 0x1.fp-129 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (-1.5 - 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0.0 + 0x0.fffffffffffff8p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0.0 + 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0.0 + 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0.0 - 0x0.fffffffffffff8p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0.0 - 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0.0 - 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0.25 + 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0.25 - 1.0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0.5 + +0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0.5 + 0x1.fp-1025 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0.5 + 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0.5 + 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0.5 + 0x1p-105 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 + 0x1p-112 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 + 0x1p-23 i)":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: casinh (0.5 + 0x1p-23 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Real part of: casinh (0.5 + 0x1p-52 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0.5 + 0x1p-52 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0.5 + 0x1p-63 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (0.5 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 - 0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0.5 - 0x1.fp-1025 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0.5 - 0x1.fp-129 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0.5 - 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0.5 - 0x1p-105 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 - 0x1p-112 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 - 0x1p-23 i)":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: casinh (0.5 - 0x1p-23 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Real part of: casinh (0.5 - 0x1p-52 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0.5 - 0x1p-52 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0.5 - 0x1p-63 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.5 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (0.5 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: casinh (0.75 + 1.25 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0.75 + 1.25 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0x0.fffffffffffff8p0 + 0x1.fp-1025 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0x0.fffffffffffff8p0 - 0x1.fp-1025 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x0.ffffffffffffffffffffffffffcp0 + 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x0.ffffffffffffffffffffffffffcp0 + 0x1.fp-1025 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x0.ffffffffffffffffffffffffffcp0 + 0x1p-105 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x0.ffffffffffffffffffffffffffcp0 - 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x0.ffffffffffffffffffffffffffcp0 - 0x1.fp-1025 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x0.ffffffffffffffffffffffffffcp0 - 0x1p-105 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x0.ffffffffffffffffp0 + 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x0.ffffffffffffffffp0 + 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x0.ffffffffffffffffp0 + 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x0.ffffffffffffffffp0 - 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x0.ffffffffffffffffp0 - 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x0.ffffffffffffffffp0 - 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x0.ffffffp0 + 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (0x0.ffffffp0 - 0x1p-23 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (0x1.0000000000000000000000000001p0 + 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1.0000000000000000000000000001p0 + 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1.0000000000000000000000000001p0 + 0x1p-113 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0x1.0000000000000000000000000001p0 + 0x1p-113 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1.0000000000000000000000000001p0 - 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1.0000000000000000000000000001p0 - 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1.0000000000000000000000000001p0 - 0x1p-113 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0x1.0000000000000000000000000001p0 - 0x1p-113 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1.0000000000000002p0 + 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1.0000000000000002p0 + 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1.0000000000000002p0 + 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0x1.0000000000000002p0 + 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1.0000000000000002p0 - 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1.0000000000000002p0 - 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1.0000000000000002p0 - 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0x1.0000000000000002p0 - 0x1p-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1.0000000000001p0 + 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1.0000000000001p0 + 0x1.fp-1025 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0x1.0000000000001p0 + 0x1p-52 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1.0000000000001p0 - 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1.0000000000001p0 - 0x1.fp-1025 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0x1.0000000000001p0 - 0x1p-52 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0x1.000002p0 + 0x1p-23 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0x1.000002p0 - 0x1p-23 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1.fp-10 + 1.0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1.fp-10 - 1.0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0x1.fp-1025 + 0x0.fffffffffffff8p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0x1.fp-1025 - 0x0.fffffffffffff8p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1.fp-129 + 0.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casinh (0x1.fp-129 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1.fp-129 - 0.5 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casinh (0x1.fp-129 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0x1.fp-16385 + 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1.fp-16385 + 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0x1.fp-16385 - 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1.fp-16385 - 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1.fp-30 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1.fp-30 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1.fp1023 + 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (0x1.fp127 + 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (0x1.fp16383 + 0x1.fp16383 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1p-105 + 0.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1p-105 + 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0x1p-105 + 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1p-105 - 0.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1p-105 - 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0x1p-105 - 0x0.ffffffffffffffffffffffffffcp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1p-112 + 0.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0x1p-112 + 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0x1p-112 + 0x0.ffffffffffffffffffffffffffff8p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1p-112 - 0.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0x1p-112 - 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0x1p-112 - 0x0.ffffffffffffffffffffffffffff8p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1p-113 + 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1p-113 - 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1p-23 + 0.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0x1p-23 + 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1p-23 + 0x0.ffffffp0 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: casinh (0x1p-23 + 0x0.ffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1p-23 + 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1p-23 - 0.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0x1p-23 - 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1p-23 - 0x0.ffffffp0 i)":
+float: 2
+ifloat: 2
+Test "Imaginary part of: casinh (0x1p-23 - 0x0.ffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1p-23 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1p-52 + 0x0.fffffffffffff8p0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (0x1p-52 - 0x0.fffffffffffff8p0 i)":
+double: 1
+idouble: 1
+Test "Real part of: casinh (0x1p-63 + 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1p-63 + 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1p-63 - 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1p-63 - 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1p500 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1p500 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1p5000 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0x1p5000 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (1.0 + +0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (1.0 + 0.25 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (1.0 + 0.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (1.0 + 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (1.0 + 0x1.fp-10 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casinh (1.0 + 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (1.0 + 0x1.fp-100 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (1.0 + 0x1.fp-1000 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (1.0 + 0x1.fp-10000 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (1.0 + 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (1.0 + 0x1.fp-129 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (1.0 + 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (1.0 + 0x1.fp-30 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (1.0 + 0x1.fp-30 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (1.0 + 0x1p500 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (1.0 + 0x1p5000 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (1.0 - 0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (1.0 - 0.25 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (1.0 - 0.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (1.0 - 0.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (1.0 - 0x1.fp-10 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: casinh (1.0 - 0x1.fp-10 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (1.0 - 0x1.fp-100 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (1.0 - 0x1.fp-1000 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (1.0 - 0x1.fp-10000 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (1.0 - 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (1.0 - 0x1.fp-129 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (1.0 - 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (1.0 - 0x1.fp-30 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (1.0 - 0x1.fp-30 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (1.0 - 0x1p500 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (1.0 - 0x1p5000 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (1.5 + +0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (1.5 + 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (1.5 + 0x1.fp-129 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (1.5 + 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (1.5 - 0 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (1.5 - 0x1.fp-1025 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (1.5 - 0x1.fp-129 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (1.5 - 0x1.fp-16385 i)":
+ildouble: 1
+ldouble: 1
+
+# catan
+Test "Imaginary part of: catan (-0x0.fffffffffffff8p0 + 0x1p-27 i)":
+double: 1
+idouble: 1
+Test "Real part of: catan (-0x0.ffffffffffffffffffffffffffff8p0 + 0x1p-16382 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catan (-0x0.ffffffffffffffffffffffffffff8p0 + 0x1p-57 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: catan (-0x0.ffffffffffffffffffffffffffff8p0 - 0x1p-16382 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: catan (-0x0.ffffffp0 + 0x1p-126 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catan (-0x0.ffffffp0 + 0x1p-13 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: catan (-0x0.ffffffp0 - 0x1p-126 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catan (-0x1.0000000000000000000000000001p0 + 0x1p-16382 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catan (-0x1.0000000000000000000000000001p0 - 0x1p-16382 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catan (-0x1.0000000000000000000000000001p0 - 0x1p-57 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catan (-0x1.0000000000001p0 - 0x1p-27 i)":
+double: 1
+idouble: 1
+Test "Real part of: catan (-0x1.000002p0 + 0x1p-126 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: catan (-0x1.000002p0 + 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (-0x1.000002p0 - 0x1p-126 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: catan (-0x1.000002p0 - 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (-0x1.000002p0 - 0x1p-13 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (-0x1.fp1023 + 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (-0x1.fp1023 - 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (-0x1.fp127 + 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (-0x1.fp127 - 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (-0x1.fp16383 + 0x1.fp16383 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catan (-0x1.fp16383 - 0x1.fp16383 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catan (-0x1p-1020 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (-0x1p-1020 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: catan (-0x1p-13 + 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (-0x1p-13 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (-0x1p-13 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (-0x1p-13 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (-0x1p-13 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (-0x1p-16380 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catan (-0x1p-16380 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: catan (-0x1p-33 + 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: catan (-0x1p-33 + 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: catan (-0x1p-33 - 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: catan (-0x1p-33 - 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catan (-0x1p-54 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (-0x1p-54 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (-0x1p-57 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (-0x1p-57 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (-1.0 + 0x1p-13 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: catan (-1.0 - 0x1p-13 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catan (-2 - 3 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: catan (0.75 + 1.25 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catan (0x0.fffffffffffff8p0 + 0x1p-27 i)":
+double: 1
+idouble: 1
+Test "Real part of: catan (0x0.ffffffffffffffffffffffffffff8p0 + 0x1p-16382 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catan (0x0.ffffffffffffffffffffffffffff8p0 + 0x1p-57 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: catan (0x0.ffffffffffffffffffffffffffff8p0 - 0x1p-16382 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: catan (0x0.ffffffp0 + 0x1p-126 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catan (0x0.ffffffp0 + 0x1p-13 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: catan (0x0.ffffffp0 - 0x1p-126 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catan (0x1.0000000000000000000000000001p0 + 0x1p-16382 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catan (0x1.0000000000000000000000000001p0 - 0x1p-16382 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catan (0x1.0000000000000000000000000001p0 - 0x1p-57 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catan (0x1.0000000000001p0 - 0x1p-27 i)":
+double: 1
+idouble: 1
+Test "Real part of: catan (0x1.000002p0 + 0x1p-126 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: catan (0x1.000002p0 + 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (0x1.000002p0 - 0x1p-126 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: catan (0x1.000002p0 - 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (0x1.000002p0 - 0x1p-13 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (0x1.fp1023 + 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (0x1.fp1023 - 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (0x1.fp127 + 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (0x1.fp127 - 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (0x1.fp16383 + 0x1.fp16383 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catan (0x1.fp16383 - 0x1.fp16383 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catan (0x1p-1020 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catan (0x1p-1020 - 1.0 i)":
+double: 1
+idouble: 1
+Test "Real part of: catan (0x1p-13 + 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (0x1p-13 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (0x1p-13 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (0x1p-13 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (0x1p-13 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (0x1p-16380 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catan (0x1p-16380 - 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: catan (0x1p-33 + 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: catan (0x1p-33 + 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: catan (0x1p-33 - 0x0.ffffffffffffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: catan (0x1p-33 - 0x1.0000000000000002p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catan (0x1p-54 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (0x1p-54 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (0x1p-57 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catan (0x1p-57 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catan (1.0 + 0x1p-13 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: catan (1.0 - 0x1p-13 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# catanh
+Test "Imaginary part of: catanh (-0x0.ffffffffffffffffp0 + 0x1p-33 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catanh (-0x0.ffffffffffffffffp0 - 0x1p-33 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catanh (-0x1.0000000000000002p0 + 0x1p-33 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catanh (-0x1.0000000000000002p0 - 0x1p-33 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: catanh (-0x1.000002p0 + 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catanh (-0x1.000002p0 + 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (-0x1.000002p0 - 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catanh (-0x1.000002p0 - 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (-0x1.fp1023 + 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Real part of: catanh (-0x1.fp1023 - 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Real part of: catanh (-0x1.fp127 + 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Real part of: catanh (-0x1.fp127 - 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Real part of: catanh (-0x1.fp16383 + 0x1.fp16383 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: catanh (-0x1.fp16383 - 0x1.fp16383 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catanh (-0x1p-126 + 0x0.ffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catanh (-0x1p-126 + 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catanh (-0x1p-126 - 0x0.ffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catanh (-0x1p-126 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: catanh (-0x1p-13 + 0x1.000002p0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (-0x1p-13 + 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catanh (-0x1p-13 + 1.0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: catanh (-0x1p-13 - 0x1.000002p0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (-0x1p-13 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catanh (-0x1p-13 - 1.0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catanh (-0x1p-16382 + 0x0.ffffffffffffffffffffffffffff8p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: catanh (-0x1p-16382 + 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catanh (-0x1p-16382 - 0x0.ffffffffffffffffffffffffffff8p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: catanh (-0x1p-16382 - 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: catanh (-0x1p-27 + 0x1.0000000000001p0 i)":
+double: 1
+idouble: 1
+Test "Real part of: catanh (-0x1p-27 - 0x1.0000000000001p0 i)":
+double: 1
+idouble: 1
+Test "Real part of: catanh (-0x1p-57 + 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: catanh (-0x1p-57 - 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: catanh (-1.0 + 0x1p-1020 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (-1.0 + 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (-1.0 + 0x1p-16380 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: catanh (-1.0 + 0x1p-54 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (-1.0 + 0x1p-57 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (-1.0 - 0x1p-1020 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (-1.0 - 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (-1.0 - 0x1p-16380 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: catanh (-1.0 - 0x1p-54 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (-1.0 - 0x1p-57 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (-2 - 3 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: catanh (0.75 + 1.25 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catanh (0.75 + 1.25 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catanh (0x0.ffffffffffffffffp0 + 0x1p-33 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catanh (0x0.ffffffffffffffffp0 - 0x1p-33 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catanh (0x1.0000000000000002p0 + 0x1p-33 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catanh (0x1.0000000000000002p0 - 0x1p-33 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catanh (0x1.000002p0 + 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catanh (0x1.000002p0 - 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (0x1.fp1023 + 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Real part of: catanh (0x1.fp1023 - 0x1.fp1023 i)":
+double: 1
+idouble: 1
+Test "Real part of: catanh (0x1.fp127 + 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Real part of: catanh (0x1.fp127 - 0x1.fp127 i)":
+double: 1
+idouble: 1
+Test "Real part of: catanh (0x1.fp16383 + 0x1.fp16383 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: catanh (0x1.fp16383 - 0x1.fp16383 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catanh (0x1p-126 + 0x0.ffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catanh (0x1p-126 + 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catanh (0x1p-126 - 0x0.ffffffp0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catanh (0x1p-126 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: catanh (0x1p-13 + 0x0.ffffffp0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catanh (0x1p-13 + 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catanh (0x1p-13 + 1.0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: catanh (0x1p-13 - 0x0.ffffffp0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catanh (0x1p-13 - 0x1.000002p0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catanh (0x1p-13 - 1.0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catanh (0x1p-16382 + 0x0.ffffffffffffffffffffffffffff8p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: catanh (0x1p-16382 + 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catanh (0x1p-16382 - 0x0.ffffffffffffffffffffffffffff8p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: catanh (0x1p-16382 - 0x1.0000000000000000000000000001p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: catanh (0x1p-27 + 0x0.fffffffffffff8p0 i)":
+double: 1
+idouble: 1
+Test "Real part of: catanh (0x1p-27 - 0x0.fffffffffffff8p0 i)":
+double: 1
+idouble: 1
+Test "Real part of: catanh (0x1p-57 + 0x0.ffffffffffffffffffffffffffff8p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: catanh (0x1p-57 - 0x0.ffffffffffffffffffffffffffff8p0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: catanh (1.0 + 0x1p-1020 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (1.0 + 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (1.0 + 0x1p-16380 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: catanh (1.0 + 0x1p-54 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (1.0 + 0x1p-57 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (1.0 - 0x1p-1020 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (1.0 - 0x1p-13 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (1.0 - 0x1p-16380 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: catanh (1.0 - 0x1p-54 i)":
+float: 1
+ifloat: 1
+Test "Real part of: catanh (1.0 - 0x1p-57 i)":
+float: 1
+ifloat: 1
+
+# cbrt
+Test "cbrt (-0.001)":
+ildouble: 1
+ldouble: 1
+Test "cbrt (-27.0)":
+double: 1
+idouble: 1
+Test "cbrt (0.75)":
+double: 1
+idouble: 1
+Test "cbrt (0.9921875)":
+double: 1
+idouble: 1
+
+# ccos
+Test "Imaginary part of: ccos (-0.75 + 11357.25 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccos (-0.75 + 710.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccos (-0.75 + 89.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccos (-0.75 + 89.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccos (-0.75 - 11357.25 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccos (-0.75 - 710.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccos (-0.75 - 89.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccos (-0.75 - 89.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccos (-2 - 3 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccos (-2 - 3 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccos (0.75 + 1.25 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccos (0.75 + 1.25 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccos (0.75 + 11357.25 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccos (0.75 + 710.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccos (0.75 + 89.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccos (0.75 + 89.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccos (0.75 - 11357.25 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccos (0.75 - 710.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccos (0.75 - 89.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccos (0.75 - 89.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccos (0x1p-1074 + 1440 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: ccos (0x1p-16434 + 22730 i)":
+ildouble: 1
+ldouble: 1
+
+# ccosh
+Test "Imaginary part of: ccosh (-11357.25 + 0.75 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccosh (-11357.25 - 0.75 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccosh (-2 - 3 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccosh (-2 - 3 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccosh (-710.5 + 0.75 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccosh (-710.5 - 0.75 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccosh (-89.5 + 0.75 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccosh (-89.5 + 0.75 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccosh (-89.5 - 0.75 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccosh (-89.5 - 0.75 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccosh (0.75 + 1.25 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (0.75 + 1.25 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (11357.25 + 0.75 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccosh (11357.25 - 0.75 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccosh (1440 + 0x1p-1074 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: ccosh (22730 + 0x1p-16434 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccosh (710.5 + 0.75 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccosh (710.5 - 0.75 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccosh (89.5 + 0.75 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccosh (89.5 + 0.75 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccosh (89.5 - 0.75 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccosh (89.5 - 0.75 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# cexp
+Test "Imaginary part of: cexp (-10000 + 0x1p16383 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cexp (-2.0 - 3.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cexp (-2.0 - 3.0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cexp (-720 + 0.75 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cexp (-95 + 0.75 i)":
+double: 1
+idouble: 1
+Test "Real part of: cexp (0.75 + 1.25 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cexp (0.75 + 1.25 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cexp (1440 + 0x1p-1074 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cexp (22730 + 0x1p-16434 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cexp (50 + 0x1p127 i)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cexp (50 + 0x1p127 i)":
+double: 1
+idouble: 1
+Test "Real part of: cexp (500 + 0x1p1023 i)":
+double: 1
+idouble: 1
+Test "Real part of: cexp (709.8125 + 0.75 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: cexp (709.8125 + 0.75 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cexp (88.75 + 0.75 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cexp (88.75 + 0.75 i)":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# clog
+Test "Real part of: clog (-0x1.0000000123456p0 + 0x1.2345678p-1000 i)":
+double: 1
+idouble: 1
+Test "Real part of: clog (-0x1.0000000123456p0 + 0x1.2345678p-30 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog (-0x1.234566p-40 - 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog (-0x1.fp+127 + 0x1p-149 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog (-0x1.fp+127 - 0x1p-149 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog (-0x1.fp+16383 + 0x1p-16445 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog (-0x1.fp+16383 + 0x1p-16494 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog (-0x1.fp+16383 - 0x1p-16445 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog (-0x1.fp+16383 - 0x1p-16494 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog (-0x1p-149 + 0x1.fp+127 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog (-0x1p-149 + 0x1.fp+127 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog (-0x1p-149 - 0x1.fp+127 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog (-0x1p-149 - 0x1.fp+127 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog (-0x1p-16445 + 0x1.fp+16383 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog (-0x1p-16445 - 0x1.fp+16383 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog (-0x1p-16494 + 0x1.fp+16383 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog (-0x1p-16494 - 0x1.fp+16383 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog (0x0.ffffffp0 + 0x0.ffffffp-100 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog (0x1.000566p0 + 0x1.234p-10 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog (0x1.000566p0 + 0x1.234p-10 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog (0x1.fp+127 + 0x1p-149 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog (0x1.fp+127 - 0x1p-149 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog (0x1.fp+16383 + 0x1.fp+16383 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog (0x1.fp+16383 + 0x1p-16445 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog (0x1.fp+16383 + 0x1p-16494 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog (0x1.fp+16383 - 0x1p-16445 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog (0x1.fp+16383 - 0x1p-16494 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog (0x10673dd0f2481p-51 + 0x7ef1d17cefbd2p-51 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog (0x1p-1074 + 0x1p-1074 i)":
+double: 1
+idouble: 1
+Test "Real part of: clog (0x1p-147 + 0x1p-147 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog (0x1p-149 + 0x1.fp+127 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog (0x1p-149 - 0x1.fp+127 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog (0x1p-16445 + 0x1.fp+16383 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog (0x1p-16445 - 0x1.fp+16383 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog (0x1p-16494 + 0x1.fp+16383 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog (0x1p-16494 - 0x1.fp+16383 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog (0x2818p-15 + 0x798fp-15 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog (0x298c62cb546588a7p-63 + 0x7911b1dfcc4ecdaep-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog (0x2ede88p-23 + 0x771c3fp-23 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog (0x3f96469050f650869c2p-75 + 0x6f16b2c9c8b05988335p-75 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog (0x55cb6d0c83af5p-55 + 0x7fe33c0c7c4e90p-55 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog (0x5b06b680ea2ccp-52 + 0xef452b965da9fp-52 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog (0x659feap-24 + 0xeaf6f9p-24 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog (0x6771f22c64ed551b857c128b4cp-105 + 0x1f570e7a13cc3cf2f44fd793ea1p-105 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog (0x6b10b4f3520217b6p-64 + 0xe8893cbb449253a1p-64 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog (0x8ecbf810c4ae6p-52 + 0xd479468b09a37p-52 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog (0x9b57bp-20 + 0xcb7b4p-20 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog (0xdb85c467ee2aadd5f425fe0f4b8dp-114 + 0x3e83162a0f95f1dcbf97dddf410eap-114 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog (0xfd95243681c055c2632286921092p-113 + 0x1bccabcd29ca2152860ec29e34ef7p-113 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog (0xfe961079616p-45 + 0x1bc37e09e6d1p-45 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog (1.0 + 0x1.234566p-10 i)":
+float: 1
+ifloat: 1
+
+# clog10
+Test "Imaginary part of: clog10 (-0 + inf i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-0 - inf i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: clog10 (-0x1.0000000123456p0 + 0x1.2345678p-1000 i)":
+double: 2
+idouble: 2
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (-0x1.0000000123456p0 + 0x1.2345678p-1000 i)":
+double: 1
+idouble: 1
+Test "Real part of: clog10 (-0x1.0000000123456p0 + 0x1.2345678p-30 i)":
+double: 2
+idouble: 2
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (-0x1.0000000123456p0 + 0x1.2345678p-30 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-0x1.fp+1023 + 0x1p-1074 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-0x1.fp+1023 - 0x1p-1074 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-0x1.fp+127 + 0x1p-149 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-0x1.fp+127 - 0x1p-149 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-0x1p-1074 + 0x1.fp+1023 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-0x1p-1074 - 0x1.fp+1023 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-0x1p-149 + 0x1.fp+127 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-0x1p-149 - 0x1.fp+127 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-1.0 + 0x1.234566p-20 i)":
+double: 1
+idouble: 1
+Test "Real part of: clog10 (-2 - 3 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (-2 - 3 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (-3 + inf i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-3 - inf i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 1 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + inf i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-inf - 0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 1 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 + inf i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 - inf i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0.75 + 1.25 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog10 (0x0.fffffffffffff8p0 + 0x0.fffffffffffff8p-1000 i)":
+double: 1
+idouble: 1
+Test "Real part of: clog10 (0x0.ffffffp0 + 0x0.ffffffp-100 i)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog10 (0x1.00000000000000123456789abcp0 + 0x1.23456789p-1000 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (0x1.00000000000000123456789abcp0 + 0x1.23456789p-1000 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (0x1.00000000000000123456789abcp0 + 0x1.23456789p-60 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog10 (0x1.000566p0 + 0x1.234p-10 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1.000566p0 + 0x1.234p-10 i)":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+Test "Real part of: clog10 (0x1.000566p0 + 0x1.234p-100 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1.000566p0 + 0x1.234p-100 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (0x1.234566p-30 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog10 (0x1.234566p-50 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (0x1.234566p-50 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: clog10 (0x1.234566p-60 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (0x1.234566p-60 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1.fffffep+127 + 0x1.fffffep+127 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: clog10 (0x1.fffffep+127 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1.fffffffffffffp+1023 + 0x1.fffffffffffffp+1023 i)":
+double: 1
+idouble: 1
+Test "Real part of: clog10 (0x1.fp+16383 + 0x1.fp+16383 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog10 (0x1.fp+16383 + 0x1p+16383 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog10 (0x10673dd0f2481p-51 + 0x7ef1d17cefbd2p-51 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog10 (0x1367a310575591p-54 + 0x3cfcc0a0541f60p-54 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (0x1367a310575591p-54 + 0x3cfcc0a0541f60p-54 i)":
+double: 1
+idouble: 1
+Test "Real part of: clog10 (0x1415bcaf2105940d49a636e98ae59p-115 + 0x7e6a150adfcd1b0921d44b31f40f4p-115 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (0x15cfbd1990d1ffp-53 + 0x176a3973e09a9ap-53 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (0x164c74eea876p-45 + 0x16f393482f77p-45 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x1a6p-10 + 0x3a5p-10 i)":
+double: 1
+idouble: 1
+Test "Real part of: clog10 (0x1df515eb171a808b9e400266p-95 + 0x7c71eb0cd4688dfe98581c77p-95 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (0x1df515eb171a808b9e400266p-95 + 0x7c71eb0cd4688dfe98581c77p-95 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (0x1p-1073 + 0x1p-1073 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x1p-1074 + 0x1.fp+1023 i)":
+double: 1
+idouble: 1
+Test "Real part of: clog10 (0x1p-1074 + 0x1p-1074 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x1p-1074 + 0x1p-1074 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x1p-1074 - 0x1.fp+1023 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x1p-147 + 0x1p-147 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1p-149 + 0x1.fp+127 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1p-149 + 0x1p-149 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1p-149 - 0x1.fp+127 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1p-509 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x1p-510 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x1p-511 + 1.0 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x1p-61 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1p-62 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1p-63 + 1.0 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: clog10 (0x2818p-15 + 0x798fp-15 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (0x2818p-15 + 0x798fp-15 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog10 (0x2dd46725bp-35 + 0x7783a1284p-35 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog10 (0x2ede88p-23 + 0x771c3fp-23 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x2ede88p-23 + 0x771c3fp-23 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (0x3f96469050f650869c2p-75 + 0x6f16b2c9c8b05988335p-75 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog10 (0x4447d7175p-35 + 0x6c445e00ap-35 i)":
+double: 1
+idouble: 1
+Test "Real part of: clog10 (0x4d4ep-15 + 0x6605p-15 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog10 (0x4d9c37e2b5cb4533p-63 + 0x65c98be2385a042ep-63 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog10 (0x55cb6d0c83af5p-55 + 0x7fe33c0c7c4e90p-55 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (0x5b06b680ea2ccp-52 + 0xef452b965da9fp-52 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog10 (0x602fd5037c4792efp-64 + 0xed3e2086dcca80b8p-64 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog10 (0x6241ef0da53f539f02fad67dabp-106 + 0x3fb46641182f7efd9caa769dac0p-106 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog10 (0x659feap-24 + 0xeaf6f9p-24 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (0x659feap-24 + 0xeaf6f9p-24 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (0x6b10b4f3520217b6p-64 + 0xe8893cbb449253a1p-64 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (0x9b57bp-20 + 0xcb7b4p-20 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog10 (0xdb85c467ee2aadd5f425fe0f4b8dp-114 + 0x3e83162a0f95f1dcbf97dddf410eap-114 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog10 (0xf2p-10 + 0x3e3p-10 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0xf2p-10 + 0x3e3p-10 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0xfd95243681c055c2632286921092p-113 + 0x1bccabcd29ca2152860ec29e34ef7p-113 i)":
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: clog10 (0xfe961079616p-45 + 0x1bc37e09e6d1p-45 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (1.0 + 0x1.234566p-10 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (3 + inf i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 - inf i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf + inf i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf - inf i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# cos
+Test "cos (0x1p+120)":
+float: 1
+ifloat: 1
+Test "cos (0x1p+127)":
+float: 1
+ifloat: 1
+Test "cos (M_PI_6l * 2.0)":
+double: 1
+idouble: 1
+Test "cos (M_PI_6l * 4.0)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# cos_downward
+Test "cos_downward (1)":
+float: 1
+ifloat: 1
+Test "cos_downward (2)":
+float: 1
+ifloat: 1
+Test "cos_downward (3)":
+float: 1
+ifloat: 1
+Test "cos_downward (4)":
+float: 1
+ifloat: 1
+Test "cos_downward (5)":
+float: 1
+ifloat: 1
+Test "cos_downward (7)":
+float: 1
+ifloat: 1
+Test "cos_downward (8)":
+float: 1
+ifloat: 1
+
+# cos_tonearest
+Test "cos_tonearest (7)":
+float: 1
+ifloat: 1
+
+# cos_towardzero
+Test "cos_towardzero (2)":
+float: 1
+ifloat: 1
+Test "cos_towardzero (3)":
+float: 1
+ifloat: 1
+Test "cos_towardzero (5)":
+float: 1
+ifloat: 1
+Test "cos_towardzero (7)":
+float: 1
+ifloat: 1
+Test "cos_towardzero (8)":
+float: 1
+ifloat: 1
+
+# cos_upward
+Test "cos_upward (10)":
+float: 1
+ifloat: 1
+Test "cos_upward (6)":
+float: 1
+ifloat: 1
+Test "cos_upward (7)":
+float: 1
+ifloat: 1
+Test "cos_upward (9)":
+float: 2
+ifloat: 2
+
+# cosh_downward
+Test "cosh_downward (22)":
+float: 1
+ifloat: 1
+Test "cosh_downward (23)":
+float: 1
+ifloat: 1
+Test "cosh_downward (24)":
+float: 1
+ifloat: 1
+
+# cosh_tonearest
+Test "cosh_tonearest (22)":
+ildouble: 1
+ldouble: 1
+
+# cosh_towardzero
+Test "cosh_towardzero (22)":
+float: 1
+ifloat: 1
+Test "cosh_towardzero (23)":
+float: 1
+ifloat: 1
+Test "cosh_towardzero (24)":
+float: 1
+ifloat: 1
+
+# cpow
+Test "Real part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i)":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+ildouble: 4
+ldouble: 4
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 0.0 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i)":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+ildouble: 2
+ldouble: 2
+Test "Real part of: cpow (2 + 0 i, 10 + 0 i)":
+ildouble: 2
+ldouble: 2
+Test "Real part of: cpow (2 + 3 i, 4 + 0 i)":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i)":
+float: 2
+ifloat: 2
+
+# csin
+Test "Real part of: csin (-0.75 + 11357.25 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: csin (-0.75 + 710.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: csin (-0.75 + 89.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csin (-0.75 + 89.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: csin (-0.75 - 11357.25 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: csin (-0.75 - 710.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: csin (-0.75 - 89.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csin (-0.75 - 89.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csin (-2 - 3 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: csin (0.75 + 1.25 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: csin (0.75 + 11357.25 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: csin (0.75 + 710.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: csin (0.75 + 89.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csin (0.75 + 89.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: csin (0.75 - 11357.25 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: csin (0.75 - 710.5 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: csin (0.75 - 89.5 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csin (0.75 - 89.5 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: csin (0x1p-1074 + 1440 i)":
+double: 1
+idouble: 1
+Test "Real part of: csin (0x1p-16434 + 22730 i)":
+ildouble: 1
+ldouble: 1
+
+# csinh
+Test "Imaginary part of: csinh (-11357.25 + 0.75 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csinh (-11357.25 - 0.75 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: csinh (-2 - 3 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csinh (-2 - 3 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: csinh (-710.5 + 0.75 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csinh (-710.5 - 0.75 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: csinh (-89.5 + 0.75 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csinh (-89.5 + 0.75 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: csinh (-89.5 - 0.75 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csinh (-89.5 - 0.75 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: csinh (0.75 + 1.25 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csinh (0.75 + 1.25 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csinh (11357.25 + 0.75 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csinh (11357.25 - 0.75 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csinh (1440 + 0x1p-1074 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: csinh (22730 + 0x1p-16434 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csinh (710.5 + 0.75 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csinh (710.5 - 0.75 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: csinh (89.5 + 0.75 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csinh (89.5 + 0.75 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: csinh (89.5 - 0.75 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csinh (89.5 - 0.75 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# csqrt
+Test "Real part of: csqrt (-0x1.0000000000000000000000000001p-16382 - 0x1.0000000000000000000000000001p-16382 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: csqrt (-0x1.0000000000000002p-16382 - 0x1.0000000000000002p-16382 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csqrt (-0x1.0000000000000002p-16382 - 0x1.0000000000000002p-16382 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: csqrt (-0x1.0000000000001p-1022 - 0x1.0000000000001p-1022 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: csqrt (-0x1.000002p-126 - 0x1.000002p-126 i)":
+double: 1
+idouble: 1
+Test "Real part of: csqrt (-2 + 3 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: csqrt (-2 - 3 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csqrt (0.75 + 1.25 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csqrt (0x1.0000000000000000000000000001p-16382 + 0x1.0000000000000000000000000001p-16382 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: csqrt (0x1.0000000000000002p-16382 + 0x1.0000000000000002p-16382 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csqrt (0x1.0000000000000002p-16382 + 0x1.0000000000000002p-16382 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csqrt (0x1.0000000000001p-1022 + 0x1.0000000000001p-1022 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csqrt (0x1.000002p-126 + 0x1.000002p-126 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: csqrt (0x1.fffffep+127 + 1.0 i)":
+float: 1
+ifloat: 1
+Test "Real part of: csqrt (0x1.fffffffffffffp+1023 + 0x1.fffffffffffffp+1023 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: csqrt (0x1.fffffffffffffp+1023 + 0x1.fffffffffffffp+1023 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csqrt (0x1.fffffffffffffp+1023 + 0x1p+1023 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: csqrt (0x1.fp+16383 + 0x1.fp+16383 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csqrt (0x1.fp+16383 + 0x1.fp+16383 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csqrt (0x1.fp+16383 + 0x1p+16383 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csqrt (0x1p-16440 + 0x1p-16441 i)":
+ildouble: 1
+ldouble: 1
+
+# ctan
+Test "Real part of: ctan (-2 - 3 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ctan (-2 - 3 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ctan (0.75 + 1.25 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctan (0.75 + 1.25 i)":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+Test "Real part of: ctan (0x1p1023 + 1 i)":
+double: 1
+idouble: 1
+Test "Imaginary part of: ctan (0x1p1023 + 1 i)":
+ildouble: 2
+ldouble: 2
+Test "Real part of: ctan (0x1p127 + 1 i)":
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: ctan (0x1p127 + 1 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ctan (0x1p16383 + 1 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctan (0x1p16383 + 1 i)":
+ildouble: 2
+ldouble: 2
+Test "Real part of: ctan (0x3.243f6cp-1 + 0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ctan (1 + 355 i)":
+ildouble: 2
+ldouble: 2
+Test "Real part of: ctan (1 + 365 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: ctan (1 + 45 i)":
+ildouble: 2
+ldouble: 2
+Test "Real part of: ctan (1 + 47 i)":
+ildouble: 1
+ldouble: 1
+
+# ctan_downward
+Test "Real part of: ctan_downward (0x1.921fb6p+0 + 0x1p-149 i)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "Imaginary part of: ctan_downward (0x1.921fb6p+0 + 0x1p-149 i)":
+float: 1
+ifloat: 1
+
+# ctan_tonearest
+Test "Imaginary part of: ctan_tonearest (0x1.921fb54442d1846ap+0 + 0x1p-16445 i)":
+ildouble: 1
+ldouble: 1
+Test "Real part of: ctan_tonearest (0x1.921fb54442d18p+0 + 0x1p-1074 i)":
+ildouble: 3
+ldouble: 3
+Test "Imaginary part of: ctan_tonearest (0x1.921fb54442d18p+0 + 0x1p-1074 i)":
+ildouble: 3
+ldouble: 3
+Test "Real part of: ctan_tonearest (0x1.921fb6p+0 + 0x1p-149 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctan_tonearest (0x1.921fb6p+0 + 0x1p-149 i)":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+# ctan_towardzero
+Test "Real part of: ctan_towardzero (0x1.921fb6p+0 + 0x1p-149 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ctan_towardzero (0x1.921fb6p+0 + 0x1p-149 i)":
+float: 1
+ifloat: 1
+
+# ctan_upward
+Test "Real part of: ctan_upward (0x1.921fb54442d18p+0 + 0x1p-1074 i)":
+double: 1
+idouble: 1
+Test "Real part of: ctan_upward (0x1.921fb6p+0 + 0x1p-149 i)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "Imaginary part of: ctan_upward (0x1.921fb6p+0 + 0x1p-149 i)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# ctanh
+Test "Real part of: ctanh (-2 - 3 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ctanh (-2 - 3 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ctanh (0 + 0x3.243f6cp-1 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctanh (0 + pi/4 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ctanh (0.75 + 1.25 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ctanh (0.75 + 1.25 i)":
+float: 2
+ifloat: 2
+Test "Real part of: ctanh (1 + 0x1p1023 i)":
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: ctanh (1 + 0x1p1023 i)":
+double: 1
+idouble: 1
+Test "Real part of: ctanh (1 + 0x1p127 i)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctanh (1 + 0x1p127 i)":
+ildouble: 2
+ldouble: 2
+Test "Real part of: ctanh (1 + 0x1p16383 i)":
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: ctanh (1 + 0x1p16383 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctanh (355 + 1 i)":
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: ctanh (365 + 1 i)":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctanh (45 + 1 i)":
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: ctanh (47 + 1 i)":
+ildouble: 1
+ldouble: 1
+
+# ctanh_downward
+Test "Real part of: ctanh_downward (0x1p-149 + 0x1.921fb6p+0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ctanh_downward (0x1p-149 + 0x1.921fb6p+0 i)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+# ctanh_tonearest
+Test "Real part of: ctanh_tonearest (0x1p-1074 + 0x1.921fb54442d18p+0 i)":
+ildouble: 3
+ldouble: 3
+Test "Imaginary part of: ctanh_tonearest (0x1p-1074 + 0x1.921fb54442d18p+0 i)":
+ildouble: 3
+ldouble: 3
+Test "Real part of: ctanh_tonearest (0x1p-149 + 0x1.921fb6p+0 i)":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: ctanh_tonearest (0x1p-149 + 0x1.921fb6p+0 i)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ctanh_tonearest (0x1p-16445 + 0x1.921fb54442d1846ap+0 i)":
+ildouble: 1
+ldouble: 1
+
+# ctanh_towardzero
+Test "Real part of: ctanh_towardzero (0x1p-149 + 0x1.921fb6p+0 i)":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ctanh_towardzero (0x1p-149 + 0x1.921fb6p+0 i)":
+float: 1
+ifloat: 1
+
+# ctanh_upward
+Test "Imaginary part of: ctanh_upward (0x1p-1074 + 0x1.921fb54442d18p+0 i)":
+double: 1
+idouble: 1
+Test "Real part of: ctanh_upward (0x1p-149 + 0x1.921fb6p+0 i)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "Imaginary part of: ctanh_upward (0x1p-149 + 0x1.921fb6p+0 i)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+# erf
+Test "erf (1.25)":
+double: 1
+idouble: 1
+
+# erfc
+Test "erfc (0x1.f7303cp+1)":
+double: 1
+idouble: 1
+Test "erfc (0x1.ffa002p+2)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "erfc (0x1.ffffc8p+2)":
+ildouble: 1
+ldouble: 1
+Test "erfc (2.0)":
+double: 1
+idouble: 1
+Test "erfc (27.0)":
+ildouble: 1
+ldouble: 1
+Test "erfc (4.125)":
+double: 1
+idouble: 1
+
+# exp10
+Test "exp10 (-1)":
+double: 1
+idouble: 1
+Test "exp10 (-305)":
+double: 1
+idouble: 1
+Test "exp10 (-36)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "exp10 (3)":
+double: 1
+idouble: 1
+Test "exp10 (36)":
+double: 1
+idouble: 1
+Test "exp10 (4932)":
+ildouble: 1
+ldouble: 1
+
+# exp2
+Test "exp2 (100.5)":
+ildouble: 1
+ldouble: 1
+
+# exp_downward
+Test "exp_downward (2)":
+float: 1
+ifloat: 1
+Test "exp_downward (3)":
+float: 1
+ifloat: 1
+
+# exp_towardzero
+Test "exp_towardzero (2)":
+float: 1
+ifloat: 1
+Test "exp_towardzero (3)":
+float: 1
+ifloat: 1
+
+# exp_upward
+Test "exp_upward (1)":
+float: 1
+ifloat: 1
+
+# expm1
+Test "expm1 (-79.0)":
+ildouble: 1
+ldouble: 1
+Test "expm1 (0.75)":
+double: 1
+idouble: 1
+Test "expm1 (1)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "expm1 (500.0)":
+double: 1
+idouble: 1
+
+# gamma
+Test "gamma (-0.5)":
+ildouble: 1
+ldouble: 1
+Test "gamma (0.7)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "gamma (1.2)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# hypot
+Test "hypot (-0.7, -12.4)":
+float: 1
+ifloat: 1
+Test "hypot (-0.7, 12.4)":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, -0.7)":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, 0.7)":
+float: 1
+ifloat: 1
+Test "hypot (0.7, -12.4)":
+float: 1
+ifloat: 1
+Test "hypot (0.7, 12.4)":
+float: 1
+ifloat: 1
+Test "hypot (12.4, -0.7)":
+float: 1
+ifloat: 1
+Test "hypot (12.4, 0.7)":
+float: 1
+ifloat: 1
+
+# j0
+Test "j0 (-0x1.001000001p+593)":
+ildouble: 1
+ldouble: 1
+Test "j0 (-4.0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (0.75)":
+float: 1
+ifloat: 1
+Test "j0 (0x1.d7ce3ap+107)":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "j0 (0x1p1023)":
+ildouble: 1
+ldouble: 1
+Test "j0 (0x1p16383)":
+ildouble: 2
+ldouble: 2
+Test "j0 (10.0)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "j0 (2.0)":
+float: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "j0 (4.0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (8.0)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# j1
+Test "j1 (-1.0)":
+ildouble: 1
+ldouble: 1
+Test "j1 (0.75)":
+ildouble: 1
+ldouble: 1
+Test "j1 (0x1.3ffp+74)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "j1 (0x1.ff00000000002p+840)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "j1 (0x1p1023)":
+ildouble: 1
+ldouble: 1
+Test "j1 (0x1p16382)":
+ildouble: 1
+ldouble: 1
+Test "j1 (0x1p16383)":
+ildouble: 2
+ldouble: 2
+Test "j1 (1.0)":
+ildouble: 1
+ldouble: 1
+Test "j1 (10.0)":
+float: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "j1 (2.0)":
+double: 1
+idouble: 1
+Test "j1 (8.0)":
+double: 1
+idouble: 1
+ildouble: 4
+ldouble: 4
+
+# jn
+Test "jn (0, -4.0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 0.75)":
+float: 1
+ifloat: 1
+Test "jn (0, 10.0)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "jn (0, 2.0)":
+float: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "jn (0, 4.0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 8.0)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (1, -1.0)":
+ildouble: 1
+ldouble: 1
+Test "jn (1, 0.75)":
+ildouble: 1
+ldouble: 1
+Test "jn (1, 1.0)":
+ildouble: 1
+ldouble: 1
+Test "jn (1, 10.0)":
+float: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "jn (1, 2.0)":
+double: 1
+idouble: 1
+Test "jn (1, 8.0)":
+double: 1
+idouble: 1
+ildouble: 4
+ldouble: 4
+Test "jn (10, -1.0)":
+ildouble: 1
+ldouble: 1
+Test "jn (10, 0.125)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (10, 0.75)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (10, 1.0)":
+ildouble: 1
+ldouble: 1
+Test "jn (10, 10.0)":
+double: 4
+float: 3
+idouble: 4
+ifloat: 3
+ildouble: 2
+ldouble: 2
+Test "jn (10, 2.0)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "jn (2, 0x1.ffff62p+99)":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+Test "jn (2, 2.4048255576957729)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (3, 0.125)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 0.75)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 10.0)":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "jn (3, 2.0)":
+float: 1
+ifloat: 1
+Test "jn (3, 2.4048255576957729)":
+double: 3
+idouble: 3
+ildouble: 1
+ldouble: 1
+Test "jn (4, 2.4048255576957729)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "jn (5, 2.4048255576957729)":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "jn (6, 2.4048255576957729)":
+double: 4
+float: 3
+idouble: 4
+ifloat: 3
+ildouble: 5
+ldouble: 5
+Test "jn (7, 2.4048255576957729)":
+double: 3
+float: 5
+idouble: 3
+ifloat: 5
+ildouble: 3
+ldouble: 3
+Test "jn (8, 2.4048255576957729)":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+ildouble: 8
+ldouble: 8
+Test "jn (9, 2.4048255576957729)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 3
+ldouble: 3
+
+# lgamma
+Test "lgamma (-0.5)":
+ildouble: 1
+ldouble: 1
+Test "lgamma (0.7)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "lgamma (1.2)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# log10
+Test "log10 (0.75)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "log10 (e)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# log1p
+Test "log1p (-0.25)":
+float: 1
+ifloat: 1
+
+# log2
+Test "log2 (0.75)":
+ildouble: 1
+ldouble: 1
+
+# pow
+Test "pow (0x0.fffffffffffff8p0, -0x1.23456789abcdfp62)":
+ildouble: 1
+ldouble: 1
+Test "pow (0x0.ffffffp0, -0x1p24)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "pow (0x0.ffffffp0, 0x1p24)":
+float: 1
+ifloat: 1
+Test "pow (0x1.000002p0, 0x1p24)":
+float: 1
+ifloat: 1
+Test "pow (10.0, -4930.0)":
+ildouble: 1
+ldouble: 1
+Test "pow (10.0, 4929.0)":
+ildouble: 1
+ldouble: 1
+Test "pow (10.0, 4930.0)":
+ildouble: 1
+ldouble: 1
+Test "pow (10.0, 4931.0)":
+ildouble: 1
+ldouble: 1
+Test "pow (10.0, 4932.0)":
+ildouble: 1
+ldouble: 1
+Test "pow (1e4932, 0.75)":
+ildouble: 1
+ldouble: 1
+
+# pow10
+Test "pow10 (-1)":
+double: 1
+idouble: 1
+Test "pow10 (-305)":
+double: 1
+idouble: 1
+Test "pow10 (-36)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "pow10 (3)":
+double: 1
+idouble: 1
+Test "pow10 (36)":
+double: 1
+idouble: 1
+Test "pow10 (4932)":
+ildouble: 1
+ldouble: 1
+
+# pow_downward
+Test "pow_downward (1.5, 1.03125)":
+float: 1
+ifloat: 1
+
+# pow_towardzero
+Test "pow_towardzero (1.5, 1.03125)":
+float: 1
+ifloat: 1
+
+# pow_upward
+Test "pow_upward (1.0625, 1.125)":
+float: 1
+ifloat: 1
+
+# sin_downward
+Test "sin_downward (10)":
+float: 1
+ifloat: 1
+Test "sin_downward (3)":
+float: 1
+ifloat: 1
+Test "sin_downward (5)":
+float: 1
+ifloat: 1
+Test "sin_downward (6)":
+float: 1
+ifloat: 1
+
+# sin_tonearest
+Test "sin_tonearest (1)":
+float: 1
+ifloat: 1
+Test "sin_tonearest (3)":
+ildouble: 1
+ldouble: 1
+
+# sin_towardzero
+Test "sin_towardzero (1)":
+float: 1
+ifloat: 1
+Test "sin_towardzero (10)":
+float: 1
+ifloat: 1
+Test "sin_towardzero (4)":
+float: 1
+ifloat: 1
+Test "sin_towardzero (5)":
+float: 1
+ifloat: 1
+Test "sin_towardzero (9)":
+float: 1
+ifloat: 1
+
+# sin_upward
+Test "sin_upward (1)":
+float: 1
+ifloat: 1
+Test "sin_upward (2)":
+float: 2
+ifloat: 2
+Test "sin_upward (4)":
+float: 1
+ifloat: 1
+Test "sin_upward (9)":
+float: 1
+ifloat: 1
+
+# sincos
+Test "sincos (0x1p+120) extra output 2":
+float: 1
+ifloat: 1
+Test "sincos (0x1p+127) extra output 2":
+float: 1
+ifloat: 1
+Test "sincos (M_PI_6l*2.0) extra output 1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (M_PI_6l*2.0) extra output 2":
+double: 1
+idouble: 1
+Test "sincos (pi/6) extra output 2":
+float: 1
+ifloat: 1
+
+# sinh_downward
+Test "sinh_downward (22)":
+float: 1
+ifloat: 1
+Test "sinh_downward (23)":
+float: 1
+ifloat: 1
+Test "sinh_downward (24)":
+float: 1
+ifloat: 1
+
+# sinh_towardzero
+Test "sinh_towardzero (22)":
+float: 1
+ifloat: 1
+Test "sinh_towardzero (23)":
+float: 1
+ifloat: 1
+Test "sinh_towardzero (24)":
+float: 1
+ifloat: 1
+
+# tan_downward
+Test "tan_downward (1)":
+float: 1
+ifloat: 1
+Test "tan_downward (10)":
+float: 1
+ifloat: 1
+Test "tan_downward (2)":
+float: 1
+ifloat: 1
+Test "tan_downward (6)":
+float: 1
+ifloat: 1
+Test "tan_downward (8)":
+float: 1
+ifloat: 1
+Test "tan_downward (9)":
+float: 1
+ifloat: 1
+
+# tan_towardzero
+Test "tan_towardzero (10)":
+float: 1
+ifloat: 1
+Test "tan_towardzero (3)":
+float: 1
+ifloat: 1
+Test "tan_towardzero (4)":
+float: 1
+ifloat: 1
+Test "tan_towardzero (5)":
+float: 1
+ifloat: 1
+Test "tan_towardzero (9)":
+float: 1
+ifloat: 1
+
+# tan_upward
+Test "tan_upward (1)":
+float: 1
+ifloat: 1
+Test "tan_upward (10)":
+float: 1
+ifloat: 1
+Test "tan_upward (3)":
+float: 1
+ifloat: 1
+Test "tan_upward (5)":
+float: 1
+ifloat: 1
+
+# tanh
+Test "tanh (-0.75)":
+ildouble: 1
+ldouble: 1
+Test "tanh (-1.0)":
+ildouble: 1
+ldouble: 1
+Test "tanh (0.75)":
+ildouble: 1
+ldouble: 1
+Test "tanh (1.0)":
+ildouble: 1
+ldouble: 1
+
+# tgamma
+Test "tgamma (-0.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (-0x0.fffffffffffff8p0)":
+double: 1
+idouble: 1
+Test "tgamma (-0x0.ffffffffffffffffffffffffffff8p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x0.ffffffp0)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x1.0000000000000002p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x1.0000000000001p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x1.000002p0)":
+double: 2
+idouble: 2
+Test "tgamma (-0x1.0a32a2p+5)":
+float: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "tgamma (-0x1.5800000080001p+7)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x1.fffffffffffffffep0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x1.fffffffffffffp0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x13.ffffep0)":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x13.ffffffffffffffep0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x13.fffffffffffffffffffffffff8p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x13.ffffffffffffp0)":
+ildouble: 2
+ldouble: 2
+Test "tgamma (-0x14.000000000000000000000000001p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x14.000000000001p0)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x14.00002p0)":
+float: 1
+ifloat: 1
+ildouble: 4
+ldouble: 4
+Test "tgamma (-0x1d.ffffep0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x1d.fffffffffffffffffffffffff8p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x1d.ffffffffffffp0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x1e.000000000000000000000000001p0)":
+ildouble: 2
+ldouble: 2
+Test "tgamma (-0x1e.00000000000000000000000008p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x1e.000000000000002p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x1e.000000000001p0)":
+double: 3
+idouble: 3
+Test "tgamma (-0x1e.00002p0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x1f3.ffffffffffffffffffffffffffp0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x1p-24)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x2.0000000000000000000000000002p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x2.0000000000002p0)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x2.000004p0)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x2.fffffcp0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (-0x2.ffffffffffffep0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x27.fffffffffffep0)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x27.ffffffffffffffcp0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x27.ffffffffffffffffffffffffffep0)":
+ildouble: 2
+ldouble: 2
+Test "tgamma (-0x27.fffffffffffffffffffffffffp0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x28.0000000000000000000000001p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x28.000000000002p0)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x28.00004p0)":
+double: 2
+idouble: 2
+ildouble: 2
+ldouble: 2
+Test "tgamma (-0x28.ffffffffffffffcp0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x28.ffffffffffffffffffffffffffep0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x28.fffffffffffffffffffffffffp0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x29.000000000000000000000000002p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x29.0000000000000000000000001p0)":
+ildouble: 2
+ldouble: 2
+Test "tgamma (-0x29.00004p0)":
+double: 1
+idouble: 1
+Test "tgamma (-0x29.ffffcp0)":
+double: 1
+idouble: 1
+Test "tgamma (-0x29.fffffffffffep0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x29.ffffffffffffffcp0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x29.ffffffffffffffffffffffffffep0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x29.fffffffffffffffffffffffffp0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x2a.000000000000000000000000002p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x2a.0000000000000000000000001p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x2a.000000000000004p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x2a.000000000002p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x2ed.fffffffffffffffffffffffffep0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x2ee.00000000000004p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x3.00000000000000000000000001p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x3.000004p0)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "tgamma (-0x3.fffffcp0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (-0x3.ffffffffffffep0)":
+double: 2
+idouble: 2
+Test "tgamma (-0x3.fffffffffffffffcp0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x3.fffffffffffffffffffffffffffep0)":
+ildouble: 2
+ldouble: 2
+Test "tgamma (-0x31.fffffffffffep0)":
+double: 3
+idouble: 3
+ildouble: 2
+ldouble: 2
+Test "tgamma (-0x31.ffffffffffffffcp0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x31.ffffffffffffffffffffffffffep0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x31.fffffffffffffffffffffffffp0)":
+ildouble: 2
+ldouble: 2
+Test "tgamma (-0x32.000000000000000000000000002p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x32.0000000000000000000000001p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x32.000000000000004p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x3e7.fffffffffffffcp0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x3e7.fffffffffffffffffffffffffep0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x3e8.00000000000000000000000002p0)":
+ildouble: 2
+ldouble: 2
+Test "tgamma (-0x3e8.00000000000004p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x4.0000000000004p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x4.000008p0)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x4.fffff8p0)":
+double: 1
+idouble: 1
+Test "tgamma (-0x4.ffffffffffffcp0)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x4.fffffffffffffffffffffffffep0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x4.fffffffffffffffffffffffffffcp0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x5.0000000000000008p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x5.0000000000004p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x5.000008p0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (-0x5.fffff8p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x5.ffffffffffffcp0)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x5.fffffffffffffff8p0)":
+ildouble: 2
+ldouble: 2
+Test "tgamma (-0x5.fffffffffffffffffffffffffep0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x5.fffffffffffffffffffffffffffcp0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x5db.fffffffffffff8p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x5db.fffffffffffffffffffffffffcp0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x5dc.00000000000000000000000004p0)":
+ildouble: 2
+ldouble: 2
+Test "tgamma (-0x6.0000000000000000000000000004p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x6.00000000000000000000000002p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x6.0000000000004p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x6.000008p0)":
+float: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "tgamma (-0x6.fffff8p0)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x6.ffffffffffffcp0)":
+double: 4
+idouble: 4
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x6.fffffffffffffff8p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x6.fffffffffffffffffffffffffffcp0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x63.fffffffffffcp0)":
+double: 2
+idouble: 2
+Test "tgamma (-0x63.ffffffffffffff8p0)":
+ildouble: 2
+ldouble: 2
+Test "tgamma (-0x63.ffffffffffffffffffffffffep0)":
+ildouble: 2
+ldouble: 2
+Test "tgamma (-0x64.000000000000000000000000004p0)":
+ildouble: 2
+ldouble: 2
+Test "tgamma (-0x64.0000000000000000000000002p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x64.000000000004p0)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x6d5.fffffffffffff8p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x6d6.00000000000000000000000004p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x6e3.00000000000000000000000004p0)":
+ildouble: 2
+ldouble: 2
+Test "tgamma (-0x7.0000000000000008p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x7.0000000000004p0)":
+double: 3
+idouble: 3
+Test "tgamma (-0x7.000008p0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (-0x7.fffff8p0)":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "tgamma (-0x7.ffffffffffffcp0)":
+double: 3
+idouble: 3
+Test "tgamma (-0x7.fffffffffffffff8p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x7.fffffffffffffffffffffffffep0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x7.fffffffffffffffffffffffffffcp0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x8.0000000000000000000000000008p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x8.00000000000000000000000004p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x8.0000000000008p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x8.00001p0)":
+double: 2
+idouble: 2
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x9.ffffffffffff8p0)":
+double: 1
+idouble: 1
+Test "tgamma (-0x9.fffffffffffffffffffffffffff8p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x9.fffffp0)":
+float: 1
+ifloat: 1
+Test "tgamma (-0x95.ffffffffffffffp0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x96.000000000000000000000000008p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x96.0000000000000000000000004p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0x96.00000000000001p0)":
+ildouble: 2
+ldouble: 2
+Test "tgamma (-0x96.000000000008p0)":
+double: 1
+idouble: 1
+Test "tgamma (-0xa.0000000000008p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0xa.00001p0)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0xb4.ffffffffffffffffffffffffcp0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0xb4.ffffffffffffffp0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0xb5.0000000000000000000000004p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0xb5.00000000000001p0)":
+ildouble: 2
+ldouble: 2
+Test "tgamma (-0xb5.000000000008p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0xb5.ffffffffffffffffffffffffff8p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0xb6.00000000000001p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0xb6.000000000008p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0xb6.fffffffffff8p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0xb6.ffffffffffffffffffffffffff8p0)":
+ildouble: 3
+ldouble: 3
+Test "tgamma (-0xb7.000000000000000000000000008p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0xb7.00000000000001p0)":
+ildouble: 2
+ldouble: 2
+Test "tgamma (-0xb7.000000000008p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0xb7.ffffffffffffffffffffffffcp0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0xb7.ffffffffffffffffffffffffff8p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0xb8.00000000000001p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0xbb.ffffffffffffffffffffffffcp0)":
+ildouble: 3
+ldouble: 3
+Test "tgamma (-0xbb.ffffffffffffffffffffffffff8p0)":
+ildouble: 4
+ldouble: 4
+Test "tgamma (-0xbc.000000000000000000000000008p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0xbc.0000000000000000000000004p0)":
+ildouble: 2
+ldouble: 2
+Test "tgamma (-0xbc.00000000000001p0)":
+ildouble: 2
+ldouble: 2
+Test "tgamma (-0xbc.ffffffffffffffp0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0xbd.000000000000000000000000008p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0xbd.00000000000001p0)":
+ildouble: 2
+ldouble: 2
+Test "tgamma (-0xbd.ffffffffffffffp0)":
+ildouble: 2
+ldouble: 2
+Test "tgamma (-0xbe.000000000000000000000000008p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0xbe.0000000000000000000000004p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0xbe.ffffffffffffffffffffffffcp0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0xbe.ffffffffffffffp0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0xbf.000000000000000000000000008p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0xbf.0000000000000000000000004p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0xbf.00000000000001p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0xf9.ffffffffffffffp0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-0xfa.000000000000000000000000008p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (-2.5)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "tgamma (-3.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (-4.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (-5.5)":
+double: 1
+idouble: 1
+Test "tgamma (-6.5)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (-7.5)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "tgamma (-8.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (-9.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (0.5)":
+float: 1
+ifloat: 1
+Test "tgamma (0.7)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (0x1.fffffep0)":
+float: 1
+ifloat: 1
+Test "tgamma (0x1.fffffffffffffffep0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (0x1.ffffffffffffffffffffffffffffp0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (0x1.fffffffffffffp0)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (0x1p-113)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (0x1p-24)":
+float: 1
+ifloat: 1
+Test "tgamma (0x1p-53)":
+double: 1
+idouble: 1
+Test "tgamma (0x2.30a43cp+4)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "tgamma (0x2.fffffcp0)":
+float: 3
+ifloat: 3
+Test "tgamma (0x2.ffffffffffffep0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (0x3.0000000000002p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (0x3.fffffcp0)":
+float: 1
+ifloat: 1
+Test "tgamma (0x3.ffffffffffffep0)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (0x3.fffffffffffffffcp0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (0x3.fffffffffffffffffffffffffffep0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (0x4.0000000000000000000000000004p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (0x4.0000000000004p0)":
+double: 1
+idouble: 1
+Test "tgamma (0x4.000008p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (0x4.ffffffffffffcp0)":
+double: 1
+idouble: 1
+Test "tgamma (0x4.fffffffffffffffffffffffffep0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (0x4.fffffffffffffffffffffffffffcp0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (0x5.0000000000000000000000000004p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (0x5.0000000000004p0)":
+double: 1
+idouble: 1
+Test "tgamma (0x5.000008p0)":
+float: 2
+ifloat: 2
+Test "tgamma (0x5.fffff8p0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (0x5.ffffffffffffcp0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (0x5.fffffffffffffff8p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (0x5.fffffffffffffffffffffffffep0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (0x6.0000000000000000000000000004p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (0x6.0000000000000008p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (0x6.0000000000004p0)":
+double: 1
+idouble: 1
+Test "tgamma (0x6.000008p0)":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "tgamma (0x6.fffff8p0)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (0x6.ffffffffffffcp0)":
+double: 4
+idouble: 4
+Test "tgamma (0x6.fffffffffffffff8p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (0x7.0000000000000000000000000004p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (0x7.0000000000000008p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (0x7.0000000000004p0)":
+double: 4
+idouble: 4
+Test "tgamma (0x7.000008p0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (0x7.fffff8p0)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "tgamma (0x7.ffffffffffffcp0)":
+double: 2
+idouble: 2
+ildouble: 1
+ldouble: 1
+Test "tgamma (0x7.fffffffffffffffffffffffffffcp0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (0x8.0000000000000000000000000008p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (0x8.0000000000008p0)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (0x8.00001p0)":
+double: 2
+idouble: 2
+Test "tgamma (0xa.b9fd72b0fb238p+4)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (0xa.b9fd72b0fb23a9ddbf0d3804f8p+4)":
+ildouble: 2
+ldouble: 2
+Test "tgamma (10)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (18.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (19.5)":
+double: 2
+idouble: 2
+ildouble: 1
+ldouble: 1
+Test "tgamma (2.5)":
+float: 2
+ifloat: 2
+Test "tgamma (23.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (29.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (3)":
+float: 1
+ifloat: 1
+Test "tgamma (3.5)":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "tgamma (30.5)":
+float: 1
+ifloat: 1
+Test "tgamma (32.5)":
+ildouble: 1
+ldouble: 1
+Test "tgamma (33.5)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (34.5)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "tgamma (4)":
+float: 1
+ifloat: 1
+Test "tgamma (4.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (6)":
+float: 1
+ifloat: 1
+Test "tgamma (6.5)":
+float: 1
+ifloat: 1
+Test "tgamma (7)":
+double: 1
+idouble: 1
+Test "tgamma (7.5)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "tgamma (8)":
+double: 1
+idouble: 1
+Test "tgamma (8.5)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (9)":
+double: 1
+idouble: 1
+Test "tgamma (9.5)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+# y0
+Test "y0 (0x1.3ffp+74)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "y0 (0x1.ff00000000002p+840)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "y0 (0x1p-10)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "y0 (0x1p-110)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "y0 (0x1p-20)":
+float: 1
+ifloat: 1
+Test "y0 (0x1p-30)":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "y0 (0x1p-40)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "y0 (0x1p-50)":
+float: 1
+ifloat: 1
+Test "y0 (0x1p-60)":
+ildouble: 1
+ldouble: 1
+Test "y0 (0x1p-70)":
+double: 1
+idouble: 1
+Test "y0 (0x1p-80)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "y0 (0x1p1023)":
+ildouble: 1
+ldouble: 1
+Test "y0 (0x1p16382)":
+ildouble: 1
+ldouble: 1
+Test "y0 (0x1p16383)":
+ildouble: 2
+ldouble: 2
+Test "y0 (1.0)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (1.5)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (10.0)":
+float: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+Test "y0 (8.0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+
+# y1
+Test "y1 (0.125)":
+double: 1
+idouble: 1
+Test "y1 (0.75)":
+ildouble: 1
+ldouble: 1
+Test "y1 (0x1.001000001p+593)":
+ildouble: 1
+ldouble: 1
+Test "y1 (0x1.27e204p+99)":
+double: 1
+idouble: 1
+Test "y1 (0x1p-10)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "y1 (0x1p-30)":
+ildouble: 1
+ldouble: 1
+Test "y1 (0x1p1023)":
+ildouble: 1
+ldouble: 1
+Test "y1 (0x1p16383)":
+ildouble: 2
+ldouble: 2
+Test "y1 (1.5)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "y1 (10.0)":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "y1 (2.0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "y1 (8.0)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# yn
+Test "yn (0, 1.0)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 1.5)":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 10.0)":
+float: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+Test "yn (0, 8.0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+Test "yn (1, 0.125)":
+double: 1
+idouble: 1
+Test "yn (1, 0.75)":
+ildouble: 1
+ldouble: 1
+Test "yn (1, 1.5)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (1, 10.0)":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "yn (1, 2.0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (1, 8.0)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "yn (10, 0.125)":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+Test "yn (10, 0.75)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 5
+ldouble: 5
+Test "yn (10, 1.0)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "yn (10, 10.0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "yn (10, 2.0)":
+double: 2
+idouble: 2
+ildouble: 2
+ldouble: 2
+Test "yn (3, 0.125)":
+double: 1
+idouble: 1
+Test "yn (3, 0.75)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "yn (3, 10.0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (3, 2.0)":
+double: 1
+idouble: 1
+
+# Maximal error of functions:
+Function: "acos_downward":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "acos_towardzero":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "asin_downward":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "asin_towardzero":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "asin_upward":
+float: 1
+ifloat: 1
+
+Function: "atan2":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "atanh":
+float: 1
+ifloat: 1
+
+Function: Real part of "cacos":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 2
+ldouble: 2
+
+Function: Imaginary part of "cacos":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "cacosh":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 2
+ldouble: 2
+
+Function: Imaginary part of "cacosh":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "casin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Imaginary part of "casin":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "casinh":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 2
+ldouble: 2
+
+Function: Imaginary part of "casinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "catan":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "catan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "catanh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "catanh":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "cbrt":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ccos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ccos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "cexp":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "cexp":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "clog":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "clog":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "clog10":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "clog10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: "cos":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "cos_downward":
+float: 1
+ifloat: 1
+
+Function: "cos_tonearest":
+float: 1
+ifloat: 1
+
+Function: "cos_towardzero":
+float: 1
+ifloat: 1
+
+Function: "cos_upward":
+float: 2
+ifloat: 2
+
+Function: "cosh_downward":
+float: 1
+ifloat: 1
+
+Function: "cosh_tonearest":
+ildouble: 1
+ldouble: 1
+
+Function: "cosh_towardzero":
+float: 1
+ifloat: 1
+
+Function: Real part of "cpow":
+double: 2
+float: 4
+idouble: 2
+ifloat: 4
+ildouble: 4
+ldouble: 4
+
+Function: Imaginary part of "cpow":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "csin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csin":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "csinh":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "csqrt":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csqrt":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ctan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Imaginary part of "ctan":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "ctan_downward":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: Imaginary part of "ctan_downward":
+float: 1
+ifloat: 1
+
+Function: Real part of "ctan_tonearest":
+float: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+
+Function: Imaginary part of "ctan_tonearest":
+float: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+
+Function: Real part of "ctan_towardzero":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "ctan_towardzero":
+float: 1
+ifloat: 1
+
+Function: Real part of "ctan_upward":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: Imaginary part of "ctan_upward":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Real part of "ctanh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Imaginary part of "ctanh":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "ctanh_downward":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "ctanh_downward":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: Real part of "ctanh_tonearest":
+float: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+
+Function: Imaginary part of "ctanh_tonearest":
+float: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+
+Function: Real part of "ctanh_towardzero":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "ctanh_towardzero":
+float: 1
+ifloat: 1
+
+Function: Real part of "ctanh_upward":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Imaginary part of "ctanh_upward":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: "erf":
+double: 1
+idouble: 1
+
+Function: "erfc":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "exp10":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: "exp2":
+ildouble: 1
+ldouble: 1
+
+Function: "exp_downward":
+float: 1
+ifloat: 1
+
+Function: "exp_towardzero":
+float: 1
+ifloat: 1
+
+Function: "exp_upward":
+float: 1
+ifloat: 1
+
+Function: "expm1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "gamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "hypot":
+float: 1
+ifloat: 1
+
+Function: "j0":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+
+Function: "j1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 4
+ldouble: 4
+
+Function: "jn":
+double: 4
+float: 5
+idouble: 4
+ifloat: 5
+ildouble: 8
+ldouble: 8
+
+Function: "lgamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "log10":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "log1p":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "log2":
+ildouble: 1
+ldouble: 1
+
+Function: "pow":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "pow10":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: "pow_downward":
+float: 1
+ifloat: 1
+
+Function: "pow_towardzero":
+float: 1
+ifloat: 1
+
+Function: "pow_upward":
+float: 1
+ifloat: 1
+
+Function: "sin_downward":
+float: 1
+ifloat: 1
+
+Function: "sin_tonearest":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "sin_towardzero":
+float: 1
+ifloat: 1
+
+Function: "sin_upward":
+float: 2
+ifloat: 2
+
+Function: "sincos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "sinh_downward":
+float: 1
+ifloat: 1
+
+Function: "sinh_towardzero":
+float: 1
+ifloat: 1
+
+Function: "tan":
+double: 1
+idouble: 1
+
+Function: "tan_downward":
+float: 1
+ifloat: 1
+
+Function: "tan_towardzero":
+float: 1
+ifloat: 1
+
+Function: "tan_upward":
+float: 1
+ifloat: 1
+
+Function: "tanh":
+ildouble: 1
+ldouble: 1
+
+Function: "tgamma":
+double: 4
+float: 3
+idouble: 4
+ifloat: 3
+ildouble: 4
+ldouble: 4
+
+Function: "y0":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 3
+ldouble: 3
+
+Function: "y1":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+ildouble: 2
+ldouble: 2
+
+Function: "yn":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+ildouble: 5
+ldouble: 5
+
+# end of automatic generation
diff --git a/test/math/libm-test-ulps-powerpc b/test/math/libm-test-ulps-powerpc
new file mode 100644
index 000000000..8516e915e
--- /dev/null
+++ b/test/math/libm-test-ulps-powerpc
@@ -0,0 +1,1336 @@
+# Begin of automatic generation
+
+# acos
+Test "acos (2e-17) == 1.57079632679489659923132169163975144":
+ildouble: 1
+ldouble: 1
+
+# asin
+Test "asin (0.75) == 0.848062078981481008052944338998418080":
+ildouble: 2
+ldouble: 2
+
+# atan2
+Test "atan2 (-0.00756827042671106339, -.001792735857538728036) == -1.80338464113663849327153994379639112":
+ildouble: 1
+ldouble: 1
+Test "atan2 (-0.75, -1.0) == -2.49809154479650885165983415456218025":
+float: 1
+ifloat: 1
+Test "atan2 (0.75, -1.0) == 2.49809154479650885165983415456218025":
+float: 1
+ifloat: 1
+Test "atan2 (1.390625, 0.9296875) == 0.981498387184244311516296577615519772":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# atanh
+Test "atanh (0.75) == 0.972955074527656652552676371721589865":
+float: 1
+ifloat: 1
+
+# cabs
+Test "cabs (0.75 + 1.25 i) == 1.45773797371132511771853821938639577":
+ildouble: 1
+ldouble: 1
+
+# cacosh
+Test "Real part of: cacosh (-2 - 3 i) == 1.9833870299165354323470769028940395 - 2.1414491111159960199416055713254211 i":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+Test "Imaginary part of: cacosh (-2 - 3 i) == 1.9833870299165354323470769028940395 - 2.1414491111159960199416055713254211 i":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+
+# casin
+Test "Real part of: casin (-2 - 3 i) == -0.57065278432109940071028387968566963 - 1.9833870299165354323470769028940395 i":
+ildouble: 1
+ldouble: 1
+Test "Real part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# casinh
+Test "Real part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+ildouble: 4
+ldouble: 4
+Test "Imaginary part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+ildouble: 1
+ldouble: 1
+Test "Real part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# catan
+Test "Real part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+float: 3
+ifloat: 3
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: catan (0.75 + 1.25 i) == 1.10714871779409050301706546017853704 + 0.549306144334054845697622618461262852 i":
+float: 4
+ifloat: 4
+
+# catanh
+Test "Real part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+double: 4
+idouble: 4
+Test "Imaginary part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+float: 4
+ifloat: 4
+Test "Real part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+float: 6
+ifloat: 6
+
+# cbrt
+Test "cbrt (-27.0) == -3.0":
+double: 1
+idouble: 1
+Test "cbrt (0.9921875) == 0.997389022060725270579075195353955217":
+double: 1
+idouble: 1
+
+# ccos
+Test "Imaginary part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+float: 1
+ifloat: 1
+Test "Real part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+float: 1
+ifloat: 1
+
+# ccosh
+Test "Real part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+Test "Real part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+# cexp
+Test "Imaginary part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+float: 1
+ifloat: 1
+Test "Real part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+ildouble: 1
+ldouble: 1
+
+# clog
+Test "Imaginary part of: clog (-2 - 3 i) == 1.2824746787307683680267437207826593 - 2.1587989303424641704769327722648368 i":
+float: 3
+ifloat: 3
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog (0.75 + 1.25 i) == 0.376885901188190075998919126749298416 + 1.03037682652431246378774332703115153 i":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: clog (0.75 + 1.25 i) == 0.376885901188190075998919126749298416 + 1.03037682652431246378774332703115153 i":
+ildouble: 1
+ldouble: 1
+
+# clog10
+Test "Imaginary part of: clog10 (-0 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (-0 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (-3 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (-3 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (-inf + 0 i) == inf + pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (-inf + 1 i) == inf + pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (-inf + inf i) == inf + 3/4 pi*log10(e) i":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-inf - 0 i) == inf - pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (-inf - 1 i) == inf - pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (0 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (0 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
+float: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+Test "Imaginary part of: clog10 (3 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (3 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (inf + inf i) == inf + pi/4*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (inf - inf i) == inf - pi/4*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# cos
+Test "cos (M_PI_6l * 2.0) == 0.5":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "cos (M_PI_6l * 4.0) == -0.5":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "cos (pi/2) == 0":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "cos (16.0) == -0.9576594803233846418996372326511034717803"
+ildouble: 2
+ldouble: 2
+
+# cpow
+Test "Real part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 0.0 i) == 0.75 + 1.25 i":
+ildouble: 2
+ldouble: 2
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i) == 0.0846958290317209430433805274189191353 + 0.513285749182902449043287190519090481 i":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+Test "Real part of: cpow (2 + 0 i, 10 + 0 i) == 1024.0 + 0.0 i":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+float: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+
+# csinh
+Test "Imaginary part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# csqrt
+Test "Real part of: csqrt (-2 + 3 i) == 0.89597747612983812471573375529004348 + 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+Test "Real part of: csqrt (-2 - 3 i) == 0.89597747612983812471573375529004348 - 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+
+# ctan
+Test "Real part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i":
+double: 1
+idouble: 1
+
+# ctanh
+Test "Real part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "Imaginary part of: ctanh (0 + pi/4 i) == 0.0 + 1.0 i":
+float: 1
+ifloat: 1
+Test "Real part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+# erf
+Test "erf (1.25) == 0.922900128256458230136523481197281140":
+double: 1
+idouble: 1
+
+# erfc
+Test "erfc (0.75) == 0.288844366346484868401062165408589223":
+float: 1
+ifloat: 1
+Test "erfc (2.0) == 0.00467773498104726583793074363274707139":
+double: 1
+idouble: 1
+Test "erfc (4.125) == 0.542340079956506600531223408575531062e-8":
+double: 1
+idouble: 1
+
+# exp
+Test "exp (0.75) == 2.11700001661267466854536981983709561":
+ildouble: 1
+ldouble: 1
+Test "exp (50.0) == 5184705528587072464087.45332293348538":
+ildouble: 1
+ldouble: 1
+
+# exp10
+Test "exp10 (-1) == 0.1":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "exp10 (0.75) == 5.62341325190349080394951039776481231":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "exp10 (3) == 1000":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+ildouble: 8
+ldouble: 8
+
+# exp2
+Test "exp2 (10) == 1024":
+ildouble: 2
+ldouble: 2
+
+# expm1
+Test "expm1 (0.75) == 1.11700001661267466854536981983709561":
+double: 1
+idouble: 1
+Test "expm1 (1) == M_El - 1.0":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# hypot
+Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.75, 1.25) == 1.45773797371132511771853821938639577":
+ildouble: 1
+ldouble: 1
+Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+
+# j0
+Test "j0 (-4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "j0 (10.0) == -0.245935764451348335197760862485328754":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "j0 (2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+Test "j0 (4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "j0 (8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# j1
+Test "j1 (10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "j1 (2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "j1 (8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+# jn
+Test "jn (0, -4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "jn (0, 10.0) == -0.245935764451348335197760862485328754":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (0, 2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+Test "jn (0, 4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "jn (0, 8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (1, 10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "jn (1, 2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "jn (1, 8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "jn (10, -1.0) == 0.263061512368745320699785368779050294e-9":
+ildouble: 1
+ldouble: 1
+Test "jn (10, 0.125) == 0.250543369809369890173993791865771547e-18":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (10, 0.75) == 0.149621713117596814698712483621682835e-10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (10, 1.0) == 0.263061512368745320699785368779050294e-9":
+ildouble: 1
+ldouble: 1
+Test "jn (10, 10.0) == 0.207486106633358857697278723518753428":
+float: 1
+ifloat: 1
+ildouble: 4
+ldouble: 4
+Test "jn (10, 2.0) == 0.251538628271673670963516093751820639e-6":
+float: 4
+ifloat: 4
+Test "jn (3, -1.0) == -0.0195633539826684059189053216217515083":
+ildouble: 1
+ldouble: 1
+Test "jn (3, 0.125) == 0.406503832554912875023029337653442868e-4":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 0.75) == 0.848438342327410884392755236884386804e-2":
+double: 1
+idouble: 1
+Test "jn (3, 1.0) == 0.0195633539826684059189053216217515083":
+ildouble: 1
+ldouble: 1
+Test "jn (3, 10.0) == 0.0583793793051868123429354784103409563":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "jn (3, 2.0) == 0.128943249474402051098793332969239835":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 2
+ldouble: 2
+
+# lgamma
+Test "lgamma (0.7) == 0.260867246531666514385732417016759578":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 3
+ldouble: 3
+
+# log10
+Test "log10 (0.75) == -0.124938736608299953132449886193870744":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "log10 (e) == log10(e)":
+float: 1
+ifloat: 1
+
+# log1p
+Test "log1p (-0.25) == -0.287682072451780927439219005993827432":
+float: 1
+ifloat: 1
+
+# log2
+Test "log2 (e) == M_LOG2El":
+ildouble: 1
+ldouble: 1
+
+# sin
+Test "sin (16.0) == -0.2879033166650652947844562482186175296207"
+ildouble: 2
+ldouble: 2
+
+# sincos
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in sin_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (pi/2, &sin_res, &cos_res) puts 0 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (pi/6, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in cos_res":
+float: 1
+ifloat: 1
+
+# sinh
+Test "sinh (0.75) == 0.822316731935829980703661634446913849":
+ildouble: 1
+ldouble: 1
+
+# tan
+Test "tan (pi/4) == 1":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+# tanh
+Test "tanh (-0.75) == -0.635148952387287319214434357312496495":
+ildouble: 1
+ldouble: 1
+Test "tanh (0.75) == 0.635148952387287319214434357312496495":
+ildouble: 1
+ldouble: 1
+
+# tgamma
+Test "tgamma (-0.5) == -2 sqrt (pi)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (0.5) == sqrt (pi)":
+float: 1
+ifloat: 1
+Test "tgamma (0.7) == 1.29805533264755778568117117915281162":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# y0
+Test "y0 (0.125) == -1.38968062514384052915582277745018693":
+ildouble: 1
+ldouble: 1
+Test "y0 (0.75) == -0.137172769385772397522814379396581855":
+ildouble: 1
+ldouble: 1
+Test "y0 (1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "y0 (1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (10.0) == 0.0556711672835993914244598774101900481":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "y0 (2.0) == 0.510375672649745119596606592727157873":
+double: 1
+idouble: 1
+Test "y0 (8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# y1
+Test "y1 (0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+Test "y1 (1.5) == -0.412308626973911295952829820633445323":
+float: 1
+ifloat: 1
+Test "y1 (10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "y1 (2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 2
+ifloat: 2
+Test "y1 (8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 2
+ldouble: 2
+
+# yn
+Test "yn (0, 0.125) == -1.38968062514384052915582277745018693":
+ildouble: 1
+ldouble: 1
+Test "yn (0, 0.75) == -0.137172769385772397522814379396581855":
+ildouble: 1
+ldouble: 1
+Test "yn (0, 1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "yn (0, 1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 10.0) == 0.0556711672835993914244598774101900481":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "yn (0, 2.0) == 0.510375672649745119596606592727157873":
+double: 1
+idouble: 1
+Test "yn (0, 8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "yn (1, 0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+Test "yn (1, 1.5) == -0.412308626973911295952829820633445323":
+float: 2
+ifloat: 2
+Test "yn (1, 10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "yn (1, 2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (1, 8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "yn (3, 0.125) == -2612.69757350066712600220955744091741":
+double: 1
+idouble: 1
+Test "yn (10, 0.125) == -127057845771019398.252538486899753195":
+double: 1
+idouble: 1
+Test "yn (10, 0.75) == -2133501638.90573424452445412893839236":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "yn (10, 1.0) == -121618014.278689189288130426667971145":
+float: 2
+ifloat: 2
+Test "yn (10, 10.0) == -0.359814152183402722051986577343560609":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "yn (10, 2.0) == -129184.542208039282635913145923304214":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "yn (3, 0.125) == -2612.69757350066712600220955744091741":
+double: 1
+idouble: 1
+Test "yn (3, 0.75) == -12.9877176234475433186319774484809207":
+float: 1
+ifloat: 1
+Test "yn (3, 10.0) == -0.251362657183837329779204747654240998":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "yn (3, 2.0) == -1.12778377684042778608158395773179238":
+double: 1
+idouble: 1
+
+# Maximal error of functions:
+Function: "acos":
+ildouble: 1
+ldouble: 1
+
+Function: "acosh":
+ildouble: 1
+ldouble: 1
+
+Function: "asin":
+ildouble: 2
+ldouble: 2
+
+Function: "asinh":
+ildouble: 1
+ldouble: 1
+
+Function: "atan2":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "atanh":
+float: 1
+ifloat: 1
+
+Function: "cabs":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "cacos":
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "cacos":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "cacosh":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "cacosh":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+
+Function: Real part of "casin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "casin":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "casinh":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+ildouble: 4
+ldouble: 4
+
+Function: Imaginary part of "casinh":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "catan":
+float: 4
+ifloat: 4
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "catan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "catanh":
+double: 4
+idouble: 4
+
+Function: Imaginary part of "catanh":
+float: 6
+ifloat: 6
+
+Function: "cbrt":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ccos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ccos":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ccosh":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "cexp":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Imaginary part of "cexp":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "clog":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Imaginary part of "clog":
+float: 3
+ifloat: 3
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "clog10":
+float: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+
+Function: Imaginary part of "clog10":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+ildouble: 1
+ldouble: 1
+
+Function: "cos":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "cosh":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "cpow":
+double: 2
+float: 5
+idouble: 2
+ifloat: 5
+ildouble: 2
+ldouble: 2
+
+Function: Imaginary part of "cpow":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+
+Function: Imaginary part of "cproj":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "csin":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "csinh":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "csqrt":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csqrt":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ctan":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ctan":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ctanh":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ctanh":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "erf":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: "erfc":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "exp":
+ildouble: 1
+ldouble: 1
+
+Function: "exp10":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+ildouble: 8
+ldouble: 8
+
+Function: "exp2":
+ildouble: 2
+ldouble: 2
+
+Function: "expm1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "gamma":
+ildouble: 1
+ldouble: 1
+
+Function: "hypot":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "j0":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "j1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "jn":
+double: 3
+float: 4
+idouble: 3
+ifloat: 4
+ildouble: 4
+ldouble: 4
+
+Function: "lgamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 3
+ldouble: 3
+
+Function: "log":
+ildouble: 1
+ldouble: 1
+
+Function: "log10":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "log1p":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "log2":
+ildouble: 1
+ldouble: 1
+
+Function: "pow":
+ildouble: 1
+ldouble: 1
+
+Function: "sin":
+ildouble: 1
+ldouble: 1
+
+Function: "sincos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "sinh":
+ildouble: 1
+ldouble: 1
+
+Function: "tan":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: "tanh":
+ildouble: 1
+ldouble: 1
+
+Function: "tgamma":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "y0":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "y1":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+ildouble: 2
+ldouble: 2
+
+Function: "yn":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+ildouble: 2
+ldouble: 2
+
+# end of automatic generation
diff --git a/test/math/libm-test-ulps-s390 b/test/math/libm-test-ulps-s390
new file mode 100644
index 000000000..989722e65
--- /dev/null
+++ b/test/math/libm-test-ulps-s390
@@ -0,0 +1,1332 @@
+# Begin of automatic generation
+
+# atan2
+Test "atan2 (-0.00756827042671106339, -.001792735857538728036) == -1.80338464113663849327153994379639112":
+ildouble: 1
+ldouble: 1
+Test "atan2 (-0.75, -1.0) == -2.49809154479650885165983415456218025":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "atan2 (0.75, -1.0) == 2.49809154479650885165983415456218025":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "atan2 (1.390625, 0.9296875) == 0.981498387184244311516296577615519772":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# atanh
+Test "atanh (0.75) == 0.972955074527656652552676371721589865":
+float: 1
+ifloat: 1
+
+# cacos
+Test "Imaginary part of: cacos (0.75 + 1.25 i) == 1.11752014915610270578240049553777969 - 1.13239363160530819522266333696834467 i":
+ildouble: 1
+ldouble: 1
+
+# cacosh
+Test "Real part of: cacosh (-2 - 3 i) == 1.9833870299165354323470769028940395 - 2.1414491111159960199416055713254211 i":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+Test "Imaginary part of: cacosh (-2 - 3 i) == 1.9833870299165354323470769028940395 - 2.1414491111159960199416055713254211 i":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+ildouble: 1
+ldouble: 1
+
+# casin
+Test "Real part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+ildouble: 1
+ldouble: 1
+
+# casinh
+Test "Real part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+ildouble: 4
+ldouble: 4
+Test "Imaginary part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+ildouble: 2
+ldouble: 2
+Test "Real part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# catan
+Test "Real part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+float: 3
+ifloat: 3
+Test "Imaginary part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: catan (0.75 + 1.25 i) == 1.10714871779409050301706546017853704 + 0.549306144334054845697622618461262852 i":
+float: 4
+ifloat: 4
+Test "Imaginary part of: catan (0.75 + 1.25 i) == 1.10714871779409050301706546017853704 + 0.549306144334054845697622618461262852 i":
+ildouble: 1
+ldouble: 1
+
+# catanh
+Test "Real part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+double: 4
+idouble: 4
+Test "Imaginary part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+float: 4
+ifloat: 4
+Test "Real part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+float: 6
+ifloat: 6
+ildouble: 1
+ldouble: 1
+
+# cbrt
+Test "cbrt (-0.001) == -0.1":
+ildouble: 1
+ldouble: 1
+Test "cbrt (-27.0) == -3.0":
+double: 1
+idouble: 1
+Test "cbrt (0.75) == 0.908560296416069829445605878163630251":
+double: 1
+idouble: 1
+Test "cbrt (0.9921875) == 0.997389022060725270579075195353955217":
+double: 1
+idouble: 1
+
+# ccos
+Test "Real part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+float: 1
+ifloat: 1
+
+# ccosh
+Test "Real part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+float: 1
+ifloat: 1
+
+# cexp
+Test "Real part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+ildouble: 1
+ldouble: 1
+
+# clog
+Test "Imaginary part of: clog (-2 - 3 i) == 1.2824746787307683680267437207826593 - 2.1587989303424641704769327722648368 i":
+float: 3
+ifloat: 3
+Test "Real part of: clog (0.75 + 1.25 i) == 0.376885901188190075998919126749298416 + 1.03037682652431246378774332703115153 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# clog10
+Test "Imaginary part of: clog10 (-0 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-0 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (-3 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-3 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 0 i) == inf + pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 1 i) == inf + pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + inf i) == inf + 3/4 pi*log10(e) i":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-inf - 0 i) == inf - pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 1 i) == inf - pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (3 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf + inf i) == inf + pi/4*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf - inf i) == inf - pi/4*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# cos
+Test "cos (M_PI_6l * 2.0) == 0.5":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "cos (M_PI_6l * 4.0) == -0.5":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "cos (pi/2) == 0":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# cpow
+Test "Real part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+ildouble: 4
+ldouble: 4
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 0.0 i) == 0.75 + 1.25 i":
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 1.0 + 0.0 i) == 0.75 + 1.25 i":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i) == 0.0846958290317209430433805274189191353 + 0.513285749182902449043287190519090481 i":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+ildouble: 10
+ldouble: 10
+Test "Real part of: cpow (2 + 0 i, 10 + 0 i) == 1024.0 + 0.0 i":
+ildouble: 2
+ldouble: 2
+Test "Real part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+ildouble: 3
+ldouble: 3
+Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# csin
+Test "Imaginary part of: csin (-2 - 3 i) == -9.15449914691142957346729954460983256 + 4.16890695996656435075481305885375484 i":
+ildouble: 1
+ldouble: 1
+Test "Real part of: csin (0.75 + 1.25 i) == 1.28722291002649188575873510790565441 + 1.17210635989270256101081285116138863 i":
+ildouble: 1
+ldouble: 1
+
+# csinh
+Test "Real part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+double: 1
+idouble: 1
+Test "Real part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+
+# csqrt
+Test "Real part of: csqrt (-2 + 3 i) == 0.89597747612983812471573375529004348 + 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: csqrt (-2 - 3 i) == 0.89597747612983812471573375529004348 - 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csqrt (0.75 + 1.25 i) == 1.05065169626078392338656675760808326 + 0.594868882070379067881984030639932657 i":
+ildouble: 1
+ldouble: 1
+
+# ctan
+Test "Real part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+
+# ctanh
+Test "Real part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctanh (0 + pi/4 i) == 0.0 + 1.0 i":
+float: 1
+ifloat: 1
+Test "Real part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i":
+double: 1
+idouble: 1
+
+# erf
+Test "erf (1.25) == 0.922900128256458230136523481197281140":
+double: 1
+idouble: 1
+
+# erfc
+Test "erfc (0.75) == 0.288844366346484868401062165408589223":
+float: 1
+ifloat: 1
+Test "erfc (2.0) == 0.00467773498104726583793074363274707139":
+double: 1
+idouble: 1
+Test "erfc (27.0) == 0.523704892378925568501606768284954709e-318":
+ildouble: 1
+ldouble: 1
+Test "erfc (4.125) == 0.542340079956506600531223408575531062e-8":
+double: 1
+idouble: 1
+
+# exp10
+Test "exp10 (-1) == 0.1":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "exp10 (0.75) == 5.62341325190349080394951039776481231":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "exp10 (3) == 1000":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# exp2
+Test "exp2 (10) == 1024":
+ildouble: 2
+ldouble: 2
+
+# expm1
+Test "expm1 (0.75) == 1.11700001661267466854536981983709561":
+double: 1
+idouble: 1
+Test "expm1 (1) == M_El - 1.0":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# gamma
+Test "gamma (-0.5) == log(2*sqrt(pi))":
+ildouble: 1
+ldouble: 1
+
+# hypot
+Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+
+# j0
+Test "j0 (-4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "j0 (0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "j0 (10.0) == -0.245935764451348335197760862485328754":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "j0 (2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "j0 (4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "j0 (8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# j1
+Test "j1 (-1.0) == -0.440050585744933515959682203718914913":
+ildouble: 1
+ldouble: 1
+Test "j1 (0.75) == 0.349243602174862192523281016426251335":
+ildouble: 1
+ldouble: 1
+Test "j1 (1.0) == 0.440050585744933515959682203718914913":
+ildouble: 1
+ldouble: 1
+Test "j1 (10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "j1 (2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "j1 (8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+ildouble: 4
+ldouble: 4
+
+# jn
+Test "jn (0, -4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "jn (0, 0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "jn (0, 10.0) == -0.245935764451348335197760862485328754":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "jn (0, 2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "jn (0, 4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "jn (0, 8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (1, -1.0) == -0.440050585744933515959682203718914913":
+ildouble: 1
+ldouble: 1
+Test "jn (1, 0.75) == 0.349243602174862192523281016426251335":
+ildouble: 1
+ldouble: 1
+Test "jn (1, 1.0) == 0.440050585744933515959682203718914913":
+ildouble: 1
+ldouble: 1
+Test "jn (1, 10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "jn (1, 2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "jn (1, 8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+ildouble: 4
+ldouble: 4
+Test "jn (10, -1.0) == 0.263061512368745320699785368779050294e-9":
+ildouble: 1
+ldouble: 1
+Test "jn (10, 0.125) == 0.250543369809369890173993791865771547e-18":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (10, 0.75) == 0.149621713117596814698712483621682835e-10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (10, 1.0) == 0.263061512368745320699785368779050294e-9":
+ildouble: 1
+ldouble: 1
+Test "jn (10, 10.0) == 0.207486106633358857697278723518753428":
+double: 4
+float: 3
+idouble: 4
+ifloat: 3
+ildouble: 2
+ldouble: 2
+Test "jn (10, 2.0) == 0.251538628271673670963516093751820639e-6":
+float: 4
+ifloat: 4
+Test "jn (3, 0.125) == 0.406503832554912875023029337653442868e-4":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 0.75) == 0.848438342327410884392755236884386804e-2":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 10.0) == 0.0583793793051868123429354784103409563":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "jn (3, 2.0) == 0.128943249474402051098793332969239835":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# lgamma
+Test "lgamma (-0.5) == log(2*sqrt(pi))":
+ildouble: 1
+ldouble: 1
+Test "lgamma (0.7) == 0.260867246531666514385732417016759578":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# log10
+Test "log10 (0.75) == -0.124938736608299953132449886193870744":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "log10 (e) == log10(e)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# log1p
+Test "log1p (-0.25) == -0.287682072451780927439219005993827432":
+float: 1
+ifloat: 1
+
+# log2
+Test "log2 (0.75) == -.415037499278843818546261056052183492":
+ildouble: 1
+ldouble: 1
+
+# sincos
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in sin_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "sincos (pi/2, &sin_res, &cos_res) puts 0 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (pi/6, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in cos_res":
+float: 1
+ifloat: 1
+
+# sqrt
+Test "sqrt (2) == M_SQRT2l":
+ildouble: 1
+ldouble: 1
+
+# tan
+Test "tan (pi/4) == 1":
+double: 1
+idouble: 1
+
+# tanh
+Test "tanh (-0.75) == -0.635148952387287319214434357312496495":
+ildouble: 1
+ldouble: 1
+Test "tanh (-1.0) == -0.7615941559557648881194582826047935904":
+ildouble: 1
+ldouble: 1
+Test "tanh (0.75) == 0.635148952387287319214434357312496495":
+ildouble: 1
+ldouble: 1
+Test "tanh (1.0) == 0.7615941559557648881194582826047935904":
+ildouble: 1
+ldouble: 1
+
+# tgamma
+Test "tgamma (-0.5) == -2 sqrt (pi)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (0.5) == sqrt (pi)":
+float: 1
+ifloat: 1
+Test "tgamma (0.7) == 1.29805533264755778568117117915281162":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (4) == 6":
+ildouble: 1
+ldouble: 1
+
+# y0
+Test "y0 (1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (10.0) == 0.0556711672835993914244598774101900481":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+Test "y0 (2.0) == 0.510375672649745119596606592727157873":
+double: 1
+idouble: 1
+Test "y0 (8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+
+# y1
+Test "y1 (0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+Test "y1 (0.75) == -1.03759455076928541973767132140642198":
+ildouble: 1
+ldouble: 1
+Test "y1 (1.5) == -0.412308626973911295952829820633445323":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "y1 (10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "y1 (2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "y1 (8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# yn
+Test "yn (0, 1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 10.0) == 0.0556711672835993914244598774101900481":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+Test "yn (0, 2.0) == 0.510375672649745119596606592727157873":
+double: 1
+idouble: 1
+Test "yn (0, 8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+Test "yn (1, 0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+Test "yn (1, 0.75) == -1.03759455076928541973767132140642198":
+ildouble: 1
+ldouble: 1
+Test "yn (1, 1.5) == -0.412308626973911295952829820633445323":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (1, 10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "yn (1, 2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (1, 8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "yn (10, 0.125) == -127057845771019398.252538486899753195":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+Test "yn (10, 0.75) == -2133501638.90573424452445412893839236":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 5
+ldouble: 5
+Test "yn (10, 1.0) == -121618014.278689189288130426667971145":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "yn (10, 10.0) == -0.359814152183402722051986577343560609":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "yn (10, 2.0) == -129184.542208039282635913145923304214":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "yn (3, 0.125) == -2612.69757350066712600220955744091741":
+double: 1
+idouble: 1
+Test "yn (3, 0.75) == -12.9877176234475433186319774484809207":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "yn (3, 10.0) == -0.251362657183837329779204747654240998":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (3, 2.0) == -1.12778377684042778608158395773179238":
+double: 1
+idouble: 1
+
+# Maximal error of functions:
+Function: "atan2":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "atanh":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "cacos":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "cacosh":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+
+Function: Imaginary part of "cacosh":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "casin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "casin":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "casinh":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+ildouble: 4
+ldouble: 4
+
+Function: Imaginary part of "casinh":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "catan":
+float: 4
+ifloat: 4
+
+Function: Imaginary part of "catan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "catanh":
+double: 4
+idouble: 4
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "catanh":
+float: 6
+ifloat: 6
+ildouble: 1
+ldouble: 1
+
+Function: "cbrt":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ccos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ccos":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ccosh":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "cexp":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "cexp":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "clog":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "clog":
+float: 3
+ifloat: 3
+
+Function: Real part of "clog10":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "clog10":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+ildouble: 1
+ldouble: 1
+
+Function: "cos":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "cpow":
+double: 2
+float: 4
+idouble: 2
+ifloat: 4
+ildouble: 10
+ldouble: 10
+
+Function: Imaginary part of "cpow":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "csin":
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csin":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "csinh":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "csqrt":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csqrt":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ctan":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ctan":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "ctanh":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ctanh":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "erf":
+double: 1
+idouble: 1
+
+Function: "erfc":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "exp10":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "exp2":
+ildouble: 2
+ldouble: 2
+
+Function: "expm1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "gamma":
+ildouble: 1
+ldouble: 1
+
+Function: "hypot":
+float: 1
+ifloat: 1
+
+Function: "j0":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+ildouble: 2
+ldouble: 2
+
+Function: "j1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 4
+ldouble: 4
+
+Function: "jn":
+double: 4
+float: 4
+idouble: 4
+ifloat: 4
+ildouble: 4
+ldouble: 4
+
+Function: "lgamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "log10":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "log1p":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "log2":
+ildouble: 1
+ldouble: 1
+
+Function: "sincos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "sqrt":
+ildouble: 1
+ldouble: 1
+
+Function: "tan":
+double: 1
+idouble: 1
+
+Function: "tanh":
+ildouble: 1
+ldouble: 1
+
+Function: "tgamma":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "y0":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 3
+ldouble: 3
+
+Function: "y1":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "yn":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+ildouble: 5
+ldouble: 5
+
+# end of automatic generation
diff --git a/test/math/libm-test-ulps-sh b/test/math/libm-test-ulps-sh
new file mode 100644
index 000000000..4831f4849
--- /dev/null
+++ b/test/math/libm-test-ulps-sh
@@ -0,0 +1,1094 @@
+# Begin of automatic generation
+
+# asin
+Test "asin (-0.5) == -pi/6":
+float: 2
+ifloat: 2
+Test "asin (0.5) == pi/6":
+float: 2
+ifloat: 2
+Test "asin (0.7) == 0.7753974966107530637":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# atan2
+Test "atan2 (0.7, -1.0) == 2.530866689200584621918884506789267":
+float: 3
+ifloat: 3
+Test "atan2 (-0.7, -1.0) == -2.530866689200584621918884506789267":
+float: 3
+ifloat: 3
+Test "atan2 (1.4, -0.93) == 2.1571487668237843754887415992772736":
+float: 4
+ifloat: 4
+
+# atanh
+Test "atanh (0.7) == 0.8673005276940531944":
+double: 1
+idouble: 1
+
+# cabs
+Test "cabs (-0.7 + 12.4 i) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "cabs (-0.7 - 12.4 i) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "cabs (-12.4 + 0.7 i) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "cabs (-12.4 - 0.7 i) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "cabs (0.7 + 1.2 i) == 1.3892443989449804508432547041028554":
+double: 1
+idouble: 1
+Test "cabs (0.7 + 12.4 i) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+
+# cacos
+Test "Real part of: cacos (0.7 + 1.2 i) == 1.1351827477151551088992008271819053 - 1.0927647857577371459105272080819308 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cacos (0.7 + 1.2 i) == 1.1351827477151551088992008271819053 - 1.0927647857577371459105272080819308 i":
+float: 1
+ifloat: 1
+
+# cacosh
+Test "Real part of: cacosh (-2 - 3 i) == 1.9833870299165354323470769028940395 - 2.1414491111159960199416055713254211 i":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+Test "Imaginary part of: cacosh (-2 - 3 i) == 1.9833870299165354323470769028940395 - 2.1414491111159960199416055713254211 i":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+Test "Real part of: cacosh (0.7 + 1.2 i) == 1.0927647857577371459105272080819308 + 1.1351827477151551088992008271819053 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# casin
+Test "Real part of: casin (0.7 + 1.2 i) == 0.4356135790797415103321208644578462 + 1.0927647857577371459105272080819308 i":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+Test "Imaginary part of: casin (0.7 + 1.2 i) == 0.4356135790797415103321208644578462 + 1.0927647857577371459105272080819308 i":
+float: 1
+ifloat: 1
+
+# casinh
+Test "Real part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+Test "Imaginary part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+Test "Real part of: casinh (0.7 + 1.2 i) == 0.97865459559367387689317593222160964 + 0.91135418953156011567903546856170941 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: casinh (0.7 + 1.2 i) == 0.97865459559367387689317593222160964 + 0.91135418953156011567903546856170941 i":
+float: 1
+ifloat: 1
+
+# catan
+Test "Real part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+float: 3
+ifloat: 3
+Test "Imaginary part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: catan (0.7 + 1.2 i) == 1.0785743834118921877443707996386368 + 0.57705737765343067644394541889341712 i":
+float: 4
+ifloat: 4
+Test "Imaginary part of: catan (0.7 + 1.2 i) == 1.0785743834118921877443707996386368 + 0.57705737765343067644394541889341712 i":
+double: 1
+idouble: 1
+
+# catanh
+Test "Real part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+double: 4
+idouble: 4
+Test "Imaginary part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+float: 4
+ifloat: 4
+Test "Real part of: catanh (0.7 + 1.2 i) == 0.2600749516525135959200648705635915 + 0.97024030779509898497385130162655963 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: catanh (0.7 + 1.2 i) == 0.2600749516525135959200648705635915 + 0.97024030779509898497385130162655963 i":
+double: 1
+float: 6
+idouble: 1
+ifloat: 6
+
+# cbrt
+Test "cbrt (-27.0) == -3.0":
+double: 1
+idouble: 1
+Test "cbrt (0.970299) == 0.99":
+double: 1
+idouble: 1
+
+# ccos
+Test "Imaginary part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+float: 1
+ifloat: 1
+Test "Real part of: ccos (0.7 + 1.2 i) == 1.3848657645312111080 - 0.97242170335830028619 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: ccos (0.7 + 1.2 i) == 1.3848657645312111080 - 0.97242170335830028619 i":
+double: 1
+idouble: 1
+
+# ccosh
+Test "Real part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+Test "Real part of: ccosh (0.7 + 1.2 i) == 0.4548202223691477654 + 0.7070296600921537682 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (0.7 + 1.2 i) == 0.4548202223691477654 + 0.7070296600921537682 i":
+double: 1
+idouble: 1
+
+# cexp
+Test "Imaginary part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+float: 1
+ifloat: 1
+Test "Real part of: cexp (0.7 + 1.2 i) == 0.7296989091503236012 + 1.8768962328348102821 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: cexp (0.7 + 1.2 i) == 0.7296989091503236012 + 1.8768962328348102821 i":
+float: 1
+ifloat: 1
+
+# clog
+Test "Imaginary part of: clog (-2 - 3 i) == 1.2824746787307683680267437207826593 - 2.1587989303424641704769327722648368 i":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+
+# clog10
+Test "Imaginary part of: clog10 (-0 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-0 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+Test "Imaginary part of: clog10 (-3 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-3 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 0 i) == inf + pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 1 i) == inf + pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 0 i) == inf - pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 1 i) == inf - pi*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Real part of: clog10 (0.7 + 1.2 i) == 0.1427786545038868803 + 0.4528483579352493248 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0.7 + 1.2 i) == 0.1427786545038868803 + 0.4528483579352493248 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (3 + inf i) == inf + pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 - inf i) == inf - pi/2*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf + inf i) == inf + pi/4*log10(e) i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf - inf i) == inf - pi/4*log10(e) i":
+float: 1
+ifloat: 1
+
+# cos
+Test "cos (0.7) == 0.7648421872844884262":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "cos (M_PI_6l * 2.0) == 0.5":
+double: 1
+float: 0.5
+idouble: 1
+ifloat: 0.5
+Test "cos (M_PI_6l * 4.0) == -0.5":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "cos (pi/2) == 0":
+double: 0.2758
+float: 0.3667
+idouble: 0.2758
+ifloat: 0.3667
+
+# cpow
+Test "Real part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i":
+double: 1.1031
+float: 1.5
+idouble: 1.1031
+ifloat: 1.5
+
+# csin
+Test "Imaginary part of: csin (0.7 + 1.2 i) == 1.1664563419657581376 + 1.1544997246948547371 i":
+float: 1
+ifloat: 1
+
+# csinh
+Test "Imaginary part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+double: 1
+idouble: 1
+Test "Real part of: csinh (0.7 + 1.2 i) == 0.27487868678117583582 + 1.1698665727426565139 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csinh (0.7 + 1.2 i) == 0.27487868678117583582 + 1.1698665727426565139 i":
+float: 1
+ifloat: 1
+
+# csqrt
+Test "Real part of: csqrt (-2 + 3 i) == 0.89597747612983812471573375529004348 + 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+Test "Real part of: csqrt (-2 - 3 i) == 0.89597747612983812471573375529004348 - 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+Test "Real part of: csqrt (0.7 + 1.2 i) == 1.022067610030026450706487883081139 + 0.58704531296356521154977678719838035 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: csqrt (0.7 + 1.2 i) == 1.022067610030026450706487883081139 + 0.58704531296356521154977678719838035 i":
+float: 1
+ifloat: 1
+
+# ctan
+Test "Real part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+double: 1
+idouble: 1
+Test "Real part of: ctan (0.7 + 1.2 i) == 0.1720734197630349001 + 0.9544807059989405538 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ctan (0.7 + 1.2 i) == 0.1720734197630349001 + 0.9544807059989405538 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# ctanh
+Test "Real part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "Imaginary part of: ctanh (0 + pi/4 i) == 0.0 + 1.0 i":
+float: 1
+ifloat: 1
+Test "Real part of: ctanh (0.7 + 1.2 i) == 1.3472197399061191630 + 0.4778641038326365540 i":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "Imaginary part of: ctanh (0.7 + 1.2 i) == 1.3472197399061191630 + 0.4778641038326365540 i":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+# erfc
+Test "erfc (0.7) == 0.32219880616258152702":
+double: 1
+idouble: 1
+Test "erfc (1.2) == 0.089686021770364619762":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+Test "erfc (2.0) == 0.0046777349810472658379":
+double: 1
+idouble: 1
+Test "erfc (4.1) == 0.67000276540848983727e-8":
+double: 24
+float: 12
+idouble: 24
+ifloat: 12
+
+# exp10
+Test "exp10 (-1) == 0.1":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "exp10 (0.7) == 5.0118723362727228500":
+float: 1
+ifloat: 1
+Test "exp10 (3) == 1000":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+
+# expm1
+Test "expm1 (1) == M_El - 1.0":
+float: 1
+ifloat: 1
+
+# fmod
+Test "fmod (-6.5, -2.3) == -1.9":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "fmod (-6.5, 2.3) == -1.9":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "fmod (6.5, -2.3) == 1.9":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "fmod (6.5, 2.3) == 1.9":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+# hypot
+Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, 1.2) == 1.3892443989449804508432547041028554":
+double: 1
+idouble: 1
+Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+
+# j0
+Test "j0 (10.0) == -0.24593576445134833520":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "j0 (2.0) == 0.22389077914123566805":
+float: 2
+ifloat: 2
+Test "j0 (8.0) == 0.17165080713755390609":
+float: 1
+ifloat: 1
+
+# j1
+Test "j1 (10.0) == 0.043472746168861436670":
+float: 2
+ifloat: 2
+Test "j1 (2.0) == 0.57672480775687338720":
+double: 1
+idouble: 1
+Test "j1 (8.0) == 0.23463634685391462438":
+double: 1
+idouble: 1
+
+# jn
+Test "jn (0, 10.0) == -0.24593576445134833520":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "jn (0, 2.0) == 0.22389077914123566805":
+float: 2
+ifloat: 2
+Test "jn (0, 8.0) == 0.17165080713755390609":
+float: 1
+ifloat: 1
+Test "jn (1, 10.0) == 0.043472746168861436670":
+float: 2
+ifloat: 2
+Test "jn (1, 2.0) == 0.57672480775687338720":
+double: 1
+idouble: 1
+Test "jn (1, 8.0) == 0.23463634685391462438":
+double: 1
+idouble: 1
+Test "jn (10, 0.1) == 0.26905328954342155795e-19":
+double: 6
+float: 4
+idouble: 6
+ifloat: 4
+Test "jn (10, 0.7) == 0.75175911502153953928e-11":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "jn (10, 10.0) == 0.20748610663335885770":
+double: 4
+float: 3
+idouble: 4
+ifloat: 3
+Test "jn (10, 2.0) == 0.25153862827167367096e-6":
+float: 4
+ifloat: 4
+Test "jn (3, 0.1) == 0.000020820315754756261429":
+double: 1
+idouble: 1
+Test "jn (3, 0.7) == 0.0069296548267508408077":
+float: 1
+ifloat: 1
+Test "jn (3, 10.0) == 0.058379379305186812343":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "jn (3, 2.0) == 0.12894324947440205110":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# lgamma
+Test "lgamma (0.7) == 0.260867246531666514385732417016759578":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# log
+Test "log (0.7) == -0.35667494393873237891263871124118447":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# log10
+Test "log10 (0.7) == -0.15490195998574316929":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "log10 (e) == log10(e)":
+float: 1
+ifloat: 1
+
+# log1p
+Test "log1p (-0.3) == -0.35667494393873237891263871124118447":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# log2
+Test "log2 (0.7) == -0.51457317282975824043":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# sincos
+Test "sincos (0.7, &sin_res, &cos_res) puts 0.76484218728448842626 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res":
+double: 1
+float: 0.5
+idouble: 1
+ifloat: 0.5
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.866025403784438646764 in sin_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (pi/2, &sin_res, &cos_res) puts 0 in cos_res":
+double: 0.2758
+float: 0.3667
+idouble: 0.2758
+ifloat: 0.3667
+Test "sincos (pi/6, &sin_res, &cos_res) puts 0.866025403784438646764 in cos_res":
+float: 1
+ifloat: 1
+
+# sinh
+Test "sinh (0.7) == 0.75858370183953350346":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# tan
+Test "tan (pi/4) == 1":
+double: 0.5
+idouble: 0.5
+
+# tanh
+Test "tanh (0.7) == 0.60436777711716349631":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# tgamma
+Test "tgamma (-0.5) == -2 sqrt (pi)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (0.5) == sqrt (pi)":
+float: 1
+ifloat: 1
+Test "tgamma (0.7) == 1.29805533264755778568117117915281162":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# y0
+Test "y0 (0.7) == -0.19066492933739506743":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (1.0) == 0.088256964215676957983":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (1.5) == 0.38244892379775884396":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (10.0) == 0.055671167283599391424":
+float: 1
+ifloat: 1
+Test "y0 (8.0) == 0.22352148938756622053":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# y1
+Test "y1 (0.1) == -6.4589510947020269877":
+double: 1
+idouble: 1
+Test "y1 (0.7) == -1.1032498719076333697":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "y1 (1.5) == -0.41230862697391129595":
+float: 1
+ifloat: 1
+Test "y1 (10.0) == 0.24901542420695388392":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "y1 (2.0) == -0.10703243154093754689":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "y1 (8.0) == -0.15806046173124749426":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# yn
+Test "yn (0, 0.7) == -0.19066492933739506743":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 1.0) == 0.088256964215676957983":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 1.5) == 0.38244892379775884396":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 10.0) == 0.055671167283599391424":
+float: 1
+ifloat: 1
+Test "yn (0, 8.0) == 0.22352148938756622053":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (1, 0.1) == -6.4589510947020269877":
+double: 1
+idouble: 1
+Test "yn (1, 0.7) == -1.1032498719076333697":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (1, 1.5) == -0.41230862697391129595":
+float: 1
+ifloat: 1
+Test "yn (1, 10.0) == 0.24901542420695388392":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "yn (1, 2.0) == -0.10703243154093754689":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (1, 8.0) == -0.15806046173124749426":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "yn (10, 0.1) == -0.11831335132045197885e19":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+Test "yn (10, 0.7) == -0.42447194260703866924e10":
+double: 3
+idouble: 3
+Test "yn (10, 1.0) == -0.12161801427868918929e9":
+double: 1
+idouble: 1
+Test "yn (10, 10.0) == -0.35981415218340272205":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (10, 2.0) == -129184.54220803928264":
+double: 2
+idouble: 2
+Test "yn (3, 0.1) == -5099.3323786129048894":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 0.7) == -15.819479052819633505":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "yn (3, 10.0) == -0.25136265718383732978":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 2.0) == -1.1277837768404277861":
+double: 1
+idouble: 1
+
+# Maximal error of functions:
+Function: "asin":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "atan2":
+float: 4
+ifloat: 4
+
+Function: "atanh":
+double: 1
+idouble: 1
+
+Function: "cabs":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "cacos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "cacos":
+float: 1
+ifloat: 1
+
+Function: Real part of "cacosh":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+
+Function: Imaginary part of "cacosh":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+
+Function: Real part of "casin":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+
+Function: Imaginary part of "casin":
+float: 1
+ifloat: 1
+
+Function: Real part of "casinh":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+
+Function: Imaginary part of "casinh":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+
+Function: Real part of "catan":
+float: 4
+ifloat: 4
+
+Function: Imaginary part of "catan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "catanh":
+double: 4
+float: 1
+idouble: 4
+ifloat: 1
+
+Function: Imaginary part of "catanh":
+double: 1
+float: 6
+idouble: 1
+ifloat: 6
+
+Function: "cbrt":
+double: 1
+idouble: 1
+
+Function: Real part of "ccos":
+double: 1
+idouble: 1
+
+Function: Imaginary part of "ccos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "cexp":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "cexp":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "clog":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+
+Function: Real part of "clog10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "clog10":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+
+Function: "cos":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: Real part of "cpow":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+
+Function: Imaginary part of "cpow":
+double: 1.1031
+float: 2
+idouble: 1.1031
+ifloat: 2
+
+Function: Imaginary part of "csin":
+float: 1
+ifloat: 1
+
+Function: Real part of "csinh":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "csqrt":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "csqrt":
+float: 1
+ifloat: 1
+
+Function: Real part of "ctan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ctan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "ctanh":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: Imaginary part of "ctanh":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: "erfc":
+double: 24
+float: 12
+idouble: 24
+ifloat: 12
+
+Function: "exp10":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+
+Function: "expm1":
+float: 1
+ifloat: 1
+
+Function: "fmod":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: "hypot":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "j0":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: "j1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "jn":
+double: 6
+float: 4
+idouble: 6
+ifloat: 4
+
+Function: "lgamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "log":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "log10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "log1p":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "log2":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "sincos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "sinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "tan":
+double: 0.5
+idouble: 0.5
+
+Function: "tanh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "tgamma":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "y0":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: "y1":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+
+Function: "yn":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+
+# end of automatic generation
diff --git a/test/math/libm-test-ulps-sparc b/test/math/libm-test-ulps-sparc
new file mode 100644
index 000000000..6a447a1e5
--- /dev/null
+++ b/test/math/libm-test-ulps-sparc
@@ -0,0 +1,1338 @@
+# Begin of automatic generation
+
+# atan2
+Test "atan2 (-0.00756827042671106339, -.001792735857538728036) == -1.80338464113663849327153994379639112":
+float: 6
+ifloat: 6
+ildouble: 1
+ldouble: 1
+Test "atan2 (-0.75, -1.0) == -2.49809154479650885165983415456218025":
+float: 3
+ifloat: 3
+ildouble: 1
+ldouble: 1
+Test "atan2 (0.75, -1.0) == 2.49809154479650885165983415456218025":
+float: 3
+ifloat: 3
+ildouble: 1
+ldouble: 1
+Test "atan2 (1.390625, 0.9296875) == 0.981498387184244311516296577615519772":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# atanh
+Test "atanh (0.75) == 0.972955074527656652552676371721589865":
+float: 1
+ifloat: 1
+
+# cacos
+Test "Imaginary part of: cacos (0.75 + 1.25 i) == 1.11752014915610270578240049553777969 - 1.13239363160530819522266333696834467 i":
+ildouble: 1
+ldouble: 1
+
+# cacosh
+Test "Real part of: cacosh (-2 - 3 i) == 1.9833870299165354323470769028940395 - 2.1414491111159960199416055713254211 i":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+ildouble: 5
+ldouble: 5
+Test "Imaginary part of: cacosh (-2 - 3 i) == 1.9833870299165354323470769028940395 - 2.1414491111159960199416055713254211 i":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+ildouble: 1
+ldouble: 1
+
+# casin
+Test "Real part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+ildouble: 1
+ldouble: 1
+
+# casinh
+Test "Real part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+ildouble: 4
+ldouble: 4
+Test "Imaginary part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+ildouble: 2
+ldouble: 2
+Test "Real part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# catan
+Test "Real part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+float: 3
+ifloat: 3
+Test "Imaginary part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: catan (0.75 + 1.25 i) == 1.10714871779409050301706546017853704 + 0.549306144334054845697622618461262852 i":
+float: 4
+ifloat: 4
+Test "Imaginary part of: catan (0.75 + 1.25 i) == 1.10714871779409050301706546017853704 + 0.549306144334054845697622618461262852 i":
+ildouble: 1
+ldouble: 1
+
+# catanh
+Test "Real part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+double: 4
+idouble: 4
+Test "Imaginary part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+float: 4
+ifloat: 4
+Test "Real part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+float: 6
+ifloat: 6
+ildouble: 1
+ldouble: 1
+
+# cbrt
+Test "cbrt (-0.001) == -0.1":
+ildouble: 1
+ldouble: 1
+Test "cbrt (-27.0) == -3.0":
+double: 1
+idouble: 1
+Test "cbrt (0.75) == 0.908560296416069829445605878163630251":
+double: 1
+idouble: 1
+Test "cbrt (0.9921875) == 0.997389022060725270579075195353955217":
+double: 1
+idouble: 1
+
+# ccos
+Test "Real part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+float: 1
+ifloat: 1
+
+# ccosh
+Test "Real part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+float: 1
+ifloat: 1
+
+# cexp
+Test "Real part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+ildouble: 1
+ldouble: 1
+
+# clog
+Test "Imaginary part of: clog (-2 - 3 i) == 1.2824746787307683680267437207826593 - 2.1587989303424641704769327722648368 i":
+float: 3
+ifloat: 3
+Test "Real part of: clog (0.75 + 1.25 i) == 0.376885901188190075998919126749298416 + 1.03037682652431246378774332703115153 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# clog10
+Test "Imaginary part of: clog10 (-0 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-0 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (-3 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-3 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 0 i) == inf + pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 1 i) == inf + pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + inf i) == inf + 3/4 pi*log10(e) i":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-inf - 0 i) == inf - pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 1 i) == inf - pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (3 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf + inf i) == inf + pi/4*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf - inf i) == inf - pi/4*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# cos
+Test "cos (M_PI_6l * 2.0) == 0.5":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "cos (M_PI_6l * 4.0) == -0.5":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "cos (pi/2) == 0":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# cpow
+Test "Real part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+ildouble: 4
+ldouble: 4
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 0.0 i) == 0.75 + 1.25 i":
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 1.0 + 0.0 i) == 0.75 + 1.25 i":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i) == 0.0846958290317209430433805274189191353 + 0.513285749182902449043287190519090481 i":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+ildouble: 1
+ldouble: 1
+Test "Real part of: cpow (2 + 0 i, 10 + 0 i) == 1024.0 + 0.0 i":
+ildouble: 2
+ldouble: 2
+Test "Real part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+ildouble: 3
+ldouble: 3
+Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+float: 2
+ifloat: 2
+Test "Imaginary part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# csin
+Test "Imaginary part of: csin (-2 - 3 i) == -9.15449914691142957346729954460983256 + 4.16890695996656435075481305885375484 i":
+ildouble: 1
+ldouble: 1
+Test "Real part of: csin (0.75 + 1.25 i) == 1.28722291002649188575873510790565441 + 1.17210635989270256101081285116138863 i":
+ildouble: 1
+ldouble: 1
+
+# csinh
+Test "Real part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+double: 1
+idouble: 1
+Test "Real part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+
+# csqrt
+Test "Real part of: csqrt (-2 + 3 i) == 0.89597747612983812471573375529004348 + 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: csqrt (-2 - 3 i) == 0.89597747612983812471573375529004348 - 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csqrt (0.75 + 1.25 i) == 1.05065169626078392338656675760808326 + 0.594868882070379067881984030639932657 i":
+ildouble: 1
+ldouble: 1
+
+# ctan
+Test "Real part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+
+# ctanh
+Test "Real part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctanh (0 + pi/4 i) == 0.0 + 1.0 i":
+float: 1
+ifloat: 1
+Test "Real part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i":
+double: 1
+idouble: 1
+
+# erf
+Test "erf (0.75) == 0.711155633653515131598937834591410777":
+double: 1
+idouble: 1
+Test "erf (1.25) == 0.922900128256458230136523481197281140":
+double: 1
+idouble: 1
+
+# erfc
+Test "erfc (2.0) == 0.00467773498104726583793074363274707139":
+double: 1
+idouble: 1
+Test "erfc (27.0) == 0.523704892378925568501606768284954709e-318":
+ildouble: 1
+ldouble: 1
+Test "erfc (4.125) == 0.542340079956506600531223408575531062e-8":
+double: 1
+idouble: 1
+
+# exp
+Test "exp (1) == e":
+double: 1
+idouble: 1
+
+# exp10
+Test "exp10 (-1) == 0.1":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "exp10 (0.75) == 5.62341325190349080394951039776481231":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "exp10 (3) == 1000":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# exp2
+Test "exp2 (10) == 1024":
+ildouble: 2
+ldouble: 2
+
+# expm1
+Test "expm1 (0.75) == 1.11700001661267466854536981983709561":
+double: 1
+idouble: 1
+Test "expm1 (1) == M_El - 1.0":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# gamma
+Test "gamma (-0.5) == log(2*sqrt(pi))":
+ildouble: 1
+ldouble: 1
+
+# hypot
+Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+
+# j0
+Test "j0 (-4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "j0 (10.0) == -0.245935764451348335197760862485328754":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "j0 (2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "j0 (4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "j0 (8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# j1
+Test "j1 (-1.0) == -0.440050585744933515959682203718914913":
+ildouble: 1
+ldouble: 1
+Test "j1 (0.75) == 0.349243602174862192523281016426251335":
+ildouble: 1
+ldouble: 1
+Test "j1 (1.0) == 0.440050585744933515959682203718914913":
+ildouble: 1
+ldouble: 1
+Test "j1 (10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "j1 (2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "j1 (8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+ildouble: 4
+ldouble: 4
+
+# jn
+Test "jn (0, -4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "jn (0, 10.0) == -0.245935764451348335197760862485328754":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "jn (0, 2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "jn (0, 4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (0, 8.0) == 0.171650807137553906090869407851972001":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (1, -1.0) == -0.440050585744933515959682203718914913":
+ildouble: 1
+ldouble: 1
+Test "jn (1, 0.75) == 0.349243602174862192523281016426251335":
+ildouble: 1
+ldouble: 1
+Test "jn (1, 1.0) == 0.440050585744933515959682203718914913":
+ildouble: 1
+ldouble: 1
+Test "jn (1, 10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "jn (1, 2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "jn (1, 8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+ildouble: 4
+ldouble: 4
+Test "jn (10, -1.0) == 0.263061512368745320699785368779050294e-9":
+ildouble: 1
+ldouble: 1
+Test "jn (10, 0.125) == 0.250543369809369890173993791865771547e-18":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (10, 0.75) == 0.149621713117596814698712483621682835e-10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (10, 1.0) == 0.263061512368745320699785368779050294e-9":
+ildouble: 1
+ldouble: 1
+Test "jn (10, 10.0) == 0.207486106633358857697278723518753428":
+double: 4
+float: 3
+idouble: 4
+ifloat: 3
+ildouble: 2
+ldouble: 2
+Test "jn (10, 2.0) == 0.251538628271673670963516093751820639e-6":
+float: 4
+ifloat: 4
+Test "jn (3, 0.125) == 0.406503832554912875023029337653442868e-4":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 0.75) == 0.848438342327410884392755236884386804e-2":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 10.0) == 0.0583793793051868123429354784103409563":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "jn (3, 2.0) == 0.128943249474402051098793332969239835":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# lgamma
+Test "lgamma (-0.5) == log(2*sqrt(pi))":
+ildouble: 1
+ldouble: 1
+Test "lgamma (0.7) == 0.260867246531666514385732417016759578":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# log10
+Test "log10 (0.75) == -0.124938736608299953132449886193870744":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+Test "log10 (e) == log10(e)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# log1p
+Test "log1p (-0.25) == -0.287682072451780927439219005993827432":
+float: 1
+ifloat: 1
+Test "log1p (M_El - 1.0) == 1":
+ildouble: 1
+ldouble: 1
+
+# log2
+Test "log2 (0.75) == -.415037499278843818546261056052183492":
+ildouble: 1
+ldouble: 1
+
+# sincos
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in sin_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "sincos (pi/2, &sin_res, &cos_res) puts 0 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "sincos (pi/6, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in cos_res":
+float: 1
+ifloat: 1
+
+# sqrt
+Test "sqrt (2) == M_SQRT2l":
+ildouble: 1
+ldouble: 1
+
+# tan
+Test "tan (pi/4) == 1":
+double: 1
+idouble: 1
+
+# tanh
+Test "tanh (-0.75) == -0.635148952387287319214434357312496495":
+ildouble: 1
+ldouble: 1
+Test "tanh (-1.0) == -0.7615941559557648881194582826047935904":
+ildouble: 1
+ldouble: 1
+Test "tanh (0.75) == 0.635148952387287319214434357312496495":
+ildouble: 1
+ldouble: 1
+Test "tanh (1.0) == 0.7615941559557648881194582826047935904":
+ildouble: 1
+ldouble: 1
+
+# tgamma
+Test "tgamma (-0.5) == -2 sqrt (pi)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (0.5) == sqrt (pi)":
+float: 1
+ifloat: 1
+Test "tgamma (0.7) == 1.29805533264755778568117117915281162":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (4) == 6":
+ildouble: 1
+ldouble: 1
+
+# y0
+Test "y0 (1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (10.0) == 0.0556711672835993914244598774101900481":
+float: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+Test "y0 (8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+
+# y1
+Test "y1 (0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+Test "y1 (0.75) == -1.03759455076928541973767132140642198":
+ildouble: 1
+ldouble: 1
+Test "y1 (1.5) == -0.412308626973911295952829820633445323":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "y1 (10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "y1 (2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "y1 (8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# yn
+Test "yn (0, 1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 10.0) == 0.0556711672835993914244598774101900481":
+float: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+Test "yn (0, 8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+Test "yn (1, 0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+Test "yn (1, 0.75) == -1.03759455076928541973767132140642198":
+ildouble: 1
+ldouble: 1
+Test "yn (1, 1.5) == -0.412308626973911295952829820633445323":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (1, 10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "yn (1, 2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (1, 8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "yn (10, 0.125) == -127057845771019398.252538486899753195":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+Test "yn (10, 0.75) == -2133501638.90573424452445412893839236":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 5
+ldouble: 5
+Test "yn (10, 1.0) == -121618014.278689189288130426667971145":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "yn (10, 10.0) == -0.359814152183402722051986577343560609":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "yn (10, 2.0) == -129184.542208039282635913145923304214":
+double: 2
+idouble: 2
+ildouble: 2
+ldouble: 2
+Test "yn (3, 0.125) == -2612.69757350066712600220955744091741":
+double: 1
+idouble: 1
+Test "yn (3, 0.75) == -12.9877176234475433186319774484809207":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "yn (3, 10.0) == -0.251362657183837329779204747654240998":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (3, 2.0) == -1.12778377684042778608158395773179238":
+double: 1
+idouble: 1
+
+# Maximal error of functions:
+Function: "atan2":
+float: 6
+ifloat: 6
+ildouble: 1
+ldouble: 1
+
+Function: "atanh":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "cacos":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "cacosh":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+ildouble: 5
+ldouble: 5
+
+Function: Imaginary part of "cacosh":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "casin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "casin":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "casinh":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+ildouble: 4
+ldouble: 4
+
+Function: Imaginary part of "casinh":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "catan":
+float: 4
+ifloat: 4
+
+Function: Imaginary part of "catan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "catanh":
+double: 4
+idouble: 4
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "catanh":
+float: 6
+ifloat: 6
+ildouble: 1
+ldouble: 1
+
+Function: "cbrt":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ccos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ccos":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ccosh":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "cexp":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "cexp":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "clog":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "clog":
+float: 3
+ifloat: 3
+
+Function: Real part of "clog10":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "clog10":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+ildouble: 1
+ldouble: 1
+
+Function: "cos":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "cpow":
+double: 2
+float: 4
+idouble: 2
+ifloat: 4
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "cpow":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "csin":
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csin":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "csinh":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "csqrt":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csqrt":
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ctan":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ctan":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "ctanh":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ctanh":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "erf":
+double: 1
+idouble: 1
+
+Function: "erfc":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: "exp":
+double: 1
+idouble: 1
+
+Function: "exp10":
+double: 6
+float: 2
+idouble: 6
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "exp2":
+ildouble: 2
+ldouble: 2
+
+Function: "expm1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "gamma":
+ildouble: 1
+ldouble: 1
+
+Function: "hypot":
+float: 1
+ifloat: 1
+
+Function: "j0":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+
+Function: "j1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 4
+ldouble: 4
+
+Function: "jn":
+double: 4
+float: 4
+idouble: 4
+ifloat: 4
+ildouble: 4
+ldouble: 4
+
+Function: "lgamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "log":
+float: 1
+ifloat: 1
+
+Function: "log10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "log1p":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "log2":
+ildouble: 1
+ldouble: 1
+
+Function: "sincos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "sqrt":
+ildouble: 1
+ldouble: 1
+
+Function: "tan":
+double: 1
+idouble: 1
+
+Function: "tanh":
+ildouble: 1
+ldouble: 1
+
+Function: "tgamma":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "y0":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 3
+ldouble: 3
+
+Function: "y1":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "yn":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+ildouble: 5
+ldouble: 5
+
+# end of automatic generation
diff --git a/test/math/libm-test-ulps-x86_64 b/test/math/libm-test-ulps-x86_64
new file mode 100644
index 000000000..0ced4be7b
--- /dev/null
+++ b/test/math/libm-test-ulps-x86_64
@@ -0,0 +1,1308 @@
+# Begin of automatic generation
+
+# acos
+Test "acos (0.75) == 0.722734247813415611178377352641333362":
+ildouble: 1
+ldouble: 1
+
+# asin
+Test "asin (-0.5) == -pi/6":
+ildouble: 1
+ldouble: 1
+Test "asin (-1.0) == -pi/2":
+ildouble: 1
+ldouble: 1
+Test "asin (0.5) == pi/6":
+ildouble: 1
+ldouble: 1
+Test "asin (0.75) == 0.848062078981481008052944338998418080":
+ildouble: 1
+ldouble: 1
+Test "asin (1.0) == pi/2":
+ildouble: 1
+ldouble: 1
+
+# atan2
+Test "atan2 (-0.75, -1.0) == -2.49809154479650885165983415456218025":
+float: 1
+ifloat: 1
+Test "atan2 (0.75, -1.0) == 2.49809154479650885165983415456218025":
+float: 1
+ifloat: 1
+Test "atan2 (1.390625, 0.9296875) == 0.981498387184244311516296577615519772":
+float: 1
+ifloat: 1
+
+# atanh
+Test "atanh (0.75) == 0.972955074527656652552676371721589865":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# cacos
+Test "Imaginary part of: cacos (0.75 + 1.25 i) == 1.11752014915610270578240049553777969 - 1.13239363160530819522266333696834467 i":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+# cacosh
+Test "Real part of: cacosh (-2 - 3 i) == 1.9833870299165354323470769028940395 - 2.1414491111159960199416055713254211 i":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+ildouble: 6
+ldouble: 6
+Test "Imaginary part of: cacosh (-2 - 3 i) == 1.9833870299165354323470769028940395 - 2.1414491111159960199416055713254211 i":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+ildouble: 1
+ldouble: 1
+Test "Real part of: cacosh (0.75 + 1.25 i) == 1.13239363160530819522266333696834467 + 1.11752014915610270578240049553777969 i":
+ildouble: 1
+ldouble: 1
+
+# casin
+Test "Real part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: casin (0.75 + 1.25 i) == 0.453276177638793913448921196101971749 + 1.13239363160530819522266333696834467 i":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+# casinh
+Test "Real part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+ildouble: 5
+ldouble: 5
+Test "Imaginary part of: casinh (-2 - 3 i) == -1.9686379257930962917886650952454982 - 0.96465850440760279204541105949953237 i":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+ildouble: 5
+ldouble: 5
+Test "Real part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: casinh (0.75 + 1.25 i) == 1.03171853444778027336364058631006594 + 0.911738290968487636358489564316731207 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ldouble: 1
+ildouble: 1
+
+# catan
+Test "Real part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+float: 3
+ifloat: 3
+Test "Imaginary part of: catan (-2 - 3 i) == -1.4099210495965755225306193844604208 - 0.22907268296853876629588180294200276 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: catan (0.75 + 1.25 i) == 1.10714871779409050301706546017853704 + 0.549306144334054845697622618461262852 i":
+float: 4
+ifloat: 4
+
+# catanh
+Test "Real part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+double: 4
+idouble: 4
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: catanh (-2 - 3 i) == -0.14694666622552975204743278515471595 - 1.3389725222944935611241935759091443 i":
+float: 4
+ifloat: 4
+Test "Real part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: catanh (0.75 + 1.25 i) == 0.261492138795671927078652057366532140 + 0.996825126463918666098902241310446708 i":
+float: 6
+ifloat: 6
+
+# cbrt
+Test "cbrt (-0.001) == -0.1":
+ildouble: 1
+ldouble: 1
+Test "cbrt (-27.0) == -3.0":
+double: 1
+idouble: 1
+Test "cbrt (0.75) == 0.908560296416069829445605878163630251":
+double: 1
+idouble: 1
+Test "cbrt (0.9921875) == 0.997389022060725270579075195353955217":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+# ccos
+Test "Real part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: ccos (-2 - 3 i) == -4.18962569096880723013255501961597373 - 9.10922789375533659797919726277886212 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ccos (0.75 + 1.25 i) == 1.38173873063425888530729933139078645 - 1.09193013555397466170919531722024128 i":
+ildouble: 1
+ldouble: 1
+float: 1
+ifloat: 1
+
+# ccosh
+Test "Real part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (-2 - 3 i) == -3.72454550491532256547397070325597253 + 0.511822569987384608834463849801875634 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: ccosh (0.75 + 1.25 i) == 0.408242591877968807788852146397499084 + 0.780365930845853240391326216300863152 i":
+float: 1
+ifloat: 1
+
+# cexp
+Test "Imaginary part of: cexp (-2.0 - 3.0 i) == -0.13398091492954261346140525546115575 - 0.019098516261135196432576240858800925 i":
+float: 1
+ifloat: 1
+Test "Real part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: cexp (0.75 + 1.25 i) == 0.667537446429131586942201977015932112 + 2.00900045494094876258347228145863909 i":
+ildouble: 1
+ldouble: 1
+
+# clog
+Test "Imaginary part of: clog (-2 - 3 i) == 1.2824746787307683680267437207826593 - 2.1587989303424641704769327722648368 i":
+float: 3
+ifloat: 3
+Test "Real part of: clog (0.75 + 1.25 i) == 0.376885901188190075998919126749298416 + 1.03037682652431246378774332703115153 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# clog10
+Test "Imaginary part of: clog10 (-0 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-0 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (-3 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-3 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 0 i) == inf + pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + 1 i) == inf + pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf + inf i) == inf + 3/4 pi*log10(e) i":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (-inf - 0 i) == inf - pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (-inf - 1 i) == inf - pi*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Real part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (3 + inf i) == inf + pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (3 - inf i) == inf - pi/2*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf + inf i) == inf + pi/4*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (inf - inf i) == inf - pi/4*log10(e) i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# cos
+Test "cos (M_PI_6l * 2.0) == 0.5":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "cos (M_PI_6l * 4.0) == -0.5":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "cos (pi/2) == 0":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "cos (0.80190127184058835) == 0.69534156199418473":
+double: 1
+idouble: 1
+
+# cpow
+Test "Real part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+ldouble: 1
+ildouble: 1
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.0 + 1.0 i) == 0.331825439177608832276067945276730566 + 0.131338600281188544930936345230903032 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i":
+double: 1
+float: 4
+idouble: 1
+ifloat: 4
+ildouble: 5
+ldouble: 5
+Test "Imaginary part of: cpow (0.75 + 1.25 i, 0.75 + 1.25 i) == 0.117506293914473555420279832210420483 + 0.346552747708338676483025352060418001 i":
+ildouble: 2
+ldouble: 2
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 0.0 i) == 0.75 + 1.25 i":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cpow (0.75 + 1.25 i, 1.0 + 1.0 i) == 0.0846958290317209430433805274189191353 + 0.513285749182902449043287190519090481 i":
+double: 2
+float: 3
+idouble: 2
+ifloat: 3
+ildouble: 3
+ldouble: 3
+Test "Real part of: cpow (2 + 0 i, 10 + 0 i) == 1024.0 + 0.0 i":
+ildouble: 1
+ldouble: 1
+Test "Real part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+Test "Imaginary part of: cpow (2 + 3 i, 4 + 0 i) == -119.0 - 120.0 i":
+float: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+Test "Imaginary part of: cpow (e + 0 i, 0 + 2 * M_PIl i) == 1.0 + 0.0 i":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# csin
+Test "Real part of: csin (0.75 + 1.25 i) == 1.28722291002649188575873510790565441 + 1.17210635989270256101081285116138863 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csin (0.75 + 1.25 i) == 1.28722291002649188575873510790565441 + 1.17210635989270256101081285116138863 i":
+float: 1
+ifloat: 1
+Test "Imaginary part of: csin (-2 - 3 i) == -9.15449914691142957346729954460983256 + 4.16890695996656435075481305885375484 i":
+double: 1
+idouble: 1
+
+# csinh
+Test "Real part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: csinh (-2 - 3 i) == 3.59056458998577995201256544779481679 - 0.530921086248519805267040090660676560 i":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+Test "Real part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: csinh (0.75 + 1.25 i) == 0.259294854551162779153349830618433028 + 1.22863452409509552219214606515777594 i":
+float: 1
+ifloat: 1
+
+# csqrt
+Test "Real part of: csqrt (-2 + 3 i) == 0.89597747612983812471573375529004348 + 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+Test "Real part of: csqrt (-2 - 3 i) == 0.89597747612983812471573375529004348 - 1.6741492280355400404480393008490519 i":
+float: 1
+ifloat: 1
+
+# ctan
+Test "Real part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+double: 1
+idouble: 1
+ildouble: 439
+ldouble: 439
+Test "Imaginary part of: ctan (-2 - 3 i) == 0.376402564150424829275122113032269084e-2 - 1.00323862735360980144635859782192726 i":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "Real part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: ctan (0.75 + 1.25 i) == 0.160807785916206426725166058173438663 + 0.975363285031235646193581759755216379 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+
+# ctanh
+Test "Real part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+float: 2
+ifloat: 2
+ildouble: 5
+ldouble: 5
+double: 1
+idouble: 1
+Test "Imaginary part of: ctanh (-2 - 3 i) == -0.965385879022133124278480269394560686 + 0.988437503832249372031403430350121098e-2 i":
+ildouble: 25
+ldouble: 25
+Test "Imaginary part of: ctanh (0 + pi/4 i) == 0.0 + 1.0 i":
+float: 1
+ifloat: 1
+Test "Real part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: ctanh (0.75 + 1.25 i) == 1.37260757053378320258048606571226857 + 0.385795952609750664177596760720790220 i":
+ildouble: 1
+ldouble: 1
+double: 1
+idouble: 1
+
+# erf
+Test "erf (1.25) == 0.922900128256458230136523481197281140":
+double: 1
+idouble: 1
+
+# erfc
+Test "erfc (1.25) == 0.0770998717435417698634765188027188596":
+ildouble: 1
+ldouble: 1
+Test "erfc (2.0) == 0.00467773498104726583793074363274707139":
+double: 1
+idouble: 1
+Test "erfc (4.125) == 0.542340079956506600531223408575531062e-8":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+# exp10
+Test "exp10 (-1) == 0.1":
+ildouble: 1
+ldouble: 1
+float: 1
+ifloat: 1
+double: 2
+idouble: 2
+Test "exp10 (0.75) == 5.62341325190349080394951039776481231":
+ildouble: 2
+ldouble: 2
+float: 1
+ifloat: 1
+double: 1
+idouble: 1
+Test "exp10 (3) == 1000":
+ildouble: 8
+ldouble: 8
+float: 2
+ifloat: 2
+double: 6
+idouble: 6
+
+# expm1
+Test "expm1 (0.75) == 1.11700001661267466854536981983709561":
+double: 1
+idouble: 1
+Test "expm1 (1) == M_El - 1.0":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# gamma
+Test "gamma (-0.5) == log(2*sqrt(pi))":
+ildouble: 1
+ldouble: 1
+
+# hypot
+Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+
+# j0
+Test "j0 (-4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "j0 (0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "j0 (10.0) == -0.245935764451348335197760862485328754":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "j0 (2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+Test "j0 (4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "j0 (8.0) == 0.171650807137553906090869407851972001":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+# j1
+Test "j1 (10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "j1 (2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "j1 (8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+# jn
+Test "jn (0, -4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (0, 0.75) == 0.864242275166648623555731103820923211":
+float: 1
+ifloat: 1
+Test "jn (0, 10.0) == -0.245935764451348335197760862485328754":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "jn (0, 2.0) == 0.223890779141235668051827454649948626":
+float: 2
+ifloat: 2
+Test "jn (0, 4.0) == -3.9714980986384737228659076845169804197562E-1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (0, 8.0) == 0.171650807137553906090869407851972001":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "jn (1, 10.0) == 0.0434727461688614366697487680258592883":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "jn (1, 2.0) == 0.576724807756873387202448242269137087":
+double: 1
+idouble: 1
+Test "jn (1, 8.0) == 0.234636346853914624381276651590454612":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "jn (10, -1.0) == 0.263061512368745320699785368779050294e-9":
+ildouble: 1
+ldouble: 1
+Test "jn (10, 0.125) == 0.250543369809369890173993791865771547e-18":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (10, 0.75) == 0.149621713117596814698712483621682835e-10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "jn (10, 1.0) == 0.263061512368745320699785368779050294e-9":
+ildouble: 1
+ldouble: 1
+Test "jn (10, 10.0) == 0.207486106633358857697278723518753428":
+double: 4
+float: 3
+idouble: 4
+ifloat: 3
+ildouble: 2
+ldouble: 2
+Test "jn (10, 2.0) == 0.251538628271673670963516093751820639e-6":
+float: 4
+ifloat: 4
+ildouble: 1
+ldouble: 1
+Test "jn (3, -1.0) == -0.0195633539826684059189053216217515083":
+ildouble: 1
+ldouble: 1
+Test "jn (3, 0.125) == 0.406503832554912875023029337653442868e-4":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 0.75) == 0.848438342327410884392755236884386804e-2":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "jn (3, 1.0) == 0.0195633539826684059189053216217515083":
+ildouble: 1
+ldouble: 1
+Test "jn (3, 10.0) == 0.0583793793051868123429354784103409563":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "jn (3, 2.0) == 0.128943249474402051098793332969239835":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# lgamma
+Test "lgamma (-0.5) == log(2*sqrt(pi))":
+ildouble: 1
+ldouble: 1
+Test "lgamma (0.7) == 0.260867246531666514385732417016759578":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# log10
+Test "log10 (0.75) == -0.124938736608299953132449886193870744":
+ildouble: 1
+ldouble: 1
+float: 2
+ifloat: 2
+double: 1
+idouble: 1
+Test "log10 (e) == log10(e)":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# log1p
+Test "log1p (-0.25) == -0.287682072451780927439219005993827432":
+float: 1
+ifloat: 1
+
+# sincos
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.5 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "sincos (M_PI_6l*2.0, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in sin_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "sincos (pi/2, &sin_res, &cos_res) puts 0 in cos_res":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "sincos (pi/6, &sin_res, &cos_res) puts 0.86602540378443864676372317075293616 in cos_res":
+float: 1
+ifloat: 1
+Test "sincos (0.80190127184058835, &sin_res, &cos_res) puts 0.69534156199418473 in cos_res":
+double: 1
+idouble: 1
+
+# tan
+Test "tan (pi/4) == 1":
+double: 1
+idouble: 1
+
+# tgamma
+Test "tgamma (-0.5) == -2 sqrt (pi)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "tgamma (0.5) == sqrt (pi)":
+float: 1
+ifloat: 1
+Test "tgamma (0.7) == 1.29805533264755778568117117915281162":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "tgamma (4) == 6":
+ildouble: 1
+ldouble: 1
+
+# y0
+Test "y0 (0.125) == -1.38968062514384052915582277745018693":
+ildouble: 1
+ldouble: 1
+Test "y0 (1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "y0 (1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "y0 (10.0) == 0.0556711672835993914244598774101900481":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "y0 (8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# y1
+Test "y1 (0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "y1 (1.5) == -0.412308626973911295952829820633445323":
+float: 1
+ifloat: 1
+Test "y1 (10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "y1 (2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "y1 (8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+# yn
+Test "yn (0, 0.125) == -1.38968062514384052915582277745018693":
+ildouble: 1
+ldouble: 1
+Test "yn (0, 1.0) == 0.0882569642156769579829267660235151628":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (0, 1.5) == 0.382448923797758843955068554978089862":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+Test "yn (0, 10.0) == 0.0556711672835993914244598774101900481":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (0, 8.0) == 0.223521489387566220527323400498620359":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (1, 0.125) == -5.19993611253477499595928744876579921":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "yn (1, 1.5) == -0.412308626973911295952829820633445323":
+float: 1
+ifloat: 1
+Test "yn (1, 10.0) == 0.249015424206953883923283474663222803":
+double: 3
+float: 1
+idouble: 3
+ifloat: 1
+Test "yn (1, 2.0) == -0.107032431540937546888370772277476637":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "yn (1, 8.0) == -0.158060461731247494255555266187483550":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+Test "yn (10, 0.125) == -127057845771019398.252538486899753195":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+Test "yn (10, 0.75) == -2133501638.90573424452445412893839236":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 4
+ldouble: 4
+Test "yn (10, 1.0) == -121618014.278689189288130426667971145":
+double: 1
+idouble: 1
+Test "yn (10, 10.0) == -0.359814152183402722051986577343560609":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (10, 2.0) == -129184.542208039282635913145923304214":
+double: 2
+idouble: 2
+Test "yn (3, 0.125) == -2612.69757350066712600220955744091741":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "yn (3, 0.75) == -12.9877176234475433186319774484809207":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+Test "yn (3, 10.0) == -0.251362657183837329779204747654240998":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "yn (3, 2.0) == -1.12778377684042778608158395773179238":
+double: 1
+idouble: 1
+
+# Maximal error of functions:
+Function: "acos":
+ildouble: 1
+ldouble: 1
+
+Function: "asin":
+ildouble: 1
+ldouble: 1
+
+Function: "atan2":
+float: 1
+ifloat: 1
+
+Function: "atanh":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "cacos":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "cacosh":
+double: 1
+float: 7
+idouble: 1
+ifloat: 7
+ildouble: 6
+ldouble: 6
+
+Function: Imaginary part of "cacosh":
+double: 1
+float: 3
+idouble: 1
+ifloat: 3
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "casin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Imaginary part of "casin":
+float: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "casinh":
+double: 5
+float: 1
+idouble: 5
+ifloat: 1
+ildouble: 5
+ldouble: 5
+
+Function: Imaginary part of "casinh":
+double: 3
+float: 6
+idouble: 3
+ifloat: 6
+ildouble: 5
+ldouble: 5
+
+Function: Real part of "catan":
+float: 4
+ifloat: 4
+
+Function: Imaginary part of "catan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "catanh":
+double: 4
+idouble: 4
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "catanh":
+float: 6
+ifloat: 6
+
+Function: "cbrt":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ccos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "ccos":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "ccosh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "cexp":
+float: 1
+ifloat: 1
+
+Function: Imaginary part of "cexp":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "clog":
+float: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "clog":
+float: 3
+ifloat: 3
+
+Function: Real part of "clog10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "clog10":
+double: 1
+float: 5
+idouble: 1
+ifloat: 5
+ildouble: 1
+ldouble: 1
+
+Function: "cos":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Real part of "cpow":
+double: 2
+float: 5
+idouble: 2
+ifloat: 5
+ildouble: 5
+ldouble: 5
+
+Function: Imaginary part of "cpow":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "csin":
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Real part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: Imaginary part of "csinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Real part of "csqrt":
+float: 1
+ifloat: 1
+
+Function: Real part of "ctan":
+double: 1
+idouble: 1
+ildouble: 439
+ldouble: 439
+
+Function: Imaginary part of "ctan":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 3
+ldouble: 3
+
+Function: Real part of "ctanh":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 5
+ldouble: 5
+
+Function: Imaginary part of "ctanh":
+float: 1
+ifloat: 1
+ildouble: 25
+ldouble: 25
+double: 1
+idouble: 1
+
+Function: "erf":
+double: 1
+idouble: 1
+
+Function: "erfc":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: "exp10":
+ildouble: 8
+ldouble: 8
+float: 2
+ifloat: 2
+double: 6
+idouble: 6
+
+Function: "expm1":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "gamma":
+ildouble: 1
+ldouble: 1
+
+Function: "hypot":
+float: 1
+ifloat: 1
+
+Function: "j0":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "j1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "jn":
+double: 4
+float: 4
+idouble: 4
+ifloat: 4
+ildouble: 2
+ldouble: 2
+
+Function: "lgamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "log10":
+float: 2
+ifloat: 2
+ildouble: 1
+ldouble: 1
+double: 1
+idouble: 1
+
+Function: "log1p":
+float: 1
+ifloat: 1
+
+Function: "sincos":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "tan":
+double: 1
+idouble: 1
+
+Function: "tgamma":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "y0":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+Function: "y1":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+ildouble: 1
+ldouble: 1
+
+Function: "yn":
+double: 3
+float: 2
+idouble: 3
+ifloat: 2
+ildouble: 4
+ldouble: 4
+
+# end of automatic generation
diff --git a/test/math/libm-test-ulps-xtensa b/test/math/libm-test-ulps-xtensa
new file mode 100644
index 000000000..46b2ac559
--- /dev/null
+++ b/test/math/libm-test-ulps-xtensa
@@ -0,0 +1,145 @@
+# Begin of automatic generation
+
+# cos
+Test "cos (M_PI_6l * 2.0) == 0.5":
+double: 1
+idouble: 1
+Test "cos (M_PI_6l * 4.0) == -0.5":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+# erf
+Test "erf (0.75) == 0.711155633653515131598937834591410777":
+double: 1
+idouble: 1
+Test "erf (1.25) == 0.922900128256458230136523481197281140":
+double: 1
+idouble: 1
+
+# erfc
+Test "erfc (4.125) == 0.542340079956506600531223408575531062e-8":
+double: 1
+idouble: 1
+
+# exp
+Test "exp (1) == e":
+double: 1
+idouble: 1
+
+# expm1
+Test "expm1 (0.75) == 1.11700001661267466854536981983709561":
+double: 1
+idouble: 1
+
+# hypot
+Test "hypot (-0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (-12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, -12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (0.7, 12.4) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, -0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+Test "hypot (12.4, 0.7) == 12.419742348374220601176836866763271":
+float: 1
+ifloat: 1
+
+# lgamma
+Test "lgamma (0.7) == 0.260867246531666514385732417016759578":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "lgamma (1.2) == -0.853740900033158497197028392998854470e-1":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+# log10
+Test "log10 (0.75) == -0.124938736608299953132449886193870744":
+double: 1
+idouble: 1
+Test "log10 (e) == log10(e)":
+float: 1
+ifloat: 1
+
+# tgamma
+Test "tgamma (-0.5) == -2 sqrt (pi)":
+double: 1
+idouble: 1
+Test "tgamma (0.7) == 1.29805533264755778568117117915281162":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# Maximal error of functions:
+Function: "cos":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+
+Function: "erf":
+double: 1
+idouble: 1
+
+Function: "erfc":
+double: 1
+idouble: 1
+
+Function: "exp":
+double: 1
+idouble: 1
+
+Function: "expm1":
+double: 1
+idouble: 1
+
+Function: "hypot":
+float: 1
+ifloat: 1
+
+Function: "lgamma":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "log":
+float: 1
+ifloat: 1
+
+Function: "log10":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "tan":
+double: 1
+idouble: 1
+
+Function: "tgamma":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# end of automatic generation
diff --git a/test/math/libm-test.inc b/test/math/libm-test.inc
index c9c2c8b41..f50b48b81 100644
--- a/test/math/libm-test.inc
+++ b/test/math/libm-test.inc
@@ -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/>. */
/* Part of testsuite for libm.
@@ -26,17 +25,17 @@
FUNC(function): converts general function name (like cos) to
name with correct suffix (e.g. cosl or cosf)
MATHCONST(x): like FUNC but for constants (e.g convert 0.0 to 0.0L)
- FLOAT: floating point type to test
- - TEST_MSG: informal message to be displayed
+ FLOAT: floating point type to test
+ - TEST_MSG: informal message to be displayed
CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat):
chooses one of the parameters as delta for testing
equality
- PRINTF_EXPR Floating point conversion specification to print a variable
+ PRINTF_EXPR Floating point conversion specification to print a variable
of type FLOAT with printf. PRINTF_EXPR just contains
the specifier, not the percent and width arguments,
e.g. "f".
PRINTF_XEXPR Like PRINTF_EXPR, but print in hexadecimal format.
- PRINTF_NEXPR Like PRINTF_EXPR, but print nice. */
+ PRINTF_NEXPR Like PRINTF_EXPR, but print nice. */
/* This testsuite has currently tests for:
acos, acosh, asin, asinh, atan, atan2, atanh,
@@ -116,6 +115,9 @@
# define _GNU_SOURCE
#endif
+#undef __CHK_COMPLEX_STUFF
+#define __CHK_COMPLEX_STUFF 0
+
#include "libm-test-ulps.h"
#include <complex.h>
#include <math.h>
@@ -1121,8 +1123,10 @@ cacosh_test (void)
END (cacosh, complex);
}
+#endif
+#if __CHK_COMPLEX_STUFF
static void
carg_test (void)
{
@@ -1189,7 +1193,9 @@ carg_test (void)
END (carg);
}
+#endif /* __CHK_COMPLEX_STUFF */
+#if 0
static void
casin_test (void)
{
@@ -1684,7 +1690,7 @@ ceil_test (void)
}
-#if 0
+#if __CHK_COMPLEX_STUFF
static void
cexp_test (void)
{
@@ -1747,8 +1753,9 @@ cexp_test (void)
END (cexp, complex);
}
+#endif /* __CHK_COMPLEX_STUFF */
-
+#if 0
static void
cimag_test (void)
{
@@ -2589,7 +2596,6 @@ fabs_test (void)
}
-#if 0
static void
fdim_test (void)
{
@@ -2625,7 +2631,6 @@ fdim_test (void)
END (fdim);
}
-#endif
static void
@@ -2695,7 +2700,6 @@ floor_test (void)
}
-#if 0
static void
fma_test (void)
{
@@ -2798,7 +2802,6 @@ fmin_test (void)
END (fmin);
}
-#endif
static void
@@ -3003,6 +3006,7 @@ isnormal_test (void)
END (isnormal);
}
+#if defined __DO_XSI_MATH__ && !(defined TEST_LDOUBLE || defined TEST_FLOAT)
static void
j0_test (void)
{
@@ -3149,6 +3153,7 @@ jn_test (void)
END (jn);
}
+#endif /* __DO_XSI_MATH__ */
static void
@@ -3413,8 +3418,6 @@ log1p_test (void)
END (log1p);
}
-
-#if 0
static void
log2_test (void)
{
@@ -3444,8 +3447,6 @@ log2_test (void)
END (log2);
}
-#endif
-
static void
logb_test (void)
@@ -3628,7 +3629,6 @@ modf_test (void)
}
-#if 0
static void
nearbyint_test (void)
{
@@ -3709,7 +3709,6 @@ nexttoward_test (void)
END (nexttoward);
}
-#endif
static void
@@ -3949,7 +3948,6 @@ remainder_test (void)
END (remainder);
}
-#if 0
static void
remquo_test (void)
{
@@ -3980,7 +3978,6 @@ remquo_test (void)
END (remquo);
}
-#endif
static void
rint_test (void)
@@ -4228,11 +4225,12 @@ round_test (void)
#endif
+#ifdef __UCLIBC_SUSV3_LEGACY__
static void
scalb_test (void)
{
-
START (scalb);
+#ifndef TEST_LDOUBLE /* uclibc doesn't have scalbl */
TEST_ff_f (scalb, 2.0, 0.5, nan_value, INVALID_EXCEPTION);
TEST_ff_f (scalb, 3.0, -2.5, nan_value, INVALID_EXCEPTION);
@@ -4283,10 +4281,10 @@ scalb_test (void)
TEST_ff_f (scalb, 0.8L, 4, 12.8L);
TEST_ff_f (scalb, -0.854375L, 5, -27.34L);
-
+#endif /* TEST_LDOUBLE */
END (scalb);
}
-
+#endif
static void
scalbn_test (void)
@@ -4310,7 +4308,6 @@ scalbn_test (void)
}
-#if 0
static void
scalbln_test (void)
{
@@ -4331,7 +4328,6 @@ scalbln_test (void)
END (scalbn);
}
-#endif
static void
@@ -4515,7 +4511,8 @@ tanh_test (void)
START (tanh);
TEST_f_f (tanh, 0, 0);
- TEST_f_f (tanh, minus_zero, minus_zero);
+ /* vda: uclibc: added IGNORE_ZERO_INF_SIGN to treat -0 as ok */
+ TEST_f_f (tanh, minus_zero, minus_zero, IGNORE_ZERO_INF_SIGN);
#ifndef TEST_INLINE
TEST_f_f (tanh, plus_infty, 1);
@@ -4535,7 +4532,6 @@ tanh_test (void)
END (tanh);
}
-#if 0
static void
tgamma_test (void)
{
@@ -4567,7 +4563,6 @@ tgamma_test (void)
END (tgamma);
}
-#endif
#if 0
@@ -4647,6 +4642,7 @@ trunc_test (void)
}
#endif
+#if defined __DO_XSI_MATH__ && !(defined TEST_LDOUBLE || defined TEST_FLOAT)
static void
y0_test (void)
{
@@ -4789,6 +4785,7 @@ yn_test (void)
END (yn);
}
+#endif /* __DO_XSI_MATH__ */
static void
@@ -4967,17 +4964,15 @@ main (int argc, char **argv)
log_test ();
log10_test ();
log1p_test ();
-#if 0
log2_test ();
-#endif
logb_test ();
modf_test ();
ilogb_test ();
+#ifdef __UCLIBC_SUSV3_LEGACY__
scalb_test ();
+#endif
scalbn_test ();
-#if 0
scalbln_test ();
-#endif
significand_test ();
/* Power and absolute value functions: */
@@ -4992,16 +4987,12 @@ main (int argc, char **argv)
erfc_test ();
gamma_test ();
lgamma_test ();
-#if 0
tgamma_test ();
-#endif
/* Nearest integer functions: */
ceil_test ();
floor_test ();
-#if 0
nearbyint_test ();
-#endif
rint_test ();
#if 0
rint_test_tonearest ();
@@ -5019,13 +5010,10 @@ main (int argc, char **argv)
/* Remainder functions: */
fmod_test ();
remainder_test ();
-#if 0
remquo_test ();
-#endif
/* Manipulation functions: */
copysign_test ();
-#if 0
nextafter_test ();
nexttoward_test ();
@@ -5037,24 +5025,29 @@ main (int argc, char **argv)
/* Multiply and add: */
fma_test ();
+
/* Complex functions: */
cabs_test ();
+#if __CHK_COMPLEX_STUFF
+#if 0
cacos_test ();
cacosh_test ();
+#endif
carg_test ();
+#if 0
casin_test ();
casinh_test ();
catan_test ();
catanh_test ();
ccos_test ();
ccosh_test ();
+#endif
cexp_test ();
+#if 0
cimag_test ();
clog10_test ();
clog_test ();
-#if 0
conj_test ();
-#endif
cpow_test ();
cproj_test ();
creal_test ();
@@ -5064,16 +5057,17 @@ main (int argc, char **argv)
ctan_test ();
ctanh_test ();
#endif
+#endif /* __CHK_COMPLEX_STUFF */
/* Bessel functions: */
-#if 0
+#if defined __DO_XSI_MATH__ && !(defined TEST_LDOUBLE || defined TEST_FLOAT)
j0_test ();
j1_test ();
jn_test ();
y0_test ();
y1_test ();
yn_test ();
-#endif
+#endif /* __DO_XSI_MATH__ */
if (output_ulps)
fclose (ulps_file);
diff --git a/test/math/rint.c b/test/math/rint.c
index 04c195385..b595459a3 100644
--- a/test/math/rint.c
+++ b/test/math/rint.c
@@ -1,11 +1,33 @@
#include <math.h>
+#include <float.h>
#include <stdlib.h>
+#include <stdint.h>
#include <stdio.h>
-int main(void) {
- double d1, d2;
- d1 = 0.6; d2 = rint(d1);
- printf("d1 = %f, d2 = %f\n", d1, d2);
- return 0;
-}
+#define check_d1(func, param, expected) \
+do { \
+ int err; hex_union ur; hex_union up; \
+ double result = func(param); up.f = param; ur.f = result; \
+ errors += (err = (result != (expected))); \
+ err \
+ ? printf("FAIL: %s(%g/"HEXFMT")=%g/"HEXFMT" (expected %g)\n", \
+ #func, (double)(param), (long long)up.hex, result, (long long)ur.hex, (double)(expected)) \
+ : printf("PASS: %s(%g)=%g\n", #func, (double)(param), result); \
+} while (0)
+
+#define HEXFMT "%08llx"
+typedef union {
+ double f;
+ uint64_t hex;
+} hex_union;
+double result;
+
+int errors = 0;
+int main(void)
+{
+ check_d1(rint, 0.6, 1.0);
+
+ printf("Errors: %d\n", errors);
+ return errors;
+}
diff --git a/test/math/signgam.c b/test/math/signgam.c
new file mode 100644
index 000000000..2f1adbaad
--- /dev/null
+++ b/test/math/signgam.c
@@ -0,0 +1,28 @@
+#define _XOPEN_SOURCE 600
+#include <math.h>
+#include <float.h>
+#include <stdio.h>
+
+double zero = 0.0;
+double mzero;
+
+int main(void)
+{
+ double d;
+ int errors = 0;
+
+ mzero = copysign(zero, -1.0);
+
+ d = lgamma(zero);
+ printf("%g %d\n", d, signgam);
+ errors += !(d == HUGE_VAL);
+ errors += !(signgam == 1);
+
+ d = lgamma(mzero);
+ printf("%g %d\n", d, signgam);
+ errors += !(d == HUGE_VAL);
+ errors += !(signgam == -1);
+
+ printf("Errors: %d\n", errors);
+ return errors;
+}
diff --git a/test/math/test-double.c b/test/math/test-double.c
index 4d239a71d..3c9733e03 100644
--- a/test/math/test-double.c
+++ b/test/math/test-double.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 FUNC(function) function
#define FLOAT double
diff --git a/test/math/test-float.c b/test/math/test-float.c
index 26a4213b4..6764fff47 100644
--- a/test/math/test-float.c
+++ b/test/math/test-float.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 FUNC(function) function ## f
#define FLOAT float
diff --git a/test/math/test-fpucw.c b/test/math/test-fpucw.c
index 6d638c66c..93237eae8 100644
--- a/test/math/test-fpucw.c
+++ b/test/math/test-fpucw.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 <fpu_control.h>
#include <stdio.h>
diff --git a/test/math/test-idouble.c b/test/math/test-idouble.c
index 7606a89ff..e340e1951 100644
--- a/test/math/test-idouble.c
+++ b/test/math/test-idouble.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 FUNC(function) function
#define FLOAT double
diff --git a/test/math/test-ifloat.c b/test/math/test-ifloat.c
index 9eb9ce502..b8291d1f5 100644
--- a/test/math/test-ifloat.c
+++ b/test/math/test-ifloat.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 FUNC(function) function ## f
#define FLOAT float
diff --git a/test/math/test-ildoubl.c b/test/math/test-ildoubl.c
index 597edbca1..787380431 100644
--- a/test/math/test-ildoubl.c
+++ b/test/math/test-ildoubl.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 FUNC(function) function##l
#define FLOAT long double
diff --git a/test/math/test-ldouble.c b/test/math/test-ldouble.c
index 272122766..a5ec7cba8 100644
--- a/test/math/test-ldouble.c
+++ b/test/math/test-ldouble.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 FUNC(function) function##l
#define FLOAT long double
diff --git a/test/math/tst-definitions.c b/test/math/tst-definitions.c
index 7d352af40..3f71611ef 100644
--- a/test/math/tst-definitions.c
+++ b/test/math/tst-definitions.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 <limits.h>
#include <math.h>
diff --git a/test/misc/Makefile b/test/misc/Makefile
index 48c549e73..09fa233a6 100644
--- a/test/misc/Makefile
+++ b/test/misc/Makefile
@@ -1,14 +1,8 @@
# uClibc misc tests
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-TESTS_DISABLED := outb tst-fnmatch bug-glob1 tst-gnuglob
-
+top_builddir=../../
+top_srcdir=../../
+include ../Rules.mak
+-include Makefile.in
include ../Test.mak
-
-CFLAGS_dirent64 := -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
-
-DODIFF_dirent := 1
-DODIFF_dirent64 := 1
-
-OPTS_bug-glob1 := $(PWD)
-OPTS_tst-fnmatch := < tst-fnmatch.input
diff --git a/test/misc/Makefile.in b/test/misc/Makefile.in
new file mode 100644
index 000000000..a15ff97d6
--- /dev/null
+++ b/test/misc/Makefile.in
@@ -0,0 +1,48 @@
+# uClibc misc tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+TESTS_DISABLED := outb tst-fnmatch bug-glob1 tst-gnuglob
+
+ifeq ($(TARGET_avr32),y)
+TESTS_DISABLED += tst-inotify
+endif
+
+ifeq ($(UCLIBC_HAS_LFS),)
+TESTS_DISABLED += dirent64
+TESTS_DISABLED += tst-statfs # assuming host has LFS on
+endif
+CFLAGS_dirent64 := -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
+
+ifeq ($(UCLIBC_LINUX_SPECIFIC),)
+TESTS_DISABLED += tst-inotify
+endif
+
+ifeq ($(UCLIBC_HAS_GLOB),)
+TESTS_DISABLED += bug-glob2
+endif
+
+ifeq ($(UCLIBC_HAS_UTMPX),)
+TESTS_DISABLED += tst-utmpx
+endif
+
+ifeq ($(UCLIBC_HAS_UTMP),)
+TESTS_DISABLED += tst-utmp
+endif
+
+DODIFF_dirent := 1
+DODIFF_dirent64 := 1
+DODIFF_tst-statfs := 1
+DODIFF_tst-statvfs := 1
+
+OPTS_bug-glob1 := $(PWD)
+OPTS_tst-fnmatch := < tst-fnmatch.input
+
+MNTENTS = / /sys /proc /dev
+OPTS_tst-statfs := $(MNTENTS)
+OPTS_tst-statvfs := $(MNTENTS)
+
+CFLAGS_bug-glob2 = -fPIC
+CFLAGS_opendir-tst1 = -fPIC
+CFLAGS_tst-inotify = -fPIC
+CFLAGS_tst-utmp = -fPIC
+CFLAGS_tst-utmpx = -fPIC
diff --git a/test/misc/bug-glob1.c b/test/misc/bug-glob1.c
index aec84ad44..276983a0d 100644
--- a/test/misc/bug-glob1.c
+++ b/test/misc/bug-glob1.c
@@ -32,9 +32,7 @@ prepare (int argc, char *argv[])
again:
strcpy (stpcpy (fname, argv[1]), ext);
-/*
- fname = mktemp (fname);
-*/
+/* fname = mktemp (fname); */
close(mkstemp(fname));
unlink(fname);
diff --git a/test/misc/bug-glob2.c b/test/misc/bug-glob2.c
index f8b030e2c..069891b03 100644
--- a/test/misc/bug-glob2.c
+++ b/test/misc/bug-glob2.c
@@ -14,12 +14,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 <errno.h>
-#include <error.h>
#include <dirent.h>
#include <glob.h>
#include <stdlib.h>
diff --git a/test/misc/fdopen.c b/test/misc/fdopen.c
index f64cfb6b9..97e66de0a 100644
--- a/test/misc/fdopen.c
+++ b/test/misc/fdopen.c
@@ -33,7 +33,7 @@ main (int argc, char *argv[])
assert (fclose (fp) == 0);
fp = NULL;
- fd = open (name, O_RDWR|O_CREAT);
+ fd = open (name, O_RDWR|O_CREAT, 0660);
assert (fd != -1);
assert (lseek (fd, 5, SEEK_SET) == 5);
diff --git a/test/misc/opendir-tst1.c b/test/misc/opendir-tst1.c
index 983d4b482..ffd785f80 100644
--- a/test/misc/opendir-tst1.c
+++ b/test/misc/opendir-tst1.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 <dirent.h>
#include <errno.h>
@@ -24,6 +23,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <sys/stat.h>
/* Name of the FIFO. */
char tmpname[] = "fifoXXXXXX";
@@ -92,4 +92,4 @@ do_cleanup (void)
/* Include the test skeleton. */
-#include <test-skeleton.c>
+#include "../test-skeleton.c"
diff --git a/test/misc/tst-fnmatch.c b/test/misc/tst-fnmatch.c
index bb102c5bb..e7d5324bb 100644
--- a/test/misc/tst-fnmatch.c
+++ b/test/misc/tst-fnmatch.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 <error.h>
diff --git a/test/misc/tst-fnmatch.input b/test/misc/tst-fnmatch.input
index 9061d1994..bf69c12c0 100644
--- a/test/misc/tst-fnmatch.input
+++ b/test/misc/tst-fnmatch.input
@@ -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; see the file COPYING.LIB. If
+# not, see <http://www.gnu.org/licenses/>.
# Derived from the IEEE 2003.2 text. The standard only contains some
diff --git a/test/misc/tst-gnuglob.c b/test/misc/tst-gnuglob.c
index 04c6743e9..53bc0cff2 100644
--- a/test/misc/tst-gnuglob.c
+++ b/test/misc/tst-gnuglob.c
@@ -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 <dirent.h>
#include <errno.h>
diff --git a/test/misc/tst-inotify.c b/test/misc/tst-inotify.c
new file mode 100644
index 000000000..f9f6830e3
--- /dev/null
+++ b/test/misc/tst-inotify.c
@@ -0,0 +1,65 @@
+/* vi: set sw=4 ts=4 sts=4: */
+/*
+ * inotify test for uClibc
+ * Copyright (C) 2012 by Kevin Cernekee <cernekee@gmail.com>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+#include <inttypes.h>
+#include <sys/inotify.h>
+#include <sys/fcntl.h>
+
+static int
+do_test(void)
+{
+ int ifd, fd, ret, result = 0;
+ struct inotify_event e;
+ char tfile[] = "/tmp/inotify.XXXXXX";
+
+ fd = mkstemp(tfile);
+ close(fd);
+
+ ifd = inotify_init1(IN_NONBLOCK);
+ if (ifd < 0) {
+ perror("inotify_init1()");
+ result = 1;
+ }
+ if (inotify_add_watch(ifd, tfile, IN_DELETE_SELF) < 0) {
+ perror("inotify_add_watch()");
+ result = 1;
+ }
+
+ /* nonblocking inotify should return immediately with no events */
+ ret = read(ifd, &e, sizeof(e));
+ if (ret != -1 || errno != EAGAIN) {
+ fprintf(stderr, "first read() returned %d\n", ret);
+ result = 1;
+ }
+
+ /* generate an event */
+ unlink(tfile);
+
+ /* now check whether our event was seen */
+ ret = read(ifd, &e, sizeof(e));
+ if (ret != sizeof(e)) {
+ fprintf(stderr, "second read() returned %d\n", ret);
+ result = 1;
+ }
+
+ if (!(e.mask & IN_DELETE_SELF)) {
+ fprintf(stderr, "incorrect event mask: %" PRIx32 "\n", e.mask);
+ result = 1;
+ }
+
+ return result;
+}
+
+#define TIMEOUT 5
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/misc/tst-mkostemps.c b/test/misc/tst-mkostemps.c
new file mode 100644
index 000000000..272e747a1
--- /dev/null
+++ b/test/misc/tst-mkostemps.c
@@ -0,0 +1,159 @@
+/*
+ * Test application for mkstemp/mkstemps/mkostemp/mkostemps
+ * Copyright (C) 2015 by Romain Naour <romain.naour@openwide.fr>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#define assert(x) \
+ if (!(x)) \
+ { \
+ fputs ("test failed: " #x "\n", stderr); \
+ retval = 1; \
+ goto the_end; \
+ }
+
+int
+main (int argc, char *argv[])
+{
+ char name[256];
+ char name_suffix[256];
+ FILE *fp = NULL;
+ int retval = 0;
+ int fd;
+ int flags = O_RDONLY | O_CLOEXEC;
+ struct stat sb_f1;
+ struct stat sb_f2;
+
+ /* mkstemp test */
+ sprintf(name, "/tmp/%s-uClibc-test.XXXXXX", __FILE__);
+
+ fd = mkstemp(name);
+
+ fstat(fd, &sb_f1);
+ assert ((sb_f1.st_mode & S_IFMT) == S_IFREG)
+
+ stat(name, &sb_f2);
+ assert ((sb_f2.st_mode & S_IFMT) == S_IFREG)
+
+ assert (sb_f1.st_ino == sb_f2.st_ino)
+
+ close(fd);
+ unlink (name);
+
+ /* mkstemps test */
+ sprintf(name_suffix, "/tmp/%s-uClibc-test.XXXXXX.txt", __FILE__);
+
+ fd = mkstemps(name_suffix, 4);
+
+ fstat(fd, &sb_f1);
+ assert ((sb_f1.st_mode & S_IFMT) == S_IFREG)
+
+ stat(name_suffix, &sb_f2);
+ assert ((sb_f2.st_mode & S_IFMT) == S_IFREG)
+
+ assert (sb_f1.st_ino == sb_f2.st_ino)
+
+ close(fd);
+ unlink (name_suffix);
+
+ /* mkostemp test */
+ sprintf(name, "/tmp/%s-uClibc-test.XXXXXX", __FILE__);
+
+ fd = mkostemp(name, flags);
+
+ fstat(fd, &sb_f1);
+ assert ((sb_f1.st_mode & S_IFMT) == S_IFREG)
+
+ stat(name, &sb_f2);
+ assert ((sb_f2.st_mode & S_IFMT) == S_IFREG)
+
+ assert (sb_f1.st_ino == sb_f2.st_ino)
+ assert (sb_f1.st_mode == sb_f2.st_mode)
+
+ close(fd);
+ unlink (name);
+
+ /* mkostemps test */
+ sprintf(name_suffix, "/tmp/%s-uClibc-test.XXXXXX.txt", __FILE__);
+
+ fd = mkostemps(name_suffix, 4, flags);
+
+ fstat(fd, &sb_f1);
+ assert ((sb_f1.st_mode & S_IFMT) == S_IFREG)
+
+ stat(name_suffix, &sb_f2);
+ assert ((sb_f2.st_mode & S_IFMT) == S_IFREG)
+
+ assert (sb_f1.st_ino == sb_f2.st_ino)
+ assert (sb_f1.st_mode == sb_f2.st_mode)
+
+ close(fd);
+ unlink (name_suffix);
+
+ /* suffixlen = 0 */
+ sprintf(name_suffix, "/tmp/%s-uClibc-test.XXXXXX", __FILE__);
+
+ fd = mkostemps(name_suffix, 0, flags);
+
+ fstat(fd, &sb_f1);
+ assert ((sb_f1.st_mode & S_IFMT) == S_IFREG)
+
+ stat(name_suffix, &sb_f2);
+ assert ((sb_f2.st_mode & S_IFMT) == S_IFREG)
+
+ assert (sb_f1.st_ino == sb_f2.st_ino)
+ assert (sb_f1.st_mode == sb_f2.st_mode)
+
+ close(fd);
+ unlink (name_suffix);
+
+ /* stress tests */
+
+ /* template len < 6 */
+ sprintf(name, "XXXXX");
+
+ fd = mkstemp(name);
+
+ assert(fd == -1);
+ assert(errno == EINVAL);
+
+ /* suffixlen < 0 */
+ sprintf(name_suffix, "/tmp/%s-uClibc-test.XXXXXX.txt", __FILE__);
+
+ fd = mkostemps(name_suffix, -1, flags);
+
+ assert(fd == -1);
+ assert(errno == EINVAL);
+
+ /* Missing one X */
+ sprintf(name_suffix, "/tmp/%s-uClibc-test.XXXXX.txt", __FILE__);
+
+ fd = mkostemps(name_suffix, 4, flags);
+
+ assert(fd == -1);
+ assert(errno == EINVAL);
+
+ /* wrong suffixlen */
+ sprintf(name_suffix, "/tmp/%s-uClibc-test.XXXXXX.txt", __FILE__);
+
+ fd = mkostemps(name_suffix, 2, flags);
+
+ assert(fd == -1);
+ assert(errno == EINVAL);
+
+the_end:
+ if (fp != NULL)
+ assert (fclose (fp) == 0);
+ unlink (name);
+ unlink (name_suffix);
+
+ return retval;
+}
diff --git a/test/misc/tst-scandir.c b/test/misc/tst-scandir.c
new file mode 100644
index 000000000..e1c72e3c9
--- /dev/null
+++ b/test/misc/tst-scandir.c
@@ -0,0 +1,23 @@
+#include <dirent.h>
+#include <errno.h>
+#include <stdio.h> /* perror() */
+#include <stdlib.h>
+
+static int skip_all(const struct dirent *dirbuf)
+{
+ errno = EBADF;
+ return 0;
+}
+
+int main(void)
+{
+ struct dirent **namelist;
+ int n;
+
+ n = scandir(".", &namelist, skip_all, 0);
+ if (n < 0) {
+ perror("scandir");
+ return EXIT_FAILURE;
+ }
+ return EXIT_SUCCESS;
+}
diff --git a/test/misc/tst-statfs.c b/test/misc/tst-statfs.c
new file mode 100644
index 000000000..b8b4229ba
--- /dev/null
+++ b/test/misc/tst-statfs.c
@@ -0,0 +1,31 @@
+#include <sys/vfs.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int
+main(int argc, char* argv[])
+{
+ struct statfs s;
+ int ret = 0, i;
+
+ for (i = 1; i < argc; i++) {
+ if (statfs(argv[i], &s) != 0) {
+ fprintf(stderr, "%s: %s: statfs failed. %s\n",
+ *argv, argv[i], strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+ ++ret;
+ printf("statfs %s:\n\tblocks=%lld\n\tblkfree=%lld\n\tbsize=%d\n",
+ argv[i], s.f_blocks, s.f_bfree, s.f_bsize);
+#ifdef _STATFS_F_FRSIZE
+ printf("\tfrsize=%lld\n", s.f_frsize);
+#elif defined __mips__
+ printf("\tfrsize=mips, unsupported?\n");
+#else
+# error no _STATFS_F_FRSIZE
+#endif
+ }
+ exit(ret ? EXIT_SUCCESS : EXIT_FAILURE);
+}
diff --git a/test/misc/tst-statvfs.c b/test/misc/tst-statvfs.c
new file mode 100644
index 000000000..4b67719e9
--- /dev/null
+++ b/test/misc/tst-statvfs.c
@@ -0,0 +1,26 @@
+#include <sys/statvfs.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int
+main(int argc, char* argv[])
+{
+ struct statvfs s;
+ int i;
+
+ for (i = 1; i < argc; i++) {
+ if (statvfs(argv[i], &s) != 0) {
+ fprintf(stderr, "%s: %s: statvfs failed. %s\n",
+ *argv, argv[i], strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+ printf("statvfs %s:\n\tblocks=%lld\n\tblkfree=%lld\n\tbsize=%d\n",
+ argv[i], s.f_blocks, s.f_bfree, s.f_bsize);
+#if 1 // def _STATFS_F_FRSIZE
+ printf("\tfrsize=%lld\n", s.f_frsize);
+#endif
+ }
+ exit(EXIT_SUCCESS);
+}
diff --git a/test/misc/tst-utmp.c b/test/misc/tst-utmp.c
index 12a208855..1b0333a32 100644
--- a/test/misc/tst-utmp.c
+++ b/test/misc/tst-utmp.c
@@ -14,12 +14,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 <errno.h>
-#include <error.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
@@ -39,6 +37,21 @@
# include <utmp.h>
#endif
+#ifndef _HAVE_UT_TYPE
+# define _HAVE_UT_TYPE 0
+#endif
+#ifndef _HAVE_UT_PID
+# define _HAVE_UT_PID 0
+#endif
+#ifndef _HAVE_UT_ID
+# define _HAVE_UT_ID 0
+#endif
+#ifndef _HAVE_UT_TV
+# define _HAVE_UT_TV 0
+#endif
+#ifndef _HAVE_UT_HOST
+# define _HAVE_UT_HOST 0
+#endif
#if _HAVE_UT_TYPE || defined UTMPX
@@ -50,7 +63,7 @@ static void do_prepare (int argc, char *argv[]);
#define PREPARE do_prepare
/* This defines the `main' function and some more. */
-#include <test-skeleton.c>
+#include "../test-skeleton.c"
/* These are for the temporary file we generate. */
@@ -70,8 +83,11 @@ do_prepare (int argc, char *argv[])
/* Open our test file. */
fd = mkstemp (name);
- if (fd == -1)
- error (EXIT_FAILURE, errno, "cannot open test file `%s'", name);
+ if (fd == -1) {
+ fprintf (stderr, "cannot open test file `%s': ", name);
+ perror (NULL);
+ exit (EXIT_FAILURE);
+ }
}
struct utmp entry[] =
@@ -111,7 +127,7 @@ do_init (void)
{
if (pututline (&entry[n]) == NULL)
{
- error (0, errno, "cannot write UTMP entry");
+ perror ("cannot write UTMP entry");
return 1;
}
}
@@ -136,7 +152,7 @@ do_check (void)
if (n < num_entries &&
memcmp (ut, &entry[n], sizeof (struct utmp)))
{
- error (0, 0, "UTMP entry does not match");
+ fprintf (stderr, "UTMP entry does not match\n");
return 1;
}
@@ -145,7 +161,7 @@ do_check (void)
if (n != num_entries)
{
- error (0, 0, "number of UTMP entries is incorrect");
+ fprintf (stderr, "number of UTMP entries is incorrect\n");
return 1;
}
@@ -177,7 +193,7 @@ simulate_login (const char *line, const char *user)
if (pututline (&entry[n]) == NULL)
{
- error (0, errno, "cannot write UTMP entry");
+ perror ("cannot write UTMP entry");
return 1;
}
@@ -187,7 +203,7 @@ simulate_login (const char *line, const char *user)
}
}
- error (0, 0, "no entries available");
+ fprintf (stderr, "no entries available\n");
return 1;
}
@@ -211,7 +227,7 @@ simulate_logout (const char *line)
if (pututline (&entry[n]) == NULL)
{
- error (0, errno, "cannot write UTMP entry");
+ perror ("cannot write UTMP entry");
return 1;
}
@@ -221,7 +237,7 @@ simulate_logout (const char *line)
}
}
- error (0, 0, "no entry found for `%s'", line);
+ fprintf (stderr, "no entry found for `%s'\n", line);
return 1;
}
@@ -238,7 +254,8 @@ check_login (const char *line)
up = getutline (&ut);
if (up == NULL)
{
- error (0, errno, "cannot get entry for line `%s'", line);
+ fprintf (stderr, "cannot get entry for line `%s': ", line);
+ perror(NULL);
return 1;
}
@@ -250,7 +267,7 @@ check_login (const char *line)
{
if (memcmp (up, &entry[n], sizeof (struct utmp)))
{
- error (0, 0, "UTMP entry does not match");
+ fprintf (stderr, "UTMP entry does not match\n");
return 1;
}
@@ -258,7 +275,7 @@ check_login (const char *line)
}
}
- error (0, 0, "bogus entry for line `%s'", line);
+ fprintf (stderr, "bogus entry for line `%s'\n", line);
return 1;
}
@@ -272,7 +289,7 @@ check_logout (const char *line)
strcpy (ut.ut_line, line);
if (getutline (&ut) != NULL)
{
- error (0, 0, "bogus login entry for `%s'", line);
+ fprintf (stderr, "bogus login entry for `%s'\n", line);
return 1;
}
@@ -295,7 +312,8 @@ check_id (const char *id)
up = getutid (&ut);
if (up == NULL)
{
- error (0, errno, "cannot get entry for ID `%s'", id);
+ fprintf (stderr, "cannot get entry for ID `%s': ", id);
+ perror (NULL);
return 1;
}
@@ -307,7 +325,7 @@ check_id (const char *id)
{
if (memcmp (up, &entry[n], sizeof (struct utmp)))
{
- error (0, 0, "UTMP entry does not match");
+ fprintf (stderr, "UTMP entry does not match\n");
return 1;
}
@@ -315,7 +333,7 @@ check_id (const char *id)
}
}
- error (0, 0, "bogus entry for ID `%s'", id);
+ fprintf (stderr, "bogus entry for ID `%s'\n", id);
return 1;
}
@@ -332,7 +350,8 @@ check_type (int type)
up = getutid (&ut);
if (up == NULL)
{
- error (0, errno, "cannot get entry for type `%d'", type);
+ fprintf (stderr, "cannot get entry for type `%d': ", type);
+ perror (NULL);
return 1;
}
@@ -344,7 +363,7 @@ check_type (int type)
{
if (memcmp (up, &entry[n], sizeof (struct utmp)))
{
- error (0, 0, "UTMP entry does not match");
+ fprintf (stderr, "UTMP entry does not match\n");
return 1;
}
@@ -352,7 +371,7 @@ check_type (int type)
}
}
- error (0, 0, "bogus entry for type `%d'", type);
+ fprintf (stderr, "bogus entry for type `%d'\n", type);
return 1;
}
diff --git a/test/misc/tst-utmpx.c b/test/misc/tst-utmpx.c
new file mode 100644
index 000000000..edb5551d7
--- /dev/null
+++ b/test/misc/tst-utmpx.c
@@ -0,0 +1,2 @@
+#define UTMPX
+#include "tst-utmp.c"
diff --git a/test/mmap/Makefile b/test/mmap/Makefile
index b4c301014..89e7195fb 100644
--- a/test/mmap/Makefile
+++ b/test/mmap/Makefile
@@ -1,4 +1,8 @@
# uClibc mmap tests
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+top_builddir=../../
+top_srcdir=../../
+include ../Rules.mak
+-include Makefile.in
include ../Test.mak
diff --git a/test/mmap/mmap2.c b/test/mmap/mmap2.c
index b9a8f9ac4..8b94c6199 100644
--- a/test/mmap/mmap2.c
+++ b/test/mmap/mmap2.c
@@ -25,7 +25,12 @@ int main(int argc, char **argv) {
void* map_base = 0;
int fd;
off_t target = 0xfffff000;
- if((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) FATAL;
+ if((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) {
+ /* skip test for non-root users */
+ if (errno == EACCES)
+ return 0;
+ FATAL;
+ }
printf("/dev/mem opened.\n");
fflush(stdout);
diff --git a/test/nptl/Makefile b/test/nptl/Makefile
new file mode 100644
index 000000000..c22b635b7
--- /dev/null
+++ b/test/nptl/Makefile
@@ -0,0 +1,8 @@
+# uClibc NPTL tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+top_builddir=../../
+top_srcdir=../../
+include ../Rules.mak
+-include Makefile.in
+include ../Test.mak
diff --git a/test/nptl/Makefile.in b/test/nptl/Makefile.in
new file mode 100644
index 000000000..d43db2bc4
--- /dev/null
+++ b/test/nptl/Makefile.in
@@ -0,0 +1,220 @@
+# uClibc NPTL tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+TESTS := tst-align tst-align2 tst-atfork1 tst-attr1 tst-attr2 tst-attr3 \
+ tst-barrier1 tst-barrier2 tst-barrier3 tst-barrier4 tst-basic1 \
+ tst-basic2 tst-basic3 tst-basic4 tst-basic5 tst-basic6 \
+ tst-cancel1 tst-cancel2 tst-cancel3 tst-cancel6 tst-cancel7 \
+ tst-cancel8 tst-cancel9 tst-cancel10 tst-cancel11 tst-cancel12 \
+ tst-cancel13 tst-cancel14 tst-cancel15 tst-cancel16 \
+ tst-cancel19 tst-cancel20 tst-cancel21 tst-cancel22 \
+ tst-cleanup0 tst-cleanup1 tst-cleanup2 tst-cleanup3 \
+ tst-cleanup4 tst-clock1 tst-clock2 tst-cond1 tst-cond2 \
+ tst-cond3 tst-cond4 tst-cond5 tst-cond6 tst-cond7 tst-cond8 \
+ tst-cond9 tst-cond10 tst-cond11 tst-cond12 tst-cond13 \
+ tst-cond14 tst-cond15 tst-cond16 tst-cond17 tst-cond18 \
+ tst-cond19 tst-cond20 tst-cond21 tst-detach1 tst-eintr1 \
+ tst-eintr2 tst-eintr3 tst-eintr4 tst-eintr5 tst-exec2 tst-exec3 \
+ tst-exec4 tst-exit1 tst-exit2 tst-exit3 tst-flock1 tst-flock2 \
+ tst-fork1 tst-fork2 tst-fork3 tst-fork4 tst-initializers1 \
+ tst-join1 tst-join2 tst-join3 tst-join4 tst-join5 tst-key1 \
+ tst-key2 tst-key3 tst-key4 tst-kill1 tst-kill2 tst-kill3 \
+ tst-kill4 tst-kill5 tst-kill6 tst-mutex1 tst-mutex2 tst-mutex3 \
+ tst-mutex4 tst-mutex5 tst-mutex6 tst-mutex7 tst-mutex8 \
+ tst-mutex9 tst-mutex5a tst-mutex7a tst-once1 tst-once2 \
+ tst-once3 tst-once4 tst-popen1 tst-raise1 tst-rwlock1 \
+ tst-rwlock2 tst-rwlock3 tst-rwlock4 tst-rwlock5 tst-rwlock6 \
+ tst-rwlock7 tst-rwlock8 tst-rwlock9 tst-rwlock10 tst-rwlock11 \
+ tst-rwlock12 tst-rwlock13 tst-rwlock14 tst-sched1 tst-sem1 \
+ tst-sem2 tst-sem3 tst-sem4 tst-sem5 tst-sem6 tst-sem7 tst-sem8 \
+ tst-sem9 tst-signal1 tst-signal2 tst-signal3 tst-signal4 \
+ tst-signal5 tst-signal6 tst-spin1 tst-spin2 tst-spin3 \
+ tst-stack1 tst-stack2 tst-stdio1 tst-stdio2 tst-sysconf \
+ tst-tls1 tst-tls2 tst-tls3 tst-tls4 tst-tls5 tst-tsd1 tst-tsd2 \
+ tst-tsd3 tst-tsd4 tst-tsd5 tst-umask1 \
+ tst-align3 tst-cancel4 tst-cancel5 tst-cancel18 tst-cancel23 \
+ tst-cancel25 tst-cancelx2 tst-cancelx3 tst-cancelx4 tst-cancelx6 \
+ tst-cancelx7 tst-cancelx8 tst-cancelx9 tst-cancelx10 tst-cancelx11 \
+ tst-cancelx12 tst-cancelx13 tst-cancelx14 tst-cancelx15 tst-cancelx16 \
+ tst-cancelx18 tst-cancelx20 tst-cancelx21 tst-cleanupx0 tst-cleanupx1 \
+ tst-cleanupx2 tst-cleanupx3 tst-cleanupx4 tst-cond22 tst-cond23 \
+ tst-getpid1 tst-getpid2 tst-getpid3 tst-join6 tst-tsd6 \
+ tst-oddstacklimit tst-oncex3 tst-oncex4 tst-rwlock2a \
+ tst-basic7 tst-vfork1x tst-vfork2x tst-sem10 tst-sem11 \
+ tst-sem12 tst-typesizes tst-initializers1-c89 tst-initializers1-c99 \
+ tst-initializers1-gnu89 tst-initializers1-gnu99 \
+ tst-atfork2
+
+#
+# These are for the RT library and POSIX timers.
+#
+TESTS += tst-clock tst-clock_nanosleep tst-cpuclock1 tst-cpuclock2 \
+ tst-cputimer1 tst-cputimer2 tst-cputimer3 tst-mqueue1 \
+ tst-mqueue2 tst-mqueue3 tst-mqueue4 tst-mqueue5 tst-mqueue6 \
+ tst-mqueue7 tst-mqueue8 tst-mqueue9 tst-timer2 tst-timer3 \
+ tst-timer4 tst-timer5
+
+ifeq ($(UCLIBC_HAS_OBSOLETE_BSD_SIGNAL),)
+TESTS_DISABLED += tst-exec2 tst-exec3 tst-exec4
+endif
+
+ifeq ($(UCLIBC_SUSV4_LEGACY),)
+TESTS_DISABLED += tst-basic5 tst-cancel4 tst-cancel5 tst-cancelx4
+endif
+
+GLIBC_TESTS_DISABLED := tst-eintr1_glibc tst-eintr2_glibc \
+ tst-eintr3_glibc tst-eintr4_glibc tst-eintr5_glibc \
+ tst-tls1_glibc tst-tls2_glibc
+
+
+ifeq ($(HAVE_SHARED),)
+TESTS_DISABLED += tst-tls3 tst-tls4 tst-tls5 tst-dlsym1 tst-fini1 \
+ tst-unload
+else
+GLIBC_TESTS_DISABLED += tst-tls3_glibc tst-tls4_glibc tst-tls5_glibc
+endif
+
+EXTRA_CFLAGS := -DNOT_IN_libc=1 -D_LIBC -D__USE_GNU -std=gnu99 \
+ $(PTINC) \
+ -I$(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH) \
+ -I$(top_srcdir)libc/sysdeps/linux \
+ -I$(top_builddir)include \
+ -include $(top_builddir)include/libc-symbols.h
+
+ifeq ($(TARGET_ARCH),i386)
+CFLAGS_tst-align := -malign-double -mpreferred-stack-boundary=4
+endif
+ifeq ($(TARGET_ARCH),i686)
+CFLAGS_tst-align := -malign-double -mpreferred-stack-boundary=4 -msse
+endif
+CFLAGS_tst-cleanup4aux.o := -W
+CFLAGS_tst-initializers1 := -W -Werror
+CFLAGS_tst-tls3mod.so := -fPIC -DPIC -DSHARED -shared -DNOT_IN_libc
+CFLAGS_tst-tls4moda.so := -fPIC -DPIC -DSHARED -shared -DNOT_IN_libc
+CFLAGS_tst-tls4modb.so := -fPIC -DPIC -DSHARED -shared -DNOT_IN_libc
+CFLAGS_tst-tls5mod.so := -fPIC -DPIC -DSHARED -shared -DNOT_IN_libc
+CFLAGS_tst-tls5moda.so := -fPIC -DPIC -DSHARED -shared -DNOT_IN_libc
+CFLAGS_tst-tls5modb.so := -fPIC -DPIC -DSHARED -shared -DNOT_IN_libc
+CFLAGS_tst-tls5modc.so := -fPIC -DPIC -DSHARED -shared -DNOT_IN_libc
+CFLAGS_tst-tls5modd.so := -fPIC -DPIC -DSHARED -shared -DNOT_IN_libc
+CFLAGS_tst-tls5mode.so := -fPIC -DPIC -DSHARED -shared -DNOT_IN_libc
+CFLAGS_tst-tls5modf.so := -fPIC -DPIC -DSHARED -shared -DNOT_IN_libc
+
+CFLAGS_tst-fini1mod.so := -fPIC -DPIC -DSHARED -shared -DNOT_IN_libc
+LDFLAGS_tst-cond11 = -lrt
+LDFLAGS_tst-cond19 = -lrt
+LDFLAGS_tst-cancel18 = -lrt
+LDFLAGS_tst-cancelx18 = -lrt
+LDFLAGS_tst-clock2 = -lrt
+LDFLAGS_tst-rwlock14 = -lrt
+LDFLAGS_tst-fini1 = -Wl,-rpath=./ tst-fini1mod.so
+LDFLAGS_tst-fini1mod.so = -Wl,-soname=tst-fini1mod.so
+LDFLAGS_tst-unload = -ldl
+LDFLAGS_tst-cancel5 := -lpthread
+LDFLAGS_tst-cancel23 := -lc -lpthread
+LDFLAGS_tst-vfork1x := -lc -lpthread
+LDFLAGS_tst-vfork2x := -lc -lpthread
+
+CFLAGS_tst-cancelx2 += -fexceptions
+CFLAGS_tst-cancelx3 += -fexceptions
+CFLAGS_tst-cancelx4 += -fexceptions
+CFLAGS_tst-cancelx6 += -fexceptions
+CFLAGS_tst-cancelx7 += -fexceptions
+CFLAGS_tst-cancelx8 += -fexceptions
+CFLAGS_tst-cancelx9 += -fexceptions
+CFLAGS_tst-cancelx10 += -fexceptions
+CFLAGS_tst-cancelx11 += -fexceptions
+CFLAGS_tst-cancelx12 += -fexceptions
+CFLAGS_tst-cancelx13 += -fexceptions
+CFLAGS_tst-cancelx14 += -fexceptions
+CFLAGS_tst-cancelx15 += -fexceptions
+CFLAGS_tst-cancelx16 += -fexceptions
+CFLAGS_tst-cancelx18 += -fexceptions
+CFLAGS_tst-cancelx20 += -fexceptions -fasynchronous-unwind-tables
+CFLAGS_tst-cancelx21 += -fexceptions -fasynchronous-unwind-tables
+CFLAGS_tst-cleanupx0 += -fexceptions -fasynchronous-unwind-tables
+CFLAGS_tst-cleanupx1 += -fexceptions -fasynchronous-unwind-tables
+CFLAGS_tst-cleanupx2 += -fexceptions
+CFLAGS_tst-cleanupx3 += -fexceptions
+
+CFLAGS_tst-oncex3 += -fexceptions
+CFLAGS_tst-oncex4 += -fexceptions
+CFLAGS_tst-align += $(stack-align-test-flags)
+CFLAGS_tst-align3 += $(stack-align-test-flags)
+CFLAGS_tst-initializers1 = -W -Wall -Werror
+CFLAGS_tst-sem11 += -fexceptions -fasynchronous-unwind-tables
+CFLAGS_tst-sem12 += -fexceptions -fasynchronous-unwind-tables
+CFLAGS_tst-initializers1 = -W -Wall -Werror
+CFLAGS_tst-initializers1-c89 = $(CFLAGS-tst-initializers1) -std=c89
+CFLAGS_tst-initializers1-c99 = $(CFLAGS-tst-initializers1) -std=c99
+CFLAGS_tst-initializers1-gnu89 = $(CFLAGS-tst-initializers1) -std=gnu89
+CFLAGS_tst-initializers1-gnu99 = $(CFLAGS-tst-initializers1) -std=gnu99
+
+EXTRA_LDFLAGS = $(if $(findstring -lpthread,$(LDFLAGS_$@)),,-lpthread)
+
+LDFLAGS_tst-atfork2 := -ldl
+LDFLAGS_libatfork.so := -shared -static-libgcc -lpthread
+LDFLAGS_tst-cleanup4 := tst-cleanup4aux.o
+LDFLAGS_tst-cleanupx4 := tst-cleanup4aux.o
+LDFLAGS_tst-clock2 := -lrt
+LDFLAGS_tst-cond11 := -lrt
+LDFLAGS_tst-cond19 := -lrt
+LDFLAGS_tst-rwlock14 := -lrt
+LDFLAGS_tst-tls3 := -ldl -rdynamic
+LDFLAGS_tst-tls4 := -ldl
+LDFLAGS_tst-tls5 := tst-tls5mod.so
+LDFLAGS_tst-clock := -lrt
+LDFLAGS_tst-clock_nanosleep := -lrt
+LDFLAGS_tst-cpuclock1 := -lrt
+LDFLAGS_tst-cpuclock2 := -lrt -lpthread
+LDFLAGS_tst-cputimer1 := -lrt -lpthread
+LDFLAGS_tst-cputimer2 := -lrt -lpthread
+LDFLAGS_tst-cputimer3 := -lrt -lpthread
+LDFLAGS_tst-mqueue1 := -lrt
+LDFLAGS_tst-mqueue2 := -lrt
+LDFLAGS_tst-mqueue3 := -lrt -lpthread
+LDFLAGS_tst-mqueue4 := -lrt
+LDFLAGS_tst-mqueue5 := -lrt -lpthread
+LDFLAGS_tst-mqueue6 := -lrt -lpthread
+LDFLAGS_tst-mqueue7 := -lrt
+LDFLAGS_tst-mqueue8 := -lrt
+LDFLAGS_tst-mqueue9 := -lrt
+LDFLAGS_tst-timer2 := -lrt -lpthread
+LDFLAGS_tst-timer3 := -lrt -lpthread
+LDFLAGS_tst-timer4 := -lrt -lpthread
+LDFLAGS_tst-timer5 := -lrt -lpthread
+LDFLAGS_tst-dlsym1 := -ldl -rdynamic
+LDFLAGS_tst-tls3mod.so := -shared -static-libgcc -lpthread
+LDFLAGS_tst-tls4moda.so := -shared -static-libgcc
+LDFLAGS_tst-tls4modb.so := -shared -static-libgcc
+LDFLAGS_tst-tls5mod.so := -shared -static-libgcc -Wl,-soname,tst-tls5mod.so
+LDFLAGS_tst-tls5moda.so := -shared -static-libgcc
+LDFLAGS_tst-tls5modb.so := -shared -static-libgcc
+LDFLAGS_tst-tls5modc.so := -shared -static-libgcc
+LDFLAGS_tst-tls5modd.so := -shared -static-libgcc
+LDFLAGS_tst-tls5mode.so := -shared -static-libgcc
+LDFLAGS_tst-tls5modf.so := -shared -static-libgcc
+LDFLAGS_tst-cleanupx4 := tst-cleanup4aux.o
+
+#
+# Special case
+#
+tst-cleanup4aux.o:
+ $(Q)$(CC) $(CFLAGS) $(CFLAGS_$@) $(EXTRA_CFLAGS) -c tst-cleanup4aux.c -o $@
+
+tst-cleanup4: tst-cleanup4aux.o
+tst-tls3: tst-tls3mod.so
+tst-tls4: tst-tls4moda.so tst-tls4modb.so
+tst-tls5: tst-tls5mod.so
+
+tst-cleanupx4 : tst-cleanup4aux.o
+tst-fini1: tst-fini1mod.so
+
+tst-atfork2: libatfork.so
+tst-atfork2_glibc: libatfork.so.glibc
+
+OPTS_tst-cancel7 = -c ./tst-cancel7
+OPTS_tst-mqueue7 = -- ./tst-mqueue7
+OPTS_tst-exec4 = ./tst-exec4
+
+WRAPPER := env LD_LIBRARY_PATH="$$PWD:.:$(LD_LIBRARY_PATH)" TIMEOUTFACTOR=10
diff --git a/test/nptl/eintr.c b/test/nptl/eintr.c
new file mode 100644
index 000000000..d6425b51b
--- /dev/null
+++ b/test/nptl/eintr.c
@@ -0,0 +1,88 @@
+/* Copyright (C) 2003 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 <pthread.h>
+#include <signal.h>
+#include <unistd.h>
+
+
+static int the_sig;
+
+
+static void
+eintr_handler (int sig)
+{
+ if (sig != the_sig)
+ {
+ write (STDOUT_FILENO, "eintr_handler: signal number wrong\n", 35);
+ _exit (1);
+ }
+ write (STDOUT_FILENO, ".", 1);
+}
+
+
+static void *
+eintr_source (void *arg)
+{
+ struct timespec ts = { .tv_sec = 0, .tv_nsec = 500000 };
+
+ if (arg == NULL)
+ {
+ sigset_t ss;
+ sigemptyset (&ss);
+ sigaddset (&ss, the_sig);
+ pthread_sigmask (SIG_BLOCK, &ss, NULL);
+ }
+
+ while (1)
+ {
+ if (arg != NULL)
+ pthread_kill (*(pthread_t *) arg, the_sig);
+ else
+ kill (getpid (), the_sig);
+
+ nanosleep (&ts, NULL);
+ }
+
+ /* NOTREACHED */
+ return NULL;
+}
+
+
+static void
+setup_eintr (int sig, pthread_t *thp)
+{
+ struct sigaction sa;
+ sigemptyset (&sa.sa_mask);
+ sa.sa_flags = 0;
+ sa.sa_handler = eintr_handler;
+ if (sigaction (sig, &sa, NULL) != 0)
+ {
+ puts ("setup_eintr: sigaction failed");
+ exit (1);
+ }
+ the_sig = sig;
+
+ /* Create the thread which will fire off the signals. */
+ pthread_t th;
+ if (pthread_create (&th, NULL, eintr_source, thp) != 0)
+ {
+ puts ("setup_eintr: pthread_create failed");
+ exit (1);
+ }
+}
diff --git a/test/nptl/libatfork.c b/test/nptl/libatfork.c
new file mode 100644
index 000000000..f4ddca057
--- /dev/null
+++ b/test/nptl/libatfork.c
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include <pthread.h>
+
+static void atfork_prepare(void)
+{
+ /* nothing to do */
+}
+
+static void atfork_parent(void)
+{
+ /* nothing to do */
+}
+
+static void atfork_child(void)
+{
+ /* nothing to do */
+}
+
+static __attribute__((constructor)) void init(void)
+{
+ pthread_atfork(atfork_prepare, atfork_parent, atfork_child);
+}
+
+static __attribute__((destructor)) void done(void)
+{
+ /* nothing to do */
+}
diff --git a/test/nptl/tst-align.c b/test/nptl/tst-align.c
new file mode 100644
index 000000000..df66b38b7
--- /dev/null
+++ b/test/nptl/tst-align.c
@@ -0,0 +1,70 @@
+/* Copyright (C) 2003 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 <pthread.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include "tst-stack-align.h"
+
+static void *
+tf (void *arg)
+{
+ bool ok = true;
+
+ puts ("in thread");
+
+ if (TEST_STACK_ALIGN ())
+ ok = false;
+
+ return ok ? NULL : (void *) -1l;
+}
+
+static int
+do_test (void)
+{
+ bool ok = true;
+
+ puts ("in main");
+
+ if (TEST_STACK_ALIGN ())
+ ok = false;
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ return 1;
+ }
+
+ void *res;
+ if (pthread_join (th, &res) != 0)
+ {
+ puts ("join failed");
+ return 1;
+ }
+
+ if (res != NULL)
+ ok = false;
+
+ return ok ? 0 : 1;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-align2.c b/test/nptl/tst-align2.c
new file mode 100644
index 000000000..7d3a09913
--- /dev/null
+++ b/test/nptl/tst-align2.c
@@ -0,0 +1,86 @@
+/* Copyright (C) 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/>. */
+
+#include <sched.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include "tst-stack-align.h"
+
+static int
+f (void *arg)
+{
+ bool ok = true;
+
+ if (TEST_STACK_ALIGN ())
+ ok = false;
+
+ return ok ? 0 : 1;
+}
+
+static int
+do_test (void)
+{
+ bool ok = true;
+
+ puts ("in main");
+
+ if (TEST_STACK_ALIGN ())
+ ok = false;
+
+#ifdef __ia64__
+ extern int __clone2 (int (*__fn) (void *__arg), void *__child_stack_base,
+ size_t __child_stack_size, int __flags,
+ void *__arg, ...);
+ char st[256 * 1024];
+ pid_t p = __clone2 (f, st, sizeof (st), 0, 0);
+#else
+ char st[128 * 1024];
+ pid_t p = clone (f, st + sizeof (st), 0, 0);
+#endif
+ if (p == -1)
+ {
+ printf("clone failed: %m\n");
+ return 1;
+ }
+
+ int e;
+ if (waitpid (p, &e, __WCLONE) != p)
+ {
+ puts ("waitpid failed");
+ kill (p, SIGKILL);
+ return 1;
+ }
+ if (!WIFEXITED (e))
+ {
+ if (WIFSIGNALED (e))
+ printf ("died from signal %s\n", strsignal (WTERMSIG (e)));
+ else
+ puts ("did not terminate correctly");
+ return 1;
+ }
+ if (WEXITSTATUS (e) != 0)
+ ok = false;
+
+ return ok ? 0 : 1;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-align3.c b/test/nptl/tst-align3.c
new file mode 100644
index 000000000..fb0a8e4ec
--- /dev/null
+++ b/test/nptl/tst-align3.c
@@ -0,0 +1,56 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 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 <pthread.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include "tst-stack-align.h"
+
+static bool ok = true;
+static pthread_once_t once = PTHREAD_ONCE_INIT;
+
+static void
+once_test (void)
+{
+ puts ("in once_test");
+
+ if (TEST_STACK_ALIGN ())
+ ok = false;
+}
+
+static int
+do_test (void)
+{
+ puts ("in main");
+
+ if (TEST_STACK_ALIGN ())
+ ok = false;
+
+ if (pthread_once (&once, once_test))
+ {
+ puts ("pthread once failed");
+ return 1;
+ }
+
+ return ok ? 0 : 1;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-atfork1.c b/test/nptl/tst-atfork1.c
new file mode 100644
index 000000000..129893747
--- /dev/null
+++ b/test/nptl/tst-atfork1.c
@@ -0,0 +1,120 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+
+static int val;
+
+
+static void
+prepare1 (void)
+{
+ val *= 2;
+}
+
+static void
+prepare2 (void)
+{
+ ++val;
+}
+
+static void
+parent1 (void)
+{
+ val += 4;
+}
+
+static void
+parent2 (void)
+{
+ val *= 4;
+}
+
+static void
+child1 (void)
+{
+ val += 8;
+}
+
+static void
+child2 (void)
+{
+ val *= 8;
+}
+
+
+static int
+do_test (void)
+{
+ pid_t pid;
+ int status = 0;
+
+ if (pthread_atfork (prepare1, parent1, child1) != 0)
+ {
+ puts ("1st atfork failed");
+ exit (1);
+ }
+ if (pthread_atfork (prepare2, parent2, child2) != 0)
+ {
+ puts ("2nd atfork failed");
+ exit (1);
+ }
+
+ pid = fork ();
+ if (pid == -1)
+ {
+ puts ("fork failed");
+ exit (1);
+ }
+
+ if (pid != 0)
+ {
+ /* Parent. */
+ if (val != 24)
+ {
+ printf ("expected val=%d, got %d\n", 24, val);
+ exit (1);
+ }
+
+ if (TEMP_FAILURE_RETRY (waitpid (pid, &status, 0)) != pid)
+ {
+ puts ("waitpid failed");
+ exit (1);
+ }
+ }
+ else
+ {
+ /* Child. */
+ if (val != 80)
+ {
+ printf ("expected val=%d, got %d\n", 80, val);
+ exit (2);
+ }
+ }
+
+ return status;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-atfork2.c b/test/nptl/tst-atfork2.c
new file mode 100644
index 000000000..1c303de63
--- /dev/null
+++ b/test/nptl/tst-atfork2.c
@@ -0,0 +1,24 @@
+#include <stdio.h>
+#include <unistd.h>
+#include <dlfcn.h>
+
+int main(int argc, char *argv[])
+{
+ void *h;
+ pid_t pid;
+
+ h = dlopen("libatfork.so", RTLD_NOW);
+ if (!h)
+ {
+ printf("Failed to open libatfork.so\n");
+ return 1;
+ }
+ dlclose(h);
+
+ if ((pid = fork()) < 0) {
+ printf("Fork failed\n");
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/test/nptl/tst-attr1.c b/test/nptl/tst-attr1.c
new file mode 100644
index 000000000..987f87ff5
--- /dev/null
+++ b/test/nptl/tst-attr1.c
@@ -0,0 +1,305 @@
+/* Copyright (C) 2003 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 <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+int
+do_test (void)
+{
+ int i;
+ pthread_attr_t a;
+
+ if (pthread_attr_init (&a) != 0)
+ {
+ puts ("attr_init failed");
+ exit (1);
+ }
+
+ pthread_mutexattr_t ma;
+
+ if (pthread_mutexattr_init (&ma) != 0)
+ {
+ puts ("mutexattr_init failed");
+ exit (1);
+ }
+
+ pthread_rwlockattr_t rwa;
+
+ if (pthread_rwlockattr_init (&rwa) != 0)
+ {
+ puts ("rwlockattr_init failed");
+ exit (1);
+ }
+
+ /* XXX Remove if default value is clear. */
+ pthread_attr_setinheritsched (&a, PTHREAD_INHERIT_SCHED);
+ pthread_attr_setschedpolicy (&a, SCHED_OTHER);
+ pthread_attr_setscope (&a, PTHREAD_SCOPE_SYSTEM);
+
+ for (i = 0; i < 10000; ++i)
+ {
+ long int r = random ();
+
+ if (r != PTHREAD_CREATE_DETACHED && r != PTHREAD_CREATE_JOINABLE)
+ {
+ int e = pthread_attr_setdetachstate (&a, r);
+
+ if (e == 0)
+ {
+ printf ("attr_setdetachstate with value %ld succeeded\n", r);
+ exit (1);
+ }
+ if (e != EINVAL)
+ {
+ puts ("attr_setdetachstate didn't return EINVAL");
+ exit (1);
+ }
+
+ int s;
+ if (pthread_attr_getdetachstate (&a, &s) != 0)
+ {
+ puts ("attr_getdetachstate failed");
+ exit (1);
+ }
+
+ if (s != PTHREAD_CREATE_JOINABLE)
+ {
+ printf ("\
+detach state changed to %d by invalid setdetachstate call\n", s);
+ exit (1);
+ }
+ }
+
+ if (r != PTHREAD_INHERIT_SCHED && r != PTHREAD_EXPLICIT_SCHED)
+ {
+ int e = pthread_attr_setinheritsched (&a, r);
+
+ if (e == 0)
+ {
+ printf ("attr_setinheritsched with value %ld succeeded\n", r);
+ exit (1);
+ }
+ if (e != EINVAL)
+ {
+ puts ("attr_setinheritsched didn't return EINVAL");
+ exit (1);
+ }
+
+ int s;
+ if (pthread_attr_getinheritsched (&a, &s) != 0)
+ {
+ puts ("attr_getinheritsched failed");
+ exit (1);
+ }
+
+ if (s != PTHREAD_INHERIT_SCHED)
+ {
+ printf ("\
+inheritsched changed to %d by invalid setinheritsched call\n", s);
+ exit (1);
+ }
+ }
+
+ if (r != SCHED_OTHER && r != SCHED_RR && r != SCHED_FIFO)
+ {
+ int e = pthread_attr_setschedpolicy (&a, r);
+
+ if (e == 0)
+ {
+ printf ("attr_setschedpolicy with value %ld succeeded\n", r);
+ exit (1);
+ }
+ if (e != EINVAL)
+ {
+ puts ("attr_setschedpolicy didn't return EINVAL");
+ exit (1);
+ }
+
+ int s;
+ if (pthread_attr_getschedpolicy (&a, &s) != 0)
+ {
+ puts ("attr_getschedpolicy failed");
+ exit (1);
+ }
+
+ if (s != SCHED_OTHER)
+ {
+ printf ("\
+schedpolicy changed to %d by invalid setschedpolicy call\n", s);
+ exit (1);
+ }
+ }
+
+ if (r != PTHREAD_SCOPE_SYSTEM && r != PTHREAD_SCOPE_PROCESS)
+ {
+ int e = pthread_attr_setscope (&a, r);
+
+ if (e == 0)
+ {
+ printf ("attr_setscope with value %ld succeeded\n", r);
+ exit (1);
+ }
+ if (e != EINVAL)
+ {
+ puts ("attr_setscope didn't return EINVAL");
+ exit (1);
+ }
+
+ int s;
+ if (pthread_attr_getscope (&a, &s) != 0)
+ {
+ puts ("attr_getscope failed");
+ exit (1);
+ }
+
+ if (s != PTHREAD_SCOPE_SYSTEM)
+ {
+ printf ("\
+contentionscope changed to %d by invalid setscope call\n", s);
+ exit (1);
+ }
+ }
+
+ if (r != PTHREAD_PROCESS_PRIVATE && r != PTHREAD_PROCESS_SHARED)
+ {
+ int e = pthread_mutexattr_setpshared (&ma, r);
+
+ if (e == 0)
+ {
+ printf ("mutexattr_setpshared with value %ld succeeded\n", r);
+ exit (1);
+ }
+ if (e != EINVAL)
+ {
+ puts ("mutexattr_setpshared didn't return EINVAL");
+ exit (1);
+ }
+
+ int s;
+ if (pthread_mutexattr_getpshared (&ma, &s) != 0)
+ {
+ puts ("mutexattr_getpshared failed");
+ exit (1);
+ }
+
+ if (s != PTHREAD_PROCESS_PRIVATE)
+ {
+ printf ("\
+pshared changed to %d by invalid mutexattr_setpshared call\n", s);
+ exit (1);
+ }
+
+ e = pthread_rwlockattr_setpshared (&rwa, r);
+
+ if (e == 0)
+ {
+ printf ("rwlockattr_setpshared with value %ld succeeded\n", r);
+ exit (1);
+ }
+ if (e != EINVAL)
+ {
+ puts ("rwlockattr_setpshared didn't return EINVAL");
+ exit (1);
+ }
+
+ if (pthread_rwlockattr_getpshared (&rwa, &s) != 0)
+ {
+ puts ("rwlockattr_getpshared failed");
+ exit (1);
+ }
+
+ if (s != PTHREAD_PROCESS_PRIVATE)
+ {
+ printf ("\
+pshared changed to %d by invalid rwlockattr_setpshared call\n", s);
+ exit (1);
+ }
+ }
+
+ if (r != PTHREAD_CANCEL_ENABLE && r != PTHREAD_CANCEL_DISABLE)
+ {
+ int e = pthread_setcancelstate (r, NULL);
+
+ if (e == 0)
+ {
+ printf ("setcancelstate with value %ld succeeded\n", r);
+ exit (1);
+ }
+
+ if (e != EINVAL)
+ {
+ puts ("setcancelstate didn't return EINVAL");
+ exit (1);
+ }
+
+ int s;
+ if (pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, &s) != 0)
+ {
+ puts ("setcancelstate failed for PTHREAD_CANCEL_ENABLE");
+ exit (1);
+ }
+
+ if (s != PTHREAD_CANCEL_ENABLE)
+ {
+ puts ("invalid setcancelstate changed state");
+ exit (1);
+ }
+ }
+
+ if (r != PTHREAD_CANCEL_DEFERRED && r != PTHREAD_CANCEL_ASYNCHRONOUS)
+ {
+ int e = pthread_setcanceltype (r, NULL);
+
+ if (e == 0)
+ {
+ printf ("setcanceltype with value %ld succeeded\n", r);
+ exit (1);
+ }
+
+ if (e != EINVAL)
+ {
+ puts ("setcanceltype didn't return EINVAL");
+ exit (1);
+ }
+
+ int s;
+ if (pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &s) != 0)
+ {
+ puts ("setcanceltype failed for PTHREAD_CANCEL_DEFERRED");
+ exit (1);
+ }
+
+ if (s != PTHREAD_CANCEL_DEFERRED)
+ {
+ puts ("invalid setcanceltype changed state");
+ exit (1);
+ }
+ }
+ }
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-attr2.c b/test/nptl/tst-attr2.c
new file mode 100644
index 000000000..e8f9cc986
--- /dev/null
+++ b/test/nptl/tst-attr2.c
@@ -0,0 +1,316 @@
+/* Copyright (C) 2003 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 <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+int
+do_test (void)
+{
+ pthread_attr_t a;
+
+ if (pthread_attr_init (&a) != 0)
+ {
+ puts ("attr_init failed");
+ exit (1);
+ }
+
+ /* Check default value of detach state. */
+ int s;
+ if (pthread_attr_getdetachstate (&a, &s) != 0)
+ {
+ puts ("1st attr_getdestachstate failed");
+ exit (1);
+ }
+ if (s != PTHREAD_CREATE_JOINABLE)
+ {
+ printf ("\
+default detach state wrong: %d, expected %d (PTHREAD_CREATE_JOINABLE)\n",
+ s, PTHREAD_CREATE_JOINABLE);
+ exit (1);
+ }
+
+ int e = pthread_attr_setdetachstate (&a, PTHREAD_CREATE_DETACHED);
+ if (e != 0)
+ {
+ puts ("1st attr_setdetachstate failed");
+ exit (1);
+ }
+ if (pthread_attr_getdetachstate (&a, &s) != 0)
+ {
+ puts ("2nd attr_getdestachstate failed");
+ exit (1);
+ }
+ if (s != PTHREAD_CREATE_DETACHED)
+ {
+ puts ("PTHREAD_CREATE_DETACHED set, but not given back");
+ exit (1);
+ }
+
+ e = pthread_attr_setdetachstate (&a, PTHREAD_CREATE_JOINABLE);
+ if (e != 0)
+ {
+ puts ("2nd attr_setdetachstate failed");
+ exit (1);
+ }
+ if (pthread_attr_getdetachstate (&a, &s) != 0)
+ {
+ puts ("3rd attr_getdestachstate failed");
+ exit (1);
+ }
+ if (s != PTHREAD_CREATE_JOINABLE)
+ {
+ puts ("PTHREAD_CREATE_JOINABLE set, but not given back");
+ exit (1);
+ }
+
+
+ size_t g;
+ if (pthread_attr_getguardsize (&a, &g) != 0)
+ {
+ puts ("1st attr_getguardsize failed");
+ exit (1);
+ }
+ if (g != (size_t) sysconf (_SC_PAGESIZE))
+ {
+ printf ("default guardsize %zu, expected %ld (PAGESIZE)\n",
+ g, sysconf (_SC_PAGESIZE));
+ exit (1);
+ }
+
+ e = pthread_attr_setguardsize (&a, 0);
+ if (e != 0)
+ {
+ puts ("1st attr_setguardsize failed");
+ exit (1);
+ }
+ if (pthread_attr_getguardsize (&a, &g) != 0)
+ {
+ puts ("2nd attr_getguardsize failed");
+ exit (1);
+ }
+ if (g != 0)
+ {
+ printf ("guardsize set to zero but %zu returned\n", g);
+ exit (1);
+ }
+
+ e = pthread_attr_setguardsize (&a, 1);
+ if (e != 0)
+ {
+ puts ("2nd attr_setguardsize failed");
+ exit (1);
+ }
+ if (pthread_attr_getguardsize (&a, &g) != 0)
+ {
+ puts ("3rd attr_getguardsize failed");
+ exit (1);
+ }
+ if (g != 1)
+ {
+ printf ("guardsize set to 1 but %zu returned\n", g);
+ exit (1);
+ }
+
+
+ if (pthread_attr_getinheritsched (&a, &s) != 0)
+ {
+ puts ("1st attr_getinheritsched failed");
+ exit (1);
+ }
+ /* XXX What is the correct default value. */
+ if (s != PTHREAD_INHERIT_SCHED && s != PTHREAD_EXPLICIT_SCHED)
+ {
+ puts ("incorrect default value for inheritsched");
+ exit (1);
+ }
+
+ e = pthread_attr_setinheritsched (&a, PTHREAD_EXPLICIT_SCHED);
+ if (e != 0)
+ {
+ puts ("1st attr_setinheritsched failed");
+ exit (1);
+ }
+ if (pthread_attr_getinheritsched (&a, &s) != 0)
+ {
+ puts ("2nd attr_getinheritsched failed");
+ exit (1);
+ }
+ if (s != PTHREAD_EXPLICIT_SCHED)
+ {
+ printf ("inheritsched set to PTHREAD_EXPLICIT_SCHED, but got %d\n", s);
+ exit (1);
+ }
+
+ e = pthread_attr_setinheritsched (&a, PTHREAD_INHERIT_SCHED);
+ if (e != 0)
+ {
+ puts ("2nd attr_setinheritsched failed");
+ exit (1);
+ }
+ if (pthread_attr_getinheritsched (&a, &s) != 0)
+ {
+ puts ("3rd attr_getinheritsched failed");
+ exit (1);
+ }
+ if (s != PTHREAD_INHERIT_SCHED)
+ {
+ printf ("inheritsched set to PTHREAD_INHERIT_SCHED, but got %d\n", s);
+ exit (1);
+ }
+
+
+ if (pthread_attr_getschedpolicy (&a, &s) != 0)
+ {
+ puts ("1st attr_getschedpolicy failed");
+ exit (1);
+ }
+ /* XXX What is the correct default value. */
+ if (s != SCHED_OTHER && s != SCHED_FIFO && s != SCHED_RR)
+ {
+ puts ("incorrect default value for schedpolicy");
+ exit (1);
+ }
+
+ e = pthread_attr_setschedpolicy (&a, SCHED_RR);
+ if (e != 0)
+ {
+ puts ("1st attr_setschedpolicy failed");
+ exit (1);
+ }
+ if (pthread_attr_getschedpolicy (&a, &s) != 0)
+ {
+ puts ("2nd attr_getschedpolicy failed");
+ exit (1);
+ }
+ if (s != SCHED_RR)
+ {
+ printf ("schedpolicy set to SCHED_RR, but got %d\n", s);
+ exit (1);
+ }
+
+ e = pthread_attr_setschedpolicy (&a, SCHED_FIFO);
+ if (e != 0)
+ {
+ puts ("2nd attr_setschedpolicy failed");
+ exit (1);
+ }
+ if (pthread_attr_getschedpolicy (&a, &s) != 0)
+ {
+ puts ("3rd attr_getschedpolicy failed");
+ exit (1);
+ }
+ if (s != SCHED_FIFO)
+ {
+ printf ("schedpolicy set to SCHED_FIFO, but got %d\n", s);
+ exit (1);
+ }
+
+ e = pthread_attr_setschedpolicy (&a, SCHED_OTHER);
+ if (e != 0)
+ {
+ puts ("3rd attr_setschedpolicy failed");
+ exit (1);
+ }
+ if (pthread_attr_getschedpolicy (&a, &s) != 0)
+ {
+ puts ("4th attr_getschedpolicy failed");
+ exit (1);
+ }
+ if (s != SCHED_OTHER)
+ {
+ printf ("schedpolicy set to SCHED_OTHER, but got %d\n", s);
+ exit (1);
+ }
+
+
+ if (pthread_attr_getscope (&a, &s) != 0)
+ {
+ puts ("1st attr_getscope failed");
+ exit (1);
+ }
+ /* XXX What is the correct default value. */
+ if (s != PTHREAD_SCOPE_SYSTEM && s != PTHREAD_SCOPE_PROCESS)
+ {
+ puts ("incorrect default value for contentionscope");
+ exit (1);
+ }
+
+ e = pthread_attr_setscope (&a, PTHREAD_SCOPE_PROCESS);
+ if (e != ENOTSUP)
+ {
+ if (e != 0)
+ {
+ puts ("1st attr_setscope failed");
+ exit (1);
+ }
+ if (pthread_attr_getscope (&a, &s) != 0)
+ {
+ puts ("2nd attr_getscope failed");
+ exit (1);
+ }
+ if (s != PTHREAD_SCOPE_PROCESS)
+ {
+ printf ("\
+contentionscope set to PTHREAD_SCOPE_PROCESS, but got %d\n", s);
+ exit (1);
+ }
+ }
+
+ e = pthread_attr_setscope (&a, PTHREAD_SCOPE_SYSTEM);
+ if (e != 0)
+ {
+ puts ("2nd attr_setscope failed");
+ exit (1);
+ }
+ if (pthread_attr_getscope (&a, &s) != 0)
+ {
+ puts ("3rd attr_getscope failed");
+ exit (1);
+ }
+ if (s != PTHREAD_SCOPE_SYSTEM)
+ {
+ printf ("contentionscope set to PTHREAD_SCOPE_SYSTEM, but got %d\n", s);
+ exit (1);
+ }
+
+ char buf[1];
+ e = pthread_attr_setstack (&a, buf, 1);
+ if (e != EINVAL)
+ {
+ puts ("setstack with size 1 did not produce EINVAL");
+ exit (1);
+ }
+
+ e = pthread_attr_setstacksize (&a, 1);
+ if (e != EINVAL)
+ {
+ puts ("setstacksize with size 1 did not produce EINVAL");
+ exit (1);
+ }
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-attr3.c b/test/nptl/tst-attr3.c
new file mode 100644
index 000000000..5ccf9abba
--- /dev/null
+++ b/test/nptl/tst-attr3.c
@@ -0,0 +1,419 @@
+/* pthread_getattr_np test.
+ Copyright (C) 2003, 2004 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/>. */
+
+#include <errno.h>
+#include <error.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+static void *
+tf (void *arg)
+{
+ pthread_attr_t a, *ap, a2;
+ int err;
+ void *result = NULL;
+
+ if (arg == NULL)
+ {
+ ap = &a2;
+ err = pthread_attr_init (ap);
+ if (err)
+ {
+ error (0, err, "pthread_attr_init failed");
+ return tf;
+ }
+ }
+ else
+ ap = (pthread_attr_t *) arg;
+
+ err = pthread_getattr_np (pthread_self (), &a);
+ if (err)
+ {
+ error (0, err, "pthread_getattr_np failed");
+ result = tf;
+ }
+
+ int detachstate1, detachstate2;
+ err = pthread_attr_getdetachstate (&a, &detachstate1);
+ if (err)
+ {
+ error (0, err, "pthread_attr_getdetachstate failed");
+ result = tf;
+ }
+ else
+ {
+ err = pthread_attr_getdetachstate (ap, &detachstate2);
+ if (err)
+ {
+ error (0, err, "pthread_attr_getdetachstate failed");
+ result = tf;
+ }
+ else if (detachstate1 != detachstate2)
+ {
+ error (0, 0, "detachstate differs %d != %d",
+ detachstate1, detachstate2);
+ result = tf;
+ }
+ }
+
+ void *stackaddr;
+ size_t stacksize;
+ err = pthread_attr_getstack (&a, &stackaddr, &stacksize);
+ if (err)
+ {
+ error (0, err, "pthread_attr_getstack failed");
+ result = tf;
+ }
+ else if ((void *) &a < stackaddr
+ || (void *) &a >= stackaddr + stacksize)
+ {
+ error (0, 0, "pthread_attr_getstack returned range does not cover thread's stack");
+ result = tf;
+ }
+ else
+ printf ("thread stack %p-%p (0x%zx)\n", stackaddr, stackaddr + stacksize,
+ stacksize);
+
+ size_t guardsize1, guardsize2;
+ err = pthread_attr_getguardsize (&a, &guardsize1);
+ if (err)
+ {
+ error (0, err, "pthread_attr_getguardsize failed");
+ result = tf;
+ }
+ else
+ {
+ err = pthread_attr_getguardsize (ap, &guardsize2);
+ if (err)
+ {
+ error (0, err, "pthread_attr_getguardsize failed");
+ result = tf;
+ }
+ else if (guardsize1 != guardsize2)
+ {
+ error (0, 0, "guardsize differs %zd != %zd",
+ guardsize1, guardsize2);
+ result = tf;
+ }
+ else
+ printf ("thread guardsize %zd\n", guardsize1);
+ }
+
+ int scope1, scope2;
+ err = pthread_attr_getscope (&a, &scope1);
+ if (err)
+ {
+ error (0, err, "pthread_attr_getscope failed");
+ result = tf;
+ }
+ else
+ {
+ err = pthread_attr_getscope (ap, &scope2);
+ if (err)
+ {
+ error (0, err, "pthread_attr_getscope failed");
+ result = tf;
+ }
+ else if (scope1 != scope2)
+ {
+ error (0, 0, "scope differs %d != %d",
+ scope1, scope2);
+ result = tf;
+ }
+ }
+
+ int inheritsched1, inheritsched2;
+ err = pthread_attr_getinheritsched (&a, &inheritsched1);
+ if (err)
+ {
+ error (0, err, "pthread_attr_getinheritsched failed");
+ result = tf;
+ }
+ else
+ {
+ err = pthread_attr_getinheritsched (ap, &inheritsched2);
+ if (err)
+ {
+ error (0, err, "pthread_attr_getinheritsched failed");
+ result = tf;
+ }
+ else if (inheritsched1 != inheritsched2)
+ {
+ error (0, 0, "inheritsched differs %d != %d",
+ inheritsched1, inheritsched2);
+ result = tf;
+ }
+ }
+
+ cpu_set_t c1, c2;
+ err = pthread_getaffinity_np (pthread_self (), sizeof (c1), &c1);
+ if (err == 0)
+ {
+ err = pthread_attr_getaffinity_np (&a, sizeof (c2), &c2);
+ if (err)
+ {
+ error (0, err, "pthread_attr_getaffinity_np failed");
+ result = tf;
+ }
+ else if (memcmp (&c1, &c2, sizeof (c1)))
+ {
+ error (0, 0, "pthread_attr_getaffinity_np returned different CPU mask than pthread_getattr_np");
+ result = tf;
+ }
+ }
+
+ err = pthread_attr_destroy (&a);
+ if (err)
+ {
+ error (0, err, "pthread_attr_destroy failed");
+ result = tf;
+ }
+
+ if (ap == &a2)
+ {
+ err = pthread_attr_destroy (ap);
+ if (err)
+ {
+ error (0, err, "pthread_attr_destroy failed");
+ result = tf;
+ }
+ }
+
+ return result;
+}
+
+
+static int
+do_test (void)
+{
+ int result = 0;
+ pthread_attr_t a;
+ cpu_set_t c1, c2;
+
+ int err = pthread_attr_init (&a);
+ if (err)
+ {
+ error (0, err, "pthread_attr_init failed");
+ result = 1;
+ }
+
+ err = pthread_attr_getaffinity_np (&a, sizeof (c1), &c1);
+ if (err && err != ENOSYS)
+ {
+ error (0, err, "pthread_attr_getaffinity_np failed");
+ result = 1;
+ }
+
+ err = pthread_attr_destroy (&a);
+ if (err)
+ {
+ error (0, err, "pthread_attr_destroy failed");
+ result = 1;
+ }
+
+ err = pthread_getattr_np (pthread_self (), &a);
+ if (err)
+ {
+ error (0, err, "pthread_getattr_np failed");
+ result = 1;
+ }
+
+ int detachstate;
+ err = pthread_attr_getdetachstate (&a, &detachstate);
+ if (err)
+ {
+ error (0, err, "pthread_attr_getdetachstate failed");
+ result = 1;
+ }
+ else if (detachstate != PTHREAD_CREATE_JOINABLE)
+ {
+ error (0, 0, "initial thread not joinable");
+ result = 1;
+ }
+
+ void *stackaddr;
+ size_t stacksize;
+ err = pthread_attr_getstack (&a, &stackaddr, &stacksize);
+ if (err)
+ {
+ error (0, err, "pthread_attr_getstack failed");
+ result = 1;
+ }
+ else if ((void *) &a < stackaddr
+ || (void *) &a >= stackaddr + stacksize)
+ {
+ error (0, 0, "pthread_attr_getstack returned range does not cover main's stack");
+ result = 1;
+ }
+ else
+ printf ("initial thread stack %p-%p (0x%zx)\n", stackaddr,
+ stackaddr + stacksize, stacksize);
+
+ size_t guardsize;
+ err = pthread_attr_getguardsize (&a, &guardsize);
+ if (err)
+ {
+ error (0, err, "pthread_attr_getguardsize failed");
+ result = 1;
+ }
+ else if (guardsize != 0)
+ {
+ error (0, 0, "pthread_attr_getguardsize returned %zd != 0",
+ guardsize);
+ result = 1;
+ }
+
+ int scope;
+ err = pthread_attr_getscope (&a, &scope);
+ if (err)
+ {
+ error (0, err, "pthread_attr_getscope failed");
+ result = 1;
+ }
+ else if (scope != PTHREAD_SCOPE_SYSTEM)
+ {
+ error (0, 0, "pthread_attr_getscope returned %d != PTHREAD_SCOPE_SYSTEM",
+ scope);
+ result = 1;
+ }
+
+ int inheritsched;
+ err = pthread_attr_getinheritsched (&a, &inheritsched);
+ if (err)
+ {
+ error (0, err, "pthread_attr_getinheritsched failed");
+ result = 1;
+ }
+ else if (inheritsched != PTHREAD_INHERIT_SCHED)
+ {
+ error (0, 0, "pthread_attr_getinheritsched returned %d != PTHREAD_INHERIT_SCHED",
+ inheritsched);
+ result = 1;
+ }
+
+ err = pthread_getaffinity_np (pthread_self (), sizeof (c1), &c1);
+ if (err == 0)
+ {
+ err = pthread_attr_getaffinity_np (&a, sizeof (c2), &c2);
+ if (err)
+ {
+ error (0, err, "pthread_attr_getaffinity_np failed");
+ result = 1;
+ }
+ else if (memcmp (&c1, &c2, sizeof (c1)))
+ {
+ error (0, 0, "pthread_attr_getaffinity_np returned different CPU mask than pthread_getattr_np");
+ result = 1;
+ }
+ }
+
+ err = pthread_attr_destroy (&a);
+ if (err)
+ {
+ error (0, err, "pthread_attr_destroy failed");
+ result = 1;
+ }
+
+ pthread_t th;
+ err = pthread_create (&th, NULL, tf, NULL);
+ if (err)
+ {
+ error (0, err, "pthread_create #1 failed");
+ result = 1;
+ }
+ else
+ {
+ void *ret;
+ err = pthread_join (th, &ret);
+ if (err)
+ {
+ error (0, err, "pthread_join #1 failed");
+ result = 1;
+ }
+ else if (ret != NULL)
+ result = 1;
+ }
+
+ err = pthread_attr_init (&a);
+ if (err)
+ {
+ error (0, err, "pthread_attr_init failed");
+ result = 1;
+ }
+
+ err = pthread_create (&th, &a, tf, &a);
+ if (err)
+ {
+ error (0, err, "pthread_create #2 failed");
+ result = 1;
+ }
+ else
+ {
+ void *ret;
+ err = pthread_join (th, &ret);
+ if (err)
+ {
+ error (0, err, "pthread_join #2 failed");
+ result = 1;
+ }
+ else if (ret != NULL)
+ result = 1;
+ }
+
+ err = pthread_attr_setguardsize (&a, 16 * sysconf (_SC_PAGESIZE));
+ if (err)
+ {
+ error (0, err, "pthread_attr_setguardsize failed");
+ result = 1;
+ }
+
+ err = pthread_create (&th, &a, tf, &a);
+ if (err)
+ {
+ error (0, err, "pthread_create #3 failed");
+ result = 1;
+ }
+ else
+ {
+ void *ret;
+ err = pthread_join (th, &ret);
+ if (err)
+ {
+ error (0, err, "pthread_join #3 failed");
+ result = 1;
+ }
+ else if (ret != NULL)
+ result = 1;
+ }
+
+ err = pthread_attr_destroy (&a);
+ if (err)
+ {
+ error (0, err, "pthread_attr_destroy failed");
+ result = 1;
+ }
+
+ return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-barrier1.c b/test/nptl/tst-barrier1.c
new file mode 100644
index 000000000..4e396c97a
--- /dev/null
+++ b/test/nptl/tst-barrier1.c
@@ -0,0 +1,70 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+
+
+static int
+do_test (void)
+{
+ pthread_barrier_t b;
+ int e;
+ int cnt;
+
+ e = pthread_barrier_init (&b, NULL, 0);
+ if (e == 0)
+ {
+ puts ("barrier_init with count 0 succeeded");
+ return 1;
+ }
+ if (e != EINVAL)
+ {
+ puts ("barrier_init with count 0 didn't return EINVAL");
+ return 1;
+ }
+
+ if (pthread_barrier_init (&b, NULL, 1) != 0)
+ {
+ puts ("real barrier_init failed");
+ return 1;
+ }
+
+ for (cnt = 0; cnt < 10; ++cnt)
+ {
+ e = pthread_barrier_wait (&b);
+
+ if (e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait didn't return PTHREAD_BARRIER_SERIAL_THREAD");
+ return 1;
+ }
+ }
+
+ if (pthread_barrier_destroy (&b) != 0)
+ {
+ puts ("barrier_destroy failed");
+ return 1;
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-barrier2.c b/test/nptl/tst-barrier2.c
new file mode 100644
index 000000000..8ffcda063
--- /dev/null
+++ b/test/nptl/tst-barrier2.c
@@ -0,0 +1,184 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <pthread.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+
+
+static int
+do_test (void)
+{
+ size_t ps = sysconf (_SC_PAGESIZE);
+ char tmpfname[] = "/tmp/tst-barrier2.XXXXXX";
+ char data[ps];
+ void *mem;
+ int fd;
+ pthread_barrier_t *b;
+ pthread_barrierattr_t a;
+ pid_t pid;
+ int serials = 0;
+ int cnt;
+ int status;
+ int p;
+
+ fd = mkstemp (tmpfname);
+ if (fd == -1)
+ {
+ printf ("cannot open temporary file: %m\n");
+ return 1;
+ }
+
+ /* Make sure it is always removed. */
+ unlink (tmpfname);
+
+ /* Create one page of data. */
+ memset (data, '\0', ps);
+
+ /* Write the data to the file. */
+ if (write (fd, data, ps) != (ssize_t) ps)
+ {
+ puts ("short write");
+ return 1;
+ }
+
+ mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ if (mem == MAP_FAILED)
+ {
+ printf ("mmap failed: %m\n");
+ return 1;
+ }
+
+ b = (pthread_barrier_t *) (((uintptr_t) mem + __alignof (pthread_barrier_t))
+ & ~(__alignof (pthread_barrier_t) - 1));
+
+ if (pthread_barrierattr_init (&a) != 0)
+ {
+ puts ("barrierattr_init failed");
+ return 1;
+ }
+
+ if (pthread_barrierattr_getpshared (&a, &p) != 0)
+ {
+ puts ("1st barrierattr_getpshared failed");
+ return 1;
+ }
+
+ if (p != PTHREAD_PROCESS_PRIVATE)
+ {
+ puts ("default pshared value wrong");
+ return 1;
+ }
+
+ if (pthread_barrierattr_setpshared (&a, PTHREAD_PROCESS_SHARED) != 0)
+ {
+ puts ("barrierattr_setpshared failed");
+ return 1;
+ }
+
+ if (pthread_barrierattr_getpshared (&a, &p) != 0)
+ {
+ puts ("2nd barrierattr_getpshared failed");
+ return 1;
+ }
+
+ if (p != PTHREAD_PROCESS_SHARED)
+ {
+ puts ("pshared value after setpshared call wrong");
+ return 1;
+ }
+
+ if (pthread_barrier_init (b, &a, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ return 1;
+ }
+
+ if (pthread_barrierattr_destroy (&a) != 0)
+ {
+ puts ("barrierattr_destroy failed");
+ return 1;
+ }
+
+ puts ("going to fork now");
+ pid = fork ();
+ if (pid == -1)
+ {
+ puts ("fork failed");
+ return 1;
+ }
+
+ /* Just to be sure we don't hang forever. */
+ alarm (4);
+
+#define N 30
+ for (cnt = 0; cnt < N; ++cnt)
+ {
+ int e;
+
+ e = pthread_barrier_wait (b);
+ if (e == PTHREAD_BARRIER_SERIAL_THREAD)
+ ++serials;
+ else if (e != 0)
+ {
+ printf ("%s: barrier_wait returned value %d != 0 and PTHREAD_BARRIER_SERIAL_THREAD\n",
+ pid == 0 ? "child" : "parent", e);
+ return 1;
+ }
+ }
+
+ alarm (0);
+
+ printf ("%s: was %d times the serial thread\n",
+ pid == 0 ? "child" : "parent", serials);
+
+ if (pid == 0)
+ /* The child. Pass the number of times we had the serializing
+ thread back to the parent. */
+ exit (serials);
+
+ if (waitpid (pid, &status, 0) != pid)
+ {
+ puts ("waitpid failed");
+ return 1;
+ }
+
+ if (!WIFEXITED (status))
+ {
+ puts ("child exited abnormally");
+ return 1;
+ }
+
+ if (WEXITSTATUS (status) + serials != N)
+ {
+ printf ("total number of serials is %d, expected %d\n",
+ WEXITSTATUS (status) + serials, N);
+ return 1;
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-barrier3.c b/test/nptl/tst-barrier3.c
new file mode 100644
index 000000000..9c4e2b25f
--- /dev/null
+++ b/test/nptl/tst-barrier3.c
@@ -0,0 +1,153 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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/>. */
+
+/* Test of POSIX barriers. */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define NTHREADS 20
+
+#define ROUNDS 20
+
+static pthread_barrier_t barriers[NTHREADS];
+
+static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+static int counters[NTHREADS];
+static int serial[NTHREADS];
+
+static void *
+worker (void *arg)
+{
+ void *result = NULL;
+ int nr = (long int) arg;
+ int i;
+
+ for (i = 0; i < ROUNDS; ++i)
+ {
+ int j;
+ int retval;
+
+ if (nr == 0)
+ {
+ memset (counters, '\0', sizeof (counters));
+ memset (serial, '\0', sizeof (serial));
+ }
+
+ retval = pthread_barrier_wait (&barriers[NTHREADS - 1]);
+ if (retval != 0 && retval != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("thread %d failed to wait for all the others\n", nr);
+ result = (void *) 1;
+ }
+
+ for (j = nr; j < NTHREADS; ++j)
+ {
+ /* Increment the counter for this round. */
+ pthread_mutex_lock (&lock);
+ ++counters[j];
+ pthread_mutex_unlock (&lock);
+
+ /* Wait for the rest. */
+ retval = pthread_barrier_wait (&barriers[j]);
+
+ /* Test the result. */
+ if (nr == 0 && counters[j] != j + 1)
+ {
+ printf ("barrier in round %d released but count is %d\n",
+ j, counters[j]);
+ result = (void *) 1;
+ }
+
+ if (retval != 0)
+ {
+ if (retval != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("thread %d in round %d has nonzero return value != PTHREAD_BARRIER_SERIAL_THREAD\n",
+ nr, j);
+ result = (void *) 1;
+ }
+ else
+ {
+ pthread_mutex_lock (&lock);
+ ++serial[j];
+ pthread_mutex_unlock (&lock);
+ }
+ }
+
+ /* Wait for the rest again. */
+ retval = pthread_barrier_wait (&barriers[j]);
+
+ /* Now we can check whether exactly one thread was serializing. */
+ if (nr == 0 && serial[j] != 1)
+ {
+ printf ("not exactly one serial thread in round %d\n", j);
+ result = (void *) 1;
+ }
+ }
+ }
+
+ return result;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#define TIMEOUT 60
+static int
+do_test (void)
+{
+ pthread_t threads[NTHREADS];
+ int i;
+ void *res;
+ int result = 0;
+
+ /* Initialized the barrier variables. */
+ for (i = 0; i < NTHREADS; ++i)
+ if (pthread_barrier_init (&barriers[i], NULL, i + 1) != 0)
+ {
+ printf ("Failed to initialize barrier %d\n", i);
+ exit (1);
+ }
+
+ /* Start the threads. */
+ for (i = 0; i < NTHREADS; ++i)
+ if (pthread_create (&threads[i], NULL, worker, (void *) (long int) i) != 0)
+ {
+ printf ("Failed to start thread %d\n", i);
+ exit (1);
+ }
+
+ /* And wait for them. */
+ for (i = 0; i < NTHREADS; ++i)
+ if (pthread_join (threads[i], &res) != 0 || res != NULL)
+ {
+ printf ("thread %d returned a failure\n", i);
+ result = 1;
+ }
+ else
+ printf ("joined threads %d\n", i);
+
+ if (result == 0)
+ puts ("all OK");
+
+ return result;
+}
+
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-barrier4.c b/test/nptl/tst-barrier4.c
new file mode 100644
index 000000000..cad9fb727
--- /dev/null
+++ b/test/nptl/tst-barrier4.c
@@ -0,0 +1,121 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
+
+ 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 a test for behavior not guaranteed by POSIX. */
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static pthread_barrier_t b1;
+static pthread_barrier_t b2;
+
+
+#define N 20
+
+static void *
+tf (void *arg)
+{
+ int round = 0;
+
+ while (round++ < 30)
+ {
+ if (pthread_barrier_wait (&b1) == PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ pthread_barrier_destroy (&b1);
+ if (pthread_barrier_init (&b1, NULL, N) != 0)
+ {
+ puts ("tf: 1st barrier_init failed");
+ exit (1);
+ }
+ }
+
+ if (pthread_barrier_wait (&b2) == PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ pthread_barrier_destroy (&b2);
+ if (pthread_barrier_init (&b2, NULL, N) != 0)
+ {
+ puts ("tf: 2nd barrier_init failed");
+ exit (1);
+ }
+ }
+ }
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ pthread_attr_t at;
+ int cnt;
+
+ if (pthread_attr_init (&at) != 0)
+ {
+ puts ("attr_init failed");
+ return 1;
+ }
+
+ if (pthread_attr_setstacksize (&at, 1 * 1024 * 1024) != 0)
+ {
+ puts ("attr_setstacksize failed");
+ return 1;
+ }
+
+ if (pthread_barrier_init (&b1, NULL, N) != 0)
+ {
+ puts ("1st barrier_init failed");
+ return 1;
+ }
+
+ if (pthread_barrier_init (&b2, NULL, N) != 0)
+ {
+ puts ("2nd barrier_init failed");
+ return 1;
+ }
+
+ pthread_t th[N - 1];
+ for (cnt = 0; cnt < N - 1; ++cnt)
+ if (pthread_create (&th[cnt], &at, tf, NULL) != 0)
+ {
+ puts ("pthread_create failed");
+ return 1;
+ }
+
+ if (pthread_attr_destroy (&at) != 0)
+ {
+ puts ("attr_destroy failed");
+ return 1;
+ }
+
+ tf (NULL);
+
+ for (cnt = 0; cnt < N - 1; ++cnt)
+ if (pthread_join (th[cnt], NULL) != 0)
+ {
+ puts ("pthread_join failed");
+ return 1;
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-basic1.c b/test/nptl/tst-basic1.c
new file mode 100644
index 000000000..748bbb7f0
--- /dev/null
+++ b/test/nptl/tst-basic1.c
@@ -0,0 +1,81 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+
+static pid_t pid;
+
+static void *
+tf (void *a)
+{
+ if (getpid () != pid)
+ {
+ write (2, "pid mismatch\n", 13);
+ _exit (1);
+ }
+
+ return a;
+}
+
+
+int
+do_test (void)
+{
+ pid = getpid ();
+
+#define N 2
+ pthread_t t[N];
+ int i;
+
+ for (i = 0; i < N; ++i)
+ if (pthread_create (&t[i], NULL, tf, (void *) (long int) (i + 1)) != 0)
+ {
+ write (2, "create failed\n", 14);
+ _exit (1);
+ }
+ else
+ printf ("created thread %d\n", i);
+
+ for (i = 0; i < N; ++i)
+ {
+ void *r;
+ int e;
+ if ((e = pthread_join (t[i], &r)) != 0)
+ {
+ printf ("join failed: %d\n", e);
+ _exit (1);
+ }
+ else if (r != (void *) (long int) (i + 1))
+ {
+ write (2, "result wrong\n", 13);
+ _exit (1);
+ }
+ else
+ printf ("joined thread %d\n", i);
+ }
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-basic2.c b/test/nptl/tst-basic2.c
new file mode 100644
index 000000000..58ed6ac53
--- /dev/null
+++ b/test/nptl/tst-basic2.c
@@ -0,0 +1,120 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+#define N 20
+
+static pthread_t th[N];
+static pthread_mutex_t lock[N];
+
+
+static void *tf (void *a)
+{
+ uintptr_t idx = (uintptr_t) a;
+
+ pthread_mutex_lock (&lock[idx]);
+
+ return pthread_equal (pthread_self (), th[idx]) ? NULL : (void *) 1l;
+}
+
+
+int
+do_test (void)
+{
+ if (pthread_equal (pthread_self (), pthread_self ()) == 0)
+ {
+ puts ("pthread_equal (pthread_self (), pthread_self ()) failed");
+ exit (1);
+ }
+
+ pthread_attr_t at;
+
+ if (pthread_attr_init (&at) != 0)
+ {
+ puts ("attr_init failed");
+ return 1;
+ }
+
+ if (pthread_attr_setstacksize (&at, 1 * 1024 * 1024) != 0)
+ {
+ puts ("attr_setstacksize failed");
+ return 1;
+ }
+
+ int i;
+ for (i = 0; i < N; ++i)
+ {
+ if (pthread_mutex_init (&lock[i], NULL) != 0)
+ {
+ puts ("mutex_init failed");
+ exit (1);
+ }
+
+ if (pthread_mutex_lock (&lock[i]) != 0)
+ {
+ puts ("mutex_lock failed");
+ exit (1);
+ }
+
+ if (pthread_create (&th[i], &at, tf, (void *) (long int) i) != 0)
+ {
+ puts ("create failed");
+ exit (1);
+ }
+
+ if (pthread_mutex_unlock (&lock[i]) != 0)
+ {
+ puts ("mutex_unlock failed");
+ exit (1);
+ }
+
+ printf ("created thread %d\n", i);
+ }
+
+ if (pthread_attr_destroy (&at) != 0)
+ {
+ puts ("attr_destroy failed");
+ return 1;
+ }
+
+ int result = 0;
+ for (i = 0; i < N; ++i)
+ {
+ void *r;
+ int e;
+ if ((e = pthread_join (th[i], &r)) != 0)
+ {
+ printf ("join failed: %d\n", e);
+ _exit (1);
+ }
+ else if (r != NULL)
+ result = 1;
+ }
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-basic3.c b/test/nptl/tst-basic3.c
new file mode 100644
index 000000000..a3e2603bd
--- /dev/null
+++ b/test/nptl/tst-basic3.c
@@ -0,0 +1,86 @@
+/* Copyright (C) 2003 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 <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static int nrunning = 1;
+
+
+static void
+final_test (void)
+{
+ puts ("final_test has been called");
+
+#define THE_SIGNAL SIGUSR1
+ kill (getpid (), SIGUSR1);
+}
+
+
+static void *
+tf (void *a)
+{
+ if (pthread_join ((pthread_t) a, NULL) != 0)
+ {
+ printf ("join failed while %d are running\n", nrunning);
+ _exit (1);
+ }
+
+ printf ("%2d left\n", --nrunning);
+
+ return NULL;
+}
+
+
+int
+do_test (void)
+{
+#define N 20
+ pthread_t t[N];
+ pthread_t last = pthread_self ();
+ int i;
+
+ atexit (final_test);
+
+ printf ("starting %d + 1 threads\n", N);
+ for (i = 0; i < N; ++i)
+ {
+ if (pthread_create (&t[i], NULL, tf, (void *) last) != 0)
+ {
+ puts ("create failed");
+ _exit (1);
+ }
+
+ ++nrunning;
+
+ last = t[i];
+ }
+
+ printf ("%2d left\n", --nrunning);
+
+ pthread_exit (NULL);
+}
+
+
+#define EXPECTED_SIGNAL THE_SIGNAL
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-basic4.c b/test/nptl/tst-basic4.c
new file mode 100644
index 000000000..b69ca200b
--- /dev/null
+++ b/test/nptl/tst-basic4.c
@@ -0,0 +1,100 @@
+/* Copyright (C) 2003 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 <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+
+static void
+final_test (void)
+{
+ puts ("final_test has been called");
+
+#define THE_SIGNAL SIGUSR1
+ kill (getpid (), SIGUSR1);
+}
+
+
+static void *
+tf (void *a)
+{
+ pid_t pid = fork ();
+ if (pid == -1)
+ {
+ puts ("fork failed");
+ exit (1);
+ }
+
+ if (pid == 0)
+ {
+ atexit (final_test);
+
+ pthread_exit (NULL);
+ }
+
+ int r;
+ int e = TEMP_FAILURE_RETRY (waitpid (pid, &r, 0));
+ if (e != pid)
+ {
+ puts ("waitpid failed");
+ exit (1);
+ }
+
+ if (! WIFSIGNALED (r))
+ {
+ puts ("child not signled");
+ exit (1);
+ }
+
+ if (WTERMSIG (r) != THE_SIGNAL)
+ {
+ puts ("child's termination signal wrong");
+ exit (1);
+ }
+
+ return NULL;
+}
+
+
+int
+do_test (void)
+{
+ pthread_t th;
+
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ _exit (1);
+ }
+
+ if (pthread_join (th, NULL) != 0)
+ {
+ puts ("join failed");
+ exit (1);
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-basic5.c b/test/nptl/tst-basic5.c
new file mode 100644
index 000000000..76b59096e
--- /dev/null
+++ b/test/nptl/tst-basic5.c
@@ -0,0 +1,73 @@
+/* Copyright (C) 2003 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 <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+
+int
+do_test (void)
+{
+ int c = pthread_getconcurrency ();
+ if (c != 0)
+ {
+ puts ("initial concurrencylevel wrong");
+ exit (1);
+ }
+
+ if (pthread_setconcurrency (1) != 0)
+ {
+ puts ("setconcurrency failed");
+ exit (1);
+ }
+
+ c = pthread_getconcurrency ();
+ if (c != 1)
+ {
+ puts ("getconcurrency didn't return the value previous set");
+ exit (1);
+ }
+
+ int e = pthread_setconcurrency (-1);
+ if (e == 0)
+ {
+ puts ("setconcurrency of negative value didn't failed");
+ exit (1);
+ }
+ if (e != EINVAL)
+ {
+ puts ("setconcurrency didn't return EINVAL for negative value");
+ exit (1);
+ }
+
+ c = pthread_getconcurrency ();
+ if (c != 1)
+ {
+ puts ("invalid getconcurrency changed level");
+ exit (1);
+ }
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-basic6.c b/test/nptl/tst-basic6.c
new file mode 100644
index 000000000..91e5fe2c7
--- /dev/null
+++ b/test/nptl/tst-basic6.c
@@ -0,0 +1,131 @@
+/* Copyright (C) 2003 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 <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+
+static char *p;
+
+static pthread_barrier_t b;
+#define BT \
+ e = pthread_barrier_wait (&b); \
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD) \
+ { \
+ puts ("barrier_wait failed"); \
+ exit (1); \
+ }
+
+
+static void *
+tf (void *a)
+{
+ int e;
+
+ BT;
+
+ char *p2 = getcwd (NULL, 0);
+ if (p2 == NULL)
+ {
+ puts ("2nd getcwd failed");
+ exit (1);
+ }
+
+ if (strcmp (p, p2) != 0)
+ {
+ printf ("initial cwd mismatch: \"%s\" vs \"%s\"\n", p, p2);
+ exit (1);
+ }
+
+ free (p);
+ free (p2);
+
+ if (chdir ("..") != 0)
+ {
+ puts ("chdir failed");
+ exit (1);
+ }
+
+ p = getcwd (NULL, 0);
+ if (p == NULL)
+ {
+ puts ("getcwd failed");
+ exit (1);
+ }
+
+ return a;
+}
+
+
+int
+do_test (void)
+{
+ if (pthread_barrier_init (&b, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ exit (1);
+ }
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ exit (1);
+ }
+
+ p = getcwd (NULL, 0);
+ if (p == NULL)
+ {
+ puts ("getcwd failed");
+ exit (1);
+ }
+
+ int e;
+ BT;
+
+ if (pthread_join (th, NULL) != 0)
+ {
+ puts ("join failed");
+ exit (1);
+ }
+
+ char *p2 = getcwd (NULL, 0);
+ if (p2 == NULL)
+ {
+ puts ("2nd getcwd failed");
+ exit (1);
+ }
+
+ if (strcmp (p, p2) != 0)
+ {
+ printf ("cwd after chdir mismatch: \"%s\" vs \"%s\"\n", p, p2);
+ exit (1);
+ }
+
+ free (p);
+ free (p2);
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-basic7.c b/test/nptl/tst-basic7.c
new file mode 100644
index 000000000..15b618786
--- /dev/null
+++ b/test/nptl/tst-basic7.c
@@ -0,0 +1,75 @@
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <limits.h>
+#include <sys/mman.h>
+#include <sys/resource.h>
+
+static void use_stack (size_t needed);
+
+void (*use_stack_ptr) (size_t) = use_stack;
+
+static void
+use_stack (size_t needed)
+{
+ size_t sz = sysconf (_SC_PAGESIZE);
+ char *buf = alloca (sz);
+ memset (buf, '\0', sz);
+
+ if (needed > sz)
+ use_stack_ptr (needed - sz);
+}
+
+static void
+use_up_memory (void)
+{
+ struct rlimit rl;
+ getrlimit (RLIMIT_AS, &rl);
+ rl.rlim_cur = 10 * 1024 * 1024;
+ setrlimit (RLIMIT_AS, &rl);
+
+ char *c;
+ int PAGESIZE = getpagesize ();
+ while (1)
+ {
+ c = mmap (NULL, PAGESIZE, PROT_NONE, MAP_ANON | MAP_PRIVATE, -1, 0);
+ if (c == MAP_FAILED)
+ break;
+ }
+}
+
+static void *
+child (void *arg)
+{
+ sleep (1);
+ return arg;
+}
+
+static int
+do_test (void)
+{
+ int err;
+ pthread_t tid;
+
+ /* Allocate the memory needed for the stack. */
+ use_stack_ptr (PTHREAD_STACK_MIN);
+
+ use_up_memory ();
+
+ err = pthread_create (&tid, NULL, child, NULL);
+ if (err != 0)
+ {
+ printf ("pthread_create returns %d: %s\n", err,
+ err == EAGAIN ? "OK" : "FAIL");
+ return err != EAGAIN;
+ }
+
+ /* We did not fail to allocate memory despite the preparation. Oh well. */
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cancel1.c b/test/nptl/tst-cancel1.c
new file mode 100644
index 000000000..8b2ca07b1
--- /dev/null
+++ b/test/nptl/tst-cancel1.c
@@ -0,0 +1,162 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+static pthread_mutex_t m1 = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t m2 = PTHREAD_MUTEX_INITIALIZER;
+
+static int cntr;
+
+
+static void
+cleanup (void *arg)
+{
+ if (arg != (void *) 42l)
+ cntr = 42;
+ else
+ cntr = 1;
+}
+
+
+static void *
+tf (void *arg)
+{
+ /* Ignore all signals. This must not have any effect on delivering
+ the cancellation signal. */
+ sigset_t ss;
+
+ sigfillset (&ss);
+
+ if (pthread_sigmask (SIG_BLOCK, &ss, NULL) != 0)
+ {
+ puts ("pthread_sigmask failed");
+ exit (1);
+ }
+
+ pthread_cleanup_push (cleanup, (void *) 42l);
+
+ int err = pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+ if (err != 0)
+ {
+ printf ("setcanceltype failed: %s\n", strerror (err));
+ exit (1);
+ }
+ /* The following code is not standard compliant: the mutex functions
+ must not be called with asynchronous cancellation enabled. */
+
+ err = pthread_mutex_unlock (&m2);
+ if (err != 0)
+ {
+ printf ("child: mutex_unlock failed: %s\n", strerror (err));
+ exit (1);
+ }
+
+ err = pthread_mutex_lock (&m1);
+ if (err != 0)
+ {
+ printf ("child: 1st mutex_lock failed: %s\n", strerror (err));
+ exit (1);
+ }
+
+ /* We should never come here. */
+
+ pthread_cleanup_pop (0);
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ int err;
+ pthread_t th;
+ int result = 0;
+ void *retval;
+
+ /* Get the mutexes. */
+ err = pthread_mutex_lock (&m1);
+ if (err != 0)
+ {
+ printf ("parent: 1st mutex_lock failed: %s\n", strerror (err));
+ return 1;
+ }
+ err = pthread_mutex_lock (&m2);
+ if (err != 0)
+ {
+ printf ("parent: 2nd mutex_lock failed: %s\n", strerror (err));
+ return 1;
+ }
+
+ err = pthread_create (&th, NULL, tf, NULL);
+ if (err != 0)
+ {
+ printf ("create failed: %s\n", strerror (err));
+ return 1;
+ }
+
+ err = pthread_mutex_lock (&m2);
+ if (err != 0)
+ {
+ printf ("parent: 3rd mutex_lock failed: %s\n", strerror (err));
+ return 1;
+ }
+
+ err = pthread_cancel (th);
+ if (err != 0)
+ {
+ printf ("cancel failed: %s\n", strerror (err));
+ return 1;
+ }
+
+ err = pthread_join (th, &retval);
+ if (err != 0)
+ {
+ printf ("join failed: %s\n", strerror (err));
+ return 1;
+ }
+
+ if (retval != PTHREAD_CANCELED)
+ {
+ printf ("wrong return value: %p\n", retval);
+ result = 1;
+ }
+
+ if (cntr == 42)
+ {
+ puts ("cleanup handler called with wrong argument");
+ result = 1;
+ }
+ else if (cntr != 1)
+ {
+ puts ("cleanup handling not called");
+ result = 1;
+ }
+
+ return result;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cancel10.c b/test/nptl/tst-cancel10.c
new file mode 100644
index 000000000..534ddf439
--- /dev/null
+++ b/test/nptl/tst-cancel10.c
@@ -0,0 +1,125 @@
+/* Copyright (C) 2003, 2004 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 <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+static void
+cleanup (void *arg)
+{
+ /* Just for fun. */
+ if (pthread_cancel (pthread_self ()) != 0)
+ {
+ puts ("cleanup: cancel failed");
+ exit (1);
+ }
+
+ printf ("cleanup for %ld\n", (long int) arg);
+}
+
+
+static void *
+tf (void *arg)
+{
+ long int n = (long int) arg;
+
+ pthread_cleanup_push (cleanup, arg);
+
+ if (pthread_setcanceltype ((n & 1) == 0
+ ? PTHREAD_CANCEL_DEFERRED
+ : PTHREAD_CANCEL_ASYNCHRONOUS, NULL) != 0)
+ {
+ puts ("setcanceltype failed");
+ exit (1);
+ }
+
+ if (pthread_cancel (pthread_self ()) != 0)
+ {
+ puts ("cancel failed");
+ exit (1);
+ }
+
+ pthread_testcancel ();
+
+ /* We should never come here. */
+
+ pthread_cleanup_pop (0);
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ pthread_attr_t at;
+
+ if (pthread_attr_init (&at) != 0)
+ {
+ puts ("attr_init failed");
+ return 1;
+ }
+
+ if (pthread_attr_setstacksize (&at, 1 * 1024 * 1024) != 0)
+ {
+ puts ("attr_setstacksize failed");
+ return 1;
+ }
+
+#define N 20
+ int i;
+ pthread_t th[N];
+
+ for (i = 0; i < N; ++i)
+ if (pthread_create (&th[i], &at, tf, (void *) (long int) i) != 0)
+ {
+ puts ("create failed");
+ exit (1);
+ }
+
+ if (pthread_attr_destroy (&at) != 0)
+ {
+ puts ("attr_destroy failed");
+ return 1;
+ }
+
+ for (i = 0; i < N; ++i)
+ {
+ void *r;
+ if (pthread_join (th[i], &r) != 0)
+ {
+ puts ("join failed");
+ exit (1);
+ }
+
+ if (r != PTHREAD_CANCELED)
+ {
+ puts ("thread not canceled");
+ exit (1);
+ }
+ }
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cancel11.c b/test/nptl/tst-cancel11.c
new file mode 100644
index 000000000..c09158237
--- /dev/null
+++ b/test/nptl/tst-cancel11.c
@@ -0,0 +1,122 @@
+/* Copyright (C) 2003 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 <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+
+static pthread_barrier_t bar;
+static int fd[2];
+
+
+static void
+cleanup (void *arg)
+{
+ static int ncall;
+
+ if (++ncall != 1)
+ {
+ puts ("second call to cleanup");
+ exit (1);
+ }
+
+ printf ("cleanup call #%d\n", ncall);
+}
+
+
+static void *
+tf (void *arg)
+{
+ pthread_cleanup_push (cleanup, NULL);
+
+ int e = pthread_barrier_wait (&bar);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("tf: 1st barrier_wait failed");
+ exit (1);
+ }
+
+ /* This call should block and be cancelable. */
+ char buf[20];
+ read (fd[0], buf, sizeof (buf));
+
+ pthread_cleanup_pop (0);
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ pthread_t th;
+
+ if (pthread_barrier_init (&bar, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ exit (1);
+ }
+
+ if (pipe (fd) != 0)
+ {
+ puts ("pipe failed");
+ exit (1);
+ }
+
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ exit (1);
+ }
+
+ int e = pthread_barrier_wait (&bar);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("1st barrier_wait failed");
+ exit (1);
+ }
+
+ if (pthread_cancel (th) != 0)
+ {
+ puts ("1st cancel failed");
+ exit (1);
+ }
+
+ void *r;
+ if (pthread_join (th, &r) != 0)
+ {
+ puts ("join failed");
+ exit (1);
+ }
+
+ if (r != PTHREAD_CANCELED)
+ {
+ puts ("thread not canceled");
+ exit (1);
+ }
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cancel12.c b/test/nptl/tst-cancel12.c
new file mode 100644
index 000000000..8b3faa607
--- /dev/null
+++ b/test/nptl/tst-cancel12.c
@@ -0,0 +1,126 @@
+/* Copyright (C) 2003 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 <errno.h>
+#include <pthread.h>
+#include <semaphore.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+
+static pthread_barrier_t bar;
+static sem_t sem;
+
+
+static void
+cleanup (void *arg)
+{
+ static int ncall;
+
+ if (++ncall != 1)
+ {
+ puts ("second call to cleanup");
+ exit (1);
+ }
+
+ printf ("cleanup call #%d\n", ncall);
+}
+
+
+static void *
+tf (void *arg)
+{
+ pthread_cleanup_push (cleanup, NULL);
+
+ int e = pthread_barrier_wait (&bar);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("tf: 1st barrier_wait failed");
+ exit (1);
+ }
+
+ /* This call should block and be cancelable. */
+ sem_wait (&sem);
+
+ pthread_cleanup_pop (0);
+
+ puts ("sem_wait returned");
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ pthread_t th;
+
+ if (pthread_barrier_init (&bar, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ exit (1);
+ }
+
+ if (sem_init (&sem, 0, 1) != 0)
+ {
+ puts ("sem_init failed");
+ exit (1);
+ }
+
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ exit (1);
+ }
+
+ /* Check whether cancellation is honored even before sem_wait does
+ anything. */
+ if (pthread_cancel (th) != 0)
+ {
+ puts ("1st cancel failed");
+ exit (1);
+ }
+
+ int e = pthread_barrier_wait (&bar);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("1st barrier_wait failed");
+ exit (1);
+ }
+
+ void *r;
+ if (pthread_join (th, &r) != 0)
+ {
+ puts ("join failed");
+ exit (1);
+ }
+
+ if (r != PTHREAD_CANCELED)
+ {
+ puts ("thread not canceled");
+ exit (1);
+ }
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cancel13.c b/test/nptl/tst-cancel13.c
new file mode 100644
index 000000000..cf3ce20f5
--- /dev/null
+++ b/test/nptl/tst-cancel13.c
@@ -0,0 +1,128 @@
+/* Copyright (C) 2003 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 <errno.h>
+#include <pthread.h>
+#include <semaphore.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+
+static pthread_barrier_t bar;
+static sem_t sem;
+
+
+static void
+cleanup (void *arg)
+{
+ static int ncall;
+
+ if (++ncall != 1)
+ {
+ puts ("second call to cleanup");
+ exit (1);
+ }
+
+ printf ("cleanup call #%d\n", ncall);
+}
+
+
+static void *
+tf (void *arg)
+{
+ pthread_cleanup_push (cleanup, NULL);
+
+ int e = pthread_barrier_wait (&bar);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("tf: 1st barrier_wait failed");
+ exit (1);
+ }
+
+ /* This call should block and be cancelable. */
+ sem_wait (&sem);
+
+ pthread_cleanup_pop (0);
+
+ puts ("sem_wait returned");
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ pthread_t th;
+
+ if (pthread_barrier_init (&bar, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ exit (1);
+ }
+
+ if (sem_init (&sem, 0, 0) != 0)
+ {
+ puts ("sem_init failed");
+ exit (1);
+ }
+
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ exit (1);
+ }
+
+ int e = pthread_barrier_wait (&bar);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("1st barrier_wait failed");
+ exit (1);
+ }
+
+ /* Give the child a chance to go to sleep in sem_wait. */
+ sleep (1);
+
+ /* Check whether cancellation is honored when waiting in sem_wait. */
+ if (pthread_cancel (th) != 0)
+ {
+ puts ("1st cancel failed");
+ exit (1);
+ }
+
+ void *r;
+ if (pthread_join (th, &r) != 0)
+ {
+ puts ("join failed");
+ exit (1);
+ }
+
+ if (r != PTHREAD_CANCELED)
+ {
+ puts ("thread not canceled");
+ exit (1);
+ }
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cancel14.c b/test/nptl/tst-cancel14.c
new file mode 100644
index 000000000..defbbdd84
--- /dev/null
+++ b/test/nptl/tst-cancel14.c
@@ -0,0 +1,136 @@
+/* Copyright (C) 2003 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 <errno.h>
+#include <pthread.h>
+#include <semaphore.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/time.h>
+
+
+static pthread_barrier_t bar;
+static sem_t sem;
+
+
+static void
+cleanup (void *arg)
+{
+ static int ncall;
+
+ if (++ncall != 1)
+ {
+ puts ("second call to cleanup");
+ exit (1);
+ }
+
+ printf ("cleanup call #%d\n", ncall);
+}
+
+
+static void *
+tf (void *arg)
+{
+ pthread_cleanup_push (cleanup, NULL);
+
+ int e = pthread_barrier_wait (&bar);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("tf: 1st barrier_wait failed");
+ exit (1);
+ }
+
+ struct timeval tv;
+ (void) gettimeofday (&tv, NULL);
+
+ struct timespec ts;
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+
+ /* Timeout in 5 seconds. */
+ ts.tv_sec += 5;
+
+ /* This call should block and be cancelable. */
+ sem_timedwait (&sem, &ts);
+
+ pthread_cleanup_pop (0);
+
+ puts ("sem_timedwait returned");
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ pthread_t th;
+
+ if (pthread_barrier_init (&bar, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ exit (1);
+ }
+
+ if (sem_init (&sem, 0, 1) != 0)
+ {
+ puts ("sem_init failed");
+ exit (1);
+ }
+
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ exit (1);
+ }
+
+ /* Check whether cancellation is honored even before sem_timedwait does
+ anything. */
+ if (pthread_cancel (th) != 0)
+ {
+ puts ("1st cancel failed");
+ exit (1);
+ }
+
+ int e = pthread_barrier_wait (&bar);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("1st barrier_wait failed");
+ exit (1);
+ }
+
+ void *r;
+ if (pthread_join (th, &r) != 0)
+ {
+ puts ("join failed");
+ exit (1);
+ }
+
+ if (r != PTHREAD_CANCELED)
+ {
+ puts ("thread not canceled");
+ exit (1);
+ }
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cancel15.c b/test/nptl/tst-cancel15.c
new file mode 100644
index 000000000..eb2d713e6
--- /dev/null
+++ b/test/nptl/tst-cancel15.c
@@ -0,0 +1,141 @@
+/* Copyright (C) 2003 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 <errno.h>
+#include <pthread.h>
+#include <semaphore.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/time.h>
+
+
+static pthread_barrier_t bar;
+static sem_t sem;
+
+
+static void
+cleanup (void *arg)
+{
+ static int ncall;
+
+ if (++ncall != 1)
+ {
+ puts ("second call to cleanup");
+ exit (1);
+ }
+
+ printf ("cleanup call #%d\n", ncall);
+}
+
+
+static void *
+tf (void *arg)
+{
+ int e;
+
+ pthread_cleanup_push (cleanup, NULL);
+
+ e = pthread_barrier_wait (&bar);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("tf: 1st barrier_wait failed");
+ exit (1);
+ }
+
+ struct timeval tv;
+ (void) gettimeofday (&tv, NULL);
+
+ struct timespec ts;
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+
+ /* Timeout in 5 seconds. */
+ ts.tv_sec += 5;
+
+ /* This call should block and be cancelable. */
+ errno = 0;
+ e = sem_timedwait (&sem, &ts);
+
+ pthread_cleanup_pop (0);
+
+ printf ("sem_timedwait returned, e = %d, errno = %d\n", e, errno);
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ pthread_t th;
+
+ if (pthread_barrier_init (&bar, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ exit (1);
+ }
+
+ if (sem_init (&sem, 0, 0) != 0)
+ {
+ puts ("sem_init failed");
+ exit (1);
+ }
+
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ exit (1);
+ }
+
+ int e = pthread_barrier_wait (&bar);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("1st barrier_wait failed");
+ exit (1);
+ }
+
+ /* Give the child a chance to go to sleep in sem_wait. */
+ sleep (1);
+
+ /* Check whether cancellation is honored when waiting in sem_timedwait. */
+ if (pthread_cancel (th) != 0)
+ {
+ puts ("1st cancel failed");
+ exit (1);
+ }
+
+ void *r;
+ if (pthread_join (th, &r) != 0)
+ {
+ puts ("join failed");
+ exit (1);
+ }
+
+ if (r != PTHREAD_CANCELED)
+ {
+ puts ("thread not canceled");
+ exit (1);
+ }
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cancel16.c b/test/nptl/tst-cancel16.c
new file mode 100644
index 000000000..6af657c47
--- /dev/null
+++ b/test/nptl/tst-cancel16.c
@@ -0,0 +1,230 @@
+/* Copyright (C) 2003 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 <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+
+
+static pthread_barrier_t b2;
+static int fd;
+static int called;
+
+
+static void
+cl (void *arg)
+{
+ called = 1;
+}
+
+
+static void *
+tf (void *arg)
+{
+ int r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("child thread: barrier_wait failed");
+ exit (1);
+ }
+
+ pthread_cleanup_push (cl, NULL);
+
+ /* This call should never return. */
+ (void) lockf (fd, F_LOCK, 0);
+
+ pthread_cleanup_pop (0);
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ char fname[] = "/tmp/cancel16XXXXXX";
+ fd = mkstemp (fname);
+ if (fd == -1)
+ {
+ puts ("mkstemp failed");
+ return 1;
+ }
+ unlink (fname);
+
+ char mem[sizeof (pthread_barrier_t)];
+ memset (mem, '\0', sizeof (mem));
+ if (TEMP_FAILURE_RETRY (pwrite (fd, mem, sizeof (mem), 0)) != sizeof (mem))
+ {
+ puts ("pwrite failed");
+ return 1;
+ }
+
+ void *p = mmap (NULL, sizeof (mem), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
+ if (p == MAP_FAILED)
+ {
+ puts ("mmap failed");
+ return 1;
+ }
+ pthread_barrier_t *b = (pthread_barrier_t *) p;
+
+ pthread_barrierattr_t ba;
+ if (pthread_barrierattr_init (&ba) != 0)
+ {
+ puts ("barrierattr_init failed");
+ return 1;
+ }
+ if (pthread_barrierattr_setpshared (&ba, 1) != 0)
+ {
+ puts ("barrierattr_setshared failed");
+ return 1;
+ }
+
+ if (pthread_barrier_init (b, &ba, 2) != 0)
+ {
+ puts ("1st barrier_init failed");
+ return 1;
+ }
+ if (pthread_barrierattr_destroy (&ba) != 0)
+ {
+ puts ("barrier_destroy failed");
+ return 1;
+ }
+
+ pid_t pid = fork ();
+ if (pid == 0)
+ {
+ /* Child. Lock the file and wait. */
+ if (lockf (fd, F_LOCK, 0) != 0)
+ {
+ puts ("child process: lockf failed");
+ _exit (1);
+ }
+
+ int r = pthread_barrier_wait (b);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("child process: 1st barrier_wait failed");
+ _exit (1);
+ }
+
+ /* Make sure the process dies. */
+ alarm (5);
+
+ r = pthread_barrier_wait (b);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("child process: 2nd barrier_wait failed");
+ _exit (1);
+ }
+
+ _exit (0);
+ }
+ if (pid == -1)
+ {
+ puts ("fork failed");
+ return 1;
+ }
+
+ int r = pthread_barrier_wait (b);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("main: 1st barrier_wait failed");
+ _exit (1);
+ }
+
+ if (pthread_barrier_init (&b2, NULL, 2) != 0)
+ {
+ puts ("2nd barrier_init failed");
+ return 1;
+ }
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ return 1;
+ }
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("main: 2nd barrier_wait failed");
+ return 1;
+ }
+
+ /* Delay. */
+ sleep (1);
+
+ if (pthread_cancel (th) != 0)
+ {
+ puts ("cancel failed");
+ return 1;
+ }
+
+ void *result;
+ if (pthread_join (th, &result) != 0)
+ {
+ puts ("join failed");
+ return 1;
+ }
+ if (result != PTHREAD_CANCELED)
+ {
+ puts ("thread not canceled");
+ return 1;
+ }
+ if (called == 0)
+ {
+ puts ("cleanup handler not called");
+ return 1;
+ }
+
+ r = pthread_barrier_wait (b);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("main: 3rd barrier_wait failed");
+ return 1;
+ }
+
+ int status;
+ if (TEMP_FAILURE_RETRY (waitpid (pid, &status, 0)) != pid)
+ {
+ puts ("waitpid failed");
+ return 1;
+ }
+ if (WEXITSTATUS (status) != 0)
+ {
+ printf ("child process exits with %d\n", WEXITSTATUS (status));
+ return 1;
+ }
+
+ if (lockf (fd, F_LOCK, 0) != 0)
+ {
+ puts ("main: lockf failed");
+ return 1;
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cancel18.c b/test/nptl/tst-cancel18.c
new file mode 100644
index 000000000..e653119d6
--- /dev/null
+++ b/test/nptl/tst-cancel18.c
@@ -0,0 +1,173 @@
+/* Copyright (C) 2003 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 <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <unistd.h>
+
+
+static pthread_barrier_t b;
+
+
+/* Cleanup handling test. */
+static int cl_called;
+
+static void
+cl (void *arg)
+{
+ ++cl_called;
+}
+
+
+static void *
+tf (void *arg)
+{
+ int r = pthread_barrier_wait (&b);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ exit (1);
+ }
+
+ pthread_cleanup_push (cl, NULL);
+
+ struct timespec ts = { .tv_sec = arg == NULL ? 10000000 : 0, .tv_nsec = 0 };
+ TEMP_FAILURE_RETRY (clock_nanosleep (CLOCK_REALTIME, 0, &ts, &ts));
+
+ pthread_cleanup_pop (0);
+
+ puts ("clock_nanosleep returned");
+
+ exit (1);
+}
+
+
+static int
+do_test (void)
+{
+ if (pthread_barrier_init (&b, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ return 1;
+ }
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("1st create failed");
+ return 1;
+ }
+
+ int r = pthread_barrier_wait (&b);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ exit (1);
+ }
+
+ struct timespec ts = { .tv_sec = 0, .tv_nsec = 100000000 };
+ while (nanosleep (&ts, &ts) != 0)
+ continue;
+
+ puts ("going to cancel in-time");
+ if (pthread_cancel (th) != 0)
+ {
+ puts ("1st cancel failed");
+ return 1;
+ }
+
+ void *status;
+ if (pthread_join (th, &status) != 0)
+ {
+ puts ("1st join failed");
+ return 1;
+ }
+ if (status != PTHREAD_CANCELED)
+ {
+ puts ("1st thread not canceled");
+ return 1;
+ }
+
+ if (cl_called == 0)
+ {
+ puts ("cleanup handler not called");
+ return 1;
+ }
+ if (cl_called > 1)
+ {
+ puts ("cleanup handler called more than once");
+ return 1;
+ }
+
+ puts ("in-time cancellation succeeded");
+
+
+ cl_called = 0;
+
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("2nd create failed");
+ return 1;
+ }
+
+ puts ("going to cancel early");
+ if (pthread_cancel (th) != 0)
+ {
+ puts ("2nd cancel failed");
+ return 1;
+ }
+
+ r = pthread_barrier_wait (&b);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ exit (1);
+ }
+
+ if (pthread_join (th, &status) != 0)
+ {
+ puts ("2nd join failed");
+ return 1;
+ }
+ if (status != PTHREAD_CANCELED)
+ {
+ puts ("2nd thread not canceled");
+ return 1;
+ }
+
+ if (cl_called == 0)
+ {
+ printf ("cleanup handler not called\n");
+ return 1;
+ }
+ if (cl_called > 1)
+ {
+ printf ("cleanup handler called more than once\n");
+ return 1;
+ }
+
+ puts ("early cancellation succeeded");
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cancel19.c b/test/nptl/tst-cancel19.c
new file mode 100644
index 000000000..921df3f9d
--- /dev/null
+++ b/test/nptl/tst-cancel19.c
@@ -0,0 +1,286 @@
+/* Copyright (C) 2003 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/>. */
+
+#include <errno.h>
+#include <error.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/select.h>
+#include <sys/time.h>
+#include <unistd.h>
+
+static void *
+tf (void *arg)
+{
+ return NULL;
+}
+
+static void
+handler (int sig)
+{
+}
+
+static void __attribute__ ((noinline))
+clobber_lots_of_regs (void)
+{
+#define X1(n) long r##n = 10##n; __asm__ __volatile__ ("" : "+r" (r##n));
+#define X2(n) X1(n##0) X1(n##1) X1(n##2) X1(n##3) X1(n##4)
+#define X3(n) X2(n##0) X2(n##1) X2(n##2) X2(n##3) X2(n##4)
+ X3(0) X3(1) X3(2) X3(3) X3(4)
+#undef X1
+#define X1(n) __asm__ __volatile__ ("" : : "r" (r##n));
+ X3(0) X3(1) X3(2) X3(3) X3(4)
+#undef X1
+#undef X2
+#undef X3
+}
+
+static int
+do_test (void)
+{
+ pthread_t th;
+ int old, rc;
+ int ret = 0;
+ int fd[2];
+
+ rc = pipe (fd);
+ if (rc < 0)
+ error (EXIT_FAILURE, errno, "couldn't create pipe");
+
+ rc = pthread_create (&th, NULL, tf, NULL);
+ if (rc)
+ error (EXIT_FAILURE, rc, "couldn't create thread");
+
+ rc = pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &old);
+ if (rc)
+ {
+ error (0, rc, "1st pthread_setcanceltype failed");
+ ret = 1;
+ }
+ if (old != PTHREAD_CANCEL_DEFERRED && old != PTHREAD_CANCEL_ASYNCHRONOUS)
+ {
+ error (0, 0, "1st pthread_setcanceltype returned invalid value %d",
+ old);
+ ret = 1;
+ }
+
+ clobber_lots_of_regs ();
+ close (fd[0]);
+
+ rc = pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &old);
+ if (rc)
+ {
+ error (0, rc, "pthread_setcanceltype after close failed");
+ ret = 1;
+ }
+ if (old != PTHREAD_CANCEL_DEFERRED)
+ {
+ error (0, 0, "pthread_setcanceltype after close returned invalid value %d",
+ old);
+ ret = 1;
+ }
+
+ clobber_lots_of_regs ();
+ close (fd[1]);
+
+ rc = pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &old);
+ if (rc)
+ {
+ error (0, rc, "pthread_setcanceltype after 2nd close failed");
+ ret = 1;
+ }
+ if (old != PTHREAD_CANCEL_ASYNCHRONOUS)
+ {
+ error (0, 0, "pthread_setcanceltype after 2nd close returned invalid value %d",
+ old);
+ ret = 1;
+ }
+
+ struct sigaction sa = { .sa_handler = handler, .sa_flags = 0 };
+ sigemptyset (&sa.sa_mask);
+ sigaction (SIGALRM, &sa, NULL);
+
+ struct itimerval it;
+ it.it_value.tv_sec = 1;
+ it.it_value.tv_usec = 0;
+ it.it_interval = it.it_value;
+ setitimer (ITIMER_REAL, &it, NULL);
+
+ clobber_lots_of_regs ();
+ pause ();
+
+ memset (&it, 0, sizeof (it));
+ setitimer (ITIMER_REAL, &it, NULL);
+
+ rc = pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &old);
+ if (rc)
+ {
+ error (0, rc, "pthread_setcanceltype after pause failed");
+ ret = 1;
+ }
+ if (old != PTHREAD_CANCEL_DEFERRED)
+ {
+ error (0, 0, "pthread_setcanceltype after pause returned invalid value %d",
+ old);
+ ret = 1;
+ }
+
+ it.it_value.tv_sec = 1;
+ it.it_value.tv_usec = 0;
+ it.it_interval = it.it_value;
+ setitimer (ITIMER_REAL, &it, NULL);
+
+ clobber_lots_of_regs ();
+ pause ();
+
+ memset (&it, 0, sizeof (it));
+ setitimer (ITIMER_REAL, &it, NULL);
+
+ rc = pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &old);
+ if (rc)
+ {
+ error (0, rc, "pthread_setcanceltype after 2nd pause failed");
+ ret = 1;
+ }
+ if (old != PTHREAD_CANCEL_ASYNCHRONOUS)
+ {
+ error (0, 0, "pthread_setcanceltype after 2nd pause returned invalid value %d",
+ old);
+ ret = 1;
+ }
+
+ char fname[] = "/tmp/tst-cancel19-dir-XXXXXX\0foo/bar";
+ char *enddir = strchr (fname, '\0');
+ if (mkdtemp (fname) == NULL)
+ {
+ error (0, errno, "mkdtemp failed");
+ ret = 1;
+ }
+ *enddir = '/';
+
+ clobber_lots_of_regs ();
+ creat (fname, 0400);
+
+ rc = pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &old);
+ if (rc)
+ {
+ error (0, rc, "pthread_setcanceltype after creat failed");
+ ret = 1;
+ }
+ if (old != PTHREAD_CANCEL_DEFERRED)
+ {
+ error (0, 0, "pthread_setcanceltype after creat returned invalid value %d",
+ old);
+ ret = 1;
+ }
+
+ clobber_lots_of_regs ();
+ creat (fname, 0400);
+
+ rc = pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &old);
+ if (rc)
+ {
+ error (0, rc, "pthread_setcanceltype after 2nd creat failed");
+ ret = 1;
+ }
+ if (old != PTHREAD_CANCEL_ASYNCHRONOUS)
+ {
+ error (0, 0, "pthread_setcanceltype after 2nd creat returned invalid value %d",
+ old);
+ ret = 1;
+ }
+
+ clobber_lots_of_regs ();
+ open (fname, O_CREAT, 0400);
+
+ rc = pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &old);
+ if (rc)
+ {
+ error (0, rc, "pthread_setcanceltype after open failed");
+ ret = 1;
+ }
+ if (old != PTHREAD_CANCEL_DEFERRED)
+ {
+ error (0, 0, "pthread_setcanceltype after open returned invalid value %d",
+ old);
+ ret = 1;
+ }
+
+ clobber_lots_of_regs ();
+ open (fname, O_CREAT, 0400);
+
+ rc = pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &old);
+ if (rc)
+ {
+ error (0, rc, "pthread_setcanceltype after 2nd open failed");
+ ret = 1;
+ }
+ if (old != PTHREAD_CANCEL_ASYNCHRONOUS)
+ {
+ error (0, 0, "pthread_setcanceltype after 2nd open returned invalid value %d",
+ old);
+ ret = 1;
+ }
+
+ *enddir = '\0';
+ rmdir (fname);
+
+ clobber_lots_of_regs ();
+ select (-1, NULL, NULL, NULL, NULL);
+
+ rc = pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &old);
+ if (rc)
+ {
+ error (0, rc, "pthread_setcanceltype after select failed");
+ ret = 1;
+ }
+ if (old != PTHREAD_CANCEL_DEFERRED)
+ {
+ error (0, 0, "pthread_setcanceltype after select returned invalid value %d",
+ old);
+ ret = 1;
+ }
+
+ clobber_lots_of_regs ();
+ select (-1, NULL, NULL, NULL, NULL);
+
+ rc = pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &old);
+ if (rc)
+ {
+ error (0, rc, "pthread_setcanceltype after 2nd select failed");
+ ret = 1;
+ }
+ if (old != PTHREAD_CANCEL_ASYNCHRONOUS)
+ {
+ error (0, 0, "pthread_setcanceltype after 2nd select returned invalid value %d",
+ old);
+ ret = 1;
+ }
+
+ pthread_join (th, NULL);
+
+ return ret;
+}
+
+#define TIMEOUT 20
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cancel2.c b/test/nptl/tst-cancel2.c
new file mode 100644
index 000000000..45c9e8ea9
--- /dev/null
+++ b/test/nptl/tst-cancel2.c
@@ -0,0 +1,99 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <unistd.h>
+
+
+static int fd[2];
+
+
+static void *
+tf (void *arg)
+{
+ /* The buffer size must be larger than the pipe size so that the
+ write blocks. */
+ char buf[100000];
+
+ if (write (fd[1], buf, sizeof (buf)) == sizeof (buf))
+ {
+ puts ("write succeeded");
+ return (void *) 1l;
+ }
+
+ return (void *) 42l;
+}
+
+
+static int
+do_test (void)
+{
+ pthread_t th;
+ void *r;
+ struct sigaction sa;
+
+ sa.sa_handler = SIG_IGN;
+ sigemptyset (&sa.sa_mask);
+ sa.sa_flags = 0;
+
+ if (sigaction (SIGPIPE, &sa, NULL) != 0)
+ {
+ puts ("sigaction failed");
+ return 1;
+ }
+
+ if (pipe (fd) != 0)
+ {
+ puts ("pipe failed");
+ return 1;
+ }
+
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ return 1;
+ }
+
+ if (pthread_cancel (th) != 0)
+ {
+ puts ("cancel failed");
+ return 1;
+ }
+
+ /* This will cause the write in the child to return. */
+ close (fd[0]);
+
+ if (pthread_join (th, &r) != 0)
+ {
+ puts ("join failed");
+ return 1;
+ }
+
+ if (r != PTHREAD_CANCELED)
+ {
+ printf ("result is wrong: expected %p, got %p\n", PTHREAD_CANCELED, r);
+ return 1;
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cancel20.c b/test/nptl/tst-cancel20.c
new file mode 100644
index 000000000..7e9199fe5
--- /dev/null
+++ b/test/nptl/tst-cancel20.c
@@ -0,0 +1,263 @@
+/* Copyright (C) 2003, 2004 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/>. */
+
+#include <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static int fd[4];
+static pthread_barrier_t b;
+volatile int in_sh_body;
+unsigned long cleanups;
+
+static void
+cl (void *arg)
+{
+ cleanups = (cleanups << 4) | (long) arg;
+}
+
+
+static void __attribute__((noinline))
+sh_body (void)
+{
+ char c;
+
+ pthread_cleanup_push (cl, (void *) 1L);
+
+ in_sh_body = 1;
+ if (read (fd[2], &c, 1) == 1)
+ {
+ puts ("read succeeded");
+ exit (1);
+ }
+
+ pthread_cleanup_pop (0);
+}
+
+
+static void
+sh (int sig)
+{
+ pthread_cleanup_push (cl, (void *) 2L);
+ sh_body ();
+ in_sh_body = 0;
+
+ pthread_cleanup_pop (0);
+}
+
+
+static void __attribute__((noinline))
+tf_body (void)
+{
+ char c;
+
+ pthread_cleanup_push (cl, (void *) 3L);
+
+ int r = pthread_barrier_wait (&b);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("child thread: barrier_wait failed");
+ exit (1);
+ }
+
+ if (read (fd[0], &c, 1) == 1)
+ {
+ puts ("read succeeded");
+ exit (1);
+ }
+
+ read (fd[0], &c, 1);
+
+ pthread_cleanup_pop (0);
+}
+
+
+static void *
+tf (void *arg)
+{
+ pthread_cleanup_push (cl, (void *) 4L);
+ tf_body ();
+ pthread_cleanup_pop (0);
+ return NULL;
+}
+
+
+static int
+do_one_test (void)
+{
+ in_sh_body = 0;
+ cleanups = 0;
+ if (pipe (fd) != 0 || pipe (fd + 2) != 0)
+ {
+ puts ("pipe failed");
+ return 1;
+ }
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ return 1;
+ }
+
+ int r = pthread_barrier_wait (&b);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("parent thread: barrier_wait failed");
+ return 1;
+ }
+
+ sleep (1);
+
+ r = pthread_kill (th, SIGHUP);
+ if (r)
+ {
+ errno = r;
+ printf ("pthread_kill failed %m\n");
+ return 1;
+ }
+
+ while (in_sh_body == 0)
+ sleep (1);
+
+ if (pthread_cancel (th) != 0)
+ {
+ puts ("cancel failed");
+ return 1;
+ }
+
+ /* This will cause the read in the child to return. */
+ close (fd[0]);
+ close (fd[1]);
+ close (fd[2]);
+ close (fd[3]);
+
+ void *ret;
+ if (pthread_join (th, &ret) != 0)
+ {
+ puts ("join failed");
+ return 1;
+ }
+
+ if (ret != PTHREAD_CANCELED)
+ {
+ puts ("result is wrong");
+ return 1;
+ }
+
+ if (cleanups != 0x1234L)
+ {
+ printf ("called cleanups %lx\n", cleanups);
+ return 1;
+ }
+
+ return 0;
+}
+
+
+static int
+do_test (void)
+{
+ stack_t ss;
+ ss.ss_sp = malloc (2 * SIGSTKSZ);
+ if (ss.ss_sp == NULL)
+ {
+ puts ("failed to allocate alternate stack");
+ return 1;
+ }
+ ss.ss_flags = 0;
+ ss.ss_size = 2 * SIGSTKSZ;
+ if (sigaltstack (&ss, NULL) < 0)
+ {
+ printf ("sigaltstack failed %m\n");
+ return 1;
+ }
+
+ if (pthread_barrier_init (&b, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ return 1;
+ }
+
+ struct sigaction sa;
+ sa.sa_handler = sh;
+ sigemptyset (&sa.sa_mask);
+ sa.sa_flags = 0;
+
+ if (sigaction (SIGHUP, &sa, NULL) != 0)
+ {
+ puts ("sigaction failed");
+ return 1;
+ }
+
+ puts ("sa_flags = 0 test");
+ if (do_one_test ())
+ return 1;
+
+ sa.sa_handler = sh;
+ sigemptyset (&sa.sa_mask);
+ sa.sa_flags = SA_ONSTACK;
+
+ if (sigaction (SIGHUP, &sa, NULL) != 0)
+ {
+ puts ("sigaction failed");
+ return 1;
+ }
+
+ puts ("sa_flags = SA_ONSTACK test");
+ if (do_one_test ())
+ return 1;
+
+ sa.sa_sigaction = (void (*)(int, siginfo_t *, void *)) sh;
+ sigemptyset (&sa.sa_mask);
+ sa.sa_flags = SA_SIGINFO;
+
+ if (sigaction (SIGHUP, &sa, NULL) != 0)
+ {
+ puts ("sigaction failed");
+ return 1;
+ }
+
+ puts ("sa_flags = SA_SIGINFO test");
+ if (do_one_test ())
+ return 1;
+
+ sa.sa_sigaction = (void (*)(int, siginfo_t *, void *)) sh;
+ sigemptyset (&sa.sa_mask);
+ sa.sa_flags = SA_SIGINFO | SA_ONSTACK;
+
+ if (sigaction (SIGHUP, &sa, NULL) != 0)
+ {
+ puts ("sigaction failed");
+ return 1;
+ }
+
+ puts ("sa_flags = SA_SIGINFO|SA_ONSTACK test");
+ if (do_one_test ())
+ return 1;
+
+ return 0;
+}
+
+#define TIMEOUT 40
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cancel21.c b/test/nptl/tst-cancel21.c
new file mode 100644
index 000000000..489c18ab0
--- /dev/null
+++ b/test/nptl/tst-cancel21.c
@@ -0,0 +1,293 @@
+/* Copyright (C) 2003, 2004 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/>. */
+
+#include <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+
+static int fd[4];
+static pthread_barrier_t b;
+volatile int in_sh_body;
+unsigned long cleanups;
+
+static void
+cl (void *arg)
+{
+ cleanups = (cleanups << 4) | (long) arg;
+}
+
+
+static void __attribute__((noinline))
+sh_body (void)
+{
+ char c;
+
+ pthread_cleanup_push (cl, (void *) 1L);
+
+ in_sh_body = 1;
+ if (read (fd[2], &c, 1) == 1)
+ {
+ puts ("read succeeded");
+ exit (1);
+ }
+
+ pthread_cleanup_pop (0);
+}
+
+
+static void
+sh (int sig)
+{
+ pthread_cleanup_push (cl, (void *) 2L);
+ sh_body ();
+ in_sh_body = 0;
+
+ pthread_cleanup_pop (0);
+}
+
+
+static void __attribute__((noinline))
+tf_body (void)
+{
+ char c;
+
+ pthread_cleanup_push (cl, (void *) 3L);
+
+ int r = pthread_barrier_wait (&b);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("child thread: barrier_wait failed");
+ exit (1);
+ }
+
+ if (read (fd[0], &c, 1) == 1)
+ {
+ puts ("read succeeded");
+ exit (1);
+ }
+
+ read (fd[0], &c, 1);
+
+ pthread_cleanup_pop (0);
+}
+
+
+static void *
+tf (void *arg)
+{
+ pthread_t th = (pthread_t) arg;
+
+ int r = pthread_barrier_wait (&b);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("parent thread: barrier_wait failed");
+ exit (1);
+ }
+
+ sleep (1);
+
+ r = pthread_kill (th, SIGHUP);
+ if (r)
+ {
+ errno = r;
+ printf ("pthread_kill failed %m\n");
+ exit (1);
+ }
+
+ while (in_sh_body == 0)
+ sleep (1);
+
+ if (pthread_cancel (th) != 0)
+ {
+ puts ("cancel failed");
+ exit (1);
+ }
+
+ /* This will cause the read in the initial thread to return. */
+ close (fd[0]);
+ close (fd[1]);
+ close (fd[2]);
+ close (fd[3]);
+
+ void *ret;
+ if (pthread_join (th, &ret) != 0)
+ {
+ puts ("join failed");
+ exit (1);
+ }
+
+ if (ret != PTHREAD_CANCELED)
+ {
+ puts ("result is wrong");
+ exit (1);
+ }
+
+ if (cleanups != 0x1234L)
+ {
+ printf ("called cleanups %lx\n", cleanups);
+ exit (1);
+ }
+
+ if (pthread_barrier_destroy (&b))
+ {
+ puts ("barrier destroy failed");
+ exit (1);
+ }
+
+ exit (0);
+}
+
+
+static int
+do_one_test (void)
+{
+ in_sh_body = 0;
+
+ pid_t pid = fork ();
+
+ if (pid == -1)
+ {
+ printf ("fork failed: %m\n");
+ return 1;
+ }
+
+ if (pid)
+ {
+ int status;
+ if (waitpid (pid, &status, 0) < 0)
+ {
+ printf ("waitpid failed %m\n");
+ return 1;
+ }
+
+ return !WIFEXITED (status) || WEXITSTATUS (status);
+ }
+
+ if (pthread_barrier_init (&b, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ exit (1);
+ }
+
+ cleanups = 0;
+ if (pipe (fd) != 0 || pipe (fd + 2) != 0)
+ {
+ puts ("pipe failed");
+ exit (1);
+ }
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, (void *) pthread_self ()) != 0)
+ {
+ puts ("create failed");
+ exit (1);
+ }
+
+ pthread_cleanup_push (cl, (void *) 4L);
+ tf_body ();
+ pthread_cleanup_pop (0);
+ exit (1);
+}
+
+
+static int
+do_test (void)
+{
+ stack_t ss;
+ ss.ss_sp = malloc (2 * SIGSTKSZ);
+ if (ss.ss_sp == NULL)
+ {
+ puts ("failed to allocate alternate stack");
+ return 1;
+ }
+ ss.ss_flags = 0;
+ ss.ss_size = 2 * SIGSTKSZ;
+ if (sigaltstack (&ss, NULL) < 0)
+ {
+ printf ("sigaltstack failed %m\n");
+ return 1;
+ }
+
+ struct sigaction sa;
+ sa.sa_handler = sh;
+ sigemptyset (&sa.sa_mask);
+ sa.sa_flags = 0;
+
+ if (sigaction (SIGHUP, &sa, NULL) != 0)
+ {
+ puts ("sigaction failed");
+ return 1;
+ }
+
+ puts ("sa_flags = 0 test");
+ if (do_one_test ())
+ return 1;
+
+ sa.sa_handler = sh;
+ sigemptyset (&sa.sa_mask);
+ sa.sa_flags = SA_ONSTACK;
+
+ if (sigaction (SIGHUP, &sa, NULL) != 0)
+ {
+ puts ("sigaction failed");
+ return 1;
+ }
+
+ puts ("sa_flags = SA_ONSTACK test");
+ if (do_one_test ())
+ return 1;
+
+ sa.sa_sigaction = (void (*)(int, siginfo_t *, void *)) sh;
+ sigemptyset (&sa.sa_mask);
+ sa.sa_flags = SA_SIGINFO;
+
+ if (sigaction (SIGHUP, &sa, NULL) != 0)
+ {
+ puts ("sigaction failed");
+ return 1;
+ }
+
+ puts ("sa_flags = SA_SIGINFO test");
+ if (do_one_test ())
+ return 1;
+
+ sa.sa_sigaction = (void (*)(int, siginfo_t *, void *)) sh;
+ sigemptyset (&sa.sa_mask);
+ sa.sa_flags = SA_SIGINFO | SA_ONSTACK;
+
+ if (sigaction (SIGHUP, &sa, NULL) != 0)
+ {
+ puts ("sigaction failed");
+ return 1;
+ }
+
+ puts ("sa_flags = SA_SIGINFO|SA_ONSTACK test");
+ if (do_one_test ())
+ return 1;
+
+ return 0;
+}
+
+#define TIMEOUT 40
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cancel22.c b/test/nptl/tst-cancel22.c
new file mode 100644
index 000000000..8febbf0e1
--- /dev/null
+++ b/test/nptl/tst-cancel22.c
@@ -0,0 +1,121 @@
+/* Copyright (C) 2003 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/>. */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+pthread_barrier_t b;
+int seen;
+
+static void *
+tf (void *arg)
+{
+ int i;
+ int old;
+ int r = pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &old);
+ if (r != 0)
+ {
+ puts ("setcancelstate failed");
+ exit (1);
+ }
+
+ r = pthread_barrier_wait (&b);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ exit (1);
+ }
+
+ for (i = 0; i < 10; ++i)
+ {
+ struct timespec ts = { .tv_sec = 0, .tv_nsec = 100000000 };
+ TEMP_FAILURE_RETRY (nanosleep (&ts, &ts));
+ }
+
+ seen = 1;
+ pthread_setcancelstate (old, NULL);
+
+ struct timespec ts = { .tv_sec = 0, .tv_nsec = 100000000 };
+ TEMP_FAILURE_RETRY (nanosleep (&ts, &ts));
+
+ exit (1);
+}
+
+
+static int
+do_test (void)
+{
+ if (pthread_barrier_init (&b, NULL, 2) != 0)
+ {
+ puts ("barrier init failed");
+ return 1;
+ }
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("thread creation failed");
+ return 1;
+ }
+
+ int r = pthread_barrier_wait (&b);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ return 1;
+ }
+
+ if (pthread_cancel (th) != 0)
+ {
+ puts ("cancel failed");
+ return 1;
+ }
+
+ void *status;
+ if (pthread_join (th, &status) != 0)
+ {
+ puts ("join failed");
+ return 1;
+ }
+ if (status != PTHREAD_CANCELED)
+ {
+ puts ("thread not canceled");
+ return 1;
+ }
+
+ if (pthread_barrier_destroy (&b) != 0)
+ {
+ puts ("barrier_destroy failed");
+ return 1;
+ }
+
+ if (seen != 1)
+ {
+ puts ("thread cancelled when PTHREAD_CANCEL_DISABLED");
+ return 1;
+ }
+
+ return 0;
+}
+
+#define TIMEOUT 5
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cancel23.c b/test/nptl/tst-cancel23.c
new file mode 100644
index 000000000..211168748
--- /dev/null
+++ b/test/nptl/tst-cancel23.c
@@ -0,0 +1 @@
+#include "tst-cancel22.c"
diff --git a/test/nptl/tst-cancel25.c b/test/nptl/tst-cancel25.c
new file mode 100644
index 000000000..00b99ad55
--- /dev/null
+++ b/test/nptl/tst-cancel25.c
@@ -0,0 +1,171 @@
+#include <pthreadP.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static pthread_barrier_t b;
+static pthread_t th2;
+
+
+static void *
+tf2 (void *arg)
+{
+ sigset_t mask;
+ if (pthread_sigmask (SIG_SETMASK, NULL, &mask) != 0)
+ {
+ puts ("pthread_sigmask failed");
+ exit (1);
+ }
+ if (sigismember (&mask, SIGCANCEL))
+ {
+ puts ("SIGCANCEL blocked in new thread");
+ exit (1);
+ }
+
+ /* Sync with the main thread so that we do not test anything else. */
+ int e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ exit (1);
+ }
+
+ while (1)
+ {
+ /* Just a cancelable call. */
+ struct timespec ts = { 10000, 0 };
+ nanosleep (&ts, 0);
+ }
+
+ return NULL;
+}
+
+
+static void
+unwhand (void *arg)
+{
+ if (pthread_create (&th2, NULL, tf2, NULL) != 0)
+ {
+ puts ("unwhand: create failed");
+ exit (1);
+ }
+}
+
+
+static void *
+tf (void *arg)
+{
+ pthread_cleanup_push (unwhand, NULL);
+
+ /* Sync with the main thread so that we do not test anything else. */
+ int e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ exit (1);
+ }
+
+ while (1)
+ {
+ /* Just a cancelable call. */
+ struct timespec ts = { 10000, 0 };
+ nanosleep (&ts, 0);
+ }
+
+ pthread_cleanup_pop (0);
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ if (pthread_barrier_init (&b, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ return 1;
+ }
+
+ pthread_t th1;
+ if (pthread_create (&th1, NULL, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ return 1;
+ }
+
+ int e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ return 1;
+ }
+
+ /* Make sure tf1 enters nanosleep. */
+ struct timespec ts = { 0, 500000000 };
+ while (nanosleep (&ts, &ts) != 0)
+ ;
+
+ if (pthread_cancel (th1) != 0)
+ {
+ puts ("1st cancel failed");
+ return 1;
+ }
+
+ void *res;
+ if (pthread_join (th1, &res) != 0)
+ {
+ puts ("1st join failed");
+ return 1;
+ }
+ if (res != PTHREAD_CANCELED)
+ {
+ puts ("1st thread not canceled");
+ return 1;
+ }
+
+ e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ return 1;
+ }
+
+ /* Make sure tf2 enters nanosleep. */
+ ts.tv_sec = 0;
+ ts.tv_nsec = 500000000;
+ while (nanosleep (&ts, &ts) != 0)
+ ;
+
+ puts ("calling pthread_cancel the second time");
+ if (pthread_cancel (th2) != 0)
+ {
+ puts ("2nd cancel failed");
+ return 1;
+ }
+
+ puts ("calling pthread_join the second time");
+ if (pthread_join (th2, &res) != 0)
+ {
+ puts ("2nd join failed");
+ return 1;
+ }
+ if (res != PTHREAD_CANCELED)
+ {
+ puts ("2nd thread not canceled");
+ return 1;
+ }
+
+ if (pthread_barrier_destroy (&b) != 0)
+ {
+ puts ("barrier_destroy failed");
+ return 0;
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#define TIMEOUT 4
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cancel3.c b/test/nptl/tst-cancel3.c
new file mode 100644
index 000000000..e1c111d29
--- /dev/null
+++ b/test/nptl/tst-cancel3.c
@@ -0,0 +1,97 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <unistd.h>
+
+
+static int fd[2];
+
+
+static void *
+tf (void *arg)
+{
+ char buf[100];
+
+ if (read (fd[0], buf, sizeof (buf)) == sizeof (buf))
+ {
+ puts ("read succeeded");
+ return (void *) 1l;
+ }
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ pthread_t th;
+ void *r;
+ struct sigaction sa;
+
+ sa.sa_handler = SIG_IGN;
+ sigemptyset (&sa.sa_mask);
+ sa.sa_flags = 0;
+
+ if (sigaction (SIGPIPE, &sa, NULL) != 0)
+ {
+ puts ("sigaction failed");
+ return 1;
+ }
+
+ if (pipe (fd) != 0)
+ {
+ puts ("pipe failed");
+ return 1;
+ }
+
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ return 1;
+ }
+
+ if (pthread_cancel (th) != 0)
+ {
+ puts ("cancel failed");
+ return 1;
+ }
+
+ /* This will cause the read in the child to return. */
+ close (fd[0]);
+
+ if (pthread_join (th, &r) != 0)
+ {
+ puts ("join failed");
+ return 1;
+ }
+
+ if (r != PTHREAD_CANCELED)
+ {
+ puts ("result is wrong");
+ return 1;
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cancel4.c b/test/nptl/tst-cancel4.c
new file mode 100644
index 000000000..ecaf297cc
--- /dev/null
+++ b/test/nptl/tst-cancel4.c
@@ -0,0 +1,2393 @@
+/* Copyright (C) 2002, 2003, 2004, 2006, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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/>. */
+
+/* NOTE: this tests functionality beyond POSIX. POSIX does not allow
+ exit to be called more than once. */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <pthread.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <termios.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/msg.h>
+#include <sys/poll.h>
+#include <sys/select.h>
+#include <sys/socket.h>
+#include <sys/uio.h>
+#include <sys/un.h>
+#include <sys/wait.h>
+
+#include "pthreadP.h"
+
+
+/* Since STREAMS are not supported in the standard Linux kernel and
+ there we don't advertise STREAMS as supported is no need to test
+ the STREAMS related functions. This affects
+ getmsg() getpmsg() putmsg()
+ putpmsg()
+
+ lockf() and fcntl() are tested in tst-cancel16.
+
+ pthread_join() is tested in tst-join5.
+
+ pthread_testcancel()'s only purpose is to allow cancellation. This
+ is tested in several places.
+
+ sem_wait() and sem_timedwait() are checked in tst-cancel1[2345] tests.
+
+ mq_send(), mq_timedsend(), mq_receive() and mq_timedreceive() are checked
+ in tst-mqueue8{,x} tests.
+
+ aio_suspend() is tested in tst-cancel17.
+
+ clock_nanosleep() is tested in tst-cancel18.
+*/
+
+/* Pipe descriptors. */
+static int fds[2];
+
+/* Temporary file descriptor, to be closed after each round. */
+static int tempfd = -1;
+static int tempfd2 = -1;
+/* Name of temporary file to be removed after each round. */
+static char *tempfname;
+/* Temporary message queue. */
+static int tempmsg = -1;
+
+/* Often used barrier for two threads. */
+static pthread_barrier_t b2;
+
+
+#ifndef IPC_ADDVAL
+# define IPC_ADDVAL 0
+#endif
+
+/* The WRITE_BUFFER_SIZE value needs to be chosen such that if we set
+ the socket send buffer size to '1', a write of this size on that
+ socket will block.
+
+ The Linux kernel imposes a minimum send socket buffer size which
+ has changed over the years. As of Linux 3.10 the value is:
+
+ 2 * (2048 + SKB_DATA_ALIGN(sizeof(struct sk_buff)))
+
+ which is attempting to make sure that with standard MTUs,
+ TCP can always queue up at least 2 full sized packets.
+
+ Furthermore, there is logic in the socket send paths that
+ will allow one more packet (of any size) to be queued up as
+ long as some socket buffer space remains. Blocking only
+ occurs when we try to queue up a new packet and the send
+ buffer space has already been fully consumed.
+
+ Therefore we must set this value to the largest possible value of
+ the formula above (and since it depends upon the size of "struct
+ sk_buff", it is dependent upon machine word size etc.) plus some
+ slack space. */
+
+#define WRITE_BUFFER_SIZE 16384
+
+/* Cleanup handling test. */
+static int cl_called;
+
+static void
+cl (void *arg)
+{
+ ++cl_called;
+}
+
+
+
+static void *
+tf_read (void *arg)
+{
+ int fd;
+ int r;
+
+ if (arg == NULL)
+ fd = fds[0];
+ else
+ {
+ char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
+ tempfd = fd = mkstemp (fname);
+ if (fd == -1)
+ printf ("%s: mkstemp failed\n", __FUNCTION__);
+ unlink (fname);
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+ }
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ ssize_t s;
+ pthread_cleanup_push (cl, NULL);
+
+ char buf[100];
+ s = read (fd, buf, sizeof (buf));
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: read returns with %zd\n", __FUNCTION__, s);
+
+ exit (1);
+}
+
+
+static void *
+tf_readv (void *arg)
+{
+ int fd;
+ int r;
+
+ if (arg == NULL)
+ fd = fds[0];
+ else
+ {
+ char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
+ tempfd = fd = mkstemp (fname);
+ if (fd == -1)
+ printf ("%s: mkstemp failed\n", __FUNCTION__);
+ unlink (fname);
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+ }
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ ssize_t s;
+ pthread_cleanup_push (cl, NULL);
+
+ char buf[100];
+ struct iovec iov[1] = { [0] = { .iov_base = buf, .iov_len = sizeof (buf) } };
+ s = readv (fd, iov, 1);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: readv returns with %zd\n", __FUNCTION__, s);
+
+ exit (1);
+}
+
+
+static void *
+tf_write (void *arg)
+{
+ int fd;
+ int r;
+
+ if (arg == NULL)
+ fd = fds[1];
+ else
+ {
+ char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
+ tempfd = fd = mkstemp (fname);
+ if (fd == -1)
+ printf ("%s: mkstemp failed\n", __FUNCTION__);
+ unlink (fname);
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+ }
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ ssize_t s;
+ pthread_cleanup_push (cl, NULL);
+
+ char buf[WRITE_BUFFER_SIZE];
+ memset (buf, '\0', sizeof (buf));
+ s = write (fd, buf, sizeof (buf));
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: write returns with %zd\n", __FUNCTION__, s);
+
+ exit (1);
+}
+
+
+static void *
+tf_writev (void *arg)
+{
+ int fd;
+ int r;
+
+ if (arg == NULL)
+ fd = fds[1];
+ else
+ {
+ char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
+ tempfd = fd = mkstemp (fname);
+ if (fd == -1)
+ printf ("%s: mkstemp failed\n", __FUNCTION__);
+ unlink (fname);
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+ }
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ ssize_t s;
+ pthread_cleanup_push (cl, NULL);
+
+ char buf[WRITE_BUFFER_SIZE];
+ memset (buf, '\0', sizeof (buf));
+ struct iovec iov[1] = { [0] = { .iov_base = buf, .iov_len = sizeof (buf) } };
+ s = writev (fd, iov, 1);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: writev returns with %zd\n", __FUNCTION__, s);
+
+ exit (1);
+}
+
+/* sleep is not early cancelable, disable for now */
+#if 0
+static void *
+tf_sleep (void *arg)
+{
+ int r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ if (arg != NULL)
+ {
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+ }
+
+ pthread_cleanup_push (cl, NULL);
+
+ sleep (arg == NULL ? 1000000 : 0);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: sleep returns\n", __FUNCTION__);
+
+ exit (1);
+}
+#endif
+
+static void *
+tf_usleep (void *arg)
+{
+ int r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ if (arg != NULL)
+ {
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+ }
+
+ pthread_cleanup_push (cl, NULL);
+
+ usleep (arg == NULL ? (useconds_t) ULONG_MAX : 0);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: usleep returns\n", __FUNCTION__);
+
+ exit (1);
+}
+
+
+static void *
+tf_nanosleep (void *arg)
+{
+ int r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ if (arg != NULL)
+ {
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+ }
+
+ pthread_cleanup_push (cl, NULL);
+
+ struct timespec ts = { .tv_sec = arg == NULL ? 10000000 : 0, .tv_nsec = 0 };
+ TEMP_FAILURE_RETRY (nanosleep (&ts, &ts));
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: nanosleep returns\n", __FUNCTION__);
+
+ exit (1);
+}
+
+
+static void *
+tf_select (void *arg)
+{
+ int fd;
+ int r;
+
+ if (arg == NULL)
+ fd = fds[0];
+ else
+ {
+ char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
+ tempfd = fd = mkstemp (fname);
+ if (fd == -1)
+ printf ("%s: mkstemp failed\n", __FUNCTION__);
+ unlink (fname);
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+ }
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ fd_set rfs;
+ FD_ZERO (&rfs);
+ FD_SET (fd, &rfs);
+
+ int s;
+ pthread_cleanup_push (cl, NULL);
+
+ s = select (fd + 1, &rfs, NULL, NULL, NULL);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: select returns with %d (%s)\n", __FUNCTION__, s,
+ strerror (errno));
+
+ exit (1);
+}
+
+
+static void *
+tf_pselect (void *arg)
+{
+ int fd;
+ int r;
+
+ if (arg == NULL)
+ fd = fds[0];
+ else
+ {
+ char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
+ tempfd = fd = mkstemp (fname);
+ if (fd == -1)
+ printf ("%s: mkstemp failed\n", __FUNCTION__);
+ unlink (fname);
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+ }
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ fd_set rfs;
+ FD_ZERO (&rfs);
+ FD_SET (fd, &rfs);
+
+ int s;
+ pthread_cleanup_push (cl, NULL);
+
+ s = pselect (fd + 1, &rfs, NULL, NULL, NULL, NULL);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: pselect returns with %d (%s)\n", __FUNCTION__, s,
+ strerror (errno));
+
+ exit (1);
+}
+
+
+static void *
+tf_poll (void *arg)
+{
+ int fd;
+ int r;
+
+ if (arg == NULL)
+ fd = fds[0];
+ else
+ {
+ char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
+ tempfd = fd = mkstemp (fname);
+ if (fd == -1)
+ printf ("%s: mkstemp failed\n", __FUNCTION__);
+ unlink (fname);
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+ }
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ struct pollfd rfs[1] = { [0] = { .fd = fd, .events = POLLIN } };
+
+ int s;
+ pthread_cleanup_push (cl, NULL);
+
+ s = poll (rfs, 1, -1);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: poll returns with %d (%s)\n", __FUNCTION__, s,
+ strerror (errno));
+
+ exit (1);
+}
+
+
+static void *
+tf_ppoll (void *arg)
+{
+ int fd;
+ int r;
+
+ if (arg == NULL)
+ fd = fds[0];
+ else
+ {
+ char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
+ tempfd = fd = mkstemp (fname);
+ if (fd == -1)
+ printf ("%s: mkstemp failed\n", __FUNCTION__);
+ unlink (fname);
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+ }
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ struct pollfd rfs[1] = { [0] = { .fd = fd, .events = POLLIN } };
+
+ int s;
+ pthread_cleanup_push (cl, NULL);
+
+ s = ppoll (rfs, 1, NULL, NULL);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: ppoll returns with %d (%s)\n", __FUNCTION__, s,
+ strerror (errno));
+
+ exit (1);
+}
+
+
+static void *
+tf_wait (void *arg)
+{
+ pid_t pid = fork ();
+ if (pid == -1)
+ {
+ puts ("fork failed");
+ exit (1);
+ }
+
+ if (pid == 0)
+ {
+ /* Make the program disappear after a while. */
+ if (arg == NULL)
+ sleep (10);
+ exit (0);
+ }
+
+ int r;
+ if (arg != NULL)
+ {
+ struct timespec ts = { .tv_sec = 0, .tv_nsec = 100000000 };
+ while (nanosleep (&ts, &ts) != 0)
+ continue;
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+ }
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ int s;
+ pthread_cleanup_push (cl, NULL);
+
+ s = wait (NULL);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: wait returns with %d (%s)\n", __FUNCTION__, s,
+ strerror (errno));
+
+ exit (1);
+}
+
+
+static void *
+tf_waitpid (void *arg)
+{
+
+ pid_t pid = fork ();
+ if (pid == -1)
+ {
+ puts ("fork failed");
+ exit (1);
+ }
+
+ if (pid == 0)
+ {
+ /* Make the program disappear after a while. */
+ if (arg == NULL)
+ sleep (10);
+ exit (0);
+ }
+
+ int r;
+ if (arg != NULL)
+ {
+ struct timespec ts = { .tv_sec = 0, .tv_nsec = 100000000 };
+ while (nanosleep (&ts, &ts) != 0)
+ continue;
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+ }
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ int s;
+ pthread_cleanup_push (cl, NULL);
+
+ s = waitpid (-1, NULL, 0);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: waitpid returns with %d (%s)\n", __FUNCTION__, s,
+ strerror (errno));
+
+ exit (1);
+}
+
+
+static void *
+tf_waitid (void *arg)
+{
+ pid_t pid = fork ();
+ if (pid == -1)
+ {
+ puts ("fork failed");
+ exit (1);
+ }
+
+ if (pid == 0)
+ {
+ /* Make the program disappear after a while. */
+ if (arg == NULL)
+ sleep (10);
+ exit (0);
+ }
+
+ int r;
+ if (arg != NULL)
+ {
+ struct timespec ts = { .tv_sec = 0, .tv_nsec = 100000000 };
+ while (nanosleep (&ts, &ts) != 0)
+ continue;
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+ }
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ int s;
+ pthread_cleanup_push (cl, NULL);
+
+#ifndef WEXITED
+# define WEXITED 0
+#endif
+ siginfo_t si;
+ s = waitid (P_PID, pid, &si, WEXITED);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: waitid returns with %d (%s)\n", __FUNCTION__, s,
+ strerror (errno));
+
+ exit (1);
+}
+
+
+static void *
+tf_sigpause (void *arg)
+{
+ int r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ if (arg != NULL)
+ {
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+ }
+
+ pthread_cleanup_push (cl, NULL);
+
+ sigpause (SIGCANCEL);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: sigpause returned\n", __FUNCTION__);
+
+ exit (1);
+}
+
+
+static void *
+tf_sigsuspend (void *arg)
+{
+ int r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ if (arg != NULL)
+ {
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+ }
+
+ pthread_cleanup_push (cl, NULL);
+
+ /* Just for fun block all signals. */
+ sigset_t mask;
+ sigfillset (&mask);
+ sigsuspend (&mask);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: sigsuspend returned\n", __FUNCTION__);
+
+ exit (1);
+}
+
+
+static void *
+tf_sigwait (void *arg)
+{
+ int r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ if (arg != NULL)
+ {
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+ }
+
+ /* Block SIGUSR1. */
+ sigset_t mask;
+ sigemptyset (&mask);
+ sigaddset (&mask, SIGUSR1);
+ if (pthread_sigmask (SIG_BLOCK, &mask, NULL) != 0)
+ {
+ printf ("%s: pthread_sigmask failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ int sig;
+ pthread_cleanup_push (cl, NULL);
+
+ /* Wait for SIGUSR1. */
+ sigwait (&mask, &sig);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: sigwait returned with signal %d\n", __FUNCTION__, sig);
+
+ exit (1);
+}
+
+
+static void *
+tf_sigwaitinfo (void *arg)
+{
+ int r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ if (arg != NULL)
+ {
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+ }
+
+ /* Block SIGUSR1. */
+ sigset_t mask;
+ sigemptyset (&mask);
+ sigaddset (&mask, SIGUSR1);
+ if (pthread_sigmask (SIG_BLOCK, &mask, NULL) != 0)
+ {
+ printf ("%s: pthread_sigmask failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ siginfo_t info;
+ pthread_cleanup_push (cl, NULL);
+
+ /* Wait for SIGUSR1. */
+ sigwaitinfo (&mask, &info);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: sigwaitinfo returned with signal %d\n", __FUNCTION__,
+ info.si_signo);
+
+ exit (1);
+}
+
+
+static void *
+tf_sigtimedwait (void *arg)
+{
+ int r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ if (arg != NULL)
+ {
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+ }
+
+ /* Block SIGUSR1. */
+ sigset_t mask;
+ sigemptyset (&mask);
+ sigaddset (&mask, SIGUSR1);
+ if (pthread_sigmask (SIG_BLOCK, &mask, NULL) != 0)
+ {
+ printf ("%s: pthread_sigmask failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ /* Wait for SIGUSR1. */
+ siginfo_t info;
+ struct timespec ts = { .tv_sec = 60, .tv_nsec = 0 };
+ pthread_cleanup_push (cl, NULL);
+
+ sigtimedwait (&mask, &info, &ts);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: sigtimedwait returned with signal %d\n", __FUNCTION__,
+ info.si_signo);
+
+ exit (1);
+}
+
+
+static void *
+tf_pause (void *arg)
+{
+ int r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ if (arg != NULL)
+ {
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+ }
+
+ pthread_cleanup_push (cl, NULL);
+
+ pause ();
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: pause returned\n", __FUNCTION__);
+
+ exit (1);
+}
+
+
+static void *
+tf_accept (void *arg)
+{
+ struct sockaddr_un sun;
+ /* To test a non-blocking accept call we make the call file by using
+ a datagrame socket. */
+ int pf = arg == NULL ? SOCK_STREAM : SOCK_DGRAM;
+
+ tempfd = socket (AF_UNIX, pf, 0);
+ if (tempfd == -1)
+ {
+ printf ("%s: socket call failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ int tries = 0;
+ do
+ {
+ if (++tries > 10)
+ {
+ printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
+ /* prevent endless loop, when bind fails forever */
+ exit (1);
+ }
+
+ strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-1-XXXXXX");
+ if (mktemp (sun.sun_path) == NULL)
+ {
+ printf ("%s: cannot generate temp file name\n", __FUNCTION__);
+ exit (1);
+ }
+ sun.sun_family = AF_UNIX;
+ }
+ while (bind (tempfd, (struct sockaddr *) &sun,
+ offsetof (struct sockaddr_un, sun_path)
+ + strlen (sun.sun_path) + 1) != 0);
+
+ unlink (sun.sun_path);
+
+ listen (tempfd, 5);
+
+ socklen_t len = sizeof (sun);
+
+ int r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ if (arg != NULL)
+ {
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+ }
+
+ pthread_cleanup_push (cl, NULL);
+
+ accept (tempfd, (struct sockaddr *) &sun, &len);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: accept returned\n", __FUNCTION__);
+
+ exit (1);
+}
+
+
+static void *
+tf_send (void *arg)
+{
+ struct sockaddr_un sun;
+
+ tempfd = socket (AF_UNIX, SOCK_STREAM, 0);
+ if (tempfd == -1)
+ {
+ printf ("%s: first socket call failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ int tries = 0;
+ do
+ {
+ if (++tries > 10)
+ {
+ printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
+ exit (1);
+ }
+
+ strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-2-XXXXXX");
+ if (mktemp (sun.sun_path) == NULL)
+ {
+ printf ("%s: cannot generate temp file name\n", __FUNCTION__);
+ exit (1);
+ }
+ sun.sun_family = AF_UNIX;
+ }
+ while (bind (tempfd, (struct sockaddr *) &sun,
+ offsetof (struct sockaddr_un, sun_path)
+ + strlen (sun.sun_path) + 1) != 0);
+
+ listen (tempfd, 5);
+
+ tempfd2 = socket (AF_UNIX, SOCK_STREAM, 0);
+ if (tempfd2 == -1)
+ {
+ printf ("%s: second socket call failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ if (connect (tempfd2, (struct sockaddr *) &sun, sizeof (sun)) != 0)
+ {
+ printf ("%s: connect failed\n", __FUNCTION__);
+ exit(1);
+ }
+
+ unlink (sun.sun_path);
+
+ int r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ if (arg != NULL)
+ {
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+ }
+
+ pthread_cleanup_push (cl, NULL);
+
+ /* Very large block, so that the send call blocks. */
+ char mem[700000];
+
+ send (tempfd2, mem, arg == NULL ? sizeof (mem) : 1, 0);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: send returned\n", __FUNCTION__);
+
+ exit (1);
+}
+
+
+static void *
+tf_recv (void *arg)
+{
+ struct sockaddr_un sun;
+
+ tempfd = socket (AF_UNIX, SOCK_STREAM, 0);
+ if (tempfd == -1)
+ {
+ printf ("%s: first socket call failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ int tries = 0;
+ do
+ {
+ if (++tries > 10)
+ {
+ printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
+ exit (1);
+ }
+
+ strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-3-XXXXXX");
+ if (mktemp (sun.sun_path) == NULL)
+ {
+ printf ("%s: cannot generate temp file name\n", __FUNCTION__);
+ exit (1);
+ }
+ sun.sun_family = AF_UNIX;
+ }
+ while (bind (tempfd, (struct sockaddr *) &sun,
+ offsetof (struct sockaddr_un, sun_path)
+ + strlen (sun.sun_path) + 1) != 0);
+
+ listen (tempfd, 5);
+
+ tempfd2 = socket (AF_UNIX, SOCK_STREAM, 0);
+ if (tempfd2 == -1)
+ {
+ printf ("%s: second socket call failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ if (connect (tempfd2, (struct sockaddr *) &sun, sizeof (sun)) != 0)
+ {
+ printf ("%s: connect failed\n", __FUNCTION__);
+ exit(1);
+ }
+
+ unlink (sun.sun_path);
+
+ int r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ if (arg != NULL)
+ {
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+ }
+
+ pthread_cleanup_push (cl, NULL);
+
+ char mem[70];
+
+ recv (tempfd2, mem, arg == NULL ? sizeof (mem) : 0, 0);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: recv returned\n", __FUNCTION__);
+
+ exit (1);
+}
+
+
+static void *
+tf_recvfrom (void *arg)
+{
+ struct sockaddr_un sun;
+
+ tempfd = socket (AF_UNIX, SOCK_DGRAM, 0);
+ if (tempfd == -1)
+ {
+ printf ("%s: first socket call failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ int tries = 0;
+ do
+ {
+ if (++tries > 10)
+ {
+ printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
+ exit (1);
+ }
+
+ strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-4-XXXXXX");
+ if (mktemp (sun.sun_path) == NULL)
+ {
+ printf ("%s: cannot generate temp file name\n", __FUNCTION__);
+ exit (1);
+ }
+ sun.sun_family = AF_UNIX;
+ }
+ while (bind (tempfd, (struct sockaddr *) &sun,
+ offsetof (struct sockaddr_un, sun_path)
+ + strlen (sun.sun_path) + 1) != 0);
+
+ tempfname = strdup (sun.sun_path);
+
+ tempfd2 = socket (AF_UNIX, SOCK_DGRAM, 0);
+ if (tempfd2 == -1)
+ {
+ printf ("%s: second socket call failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ int r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ if (arg != NULL)
+ {
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+ }
+
+ pthread_cleanup_push (cl, NULL);
+
+ char mem[70];
+ socklen_t len = sizeof (sun);
+
+ recvfrom (tempfd2, mem, arg == NULL ? sizeof (mem) : 0, 0,
+ (struct sockaddr *) &sun, &len);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: recvfrom returned\n", __FUNCTION__);
+
+ exit (1);
+}
+
+
+static void *
+tf_recvmsg (void *arg)
+{
+ struct sockaddr_un sun;
+
+ tempfd = socket (AF_UNIX, SOCK_DGRAM, 0);
+ if (tempfd == -1)
+ {
+ printf ("%s: first socket call failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ int tries = 0;
+ do
+ {
+ if (++tries > 10)
+ {
+ printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
+ exit (1);
+ }
+
+ strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-5-XXXXXX");
+ if (mktemp (sun.sun_path) == NULL)
+ {
+ printf ("%s: cannot generate temp file name\n", __FUNCTION__);
+ exit (1);
+ }
+ sun.sun_family = AF_UNIX;
+ }
+ while (bind (tempfd, (struct sockaddr *) &sun,
+ offsetof (struct sockaddr_un, sun_path)
+ + strlen (sun.sun_path) + 1) != 0);
+
+ tempfname = strdup (sun.sun_path);
+
+ tempfd2 = socket (AF_UNIX, SOCK_DGRAM, 0);
+ if (tempfd2 == -1)
+ {
+ printf ("%s: second socket call failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ int r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ if (arg != NULL)
+ {
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+ }
+
+ pthread_cleanup_push (cl, NULL);
+
+ char mem[70];
+ struct iovec iov[1];
+ iov[0].iov_base = mem;
+ iov[0].iov_len = arg == NULL ? sizeof (mem) : 0;
+
+ struct msghdr m;
+ m.msg_name = &sun;
+ m.msg_namelen = sizeof (sun);
+ m.msg_iov = iov;
+ m.msg_iovlen = 1;
+ m.msg_control = NULL;
+ m.msg_controllen = 0;
+
+ recvmsg (tempfd2, &m, 0);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: recvmsg returned\n", __FUNCTION__);
+
+ exit (1);
+}
+
+
+static void *
+tf_open (void *arg)
+{
+ if (arg == NULL)
+ // XXX If somebody can provide a portable test case in which open()
+ // blocks we can enable this test to run in both rounds.
+ abort ();
+
+ int r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ pthread_cleanup_push (cl, NULL);
+
+ open ("Makefile", O_RDONLY);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: open returned\n", __FUNCTION__);
+
+ exit (1);
+}
+
+
+static void *
+tf_close (void *arg)
+{
+ if (arg == NULL)
+ // XXX If somebody can provide a portable test case in which close()
+ // blocks we can enable this test to run in both rounds.
+ abort ();
+
+ char fname[] = "/tmp/tst-cancel-fd-XXXXXX";
+ tempfd = mkstemp (fname);
+ if (tempfd == -1)
+ {
+ printf ("%s: mkstemp failed\n", __FUNCTION__);
+ exit (1);
+ }
+ unlink (fname);
+
+ int r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ pthread_cleanup_push (cl, NULL);
+
+ close (tempfd);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: close returned\n", __FUNCTION__);
+
+ exit (1);
+}
+
+
+static void *
+tf_pread (void *arg)
+{
+ if (arg == NULL)
+ // XXX If somebody can provide a portable test case in which pread()
+ // blocks we can enable this test to run in both rounds.
+ abort ();
+
+ tempfd = open ("Makefile", O_RDONLY);
+ if (tempfd == -1)
+ {
+ printf ("%s: cannot open Makefile\n", __FUNCTION__);
+ exit (1);
+ }
+
+ int r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ pthread_cleanup_push (cl, NULL);
+
+ char mem[10];
+ pread (tempfd, mem, sizeof (mem), 0);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: pread returned\n", __FUNCTION__);
+
+ exit (1);
+}
+
+
+static void *
+tf_pwrite (void *arg)
+{
+ if (arg == NULL)
+ // XXX If somebody can provide a portable test case in which pwrite()
+ // blocks we can enable this test to run in both rounds.
+ abort ();
+
+ char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
+ tempfd = mkstemp (fname);
+ if (tempfd == -1)
+ {
+ printf ("%s: mkstemp failed\n", __FUNCTION__);
+ exit (1);
+ }
+ unlink (fname);
+
+ int r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ pthread_cleanup_push (cl, NULL);
+
+ char mem[10];
+ pwrite (tempfd, mem, sizeof (mem), 0);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: pwrite returned\n", __FUNCTION__);
+
+ exit (1);
+}
+
+
+static void *
+tf_fsync (void *arg)
+{
+ if (arg == NULL)
+ // XXX If somebody can provide a portable test case in which fsync()
+ // blocks we can enable this test to run in both rounds.
+ abort ();
+
+ tempfd = open ("Makefile", O_RDONLY);
+ if (tempfd == -1)
+ {
+ printf ("%s: cannot open Makefile\n", __FUNCTION__);
+ exit (1);
+ }
+
+ int r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ pthread_cleanup_push (cl, NULL);
+
+ fsync (tempfd);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: fsync returned\n", __FUNCTION__);
+
+ exit (1);
+}
+
+
+static void *
+tf_fdatasync (void *arg)
+{
+ if (arg == NULL)
+ // XXX If somebody can provide a portable test case in which fdatasync()
+ // blocks we can enable this test to run in both rounds.
+ abort ();
+
+ tempfd = open ("Makefile", O_RDONLY);
+ if (tempfd == -1)
+ {
+ printf ("%s: cannot open Makefile\n", __FUNCTION__);
+ exit (1);
+ }
+
+ int r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ pthread_cleanup_push (cl, NULL);
+
+ fdatasync (tempfd);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: fdatasync returned\n", __FUNCTION__);
+
+ exit (1);
+}
+
+
+static void *
+tf_msync (void *arg)
+{
+ if (arg == NULL)
+ // XXX If somebody can provide a portable test case in which msync()
+ // blocks we can enable this test to run in both rounds.
+ abort ();
+
+ tempfd = open ("Makefile", O_RDONLY);
+ if (tempfd == -1)
+ {
+ printf ("%s: cannot open Makefile\n", __FUNCTION__);
+ exit (1);
+ }
+ void *p = mmap (NULL, 10, PROT_READ, MAP_SHARED, tempfd, 0);
+ if (p == MAP_FAILED)
+ {
+ printf ("%s: mmap failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ int r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ pthread_cleanup_push (cl, NULL);
+
+ msync (p, 10, 0);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: msync returned\n", __FUNCTION__);
+
+ exit (1);
+}
+
+
+static void *
+tf_sendto (void *arg)
+{
+ if (arg == NULL)
+ // XXX If somebody can provide a portable test case in which sendto()
+ // blocks we can enable this test to run in both rounds.
+ abort ();
+
+ struct sockaddr_un sun;
+
+ tempfd = socket (AF_UNIX, SOCK_DGRAM, 0);
+ if (tempfd == -1)
+ {
+ printf ("%s: first socket call failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ int tries = 0;
+ do
+ {
+ if (++tries > 10)
+ {
+ printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
+ exit (1);
+ }
+
+ strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-6-XXXXXX");
+ if (mktemp (sun.sun_path) == NULL)
+ {
+ printf ("%s: cannot generate temp file name\n", __FUNCTION__);
+ exit (1);
+ }
+ sun.sun_family = AF_UNIX;
+ }
+ while (bind (tempfd, (struct sockaddr *) &sun,
+ offsetof (struct sockaddr_un, sun_path)
+ + strlen (sun.sun_path) + 1) != 0);
+ tempfname = strdup (sun.sun_path);
+
+ tempfd2 = socket (AF_UNIX, SOCK_DGRAM, 0);
+ if (tempfd2 == -1)
+ {
+ printf ("%s: second socket call failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ int r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ pthread_cleanup_push (cl, NULL);
+
+ char mem[1];
+
+ sendto (tempfd2, mem, arg == NULL ? sizeof (mem) : 1, 0,
+ (struct sockaddr *) &sun,
+ offsetof (struct sockaddr_un, sun_path) + strlen (sun.sun_path) + 1);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: sendto returned\n", __FUNCTION__);
+
+ exit (1);
+}
+
+
+static void *
+tf_sendmsg (void *arg)
+{
+ if (arg == NULL)
+ // XXX If somebody can provide a portable test case in which sendmsg()
+ // blocks we can enable this test to run in both rounds.
+ abort ();
+
+ struct sockaddr_un sun;
+
+ tempfd = socket (AF_UNIX, SOCK_DGRAM, 0);
+ if (tempfd == -1)
+ {
+ printf ("%s: first socket call failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ int tries = 0;
+ do
+ {
+ if (++tries > 10)
+ {
+ printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
+ exit (1);
+ }
+
+ strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-7-XXXXXX");
+ if (mktemp (sun.sun_path) == NULL)
+ {
+ printf ("%s: cannot generate temp file name\n", __FUNCTION__);
+ exit (1);
+ }
+ sun.sun_family = AF_UNIX;
+ }
+ while (bind (tempfd, (struct sockaddr *) &sun,
+ offsetof (struct sockaddr_un, sun_path)
+ + strlen (sun.sun_path) + 1) != 0);
+ tempfname = strdup (sun.sun_path);
+
+ tempfd2 = socket (AF_UNIX, SOCK_DGRAM, 0);
+ if (tempfd2 == -1)
+ {
+ printf ("%s: second socket call failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ int r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ pthread_cleanup_push (cl, NULL);
+
+ char mem[1];
+ struct iovec iov[1];
+ iov[0].iov_base = mem;
+ iov[0].iov_len = 1;
+
+ struct msghdr m;
+ m.msg_name = &sun;
+ m.msg_namelen = (offsetof (struct sockaddr_un, sun_path)
+ + strlen (sun.sun_path) + 1);
+ m.msg_iov = iov;
+ m.msg_iovlen = 1;
+ m.msg_control = NULL;
+ m.msg_controllen = 0;
+
+ sendmsg (tempfd2, &m, 0);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: sendmsg returned\n", __FUNCTION__);
+
+ exit (1);
+}
+
+
+static void *
+tf_creat (void *arg)
+{
+ if (arg == NULL)
+ // XXX If somebody can provide a portable test case in which sendmsg()
+ // blocks we can enable this test to run in both rounds.
+ abort ();
+
+ int r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ pthread_cleanup_push (cl, NULL);
+
+ creat ("tmp/tst-cancel-4-should-not-exist", 0666);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: creat returned\n", __FUNCTION__);
+
+ exit (1);
+}
+
+
+static void *
+tf_connect (void *arg)
+{
+ if (arg == NULL)
+ // XXX If somebody can provide a portable test case in which connect()
+ // blocks we can enable this test to run in both rounds.
+ abort ();
+
+ struct sockaddr_un sun;
+
+ tempfd = socket (AF_UNIX, SOCK_STREAM, 0);
+ if (tempfd == -1)
+ {
+ printf ("%s: first socket call failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ int tries = 0;
+ do
+ {
+ if (++tries > 10)
+ {
+ printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
+ exit (1);
+ }
+
+ strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-2-XXXXXX");
+ if (mktemp (sun.sun_path) == NULL)
+ {
+ printf ("%s: cannot generate temp file name\n", __FUNCTION__);
+ exit (1);
+ }
+ sun.sun_family = AF_UNIX;
+ }
+ while (bind (tempfd, (struct sockaddr *) &sun,
+ offsetof (struct sockaddr_un, sun_path)
+ + strlen (sun.sun_path) + 1) != 0);
+ tempfname = strdup (sun.sun_path);
+
+ listen (tempfd, 5);
+
+ tempfd2 = socket (AF_UNIX, SOCK_STREAM, 0);
+ if (tempfd2 == -1)
+ {
+ printf ("%s: second socket call failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ int r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ if (arg != NULL)
+ {
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+ }
+
+ pthread_cleanup_push (cl, NULL);
+
+ connect (tempfd2, (struct sockaddr *) &sun, sizeof (sun));
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: connect returned\n", __FUNCTION__);
+
+ exit (1);
+}
+
+
+static void *
+tf_tcdrain (void *arg)
+{
+ if (arg == NULL)
+ // XXX If somebody can provide a portable test case in which tcdrain()
+ // blocks we can enable this test to run in both rounds.
+ abort ();
+
+ int r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ if (arg != NULL)
+ {
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+ }
+
+ pthread_cleanup_push (cl, NULL);
+
+ /* Regardless of stderr being a terminal, the tcdrain call should be
+ canceled. */
+ tcdrain (STDERR_FILENO);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: tcdrain returned\n", __FUNCTION__);
+
+ exit (1);
+}
+
+
+static void *
+tf_msgrcv (void *arg)
+{
+ tempmsg = msgget (IPC_PRIVATE, 0666 | IPC_CREAT);
+ if (tempmsg == -1)
+ {
+ printf ("%s: msgget failed: %s\n", __FUNCTION__, strerror (errno));
+ exit (1);
+ }
+
+ int r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ if (arg != NULL)
+ {
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+ }
+
+ ssize_t s;
+
+ pthread_cleanup_push (cl, NULL);
+
+ struct
+ {
+ long int type;
+ char mem[10];
+ } m;
+ int randnr;
+ /* We need a positive random number. */
+ do
+ randnr = random () % 64000;
+ while (randnr <= 0);
+ do
+ {
+ errno = 0;
+ s = msgrcv (tempmsg, (struct msgbuf *) &m, 10, randnr, 0);
+ }
+ while (errno == EIDRM || errno == EINTR);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: msgrcv returned %zd with errno = %m\n", __FUNCTION__, s);
+
+ msgctl (tempmsg, IPC_RMID, NULL);
+
+ exit (1);
+}
+
+
+static void *
+tf_msgsnd (void *arg)
+{
+ if (arg == NULL)
+ // XXX If somebody can provide a portable test case in which msgsnd()
+ // blocks we can enable this test to run in both rounds.
+ abort ();
+
+ tempmsg = msgget (IPC_PRIVATE, 0666 | IPC_CREAT);
+ if (tempmsg == -1)
+ {
+ printf ("%s: msgget failed: %s\n", __FUNCTION__, strerror (errno));
+ exit (1);
+ }
+
+ int r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ pthread_cleanup_push (cl, NULL);
+
+ struct
+ {
+ long int type;
+ char mem[1];
+ } m;
+ /* We need a positive random number. */
+ do
+ m.type = random () % 64000;
+ while (m.type <= 0);
+ msgsnd (tempmsg, (struct msgbuf *) &m, sizeof (m.mem), 0);
+
+ pthread_cleanup_pop (0);
+
+ printf ("%s: msgsnd returned\n", __FUNCTION__);
+
+ msgctl (tempmsg, IPC_RMID, NULL);
+
+ exit (1);
+}
+
+
+static struct
+{
+ const char *name;
+ void *(*tf) (void *);
+ int nb;
+ int only_early;
+} tests[] =
+{
+#define ADD_TEST(name, nbar, early) { #name, tf_##name, nbar, early }
+ ADD_TEST (read, 2, 0),
+ ADD_TEST (readv, 2, 0),
+ ADD_TEST (select, 2, 0),
+ ADD_TEST (pselect, 2, 0),
+ ADD_TEST (poll, 2, 0),
+ ADD_TEST (ppoll, 2, 0),
+ ADD_TEST (write, 2, 0),
+ ADD_TEST (writev, 2, 0),
+ ADD_TEST (usleep, 2, 0),
+ ADD_TEST (nanosleep, 2, 0),
+ ADD_TEST (wait, 2, 0),
+ ADD_TEST (waitid, 2, 0),
+ ADD_TEST (waitpid, 2, 0),
+ ADD_TEST (sigpause, 2, 0),
+ ADD_TEST (sigsuspend, 2, 0),
+ ADD_TEST (sigwait, 2, 0),
+ ADD_TEST (sigwaitinfo, 2, 0),
+ ADD_TEST (sigtimedwait, 2, 0),
+ ADD_TEST (pause, 2, 0),
+ ADD_TEST (accept, 2, 0),
+ ADD_TEST (send, 2, 0),
+ ADD_TEST (recv, 2, 0),
+ ADD_TEST (recvfrom, 2, 0),
+ ADD_TEST (recvmsg, 2, 0),
+ ADD_TEST (open, 2, 1),
+ ADD_TEST (close, 2, 1),
+ ADD_TEST (pread, 2, 1),
+ ADD_TEST (pwrite, 2, 1),
+ ADD_TEST (fsync, 2, 1),
+ ADD_TEST (fdatasync, 2, 1),
+ ADD_TEST (msync, 2, 1),
+ ADD_TEST (sendto, 2, 1),
+ ADD_TEST (sendmsg, 2, 1),
+ ADD_TEST (creat, 2, 1),
+ ADD_TEST (connect, 2, 1),
+ ADD_TEST (tcdrain, 2, 1),
+ ADD_TEST (msgrcv, 2, 0),
+ ADD_TEST (msgsnd, 2, 1),
+};
+#define ntest_tf (sizeof (tests) / sizeof (tests[0]))
+
+
+static int
+do_test (void)
+{
+ int val;
+ socklen_t len;
+
+ if (socketpair (AF_UNIX, SOCK_STREAM, PF_UNIX, fds) != 0)
+ {
+ perror ("socketpair");
+ exit (1);
+ }
+
+ val = 1;
+ len = sizeof(val);
+ setsockopt (fds[1], SOL_SOCKET, SO_SNDBUF, &val, sizeof(val));
+ if (getsockopt (fds[1], SOL_SOCKET, SO_SNDBUF, &val, &len) < 0)
+ {
+ perror ("getsockopt");
+ exit (1);
+ }
+ if (val >= WRITE_BUFFER_SIZE)
+ {
+ puts ("minimum write buffer size too large");
+ exit (1);
+ }
+ setsockopt (fds[1], SOL_SOCKET, SO_SNDBUF, &val, sizeof(val));
+
+ int result = 0;
+ size_t cnt;
+ for (cnt = 0; cnt < ntest_tf; ++cnt)
+ {
+ if (tests[cnt].only_early)
+ continue;
+
+ if (pthread_barrier_init (&b2, NULL, tests[cnt].nb) != 0)
+ {
+ puts ("b2 init failed");
+ exit (1);
+ }
+
+ /* Reset the counter for the cleanup handler. */
+ cl_called = 0;
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tests[cnt].tf, NULL) != 0)
+ {
+ printf ("create for '%s' test failed\n", tests[cnt].name);
+ result = 1;
+ continue;
+ }
+
+ int r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ result = 1;
+ continue;
+ }
+
+ struct timespec ts = { .tv_sec = 0, .tv_nsec = 100000000 };
+ while (nanosleep (&ts, &ts) != 0)
+ continue;
+
+ if (pthread_cancel (th) != 0)
+ {
+ printf ("cancel for '%s' failed\n", tests[cnt].name);
+ result = 1;
+ continue;
+ }
+
+ void *status;
+ if (pthread_join (th, &status) != 0)
+ {
+ printf ("join for '%s' failed\n", tests[cnt].name);
+ result = 1;
+ continue;
+ }
+ if (status != PTHREAD_CANCELED)
+ {
+ printf ("thread for '%s' not canceled\n", tests[cnt].name);
+ result = 1;
+ continue;
+ }
+
+ if (pthread_barrier_destroy (&b2) != 0)
+ {
+ puts ("barrier_destroy failed");
+ result = 1;
+ continue;
+ }
+
+ if (cl_called == 0)
+ {
+ printf ("cleanup handler not called for '%s'\n", tests[cnt].name);
+ result = 1;
+ continue;
+ }
+ if (cl_called > 1)
+ {
+ printf ("cleanup handler called more than once for '%s'\n",
+ tests[cnt].name);
+ result = 1;
+ continue;
+ }
+
+ printf ("in-time cancel test of '%s' successful\n", tests[cnt].name);
+
+ if (tempfd != -1)
+ {
+ close (tempfd);
+ tempfd = -1;
+ }
+ if (tempfd2 != -1)
+ {
+ close (tempfd2);
+ tempfd2 = -1;
+ }
+ if (tempfname != NULL)
+ {
+ unlink (tempfname);
+ free (tempfname);
+ tempfname = NULL;
+ }
+ if (tempmsg != -1)
+ {
+ msgctl (tempmsg, IPC_RMID, NULL);
+ tempmsg = -1;
+ }
+ }
+
+ for (cnt = 0; cnt < ntest_tf; ++cnt)
+ {
+ if (pthread_barrier_init (&b2, NULL, tests[cnt].nb) != 0)
+ {
+ puts ("b2 init failed");
+ exit (1);
+ }
+
+ /* Reset the counter for the cleanup handler. */
+ cl_called = 0;
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tests[cnt].tf, (void *) 1l) != 0)
+ {
+ printf ("create for '%s' test failed\n", tests[cnt].name);
+ result = 1;
+ continue;
+ }
+
+ int r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ result = 1;
+ continue;
+ }
+
+ if (pthread_cancel (th) != 0)
+ {
+ printf ("cancel for '%s' failed\n", tests[cnt].name);
+ result = 1;
+ continue;
+ }
+
+ r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ result = 1;
+ continue;
+ }
+
+ void *status;
+ if (pthread_join (th, &status) != 0)
+ {
+ printf ("join for '%s' failed\n", tests[cnt].name);
+ result = 1;
+ continue;
+ }
+ if (status != PTHREAD_CANCELED)
+ {
+ printf ("thread for '%s' not canceled\n", tests[cnt].name);
+ result = 1;
+ continue;
+ }
+
+ if (pthread_barrier_destroy (&b2) != 0)
+ {
+ puts ("barrier_destroy failed");
+ result = 1;
+ continue;
+ }
+
+ if (cl_called == 0)
+ {
+ printf ("cleanup handler not called for '%s'\n", tests[cnt].name);
+ result = 1;
+ continue;
+ }
+ if (cl_called > 1)
+ {
+ printf ("cleanup handler called more than once for '%s'\n",
+ tests[cnt].name);
+ result = 1;
+ continue;
+ }
+
+ printf ("early cancel test of '%s' successful\n", tests[cnt].name);
+
+ if (tempfd != -1)
+ {
+ close (tempfd);
+ tempfd = -1;
+ }
+ if (tempfd2 != -1)
+ {
+ close (tempfd2);
+ tempfd2 = -1;
+ }
+ if (tempfname != NULL)
+ {
+ unlink (tempfname);
+ free (tempfname);
+ tempfname = NULL;
+ }
+ if (tempmsg != -1)
+ {
+ msgctl (tempmsg, IPC_RMID, NULL);
+ tempmsg = -1;
+ }
+ }
+
+ return result;
+}
+
+#define TIMEOUT 60
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cancel5.c b/test/nptl/tst-cancel5.c
new file mode 100644
index 000000000..1c879eba8
--- /dev/null
+++ b/test/nptl/tst-cancel5.c
@@ -0,0 +1 @@
+#include "tst-cancel4.c"
diff --git a/test/nptl/tst-cancel6.c b/test/nptl/tst-cancel6.c
new file mode 100644
index 000000000..4e11277ea
--- /dev/null
+++ b/test/nptl/tst-cancel6.c
@@ -0,0 +1,78 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static void *
+tf (void *arg)
+{
+ char buf[100];
+ fgets (buf, sizeof (buf), arg);
+ /* This call should never return. */
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ int fd[2];
+ if (pipe (fd) != 0)
+ {
+ puts ("pipe failed");
+ return 1;
+ }
+
+ FILE *fp = fdopen (fd[0], "r");
+ if (fp == NULL)
+ {
+ puts ("fdopen failed");
+ return 1;
+ }
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, fp) != 0)
+ {
+ puts ("pthread_create failed");
+ return 1;
+ }
+
+ sleep (1);
+
+ if (pthread_cancel (th) != 0)
+ {
+ puts ("pthread_cancel failed");
+ return 1;
+ }
+
+ void *r;
+ if (pthread_join (th, &r) != 0)
+ {
+ puts ("pthread_join failed");
+ return 1;
+ }
+
+ return r != PTHREAD_CANCELED;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cancel7.c b/test/nptl/tst-cancel7.c
new file mode 100644
index 000000000..9e7d22ed5
--- /dev/null
+++ b/test/nptl/tst-cancel7.c
@@ -0,0 +1,208 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 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 <errno.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+const char *command;
+const char *pidfile;
+char pidfilename[] = "/tmp/tst-cancel7-XXXXXX";
+
+static void *
+tf (void *arg)
+{
+ const char *args = " -d -p ";
+ char *cmd = alloca (strlen (command) + strlen (args)
+ + strlen (pidfilename) + 1);
+
+ strcpy (stpcpy (stpcpy (cmd, command), args), pidfilename);
+ system (cmd);
+ /* This call should never return. */
+ return NULL;
+}
+
+
+static void
+sl (void)
+{
+ FILE *f = fopen (pidfile, "w");
+ if (f == NULL)
+ exit (1);
+
+ fprintf (f, "%lld\n", (long long) getpid ());
+ fflush (f);
+
+ struct flock fl =
+ {
+ .l_type = F_WRLCK,
+ .l_start = 0,
+ .l_whence = SEEK_SET,
+ .l_len = 1
+ };
+ if (fcntl (fileno (f), F_SETLK, &fl) != 0)
+ exit (1);
+
+ sigset_t ss;
+ sigfillset (&ss);
+ sigsuspend (&ss);
+ exit (0);
+}
+
+
+static void
+do_prepare (int argc, char *argv[])
+{
+ if (command == NULL)
+ command = argv[0];
+
+ if (pidfile)
+ sl ();
+
+ int fd = mkstemp (pidfilename);
+ if (fd == -1)
+ {
+ puts ("mkstemp failed");
+ exit (1);
+ }
+
+ write (fd, " ", 1);
+ close (fd);
+}
+
+
+static int
+do_test (void)
+{
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("pthread_create failed");
+ return 1;
+ }
+
+ do
+ sleep (1);
+ while (access (pidfilename, R_OK) != 0);
+
+ if (pthread_cancel (th) != 0)
+ {
+ puts ("pthread_cancel failed");
+ return 1;
+ }
+
+ void *r;
+ if (pthread_join (th, &r) != 0)
+ {
+ puts ("pthread_join failed");
+ return 1;
+ }
+
+ sleep (1);
+
+ FILE *f = fopen (pidfilename, "r+");
+ if (f == NULL)
+ {
+ puts ("no pidfile");
+ return 1;
+ }
+
+ long long ll;
+ if (fscanf (f, "%lld\n", &ll) != 1)
+ {
+ puts ("could not read pid");
+ unlink (pidfilename);
+ return 1;
+ }
+
+ struct flock fl =
+ {
+ .l_type = F_WRLCK,
+ .l_start = 0,
+ .l_whence = SEEK_SET,
+ .l_len = 1
+ };
+ if (fcntl (fileno (f), F_GETLK, &fl) != 0)
+ {
+ puts ("F_GETLK failed");
+ unlink (pidfilename);
+ return 1;
+ }
+
+ if (fl.l_type != F_UNLCK)
+ {
+ printf ("child %lld still running\n", (long long) fl.l_pid);
+ if (fl.l_pid == ll)
+ kill (fl.l_pid, SIGKILL);
+
+ unlink (pidfilename);
+ return 1;
+ }
+
+ fclose (f);
+
+ unlink (pidfilename);
+
+ return r != PTHREAD_CANCELED;
+}
+
+#if 0 /* unused */
+static void
+do_cleanup (void)
+{
+ FILE *f = fopen (pidfilename, "r+");
+ long long ll;
+
+ if (f != NULL && fscanf (f, "%lld\n", &ll) == 1)
+ {
+ struct flock fl =
+ {
+ .l_type = F_WRLCK,
+ .l_start = 0,
+ .l_whence = SEEK_SET,
+ .l_len = 1
+ };
+ if (fcntl (fileno (f), F_GETLK, &fl) == 0 && fl.l_type != F_UNLCK
+ && fl.l_pid == ll)
+ kill (fl.l_pid, SIGKILL);
+
+ fclose (f);
+ }
+
+ unlink (pidfilename);
+}
+#endif
+
+#define CMDLINE_OPTIONS \
+ "c:p:"
+#define CMDLINE_PROCESS \
+ case 'c': \
+ command = optarg; \
+ break; \
+ case 'p': \
+ pidfile = optarg; \
+ break;
+#define PREPARE(argc, argv) do_prepare (argc, argv)
+#define TEST_FUNCTION do_test ()
+#define TIMEOUT 5
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cancel8.c b/test/nptl/tst-cancel8.c
new file mode 100644
index 000000000..1c91d47a0
--- /dev/null
+++ b/test/nptl/tst-cancel8.c
@@ -0,0 +1,142 @@
+/* Copyright (C) 2003 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 <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static pthread_barrier_t bar;
+
+static int global;
+
+
+static void
+cleanup (void *arg)
+{
+ global = 1;
+}
+
+
+static void *
+tf (void *arg)
+{
+ /* Enable cancellation, but defer it. */
+ if (pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL) != 0)
+ {
+ puts ("setcancelstate failed");
+ exit (1);
+ }
+ if (pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, NULL) != 0)
+ {
+ puts ("setcanceltype failed");
+ exit (1);
+ }
+
+ /* Add cleanup handler. */
+ pthread_cleanup_push (cleanup, NULL);
+
+ /* Synchronize with the main thread. */
+ int r = pthread_barrier_wait (&bar);
+ if (r != 0 && r!= PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("tf: first barrier_wait failed");
+ exit (1);
+ }
+
+ /* And again. Once this is done the main thread should have canceled
+ this thread. */
+ r = pthread_barrier_wait (&bar);
+ if (r != 0 && r!= PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("tf: second barrier_wait failed");
+ exit (1);
+ }
+
+ /* Remove the cleanup handler without executing it. */
+ pthread_cleanup_pop (0);
+
+ /* Now react on the cancellation. */
+ pthread_testcancel ();
+
+ /* This call should never return. */
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ if (pthread_barrier_init (&bar, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ exit (1);
+ }
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("pthread_create failed");
+ return 1;
+ }
+
+ int r = pthread_barrier_wait (&bar);
+ if (r != 0 && r!= PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("first barrier_wait failed");
+ exit (1);
+ }
+
+ if (pthread_cancel (th) != 0)
+ {
+ puts ("pthread_cancel failed");
+ return 1;
+ }
+
+ r = pthread_barrier_wait (&bar);
+ if (r != 0 && r!= PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("second barrier_wait failed");
+ exit (1);
+ }
+
+ void *result;
+ if (pthread_join (th, &result) != 0)
+ {
+ puts ("pthread_join failed");
+ return 1;
+ }
+
+ if (result != PTHREAD_CANCELED)
+ {
+ puts ("thread was not canceled");
+ exit (1);
+ }
+
+ if (global != 0)
+ {
+ puts ("cancellation handler has been called");
+ exit (1);
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cancel9.c b/test/nptl/tst-cancel9.c
new file mode 100644
index 000000000..40a62c588
--- /dev/null
+++ b/test/nptl/tst-cancel9.c
@@ -0,0 +1,125 @@
+/* Copyright (C) 2003, 2004 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 <fcntl.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+
+static pthread_barrier_t b;
+
+
+static void
+cleanup (void *arg)
+{
+ fputs ("in cleanup\n", stdout);
+}
+
+
+static void *
+tf (void *arg)
+{
+ int fd = open ("/dev/null", O_RDWR);
+ if (fd == -1)
+ {
+ puts ("cannot open /dev/null");
+ exit (1);
+ }
+ FILE *fp = fdopen (fd, "w");
+ if (fp == NULL)
+ {
+ puts ("fdopen failed");
+ exit (1);
+ }
+
+ pthread_cleanup_push (cleanup, NULL);
+
+ int e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ exit (1);
+ }
+
+ while (1)
+ /* fprintf() uses write() which is a cancallation point. */
+ fprintf (fp, "foo");
+
+ pthread_cleanup_pop (0);
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ if (pthread_barrier_init (&b, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ exit (1);
+ }
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ return 1;
+ }
+
+ int e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ exit (1);
+ }
+
+ sleep (1);
+
+ puts ("cancel now");
+
+ if (pthread_cancel (th) != 0)
+ {
+ puts ("cancel failed");
+ exit (1);
+ }
+
+ puts ("waiting for the child");
+
+ void *r;
+ if (pthread_join (th, &r) != 0)
+ {
+ puts ("join failed");
+ exit (1);
+ }
+
+ if (r != PTHREAD_CANCELED)
+ {
+ puts ("thread wasn't canceled");
+ exit (1);
+ }
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cancelx10.c b/test/nptl/tst-cancelx10.c
new file mode 100644
index 000000000..e5bbb34e6
--- /dev/null
+++ b/test/nptl/tst-cancelx10.c
@@ -0,0 +1 @@
+#include "tst-cancel10.c"
diff --git a/test/nptl/tst-cancelx11.c b/test/nptl/tst-cancelx11.c
new file mode 100644
index 000000000..ffcc2eefc
--- /dev/null
+++ b/test/nptl/tst-cancelx11.c
@@ -0,0 +1 @@
+#include "tst-cancel11.c"
diff --git a/test/nptl/tst-cancelx12.c b/test/nptl/tst-cancelx12.c
new file mode 100644
index 000000000..f90ae61ba
--- /dev/null
+++ b/test/nptl/tst-cancelx12.c
@@ -0,0 +1 @@
+#include "tst-cancel12.c"
diff --git a/test/nptl/tst-cancelx13.c b/test/nptl/tst-cancelx13.c
new file mode 100644
index 000000000..37c4c39c3
--- /dev/null
+++ b/test/nptl/tst-cancelx13.c
@@ -0,0 +1 @@
+#include "tst-cancel13.c"
diff --git a/test/nptl/tst-cancelx14.c b/test/nptl/tst-cancelx14.c
new file mode 100644
index 000000000..ba4e77584
--- /dev/null
+++ b/test/nptl/tst-cancelx14.c
@@ -0,0 +1 @@
+#include "tst-cancel14.c"
diff --git a/test/nptl/tst-cancelx15.c b/test/nptl/tst-cancelx15.c
new file mode 100644
index 000000000..005c1f6e3
--- /dev/null
+++ b/test/nptl/tst-cancelx15.c
@@ -0,0 +1 @@
+#include "tst-cancel15.c"
diff --git a/test/nptl/tst-cancelx16.c b/test/nptl/tst-cancelx16.c
new file mode 100644
index 000000000..99af3b197
--- /dev/null
+++ b/test/nptl/tst-cancelx16.c
@@ -0,0 +1 @@
+#include "tst-cancel16.c"
diff --git a/test/nptl/tst-cancelx18.c b/test/nptl/tst-cancelx18.c
new file mode 100644
index 000000000..56da18f38
--- /dev/null
+++ b/test/nptl/tst-cancelx18.c
@@ -0,0 +1 @@
+#include "tst-cancel18.c"
diff --git a/test/nptl/tst-cancelx2.c b/test/nptl/tst-cancelx2.c
new file mode 100644
index 000000000..95dc8a857
--- /dev/null
+++ b/test/nptl/tst-cancelx2.c
@@ -0,0 +1 @@
+#include "tst-cancel2.c"
diff --git a/test/nptl/tst-cancelx20.c b/test/nptl/tst-cancelx20.c
new file mode 100644
index 000000000..6bd86376c
--- /dev/null
+++ b/test/nptl/tst-cancelx20.c
@@ -0,0 +1 @@
+#include "tst-cancel20.c"
diff --git a/test/nptl/tst-cancelx21.c b/test/nptl/tst-cancelx21.c
new file mode 100644
index 000000000..2a01061ea
--- /dev/null
+++ b/test/nptl/tst-cancelx21.c
@@ -0,0 +1 @@
+#include "tst-cancel21.c"
diff --git a/test/nptl/tst-cancelx3.c b/test/nptl/tst-cancelx3.c
new file mode 100644
index 000000000..3937f10b9
--- /dev/null
+++ b/test/nptl/tst-cancelx3.c
@@ -0,0 +1 @@
+#include "tst-cancel3.c"
diff --git a/test/nptl/tst-cancelx4.c b/test/nptl/tst-cancelx4.c
new file mode 100644
index 000000000..1c879eba8
--- /dev/null
+++ b/test/nptl/tst-cancelx4.c
@@ -0,0 +1 @@
+#include "tst-cancel4.c"
diff --git a/test/nptl/tst-cancelx6.c b/test/nptl/tst-cancelx6.c
new file mode 100644
index 000000000..6926e21c2
--- /dev/null
+++ b/test/nptl/tst-cancelx6.c
@@ -0,0 +1 @@
+#include "tst-cancel6.c"
diff --git a/test/nptl/tst-cancelx7.c b/test/nptl/tst-cancelx7.c
new file mode 100644
index 000000000..4df1a5881
--- /dev/null
+++ b/test/nptl/tst-cancelx7.c
@@ -0,0 +1 @@
+#include "tst-cancel7.c"
diff --git a/test/nptl/tst-cancelx8.c b/test/nptl/tst-cancelx8.c
new file mode 100644
index 000000000..0555c7ceb
--- /dev/null
+++ b/test/nptl/tst-cancelx8.c
@@ -0,0 +1 @@
+#include "tst-cancel8.c"
diff --git a/test/nptl/tst-cancelx9.c b/test/nptl/tst-cancelx9.c
new file mode 100644
index 000000000..9d84663d7
--- /dev/null
+++ b/test/nptl/tst-cancelx9.c
@@ -0,0 +1 @@
+#include "tst-cancel9.c"
diff --git a/test/nptl/tst-cleanup0.c b/test/nptl/tst-cleanup0.c
new file mode 100644
index 000000000..401115d73
--- /dev/null
+++ b/test/nptl/tst-cleanup0.c
@@ -0,0 +1,75 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static int global;
+
+
+static void
+ch (void *arg)
+{
+ int val = (long int) arg;
+
+ printf ("ch (%d)\n", val);
+
+ global *= val;
+ global += val;
+}
+
+
+static void
+endfct (void)
+{
+ /* We force exit right here. */
+ _exit (global);
+}
+
+
+static int
+do_test (void)
+{
+ atexit (endfct);
+
+ pthread_cancel (pthread_self ());
+
+ pthread_cleanup_push (ch, (void *) 1l);
+
+ pthread_cleanup_push (ch, (void *) 2l);
+
+ pthread_cleanup_push (ch, (void *) 3l);
+
+// pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+
+ pthread_cleanup_pop (1);
+
+ pthread_cleanup_pop (1);
+
+ pthread_cleanup_pop (1);
+
+ return 100;
+}
+
+
+#define EXPECTED_STATUS 9
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cleanup1.c b/test/nptl/tst-cleanup1.c
new file mode 100644
index 000000000..e89f434f5
--- /dev/null
+++ b/test/nptl/tst-cleanup1.c
@@ -0,0 +1,99 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static int global;
+
+
+static void
+ch (void *arg)
+{
+ int val = (long int) arg;
+
+ printf ("ch (%d)\n", val);
+
+ global *= val;
+ global += val;
+}
+
+
+static void *
+tf (void *a)
+{
+ pthread_cancel (pthread_self ());
+
+ pthread_cleanup_push (ch, (void *) 1l);
+
+ pthread_cleanup_push (ch, (void *) 2l);
+
+ pthread_cleanup_push (ch, (void *) 3l);
+
+ pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+
+ pthread_cleanup_pop (1);
+
+ pthread_cleanup_pop (1);
+
+ pthread_cleanup_pop (1);
+
+ return NULL;
+}
+
+
+int
+do_test (void)
+{
+ pthread_t th;
+
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ write (2, "create failed\n", 14);
+ _exit (1);
+ }
+
+ void *r;
+ int e;
+ if ((e = pthread_join (th, &r)) != 0)
+ {
+ printf ("join failed: %d\n", e);
+ _exit (1);
+ }
+
+ if (r != PTHREAD_CANCELED)
+ {
+ puts ("thread not canceled");
+ exit (1);
+ }
+
+ if (global != 9)
+ {
+ printf ("global = %d, expected 9\n", global);
+ exit (1);
+ }
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cleanup2.c b/test/nptl/tst-cleanup2.c
new file mode 100644
index 000000000..d01301b9f
--- /dev/null
+++ b/test/nptl/tst-cleanup2.c
@@ -0,0 +1,62 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Bao Duong <bduong@progress.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 <setjmp.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+
+static sigjmp_buf jmpbuf;
+
+static void
+sig_handler (int signo)
+{
+ siglongjmp (jmpbuf, 1);
+}
+
+static int
+do_test (void)
+{
+ char *p = NULL;
+ struct sigaction sa;
+
+ sa.sa_handler = sig_handler;
+ sigemptyset (&sa.sa_mask);
+ sa.sa_flags = SA_SIGINFO;
+
+ if (sigaction (SIGSEGV, &sa, 0))
+ {
+ perror ("installing SIGSEGV handler\n");
+ exit (1);
+ }
+
+ puts ("Attempting to sprintf to null ptr");
+ if (setjmp (jmpbuf))
+ {
+ puts ("Exiting main...");
+ return 0;
+ }
+
+ sprintf (p, "This should segv\n");
+
+ return 1;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cleanup3.c b/test/nptl/tst-cleanup3.c
new file mode 100644
index 000000000..67bd9eb6f
--- /dev/null
+++ b/test/nptl/tst-cleanup3.c
@@ -0,0 +1,97 @@
+/* Copyright (C) 2003 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 <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static int global;
+
+
+static void
+ch (void *arg)
+{
+ int val = (long int) arg;
+
+ printf ("ch (%d)\n", val);
+
+ global *= val;
+ global += val;
+}
+
+
+static void *
+tf (void *a)
+{
+ pthread_cleanup_push (ch, (void *) 1l);
+
+ pthread_cleanup_push (ch, (void *) 2l);
+
+ pthread_cleanup_push (ch, (void *) 3l);
+
+ pthread_exit ((void *) 1l);
+
+ pthread_cleanup_pop (1);
+
+ pthread_cleanup_pop (1);
+
+ pthread_cleanup_pop (1);
+
+ return NULL;
+}
+
+
+int
+do_test (void)
+{
+ pthread_t th;
+
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ write (2, "create failed\n", 14);
+ _exit (1);
+ }
+
+ void *r;
+ int e;
+ if ((e = pthread_join (th, &r)) != 0)
+ {
+ printf ("join failed: %d\n", e);
+ _exit (1);
+ }
+
+ if (r != (void *) 1l)
+ {
+ puts ("thread not canceled");
+ exit (1);
+ }
+
+ if (global != 9)
+ {
+ printf ("global = %d, expected 9\n", global);
+ exit (1);
+ }
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cleanup4.c b/test/nptl/tst-cleanup4.c
new file mode 100644
index 000000000..3fe399820
--- /dev/null
+++ b/test/nptl/tst-cleanup4.c
@@ -0,0 +1,197 @@
+/* Copyright (C) 2003 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/>. */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+/* LinuxThreads pthread_cleanup_{push,pop} helpers. */
+extern void _pthread_cleanup_push (struct _pthread_cleanup_buffer *__buffer,
+ void (*__routine) (void *),
+ void *__arg);
+extern void _pthread_cleanup_pop (struct _pthread_cleanup_buffer *__buffer,
+ int __execute);
+
+static int fds[2];
+static pthread_barrier_t b2;
+static int global;
+
+/* Defined in tst-cleanup4aux.c, never compiled with -fexceptions. */
+extern void fn5 (void);
+extern void fn7 (void);
+extern void fn9 (void);
+
+void
+clh (void *arg)
+{
+ int val = (long int) arg;
+
+ printf ("clh (%d)\n", val);
+
+ global *= val;
+ global += val;
+}
+
+
+static __attribute__((noinline)) void
+fn_read (void)
+{
+ int r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ char c;
+ read (fds[0], &c, 1);
+}
+
+
+__attribute__((noinline)) void
+fn0 (void)
+{
+ pthread_cleanup_push (clh, (void *) 1l);
+
+ fn_read ();
+
+ pthread_cleanup_pop (1);
+}
+
+
+__attribute__((noinline)) void
+fn1 (void)
+{
+ /* This is the old LinuxThreads pthread_cleanup_{push,pop}. */
+ struct _pthread_cleanup_buffer b;
+ _pthread_cleanup_push (&b, clh, (void *) 2l);
+
+ fn0 ();
+
+ _pthread_cleanup_pop (&b, 1);
+}
+
+
+static __attribute__((noinline)) void
+fn2 (void)
+{
+ pthread_cleanup_push (clh, (void *) 3l);
+
+ fn1 ();
+
+ pthread_cleanup_pop (1);
+}
+
+
+static void *
+tf (void *a)
+{
+ switch ((long) a)
+ {
+ case 0:
+ fn2 ();
+ break;
+ case 1:
+ fn5 ();
+ break;
+ case 2:
+ fn7 ();
+ break;
+ case 3:
+ fn9 ();
+ break;
+ }
+
+ return NULL;
+}
+
+
+int
+do_test (void)
+{
+ int result = 0;
+
+ if (pipe (fds) != 0)
+ {
+ puts ("pipe failed");
+ exit (1);
+ }
+
+ if (pthread_barrier_init (&b2, NULL, 2) != 0)
+ {
+ puts ("b2 init failed");
+ exit (1);
+ }
+
+ const int expect[] =
+ {
+ 15, /* 1 2 3 */
+ 276, /* 1 4 5 6 */
+ 120, /* 1 7 8 */
+ 460 /* 1 2 9 10 */
+ };
+
+ long i;
+ for (i = 0; i < 4; ++i)
+ {
+ global = 0;
+
+ printf ("test %ld\n", i);
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, (void *) i) != 0)
+ {
+ puts ("create failed");
+ exit (1);
+ }
+
+ int e = pthread_barrier_wait (&b2);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __FUNCTION__);
+ exit (1);
+ }
+
+ pthread_cancel (th);
+
+ void *r;
+ if ((e = pthread_join (th, &r)) != 0)
+ {
+ printf ("join failed: %d\n", e);
+ _exit (1);
+ }
+
+ if (r != PTHREAD_CANCELED)
+ {
+ puts ("thread not canceled");
+ exit (1);
+ }
+
+ if (global != expect[i])
+ {
+ printf ("global = %d, expected %d\n", global, expect[i]);
+ result = 1;
+ }
+ }
+
+ return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cleanup4aux.c b/test/nptl/tst-cleanup4aux.c
new file mode 100644
index 000000000..029c4939f
--- /dev/null
+++ b/test/nptl/tst-cleanup4aux.c
@@ -0,0 +1,120 @@
+/* Copyright (C) 2003 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/>. */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+extern void _pthread_cleanup_push (struct _pthread_cleanup_buffer *__buffer,
+ void (*__routine) (void *),
+ void *__arg);
+extern void _pthread_cleanup_pop (struct _pthread_cleanup_buffer *__buffer,
+ int __execute);
+
+extern void clh (void *arg);
+extern void fn0 (void);
+extern void fn1 (void);
+extern void fn5 (void);
+extern void fn7 (void);
+extern void fn9 (void);
+
+
+static __attribute__((noinline)) void
+fn3 (void)
+{
+ /* This is the old LinuxThreads pthread_cleanup_{push,pop}. */
+ struct _pthread_cleanup_buffer b;
+ _pthread_cleanup_push (&b, clh, (void *) 4l);
+
+ fn0 ();
+
+ _pthread_cleanup_pop (&b, 1);
+}
+
+
+static __attribute__((noinline)) void
+fn4 (void)
+{
+ pthread_cleanup_push (clh, (void *) 5l);
+
+ fn3 ();
+
+ pthread_cleanup_pop (1);
+}
+
+
+void
+fn5 (void)
+{
+ /* This is the old LinuxThreads pthread_cleanup_{push,pop}. */
+ struct _pthread_cleanup_buffer b;
+ _pthread_cleanup_push (&b, clh, (void *) 6l);
+
+ fn4 ();
+
+ _pthread_cleanup_pop (&b, 1);
+}
+
+
+static __attribute__((noinline)) void
+fn6 (void)
+{
+ pthread_cleanup_push (clh, (void *) 7l);
+
+ fn0 ();
+
+ pthread_cleanup_pop (1);
+}
+
+
+void
+fn7 (void)
+{
+ /* This is the old LinuxThreads pthread_cleanup_{push,pop}. */
+ struct _pthread_cleanup_buffer b;
+ _pthread_cleanup_push (&b, clh, (void *) 8l);
+
+ fn6 ();
+
+ _pthread_cleanup_pop (&b, 1);
+}
+
+
+static __attribute__((noinline)) void
+fn8 (void)
+{
+ pthread_cleanup_push (clh, (void *) 9l);
+
+ fn1 ();
+
+ pthread_cleanup_pop (1);
+}
+
+
+void
+fn9 (void)
+{
+ /* This is the old LinuxThreads pthread_cleanup_{push,pop}. */
+ struct _pthread_cleanup_buffer b;
+ _pthread_cleanup_push (&b, clh, (void *) 10l);
+
+ fn8 ();
+
+ _pthread_cleanup_pop (&b, 1);
+}
diff --git a/test/nptl/tst-cleanupx0.c b/test/nptl/tst-cleanupx0.c
new file mode 100644
index 000000000..0012ab1b2
--- /dev/null
+++ b/test/nptl/tst-cleanupx0.c
@@ -0,0 +1 @@
+#include "tst-cleanup0.c"
diff --git a/test/nptl/tst-cleanupx1.c b/test/nptl/tst-cleanupx1.c
new file mode 100644
index 000000000..21e9e58bd
--- /dev/null
+++ b/test/nptl/tst-cleanupx1.c
@@ -0,0 +1 @@
+#include "tst-cleanup1.c"
diff --git a/test/nptl/tst-cleanupx2.c b/test/nptl/tst-cleanupx2.c
new file mode 100644
index 000000000..8b9e35093
--- /dev/null
+++ b/test/nptl/tst-cleanupx2.c
@@ -0,0 +1 @@
+#include "tst-cleanup2.c"
diff --git a/test/nptl/tst-cleanupx3.c b/test/nptl/tst-cleanupx3.c
new file mode 100644
index 000000000..90baf904f
--- /dev/null
+++ b/test/nptl/tst-cleanupx3.c
@@ -0,0 +1 @@
+#include "tst-cleanup3.c"
diff --git a/test/nptl/tst-cleanupx4.c b/test/nptl/tst-cleanupx4.c
new file mode 100644
index 000000000..8dea954b5
--- /dev/null
+++ b/test/nptl/tst-cleanupx4.c
@@ -0,0 +1 @@
+#include "tst-cleanup4.c"
diff --git a/test/nptl/tst-clock.c b/test/nptl/tst-clock.c
new file mode 100644
index 000000000..2023cbc6d
--- /dev/null
+++ b/test/nptl/tst-clock.c
@@ -0,0 +1,123 @@
+/* Test program for POSIX clock_* functions.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000.
+
+ 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 <stdio.h>
+#include <string.h>
+#include <time.h>
+
+
+/* We want to see output immediately. */
+#define STDOUT_UNBUFFERED
+
+/* We expect to run at least 10 seconds. */
+#define TIMEOUT 15
+
+static int
+clock_test (clockid_t cl)
+{
+ struct timespec old_ts;
+ struct timespec ts;
+ struct timespec waitit;
+ int result = 0;
+ int i;
+
+ memset (&ts, '\0', sizeof ts);
+
+ waitit.tv_sec = 0;
+ waitit.tv_nsec = 500000000;
+
+ /* Get and print resolution of the clock. */
+ if (clock_getres (cl, &ts) == 0)
+ {
+ if (ts.tv_nsec < 0 || ts.tv_nsec >= 1000000000)
+ {
+ printf ("clock %d: nanosecond value of resolution wrong\n", cl);
+ result = 1;
+ }
+ else
+ printf ("clock %d: resolution = %ld.%09ld secs\n",
+ cl, ts.tv_sec, ts.tv_nsec);
+ }
+ else
+ {
+ printf ("clock %d: cannot get resolution\n", cl);
+ result = 1;
+ }
+
+ memset (&ts, '\0', sizeof ts);
+ memset (&old_ts, '\0', sizeof old_ts);
+
+ /* Next get the current time value a few times. */
+ for (i = 0; i < 10; ++i)
+ {
+ if (clock_gettime (cl, &ts) == 0)
+ {
+ if (ts.tv_nsec < 0 || ts.tv_nsec >= 1000000000)
+ {
+ printf ("clock %d: nanosecond value of time wrong (try %d)\n",
+ cl, i);
+ result = 1;
+ }
+ else
+ {
+ printf ("clock %d: time = %ld.%09ld secs\n",
+ cl, ts.tv_sec, ts.tv_nsec);
+
+ if (memcmp (&ts, &old_ts, sizeof ts) == 0)
+ {
+ printf ("clock %d: time hasn't changed (try %d)\n", cl, i);
+ result = 1;
+
+ old_ts = ts;
+ }
+ }
+ }
+ else
+ {
+ printf ("clock %d: cannot get time (try %d)\n", cl, i);
+ result = 1;
+ }
+
+ /* Wait a bit before the next iteration. */
+ nanosleep (&waitit, NULL);
+ }
+
+ return result;
+}
+
+static int
+do_test (void)
+{
+ clockid_t cl;
+ int result;
+
+ result = clock_test (CLOCK_REALTIME);
+
+ if (clock_getcpuclockid (0, &cl) == 0)
+ /* XXX It's not yet a bug when this fails. */
+ clock_test (cl);
+ else
+ printf("CPU clock unavailble, skipping test\n");
+
+ return result;
+}
+#define TEST_FUNCTION do_test ()
+
+
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-clock1.c b/test/nptl/tst-clock1.c
new file mode 100644
index 000000000..7e483b534
--- /dev/null
+++ b/test/nptl/tst-clock1.c
@@ -0,0 +1,50 @@
+/* Copyright (C) 2003, 2004 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 <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <unistd.h>
+
+
+int
+do_test (void)
+{
+#if defined _POSIX_THREAD_CPUTIME && _POSIX_THREAD_CPUTIME >= 0
+ clockid_t cl;
+ /* This is really only a linking-test here. */
+ int e = pthread_getcpuclockid (pthread_self (), &cl);
+ if (e != 0)
+ {
+# if _POSIX_THREAD_CPUTIME == 0
+ if (sysconf (_SC_THREAD_CPUTIME) >= 0)
+# endif
+ {
+ puts ("cpuclock advertized, but cannot get ID");
+ exit (1);
+ }
+ }
+#endif
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-clock2.c b/test/nptl/tst-clock2.c
new file mode 100644
index 000000000..df6ec00db
--- /dev/null
+++ b/test/nptl/tst-clock2.c
@@ -0,0 +1,201 @@
+/* Copyright (C) 2003, 2004 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 <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <unistd.h>
+
+
+#if defined _POSIX_THREAD_CPUTIME && _POSIX_THREAD_CPUTIME >= 0
+static pthread_barrier_t b2;
+static pthread_barrier_t bN;
+
+
+static void *
+tf (void *arg)
+{
+ int e = pthread_barrier_wait (&b2);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ exit (1);
+ }
+
+ e = pthread_barrier_wait (&bN);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ exit (1);
+ }
+
+ return NULL;
+}
+#endif
+
+
+int
+do_test (void)
+{
+#if defined _POSIX_THREAD_CPUTIME && _POSIX_THREAD_CPUTIME >= 0
+# define N 10
+
+# if _POSIX_THREAD_CPUTIME == 0
+ if (sysconf (_SC_THREAD_CPUTIME) < 0)
+ {
+ puts ("_POSIX_THREAD_CPUTIME option not available");
+ return 0;
+ }
+# endif
+
+ if (pthread_barrier_init (&b2, NULL, 2) != 0
+ || pthread_barrier_init (&bN, NULL, N + 1) != 0)
+ {
+ puts ("barrier_init failed");
+ return 1;
+ }
+
+ struct timespec ts = { .tv_sec = 0, .tv_nsec = 100000000 };
+ TEMP_FAILURE_RETRY (nanosleep (&ts, &ts));
+
+ pthread_t th[N + 1];
+ clockid_t cl[N + 1];
+# ifndef CLOCK_THREAD_CPUTIME_ID
+ if (pthread_getcpuclockid (pthread_self (), &cl[0]) != 0)
+ {
+ puts ("own pthread_getcpuclockid failed");
+ return 1;
+ }
+# else
+ cl[0] = CLOCK_THREAD_CPUTIME_ID;
+# endif
+
+ pthread_attr_t at;
+
+ if (pthread_attr_init (&at) != 0)
+ {
+ puts ("attr_init failed");
+ return 1;
+ }
+
+ if (pthread_attr_setstacksize (&at, 1 * 1024 * 1024) != 0)
+ {
+ puts ("attr_setstacksize failed");
+ return 1;
+ }
+
+ int i;
+ int e;
+ for (i = 0; i < N; ++i)
+ {
+ if (pthread_create (&th[i], &at, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ return 1;
+ }
+
+ e = pthread_barrier_wait (&b2);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ return 1;
+ }
+
+ ts.tv_sec = 0;
+ ts.tv_nsec = 100000000;
+ TEMP_FAILURE_RETRY (nanosleep (&ts, &ts));
+
+ if (pthread_getcpuclockid (th[i], &cl[i + 1]) != 0)
+ {
+ puts ("pthread_getcpuclockid failed");
+ return 1;
+ }
+ }
+
+ if (pthread_attr_destroy (&at) != 0)
+ {
+ puts ("attr_destroy failed");
+ return 1;
+ }
+
+ struct timespec t[N + 1];
+ for (i = 0; i < N + 1; ++i)
+ if (clock_gettime (cl[i], &t[i]) != 0)
+ {
+ printf ("clock_gettime round %d failed\n", i);
+ return 1;
+ }
+
+ for (i = 0; i < N; ++i)
+ {
+ struct timespec diff;
+
+ diff.tv_sec = t[i].tv_sec - t[i + 1].tv_sec;
+ diff.tv_nsec = t[i].tv_nsec - t[i + 1].tv_nsec;
+ if (diff.tv_nsec < 0)
+ {
+ diff.tv_nsec += 1000000000;
+ --diff.tv_sec;
+ }
+
+ if (diff.tv_sec < 0 || (diff.tv_sec == 0 && diff.tv_nsec < 100000000))
+ {
+ printf ("\
+difference between thread %d and %d too small (%ld.%09ld)\n",
+ i, i + 1, (long int) diff.tv_sec, (long int) diff.tv_nsec);
+ return 1;
+ }
+
+ printf ("diff %d->%d: %ld.%09ld\n",
+ i, i + 1, (long int) diff.tv_sec, (long int) diff.tv_nsec);
+ }
+
+ ts.tv_sec = 0;
+ ts.tv_nsec = 0;
+ for (i = 0; i < N + 1; ++i)
+ if (clock_settime (cl[i], &ts) != 0)
+ {
+ printf ("clock_settime(%d) round %d failed\n", cl[i], i);
+ return 1;
+ }
+
+ for (i = 0; i < N + 1; ++i)
+ {
+ if (clock_gettime (cl[i], &ts) != 0)
+ {
+ puts ("clock_gettime failed");
+ return 1;
+ }
+
+ if (ts.tv_sec > t[i].tv_sec
+ || (ts.tv_sec == t[i].tv_sec && ts.tv_nsec > t[i].tv_nsec))
+ {
+ puts ("clock_settime didn't reset clock");
+ return 1;
+ }
+ }
+#endif
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-clock_nanosleep.c b/test/nptl/tst-clock_nanosleep.c
new file mode 100644
index 000000000..a2d1f0085
--- /dev/null
+++ b/test/nptl/tst-clock_nanosleep.c
@@ -0,0 +1,57 @@
+/* Copyright (C) 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 <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/time.h>
+#include <time.h>
+
+
+/* Test that clock_nanosleep() does sleep. */
+static int
+do_test (void)
+{
+ /* Current time. */
+ struct timeval tv1;
+ (void) gettimeofday (&tv1, NULL);
+
+ struct timespec ts;
+ ts.tv_sec = 1;
+ ts.tv_nsec = 0;
+ TEMP_FAILURE_RETRY (clock_nanosleep (CLOCK_REALTIME, 0, &ts, &ts));
+
+ /* At least one second must have passed. */
+ struct timeval tv2;
+ (void) gettimeofday (&tv2, NULL);
+
+ tv2.tv_sec -= tv1.tv_sec;
+ tv2.tv_usec -= tv1.tv_usec;
+ if (tv2.tv_usec < 0)
+ --tv2.tv_sec;
+
+ if (tv2.tv_sec < 1)
+ {
+ puts ("clock_nanosleep didn't sleep long enough");
+ return 1;
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cond1.c b/test/nptl/tst-cond1.c
new file mode 100644
index 000000000..30efe5b5e
--- /dev/null
+++ b/test/nptl/tst-cond1.c
@@ -0,0 +1,93 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <error.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
+
+
+static void *
+tf (void *p)
+{
+ int err;
+
+ err = pthread_mutex_lock (&mut);
+ if (err != 0)
+ error (EXIT_FAILURE, err, "child: cannot get mutex");
+
+ puts ("child: got mutex; signalling");
+
+ pthread_cond_signal (&cond);
+
+ puts ("child: unlock");
+
+ err = pthread_mutex_unlock (&mut);
+ if (err != 0)
+ error (EXIT_FAILURE, err, "child: cannot unlock");
+
+ puts ("child: done");
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ pthread_t th;
+ int err;
+
+ printf ("&cond = %p\n&mut = %p\n", &cond, &mut);
+
+ puts ("parent: get mutex");
+
+ err = pthread_mutex_lock (&mut);
+ if (err != 0)
+ error (EXIT_FAILURE, err, "parent: cannot get mutex");
+
+ puts ("parent: create child");
+
+ err = pthread_create (&th, NULL, tf, NULL);
+ if (err != 0)
+ error (EXIT_FAILURE, err, "parent: cannot create thread");
+
+ puts ("parent: wait for condition");
+
+ err = pthread_cond_wait (&cond, &mut);
+ if (err != 0)
+ error (EXIT_FAILURE, err, "parent: cannot wait fir signal");
+
+ puts ("parent: got signal");
+
+ err = pthread_join (th, NULL);
+ if (err != 0)
+ error (EXIT_FAILURE, err, "parent: failed to join");
+
+ puts ("done");
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cond10.c b/test/nptl/tst-cond10.c
new file mode 100644
index 000000000..cd5247727
--- /dev/null
+++ b/test/nptl/tst-cond10.c
@@ -0,0 +1,172 @@
+/* Copyright (C) 2003, 2004 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 <error.h>
+#include <pthread.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+#define N 10
+#define ROUNDS 100
+
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
+static pthread_barrier_t bN1;
+static pthread_barrier_t b2;
+
+
+static void *
+tf (void *p)
+{
+ if (pthread_mutex_lock (&mut) != 0)
+ {
+ puts ("child: 1st mutex_lock failed");
+ exit (1);
+ }
+
+ int e = pthread_barrier_wait (&b2);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("child: 1st barrier_wait failed");
+ exit (1);
+ }
+
+ if (pthread_cond_wait (&cond, &mut) != 0)
+ {
+ puts ("child: cond_wait failed");
+ exit (1);
+ }
+
+ if (pthread_mutex_unlock (&mut) != 0)
+ {
+ puts ("child: mutex_unlock failed");
+ exit (1);
+ }
+
+ e = pthread_barrier_wait (&bN1);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("child: 2nd barrier_wait failed");
+ exit (1);
+ }
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ if (pthread_barrier_init (&bN1, NULL, N + 1) != 0)
+ {
+ puts ("barrier_init failed");
+ exit (1);
+ }
+
+ if (pthread_barrier_init (&b2, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ exit (1);
+ }
+
+ pthread_attr_t at;
+
+ if (pthread_attr_init (&at) != 0)
+ {
+ puts ("attr_init failed");
+ return 1;
+ }
+
+ if (pthread_attr_setstacksize (&at, 1 * 1024 * 1024) != 0)
+ {
+ puts ("attr_setstacksize failed");
+ return 1;
+ }
+
+ int r;
+ for (r = 0; r < ROUNDS; ++r)
+ {
+ printf ("round %d\n", r + 1);
+
+ int i;
+ pthread_t th[N];
+ for (i = 0; i < N; ++i)
+ {
+ if (pthread_create (&th[i], &at, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ exit (1);
+ }
+
+ int e = pthread_barrier_wait (&b2);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("parent: 1st barrier_wait failed");
+ exit (1);
+ }
+ }
+
+ if (pthread_mutex_lock (&mut) != 0)
+ {
+ puts ("parent: mutex_lock failed");
+ exit (1);
+ }
+ if (pthread_mutex_unlock (&mut) != 0)
+ {
+ puts ("parent: mutex_unlock failed");
+ exit (1);
+ }
+
+ /* N single signal calls. Without locking. This tests that no
+ signal gets lost. */
+ for (i = 0; i < N; ++i)
+ if (pthread_cond_signal (&cond) != 0)
+ {
+ puts ("cond_signal failed");
+ exit (1);
+ }
+
+ int e = pthread_barrier_wait (&bN1);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("parent: 2nd barrier_wait failed");
+ exit (1);
+ }
+
+ for (i = 0; i < N; ++i)
+ if (pthread_join (th[i], NULL) != 0)
+ {
+ puts ("join failed");
+ exit (1);
+ }
+ }
+
+ if (pthread_attr_destroy (&at) != 0)
+ {
+ puts ("attr_destroy failed");
+ return 1;
+ }
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cond11.c b/test/nptl/tst-cond11.c
new file mode 100644
index 000000000..4aaf38002
--- /dev/null
+++ b/test/nptl/tst-cond11.c
@@ -0,0 +1,190 @@
+/* Copyright (C) 2003, 2004 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 <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <time.h>
+#include <unistd.h>
+
+
+#if defined _POSIX_CLOCK_SELECTION && _POSIX_CLOCK_SELECTION >= 0
+static int
+run_test (clockid_t cl)
+{
+ pthread_condattr_t condattr;
+ pthread_cond_t cond;
+ pthread_mutexattr_t mutattr;
+ pthread_mutex_t mut;
+
+ printf ("clock = %d\n", (int) cl);
+
+ if (pthread_condattr_init (&condattr) != 0)
+ {
+ puts ("condattr_init failed");
+ return 1;
+ }
+
+ if (pthread_condattr_setclock (&condattr, cl) != 0)
+ {
+ puts ("condattr_setclock failed");
+ return 1;
+ }
+
+ clockid_t cl2;
+ if (pthread_condattr_getclock (&condattr, &cl2) != 0)
+ {
+ puts ("condattr_getclock failed");
+ return 1;
+ }
+ if (cl != cl2)
+ {
+ printf ("condattr_getclock returned wrong value: %d, expected %d\n",
+ (int) cl2, (int) cl);
+ return 1;
+ }
+
+ if (pthread_cond_init (&cond, &condattr) != 0)
+ {
+ puts ("cond_init failed");
+ return 1;
+ }
+
+ if (pthread_condattr_destroy (&condattr) != 0)
+ {
+ puts ("condattr_destroy failed");
+ return 1;
+ }
+
+ if (pthread_mutexattr_init (&mutattr) != 0)
+ {
+ puts ("mutexattr_init failed");
+ return 1;
+ }
+
+ if (pthread_mutexattr_settype (&mutattr, PTHREAD_MUTEX_ERRORCHECK) != 0)
+ {
+ puts ("mutexattr_settype failed");
+ return 1;
+ }
+
+ if (pthread_mutex_init (&mut, &mutattr) != 0)
+ {
+ puts ("mutex_init failed");
+ return 1;
+ }
+
+ if (pthread_mutexattr_destroy (&mutattr) != 0)
+ {
+ puts ("mutexattr_destroy failed");
+ return 1;
+ }
+
+ if (pthread_mutex_lock (&mut) != 0)
+ {
+ puts ("mutex_lock failed");
+ return 1;
+ }
+
+ if (pthread_mutex_lock (&mut) != EDEADLK)
+ {
+ puts ("2nd mutex_lock did not return EDEADLK");
+ return 1;
+ }
+
+ struct timespec ts;
+ if (clock_gettime (cl, &ts) != 0)
+ {
+ puts ("clock_gettime failed");
+ return 1;
+ }
+
+ /* Wait one second. */
+ ++ts.tv_sec;
+
+ int e = pthread_cond_timedwait (&cond, &mut, &ts);
+ if (e == 0)
+ {
+ puts ("cond_timedwait succeeded");
+ return 1;
+ }
+ else if (e != ETIMEDOUT)
+ {
+ puts ("cond_timedwait did not return ETIMEDOUT");
+ return 1;
+ }
+
+ if (pthread_mutex_unlock (&mut) != 0)
+ {
+ puts ("mutex_unlock failed");
+ return 1;
+ }
+
+ if (pthread_mutex_destroy (&mut) != 0)
+ {
+ puts ("mutex_destroy failed");
+ return 1;
+ }
+
+ if (pthread_cond_destroy (&cond) != 0)
+ {
+ puts ("cond_destroy failed");
+ return 1;
+ }
+
+ return 0;
+}
+#endif
+
+
+static int
+do_test (void)
+{
+#if !defined _POSIX_CLOCK_SELECTION || _POSIX_CLOCK_SELECTION == -1
+
+ puts ("_POSIX_CLOCK_SELECTION not supported, test skipped");
+ return 0;
+
+#else
+
+ int res = run_test (CLOCK_REALTIME);
+
+# if defined _POSIX_MONOTONIC_CLOCK && _POSIX_MONOTONIC_CLOCK >= 0
+# if _POSIX_MONOTONIC_CLOCK == 0
+ int e = sysconf (_SC_MONOTONIC_CLOCK);
+ if (e < 0)
+ puts ("CLOCK_MONOTONIC not supported");
+ else if (e == 0)
+ {
+ puts ("sysconf (_SC_MONOTONIC_CLOCK) must not return 0");
+ res = 1;
+ }
+ else
+# endif
+ res |= run_test (CLOCK_MONOTONIC);
+# else
+ puts ("_POSIX_MONOTONIC_CLOCK not defined");
+# endif
+
+ return res;
+#endif
+}
+
+#define TIMEOUT 3
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cond12.c b/test/nptl/tst-cond12.c
new file mode 100644
index 000000000..b38d9d5ec
--- /dev/null
+++ b/test/nptl/tst-cond12.c
@@ -0,0 +1,195 @@
+/* Copyright (C) 2003 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 <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+
+
+static char fname[] = "/tmp/tst-cond12-XXXXXX";
+static int fd;
+
+
+static void prepare (void);
+#define PREPARE(argc, argv) prepare ()
+
+static int do_test (void);
+#define TEST_FUNCTION do_test ()
+
+#include "../test-skeleton.c"
+
+
+static void
+prepare (void)
+{
+ fd = mkstemp (fname);
+ if (fd == -1)
+ {
+ printf ("mkstemp failed: %m\n");
+ exit (1);
+ }
+ add_temp_file (fname);
+ if (ftruncate (fd, 1000) < 0)
+ {
+ printf ("ftruncate failed: %m\n");
+ exit (1);
+ }
+}
+
+
+static int
+do_test (void)
+{
+ struct
+ {
+ pthread_mutex_t m;
+ pthread_cond_t c;
+ int var;
+ } *p = mmap (NULL, sizeof (*p), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
+ if (p == MAP_FAILED)
+ {
+ printf ("initial mmap failed: %m\n");
+ return 1;
+ }
+
+ pthread_mutexattr_t ma;
+ if (pthread_mutexattr_init (&ma) != 0)
+ {
+ puts ("mutexattr_init failed");
+ return 1;
+ }
+ if (pthread_mutexattr_setpshared (&ma, 1) != 0)
+ {
+ puts ("mutexattr_setpshared failed");
+ return 1;
+ }
+ if (pthread_mutex_init (&p->m, &ma) != 0)
+ {
+ puts ("mutex_init failed");
+ return 1;
+ }
+ if (pthread_mutexattr_destroy (&ma) != 0)
+ {
+ puts ("mutexattr_destroy failed");
+ return 1;
+ }
+
+ pthread_condattr_t ca;
+ if (pthread_condattr_init (&ca) != 0)
+ {
+ puts ("condattr_init failed");
+ return 1;
+ }
+ if (pthread_condattr_setpshared (&ca, 1) != 0)
+ {
+ puts ("condattr_setpshared failed");
+ return 1;
+ }
+ if (pthread_cond_init (&p->c, &ca) != 0)
+ {
+ puts ("mutex_init failed");
+ return 1;
+ }
+ if (pthread_condattr_destroy (&ca) != 0)
+ {
+ puts ("condattr_destroy failed");
+ return 1;
+ }
+
+ if (pthread_mutex_lock (&p->m) != 0)
+ {
+ puts ("initial mutex_lock failed");
+ return 1;
+ }
+
+ p->var = 42;
+
+ pid_t pid = fork ();
+ if (pid == -1)
+ {
+ printf ("fork failed: %m\n");
+ return 1;
+ }
+
+ if (pid == 0)
+ {
+ void *oldp = p;
+ p = mmap (NULL, sizeof (*p), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
+
+ if (p == oldp)
+ {
+ puts ("child: mapped to same address");
+ kill (getppid (), SIGKILL);
+ exit (1);
+ }
+
+ munmap (oldp, sizeof (*p));
+
+ if (pthread_mutex_lock (&p->m) != 0)
+ {
+ puts ("child: mutex_lock failed");
+ kill (getppid (), SIGKILL);
+ exit (1);
+ }
+
+ p->var = 0;
+
+#ifndef USE_COND_SIGNAL
+ if (pthread_cond_broadcast (&p->c) != 0)
+ {
+ puts ("child: cond_broadcast failed");
+ kill (getppid (), SIGKILL);
+ exit (1);
+ }
+#else
+ if (pthread_cond_signal (&p->c) != 0)
+ {
+ puts ("child: cond_signal failed");
+ kill (getppid (), SIGKILL);
+ exit (1);
+ }
+#endif
+
+ if (pthread_mutex_unlock (&p->m) != 0)
+ {
+ puts ("child: mutex_unlock failed");
+ kill (getppid (), SIGKILL);
+ exit (1);
+ }
+
+ exit (0);
+ }
+
+ do
+ pthread_cond_wait (&p->c, &p->m);
+ while (p->var != 0);
+
+ if (TEMP_FAILURE_RETRY (waitpid (pid, NULL, 0)) != pid)
+ {
+ printf ("waitpid failed: %m\n");
+ kill (pid, SIGKILL);
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/test/nptl/tst-cond13.c b/test/nptl/tst-cond13.c
new file mode 100644
index 000000000..29d79b533
--- /dev/null
+++ b/test/nptl/tst-cond13.c
@@ -0,0 +1,2 @@
+#define USE_COND_SIGNAL 1
+#include "tst-cond12.c"
diff --git a/test/nptl/tst-cond14.c b/test/nptl/tst-cond14.c
new file mode 100644
index 000000000..837840582
--- /dev/null
+++ b/test/nptl/tst-cond14.c
@@ -0,0 +1,117 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
+
+ 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 <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t mut = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+static pthread_mutex_t mut2 = PTHREAD_MUTEX_INITIALIZER;
+
+static void *
+tf (void *p)
+{
+ if (pthread_mutex_lock (&mut) != 0)
+ {
+ printf ("%s: 1st mutex_lock failed\n", __func__);
+ exit (1);
+ }
+ if (pthread_mutex_lock (&mut) != 0)
+ {
+ printf ("%s: 2nd mutex_lock failed\n", __func__);
+ exit (1);
+ }
+ if (pthread_mutex_lock (&mut) != 0)
+ {
+ printf ("%s: 3rd mutex_lock failed\n", __func__);
+ exit (1);
+ }
+
+ if (pthread_mutex_unlock (&mut2) != 0)
+ {
+ printf ("%s: mutex_unlock failed\n", __func__);
+ exit (1);
+ }
+
+ if (pthread_cond_wait (&cond, &mut) != 0)
+ {
+ printf ("%s: cond_wait failed\n", __func__);
+ exit (1);
+ }
+
+ puts ("child: done");
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ if (pthread_mutex_lock (&mut2) != 0)
+ {
+ puts ("1st mutex_lock failed");
+ return 1;
+ }
+
+ puts ("parent: create child");
+
+ pthread_t th;
+ int err = pthread_create (&th, NULL, tf, NULL);
+ if (err != 0)
+ {
+ printf ("parent: cannot create thread: %s\n", strerror (err));
+ return 1;
+ }
+
+ /* We have to synchronize with the child. */
+ if (pthread_mutex_lock (&mut2) != 0)
+ {
+ puts ("2nd mutex_lock failed");
+ return 1;
+ }
+
+ /* Give the child to reach to pthread_cond_wait. */
+ sleep (1);
+
+ if (pthread_cond_signal (&cond) != 0)
+ {
+ puts ("cond_signal failed");
+ return 1;
+ }
+
+ err = pthread_join (th, NULL);
+ if (err != 0)
+ {
+ printf ("parent: failed to join: %s\n", strerror (err));
+ return 1;
+ }
+
+ puts ("done");
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#define TIMEOUT 3
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cond15.c b/test/nptl/tst-cond15.c
new file mode 100644
index 000000000..0e8448c11
--- /dev/null
+++ b/test/nptl/tst-cond15.c
@@ -0,0 +1,159 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
+
+ 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 <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/time.h>
+
+
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t mut = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+static pthread_mutex_t mut2 = PTHREAD_MUTEX_INITIALIZER;
+
+static void *
+tf (void *p)
+{
+ if (pthread_mutex_lock (&mut) != 0)
+ {
+ printf ("%s: 1st mutex_lock failed\n", __func__);
+ exit (1);
+ }
+ if (pthread_mutex_lock (&mut) != 0)
+ {
+ printf ("%s: 2nd mutex_lock failed\n", __func__);
+ exit (1);
+ }
+ if (pthread_mutex_lock (&mut) != 0)
+ {
+ printf ("%s: 3rd mutex_lock failed\n", __func__);
+ exit (1);
+ }
+
+ if (pthread_mutex_unlock (&mut2) != 0)
+ {
+ printf ("%s: mutex_unlock failed\n", __func__);
+ exit (1);
+ }
+
+ struct timeval tv;
+ gettimeofday (&tv, NULL);
+ struct timespec ts;
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+ ts.tv_sec += p == NULL ? 100 : 1;
+
+ int err = pthread_cond_timedwait (&cond, &mut, &ts);
+ if ((err != 0 && p == NULL) || (err != ETIMEDOUT && p != NULL))
+ {
+ printf ("%s: cond_wait failed\n", __func__);
+ exit (1);
+ }
+
+ if (pthread_mutex_unlock (&mut) != 0)
+ {
+ printf ("%s: 1st mutex_unlock failed\n", __func__);
+ exit (1);
+ }
+ if (pthread_mutex_unlock (&mut) != 0)
+ {
+ printf ("%s: 2nd mutex_unlock failed\n", __func__);
+ exit (1);
+ }
+ if (pthread_mutex_unlock (&mut) != 0)
+ {
+ printf ("%s: 3rd mutex_unlock failed\n", __func__);
+ exit (1);
+ }
+
+ puts ("child: done");
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ if (pthread_mutex_lock (&mut2) != 0)
+ {
+ puts ("1st mutex_lock failed");
+ return 1;
+ }
+
+ puts ("parent: create 1st child");
+
+ pthread_t th;
+ int err = pthread_create (&th, NULL, tf, NULL);
+ if (err != 0)
+ {
+ printf ("parent: cannot 1st create thread: %s\n", strerror (err));
+ return 1;
+ }
+
+ /* We have to synchronize with the child. */
+ if (pthread_mutex_lock (&mut2) != 0)
+ {
+ puts ("2nd mutex_lock failed");
+ return 1;
+ }
+
+ /* Give the child to reach to pthread_cond_wait. */
+ sleep (1);
+
+ if (pthread_cond_signal (&cond) != 0)
+ {
+ puts ("cond_signal failed");
+ return 1;
+ }
+
+ err = pthread_join (th, NULL);
+ if (err != 0)
+ {
+ printf ("parent: failed to join: %s\n", strerror (err));
+ return 1;
+ }
+
+
+ puts ("parent: create 2nd child");
+
+ err = pthread_create (&th, NULL, tf, (void *) 1l);
+ if (err != 0)
+ {
+ printf ("parent: cannot 2nd create thread: %s\n", strerror (err));
+ return 1;
+ }
+
+ err = pthread_join (th, NULL);
+ if (err != 0)
+ {
+ printf ("parent: failed to join: %s\n", strerror (err));
+ return 1;
+ }
+
+ puts ("done");
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#define TIMEOUT 6
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cond16.c b/test/nptl/tst-cond16.c
new file mode 100644
index 000000000..44b98634b
--- /dev/null
+++ b/test/nptl/tst-cond16.c
@@ -0,0 +1,104 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
+
+ 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 <pthread.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+pthread_cond_t cv = PTHREAD_COND_INITIALIZER;
+pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+bool n, exiting;
+FILE *f;
+int count;
+
+void *
+tf (void *dummy)
+{
+ bool loop = true;
+
+ while (loop)
+ {
+ pthread_mutex_lock (&lock);
+ while (n && !exiting)
+ pthread_cond_wait (&cv, &lock);
+ n = true;
+ pthread_mutex_unlock (&lock);
+
+ fputs (".", f);
+
+ pthread_mutex_lock (&lock);
+ n = false;
+ if (exiting)
+ loop = false;
+#ifdef UNLOCK_AFTER_BROADCAST
+ pthread_cond_broadcast (&cv);
+ pthread_mutex_unlock (&lock);
+#else
+ pthread_mutex_unlock (&lock);
+ pthread_cond_broadcast (&cv);
+#endif
+ }
+
+ return NULL;
+}
+
+int
+do_test (void)
+{
+ f = fopen ("/dev/null", "w");
+ if (f == NULL)
+ {
+ printf ("couldn't open /dev/null, %m\n");
+ return 1;
+ }
+
+ count = sysconf (_SC_NPROCESSORS_ONLN);
+ if (count <= 0)
+ count = 1;
+ count *= 4;
+
+ pthread_t th[count];
+ int i, ret;
+ for (i = 0; i < count; ++i)
+ if ((ret = pthread_create (&th[i], NULL, tf, NULL)) != 0)
+ {
+ errno = ret;
+ printf ("pthread_create %d failed: %m\n", i);
+ return 1;
+ }
+
+ struct timespec ts = { .tv_sec = 20, .tv_nsec = 0 };
+ while (nanosleep (&ts, &ts) != 0);
+
+ pthread_mutex_lock (&lock);
+ exiting = true;
+ pthread_mutex_unlock (&lock);
+
+ for (i = 0; i < count; ++i)
+ pthread_join (th[i], NULL);
+
+ fclose (f);
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#define TIMEOUT 40
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cond17.c b/test/nptl/tst-cond17.c
new file mode 100644
index 000000000..0586fa59a
--- /dev/null
+++ b/test/nptl/tst-cond17.c
@@ -0,0 +1,2 @@
+#define UNLOCK_AFTER_BROADCAST 1
+#include "tst-cond16.c"
diff --git a/test/nptl/tst-cond18.c b/test/nptl/tst-cond18.c
new file mode 100644
index 000000000..a1bb947ac
--- /dev/null
+++ b/test/nptl/tst-cond18.c
@@ -0,0 +1,116 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
+
+ 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 <fcntl.h>
+#include <pthread.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+
+pthread_cond_t cv = PTHREAD_COND_INITIALIZER;
+pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+bool exiting;
+int fd, count, spins, nn;
+
+void *
+tf (void *id)
+{
+ pthread_mutex_lock (&lock);
+
+ if ((long) id == 0)
+ {
+ while (!exiting)
+ {
+ if ((spins++ % 1000) == 0)
+ write (fd, ".", 1);
+ pthread_mutex_unlock (&lock);
+
+ pthread_mutex_lock (&lock);
+ int njobs = rand () % (count + 1);
+ nn = njobs;
+ if ((rand () % 30) == 0)
+ pthread_cond_broadcast (&cv);
+ else
+ while (njobs--)
+ pthread_cond_signal (&cv);
+ }
+
+ pthread_cond_broadcast (&cv);
+ }
+ else
+ {
+ while (!exiting)
+ {
+ while (!nn && !exiting)
+ pthread_cond_wait (&cv, &lock);
+ --nn;
+ pthread_mutex_unlock (&lock);
+
+ pthread_mutex_lock (&lock);
+ }
+ }
+
+ pthread_mutex_unlock (&lock);
+ return NULL;
+}
+
+int
+do_test (void)
+{
+ fd = open ("/dev/null", O_WRONLY);
+ if (fd < 0)
+ {
+ printf ("couldn't open /dev/null, %m\n");
+ return 1;
+ }
+
+ count = sysconf (_SC_NPROCESSORS_ONLN);
+ if (count <= 0)
+ count = 1;
+ count *= 8;
+
+ pthread_t th[count + 1];
+ int i, ret;
+
+ for (i = 0; i <= count; ++i)
+ if ((ret = pthread_create (&th[i], NULL, tf, (void *) (long) i)) != 0)
+ {
+ errno = ret;
+ printf ("pthread_create %d failed: %m\n", i);
+ return 1;
+ }
+
+ struct timespec ts = { .tv_sec = 20, .tv_nsec = 0 };
+ while (nanosleep (&ts, &ts) != 0);
+
+ pthread_mutex_lock (&lock);
+ exiting = true;
+ pthread_mutex_unlock (&lock);
+
+ for (i = 0; i < count; ++i)
+ pthread_join (th[i], NULL);
+
+ close (fd);
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#define TIMEOUT 40
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cond19.c b/test/nptl/tst-cond19.c
new file mode 100644
index 000000000..200e0eaf0
--- /dev/null
+++ b/test/nptl/tst-cond19.c
@@ -0,0 +1,75 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
+
+ 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 <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+
+
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
+
+
+static int
+do_test (void)
+{
+ int result = 0;
+ struct timespec ts;
+
+ if (clock_gettime (CLOCK_REALTIME, &ts) != 0)
+ {
+ puts ("clock_gettime failed");
+ return 1;
+ }
+
+ ts.tv_nsec = -1;
+
+ int e = pthread_cond_timedwait (&cond, &mut, &ts);
+ if (e == 0)
+ {
+ puts ("first cond_timedwait did not fail");
+ result = 1;
+ }
+ else if (e != EINVAL)
+ {
+ puts ("first cond_timedwait did not return EINVAL");
+ result = 1;
+ }
+
+ ts.tv_nsec = 2000000000;
+
+ e = pthread_cond_timedwait (&cond, &mut, &ts);
+ if (e == 0)
+ {
+ puts ("second cond_timedwait did not fail");
+ result = 1;
+ }
+ else if (e != EINVAL)
+ {
+ puts ("second cond_timedwait did not return EINVAL");
+ result = 1;
+ }
+
+ return result;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cond2.c b/test/nptl/tst-cond2.c
new file mode 100644
index 000000000..1da074cdd
--- /dev/null
+++ b/test/nptl/tst-cond2.c
@@ -0,0 +1,162 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <error.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+
+static pthread_barrier_t bar;
+
+
+static void *
+tf (void *a)
+{
+ int i = (long int) a;
+ int err;
+
+ printf ("child %d: lock\n", i);
+
+ err = pthread_mutex_lock (&mut);
+ if (err != 0)
+ error (EXIT_FAILURE, err, "locking in child failed");
+
+ printf ("child %d: sync\n", i);
+
+ int e = pthread_barrier_wait (&bar);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("child: barrier_wait failed");
+ exit (1);
+ }
+
+ printf ("child %d: wait\n", i);
+
+ err = pthread_cond_wait (&cond, &mut);
+ if (err != 0)
+ error (EXIT_FAILURE, err, "child %d: failed to wait", i);
+
+ printf ("child %d: woken up\n", i);
+
+ err = pthread_mutex_unlock (&mut);
+ if (err != 0)
+ error (EXIT_FAILURE, err, "child %d: unlock[2] failed", i);
+
+ printf ("child %d: done\n", i);
+
+ return NULL;
+}
+
+
+#define N 10
+
+
+static int
+do_test (void)
+{
+ pthread_t th[N];
+ int i;
+ int err;
+
+ printf ("&cond = %p\n&mut = %p\n", &cond, &mut);
+
+ if (pthread_barrier_init (&bar, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ exit (1);
+ }
+
+ pthread_attr_t at;
+
+ if (pthread_attr_init (&at) != 0)
+ {
+ puts ("attr_init failed");
+ return 1;
+ }
+
+ if (pthread_attr_setstacksize (&at, 1 * 1024 * 1024) != 0)
+ {
+ puts ("attr_setstacksize failed");
+ return 1;
+ }
+
+ for (i = 0; i < N; ++i)
+ {
+ printf ("create thread %d\n", i);
+
+ err = pthread_create (&th[i], &at, tf, (void *) (long int) i);
+ if (err != 0)
+ error (EXIT_FAILURE, err, "cannot create thread %d", i);
+
+ printf ("wait for child %d\n", i);
+
+ /* Wait for the child to start up and get the mutex for the
+ conditional variable. */
+ int e = pthread_barrier_wait (&bar);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ exit (1);
+ }
+ }
+
+ if (pthread_attr_destroy (&at) != 0)
+ {
+ puts ("attr_destroy failed");
+ return 1;
+ }
+
+ puts ("get lock outselves");
+
+ err = pthread_mutex_lock (&mut);
+ if (err != 0)
+ error (EXIT_FAILURE, err, "mut locking failed");
+
+ puts ("broadcast");
+
+ /* Wake up all threads. */
+ err = pthread_cond_broadcast (&cond);
+ if (err != 0)
+ error (EXIT_FAILURE, err, "parent: broadcast failed");
+
+ err = pthread_mutex_unlock (&mut);
+ if (err != 0)
+ error (EXIT_FAILURE, err, "mut unlocking failed");
+
+ /* Join all threads. */
+ for (i = 0; i < N; ++i)
+ {
+ printf ("join thread %d\n", i);
+
+ err = pthread_join (th[i], NULL);
+ if (err != 0)
+ error (EXIT_FAILURE, err, "join of child %d failed", i);
+ }
+
+ puts ("done");
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cond20.c b/test/nptl/tst-cond20.c
new file mode 100644
index 000000000..c1341a07b
--- /dev/null
+++ b/test/nptl/tst-cond20.c
@@ -0,0 +1,169 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
+
+ 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 <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#define N 10
+#define ROUNDS 1000
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_cond_t cond2 = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
+static pthread_barrier_t b;
+static int count;
+
+static void *
+tf (void *p)
+{
+ int i;
+ for (i = 0; i < ROUNDS; ++i)
+ {
+ pthread_mutex_lock (&mut);
+
+ if (++count == N)
+ pthread_cond_signal (&cond2);
+
+#ifdef TIMED
+ struct timeval tv;
+ gettimeofday (&tv, NULL);
+ struct timespec ts;
+ /* Wait three seconds. */
+ ts.tv_sec = tv.tv_sec + 3;
+ ts.tv_nsec = tv.tv_usec * 1000;
+ pthread_cond_timedwait (&cond, &mut, &ts);
+#else
+ pthread_cond_wait (&cond, &mut);
+#endif
+
+ pthread_mutex_unlock (&mut);
+
+ int err = pthread_barrier_wait (&b);
+ if (err != 0 && err != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("child: barrier_wait failed");
+ exit (1);
+ }
+
+ err = pthread_barrier_wait (&b);
+ if (err != 0 && err != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("child: barrier_wait failed");
+ exit (1);
+ }
+ }
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ if (pthread_barrier_init (&b, NULL, N + 1) != 0)
+ {
+ puts ("barrier_init failed");
+ return 1;
+ }
+
+ pthread_mutex_lock (&mut);
+
+ int i, j, err;
+ pthread_t th[N];
+ for (i = 0; i < N; ++i)
+ if ((err = pthread_create (&th[i], NULL, tf, NULL)) != 0)
+ {
+ printf ("cannot create thread %d: %s\n", i, strerror (err));
+ return 1;
+ }
+
+ for (i = 0; i < ROUNDS; ++i)
+ {
+ pthread_cond_wait (&cond2, &mut);
+
+ if (i & 1)
+ pthread_mutex_unlock (&mut);
+
+ if (i & 2)
+ pthread_cond_broadcast (&cond);
+ else if (i & 4)
+ for (j = 0; j < N; ++j)
+ pthread_cond_signal (&cond);
+ else
+ {
+ for (j = 0; j < (i / 8) % N; ++j)
+ pthread_cond_signal (&cond);
+ pthread_cond_broadcast (&cond);
+ }
+
+ if ((i & 1) == 0)
+ pthread_mutex_unlock (&mut);
+
+ err = pthread_cond_destroy (&cond);
+ if (err)
+ {
+ printf ("pthread_cond_destroy failed: %s\n", strerror (err));
+ return 1;
+ }
+
+ /* Now clobber the cond variable which has been successfully
+ destroyed above. */
+ memset (&cond, (char) i, sizeof (cond));
+
+ err = pthread_barrier_wait (&b);
+ if (err != 0 && err != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("parent: barrier_wait failed");
+ return 1;
+ }
+
+ pthread_mutex_lock (&mut);
+
+ err = pthread_barrier_wait (&b);
+ if (err != 0 && err != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("parent: barrier_wait failed");
+ return 1;
+ }
+
+ count = 0;
+ err = pthread_cond_init (&cond, NULL);
+ if (err)
+ {
+ printf ("pthread_cond_init failed: %s\n", strerror (err));
+ return 1;
+ }
+ }
+
+ for (i = 0; i < N; ++i)
+ if ((err = pthread_join (th[i], NULL)) != 0)
+ {
+ printf ("failed to join thread %d: %s\n", i, strerror (err));
+ return 1;
+ }
+
+ puts ("done");
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cond21.c b/test/nptl/tst-cond21.c
new file mode 100644
index 000000000..89cb771b5
--- /dev/null
+++ b/test/nptl/tst-cond21.c
@@ -0,0 +1,3 @@
+#include <sys/time.h>
+#define TIMED 1
+#include "tst-cond20.c"
diff --git a/test/nptl/tst-cond22.c b/test/nptl/tst-cond22.c
new file mode 100644
index 000000000..bd978e50c
--- /dev/null
+++ b/test/nptl/tst-cond22.c
@@ -0,0 +1,160 @@
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static pthread_barrier_t b;
+static pthread_cond_t c = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
+
+
+static void
+cl (void *arg)
+{
+ pthread_mutex_unlock (&m);
+}
+
+
+static void *
+tf (void *arg)
+{
+ if (pthread_mutex_lock (&m) != 0)
+ {
+ printf ("%s: mutex_lock failed\n", __func__);
+ exit (1);
+ }
+ int e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("%s: barrier_wait failed\n", __func__);
+ exit (1);
+ }
+ pthread_cleanup_push (cl, NULL);
+ /* We have to loop here because the cancellation might come after
+ the cond_wait call left the cancelable area and is then waiting
+ on the mutex. In this case the beginning of the second cond_wait
+ call will cause the cancellation to happen. */
+ do
+ if (pthread_cond_wait (&c, &m) != 0)
+ {
+ printf ("%s: cond_wait failed\n", __func__);
+ exit (1);
+ }
+ while (arg == NULL);
+ pthread_cleanup_pop (0);
+ if (pthread_mutex_unlock (&m) != 0)
+ {
+ printf ("%s: mutex_unlock failed\n", __func__);
+ exit (1);
+ }
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ int status = 0;
+
+ if (pthread_barrier_init (&b, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ return 1;
+ }
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("1st create failed");
+ return 1;
+ }
+ int e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("1st barrier_wait failed");
+ return 1;
+ }
+ if (pthread_mutex_lock (&m) != 0)
+ {
+ puts ("1st mutex_lock failed");
+ return 1;
+ }
+ if (pthread_cond_signal (&c) != 0)
+ {
+ puts ("1st cond_signal failed");
+ return 1;
+ }
+ if (pthread_cancel (th) != 0)
+ {
+ puts ("cancel failed");
+ return 1;
+ }
+ if (pthread_mutex_unlock (&m) != 0)
+ {
+ puts ("1st mutex_unlock failed");
+ return 1;
+ }
+ void *res;
+ if (pthread_join (th, &res) != 0)
+ {
+ puts ("1st join failed");
+ return 1;
+ }
+ if (res != PTHREAD_CANCELED)
+ {
+ puts ("first thread not canceled");
+ status = 1;
+ }
+
+ printf ("cond = { %d, %x, %lld, %lld, %lld, %p, %u, %u }\n",
+ c.__data.__lock, c.__data.__futex, c.__data.__total_seq,
+ c.__data.__wakeup_seq, c.__data.__woken_seq, c.__data.__mutex,
+ c.__data.__nwaiters, c.__data.__broadcast_seq);
+
+ if (pthread_create (&th, NULL, tf, (void *) 1l) != 0)
+ {
+ puts ("2nd create failed");
+ return 1;
+ }
+ e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("2nd barrier_wait failed");
+ return 1;
+ }
+ if (pthread_mutex_lock (&m) != 0)
+ {
+ puts ("2nd mutex_lock failed");
+ return 1;
+ }
+ if (pthread_cond_signal (&c) != 0)
+ {
+ puts ("2nd cond_signal failed");
+ return 1;
+ }
+ if (pthread_mutex_unlock (&m) != 0)
+ {
+ puts ("2nd mutex_unlock failed");
+ return 1;
+ }
+ if (pthread_join (th, &res) != 0)
+ {
+ puts ("2nd join failed");
+ return 1;
+ }
+ if (res != NULL)
+ {
+ puts ("2nd thread canceled");
+ status = 1;
+ }
+
+ printf ("cond = { %d, %x, %lld, %lld, %lld, %p, %u, %u }\n",
+ c.__data.__lock, c.__data.__futex, c.__data.__total_seq,
+ c.__data.__wakeup_seq, c.__data.__woken_seq, c.__data.__mutex,
+ c.__data.__nwaiters, c.__data.__broadcast_seq);
+
+ return status;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cond23.c b/test/nptl/tst-cond23.c
new file mode 100644
index 000000000..fb2936f00
--- /dev/null
+++ b/test/nptl/tst-cond23.c
@@ -0,0 +1,183 @@
+/* Copyright (C) 2008 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2008.
+
+ 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 <pthread.h>
+#include <stdio.h>
+#include <time.h>
+#include <unistd.h>
+
+
+#if defined _POSIX_CLOCK_SELECTION && _POSIX_CLOCK_SELECTION >= 0
+static int
+check (pthread_condattr_t *condattr, int pshared, clockid_t cl)
+{
+ clockid_t cl2;
+ if (pthread_condattr_getclock (condattr, &cl2) != 0)
+ {
+ puts ("condattr_getclock failed");
+ return 1;
+ }
+ if (cl != cl2)
+ {
+ printf ("condattr_getclock returned wrong value: %d, expected %d\n",
+ (int) cl2, (int) cl);
+ return 1;
+ }
+
+ int p;
+ if (pthread_condattr_getpshared (condattr, &p) != 0)
+ {
+ puts ("condattr_getpshared failed");
+ return 1;
+ }
+ else if (p != pshared)
+ {
+ printf ("condattr_getpshared returned wrong value: %d, expected %d\n",
+ p, pshared);
+ return 1;
+ }
+
+ return 0;
+}
+
+static int
+run_test (clockid_t cl)
+{
+ pthread_condattr_t condattr;
+
+ printf ("clock = %d\n", (int) cl);
+
+ if (pthread_condattr_init (&condattr) != 0)
+ {
+ puts ("condattr_init failed");
+ return 1;
+ }
+
+ if (check (&condattr, PTHREAD_PROCESS_PRIVATE, CLOCK_REALTIME))
+ return 1;
+
+ if (pthread_condattr_setpshared (&condattr, PTHREAD_PROCESS_SHARED) != 0)
+ {
+ puts ("1st condattr_setpshared failed");
+ return 1;
+ }
+
+ if (check (&condattr, PTHREAD_PROCESS_SHARED, CLOCK_REALTIME))
+ return 1;
+
+ if (pthread_condattr_setclock (&condattr, cl) != 0)
+ {
+ puts ("1st condattr_setclock failed");
+ return 1;
+ }
+
+ if (check (&condattr, PTHREAD_PROCESS_SHARED, cl))
+ return 1;
+
+ if (pthread_condattr_setpshared (&condattr, PTHREAD_PROCESS_PRIVATE) != 0)
+ {
+ puts ("2nd condattr_setpshared failed");
+ return 1;
+ }
+
+ if (check (&condattr, PTHREAD_PROCESS_PRIVATE, cl))
+ return 1;
+
+ if (pthread_condattr_setclock (&condattr, CLOCK_REALTIME) != 0)
+ {
+ puts ("2nd condattr_setclock failed");
+ return 1;
+ }
+
+ if (check (&condattr, PTHREAD_PROCESS_PRIVATE, CLOCK_REALTIME))
+ return 1;
+
+ if (pthread_condattr_setclock (&condattr, cl) != 0)
+ {
+ puts ("3rd condattr_setclock failed");
+ return 1;
+ }
+
+ if (check (&condattr, PTHREAD_PROCESS_PRIVATE, cl))
+ return 1;
+
+ if (pthread_condattr_setpshared (&condattr, PTHREAD_PROCESS_SHARED) != 0)
+ {
+ puts ("3rd condattr_setpshared failed");
+ return 1;
+ }
+
+ if (check (&condattr, PTHREAD_PROCESS_SHARED, cl))
+ return 1;
+
+ if (pthread_condattr_setclock (&condattr, CLOCK_REALTIME) != 0)
+ {
+ puts ("4th condattr_setclock failed");
+ return 1;
+ }
+
+ if (check (&condattr, PTHREAD_PROCESS_SHARED, CLOCK_REALTIME))
+ return 1;
+
+ if (pthread_condattr_destroy (&condattr) != 0)
+ {
+ puts ("condattr_destroy failed");
+ return 1;
+ }
+
+ return 0;
+}
+#endif
+
+
+static int
+do_test (void)
+{
+#if !defined _POSIX_CLOCK_SELECTION || _POSIX_CLOCK_SELECTION == -1
+
+ puts ("_POSIX_CLOCK_SELECTION not supported, test skipped");
+ return 0;
+
+#else
+
+ int res = run_test (CLOCK_REALTIME);
+
+# if defined _POSIX_MONOTONIC_CLOCK && _POSIX_MONOTONIC_CLOCK >= 0
+# if _POSIX_MONOTONIC_CLOCK == 0
+ int e = sysconf (_SC_MONOTONIC_CLOCK);
+ if (e < 0)
+ puts ("CLOCK_MONOTONIC not supported");
+ else if (e == 0)
+ {
+ puts ("sysconf (_SC_MONOTONIC_CLOCK) must not return 0");
+ res = 1;
+ }
+ else
+# endif
+ res |= run_test (CLOCK_MONOTONIC);
+# else
+ puts ("_POSIX_MONOTONIC_CLOCK not defined");
+# endif
+
+ return res;
+#endif
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cond3.c b/test/nptl/tst-cond3.c
new file mode 100644
index 000000000..b18183121
--- /dev/null
+++ b/test/nptl/tst-cond3.c
@@ -0,0 +1,112 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+
+/* Note that this test requires more than the standard. It is
+ required that there are no spurious wakeups if only more readers
+ are added. This is a reasonable demand. */
+
+
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
+
+
+#define N 10
+
+
+static void *
+tf (void *arg)
+{
+ int i = (long int) arg;
+ int err;
+
+ /* Get the mutex. */
+ err = pthread_mutex_lock (&mut);
+ if (err != 0)
+ {
+ printf ("child %d mutex_lock failed: %s\n", i, strerror (err));
+ exit (1);
+ }
+
+ /* This call should never return. */
+ pthread_cond_wait (&cond, &mut);
+
+ /* We should never get here. */
+ exit (1);
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ int err;
+ int i;
+
+ for (i = 0; i < N; ++i)
+ {
+ pthread_t th;
+
+ if (i != 0)
+ {
+ /* Release the mutex. */
+ err = pthread_mutex_unlock (&mut);
+ if (err != 0)
+ {
+ printf ("mutex_unlock %d failed: %s\n", i, strerror (err));
+ return 1;
+ }
+ }
+
+ err = pthread_create (&th, NULL, tf, (void *) (long int) i);
+ if (err != 0)
+ {
+ printf ("create %d failed: %s\n", i, strerror (err));
+ return 1;
+ }
+
+ /* Get the mutex. */
+ err = pthread_mutex_lock (&mut);
+ if (err != 0)
+ {
+ printf ("mutex_lock %d failed: %s\n", i, strerror (err));
+ return 1;
+ }
+ }
+
+ /* Set an alarm for 1 second. The wrapper will expect this. */
+ alarm (1);
+
+ /* This call should never return. */
+ pthread_cond_wait (&cond, &mut);
+
+ puts ("cond_wait returned");
+ return 1;
+}
+
+
+#define EXPECTED_SIGNAL SIGALRM
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cond4.c b/test/nptl/tst-cond4.c
new file mode 100644
index 000000000..47a7380de
--- /dev/null
+++ b/test/nptl/tst-cond4.c
@@ -0,0 +1,263 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+#include <stdint.h>
+
+
+int *condition;
+
+static int
+do_test (void)
+{
+ size_t ps = sysconf (_SC_PAGESIZE);
+ char tmpfname[] = "/tmp/tst-cond4.XXXXXX";
+ char data[ps];
+ void *mem;
+ int fd;
+ pthread_mutexattr_t ma;
+ pthread_mutex_t *mut1;
+ pthread_mutex_t *mut2;
+ pthread_condattr_t ca;
+ pthread_cond_t *cond;
+ pid_t pid;
+ int result = 0;
+ int p;
+
+ fd = mkstemp (tmpfname);
+ if (fd == -1)
+ {
+ printf ("cannot open temporary file: %m\n");
+ return 1;
+ }
+
+ /* Make sure it is always removed. */
+ unlink (tmpfname);
+
+ /* Create one page of data. */
+ memset (data, '\0', ps);
+
+ /* Write the data to the file. */
+ if (write (fd, data, ps) != (ssize_t) ps)
+ {
+ puts ("short write");
+ return 1;
+ }
+
+ mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ if (mem == MAP_FAILED)
+ {
+ printf ("mmap failed: %m\n");
+ return 1;
+ }
+
+ mut1 = (pthread_mutex_t *) (((uintptr_t) mem
+ + __alignof (pthread_mutex_t))
+ & ~(__alignof (pthread_mutex_t) - 1));
+ mut2 = mut1 + 1;
+
+ cond = (pthread_cond_t *) (((uintptr_t) (mut2 + 1)
+ + __alignof (pthread_cond_t))
+ & ~(__alignof (pthread_cond_t) - 1));
+
+ condition = (int *) (((uintptr_t) (cond + 1) + __alignof (int))
+ & ~(__alignof (int) - 1));
+
+ if (pthread_mutexattr_init (&ma) != 0)
+ {
+ puts ("mutexattr_init failed");
+ return 1;
+ }
+
+ if (pthread_mutexattr_getpshared (&ma, &p) != 0)
+ {
+ puts ("1st mutexattr_getpshared failed");
+ return 1;
+ }
+
+ if (p != PTHREAD_PROCESS_PRIVATE)
+ {
+ puts ("default pshared value wrong");
+ return 1;
+ }
+
+ if (pthread_mutexattr_setpshared (&ma, PTHREAD_PROCESS_SHARED) != 0)
+ {
+ puts ("mutexattr_setpshared failed");
+ return 1;
+ }
+
+ if (pthread_mutexattr_getpshared (&ma, &p) != 0)
+ {
+ puts ("2nd mutexattr_getpshared failed");
+ return 1;
+ }
+
+ if (p != PTHREAD_PROCESS_SHARED)
+ {
+ puts ("pshared value after setpshared call wrong");
+ return 1;
+ }
+
+ if (pthread_mutex_init (mut1, &ma) != 0)
+ {
+ puts ("1st mutex_init failed");
+ return 1;
+ }
+
+ if (pthread_mutex_init (mut2, &ma) != 0)
+ {
+ puts ("2nd mutex_init failed");
+ return 1;
+ }
+
+ if (pthread_condattr_init (&ca) != 0)
+ {
+ puts ("condattr_init failed");
+ return 1;
+ }
+
+ if (pthread_condattr_getpshared (&ca, &p) != 0)
+ {
+ puts ("1st condattr_getpshared failed");
+ return 1;
+ }
+
+ if (p != PTHREAD_PROCESS_PRIVATE)
+ {
+ puts ("default value for pshared in condattr wrong");
+ return 1;
+ }
+
+ if (pthread_condattr_setpshared (&ca, PTHREAD_PROCESS_SHARED) != 0)
+ {
+ puts ("condattr_setpshared failed");
+ return 1;
+ }
+
+ if (pthread_condattr_getpshared (&ca, &p) != 0)
+ {
+ puts ("2nd condattr_getpshared failed");
+ return 1;
+ }
+
+ if (p != PTHREAD_PROCESS_SHARED)
+ {
+ puts ("pshared condattr still not set");
+ return 1;
+ }
+
+ if (pthread_cond_init (cond, &ca) != 0)
+ {
+ puts ("cond_init failed");
+ return 1;
+ }
+
+ if (pthread_mutex_lock (mut1) != 0)
+ {
+ puts ("parent: 1st mutex_lock failed");
+ return 1;
+ }
+
+ puts ("going to fork now");
+ pid = fork ();
+ if (pid == -1)
+ {
+ puts ("fork failed");
+ return 1;
+ }
+ else if (pid == 0)
+ {
+ if (pthread_mutex_lock (mut2) != 0)
+ {
+ puts ("child: mutex_lock failed");
+ return 1;
+ }
+
+ if (pthread_mutex_unlock (mut1) != 0)
+ {
+ puts ("child: 1st mutex_unlock failed");
+ return 1;
+ }
+
+ do
+ if (pthread_cond_wait (cond, mut2) != 0)
+ {
+ puts ("child: cond_wait failed");
+ return 1;
+ }
+ while (*condition == 0);
+
+ if (pthread_mutex_unlock (mut2) != 0)
+ {
+ puts ("child: 2nd mutex_unlock failed");
+ return 1;
+ }
+
+ puts ("child done");
+ }
+ else
+ {
+ int status;
+
+ if (pthread_mutex_lock (mut1) != 0)
+ {
+ puts ("parent: 2nd mutex_lock failed");
+ return 1;
+ }
+
+ if (pthread_mutex_lock (mut2) != 0)
+ {
+ puts ("parent: 3rd mutex_lock failed");
+ return 1;
+ }
+
+ if (pthread_cond_signal (cond) != 0)
+ {
+ puts ("parent: cond_signal failed");
+ return 1;
+ }
+
+ *condition = 1;
+
+ if (pthread_mutex_unlock (mut2) != 0)
+ {
+ puts ("parent: mutex_unlock failed");
+ return 1;
+ }
+
+ puts ("waiting for child");
+
+ waitpid (pid, &status, 0);
+ result |= status;
+
+ puts ("parent done");
+ }
+
+ return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cond5.c b/test/nptl/tst-cond5.c
new file mode 100644
index 000000000..7da5b4110
--- /dev/null
+++ b/test/nptl/tst-cond5.c
@@ -0,0 +1,105 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <sys/time.h>
+
+
+static pthread_mutex_t mut;
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+
+
+static int
+do_test (void)
+{
+ pthread_mutexattr_t ma;
+ int err;
+ struct timespec ts;
+ struct timeval tv;
+
+ if (pthread_mutexattr_init (&ma) != 0)
+ {
+ puts ("mutexattr_init failed");
+ exit (1);
+ }
+
+ if (pthread_mutexattr_settype (&ma, PTHREAD_MUTEX_ERRORCHECK) != 0)
+ {
+ puts ("mutexattr_settype failed");
+ exit (1);
+ }
+
+ if (pthread_mutex_init (&mut, &ma) != 0)
+ {
+ puts ("mutex_init failed");
+ exit (1);
+ }
+
+ /* Get the mutex. */
+ if (pthread_mutex_lock (&mut) != 0)
+ {
+ puts ("mutex_lock failed");
+ exit (1);
+ }
+
+ /* Waiting for the condition will fail. But we want the timeout here. */
+ if (gettimeofday (&tv, NULL) != 0)
+ {
+ puts ("gettimeofday failed");
+ exit (1);
+ }
+
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+ ts.tv_nsec += 500000000;
+ if (ts.tv_nsec >= 1000000000)
+ {
+ ts.tv_nsec -= 1000000000;
+ ++ts.tv_sec;
+ }
+ err = pthread_cond_timedwait (&cond, &mut, &ts);
+ if (err == 0)
+ {
+ /* This could in theory happen but here without any signal and
+ additional waiter it should not. */
+ puts ("cond_timedwait succeeded");
+ exit (1);
+ }
+ else if (err != ETIMEDOUT)
+ {
+ printf ("cond_timedwait returned with %s\n", strerror (err));
+ exit (1);
+ }
+
+ err = pthread_mutex_unlock (&mut);
+ if (err != 0)
+ {
+ printf ("mutex_unlock failed: %s\n", strerror (err));
+ exit (1);
+ }
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cond6.c b/test/nptl/tst-cond6.c
new file mode 100644
index 000000000..f28d4c157
--- /dev/null
+++ b/test/nptl/tst-cond6.c
@@ -0,0 +1,233 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/time.h>
+#include <sys/wait.h>
+#include <stdint.h>
+
+
+int *condition;
+
+static int
+do_test (void)
+{
+ size_t ps = sysconf (_SC_PAGESIZE);
+ char tmpfname[] = "/tmp/tst-cond6.XXXXXX";
+ char data[ps];
+ void *mem;
+ int fd;
+ pthread_mutexattr_t ma;
+ pthread_mutex_t *mut1;
+ pthread_mutex_t *mut2;
+ pthread_condattr_t ca;
+ pthread_cond_t *cond;
+ pid_t pid;
+ int result = 0;
+
+ fd = mkstemp (tmpfname);
+ if (fd == -1)
+ {
+ printf ("cannot open temporary file: %m\n");
+ exit (1);
+ }
+
+ /* Make sure it is always removed. */
+ unlink (tmpfname);
+
+ /* Create one page of data. */
+ memset (data, '\0', ps);
+
+ /* Write the data to the file. */
+ if (write (fd, data, ps) != (ssize_t) ps)
+ {
+ puts ("short write");
+ exit (1);
+ }
+
+ mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ if (mem == MAP_FAILED)
+ {
+ printf ("mmap failed: %m\n");
+ exit (1);
+ }
+
+ mut1 = (pthread_mutex_t *) (((uintptr_t) mem
+ + __alignof (pthread_mutex_t))
+ & ~(__alignof (pthread_mutex_t) - 1));
+ mut2 = mut1 + 1;
+
+ cond = (pthread_cond_t *) (((uintptr_t) (mut2 + 1)
+ + __alignof (pthread_cond_t))
+ & ~(__alignof (pthread_cond_t) - 1));
+
+ condition = (int *) (((uintptr_t) (cond + 1) + __alignof (int))
+ & ~(__alignof (int) - 1));
+
+ if (pthread_mutexattr_init (&ma) != 0)
+ {
+ puts ("mutexattr_init failed");
+ exit (1);
+ }
+
+ if (pthread_mutexattr_setpshared (&ma, PTHREAD_PROCESS_SHARED) != 0)
+ {
+ puts ("mutexattr_setpshared failed");
+ exit (1);
+ }
+
+ if (pthread_mutex_init (mut1, &ma) != 0)
+ {
+ puts ("1st mutex_init failed");
+ exit (1);
+ }
+
+ if (pthread_mutex_init (mut2, &ma) != 0)
+ {
+ puts ("2nd mutex_init failed");
+ exit (1);
+ }
+
+ if (pthread_condattr_init (&ca) != 0)
+ {
+ puts ("condattr_init failed");
+ exit (1);
+ }
+
+ if (pthread_condattr_setpshared (&ca, PTHREAD_PROCESS_SHARED) != 0)
+ {
+ puts ("condattr_setpshared failed");
+ exit (1);
+ }
+
+ if (pthread_cond_init (cond, &ca) != 0)
+ {
+ puts ("cond_init failed");
+ exit (1);
+ }
+
+ if (pthread_mutex_lock (mut1) != 0)
+ {
+ puts ("parent: 1st mutex_lock failed");
+ exit (1);
+ }
+
+ puts ("going to fork now");
+ pid = fork ();
+ if (pid == -1)
+ {
+ puts ("fork failed");
+ exit (1);
+ }
+ else if (pid == 0)
+ {
+ struct timespec ts;
+ struct timeval tv;
+
+ if (pthread_mutex_lock (mut2) != 0)
+ {
+ puts ("child: mutex_lock failed");
+ exit (1);
+ }
+
+ if (pthread_mutex_unlock (mut1) != 0)
+ {
+ puts ("child: 1st mutex_unlock failed");
+ exit (1);
+ }
+
+ if (gettimeofday (&tv, NULL) != 0)
+ {
+ puts ("gettimeofday failed");
+ exit (1);
+ }
+
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+ ts.tv_nsec += 500000000;
+ if (ts.tv_nsec >= 1000000000)
+ {
+ ts.tv_nsec -= 1000000000;
+ ++ts.tv_sec;
+ }
+
+ do
+ if (pthread_cond_timedwait (cond, mut2, &ts) != 0)
+ {
+ puts ("child: cond_wait failed");
+ exit (1);
+ }
+ while (*condition == 0);
+
+ if (pthread_mutex_unlock (mut2) != 0)
+ {
+ puts ("child: 2nd mutex_unlock failed");
+ exit (1);
+ }
+
+ puts ("child done");
+ }
+ else
+ {
+ int status;
+
+ if (pthread_mutex_lock (mut1) != 0)
+ {
+ puts ("parent: 2nd mutex_lock failed");
+ exit (1);
+ }
+
+ if (pthread_mutex_lock (mut2) != 0)
+ {
+ puts ("parent: 3rd mutex_lock failed");
+ exit (1);
+ }
+
+ if (pthread_cond_signal (cond) != 0)
+ {
+ puts ("parent: cond_signal failed");
+ exit (1);
+ }
+
+ *condition = 1;
+
+ if (pthread_mutex_unlock (mut2) != 0)
+ {
+ puts ("parent: mutex_unlock failed");
+ exit (1);
+ }
+
+ puts ("waiting for child");
+
+ waitpid (pid, &status, 0);
+ result |= status;
+
+ puts ("parent done");
+ }
+
+ return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cond7.c b/test/nptl/tst-cond7.c
new file mode 100644
index 000000000..c48fda13c
--- /dev/null
+++ b/test/nptl/tst-cond7.c
@@ -0,0 +1,167 @@
+/* Copyright (C) 2003 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/>. */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <sys/time.h>
+
+
+typedef struct
+ {
+ pthread_cond_t cond;
+ pthread_mutex_t lock;
+ pthread_t h;
+ } T;
+
+
+static volatile bool done;
+
+
+static void *
+tf (void *arg)
+{
+ puts ("child created");
+
+ if (pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL) != 0
+ || pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, NULL) != 0)
+ {
+ puts ("cannot set cancellation options");
+ exit (1);
+ }
+
+ T *t = (T *) arg;
+
+ if (pthread_mutex_lock (&t->lock) != 0)
+ {
+ puts ("child: lock failed");
+ exit (1);
+ }
+
+ done = true;
+
+ if (pthread_cond_signal (&t->cond) != 0)
+ {
+ puts ("child: cond_signal failed");
+ exit (1);
+ }
+
+ if (pthread_cond_wait (&t->cond, &t->lock) != 0)
+ {
+ puts ("child: cond_wait failed");
+ exit (1);
+ }
+
+ if (pthread_mutex_unlock (&t->lock) != 0)
+ {
+ puts ("child: unlock failed");
+ exit (1);
+ }
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ int i;
+#define N 100
+ T *t[N];
+ for (i = 0; i < N; ++i)
+ {
+ printf ("round %d\n", i);
+
+ t[i] = (T *) malloc (sizeof (T));
+ if (t[i] == NULL)
+ {
+ puts ("out of memory");
+ exit (1);
+ }
+
+ if (pthread_mutex_init (&t[i]->lock, NULL) != 0
+ || pthread_cond_init (&t[i]->cond, NULL) != 0)
+ {
+ puts ("an _init function failed");
+ exit (1);
+ }
+
+ if (pthread_mutex_lock (&t[i]->lock) != 0)
+ {
+ puts ("initial mutex_lock failed");
+ exit (1);
+ }
+
+ done = false;
+
+ if (pthread_create (&t[i]->h, NULL, tf, t[i]) != 0)
+ {
+ puts ("pthread_create failed");
+ exit (1);
+ }
+
+ do
+ if (pthread_cond_wait (&t[i]->cond, &t[i]->lock) != 0)
+ {
+ puts ("cond_wait failed");
+ exit (1);
+ }
+ while (! done);
+
+ /* Release the lock since the cancel handler will get it. */
+ if (pthread_mutex_unlock (&t[i]->lock) != 0)
+ {
+ puts ("mutex_unlock failed");
+ exit (1);
+ }
+
+ if (pthread_cancel (t[i]->h) != 0)
+ {
+ puts ("cancel failed");
+ exit (1);
+ }
+
+ puts ("parent: joining now");
+
+ void *result;
+ if (pthread_join (t[i]->h, &result) != 0)
+ {
+ puts ("join failed");
+ exit (1);
+ }
+
+ if (result != PTHREAD_CANCELED)
+ {
+ puts ("result != PTHREAD_CANCELED");
+ exit (1);
+ }
+ }
+
+ for (i = 0; i < N; ++i)
+ free (t[i]);
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cond8.c b/test/nptl/tst-cond8.c
new file mode 100644
index 000000000..fb13fa46c
--- /dev/null
+++ b/test/nptl/tst-cond8.c
@@ -0,0 +1,276 @@
+/* Copyright (C) 2003 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 <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <sys/time.h>
+
+
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t mut = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
+
+static pthread_barrier_t bar;
+
+
+static void
+ch (void *arg)
+{
+ int e = pthread_mutex_lock (&mut);
+ if (e == 0)
+ {
+ puts ("mutex not locked at all by cond_wait");
+ exit (1);
+ }
+
+ if (e != EDEADLK)
+ {
+ puts ("no deadlock error signaled");
+ exit (1);
+ }
+
+ if (pthread_mutex_unlock (&mut) != 0)
+ {
+ puts ("ch: cannot unlock mutex");
+ exit (1);
+ }
+
+ puts ("ch done");
+}
+
+
+static void *
+tf1 (void *p)
+{
+ int err;
+
+ if (pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL) != 0
+ || pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, NULL) != 0)
+ {
+ puts ("cannot set cancellation options");
+ exit (1);
+ }
+
+ err = pthread_mutex_lock (&mut);
+ if (err != 0)
+ {
+ puts ("child: cannot get mutex");
+ exit (1);
+ }
+
+ err = pthread_barrier_wait (&bar);
+ if (err != 0 && err != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("barrier_wait returned %d\n", err);
+ exit (1);
+ }
+
+ puts ("child: got mutex; waiting");
+
+ pthread_cleanup_push (ch, NULL);
+
+ pthread_cond_wait (&cond, &mut);
+
+ pthread_cleanup_pop (0);
+
+ puts ("child: cond_wait should not have returned");
+
+ return NULL;
+}
+
+
+static void *
+tf2 (void *p)
+{
+ int err;
+
+ if (pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL) != 0
+ || pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, NULL) != 0)
+ {
+ puts ("cannot set cancellation options");
+ exit (1);
+ }
+
+ err = pthread_mutex_lock (&mut);
+ if (err != 0)
+ {
+ puts ("child: cannot get mutex");
+ exit (1);
+ }
+
+ err = pthread_barrier_wait (&bar);
+ if (err != 0 && err != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ printf ("barrier_wait returned %d\n", err);
+ exit (1);
+ }
+
+ puts ("child: got mutex; waiting");
+
+ pthread_cleanup_push (ch, NULL);
+
+ /* Current time. */
+ struct timeval tv;
+ (void) gettimeofday (&tv, NULL);
+ /* +1000 seconds in correct format. */
+ struct timespec ts;
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+ ts.tv_sec += 1000;
+
+ pthread_cond_timedwait (&cond, &mut, &ts);
+
+ pthread_cleanup_pop (0);
+
+ puts ("child: cond_wait should not have returned");
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ pthread_t th;
+ int err;
+
+ printf ("&cond = %p\n&mut = %p\n", &cond, &mut);
+
+ puts ("parent: get mutex");
+
+ err = pthread_barrier_init (&bar, NULL, 2);
+ if (err != 0)
+ {
+ puts ("parent: cannot init barrier");
+ exit (1);
+ }
+
+ puts ("parent: create child");
+
+ err = pthread_create (&th, NULL, tf1, NULL);
+ if (err != 0)
+ {
+ puts ("parent: cannot create thread");
+ exit (1);
+ }
+
+ puts ("parent: wait for child to lock mutex");
+
+ err = pthread_barrier_wait (&bar);
+ if (err != 0 && err != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("parent: cannot wait for barrier");
+ exit (1);
+ }
+
+ err = pthread_mutex_lock (&mut);
+ if (err != 0)
+ {
+ puts ("parent: mutex_lock failed");
+ exit (1);
+ }
+
+ err = pthread_mutex_unlock (&mut);
+ if (err != 0)
+ {
+ puts ("parent: mutex_unlock failed");
+ exit (1);
+ }
+
+ if (pthread_cancel (th) != 0)
+ {
+ puts ("cannot cancel thread");
+ exit (1);
+ }
+
+ void *r;
+ err = pthread_join (th, &r);
+ if (err != 0)
+ {
+ puts ("parent: failed to join");
+ exit (1);
+ }
+
+ if (r != PTHREAD_CANCELED)
+ {
+ puts ("child hasn't been canceled");
+ exit (1);
+ }
+
+
+
+ puts ("parent: create 2nd child");
+
+ err = pthread_create (&th, NULL, tf2, NULL);
+ if (err != 0)
+ {
+ puts ("parent: cannot create thread");
+ exit (1);
+ }
+
+ puts ("parent: wait for child to lock mutex");
+
+ err = pthread_barrier_wait (&bar);
+ if (err != 0 && err != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("parent: cannot wait for barrier");
+ exit (1);
+ }
+
+ err = pthread_mutex_lock (&mut);
+ if (err != 0)
+ {
+ puts ("parent: mutex_lock failed");
+ exit (1);
+ }
+
+ err = pthread_mutex_unlock (&mut);
+ if (err != 0)
+ {
+ puts ("parent: mutex_unlock failed");
+ exit (1);
+ }
+
+ if (pthread_cancel (th) != 0)
+ {
+ puts ("cannot cancel thread");
+ exit (1);
+ }
+
+ err = pthread_join (th, &r);
+ if (err != 0)
+ {
+ puts ("parent: failed to join");
+ exit (1);
+ }
+
+ if (r != PTHREAD_CANCELED)
+ {
+ puts ("child hasn't been canceled");
+ exit (1);
+ }
+
+ puts ("done");
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cond9.c b/test/nptl/tst-cond9.c
new file mode 100644
index 000000000..dcb597ddf
--- /dev/null
+++ b/test/nptl/tst-cond9.c
@@ -0,0 +1,149 @@
+/* Copyright (C) 2003 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 <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <sys/time.h>
+
+
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t mut = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
+
+
+static void *
+tf (void *arg)
+{
+ int err = pthread_cond_wait (&cond, &mut);
+ if (err == 0)
+ {
+ puts ("cond_wait did not fail");
+ exit (1);
+ }
+
+ if (err != EPERM)
+ {
+ printf ("cond_wait didn't return EPERM but %d\n", err);
+ exit (1);
+ }
+
+
+ /* Current time. */
+ struct timeval tv;
+ (void) gettimeofday (&tv, NULL);
+ /* +1000 seconds in correct format. */
+ struct timespec ts;
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+ ts.tv_sec += 1000;
+
+ err = pthread_cond_timedwait (&cond, &mut, &ts);
+ if (err == 0)
+ {
+ puts ("cond_timedwait did not fail");
+ exit (1);
+ }
+
+ if (err != EPERM)
+ {
+ printf ("cond_timedwait didn't return EPERM but %d\n", err);
+ exit (1);
+ }
+
+ return (void *) 1l;
+}
+
+
+static int
+do_test (void)
+{
+ pthread_t th;
+ int err;
+
+ printf ("&cond = %p\n&mut = %p\n", &cond, &mut);
+
+ err = pthread_cond_wait (&cond, &mut);
+ if (err == 0)
+ {
+ puts ("cond_wait did not fail");
+ exit (1);
+ }
+
+ if (err != EPERM)
+ {
+ printf ("cond_wait didn't return EPERM but %d\n", err);
+ exit (1);
+ }
+
+
+ /* Current time. */
+ struct timeval tv;
+ (void) gettimeofday (&tv, NULL);
+ /* +1000 seconds in correct format. */
+ struct timespec ts;
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+ ts.tv_sec += 1000;
+
+ err = pthread_cond_timedwait (&cond, &mut, &ts);
+ if (err == 0)
+ {
+ puts ("cond_timedwait did not fail");
+ exit (1);
+ }
+
+ if (err != EPERM)
+ {
+ printf ("cond_timedwait didn't return EPERM but %d\n", err);
+ exit (1);
+ }
+
+ if (pthread_mutex_lock (&mut) != 0)
+ {
+ puts ("parent: mutex_lock failed");
+ exit (1);
+ }
+
+ puts ("creating thread");
+
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ exit (1);
+ }
+
+ void *r;
+ if (pthread_join (th, &r) != 0)
+ {
+ puts ("join failed");
+ exit (1);
+ }
+ if (r != (void *) 1l)
+ {
+ puts ("thread has wrong return value");
+ exit (1);
+ }
+
+ puts ("done");
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cpuclock1.c b/test/nptl/tst-cpuclock1.c
new file mode 100644
index 000000000..9d68ec520
--- /dev/null
+++ b/test/nptl/tst-cpuclock1.c
@@ -0,0 +1,306 @@
+/* Test program for process CPU clocks.
+ Copyright (C) 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/>. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+#include <signal.h>
+#include <sys/wait.h>
+
+/* This function is intended to rack up both user and system time. */
+static void
+chew_cpu (void)
+{
+ while (1)
+ {
+ static volatile char buf[4096];
+ for (int i = 0; i < 100; ++i)
+ for (size_t j = 0; j < sizeof buf; ++j)
+ buf[j] = 0xaa;
+ int nullfd = open ("/dev/null", O_WRONLY);
+ for (int i = 0; i < 100; ++i)
+ for (size_t j = 0; j < sizeof buf; ++j)
+ buf[j] = 0xbb;
+ write (nullfd, (char *) buf, sizeof buf);
+ close (nullfd);
+ if (getppid () == 1)
+ _exit (2);
+ }
+}
+
+static int
+do_test (void)
+{
+ int result = 0;
+ clockid_t cl;
+ int e;
+ pid_t dead_child, child;
+
+ /* Fork a child and let it die, to give us a PID known not be valid
+ (assuming PIDs don't wrap around during the test). */
+ {
+ dead_child = fork ();
+ if (dead_child == 0)
+ _exit (0);
+ if (dead_child < 0)
+ {
+ perror ("fork");
+ return 1;
+ }
+ int x;
+ if (wait (&x) != dead_child)
+ {
+ perror ("wait");
+ return 2;
+ }
+ }
+
+ /* POSIX says we should get ESRCH for this. */
+ e = clock_getcpuclockid (dead_child, &cl);
+ if (e != ENOSYS && e != ESRCH && e != EPERM)
+ {
+ printf ("clock_getcpuclockid on dead PID %d => %s\n",
+ dead_child, strerror (e));
+ result = 1;
+ }
+
+ /* Now give us a live child eating up CPU time. */
+ child = fork ();
+ if (child == 0)
+ {
+ chew_cpu ();
+ _exit (1);
+ }
+ if (child < 0)
+ {
+ perror ("fork");
+ return 1;
+ }
+
+ e = clock_getcpuclockid (child, &cl);
+ if (e == EPERM)
+ {
+ puts ("clock_getcpuclockid does not support other processes");
+ goto done;
+ }
+ if (e != 0)
+ {
+ printf ("clock_getcpuclockid on live PID %d => %s\n",
+ child, strerror (e));
+ result = 1;
+ goto done;
+ }
+
+ const clockid_t child_clock = cl;
+ struct timespec res;
+ if (clock_getres (child_clock, &res) < 0)
+ {
+ printf ("clock_getres on live PID %d clock %lx => %s\n",
+ child, (unsigned long int) child_clock, strerror (errno));
+ result = 1;
+ goto done;
+ }
+ printf ("live PID %d clock %lx resolution %lu.%.9lu\n",
+ child, (unsigned long int) child_clock, res.tv_sec, res.tv_nsec);
+
+ struct timespec before, after;
+ if (clock_gettime (child_clock, &before) < 0)
+ {
+ printf ("clock_gettime on live PID %d clock %lx => %s\n",
+ child, (unsigned long int) child_clock, strerror (errno));
+ result = 1;
+ goto done;
+ }
+ printf ("live PID %d before sleep => %lu.%.9lu\n",
+ child, before.tv_sec, before.tv_nsec);
+
+ struct timespec sleeptime = { .tv_nsec = 500000000 };
+ nanosleep (&sleeptime, NULL);
+
+ if (clock_gettime (child_clock, &after) < 0)
+ {
+ printf ("clock_gettime on live PID %d clock %lx => %s\n",
+ child, (unsigned long int) child_clock, strerror (errno));
+ result = 1;
+ goto done;
+ }
+ printf ("live PID %d after sleep => %lu.%.9lu\n",
+ child, after.tv_sec, after.tv_nsec);
+
+ struct timespec diff = { .tv_sec = after.tv_sec - before.tv_sec,
+ .tv_nsec = after.tv_nsec - before.tv_nsec };
+ if (diff.tv_nsec < 0)
+ {
+ --diff.tv_sec;
+ diff.tv_nsec += 1000000000;
+ }
+ if (diff.tv_sec != 0
+ || diff.tv_nsec > 600000000
+ || diff.tv_nsec < 100000000)
+ {
+ printf ("before - after %lu.%.9lu outside reasonable range\n",
+ diff.tv_sec, diff.tv_nsec);
+ result = 1;
+ }
+
+ sleeptime.tv_nsec = 100000000;
+ e = clock_nanosleep (child_clock, 0, &sleeptime, NULL);
+ if (e == EINVAL || e == ENOTSUP || e == ENOSYS)
+ {
+ printf ("clock_nanosleep not supported for other process clock: %s\n",
+ strerror (e));
+ }
+ else if (e != 0)
+ {
+ printf ("clock_nanosleep on other process clock: %s\n", strerror (e));
+ result = 1;
+ }
+ else
+ {
+ struct timespec afterns;
+ if (clock_gettime (child_clock, &afterns) < 0)
+ {
+ printf ("clock_gettime on live PID %d clock %lx => %s\n",
+ child, (unsigned long int) child_clock, strerror (errno));
+ result = 1;
+ }
+ else
+ {
+ struct timespec d = { .tv_sec = afterns.tv_sec - after.tv_sec,
+ .tv_nsec = afterns.tv_nsec - after.tv_nsec };
+ if (d.tv_nsec < 0)
+ {
+ --d.tv_sec;
+ d.tv_nsec += 1000000000;
+ }
+ if (d.tv_sec > 0
+ || d.tv_nsec < sleeptime.tv_nsec
+ || d.tv_nsec > sleeptime.tv_nsec * 2)
+ {
+ printf ("nanosleep time %lu.%.9lu outside reasonable range\n",
+ d.tv_sec, d.tv_nsec);
+ result = 1;
+ }
+ }
+ }
+
+ if (kill (child, SIGKILL) != 0)
+ {
+ perror ("kill");
+ result = 2;
+ goto done;
+ }
+
+ /* Wait long enough to let the child finish dying. */
+
+ sleeptime.tv_nsec = 200000000;
+ nanosleep (&sleeptime, NULL);
+
+ struct timespec dead;
+ if (clock_gettime (child_clock, &dead) < 0)
+ {
+ printf ("clock_gettime on dead PID %d clock %lx => %s\n",
+ child, (unsigned long int) child_clock, strerror (errno));
+ result = 1;
+ goto done;
+ }
+ printf ("dead PID %d => %lu.%.9lu\n",
+ child, dead.tv_sec, dead.tv_nsec);
+
+ diff.tv_sec = dead.tv_sec - after.tv_sec;
+ diff.tv_nsec = dead.tv_nsec - after.tv_nsec;
+ if (diff.tv_nsec < 0)
+ {
+ --diff.tv_sec;
+ diff.tv_nsec += 1000000000;
+ }
+ if (diff.tv_sec != 0 || diff.tv_nsec > 200000000)
+ {
+ printf ("dead - after %lu.%.9lu outside reasonable range\n",
+ diff.tv_sec, diff.tv_nsec);
+ result = 1;
+ }
+
+ /* Now reap the child and verify that its clock is no longer valid. */
+ {
+ int x;
+ if (waitpid (child, &x, 0) != child)
+ {
+ perror ("waitpid");
+ result = 1;
+ }
+ }
+
+ if (clock_gettime (child_clock, &dead) == 0)
+ {
+ printf ("clock_gettime on reaped PID %d clock %lx => %lu%.9lu\n",
+ child, (unsigned long int) child_clock,
+ dead.tv_sec, dead.tv_nsec);
+ result = 1;
+ }
+ else
+ {
+ if (errno != EINVAL)
+ result = 1;
+ printf ("clock_gettime on reaped PID %d clock %lx => %s\n",
+ child, (unsigned long int) child_clock, strerror (errno));
+ }
+
+ if (clock_getres (child_clock, &dead) == 0)
+ {
+ printf ("clock_getres on reaped PID %d clock %lx => %lu%.9lu\n",
+ child, (unsigned long int) child_clock,
+ dead.tv_sec, dead.tv_nsec);
+ result = 1;
+ }
+ else
+ {
+ if (errno != EINVAL)
+ result = 1;
+ printf ("clock_getres on reaped PID %d clock %lx => %s\n",
+ child, (unsigned long int) child_clock, strerror (errno));
+ }
+
+ return result;
+
+ done:
+ {
+ if (kill (child, SIGKILL) != 0 && errno != ESRCH)
+ {
+ perror ("kill");
+ return 2;
+ }
+ int x;
+ if (waitpid (child, &x, 0) != child && errno != ECHILD)
+ {
+ perror ("waitpid");
+ return 2;
+ }
+ }
+
+ return result;
+}
+
+
+#define TIMEOUT 5
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cpuclock2.c b/test/nptl/tst-cpuclock2.c
new file mode 100644
index 000000000..d08dc6211
--- /dev/null
+++ b/test/nptl/tst-cpuclock2.c
@@ -0,0 +1,331 @@
+/* Test program for process and thread CPU clocks.
+ 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/>. */
+
+#include <unistd.h>
+
+#if (_POSIX_THREADS - 0) <= 0
+
+# define TEST_FUNCTION 0
+
+#else
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+#include <pthread.h>
+
+static pthread_barrier_t barrier;
+
+/* This function is intended to rack up both user and system time. */
+static void *
+chew_cpu (void *arg)
+{
+ pthread_barrier_wait (&barrier);
+
+ while (1)
+ {
+ static volatile char buf[4096];
+ for (int i = 0; i < 100; ++i)
+ for (size_t j = 0; j < sizeof buf; ++j)
+ buf[j] = 0xaa;
+ int nullfd = open ("/dev/null", O_WRONLY);
+ for (int i = 0; i < 100; ++i)
+ for (size_t j = 0; j < sizeof buf; ++j)
+ buf[j] = 0xbb;
+ write (nullfd, (char *) buf, sizeof buf);
+ close (nullfd);
+ }
+
+ return NULL;
+}
+
+static unsigned long long int
+tsdiff (const struct timespec *before, const struct timespec *after)
+{
+ struct timespec diff = { .tv_sec = after->tv_sec - before->tv_sec,
+ .tv_nsec = after->tv_nsec - before->tv_nsec };
+ while (diff.tv_nsec < 0)
+ {
+ --diff.tv_sec;
+ diff.tv_nsec += 1000000000;
+ }
+ return diff.tv_sec * 1000000000ULL + diff.tv_nsec;
+}
+
+static unsigned long long int
+test_nanosleep (clockid_t clock, const char *which,
+ const struct timespec *before, int *bad)
+{
+ const struct timespec sleeptime = { .tv_nsec = 100000000 };
+ int e = clock_nanosleep (clock, 0, &sleeptime, NULL);
+ if (e == EINVAL || e == ENOTSUP || e == ENOSYS)
+ {
+ printf ("clock_nanosleep not supported for %s CPU clock: %s\n",
+ which, strerror (e));
+ return 0;
+ }
+ if (e != 0)
+ {
+ printf ("clock_nanosleep on %s CPU clock: %s\n", which, strerror (e));
+ *bad = 1;
+ return 0;
+ }
+
+ struct timespec after;
+ if (clock_gettime (clock, &after) < 0)
+ {
+ printf ("clock_gettime on %s CPU clock %lx => %s\n",
+ which, (unsigned long int) clock, strerror (errno));
+ *bad = 1;
+ return 0;
+ }
+
+ unsigned long long int diff = tsdiff (before, &after);
+ if (diff < sleeptime.tv_nsec || diff > sleeptime.tv_nsec * 2)
+ {
+ printf ("clock_nanosleep on %s slept %llu (outside reasonable range)\n",
+ which, diff);
+ *bad = 1;
+ return diff;
+ }
+
+ struct timespec sleeptimeabs = sleeptime;
+ sleeptimeabs.tv_sec += after.tv_sec;
+ sleeptimeabs.tv_nsec += after.tv_nsec;
+ while (sleeptimeabs.tv_nsec > 1000000000)
+ {
+ ++sleeptimeabs.tv_sec;
+ sleeptimeabs.tv_nsec -= 1000000000;
+ }
+ e = clock_nanosleep (clock, TIMER_ABSTIME, &sleeptimeabs, NULL);
+ if (e != 0)
+ {
+ printf ("absolute clock_nanosleep on %s CPU clock: %s\n",
+ which, strerror (e));
+ *bad = 1;
+ return diff;
+ }
+
+ struct timespec afterabs;
+ if (clock_gettime (clock, &afterabs) < 0)
+ {
+ printf ("clock_gettime on %s CPU clock %lx => %s\n",
+ which, (unsigned long int) clock, strerror (errno));
+ *bad = 1;
+ return diff;
+ }
+
+ unsigned long long int sleepdiff = tsdiff (&sleeptimeabs, &afterabs);
+ if (sleepdiff > sleeptime.tv_nsec)
+ {
+ printf ("\
+absolute clock_nanosleep on %s %llu past target (outside reasonable range)\n",
+ which, sleepdiff);
+ *bad = 1;
+ }
+
+ unsigned long long int diffabs = tsdiff (&after, &afterabs);
+ if (diffabs < sleeptime.tv_nsec || diffabs > sleeptime.tv_nsec * 2)
+ {
+ printf ("\
+absolute clock_nanosleep on %s slept %llu (outside reasonable range)\n",
+ which, diffabs);
+ *bad = 1;
+ }
+
+ return diff + diffabs;
+}
+
+
+
+static int
+do_test (void)
+{
+ int result = 0;
+ clockid_t process_clock, th_clock, my_thread_clock;
+ int e;
+ pthread_t th;
+
+ e = clock_getcpuclockid (0, &process_clock);
+ if (e != 0)
+ {
+ printf ("clock_getcpuclockid on self => %s\n", strerror (e));
+ return 1;
+ }
+
+ e = pthread_getcpuclockid (pthread_self (), &my_thread_clock);
+ if (e != 0)
+ {
+ printf ("pthread_getcpuclockid on self => %s\n", strerror (e));
+ return 1;
+ }
+
+ /* This is a kludge. This test fails if the semantics of thread and
+ process clocks are wrong. The old code using hp-timing without kernel
+ support has bogus semantics if there are context switches. We don't
+ fail to report failure when the proper functionality is not available
+ in the kernel. It so happens that Linux kernels without correct CPU
+ clock support also lack CPU timer support, so we use use that to guess
+ that we are using the bogus code and not test it. */
+ timer_t t;
+ if (timer_create (my_thread_clock, NULL, &t) != 0)
+ {
+ printf ("timer_create: %m\n");
+ puts ("No support for CPU clocks with good semantics, skipping test");
+ return 0;
+ }
+ timer_delete (t);
+
+
+ pthread_barrier_init (&barrier, NULL, 2);
+
+ e = pthread_create (&th, NULL, chew_cpu, NULL);
+ if (e != 0)
+ {
+ printf ("pthread_create: %s\n", strerror (e));
+ return 1;
+ }
+
+ e = pthread_getcpuclockid (th, &th_clock);
+ if (e == ENOENT || e == ENOSYS || e == ENOTSUP)
+ {
+ puts ("pthread_getcpuclockid does not support other threads");
+ return 1;
+ }
+
+ pthread_barrier_wait (&barrier);
+
+ struct timespec res;
+ if (clock_getres (th_clock, &res) < 0)
+ {
+ printf ("clock_getres on thread clock %lx => %s\n",
+ (unsigned long int) th_clock, strerror (errno));
+ result = 1;
+ return 1;
+ }
+ printf ("live thread clock %lx resolution %lu.%.9lu\n",
+ (unsigned long int) th_clock, res.tv_sec, res.tv_nsec);
+
+ struct timespec process_before, process_after;
+ if (clock_gettime (process_clock, &process_before) < 0)
+ {
+ printf ("clock_gettime on process clock %lx => %s\n",
+ (unsigned long int) th_clock, strerror (errno));
+ return 1;
+ }
+
+ struct timespec before, after;
+ if (clock_gettime (th_clock, &before) < 0)
+ {
+ printf ("clock_gettime on live thread clock %lx => %s\n",
+ (unsigned long int) th_clock, strerror (errno));
+ return 1;
+ }
+ printf ("live thread before sleep => %lu.%.9lu\n",
+ before.tv_sec, before.tv_nsec);
+
+ struct timespec me_before, me_after;
+ if (clock_gettime (my_thread_clock, &me_before) < 0)
+ {
+ printf ("clock_gettime on live thread clock %lx => %s\n",
+ (unsigned long int) th_clock, strerror (errno));
+ return 1;
+ }
+ printf ("self thread before sleep => %lu.%.9lu\n",
+ me_before.tv_sec, me_before.tv_nsec);
+
+ struct timespec sleeptime = { .tv_nsec = 500000000 };
+ nanosleep (&sleeptime, NULL);
+
+ if (clock_gettime (th_clock, &after) < 0)
+ {
+ printf ("clock_gettime on live thread clock %lx => %s\n",
+ (unsigned long int) th_clock, strerror (errno));
+ return 1;
+ }
+ printf ("live thread after sleep => %lu.%.9lu\n",
+ after.tv_sec, after.tv_nsec);
+
+ if (clock_gettime (process_clock, &process_after) < 0)
+ {
+ printf ("clock_gettime on process clock %lx => %s\n",
+ (unsigned long int) th_clock, strerror (errno));
+ return 1;
+ }
+
+ if (clock_gettime (my_thread_clock, &me_after) < 0)
+ {
+ printf ("clock_gettime on live thread clock %lx => %s\n",
+ (unsigned long int) th_clock, strerror (errno));
+ return 1;
+ }
+ printf ("self thread after sleep => %lu.%.9lu\n",
+ me_after.tv_sec, me_after.tv_nsec);
+
+ unsigned long long int th_diff = tsdiff (&before, &after);
+ unsigned long long int pdiff = tsdiff (&process_before, &process_after);
+ unsigned long long int my_diff = tsdiff (&me_before, &me_after);
+
+ if (th_diff < 100000000 || th_diff > 600000000)
+ {
+ printf ("thread before - after %llu outside reasonable range\n",
+ th_diff);
+ result = 1;
+ }
+
+ if (my_diff > 100000000)
+ {
+ printf ("self thread before - after %llu outside reasonable range\n",
+ my_diff);
+ result = 1;
+ }
+
+ if (pdiff < th_diff)
+ {
+ printf ("process before - after %llu outside reasonable range (%llu)\n",
+ pdiff, th_diff);
+ result = 1;
+ }
+
+ process_after.tv_nsec += test_nanosleep (th_clock, "thread",
+ &after, &result);
+ process_after.tv_nsec += test_nanosleep (process_clock, "process",
+ &process_after, &result);
+ test_nanosleep (CLOCK_PROCESS_CPUTIME_ID,
+ "PROCESS_CPUTIME_ID", &process_after, &result);
+
+ pthread_cancel (th);
+
+ e = clock_nanosleep (CLOCK_THREAD_CPUTIME_ID, 0, &sleeptime, NULL);
+ if (e != EINVAL)
+ {
+ printf ("clock_nanosleep CLOCK_THREAD_CPUTIME_ID: %s\n",
+ strerror (e));
+ result = 1;
+ }
+
+ return result;
+}
+# define TIMEOUT 8
+# define TEST_FUNCTION do_test ()
+#endif
+
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-cputimer1.c b/test/nptl/tst-cputimer1.c
new file mode 100644
index 000000000..8f5dd76cf
--- /dev/null
+++ b/test/nptl/tst-cputimer1.c
@@ -0,0 +1,68 @@
+/* Tests for POSIX timer implementation using process CPU clock. */
+
+#include <unistd.h>
+
+#if _POSIX_THREADS && defined _POSIX_CPUTIME
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <time.h>
+#include <pthread.h>
+
+#define TEST_CLOCK CLOCK_PROCESS_CPUTIME_ID
+#define TEST_CLOCK_MISSING(clock) \
+ (setup_test () ? "process CPU clock timer support" : NULL)
+
+/* This function is intended to rack up both user and system time. */
+static void *
+chew_cpu (void *arg)
+{
+ while (1)
+ {
+ static volatile char buf[4096];
+ for (int i = 0; i < 100; ++i)
+ for (size_t j = 0; j < sizeof buf; ++j)
+ buf[j] = 0xaa;
+ int nullfd = open ("/dev/null", O_WRONLY);
+ for (int i = 0; i < 100; ++i)
+ for (size_t j = 0; j < sizeof buf; ++j)
+ buf[j] = 0xbb;
+ write (nullfd, (char *) buf, sizeof buf);
+ close (nullfd);
+ }
+
+ return NULL;
+}
+
+static int
+setup_test (void)
+{
+ /* Test timers on our own process CPU clock by having a worker thread
+ eating CPU. First make sure we can make such timers at all. */
+
+ timer_t t;
+ if (timer_create (TEST_CLOCK, NULL, &t) != 0)
+ {
+ printf ("timer_create: %m\n");
+ return 1;
+ }
+ timer_delete (t);
+
+ pthread_t th;
+ int e = pthread_create (&th, NULL, chew_cpu, NULL);
+ if (e != 0)
+ {
+ printf ("pthread_create: %s\n", strerror (e));
+ exit (1);
+ }
+
+ return 0;
+}
+
+#else
+# define TEST_CLOCK_MISSING(clock) "process clocks"
+#endif
+
+#include "tst-timer4.c"
diff --git a/test/nptl/tst-cputimer2.c b/test/nptl/tst-cputimer2.c
new file mode 100644
index 000000000..397d7998c
--- /dev/null
+++ b/test/nptl/tst-cputimer2.c
@@ -0,0 +1,83 @@
+/* Tests for POSIX timer implementation using thread CPU clock. */
+
+#include <unistd.h>
+
+#if _POSIX_THREADS && defined _POSIX_CPUTIME
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <time.h>
+#include <pthread.h>
+
+static clockid_t worker_thread_clock;
+
+#define TEST_CLOCK worker_thread_clock
+#define TEST_CLOCK_MISSING(clock) \
+ (setup_test () ? "thread CPU clock timer support" : NULL)
+
+/* This function is intended to rack up both user and system time. */
+static void *
+chew_cpu (void *arg)
+{
+ while (1)
+ {
+ static volatile char buf[4096];
+ for (int i = 0; i < 100; ++i)
+ for (size_t j = 0; j < sizeof buf; ++j)
+ buf[j] = 0xaa;
+ int nullfd = open ("/dev/null", O_WRONLY);
+ for (int i = 0; i < 100; ++i)
+ for (size_t j = 0; j < sizeof buf; ++j)
+ buf[j] = 0xbb;
+ write (nullfd, (char *) buf, sizeof buf);
+ close (nullfd);
+ }
+
+ return NULL;
+}
+
+static int
+setup_test (void)
+{
+ /* Test timers on a thread CPU clock by having a worker thread eating
+ CPU. First make sure we can make such timers at all. */
+
+ pthread_t th;
+ int e = pthread_create (&th, NULL, chew_cpu, NULL);
+ if (e != 0)
+ {
+ printf ("pthread_create: %s\n", strerror (e));
+ exit (1);
+ }
+
+ e = pthread_getcpuclockid (th, &worker_thread_clock);
+ if (e == EPERM || e == ENOENT || e == ENOTSUP)
+ {
+ puts ("pthread_getcpuclockid does not support other threads");
+ return 1;
+ }
+ if (e != 0)
+ {
+ printf ("pthread_getcpuclockid: %s\n", strerror (e));
+ exit (1);
+ }
+
+ timer_t t;
+ if (timer_create (TEST_CLOCK, NULL, &t) != 0)
+ {
+ printf ("timer_create: %m\n");
+ return 1;
+ }
+ timer_delete (t);
+
+ return 0;
+}
+
+#else
+# define TEST_CLOCK_MISSING(clock) "process clocks"
+#endif
+
+#include "tst-timer4.c"
diff --git a/test/nptl/tst-cputimer3.c b/test/nptl/tst-cputimer3.c
new file mode 100644
index 000000000..056766a37
--- /dev/null
+++ b/test/nptl/tst-cputimer3.c
@@ -0,0 +1,130 @@
+/* Tests for POSIX timer implementation using another process's CPU clock. */
+
+#include <unistd.h>
+
+#if _POSIX_THREADS && defined _POSIX_CPUTIME
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <time.h>
+#include <signal.h>
+#include <sys/wait.h>
+
+static clockid_t child_clock;
+
+#define TEST_CLOCK child_clock
+#define TEST_CLOCK_MISSING(clock) \
+ (setup_test () ? "other-process CPU clock timer support" : NULL)
+
+/* This function is intended to rack up both user and system time. */
+static void
+chew_cpu (void)
+{
+ while (1)
+ {
+ static volatile char buf[4096];
+ for (int i = 0; i < 100; ++i)
+ for (size_t j = 0; j < sizeof buf; ++j)
+ buf[j] = 0xaa;
+ int nullfd = open ("/dev/null", O_WRONLY);
+ for (int i = 0; i < 100; ++i)
+ for (size_t j = 0; j < sizeof buf; ++j)
+ buf[j] = 0xbb;
+ write (nullfd, (char *) buf, sizeof buf);
+ close (nullfd);
+ if (getppid () == 1)
+ _exit (2);
+ }
+}
+
+static pid_t child;
+static void
+cleanup_child (void)
+{
+ if (child <= 0)
+ return;
+ if (kill (child, SIGKILL) < 0 && errno != ESRCH)
+ printf ("cannot kill child %d: %m\n", child);
+ else
+ {
+ int status;
+ errno = 0;
+ if (waitpid (child, &status, 0) != child)
+ printf ("waitpid %d: %m\n", child);
+ }
+}
+#define CLEANUP_HANDLER cleanup_child ()
+
+static int
+setup_test (void)
+{
+ /* Test timers on a process CPU clock by having a child process eating
+ CPU. First make sure we can make such timers at all. */
+
+ int pipefd[2];
+ if (pipe (pipefd) < 0)
+ {
+ printf ("pipe: %m\n");
+ exit (1);
+ }
+
+ child = fork ();
+
+ if (child == 0)
+ {
+ char c;
+ close (pipefd[1]);
+ if (read (pipefd[0], &c, 1) == 1)
+ chew_cpu ();
+ _exit (1);
+ }
+
+ if (child < 0)
+ {
+ printf ("fork: %m\n");
+ exit (1);
+ }
+
+ atexit (&cleanup_child);
+
+ close (pipefd[0]);
+
+ int e = clock_getcpuclockid (child, &child_clock);
+ if (e == EPERM)
+ {
+ puts ("clock_getcpuclockid does not support other processes");
+ return 1;
+ }
+ if (e != 0)
+ {
+ printf ("clock_getcpuclockid: %s\n", strerror (e));
+ exit (1);
+ }
+
+ timer_t t;
+ if (timer_create (TEST_CLOCK, NULL, &t) != 0)
+ {
+ printf ("timer_create: %m\n");
+ return 1;
+ }
+ timer_delete (t);
+
+ /* Get the child started chewing. */
+ if (write (pipefd[1], "x", 1) != 1)
+ {
+ printf ("write to pipe: %m\n");
+ return 1;
+ }
+ close (pipefd[1]);
+
+ return 0;
+}
+
+#else
+# define TEST_CLOCK_MISSING(clock) "process clocks"
+#endif
+
+#include "tst-timer4.c"
diff --git a/test/nptl/tst-detach1.c b/test/nptl/tst-detach1.c
new file mode 100644
index 000000000..90a69fffd
--- /dev/null
+++ b/test/nptl/tst-detach1.c
@@ -0,0 +1,55 @@
+/* Copyright (C) 2003 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 <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static void *
+tf (void *arg)
+{
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, (void *) pthread_self ()) != 0)
+ {
+ puts ("create failed");
+ exit (1);
+ }
+
+ /* Give the child a chance to finish. */
+ sleep (1);
+
+ if (pthread_detach (th) != 0)
+ {
+ puts ("detach failed");
+ exit (1);
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-dlsym1.c b/test/nptl/tst-dlsym1.c
new file mode 100644
index 000000000..3744570c7
--- /dev/null
+++ b/test/nptl/tst-dlsym1.c
@@ -0,0 +1,66 @@
+/* Test case by Hui Huang <hui.huang@sun.com>. */
+#include <dlfcn.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static void *
+start_routine (void *args)
+{
+ int i;
+ void **addrs = (void **) args;
+ for (i = 0; i < 10000; ++i)
+ addrs[i % 1024] = dlsym (NULL, "does_not_exist");
+
+ return addrs;
+}
+
+
+static int
+do_test (void)
+{
+ pthread_t tid1, tid2, tid3;
+
+ void *addrs1[1024];
+ void *addrs2[1024];
+ void *addrs3[1024];
+
+ if (pthread_create (&tid1, NULL, start_routine, addrs1) != 0)
+ {
+ puts ("1st create failed");
+ exit (1);
+ }
+ if (pthread_create (&tid2, NULL, start_routine, addrs2) != 0)
+ {
+ puts ("2nd create failed");
+ exit (1);
+ }
+ if (pthread_create (&tid3, NULL, start_routine, addrs3) != 0)
+ {
+ puts ("3rd create failed");
+ exit (1);
+ }
+
+ if (pthread_join (tid1, NULL) != 0)
+ {
+ puts ("1st join failed");
+ exit (1);
+ }
+ if (pthread_join (tid2, NULL) != 0)
+ {
+ puts ("2nd join failed");
+ exit (1);
+ }
+ if (pthread_join (tid3, NULL) != 0)
+ {
+ puts ("2rd join failed");
+ exit (1);
+ }
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-eintr1.c b/test/nptl/tst-eintr1.c
new file mode 100644
index 000000000..ac381a88b
--- /dev/null
+++ b/test/nptl/tst-eintr1.c
@@ -0,0 +1,104 @@
+/* Copyright (C) 2003 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 <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "eintr.c"
+
+
+static void *
+tf2 (void *arg)
+{
+ return arg;
+}
+
+
+static void *
+tf1 (void *arg)
+{
+ while (1)
+ {
+ pthread_t th;
+
+ int e = pthread_create (&th, NULL, tf2, NULL);
+ if (e != 0)
+ {
+ if (e == EINTR)
+ {
+ puts ("pthread_create returned EINTR");
+ exit (1);
+ }
+
+ char buf[100];
+ printf ("tf1: pthread_create failed: %s\n",
+ strerror_r (e, buf, sizeof (buf)));
+ exit (1);
+ }
+
+ e = pthread_join (th, NULL);
+ if (e != 0)
+ {
+ if (e == EINTR)
+ {
+ puts ("pthread_join returned EINTR");
+ exit (1);
+ }
+
+ char buf[100];
+ printf ("tf1: pthread_join failed: %s\n",
+ strerror_r (e, buf, sizeof (buf)));
+ exit (1);
+ }
+ }
+}
+
+
+static int
+do_test (void)
+{
+ setup_eintr (SIGUSR1, NULL);
+
+ int i;
+ for (i = 0; i < 10; ++i)
+ {
+ pthread_t th;
+ int e = pthread_create (&th, NULL, tf1, NULL);
+ if (e != 0)
+ {
+ char buf[100];
+ printf ("main: pthread_create failed: %s\n",
+ strerror_r (e, buf, sizeof (buf)));
+ exit (1);
+ }
+ }
+
+ (void) tf1 (NULL);
+ /* NOTREACHED */
+
+ return 0;
+}
+
+#define EXPECTED_SIGNAL SIGALRM
+#define TIMEOUT 3
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-eintr2.c b/test/nptl/tst-eintr2.c
new file mode 100644
index 000000000..f20c70922
--- /dev/null
+++ b/test/nptl/tst-eintr2.c
@@ -0,0 +1,117 @@
+/* Copyright (C) 2003 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 <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+
+#include "eintr.c"
+
+
+static pthread_mutex_t m1 = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t m2 = PTHREAD_MUTEX_INITIALIZER;
+
+
+static void *
+tf1 (void *arg)
+{
+ struct timespec ts;
+ struct timeval tv;
+
+ gettimeofday (&tv, NULL);
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+ ts.tv_sec += 10000;
+
+ /* This call must never return. */
+ int e = pthread_mutex_timedlock (&m1, &ts);
+ char buf[100];
+ printf ("tf1: mutex_timedlock returned: %s\n",
+ strerror_r (e, buf, sizeof (buf)));
+
+ exit (1);
+}
+
+
+static void *
+tf2 (void *arg)
+{
+ while (1)
+ {
+ int e = pthread_mutex_lock (&m2);
+ if (e != 0)
+ {
+ puts ("tf2: mutex_lock failed");
+ exit (1);
+ }
+ e = pthread_mutex_unlock (&m2);
+ if (e != 0)
+ {
+ puts ("tf2: mutex_unlock failed");
+ exit (1);
+ }
+ struct timespec ts = { .tv_sec = 0, .tv_nsec = 10000000 };
+ nanosleep (&ts, NULL);
+ }
+}
+
+
+static int
+do_test (void)
+{
+ if (pthread_mutex_lock (&m1) != 0)
+ {
+ puts ("mutex_lock failed");
+ exit (1);
+ }
+
+ setup_eintr (SIGUSR1, NULL);
+
+ pthread_t th;
+ char buf[100];
+ int e = pthread_create (&th, NULL, tf1, NULL);
+ if (e != 0)
+ {
+ printf ("main: 1st pthread_create failed: %s\n",
+ strerror_r (e, buf, sizeof (buf)));
+ exit (1);
+ }
+
+ e = pthread_create (&th, NULL, tf2, NULL);
+ if (e != 0)
+ {
+ printf ("main: 2nd pthread_create failed: %s\n",
+ strerror_r (e, buf, sizeof (buf)));
+ exit (1);
+ }
+
+ /* This call must never return. */
+ e = pthread_mutex_lock (&m1);
+ printf ("main: mutex_lock returned: %s\n",
+ strerror_r (e, buf, sizeof (buf)));
+
+ return 0;
+}
+
+#define EXPECTED_SIGNAL SIGALRM
+#define TIMEOUT 3
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-eintr3.c b/test/nptl/tst-eintr3.c
new file mode 100644
index 000000000..31497603b
--- /dev/null
+++ b/test/nptl/tst-eintr3.c
@@ -0,0 +1,71 @@
+/* Copyright (C) 2003 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 <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "eintr.c"
+
+
+static void *
+tf (void *arg)
+{
+ pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
+ pthread_mutex_lock (&m);
+ /* This call must not return. */
+ pthread_mutex_lock (&m);
+
+ puts ("tf: mutex_lock returned");
+ exit (1);
+}
+
+
+static int
+do_test (void)
+{
+ pthread_t self = pthread_self ();
+
+ setup_eintr (SIGUSR1, &self);
+
+ pthread_t th;
+ char buf[100];
+ int e = pthread_create (&th, NULL, tf, NULL);
+ if (e != 0)
+ {
+ printf ("main: pthread_create failed: %s\n",
+ strerror_r (e, buf, sizeof (buf)));
+ exit (1);
+ }
+
+ /* This call must never return. */
+ e = pthread_join (th, NULL);
+
+ if (e == EINTR)
+ puts ("pthread_join returned with EINTR");
+
+ return 0;
+}
+
+#define EXPECTED_SIGNAL SIGALRM
+#define TIMEOUT 1
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-eintr4.c b/test/nptl/tst-eintr4.c
new file mode 100644
index 000000000..f2290f9d0
--- /dev/null
+++ b/test/nptl/tst-eintr4.c
@@ -0,0 +1,55 @@
+/* Copyright (C) 2003 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 <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "eintr.c"
+
+
+static int
+do_test (void)
+{
+ pthread_t self = pthread_self ();
+
+ setup_eintr (SIGUSR1, &self);
+
+ pthread_barrier_t b;
+ if (pthread_barrier_init (&b, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ exit (1);
+ }
+
+ /* This call must never return. */
+ int e = pthread_barrier_wait (&b);
+
+ if (e == EINTR)
+ puts ("pthread_join returned with EINTR");
+
+ return 0;
+}
+
+#define EXPECTED_SIGNAL SIGALRM
+#define TIMEOUT 1
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-eintr5.c b/test/nptl/tst-eintr5.c
new file mode 100644
index 000000000..f7cb76274
--- /dev/null
+++ b/test/nptl/tst-eintr5.c
@@ -0,0 +1,80 @@
+/* Copyright (C) 2003 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 <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+
+#include "eintr.c"
+
+
+static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t c = PTHREAD_COND_INITIALIZER;
+
+
+static void *
+tf (void *arg)
+{
+ struct timespec ts;
+ struct timeval tv;
+
+ gettimeofday (&tv, NULL);
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+ ts.tv_sec += 10000;
+
+ /* This call must never return. */
+ int e = pthread_cond_timedwait (&c, &m, &ts);
+ char buf[100];
+ printf ("tf: cond_timedwait returned: %s\n",
+ strerror_r (e, buf, sizeof (buf)));
+
+ exit (1);
+}
+
+
+static int
+do_test (void)
+{
+ setup_eintr (SIGUSR1, NULL);
+
+ pthread_t th;
+ char buf[100];
+ int e = pthread_create (&th, NULL, tf, NULL);
+ if (e != 0)
+ {
+ printf ("main: pthread_create failed: %s\n",
+ strerror_r (e, buf, sizeof (buf)));
+ exit (1);
+ }
+
+ /* This call must never return. */
+ e = pthread_cond_wait (&c, &m);
+ printf ("main: cond_wait returned: %s\n",
+ strerror_r (e, buf, sizeof (buf)));
+
+ return 0;
+}
+
+#define EXPECTED_SIGNAL SIGALRM
+#define TIMEOUT 3
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-exec2.c b/test/nptl/tst-exec2.c
new file mode 100644
index 000000000..061e3fc7c
--- /dev/null
+++ b/test/nptl/tst-exec2.c
@@ -0,0 +1,153 @@
+/* Thread with running thread calls exec.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <paths.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+
+static void *
+tf (void *arg)
+{
+ pthread_t th = (pthread_t) arg;
+
+ if (pthread_join (th, NULL) == 0)
+ {
+ puts ("thread in parent joined!?");
+ exit (1);
+ }
+
+ puts ("join in thread in parent returned!?");
+ exit (1);
+}
+
+
+static int
+do_test (void)
+{
+ int fd[2];
+ if (pipe (fd) != 0)
+ {
+ puts ("pipe failed");
+ exit (1);
+ }
+
+ /* Not interested in knowing when the pipe is closed. */
+ if (sigignore (SIGPIPE) != 0)
+ {
+ puts ("sigignore failed");
+ exit (1);
+ }
+
+ pid_t pid = fork ();
+ if (pid == -1)
+ {
+ puts ("fork failed");
+ exit (1);
+ }
+
+ if (pid == 0)
+ {
+ /* Use the fd for stdout. This is kind of ugly because it
+ substitutes the fd of stdout but we know what we are doing
+ here... */
+ if (dup2 (fd[1], STDOUT_FILENO) != STDOUT_FILENO)
+ {
+ puts ("dup2 failed");
+ exit (1);
+ }
+
+ close (fd[0]);
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, (void *) pthread_self ()) != 0)
+ {
+ puts ("create failed");
+ exit (1);
+ }
+
+ execl (_PATH_BSHELL, _PATH_BSHELL, "-c", "echo $$", NULL);
+
+ puts ("execl failed");
+ exit (1);
+ }
+
+ close (fd[1]);
+
+ char buf[200];
+ ssize_t n;
+ bool seen_pid = false;
+ while (TEMP_FAILURE_RETRY ((n = read (fd[0], buf, sizeof (buf)))) > 0)
+ {
+ /* We only expect to read the PID. */
+ char *endp;
+ long int rpid = strtol (buf, &endp, 10);
+
+ if (*endp != '\n')
+ {
+ printf ("didn't parse whole line: \"%s\"\n", buf);
+ exit (1);
+ }
+ if (endp == buf)
+ {
+ puts ("read empty line");
+ exit (1);
+ }
+
+ if (rpid != pid)
+ {
+ printf ("found \"%s\", expected PID %ld\n", buf, (long int) pid);
+ exit (1);
+ }
+
+ if (seen_pid)
+ {
+ puts ("found more than one PID line");
+ exit (1);
+ }
+ seen_pid = true;
+ }
+
+ close (fd[0]);
+
+ int status;
+ int err = waitpid (pid, &status, 0);
+ if (err != pid)
+ {
+ puts ("waitpid failed");
+ exit (1);
+ }
+
+ if (!seen_pid)
+ {
+ puts ("didn't get PID");
+ exit (1);
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-exec3.c b/test/nptl/tst-exec3.c
new file mode 100644
index 000000000..be4098b32
--- /dev/null
+++ b/test/nptl/tst-exec3.c
@@ -0,0 +1,151 @@
+/* Thread calls exec.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <paths.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+
+static void *
+tf (void *arg)
+{
+ execl (_PATH_BSHELL, _PATH_BSHELL, "-c", "echo $$", NULL);
+
+ puts ("execl failed");
+ exit (1);
+}
+
+
+static int
+do_test (void)
+{
+ int fd[2];
+ if (pipe (fd) != 0)
+ {
+ puts ("pipe failed");
+ exit (1);
+ }
+
+ /* Not interested in knowing when the pipe is closed. */
+ if (sigignore (SIGPIPE) != 0)
+ {
+ puts ("sigignore failed");
+ exit (1);
+ }
+
+ pid_t pid = fork ();
+ if (pid == -1)
+ {
+ puts ("fork failed");
+ exit (1);
+ }
+
+ if (pid == 0)
+ {
+ /* Use the fd for stdout. This is kind of ugly because it
+ substitutes the fd of stdout but we know what we are doing
+ here... */
+ if (dup2 (fd[1], STDOUT_FILENO) != STDOUT_FILENO)
+ {
+ puts ("dup2 failed");
+ exit (1);
+ }
+
+ close (fd[0]);
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ exit (1);
+ }
+
+ if (pthread_join (th, NULL) == 0)
+ {
+ puts ("join succeeded!?");
+ exit (1);
+ }
+
+ puts ("join returned!?");
+ exit (1);
+ }
+
+ close (fd[1]);
+
+ char buf[200];
+ ssize_t n;
+ bool seen_pid = false;
+ while (TEMP_FAILURE_RETRY ((n = read (fd[0], buf, sizeof (buf)))) > 0)
+ {
+ /* We only expect to read the PID. */
+ char *endp;
+ long int rpid = strtol (buf, &endp, 10);
+
+ if (*endp != '\n')
+ {
+ printf ("didn't parse whole line: \"%s\"\n", buf);
+ exit (1);
+ }
+ if (endp == buf)
+ {
+ puts ("read empty line");
+ exit (1);
+ }
+
+ if (rpid != pid)
+ {
+ printf ("found \"%s\", expected PID %ld\n", buf, (long int) pid);
+ exit (1);
+ }
+
+ if (seen_pid)
+ {
+ puts ("found more than one PID line");
+ exit (1);
+ }
+ seen_pid = true;
+ }
+
+ close (fd[0]);
+
+ int status;
+ int err = waitpid (pid, &status, 0);
+ if (err != pid)
+ {
+ puts ("waitpid failed");
+ exit (1);
+ }
+
+ if (!seen_pid)
+ {
+ puts ("didn't get PID");
+ exit (1);
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-exec4.c b/test/nptl/tst-exec4.c
new file mode 100644
index 000000000..1a4b88c69
--- /dev/null
+++ b/test/nptl/tst-exec4.c
@@ -0,0 +1,115 @@
+/* Signal handler and mask set in thread which calls exec.
+ Copyright (C) 2003 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 <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static void *
+tf (void *arg)
+{
+ /* Ignore SIGUSR1 and block SIGUSR2. */
+ if (sigignore (SIGUSR1) != 0)
+ {
+ puts ("sigignore failed");
+ exit (1);
+ }
+
+ sigset_t ss;
+ sigemptyset (&ss);
+ sigaddset (&ss, SIGUSR2);
+ if (pthread_sigmask (SIG_BLOCK, &ss, NULL) != 0)
+ {
+ puts ("1st run: sigmask failed");
+ exit (1);
+ }
+
+ char **oldargv = (char **) arg;
+ size_t n = 1;
+ while (oldargv[n] != NULL)
+ ++n;
+
+ char **argv = (char **) alloca ((n + 1) * sizeof (char *));
+ for (n = 0; oldargv[n + 1] != NULL; ++n)
+ argv[n] = oldargv[n + 1];
+ argv[n++] = (char *) "-d";
+ argv[n] = NULL;
+
+ execv (argv[0], argv);
+
+ puts ("execv failed");
+
+ exit (1);
+}
+
+
+static int
+do_test (int argc, char *argv[])
+{
+ if (argc == 1)
+ {
+ /* This is the second call. Perform the test. */
+ struct sigaction sa;
+
+ if (sigaction (SIGUSR1, NULL, &sa) != 0)
+ {
+ puts ("2nd run: sigaction failed");
+ return 1;
+ }
+ if (sa.sa_handler != SIG_IGN)
+ {
+ puts ("SIGUSR1 not ignored");
+ return 1;
+ }
+
+ sigset_t ss;
+ if (pthread_sigmask (SIG_SETMASK, NULL, &ss) != 0)
+ {
+ puts ("2nd run: sigmask failed");
+ return 1;
+ }
+ if (! sigismember (&ss, SIGUSR2))
+ {
+ puts ("SIGUSR2 not blocked");
+ return 1;
+ }
+
+ return 0;
+ }
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, argv) != 0)
+ {
+ puts ("create failed");
+ exit (1);
+ }
+
+ /* This call should never return. */
+ pthread_join (th, NULL);
+
+ puts ("join returned");
+
+ return 1;
+}
+
+#define TEST_FUNCTION do_test (argc, argv)
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-exit1.c b/test/nptl/tst-exit1.c
new file mode 100644
index 000000000..7f0fe7954
--- /dev/null
+++ b/test/nptl/tst-exit1.c
@@ -0,0 +1,78 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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/>. */
+
+/* NOTE: this tests functionality beyond POSIX. POSIX does not allow
+ exit to be called more than once. */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+static pthread_barrier_t b;
+
+
+static void *
+tf (void *arg)
+{
+ int r = pthread_barrier_wait (&b);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ exit (1);
+ }
+
+ exit (0);
+}
+
+
+static int
+do_test (void)
+{
+ if (pthread_barrier_init (&b, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ exit (1);
+ }
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ exit (1);
+ }
+
+ int r = pthread_barrier_wait (&b);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ exit (1);
+ }
+
+ /* Do nothing. */
+ if (pthread_join (th, NULL) == 0)
+ {
+ puts ("join succeeded!?");
+ exit (1);
+ }
+
+ puts ("join returned!?");
+ exit (1);
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-exit2.c b/test/nptl/tst-exit2.c
new file mode 100644
index 000000000..3f5ff27b0
--- /dev/null
+++ b/test/nptl/tst-exit2.c
@@ -0,0 +1,40 @@
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+
+static void *
+tf (void *arg)
+{
+ while (1)
+ sleep (100);
+
+ /* NOTREACHED */
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ pthread_t th;
+
+ int e = pthread_create (&th, NULL, tf, NULL);
+ if (e != 0)
+ {
+ printf ("create failed: %s\n", strerror (e));
+ return 1;
+ }
+
+ /* Terminate only this thread. */
+ pthread_exit (NULL);
+
+ /* NOTREACHED */
+ return 1;
+}
+
+#define EXPECTED_SIGNAL SIGALRM
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-exit3.c b/test/nptl/tst-exit3.c
new file mode 100644
index 000000000..da92c82c0
--- /dev/null
+++ b/test/nptl/tst-exit3.c
@@ -0,0 +1,81 @@
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+
+static pthread_barrier_t b;
+
+
+static void *
+tf2 (void *arg)
+{
+ while (1)
+ sleep (100);
+
+ /* NOTREACHED */
+ return NULL;
+}
+
+
+static void *
+tf (void *arg)
+{
+ pthread_t th;
+
+ int e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ exit (1);
+ }
+
+ e = pthread_create (&th, NULL, tf2, NULL);
+ if (e != 0)
+ {
+ printf ("create failed: %s\n", strerror (e));
+ exit (1);
+ }
+
+ /* Terminate only this thread. */
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ pthread_t th;
+
+ if (pthread_barrier_init (&b, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ exit (1);
+ }
+
+ int e = pthread_create (&th, NULL, tf, NULL);
+ if (e != 0)
+ {
+ printf ("create failed: %s\n", strerror (e));
+ exit (1);
+ }
+
+ e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ exit (1);
+ }
+
+ /* Terminate only this thread. */
+ pthread_exit (NULL);
+
+ /* NOTREACHED */
+ return 1;
+}
+
+#define EXPECTED_SIGNAL SIGALRM
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-fini1.c b/test/nptl/tst-fini1.c
new file mode 100644
index 000000000..b8c7a7306
--- /dev/null
+++ b/test/nptl/tst-fini1.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
+
+ 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 <unistd.h>
+
+extern void m (void);
+
+int
+main (void)
+{
+ alarm (5);
+
+ m ();
+
+ /* The destructor is supposed to run now. Make sure that if it is
+ not we will notice it by using 42 as the exit code. In case the
+ destructor is run it will terminate with status zero. */
+ return 42;
+}
diff --git a/test/nptl/tst-fini1mod.c b/test/nptl/tst-fini1mod.c
new file mode 100644
index 000000000..669c9af4c
--- /dev/null
+++ b/test/nptl/tst-fini1mod.c
@@ -0,0 +1,71 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
+
+ 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 <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static void *
+tf (void *arg)
+{
+ int fds[2];
+ if (pipe (fds) != 0)
+ {
+ puts ("pipe failed");
+ exit (1);
+ }
+
+ char buf[10];
+ read (fds[0], buf, sizeof (buf));
+
+ puts ("read returned");
+ exit (1);
+}
+
+static pthread_t th;
+
+static void
+__attribute ((destructor))
+dest (void)
+{
+ if (pthread_cancel (th) != 0)
+ {
+ puts ("cancel failed");
+ _exit (1);
+ }
+ void *r;
+ if (pthread_join (th, &r) != 0)
+ {
+ puts ("join failed");
+ _exit (1);
+ }
+ /* Exit successfully. */
+ _exit (0);
+}
+
+void
+m (void)
+{
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ _exit (1);
+ }
+}
diff --git a/test/nptl/tst-flock1.c b/test/nptl/tst-flock1.c
new file mode 100644
index 000000000..e271c8023
--- /dev/null
+++ b/test/nptl/tst-flock1.c
@@ -0,0 +1,92 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/file.h>
+
+
+static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+
+static int fd;
+
+
+static void *
+tf (void *arg)
+{
+ if (flock (fd, LOCK_SH | LOCK_NB) != 0)
+ {
+ puts ("second flock failed");
+ exit (1);
+ }
+
+ pthread_mutex_unlock (&lock);
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ char tmp[] = "/tmp/tst-flock1-XXXXXX";
+
+ fd = mkstemp (tmp);
+ if (fd == -1)
+ {
+ puts ("mkstemp failed");
+ exit (1);
+ }
+
+ unlink (tmp);
+
+ write (fd, "foobar xyzzy", 12);
+
+ if (flock (fd, LOCK_EX | LOCK_NB) != 0)
+ {
+ puts ("first flock failed");
+ exit (1);
+ }
+
+ pthread_mutex_lock (&lock);
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("pthread_create failed");
+ exit (1);
+ }
+
+ pthread_mutex_lock (&lock);
+
+ void *result;
+ if (pthread_join (th, &result) != 0)
+ {
+ puts ("pthread_join failed");
+ exit (1);
+ }
+
+ close (fd);
+
+ return result != NULL;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-flock2.c b/test/nptl/tst-flock2.c
new file mode 100644
index 000000000..941c52ffe
--- /dev/null
+++ b/test/nptl/tst-flock2.c
@@ -0,0 +1,259 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/file.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+
+
+static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t lock2 = PTHREAD_MUTEX_INITIALIZER;
+static int fd;
+
+
+static void *
+tf (void *arg)
+{
+ struct flock fl =
+ {
+ .l_type = F_WRLCK,
+ .l_start = 0,
+ .l_whence = SEEK_SET,
+ .l_len = 10
+ };
+ if (TEMP_FAILURE_RETRY (fcntl (fd, F_SETLKW, &fl)) != 0)
+ {
+ puts ("fourth fcntl failed");
+ exit (1);
+ }
+
+ pthread_mutex_unlock (&lock);
+
+ pthread_mutex_lock (&lock2);
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ char tmp[] = "/tmp/tst-flock2-XXXXXX";
+
+ fd = mkstemp (tmp);
+ if (fd == -1)
+ {
+ puts ("mkstemp failed");
+ return 1;
+ }
+
+ unlink (tmp);
+
+ int i;
+ for (i = 0; i < 20; ++i)
+ write (fd, "foobar xyzzy", 12);
+
+ pthread_barrier_t *b;
+ b = mmap (NULL, sizeof (pthread_barrier_t), PROT_READ | PROT_WRITE,
+ MAP_SHARED, fd, 0);
+ if (b == MAP_FAILED)
+ {
+ puts ("mmap failed");
+ return 1;
+ }
+
+ pthread_barrierattr_t ba;
+ if (pthread_barrierattr_init (&ba) != 0)
+ {
+ puts ("barrierattr_init failed");
+ return 1;
+ }
+
+ if (pthread_barrierattr_setpshared (&ba, PTHREAD_PROCESS_SHARED) != 0)
+ {
+ puts ("barrierattr_setpshared failed");
+ return 1;
+ }
+
+ if (pthread_barrier_init (b, &ba, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ return 1;
+ }
+
+ if (pthread_barrierattr_destroy (&ba) != 0)
+ {
+ puts ("barrierattr_destroy failed");
+ return 1;
+ }
+
+ struct flock fl =
+ {
+ .l_type = F_WRLCK,
+ .l_start = 0,
+ .l_whence = SEEK_SET,
+ .l_len = 10
+ };
+ if (TEMP_FAILURE_RETRY (fcntl (fd, F_SETLKW, &fl)) != 0)
+ {
+ puts ("first fcntl failed");
+ return 1;
+ }
+
+ pid_t pid = fork ();
+ if (pid == -1)
+ {
+ puts ("fork failed");
+ return 1;
+ }
+
+ if (pid == 0)
+ {
+ /* Make sure the child does not stay around indefinitely. */
+ alarm (10);
+
+ /* Try to get the lock. */
+ if (TEMP_FAILURE_RETRY (fcntl (fd, F_SETLK, &fl)) == 0)
+ {
+ puts ("child: second flock succeeded");
+ return 1;
+ }
+ }
+
+ pthread_barrier_wait (b);
+
+ if (pid != 0)
+ {
+ fl.l_type = F_UNLCK;
+ if (TEMP_FAILURE_RETRY (fcntl (fd, F_SETLKW, &fl)) != 0)
+ {
+ puts ("third fcntl failed");
+ return 1;
+ }
+ }
+
+ pthread_barrier_wait (b);
+
+ pthread_t th;
+ if (pid == 0)
+ {
+ if (pthread_mutex_lock (&lock) != 0)
+ {
+ puts ("1st locking of lock failed");
+ return 1;
+ }
+
+ if (pthread_mutex_lock (&lock2) != 0)
+ {
+ puts ("1st locking of lock2 failed");
+ return 1;
+ }
+
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("pthread_create failed");
+ return 1;
+ }
+
+ if (pthread_mutex_lock (&lock) != 0)
+ {
+ puts ("2nd locking of lock failed");
+ return 1;
+ }
+
+ puts ("child locked file");
+ }
+
+ pthread_barrier_wait (b);
+
+ if (pid != 0)
+ {
+ fl.l_type = F_WRLCK;
+ if (TEMP_FAILURE_RETRY (fcntl (fd, F_SETLK, &fl)) == 0)
+ {
+ puts ("fifth fcntl succeeded");
+ return 1;
+ }
+
+ puts ("file locked by child");
+ }
+
+ pthread_barrier_wait (b);
+
+ if (pid == 0)
+ {
+ if (pthread_mutex_unlock (&lock2) != 0)
+ {
+ puts ("unlock of lock2 failed");
+ return 1;
+ }
+
+ if (pthread_join (th, NULL) != 0)
+ {
+ puts ("join failed");
+ return 1;
+ }
+
+ puts ("child's thread terminated");
+ }
+
+ pthread_barrier_wait (b);
+
+ if (pid != 0)
+ {
+ fl.l_type = F_WRLCK;
+ if (TEMP_FAILURE_RETRY (fcntl (fd, F_SETLK, &fl)) == 0)
+ {
+ puts ("fifth fcntl succeeded");
+ return 1;
+ }
+
+ puts ("file still locked");
+ }
+
+ pthread_barrier_wait (b);
+
+ if (pid == 0)
+ {
+ _exit (0);
+ }
+
+ int status;
+ if (TEMP_FAILURE_RETRY (waitpid (pid, &status, 0)) != pid)
+ {
+ puts ("waitpid failed");
+ return 1;
+ }
+ puts ("child terminated");
+
+ if (TEMP_FAILURE_RETRY (fcntl (fd, F_SETLKW, &fl)) != 0)
+ {
+ puts ("sixth fcntl failed");
+ return 1;
+ }
+
+ return status;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-fork1.c b/test/nptl/tst-fork1.c
new file mode 100644
index 000000000..0d8972831
--- /dev/null
+++ b/test/nptl/tst-fork1.c
@@ -0,0 +1,119 @@
+/* Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Roland McGrath <roland@redhat.com>, 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 <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+static void *
+thread_function (void * arg)
+{
+ int i = (intptr_t) arg;
+ int status;
+ pid_t pid;
+ pid_t pid2;
+
+ pid = fork ();
+ switch (pid)
+ {
+ case 0:
+ printf ("%ld for %d\n", (long int) getpid (), i);
+ struct timespec ts = { .tv_sec = 0, .tv_nsec = 100000000 * i };
+ nanosleep (&ts, NULL);
+ _exit (i);
+ break;
+ case -1:
+ printf ("fork: %m\n");
+ return (void *) 1l;
+ break;
+ }
+
+ pid2 = TEMP_FAILURE_RETRY (waitpid (pid, &status, 0));
+ if (pid2 != pid)
+ {
+ printf ("waitpid returned %ld, expected %ld\n",
+ (long int) pid2, (long int) pid);
+ return (void *) 1l;
+ }
+
+ printf ("%ld with %d, expected %d\n",
+ (long int) pid, WEXITSTATUS (status), i);
+
+ return WEXITSTATUS (status) == i ? NULL : (void *) 1l;
+}
+
+#define N 5
+static const int t[N] = { 7, 6, 5, 4, 3 };
+
+int
+main (void)
+{
+ pthread_t th[N];
+ int i;
+ int result = 0;
+ pthread_attr_t at;
+
+ if (pthread_attr_init (&at) != 0)
+ {
+ puts ("attr_init failed");
+ return 1;
+ }
+
+ if (pthread_attr_setstacksize (&at, 1 * 1024 * 1024) != 0)
+ {
+ puts ("attr_setstacksize failed");
+ return 1;
+ }
+
+ for (i = 0; i < N; ++i)
+ if (pthread_create (&th[i], NULL, thread_function,
+ (void *) (intptr_t) t[i]) != 0)
+ {
+ printf ("creation of thread %d failed\n", i);
+ exit (1);
+ }
+
+ if (pthread_attr_destroy (&at) != 0)
+ {
+ puts ("attr_destroy failed");
+ return 1;
+ }
+
+ for (i = 0; i < N; ++i)
+ {
+ void *v;
+ if (pthread_join (th[i], &v) != 0)
+ {
+ printf ("join of thread %d failed\n", i);
+ result = 1;
+ }
+ else if (v != NULL)
+ {
+ printf ("join %d successful, but child failed\n", i);
+ result = 1;
+ }
+ else
+ printf ("join %d successful\n", i);
+ }
+
+ return result;
+}
diff --git a/test/nptl/tst-fork2.c b/test/nptl/tst-fork2.c
new file mode 100644
index 000000000..d85ea21e1
--- /dev/null
+++ b/test/nptl/tst-fork2.c
@@ -0,0 +1,89 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Roland McGrath <roland@redhat.com>, 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 <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+
+static pid_t initial_pid;
+
+
+static void *
+tf (void *arg)
+{
+ if (getppid () != initial_pid)
+ {
+ printf ("getppid in thread returned %ld, expected %ld\n",
+ (long int) getppid (), (long int) initial_pid);
+ return (void *) -1;
+ }
+
+ return NULL;
+}
+
+
+int
+main (void)
+{
+ initial_pid = getpid ();
+
+ pid_t child = fork ();
+ if (child == 0)
+ {
+ if (getppid () != initial_pid)
+ {
+ printf ("first getppid returned %ld, expected %ld\n",
+ (long int) getppid (), (long int) initial_pid);
+ exit (1);
+ }
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("pthread_create failed");
+ exit (1);
+ }
+
+ void *result;
+ if (pthread_join (th, &result) != 0)
+ {
+ puts ("pthread_join failed");
+ exit (1);
+ }
+
+ exit (result == NULL ? 0 : 1);
+ }
+ else if (child == -1)
+ {
+ puts ("initial fork failed");
+ return 1;
+ }
+
+ int status;
+ if (TEMP_FAILURE_RETRY (waitpid (child, &status, 0)) != child)
+ {
+ printf ("waitpid failed: %m\n");
+ return 1;
+ }
+
+ return status;
+}
diff --git a/test/nptl/tst-fork3.c b/test/nptl/tst-fork3.c
new file mode 100644
index 000000000..968d0ab98
--- /dev/null
+++ b/test/nptl/tst-fork3.c
@@ -0,0 +1,106 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Roland McGrath <roland@redhat.com>, 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 <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+
+static pid_t initial_pid;
+
+
+static void *
+tf2 (void *arg)
+{
+ if (getppid () != initial_pid)
+ {
+ printf ("getppid in thread returned %ld, expected %ld\n",
+ (long int) getppid (), (long int) initial_pid);
+ return (void *) -1;
+ }
+
+ return NULL;
+}
+
+
+static void *
+tf1 (void *arg)
+{
+ pid_t child = fork ();
+ if (child == 0)
+ {
+ if (getppid () != initial_pid)
+ {
+ printf ("first getppid returned %ld, expected %ld\n",
+ (long int) getppid (), (long int) initial_pid);
+ exit (1);
+ }
+
+ pthread_t th2;
+ if (pthread_create (&th2, NULL, tf2, NULL) != 0)
+ {
+ puts ("child: pthread_create failed");
+ exit (1);
+ }
+
+ void *result;
+ if (pthread_join (th2, &result) != 0)
+ {
+ puts ("pthread_join failed");
+ exit (1);
+ }
+
+ exit (result == NULL ? 0 : 1);
+ }
+ else if (child == -1)
+ {
+ puts ("initial fork failed");
+ exit (1);
+ }
+
+ int status;
+ if (TEMP_FAILURE_RETRY (waitpid (child, &status, 0)) != child)
+ {
+ printf ("waitpid failed: %m\n");
+ exit (1);
+ }
+
+ exit (status);
+}
+
+
+int
+main (void)
+{
+ initial_pid = getpid ();
+
+ pthread_t th1;
+ if (pthread_create (&th1, NULL, tf1, NULL) != 0)
+ {
+ puts ("parent: pthread_create failed");
+ exit (1);
+ }
+
+ /* This call should never return. */
+ pthread_join (th1, NULL);
+
+ return 1;
+}
diff --git a/test/nptl/tst-fork4.c b/test/nptl/tst-fork4.c
new file mode 100644
index 000000000..ee87108a1
--- /dev/null
+++ b/test/nptl/tst-fork4.c
@@ -0,0 +1,64 @@
+/* Test of fork updating child universe's pthread structures.
+ Copyright (C) 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 <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <string.h>
+
+
+static int
+do_test (void)
+{
+ pthread_t me = pthread_self ();
+
+ pid_t pid = fork ();
+
+ if (pid < 0)
+ {
+ printf ("fork: %m\n");
+ return 1;
+ }
+
+ if (pid == 0)
+ {
+ int err = pthread_kill (me, SIGTERM);
+ printf ("pthread_kill returned: %s\n", strerror (err));
+ return 3;
+ }
+
+ int status;
+ errno = 0;
+ if (wait (&status) != pid)
+ printf ("wait failed: %m\n");
+ else if (WIFSIGNALED (status) && WTERMSIG (status) == SIGTERM)
+ {
+ printf ("child correctly died with SIGTERM\n");
+ return 0;
+ }
+ else
+ printf ("child died with bad status %#x\n", status);
+
+ return 1;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-getpid1.c b/test/nptl/tst-getpid1.c
new file mode 100644
index 000000000..4d25b0de7
--- /dev/null
+++ b/test/nptl/tst-getpid1.c
@@ -0,0 +1,122 @@
+#include <sched.h>
+#include <signal.h>
+#include <string.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <bits/stackinfo.h>
+
+#ifndef TEST_CLONE_FLAGS
+#define TEST_CLONE_FLAGS 0
+#endif
+
+static int sig;
+
+static int
+f (void *a)
+{
+ puts ("in f");
+ union sigval sival;
+ sival.sival_int = getpid ();
+ printf ("pid = %d\n", sival.sival_int);
+ if (sigqueue (getppid (), sig, sival) != 0)
+ return 1;
+ return 0;
+}
+
+
+static int
+do_test (void)
+{
+ int mypid = getpid ();
+
+ sig = SIGRTMIN;
+ sigset_t ss;
+ sigemptyset (&ss);
+ sigaddset (&ss, sig);
+ if (sigprocmask (SIG_BLOCK, &ss, NULL) != 0)
+ {
+ printf ("sigprocmask failed: %m\n");
+ return 1;
+ }
+
+#ifdef __ia64__
+ extern int __clone2 (int (*__fn) (void *__arg), void *__child_stack_base,
+ size_t __child_stack_size, int __flags,
+ void *__arg, ...);
+ char st[256 * 1024] __attribute__ ((aligned));
+ pid_t p = __clone2 (f, st, sizeof (st), TEST_CLONE_FLAGS, 0);
+#else
+ char st[128 * 1024] __attribute__ ((aligned));
+# if _STACK_GROWS_DOWN
+ pid_t p = clone (f, st + sizeof (st), TEST_CLONE_FLAGS, 0);
+# elif _STACK_GROWS_UP
+ pid_t p = clone (f, st, TEST_CLONE_FLAGS, 0);
+# else
+# error "Define either _STACK_GROWS_DOWN or _STACK_GROWS_UP"
+# endif
+#endif
+ if (p == -1)
+ {
+ printf("clone failed: %m\n");
+ return 1;
+ }
+ printf ("new thread: %d\n", (int) p);
+
+ siginfo_t si;
+ do
+ if (sigwaitinfo (&ss, &si) < 0)
+ {
+ printf("sigwaitinfo failed: %m\n");
+ kill (p, SIGKILL);
+ return 1;
+ }
+ while (si.si_signo != sig || si.si_code != SI_QUEUE);
+
+ int e;
+ if (waitpid (p, &e, __WCLONE) != p)
+ {
+ puts ("waitpid failed");
+ kill (p, SIGKILL);
+ return 1;
+ }
+ if (!WIFEXITED (e))
+ {
+ if (WIFSIGNALED (e))
+ printf ("died from signal %s\n", strsignal (WTERMSIG (e)));
+ else
+ puts ("did not terminate correctly");
+ return 1;
+ }
+ if (WEXITSTATUS (e) != 0)
+ {
+ printf ("exit code %d\n", WEXITSTATUS (e));
+ return 1;
+ }
+
+ if (si.si_int != (int) p)
+ {
+ printf ("expected PID %d, got si_int %d\n", (int) p, si.si_int);
+ kill (p, SIGKILL);
+ return 1;
+ }
+
+ if (si.si_pid != p)
+ {
+ printf ("expected PID %d, got si_pid %d\n", (int) p, (int) si.si_pid);
+ kill (p, SIGKILL);
+ return 1;
+ }
+
+ if (getpid () != mypid)
+ {
+ puts ("my PID changed");
+ return 1;
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-getpid2.c b/test/nptl/tst-getpid2.c
new file mode 100644
index 000000000..fc98cb60d
--- /dev/null
+++ b/test/nptl/tst-getpid2.c
@@ -0,0 +1,2 @@
+#define TEST_CLONE_FLAGS CLONE_VM
+#include "tst-getpid1.c"
diff --git a/test/nptl/tst-getpid3.c b/test/nptl/tst-getpid3.c
new file mode 100644
index 000000000..f1e77f6b1
--- /dev/null
+++ b/test/nptl/tst-getpid3.c
@@ -0,0 +1,114 @@
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+
+static pid_t pid;
+
+static void *
+pid_thread (void *arg)
+{
+ if (pid != getpid ())
+ {
+ printf ("pid wrong in thread: should be %d, is %d\n",
+ (int) pid, (int) getpid ());
+ return (void *) 1L;
+ }
+
+ return NULL;
+}
+
+static int
+do_test (void)
+{
+ pid = getpid ();
+
+ pthread_t thr;
+ int ret = pthread_create (&thr, NULL, pid_thread, NULL);
+ if (ret)
+ {
+ printf ("pthread_create failed: %d\n", ret);
+ return 1;
+ }
+
+ void *thr_ret;
+ ret = pthread_join (thr, &thr_ret);
+ if (ret)
+ {
+ printf ("pthread_create failed: %d\n", ret);
+ return 1;
+ }
+ else if (thr_ret)
+ {
+ printf ("thread getpid failed\n");
+ return 1;
+ }
+
+ pid_t child = fork ();
+ if (child == -1)
+ {
+ printf ("fork failed: %m\n");
+ return 1;
+ }
+ else if (child == 0)
+ {
+ if (pid == getpid ())
+ {
+ puts ("pid did not change after fork");
+ exit (1);
+ }
+
+ pid = getpid ();
+ ret = pthread_create (&thr, NULL, pid_thread, NULL);
+ if (ret)
+ {
+ printf ("pthread_create failed: %d\n", ret);
+ return 1;
+ }
+
+ ret = pthread_join (thr, &thr_ret);
+ if (ret)
+ {
+ printf ("pthread_create failed: %d\n", ret);
+ return 1;
+ }
+ else if (thr_ret)
+ {
+ printf ("thread getpid failed\n");
+ return 1;
+ }
+
+ return 0;
+ }
+
+ int status;
+ if (TEMP_FAILURE_RETRY (waitpid (child, &status, 0)) != child)
+ {
+ puts ("waitpid failed");
+ kill (child, SIGKILL);
+ return 1;
+ }
+
+ if (!WIFEXITED (status))
+ {
+ if (WIFSIGNALED (status))
+ printf ("died from signal %s\n", strsignal (WTERMSIG (status)));
+ else
+ puts ("did not terminate correctly");
+ return 1;
+ }
+ if (WEXITSTATUS (status) != 0)
+ {
+ printf ("exit code %d\n", WEXITSTATUS (status));
+ return 1;
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-initializers1-c89.c b/test/nptl/tst-initializers1-c89.c
new file mode 100644
index 000000000..7c27c1d54
--- /dev/null
+++ b/test/nptl/tst-initializers1-c89.c
@@ -0,0 +1 @@
+#include "tst-initializers1.c"
diff --git a/test/nptl/tst-initializers1-c99.c b/test/nptl/tst-initializers1-c99.c
new file mode 100644
index 000000000..7c27c1d54
--- /dev/null
+++ b/test/nptl/tst-initializers1-c99.c
@@ -0,0 +1 @@
+#include "tst-initializers1.c"
diff --git a/test/nptl/tst-initializers1-gnu89.c b/test/nptl/tst-initializers1-gnu89.c
new file mode 100644
index 000000000..7c27c1d54
--- /dev/null
+++ b/test/nptl/tst-initializers1-gnu89.c
@@ -0,0 +1 @@
+#include "tst-initializers1.c"
diff --git a/test/nptl/tst-initializers1-gnu99.c b/test/nptl/tst-initializers1-gnu99.c
new file mode 100644
index 000000000..7c27c1d54
--- /dev/null
+++ b/test/nptl/tst-initializers1-gnu99.c
@@ -0,0 +1 @@
+#include "tst-initializers1.c"
diff --git a/test/nptl/tst-initializers1.c b/test/nptl/tst-initializers1.c
new file mode 100644
index 000000000..1e353806b
--- /dev/null
+++ b/test/nptl/tst-initializers1.c
@@ -0,0 +1,47 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 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 <pthread.h>
+
+pthread_mutex_t mtx_normal = PTHREAD_MUTEX_INITIALIZER;
+pthread_mutex_t mtx_recursive = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+pthread_mutex_t mtx_errorchk = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
+pthread_mutex_t mtx_adaptive = PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP;
+pthread_rwlock_t rwl_normal = PTHREAD_RWLOCK_INITIALIZER;
+pthread_rwlock_t rwl_writer
+ = PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP;
+pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+
+int
+main (void)
+{
+ if (mtx_normal.__data.__kind != PTHREAD_MUTEX_TIMED_NP)
+ return 1;
+ if (mtx_recursive.__data.__kind != PTHREAD_MUTEX_RECURSIVE_NP)
+ return 1;
+ if (mtx_errorchk.__data.__kind != PTHREAD_MUTEX_ERRORCHECK_NP)
+ return 1;
+ if (mtx_adaptive.__data.__kind != PTHREAD_MUTEX_ADAPTIVE_NP)
+ return 1;
+ if (rwl_normal.__data.__flags != PTHREAD_RWLOCK_PREFER_READER_NP)
+ return 1;
+ if (rwl_writer.__data.__flags
+ != PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP)
+ return 1;
+ return 0;
+}
diff --git a/test/nptl/tst-join1.c b/test/nptl/tst-join1.c
new file mode 100644
index 000000000..681245a1c
--- /dev/null
+++ b/test/nptl/tst-join1.c
@@ -0,0 +1,82 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+
+
+static void *
+tf (void *arg)
+{
+ pthread_t mh = (pthread_t) arg;
+ void *result;
+
+ if (pthread_mutex_unlock (&lock) != 0)
+ {
+ puts ("unlock failed");
+ exit (1);
+ }
+
+ if (pthread_join (mh, &result) != 0)
+ {
+ puts ("join failed");
+ exit (1);
+ }
+
+ if (result != (void *) 42l)
+ {
+ printf ("result wrong: expected %p, got %p\n", (void *) 42, result);
+ exit (1);
+ }
+
+ exit (0);
+}
+
+
+static int
+do_test (void)
+{
+ pthread_t th;
+
+ if (pthread_mutex_lock (&lock) != 0)
+ {
+ puts ("1st lock failed");
+ exit (1);
+ }
+
+ if (pthread_create (&th, NULL, tf, (void *) pthread_self ()) != 0)
+ {
+ puts ("create failed");
+ exit (1);
+ }
+
+ if (pthread_mutex_lock (&lock) != 0)
+ {
+ puts ("2nd lock failed");
+ exit (1);
+ }
+
+ pthread_exit ((void *) 42);
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-join2.c b/test/nptl/tst-join2.c
new file mode 100644
index 000000000..03203983c
--- /dev/null
+++ b/test/nptl/tst-join2.c
@@ -0,0 +1,103 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+
+static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+
+
+static void *
+tf (void *arg)
+{
+ if (pthread_mutex_lock (&lock) != 0)
+ {
+ puts ("child: mutex_lock failed");
+ return NULL;
+ }
+
+ return (void *) 42l;
+}
+
+
+static int
+do_test (void)
+{
+ pthread_t th;
+
+ if (pthread_mutex_lock (&lock) != 0)
+ {
+ puts ("mutex_lock failed");
+ exit (1);
+ }
+
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("mutex_create failed");
+ exit (1);
+ }
+
+ void *status;
+ int val = pthread_tryjoin_np (th, &status);
+ if (val == 0)
+ {
+ puts ("1st tryjoin succeeded");
+ exit (1);
+ }
+ else if (val != EBUSY)
+ {
+ puts ("1st tryjoin didn't return EBUSY");
+ exit (1);
+ }
+
+ if (pthread_mutex_unlock (&lock) != 0)
+ {
+ puts ("mutex_unlock failed");
+ exit (1);
+ }
+
+ while ((val = pthread_tryjoin_np (th, &status)) != 0)
+ {
+ if (val != EBUSY)
+ {
+ printf ("tryjoin returned %s (%d), expected only 0 or EBUSY\n",
+ strerror (val), val);
+ exit (1);
+ }
+
+ /* Delay minimally. */
+ struct timespec ts = { .tv_sec = 0, .tv_nsec = 10000000 };
+ nanosleep (&ts, NULL);
+ }
+
+ if (status != (void *) 42l)
+ {
+ printf ("return value %p, expected %p\n", status, (void *) 42l);
+ exit (1);
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-join3.c b/test/nptl/tst-join3.c
new file mode 100644
index 000000000..b25ffd8ba
--- /dev/null
+++ b/test/nptl/tst-join3.c
@@ -0,0 +1,122 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+
+
+static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+
+
+static void *
+tf (void *arg)
+{
+ if (pthread_mutex_lock (&lock) != 0)
+ {
+ puts ("child: mutex_lock failed");
+ return NULL;
+ }
+
+ return (void *) 42l;
+}
+
+
+static int
+do_test (void)
+{
+ pthread_t th;
+
+ if (pthread_mutex_lock (&lock) != 0)
+ {
+ puts ("mutex_lock failed");
+ exit (1);
+ }
+
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("mutex_create failed");
+ exit (1);
+ }
+
+ void *status;
+ struct timespec ts;
+ struct timeval tv;
+ (void) gettimeofday (&tv, NULL);
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+ ts.tv_nsec += 200000000;
+ if (ts.tv_nsec >= 1000000000)
+ {
+ ts.tv_nsec -= 1000000000;
+ ++ts.tv_sec;
+ }
+ int val = pthread_timedjoin_np (th, &status, &ts);
+ if (val == 0)
+ {
+ puts ("1st timedjoin succeeded");
+ exit (1);
+ }
+ else if (val != ETIMEDOUT)
+ {
+ puts ("1st timedjoin didn't return ETIMEDOUT");
+ exit (1);
+ }
+
+ if (pthread_mutex_unlock (&lock) != 0)
+ {
+ puts ("mutex_unlock failed");
+ exit (1);
+ }
+
+ while (1)
+ {
+ (void) gettimeofday (&tv, NULL);
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+ ts.tv_nsec += 200000000;
+ if (ts.tv_nsec >= 1000000000)
+ {
+ ts.tv_nsec -= 1000000000;
+ ++ts.tv_sec;
+ }
+
+ val = pthread_timedjoin_np (th, &status, &ts);
+ if (val == 0)
+ break;
+
+ if (val != ETIMEDOUT)
+ {
+ printf ("timedjoin returned %s (%d), expected only 0 or ETIMEDOUT\n",
+ strerror (val), val);
+ exit (1);
+ }
+ }
+
+ if (status != (void *) 42l)
+ {
+ printf ("return value %p, expected %p\n", status, (void *) 42l);
+ exit (1);
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-join4.c b/test/nptl/tst-join4.c
new file mode 100644
index 000000000..96b650ddc
--- /dev/null
+++ b/test/nptl/tst-join4.c
@@ -0,0 +1,124 @@
+/* Copyright (C) 2003, 2004 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 <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static pthread_barrier_t bar;
+
+
+static void *
+tf (void *arg)
+{
+ if (pthread_barrier_wait (&bar) != 0)
+ {
+ puts ("tf: barrier_wait failed");
+ exit (1);
+ }
+
+ return (void *) 1l;
+}
+
+
+static int
+do_test (void)
+{
+ if (pthread_barrier_init (&bar, NULL, 3) != 0)
+ {
+ puts ("barrier_init failed");
+ exit (1);
+ }
+
+ pthread_attr_t a;
+
+ if (pthread_attr_init (&a) != 0)
+ {
+ puts ("attr_init failed");
+ exit (1);
+ }
+
+ if (pthread_attr_setstacksize (&a, 1 * 1024 * 1024) != 0)
+ {
+ puts ("attr_setstacksize failed");
+ return 1;
+ }
+
+ pthread_t th[2];
+
+ if (pthread_create (&th[0], &a, tf, NULL) != 0)
+ {
+ puts ("1st create failed");
+ exit (1);
+ }
+
+ if (pthread_attr_setdetachstate (&a, PTHREAD_CREATE_DETACHED) != 0)
+ {
+ puts ("attr_setdetachstate failed");
+ exit (1);
+ }
+
+ if (pthread_create (&th[1], &a, tf, NULL) != 0)
+ {
+ puts ("1st create failed");
+ exit (1);
+ }
+
+ if (pthread_attr_destroy (&a) != 0)
+ {
+ puts ("attr_destroy failed");
+ exit (1);
+ }
+
+ if (pthread_detach (th[0]) != 0)
+ {
+ puts ("could not detach 1st thread");
+ exit (1);
+ }
+
+ int err = pthread_detach (th[0]);
+ if (err == 0)
+ {
+ puts ("second detach of 1st thread succeeded");
+ exit (1);
+ }
+ if (err != EINVAL)
+ {
+ printf ("second detach of 1st thread returned %d, not EINVAL\n", err);
+ exit (1);
+ }
+
+ err = pthread_detach (th[1]);
+ if (err == 0)
+ {
+ puts ("detach of 2nd thread succeeded");
+ exit (1);
+ }
+ if (err != EINVAL)
+ {
+ printf ("detach of 2nd thread returned %d, not EINVAL\n", err);
+ exit (1);
+ }
+
+ exit (0);
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-join5.c b/test/nptl/tst-join5.c
new file mode 100644
index 000000000..feeee2ee3
--- /dev/null
+++ b/test/nptl/tst-join5.c
@@ -0,0 +1,142 @@
+/* Copyright (C) 2003 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 <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static void *
+tf1 (void *arg)
+{
+ pthread_join ((pthread_t) arg, NULL);
+
+ puts ("1st join returned");
+
+ return (void *) 1l;
+}
+
+
+static void *
+tf2 (void *arg)
+{
+ int a;
+ a = pthread_join ((pthread_t) arg, NULL);
+
+ puts ("2nd join returned");
+ printf("a = %i\n", a);
+
+ return (void *) 1l;
+}
+
+
+static int
+do_test (void)
+{
+ pthread_t th;
+
+ int err = pthread_join (pthread_self (), NULL);
+ if (err == 0)
+ {
+ puts ("1st circular join succeeded");
+ exit (1);
+ }
+ if (err != EDEADLK)
+ {
+ printf ("1st circular join %d, not EDEADLK\n", err);
+ exit (1);
+ }
+
+ if (pthread_create (&th, NULL, tf1, (void *) pthread_self ()) != 0)
+ {
+ puts ("1st create failed");
+ exit (1);
+ }
+
+ if (pthread_cancel (th) != 0)
+ {
+ puts ("cannot cancel 1st thread");
+ exit (1);
+ }
+
+ void *r;
+ err = pthread_join (th, &r);
+ if (err != 0)
+ {
+ printf ("cannot join 1st thread: %d\n", err);
+ exit (1);
+ }
+ if (r != PTHREAD_CANCELED)
+ {
+ puts ("1st thread not canceled");
+ exit (1);
+ }
+
+ err = pthread_join (pthread_self (), NULL);
+ if (err == 0)
+ {
+ puts ("2nd circular join succeeded");
+ exit (1);
+ }
+ if (err != EDEADLK)
+ {
+ printf ("2nd circular join %d, not EDEADLK\n", err);
+ exit (1);
+ }
+
+ if (pthread_create (&th, NULL, tf2, (void *) pthread_self ()) != 0)
+ {
+ puts ("2nd create failed");
+ exit (1);
+ }
+
+ if (pthread_cancel (th) != 0)
+ {
+ puts ("cannot cancel 2nd thread");
+ exit (1);
+ }
+
+ if (pthread_join (th, &r) != 0)
+ {
+ puts ("cannot join 2nd thread");
+ exit (1);
+ }
+ if (r != PTHREAD_CANCELED)
+ {
+ puts ("2nd thread not canceled");
+ exit (1);
+ }
+
+ err = pthread_join (pthread_self (), NULL);
+ if (err == 0)
+ {
+ puts ("2nd circular join succeeded");
+ exit (1);
+ }
+ if (err != EDEADLK)
+ {
+ printf ("2nd circular join %d, not EDEADLK\n", err);
+ exit (1);
+ }
+
+ exit (0);
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-join6.c b/test/nptl/tst-join6.c
new file mode 100644
index 000000000..0c9e7c056
--- /dev/null
+++ b/test/nptl/tst-join6.c
@@ -0,0 +1,2 @@
+#define WAIT_IN_CHILD 1
+#include "tst-join5.c"
diff --git a/test/nptl/tst-key1.c b/test/nptl/tst-key1.c
new file mode 100644
index 000000000..ebda39533
--- /dev/null
+++ b/test/nptl/tst-key1.c
@@ -0,0 +1,88 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <limits.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+int
+do_test (void)
+{
+ int max;
+#ifdef PTHREAD_KEYS_MAX
+ max = PTHREAD_KEYS_MAX;
+#else
+ max = _POSIX_THREAD_KEYS_MAX;
+#endif
+ pthread_key_t *keys = alloca (max * sizeof (pthread_key_t));
+
+ int i;
+ for (i = 0; i < max; ++i)
+ if (pthread_key_create (&keys[i], NULL) != 0)
+ {
+ write (2, "key_create failed\n", 18);
+ _exit (1);
+ }
+ else
+ {
+ printf ("created key %d\n", i);
+
+ if (pthread_setspecific (keys[i], (const void *) (i + 100l)) != 0)
+ {
+ write (2, "setspecific failed\n", 19);
+ _exit (1);
+ }
+ }
+
+ for (i = 0; i < max; ++i)
+ {
+ if (pthread_getspecific (keys[i]) != (void *) (i + 100l))
+ {
+ write (2, "getspecific failed\n", 19);
+ _exit (1);
+ }
+
+ if (pthread_key_delete (keys[i]) != 0)
+ {
+ write (2, "key_delete failed\n", 18);
+ _exit (1);
+ }
+ }
+
+ /* Now it must be once again possible to allocate keys. */
+ if (pthread_key_create (&keys[0], NULL) != 0)
+ {
+ write (2, "2nd key_create failed\n", 22);
+ _exit (1);
+ }
+
+ if (pthread_key_delete (keys[0]) != 0)
+ {
+ write (2, "2nd key_delete failed\n", 22);
+ _exit (1);
+ }
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-key2.c b/test/nptl/tst-key2.c
new file mode 100644
index 000000000..c32031e60
--- /dev/null
+++ b/test/nptl/tst-key2.c
@@ -0,0 +1,114 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#define N 2
+
+
+static int cnt0;
+static void
+f0 (void *p)
+{
+ ++cnt0;
+}
+
+
+static int cnt1;
+static void
+f1 (void *p)
+{
+ ++cnt1;
+}
+
+
+static void (*fcts[N]) (void *) =
+{
+ f0,
+ f1
+};
+
+
+static void *
+tf (void *arg)
+{
+ pthread_key_t *key = (pthread_key_t *) arg;
+
+ if (pthread_setspecific (*key, (void *) -1l) != 0)
+ {
+ write (2, "setspecific failed\n", 19);
+ _exit (1);
+ }
+
+ return NULL;
+}
+
+
+int
+do_test (void)
+{
+ pthread_key_t keys[N];
+
+ int i;
+ for (i = 0; i < N; ++i)
+ if (pthread_key_create (&keys[i], fcts[i]) != 0)
+ {
+ write (2, "key_create failed\n", 18);
+ _exit (1);
+ }
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, &keys[1]) != 0)
+ {
+ write (2, "create failed\n", 14);
+ _exit (1);
+ }
+
+ if (pthread_join (th, NULL) != 0)
+ {
+ write (2, "join failed\n", 12);
+ _exit (1);
+ }
+
+ if (cnt0 != 0)
+ {
+ write (2, "cnt0 != 0\n", 10);
+ _exit (1);
+ }
+
+ if (cnt1 != 1)
+ {
+ write (2, "cnt1 != 1\n", 10);
+ _exit (1);
+ }
+
+ for (i = 0; i < N; ++i)
+ if (pthread_key_delete (keys[i]) != 0)
+ {
+ write (2, "key_delete failed\n", 18);
+ _exit (1);
+ }
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-key3.c b/test/nptl/tst-key3.c
new file mode 100644
index 000000000..f5426ce12
--- /dev/null
+++ b/test/nptl/tst-key3.c
@@ -0,0 +1,155 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#define N 2
+
+
+static int cnt0;
+static void
+f0 (void *p)
+{
+ ++cnt0;
+}
+
+
+static int cnt1;
+static void
+f1 (void *p)
+{
+ ++cnt1;
+}
+
+
+static void (*fcts[N]) (void *) =
+{
+ f0,
+ f1
+};
+
+
+static pthread_barrier_t b;
+
+
+static void *
+tf (void *arg)
+{
+ pthread_key_t *key = (pthread_key_t *) arg;
+
+ if (pthread_setspecific (*key, (void *) -1l) != 0)
+ {
+ write (2, "setspecific failed\n", 19);
+ _exit (1);
+ }
+
+ pthread_barrier_wait (&b);
+
+ const struct timespec t = { .tv_sec = 1000, .tv_nsec = 0 };
+ while (1)
+ nanosleep (&t, NULL);
+
+ /* NOTREACHED */
+ return NULL;
+}
+
+
+int
+do_test (void)
+{
+ pthread_key_t keys[N];
+
+ int i;
+ for (i = 0; i < N; ++i)
+ if (pthread_key_create (&keys[i], fcts[i]) != 0)
+ {
+ write (2, "key_create failed\n", 18);
+ _exit (1);
+ }
+
+ if (pthread_barrier_init (&b, NULL, 2) != 0)
+ {
+ write (2, "barrier_init failed\n", 20);
+ _exit (1);
+ }
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, &keys[1]) != 0)
+ {
+ write (2, "create failed\n", 14);
+ _exit (1);
+ }
+
+ pthread_barrier_wait (&b);
+
+ if (pthread_cancel (th) != 0)
+ {
+ write (2, "cancel failed\n", 14);
+ _exit (1);
+ }
+
+ void *status;
+ if (pthread_join (th, &status) != 0)
+ {
+ write (2, "join failed\n", 12);
+ _exit (1);
+ }
+
+ if (status != PTHREAD_CANCELED)
+ {
+ write (2, "thread not canceled\n", 20);
+ _exit (1);
+ }
+
+ /* Note that the TSD destructors not necessarily have to have
+ finished by the time pthread_join returns. At least according to
+ POSIX. We implement the stronger requirement that they indeed
+ have run and therefore these tests succeed. */
+ if (cnt0 != 0)
+ {
+ write (2, "cnt0 != 0\n", 10);
+ _exit (1);
+ }
+
+ if (cnt1 != 1)
+ {
+ write (2, "cnt1 != 1\n", 10);
+ _exit (1);
+ }
+
+ for (i = 0; i < N; ++i)
+ if (pthread_key_delete (keys[i]) != 0)
+ {
+ write (2, "key_delete failed\n", 18);
+ _exit (1);
+ }
+
+ if (pthread_barrier_destroy (&b) != 0)
+ {
+ write (2, "barrier_destroy failed\n", 23);
+ _exit (1);
+ }
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-key4.c b/test/nptl/tst-key4.c
new file mode 100644
index 000000000..af44c2234
--- /dev/null
+++ b/test/nptl/tst-key4.c
@@ -0,0 +1,136 @@
+/* Copyright (C) 2003, 2004 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 <limits.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+#ifdef PTHREAD_KEYS_MAX
+const int max = PTHREAD_KEYS_MAX;
+#else
+const int max = _POSIX_THREAD_KEYS_MAX;
+#endif
+static pthread_key_t *keys;
+
+
+static void *
+tf1 (void *arg)
+{
+ int i;
+ for (i = 0; i < max; ++i)
+ if (pthread_setspecific (keys[i], (void *) (long int) (i + 1)) != 0)
+ {
+ puts ("setspecific failed");
+ exit (1);
+ }
+
+ return NULL;
+}
+
+
+static void *
+tf2 (void *arg)
+{
+ int i;
+ for (i = 0; i < max; ++i)
+ if (pthread_getspecific (keys[i]) != NULL)
+ {
+ printf ("getspecific for key %d not NULL\n", i);
+ exit (1);
+ }
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ keys = alloca (max * sizeof (pthread_key_t));
+
+ int i;
+ for (i = 0; i < max; ++i)
+ if (pthread_key_create (&keys[i], NULL) != 0)
+ {
+ puts ("key_create failed");
+ exit (1);
+ }
+
+ pthread_attr_t a;
+
+ if (pthread_attr_init (&a) != 0)
+ {
+ puts ("attr_init failed");
+ exit (1);
+ }
+
+ if (pthread_attr_setstacksize (&a, 1 * 1024 * 1024) != 0)
+ {
+ puts ("attr_setstacksize failed");
+ return 1;
+ }
+
+ for (i = 0; i < 10; ++i)
+ {
+ int j;
+#define N 2
+ pthread_t th[N];
+ for (j = 0; j < N; ++j)
+ if (pthread_create (&th[j], NULL, tf1, NULL) != 0)
+ {
+ puts ("1st create failed");
+ exit (1);
+ }
+
+ for (j = 0; j < N; ++j)
+ if (pthread_join (th[j], NULL) != 0)
+ {
+ puts ("1st join failed");
+ exit (1);
+ }
+
+ for (j = 0; j < N; ++j)
+ if (pthread_create (&th[j], NULL, tf2, NULL) != 0)
+ {
+ puts ("2nd create failed");
+ exit (1);
+ }
+
+ for (j = 0; j < N; ++j)
+ if (pthread_join (th[j], NULL) != 0)
+ {
+ puts ("2nd join failed");
+ exit (1);
+ }
+ }
+
+ if (pthread_attr_destroy (&a) != 0)
+ {
+ puts ("attr_destroy failed");
+ exit (1);
+ }
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-kill1.c b/test/nptl/tst-kill1.c
new file mode 100644
index 000000000..f58016f97
--- /dev/null
+++ b/test/nptl/tst-kill1.c
@@ -0,0 +1,99 @@
+/* Copyright (C) 2003 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 <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static pthread_cond_t c = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
+static pthread_barrier_t b;
+
+static void *
+tf (void *a)
+{
+ if (pthread_mutex_lock (&m) != 0)
+ {
+ puts ("child: mutex_lock failed");
+ exit (1);
+ }
+
+ int e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("child: barrier_wait failed");
+ exit (1);
+ }
+
+ /* This call should never return. */
+ pthread_cond_wait (&c, &m);
+
+ return NULL;
+}
+
+
+int
+do_test (void)
+{
+ pthread_t th;
+
+ if (pthread_barrier_init (&b, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ exit (1);
+ }
+
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ exit (1);
+ }
+
+ int e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ exit (1);
+ }
+
+ if (pthread_mutex_lock (&m) != 0)
+ {
+ puts ("mutex_lock failed");
+ exit (1);
+ }
+
+ /* Send the thread a signal which it doesn't catch and which will
+ cause the process to terminate. */
+ if (pthread_kill (th, SIGUSR1) != 0)
+ {
+ puts ("kill failed");
+ exit (1);
+ }
+
+ /* This call should never return. */
+ pthread_join (th, NULL);
+
+ return 0;
+}
+
+
+#define EXPECTED_SIGNAL SIGUSR1
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-kill2.c b/test/nptl/tst-kill2.c
new file mode 100644
index 000000000..0315a020f
--- /dev/null
+++ b/test/nptl/tst-kill2.c
@@ -0,0 +1,138 @@
+/* Copyright (C) 2003 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 <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/time.h>
+
+
+static pthread_cond_t c = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
+static pthread_barrier_t b;
+
+static void *
+tf (void *a)
+{
+ /* Block SIGUSR1. */
+ sigset_t ss;
+
+ sigemptyset (&ss);
+ sigaddset (&ss, SIGUSR1);
+ if (pthread_sigmask (SIG_BLOCK, &ss, NULL) != 0)
+ {
+ puts ("child: sigmask failed");
+ exit (1);
+ }
+
+ if (pthread_mutex_lock (&m) != 0)
+ {
+ puts ("child: mutex_lock failed");
+ exit (1);
+ }
+
+ int e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("child: barrier_wait failed");
+ exit (1);
+ }
+
+ /* Compute timeout. */
+ struct timeval tv;
+ (void) gettimeofday (&tv, NULL);
+ struct timespec ts;
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+ /* Timeout: 1sec. */
+ ts.tv_sec += 1;
+
+ /* This call should never return. */
+ if (pthread_cond_timedwait (&c, &m, &ts) != ETIMEDOUT)
+ {
+ puts ("cond_timedwait didn't time out");
+ exit (1);
+ }
+
+ return NULL;
+}
+
+
+int
+do_test (void)
+{
+ pthread_t th;
+
+ if (pthread_barrier_init (&b, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ exit (1);
+ }
+
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ exit (1);
+ }
+
+ int e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ exit (1);
+ }
+
+ if (pthread_mutex_lock (&m) != 0)
+ {
+ puts ("mutex_lock failed");
+ exit (1);
+ }
+
+ /* Send the thread a signal which it has blocked. */
+ if (pthread_kill (th, SIGUSR1) != 0)
+ {
+ puts ("kill failed");
+ exit (1);
+ }
+
+ if (pthread_mutex_unlock (&m) != 0)
+ {
+ puts ("mutex_unlock failed");
+ exit (1);
+ }
+
+ void *r;
+ if (pthread_join (th, &r) != 0)
+ {
+ puts ("join failed");
+ exit (1);
+ }
+ if (r != NULL)
+ {
+ puts ("return value wrong");
+ exit (1);
+ }
+
+ return 0;
+}
+
+
+#define TIMEOUT 5
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-kill3.c b/test/nptl/tst-kill3.c
new file mode 100644
index 000000000..fe9359b39
--- /dev/null
+++ b/test/nptl/tst-kill3.c
@@ -0,0 +1,158 @@
+/* Copyright (C) 2003 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 <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/time.h>
+
+
+static pthread_cond_t c = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
+static pthread_barrier_t b;
+
+
+static void
+handler (int sig)
+{
+ write (1, "handler called\n", 15);
+ _exit (1);
+}
+
+
+static void *
+tf (void *a)
+{
+ /* Block SIGUSR1. */
+ sigset_t ss;
+
+ sigemptyset (&ss);
+ sigaddset (&ss, SIGUSR1);
+ if (pthread_sigmask (SIG_BLOCK, &ss, NULL) != 0)
+ {
+ puts ("child: sigmask failed");
+ exit (1);
+ }
+
+ if (pthread_mutex_lock (&m) != 0)
+ {
+ puts ("child: mutex_lock failed");
+ exit (1);
+ }
+
+ int e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("child: barrier_wait failed");
+ exit (1);
+ }
+
+ /* Compute timeout. */
+ struct timeval tv;
+ (void) gettimeofday (&tv, NULL);
+ struct timespec ts;
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+ /* Timeout: 1sec. */
+ ts.tv_sec += 1;
+
+ /* This call should never return. */
+ if (pthread_cond_timedwait (&c, &m, &ts) != ETIMEDOUT)
+ {
+ puts ("cond_timedwait didn't time out");
+ exit (1);
+ }
+
+ return NULL;
+}
+
+
+int
+do_test (void)
+{
+ pthread_t th;
+
+ struct sigaction sa;
+ sigemptyset (&sa.sa_mask);
+ sa.sa_flags = 0;
+ sa.sa_handler = handler;
+ if (sigaction (SIGUSR1, &sa, NULL) != 0)
+ {
+ puts ("sigaction failed");
+ exit (1);
+ }
+
+ if (pthread_barrier_init (&b, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ exit (1);
+ }
+
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ exit (1);
+ }
+
+ int e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ exit (1);
+ }
+
+ if (pthread_mutex_lock (&m) != 0)
+ {
+ puts ("mutex_lock failed");
+ exit (1);
+ }
+
+ /* Send the thread a signal which it has blocked. */
+ if (pthread_kill (th, SIGUSR1) != 0)
+ {
+ puts ("kill failed");
+ exit (1);
+ }
+
+ if (pthread_mutex_unlock (&m) != 0)
+ {
+ puts ("mutex_unlock failed");
+ exit (1);
+ }
+
+ void *r;
+ if (pthread_join (th, &r) != 0)
+ {
+ puts ("join failed");
+ exit (1);
+ }
+ if (r != NULL)
+ {
+ puts ("return value wrong");
+ exit (1);
+ }
+
+ return 0;
+}
+
+
+#define TIMEOUT 5
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-kill4.c b/test/nptl/tst-kill4.c
new file mode 100644
index 000000000..4ede7ed5d
--- /dev/null
+++ b/test/nptl/tst-kill4.c
@@ -0,0 +1,73 @@
+/* Copyright (C) 2003 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 <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static void *
+tf (void *a)
+{
+ return NULL;
+}
+
+
+int
+do_test (void)
+{
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ exit (1);
+ }
+
+ if (pthread_join (th, NULL) != 0)
+ {
+ puts ("join failed");
+ exit (1);
+ }
+
+ /* The following only works because we assume here something about
+ the implementation. Namely, that the memory allocated for the
+ thread descriptor is not going away, that the the TID field is
+ cleared and therefore the signal is sent to process 0, and that
+ we can savely assume there is no other process with this ID at
+ that time. */
+ int e = pthread_kill (th, 0);
+ if (e == 0)
+ {
+ puts ("pthread_kill succeeded");
+ exit (1);
+ }
+ if (e != ESRCH)
+ {
+ puts ("pthread_kill didn't return ESRCH");
+ exit (1);
+ }
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-kill5.c b/test/nptl/tst-kill5.c
new file mode 100644
index 000000000..254015c36
--- /dev/null
+++ b/test/nptl/tst-kill5.c
@@ -0,0 +1,48 @@
+/* Copyright (C) 2003 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 <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+int
+do_test (void)
+{
+ /* XXX This test might require architecture and system specific changes.
+ There is no guarantee that this signal number is invalid. */
+ int e = pthread_kill (pthread_self (), SIGRTMAX + 10);
+ if (e == 0)
+ {
+ puts ("kill didn't failed");
+ exit (1);
+ }
+ if (e != EINVAL)
+ {
+ puts ("error not EINVAL");
+ exit (1);
+ }
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-kill6.c b/test/nptl/tst-kill6.c
new file mode 100644
index 000000000..f530e4ed0
--- /dev/null
+++ b/test/nptl/tst-kill6.c
@@ -0,0 +1,161 @@
+/* Copyright (C) 2003, 2004 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 <errno.h>
+#include <pthread.h>
+#include <semaphore.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static pthread_t receiver;
+static sem_t sem;
+static pthread_barrier_t b;
+
+static void
+handler (int sig)
+{
+ if (sig != SIGUSR1)
+ {
+ write (STDOUT_FILENO, "wrong signal\n", 13);
+ _exit (1);
+ }
+
+ if (pthread_self () != receiver)
+ {
+ write (STDOUT_FILENO, "not the intended receiver\n", 26);
+ _exit (1);
+ }
+
+ if (sem_post (&sem) != 0)
+ {
+ write (STDOUT_FILENO, "sem_post failed\n", 16);
+ _exit (1);
+ }
+}
+
+
+static void *
+tf (void *a)
+{
+ int e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("child: barrier_wait failed");
+ exit (1);
+ }
+
+ return NULL;
+}
+
+
+int
+do_test (void)
+{
+ struct sigaction sa;
+ sigemptyset (&sa.sa_mask);
+ sa.sa_flags = 0;
+ sa.sa_handler = handler;
+ if (sigaction (SIGUSR1, &sa, NULL) != 0)
+ {
+ puts ("sigaction failed");
+ exit (1);
+ }
+
+#define N 20
+
+ if (pthread_barrier_init (&b, NULL, N + 1) != 0)
+ {
+ puts ("barrier_init failed");
+ exit (1);
+ }
+
+ pthread_attr_t a;
+
+ if (pthread_attr_init (&a) != 0)
+ {
+ puts ("attr_init failed");
+ exit (1);
+ }
+
+ if (pthread_attr_setstacksize (&a, 1 * 1024 * 1024) != 0)
+ {
+ puts ("attr_setstacksize failed");
+ return 1;
+ }
+
+ pthread_t th[N];
+ int i;
+ for (i = 0; i < N; ++i)
+ if (pthread_create (&th[i], &a, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ exit (1);
+ }
+
+ if (pthread_attr_destroy (&a) != 0)
+ {
+ puts ("attr_destroy failed");
+ exit (1);
+ }
+
+ if (sem_init (&sem, 0, 0) != 0)
+ {
+ puts ("sem_init failed");
+ exit (1);
+ }
+
+ for (i = 0; i < N * 10; ++i)
+ {
+ receiver = th[i % N];
+
+ if (pthread_kill (receiver, SIGUSR1) != 0)
+ {
+ puts ("kill failed");
+ exit (1);
+ }
+
+ if (TEMP_FAILURE_RETRY (sem_wait (&sem)) != 0)
+ {
+ puts ("sem_wait failed");
+ exit (1);
+ }
+ }
+
+ int e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ exit (1);
+ }
+
+ for (i = 0; i < N; ++i)
+ if (pthread_join (th[i], NULL) != 0)
+ {
+ puts ("join failed");
+ exit (1);
+ }
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-mqueue.h b/test/nptl/tst-mqueue.h
new file mode 100644
index 000000000..1401c3e03
--- /dev/null
+++ b/test/nptl/tst-mqueue.h
@@ -0,0 +1,83 @@
+/* Common code for message queue passing tests.
+ Copyright (C) 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
+
+ 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 <mqueue.h>
+#include <search.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/uio.h>
+#include <unistd.h>
+
+static int temp_mq_fd;
+
+/* Add temporary files in list. */
+static void
+__attribute__ ((unused))
+add_temp_mq (const char *name)
+{
+ struct iovec iov[2];
+ iov[0].iov_base = (char *) name;
+ iov[0].iov_len = strlen (name);
+ iov[1].iov_base = (char *) "\n";
+ iov[1].iov_len = 1;
+ if (writev (temp_mq_fd, iov, 2) != iov[0].iov_len + 1)
+ printf ("Could not record temp mq filename %s\n", name);
+}
+
+/* Delete all temporary message queues. */
+static void
+do_cleanup (void)
+{
+ if (lseek (temp_mq_fd, 0, SEEK_SET) != 0)
+ return;
+
+ FILE *f = fdopen (temp_mq_fd, "r");
+ if (f == NULL)
+ return;
+
+ char *line = NULL;
+ size_t n = 0;
+ ssize_t rets;
+ while ((rets = getline (&line, &n, f)) > 0)
+ {
+ if (line[rets - 1] != '\n')
+ continue;
+
+ line[rets - 1] = '\0';
+ mq_unlink (line);
+ }
+ fclose (f);
+}
+
+static void
+do_prepare (void)
+{
+ char name [] = "/tmp/tst-mqueueN.XXXXXX";
+ temp_mq_fd = mkstemp (name);
+ if (temp_mq_fd == -1)
+ {
+ printf ("Could not create temporary file %s: %m\n", name);
+ exit (1);
+ }
+ unlink (name);
+}
+
+#define PREPARE(argc, argv) do_prepare ()
+#define CLEANUP_HANDLER do_cleanup ()
diff --git a/test/nptl/tst-mqueue1.c b/test/nptl/tst-mqueue1.c
new file mode 100644
index 000000000..5ec79cf3b
--- /dev/null
+++ b/test/nptl/tst-mqueue1.c
@@ -0,0 +1,416 @@
+/* Test message queue passing.
+ Copyright (C) 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
+
+ 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 <fcntl.h>
+#include <mqueue.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/wait.h>
+#include <time.h>
+#include <unistd.h>
+#include "tst-mqueue.h"
+
+static int
+intcmp (const void *a, const void *b)
+{
+ if (*(unsigned char *)a < *(unsigned char *)b)
+ return 1;
+ if (*(unsigned char *)a > *(unsigned char *)b)
+ return -1;
+ return 0;
+}
+
+static int
+check_attrs (struct mq_attr *attr, int nonblock, long cnt)
+{
+ int result = 0;
+
+ if (attr->mq_maxmsg != 10 || attr->mq_msgsize != 1)
+ {
+ printf ("attributes don't match those passed to mq_open\n"
+ "mq_maxmsg %ld, mq_msgsize %ld\n",
+ attr->mq_maxmsg, attr->mq_msgsize);
+ result = 1;
+ }
+
+ if ((attr->mq_flags & O_NONBLOCK) != nonblock)
+ {
+ printf ("mq_flags %lx != %x\n", (attr->mq_flags & O_NONBLOCK), nonblock);
+ result = 1;
+ }
+
+ if (attr->mq_curmsgs != cnt)
+ {
+ printf ("mq_curmsgs %ld != %ld\n", attr->mq_curmsgs, cnt);
+ result = 1;
+ }
+
+ return result;
+}
+
+static int
+do_one_test (mqd_t q, const char *name, int nonblock)
+{
+ int result = 0;
+
+ char v []
+ = { 0x32, 0x62, 0x22, 0x31, 0x11, 0x73, 0x61, 0x21, 0x72, 0x71, 0x81 };
+
+ struct mq_attr attr;
+ memset (&attr, 0xaa, sizeof (attr));
+ if (mq_getattr (q, &attr) != 0)
+ {
+ printf ("mq_getattr failed: %m\n");
+ result = 1;
+ }
+ else
+ result |= check_attrs (&attr, nonblock, 0);
+
+ if (mq_receive (q, &v[0], 1, NULL) != -1)
+ {
+ puts ("mq_receive on O_WRONLY mqd_t unexpectedly succeeded");
+ result = 1;
+ }
+ else if (errno != EBADF)
+ {
+ printf ("mq_receive on O_WRONLY mqd_t did not fail with EBADF: %m\n");
+ result = 1;
+ }
+
+ struct timespec ts;
+ if (clock_gettime (CLOCK_REALTIME, &ts) == 0)
+ --ts.tv_sec;
+ else
+ {
+ ts.tv_sec = time (NULL) - 1;
+ ts.tv_nsec = 0;
+ }
+
+ int ret;
+ for (int i = 0; i < 10; ++i)
+ {
+ if (i & 1)
+ ret = mq_send (q, &v[i], 1, v[i] >> 4);
+ else
+ ret = mq_timedsend (q, &v[i], 1, v[i] >> 4, &ts);
+
+ if (ret)
+ {
+ printf ("mq_%ssend failed: %m\n", (i & 1) ? "" : "timed");
+ result = 1;
+ }
+ }
+
+ ret = mq_timedsend (q, &v[10], 1, 8, &ts);
+ if (ret != -1)
+ {
+ puts ("mq_timedsend on full queue did not fail");
+ result = 1;
+ }
+ else if (errno != (nonblock ? EAGAIN : ETIMEDOUT))
+ {
+ printf ("mq_timedsend on full queue did not fail with %s: %m\n",
+ nonblock ? "EAGAIN" : "ETIMEDOUT");
+ result = 1;
+ }
+
+ if (nonblock)
+ {
+ ret = mq_send (q, &v[10], 1, 8);
+ if (ret != -1)
+ {
+ puts ("mq_send on full non-blocking queue did not fail");
+ result = 1;
+ }
+ else if (errno != EAGAIN)
+ {
+ printf ("mq_send on full non-blocking queue did not fail"
+ "with EAGAIN: %m\n");
+ result = 1;
+ }
+ }
+
+ memset (&attr, 0xaa, sizeof (attr));
+ if (mq_getattr (q, &attr) != 0)
+ {
+ printf ("mq_getattr failed: %m\n");
+ result = 1;
+ }
+ else
+ result |= check_attrs (&attr, nonblock, 10);
+
+ pid_t pid = fork ();
+ if (pid == -1)
+ {
+ printf ("fork failed: %m\n");
+ result = 1;
+ }
+ else if (pid == 0)
+ {
+ result = 0;
+
+ if (mq_close (q) != 0)
+ {
+ printf ("mq_close in child failed: %m\n");
+ result = 1;
+ }
+
+ q = mq_open (name, O_RDONLY | nonblock);
+ if (q == (mqd_t) -1)
+ {
+ printf ("mq_open in child failed: %m\n");
+ exit (1);
+ }
+
+ memset (&attr, 0xaa, sizeof (attr));
+ if (mq_getattr (q, &attr) != 0)
+ {
+ printf ("mq_getattr failed: %m\n");
+ result = 1;
+ }
+ else
+ result |= check_attrs (&attr, nonblock, 10);
+
+ char vr[11] = { };
+ unsigned int prio;
+ ssize_t rets;
+
+ if (mq_send (q, &v[0], 1, 1) != -1)
+ {
+ puts ("mq_send on O_RDONLY mqd_t unexpectedly succeeded");
+ result = 1;
+ }
+ else if (errno != EBADF)
+ {
+ printf ("mq_send on O_WRONLY mqd_t did not fail with EBADF: %m\n");
+ result = 1;
+ }
+
+ for (int i = 0; i < 10; ++i)
+ {
+ if (i & 1)
+ rets = mq_receive (q, &vr[i], 1, &prio);
+ else
+ rets = mq_timedreceive (q, &vr[i], 1, &prio, &ts);
+
+ if (rets != 1)
+ {
+ if (rets == -1)
+ printf ("mq_%sreceive failed: %m\n", (i & 1) ? "" : "timed");
+ else
+ printf ("mq_%sreceive returned %zd != 1\n",
+ (i & 1) ? "" : "timed", rets);
+ result = 1;
+ }
+ else if (prio != (unsigned int) vr[i] >> 4)
+ {
+ printf ("unexpected priority %x for value %02x\n", prio,
+ vr[i]);
+ result = 1;
+ }
+ }
+
+ qsort (v, 10, 1, intcmp);
+ if (memcmp (v, vr, 10) != 0)
+ {
+ puts ("messages not received in expected order");
+ result = 1;
+ }
+
+ rets = mq_timedreceive (q, &vr[10], 1, &prio, &ts);
+ if (rets != -1)
+ {
+ puts ("mq_timedreceive on empty queue did not fail");
+ result = 1;
+ }
+ else if (errno != (nonblock ? EAGAIN : ETIMEDOUT))
+ {
+ printf ("mq_timedreceive on empty queue did not fail with %s: %m\n",
+ nonblock ? "EAGAIN" : "ETIMEDOUT");
+ result = 1;
+ }
+
+ if (nonblock)
+ {
+ ret = mq_receive (q, &vr[10], 1, &prio);
+ if (ret != -1)
+ {
+ puts ("mq_receive on empty non-blocking queue did not fail");
+ result = 1;
+ }
+ else if (errno != EAGAIN)
+ {
+ printf ("mq_receive on empty non-blocking queue did not fail"
+ "with EAGAIN: %m\n");
+ result = 1;
+ }
+ }
+
+ memset (&attr, 0xaa, sizeof (attr));
+ if (mq_getattr (q, &attr) != 0)
+ {
+ printf ("mq_getattr failed: %m\n");
+ result = 1;
+ }
+ else
+ result |= check_attrs (&attr, nonblock, 0);
+
+ if (mq_close (q) != 0)
+ {
+ printf ("mq_close in child failed: %m\n");
+ result = 1;
+ }
+
+ exit (result);
+ }
+
+ int status;
+ if (TEMP_FAILURE_RETRY (waitpid (pid, &status, 0)) != pid)
+ {
+ printf ("waitpid failed: %m\n");
+ kill (pid, SIGKILL);
+ result = 1;
+ }
+ else if (!WIFEXITED (status) || WEXITSTATUS (status))
+ {
+ printf ("child failed: %d\n", status);
+ result = 1;
+ }
+
+ memset (&attr, 0xaa, sizeof (attr));
+ if (mq_getattr (q, &attr) != 0)
+ {
+ printf ("mq_getattr failed: %m\n");
+ result = 1;
+ }
+ else
+ result |= check_attrs (&attr, nonblock, 0);
+
+ return result;
+}
+
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+ int result = 0;
+
+ char name[sizeof "/tst-mqueue1-" + sizeof (pid_t) * 3];
+ snprintf (name, sizeof (name), "/tst-mqueue1-%u", getpid ());
+
+ struct mq_attr attr = { .mq_maxmsg = 10, .mq_msgsize = 1 };
+ mqd_t q = mq_open (name, O_CREAT | O_EXCL | O_WRONLY, 0600, &attr);
+
+ if (q == (mqd_t) -1)
+ {
+ printf ("mq_open failed with: %m\n");
+ return result;
+ }
+ else
+ add_temp_mq (name);
+
+ result |= do_one_test (q, name, 0);
+
+ mqd_t q2 = mq_open (name, O_WRONLY | O_NONBLOCK);
+ if (q2 == (mqd_t) -1)
+ {
+ printf ("mq_open failed with: %m\n");
+ q2 = q;
+ result = 1;
+ }
+ else
+ {
+ if (mq_close (q) != 0)
+ {
+ printf ("mq_close in parent failed: %m\n");
+ result = 1;
+ }
+
+ q = q2;
+ result |= do_one_test (q, name, O_NONBLOCK);
+
+ if (mq_getattr (q, &attr) != 0)
+ {
+ printf ("mq_getattr failed: %m\n");
+ result = 1;
+ }
+ else
+ {
+ attr.mq_flags ^= O_NONBLOCK;
+
+ struct mq_attr attr2;
+ memset (&attr2, 0x55, sizeof (attr2));
+ if (mq_setattr (q, &attr, &attr2) != 0)
+ {
+ printf ("mq_setattr failed: %m\n");
+ result = 1;
+ }
+ else if (attr.mq_flags != (attr2.mq_flags ^ O_NONBLOCK)
+ || attr.mq_maxmsg != attr2.mq_maxmsg
+ || attr.mq_msgsize != attr2.mq_msgsize
+ || attr.mq_curmsgs != 0
+ || attr2.mq_curmsgs != 0)
+ {
+ puts ("mq_setattr returned unexpected values in *omqstat");
+ result = 1;
+ }
+ else
+ {
+ result |= do_one_test (q, name, 0);
+
+ if (mq_setattr (q, &attr2, NULL) != 0)
+ {
+ printf ("mq_setattr failed: %m\n");
+ result = 1;
+ }
+ else
+ result |= do_one_test (q, name, O_NONBLOCK);
+ }
+ }
+ }
+
+ if (mq_unlink (name) != 0)
+ {
+ printf ("mq_unlink failed: %m\n");
+ result = 1;
+ }
+
+ if (mq_close (q) != 0)
+ {
+ printf ("mq_close in parent failed: %m\n");
+ result = 1;
+ }
+
+ if (mq_close (q) != -1)
+ {
+ puts ("second mq_close did not fail");
+ result = 1;
+ }
+ else if (errno != EBADF)
+ {
+ printf ("second mq_close did not fail with EBADF: %m\n");
+ result = 1;
+ }
+
+ return result;
+}
+
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-mqueue2.c b/test/nptl/tst-mqueue2.c
new file mode 100644
index 000000000..9fbaedd90
--- /dev/null
+++ b/test/nptl/tst-mqueue2.c
@@ -0,0 +1,476 @@
+/* Test message queue passing.
+ Copyright (C) 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
+
+ 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 <fcntl.h>
+#include <mqueue.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+#include <sys/wait.h>
+#include <time.h>
+#include <unistd.h>
+#include "tst-mqueue.h"
+
+static void
+alrm_handler (int sig)
+{
+}
+
+#define TIMEOUT 10
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+ int result = 0;
+
+ char name[sizeof "/tst-mqueue2-" + sizeof (pid_t) * 3];
+ snprintf (name, sizeof (name), "/tst-mqueue2-%u", getpid ());
+
+ struct mq_attr attr = { .mq_maxmsg = 2, .mq_msgsize = 2 };
+ mqd_t q = mq_open (name, O_CREAT | O_EXCL | O_RDWR, 0600, &attr);
+
+ if (q == (mqd_t) -1)
+ {
+ printf ("mq_open failed with: %m\n");
+ return result;
+ }
+ else
+ add_temp_mq (name);
+
+ mqd_t q2 = mq_open (name, O_CREAT | O_EXCL | O_RDWR, 0600, &attr);
+ if (q2 != (mqd_t) -1)
+ {
+ puts ("mq_open with O_EXCL unexpectedly succeeded");
+ result = 1;
+ }
+ else if (errno != EEXIST)
+ {
+ printf ("mq_open did not fail with EEXIST: %m\n");
+ result = 1;
+ }
+
+ char name2[sizeof "/tst-mqueue2-2-" + sizeof (pid_t) * 3];
+ snprintf (name2, sizeof (name2), "/tst-mqueue2-2-%u", getpid ());
+
+ attr.mq_maxmsg = -2;
+ q2 = mq_open (name2, O_CREAT | O_EXCL | O_RDWR, 0600, &attr);
+ if (q2 != (mqd_t) -1)
+ {
+ puts ("mq_open with invalid mq_maxmsg unexpectedly succeeded");
+ add_temp_mq (name2);
+ result = 1;
+ }
+ else if (errno != EINVAL)
+ {
+ printf ("mq_open with invalid mq_maxmsg did not fail with "
+ "EINVAL: %m\n");
+ result = 1;
+ }
+
+ attr.mq_maxmsg = 2;
+ attr.mq_msgsize = -56;
+ q2 = mq_open (name2, O_CREAT | O_EXCL | O_RDWR, 0600, &attr);
+ if (q2 != (mqd_t) -1)
+ {
+ puts ("mq_open with invalid mq_msgsize unexpectedly succeeded");
+ add_temp_mq (name2);
+ result = 1;
+ }
+ else if (errno != EINVAL)
+ {
+ printf ("mq_open with invalid mq_msgsize did not fail with "
+ "EINVAL: %m\n");
+ result = 1;
+ }
+
+ char buf[3];
+ struct timespec ts;
+ if (clock_gettime (CLOCK_REALTIME, &ts) == 0)
+ ts.tv_sec += 10;
+ else
+ {
+ ts.tv_sec = time (NULL) + 10;
+ ts.tv_nsec = 0;
+ }
+
+ if (mq_timedreceive (q, buf, 1, NULL, &ts) == 0)
+ {
+ puts ("mq_timedreceive with too small msg_len did not fail");
+ result = 1;
+ }
+ else if (errno != EMSGSIZE)
+ {
+ printf ("mq_timedreceive with too small msg_len did not fail with "
+ "EMSGSIZE: %m\n");
+ result = 1;
+ }
+
+ ts.tv_nsec = -1;
+ if (mq_timedreceive (q, buf, 2, NULL, &ts) == 0)
+ {
+ puts ("mq_timedreceive with negative tv_nsec did not fail");
+ result = 1;
+ }
+ else if (errno != EINVAL)
+ {
+ printf ("mq_timedreceive with negative tv_nsec did not fail with "
+ "EINVAL: %m\n");
+ result = 1;
+ }
+
+ ts.tv_nsec = 1000000000;
+ if (mq_timedreceive (q, buf, 2, NULL, &ts) == 0)
+ {
+ puts ("mq_timedreceive with tv_nsec >= 1000000000 did not fail");
+ result = 1;
+ }
+ else if (errno != EINVAL)
+ {
+ printf ("mq_timedreceive with tv_nsec >= 1000000000 did not fail with "
+ "EINVAL: %m\n");
+ result = 1;
+ }
+
+ struct sigaction sa = { .sa_handler = alrm_handler, .sa_flags = 0 };
+ sigemptyset (&sa.sa_mask);
+ sigaction (SIGALRM, &sa, NULL);
+
+ struct itimerval it = { .it_value = { .tv_sec = 1 } };
+ setitimer (ITIMER_REAL, &it, NULL);
+
+ if (mq_receive (q, buf, 2, NULL) == 0)
+ {
+ puts ("mq_receive on empty queue did not block");
+ result = 1;
+ }
+ else if (errno != EINTR)
+ {
+ printf ("mq_receive on empty queue did not fail with EINTR: %m\n");
+ result = 1;
+ }
+
+ setitimer (ITIMER_REAL, &it, NULL);
+
+ ts.tv_nsec = 0;
+ if (mq_timedreceive (q, buf, 2, NULL, &ts) == 0)
+ {
+ puts ("mq_timedreceive on empty queue did not block");
+ result = 1;
+ }
+ else if (errno != EINTR)
+ {
+ printf ("mq_timedreceive on empty queue did not fail with EINTR: %m\n");
+ result = 1;
+ }
+
+ buf[0] = '6';
+ buf[1] = '7';
+ if (mq_send (q, buf, 2, 3) != 0
+ || (buf[0] = '8', mq_send (q, buf, 1, 4) != 0))
+ {
+ printf ("mq_send failed: %m\n");
+ result = 1;
+ }
+
+ memset (buf, ' ', sizeof (buf));
+
+ unsigned int prio;
+ ssize_t rets = mq_receive (q, buf, 3, &prio);
+ if (rets != 1)
+ {
+ if (rets == -1)
+ printf ("mq_receive failed: %m\n");
+ else
+ printf ("mq_receive returned %zd != 1\n", rets);
+ result = 1;
+ }
+ else if (prio != 4 || memcmp (buf, "8 ", 3) != 0)
+ {
+ printf ("mq_receive prio %u (4) buf \"%c%c%c\" (\"8 \")\n",
+ prio, buf[0], buf[1], buf[2]);
+ result = 1;
+ }
+
+ rets = mq_receive (q, buf, 2, NULL);
+ if (rets != 2)
+ {
+ if (rets == -1)
+ printf ("mq_receive failed: %m\n");
+ else
+ printf ("mq_receive returned %zd != 2\n", rets);
+ result = 1;
+ }
+ else if (memcmp (buf, "67 ", 3) != 0)
+ {
+ printf ("mq_receive buf \"%c%c%c\" != \"67 \"\n",
+ buf[0], buf[1], buf[2]);
+ result = 1;
+ }
+
+ buf[0] = '2';
+ buf[1] = '1';
+ if (clock_gettime (CLOCK_REALTIME, &ts) != 0)
+ ts.tv_sec = time (NULL);
+ ts.tv_nsec = -1000000001;
+ if ((mq_timedsend (q, buf, 2, 5, &ts) != 0
+ && (errno != EINVAL || mq_send (q, buf, 2, 5) != 0))
+ || (buf[0] = '3', ts.tv_nsec = -ts.tv_nsec,
+ (mq_timedsend (q, buf, 1, 4, &ts) != 0
+ && (errno != EINVAL || mq_send (q, buf, 1, 4) != 0))))
+ {
+ printf ("mq_timedsend failed: %m\n");
+ result = 1;
+ }
+
+ buf[0] = '-';
+ ts.tv_nsec = 1000000001;
+ if (mq_timedsend (q, buf, 1, 6, &ts) == 0)
+ {
+ puts ("mq_timedsend with tv_nsec >= 1000000000 did not fail");
+ result = 1;
+ }
+ else if (errno != EINVAL)
+ {
+ printf ("mq_timedsend with tv_nsec >= 1000000000 did not fail with "
+ "EINVAL: %m\n");
+ result = 1;
+ }
+
+ ts.tv_nsec = -2;
+ if (mq_timedsend (q, buf, 1, 6, &ts) == 0)
+ {
+ puts ("mq_timedsend with negative tv_nsec did not fail");
+ result = 1;
+ }
+ else if (errno != EINVAL)
+ {
+ printf ("mq_timedsend with megatove tv_nsec did not fail with "
+ "EINVAL: %m\n");
+ result = 1;
+ }
+
+ setitimer (ITIMER_REAL, &it, NULL);
+
+ if (mq_send (q, buf, 2, 8) == 0)
+ {
+ puts ("mq_send on full queue did not block");
+ result = 1;
+ }
+ else if (errno != EINTR)
+ {
+ printf ("mq_send on full queue did not fail with EINTR: %m\n");
+ result = 1;
+ }
+
+ setitimer (ITIMER_REAL, &it, NULL);
+
+ ts.tv_sec += 10;
+ ts.tv_nsec = 0;
+ if (mq_timedsend (q, buf, 2, 7, &ts) == 0)
+ {
+ puts ("mq_timedsend on full queue did not block");
+ result = 1;
+ }
+ else if (errno != EINTR)
+ {
+ printf ("mq_timedsend on full queue did not fail with EINTR: %m\n");
+ result = 1;
+ }
+
+ memset (buf, ' ', sizeof (buf));
+
+ if (clock_gettime (CLOCK_REALTIME, &ts) != 0)
+ ts.tv_sec = time (NULL);
+ ts.tv_nsec = -1000000001;
+ rets = mq_timedreceive (q, buf, 2, &prio, &ts);
+ if (rets == -1 && errno == EINVAL)
+ rets = mq_receive (q, buf, 2, &prio);
+ if (rets != 2)
+ {
+ if (rets == -1)
+ printf ("mq_timedreceive failed: %m\n");
+ else
+ printf ("mq_timedreceive returned %zd != 2\n", rets);
+ result = 1;
+ }
+ else if (prio != 5 || memcmp (buf, "21 ", 3) != 0)
+ {
+ printf ("mq_timedreceive prio %u (5) buf \"%c%c%c\" (\"21 \")\n",
+ prio, buf[0], buf[1], buf[2]);
+ result = 1;
+ }
+
+ if (mq_receive (q, buf, 1, NULL) == 0)
+ {
+ puts ("mq_receive with too small msg_len did not fail");
+ result = 1;
+ }
+ else if (errno != EMSGSIZE)
+ {
+ printf ("mq_receive with too small msg_len did not fail with "
+ "EMSGSIZE: %m\n");
+ result = 1;
+ }
+
+ ts.tv_nsec = -ts.tv_nsec;
+ rets = mq_timedreceive (q, buf, 2, NULL, &ts);
+ if (rets == -1 && errno == EINVAL)
+ rets = mq_receive (q, buf, 2, NULL);
+ if (rets != 1)
+ {
+ if (rets == -1)
+ printf ("mq_timedreceive failed: %m\n");
+ else
+ printf ("mq_timedreceive returned %zd != 1\n", rets);
+ result = 1;
+ }
+ else if (memcmp (buf, "31 ", 3) != 0)
+ {
+ printf ("mq_timedreceive buf \"%c%c%c\" != \"31 \"\n",
+ buf[0], buf[1], buf[2]);
+ result = 1;
+ }
+
+ if (mq_send (q, "", 0, 2) != 0)
+ {
+ printf ("mq_send with msg_len 0 failed: %m\n");
+ result = 1;
+ }
+
+ rets = mq_receive (q, buf, 2, &prio);
+ if (rets)
+ {
+ if (rets == -1)
+ printf ("mq_receive failed: %m\n");
+ else
+ printf ("mq_receive returned %zd != 0\n", rets);
+ result = 1;
+ }
+
+ long mq_prio_max = sysconf (_SC_MQ_PRIO_MAX);
+ if (mq_prio_max > 0 && (unsigned int) mq_prio_max == mq_prio_max)
+ {
+ if (mq_send (q, buf, 1, mq_prio_max) == 0)
+ {
+ puts ("mq_send with MQ_PRIO_MAX priority unpexpectedly succeeded");
+ result = 1;
+ }
+ else if (errno != EINVAL)
+ {
+ printf ("mq_send with MQ_PRIO_MAX priority did not fail with "
+ "EINVAL: %m\n");
+ result = 1;
+ }
+
+ if (mq_send (q, buf, 1, mq_prio_max - 1) != 0)
+ {
+ printf ("mq_send with MQ_PRIO_MAX-1 priority failed: %m\n");
+ result = 1;
+ }
+ }
+
+ if (mq_unlink (name) != 0)
+ {
+ printf ("mq_unlink failed: %m\n");
+ result = 1;
+ }
+
+ q2 = mq_open (name, O_RDWR);
+ if (q2 != (mqd_t) -1)
+ {
+ printf ("mq_open of unlinked %s without O_CREAT unexpectedly"
+ "succeeded\n", name);
+ result = 1;
+ }
+ else if (errno != ENOENT)
+ {
+ printf ("mq_open of unlinked %s without O_CREAT did not fail with "
+ "ENOENT: %m\n", name);
+ result = 1;
+ }
+
+ if (mq_close (q) != 0)
+ {
+ printf ("mq_close in parent failed: %m\n");
+ result = 1;
+ }
+
+ if (mq_receive (q, buf, 2, NULL) == 0)
+ {
+ puts ("mq_receive on invalid mqd_t did not fail");
+ result = 1;
+ }
+ else if (errno != EBADF)
+ {
+ printf ("mq_receive on invalid mqd_t did not fail with EBADF: %m\n");
+ result = 1;
+ }
+
+ if (mq_send (q, buf, 1, 2) == 0)
+ {
+ puts ("mq_send on invalid mqd_t did not fail");
+ result = 1;
+ }
+ else if (errno != EBADF)
+ {
+ printf ("mq_send on invalid mqd_t did not fail with EBADF: %m\n");
+ result = 1;
+ }
+
+ if (mq_getattr (q, &attr) == 0)
+ {
+ puts ("mq_getattr on invalid mqd_t did not fail");
+ result = 1;
+ }
+ else if (errno != EBADF)
+ {
+ printf ("mq_getattr on invalid mqd_t did not fail with EBADF: %m\n");
+ result = 1;
+ }
+
+ memset (&attr, 0, sizeof (attr));
+ if (mq_setattr (q, &attr, NULL) == 0)
+ {
+ puts ("mq_setattr on invalid mqd_t did not fail");
+ result = 1;
+ }
+ else if (errno != EBADF)
+ {
+ printf ("mq_setattr on invalid mqd_t did not fail with EBADF: %m\n");
+ result = 1;
+ }
+
+ if (mq_unlink ("/tst-mqueue2-which-should-never-exist") != -1)
+ {
+ puts ("mq_unlink of non-existant message queue unexpectedly succeeded");
+ result = 1;
+ }
+ else if (errno != ENOENT)
+ {
+ printf ("mq_unlink of non-existant message queue did not fail with "
+ "ENOENT: %m\n");
+ result = 1;
+ }
+ return result;
+}
+
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-mqueue3.c b/test/nptl/tst-mqueue3.c
new file mode 100644
index 000000000..5686f43f7
--- /dev/null
+++ b/test/nptl/tst-mqueue3.c
@@ -0,0 +1,243 @@
+/* Test SIGEV_THREAD handling for POSIX message queues.
+ Copyright (C) 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
+
+ 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 <mqueue.h>
+#include <signal.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+#if _POSIX_THREADS
+# include <pthread.h>
+
+static pid_t pid;
+static mqd_t m;
+static const char message[] = "hello";
+
+# define MAXMSG 10
+# define MSGSIZE 10
+# define UNIQUE 42
+
+
+static void
+fct (union sigval s)
+{
+ /* Put the mq in non-blocking mode. */
+ struct mq_attr attr;
+ if (mq_getattr (m, &attr) != 0)
+ {
+ printf ("%s: mq_getattr failed: %m\n", __FUNCTION__);
+ exit (1);
+ }
+ attr.mq_flags |= O_NONBLOCK;
+ if (mq_setattr (m, &attr, NULL) != 0)
+ {
+ printf ("%s: mq_setattr failed: %m\n", __FUNCTION__);
+ exit (1);
+ }
+
+ /* Check the values. */
+ if (attr.mq_maxmsg != MAXMSG)
+ {
+ printf ("%s: mq_maxmsg wrong: is %ld, expecte %d\n",
+ __FUNCTION__, attr.mq_maxmsg, MAXMSG);
+ exit (1);
+ }
+ if (attr.mq_msgsize != MAXMSG)
+ {
+ printf ("%s: mq_msgsize wrong: is %ld, expecte %d\n",
+ __FUNCTION__, attr.mq_msgsize, MSGSIZE);
+ exit (1);
+ }
+
+ /* Read the message. */
+ char buf[attr.mq_msgsize];
+ ssize_t n = TEMP_FAILURE_RETRY (mq_receive (m, buf, attr.mq_msgsize, NULL));
+ if (n != sizeof (message))
+ {
+ printf ("%s: length of message wrong: is %zd, expected %zu\n",
+ __FUNCTION__, n, sizeof (message));
+ exit (1);
+ }
+ if (memcmp (buf, message, sizeof (message)) != 0)
+ {
+ printf ("%s: message wrong: is \"%s\", expected \"%s\"\n",
+ __FUNCTION__, buf, message);
+ exit (1);
+ }
+
+ exit (UNIQUE);
+}
+
+
+int
+do_test (void)
+{
+ char tmpfname[] = "/tmp/tst-mqueue3-barrier.XXXXXX";
+ int fd = mkstemp (tmpfname);
+ if (fd == -1)
+ {
+ printf ("cannot open temporary file: %m\n");
+ return 1;
+ }
+
+ /* Make sure it is always removed. */
+ unlink (tmpfname);
+
+ /* Create one page of data. */
+ size_t ps = sysconf (_SC_PAGESIZE);
+ char data[ps];
+ memset (data, '\0', ps);
+
+ /* Write the data to the file. */
+ if (write (fd, data, ps) != (ssize_t) ps)
+ {
+ puts ("short write");
+ return 1;
+ }
+
+ void *mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ if (mem == MAP_FAILED)
+ {
+ printf ("mmap failed: %m\n");
+ return 1;
+ }
+
+ pthread_barrier_t *b;
+ b = (pthread_barrier_t *) (((uintptr_t) mem + __alignof (pthread_barrier_t))
+ & ~(__alignof (pthread_barrier_t) - 1));
+
+ pthread_barrierattr_t a;
+ if (pthread_barrierattr_init (&a) != 0)
+ {
+ puts ("barrierattr_init failed");
+ return 1;
+ }
+
+ if (pthread_barrierattr_setpshared (&a, PTHREAD_PROCESS_SHARED) != 0)
+ {
+ puts ("barrierattr_setpshared failed, could not test");
+ return 0;
+ }
+
+ if (pthread_barrier_init (b, &a, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ return 1;
+ }
+
+ if (pthread_barrierattr_destroy (&a) != 0)
+ {
+ puts ("barrierattr_destroy failed");
+ return 1;
+ }
+
+ /* Name for the message queue. */
+ char mqname[sizeof ("/tst-mqueue3-") + 3 * sizeof (pid_t)];
+ snprintf (mqname, sizeof (mqname) - 1, "/tst-mqueue3-%ld",
+ (long int) getpid ());
+
+ /* Create the message queue. */
+ struct mq_attr attr = { .mq_maxmsg = MAXMSG, .mq_msgsize = MSGSIZE };
+ m = mq_open (mqname, O_CREAT | O_EXCL | O_RDWR, 0600, &attr);
+ if (m == -1)
+ {
+ if (errno == ENOSYS)
+ {
+ puts ("not implemented");
+ return 0;
+ }
+
+ puts ("mq_open failed");
+ return 1;
+ }
+
+ /* Unlink the message queue right away. */
+ if (mq_unlink (mqname) != 0)
+ {
+ puts ("mq_unlink failed");
+ return 1;
+ }
+
+ pid = fork ();
+ if (pid == -1)
+ {
+ puts ("fork failed");
+ return 1;
+ }
+ if (pid == 0)
+ {
+ /* Request notification via thread. */
+ struct sigevent ev;
+ ev.sigev_notify = SIGEV_THREAD;
+ ev.sigev_notify_function = fct;
+ ev.sigev_value.sival_ptr = NULL;
+ ev.sigev_notify_attributes = NULL;
+
+ /* Tell the kernel. */
+ if (mq_notify (m,&ev) != 0)
+ {
+ puts ("mq_notify failed");
+ exit (1);
+ }
+
+ /* Tell the parent we are ready. */
+ (void) pthread_barrier_wait (b);
+
+ /* Make sure the process goes away eventually. */
+ alarm (10);
+
+ /* Do nothing forever. */
+ while (1)
+ pause ();
+ }
+
+ /* Wait for the child process to register to notification method. */
+ (void) pthread_barrier_wait (b);
+
+ /* Send the message. */
+ if (mq_send (m, message, sizeof (message), 1) != 0)
+ {
+ kill (pid, SIGKILL);
+ puts ("mq_send failed");
+ return 1;
+ }
+
+ int r;
+ if (TEMP_FAILURE_RETRY (waitpid (pid, &r, 0)) != pid)
+ {
+ kill (pid, SIGKILL);
+ puts ("waitpid failed");
+ return 1;
+ }
+
+ return WIFEXITED (r) && WEXITSTATUS (r) == UNIQUE ? 0 : 1;
+}
+# define TEST_FUNCTION do_test ()
+#else
+# define TEST_FUNCTION 0
+#endif
+
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-mqueue4.c b/test/nptl/tst-mqueue4.c
new file mode 100644
index 000000000..87ef0c3c0
--- /dev/null
+++ b/test/nptl/tst-mqueue4.c
@@ -0,0 +1,287 @@
+/* Test message queue passing.
+ Copyright (C) 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
+
+ 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 <fcntl.h>
+#include <mqueue.h>
+#include <limits.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+#include <sys/wait.h>
+#include <time.h>
+#include <unistd.h>
+#include "tst-mqueue.h"
+
+#define TIMEOUT 4
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+ int result = 0;
+
+ char name[sizeof "/tst-mqueue4-" + sizeof (pid_t) * 3 + NAME_MAX];
+ char *p;
+ p = name + snprintf (name, sizeof (name), "/tst-mqueue4-%u", getpid ());
+ struct mq_attr attr = { .mq_maxmsg = 2, .mq_msgsize = 2 };
+ mqd_t q = mq_open (name, O_CREAT | O_EXCL | O_RDWR, 0600, &attr);
+
+ if (q == (mqd_t) -1)
+ {
+ printf ("mq_open failed with: %m\n");
+ return result;
+ }
+ else
+ add_temp_mq (name);
+
+ *p = '.';
+ memset (p + 1, 'x', NAME_MAX + 1 - (p - name));
+ name[NAME_MAX + 1] = '\0';
+
+ mqd_t q2 = mq_open (name, O_CREAT | O_EXCL | O_RDWR, 0600, &attr);
+ if (q2 == (mqd_t) -1)
+ {
+ printf ("mq_open with NAME_MAX long name compoment failed with: %m\n");
+ result = 1;
+ }
+
+ if (mq_unlink (name) != 0)
+ {
+ printf ("mq_unlink failed: %m\n");
+ result = 1;
+ }
+
+ if (mq_close (q2) != 0)
+ {
+ printf ("mq_close failed: %m\n");
+ result = 1;
+ }
+
+ name[NAME_MAX + 1] = 'x';
+ name[NAME_MAX + 2] = '\0';
+ q2 = mq_open (name, O_CREAT | O_EXCL | O_RDWR, 0600, &attr);
+ if (q2 != (mqd_t) -1)
+ {
+ puts ("mq_open with too long name component unexpectedly succeeded");
+ mq_unlink (name);
+ mq_close (q2);
+ result = 1;
+ }
+ else if (errno != ENAMETOOLONG)
+ {
+ printf ("mq_open with too long name component did not fail with "
+ "ENAMETOOLONG: %m\n");
+ result = 1;
+ }
+
+ if (mq_unlink (name) == 0)
+ {
+ puts ("mq_unlink with too long name component unexpectedly succeeded");
+ result = 1;
+ }
+ else if (errno != ENAMETOOLONG)
+ {
+ printf ("mq_unlink with too long name component did not fail with "
+ "ENAMETOOLONG: %m\n");
+ result = 1;
+ }
+
+ *p = '\0';
+ attr.mq_maxmsg = 1;
+ attr.mq_msgsize = 3;
+ q2 = mq_open (name, O_CREAT | O_RDWR, 0600, &attr);
+ if (q2 == (mqd_t) -1)
+ {
+ printf ("mq_open without O_EXCL failed with %m\n");
+ result = 1;
+ }
+
+ char buf[3];
+ strcpy (buf, "jk");
+ if (mq_send (q, buf, 2, 4) != 0)
+ {
+ printf ("mq_send failed: %m\n");
+ result = 1;
+ }
+
+ if (mq_send (q, buf + 1, 1, 5) != 0)
+ {
+ printf ("mq_send failed: %m\n");
+ result = 1;
+ }
+
+ if (mq_getattr (q2, &attr) != 0)
+ {
+ printf ("mq_getattr failed: %m\n");
+ result = 1;
+ }
+
+ if ((attr.mq_flags & O_NONBLOCK)
+ || attr.mq_maxmsg != 2
+ || attr.mq_msgsize != 2
+ || attr.mq_curmsgs != 2)
+ {
+ printf ("mq_getattr returned unexpected { .mq_flags = %ld,\n"
+ ".mq_maxmsg = %ld, .mq_msgsize = %ld, .mq_curmsgs = %ld }\n",
+ attr.mq_flags, attr.mq_maxmsg, attr.mq_msgsize, attr.mq_curmsgs);
+ result = 1;
+ }
+
+ struct timespec ts;
+ if (clock_gettime (CLOCK_REALTIME, &ts) == 0)
+ ++ts.tv_sec;
+ else
+ {
+ ts.tv_sec = time (NULL) + 1;
+ ts.tv_nsec = 0;
+ }
+
+ if (mq_timedsend (q2, buf, 1, 1, &ts) == 0)
+ {
+ puts ("mq_timedsend unexpectedly succeeded");
+ result = 1;
+ }
+ else if (errno != ETIMEDOUT)
+ {
+ printf ("mq_timedsend did not fail with ETIMEDOUT: %m\n");
+ result = 1;
+ }
+
+ if (mq_close (q2) != 0)
+ {
+ printf ("mq_close failed: %m\n");
+ result = 1;
+ }
+
+ q2 = mq_open (name, O_RDONLY, 0600);
+ if (q2 == (mqd_t) -1)
+ {
+ printf ("mq_open without O_CREAT failed with %m\n");
+ result = 1;
+ }
+
+ mqd_t q3 = mq_open (name, O_RDONLY, 0600);
+ if (q3 == (mqd_t) -1)
+ {
+ printf ("mq_open without O_CREAT failed with %m\n");
+ result = 1;
+ }
+
+ memset (buf, ' ', sizeof (buf));
+
+ unsigned int prio;
+ ssize_t rets = mq_receive (q2, buf, 2, &prio);
+ if (rets != 1)
+ {
+ if (rets == -1)
+ printf ("mq_receive failed with: %m\n");
+ else
+ printf ("mq_receive returned %zd != 1\n", rets);
+ result = 1;
+ }
+ else if (prio != 5 || memcmp (buf, "k ", 3) != 0)
+ {
+ printf ("mq_receive returned prio %u (2) buf \"%c%c%c\" (\"k \")\n",
+ prio, buf[0], buf[1], buf[2]);
+ result = 1;
+ }
+
+ if (mq_getattr (q3, &attr) != 0)
+ {
+ printf ("mq_getattr failed: %m\n");
+ result = 1;
+ }
+
+ if ((attr.mq_flags & O_NONBLOCK)
+ || attr.mq_maxmsg != 2
+ || attr.mq_msgsize != 2
+ || attr.mq_curmsgs != 1)
+ {
+ printf ("mq_getattr returned unexpected { .mq_flags = %ld,\n"
+ ".mq_maxmsg = %ld, .mq_msgsize = %ld, .mq_curmsgs = %ld }\n",
+ attr.mq_flags, attr.mq_maxmsg, attr.mq_msgsize, attr.mq_curmsgs);
+ result = 1;
+ }
+
+ rets = mq_receive (q3, buf, 2, NULL);
+ if (rets != 2)
+ {
+ if (rets == -1)
+ printf ("mq_receive failed with: %m\n");
+ else
+ printf ("mq_receive returned %zd != 2\n", rets);
+ result = 1;
+ }
+ else if (memcmp (buf, "jk ", 3) != 0)
+ {
+ printf ("mq_receive returned buf \"%c%c%c\" != \"jk \"\n",
+ buf[0], buf[1], buf[2]);
+ result = 1;
+ }
+
+ if (clock_gettime (CLOCK_REALTIME, &ts) == 0)
+ ++ts.tv_sec;
+ else
+ {
+ ts.tv_sec = time (NULL) + 1;
+ ts.tv_nsec = 0;
+ }
+
+ if (mq_timedreceive (q2, buf, 2, NULL, &ts) != -1)
+ {
+ puts ("mq_timedreceive on empty queue unexpectedly succeeded");
+ result = 1;
+ }
+ else if (errno != ETIMEDOUT)
+ {
+ printf ("mq_timedreceive on empty queue did not fail with "
+ "ETIMEDOUT: %m\n");
+ result = 1;
+ }
+
+ if (mq_unlink (name) != 0)
+ {
+ printf ("mq_unlink failed: %m\n");
+ result = 1;
+ }
+
+ if (mq_close (q) != 0)
+ {
+ printf ("mq_close failed: %m\n");
+ result = 1;
+ }
+
+ if (mq_close (q2) != 0)
+ {
+ printf ("mq_close failed: %m\n");
+ result = 1;
+ }
+
+ if (mq_close (q3) != 0)
+ {
+ printf ("mq_close failed: %m\n");
+ result = 1;
+ }
+
+ return result;
+}
+
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-mqueue5.c b/test/nptl/tst-mqueue5.c
new file mode 100644
index 000000000..58e2ebfb4
--- /dev/null
+++ b/test/nptl/tst-mqueue5.c
@@ -0,0 +1,1013 @@
+/* Test mq_notify.
+ Copyright (C) 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
+
+ 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 <fcntl.h>
+#include <mqueue.h>
+#include <limits.h>
+#include <signal.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/time.h>
+#include <sys/wait.h>
+#include <time.h>
+#include <unistd.h>
+#include "tst-mqueue.h"
+
+#define TIMEOUT 3
+
+#if _POSIX_THREADS
+# include <pthread.h>
+
+volatile int rtmin_cnt;
+volatile pid_t rtmin_pid;
+volatile uid_t rtmin_uid;
+volatile int rtmin_code;
+volatile union sigval rtmin_sigval;
+
+static void
+rtmin_handler (int sig, siginfo_t *info, void *ctx)
+{
+ if (sig != SIGRTMIN)
+ abort ();
+ ++rtmin_cnt;
+ rtmin_pid = info->si_pid;
+ rtmin_uid = info->si_uid;
+ rtmin_code = info->si_code;
+ rtmin_sigval = info->si_value;
+}
+
+#define mqsend(q) (mqsend) (q, __LINE__)
+static int
+(mqsend) (mqd_t q, int line)
+{
+ char c;
+ if (mq_send (q, &c, 1, 1) != 0)
+ {
+ printf ("mq_send on line %d failed with: %m\n", line);
+ return 1;
+ }
+ return 0;
+}
+
+#define mqrecv(q) (mqrecv) (q, __LINE__)
+static int
+(mqrecv) (mqd_t q, int line)
+{
+ char c;
+ ssize_t rets = TEMP_FAILURE_RETRY (mq_receive (q, &c, 1, NULL));
+ if (rets != 1)
+ {
+ if (rets == -1)
+ printf ("mq_receive on line %d failed with: %m\n", line);
+ else
+ printf ("mq_receive on line %d returned %zd != 1\n",
+ line, rets);
+ return 1;
+ }
+ return 0;
+}
+
+struct thr_data
+{
+ const char *name;
+ pthread_barrier_t *b3;
+ mqd_t q;
+};
+
+static void *
+thr (void *arg)
+{
+ pthread_barrier_t *b3 = ((struct thr_data *)arg)->b3;
+ mqd_t q = ((struct thr_data *)arg)->q;
+ const char *name = ((struct thr_data *)arg)->name;
+ int result = 0;
+
+ result |= mqrecv (q);
+
+ (void) pthread_barrier_wait (b3);
+
+ /* Child verifies SIGRTMIN has not been sent. */
+
+ (void) pthread_barrier_wait (b3);
+
+ /* Parent calls mqsend (q), which should trigger notification. */
+
+ (void) pthread_barrier_wait (b3);
+
+ if (rtmin_cnt != 2)
+ {
+ puts ("SIGRTMIN signal in child did not arrive");
+ result = 1;
+ }
+ else if (rtmin_pid != getppid ()
+ || rtmin_uid != getuid ()
+ || rtmin_code != SI_MESGQ
+ || rtmin_sigval.sival_int != 0xdeadbeef)
+ {
+ printf ("unexpected siginfo_t fields: pid %u (%u), uid %u (%u), code %d (%d), si_int %d (%d)\n",
+ rtmin_pid, getppid (), rtmin_uid, getuid (),
+ rtmin_code, SI_MESGQ, rtmin_sigval.sival_int, 0xdeadbeef);
+ result = 1;
+ }
+
+ struct sigevent ev;
+ memset (&ev, 0x82, sizeof (ev));
+ ev.sigev_notify = SIGEV_NONE;
+ if (mq_notify (q, &ev) != 0)
+ {
+ printf ("mq_notify in thread (q, { SIGEV_NONE }) failed with: %m\n");
+ result = 1;
+ }
+
+ if (mq_notify (q, NULL) != 0)
+ {
+ printf ("mq_notify in thread (q, NULL) failed with: %m\n");
+ result = 1;
+ }
+
+ result |= mqrecv (q);
+
+ (void) pthread_barrier_wait (b3);
+
+ /* Child calls mq_notify (q, { SIGEV_SIGNAL }). */
+
+ (void) pthread_barrier_wait (b3);
+
+ if (mq_notify (q, NULL) != 0)
+ {
+ printf ("second mq_notify in thread (q, NULL) failed with: %m\n");
+ result = 1;
+ }
+
+ (void) pthread_barrier_wait (b3);
+
+ /* Parent calls mqsend (q), which should not trigger notification. */
+
+ (void) pthread_barrier_wait (b3);
+
+ /* Child verifies SIGRTMIN has not been received. */
+ /* Child calls mq_notify (q, { SIGEV_SIGNAL }). */
+
+ (void) pthread_barrier_wait (b3);
+
+ mqd_t q4 = mq_open (name, O_RDONLY);
+ if (q4 == (mqd_t) -1)
+ {
+ printf ("mq_open in thread failed with: %m\n");
+ result = 1;
+ }
+
+ if (mq_notify (q4, NULL) != 0)
+ {
+ printf ("mq_notify in thread (q4, NULL) failed with: %m\n");
+ result = 1;
+ }
+
+ if (mq_close (q4) != 0)
+ {
+ printf ("mq_close in thread failed with: %m\n");
+ result = 1;
+ }
+
+ (void) pthread_barrier_wait (b3);
+
+ /* Parent calls mqsend (q), which should not trigger notification. */
+
+ (void) pthread_barrier_wait (b3);
+
+ /* Child verifies SIGRTMIN has not been received. */
+ /* Child calls mq_notify (q, { SIGEV_SIGNAL }). */
+
+ (void) pthread_barrier_wait (b3);
+
+ mqd_t q5 = mq_open (name, O_WRONLY);
+ if (q5 == (mqd_t) -1)
+ {
+ printf ("mq_open O_WRONLY in thread failed with: %m\n");
+ result = 1;
+ }
+
+ if (mq_notify (q5, NULL) != 0)
+ {
+ printf ("mq_notify in thread (q5, NULL) failed with: %m\n");
+ result = 1;
+ }
+
+ if (mq_close (q5) != 0)
+ {
+ printf ("mq_close in thread failed with: %m\n");
+ result = 1;
+ }
+
+ (void) pthread_barrier_wait (b3);
+
+ /* Parent calls mqsend (q), which should not trigger notification. */
+
+ (void) pthread_barrier_wait (b3);
+
+ /* Child verifies SIGRTMIN has not been received. */
+
+ return (void *) (long) result;
+}
+
+static void
+do_child (const char *name, pthread_barrier_t *b2, pthread_barrier_t *b3,
+ mqd_t q)
+{
+ int result = 0;
+
+ struct sigevent ev;
+ memset (&ev, 0x55, sizeof (ev));
+ ev.sigev_notify = SIGEV_SIGNAL;
+ ev.sigev_signo = SIGRTMIN;
+ ev.sigev_value.sival_ptr = &ev;
+ if (mq_notify (q, &ev) == 0)
+ {
+ puts ("first mq_notify in child (q, { SIGEV_SIGNAL }) unexpectedly succeeded");
+ result = 1;
+ }
+ else if (errno != EBUSY)
+ {
+ printf ("first mq_notify in child (q, { SIGEV_SIGNAL }) failed with: %m\n");
+ result = 1;
+ }
+
+ (void) pthread_barrier_wait (b2);
+
+ /* Parent calls mqsend (q), which makes notification available. */
+
+ (void) pthread_barrier_wait (b2);
+
+ rtmin_cnt = 0;
+
+ if (mq_notify (q, &ev) != 0)
+ {
+ printf ("second mq_notify in child (q, { SIGEV_SIGNAL }) failed with: %m\n");
+ result = 1;
+ }
+
+ if (rtmin_cnt != 0)
+ {
+ puts ("SIGRTMIN signal in child caught too early");
+ result = 1;
+ }
+
+ (void) pthread_barrier_wait (b2);
+
+ /* Parent unsuccessfully attempts to mq_notify. */
+ /* Parent calls mqsend (q), which makes notification available
+ and triggers a signal in the child. */
+ /* Parent successfully calls mq_notify SIGEV_SIGNAL. */
+
+ (void) pthread_barrier_wait (b2);
+
+ if (rtmin_cnt != 1)
+ {
+ puts ("SIGRTMIN signal in child did not arrive");
+ result = 1;
+ }
+ else if (rtmin_pid != getppid ()
+ || rtmin_uid != getuid ()
+ || rtmin_code != SI_MESGQ
+ || rtmin_sigval.sival_ptr != &ev)
+ {
+ printf ("unexpected siginfo_t fields: pid %u (%u), uid %u (%u), code %d (%d), si_ptr %p (%p)\n",
+ rtmin_pid, getppid (), rtmin_uid, getuid (),
+ rtmin_code, SI_MESGQ, rtmin_sigval.sival_ptr, &ev);
+ result = 1;
+ }
+
+ result |= mqsend (q);
+
+ (void) pthread_barrier_wait (b2);
+
+ /* Parent verifies caught SIGRTMIN. */
+
+ mqd_t q2 = mq_open (name, O_RDWR);
+ if (q2 == (mqd_t) -1)
+ {
+ printf ("mq_open in child failed with: %m\n");
+ result = 1;
+ }
+
+ (void) pthread_barrier_wait (b2);
+
+ /* Parent mq_open's another mqd_t for the same queue (q3). */
+
+ memset (&ev, 0x11, sizeof (ev));
+ ev.sigev_notify = SIGEV_SIGNAL;
+ ev.sigev_signo = SIGRTMIN;
+ ev.sigev_value.sival_ptr = &ev;
+ if (mq_notify (q2, &ev) != 0)
+ {
+ printf ("mq_notify in child (q2, { SIGEV_SIGNAL }) failed with: %m\n");
+ result = 1;
+ }
+
+ (void) pthread_barrier_wait (b2);
+
+ /* Parent unsuccessfully attempts to mq_notify { SIGEV_NONE } on q. */
+
+ (void) pthread_barrier_wait (b2);
+
+ if (mq_close (q2) != 0)
+ {
+ printf ("mq_close failed: %m\n");
+ result = 1;
+ }
+
+ (void) pthread_barrier_wait (b2);
+
+ /* Parent successfully calls mq_notify { SIGEV_NONE } on q3. */
+
+ (void) pthread_barrier_wait (b2);
+
+ memset (&ev, 0xbb, sizeof (ev));
+ ev.sigev_notify = SIGEV_SIGNAL;
+ ev.sigev_signo = SIGRTMIN;
+ ev.sigev_value.sival_ptr = &b2;
+ if (mq_notify (q, &ev) == 0)
+ {
+ puts ("third mq_notify in child (q, { SIGEV_SIGNAL }) unexpectedly succeeded");
+ result = 1;
+ }
+ else if (errno != EBUSY)
+ {
+ printf ("third mq_notify in child (q, { SIGEV_SIGNAL }) failed with: %m\n");
+ result = 1;
+ }
+
+ (void) pthread_barrier_wait (b2);
+
+ /* Parent calls mq_close on q3, which makes the queue available again for
+ notification. */
+
+ (void) pthread_barrier_wait (b2);
+
+ memset (&ev, 0x13, sizeof (ev));
+ ev.sigev_notify = SIGEV_NONE;
+ if (mq_notify (q, &ev) != 0)
+ {
+ printf ("mq_notify in child (q, { SIGEV_NONE }) failed with: %m\n");
+ result = 1;
+ }
+
+ if (mq_notify (q, NULL) != 0)
+ {
+ printf ("mq_notify in child (q, NULL) failed with: %m\n");
+ result = 1;
+ }
+
+ (void) pthread_barrier_wait (b2);
+
+ struct thr_data thr_data = { .name = name, .b3 = b3, .q = q };
+ pthread_t th;
+ int ret = pthread_create (&th, NULL, thr, &thr_data);
+ if (ret)
+ {
+ errno = ret;
+ printf ("pthread_created failed with: %m\n");
+ result = 1;
+ }
+
+ /* Wait till thr calls mq_receive on the empty queue q and blocks on it. */
+ sleep (1);
+
+ memset (&ev, 0x5f, sizeof (ev));
+ ev.sigev_notify = SIGEV_SIGNAL;
+ ev.sigev_signo = SIGRTMIN;
+ ev.sigev_value.sival_int = 0xdeadbeef;
+ if (mq_notify (q, &ev) != 0)
+ {
+ printf ("fourth mq_notify in child (q, { SIGEV_SIGNAL }) failed with: %m\n");
+ result = 1;
+ }
+
+ (void) pthread_barrier_wait (b2);
+
+ /* Parent calls mqsend (q), which should wake up mqrecv (q)
+ in the thread but no notification should be sent. */
+
+ (void) pthread_barrier_wait (b3);
+
+ if (rtmin_cnt != 1)
+ {
+ puts ("SIGRTMIN signal caught while thr was blocked on mq_receive");
+ result = 1;
+ }
+
+ (void) pthread_barrier_wait (b3);
+
+ /* Parent calls mqsend (q), which should trigger notification. */
+
+ (void) pthread_barrier_wait (b3);
+
+ /* Thread verifies SIGRTMIN has been received. */
+ /* Thread calls mq_notify (q, { SIGEV_NONE }) to verify notification is now
+ available for registration. */
+ /* Thread calls mq_notify (q, NULL). */
+
+ (void) pthread_barrier_wait (b3);
+
+ memset (&ev, 0x6a, sizeof (ev));
+ ev.sigev_notify = SIGEV_SIGNAL;
+ ev.sigev_signo = SIGRTMIN;
+ ev.sigev_value.sival_ptr = do_child;
+ if (mq_notify (q, &ev) != 0)
+ {
+ printf ("fifth mq_notify in child (q, { SIGEV_SIGNAL }) failed with: %m\n");
+ result = 1;
+ }
+
+ (void) pthread_barrier_wait (b3);
+
+ /* Thread calls mq_notify (q, NULL), which should unregister the above
+ notification. */
+
+ (void) pthread_barrier_wait (b3);
+
+ /* Parent calls mqsend (q), which should not trigger notification. */
+
+ (void) pthread_barrier_wait (b3);
+
+ if (rtmin_cnt != 2)
+ {
+ puts ("SIGRTMIN signal caught while notification has been disabled");
+ result = 1;
+ }
+
+ memset (&ev, 0x7b, sizeof (ev));
+ ev.sigev_notify = SIGEV_SIGNAL;
+ ev.sigev_signo = SIGRTMIN;
+ ev.sigev_value.sival_ptr = thr;
+ if (mq_notify (q, &ev) != 0)
+ {
+ printf ("sixth mq_notify in child (q, { SIGEV_SIGNAL }) failed with: %m\n");
+ result = 1;
+ }
+
+ (void) pthread_barrier_wait (b3);
+
+ /* Thread opens a new O_RDONLY mqd_t (q4). */
+ /* Thread calls mq_notify (q4, NULL), which should unregister the above
+ notification. */
+ /* Thread calls mq_close (q4). */
+
+ (void) pthread_barrier_wait (b3);
+
+ /* Parent calls mqsend (q), which should not trigger notification. */
+
+ (void) pthread_barrier_wait (b3);
+
+ if (rtmin_cnt != 2)
+ {
+ puts ("SIGRTMIN signal caught while notification has been disabled");
+ result = 1;
+ }
+
+ memset (&ev, 0xe1, sizeof (ev));
+ ev.sigev_notify = SIGEV_SIGNAL;
+ ev.sigev_signo = SIGRTMIN;
+ ev.sigev_value.sival_int = 127;
+ if (mq_notify (q, &ev) != 0)
+ {
+ printf ("seventh mq_notify in child (q, { SIGEV_SIGNAL }) failed with: %m\n");
+ result = 1;
+ }
+
+ (void) pthread_barrier_wait (b3);
+
+ /* Thread opens a new O_WRONLY mqd_t (q5). */
+ /* Thread calls mq_notify (q5, NULL), which should unregister the above
+ notification. */
+ /* Thread calls mq_close (q5). */
+
+ (void) pthread_barrier_wait (b3);
+
+ /* Parent calls mqsend (q), which should not trigger notification. */
+
+ (void) pthread_barrier_wait (b3);
+
+ if (rtmin_cnt != 2)
+ {
+ puts ("SIGRTMIN signal caught while notification has been disabled");
+ result = 1;
+ }
+
+ void *thr_ret;
+ ret = pthread_join (th, &thr_ret);
+ if (ret)
+ {
+ errno = ret;
+ printf ("pthread_join failed: %m\n");
+ result = 1;
+ }
+ else if (thr_ret)
+ result = 1;
+
+ if (mq_close (q) != 0)
+ {
+ printf ("mq_close failed: %m\n");
+ result = 1;
+ }
+
+ exit (result);
+}
+
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+ int result = 0;
+
+ char tmpfname[] = "/tmp/tst-mqueue5-barrier.XXXXXX";
+ int fd = mkstemp (tmpfname);
+ if (fd == -1)
+ {
+ printf ("cannot open temporary file: %m\n");
+ return 1;
+ }
+
+ /* Make sure it is always removed. */
+ unlink (tmpfname);
+
+ /* Create one page of data. */
+ size_t ps = sysconf (_SC_PAGESIZE);
+ char data[ps];
+ memset (data, '\0', ps);
+
+ /* Write the data to the file. */
+ if (write (fd, data, ps) != (ssize_t) ps)
+ {
+ puts ("short write");
+ return 1;
+ }
+
+ void *mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ if (mem == MAP_FAILED)
+ {
+ printf ("mmap failed: %m\n");
+ return 1;
+ }
+
+ pthread_barrier_t *b2;
+ b2 = (pthread_barrier_t *) (((uintptr_t) mem + __alignof (pthread_barrier_t))
+ & ~(__alignof (pthread_barrier_t) - 1));
+
+ pthread_barrier_t *b3;
+ b3 = b2 + 1;
+
+ pthread_barrierattr_t a;
+ if (pthread_barrierattr_init (&a) != 0)
+ {
+ puts ("barrierattr_init failed");
+ return 1;
+ }
+
+ if (pthread_barrierattr_setpshared (&a, PTHREAD_PROCESS_SHARED) != 0)
+ {
+ puts ("barrierattr_setpshared failed, could not test");
+ return 0;
+ }
+
+ if (pthread_barrier_init (b2, &a, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ return 1;
+ }
+
+ if (pthread_barrier_init (b3, &a, 3) != 0)
+ {
+ puts ("barrier_init failed");
+ return 1;
+ }
+
+ if (pthread_barrierattr_destroy (&a) != 0)
+ {
+ puts ("barrierattr_destroy failed");
+ return 1;
+ }
+
+ char name[sizeof "/tst-mqueue5-" + sizeof (pid_t) * 3];
+ snprintf (name, sizeof (name), "/tst-mqueue5-%u", getpid ());
+
+ struct mq_attr attr = { .mq_maxmsg = 1, .mq_msgsize = 1 };
+ mqd_t q = mq_open (name, O_CREAT | O_EXCL | O_RDWR, 0600, &attr);
+
+ if (q == (mqd_t) -1)
+ {
+ printf ("mq_open failed with: %m\n");
+ return result;
+ }
+ else
+ add_temp_mq (name);
+
+ struct sigevent ev;
+ memset (&ev, 0xaa, sizeof (ev));
+ ev.sigev_notify = SIGEV_NONE;
+ if (mq_notify (q, &ev) != 0)
+ {
+ printf ("mq_notify (q, { SIGEV_NONE }) failed with: %m\n");
+ result = 1;
+ }
+
+ if (mq_notify (q, &ev) == 0)
+ {
+ puts ("second mq_notify (q, { SIGEV_NONE }) unexpectedly succeeded");
+ result = 1;
+ }
+ else if (errno != EBUSY)
+ {
+ printf ("second mq_notify (q, { SIGEV_NONE }) failed with: %m\n");
+ result = 1;
+ }
+
+ result |= mqsend (q);
+
+ if (mq_notify (q, &ev) != 0)
+ {
+ printf ("third mq_notify (q, { SIGEV_NONE }) failed with: %m\n");
+ result = 1;
+ }
+
+ result |= mqrecv (q);
+
+ if (mq_notify (q, NULL) != 0)
+ {
+ printf ("mq_notify (q, NULL) failed with: %m\n");
+ result = 1;
+ }
+
+ if (mq_notify (q, NULL) != 0)
+ {
+ /* Implementation-defined behaviour, so don't fail,
+ just inform. */
+ printf ("second mq_notify (q, NULL) failed with: %m\n");
+ }
+
+ struct sigaction sa = { .sa_sigaction = rtmin_handler,
+ .sa_flags = SA_SIGINFO };
+ sigemptyset (&sa.sa_mask);
+ sigaction (SIGRTMIN, &sa, NULL);
+
+ memset (&ev, 0x55, sizeof (ev));
+ ev.sigev_notify = SIGEV_SIGNAL;
+ ev.sigev_signo = SIGRTMIN;
+ ev.sigev_value.sival_int = 26;
+ if (mq_notify (q, &ev) != 0)
+ {
+ printf ("mq_notify (q, { SIGEV_SIGNAL }) failed with: %m\n");
+ result = 1;
+ }
+
+ ev.sigev_value.sival_ptr = &ev;
+ if (mq_notify (q, &ev) == 0)
+ {
+ puts ("second mq_notify (q, { SIGEV_SIGNAL }) unexpectedly succeeded");
+ result = 1;
+ }
+ else if (errno != EBUSY)
+ {
+ printf ("second mq_notify (q, { SIGEV_SIGNAL }) failed with: %m\n");
+ result = 1;
+ }
+
+ if (rtmin_cnt != 0)
+ {
+ puts ("SIGRTMIN signal caught too early");
+ result = 1;
+ }
+
+ result |= mqsend (q);
+
+ if (rtmin_cnt != 1)
+ {
+ puts ("SIGRTMIN signal did not arrive");
+ result = 1;
+ }
+ else if (rtmin_pid != getpid ()
+ || rtmin_uid != getuid ()
+ || rtmin_code != SI_MESGQ
+ || rtmin_sigval.sival_int != 26)
+ {
+ printf ("unexpected siginfo_t fields: pid %u (%u), uid %u (%u), code %d (%d), si_int %d (26)\n",
+ rtmin_pid, getpid (), rtmin_uid, getuid (),
+ rtmin_code, SI_MESGQ, rtmin_sigval.sival_int);
+ result = 1;
+ }
+
+ ev.sigev_value.sival_int = 75;
+ if (mq_notify (q, &ev) != 0)
+ {
+ printf ("third mq_notify (q, { SIGEV_SIGNAL }) failed with: %m\n");
+ result = 1;
+ }
+
+ result |= mqrecv (q);
+
+ if (mq_notify (q, NULL) != 0)
+ {
+ printf ("mq_notify (q, NULL) failed with: %m\n");
+ result = 1;
+ }
+
+ memset (&ev, 0x33, sizeof (ev));
+ ev.sigev_notify = SIGEV_NONE;
+ if (mq_notify (q, &ev) != 0)
+ {
+ printf ("fourth mq_notify (q, { SIGEV_NONE }) failed with: %m\n");
+ result = 1;
+ }
+
+ pid_t pid = fork ();
+ if (pid == -1)
+ {
+ printf ("fork () failed: %m\n");
+ mq_unlink (name);
+ return 1;
+ }
+
+ if (pid == 0)
+ do_child (name, b2, b3, q);
+
+ /* Child unsuccessfully attempts to mq_notify. */
+
+ (void) pthread_barrier_wait (b2);
+
+ result |= mqsend (q);
+
+ (void) pthread_barrier_wait (b2);
+
+ /* Child successfully calls mq_notify SIGEV_SIGNAL now. */
+
+ result |= mqrecv (q);
+
+ (void) pthread_barrier_wait (b2);
+
+ memset (&ev, 0xbb, sizeof (ev));
+ ev.sigev_notify = SIGEV_SIGNAL;
+ ev.sigev_signo = SIGRTMIN;
+ ev.sigev_value.sival_int = 15;
+ if (mq_notify (q, &ev) == 0)
+ {
+ puts ("fourth mq_notify (q, { SIGEV_SIGNAL }) unexpectedly succeeded");
+ result = 1;
+ }
+ else if (errno != EBUSY)
+ {
+ printf ("fourth mq_notify (q, { SIGEV_SIGNAL }) failed with: %m\n");
+ result = 1;
+ }
+
+ result |= mqsend (q);
+
+ if (mq_notify (q, &ev) != 0)
+ {
+ printf ("fifth mq_notify (q, { SIGEV_SIGNAL }) failed with: %m\n");
+ result = 1;
+ }
+
+ if (rtmin_cnt != 1)
+ {
+ puts ("SIGRTMIN signal caught too early");
+ result = 1;
+ }
+
+ result |= mqrecv (q);
+
+ (void) pthread_barrier_wait (b2);
+
+ /* Child verifies caught SIGRTMIN signal. */
+ /* Child calls mq_send (q) which triggers SIGRTMIN signal here. */
+
+ (void) pthread_barrier_wait (b2);
+
+ /* Child mq_open's another mqd_t for the same queue (q2). */
+
+ if (rtmin_cnt != 2)
+ {
+ puts ("SIGRTMIN signal did not arrive");
+ result = 1;
+ }
+ else if (rtmin_pid != pid
+ || rtmin_uid != getuid ()
+ || rtmin_code != SI_MESGQ
+ || rtmin_sigval.sival_int != 15)
+ {
+ printf ("unexpected siginfo_t fields: pid %u (%u), uid %u (%u), code %d (%d), si_int %d (15)\n",
+ rtmin_pid, pid, rtmin_uid, getuid (),
+ rtmin_code, SI_MESGQ, rtmin_sigval.sival_int);
+ result = 1;
+ }
+
+ result |= mqrecv (q);
+
+ (void) pthread_barrier_wait (b2);
+
+ /* Child successfully calls mq_notify { SIGEV_SIGNAL } on q2. */
+
+ (void) pthread_barrier_wait (b2);
+
+ memset (&ev, 0xbb, sizeof (ev));
+ ev.sigev_notify = SIGEV_NONE;
+ if (mq_notify (q, &ev) == 0)
+ {
+ puts ("fifth mq_notify (q, { SIGEV_NONE }) unexpectedly succeeded");
+ result = 1;
+ }
+ else if (errno != EBUSY)
+ {
+ printf ("fifth mq_notify (q, { SIGEV_NONE }) failed with: %m\n");
+ result = 1;
+ }
+
+ (void) pthread_barrier_wait (b2);
+
+ /* Child calls mq_close on q2, which makes the queue available again for
+ notification. */
+
+ mqd_t q3 = mq_open (name, O_RDWR);
+ if (q3 == (mqd_t) -1)
+ {
+ printf ("mq_open q3 in parent failed with: %m\n");
+ result = 1;
+ }
+
+ (void) pthread_barrier_wait (b2);
+
+ memset (&ev, 0x12, sizeof (ev));
+ ev.sigev_notify = SIGEV_NONE;
+ if (mq_notify (q3, &ev) != 0)
+ {
+ printf ("mq_notify (q3, { SIGEV_NONE }) failed with: %m\n");
+ result = 1;
+ }
+
+ (void) pthread_barrier_wait (b2);
+
+ /* Child unsuccessfully attempts to mq_notify { SIGEV_SIGNAL } on q. */
+
+ (void) pthread_barrier_wait (b2);
+
+ if (mq_close (q3) != 0)
+ {
+ printf ("mq_close failed: %m\n");
+ result = 1;
+ }
+
+ (void) pthread_barrier_wait (b2);
+
+ /* Child successfully calls mq_notify { SIGEV_NONE } on q. */
+ /* Child successfully calls mq_notify NULL on q. */
+
+ (void) pthread_barrier_wait (b2);
+
+ /* Child creates new thread. */
+ /* Thread blocks on mqrecv (q). */
+ /* Child sleeps for 1sec so that thread has time to reach that point. */
+ /* Child successfully calls mq_notify { SIGEV_SIGNAL } on q. */
+
+ (void) pthread_barrier_wait (b2);
+
+ result |= mqsend (q);
+
+ (void) pthread_barrier_wait (b3);
+
+ /* Child verifies SIGRTMIN has not been sent. */
+
+ (void) pthread_barrier_wait (b3);
+
+ result |= mqsend (q);
+
+ (void) pthread_barrier_wait (b3);
+
+ /* Thread verifies SIGRTMIN has been caught. */
+ /* Thread calls mq_notify (q, { SIGEV_NONE }) to verify notification is now
+ available for registration. */
+ /* Thread calls mq_notify (q, NULL). */
+
+ (void) pthread_barrier_wait (b3);
+
+ /* Child calls mq_notify (q, { SIGEV_SIGNAL }). */
+
+ (void) pthread_barrier_wait (b3);
+
+ /* Thread calls mq_notify (q, NULL). */
+
+ (void) pthread_barrier_wait (b3);
+
+ result |= mqsend (q);
+ result |= mqrecv (q);
+
+ (void) pthread_barrier_wait (b3);
+
+ /* Child verifies SIGRTMIN has not been sent. */
+ /* Child calls mq_notify (q, { SIGEV_SIGNAL }). */
+
+ (void) pthread_barrier_wait (b3);
+
+ /* Thread opens a new O_RDONLY mqd_t (q4). */
+ /* Thread calls mq_notify (q4, NULL). */
+ /* Thread calls mq_close (q4). */
+
+ (void) pthread_barrier_wait (b3);
+
+ result |= mqsend (q);
+ result |= mqrecv (q);
+
+ (void) pthread_barrier_wait (b3);
+
+ /* Child verifies SIGRTMIN has not been sent. */
+ /* Child calls mq_notify (q, { SIGEV_SIGNAL }). */
+
+ (void) pthread_barrier_wait (b3);
+
+ /* Thread opens a new O_WRONLY mqd_t (q5). */
+ /* Thread calls mq_notify (q5, NULL). */
+ /* Thread calls mq_close (q5). */
+
+ (void) pthread_barrier_wait (b3);
+
+ result |= mqsend (q);
+ result |= mqrecv (q);
+
+ (void) pthread_barrier_wait (b3);
+
+ /* Child verifies SIGRTMIN has not been sent. */
+
+ int status;
+ if (TEMP_FAILURE_RETRY (waitpid (pid, &status, 0)) != pid)
+ {
+ puts ("waitpid failed");
+ kill (pid, SIGKILL);
+ result = 1;
+ }
+ else if (!WIFEXITED (status) || WEXITSTATUS (status))
+ {
+ printf ("child failed with status %d\n", status);
+ result = 1;
+ }
+
+ if (mq_unlink (name) != 0)
+ {
+ printf ("mq_unlink failed: %m\n");
+ result = 1;
+ }
+
+ if (mq_close (q) != 0)
+ {
+ printf ("mq_close failed: %m\n");
+ result = 1;
+ }
+
+ if (mq_notify (q, NULL) == 0)
+ {
+ puts ("mq_notify on closed mqd_t unexpectedly succeeded");
+ result = 1;
+ }
+ else if (errno != EBADF)
+ {
+ printf ("mq_notify on closed mqd_t did not fail with EBADF: %m\n");
+ result = 1;
+ }
+
+ memset (&ev, 0x55, sizeof (ev));
+ ev.sigev_notify = SIGEV_NONE;
+ if (mq_notify (q, &ev) == 0)
+ {
+ puts ("mq_notify on closed mqd_t unexpectedly succeeded");
+ result = 1;
+ }
+ else if (errno != EBADF)
+ {
+ printf ("mq_notify on closed mqd_t did not fail with EBADF: %m\n");
+ result = 1;
+ }
+
+ return result;
+}
+#else
+# define TEST_FUNCTION 0
+#endif
+
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-mqueue6.c b/test/nptl/tst-mqueue6.c
new file mode 100644
index 000000000..8d84c1929
--- /dev/null
+++ b/test/nptl/tst-mqueue6.c
@@ -0,0 +1,304 @@
+/* Test mq_notify.
+ Copyright (C) 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
+
+ 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 <fcntl.h>
+#include <mqueue.h>
+#include <limits.h>
+#include <signal.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/time.h>
+#include <sys/wait.h>
+#include <time.h>
+#include <unistd.h>
+#include "tst-mqueue.h"
+
+#if _POSIX_THREADS
+# include <pthread.h>
+
+# define mqsend(q) (mqsend) (q, __LINE__)
+static int
+(mqsend) (mqd_t q, int line)
+{
+ char c;
+ if (mq_send (q, &c, 1, 1) != 0)
+ {
+ printf ("mq_send on line %d failed with: %m\n", line);
+ return 1;
+ }
+ return 0;
+}
+
+# define mqrecv(q) (mqrecv) (q, __LINE__)
+static int
+(mqrecv) (mqd_t q, int line)
+{
+ char c;
+ ssize_t rets = TEMP_FAILURE_RETRY (mq_receive (q, &c, 1, NULL));
+ if (rets != 1)
+ {
+ if (rets == -1)
+ printf ("mq_receive on line %d failed with: %m\n", line);
+ else
+ printf ("mq_receive on line %d returned %zd != 1\n",
+ line, rets);
+ return 1;
+ }
+ return 0;
+}
+
+volatile int fct_cnt, fct_err;
+size_t fct_guardsize;
+
+static void
+fct (union sigval s)
+{
+ mqd_t q = *(mqd_t *) s.sival_ptr;
+
+ pthread_attr_t nattr;
+ int ret = pthread_getattr_np (pthread_self (), &nattr);
+ if (ret)
+ {
+ errno = ret;
+ printf ("pthread_getattr_np failed: %m\n");
+ fct_err = 1;
+ }
+ else
+ {
+ ret = pthread_attr_getguardsize (&nattr, &fct_guardsize);
+ if (ret)
+ {
+ errno = ret;
+ printf ("pthread_attr_getguardsize failed: %m\n");
+ fct_err = 1;
+ }
+ if (pthread_attr_destroy (&nattr) != 0)
+ {
+ puts ("pthread_attr_destroy failed");
+ fct_err = 1;
+ }
+ }
+
+ ++fct_cnt;
+ fct_err |= mqsend (q);
+}
+
+# define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+ int result = 0;
+
+ char name[sizeof "/tst-mqueue6-" + sizeof (pid_t) * 3];
+ snprintf (name, sizeof (name), "/tst-mqueue6-%u", getpid ());
+
+ struct mq_attr attr = { .mq_maxmsg = 1, .mq_msgsize = 1 };
+ mqd_t q = mq_open (name, O_CREAT | O_EXCL | O_RDWR, 0600, &attr);
+
+ if (q == (mqd_t) -1)
+ {
+ printf ("mq_open failed with: %m\n");
+ return result;
+ }
+ else
+ add_temp_mq (name);
+
+ pthread_attr_t nattr;
+ if (pthread_attr_init (&nattr)
+ || pthread_attr_setguardsize (&nattr, 0))
+ {
+ puts ("pthread_attr_t setup failed");
+ result = 1;
+ }
+
+ fct_guardsize = 1;
+
+ struct sigevent ev;
+ memset (&ev, 0xaa, sizeof (ev));
+ ev.sigev_notify = SIGEV_THREAD;
+ ev.sigev_notify_function = fct;
+ ev.sigev_notify_attributes = &nattr;
+ ev.sigev_value.sival_ptr = &q;
+ if (mq_notify (q, &ev) != 0)
+ {
+ printf ("mq_notify (q, { SIGEV_THREAD }) failed with: %m\n");
+ result = 1;
+ }
+
+ size_t ps = sysconf (_SC_PAGESIZE);
+ if (pthread_attr_setguardsize (&nattr, 32 * ps))
+ {
+ puts ("pthread_attr_t setup failed");
+ result = 1;
+ }
+
+ if (mq_notify (q, &ev) == 0)
+ {
+ puts ("second mq_notify (q, { SIGEV_NONE }) unexpectedly succeeded");
+ result = 1;
+ }
+ else if (errno != EBUSY)
+ {
+ printf ("second mq_notify (q, { SIGEV_NONE }) failed with: %m\n");
+ result = 1;
+ }
+
+ if (fct_cnt != 0)
+ {
+ printf ("fct called too early (%d on %d)\n", fct_cnt, __LINE__);
+ result = 1;
+ }
+
+ result |= mqsend (q);
+
+ result |= mqrecv (q);
+ result |= mqrecv (q);
+
+ if (fct_cnt != 1)
+ {
+ printf ("fct not called (%d on %d)\n", fct_cnt, __LINE__);
+ result = 1;
+ }
+ else if (fct_guardsize != 0)
+ {
+ printf ("fct_guardsize %zd != 0\n", fct_guardsize);
+ result = 1;
+ }
+
+ if (mq_notify (q, &ev) != 0)
+ {
+ printf ("third mq_notify (q, { SIGEV_NONE }) failed with: %m\n");
+ result = 1;
+ }
+
+ if (mq_notify (q, NULL) != 0)
+ {
+ printf ("mq_notify (q, NULL) failed with: %m\n");
+ result = 1;
+ }
+
+ memset (&ev, 0x11, sizeof (ev));
+ ev.sigev_notify = SIGEV_THREAD;
+ ev.sigev_notify_function = fct;
+ ev.sigev_notify_attributes = &nattr;
+ ev.sigev_value.sival_ptr = &q;
+ if (mq_notify (q, &ev) != 0)
+ {
+ printf ("mq_notify (q, { SIGEV_THREAD }) failed with: %m\n");
+ result = 1;
+ }
+
+ if (pthread_attr_setguardsize (&nattr, 0))
+ {
+ puts ("pthread_attr_t setup failed");
+ result = 1;
+ }
+
+ if (mq_notify (q, &ev) == 0)
+ {
+ puts ("second mq_notify (q, { SIGEV_NONE }) unexpectedly succeeded");
+ result = 1;
+ }
+ else if (errno != EBUSY)
+ {
+ printf ("second mq_notify (q, { SIGEV_NONE }) failed with: %m\n");
+ result = 1;
+ }
+
+ if (fct_cnt != 1)
+ {
+ printf ("fct called too early (%d on %d)\n", fct_cnt, __LINE__);
+ result = 1;
+ }
+
+ result |= mqsend (q);
+
+ result |= mqrecv (q);
+ result |= mqrecv (q);
+
+ if (fct_cnt != 2)
+ {
+ printf ("fct not called (%d on %d)\n", fct_cnt, __LINE__);
+ result = 1;
+ }
+ else if (fct_guardsize != 32 * ps)
+ {
+ printf ("fct_guardsize %zd != %zd\n", fct_guardsize, 32 * ps);
+ result = 1;
+ }
+
+ if (mq_notify (q, &ev) != 0)
+ {
+ printf ("third mq_notify (q, { SIGEV_NONE }) failed with: %m\n");
+ result = 1;
+ }
+
+ if (mq_notify (q, NULL) != 0)
+ {
+ printf ("mq_notify (q, NULL) failed with: %m\n");
+ result = 1;
+ }
+
+ if (pthread_attr_destroy (&nattr) != 0)
+ {
+ puts ("pthread_attr_destroy failed");
+ result = 1;
+ }
+
+ if (mq_unlink (name) != 0)
+ {
+ printf ("mq_unlink failed: %m\n");
+ result = 1;
+ }
+
+ if (mq_close (q) != 0)
+ {
+ printf ("mq_close failed: %m\n");
+ result = 1;
+ }
+
+ memset (&ev, 0x55, sizeof (ev));
+ ev.sigev_notify = SIGEV_THREAD;
+ ev.sigev_notify_function = fct;
+ ev.sigev_notify_attributes = NULL;
+ ev.sigev_value.sival_int = 0;
+ if (mq_notify (q, &ev) == 0)
+ {
+ puts ("mq_notify on closed mqd_t unexpectedly succeeded");
+ result = 1;
+ }
+ else if (errno != EBADF)
+ {
+ printf ("mq_notify on closed mqd_t did not fail with EBADF: %m\n");
+ result = 1;
+ }
+
+ if (fct_err)
+ result = 1;
+ return result;
+}
+#else
+# define TEST_FUNCTION 0
+#endif
+
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-mqueue7.c b/test/nptl/tst-mqueue7.c
new file mode 100644
index 000000000..1892f951a
--- /dev/null
+++ b/test/nptl/tst-mqueue7.c
@@ -0,0 +1,108 @@
+/* Test all open message queues descriptors are closed during exec*.
+ Copyright (C) 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
+
+ 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 <fcntl.h>
+#include <mqueue.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/wait.h>
+#include <time.h>
+#include <unistd.h>
+
+#define OPT_AFTEREXEC 20000
+
+static mqd_t after_exec = (mqd_t) -1;
+
+#define CMDLINE_OPTIONS \
+ "a:"
+
+#define CMDLINE_PROCESS \
+ case 'a': \
+ after_exec = (mqd_t) strtoul (optarg, NULL, 0); \
+ break;
+
+static int
+do_after_exec (void)
+{
+ int result = 0;
+
+ struct mq_attr attr;
+ if (mq_getattr (after_exec, &attr) == 0)
+ {
+ puts ("mq_getattr after exec unexpectedly succeeded");
+ result = 1;
+ }
+ else if (errno != EBADF)
+ {
+ printf ("mq_getattr after exec did not fail with EBADF: %m\n");
+ result = 1;
+ }
+
+ return result;
+}
+
+static int
+do_test (int argc, char **argv)
+{
+ if (after_exec != (mqd_t) -1)
+ return do_after_exec ();
+
+ char name[sizeof "/tst-mqueue7-" + sizeof (pid_t) * 3];
+ snprintf (name, sizeof (name), "/tst-mqueue7-%u", getpid ());
+
+ struct mq_attr attr = { .mq_maxmsg = 10, .mq_msgsize = 1 };
+ mqd_t q = mq_open (name, O_CREAT | O_EXCL | O_WRONLY, 0600, &attr);
+
+ if (q == (mqd_t) -1)
+ {
+ printf ("mq_open failed with: %m\n");
+ return 0;
+ }
+ else if (mq_unlink (name) != 0)
+ {
+ printf ("mq_unlink failed with: %m\n");
+ return 1;
+ }
+
+ if (mq_getattr (q, &attr) != 0)
+ {
+ printf ("mq_getattr failed: %m\n");
+ return 1;
+ }
+
+ char after_exec_arg[sizeof "-a=0x" + sizeof (long) * 3];
+ snprintf (after_exec_arg, sizeof (after_exec_arg),
+ "-a=0x%lx", (long) q);
+
+ const char *newargv[argc + 2];
+ for (int i = 1; i < argc; ++i)
+ newargv[i - 1] = argv[i];
+ newargv[argc - 1] = "-d";
+ newargv[argc] = after_exec_arg;
+ newargv[argc + 1] = NULL;
+
+ /* Verify that exec* has the effect of mq_close (q). */
+ execv (newargv[0], (char * const *) newargv);
+ printf ("execv failed: %m\n");
+ return 1;
+}
+
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-mqueue8.c b/test/nptl/tst-mqueue8.c
new file mode 100644
index 000000000..b80e4e5c3
--- /dev/null
+++ b/test/nptl/tst-mqueue8.c
@@ -0,0 +1,265 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
+
+ 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 <mqueue.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#if _POSIX_THREADS
+# include <pthread.h>
+
+static pthread_barrier_t b;
+
+/* Cleanup handling test. */
+static int cl_called;
+
+static void
+cl (void *arg)
+{
+ ++cl_called;
+}
+
+#define TF_MQ_RECEIVE 0L
+#define TF_MQ_TIMEDRECEIVE 1L
+#define TF_MQ_SEND 2L
+#define TF_MQ_TIMEDSEND 3L
+
+static const char *names[]
+ = { "mq_receive", "mq_timedreceive", "mq_send", "mq_timedsend" };
+
+static mqd_t q;
+static struct timespec never;
+
+static void *
+tf (void *arg)
+{
+ int r = pthread_barrier_wait (&b);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("tf: barrier_wait failed");
+ exit (1);
+ }
+
+ pthread_cleanup_push (cl, NULL);
+
+ char c = ' ';
+
+ switch ((long) arg)
+ {
+ case TF_MQ_SEND:
+ TEMP_FAILURE_RETRY (mq_send (q, &c, 1, 1));
+ break;
+ case TF_MQ_TIMEDSEND:
+ TEMP_FAILURE_RETRY (mq_timedsend (q, &c, 1, 1, &never));
+ break;
+ case TF_MQ_RECEIVE:
+ TEMP_FAILURE_RETRY (mq_receive (q, &c, 1, NULL));
+ break;
+ case TF_MQ_TIMEDRECEIVE:
+ TEMP_FAILURE_RETRY (mq_timedreceive (q, &c, 1, NULL, &never));
+ break;
+ }
+
+ pthread_cleanup_pop (0);
+
+ printf ("tf: %s returned\n", names[(long) arg]);
+
+ exit (1);
+}
+
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+ char name[sizeof "/tst-mqueue8-" + sizeof (pid_t) * 3];
+ snprintf (name, sizeof (name), "/tst-mqueue8-%u", getpid ());
+
+ struct mq_attr attr = { .mq_maxmsg = 1, .mq_msgsize = 1 };
+ q = mq_open (name, O_CREAT | O_EXCL | O_RDWR, 0600, &attr);
+
+ if (q == (mqd_t) -1)
+ {
+ printf ("mq_open failed with: %m\n");
+ return 0;
+ }
+
+ if (mq_unlink (name) != 0)
+ {
+ printf ("mq_unlink failed with: %m\n");
+ return 1;
+ }
+
+ if (pthread_barrier_init (&b, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ return 1;
+ }
+
+ if (clock_gettime (CLOCK_REALTIME, &never) == 0)
+ never.tv_sec += 100;
+ else
+ {
+ never.tv_sec = time (NULL) + 100;
+ never.tv_nsec = 0;
+ }
+
+ int result = 0;
+ for (long l = TF_MQ_RECEIVE; l <= TF_MQ_TIMEDSEND; ++l)
+ {
+ cl_called = 0;
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, (void *) l) != 0)
+ {
+ printf ("1st %s create failed\n", names[l]);
+ result = 1;
+ continue;
+ }
+
+ int r = pthread_barrier_wait (&b);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ result = 1;
+ continue;
+ }
+
+ struct timespec ts = { .tv_sec = 0, .tv_nsec = 100000000 };
+ while (nanosleep (&ts, &ts) != 0)
+ continue;
+
+ printf ("going to cancel %s in-time\n", names[l]);
+ if (pthread_cancel (th) != 0)
+ {
+ printf ("1st cancel of %s failed\n", names[l]);
+ result = 1;
+ continue;
+ }
+
+ void *status;
+ if (pthread_join (th, &status) != 0)
+ {
+ printf ("1st join of %s failed\n", names[l]);
+ result = 1;
+ continue;
+ }
+ if (status != PTHREAD_CANCELED)
+ {
+ printf ("1st %s thread not canceled\n", names[l]);
+ result = 1;
+ continue;
+ }
+
+ if (cl_called == 0)
+ {
+ printf ("%s cleanup handler not called\n", names[l]);
+ result = 1;
+ continue;
+ }
+ if (cl_called > 1)
+ {
+ printf ("%s cleanup handler called more than once\n", names[l]);
+ result = 1;
+ continue;
+ }
+
+ printf ("in-time %s cancellation succeeded\n", names[l]);
+
+ cl_called = 0;
+
+ if (pthread_create (&th, NULL, tf, (void *) l) != 0)
+ {
+ printf ("2nd %s create failed\n", names[l]);
+ result = 1;
+ continue;
+ }
+
+ printf ("going to cancel %s early\n", names[l]);
+ if (pthread_cancel (th) != 0)
+ {
+ printf ("2nd cancel of %s failed\n", names[l]);
+ result = 1;
+ continue;
+ }
+
+ r = pthread_barrier_wait (&b);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ result = 1;
+ continue;
+ }
+
+ if (pthread_join (th, &status) != 0)
+ {
+ printf ("2nd join of %s failed\n", names[l]);
+ result = 1;
+ continue;
+ }
+ if (status != PTHREAD_CANCELED)
+ {
+ printf ("2nd %s thread not canceled\n", names[l]);
+ result = 1;
+ continue;
+ }
+
+ if (cl_called == 0)
+ {
+ printf ("%s cleanup handler not called\n", names[l]);
+ result = 1;
+ continue;
+ }
+ if (cl_called > 1)
+ {
+ printf ("%s cleanup handler called more than once\n", names[l]);
+ result = 1;
+ continue;
+ }
+
+ printf ("early %s cancellation succeeded\n", names[l]);
+
+ if (l == TF_MQ_TIMEDRECEIVE)
+ {
+ /* mq_receive and mq_timedreceive are tested on empty mq.
+ For mq_send and mq_timedsend we need to make it full.
+ If this fails, there is no point in doing further testing. */
+ char c = ' ';
+ if (mq_send (q, &c, 1, 1) != 0)
+ {
+ printf ("mq_send failed: %m\n");
+ result = 1;
+ break;
+ }
+ }
+ }
+
+ if (mq_close (q) != 0)
+ {
+ printf ("mq_close failed: %m\n");
+ result = 1;
+ }
+
+ return result;
+}
+#else
+# define TEST_FUNCTION 0
+#endif
+
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-mqueue9.c b/test/nptl/tst-mqueue9.c
new file mode 100644
index 000000000..7098b847e
--- /dev/null
+++ b/test/nptl/tst-mqueue9.c
@@ -0,0 +1,91 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
+
+ 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 <mqueue.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include "tst-mqueue.h"
+
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+ if (geteuid () != 0)
+ {
+ puts ("this test requires root");
+ return 0;
+ }
+
+ char name[sizeof "/tst-mqueue9-" + sizeof (pid_t) * 3];
+ snprintf (name, sizeof (name), "/tst-mqueue9-%u", getpid ());
+
+ struct mq_attr attr = { .mq_maxmsg = 1, .mq_msgsize = 1 };
+ mqd_t q = mq_open (name, O_CREAT | O_EXCL | O_RDWR, 0600, &attr);
+
+ if (q == (mqd_t) -1)
+ {
+ printf ("mq_open failed with: %m\n");
+ return 0;
+ }
+ else
+ add_temp_mq (name);
+
+ if (seteuid (1) != 0)
+ {
+ printf ("failed to seteuid (1): %m\n");
+ mq_unlink (name);
+ return 0;
+ }
+
+ int result = 0;
+ if (mq_unlink (name) == 0)
+ {
+ puts ("mq_unlink unexpectedly succeeded");
+ result = 1;
+ }
+ else if (errno != EACCES)
+ {
+ printf ("mq_unlink did not fail with EACCES: %m\n");
+ result = 1;;
+ }
+
+ if (seteuid (0) != 0)
+ {
+ printf ("failed to seteuid (0): %m\n");
+ result = 1;
+ }
+
+ if (mq_unlink (name) != 0)
+ {
+ printf ("mq_unlink failed with: %m\n");
+ result = 1;
+ }
+
+ if (mq_close (q) != 0)
+ {
+ printf ("mq_close failed with: %m\n");
+ result = 1;
+ }
+
+ return result;
+}
+
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-mutex1.c b/test/nptl/tst-mutex1.c
new file mode 100644
index 000000000..0f3a98c76
--- /dev/null
+++ b/test/nptl/tst-mutex1.c
@@ -0,0 +1,56 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread.h>
+#include <stdio.h>
+
+
+static int
+do_test (void)
+{
+ pthread_mutex_t m;
+
+ if (pthread_mutex_init (&m, NULL) != 0)
+ {
+ puts ("mutex_init failed");
+ return 1;
+ }
+
+ if (pthread_mutex_lock (&m) != 0)
+ {
+ puts ("mutex_lock failed");
+ return 1;
+ }
+
+ if (pthread_mutex_unlock (&m) != 0)
+ {
+ puts ("mutex_unlock failed");
+ return 1;
+ }
+
+ if (pthread_mutex_destroy (&m) != 0)
+ {
+ puts ("mutex_destroy failed");
+ return 1;
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-mutex2.c b/test/nptl/tst-mutex2.c
new file mode 100644
index 000000000..707afe9fc
--- /dev/null
+++ b/test/nptl/tst-mutex2.c
@@ -0,0 +1,222 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static pthread_mutex_t m;
+static pthread_barrier_t b;
+
+
+static void *
+tf (void *arg)
+{
+ int e = pthread_mutex_unlock (&m);
+ if (e == 0)
+ {
+ puts ("child: 1st mutex_unlock succeeded");
+ exit (1);
+ }
+ else if (e != EPERM)
+ {
+ puts ("child: 1st mutex_unlock error != EPERM");
+ exit (1);
+ }
+
+ e = pthread_mutex_trylock (&m);
+ if (e == 0)
+ {
+ puts ("child: 1st trylock suceeded");
+ exit (1);
+ }
+ if (e != EBUSY)
+ {
+ puts ("child: 1st trylock didn't return EBUSY");
+ exit (1);
+ }
+
+ e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("child: 1st barrier_wait failed");
+ exit (1);
+ }
+
+ e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("child: 2nd barrier_wait failed");
+ exit (1);
+ }
+
+ e = pthread_mutex_unlock (&m);
+ if (e == 0)
+ {
+ puts ("child: 2nd mutex_unlock succeeded");
+ exit (1);
+ }
+ else if (e != EPERM)
+ {
+ puts ("child: 2nd mutex_unlock error != EPERM");
+ exit (1);
+ }
+
+ if (pthread_mutex_trylock (&m) != 0)
+ {
+ puts ("child: 2nd trylock failed");
+ exit (1);
+ }
+
+ if (pthread_mutex_unlock (&m) != 0)
+ {
+ puts ("child: 3rd mutex_unlock failed");
+ exit (1);
+ }
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ pthread_mutexattr_t a;
+ int e;
+
+ if (pthread_mutexattr_init (&a) != 0)
+ {
+ puts ("mutexattr_init failed");
+ exit (1);
+ }
+
+ if (pthread_mutexattr_settype (&a, PTHREAD_MUTEX_ERRORCHECK) != 0)
+ {
+ puts ("mutexattr_settype failed");
+ exit (1);
+ }
+
+ if (pthread_mutex_init (&m, &a) != 0)
+ {
+ puts ("mutex_init failed");
+ exit (1);
+ }
+
+ if (pthread_barrier_init (&b, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ exit (1);
+ }
+
+ if ((e = pthread_mutex_unlock (&m)) == 0)
+ {
+ puts ("1st mutex_unlock succeeded");
+ exit (1);
+ }
+ else if (e != EPERM)
+ {
+ puts ("1st mutex_unlock error != EPERM");
+ exit (1);
+ }
+
+ if (pthread_mutex_lock (&m) != 0)
+ {
+ puts ("mutex_lock failed");
+ exit (1);
+ }
+
+ if ((e = pthread_mutex_lock (&m)) == 0)
+ {
+ puts ("2nd mutex_lock succeeded");
+ exit (1);
+ }
+ else if (e != EDEADLK)
+ {
+ puts ("2nd mutex_lock error != EDEADLK");
+ exit (1);
+ }
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ exit (1);
+ }
+
+ e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("1st barrier_wait failed");
+ exit (1);
+ }
+
+ if (pthread_mutex_unlock (&m) != 0)
+ {
+ puts ("2nd mutex_unlock failed");
+ exit (1);
+ }
+
+ if ((e = pthread_mutex_unlock (&m)) == 0)
+ {
+ puts ("3rd mutex_unlock succeeded");
+ exit (1);
+ }
+ else if (e != EPERM)
+ {
+ puts ("3rd mutex_unlock error != EPERM");
+ exit (1);
+ }
+
+ e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("2nd barrier_wait failed");
+ exit (1);
+ }
+
+ if (pthread_join (th, NULL) != 0)
+ {
+ puts ("join failed");
+ exit (1);
+ }
+
+ if (pthread_mutex_destroy (&m) != 0)
+ {
+ puts ("mutex_destroy failed");
+ exit (1);
+ }
+
+ if (pthread_barrier_destroy (&b) != 0)
+ {
+ puts ("barrier_destroy failed");
+ exit (1);
+ }
+
+ if (pthread_mutexattr_destroy (&a) != 0)
+ {
+ puts ("mutexattr_destroy failed");
+ exit (1);
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-mutex3.c b/test/nptl/tst-mutex3.c
new file mode 100644
index 000000000..5e582858b
--- /dev/null
+++ b/test/nptl/tst-mutex3.c
@@ -0,0 +1,224 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static pthread_mutex_t m;
+static pthread_barrier_t b;
+
+
+static void *
+tf (void *arg)
+{
+ int e = pthread_mutex_unlock (&m);
+ if (e == 0)
+ {
+ puts ("1st mutex_unlock in child succeeded");
+ exit (1);
+ }
+ if (e != EPERM)
+ {
+ puts ("1st mutex_unlock in child didn't return EPERM");
+ exit (1);
+ }
+
+ e = pthread_mutex_trylock (&m);
+ if (e == 0)
+ {
+ puts ("mutex_trylock in second thread succeeded");
+ exit (1);
+ }
+ if (e != EBUSY)
+ {
+ puts ("mutex_trylock returned wrong value");
+ exit (1);
+ }
+
+ e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ exit (1);
+ }
+
+ e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ exit (1);
+ }
+
+ e = pthread_mutex_unlock (&m);
+ if (e == 0)
+ {
+ puts ("2nd mutex_unlock in child succeeded");
+ exit (1);
+ }
+ if (e != EPERM)
+ {
+ puts ("2nd mutex_unlock in child didn't return EPERM");
+ exit (1);
+ }
+
+ if (pthread_mutex_trylock (&m) != 0)
+ {
+ puts ("2nd mutex_trylock in second thread failed");
+ exit (1);
+ }
+
+ if (pthread_mutex_unlock (&m) != 0)
+ {
+ puts ("3rd mutex_unlock in second thread failed");
+ exit (1);
+ }
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ pthread_mutexattr_t a;
+
+ if (pthread_mutexattr_init (&a) != 0)
+ {
+ puts ("mutexattr_init failed");
+ return 1;
+ }
+
+ if (pthread_mutexattr_settype (&a, PTHREAD_MUTEX_RECURSIVE) != 0)
+ {
+ puts ("mutexattr_settype failed");
+ return 1;
+ }
+
+ if (pthread_mutex_init (&m, &a) != 0)
+ {
+ puts ("mutex_init failed");
+ return 1;
+ }
+
+ if (pthread_barrier_init (&b, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ return 1;
+ }
+
+ if (pthread_mutex_lock (&m) != 0)
+ {
+ puts ("mutex_lock failed");
+ return 1;
+ }
+
+ if (pthread_mutex_lock (&m) != 0)
+ {
+ puts ("2nd mutex_lock failed");
+ return 1;
+ }
+
+ if (pthread_mutex_trylock (&m) != 0)
+ {
+ puts ("1st trylock failed");
+ return 1;
+ }
+
+ if (pthread_mutex_unlock (&m) != 0)
+ {
+ puts ("mutex_unlock failed");
+ return 1;
+ }
+
+ if (pthread_mutex_unlock (&m) != 0)
+ {
+ puts ("2nd mutex_unlock failed");
+ return 1;
+ }
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ return 1;
+ }
+
+ int e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ return 1;
+ }
+
+ if (pthread_mutex_unlock (&m) != 0)
+ {
+ puts ("3rd mutex_unlock failed");
+ return 1;
+ }
+
+ e = pthread_mutex_unlock (&m);
+ if (e == 0)
+ {
+ puts ("4th mutex_unlock succeeded");
+ return 1;
+ }
+ if (e != EPERM)
+ {
+ puts ("4th mutex_unlock didn't return EPERM");
+ return 1;
+ }
+
+ e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ return 1;
+ }
+
+ if (pthread_join (th, NULL) != 0)
+ {
+ puts ("join failed");
+ return 1;
+ }
+
+ if (pthread_barrier_destroy (&b) != 0)
+ {
+ puts ("barrier_destroy failed");
+ return 1;
+ }
+
+ if (pthread_mutex_destroy (&m) != 0)
+ {
+ puts ("mutex_destroy failed");
+ return 1;
+ }
+
+ if (pthread_mutexattr_destroy (&a) != 0)
+ {
+ puts ("mutexattr_destroy failed");
+ return 1;
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-mutex4.c b/test/nptl/tst-mutex4.c
new file mode 100644
index 000000000..f66abc052
--- /dev/null
+++ b/test/nptl/tst-mutex4.c
@@ -0,0 +1,190 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <pthread.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+
+
+static int
+do_test (void)
+{
+ size_t ps = sysconf (_SC_PAGESIZE);
+ char tmpfname[] = "/tmp/tst-mutex4.XXXXXX";
+ char data[ps];
+ void *mem;
+ int fd;
+ pthread_mutex_t *m;
+ pthread_mutexattr_t a;
+ pid_t pid;
+ char *p;
+ int err;
+ int s;
+
+ fd = mkstemp (tmpfname);
+ if (fd == -1)
+ {
+ printf ("cannot open temporary file: %m\n");
+ return 1;
+ }
+
+ /* Make sure it is always removed. */
+ unlink (tmpfname);
+
+ /* Create one page of data. */
+ memset (data, '\0', ps);
+
+ /* Write the data to the file. */
+ if (write (fd, data, ps) != (ssize_t) ps)
+ {
+ puts ("short write");
+ return 1;
+ }
+
+ mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ if (mem == MAP_FAILED)
+ {
+ printf ("mmap failed: %m\n");
+ return 1;
+ }
+
+ m = (pthread_mutex_t *) (((uintptr_t) mem + __alignof (pthread_mutex_t))
+ & ~(__alignof (pthread_mutex_t) - 1));
+ p = (char *) (m + 1);
+
+ if (pthread_mutexattr_init (&a) != 0)
+ {
+ puts ("mutexattr_init failed");
+ return 1;
+ }
+
+ if (pthread_mutexattr_getpshared (&a, &s) != 0)
+ {
+ puts ("1st mutexattr_getpshared failed");
+ return 1;
+ }
+
+ if (s != PTHREAD_PROCESS_PRIVATE)
+ {
+ puts ("default pshared value wrong");
+ return 1;
+ }
+
+ if (pthread_mutexattr_setpshared (&a, PTHREAD_PROCESS_SHARED) != 0)
+ {
+ puts ("mutexattr_setpshared failed");
+ return 1;
+ }
+
+ if (pthread_mutexattr_getpshared (&a, &s) != 0)
+ {
+ puts ("2nd mutexattr_getpshared failed");
+ return 1;
+ }
+
+ if (s != PTHREAD_PROCESS_SHARED)
+ {
+ puts ("pshared value after setpshared call wrong");
+ return 1;
+ }
+
+ if (pthread_mutex_init (m, &a) != 0)
+ {
+ puts ("mutex_init failed");
+ return 1;
+ }
+
+ if (pthread_mutex_lock (m) != 0)
+ {
+ puts ("mutex_lock failed");
+ return 1;
+ }
+
+ if (pthread_mutexattr_destroy (&a) != 0)
+ {
+ puts ("mutexattr_destroy failed");
+ return 1;
+ }
+
+ err = pthread_mutex_trylock (m);
+ if (err == 0)
+ {
+ puts ("mutex_trylock succeeded");
+ return 1;
+ }
+ else if (err != EBUSY)
+ {
+ puts ("mutex_trylock didn't return EBUSY");
+ return 1;
+ }
+
+ *p = 0;
+
+ puts ("going to fork now");
+ pid = fork ();
+ if (pid == -1)
+ {
+ puts ("fork failed");
+ return 1;
+ }
+ else if (pid == 0)
+ {
+ /* Play some lock ping-pong. It's our turn to unlock first. */
+ if ((*p)++ != 0)
+ {
+ puts ("child: *p != 0");
+ return 1;
+ }
+
+ if (pthread_mutex_unlock (m) != 0)
+ {
+ puts ("child: 1st mutex_unlock failed");
+ return 1;
+ }
+
+ puts ("child done");
+ }
+ else
+ {
+ if (pthread_mutex_lock (m) != 0)
+ {
+ puts ("parent: 2nd mutex_lock failed");
+ return 1;
+ }
+
+ if (*p != 1)
+ {
+ puts ("*p != 1");
+ return 1;
+ }
+
+ puts ("parent done");
+ }
+
+ return 0;
+}
+
+#define TIMEOUT 4
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-mutex5.c b/test/nptl/tst-mutex5.c
new file mode 100644
index 000000000..85dddef7e
--- /dev/null
+++ b/test/nptl/tst-mutex5.c
@@ -0,0 +1,185 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <time.h>
+#include <unistd.h>
+#include <sys/time.h>
+
+
+#ifndef TYPE
+# define TYPE PTHREAD_MUTEX_NORMAL
+#endif
+
+
+static int
+do_test (void)
+{
+ pthread_mutex_t m;
+ struct timespec ts;
+ struct timeval tv;
+ struct timeval tv2;
+ int err;
+ pthread_mutexattr_t a;
+
+ if (pthread_mutexattr_init (&a) != 0)
+ {
+ puts ("mutexattr_init failed");
+ return 1;
+ }
+
+ if (pthread_mutexattr_settype (&a, TYPE) != 0)
+ {
+ puts ("mutexattr_settype failed");
+ return 1;
+ }
+
+ if (pthread_mutex_init (&m, &a) != 0)
+ {
+ puts ("mutex_init failed");
+ return 1;
+ }
+
+ if (pthread_mutexattr_destroy (&a) != 0)
+ {
+ puts ("mutexattr_destroy failed");
+ return 1;
+ }
+
+ if (pthread_mutex_lock (&m) != 0)
+ {
+ puts ("mutex_lock failed");
+ return 1;
+ }
+
+ if (pthread_mutex_trylock (&m) == 0)
+ {
+ puts ("mutex_trylock succeeded");
+ return 1;
+ }
+
+ gettimeofday (&tv, NULL);
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+
+ ts.tv_sec += 2; /* Wait 2 seconds. */
+
+ err = pthread_mutex_timedlock (&m, &ts);
+ if (err == 0)
+ {
+ puts ("timedlock succeeded");
+ return 1;
+ }
+ else if (err != ETIMEDOUT)
+ {
+ printf ("timedlock error != ETIMEDOUT: %d\n", err);
+ return 1;
+ }
+ else
+ {
+ int clk_tck = sysconf (_SC_CLK_TCK);
+
+ gettimeofday (&tv2, NULL);
+
+ tv2.tv_sec -= tv.tv_sec;
+ tv2.tv_usec -= tv.tv_usec;
+ if (tv2.tv_usec < 0)
+ {
+ tv2.tv_usec += 1000000;
+ tv2.tv_sec -= 1;
+ }
+
+ /* Be a bit tolerant, add one CLK_TCK. */
+ tv2.tv_usec += 1000000 / clk_tck;
+ if (tv2.tv_usec >= 1000000)
+ {
+ tv2.tv_usec -= 1000000;
+ ++tv2.tv_sec;
+ }
+
+ if (tv2.tv_sec < 2)
+ {
+ printf ("premature timeout: %ld.%06ld difference\n",
+ tv2.tv_sec, tv2.tv_usec);
+ return 1;
+ }
+ }
+
+ (void) gettimeofday (&tv, NULL);
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+
+ ts.tv_sec += 2; /* Wait 2 seconds. */
+ /* The following makes the ts value invalid. */
+ ts.tv_nsec += 1000000000;
+
+ err = pthread_mutex_timedlock (&m, &ts);
+ if (err == 0)
+ {
+ puts ("2nd timedlock succeeded");
+ return 1;
+ }
+ else if (err != EINVAL)
+ {
+ printf ("2nd timedlock error != EINVAL: %d\n", err);
+ return 1;
+ }
+
+ if (pthread_mutex_unlock (&m) != 0)
+ {
+ puts ("mutex_unlock failed");
+ return 1;
+ }
+
+ (void) gettimeofday (&tv, NULL);
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+
+ ts.tv_sec += 2; /* Wait 2 seconds. */
+ if (pthread_mutex_timedlock (&m, &ts) != 0)
+ {
+ puts ("3rd timedlock failed");
+ }
+
+ (void) gettimeofday (&tv2, NULL);
+
+ /* Check that timedlock didn't delay. We use a limit of 0.1 secs. */
+ timersub (&tv2, &tv, &tv2);
+ if (tv2.tv_sec > 0 || tv2.tv_usec > 100000)
+ {
+ puts ("3rd timedlock didn't return right away");
+ return 1;
+ }
+
+ if (pthread_mutex_unlock (&m) != 0)
+ {
+ puts ("final mutex_unlock failed");
+ return 1;
+ }
+
+ if (pthread_mutex_destroy (&m) != 0)
+ {
+ puts ("mutex_destroy failed");
+ return 1;
+ }
+
+ return 0;
+}
+
+#define TIMEOUT 4
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-mutex5a.c b/test/nptl/tst-mutex5a.c
new file mode 100644
index 000000000..f91eec0d7
--- /dev/null
+++ b/test/nptl/tst-mutex5a.c
@@ -0,0 +1,2 @@
+#define TYPE PTHREAD_MUTEX_ADAPTIVE_NP
+#include "tst-mutex5.c"
diff --git a/test/nptl/tst-mutex6.c b/test/nptl/tst-mutex6.c
new file mode 100644
index 000000000..0dcfc7725
--- /dev/null
+++ b/test/nptl/tst-mutex6.c
@@ -0,0 +1,54 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <unistd.h>
+
+
+static int
+do_test (void)
+{
+ pthread_mutex_t m;
+
+ if (pthread_mutex_init (&m, NULL) != 0)
+ {
+ puts ("mutex_init failed");
+ return 1;
+ }
+
+ if (pthread_mutex_lock (&m) != 0)
+ {
+ puts ("1st mutex_lock failed");
+ return 1;
+ }
+
+ /* Set an alarm for 1 second. The wrapper will expect this. */
+ alarm (1);
+
+ /* This call should never return. */
+ pthread_mutex_lock (&m);
+
+ puts ("2nd mutex_lock returned");
+ return 1;
+}
+
+#define EXPECTED_SIGNAL SIGALRM
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-mutex7.c b/test/nptl/tst-mutex7.c
new file mode 100644
index 000000000..29a1423fd
--- /dev/null
+++ b/test/nptl/tst-mutex7.c
@@ -0,0 +1,120 @@
+/* Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread.h>
+#include <stdio.h>
+#include <time.h>
+
+
+#ifndef INIT
+# define INIT PTHREAD_MUTEX_INITIALIZER
+#endif
+
+
+static pthread_mutex_t lock = INIT;
+
+
+#define ROUNDS 1000
+#define N 100
+
+
+static void *
+tf (void *arg)
+{
+ int nr = (long int) arg;
+ int cnt;
+ struct timespec ts = { .tv_sec = 0, .tv_nsec = 11000 };
+
+ for (cnt = 0; cnt < ROUNDS; ++cnt)
+ {
+ if (pthread_mutex_lock (&lock) != 0)
+ {
+ printf ("thread %d: failed to get the lock\n", nr);
+ return (void *) 1l;
+ }
+
+ if (pthread_mutex_unlock (&lock) != 0)
+ {
+ printf ("thread %d: failed to release the lock\n", nr);
+ return (void *) 1l;
+ }
+
+ nanosleep (&ts, NULL);
+ }
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ pthread_attr_t at;
+ pthread_t th[N];
+ int cnt;
+
+ if (pthread_attr_init (&at) != 0)
+ {
+ puts ("attr_init failed");
+ return 1;
+ }
+
+ if (pthread_attr_setstacksize (&at, 1 * 1024 * 1024) != 0)
+ {
+ puts ("attr_setstacksize failed");
+ return 1;
+ }
+
+ if (pthread_mutex_lock (&lock) != 0)
+ {
+ puts ("locking in parent failed");
+ return 1;
+ }
+
+ for (cnt = 0; cnt < N; ++cnt)
+ if (pthread_create (&th[cnt], &at, tf, (void *) (long int) cnt) != 0)
+ {
+ printf ("creating thread %d failed\n", cnt);
+ return 1;
+ }
+
+ if (pthread_attr_destroy (&at) != 0)
+ {
+ puts ("attr_destroy failed");
+ return 1;
+ }
+
+ if (pthread_mutex_unlock (&lock) != 0)
+ {
+ puts ("unlocking in parent failed");
+ return 1;
+ }
+
+ for (cnt = 0; cnt < N; ++cnt)
+ if (pthread_join (th[cnt], NULL) != 0)
+ {
+ printf ("joining thread %d failed\n", cnt);
+ return 1;
+ }
+
+ return 0;
+}
+
+#define TIMEOUT 60
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-mutex7a.c b/test/nptl/tst-mutex7a.c
new file mode 100644
index 000000000..f08799ae7
--- /dev/null
+++ b/test/nptl/tst-mutex7a.c
@@ -0,0 +1,2 @@
+#define INIT PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
+#include "tst-mutex7.c"
diff --git a/test/nptl/tst-mutex8.c b/test/nptl/tst-mutex8.c
new file mode 100644
index 000000000..a949be340
--- /dev/null
+++ b/test/nptl/tst-mutex8.c
@@ -0,0 +1,366 @@
+/* Copyright (C) 2003 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/>. */
+
+/* This test checks behavior not required by POSIX. */
+#include <errno.h>
+#include <pthread.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static pthread_mutex_t *m;
+static pthread_barrier_t b;
+static pthread_cond_t c;
+static bool done;
+
+
+static void
+cl (void *arg)
+{
+ if (pthread_mutex_unlock (m) != 0)
+ {
+ puts ("cl: mutex_unlocked failed");
+ exit (1);
+ }
+}
+
+
+static void *
+tf (void *arg)
+{
+ if (pthread_mutex_lock (m) != 0)
+ {
+ puts ("tf: mutex_lock failed");
+ return (void *) 1l;
+ }
+
+ int e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ return (void *) 1l;
+ }
+
+ if (arg == NULL)
+ do
+ if (pthread_cond_wait (&c, m) != 0)
+ {
+ puts ("tf: cond_wait failed");
+ return (void *) 1l;
+ }
+ while (! done);
+ else
+ do
+ {
+ pthread_cleanup_push (cl, NULL);
+
+ if (pthread_cond_wait (&c, m) != 0)
+ {
+ puts ("tf: cond_wait failed");
+ return (void *) 1l;
+ }
+
+ pthread_cleanup_pop (0);
+ }
+ while (! done);
+
+ if (pthread_mutex_unlock (m) != 0)
+ {
+ puts ("tf: mutex_unlock failed");
+ return (void *) 1l;
+ }
+
+ return NULL;
+}
+
+
+static int
+check_type (const char *mas, pthread_mutexattr_t *ma)
+{
+ if (pthread_mutex_init (m, ma) != 0)
+ {
+ printf ("1st mutex_init failed for %s\n", mas);
+ return 1;
+ }
+
+ if (pthread_mutex_destroy (m) != 0)
+ {
+ printf ("immediate mutex_destroy failed for %s\n", mas);
+ return 1;
+ }
+
+ if (pthread_mutex_init (m, ma) != 0)
+ {
+ printf ("2nd mutex_init failed for %s\n", mas);
+ return 1;
+ }
+
+ if (pthread_mutex_lock (m) != 0)
+ {
+ printf ("1st mutex_lock failed for %s\n", mas);
+ return 1;
+ }
+
+ int e = pthread_mutex_destroy (m);
+ if (e == 0)
+ {
+ printf ("mutex_destroy of self-locked mutex succeeded for %s\n", mas);
+ return 1;
+ }
+ if (e != EBUSY)
+ {
+ printf ("mutex_destroy of self-locked mutex did not return EBUSY %s\n",
+ mas);
+ return 1;
+ }
+
+ if (pthread_mutex_unlock (m) != 0)
+ {
+ printf ("1st mutex_unlock failed for %s\n", mas);
+ return 1;
+ }
+
+ if (pthread_mutex_trylock (m) != 0)
+ {
+ printf ("mutex_trylock failed for %s\n", mas);
+ return 1;
+ }
+
+ e = pthread_mutex_destroy (m);
+ if (e == 0)
+ {
+ printf ("mutex_destroy of self-trylocked mutex succeeded for %s\n", mas);
+ return 1;
+ }
+ if (e != EBUSY)
+ {
+ printf ("\
+mutex_destroy of self-trylocked mutex did not return EBUSY %s\n",
+ mas);
+ return 1;
+ }
+
+ if (pthread_mutex_unlock (m) != 0)
+ {
+ printf ("2nd mutex_unlock failed for %s\n", mas);
+ return 1;
+ }
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("1st create failed");
+ return 1;
+ }
+ done = false;
+
+ e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("1st barrier_wait failed");
+ return 1;
+ }
+
+ if (pthread_mutex_lock (m) != 0)
+ {
+ printf ("2nd mutex_lock failed for %s\n", mas);
+ return 1;
+ }
+
+ if (pthread_mutex_unlock (m) != 0)
+ {
+ printf ("3rd mutex_unlock failed for %s\n", mas);
+ return 1;
+ }
+
+ e = pthread_mutex_destroy (m);
+ if (e == 0)
+ {
+ printf ("mutex_destroy of condvar-used mutex succeeded for %s\n", mas);
+ return 1;
+ }
+ if (e != EBUSY)
+ {
+ printf ("\
+mutex_destroy of condvar-used mutex did not return EBUSY for %s\n", mas);
+ return 1;
+ }
+
+ done = true;
+ if (pthread_cond_signal (&c) != 0)
+ {
+ puts ("cond_signal failed");
+ return 1;
+ }
+
+ void *r;
+ if (pthread_join (th, &r) != 0)
+ {
+ puts ("join failed");
+ return 1;
+ }
+ if (r != NULL)
+ {
+ puts ("thread didn't return NULL");
+ return 1;
+ }
+
+ if (pthread_mutex_destroy (m) != 0)
+ {
+ printf ("mutex_destroy after condvar-use failed for %s\n", mas);
+ return 1;
+ }
+
+ if (pthread_mutex_init (m, ma) != 0)
+ {
+ printf ("3rd mutex_init failed for %s\n", mas);
+ return 1;
+ }
+
+ if (pthread_create (&th, NULL, tf, (void *) 1) != 0)
+ {
+ puts ("2nd create failed");
+ return 1;
+ }
+ done = false;
+
+ e = pthread_barrier_wait (&b);
+ if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("2nd barrier_wait failed");
+ return 1;
+ }
+
+ if (pthread_mutex_lock (m) != 0)
+ {
+ printf ("3rd mutex_lock failed for %s\n", mas);
+ return 1;
+ }
+
+ if (pthread_mutex_unlock (m) != 0)
+ {
+ printf ("4th mutex_unlock failed for %s\n", mas);
+ return 1;
+ }
+
+ e = pthread_mutex_destroy (m);
+ if (e == 0)
+ {
+ printf ("2nd mutex_destroy of condvar-used mutex succeeded for %s\n",
+ mas);
+ return 1;
+ }
+ if (e != EBUSY)
+ {
+ printf ("\
+2nd mutex_destroy of condvar-used mutex did not return EBUSY for %s\n",
+ mas);
+ return 1;
+ }
+
+ if (pthread_cancel (th) != 0)
+ {
+ puts ("cond_cancel failed");
+ return 1;
+ }
+
+ if (pthread_join (th, &r) != 0)
+ {
+ puts ("join failed");
+ return 1;
+ }
+ if (r != PTHREAD_CANCELED)
+ {
+ puts ("thread not canceled");
+ return 1;
+ }
+
+ if (pthread_mutex_destroy (m) != 0)
+ {
+ printf ("mutex_destroy after condvar-canceled failed for %s\n", mas);
+ return 1;
+ }
+
+ return 0;
+}
+
+
+static int
+do_test (void)
+{
+ pthread_mutex_t mm;
+ m = &mm;
+
+ if (pthread_barrier_init (&b, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ return 1;
+ }
+
+ if (pthread_cond_init (&c, NULL) != 0)
+ {
+ puts ("cond_init failed");
+ return 1;
+ }
+
+ puts ("check normal mutex");
+ int res = check_type ("normal", NULL);
+
+ pthread_mutexattr_t ma;
+ if (pthread_mutexattr_init (&ma) != 0)
+ {
+ puts ("1st mutexattr_init failed");
+ return 1;
+ }
+ if (pthread_mutexattr_settype (&ma, PTHREAD_MUTEX_RECURSIVE) != 0)
+ {
+ puts ("1st mutexattr_settype failed");
+ return 1;
+ }
+ puts ("check recursive mutex");
+ res |= check_type ("recursive", &ma);
+ if (pthread_mutexattr_destroy (&ma) != 0)
+ {
+ puts ("1st mutexattr_destroy failed");
+ return 1;
+ }
+
+ if (pthread_mutexattr_init (&ma) != 0)
+ {
+ puts ("2nd mutexattr_init failed");
+ return 1;
+ }
+ if (pthread_mutexattr_settype (&ma, PTHREAD_MUTEX_ERRORCHECK) != 0)
+ {
+ puts ("2nd mutexattr_settype failed");
+ return 1;
+ }
+ puts ("check error-checking mutex");
+ res |= check_type ("error-checking", &ma);
+ if (pthread_mutexattr_destroy (&ma) != 0)
+ {
+ puts ("2nd mutexattr_destroy failed");
+ return 1;
+ }
+
+ return res;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-mutex9.c b/test/nptl/tst-mutex9.c
new file mode 100644
index 000000000..a4bb3aaaf
--- /dev/null
+++ b/test/nptl/tst-mutex9.c
@@ -0,0 +1,190 @@
+/* Copyright (C) 2003, 2004 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 <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <sys/time.h>
+
+int gettimeofday(struct timeval *tv, struct timezone *tz);
+
+
+static int
+do_test (void)
+{
+ size_t ps = sysconf (_SC_PAGESIZE);
+ char tmpfname[] = "/tmp/tst-mutex9.XXXXXX";
+ char data[ps];
+ void *mem;
+ int fd;
+ pthread_mutex_t *m;
+ pthread_mutexattr_t a;
+ pid_t pid;
+ char *p;
+
+ fd = mkstemp (tmpfname);
+ if (fd == -1)
+ {
+ printf ("cannot open temporary file: %m\n");
+ return 1;
+ }
+
+ /* Make sure it is always removed. */
+ unlink (tmpfname);
+
+ /* Create one page of data. */
+ memset (data, '\0', ps);
+
+ /* Write the data to the file. */
+ if (write (fd, data, ps) != (ssize_t) ps)
+ {
+ puts ("short write");
+ return 1;
+ }
+
+ mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ if (mem == MAP_FAILED)
+ {
+ printf ("mmap failed: %m\n");
+ return 1;
+ }
+
+ m = (pthread_mutex_t *) (((uintptr_t) mem + __alignof (pthread_mutex_t))
+ & ~(__alignof (pthread_mutex_t) - 1));
+ p = (char *) (m + 1);
+
+ if (pthread_mutexattr_init (&a) != 0)
+ {
+ puts ("mutexattr_init failed");
+ return 1;
+ }
+
+ if (pthread_mutexattr_setpshared (&a, PTHREAD_PROCESS_SHARED) != 0)
+ {
+ puts ("mutexattr_setpshared failed");
+ return 1;
+ }
+
+ if (pthread_mutexattr_settype (&a, PTHREAD_MUTEX_RECURSIVE) != 0)
+ {
+ puts ("mutexattr_settype failed");
+ return 1;
+ }
+
+ if (pthread_mutex_init (m, &a) != 0)
+ {
+ puts ("mutex_init failed");
+ return 1;
+ }
+
+ if (pthread_mutex_lock (m) != 0)
+ {
+ puts ("mutex_lock failed");
+ return 1;
+ }
+
+ if (pthread_mutexattr_destroy (&a) != 0)
+ {
+ puts ("mutexattr_destroy failed");
+ return 1;
+ }
+
+ puts ("going to fork now");
+ pid = fork ();
+ if (pid == -1)
+ {
+ puts ("fork failed");
+ return 1;
+ }
+ else if (pid == 0)
+ {
+ if (pthread_mutex_trylock (m) == 0)
+ {
+ puts ("child: mutex_trylock succeeded");
+ exit (1);
+ }
+
+ if (pthread_mutex_unlock (m) == 0)
+ {
+ puts ("child: mutex_unlock succeeded");
+ exit (1);
+ }
+
+ struct timeval tv;
+ gettimeofday (&tv, NULL);
+ struct timespec ts;
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+ ts.tv_nsec += 500000000;
+ if (ts.tv_nsec >= 1000000000)
+ {
+ ++ts.tv_sec;
+ ts.tv_nsec -= 1000000000;
+ }
+
+ int e = pthread_mutex_timedlock (m, &ts);
+ if (e == 0)
+ {
+ puts ("child: mutex_timedlock succeeded");
+ exit (1);
+ }
+ if (e != ETIMEDOUT)
+ {
+ puts ("child: mutex_timedlock didn't time out");
+ exit (1);
+ }
+
+ alarm (1);
+
+ pthread_mutex_lock (m);
+
+ puts ("child: mutex_lock returned");
+
+ exit (0);
+ }
+
+ sleep (2);
+
+ int status;
+ if (TEMP_FAILURE_RETRY (waitpid (pid, &status, 0)) != pid)
+ {
+ puts ("waitpid failed");
+ return 1;
+ }
+ if (! WIFSIGNALED (status))
+ {
+ puts ("child not killed by signal");
+ return 1;
+ }
+ if (WTERMSIG (status) != SIGALRM)
+ {
+ puts ("child not killed by SIGALRM");
+ return 1;
+ }
+
+ return 0;
+}
+
+#define TIMEOUT 3
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-oddstacklimit.c b/test/nptl/tst-oddstacklimit.c
new file mode 100644
index 000000000..9fbef1889
--- /dev/null
+++ b/test/nptl/tst-oddstacklimit.c
@@ -0,0 +1 @@
+#include "tst-basic1.c"
diff --git a/test/nptl/tst-once1.c b/test/nptl/tst-once1.c
new file mode 100644
index 000000000..308a45586
--- /dev/null
+++ b/test/nptl/tst-once1.c
@@ -0,0 +1,50 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread.h>
+#include <stdio.h>
+
+
+static pthread_once_t once = PTHREAD_ONCE_INIT;
+
+static int global;
+
+static void
+once_handler (void)
+{
+ ++global;
+}
+
+
+static int
+do_test (void)
+{
+ pthread_once (&once, once_handler);
+ pthread_once (&once, once_handler);
+
+ if (global != 1)
+ {
+ printf ("global = %d, expected 1\n", global);
+ return 1;
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-once2.c b/test/nptl/tst-once2.c
new file mode 100644
index 000000000..6e2f3db1f
--- /dev/null
+++ b/test/nptl/tst-once2.c
@@ -0,0 +1,103 @@
+/* Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+
+
+#define N 100
+
+static pthread_once_t once = PTHREAD_ONCE_INIT;
+
+static int global;
+
+static void
+once_handler (void)
+{
+ struct timespec ts;
+
+ ++global;
+
+ ts.tv_sec = 2;
+ ts.tv_nsec = 0;
+ nanosleep (&ts, NULL);
+}
+
+
+static void *
+tf (void *arg)
+{
+ pthread_once (&once, once_handler);
+
+ if (global != 1)
+ {
+ printf ("thread %ld: global == %d\n", (long int) arg, global);
+ exit (1);
+ }
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ pthread_attr_t at;
+ pthread_t th[N];
+ int cnt;
+
+ if (pthread_attr_init (&at) != 0)
+ {
+ puts ("attr_init failed");
+ return 1;
+ }
+
+ if (pthread_attr_setstacksize (&at, 1 * 1024 * 1024) != 0)
+ {
+ puts ("attr_setstacksize failed");
+ return 1;
+ }
+
+ for (cnt = 0; cnt < N; ++cnt)
+ if (pthread_create (&th[cnt], &at, tf, (void *) (long int) cnt) != 0)
+ {
+ printf ("creation of thread %d failed\n", cnt);
+ return 1;
+ }
+
+ if (pthread_attr_destroy (&at) != 0)
+ {
+ puts ("attr_destroy failed");
+ return 1;
+ }
+
+ for (cnt = 0; cnt < N; ++cnt)
+ if (pthread_join (th[cnt], NULL) != 0)
+ {
+ printf ("join of thread %d failed\n", cnt);
+ return 1;
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#define TIMEOUT 4
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-once3.c b/test/nptl/tst-once3.c
new file mode 100644
index 000000000..c869ca890
--- /dev/null
+++ b/test/nptl/tst-once3.c
@@ -0,0 +1,161 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+
+
+#define N 100
+
+static pthread_once_t once = PTHREAD_ONCE_INIT;
+
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
+
+static pthread_barrier_t bar;
+
+static int global;
+static int cl_called;
+
+static void
+once_handler1 (void)
+{
+ if (pthread_mutex_lock (&mut) != 0)
+ {
+ puts ("once_handler1: mutex_lock failed");
+ exit (1);
+ }
+ puts ("once_handler1: locked");
+
+ int r = pthread_barrier_wait (&bar);
+ if (r != 0 && r!= PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("once_handler1: barrier_wait failed");
+ exit (1);
+ }
+
+ pthread_cond_wait (&cond, &mut);
+
+ /* We should never get here. */
+ exit (42);
+}
+
+static void
+once_handler2 (void)
+{
+ global = 1;
+}
+
+
+static void
+cl (void *arg)
+{
+ cl_called = 1;
+}
+
+
+static void *
+tf (void *arg)
+{
+ pthread_cleanup_push (cl, NULL)
+
+ pthread_once (&once, once_handler1);
+
+ pthread_cleanup_pop (0);
+
+ /* We should never get here. */
+ puts ("pthread_once in tf returned");
+ exit (1);
+}
+
+
+static int
+do_test (void)
+{
+ pthread_t th;
+
+ if (pthread_barrier_init (&bar, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ return 1;
+ }
+
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("first create failed");
+ return 1;
+ }
+
+ int r = pthread_barrier_wait (&bar);
+ if (r != 0 && r!= PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ return 1;
+ }
+
+ if (pthread_mutex_lock (&mut) != 0)
+ {
+ puts ("mutex_lock failed");
+ return 1;
+ }
+ /* We unlock the mutex so that we catch the case where the pthread_cond_wait
+ call incorrectly resumes and tries to get the mutex. */
+ if (pthread_mutex_unlock (&mut) != 0)
+ {
+ puts ("mutex_unlock failed");
+ return 1;
+ }
+
+ /* Cancel the thread. */
+ puts ("going to cancel");
+ if (pthread_cancel (th) != 0)
+ {
+ puts ("cancel failed");
+ return 1;
+ }
+
+ void *result;
+ pthread_join (th, &result);
+ if (result != PTHREAD_CANCELED)
+ {
+ puts ("join didn't return PTHREAD_CANCELED");
+ return 1;
+ }
+
+ if (cl_called != 1)
+ {
+ puts ("cleanup handler not called");
+ return 1;
+ }
+
+ pthread_once (&once, once_handler2);
+
+ if (global != 1)
+ {
+ puts ("global still 0");
+ return 1;
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#define TIMEOUT 4
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-once4.c b/test/nptl/tst-once4.c
new file mode 100644
index 000000000..a80b83099
--- /dev/null
+++ b/test/nptl/tst-once4.c
@@ -0,0 +1,201 @@
+/* Copyright (C) 2003, 2004 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 <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <unistd.h>
+
+
+static pthread_once_t once = PTHREAD_ONCE_INIT;
+
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
+
+static pthread_barrier_t bar;
+
+static int global;
+static int cl_called;
+
+static void
+once_handler1 (void)
+{
+ if (pthread_mutex_lock (&mut) != 0)
+ {
+ puts ("once_handler1: mutex_lock failed");
+ exit (1);
+ }
+
+ int r = pthread_barrier_wait (&bar);
+ if (r != 0 && r!= PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("once_handler1: barrier_wait failed");
+ exit (1);
+ }
+
+ pthread_cond_wait (&cond, &mut);
+
+ /* We should never get here. */
+}
+
+
+static void
+once_handler2 (void)
+{
+ global = 1;
+}
+
+
+static void
+cl (void *arg)
+{
+ ++cl_called;
+}
+
+
+static void *
+tf1 (void *arg)
+{
+ pthread_cleanup_push (cl, NULL);
+
+ pthread_once (&once, once_handler1);
+
+ pthread_cleanup_pop (0);
+
+ /* We should never get here. */
+ puts ("pthread_once in tf returned");
+ exit (1);
+}
+
+
+static void *
+tf2 (void *arg)
+{
+ pthread_cleanup_push (cl, NULL);
+
+ int r = pthread_barrier_wait (&bar);
+ if (r != 0 && r!= PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("once_handler2: barrier_wait failed");
+ exit (1);
+ }
+
+ pthread_cleanup_pop (0);
+
+ pthread_once (&once, once_handler2);
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ pthread_t th[2];
+
+ if (pthread_barrier_init (&bar, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ return 1;
+ }
+
+ if (pthread_create (&th[0], NULL, tf1, NULL) != 0)
+ {
+ puts ("first create failed");
+ return 1;
+ }
+
+ int r = pthread_barrier_wait (&bar);
+ if (r != 0 && r!= PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("first barrier_wait failed");
+ return 1;
+ }
+
+ if (pthread_mutex_lock (&mut) != 0)
+ {
+ puts ("mutex_lock failed");
+ return 1;
+ }
+ /* We unlock the mutex so that we catch the case where the pthread_cond_wait
+ call incorrectly resumes and tries to get the mutex. */
+ if (pthread_mutex_unlock (&mut) != 0)
+ {
+ puts ("mutex_unlock failed");
+ return 1;
+ }
+
+ if (pthread_create (&th[1], NULL, tf2, NULL) != 0)
+ {
+ puts ("second create failed");
+ return 1;
+ }
+
+ r = pthread_barrier_wait (&bar);
+ if (r != 0 && r!= PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("second barrier_wait failed");
+ return 1;
+ }
+
+ /* Give the second thread a chance to reach the pthread_once call. */
+ sleep (2);
+
+ /* Cancel the thread. */
+ if (pthread_cancel (th[0]) != 0)
+ {
+ puts ("cancel failed");
+ return 1;
+ }
+
+ void *result;
+ pthread_join (th[0], &result);
+ if (result != PTHREAD_CANCELED)
+ {
+ puts ("first join didn't return PTHREAD_CANCELED");
+ return 1;
+ }
+
+ puts ("joined first thread");
+
+ pthread_join (th[1], &result);
+ if (result != NULL)
+ {
+ puts ("second join didn't return PTHREAD_CANCELED");
+ return 1;
+ }
+
+ if (global != 1)
+ {
+ puts ("global still 0");
+ return 1;
+ }
+
+ if (cl_called != 1)
+ {
+ printf ("cl_called = %d\n", cl_called);
+ return 1;
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#define TIMEOUT 4
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-oncex3.c b/test/nptl/tst-oncex3.c
new file mode 100644
index 000000000..08225b88d
--- /dev/null
+++ b/test/nptl/tst-oncex3.c
@@ -0,0 +1 @@
+#include "tst-once3.c"
diff --git a/test/nptl/tst-oncex4.c b/test/nptl/tst-oncex4.c
new file mode 100644
index 000000000..9b4d98f3f
--- /dev/null
+++ b/test/nptl/tst-oncex4.c
@@ -0,0 +1 @@
+#include "tst-once4.c"
diff --git a/test/nptl/tst-popen1.c b/test/nptl/tst-popen1.c
new file mode 100644
index 000000000..0c779fc99
--- /dev/null
+++ b/test/nptl/tst-popen1.c
@@ -0,0 +1,59 @@
+/* Copyright (C) 2003 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/>. */
+
+#include <errno.h>
+#include <error.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+static void *
+dummy (void *x)
+{
+ return NULL;
+}
+
+static char buf[sizeof "something\n"];
+
+static int
+do_test (void)
+{
+ FILE *f;
+ pthread_t p;
+ int err;
+
+ f = popen ("echo something", "r");
+ if (f == NULL)
+ error (EXIT_FAILURE, errno, "popen failed");
+ if (fgets (buf, sizeof (buf), f) == NULL)
+ error (EXIT_FAILURE, 0, "fgets failed");
+ if (strcmp (buf, "something\n"))
+ error (EXIT_FAILURE, 0, "read wrong data");
+ if (pclose (f))
+ error (EXIT_FAILURE, errno, "pclose returned non-zero");
+ if ((err = pthread_create (&p, NULL, dummy, NULL)))
+ error (EXIT_FAILURE, err, "pthread_create failed");
+ if ((err = pthread_join (p, NULL)))
+ error (EXIT_FAILURE, err, "pthread_join failed");
+ exit (0);
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-raise1.c b/test/nptl/tst-raise1.c
new file mode 100644
index 000000000..45c62e19e
--- /dev/null
+++ b/test/nptl/tst-raise1.c
@@ -0,0 +1,61 @@
+/* Copyright (C) 2003 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/>. */
+
+#include <errno.h>
+#include <error.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+volatile int count;
+
+void
+sh (int sig)
+{
+ ++count;
+}
+
+int
+main (void)
+{
+ struct sigaction sa;
+ sa.sa_handler = sh;
+ sigemptyset (&sa.sa_mask);
+ sa.sa_flags = 0;
+ if (sigaction (SIGUSR1, &sa, NULL) < 0)
+ {
+ printf ("sigaction failed: %m\n");
+ exit (1);
+ }
+ if (raise (SIGUSR1) < 0)
+ {
+ printf ("first raise failed: %m\n");
+ exit (1);
+ }
+ if (raise (SIGUSR1) < 0)
+ {
+ printf ("second raise failed: %m\n");
+ exit (1);
+ }
+ if (count != 2)
+ {
+ printf ("signal handler not called 2 times\n");
+ exit (1);
+ }
+ exit (0);
+}
diff --git a/test/nptl/tst-rwlock1.c b/test/nptl/tst-rwlock1.c
new file mode 100644
index 000000000..a5e8d6326
--- /dev/null
+++ b/test/nptl/tst-rwlock1.c
@@ -0,0 +1,116 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread.h>
+#include <stdio.h>
+
+
+static int
+do_test (void)
+{
+ pthread_rwlock_t r;
+
+ if (pthread_rwlock_init (&r, NULL) != 0)
+ {
+ puts ("rwlock_init failed");
+ return 1;
+ }
+ puts ("rwlock_init succeeded");
+
+ if (pthread_rwlock_rdlock (&r) != 0)
+ {
+ puts ("1st rwlock_rdlock failed");
+ return 1;
+ }
+ puts ("1st rwlock_rdlock succeeded");
+
+ if (pthread_rwlock_rdlock (&r) != 0)
+ {
+ puts ("2nd rwlock_rdlock failed");
+ return 1;
+ }
+ puts ("2nd rwlock_rdlock succeeded");
+
+ if (pthread_rwlock_unlock (&r) != 0)
+ {
+ puts ("1st rwlock_unlock failed");
+ return 1;
+ }
+ puts ("1st rwlock_unlock succeeded");
+
+ if (pthread_rwlock_unlock (&r) != 0)
+ {
+ puts ("2nd rwlock_unlock failed");
+ return 1;
+ }
+ puts ("2nd rwlock_unlock succeeded");
+
+ if (pthread_rwlock_wrlock (&r) != 0)
+ {
+ puts ("1st rwlock_wrlock failed");
+ return 1;
+ }
+ puts ("1st rwlock_wrlock succeeded");
+
+ if (pthread_rwlock_unlock (&r) != 0)
+ {
+ puts ("3rd rwlock_unlock failed");
+ return 1;
+ }
+ puts ("3rd rwlock_unlock succeeded");
+
+ if (pthread_rwlock_wrlock (&r) != 0)
+ {
+ puts ("2nd rwlock_wrlock failed");
+ return 1;
+ }
+ puts ("2nd rwlock_wrlock succeeded");
+
+ if (pthread_rwlock_unlock (&r) != 0)
+ {
+ puts ("4th rwlock_unlock failed");
+ return 1;
+ }
+ puts ("4th rwlock_unlock succeeded");
+
+ if (pthread_rwlock_rdlock (&r) != 0)
+ {
+ puts ("3rd rwlock_rdlock failed");
+ return 1;
+ }
+ puts ("3rd rwlock_rdlock succeeded");
+
+ if (pthread_rwlock_unlock (&r) != 0)
+ {
+ puts ("5th rwlock_unlock failed");
+ return 1;
+ }
+ puts ("5th rwlock_unlock succeeded");
+
+ if (pthread_rwlock_destroy (&r) != 0)
+ {
+ puts ("rwlock_destroy failed");
+ return 1;
+ }
+ puts ("rwlock_destroy succeeded");
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-rwlock10.c b/test/nptl/tst-rwlock10.c
new file mode 100644
index 000000000..e22b1e07f
--- /dev/null
+++ b/test/nptl/tst-rwlock10.c
@@ -0,0 +1,20 @@
+/* Test program for timedout read/write lock functions.
+ Copyright (C) 2003 Free Software Foundation, Inc.
+ 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; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#define INIT PTHREAD_RWLOCK_INITIALIZER
+#include "tst-rwlock8.c"
diff --git a/test/nptl/tst-rwlock11.c b/test/nptl/tst-rwlock11.c
new file mode 100644
index 000000000..93a1b0cce
--- /dev/null
+++ b/test/nptl/tst-rwlock11.c
@@ -0,0 +1,20 @@
+/* Test program for timedout read/write lock functions.
+ Copyright (C) 2003 Free Software Foundation, Inc.
+ 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; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#define INIT PTHREAD_RWLOCK_INITIALIZER
+#include "tst-rwlock9.c"
diff --git a/test/nptl/tst-rwlock12.c b/test/nptl/tst-rwlock12.c
new file mode 100644
index 000000000..c0e5cee92
--- /dev/null
+++ b/test/nptl/tst-rwlock12.c
@@ -0,0 +1,207 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <pthread.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+
+
+static int
+do_test (void)
+{
+ size_t ps = sysconf (_SC_PAGESIZE);
+ char tmpfname[] = "/tmp/tst-rwlock12.XXXXXX";
+ char data[ps];
+ void *mem;
+ int fd;
+ pthread_mutex_t *m;
+ pthread_mutexattr_t ma;
+ pthread_rwlock_t *r;
+ pthread_rwlockattr_t ra;
+ pid_t pid;
+ int status = 0;
+
+ fd = mkstemp (tmpfname);
+ if (fd == -1)
+ {
+ printf ("cannot open temporary file: %m\n");
+ return 1;
+ }
+
+ /* Make sure it is always removed. */
+ unlink (tmpfname);
+
+ /* Create one page of data. */
+ memset (data, '\0', ps);
+
+ /* Write the data to the file. */
+ if (write (fd, data, ps) != (ssize_t) ps)
+ {
+ puts ("short write");
+ return 1;
+ }
+
+ mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ if (mem == MAP_FAILED)
+ {
+ printf ("mmap failed: %m\n");
+ return 1;
+ }
+
+ r = (pthread_rwlock_t *) (((uintptr_t) mem + __alignof (pthread_rwlock_t))
+ & ~(__alignof (pthread_rwlock_t) - 1));
+ /* The following assumes alignment for a mutex is at least as high
+ as that for a rwlock. Which is true in our case. */
+ m = (pthread_mutex_t *) (r + 1);
+
+ if (pthread_rwlockattr_init (&ra) != 0)
+ {
+ puts ("rwlockattr_init failed");
+ return 1;
+ }
+
+ if (pthread_rwlockattr_setpshared (&ra, PTHREAD_PROCESS_SHARED) != 0)
+ {
+ puts ("rwlockattr_setpshared failed");
+ return 1;
+ }
+
+ if (pthread_rwlock_init (r, &ra) != 0)
+ {
+ puts ("rwlock_init failed");
+ return 1;
+ }
+
+ if (pthread_mutexattr_init (&ma) != 0)
+ {
+ puts ("rwlockattr_init failed");
+ return 1;
+ }
+
+ if (pthread_mutexattr_setpshared (&ma, PTHREAD_PROCESS_SHARED) != 0)
+ {
+ puts ("mutexattr_setpshared failed");
+ return 1;
+ }
+
+ if (pthread_mutex_init (m, &ma) != 0)
+ {
+ puts ("mutex_init failed");
+ return 1;
+ }
+
+ /* Lock the mutex. */
+ if (pthread_mutex_lock (m) != 0)
+ {
+ puts ("mutex_lock failed");
+ return 1;
+ }
+
+ puts ("going to fork now");
+ pid = fork ();
+ if (pid == -1)
+ {
+ puts ("fork failed");
+ return 1;
+ }
+ else if (pid == 0)
+ {
+ /* Lock the mutex. */
+ if (pthread_mutex_lock (m) != 0)
+ {
+ puts ("child: mutex_lock failed");
+ return 1;
+ }
+
+ /* Try to get the rwlock. */
+ if (pthread_rwlock_trywrlock (r) == 0)
+ {
+ puts ("rwlock_trywrlock succeeded");
+ return 1;
+ }
+
+ /* Try again. */
+ struct timespec ts = { .tv_sec = 0, .tv_nsec = 500000000 };
+ int e = pthread_rwlock_timedwrlock (r, &ts);
+ if (e == 0)
+ {
+ puts ("rwlock_timedwrlock succeeded");
+ return 1;
+ }
+ if (e != ETIMEDOUT)
+ {
+ puts ("rwlock_timedwrlock didn't return ETIMEDOUT");
+ status = 1;
+ }
+
+ if (pthread_rwlock_tryrdlock (r) == 0)
+ {
+ puts ("rwlock_tryrdlock succeeded");
+ return 1;
+ }
+
+ e = pthread_rwlock_timedrdlock (r, &ts);
+ if (e == 0)
+ {
+ puts ("rwlock_timedrdlock succeeded");
+ return 1;
+ }
+ if (e != ETIMEDOUT)
+ {
+ puts ("rwlock_timedrdlock didn't return ETIMEDOUT");
+ status = 1;
+ }
+ }
+ else
+ {
+ /* Lock the rwlock for writing. */
+ if (pthread_rwlock_wrlock (r) != 0)
+ {
+ puts ("rwlock_wrlock failed");
+ kill (pid, SIGTERM);
+ return 1;
+ }
+
+ /* Allow the child to run. */
+ if (pthread_mutex_unlock (m) != 0)
+ {
+ puts ("mutex_unlock failed");
+ kill (pid, SIGTERM);
+ return 1;
+ }
+
+ /* Just wait for the child. */
+ if (TEMP_FAILURE_RETRY (waitpid (pid, &status, 0)) != pid)
+ {
+ puts ("waitpid failed");
+ kill (pid, SIGTERM);
+ return 1;
+ }
+ }
+
+ return status;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-rwlock13.c b/test/nptl/tst-rwlock13.c
new file mode 100644
index 000000000..8fb2a7d2b
--- /dev/null
+++ b/test/nptl/tst-rwlock13.c
@@ -0,0 +1,70 @@
+/* Copyright (C) 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/>. */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <string.h>
+
+
+static int
+do_test (void)
+{
+ pthread_rwlock_t r;
+ int ret;
+
+ memset (&r, 0xaa, sizeof (r));
+ if ((ret = pthread_rwlock_init (&r, NULL)) != 0)
+ {
+ printf ("rwlock_init failed: %d\n", ret);
+ return 1;
+ }
+
+ if ((ret = pthread_rwlock_rdlock (&r)) != 0)
+ {
+ printf ("rwlock_rdlock failed: %d\n", ret);
+ return 1;
+ }
+
+ if ((ret = pthread_rwlock_unlock (&r)) != 0)
+ {
+ printf ("rwlock_unlock failed: %d\n", ret);
+ return 1;
+ }
+
+ if ((ret = pthread_rwlock_wrlock (&r)) != 0)
+ {
+ printf ("rwlock_wrlock failed: %d\n", ret);
+ return 1;
+ }
+
+ if ((ret = pthread_rwlock_unlock (&r)) != 0)
+ {
+ printf ("second rwlock_unlock failed: %d\n", ret);
+ return 1;
+ }
+
+ if ((ret = pthread_rwlock_destroy (&r)) != 0)
+ {
+ printf ("second rwlock_destroy failed: %d\n", ret);
+ return 1;
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-rwlock14.c b/test/nptl/tst-rwlock14.c
new file mode 100644
index 000000000..953d80282
--- /dev/null
+++ b/test/nptl/tst-rwlock14.c
@@ -0,0 +1,168 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
+
+ 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 <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+
+
+static pthread_barrier_t b;
+static pthread_rwlock_t r = PTHREAD_RWLOCK_INITIALIZER;
+
+
+static void *
+tf (void *arg)
+{
+ /* Lock the read-write lock. */
+ if (pthread_rwlock_wrlock (&r) != 0)
+ {
+ puts ("tf: cannot lock rwlock");
+ exit (EXIT_FAILURE);
+ }
+
+ pthread_t mt = *(pthread_t *) arg;
+
+ pthread_barrier_wait (&b);
+
+ /* This call will never return. */
+ pthread_join (mt, NULL);
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ int result = 0;
+ struct timespec ts;
+
+ if (clock_gettime (CLOCK_REALTIME, &ts) != 0)
+ {
+ puts ("clock_gettime failed");
+ return 1;
+ }
+
+ if (pthread_barrier_init (&b, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ return 1;
+ }
+
+ pthread_t me = pthread_self ();
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, &me) != 0)
+ {
+ puts ("create failed");
+ return 1;
+ }
+
+ /* Wait until the rwlock is locked. */
+ pthread_barrier_wait (&b);
+
+ ts.tv_nsec = -1;
+
+ int e = pthread_rwlock_timedrdlock (&r, &ts);
+ if (e == 0)
+ {
+ puts ("first rwlock_timedrdlock did not fail");
+ result = 1;
+ }
+ else if (e != EINVAL)
+ {
+ puts ("first rwlock_timedrdlock did not return EINVAL");
+ result = 1;
+ }
+
+ e = pthread_rwlock_timedwrlock (&r, &ts);
+ if (e == 0)
+ {
+ puts ("first rwlock_timedwrlock did not fail");
+ result = 1;
+ }
+ else if (e != EINVAL)
+ {
+ puts ("first rwlock_timedwrlock did not return EINVAL");
+ result = 1;
+ }
+
+ ts.tv_nsec = 1000000000;
+
+ e = pthread_rwlock_timedrdlock (&r, &ts);
+ if (e == 0)
+ {
+ puts ("second rwlock_timedrdlock did not fail");
+ result = 1;
+ }
+ else if (e != EINVAL)
+ {
+ puts ("second rwlock_timedrdlock did not return EINVAL");
+ result = 1;
+ }
+
+ e = pthread_rwlock_timedrdlock (&r, &ts);
+ if (e == 0)
+ {
+ puts ("second rwlock_timedrdlock did not fail");
+ result = 1;
+ }
+ else if (e != EINVAL)
+ {
+ puts ("second rwlock_timedrdlock did not return EINVAL");
+ result = 1;
+ }
+
+ ts.tv_nsec = 0x100001000LL;
+ if (ts.tv_nsec != 0x100001000LL)
+ ts.tv_nsec = 2000000000;
+
+ e = pthread_rwlock_timedrdlock (&r, &ts);
+ if (e == 0)
+ {
+ puts ("third rwlock_timedrdlock did not fail");
+ result = 1;
+ }
+ else if (e != EINVAL)
+ {
+ puts ("third rwlock_timedrdlock did not return EINVAL");
+ result = 1;
+ }
+
+ e = pthread_rwlock_timedrdlock (&r, &ts);
+ if (e == 0)
+ {
+ puts ("third rwlock_timedrdlock did not fail");
+ result = 1;
+ }
+ else if (e != EINVAL)
+ {
+ puts ("third rwlock_timedrdlock did not return EINVAL");
+ result = 1;
+ }
+
+ if (result == 0)
+ puts ("no bugs");
+
+ return result;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-rwlock2.c b/test/nptl/tst-rwlock2.c
new file mode 100644
index 000000000..a74ce864c
--- /dev/null
+++ b/test/nptl/tst-rwlock2.c
@@ -0,0 +1,142 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+
+
+static int
+do_test (void)
+{
+ pthread_rwlock_t r;
+ int e;
+
+ if (pthread_rwlock_init (&r, NULL) != 0)
+ {
+ puts ("rwlock_init failed");
+ return 1;
+ }
+ puts ("rwlock_init succeeded");
+
+ if (pthread_rwlock_wrlock (&r) != 0)
+ {
+ puts ("1st rwlock_wrlock failed");
+ return 1;
+ }
+ puts ("1st rwlock_wrlock succeeded");
+
+ e = pthread_rwlock_tryrdlock (&r);
+ if (e == 0)
+ {
+ puts ("rwlock_tryrdlock on rwlock with writer succeeded");
+ return 1;
+ }
+ if (e != EBUSY)
+ {
+ puts ("rwlock_tryrdlock on rwlock with writer return value != EBUSY");
+ return 1;
+ }
+ puts ("rwlock_tryrdlock on rwlock with writer failed with EBUSY");
+
+ e = pthread_rwlock_trywrlock (&r);
+ if (e == 0)
+ {
+ puts ("rwlock_trywrlock on rwlock with writer succeeded");
+ return 1;
+ }
+ if (e != EBUSY)
+ {
+ puts ("rwlock_trywrlock on rwlock with writer return value != EBUSY");
+ return 1;
+ }
+ puts ("rwlock_trywrlock on rwlock with writer failed with EBUSY");
+
+ if (pthread_rwlock_unlock (&r) != 0)
+ {
+ puts ("1st rwlock_unlock failed");
+ return 1;
+ }
+ puts ("1st rwlock_unlock succeeded");
+
+ if (pthread_rwlock_tryrdlock (&r) != 0)
+ {
+ puts ("rwlock_tryrdlock on unlocked rwlock failed");
+ return 1;
+ }
+ puts ("rwlock_tryrdlock on unlocked rwlock succeeded");
+
+ e = pthread_rwlock_trywrlock (&r);
+ if (e == 0)
+ {
+ puts ("rwlock_trywrlock on rwlock with reader succeeded");
+ return 1;
+ }
+ if (e != EBUSY)
+ {
+ puts ("rwlock_trywrlock on rwlock with reader return value != EBUSY");
+ return 1;
+ }
+ puts ("rwlock_trywrlock on rwlock with reader failed with EBUSY");
+
+ if (pthread_rwlock_unlock (&r) != 0)
+ {
+ puts ("2nd rwlock_unlock failed");
+ return 1;
+ }
+ puts ("2nd rwlock_unlock succeeded");
+
+ if (pthread_rwlock_trywrlock (&r) != 0)
+ {
+ puts ("rwlock_trywrlock on unlocked rwlock failed");
+ return 1;
+ }
+ puts ("rwlock_trywrlock on unlocked rwlock succeeded");
+
+ e = pthread_rwlock_tryrdlock (&r);
+ if (e == 0)
+ {
+ puts ("rwlock_tryrdlock on rwlock with writer succeeded");
+ return 1;
+ }
+ if (e != EBUSY)
+ {
+ puts ("rwlock_tryrdlock on rwlock with writer return value != EBUSY");
+ return 1;
+ }
+ puts ("rwlock_tryrdlock on rwlock with writer failed with EBUSY");
+
+ if (pthread_rwlock_unlock (&r) != 0)
+ {
+ puts ("3rd rwlock_unlock failed");
+ return 1;
+ }
+ puts ("3rd rwlock_unlock succeeded");
+
+ if (pthread_rwlock_destroy (&r) != 0)
+ {
+ puts ("rwlock_destroy failed");
+ return 1;
+ }
+ puts ("rwlock_destroy succeeded");
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-rwlock2a.c b/test/nptl/tst-rwlock2a.c
new file mode 100644
index 000000000..615de5c01
--- /dev/null
+++ b/test/nptl/tst-rwlock2a.c
@@ -0,0 +1,2 @@
+#define TYPE PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP
+#include "tst-rwlock2.c"
diff --git a/test/nptl/tst-rwlock3.c b/test/nptl/tst-rwlock3.c
new file mode 100644
index 000000000..1cb533896
--- /dev/null
+++ b/test/nptl/tst-rwlock3.c
@@ -0,0 +1,92 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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/>. */
+
+/* This test case checks more than standard compliance. An
+ implementation may provide this service but it is not required to
+ do so. */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+
+
+static int
+do_test (void)
+{
+ pthread_rwlock_t r;
+ int e;
+
+ if (pthread_rwlock_init (&r, NULL) != 0)
+ {
+ puts ("rwlock_init failed");
+ return 1;
+ }
+ puts ("rwlock_init succeeded");
+
+ if (pthread_rwlock_trywrlock (&r) != 0)
+ {
+ puts ("rwlock_trywrlock on unlocked rwlock failed");
+ return 1;
+ }
+ puts ("rwlock_trywrlock on unlocked rwlock succeeded");
+
+ e = pthread_rwlock_rdlock (&r);
+ if (e == 0)
+ {
+ puts ("rwlock_rdlock on rwlock with writer succeeded");
+ return 1;
+ }
+ if (e != EDEADLK)
+ {
+ puts ("rwlock_rdlock on rwlock with writer failed != EDEADLK");
+ return 1;
+ }
+ puts ("rwlock_rdlock on rwlock with writer failed with EDEADLK");
+
+ e = pthread_rwlock_wrlock (&r);
+ if (e == 0)
+ {
+ puts ("rwlock_wrlock on rwlock with writer succeeded");
+ return 1;
+ }
+ if (e != EDEADLK)
+ {
+ puts ("rwlock_wrlock on rwlock with writer failed != EDEADLK");
+ return 1;
+ }
+ puts ("rwlock_wrlock on rwlock with writer failed with EDEADLK");
+
+ if (pthread_rwlock_unlock (&r) != 0)
+ {
+ puts ("rwlock_unlock failed");
+ return 1;
+ }
+ puts ("rwlock_unlock succeeded");
+
+ if (pthread_rwlock_destroy (&r) != 0)
+ {
+ puts ("rwlock_destroy failed");
+ return 1;
+ }
+ puts ("rwlock_destroy succeeded");
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-rwlock4.c b/test/nptl/tst-rwlock4.c
new file mode 100644
index 000000000..0bbf083e7
--- /dev/null
+++ b/test/nptl/tst-rwlock4.c
@@ -0,0 +1,189 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <pthread.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+
+
+static int
+do_test (void)
+{
+ size_t ps = sysconf (_SC_PAGESIZE);
+ char tmpfname[] = "/tmp/tst-rwlock4.XXXXXX";
+ char data[ps];
+ void *mem;
+ int fd;
+ pthread_rwlock_t *r;
+ pthread_rwlockattr_t a;
+ pid_t pid;
+ char *p;
+ int err;
+ int s;
+
+ fd = mkstemp (tmpfname);
+ if (fd == -1)
+ {
+ printf ("cannot open temporary file: %m\n");
+ return 1;
+ }
+
+ /* Make sure it is always removed. */
+ unlink (tmpfname);
+
+ /* Create one page of data. */
+ memset (data, '\0', ps);
+
+ /* Write the data to the file. */
+ if (write (fd, data, ps) != (ssize_t) ps)
+ {
+ puts ("short write");
+ return 1;
+ }
+
+ mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ if (mem == MAP_FAILED)
+ {
+ printf ("mmap failed: %m\n");
+ return 1;
+ }
+
+ r = (pthread_rwlock_t *) (((uintptr_t) mem + __alignof (pthread_rwlock_t))
+ & ~(__alignof (pthread_rwlock_t) - 1));
+ p = (char *) (r + 1);
+
+ if (pthread_rwlockattr_init (&a) != 0)
+ {
+ puts ("rwlockattr_init failed");
+ return 1;
+ }
+
+ if (pthread_rwlockattr_getpshared (&a, &s) != 0)
+ {
+ puts ("1st rwlockattr_getpshared failed");
+ return 1;
+ }
+
+ if (s != PTHREAD_PROCESS_PRIVATE)
+ {
+ puts ("default pshared value wrong");
+ return 1;
+ }
+
+ if (pthread_rwlockattr_setpshared (&a, PTHREAD_PROCESS_SHARED) != 0)
+ {
+ puts ("rwlockattr_setpshared failed");
+ return 1;
+ }
+
+ if (pthread_rwlockattr_getpshared (&a, &s) != 0)
+ {
+ puts ("2nd rwlockattr_getpshared failed");
+ return 1;
+ }
+
+ if (s != PTHREAD_PROCESS_SHARED)
+ {
+ puts ("pshared value after setpshared call wrong");
+ return 1;
+ }
+
+ if (pthread_rwlock_init (r, &a) != 0)
+ {
+ puts ("rwlock_init failed");
+ return 1;
+ }
+
+ if (pthread_rwlock_rdlock (r) != 0)
+ {
+ puts ("rwlock_rdlock failed");
+ return 1;
+ }
+
+ if (pthread_rwlockattr_destroy (&a) != 0)
+ {
+ puts ("rwlockattr_destroy failed");
+ return 1;
+ }
+
+ err = pthread_rwlock_trywrlock (r);
+ if (err == 0)
+ {
+ puts ("rwlock_trywrlock succeeded");
+ return 1;
+ }
+ else if (err != EBUSY)
+ {
+ puts ("rwlock_trywrlock didn't return EBUSY");
+ return 1;
+ }
+
+ *p = 0;
+
+ puts ("going to fork now");
+ pid = fork ();
+ if (pid == -1)
+ {
+ puts ("fork failed");
+ return 1;
+ }
+ else if (pid == 0)
+ {
+ /* Play some lock ping-pong. It's our turn to unlock first. */
+ if ((*p)++ != 0)
+ {
+ puts ("child: *p != 0");
+ return 1;
+ }
+
+ if (pthread_rwlock_unlock (r) != 0)
+ {
+ puts ("child: 1st rwlock_unlock failed");
+ return 1;
+ }
+
+ puts ("child done");
+ }
+ else
+ {
+ if (pthread_rwlock_wrlock (r) != 0)
+ {
+ puts ("parent: rwlock_wrlock failed");
+ return 1;
+ }
+
+ if (*p != 1)
+ {
+ puts ("*p != 1");
+ return 1;
+ }
+
+ puts ("parent done");
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-rwlock5.c b/test/nptl/tst-rwlock5.c
new file mode 100644
index 000000000..4914afdca
--- /dev/null
+++ b/test/nptl/tst-rwlock5.c
@@ -0,0 +1,86 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
+static pthread_rwlock_t r;
+
+
+static void *
+tf (void *arg)
+{
+ if (pthread_rwlock_wrlock (&r) == 0)
+ {
+ puts ("child: rwlock_wrlock succeeded");
+ exit (1);
+ }
+
+ puts ("child: rwlock_wrlock returned");
+
+ exit (1);
+}
+
+
+static int
+do_test (void)
+{
+ pthread_t th;
+
+ if (pthread_rwlock_init (&r, NULL) != 0)
+ {
+ puts ("rwlock_init failed");
+ return 1;
+ }
+
+ if (pthread_rwlock_wrlock (&r) != 0)
+ {
+ puts ("rwlock_wrlock failed");
+ return 1;
+ }
+
+ if (pthread_mutex_lock (&m) != 0)
+ {
+ puts ("mutex_lock failed");
+ return 1;
+ }
+
+ /* Set an alarm for 1 second. The wrapper will expect this. */
+ alarm (1);
+
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ return 1;
+ }
+
+ /* This call should never return. */
+ pthread_mutex_lock (&m);
+
+ puts ("2nd mutex_lock returned");
+ return 1;
+}
+
+#define EXPECTED_SIGNAL SIGALRM
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-rwlock6.c b/test/nptl/tst-rwlock6.c
new file mode 100644
index 000000000..78d07167a
--- /dev/null
+++ b/test/nptl/tst-rwlock6.c
@@ -0,0 +1,225 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/time.h>
+
+
+static int kind[] =
+ {
+ PTHREAD_RWLOCK_PREFER_READER_NP,
+ PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,
+ PTHREAD_RWLOCK_PREFER_WRITER_NP,
+ };
+
+
+static void *
+tf (void *arg)
+{
+ pthread_rwlock_t *r = arg;
+
+ /* Timeout: 0.3 secs. */
+ struct timeval tv;
+ (void) gettimeofday (&tv, NULL);
+
+ struct timespec ts;
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+ ts.tv_nsec += 300000000;
+ if (ts.tv_nsec >= 1000000000)
+ {
+ ts.tv_nsec -= 1000000000;
+ ++ts.tv_sec;
+ }
+
+ puts ("child calling timedrdlock");
+
+ int err = pthread_rwlock_timedrdlock (r, &ts);
+ if (err == 0)
+ {
+ puts ("rwlock_timedrdlock returned");
+ pthread_exit ((void *) 1l);
+ }
+
+ if (err != ETIMEDOUT)
+ {
+ printf ("err = %s (%d), expected %s (%d)\n",
+ strerror (err), err, strerror (ETIMEDOUT), ETIMEDOUT);
+ pthread_exit ((void *) 1l);
+ }
+
+ puts ("1st child timedrdlock done");
+
+ struct timeval tv2;
+ (void) gettimeofday (&tv2, NULL);
+
+ timersub (&tv2, &tv, &tv);
+
+ if (tv.tv_usec < 200000)
+ {
+ puts ("timeout too short");
+ pthread_exit ((void *) 1l);
+ }
+
+ (void) gettimeofday (&tv, NULL);
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+ ts.tv_sec += 10;
+ /* Note that the following operation makes ts invalid. */
+ ts.tv_nsec += 1000000000;
+
+ err = pthread_rwlock_timedrdlock (r, &ts);
+ if (err == 0)
+ {
+ puts ("2nd timedrdlock succeeded");
+ pthread_exit ((void *) 1l);
+ }
+ if (err != EINVAL)
+ {
+ puts ("2nd timedrdlock did not return EINVAL");
+ pthread_exit ((void *) 1l);
+ }
+
+ puts ("2nd child timedrdlock done");
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ size_t cnt;
+ for (cnt = 0; cnt < sizeof (kind) / sizeof (kind[0]); ++cnt)
+ {
+ pthread_rwlock_t r;
+ pthread_rwlockattr_t a;
+
+ if (pthread_rwlockattr_init (&a) != 0)
+ {
+ printf ("round %Zu: rwlockattr_t failed\n", cnt);
+ exit (1);
+ }
+
+ if (pthread_rwlockattr_setkind_np (&a, kind[cnt]) != 0)
+ {
+ printf ("round %Zu: rwlockattr_setkind failed\n", cnt);
+ exit (1);
+ }
+
+ if (pthread_rwlock_init (&r, &a) != 0)
+ {
+ printf ("round %Zu: rwlock_init failed\n", cnt);
+ exit (1);
+ }
+
+ if (pthread_rwlockattr_destroy (&a) != 0)
+ {
+ printf ("round %Zu: rwlockattr_destroy failed\n", cnt);
+ exit (1);
+ }
+
+ struct timeval tv;
+ (void) gettimeofday (&tv, NULL);
+
+ struct timespec ts;
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+
+ ++ts.tv_sec;
+
+ /* Get a write lock. */
+ int e = pthread_rwlock_timedwrlock (&r, &ts);
+ if (e != 0)
+ {
+ printf ("round %Zu: rwlock_timedwrlock failed (%d)\n", cnt, e);
+ exit (1);
+ }
+
+ puts ("1st timedwrlock done");
+
+ (void) gettimeofday (&tv, NULL);
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+ ++ts.tv_sec;
+ e = pthread_rwlock_timedrdlock (&r, &ts);
+ if (e == 0)
+ {
+ puts ("timedrdlock succeeded");
+ exit (1);
+ }
+ if (e != EDEADLK)
+ {
+ puts ("timedrdlock did not return EDEADLK");
+ exit (1);
+ }
+
+ puts ("1st timedrdlock done");
+
+ (void) gettimeofday (&tv, NULL);
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+ ++ts.tv_sec;
+ e = pthread_rwlock_timedwrlock (&r, &ts);
+ if (e == 0)
+ {
+ puts ("2nd timedwrlock succeeded");
+ exit (1);
+ }
+ if (e != EDEADLK)
+ {
+ puts ("2nd timedwrlock did not return EDEADLK");
+ exit (1);
+ }
+
+ puts ("2nd timedwrlock done");
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, &r) != 0)
+ {
+ printf ("round %Zu: create failed\n", cnt);
+ exit (1);
+ }
+
+ puts ("started thread");
+
+ void *status;
+ if (pthread_join (th, &status) != 0)
+ {
+ printf ("round %Zu: join failed\n", cnt);
+ exit (1);
+ }
+ if (status != NULL)
+ {
+ printf ("failure in round %Zu\n", cnt);
+ exit (1);
+ }
+
+ puts ("joined thread");
+
+ if (pthread_rwlock_destroy (&r) != 0)
+ {
+ printf ("round %Zu: rwlock_destroy failed\n", cnt);
+ exit (1);
+ }
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-rwlock7.c b/test/nptl/tst-rwlock7.c
new file mode 100644
index 000000000..5189a4781
--- /dev/null
+++ b/test/nptl/tst-rwlock7.c
@@ -0,0 +1,178 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/time.h>
+
+
+static int kind[] =
+ {
+ PTHREAD_RWLOCK_PREFER_READER_NP,
+ PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,
+ PTHREAD_RWLOCK_PREFER_WRITER_NP,
+ };
+
+
+static void *
+tf (void *arg)
+{
+ pthread_rwlock_t *r = arg;
+
+ /* Timeout: 0.3 secs. */
+ struct timeval tv;
+ (void) gettimeofday (&tv, NULL);
+
+ struct timespec ts;
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+ ts.tv_nsec += 300000000;
+ if (ts.tv_nsec >= 1000000000)
+ {
+ ts.tv_nsec -= 1000000000;
+ ++ts.tv_sec;
+ }
+
+ int err = pthread_rwlock_timedwrlock (r, &ts);
+ if (err == 0)
+ {
+ puts ("rwlock_timedwrlock returned");
+ pthread_exit ((void *) 1l);
+ }
+
+ if (err != ETIMEDOUT)
+ {
+ printf ("err = %s (%d), expected %s (%d)\n",
+ strerror (err), err, strerror (ETIMEDOUT), ETIMEDOUT);
+ pthread_exit ((void *) 1l);
+ }
+
+ struct timeval tv2;
+ (void) gettimeofday (&tv2, NULL);
+
+ timersub (&tv2, &tv, &tv);
+
+ if (tv.tv_usec < 200000)
+ {
+ puts ("timeout too short");
+ pthread_exit ((void *) 1l);
+ }
+
+ (void) gettimeofday (&tv, NULL);
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+ ts.tv_sec += 10;
+ /* Note that the following operation makes ts invalid. */
+ ts.tv_nsec += 1000000000;
+
+ err = pthread_rwlock_timedwrlock (r, &ts);
+ if (err == 0)
+ {
+ puts ("2nd timedwrlock succeeded");
+ pthread_exit ((void *) 1l);
+ }
+ if (err != EINVAL)
+ {
+ puts ("2nd timedwrlock did not return EINVAL");
+ pthread_exit ((void *) 1l);
+ }
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ size_t cnt;
+ for (cnt = 0; cnt < sizeof (kind) / sizeof (kind[0]); ++cnt)
+ {
+ pthread_rwlock_t r;
+ pthread_rwlockattr_t a;
+
+ if (pthread_rwlockattr_init (&a) != 0)
+ {
+ printf ("round %Zu: rwlockattr_t failed\n", cnt);
+ exit (1);
+ }
+
+ if (pthread_rwlockattr_setkind_np (&a, kind[cnt]) != 0)
+ {
+ printf ("round %Zu: rwlockattr_setkind failed\n", cnt);
+ exit (1);
+ }
+
+ if (pthread_rwlock_init (&r, &a) != 0)
+ {
+ printf ("round %Zu: rwlock_init failed\n", cnt);
+ exit (1);
+ }
+
+ if (pthread_rwlockattr_destroy (&a) != 0)
+ {
+ printf ("round %Zu: rwlockattr_destroy failed\n", cnt);
+ exit (1);
+ }
+
+ struct timeval tv;
+ (void) gettimeofday (&tv, NULL);
+
+ struct timespec ts;
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+
+ ++ts.tv_sec;
+
+ /* Get a read lock. */
+ if (pthread_rwlock_timedrdlock (&r, &ts) != 0)
+ {
+ printf ("round %Zu: rwlock_timedrdlock failed\n", cnt);
+ exit (1);
+ }
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, &r) != 0)
+ {
+ printf ("round %Zu: create failed\n", cnt);
+ exit (1);
+ }
+
+ void *status;
+ if (pthread_join (th, &status) != 0)
+ {
+ printf ("round %Zu: join failed\n", cnt);
+ exit (1);
+ }
+ if (status != NULL)
+ {
+ printf ("failure in round %Zu\n", cnt);
+ exit (1);
+ }
+
+ if (pthread_rwlock_destroy (&r) != 0)
+ {
+ printf ("round %Zu: rwlock_destroy failed\n", cnt);
+ exit (1);
+ }
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-rwlock8.c b/test/nptl/tst-rwlock8.c
new file mode 100644
index 000000000..b67e55a17
--- /dev/null
+++ b/test/nptl/tst-rwlock8.c
@@ -0,0 +1,163 @@
+/* Test program for timedout read/write lock functions.
+ Copyright (C) 2000, 2003 Free Software Foundation, Inc.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2000.
+
+ 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/>. */
+
+#include <errno.h>
+#include <error.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <unistd.h>
+
+
+#define NWRITERS 15
+#define WRITETRIES 10
+#define NREADERS 15
+#define READTRIES 15
+
+#define DELAY 1000000
+
+#ifndef INIT
+# define INIT PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP
+#endif
+
+static pthread_rwlock_t lock = INIT;
+
+
+static void *
+writer_thread (void *nr)
+{
+ struct timespec delay;
+ int n;
+
+ delay.tv_sec = 0;
+ delay.tv_nsec = DELAY;
+
+ for (n = 0; n < WRITETRIES; ++n)
+ {
+ printf ("writer thread %ld tries again\n", (long int) nr);
+
+ if (pthread_rwlock_wrlock (&lock) != 0)
+ {
+ puts ("wrlock failed");
+ exit (1);
+ }
+
+ printf ("writer thread %ld succeeded\n", (long int) nr);
+
+ nanosleep (&delay, NULL);
+
+ if (pthread_rwlock_unlock (&lock) != 0)
+ {
+ puts ("unlock for writer failed");
+ exit (1);
+ }
+
+ printf ("writer thread %ld released\n", (long int) nr);
+ }
+
+ return NULL;
+}
+
+
+static void *
+reader_thread (void *nr)
+{
+ struct timespec delay;
+ int n;
+
+ delay.tv_sec = 0;
+ delay.tv_nsec = DELAY;
+
+ for (n = 0; n < READTRIES; ++n)
+ {
+ printf ("reader thread %ld tries again\n", (long int) nr);
+
+ if (pthread_rwlock_rdlock (&lock) != 0)
+ {
+ puts ("rdlock failed");
+ exit (1);
+ }
+
+ printf ("reader thread %ld succeeded\n", (long int) nr);
+
+ nanosleep (&delay, NULL);
+
+ if (pthread_rwlock_unlock (&lock) != 0)
+ {
+ puts ("unlock for reader failed");
+ exit (1);
+ }
+
+ printf ("reader thread %ld released\n", (long int) nr);
+ }
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ pthread_t thwr[NWRITERS];
+ pthread_t thrd[NREADERS];
+ int n;
+ void *res;
+
+ /* Make standard error the same as standard output. */
+ dup2 (1, 2);
+
+ /* Make sure we see all message, even those on stdout. */
+ setvbuf (stdout, NULL, _IONBF, 0);
+
+ for (n = 0; n < NWRITERS; ++n)
+ if (pthread_create (&thwr[n], NULL, writer_thread,
+ (void *) (long int) n) != 0)
+ {
+ puts ("writer create failed");
+ exit (1);
+ }
+
+ for (n = 0; n < NREADERS; ++n)
+ if (pthread_create (&thrd[n], NULL, reader_thread,
+ (void *) (long int) n) != 0)
+ {
+ puts ("reader create failed");
+ exit (1);
+ }
+
+ /* Wait for all the threads. */
+ for (n = 0; n < NWRITERS; ++n)
+ if (pthread_join (thwr[n], &res) != 0)
+ {
+ puts ("writer join failed");
+ exit (1);
+ }
+ for (n = 0; n < NREADERS; ++n)
+ if (pthread_join (thrd[n], &res) != 0)
+ {
+ puts ("reader join failed");
+ exit (1);
+ }
+
+ return 0;
+}
+
+#define TIMEOUT 30
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-rwlock9.c b/test/nptl/tst-rwlock9.c
new file mode 100644
index 000000000..e9f015120
--- /dev/null
+++ b/test/nptl/tst-rwlock9.c
@@ -0,0 +1,202 @@
+/* Test program for timedout read/write lock functions.
+ Copyright (C) 2000, 2003 Free Software Foundation, Inc.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2000.
+
+ 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/>. */
+
+#include <errno.h>
+#include <error.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <unistd.h>
+#include <sys/time.h>
+
+
+#define NWRITERS 15
+#define WRITETRIES 10
+#define NREADERS 15
+#define READTRIES 15
+
+#define TIMEOUT 1000000
+#define DELAY 1000000
+
+#ifndef INIT
+# define INIT PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP
+#endif
+
+static pthread_rwlock_t lock = INIT;
+
+
+static void *
+writer_thread (void *nr)
+{
+ struct timespec ts;
+ struct timespec delay;
+ int n;
+
+ delay.tv_sec = 0;
+ delay.tv_nsec = DELAY;
+
+ for (n = 0; n < WRITETRIES; ++n)
+ {
+ int e;
+ do
+ {
+ struct timeval tv;
+ (void) gettimeofday (&tv, NULL);
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+
+ ts.tv_nsec += 2 * TIMEOUT;
+ if (ts.tv_nsec >= 1000000000)
+ {
+ ts.tv_nsec -= 1000000000;
+ ++ts.tv_sec;
+ }
+
+ printf ("writer thread %ld tries again\n", (long int) nr);
+
+ e = pthread_rwlock_timedwrlock (&lock, &ts);
+ if (e != 0 && e != ETIMEDOUT)
+ {
+ puts ("timedwrlock failed");
+ exit (1);
+ }
+ }
+ while (e == ETIMEDOUT);
+
+ printf ("writer thread %ld succeeded\n", (long int) nr);
+
+ nanosleep (&delay, NULL);
+
+ if (pthread_rwlock_unlock (&lock) != 0)
+ {
+ puts ("unlock for writer failed");
+ exit (1);
+ }
+
+ printf ("writer thread %ld released\n", (long int) nr);
+ }
+
+ return NULL;
+}
+
+
+static void *
+reader_thread (void *nr)
+{
+ struct timespec ts;
+ struct timespec delay;
+ int n;
+
+ delay.tv_sec = 0;
+ delay.tv_nsec = DELAY;
+
+ for (n = 0; n < READTRIES; ++n)
+ {
+ int e;
+ do
+ {
+ struct timeval tv;
+ (void) gettimeofday (&tv, NULL);
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+
+ ts.tv_nsec += TIMEOUT;
+ if (ts.tv_nsec >= 1000000000)
+ {
+ ts.tv_nsec -= 1000000000;
+ ++ts.tv_sec;
+ }
+
+ printf ("reader thread %ld tries again\n", (long int) nr);
+
+ e = pthread_rwlock_timedrdlock (&lock, &ts);
+ if (e != 0 && e != ETIMEDOUT)
+ {
+ puts ("timedrdlock failed");
+ exit (1);
+ }
+ }
+ while (e == ETIMEDOUT);
+
+ printf ("reader thread %ld succeeded\n", (long int) nr);
+
+ nanosleep (&delay, NULL);
+
+ if (pthread_rwlock_unlock (&lock) != 0)
+ {
+ puts ("unlock for reader failed");
+ exit (1);
+ }
+
+ printf ("reader thread %ld released\n", (long int) nr);
+ }
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ pthread_t thwr[NWRITERS];
+ pthread_t thrd[NREADERS];
+ int n;
+ void *res;
+
+ /* Make standard error the same as standard output. */
+ dup2 (1, 2);
+
+ /* Make sure we see all message, even those on stdout. */
+ setvbuf (stdout, NULL, _IONBF, 0);
+
+ for (n = 0; n < NWRITERS; ++n)
+ if (pthread_create (&thwr[n], NULL, writer_thread,
+ (void *) (long int) n) != 0)
+ {
+ puts ("writer create failed");
+ exit (1);
+ }
+
+ for (n = 0; n < NREADERS; ++n)
+ if (pthread_create (&thrd[n], NULL, reader_thread,
+ (void *) (long int) n) != 0)
+ {
+ puts ("reader create failed");
+ exit (1);
+ }
+
+ /* Wait for all the threads. */
+ for (n = 0; n < NWRITERS; ++n)
+ if (pthread_join (thwr[n], &res) != 0)
+ {
+ puts ("writer join failed");
+ exit (1);
+ }
+ for (n = 0; n < NREADERS; ++n)
+ if (pthread_join (thrd[n], &res) != 0)
+ {
+ puts ("reader join failed");
+ exit (1);
+ }
+
+ return 0;
+}
+
+#undef TIMEOUT
+#define TIMEOUT 30
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-sched1.c b/test/nptl/tst-sched1.c
new file mode 100644
index 000000000..be3f1b84e
--- /dev/null
+++ b/test/nptl/tst-sched1.c
@@ -0,0 +1,97 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+
+static int global;
+
+static void *
+tf (void *a)
+{
+ global = 1;
+
+ return 0;
+}
+
+
+int
+do_test (void)
+{
+ pthread_t th;
+ pthread_attr_t at;
+
+ if (pthread_attr_init (&at) != 0)
+ {
+ puts ("attr_init failed");
+ return 1;
+ }
+
+ if (pthread_attr_setschedpolicy (&at, SCHED_OTHER) != 0)
+ {
+ puts ("attr_setschedpolicy failed");
+ return 1;
+ }
+
+ struct sched_param pa;
+ if (sched_getparam (getpid (), &pa) != 0)
+ {
+ puts ("sched_getschedparam failed");
+ return 1;
+ }
+
+ if (pthread_attr_setschedparam (&at, &pa) != 0)
+ {
+ puts ("attr_setschedparam failed");
+ return 1;
+ }
+
+ if (pthread_attr_setinheritsched (&at, PTHREAD_EXPLICIT_SCHED) != 0)
+ {
+ puts ("attr_setinheritsched failed");
+ return 1;
+ }
+
+ if (pthread_create (&th, &at, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ return 1;
+ }
+
+ int e = pthread_join (th, NULL);
+ if (e != 0)
+ {
+ printf ("join failed: %d\n", e);
+ return 1;
+ }
+
+ if (global == 0)
+ {
+ puts ("thread didn't run");
+ return 1;
+ }
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-sem1.c b/test/nptl/tst-sem1.c
new file mode 100644
index 000000000..5e55dd38d
--- /dev/null
+++ b/test/nptl/tst-sem1.c
@@ -0,0 +1,88 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <semaphore.h>
+#include <stdio.h>
+#include <unistd.h>
+
+
+static int
+do_test (void)
+{
+ sem_t s;
+
+ if (sem_init (&s, 0, 1) == -1)
+ {
+ puts ("init failed");
+ return 1;
+ }
+
+ if (TEMP_FAILURE_RETRY (sem_wait (&s)) == -1)
+ {
+ puts ("1st wait failed");
+ return 1;
+ }
+
+ if (sem_post (&s) == -1)
+ {
+ puts ("1st post failed");
+ return 1;
+ }
+
+ if (TEMP_FAILURE_RETRY (sem_trywait (&s)) == -1)
+ {
+ puts ("1st trywait failed");
+ return 1;
+ }
+
+ errno = 0;
+ if (TEMP_FAILURE_RETRY (sem_trywait (&s)) != -1)
+ {
+ puts ("2nd trywait succeeded");
+ return 1;
+ }
+ else if (errno != EAGAIN)
+ {
+ puts ("2nd trywait did not set errno to EAGAIN");
+ return 1;
+ }
+
+ if (sem_post (&s) == -1)
+ {
+ puts ("2nd post failed");
+ return 1;
+ }
+
+ if (TEMP_FAILURE_RETRY (sem_wait (&s)) == -1)
+ {
+ puts ("2nd wait failed");
+ return 1;
+ }
+
+ if (sem_destroy (&s) == -1)
+ {
+ puts ("destroy failed");
+ return 1;
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-sem10.c b/test/nptl/tst-sem10.c
new file mode 100644
index 000000000..ae6218a60
--- /dev/null
+++ b/test/nptl/tst-sem10.c
@@ -0,0 +1,87 @@
+/* Copyright (C) 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2007.
+
+ 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 <pthread.h>
+#include <semaphore.h>
+#include <stdio.h>
+#include <time.h>
+#include <unistd.h>
+#include <sys/time.h>
+
+
+static int
+do_test (void)
+{
+ sem_t s;
+ if (sem_init (&s, 0, 0) == -1)
+ {
+ puts ("sem_init failed");
+ return 1;
+ }
+
+ struct timeval tv;
+ if (gettimeofday (&tv, NULL) != 0)
+ {
+ puts ("gettimeofday failed");
+ return 1;
+ }
+
+ struct timespec ts;
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+
+ /* Set ts to yesterday. */
+ ts.tv_sec -= 86400;
+
+ int type_before;
+ if (pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &type_before) != 0)
+ {
+ puts ("first pthread_setcanceltype failed");
+ return 1;
+ }
+
+ errno = 0;
+ if (TEMP_FAILURE_RETRY (sem_timedwait (&s, &ts)) != -1)
+ {
+ puts ("sem_timedwait succeeded");
+ return 1;
+ }
+ if (errno != ETIMEDOUT)
+ {
+ printf ("sem_timedwait return errno = %d instead of ETIMEDOUT\n",
+ errno);
+ return 1;
+ }
+
+ int type_after;
+ if (pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &type_after) != 0)
+ {
+ puts ("second pthread_setcanceltype failed");
+ return 1;
+ }
+ if (type_after != PTHREAD_CANCEL_DEFERRED)
+ {
+ puts ("sem_timedwait changed cancellation type");
+ return 1;
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-sem11.c b/test/nptl/tst-sem11.c
new file mode 100644
index 000000000..6633ddd1f
--- /dev/null
+++ b/test/nptl/tst-sem11.c
@@ -0,0 +1,76 @@
+#include <semaphore.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <internaltypes.h>
+
+#ifndef SEM_WAIT
+# define SEM_WAIT(s) sem_wait (s)
+#endif
+
+static void *
+tf (void *arg)
+{
+#ifdef PREPARE
+ PREPARE
+#endif
+ SEM_WAIT (arg);
+ return NULL;
+}
+
+int
+main (void)
+{
+ int tries = 5;
+ pthread_t th;
+ sem_t s;
+ again:
+ if (sem_init (&s, 0, 0) != 0)
+ {
+ puts ("sem_init failed");
+ return 1;
+ }
+
+ struct new_sem *is = (struct new_sem *) &s;
+
+ if (is->nwaiters != 0)
+ {
+ puts ("nwaiters not initialized");
+ return 1;
+ }
+
+ if (pthread_create (&th, NULL, tf, &s) != 0)
+ {
+ puts ("pthread_create failed");
+ return 1;
+ }
+
+ sleep (1);
+
+ if (pthread_cancel (th) != 0)
+ {
+ puts ("pthread_cancel failed");
+ return 1;
+ }
+
+ void *r;
+ if (pthread_join (th, &r) != 0)
+ {
+ puts ("pthread_join failed");
+ return 1;
+ }
+ if (r != PTHREAD_CANCELED && --tries > 0)
+ {
+ /* Maybe we get the scheduling right the next time. */
+ sem_destroy (&s);
+ goto again;
+ }
+
+ if (is->nwaiters != 0)
+ {
+ puts ("nwaiters not reset");
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/test/nptl/tst-sem12.c b/test/nptl/tst-sem12.c
new file mode 100644
index 000000000..71d02b70e
--- /dev/null
+++ b/test/nptl/tst-sem12.c
@@ -0,0 +1,14 @@
+#include <time.h>
+#include <sys/time.h>
+
+
+#define PREPARE \
+ struct timespec ts; \
+ struct timeval tv; \
+ gettimeofday (&tv, NULL); \
+ TIMEVAL_TO_TIMESPEC (&tv, &ts); \
+ ts.tv_sec += 60;
+
+#define SEM_WAIT(s) sem_timedwait (s, &ts)
+
+#include "tst-sem11.c"
diff --git a/test/nptl/tst-sem2.c b/test/nptl/tst-sem2.c
new file mode 100644
index 000000000..edc553c7b
--- /dev/null
+++ b/test/nptl/tst-sem2.c
@@ -0,0 +1,53 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <semaphore.h>
+#include <signal.h>
+#include <stdio.h>
+#include <unistd.h>
+
+
+static int
+do_test (void)
+{
+ sem_t s;
+
+ if (sem_init (&s, 0, 0) == -1)
+ {
+ puts ("init failed");
+ return 1;
+ }
+
+ /* Set an alarm for 1 second. The wrapper will expect this. */
+ alarm (1);
+
+ if (TEMP_FAILURE_RETRY (sem_wait (&s)) == -1)
+ {
+ puts ("wait failed");
+ return 1;
+ }
+
+ /* We should never get here. */
+ puts ("wait succeeded");
+ return 1;
+}
+
+#define EXPECTED_SIGNAL SIGALRM
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-sem3.c b/test/nptl/tst-sem3.c
new file mode 100644
index 000000000..7b75e29e2
--- /dev/null
+++ b/test/nptl/tst-sem3.c
@@ -0,0 +1,144 @@
+/* Copyright (C) 2002-2014 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <semaphore.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+
+
+int
+do_test (void)
+{
+ size_t ps = sysconf (_SC_PAGESIZE);
+ char tmpfname[] = "/tmp/tst-sem3.XXXXXX";
+ char data[ps];
+ void *mem;
+ int fd;
+ sem_t *s;
+ pid_t pid;
+ char *p;
+
+ fd = mkstemp (tmpfname);
+ if (fd == -1)
+ {
+ printf ("cannot open temporary file: %m\n");
+ return 1;
+ }
+
+ /* Make sure it is always removed. */
+ unlink (tmpfname);
+
+ /* Create one page of data. */
+ memset (data, '\0', ps);
+
+ /* Write the data to the file. */
+ if (write (fd, data, ps) != (ssize_t) ps)
+ {
+ puts ("short write");
+ return 1;
+ }
+
+ mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ if (mem == MAP_FAILED)
+ {
+ printf ("mmap failed: %m\n");
+ return 1;
+ }
+
+ s = (sem_t *) (((uintptr_t) mem + __alignof (sem_t))
+ & ~(__alignof (sem_t) - 1));
+ p = (char *) (s + 1);
+
+ if (sem_init (s, 1, 1) == -1)
+ {
+ puts ("init failed");
+ return 1;
+ }
+
+ if (TEMP_FAILURE_RETRY (sem_wait (s)) == -1)
+ {
+ puts ("1st wait failed");
+ return 1;
+ }
+
+ errno = 0;
+ if (TEMP_FAILURE_RETRY (sem_trywait (s)) != -1)
+ {
+ puts ("trywait succeeded");
+ return 1;
+ }
+ else if (errno != EAGAIN)
+ {
+ puts ("trywait didn't return EAGAIN");
+ return 1;
+ }
+
+ *p = 0;
+
+ puts ("going to fork now");
+ pid = fork ();
+ if (pid == -1)
+ {
+ puts ("fork failed");
+ return 1;
+ }
+ else if (pid == 0)
+ {
+ /* Play some lock ping-pong. It's our turn to unlock first. */
+ if ((*p)++ != 0)
+ {
+ puts ("child: *p != 0");
+ return 1;
+ }
+
+ if (sem_post (s) == -1)
+ {
+ puts ("child: 1st post failed");
+ return 1;
+ }
+
+ puts ("child done");
+ }
+ else
+ {
+ if (TEMP_FAILURE_RETRY (sem_wait (s)) == -1)
+ {
+ printf ("parent: 2nd wait failed: %m\n");
+ return 1;
+ }
+
+ if (*p != 1)
+ {
+ puts ("*p != 1");
+ return 1;
+ }
+
+ puts ("parent done");
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-sem4.c b/test/nptl/tst-sem4.c
new file mode 100644
index 000000000..72ed97d37
--- /dev/null
+++ b/test/nptl/tst-sem4.c
@@ -0,0 +1,149 @@
+/* Copyright (C) 2002-2014 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <fcntl.h>
+#include <semaphore.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static void
+remove_sem (int status, void *arg)
+{
+ sem_unlink (arg);
+}
+
+
+int
+do_test (void)
+{
+ sem_t *s;
+ sem_t *s2;
+ pid_t pid;
+ int val;
+
+ s = sem_open ("/glibc-tst-sem4", O_CREAT, 0600, 1);
+ if (s == SEM_FAILED)
+ {
+ if (errno == ENOSYS)
+ {
+ puts ("sem_open not supported. Oh well.");
+ return 0;
+ }
+
+ /* Maybe the shm filesystem has strict permissions. */
+ if (errno == EACCES)
+ {
+ puts ("sem_open not allowed. Oh well.");
+ return 0;
+ }
+
+ printf ("sem_open: %m\n");
+ return 1;
+ }
+
+ on_exit (remove_sem, (void *) "/glibc-tst-sem4");
+
+ /* We have the semaphore object. Now try again with O_EXCL, this
+ should fail. */
+ s2 = sem_open ("/glibc-tst-sem4", O_CREAT | O_EXCL, 0600, 1);
+ if (s2 != SEM_FAILED)
+ {
+ puts ("2nd sem_open didn't fail");
+ return 1;
+ }
+ if (errno != EEXIST)
+ {
+ puts ("2nd sem_open returned wrong error");
+ return 1;
+ }
+
+ /* Check the value. */
+ if (sem_getvalue (s, &val) == -1)
+ {
+ puts ("getvalue failed");
+ return 1;
+ }
+ if (val != 1)
+ {
+ printf ("initial value wrong: got %d, expected 1\n", val);
+ return 1;
+ }
+
+ if (TEMP_FAILURE_RETRY (sem_wait (s)) == -1)
+ {
+ puts ("1st sem_wait failed");
+ return 1;
+ }
+
+ pid = fork ();
+ if (pid == -1)
+ {
+ printf ("fork failed: %m\n");
+ return 1;
+ }
+
+ if (pid == 0)
+ {
+ /* Child. */
+
+ /* Check the value. */
+ if (sem_getvalue (s, &val) == -1)
+ {
+ puts ("child: getvalue failed");
+ return 1;
+ }
+ if (val != 0)
+ {
+ printf ("child: value wrong: got %d, expect 0\n", val);
+ return 1;
+ }
+
+ if (sem_post (s) == -1)
+ {
+ puts ("child: post failed");
+ return 1;
+ }
+ }
+ else
+ {
+ if (TEMP_FAILURE_RETRY (sem_wait (s)) == -1)
+ {
+ puts ("2nd sem_wait failed");
+ return 1;
+ }
+
+ if (sem_getvalue (s, &val) == -1)
+ {
+ puts ("parent: 2nd getvalue failed");
+ return 1;
+ }
+ if (val != 0)
+ {
+ printf ("parent: value wrong: got %d, expected 0\n", val);
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-sem5.c b/test/nptl/tst-sem5.c
new file mode 100644
index 000000000..f0b905c33
--- /dev/null
+++ b/test/nptl/tst-sem5.c
@@ -0,0 +1,79 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <semaphore.h>
+#include <stdio.h>
+#include <time.h>
+#include <unistd.h>
+#include <sys/time.h>
+
+
+static int
+do_test (void)
+{
+ sem_t s;
+ struct timespec ts;
+ struct timeval tv;
+
+ if (sem_init (&s, 0, 1) == -1)
+ {
+ puts ("sem_init failed");
+ return 1;
+ }
+
+ if (TEMP_FAILURE_RETRY (sem_wait (&s)) == -1)
+ {
+ puts ("sem_wait failed");
+ return 1;
+ }
+
+ if (gettimeofday (&tv, NULL) != 0)
+ {
+ puts ("gettimeofday failed");
+ return 1;
+ }
+
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+
+ /* We wait for half a second. */
+ ts.tv_nsec += 500000000;
+ if (ts.tv_nsec >= 1000000000)
+ {
+ ++ts.tv_sec;
+ ts.tv_nsec -= 1000000000;
+ }
+
+ errno = 0;
+ if (TEMP_FAILURE_RETRY (sem_timedwait (&s, &ts)) != -1)
+ {
+ puts ("sem_timedwait succeeded");
+ return 1;
+ }
+ if (errno != ETIMEDOUT)
+ {
+ printf ("sem_timedwait return errno = %d instead of ETIMEDOUT\n",
+ errno);
+ return 1;
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-sem6.c b/test/nptl/tst-sem6.c
new file mode 100644
index 000000000..16adb95ef
--- /dev/null
+++ b/test/nptl/tst-sem6.c
@@ -0,0 +1,80 @@
+/* Copyright (C) 2003 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 <errno.h>
+#include <semaphore.h>
+#include <signal.h>
+#include <stdio.h>
+#include <unistd.h>
+
+
+static void
+handler (int sig)
+{
+ struct sigaction sa;
+
+ sa.sa_handler = SIG_DFL;
+ sa.sa_flags = 0;
+ sigemptyset (&sa.sa_mask);
+
+ sigaction (SIGALRM, &sa, NULL);
+
+ /* Rearm the timer. */
+ alarm (1);
+}
+
+
+static int
+do_test (void)
+{
+ sem_t s;
+ struct sigaction sa;
+
+ sa.sa_handler = handler;
+ sa.sa_flags = 0;
+ sigemptyset (&sa.sa_mask);
+
+ sigaction (SIGALRM, &sa, NULL);
+
+ if (sem_init (&s, 0, 0) == -1)
+ {
+ puts ("init failed");
+ return 1;
+ }
+
+ /* Set an alarm for 1 second. The wrapper will expect this. */
+ alarm (1);
+
+ int res = sem_wait (&s);
+ if (res == 0)
+ {
+ puts ("wait succeeded");
+ return 1;
+ }
+ if (res != -1 || errno != EINTR)
+ {
+ puts ("wait didn't fail with EINTR");
+ return 1;
+ }
+
+ return 0;
+}
+
+#define TIMEOUT 3
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-sem7.c b/test/nptl/tst-sem7.c
new file mode 100644
index 000000000..34ddb4058
--- /dev/null
+++ b/test/nptl/tst-sem7.c
@@ -0,0 +1,108 @@
+/* Copyright (C) 2003 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 <errno.h>
+#include <fcntl.h>
+#include <semaphore.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static void
+remove_sem (int status, void *arg)
+{
+ sem_unlink (arg);
+}
+
+
+int
+main (void)
+{
+ sem_t *s;
+ sem_t *s2;
+ sem_t *s3;
+
+ s = sem_open ("/glibc-tst-sem7", O_CREAT, 0600, 1);
+ if (s == SEM_FAILED)
+ {
+ if (errno == ENOSYS)
+ {
+ puts ("sem_open not supported. Oh well.");
+ return 0;
+ }
+
+ /* Maybe the shm filesystem has strict permissions. */
+ if (errno == EACCES)
+ {
+ puts ("sem_open not allowed. Oh well.");
+ return 0;
+ }
+
+ printf ("sem_open: %m\n");
+ return 1;
+ }
+
+ on_exit (remove_sem, (void *) "/glibc-tst-sem7");
+
+ /* We have the semaphore object. Now try again. We should get the
+ same address. */
+ s2 = sem_open ("/glibc-tst-sem7", O_CREAT, 0600, 1);
+ if (s2 == SEM_FAILED)
+ {
+ puts ("2nd sem_open failed");
+ return 1;
+ }
+ if (s != s2)
+ {
+ puts ("2nd sem_open didn't return the same address");
+ return 1;
+ }
+
+ /* And again, this time without O_CREAT. */
+ s3 = sem_open ("/glibc-tst-sem7", 0);
+ if (s3 == SEM_FAILED)
+ {
+ puts ("3rd sem_open failed");
+ return 1;
+ }
+ if (s != s3)
+ {
+ puts ("3rd sem_open didn't return the same address");
+ return 1;
+ }
+
+ /* Now close the handle. Three times. */
+ if (sem_close (s2) != 0)
+ {
+ puts ("1st sem_close failed");
+ return 1;
+ }
+ if (sem_close (s) != 0)
+ {
+ puts ("2nd sem_close failed");
+ return 1;
+ }
+ if (sem_close (s3) != 0)
+ {
+ puts ("3rd sem_close failed");
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/test/nptl/tst-sem8.c b/test/nptl/tst-sem8.c
new file mode 100644
index 000000000..286590fd6
--- /dev/null
+++ b/test/nptl/tst-sem8.c
@@ -0,0 +1,73 @@
+/* Copyright (C) 2003 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 <errno.h>
+#include <fcntl.h>
+#include <semaphore.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static void
+remove_sem (int status, void *arg)
+{
+ sem_unlink (arg);
+}
+
+
+int
+main (void)
+{
+ sem_t *s;
+ int i;
+
+ on_exit (remove_sem, (void *) "/glibc-tst-sem8");
+
+ for (i = 0; i < 3; ++i)
+ {
+ s = sem_open ("/glibc-tst-sem8", O_CREAT, 0600, 1);
+ if (s == SEM_FAILED)
+ {
+ if (errno == ENOSYS)
+ {
+ puts ("sem_open not supported. Oh well.");
+ return 0;
+ }
+
+ /* Maybe the shm filesystem has strict permissions. */
+ if (errno == EACCES)
+ {
+ puts ("sem_open not allowed. Oh well.");
+ return 0;
+ }
+
+ printf ("sem_open: %m\n");
+ return 1;
+ }
+
+ /* Now close the handle. */
+ if (sem_close (s) != 0)
+ {
+ puts ("sem_close failed");
+ return 1;
+ }
+ }
+
+ return 0;
+}
diff --git a/test/nptl/tst-sem9.c b/test/nptl/tst-sem9.c
new file mode 100644
index 000000000..bdb594b09
--- /dev/null
+++ b/test/nptl/tst-sem9.c
@@ -0,0 +1,80 @@
+/* Copyright (C) 2003 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 <errno.h>
+#include <fcntl.h>
+#include <semaphore.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static void
+remove_sem (int status, void *arg)
+{
+ sem_unlink (arg);
+}
+
+
+int
+main (void)
+{
+ sem_t *s;
+ int i;
+
+ on_exit (remove_sem, (void *) "/glibc-tst-sem9");
+
+ for (i = 0; i < 3; ++i)
+ {
+ s = sem_open ("/glibc-tst-sem9", O_CREAT, 0600, 1);
+ if (s == SEM_FAILED)
+ {
+ if (errno == ENOSYS)
+ {
+ puts ("sem_open not supported. Oh well.");
+ return 0;
+ }
+
+ /* Maybe the shm filesystem has strict permissions. */
+ if (errno == EACCES)
+ {
+ puts ("sem_open not allowed. Oh well.");
+ return 0;
+ }
+
+ printf ("sem_open: %m\n");
+ return 1;
+ }
+
+ /* Now close the handle. */
+ if (sem_close (s) != 0)
+ {
+ puts ("sem_close failed");
+ return 1;
+ }
+
+ /* And remove it. */
+ if (sem_unlink ("/glibc-tst-sem9") != 0)
+ {
+ puts ("sem_unlink failed");
+ return 1;
+ }
+ }
+
+ return 0;
+}
diff --git a/test/nptl/tst-signal1.c b/test/nptl/tst-signal1.c
new file mode 100644
index 000000000..0f952fd24
--- /dev/null
+++ b/test/nptl/tst-signal1.c
@@ -0,0 +1,188 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+
+
+static sigset_t ss;
+static pthread_barrier_t *b;
+
+
+static void *
+tf (void *arg)
+{
+ sigdelset (&ss, SIGINT);
+
+ if (pthread_sigmask (SIG_SETMASK, &ss, NULL) != 0)
+ {
+ puts ("2nd pthread_sigmask failed");
+ exit (1);
+ }
+
+ pthread_barrier_wait (b);
+
+ int sig;
+ int res = sigwait (&ss, &sig);
+ if (res == 0)
+ {
+ printf ("sigwait returned successfully with signal %d\n", sig);
+ exit (1);
+ }
+
+ printf ("sigwait returned with %s (%d)\n", strerror (res), res);
+
+ return NULL;
+}
+
+
+static void
+receiver (void)
+{
+ pthread_t th;
+
+ /* Make sure the process doesn't run forever. */
+ alarm (10);
+
+ sigfillset (&ss);
+
+ if (pthread_sigmask (SIG_SETMASK, &ss, NULL) != 0)
+ {
+ puts ("1st pthread_sigmask failed");
+ exit (1);
+ }
+
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("pthread_create failed");
+ exit (1);
+ }
+
+ if (pthread_join (th, NULL) == 0)
+ {
+ puts ("thread joined?!");
+ exit (1);
+ }
+
+ _exit (0);
+}
+
+
+static int
+do_test (void)
+{
+ char tmp[] = "/tmp/tst-signal1-XXXXXX";
+
+ int fd = mkstemp (tmp);
+ if (fd == -1)
+ {
+ puts ("mkstemp failed");
+ exit (1);
+ }
+
+ unlink (tmp);
+
+ int i;
+ for (i = 0; i < 20; ++i)
+ write (fd, "foobar xyzzy", 12);
+
+ b = mmap (NULL, sizeof (pthread_barrier_t), PROT_READ | PROT_WRITE,
+ MAP_SHARED, fd, 0);
+ if (b == MAP_FAILED)
+ {
+ puts ("mmap failed");
+ exit (1);
+ }
+
+ pthread_barrierattr_t ba;
+ if (pthread_barrierattr_init (&ba) != 0)
+ {
+ puts ("barrierattr_init failed");
+ exit (1);
+ }
+
+ if (pthread_barrierattr_setpshared (&ba, PTHREAD_PROCESS_SHARED) != 0)
+ {
+ puts ("barrierattr_setpshared failed");
+ exit (1);
+ }
+
+ if (pthread_barrier_init (b, &ba, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ exit (1);
+ }
+
+ if (pthread_barrierattr_destroy (&ba) != 0)
+ {
+ puts ("barrierattr_destroy failed");
+ exit (1);
+ }
+
+ pid_t pid = fork ();
+ if (pid == -1)
+ {
+ puts ("fork failed");
+ exit (1);
+ }
+
+ if (pid == 0)
+ receiver ();
+
+ pthread_barrier_wait (b);
+
+ /* Wait a bit more. */
+ struct timespec ts = { .tv_sec = 0, .tv_nsec = 10000000 };
+ nanosleep (&ts, NULL);
+
+ /* Send the signal. */
+ puts ("sending the signal now");
+ kill (pid, SIGINT);
+
+ /* Wait for the process to terminate. */
+ int status;
+ if (TEMP_FAILURE_RETRY (waitpid (pid, &status, 0)) != pid)
+ {
+ puts ("wrong child reported terminated");
+ exit (1);
+ }
+
+ if (!WIFSIGNALED (status))
+ {
+ puts ("child wasn't signalled");
+ exit (1);
+ }
+
+ if (WTERMSIG (status) != SIGINT)
+ {
+ puts ("child not terminated with SIGINT");
+ exit (1);
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-signal2.c b/test/nptl/tst-signal2.c
new file mode 100644
index 000000000..37d5611e4
--- /dev/null
+++ b/test/nptl/tst-signal2.c
@@ -0,0 +1,197 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+#include <string.h>
+
+
+static sigset_t ss;
+static pthread_barrier_t *b;
+
+
+static void *
+tf (void *arg)
+{
+ pthread_barrier_wait (b);
+
+ puts ("child: calling sigwait now");
+
+ int sig;
+ int err;
+ err = sigwait (&ss, &sig);
+ if (err != 0)
+ {
+ printf ("sigwait returned unsuccessfully: %s (%d)\n",
+ strerror (err), err);
+ _exit (1);
+ }
+
+ puts ("sigwait returned");
+
+ if (sig != SIGINT)
+ {
+ printf ("caught signal %d, expected %d (SIGINT)\n", sig, SIGINT);
+ _exit (1);
+ }
+
+ puts ("child thread terminating now");
+
+ return NULL;
+}
+
+
+static void
+receiver (void)
+{
+ pthread_t th;
+
+ /* Make sure the process doesn't run forever. */
+ alarm (10);
+
+ sigfillset (&ss);
+
+ if (pthread_sigmask (SIG_SETMASK, &ss, NULL) != 0)
+ {
+ puts ("1st pthread_sigmask failed");
+ _exit (1);
+ }
+
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("pthread_create failed");
+ _exit (1);
+ }
+
+ if (pthread_join (th, NULL) != 0)
+ {
+ puts ("thread didn't join");
+ _exit (1);
+ }
+
+ puts ("join succeeded");
+
+ _exit (0);
+}
+
+
+static int
+do_test (void)
+{
+ char tmp[] = "/tmp/tst-signal1-XXXXXX";
+
+ int fd = mkstemp (tmp);
+ if (fd == -1)
+ {
+ puts ("mkstemp failed");
+ exit (1);
+ }
+
+ unlink (tmp);
+
+ int i;
+ for (i = 0; i < 20; ++i)
+ write (fd, "foobar xyzzy", 12);
+
+ b = mmap (NULL, sizeof (pthread_barrier_t), PROT_READ | PROT_WRITE,
+ MAP_SHARED, fd, 0);
+ if (b == MAP_FAILED)
+ {
+ puts ("mmap failed");
+ exit (1);
+ }
+
+ pthread_barrierattr_t ba;
+ if (pthread_barrierattr_init (&ba) != 0)
+ {
+ puts ("barrierattr_init failed");
+ exit (1);
+ }
+
+ if (pthread_barrierattr_setpshared (&ba, PTHREAD_PROCESS_SHARED) != 0)
+ {
+ puts ("barrierattr_setpshared failed");
+ exit (1);
+ }
+
+ if (pthread_barrier_init (b, &ba, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ exit (1);
+ }
+
+ if (pthread_barrierattr_destroy (&ba) != 0)
+ {
+ puts ("barrierattr_destroy failed");
+ exit (1);
+ }
+
+ pid_t pid = fork ();
+ if (pid == -1)
+ {
+ puts ("fork failed");
+ exit (1);
+ }
+
+ if (pid == 0)
+ receiver ();
+
+ pthread_barrier_wait (b);
+
+ /* Wait a bit more. */
+ struct timespec ts = { .tv_sec = 0, .tv_nsec = 10000000 };
+ nanosleep (&ts, NULL);
+
+ /* Send the signal. */
+ puts ("sending the signal now");
+ kill (pid, SIGINT);
+
+ /* Wait for the process to terminate. */
+ int status;
+ if (TEMP_FAILURE_RETRY (waitpid (pid, &status, 0)) != pid)
+ {
+ puts ("wrong child reported terminated");
+ exit (1);
+ }
+
+ if (!WIFEXITED (status))
+ {
+ if (WIFSIGNALED (status))
+ printf ("child exited with signal %d\n", WTERMSIG (status));
+ else
+ puts ("child didn't exit normally");
+ exit (1);
+ }
+
+ if (WEXITSTATUS (status) != 0)
+ {
+ printf ("exit status %d != 0\n", WEXITSTATUS (status));
+ exit (1);
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-signal3.c b/test/nptl/tst-signal3.c
new file mode 100644
index 000000000..fbd9ace8e
--- /dev/null
+++ b/test/nptl/tst-signal3.c
@@ -0,0 +1,260 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <pthread.h>
+#include <semaphore.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+/* Number of different signalss to use. Also is the number of
+ threads. */
+#define N 10
+/* Maximum number of threads in flight at any one time. */
+#define INFLIGHT 5
+/* Number of signals sent in total. */
+#define ROUNDS 10000
+
+
+static int received[N][N];
+static int nsig[N];
+static pthread_t th[N];
+static sem_t sem;
+static pthread_mutex_t lock[N];
+static pthread_t th_main;
+static int sig0;
+
+static void
+handler (int sig)
+{
+ int i;
+ for (i = 0; i < N; ++i)
+ if (pthread_equal (pthread_self (), th[i]))
+ break;
+
+ if (i == N)
+ {
+ if (pthread_equal (pthread_self (), th_main))
+ puts ("signal received by main thread");
+ else
+ printf ("signal received by unknown thread (%lx)\n",
+ (unsigned long int) pthread_self ());
+ exit (1);
+ }
+
+ ++received[i][sig - sig0];
+
+ sem_post (&sem);
+}
+
+
+static void *
+tf (void *arg)
+{
+ int idx = (long int) arg;
+
+ sigset_t ss;
+ sigemptyset (&ss);
+
+ int i;
+ for (i = 0; i <= idx; ++i)
+ sigaddset (&ss, sig0 + i);
+
+ if (pthread_sigmask (SIG_UNBLOCK, &ss, NULL) != 0)
+ {
+ printf ("thread %d: pthread_sigmask failed\n", i);
+ exit (1);
+ }
+
+ pthread_mutex_lock (&lock[idx]);
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ /* Block all signals. */
+ sigset_t ss;
+ sigfillset (&ss);
+
+ th_main = pthread_self ();
+
+ sig0 = SIGRTMIN;
+
+ if (pthread_sigmask (SIG_SETMASK, &ss, NULL) != 0)
+ {
+ puts ("1st pthread_sigmask failed");
+ exit (1);
+ }
+
+ /* Install the handler. */
+ int i;
+ for (i = 0; i < N; ++i)
+ {
+ struct sigaction sa =
+ {
+ .sa_handler = handler,
+ .sa_flags = 0
+ };
+ sigfillset (&sa.sa_mask);
+
+ if (sigaction (sig0 + i, &sa, NULL) != 0)
+ {
+ printf ("sigaction for signal %d failed\n", i);
+ exit (1);
+ }
+ }
+
+ if (sem_init (&sem, 0, INFLIGHT) != 0)
+ {
+ puts ("sem_init failed");
+ exit (1);
+ }
+
+ pthread_attr_t a;
+
+ if (pthread_attr_init (&a) != 0)
+ {
+ puts ("attr_init failed");
+ exit (1);
+ }
+
+ if (pthread_attr_setstacksize (&a, 1 * 1024 * 1024) != 0)
+ {
+ puts ("attr_setstacksize failed");
+ return 1;
+ }
+
+ for (i = 0; i < N; ++i)
+ {
+ if (pthread_mutex_init (&lock[i], NULL) != 0)
+ {
+ printf ("mutex_init[%d] failed\n", i);
+ }
+
+ if (pthread_mutex_lock (&lock[i]) != 0)
+ {
+ printf ("mutex_lock[%d] failed\n", i);
+ }
+
+ if (pthread_create (&th[i], &a, tf, (void *) (long int) i) != 0)
+ {
+ printf ("create of thread %d failed\n", i);
+ exit (1);
+ }
+ }
+
+ if (pthread_attr_destroy (&a) != 0)
+ {
+ puts ("attr_destroy failed");
+ exit (1);
+ }
+
+ int result = 0;
+ unsigned int r = 42;
+ pid_t pid = getpid ();
+
+ for (i = 0; i < ROUNDS; ++i)
+ {
+ if (TEMP_FAILURE_RETRY (sem_wait (&sem)) != 0)
+ {
+ printf ("sem_wait round %d failed: %m\n", i);
+ exit (1);
+ }
+
+ int s = rand_r (&r) % N;
+
+ kill (pid, sig0 + s);
+ }
+
+ void *status;
+ for (i = 0; i < N; ++i)
+ {
+ if (pthread_mutex_unlock (&lock[i]) != 0)
+ {
+ printf ("unlock %d failed\n", i);
+ exit (1);
+ }
+
+ if (pthread_join (th[i], &status) != 0)
+ {
+ printf ("join %d failed\n", i);
+ result = 1;
+ }
+ else if (status != NULL)
+ {
+ printf ("%d: result != NULL\n", i);
+ result = 1;
+ }
+ }
+
+ int total = 0;
+ for (i = 0; i < N; ++i)
+ {
+ int j;
+
+ for (j = 0; j <= i; ++j)
+ total += received[i][j];
+
+ for (j = i + 1; j < N; ++j)
+ if (received[i][j] != 0)
+ {
+ printf ("thread %d received signal SIGRTMIN+%d\n", i, j);
+ result = 1;
+ }
+ }
+
+ if (total != ROUNDS)
+ {
+ printf ("total number of handled signals is %d, expected %d\n",
+ total, ROUNDS);
+ result = 1;
+ }
+
+ printf ("A total of %d signals sent and received\n", total);
+ for (i = 0; i < N; ++i)
+ {
+ printf ("thread %2d:", i);
+
+ int j;
+ for (j = 0; j <= i; ++j)
+ {
+ printf (" %5d", received[i][j]);
+ nsig[j] += received[i][j];
+ }
+
+ putchar ('\n');
+
+ }
+
+ printf ("\nTotal :");
+ for (i = 0; i < N; ++i)
+ printf (" %5d", nsig[i]);
+ putchar ('\n');
+
+ return result;
+}
+
+#define TIMEOUT 10
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-signal4.c b/test/nptl/tst-signal4.c
new file mode 100644
index 000000000..f249b7b75
--- /dev/null
+++ b/test/nptl/tst-signal4.c
@@ -0,0 +1,59 @@
+/* Copyright (C) 2003 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 <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+static int
+do_test (void)
+{
+ sigset_t ss;
+
+ sigemptyset (&ss);
+
+ int i;
+ for (i = 0; i < 10000; ++i)
+ {
+ long int r = random ();
+
+ if (r != SIG_BLOCK && r != SIG_SETMASK && r != SIG_UNBLOCK)
+ {
+ int e = pthread_sigmask (r, &ss, NULL);
+
+ if (e == 0)
+ {
+ printf ("pthread_sigmask succeeded for how = %ld\n", r);
+ exit (1);
+ }
+
+ if (e != EINVAL)
+ {
+ puts ("pthread_sigmask didn't return EINVAL");
+ exit (1);
+ }
+ }
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-signal5.c b/test/nptl/tst-signal5.c
new file mode 100644
index 000000000..5c0ac0c17
--- /dev/null
+++ b/test/nptl/tst-signal5.c
@@ -0,0 +1,110 @@
+/* Copyright (C) 2003 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 <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+
+
+static sigset_t ss;
+
+
+static void *
+tf (void *arg)
+{
+ sigset_t ss2;
+ if (pthread_sigmask (SIG_SETMASK, NULL, &ss2) != 0)
+ {
+ puts ("child: sigmask failed");
+ exit (1);
+ }
+
+ int i;
+ for (i = 1; i < 32; ++i)
+ if (sigismember (&ss, i) && ! sigismember (&ss2, i))
+ {
+ printf ("signal %d set in parent mask, but not in child\n", i);
+ exit (1);
+ }
+ else if (! sigismember (&ss, i) && sigismember (&ss2, i))
+ {
+ printf ("signal %d set in child mask, but not in parent\n", i);
+ exit (1);
+ }
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ sigemptyset (&ss);
+ sigaddset (&ss, SIGUSR1);
+ if (pthread_sigmask (SIG_SETMASK, &ss, NULL) != 0)
+ {
+ puts ("1st sigmask failed");
+ exit (1);
+ }
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("1st create failed");
+ exit (1);
+ }
+
+ void *r;
+ if (pthread_join (th, &r) != 0)
+ {
+ puts ("1st join failed");
+ exit (1);
+ }
+
+ sigemptyset (&ss);
+ sigaddset (&ss, SIGUSR2);
+ sigaddset (&ss, SIGFPE);
+ if (pthread_sigmask (SIG_SETMASK, &ss, NULL) != 0)
+ {
+ puts ("2nd sigmask failed");
+ exit (1);
+ }
+
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("2nd create failed");
+ exit (1);
+ }
+
+ if (pthread_join (th, &r) != 0)
+ {
+ puts ("2nd join failed");
+ exit (1);
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-signal6.c b/test/nptl/tst-signal6.c
new file mode 100644
index 000000000..31827b7c2
--- /dev/null
+++ b/test/nptl/tst-signal6.c
@@ -0,0 +1,191 @@
+/* Copyright (C) 2003 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 <pthread.h>
+#include <signal.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+#define N 2
+static pthread_barrier_t bar;
+static struct
+{
+ void *p;
+ pthread_t s;
+} ti[N];
+static int sig1;
+
+
+static void
+handler (int sig)
+{
+ pthread_t self = pthread_self ();
+ size_t i;
+
+ for (i = 0; i < N; ++i)
+ if (ti[i].s == self)
+ {
+ if ((uintptr_t) ti[i].p <= (uintptr_t) &self
+ && (uintptr_t) ti[i].p + 2 * MINSIGSTKSZ > (uintptr_t) &self)
+ {
+ puts ("alt stack not used");
+ exit (1);
+ }
+
+ printf ("thread %zu used alt stack for signal %d\n", i, sig);
+
+ return;
+ }
+
+ puts ("handler: thread not found");
+ exit (1);
+}
+
+
+static void *
+tf (void *arg)
+{
+ size_t nr = (uintptr_t) arg;
+ if (nr >= N)
+ {
+ puts ("wrong nr parameter");
+ exit (1);
+ }
+
+ sigset_t ss;
+ sigemptyset (&ss);
+ size_t i;
+ for (i = 0; i < N; ++i)
+ if (i != nr)
+ if (sigaddset (&ss, sig1 + i) != 0)
+ {
+ puts ("tf: sigaddset failed");
+ exit (1);
+ }
+ if (pthread_sigmask (SIG_BLOCK, &ss, NULL) != 0)
+ {
+ puts ("tf: sigmask failed");
+ exit (1);
+ }
+
+ void *p = malloc (2 * MINSIGSTKSZ);
+ if (p == NULL)
+ {
+ puts ("tf: malloc failed");
+ exit (1);
+ }
+
+ stack_t s;
+ s.ss_sp = p;
+ s.ss_size = 2 * MINSIGSTKSZ;
+ s.ss_flags = 0;
+ if (sigaltstack (&s, NULL) != 0)
+ {
+ puts ("tf: sigaltstack failed");
+ exit (1);
+ }
+
+ ti[nr].p = p;
+ ti[nr].s = pthread_self ();
+
+ pthread_barrier_wait (&bar);
+
+ pthread_barrier_wait (&bar);
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ sig1 = SIGRTMIN;
+ if (sig1 + N > SIGRTMAX)
+ {
+ puts ("too few RT signals");
+ return 0;
+ }
+
+ struct sigaction sa;
+ sa.sa_handler = handler;
+ sa.sa_flags = 0;
+ sigemptyset (&sa.sa_mask);
+
+ if (sigaction (sig1, &sa, NULL) != 0
+ || sigaction (sig1 + 1, &sa, NULL) != 0
+ || sigaction (sig1 + 2, &sa, NULL) != 0)
+ {
+ puts ("sigaction failed");
+ return 1;
+ }
+
+ if (pthread_barrier_init (&bar, NULL, 1 + N) != 0)
+ {
+ puts ("barrier_init failed");
+ return 1;
+ }
+
+ pthread_t th[N];
+ size_t i;
+ for (i = 0; i < N; ++i)
+ if (pthread_create (&th[i], NULL, tf, (void *) (long int) i) != 0)
+ {
+ puts ("create failed");
+ return 1;
+ }
+
+ /* Block the three signals. */
+ sigset_t ss;
+ sigemptyset (&ss);
+ for (i = 0; i <= N; ++i)
+ sigaddset (&ss, sig1 + i);
+ if (pthread_sigmask (SIG_BLOCK, &ss, NULL) != 0)
+ {
+ puts ("main: sigmask failed");
+ return 1;
+ }
+
+ pthread_barrier_wait (&bar);
+
+ /* Send some signals. */
+ pid_t me = getpid ();
+ kill (me, sig1 + N);
+ for (i = 0; i < N; ++i)
+ kill (me, sig1 + i);
+ kill (me, sig1 + N);
+
+ /* Give the signals a chance to be worked on. */
+ sleep (1);
+
+ pthread_barrier_wait (&bar);
+
+ for (i = 0; i < N; ++i)
+ if (pthread_join (th[i], NULL) != 0)
+ {
+ puts ("join failed");
+ return 1;
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-signal7.c b/test/nptl/tst-signal7.c
new file mode 100644
index 000000000..629f377ae
--- /dev/null
+++ b/test/nptl/tst-signal7.c
@@ -0,0 +1,58 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <pthreadP.h>
+#include <signal.h>
+#include <stdio.h>
+
+
+static int
+do_test (void)
+{
+ int result = 0;
+
+ errno = 0;
+ if (sigaction (SIGCANCEL, NULL, NULL) == 0)
+ {
+ puts ("sigaction(SIGCANCEL) did not fail");
+ result = 1;
+ }
+ else if (errno != EINVAL)
+ {
+ puts ("sigaction(SIGCANCEL) did not set errno to EINVAL");
+ result = 1;
+ }
+
+ errno = 0;
+ if (sigaction (SIGSETXID, NULL, NULL) == 0)
+ {
+ puts ("sigaction(SIGSETXID) did not fail");
+ result = 1;
+ }
+ else if (errno != EINVAL)
+ {
+ puts ("sigaction(SIGSETXID) did not set errno to EINVAL");
+ result = 1;
+ }
+
+ return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-spin1.c b/test/nptl/tst-spin1.c
new file mode 100644
index 000000000..b55c9584a
--- /dev/null
+++ b/test/nptl/tst-spin1.c
@@ -0,0 +1,56 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread.h>
+#include <stdio.h>
+
+
+static int
+do_test (void)
+{
+ pthread_spinlock_t s;
+
+ if (pthread_spin_init (&s, PTHREAD_PROCESS_PRIVATE) != 0)
+ {
+ puts ("spin_init failed");
+ return 1;
+ }
+
+ if (pthread_spin_lock (&s) != 0)
+ {
+ puts ("spin_lock failed");
+ return 1;
+ }
+
+ if (pthread_spin_unlock (&s) != 0)
+ {
+ puts ("spin_unlock failed");
+ return 1;
+ }
+
+ if (pthread_spin_destroy (&s) != 0)
+ {
+ puts ("spin_destroy failed");
+ return 1;
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-spin2.c b/test/nptl/tst-spin2.c
new file mode 100644
index 000000000..6119a3b23
--- /dev/null
+++ b/test/nptl/tst-spin2.c
@@ -0,0 +1,158 @@
+/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <errno.h>
+#include <pthread.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+
+
+static int
+do_test (void)
+{
+ size_t ps = sysconf (_SC_PAGESIZE);
+ char tmpfname[] = "/tmp/tst-spin2.XXXXXX";
+ char data[ps];
+ void *mem;
+ int fd;
+ pthread_spinlock_t *s;
+ pid_t pid;
+ char *p;
+ int err;
+
+ fd = mkstemp (tmpfname);
+ if (fd == -1)
+ {
+ printf ("cannot open temporary file: %m\n");
+ return 1;
+ }
+
+ /* Make sure it is always removed. */
+ unlink (tmpfname);
+
+ /* Create one page of data. */
+ memset (data, '\0', ps);
+
+ /* Write the data to the file. */
+ if (write (fd, data, ps) != (ssize_t) ps)
+ {
+ puts ("short write");
+ return 1;
+ }
+
+ mem = mmap (NULL, ps, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ if (mem == MAP_FAILED)
+ {
+ printf ("mmap failed: %m\n");
+ return 1;
+ }
+
+ s = (pthread_spinlock_t *) (((uintptr_t) mem
+ + __alignof (pthread_spinlock_t))
+ & ~(__alignof (pthread_spinlock_t) - 1));
+ p = (char *) (s + 1);
+
+ if (pthread_spin_init (s, PTHREAD_PROCESS_SHARED) != 0)
+ {
+ puts ("spin_init failed");
+ return 1;
+ }
+
+ if (pthread_spin_lock (s) != 0)
+ {
+ puts ("spin_lock failed");
+ return 1;
+ }
+
+ err = pthread_spin_trylock (s);
+ if (err == 0)
+ {
+ puts ("1st spin_trylock succeeded");
+ return 1;
+ }
+ else if (err != EBUSY)
+ {
+ puts ("1st spin_trylock didn't return EBUSY");
+ return 1;
+ }
+
+ err = pthread_spin_unlock (s);
+ if (err != 0)
+ {
+ puts ("parent: spin_unlock failed");
+ return 1;
+ }
+
+ err = pthread_spin_trylock (s);
+ if (err != 0)
+ {
+ puts ("2nd spin_trylock failed");
+ return 1;
+ }
+
+ *p = 0;
+
+ puts ("going to fork now");
+ pid = fork ();
+ if (pid == -1)
+ {
+ puts ("fork failed");
+ return 1;
+ }
+ else if (pid == 0)
+ {
+ /* Play some lock ping-pong. It's our turn to unlock first. */
+ if ((*p)++ != 0)
+ {
+ puts ("child: *p != 0");
+ return 1;
+ }
+
+ if (pthread_spin_unlock (s) != 0)
+ {
+ puts ("child: 1st spin_unlock failed");
+ return 1;
+ }
+
+ puts ("child done");
+ }
+ else
+ {
+ if (pthread_spin_lock (s) != 0)
+ {
+ puts ("parent: 2nd spin_lock failed");
+ return 1;
+ }
+
+ puts ("waiting for child");
+
+ waitpid (pid, NULL, 0);
+
+ puts ("parent done");
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-spin3.c b/test/nptl/tst-spin3.c
new file mode 100644
index 000000000..b54d42c33
--- /dev/null
+++ b/test/nptl/tst-spin3.c
@@ -0,0 +1,54 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <unistd.h>
+
+
+static int
+do_test (void)
+{
+ pthread_spinlock_t s;
+
+ if (pthread_spin_init (&s, PTHREAD_PROCESS_PRIVATE) != 0)
+ {
+ puts ("spin_init failed");
+ return 1;
+ }
+
+ if (pthread_spin_lock (&s) != 0)
+ {
+ puts ("1st spin_lock failed");
+ return 1;
+ }
+
+ /* Set an alarm for 1 second. The wrapper will expect this. */
+ alarm (1);
+
+ /* This call should never return. */
+ pthread_spin_lock (&s);
+
+ puts ("2nd spin_lock returned");
+ return 1;
+}
+
+#define EXPECTED_SIGNAL SIGALRM
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-stack-align.h b/test/nptl/tst-stack-align.h
new file mode 100644
index 000000000..9a59d7137
--- /dev/null
+++ b/test/nptl/tst-stack-align.h
@@ -0,0 +1,34 @@
+/* Copyright (C) 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 <stdio.h>
+#include <stdint.h>
+
+#define TEST_STACK_ALIGN() \
+ ({ \
+ double _d = 12.0; \
+ long double _ld = 15.0; \
+ int _ret = 0; \
+ printf ("double: %g %p %zu\n", _d, &_d, __alignof (double)); \
+ if ((((uintptr_t) &_d) & (__alignof (double) - 1)) != 0) \
+ _ret = 1; \
+ \
+ printf ("ldouble: %Lg %p %zu\n", _ld, &_ld, __alignof (long double)); \
+ if ((((uintptr_t) &_ld) & (__alignof (long double) - 1)) != 0) \
+ _ret = 1; \
+ _ret; \
+ })
diff --git a/test/nptl/tst-stack1.c b/test/nptl/tst-stack1.c
new file mode 100644
index 000000000..288024a1d
--- /dev/null
+++ b/test/nptl/tst-stack1.c
@@ -0,0 +1,145 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <limits.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/param.h>
+#include <unistd.h>
+
+
+static void *stack;
+static size_t size;
+
+
+static void *
+tf (void *a)
+{
+ int result = 0;
+
+ puts ("child start");
+
+ pthread_attr_t attr;
+ if (pthread_getattr_np (pthread_self (), &attr) != 0)
+ {
+ puts ("getattr_np failed");
+ exit (1);
+ }
+
+ size_t test_size;
+ void *test_stack;
+ if (pthread_attr_getstack (&attr, &test_stack, &test_size) != 0)
+ {
+ puts ("attr_getstack failed");
+ exit (1);
+ }
+
+ if (test_size != size)
+ {
+ printf ("child: reported size differs: is %zu, expected %zu\n",
+ test_size, size);
+ result = 1;
+ }
+
+ if (test_stack != stack)
+ {
+ printf ("child: reported stack address differs: is %p, expected %p\n",
+ test_stack, stack);
+ result = 1;
+ }
+
+ puts ("child OK");
+
+ return result ? (void *) 1l : NULL;
+}
+
+
+int
+do_test (void)
+{
+ int result = 0;
+
+ size = MAX (4 * getpagesize (), PTHREAD_STACK_MIN);
+ if (posix_memalign (&stack, getpagesize (), size) != 0)
+ {
+ puts ("out of memory while allocating the stack memory");
+ exit (1);
+ }
+
+ pthread_attr_t attr;
+ if (pthread_attr_init (&attr) != 0)
+ {
+ puts ("attr_init failed");
+ exit (1);
+ }
+
+ puts ("attr_setstack");
+ if (pthread_attr_setstack (&attr, stack, size) != 0)
+ {
+ puts ("attr_setstack failed");
+ exit (1);
+ }
+
+ size_t test_size;
+ void *test_stack;
+ puts ("attr_getstack");
+ if (pthread_attr_getstack (&attr, &test_stack, &test_size) != 0)
+ {
+ puts ("attr_getstack failed");
+ exit (1);
+ }
+
+ if (test_size != size)
+ {
+ printf ("reported size differs: is %zu, expected %zu\n",
+ test_size, size);
+ result = 1;
+ }
+
+ if (test_stack != stack)
+ {
+ printf ("reported stack address differs: is %p, expected %p\n",
+ test_stack, stack);
+ result = 1;
+ }
+
+ puts ("create");
+
+ pthread_t th;
+ if (pthread_create (&th, &attr, tf, NULL) != 0)
+ {
+ puts ("failed to create thread");
+ exit (1);
+ }
+
+ void *status;
+ if (pthread_join (th, &status) != 0)
+ {
+ puts ("join failed");
+ exit (1);
+ }
+
+ result |= status != NULL;
+
+ return result;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-stack2.c b/test/nptl/tst-stack2.c
new file mode 100644
index 000000000..7b1e2f6a6
--- /dev/null
+++ b/test/nptl/tst-stack2.c
@@ -0,0 +1,79 @@
+/* Copyright (C) 2003 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/>. */
+
+/* Test whether it is possible to create a thread with PTHREAD_STACK_MIN
+ stack size. */
+
+#include <pthread.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <limits.h>
+
+static int seen;
+
+static void *
+tf (void *p)
+{
+ ++seen;
+ return NULL;
+}
+
+static int
+do_test (void)
+{
+ pthread_attr_t attr;
+ pthread_attr_init (&attr);
+
+ int result = 0;
+ int res = pthread_attr_setstacksize (&attr, PTHREAD_STACK_MIN);
+ if (res)
+ {
+ printf ("pthread_attr_setstacksize failed %d\n", res);
+ result = 1;
+ }
+
+ /* Create the thread. */
+ pthread_t th;
+ res = pthread_create (&th, &attr, tf, NULL);
+ if (res)
+ {
+ printf ("pthread_create failed %d\n", res);
+ result = 1;
+ }
+ else
+ {
+ res = pthread_join (th, NULL);
+ if (res)
+ {
+ printf ("pthread_join failed %d\n", res);
+ result = 1;
+ }
+ }
+
+ if (seen != 1)
+ {
+ printf ("seen %d != 1\n", seen);
+ result = 1;
+ }
+
+ return result;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-stdio1.c b/test/nptl/tst-stdio1.c
new file mode 100644
index 000000000..2396e0185
--- /dev/null
+++ b/test/nptl/tst-stdio1.c
@@ -0,0 +1,56 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <unistd.h>
+
+
+static void *tf (void *a)
+{
+ flockfile (stdout);
+ /* This call should never return. */
+ return a;
+}
+
+
+int
+do_test (void)
+{
+ pthread_t th;
+
+ flockfile (stdout);
+
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ write (2, "create failed\n", 14);
+ _exit (1);
+ }
+
+ pthread_join (th, NULL);
+
+ puts ("join returned");
+
+ return 0;
+}
+
+
+#define EXPECTED_SIGNAL SIGALRM
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-stdio2.c b/test/nptl/tst-stdio2.c
new file mode 100644
index 000000000..4ac778cc0
--- /dev/null
+++ b/test/nptl/tst-stdio2.c
@@ -0,0 +1,81 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static void *tf (void *a)
+{
+ puts ("start tf");
+
+ /* Multiple locking, implicitly or explicitly, must be possible. */
+ flockfile (stdout);
+
+ puts ("after first flockfile");
+
+ flockfile (stdout);
+
+ puts ("foo");
+
+ funlockfile (stdout);
+
+ puts ("after first funlockfile");
+
+ funlockfile (stdout);
+
+ puts ("all done");
+
+ return a;
+}
+
+
+int
+do_test (void)
+{
+ pthread_t th;
+
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ write (2, "create failed\n", 14);
+ _exit (1);
+ }
+
+ void *result;
+ if (pthread_join (th, &result) != 0)
+ {
+ puts ("join failed");
+ exit (1);
+ }
+ else if (result != NULL)
+ {
+ printf ("wrong return value: %p, expected %p\n", result, NULL);
+ exit (1);
+ }
+
+ puts ("join returned succsefully");
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-sysconf.c b/test/nptl/tst-sysconf.c
new file mode 100644
index 000000000..da493ef43
--- /dev/null
+++ b/test/nptl/tst-sysconf.c
@@ -0,0 +1,47 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread.h>
+#include <stdio.h>
+#include <unistd.h>
+
+
+static int
+do_test (void)
+{
+ puts ("We expect no limits");
+ /* We have no fixed limit on the number of threads. Make sure the
+ headers tell the right story. */
+#ifdef PTHREAD_THREADS_MAX
+ printf ("Header report maximum number of threads = %lu\n",
+ (unsigned long int) PTHREAD_THREADS_MAX);
+ return 1;
+#else
+ long int r = sysconf (_SC_THREAD_THREADS_MAX);
+ if (r != -1)
+ {
+ printf ("sysconf(_SC_THREAD_THREADS_MAX) return %ld\n", r);
+ return 1;
+ }
+#endif
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-timer2.c b/test/nptl/tst-timer2.c
new file mode 100644
index 000000000..60026c1ef
--- /dev/null
+++ b/test/nptl/tst-timer2.c
@@ -0,0 +1,65 @@
+/* Test for crashing bugs when trying to create too many timers. */
+
+#include <stdio.h>
+#include <time.h>
+#include <signal.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <unistd.h>
+
+#if _POSIX_THREADS
+# include <pthread.h>
+
+void
+thread (union sigval arg)
+{
+ puts ("Timeout");
+}
+
+int
+do_test (void)
+{
+ int i, res;
+ timer_t timerId;
+ struct itimerspec itval;
+ struct sigevent sigev;
+
+ itval.it_interval.tv_sec = 2;
+ itval.it_interval.tv_nsec = 0;
+ itval.it_value.tv_sec = 2;
+ itval.it_value.tv_nsec = 0;
+
+ sigev.sigev_notify = SIGEV_THREAD;
+ sigev.sigev_signo = SIGRTMIN;
+ sigev.sigev_notify_function = thread;
+ sigev.sigev_notify_attributes = 0;
+ sigev.sigev_value.sival_ptr = (void *) &timerId;
+
+ for (i = 0; i < 100; i++)
+ {
+ printf ("cnt = %d\n", i);
+
+ if (timer_create (CLOCK_REALTIME, &sigev, &timerId) < 0)
+ {
+ perror ("timer_create");
+ continue;
+ }
+
+ res = timer_settime (timerId, 0, &itval, NULL);
+ if (res < 0)
+ perror ("timer_settime");
+
+ res = timer_delete (timerId);
+ if (res < 0)
+ perror ("timer_delete");
+ }
+
+ return 0;
+}
+
+# define TEST_FUNCTION do_test ()
+#else
+# define TEST_FUNCTION 0
+#endif
+
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-timer3.c b/test/nptl/tst-timer3.c
new file mode 100644
index 000000000..8113f6690
--- /dev/null
+++ b/test/nptl/tst-timer3.c
@@ -0,0 +1,86 @@
+/* Test for bogus per-thread deletion of timers. */
+
+#include <stdio.h>
+#include <error.h>
+#include <time.h>
+#include <signal.h>
+#include <stdint.h>
+#include <string.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <unistd.h>
+#if _POSIX_THREADS
+# include <pthread.h>
+
+
+/* Creating timers in another thread should work too. */
+static void *
+do_timer_create (void *arg)
+{
+ struct sigevent *const sigev = arg;
+ timer_t *const timerId = sigev->sigev_value.sival_ptr;
+ if (timer_create (CLOCK_REALTIME, sigev, timerId) < 0)
+ {
+ printf ("timer_create: %m\n");
+ return NULL;
+ }
+ return timerId;
+}
+
+
+static int
+do_test (void)
+{
+ int i, res;
+ timer_t timerId;
+ struct itimerspec itval;
+ struct sigevent sigev;
+
+ itval.it_interval.tv_sec = 2;
+ itval.it_interval.tv_nsec = 0;
+ itval.it_value.tv_sec = 2;
+ itval.it_value.tv_nsec = 0;
+
+ sigev.sigev_notify = SIGEV_SIGNAL;
+ sigev.sigev_signo = SIGALRM;
+ sigev.sigev_value.sival_ptr = (void *) &timerId;
+
+ for (i = 0; i < 100; i++)
+ {
+ printf ("cnt = %d\n", i);
+
+ pthread_t thr;
+ res = pthread_create (&thr, NULL, &do_timer_create, &sigev);
+ if (res)
+ {
+ printf ("pthread_create: %s\n", strerror (res));
+ continue;
+ }
+ void *val;
+ res = pthread_join (thr, &val);
+ if (res)
+ {
+ printf ("pthread_join: %s\n", strerror (res));
+ continue;
+ }
+ if (val == NULL)
+ continue;
+
+ res = timer_settime (timerId, 0, &itval, NULL);
+ if (res < 0)
+ printf ("timer_settime: %m\n");
+
+ res = timer_delete (timerId);
+ if (res < 0)
+ printf ("timer_delete: %m\n");
+ }
+
+ return 0;
+}
+
+# define TEST_FUNCTION do_test ()
+#else
+# define TEST_FUNCTION 0
+#endif
+
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-timer4.c b/test/nptl/tst-timer4.c
new file mode 100644
index 000000000..fafb5651b
--- /dev/null
+++ b/test/nptl/tst-timer4.c
@@ -0,0 +1,647 @@
+/* Tests for POSIX timer implementation.
+ Copyright (C) 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2004
+
+ 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/>. */
+
+#include <errno.h>
+#include <signal.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+#if _POSIX_THREADS
+# include <pthread.h>
+
+# ifndef TEST_CLOCK
+# define TEST_CLOCK CLOCK_REALTIME
+# endif
+
+pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+
+timer_t timer_none, timer_sig1, timer_sig2, timer_thr1, timer_thr2;
+
+int thr1_cnt, thr1_err;
+union sigval thr1_sigval;
+struct timespec thr1_ts;
+
+static void
+thr1 (union sigval sigval)
+{
+ pthread_mutex_lock (&lock);
+ thr1_err = clock_gettime (TEST_CLOCK, &thr1_ts);
+ if (thr1_cnt >= 5)
+ {
+ struct itimerspec it = { };
+ thr1_err |= timer_settime (timer_thr1, 0, &it, NULL);
+ }
+ thr1_sigval = sigval;
+ ++thr1_cnt;
+ pthread_cond_signal (&cond);
+ pthread_mutex_unlock (&lock);
+}
+
+int thr2_cnt, thr2_err;
+union sigval thr2_sigval;
+size_t thr2_guardsize;
+struct timespec thr2_ts;
+
+static void
+thr2 (union sigval sigval)
+{
+ pthread_attr_t nattr;
+ int err = 0;
+ size_t guardsize = -1;
+ int ret = pthread_getattr_np (pthread_self (), &nattr);
+ if (ret)
+ {
+ errno = ret;
+ printf ("*** pthread_getattr_np failed: %m\n");
+ err = 1;
+ }
+ else
+ {
+ ret = pthread_attr_getguardsize (&nattr, &guardsize);
+ if (ret)
+ {
+ errno = ret;
+ printf ("*** pthread_attr_getguardsize failed: %m\n");
+ err = 1;
+ }
+ if (pthread_attr_destroy (&nattr) != 0)
+ {
+ puts ("*** pthread_attr_destroy failed");
+ err = 1;
+ }
+ }
+ pthread_mutex_lock (&lock);
+ thr2_err = clock_gettime (TEST_CLOCK, &thr2_ts) | err;
+ if (thr2_cnt >= 5)
+ {
+ struct itimerspec it = { };
+ thr2_err |= timer_settime (timer_thr2, 0, &it, NULL);
+ }
+ thr2_sigval = sigval;
+ ++thr2_cnt;
+ thr2_guardsize = guardsize;
+ pthread_cond_signal (&cond);
+ pthread_mutex_unlock (&lock);
+}
+
+volatile int sig1_cnt, sig1_err;
+volatile union sigval sig1_sigval;
+struct timespec sig1_ts;
+
+static void
+sig1_handler (int sig, siginfo_t *info, void *ctx)
+{
+ int err = 0;
+ if (sig != SIGRTMIN) err |= 1 << 0;
+ if (info->si_signo != SIGRTMIN) err |= 1 << 1;
+ if (info->si_code != SI_TIMER) err |= 1 << 2;
+ if (clock_gettime (TEST_CLOCK, &sig1_ts) != 0)
+ err |= 1 << 3;
+ if (sig1_cnt >= 5)
+ {
+ struct itimerspec it = { };
+ if (timer_settime (timer_sig1, 0, &it, NULL))
+ err |= 1 << 4;
+ }
+ sig1_err |= err;
+ sig1_sigval = info->si_value;
+ ++sig1_cnt;
+}
+
+volatile int sig2_cnt, sig2_err;
+volatile union sigval sig2_sigval;
+struct timespec sig2_ts;
+
+static void
+sig2_handler (int sig, siginfo_t *info, void *ctx)
+{
+ int err = 0;
+ if (sig != SIGRTMIN + 1) err |= 1 << 0;
+ if (info->si_signo != SIGRTMIN + 1) err |= 1 << 1;
+ if (info->si_code != SI_TIMER) err |= 1 << 2;
+ if (clock_gettime (TEST_CLOCK, &sig2_ts) != 0)
+ err |= 1 << 3;
+ if (sig2_cnt >= 5)
+ {
+ struct itimerspec it = { };
+ if (timer_settime (timer_sig2, 0, &it, NULL))
+ err |= 1 << 4;
+ }
+ sig2_err |= err;
+ sig2_sigval = info->si_value;
+ ++sig2_cnt;
+}
+
+/* Check if end is later or equal to start + nsec. */
+static int
+check_ts (const char *name, const struct timespec *start,
+ const struct timespec *end, long msec)
+{
+ struct timespec ts = *start;
+
+ ts.tv_sec += msec / 1000000;
+ ts.tv_nsec += (msec % 1000000) * 1000;
+ if (ts.tv_nsec >= 1000000000)
+ {
+ ++ts.tv_sec;
+ ts.tv_nsec -= 1000000000;
+ }
+ if (end->tv_sec < ts.tv_sec
+ || (end->tv_sec == ts.tv_sec && end->tv_nsec < ts.tv_nsec))
+ {
+ printf ("\
+*** timer %s invoked too soon: %ld.%09ld instead of expected %ld.%09ld\n",
+ name, (long) end->tv_sec, end->tv_nsec,
+ (long) ts.tv_sec, ts.tv_nsec);
+ return 1;
+ }
+ else
+ return 0;
+}
+
+#define TIMEOUT 15
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+ int result = 0;
+
+#ifdef TEST_CLOCK_MISSING
+ const char *missing = TEST_CLOCK_MISSING (TEST_CLOCK);
+ if (missing != NULL)
+ {
+ printf ("%s missing, skipping test\n", missing);
+ return 0;
+ }
+#endif
+
+ struct timespec ts;
+ if (clock_gettime (TEST_CLOCK, &ts) != 0)
+ {
+ printf ("*** clock_gettime failed: %m\n");
+ result = 1;
+ }
+ else
+ printf ("clock_gettime returned timespec = { %ld, %ld }\n",
+ (long) ts.tv_sec, ts.tv_nsec);
+
+ if (clock_getres (TEST_CLOCK, &ts) != 0)
+ {
+ printf ("*** clock_getres failed: %m\n");
+ result = 1;
+ }
+ else
+ printf ("clock_getres returned timespec = { %ld, %ld }\n",
+ (long) ts.tv_sec, ts.tv_nsec);
+
+ struct sigevent ev;
+ memset (&ev, 0x11, sizeof (ev));
+ ev.sigev_notify = SIGEV_NONE;
+ if (timer_create (TEST_CLOCK, &ev, &timer_none) != 0)
+ {
+ printf ("*** timer_create for timer_none failed: %m\n");
+ return 1;
+ }
+
+ struct sigaction sa = { .sa_sigaction = sig1_handler,
+ .sa_flags = SA_SIGINFO };
+ sigemptyset (&sa.sa_mask);
+ sigaction (SIGRTMIN, &sa, NULL);
+ sa.sa_sigaction = sig2_handler;
+ sigaction (SIGRTMIN + 1, &sa, NULL);
+
+ memset (&ev, 0x22, sizeof (ev));
+ ev.sigev_notify = SIGEV_SIGNAL;
+ ev.sigev_signo = SIGRTMIN;
+ ev.sigev_value.sival_ptr = &ev;
+ if (timer_create (TEST_CLOCK, &ev, &timer_sig1) != 0)
+ {
+ printf ("*** timer_create for timer_sig1 failed: %m\n");
+ return 1;
+ }
+
+ memset (&ev, 0x33, sizeof (ev));
+ ev.sigev_notify = SIGEV_SIGNAL;
+ ev.sigev_signo = SIGRTMIN + 1;
+ ev.sigev_value.sival_int = 163;
+ if (timer_create (TEST_CLOCK, &ev, &timer_sig2) != 0)
+ {
+ printf ("*** timer_create for timer_sig2 failed: %m\n");
+ return 1;
+ }
+
+ memset (&ev, 0x44, sizeof (ev));
+ ev.sigev_notify = SIGEV_THREAD;
+ ev.sigev_notify_function = thr1;
+ ev.sigev_notify_attributes = NULL;
+ ev.sigev_value.sival_ptr = &ev;
+ if (timer_create (TEST_CLOCK, &ev, &timer_thr1) != 0)
+ {
+ printf ("*** timer_create for timer_thr1 failed: %m\n");
+ return 1;
+ }
+
+ pthread_attr_t nattr;
+ if (pthread_attr_init (&nattr)
+ || pthread_attr_setguardsize (&nattr, 0))
+ {
+ puts ("*** pthread_attr_t setup failed");
+ result = 1;
+ }
+
+ memset (&ev, 0x55, sizeof (ev));
+ ev.sigev_notify = SIGEV_THREAD;
+ ev.sigev_notify_function = thr2;
+ ev.sigev_notify_attributes = &nattr;
+ ev.sigev_value.sival_int = 111;
+ if (timer_create (TEST_CLOCK, &ev, &timer_thr2) != 0)
+ {
+ printf ("*** timer_create for timer_thr2 failed: %m\n");
+ return 1;
+ }
+
+ int ret = timer_getoverrun (timer_thr1);
+ if (ret != 0)
+ {
+ if (ret == -1)
+ printf ("*** timer_getoverrun failed: %m\n");
+ else
+ printf ("*** timer_getoverrun returned %d != 0\n", ret);
+ result = 1;
+ }
+
+ struct itimerspec it;
+ it.it_value.tv_sec = 0;
+ it.it_value.tv_nsec = -26;
+ it.it_interval.tv_sec = 0;
+ it.it_interval.tv_nsec = 0;
+ if (timer_settime (timer_sig1, 0, &it, NULL) == 0)
+ {
+ puts ("*** timer_settime with negative tv_nsec unexpectedly succeeded");
+ result = 1;
+ }
+ else if (errno != EINVAL)
+ {
+ printf ("*** timer_settime with negative tv_nsec did not fail with "
+ "EINVAL: %m\n");
+ result = 1;
+ }
+
+ it.it_value.tv_nsec = 100000;
+ it.it_interval.tv_nsec = 1000000000;
+ if (timer_settime (timer_sig2, 0, &it, NULL) == 0)
+ {
+ puts ("\
+*** timer_settime with tv_nsec 1000000000 unexpectedly succeeded");
+ result = 1;
+ }
+ else if (errno != EINVAL)
+ {
+ printf ("*** timer_settime with tv_nsec 1000000000 did not fail with "
+ "EINVAL: %m\n");
+ result = 1;
+ }
+
+#if 0
+ it.it_value.tv_nsec = 0;
+ it.it_interval.tv_nsec = -26;
+ if (timer_settime (timer_thr1, 0, &it, NULL) != 0)
+ {
+ printf ("\
+!!! timer_settime with it_value 0 it_interval invalid failed: %m\n");
+ /* FIXME: is this mandated by POSIX?
+ result = 1; */
+ }
+
+ it.it_interval.tv_nsec = 3000000000;
+ if (timer_settime (timer_thr2, 0, &it, NULL) != 0)
+ {
+ printf ("\
+!!! timer_settime with it_value 0 it_interval invalid failed: %m\n");
+ /* FIXME: is this mandated by POSIX?
+ result = 1; */
+ }
+#endif
+
+ struct timespec startts;
+ if (clock_gettime (TEST_CLOCK, &startts) != 0)
+ {
+ printf ("*** clock_gettime failed: %m\n");
+ result = 1;
+ }
+
+ it.it_value.tv_nsec = 100000000;
+ it.it_interval.tv_nsec = 0;
+ if (timer_settime (timer_none, 0, &it, NULL) != 0)
+ {
+ printf ("*** timer_settime timer_none failed: %m\n");
+ result = 1;
+ }
+
+ it.it_value.tv_nsec = 200000000;
+ if (timer_settime (timer_thr1, 0, &it, NULL) != 0)
+ {
+ printf ("*** timer_settime timer_thr1 failed: %m\n");
+ result = 1;
+ }
+
+ it.it_value.tv_nsec = 300000000;
+ if (timer_settime (timer_thr2, 0, &it, NULL) != 0)
+ {
+ printf ("*** timer_settime timer_thr2 failed: %m\n");
+ result = 1;
+ }
+
+ it.it_value.tv_nsec = 400000000;
+ if (timer_settime (timer_sig1, 0, &it, NULL) != 0)
+ {
+ printf ("*** timer_settime timer_sig1 failed: %m\n");
+ result = 1;
+ }
+
+ it.it_value.tv_nsec = 500000000;
+ if (TEMP_FAILURE_RETRY (timer_settime (timer_sig2, 0, &it, NULL)) != 0)
+ {
+ printf ("*** timer_settime timer_sig2 failed: %m\n");
+ result = 1;
+ }
+
+ pthread_mutex_lock (&lock);
+ while (thr1_cnt == 0 || thr2_cnt == 0)
+ pthread_cond_wait (&cond, &lock);
+ pthread_mutex_unlock (&lock);
+
+ while (sig1_cnt == 0 || sig2_cnt == 0)
+ {
+ ts.tv_sec = 0;
+ ts.tv_nsec = 100000000;
+ nanosleep (&ts, NULL);
+ }
+
+ pthread_mutex_lock (&lock);
+
+ if (thr1_cnt != 1)
+ {
+ printf ("*** thr1 not called exactly once, but %d times\n", thr1_cnt);
+ result = 1;
+ }
+ else if (thr1_err)
+ {
+ puts ("*** an error occurred in thr1");
+ result = 1;
+ }
+ else if (thr1_sigval.sival_ptr != &ev)
+ {
+ printf ("*** thr1_sigval.sival_ptr %p != %p\n",
+ thr1_sigval.sival_ptr, &ev);
+ result = 1;
+ }
+ else if (check_ts ("thr1", &startts, &thr1_ts, 200000))
+ result = 1;
+
+ if (thr2_cnt != 1)
+ {
+ printf ("*** thr2 not called exactly once, but %d times\n", thr2_cnt);
+ result = 1;
+ }
+ else if (thr2_err)
+ {
+ puts ("*** an error occurred in thr2");
+ result = 1;
+ }
+ else if (thr2_sigval.sival_int != 111)
+ {
+ printf ("*** thr2_sigval.sival_ptr %d != 111\n", thr2_sigval.sival_int);
+ result = 1;
+ }
+ else if (check_ts ("thr2", &startts, &thr2_ts, 300000))
+ result = 1;
+ else if (thr2_guardsize != 0)
+ {
+ printf ("*** thr2 guardsize %zd != 0\n", thr2_guardsize);
+ result = 1;
+ }
+
+ pthread_mutex_unlock (&lock);
+
+ if (sig1_cnt != 1)
+ {
+ printf ("*** sig1 not called exactly once, but %d times\n", sig1_cnt);
+ result = 1;
+ }
+ else if (sig1_err)
+ {
+ printf ("*** errors occurred in sig1 handler %x\n", sig1_err);
+ result = 1;
+ }
+ else if (sig1_sigval.sival_ptr != &ev)
+ {
+ printf ("*** sig1_sigval.sival_ptr %p != %p\n",
+ sig1_sigval.sival_ptr, &ev);
+ result = 1;
+ }
+ else if (check_ts ("sig1", &startts, &sig1_ts, 400000))
+ result = 1;
+
+ if (sig2_cnt != 1)
+ {
+ printf ("*** sig2 not called exactly once, but %d times\n", sig2_cnt);
+ result = 1;
+ }
+ else if (sig2_err)
+ {
+ printf ("*** errors occurred in sig2 handler %x\n", sig2_err);
+ result = 1;
+ }
+ else if (sig2_sigval.sival_int != 163)
+ {
+ printf ("*** sig2_sigval.sival_ptr %d != 163\n", sig2_sigval.sival_int);
+ result = 1;
+ }
+ else if (check_ts ("sig2", &startts, &sig2_ts, 500000))
+ result = 1;
+
+ if (timer_gettime (timer_none, &it) != 0)
+ {
+ printf ("*** timer_gettime timer_none failed: %m\n");
+ result = 1;
+ }
+ else if (it.it_value.tv_sec || it.it_value.tv_nsec
+ || it.it_interval.tv_sec || it.it_interval.tv_nsec)
+ {
+ printf ("\
+*** timer_gettime timer_none returned { %ld.%09ld, %ld.%09ld }\n",
+ (long) it.it_value.tv_sec, it.it_value.tv_nsec,
+ (long) it.it_interval.tv_sec, it.it_interval.tv_nsec);
+ result = 1;
+ }
+
+ if (clock_gettime (TEST_CLOCK, &startts) != 0)
+ {
+ printf ("*** clock_gettime failed: %m\n");
+ result = 1;
+ }
+
+ it.it_value.tv_sec = 1;
+ it.it_value.tv_nsec = 0;
+ it.it_interval.tv_sec = 0;
+ it.it_interval.tv_nsec = 100000000;
+ if (timer_settime (timer_none, 0, &it, NULL) != 0)
+ {
+ printf ("*** timer_settime timer_none failed: %m\n");
+ result = 1;
+ }
+
+ it.it_value.tv_nsec = 100000000;
+ it.it_interval.tv_nsec = 200000000;
+ if (timer_settime (timer_thr1, 0, &it, NULL) != 0)
+ {
+ printf ("*** timer_settime timer_thr1 failed: %m\n");
+ result = 1;
+ }
+
+ it.it_value.tv_nsec = 200000000;
+ it.it_interval.tv_nsec = 300000000;
+ if (timer_settime (timer_thr2, 0, &it, NULL) != 0)
+ {
+ printf ("*** timer_settime timer_thr2 failed: %m\n");
+ result = 1;
+ }
+
+ it.it_value.tv_nsec = 300000000;
+ it.it_interval.tv_nsec = 400000000;
+ if (timer_settime (timer_sig1, 0, &it, NULL) != 0)
+ {
+ printf ("*** timer_settime timer_sig1 failed: %m\n");
+ result = 1;
+ }
+
+ it.it_value.tv_nsec = 400000000;
+ it.it_interval.tv_nsec = 500000000;
+ if (TEMP_FAILURE_RETRY (timer_settime (timer_sig2, 0, &it, NULL)) != 0)
+ {
+ printf ("*** timer_settime timer_sig2 failed: %m\n");
+ result = 1;
+ }
+
+ pthread_mutex_lock (&lock);
+ while (thr1_cnt < 6 || thr2_cnt < 6)
+ pthread_cond_wait (&cond, &lock);
+ pthread_mutex_unlock (&lock);
+
+ while (sig1_cnt < 6 || sig2_cnt < 6)
+ {
+ ts.tv_sec = 0;
+ ts.tv_nsec = 100000000;
+ nanosleep (&ts, NULL);
+ }
+
+ pthread_mutex_lock (&lock);
+
+ if (thr1_err)
+ {
+ puts ("*** an error occurred in thr1");
+ result = 1;
+ }
+ else if (check_ts ("thr1", &startts, &thr1_ts, 1100000 + 4 * 200000))
+ result = 1;
+
+ if (thr2_err)
+ {
+ puts ("*** an error occurred in thr2");
+ result = 1;
+ }
+ else if (check_ts ("thr2", &startts, &thr2_ts, 1200000 + 4 * 300000))
+ result = 1;
+ else if (thr2_guardsize != 0)
+ {
+ printf ("*** thr2 guardsize %zd != 0\n", thr2_guardsize);
+ result = 1;
+ }
+
+ pthread_mutex_unlock (&lock);
+
+ if (sig1_err)
+ {
+ printf ("*** errors occurred in sig1 handler %x\n", sig1_err);
+ result = 1;
+ }
+ else if (check_ts ("sig1", &startts, &sig1_ts, 1300000 + 4 * 400000))
+ result = 1;
+
+ if (sig2_err)
+ {
+ printf ("*** errors occurred in sig2 handler %x\n", sig2_err);
+ result = 1;
+ }
+ else if (check_ts ("sig2", &startts, &sig2_ts, 1400000 + 4 * 500000))
+ result = 1;
+
+ if (timer_gettime (timer_none, &it) != 0)
+ {
+ printf ("*** timer_gettime timer_none failed: %m\n");
+ result = 1;
+ }
+ else if (it.it_interval.tv_sec || it.it_interval.tv_nsec != 100000000)
+ {
+ printf ("\
+!!! second timer_gettime timer_none returned it_interval %ld.%09ld\n",
+ (long) it.it_interval.tv_sec, it.it_interval.tv_nsec);
+ /* FIXME: For now disabled.
+ result = 1; */
+ }
+
+ if (timer_delete (timer_none) != 0)
+ {
+ printf ("*** timer_delete for timer_none failed: %m\n");
+ result = 1;
+ }
+
+ if (timer_delete (timer_sig1) != 0)
+ {
+ printf ("*** timer_delete for timer_sig1 failed: %m\n");
+ result = 1;
+ }
+
+ if (timer_delete (timer_sig2) != 0)
+ {
+ printf ("*** timer_delete for timer_sig2 failed: %m\n");
+ result = 1;
+ }
+
+ if (timer_delete (timer_thr1) != 0)
+ {
+ printf ("*** timer_delete for timer_thr1 failed: %m\n");
+ result = 1;
+ }
+
+ if (timer_delete (timer_thr2) != 0)
+ {
+ printf ("*** timer_delete for timer_thr2 failed: %m\n");
+ result = 1;
+ }
+ return result;
+}
+#else
+# define TEST_FUNCTION 0
+#endif
+
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-timer5.c b/test/nptl/tst-timer5.c
new file mode 100644
index 000000000..6466c8efc
--- /dev/null
+++ b/test/nptl/tst-timer5.c
@@ -0,0 +1,38 @@
+/* Timer test using the monotonic clock. */
+
+#include <time.h>
+#include <unistd.h>
+
+#if defined CLOCK_MONOTONIC && defined _POSIX_MONOTONIC_CLOCK
+
+# define TEST_CLOCK CLOCK_MONOTONIC
+# define TEST_CLOCK_MISSING(clock) \
+ (setup_test () ? "CLOCK_MONOTONIC" : NULL)
+
+# include <stdio.h>
+
+static int
+setup_test (void)
+{
+ if (sysconf (_SC_MONOTONIC_CLOCK) <= 0)
+ return 1;
+
+ /* The user-level timers implementation doesn't support CLOCK_MONOTONIC,
+ even though sysconf claims it will. */
+ timer_t t;
+ if (timer_create (TEST_CLOCK, NULL, &t) != 0)
+ {
+ printf ("timer_create: %m\n");
+ return 1;
+ }
+ timer_delete (t);
+
+ return 0;
+}
+
+# include "tst-timer4.c"
+
+#else
+# define TEST_FUNCTION 0
+# include "../test-skeleton.c"
+#endif
diff --git a/test/nptl/tst-tls1.c b/test/nptl/tst-tls1.c
new file mode 100644
index 000000000..a7cf8f408
--- /dev/null
+++ b/test/nptl/tst-tls1.c
@@ -0,0 +1,121 @@
+/* Copyright (C) 2003, 2004 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 <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <tls.h>
+
+#if HAVE___THREAD
+struct test_s
+{
+ int a;
+ int b;
+};
+
+#define INIT_A 1
+#define INIT_B 42
+/* Deliberately not static. */
+__thread struct test_s s __attribute__ ((tls_model ("initial-exec"))) =
+{
+ .a = INIT_A,
+ .b = INIT_B
+};
+
+
+static void *
+tf (void *arg)
+{
+ if (s.a != INIT_A || s.b != INIT_B)
+ {
+ puts ("initial value of s in child thread wrong");
+ exit (1);
+ }
+
+ ++s.a;
+
+ return NULL;
+}
+#endif
+
+
+int
+do_test (void)
+{
+#if !HAVE___THREAD
+
+ puts ("No __thread support in compiler, test skipped.");
+
+ return 0;
+#else
+
+ if (s.a != INIT_A || s.b != INIT_B)
+ {
+ puts ("initial value of s in main thread wrong");
+ exit (1);
+ }
+
+ pthread_attr_t a;
+
+ if (pthread_attr_init (&a) != 0)
+ {
+ puts ("attr_init failed");
+ exit (1);
+ }
+
+ if (pthread_attr_setstacksize (&a, 1 * 1024 * 1024) != 0)
+ {
+ puts ("attr_setstacksize failed");
+ return 1;
+ }
+
+#define N 10
+ int i;
+ for (i = 0; i < N; ++i)
+ {
+#define M 10
+ pthread_t th[M];
+ int j;
+ for (j = 0; j < M; ++j, ++s.a)
+ if (pthread_create (&th[j], &a, tf, NULL) != 0)
+ {
+ puts ("pthread_create failed");
+ exit (1);
+ }
+
+ for (j = 0; j < M; ++j)
+ if (pthread_join (th[j], NULL) != 0)
+ {
+ puts ("pthread_join failed");
+ exit (1);
+ }
+ }
+
+ if (pthread_attr_destroy (&a) != 0)
+ {
+ puts ("attr_destroy failed");
+ exit (1);
+ }
+
+ return 0;
+#endif
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-tls2.c b/test/nptl/tst-tls2.c
new file mode 100644
index 000000000..f60f4a5e3
--- /dev/null
+++ b/test/nptl/tst-tls2.c
@@ -0,0 +1,215 @@
+/* Copyright (C) 2003, 2004 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 <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <semaphore.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <tls.h>
+
+#if HAVE___THREAD
+
+#define N 10
+static pthread_t th[N];
+
+
+#define CB(n) \
+static void \
+cb##n (void) \
+{ \
+ if (th[n] != pthread_self ()) \
+ { \
+ write (STDOUT_FILENO, "wrong callback\n", 15); \
+ _exit (1); \
+ } \
+}
+CB (0)
+CB (1)
+CB (2)
+CB (3)
+CB (4)
+CB (5)
+CB (6)
+CB (7)
+CB (8)
+CB (9)
+static void (*cbs[]) (void) =
+{
+ cb0, cb1, cb2, cb3, cb4, cb5, cb6, cb7, cb8, cb9
+};
+
+
+static __thread void (*fp) (void) __attribute__ ((tls_model ("local-exec")));
+
+
+static sem_t s;
+
+
+#define THE_SIG SIGUSR1
+static void
+handler (int sig)
+{
+ if (sig != THE_SIG)
+ {
+ write (STDOUT_FILENO, "wrong signal\n", 13);
+ _exit (1);
+ }
+
+ fp ();
+
+ if (sem_post (&s) != 0)
+ {
+ write (STDOUT_FILENO, "sem_post failed\n", 16);
+ _exit (1);
+ }
+}
+
+
+static pthread_barrier_t b;
+
+#define TOTAL_SIGS 1000
+static int nsigs;
+
+
+static void *
+tf (void *arg)
+{
+ fp = arg;
+
+ pthread_barrier_wait (&b);
+
+ pthread_barrier_wait (&b);
+
+ if (nsigs != TOTAL_SIGS)
+ {
+ puts ("barrier_wait prematurely returns");
+ exit (1);
+ }
+
+ return NULL;
+}
+#endif
+
+int
+do_test (void)
+{
+#if !HAVE___THREAD
+
+ puts ("No __thread support in compiler, test skipped.");
+
+ return 0;
+#else
+
+ if (pthread_barrier_init (&b, NULL, N + 1) != 0)
+ {
+ puts ("barrier_init failed");
+ exit (1);
+ }
+
+ if (sem_init (&s, 0, 0) != 0)
+ {
+ puts ("sem_init failed");
+ exit (1);
+ }
+
+ struct sigaction sa;
+ sa.sa_handler = handler;
+ sigemptyset (&sa.sa_mask);
+ sa.sa_flags = 0;
+ if (sigaction (THE_SIG, &sa, NULL) != 0)
+ {
+ puts ("sigaction failed");
+ exit (1);
+ }
+
+ pthread_attr_t a;
+
+ if (pthread_attr_init (&a) != 0)
+ {
+ puts ("attr_init failed");
+ exit (1);
+ }
+
+ if (pthread_attr_setstacksize (&a, 1 * 1024 * 1024) != 0)
+ {
+ puts ("attr_setstacksize failed");
+ return 1;
+ }
+
+ int i;
+ for (i = 0; i < N; ++i)
+ if (pthread_create (&th[i], &a, tf, cbs[i]) != 0)
+ {
+ puts ("pthread_create failed");
+ exit (1);
+ }
+
+ if (pthread_attr_destroy (&a) != 0)
+ {
+ puts ("attr_destroy failed");
+ exit (1);
+ }
+
+ pthread_barrier_wait (&b);
+
+ sigset_t ss;
+ sigemptyset (&ss);
+ sigaddset (&ss, THE_SIG);
+ if (pthread_sigmask (SIG_BLOCK, &ss, NULL) != 0)
+ {
+ puts ("pthread_sigmask failed");
+ exit (1);
+ }
+
+ /* Start sending signals. */
+ for (i = 0; i < TOTAL_SIGS; ++i)
+ {
+ if (kill (getpid (), THE_SIG) != 0)
+ {
+ puts ("kill failed");
+ exit (1);
+ }
+
+ if (TEMP_FAILURE_RETRY (sem_wait (&s)) != 0)
+ {
+ puts ("sem_wait failed");
+ exit (1);
+ }
+
+ ++nsigs;
+ }
+
+ pthread_barrier_wait (&b);
+
+ for (i = 0; i < N; ++i)
+ if (pthread_join (th[i], NULL) != 0)
+ {
+ puts ("join failed");
+ exit (1);
+ }
+
+ return 0;
+#endif
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-tls3.c b/test/nptl/tst-tls3.c
new file mode 100644
index 000000000..0d4e5140c
--- /dev/null
+++ b/test/nptl/tst-tls3.c
@@ -0,0 +1,224 @@
+/* Copyright (C) 2003, 2004 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 <dlfcn.h>
+#include <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <semaphore.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <pthreaddef.h>
+#include <tls.h>
+
+#define THE_SIG SIGUSR1
+
+
+#define N 10
+static pthread_t th[N];
+
+
+#define CB(n) \
+static void \
+cb##n (void) \
+{ \
+ if (th[n] != pthread_self ()) \
+ { \
+ write (STDOUT_FILENO, "wrong callback\n", 15); \
+ _exit (1); \
+ } \
+}
+CB (0)
+CB (1)
+CB (2)
+CB (3)
+CB (4)
+CB (5)
+CB (6)
+CB (7)
+CB (8)
+CB (9)
+static void (*cbs[]) (void) =
+{
+ cb0, cb1, cb2, cb3, cb4, cb5, cb6, cb7, cb8, cb9
+};
+
+
+sem_t s;
+
+
+pthread_barrier_t b;
+
+#define TOTAL_SIGS 1000
+int nsigs;
+
+
+int
+do_test (void)
+{
+#if !HAVE___THREAD
+
+ puts ("No __thread support in compiler, test skipped.");
+
+ return 0;
+#else
+
+ if ((uintptr_t) pthread_self () & (TCB_ALIGNMENT - 1))
+ {
+ puts ("initial thread's struct pthread not aligned enough");
+ exit (1);
+ }
+
+ if (pthread_barrier_init (&b, NULL, N + 1) != 0)
+ {
+ puts ("barrier_init failed");
+ exit (1);
+ }
+
+ if (sem_init (&s, 0, 0) != 0)
+ {
+ puts ("sem_init failed");
+ exit (1);
+ }
+
+ void *h = dlopen ("tst-tls3mod.so", RTLD_LAZY);
+ if (h == NULL)
+ {
+ puts ("dlopen failed");
+ exit (1);
+ }
+
+ void *(*tf) (void *) = dlsym (h, "tf");
+ if (tf == NULL)
+ {
+ puts ("dlsym for tf failed");
+ exit (1);
+ }
+
+ void (*setup_tf) (pthread_barrier_t*, int*, sem_t*) = dlsym(h, "setup_tf");
+ if (setup_tf == NULL)
+ {
+ puts ("dlsym for setup_tf failed");
+ exit(1);
+ }
+
+ setup_tf (&b, &nsigs, &s);
+
+ struct sigaction sa;
+ sa.sa_handler = dlsym (h, "handler");
+ if (sa.sa_handler == NULL)
+ {
+ puts ("dlsym for handler failed");
+ exit (1);
+ }
+ sigemptyset (&sa.sa_mask);
+ sa.sa_flags = 0;
+ if (sigaction (THE_SIG, &sa, NULL) != 0)
+ {
+ puts ("sigaction failed");
+ exit (1);
+ }
+
+ pthread_attr_t a;
+
+ if (pthread_attr_init (&a) != 0)
+ {
+ puts ("attr_init failed");
+ exit (1);
+ }
+
+ if (pthread_attr_setstacksize (&a, 1 * 1024 * 1024) != 0)
+ {
+ puts ("attr_setstacksize failed");
+ return 1;
+ }
+
+ int r;
+ for (r = 0; r < 10; ++r)
+ {
+ int i;
+ for (i = 0; i < N; ++i)
+ if (pthread_create (&th[i], &a, tf, cbs[i]) != 0)
+ {
+ puts ("pthread_create failed");
+ exit (1);
+ }
+
+ nsigs = 0;
+
+ pthread_barrier_wait (&b);
+
+ sigset_t ss;
+ sigemptyset (&ss);
+ sigaddset (&ss, THE_SIG);
+ if (pthread_sigmask (SIG_BLOCK, &ss, NULL) != 0)
+ {
+ puts ("pthread_sigmask failed");
+ exit (1);
+ }
+
+ /* Start sending signals. */
+ for (i = 0; i < TOTAL_SIGS; ++i)
+ {
+ if (kill (getpid (), THE_SIG) != 0)
+ {
+ puts ("kill failed");
+ exit (1);
+ }
+
+ if (TEMP_FAILURE_RETRY (sem_wait (&s)) != 0)
+ {
+ puts ("sem_wait failed");
+ exit (1);
+ }
+
+ ++nsigs;
+ }
+
+ pthread_barrier_wait (&b);
+
+ if (pthread_sigmask (SIG_UNBLOCK, &ss, NULL) != 0)
+ {
+ puts ("pthread_sigmask failed");
+ exit (1);
+ }
+
+ for (i = 0; i < N; ++i)
+ if (pthread_join (th[i], NULL) != 0)
+ {
+ puts ("join failed");
+ exit (1);
+ }
+ }
+
+ if (pthread_attr_destroy (&a) != 0)
+ {
+ puts ("attr_destroy failed");
+ exit (1);
+ }
+
+ return 0;
+#endif
+}
+
+
+#define TIMEOUT 5
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-tls3mod.c b/test/nptl/tst-tls3mod.c
new file mode 100644
index 000000000..0fd326162
--- /dev/null
+++ b/test/nptl/tst-tls3mod.c
@@ -0,0 +1,105 @@
+/* Copyright (C) 2003 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 <pthread.h>
+#include <semaphore.h>
+#include <signal.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <pthreaddef.h>
+#include <tls.h>
+
+#if HAVE___THREAD
+
+static pthread_barrier_t* b = NULL;
+
+#define TOTAL_SIGS 1000
+static int* nsigs = NULL;
+
+static sem_t* s = NULL;
+
+static __thread void (*fp) (void);
+
+
+#define THE_SIG SIGUSR1
+void
+handler (int sig)
+{
+ if (sig != THE_SIG)
+ {
+ write (STDOUT_FILENO, "wrong signal\n", 13);
+ _exit (1);
+ }
+
+ fp ();
+
+ if (sem_post (s) != 0)
+ {
+ write (STDOUT_FILENO, "sem_post failed\n", 16);
+ _exit (1);
+ }
+}
+
+void
+setup_tf (pthread_barrier_t* t_b, int* t_nsigs, sem_t* t_s)
+{
+ b = t_b;
+ nsigs = t_nsigs;
+ s = t_s;
+}
+
+void *
+tf (void *arg)
+{
+ if (!b || !s || !nsigs)
+ {
+ puts ("need to call setup_tf first");
+ exit (1);
+ }
+
+ if ((uintptr_t) pthread_self () & (TCB_ALIGNMENT - 1))
+ {
+ puts ("thread's struct pthread not aligned enough");
+ exit (1);
+ }
+
+ if (fp != NULL)
+ {
+ printf("fp=%p\n", (void *)&fp);
+ puts ("fp not initially NULL");
+ exit (1);
+ }
+
+ fp = arg;
+
+ pthread_barrier_wait (b);
+
+ pthread_barrier_wait (b);
+
+ if (*nsigs != TOTAL_SIGS)
+ {
+ puts ("barrier_wait prematurely returns");
+ exit (1);
+ }
+
+ return NULL;
+}
+
+#endif
diff --git a/test/nptl/tst-tls4.c b/test/nptl/tst-tls4.c
new file mode 100644
index 000000000..378b13aae
--- /dev/null
+++ b/test/nptl/tst-tls4.c
@@ -0,0 +1,190 @@
+/* Copyright (C) 2003 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/>. */
+
+#include <dlfcn.h>
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <tls.h>
+
+#if HAVE___THREAD && defined HAVE_TLS_MODEL_ATTRIBUTE
+
+#define N 3
+
+void (*test1) (void), (*test2) (void);
+
+pthread_barrier_t b2, b3;
+
+static void *
+tf (void *arg)
+{
+ int i;
+
+ for (i = 0; i <= (uintptr_t) arg; ++i)
+ {
+ int r = pthread_barrier_wait (&b3);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("tf: barrier_wait failed");
+ exit (1);
+ }
+ }
+
+ test1 ();
+
+ for (i = 0; i < 3; ++i)
+ {
+ int r = pthread_barrier_wait (&b3);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("tf: barrier_wait failed");
+ exit (1);
+ }
+ }
+
+ test2 ();
+
+ for (i = 0; i < 3 - (uintptr_t) arg; ++i)
+ {
+ int r = pthread_barrier_wait (&b3);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("tf: barrier_wait failed");
+ exit (1);
+ }
+ }
+
+ return NULL;
+}
+
+static void *
+tf2 (void *arg)
+{
+ int r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("tf2: barrier_wait failed");
+ exit (1);
+ }
+
+ int i;
+ for (i = 0; i < N; ++i)
+ tf (arg);
+ return NULL;
+}
+
+int
+do_test (void)
+{
+ pthread_t th[2];
+ const char *modules[N]
+ = { "tst-tls4moda.so", "tst-tls4moda.so", "tst-tls4modb.so" };
+
+ if (pthread_barrier_init (&b2, NULL, 2) != 0)
+ {
+ puts ("barrier_init failed");
+ return 1;
+ }
+
+ if (pthread_barrier_init (&b3, NULL, 3) != 0)
+ {
+ puts ("barrier_init failed");
+ return 1;
+ }
+
+ if (pthread_create (&th[0], NULL, tf2, (void *) (uintptr_t) 1))
+ {
+ puts ("pthread_create failed");
+ return 1;
+ }
+
+ int r = pthread_barrier_wait (&b2);
+ if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+ {
+ puts ("barrier_wait failed");
+ return 1;
+ }
+
+ int i;
+ for (i = 0; i < N; ++i)
+ {
+ void *h = dlopen (modules[i], RTLD_LAZY);
+ if (h == NULL)
+ {
+ printf ("dlopen failed %s\n", dlerror ());
+ return 1;
+ }
+
+ test1 = dlsym (h, "test1");
+ if (test1 == NULL)
+ {
+ printf ("dlsym for test1 failed %s\n", dlerror ());
+ return 1;
+ }
+
+ test2 = dlsym (h, "test2");
+ if (test2 == NULL)
+ {
+ printf ("dlsym for test2 failed %s\n", dlerror ());
+ return 1;
+ }
+
+ if (pthread_create (&th[1], NULL, tf, (void *) (uintptr_t) 2))
+ {
+ puts ("pthread_create failed");
+ return 1;
+ }
+
+ tf ((void *) (uintptr_t) 0);
+
+ if (pthread_join (th[1], NULL) != 0)
+ {
+ puts ("join failed");
+ return 1;
+ }
+
+ if (dlclose (h))
+ {
+ puts ("dlclose failed");
+ return 1;
+ }
+
+ printf ("test %d with %s succeeded\n", i, modules[i]);
+ }
+
+ if (pthread_join (th[0], NULL) != 0)
+ {
+ puts ("join failed");
+ return 1;
+ }
+
+ return 0;
+}
+
+#define TIMEOUT 5
+#define TEST_FUNCTION do_test ()
+
+#else
+
+#define TEST_FUNCTION 0
+
+#endif
+
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-tls4moda.c b/test/nptl/tst-tls4moda.c
new file mode 100644
index 000000000..9a59cf7a2
--- /dev/null
+++ b/test/nptl/tst-tls4moda.c
@@ -0,0 +1,55 @@
+/* Copyright (C) 2003 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/>. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <tls.h>
+
+#if HAVE___THREAD && defined HAVE_TLS_MODEL_ATTRIBUTE
+
+static __thread unsigned char foo [32]
+ __attribute__ ((tls_model ("initial-exec"), aligned (sizeof (void *))));
+
+void
+test1 (void)
+{
+ size_t s;
+
+ for (s = 0; s < sizeof (foo); ++s)
+ {
+ if (foo [s])
+ abort ();
+ foo [s] = s;
+ }
+}
+
+void
+test2 (void)
+{
+ size_t s;
+
+ for (s = 0; s < sizeof (foo); ++s)
+ {
+ if (foo [s] != s)
+ abort ();
+ foo [s] = sizeof (foo) - s;
+ }
+}
+
+#endif
diff --git a/test/nptl/tst-tls4modb.c b/test/nptl/tst-tls4modb.c
new file mode 100644
index 000000000..66044b2ed
--- /dev/null
+++ b/test/nptl/tst-tls4modb.c
@@ -0,0 +1,64 @@
+/* Copyright (C) 2003 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/>. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <tls.h>
+
+#if HAVE___THREAD && defined HAVE_TLS_MODEL_ATTRIBUTE
+
+static int i;
+int bar;
+
+static __thread void *foo [32 / sizeof (void *)]
+ __attribute__ ((tls_model ("initial-exec"), aligned (sizeof (void *))))
+ = { &i, &bar };
+
+void
+test1 (void)
+{
+ size_t s;
+
+ if (foo [0] != &i || foo [1] != &bar)
+ abort ();
+
+ foo [0] = NULL;
+ foo [1] = NULL;
+ for (s = 0; s < sizeof (foo) / sizeof (void *); ++s)
+ {
+ if (foo [s])
+ abort ();
+ foo [s] = &foo[s];
+ }
+}
+
+void
+test2 (void)
+{
+ size_t s;
+
+ for (s = 0; s < sizeof (foo) / sizeof (void *); ++s)
+ {
+ if (foo [s] != &foo [s])
+ abort ();
+ foo [s] = &foo [s ^ 1];
+ }
+}
+
+#endif
diff --git a/test/nptl/tst-tls5.c b/test/nptl/tst-tls5.c
new file mode 100644
index 000000000..c8afe6a87
--- /dev/null
+++ b/test/nptl/tst-tls5.c
@@ -0,0 +1,118 @@
+/* Copyright (C) 2003 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/>. */
+
+/* Check alignment, overlapping and layout of TLS variables. */
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <sys/param.h>
+
+#include "tst-tls5.h"
+
+#ifdef TLS_REGISTER
+
+struct tls_obj tls_registry[64];
+
+static int
+tls_addr_cmp (const void *a, const void *b)
+{
+ if (((struct tls_obj *)a)->addr < ((struct tls_obj *)b)->addr)
+ return -1;
+ if (((struct tls_obj *)a)->addr > ((struct tls_obj *)b)->addr)
+ return 1;
+ return 0;
+}
+
+static int
+do_test (void)
+{
+ size_t cnt, i;
+ int res = 0;
+ uintptr_t min_addr = ~(uintptr_t) 0, max_addr = 0;
+
+ for (cnt = 0; tls_registry[cnt].name; ++cnt);
+ tls_registry[cnt].name = NULL;
+ tls_registry[cnt].addr = (uintptr_t) pthread_self ();
+ tls_registry[cnt].size = sizeof (struct pthread);
+ tls_registry[cnt++].align = __alignof__ (struct pthread);
+
+ qsort (tls_registry, cnt, sizeof (struct tls_obj), tls_addr_cmp);
+
+ for (i = 0; i < cnt; ++i)
+ {
+ printf ("%s%s = %p, size %zd, align %zd",
+ tls_registry[i].name ? "&" : "",
+ tls_registry[i].name ?: "pthread_self ()",
+ (void *) tls_registry[i].addr,
+ tls_registry[i].size, tls_registry[i].align);
+ if (tls_registry[i].addr & (tls_registry[i].align - 1))
+ {
+ fputs (", WRONG ALIGNMENT", stdout);
+ res = 1;
+ }
+ if (i > 0
+ && (tls_registry[i - 1].addr + tls_registry[i - 1].size
+ > tls_registry[i].addr))
+ {
+ fputs (", ADDRESS OVERLAP", stdout);
+ res = 1;
+ }
+ puts ("");
+ if (tls_registry[i].name)
+ {
+ min_addr = MIN (tls_registry[i].addr, min_addr);
+ max_addr = MAX (tls_registry[i].addr + tls_registry[i].size,
+ max_addr);
+ }
+ }
+
+ if (cnt > 1)
+ {
+#if defined(TLS_TCB_AT_TP)
+ if (tls_registry[cnt - 1].name)
+ {
+ puts ("pthread_self () not larger than all TLS addresses");
+ res = 1;
+ }
+ else
+ max_addr = MAX (tls_registry[cnt - 1].addr, max_addr);
+#elif defined(TLS_DTV_AT_TP)
+ if (tls_registry[0].name)
+ {
+ puts ("pthread_self () not smaller than all TLS addresses");
+ res = 1;
+ }
+#else
+ abort ();
+#endif
+ printf ("Initial TLS used block size %zd\n",
+ (size_t) (max_addr - min_addr));
+ }
+ return res;
+}
+
+#define TEST_FUNCTION do_test ()
+
+#else
+
+#define TEST_FUNCTION 0
+
+#endif
+
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-tls5.h b/test/nptl/tst-tls5.h
new file mode 100644
index 000000000..b7c14eb82
--- /dev/null
+++ b/test/nptl/tst-tls5.h
@@ -0,0 +1,28 @@
+#include <stdint.h>
+#include <stdlib.h>
+#include <tls.h>
+
+#if USE_TLS && HAVE___THREAD
+
+struct tls_obj
+{
+ const char *name;
+ uintptr_t addr;
+ size_t size;
+ size_t align;
+};
+extern struct tls_obj tls_registry[];
+
+#define TLS_REGISTER(x) \
+static void __attribute__((constructor)) \
+tls_register_##x (void) \
+{ \
+ size_t i; \
+ for (i = 0; tls_registry[i].name; ++i); \
+ tls_registry[i].name = #x; \
+ tls_registry[i].addr = (uintptr_t) &x; \
+ tls_registry[i].size = sizeof (x); \
+ tls_registry[i].align = __alignof__ (x); \
+}
+
+#endif
diff --git a/test/nptl/tst-tls5mod.c b/test/nptl/tst-tls5mod.c
new file mode 100644
index 000000000..4616a20e9
--- /dev/null
+++ b/test/nptl/tst-tls5mod.c
@@ -0,0 +1,6 @@
+#include "tst-tls5.h"
+
+#ifdef TLS_REGISTER
+/* Ensure tls_registry is exported from the binary. */
+void *tst_tls5mod attribute_hidden = tls_registry;
+#endif
diff --git a/test/nptl/tst-tls5moda.c b/test/nptl/tst-tls5moda.c
new file mode 100644
index 000000000..4644d763a
--- /dev/null
+++ b/test/nptl/tst-tls5moda.c
@@ -0,0 +1,6 @@
+#include "tst-tls5.h"
+
+#ifdef TLS_REGISTER
+static __thread char a [32] __attribute__ ((aligned (64)));
+TLS_REGISTER (a)
+#endif
diff --git a/test/nptl/tst-tls5modb.c b/test/nptl/tst-tls5modb.c
new file mode 100644
index 000000000..09b439670
--- /dev/null
+++ b/test/nptl/tst-tls5modb.c
@@ -0,0 +1,6 @@
+#include "tst-tls5.h"
+
+#ifdef TLS_REGISTER
+static __thread int b;
+TLS_REGISTER (b)
+#endif
diff --git a/test/nptl/tst-tls5modc.c b/test/nptl/tst-tls5modc.c
new file mode 100644
index 000000000..bbd89633d
--- /dev/null
+++ b/test/nptl/tst-tls5modc.c
@@ -0,0 +1,6 @@
+#include "tst-tls5.h"
+
+#ifdef TLS_REGISTER
+static __thread int c;
+TLS_REGISTER (c)
+#endif
diff --git a/test/nptl/tst-tls5modd.c b/test/nptl/tst-tls5modd.c
new file mode 100644
index 000000000..8b54d168c
--- /dev/null
+++ b/test/nptl/tst-tls5modd.c
@@ -0,0 +1,6 @@
+#include "tst-tls5.h"
+
+#ifdef TLS_REGISTER
+static __thread int d;
+TLS_REGISTER (d)
+#endif
diff --git a/test/nptl/tst-tls5mode.c b/test/nptl/tst-tls5mode.c
new file mode 100644
index 000000000..d30b06752
--- /dev/null
+++ b/test/nptl/tst-tls5mode.c
@@ -0,0 +1,8 @@
+#include "tst-tls5.h"
+
+#ifdef TLS_REGISTER
+static __thread int e1 = 24;
+static __thread char e2 [32] __attribute__ ((aligned (64)));
+TLS_REGISTER (e1)
+TLS_REGISTER (e2)
+#endif
diff --git a/test/nptl/tst-tls5modf.c b/test/nptl/tst-tls5modf.c
new file mode 100644
index 000000000..52dcb9495
--- /dev/null
+++ b/test/nptl/tst-tls5modf.c
@@ -0,0 +1,9 @@
+#include "tst-tls5.h"
+
+#ifdef TLS_REGISTER
+char tst_tls5modf[60] attribute_hidden = { 26 };
+static __thread int f1 = 24;
+static __thread char f2 [32] __attribute__ ((aligned (64)));
+TLS_REGISTER (f1)
+TLS_REGISTER (f2)
+#endif
diff --git a/test/nptl/tst-tsd1.c b/test/nptl/tst-tsd1.c
new file mode 100644
index 000000000..af46d685b
--- /dev/null
+++ b/test/nptl/tst-tsd1.c
@@ -0,0 +1,117 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread.h>
+#include <stdio.h>
+#include <string.h>
+
+
+static int
+do_test (void)
+{
+ pthread_key_t key1;
+ pthread_key_t key2;
+ void *value;
+ int result = 0;
+ int err;
+
+ err = pthread_key_create (&key1, NULL);
+ if (err != 0)
+ {
+ printf ("1st key_create failed: %s\n", strerror (err));
+ return 1;
+ }
+
+ /* Initial value must be NULL. */
+ value = pthread_getspecific (key1);
+ if (value != NULL)
+ {
+ puts ("1st getspecific != NULL");
+ result = 1;
+ }
+
+ err = pthread_setspecific (key1, (void *) -2l);
+ if (err != 0)
+ {
+ printf ("1st setspecific failed: %s\n", strerror (err));
+ return 1;
+ }
+
+ value = pthread_getspecific (key1);
+ if (value == NULL)
+ {
+ puts ("2nd getspecific == NULL\n");
+ result = 1;
+ }
+ else if (value != (void *) -2l)
+ {
+ puts ("2nd getspecific != -2l\n");
+ result = 1;
+ }
+
+ err = pthread_setspecific (key1, (void *) -3l);
+ if (err != 0)
+ {
+ printf ("2nd setspecific failed: %s\n", strerror (err));
+ return 1;
+ }
+
+ value = pthread_getspecific (key1);
+ if (value == NULL)
+ {
+ puts ("3rd getspecific == NULL\n");
+ result = 1;
+ }
+ else if (value != (void *) -3l)
+ {
+ puts ("3rd getspecific != -2l\n");
+ result = 1;
+ }
+
+ err = pthread_key_delete (key1);
+ if (err != 0)
+ {
+ printf ("key_delete failed: %s\n", strerror (err));
+ result = 1;
+ }
+
+
+ err = pthread_key_create (&key2, NULL);
+ if (err != 0)
+ {
+ printf ("2nd key_create failed: %s\n", strerror (err));
+ return 1;
+ }
+
+ if (key1 != key2)
+ puts ("key1 != key2; no more tests performed");
+ else
+ {
+ value = pthread_getspecific (key2);
+ if (value != NULL)
+ {
+ puts ("4th getspecific != NULL");
+ result = 1;
+ }
+ }
+
+ return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-tsd2.c b/test/nptl/tst-tsd2.c
new file mode 100644
index 000000000..71e793fd4
--- /dev/null
+++ b/test/nptl/tst-tsd2.c
@@ -0,0 +1,96 @@
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <pthread.h>
+#include <stdio.h>
+#include <string.h>
+
+
+static int result;
+
+
+static void
+destr (void *arg)
+{
+ if (arg != (void *) -2l)
+ result = 2;
+ else
+ result = 0;
+}
+
+
+static void *
+tf (void *arg)
+{
+ pthread_key_t key = (pthread_key_t) (long int) arg;
+ int err;
+
+ err = pthread_setspecific (key, (void *) -2l);
+ if (err != 0)
+ result = 3;
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ pthread_key_t key;
+ pthread_t th;
+ int err;
+
+ err = pthread_key_create (&key, destr);
+ if (err != 0)
+ {
+ printf ("key_create failed: %s\n", strerror (err));
+ return 1;
+ }
+
+ result = 1;
+
+ err = pthread_create (&th, NULL, tf, (void *) (long int) key);
+ if (err != 0)
+ {
+ printf ("create failed: %s\n", strerror (err));
+ return 1;
+ }
+
+ /* Wait for the thread to terminate. */
+ err = pthread_join (th, NULL);
+ if (err != 0)
+ {
+ printf ("join failed: %s\n", strerror (err));
+ return 1;
+ }
+
+ if (result == 1)
+ puts ("destructor not called");
+ else if (result == 2)
+ puts ("destructor got passed a wrong value");
+ else if (result == 3)
+ puts ("setspecific in child failed");
+ else if (result != 0)
+ puts ("result != 0");
+
+ return result;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-tsd3.c b/test/nptl/tst-tsd3.c
new file mode 100644
index 000000000..4dc46f2a8
--- /dev/null
+++ b/test/nptl/tst-tsd3.c
@@ -0,0 +1,128 @@
+/* Copyright (C) 2003 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 <limits.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static pthread_key_t key1;
+static pthread_key_t key2;
+
+
+static int left;
+
+
+static void
+destr1 (void *arg)
+{
+ if (--left > 0)
+ {
+ puts ("set key2");
+
+ if (pthread_setspecific (key2, (void *) 1l) != 0)
+ {
+ puts ("destr1: setspecific failed");
+ exit (1);
+ }
+ }
+}
+
+
+static void
+destr2 (void *arg)
+{
+ if (--left > 0)
+ {
+ puts ("set key1");
+
+ if (pthread_setspecific (key1, (void *) 1l) != 0)
+ {
+ puts ("destr2: setspecific failed");
+ exit (1);
+ }
+ }
+}
+
+
+static void *
+tf (void *arg)
+{
+ /* Let the destructors work. */
+ left = 7;
+
+ if (pthread_setspecific (key1, (void *) 1l) != 0
+ || pthread_setspecific (key2, (void *) 1l) != 0)
+ {
+ puts ("tf: setspecific failed");
+ exit (1);
+ }
+
+ return NULL;
+}
+
+
+static int
+do_test (void)
+{
+ /* Allocate two keys, both with destructors. */
+ if (pthread_key_create (&key1, destr1) != 0
+ || pthread_key_create (&key2, destr2) != 0)
+ {
+ puts ("key_create failed");
+ return 1;
+ }
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ return 1;
+ }
+
+ if (pthread_join (th, NULL) != 0)
+ {
+ puts ("join failed");
+ return 1;
+ }
+
+ if (left != 0)
+ {
+ printf ("left == %d\n", left);
+ return 1;
+ }
+
+ if (pthread_getspecific (key1) != NULL)
+ {
+ puts ("key1 data != NULL");
+ return 1;
+ }
+ if (pthread_getspecific (key2) != NULL)
+ {
+ puts ("key2 data != NULL");
+ return 1;
+ }
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-tsd4.c b/test/nptl/tst-tsd4.c
new file mode 100644
index 000000000..cf58d8581
--- /dev/null
+++ b/test/nptl/tst-tsd4.c
@@ -0,0 +1,102 @@
+/* Copyright (C) 2003 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 <limits.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+static pthread_key_t key;
+
+
+static int rounds;
+
+
+static void
+destr (void *arg)
+{
+ ++rounds;
+
+ if (pthread_setspecific (key, (void *) 1l) != 0)
+ {
+ puts ("destr: setspecific failed");
+ exit (1);
+ }
+}
+
+
+static void *
+tf (void *arg)
+{
+ if (pthread_setspecific (key, (void *) 1l) != 0)
+ {
+ puts ("tf: setspecific failed");
+ exit (1);
+ }
+
+ return NULL;
+}
+
+
+/* This test check non-standard behavior. The standard does not
+ require that the implementation has to stop calling TSD destructors
+ when they are set over and over again. But NPTL does. */
+static int
+do_test (void)
+{
+ /* Allocate two keys, both with destructors. */
+ if (pthread_key_create (&key, destr) != 0)
+ {
+ puts ("key_create failed");
+ return 1;
+ }
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ return 1;
+ }
+
+ if (pthread_join (th, NULL) != 0)
+ {
+ puts ("join failed");
+ return 1;
+ }
+
+ if (rounds < PTHREAD_DESTRUCTOR_ITERATIONS)
+ {
+ printf ("rounds == %d, PTHREAD_DESTRUCTOR_ITERATIONS = %d\n",
+ rounds, PTHREAD_DESTRUCTOR_ITERATIONS);
+ return 1;
+ }
+
+ if (pthread_getspecific (key) != NULL)
+ {
+ puts ("key data != NULL");
+ return 1;
+ }
+
+ return 0;
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-tsd5.c b/test/nptl/tst-tsd5.c
new file mode 100644
index 000000000..8fc7b35ef
--- /dev/null
+++ b/test/nptl/tst-tsd5.c
@@ -0,0 +1,80 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
+
+ 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 <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
+
+
+static void
+cl (void *p)
+{
+ pthread_mutex_unlock (&m);
+}
+
+
+static void *
+tf (void *arg)
+{
+ if (pthread_mutex_lock (&m) != 0)
+ {
+ puts ("2nd mutex_lock failed");
+ exit (1);
+ }
+
+ exit (0);
+}
+
+
+static int
+do_test (void)
+{
+ pthread_key_t k;
+ if (pthread_key_create (&k, cl) != 0)
+ {
+ puts ("key_create failed");
+ return 1;
+ }
+ if (pthread_setspecific (k, (void *) 1) != 0)
+ {
+ puts ("setspecific failed");
+ return 1;
+ }
+
+ if (pthread_mutex_lock (&m) != 0)
+ {
+ puts ("1st mutex_lock failed");
+ return 1;
+ }
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("create failed");
+ return 1;
+ }
+
+ pthread_exit (NULL);
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-tsd6.c b/test/nptl/tst-tsd6.c
new file mode 100644
index 000000000..debb1dd36
--- /dev/null
+++ b/test/nptl/tst-tsd6.c
@@ -0,0 +1,89 @@
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+#define NKEYS 100
+static pthread_key_t keys[NKEYS];
+static pthread_barrier_t b;
+
+
+static void *
+tf (void *arg)
+{
+ void *res = NULL;
+ for (int i = 0; i < NKEYS; ++i)
+ {
+ void *p = pthread_getspecific (keys[i]);
+ pthread_setspecific (keys[i], (void *) 7);
+ if (p != NULL)
+ res = p;
+ }
+ if (arg != NULL)
+ {
+ pthread_barrier_wait (arg);
+ pthread_barrier_wait (arg);
+ }
+ return res;
+}
+
+
+static int
+do_test (void)
+{
+ pthread_barrier_init (&b, NULL, 2);
+
+ for (int i = 0; i < NKEYS; ++i)
+ if (pthread_key_create (&keys[i], NULL) != 0)
+ {
+ puts ("cannot create keys");
+ return 1;
+ }
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, &b) != 0)
+ {
+ puts ("cannot create thread in parent");
+ return 1;
+ }
+
+ pthread_barrier_wait (&b);
+
+ pid_t pid = fork ();
+ if (pid == 0)
+ {
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("cannot create thread in child");
+ exit (1);
+ }
+
+ void *res;
+ pthread_join (th, &res);
+
+ exit (res != NULL);
+ }
+ else if (pid == -1)
+ {
+ puts ("cannot create child process");
+ return 1;
+ }
+
+ int s;
+ if (TEMP_FAILURE_RETRY (waitpid (pid, &s, 0)) != pid)
+ {
+ puts ("failing to wait for child process");
+ return 1;
+ }
+
+ pthread_barrier_wait (&b);
+ pthread_join (th, NULL);
+
+ return !WIFEXITED (s) ? 2 : WEXITSTATUS (s);
+}
+
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-typesizes.c b/test/nptl/tst-typesizes.c
new file mode 100644
index 000000000..59e948527
--- /dev/null
+++ b/test/nptl/tst-typesizes.c
@@ -0,0 +1,95 @@
+/* Copyright (C) 2005, 2007, 2008 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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 <stdio.h>
+#include <pthreadP.h>
+#include <semaphore.h>
+
+static const struct
+{
+ const char *name;
+ size_t expected;
+ size_t is;
+} types[] =
+ {
+#define T(t, c) \
+ { #t, c, sizeof (t) }
+ T (pthread_attr_t, __SIZEOF_PTHREAD_ATTR_T),
+ T (pthread_mutex_t, __SIZEOF_PTHREAD_MUTEX_T),
+ T (pthread_mutexattr_t, __SIZEOF_PTHREAD_MUTEXATTR_T),
+ T (pthread_cond_t, __SIZEOF_PTHREAD_COND_T),
+ T (pthread_condattr_t, __SIZEOF_PTHREAD_CONDATTR_T),
+ T (pthread_rwlock_t, __SIZEOF_PTHREAD_RWLOCK_T),
+ T (pthread_rwlockattr_t, __SIZEOF_PTHREAD_RWLOCKATTR_T),
+ T (pthread_barrier_t, __SIZEOF_PTHREAD_BARRIER_T),
+ T (pthread_barrierattr_t, __SIZEOF_PTHREAD_BARRIERATTR_T)
+ };
+
+static int
+do_test (void)
+{
+ int result = 0;
+
+#define TEST_TYPE(name) \
+ printf ("%s: ", #name); \
+ if (sizeof (name) != sizeof (((name *) 0)->__size)) \
+ { \
+ printf ("expected %zu, is %zu\n", \
+ sizeof (((name *) 0)->__size), sizeof (name)); \
+ result = 1; \
+ } \
+ else \
+ puts ("OK")
+
+ TEST_TYPE (pthread_mutex_t);
+ TEST_TYPE (pthread_cond_t);
+ TEST_TYPE (pthread_rwlock_t);
+
+#define TEST_TYPE2(name, internal) \
+ printf ("%s: ", #name); \
+ if (sizeof (((name *) 0)->__size) < sizeof (internal)) \
+ { \
+ printf ("expected %zu, is %zu\n", \
+ sizeof (((name *) 0)->__size), sizeof (internal)); \
+ result = 1; \
+ } \
+ else \
+ puts ("OK")
+
+ TEST_TYPE2 (pthread_attr_t, struct pthread_attr);
+ TEST_TYPE2 (pthread_mutexattr_t, struct pthread_mutexattr);
+ TEST_TYPE2 (pthread_condattr_t, struct pthread_condattr);
+ TEST_TYPE2 (pthread_rwlockattr_t, struct pthread_rwlockattr);
+ TEST_TYPE2 (pthread_barrier_t, struct pthread_barrier);
+ TEST_TYPE2 (pthread_barrierattr_t, struct pthread_barrierattr);
+ TEST_TYPE2 (sem_t, struct new_sem);
+ TEST_TYPE2 (sem_t, struct old_sem);
+
+ for (size_t i = 0; i < sizeof (types) / sizeof (types[0]); ++i)
+ if (types[i].expected != types[i].is)
+ {
+ printf ("%s: expected %zu, is %zu\n",
+ types[i].name, types[i].expected, types[i].is);
+ result = 1;
+ }
+
+ return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-umask1.c b/test/nptl/tst-umask1.c
new file mode 100644
index 000000000..65b4df35b
--- /dev/null
+++ b/test/nptl/tst-umask1.c
@@ -0,0 +1,136 @@
+/* Copyright (C) 2003 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 <fcntl.h>
+#include <pthread.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+
+static struct
+{
+ int (*fp) (const char *, mode_t);
+ const char *name;
+ bool is_fd;
+} fcts[] =
+{
+ { creat, "creat", true },
+ { mkdir, "mkdir", false },
+ { mkfifo, "mkfifo", false },
+};
+#define nfcts (sizeof (fcts) / sizeof (fcts[0]))
+
+
+static int
+work (const char *fname, int mask)
+{
+ int result = 0;
+ size_t i;
+ for (i = 0; i < nfcts; ++i)
+ {
+ remove (fname);
+ int fd = fcts[i].fp (fname, 0777);
+ if (fd == -1)
+ {
+ printf ("cannot %s %s: %m\n", fcts[i].name, fname);
+ exit (1);
+ }
+ if (fcts[i].is_fd)
+ close (fd);
+ struct stat st;
+ if (stat (fname, &st) == -1)
+ {
+ printf ("cannot stat %s after %s: %m\n", fname, fcts[i].name);
+ exit (1);
+ }
+
+ if ((st.st_mode & mask) != 0)
+ {
+ printf ("mask not successful after %s: %x still set\n",
+ fcts[i].name, (unsigned int) (st.st_mode & mask));
+ result = 1;
+ }
+ }
+
+ return result;
+}
+
+
+static pthread_barrier_t bar;
+
+
+static void *
+tf (void *arg)
+{
+ pthread_barrier_wait (&bar);
+
+ int result = work (arg, 022);
+
+ pthread_barrier_wait (&bar);
+
+ pthread_barrier_wait (&bar);
+
+ return (work (arg, 0) | result) ? (void *) -1l : NULL;
+}
+
+
+static int
+do_test (const char *fname)
+{
+ int result = 0;
+
+ umask (0);
+ result |= work (fname, 0);
+
+ pthread_barrier_init (&bar, NULL, 2);
+
+ pthread_t th;
+ if (pthread_create (&th, NULL, tf, (void *) fname) != 0)
+ {
+ puts ("cannot create thread");
+ exit (1);
+ }
+
+ umask (022);
+ result |= work (fname, 022);
+
+ pthread_barrier_wait (&bar);
+
+ pthread_barrier_wait (&bar);
+
+ umask (0);
+
+ pthread_barrier_wait (&bar);
+
+ void *res;
+ if (pthread_join (th, &res) != 0)
+ {
+ puts ("join failed");
+ exit (1);
+ }
+
+ remove (fname);
+
+ return result || res != NULL;
+}
+
+#define TEST_FUNCTION do_test (argc < 2 ? "/tmp/tst-umask.tmp" : argv[1])
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-unload.c b/test/nptl/tst-unload.c
new file mode 100644
index 000000000..74a714ecb
--- /dev/null
+++ b/test/nptl/tst-unload.c
@@ -0,0 +1,46 @@
+/* Tests for non-unloading of libpthread.
+ Copyright (C) 2000, 2002, 2003, 2004 Free Software Foundation, Inc.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2000.
+
+ 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/>. */
+
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+static int
+do_test (void)
+{
+ void *p = dlopen ("libpthread.so.1", RTLD_LAZY);
+
+ if (p == NULL)
+ {
+ puts ("failed to load libpthread.so.1");
+ return 1;
+ }
+
+ if (dlclose (p) != 0)
+ {
+ puts ("dlclose (libpthread.so.1) failed");
+ return 1;
+ }
+
+ puts ("seems to work");
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-vfork1.c b/test/nptl/tst-vfork1.c
new file mode 100644
index 000000000..b3c9d207d
--- /dev/null
+++ b/test/nptl/tst-vfork1.c
@@ -0,0 +1,149 @@
+/* Test for vfork functions.
+ Copyright (C) 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
+
+ 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 <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+/* This test relies on non-POSIX functionality since the child
+ processes call write and getpid. */
+static int
+do_test (void)
+{
+ int result = 0;
+ int fd[2];
+
+ if (pipe (fd) == -1)
+ {
+ puts ("pipe failed");
+ return 1;
+ }
+
+ /* First vfork() without previous getpid(). */
+ pid_t p1;
+ if ((p1 = vfork ()) == 0)
+ {
+ pid_t p = getpid ();
+ _exit (TEMP_FAILURE_RETRY (write (fd[1], &p, sizeof (p))) != sizeof (p));
+ }
+ else if (p1 == -1)
+ {
+ puts ("1st vfork failed");
+ result = 1;
+ }
+
+ pid_t p2 = 0;
+ if (TEMP_FAILURE_RETRY (read (fd[0], &p2, sizeof (pid_t))) != sizeof (pid_t))
+ {
+ puts ("1st read failed");
+ result = 1;
+ }
+ int r;
+ if (TEMP_FAILURE_RETRY (waitpid (p1, &r, 0)) != p1)
+ {
+ puts ("1st waitpid failed");
+ result = 1;
+ }
+ else if (r != 0)
+ {
+ puts ("write in 1st child failed");
+ result = 1;
+ }
+
+ /* Main process' ID. */
+ pid_t p0 = getpid ();
+
+ /* vfork() again, but after a getpid() in the main process. */
+ pid_t p3;
+ if ((p3 = vfork ()) == 0)
+ {
+ pid_t p = getpid ();
+ _exit (TEMP_FAILURE_RETRY (write (fd[1], &p, sizeof (p))) != sizeof (p));
+ }
+ else if (p1 == -1)
+ {
+ puts ("2nd vfork failed");
+ result = 1;
+ }
+
+ pid_t p4;
+ if (TEMP_FAILURE_RETRY (read (fd[0], &p4, sizeof (pid_t))) != sizeof (pid_t))
+ {
+ puts ("2nd read failed");
+ result = 1;
+ }
+ if (TEMP_FAILURE_RETRY (waitpid (p3, &r, 0)) != p3)
+ {
+ puts ("2nd waitpid failed");
+ result = 1;
+ }
+ else if (r != 0)
+ {
+ puts ("write in 2nd child failed");
+ result = 1;
+ }
+
+ /* And getpid in the main process again. */
+ pid_t p5 = getpid ();
+
+ /* Analysis of the results. */
+ if (p0 != p5)
+ {
+ printf ("p0(%ld) != p5(%ld)\n", (long int) p0, (long int) p5);
+ result = 1;
+ }
+
+ if (p0 == p1)
+ {
+ printf ("p0(%ld) == p1(%ld)\n", (long int) p0, (long int) p1);
+ result = 1;
+ }
+
+ if (p1 != p2)
+ {
+ printf ("p1(%ld) != p2(%ld)\n", (long int) p1, (long int) p2);
+ result = 1;
+ }
+
+ if (p0 == p3)
+ {
+ printf ("p0(%ld) == p3(%ld)\n", (long int) p0, (long int) p3);
+ result = 1;
+ }
+
+ if (p3 != p4)
+ {
+ printf ("p3(%ld) != p4(%ld)\n", (long int) p3, (long int) p4);
+ result = 1;
+ }
+
+ close (fd[0]);
+ close (fd[1]);
+
+ if (result == 0)
+ puts ("All OK");
+
+ return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-vfork1x.c b/test/nptl/tst-vfork1x.c
new file mode 100644
index 000000000..b3c9d207d
--- /dev/null
+++ b/test/nptl/tst-vfork1x.c
@@ -0,0 +1,149 @@
+/* Test for vfork functions.
+ Copyright (C) 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
+
+ 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 <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+/* This test relies on non-POSIX functionality since the child
+ processes call write and getpid. */
+static int
+do_test (void)
+{
+ int result = 0;
+ int fd[2];
+
+ if (pipe (fd) == -1)
+ {
+ puts ("pipe failed");
+ return 1;
+ }
+
+ /* First vfork() without previous getpid(). */
+ pid_t p1;
+ if ((p1 = vfork ()) == 0)
+ {
+ pid_t p = getpid ();
+ _exit (TEMP_FAILURE_RETRY (write (fd[1], &p, sizeof (p))) != sizeof (p));
+ }
+ else if (p1 == -1)
+ {
+ puts ("1st vfork failed");
+ result = 1;
+ }
+
+ pid_t p2 = 0;
+ if (TEMP_FAILURE_RETRY (read (fd[0], &p2, sizeof (pid_t))) != sizeof (pid_t))
+ {
+ puts ("1st read failed");
+ result = 1;
+ }
+ int r;
+ if (TEMP_FAILURE_RETRY (waitpid (p1, &r, 0)) != p1)
+ {
+ puts ("1st waitpid failed");
+ result = 1;
+ }
+ else if (r != 0)
+ {
+ puts ("write in 1st child failed");
+ result = 1;
+ }
+
+ /* Main process' ID. */
+ pid_t p0 = getpid ();
+
+ /* vfork() again, but after a getpid() in the main process. */
+ pid_t p3;
+ if ((p3 = vfork ()) == 0)
+ {
+ pid_t p = getpid ();
+ _exit (TEMP_FAILURE_RETRY (write (fd[1], &p, sizeof (p))) != sizeof (p));
+ }
+ else if (p1 == -1)
+ {
+ puts ("2nd vfork failed");
+ result = 1;
+ }
+
+ pid_t p4;
+ if (TEMP_FAILURE_RETRY (read (fd[0], &p4, sizeof (pid_t))) != sizeof (pid_t))
+ {
+ puts ("2nd read failed");
+ result = 1;
+ }
+ if (TEMP_FAILURE_RETRY (waitpid (p3, &r, 0)) != p3)
+ {
+ puts ("2nd waitpid failed");
+ result = 1;
+ }
+ else if (r != 0)
+ {
+ puts ("write in 2nd child failed");
+ result = 1;
+ }
+
+ /* And getpid in the main process again. */
+ pid_t p5 = getpid ();
+
+ /* Analysis of the results. */
+ if (p0 != p5)
+ {
+ printf ("p0(%ld) != p5(%ld)\n", (long int) p0, (long int) p5);
+ result = 1;
+ }
+
+ if (p0 == p1)
+ {
+ printf ("p0(%ld) == p1(%ld)\n", (long int) p0, (long int) p1);
+ result = 1;
+ }
+
+ if (p1 != p2)
+ {
+ printf ("p1(%ld) != p2(%ld)\n", (long int) p1, (long int) p2);
+ result = 1;
+ }
+
+ if (p0 == p3)
+ {
+ printf ("p0(%ld) == p3(%ld)\n", (long int) p0, (long int) p3);
+ result = 1;
+ }
+
+ if (p3 != p4)
+ {
+ printf ("p3(%ld) != p4(%ld)\n", (long int) p3, (long int) p4);
+ result = 1;
+ }
+
+ close (fd[0]);
+ close (fd[1]);
+
+ if (result == 0)
+ puts ("All OK");
+
+ return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-vfork2.c b/test/nptl/tst-vfork2.c
new file mode 100644
index 000000000..6b2d98bac
--- /dev/null
+++ b/test/nptl/tst-vfork2.c
@@ -0,0 +1,198 @@
+/* Test for vfork functions.
+ Copyright (C) 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
+
+ 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 <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+int raise_fail;
+
+static void
+alrm (int sig)
+{
+ if (raise (SIGUSR1) < 0)
+ raise_fail = 1;
+}
+
+/* This test relies on non-POSIX functionality since the child
+ processes call write, nanosleep and getpid. */
+static int
+do_test (void)
+{
+ int result = 0;
+ int fd[2];
+
+ signal (SIGUSR1, SIG_IGN);
+
+ struct sigaction sa;
+ sa.sa_handler = alrm;
+ sigemptyset (&sa.sa_mask);
+ sa.sa_flags = 0;
+ if (sigaction (SIGALRM, &sa, NULL) < 0)
+ {
+ puts ("couldn't set up SIGALRM handler");
+ return 1;
+ }
+
+ if (pipe (fd) == -1)
+ {
+ puts ("pipe failed");
+ return 1;
+ }
+
+ struct itimerval it;
+ it.it_value.tv_sec = 0;
+ it.it_value.tv_usec = 200 * 1000;
+ it.it_interval = it.it_value;
+ if (setitimer (ITIMER_REAL, &it, NULL) < 0)
+ {
+ puts ("couldn't set up timer");
+ return 1;
+ }
+
+ /* First vfork() without previous getpid(). */
+ pid_t p1;
+ if ((p1 = vfork ()) == 0)
+ {
+ pid_t p = getpid ();
+
+ struct timespec ts;
+ ts.tv_sec = 1;
+ ts.tv_nsec = 0;
+ TEMP_FAILURE_RETRY (nanosleep (&ts, &ts));
+ _exit (TEMP_FAILURE_RETRY (write (fd[1], &p, sizeof (p))) != sizeof (p));
+ }
+ else if (p1 == -1)
+ {
+ puts ("1st vfork failed");
+ result = 1;
+ }
+
+ memset (&it, 0, sizeof (it));
+ setitimer (ITIMER_REAL, &it, NULL);
+
+ pid_t p2 = 0;
+ if (TEMP_FAILURE_RETRY (read (fd[0], &p2, sizeof (pid_t))) != sizeof (pid_t))
+ {
+ puts ("1st read failed");
+ result = 1;
+ }
+ int r;
+ if (TEMP_FAILURE_RETRY (waitpid (p1, &r, 0)) != p1)
+ {
+ puts ("1st waitpid failed");
+ result = 1;
+ }
+ else if (r != 0)
+ {
+ puts ("write in 1st child failed");
+ result = 1;
+ }
+
+ /* Main process' ID. */
+ pid_t p0 = getpid ();
+
+ /* vfork() again, but after a getpid() in the main process. */
+ pid_t p3;
+ if ((p3 = vfork ()) == 0)
+ {
+ pid_t p = getpid ();
+ _exit (TEMP_FAILURE_RETRY (write (fd[1], &p, sizeof (p))) != sizeof (p));
+ }
+ else if (p1 == -1)
+ {
+ puts ("2nd vfork failed");
+ result = 1;
+ }
+
+ pid_t p4;
+ if (TEMP_FAILURE_RETRY (read (fd[0], &p4, sizeof (pid_t))) != sizeof (pid_t))
+ {
+ puts ("2nd read failed");
+ result = 1;
+ }
+ if (TEMP_FAILURE_RETRY (waitpid (p3, &r, 0)) != p3)
+ {
+ puts ("2nd waitpid failed");
+ result = 1;
+ }
+ else if (r != 0)
+ {
+ puts ("write in 2nd child failed");
+ result = 1;
+ }
+
+ /* And getpid in the main process again. */
+ pid_t p5 = getpid ();
+
+ /* Analysis of the results. */
+ if (p0 != p5)
+ {
+ printf ("p0(%ld) != p5(%ld)\n", (long int) p0, (long int) p5);
+ result = 1;
+ }
+
+ if (p0 == p1)
+ {
+ printf ("p0(%ld) == p1(%ld)\n", (long int) p0, (long int) p1);
+ result = 1;
+ }
+
+ if (p1 != p2)
+ {
+ printf ("p1(%ld) != p2(%ld)\n", (long int) p1, (long int) p2);
+ result = 1;
+ }
+
+ if (p0 == p3)
+ {
+ printf ("p0(%ld) == p3(%ld)\n", (long int) p0, (long int) p3);
+ result = 1;
+ }
+
+ if (p3 != p4)
+ {
+ printf ("p3(%ld) != p4(%ld)\n", (long int) p3, (long int) p4);
+ result = 1;
+ }
+
+ close (fd[0]);
+ close (fd[1]);
+
+ if (raise_fail)
+ {
+ puts ("raise failed");
+ result = 1;
+ }
+
+ if (result == 0)
+ puts ("All OK");
+
+ return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/nptl/tst-vfork2x.c b/test/nptl/tst-vfork2x.c
new file mode 100644
index 000000000..6b2d98bac
--- /dev/null
+++ b/test/nptl/tst-vfork2x.c
@@ -0,0 +1,198 @@
+/* Test for vfork functions.
+ Copyright (C) 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
+
+ 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 <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+int raise_fail;
+
+static void
+alrm (int sig)
+{
+ if (raise (SIGUSR1) < 0)
+ raise_fail = 1;
+}
+
+/* This test relies on non-POSIX functionality since the child
+ processes call write, nanosleep and getpid. */
+static int
+do_test (void)
+{
+ int result = 0;
+ int fd[2];
+
+ signal (SIGUSR1, SIG_IGN);
+
+ struct sigaction sa;
+ sa.sa_handler = alrm;
+ sigemptyset (&sa.sa_mask);
+ sa.sa_flags = 0;
+ if (sigaction (SIGALRM, &sa, NULL) < 0)
+ {
+ puts ("couldn't set up SIGALRM handler");
+ return 1;
+ }
+
+ if (pipe (fd) == -1)
+ {
+ puts ("pipe failed");
+ return 1;
+ }
+
+ struct itimerval it;
+ it.it_value.tv_sec = 0;
+ it.it_value.tv_usec = 200 * 1000;
+ it.it_interval = it.it_value;
+ if (setitimer (ITIMER_REAL, &it, NULL) < 0)
+ {
+ puts ("couldn't set up timer");
+ return 1;
+ }
+
+ /* First vfork() without previous getpid(). */
+ pid_t p1;
+ if ((p1 = vfork ()) == 0)
+ {
+ pid_t p = getpid ();
+
+ struct timespec ts;
+ ts.tv_sec = 1;
+ ts.tv_nsec = 0;
+ TEMP_FAILURE_RETRY (nanosleep (&ts, &ts));
+ _exit (TEMP_FAILURE_RETRY (write (fd[1], &p, sizeof (p))) != sizeof (p));
+ }
+ else if (p1 == -1)
+ {
+ puts ("1st vfork failed");
+ result = 1;
+ }
+
+ memset (&it, 0, sizeof (it));
+ setitimer (ITIMER_REAL, &it, NULL);
+
+ pid_t p2 = 0;
+ if (TEMP_FAILURE_RETRY (read (fd[0], &p2, sizeof (pid_t))) != sizeof (pid_t))
+ {
+ puts ("1st read failed");
+ result = 1;
+ }
+ int r;
+ if (TEMP_FAILURE_RETRY (waitpid (p1, &r, 0)) != p1)
+ {
+ puts ("1st waitpid failed");
+ result = 1;
+ }
+ else if (r != 0)
+ {
+ puts ("write in 1st child failed");
+ result = 1;
+ }
+
+ /* Main process' ID. */
+ pid_t p0 = getpid ();
+
+ /* vfork() again, but after a getpid() in the main process. */
+ pid_t p3;
+ if ((p3 = vfork ()) == 0)
+ {
+ pid_t p = getpid ();
+ _exit (TEMP_FAILURE_RETRY (write (fd[1], &p, sizeof (p))) != sizeof (p));
+ }
+ else if (p1 == -1)
+ {
+ puts ("2nd vfork failed");
+ result = 1;
+ }
+
+ pid_t p4;
+ if (TEMP_FAILURE_RETRY (read (fd[0], &p4, sizeof (pid_t))) != sizeof (pid_t))
+ {
+ puts ("2nd read failed");
+ result = 1;
+ }
+ if (TEMP_FAILURE_RETRY (waitpid (p3, &r, 0)) != p3)
+ {
+ puts ("2nd waitpid failed");
+ result = 1;
+ }
+ else if (r != 0)
+ {
+ puts ("write in 2nd child failed");
+ result = 1;
+ }
+
+ /* And getpid in the main process again. */
+ pid_t p5 = getpid ();
+
+ /* Analysis of the results. */
+ if (p0 != p5)
+ {
+ printf ("p0(%ld) != p5(%ld)\n", (long int) p0, (long int) p5);
+ result = 1;
+ }
+
+ if (p0 == p1)
+ {
+ printf ("p0(%ld) == p1(%ld)\n", (long int) p0, (long int) p1);
+ result = 1;
+ }
+
+ if (p1 != p2)
+ {
+ printf ("p1(%ld) != p2(%ld)\n", (long int) p1, (long int) p2);
+ result = 1;
+ }
+
+ if (p0 == p3)
+ {
+ printf ("p0(%ld) == p3(%ld)\n", (long int) p0, (long int) p3);
+ result = 1;
+ }
+
+ if (p3 != p4)
+ {
+ printf ("p3(%ld) != p4(%ld)\n", (long int) p3, (long int) p4);
+ result = 1;
+ }
+
+ close (fd[0]);
+ close (fd[1]);
+
+ if (raise_fail)
+ {
+ puts ("raise failed");
+ result = 1;
+ }
+
+ if (result == 0)
+ puts ("All OK");
+
+ return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/plt/check-plt.sh b/test/plt/check-plt.sh
new file mode 100755
index 000000000..bedc8fd35
--- /dev/null
+++ b/test/plt/check-plt.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+allowed="
+calloc
+free
+malloc
+memalign
+realloc
+"
+
+${OBJDUMP:-objdump} -d ${top_builddir:-../..}/lib/libc.so.? | \
+gawk -v allowed="${allowed}" '
+BEGIN {
+ COUNT = split(" " allowed, ALLOWED);
+}
+
+# Strip away the noise. The name will be like:
+# <brk>:
+# <foo@plt>
+function symstrip(name) {
+ return gensub(/.*<([^>@]*).*/, "\\1", "", name);
+}
+
+{
+# Match the start of the symbol disassembly
+# 00009720 <brk>:
+if ($2 ~ />:$/) {
+ f = symstrip($2);
+
+} else if ($NF ~ /@plt>/) {
+ rf = symstrip($NF);
+ for (a in ALLOWED) {
+ a = ALLOWED[a];
+ if (a == rf)
+ next;
+ }
+ print "Func " f " references " rf;
+}
+}' | sort -u
diff --git a/test/pthread/Makefile b/test/pthread/Makefile
index ef924ad1a..97ebee894 100644
--- a/test/pthread/Makefile
+++ b/test/pthread/Makefile
@@ -1,8 +1,8 @@
# uClibc pthread tests
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+top_builddir=../../
+top_srcdir=../../
+include ../Rules.mak
+-include Makefile.in
include ../Test.mak
-
-EXTRA_LDFLAGS := -lpthread
-
-LDFLAGS_cancellation-points := -lrt
diff --git a/test/pthread/Makefile.in b/test/pthread/Makefile.in
new file mode 100644
index 000000000..c50748d69
--- /dev/null
+++ b/test/pthread/Makefile.in
@@ -0,0 +1,8 @@
+# uClibc pthread tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+TESTS_DISABLED += cancellation-points
+
+EXTRA_LDFLAGS := -lpthread
+
+LDFLAGS_cancellation-points := -lrt
diff --git a/test/pthread/cancellation-points.c b/test/pthread/cancellation-points.c
index 3fe49fcaa..5453060f7 100644
--- a/test/pthread/cancellation-points.c
+++ b/test/pthread/cancellation-points.c
@@ -29,12 +29,12 @@
/* take care of optional things ... */
#define STUB(func, args) static void func args { sleep(0); }
-#if !defined(__UCLIBC__) || defined(__UCLIBC_AIO__)
+#if defined(__UCLIBC_AIO__)
# include <aio.h>
#else
STUB(aio_suspend, (void *p, int n, const void *p2))
#endif
-#if !defined(__UCLIBC__) || defined(__UCLIBC_STROPTS__)
+#if defined(__UCLIBC_STROPTS__)
# include <stropts.h>
#else
STUB(getmsg, (int f, void *p, void *p2, void *p3))
@@ -141,7 +141,9 @@ MAKE_CANCEL_THREAD_FUNC_EX(sem_wait, (&sem), help_sem_setup())
MAKE_CANCEL_THREAD_FUNC(send, (-1, NULL, 0, 0))
MAKE_CANCEL_THREAD_FUNC(sendmsg, (-1, NULL, 0))
MAKE_CANCEL_THREAD_FUNC(sendto, (-1, NULL, 0, 0, NULL, 0))
+#ifdef __UCLIBC_SUSV4_LEGACY__
MAKE_CANCEL_THREAD_FUNC(sigpause, (0))
+#endif
MAKE_CANCEL_THREAD_FUNC(sigsuspend, (NULL))
MAKE_CANCEL_THREAD_FUNC(sigtimedwait, (NULL, NULL, NULL))
MAKE_CANCEL_THREAD_FUNC(sigwait, (NULL, NULL))
@@ -149,7 +151,9 @@ MAKE_CANCEL_THREAD_FUNC(sigwaitinfo, (NULL, NULL))
MAKE_CANCEL_THREAD_FUNC(sleep, (0))
MAKE_CANCEL_THREAD_FUNC(system, (""))
MAKE_CANCEL_THREAD_FUNC(tcdrain, (-1))
+#ifdef __UCLIBC_SUSV3_LEGACY__
MAKE_CANCEL_THREAD_FUNC(usleep, (0))
+#endif
MAKE_CANCEL_THREAD_FUNC(wait, (NULL))
MAKE_CANCEL_THREAD_FUNC(waitid, (0, 0, NULL, 0))
MAKE_CANCEL_THREAD_FUNC(waitpid, (-1, NULL, 0))
@@ -264,7 +268,9 @@ int main(int argc, char *argv[])
ret += TEST_FUNC(sleep);
ret += TEST_FUNC(system);
ret += TEST_FUNC(tcdrain);
+#ifdef __UCLIBC_SUSV3_LEGACY__
ret += TEST_FUNC(usleep);
+#endif
ret += TEST_FUNC(wait);
ret += TEST_FUNC(waitid);
ret += TEST_FUNC(waitpid);
diff --git a/test/pthread/ex6.c b/test/pthread/ex6.c
index bb96ca5fa..ffb628771 100644
--- a/test/pthread/ex6.c
+++ b/test/pthread/ex6.c
@@ -2,7 +2,7 @@
#include <stdio.h>
#include <string.h>
#include <pthread.h>
-#include <unistd.h>
+#include <time.h>
static void *
test_thread (void *v_param)
@@ -14,6 +14,9 @@ int
main (void)
{
unsigned long count;
+ struct timespec ts;
+ ts.tv_sec = 0;
+ ts.tv_nsec = 10 * 1000;
setvbuf (stdout, NULL, _IONBF, 0);
@@ -35,7 +38,7 @@ main (void)
}
/* pthread_detach (thread); */
pthread_join (thread, NULL);
- usleep (10);
+ nanosleep (&ts, NULL);
}
return 0;
}
diff --git a/test/pthread/ex7.c b/test/pthread/ex7.c
index 49af18d96..8eeb9a2e5 100644
--- a/test/pthread/ex7.c
+++ b/test/pthread/ex7.c
@@ -8,7 +8,7 @@
#include <string.h>
#include <pthread.h>
#include <sys/time.h>
-#include <unistd.h>
+#include <time.h>
/* Our event variable using a condition variable contruct. */
typedef struct {
@@ -63,6 +63,9 @@ int
main (void)
{
unsigned long count;
+ struct timespec ts;
+ ts.tv_sec = 0;
+ ts.tv_nsec = 10 * 1000;
setvbuf (stdout, NULL, _IONBF, 0);
@@ -96,7 +99,7 @@ main (void)
printf ("count = %lu\n", count);
}
- usleep (10);
+ nanosleep (&ts, NULL);
}
return 0;
diff --git a/test/pthread/tst-join2.c b/test/pthread/tst-join2.c
new file mode 100644
index 000000000..2cfab8b0e
--- /dev/null
+++ b/test/pthread/tst-join2.c
@@ -0,0 +1,104 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+
+static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+
+
+static void *
+tf (void *arg)
+{
+ if (pthread_mutex_lock (&lock) != 0)
+ {
+ puts ("child: mutex_lock failed");
+ return NULL;
+ }
+
+ return (void *) 42l;
+}
+
+
+static int
+do_test (void)
+{
+ pthread_t th;
+
+ if (pthread_mutex_lock (&lock) != 0)
+ {
+ puts ("mutex_lock failed");
+ exit (1);
+ }
+
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("mutex_create failed");
+ exit (1);
+ }
+
+ void *status;
+ int val = pthread_tryjoin_np (th, &status);
+ if (val == 0)
+ {
+ puts ("1st tryjoin succeeded");
+ exit (1);
+ }
+ else if (val != EBUSY)
+ {
+ puts ("1st tryjoin didn't return EBUSY");
+ exit (1);
+ }
+
+ if (pthread_mutex_unlock (&lock) != 0)
+ {
+ puts ("mutex_unlock failed");
+ exit (1);
+ }
+
+ while ((val = pthread_tryjoin_np (th, &status)) != 0)
+ {
+ if (val != EBUSY)
+ {
+ printf ("tryjoin returned %s (%d), expected only 0 or EBUSY\n",
+ strerror (val), val);
+ exit (1);
+ }
+
+ /* Delay minimally. */
+ struct timespec ts = { .tv_sec = 0, .tv_nsec = 10000000 };
+ nanosleep (&ts, NULL);
+ }
+
+ if (status != (void *) 42l)
+ {
+ printf ("return value %p, expected %p\n", status, (void *) 42l);
+ exit (1);
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/pthread/tst-join3.c b/test/pthread/tst-join3.c
new file mode 100644
index 000000000..df1135fb5
--- /dev/null
+++ b/test/pthread/tst-join3.c
@@ -0,0 +1,123 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 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, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+
+
+static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
+
+
+static void *
+tf (void *arg)
+{
+ if (pthread_mutex_lock (&lock) != 0)
+ {
+ puts ("child: mutex_lock failed");
+ return NULL;
+ }
+
+ return (void *) 42l;
+}
+
+
+static int
+do_test (void)
+{
+ pthread_t th;
+
+ if (pthread_mutex_lock (&lock) != 0)
+ {
+ puts ("mutex_lock failed");
+ exit (1);
+ }
+
+ if (pthread_create (&th, NULL, tf, NULL) != 0)
+ {
+ puts ("mutex_create failed");
+ exit (1);
+ }
+
+ void *status;
+ struct timespec ts;
+ struct timeval tv;
+ (void) gettimeofday (&tv, NULL);
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+ ts.tv_nsec += 200000000;
+ if (ts.tv_nsec >= 1000000000)
+ {
+ ts.tv_nsec -= 1000000000;
+ ++ts.tv_sec;
+ }
+ int val = pthread_timedjoin_np (th, &status, &ts);
+ if (val == 0)
+ {
+ puts ("1st timedjoin succeeded");
+ exit (1);
+ }
+ else if (val != ETIMEDOUT)
+ {
+ puts ("1st timedjoin didn't return ETIMEDOUT");
+ exit (1);
+ }
+
+ if (pthread_mutex_unlock (&lock) != 0)
+ {
+ puts ("mutex_unlock failed");
+ exit (1);
+ }
+
+ while (1)
+ {
+ (void) gettimeofday (&tv, NULL);
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+ ts.tv_nsec += 200000000;
+ if (ts.tv_nsec >= 1000000000)
+ {
+ ts.tv_nsec -= 1000000000;
+ ++ts.tv_sec;
+ }
+
+ val = pthread_timedjoin_np (th, &status, &ts);
+ if (val == 0)
+ break;
+
+ if (val != ETIMEDOUT)
+ {
+ printf ("timedjoin returned %s (%d), expected only 0 or ETIMEDOUT\n",
+ strerror (val), val);
+ exit (1);
+ }
+ }
+
+ if (status != (void *) 42l)
+ {
+ printf ("return value %p, expected %p\n", status, (void *) 42l);
+ exit (1);
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/pwd_grp/Makefile b/test/pwd_grp/Makefile
index e6362d352..fa2aacb8e 100644
--- a/test/pwd_grp/Makefile
+++ b/test/pwd_grp/Makefile
@@ -1,10 +1,8 @@
# uClibc pwd_grp tests
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+top_builddir=../../
+top_srcdir=../../
+include ../Rules.mak
+-include Makefile.in
include ../Test.mak
-
-DODIFF_test_pwd := 1
-DODIFF_test_grp := 1
-DODIFF_pwcat := 1
-DODIFF_grcat := 1
-DODIFF_getgroups := 1
diff --git a/test/pwd_grp/Makefile.in b/test/pwd_grp/Makefile.in
new file mode 100644
index 000000000..d561f3dcc
--- /dev/null
+++ b/test/pwd_grp/Makefile.in
@@ -0,0 +1,8 @@
+# uClibc pwd_grp tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+DODIFF_test_pwd := 1
+DODIFF_test_grp := 1
+DODIFF_pwcat := 1
+DODIFF_grcat := 1
+DODIFF_getgroups := 1
diff --git a/test/pwd_grp/getgroups.c b/test/pwd_grp/getgroups.c
index 0c093081a..c34355215 100644
--- a/test/pwd_grp/getgroups.c
+++ b/test/pwd_grp/getgroups.c
@@ -13,7 +13,6 @@
#include <sys/types.h>
#include <pwd.h>
#include <grp.h>
-#include <err.h>
/* The number of errors encountered so far. */
static int problems = 0;
@@ -25,7 +24,7 @@ static void print_group(gid_t gid)
grp = getgrgid(gid);
if (grp == NULL) {
- warn("cannot find name for group ID %u", gid);
+ fprintf(stderr, "cannot find name for group ID %u\n", gid);
problems++;
}
@@ -46,14 +45,16 @@ static int xgetgroups(gid_t gid, int *n_groups, gid_t ** groups)
/* Add 1 just in case max_n_groups is zero. */
g = (gid_t *) malloc(max_n_groups * sizeof(gid_t) + 1);
- if (g == NULL)
- err(EXIT_FAILURE, "out of memory");
+ if (g == NULL) {
+ fprintf(stderr, "out of memory\n");
+ exit(EXIT_FAILURE);
+ }
ng = getgroups(max_n_groups, g);
if (ng < 0) {
- warn("cannot get supplemental group list");
+ fprintf(stderr, "cannot get supplemental group list\n");
++fail;
- free(groups);
+ free(g);
}
if (!fail) {
*n_groups = ng;
diff --git a/test/regex/Makefile b/test/regex/Makefile
index 7c55c3c0e..eea0c491b 100644
--- a/test/regex/Makefile
+++ b/test/regex/Makefile
@@ -1,17 +1,8 @@
# uClibc regex tests
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-#TESTS_DISABLED := testregexi testregexn
-
+top_builddir=../../
+top_srcdir=../../
+include ../Rules.mak
+-include Makefile.in
include ../Test.mak
-
-CFLAGS_tst-regex2 := -std=c99
-
-OPTS_testregex := < basic.dat
-OPTS_testregexc := < categorize.dat
-OPTS_testregexf := < forcedassoc.dat
-OPTS_testregexi := -c < interpretation.dat
-OPTS_testregexl := < leftassoc.dat
-OPTS_testregexn := -c < nullsubexpr.dat
-OPTS_testregexp := < repetition.dat
-OPTS_testregexr := < rightassoc.dat
diff --git a/test/regex/Makefile.in b/test/regex/Makefile.in
new file mode 100644
index 000000000..ef1e3034f
--- /dev/null
+++ b/test/regex/Makefile.in
@@ -0,0 +1,6 @@
+# triggers gcc ICE with gcc 5.3.0
+ifeq ($(TARGET_lm32),y)
+TESTS_DISABLED := testregex
+endif
+
+CFLAGS_tst-regex2 = -fPIC
diff --git a/test/regex/testregex.c b/test/regex/testregex.c
index 3992c2647..993ac2687 100644
--- a/test/regex/testregex.c
+++ b/test/regex/testregex.c
@@ -298,7 +298,7 @@ H("</HTML>\n");
#define streq(a,b) (*(a)==*(b)&&!strcmp(a,b))
#endif
-#define HUNG 2
+#define HUNG 5
#define NOTEST (~0)
#ifndef REG_TEST_DEFAULT
@@ -1111,7 +1111,7 @@ catchfree(regex_t* preg, int flags, int* tabs, char* spec, char* re, char* s, ch
}
int
-main(int argc, char** argv)
+old_main(int unused_param_argc, char** argv)
{
int flags;
int cflags;
@@ -2103,7 +2103,7 @@ main(int argc, char** argv)
printf(" %-.*s", subunitlen, subunit);
printf(", %d test%s", testno, testno == 1 ? "" : "s");
if (state.ignored)
- printf(", %d ignored mismatche%s", state.ignored, state.ignored == 1 ? "" : "s");
+ printf(", %d ignored mismatch%s", state.ignored, state.ignored == 1 ? "" : "es");
if (state.warnings)
printf(", %d warning%s", state.warnings, state.warnings == 1 ? "" : "s");
if (state.unspecified)
@@ -2117,3 +2117,29 @@ main(int argc, char** argv)
}
return 0;
}
+
+int main(int argc, char **argv)
+{
+ static char *param[][4] = {
+ { NULL, "basic.dat" , NULL },
+ { NULL, "categorize.dat" , NULL },
+ { NULL, "forcedassoc.dat" , NULL },
+ { NULL, "-c", "interpretation.dat", NULL },
+ { NULL, "leftassoc.dat" , NULL },
+ { NULL, "-c", "nullsubexpr.dat" , NULL },
+ { NULL, "repetition.dat" , NULL },
+ { NULL, "rightassoc.dat" , NULL },
+ };
+ int r, i;
+
+ if (argv[1])
+ return old_main(argc, argv);
+
+ r = 0;
+ for (i = 0; i < sizeof(param) / sizeof(param[0]); i++) {
+ param[i][0] = argv[0];
+ printf("Testing %s\n", param[i][1][0] != '-' ? param[i][1] : param[i][2]);
+ r |= old_main(3 /* not used */, param[i]);
+ }
+ return r;
+}
diff --git a/test/regex/testregexc.c b/test/regex/testregexc.c
deleted file mode 100644
index 46b3ee848..000000000
--- a/test/regex/testregexc.c
+++ /dev/null
@@ -1 +0,0 @@
-#include "testregex.c"
diff --git a/test/regex/testregexf.c b/test/regex/testregexf.c
deleted file mode 100644
index 46b3ee848..000000000
--- a/test/regex/testregexf.c
+++ /dev/null
@@ -1 +0,0 @@
-#include "testregex.c"
diff --git a/test/regex/testregexi.c b/test/regex/testregexi.c
deleted file mode 100644
index 46b3ee848..000000000
--- a/test/regex/testregexi.c
+++ /dev/null
@@ -1 +0,0 @@
-#include "testregex.c"
diff --git a/test/regex/testregexl.c b/test/regex/testregexl.c
deleted file mode 100644
index 46b3ee848..000000000
--- a/test/regex/testregexl.c
+++ /dev/null
@@ -1 +0,0 @@
-#include "testregex.c"
diff --git a/test/regex/testregexn.c b/test/regex/testregexn.c
deleted file mode 100644
index 46b3ee848..000000000
--- a/test/regex/testregexn.c
+++ /dev/null
@@ -1 +0,0 @@
-#include "testregex.c"
diff --git a/test/regex/testregexp.c b/test/regex/testregexp.c
deleted file mode 100644
index 46b3ee848..000000000
--- a/test/regex/testregexp.c
+++ /dev/null
@@ -1 +0,0 @@
-#include "testregex.c"
diff --git a/test/regex/testregexr.c b/test/regex/testregexr.c
deleted file mode 100644
index 46b3ee848..000000000
--- a/test/regex/testregexr.c
+++ /dev/null
@@ -1 +0,0 @@
-#include "testregex.c"
diff --git a/test/regex/tst-regex2.c b/test/regex/tst-regex2.c
index 94be59d85..bb47d6467 100644
--- a/test/regex/tst-regex2.c
+++ b/test/regex/tst-regex2.c
@@ -1,3 +1,5 @@
+#define _GNU_SOURCE 1
+
#include <fcntl.h>
#include <locale.h>
#include <regex.h>
@@ -5,240 +7,244 @@
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
+#include <sys/time.h>
#include <time.h>
#include <unistd.h>
#include <errno.h>
-#undef _POSIX_CPUTIME
-#if defined _POSIX_CPUTIME && _POSIX_CPUTIME >= 0
-static clockid_t cl;
-static int use_clock;
-#endif
-
static int
-do_test (void)
+do_test(void)
{
-#if defined _POSIX_CPUTIME && _POSIX_CPUTIME >= 0
-# if _POSIX_CPUTIME == 0
- if (sysconf (_SC_CPUTIME) < 0)
- use_clock = 0;
- else
-# endif
- /* See whether we can use the CPU clock. */
- use_clock = clock_getcpuclockid (0, &cl) == 0;
-#endif
-
- static const char *pat[] = {
- ".?.?.?.?.?.?.?Log\\.13",
- "(.?)(.?)(.?)(.?)(.?)(.?)(.?)Log\\.13",
- "((((((((((.?))))))))))((((((((((.?))))))))))((((((((((.?))))))))))"
- "((((((((((.?))))))))))((((((((((.?))))))))))((((((((((.?))))))))))"
- "((((((((((.?))))))))))Log\\.13" };
-
- int fd = open (".regex.ChangeLog.14", O_RDONLY);
- if (fd < 0)
- {
- printf ("Couldn't open .regex.ChangeLog.14: %s\n", strerror(errno));
- return 1;
- }
-
- struct stat64 st;
- if (fstat64 (fd, &st) < 0)
- {
- printf ("Couldn't fstat ChangeLog.14: %s\n", strerror(errno));
- return 1;
- }
-
- char *buf = malloc (st.st_size + 1);
- if (buf == NULL)
- {
- printf ("Couldn't allocate buffer: %s\n", strerror(errno));
- return 1;
- }
-
- if (read (fd, buf, st.st_size) != (ssize_t) st.st_size)
- {
- puts ("Couldn't read ChangeLog.14");
- return 1;
- }
-
- close (fd);
- buf[st.st_size] = '\0';
-
-#ifdef __UCLIBC_HAS_XLOCALE__
- setlocale (LC_ALL, "de_DE.UTF-8");
-#endif
-
- char *string = buf;
- size_t len = st.st_size;
-
- for (int testno = 0; testno < 4; ++testno)
- for (int i = 0; i < sizeof (pat) / sizeof (pat[0]); ++i)
- {
- printf ("test %d pattern %d", testno, i);
-
- regex_t rbuf;
- struct re_pattern_buffer rpbuf;
- int err;
- if (testno < 2)
- {
- err = regcomp (&rbuf, pat[i],
- REG_EXTENDED | (testno ? REG_NOSUB : 0));
- if (err != 0)
- {
- putchar ('\n');
- char errstr[300];
- regerror (err, &rbuf, errstr, sizeof (errstr));
- puts (errstr);
- return err;
- }
- }
- else
- {
- re_set_syntax (RE_SYNTAX_POSIX_EGREP
- | (testno == 3 ? RE_NO_SUB : 0));
-
- memset (&rpbuf, 0, sizeof (rpbuf));
- const char *s = re_compile_pattern (pat[i], strlen (pat[i]),
- &rpbuf);
- if (s != NULL)
- {
- printf ("\n%s\n", s);
+ static const char *pat[] = {
+ ".?.?.?.?.?.?.?Log\\.13",
+ "(.?)(.?)(.?)(.?)(.?)(.?)(.?)Log\\.13",
+ "((((((((((.?))))))))))((((((((((.?))))))))))((((((((((.?))))))))))"
+ "((((((((((.?))))))))))((((((((((.?))))))))))((((((((((.?))))))))))"
+ "((((((((((.?))))))))))Log\\.13"
+ };
+ char *buf, *string;
+ const char *fname = "tst-regex2.dat";
+ struct stat st;
+ unsigned len;
+ int testno;
+ int exitcode = 0;
+
+ int fd = open(fname, O_RDONLY);
+ if (fd < 0) {
+ printf("Couldn't open %s: %s\n", fname, strerror(errno));
+ return 1;
+ }
+ if (fstat(fd, &st) < 0) {
+ printf("Couldn't fstat %s: %s\n", fname, strerror(errno));
+ return 1;
+ }
+ len = st.st_size;
+ string = buf = malloc(len + 1);
+ if (buf == NULL) {
+ printf("Couldn't allocate %u bytes\n", len + 1);
+ return 1;
+ }
+ if (read(fd, buf, st.st_size) != (ssize_t) st.st_size) {
+ printf("Couldn't read %s\n", fname);
return 1;
- }
+ }
- /* Just so that this can be tested with earlier glibc as well. */
- if (testno == 3)
- rpbuf.no_sub = 1;
- }
+ close(fd);
+ buf[len] = '\0';
-#if defined _POSIX_CPUTIME && _POSIX_CPUTIME >= 0
- struct timespec start, stop;
- if (use_clock)
- use_clock = clock_gettime (cl, &start) == 0;
+#if defined __UCLIBC_HAS_XLOCALE__ || !defined __UCLIBC__
+ setlocale(LC_ALL, "de_DE.UTF-8");
#endif
- if (testno < 2)
- {
- regmatch_t pmatch[71];
- err = regexec (&rbuf, string, 71, pmatch, 0);
- if (err == REG_NOMATCH)
- {
- puts ("\nregexec failed");
- return 1;
- }
-
- if (testno == 0)
- {
- if (pmatch[0].rm_eo != pmatch[0].rm_so + 13
- || pmatch[0].rm_eo > len
- || pmatch[0].rm_so < len - 100
- || strncmp (string + pmatch[0].rm_so,
- " ChangeLog.13 for earlier changes",
- sizeof " ChangeLog.13 for earlier changes" - 1)
- != 0)
- {
- puts ("\nregexec without REG_NOSUB did not find the correct match");
- return 1;
+ for (testno = 0; testno < 2; ++testno) {
+ int i;
+ for (i = 0; i < sizeof(pat) / sizeof(pat[0]); ++i) {
+ struct timeval start, stop;
+ regex_t rbuf;
+ int err;
+
+ printf("test %d pattern %d '%s'\n", testno, i, pat[i]);
+ gettimeofday(&start, NULL);
+
+ err = regcomp(&rbuf, pat[i],
+ REG_EXTENDED | (testno ? REG_NOSUB : 0));
+ if (err != 0) {
+ char errstr[300];
+ regerror(err, &rbuf, errstr, sizeof(errstr));
+ puts(errstr);
+ exitcode = 1;
+ goto contin1;
+ }
+
+ regmatch_t pmatch[71];
+ err = regexec(&rbuf, string, 71, pmatch, 0);
+ if (err == REG_NOMATCH) {
+ puts("regexec failed");
+ exitcode = 1;
+ goto contin1;
+ }
+
+ if (testno == 0) {
+ if (pmatch[0].rm_eo != pmatch[0].rm_so + 13
+ || pmatch[0].rm_eo > len
+ || pmatch[0].rm_so < len - 100
+ || strncmp(string + pmatch[0].rm_so,
+ " ChangeLog.13 for earlier changes",
+ sizeof " ChangeLog.13 for earlier changes" - 1
+ ) != 0
+ ) {
+ puts("regexec without REG_NOSUB did not find the correct match");
+ exitcode = 1;
+ goto contin1;
+ }
+
+ if (i > 0) {
+ int j, k, l;
+ for (j = 0, l = 1; j < 7; ++j) {
+ for (k = 0; k < (i == 1 ? 1 : 10); ++k, ++l) {
+ if (pmatch[l].rm_so != pmatch[0].rm_so + j
+ || pmatch[l].rm_eo != pmatch[l].rm_so + 1
+ ) {
+ printf("pmatch[%d] incorrect\n", l);
+ exitcode = 1;
+ goto contin1;
+ }
+ }
+ }
+ }
+ }
+
+ gettimeofday(&stop, NULL);
+ stop.tv_sec -= start.tv_sec;
+ if (stop.tv_usec < start.tv_usec) {
+ stop.tv_sec--;
+ stop.tv_usec += 1000000;
+ }
+ stop.tv_usec -= start.tv_usec;
+ printf(" %lu.%06lus\n", (unsigned long) stop.tv_sec,
+ (unsigned long) stop.tv_usec);
+ contin1:
+ regfree(&rbuf);
}
-
- if (i > 0)
- for (int j = 0, l = 1; j < 7; ++j)
- for (int k = 0; k < (i == 1 ? 1 : 10); ++k, ++l)
- if (pmatch[l].rm_so != pmatch[0].rm_so + j
- || pmatch[l].rm_eo != pmatch[l].rm_so + 1)
- {
- printf ("\npmatch[%d] incorrect\n", l);
- return 1;
- }
- }
}
- else
- {
- struct re_registers regs;
-
- memset (&regs, 0, sizeof (regs));
- int match = re_search (&rpbuf, string, len, 0, len,
- &regs);
- if (match < 0)
- {
- puts ("\nre_search failed");
- return 1;
- }
-
- if (match + 13 > len
- || match < len - 100
- || strncmp (string + match,
- " ChangeLog.13 for earlier changes",
- sizeof " ChangeLog.13 for earlier changes" - 1)
- != 0)
- {
- puts ("\nre_search did not find the correct match");
- return 1;
- }
-
- if (testno == 2)
- {
- if (regs.num_regs != 2 + (i == 0 ? 0 : i == 1 ? 7 : 70))
- {
- printf ("\nincorrect num_regs %d\n", regs.num_regs);
- return 1;
- }
-
- if (regs.start[0] != match || regs.end[0] != match + 13)
- {
- printf ("\nincorrect regs.{start,end}[0] = { %d, %d}\n",
- regs.start[0], regs.end[0]);
- return 1;
- }
- if (regs.start[regs.num_regs - 1] != -1
- || regs.end[regs.num_regs - 1] != -1)
- {
- puts ("\nincorrect regs.{start,end}[num_regs - 1]");
- return 1;
+ for (testno = 2; testno < 4; ++testno) {
+ int i;
+ for (i = 0; i < sizeof(pat) / sizeof(pat[0]); ++i) {
+ struct timeval start, stop;
+ struct re_pattern_buffer rpbuf;
+ struct re_registers regs;
+ const char *s;
+ int match;
+
+ printf("test %d pattern %d '%s'\n", testno, i, pat[i]);
+ gettimeofday(&start, NULL);
+
+ re_set_syntax(RE_SYNTAX_POSIX_EGREP
+ | (testno == 3 ? RE_NO_SUB : 0));
+ memset(&rpbuf, 0, sizeof(rpbuf));
+ s = re_compile_pattern(pat[i], strlen(pat[i]), &rpbuf);
+ if (s != NULL) {
+ printf("%s\n", s);
+ exitcode = 1;
+ goto contin2;
+ }
+
+ memset(&regs, 0, sizeof(regs));
+ match = re_search(&rpbuf, string, len, 0, len, &regs);
+ if (match < 0) {
+ printf("re_search failed (err:%d)\n", match);
+ exitcode = 1;
+ goto contin2;
+ }
+ if (match + 13 > len) {
+ printf("re_search: match+13 > len (%d > %d)\n", match + 13, len);
+ exitcode = 1;
+ goto contin2;
+ }
+ if (match < len - 100) {
+ printf("re_search: match < len-100 (%d < %d)\n", match, len - 100);
+ exitcode = 1;
+ goto contin2;
+ }
+ if (strncmp(string + match, " ChangeLog.13 for earlier changes",
+ sizeof(" ChangeLog.13 for earlier changes") - 1
+ ) != 0
+ ) {
+ printf("re_search did not find the correct match"
+ "(found '%s' instead)\n", string + match);
+ exitcode = 1;
+ goto contin2;
+ }
+
+ if (testno == 2) {
+ int expected = 72;
+ if (i == 0)
+ expected = 2;
+ if (i == 1)
+ expected = 9;
+ if (regs.num_regs != expected) {
+ printf("incorrect num_regs %d, expected %d\n", regs.num_regs, expected);
+ exitcode = 1;
+ goto contin2;
+ }
+ if (regs.start[0] != match || regs.end[0] != match + 13) {
+ printf("incorrect regs.{start,end}[0] = { %d, %d },"
+ " expected { %d, %d }\n",
+ regs.start[0], regs.end[0],
+ match, match + 13
+ );
+ exitcode = 1;
+ goto contin2;
+ }
+ if (regs.start[regs.num_regs - 1] != -1
+ || regs.end[regs.num_regs - 1] != -1
+ ) {
+ printf("incorrect regs.{start,end}[num_regs - 1] = { %d, %d },"
+ " expected { -1, -1 }\n",
+ regs.start[regs.num_regs - 1], regs.end[regs.num_regs - 1]
+ );
+ exitcode = 1;
+ goto contin2;
+ }
+
+ if (i > 0) {
+ int j, k, l;
+ for (j = 0, l = 1; j < 7; ++j) {
+ for (k = 0; k < (i == 1 ? 1 : 10); ++k, ++l) {
+ if (regs.start[l] != match + j
+ || regs.end[l] != match + j + 1
+ ) {
+ printf("incorrect regs.{start,end}[%d] = { %d, %d },"
+ " expected { %d, %d }\n",
+ l,
+ regs.start[l], regs.end[l],
+ match + j, match + j + 1
+ );
+ exitcode = 1;
+ goto contin2;
+ }
+ }
+ }
+ }
+ }
+
+ gettimeofday(&stop, NULL);
+ stop.tv_sec -= start.tv_sec;
+ if (stop.tv_usec < start.tv_usec) {
+ stop.tv_sec--;
+ stop.tv_usec += 1000000;
+ }
+ stop.tv_usec -= start.tv_usec;
+ printf(" %lu.%06lus\n", (unsigned long) stop.tv_sec,
+ (unsigned long) stop.tv_usec);
+ contin2:
+ regfree(&rpbuf);
}
-
- if (i > 0)
- for (int j = 0, l = 1; j < 7; ++j)
- for (int k = 0; k < (i == 1 ? 1 : 10); ++k, ++l)
- if (regs.start[l] != match + j
- || regs.end[l] != regs.start[l] + 1)
- {
- printf ("\nregs.{start,end}[%d] incorrect\n", l);
- return 1;
- }
- }
- }
-
-#if defined _POSIX_CPUTIME && _POSIX_CPUTIME >= 0
- if (use_clock)
- use_clock = clock_gettime (cl, &stop) == 0;
- if (use_clock)
- {
- stop.tv_sec -= start.tv_sec;
- if (stop.tv_nsec < start.tv_nsec)
- {
- stop.tv_sec--;
- stop.tv_nsec += 1000000000 - start.tv_nsec;
- }
- else
- stop.tv_nsec -= start.tv_nsec;
- printf (": %ld.%09lds\n", (long) stop.tv_sec, (long) stop.tv_nsec);
}
- else
-#endif
- putchar ('\n');
-
- if (testno < 2)
- regfree (&rbuf);
- else
- regfree (&rpbuf);
- }
-
- return 0;
+ return exitcode;
}
-#define TIMEOUT 20
-#define TEST_FUNCTION do_test ()
+#define TIMEOUT 100
+#define TEST_FUNCTION do_test()
#include "../test-skeleton.c"
diff --git a/test/regex/.regex.ChangeLog.14 b/test/regex/tst-regex2.dat
index ace9f3b66..ace9f3b66 100644
--- a/test/regex/.regex.ChangeLog.14
+++ b/test/regex/tst-regex2.dat
diff --git a/test/regex/tst-regexloc.c b/test/regex/tst-regexloc.c
index 88ab58116..d862678e5 100644
--- a/test/regex/tst-regexloc.c
+++ b/test/regex/tst-regexloc.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 <sys/types.h>
#include <regex.h>
@@ -24,10 +23,12 @@
int
main (int argc, char *argv[])
{
-#ifdef __UCLIBC_HAS_XLOCALE__
+/* If uclibc has extended locale, or if it's a host build
+ * (assuming host libc always has locale): */
+#if defined __UCLIBC_HAS_XLOCALE__ || !defined __UCLIBC__
regex_t re;
regmatch_t mat[1];
- int res = 1;
+ int exitcode = 1;
if (setlocale (LC_ALL, "de_DE.ISO-8859-1") == NULL)
puts ("cannot set locale");
@@ -37,11 +38,14 @@ main (int argc, char *argv[])
puts ("no match");
else
{
- printf ("match from %d to %d\n", mat[0].rm_so, mat[0].rm_eo);
- res = mat[0].rm_so != 0 || mat[0].rm_eo != 6;
+ exitcode = mat[0].rm_so != 0 || mat[0].rm_eo != 6;
+ printf ("match from %d to %d - %s\n",
+ mat[0].rm_so, mat[0].rm_eo,
+ exitcode ? "WRONG!" : "ok"
+ );
}
- return res;
+ return exitcode;
#else
puts("Test requires locale; skipping");
return 0;
diff --git a/test/rpc/Makefile b/test/rpc/Makefile
index 8ea934800..e098072fc 100644
--- a/test/rpc/Makefile
+++ b/test/rpc/Makefile
@@ -1,12 +1,8 @@
# uClibc rpc tests
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-TESTS := getrpcent
-
-ifeq ($(UCLIBC_HAS_REENTRANT_RPC),y)
-TESTS += getrpcent_r
-endif
-
+top_builddir=../../
+top_srcdir=../../
+include ../Rules.mak
+-include Makefile.in
include ../Test.mak
-
-DODIFF_getrpcent := 1
diff --git a/test/rpc/Makefile.in b/test/rpc/Makefile.in
new file mode 100644
index 000000000..5612ff202
--- /dev/null
+++ b/test/rpc/Makefile.in
@@ -0,0 +1,11 @@
+# uClibc rpc tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+TESTS := getrpcent
+
+ifeq ($(UCLIBC_HAS_REENTRANT_RPC),y)
+TESTS += getrpcent_r
+endif
+
+DODIFF_getrpcent := 1
+
diff --git a/test/rpc/getrpcent_r.c b/test/rpc/getrpcent_r.c
index 708deba10..65ca61cd9 100644
--- a/test/rpc/getrpcent_r.c
+++ b/test/rpc/getrpcent_r.c
@@ -1,6 +1,7 @@
#include <netdb.h>
#include <stdio.h>
#include <errno.h>
+#include <string.h>
int main(int argc, char *argv[])
{
diff --git a/test/setjmp/Makefile b/test/setjmp/Makefile
index 581ab3213..6feab59ef 100644
--- a/test/setjmp/Makefile
+++ b/test/setjmp/Makefile
@@ -1,4 +1,8 @@
# uClibc setjmp tests
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+top_builddir=../../
+top_srcdir=../../
+include ../Rules.mak
+-include Makefile.in
include ../Test.mak
diff --git a/test/setjmp/Makefile.in b/test/setjmp/Makefile.in
new file mode 100644
index 000000000..a5b7b591a
--- /dev/null
+++ b/test/setjmp/Makefile.in
@@ -0,0 +1 @@
+CFLAGS_bug269-setjmp = -fPIC
diff --git a/test/setjmp/bug269-setjmp.c b/test/setjmp/bug269-setjmp.c
index b11ac7b24..a9254a1df 100644
--- a/test/setjmp/bug269-setjmp.c
+++ b/test/setjmp/bug269-setjmp.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/>. */
/* Test case for Bugzilla # 269 */
diff --git a/test/setjmp/tst-setjmp.c b/test/setjmp/tst-setjmp.c
index f0feb99a8..ea1c29acd 100644
--- a/test/setjmp/tst-setjmp.c
+++ b/test/setjmp/tst-setjmp.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 <stdio.h>
#include <setjmp.h>
diff --git a/test/signal/Makefile b/test/signal/Makefile
index 2ff96fa73..c2afb5f50 100644
--- a/test/signal/Makefile
+++ b/test/signal/Makefile
@@ -1,8 +1,8 @@
# uClibc signal tests
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-ifeq ($(UCLIBC_HAS_OBSOLETE_BSD_SIGNAL),)
-TESTS_DISABLED := tst-sigsimple
-endif
-
+top_builddir=../../
+top_srcdir=../../
+include ../Rules.mak
+-include Makefile.in
include ../Test.mak
diff --git a/test/signal/Makefile.in b/test/signal/Makefile.in
new file mode 100644
index 000000000..27791a911
--- /dev/null
+++ b/test/signal/Makefile.in
@@ -0,0 +1,10 @@
+# uClibc signal tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+ifeq ($(UCLIBC_HAS_OBSOLETE_BSD_SIGNAL),)
+TESTS_DISABLED := tst-sigsimple
+endif
+
+CFLAGS_tst-signalfd = -fPIC
+CFLAGS_tst-sigset = -fPIC
+CFLAGS_tst-sigsimple = -fPIC
diff --git a/test/signal/tst-raise.c b/test/signal/tst-raise.c
index d24c316cf..534ae7151 100644
--- a/test/signal/tst-raise.c
+++ b/test/signal/tst-raise.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 <string.h>
diff --git a/test/signal/tst-signalfd.c b/test/signal/tst-signalfd.c
new file mode 100644
index 000000000..1fbb748aa
--- /dev/null
+++ b/test/signal/tst-signalfd.c
@@ -0,0 +1,63 @@
+/* vi: set sw=4 ts=4 sts=4: */
+/*
+ * signalfd test for uClibc
+ * Copyright (C) 2012 by Kevin Cernekee <cernekee@gmail.com>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+#include <error.h>
+#include <signal.h>
+#include <sys/signalfd.h>
+#include <sys/fcntl.h>
+
+static int
+do_test(void)
+{
+ int fd, ret, result = 0;
+ struct signalfd_siginfo ssi;
+ sigset_t mask;
+
+ sigemptyset(&mask);
+ sigaddset(&mask, SIGUSR1);
+ sigprocmask(SIG_BLOCK, &mask, NULL);
+
+ fd = signalfd(-1, &mask, SFD_NONBLOCK);
+ if (fd < 0) {
+ printf("signalfd() failed: %s\n", strerror(errno));
+ result = 1;
+ }
+
+ /* this should return immediately with EAGAIN due to SFD_NONBLOCK */
+ memset(&ssi, 0, sizeof(ssi));
+ ret = read(fd, &ssi, sizeof(ssi));
+ if (ret != -1 || errno != EAGAIN) {
+ error(0, 0, "first read() returned %d", ret);
+ result = 1;
+ }
+
+ kill(getpid(), SIGUSR1);
+
+ /* this should return a struct ssi indicating receipt of SIGUSR1 */
+ ret = read(fd, &ssi, sizeof(ssi));
+ if (ret != sizeof(ssi)) {
+ error(0, 0, "second read() returned %d", ret);
+ result = 1;
+ }
+
+ if (ssi.ssi_signo != SIGUSR1) {
+ error(0, 0, "ssi contains bogus signo");
+ result = 1;
+ }
+
+ return result;
+}
+
+#define TIMEOUT 5
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/signal/tst-sigsimple.c b/test/signal/tst-sigsimple.c
index 22bb85cba..80220eed0 100644
--- a/test/signal/tst-sigsimple.c
+++ b/test/signal/tst-sigsimple.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 <signal.h>
diff --git a/test/silly/Makefile b/test/silly/Makefile
index ccd701852..54f4bd023 100644
--- a/test/silly/Makefile
+++ b/test/silly/Makefile
@@ -1,7 +1,8 @@
# uClibc silly tests
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+top_builddir=../../
+top_srcdir=../../
+include ../Rules.mak
+-include Makefile.in
include ../Test.mak
-
-RET_hello := 42
-RET_tiny := 42
diff --git a/test/silly/Makefile.in b/test/silly/Makefile.in
new file mode 100644
index 000000000..c47734414
--- /dev/null
+++ b/test/silly/Makefile.in
@@ -0,0 +1,24 @@
+# uClibc silly tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+RET_hello := 42
+RET_tiny := 42
+
+ifeq ($(TARGET_ARCH),ia64)
+TESTS_DISABLED += tst-atomic tst-atomic-long
+endif
+
+ifeq ($(TARGET_ARCH),mips)
+TESTS_DISABLED += tst-atomic tst-atomic-long
+endif
+
+ifeq ($(TARGET_ARCH),sparc)
+TESTS_DISABLED += tst-atomic tst-atomic-long
+endif
+
+atomic_headers := -I$(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH) \
+ -I$(top_srcdir)libc/sysdeps/linux \
+ -I$(top_builddir)include
+
+CFLAGS_tst-atomic = $(atomic_headers) -fPIC
+CFLAGS_tst-atomic-long = $(atomic_headers) -fPIC
diff --git a/test/silly/hello.c b/test/silly/hello.c
index 4aba926e6..d330597ab 100644
--- a/test/silly/hello.c
+++ b/test/silly/hello.c
@@ -1,4 +1,4 @@
-#include<stdio.h>
+#include <stdio.h>
#include <stdlib.h>
int main(void)
diff --git a/test/silly/tst-atomic-long.c b/test/silly/tst-atomic-long.c
new file mode 100644
index 000000000..d13fb074c
--- /dev/null
+++ b/test/silly/tst-atomic-long.c
@@ -0,0 +1,27 @@
+/* Tests for atomic.h macros.
+ Copyright (C) 2003-2015 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/>. */
+
+#include <bits/wordsize.h>
+
+#define atomic_t long
+#if __WORDSIZE == 64
+# define TEST_ATOMIC64 1
+#endif
+
+#include "tst-atomic.c"
diff --git a/test/silly/tst-atomic.c b/test/silly/tst-atomic.c
new file mode 100644
index 000000000..fc773b231
--- /dev/null
+++ b/test/silly/tst-atomic.c
@@ -0,0 +1,573 @@
+/* Tests for atomic.h macros.
+ Copyright (C) 2003-2015 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/>. */
+
+#include <stdio.h>
+#include <atomic.h>
+
+#ifndef atomic_t
+# define atomic_t int
+#endif
+
+#define CHK2(f,a1,a2,rv,new_mem) \
+ retval = f(&mem, a1, a2); \
+ if (retval != rv) { \
+ printf("%s(mem, %lu, %lu): retval %lu != expected %lu\n", \
+ #f, a1, a2, retval, rv); \
+ ret = 1; \
+ } \
+ if (mem != new_mem) { \
+ printf("%s(mem, %lu, %lu): mem %lu != expected %lu\n", \
+ #f, a1, a2, mem, new_mem); \
+ ret = 1; \
+ }
+#define CHK1(f,a1,rv,new_mem) \
+ retval = f(&mem, a1); \
+ if (retval != rv) { \
+ printf("%s(mem, %lu): retval %lu != expected %lu\n", \
+ #f, a1, retval, rv); \
+ ret = 1; \
+ } \
+ if (mem != new_mem) { \
+ printf("%s(mem, %lu): mem %lu != expected %lu\n", \
+ #f, a1, mem, new_mem); \
+ ret = 1; \
+ }
+#define CHK0(f,rv,new_mem) \
+ retval = f(&mem); \
+ if (retval != rv) { \
+ printf("%s(mem): retval %lu != expected %lu\n", \
+ #f, retval, rv); \
+ ret = 1; \
+ } \
+ if (mem != new_mem) { \
+ printf("%s(mem): mem %lu != expected %lu\n", \
+ #f, mem, new_mem); \
+ ret = 1; \
+ }
+
+/* Test various atomic.h macros. */
+static int
+do_test (void)
+{
+ atomic_t mem, expected, retval;
+ int ret = 0;
+
+#ifdef atomic_compare_and_exchange_val_acq
+ mem = 24;
+ CHK2(atomic_compare_and_exchange_val_acq, 35, 24, 24, 35);
+ mem = 12;
+ CHK2(atomic_compare_and_exchange_val_acq, 10, 15, 12, 12);
+ mem = -15;
+ CHK2(atomic_compare_and_exchange_val_acq, -56, -15, -15, -56);
+ mem = -1;
+ CHK2(atomic_compare_and_exchange_val_acq, 17, 0, -1, -1);
+#endif
+
+ mem = 24;
+ CHK2(atomic_compare_and_exchange_bool_acq, 35, 24, 0, 35);
+ mem = 12;
+ CHK2(atomic_compare_and_exchange_bool_acq, 10, 15, 1, 12);
+ mem = -15;
+ CHK2(atomic_compare_and_exchange_bool_acq, -56, -15, 0, -56);
+ mem = -1;
+ CHK2(atomic_compare_and_exchange_bool_acq, 17, 0, 1, -1);
+
+ mem = 64;
+ CHK1(atomic_exchange_acq, 31, 64, 31);
+ mem = 2;
+ CHK1(atomic_exchange_and_add, 11, 2, 13);
+ mem = 2;
+ CHK1(atomic_exchange_and_add_acq, 11, 2, 13);
+ mem = 2;
+ CHK1(atomic_exchange_and_add_rel, 11, 2, 13);
+
+ mem = -21;
+ atomic_add (&mem, 22);
+ if (mem != 1)
+ {
+ printf ("atomic_add(mem, 22): mem %lu != expected 1\n", mem);
+ ret = 1;
+ }
+
+ mem = -1;
+ atomic_increment (&mem);
+ if (mem != 0)
+ {
+ printf ("atomic_increment(mem): mem %lu != expected 0\n", mem);
+ ret = 1;
+ }
+
+ mem = 2;
+ if ((retval = atomic_increment_val (&mem)) != 3)
+ {
+ printf ("atomic_increment_val(mem): retval %lu != expected 3\n", retval);
+ ret = 1;
+ }
+
+ mem = 0;
+ CHK0(atomic_increment_and_test, 0, 1);
+ mem = 35;
+ CHK0(atomic_increment_and_test, 0, 36);
+ mem = -1;
+ CHK0(atomic_increment_and_test, 1, 0);
+ mem = 17;
+ atomic_decrement (&mem);
+ if (mem != 16)
+ {
+ printf ("atomic_increment(mem): mem %lu != expected 16\n", mem);
+ ret = 1;
+ }
+
+ if ((retval = atomic_decrement_val (&mem)) != 15)
+ {
+ printf ("atomic_decrement_val(mem): retval %lu != expected 15\n", retval);
+ ret = 1;
+ }
+
+ mem = 0;
+ CHK0(atomic_decrement_and_test, 0, -1);
+
+ mem = 15;
+ CHK0(atomic_decrement_and_test, 0, 14);
+ mem = 1;
+ CHK0(atomic_decrement_and_test, 1, 0);
+ mem = 1;
+ if (atomic_decrement_if_positive (&mem) != 1
+ || mem != 0)
+ {
+ puts ("atomic_decrement_if_positive test 1 failed");
+ ret = 1;
+ }
+
+ mem = 0;
+ if (atomic_decrement_if_positive (&mem) != 0
+ || mem != 0)
+ {
+ puts ("atomic_decrement_if_positive test 2 failed");
+ ret = 1;
+ }
+
+ mem = -1;
+ if (atomic_decrement_if_positive (&mem) != -1
+ || mem != -1)
+ {
+ puts ("atomic_decrement_if_positive test 3 failed");
+ ret = 1;
+ }
+
+ mem = -12;
+ if (! atomic_add_negative (&mem, 10)
+ || mem != -2)
+ {
+ puts ("atomic_add_negative test 1 failed");
+ ret = 1;
+ }
+
+ mem = 0;
+ if (atomic_add_negative (&mem, 100)
+ || mem != 100)
+ {
+ puts ("atomic_add_negative test 2 failed");
+ ret = 1;
+ }
+
+ mem = 15;
+ if (atomic_add_negative (&mem, -10)
+ || mem != 5)
+ {
+ puts ("atomic_add_negative test 3 failed");
+ ret = 1;
+ }
+
+ mem = -12;
+ if (atomic_add_negative (&mem, 14)
+ || mem != 2)
+ {
+ puts ("atomic_add_negative test 4 failed");
+ ret = 1;
+ }
+
+ mem = 0;
+ if (! atomic_add_negative (&mem, -1)
+ || mem != -1)
+ {
+ puts ("atomic_add_negative test 5 failed");
+ ret = 1;
+ }
+
+ mem = -31;
+ if (atomic_add_negative (&mem, 31)
+ || mem != 0)
+ {
+ puts ("atomic_add_negative test 6 failed");
+ ret = 1;
+ }
+
+ mem = -34;
+ if (atomic_add_zero (&mem, 31)
+ || mem != -3)
+ {
+ puts ("atomic_add_zero test 1 failed");
+ ret = 1;
+ }
+
+ mem = -36;
+ if (! atomic_add_zero (&mem, 36)
+ || mem != 0)
+ {
+ puts ("atomic_add_zero test 2 failed");
+ ret = 1;
+ }
+
+ mem = 113;
+ if (atomic_add_zero (&mem, -13)
+ || mem != 100)
+ {
+ puts ("atomic_add_zero test 3 failed");
+ ret = 1;
+ }
+
+ mem = -18;
+ if (atomic_add_zero (&mem, 20)
+ || mem != 2)
+ {
+ puts ("atomic_add_zero test 4 failed");
+ ret = 1;
+ }
+
+ mem = 10;
+ if (atomic_add_zero (&mem, -20)
+ || mem != -10)
+ {
+ puts ("atomic_add_zero test 5 failed");
+ ret = 1;
+ }
+
+ mem = 10;
+ if (! atomic_add_zero (&mem, -10)
+ || mem != 0)
+ {
+ puts ("atomic_add_zero test 6 failed");
+ ret = 1;
+ }
+
+ mem = 0;
+ atomic_bit_set (&mem, 1);
+ if (mem != 2)
+ {
+ puts ("atomic_bit_set test 1 failed");
+ ret = 1;
+ }
+
+ mem = 8;
+ atomic_bit_set (&mem, 3);
+ if (mem != 8)
+ {
+ puts ("atomic_bit_set test 2 failed");
+ ret = 1;
+ }
+
+#ifdef TEST_ATOMIC64
+ mem = 16;
+ atomic_bit_set (&mem, 35);
+ if (mem != 0x800000010LL)
+ {
+ puts ("atomic_bit_set test 3 failed");
+ ret = 1;
+ }
+#endif
+
+ mem = 0;
+ if (atomic_bit_test_set (&mem, 1)
+ || mem != 2)
+ {
+ puts ("atomic_bit_test_set test 1 failed");
+ ret = 1;
+ }
+
+ mem = 8;
+ if (! atomic_bit_test_set (&mem, 3)
+ || mem != 8)
+ {
+ puts ("atomic_bit_test_set test 2 failed");
+ ret = 1;
+ }
+
+#ifdef TEST_ATOMIC64
+ mem = 16;
+ if (atomic_bit_test_set (&mem, 35)
+ || mem != 0x800000010LL)
+ {
+ puts ("atomic_bit_test_set test 3 failed");
+ ret = 1;
+ }
+
+ mem = 0x100000000LL;
+ if (! atomic_bit_test_set (&mem, 32)
+ || mem != 0x100000000LL)
+ {
+ puts ("atomic_bit_test_set test 4 failed");
+ ret = 1;
+ }
+#endif
+
+#ifdef catomic_compare_and_exchange_val_acq
+ mem = 24;
+ if (catomic_compare_and_exchange_val_acq (&mem, 35, 24) != 24
+ || mem != 35)
+ {
+ puts ("catomic_compare_and_exchange_val_acq test 1 failed");
+ ret = 1;
+ }
+
+ mem = 12;
+ if (catomic_compare_and_exchange_val_acq (&mem, 10, 15) != 12
+ || mem != 12)
+ {
+ puts ("catomic_compare_and_exchange_val_acq test 2 failed");
+ ret = 1;
+ }
+
+ mem = -15;
+ if (catomic_compare_and_exchange_val_acq (&mem, -56, -15) != -15
+ || mem != -56)
+ {
+ puts ("catomic_compare_and_exchange_val_acq test 3 failed");
+ ret = 1;
+ }
+
+ mem = -1;
+ if (catomic_compare_and_exchange_val_acq (&mem, 17, 0) != -1
+ || mem != -1)
+ {
+ puts ("catomic_compare_and_exchange_val_acq test 4 failed");
+ ret = 1;
+ }
+#endif
+
+ mem = 24;
+ if (catomic_compare_and_exchange_bool_acq (&mem, 35, 24)
+ || mem != 35)
+ {
+ puts ("catomic_compare_and_exchange_bool_acq test 1 failed");
+ ret = 1;
+ }
+
+ mem = 12;
+ if (! catomic_compare_and_exchange_bool_acq (&mem, 10, 15)
+ || mem != 12)
+ {
+ puts ("catomic_compare_and_exchange_bool_acq test 2 failed");
+ ret = 1;
+ }
+
+ mem = -15;
+ if (catomic_compare_and_exchange_bool_acq (&mem, -56, -15)
+ || mem != -56)
+ {
+ puts ("catomic_compare_and_exchange_bool_acq test 3 failed");
+ ret = 1;
+ }
+
+ mem = -1;
+ if (! catomic_compare_and_exchange_bool_acq (&mem, 17, 0)
+ || mem != -1)
+ {
+ puts ("catomic_compare_and_exchange_bool_acq test 4 failed");
+ ret = 1;
+ }
+
+ mem = 2;
+ if (catomic_exchange_and_add (&mem, 11) != 2
+ || mem != 13)
+ {
+ puts ("catomic_exchange_and_add test failed");
+ ret = 1;
+ }
+
+ mem = -21;
+ catomic_add (&mem, 22);
+ if (mem != 1)
+ {
+ puts ("catomic_add test failed");
+ ret = 1;
+ }
+
+ mem = -1;
+ catomic_increment (&mem);
+ if (mem != 0)
+ {
+ puts ("catomic_increment test failed");
+ ret = 1;
+ }
+
+ mem = 2;
+ if (catomic_increment_val (&mem) != 3)
+ {
+ puts ("catomic_increment_val test failed");
+ ret = 1;
+ }
+
+ mem = 17;
+ catomic_decrement (&mem);
+ if (mem != 16)
+ {
+ puts ("catomic_decrement test failed");
+ ret = 1;
+ }
+
+ if (catomic_decrement_val (&mem) != 15)
+ {
+ puts ("catomic_decrement_val test failed");
+ ret = 1;
+ }
+
+ /* Tests for C11-like atomics. */
+ mem = 11;
+ if (atomic_load_relaxed (&mem) != 11 || atomic_load_acquire (&mem) != 11)
+ {
+ puts ("atomic_load_{relaxed,acquire} test failed");
+ ret = 1;
+ }
+
+ atomic_store_relaxed (&mem, 12);
+ if (mem != 12)
+ {
+ puts ("atomic_store_relaxed test failed");
+ ret = 1;
+ }
+ atomic_store_release (&mem, 13);
+ if (mem != 13)
+ {
+ puts ("atomic_store_release test failed");
+ ret = 1;
+ }
+
+ mem = 14;
+ expected = 14;
+ if (!atomic_compare_exchange_weak_relaxed (&mem, &expected, 25)
+ || mem != 25 || expected != 14)
+ {
+ puts ("atomic_compare_exchange_weak_relaxed test 1 failed");
+ ret = 1;
+ }
+ if (atomic_compare_exchange_weak_relaxed (&mem, &expected, 14)
+ || mem != 25 || expected != 25)
+ {
+ puts ("atomic_compare_exchange_weak_relaxed test 2 failed");
+ ret = 1;
+ }
+ mem = 14;
+ expected = 14;
+ if (!atomic_compare_exchange_weak_acquire (&mem, &expected, 25)
+ || mem != 25 || expected != 14)
+ {
+ puts ("atomic_compare_exchange_weak_acquire test 1 failed");
+ ret = 1;
+ }
+ if (atomic_compare_exchange_weak_acquire (&mem, &expected, 14)
+ || mem != 25 || expected != 25)
+ {
+ puts ("atomic_compare_exchange_weak_acquire test 2 failed");
+ ret = 1;
+ }
+ mem = 14;
+ expected = 14;
+ if (!atomic_compare_exchange_weak_release (&mem, &expected, 25)
+ || mem != 25 || expected != 14)
+ {
+ puts ("atomic_compare_exchange_weak_release test 1 failed");
+ ret = 1;
+ }
+ if (atomic_compare_exchange_weak_release (&mem, &expected, 14)
+ || mem != 25 || expected != 25)
+ {
+ puts ("atomic_compare_exchange_weak_release test 2 failed");
+ ret = 1;
+ }
+
+ mem = 23;
+ if (atomic_exchange_acquire (&mem, 42) != 23 || mem != 42)
+ {
+ puts ("atomic_exchange_acquire test failed");
+ ret = 1;
+ }
+ mem = 23;
+ if (atomic_exchange_release (&mem, 42) != 23 || mem != 42)
+ {
+ puts ("atomic_exchange_release test failed");
+ ret = 1;
+ }
+
+ mem = 23;
+ if (atomic_fetch_add_relaxed (&mem, 1) != 23 || mem != 24)
+ {
+ puts ("atomic_fetch_add_relaxed test failed");
+ ret = 1;
+ }
+ mem = 23;
+ if (atomic_fetch_add_acquire (&mem, 1) != 23 || mem != 24)
+ {
+ puts ("atomic_fetch_add_acquire test failed");
+ ret = 1;
+ }
+ mem = 23;
+ if (atomic_fetch_add_release (&mem, 1) != 23 || mem != 24)
+ {
+ puts ("atomic_fetch_add_release test failed");
+ ret = 1;
+ }
+ mem = 23;
+ if (atomic_fetch_add_acq_rel (&mem, 1) != 23 || mem != 24)
+ {
+ puts ("atomic_fetch_add_acq_rel test failed");
+ ret = 1;
+ }
+
+ mem = 3;
+ if (atomic_fetch_and_acquire (&mem, 2) != 3 || mem != 2)
+ {
+ puts ("atomic_fetch_and_acquire test failed");
+ ret = 1;
+ }
+
+ mem = 4;
+ if (atomic_fetch_or_relaxed (&mem, 2) != 4 || mem != 6)
+ {
+ puts ("atomic_fetch_or_relaxed test failed");
+ ret = 1;
+ }
+ mem = 4;
+ if (atomic_fetch_or_acquire (&mem, 2) != 4 || mem != 6)
+ {
+ puts ("atomic_fetch_or_acquire test failed");
+ ret = 1;
+ }
+
+ /* This is a single-threaded test, so we can't test the effects of the
+ fences. */
+ atomic_thread_fence_acquire ();
+ atomic_thread_fence_release ();
+ atomic_thread_fence_seq_cst ();
+
+ return ret;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/stat/Makefile b/test/stat/Makefile
index 008a81248..03fdb960a 100644
--- a/test/stat/Makefile
+++ b/test/stat/Makefile
@@ -1,12 +1,8 @@
# uClibc stat tests
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+top_builddir=../../
+top_srcdir=../../
+include ../Rules.mak
+-include Makefile.in
include ../Test.mak
-
-CFLAGS_stat64 := -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
-
-DODIFF_stat := 1
-DODIFF_stat64 := 1
-
-OPTS_stat := Makefile
-OPTS_stat64 := Makefile
diff --git a/test/stat/Makefile.in b/test/stat/Makefile.in
new file mode 100644
index 000000000..9c06dedb3
--- /dev/null
+++ b/test/stat/Makefile.in
@@ -0,0 +1,13 @@
+# uClibc stat tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+ifeq ($(UCLIBC_HAS_LFS),)
+TESTS_DISABLED := stat64
+endif
+CFLAGS_stat64 := -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
+
+DODIFF_stat := 1
+DODIFF_stat64 := 1
+
+OPTS_stat := Makefile
+OPTS_stat64 := Makefile
diff --git a/test/stat/memcmp-stat.c b/test/stat/memcmp-stat.c
index c38e3ff88..254c754c4 100644
--- a/test/stat/memcmp-stat.c
+++ b/test/stat/memcmp-stat.c
@@ -48,7 +48,7 @@ static void show_stat(struct stat *st)
(long int)st->st_size,
(long int)st->st_blksize,
(long int)st->st_blocks,
-#ifndef __UCLIBC__
+#if !defined(__UCLIBC__) || defined(__USE_MISC)
(long int)st->st_atime,
(long int)st->st_atim.tv_nsec,
(long int)st->st_mtime,
diff --git a/test/stat/stat-loop256.c b/test/stat/stat-loop256.c
new file mode 100644
index 000000000..14284c184
--- /dev/null
+++ b/test/stat/stat-loop256.c
@@ -0,0 +1,32 @@
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+int main()
+{
+ struct stat statbuf;
+ int ret = 0;
+ char* loop255 = "/dev/loop255";
+ char* loop256 = "/dev/loop256";
+ mode_t mode = 0660;
+ mknod(loop255, mode, 0x7ff);
+ mknod(loop256, mode, 0x100700);
+ ret = stat(loop255, &statbuf);
+ if(ret < 0) {
+ printf("stat: Cant stat %s\n",loop255);
+ unlink(loop255);
+ exit(1);
+ }
+ ret = stat(loop256, &statbuf);
+ if(ret < 0) {
+ printf("stat: Cant stat %s\n",loop256);
+ unlink(loop255);
+ unlink(loop256);
+ exit(1);
+ }
+
+ unlink(loop255);
+ unlink(loop256);
+ exit(0);
+}
+
diff --git a/test/stdio/Makefile b/test/stdio/Makefile
index d3ae2f368..95b930b9d 100644
--- a/test/stdio/Makefile
+++ b/test/stdio/Makefile
@@ -1,6 +1,8 @@
-# uClibc assert tests
+# uClibc stdio tests
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+top_builddir=../../
+top_srcdir=../../
+include ../Rules.mak
+-include Makefile.in
include ../Test.mak
-
-DODIFF_64bit := 1
diff --git a/test/stdio/Makefile.in b/test/stdio/Makefile.in
new file mode 100644
index 000000000..3e60b4090
--- /dev/null
+++ b/test/stdio/Makefile.in
@@ -0,0 +1,10 @@
+# uClibc stdio tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+DODIFF_64bit := 1
+
+ifeq ($(UCLIBC_HAS_GLIBC_CUSTOM_STREAMS),)
+TESTS_DISABLED += tst-fmemopen
+endif
+
+CFLAGS_tst-fmemopen = -fPIC
diff --git a/test/stdio/lseek_no_lfs.c b/test/stdio/lseek_no_lfs.c
new file mode 100644
index 000000000..54daf6b48
--- /dev/null
+++ b/test/stdio/lseek_no_lfs.c
@@ -0,0 +1,22 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+
+int main(int argc, char *argv[])
+{
+ FILE * f = fopen(argv[0], "rb");
+ if (!f)
+ {
+ printf("Error: Can't open %s, reason: %s\n", argv[0], strerror(errno));
+ return 1;
+ }
+
+ if (fseek(f, (unsigned)4096, (int)SEEK_SET) == -1)
+ {
+ printf("Test failed, fseek return fail code. errno=%u (%s)\n", errno, strerror(errno));
+ return 1;
+ }
+
+ fclose(f);
+ return 0;
+}
diff --git a/test/stdio/scanf_m.c b/test/stdio/scanf_m.c
new file mode 100644
index 000000000..0ce78b6e4
--- /dev/null
+++ b/test/stdio/scanf_m.c
@@ -0,0 +1,24 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int main(void)
+{
+ const char *buf = "hello world";
+ char *ps = NULL, *pc = NULL;
+ char s[6], c;
+
+ /* Check that %[...]/%c work. */
+ sscanf(buf, "%[a-z] %c", s, &c);
+ /* Check that %m[...]/%mc work. */
+ sscanf(buf, "%m[a-z] %mc", &ps, &pc);
+
+ if (strcmp(ps, "hello") != 0 || *pc != 'w' ||
+ strcmp(s, "hello") != 0 || c != 'w')
+ return 1;
+
+ free(ps);
+ free(pc);
+
+ return 0;
+}
diff --git a/test/stdio/tst-fmemopen.c b/test/stdio/tst-fmemopen.c
new file mode 100644
index 000000000..384faa1c9
--- /dev/null
+++ b/test/stdio/tst-fmemopen.c
@@ -0,0 +1,53 @@
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+static char *text_input = "1 23 43";
+
+static const char *good_answer = "1 529 1849 ";
+
+
+static int
+do_test (void)
+{
+ FILE *out, *in;
+ int v, s;
+ size_t size;
+ char *ptr;
+
+ in = fmemopen(text_input, strlen(text_input), "r");
+ if (in == NULL) {
+ perror("fmemopen");
+ return 1;
+ }
+
+ out = open_memstream(&ptr, &size);
+ if (out == NULL) {
+ perror("open_memstream");
+ return 1;
+ }
+
+ for (;;) {
+ s = fscanf(in, "%d", &v);
+ if (s <= 0)
+ break;
+
+ s = fprintf(out, "%d ", v * v);
+ if (s == -1) {
+ puts("fprintf failed");
+ exit(1);
+ }
+ }
+ fclose(in);
+ fclose(out);
+
+ if (size != strlen(good_answer) || strcmp(good_answer, ptr) != 0) {
+ printf("failed: size=%zu; ptr=%s\n", size, ptr);
+ exit(1);
+ }
+ free(ptr);
+ exit(0);
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/stdlib/Makefile b/test/stdlib/Makefile
index efec56d70..567e0e37a 100644
--- a/test/stdlib/Makefile
+++ b/test/stdlib/Makefile
@@ -1,9 +1,8 @@
# uClibc stdlib tests
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+top_builddir=../../
+top_srcdir=../../
+include ../Rules.mak
+-include Makefile.in
include ../Test.mak
-
-DODIFF_qsort := 1
-DODIFF_testatexit := 1
-DODIFF_teston_exit := 1
-DODIFF_teststrtol := 1
diff --git a/test/stdlib/Makefile.in b/test/stdlib/Makefile.in
new file mode 100644
index 000000000..91dfde412
--- /dev/null
+++ b/test/stdlib/Makefile.in
@@ -0,0 +1,19 @@
+# uClibc stdlib tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+DODIFF_qsort := 1
+DODIFF_testatexit := 1
+DODIFF_teston_exit := 1
+DODIFF_teststrtol := 1
+
+TESTS_DISABLED :=
+ifeq ($(UCLIBC_HAS_PTY),)
+TESTS_DISABLED += ptytest
+endif
+ifeq ($(UCLIBC_HAS_ARC4RANDOM),)
+TESTS_DISABLED += testarc4random
+endif
+
+CFLAGS_test-canon = -fPIC
+CFLAGS_test-canon2 = -fPIC
+CFLAGS_testatexit = -fPIC
diff --git a/test/stdlib/qsort.c b/test/stdlib/qsort.c
index abc505e2d..74f93315f 100644
--- a/test/stdlib/qsort.c
+++ b/test/stdlib/qsort.c
@@ -34,7 +34,15 @@ int main(void)
printf("[%d] %s\n", i, dirbuf->d_name);
}
printf("\nCalling qsort()\n");
- qsort(array, numdir, sizeof(struct dirent *), alphasort);
+ /* Even though some manpages say that alphasort should be
+ * int alphasort(const void *a, const void *b),
+ * in reality glibc and uclibc have const struct dirent**
+ * instead of const void*.
+ * Therefore we get a warning here unless we use a cast,
+ * which makes people think that alphasort prototype
+ * needs to be fixed in uclibc headers.
+ */
+ qsort(array, numdir, sizeof(struct dirent *), (void*) alphasort);
for (i = 0; i < numdir; ++i) {
dirbuf = array[i];
printf("[%d] %s\n", i, dirbuf->d_name);
diff --git a/test/stdlib/test-canon.c b/test/stdlib/test-canon.c
index 9770a948d..1b43dedfb 100644
--- a/test/stdlib/test-canon.c
+++ b/test/stdlib/test-canon.c
@@ -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/>. */
/* This file must be run from within a directory called "stdlib". */
@@ -28,10 +27,11 @@
#include <string.h>
#include <unistd.h>
#include <sys/param.h>
+#include <sys/stat.h>
/* Prototype for our test function. */
extern int do_test (int argc, char *argv[]);
-#include <test-skeleton.c>
+#include "../test-skeleton.c"
#ifndef PATH_MAX
# define PATH_MAX 4096
diff --git a/test/stdlib/test-canon2.c b/test/stdlib/test-canon2.c
new file mode 100644
index 000000000..4a03b2d48
--- /dev/null
+++ b/test/stdlib/test-canon2.c
@@ -0,0 +1,86 @@
+/* Test for realpath/canonicalize function.
+ Copyright (C) 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 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/>. */
+
+#include <errno.h>
+#include <string.h>
+
+
+/* Prototype for our test function. */
+extern void do_prepare (int argc, char *argv[]);
+extern int do_test (int argc, char *argv[]);
+
+/* We have a preparation function. */
+#define PREPARE do_prepare
+
+#include <test-skeleton.c>
+
+/* Name of the temporary files we create. */
+char *name1;
+char *name2;
+
+/* Preparation. */
+void
+do_prepare (int argc, char *argv[])
+{
+ size_t test_dir_len;
+ int tfd;
+
+ test_dir_len = strlen (test_dir);
+
+ /* Generate the circular symlinks. */
+ name1 = malloc (test_dir_len + sizeof ("/canonXXXXXX"));
+ mempcpy (mempcpy (name1, test_dir, test_dir_len),
+ "/canonXXXXXX", sizeof ("/canonXXXXXX"));
+ name2 = strdup (name1);
+ tfd = mkstemp(name1);
+ if (tfd < 0) {
+ printf("%s: cannot generate temp file name\n", __FUNCTION__);
+ exit(1);
+ }
+ close(tfd);
+ add_temp_file (name1);
+ tfd = mkstemp(name2);
+ if (tfd < 0) {
+ printf("%s: cannot generate temp file name\n", __FUNCTION__);
+ exit(1);
+ }
+ close(tfd);
+ add_temp_file (name2);
+}
+
+
+/* Run the test. */
+int
+do_test (int argc, char *argv[])
+{
+ char *canon;
+
+ printf ("create symlinks from %s to %s and vice versa\n", name1, name2);
+ if (symlink (name1, name2) == -1
+ || symlink (name2, name1) == -1)
+ /* We cannot test this. */
+ return 0;
+
+ /* Call the function. This is equivalent the using `realpath' but the
+ function allocates the room for the result. */
+ errno = 0;
+ canon = canonicalize_file_name (name1);
+
+ return canon != NULL || errno != ELOOP;
+}
diff --git a/test/stdlib/test-mkostemp-O_CLOEXEC.c b/test/stdlib/test-mkostemp-O_CLOEXEC.c
new file mode 100644
index 000000000..9ff229af1
--- /dev/null
+++ b/test/stdlib/test-mkostemp-O_CLOEXEC.c
@@ -0,0 +1,45 @@
+#define _XOPEN_SOURCE_EXTENDED
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/wait.h>
+#include <errno.h>
+
+#if !defined __ARCH_USE_MMU__
+# define fork vfork
+#endif
+
+int main(int argc, char *argv[]) {
+ int fd, status;
+ char buff[5];
+ char template[] = "/tmp/test-mkostemp.XXXXXX";
+
+ fd = mkostemp(template, O_CLOEXEC);
+ unlink(template);
+
+ snprintf(buff, 5, "%d", fd);
+
+ if(!fork())
+ if(execl("./test-mkostemp-child", "test-mkostemp-child", buff, NULL) == -1)
+ exit(EXIT_FAILURE);
+
+ wait(&status);
+
+ memset(buff, 0, 5);
+ lseek(fd, 0, SEEK_SET);
+ errno = 0;
+ if(read(fd, buff, 5) == -1)
+ exit(EXIT_FAILURE);
+
+ if(!strncmp(buff, "test", 5))
+ exit(EXIT_FAILURE);
+ else
+ exit(EXIT_SUCCESS);
+
+ close(fd);
+ exit(EXIT_SUCCESS);
+}
diff --git a/test/stdlib/test-mkostemp-child.c b/test/stdlib/test-mkostemp-child.c
new file mode 100644
index 000000000..708bd80a1
--- /dev/null
+++ b/test/stdlib/test-mkostemp-child.c
@@ -0,0 +1,22 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+int main(int argc, char *argv[]) {
+ int fd;
+
+ /* This file gets built and run as a test, but its
+ * really just a helper for test-mkostemp-O_CLOEXEC.c.
+ * So, we'll always return succcess.
+ */
+ if(argc != 2)
+ exit(EXIT_SUCCESS);
+
+ sscanf(argv[1], "%d", &fd);
+
+ if(write(fd, "test\0", 5) == -1)
+ ; /* Don't Panic! Failure is okay here. */
+
+ close(fd);
+ exit(EXIT_SUCCESS);
+}
diff --git a/test/stdlib/testarc4random.c b/test/stdlib/testarc4random.c
new file mode 100644
index 000000000..14ff1cc36
--- /dev/null
+++ b/test/stdlib/testarc4random.c
@@ -0,0 +1,10 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+int main(void)
+{
+ int random_number;
+ random_number = arc4random() % 65536;
+ printf("%d\n", random_number);
+ return 0;
+}
diff --git a/test/stdlib/teststrtoq.c b/test/stdlib/teststrtoq.c
new file mode 100644
index 000000000..6e1a4cbc6
--- /dev/null
+++ b/test/stdlib/teststrtoq.c
@@ -0,0 +1,89 @@
+
+#include <stdlib.h>
+#include <stdio.h>
+
+
+const char *strings[]={
+ /* some simple stuff */
+ "0", "1", "10",
+ "100", "1000", "10000", "100000", "1000000",
+ "10000000", "100000000", "1000000000",
+
+ /* negative */
+ "-0", "-1", "-10",
+ "-100", "-1000", "-10000", "-100000", "-1000000",
+ "-10000000", "-100000000", "-1000000000",
+
+ /* test base>10 */
+ "a", "b", "f", "g", "z",
+
+ /* test hex */
+ "0x0", "0x1", "0xa", "0xf", "0x10",
+
+ /* test octal */
+ "00", "01", "07", "08", "0a", "010",
+
+ /* other */
+ "0x8000000",
+
+ /* check overflow cases: (for 32 bit) */
+ "2147483645",
+ "2147483646",
+ "2147483647",
+ "2147483648",
+ "2147483649",
+ "-2147483645",
+ "-2147483646",
+ "-2147483647",
+ "-2147483648",
+ "-2147483649",
+ "4294967293",
+ "4294967294",
+ "4294967295",
+ "4294967296",
+ "4294967297",
+ "-4294967293",
+ "-4294967294",
+ "-4294967295",
+ "-4294967296",
+ "-4294967297",
+
+ /* bad input tests */
+ "",
+ "00",
+ "0x",
+ "0x0",
+ "-",
+ "+",
+ " ",
+ " -",
+ " - 0",
+};
+int n_tests=sizeof(strings)/sizeof(strings[0]);
+
+
+
+void do_test(int base);
+void do_test(int base)
+{
+ int i;
+ quad_t n;
+ char *endptr;
+
+ for(i=0;i<n_tests;i++){
+ n=strtoq(strings[i],&endptr,base);
+ printf("strtoq(\"%s\",%d) len=%lu res=%qd\n",
+ strings[i],base,(unsigned long)(endptr-strings[i]),n);
+ }
+}
+
+int main(int argc,char *argv[])
+{
+ do_test(0);
+ do_test(8);
+ do_test(10);
+ do_test(16);
+ do_test(36);
+
+ return 0;
+}
diff --git a/test/string/Makefile b/test/string/Makefile
index a18d52e93..8948a50e3 100644
--- a/test/string/Makefile
+++ b/test/string/Makefile
@@ -1,6 +1,8 @@
# uClibc string tests
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+top_builddir=../../
+top_srcdir=../../
+include ../Rules.mak
+-include Makefile.in
include ../Test.mak
-
-EXTRA_CFLAGS := -fno-builtin
diff --git a/test/string/Makefile.in b/test/string/Makefile.in
new file mode 100644
index 000000000..39fb91210
--- /dev/null
+++ b/test/string/Makefile.in
@@ -0,0 +1,8 @@
+# uClibc string tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+EXTRA_CFLAGS := -fno-builtin
+
+ifeq ($(TARGET_ARCH),h8300)
+TESTS_DISABLED += stratcliff
+endif
diff --git a/test/string/stratcliff.c b/test/string/stratcliff.c
index 41e774681..b45be4bde 100644
--- a/test/string/stratcliff.c
+++ b/test/string/stratcliff.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/>. */
#define _GNU_SOURCE 1
diff --git a/test/string/test-ffs.c b/test/string/test-ffs.c
index 86e11758d..e43f12360 100644
--- a/test/string/test-ffs.c
+++ b/test/string/test-ffs.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/>. */
#include <stdlib.h>
#include <stdio.h>
diff --git a/test/string/testcopy.c b/test/string/testcopy.c
index 60039f790..51c47a174 100644
--- a/test/string/testcopy.c
+++ b/test/string/testcopy.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 <stdlib.h>
#include <stdio.h>
diff --git a/test/string/tester.c b/test/string/tester.c
index ac1b90118..7f3ff2865 100644
--- a/test/string/tester.c
+++ b/test/string/tester.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/>. */
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
@@ -427,6 +426,7 @@ test_strncmp (void)
check (strncmp ("abc", "def", 0) == 0, 13); /* Zero count. */
check (strncmp ("abc", "", (size_t)-1) > 0, 14); /* set sign bit in count */
check (strncmp ("abc", "abc", (size_t)-2) == 0, 15);
+ check (strncmp ("aa", "ab", (size_t)-1) < 0, 16);
}
static void
diff --git a/test/string/tst-bswap.c b/test/string/tst-bswap.c
index b2b4ef08d..52a271814 100644
--- a/test/string/tst-bswap.c
+++ b/test/string/tst-bswap.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 <byteswap.h>
#include <stdio.h>
diff --git a/test/string/tst-inlcall.c b/test/string/tst-inlcall.c
index 2a4124ea5..7e2eba37e 100644
--- a/test/string/tst-inlcall.c
+++ b/test/string/tst-inlcall.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/>. */
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
diff --git a/test/termios/Makefile b/test/termios/Makefile
index 2aa6ccd90..098cca6e0 100644
--- a/test/termios/Makefile
+++ b/test/termios/Makefile
@@ -1,4 +1,8 @@
# uClibc termios tests
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+top_builddir=../../
+top_srcdir=../../
+include ../Rules.mak
+-include Makefile.in
include ../Test.mak
diff --git a/test/test-skeleton.c b/test/test-skeleton.c
index adfc8b75b..4f2680485 100644
--- a/test/test-skeleton.c
+++ b/test/test-skeleton.c
@@ -14,10 +14,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 <assert.h>
#include <errno.h>
#include <getopt.h>
#include <malloc.h>
@@ -44,19 +44,6 @@
# define TEST_DATA_LIMIT (64 << 20) /* Data limit (bytes) to run with. */
#endif
-#define OPT_DIRECT 1000
-#define OPT_TESTDIR 1001
-
-static struct option options[] =
-{
-#ifdef CMDLINE_OPTIONS
- CMDLINE_OPTIONS
-#endif
- { "direct", no_argument, NULL, OPT_DIRECT },
- { "test-dir", required_argument, NULL, OPT_TESTDIR },
- { NULL, 0, NULL, 0 }
-};
-
/* PID of the test itself. */
static pid_t pid;
@@ -67,7 +54,7 @@ static const char *test_dir;
struct temp_name_list
{
struct qelem q;
- const char *name;
+ char *name;
} *temp_name_list;
/* Add temporary files in list. */
@@ -77,14 +64,17 @@ add_temp_file (const char *name)
{
struct temp_name_list *newp
= (struct temp_name_list *) calloc (sizeof (*newp), 1);
- if (newp != NULL)
+ char *newname = strdup (name);
+ if (newp != NULL && newname != NULL)
{
- newp->name = name;
+ newp->name = newname;
if (temp_name_list == NULL)
temp_name_list = (struct temp_name_list *) &newp->q;
else
insque (newp, temp_name_list);
}
+ else
+ free (newp);
}
/* Delete all temporary files. */
@@ -94,17 +84,25 @@ delete_temp_files (void)
while (temp_name_list != NULL)
{
remove (temp_name_list->name);
- temp_name_list = (struct temp_name_list *) temp_name_list->q.q_forw;
+ free (temp_name_list->name);
+
+ struct temp_name_list *next
+ = (struct temp_name_list *) temp_name_list->q.q_forw;
+ free (temp_name_list);
+ temp_name_list = next;
}
}
-/* Create a temporary file. */
+/* Create a temporary file. Return the opened file descriptor on
+ success, or -1 on failure. Write the file name to *FILENAME if
+ FILENAME is not NULL. In this case, the caller is expected to free
+ *FILENAME. */
static int
__attribute__ ((unused))
create_temp_file (const char *base, char **filename)
{
char *fname;
- int fd;
+ int _fd;
fname = (char *) malloc (strlen (test_dir) + 1 + strlen (base)
+ sizeof ("XXXXXX"));
@@ -115,8 +113,8 @@ create_temp_file (const char *base, char **filename)
}
strcpy (stpcpy (stpcpy (stpcpy (fname, test_dir), "/"), base), "XXXXXX");
- fd = mkstemp (fname);
- if (fd == -1)
+ _fd = mkstemp (fname);
+ if (_fd == -1)
{
printf ("cannot open temporary file '%s': %s\n", fname, strerror(errno));
free (fname);
@@ -126,25 +124,33 @@ create_temp_file (const char *base, char **filename)
add_temp_file (fname);
if (filename != NULL)
*filename = fname;
+ else
+ free (fname);
- return fd;
+ return _fd;
}
/* Timeout handler. We kill the child and exit with an error. */
static void
__attribute__ ((noreturn))
-timeout_handler (int sig __attribute__ ((unused)))
+signal_handler (int sig __attribute__ ((unused)))
{
int killed = 0;
int status;
+ int i;
- /* Send signal. */
+ assert (pid > 1);
+ /* Kill the whole process group. */
+ kill (-pid, SIGKILL);
+ /* In case setpgid failed in the child, kill it individually too. */
kill (pid, SIGKILL);
/* Wait for it to terminate. */
- int i;
for (i = 0; i < 5; ++i)
{
+#ifdef __UCLIBC_HAS_REALTIME__
+ struct timespec ts;
+#endif
killed = waitpid (pid, &status, WNOHANG|WUNTRACED);
if (killed != 0)
break;
@@ -153,10 +159,14 @@ timeout_handler (int sig __attribute__ ((unused)))
nanosleep() call return prematurely, all the better. We
won't restart it since this probably means the child process
finally died. */
- struct timespec ts;
+#ifdef __UCLIBC_HAS_REALTIME__
ts.tv_sec = 0;
ts.tv_nsec = 100000000;
nanosleep (&ts, NULL);
+#else
+ /* No nanosleep, just sleep 1s instead of 0.1s */
+ sleep(1);
+#endif
}
if (killed != 0 && killed != pid)
{
@@ -168,6 +178,12 @@ timeout_handler (int sig __attribute__ ((unused)))
CLEANUP_HANDLER;
#endif
+ if (sig == SIGINT)
+ {
+ signal (sig, SIG_DFL);
+ raise (sig);
+ }
+
/* If we expected this signal: good! */
#ifdef EXPECTED_SIGNAL
if (EXPECTED_SIGNAL == SIGALRM)
@@ -190,6 +206,18 @@ timeout_handler (int sig __attribute__ ((unused)))
exit (1);
}
+#ifdef __XXX_HANDLE_CTRL_C
+static void
+__attribute__ ((noreturn))
+handler_killpid(int sig)
+{
+ kill(pid, SIGKILL); /* kill test */
+ signal(sig, SIG_DFL);
+ raise(sig); /* kill ourself */
+ _exit(128 + sig); /* paranoia */
+}
+#endif
+
/* We provide the entry point here. */
int
main (int argc, char *argv[])
@@ -203,6 +231,7 @@ main (int argc, char *argv[])
int opt;
unsigned int timeoutfactor = 1;
pid_t termpid;
+ char *envstr_timeoutfactor;
/* Make uses of freed and uninitialized memory known. */
#ifdef __MALLOC_STANDARD__
@@ -216,15 +245,18 @@ main (int argc, char *argv[])
setbuf (stdout, NULL);
#endif
- while ((opt = getopt_long (argc, argv, "+", options, NULL)) != -1)
+# ifndef CMDLINE_OPTIONS
+# define CMDLINE_OPTIONS ""
+# endif
+ while ((opt = getopt (argc, argv, "+dt:" CMDLINE_OPTIONS)) >= 0)
switch (opt)
{
case '?':
exit (1);
- case OPT_DIRECT:
+ case 'd':
direct = 1;
break;
- case OPT_TESTDIR:
+ case 't':
test_dir = optarg;
break;
#ifdef CMDLINE_PROCESS
@@ -234,7 +266,7 @@ main (int argc, char *argv[])
/* If set, read the test TIMEOUTFACTOR value from the environment.
This value is used to scale the default test timeout values. */
- char *envstr_timeoutfactor = getenv ("TIMEOUTFACTOR");
+ envstr_timeoutfactor = getenv ("TIMEOUTFACTOR");
if (envstr_timeoutfactor != NULL)
{
char *envstr_conv = envstr_timeoutfactor;
@@ -293,6 +325,9 @@ main (int argc, char *argv[])
if (pid == 0)
{
/* This is the child. */
+#ifdef RLIMIT_DATA
+ struct rlimit data_limit;
+#endif
#ifdef RLIMIT_CORE
/* Try to avoid dumping core. */
struct rlimit core_limit;
@@ -303,7 +338,6 @@ main (int argc, char *argv[])
#ifdef RLIMIT_DATA
/* Try to avoid eating all memory if a test leaks. */
- struct rlimit data_limit;
if (getrlimit (RLIMIT_DATA, &data_limit) == 0)
{
if (TEST_DATA_LIMIT == RLIM_INFINITY)
@@ -320,7 +354,8 @@ main (int argc, char *argv[])
/* We put the test process in its own pgrp so that if it bogusly
generates any job control signals, they won't hit the whole build. */
- setpgid (0, 0);
+ if (setpgid (0, 0) != 0)
+ printf ("Failed to set the process group ID: %m\n");
/* Execute the test function and exit with the return value. */
exit (TEST_FUNCTION);
@@ -332,14 +367,23 @@ main (int argc, char *argv[])
exit (1);
}
+#ifdef __XXX_HANDLE_CTRL_C
+ signal (SIGTERM, handler_killpid);
+ signal (SIGINT, handler_killpid);
+ signal (SIGQUIT, handler_killpid);
+#endif
+
/* Set timeout. */
#ifndef TIMEOUT
/* Default timeout is two seconds. */
# define TIMEOUT 2
#endif
- signal (SIGALRM, timeout_handler);
+ signal (SIGALRM, signal_handler);
alarm (TIMEOUT * timeoutfactor);
+ /* Make sure we clean up if the wrapper gets interrupted. */
+ signal (SIGINT, signal_handler);
+
/* Wait for the regular termination. */
termpid = TEMP_FAILURE_RETRY (waitpid (pid, &status, 0));
if (termpid == -1)
diff --git a/test/testsuite.h b/test/testsuite.h
index afc45b0c0..84c78156a 100644
--- a/test/testsuite.h
+++ b/test/testsuite.h
@@ -27,11 +27,12 @@ void error_msg(int result, int line, const char* file, const char* command)
{
failures++;
- printf("\nFAILED TEST %lu: \n\t%s\n", (unsigned long)test_number, command);
+ printf("\nFAILED TEST %lu: \n\t%s\nResult: %d",
+ (unsigned long)test_number, command, result);
printf("AT LINE: %d, FILE: %s\n\n", line, file);
}
-void success_msg(int result, const char* command)
+void success_msg(int result __attribute__((unused)), const char* command __attribute__((unused)))
{
#if 0
printf("passed test: %s == 0\n", command);
diff --git a/test/time/Makefile b/test/time/Makefile
index 8c6978f0d..fed45697b 100644
--- a/test/time/Makefile
+++ b/test/time/Makefile
@@ -1,13 +1,8 @@
# uClibc time tests
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-TESTS_DISABLED := bug-asctime bug-asctime_r time tst-mktime2 tst-posixtz \
- tst-strftime tst-strptime tst-timezone
-
-ifneq ($(UCLIBC_HAS_XLOCALE),y)
-TESTS_DISABLED += tst-ftime_l
-endif
-
+top_builddir=../../
+top_srcdir=../../
+include ../Rules.mak
+-include Makefile.in
include ../Test.mak
-
-CFLAGS_tst-strptime2 := -std=c99
diff --git a/test/time/Makefile.in b/test/time/Makefile.in
new file mode 100644
index 000000000..8afc013d7
--- /dev/null
+++ b/test/time/Makefile.in
@@ -0,0 +1,25 @@
+# uClibc time tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+TESTS_DISABLED := bug-asctime bug-asctime_r time tst-mktime2 tst-posixtz \
+ tst-strftime tst-strptime tst-timezone
+
+ifeq ($(TARGET_avr32),y)
+TESTS_DISABLED += tst-timerfd
+endif
+
+ifneq ($(UCLIBC_HAS_XLOCALE),y)
+TESTS_DISABLED += tst-ftime_l
+endif
+
+ifneq ($(UCLIBC_HAS_WCHAR)$(UCLIBC_HAS_LOCALE),yy)
+TESTS_DISABLED += tst_wcsftime
+endif
+
+CFLAGS_tst-strptime2 := -std=c99
+CFLAGS_tst-ctime = -fPIC
+CFLAGS_tst-futimens1 = -fPIC
+CFLAGS_tst-timerfd = -fPIC
+
+DODIFF_futimens1 := 1
+DODIFF_tst_wcsftime := 1
diff --git a/test/time/test_time.c b/test/time/test_time.c
index 2ce819a3f..ab2931895 100644
--- a/test/time/test_time.c
+++ b/test/time/test_time.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 <stdio.h>
#include <stdlib.h>
diff --git a/test/time/tst-ctime.c b/test/time/tst-ctime.c
new file mode 100644
index 000000000..91d827aa2
--- /dev/null
+++ b/test/time/tst-ctime.c
@@ -0,0 +1,44 @@
+/* vi: set sw=4 ts=4: */
+/* testcase for ctime(3) with large time
+ * Copyright (C) 2010 David A Ramos <daramos@gustav.stanford.edu>
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#define MAX_POSITIVE(type) (~0 & ~((type) 1 << (sizeof(type)*8 - 1)))
+
+int do_test(int argc, char **argv) {
+ char *correct = 0, *s;
+ int status;
+
+ /* need a very high positive number (e.g., max - 1024) */
+ time_t test = MAX_POSITIVE(time_t) - 1024;
+
+ s = asctime(localtime(&test));
+
+ if (s) {
+ // copy static buffer to heap
+ correct = malloc(strlen(s)+1);
+ strcpy(correct, s);
+ }
+
+ s = ctime(&test);
+
+ printf("ANSI:\t%suClibc:\t%s", correct, s);
+
+ if (s != correct && strcmp(correct, s))
+ status = EXIT_FAILURE;
+ else
+ status = EXIT_SUCCESS;
+
+ if (correct)
+ free(correct);
+
+ return status;
+}
+
+#include <test-skeleton.c>
diff --git a/test/time/tst-futimens1.c b/test/time/tst-futimens1.c
new file mode 100644
index 000000000..2c25bd4de
--- /dev/null
+++ b/test/time/tst-futimens1.c
@@ -0,0 +1,105 @@
+/* vi: set sw=4 ts=4: */
+/* testcase for futimens(2)
+ * 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/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <unistd.h>
+
+struct
+{
+ char *name; /* name of file to open */
+ int flags; /* flags for file descriptor */
+ const struct timespec ts[2];
+ int err; /* expected errno */
+} tests [] =
+{
+ {"futimens.tst", (O_CREAT|O_TRUNC), {{0,0},{0,0}}, 0},
+ {"futimens.tst", (O_CREAT|O_TRUNC), {{99,0},{0,0}}, 0},
+ {"futimens.tst", (O_CREAT|O_TRUNC), {{0,99},{0,0}}, 0},
+ {"futimens.tst", (O_CREAT|O_TRUNC), {{0,0},{99,0}}, 0},
+ {"futimens.tst", (O_CREAT|O_TRUNC), {{0,0},{0,99}}, 0},
+ {"futimens.tst", (O_CREAT|O_TRUNC), {{11,2},{3,4}}, 0},
+};
+int do_test(int argc, char **argv) {
+ char *name;
+ int i, errors;
+ errors = argc - argc + 0;
+ unsigned has_stat_nsec = 0;
+ {
+ struct stat probe;
+ /* Let's attempt an educated guess if this filesystem supports
+ * nanosecond mtime. */
+ if ((!stat(".", &probe)) && probe.st_mtim.tv_nsec)
+ has_stat_nsec = 1;
+ else if ((!stat(argv[0], &probe)) && probe.st_mtim.tv_nsec)
+ has_stat_nsec = 1;
+ }
+ for (i=0; i < (int) (sizeof(tests)/sizeof(tests[0])); ++i) {
+ int err, fd;
+ struct stat sb;
+ name = tests[i].name;
+ if (*name != '.')
+ unlink(name);
+ fd = open(name, tests[i].flags, 0660);
+ if (fd < 0)
+ abort();
+ errno = 0;
+ err = futimens(fd, tests[i].ts);
+ if ((errno && !err) || (!errno && err)) {
+ err = errno;
+ printf("FAILED test %d (errno and return value disagree)\n", i);
+ ++errors;
+ } else
+ err = errno;
+ if (err != tests[i].err) {
+ printf("FAILED test %d (expected errno %d, got %d)\n",
+ i, tests[i].err, err);
+ ++errors;
+ continue;
+ }
+ if (stat(name, &sb) < 0) {
+ printf("FAILED test %d (verification)\n", i);
+ ++errors;
+ continue;
+ } else {
+ unsigned wrong = tests[i].ts[0].tv_sec != sb.st_atim.tv_sec ||
+ tests[i].ts[0].tv_nsec != sb.st_atim.tv_nsec ||
+ tests[i].ts[1].tv_sec != sb.st_mtim.tv_sec ||
+ tests[i].ts[1].tv_nsec != sb.st_mtim.tv_nsec;
+ if (wrong) {
+ if (tests[i].ts[0].tv_sec != sb.st_atim.tv_sec) {
+ printf("FAILED test %d (access time, sec: expected %ld, got %ld)\n",
+ i, tests[i].ts[0].tv_sec, sb.st_atim.tv_sec);
+ ++errors;
+ }
+ if (tests[i].ts[0].tv_nsec != sb.st_atim.tv_nsec) {
+ printf("FAILED test %d (access time, nsec: expected %ld, got %ld)\n",
+ i, tests[i].ts[0].tv_nsec, sb.st_atim.tv_nsec);
+ errors += has_stat_nsec;
+ }
+
+ if (tests[i].ts[1].tv_sec != sb.st_mtim.tv_sec) {
+ printf("FAILED test %d (modification time, sec: expected %ld, got %ld)\n",
+ i, tests[i].ts[1].tv_sec, sb.st_mtim.tv_sec);
+ ++errors;
+ }
+ if (tests[i].ts[1].tv_nsec != sb.st_mtim.tv_nsec) {
+ printf("FAILED test %d (modification time, nsec: expected %ld, got %ld)\n",
+ i, tests[i].ts[1].tv_nsec, sb.st_mtim.tv_nsec);
+ errors += has_stat_nsec;
+ }
+ }
+ }
+ }
+ if (*name != '.')
+ unlink(name);
+ printf("%d errors.\n", errors);
+ return (!errors) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
+#include <test-skeleton.c>
diff --git a/test/time/tst-strptime.c b/test/time/tst-strptime.c
index 6356aa0d4..32001d47e 100644
--- a/test/time/tst-strptime.c
+++ b/test/time/tst-strptime.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/>. */
#include <locale.h>
#include <stdio.h>
diff --git a/test/time/tst-timerfd.c b/test/time/tst-timerfd.c
new file mode 100644
index 000000000..5562ed74f
--- /dev/null
+++ b/test/time/tst-timerfd.c
@@ -0,0 +1,71 @@
+/* vi: set sw=4 ts=4 sts=4: */
+/*
+ * timerfd test for uClibc
+ * Copyright (C) 2012 by Kevin Cernekee <cernekee@gmail.com>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+#include <error.h>
+#include <signal.h>
+#include <stdint.h>
+#include <inttypes.h>
+#include <time.h>
+#include <sys/timerfd.h>
+#include <sys/fcntl.h>
+
+static int
+do_test(void)
+{
+ int fd, ret, result = 0;
+ struct itimerspec s;
+ uint64_t val;
+ time_t start, now;
+
+ fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK);
+ if (fd < 0) {
+ perror("timerfd() failed");
+ result = 1;
+ }
+ s.it_value.tv_sec = 1;
+ s.it_value.tv_nsec = 0;
+ s.it_interval.tv_sec = 0;
+ s.it_interval.tv_nsec = 0;
+ timerfd_settime(fd, 0, &s, NULL);
+ start = time(NULL);
+
+ /* this should return immediately with EAGAIN due to TFD_NONBLOCK */
+ ret = read(fd, &val, sizeof(val));
+ if (ret != -1 || errno != EAGAIN) {
+ error(0, 0, "first read() returned %d", ret);
+ result = 1;
+ }
+
+ /* let the timer expire, then check it again */
+ do {
+ now = time(NULL);
+ } while (now - start < 2);
+
+ ret = read(fd, &val, sizeof(val));
+ if (ret != sizeof(val)) {
+ error(0, 0, "second read() returned %d", ret);
+ result = 1;
+ }
+
+ /* we are expecting a single expiration, since it_interval is 0 */
+ if (val != 1) {
+ error(0, 0, "wrong number of expirations: %" PRIx64, val);
+ result = 1;
+ }
+
+ return result;
+}
+
+#define TIMEOUT 5
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/time/tst-timezone.c b/test/time/tst-timezone.c
index 4c879163c..e89be0b06 100644
--- a/test/time/tst-timezone.c
+++ b/test/time/tst-timezone.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 <time.h>
#include <stdio.h>
diff --git a/test/time/tst_wcsftime.c b/test/time/tst_wcsftime.c
index 6e35f1e6f..5631d952a 100644
--- a/test/time/tst_wcsftime.c
+++ b/test/time/tst_wcsftime.c
@@ -1,39 +1,65 @@
#include <stdio.h>
#include <time.h>
#include <features.h>
-#ifdef __UCLIBC_HAS_WCHAR__
#include <wchar.h>
+#include <locale.h>
+
+#define NUM_OF_DATES 7
+#define NUM_OF_LOCALES 3
+#define BUF_SIZE 256
int
-main (int argc, char *argv[])
+main (void)
{
- wchar_t buf[200];
- time_t t;
+ wchar_t buf[BUF_SIZE];
struct tm *tp;
- int result = 0;
+ time_t time_list[NUM_OF_DATES] = {
+ 500, 68200000, 694223999,
+ 694224000, 704900000, 705000000,
+ 705900000
+ };
+ char *locale_list[NUM_OF_LOCALES] = {
+ "C",
+ "fr_FR.ISO-8859-1",
+ "ja_JP.UTF-8"
+ };
+ int result = 0, ddd, lll;
size_t n;
- time (&t);
- tp = gmtime (&t);
+ for (lll = 0; lll < NUM_OF_LOCALES; lll++) {
+ printf ("\nUsing locale: %s\n", locale_list[lll]);
+ char* set = setlocale(LC_ALL, locale_list[lll]);
+ if (set == NULL) {
+ printf ("FAILED!\n\n");
+ continue;
+ } else
+ printf ("\n");
+ for (ddd = 0; ddd < NUM_OF_DATES; ddd++) {
+ tp = localtime(&time_list[ddd]);
+ printf ("%ld corresponds to ", time_list[ddd]);
- n = wcsftime (buf, sizeof (buf) / sizeof (buf[0]),
- L"%H:%M:%S %Y-%m-%d\n", tp);
- if (n != 21)
- result = 1;
+ n = wcsftime (buf, sizeof (buf) / sizeof (buf[0]),
+ L"%H:%M:%S %Y-%m-%d%n", tp);
+ if (n != 21) {
+ result = 1;
+ printf ("FAILED!\n");
+ }
- wprintf (L"It is now %ls", buf);
+ printf ("%ls", buf);
- wcsftime (buf, sizeof (buf) / sizeof (buf[0]), L"%A\n", tp);
+ wcsftime (buf, sizeof (buf) / sizeof (buf[0]),
+ L"%tor, as %%D %%T: %D %T%n", tp);
+ printf ("%ls", buf);
- wprintf (L"The weekday is %ls", buf);
+ wcsftime (buf, sizeof (buf) / sizeof (buf[0]), L"%A (%a)%n", tp);
+ printf ("The weekday was %ls", buf);
+ wcsftime (buf, sizeof (buf) / sizeof (buf[0]), L"%B (%b) %Y%n", tp);
+ /* glibc bug? forgets aigu from french february février
+ * See s/printf (/wprintf (L/g */
+ //wprintf (L"Month was %ls", buf);
+ printf ("Month was %ls", buf);
+ }
+ }
return result;
}
-
-#else
-int main(void)
-{
- puts("Test requires WCHAR support; skipping");
- return 0;
-}
-#endif
diff --git a/test/tls/Makefile b/test/tls/Makefile
new file mode 100644
index 000000000..607fec2c9
--- /dev/null
+++ b/test/tls/Makefile
@@ -0,0 +1,8 @@
+# uClibc TLS tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+top_builddir=../../
+top_srcdir=../../
+include ../Rules.mak
+-include Makefile.in
+include ../Test.mak
diff --git a/test/tls/Makefile.in b/test/tls/Makefile.in
new file mode 100644
index 000000000..6e193a996
--- /dev/null
+++ b/test/tls/Makefile.in
@@ -0,0 +1,150 @@
+# uClibc TLS tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+TESTS := tst-tls1 tst-tls2 tst-tls3 tst-tls4 tst-tls5 tst-tls6 tst-tls7 \
+ tst-tls8 tst-tls9 tst-tls10 tst-tls11 tst-tls12 tst-tls13 \
+ tst-tls14 tst-tls15 tst-tls16 tst-tls17 tst-tls18 tst-tls-at-ctor \
+ tst-tls1-static tst-tls2-static tst-tls9-static
+TESTS_DISABLED := tst-tls1-static tst-tls2-static tst-tls9-static
+
+# test always fails for every architecture,
+# guessing some unimplemented check or feature
+TESTS_DISABLED += tst-tls16
+
+#all these tests require shared libraries
+ifeq ($(HAVE_SHARED),)
+TESTS_DISABLED := $(TESTS)
+endif
+
+# All these tests need tls.h, which is not installed with glibc
+GLIBC_TESTS_DISABLED := $(addsuffix _glibc,$(filter-out $(TESTS_DISABLED),$(TESTS)))
+
+
+PTDIR := $(top_builddir)libpthread/nptl
+SYSDEPS_DIR := $(top_srcdir)libc/sysdeps
+
+EXTRA_CFLAGS := -DNOT_IN_libc=1 \
+ -std=gnu99 -I. \
+ -I$(SYSDEPS_DIR)/linux \
+ -I$(SYSDEPS_DIR)/linux/$(TARGET_ARCH) \
+ -I$(PTDIR) \
+ -I$(PTDIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH) \
+ -I$(PTDIR)/sysdeps/$(TARGET_ARCH) \
+ -I$(PTDIR)/sysdeps/unix/sysv/linux \
+ -I$(PTDIR)/sysdeps/pthread \
+ -I$(PTDIR)/sysdeps/pthread/bits \
+ -I$(PTDIR)/sysdeps/generic \
+ -I$(top_builddir)ldso/include \
+ -I$(top_builddir)ldso/ldso/$(TARGET_ARCH) \
+ -I$(top_builddir)include \
+ -include $(top_builddir)include/libc-symbols.h
+
+tlsmod17a-suffixes := 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+tlsmod18a-suffixes := 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+CFLAGS_tst-tlsmod1.so := -fPIC -DSHARED -shared
+CFLAGS_tst-tlsmod2.so := -fPIC -DSHARED -shared
+CFLAGS_tst-tlsmod3.so := -fPIC -DSHARED -shared
+CFLAGS_tst-tlsmod4.so := -fPIC -DSHARED -shared
+CFLAGS_tst-tlsmod5.so := -fPIC -DSHARED -shared
+CFLAGS_tst-tlsmod6.so := -fPIC -DSHARED -shared
+CFLAGS_tst-tlsmod7.so := -fPIC -DSHARED -shared
+CFLAGS_tst-tlsmod8.so := -fPIC -DSHARED -shared
+CFLAGS_tst-tlsmod9.so := -fPIC -DSHARED -shared
+CFLAGS_tst-tlsmod10.so := -fPIC -DSHARED -shared
+CFLAGS_tst-tlsmod11.so := -fPIC -DSHARED -shared
+CFLAGS_tst-tlsmod12.so := -fPIC -DSHARED -shared
+CFLAGS_tst-tlsmod13.so := -fPIC -DSHARED -shared
+CFLAGS_tst-tlsmod13a.so := -fPIC -DSHARED -shared
+CFLAGS_tst-tlsmod14a.so := -fPIC -DSHARED -shared
+CFLAGS_tst-tlsmod14b.so := -fPIC -DSHARED -shared
+CFLAGS_tst-tlsmod15a.so := -fPIC -DSHARED -shared
+CFLAGS_tst-tlsmod15b.so := -fPIC -DSHARED -shared
+CFLAGS_tst-tlsmod16a.so := -fPIC -DSHARED -shared
+CFLAGS_tst-tlsmod16b.so := -fPIC -DSHARED -shared
+CFLAGS_tst-tlsmod17a.so := -fPIC -DSHARED -shared
+CFLAGS_tst-tlsmod17b.so := -fPIC -DSHARED -shared
+CFLAGS_tst-tlsmod18a.so := -fPIC -DSHARED -shared
+CFLAGS_tst-tlsmod-at-ctor.so := -fPIC -DSHARED -shared
+
+LDFLAGS_tst-tlsmod1.so := -shared -static-libgcc -L$(top_builddir)lib
+LDFLAGS_tst-tlsmod2.so := -shared -static-libgcc -L$(top_builddir)lib
+LDFLAGS_tst-tlsmod3.so := -shared -static-libgcc -L$(top_builddir)lib \
+ tst-tlsmod2.so
+LDFLAGS_tst-tlsmod4.so := -shared -static-libgcc -L$(top_builddir)lib
+LDFLAGS_tst-tlsmod5.so := -shared -static-libgcc -L$(top_builddir)lib
+LDFLAGS_tst-tlsmod6.so := -shared -static-libgcc -L$(top_builddir)lib
+LDFLAGS_tst-tlsmod7.so := -shared -static-libgcc -L$(top_builddir)lib
+LDFLAGS_tst-tlsmod8.so := -shared -static-libgcc -L$(top_builddir)lib \
+ tst-tlsmod7.so
+LDFLAGS_tst-tlsmod9.so := -shared -static-libgcc -L$(top_builddir)lib \
+ tst-tlsmod8.so
+LDFLAGS_tst-tlsmod10.so := -shared -static-libgcc -L$(top_builddir)lib \
+ tst-tlsmod9.so
+LDFLAGS_tst-tlsmod11.so := -shared -static-libgcc -L$(top_builddir)lib
+LDFLAGS_tst-tlsmod12.so := -shared -static-libgcc -L$(top_builddir)lib \
+ tst-tlsmod11.so
+LDFLAGS_tst-tlsmod13.so := -shared -static-libgcc -L$(top_builddir)lib
+LDFLAGS_tst-tlsmod13a.so := -shared -static-libgcc -L$(top_builddir)lib \
+ tst-tlsmod13.so
+LDFLAGS_tst-tlsmod14a.so := -shared -static-libgcc -L$(top_builddir)lib
+LDFLAGS_tst-tlsmod14b.so := -shared -static-libgcc -L$(top_builddir)lib
+LDFLAGS_tst-tlsmod15a.so := -shared -static-libgcc -L$(top_builddir)lib
+LDFLAGS_tst-tlsmod15b.so := -shared -static-libgcc -L$(top_builddir)lib
+LDFLAGS_tst-tlsmod16a.so := -shared -static-libgcc -L$(top_builddir)lib
+LDFLAGS_tst-tlsmod16b.so := -shared -static-libgcc -L$(top_builddir)lib
+LDFLAGS_tst-tlsmod17a.so := -shared -static-libgcc -L$(top_builddir)lib
+LDFLAGS_tst-tlsmod17b.so := -shared -static-libgcc -L$(top_builddir)lib \
+ $(patsubst %,tst-tlsmod17a%.so,$(tlsmod17a-suffixes))
+LDFLAGS_tst-tlsmod18a.so := -shared -static-libgcc -L$(top_builddir)lib
+LDFLAGS_tst-tlsmod-at-ctor.so := -shared -static-libgcc -L$(top_builddir)lib
+
+LDFLAGS_tst-tls3 := tst-tlsmod1.so tst-tlsmod4.so
+LDFLAGS_tst-tls4 := -ldl
+LDFLAGS_tst-tls5 := -ldl
+LDFLAGS_tst-tls6 := -ldl
+LDFLAGS_tst-tls7 := -ldl
+LDFLAGS_tst-tls8 := -ldl
+LDFLAGS_tst-tls9 := -ldl
+LDFLAGS_tst-tls10 := -Wl,-rpath-link=. tst-tlsmod8.so tst-tlsmod7.so
+LDFLAGS_tst-tls11 := -Wl,-rpath-link=. tst-tlsmod9.so tst-tlsmod10.so
+LDFLAGS_tst-tls12 := -Wl,-rpath-link=. tst-tlsmod11.so tst-tlsmod12.so
+LDFLAGS_tst-tls13 := -ldl -Wl,-rpath-link=.
+LDFLAGS_tst-tls14 := -ldl -Wl,-rpath-link=. tst-tlsmod14a.so
+LDFLAGS_tst-tls15 := -ldl -Wl,-rpath-link=.
+LDFLAGS_tst-tls16 := -ldl -Wl,-rpath-link=.
+LDFLAGS_tst-tls17 := -ldl -Wl,-rpath-link=.
+LDFLAGS_tst-tls18 := -ldl -Wl,-rpath-link=.
+LDFLAGS_tst-tls-at-ctor := tst-tlsmod-at-ctor.so
+
+tst-tls3: tst-tlsmod1.so tst-tlsmod4.so
+tst-tls4: tst-tlsmod2.so
+tst-tls5: tst-tlsmod2.so
+tst-tls6: tst-tlsmod2.so
+tst-tls7: tst-tlsmod2.so tst-tlsmod3.so
+tst-tls8: tst-tlsmod2.so tst-tlsmod3.so tst-tlsmod4.so
+tst-tls9: tst-tlsmod5.so tst-tlsmod6.so
+tst-tls10: tst-tlsmod7.so tst-tlsmod8.so
+tst-tls11: tst-tlsmod9.so tst-tlsmod10.so
+tst-tls12: tst-tlsmod11.so tst-tlsmod12.so
+tst-tls13: tst-tlsmod13.so tst-tlsmod13a.so
+tst-tls14: tst-tlsmod14a.so tst-tlsmod14b.so
+tst-tls15: tst-tlsmod15b.so
+tst-tls16: tst-tlsmod16a.so tst-tlsmod16b.so
+tst-tls17: tst-tlsmod17b.so
+tst-tlsmod17b.so: $(patsubst %,tst-tlsmod17a%.so,$(tlsmod17a-suffixes))
+tst-tlsmod17a%.so: tst-tlsmod17a.c
+ $(Q)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_tst-tlsmod17a.so) $< -o $@ \
+ -DN=$* -Wl,-soname,$@ $(LDFLAGS) $(EXTRA_LIBS) \
+ $(LDFLAGS_tst-tlsmod17a.so)
+tst-tls18: $(patsubst %,tst-tlsmod18a%.so,$(tlsmod18a-suffixes))
+tst-tlsmod18a%.so: tst-tlsmod18a.c
+ $(Q)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_tst-tlsmod18a.so) $< -o $@ \
+ -DN=$* -Wl,-soname,$@ $(LDFLAGS) $(EXTRA_LIBS) \
+ $(LDFLAGS_tst-tlsmod18a.so)
+tst-tls-at-ctor: tst-tlsmod-at-ctor.so
+
+ifeq ($(TARGET_ARCH),mips)
+RET_tst-tls15 := 1
+endif
+
+WRAPPER := env LD_LIBRARY_PATH="$$PWD:.:$(LD_LIBRARY_PATH)"
diff --git a/test/tls/README b/test/tls/README
new file mode 100644
index 000000000..06c9eb743
--- /dev/null
+++ b/test/tls/README
@@ -0,0 +1,8 @@
+These tests were imported from 'glibc/elf' and are responsible for testing
+the TLS functionality of the dynamic loader. The file 'tls-macros-mips.h'
+is a copy of 'glibc/sysdeps/mips/tls-macros.h'. Dependency and link orders
+are critical and should NOT be changed. Even if you think you know what
+you are doing, do not touch the Makefile without posting to the uClibc
+development mailing list.
+
+-Steve <sjhill@uclibc.org>
diff --git a/test/tls/tls-macros-arm.h b/test/tls/tls-macros-arm.h
new file mode 100644
index 000000000..13d0f9752
--- /dev/null
+++ b/test/tls/tls-macros-arm.h
@@ -0,0 +1,51 @@
+#define TLS_LE(x) \
+ ({ int *__result; \
+ void *tp = __builtin_thread_pointer (); \
+ __asm__ ("ldr %0, 1f; " \
+ "add %0, %1, %0; " \
+ "b 2f; " \
+ "1: .word " #x "(tpoff); " \
+ "2: " \
+ : "=&r" (__result) : "r" (tp)); \
+ __result; })
+
+#define TLS_IE(x) \
+ ({ int *__result; \
+ void *tp = __builtin_thread_pointer (); \
+ __asm__ ("ldr %0, 1f; " \
+ "3: ldr %0, [pc, %0];" \
+ "add %0, %1, %0; " \
+ "b 2f; " \
+ "1: .word " #x "(gottpoff) + (. - 3b - 8); " \
+ "2: " \
+ : "=&r" (__result) : "r" (tp)); \
+ __result; })
+
+#define TLS_LD(x) \
+ ({ char *__result; \
+ int __offset; \
+ extern void *__tls_get_addr (void *); \
+ __asm__ ("ldr %0, 2f; " \
+ "1: add %0, pc, %0; " \
+ "b 3f; " \
+ "2: .word " #x "(tlsldm) + (. - 1b - 8); " \
+ "3: " \
+ : "=r" (__result)); \
+ __result = (char *)__tls_get_addr (__result); \
+ __asm__ ("ldr %0, 1f; " \
+ "b 2f; " \
+ "1: .word " #x "(tlsldo); " \
+ "2: " \
+ : "=r" (__offset)); \
+ (int *) (__result + __offset); })
+
+#define TLS_GD(x) \
+ ({ int *__result; \
+ extern void *__tls_get_addr (void *); \
+ __asm__ ("ldr %0, 2f; " \
+ "1: add %0, pc, %0; " \
+ "b 3f; " \
+ "2: .word " #x "(tlsgd) + (. - 1b - 8); " \
+ "3: " \
+ : "=r" (__result)); \
+ (int *)__tls_get_addr (__result); })
diff --git a/test/tls/tls-macros-mips.h b/test/tls/tls-macros-mips.h
new file mode 100644
index 000000000..eed0938f2
--- /dev/null
+++ b/test/tls/tls-macros-mips.h
@@ -0,0 +1,64 @@
+/* Macros to support TLS testing in times of missing compiler support. */
+
+#include <sys/cdefs.h>
+#include <sys/asm.h>
+
+#define __STRING2(X) __STRING(X)
+#define ADDU __STRING2(PTR_ADDU)
+#define ADDIU __STRING2(PTR_ADDIU)
+#define LW __STRING2(PTR_L)
+
+/* Load the GOT pointer, which may not be in $28 in a non-PIC
+ (abicalls pic0) function. */
+#ifndef __PIC__
+# if _MIPS_SIM != _ABI64
+# define LOAD_GP "move %[tmp], $28\n\tla $28, __gnu_local_gp\n\t"
+# else
+# define LOAD_GP "move %[tmp], $28\n\tdla $28, __gnu_local_gp\n\t"
+# endif
+# define UNLOAD_GP "\n\tmove $28, %[tmp]"
+#else
+# define LOAD_GP
+# define UNLOAD_GP
+#endif
+
+# define TLS_GD(x) \
+ ({ void *__result, *__tmp; \
+ extern void *__tls_get_addr (void *); \
+ __asm__ (LOAD_GP ADDIU " %0, $28, %%tlsgd(" #x ")" \
+ UNLOAD_GP \
+ : "=r" (__result), [tmp] "=&r" (__tmp)); \
+ (int *)__tls_get_addr (__result); })
+# define TLS_LD(x) \
+ ({ void *__result, *__tmp; \
+ extern void *__tls_get_addr (void *); \
+ __asm__ (LOAD_GP ADDIU " %0, $28, %%tlsldm(" #x ")" \
+ UNLOAD_GP \
+ : "=r" (__result), [tmp] "=&r" (__tmp)); \
+ __result = __tls_get_addr (__result); \
+ __asm__ ("lui $3,%%dtprel_hi(" #x ")\n\t" \
+ "addiu $3,$3,%%dtprel_lo(" #x ")\n\t" \
+ ADDU " %0,%0,$3" \
+ : "+r" (__result) : : "$3"); \
+ __result; })
+# define TLS_IE(x) \
+ ({ void *__result, *__tmp; \
+ __asm__ (".set push\n\t.set mips32r2\n\t" \
+ "rdhwr\t%0,$29\n\t.set pop" \
+ : "=v" (__result)); \
+ __asm__ (LOAD_GP LW " $3,%%gottprel(" #x ")($28)\n\t" \
+ ADDU " %0,%0,$3" \
+ UNLOAD_GP \
+ : "+r" (__result), [tmp] "=&r" (__tmp) \
+ : : "$3"); \
+ __result; })
+# define TLS_LE(x) \
+ ({ void *__result; \
+ __asm__ (".set push\n\t.set mips32r2\n\t" \
+ "rdhwr\t%0,$29\n\t.set pop" \
+ : "=v" (__result)); \
+ __asm__ ("lui $3,%%tprel_hi(" #x ")\n\t" \
+ "addiu $3,$3,%%tprel_lo(" #x ")\n\t" \
+ ADDU " %0,%0,$3" \
+ : "+r" (__result) : : "$3"); \
+ __result; })
diff --git a/test/tls/tls-macros-thumb.h b/test/tls/tls-macros-thumb.h
new file mode 100644
index 000000000..dfa6582a5
--- /dev/null
+++ b/test/tls/tls-macros-thumb.h
@@ -0,0 +1,57 @@
+#define TLS_LE(x) \
+ ({ int *__result; \
+ void *tp = __builtin_thread_pointer (); \
+ __asm__ ("ldr %0, 1f; " \
+ "add %0, %1, %0; " \
+ "b 2f; " \
+ ".align 2; " \
+ "1: .word " #x "(tpoff); " \
+ "2: " \
+ : "=&r" (__result) : "r" (tp)); \
+ __result; })
+
+#define TLS_IE(x) \
+ ({ int *__result; \
+ int tmp; \
+ void *tp = __builtin_thread_pointer (); \
+ __asm__ ("ldr %0, 1f; " \
+ "adr %1, 1f; " \
+ "ldr %0, [%1, %0]; " \
+ "add %0, %2, %0; " \
+ "b 2f; " \
+ ".align 2; " \
+ "1: .word " #x "(gottpoff); " \
+ "2: " \
+ : "=&r" (__result), "=&r"(tmp) : "r" (tp)); \
+ __result; })
+
+#define TLS_LD(x) \
+ ({ char *__result; \
+ int __offset; \
+ extern void *__tls_get_addr (void *); \
+ __asm__ ("ldr %0, 2f; " \
+ ".align 2; " \
+ "1: add %0, pc, %0; " \
+ "b 3f; " \
+ "2: .word " #x "(tlsldm) + (. - 1b - 4); " \
+ "3: " \
+ : "=r" (__result)); \
+ __result = (char *)__tls_get_addr (__result); \
+ __asm__ ("ldr %0, 1f; " \
+ "b 2f; " \
+ "1: .word " #x "(tlsldo); " \
+ "2: " \
+ : "=r" (__offset)); \
+ (int *) (__result + __offset); })
+
+#define TLS_GD(x) \
+ ({ int *__result; \
+ extern void *__tls_get_addr (void *); \
+ __asm__ ("ldr %0, 2f; " \
+ ".align 2; " \
+ "1: add %0, pc, %0; " \
+ "b 3f; " \
+ "2: .word " #x "(tlsgd) + (. - 1b - 4); " \
+ "3: " \
+ : "=r" (__result)); \
+ (int *)__tls_get_addr (__result); })
diff --git a/test/tls/tls-macros.h b/test/tls/tls-macros.h
new file mode 100644
index 000000000..e4d87f26d
--- /dev/null
+++ b/test/tls/tls-macros.h
@@ -0,0 +1,1000 @@
+/* Macros to support TLS testing in times of missing compiler support. */
+
+#define COMMON_INT_DEF(x) \
+ __asm__ (".tls_common " #x ",4,4")
+/* XXX Until we get compiler support we don't need declarations. */
+#define COMMON_INT_DECL(x)
+
+/* XXX This definition will probably be machine specific, too. */
+#define VAR_INT_DEF(x) \
+ __asm__ (".section .tdata\n\t" \
+ ".globl " #x "\n" \
+ ".balign 4\n" \
+ #x ":\t.long 0\n\t" \
+ ".size " #x ",4\n\t" \
+ ".previous")
+/* XXX Until we get compiler support we don't need declarations. */
+#define VAR_INT_DECL(x)
+
+#ifdef __mips__
+#include <tls-macros-mips.h>
+#endif
+
+#ifdef __arm__
+#ifdef __thumb__
+#include <tls-macros-thumb.h>
+#else
+#include <tls-macros-arm.h>
+#endif
+#endif
+
+ /* XXX Each architecture must have its own asm for now. */
+#ifdef __i386__
+# define TLS_LE(x) \
+ ({ int *__l; \
+ __asm__ ("movl %%gs:0,%0\n\t" \
+ "subl $" #x "@tpoff,%0" \
+ : "=r" (__l)); \
+ __l; })
+
+# ifdef __PIC__
+# define TLS_IE(x) \
+ ({ int *__l; \
+ __asm__ ("movl %%gs:0,%0\n\t" \
+ "subl " #x "@gottpoff(%%ebx),%0" \
+ : "=r" (__l)); \
+ __l; })
+# else
+# define TLS_IE(x) \
+ ({ int *__l; \
+ __asm__ ("call 1f\n\t" \
+ ".subsection 1\n" \
+ "1:\tmovl (%%esp), %%ebx\n\t" \
+ "ret\n\t" \
+ ".previous\n\t" \
+ "addl $_GLOBAL_OFFSET_TABLE_, %%ebx\n\t" \
+ "movl %%gs:0,%0\n\t" \
+ "subl " #x "@gottpoff(%%ebx),%0" \
+ : "=r" (__l)); \
+ __l; })
+# endif
+
+# ifdef __PIC__
+# define TLS_LD(x) \
+ ({ int *__l, __c, __d; \
+ __asm__ ("leal " #x "@tlsldm(%%ebx),%%eax\n\t" \
+ "call ___tls_get_addr@plt\n\t" \
+ "leal " #x "@dtpoff(%%eax), %%eax" \
+ : "=a" (__l), "=&c" (__c), "=&d" (__d)); \
+ __l; })
+# else
+# define TLS_LD(x) \
+ ({ int *__l, __b, __c, __d; \
+ __asm__ ("call 1f\n\t" \
+ ".subsection 1\n" \
+ "1:\tmovl (%%esp), %%ebx\n\t" \
+ "ret\n\t" \
+ ".previous\n\t" \
+ "addl $_GLOBAL_OFFSET_TABLE_, %%ebx\n\t" \
+ "leal " #x "@tlsldm(%%ebx),%%eax\n\t" \
+ "call ___tls_get_addr@plt\n\t" \
+ "leal " #x "@dtpoff(%%eax), %%eax" \
+ : "=a" (__l), "=&b" (__b), "=&c" (__c), "=&d" (__d)); \
+ __l; })
+# endif
+
+# ifdef __PIC__
+# define TLS_GD(x) \
+ ({ int *__l, __c, __d; \
+ __asm__ ("leal " #x "@tlsgd(%%ebx),%%eax\n\t" \
+ "call ___tls_get_addr@plt\n\t" \
+ "nop" \
+ : "=a" (__l), "=&c" (__c), "=&d" (__d)); \
+ __l; })
+# else
+# define TLS_GD(x) \
+ ({ int *__l, __c, __d; \
+ __asm__ ("call 1f\n\t" \
+ ".subsection 1\n" \
+ "1:\tmovl (%%esp), %%ebx\n\t" \
+ "ret\n\t" \
+ ".previous\n\t" \
+ "addl $_GLOBAL_OFFSET_TABLE_, %%ebx\n\t" \
+ "leal " #x "@tlsgd(%%ebx),%%eax\n\t" \
+ "call ___tls_get_addr@plt\n\t" \
+ "nop" \
+ : "=a" (__l), "=&c" (__c), "=&d" (__d)); \
+ __l; })
+# endif
+
+#elif defined __x86_64__
+
+# define TLS_LE(x) \
+ ({ int *__l; \
+ __asm__ ("mov %%fs:0,%0\n\t" \
+ "lea " #x "@tpoff(%0), %0" \
+ : "=r" (__l)); \
+ __l; })
+
+# define TLS_IE(x) \
+ ({ int *__l; \
+ __asm__ ("mov %%fs:0,%0\n\t" \
+ "add " #x "@gottpoff(%%rip),%0" \
+ : "=r" (__l)); \
+ __l; })
+
+# define TLS_LD(x) \
+ ({ int *__l, __c, __d; \
+ __asm__ ("leaq " #x "@tlsld(%%rip),%%rdi\n\t" \
+ "call __tls_get_addr@plt\n\t" \
+ "leaq " #x "@dtpoff(%%rax), %%rax" \
+ : "=a" (__l), "=&c" (__c), "=&d" (__d) \
+ : : "rdi", "rsi", "r8", "r9", "r10", "r11"); \
+ __l; })
+
+# ifdef __ILP32__
+# define TLS_GD_PREFIX
+# else
+# define TLS_GD_PREFIX ".byte 0x66\n\t"
+# endif
+
+# define TLS_GD(x) \
+ ({ int *__l, __c, __d; \
+ __asm__ (TLS_GD_PREFIX \
+ "leaq " #x "@tlsgd(%%rip),%%rdi\n\t" \
+ ".word 0x6666\n\t" \
+ "rex64\n\t" \
+ "call __tls_get_addr@plt" \
+ : "=a" (__l), "=&c" (__c), "=&d" (__d) \
+ : : "rdi", "rsi", "r8", "r9", "r10", "r11"); \
+ __l; })
+
+#elif defined __sh__
+
+# define TLS_LE(x) \
+ ({ int *__l; void *__tp; \
+ __asm__ ("stc gbr,%1\n\t" \
+ "mov.l 1f,%0\n\t" \
+ "bra 2f\n\t" \
+ " add %1,%0\n\t" \
+ ".align 2\n\t" \
+ "1: .long " #x "@tpoff\n\t" \
+ "2:" \
+ : "=r" (__l), "=r" (__tp)); \
+ __l; })
+
+# ifdef __PIC__
+# define TLS_IE(x) \
+ ({ int *__l; void *__tp; \
+ register void *__gp __asm__("r12"); \
+ __asm__ ("mov.l 1f,r0\n\t" \
+ "stc gbr,%1\n\t" \
+ "mov.l @(r0,r12),%0\n\t" \
+ "bra 2f\n\t" \
+ " add %1,%0\n\t" \
+ ".align 2\n\t" \
+ "1: .long " #x "@gottpoff\n\t" \
+ "2:" \
+ : "=r" (__l), "=r" (__tp) : "r" (__gp) : "r0"); \
+ __l; })
+# else
+# define TLS_IE(x) \
+ ({ int *__l; void *__tp; \
+ __asm__ ("mov.l r12,@-r15\n\t" \
+ "mova 0f,r0\n\t" \
+ "mov.l 0f,r12\n\t" \
+ "add r0,r12\n\t" \
+ "mov.l 1f,r0\n\t" \
+ "stc gbr,%1\n\t" \
+ "mov.l @(r0,r12),%0\n\t" \
+ "bra 2f\n\t" \
+ " add %1,%0\n\t" \
+ ".align 2\n\t" \
+ "1: .long " #x "@gottpoff\n\t" \
+ "0: .long _GLOBAL_OFFSET_TABLE_\n\t" \
+ "2: mov.l @r15+,r12" \
+ : "=r" (__l), "=r" (__tp) : : "r0"); \
+ __l; })
+#endif
+
+# ifdef __PIC__
+# define TLS_LD(x) \
+ ({ int *__l; \
+ register void *__gp __asm__("r12"); \
+ __asm__ ("mov.l 1f,r4\n\t" \
+ "mova 2f,r0\n\t" \
+ "mov.l 2f,r1\n\t" \
+ "add r0,r1\n\t" \
+ "jsr @r1\n\t" \
+ " add r12,r4\n\t" \
+ "bra 4f\n\t" \
+ " nop\n\t" \
+ ".align 2\n\t" \
+ "1: .long " #x "@tlsldm\n\t" \
+ "2: .long __tls_get_addr@plt\n\t" \
+ "4: mov.l 3f,%0\n\t" \
+ "bra 5f\n\t" \
+ " add r0,%0\n\t" \
+ ".align 2\n\t" \
+ "3: .long " #x "@dtpoff\n\t" \
+ "5:" \
+ : "=r" (__l) : "r" (__gp) : "r0", "r1", "r2", "r3", "r4", "r5", \
+ "r6", "r7", "pr", "t"); \
+ __l; })
+# else
+# define TLS_LD(x) \
+ ({ int *__l; \
+ __asm__ ("mov.l r12,@-r15\n\t" \
+ "mova 0f,r0\n\t" \
+ "mov.l 0f,r12\n\t" \
+ "add r0,r12\n\t" \
+ "mov.l 1f,r4\n\t" \
+ "mova 2f,r0\n\t" \
+ "mov.l 2f,r1\n\t" \
+ "add r0,r1\n\t" \
+ "jsr @r1\n\t" \
+ " add r12,r4\n\t" \
+ "bra 4f\n\t" \
+ " nop\n\t" \
+ ".align 2\n\t" \
+ "1: .long " #x "@tlsldm\n\t" \
+ "2: .long __tls_get_addr@plt\n\t" \
+ "0: .long _GLOBAL_OFFSET_TABLE_\n\t" \
+ "4: mov.l 3f,%0\n\t" \
+ "bra 5f\n\t" \
+ " add r0,%0\n\t" \
+ ".align 2\n\t" \
+ "3: .long " #x "@dtpoff\n\t" \
+ "5: mov.l @r15+,r12" \
+ : "=r" (__l) : : "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
+ "pr", "t"); \
+ __l; })
+#endif
+
+# ifdef __PIC__
+# define TLS_GD(x) \
+ ({ int *__l; \
+ register void *__gp __asm__("r12"); \
+ __asm__ ("mov.l 1f,r4\n\t" \
+ "mova 2f,r0\n\t" \
+ "mov.l 2f,r1\n\t" \
+ "add r0,r1\n\t" \
+ "jsr @r1\n\t" \
+ " add r12,r4\n\t" \
+ "bra 3f\n\t" \
+ " mov r0,%0\n\t" \
+ ".align 2\n\t" \
+ "1: .long " #x "@tlsgd\n\t" \
+ "2: .long __tls_get_addr@plt\n\t" \
+ "3:" \
+ : "=r" (__l) : "r" (__gp) : "r0", "r1", "r2", "r3", "r4", "r5", \
+ "r6", "r7", "pr", "t"); \
+ __l; })
+# else
+# define TLS_GD(x) \
+ ({ int *__l; \
+ __asm__ ("mov.l r12,@-r15\n\t" \
+ "mova 0f,r0\n\t" \
+ "mov.l 0f,r12\n\t" \
+ "add r0,r12\n\t" \
+ "mov.l 1f,r4\n\t" \
+ "mova 2f,r0\n\t" \
+ "mov.l 2f,r1\n\t" \
+ "add r0,r1\n\t" \
+ "jsr @r1\n\t" \
+ " add r12,r4\n\t" \
+ "bra 3f\n\t" \
+ " mov r0,%0\n\t" \
+ ".align 2\n\t" \
+ "1: .long " #x "@tlsgd\n\t" \
+ "2: .long __tls_get_addr@plt\n\t" \
+ "0: .long _GLOBAL_OFFSET_TABLE_\n\t" \
+ "3: mov.l @r15+,r12" \
+ : "=r" (__l) : : "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
+ "pr", "t"); \
+ __l; })
+#endif
+
+#elif defined __alpha__
+
+register void *__gp __asm__("$29");
+
+# define TLS_LE(x) \
+ ({ int *__l; \
+ __asm__ ("call_pal 158\n\tlda $0," #x "($0)\t\t!tprel" : "=v"(__l)); \
+ __l; })
+
+# define TLS_IE(x) \
+ ({ char *__tp; unsigned long __o; \
+ __asm__ ("call_pal 158\n\tldq %1," #x "($gp)\t\t!gottprel" \
+ : "=v"(__tp), "=r"(__o) : "r"(__gp)); \
+ (int *)(__tp + __o); })
+
+# define TLS_LD(x) \
+ ({ extern void *__tls_get_addr(void *); int *__l; void *__i; \
+ __asm__ ("lda %0," #x "($gp)\t\t!tlsldm" : "=r" (__i) : "r"(__gp)); \
+ __i = __tls_get_addr(__i); \
+ __asm__ ("lda %0, " #x "(%1)\t\t!dtprel" : "=r"(__l) : "r"(__i)); \
+ __l; })
+
+# define TLS_GD(x) \
+ ({ extern void *__tls_get_addr(void *); void *__i; \
+ __asm__ ("lda %0," #x "($gp)\t\t!tlsgd" : "=r" (__i) : "r"(__gp)); \
+ (int *) __tls_get_addr(__i); })
+
+
+#elif defined __ia64__
+
+# define TLS_LE(x) \
+ ({ void *__l; \
+ __asm__ ("mov r2=r13\n\t" \
+ ";;\n\t" \
+ "addl %0=@tprel(" #x "),r2\n\t" \
+ : "=r" (__l) : : "r2" ); __l; })
+
+# define TLS_IE(x) \
+ ({ void *__l; \
+ register long __gp __asm__ ("gp"); \
+ __asm__ (";;\n\t" \
+ "addl r16=@ltoff(@tprel(" #x ")),gp\n\t" \
+ ";;\n\t" \
+ "ld8 r17=[r16]\n\t" \
+ ";;\n\t" \
+ "add %0=r13,r17\n\t" \
+ ";;\n\t" \
+ : "=r" (__l) : "r" (__gp) : "r16", "r17" ); __l; })
+
+# define __TLS_CALL_CLOBBERS \
+ "r2", "r3", "r8", "r9", "r10", "r11", "r14", "r15", "r16", "r17", \
+ "r18", "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26", \
+ "r27", "r28", "r29", "r30", "r31", \
+ "p6", "p7", "p8", "p9", "p10", "p11", "p12", "p13", "p14", "p15", \
+ "f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
+ "b6", "b7", \
+ "out0", "out1", "out2", "out3", "out4", "out5", "out6", "out7"
+
+# define TLS_LD(x) \
+ ({ void *__l; \
+ register long __gp __asm__ ("gp"); \
+ __asm__ (";;\n\t" \
+ "mov loc0=gp\n\t" \
+ "addl r16=@ltoff(@dtpmod(" #x ")),gp\n\t" \
+ "addl out1=@dtprel(" #x "),r0\n\t" \
+ ";;\n\t" \
+ "ld8 out0=[r16]\n\t" \
+ "br.call.sptk.many b0=__tls_get_addr" \
+ ";;\n\t" \
+ "mov gp=loc0\n\t" \
+ "mov %0=r8\n\t" \
+ ";;\n\t" \
+ : "=r" (__l) : "r" (__gp) : "loc0", __TLS_CALL_CLOBBERS); \
+ __l; })
+
+# define TLS_GD(x) \
+ ({ void *__l; \
+ register long __gp __asm__ ("gp"); \
+ __asm__ (";;\n\t" \
+ "mov loc0=gp\n\t" \
+ "addl r16=@ltoff(@dtpmod(" #x ")),gp\n\t" \
+ "addl r17=@ltoff(@dtprel(" #x ")),gp\n\t" \
+ ";;\n\t" \
+ "ld8 out0=[r16]\n\t" \
+ "ld8 out1=[r17]\n\t" \
+ "br.call.sptk.many b0=__tls_get_addr" \
+ ";;\n\t" \
+ "mov gp=loc0\n\t" \
+ "mov %0=r8\n\t" \
+ ";;\n\t" \
+ : "=r" (__l) : "r" (__gp) : "loc0", __TLS_CALL_CLOBBERS); \
+ __l; })
+
+#elif defined __sparc__ && !defined __arch64__
+
+# define TLS_LE(x) \
+ ({ int *__l; \
+ __asm__ ("sethi %%tle_hix22(" #x "), %0" : "=r" (__l)); \
+ __asm__ ("xor %1, %%tle_lox10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
+ __asm__ ("add %%g7, %1, %0" : "=r" (__l) : "r" (__l)); \
+ __l; })
+
+# ifdef __PIC__
+# define TLS_LOAD_PIC \
+ ({ register long pc __asm__ ("%o7"); \
+ long got; \
+ __asm__ ("sethi %%hi(_GLOBAL_OFFSET_TABLE_-4), %1\n\t" \
+ "call .+8\n\t" \
+ "add %1, %%lo(_GLOBAL_OFFSET_TABLE_+4), %1\n\t" \
+ "add %1, %0, %1\n\t" \
+ : "=r" (pc), "=r" (got)); \
+ got; })
+# else
+# define TLS_LOAD_PIC \
+ ({ long got; \
+ __asm__ (".hidden _GLOBAL_OFFSET_TABLE_\n\t" \
+ "sethi %%hi(_GLOBAL_OFFSET_TABLE_), %0\n\t" \
+ "or %0, %%lo(_GLOBAL_OFFSET_TABLE_), %0" \
+ : "=r" (got)); \
+ got; })
+# endif
+
+# define TLS_IE(x) \
+ ({ int *__l; \
+ __asm__ ("sethi %%tie_hi22(" #x "), %0" : "=r" (__l)); \
+ __asm__ ("add %1, %%tie_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
+ __asm__ ("ld [%1 + %2], %0, %%tie_ld(" #x ")" \
+ : "=r" (__l) : "r" (TLS_LOAD_PIC), "r" (__l)); \
+ __asm__ ("add %%g7, %1, %0, %%tie_add(" #x ")" : "=r" (__l) : "r" (__l)); \
+ __l; })
+
+# define TLS_LD(x) \
+ ({ int *__l; register void *__o0 __asm__ ("%o0"); \
+ long __o; \
+ __asm__ ("sethi %%tldm_hi22(" #x "), %0" : "=r" (__l)); \
+ __asm__ ("add %1, %%tldm_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
+ __asm__ ("add %1, %2, %0, %%tldm_add(" #x ")" \
+ : "=r" (__o0) : "r" (TLS_LOAD_PIC), "r" (__l)); \
+ __asm__ ("call __tls_get_addr, %%tgd_call(" #x ")\n\t" \
+ " nop" \
+ : "=r" (__o0) : "0" (__o0) \
+ : "g1", "g2", "g3", "g4", "g5", "g6", "o1", "o2", "o3", "o4", \
+ "o5", "o7", "cc"); \
+ __asm__ ("sethi %%tldo_hix22(" #x "), %0" : "=r" (__o)); \
+ __asm__ ("xor %1, %%tldo_lox10(" #x "), %0" : "=r" (__o) : "r" (__o)); \
+ __asm__ ("add %1, %2, %0, %%tldo_add(" #x ")" : "=r" (__l) \
+ : "r" (__o0), "r" (__o)); \
+ __l; })
+
+# define TLS_GD(x) \
+ ({ int *__l; register void *__o0 __asm__ ("%o0"); \
+ __asm__ ("sethi %%tgd_hi22(" #x "), %0" : "=r" (__l)); \
+ __asm__ ("add %1, %%tgd_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
+ __asm__ ("add %1, %2, %0, %%tgd_add(" #x ")" \
+ : "=r" (__o0) : "r" (TLS_LOAD_PIC), "r" (__l)); \
+ __asm__ ("call __tls_get_addr, %%tgd_call(" #x ")\n\t" \
+ " nop" \
+ : "=r" (__o0) : "0" (__o0) \
+ : "g1", "g2", "g3", "g4", "g5", "g6", "o1", "o2", "o3", "o4", \
+ "o5", "o7", "cc"); \
+ __o0; })
+
+#elif defined __sparc__ && defined __arch64__
+
+# define TLS_LE(x) \
+ ({ int *__l; \
+ __asm__ ("sethi %%tle_hix22(" #x "), %0" : "=r" (__l)); \
+ __asm__ ("xor %1, %%tle_lox10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
+ __asm__ ("add %%g7, %1, %0" : "=r" (__l) : "r" (__l)); \
+ __l; })
+
+# ifdef __PIC__
+# define TLS_LOAD_PIC \
+ ({ long pc, got; \
+ __asm__ ("sethi %%hi(_GLOBAL_OFFSET_TABLE_-4), %1\n\t" \
+ "rd %%pc, %0\n\t" \
+ "add %1, %%lo(_GLOBAL_OFFSET_TABLE_+4), %1\n\t" \
+ "add %1, %0, %1\n\t" \
+ : "=r" (pc), "=r" (got)); \
+ got; })
+# else
+# define TLS_LOAD_PIC \
+ ({ long got; \
+ __asm__ (".hidden _GLOBAL_OFFSET_TABLE_\n\t" \
+ "sethi %%hi(_GLOBAL_OFFSET_TABLE_), %0\n\t" \
+ "or %0, %%lo(_GLOBAL_OFFSET_TABLE_), %0" \
+ : "=r" (got)); \
+ got; })
+# endif
+
+# define TLS_IE(x) \
+ ({ int *__l; \
+ __asm__ ("sethi %%tie_hi22(" #x "), %0" : "=r" (__l)); \
+ __asm__ ("add %1, %%tie_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
+ __asm__ ("ldx [%1 + %2], %0, %%tie_ldx(" #x ")" \
+ : "=r" (__l) : "r" (TLS_LOAD_PIC), "r" (__l)); \
+ __asm__ ("add %%g7, %1, %0, %%tie_add(" #x ")" : "=r" (__l) : "r" (__l)); \
+ __l; })
+
+# define TLS_LD(x) \
+ ({ int *__l; register void *__o0 __asm__ ("%o0"); \
+ long __o; \
+ __asm__ ("sethi %%tldm_hi22(" #x "), %0" : "=r" (__l)); \
+ __asm__ ("add %1, %%tldm_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
+ __asm__ ("add %1, %2, %0, %%tldm_add(" #x ")" \
+ : "=r" (__o0) : "r" (TLS_LOAD_PIC), "r" (__l)); \
+ __asm__ ("call __tls_get_addr, %%tgd_call(" #x ")\n\t" \
+ " nop" \
+ : "=r" (__o0) : "0" (__o0) \
+ : "g1", "g2", "g3", "g4", "g5", "g6", "o1", "o2", "o3", "o4", \
+ "o5", "o7", "cc"); \
+ __asm__ ("sethi %%tldo_hix22(" #x "), %0" : "=r" (__o)); \
+ __asm__ ("xor %1, %%tldo_lox10(" #x "), %0" : "=r" (__o) : "r" (__o)); \
+ __asm__ ("add %1, %2, %0, %%tldo_add(" #x ")" : "=r" (__l) \
+ : "r" (__o0), "r" (__o)); \
+ __l; })
+
+# define TLS_GD(x) \
+ ({ int *__l; register void *__o0 __asm__ ("%o0"); \
+ __asm__ ("sethi %%tgd_hi22(" #x "), %0" : "=r" (__l)); \
+ __asm__ ("add %1, %%tgd_lo10(" #x "), %0" : "=r" (__l) : "r" (__l)); \
+ __asm__ ("add %1, %2, %0, %%tgd_add(" #x ")" \
+ : "=r" (__o0) : "r" (TLS_LOAD_PIC), "r" (__l)); \
+ __asm__ ("call __tls_get_addr, %%tgd_call(" #x ")\n\t" \
+ " nop" \
+ : "=r" (__o0) : "0" (__o0) \
+ : "g1", "g2", "g3", "g4", "g5", "g6", "o1", "o2", "o3", "o4", \
+ "o5", "o7", "cc"); \
+ __o0; })
+
+#elif defined __s390x__
+
+# define TLS_LE(x) \
+ ({ unsigned long __offset; \
+ __asm__ ("bras %0,1f\n" \
+ "0:\t.quad " #x "@ntpoff\n" \
+ "1:\tlg %0,0(%0)" \
+ : "=a" (__offset) : : "cc" ); \
+ (int *) (__builtin_thread_pointer() + __offset); })
+
+# ifdef __PIC__
+# define TLS_IE(x) \
+ ({ unsigned long __offset; \
+ __asm__ ("bras %0,1f\n" \
+ "0:\t.quad " #x "@gotntpoff\n" \
+ "1:\tlg %0,0(%0)\n\t" \
+ "lg %0,0(%0,%%r12):tls_load:" #x \
+ : "=&a" (__offset) : : "cc" ); \
+ (int *) (__builtin_thread_pointer() + __offset); })
+# else
+# define TLS_IE(x) \
+ ({ unsigned long __offset; \
+ __asm__ ("bras %0,1f\n" \
+ "0:\t.quad " #x "@indntpoff\n" \
+ "1:\t lg %0,0(%0)\n\t" \
+ "lg %0,0(%0):tls_load:" #x \
+ : "=&a" (__offset) : : "cc" ); \
+ (int *) (__builtin_thread_pointer() + __offset); })
+# endif
+
+# ifdef __PIC__
+# define TLS_LD(x) \
+ ({ unsigned long __offset, __save12; \
+ __asm__ ("bras %0,1f\n" \
+ "0:\t.quad " #x "@tlsldm\n\t" \
+ ".quad " #x "@dtpoff\n" \
+ "1:\tlgr %1,%%r12\n\t" \
+ "larl %%r12,_GLOBAL_OFFSET_TABLE_\n\t" \
+ "lg %%r2,0(%0)\n\t" \
+ "brasl %%r14,__tls_get_offset@plt:tls_ldcall:" #x "\n\t" \
+ "lg %0,8(%0)\n\t" \
+ "algr %0,%%r2\n\t" \
+ "lgr %%r12,%1" \
+ : "=&a" (__offset), "=&a" (__save12) \
+ : : "cc", "0", "1", "2", "3", "4", "5", "14" ); \
+ (int *) (__builtin_thread_pointer() + __offset); })
+# else
+# define TLS_LD(x) \
+ ({ unsigned long __offset; \
+ __asm__ ("bras %0,1f\n" \
+ "0:\t.quad " #x "@tlsldm\n\t" \
+ ".quad " #x "@dtpoff\n" \
+ "1:\tlarl %%r12,_GLOBAL_OFFSET_TABLE_\n\t" \
+ "lg %%r2,0(%0)\n\t" \
+ "brasl %%r14,__tls_get_offset@plt:tls_ldcall:" #x "\n\t" \
+ "lg %0,8(%0)\n\t" \
+ "algr %0,%%r2" \
+ : "=&a" (__offset) \
+ : : "cc", "0", "1", "2", "3", "4", "5", "12", "14" ); \
+ (int *) (__builtin_thread_pointer() + __offset); })
+# endif
+
+# ifdef __PIC__
+# define TLS_GD(x) \
+ ({ unsigned long __offset, __save12; \
+ __asm__ ("bras %0,1f\n" \
+ "0:\t.quad " #x "@tlsgd\n" \
+ "1:\tlgr %1,%%r12\n\t" \
+ "larl %%r12,_GLOBAL_OFFSET_TABLE_\n\t" \
+ "lg %%r2,0(%0)\n\t" \
+ "brasl %%r14,__tls_get_offset@plt:tls_gdcall:" #x "\n\t" \
+ "lgr %0,%%r2\n\t" \
+ "lgr %%r12,%1" \
+ : "=&a" (__offset), "=&a" (__save12) \
+ : : "cc", "0", "1", "2", "3", "4", "5", "14" ); \
+ (int *) (__builtin_thread_pointer() + __offset); })
+# else
+# define TLS_GD(x) \
+ ({ unsigned long __offset; \
+ __asm__ ("bras %0,1f\n" \
+ "0:\t.quad " #x "@tlsgd\n" \
+ "1:\tlarl %%r12,_GLOBAL_OFFSET_TABLE_\n\t" \
+ "lg %%r2,0(%0)\n\t" \
+ "brasl %%r14,__tls_get_offset@plt:tls_gdcall:" #x "\n\t" \
+ "lgr %0,%%r2" \
+ : "=&a" (__offset) \
+ : : "cc", "0", "1", "2", "3", "4", "5", "12", "14" ); \
+ (int *) (__builtin_thread_pointer() + __offset); })
+# endif
+
+#elif defined __s390__
+
+# define TLS_LE(x) \
+ ({ unsigned long __offset; \
+ __asm__ ("bras %0,1f\n" \
+ "0:\t.long " #x "@ntpoff\n" \
+ "1:\tl %0,0(%0)" \
+ : "=a" (__offset) : : "cc" ); \
+ (int *) (__builtin_thread_pointer() + __offset); })
+
+# ifdef __PIC__
+# define TLS_IE(x) \
+ ({ unsigned long __offset; \
+ __asm__ ("bras %0,1f\n" \
+ "0:\t.long " #x "@gotntpoff\n" \
+ "1:\tl %0,0(%0)\n\t" \
+ "l %0,0(%0,%%r12):tls_load:" #x \
+ : "=&a" (__offset) : : "cc" ); \
+ (int *) (__builtin_thread_pointer() + __offset); })
+# else
+# define TLS_IE(x) \
+ ({ unsigned long __offset; \
+ __asm__ ("bras %0,1f\n" \
+ "0:\t.long " #x "@indntpoff\n" \
+ "1:\t l %0,0(%0)\n\t" \
+ "l %0,0(%0):tls_load:" #x \
+ : "=&a" (__offset) : : "cc" ); \
+ (int *) (__builtin_thread_pointer() + __offset); })
+# endif
+
+# ifdef __PIC__
+# define TLS_LD(x) \
+ ({ unsigned long __offset, __save12; \
+ __asm__ ("bras %0,1f\n" \
+ "0:\t.long _GLOBAL_OFFSET_TABLE_-0b\n\t" \
+ ".long __tls_get_offset@plt-0b\n\t" \
+ ".long " #x "@tlsldm\n\t" \
+ ".long " #x "@dtpoff\n" \
+ "1:\tlr %1,%%r12\n\t" \
+ "l %%r12,0(%0)\n\t" \
+ "la %%r12,0(%%r12,%0)\n\t" \
+ "l %%r1,4(%0)\n\t" \
+ "l %%r2,8(%0)\n\t" \
+ "bas %%r14,0(%%r1,%0):tls_ldcall:" #x "\n\t" \
+ "l %0,12(%0)\n\t" \
+ "alr %0,%%r2\n\t" \
+ "lr %%r12,%1" \
+ : "=&a" (__offset), "=&a" (__save12) \
+ : : "cc", "0", "1", "2", "3", "4", "5" ); \
+ (int *) (__builtin_thread_pointer() + __offset); })
+# else
+# define TLS_LD(x) \
+ ({ unsigned long __offset; \
+ __asm__ ("bras %0,1f\n" \
+ "0:\t.long _GLOBAL_OFFSET_TABLE_\n\t" \
+ ".long __tls_get_offset@plt\n\t" \
+ ".long " #x "@tlsldm\n\t" \
+ ".long " #x "@dtpoff\n" \
+ "1:\tl %%r12,0(%0)\n\t" \
+ "l %%r1,4(%0)\n\t" \
+ "l %%r2,8(%0)\n\t" \
+ "bas %%r14,0(%%r1):tls_ldcall:" #x "\n\t" \
+ "l %0,12(%0)\n\t" \
+ "alr %0,%%r2" \
+ : "=&a" (__offset) : : "cc", "0", "1", "2", "3", "4", "5", "12" ); \
+ (int *) (__builtin_thread_pointer() + __offset); })
+# endif
+
+# ifdef __PIC__
+# define TLS_GD(x) \
+ ({ unsigned long __offset, __save12; \
+ __asm__ ("bras %0,1f\n" \
+ "0:\t.long _GLOBAL_OFFSET_TABLE_-0b\n\t" \
+ ".long __tls_get_offset@plt-0b\n\t" \
+ ".long " #x "@tlsgd\n" \
+ "1:\tlr %1,%%r12\n\t" \
+ "l %%r12,0(%0)\n\t" \
+ "la %%r12,0(%%r12,%0)\n\t" \
+ "l %%r1,4(%0)\n\t" \
+ "l %%r2,8(%0)\n\t" \
+ "bas %%r14,0(%%r1,%0):tls_gdcall:" #x "\n\t" \
+ "lr %0,%%r2\n\t" \
+ "lr %%r12,%1" \
+ : "=&a" (__offset), "=&a" (__save12) \
+ : : "cc", "0", "1", "2", "3", "4", "5" ); \
+ (int *) (__builtin_thread_pointer() + __offset); })
+# else
+# define TLS_GD(x) \
+ ({ unsigned long __offset; \
+ __asm__ ("bras %0,1f\n" \
+ "0:\t.long _GLOBAL_OFFSET_TABLE_\n\t" \
+ ".long __tls_get_offset@plt\n\t" \
+ ".long " #x "@tlsgd\n" \
+ "1:\tl %%r12,0(%0)\n\t" \
+ "l %%r1,4(%0)\n\t" \
+ "l %%r2,8(%0)\n\t" \
+ "bas %%r14,0(%%r1):tls_gdcall:" #x "\n\t" \
+ "lr %0,%%r2" \
+ : "=&a" (__offset) : : "cc", "0", "1", "2", "3", "4", "5", "12" ); \
+ (int *) (__builtin_thread_pointer() + __offset); })
+# endif
+
+#elif defined __powerpc__ && !defined __powerpc64__
+
+/*#include "config.h"*/
+
+# define __TLS_CALL_CLOBBERS \
+ "0", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", \
+ "lr", "ctr", "cr0", "cr1", "cr5", "cr6", "cr7"
+
+/* PowerPC32 Local Exec TLS access. */
+# define TLS_LE(x) \
+ ({ int *__result; \
+ __asm__ ("addi %0,2," #x "@tprel" \
+ : "=r" (__result)); \
+ __result; })
+
+/* PowerPC32 Initial Exec TLS access. */
+# ifdef HAVE_ASM_PPC_REL16
+# define TLS_IE(x) \
+ ({ int *__result; \
+ __asm__ ("bcl 20,31,1f\n1:\t" \
+ "mflr %0\n\t" \
+ "addis %0,%0,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t" \
+ "addi %0,%0,_GLOBAL_OFFSET_TABLE_-1b@l\n\t" \
+ "lwz %0," #x "@got@tprel(%0)\n\t" \
+ "add %0,%0," #x "@tls" \
+ : "=b" (__result) : \
+ : "lr"); \
+ __result; })
+# else
+# define TLS_IE(x) \
+ ({ int *__result; \
+ __asm__ ("bl _GLOBAL_OFFSET_TABLE_@local-4\n\t" \
+ "mflr %0\n\t" \
+ "lwz %0," #x "@got@tprel(%0)\n\t" \
+ "add %0,%0," #x "@tls" \
+ : "=b" (__result) : \
+ : "lr"); \
+ __result; })
+# endif
+
+/* PowerPC32 Local Dynamic TLS access. */
+# ifdef HAVE_ASM_PPC_REL16
+# define TLS_LD(x) \
+ ({ int *__result; \
+ __asm__ ("bcl 20,31,1f\n1:\t" \
+ "mflr 3\n\t" \
+ "addis 3,3,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t" \
+ "addi 3,3,_GLOBAL_OFFSET_TABLE_-1b@l\n\t" \
+ "addi 3,3," #x "@got@tlsld\n\t" \
+ "bl __tls_get_addr@plt\n\t" \
+ "addi %0,3," #x "@dtprel" \
+ : "=r" (__result) : \
+ : __TLS_CALL_CLOBBERS); \
+ __result; })
+# else
+# define TLS_LD(x) \
+ ({ int *__result; \
+ __asm__ ("bl _GLOBAL_OFFSET_TABLE_@local-4\n\t" \
+ "mflr 3\n\t" \
+ "addi 3,3," #x "@got@tlsld\n\t" \
+ "bl __tls_get_addr@plt\n\t" \
+ "addi %0,3," #x "@dtprel" \
+ : "=r" (__result) : \
+ : __TLS_CALL_CLOBBERS); \
+ __result; })
+# endif
+
+/* PowerPC32 General Dynamic TLS access. */
+# ifdef HAVE_ASM_PPC_REL16
+# define TLS_GD(x) \
+ ({ register int *__result __asm__ ("r3"); \
+ __asm__ ("bcl 20,31,1f\n1:\t" \
+ "mflr 3\n\t" \
+ "addis 3,3,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t" \
+ "addi 3,3,_GLOBAL_OFFSET_TABLE_-1b@l\n\t" \
+ "addi 3,3," #x "@got@tlsgd\n\t" \
+ "bl __tls_get_addr@plt" \
+ : : \
+ : __TLS_CALL_CLOBBERS); \
+ __result; })
+# else
+# define TLS_GD(x) \
+ ({ register int *__result __asm__ ("r3"); \
+ __asm__ ("bl _GLOBAL_OFFSET_TABLE_@local-4\n\t" \
+ "mflr 3\n\t" \
+ "addi 3,3," #x "@got@tlsgd\n\t" \
+ "bl __tls_get_addr@plt" \
+ : : \
+ : __TLS_CALL_CLOBBERS); \
+ __result; })
+# endif
+
+#elif defined __powerpc__ && defined __powerpc64__
+
+/* PowerPC64 Local Exec TLS access. */
+# define TLS_LE(x) \
+ ({ int * __result; \
+ __asm__ ( \
+ " addis %0,13," #x "@tprel@ha\n" \
+ " addi %0,%0," #x "@tprel@l\n" \
+ : "=b" (__result) ); \
+ __result; \
+ })
+/* PowerPC64 Initial Exec TLS access. */
+# define TLS_IE(x) \
+ ({ int * __result; \
+ __asm__ ( \
+ " ld %0," #x "@got@tprel(2)\n" \
+ " add %0,%0," #x "@tls\n" \
+ : "=b" (__result) ); \
+ __result; \
+ })
+/* PowerPC64 Local Dynamic TLS access. */
+# define TLS_LD(x) \
+ ({ int * __result; \
+ __asm__ ( \
+ " addi 3,2," #x "@got@tlsld\n" \
+ " bl .__tls_get_addr\n" \
+ " nop \n" \
+ " addis %0,3," #x "@dtprel@ha\n" \
+ " addi %0,%0," #x "@dtprel@l\n" \
+ : "=b" (__result) : \
+ : "0", "3", "4", "5", "6", "7", \
+ "8", "9", "10", "11", "12", \
+ "lr", "ctr", \
+ "cr0", "cr1", "cr5", "cr6", "cr7"); \
+ __result; \
+ })
+/* PowerPC64 General Dynamic TLS access. */
+# define TLS_GD(x) \
+ ({ int * __result; \
+ __asm__ ( \
+ " addi 3,2," #x "@got@tlsgd\n" \
+ " bl .__tls_get_addr\n" \
+ " nop \n" \
+ " mr %0,3\n" \
+ : "=b" (__result) : \
+ : "0", "3", "4", "5", "6", "7", \
+ "8", "9", "10", "11", "12", \
+ "lr", "ctr", \
+ "cr0", "cr1", "cr5", "cr6", "cr7"); \
+ __result; \
+ })
+
+#elif defined __arc__
+
+/* For now */
+#define TLS_LD(x) TLS_IE(x)
+
+#define TLS_GD(x) \
+ ({ int *__result; \
+ __asm__ ("add r0, pcl, @" #x "@tlsgd \n" \
+ ".tls_gd_ld " #x "`bl __tls_get_addr@plt \n" \
+ "mov %0, r0 \n" \
+ : "=&r" (__result) \
+ ::"r0","r1","r2","r3","r4","r5","r6","r7", \
+ "r8","r9","r10","r11","r12"); \
+ __result; })
+
+#define TLS_LE(x) \
+ ({ int *__result; \
+ void *tp = __builtin_thread_pointer(); \
+ __asm__ ("add %0, %1, @" #x "@tpoff \n" \
+ : "=r" (__result) : "r"(tp)); \
+ __result; })
+
+#define TLS_IE(x) \
+ ({ int *__result; \
+ void *tp = __builtin_thread_pointer(); \
+ __asm__ ("ld %0, [pcl, @" #x "@tlsie] \n" \
+ "add %0, %1, %0 \n" \
+ : "=&r" (__result) : "r" (tp)); \
+ __result; })
+
+#elif defined __xtensa__
+
+#if defined(__XTENSA_WINDOWED_ABI__)
+#define TLS_GD(x) \
+ ({ int *__l; \
+ __asm__ ("movi a8, " #x "@TLSFUNC\n\t" \
+ "movi a10, " #x "@TLSARG\n\t" \
+ "callx8.tls a8, " #x "@TLSCALL\n\t" \
+ "mov %0, a10\n\t" \
+ : "=r" (__l) \
+ : \
+ : "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15"); \
+ __l; })
+
+#define TLS_LD(x) \
+ ({ int *__l; \
+ __asm__ ("movi a8, _TLS_MODULE_BASE_@TLSFUNC\n\t" \
+ "movi a10, _TLS_MODULE_BASE_@TLSARG\n\t" \
+ "callx8.tls a8, _TLS_MODULE_BASE_@TLSCALL\n\t" \
+ "movi %0, " #x "@TPOFF\n\t" \
+ "add %0, %0, a10\n\t" \
+ : "=r" (__l) \
+ : \
+ : "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15"); \
+ __l; })
+#elif defined(__XTENSA_CALL0_ABI__)
+#define TLS_GD(x) \
+ ({ int *__l; \
+ __asm__ ("movi a0, " #x "@TLSFUNC\n\t" \
+ "movi a2, " #x "@TLSARG\n\t" \
+ "callx0.tls a0, " #x "@TLSCALL\n\t" \
+ "mov %0, a2\n\t" \
+ : "=r" (__l) \
+ : \
+ : "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11");\
+ __l; })
+
+#define TLS_LD(x) \
+ ({ int *__l; \
+ __asm__ ("movi a0, _TLS_MODULE_BASE_@TLSFUNC\n\t" \
+ "movi a2, _TLS_MODULE_BASE_@TLSARG\n\t" \
+ "callx0.tls a0, _TLS_MODULE_BASE_@TLSCALL\n\t" \
+ "movi %0, " #x "@TPOFF\n\t" \
+ "add %0, %0, a2\n\t" \
+ : "=r" (__l) \
+ : \
+ : "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11");\
+ __l; })
+#else
+#error Unsupported Xtensa ABI
+#endif
+
+#define TLS_IE(x) TLS_LE(x)
+
+#define TLS_LE(x) \
+ ({ int *__l; \
+ int __t; \
+ __asm__ ("rur %0, threadptr\n\t" \
+ "movi %1, " #x "@TPOFF\n\t" \
+ "add %0, %0, %1\n\t" \
+ : "=r" (__l), "=r" (__t) ); \
+ __l; }); \
+
+#elif defined __metag__
+
+# define TLS_GD(x) \
+ ({ void *__result; \
+ extern void *__tls_get_addr (void *); \
+ __asm__ ("MOV %0, A1LbP\n\t" \
+ "ADD %0, %0, #(" #x "@TLSGD)" \
+ : "=d" (__result)); \
+ (int *)__tls_get_addr (__result); })
+
+# define TLS_LD(x) \
+ ({ void *__result; \
+ extern void *__tls_get_addr (void *); \
+ __asm__ ("MOV %0, A1LbP\n\t" \
+ "ADD %0, %0, #(" #x "@TLSLDM)" \
+ : "=d" (__result)); \
+ __result = __tls_get_addr (__result); \
+ __asm__ ("ADDT %0,%0,#HI(" #x "@TLSLDO)\n\t" \
+ "ADD %0,%0,#LO(" #x "@TLSLDO)" \
+ : "+d" (__result)); \
+ __result; })
+
+# define TLS_IE(x) \
+ ({ void *__result; \
+ unsigned long __rel; \
+ extern void *__metag_load_tp (void); \
+ __asm__ ("GETD %0,[A1LbP+#(" #x "@TLSIE)]" \
+ : "=d" (__rel)); \
+ __result = __metag_load_tp(); \
+ __result + __rel; })
+
+# define TLS_LE(x) \
+ ({ void *__result; \
+ extern void *__metag_load_tp (void); \
+ __result = __metag_load_tp(); \
+ __asm__ ("ADDT %0,%0,#HI(" #x "@TLSLE)\n\t" \
+ "ADD %0,%0,#LO(" #x "@TLSLE)" \
+ : "+d" (__result)); \
+ __result; })
+
+#elif !defined TLS_LE || !defined TLS_IE \
+ || !defined TLS_LD || !defined TLS_GD
+# error "No support for this architecture so far."
+#endif
diff --git a/test/tls/tst-tls-at-ctor.c b/test/tls/tst-tls-at-ctor.c
new file mode 100644
index 000000000..53aece181
--- /dev/null
+++ b/test/tls/tst-tls-at-ctor.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <tls.h>
+
+#define TLS_VAR_INIT_VALUE 99
+
+#ifdef USE_TLS
+extern __thread int tls_var;
+#endif
+
+int main(void)
+{
+ int ret = EXIT_SUCCESS;
+#ifdef USE_TLS
+ if (tls_var != TLS_VAR_INIT_VALUE) {
+ printf("tls_var = %d - Expected value = %d\n", tls_var, TLS_VAR_INIT_VALUE);
+ ret = EXIT_FAILURE;
+ }
+#endif
+ return ret;
+}
diff --git a/test/tls/tst-tls1-static.c b/test/tls/tst-tls1-static.c
new file mode 100644
index 000000000..a01008073
--- /dev/null
+++ b/test/tls/tst-tls1-static.c
@@ -0,0 +1 @@
+#include "tst-tls1.c"
diff --git a/test/tls/tst-tls1.c b/test/tls/tst-tls1.c
new file mode 100644
index 000000000..f5ac6d2bc
--- /dev/null
+++ b/test/tls/tst-tls1.c
@@ -0,0 +1,92 @@
+/* glibc test for TLS in ld.so. */
+#undef _LIBC
+#include <stdio.h>
+
+#include <tls.h>
+
+#ifdef USE_TLS
+# include "tls-macros.h"
+
+
+/* Two common 'int' variables in TLS. */
+COMMON_INT_DEF(foo);
+COMMON_INT_DEF(bar);
+#endif
+
+
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+#ifdef USE_TLS
+ int result = 0;
+ int *ap, *bp;
+
+
+ /* Set the variable using the local exec model. */
+ puts ("set bar to 1 (LE)");
+ ap = TLS_LE (bar);
+ *ap = 1;
+
+
+ /* Get variables using initial exec model. */
+ fputs ("get sum of foo and bar (IE)", stdout);
+ ap = TLS_IE (foo);
+ bp = TLS_IE (bar);
+ printf (" = %d\n", *ap + *bp);
+ result |= *ap + *bp != 1;
+ if (*ap != 0)
+ {
+ printf ("foo = %d\n", *ap);
+ result = 1;
+ }
+ if (*bp != 1)
+ {
+ printf ("bar = %d\n", *bp);
+ result = 1;
+ }
+
+
+ /* Get variables using local dynamic model. */
+ fputs ("get sum of foo and bar (LD)", stdout);
+ ap = TLS_LD (foo);
+ bp = TLS_LD (bar);
+ printf (" = %d\n", *ap + *bp);
+ result |= *ap + *bp != 1;
+ if (*ap != 0)
+ {
+ printf ("foo = %d\n", *ap);
+ result = 1;
+ }
+ if (*bp != 1)
+ {
+ printf ("bar = %d\n", *bp);
+ result = 1;
+ }
+
+
+ /* Get variables using generic dynamic model. */
+ fputs ("get sum of foo and bar (GD)", stdout);
+ ap = TLS_GD (foo);
+ bp = TLS_GD (bar);
+ printf (" = %d\n", *ap + *bp);
+ result |= *ap + *bp != 1;
+ if (*ap != 0)
+ {
+ printf ("foo = %d\n", *ap);
+ result = 1;
+ }
+ if (*bp != 1)
+ {
+ printf ("bar = %d\n", *bp);
+ result = 1;
+ }
+
+ return result;
+#else
+ return 0;
+#endif
+}
+
+
+#include "../test-skeleton.c"
diff --git a/test/tls/tst-tls10.c b/test/tls/tst-tls10.c
new file mode 100644
index 000000000..fc0677072
--- /dev/null
+++ b/test/tls/tst-tls10.c
@@ -0,0 +1,40 @@
+#include "tst-tls10.h"
+
+#ifdef USE_TLS__THREAD
+__thread int dummy __attribute__((visibility ("hidden"))) = 12;
+__thread struct A local = { 1, 2, 3 };
+#endif
+
+#define CHECK(N, S) \
+ p = f##N##a (); \
+ if (p->a != S || p->b != S + 1 || p->c != S + 2) \
+ abort ()
+
+int
+main (void)
+{
+ struct A *p;
+ if (local.a != 1 || local.b != 2 || local.c != 3)
+ abort ();
+#ifdef USE_TLS__THREAD
+ if (a1.a != 4 || a1.b != 5 || a1.c != 6)
+ abort ();
+ if (a2.a != 22 || a2.b != 23 || a2.c != 24)
+ abort ();
+ if (a3.a != 10 || a3.b != 11 || a3.c != 12)
+ abort ();
+ if (a4.a != 25 || a4.b != 26 || a4.c != 27)
+ abort ();
+ check1 ();
+ check2 ();
+ if (f1a () != &a1 || f2a () != &a2 || f3a () != &a3 || f4a () != &a4)
+ abort ();
+ CHECK (5, 16);
+ CHECK (6, 19);
+ if (f7a () != &a2 || f8a () != &a4)
+ abort ();
+ CHECK (9, 28);
+ CHECK (10, 31);
+#endif
+ exit (0);
+}
diff --git a/test/tls/tst-tls10.h b/test/tls/tst-tls10.h
new file mode 100644
index 000000000..1be6adc29
--- /dev/null
+++ b/test/tls/tst-tls10.h
@@ -0,0 +1,38 @@
+#include <tls.h>
+#include <stdlib.h>
+
+#if defined USE_TLS && defined HAVE___THREAD \
+ && defined HAVE_TLS_MODEL_ATTRIBUTE
+# define USE_TLS__THREAD
+
+struct A
+{
+ char a;
+ int b;
+ long long c;
+};
+
+extern __thread struct A a1, a2, a3, a4;
+extern struct A *f1a (void);
+extern struct A *f2a (void);
+extern struct A *f3a (void);
+extern struct A *f4a (void);
+extern struct A *f5a (void);
+extern struct A *f6a (void);
+extern struct A *f7a (void);
+extern struct A *f8a (void);
+extern struct A *f9a (void);
+extern struct A *f10a (void);
+extern int f1b (void);
+extern int f2b (void);
+extern int f3b (void);
+extern int f4b (void);
+extern int f5b (void);
+extern int f6b (void);
+extern int f7b (void);
+extern int f8b (void);
+extern int f9b (void);
+extern int f10b (void);
+extern void check1 (void);
+extern void check2 (void);
+#endif
diff --git a/test/tls/tst-tls11.c b/test/tls/tst-tls11.c
new file mode 100644
index 000000000..816cf5cc2
--- /dev/null
+++ b/test/tls/tst-tls11.c
@@ -0,0 +1,27 @@
+#include "tst-tls10.h"
+
+#define CHECK(N, S) \
+ p = f##N##a (); \
+ if (p->a != S || p->b != S + 1 || p->c != S + 2) \
+ abort ()
+
+int
+main (void)
+{
+#ifdef USE_TLS__THREAD
+ struct A *p;
+ check1 ();
+ check2 ();
+ CHECK (1, 4);
+ CHECK (2, 22);
+ CHECK (3, 10);
+ CHECK (4, 25);
+ CHECK (5, 16);
+ CHECK (6, 19);
+ CHECK (7, 22);
+ CHECK (8, 25);
+ CHECK (9, 28);
+ CHECK (10, 31);
+#endif
+ exit (0);
+}
diff --git a/test/tls/tst-tls12.c b/test/tls/tst-tls12.c
new file mode 100644
index 000000000..84aa7d35c
--- /dev/null
+++ b/test/tls/tst-tls12.c
@@ -0,0 +1,18 @@
+#include "tst-tls10.h"
+
+#define CHECK(N, S) \
+ p = &a##N; \
+ if (p->a != S || p->b != S + 1 || p->c != S + 2) \
+ abort ()
+
+int
+main (void)
+{
+#ifdef USE_TLS__THREAD
+ struct A *p;
+ check1 ();
+ CHECK (1, 4);
+ CHECK (2, 7);
+#endif
+ exit (0);
+}
diff --git a/test/tls/tst-tls13.c b/test/tls/tst-tls13.c
new file mode 100644
index 000000000..4cb74e76b
--- /dev/null
+++ b/test/tls/tst-tls13.c
@@ -0,0 +1,30 @@
+/* Check unloading modules with data in static TLS block. */
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static int
+do_test (void)
+{
+ int i;
+ for (i = 0; i < 1000;)
+ {
+ printf ("round %d\n",++i);
+
+ void *h = dlopen ("tst-tlsmod13a.so", RTLD_LAZY);
+ if (h == NULL)
+ {
+ printf ("cannot load: %s\n", dlerror ());
+ exit (1);
+ }
+
+ dlclose (h);
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#define TIMEOUT 50
+#include "../test-skeleton.c"
diff --git a/test/tls/tst-tls14.c b/test/tls/tst-tls14.c
new file mode 100644
index 000000000..428fd5293
--- /dev/null
+++ b/test/tls/tst-tls14.c
@@ -0,0 +1,66 @@
+/* Check alignment of TLS variable. */
+#include <dlfcn.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <tls.h>
+
+#if USE_TLS && HAVE___THREAD
+
+#define AL 4096
+struct foo
+{
+ int i;
+} __attribute ((aligned (AL)));
+
+static __thread struct foo f;
+static struct foo g;
+
+
+extern int in_dso1 (void);
+
+
+static int
+do_test (void)
+{
+ int result = 0;
+
+ int fail = (((uintptr_t) &f) & (AL - 1)) != 0;
+ printf ("&f = %p %s\n", &f, fail ? "FAIL" : "OK");
+ result |= fail;
+
+ fail = (((uintptr_t) &g) & (AL - 1)) != 0;
+ printf ("&g = %p %s\n", &g, fail ? "FAIL" : "OK");
+ result |= fail;
+
+ result |= in_dso1 ();
+
+ void *h = dlopen ("tst-tlsmod14b.so", RTLD_LAZY);
+ if (h == NULL)
+ {
+ printf ("cannot open tst-tlsmod14b.so: %m\n");
+ exit (1);
+ }
+
+ int (*fp) (void) = (int (*) (void)) dlsym (h, "in_dso2");
+ if (fp == NULL)
+ {
+ puts ("cannot find in_dso2");
+ exit (1);
+ }
+
+ result |= fp ();
+
+ return result;
+}
+
+#define TEST_FUNCTION do_test ()
+
+#else
+
+#define TEST_FUNCTION 0
+
+#endif
+
+#include "../test-skeleton.c"
diff --git a/test/tls/tst-tls15.c b/test/tls/tst-tls15.c
new file mode 100644
index 000000000..2c2df251b
--- /dev/null
+++ b/test/tls/tst-tls15.c
@@ -0,0 +1,33 @@
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+static int
+do_test (void)
+{
+ void *h = dlopen ("tst-tlsmod15a.so", RTLD_NOW);
+ if (h != NULL)
+ {
+ puts ("unexpectedly succeeded to open tst-tlsmod15a.so");
+ exit (1);
+ }
+
+ h = dlopen ("tst-tlsmod15b.so", RTLD_NOW);
+ if (h == NULL)
+ {
+ puts ("failed to open tst-tlsmod15b.so");
+ exit (1);
+ }
+
+ int (*fp) (void) = (int (*) (void)) dlsym (h, "in_dso");
+ if (fp == NULL)
+ {
+ puts ("cannot find in_dso");
+ exit (1);
+ }
+
+ return fp ();
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/tls/tst-tls16.c b/test/tls/tst-tls16.c
new file mode 100644
index 000000000..17912dc30
--- /dev/null
+++ b/test/tls/tst-tls16.c
@@ -0,0 +1,53 @@
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+static int
+do_test (void)
+{
+ void *h = dlopen ("tst-tlsmod16a.so", RTLD_LAZY | RTLD_GLOBAL);
+ if (h == NULL)
+ {
+ puts ("unexpectedly failed to open tst-tlsmod16a.so");
+ exit (1);
+ }
+
+ void *p = dlsym (h, "tlsvar");
+
+ /* This dlopen should indeed fail, because tlsvar was assigned to
+ dynamic TLS, and the new module requests it to be in static TLS.
+ However, there's a possibility that dlopen succeeds if the
+ variable is, for whatever reason, assigned to static TLS, or if
+ the module fails to require static TLS, or even if TLS is not
+ supported. */
+ h = dlopen ("tst-tlsmod16b.so", RTLD_NOW | RTLD_GLOBAL);
+ if (h == NULL)
+ {
+ return 0;
+ }
+
+ puts ("unexpectedly succeeded to open tst-tlsmod16b.so");
+
+
+ void *(*fp) (void) = (void *(*) (void)) dlsym (h, "in_dso");
+ if (fp == NULL)
+ {
+ puts ("cannot find in_dso");
+ exit (1);
+ }
+
+ /* If the dlopen passes, at least make sure the address returned by
+ dlsym is the same as that returned by the initial-exec access.
+ If the variable was assigned to dynamic TLS during dlsym, this
+ portion will fail. */
+ if (fp () != p)
+ {
+ puts ("returned values do not match");
+ exit (1);
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/tls/tst-tls17.c b/test/tls/tst-tls17.c
new file mode 100644
index 000000000..c1bc7d8f4
--- /dev/null
+++ b/test/tls/tst-tls17.c
@@ -0,0 +1,29 @@
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+static int
+do_test (void)
+{
+ void *h = dlopen ("tst-tlsmod17b.so", RTLD_LAZY);
+ if (h == NULL)
+ {
+ puts ("unexpectedly failed to open tst-tlsmod17b.so");
+ exit (1);
+ }
+
+ int (*fp) (void) = (int (*) (void)) dlsym (h, "tlsmod17b");
+ if (fp == NULL)
+ {
+ puts ("cannot find tlsmod17b");
+ exit (1);
+ }
+
+ if (fp ())
+ exit (1);
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/tls/tst-tls18.c b/test/tls/tst-tls18.c
new file mode 100644
index 000000000..00dcdff4e
--- /dev/null
+++ b/test/tls/tst-tls18.c
@@ -0,0 +1,38 @@
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+static int
+do_test (void)
+{
+ char modname[sizeof "tst-tlsmod18aXX.so"];
+ void *h[20];
+ for (int i = 0; i < 20; i++)
+ {
+ snprintf (modname, sizeof modname, "tst-tlsmod18a%d.so", i);
+ h[i] = dlopen (modname, RTLD_LAZY);
+ if (h[i] == NULL)
+ {
+ printf ("unexpectedly failed to open %s", modname);
+ exit (1);
+ }
+ }
+
+ for (int i = 0; i < 20; i++)
+ {
+ int (*fp) (void) = (int (*) (void)) dlsym (h[i], "test");
+ if (fp == NULL)
+ {
+ printf ("cannot find test in tst-tlsmod18a%d.so", i);
+ exit (1);
+ }
+
+ if (fp ())
+ exit (1);
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/test/tls/tst-tls2-static.c b/test/tls/tst-tls2-static.c
new file mode 100644
index 000000000..55ffa5744
--- /dev/null
+++ b/test/tls/tst-tls2-static.c
@@ -0,0 +1 @@
+#include "tst-tls2.c"
diff --git a/test/tls/tst-tls2.c b/test/tls/tst-tls2.c
new file mode 100644
index 000000000..417489968
--- /dev/null
+++ b/test/tls/tst-tls2.c
@@ -0,0 +1,91 @@
+/* glibc test for TLS in ld.so. */
+#include <stdio.h>
+
+#include <tls.h>
+
+#ifdef USE_TLS
+# include "tls-macros.h"
+
+
+/* Two 'int' variables in TLS. */
+VAR_INT_DEF(foo);
+VAR_INT_DEF(bar);
+#endif
+
+
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+#ifdef USE_TLS
+ int result = 0;
+ int *ap, *bp;
+
+
+ /* Set the variable using the local exec model. */
+ puts ("set bar to 1 (LE)");
+ ap = TLS_LE (bar);
+ *ap = 1;
+
+
+ /* Get variables using initial exec model. */
+ fputs ("get sum of foo and bar (IE)", stdout);
+ ap = TLS_IE (foo);
+ bp = TLS_IE (bar);
+ printf (" = %d\n", *ap + *bp);
+ result |= *ap + *bp != 1;
+ if (*ap != 0)
+ {
+ printf ("foo = %d\n", *ap);
+ result = 1;
+ }
+ if (*bp != 1)
+ {
+ printf ("bar = %d\n", *bp);
+ result = 1;
+ }
+
+
+ /* Get variables using local dynamic model. */
+ fputs ("get sum of foo and bar (LD)", stdout);
+ ap = TLS_LD (foo);
+ bp = TLS_LD (bar);
+ printf (" = %d\n", *ap + *bp);
+ result |= *ap + *bp != 1;
+ if (*ap != 0)
+ {
+ printf ("foo = %d\n", *ap);
+ result = 1;
+ }
+ if (*bp != 1)
+ {
+ printf ("bar = %d\n", *bp);
+ result = 1;
+ }
+
+
+ /* Get variables using generic dynamic model. */
+ fputs ("get sum of foo and bar (GD)", stdout);
+ ap = TLS_GD (foo);
+ bp = TLS_GD (bar);
+ printf (" = %d\n", *ap + *bp);
+ result |= *ap + *bp != 1;
+ if (*ap != 0)
+ {
+ printf ("foo = %d\n", *ap);
+ result = 1;
+ }
+ if (*bp != 1)
+ {
+ printf ("bar = %d\n", *bp);
+ result = 1;
+ }
+
+ return result;
+#else
+ return 0;
+#endif
+}
+
+
+#include "../test-skeleton.c"
diff --git a/test/tls/tst-tls3.c b/test/tls/tst-tls3.c
new file mode 100644
index 000000000..84be43575
--- /dev/null
+++ b/test/tls/tst-tls3.c
@@ -0,0 +1,76 @@
+/* glibc test for TLS in ld.so. */
+#include <stdio.h>
+
+#include <tls.h>
+
+#ifdef USE_TLS
+# include "tls-macros.h"
+
+
+/* One define int variable, two externs. */
+COMMON_INT_DECL(foo);
+VAR_INT_DECL(bar);
+VAR_INT_DEF(baz);
+#endif
+
+
+extern int in_dso (void);
+
+
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+#ifdef USE_TLS
+ int result = 0;
+ int *ap, *bp, *cp;
+
+
+ /* Set the variable using the local exec model. */
+ puts ("set baz to 3 (LE)");
+ ap = TLS_LE (baz);
+ *ap = 3;
+
+
+ /* Get variables using initial exec model. */
+ puts ("set variables foo and bar (IE)");
+ ap = TLS_IE (foo);
+ *ap = 1;
+ bp = TLS_IE (bar);
+ *bp = 2;
+
+
+ /* Get variables using local dynamic model. */
+ fputs ("get sum of foo, bar (GD) and baz (LD)", stdout);
+ ap = TLS_GD (foo);
+ bp = TLS_GD (bar);
+ cp = TLS_LD (baz);
+ printf (" = %d\n", *ap + *bp + *cp);
+ result |= *ap + *bp + *cp != 6;
+ if (*ap != 1)
+ {
+ printf ("foo = %d\n", *ap);
+ result = 1;
+ }
+ if (*bp != 2)
+ {
+ printf ("bar = %d\n", *bp);
+ result = 1;
+ }
+ if (*cp != 3)
+ {
+ printf ("baz = %d\n", *cp);
+ result = 1;
+ }
+
+
+ result |= in_dso ();
+
+ return result;
+#else
+ return 0;
+#endif
+}
+
+
+#include "../test-skeleton.c"
diff --git a/test/tls/tst-tls4.c b/test/tls/tst-tls4.c
new file mode 100644
index 000000000..f92ee53ce
--- /dev/null
+++ b/test/tls/tst-tls4.c
@@ -0,0 +1,56 @@
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <tls.h>
+
+
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+#ifdef USE_TLS
+ static const char modname[] = "tst-tlsmod2.so";
+ int result = 0;
+ int *foop;
+ int (*fp) (int, int *);
+ void *h;
+
+ h = dlopen (modname, RTLD_LAZY);
+ if (h == NULL)
+ {
+ printf ("cannot open '%s': %s\n", modname, dlerror ());
+ exit (1);
+ }
+
+ fp = dlsym (h, "in_dso");
+ if (fp == NULL)
+ {
+ printf ("cannot get symbol 'in_dso': %s\n", dlerror ());
+ exit (1);
+ }
+
+ result |= fp (0, NULL);
+
+ foop = dlsym (h, "foo");
+ if (foop == NULL)
+ {
+ printf ("cannot get symbol 'foo' the second time: %s\n", dlerror ());
+ exit (1);
+ }
+ if (*foop != 16)
+ {
+ puts ("foo != 16");
+ result = 1;
+ }
+
+ dlclose (h);
+
+ return result;
+#else
+ return 0;
+#endif
+}
+
+
+#include "../test-skeleton.c"
diff --git a/test/tls/tst-tls5.c b/test/tls/tst-tls5.c
new file mode 100644
index 000000000..a571d2cd3
--- /dev/null
+++ b/test/tls/tst-tls5.c
@@ -0,0 +1,72 @@
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <tls.h>
+
+
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+#ifdef USE_TLS
+ static const char modname[] = "tst-tlsmod2.so";
+ int result = 0;
+ int *foop;
+ int *foop2;
+ int (*fp) (int, int *);
+ void *h;
+
+ h = dlopen (modname, RTLD_LAZY);
+ if (h == NULL)
+ {
+ printf ("cannot open '%s': %s\n", modname, dlerror ());
+ exit (1);
+ }
+
+ foop = dlsym (h, "foo");
+ if (foop == NULL)
+ {
+ printf ("cannot get symbol 'foo': %s\n", dlerror ());
+ exit (1);
+ }
+
+ *foop = 42;
+
+ fp = dlsym (h, "in_dso");
+ if (fp == NULL)
+ {
+ printf ("cannot get symbol 'in_dso': %s\n", dlerror ());
+ exit (1);
+ }
+
+ result |= fp (42, foop);
+
+ foop2 = dlsym (h, "foo");
+ if (foop2 == NULL)
+ {
+ printf ("cannot get symbol 'foo' the second time: %s\n", dlerror ());
+ exit (1);
+ }
+
+ if (foop != foop2)
+ {
+ puts ("address of 'foo' different the second time");
+ result = 1;
+ }
+ else if (*foop != 16)
+ {
+ puts ("foo != 16");
+ result = 1;
+ }
+
+ dlclose (h);
+
+ return result;
+#else
+ return 0;
+#endif
+}
+
+
+#include "../test-skeleton.c"
diff --git a/test/tls/tst-tls6.c b/test/tls/tst-tls6.c
new file mode 100644
index 000000000..0ebc50737
--- /dev/null
+++ b/test/tls/tst-tls6.c
@@ -0,0 +1,107 @@
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <tls.h>
+#include <link.h>
+#ifdef __UCLIBC__
+#include "dl-elf.h"
+#include "dl-hash.h"
+#endif
+
+
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+#ifdef USE_TLS
+ static const char modname[] = "tst-tlsmod2.so";
+ int result = 0;
+ int *foop;
+ int *foop2;
+ int (*fp) (int, int *);
+ void *h;
+ int i;
+ int modid = -1;
+
+ for (i = 0; i < 10; ++i)
+ {
+ h = dlopen (modname, RTLD_LAZY);
+ if (h == NULL)
+ {
+ printf ("cannot open '%s': %s\n", modname, dlerror ());
+ exit (1);
+ }
+
+ /* Dirty test code here: we peek into a private data structure.
+ We make sure that the module gets assigned the same ID every
+ time. The value of the first round is used. */
+#ifdef __UCLIBC__
+ if (modid == -1)
+ modid = ((struct dyn_elf *) h)->dyn->l_tls_modid;
+ else if (((struct dyn_elf *)h)->dyn->l_tls_modid != (size_t) modid)
+ {
+ printf ("round %d: modid now %zu, initially %d\n",
+ i,
+ ((struct dyn_elf *)h)->dyn->l_tls_modid,
+ modid);
+ result = 1;
+ }
+#else
+ if (modid == -1)
+ modid = ((struct link_map *) h)->l_tls_modid;
+ else if (((struct link_map *) h)->l_tls_modid != modid)
+ {
+ printf ("round %d: modid now %zd, initially %d\n",
+ i, ((struct link_map *) h)->l_tls_modid, modid);
+ result = 1;
+ }
+#endif
+
+ foop = dlsym (h, "foo");
+ if (foop == NULL)
+ {
+ printf ("cannot get symbol 'foo': %s\n", dlerror ());
+ exit (1);
+ }
+
+ *foop = 42 + i;
+
+ fp = dlsym (h, "in_dso");
+ if (fp == NULL)
+ {
+ printf ("cannot get symbol 'in_dso': %s\n", dlerror ());
+ exit (1);
+ }
+
+ result |= fp (42 + i, foop);
+
+ foop2 = dlsym (h, "foo");
+ if (foop2 == NULL)
+ {
+ printf ("cannot get symbol 'foo' the second time: %s\n", dlerror ());
+ exit (1);
+ }
+
+ if (foop != foop2)
+ {
+ puts ("address of 'foo' different the second time");
+ result = 1;
+ }
+ else if (*foop != 16)
+ {
+ puts ("foo != 16");
+ result = 1;
+ }
+
+ dlclose (h);
+ }
+
+ return result;
+#else
+ return 0;
+#endif
+}
+
+
+#include "../test-skeleton.c"
diff --git a/test/tls/tst-tls7.c b/test/tls/tst-tls7.c
new file mode 100644
index 000000000..2dde9afa4
--- /dev/null
+++ b/test/tls/tst-tls7.c
@@ -0,0 +1,78 @@
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <tls.h>
+#include <link.h>
+#ifdef __UCLIBC__
+#include "dl-elf.h"
+#include "dl-hash.h"
+#endif
+
+
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+#ifdef USE_TLS
+ static const char modname[] = "tst-tlsmod3.so";
+ int result = 0;
+ int (*fp) (void);
+ void *h;
+ int i;
+ int modid = -1;
+
+ for (i = 0; i < 10; ++i)
+ {
+ h = dlopen (modname, RTLD_LAZY);
+ if (h == NULL)
+ {
+ printf ("cannot open '%s': %s\n", modname, dlerror ());
+ exit (1);
+ }
+
+ /* Dirty test code here: we peek into a private data structure.
+ We make sure that the module gets assigned the same ID every
+ time. The value of the first round is used. */
+#ifdef __UCLIBC__
+ if (modid == -1)
+ modid = ((struct dyn_elf *) h)->dyn->l_tls_modid;
+ else if (((struct dyn_elf *)h)->dyn->l_tls_modid != (size_t) modid)
+ {
+ printf ("round %d: modid now %zu, initially %d\n",
+ i,
+ ((struct dyn_elf *)h)->dyn->l_tls_modid,
+ modid);
+ result = 1;
+ }
+#else
+ if (modid == -1)
+ modid = ((struct link_map *) h)->l_tls_modid;
+ else if (((struct link_map *) h)->l_tls_modid != (size_t) modid)
+ {
+ printf ("round %d: modid now %zu, initially %d\n",
+ i, ((struct link_map *) h)->l_tls_modid, modid);
+ result = 1;
+ }
+#endif
+
+ fp = dlsym (h, "in_dso2");
+ if (fp == NULL)
+ {
+ printf ("cannot get symbol 'in_dso2': %s\n", dlerror ());
+ exit (1);
+ }
+
+ result |= fp ();
+
+ dlclose (h);
+ }
+
+ return result;
+#else
+ return 0;
+#endif
+}
+
+
+#include "../test-skeleton.c"
diff --git a/test/tls/tst-tls8.c b/test/tls/tst-tls8.c
new file mode 100644
index 000000000..140de438e
--- /dev/null
+++ b/test/tls/tst-tls8.c
@@ -0,0 +1,229 @@
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <tls.h>
+#include <link.h>
+#ifdef __UCLIBC__
+#include "dl-elf.h"
+#include "dl-hash.h"
+#endif
+
+
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+#ifdef USE_TLS
+ static const char modname1[] = "tst-tlsmod3.so";
+ static const char modname2[] = "tst-tlsmod4.so";
+ int result = 0;
+ int (*fp1) (void);
+ int (*fp2) (int, int *);
+ void *h1;
+ void *h2;
+ int i;
+ size_t modid1 = (size_t) -1;
+ size_t modid2 = (size_t) -1;
+ int *bazp;
+
+ for (i = 0; i < 10; ++i)
+ {
+ h1 = dlopen (modname1, RTLD_LAZY);
+ if (h1 == NULL)
+ {
+ printf ("cannot open '%s': %s\n", modname1, dlerror ());
+ exit (1);
+ }
+
+ /* Dirty test code here: we peek into a private data structure.
+ We make sure that the module gets assigned the same ID every
+ time. The value of the first round is used. */
+#ifdef __UCLIBC__
+ if (modid1 == (size_t) -1)
+ modid1 = ((struct dyn_elf *) h1)->dyn->l_tls_modid;
+ else if (((struct dyn_elf *)h1)->dyn->l_tls_modid != (size_t) modid1)
+ {
+ printf ("round %d: modid now %zd, initially %zd\n",
+ i,
+ ((struct dyn_elf *)h1)->dyn->l_tls_modid,
+ modid1);
+ result = 1;
+ }
+#else
+ if (modid1 == (size_t) -1)
+ modid1 = ((struct link_map *) h1)->l_tls_modid;
+ else if (((struct link_map *) h1)->l_tls_modid != modid1)
+ {
+ printf ("round %d: modid now %zd, initially %zd\n",
+ i, ((struct link_map *) h1)->l_tls_modid, modid1);
+ result = 1;
+ }
+#endif
+
+ fp1 = dlsym (h1, "in_dso2");
+ if (fp1 == NULL)
+ {
+ printf ("cannot get symbol 'in_dso2' in %s\n", modname1);
+ exit (1);
+ }
+
+ result |= fp1 ();
+
+
+
+ h2 = dlopen (modname2, RTLD_LAZY);
+ if (h2 == NULL)
+ {
+ printf ("cannot open '%s': %s\n", modname2, dlerror ());
+ exit (1);
+ }
+
+ /* Dirty test code here: we peek into a private data structure.
+ We make sure that the module gets assigned the same ID every
+ time. The value of the first round is used. */
+#ifdef __UCLIBC__
+ if (modid2 == (size_t) -1)
+ modid2 = ((struct dyn_elf *)h2)->dyn->l_tls_modid;
+ else if (((struct dyn_elf *)h2)->dyn->l_tls_modid
+ != (size_t) modid2)
+ {
+ printf ("round %d: modid now %zd, initially %zd\n",
+ i,
+ ((struct dyn_elf *)h2)->dyn->l_tls_modid,
+ modid2);
+ result = 1;
+ }
+#else
+ if (modid2 == (size_t) -1)
+ modid2 = ((struct link_map *) h2)->l_tls_modid;
+ else if (((struct link_map *) h2)->l_tls_modid != modid2)
+ {
+ printf ("round %d: modid now %zd, initially %zd\n",
+ i, ((struct link_map *) h2)->l_tls_modid, modid2);
+ result = 1;
+ }
+#endif
+
+ bazp = dlsym (h2, "baz");
+ if (bazp == NULL)
+ {
+ printf ("cannot get symbol 'baz' in %s\n", modname2);
+ exit (1);
+ }
+
+ *bazp = 42 + i;
+
+ fp2 = dlsym (h2, "in_dso");
+ if (fp2 == NULL)
+ {
+ printf ("cannot get symbol 'in_dso' in %s\n", modname2);
+ exit (1);
+ }
+
+ result |= fp2 (42 + i, bazp);
+
+ dlclose (h1);
+ dlclose (h2);
+
+
+ h1 = dlopen (modname1, RTLD_LAZY);
+ if (h1 == NULL)
+ {
+ printf ("cannot open '%s': %s\n", modname1, dlerror ());
+ exit (1);
+ }
+
+ /* Dirty test code here: we peek into a private data structure.
+ We make sure that the module gets assigned the same ID every
+ time. The value of the first round is used. */
+#ifdef __UCLIBC__
+ if (((struct dyn_elf *)h1)->dyn->l_tls_modid
+ != modid1)
+ {
+ printf ("round %d: modid now %zd, initially %zd\n",
+ i,
+ ((struct dyn_elf *)h1)->dyn->l_tls_modid,
+ modid1);
+ result = 1;
+ }
+#else
+ if (((struct link_map *) h1)->l_tls_modid != modid1)
+ {
+ printf ("round %d: modid now %zd, initially %zd\n",
+ i, ((struct link_map *) h1)->l_tls_modid, modid1);
+ result = 1;
+ }
+#endif
+
+ fp1 = dlsym (h1, "in_dso2");
+ if (fp1 == NULL)
+ {
+ printf ("cannot get symbol 'in_dso2' in %s\n", modname1);
+ exit (1);
+ }
+
+ result |= fp1 ();
+
+
+
+ h2 = dlopen (modname2, RTLD_LAZY);
+ if (h2 == NULL)
+ {
+ printf ("cannot open '%s': %s\n", modname2, dlerror ());
+ exit (1);
+ }
+
+ /* Dirty test code here: we peek into a private data structure.
+ We make sure that the module gets assigned the same ID every
+ time. The value of the first round is used. */
+#ifdef __UCLIBC__
+ if (((struct dyn_elf *)h2)->dyn->l_tls_modid
+ != modid2)
+ {
+ printf ("round %d: modid now %zd, initially %zd\n",
+ i,
+ ((struct dyn_elf *)h2)->dyn->l_tls_modid,
+ modid2);
+ result = 1;
+ }
+#else
+ if (((struct link_map *) h2)->l_tls_modid != modid2)
+ {
+ printf ("round %d: modid now %zd, initially %zd\n",
+ i, ((struct link_map *) h2)->l_tls_modid, modid2);
+ result = 1;
+ }
+#endif
+
+ bazp = dlsym (h2, "baz");
+ if (bazp == NULL)
+ {
+ printf ("cannot get symbol 'baz' in %s\n", modname2);
+ exit (1);
+ }
+
+ *bazp = 62 + i;
+
+ fp2 = dlsym (h2, "in_dso");
+ if (fp2 == NULL)
+ {
+ printf ("cannot get symbol 'in_dso' in %s\n", modname2);
+ exit (1);
+ }
+
+ result |= fp2 (62 + i, bazp);
+
+ /* This time the dlclose calls are in reverse order. */
+ dlclose (h2);
+ dlclose (h1);
+ }
+
+ return result;
+#else
+ return 0;
+#endif
+}
+
+
+#include "../test-skeleton.c"
diff --git a/test/tls/tst-tls9-static.c b/test/tls/tst-tls9-static.c
new file mode 100644
index 000000000..51812ccc7
--- /dev/null
+++ b/test/tls/tst-tls9-static.c
@@ -0,0 +1 @@
+#include "tst-tls9.c"
diff --git a/test/tls/tst-tls9.c b/test/tls/tst-tls9.c
new file mode 100644
index 000000000..e317696df
--- /dev/null
+++ b/test/tls/tst-tls9.c
@@ -0,0 +1,42 @@
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <link.h>
+#include <tls.h>
+
+#define TEST_FUNCTION do_test ()
+static int
+do_test (void)
+{
+#ifdef USE_TLS
+ static const char modname1[] = "tst-tlsmod5.so";
+ static const char modname2[] = "tst-tlsmod6.so";
+ int result = 0;
+
+ void *h1 = dlopen (modname1, RTLD_LAZY);
+ if (h1 == NULL)
+ {
+ printf ("cannot open '%s': %s\n", modname1, dlerror ());
+ result = 1;
+ }
+ void *h2 = dlopen (modname2, RTLD_LAZY);
+ if (h2 == NULL)
+ {
+ printf ("cannot open '%s': %s\n", modname2, dlerror ());
+ result = 1;
+ }
+
+ if (h1 != NULL)
+ dlclose (h1);
+ if (h2 != NULL)
+ dlclose (h2);
+
+ return result;
+#else
+ return 0;
+#endif
+}
+
+
+#include "../test-skeleton.c"
diff --git a/test/tls/tst-tlsmod-at-ctor.c b/test/tls/tst-tlsmod-at-ctor.c
new file mode 100644
index 000000000..bd04b5081
--- /dev/null
+++ b/test/tls/tst-tlsmod-at-ctor.c
@@ -0,0 +1,25 @@
+#include <stdio.h>
+#include <tls.h>
+
+#define TLS_VAR_INIT_VALUE 99
+
+#ifdef USE_TLS
+__thread int tls_var __attribute__((tls_model("global-dynamic")));
+static __thread int local_tls_var __attribute__((tls_model("local-dynamic")));
+#endif
+
+void __attribute__((constructor)) libtls_ctor(void);
+void libtls_ctor(void)
+{
+ printf("libtls: constructor!\n");
+#ifdef USE_TLS
+ local_tls_var = TLS_VAR_INIT_VALUE;
+ tls_var = local_tls_var;
+#endif
+}
+
+void __attribute__((destructor)) libtls_dtor(void);
+void libtls_dtor(void)
+{
+ printf("libtls: destructor!\n");
+}
diff --git a/test/tls/tst-tlsmod1.c b/test/tls/tst-tlsmod1.c
new file mode 100644
index 000000000..b4954ca3e
--- /dev/null
+++ b/test/tls/tst-tlsmod1.c
@@ -0,0 +1,68 @@
+#include <stdio.h>
+
+#include <tls.h>
+
+#ifdef USE_TLS
+#include "tls-macros.h"
+
+
+/* One define int variable, two externs. */
+COMMON_INT_DEF(foo);
+VAR_INT_DEF(bar);
+VAR_INT_DECL(baz);
+#endif
+
+extern int in_dso (void);
+
+int
+in_dso (void)
+{
+ int result = 0;
+#ifdef USE_TLS
+ int *ap, *bp, *cp;
+
+ /* Get variables using initial exec model. */
+ fputs ("get sum of foo and bar (IE)", stdout);
+ __asm__ ("" ::: "memory");
+ ap = TLS_IE (foo);
+ bp = TLS_IE (bar);
+ printf (" = %d\n", *ap + *bp);
+ result |= *ap + *bp != 3;
+ if (*ap != 1)
+ {
+ printf ("foo = %d\n", *ap);
+ result = 1;
+ }
+ if (*bp != 2)
+ {
+ printf ("bar = %d\n", *bp);
+ result = 1;
+ }
+
+
+ /* Get variables using generic dynamic model. */
+ fputs ("get sum of foo and bar and baz (GD)", stdout);
+ ap = TLS_GD (foo);
+ bp = TLS_GD (bar);
+ cp = TLS_GD (baz);
+ printf (" = %d\n", *ap + *bp + *cp);
+ result |= *ap + *bp + *cp != 6;
+ if (*ap != 1)
+ {
+ printf ("foo = %d\n", *ap);
+ result = 1;
+ }
+ if (*bp != 2)
+ {
+ printf ("bar = %d\n", *bp);
+ result = 1;
+ }
+ if (*cp != 3)
+ {
+ printf ("baz = %d\n", *cp);
+ result = 1;
+ }
+#endif
+
+ return result;
+}
diff --git a/test/tls/tst-tlsmod10.c b/test/tls/tst-tlsmod10.c
new file mode 100644
index 000000000..32e54f3c0
--- /dev/null
+++ b/test/tls/tst-tlsmod10.c
@@ -0,0 +1 @@
+#include "tst-tlsmod8.c"
diff --git a/test/tls/tst-tlsmod11.c b/test/tls/tst-tlsmod11.c
new file mode 100644
index 000000000..9938b5753
--- /dev/null
+++ b/test/tls/tst-tlsmod11.c
@@ -0,0 +1,6 @@
+#include "tst-tls10.h"
+
+#ifdef USE_TLS__THREAD
+__thread struct A a1 = { 4, 5, 6 };
+__thread struct A a2 = { 7, 8, 9 };
+#endif
diff --git a/test/tls/tst-tlsmod12.c b/test/tls/tst-tlsmod12.c
new file mode 100644
index 000000000..4602709a1
--- /dev/null
+++ b/test/tls/tst-tlsmod12.c
@@ -0,0 +1,14 @@
+#include "tst-tls10.h"
+
+#ifdef USE_TLS__THREAD
+extern __thread struct A a2 __attribute__((tls_model("initial-exec")));
+
+void
+check1 (void)
+{
+ if (a1.a != 4 || a1.b != 5 || a1.c != 6)
+ abort ();
+ if (a2.a != 7 || a2.b != 8 || a2.c != 9)
+ abort ();
+}
+#endif
diff --git a/test/tls/tst-tlsmod13.c b/test/tls/tst-tlsmod13.c
new file mode 100644
index 000000000..beca89f6f
--- /dev/null
+++ b/test/tls/tst-tlsmod13.c
@@ -0,0 +1,14 @@
+#include <tls.h>
+
+#if defined USE_TLS && defined HAVE___THREAD \
+ && defined HAVE_TLS_MODEL_ATTRIBUTE
+__thread int a[2] __attribute__ ((tls_model ("initial-exec")));
+#else
+int a[2];
+#endif
+
+int
+foo (void)
+{
+ return a[0];
+}
diff --git a/test/tls/tst-tlsmod13a.c b/test/tls/tst-tlsmod13a.c
new file mode 100644
index 000000000..14b12b032
--- /dev/null
+++ b/test/tls/tst-tlsmod13a.c
@@ -0,0 +1,16 @@
+#include <tls.h>
+
+#if defined USE_TLS && defined HAVE___THREAD \
+ && defined HAVE_TLS_MODEL_ATTRIBUTE
+__thread int b[2] __attribute__ ((tls_model ("initial-exec")));
+#else
+int b[2];
+#endif
+
+extern int foo (void);
+
+int
+bar (void)
+{
+ return foo () + b[0];
+}
diff --git a/test/tls/tst-tlsmod14a.c b/test/tls/tst-tlsmod14a.c
new file mode 100644
index 000000000..0bb393d9c
--- /dev/null
+++ b/test/tls/tst-tlsmod14a.c
@@ -0,0 +1,41 @@
+#include <stdint.h>
+#include <stdio.h>
+
+#include <tls.h>
+
+#if USE_TLS && HAVE___THREAD
+
+#define AL 4096
+struct foo
+{
+ int i;
+} __attribute ((aligned (AL)));
+
+static __thread struct foo f;
+static struct foo g;
+
+
+#ifndef FCT
+# define FCT in_dso1
+#endif
+
+
+int
+FCT (void)
+{
+ puts (__func__);
+
+ int result = 0;
+
+ int fail = (((uintptr_t) &f) & (AL - 1)) != 0;
+ printf ("&f = %p %s\n", &f, fail ? "FAIL" : "OK");
+ result |= fail;
+
+ fail = (((uintptr_t) &g) & (AL - 1)) != 0;
+ printf ("&g = %p %s\n", &g, fail ? "FAIL" : "OK");
+ result |= fail;
+
+ return result;
+}
+
+#endif
diff --git a/test/tls/tst-tlsmod14b.c b/test/tls/tst-tlsmod14b.c
new file mode 100644
index 000000000..24d9ceaf7
--- /dev/null
+++ b/test/tls/tst-tlsmod14b.c
@@ -0,0 +1,2 @@
+#define FCT in_dso2
+#include "tst-tlsmod14a.c"
diff --git a/test/tls/tst-tlsmod15a.c b/test/tls/tst-tlsmod15a.c
new file mode 100644
index 000000000..66c707129
--- /dev/null
+++ b/test/tls/tst-tlsmod15a.c
@@ -0,0 +1,6 @@
+extern int nonexistent_dummy_var;
+int *
+foo (void)
+{
+ return &nonexistent_dummy_var;
+}
diff --git a/test/tls/tst-tlsmod15b.c b/test/tls/tst-tlsmod15b.c
new file mode 100644
index 000000000..4f63eab14
--- /dev/null
+++ b/test/tls/tst-tlsmod15b.c
@@ -0,0 +1,17 @@
+#include "tst-tls10.h"
+
+#ifdef USE_TLS__THREAD
+__thread int mod15b_var __attribute__((tls_model("initial-exec")));
+
+int
+in_dso (void)
+{
+ return mod15b_var;
+}
+#else
+int
+in_dso (void)
+{
+ return 0;
+}
+#endif
diff --git a/test/tls/tst-tlsmod16a.c b/test/tls/tst-tlsmod16a.c
new file mode 100644
index 000000000..847c8090f
--- /dev/null
+++ b/test/tls/tst-tlsmod16a.c
@@ -0,0 +1,7 @@
+#include <tls.h>
+
+#if defined HAVE___THREAD && defined HAVE_TLS_MODEL_ATTRIBUTE
+int __thread tlsvar;
+#else
+int tlsvar;
+#endif
diff --git a/test/tls/tst-tlsmod16b.c b/test/tls/tst-tlsmod16b.c
new file mode 100644
index 000000000..308e6bae9
--- /dev/null
+++ b/test/tls/tst-tlsmod16b.c
@@ -0,0 +1,13 @@
+#include <tls.h>
+
+#if defined HAVE___THREAD && defined HAVE_TLS_MODEL_ATTRIBUTE
+extern __thread int tlsvar __attribute__((tls_model("initial-exec")));
+#else
+extern int tlsvar;
+#endif
+
+void *
+in_dso (void)
+{
+ return &tlsvar;
+}
diff --git a/test/tls/tst-tlsmod17a.c b/test/tls/tst-tlsmod17a.c
new file mode 100644
index 000000000..4d3965005
--- /dev/null
+++ b/test/tls/tst-tlsmod17a.c
@@ -0,0 +1,23 @@
+#include <stdio.h>
+
+#ifndef N
+#define N 0
+#endif
+#define CONCAT1(s, n) s##n
+#define CONCAT(s, n) CONCAT1(s, n)
+
+__thread int CONCAT (v, N) = 4;
+
+int
+CONCAT (tlsmod17a, N) (void)
+{
+ int *p = &CONCAT (v, N);
+ /* GCC assumes &var is never NULL, add optimization barrier. */
+ __asm__ __volatile__ ("" : "+r" (p));
+ if (p == NULL || *p != 4)
+ {
+ printf ("fail %d %p\n", N, p);
+ return 1;
+ }
+ return 0;
+}
diff --git a/test/tls/tst-tlsmod17b.c b/test/tls/tst-tlsmod17b.c
new file mode 100644
index 000000000..617882873
--- /dev/null
+++ b/test/tls/tst-tlsmod17b.c
@@ -0,0 +1,15 @@
+#define P(N) extern int tlsmod17a##N (void);
+#define PS P(0) P(1) P(2) P(3) P(4) P(5) P(6) P(7) P(8) P(9) \
+ P(10) P(12) P(13) P(14) P(15) P(16) P(17) P(18) P(19)
+PS
+#undef P
+
+int
+tlsmod17b (void)
+{
+ int res = 0;
+#define P(N) res |= tlsmod17a##N ();
+ PS
+#undef P
+ return res;
+}
diff --git a/test/tls/tst-tlsmod18a.c b/test/tls/tst-tlsmod18a.c
new file mode 100644
index 000000000..e0ae65a88
--- /dev/null
+++ b/test/tls/tst-tlsmod18a.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+
+#ifndef N
+# define N 0
+#endif
+
+static __thread int var = 4;
+
+int
+test (void)
+{
+ int *p = &var;
+ /* GCC assumes &var is never NULL, add optimization barrier. */
+ __asm__ __volatile__ ("" : "+r" (p));
+ if (p == NULL || *p != 4)
+ {
+ printf ("fail %d %p\n", N, p);
+ return 1;
+ }
+ return 0;
+}
diff --git a/test/tls/tst-tlsmod2.c b/test/tls/tst-tlsmod2.c
new file mode 100644
index 000000000..4547c9716
--- /dev/null
+++ b/test/tls/tst-tlsmod2.c
@@ -0,0 +1,38 @@
+#include <stdio.h>
+
+#include <tls.h>
+
+#ifdef USE_TLS
+#include "tls-macros.h"
+
+
+COMMON_INT_DEF(foo);
+
+
+int
+in_dso (int n, int *caller_foop)
+{
+ int *foop;
+ int result = 0;
+
+ puts ("foo"); /* Make sure PLT is used before macros. */
+ __asm__ ("" ::: "memory");
+
+ foop = TLS_GD (foo);
+
+ if (caller_foop != NULL && foop != caller_foop)
+ {
+ printf ("callers address of foo differs: %p vs %p\n", caller_foop, foop);
+ result = 1;
+ }
+ else if (*foop != n)
+ {
+ printf ("foo != %d\n", n);
+ result = 1;
+ }
+
+ *foop = 16;
+
+ return result;
+}
+#endif
diff --git a/test/tls/tst-tlsmod3.c b/test/tls/tst-tlsmod3.c
new file mode 100644
index 000000000..12505f623
--- /dev/null
+++ b/test/tls/tst-tlsmod3.c
@@ -0,0 +1,41 @@
+#include <stdio.h>
+
+#include <tls.h>
+
+#ifdef USE_TLS
+# include "tls-macros.h"
+
+extern int in_dso (int n, int *caller_foop);
+
+COMMON_INT_DEF(comm_n);
+
+
+
+
+int
+in_dso2 (void)
+{
+ int *foop;
+ int result = 0;
+ static int n;
+ int *np;
+
+ puts ("foo"); /* Make sure PLT is used before macros. */
+ __asm__ ("" ::: "memory");
+
+ foop = TLS_GD (foo);
+ np = TLS_GD (comm_n);
+
+ if (n != *np)
+ {
+ printf ("n = %d != comm_n = %d\n", n, *np);
+ result = 1;
+ }
+
+ result |= in_dso (*foop = 42 + n++, foop);
+
+ *foop = 16;
+
+ return result;
+}
+#endif
diff --git a/test/tls/tst-tlsmod4.c b/test/tls/tst-tlsmod4.c
new file mode 100644
index 000000000..4893cdae7
--- /dev/null
+++ b/test/tls/tst-tlsmod4.c
@@ -0,0 +1,38 @@
+#include <stdio.h>
+
+#include <tls.h>
+
+#ifdef USE_TLS
+# include "tls-macros.h"
+
+
+COMMON_INT_DEF(baz);
+
+
+int
+in_dso (int n, int *caller_bazp)
+{
+ int *bazp;
+ int result = 0;
+
+ puts ("foo"); /* Make sure PLT is used before macros. */
+ __asm__ ("" ::: "memory");
+
+ bazp = TLS_GD (baz);
+
+ if (caller_bazp != NULL && bazp != caller_bazp)
+ {
+ printf ("callers address of baz differs: %p vs %p\n", caller_bazp, bazp);
+ result = 1;
+ }
+ else if (*bazp != n)
+ {
+ printf ("baz != %d\n", n);
+ result = 1;
+ }
+
+ *bazp = 16;
+
+ return result;
+}
+#endif
diff --git a/test/tls/tst-tlsmod5.c b/test/tls/tst-tlsmod5.c
new file mode 100644
index 000000000..2ec69e13b
--- /dev/null
+++ b/test/tls/tst-tlsmod5.c
@@ -0,0 +1,7 @@
+#include <tls.h>
+
+#ifdef USE_TLS
+#include "tls-macros.h"
+
+COMMON_INT_DEF(foo);
+#endif
diff --git a/test/tls/tst-tlsmod6.c b/test/tls/tst-tlsmod6.c
new file mode 100644
index 000000000..0fda51b22
--- /dev/null
+++ b/test/tls/tst-tlsmod6.c
@@ -0,0 +1,7 @@
+#include <tls.h>
+
+#ifdef USE_TLS
+#include "tls-macros.h"
+
+COMMON_INT_DEF(bar);
+#endif
diff --git a/test/tls/tst-tlsmod7.c b/test/tls/tst-tlsmod7.c
new file mode 100644
index 000000000..944b97f9c
--- /dev/null
+++ b/test/tls/tst-tlsmod7.c
@@ -0,0 +1,103 @@
+#include "tst-tls10.h"
+
+#ifdef USE_TLS__THREAD
+__thread int dummy __attribute__((visibility ("hidden"))) = 12;
+__thread struct A a1 = { 4, 5, 6 };
+__thread struct A a2 = { 7, 8, 9 };
+__thread struct A a3 __attribute__((tls_model("initial-exec")))
+ = { 10, 11, 12 };
+__thread struct A a4 __attribute__((tls_model("initial-exec")))
+ = { 13, 14, 15 };
+static __thread struct A local1 = { 16, 17, 18 };
+static __thread struct A local2 __attribute__((tls_model("initial-exec")))
+ = { 19, 20, 21 };
+
+void
+check1 (void)
+{
+ if (a1.a != 4 || a1.b != 5 || a1.c != 6)
+ abort ();
+ if (a2.a != 22 || a2.b != 23 || a2.c != 24)
+ abort ();
+ if (a3.a != 10 || a3.b != 11 || a3.c != 12)
+ abort ();
+ if (a4.a != 25 || a4.b != 26 || a4.c != 27)
+ abort ();
+ if (local1.a != 16 || local1.b != 17 || local1.c != 18)
+ abort ();
+ if (local2.a != 19 || local2.b != 20 || local2.c != 21)
+ abort ();
+}
+
+struct A *
+f1a (void)
+{
+ return &a1;
+}
+
+struct A *
+f2a (void)
+{
+ return &a2;
+}
+
+struct A *
+f3a (void)
+{
+ return &a3;
+}
+
+struct A *
+f4a (void)
+{
+ return &a4;
+}
+
+struct A *
+f5a (void)
+{
+ return &local1;
+}
+
+struct A *
+f6a (void)
+{
+ return &local2;
+}
+
+int
+f1b (void)
+{
+ return a1.a;
+}
+
+int
+f2b (void)
+{
+ return a2.b;
+}
+
+int
+f3b (void)
+{
+ return a3.c;
+}
+
+int
+f4b (void)
+{
+ return a4.a;
+}
+
+int
+f5b (void)
+{
+ return local1.b;
+}
+
+int
+f6b (void)
+{
+ return local2.c;
+}
+#endif
diff --git a/test/tls/tst-tlsmod8.c b/test/tls/tst-tlsmod8.c
new file mode 100644
index 000000000..c1822fc0c
--- /dev/null
+++ b/test/tls/tst-tlsmod8.c
@@ -0,0 +1,72 @@
+#include "tst-tls10.h"
+
+#ifdef USE_TLS__THREAD
+__thread long long dummy __attribute__((visibility ("hidden"))) = 12;
+__thread struct A a2 = { 22, 23, 24 };
+__thread struct A a4 __attribute__((tls_model("initial-exec")))
+ = { 25, 26, 27 };
+static __thread struct A local1 = { 28, 29, 30 };
+static __thread struct A local2 __attribute__((tls_model("initial-exec")))
+ = { 31, 32, 33 };
+
+void
+check2 (void)
+{
+ if (a2.a != 22 || a2.b != 23 || a2.c != 24)
+ abort ();
+ if (a4.a != 25 || a4.b != 26 || a4.c != 27)
+ abort ();
+ if (local1.a != 28 || local1.b != 29 || local1.c != 30)
+ abort ();
+ if (local2.a != 31 || local2.b != 32 || local2.c != 33)
+ abort ();
+}
+
+struct A *
+f7a (void)
+{
+ return &a2;
+}
+
+struct A *
+f8a (void)
+{
+ return &a4;
+}
+
+struct A *
+f9a (void)
+{
+ return &local1;
+}
+
+struct A *
+f10a (void)
+{
+ return &local2;
+}
+
+int
+f7b (void)
+{
+ return a2.b;
+}
+
+int
+f8b (void)
+{
+ return a4.a;
+}
+
+int
+f9b (void)
+{
+ return local1.b;
+}
+
+int
+f10b (void)
+{
+ return local2.c;
+}
+#endif
diff --git a/test/tls/tst-tlsmod9.c b/test/tls/tst-tlsmod9.c
new file mode 100644
index 000000000..e124144e4
--- /dev/null
+++ b/test/tls/tst-tlsmod9.c
@@ -0,0 +1,101 @@
+#include "tst-tls10.h"
+
+#ifdef USE_TLS__THREAD
+__thread int dummy __attribute__((visibility ("hidden"))) = 12;
+__thread struct A a1 = { 4, 5, 6 };
+__thread struct A a3 __attribute__((tls_model("initial-exec")))
+ = { 10, 11, 12 };
+extern __thread struct A a4 __attribute__((tls_model("initial-exec")));
+static __thread struct A local1 = { 16, 17, 18 };
+static __thread struct A local2 __attribute__((tls_model("initial-exec")))
+ = { 19, 20, 21 };
+
+void
+check1 (void)
+{
+ if (a1.a != 4 || a1.b != 5 || a1.c != 6)
+ abort ();
+ if (a2.a != 22 || a2.b != 23 || a2.c != 24)
+ abort ();
+ if (a3.a != 10 || a3.b != 11 || a3.c != 12)
+ abort ();
+ if (a4.a != 25 || a4.b != 26 || a4.c != 27)
+ abort ();
+ if (local1.a != 16 || local1.b != 17 || local1.c != 18)
+ abort ();
+ if (local2.a != 19 || local2.b != 20 || local2.c != 21)
+ abort ();
+}
+
+struct A *
+f1a (void)
+{
+ return &a1;
+}
+
+struct A *
+f2a (void)
+{
+ return &a2;
+}
+
+struct A *
+f3a (void)
+{
+ return &a3;
+}
+
+struct A *
+f4a (void)
+{
+ return &a4;
+}
+
+struct A *
+f5a (void)
+{
+ return &local1;
+}
+
+struct A *
+f6a (void)
+{
+ return &local2;
+}
+
+int
+f1b (void)
+{
+ return a1.a;
+}
+
+int
+f2b (void)
+{
+ return a2.b;
+}
+
+int
+f3b (void)
+{
+ return a3.c;
+}
+
+int
+f4b (void)
+{
+ return a4.a;
+}
+
+int
+f5b (void)
+{
+ return local1.b;
+}
+
+int
+f6b (void)
+{
+ return local2.c;
+}
+#endif
diff --git a/test/uclibcng-testrunner.sh b/test/uclibcng-testrunner.sh
new file mode 100644
index 000000000..943c95086
--- /dev/null
+++ b/test/uclibcng-testrunner.sh
@@ -0,0 +1,62 @@
+#!/bin/sh
+#-
+# Copyright (c) 2015
+# Thorsten "mirabilos" Glaser <tg@mirbsd.org>
+#
+# Provided that these terms and disclaimer and all copyright notices
+# are retained or reproduced in an accompanying document, permission
+# is granted to deal in this work without restriction, including un-
+# limited rights to use, publicly perform, distribute, sell, modify,
+# merge, give away, or sublicence.
+#
+# This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to
+# the utmost extent permitted by applicable law, neither express nor
+# implied; without malicious intent or gross negligence. In no event
+# may a licensor, author or contributor be held liable for indirect,
+# direct, other damage, loss, or other issues arising in any way out
+# of dealing in the work, even if advised of the possibility of such
+# damage or existence of a defect, except proven that it results out
+# of said person's immediate fault when using the work as intended.
+#-
+# Testsuite runner
+
+die() {
+ echo >&2 E: "$*"
+ exit 1
+}
+
+test -s uclibcng-testrunner.in || die uclibcng-testrunner.in not found
+
+nfail=0
+npass=0
+while read expected_ret tst_src_name binary_name subdir cmd; do
+ printf '.... %s\r' "$binary_name"
+ (cd $subdir && eval "$cmd" >$binary_name.out 2>&1) </dev/null
+ ret=$?
+ test $ret = "$expected_ret" || {
+ echo "FAIL $binary_name got $ret expected $expected_ret"
+ nfail=`expr $nfail + 1`
+ sed 's/^/ /' <$subdir/$binary_name.out
+ continue
+ }
+ for x in $binary_name.out $test_src_name.out -; do
+ if test x"$x" = x"-"; then
+ echo "PASS $binary_name"
+ npass=`expr $npass + 1`
+ break
+ fi
+ test -e "$subdir/$x.good" || continue
+ if d=`diff -u "$subdir/$binary_name.out" "$subdir/$x.good"`; then
+ echo "PASS $binary_name"
+ npass=`expr $npass + 1`
+ else
+ echo "FAIL $binary_name expected output differs"
+ nfail=`expr $nfail + 1`
+ echo "$d" | sed 's/^/ /'
+ fi
+ break
+ done
+done <uclibcng-testrunner.in
+echo Total failed: $nfail
+echo Total passed: $npass
+test $nfail = 0
diff --git a/test/unistd/Makefile b/test/unistd/Makefile
index c5007cdcc..796d7ccea 100644
--- a/test/unistd/Makefile
+++ b/test/unistd/Makefile
@@ -1,13 +1,8 @@
# uClibc unistd tests
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+top_builddir=../../
+top_srcdir=../../
+include ../Rules.mak
+-include Makefile.in
include ../Test.mak
-
-OPTS_getopt := -abcXXX -9
-OPTS_getopt_long := --add XXX --delete YYY --verbose
-ifeq ($(UCLIBC_HAS_GNU_GETOPT),y)
-OPTS_tstgetopt := -a -b -cfoobar --required foobar --optional=bazbug --none random --col --color --colour
-else
-# reordering is not supported, behaves as if POSIXLY_CORRECT would be set
-OPTS_tstgetopt := -a -b -cfoobar --required foobar --optional=bazbug --none --colou --color --colour random
-endif
diff --git a/test/unistd/Makefile.in b/test/unistd/Makefile.in
new file mode 100644
index 000000000..da59a3689
--- /dev/null
+++ b/test/unistd/Makefile.in
@@ -0,0 +1,49 @@
+# uClibc unistd tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+TESTS_DISABLED :=
+# If LFS is not set, get rid of all *64 tests up front
+ifeq ($(UCLIBC_HAS_LFS),)
+TESTS_DISABLED += tst-preadwrite64
+endif
+
+# If we don't have LINUX_SPECIFIC, then get rid of tst-fallocate
+ifeq ($(UCLIBC_LINUX_SPECIFIC),)
+TESTS_DISABLED += tst-fallocate
+endif
+
+ifeq ($(TARGET_avr32),y)
+TESTS_DISABLED += tst-fallocate tst-posix_fallocate tst-fallocate64
+endif
+
+# The logic is similar for HAS_ADVANCED_REALTIME and
+# tst-posix_fallocate/tst-posix_fallocate64
+ifeq ($(UCLIBC_HAS_ADVANCED_REALTIME),)
+TESTS_DISABLED += tst-posix_fallocate
+endif
+
+OPTS_getopt := -abcXXX -9
+OPTS_getopt_long := --add XXX --delete YYY --verbose
+ifeq ($(UCLIBC_HAS_GNU_GETOPT),y)
+OPTS_tstgetopt := -a -b -cfoobar --required foobar --optional=bazbug --none random --col --color --colour
+else
+# reordering is not supported, behaves as if POSIXLY_CORRECT would be set
+OPTS_tstgetopt := -a -b -cfoobar --required foobar --optional=bazbug --none --colou --color --colour random
+endif
+
+# for embedded systems 4 GB disk space is not available
+TESTS_DISABLED += tst-posix_fallocate64 tst-fallocate64
+
+CFLAGS_tst-fallocate = -fPIC
+CFLAGS_tst-posix_fallocate = -fPIC
+CFLAGS_tst-preadwrite = -fPIC
+CFLAGS_tst-preadwrite64 = -fPIC
+
+# getconf.c lives in utils/
+# Testsuite cannot currently be built with O= anyway, so hardcode path here
+getconf.c:
+ $(LN_S) ../../utils/$(@F) .
+EXTRA_CLEAN += getconf.c
+TESTS_DISABLED += getconf
+CFLAGS_getconf = -DGETCONF_DIR='"$(CURDIR)"'
+shell_tst-getconf: getconf getconf_glibc
diff --git a/test/unistd/errno.c b/test/unistd/errno.c
index 5fdb3b347..5d4fc726a 100644
--- a/test/unistd/errno.c
+++ b/test/unistd/errno.c
@@ -17,7 +17,7 @@ int main(void)
{
int r_clone, ret_errno;
- r_clone = do_clone(child_fn, NULL, (int) NULL, NULL);
+ r_clone = do_clone(child_fn, NULL, 0, NULL);
ret_errno = errno;
if (ret_errno != EINVAL || r_clone != -1) {
fprintf(stderr, "clone: res=%d (wanted -1) errno=%d (wanted %d)\n",
diff --git a/test/unistd/tst-fallocate.c b/test/unistd/tst-fallocate.c
new file mode 100644
index 000000000..fc81781bb
--- /dev/null
+++ b/test/unistd/tst-fallocate.c
@@ -0,0 +1,166 @@
+#include <fcntl.h>
+#include <sys/stat.h>
+
+#ifndef TST_FALLOCATE64
+# define stat64 stat
+# define fstat64 fstat
+# else
+# ifndef O_LARGEFILE
+# error no O_LARGEFILE but you want to test with LFS enabled
+# endif
+#endif
+
+static void do_prepare(void);
+static int do_test(void);
+#define PREPARE(argc, argv) do_prepare ()
+#define TEST_FUNCTION do_test ()
+#include <test-skeleton.c>
+
+static int fd;
+static void
+do_prepare (void)
+{
+ fd = create_temp_file ("tst-fallocate.", NULL);
+ if (fd == -1)
+ {
+ printf ("cannot create temporary file: %m\n");
+ exit (1);
+ }
+}
+
+
+static int
+do_test (void)
+{
+ struct stat64 st;
+ int c;
+ char garbage[4096];
+ blkcnt_t blksb4;
+
+ if (fstat64 (fd, &st) != 0)
+ {
+ puts ("1st fstat failed");
+ return 1;
+ }
+
+ if (st.st_size != 0)
+ {
+ puts ("file not created with size 0");
+ return 1;
+ }
+
+ /* This is the default mode which is identical to posix_fallocate().
+ Note: we need a few extra blocks for FALLOC_FL_PUNCH_HOLE below.
+ While block sizes vary, we'll assume eight 4K blocks for good measure. */
+ if (fallocate (fd, 0, 8 * 4096, 128) != 0)
+ {
+ puts ("1st fallocate call failed");
+ return 1;
+ }
+
+ if (fstat64 (fd, &st) != 0)
+ {
+ puts ("2nd fstat failed");
+ return 1;
+ }
+
+ if (st.st_size != 8 * 4096 + 128)
+ {
+ printf ("file size after 1st fallocate call is %llu, expected %u\n",
+ (unsigned long long int) st.st_size, 8u * 4096u + 128u);
+ return 1;
+ }
+
+ /* Without FALLOC_FL_KEEP_SIZE, this would increaste the size of the file. */
+ if (fallocate (fd, FALLOC_FL_KEEP_SIZE, 0, 16 * 4096) != 0)
+ {
+ puts ("2nd fallocate call failed");
+ return 1;
+ }
+
+ if (fstat64 (fd, &st) != 0)
+ {
+ puts ("3rd fstat failed");
+ return 1;
+ }
+
+ if (st.st_size != 8 * 4096 + 128)
+ {
+ printf ("file size changed in 2nd fallocate call to %llu, expected %u\n",
+ (unsigned long long int) st.st_size, 8u * 4096u + 128u);
+ return 1;
+ }
+
+ /* Let's fill up the first eight 4k blocks with 'x' to force some allocations. */
+
+ memset(garbage, 'x', 4096);
+ for(c=0; c < 8; c++)
+ if(write(fd, garbage, 4096) == -1)
+ {
+ puts ("write failed");
+ return 1;
+ }
+
+ if (fstat64 (fd, &st) != 0)
+ {
+ puts ("4th fstat failed");
+ return 1;
+ }
+
+ blksb4 = st.st_blocks;
+
+ /* Let's punch a hole in the entire file, turning it effectively into a sparse file. */
+ if (fallocate (fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 8 * 4096 + 128) != 0)
+ {
+ puts ("3rd fallocate call failed");
+ return 1;
+ }
+
+ if (fstat64 (fd, &st) != 0)
+ {
+ puts ("5th fstat failed");
+ return 1;
+ }
+
+ if (st.st_size != 8 * 4096 + 128)
+ {
+ printf ("file size after 3rd fallocate call is %llu, expected %u\n",
+ (unsigned long long int) st.st_size, 8u * 4096u + 128u);
+ return 1;
+ }
+
+ /* The number of allocated blocks should decrease. I hope this works on
+ all filesystems! */
+ if (st.st_blocks >= blksb4)
+ {
+ printf ("number of blocks after 3rd fallocate call is %lu, expected less than %lu\n",
+ (unsigned long int) st.st_blocks, blksb4);
+ return 1;
+ }
+
+#ifdef TST_FALLOCATE64
+ /* We'll just do a mode = 0 test for fallocate64() */
+ if (fallocate64 (fd, 0, 4097ULL, 4294967295ULL + 2ULL) != 0)
+ {
+ puts ("1st fallocate64 call failed");
+ return 1;
+ }
+
+ if (fstat64 (fd, &st) != 0)
+ {
+ puts ("6th fstat failed");
+ return 1;
+ }
+
+ if (st.st_size != 4097ULL + 4294967295ULL + 2ULL)
+ {
+ printf ("file size after 1st fallocate64 call is %llu, expected %llu\n",
+ (unsigned long long int) st.st_size, 4097ULL + 4294967295ULL + 2ULL);
+ return 1;
+ }
+#endif
+ close (fd);
+
+ return 0;
+}
+
diff --git a/test/unistd/tst-fallocate64.c b/test/unistd/tst-fallocate64.c
new file mode 100644
index 000000000..720428f8f
--- /dev/null
+++ b/test/unistd/tst-fallocate64.c
@@ -0,0 +1,2 @@
+#define TST_FALLOCATE64
+#include "tst-fallocate.c"
diff --git a/test/unistd/tst-getconf.sh b/test/unistd/tst-getconf.sh
new file mode 100755
index 000000000..3a2aa4ea7
--- /dev/null
+++ b/test/unistd/tst-getconf.sh
@@ -0,0 +1,240 @@
+#! /bin/sh
+
+basedir="."
+
+# make sure to use the same locale everywhere.
+LC_ALL=C
+export LC_ALL
+LANG=C
+export LANG
+
+for suffix in _glibc ''
+do
+binary=$basedir/getconf$suffix
+logfile=$basedir/tst-getconf$suffix.out
+rm -f $logfile
+
+result=0
+while read name; do
+ case "$name" in
+ "#"*) continue;;
+ esac
+ echo -n "getconf $name: " >> $logfile
+ $binary "$name" 2>> $logfile >> $logfile
+ if test $? -ne 0; then
+ echo "*** $name FAILED" >> $logfile
+ result=1
+ fi
+done <<EOF
+AIO_LISTIO_MAX
+AIO_MAX
+AIO_PRIO_DELTA_MAX
+ARG_MAX
+ATEXIT_MAX
+BC_BASE_MAX
+BC_DIM_MAX
+BC_SCALE_MAX
+BC_STRING_MAX
+CHILD_MAX
+COLL_WEIGHTS_MAX
+DELAYTIMER_MAX
+EXPR_NEST_MAX
+HOST_NAME_MAX
+IOV_MAX
+LINE_MAX
+LOGIN_NAME_MAX
+NGROUPS_MAX
+MQ_OPEN_MAX
+MQ_PRIO_MAX
+OPEN_MAX
+_POSIX_ADVISORY_INFO
+_POSIX_BARRIERS
+_POSIX_ASYNCHRONOUS_IO
+_POSIX_BASE
+_POSIX_C_LANG_SUPPORT
+_POSIX_C_LANG_SUPPORT_R
+_POSIX_CLOCK_SELECTION
+_POSIX_CPUTIME
+_POSIX_DEVICE_IO
+_POSIX_DEVICE_SPECIFIC
+_POSIX_DEVICE_SPECIFIC_R
+_POSIX_FD_MGMT
+_POSIX_FIFO
+_POSIX_FILE_ATTRIBUTES
+_POSIX_FILE_LOCKING
+_POSIX_FILE_SYSTEM
+_POSIX_FSYNC
+_POSIX_JOB_CONTROL
+_POSIX_MAPPED_FILES
+_POSIX_MEMLOCK
+_POSIX_MEMLOCK_RANGE
+_POSIX_MEMORY_PROTECTION
+_POSIX_MESSAGE_PASSING
+_POSIX_MONOTONIC_CLOCK
+_POSIX_MULTI_PROCESS
+_POSIX_NETWORKING
+_POSIX_PIPE
+_POSIX_PRIORITIZED_IO
+_POSIX_PRIORITY_SCHEDULING
+_POSIX_READER_WRITER_LOCKS
+_POSIX_REALTIME_SIGNALS
+_POSIX_REGEXP
+_POSIX_SAVED_IDS
+_POSIX_SEMAPHORES
+_POSIX_SHARED_MEMORY_OBJECTS
+_POSIX_SHELL
+_POSIX_SIGNALS
+_POSIX_SINGLE_PROCESS
+_POSIX_SPAWN
+_POSIX_SPIN_LOCKS
+_POSIX_SPORADIC_SERVER
+_POSIX_SYNCHRONIZED_IO
+_POSIX_SYSTEM_DATABASE
+_POSIX_SYSTEM_DATABASE_R
+_POSIX_THREAD_ATTR_STACKADDR
+_POSIX_THREAD_ATTR_STACKSIZE
+_POSIX_THREAD_CPUTIME
+_POSIX_THREAD_PRIO_INHERIT
+_POSIX_THREAD_PRIO_PROTECT
+_POSIX_THREAD_PRIORITY_SCHEDULING
+_POSIX_THREAD_PROCESS_SHARED
+_POSIX_THREAD_SAFE_FUNCTIONS
+_POSIX_THREAD_SPORADIC_SERVER
+_POSIX_THREADS
+_POSIX_TIMEOUTS
+_POSIX_TIMERS
+_POSIX_TRACE
+_POSIX_TRACE_EVENT_FILTER
+_POSIX_TRACE_INHERIT
+_POSIX_TRACE_LOG
+_POSIX_TYPED_MEMORY_OBJECTS
+_POSIX_USER_GROUPS
+_POSIX_USER_GROUPS_R
+_POSIX_VERSION
+_POSIX_V7_ILP32_OFF32
+_POSIX_V7_ILP32_OFFBIG
+_POSIX_V7_LP64_OFF64
+_POSIX_V7_LPBIG_OFFBIG
+#_POSIX_V7_WIDTH_RESTRICTED_ENVS
+POSIX2_C_BIND
+POSIX2_C_DEV
+POSIX2_C_VERSION
+POSIX2_CHAR_TERM
+POSIX2_FORT_DEV
+POSIX2_FORT_RUN
+POSIX2_LOCALEDEF
+POSIX2_PBS
+POSIX2_PBS_ACCOUNTING
+POSIX2_PBS_LOCATE
+POSIX2_PBS_MESSAGE
+POSIX2_PBS_TRACK
+POSIX2_SW_DEV
+POSIX2_UPE
+POSIX2_VERSION
+_REGEX_VERSION
+PAGE_SIZE
+PAGESIZE
+PTHREAD_DESTRUCTOR_ITERATIONS
+PTHREAD_KEYS_MAX
+PTHREAD_STACK_MIN
+PTHREAD_THREADS_MAX
+RE_DUP_MAX
+RTSIG_MAX
+SEM_NSEMS_MAX
+SEM_VALUE_MAX
+SIGQUEUE_MAX
+STREAM_MAX
+SYMLOOP_MAX
+TIMER_MAX
+TTY_NAME_MAX
+TZNAME_MAX
+#_XBS5_ILP32_OFF32
+#_XBS5_ILP32_OFFBIG
+#_XBS5_LP64_OFF64
+#_XBS5_LPBIG_OFFBIG
+_XOPEN_CRYPT
+_XOPEN_ENH_I18N
+_XOPEN_LEGACY
+_XOPEN_REALTIME
+_XOPEN_REALTIME_THREADS
+_XOPEN_SHM
+_XOPEN_UNIX
+_XOPEN_VERSION
+_XOPEN_XCU_VERSION
+PATH
+#POSIX_V7_ILP32_OFF32_CFLAGS
+#POSIX_V7_ILP32_OFF32_LDFLAGS
+#POSIX_V7_ILP32_OFF32_LIBS
+#POSIX_V7_ILP32_OFF32_LINTFLAGS
+#POSIX_V7_ILP32_OFFBIG_CFLAGS
+#POSIX_V7_ILP32_OFFBIG_LDFLAGS
+#POSIX_V7_ILP32_OFFBIG_LIBS
+#POSIX_V7_ILP32_OFFBIG_LINTFLAGS
+#POSIX_V7_LP64_OFF64_CFLAGS
+#POSIX_V7_LP64_OFF64_LDFLAGS
+#POSIX_V7_LP64_OFF64_LIBS
+#POSIX_V7_LP64_OFF64_LINTFLAGS
+#POSIX_V7_LPBIG_OFFBIG_CFLAGS
+#POSIX_V7_LPBIG_OFFBIG_LDFLAGS
+#POSIX_V7_LPBIG_OFFBIG_LIBS
+#POSIX_V7_LPBIG_OFFBIG_LINTFLAGS
+#XBS5_ILP32_OFF32_CFLAGS
+#XBS5_ILP32_OFF32_LDFLAGS
+#XBS5_ILP32_OFF32_LIBS
+#XBS5_ILP32_OFF32_LINTFLAGS
+#XBS5_ILP32_OFFBIG_CFLAGS
+#XBS5_ILP32_OFFBIG_LDFLAGS
+#XBS5_ILP32_OFFBIG_LIBS
+#XBS5_ILP32_OFFBIG_LINTFLAGS
+#XBS5_LP64_OFF64_CFLAGS
+#XBS5_LP64_OFF64_LDFLAGS
+#XBS5_LP64_OFF64_LIBS
+#XBS5_LP64_OFF64_LINTFLAGS
+#XBS5_LPBIG_OFFBIG_CFLAGS
+#XBS5_LPBIG_OFFBIG_LDFLAGS
+#XBS5_LPBIG_OFFBIG_LIBS
+#XBS5_LPBIG_OFFBIG_LINTFLAGS
+_NPROCESSORS_ONLN
+_NPROCESSORS_CONF
+EOF
+
+while read name; do
+ echo -n "getconf $name /: " >> $logfile
+ $binary "$name" / 2>> $logfile >> $logfile
+ if test $? -ne 0; then
+ echo "*** $name FAILED" >> $logfile
+ result=1
+ fi
+done <<EOF
+FILESIZEBITS
+LINK_MAX
+MAX_CANON
+MAX_INPUT
+NAME_MAX
+PATH_MAX
+PIPE_BUF
+POSIX_ALLOC_SIZE_MIN
+POSIX_REC_INCR_XFER_SIZE
+POSIX_REC_MAX_XFER_SIZE
+POSIX_REC_MIN_XFER_SIZE
+POSIX_REC_XFER_ALIGN
+SYMLINK_MAX
+_POSIX_CHOWN_RESTRICTED
+_POSIX_NO_TRUNC
+_POSIX_VDISABLE
+_POSIX_ASYNC_IO
+_POSIX_PRIO_IO
+_POSIX_SYNC_IO
+EOF
+
+done
+exit $result
+
+# Preserve executable bits for this shell script.
+Local Variables:
+eval:(defun frobme () (set-file-modes buffer-file-name file-mode))
+eval:(make-local-variable 'file-mode)
+eval:(setq file-mode (file-modes (buffer-file-name)))
+eval:(make-local-variable 'after-save-hook)
+eval:(add-hook 'after-save-hook 'frobme)
+End:
diff --git a/test/unistd/tst-posix_fallocate.c b/test/unistd/tst-posix_fallocate.c
new file mode 100644
index 000000000..d41c604e8
--- /dev/null
+++ b/test/unistd/tst-posix_fallocate.c
@@ -0,0 +1,127 @@
+#include <fcntl.h>
+#include <sys/stat.h>
+
+#ifndef TST_POSIX_FALLOCATE64
+# define stat64 stat
+# define fstat64 fstat
+# else
+# ifndef O_LARGEFILE
+# error no O_LARGEFILE but you want to test with LFS enabled
+# endif
+#endif
+
+static void do_prepare (void);
+#define PREPARE(argc, argv) do_prepare ()
+static int do_test (void);
+#define TEST_FUNCTION do_test ()
+#include <test-skeleton.c>
+
+static int fd;
+static void
+do_prepare (void)
+{
+ fd = create_temp_file ("tst-posix_fallocate.", NULL);
+ if (fd == -1)
+ {
+ printf ("cannot create temporary file: %m\n");
+ exit (1);
+ }
+}
+
+
+static int
+do_test (void)
+{
+ struct stat64 st;
+
+ if (fstat64 (fd, &st) != 0)
+ {
+ puts ("1st fstat failed");
+ return 1;
+ }
+
+ if (st.st_size != 0)
+ {
+ puts ("file not created with size 0");
+ return 1;
+ }
+
+ if (posix_fallocate (fd, 512, 768) != 0)
+ {
+ puts ("1st posix_fallocate call failed");
+ return 1;
+ }
+
+ if (fstat64 (fd, &st) != 0)
+ {
+ puts ("2nd fstat failed");
+ return 1;
+ }
+
+ if (st.st_size != 512 + 768)
+ {
+ printf ("file size after 1st posix_fallocate call is %llu, expected %u\n",
+ (unsigned long long int) st.st_size, 512u + 768u);
+ return 1;
+ }
+
+ if (posix_fallocate (fd, 0, 1024) != 0)
+ {
+ puts ("2nd posix_fallocate call failed");
+ return 1;
+ }
+
+ if (fstat64 (fd, &st) != 0)
+ {
+ puts ("3rd fstat failed");
+ return 1;
+ }
+
+ if (st.st_size != 512 + 768)
+ {
+ puts ("file size changed in 2nd posix_fallocate");
+ return 1;
+ }
+
+ if (posix_fallocate (fd, 2048, 64) != 0)
+ {
+ puts ("3rd posix_fallocate call failed");
+ return 1;
+ }
+
+ if (fstat64 (fd, &st) != 0)
+ {
+ puts ("4th fstat failed");
+ return 1;
+ }
+
+ if (st.st_size != 2048 + 64)
+ {
+ printf ("file size after 3rd posix_fallocate call is %llu, expected %u\n",
+ (unsigned long long int) st.st_size, 2048u + 64u);
+ return 1;
+ }
+#ifdef TST_POSIX_FALLOCATE64
+ if (posix_fallocate64 (fd, 4097ULL, 4294967295ULL + 2ULL) != 0)
+ {
+ puts ("4th posix_fallocate call failed");
+ return 1;
+ }
+
+ if (fstat64 (fd, &st) != 0)
+ {
+ puts ("5th fstat failed");
+ return 1;
+ }
+
+ if (st.st_size != 4097ULL + 4294967295ULL + 2ULL)
+ {
+ printf ("file size after 4th posix_fallocate call is %llu, expected %llu\n",
+ (unsigned long long int) st.st_size, 4097ULL + 4294967295ULL + 2ULL);
+ return 1;
+ }
+#endif
+ close (fd);
+
+ return 0;
+}
diff --git a/test/unistd/tst-posix_fallocate64.c b/test/unistd/tst-posix_fallocate64.c
new file mode 100644
index 000000000..b1ee0ffdd
--- /dev/null
+++ b/test/unistd/tst-posix_fallocate64.c
@@ -0,0 +1,2 @@
+#define TST_POSIX_FALLOCATE64
+#include "tst-posix_fallocate.c"
diff --git a/test/unistd/tst-preadwrite.c b/test/unistd/tst-preadwrite.c
index 281044858..66a1c0aa3 100644
--- a/test/unistd/tst-preadwrite.c
+++ b/test/unistd/tst-preadwrite.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/>. */
#include <errno.h>
#include <error.h>
@@ -44,7 +43,7 @@ extern int do_test (int argc, char *argv[]);
#define TIMEOUT 20 /* sec */
/* This defines the `main' function and some more. */
-#include <test-skeleton.c>
+#include "../test-skeleton.c"
/* These are for the temporary file we generate. */
char *name;
diff --git a/test/unistd/tst-preadwrite64.c b/test/unistd/tst-preadwrite64.c
index 57098e864..a0ec021c6 100644
--- a/test/unistd/tst-preadwrite64.c
+++ b/test/unistd/tst-preadwrite64.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/>. */
#define PREAD pread64
#define PWRITE pwrite64
diff --git a/test/unistd/tst-pselect.c b/test/unistd/tst-pselect.c
new file mode 100644
index 000000000..cab945119
--- /dev/null
+++ b/test/unistd/tst-pselect.c
@@ -0,0 +1,51 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/select.h>
+
+// our SIGALRM handler
+void handler(int signum) {
+ (void)signum;
+ puts("got signal\n");
+}
+
+static int
+do_test (void)
+{
+ int rc;
+ sigset_t wait_mask, mask_sigchld;
+ struct sigaction act;
+
+ // block SIGALRM. We want to handle it only when we're ready
+ sigemptyset(&mask_sigchld);
+ sigaddset(&mask_sigchld, SIGALRM);
+ sigprocmask(SIG_BLOCK, &mask_sigchld, &wait_mask);
+ sigdelset(&wait_mask, SIGALRM);
+
+ // register a signal handler so we can see when the signal arrives
+ memset(&act, 0, sizeof(act));
+ sigemptyset(&act.sa_mask); // just in case an empty set isn't all 0's (total paranoia)
+ act.sa_handler = handler;
+ sigaction(SIGALRM, &act, NULL);
+
+ // send ourselves a SIGARLM. It will pend until we unblock that signal in pselect()
+ printf("sending ourselves a signal\n");
+ kill(getpid(), SIGALRM);
+
+ printf("signal is pending; calling pselect()\n");
+ rc = pselect(0, NULL, NULL, NULL, NULL, &wait_mask);
+ if (rc != -1 || errno != EINTR) {
+ int e = errno;
+ printf("pselect() returned %d, errno %d (%s)\n", rc, e, strerror(e));
+ exit(1);
+ }
+
+ return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include <test-skeleton.c>
diff --git a/test/unistd/tstgetopt.c b/test/unistd/tstgetopt.c
index 97ae2ef25..1c1263e67 100644
--- a/test/unistd/tstgetopt.c
+++ b/test/unistd/tstgetopt.c
@@ -21,7 +21,7 @@ main (int argc, char **argv)
char *cvalue = NULL;
int Cflag = 0;
int nflag = 0;
- int index;
+ int idx;
int c;
int result = 0;
@@ -67,8 +67,8 @@ main (int argc, char **argv)
result |= (aflag != 1 || bflag != 1 || cvalue == NULL
|| strcmp (cvalue, "foobar") != 0 || Cflag != 3 || nflag != 1);
- for (index = optind; index < argc; index++)
- printf ("Non-option argument %s\n", argv[index]);
+ for (idx = optind; idx < argc; idx++)
+ printf ("Non-option argument %s\n", argv[idx]);
result |= optind + 1 != argc || strcmp (argv[optind], "random") != 0;
diff --git a/utils/.gitignore b/utils/.gitignore
new file mode 100644
index 000000000..7cdfa90c1
--- /dev/null
+++ b/utils/.gitignore
@@ -0,0 +1,12 @@
+getconf
+getconf.host
+iconv
+iconv.host
+ldconfig
+ldconfig.host
+ldd
+ldd.host
+locale
+locale.host
+getconf
+getconf.host
diff --git a/utils/Makefile.in b/utils/Makefile.in
index 611e07efa..6349aa73d 100644
--- a/utils/Makefile.in
+++ b/utils/Makefile.in
@@ -1,45 +1,81 @@
# Makefile for uClibc
#
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2009 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-#
-CFLAGS-utils := -DNOT_IN_libc $(SSP_ALL_CFLAGS) -B$(top_builddir)lib -Wl,-rpath-link,$(top_builddir)lib
+subdirs += utils
-CFLAGS-utils-common := -I$(top_srcdir)ldso/include -DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" -DUCLIBC_LDSO=$(UCLIBC_LDSO)
-CFLAGS-utils-shared := $(PIEFLAG) $(LDPIEFLAG)
+# "make utils" flags
+
+CFLAGS-utils := \
+ $(SSP_ALL_CFLAGS) \
+ -I$(top_srcdir)ldso/ldso/$(TARGET_ARCH) \
+ -I$(top_srcdir)ldso/include \
+ -DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \
+ -DUCLIBC_LDSO=\"$(UCLIBC_LDSO)\" \
+ -I$(top_srcdir)/$(KERNEL_HEADERS) \
+ -DNOT_IN_libc \
+ -B$(top_builddir)lib \
+ -Wl,-rpath-link,$(top_builddir)lib
-CFLAGS-ldconfig := $(CFLAGS-utils-common)
+ifeq ($(UCLIBC_BUILD_PIE),y)
+CFLAGS-utils-shared := $(PIEFLAG) $(LDPIEFLAG)
+else
+CFLAGS-utils-shared :=
+endif
+CFLAGS-ldconfig := -DBUILDING_LINKAGE
ifeq ($(UCLIBC_STATIC_LDCONFIG),y)
CFLAGS-ldconfig += -static
else
CFLAGS-ldconfig += $(CFLAGS-utils-shared)
endif
-CFLAGS-ldd := $(CFLAGS-utils-common) $(CFLAGS-utils-shared)
+CFLAGS-ldd := $(CFLAGS-utils-shared) -DBUILDING_LINKAGE
-# needs CFLAGS-utils explicitely, because the source file is not located in utils
-CFLAGS-iconv := $(CFLAGS-utils) $(CFLAGS-utils-shared) -DL_iconv_main
-
-CFLAGS-readelf := $(CFLAGS-utils-shared)
+# Need CFLAGS-utils explicitly, because the source file is not located in utils
+CFLAGS-iconv := $(CFLAGS-utils) \
+ $(CFLAGS-utils-shared) \
+ -I$(top_srcdir)libc/misc/wchar
CFLAGS-locale := $(CFLAGS-utils)
-
-BUILD_CFLAGS-utils := -include $(top_srcdir)include/elf.h
-
-BUILD_CFLAGS-utils-common := $(CFLAGS-utils-common)
-
-ifeq ($(LDSO_CACHE_SUPPORT),y)
-BUILD_CFLAGS-utils-common += -D__LDSO_CACHE_SUPPORT__=1
-endif
-
-BUILD_CFLAGS-ldconfig.host := $(BUILD_CFLAGS-utils-common)
-
-BUILD_CFLAGS-ldd.host := $(BUILD_CFLAGS-utils-common)
-
-BUILD_LDFLAGS-utils := -Wl,-s
+CFLAGS-getconf :=$(CFLAGS-utils) \
+ -DGETCONF_DIR='"$(CURDIR)"'
+
+# "make hostutils" flags
+
+UTILS_CONFIG_FLAGS-y :=
+UTILS_CONFIG_FLAGS-$(LDSO_CACHE_SUPPORT) += -D__LDSO_CACHE_SUPPORT__
+UTILS_CONFIG_FLAGS-$(LDSO_LDD_SUPPORT) += -D__LDSO_LDD_SUPPORT__
+UTILS_CONFIG_FLAGS-$(LDSO_STANDALONE_SUPPORT) += -D__LDSO_STANDALONE_SUPPORT__
+
+BUILD_CFLAGS-utils := \
+ -DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \
+ -DUCLIBC_LDSO=\"$(UCLIBC_LDSO)\" \
+ -DARCH_NATIVE_BIT=$(ARCH_NATIVE_BIT) \
+ $(UTILS_CONFIG_FLAGS-y)
+BUILD_CFLAGS-ldconfig.host := \
+ -DBUILDING_LINKAGE \
+ -I$(top_srcdir)ldso/ldso/$(TARGET_ARCH) \
+ -I$(top_srcdir)ldso/include
+BUILD_CFLAGS-ldd.host := \
+ -DBUILDING_LINKAGE \
+ -I$(top_srcdir)ldso/ldso/$(TARGET_ARCH) \
+ -I$(top_srcdir)ldso/include \
+ -include $(top_srcdir)include/elf.h
+BUILD_CFLAGS-locale.host := \
+ -DNOT_IN_libc \
+ -I$(top_srcdir)utils/ \
+ -I.
+BUILD_CFLAGS-iconv.host := \
+ -include $(top_builddir)extra/locale/c8tables.h \
+ -I$(top_srcdir)libc/misc/wchar -DL_iconv_main
+
+BUILD_CFLAGS-getconf.host := \
+ -DGETCONF_DIR='"$(CURDIR)"'
+
+# Rules
utils_DIR := $(top_srcdir)utils
utils_OUT := $(top_builddir)utils
@@ -47,56 +83,60 @@ utils_OUT := $(top_builddir)utils
DEPS-ldconfig := $(utils_DIR)/chroot_realpath.c
DEPS-ldconfig.host := $(DEPS-ldconfig)
-utils_OBJ := readelf
+utils_OBJ := getconf
ifeq ($(HAVE_SHARED),y)
utils_OBJ += ldconfig ldd
endif
-utils_ICONV_OBJ =
-utils_LOCALE_OBJ =
+utils_LOCALE_OBJ :=
ifeq ($(UCLIBC_HAS_LOCALE),y)
-utils_ICONV_OBJ := $(utils_OUT)/iconv
-utils_LOCALE_OBJ := $(utils_OUT)/locale
+utils_OBJ += iconv
+#utils_LOCALE_OBJ += $(utils_OUT)/locale
endif
utils_OBJ := $(patsubst %,$(utils_OUT)/%,$(utils_OBJ))
hostutils_OBJ := $(patsubst %,%.host,$(utils_OBJ))
+hostutils_LOCALE_OBJ := $(patsubst %,%.host,$(utils_LOCALE_OBJ))
-utils: $(utils_OBJ) $(utils_ICONV_OBJ) $(utils_LOCALE_OBJ)
+utils: $(utils_OBJ) $(utils_LOCALE_OBJ)
# NOTE: We build the utils AFTER we have a uClibc-targeted toolchain.
$(utils_OBJ): $(utils_OUT)/% : $(utils_DIR)/%.c | $(libc)
$(compile.u)
-$(utils_OUT)/iconv: $(top_srcdir)libc/misc/wchar/wchar.c | $(libc)
- $(compile.u)
-
$(utils_OUT)/locale: $(top_srcdir)extra/locale/programs/locale.c | $(libc)
$(compile.u)
-hostutils: $(hostutils_OBJ)
+$(utils_OUT)/locale.host: $(top_srcdir)extra/locale/programs/locale.c | $(libc)
+ $(hcompile.u)
+
+hostutils: $(hostutils_OBJ) $(hostutils_LOCALE_OBJ)
$(hostutils_OBJ): $(utils_OUT)/%.host : $(utils_DIR)/%.c
$(hcompile.u)
+
install-y += utils_install
-utils_install: utils
- $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)usr/bin
- #$(INSTALL) -m 755 $(utils_OUT)/readelf $(PREFIX)$(RUNTIME_PREFIX)usr/bin/readelf
+# This installs both utils and hostutils, so doesn't depend on either.
+
+utils_install: $(addsuffix $(DOTHOST), $(utils_OBJ) $(utils_LOCALE_OBJ))
+ $(Q)$(INSTALL) -D -m 755 $(utils_OUT)/getconf$(DOTHOST) $(PREFIX)$(DEVEL_PREFIX)bin/getconf
ifeq ($(HAVE_SHARED),y)
- $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)sbin
- $(INSTALL) -m 755 $(utils_OUT)/ldd $(PREFIX)$(RUNTIME_PREFIX)usr/bin/ldd
- $(INSTALL) -m 755 $(utils_OUT)/ldconfig $(PREFIX)$(RUNTIME_PREFIX)sbin/ldconfig
+ $(Q)$(INSTALL) -D -m 755 $(utils_OUT)/ldd$(DOTHOST) $(PREFIX)$(DEVEL_PREFIX)bin/ldd
+ $(Q)$(INSTALL) -D -m 755 $(utils_OUT)/ldconfig$(DOTHOST) $(PREFIX)$(RUNTIME_PREFIX)sbin/ldconfig
endif
ifeq ($(UCLIBC_HAS_LOCALE),y)
- $(INSTALL) -m 755 $(utils_OUT)/iconv $(PREFIX)$(RUNTIME_PREFIX)usr/bin/iconv
- $(INSTALL) -m 755 $(utils_OUT)/locale $(PREFIX)$(RUNTIME_PREFIX)usr/bin/locale
+ $(Q)$(INSTALL) -D -m 755 $(utils_OUT)/iconv$(DOTHOST) $(PREFIX)$(DEVEL_PREFIX)bin/iconv
+ #$(Q)$(INSTALL) -m 755 $(utils_OUT)/locale$(DOTHOST) $(PREFIX)$(DEVEL_PREFIX)bin/locale
endif
-objclean-y += utils_clean
-utils_clean:
- $(RM) $(utils_OUT)/{ldconfig,ldd,readelf,iconv,locale,*.host}
+objclean-y += CLEAN_utils
+
+CLEAN_utils:
+ $(do_rm) $(addprefix $(utils_OUT)/, getconf iconv ldconfig ldd locale *.host)
+ $(Q)# This is a hack..
+ $(Q)$(RM) $(utils_OUT)/.*.dep
diff --git a/utils/bswap.h b/utils/bswap.h
index 666b80a73..0047e4e98 100644
--- a/utils/bswap.h
+++ b/utils/bswap.h
@@ -6,40 +6,6 @@
#ifndef _BSWAP_H
#define _BSWAP_H 1
-#if !defined(__BYTE_ORDER) && defined(BYTE_ORDER)
-# define __BYTE_ORDER BYTE_ORDER
-# if !defined(__BIG_ENDIAN) && defined(BIG_ENDIAN)
-# define __BIG_ENDIAN BIG_ENDIAN
-# endif
-# if !defined(__LITTLE_ENDIAN) && defined(LITTLE_ENDIAN)
-# define __LITTLE_ENDIAN LITTLE_ENDIAN
-# endif
-#endif
-
-#ifndef __BYTE_ORDER
-# ifdef __linux__
-# include <endian.h>
-# else
-# define __LITTLE_ENDIAN 1234 /* least-significant byte first (vax, pc) */
-# define __BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */
-# define __PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp) */
-
-# if defined(sun386) || defined(i386) || defined(__LITTLE_ENDIAN__)
-# define __BYTE_ORDER __LITTLE_ENDIAN
-# endif
-
-# if defined(sparc) || defined(__BIG_ENDIAN__)
-# define __BYTE_ORDER __BIG_ENDIAN
-# endif
-
-# endif /* __linux__ */
-#endif /* __BYTE_ORDER */
-
-
-#ifndef __BYTE_ORDER
-# error "Undefined __BYTE_ORDER"
-#endif
-
#ifdef __linux__
# include <byteswap.h>
#else
@@ -56,6 +22,24 @@ static __inline__ uint32_t bswap_32(uint32_t x)
(((x) & 0x0000ff00) << 8) | \
(((x) & 0x000000ff) << 24));
}
+static __inline__ uint64_t bswap_64(uint64_t x)
+{
+#define _uswap_64(x, sfx) \
+ return ((((x) & 0xff00000000000000##sfx) >> 56) | \
+ (((x) & 0x00ff000000000000##sfx) >> 40) | \
+ (((x) & 0x0000ff0000000000##sfx) >> 24) | \
+ (((x) & 0x000000ff00000000##sfx) >> 8) | \
+ (((x) & 0x00000000ff000000##sfx) << 8) | \
+ (((x) & 0x0000000000ff0000##sfx) << 24) | \
+ (((x) & 0x000000000000ff00##sfx) << 40) | \
+ (((x) & 0x00000000000000ff##sfx) << 56));
+#if defined(__GNUC__)
+ _uswap_64(x, ull)
+#else
+ _uswap_64(x, )
+#endif
+#undef _uswap_64
+}
#endif
#endif
diff --git a/utils/chroot_realpath.c b/utils/chroot_realpath.c
index 0785c6c5b..f17a2184f 100644
--- a/utils/chroot_realpath.c
+++ b/utils/chroot_realpath.c
@@ -1,5 +1,5 @@
/*
- * chroot_realpath.c -- reslove pathname as if inside chroot
+ * chroot_realpath.c -- resolve pathname as if inside chroot
* Based on realpath.c Copyright (C) 1993 Rick Sladkey <jrs@world.std.com>
*
* This program is free software; you can redistribute it and/or
@@ -14,37 +14,19 @@
*
* You should have received a copy of the GNU Lesser General Public
* License along with this 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/>.
*
* 2005/09/12: Dan Howell (modified from realpath.c to emulate chroot)
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <sys/types.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <string.h>
-#include <strings.h>
-#include <limits.h> /* for PATH_MAX */
-#include <sys/param.h> /* for MAXPATHLEN */
-#include <errno.h>
-#ifndef __set_errno
-#define __set_errno(val) ((errno) = (val))
-#endif
-
-#include <sys/stat.h> /* for S_IFLNK */
-
-#ifndef PATH_MAX
-#define PATH_MAX _POSIX_PATH_MAX
-#endif
+#include "porting.h"
#define MAX_READLINKS 32
-char *chroot_realpath(const char *chroot, const char *path,
+char *chroot_realpath(const char *root, const char *path,
+ char resolved_path[]);
+
+char *chroot_realpath(const char *root, const char *path,
char resolved_path[])
{
char copy_path[PATH_MAX];
@@ -58,16 +40,16 @@ char *chroot_realpath(const char *chroot, const char *path,
int chroot_len;
/* Trivial case. */
- if (chroot == NULL || *chroot == '\0' ||
- (*chroot == '/' && chroot[1] == '\0')) {
+ if (root == NULL || *root == '\0' ||
+ (*root == '/' && root[1] == '\0')) {
strcpy(resolved_path, path);
return resolved_path;
}
- chroot_len = strlen(chroot);
+ chroot_len = strlen(root);
if (chroot_len + strlen(path) >= PATH_MAX - 3) {
- __set_errno(ENAMETOOLONG);
+ errno = ENAMETOOLONG;
return NULL;
}
@@ -77,7 +59,7 @@ char *chroot_realpath(const char *chroot, const char *path,
max_path = copy_path + PATH_MAX - chroot_len - 3;
/* Start with the chroot path. */
- strcpy(new_path, chroot);
+ strcpy(new_path, root);
new_path += chroot_len;
while (*new_path == '/' && new_path > got_path)
new_path--;
@@ -112,7 +94,7 @@ char *chroot_realpath(const char *chroot, const char *path,
/* Safely copy the next pathname component. */
while (*path != '\0' && *path != '/') {
if (path > max_path) {
- __set_errno(ENAMETOOLONG);
+ errno = ENAMETOOLONG;
return NULL;
}
*new_path++ = *path++;
@@ -123,7 +105,7 @@ char *chroot_realpath(const char *chroot, const char *path,
#ifdef S_IFLNK
/* Protect against infinite loops. */
if (readlinks++ > MAX_READLINKS) {
- __set_errno(ELOOP);
+ errno = ELOOP;
return NULL;
}
/* See if latest pathname component is a symlink. */
@@ -148,7 +130,7 @@ char *chroot_realpath(const char *chroot, const char *path,
while (*(--new_path) != '/') ;
/* Safe sex check. */
if (strlen(path) + n >= PATH_MAX - 2) {
- __set_errno(ENAMETOOLONG);
+ errno = ENAMETOOLONG;
return NULL;
}
/* Insert symlink contents into path. */
diff --git a/utils/getconf.c b/utils/getconf.c
new file mode 100644
index 000000000..3dd3d75d9
--- /dev/null
+++ b/utils/getconf.c
@@ -0,0 +1,1335 @@
+/* Copyright (C) 1991, 92, 1995-2008, 2009 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ 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; 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, see <http://www.gnu.org/licenses/>. */
+
+#define _GNU_SOURCE 1
+#include "porting.h"
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#define PACKAGE "getconf regression test"
+#undef VERSION
+#define VERSION ""
+#define _(x) x
+#define error(status, errnum, fmt, ...) \
+ {fprintf(stderr, fmt "\n", ## __VA_ARGS__); exit(status);}
+
+
+struct conf
+ {
+ const char *name;
+ const int call_name;
+ const enum { SYSCONF, CONFSTR, PATHCONF } call;
+ };
+
+static const struct conf vars[] =
+ {
+#ifdef _PC_LINK_MAX
+ { "LINK_MAX", _PC_LINK_MAX, PATHCONF },
+#endif
+#ifdef _PC_LINK_MAX
+ { "_POSIX_LINK_MAX", _PC_LINK_MAX, PATHCONF },
+#endif
+#ifdef _PC_MAX_CANON
+ { "MAX_CANON", _PC_MAX_CANON, PATHCONF },
+#endif
+#ifdef _PC_MAX_CANON
+ { "_POSIX_MAX_CANON", _PC_MAX_CANON, PATHCONF },
+#endif
+#ifdef _PC_MAX_INPUT
+ { "MAX_INPUT", _PC_MAX_INPUT, PATHCONF },
+#endif
+#ifdef _PC_MAX_INPUT
+ { "_POSIX_MAX_INPUT", _PC_MAX_INPUT, PATHCONF },
+#endif
+#ifdef _PC_NAME_MAX
+ { "NAME_MAX", _PC_NAME_MAX, PATHCONF },
+#endif
+#ifdef _PC_NAME_MAX
+ { "_POSIX_NAME_MAX", _PC_NAME_MAX, PATHCONF },
+#endif
+#ifdef _PC_PATH_MAX
+ { "PATH_MAX", _PC_PATH_MAX, PATHCONF },
+#endif
+#ifdef _PC_PATH_MAX
+ { "_POSIX_PATH_MAX", _PC_PATH_MAX, PATHCONF },
+#endif
+#ifdef _PC_PIPE_BUF
+ { "PIPE_BUF", _PC_PIPE_BUF, PATHCONF },
+#endif
+#ifdef _PC_PIPE_BUF
+ { "_POSIX_PIPE_BUF", _PC_PIPE_BUF, PATHCONF },
+#endif
+#ifdef _PC_SOCK_MAXBUF
+ { "SOCK_MAXBUF", _PC_SOCK_MAXBUF, PATHCONF },
+#endif
+#ifdef _PC_ASYNC_IO
+ { "_POSIX_ASYNC_IO", _PC_ASYNC_IO, PATHCONF },
+#endif
+#ifdef _PC_CHOWN_RESTRICTED
+ { "_POSIX_CHOWN_RESTRICTED", _PC_CHOWN_RESTRICTED, PATHCONF },
+#endif
+#ifdef _PC_NO_TRUNC
+ { "_POSIX_NO_TRUNC", _PC_NO_TRUNC, PATHCONF },
+#endif
+#ifdef _PC_PRIO_IO
+ { "_POSIX_PRIO_IO", _PC_PRIO_IO, PATHCONF },
+#endif
+#ifdef _PC_SYNC_IO
+ { "_POSIX_SYNC_IO", _PC_SYNC_IO, PATHCONF },
+#endif
+#ifdef _PC_VDISABLE
+ { "_POSIX_VDISABLE", _PC_VDISABLE, PATHCONF },
+#endif
+
+#ifdef _SC_ARG_MAX
+ { "ARG_MAX", _SC_ARG_MAX, SYSCONF },
+#endif
+#ifdef _SC_ATEXIT_MAX
+ { "ATEXIT_MAX", _SC_ATEXIT_MAX, SYSCONF },
+#endif
+#ifdef _SC_CHAR_BIT
+ { "CHAR_BIT", _SC_CHAR_BIT, SYSCONF },
+#endif
+#ifdef _SC_CHAR_MAX
+ { "CHAR_MAX", _SC_CHAR_MAX, SYSCONF },
+#endif
+#ifdef _SC_CHAR_MIN
+ { "CHAR_MIN", _SC_CHAR_MIN, SYSCONF },
+#endif
+#ifdef _SC_CHILD_MAX
+ { "CHILD_MAX", _SC_CHILD_MAX, SYSCONF },
+#endif
+#ifdef _SC_CLK_TCK
+ { "CLK_TCK", _SC_CLK_TCK, SYSCONF },
+#endif
+#ifdef _SC_INT_MAX
+ { "INT_MAX", _SC_INT_MAX, SYSCONF },
+#endif
+#ifdef _SC_INT_MIN
+ { "INT_MIN", _SC_INT_MIN, SYSCONF },
+#endif
+#ifdef _SC_UIO_MAXIOV
+ { "IOV_MAX", _SC_UIO_MAXIOV, SYSCONF },
+#endif
+#ifdef _SC_LOGIN_NAME_MAX
+ { "LOGNAME_MAX", _SC_LOGIN_NAME_MAX, SYSCONF },
+#endif
+#ifdef _SC_LONG_BIT
+ { "LONG_BIT", _SC_LONG_BIT, SYSCONF },
+#endif
+#ifdef _SC_MB_LEN_MAX
+ { "MB_LEN_MAX", _SC_MB_LEN_MAX, SYSCONF },
+#endif
+#ifdef _SC_NGROUPS_MAX
+ { "NGROUPS_MAX", _SC_NGROUPS_MAX, SYSCONF },
+#endif
+#ifdef _SC_NL_ARGMAX
+ { "NL_ARGMAX", _SC_NL_ARGMAX, SYSCONF },
+#endif
+#ifdef _SC_NL_LANGMAX
+ { "NL_LANGMAX", _SC_NL_LANGMAX, SYSCONF },
+#endif
+#ifdef _SC_NL_MSGMAX
+ { "NL_MSGMAX", _SC_NL_MSGMAX, SYSCONF },
+#endif
+#ifdef _SC_NL_NMAX
+ { "NL_NMAX", _SC_NL_NMAX, SYSCONF },
+#endif
+#ifdef _SC_NL_SETMAX
+ { "NL_SETMAX", _SC_NL_SETMAX, SYSCONF },
+#endif
+#ifdef _SC_NL_TEXTMAX
+ { "NL_TEXTMAX", _SC_NL_TEXTMAX, SYSCONF },
+#endif
+#ifdef _SC_GETGR_R_SIZE_MAX
+ { "NSS_BUFLEN_GROUP", _SC_GETGR_R_SIZE_MAX, SYSCONF },
+#endif
+#ifdef _SC_GETPW_R_SIZE_MAX
+ { "NSS_BUFLEN_PASSWD", _SC_GETPW_R_SIZE_MAX, SYSCONF },
+#endif
+#ifdef _SC_NZERO
+ { "NZERO", _SC_NZERO, SYSCONF },
+#endif
+#ifdef _SC_OPEN_MAX
+ { "OPEN_MAX", _SC_OPEN_MAX, SYSCONF },
+#endif
+#ifdef _SC_PAGESIZE
+ { "PAGESIZE", _SC_PAGESIZE, SYSCONF },
+#endif
+#ifdef _SC_PAGESIZE
+ { "PAGE_SIZE", _SC_PAGESIZE, SYSCONF },
+#endif
+#ifdef _SC_PASS_MAX
+ { "PASS_MAX", _SC_PASS_MAX, SYSCONF },
+#endif
+#ifdef _SC_THREAD_DESTRUCTOR_ITERATIONS
+ { "PTHREAD_DESTRUCTOR_ITERATIONS", _SC_THREAD_DESTRUCTOR_ITERATIONS, SYSCONF },
+#endif
+#ifdef _SC_THREAD_KEYS_MAX
+ { "PTHREAD_KEYS_MAX", _SC_THREAD_KEYS_MAX, SYSCONF },
+#endif
+#ifdef _SC_THREAD_STACK_MIN
+ { "PTHREAD_STACK_MIN", _SC_THREAD_STACK_MIN, SYSCONF },
+#endif
+#ifdef _SC_THREAD_THREADS_MAX
+ { "PTHREAD_THREADS_MAX", _SC_THREAD_THREADS_MAX, SYSCONF },
+#endif
+#ifdef _SC_SCHAR_MAX
+ { "SCHAR_MAX", _SC_SCHAR_MAX, SYSCONF },
+#endif
+#ifdef _SC_SCHAR_MIN
+ { "SCHAR_MIN", _SC_SCHAR_MIN, SYSCONF },
+#endif
+#ifdef _SC_SHRT_MAX
+ { "SHRT_MAX", _SC_SHRT_MAX, SYSCONF },
+#endif
+#ifdef _SC_SHRT_MIN
+ { "SHRT_MIN", _SC_SHRT_MIN, SYSCONF },
+#endif
+#ifdef _SC_SSIZE_MAX
+ { "SSIZE_MAX", _SC_SSIZE_MAX, SYSCONF },
+#endif
+#ifdef _SC_TTY_NAME_MAX
+ { "TTY_NAME_MAX", _SC_TTY_NAME_MAX, SYSCONF },
+#endif
+#ifdef _SC_TZNAME_MAX
+ { "TZNAME_MAX", _SC_TZNAME_MAX, SYSCONF },
+#endif
+#ifdef _SC_UCHAR_MAX
+ { "UCHAR_MAX", _SC_UCHAR_MAX, SYSCONF },
+#endif
+#ifdef _SC_UINT_MAX
+ { "UINT_MAX", _SC_UINT_MAX, SYSCONF },
+#endif
+#ifdef _SC_UIO_MAXIOV
+ { "UIO_MAXIOV", _SC_UIO_MAXIOV, SYSCONF },
+#endif
+#ifdef _SC_ULONG_MAX
+ { "ULONG_MAX", _SC_ULONG_MAX, SYSCONF },
+#endif
+#ifdef _SC_USHRT_MAX
+ { "USHRT_MAX", _SC_USHRT_MAX, SYSCONF },
+#endif
+#ifdef _SC_WORD_BIT
+ { "WORD_BIT", _SC_WORD_BIT, SYSCONF },
+#endif
+#ifdef _SC_AVPHYS_PAGES
+ { "_AVPHYS_PAGES", _SC_AVPHYS_PAGES, SYSCONF },
+#endif
+#ifdef _SC_NPROCESSORS_CONF
+ { "_NPROCESSORS_CONF", _SC_NPROCESSORS_CONF, SYSCONF },
+#endif
+#ifdef _SC_NPROCESSORS_ONLN
+ { "_NPROCESSORS_ONLN", _SC_NPROCESSORS_ONLN, SYSCONF },
+#endif
+#ifdef _SC_PHYS_PAGES
+ { "_PHYS_PAGES", _SC_PHYS_PAGES, SYSCONF },
+#endif
+#ifdef _SC_ARG_MAX
+ { "_POSIX_ARG_MAX", _SC_ARG_MAX, SYSCONF },
+#endif
+#ifdef _SC_ASYNCHRONOUS_IO
+ { "_POSIX_ASYNCHRONOUS_IO", _SC_ASYNCHRONOUS_IO, SYSCONF },
+#endif
+#ifdef _SC_CHILD_MAX
+ { "_POSIX_CHILD_MAX", _SC_CHILD_MAX, SYSCONF },
+#endif
+#ifdef _SC_FSYNC
+ { "_POSIX_FSYNC", _SC_FSYNC, SYSCONF },
+#endif
+#ifdef _SC_JOB_CONTROL
+ { "_POSIX_JOB_CONTROL", _SC_JOB_CONTROL, SYSCONF },
+#endif
+#ifdef _SC_MAPPED_FILES
+ { "_POSIX_MAPPED_FILES", _SC_MAPPED_FILES, SYSCONF },
+#endif
+#ifdef _SC_MEMLOCK
+ { "_POSIX_MEMLOCK", _SC_MEMLOCK, SYSCONF },
+#endif
+#ifdef _SC_MEMLOCK_RANGE
+ { "_POSIX_MEMLOCK_RANGE", _SC_MEMLOCK_RANGE, SYSCONF },
+#endif
+#ifdef _SC_MEMORY_PROTECTION
+ { "_POSIX_MEMORY_PROTECTION", _SC_MEMORY_PROTECTION, SYSCONF },
+#endif
+#ifdef _SC_MESSAGE_PASSING
+ { "_POSIX_MESSAGE_PASSING", _SC_MESSAGE_PASSING, SYSCONF },
+#endif
+#ifdef _SC_NGROUPS_MAX
+ { "_POSIX_NGROUPS_MAX", _SC_NGROUPS_MAX, SYSCONF },
+#endif
+#ifdef _SC_OPEN_MAX
+ { "_POSIX_OPEN_MAX", _SC_OPEN_MAX, SYSCONF },
+#endif
+#ifdef _SC_PII
+ { "_POSIX_PII", _SC_PII, SYSCONF },
+#endif
+#ifdef _SC_PII_INTERNET
+ { "_POSIX_PII_INTERNET", _SC_PII_INTERNET, SYSCONF },
+#endif
+#ifdef _SC_PII_INTERNET_DGRAM
+ { "_POSIX_PII_INTERNET_DGRAM", _SC_PII_INTERNET_DGRAM, SYSCONF },
+#endif
+#ifdef _SC_PII_INTERNET_STREAM
+ { "_POSIX_PII_INTERNET_STREAM", _SC_PII_INTERNET_STREAM, SYSCONF },
+#endif
+#ifdef _SC_PII_OSI
+ { "_POSIX_PII_OSI", _SC_PII_OSI, SYSCONF },
+#endif
+#ifdef _SC_PII_OSI_CLTS
+ { "_POSIX_PII_OSI_CLTS", _SC_PII_OSI_CLTS, SYSCONF },
+#endif
+#ifdef _SC_PII_OSI_COTS
+ { "_POSIX_PII_OSI_COTS", _SC_PII_OSI_COTS, SYSCONF },
+#endif
+#ifdef _SC_PII_OSI_M
+ { "_POSIX_PII_OSI_M", _SC_PII_OSI_M, SYSCONF },
+#endif
+#ifdef _SC_PII_SOCKET
+ { "_POSIX_PII_SOCKET", _SC_PII_SOCKET, SYSCONF },
+#endif
+#ifdef _SC_PII_XTI
+ { "_POSIX_PII_XTI", _SC_PII_XTI, SYSCONF },
+#endif
+#ifdef _SC_POLL
+ { "_POSIX_POLL", _SC_POLL, SYSCONF },
+#endif
+#ifdef _SC_PRIORITIZED_IO
+ { "_POSIX_PRIORITIZED_IO", _SC_PRIORITIZED_IO, SYSCONF },
+#endif
+#ifdef _SC_PRIORITY_SCHEDULING
+ { "_POSIX_PRIORITY_SCHEDULING", _SC_PRIORITY_SCHEDULING, SYSCONF },
+#endif
+#ifdef _SC_REALTIME_SIGNALS
+ { "_POSIX_REALTIME_SIGNALS", _SC_REALTIME_SIGNALS, SYSCONF },
+#endif
+#ifdef _SC_SAVED_IDS
+ { "_POSIX_SAVED_IDS", _SC_SAVED_IDS, SYSCONF },
+#endif
+#ifdef _SC_SELECT
+ { "_POSIX_SELECT", _SC_SELECT, SYSCONF },
+#endif
+#ifdef _SC_SEMAPHORES
+ { "_POSIX_SEMAPHORES", _SC_SEMAPHORES, SYSCONF },
+#endif
+#ifdef _SC_SHARED_MEMORY_OBJECTS
+ { "_POSIX_SHARED_MEMORY_OBJECTS", _SC_SHARED_MEMORY_OBJECTS, SYSCONF },
+#endif
+#ifdef _SC_SSIZE_MAX
+ { "_POSIX_SSIZE_MAX", _SC_SSIZE_MAX, SYSCONF },
+#endif
+#ifdef _SC_STREAM_MAX
+ { "_POSIX_STREAM_MAX", _SC_STREAM_MAX, SYSCONF },
+#endif
+#ifdef _SC_SYNCHRONIZED_IO
+ { "_POSIX_SYNCHRONIZED_IO", _SC_SYNCHRONIZED_IO, SYSCONF },
+#endif
+#ifdef _SC_THREADS
+ { "_POSIX_THREADS", _SC_THREADS, SYSCONF },
+#endif
+#ifdef _SC_THREAD_ATTR_STACKADDR
+ { "_POSIX_THREAD_ATTR_STACKADDR", _SC_THREAD_ATTR_STACKADDR, SYSCONF },
+#endif
+#ifdef _SC_THREAD_ATTR_STACKSIZE
+ { "_POSIX_THREAD_ATTR_STACKSIZE", _SC_THREAD_ATTR_STACKSIZE, SYSCONF },
+#endif
+#ifdef _SC_THREAD_PRIORITY_SCHEDULING
+ { "_POSIX_THREAD_PRIORITY_SCHEDULING", _SC_THREAD_PRIORITY_SCHEDULING, SYSCONF },
+#endif
+#ifdef _SC_THREAD_PRIO_INHERIT
+ { "_POSIX_THREAD_PRIO_INHERIT", _SC_THREAD_PRIO_INHERIT, SYSCONF },
+#endif
+#ifdef _SC_THREAD_PRIO_PROTECT
+ { "_POSIX_THREAD_PRIO_PROTECT", _SC_THREAD_PRIO_PROTECT, SYSCONF },
+#endif
+#ifdef _SC_THREAD_ROBUST_PRIO_INHERIT
+ { "_POSIX_THREAD_ROBUST_PRIO_INHERIT", _SC_THREAD_ROBUST_PRIO_INHERIT,
+ SYSCONF },
+#endif
+#ifdef _SC_THREAD_ROBUST_PRIO_PROTECT
+ { "_POSIX_THREAD_ROBUST_PRIO_PROTECT", _SC_THREAD_ROBUST_PRIO_PROTECT,
+ SYSCONF },
+#endif
+#ifdef _SC_THREAD_PROCESS_SHARED
+ { "_POSIX_THREAD_PROCESS_SHARED", _SC_THREAD_PROCESS_SHARED, SYSCONF },
+#endif
+#ifdef _SC_THREAD_SAFE_FUNCTIONS
+ { "_POSIX_THREAD_SAFE_FUNCTIONS", _SC_THREAD_SAFE_FUNCTIONS, SYSCONF },
+#endif
+#ifdef _SC_TIMERS
+ { "_POSIX_TIMERS", _SC_TIMERS, SYSCONF },
+#endif
+#ifdef _SC_TIMER_MAX
+ { "TIMER_MAX", _SC_TIMER_MAX, SYSCONF },
+#endif
+#ifdef _SC_TZNAME_MAX
+ { "_POSIX_TZNAME_MAX", _SC_TZNAME_MAX, SYSCONF },
+#endif
+#ifdef _SC_VERSION
+ { "_POSIX_VERSION", _SC_VERSION, SYSCONF },
+#endif
+#ifdef _SC_T_IOV_MAX
+ { "_T_IOV_MAX", _SC_T_IOV_MAX, SYSCONF },
+#endif
+#ifdef _SC_XOPEN_CRYPT
+ { "_XOPEN_CRYPT", _SC_XOPEN_CRYPT, SYSCONF },
+#endif
+#ifdef _SC_XOPEN_ENH_I18N
+ { "_XOPEN_ENH_I18N", _SC_XOPEN_ENH_I18N, SYSCONF },
+#endif
+#ifdef _SC_XOPEN_LEGACY
+ { "_XOPEN_LEGACY", _SC_XOPEN_LEGACY, SYSCONF },
+#endif
+#ifdef _SC_XOPEN_REALTIME
+ { "_XOPEN_REALTIME", _SC_XOPEN_REALTIME, SYSCONF },
+#endif
+#ifdef _SC_XOPEN_REALTIME_THREADS
+ { "_XOPEN_REALTIME_THREADS", _SC_XOPEN_REALTIME_THREADS, SYSCONF },
+#endif
+#ifdef _SC_XOPEN_SHM
+ { "_XOPEN_SHM", _SC_XOPEN_SHM, SYSCONF },
+#endif
+#ifdef _SC_XOPEN_UNIX
+ { "_XOPEN_UNIX", _SC_XOPEN_UNIX, SYSCONF },
+#endif
+#ifdef _SC_XOPEN_VERSION
+ { "_XOPEN_VERSION", _SC_XOPEN_VERSION, SYSCONF },
+#endif
+#ifdef _SC_XOPEN_XCU_VERSION
+ { "_XOPEN_XCU_VERSION", _SC_XOPEN_XCU_VERSION, SYSCONF },
+#endif
+#ifdef _SC_XOPEN_XPG2
+ { "_XOPEN_XPG2", _SC_XOPEN_XPG2, SYSCONF },
+#endif
+#ifdef _SC_XOPEN_XPG3
+ { "_XOPEN_XPG3", _SC_XOPEN_XPG3, SYSCONF },
+#endif
+#ifdef _SC_XOPEN_XPG4
+ { "_XOPEN_XPG4", _SC_XOPEN_XPG4, SYSCONF },
+#endif
+ /* POSIX.2 */
+#ifdef _SC_BC_BASE_MAX
+ { "BC_BASE_MAX", _SC_BC_BASE_MAX, SYSCONF },
+#endif
+#ifdef _SC_BC_DIM_MAX
+ { "BC_DIM_MAX", _SC_BC_DIM_MAX, SYSCONF },
+#endif
+#ifdef _SC_BC_SCALE_MAX
+ { "BC_SCALE_MAX", _SC_BC_SCALE_MAX, SYSCONF },
+#endif
+#ifdef _SC_BC_STRING_MAX
+ { "BC_STRING_MAX", _SC_BC_STRING_MAX, SYSCONF },
+#endif
+ { "CHARCLASS_NAME_MAX", _SC_CHARCLASS_NAME_MAX, SYSCONF },
+#ifdef _SC_COLL_WEIGHTS_MAX
+ { "COLL_WEIGHTS_MAX", _SC_COLL_WEIGHTS_MAX, SYSCONF },
+#endif
+#ifdef _SC_EQUIV_CLASS_MAX
+ { "EQUIV_CLASS_MAX", _SC_EQUIV_CLASS_MAX, SYSCONF },
+#endif
+#ifdef _SC_EXPR_NEST_MAX
+ { "EXPR_NEST_MAX", _SC_EXPR_NEST_MAX, SYSCONF },
+#endif
+#ifdef _SC_LINE_MAX
+ { "LINE_MAX", _SC_LINE_MAX, SYSCONF },
+#endif
+#ifdef _SC_BC_BASE_MAX
+ { "POSIX2_BC_BASE_MAX", _SC_BC_BASE_MAX, SYSCONF },
+#endif
+#ifdef _SC_BC_DIM_MAX
+ { "POSIX2_BC_DIM_MAX", _SC_BC_DIM_MAX, SYSCONF },
+#endif
+#ifdef _SC_BC_SCALE_MAX
+ { "POSIX2_BC_SCALE_MAX", _SC_BC_SCALE_MAX, SYSCONF },
+#endif
+#ifdef _SC_BC_STRING_MAX
+ { "POSIX2_BC_STRING_MAX", _SC_BC_STRING_MAX, SYSCONF },
+#endif
+#ifdef _SC_2_CHAR_TERM
+ { "POSIX2_CHAR_TERM", _SC_2_CHAR_TERM, SYSCONF },
+#endif
+#ifdef _SC_COLL_WEIGHTS_MAX
+ { "POSIX2_COLL_WEIGHTS_MAX", _SC_COLL_WEIGHTS_MAX, SYSCONF },
+#endif
+#ifdef _SC_2_C_BIND
+ { "POSIX2_C_BIND", _SC_2_C_BIND, SYSCONF },
+#endif
+#ifdef _SC_2_C_DEV
+ { "POSIX2_C_DEV", _SC_2_C_DEV, SYSCONF },
+#endif
+#ifdef _SC_2_C_VERSION
+ { "POSIX2_C_VERSION", _SC_2_C_VERSION, SYSCONF },
+#endif
+#ifdef _SC_EXPR_NEST_MAX
+ { "POSIX2_EXPR_NEST_MAX", _SC_EXPR_NEST_MAX, SYSCONF },
+#endif
+#ifdef _SC_2_FORT_DEV
+ { "POSIX2_FORT_DEV", _SC_2_FORT_DEV, SYSCONF },
+#endif
+#ifdef _SC_2_FORT_RUN
+ { "POSIX2_FORT_RUN", _SC_2_FORT_RUN, SYSCONF },
+#endif
+#ifdef _SC_LINE_MAX
+ { "_POSIX2_LINE_MAX", _SC_LINE_MAX, SYSCONF },
+ { "POSIX2_LINE_MAX", _SC_LINE_MAX, SYSCONF },
+#endif
+#ifdef _SC_2_LOCALEDEF
+ { "POSIX2_LOCALEDEF", _SC_2_LOCALEDEF, SYSCONF },
+#endif
+#ifdef _SC_RE_DUP_MAX
+ { "POSIX2_RE_DUP_MAX", _SC_RE_DUP_MAX, SYSCONF },
+#endif
+#ifdef _SC_2_SW_DEV
+ { "POSIX2_SW_DEV", _SC_2_SW_DEV, SYSCONF },
+#endif
+#ifdef _SC_2_UPE
+ { "POSIX2_UPE", _SC_2_UPE, SYSCONF },
+#endif
+#ifdef _SC_2_VERSION
+ { "POSIX2_VERSION", _SC_2_VERSION, SYSCONF },
+#endif
+#ifdef _SC_RE_DUP_MAX
+ { "RE_DUP_MAX", _SC_RE_DUP_MAX, SYSCONF },
+#endif
+
+#ifdef _CS_PATH
+ { "PATH", _CS_PATH, CONFSTR },
+ { "CS_PATH", _CS_PATH, CONFSTR },
+#endif
+
+ /* LFS */
+#ifdef _CS_LFS_CFLAGS
+ { "LFS_CFLAGS", _CS_LFS_CFLAGS, CONFSTR },
+#endif
+#ifdef _CS_LFS_LDFLAGS
+ { "LFS_LDFLAGS", _CS_LFS_LDFLAGS, CONFSTR },
+#endif
+#ifdef _CS_LFS_LIBS
+ { "LFS_LIBS", _CS_LFS_LIBS, CONFSTR },
+#endif
+#ifdef _CS_LFS_LINTFLAGS
+ { "LFS_LINTFLAGS", _CS_LFS_LINTFLAGS, CONFSTR },
+#endif
+#ifdef _CS_LFS64_CFLAGS
+ { "LFS64_CFLAGS", _CS_LFS64_CFLAGS, CONFSTR },
+#endif
+#ifdef _CS_LFS64_LDFLAGS
+ { "LFS64_LDFLAGS", _CS_LFS64_LDFLAGS, CONFSTR },
+#endif
+#ifdef _CS_LFS64_LIBS
+ { "LFS64_LIBS", _CS_LFS64_LIBS, CONFSTR },
+#endif
+#ifdef _CS_LFS64_LINTFLAGS
+ { "LFS64_LINTFLAGS", _CS_LFS64_LINTFLAGS, CONFSTR },
+#endif
+
+ /* Programming environments. */
+#ifdef _CS_V5_WIDTH_RESTRICTED_ENVS
+ { "_XBS5_WIDTH_RESTRICTED_ENVS", _CS_V5_WIDTH_RESTRICTED_ENVS, CONFSTR },
+ { "XBS5_WIDTH_RESTRICTED_ENVS", _CS_V5_WIDTH_RESTRICTED_ENVS, CONFSTR },
+#endif
+
+#ifdef _SC_XBS5_ILP32_OFF32
+ { "_XBS5_ILP32_OFF32", _SC_XBS5_ILP32_OFF32, SYSCONF },
+#endif
+#ifdef _CS_XBS5_ILP32_OFF32_CFLAGS
+ { "XBS5_ILP32_OFF32_CFLAGS", _CS_XBS5_ILP32_OFF32_CFLAGS, CONFSTR },
+#endif
+#ifdef _CS_XBS5_ILP32_OFF32_LDFLAGS
+ { "XBS5_ILP32_OFF32_LDFLAGS", _CS_XBS5_ILP32_OFF32_LDFLAGS, CONFSTR },
+#endif
+#ifdef _CS_XBS5_ILP32_OFF32_LIBS
+ { "XBS5_ILP32_OFF32_LIBS", _CS_XBS5_ILP32_OFF32_LIBS, CONFSTR },
+#endif
+#ifdef _CS_XBS5_ILP32_OFF32_LINTFLAGS
+ { "XBS5_ILP32_OFF32_LINTFLAGS", _CS_XBS5_ILP32_OFF32_LINTFLAGS, CONFSTR },
+#endif
+
+#ifdef _SC_XBS5_ILP32_OFFBIG
+ { "_XBS5_ILP32_OFFBIG", _SC_XBS5_ILP32_OFFBIG, SYSCONF },
+#endif
+#ifdef _CS_XBS5_ILP32_OFFBIG_CFLAGS
+ { "XBS5_ILP32_OFFBIG_CFLAGS", _CS_XBS5_ILP32_OFFBIG_CFLAGS, CONFSTR },
+#endif
+#ifdef _CS_XBS5_ILP32_OFFBIG_LDFLAGS
+ { "XBS5_ILP32_OFFBIG_LDFLAGS", _CS_XBS5_ILP32_OFFBIG_LDFLAGS, CONFSTR },
+#endif
+#ifdef _CS_XBS5_ILP32_OFFBIG_LIBS
+ { "XBS5_ILP32_OFFBIG_LIBS", _CS_XBS5_ILP32_OFFBIG_LIBS, CONFSTR },
+#endif
+#ifdef _CS_XBS5_ILP32_OFFBIG_LINTFLAGS
+ { "XBS5_ILP32_OFFBIG_LINTFLAGS", _CS_XBS5_ILP32_OFFBIG_LINTFLAGS, CONFSTR },
+#endif
+
+#ifdef _SC_XBS5_LP64_OFF64
+ { "_XBS5_LP64_OFF64", _SC_XBS5_LP64_OFF64, SYSCONF },
+#endif
+#ifdef _CS_XBS5_LP64_OFF64_CFLAGS
+ { "XBS5_LP64_OFF64_CFLAGS", _CS_XBS5_LP64_OFF64_CFLAGS, CONFSTR },
+#endif
+#ifdef _CS_XBS5_LP64_OFF64_LDFLAGS
+ { "XBS5_LP64_OFF64_LDFLAGS", _CS_XBS5_LP64_OFF64_LDFLAGS, CONFSTR },
+#endif
+#ifdef _CS_XBS5_LP64_OFF64_LIBS
+ { "XBS5_LP64_OFF64_LIBS", _CS_XBS5_LP64_OFF64_LIBS, CONFSTR },
+#endif
+#ifdef _CS_XBS5_LP64_OFF64_LINTFLAGS
+ { "XBS5_LP64_OFF64_LINTFLAGS", _CS_XBS5_LP64_OFF64_LINTFLAGS, CONFSTR },
+#endif
+
+#ifdef _SC_XBS5_LPBIG_OFFBIG
+ { "_XBS5_LPBIG_OFFBIG", _SC_XBS5_LPBIG_OFFBIG, SYSCONF },
+#endif
+#ifdef _CS_XBS5_LPBIG_OFFBIG_CFLAGS
+ { "XBS5_LPBIG_OFFBIG_CFLAGS", _CS_XBS5_LPBIG_OFFBIG_CFLAGS, CONFSTR },
+#endif
+#ifdef _CS_XBS5_LPBIG_OFFBIG_LDFLAGS
+ { "XBS5_LPBIG_OFFBIG_LDFLAGS", _CS_XBS5_LPBIG_OFFBIG_LDFLAGS, CONFSTR },
+#endif
+#ifdef _CS_XBS5_LPBIG_OFFBIG_LIBS
+ { "XBS5_LPBIG_OFFBIG_LIBS", _CS_XBS5_LPBIG_OFFBIG_LIBS, CONFSTR },
+#endif
+#ifdef _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS
+ { "XBS5_LPBIG_OFFBIG_LINTFLAGS", _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS, CONFSTR },
+#endif
+
+#ifdef _SC_V6_ILP32_OFF32
+ { "_POSIX_V6_ILP32_OFF32", _SC_V6_ILP32_OFF32, SYSCONF },
+#endif
+#ifdef _CS_POSIX_V6_ILP32_OFF32_CFLAGS
+ { "POSIX_V6_ILP32_OFF32_CFLAGS", _CS_POSIX_V6_ILP32_OFF32_CFLAGS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V6_ILP32_OFF32_LDFLAGS
+ { "POSIX_V6_ILP32_OFF32_LDFLAGS", _CS_POSIX_V6_ILP32_OFF32_LDFLAGS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V6_ILP32_OFF32_LIBS
+ { "POSIX_V6_ILP32_OFF32_LIBS", _CS_POSIX_V6_ILP32_OFF32_LIBS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS
+ { "POSIX_V6_ILP32_OFF32_LINTFLAGS", _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS, CONFSTR },
+#endif
+
+#ifdef _CS_V6_WIDTH_RESTRICTED_ENVS
+ { "_POSIX_V6_WIDTH_RESTRICTED_ENVS", _CS_V6_WIDTH_RESTRICTED_ENVS, CONFSTR },
+ { "POSIX_V6_WIDTH_RESTRICTED_ENVS", _CS_V6_WIDTH_RESTRICTED_ENVS, CONFSTR },
+#endif
+
+#ifdef _SC_V6_ILP32_OFFBIG
+ { "_POSIX_V6_ILP32_OFFBIG", _SC_V6_ILP32_OFFBIG, SYSCONF },
+#endif
+#ifdef _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS
+ { "POSIX_V6_ILP32_OFFBIG_CFLAGS", _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS
+ { "POSIX_V6_ILP32_OFFBIG_LDFLAGS", _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V6_ILP32_OFFBIG_LIBS
+ { "POSIX_V6_ILP32_OFFBIG_LIBS", _CS_POSIX_V6_ILP32_OFFBIG_LIBS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS
+ { "POSIX_V6_ILP32_OFFBIG_LINTFLAGS", _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS, CONFSTR },
+#endif
+
+#ifdef _SC_V6_LP64_OFF64
+ { "_POSIX_V6_LP64_OFF64", _SC_V6_LP64_OFF64, SYSCONF },
+#endif
+#ifdef _CS_POSIX_V6_LP64_OFF64_CFLAGS
+ { "POSIX_V6_LP64_OFF64_CFLAGS", _CS_POSIX_V6_LP64_OFF64_CFLAGS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V6_LP64_OFF64_LDFLAGS
+ { "POSIX_V6_LP64_OFF64_LDFLAGS", _CS_POSIX_V6_LP64_OFF64_LDFLAGS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V6_LP64_OFF64_LIBS
+ { "POSIX_V6_LP64_OFF64_LIBS", _CS_POSIX_V6_LP64_OFF64_LIBS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V6_LP64_OFF64_LINTFLAGS
+ { "POSIX_V6_LP64_OFF64_LINTFLAGS", _CS_POSIX_V6_LP64_OFF64_LINTFLAGS, CONFSTR },
+#endif
+
+#ifdef _SC_V6_LPBIG_OFFBIG
+ { "_POSIX_V6_LPBIG_OFFBIG", _SC_V6_LPBIG_OFFBIG, SYSCONF },
+#endif
+#ifdef _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS
+ { "POSIX_V6_LPBIG_OFFBIG_CFLAGS", _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS
+ { "POSIX_V6_LPBIG_OFFBIG_LDFLAGS", _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V6_LPBIG_OFFBIG_LIBS
+ { "POSIX_V6_LPBIG_OFFBIG_LIBS", _CS_POSIX_V6_LPBIG_OFFBIG_LIBS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS
+ { "POSIX_V6_LPBIG_OFFBIG_LINTFLAGS", _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS, CONFSTR },
+#endif
+
+#ifdef _SC_V7_ILP32_OFF32
+ { "_POSIX_V7_ILP32_OFF32", _SC_V7_ILP32_OFF32, SYSCONF },
+#endif
+#ifdef _CS_POSIX_V7_ILP32_OFF32_CFLAGS
+ { "POSIX_V7_ILP32_OFF32_CFLAGS", _CS_POSIX_V7_ILP32_OFF32_CFLAGS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V7_ILP32_OFF32_LDFLAGS
+ { "POSIX_V7_ILP32_OFF32_LDFLAGS", _CS_POSIX_V7_ILP32_OFF32_LDFLAGS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V7_ILP32_OFF32_LIBS
+ { "POSIX_V7_ILP32_OFF32_LIBS", _CS_POSIX_V7_ILP32_OFF32_LIBS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS
+ { "POSIX_V7_ILP32_OFF32_LINTFLAGS", _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS, CONFSTR },
+#endif
+
+#ifdef _CS_V7_WIDTH_RESTRICTED_ENVS
+ { "_POSIX_V7_WIDTH_RESTRICTED_ENVS", _CS_V7_WIDTH_RESTRICTED_ENVS, CONFSTR },
+ { "POSIX_V7_WIDTH_RESTRICTED_ENVS", _CS_V7_WIDTH_RESTRICTED_ENVS, CONFSTR },
+#endif
+
+#ifdef _SC_V7_ILP32_OFFBIG
+ { "_POSIX_V7_ILP32_OFFBIG", _SC_V7_ILP32_OFFBIG, SYSCONF },
+#endif
+#ifdef _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS
+ { "POSIX_V7_ILP32_OFFBIG_CFLAGS", _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS
+ { "POSIX_V7_ILP32_OFFBIG_LDFLAGS", _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V7_ILP32_OFFBIG_LIBS
+ { "POSIX_V7_ILP32_OFFBIG_LIBS", _CS_POSIX_V7_ILP32_OFFBIG_LIBS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS
+ { "POSIX_V7_ILP32_OFFBIG_LINTFLAGS", _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS, CONFSTR },
+#endif
+
+#ifdef _SC_V7_LP64_OFF64
+ { "_POSIX_V7_LP64_OFF64", _SC_V7_LP64_OFF64, SYSCONF },
+#endif
+#ifdef _CS_POSIX_V7_LP64_OFF64_CFLAGS
+ { "POSIX_V7_LP64_OFF64_CFLAGS", _CS_POSIX_V7_LP64_OFF64_CFLAGS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V7_LP64_OFF64_LDFLAGS
+ { "POSIX_V7_LP64_OFF64_LDFLAGS", _CS_POSIX_V7_LP64_OFF64_LDFLAGS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V7_LP64_OFF64_LIBS
+ { "POSIX_V7_LP64_OFF64_LIBS", _CS_POSIX_V7_LP64_OFF64_LIBS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V7_LP64_OFF64_LINTFLAGS
+ { "POSIX_V7_LP64_OFF64_LINTFLAGS", _CS_POSIX_V7_LP64_OFF64_LINTFLAGS, CONFSTR },
+#endif
+
+#ifdef _SC_V7_LPBIG_OFFBIG
+ { "_POSIX_V7_LPBIG_OFFBIG", _SC_V7_LPBIG_OFFBIG, SYSCONF },
+#endif
+#ifdef _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS
+ { "POSIX_V7_LPBIG_OFFBIG_CFLAGS", _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS
+ { "POSIX_V7_LPBIG_OFFBIG_LDFLAGS", _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V7_LPBIG_OFFBIG_LIBS
+ { "POSIX_V7_LPBIG_OFFBIG_LIBS", _CS_POSIX_V7_LPBIG_OFFBIG_LIBS, CONFSTR },
+#endif
+#ifdef _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS
+ { "POSIX_V7_LPBIG_OFFBIG_LINTFLAGS", _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS, CONFSTR },
+#endif
+
+#ifdef _SC_ADVISORY_INFO
+ { "_POSIX_ADVISORY_INFO", _SC_ADVISORY_INFO, SYSCONF },
+#endif
+#ifdef _SC_BARRIERS
+ { "_POSIX_BARRIERS", _SC_BARRIERS, SYSCONF },
+#endif
+#ifdef _SC_BASE
+ { "_POSIX_BASE", _SC_BASE, SYSCONF },
+#endif
+#ifdef _SC_C_LANG_SUPPORT
+ { "_POSIX_C_LANG_SUPPORT", _SC_C_LANG_SUPPORT, SYSCONF },
+#endif
+#ifdef _SC_C_LANG_SUPPORT_R
+ { "_POSIX_C_LANG_SUPPORT_R", _SC_C_LANG_SUPPORT_R, SYSCONF },
+#endif
+#ifdef _SC_CLOCK_SELECTION
+ { "_POSIX_CLOCK_SELECTION", _SC_CLOCK_SELECTION, SYSCONF },
+#endif
+#ifdef _SC_CPUTIME
+ { "_POSIX_CPUTIME", _SC_CPUTIME, SYSCONF },
+#endif
+#ifdef _SC_THREAD_CPUTIME
+ { "_POSIX_THREAD_CPUTIME", _SC_THREAD_CPUTIME, SYSCONF },
+#endif
+#ifdef _SC_DEVICE_SPECIFIC
+ { "_POSIX_DEVICE_SPECIFIC", _SC_DEVICE_SPECIFIC, SYSCONF },
+#endif
+#ifdef _SC_DEVICE_SPECIFIC_R
+ { "_POSIX_DEVICE_SPECIFIC_R", _SC_DEVICE_SPECIFIC_R, SYSCONF },
+#endif
+#ifdef _SC_FD_MGMT
+ { "_POSIX_FD_MGMT", _SC_FD_MGMT, SYSCONF },
+#endif
+#ifdef _SC_FIFO
+ { "_POSIX_FIFO", _SC_FIFO, SYSCONF },
+#endif
+#ifdef _SC_PIPE
+ { "_POSIX_PIPE", _SC_PIPE, SYSCONF },
+#endif
+#ifdef _SC_FILE_ATTRIBUTES
+ { "_POSIX_FILE_ATTRIBUTES", _SC_FILE_ATTRIBUTES, SYSCONF },
+#endif
+#ifdef _SC_FILE_LOCKING
+ { "_POSIX_FILE_LOCKING", _SC_FILE_LOCKING, SYSCONF },
+#endif
+#ifdef _SC_FILE_SYSTEM
+ { "_POSIX_FILE_SYSTEM", _SC_FILE_SYSTEM, SYSCONF },
+#endif
+#ifdef _SC_MONOTONIC_CLOCK
+ { "_POSIX_MONOTONIC_CLOCK", _SC_MONOTONIC_CLOCK, SYSCONF },
+#endif
+#ifdef _SC_MULTI_PROCESS
+ { "_POSIX_MULTI_PROCESS", _SC_MULTI_PROCESS, SYSCONF },
+#endif
+#ifdef _SC_SINGLE_PROCESS
+ { "_POSIX_SINGLE_PROCESS", _SC_SINGLE_PROCESS, SYSCONF },
+#endif
+#ifdef _SC_NETWORKING
+ { "_POSIX_NETWORKING", _SC_NETWORKING, SYSCONF },
+#endif
+#ifdef _SC_READER_WRITER_LOCKS
+ { "_POSIX_READER_WRITER_LOCKS", _SC_READER_WRITER_LOCKS, SYSCONF },
+#endif
+#ifdef _SC_SPIN_LOCKS
+ { "_POSIX_SPIN_LOCKS", _SC_SPIN_LOCKS, SYSCONF },
+#endif
+#ifdef _SC_REGEXP
+ { "_POSIX_REGEXP", _SC_REGEXP, SYSCONF },
+#endif
+#ifdef _SC_REGEX_VERSION
+ { "_REGEX_VERSION", _SC_REGEX_VERSION, SYSCONF },
+#endif
+#ifdef _SC_SHELL
+ { "_POSIX_SHELL", _SC_SHELL, SYSCONF },
+#endif
+#ifdef _SC_SIGNALS
+ { "_POSIX_SIGNALS", _SC_SIGNALS, SYSCONF },
+#endif
+#ifdef _SC_SPAWN
+ { "_POSIX_SPAWN", _SC_SPAWN, SYSCONF },
+#endif
+#ifdef _SC_SPORADIC_SERVER
+ { "_POSIX_SPORADIC_SERVER", _SC_SPORADIC_SERVER, SYSCONF },
+#endif
+#ifdef _SC_THREAD_SPORADIC_SERVER
+ { "_POSIX_THREAD_SPORADIC_SERVER", _SC_THREAD_SPORADIC_SERVER, SYSCONF },
+#endif
+#ifdef _SC_SYSTEM_DATABASE
+ { "_POSIX_SYSTEM_DATABASE", _SC_SYSTEM_DATABASE, SYSCONF },
+#endif
+#ifdef _SC_SYSTEM_DATABASE_R
+ { "_POSIX_SYSTEM_DATABASE_R", _SC_SYSTEM_DATABASE_R, SYSCONF },
+#endif
+#ifdef _SC_TIMEOUTS
+ { "_POSIX_TIMEOUTS", _SC_TIMEOUTS, SYSCONF },
+#endif
+#ifdef _SC_TYPED_MEMORY_OBJECTS
+ { "_POSIX_TYPED_MEMORY_OBJECTS", _SC_TYPED_MEMORY_OBJECTS, SYSCONF },
+#endif
+#ifdef _SC_USER_GROUPS
+ { "_POSIX_USER_GROUPS", _SC_USER_GROUPS, SYSCONF },
+#endif
+#ifdef _SC_USER_GROUPS_R
+ { "_POSIX_USER_GROUPS_R", _SC_USER_GROUPS_R, SYSCONF },
+#endif
+#ifdef _SC_2_PBS
+ { "POSIX2_PBS", _SC_2_PBS, SYSCONF },
+#endif
+#ifdef _SC_2_PBS_ACCOUNTING
+ { "POSIX2_PBS_ACCOUNTING", _SC_2_PBS_ACCOUNTING, SYSCONF },
+#endif
+#ifdef _SC_2_PBS_LOCATE
+ { "POSIX2_PBS_LOCATE", _SC_2_PBS_LOCATE, SYSCONF },
+#endif
+#ifdef _SC_2_PBS_TRACK
+ { "POSIX2_PBS_TRACK", _SC_2_PBS_TRACK, SYSCONF },
+#endif
+#ifdef _SC_2_PBS_MESSAGE
+ { "POSIX2_PBS_MESSAGE", _SC_2_PBS_MESSAGE, SYSCONF },
+#endif
+#ifdef _SC_SYMLOOP_MAX
+ { "SYMLOOP_MAX", _SC_SYMLOOP_MAX, SYSCONF },
+#endif
+#ifdef _SC_STREAM_MAX
+ { "STREAM_MAX", _SC_STREAM_MAX, SYSCONF },
+#endif
+#ifdef _SC_AIO_LISTIO_MAX
+ { "AIO_LISTIO_MAX", _SC_AIO_LISTIO_MAX, SYSCONF },
+#endif
+#ifdef _SC_AIO_MAX
+ { "AIO_MAX", _SC_AIO_MAX, SYSCONF },
+#endif
+#ifdef _SC_AIO_PRIO_DELTA_MAX
+ { "AIO_PRIO_DELTA_MAX", _SC_AIO_PRIO_DELTA_MAX, SYSCONF },
+#endif
+#ifdef _SC_DELAYTIMER_MAX
+ { "DELAYTIMER_MAX", _SC_DELAYTIMER_MAX, SYSCONF },
+#endif
+#ifdef _SC_HOST_NAME_MAX
+ { "HOST_NAME_MAX", _SC_HOST_NAME_MAX, SYSCONF },
+#endif
+#ifdef _SC_LOGIN_NAME_MAX
+ { "LOGIN_NAME_MAX", _SC_LOGIN_NAME_MAX, SYSCONF },
+#endif
+#ifdef _SC_MQ_OPEN_MAX
+ { "MQ_OPEN_MAX", _SC_MQ_OPEN_MAX, SYSCONF },
+#endif
+#ifdef _SC_MQ_PRIO_MAX
+ { "MQ_PRIO_MAX", _SC_MQ_PRIO_MAX, SYSCONF },
+#endif
+#ifdef _SC_DEVICE_IO
+ { "_POSIX_DEVICE_IO", _SC_DEVICE_IO, SYSCONF },
+#endif
+#ifdef _SC_TRACE
+ { "_POSIX_TRACE", _SC_TRACE, SYSCONF },
+#endif
+#ifdef _SC_TRACE_EVENT_FILTER
+ { "_POSIX_TRACE_EVENT_FILTER", _SC_TRACE_EVENT_FILTER, SYSCONF },
+#endif
+#ifdef _SC_TRACE_INHERIT
+ { "_POSIX_TRACE_INHERIT", _SC_TRACE_INHERIT, SYSCONF },
+#endif
+#ifdef _SC_TRACE_LOG
+ { "_POSIX_TRACE_LOG", _SC_TRACE_LOG, SYSCONF },
+#endif
+#ifdef _SC_RTSIG_MAX
+ { "RTSIG_MAX", _SC_RTSIG_MAX, SYSCONF },
+#endif
+#ifdef _SC_SEM_NSEMS_MAX
+ { "SEM_NSEMS_MAX", _SC_SEM_NSEMS_MAX, SYSCONF },
+#endif
+#ifdef _SC_SEM_VALUE_MAX
+ { "SEM_VALUE_MAX", _SC_SEM_VALUE_MAX, SYSCONF },
+#endif
+#ifdef _SC_SIGQUEUE_MAX
+ { "SIGQUEUE_MAX", _SC_SIGQUEUE_MAX, SYSCONF },
+#endif
+#ifdef _PC_FILESIZEBITS
+ { "FILESIZEBITS", _PC_FILESIZEBITS, PATHCONF },
+#endif
+#ifdef _PC_ALLOC_SIZE_MIN
+ { "POSIX_ALLOC_SIZE_MIN", _PC_ALLOC_SIZE_MIN, PATHCONF },
+#endif
+#ifdef _PC_REC_INCR_XFER_SIZE
+ { "POSIX_REC_INCR_XFER_SIZE", _PC_REC_INCR_XFER_SIZE, PATHCONF },
+#endif
+#ifdef _PC_REC_MAX_XFER_SIZE
+ { "POSIX_REC_MAX_XFER_SIZE", _PC_REC_MAX_XFER_SIZE, PATHCONF },
+#endif
+#ifdef _PC_REC_MIN_XFER_SIZE
+ { "POSIX_REC_MIN_XFER_SIZE", _PC_REC_MIN_XFER_SIZE, PATHCONF },
+#endif
+#ifdef _PC_REC_XFER_ALIGN
+ { "POSIX_REC_XFER_ALIGN", _PC_REC_XFER_ALIGN, PATHCONF },
+#endif
+#ifdef _PC_SYMLINK_MAX
+ { "SYMLINK_MAX", _PC_SYMLINK_MAX, PATHCONF },
+#endif
+#ifdef _CS_GNU_LIBC_VERSION
+ { "GNU_LIBC_VERSION", _CS_GNU_LIBC_VERSION, CONFSTR },
+#endif
+#ifdef _CS_GNU_LIBPTHREAD_VERSION
+ { "GNU_LIBPTHREAD_VERSION", _CS_GNU_LIBPTHREAD_VERSION, CONFSTR },
+#endif
+#ifdef _PC_2_SYMLINKS
+ { "POSIX2_SYMLINKS", _PC_2_SYMLINKS, PATHCONF },
+#endif
+
+#ifdef _SC_LEVEL1_ICACHE_SIZE
+ { "LEVEL1_ICACHE_SIZE", _SC_LEVEL1_ICACHE_SIZE, SYSCONF },
+#endif
+#ifdef _SC_LEVEL1_ICACHE_ASSOC
+ { "LEVEL1_ICACHE_ASSOC", _SC_LEVEL1_ICACHE_ASSOC, SYSCONF },
+#endif
+#ifdef _SC_LEVEL1_ICACHE_LINESIZE
+ { "LEVEL1_ICACHE_LINESIZE", _SC_LEVEL1_ICACHE_LINESIZE, SYSCONF },
+#endif
+#ifdef _SC_LEVEL1_DCACHE_SIZE
+ { "LEVEL1_DCACHE_SIZE", _SC_LEVEL1_DCACHE_SIZE, SYSCONF },
+#endif
+#ifdef _SC_LEVEL1_DCACHE_ASSOC
+ { "LEVEL1_DCACHE_ASSOC", _SC_LEVEL1_DCACHE_ASSOC, SYSCONF },
+#endif
+#ifdef _SC_LEVEL1_DCACHE_LINESIZE
+ { "LEVEL1_DCACHE_LINESIZE", _SC_LEVEL1_DCACHE_LINESIZE, SYSCONF },
+#endif
+#ifdef _SC_LEVEL2_CACHE_SIZE
+ { "LEVEL2_CACHE_SIZE", _SC_LEVEL2_CACHE_SIZE, SYSCONF },
+#endif
+#ifdef _SC_LEVEL2_CACHE_ASSOC
+ { "LEVEL2_CACHE_ASSOC", _SC_LEVEL2_CACHE_ASSOC, SYSCONF },
+#endif
+#ifdef _SC_LEVEL2_CACHE_LINESIZE
+ { "LEVEL2_CACHE_LINESIZE", _SC_LEVEL2_CACHE_LINESIZE, SYSCONF },
+#endif
+#ifdef _SC_LEVEL3_CACHE_SIZE
+ { "LEVEL3_CACHE_SIZE", _SC_LEVEL3_CACHE_SIZE, SYSCONF },
+#endif
+#ifdef _SC_LEVEL3_CACHE_ASSOC
+ { "LEVEL3_CACHE_ASSOC", _SC_LEVEL3_CACHE_ASSOC, SYSCONF },
+#endif
+#ifdef _SC_LEVEL3_CACHE_LINESIZE
+ { "LEVEL3_CACHE_LINESIZE", _SC_LEVEL3_CACHE_LINESIZE, SYSCONF },
+#endif
+#ifdef _SC_LEVEL4_CACHE_SIZE
+ { "LEVEL4_CACHE_SIZE", _SC_LEVEL4_CACHE_SIZE, SYSCONF },
+#endif
+#ifdef _SC_LEVEL4_CACHE_ASSOC
+ { "LEVEL4_CACHE_ASSOC", _SC_LEVEL4_CACHE_ASSOC, SYSCONF },
+#endif
+#ifdef _SC_LEVEL4_CACHE_LINESIZE
+ { "LEVEL4_CACHE_LINESIZE", _SC_LEVEL4_CACHE_LINESIZE, SYSCONF },
+#endif
+
+#ifdef _SC_IPV6
+ { "IPV6", _SC_IPV6, SYSCONF },
+#endif
+#ifdef _SC_RAW_SOCKETS
+ { "RAW_SOCKETS", _SC_RAW_SOCKETS, SYSCONF },
+#endif
+
+ { NULL, 0, SYSCONF }
+ };
+
+
+static const struct { const char *name; int num; } specs[] =
+ {
+#ifdef _SC_XBS5_ILP32_OFF32
+ { "XBS5_ILP32_OFF32", _SC_XBS5_ILP32_OFF32 },
+#endif
+#ifdef _SC_XBS5_ILP32_OFFBIG
+ { "XBS5_ILP32_OFFBIG", _SC_XBS5_ILP32_OFFBIG },
+#endif
+#ifdef _SC_XBS5_LP64_OFF64
+ { "XBS5_LP64_OFF64", _SC_XBS5_LP64_OFF64 },
+#endif
+#ifdef _SC_XBS5_LPBIG_OFFBIG
+ { "XBS5_LPBIG_OFFBIG", _SC_XBS5_LPBIG_OFFBIG },
+#endif
+#ifdef _SC_V6_ILP32_OFF32
+ { "POSIX_V6_ILP32_OFF32", _SC_V6_ILP32_OFF32 },
+#endif
+#ifdef _SC_V6_ILP32_OFFBIG
+ { "POSIX_V6_ILP32_OFFBIG", _SC_V6_ILP32_OFFBIG },
+#endif
+#ifdef _SC_V6_LP64_OFF64
+ { "POSIX_V6_LP64_OFF64", _SC_V6_LP64_OFF64 },
+#endif
+#ifdef _SC_V6_LPBIG_OFFBIG
+ { "POSIX_V6_LPBIG_OFFBIG", _SC_V6_LPBIG_OFFBIG },
+#endif
+#ifdef _SC_V7_ILP32_OFF32
+ { "POSIX_V7_ILP32_OFF32", _SC_V7_ILP32_OFF32 },
+#endif
+#ifdef _SC_V7_ILP32_OFFBIG
+ { "POSIX_V7_ILP32_OFFBIG", _SC_V7_ILP32_OFFBIG },
+#endif
+#ifdef _SC_V7_LP64_OFF64
+ { "POSIX_V7_LP64_OFF64", _SC_V7_LP64_OFF64 },
+#endif
+#ifdef _SC_V7_LPBIG_OFFBIG
+ { "POSIX_V7_LPBIG_OFFBIG", _SC_V7_LPBIG_OFFBIG },
+#endif
+ };
+static const int nspecs = sizeof (specs) / sizeof (specs[0]);
+
+#ifndef __UCLIBC_HAS___PROGNAME__
+static const char *__progname = "getconf";
+#endif
+
+static attribute_noreturn void
+usage (void)
+{
+ fprintf (stderr,
+ _("Usage: %s [-v specification] variable_name [pathname]\n"),
+ __progname);
+ fprintf (stderr,
+ _(" %s -a [pathname]\n"), __progname);
+ exit (2);
+}
+
+
+static attribute_noreturn void
+print_all (const char *path)
+{
+ register const struct conf *c;
+ size_t clen;
+ long int value;
+ char *cvalue;
+ for (c = vars; c->name != NULL; ++c) {
+ printf("%-35s", c->name);
+ switch (c->call) {
+ case PATHCONF:
+ value = pathconf (path, c->call_name);
+ if (value != -1) {
+ printf("%ld", value);
+ }
+ printf("\n");
+ break;
+ case SYSCONF:
+ value = sysconf (c->call_name);
+ if (value == -1l) {
+ if (c->call_name == _SC_UINT_MAX
+ || c->call_name == _SC_ULONG_MAX)
+ printf ("%lu", value);
+ }
+ else {
+ printf ("%ld", value);
+ }
+ printf ("\n");
+ break;
+ case CONFSTR:
+ clen = confstr (c->call_name, (char *) NULL, 0);
+ cvalue = (char *) malloc (clen);
+ if (cvalue == NULL)
+ error (3, 0, _("memory exhausted"));
+ if (confstr (c->call_name, cvalue, clen) != clen)
+ error (3, errno, "confstr");
+ printf ("%.*s\n", (int) clen, cvalue);
+ free (cvalue);
+ break;
+ }
+ }
+ exit (0);
+}
+
+int
+main (int argc, char *argv[])
+{
+ register const struct conf *c;
+
+ /* Set locale. Do not set LC_ALL because the other categories must
+ not be affected (according to POSIX.2). */
+
+ /* Initialize the message catalog. */
+
+ if (argc > 1 && strcmp (argv[1], "--version") == 0)
+ {
+ printf ("getconf (GNU %s) %s\n", PACKAGE, VERSION);
+ printf ("\
+Copyright (C) %s Free Software Foundation, Inc.\n\
+This is free software; see the source for copying conditions. There is NO\n\
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
+", "2009");
+ printf ("Written by %s.\n", "Roland McGrath");
+ return 0;
+ }
+
+ if (argc > 1 && strcmp (argv[1], "--help") == 0)
+ {
+ printf ("\
+Usage: getconf [-v SPEC] VAR\n\
+ or: getconf [-v SPEC] PATH_VAR PATH\n\
+\n\
+Get the configuration value for variable VAR, or for variable PATH_VAR\n\
+for path PATH. If SPEC is given, give values for compilation\n\
+environment SPEC.\n\n");
+ fputs ("For bug reporting instructions, please see:\n\
+<http://www.gnu.org/software/libc/bugs.html>.\n", stdout);
+ return 0;
+ }
+
+ const char *getconf_dir = getenv ("GETCONF_DIR") ?: GETCONF_DIR;
+ size_t getconf_dirlen = strlen (getconf_dir);
+
+ const char *spec = NULL;
+ char buf[sizeof "POSIX_V6_LPBIG_OFFBIG"];
+ char *argv0 = argv[0];
+ if (argc > 1 && strncmp (argv[1], "-v", 2) == 0)
+ {
+ if (argv[1][2] == '\0')
+ {
+ if (argc < 3)
+ usage ();
+
+ spec = argv[2];
+ argv += 2;
+ argc -= 2;
+ }
+ else
+ {
+ spec = &argv[1][2];
+ argv += 1;
+ argc += 1;
+ }
+ }
+ else
+ {
+ char default_name[getconf_dirlen + sizeof "/default"];
+ memcpy (mempcpy (default_name, getconf_dir, getconf_dirlen),
+ "/default", sizeof "/default");
+ int len = readlink (default_name, buf, sizeof buf - 1);
+ if (len > 0)
+ {
+ buf[len] = '\0';
+ spec = buf;
+ }
+ }
+
+ /* Check for the specifications we know. */
+ if (spec != NULL)
+ {
+ int i;
+ for (i = 0; i < nspecs; ++i)
+ if (strcmp (spec, specs[i].name) == 0)
+ break;
+
+ if (i == nspecs)
+ error (2, 0, _("unknown specification \"%s\""), spec);
+
+ switch (specs[i].num)
+ {
+#if !defined(_XBS5_ILP32_OFF32) && defined(_SC_XBS5_ILP32_OFF32)
+ case _SC_XBS5_ILP32_OFF32:
+#endif
+#if !defined(_XBS5_ILP32_OFFBIG) && defined(_SC_XBS5_ILP32_OFFBIG)
+ case _SC_XBS5_ILP32_OFFBIG:
+#endif
+#if !defined(_XBS5_LP64_OFF64) && defined(_SC_XBS5_LP64_OFF64)
+ case _SC_XBS5_LP64_OFF64:
+#endif
+#if !defined(_XBS5_LPBIG_OFFBIG) && defined(_SC_XBS5_LPBIG_OFFBIG)
+ case _SC_XBS5_LPBIG_OFFBIG:
+#endif
+#if !defined(_POSIX_V6_ILP32_OFF32) && defined(_SC_V6_ILP32_OFF32)
+ case _SC_V6_ILP32_OFF32:
+#endif
+#if !defined(_POSIX_V6_ILP32_OFFBIG) && defined(_SC_V6_ILP32_OFFBIG)
+ case _SC_V6_ILP32_OFFBIG:
+#endif
+#if !defined(_POSIX_V6_LP64_OFF64) && defined(_SC_V6_LP64_OFF64)
+ case _SC_V6_LP64_OFF64:
+#endif
+#if !defined(_POSIX_V6_LPBIG_OFFBIG) && defined(_SC_V6_LPBIG_OFFBIG)
+ case _SC_V6_LPBIG_OFFBIG:
+#endif
+#if !defined(_POSIX_V7_ILP32_OFF32) && defined(_SC_V7_ILP32_OFF32)
+ case _SC_V7_ILP32_OFF32:
+#endif
+#if !defined(_POSIX_V7_ILP32_OFFBIG) && defined(_SC_V7_ILP32_OFFBIG)
+ case _SC_V7_ILP32_OFFBIG:
+#endif
+#if !defined(_POSIX_V7_LP64_OFF64) && defined(_SC_V7_LP64_OFF64)
+ case _SC_V7_LP64_OFF64:
+#endif
+#if !defined(_POSIX_V7_LPBIG_OFFBIG) && defined(_SC_V7_LPBIG_OFFBIG)
+ case _SC_V7_LPBIG_OFFBIG:
+#endif
+ {
+ const char *args[argc + 3];
+ size_t spec_len = strlen (spec);
+ char getconf_name[getconf_dirlen + 1 + spec_len + 1];
+ memcpy (mempcpy (mempcpy (getconf_name, getconf_dir,
+ getconf_dirlen),
+ "/", 1), spec, spec_len + 1);
+ args[0] = argv0;
+ args[1] = "-v";
+ args[2] = spec;
+ memcpy (&args[3], &argv[1], argc * sizeof (argv[1]));
+ execv (getconf_name, (char * const *) args);
+ error (4, errno, _("Couldn't execute %s"), getconf_name);
+ }
+ default:
+ break;
+ }
+ }
+
+ if (argc > 1 && strcmp (argv[1], "-a") == 0)
+ {
+ if (argc == 2)
+ print_all ("/");
+ else if (argc == 3)
+ print_all (argv[2]);
+ else
+ usage ();
+ }
+
+ int ai = 1;
+ if (argc > ai && strcmp (argv[ai], "--") == 0)
+ ++ai;
+
+ if (argc - ai < 1 || argc - ai > 2)
+ usage ();
+
+ for (c = vars; c->name != NULL; ++c)
+ if (strcmp (c->name, argv[ai]) == 0
+ || (strncmp (c->name, "_POSIX_", 7) == 0
+ && strcmp (c->name + 7, argv[ai]) == 0))
+ {
+ long int value;
+ size_t clen;
+ char *cvalue;
+ switch (c->call)
+ {
+ case PATHCONF:
+ if (argc - ai < 2)
+ usage ();
+ errno = 0;
+ value = pathconf (argv[ai + 1], c->call_name);
+ if (value == -1)
+ {
+ if (errno) {
+ error (3, errno, "pathconf: %s", argv[ai + 1]);
+ } else
+ puts (_("undefined"));
+ }
+ else
+ printf ("%ld\n", value);
+ exit (0);
+
+ case SYSCONF:
+ if (argc - ai > 1)
+ usage ();
+ value = sysconf (c->call_name);
+ if (value == -1l)
+ {
+ if (c->call_name == _SC_UINT_MAX
+ || c->call_name == _SC_ULONG_MAX)
+ printf ("%lu\n", value);
+ else
+ puts (_("undefined"));
+ }
+ else
+ printf ("%ld\n", value);
+ exit (0);
+
+ case CONFSTR:
+ if (argc - ai > 1)
+ usage ();
+ clen = confstr (c->call_name, (char *) NULL, 0);
+ cvalue = (char *) malloc (clen);
+ if (cvalue == NULL)
+ error (3, 0, _("memory exhausted"));
+
+ if (confstr (c->call_name, cvalue, clen) != clen)
+ error (3, errno, "confstr");
+
+ printf ("%.*s\n", (int) clen, cvalue);
+ exit (0);
+ }
+ }
+
+ error (2, 0, _("Unrecognized variable `%s'"), argv[ai]);
+ /* NOTREACHED */
+ return 2;
+}
diff --git a/utils/iconv.c b/utils/iconv.c
new file mode 100644
index 000000000..48a10155e
--- /dev/null
+++ b/utils/iconv.c
@@ -0,0 +1,271 @@
+
+/* Copyright (C) 2002, 2003, 2004 Manuel Novoa III
+ *
+ * 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/>.
+ */
+
+/* ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION!
+ *
+ * Besides uClibc, I'm using this code in my libc for elks, which is
+ * a 16-bit environment with a fairly limited compiler. It would make
+ * things much easier for me if this file isn't modified unnecessarily.
+ * In particular, please put any new or replacement functions somewhere
+ * else, and modify the makefile to use your version instead.
+ * Thanks. Manuel
+ *
+ * ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION! */
+
+
+/* May 23, 2002 Initial Notes:
+ *
+ * I'm still tweaking this stuff, but it passes the tests I've thrown
+ * at it, and Erik needs it for the gcc port. The glibc extension
+ * __wcsnrtombs() hasn't been tested, as I didn't find a test for it
+ * in the glibc source. I also need to fix the behavior of
+ * _wchar_utf8sntowcs() if the max number of wchars to convert is 0.
+ *
+ * UTF-8 -> wchar -> UTF-8 conversion tests on Markus Kuhn's UTF-8-demo.txt
+ * file on my platform (x86) show about 5-10% faster conversion speed than
+ * glibc with mbsrtowcs()/wcsrtombs() and almost twice as fast as glibc with
+ * individual mbrtowc()/wcrtomb() calls.
+ *
+ * If 'DECODER' is defined, then _wchar_utf8sntowcs() will be compiled
+ * as a fail-safe UTF-8 decoder appropriate for a terminal, etc. which
+ * needs to deal gracefully with whatever is sent to it. In that mode,
+ * it passes Markus Kuhn's UTF-8-test.txt stress test. I plan to add
+ * an arg to force that behavior, so the interface will be changing.
+ *
+ * I need to fix the error checking for 16-bit wide chars. This isn't
+ * an issue for uClibc, but may be for ELKS. I'm currently not sure
+ * if I'll use 16-bit, 32-bit, or configureable wchars in ELKS.
+ *
+ * July 1, 2002
+ *
+ * Fixed _wchar_utf8sntowcs() for the max number of wchars == 0 case.
+ * Fixed nul-char bug in btowc(), and another in __mbsnrtowcs() for 8-bit
+ * locales.
+ * Enabled building of a C/POSIX-locale-only version, so full locale support
+ * no longer needs to be enabled.
+ *
+ * Nov 4, 2002
+ *
+ * Fixed a bug in _wchar_wcsntoutf8s(). Don't store wcs position if dst is NULL.
+ * Also, introduce an awful hack into _wchar_wcsntoutf8s() and wcsrtombs() in
+ * order to support %ls in printf. See comments below for details.
+ * Change behaviour of wc<->mb functions when in the C locale. Now they do
+ * a 1-1 map for the range 0x80-UCHAR_MAX. This is for backwards compatibility
+ * and consistency with the stds requirements that a printf format string by
+ * a valid multibyte string beginning and ending in it's initial shift state.
+ *
+ * Nov 5, 2002
+ *
+ * Forgot to change btowc and wctob when I changed the wc<->mb functions yesterday.
+ *
+ * Nov 7, 2002
+ *
+ * Add wcwidth and wcswidth, based on Markus Kuhn's wcwidth of 2002-05-08.
+ * Added some size/speed optimizations and integrated it into my locale
+ * framework. Minimally tested at the moment, but the stub C-locale
+ * version (which most people would probably be using) should be fine.
+ *
+ * Nov 21, 2002
+ *
+ * Revert the wc<->mb changes from earlier this month involving the C-locale.
+ * Add a couple of ugly hacks to support *wprintf.
+ * Add a mini iconv() and iconv implementation (requires locale support).
+ *
+ * Aug 1, 2003
+ * Bug fix for mbrtowc.
+ *
+ * Aug 18, 2003
+ * Bug fix: _wchar_utf8sntowcs and _wchar_wcsntoutf8s now set errno if EILSEQ.
+ *
+ * Feb 11, 2004
+ * Bug fix: Fix size check for remaining output space in iconv().
+ *
+ * Manuel
+ */
+
+/* keep libgen before string.h - and porting.h to use the
+ * XPG version of basename */
+#include <libgen.h>
+#include "porting.h"
+#include <string.h>
+#include <iconv.h>
+#include <stdarg.h>
+#include <wchar.h>
+#include "wchar.c" /* for _UC_iconv_t and __iconv_codesets */
+
+#ifdef L_iconv_main
+static
+#else
+extern
+#endif
+const unsigned char __iconv_codesets[];
+
+#define IBUF BUFSIZ
+#define OBUF BUFSIZ
+
+static char *progname;
+static int hide_errors;
+
+static void error_msg(const char *fmt, ...)
+ __attribute__ ((noreturn, format (printf, 1, 2)));
+
+static void error_msg(const char *fmt, ...)
+{
+ va_list arg;
+
+ if (!hide_errors) {
+ fprintf(stderr, "%s: ", progname);
+ va_start(arg, fmt);
+ vfprintf(stderr, fmt, arg);
+ va_end(arg);
+ }
+
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char **argv)
+{
+ FILE *ifile;
+ FILE *ofile = stdout;
+ const char *p;
+ const char *s;
+ static const char opt_chars[] = "tfocsl";
+ /* 012345 */
+ const char *opts[sizeof(opt_chars)]; /* last is infile name */
+ iconv_t ic;
+ char ibuf[IBUF];
+ char obuf[OBUF];
+ char *pi;
+ char *po;
+ size_t ni, no, r, pos;
+
+ hide_errors = 0;
+
+ for (s = opt_chars ; *s ; s++) {
+ opts[ s - opt_chars ] = NULL;
+ }
+
+ progname = *argv;
+ while (--argc) {
+ p = *++argv;
+ if ((*p != '-') || (*++p == 0)) {
+ break;
+ }
+ do {
+ if ((s = strchr(opt_chars,*p)) == NULL) {
+ USAGE:
+ s = basename(progname);
+ fprintf(stderr,
+ "%s [-cs] -f fromcode -t tocode [-o outputfile] [inputfile ...]\n"
+ " or\n%s -l\n", s, s);
+ return EXIT_FAILURE;
+ }
+ if ((s - opt_chars) < 3) {
+ if ((--argc == 0) || opts[s - opt_chars]) {
+ goto USAGE;
+ }
+ opts[s - opt_chars] = *++argv;
+ } else {
+ opts[s - opt_chars] = p;
+ }
+ } while (*++p);
+ }
+
+ if (opts[5]) { /* -l */
+ fprintf(stderr, "Recognized codesets:\n");
+ for (s = (char *)__iconv_codesets ; *s ; s += *s) {
+ fprintf(stderr," %s\n", s+2);
+ }
+ s = __LOCALE_DATA_CODESET_LIST;
+ do {
+ fprintf(stderr," %s\n", __LOCALE_DATA_CODESET_LIST+ (unsigned char)(*s));
+ } while (*++s);
+
+ return EXIT_SUCCESS;
+ }
+
+ if (opts[4]) {
+ hide_errors = 1;
+ }
+
+ if (!opts[0] || !opts[1]) {
+ goto USAGE;
+ }
+ if ((ic = iconv_open(opts[0],opts[1])) == ((iconv_t)(-1))) {
+ error_msg( "unsupported codeset in %s -> %s conversion\n", opts[1], opts[0]);
+ }
+ if (opts[3]) { /* -c */
+ ((_UC_iconv_t *) ic)->skip_invalid_input = 1;
+ }
+
+ if ((s = opts[2]) != NULL) {
+ if (!(ofile = fopen(s, "w"))) {
+ error_msg( "couldn't open %s for writing\n", s);
+ }
+ }
+
+ pos = ni = 0;
+ do {
+ if (!argc || ((**argv == '-') && !((*argv)[1]))) {
+ ifile = stdin; /* we don't check for duplicates */
+ } else if (!(ifile = fopen(*argv, "r"))) {
+ error_msg( "couldn't open %s for reading\n", *argv);
+ }
+
+ while ((r = fread(ibuf + ni, 1, IBUF - ni, ifile)) > 0) {
+ pos += r;
+ ni += r;
+ no = OBUF;
+ pi = ibuf;
+ po = obuf;
+ if ((r = iconv(ic, &pi, &ni, &po, &no)) == ((size_t)(-1))) {
+ if ((errno != EINVAL) && (errno != E2BIG)) {
+ error_msg( "iconv failed at pos %lu : %m\n", (unsigned long) (pos - ni));
+ }
+ }
+ if ((r = OBUF - no) > 0) {
+ if (fwrite(obuf, 1, OBUF - no, ofile) < r) {
+ error_msg( "write error\n");
+ }
+ }
+ if (ni) { /* still bytes in buffer! */
+ memmove(ibuf, pi, ni);
+ }
+ }
+
+ if (ferror(ifile)) {
+ error_msg( "read error\n");
+ }
+
+ ++argv;
+
+ if (ifile != stdin) {
+ fclose(ifile);
+ }
+
+ } while (--argc > 0);
+
+ iconv_close(ic);
+
+ if (ni) {
+ error_msg( "incomplete sequence\n");
+ }
+
+ return (((_UC_iconv_t *) ic)->skip_invalid_input < 2)
+ ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/utils/ldconfig.c b/utils/ldconfig.c
index 0abd0613e..e6b788118 100644
--- a/utils/ldconfig.c
+++ b/utils/ldconfig.c
@@ -26,21 +26,7 @@
* 2005/09/16: Dan Howell (modified for cross-development)
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <ctype.h>
-#include <getopt.h>
-#include <dirent.h>
-#include <unistd.h>
-#include <link.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include "bswap.h"
-#include "dl-defs.h"
+#include "porting.h"
#define BUFFER_SIZE 4096
@@ -71,22 +57,6 @@ struct exec {
/* Code indicating core file. */
#define CMAGIC 0421
-char *___strtok = NULL;
-
-/* For SunOS */
-#ifndef PATH_MAX
-#include <limits.h>
-#define PATH_MAX _POSIX_PATH_MAX
-#endif
-
-/* For SunOS */
-#ifndef N_MAGIC
-#define N_MAGIC(exec) ((exec).a_magic & 0xffff)
-#endif
-
-#define EXIT_OK 0
-#define EXIT_FATAL 128
-
char *prog = NULL;
int debug = 0; /* debug mode */
int verbose = 0; /* verbose mode */
@@ -124,6 +94,7 @@ struct needed_tab needed_tab[] = {
extern char *chroot_realpath(const char *chroot, const char *path,
char resolved_path[]);
+#if defined __UCLIBC_STATIC_LDCONFIG__ || !defined __UCLIBC_HAS_BSD_ERR__
/* These two are used internally -- you shouldn't need to use them */
static void verror_msg(const char *s, va_list p)
{
@@ -142,7 +113,7 @@ static void warnx(const char *s, ...)
fprintf(stderr, "\n");
}
-static void err(int errnum, const char *s, ...)
+static attribute_noreturn void err(int errnum, const char *s, ...)
{
va_list p;
@@ -155,14 +126,14 @@ static void err(int errnum, const char *s, ...)
static void vperror_msg(const char *s, va_list p)
{
- int err = errno;
+ int e = errno;
if (s == 0)
s = "";
verror_msg(s, p);
if (*s)
s = ": ";
- fprintf(stderr, "%s%s\n", s, strerror(err));
+ fprintf(stderr, "%s%s\n", s, strerror(e));
}
static void warn(const char *s, ...)
@@ -173,12 +144,15 @@ static void warn(const char *s, ...)
vperror_msg(s, p);
va_end(p);
}
+#else
+# include <err.h>
+#endif
static void *xmalloc(size_t size)
{
void *ptr;
if ((ptr = malloc(size)) == NULL)
- err(EXIT_FATAL, "out of memory");
+ err(EXIT_FAILURE, "out of memory");
return ptr;
}
@@ -186,7 +160,7 @@ static char *xstrdup(const char *str)
{
char *ptr;
if ((ptr = strdup(str)) == NULL)
- err(EXIT_FATAL, "out of memory");
+ err(EXIT_FAILURE, "out of memory");
return ptr;
}
@@ -201,8 +175,8 @@ static char *xstrdup(const char *str)
#define readsonameXX readsoname64
#define __ELF_NATIVE_CLASS 64
#include "readsoname2.c"
-char *readsoname(char *name, FILE *infile, int expected_type,
- int *type, int elfclass)
+static char *readsoname(char *name, FILE *infile, int expected_type,
+ int *type, int elfclass)
{
char *res;
@@ -234,8 +208,8 @@ char *readsoname(char *name, FILE *infile, int expected_type,
* If the expected, actual/deduced types missmatch we display a warning
* and use the actual/deduced type.
*/
-char *is_shlib(const char *dir, const char *name, int *type,
- int *islink, int expected_type)
+static char *is_shlib(const char *dir, const char *name, int *type,
+ int *islink, int expected_type)
{
char *good = NULL;
char *cp, *cp2;
@@ -279,15 +253,15 @@ char *is_shlib(const char *dir, const char *name, int *type,
if (fread(&exec, sizeof exec, 1, file) < 1)
warnx("can't read header from %s, skipping", buff);
else if (N_MAGIC(exec) != ZMAGIC
- && N_MAGIC(exec) != QMAGIC
- && N_MAGIC_SWAP(exec) != ZMAGIC
- && N_MAGIC_SWAP(exec) != QMAGIC) {
+ && N_MAGIC(exec) != QMAGIC
+ && N_MAGIC_SWAP(exec) != ZMAGIC
+ && N_MAGIC_SWAP(exec) != QMAGIC) {
elf_hdr = (ElfW(Ehdr) *) & exec;
if (elf_hdr->e_ident[0] != 0x7f ||
- strncmp(elf_hdr->e_ident+1, "ELF", 3) != 0)
+ strncmp((const char *)elf_hdr->e_ident + 1, "ELF", 3) != 0)
{
/* silently ignore linker scripts */
- if (strncmp((char *)&exec, "/* GNU ld", 9) != 0)
+ if (strncmp((const char *)&exec, "/* GNU ld", 9) != 0)
warnx("%s is not a shared library, skipping", buff);
} else {
/* always call readsoname to update type */
@@ -309,7 +283,7 @@ char *is_shlib(const char *dir, const char *name, int *type,
/* if the soname does not match the filename,
issue a warning, but only in debug mode. */
int len = strlen(good);
- if (debug && (strncmp(good, name, len) != 0
+ if (debug && (strncmp((const char *)good, name, len) != 0
|| (name[len] != '\0' && name[len] != '.')))
warnx("%s has inconsistent soname (%s)", buff, good);
}
@@ -351,7 +325,7 @@ char *is_shlib(const char *dir, const char *name, int *type,
}
/* update the symlink to new library */
-void link_shlib(const char *dir, const char *file, const char *so)
+static void link_shlib(const char *dir, const char *file, const char *so)
{
int change = 1;
char libname[BUFFER_SIZE];
@@ -408,7 +382,7 @@ void link_shlib(const char *dir, const char *file, const char *so)
}
/* figure out which library is greater */
-int libcmp(char *p1, char *p2)
+static int libcmp(char *p1, char *p2)
{
while (*p1) {
if (isdigit(*p1) && isdigit(*p2)) {
@@ -440,7 +414,7 @@ struct lib {
};
/* update all shared library links in a directory */
-void scan_dir(const char *rawname)
+static void scan_dir(const char *rawname)
{
DIR *dir;
const char *name;
@@ -453,7 +427,7 @@ void scan_dir(const char *rawname)
/* We need a writable copy of this string */
path = strdup(rawname);
if (!path) {
- err(EXIT_FATAL, "Out of memory!\n");
+ err(EXIT_FAILURE, "Out of memory!\n");
}
/* Eliminate all double //s */
path_n = path;
@@ -582,22 +556,22 @@ void cache_write(void)
}
#else
/* return the list of system-specific directories */
-char *get_extpath(void)
+static char *get_extpath(void)
{
char *res = NULL, *cp;
FILE *file;
- struct stat stat;
+ struct stat st;
char realconffile[BUFFER_SIZE];
if (!chroot_realpath(chroot_dir, conffile, realconffile))
return NULL;
if ((file = fopen(realconffile, "r")) != NULL) {
- fstat(fileno(file), &stat);
- res = xmalloc(stat.st_size + 1);
- fread(res, 1, stat.st_size, file);
+ fstat(fileno(file), &st);
+ res = xmalloc(st.st_size + 1);
+ (void)fread(res, 1, st.st_size, file);
fclose(file);
- res[stat.st_size] = '\0';
+ res[st.st_size] = '\0';
/* convert comments fo spaces */
for (cp = res; *cp; /*nada */ ) {
@@ -679,17 +653,17 @@ void cache_write(void)
return;
if (!chroot_realpath(chroot_dir, cachefile, realcachefile))
- err(EXIT_FATAL, "can't resolve %s in chroot %s (%s)",
+ err(EXIT_FAILURE, "can't resolve %s in chroot %s (%s)",
cachefile, chroot_dir, strerror(errno));
sprintf(tempfile, "%s~", realcachefile);
if (unlink(tempfile) && errno != ENOENT)
- err(EXIT_FATAL, "can't unlink %s~ (%s)", cachefile,
+ err(EXIT_FAILURE, "can't unlink %s~ (%s)", cachefile,
strerror(errno));
if ((cachefd = creat(tempfile, 0644)) < 0)
- err(EXIT_FATAL, "can't create %s~ (%s)", cachefile,
+ err(EXIT_FAILURE, "can't create %s~ (%s)", cachefile,
strerror(errno));
if (byteswap) {
@@ -700,7 +674,7 @@ void cache_write(void)
magic_ptr = &magic;
}
if (write(cachefd, magic_ptr, sizeof(header_t)) != sizeof(header_t))
- err(EXIT_FATAL, "can't write %s~ (%s)", cachefile,
+ err(EXIT_FAILURE, "can't write %s~ (%s)", cachefile,
strerror(errno));
for (cur_lib = lib_head; cur_lib != NULL; cur_lib = cur_lib->next) {
@@ -718,31 +692,31 @@ void cache_write(void)
}
if (write(cachefd, lib_ptr, sizeof(libentry_t)) !=
sizeof(libentry_t))
- err(EXIT_FATAL, "can't write %s~ (%s)", cachefile,
+ err(EXIT_FAILURE, "can't write %s~ (%s)", cachefile,
strerror(errno));
}
for (cur_lib = lib_head; cur_lib != NULL; cur_lib = cur_lib->next) {
if ((size_t)write(cachefd, cur_lib->soname, strlen(cur_lib->soname) + 1)
!= strlen(cur_lib->soname) + 1)
- err(EXIT_FATAL, "can't write %s~ (%s)", cachefile,
+ err(EXIT_FAILURE, "can't write %s~ (%s)", cachefile,
strerror(errno));
if ((size_t)write(cachefd, cur_lib->libname, strlen(cur_lib->libname) + 1)
!= strlen(cur_lib->libname) + 1)
- err(EXIT_FATAL, "can't write %s~ (%s)", cachefile,
+ err(EXIT_FAILURE, "can't write %s~ (%s)", cachefile,
strerror(errno));
}
if (close(cachefd))
- err(EXIT_FATAL, "can't close %s~ (%s)", cachefile,
+ err(EXIT_FAILURE, "can't close %s~ (%s)", cachefile,
strerror(errno));
if (chmod(tempfile, 0644))
- err(EXIT_FATAL, "can't chmod %s~ (%s)", cachefile,
+ err(EXIT_FAILURE, "can't chmod %s~ (%s)", cachefile,
strerror(errno));
if (rename(tempfile, realcachefile))
- err(EXIT_FATAL, "can't rename %s~ (%s)", cachefile,
+ err(EXIT_FAILURE, "can't rename %s~ (%s)", cachefile,
strerror(errno));
}
@@ -757,22 +731,22 @@ void cache_print(void)
char realcachefile[BUFFER_SIZE];
if (!chroot_realpath(chroot_dir, cachefile, realcachefile))
- err(EXIT_FATAL, "can't resolve %s in chroot %s (%s)",
+ err(EXIT_FAILURE, "can't resolve %s in chroot %s (%s)",
cachefile, chroot_dir, strerror(errno));
if (stat(realcachefile, &st) || (fd = open(realcachefile, O_RDONLY)) < 0)
- err(EXIT_FATAL, "can't read %s (%s)", cachefile, strerror(errno));
+ err(EXIT_FAILURE, "can't read %s (%s)", cachefile, strerror(errno));
c = mmap(0, st.st_size, PROT_READ, LDSO_CACHE_MMAP_FLAGS, fd, 0);
if (c == MAP_FAILED)
- err(EXIT_FATAL, "can't map %s (%s)", cachefile, strerror(errno));
+ err(EXIT_FAILURE, "can't map %s (%s)", cachefile, strerror(errno));
close(fd);
if (memcmp(((header_t *) c)->magic, LDSO_CACHE_MAGIC, LDSO_CACHE_MAGIC_LEN))
- err(EXIT_FATAL, "%s cache corrupt", cachefile);
+ err(EXIT_FAILURE, "%s cache corrupt", cachefile);
if (memcmp(((header_t *) c)->version, LDSO_CACHE_VER, LDSO_CACHE_VER_LEN))
- err(EXIT_FATAL, "wrong cache version - expected %s",
+ err(EXIT_FAILURE, "wrong cache version - expected %s",
LDSO_CACHE_VER);
header = (header_t *) c;
@@ -811,7 +785,7 @@ void cache_print(void)
}
#endif
-void usage(void)
+static attribute_noreturn void usage(void)
{
fprintf(stderr,
#ifdef __LDSO_CACHE_SUPPORT__
@@ -844,7 +818,7 @@ void usage(void)
"\tlib ... :\tlibraries to link\n\n"
#endif
);
- exit(EXIT_FATAL);
+ exit(EXIT_FAILURE);
}
#define DIR_SEP ":, \t\n"
@@ -917,11 +891,11 @@ int main(int argc, char **argv)
if (chroot_dir && *chroot_dir) {
if (chroot(chroot_dir) < 0) {
if (chdir(chroot_dir) < 0)
- err(EXIT_FATAL, "couldn't chroot to %s (%s)", chroot_dir, strerror(errno));
+ err(EXIT_FAILURE, "couldn't chroot to %s (%s)", chroot_dir, strerror(errno));
chroot_dir = ".";
} else {
if (chdir("/") < 0)
- err(EXIT_FATAL, "couldn't chdir to / (%s)", strerror(errno));
+ err(EXIT_FAILURE, "couldn't chdir to / (%s)", strerror(errno));
chroot_dir = NULL;
}
}
@@ -933,7 +907,7 @@ int main(int argc, char **argv)
if (printcache) {
/* print the cache -- don't you trust me? */
cache_print();
- exit(EXIT_OK);
+ exit(EXIT_SUCCESS);
} else if (libmode) {
/* so you want to do things manually, eh? */
@@ -953,7 +927,7 @@ int main(int argc, char **argv)
/* we'd better do a little bit of checking */
if ((so = is_shlib(dir, cp, &libtype, &islink, LIB_ANY)) == NULL)
- err(EXIT_FATAL, "%s%s%s is not a shared library",
+ err(EXIT_FAILURE, "%s%s%s is not a shared library",
dir, (*dir && strcmp(dir, "/")) ? "/" : "", cp);
/* so far, so good, maybe he knows what he's doing */
@@ -1006,5 +980,5 @@ int main(int argc, char **argv)
cache_write();
}
- exit(EXIT_OK);
+ exit(EXIT_SUCCESS);
}
diff --git a/utils/ldd.c b/utils/ldd.c
index 7818c3713..7fd4f7bb0 100644
--- a/utils/ldd.c
+++ b/utils/ldd.c
@@ -13,31 +13,18 @@
* Licensed under GPLv2 or later
*/
-#include <stdlib.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdint.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-
-#include "bswap.h"
-#include "link.h"
-#include "dl-defs.h"
-/* makefile will include elf.h for us */
-
-#ifdef DMALLOC
-#include <dmalloc.h>
-#endif
+#include "porting.h"
#if defined(__alpha__)
#define MATCH_MACHINE(x) (x == EM_ALPHA)
#define ELFCLASSM ELFCLASS64
#endif
+#if defined(__arc__)
+#define MATCH_MACHINE(x) (x == EM_ARCOMPACT)
+#define ELFCLASSM ELFCLASS32
+#endif
+
#if defined(__arm__) || defined(__thumb__)
#define MATCH_MACHINE(x) (x == EM_ARM)
#define ELFCLASSM ELFCLASS32
@@ -81,6 +68,11 @@
#define ELFCLASSM ELFCLASS32
#endif
+#if defined(__metag__)
+#define MATCH_MACHINE(x) (x == EM_METAG)
+#define ELFCLASSM ELFCLASS32
+#endif
+
#if defined(__mips__)
#define MATCH_MACHINE(x) (x == EM_MIPS || x == EM_MIPS_RS3_LE)
#define ELFCLASSM ELFCLASS32
@@ -99,11 +91,6 @@
#define ELFCLASSM ELFCLASS32
#endif
-#if defined(__v850e__)
-#define MATCH_MACHINE(x) ((x) == EM_V850 || (x) == EM_CYGNUS_V850)
-#define ELFCLASSM ELFCLASS32
-#endif
-
#if defined(__sparc__)
#define MATCH_MACHINE(x) ((x) == EM_SPARC || (x) == EM_SPARC32PLUS)
#define ELFCLASSM ELFCLASS32
@@ -119,6 +106,16 @@
#define ELFCLASSM ELFCLASS64
#endif
+#if defined(__microblaze__)
+#define MATCH_MACHINE(x) (x == EM_MICROBLAZE_OLD)
+#define ELFCLASSM ELFCLASS32
+#endif
+
+#if defined(__xtensa__)
+#define MATCH_MACHINE(x) (x == EM_XTENSA)
+#define ELFCLASSM ELFCLASS32
+#endif
+
#ifndef MATCH_MACHINE
# ifdef __linux__
# include <asm/elf.h>
@@ -134,15 +131,13 @@
# warning "You really should add a MATCH_MACHINE() macro for your architecture"
#endif
-#if __BYTE_ORDER == __LITTLE_ENDIAN
+#if UCLIBC_ENDIAN_HOST == UCLIBC_ENDIAN_LITTLE
#define ELFDATAM ELFDATA2LSB
-#elif __BYTE_ORDER == __BIG_ENDIAN
+#elif UCLIBC_ENDIAN_HOST == UCLIBC_ENDIAN_BIG
#define ELFDATAM ELFDATA2MSB
#endif
-#ifndef UCLIBC_RUNTIME_PREFIX
-# define UCLIBC_RUNTIME_PREFIX "/"
-#endif
+#define TRUSTED_LDSO UCLIBC_RUNTIME_PREFIX "lib/" UCLIBC_LDSO
struct library {
char *name;
@@ -150,16 +145,16 @@ struct library {
char *path;
struct library *next;
};
-struct library *lib_list = NULL;
-char not_found[] = "not found";
-char *interp_name = NULL;
-char *interp_dir = NULL;
+static struct library *lib_list = NULL;
+static char not_found[] = "not found";
+static char *interp_name = NULL;
+static char *interp_dir = NULL;
static int byteswap;
static int interpreter_already_found = 0;
static __inline__ uint32_t byteswap32_to_host(uint32_t value)
{
- if (byteswap == 1) {
+ if (byteswap) {
return (bswap_32(value));
} else {
return (value);
@@ -167,17 +162,17 @@ static __inline__ uint32_t byteswap32_to_host(uint32_t value)
}
static __inline__ uint64_t byteswap64_to_host(uint64_t value)
{
- if (byteswap == 1) {
+ if (byteswap) {
return (bswap_64(value));
} else {
return (value);
}
}
-#if ELFCLASSM == ELFCLASS32
-# define byteswap_to_host(x) byteswap32_to_host(x)
-#else
+#if __WORDSIZE == 64
# define byteswap_to_host(x) byteswap64_to_host(x)
+#else
+# define byteswap_to_host(x) byteswap32_to_host(x)
#endif
static ElfW(Shdr) *elf_find_section_type(uint32_t key, ElfW(Ehdr) *ehdr)
@@ -236,33 +231,21 @@ static char *elf_find_rpath(ElfW(Ehdr) *ehdr, ElfW(Dyn) *dynamic)
return NULL;
}
-int check_elf_header(ElfW(Ehdr) *const ehdr)
+static int check_elf_header(ElfW(Ehdr) *const ehdr)
{
- if (!ehdr || strncmp((char *)ehdr, ELFMAG, SELFMAG) != 0 ||
- ehdr->e_ident[EI_CLASS] != ELFCLASSM ||
- ehdr->e_ident[EI_VERSION] != EV_CURRENT)
- {
+ if (!ehdr || *(uint32_t*)ehdr != ELFMAG_U32
+ /* Use __WORDSIZE, not ELFCLASSM which depends on the host */
+ || ehdr->e_ident[EI_CLASS] != (__WORDSIZE >> 5)
+ || ehdr->e_ident[EI_VERSION] != EV_CURRENT
+ ) {
return 1;
}
/* Check if the target endianness matches the host's endianness */
- byteswap = 0;
-#if __BYTE_ORDER == __LITTLE_ENDIAN
- if (ehdr->e_ident[5] == ELFDATA2MSB) {
- /* Ick -- we will have to byte-swap everything */
- byteswap = 1;
- }
-#elif __BYTE_ORDER == __BIG_ENDIAN
- if (ehdr->e_ident[5] == ELFDATA2LSB) {
- /* Ick -- we will have to byte-swap everything */
- byteswap = 1;
- }
-#else
-#error Unknown host byte order!
-#endif
+ byteswap = !(ehdr->e_ident[5] == ELFDATAM);
- /* Be vary lazy, and only byteswap the stuff we use */
- if (byteswap == 1) {
+ /* Be very lazy, and only byteswap the stuff we use */
+ if (byteswap) {
ehdr->e_type = bswap_16(ehdr->e_type);
ehdr->e_phoff = byteswap_to_host(ehdr->e_phoff);
ehdr->e_shoff = byteswap_to_host(ehdr->e_shoff);
@@ -277,7 +260,7 @@ int check_elf_header(ElfW(Ehdr) *const ehdr)
static caddr_t cache_addr = NULL;
static size_t cache_size = 0;
-int map_cache(void)
+static int map_cache(void)
{
int fd;
struct stat st;
@@ -290,7 +273,7 @@ int map_cache(void)
else if (cache_addr != NULL)
return 0;
- if (stat(LDSO_CACHE, &st) || (fd = open(LDSO_CACHE, O_RDONLY, 0)) < 0) {
+ if (stat(LDSO_CACHE, &st) || (fd = open(LDSO_CACHE, O_RDONLY)) < 0) {
fprintf(stderr, "ldd: can't open cache '%s'\n", LDSO_CACHE);
cache_addr = (caddr_t) - 1; /* so we won't try again */
return -1;
@@ -334,7 +317,7 @@ fail:
return -1;
}
-int unmap_cache(void)
+static int unmap_cache(void)
{
if (cache_addr == NULL || cache_addr == (caddr_t) - 1)
return -1;
@@ -367,7 +350,7 @@ static void search_for_named_library(char *name, char *result,
/* We need a writable copy of this string */
path = strdup(path_list);
if (!path) {
- fprintf(stderr, "Out of memory!\n");
+ fprintf(stderr, "%s: Out of memory!\n", __func__);
exit(EXIT_FAILURE);
}
/* Eliminate all double //s */
@@ -400,8 +383,8 @@ static void search_for_named_library(char *name, char *result,
*result = '\0';
}
-void locate_library_file(ElfW(Ehdr) *ehdr, ElfW(Dyn) *dynamic, int is_suid,
- struct library *lib)
+static void locate_library_file(ElfW(Ehdr) *ehdr, ElfW(Dyn) *dynamic,
+ int is_suid, struct library *lib)
{
char *buf;
char *path;
@@ -416,7 +399,7 @@ void locate_library_file(ElfW(Ehdr) *ehdr, ElfW(Dyn) *dynamic, int is_suid,
/* We need some elbow room here. Make some room... */
buf = malloc(1024);
if (!buf) {
- fprintf(stderr, "Out of memory!\n");
+ fprintf(stderr, "%s: Out of memory!\n", __func__);
exit(EXIT_FAILURE);
}
@@ -519,13 +502,15 @@ static int add_library(ElfW(Ehdr) *ehdr, ElfW(Dyn) *dynamic, int is_setuid, char
for (cur = lib_list; cur; cur = cur->next) {
/* Check if this library is already in the list */
tmp1 = tmp2 = cur->name;
+ if (!cur->name)
+ continue;
while (*tmp1) {
if (*tmp1 == '/')
tmp2 = tmp1 + 1;
tmp1++;
}
if (strcmp(tmp2, s) == 0) {
- //printf("find_elf_interpreter is skipping '%s' (already in list)\n", cur->name);
+ /*printf("find_elf_interpreter is skipping '%s' (already in list)\n", cur->name); */
return 0;
}
}
@@ -543,7 +528,7 @@ static int add_library(ElfW(Ehdr) *ehdr, ElfW(Dyn) *dynamic, int is_setuid, char
/* Now try and locate where this library might be living... */
locate_library_file(ehdr, dynamic, is_setuid, newlib);
- //printf("add_library is adding '%s' to '%s'\n", newlib->name, newlib->path);
+ /*printf("add_library is adding '%s' to '%s'\n", newlib->name, newlib->path); */
if (!lib_list) {
lib_list = newlib;
} else {
@@ -566,6 +551,7 @@ static void find_needed_libraries(ElfW(Ehdr) *ehdr, ElfW(Dyn) *dynamic, int is_s
}
}
+#ifdef __LDSO_LDD_SUPPORT__
static struct library *find_elf_interpreter(ElfW(Ehdr) *ehdr)
{
ElfW(Phdr) *phdr;
@@ -581,7 +567,7 @@ static struct library *find_elf_interpreter(ElfW(Ehdr) *ehdr)
interp_name = strdup(s);
interp_dir = strdup(s);
tmp = strrchr(interp_dir, '/');
- if (*tmp)
+ if (tmp)
*tmp = '\0';
else {
free(interp_dir);
@@ -595,8 +581,10 @@ static struct library *find_elf_interpreter(ElfW(Ehdr) *ehdr)
}
for (cur = lib_list; cur; cur = cur->next) {
/* Check if this library is already in the list */
+ if (!tmp1 || !cur->name)
+ return NULL;
if (strcmp(cur->name, tmp1) == 0) {
- //printf("find_elf_interpreter is replacing '%s' (already in list)\n", cur->name);
+ /*printf("find_elf_interpreter is replacing '%s' (already in list)\n", cur->name); */
newlib = cur;
free(newlib->name);
if (newlib->path != not_found) {
@@ -604,7 +592,7 @@ static struct library *find_elf_interpreter(ElfW(Ehdr) *ehdr)
}
newlib->name = NULL;
newlib->path = NULL;
- return NULL;
+ break;
}
}
if (newlib == NULL)
@@ -618,7 +606,7 @@ static struct library *find_elf_interpreter(ElfW(Ehdr) *ehdr)
newlib->next = NULL;
#if 0
- //printf("find_elf_interpreter is adding '%s' to '%s'\n", newlib->name, newlib->path);
+ /*printf("find_elf_interpreter is adding '%s' to '%s'\n", newlib->name, newlib->path); */
if (!lib_list) {
lib_list = newlib;
} else {
@@ -631,20 +619,23 @@ static struct library *find_elf_interpreter(ElfW(Ehdr) *ehdr)
}
return NULL;
}
+#endif /* __LDSO_LDD_SUPPORT__ */
/* map the .so, and locate interesting pieces */
/*
#warning "There may be two warnings here about vfork() clobbering, ignore them"
*/
-int find_dependancies(char *filename)
+static int find_dependencies(char *filename)
{
int is_suid = 0;
FILE *thefile;
- struct library *interp;
struct stat statbuf;
ElfW(Ehdr) *ehdr = NULL;
ElfW(Shdr) *dynsec = NULL;
ElfW(Dyn) *dynamic = NULL;
+#ifdef __LDSO_LDD_SUPPORT__
+ struct library *interp;
+#endif
if (filename == not_found)
return 0;
@@ -673,7 +664,7 @@ int find_dependancies(char *filename)
ehdr = mmap(0, statbuf.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fileno(thefile), 0);
if (ehdr == MAP_FAILED) {
fclose(thefile);
- fprintf(stderr, "Out of memory!\n");
+ fprintf(stderr, "mmap(%s) failed: %s\n", filename, strerror(errno));
return -1;
}
@@ -701,9 +692,9 @@ foo:
}
interpreter_already_found = 0;
+#ifdef __LDSO_LDD_SUPPORT__
interp = find_elf_interpreter(ehdr);
-#ifdef __LDSO_LDD_SUPPORT__
if (interp
&& (ehdr->e_type == ET_EXEC || ehdr->e_type == ET_DYN)
&& ehdr->e_ident[EI_CLASS] == ELFCLASSM
@@ -711,8 +702,8 @@ foo:
&& ehdr->e_ident[EI_VERSION] == EV_CURRENT
&& MATCH_MACHINE(ehdr->e_machine))
{
- struct stat statbuf;
- if (stat(interp->path, &statbuf) == 0 && S_ISREG(statbuf.st_mode)) {
+ struct stat st;
+ if (stat(interp->path, &st) == 0 && S_ISREG(st.st_mode)) {
pid_t pid;
int status;
static const char *const environment[] = {
@@ -721,16 +712,59 @@ foo:
"LD_TRACE_LOADED_OBJECTS=1",
NULL
};
-
+# ifdef __LDSO_STANDALONE_SUPPORT__
+ char * lib_path = getenv("LD_LIBRARY_PATH");
+
+ /* The 'extended' environment inclusing the LD_LIBRARY_PATH */
+ static char *ext_environment[ARRAY_SIZE(environment) + 1];
+ char **envp = (char **) environment;
+
+ if (lib_path) {
+ /*
+ * If the LD_LIBRARY_PATH is set, it needs to include it
+ * into the environment for the new process to be spawned
+ */
+ char ** eenvp = (char **) ext_environment;
+
+ /* Copy the N-1 environment's entries */
+ while (*envp)
+ *eenvp++=*envp++;
+
+ /* Make room for LD_LIBRARY_PATH */
+ *eenvp = (char *) malloc(sizeof("LD_LIBRARY_PATH=")
+ + strlen(lib_path));
+ strcpy(*eenvp, "LD_LIBRARY_PATH=");
+ strcat(*eenvp, lib_path);
+ lib_path = *eenvp;
+ /* ext_environment[size] is already NULL */
+
+ /* Use the extended environment */
+ envp = ext_environment;
+ }
+ if ((pid = vfork()) == 0) {
+ /*
+ * Force to use the standard dynamic linker in stand-alone mode.
+ * It will fails at runtime if support is not actually available
+ */
+ execle(TRUSTED_LDSO, TRUSTED_LDSO, filename, NULL, envp);
+ _exit(0xdead);
+ }
+# else
if ((pid = vfork()) == 0) {
/* Cool, it looks like we should be able to actually
* run this puppy. Do so now... */
execle(filename, filename, NULL, environment);
_exit(0xdead);
}
-
+# endif
/* Wait till it returns */
waitpid(pid, &status, 0);
+
+# ifdef __LDSO_STANDALONE_SUPPORT__
+ /* Do not leak */
+ free(lib_path);
+# endif
+
if (WIFEXITED(status) && WEXITSTATUS(status) == 0) {
return 1;
}
@@ -759,8 +793,8 @@ int main(int argc, char **argv)
struct library *cur;
if (argc < 2) {
- fprintf(stderr, "ldd: missing file arguments\n");
- fprintf(stderr, "Try `ldd --help' for more information.\n");
+ fprintf(stderr, "ldd: missing file arguments\n"
+ "Try `ldd --help' for more information.\n");
exit(EXIT_FAILURE);
}
if (argc > 2)
@@ -775,8 +809,8 @@ int main(int argc, char **argv)
}
if (strcmp(*argv, "--help") == 0 || strcmp(*argv, "-h") == 0) {
- fprintf(stderr, "Usage: ldd [OPTION]... FILE...\n");
- fprintf(stderr, "\t--help\t\tprint this help and exit\n");
+ fprintf(stderr, "Usage: ldd [OPTION]... FILE...\n"
+ "\t--help\t\tprint this help and exit\n");
exit(EXIT_SUCCESS);
}
@@ -792,7 +826,7 @@ int main(int argc, char **argv)
map_cache();
- if (find_dependancies(filename) != 0)
+ if (find_dependencies(filename) != 0)
continue;
while (got_em_all) {
@@ -802,7 +836,7 @@ int main(int argc, char **argv)
if (cur->resolved == 0 && cur->path) {
got_em_all = 1;
printf("checking sub-depends for '%s'\n", cur->path);
- find_dependancies(cur->path);
+ find_dependencies(cur->path);
cur->resolved = 1;
}
}
diff --git a/utils/mmap-windows.c b/utils/mmap-windows.c
new file mode 100644
index 000000000..1799392f0
--- /dev/null
+++ b/utils/mmap-windows.c
@@ -0,0 +1,100 @@
+/* mmap() replacement for Windows
+ *
+ * Author: Mike Frysinger <vapier@gentoo.org>
+ * Placed into the public domain
+ */
+
+/* References:
+ * CreateFileMapping: http://msdn.microsoft.com/en-us/library/aa366537(VS.85).aspx
+ * CloseHandle: http://msdn.microsoft.com/en-us/library/ms724211(VS.85).aspx
+ * MapViewOfFile: http://msdn.microsoft.com/en-us/library/aa366761(VS.85).aspx
+ * UnmapViewOfFile: http://msdn.microsoft.com/en-us/library/aa366882(VS.85).aspx
+ */
+
+#include <io.h>
+#include <windows.h>
+#include <sys/types.h>
+
+#define PROT_READ 0x1
+#define PROT_WRITE 0x2
+/* This flag is only available in WinXP+ */
+#ifdef FILE_MAP_EXECUTE
+#define PROT_EXEC 0x4
+#else
+#define PROT_EXEC 0x0
+#define FILE_MAP_EXECUTE 0
+#endif
+
+#define MAP_SHARED 0x01
+#define MAP_PRIVATE 0x02
+#define MAP_ANONYMOUS 0x20
+#define MAP_ANON MAP_ANONYMOUS
+#define MAP_FAILED ((void *) -1)
+
+#ifdef __USE_FILE_OFFSET64
+# define DWORD_HI(x) (x >> 32)
+# define DWORD_LO(x) ((x) & 0xffffffff)
+#else
+# define DWORD_HI(x) (0)
+# define DWORD_LO(x) (x)
+#endif
+
+static void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset)
+{
+ if (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC))
+ return MAP_FAILED;
+ if (fd == -1) {
+ if (!(flags & MAP_ANON) || offset)
+ return MAP_FAILED;
+ } else if (flags & MAP_ANON)
+ return MAP_FAILED;
+
+ DWORD flProtect;
+ if (prot & PROT_WRITE) {
+ if (prot & PROT_EXEC)
+ flProtect = PAGE_EXECUTE_READWRITE;
+ else
+ flProtect = PAGE_READWRITE;
+ } else if (prot & PROT_EXEC) {
+ if (prot & PROT_READ)
+ flProtect = PAGE_EXECUTE_READ;
+ else if (prot & PROT_EXEC)
+ flProtect = PAGE_EXECUTE;
+ } else
+ flProtect = PAGE_READONLY;
+
+ off_t end = length + offset;
+ HANDLE mmap_fd, h;
+ if (fd == -1)
+ mmap_fd = INVALID_HANDLE_VALUE;
+ else
+ mmap_fd = (HANDLE)_get_osfhandle(fd);
+ h = CreateFileMapping(mmap_fd, NULL, flProtect, DWORD_HI(end), DWORD_LO(end), NULL);
+ if (h == NULL)
+ return MAP_FAILED;
+
+ DWORD dwDesiredAccess;
+ if (prot & PROT_WRITE)
+ dwDesiredAccess = FILE_MAP_WRITE;
+ else
+ dwDesiredAccess = FILE_MAP_READ;
+ if (prot & PROT_EXEC)
+ dwDesiredAccess |= FILE_MAP_EXECUTE;
+ if (flags & MAP_PRIVATE)
+ dwDesiredAccess |= FILE_MAP_COPY;
+ void *ret = MapViewOfFile(h, dwDesiredAccess, DWORD_HI(offset), DWORD_LO(offset), length);
+ if (ret == NULL) {
+ CloseHandle(h);
+ ret = MAP_FAILED;
+ }
+ return ret;
+}
+
+static void munmap(void *addr, size_t length)
+{
+ UnmapViewOfFile(addr);
+ /* ruh-ro, we leaked handle from CreateFileMapping() ... */
+}
+
+#undef DWORD_HI
+#undef DWORD_LO
diff --git a/utils/porting.h b/utils/porting.h
new file mode 100644
index 000000000..f83074111
--- /dev/null
+++ b/utils/porting.h
@@ -0,0 +1,97 @@
+/* Misc system-specific crap */
+
+#ifndef _PORTING_H_
+#define _PORTING_H_
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <ctype.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#ifdef __LDSO_LDD_SUPPORT__
+# include <sys/wait.h>
+#endif
+
+#if defined(_WIN32) || defined(_WINNT)
+# include "mmap-windows.c"
+#else
+# include <sys/mman.h>
+#endif
+
+#ifdef BUILDING_LINKAGE
+#include <link.h>
+/* makefile will include elf.h for us */
+
+#include "bswap.h"
+#include "dl-defs.h"
+#endif
+
+/* __WORDSIZE ist used for __ELF_NATIVE_CLASS, which is used for ElfW().
+ We want to provide the wordsize of the target, not of the host, when
+ compiling readelf.host
+ */
+#include <link.h>
+#ifdef ARCH_NATIVE_BIT
+#undef __WORDSIZE
+#define __WORDSIZE ARCH_NATIVE_BIT
+#endif
+
+#ifdef DMALLOC
+#include <dmalloc.h>
+#endif
+
+#ifndef ARRAY_SIZE
+# define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+#endif
+
+/* For SunOS */
+#ifndef PATH_MAX
+#define PATH_MAX _POSIX_PATH_MAX
+#endif
+
+#ifndef UCLIBC_RUNTIME_PREFIX
+# define UCLIBC_RUNTIME_PREFIX "/"
+#endif
+
+#undef UCLIBC_ENDIAN_HOST
+#define UCLIBC_ENDIAN_LITTLE 1234
+#define UCLIBC_ENDIAN_BIG 4321
+#if defined(BYTE_ORDER)
+# if BYTE_ORDER == LITTLE_ENDIAN
+# define UCLIBC_ENDIAN_HOST UCLIBC_ENDIAN_LITTLE
+# elif BYTE_ORDER == BIG_ENDIAN
+# define UCLIBC_ENDIAN_HOST UCLIBC_ENDIAN_BIG
+# endif
+#elif defined(__BYTE_ORDER)
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+# define UCLIBC_ENDIAN_HOST UCLIBC_ENDIAN_LITTLE
+# elif __BYTE_ORDER == __BIG_ENDIAN
+# define UCLIBC_ENDIAN_HOST UCLIBC_ENDIAN_BIG
+# endif
+#endif
+#if !defined(UCLIBC_ENDIAN_HOST)
+# error "Unknown host byte order!"
+#endif
+
+#if defined __GNUC__ || defined __ICC
+# define attribute_noreturn __attribute__ ((__noreturn__))
+#else
+# define attribute_noreturn
+#endif
+
+#endif
diff --git a/utils/readelf.c b/utils/readelf.c
deleted file mode 100644
index 2af4b5ca9..000000000
--- a/utils/readelf.c
+++ /dev/null
@@ -1,363 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * A small little readelf implementation for uClibc
- *
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- *
- * Several functions in this file (specifically, elf_find_section_type(),
- * elf_find_phdr_type(), and elf_find_dynamic(), were stolen from elflib.c from
- * elfvector (http://www.BitWagon.com/elfvector.html) by John F. Reiser
- * <jreiser@BitWagon.com>, which is copyright 2000 BitWagon Software LLC
- * (GPL2).
- *
- * Licensed under GPLv2 or later
- */
-
-
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-#include "bswap.h"
-#include "link.h"
-/* makefile will include elf.h for us */
-
-static int byteswap;
-static __inline__ uint32_t byteswap32_to_host(uint32_t value)
-{
- if (byteswap==1) {
- return(bswap_32(value));
- } else {
- return(value);
- }
-}
-static __inline__ uint64_t byteswap64_to_host(uint64_t value)
-{
- if (byteswap==1) {
- return(bswap_64(value));
- } else {
- return(value);
- }
-}
-#if __WORDSIZE == 64
-# define byteswap_to_host(x) byteswap64_to_host(x)
-#else
-# define byteswap_to_host(x) byteswap32_to_host(x)
-#endif
-
-static ElfW(Shdr) * elf_find_section_type( uint32_t key, ElfW(Ehdr) *ehdr)
-{
- int j;
- ElfW(Shdr) *shdr = (ElfW(Shdr) *)(ehdr->e_shoff + (char *)ehdr);
- for (j = ehdr->e_shnum; --j>=0; ++shdr) {
- if (key==byteswap32_to_host(shdr->sh_type)) {
- return shdr;
- }
- }
- return NULL;
-}
-
-static ElfW(Phdr) * elf_find_phdr_type( uint32_t type, ElfW(Ehdr) *ehdr)
-{
- int j;
- ElfW(Phdr) *phdr = (ElfW(Phdr) *)(ehdr->e_phoff + (char *)ehdr);
- for (j = ehdr->e_phnum; --j>=0; ++phdr) {
- if (type==byteswap32_to_host(phdr->p_type)) {
- return phdr;
- }
- }
- return NULL;
-}
-
-/* Returns value if return_val==1, ptr otherwise */
-static void * elf_find_dynamic( int64_t const key, ElfW(Dyn) *dynp,
- ElfW(Ehdr) *ehdr, int return_val)
-{
- ElfW(Phdr) *pt_text = elf_find_phdr_type(PT_LOAD, ehdr);
- ElfW(Addr) tx_reloc = byteswap_to_host(pt_text->p_vaddr) - byteswap_to_host(pt_text->p_offset);
- for (; DT_NULL!=byteswap_to_host(dynp->d_tag); ++dynp) {
- if (key == byteswap_to_host(dynp->d_tag)) {
- if (return_val == 1)
- return (void *)byteswap_to_host(dynp->d_un.d_val);
- else
- return (void *)(byteswap_to_host(dynp->d_un.d_val) - tx_reloc + (char *)ehdr );
- }
- }
- return NULL;
-}
-
-static int check_elf_header(ElfW(Ehdr) *const ehdr)
-{
- if (! ehdr || strncmp((void *)ehdr, ELFMAG, SELFMAG) != 0 ||
- (ehdr->e_ident[EI_CLASS] != ELFCLASS32 &&
- ehdr->e_ident[EI_CLASS] != ELFCLASS64) ||
- ehdr->e_ident[EI_VERSION] != EV_CURRENT)
- {
- return 1;
- }
-
- /* Check if the target endianness matches the host's endianness */
- byteswap = 0;
-#if __BYTE_ORDER == __LITTLE_ENDIAN
- if (ehdr->e_ident[5] == ELFDATA2MSB) {
- /* Ick -- we will have to byte-swap everything */
- byteswap = 1;
- }
-#elif __BYTE_ORDER == __BIG_ENDIAN
- if (ehdr->e_ident[5] == ELFDATA2LSB) {
- byteswap = 1;
- }
-#else
-#error Unknown host byte order!
-#endif
- /* Be vary lazy, and only byteswap the stuff we use */
- if (byteswap==1) {
- ehdr->e_type=bswap_16(ehdr->e_type);
- ehdr->e_machine=bswap_16(ehdr->e_machine);
- ehdr->e_phoff=byteswap_to_host(ehdr->e_phoff);
- ehdr->e_shoff=byteswap_to_host(ehdr->e_shoff);
- ehdr->e_phnum=bswap_16(ehdr->e_phnum);
- ehdr->e_shnum=bswap_16(ehdr->e_shnum);
- }
- return 0;
-}
-
-
-static void describe_elf_hdr(ElfW(Ehdr)* ehdr)
-{
- char *tmp, *tmp1;
-
- switch (ehdr->e_type) {
- case ET_NONE: tmp = "None"; tmp1 = "NONE"; break;
- case ET_REL: tmp = "Relocatable File"; tmp1 = "REL"; break;
- case ET_EXEC: tmp = "Executable file"; tmp1 = "EXEC"; break;
- case ET_DYN: tmp = "Shared object file"; tmp1 = "DYN"; break;
- case ET_CORE: tmp = "Core file"; tmp1 = "CORE"; break;
- default:
- tmp = tmp1 = "Unknown";
- }
- printf( "Type:\t\t%s (%s)\n", tmp1, tmp);
-
- switch (ehdr->e_machine) {
- case EM_NONE: tmp="No machine"; break;
- case EM_M32: tmp="AT&T WE 32100"; break;
- case EM_SPARC: tmp="SUN SPARC"; break;
- case EM_386: tmp="Intel 80386"; break;
- case EM_68K: tmp="Motorola m68k family"; break;
- case EM_88K: tmp="Motorola m88k family"; break;
- case EM_486: tmp="Intel 80486"; break;
- case EM_860: tmp="Intel 80860"; break;
- case EM_MIPS: tmp="MIPS R3000 big-endian"; break;
- case EM_S370: tmp="IBM System/370"; break;
- case EM_MIPS_RS3_LE: tmp="MIPS R3000 little-endian"; break;
- case EM_OLD_SPARCV9: tmp="Sparc v9 (old)"; break;
- case EM_PARISC: tmp="HPPA"; break;
- /*case EM_PPC_OLD: tmp="Power PC (old)"; break; conflicts with EM_VPP500 */
- case EM_SPARC32PLUS: tmp="Sun's v8plus"; break;
- case EM_960: tmp="Intel 80960"; break;
- case EM_PPC: tmp="PowerPC"; break;
- case EM_PPC64: tmp="PowerPC 64-bit"; break;
- case EM_V800: tmp="NEC V800 series"; break;
- case EM_FR20: tmp="Fujitsu FR20"; break;
- case EM_RH32: tmp="TRW RH-32"; break;
- case EM_MCORE: tmp="MCORE"; break;
- case EM_ARM: tmp="ARM"; break;
- case EM_FAKE_ALPHA: tmp="Digital Alpha"; break;
- case EM_SH: tmp="Renesas SH"; break;
- case EM_SPARCV9: tmp="SPARC v9 64-bit"; break;
- case EM_TRICORE: tmp="Siemens Tricore"; break;
- case EM_ARC: tmp="Argonaut RISC Core"; break;
- case EM_H8_300: tmp="Renesas H8/300"; break;
- case EM_H8_300H: tmp="Renesas H8/300H"; break;
- case EM_H8S: tmp="Renesas H8S"; break;
- case EM_H8_500: tmp="Renesas H8/500"; break;
- case EM_IA_64: tmp="Intel Merced"; break;
- case EM_MIPS_X: tmp="Stanford MIPS-X"; break;
- case EM_COLDFIRE: tmp="Motorola Coldfire"; break;
- case EM_68HC12: tmp="Motorola M68HC12"; break;
- case EM_ALPHA: tmp="Alpha"; break;
- case EM_CYGNUS_D10V:
- case EM_D10V: tmp="Mitsubishi D10V"; break;
- case EM_CYGNUS_D30V:
- case EM_D30V: tmp="Mitsubishi D30V"; break;
- case EM_CYGNUS_M32R:
- case EM_M32R: tmp="Renesas M32R (formerly Mitsubishi M32r)"; break;
- case EM_CYGNUS_V850:
- case EM_V850: tmp="NEC v850"; break;
- case EM_CYGNUS_MN10300:
- case EM_MN10300: tmp="Matsushita MN10300"; break;
- case EM_CYGNUS_MN10200:
- case EM_MN10200: tmp="Matsushita MN10200"; break;
- case EM_CYGNUS_FR30:
- case EM_FR30: tmp="Fujitsu FR30"; break;
- case EM_CYGNUS_FRV:
- case EM_PJ_OLD:
- case EM_PJ: tmp="picoJava"; break;
- case EM_MMA: tmp="Fujitsu MMA Multimedia Accelerator"; break;
- case EM_PCP: tmp="Siemens PCP"; break;
- case EM_NCPU: tmp="Sony nCPU embeeded RISC"; break;
- case EM_NDR1: tmp="Denso NDR1 microprocessor"; break;
- case EM_STARCORE: tmp="Motorola Start*Core processor"; break;
- case EM_ME16: tmp="Toyota ME16 processor"; break;
- case EM_ST100: tmp="STMicroelectronic ST100 processor"; break;
- case EM_TINYJ: tmp="Advanced Logic Corp. Tinyj emb.fam"; break;
- case EM_FX66: tmp="Siemens FX66 microcontroller"; break;
- case EM_ST9PLUS: tmp="STMicroelectronics ST9+ 8/16 mc"; break;
- case EM_ST7: tmp="STmicroelectronics ST7 8 bit mc"; break;
- case EM_68HC16: tmp="Motorola MC68HC16 microcontroller"; break;
- case EM_68HC11: tmp="Motorola MC68HC11 microcontroller"; break;
- case EM_68HC08: tmp="Motorola MC68HC08 microcontroller"; break;
- case EM_68HC05: tmp="Motorola MC68HC05 microcontroller"; break;
- case EM_SVX: tmp="Silicon Graphics SVx"; break;
- case EM_ST19: tmp="STMicroelectronics ST19 8 bit mc"; break;
- case EM_VAX: tmp="Digital VAX"; break;
- case EM_AVR_OLD:
- case EM_AVR: tmp="Atmel AVR 8-bit microcontroller"; break;
- case EM_CRIS: tmp="Axis Communications 32-bit embedded processor"; break;
- case EM_JAVELIN: tmp="Infineon Technologies 32-bit embedded processor"; break;
- case EM_FIREPATH: tmp="Element 14 64-bit DSP Processor"; break;
- case EM_ZSP: tmp="LSI Logic 16-bit DSP Processor"; break;
- case EM_MMIX: tmp="Donald Knuth's educational 64-bit processor"; break;
- case EM_HUANY: tmp="Harvard University machine-independent object files"; break;
- case EM_PRISM: tmp="SiTera Prism"; break;
- case EM_X86_64: tmp="AMD x86-64 architecture"; break;
- case EM_S390_OLD:
- case EM_S390: tmp="IBM S390"; break;
- case EM_XSTORMY16: tmp="Sanyo Xstormy16 CPU core"; break;
- case EM_OPENRISC:
- case EM_OR32: tmp="OpenRISC"; break;
- case EM_CRX: tmp="National Semiconductor CRX microprocessor"; break;
- case EM_DLX: tmp="OpenDLX"; break;
- case EM_IP2K_OLD:
- case EM_IP2K: tmp="Ubicom IP2xxx 8-bit microcontrollers"; break;
- case EM_IQ2000: tmp="Vitesse IQ2000"; break;
- case EM_XTENSA_OLD:
- case EM_XTENSA: tmp="Tensilica Xtensa Processor"; break;
- case EM_M32C: tmp="Renesas M32c"; break;
- case EM_MT: tmp="Morpho Techologies MT processor"; break;
- case EM_BLACKFIN: tmp="Analog Devices Blackfin"; break;
- case EM_NIOS32: tmp="Altera Nios 32"; break;
- case EM_ALTERA_NIOS2: tmp="Altera Nios II"; break;
- case EM_VPP500: tmp="Fujitsu VPP500"; break;
- case EM_PDSP: tmp="Sony DSP Processor"; break;
- default: tmp="unknown";
- }
- printf( "Machine:\t%s\n", tmp);
-
- switch (ehdr->e_ident[EI_CLASS]) {
- case ELFCLASSNONE: tmp = "Invalid class"; break;
- case ELFCLASS32: tmp = "ELF32"; break;
- case ELFCLASS64: tmp = "ELF64"; break;
- default: tmp = "Unknown";
- }
- printf( "Class:\t\t%s\n", tmp);
-
- switch (ehdr->e_ident[EI_DATA]) {
- case ELFDATANONE: tmp = "Invalid data encoding"; break;
- case ELFDATA2LSB: tmp = "2's complement, little endian"; break;
- case ELFDATA2MSB: tmp = "2's complement, big endian"; break;
- default: tmp = "Unknown";
- }
- printf( "Data:\t\t%s\n", tmp);
-
- printf( "Version:\t%d %s\n", ehdr->e_ident[EI_VERSION],
- (ehdr->e_ident[EI_VERSION]==EV_CURRENT)?
- "(current)" : "(unknown: %lx)");
-
- switch (ehdr->e_ident[EI_OSABI]) {
- case ELFOSABI_SYSV: tmp ="UNIX - System V"; break;
- case ELFOSABI_HPUX: tmp ="UNIX - HP-UX"; break;
- case ELFOSABI_NETBSD: tmp ="UNIX - NetBSD"; break;
- case ELFOSABI_LINUX: tmp ="UNIX - Linux"; break;
- case ELFOSABI_HURD: tmp ="GNU/Hurd"; break;
- case ELFOSABI_SOLARIS: tmp ="UNIX - Solaris"; break;
- case ELFOSABI_AIX: tmp ="UNIX - AIX"; break;
- case ELFOSABI_IRIX: tmp ="UNIX - IRIX"; break;
- case ELFOSABI_FREEBSD: tmp ="UNIX - FreeBSD"; break;
- case ELFOSABI_TRU64: tmp ="UNIX - TRU64"; break;
- case ELFOSABI_MODESTO: tmp ="Novell - Modesto"; break;
- case ELFOSABI_OPENBSD: tmp ="UNIX - OpenBSD"; break;
- case ELFOSABI_STANDALONE: tmp ="Standalone App"; break;
- case ELFOSABI_ARM: tmp ="ARM"; break;
- default: tmp = "Unknown";
- }
- printf( "OS/ABI:\t\t%s\n", tmp);
-
- printf( "ABI Version:\t%d\n", ehdr->e_ident[EI_ABIVERSION]);
-}
-
-static void list_needed_libraries(ElfW(Dyn)* dynamic, char *strtab)
-{
- ElfW(Dyn) *dyns;
-
- printf("Dependancies:\n");
- for (dyns=dynamic; byteswap_to_host(dyns->d_tag)!=DT_NULL; ++dyns) {
- if (dyns->d_tag == DT_NEEDED) {
- printf("\t%s\n", (char*)strtab + byteswap_to_host(dyns->d_un.d_val));
- }
- }
-}
-
-static void describe_elf_interpreter(ElfW(Ehdr)* ehdr)
-{
- ElfW(Phdr) *phdr;
- phdr = elf_find_phdr_type(PT_INTERP, ehdr);
- if (phdr) {
- printf("Interpreter:\t%s\n", (char*)ehdr + byteswap_to_host(phdr->p_offset));
- }
-}
-
-int main( int argc, char** argv)
-{
- /* map the .so, and locate interesting pieces */
- char *dynstr;
- char *thefilename = argv[1];
- FILE *thefile;
- struct stat statbuf;
- ElfW(Ehdr) *ehdr = 0;
- ElfW(Shdr) *dynsec;
- ElfW(Dyn) *dynamic;
-
- if (argc < 2 || !thefilename) {
- fprintf(stderr, "No filename specified.\n");
- exit(EXIT_FAILURE);
- }
- if (!(thefile = fopen(thefilename, "r"))) {
- perror(thefilename);
- exit(EXIT_FAILURE);
- }
- if (fstat(fileno(thefile), &statbuf) < 0) {
- perror(thefilename);
- exit(EXIT_FAILURE);
- }
-
- if ((size_t)statbuf.st_size < sizeof(ElfW(Ehdr)))
- goto foo;
-
- /* mmap the file to make reading stuff from it effortless */
- ehdr = (ElfW(Ehdr) *)mmap(0, statbuf.st_size,
- PROT_READ|PROT_WRITE, MAP_PRIVATE, fileno(thefile), 0);
-
-foo:
- /* Check if this looks legit */
- if (check_elf_header(ehdr)) {
- fprintf(stderr, "This does not appear to be an ELF file.\n");
- exit(EXIT_FAILURE);
- }
- describe_elf_hdr(ehdr);
- describe_elf_interpreter(ehdr);
-
- dynsec = elf_find_section_type(SHT_DYNAMIC, ehdr);
- if (dynsec) {
- dynamic = (ElfW(Dyn)*)(byteswap_to_host(dynsec->sh_offset) + (char *)ehdr);
- dynstr = (char *)elf_find_dynamic(DT_STRTAB, dynamic, ehdr, 0);
- list_needed_libraries(dynamic, dynstr);
- }
-
- return 0;
-}
diff --git a/utils/readsoname2.c b/utils/readsoname2.c
index 6a9f00775..5cda3318d 100644
--- a/utils/readsoname2.c
+++ b/utils/readsoname2.c
@@ -1,4 +1,4 @@
-char *readsonameXX(char *name, FILE *infile, int expected_type, int *type)
+static char *readsonameXX(char *name, FILE *infile, int expected_type, int *type)
{
ElfW(Ehdr) *epnt;
ElfW(Phdr) *ppnt;
@@ -35,13 +35,11 @@ char *readsonameXX(char *name, FILE *infile, int expected_type, int *type)
if ((char *)(epnt + 1) > (char *)(header + st.st_size))
goto skip;
-#if __BYTE_ORDER == __LITTLE_ENDIAN
- byteswap = (epnt->e_ident[5] == ELFDATA2MSB) ? 1 : 0;
-#elif __BYTE_ORDER == __BIG_ENDIAN
- byteswap = (epnt->e_ident[5] == ELFDATA2LSB) ? 1 : 0;
-#else
-#error Unknown host byte order!
-#endif
+ if (UCLIBC_ENDIAN_HOST == UCLIBC_ENDIAN_LITTLE)
+ byteswap = (epnt->e_ident[5] == ELFDATA2MSB) ? 1 : 0;
+ else if (UCLIBC_ENDIAN_HOST == UCLIBC_ENDIAN_BIG)
+ byteswap = (epnt->e_ident[5] == ELFDATA2LSB) ? 1 : 0;
+
/* Be very lazy, and only byteswap the stuff we use */
if (byteswap == 1) {
epnt->e_phoff = bswap_32(epnt->e_phoff);